@hienlh/ppm 0.17.17 → 0.17.18
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/CHANGELOG.md +5 -0
- package/assets/skills/ppm/SKILL.md +1 -1
- package/assets/skills/ppm/references/http-api.md +1 -1
- package/dist/web/assets/{ai-resource-editor-37UxM2lK.js → ai-resource-editor-BgWg-ty8.js} +1 -1
- package/dist/web/assets/{audio-preview-BG8uEB67.js → audio-preview-CLn1LTxc.js} +1 -1
- package/dist/web/assets/{chat-tab-6G5LulPM.js → chat-tab-tTUVo4G3.js} +2 -2
- package/dist/web/assets/{code-editor-BlBFI3jn.js → code-editor-DMfUjdk5.js} +2 -2
- package/dist/web/assets/{conflict-editor-CYZjqn46.js → conflict-editor-BosR4PW3.js} +1 -1
- package/dist/web/assets/{csv-preview-YxR9adj_.js → csv-preview-BqszurHp.js} +1 -1
- package/dist/web/assets/{database-viewer-CrdTyPIN.js → database-viewer-CiomoOU6.js} +1 -1
- package/dist/web/assets/{diff-viewer-DiYj_kRC.js → diff-viewer-aOrOaGWx.js} +1 -1
- package/dist/web/assets/{docx-preview-Dsrm2Hgu.js → docx-preview-BAzpJdua.js} +1 -1
- package/dist/web/assets/{extension-webview-B8ph2gI9.js → extension-webview-CKUUvgOr.js} +1 -1
- package/dist/web/assets/{git-log-panel-qIsOpM57.js → git-log-panel-B6GFWhj4.js} +1 -1
- package/dist/web/assets/{glide-data-grid-BrQskOnP.js → glide-data-grid-z9FPvRBG.js} +1 -1
- package/dist/web/assets/{group-chat-tab-DYgRs0zS.js → group-chat-tab-Bu31mwmF.js} +1 -1
- package/dist/web/assets/{image-preview-B9EWGEFv.js → image-preview-CaX4gpN6.js} +1 -1
- package/dist/web/assets/{index-BiHrB3KU.js → index-4M24PSHW.js} +5 -5
- package/dist/web/assets/keybindings-store-Cv-U85V6.js +1 -0
- package/dist/web/assets/{markdown-renderer-B4rtk2Hq.js → markdown-renderer-BNXJygz9.js} +1 -1
- package/dist/web/assets/{markdown-renderer-XIhxiUQq.js → markdown-renderer-DCsEEdo7.js} +1 -1
- package/dist/web/assets/notification-store-DADt1gJH.js +1 -0
- package/dist/web/assets/{pdf-preview-Zl3KICd5.js → pdf-preview-DZzbm9A4.js} +1 -1
- package/dist/web/assets/{postgres-viewer-BTupZTmP.js → postgres-viewer-BxpeiVkt.js} +1 -1
- package/dist/web/assets/{settings-tab-BF069B1K.js → settings-tab-DJOhpW09.js} +1 -1
- package/dist/web/assets/{sql-query-editor-RwHY1p-a.js → sql-query-editor-9TwIPvRj.js} +1 -1
- package/dist/web/assets/{sqlite-viewer-3UxftoM7.js → sqlite-viewer-D-3i_x28.js} +1 -1
- package/dist/web/assets/{system-monitor-tab-Ck1cIP7g.js → system-monitor-tab-CuVVp2wt.js} +1 -1
- package/dist/web/assets/{terminal-tab-B9opPxft.js → terminal-tab-DrSqSrdX.js} +1 -1
- package/dist/web/assets/{tool-cards-C7iLwehG.js → tool-cards-CtE_JnF-.js} +2 -2
- package/dist/web/assets/{use-monaco-theme-jtYkroys.js → use-monaco-theme-BvzqffqR.js} +1 -1
- package/dist/web/assets/{video-preview-Ced_VIvq.js → video-preview-DxdyVATR.js} +1 -1
- package/dist/web/index.html +1 -1
- package/dist/web/sw.js +1 -1
- package/package.json +1 -1
- package/src/web/components/layout/cloud-share-popover.tsx +10 -2
- package/src/web/components/layout/mobile-drawer.tsx +26 -9
- package/dist/web/assets/keybindings-store-CWi8IGEx.js +0 -1
- package/dist/web/assets/notification-store-DEIj7OrE.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.17.18] - 2026-08-01
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- **Cloud & Share unreachable on mobile** — the button to sign in to PPM Cloud, link the device, and start sharing lived only in the desktop sidebar rail, which is hidden on phones — so there was no way to link a device from mobile. A **Cloud & Share** entry now sits in the mobile drawer footer (next to Report Bug) and opens the same panel as a bottom sheet.
|
|
7
|
+
|
|
3
8
|
## [0.17.17] - 2026-08-01
|
|
4
9
|
|
|
5
10
|
### Added
|
|
@@ -71,4 +71,4 @@ This skill covers the `ppm` CLI, its HTTP API, and its config DB. It does **not*
|
|
|
71
71
|
- Third-party extensions (inspect via `ppm ext list`).
|
|
72
72
|
- The Claude Agent SDK internals (separate skill).
|
|
73
73
|
|
|
74
|
-
<!-- Generated for PPM v0.17.
|
|
74
|
+
<!-- Generated for PPM v0.17.18 at build time. Re-run `ppm export skill --install` to refresh. -->
|
|
@@ -277,4 +277,4 @@ _Base URL: `http://localhost:8080` (default; override via `ppm config set port <
|
|
|
277
277
|
- `ws://<host>/ws/terminal` — PTY terminal multiplexer
|
|
278
278
|
- `ws://<host>/ws/extensions` — extension host channel
|
|
279
279
|
|
|
280
|
-
<!-- Generated from src/server/routes/ for PPM v0.17.
|
|
280
|
+
<!-- Generated from src/server/routes/ for PPM v0.17.18 -->
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,y as n}from"./vendor-markdown-CKTlmXbz.js";import"./vendor-ui-DMRGWRuc.js";import{t as r}from"./save-BM4p9_9n.js";import"./api-client-BK4NPNoY.js";import"./vendor-mermaid-DPpYkrMf.js";import"./settings-store-DkRZhj-g.js";import{n as i}from"./utils-CSCvNZxE.js";import{Ct as a,D as o,E as s,O as c,Ot as l,T as u,Xt as d,Zt as f,k as p,kt as m,o as h}from"./index-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,y as n}from"./vendor-markdown-CKTlmXbz.js";import"./vendor-ui-DMRGWRuc.js";import{t as r}from"./save-BM4p9_9n.js";import"./api-client-BK4NPNoY.js";import"./vendor-mermaid-DPpYkrMf.js";import"./settings-store-DkRZhj-g.js";import{n as i}from"./utils-CSCvNZxE.js";import{Ct as a,D as o,E as s,O as c,Ot as l,T as u,Xt as d,Zt as f,k as p,kt as m,o as h}from"./index-4M24PSHW.js";import{t as g}from"./use-monaco-theme-BvzqffqR.js";var _=e(t(),1),v=n();function y({metadata:e}){let t=e?.filePath,n=e?.name,i=e?.resourceType??`skill`,y=e?.scope??`user`,x=e?.readOnly===!0,S=e?.shadowed===!0,C=e?.shadowedBy,w=e?.project??``,[T,E]=(0,_.useState)(``),[D,O]=(0,_.useState)(``),[k,A]=(0,_.useState)(!0),[j,M]=(0,_.useState)(null),[N,P]=(0,_.useState)(!1),F=g(),I=(0,_.useRef)(``),L=T!==D;(0,_.useEffect)(()=>{let e=!1;return A(!0),M(null),c(t,w).then(t=>{e||(E(t.content),O(t.content),I.current=t.content)}).catch(t=>{e||M(t.message)}).finally(()=>{e||A(!1)}),()=>{e=!0}},[t,w]);let R=(0,_.useCallback)(async()=>{if(x||N)return;let e=I.current;if(e!==D){P(!0);try{await p(t,e,w),O(e),E(e),a.success(`Saved`),o.getState().reload()}catch(e){a.error(e.message)}finally{P(!1)}}},[t,w,D,x,N]);(0,_.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&(e.preventDefault(),R())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[R]);let z=s[i];return(0,v.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[(0,v.jsx)(z,{className:`size-4 text-text-subtle`}),(0,v.jsx)(`span`,{className:`text-sm font-semibold`,children:n}),(0,v.jsx)(u,{scope:y}),L&&!x&&(0,v.jsx)(`span`,{className:`size-1.5 rounded-full bg-primary`,title:`Unsaved changes`}),(0,v.jsx)(`div`,{className:`flex-1`}),(0,v.jsxs)(`span`,{className:`hidden sm:block text-[11px] text-text-subtle`,children:[i,` · markdown`]}),!x&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`button`,{onClick:()=>E(D),disabled:!L||N,className:`flex items-center gap-1 rounded px-2 py-1 text-xs text-text-secondary hover:bg-surface-elevated disabled:opacity-40`,children:[(0,v.jsx)(l,{className:`size-3.5`}),` Revert`]}),(0,v.jsxs)(`button`,{onClick:()=>void R(),disabled:!L||N,className:`flex items-center gap-1 rounded bg-primary px-2.5 py-1 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-40`,children:[N?(0,v.jsx)(f,{className:`size-3.5 animate-spin`}):(0,v.jsx)(r,{className:`size-3.5`}),` Save`]})]})]}),x&&(0,v.jsx)(b,{icon:d,tone:`muted`,children:`Bundled resource — read-only. Duplicate it (from the AI Resources panel) to make an editable copy.`}),S&&C&&(0,v.jsxs)(b,{icon:m,tone:`warn`,children:[`This `,i,` is overridden by another “`,C.name,`” from a higher-priority source (`,C.source,`). It is currently inactive.`]}),(0,v.jsx)(`div`,{className:`min-h-0 flex-1`,children:k?(0,v.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,v.jsx)(f,{className:`size-5 animate-spin text-primary`})}):j?(0,v.jsx)(`div`,{className:`p-6 text-center text-sm text-destructive`,children:j}):(0,v.jsx)(h,{height:`100%`,language:`markdown`,theme:F,value:T,onChange:e=>{let t=e??``;I.current=t,E(t)},options:{readOnly:x,minimap:{enabled:!1},fontSize:13,wordWrap:`on`,scrollBeyondLastLine:!1,lineNumbers:`on`}})})]})}function b({icon:e,tone:t,children:n}){return(0,v.jsxs)(`div`,{className:i(`flex items-start gap-2 px-3 py-2 text-[12px] shrink-0 border-b border-border`,t===`warn`?`bg-amber-500/10 text-amber-300`:`bg-surface-elevated text-text-secondary`),children:[(0,v.jsx)(e,{className:`mt-0.5 size-3.5 shrink-0`}),(0,v.jsx)(`span`,{children:n})]})}export{y as AiResourceEditor};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{y as e}from"./vendor-markdown-CKTlmXbz.js";import{t}from"./createLucideIcon-ConhwJnb.js";import{t as n}from"./file-exclamation-point-DBEC-Kst.js";import"./api-client-BK4NPNoY.js";import{t as r}from"./utils-CSCvNZxE.js";import{Zt as i}from"./index-
|
|
1
|
+
import{y as e}from"./vendor-markdown-CKTlmXbz.js";import{t}from"./createLucideIcon-ConhwJnb.js";import{t as n}from"./file-exclamation-point-DBEC-Kst.js";import"./api-client-BK4NPNoY.js";import{t as r}from"./utils-CSCvNZxE.js";import{Zt as i}from"./index-4M24PSHW.js";import{t as a}from"./use-blob-url-DdXgVqfz.js";var o=t(`music`,[[`path`,{d:`M9 18V5l12-2v13`,key:`1jmyc2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}]]),s=e();function c({filePath:e,projectName:t}){let{blobUrl:c,error:l}=a(e,t);return l?(0,s.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,s.jsx)(n,{className:`size-10 text-text-subtle`}),(0,s.jsx)(`p`,{className:`text-sm`,children:`Failed to load audio.`})]}):c?(0,s.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4 p-4 bg-surface`,children:[(0,s.jsx)(o,{className:`size-16 text-text-subtle`}),(0,s.jsx)(`p`,{className:`text-sm text-text-secondary truncate max-w-xs`,children:r(e)}),(0,s.jsx)(`audio`,{src:c,controls:!0,className:`w-full max-w-md`})]}):(0,s.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,s.jsx)(i,{className:`size-5 animate-spin text-text-subtle`})})}export{c as AudioPreview};
|
|
@@ -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{b as t,y as n}from"./vendor-markdown-CKTlmXbz.js";import"./vendor-ui-DMRGWRuc.js";import{t as r}from"./createLucideIcon-ConhwJnb.js";import{t as i}from"./bot-E9mcVZnr.js";import{g as a,h as o,p as s,t as c}from"./mobile-bottom-sheet--5_YEewV.js";import{n as l,t as u}from"./use-is-mobile-CE6AamG6.js";import{t as d}from"./chevron-right-DeUue2aK.js";import{a as f,i as p,n as m,r as h,t as g}from"./tool-cards-C7iLwehG.js";import{a as _,c as v,i as y,n as b,o as x,r as S,t as C,u as w}from"./dialog-BpkAWOy8.js";import{t as T}from"./code-TekEnDFM.js";import{n as E,t as D}from"./sparkles-B3DmG8PJ.js";import{n as O,r as ee,t as k}from"./plus-DcuJuDC3.js";import{t as te}from"./shield-off-D5tU7gQT.js";import{t as A}from"./x-BsFLg-T8.js";import{i as j,r as ne,t as M}from"./api-client-BK4NPNoY.js";import{q as N}from"./vendor-mermaid-DPpYkrMf.js";import{t as re}from"./settings-store-DkRZhj-g.js";import{n as P,r as F,t as I}from"./utils-CSCvNZxE.js";import{t as ie}from"./panel-store-DnbT1c8L.js";import{i as L}from"./project-store-Sbnqc41N.js";import{t as R}from"./tab-store-vn0viMOP.js";import{a as z,c as B,f as V,g as H,i as U,l as W,m as ae,o as oe,p as G,r as se,s as K,t as ce,u as q}from"./api-settings-BJTjIG4U.js";import{$t as le,At as J,B as ue,Bt as de,Ct as fe,Dt as pe,Et as me,F as Y,Ft as he,H as X,I as ge,It as _e,Kt as ve,L as ye,Lt as be,Mt as xe,N as Se,Nt as Ce,P as we,Pt as Te,Qt as Ee,R as De,Rt as Oe,St as Z,U as ke,Ut as Ae,V as je,Vt as Me,Wt as Ne,Xt as Pe,Yt as Fe,Zt as Ie,_n as Le,an as Re,bn as ze,bt as Be,cn as Ve,f as He,fn as Ue,ft as We,gn as Ge,gt as Ke,hn as qe,i as Je,ln as Ye,mn as Xe,mt as Ze,n as Qe,nn as $e,pn as et,pt as tt,qt as nt,rn as rt,rt as it,vn as at,w as ot,wt as st,xt as ct,yn as lt,z as ut}from"./index-BiHrB3KU.js";var dt=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`}]]),ft=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`}]]),pt=r(`hand`,[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1fvzgz`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,key:`1kc0my`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,key:`10h0bg`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`1s1gnw`}]]),mt=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`}]]),ht=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`}]]),gt=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`}]]),_t=r(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),vt=r(`slash`,[[`path`,{d:`M22 2 2 22`,key:`y4kqgn`}]]),Q=e(t(),1);function yt(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 bt(e,t){let n=`pc-${yt(t)}-`;return e.map(e=>e.id?{...e,id:`${n}${e.id}`}:e)}function xt(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 St=null;function Ct(){return St||=new AudioContext,St}function wt(e,t,n,r,i=`sine`){let a=Ct(),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 Tt(){let e=Ct().currentTime;wt(523,.15,e,.15),wt(659,.2,e+.12,.15)}function Et(){let e=Ct().currentTime;wt(880,.12,e,.18,`square`),wt(698,.12,e+.15,.18,`square`),wt(880,.15,e+.3,.15,`square`)}function Dt(){let e=Ct().currentTime;wt(440,.12,e,.12),wt(523,.12,e+.1,.12),wt(659,.18,e+.2,.12)}var Ot={done:Tt,approval_request:Et,question:Dt};function kt(e){try{Ot[e]?.()}catch{}}var At={hasTeams:!1,teamNames:[],messageCount:0,unreadCount:0};function jt(e){if(document.hidden)return!1;let{panels:t}=ie.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 Mt(e,t=`claude`,n=``){let[r,i]=(0,Q.useState)([]),[a,o]=(0,Q.useState)(new Map),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(`idle`),[d,f]=(0,Q.useState)(!1),[p,h]=(0,Q.useState)(0),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)([]),w=(0,Q.useRef)([]),[T,E]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(null),[ee,k]=(0,Q.useState)(!1),[te,A]=(0,Q.useState)(null),[N,re]=(0,Q.useState)(null),P=(0,Q.useRef)(null),F=(0,Q.useRef)(null),[I,L]=(0,Q.useState)(null),R=(0,Q.useRef)(null),[z,B]=(0,Q.useState)(!1),V=(0,Q.useRef)(null),H=(0,Q.useRef)(null),U=(0,Q.useRef)(``),W=(0,Q.useRef)([]),ae=(0,Q.useRef)(new Map),oe=(0,Q.useRef)(null),G=(0,Q.useRef)(`idle`),se=(0,Q.useRef)(null),K=(0,Q.useRef)(()=>{}),ce=(0,Q.useRef)(null),q=(0,Q.useRef)(!1),le=(0,Q.useRef)(new Set),J=(0,Q.useRef)(0),ue=(0,Q.useRef)(null),de=(0,Q.useRef)(e);de.current=e;let pe=(0,Q.useRef)([]);pe.current=r;let me=(0,Q.useRef)(n);me.current=n;let Y=(0,Q.useRef)(null),he=(0,Q.useRef)(0),X=(0,Q.useRef)({teamNames:new Set,messages:[]}),ge=(0,Q.useRef)(0),[_e,ve]=(0,Q.useState)(At),[ye,be]=(0,Q.useState)([]),xe=(0,Q.useCallback)(()=>{let e=X.current;ve({hasTeams:e.teamNames.size>0,teamNames:Array.from(e.teamNames),messageCount:e.messages.length,unreadCount:ge.current}),be([...e.messages])},[]),Se=(0,Q.useCallback)(()=>{ge.current=0,xe()},[xe]),Ce=l!==`idle`;(0,Q.useEffect)(()=>{if(e)return it.getState().setStreaming(e,l!==`idle`),()=>{it.getState().setStreaming(e,!1)}},[e,l]);let we=(0,Q.useCallback)((e,t)=>{let n=W.current.findIndex(e=>e.type===`tool_use`&&(e.tool===`Agent`||e.tool===`Task`)&&e.toolUseId===t);if(n===-1)return!1;let r=W.current[n];if(r.type!==`tool_use`)return!1;let i=[...r.children??[],e];return W.current[n]={...r,children:i},!0},[]),Te=(0,Q.useCallback)(()=>{he.current=0;let e=U.current,t=[...W.current],n=oe.current;(0,Q.startTransition)(()=>{i(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}]})})},[]),Ee=(0,Q.useCallback)(()=>{he.current||=window.setTimeout(Te,100)},[Te]),De=(0,Q.useCallback)(e=>{let t=e,n=t?.type;if(!n)return;let r=e=>{let n=W.current,r=n.findIndex(e);r===-1?n.push(t):n[r]=t};switch(n){case`account_info`:oe.current={accountId:t.accountId,accountLabel:t.accountLabel},E(null);break;case`account_retry`:t.accountId&&t.accountLabel&&(oe.current={accountId:t.accountId,accountLabel:t.accountLabel}),W.current=[t],Ee();break;case`status_update`:{let e=t.accountLabel?` (${t.accountLabel})`:``;E(`${t.message}${e}`);break}case`text`:{let e=t.parentToolUseId;if(e&&we(t,e)){Ee();break}U.current+=t.content,W.current.push(t),Ee();break}case`thinking`:{let e=t.parentToolUseId;if(e&&we(t,e)){Ee();break}W.current.push(t),Ee();break}case`tool_use`:{if(t.tool===`AskUserQuestion`){t.toolUseId&&le.current.add(t.toolUseId);break}let e=t.parentToolUseId;if(e&&we(t,e)){Ee();break}let n=t.toolUseId;r(e=>!!n&&e.type===`tool_use`&&e.toolUseId===n),Ee();break}case`tool_result`:{let e=t.toolUseId;if(e&&ae.current.delete(e),e&&le.current.has(e))break;let n=t.parentToolUseId;if(n&&we(t,n)){Ee();break}r(t=>!!e&&t.type===`tool_result`&&t.toolUseId===e),Ee();break}case`approval_resolved`:{let e=t.requestId;if(t.approved&&t.answers){let n=W.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,i(e=>[...e]))}_(t=>t&&t.requestId===e?null:t),Y.current!=null&&(fe.dismiss(Y.current),Y.current=null);break}case`approval_request`:if(r(e=>e.type===`approval_request`&&e.requestId===t.requestId),q.current)break;if(_({requestId:t.requestId,tool:t.tool,input:t.input}),de.current&&!jt(de.current)){kt(t.tool===`AskUserQuestion`?`question`:`approval_request`);let e=de.current,n=t.tool===`AskUserQuestion`;Y.current=fe[n?`info`:`warning`](n?`AI has a question`:`${t.tool} needs permission`,{description:me.current||`Session ${e.slice(0,8)}`,duration:1/0,action:{label:`Go to session`,onClick:()=>{let{panels:t}=ie.getState();for(let[n,r]of Object.entries(t)){let t=r.tabs.find(t=>t.metadata?.sessionId===e);if(t){ie.getState().setActiveTab(t.id,n);break}}}}})}break;case`error`:i(e=>{let n=e[e.length-1];if(n?.role===`assistant`){let r=W.current,i=r[r.length-1],a=i?.type===`error`&&i.message===t.message?r:[...r,t];return W.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&&(X.current.teamNames.add(e),M.get(`/api/teams/${encodeURIComponent(e)}`).then(e=>{if(e?.messages){let t=X.current.messages,n=e.messages.filter(e=>!t.some(t=>t.timestamp===e.timestamp&&t.from===e.from));t.push(...n),t.sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime()),t.length>500&&t.splice(0,t.length-500)}xe()}).catch(()=>{}),xe());break}case`team_inbox`:{let e=t.messages;if(Array.isArray(e)){let t=X.current.messages;t.push(...e),t.length>500&&t.splice(0,t.length-500),ge.current+=e.length,xe()}break}case`team_updated`:xe();break;case`bash_output`:{let e=t.toolUseId;if(e){let n=ae.current.get(e);n?(n.content+=t.content,n.content.length>5e5&&(n.content=n.content.slice(-5e5)),n.lineCount=t.lineCount):ae.current.set(e,{content:t.content,lineCount:t.lineCount}),Ee()}break}case`background_registry`:{let e=t.shells??[];w.current=e,C(e);break}case`done`:{if(G.current===`idle`)break;t.contextWindowPct!=null&&y(t.contextWindowPct),de.current&&!jt(de.current)&&kt(`done`),he.current&&=(clearTimeout(he.current),0);let e=U.current,n=[...W.current],r=oe.current,a=t.lastMessageUuid;i(t=>{let i=t[t.length-1];return i?.role===`assistant`?[...t.slice(0,-1),{...i,id:`final-${Date.now()}`,content:e||i.content,events:n.length>0?n:i.events,...a&&{sdkUuid:a}}]:e||n.length>0?[...t,{id:`final-${Date.now()}`,role:`assistant`,content:e,events:n,timestamp:new Date().toISOString(),...a&&{sdkUuid:a},...r}]:t}),U.current=``,W.current=[],oe.current=null,ue.current=null,ae.current.clear(),E(null);break}}},[we,Ee]),Oe=(0,Q.useCallback)(e=>{let t;try{t=JSON.parse(e.data)}catch{return}if(t.type!==`ping`){if(t.type===`file:changed`){window.dispatchEvent(new CustomEvent(`file:changed`,{detail:t}));return}if(t.type===`session:unread_changed`){let{sessionId:e,unreadCount:n,unreadType:r,projectName:i,sessionTitle:a,manual:o}=t;Be.getState().handleUnreadChanged(e,n,r,i,a,o);return}if(typeof t.type==`string`&&t.type.startsWith(`jira:`)){window.dispatchEvent(new CustomEvent(t.type,{detail:t}));return}if(t.type===`title_updated`){O(t.title??null);return}if(t.type===`compact_status`){let e=t.status;e===`compacting`?x(`compacting`):e===`done`&&x(null);return}if(t.type===`phase_changed`){let e=t.phase;u(e),G.current=e,h(e===`connecting`?t.elapsed??0:0),e===`idle`&&x(null);return}if(t.type===`session_state`){k(!0),A(t.sessionId??de.current);let e=t,n=e.phase;u(n),G.current=n,e.sessionTitle&&O(e.sessionTitle),e.model&&(F.current&&e.model!==F.current||(e.model===F.current&&(F.current=null),re(e.model),P.current=e.model)),typeof e.effort==`string`&&(L(e.effort),R.current=e.effort),typeof e.thinking==`boolean`&&(B(e.thinking),V.current=e.thinking),e.pendingApproval&&_({requestId:e.pendingApproval.requestId,tool:e.pendingApproval.tool,input:e.pendingApproval.input}),x(e.compactStatus===`compacting`?`compacting`:null),n===`idle`&&(ce.current?.(),f(!1));return}if(t.type===`turn_events`){let e=t.events,n=t.userMessage;if(!e?.length&&!n){f(!1);return}J.current&&=(cancelAnimationFrame(J.current),0),ue.current=n,i(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}),U.current=``,W.current=[],oe.current=null,q.current=!0;let r=0,a=()=>{let t=Math.min(r+100,e.length);for(let n=r;n<t;n++)De(e[n]);r=t,r<e.length?J.current=requestAnimationFrame(a):(J.current=0,q.current=!1,f(!1))};J.current=requestAnimationFrame(a);return}De(t)}},[De]),{send:Z,connect:ke}=m({url:e&&n?`/ws/project/${encodeURIComponent(n)}/chat/${e}`:``,onMessage:Oe,autoConnect:!!e&&!!n});K.current=Z,(0,Q.useEffect)(()=>{let r=!1;H.current&&H.current!==e&&(F.current=null),H.current=e??null,u(`idle`),G.current=`idle`,_(null),Y.current!=null&&(fe.dismiss(Y.current),Y.current=null),x(null),o(new Map),U.current=``,W.current=[],ue.current=null,ae.current.clear(),he.current&&=(clearTimeout(he.current),0),k(!1),A(null),X.current={teamNames:new Set,messages:[]},ge.current=0,ve(At),be([]);let a=new Set(pe.current.map(e=>e.id));return e&&n?(c(!0),fetch(`${j(n)}/chat/sessions/${e}/messages?providerId=${t}`,{headers:{Authorization:`Bearer ${ne()}`}}).then(e=>e.json()).then(e=>{if(r)return;let t=e.ok&&Array.isArray(e.data)?e.data:[],n=ue.current;if(n!=null){for(let e=t.length-1;e>=0;e--)if(t[e].role===`user`&&t[e].content===n){t=t.slice(0,e);break}}i(e=>{let n=e.filter(e=>!a.has(e.id));return[...t,...n]})}).catch(()=>{r||i(e=>e.filter(e=>!a.has(e.id)))}).finally(()=>{r||c(!1)})):i([]),()=>{r=!0}},[e,t,n]);let Ae=(0,Q.useCallback)((e,t)=>{if(!e.trim())return;let n=G.current!==`idle`;if(n){he.current&&=(clearTimeout(he.current),0);let e=U.current,t=[...W.current];i(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})}i(t=>[...t,{id:`user-${Date.now()}`,role:`user`,content:e,timestamp:new Date().toISOString()}]),U.current=``,W.current=[],se.current=null,n?(u(`thinking`),G.current=`thinking`):(u(`initializing`),G.current=`initializing`),_(null),Y.current!=null&&(fe.dismiss(Y.current),Y.current=null),Z(JSON.stringify({type:`message`,content:e,permissionMode:t?.permissionMode,priority:t?.priority,images:t?.images,...P.current&&{model:P.current},...R.current&&{effort:R.current},...V.current!==null&&{thinking:V.current}}))},[Z]),je=(0,Q.useCallback)(e=>{re(e),P.current=e,F.current=e,Z(JSON.stringify({type:`set_model`,model:e}))},[Z]),Me=(0,Q.useCallback)(e=>{L(e),R.current=e,Z(JSON.stringify({type:`set_effort`,effort:e}))},[Z]),Ne=(0,Q.useCallback)(e=>{B(e),V.current=e,Z(JSON.stringify({type:`set_thinking`,enabled:e}))},[Z]),Pe=(0,Q.useCallback)((e,t,n)=>{if(Z(JSON.stringify({type:`approval_response`,requestId:e,approved:t,data:n})),t&&n){let t=W.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)}i(e=>[...e])}_(null),Y.current!=null&&(fe.dismiss(Y.current),Y.current=null)},[Z]),Fe=(0,Q.useCallback)(()=>{if(G.current===`idle`)return;Z(JSON.stringify({type:`cancel`}));let e=U.current,t=[...W.current];i(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}),U.current=``,W.current=[],ae.current.clear(),se.current=null,u(`idle`),G.current=`idle`,_(null),Y.current!=null&&(fe.dismiss(Y.current),Y.current=null)},[Z]),Ie=(0,Q.useCallback)(e=>{e&&Z(JSON.stringify({type:`kill_background_shell`,shellId:e}))},[Z]),Le=(0,Q.useCallback)(e=>{if(!e)return;let t=e.replace(/\.output$/,``);return w.current.find(n=>n.shellId===t||n.outputPath.endsWith(e)||n.outputPath.endsWith(`${t}.output`))},[]);(0,Q.useEffect)(()=>{e&&Qe.getState().setSessionShells(e,S)},[e,S]),(0,Q.useEffect)(()=>{if(e)return Qe.getState().retainSession(e),()=>{Qe.getState().releaseSession(e)}},[e]);let Re=(0,Q.useCallback)(()=>{k(!1),f(!0),ke()},[ke]),ze=(0,Q.useCallback)(()=>{!e||!n||fetch(`${j(n)}/chat/sessions/${e}/messages?providerId=${t}`,{headers:{Authorization:`Bearer ${ne()}`}}).then(e=>e.json()).then(e=>{G.current===`idle`&&e.ok&&Array.isArray(e.data)&&e.data.length>0&&(i(e.data),U.current=``,W.current=[])}).catch(()=>{})},[e,t,n]);ce.current=ze;let Ve=(0,Q.useCallback)(async(e,t)=>{if(!n)throw Error(`No project context available`);let r=e.replace(/^pc-[^-]+-/,``),i=`${j(n)}/chat/pre-compact-messages?jsonlPath=${encodeURIComponent(t)}&before=${encodeURIComponent(r)}`,a=bt(await M.get(i),t);return o(t=>{let n=new Map(t);return n.set(e,a),n}),a.length},[n]),He=(0,Q.useCallback)(e=>a.has(e),[a]),Ue=(0,Q.useCallback)(e=>{i(t=>t.filter(t=>t.id!==e))},[]),We=(0,Q.useCallback)(()=>{i(e=>e.filter(e=>e.role!==`system`))},[]);return{messages:r,renderedMessages:(0,Q.useMemo)(()=>xt(r,a),[r,a]),expandCompact:Ve,isCompactExpanded:He,dismissMessage:Ue,clearErrors:We,messagesLoading:s,isStreaming:Ce,phase:l,isReconnecting:d,connectingElapsed:p,pendingApproval:g,contextWindowPct:v,compactStatus:b,statusMessage:T,sessionTitle:D,model:N,setModel:je,effort:I,setEffort:Me,thinking:z,setThinking:Ne,teamActivity:_e,teamMessages:ye,markTeamRead:Se,bashPartialOutput:ae,backgroundShells:S,killBackgroundShell:Ie,findBackgroundShellByOutput:Le,sendMessage:Ae,respondToApproval:Pe,cancelStreaming:Fe,reconnect:Re,refetchMessages:ze,isConnected:ee&&te===e}}var Nt=12e4;function Pt(e,t=`claude`){let[n,r]=(0,Q.useState)({}),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(null),c=(0,Q.useRef)(null),l=(0,Q.useCallback)((n=!1)=>{if(!e)return;a(!0);let i=n?`&refresh=1`:``;fetch(`${j(e)}/chat/usage?providerId=${t}${i}`,{headers:{Authorization:`Bearer ${ne()}`}}).then(e=>e.json()).then(e=>{e.ok&&e.data&&(r(t=>({...t,...e.data})),e.data.lastFetchedAt&&s(e.data.lastFetchedAt))}).catch(()=>{}).finally(()=>a(!1))},[e,t]);return(0,Q.useEffect)(()=>(l(),c.current=setInterval(()=>l(),Nt),()=>{c.current&&clearInterval(c.current)}),[l]),{usageInfo:n,usageLoading:i,lastFetchedAt:o,refreshUsage:(0,Q.useCallback)(()=>l(!0),[l])}}var Ft={damping:.7,stiffness:.05,mass:1.25},It=70,Lt=1e3/60,Rt=350,zt=!1;globalThis.document?.addEventListener(`mousedown`,()=>{zt=!0}),globalThis.document?.addEventListener(`mouseup`,()=>{zt=!1}),globalThis.document?.addEventListener(`click`,()=>{zt=!1});var Bt=(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(!zt)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<=It}}},[]),f=(0,Q.useCallback)((e={})=>{typeof e==`string`&&(e={animation:e}),e.preserveScrollPosition||l(!0);let t=Date.now()+(Number(e.wait)||0),n=Ut(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))/Lt;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:Ut(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=Vt(e=>{g.current?.removeEventListener(`scroll`,m),g.current?.removeEventListener(`wheel`,h),e?.addEventListener(`scroll`,m,{passive:!0}),e?.addEventListener(`wheel`,h,{passive:!0})},[]),_=Vt(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=Ut(s.current,t?s.current.resize:s.current.initial);f({animation:e,wait:!0,preserveScrollPosition:!0,duration:e===`instant`?void 0:Rt})}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 Vt(e,t){let n=(0,Q.useCallback)(t=>(n.current=t,e(t)),t);return n}var Ht=new Map;function Ut(...e){let t={...Ft},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 Ht.has(r)||Ht.set(r,Object.freeze(t)),n?`instant`:Ht.get(r)}function Wt(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(()=>{M.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 $=n(),Gt=new Set([`TaskCreate`,`TaskUpdate`,`TaskStop`]);function Kt(e){let t=0;for(let n of e)if(n.events)for(let e of n.events)e.type===`tool_use`&&Gt.has(e.tool)&&t++;return t}var qt={completed:{icon:`✓`,cls:`text-success`},in_progress:{icon:`▶`,cls:`text-warning`},stopped:{icon:`■`,cls:`text-text-subtle`},pending:{icon:`○`,cls:`text-text-subtle`}};function Jt({projectName:e,sessionId:t,messages:n}){let r=(0,Q.useMemo)(()=>Kt(n),[n]),i=Wt(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 s=i.filter(e=>e.status===`completed`).length,c=i.length,u=c?Math.round(s/c*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)(d,{className:`size-3.5 shrink-0`}):(0,$.jsx)(l,{className:`size-3.5 shrink-0`}),(0,$.jsx)(h,{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:[s,`/`,c,` 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:`${u}%`}})})]}),!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)(Yt,{task:e},e.id))})]})}function Yt({task:e}){let t=qt[e.status]??qt.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 Xt=/read the full transcript at:\s*(\S+\.jsonl)/i;function Zt(e){return e.match(Xt)?.[1]?.trim()??null}var Qt=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 $t({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)(tt,{projectName:e,onSelectSession:t,className:`w-full px-4`})]})}function en(e){try{return new Date(e).toLocaleString()}catch{return``}}function tn({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 nn({content:e}){let[t,n]=(0,Q.useState)(!1);return(0,$.jsx)(tn,{icon:t?(0,$.jsx)(o,{className:`size-3.5`}):(0,$.jsx)(Ye,{className:`size-3.5`}),label:t?`Copied`:`Copy`,title:`Copy message to clipboard`,onClick:()=>{navigator.clipboard?.writeText(e).catch(()=>{}),n(!0),setTimeout(()=>n(!1),1500)}})}function rn({timestamp:e,content:t,accountLabel:n,className:r,children:i}){return(0,$.jsxs)(`div`,{className:P(`flex items-center gap-0.5 flex-wrap text-xs text-text-subtle select-none`,r),children:[(0,$.jsx)(`time`,{title:en(e),className:`pr-1 tabular-nums`,children:Z(e)}),n&&(0,$.jsxs)(`span`,{className:`px-1 truncate max-w-40`,children:[`via `,n]}),(0,$.jsx)(nn,{content:t}),i]})}var an=new Map;function on(){an.clear()}function sn(e,t,n,r){let i=`${t}:${r}`,a=an.get(i);return a||(a=M.get(`${j(e)}/chat/sessions/${t}/versions?ordinal=${r}&providerId=${n}`).catch(()=>null),an.set(i,a)),a}function cn({projectName:e,sessionId:t,providerId:n,ordinal:r,onNavigate:i,disabled:a}){let[o,s]=(0,Q.useState)(null);if((0,Q.useEffect)(()=>{if(!e||!t||!r||r<1){s(null);return}let i=!0;return sn(e,t,n,r).then(e=>{i&&s(e&&e.versions.length>=2?e:null)}),()=>{i=!1}},[e,t,n,r]),!o)return null;let{versions:c,currentIndex:l}=o,u=e=>{let t=c[e];t&&!a&&i(t.id)};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:()=>u(l-1),disabled:a||l<=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)(Ge,{className:`size-3.5`})}),(0,$.jsxs)(`span`,{className:`tabular-nums`,children:[l+1,`/`,c.length]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>u(l+1),disabled:a||l>=c.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)(d,{className:`size-3.5`})})]})}function ln(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 un(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=document.activeElement===e.customInputRef.current;if(!i&&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(!i&&(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(!i){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`&&i&&e.customInputRef.current?.blur()},a=r.current;return a&&(a.addEventListener(`keydown`,i),a.setAttribute(`tabindex`,`0`),a.contains(document.activeElement)||a.focus()),()=>{a?.removeEventListener(`keydown`,i)}},[e,t]),{focusedOption:t,setFocusedOption:n,containerRef:r}}function dn({questions:e,onSubmit:t,onSkip:n}){let r=(0,Q.useRef)(null),i=ln(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=un({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 fn=N(()=>import(`./markdown-renderer-XIhxiUQq.js`),__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])),pn=(0,Q.lazy)(()=>fn.then(e=>({default:e.MarkdownRenderer})));function mn({messages:e,messagesLoading:t,keepStaleWhileLoading:n,pendingApproval:r,onApprovalResponse:a,isStreaming:o,phase:s,onSelectSession:c,connectingElapsed:l,statusMessage:u,compactStatus:d,projectName:p,onFork:m,onEdit:h,editingMsgId:g,sessionId:_,providerId:v,onNavigateVersion:y,bashPartialOutput:b,onExpandCompact:x,isCompactExpanded:S,onDismissMessage:C,onClearErrors:w}){let{scrollRef:T,contentRef:E,scrollToBottom:D,stopScroll:O,isAtBottom:ee}=Bt({initial:`instant`,resize:`instant`}),k=(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]),te=!!r||o,[A,j]=(0,Q.useState)(null),ne=(0,Q.useCallback)(e=>{T(e),j(e)},[T]),M=(0,Q.useRef)(null);(0,Q.useLayoutEffect)(()=>{let e=A;e&&M.current!=null&&(e.scrollTop=e.scrollHeight-M.current,M.current=null)},[k.length,A]),(0,Q.useLayoutEffect)(()=>{A&&D({animation:`instant`})},[_,A]);let N=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{A&&A.clientHeight>0&&(N.current=ee)},[ee,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&&!N.current&&O()});return n.observe(e),()=>n.disconnect()},[A,O]);let re=(0,Q.useCallback)((e,t)=>{m?.(e,t)},[m]),P=(0,Q.useCallback)((e,t,n)=>{h?.(e,t,n)},[h]),F=(0,Q.useCallback)(e=>{C?.(e)},[C]),I=(0,Q.useMemo)(()=>k.reduce((e,t)=>t.role===`system`?e+1:e,0),[k]),ie=(0,Q.useMemo)(()=>k.reduce((e,t,n)=>(t.role===`user`&&e.push(n),e),[]),[k]),L=(0,Q.useCallback)(()=>{if(!x||!S)return null;for(let e of k){if(S(e.id))continue;let t=Zt(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=Zt(t.content||``);if(n)return{id:e.id,jsonlPath:n}}}}return null},[k,x,S])(),R=!!L,[z,B]=(0,Q.useState)(!1),V=(0,Q.useCallback)(async()=>{if(!L||!x||z)return;let e=A;M.current=e?e.scrollHeight-e.scrollTop:null,B(!0);try{await x(L.id,L.jsonlPath)}finally{B(!1)}},[L,x,z,A]);return(0,Q.useEffect)(()=>{let e=A;if(!e||!R)return;let t=()=>{e.scrollTop<200&&!z&&V()};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[A,R,z,V]),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)($t,{projectName:p||``,onSelectSession:c||(()=>{})}):(0,$.jsxs)(`div`,{className:`relative flex-1 overflow-hidden flex flex-col min-h-0`,children:[(0,$.jsx)(Jt,{projectName:p,sessionId:_,messages:e}),I>1&&w&&(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:w,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)(f,{className:`size-3.5`}),`Clear all errors (`,I,`)`]})}),z&&(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)(Ie,{className:`size-3 animate-spin`}),`Loading previous conversation...`]}),(0,$.jsx)(`div`,{ref:ne,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:[k.map((e,t)=>{let n=t>0?k[t-1]:void 0,r=e.role===`user`?k.slice(0,t+1).reduce((e,t)=>e+(t.role===`user`?1:0),0):0,i=e.role===`user`&&g!=null&&e.id===g,a=k[t+1],s=e.role===`assistant`&&a?.role!==`assistant`,c;if(s){let e=[];for(let n=t;n>=0&&k[n].role===`assistant`;n--){let t=gn(k[n]);t&&e.unshift(t)}c=e.join(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/markdown-renderer-DCsEEdo7.js","assets/vendor-mermaid-DPpYkrMf.js","assets/rolldown-runtime-FhOqtrmT.js","assets/vendor-markdown-CKTlmXbz.js","assets/markdown-renderer-BNXJygz9.js","assets/index-4M24PSHW.js","assets/vendor-ui-DMRGWRuc.js","assets/dialog-BpkAWOy8.js","assets/utils-CSCvNZxE.js","assets/createLucideIcon-ConhwJnb.js","assets/x-BsFLg-T8.js","assets/eye-off-Rq1n2-oe.js","assets/bot-E9mcVZnr.js","assets/mobile-bottom-sheet--5_YEewV.js","assets/chevron-right-DeUue2aK.js","assets/use-is-mobile-CE6AamG6.js","assets/sparkles-B3DmG8PJ.js","assets/database-COYAMZaw.js","assets/plus-DcuJuDC3.js","assets/react-CorNPdie.js","assets/api-client-BK4NPNoY.js","assets/api-settings-BJTjIG4U.js","assets/project-store-Sbnqc41N.js","assets/panel-store-DnbT1c8L.js","assets/settings-store-DkRZhj-g.js","assets/tab-store-vn0viMOP.js","assets/apply-theme-DxKsrDLA.js","assets/resolve-theme-CCoakF2E.js","assets/index-BYFXiFsa.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,y as n}from"./vendor-markdown-CKTlmXbz.js";import"./vendor-ui-DMRGWRuc.js";import{t as r}from"./createLucideIcon-ConhwJnb.js";import{t as i}from"./bot-E9mcVZnr.js";import{g as a,h as o,p as s,t as c}from"./mobile-bottom-sheet--5_YEewV.js";import{n as l,t as u}from"./use-is-mobile-CE6AamG6.js";import{t as d}from"./chevron-right-DeUue2aK.js";import{a as f,i as p,n as m,r as h,t as g}from"./tool-cards-CtE_JnF-.js";import{a as _,c as v,i as y,n as b,o as x,r as S,t as C,u as w}from"./dialog-BpkAWOy8.js";import{t as T}from"./code-TekEnDFM.js";import{n as E,t as D}from"./sparkles-B3DmG8PJ.js";import{n as O,r as ee,t as k}from"./plus-DcuJuDC3.js";import{t as te}from"./shield-off-D5tU7gQT.js";import{t as A}from"./x-BsFLg-T8.js";import{i as j,r as ne,t as M}from"./api-client-BK4NPNoY.js";import{q as N}from"./vendor-mermaid-DPpYkrMf.js";import{t as re}from"./settings-store-DkRZhj-g.js";import{n as P,r as F,t as I}from"./utils-CSCvNZxE.js";import{t as ie}from"./panel-store-DnbT1c8L.js";import{i as L}from"./project-store-Sbnqc41N.js";import{t as R}from"./tab-store-vn0viMOP.js";import{a as z,c as B,f as V,g as H,i as U,l as W,m as ae,o as oe,p as G,r as se,s as K,t as ce,u as q}from"./api-settings-BJTjIG4U.js";import{$t as le,At as J,B as ue,Bt as de,Ct as fe,Dt as pe,Et as me,F as Y,Ft as he,H as X,I as ge,It as _e,Kt as ve,L as ye,Lt as be,Mt as xe,N as Se,Nt as Ce,P as we,Pt as Te,Qt as Ee,R as De,Rt as Oe,St as Z,U as ke,Ut as Ae,V as je,Vt as Me,Wt as Ne,Xt as Pe,Yt as Fe,Zt as Ie,_n as Le,an as Re,bn as ze,bt as Be,cn as Ve,f as He,fn as Ue,ft as We,gn as Ge,gt as Ke,hn as qe,i as Je,ln as Ye,mn as Xe,mt as Ze,n as Qe,nn as $e,pn as et,pt as tt,qt as nt,rn as rt,rt as it,vn as at,w as ot,wt as st,xt as ct,yn as lt,z as ut}from"./index-4M24PSHW.js";var dt=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`}]]),ft=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`}]]),pt=r(`hand`,[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1fvzgz`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,key:`1kc0my`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,key:`10h0bg`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`1s1gnw`}]]),mt=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`}]]),ht=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`}]]),gt=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`}]]),_t=r(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),vt=r(`slash`,[[`path`,{d:`M22 2 2 22`,key:`y4kqgn`}]]),Q=e(t(),1);function yt(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 bt(e,t){let n=`pc-${yt(t)}-`;return e.map(e=>e.id?{...e,id:`${n}${e.id}`}:e)}function xt(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 St=null;function Ct(){return St||=new AudioContext,St}function wt(e,t,n,r,i=`sine`){let a=Ct(),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 Tt(){let e=Ct().currentTime;wt(523,.15,e,.15),wt(659,.2,e+.12,.15)}function Et(){let e=Ct().currentTime;wt(880,.12,e,.18,`square`),wt(698,.12,e+.15,.18,`square`),wt(880,.15,e+.3,.15,`square`)}function Dt(){let e=Ct().currentTime;wt(440,.12,e,.12),wt(523,.12,e+.1,.12),wt(659,.18,e+.2,.12)}var Ot={done:Tt,approval_request:Et,question:Dt};function kt(e){try{Ot[e]?.()}catch{}}var At={hasTeams:!1,teamNames:[],messageCount:0,unreadCount:0};function jt(e){if(document.hidden)return!1;let{panels:t}=ie.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 Mt(e,t=`claude`,n=``){let[r,i]=(0,Q.useState)([]),[a,o]=(0,Q.useState)(new Map),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(`idle`),[d,f]=(0,Q.useState)(!1),[p,h]=(0,Q.useState)(0),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)([]),w=(0,Q.useRef)([]),[T,E]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(null),[ee,k]=(0,Q.useState)(!1),[te,A]=(0,Q.useState)(null),[N,re]=(0,Q.useState)(null),P=(0,Q.useRef)(null),F=(0,Q.useRef)(null),[I,L]=(0,Q.useState)(null),R=(0,Q.useRef)(null),[z,B]=(0,Q.useState)(!1),V=(0,Q.useRef)(null),H=(0,Q.useRef)(null),U=(0,Q.useRef)(``),W=(0,Q.useRef)([]),ae=(0,Q.useRef)(new Map),oe=(0,Q.useRef)(null),G=(0,Q.useRef)(`idle`),se=(0,Q.useRef)(null),K=(0,Q.useRef)(()=>{}),ce=(0,Q.useRef)(null),q=(0,Q.useRef)(!1),le=(0,Q.useRef)(new Set),J=(0,Q.useRef)(0),ue=(0,Q.useRef)(null),de=(0,Q.useRef)(e);de.current=e;let pe=(0,Q.useRef)([]);pe.current=r;let me=(0,Q.useRef)(n);me.current=n;let Y=(0,Q.useRef)(null),he=(0,Q.useRef)(0),X=(0,Q.useRef)({teamNames:new Set,messages:[]}),ge=(0,Q.useRef)(0),[_e,ve]=(0,Q.useState)(At),[ye,be]=(0,Q.useState)([]),xe=(0,Q.useCallback)(()=>{let e=X.current;ve({hasTeams:e.teamNames.size>0,teamNames:Array.from(e.teamNames),messageCount:e.messages.length,unreadCount:ge.current}),be([...e.messages])},[]),Se=(0,Q.useCallback)(()=>{ge.current=0,xe()},[xe]),Ce=l!==`idle`;(0,Q.useEffect)(()=>{if(e)return it.getState().setStreaming(e,l!==`idle`),()=>{it.getState().setStreaming(e,!1)}},[e,l]);let we=(0,Q.useCallback)((e,t)=>{let n=W.current.findIndex(e=>e.type===`tool_use`&&(e.tool===`Agent`||e.tool===`Task`)&&e.toolUseId===t);if(n===-1)return!1;let r=W.current[n];if(r.type!==`tool_use`)return!1;let i=[...r.children??[],e];return W.current[n]={...r,children:i},!0},[]),Te=(0,Q.useCallback)(()=>{he.current=0;let e=U.current,t=[...W.current],n=oe.current;(0,Q.startTransition)(()=>{i(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}]})})},[]),Ee=(0,Q.useCallback)(()=>{he.current||=window.setTimeout(Te,100)},[Te]),De=(0,Q.useCallback)(e=>{let t=e,n=t?.type;if(!n)return;let r=e=>{let n=W.current,r=n.findIndex(e);r===-1?n.push(t):n[r]=t};switch(n){case`account_info`:oe.current={accountId:t.accountId,accountLabel:t.accountLabel},E(null);break;case`account_retry`:t.accountId&&t.accountLabel&&(oe.current={accountId:t.accountId,accountLabel:t.accountLabel}),W.current=[t],Ee();break;case`status_update`:{let e=t.accountLabel?` (${t.accountLabel})`:``;E(`${t.message}${e}`);break}case`text`:{let e=t.parentToolUseId;if(e&&we(t,e)){Ee();break}U.current+=t.content,W.current.push(t),Ee();break}case`thinking`:{let e=t.parentToolUseId;if(e&&we(t,e)){Ee();break}W.current.push(t),Ee();break}case`tool_use`:{if(t.tool===`AskUserQuestion`){t.toolUseId&&le.current.add(t.toolUseId);break}let e=t.parentToolUseId;if(e&&we(t,e)){Ee();break}let n=t.toolUseId;r(e=>!!n&&e.type===`tool_use`&&e.toolUseId===n),Ee();break}case`tool_result`:{let e=t.toolUseId;if(e&&ae.current.delete(e),e&&le.current.has(e))break;let n=t.parentToolUseId;if(n&&we(t,n)){Ee();break}r(t=>!!e&&t.type===`tool_result`&&t.toolUseId===e),Ee();break}case`approval_resolved`:{let e=t.requestId;if(t.approved&&t.answers){let n=W.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,i(e=>[...e]))}_(t=>t&&t.requestId===e?null:t),Y.current!=null&&(fe.dismiss(Y.current),Y.current=null);break}case`approval_request`:if(r(e=>e.type===`approval_request`&&e.requestId===t.requestId),q.current)break;if(_({requestId:t.requestId,tool:t.tool,input:t.input}),de.current&&!jt(de.current)){kt(t.tool===`AskUserQuestion`?`question`:`approval_request`);let e=de.current,n=t.tool===`AskUserQuestion`;Y.current=fe[n?`info`:`warning`](n?`AI has a question`:`${t.tool} needs permission`,{description:me.current||`Session ${e.slice(0,8)}`,duration:1/0,action:{label:`Go to session`,onClick:()=>{let{panels:t}=ie.getState();for(let[n,r]of Object.entries(t)){let t=r.tabs.find(t=>t.metadata?.sessionId===e);if(t){ie.getState().setActiveTab(t.id,n);break}}}}})}break;case`error`:i(e=>{let n=e[e.length-1];if(n?.role===`assistant`){let r=W.current,i=r[r.length-1],a=i?.type===`error`&&i.message===t.message?r:[...r,t];return W.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&&(X.current.teamNames.add(e),M.get(`/api/teams/${encodeURIComponent(e)}`).then(e=>{if(e?.messages){let t=X.current.messages,n=e.messages.filter(e=>!t.some(t=>t.timestamp===e.timestamp&&t.from===e.from));t.push(...n),t.sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime()),t.length>500&&t.splice(0,t.length-500)}xe()}).catch(()=>{}),xe());break}case`team_inbox`:{let e=t.messages;if(Array.isArray(e)){let t=X.current.messages;t.push(...e),t.length>500&&t.splice(0,t.length-500),ge.current+=e.length,xe()}break}case`team_updated`:xe();break;case`bash_output`:{let e=t.toolUseId;if(e){let n=ae.current.get(e);n?(n.content+=t.content,n.content.length>5e5&&(n.content=n.content.slice(-5e5)),n.lineCount=t.lineCount):ae.current.set(e,{content:t.content,lineCount:t.lineCount}),Ee()}break}case`background_registry`:{let e=t.shells??[];w.current=e,C(e);break}case`done`:{if(G.current===`idle`)break;t.contextWindowPct!=null&&y(t.contextWindowPct),de.current&&!jt(de.current)&&kt(`done`),he.current&&=(clearTimeout(he.current),0);let e=U.current,n=[...W.current],r=oe.current,a=t.lastMessageUuid;i(t=>{let i=t[t.length-1];return i?.role===`assistant`?[...t.slice(0,-1),{...i,id:`final-${Date.now()}`,content:e||i.content,events:n.length>0?n:i.events,...a&&{sdkUuid:a}}]:e||n.length>0?[...t,{id:`final-${Date.now()}`,role:`assistant`,content:e,events:n,timestamp:new Date().toISOString(),...a&&{sdkUuid:a},...r}]:t}),U.current=``,W.current=[],oe.current=null,ue.current=null,ae.current.clear(),E(null);break}}},[we,Ee]),Oe=(0,Q.useCallback)(e=>{let t;try{t=JSON.parse(e.data)}catch{return}if(t.type!==`ping`){if(t.type===`file:changed`){window.dispatchEvent(new CustomEvent(`file:changed`,{detail:t}));return}if(t.type===`session:unread_changed`){let{sessionId:e,unreadCount:n,unreadType:r,projectName:i,sessionTitle:a,manual:o}=t;Be.getState().handleUnreadChanged(e,n,r,i,a,o);return}if(typeof t.type==`string`&&t.type.startsWith(`jira:`)){window.dispatchEvent(new CustomEvent(t.type,{detail:t}));return}if(t.type===`title_updated`){O(t.title??null);return}if(t.type===`compact_status`){let e=t.status;e===`compacting`?x(`compacting`):e===`done`&&x(null);return}if(t.type===`phase_changed`){let e=t.phase;u(e),G.current=e,h(e===`connecting`?t.elapsed??0:0),e===`idle`&&x(null);return}if(t.type===`session_state`){k(!0),A(t.sessionId??de.current);let e=t,n=e.phase;u(n),G.current=n,e.sessionTitle&&O(e.sessionTitle),e.model&&(F.current&&e.model!==F.current||(e.model===F.current&&(F.current=null),re(e.model),P.current=e.model)),typeof e.effort==`string`&&(L(e.effort),R.current=e.effort),typeof e.thinking==`boolean`&&(B(e.thinking),V.current=e.thinking),e.pendingApproval&&_({requestId:e.pendingApproval.requestId,tool:e.pendingApproval.tool,input:e.pendingApproval.input}),x(e.compactStatus===`compacting`?`compacting`:null),n===`idle`&&(ce.current?.(),f(!1));return}if(t.type===`turn_events`){let e=t.events,n=t.userMessage;if(!e?.length&&!n){f(!1);return}J.current&&=(cancelAnimationFrame(J.current),0),ue.current=n,i(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}),U.current=``,W.current=[],oe.current=null,q.current=!0;let r=0,a=()=>{let t=Math.min(r+100,e.length);for(let n=r;n<t;n++)De(e[n]);r=t,r<e.length?J.current=requestAnimationFrame(a):(J.current=0,q.current=!1,f(!1))};J.current=requestAnimationFrame(a);return}De(t)}},[De]),{send:Z,connect:ke}=m({url:e&&n?`/ws/project/${encodeURIComponent(n)}/chat/${e}`:``,onMessage:Oe,autoConnect:!!e&&!!n});K.current=Z,(0,Q.useEffect)(()=>{let r=!1;H.current&&H.current!==e&&(F.current=null),H.current=e??null,u(`idle`),G.current=`idle`,_(null),Y.current!=null&&(fe.dismiss(Y.current),Y.current=null),x(null),o(new Map),U.current=``,W.current=[],ue.current=null,ae.current.clear(),he.current&&=(clearTimeout(he.current),0),k(!1),A(null),X.current={teamNames:new Set,messages:[]},ge.current=0,ve(At),be([]);let a=new Set(pe.current.map(e=>e.id));return e&&n?(c(!0),fetch(`${j(n)}/chat/sessions/${e}/messages?providerId=${t}`,{headers:{Authorization:`Bearer ${ne()}`}}).then(e=>e.json()).then(e=>{if(r)return;let t=e.ok&&Array.isArray(e.data)?e.data:[],n=ue.current;if(n!=null){for(let e=t.length-1;e>=0;e--)if(t[e].role===`user`&&t[e].content===n){t=t.slice(0,e);break}}i(e=>{let n=e.filter(e=>!a.has(e.id));return[...t,...n]})}).catch(()=>{r||i(e=>e.filter(e=>!a.has(e.id)))}).finally(()=>{r||c(!1)})):i([]),()=>{r=!0}},[e,t,n]);let Ae=(0,Q.useCallback)((e,t)=>{if(!e.trim())return;let n=G.current!==`idle`;if(n){he.current&&=(clearTimeout(he.current),0);let e=U.current,t=[...W.current];i(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})}i(t=>[...t,{id:`user-${Date.now()}`,role:`user`,content:e,timestamp:new Date().toISOString()}]),U.current=``,W.current=[],se.current=null,n?(u(`thinking`),G.current=`thinking`):(u(`initializing`),G.current=`initializing`),_(null),Y.current!=null&&(fe.dismiss(Y.current),Y.current=null),Z(JSON.stringify({type:`message`,content:e,permissionMode:t?.permissionMode,priority:t?.priority,images:t?.images,...P.current&&{model:P.current},...R.current&&{effort:R.current},...V.current!==null&&{thinking:V.current}}))},[Z]),je=(0,Q.useCallback)(e=>{re(e),P.current=e,F.current=e,Z(JSON.stringify({type:`set_model`,model:e}))},[Z]),Me=(0,Q.useCallback)(e=>{L(e),R.current=e,Z(JSON.stringify({type:`set_effort`,effort:e}))},[Z]),Ne=(0,Q.useCallback)(e=>{B(e),V.current=e,Z(JSON.stringify({type:`set_thinking`,enabled:e}))},[Z]),Pe=(0,Q.useCallback)((e,t,n)=>{if(Z(JSON.stringify({type:`approval_response`,requestId:e,approved:t,data:n})),t&&n){let t=W.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)}i(e=>[...e])}_(null),Y.current!=null&&(fe.dismiss(Y.current),Y.current=null)},[Z]),Fe=(0,Q.useCallback)(()=>{if(G.current===`idle`)return;Z(JSON.stringify({type:`cancel`}));let e=U.current,t=[...W.current];i(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}),U.current=``,W.current=[],ae.current.clear(),se.current=null,u(`idle`),G.current=`idle`,_(null),Y.current!=null&&(fe.dismiss(Y.current),Y.current=null)},[Z]),Ie=(0,Q.useCallback)(e=>{e&&Z(JSON.stringify({type:`kill_background_shell`,shellId:e}))},[Z]),Le=(0,Q.useCallback)(e=>{if(!e)return;let t=e.replace(/\.output$/,``);return w.current.find(n=>n.shellId===t||n.outputPath.endsWith(e)||n.outputPath.endsWith(`${t}.output`))},[]);(0,Q.useEffect)(()=>{e&&Qe.getState().setSessionShells(e,S)},[e,S]),(0,Q.useEffect)(()=>{if(e)return Qe.getState().retainSession(e),()=>{Qe.getState().releaseSession(e)}},[e]);let Re=(0,Q.useCallback)(()=>{k(!1),f(!0),ke()},[ke]),ze=(0,Q.useCallback)(()=>{!e||!n||fetch(`${j(n)}/chat/sessions/${e}/messages?providerId=${t}`,{headers:{Authorization:`Bearer ${ne()}`}}).then(e=>e.json()).then(e=>{G.current===`idle`&&e.ok&&Array.isArray(e.data)&&e.data.length>0&&(i(e.data),U.current=``,W.current=[])}).catch(()=>{})},[e,t,n]);ce.current=ze;let Ve=(0,Q.useCallback)(async(e,t)=>{if(!n)throw Error(`No project context available`);let r=e.replace(/^pc-[^-]+-/,``),i=`${j(n)}/chat/pre-compact-messages?jsonlPath=${encodeURIComponent(t)}&before=${encodeURIComponent(r)}`,a=bt(await M.get(i),t);return o(t=>{let n=new Map(t);return n.set(e,a),n}),a.length},[n]),He=(0,Q.useCallback)(e=>a.has(e),[a]),Ue=(0,Q.useCallback)(e=>{i(t=>t.filter(t=>t.id!==e))},[]),We=(0,Q.useCallback)(()=>{i(e=>e.filter(e=>e.role!==`system`))},[]);return{messages:r,renderedMessages:(0,Q.useMemo)(()=>xt(r,a),[r,a]),expandCompact:Ve,isCompactExpanded:He,dismissMessage:Ue,clearErrors:We,messagesLoading:s,isStreaming:Ce,phase:l,isReconnecting:d,connectingElapsed:p,pendingApproval:g,contextWindowPct:v,compactStatus:b,statusMessage:T,sessionTitle:D,model:N,setModel:je,effort:I,setEffort:Me,thinking:z,setThinking:Ne,teamActivity:_e,teamMessages:ye,markTeamRead:Se,bashPartialOutput:ae,backgroundShells:S,killBackgroundShell:Ie,findBackgroundShellByOutput:Le,sendMessage:Ae,respondToApproval:Pe,cancelStreaming:Fe,reconnect:Re,refetchMessages:ze,isConnected:ee&&te===e}}var Nt=12e4;function Pt(e,t=`claude`){let[n,r]=(0,Q.useState)({}),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(null),c=(0,Q.useRef)(null),l=(0,Q.useCallback)((n=!1)=>{if(!e)return;a(!0);let i=n?`&refresh=1`:``;fetch(`${j(e)}/chat/usage?providerId=${t}${i}`,{headers:{Authorization:`Bearer ${ne()}`}}).then(e=>e.json()).then(e=>{e.ok&&e.data&&(r(t=>({...t,...e.data})),e.data.lastFetchedAt&&s(e.data.lastFetchedAt))}).catch(()=>{}).finally(()=>a(!1))},[e,t]);return(0,Q.useEffect)(()=>(l(),c.current=setInterval(()=>l(),Nt),()=>{c.current&&clearInterval(c.current)}),[l]),{usageInfo:n,usageLoading:i,lastFetchedAt:o,refreshUsage:(0,Q.useCallback)(()=>l(!0),[l])}}var Ft={damping:.7,stiffness:.05,mass:1.25},It=70,Lt=1e3/60,Rt=350,zt=!1;globalThis.document?.addEventListener(`mousedown`,()=>{zt=!0}),globalThis.document?.addEventListener(`mouseup`,()=>{zt=!1}),globalThis.document?.addEventListener(`click`,()=>{zt=!1});var Bt=(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(!zt)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<=It}}},[]),f=(0,Q.useCallback)((e={})=>{typeof e==`string`&&(e={animation:e}),e.preserveScrollPosition||l(!0);let t=Date.now()+(Number(e.wait)||0),n=Ut(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))/Lt;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:Ut(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=Vt(e=>{g.current?.removeEventListener(`scroll`,m),g.current?.removeEventListener(`wheel`,h),e?.addEventListener(`scroll`,m,{passive:!0}),e?.addEventListener(`wheel`,h,{passive:!0})},[]),_=Vt(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=Ut(s.current,t?s.current.resize:s.current.initial);f({animation:e,wait:!0,preserveScrollPosition:!0,duration:e===`instant`?void 0:Rt})}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 Vt(e,t){let n=(0,Q.useCallback)(t=>(n.current=t,e(t)),t);return n}var Ht=new Map;function Ut(...e){let t={...Ft},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 Ht.has(r)||Ht.set(r,Object.freeze(t)),n?`instant`:Ht.get(r)}function Wt(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(()=>{M.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 $=n(),Gt=new Set([`TaskCreate`,`TaskUpdate`,`TaskStop`]);function Kt(e){let t=0;for(let n of e)if(n.events)for(let e of n.events)e.type===`tool_use`&&Gt.has(e.tool)&&t++;return t}var qt={completed:{icon:`✓`,cls:`text-success`},in_progress:{icon:`▶`,cls:`text-warning`},stopped:{icon:`■`,cls:`text-text-subtle`},pending:{icon:`○`,cls:`text-text-subtle`}};function Jt({projectName:e,sessionId:t,messages:n}){let r=(0,Q.useMemo)(()=>Kt(n),[n]),i=Wt(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 s=i.filter(e=>e.status===`completed`).length,c=i.length,u=c?Math.round(s/c*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)(d,{className:`size-3.5 shrink-0`}):(0,$.jsx)(l,{className:`size-3.5 shrink-0`}),(0,$.jsx)(h,{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:[s,`/`,c,` 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:`${u}%`}})})]}),!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)(Yt,{task:e},e.id))})]})}function Yt({task:e}){let t=qt[e.status]??qt.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 Xt=/read the full transcript at:\s*(\S+\.jsonl)/i;function Zt(e){return e.match(Xt)?.[1]?.trim()??null}var Qt=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 $t({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)(tt,{projectName:e,onSelectSession:t,className:`w-full px-4`})]})}function en(e){try{return new Date(e).toLocaleString()}catch{return``}}function tn({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 nn({content:e}){let[t,n]=(0,Q.useState)(!1);return(0,$.jsx)(tn,{icon:t?(0,$.jsx)(o,{className:`size-3.5`}):(0,$.jsx)(Ye,{className:`size-3.5`}),label:t?`Copied`:`Copy`,title:`Copy message to clipboard`,onClick:()=>{navigator.clipboard?.writeText(e).catch(()=>{}),n(!0),setTimeout(()=>n(!1),1500)}})}function rn({timestamp:e,content:t,accountLabel:n,className:r,children:i}){return(0,$.jsxs)(`div`,{className:P(`flex items-center gap-0.5 flex-wrap text-xs text-text-subtle select-none`,r),children:[(0,$.jsx)(`time`,{title:en(e),className:`pr-1 tabular-nums`,children:Z(e)}),n&&(0,$.jsxs)(`span`,{className:`px-1 truncate max-w-40`,children:[`via `,n]}),(0,$.jsx)(nn,{content:t}),i]})}var an=new Map;function on(){an.clear()}function sn(e,t,n,r){let i=`${t}:${r}`,a=an.get(i);return a||(a=M.get(`${j(e)}/chat/sessions/${t}/versions?ordinal=${r}&providerId=${n}`).catch(()=>null),an.set(i,a)),a}function cn({projectName:e,sessionId:t,providerId:n,ordinal:r,onNavigate:i,disabled:a}){let[o,s]=(0,Q.useState)(null);if((0,Q.useEffect)(()=>{if(!e||!t||!r||r<1){s(null);return}let i=!0;return sn(e,t,n,r).then(e=>{i&&s(e&&e.versions.length>=2?e:null)}),()=>{i=!1}},[e,t,n,r]),!o)return null;let{versions:c,currentIndex:l}=o,u=e=>{let t=c[e];t&&!a&&i(t.id)};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:()=>u(l-1),disabled:a||l<=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)(Ge,{className:`size-3.5`})}),(0,$.jsxs)(`span`,{className:`tabular-nums`,children:[l+1,`/`,c.length]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>u(l+1),disabled:a||l>=c.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)(d,{className:`size-3.5`})})]})}function ln(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 un(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=document.activeElement===e.customInputRef.current;if(!i&&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(!i&&(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(!i){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`&&i&&e.customInputRef.current?.blur()},a=r.current;return a&&(a.addEventListener(`keydown`,i),a.setAttribute(`tabindex`,`0`),a.contains(document.activeElement)||a.focus()),()=>{a?.removeEventListener(`keydown`,i)}},[e,t]),{focusedOption:t,setFocusedOption:n,containerRef:r}}function dn({questions:e,onSubmit:t,onSkip:n}){let r=(0,Q.useRef)(null),i=ln(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=un({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 fn=N(()=>import(`./markdown-renderer-DCsEEdo7.js`),__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])),pn=(0,Q.lazy)(()=>fn.then(e=>({default:e.MarkdownRenderer})));function mn({messages:e,messagesLoading:t,keepStaleWhileLoading:n,pendingApproval:r,onApprovalResponse:a,isStreaming:o,phase:s,onSelectSession:c,connectingElapsed:l,statusMessage:u,compactStatus:d,projectName:p,onFork:m,onEdit:h,editingMsgId:g,sessionId:_,providerId:v,onNavigateVersion:y,bashPartialOutput:b,onExpandCompact:x,isCompactExpanded:S,onDismissMessage:C,onClearErrors:w}){let{scrollRef:T,contentRef:E,scrollToBottom:D,stopScroll:O,isAtBottom:ee}=Bt({initial:`instant`,resize:`instant`}),k=(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]),te=!!r||o,[A,j]=(0,Q.useState)(null),ne=(0,Q.useCallback)(e=>{T(e),j(e)},[T]),M=(0,Q.useRef)(null);(0,Q.useLayoutEffect)(()=>{let e=A;e&&M.current!=null&&(e.scrollTop=e.scrollHeight-M.current,M.current=null)},[k.length,A]),(0,Q.useLayoutEffect)(()=>{A&&D({animation:`instant`})},[_,A]);let N=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{A&&A.clientHeight>0&&(N.current=ee)},[ee,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&&!N.current&&O()});return n.observe(e),()=>n.disconnect()},[A,O]);let re=(0,Q.useCallback)((e,t)=>{m?.(e,t)},[m]),P=(0,Q.useCallback)((e,t,n)=>{h?.(e,t,n)},[h]),F=(0,Q.useCallback)(e=>{C?.(e)},[C]),I=(0,Q.useMemo)(()=>k.reduce((e,t)=>t.role===`system`?e+1:e,0),[k]),ie=(0,Q.useMemo)(()=>k.reduce((e,t,n)=>(t.role===`user`&&e.push(n),e),[]),[k]),L=(0,Q.useCallback)(()=>{if(!x||!S)return null;for(let e of k){if(S(e.id))continue;let t=Zt(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=Zt(t.content||``);if(n)return{id:e.id,jsonlPath:n}}}}return null},[k,x,S])(),R=!!L,[z,B]=(0,Q.useState)(!1),V=(0,Q.useCallback)(async()=>{if(!L||!x||z)return;let e=A;M.current=e?e.scrollHeight-e.scrollTop:null,B(!0);try{await x(L.id,L.jsonlPath)}finally{B(!1)}},[L,x,z,A]);return(0,Q.useEffect)(()=>{let e=A;if(!e||!R)return;let t=()=>{e.scrollTop<200&&!z&&V()};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[A,R,z,V]),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)($t,{projectName:p||``,onSelectSession:c||(()=>{})}):(0,$.jsxs)(`div`,{className:`relative flex-1 overflow-hidden flex flex-col min-h-0`,children:[(0,$.jsx)(Jt,{projectName:p,sessionId:_,messages:e}),I>1&&w&&(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:w,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)(f,{className:`size-3.5`}),`Clear all errors (`,I,`)`]})}),z&&(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)(Ie,{className:`size-3 animate-spin`}),`Loading previous conversation...`]}),(0,$.jsx)(`div`,{ref:ne,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:[k.map((e,t)=>{let n=t>0?k[t-1]:void 0,r=e.role===`user`?k.slice(0,t+1).reduce((e,t)=>e+(t.role===`user`?1:0),0):0,i=e.role===`user`&&g!=null&&e.id===g,a=k[t+1],s=e.role===`assistant`&&a?.role!==`assistant`,c;if(s){let e=[];for(let n=t;n>=0&&k[n].role===`assistant`;n--){let t=gn(k[n]);t&&e.unshift(t)}c=e.join(`
|
|
3
3
|
|
|
4
4
|
`)}return(0,$.jsx)(`div`,{"data-msg-index":t,className:`px-4 pt-4 select-none`,children:(0,$.jsx)(Qt,{fallbackContent:e.content,children:(0,$.jsx)(_n,{message:e,isStreaming:o&&e.id.startsWith(`streaming-`),isLastAssistantInTurn:s,turnCopyText:c,projectName:p,onFork:e.role===`user`&&m?re:void 0,onEdit:e.role===`user`&&h?P:void 0,isEditing:i,onDismiss:e.role===`system`&&C?F:void 0,prevMsgId:n?.sdkUuid??n?.id,sessionId:_,providerId:v,versionOrdinal:r,onNavigateVersion:y,versionNavDisabled:o,bashPartialOutput:b})})},e.id)}),te&&(0,$.jsxs)(`div`,{className:`px-4 pt-4 pb-4 space-y-4 select-none`,children:[r&&(r.tool===`AskUserQuestion`?(0,$.jsx)(Yn,{approval:r,onRespond:a}):(0,$.jsx)(Jn,{approval:r,onRespond:a})),o&&(0,$.jsx)(Wn,{lastMessage:e[e.length-1],phase:s,elapsed:l,statusMessage:d===`compacting`?`Compacting messages...`:u})]})]})}),(0,$.jsx)(hn,{scrollElement:A,userIndices:ie,scrollToBottom:D})]})}function hn({scrollElement:e,userIndices:t,scrollToBottom:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!0),s=(e,t)=>t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop,c=(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=c(t).some(n=>s(t,n)<e-4);i(e=>e===n?e:n);let r=t.scrollHeight-t.scrollTop-t.clientHeight<8;o(e=>e===r?e:r)},a=()=>{n&&cancelAnimationFrame(n),n=requestAnimationFrame(r)};r(),t.addEventListener(`scroll`,a,{passive:!0});let l=new ResizeObserver(a);return l.observe(t),()=>{n&&cancelAnimationFrame(n),t.removeEventListener(`scroll`,a),l.disconnect()}},[e,c]);let u=(0,Q.useCallback)(()=>{let t=e;if(!t)return;let n=t.scrollTop,r;for(let e of c(t)){let i=s(t,e);if(i<n-4)r=i;else break}r!=null&&t.scrollTo({top:r,behavior:`auto`})},[e,c]),d=(0,Q.useCallback)(()=>{let t=e;if(!t)return;let r=t.scrollTop,i=c(t).map(e=>s(t,e)).find(e=>e>r+4);i==null?n({animation:`instant`}):t.scrollTo({top:i,behavior:`auto`})},[e,c,n]),f=`size-8 flex items-center justify-center rounded-full bg-surface-elevated/60 border border-border/60 text-text-secondary shadow-md backdrop-blur-sm transition-all hover:bg-surface-elevated hover:text-foreground disabled:opacity-30 disabled:cursor-default disabled:hover:bg-surface-elevated/60 disabled:hover:text-text-secondary`;return(0,$.jsxs)(`div`,{className:`absolute bottom-4 right-4 z-10 flex flex-col gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:u,disabled:!r,"aria-label":`Jump to previous message`,className:f,children:(0,$.jsx)(qe,{className:`size-4`})}),(0,$.jsx)(`button`,{type:`button`,onClick:d,disabled:a,"aria-label":`Jump to next message`,className:f,children:(0,$.jsx)(l,{className:`size-4`})})]})}function gn(e){return e.events?.length?e.events.filter(e=>e.type===`text`).map(e=>e.content).join(``):e.content}var _n=(0,Q.memo)(function({message:e,isStreaming:t,isLastAssistantInTurn:n,turnCopyText:r,projectName:i,onFork:a,onEdit:o,isEditing:s,onDismiss:c,prevMsgId:l,sessionId:u,providerId:d,versionOrdinal:p,onNavigateVersion:m,versionNavDisabled:h,bashPartialOutput:g}){if(e.role===`user`){let t=a?()=>a(e.content,l):void 0,n=o?()=>o(e.content,l,e.id):void 0;return(0,$.jsx)(kn,{content:e.content,messageId:e.id,timestamp:e.timestamp,projectName:i,onFork:t,onEdit:n,isEditing:s,sessionId:u,providerId:d,versionOrdinal:p,onNavigateVersion:m,versionNavDisabled:h})}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)(Xe,{className:`size-4 shrink-0`}),(0,$.jsx)(`p`,{className:`flex-1`,children:e.content}),c&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>c(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)(f,{className:`size-4`})})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.events&&e.events.length>0?(0,$.jsx)(Vn,{events:e.events,isStreaming:t,projectName:i,bashPartialOutput:g}):e.content&&(0,$.jsx)(`div`,{className:`text-sm text-text-primary select-text`,children:(0,$.jsx)(qn,{content:e.content,projectName:i})}),!t&&n&&(0,$.jsx)(rn,{timestamp:e.timestamp,content:r??gn(e),accountLabel:e.accountLabel,className:`-mt-1.5`})]})}),vn=new Set([`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`]),yn={"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 bn(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:yn[e]??e.replace(/^antml:/,``).replace(/-/g,` `),content:r[2].trim()})}return{cleanText:e.replace(n,``).trim(),tags:t}}function xn(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 Sn(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 Cn(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 wn(e){let t=e.match(/^\[Attached file: (.+?)\]\n*/);if(t)return{files:[t[1]],text:e.slice(t[0].length)};let n=e.match(/^\[Attached files:\n([\s\S]+?)\]\n*/);return n?{files:n[1].split(`
|
|
5
5
|
`).map(e=>e.trim()).filter(Boolean),text:e.slice(n[0].length)}:{files:[],text:e}}function Tn(e,t){let n=I(e);return`/api/project/${encodeURIComponent(t??`_`)}/chat/uploads/${encodeURIComponent(n)}`}function En(e){let t=e.lastIndexOf(`.`);return t===-1?!1:vn.has(e.slice(t).toLowerCase())}var Dn=new Set([`task-notification`,`environment_details`,`local-command-caveat`]);function On(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 kn({content:e,messageId:t,timestamp:n,projectName:r,onFork:a,onEdit:o,isEditing:c,sessionId:u,providerId:d,versionOrdinal:f,onNavigateVersion:p,versionNavDisabled:m}){let{files:h,text:g,tags:_,command:v,terminalBlocks:y,idePath:b,agent:x}=(0,Q.useMemo)(()=>{let{idePath:t,cleanText:n}=Cn(e),{blocks:r,remainingText:i}=On(n),a=wn(i),{cleanText:o,tags:s}=bn(a.text.replace(/<local-command-(?:stdout|stderr)>([\s\S]*?)<\/local-command-(?:stdout|stderr)>/g,`$1`)),{command:c,cleanText:l}=xn(o),{agent:u,cleanText:d}=Sn(l),f=c?.args?d?`${c.args}\n\n${d}`:c.args:d;return{files:a.files,text:f,tags:s,command:c,terminalBlocks:r,idePath:t,agent:u}},[e]),S=_.some(e=>Dn.has(e.name)),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(!1),D=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{let e=D.current;if(!e)return;let t=()=>E(e.scrollHeight>e.clientHeight+2);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[g]),(0,$.jsxs)(`div`,{className:P(`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:P(`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)(jn,{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)(vt,{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)(Fn,{path:b,projectName:r})]}),h.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:h.map((e,t)=>En(e)?(0,$.jsx)(Bn,{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)(Re,{className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate max-w-32`,children:I(e)})]},t))}),y.length>0&&(0,$.jsx)(`div`,{className:`space-y-1.5`,children:y.map((e,t)=>(0,$.jsx)(An,{content:e},t))}),g&&(0,$.jsx)(`div`,{ref:D,className:P(`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)(Ln,{text:g,projectName:r}):(0,$.jsx)(In,{text:g})}),(T||C)&&(0,$.jsx)(`button`,{onClick:()=>w(!C),className:P(`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)(qe,{className:`size-3`}),`Show less`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(l,{className:`size-3`}),`Show more`]})}),!S&&p&&(0,$.jsx)(cn,{projectName:r,sessionId:u,providerId:d??`claude`,ordinal:f,onNavigate:p,disabled:m})]}),!S&&(0,$.jsxs)(rn,{timestamp:n,content:e,children:[o&&(0,$.jsx)(tn,{icon:(0,$.jsx)(s,{className:`size-3.5`}),label:`Edit`,title:`Edit this message (continue in the same tab)`,onClick:o}),a&&(0,$.jsx)(tn,{icon:(0,$.jsx)(de,{className:`size-3.5`}),label:`Fork`,title:`Retry from this message (fork into a new tab)`,onClick:a})]})]})}function An({content:e}){let[t,n]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:P(`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)(_e,{className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{children:`Terminal output`}),(0,$.jsx)(l,{className:P(`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 jn({tags:e}){return(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map((e,t)=>(0,$.jsx)(Mn,{tag:e},t))})}function Mn({tag:e}){let[t,n]=(0,Q.useState)(!1);return e.name===`task-notification`?(0,$.jsx)(Pn,{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)(Te,{className:`size-2.5`}),(0,$.jsx)(`span`,{children:e.label}),(0,$.jsx)(d,{className:P(`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 Nn(e,t){return e.match(RegExp(`<${t}>([\\s\\S]*?)</${t}>`))?.[1]?.trim()||void 0}function Pn({content:e}){let[t,n]=(0,Q.useState)(!1),r=Nn(e,`status`),i=Nn(e,`summary`),a=Nn(e,`output-file`),o=Nn(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)(et,{className:`size-2.5 text-success`}):(0,$.jsx)(f,{className:`size-2.5 text-warning`}),(0,$.jsx)(`span`,{className:`truncate max-w-80`,children:i??`Task notification`}),(0,$.jsx)(d,{className:P(`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)(Fn,{path:a}),o&&(0,$.jsx)(`div`,{className:`text-[11px] text-text-subtle/80 max-h-60 overflow-y-auto leading-relaxed`,children:(0,$.jsx)(qn,{content:o})})]})]})}function Fn({path:e,projectName:t}){return(0,$.jsxs)(`button`,{type:`button`,onClick:(0,Q.useCallback)(()=>{let n=R.getState().openTab,r=t??L.getState().activeProject?.name,i=I(e),a={filePath:e};r&&(a.projectName=r),M.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)(Re,{className:`size-2.5 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate max-w-60`,children:I(e)}),(0,$.jsx)(Ve,{className:`size-2 shrink-0 opacity-50`})]})}function In({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 Ln({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)(Fn,{path:e.value,projectName:t},n):(0,$.jsx)(`span`,{children:e.value},n))})}var Rn=new Map;function zn(e){let[t,n]=(0,Q.useState)(()=>Rn.get(e)?.url??null),[r,i]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{let t=Rn.get(e);if(t){n(t.url);return}let r=!1,a=ne();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);Rn.set(e,{url:i}),n(i)}).catch(()=>{r||i(!0)}),()=>{r=!0}},[e]),{blobUrl:t,error:r}}function Bn({filePath:e,projectName:t}){let{blobUrl:n,error:r}=zn(Tn(e,t)),i=Je(e=>e.open),a=I(e);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n&&i(n,a),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,className:`size-4 rounded-sm object-cover shrink-0`}):r?(0,$.jsx)(Ee,{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 Vn({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}n.type===`text`?a+=n.content:n.type===`tool_use`?(a&&=(i.push({kind:`text`,content:a}),``),i.push({kind:`tool`,tool:n})):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)(Hn,{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)(Un,{content:e.content,animate:r,projectName:n})},`text-${a}`)}return(0,$.jsx)(g,{tool:e.tool,result:e.result,completed:e.completed,projectName:n,bashPartialOutput:r},`tool-${a}`)})})}function Hn({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)(Ie,{className:`size-3 animate-spin`}):(0,$.jsx)(d,{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 Un({content:e,animate:t,projectName:n}){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(qn,{content:e,projectName:n,isStreaming:t}),t&&(0,$.jsx)(`span`,{className:`text-text-subtle text-sm animate-pulse`,children:`Thinking...`})]})}function Wn({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)(Ie,{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 Gn=/<teammate-message[^>]*>[\s\S]*?<\/teammate-message>/g;function Kn(e){return e.replace(Gn,``).replace(/\n{3,}/g,`
|
|
@@ -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{b as t,y as n}from"./vendor-markdown-CKTlmXbz.js";import"./vendor-ui-DMRGWRuc.js";import{t as r}from"./createLucideIcon-ConhwJnb.js";import{t as i}from"./chevron-right-DeUue2aK.js";import{a,c as o,i as s,n as c,o as l,t as u}from"./dialog-BpkAWOy8.js";import{t as d}from"./code-TekEnDFM.js";import{t as f}from"./database-COYAMZaw.js";import{n as p,r as m}from"./plus-DcuJuDC3.js";import{t as ee}from"./file-exclamation-point-DBEC-Kst.js";import{a as h,i as te,r as ne,t as g}from"./glide-data-grid-BrQskOnP.js";import{t as re}from"./shield-check-C3qYSU8a.js";import{t as ie}from"./shield-off-D5tU7gQT.js";import{t as _}from"./table-Di8pv2Y_.js";import{t as v}from"./x-BsFLg-T8.js";import{i as ae,t as y}from"./api-client-BK4NPNoY.js";import{q as b}from"./vendor-mermaid-DPpYkrMf.js";import{t as oe}from"./settings-store-DkRZhj-g.js";import{t as x}from"./utils-CSCvNZxE.js";import{t as se}from"./panel-store-DnbT1c8L.js";import{i as S}from"./project-store-Sbnqc41N.js";import{t as C}from"./tab-store-vn0viMOP.js";import{$ as ce,A as le,Ht as ue,J as w,Ot as T,Q as E,U as de,Vt as fe,X as D,Y as O,Z as k,Zt as A,an as j,cn as pe,dn as M,en as me,et as N,ft as P,in as F,j as he,jt as ge,nn as _e,nt as ve,o as ye,on as I,rn as L,sn as R,tt as z}from"./index-BiHrB3KU.js";import"./data-grid-types-CzEQU9PJ.js";import{t as be}from"./use-monaco-theme-jtYkroys.js";var xe=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`}]]),B=e(t(),1),V=n();function Se(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 Ce(e){return(await y.get(`/api/fs/browse?path=${encodeURIComponent(e)}`)).entries}function we({filePath:e,projectName:t,tabId:n,className:r}){let{updateTab:a,openTab:o}=C(w(e=>({updateTab:e.updateTab,openTab:e.openTab}))),s=(0,B.useRef)(null),c=(0,B.useMemo)(()=>Se(e),[e]);(0,B.useEffect)(()=>{s.current&&(s.current.scrollLeft=s.current.scrollWidth)},[c]);let l=(0,B.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,V.jsx)(`div`,{ref:s,className:r,children:c.map((e,t)=>(0,V.jsxs)(`div`,{className:`flex items-center shrink-0`,children:[t>0&&(0,V.jsx)(i,{className:`size-3 text-muted-foreground shrink-0 mx-0.5`}),(0,V.jsx)(Te,{segment:e,isLast:t===c.length-1,onFileClick:l})]},e.absPath))})}function Te({segment:e,isLast:t,onFileClick:n}){let[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)(null);function s(t){t&&r===null&&Ce(e.parentDir).then(i).catch(e=>{o(e.message||`Failed to browse`),i([])})}return(0,V.jsxs)(O,{onOpenChange:s,children:[(0,V.jsx)(z,{asChild:!0,children:(0,V.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,V.jsx)(D,{align:`start`,className:`max-h-[300px] overflow-y-auto p-1`,children:r===null?(0,V.jsx)(k,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):a?(0,V.jsx)(k,{disabled:!0,className:`text-xs text-destructive`,children:a}):r.length===0?(0,V.jsx)(k,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Empty`}):r.map(t=>(0,V.jsx)(Ee,{entry:t,activePath:e.absPath,onFileClick:n},t.path))})]})}function Ee({entry:e,activePath:t,onFileClick:n}){let r=H(e.name,e.type===`directory`),i=e.path===t,[a,o]=(0,B.useState)(null);if(e.type===`directory`){function s(t){t&&a===null&&Ce(e.path).then(o).catch(()=>o([]))}return(0,V.jsxs)(E,{onOpenChange:s,children:[(0,V.jsxs)(N,{className:`text-xs gap-1.5 ${i?`bg-muted`:``}`,children:[(0,V.jsx)(r,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`truncate`,children:e.name})]}),(0,V.jsx)(ce,{className:`max-h-[300px] overflow-y-auto p-1`,children:a===null?(0,V.jsx)(k,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):a.length===0?(0,V.jsx)(k,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Empty`}):a.map(e=>(0,V.jsx)(Ee,{entry:e,activePath:t,onFileClick:n},e.path))})]})}return(0,V.jsxs)(k,{className:`text-xs gap-1.5 cursor-pointer ${i?`bg-muted`:``}`,onClick:t=>n(e.path,t),children:[(0,V.jsx)(r,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`truncate`,children:e.name})]})}var De={ts:I,tsx:I,js:I,jsx:I,py:I,rs:I,go:I,html:I,css:I,scss:I,json:R,md:j,txt:j,yaml:F,yml:F};function H(e,t){return t?_e:De[e.split(`.`).pop()?.toLowerCase()??``]??L}function U(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 Oe(e){return[...e].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1)}function ke({filePath:e,projectName:t,tabId:n,className:r}){let a=P(e=>e.tree),{updateTab:o,openTab:s}=C(w(e=>({updateTab:e.updateTab,openTab:e.openTab}))),c=S(e=>e.projects.find(e=>e.name===t)?.path??``),l=(0,B.useRef)(null),{prefixParts:u,relativePath:d,isExternal:f}=(0,B.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,B.useMemo)(()=>U(a,d.split(`/`).filter(Boolean)),[a,d]);(0,B.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,V.jsx)(we,{filePath:e,projectName:t,tabId:n,className:r}):(0,V.jsxs)(`div`,{ref:l,className:r,children:[u.map((e,t)=>(0,V.jsxs)(`div`,{className:`flex items-center shrink-0`,children:[t>0&&(0,V.jsx)(i,{className:`size-3 text-muted-foreground shrink-0 mx-0.5`}),(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground px-1 py-0.5`,children:e})]},`prefix-${t}`)),p.map((e,n)=>(0,V.jsxs)(`div`,{className:`flex items-center shrink-0`,children:[(n>0||u.length>0)&&(0,V.jsx)(i,{className:`size-3 text-muted-foreground shrink-0 mx-0.5`}),(0,V.jsx)(W,{segment:e,isLast:n===p.length-1,projectName:t,onFileClick:m})]},e.fullPath))]})}function W({segment:e,isLast:t,projectName:n,onFileClick:r}){let i=P(e=>e.loadChildren),a=P(e=>e.loadedPaths),o=(0,B.useMemo)(()=>Oe(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,V.jsxs)(O,{onOpenChange:c,children:[(0,V.jsx)(z,{asChild:!0,children:(0,V.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,V.jsx)(D,{align:`start`,className:`max-h-[300px] p-1`,children:o.length===0?(0,V.jsx)(k,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):o.map(t=>(0,V.jsx)(G,{node:t,projectName:n,activePath:e.fullPath,onFileClick:r},t.path))})]})}function G({node:e,projectName:t,activePath:n,onFileClick:r}){let i=H(e.name,e.type===`directory`),a=e.path===n,o=P(e=>e.loadChildren),s=P(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,V.jsxs)(E,{onOpenChange:u,children:[(0,V.jsxs)(N,{className:`text-xs gap-1.5 ${a?`bg-muted`:``}`,children:[(0,V.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`truncate`,children:e.name})]}),(0,V.jsx)(ce,{className:`max-h-[300px] overflow-y-auto p-1`,children:c.length===0?(0,V.jsx)(k,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):Oe(c).map(e=>(0,V.jsx)(G,{node:e,projectName:t,activePath:n,onFileClick:r},e.path))})]})}return(0,V.jsxs)(k,{className:`text-xs gap-1.5 cursor-pointer ${a?`bg-muted`:``}`,onSelect:e=>{},onClick:t=>{r(e.path,t)},children:[(0,V.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`truncate`,children:e.name})]})}function K({active:e,onClick:t,icon:n,label:r}){return(0,V.jsxs)(`button`,{type:`button`,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,V.jsx)(n,{className:`size-3`}),(0,V.jsx)(`span`,{className:`hidden sm:inline`,children:r})]})}function Ae({ext:e,mdMode:t,onMdModeChange:n,csvMode:r,onCsvModeChange:i,wordWrap:a,onToggleWordWrap:o,onRefresh:s,refreshing:c,filePath:l,projectName:u,className:f}){return(0,V.jsxs)(`div`,{className:f,children:[(e===`md`||e===`mdx`)&&n&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(K,{active:t===`edit`,onClick:()=>n(`edit`),icon:d,label:`Edit`}),(0,V.jsx)(K,{active:t===`preview`,onClick:()=>n(`preview`),icon:p,label:`Preview`})]}),e===`csv`&&i&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(K,{active:r===`table`,onClick:()=>i(`table`),icon:_,label:`Table`}),(0,V.jsx)(K,{active:r===`raw`,onClick:()=>i(`raw`),icon:d,label:`Raw`})]}),(0,V.jsx)(K,{active:a,onClick:o,icon:ge,label:`Wrap`}),s&&(0,V.jsxs)(`button`,{type:`button`,onClick:s,disabled:c,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,V.jsx)(fe,{className:`size-3 ${c?`animate-spin`:``}`}),(0,V.jsx)(`span`,{className:`hidden sm:inline`,children:`Refresh`})]}),l&&u&&(0,V.jsx)(K,{active:!1,onClick:()=>ve(u,l),icon:m,label:`Download`})]})}var je=[{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 Me({value:e,onChange:t}){return(0,V.jsxs)(`div`,{className:`shrink-0 flex items-center gap-1 px-2 border-l border-border`,children:[(0,V.jsx)(I,{className:`size-3 text-muted-foreground`}),(0,V.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:je.map(e=>(0,V.jsx)(`option`,{value:e.id,children:e.label},e.id))})]})}function Ne({open:e,defaultName:t,content:n,onSave:r,onCancel:i}){let[d,f]=(0,B.useState)(t),[p,m]=(0,B.useState)(!1),[ee,h]=(0,B.useState)(``),te=S(e=>e.activeProject),ne=(0,B.useCallback)(()=>{let e=d.trim();if(!e){h(`Filename cannot be empty`);return}if(/[/\\]/.test(e)){h(`Filename cannot contain / or \\`);return}h(``),m(!0)},[d]),g=(0,B.useCallback)(e=>{let t=e.includes(`\\`)?`\\`:`/`;r(e.endsWith(t)?`${e}${d.trim()}`:`${e}${t}${d.trim()}`,n)},[d,n,r]);return p?(0,V.jsx)(he,{open:!0,mode:`folder`,root:te?.path,title:`Save "${d.trim()}" to...`,onSelect:g,onCancel:()=>m(!1)}):(0,V.jsx)(u,{open:e,onOpenChange:e=>{e||i()},children:(0,V.jsxs)(c,{className:`sm:max-w-md`,children:[(0,V.jsx)(a,{children:(0,V.jsx)(l,{children:`Save As`})}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[(0,V.jsx)(`label`,{className:`text-sm text-muted-foreground`,children:`Filename`}),(0,V.jsx)(de,{value:d,onChange:e=>{f(e.target.value),h(``)},onKeyDown:e=>{e.key===`Enter`&&ne()},placeholder:`e.g. my-file.ts`,autoFocus:!0}),ee&&(0,V.jsx)(`p`,{className:`text-xs text-destructive`,children:ee})]}),(0,V.jsxs)(s,{children:[(0,V.jsx)(o,{variant:`outline`,onClick:i,children:`Cancel`}),(0,V.jsx)(o,{onClick:ne,children:`Choose Folder...`})]})]})})}var q=typeof window<`u`&&window.isSecureContext,Pe=[`(`,`)`,`{`,`}`,`[`,`]`,`<`,`>`,`;`,`:`,`=`,`"`,`'`,"`",`/`,`\\`,`_`,`#`],Fe=`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`,Ie=`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`,Le=`w-px h-5 bg-border mx-0.5 shrink-0`;function Re({editorRef:e,readOnly:t}){let n=(0,B.useCallback)(()=>e.current,[e]),r=(0,B.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,B.useState)(!1),o=(0,B.useRef)(null),s=(0,B.useCallback)(async()=>{try{let e=await navigator.clipboard.readText();e&&r(e)}catch{}},[r]),c=(0,B.useCallback)(()=>{a(!0),requestAnimationFrame(()=>o.current?.focus())},[]),l=(0,B.useCallback)(e=>{e.preventDefault();let t=e.clipboardData.getData(`text/plain`);t&&(a(!1),r(t))},[r]),u=(0,B.useCallback)(()=>{let e=n();e&&(e.focus(),e.trigger(`mobile-toolbar`,`undo`,null))},[n]),d=(0,B.useCallback)(()=>{let e=n();e&&(e.focus(),e.trigger(`mobile-toolbar`,`redo`,null))},[n]),f=(0,B.useCallback)(()=>{let e=n();e&&(e.focus(),e.trigger(`mobile-toolbar`,`tab`,null))},[n]);return t?null:(0,V.jsxs)(`div`,{className:`shrink-0 border-t border-border bg-surface`,children:[!q&&i&&(0,V.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 border-b border-border bg-muted/50`,children:[(0,V.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,V.jsx)(`button`,{type:`button`,onClick:()=>a(!1),className:`p-1.5 rounded text-muted-foreground active:bg-muted transition-colors`,children:(0,V.jsx)(v,{size:14})})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1.5 overflow-x-auto`,children:[(0,V.jsx)(`button`,{type:`button`,onClick:q?s:c,className:Fe,title:`Paste`,children:(0,V.jsx)(M,{size:14})}),(0,V.jsx)(`button`,{type:`button`,onClick:u,className:Fe,title:`Undo`,children:(0,V.jsx)(T,{size:14})}),(0,V.jsx)(`button`,{type:`button`,onClick:d,className:Fe,title:`Redo`,children:(0,V.jsx)(xe,{size:14})}),(0,V.jsx)(`div`,{className:Le}),(0,V.jsx)(`button`,{type:`button`,onClick:f,className:Ie,children:`Tab`}),(0,V.jsx)(`div`,{className:Le}),Pe.map(e=>(0,V.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:Ie,children:e},e))]})]})}var J=(0,B.lazy)(()=>b(()=>import(`./markdown-renderer-XIhxiUQq.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]))),ze=(0,B.lazy)(()=>b(()=>import(`./csv-preview-YxR9adj_.js`).then(e=>({default:e.CsvPreview})),__vite__mapDeps([29,2,5,1,6,3,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,30,31]))),Be=(0,B.lazy)(()=>b(()=>import(`./image-preview-B9EWGEFv.js`).then(e=>({default:e.ImagePreview})),__vite__mapDeps([32,5,2,1,6,3,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,33,34]))),Ve=(0,B.lazy)(()=>b(()=>import(`./pdf-preview-Zl3KICd5.js`).then(e=>({default:e.PdfPreview})),__vite__mapDeps([35,2,5,1,6,3,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,33]))),He=(0,B.lazy)(()=>b(()=>import(`./video-preview-Ced_VIvq.js`).then(e=>({default:e.VideoPreview})),__vite__mapDeps([36,5,2,1,6,3,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,33,34]))),Ue=(0,B.lazy)(()=>b(()=>import(`./audio-preview-BG8uEB67.js`).then(e=>({default:e.AudioPreview})),__vite__mapDeps([37,5,2,1,6,3,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,33,34]))),We=(0,B.lazy)(()=>b(()=>import(`./docx-preview-Dsrm2Hgu.js`).then(e=>({default:e.DocxPreview})),__vite__mapDeps([38,2,5,1,6,3,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,33]))),Ge=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`ico`]),Ke=new Set([`mp4`,`webm`,`mov`,`ogg`,`avi`,`mkv`]),qe=new Set([`mp3`,`wav`,`flac`,`aac`,`m4a`,`wma`]),Je=new Set([`db`,`sqlite`,`sqlite3`]);function Ye(e){return e.split(`.`).pop()?.toLowerCase()??``}function Xe(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`}[Ye(e)]??`plaintext`}var Ze=(0,B.memo)(function({metadata:e,tabId:t}){let n=e?.filePath,r=e?.projectName,i=e?.inlineContent,a=e?.inlineLanguage,[o,s]=(0,B.useState)(i??null),[c,l]=(0,B.useState)(`utf-8`),[u,d]=(0,B.useState)(!0),[p,m]=(0,B.useState)(null),[g,_]=(0,B.useState)(!1),v=(0,B.useRef)(null),b=(0,B.useRef)(``),S=(0,B.useRef)(null),{tabs:ce,updateTab:T}=C(w(e=>({tabs:e.tabs,updateTab:e.updateTab}))),{wordWrap:E,toggleWordWrap:de}=oe(w(e=>({wordWrap:e.wordWrap,toggleWordWrap:e.toggleWordWrap}))),fe=be(),D=e?.isUntitled===!0,O=e?.unsavedContent,[k,j]=(0,B.useState)(!1),pe=ce.find(e=>e.id===t),M=n?Ye(n):``,me=Ge.has(M),N=M===`pdf`,P=M===`docx`,F=Ke.has(M),he=qe.has(M),ge=Je.has(M),_e=M===`md`||M===`mdx`,ve=M===`csv`,I=e?.language,L=a??I??Xe(n??``),R=L===`sql`,[z,xe]=(0,B.useState)(`preview`),[Se,Ce]=(0,B.useState)(`table`),{connections:we,cachedTables:Te,refreshTables:Ee,updateConnection:De}=le(),H=n?`ppm:sql-conn:${n}`:t?`ppm:sql-conn:tab:${t}`:null,[U,Oe]=(0,B.useState)(()=>{if(!H)return null;let e=localStorage.getItem(H);return e?Number(e):null}),W=(0,B.useRef)(null),G=(0,B.useRef)(null),K=(0,B.useMemo)(()=>we.find(e=>e.id===U)??null,[we,U]),je=i!=null&&(a===`json`||a===`xml`),[q,Pe]=(0,B.useState)(!1),Fe=(0,B.useCallback)(()=>{if(i)if(q)s(i),Pe(!1);else{let e=i.trimStart();if(a===`json`)try{s(JSON.stringify(JSON.parse(e),null,2)),Pe(!0)}catch{}else if(a===`xml`){let t=0;s(e.replace(/(>)(<)(\/*)/g,`$1
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/markdown-renderer-DCsEEdo7.js","assets/vendor-mermaid-DPpYkrMf.js","assets/rolldown-runtime-FhOqtrmT.js","assets/vendor-markdown-CKTlmXbz.js","assets/markdown-renderer-BNXJygz9.js","assets/index-4M24PSHW.js","assets/vendor-ui-DMRGWRuc.js","assets/dialog-BpkAWOy8.js","assets/utils-CSCvNZxE.js","assets/createLucideIcon-ConhwJnb.js","assets/x-BsFLg-T8.js","assets/eye-off-Rq1n2-oe.js","assets/bot-E9mcVZnr.js","assets/mobile-bottom-sheet--5_YEewV.js","assets/chevron-right-DeUue2aK.js","assets/use-is-mobile-CE6AamG6.js","assets/sparkles-B3DmG8PJ.js","assets/database-COYAMZaw.js","assets/plus-DcuJuDC3.js","assets/react-CorNPdie.js","assets/api-client-BK4NPNoY.js","assets/api-settings-BJTjIG4U.js","assets/project-store-Sbnqc41N.js","assets/panel-store-DnbT1c8L.js","assets/settings-store-DkRZhj-g.js","assets/tab-store-vn0viMOP.js","assets/apply-theme-DxKsrDLA.js","assets/resolve-theme-CCoakF2E.js","assets/index-BYFXiFsa.css","assets/csv-preview-BqszurHp.js","assets/lib-CxSBdrd7.js","assets/csv-parser-B_xNn07y.js","assets/image-preview-CaX4gpN6.js","assets/file-exclamation-point-DBEC-Kst.js","assets/use-blob-url-DdXgVqfz.js","assets/pdf-preview-DZzbm9A4.js","assets/video-preview-DxdyVATR.js","assets/audio-preview-CLn1LTxc.js","assets/docx-preview-BAzpJdua.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,y as n}from"./vendor-markdown-CKTlmXbz.js";import"./vendor-ui-DMRGWRuc.js";import{t as r}from"./createLucideIcon-ConhwJnb.js";import{t as i}from"./chevron-right-DeUue2aK.js";import{a,c as o,i as s,n as c,o as l,t as u}from"./dialog-BpkAWOy8.js";import{t as d}from"./code-TekEnDFM.js";import{t as f}from"./database-COYAMZaw.js";import{n as p,r as m}from"./plus-DcuJuDC3.js";import{t as ee}from"./file-exclamation-point-DBEC-Kst.js";import{a as h,i as te,r as ne,t as g}from"./glide-data-grid-z9FPvRBG.js";import{t as re}from"./shield-check-C3qYSU8a.js";import{t as ie}from"./shield-off-D5tU7gQT.js";import{t as _}from"./table-Di8pv2Y_.js";import{t as v}from"./x-BsFLg-T8.js";import{i as ae,t as y}from"./api-client-BK4NPNoY.js";import{q as b}from"./vendor-mermaid-DPpYkrMf.js";import{t as oe}from"./settings-store-DkRZhj-g.js";import{t as x}from"./utils-CSCvNZxE.js";import{t as se}from"./panel-store-DnbT1c8L.js";import{i as S}from"./project-store-Sbnqc41N.js";import{t as C}from"./tab-store-vn0viMOP.js";import{$ as ce,A as le,Ht as ue,J as w,Ot as T,Q as E,U as de,Vt as fe,X as D,Y as O,Z as k,Zt as A,an as j,cn as pe,dn as M,en as me,et as N,ft as P,in as F,j as he,jt as ge,nn as _e,nt as ve,o as ye,on as I,rn as L,sn as R,tt as z}from"./index-4M24PSHW.js";import"./data-grid-types-CzEQU9PJ.js";import{t as be}from"./use-monaco-theme-BvzqffqR.js";var xe=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`}]]),B=e(t(),1),V=n();function Se(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 Ce(e){return(await y.get(`/api/fs/browse?path=${encodeURIComponent(e)}`)).entries}function we({filePath:e,projectName:t,tabId:n,className:r}){let{updateTab:a,openTab:o}=C(w(e=>({updateTab:e.updateTab,openTab:e.openTab}))),s=(0,B.useRef)(null),c=(0,B.useMemo)(()=>Se(e),[e]);(0,B.useEffect)(()=>{s.current&&(s.current.scrollLeft=s.current.scrollWidth)},[c]);let l=(0,B.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,V.jsx)(`div`,{ref:s,className:r,children:c.map((e,t)=>(0,V.jsxs)(`div`,{className:`flex items-center shrink-0`,children:[t>0&&(0,V.jsx)(i,{className:`size-3 text-muted-foreground shrink-0 mx-0.5`}),(0,V.jsx)(Te,{segment:e,isLast:t===c.length-1,onFileClick:l})]},e.absPath))})}function Te({segment:e,isLast:t,onFileClick:n}){let[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)(null);function s(t){t&&r===null&&Ce(e.parentDir).then(i).catch(e=>{o(e.message||`Failed to browse`),i([])})}return(0,V.jsxs)(O,{onOpenChange:s,children:[(0,V.jsx)(z,{asChild:!0,children:(0,V.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,V.jsx)(D,{align:`start`,className:`max-h-[300px] overflow-y-auto p-1`,children:r===null?(0,V.jsx)(k,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):a?(0,V.jsx)(k,{disabled:!0,className:`text-xs text-destructive`,children:a}):r.length===0?(0,V.jsx)(k,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Empty`}):r.map(t=>(0,V.jsx)(Ee,{entry:t,activePath:e.absPath,onFileClick:n},t.path))})]})}function Ee({entry:e,activePath:t,onFileClick:n}){let r=H(e.name,e.type===`directory`),i=e.path===t,[a,o]=(0,B.useState)(null);if(e.type===`directory`){function s(t){t&&a===null&&Ce(e.path).then(o).catch(()=>o([]))}return(0,V.jsxs)(E,{onOpenChange:s,children:[(0,V.jsxs)(N,{className:`text-xs gap-1.5 ${i?`bg-muted`:``}`,children:[(0,V.jsx)(r,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`truncate`,children:e.name})]}),(0,V.jsx)(ce,{className:`max-h-[300px] overflow-y-auto p-1`,children:a===null?(0,V.jsx)(k,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):a.length===0?(0,V.jsx)(k,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Empty`}):a.map(e=>(0,V.jsx)(Ee,{entry:e,activePath:t,onFileClick:n},e.path))})]})}return(0,V.jsxs)(k,{className:`text-xs gap-1.5 cursor-pointer ${i?`bg-muted`:``}`,onClick:t=>n(e.path,t),children:[(0,V.jsx)(r,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`truncate`,children:e.name})]})}var De={ts:I,tsx:I,js:I,jsx:I,py:I,rs:I,go:I,html:I,css:I,scss:I,json:R,md:j,txt:j,yaml:F,yml:F};function H(e,t){return t?_e:De[e.split(`.`).pop()?.toLowerCase()??``]??L}function U(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 Oe(e){return[...e].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1)}function ke({filePath:e,projectName:t,tabId:n,className:r}){let a=P(e=>e.tree),{updateTab:o,openTab:s}=C(w(e=>({updateTab:e.updateTab,openTab:e.openTab}))),c=S(e=>e.projects.find(e=>e.name===t)?.path??``),l=(0,B.useRef)(null),{prefixParts:u,relativePath:d,isExternal:f}=(0,B.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,B.useMemo)(()=>U(a,d.split(`/`).filter(Boolean)),[a,d]);(0,B.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,V.jsx)(we,{filePath:e,projectName:t,tabId:n,className:r}):(0,V.jsxs)(`div`,{ref:l,className:r,children:[u.map((e,t)=>(0,V.jsxs)(`div`,{className:`flex items-center shrink-0`,children:[t>0&&(0,V.jsx)(i,{className:`size-3 text-muted-foreground shrink-0 mx-0.5`}),(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground px-1 py-0.5`,children:e})]},`prefix-${t}`)),p.map((e,n)=>(0,V.jsxs)(`div`,{className:`flex items-center shrink-0`,children:[(n>0||u.length>0)&&(0,V.jsx)(i,{className:`size-3 text-muted-foreground shrink-0 mx-0.5`}),(0,V.jsx)(W,{segment:e,isLast:n===p.length-1,projectName:t,onFileClick:m})]},e.fullPath))]})}function W({segment:e,isLast:t,projectName:n,onFileClick:r}){let i=P(e=>e.loadChildren),a=P(e=>e.loadedPaths),o=(0,B.useMemo)(()=>Oe(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,V.jsxs)(O,{onOpenChange:c,children:[(0,V.jsx)(z,{asChild:!0,children:(0,V.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,V.jsx)(D,{align:`start`,className:`max-h-[300px] p-1`,children:o.length===0?(0,V.jsx)(k,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):o.map(t=>(0,V.jsx)(G,{node:t,projectName:n,activePath:e.fullPath,onFileClick:r},t.path))})]})}function G({node:e,projectName:t,activePath:n,onFileClick:r}){let i=H(e.name,e.type===`directory`),a=e.path===n,o=P(e=>e.loadChildren),s=P(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,V.jsxs)(E,{onOpenChange:u,children:[(0,V.jsxs)(N,{className:`text-xs gap-1.5 ${a?`bg-muted`:``}`,children:[(0,V.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`truncate`,children:e.name})]}),(0,V.jsx)(ce,{className:`max-h-[300px] overflow-y-auto p-1`,children:c.length===0?(0,V.jsx)(k,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):Oe(c).map(e=>(0,V.jsx)(G,{node:e,projectName:t,activePath:n,onFileClick:r},e.path))})]})}return(0,V.jsxs)(k,{className:`text-xs gap-1.5 cursor-pointer ${a?`bg-muted`:``}`,onSelect:e=>{},onClick:t=>{r(e.path,t)},children:[(0,V.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`truncate`,children:e.name})]})}function K({active:e,onClick:t,icon:n,label:r}){return(0,V.jsxs)(`button`,{type:`button`,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,V.jsx)(n,{className:`size-3`}),(0,V.jsx)(`span`,{className:`hidden sm:inline`,children:r})]})}function Ae({ext:e,mdMode:t,onMdModeChange:n,csvMode:r,onCsvModeChange:i,wordWrap:a,onToggleWordWrap:o,onRefresh:s,refreshing:c,filePath:l,projectName:u,className:f}){return(0,V.jsxs)(`div`,{className:f,children:[(e===`md`||e===`mdx`)&&n&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(K,{active:t===`edit`,onClick:()=>n(`edit`),icon:d,label:`Edit`}),(0,V.jsx)(K,{active:t===`preview`,onClick:()=>n(`preview`),icon:p,label:`Preview`})]}),e===`csv`&&i&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(K,{active:r===`table`,onClick:()=>i(`table`),icon:_,label:`Table`}),(0,V.jsx)(K,{active:r===`raw`,onClick:()=>i(`raw`),icon:d,label:`Raw`})]}),(0,V.jsx)(K,{active:a,onClick:o,icon:ge,label:`Wrap`}),s&&(0,V.jsxs)(`button`,{type:`button`,onClick:s,disabled:c,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,V.jsx)(fe,{className:`size-3 ${c?`animate-spin`:``}`}),(0,V.jsx)(`span`,{className:`hidden sm:inline`,children:`Refresh`})]}),l&&u&&(0,V.jsx)(K,{active:!1,onClick:()=>ve(u,l),icon:m,label:`Download`})]})}var je=[{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 Me({value:e,onChange:t}){return(0,V.jsxs)(`div`,{className:`shrink-0 flex items-center gap-1 px-2 border-l border-border`,children:[(0,V.jsx)(I,{className:`size-3 text-muted-foreground`}),(0,V.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:je.map(e=>(0,V.jsx)(`option`,{value:e.id,children:e.label},e.id))})]})}function Ne({open:e,defaultName:t,content:n,onSave:r,onCancel:i}){let[d,f]=(0,B.useState)(t),[p,m]=(0,B.useState)(!1),[ee,h]=(0,B.useState)(``),te=S(e=>e.activeProject),ne=(0,B.useCallback)(()=>{let e=d.trim();if(!e){h(`Filename cannot be empty`);return}if(/[/\\]/.test(e)){h(`Filename cannot contain / or \\`);return}h(``),m(!0)},[d]),g=(0,B.useCallback)(e=>{let t=e.includes(`\\`)?`\\`:`/`;r(e.endsWith(t)?`${e}${d.trim()}`:`${e}${t}${d.trim()}`,n)},[d,n,r]);return p?(0,V.jsx)(he,{open:!0,mode:`folder`,root:te?.path,title:`Save "${d.trim()}" to...`,onSelect:g,onCancel:()=>m(!1)}):(0,V.jsx)(u,{open:e,onOpenChange:e=>{e||i()},children:(0,V.jsxs)(c,{className:`sm:max-w-md`,children:[(0,V.jsx)(a,{children:(0,V.jsx)(l,{children:`Save As`})}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[(0,V.jsx)(`label`,{className:`text-sm text-muted-foreground`,children:`Filename`}),(0,V.jsx)(de,{value:d,onChange:e=>{f(e.target.value),h(``)},onKeyDown:e=>{e.key===`Enter`&&ne()},placeholder:`e.g. my-file.ts`,autoFocus:!0}),ee&&(0,V.jsx)(`p`,{className:`text-xs text-destructive`,children:ee})]}),(0,V.jsxs)(s,{children:[(0,V.jsx)(o,{variant:`outline`,onClick:i,children:`Cancel`}),(0,V.jsx)(o,{onClick:ne,children:`Choose Folder...`})]})]})})}var q=typeof window<`u`&&window.isSecureContext,Pe=[`(`,`)`,`{`,`}`,`[`,`]`,`<`,`>`,`;`,`:`,`=`,`"`,`'`,"`",`/`,`\\`,`_`,`#`],Fe=`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`,Ie=`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`,Le=`w-px h-5 bg-border mx-0.5 shrink-0`;function Re({editorRef:e,readOnly:t}){let n=(0,B.useCallback)(()=>e.current,[e]),r=(0,B.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,B.useState)(!1),o=(0,B.useRef)(null),s=(0,B.useCallback)(async()=>{try{let e=await navigator.clipboard.readText();e&&r(e)}catch{}},[r]),c=(0,B.useCallback)(()=>{a(!0),requestAnimationFrame(()=>o.current?.focus())},[]),l=(0,B.useCallback)(e=>{e.preventDefault();let t=e.clipboardData.getData(`text/plain`);t&&(a(!1),r(t))},[r]),u=(0,B.useCallback)(()=>{let e=n();e&&(e.focus(),e.trigger(`mobile-toolbar`,`undo`,null))},[n]),d=(0,B.useCallback)(()=>{let e=n();e&&(e.focus(),e.trigger(`mobile-toolbar`,`redo`,null))},[n]),f=(0,B.useCallback)(()=>{let e=n();e&&(e.focus(),e.trigger(`mobile-toolbar`,`tab`,null))},[n]);return t?null:(0,V.jsxs)(`div`,{className:`shrink-0 border-t border-border bg-surface`,children:[!q&&i&&(0,V.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 border-b border-border bg-muted/50`,children:[(0,V.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,V.jsx)(`button`,{type:`button`,onClick:()=>a(!1),className:`p-1.5 rounded text-muted-foreground active:bg-muted transition-colors`,children:(0,V.jsx)(v,{size:14})})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1.5 overflow-x-auto`,children:[(0,V.jsx)(`button`,{type:`button`,onClick:q?s:c,className:Fe,title:`Paste`,children:(0,V.jsx)(M,{size:14})}),(0,V.jsx)(`button`,{type:`button`,onClick:u,className:Fe,title:`Undo`,children:(0,V.jsx)(T,{size:14})}),(0,V.jsx)(`button`,{type:`button`,onClick:d,className:Fe,title:`Redo`,children:(0,V.jsx)(xe,{size:14})}),(0,V.jsx)(`div`,{className:Le}),(0,V.jsx)(`button`,{type:`button`,onClick:f,className:Ie,children:`Tab`}),(0,V.jsx)(`div`,{className:Le}),Pe.map(e=>(0,V.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:Ie,children:e},e))]})]})}var J=(0,B.lazy)(()=>b(()=>import(`./markdown-renderer-DCsEEdo7.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]))),ze=(0,B.lazy)(()=>b(()=>import(`./csv-preview-BqszurHp.js`).then(e=>({default:e.CsvPreview})),__vite__mapDeps([29,2,5,1,6,3,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,30,31]))),Be=(0,B.lazy)(()=>b(()=>import(`./image-preview-CaX4gpN6.js`).then(e=>({default:e.ImagePreview})),__vite__mapDeps([32,5,2,1,6,3,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,33,34]))),Ve=(0,B.lazy)(()=>b(()=>import(`./pdf-preview-DZzbm9A4.js`).then(e=>({default:e.PdfPreview})),__vite__mapDeps([35,2,5,1,6,3,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,33]))),He=(0,B.lazy)(()=>b(()=>import(`./video-preview-DxdyVATR.js`).then(e=>({default:e.VideoPreview})),__vite__mapDeps([36,5,2,1,6,3,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,33,34]))),Ue=(0,B.lazy)(()=>b(()=>import(`./audio-preview-CLn1LTxc.js`).then(e=>({default:e.AudioPreview})),__vite__mapDeps([37,5,2,1,6,3,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,33,34]))),We=(0,B.lazy)(()=>b(()=>import(`./docx-preview-BAzpJdua.js`).then(e=>({default:e.DocxPreview})),__vite__mapDeps([38,2,5,1,6,3,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,33]))),Ge=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`ico`]),Ke=new Set([`mp4`,`webm`,`mov`,`ogg`,`avi`,`mkv`]),qe=new Set([`mp3`,`wav`,`flac`,`aac`,`m4a`,`wma`]),Je=new Set([`db`,`sqlite`,`sqlite3`]);function Ye(e){return e.split(`.`).pop()?.toLowerCase()??``}function Xe(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`}[Ye(e)]??`plaintext`}var Ze=(0,B.memo)(function({metadata:e,tabId:t}){let n=e?.filePath,r=e?.projectName,i=e?.inlineContent,a=e?.inlineLanguage,[o,s]=(0,B.useState)(i??null),[c,l]=(0,B.useState)(`utf-8`),[u,d]=(0,B.useState)(!0),[p,m]=(0,B.useState)(null),[g,_]=(0,B.useState)(!1),v=(0,B.useRef)(null),b=(0,B.useRef)(``),S=(0,B.useRef)(null),{tabs:ce,updateTab:T}=C(w(e=>({tabs:e.tabs,updateTab:e.updateTab}))),{wordWrap:E,toggleWordWrap:de}=oe(w(e=>({wordWrap:e.wordWrap,toggleWordWrap:e.toggleWordWrap}))),fe=be(),D=e?.isUntitled===!0,O=e?.unsavedContent,[k,j]=(0,B.useState)(!1),pe=ce.find(e=>e.id===t),M=n?Ye(n):``,me=Ge.has(M),N=M===`pdf`,P=M===`docx`,F=Ke.has(M),he=qe.has(M),ge=Je.has(M),_e=M===`md`||M===`mdx`,ve=M===`csv`,I=e?.language,L=a??I??Xe(n??``),R=L===`sql`,[z,xe]=(0,B.useState)(`preview`),[Se,Ce]=(0,B.useState)(`table`),{connections:we,cachedTables:Te,refreshTables:Ee,updateConnection:De}=le(),H=n?`ppm:sql-conn:${n}`:t?`ppm:sql-conn:tab:${t}`:null,[U,Oe]=(0,B.useState)(()=>{if(!H)return null;let e=localStorage.getItem(H);return e?Number(e):null}),W=(0,B.useRef)(null),G=(0,B.useRef)(null),K=(0,B.useMemo)(()=>we.find(e=>e.id===U)??null,[we,U]),je=i!=null&&(a===`json`||a===`xml`),[q,Pe]=(0,B.useState)(!1),Fe=(0,B.useCallback)(()=>{if(i)if(q)s(i),Pe(!1);else{let e=i.trimStart();if(a===`json`)try{s(JSON.stringify(JSON.parse(e),null,2)),Pe(!0)}catch{}else if(a===`xml`){let t=0;s(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
|
`)),Pe(!0)}}},[i,a,q]),Ie=(0,B.useCallback)(e=>{Oe(e),H&&localStorage.setItem(H,String(e)),Ee(e).catch(()=>{})},[H,Ee]),Le=(0,B.useCallback)(n=>{t&&T(t,{metadata:{...e,language:n}})},[t,e,T]),J=(0,B.useMemo)(()=>{if(!R||!U)return;let e=(Te.get(U)??[]).map(e=>({name:e.tableName,schema:e.schemaName}));if(e.length!==0)return{tables:e,getColumns:async(e,t)=>y.get(`/api/db/connections/${U}/schema?table=${encodeURIComponent(e)}${t?`&schema=${encodeURIComponent(t)}`:``}`)}},[R,U,Te]);(0,B.useEffect)(()=>{if(!(!W.current||!J))return G.current?.dispose(),ne(),G.current=W.current.languages.registerCompletionItemProvider(`sql`,te(W.current,J)),()=>{G.current?.dispose()}},[J]);let Ze=C(e=>e.openTab),[Y,et]=(0,B.useState)(null),[tt,nt]=(0,B.useState)(null),[rt,it]=(0,B.useState)(!1),[at,ot]=(0,B.useState)(``),st=(0,B.useCallback)(async e=>{if(K){it(!0),nt(null),ot(e);try{et(await y.post(`/api/db/connections/${K.id}/query`,{sql:e}))}catch(e){nt(e.message),et(null)}finally{it(!1)}}},[K]),ct=(0,B.useCallback)(()=>{!K||!at||Ze({type:`database`,title:`${K.name} · Query`,projectId:null,closable:!0,metadata:{connectionId:K.id,connectionName:K.name,dbType:K.type,initialSql:at}})},[K,Ze,at]),lt=(0,B.useCallback)(()=>{if(!S.current||!K)return;let e=S.current,t=e.getSelection();st(t&&!t.isEmpty()?e.getModel()?.getValueInRange(t)??e.getValue():e.getValue())},[K,st]),ut=typeof window<`u`&&`ontouchstart`in window,dt=(0,B.useRef)(null),[ft,pt]=(0,B.useState)(null);(0,B.useEffect)(()=>{if(!ut)return;let e=window.visualViewport;if(!e)return;let t=()=>{let t=dt.current;if(!t)return;let n=t.getBoundingClientRect().top;pt(e.height-Math.max(0,n))};return e.addEventListener(`resize`,t),e.addEventListener(`scroll`,t),()=>{e.removeEventListener(`resize`,t),e.removeEventListener(`scroll`,t)}},[ut]);let Z=(0,B.useRef)([]),mt=(0,B.useRef)(st);mt.current=st,(0,B.useEffect)(()=>()=>{Z.current.forEach(e=>e.dispose()),Z.current=[]},[]),(0,B.useEffect)(()=>{ge&&t&&T(t,{type:`sqlite`})},[ge,t,T]);let Q=n?/^(\/|[A-Za-z]:[/\\])/.test(n):!1;(0,B.useEffect)(()=>{if(i!=null){d(!1);return}if(D){s(O??``),b.current=O??``,d(!1),O&&_(!0);return}if(!n||!Q&&!r)return;if(me||N||P||F||he){d(!1);return}d(!0),m(null);let e=Q?`/api/fs/read?path=${encodeURIComponent(n)}`:`${ae(r)}/files/read?path=${encodeURIComponent(n)}`;return y.get(e).then(e=>{s(e.content),e.encoding&&l(e.encoding),b.current=e.content,d(!1)}).catch(e=>{m(e instanceof Error?e.message:`Failed to load file`),d(!1)}),()=>{v.current&&clearTimeout(v.current)}},[n,r,me,N,P,Q,D]);let[ht,gt]=(0,B.useState)(!1),_t=(0,B.useCallback)(()=>{if(!n||i!=null||D||!Q&&!r)return;let e=Q?`/api/fs/read?path=${encodeURIComponent(n)}`:`${ae(r)}/files/read?path=${encodeURIComponent(n)}`;gt(!0),y.get(e).then(e=>{s(e.content),b.current=e.content,e.encoding&&l(e.encoding),_(!1),m(null)}).catch(e=>m(e instanceof Error?e.message:`Failed to reload file`)).finally(()=>gt(!1))},[n,r,Q,i,D]),vt=(0,B.useRef)(g);vt.current=g,(0,B.useEffect)(()=>{if(!n||!r||i!=null||D)return;let e=e=>{let t=e.detail;if(t.projectName!==r||t.path!==n||vt.current)return;let i=Q?`/api/fs/read?path=${encodeURIComponent(n)}`:`${ae(r)}/files/read?path=${encodeURIComponent(n)}`;y.get(i).then(e=>{e.content!==b.current&&(s(e.content),b.current=e.content,e.encoding&&l(e.encoding))}).catch(()=>{})};return window.addEventListener(`file:changed`,e),()=>window.removeEventListener(`file:changed`,e)},[n,r,Q,i,D]),(0,B.useEffect)(()=>{if(!pe||i!=null)return;let t=D?`Untitled-${e?.untitledNumber??1}`:n?x(n):`Untitled`,r=g?`${t} \u25CF`:t;pe.title!==r&&T(pe.id,{title:r})},[g]);let yt=(0,B.useCallback)(async e=>{if(n&&!(!Q&&!r))try{Q?await y.put(`/api/fs/write`,{path:n,content:e}):await y.put(`${ae(r)}/files/write`,{path:n,content:e}),_(!1)}catch{}},[n,r,Q]);function bt(n){let r=n??``;s(r),b.current=r,_(!0),v.current&&clearTimeout(v.current),D?v.current=setTimeout(()=>{t&&T(t,{metadata:{...e,unsavedContent:b.current}})},2e3):v.current=setTimeout(()=>yt(b.current),1e3)}let xt=(0,B.useCallback)(async(e,n)=>{try{if(v.current&&clearTimeout(v.current),await y.put(`/api/fs/write`,{path:e,content:n}),t){let{closeTab:n,openTab:r}=se.getState();n(t),r({type:`editor`,title:x(e),projectId:null,metadata:{filePath:e},closable:!0})}_(!1),j(!1)}catch{}},[t]),$=e?.lineNumber,St=e?.endLine,Ct=e?.revealAt,wt=(0,B.useCallback)(()=>{let e=S.current;if(!(!e||!$||$<=0)){if(e.revealLineInCenter($),e.setPosition({lineNumber:$,column:1}),St&&St>=$){let t=e.getModel(),n=t?.getLineCount()??$,r=Math.min(St,n),i=t?.getLineMaxColumn(r)??1;e.setSelection({startLineNumber:$,startColumn:1,endLineNumber:r,endColumn:i})}e.focus()}},[$,St]);(0,B.useEffect)(()=>{Ct!=null&&wt()},[Ct,wt]);let Tt=(0,B.useCallback)((e,t)=>{if(S.current=e,W.current=t,$&&$>0&&setTimeout(()=>wt(),100),D&&e.addCommand(t.KeyMod.CtrlCmd|t.KeyCode.KeyS,()=>j(!0)),e.addCommand(t.KeyMod.Alt|t.KeyCode.KeyZ,()=>oe.getState().toggleWordWrap()),t.languages.typescript.typescriptDefaults.setDiagnosticsOptions({noSemanticValidation:!0,noSyntaxValidation:!0,noSuggestionDiagnostics:!0}),t.languages.typescript.javascriptDefaults.setDiagnosticsOptions({noSemanticValidation:!0,noSyntaxValidation:!0,noSuggestionDiagnostics:!0}),J&&(G.current?.dispose(),G.current=t.languages.registerCompletionItemProvider(`sql`,te(t,J))),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=h(e.getValue(),t.lineNumber);n&&mt.current(n)}}),Z.current.forEach(e=>e.dispose()),Z.current=[];let n=e.getModel(),r=e.addCommand(0,(e,t)=>{t&&mt.current(t)});if(r&&n){let e=t.languages.registerCodeLensProvider(`sql`,{provideCodeLenses:e=>{if(e!==n)return{lenses:[],dispose:()=>{}};let t=[],i=e.getValue().split(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,y as n}from"./vendor-markdown-CKTlmXbz.js";import{i as r,t as i}from"./api-client-BK4NPNoY.js";import"./vendor-mermaid-DPpYkrMf.js";import{t as a}from"./settings-store-DkRZhj-g.js";import{J as o,Zt as s,o as c}from"./index-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,y as n}from"./vendor-markdown-CKTlmXbz.js";import{i as r,t as i}from"./api-client-BK4NPNoY.js";import"./vendor-mermaid-DPpYkrMf.js";import{t as a}from"./settings-store-DkRZhj-g.js";import{J as o,Zt as s,o as c}from"./index-4M24PSHW.js";import{t as l}from"./use-monaco-theme-BvzqffqR.js";var u=e(t(),1),d=n();function f(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 p(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 m({metadata:e}){let t=e?.filePath,n=e?.projectName,[m,g]=(0,u.useState)(null),[_,v]=(0,u.useState)(!0),[y,b]=(0,u.useState)(null),[x,S]=(0,u.useState)(0),C=(0,u.useRef)(null),w=(0,u.useRef)(null),T=(0,u.useRef)([]),E=(0,u.useRef)(null),{wordWrap:D}=a(o(e=>({wordWrap:e.wordWrap}))),O=l(),k=(0,u.useRef)(null),[A,j]=(0,u.useState)();(0,u.useEffect)(()=>{let e=k.current;if(!e)return;let t=new ResizeObserver(([e])=>{e&&j(Math.floor(e.contentRect.height))});return t.observe(e),()=>t.disconnect()},[]),(0,u.useEffect)(()=>{!t||!n||(v(!0),i.get(`${r(n)}/files/read?path=${encodeURIComponent(t)}`).then(e=>{g(e.content),v(!1)}).catch(e=>{b(e.message||`Failed to load file`),v(!1)}))},[t,n]);let M=(0,u.useCallback)(()=>{let e=C.current,t=w.current;if(!e||!t)return;let n=p(e.getModel()?.getValue()||``);S(n.length);for(let t of T.current)e.removeContentWidget(t);if(T.current=[],E.current&&E.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`}});E.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 (${h(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`);N(r.id,n)});let a={getId:()=>n,getDomNode:()=>i,getPosition:()=>({position:{lineNumber:r.startLine,column:1},preference:[t.editor.ContentWidgetPositionPreference.ABOVE]})};e.addContentWidget(a),T.current.push(a)}},[]),N=(0,u.useCallback)((e,t)=>{let n=C.current,r=w.current;if(!n||!r)return;let i=n.getModel();if(!i)return;let a=p(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+`
|