@pi-chamber/web 1.0.4-rc.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/DiagramView-BpG1c3Hi.js +1 -0
- package/dist/assets/{DiffView-Cay8VAqL.js → DiffView-BxwoRCYx.js} +5 -5
- package/dist/assets/FileSaveConflictDialog-DP7k9a-i.js +3 -0
- package/dist/assets/{FilesView-CEeQzjc6.js → FilesView-D_2QcdUt.js} +4 -4
- package/dist/assets/{GitHubDetailScaffold-q4YP8iyJ.js → GitHubDetailScaffold-UxLAMAOl.js} +2 -2
- package/dist/assets/GitHubLinkPicker-Bh9RO1yK.js +1 -0
- package/dist/assets/{GitHubListPrimitives-XkALat1v.js → GitHubListPrimitives-DQyhT5wG.js} +1 -1
- package/dist/assets/{GitView-DV3d0oSJ.js → GitView-XBBheKRM.js} +4 -4
- package/dist/assets/{IssuesSurface-OTyt9f3A.js → IssuesSurface-BA1kpvAJ.js} +3 -3
- package/dist/assets/{JsonTreeView-X2Auiy_q.js → JsonTreeView-BAaEPL4O.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-DzgDmUsL.js +12 -0
- package/dist/assets/{PatchDiff-GMQAv4en.js → PatchDiff-BMEUsgXH.js} +1 -1
- package/dist/assets/{PierreDiffViewer-0X__nypk.js → PierreDiffViewer-BW8MO-O6.js} +2 -2
- package/dist/assets/PullRequestsSurface-B3ictm4I.js +2 -0
- package/dist/assets/SessionSwitcherContent-rLoyVqgs.js +1 -0
- package/dist/assets/SessionSwitcherDropdown-CfySKnUu.js +2 -0
- package/dist/assets/{SessionUnreadDot-CJFawQpo.js → SessionUnreadDot-CmEF9sxM.js} +1 -1
- package/dist/assets/SettingsView-BiwlwnTK.js +6 -0
- package/dist/assets/SettingsWindow-j0e99YI0.js +1 -0
- package/dist/assets/ToolOutputDialog-VlS12Xyq.js +8 -0
- package/dist/assets/ToolPartDiffPreview-DdSneZws.js +1 -0
- package/dist/assets/{VirtualizedFileDiff-CUWx7JVZ.js → VirtualizedFileDiff-BqiXjvP6.js} +1 -1
- package/dist/assets/{Virtualizer-wpC51ZBQ.js → Virtualizer-Cp_cJWbI.js} +1 -1
- package/dist/assets/{collapsible-Ce85nuXX.js → collapsible-C7oyikVm.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-3PpRLd5B.js → computeVirtualFileMetrics-BJjC-tXV.js} +1 -1
- package/dist/assets/{contextFileOpenGuard-PoBklHMz.js → contextFileOpenGuard-BBzqKGei.js} +1 -1
- package/dist/assets/{gitStatusPredicates-BvzxqidP.js → gitStatusPredicates-Dq-E5DaH.js} +1 -1
- package/dist/assets/{githubLink-iQ51wqRa.js → githubLink-Cryd7GkG.js} +5 -5
- package/dist/assets/index-BbhXFTId.js +1 -0
- package/dist/assets/index-BnZVqcki.js +11 -0
- package/dist/assets/index-BnieExes.css +1 -0
- package/dist/assets/{main-PSCt716b.js → main-9O5IAtT_.js} +4 -4
- package/dist/assets/{main-FasHq7Ck.js → main-DWGwALIw.js} +2 -2
- package/dist/assets/{markdownCore-BH56o6Wu.js → markdownCore-B9AuEyYi.js} +1 -1
- package/dist/assets/miniChat-CgOaJfD8.js +2 -0
- package/dist/assets/mobile-BbJcYVym.js +2 -0
- package/dist/assets/nativeFileSave-BzhtrDoD.js +1 -0
- package/dist/assets/{pi-session-focus-preference-D2-1HWmY.js → pi-session-focus-preference-Bmk1iOvn.js} +4 -4
- package/dist/assets/{renderDiffWithHighlighter-l8hZWWBO.js → renderDiffWithHighlighter-CVLsdtQ5.js} +1 -1
- package/dist/assets/renderElectronMiniChatApp-R5o9NwFC.js +2 -0
- package/dist/assets/{renderFileWithHighlighter-BvDoP7ob.js → renderFileWithHighlighter-DJ9mk2bZ.js} +1 -1
- package/dist/assets/renderMobileApp-CQ9tWYIj.js +11 -0
- package/dist/assets/runtimeEndpointReset-CtK4C_5h.js +62 -0
- package/dist/assets/{runtimeSurface-B1GRkkKC.js → runtimeSurface-DBiUWYK2.js} +1 -1
- package/dist/assets/useAppFontEffects-DviRbaCJ.js +212 -0
- package/dist/assets/{useFilesViewSearch-D1jsGQrN.js → useFilesViewSearch-D2Au5Xgt.js} +1 -1
- package/dist/assets/{useGitHubRemoteSearch-zNgy2bSt.js → useGitHubRemoteSearch-D-K7aolk.js} +1 -1
- package/dist/assets/{useSwitcherItems-OCRYcHeu.js → useSwitcherItems-Dej8BzXI.js} +1 -1
- package/dist/assets/vendor-aparajita-capacitor-secure-storage-BYohCVY0.js +1 -0
- package/dist/assets/{vendor-base-ui-DIkTOIJS.js → vendor-base-ui-BscvGUFt.js} +1 -1
- package/dist/assets/vendor-boot-Dgb9NVFe.js +69 -0
- package/dist/assets/vendor-capacitor-app-BjdQVib9.js +1 -0
- package/dist/assets/vendor-capacitor-keyboard-eTtI5go3.js +1 -0
- package/dist/assets/vendor-capacitor-push-notifications-CBKq2Arn.js +1 -0
- package/dist/assets/vendor-capacitor-status-bar-9rNIGxlO.js +1 -0
- package/dist/assets/{vendor-codemirror-autocomplete-DsFn4GLp.js → vendor-codemirror-autocomplete-DxS3jwvE.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-angular-B_NMmBbS.js → vendor-codemirror-lang-angular-DdjXl9e2.js} +1 -1
- package/dist/assets/vendor-codemirror-lang-cpp--aMr7NVt.js +1 -0
- package/dist/assets/vendor-codemirror-lang-css-CZ_qxZY9.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-go-C2KHbcll.js → vendor-codemirror-lang-go-Ca-y2Alu.js} +2 -2
- package/dist/assets/vendor-codemirror-lang-html-COZ0L5wT.js +1 -0
- package/dist/assets/vendor-codemirror-lang-java-D3Rf3QNJ.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-javascript-DpTUrvx8.js → vendor-codemirror-lang-javascript-DwJ-IvCs.js} +2 -2
- package/dist/assets/vendor-codemirror-lang-jinja-D_5lod6k.js +1 -0
- package/dist/assets/vendor-codemirror-lang-json-BG8C7OpC.js +1 -0
- package/dist/assets/vendor-codemirror-lang-less-CVEkoaTw.js +1 -0
- package/dist/assets/vendor-codemirror-lang-liquid-U9vj0m8w.js +1 -0
- package/dist/assets/vendor-codemirror-lang-markdown-DqlYH9gY.js +1 -0
- package/dist/assets/vendor-codemirror-lang-php-BFEiEVA1.js +1 -0
- package/dist/assets/vendor-codemirror-lang-python-Cz1dQXQd.js +3 -0
- package/dist/assets/vendor-codemirror-lang-rust-C_CoD9mj.js +1 -0
- package/dist/assets/vendor-codemirror-lang-sass-BuR0aKh5.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-sql-C_RazIaB.js → vendor-codemirror-lang-sql-DggNUjdM.js} +2 -2
- package/dist/assets/{vendor-codemirror-lang-vue-BYL0r7KR.js → vendor-codemirror-lang-vue-DFZHi2J3.js} +1 -1
- package/dist/assets/vendor-codemirror-lang-wast-zuTN3SHT.js +1 -0
- package/dist/assets/vendor-codemirror-lang-xml-CrcvhI-k.js +1 -0
- package/dist/assets/vendor-codemirror-lang-yaml-DcVWsakb.js +1 -0
- package/dist/assets/{vendor-codemirror-language-data-DglcKYWT.js → vendor-codemirror-language-data-CCLITgCF.js} +2 -2
- package/dist/assets/{vendor-codemirror-search-DaE6R5gH.js → vendor-codemirror-search-H7NOEdbX.js} +2 -2
- package/dist/assets/{vendor-lezer-cpp-Dt99h3WT.js → vendor-lezer-cpp-C8aD2KAr.js} +1 -1
- package/dist/assets/{vendor-lezer-css-DNU_fzPI.js → vendor-lezer-css-2lbTJF-Y.js} +1 -1
- package/dist/assets/{vendor-lezer-go-BEFtcNyS.js → vendor-lezer-go-Bw6LFTrZ.js} +1 -1
- package/dist/assets/{vendor-lezer-html-DDGRhRUz.js → vendor-lezer-html-D7ym2z7S.js} +1 -1
- package/dist/assets/{vendor-lezer-java-DmfZtW09.js → vendor-lezer-java-CZhK7w21.js} +1 -1
- package/dist/assets/{vendor-lezer-javascript-oje4tdp_.js → vendor-lezer-javascript-rpKeTHZp.js} +1 -1
- package/dist/assets/{vendor-lezer-json-BRXb_bDX.js → vendor-lezer-json-C7jwsd2G.js} +1 -1
- package/dist/assets/{vendor-lezer-lr-BU2qmu_5.js → vendor-lezer-lr-DR-ylqNN.js} +1 -1
- package/dist/assets/{vendor-lezer-markdown-CicYv7V9.js → vendor-lezer-markdown-Bir0m5nB.js} +1 -1
- package/dist/assets/{vendor-lezer-php-COORrTpE.js → vendor-lezer-php-y0hIEfo1.js} +1 -1
- package/dist/assets/{vendor-lezer-python-Cuvm9X9Y.js → vendor-lezer-python-D64A9lNV.js} +1 -1
- package/dist/assets/{vendor-lezer-rust-C_zOfHbX.js → vendor-lezer-rust-E3ZA9T2L.js} +1 -1
- package/dist/assets/{vendor-lezer-sass-DWP4w7O1.js → vendor-lezer-sass-C5UFI9SP.js} +1 -1
- package/dist/assets/{vendor-lezer-xml-Br6nOYeG.js → vendor-lezer-xml-DOy7FzCR.js} +1 -1
- package/dist/assets/{vendor-lezer-yaml-CYQmm6Sb.js → vendor-lezer-yaml-kEjaSCvZ.js} +1 -1
- package/dist/assets/{vendor-replit-codemirror-vim-CZy3BUVv.js → vendor-replit-codemirror-vim-BLfh0LPy.js} +1 -1
- package/dist/assets/{web-components-v9fuidaX.js → web-components-C7CmoFxi.js} +1 -1
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +1 -1
- package/server/lib/pi/routes.js +1 -0
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +1 -1
- package/server/lib/pi/session-daemon/supervisor.js +13 -1
- package/server/lib/pi/session-daemon/supervisor.test.js +92 -0
- package/server/lib/relay/DOCUMENTATION.md +4 -0
- package/server/lib/terminal/DOCUMENTATION.md +1 -0
- package/dist/assets/DiagramView-GKGxPczP.js +0 -1
- package/dist/assets/FileSaveConflictDialog-BRM9TJo0.js +0 -3
- package/dist/assets/GitHubLinkPicker-B9xgIW8y.js +0 -1
- package/dist/assets/MarkdownRendererImpl-1HameF6j.js +0 -12
- package/dist/assets/PullRequestsSurface-Dec20SIg.js +0 -2
- package/dist/assets/SessionSwitcherContent-DEw4nz7K.js +0 -1
- package/dist/assets/SessionSwitcherDropdown-DmLhbRzE.js +0 -2
- package/dist/assets/SettingsView-CwSspvq-.js +0 -6
- package/dist/assets/SettingsWindow-DkPv9MaU.js +0 -1
- package/dist/assets/ToolOutputDialog-DDwbOpTO.js +0 -8
- package/dist/assets/ToolPartDiffPreview-DZRP7p-Q.js +0 -1
- package/dist/assets/index-CkMnC_GK.js +0 -1
- package/dist/assets/index-Dd2OcIUY.js +0 -10
- package/dist/assets/index-DvN8zlLT.css +0 -1
- package/dist/assets/miniChat-BzfobBDq.js +0 -2
- package/dist/assets/mobile-DAzZE2EL.js +0 -2
- package/dist/assets/renderElectronMiniChatApp-DGYSIihR.js +0 -2
- package/dist/assets/renderMobileApp-CwgWG0lU.js +0 -11
- package/dist/assets/runtimeEndpointReset-CmI6dBKM.js +0 -62
- package/dist/assets/useAppFontEffects--lKKtKVo.js +0 -212
- package/dist/assets/vendor-aparajita-capacitor-secure-storage-5IShChL0.js +0 -1
- package/dist/assets/vendor-boot-DyL2td56.js +0 -69
- package/dist/assets/vendor-capacitor-app-BrDJj9I_.js +0 -1
- package/dist/assets/vendor-capacitor-core-B4EWRrHz.js +0 -1
- package/dist/assets/vendor-capacitor-keyboard-CYccoJjr.js +0 -1
- package/dist/assets/vendor-capacitor-push-notifications-KNe1zSBF.js +0 -1
- package/dist/assets/vendor-capacitor-status-bar-B-N0EOVk.js +0 -1
- package/dist/assets/vendor-codemirror-lang-cpp-GOE7Gjd0.js +0 -1
- package/dist/assets/vendor-codemirror-lang-css-Dwf2XpnZ.js +0 -1
- package/dist/assets/vendor-codemirror-lang-html-DcKqyeGk.js +0 -1
- package/dist/assets/vendor-codemirror-lang-java-6eGbyB2k.js +0 -1
- package/dist/assets/vendor-codemirror-lang-jinja-xSUJjXhr.js +0 -1
- package/dist/assets/vendor-codemirror-lang-json-CLGxdOCz.js +0 -1
- package/dist/assets/vendor-codemirror-lang-less-6nXi1rS9.js +0 -1
- package/dist/assets/vendor-codemirror-lang-liquid-B9hmb9P8.js +0 -1
- package/dist/assets/vendor-codemirror-lang-markdown-DmFP9s6x.js +0 -1
- package/dist/assets/vendor-codemirror-lang-php-DC6To8iX.js +0 -1
- package/dist/assets/vendor-codemirror-lang-python-yuxIkjit.js +0 -3
- package/dist/assets/vendor-codemirror-lang-rust-di1Sjz-0.js +0 -1
- package/dist/assets/vendor-codemirror-lang-sass-BWpV9NPV.js +0 -1
- package/dist/assets/vendor-codemirror-lang-wast-BiVarhcz.js +0 -1
- package/dist/assets/vendor-codemirror-lang-xml-Cn1lY1ts.js +0 -1
- package/dist/assets/vendor-codemirror-lang-yaml-BZ6mZw9L.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DiffView-
|
|
2
|
-
import{aK as on,aL as mt,aM as Vn,j as e,aN as an,aO as ln,aP as cn,aQ as Kn,aR as Xn,aS as dn,aT as un,aU as qn,aV as Gn,aW as Yn,aX as Jn,aY as Mt,aZ as Qe,aI as It,aJ as Qn}from"./vendor-boot-DyL2td56.js";import{R as r,a as Ne}from"./vendor-react-DASdDPIk.js";/* empty css */import{t as ne,o as le,m as rt,E as hn,F as Zn,h as fn,G as pn,a as er,H as tr,I as nr,v as Te,J as rr,K as Ae,L as sr,M as or,N as ar,O as Lt,P as Xe,u as ir,Q as lr,R as cr,S as dr,T as ur,U as mn,V as gn,W as hr,X as fr,Y as pr,A as mr,Z as gr,B as xr,w as xn,z as wr}from"./index-Dd2OcIUY.js";import{_ as Ee}from"./vendor-vite-runtime-DD1OZmLC.js";import{l as yr,y as br,z as vr,B as Sr,E as jr,G as Cr,I as wn,J as yn,K as gt,T as bn,L as Nr,N as kr,O as Pr,m as Rr,w as Er,t as Tr,v as _r,H as Ot,C as $t,A as Wt,S as Ft,n as Ar,p as Dr,x as Mr,q as Ir,F as Lr,W as Or}from"./runtimeEndpointReset-CmI6dBKM.js";import{a4 as at,I as V,E as Pe,a5 as it,f as Ce,t as je,a6 as $r,B as me,o as st,P as vn,a7 as yt,a8 as Wr,a9 as We,aa as Fe,ab as Fr,ac as Be,ad as Br,ae as bt,af as zr,ag as Ur,p as vt,n as Je,ah as Sn,ai as Bt,aj as Hr,ak as St,al as jt,am as Ct,an as Nt,ao as kt,ap as Vr,aq as Kr,ar as Xr,as as qr,at as jn,H as $e,au as qe,av as Gr,aw as Yr,ax as _e,ay as Cn,az as Jr,aA as Qr,aB as Pt,aC as Zr,aD as Nn,q as zt,aE as es,aF as ts,aG as ns,aH as rs,aI as Ut,aJ as ss,b as os,c as as,aK as is,a as Ht,aL as ls,r as lt,aM as cs,aN as ds,aO as us,aP as hs,aQ as fs,aR as ps,aS as ms,aT as Ve,aU as Ke,aV as gs,a2 as xs,a3 as ws,U as ys,T as bs,V as vs,R as Ss,X as js,W as Cs,Y as Ns,Z as ks,a0 as Ps,a1 as Rs}from"./useAppFontEffects--lKKtKVo.js";import{v as kn,g as Pn}from"./contextFileOpenGuard-PoBklHMz.js";import{g as Rn,u as Es,s as Ts,i as _s,a as As,b as Ds}from"./useFilesViewSearch-D1jsGQrN.js";import{g as En}from"./SessionUnreadDot-CJFawQpo.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CUi8eEds.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";/* empty css */import"./permissionStore-B9Hkrqny.js";import"./runtimeSurface-B1GRkkKC.js";const Ms=280,Vt=4,Is=({transform:t})=>({...t,y:0}),Ls=({id:t,children:n,className:o})=>{const{attributes:i,listeners:a,setNodeRef:m,transform:x,transition:c,isDragging:h}=dn({id:t});return e.jsx("div",{ref:m,"data-sortable-tab-id":t,style:{transform:un.Transform.toString(x),transition:c},className:le("h-full rounded-md",o,h&&"opacity-50"),...i,...a,children:n})},Os=({id:t,children:n,className:o})=>e.jsx("div",{className:le("h-full",o),"data-sortable-tab-id":t,children:n}),$s=({items:t,activeId:n,onSelect:o,onClose:i,onReorder:a,layoutMode:m="scrollable",variant:x="default",activePillInsetClassName:c,activePillButtonClassName:h,inactiveTabsIconOnly:g=!1,animateActivePill:v,activePillLowercase:u=!0,nonCompositedIndicator:l=!1,className:N})=>{const f=ne(P=>P.isMobile),{isTablet:T}=at(),p=f||T,S=r.useRef(null),[k,O]=r.useState({left:!1,right:!1}),oe=r.useMemo(()=>t.map(P=>P.id),[t]),z=m==="scrollable",G=x==="default",Q=x==="active-pill",b=Q||x==="animated",X=G,q=b||X,K=Q&&z,Y=b,ee=v??b,E=typeof a=="function",Z=E?Ls:Os,j=r.useRef(new Map),[W,re]=r.useState(null),[$,F]=r.useState(!1),[ie,ce]=r.useState(null),he=r.useRef(!1),ge=r.useRef(0),pe=r.useRef(n),de=r.useRef(null),ue=r.useMemo(()=>{if(!q||!ie||!n||ie===n)return 0;const P=t.findIndex(fe=>fe.id===ie),se=t.findIndex(fe=>fe.id===n);return P<0||se<0?0:P>se?Vt:-Vt},[n,t,ie,q]),M=on(mt(Vn,{activationConstraint:{distance:8}})),B=r.useCallback((P,se)=>!P||!se?P===se:Math.abs(P.left-se.left)<.5&&Math.abs(P.top-se.top)<.5&&Math.abs(P.width-se.width)<.5&&Math.abs(P.height-se.height)<.5,[]),U=r.useCallback((P,se)=>{if(se){j.current.set(P,se);return}j.current.delete(P)},[]),J=r.useCallback(()=>{if(!q||!n){re(L=>L===null?L:null);return}const P=S.current,se=j.current.get(n);if(!P||!se){re(L=>L===null?L:null);return}let fe=0,R=0,w=se;for(;w&&w!==P;)fe+=w.offsetLeft,R+=w.offsetTop,w=w.offsetParent;const _={left:fe,top:R,width:se.offsetWidth,height:se.offsetHeight};re(L=>B(L,_)?L:_)},[n,B,q]),ae=r.useCallback(()=>{if(!z){O({left:!1,right:!1});return}const P=S.current;if(!P){O({left:!1,right:!1});return}O({left:P.scrollLeft>2,right:P.scrollLeft+P.clientWidth<P.scrollWidth-2})},[z]);r.useEffect(()=>{if(!z){O({left:!1,right:!1});return}const P=S.current;if(!P)return;ae(),P.addEventListener("scroll",ae,{passive:!0});const se=new ResizeObserver(ae);return se.observe(P),()=>{P.removeEventListener("scroll",ae),se.disconnect()}},[z,t.length,ae]),r.useEffect(()=>{if(!q){re(null);return}J();const P=S.current;if(!P)return;const se=new ResizeObserver(()=>{performance.now()-ge.current>Ms&&F(!1),J()});if(se.observe(P),n){const fe=j.current.get(n);fe&&se.observe(fe)}return()=>{se.disconnect()}},[n,t.length,J,q]),r.useLayoutEffect(()=>{J()});const xe=oe.join("\0");r.useLayoutEffect(()=>{if(!q){he.current=!1,F(!1);return}const P=de.current!==xe;if(de.current=xe,!he.current){he.current=!0,pe.current=n;return}const se=pe.current!==n;if(pe.current=n,!se||P){F(!1);return}ge.current=performance.now(),F(!0)},[n,xe,q]),r.useEffect(()=>{if(!z||!n)return;const P=S.current;if(!P)return;const se=window.requestAnimationFrame(()=>{const fe=typeof window.CSS?.escape=="function"?window.CSS.escape(n):n.replace(/"/g,'\\"'),R=P.querySelector(`[data-sortable-tab-id="${fe}"]`);R&&(R.scrollIntoView({block:"nearest",inline:"nearest"}),ae())});return()=>{window.cancelAnimationFrame(se)}},[n,z,t.length,ae]);const ve=r.useCallback(P=>{if(!a)return;const{active:se,over:fe}=P;!fe||se.id===fe.id||a(String(se.id),String(fe.id))},[a]),ye=e.jsxs("div",{className:le("relative flex h-full min-w-0 flex-1",N),children:[z&&k.left?e.jsx("div",{className:le("pointer-events-none absolute inset-y-0 left-0 z-20 bg-gradient-to-r to-transparent",b?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,z&&k.right?e.jsx("div",{className:le("pointer-events-none absolute inset-y-0 right-0 z-20 bg-gradient-to-l to-transparent",b?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,e.jsxs("div",{ref:S,className:le("relative flex h-full min-w-0 flex-1",b?"items-center overflow-x-hidden overflow-y-hidden":"items-stretch",b&&"@container/pill-tabs",b&&"pill-tabs__track",b&&(c??"gap-0.5 py-0.5"),X&&"items-center overflow-y-hidden",Y&&"rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] bg-[color-mix(in_srgb,var(--foreground)_4%,transparent)] p-0.5 gap-0.5",z?"overflow-x-auto scrollbar-none":"overflow-x-hidden"),style:z?{scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,role:"tablist","aria-label":"Tabs",children:[b&&W?e.jsx("div",{className:le("pointer-events-none absolute left-0 top-0 z-0 rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] bg-[var(--surface-elevated)]","border border-[color-mix(in_srgb,var(--foreground)_7%,transparent)]","shadow-[0_1px_2px_color-mix(in_srgb,var(--foreground)_10%,transparent),0_2px_6px_color-mix(in_srgb,var(--foreground)_6%,transparent)]",ee&&$&&(l?"pill-tabs__indicator--is-animated-layout":"pill-tabs__indicator--is-animated")),style:l?{left:`${W.left+ue}px`,top:`${W.top}px`,width:`${W.width}px`,height:`${W.height}px`}:{transform:`translate3d(${W.left+ue}px, ${W.top}px, 0)`,width:`${W.width}px`,height:`${W.height}px`}}):null,X&&W?e.jsx("div",{className:le("pointer-events-none absolute left-0 -bottom-px z-10 h-[3px] rounded-t-[2px] bg-[var(--primary-base)]",$&&"underline-tabs__indicator--is-animated"),style:{transform:`translate3d(${W.left+ue}px, 0, 0)`,width:`${W.width}px`},"aria-hidden":!0}):null,t.map(P=>{const se=P.id===n,fe=g&&b&&!se&&!!P.icon,R=!fe,w=!!P.icon,_=g&&b&&se&&!z&&!K,L=P.closable!==!1&&!!i,A=L&&!!P.icon,s=z||K?void 0:b?_?"flex-none basis-auto":f?"flex-1 basis-0 min-w-0":"flex-1 basis-0 min-w-fit":"min-w-0 flex-1 basis-0",d=L?H=>{H.button===1&&(H.preventDefault(),H.stopPropagation(),i?.(P.id))}:void 0,D=L?H=>{H.button===1&&H.preventDefault()}:void 0,I=H=>w?e.jsxs("span",{className:H,children:[e.jsx("span",{className:le("flex items-center justify-center transition-opacity",A&&(p?"opacity-0":"group-hover:opacity-0")),children:P.icon}),A?e.jsx("span",{role:"button",tabIndex:-1,className:le("absolute inset-0 z-20 flex !min-h-0 !min-w-0 items-center justify-center rounded-sm text-muted-foreground transition-opacity hover:text-foreground",p?"opacity-100":"opacity-0 group-hover:opacity-100"),onPointerDown:te=>te.stopPropagation(),onClick:te=>{te.stopPropagation(),i?.(P.id)},"aria-label":P.closeLabel??`Close ${P.label} tab`,title:P.closeLabel??`Close ${P.label} tab`,children:e.jsx(V,{name:"close",className:"h-3.5 w-3.5"})}):null]}):null;return e.jsx(Z,{id:P.id,className:s,children:e.jsxs("div",{ref:H=>U(P.id,H),onAuxClick:d,onMouseDown:D,className:le("group flex h-full min-w-0 flex-nowrap items-center",z||K?"shrink-0":b?"w-full":"w-full min-w-0",b?"relative z-10 bg-transparent":se?"relative z-10 bg-transparent text-foreground":"relative z-10 bg-transparent text-muted-foreground hover:text-foreground"),children:[e.jsx("button",{type:"button",role:"tab","aria-selected":se,"aria-label":fe?P.title??P.label:void 0,onClick:()=>o(P.id),onPointerDown:q?()=>{F(!0),ce(P.id)}:void 0,onPointerUp:q?()=>ce(null):void 0,onPointerLeave:q?()=>ce(null):void 0,onPointerCancel:q?()=>ce(null):void 0,className:le(b?"animated-tabs__button pill-tabs__button relative z-10 flex flex-1 min-w-0 flex-nowrap items-center justify-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] text-sm font-medium transition-colors duration-150 !min-h-0":"flex h-full min-w-0 flex-nowrap items-center typography-micro",b&&u?"lowercase":null,b&&(fe?"gap-0":"gap-1.5"),b?K?"shrink-0 whitespace-nowrap px-3 text-center":z?"max-w-56 shrink-0 px-3 text-center":fe?"px-2 !min-w-0 text-center":_?"shrink-0 whitespace-nowrap px-3 text-center":"px-3 text-center":z?"max-w-56 justify-start truncate px-3 text-left":"w-full justify-center truncate px-3 text-center",b?h??(Q?f?"h-[38px]":"h-[31px]":"h-7"):null,b?se?"text-foreground":"text-muted-foreground hover:text-foreground":null,b?"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-background":null),title:P.title??P.label,children:b?e.jsxs(e.Fragment,{children:[I("relative flex h-4 w-4 shrink-0 items-center justify-center"),R?e.jsx("span",{className:"animated-tabs__label truncate",children:P.label}):null]}):e.jsxs("span",{className:le("flex min-w-0 flex-nowrap items-center gap-1.5",!z&&"justify-center"),children:[I(le("relative flex h-4 w-4 shrink-0 items-center justify-center transition-colors duration-200 ease-out",se?"text-[var(--primary-base)]":"text-muted-foreground")),e.jsx("span",{className:"truncate leading-[1.2]",children:P.label})]})}),L&&!A?e.jsx("button",{type:"button",onPointerDown:H=>{H.stopPropagation()},onClick:H=>{H.stopPropagation(),i?.(P.id)},className:le("relative z-20 inline-flex !min-h-0 !min-w-0 items-center justify-center transition-opacity",b?"-ml-2.5 mr-1 h-[88%] w-5 self-center !aspect-auto rounded-md":"aspect-square h-[65%] min-h-4 max-h-5 rounded-sm mr-1",b?se?"text-muted-foreground hover:bg-transparent hover:text-foreground":"text-muted-foreground opacity-0 hover:bg-transparent hover:text-foreground group-hover:opacity-100":se?"text-muted-foreground hover:bg-interactive-hover/60 hover:text-foreground":"text-muted-foreground opacity-0 hover:bg-interactive-hover/80 hover:text-foreground group-hover:opacity-100"),"aria-label":P.closeLabel??`Close ${P.label} tab`,title:P.closeLabel??`Close ${P.label} tab`,children:e.jsx(V,{name:"close",className:"h-3 w-3"})}):null]})},P.id)})]})]});return E?e.jsxs(an,{sensors:M,collisionDetection:ln,onDragEnd:ve,modifiers:[Is],children:[e.jsx(cn,{items:oe,strategy:Kn,children:ye}),e.jsx(Xn,{dropAnimation:null})]}):ye},Kt=280,Xt=280,qt=500,Ws=({isOpen:t,isMobile:n,children:o,className:i,topBar:a})=>{const m=ne(y=>y.sidebarWidth),x=ne(y=>y.setSidebarWidth),[c,h]=r.useState(!1),g=r.useRef(0),v=r.useRef(m||Kt),u=r.useRef(null),l=r.useRef(null),N=r.useRef(null),f=r.useCallback(y=>Math.min(qt,Math.max(Xt,y)),[]),T=r.useCallback(y=>{const b=N.current;b&&(b.style.width=`${y}px`,b.style.minWidth=`${y}px`,b.style.maxWidth=`${y}px`,b.style.setProperty("--oc-left-sidebar-width",`${y}px`))},[]);r.useEffect(()=>{n&&c&&h(!1)},[n,c]),r.useEffect(()=>{c||(u.current=null,l.current=null)},[c]);const p=yr(t);if(n)return null;const S=Math.min(qt,Math.max(Xt,m||Kt)),k=p.layoutVisible?S:0,O=y=>{if(t){try{y.currentTarget.setPointerCapture(y.pointerId)}catch{}l.current=y.pointerId,h(!0),g.current=y.clientX,v.current=k,u.current=k,T(k),y.preventDefault()}},oe=y=>{if(n||!c||l.current!==y.pointerId)return;const b=y.clientX-g.current,X=f(v.current+b);u.current!==X&&(u.current=X,T(X))},z=y=>{if(l.current!==y.pointerId||n)return;try{y.currentTarget.releasePointerCapture(y.pointerId)}catch{}const b=f(u.current??k);l.current=null,u.current=null,h(!1),x(b)},G=c?u.current??k:k,Q=c?G:k;return e.jsxs("aside",{ref:N,className:le("relative flex h-full overflow-hidden motion-reduce:transition-none","bg-sidebar",i),style:{width:`${Q}px`,minWidth:`${Q}px`,maxWidth:`${Q}px`,"--oc-left-sidebar-width":`${c?G:S}px`,overflowX:"clip",transform:c||p.slidIn?"translateX(0)":"translateX(-100%)",transition:c?"none":p.transition},"aria-hidden":!t||Q===0,children:[t&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 shadow-[inset_-2px_0_10px_-2px_rgb(0_0_0_/_0.06)]","aria-hidden":"true"}),t&&e.jsx("div",{className:le("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",c&&"bg-[var(--interactive-border)]"),onPointerDown:O,onPointerMove:oe,onPointerUp:z,onPointerCancel:z,role:"separator","aria-orientation":"vertical","aria-label":"Resize left panel"}),e.jsxs("div",{className:le("relative z-10 flex h-full shrink-0 flex-col",c&&"pointer-events-none",!t&&"pointer-events-none select-none"),style:{width:"var(--oc-left-sidebar-width)",overflowX:"hidden"},"aria-hidden":!t,children:[a,e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:e.jsx(Pe,{children:o})})]})]})},Fs=t=>{if(!t||typeof t!="object")return!1;const n=t;return typeof n.x=="number"&&typeof n.y=="number"},Gt=t=>!t||typeof t!="object"?!1:Object.values(t).every(n=>typeof n=="string"),Ue=t=>{if(!t||typeof t!="object")return!1;const n=t,o=n.bounds;return typeof n.tag=="string"&&typeof n.text=="string"&&typeof n.selector=="string"&&typeof n.path=="string"&&!!o&&typeof o?.x=="number"&&typeof o?.y=="number"&&typeof o?.width=="number"&&typeof o?.height=="number"&&Fs(n.center)&&Gt(n.attributes)&&Gt(n.computedStyle)&&Array.isArray(n.ancestry)},Rt=({pageUrl:t,viewport:n,devicePixelRatio:o,target:i,screenshotAttached:a,intro:m})=>{const x=i.text.trim(),c=Object.entries(i.attributes).map(([N,f])=>`${N}="${f}"`).join(" "),h=i.computedStyle,g=i.bounds,v=i.center,u=m.replace(/[.:]+$/g,""),l=i.ancestry.map(N=>N.selectorPart).join(" > ");return[`${u}:`,`Page: ${t||"preview"}`,`Viewport: ${n.width}x${n.height}, DPR ${o}`,`Screenshot: ${a?"attached":"not attached"}`,`Element: ${i.tag}`,x?`Text: ${x}`:null,`- Selector: ${i.selector}`,`- Path: ${i.path}`,l?`- Ancestry: ${l}`:null,c?`- Attributes: ${c}`:null,`- Bounds: x=${Math.round(g.x)}, y=${Math.round(g.y)}, width=${Math.round(g.width)}, height=${Math.round(g.height)}`,`- Center: x=${Math.round(v.x)}, y=${Math.round(v.y)}`,`Styles: display=${h.display}; position=${h.position}; font=${h.fontWeight} ${h.fontSize} / ${h.lineHeight} ${h.fontFamily}; color=${h.color}; background=${h.backgroundColor}; z-index=${h.zIndex}`].filter(N=>typeof N=="string").join(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DiffView-BxwoRCYx.js","assets/vendor-boot-Dgb9NVFe.js","assets/vendor-react-DASdDPIk.js","assets/vendor-clsx-B-dksMZM.js","assets/index-BnZVqcki.js","assets/vendor-zustand-CUi8eEds.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/index-BnieExes.css","assets/useAppFontEffects-DviRbaCJ.js","assets/runtimeSurface-DBiUWYK2.js","assets/nativeFileSave-BzhtrDoD.js","assets/gitStatusPredicates-Dq-E5DaH.js","assets/VirtualizedFileDiff-BqiXjvP6.js","assets/web-components-C7CmoFxi.js","assets/computeVirtualFileMetrics-BJjC-tXV.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-yJ9XpNMI.js","assets/vendor-pierre-theming-Dgp7B_O4.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/renderDiffWithHighlighter-CVLsdtQ5.js","assets/vendor-diff-C3JhlQdm.js","assets/PierreDiffViewer-BW8MO-O6.js","assets/runtimeEndpointReset-CtK4C_5h.js","assets/SessionUnreadDot-CmEF9sxM.js","assets/permissionStore-B9Hkrqny.js","assets/runtimeEndpointReset-BV3KOtdA.css","assets/vendor-xterm-xterm-css-DDGTF8rc.css","assets/appThemeRegistry-gegrE2dq.js","assets/registerCustomTheme-DmolaWWZ.js","assets/contextFileOpenGuard-BBzqKGei.js","assets/FilesView-D_2QcdUt.js","assets/vendor-codemirror-lang-javascript-DwJ-IvCs.js","assets/vendor-lezer-javascript-rpKeTHZp.js","assets/vendor-lezer-lr-DR-ylqNN.js","assets/vendor-codemirror-autocomplete-DxS3jwvE.js","assets/vendor-codemirror-lang-json-BG8C7OpC.js","assets/vendor-lezer-json-C7jwsd2G.js","assets/vendor-codemirror-lang-css-CZ_qxZY9.js","assets/vendor-lezer-css-2lbTJF-Y.js","assets/vendor-codemirror-lang-html-COZ0L5wT.js","assets/vendor-lezer-html-D7ym2z7S.js","assets/vendor-codemirror-lang-markdown-DqlYH9gY.js","assets/vendor-lezer-markdown-Bir0m5nB.js","assets/vendor-codemirror-language-data-CCLITgCF.js","assets/vendor-codemirror-lang-python-Cz1dQXQd.js","assets/vendor-lezer-python-D64A9lNV.js","assets/shell-CjFT_Tl9.js","assets/FileSaveConflictDialog-DP7k9a-i.js","assets/vendor-react-drawio-Duu5LgQA.js","assets/useFilesViewSearch-D2Au5Xgt.js","assets/JsonTreeView-BAaEPL4O.js","assets/Virtualizer-Cp_cJWbI.js","assets/renderFileWithHighlighter-DJ9mk2bZ.js","assets/vendor-codemirror-search-H7NOEdbX.js","assets/vendor-replit-codemirror-vim-BLfh0LPy.js","assets/GitView-XBBheKRM.js","assets/GitHubDetailScaffold-UxLAMAOl.js","assets/vendor-dompurify-r8glNMJW.js","assets/collapsible-C7oyikVm.js","assets/vendor-base-ui-BscvGUFt.js","assets/PullRequestsSurface-B3ictm4I.js","assets/useGitHubRemoteSearch-D-K7aolk.js","assets/GitHubListPrimitives-DQyhT5wG.js","assets/IssuesSurface-BA1kpvAJ.js","assets/githubLink-Cryd7GkG.js","assets/DiagramView-BpG1c3Hi.js","assets/SettingsView-BiwlwnTK.js","assets/vendor-qrcode-Dv4uniC1.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/SettingsWindow-j0e99YI0.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{aO as on,aP as mt,aQ as Vn,k as e,aR as an,aS as ln,aT as cn,aU as Kn,aV as Xn,aW as dn,aX as un,aY as qn,aZ as Gn,a_ as Yn,a$ as Jn,b0 as Mt,b1 as Qe,aM as It,aN as Qn}from"./vendor-boot-Dgb9NVFe.js";import{R as r,a as Ne}from"./vendor-react-DASdDPIk.js";/* empty css */import{t as ne,o as le,m as rt,E as hn,F as Zn,h as fn,G as pn,a as er,H as tr,I as nr,v as Te,J as rr,K as Ae,L as sr,M as or,N as ar,O as Lt,P as Xe,u as ir,Q as lr,R as cr,S as dr,T as ur,U as mn,V as gn,W as hr,X as fr,Y as pr,A as mr,Z as gr,B as xr,w as xn,z as wr}from"./index-BnZVqcki.js";import{_ as Ee}from"./vendor-vite-runtime-DD1OZmLC.js";import{l as yr,y as br,z as vr,B as Sr,E as jr,G as Cr,I as wn,J as yn,K as gt,T as bn,L as Nr,N as kr,O as Pr,m as Rr,w as Er,t as Tr,v as _r,H as Ot,C as $t,A as Wt,S as Ft,n as Ar,p as Dr,x as Mr,q as Ir,F as Lr,W as Or}from"./runtimeEndpointReset-CtK4C_5h.js";import{a4 as at,I as V,E as Pe,a5 as it,h as Ce,t as je,a6 as $r,B as me,o as st,P as vn,a7 as yt,a8 as Wr,a9 as We,aa as Fe,ab as Fr,ac as Be,ad as Br,ae as bt,af as zr,ag as Ur,q as vt,p as Je,ah as Sn,ai as Bt,aj as Hr,ak as St,al as jt,am as Ct,an as Nt,ao as kt,ap as Vr,aq as Kr,ar as Xr,as as qr,at as jn,H as $e,au as qe,av as Gr,aw as Yr,ax as _e,ay as Cn,az as Jr,aA as Qr,aB as Pt,aC as Zr,aD as Nn,s as zt,aE as es,aF as ts,aG as ns,aH as rs,aI as Ut,aJ as ss,b as os,c as as,aK as is,a as Ht,aL as ls,r as lt,aM as cs,aN as ds,aO as us,aP as hs,aQ as fs,aR as ps,aS as ms,aT as Ve,aU as Ke,aV as gs,a2 as xs,a3 as ws,U as ys,T as bs,V as vs,R as Ss,X as js,W as Cs,Y as Ns,Z as ks,a0 as Ps,a1 as Rs}from"./useAppFontEffects-DviRbaCJ.js";import{v as kn,g as Pn}from"./contextFileOpenGuard-BBzqKGei.js";import{g as Rn,u as Es,s as Ts,i as _s,a as As,b as Ds}from"./useFilesViewSearch-D2Au5Xgt.js";import{g as En}from"./SessionUnreadDot-CmEF9sxM.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CUi8eEds.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";/* empty css */import"./nativeFileSave-BzhtrDoD.js";import"./permissionStore-B9Hkrqny.js";import"./runtimeSurface-DBiUWYK2.js";const Ms=280,Vt=4,Is=({transform:t})=>({...t,y:0}),Ls=({id:t,children:n,className:o})=>{const{attributes:i,listeners:a,setNodeRef:m,transform:x,transition:c,isDragging:h}=dn({id:t});return e.jsx("div",{ref:m,"data-sortable-tab-id":t,style:{transform:un.Transform.toString(x),transition:c},className:le("h-full rounded-md",o,h&&"opacity-50"),...i,...a,children:n})},Os=({id:t,children:n,className:o})=>e.jsx("div",{className:le("h-full",o),"data-sortable-tab-id":t,children:n}),$s=({items:t,activeId:n,onSelect:o,onClose:i,onReorder:a,layoutMode:m="scrollable",variant:x="default",activePillInsetClassName:c,activePillButtonClassName:h,inactiveTabsIconOnly:g=!1,animateActivePill:v,activePillLowercase:u=!0,nonCompositedIndicator:l=!1,className:N})=>{const f=ne(P=>P.isMobile),{isTablet:T}=at(),p=f||T,S=r.useRef(null),[k,O]=r.useState({left:!1,right:!1}),oe=r.useMemo(()=>t.map(P=>P.id),[t]),z=m==="scrollable",G=x==="default",Q=x==="active-pill",b=Q||x==="animated",X=G,q=b||X,K=Q&&z,Y=b,ee=v??b,E=typeof a=="function",Z=E?Ls:Os,j=r.useRef(new Map),[W,re]=r.useState(null),[$,F]=r.useState(!1),[ie,ce]=r.useState(null),he=r.useRef(!1),ge=r.useRef(0),pe=r.useRef(n),de=r.useRef(null),ue=r.useMemo(()=>{if(!q||!ie||!n||ie===n)return 0;const P=t.findIndex(fe=>fe.id===ie),se=t.findIndex(fe=>fe.id===n);return P<0||se<0?0:P>se?Vt:-Vt},[n,t,ie,q]),M=on(mt(Vn,{activationConstraint:{distance:8}})),B=r.useCallback((P,se)=>!P||!se?P===se:Math.abs(P.left-se.left)<.5&&Math.abs(P.top-se.top)<.5&&Math.abs(P.width-se.width)<.5&&Math.abs(P.height-se.height)<.5,[]),U=r.useCallback((P,se)=>{if(se){j.current.set(P,se);return}j.current.delete(P)},[]),J=r.useCallback(()=>{if(!q||!n){re(L=>L===null?L:null);return}const P=S.current,se=j.current.get(n);if(!P||!se){re(L=>L===null?L:null);return}let fe=0,R=0,w=se;for(;w&&w!==P;)fe+=w.offsetLeft,R+=w.offsetTop,w=w.offsetParent;const _={left:fe,top:R,width:se.offsetWidth,height:se.offsetHeight};re(L=>B(L,_)?L:_)},[n,B,q]),ae=r.useCallback(()=>{if(!z){O({left:!1,right:!1});return}const P=S.current;if(!P){O({left:!1,right:!1});return}O({left:P.scrollLeft>2,right:P.scrollLeft+P.clientWidth<P.scrollWidth-2})},[z]);r.useEffect(()=>{if(!z){O({left:!1,right:!1});return}const P=S.current;if(!P)return;ae(),P.addEventListener("scroll",ae,{passive:!0});const se=new ResizeObserver(ae);return se.observe(P),()=>{P.removeEventListener("scroll",ae),se.disconnect()}},[z,t.length,ae]),r.useEffect(()=>{if(!q){re(null);return}J();const P=S.current;if(!P)return;const se=new ResizeObserver(()=>{performance.now()-ge.current>Ms&&F(!1),J()});if(se.observe(P),n){const fe=j.current.get(n);fe&&se.observe(fe)}return()=>{se.disconnect()}},[n,t.length,J,q]),r.useLayoutEffect(()=>{J()});const xe=oe.join("\0");r.useLayoutEffect(()=>{if(!q){he.current=!1,F(!1);return}const P=de.current!==xe;if(de.current=xe,!he.current){he.current=!0,pe.current=n;return}const se=pe.current!==n;if(pe.current=n,!se||P){F(!1);return}ge.current=performance.now(),F(!0)},[n,xe,q]),r.useEffect(()=>{if(!z||!n)return;const P=S.current;if(!P)return;const se=window.requestAnimationFrame(()=>{const fe=typeof window.CSS?.escape=="function"?window.CSS.escape(n):n.replace(/"/g,'\\"'),R=P.querySelector(`[data-sortable-tab-id="${fe}"]`);R&&(R.scrollIntoView({block:"nearest",inline:"nearest"}),ae())});return()=>{window.cancelAnimationFrame(se)}},[n,z,t.length,ae]);const ve=r.useCallback(P=>{if(!a)return;const{active:se,over:fe}=P;!fe||se.id===fe.id||a(String(se.id),String(fe.id))},[a]),ye=e.jsxs("div",{className:le("relative flex h-full min-w-0 flex-1",N),children:[z&&k.left?e.jsx("div",{className:le("pointer-events-none absolute inset-y-0 left-0 z-20 bg-gradient-to-r to-transparent",b?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,z&&k.right?e.jsx("div",{className:le("pointer-events-none absolute inset-y-0 right-0 z-20 bg-gradient-to-l to-transparent",b?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,e.jsxs("div",{ref:S,className:le("relative flex h-full min-w-0 flex-1",b?"items-center overflow-x-hidden overflow-y-hidden":"items-stretch",b&&"@container/pill-tabs",b&&"pill-tabs__track",b&&(c??"gap-0.5 py-0.5"),X&&"items-center overflow-y-hidden",Y&&"rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] bg-[color-mix(in_srgb,var(--foreground)_4%,transparent)] p-0.5 gap-0.5",z?"overflow-x-auto scrollbar-none":"overflow-x-hidden"),style:z?{scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,role:"tablist","aria-label":"Tabs",children:[b&&W?e.jsx("div",{className:le("pointer-events-none absolute left-0 top-0 z-0 rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] bg-[var(--surface-elevated)]","border border-[color-mix(in_srgb,var(--foreground)_7%,transparent)]","shadow-[0_1px_2px_color-mix(in_srgb,var(--foreground)_10%,transparent),0_2px_6px_color-mix(in_srgb,var(--foreground)_6%,transparent)]",ee&&$&&(l?"pill-tabs__indicator--is-animated-layout":"pill-tabs__indicator--is-animated")),style:l?{left:`${W.left+ue}px`,top:`${W.top}px`,width:`${W.width}px`,height:`${W.height}px`}:{transform:`translate3d(${W.left+ue}px, ${W.top}px, 0)`,width:`${W.width}px`,height:`${W.height}px`}}):null,X&&W?e.jsx("div",{className:le("pointer-events-none absolute left-0 -bottom-px z-10 h-[3px] rounded-t-[2px] bg-[var(--primary-base)]",$&&"underline-tabs__indicator--is-animated"),style:{transform:`translate3d(${W.left+ue}px, 0, 0)`,width:`${W.width}px`},"aria-hidden":!0}):null,t.map(P=>{const se=P.id===n,fe=g&&b&&!se&&!!P.icon,R=!fe,w=!!P.icon,_=g&&b&&se&&!z&&!K,L=P.closable!==!1&&!!i,A=L&&!!P.icon,s=z||K?void 0:b?_?"flex-none basis-auto":f?"flex-1 basis-0 min-w-0":"flex-1 basis-0 min-w-fit":"min-w-0 flex-1 basis-0",d=L?H=>{H.button===1&&(H.preventDefault(),H.stopPropagation(),i?.(P.id))}:void 0,D=L?H=>{H.button===1&&H.preventDefault()}:void 0,I=H=>w?e.jsxs("span",{className:H,children:[e.jsx("span",{className:le("flex items-center justify-center transition-opacity",A&&(p?"opacity-0":"group-hover:opacity-0")),children:P.icon}),A?e.jsx("span",{role:"button",tabIndex:-1,className:le("absolute inset-0 z-20 flex !min-h-0 !min-w-0 items-center justify-center rounded-sm text-muted-foreground transition-opacity hover:text-foreground",p?"opacity-100":"opacity-0 group-hover:opacity-100"),onPointerDown:te=>te.stopPropagation(),onClick:te=>{te.stopPropagation(),i?.(P.id)},"aria-label":P.closeLabel??`Close ${P.label} tab`,title:P.closeLabel??`Close ${P.label} tab`,children:e.jsx(V,{name:"close",className:"h-3.5 w-3.5"})}):null]}):null;return e.jsx(Z,{id:P.id,className:s,children:e.jsxs("div",{ref:H=>U(P.id,H),onAuxClick:d,onMouseDown:D,className:le("group flex h-full min-w-0 flex-nowrap items-center",z||K?"shrink-0":b?"w-full":"w-full min-w-0",b?"relative z-10 bg-transparent":se?"relative z-10 bg-transparent text-foreground":"relative z-10 bg-transparent text-muted-foreground hover:text-foreground"),children:[e.jsx("button",{type:"button",role:"tab","aria-selected":se,"aria-label":fe?P.title??P.label:void 0,onClick:()=>o(P.id),onPointerDown:q?()=>{F(!0),ce(P.id)}:void 0,onPointerUp:q?()=>ce(null):void 0,onPointerLeave:q?()=>ce(null):void 0,onPointerCancel:q?()=>ce(null):void 0,className:le(b?"animated-tabs__button pill-tabs__button relative z-10 flex flex-1 min-w-0 flex-nowrap items-center justify-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] text-sm font-medium transition-colors duration-150 !min-h-0":"flex h-full min-w-0 flex-nowrap items-center typography-micro",b&&u?"lowercase":null,b&&(fe?"gap-0":"gap-1.5"),b?K?"shrink-0 whitespace-nowrap px-3 text-center":z?"max-w-56 shrink-0 px-3 text-center":fe?"px-2 !min-w-0 text-center":_?"shrink-0 whitespace-nowrap px-3 text-center":"px-3 text-center":z?"max-w-56 justify-start truncate px-3 text-left":"w-full justify-center truncate px-3 text-center",b?h??(Q?f?"h-[38px]":"h-[31px]":"h-7"):null,b?se?"text-foreground":"text-muted-foreground hover:text-foreground":null,b?"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-background":null),title:P.title??P.label,children:b?e.jsxs(e.Fragment,{children:[I("relative flex h-4 w-4 shrink-0 items-center justify-center"),R?e.jsx("span",{className:"animated-tabs__label truncate",children:P.label}):null]}):e.jsxs("span",{className:le("flex min-w-0 flex-nowrap items-center gap-1.5",!z&&"justify-center"),children:[I(le("relative flex h-4 w-4 shrink-0 items-center justify-center transition-colors duration-200 ease-out",se?"text-[var(--primary-base)]":"text-muted-foreground")),e.jsx("span",{className:"truncate leading-[1.2]",children:P.label})]})}),L&&!A?e.jsx("button",{type:"button",onPointerDown:H=>{H.stopPropagation()},onClick:H=>{H.stopPropagation(),i?.(P.id)},className:le("relative z-20 inline-flex !min-h-0 !min-w-0 items-center justify-center transition-opacity",b?"-ml-2.5 mr-1 h-[88%] w-5 self-center !aspect-auto rounded-md":"aspect-square h-[65%] min-h-4 max-h-5 rounded-sm mr-1",b?se?"text-muted-foreground hover:bg-transparent hover:text-foreground":"text-muted-foreground opacity-0 hover:bg-transparent hover:text-foreground group-hover:opacity-100":se?"text-muted-foreground hover:bg-interactive-hover/60 hover:text-foreground":"text-muted-foreground opacity-0 hover:bg-interactive-hover/80 hover:text-foreground group-hover:opacity-100"),"aria-label":P.closeLabel??`Close ${P.label} tab`,title:P.closeLabel??`Close ${P.label} tab`,children:e.jsx(V,{name:"close",className:"h-3 w-3"})}):null]})},P.id)})]})]});return E?e.jsxs(an,{sensors:M,collisionDetection:ln,onDragEnd:ve,modifiers:[Is],children:[e.jsx(cn,{items:oe,strategy:Kn,children:ye}),e.jsx(Xn,{dropAnimation:null})]}):ye},Kt=280,Xt=280,qt=500,Ws=({isOpen:t,isMobile:n,children:o,className:i,topBar:a})=>{const m=ne(y=>y.sidebarWidth),x=ne(y=>y.setSidebarWidth),[c,h]=r.useState(!1),g=r.useRef(0),v=r.useRef(m||Kt),u=r.useRef(null),l=r.useRef(null),N=r.useRef(null),f=r.useCallback(y=>Math.min(qt,Math.max(Xt,y)),[]),T=r.useCallback(y=>{const b=N.current;b&&(b.style.width=`${y}px`,b.style.minWidth=`${y}px`,b.style.maxWidth=`${y}px`,b.style.setProperty("--oc-left-sidebar-width",`${y}px`))},[]);r.useEffect(()=>{n&&c&&h(!1)},[n,c]),r.useEffect(()=>{c||(u.current=null,l.current=null)},[c]);const p=yr(t);if(n)return null;const S=Math.min(qt,Math.max(Xt,m||Kt)),k=p.layoutVisible?S:0,O=y=>{if(t){try{y.currentTarget.setPointerCapture(y.pointerId)}catch{}l.current=y.pointerId,h(!0),g.current=y.clientX,v.current=k,u.current=k,T(k),y.preventDefault()}},oe=y=>{if(n||!c||l.current!==y.pointerId)return;const b=y.clientX-g.current,X=f(v.current+b);u.current!==X&&(u.current=X,T(X))},z=y=>{if(l.current!==y.pointerId||n)return;try{y.currentTarget.releasePointerCapture(y.pointerId)}catch{}const b=f(u.current??k);l.current=null,u.current=null,h(!1),x(b)},G=c?u.current??k:k,Q=c?G:k;return e.jsxs("aside",{ref:N,className:le("relative flex h-full overflow-hidden motion-reduce:transition-none","bg-sidebar",i),style:{width:`${Q}px`,minWidth:`${Q}px`,maxWidth:`${Q}px`,"--oc-left-sidebar-width":`${c?G:S}px`,overflowX:"clip",transform:c||p.slidIn?"translateX(0)":"translateX(-100%)",transition:c?"none":p.transition},"aria-hidden":!t||Q===0,children:[t&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 shadow-[inset_-2px_0_10px_-2px_rgb(0_0_0_/_0.06)]","aria-hidden":"true"}),t&&e.jsx("div",{className:le("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",c&&"bg-[var(--interactive-border)]"),onPointerDown:O,onPointerMove:oe,onPointerUp:z,onPointerCancel:z,role:"separator","aria-orientation":"vertical","aria-label":"Resize left panel"}),e.jsxs("div",{className:le("relative z-10 flex h-full shrink-0 flex-col",c&&"pointer-events-none",!t&&"pointer-events-none select-none"),style:{width:"var(--oc-left-sidebar-width)",overflowX:"hidden"},"aria-hidden":!t,children:[a,e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:e.jsx(Pe,{children:o})})]})]})},Fs=t=>{if(!t||typeof t!="object")return!1;const n=t;return typeof n.x=="number"&&typeof n.y=="number"},Gt=t=>!t||typeof t!="object"?!1:Object.values(t).every(n=>typeof n=="string"),Ue=t=>{if(!t||typeof t!="object")return!1;const n=t,o=n.bounds;return typeof n.tag=="string"&&typeof n.text=="string"&&typeof n.selector=="string"&&typeof n.path=="string"&&!!o&&typeof o?.x=="number"&&typeof o?.y=="number"&&typeof o?.width=="number"&&typeof o?.height=="number"&&Fs(n.center)&&Gt(n.attributes)&&Gt(n.computedStyle)&&Array.isArray(n.ancestry)},Rt=({pageUrl:t,viewport:n,devicePixelRatio:o,target:i,screenshotAttached:a,intro:m})=>{const x=i.text.trim(),c=Object.entries(i.attributes).map(([N,f])=>`${N}="${f}"`).join(" "),h=i.computedStyle,g=i.bounds,v=i.center,u=m.replace(/[.:]+$/g,""),l=i.ancestry.map(N=>N.selectorPart).join(" > ");return[`${u}:`,`Page: ${t||"preview"}`,`Viewport: ${n.width}x${n.height}, DPR ${o}`,`Screenshot: ${a?"attached":"not attached"}`,`Element: ${i.tag}`,x?`Text: ${x}`:null,`- Selector: ${i.selector}`,`- Path: ${i.path}`,l?`- Ancestry: ${l}`:null,c?`- Attributes: ${c}`:null,`- Bounds: x=${Math.round(g.x)}, y=${Math.round(g.y)}, width=${Math.round(g.width)}, height=${Math.round(g.height)}`,`- Center: x=${Math.round(v.x)}, y=${Math.round(v.y)}`,`Styles: display=${h.display}; position=${h.position}; font=${h.fontWeight} ${h.fontSize} / ${h.lineHeight} ${h.fontFamily}; color=${h.color}; background=${h.backgroundColor}; z-index=${h.zIndex}`].filter(N=>typeof N=="string").join(`
|
|
3
3
|
`)},Re=new Map,Bs=3e4,Et=t=>{const n=Re.get(t);return n?n.expiresAt-Date.now()<=Bs?(Re.delete(t),null):n:null},zs=t=>{try{return new URL(t).origin}catch{return t}},He="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+/p9sAAAAASUVORK5CYII=",ct=new Map;function Tn(t){const n="#ffffff",o=t.defaultView??window;try{const i=t.body?o.getComputedStyle(t.body).backgroundColor:"";if(i&&i!=="rgba(0, 0, 0, 0)"&&i!=="transparent")return i;const a=o.getComputedStyle(t.documentElement).backgroundColor;if(a&&a!=="rgba(0, 0, 0, 0)"&&a!=="transparent")return a}catch{}return n}const _n=t=>new Promise((n,o)=>{const i=new FileReader;i.onloadend=()=>n(typeof i.result=="string"?i.result:He),i.onerror=()=>o(i.error??new Error("Failed to read image blob")),i.readAsDataURL(t)}),Us=async(t,n=.82)=>{const o=await new Promise(i=>t.toBlob(i,"image/jpeg",n));return o&&(await _n(o)).split(",",2)[1]||""},dt=async(t,n)=>{try{const o=await fetch(t,{credentials:n});return o.ok?await _n(await o.blob()):null}catch{return null}},Hs=async t=>{if(t.protocol!=="http:"&&t.protocol!=="https:")return"";const n=t.origin,o=Et(n);if(o)return`${o.proxyBasePath}${t.pathname}${t.search}${t.hash}`;const i=ct.get(n),a=i??(async()=>{try{const x=await rt("/api/preview/targets",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({url:t.toString(),allowExternal:!0})});if(!x.ok)return Re.delete(n),null;const c=await x.json(),h=typeof c.proxyBasePath=="string"?c.proxyBasePath:"",g=typeof c.expiresAt=="number"?c.expiresAt:0;if(!h)return Re.delete(n),null;const v={proxyBasePath:h,expiresAt:g};return Re.set(n,v),v}catch{return Re.delete(n),null}finally{ct.delete(n)}})();i||ct.set(n,a);const m=await a;return m?`${m.proxyBasePath}${t.pathname}${t.search}${t.hash}`:""},An=async(t,n)=>{if(!t||t.startsWith("data:"))return t;try{const o=new URL(t,n.baseURI);if(o.origin===window.location.origin||o.protocol!=="http:"&&o.protocol!=="https:")return await dt(o.toString(),"include")??He;const i=await Hs(o),a=i?await dt(i,"include"):null;return a||(await dt(o.toString(),"omit")??He)}catch{return He}},Vs=async(t,n)=>{if(!t||t==="none"||!t.includes("url("))return t;const o=Array.from(t.matchAll(/url\((['"]?)(.*?)\1\)/g));let i=t;for(const a of o){const m=a[2]||"";if(!m||m.startsWith("data:"))continue;const x=await An(m,n);i=i.replace(a[0],`url("${x}")`)}return i},Yt=t=>t.complete?Promise.resolve():new Promise(n=>{t.addEventListener("load",()=>n(),{once:!0}),t.addEventListener("error",()=>n(),{once:!0})}),Dn=t=>{const n=t.style.cssText;return()=>{t.style.cssText=n}},Ks=t=>{const n=Number.parseFloat(t.lineHeight);if(Number.isFinite(n)&&n>0)return n;const o=Number.parseFloat(t.fontSize);return Number.isFinite(o)&&o>0?o*1.2:16},Xs=(t,n,o)=>{const i=[],a=t.defaultView??window,x=Array.from(t.querySelectorAll('button, a, summary, label, [role="button"], [role="link"], [role="menuitem"], [role="tab"], nav *, header *'));for(const c of x){const h=c.textContent?.replace(/\s+/g," ").trim()??"";if(!h||!h.includes(" "))continue;const g=c.getBoundingClientRect();if(g.width<=0||g.height<=0||g.right<0||g.bottom<0||g.left>n||g.top>o)continue;const v=a.getComputedStyle(c);if(v.display==="none"||v.visibility==="hidden"||Number(v.opacity)===0)continue;const u=v.getPropertyValue("text-wrap"),l=v.getPropertyValue("text-wrap-mode"),N=v.whiteSpace.includes("nowrap")||u==="nowrap"||l==="nowrap",f=g.height<=Ks(v)*1.7;!N&&(!f||g.width>n*.72)||(i.push(Dn(c)),c.style.whiteSpace="nowrap",c.style.overflowWrap="normal",c.style.wordBreak="normal",c.style.setProperty("text-wrap","nowrap"),c.style.setProperty("text-wrap-mode","nowrap"))}return()=>{for(let c=i.length-1;c>=0;c-=1)i[c]?.()}},qs=(t,n,o,i)=>{const a=[],m=t.defaultView??window,x=m.scrollX||t.documentElement.scrollLeft||t.body?.scrollLeft||0,c=m.scrollY||t.documentElement.scrollTop||t.body?.scrollTop||0,h=Array.from(t.querySelectorAll("*")).filter(g=>{const v=m.getComputedStyle(g);if(v.position!=="fixed"||v.display==="none"||v.visibility==="hidden"||Number(v.opacity)===0)return!1;const u=g.getBoundingClientRect();return u.width>0&&u.height>0&&u.right>=0&&u.bottom>=0&&u.left<=n&&u.top<=o}).filter((g,v,u)=>!u.some((l,N)=>N<v&&l.contains(g)));for(const g of h){const v=g.getBoundingClientRect(),u=m.getComputedStyle(g),l=Math.ceil(v.width)+8,N=Math.ceil(v.height)+2;i?.add(g),a.push(Dn(g)),g.style.position="absolute",g.style.top=`${v.top+c}px`,g.style.left=`${v.left+x}px`,g.style.right="auto",g.style.bottom="auto",g.style.width=`${l}px`,g.style.minWidth=`${l}px`,g.style.height=`${N}px`,g.style.minHeight=`${N}px`,g.style.margin="0",g.style.boxSizing="border-box",g.style.transform="none",u.zIndex!=="auto"&&(g.style.zIndex=u.zIndex)}return()=>{for(let g=a.length-1;g>=0;g-=1)a[g]?.()}},Mn=async(t,n,o,i={})=>{const a=[],m=t.defaultView??window,x=u=>{if(u===t.documentElement||u===t.body)return!0;try{const l=u.getBoundingClientRect();return l.width>0&&l.height>0&&l.right>=0&&l.bottom>=0&&l.left<=n&&l.top<=o}catch{return!1}};if(i.applyLayoutWorkarounds){const u=new WeakSet;a.push(qs(t,n,o,u)),a.push(Xs(t,n,o))}const c=new Map;for(const u of Array.from(t.images))c.set(u,u.currentSrc||u.src||u.getAttribute("src")||"");const h=Array.from(t.querySelectorAll("picture"));for(const u of h){const l=Array.from(u.querySelectorAll("source"));if(l.length===0)continue;const N=l.map(f=>({source:f,srcset:f.getAttribute("srcset"),sizes:f.getAttribute("sizes")}));a.push(()=>{for(const f of N)f.srcset===null?f.source.removeAttribute("srcset"):f.source.setAttribute("srcset",f.srcset),f.sizes===null?f.source.removeAttribute("sizes"):f.source.setAttribute("sizes",f.sizes)});for(const f of l)f.removeAttribute("srcset"),f.removeAttribute("sizes")}const g=Array.from(t.images).filter(u=>x(u));await Promise.all(g.map(async u=>{const l=c.get(u)||u.currentSrc||u.src||u.getAttribute("src")||"";if(!l)return;await Yt(u);const N=await An(l,t),f={src:u.getAttribute("src"),srcset:u.getAttribute("srcset"),sizes:u.getAttribute("sizes")};a.push(()=>{f.src===null?u.removeAttribute("src"):u.setAttribute("src",f.src),f.srcset===null?u.removeAttribute("srcset"):u.setAttribute("srcset",f.srcset),f.sizes===null?u.removeAttribute("sizes"):u.setAttribute("sizes",f.sizes)}),u.removeAttribute("srcset"),u.removeAttribute("sizes"),u.setAttribute("src",N||He),await Yt(u)}));const v=Array.from(t.querySelectorAll("*")).filter(x);return await Promise.all(v.map(async u=>{const l=m.getComputedStyle(u).backgroundImage;if(!l||l==="none"||!l.includes("url("))return;const N=await Vs(l,t);if(N===l)return;const f=u.style.backgroundImage;a.push(()=>{u.style.backgroundImage=f}),u.style.backgroundImage=N})),()=>{for(let u=a.length-1;u>=0;u-=1)try{a[u]?.()}catch{}}},Gs=()=>{try{return!!window.__previewCaptureDebug}catch{return!1}},et=(...t)=>{Gs()&&console.info("[preview-capture]",...t)},In=(t,n=8)=>{const o=[];try{const i=t.querySelectorAll("*");for(const a of i){const m=a.scrollTop||0,x=a.scrollLeft||0;if(m<=0&&x<=0)continue;const c=a.tagName.toLowerCase(),h=a.id?`#${a.id}`:"",g=typeof a.className=="string"&&a.className?`.${a.className.trim().split(/\s+/).slice(0,2).join(".")}`:"";if(o.push({selector:`${c}${h}${g}`,scrollTop:m,scrollLeft:x,clientWidth:a.clientWidth,clientHeight:a.clientHeight,scrollWidth:a.scrollWidth,scrollHeight:a.scrollHeight}),o.length>=n)break}}catch{}return o},Ge="data-oc-fixed-pin",Ys=(t,n,o)=>{if(n<=0&&o<=0)return()=>{};const i=t.defaultView;if(!i)return()=>{};const a=[],m=[];try{for(const x of t.querySelectorAll("*")){if(i.getComputedStyle(x).position!=="fixed")continue;const c=x.getBoundingClientRect();if(!(c.width>0&&c.height>0))continue;x.setAttribute(Ge,JSON.stringify({top:c.top+o,left:c.left+n,width:c.width,height:c.height})),a.push(x);const h=x.tagName.toLowerCase(),g=typeof x.className=="string"&&x.className?`.${x.className.trim().split(/\s+/).slice(0,2).join(".")}`:"";m.push({selector:`${h}${g}`,top:Math.round(c.top),left:Math.round(c.left),width:Math.round(c.width),height:Math.round(c.height)})}}catch{}return et("tagged fixed elements",m),()=>{for(const x of a)try{x.removeAttribute(Ge)}catch{}}},Js={name:"oc-fixed-pin",afterClone(t){const n=t?.clone;if(!(!n||typeof n.querySelectorAll!="function"))for(const o of n.querySelectorAll(`[${Ge}]`)){let i;try{i=JSON.parse(o.getAttribute(Ge)||"")}catch{continue}o.style.setProperty("position","absolute","important"),o.style.setProperty("top",`${i.top}px`,"important"),o.style.setProperty("left",`${i.left}px`,"important"),o.style.setProperty("right","auto","important"),o.style.setProperty("bottom","auto","important"),o.style.setProperty("width",`${i.width}px`,"important"),o.style.setProperty("height",`${i.height}px`,"important"),o.removeAttribute(Ge)}}},ze="data-oc-scroll-pin",Qs=t=>{const n=[],o=In(t,64);try{const m=t.documentElement,x=t.body;for(const c of t.querySelectorAll("*")){const h=c.scrollTop||0,g=c.scrollLeft||0;if(h<=0&&g<=0)continue;const v=c!==m&&c!==x;v&&c.setAttribute(ze,JSON.stringify({top:h,left:g})),n.push({el:c,top:h,left:g,tagged:v})}}catch{}return{reapply:()=>{for(const m of n)try{m.el.scrollHeight,m.el.scrollTop!==m.top&&(m.el.scrollTop=m.top),m.el.scrollLeft!==m.left&&(m.el.scrollLeft=m.left)}catch{}},cleanup:()=>{for(const m of n)if(m.tagged)try{m.el.removeAttribute(ze)}catch{}},snapshot:o}},Zs={name:"oc-nested-scroll",afterClone(t){const n=t?.clone;if(!n||typeof n.querySelectorAll!="function")return;const o=n.ownerDocument;if(o)for(const i of n.querySelectorAll(`[${ze}]`)){let a;try{a=JSON.parse(i.getAttribute(ze)||"")}catch{i.removeAttribute(ze);continue}const m=`translate(${-a.left}px, ${-a.top}px)`,x=i.children.length===1&&i.firstElementChild instanceof HTMLElement&&i.firstElementChild.style.willChange==="transform"?i.firstElementChild:null;if(x)x.style.transform=m;else{i.style.overflow="hidden";const c=o.createElement("div");for(c.style.transform=m,c.style.willChange="transform",c.style.display="inline-block",c.style.width="100%";i.firstChild;)c.appendChild(i.firstChild);i.appendChild(c)}i.removeAttribute(ze)}}},Ln=async(t,n)=>{if(typeof window<"u")try{const o=t.getBoundingClientRect(),i=await hn("desktop_capture_page_rect",{x:o.left,y:o.top,width:o.width,height:o.height});if(!i)throw new Error("Desktop screenshot capture is not available");const a=new Image;await new Promise((f,T)=>{a.onload=()=>f(),a.onerror=()=>T(new Error("Failed to load desktop preview screenshot")),a.src=`data:${i.mime};base64,${i.base64}`});const m=Math.max(1,a.naturalWidth||i.width||Math.floor(o.width)),x=Math.max(1,a.naturalHeight||i.height||Math.floor(o.height)),h=Math.min(1,1200/m),g=document.createElement("canvas");g.width=Math.floor(m*h),g.height=Math.floor(x*h);const v=g.getContext("2d");if(!v)return null;v.scale(h,h),v.drawImage(a,0,0,m,x);const u=m/Math.max(1,o.width),l=x/Math.max(1,o.height);v.fillStyle="rgba(37, 99, 235, 0.28)",v.strokeStyle="rgb(37, 99, 235)",v.lineWidth=Math.max(2,2*u),v.fillRect(n.bounds.x*u,n.bounds.y*l,n.bounds.width*u,n.bounds.height*l),v.strokeRect(n.bounds.x*u,n.bounds.y*l,n.bounds.width*u,n.bounds.height*l);const N=await new Promise(f=>g.toBlob(f,"image/jpeg",.82));return N?new File([N],`preview-annotation-${Date.now()}.jpg`,{type:"image/jpeg"}):null}catch(o){return console.warn("[preview] failed to capture annotation screenshot:",o),null}return await to(t,n)},Tt=async(t,n,o,i,a,m)=>{if(!t)return null;try{const x=new Image;await new Promise((p,S)=>{x.onload=()=>p(),x.onerror=()=>S(new Error("Failed to load desktop browser screenshot")),x.src=`data:image/jpeg;base64,${t}`});const c=Math.max(1,x.naturalWidth||n),h=Math.max(1,x.naturalHeight||o),v=Math.min(1,1200/c),u=document.createElement("canvas");u.width=Math.floor(c*v),u.height=Math.floor(h*v);const l=u.getContext("2d");if(!l)return null;l.scale(v,v),l.drawImage(x,0,0,c,h);const N=c/Math.max(1,i||c),f=h/Math.max(1,a||h);l.fillStyle="rgba(37, 99, 235, 0.14)",l.strokeStyle="rgb(37, 99, 235)",l.lineWidth=Math.max(2,2*N),l.fillRect(m.bounds.x*N,m.bounds.y*f,m.bounds.width*N,m.bounds.height*f),l.strokeRect(m.bounds.x*N,m.bounds.y*f,m.bounds.width*N,m.bounds.height*f);const T=await new Promise(p=>u.toBlob(p,"image/jpeg",.82));return T?new File([T],`browser-annotation-${Date.now()}.jpg`,{type:"image/jpeg"}):null}catch{return null}};async function eo(t,n){try{const o=t.contentWindow,i=t.contentDocument??o?.document,a=i?.documentElement;if(!o||!i||!a)return null;const m=t.getBoundingClientRect(),x=Math.max(1,Math.ceil(o.innerWidth||t.clientWidth||m.width)),c=Math.max(1,Math.ceil(o.innerHeight||t.clientHeight||m.height)),h=i.body,g=i.scrollingElement instanceof HTMLElement?i.scrollingElement:null,v=o.scrollX||0,u=o.scrollY||0,l=o.pageXOffset||0,N=o.pageYOffset||0,f=o.visualViewport?.pageLeft||o.visualViewport?.offsetLeft||0,T=o.visualViewport?.pageTop||o.visualViewport?.offsetTop||0,p=a.scrollLeft||0,S=a.scrollTop||0,k=h?.scrollLeft||0,O=h?.scrollTop||0,oe=g?.scrollLeft||0,z=g?.scrollTop||0,G=Math.max(v,l,f,p,k,oe),Q=Math.max(u,N,T,S,O,z);et("scroll sources",{windowScrollX:v,windowScrollY:u,pageScrollX:l,pageScrollY:N,visualViewportScrollX:f,visualViewportScrollY:T,rootScrollX:p,rootScrollY:S,bodyScrollX:k,bodyScrollY:O,scrollingElementScrollX:oe,scrollingElementScrollY:z,scrollingElementTag:g?.tagName?.toLowerCase()??null,resolvedScrollX:G,resolvedScrollY:Q,nestedScrolledElements:In(i)});const y=Math.max(x,a.scrollWidth||0,h?.scrollWidth||0,Math.ceil(a.getBoundingClientRect().width||0)),b=Math.max(c,a.scrollHeight||0,h?.scrollHeight||0,Math.ceil(a.getBoundingClientRect().height||0)),X=Math.min(2,Math.max(1,window.devicePixelRatio||1)),q=a.style.scrollBehavior,K=h?.style.scrollBehavior??"";a.style.scrollBehavior="auto",h&&(h.style.scrollBehavior="auto");const Y=Qs(i);et("nested scroll snapshot",Y.snapshot);let ee=()=>{},E=()=>{};try{await i.fonts?.ready.catch(()=>{}),ee=await Mn(i,x,c,{applyLayoutWorkarounds:!1}),o.scrollTo(G,Q),E=Ys(i,G,Q),Y.reapply();const{snapdom:Z}=await Ee(async()=>{const{snapdom:U}=await import("./vendor-zumer-snapdom-Btyu_Xi2.js");return{snapdom:U}},[]),j={backgroundColor:Tn(i),cache:"disabled",dpr:X,embedFonts:!0,fast:!1,height:b,outerShadows:!0,outerTransforms:!0,placeholders:!0,plugins:[Js,Zs],quality:.82,width:y},re=await(await Z(a,j)).toCanvas();if(!re.width||!re.height)return null;const $=re.width/Math.max(1,y),F=re.height/Math.max(1,b),ie=Math.min(re.width,Math.max(1,Math.round(x*$))),ce=Math.min(re.height,Math.max(1,Math.round(c*F))),he=Math.max(0,re.width-ie),ge=Math.max(0,re.height-ce),pe=Math.min(he,Math.max(0,Math.round(G*$))),de=Math.min(ge,Math.max(0,Math.round(Q*F)));et("capture geometry",{viewportWidth:x,viewportHeight:c,captureWidth:y,captureHeight:b,canvasWidth:re.width,canvasHeight:re.height,xScale:$,yScale:F,sourceX:pe,sourceY:de,sourceWidth:ie,sourceHeight:ce});const ue=i.createElement("canvas");ue.width=ie,ue.height=ce;const M=ue.getContext("2d");if(!M)return null;M.drawImage(re,pe,de,ie,ce,0,0,ie,ce);const B=await Us(ue,.82);return B?await Tt(B,x,c,x,c,n):null}finally{E(),Y.cleanup(),ee(),o.scrollTo(G,Q),Y.reapply(),a.style.scrollBehavior=q,h&&(h.style.scrollBehavior=K)}}catch(o){return console.warn("[preview] failed to capture iframe DOM screenshot with snapDOM:",o),null}}async function to(t,n){const o=await eo(t,n);if(o)return o;try{const i=t.contentWindow,a=t.contentDocument??i?.document,m=a?.documentElement;if(!i||!a||!m)return null;const x=t.getBoundingClientRect(),c=Math.max(1,Math.ceil(i.innerWidth||t.clientWidth||x.width)),h=Math.max(1,Math.ceil(i.innerHeight||t.clientHeight||x.height)),g=i.scrollX||a.documentElement.scrollLeft||a.body?.scrollLeft||0,v=i.scrollY||a.documentElement.scrollTop||a.body?.scrollTop||0,u=a.body,l=Math.max(h,m.scrollHeight||0,u?.scrollHeight||0),N=Math.min(2,Math.max(1,window.devicePixelRatio||1)),f=m.style.scrollBehavior,T=u?.style.scrollBehavior??"";m.style.scrollBehavior="auto",u&&(u.style.scrollBehavior="auto");let p="",S=()=>{};try{await a.fonts?.ready.catch(()=>{}),S=await Mn(a,c,h,{applyLayoutWorkarounds:!0}),i.scrollTo(g,v);const{getFontEmbedCSS:O,toJpeg:oe}=await Ee(async()=>{const{getFontEmbedCSS:G,toJpeg:Q}=await import("./vendor-html-to-image-BeoRn2gJ.js");return{getFontEmbedCSS:G,toJpeg:Q}},[]),z=await O(m).catch(()=>"");p=await oe(m,{quality:.82,pixelRatio:N,width:c,height:h,backgroundColor:Tn(a),imagePlaceholder:He,fontEmbedCSS:z||void 0,style:{transform:`translate(${-g}px, ${-v}px)`,transformOrigin:"top left",minWidth:`${c}px`,minHeight:`${l}px`},cacheBust:!0})}finally{S(),i.scrollTo(g,v),m.style.scrollBehavior=f,u&&(u.style.scrollBehavior=T)}const k=p.split(",",2)[1]||"";return k?await Tt(k,c,h,c,h,n):null}catch(i){return console.warn("[preview] failed to capture iframe DOM screenshot:",i),null}}const Jt=200,no=(t,n)=>n==="all"?!0:n==="errors"?t.level==="error"||t.level==="runtime"||t.level==="resource":n==="warnings"?t.level==="warn":t.level==="log"||t.level==="info"||t.level==="debug",ot=t=>{const n=it.getState();n.setPendingSyntheticParts([...n.pendingSyntheticParts??[],{text:t,synthetic:!0}])},On=async t=>{const n=await t.json().catch(()=>({}));if(!t.ok)return{ok:!1,message:typeof n.error=="string"?n.error:`HTTP ${t.status}`};const o=typeof n.proxyBasePath=="string"?n.proxyBasePath:"",i=typeof n.previewToken=="string"?n.previewToken:"";return!o||!i?{ok:!1,message:"Could not start preview proxy."}:{ok:!0,target:{proxyBasePath:o,previewToken:i,expiresAt:typeof n.expiresAt=="number"?n.expiresAt:0}}},$n=t=>{if(typeof window>"u")return"";try{return new URL(t||window.location.href,window.location.href).origin}catch{return window.location.origin}},Qt=(t,n,o)=>{t.postMessage(o,$n(n))},ro=t=>{if(!t)return t;try{const n=new URL(t);return n.searchParams.delete("oc_preview_token"),n.searchParams.delete("oc_client_token"),n.searchParams.delete("oc_url_token"),n.toString()}catch{return t}},Zt=t=>{if(!t)return t;try{const n=new URL(t);return n.searchParams.delete("ocPreview"),n.searchParams.delete("oc_preview_token"),n.searchParams.delete("oc_client_token"),n.searchParams.delete("oc_url_token"),n.toString()}catch{return t}};function Wn(t){const[n,o]=r.useState("");return r.useEffect(()=>{if(!t){o("");return}let i=!1;return o(""),Zn(fn()).then(a=>{!i&&a&&o(t)}).catch(()=>{}),()=>{i=!0}},[t]),n}const Fn=`new Promise((resolve) => {
|
|
4
4
|
const existing = document.getElementById('__pichamber_desktop_browser_overlay');
|
|
5
5
|
if (existing) existing.remove();
|
|
@@ -132,5 +132,5 @@ ${_.details}`:"";return`[${L}] [${_.level}] ${_.message}${A}`}).join(`
|
|
|
132
132
|
${L.details}`:"";return`[${A}] [${L.level}] ${L.message}${s}`}).join(`
|
|
133
133
|
`);ot(`These are browser console logs from the dev server running for this project.
|
|
134
134
|
|
|
135
|
-
${w}${_}`),je.success("Preview console attached to chat")},[S,Q,b,F,y,t]),[B,U]=r.useState("unknown"),J=r.useRef(0),ae=r.useRef(0),xe=r.useRef(""),ve=r.useRef(""),ye=15e3;r.useEffect(()=>{if(!$){U("unknown"),xe.current="",J.current=0,ae.current=0;return}let R=!1,w=null;xe.current!==E&&(xe.current=E,J.current=Date.now(),ae.current=0);const _=L=>{w=setTimeout(()=>{R||a()},L)};return U("unknown"),(async()=>{const A=await(async()=>{try{return await rt($,{method:"GET",credentials:"include",cache:"no-store",redirect:"manual"})}catch{return null}})();if(R)return;if(!A){U("unreachable"),_(5e3);return}const s=So(A.headers,ve.current===E);if(s!=="none"){if(Re.delete(E),s==="retry-registration")ve.current=E,h({status:"loading"}),x();else{const I=await A.json().catch(()=>({}));if(R)return;const H=typeof I?.error=="string"?I.error:`HTTP ${A.status}`;h({status:"error",message:H})}return}if(A.status!==502){ve.current="",U("reachable");return}const d=J.current||Date.now();if(Date.now()-d<ye){U("starting"),ae.current+=1;const I=ae.current,H=Math.min(2e3,250*Math.pow(2,Math.min(4,I)));_(H);return}U("unreachable"),_(5e3)})(),()=>{R=!0,w&&clearTimeout(w)}},[E,$,i]);const P=K&&c.status==="ready"&&(B==="unknown"||B==="starting"),se=K&&c.status==="ready"&&B==="unreachable",fe=r.useCallback(R=>{if(!K||c.status!=="ready"||typeof window>"u")return;const w=R.currentTarget.contentWindow;if(w)try{const _=w.location,L=$n($);if(_.origin!==L||_.pathname.startsWith(c.proxyBasePath))return;const A=`${c.proxyBasePath}${_.pathname}${_.search}${_.hash}`;w.location.replace(A)}catch{}},[K,$,c]);return e.jsxs("div",{className:"absolute inset-0 flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[e.jsx("div",{className:"min-w-0 flex-1 truncate typography-micro text-muted-foreground",title:ie||t,children:ie||t||"No preview URL"}),e.jsx(me,{type:"button",size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>a(),title:"Reload preview","aria-label":"Reload preview",disabled:!F,children:e.jsx(V,{name:"refresh",className:"h-3.5 w-3.5"})}),e.jsx(me,{type:"button",size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{j&&st(j)},title:"Open in browser","aria-label":"Open in browser",disabled:!j,children:e.jsx(V,{name:"external-link",className:"h-3.5 w-3.5"})}),K?e.jsx(me,{type:"button",size:"sm",variant:O?"secondary":"ghost",className:"h-7 gap-1 px-2",onClick:()=>oe(R=>!R),title:"Inspect preview element","aria-label":"Inspect preview element",disabled:!u,children:e.jsx(V,{name:"cursor",className:"h-3.5 w-3.5"})}):null,K?e.jsxs(me,{type:"button",size:"sm",variant:N?"secondary":"ghost",className:"h-7 gap-1 px-2",onClick:()=>f(R=>!R),title:u?"Open preview console":"Waiting for preview console","aria-label":u?"Open preview console":"Waiting for preview console",disabled:!u&&S.length===0,children:[e.jsx(V,{name:"terminal-box",className:"h-3.5 w-3.5"}),pe>0?e.jsx("span",{className:"typography-micro text-status-error",children:pe}):null]}):null]}),e.jsxs("div",{className:"relative min-h-0 flex-1 bg-background",children:[P?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center text-sm text-muted-foreground",children:[e.jsx("div",{children:"Starting dev server..."}),e.jsx("div",{className:"text-xs opacity-70",children:"Waiting for the server to accept connections."})]}):se?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center text-sm text-muted-foreground",children:[e.jsx("div",{children:"Dev server is not responding."}),e.jsx("div",{className:"text-xs opacity-70",children:"Make sure your dev server is still running, then retry."}),e.jsx(me,{type:"button",size:"sm",variant:"outline",onClick:()=>a(),children:"Retry"})]}):F&&(!K||B==="reachable")?e.jsxs("div",{className:"relative h-full w-full",children:[e.jsx("iframe",{ref:g,src:F,title:"Preview",className:"h-full w-full border-0",style:{colorScheme:Z},onLoad:fe,sandbox:K?"allow-scripts allow-same-origin allow-forms allow-popups allow-downloads":"allow-scripts allow-forms"},`${F}:${i}`),O&&z?e.jsx("div",{className:"pointer-events-none absolute rounded-sm border-2 border-[var(--interactive-focus-ring)] bg-[var(--interactive-focus-ring)]/35",style:{left:z.bounds.x,top:z.bounds.y,width:z.bounds.width,height:z.bounds.height},children:e.jsxs("div",{className:"absolute -top-6 left-0 max-w-64 truncate rounded bg-[var(--surface-elevated)] px-2 py-0.5 typography-micro text-foreground shadow",children:[z.tag,z.text?` · ${z.text}`:""]})}):null]}):ce?e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-sm text-muted-foreground",children:"Connecting preview proxy..."}):he?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 px-6 text-sm text-muted-foreground",children:[e.jsx("div",{children:"Could not start preview proxy."}),c.status==="error"?e.jsx("div",{className:"text-center text-xs opacity-70",children:c.message}):null]}):e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-sm text-muted-foreground",children:"Preview needs a valid http(s) URL."}),N?e.jsxs("div",{className:"absolute inset-x-3 bottom-3 z-10 max-h-[45%] overflow-hidden rounded-xl border border-border/70 bg-[var(--surface-elevated)] shadow-lg",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border/50 px-3 py-2",children:[e.jsx("div",{className:"typography-ui-label text-foreground",children:"Preview console"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(me,{type:"button",size:"xs",variant:"ghost",onClick:M,disabled:S.length===0,children:"Attach"}),e.jsx(me,{type:"button",size:"xs",variant:"ghost",onClick:ue,disabled:S.length===0,children:"Copy"}),e.jsx(me,{type:"button",size:"xs",variant:"ghost",onClick:()=>k([]),disabled:S.length===0,children:"Clear"})]})]}),e.jsx("div",{className:"flex items-center gap-1 border-b border-border/30 px-3 py-1.5",children:["all","errors","warnings","logs"].map(R=>e.jsx(me,{type:"button",size:"xs",variant:T===R?"secondary":"ghost",onClick:()=>p(R),children:R==="all"?"All":R==="errors"?"Errors":R==="warnings"?"Warnings":"Logs"},R))}),e.jsx("div",{className:"max-h-64 overflow-auto p-2 typography-code text-xs",children:S.length===0?e.jsx("div",{className:"px-2 py-3 text-muted-foreground",children:"No preview console events yet."}):de.length===0?e.jsx("div",{className:"px-2 py-3 text-muted-foreground",children:"No events match this filter."}):de.map(R=>e.jsx("div",{className:"border-b border-border/30 px-2 py-1 last:border-b-0",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:le("shrink-0 uppercase",R.level==="error"||R.level==="runtime"||R.level==="resource"?"text-status-error":R.level==="warn"?"text-status-warning":"text-muted-foreground"),children:R.level}),e.jsx("span",{className:"min-w-0 break-words text-foreground",children:R.message})]})},R.id))})]}):null]})]})},At=t=>t,xt=t=>{const n=At(t).type;return typeof n=="string"?n:""},Co=t=>{const n=At(t).tool;return typeof n=="string"?n:""},No=t=>{const n=At(t).text;return typeof n=="string"?n:""},ko=t=>{const n=xt(t);return n==="tool"?Co(t).trim().toLowerCase()||"tool":n||"unknown"},Po=t=>{if(t.length===0)return"";const n=[];for(const o of t){const i=ko(o);n.includes(i)||n.push(i)}return n.join(" + ")},Ro=t=>t.replace(/\s+/g," ").trim(),Eo=t=>{for(const o of t)if(xt(o)==="text"){const i=Ro(No(o));if(i.length===0)continue;return i}const n=t.filter(o=>xt(o)!=="text").length;return n===0?"":`${n} attachment${n===1?"":"s"}`},To=(t,n,o)=>`${o(t)} / ${o(n)}`,_o=t=>{if(t==="12h")return!0;if(t==="24h")return!1},Ao=(t,n)=>{if(!t||!Number.isFinite(t))return"-";const o=_o(n);return new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:o===!1?"2-digit":"numeric",minute:"2-digit",...o===void 0?{}:{hour12:o}})},Do={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},nt={user:0,assistant:0,tool:0,other:0},Mo=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,ht=t=>gt(t),Io=(...t)=>{for(const n of t)if(typeof n=="string"&&n.trim().length>0)return n;return""},ke=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((n,o)=>n+ke(o),0):t&&typeof t=="object"?Object.values(t).reduce((n,o)=>n+ke(o),0):0,Lo=(t,n)=>{const o=t,i=typeof o.type=="string"?o.type:"";if(i==="reasoning")return{...nt,assistant:ke(o.text)+ke(o.content)};const a=Io(o.text,o.content,o.value,o.source?.value,o.source?.text?.value);return i==="tool"||n==="tool"?{user:0,assistant:0,tool:ke(o.input)+ke(o.output)+ke(o.error)+ke(o.call?.input)+ke(o.call?.output)+ke(o.call?.error)+ke(o.raw)+Math.round(ke(o.metadata)*.25)+Math.round(ke(o.state)*.1),other:0}:n==="user"?{user:a.length,assistant:0,tool:0,other:0}:n==="assistant"?{user:0,assistant:a.length,tool:0,other:0}:{user:0,assistant:0,tool:0,other:a.length}},nn=(t,n)=>({user:t.user+n.user,assistant:t.assistant+n.assistant,tool:t.tool+n.tool,other:t.other+n.other}),Oo=t=>{const n=qe(t.info);return n.isUser?"user":n.role==="assistant"?"assistant":n.role==="tool"?"tool":"other"},$o=(t,n)=>{if(t.length===0)return{...nt};const o=t.reduce((i,a)=>{const m=Oo(a);let x={...nt};for(const c of a.parts)x=nn(x,Lo(c,m));return nn(i,x)},{...nt});return o.user+=n.length,{user:Math.ceil(o.user/4),assistant:Math.ceil(o.assistant/4),tool:Math.ceil(o.tool/4),other:Math.ceil(o.other/4)}},Le=t=>t.toLocaleString("en-US"),Wo=t=>!Number.isFinite(t)||t<=0?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(0):new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:t<.01?4:2,maximumFractionDigits:t<.01?4:2}).format(t),Fo=(t,n)=>!t||!Number.isFinite(t)?"-":Yr(t,n,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),Bo=(t,n,o)=>{const i=t.find(m=>m.id===n),a=i?.models?.find(m=>m.id===o);return{providerName:i?.name||n||"-",modelName:a?.name||o||"-",contextLimit:typeof a?.limit?.context=="number"?a.limit.context:null}},zo=()=>{const t=ne(f=>f.timeFormatPreference),[n,o]=r.useState({}),{value:i,show:a,clear:m}=Xr(null,2e3),x=Ce(f=>f.currentSessionId),c=Ce(f=>f.currentSessionDirectory),h=qr(),g=jn(x??""),v=$e(f=>f.providers);r.useEffect(()=>{o(f=>Object.keys(f).length>0?{}:f),m()},[m,c,x]);const u=r.useCallback(async(f,T)=>{(await bt(T)).ok?a(f):m()},[m,a]),l=r.useMemo(()=>{const f=x?h.find($=>$.id===x)??null:null,T=g.filter($=>qe($.info).role==="assistant"),p=g.filter($=>qe($.info).isUser);let S=null;for(let $=T.length-1;$>=0;$-=1){const F=T[$];if(ht(F).total>0){S=F;break}}const k=S?ht(S):Do,O=S?.info?.usage,oe=wn({input:k.input,cache:{read:k.cacheRead,write:k.cacheWrite}}),z=T.reduce(($,F)=>{const ie=Mo(F.info.cost);return $+ie},0),G=S?.info?.model??null,Q=Bo(v,G?.providerID||"",G?.modelID||""),y=Q.contextLimit,b=O?yn(O):k.total,X=y&&y>0?Math.min(999,b/y*100):0,q=[...g].reverse().find($=>qe($.info).isUser&&typeof $.info.system=="string")?.info?.system||"",K=$o(g,q),Y=K.user,ee=K.assistant,E=K.tool,Z=O?0:Math.max(0,k.input-Y-ee-E),j=Y+ee+E+Z,W=g[0]?.info?.time?.created,re=g.length>0?g[g.length-1]?.info?.time?.created:null;return{sessionTitle:En(f),messagesCount:g.length,userMessagesCount:p.length,assistantMessagesCount:T.length,createdAt:f?.time?.created??W??null,lastActivityAt:re??f?.time?.created??null,providerModel:Q,tokenBreakdown:k,usagePercent:X,cacheHitRate:oe,totalAssistantCost:z,contextLimit:y,contextWindowTokens:b,hasUsage:O!==void 0,breakdown:{user:Y,assistant:ee,tool:E,other:Z},breakdownTotal:j}},[x,v,g,h]);if(!x)return e.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:"Open a session to inspect context."});const N=[{key:"user",label:"User",value:l.breakdown.user,color:"var(--status-success)"},{key:"assistant",label:"Assistant",value:l.breakdown.assistant,color:"var(--primary-base)"},{key:"tool",label:"Tool Calls",value:l.breakdown.tool,color:"var(--status-warning)"},...l.hasUsage?[]:[{key:"other",label:"Other",value:l.breakdown.other,color:"var(--surface-muted-foreground)"}]];return e.jsx("div",{className:"h-full overflow-y-auto bg-background",children:e.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:l.sessionTitle}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground/70",children:[e.jsxs("span",{children:[l.providerModel.providerName," / ",l.providerModel.modelName]}),l.createdAt&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("span",{children:Fo(l.createdAt,t)})]})]})]}),e.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsx("span",{className:"typography-micro text-muted-foreground",children:"Context"}),e.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground/70",children:[Le(l.contextWindowTokens),l.contextLimit?` / ${Le(l.contextLimit)}`:""]})]}),e.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:l.usagePercent>0&&e.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,l.usagePercent)}%`,backgroundColor:l.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}})}),e.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:`${l.usagePercent.toFixed(1)}% used`})]}),e.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:[{label:"Messages",value:Le(l.messagesCount)},{label:"User",value:Le(l.userMessagesCount)},{label:"Assistant",value:Le(l.assistantMessagesCount)},{label:"Cost",value:Wo(l.totalAssistantCost)}].map(f=>e.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5",children:[e.jsx("div",{className:"typography-micro text-muted-foreground/70",children:f.label}),e.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:f.value})]},f.label))}),e.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[e.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:"Last Assistant Message"}),e.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:"Input",value:l.tokenBreakdown.input,format:"count"},{label:"Output",value:l.tokenBreakdown.output,format:"count"},{label:"Reasoning",value:l.tokenBreakdown.reasoning,format:"count"},{label:"Cache Read",value:l.tokenBreakdown.cacheRead,format:"count"},{label:"Cache Write",value:l.tokenBreakdown.cacheWrite,format:"count"},{label:"Cache Hit",value:l.cacheHitRate.hasInput?l.cacheHitRate.percent:null,format:"percent"}].map(f=>e.jsxs("div",{children:[e.jsx("div",{className:"typography-micro text-muted-foreground/70",children:f.label}),e.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:f.value!==null&&f.value!==void 0?f.format==="percent"?`${f.value.toFixed(1)}%`:Le(f.value):"—"})]},f.label))})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:N.map(f=>f.value<=0||l.breakdownTotal<=0?null:e.jsx("div",{style:{width:`${f.value/l.breakdownTotal*100}%`,backgroundColor:f.color}},f.key))}),e.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:N.map(f=>{const T=l.breakdownTotal>0?f.value/l.breakdownTotal*100:0;return e.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:f.color}}),e.jsxs("span",{className:"typography-micro text-muted-foreground/70",children:[f.label," ",e.jsxs("span",{className:"tabular-nums",children:[T.toFixed(0),"%"]})]})]},f.key)})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"typography-micro text-muted-foreground",children:"Raw Messages"}),e.jsx("div",{className:"mt-2.5 space-y-1",children:[...g].reverse().map(f=>{const p=qe(f.info).role,S=p==="assistant",k=p==="user",O=n[f.info.id]===!0,oe=i===f.info.id,z=f.info.time?.created??null,G=Po(f.parts),Q=S?ht({info:f.info,parts:f.parts}):null,y=k?Eo(f.parts):"",b=Ao(z,t),X=G||"—",q=Q?To(Q.input,Q.output,Le):"",K=p||"unknown",Y=G?`${K}: ${G}`:K,ee=O?JSON.stringify({info:f.info,parts:f.parts},null,2):"";return e.jsxs("div",{className:"overflow-hidden rounded-lg bg-[var(--surface-elevated)]/70",children:[e.jsx("button",{type:"button",className:"w-full cursor-pointer px-3 py-1.5 text-left hover:bg-[var(--interactive-hover)]","aria-expanded":O,onClick:()=>{o(E=>({...E,[f.info.id]:E[f.info.id]!==!0}))},children:e.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:S?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[k?e.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[e.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",y]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:S?X:Y}),S&&e.jsx("span",{className:"text-right text-muted-foreground tabular-nums",children:q})]}),e.jsx("span",{className:"text-right text-muted-foreground",children:b})]})}),O&&e.jsx("div",{className:"border-t border-[var(--surface-subtle)] p-0",children:e.jsxs("div",{className:"group relative max-h-[26rem] w-full overflow-auto bg-[var(--surface-background)]",children:[e.jsx("div",{className:"absolute top-1 right-2 z-10 opacity-0 transition-opacity group-hover:opacity-100",children:e.jsx("button",{type:"button",className:"rounded p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",onClick:E=>{E.stopPropagation(),u(f.info.id,ee)},"aria-label":oe?"Copied":"Copy JSON",title:oe?"Copied":"Copy",children:oe?e.jsx(V,{name:"check",className:"size-3.5"}):e.jsx(V,{name:"file-copy",className:"size-3.5"})})}),e.jsx(Gr,{language:"json",code:ee,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},f.info.id)})})]})]})})},Uo=_e(()=>Ee(()=>import("./DiffView-Cay8VAqL.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,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51])).then(t=>({default:t.DiffView}))),Ho=_e(()=>Ee(()=>import("./FilesView-CEeQzjc6.js"),__vite__mapDeps([52,1,2,3,4,5,6,7,8,9,10,11,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,49,50,32,33,17,18,19,20,21,22,23,24,25,26,27,28,29,30,69,70,44,45,46,47,48,71,72,14,15,16,31,34,35,36,37,38,39,40,73,74,75,76])).then(t=>({default:t.FilesView}))),Vo=_e(()=>Ee(()=>import("./GitView-DV3d0oSJ.js"),__vite__mapDeps([77,10,1,2,3,9,4,5,6,7,8,11,44,45,46,47,48,12,78,79,80,81,43,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,13,41,42,49,50])).then(t=>({default:t.GitView}))),Ko=_e(()=>Ee(()=>import("./PullRequestsSurface-Dec20SIg.js"),__vite__mapDeps([82,10,1,2,3,83,4,5,6,7,8,9,11,44,45,46,47,48,84,78,79,43,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,13,41,42,49,50])).then(t=>({default:t.PullRequestsSurface}))),Xo=_e(()=>Ee(()=>import("./IssuesSurface-OTyt9f3A.js"),__vite__mapDeps([85,1,2,3,83,4,5,6,7,8,9,10,11,44,45,46,47,48,84,78,79,86])).then(t=>({default:t.IssuesSurface}))),qo=380,Go=1400,zn=600,Yo=100,Jo=24,rn=t=>Number.isFinite(t)?Math.min(Go,Math.max(qo,Math.round(t))):zn,Qo=t=>{const n=t?.parentElement?.clientWidth;return!n||n<=0?null:n},Zo=(t,n)=>{if(!t)return"";const o=t.replace(/\\/g,"/"),i=n.replace(/\\/g,"/").replace(/\/+$/,"");return i&&o.startsWith(i+"/")?o.slice(i.length+1):o},wt=(t,n=null)=>t==="file"?"Files":t==="diff"?"Changes":t==="preview"?"Preview":t==="browser"?"Browser":t==="git"?Pt(n).label:t==="terminal"?"Terminal":t==="pull-requests"?"Pull requests":t==="issues"?"Issues":t==="extensions"?"Extensions":"Context",ea=t=>{if(!t)return null;const n=t.replace(/\\/g,"/").trim();if(!n)return null;const o=n.split("/").filter(Boolean);return o.length===0?n:o[o.length-1]||null},ta=(t,n=null)=>{if(t.label)return t.label;if(t.mode==="file")return ea(t.targetPath)||"Files";if(t.mode==="preview"){const o=t.targetPath;if(o)try{const i=new URL(o);return i.host||i.hostname||"Preview"}catch{}return"Preview"}return t.mode==="diff"?"Changes":wt(t.mode,n)},ft=(t,n=null)=>{if(t.mode==="file")return t.targetPath?e.jsx(yt,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return e.jsx(Nr,{className:"h-3.5 w-3.5"});if(t.mode==="git")return e.jsx(V,{name:Pt(n).icon,className:"h-3.5 w-3.5"});if(t.mode==="terminal")return e.jsx(V,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="context")return e.jsx(V,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="preview")return e.jsx(V,{name:"global",className:"h-3.5 w-3.5 text-[var(--status-info)]"});if(t.mode==="browser")return e.jsx(V,{name:"global",className:"h-3.5 w-3.5"});if(t.mode==="pull-requests")return e.jsx(V,{name:"git-pull-request",className:"h-3.5 w-3.5"});if(t.mode==="issues")return e.jsx(V,{name:"task",className:"h-3.5 w-3.5"});if(t.mode==="extensions")return e.jsx(V,{name:"plug-2",className:"h-3.5 w-3.5"})},na=(t,n)=>t.length<=n?t:`${t.slice(0,n-3)}...`,ra=()=>{const t=Je()??"",n=r.useMemo(()=>Te(t),[t]),o=ne(C=>n?C.contextPanelByDirectory[n]:void 0),i=ne(C=>C.closeContextPanel),a=ne(C=>C.closeContextPanelTab),m=ne(C=>C.openContextPanelTab),x=ne(C=>C.toggleContextPanelExpanded),c=ne(C=>C.setContextPanelWidth),h=ne(C=>C.setActiveContextPanelTab),g=ne(C=>C.reorderContextPanelTabs),v=Ae(C=>C.setSelectedPath),u=ne(C=>C.openContextPreview),l=ne(C=>C.contextEditorTreeVisible),N=ne(C=>C.toggleContextEditorTree),f=Ce(C=>C.currentSessionId),T=r.useMemo(()=>o?.tabs??[],[o?.tabs]),p=T.find(C=>C.id===o?.activeTabId)??T[T.length-1]??null,S=!!(o?.isOpen&&p),k=!!(S&&o?.expanded),[O,oe]=r.useState(null),z=o?.width,G=Zr,Q=O??(typeof window<"u"?window.innerWidth:zn*2),y=rn(z??Math.round(G*Q)),b=Cn(n||null),[X,q]=r.useState(!1),[K,Y]=r.useState(null),[ee,E]=r.useState(null),[Z,j]=r.useState(null),[W,re]=r.useState(null),$=r.useRef(0),F=r.useRef(y),ie=r.useRef(null),ce=r.useRef(null),he=r.useRef(null),ge=r.useRef(!1);r.useLayoutEffect(()=>{const C=he.current?.parentElement;if(!C||typeof ResizeObserver>"u")return;const Se=new ResizeObserver(()=>{oe(C.clientWidth||null)});return Se.observe(C),oe(C.clientWidth||null),()=>Se.disconnect()},[]),r.useEffect(()=>{if(!S||ge.current){ge.current=S;return}const C=window.requestAnimationFrame(()=>{he.current?.focus({preventScroll:!0})});return ge.current=!0,()=>window.cancelAnimationFrame(C)},[S]);const pe=r.useRef(null),de=r.useRef(null),ue=r.useCallback(()=>{de.current=null;const C=he.current,Se=ie.current;!C||Se===null||C.style.setProperty("--oc-context-panel-width",`${Se}px`)},[]);r.useEffect(()=>()=>{de.current!==null&&clearTimeout(de.current)},[]);const M=r.useCallback(C=>{const Se=rn(C),Me=pe.current;return Me===null?Se:Math.min(Se,Math.max(1,Me))},[]),B=r.useCallback(C=>{!S||k||!n||(ce.current=C.pointerId,q(!0),$.current=C.clientX,F.current=y,ie.current=y,pe.current=Qo(he.current),document.documentElement.style.cursor="col-resize",C.preventDefault())},[n,k,S,y]),U=r.useCallback(()=>{const C=M(ie.current??y);ie.current=null,pe.current=null,de.current!==null&&(clearTimeout(de.current),de.current=null),document.documentElement.style.cursor="",n&&c(n,C),q(!1),ce.current=null},[M,n,c,y]);r.useEffect(()=>{if(!X)return;const C=Ie=>{if(ce.current!==Ie.pointerId)return;const Hn=$.current-Ie.clientX,Dt=M(F.current+Hn);ie.current!==Dt&&(ie.current=Dt,de.current===null&&(de.current=setTimeout(ue,Yo)))},Se=Ie=>{ce.current===Ie.pointerId&&U()},Me=()=>{U()};return window.addEventListener("pointermove",C),window.addEventListener("pointerup",Se),window.addEventListener("pointercancel",Se),window.addEventListener("blur",Me),()=>{window.removeEventListener("pointermove",C),window.removeEventListener("pointerup",Se),window.removeEventListener("pointercancel",Se),window.removeEventListener("blur",Me)}},[ue,M,U,X]),r.useEffect(()=>{X||(ie.current=null,document.documentElement.style.cursor="")},[X]);const J=r.useCallback(()=>{n&&i(n)},[i,n]),ae=r.useCallback(()=>{n&&x(n)},[n,x]),xe=r.useCallback(C=>{C.key==="Escape"&&(Jr(C.target)||(C.preventDefault(),C.stopPropagation(),J()))},[J]);r.useEffect(()=>{if(!(!n||!p)&&p.mode==="file"&&p.targetPath){v(n,p.targetPath,{allowOutsideRoot:!0});return}},[p,n,v]);const ve=r.useCallback(C=>{!n||p?.mode!=="diff"||m(n,{mode:"diff",targetPath:p.targetPath,stagedDiff:C==="staged",diffScope:C})},[p,n,m]),ye=p?.mode==="file"||p?.mode==="preview",P=r.useMemo(()=>p?T.filter(C=>C.mode===p.mode):[],[p,T]),se=r.useMemo(()=>P.map(C=>{const Se=ta(C,b),Me=na(Se,Jo),Ie=Zo(C.targetPath,t);return{id:C.id,label:Me,icon:ft(C,b),title:Ie?`${Se}: ${Ie}`:Se,closeLabel:`Close ${Me} tab`}}),[P,t,b]),fe=p?.mode==="pull-requests",R=p?.mode==="issues",w=p?.mode==="context"?e.jsx(zo,{}):p?.mode==="extensions"?e.jsx(Qr,{sessionId:f}):p?.mode==="git"?e.jsx(r.Suspense,{fallback:null,children:e.jsx(Vo,{isActive:S,gitHeaderSlot:p?.mode==="git"?ee:null})}):p?.mode==="pull-requests"?e.jsx(r.Suspense,{fallback:null,children:e.jsx(Ko,{headerActionsSlot:fe?W:null,headerActionsPresentation:"desktop"},`pull-requests:${n}`)}):p?.mode==="issues"?e.jsx(r.Suspense,{fallback:null,children:e.jsx(Xo,{headerActionsSlot:R?W:null,headerActionsPresentation:"desktop"},`issues:${n}`)}):p?.mode==="preview"?e.jsx(jo,{rawUrl:p.targetPath??"",onNavigate:C=>u(t,C)}):e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[e.jsx(V,{name:"global",className:"h-12 w-12 text-muted-foreground/50"}),e.jsx("div",{className:"typography-ui-header text-foreground",children:"Preview"}),e.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:"Use Project Actions or a terminal Preview button to open a preview."})]}),_=r.useMemo(()=>T.filter(C=>C.mode==="browser"),[T]),L=r.useMemo(()=>T.filter(C=>C.mode==="diff"),[T]),A=r.useMemo(()=>T.some(C=>C.mode==="terminal"),[T]),s=r.useMemo(()=>T.some(C=>C.mode==="file"),[T]),d=r.useMemo(()=>T.some(C=>C.mode==="file"&&C.targetPath),[T]),D=p?.mode==="file",I=p?.mode==="terminal",H=p?.mode==="git",te=p?.mode==="diff",we=e.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[ye?e.jsx($s,{items:se,activeId:p?.id??null,onSelect:C=>{n&&h(n,C)},onClose:C=>{n&&a(n,C)},onReorder:(C,Se)=>{n&&g(n,C,Se)},layoutMode:"scrollable",variant:"default"}):I?e.jsx("div",{ref:C=>{Y(C)},className:"flex min-w-0 flex-1 items-center px-1"}):H?e.jsx("div",{ref:C=>{E(C)},className:"flex min-w-0 flex-1 items-center overflow-hidden px-1"}):te?e.jsx("div",{ref:C=>{j(C)},className:"flex min-w-0 flex-1 items-center overflow-hidden px-1"}):fe||R?e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[p?ft(p,b):null,e.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:p?wt(p.mode,b):null}),e.jsx("span",{className:"min-w-0 flex-1"}),e.jsx("div",{ref:C=>{re(C)},className:"flex shrink-0 items-center gap-1"})]}):e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[p?ft(p,b):null,e.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:p?wt(p.mode,b):null})]}),e.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[D?e.jsx(me,{type:"button",variant:"ghost",size:"sm",onClick:N,className:"h-8 w-8 p-0",title:"Toggle file tree","aria-label":"Toggle file tree","aria-pressed":l,children:e.jsx(V,{name:"layout-right",className:"size-4"})}):null,e.jsx(me,{type:"button",variant:"ghost",size:"sm",onClick:ae,className:"h-8 w-8 p-0",title:k?"Collapse panel":"Expand panel","aria-label":k?"Collapse panel":"Expand panel",children:k?e.jsx(V,{name:"fullscreen-exit",className:"size-4"}):e.jsx(V,{name:"fullscreen",className:"size-4"})}),e.jsx(me,{type:"button",variant:"ghost",size:"sm",onClick:J,className:"h-8 w-8 p-0",title:"Close panel","aria-label":"Close panel",children:e.jsx(V,{name:"close",className:"size-4"})})]})]}),be=S?k?{"--oc-context-panel-width":O!==null?`${O}px`:"100%",width:O!==null?`${O}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${y}px`}:{"--oc-context-panel-width":`${y}px`,width:0,maxWidth:"100%",overflowX:"clip"};return e.jsxs("aside",{ref:he,"data-context-panel":"true",tabIndex:-1,inert:!S||void 0,className:le("flex min-h-0 flex-col overflow-hidden bg-background",k?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!S&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:xe,style:be,children:[S&&!k&&e.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),S&&e.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!k&&e.jsx("div",{className:le("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",X&&"bg-[var(--interactive-border)]"),onPointerDown:B,role:"separator","aria-orientation":"vertical","aria-label":"Resize context panel"}),e.jsxs("div",{className:le("relative z-10 flex h-full min-h-0 shrink-0 flex-col duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none","transition-[width,opacity]",!S&&"pointer-events-none select-none opacity-0"),style:{width:k?O!==null?`${O}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!S,children:[we,e.jsxs("div",{className:le("relative min-h-0 flex-1 overflow-hidden",X&&"pointer-events-none"),children:[s?e.jsxs("div",{className:le("absolute inset-0 flex",D?"flex":"hidden"),children:[e.jsx("div",{className:"h-full min-w-0 flex-1",children:d?e.jsx(r.Suspense,{fallback:null,children:e.jsx(Ho,{mode:"editor-only",isVisible:S&&D})}):e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[e.jsx(V,{name:"file-code",className:"h-12 w-12 text-muted-foreground/50"}),e.jsx("div",{className:"typography-ui-header text-foreground",children:"No file open"}),e.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:"Pick a file from the tree to start editing."})]})}),e.jsx(yo,{visible:l})]}):null,_.map(C=>e.jsx("div",{className:le("absolute inset-0",p?.id!==C.id&&"hidden"),children:e.jsx(lo,{initialUrl:C.targetPath??"",directory:n,tabID:C.id})},C.id)),S?L.filter(C=>p?.id===C.id).map(C=>e.jsx("div",{className:"absolute inset-0",children:e.jsx(r.Suspense,{fallback:null,children:e.jsx(Uo,{hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:C.diffScope??(C.stagedDiff?"staged":"working"),onDiffScopeChange:ve,targetFilePath:C.targetPath,flushContent:!0,toolbarSlot:te?Z:null})})},C.id)):null,A?e.jsx("div",{className:le("absolute inset-0",p?.mode==="terminal"?"block":"hidden"),children:e.jsx(bn,{visible:S&&p?.mode==="terminal",terminalHeaderSlot:I?K:null})}):null,S&&!D&&p?.mode!=="browser"&&p?.mode!=="diff"&&p?.mode!=="terminal"?w:null]})]})]})},sa=150,oa=500,aa=[],Oe=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t),Ze=(t,n)=>{if(!t||typeof t!="object")return;const o=t[n];return typeof o=="number"&&Number.isFinite(o)?o:void 0},ia=t=>t>99?"99+":String(t),la=t=>t>=90?"text-[var(--status-error)]":t>=75?"text-[var(--status-warning)]":"text-[var(--status-success)]",ca=({surface:t,isActive:n,showActivityDot:o,label:i,description:a,badgeCount:m,badgeAriaLabel:x,badgeDescription:c,orderNumber:h,showOrderNumber:g,onSelect:v,chartPercentage:u,chartDetails:l})=>{const{attributes:N,listeners:f,setNodeRef:T,transform:p,transition:S,isDragging:k}=dn({id:t.id}),O=m!=null&&m>0?ia(m):null;return e.jsx("div",{ref:T,style:{transform:un.Translate.toString(p),transition:S},className:le("relative",k&&"z-10 opacity-70"),children:e.jsxs(We,{delayDuration:sa,children:[e.jsx(Fe,{asChild:!0,children:e.jsxs("button",{type:"button",...N,...f,onClick:()=>v(t),"aria-label":x??i,"aria-pressed":n,className:le("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",n?"text-primary":"text-muted-foreground hover:text-foreground"),children:[t.id==="context"&&typeof u=="number"?e.jsx(Ut,{percentage:u,className:"size-[18px] -rotate-90"}):e.jsx(V,{name:t.icon,className:"h-[18px] w-[18px]"}),g&&h!=null?e.jsx("span",{"aria-hidden":"true",className:"absolute right-0 top-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-surface-muted px-1 text-[0.625rem] font-medium leading-none text-muted-foreground",children:h===10?"0":h}):O?e.jsx("span",{"aria-hidden":"true",className:"absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[0.625rem] font-semibold leading-none",style:{backgroundColor:"var(--status-info-background)",color:"var(--status-info)"},children:O}):o?e.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null]})}),e.jsx(Be,{side:"left",sideOffset:8,className:t.id==="context"&&l?"p-0 border-0 bg-transparent shadow-none":void 0,children:t.id==="context"&&l?e.jsx("div",{className:"w-[300px] overflow-hidden rounded-lg border border-border/70 bg-[var(--surface-elevated)] p-2 shadow-[0_8px_24px_rgb(0_0_0_/_0.18)]",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5",children:[e.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:e.jsx(Ut,{percentage:l.percentage,className:"size-[18px] -rotate-90"})}),e.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:i}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground",children:l.hasData?e.jsxs("span",{className:"inline-flex items-baseline gap-1.5 tabular-nums",children:[e.jsxs("span",{className:le("font-semibold",la(l.percentage)),children:[l.percentage.toFixed(1),"%"]}),e.jsx("span",{className:"text-muted-foreground",children:`${Oe(l.totalTokens)}/${Oe(l.contextLimit)}`})]}):e.jsx("span",{className:"typography-micro text-muted-foreground",children:"No data yet"})})]}),l.hasData?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Used tokens"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:Oe(l.totalTokens)})]}),e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Context limit"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:Oe(l.contextLimit)})]}),e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Output limit"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:Oe(l.outputLimit)})]}),typeof l.cacheRead=="number"&&typeof l.cacheWrite=="number"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Cache read"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:Oe(l.cacheRead)})]}),e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Cache write"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:Oe(l.cacheWrite)})]})]}):null,typeof l.cacheHitPercent=="number"?e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Cache hit"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:`${l.cacheHitPercent.toFixed(1)}%`})]}):null]}):e.jsx("div",{className:"px-2.5 py-2 typography-micro text-muted-foreground",children:a})]})}):e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{children:i}),e.jsx("span",{className:"typography-micro text-muted-foreground",children:a}),c?e.jsx("span",{className:"typography-micro text-muted-foreground",children:c}):null]})})]})})},da=()=>{const t=Je(),n=t?or(t):"",o=ne(w=>n?w.contextPanelByDirectory[n]:void 0),i=ne(w=>w.contextRailOrder),a=ne(w=>w.setContextRailOrder),m=ne(w=>w.openContextSurface),x=ne(w=>w.shortcutOverrides),{screenWidth:c}=at(),{git:h,github:g}=vt(),v=Sn(n||null),u=Cn(n||null),l=Nn(w=>w.ensureStatus),N=zt(w=>w.ensureScope);r.useEffect(()=>{n&&l(n,h)},[n,l,h]),r.useEffect(()=>{!n||!g||N(n,g)},[n,N,g]);const f=r.useMemo(()=>ar("switch_context_surface",x),[x]),[T,p]=r.useState(!1);r.useEffect(()=>{const w=new Set;let _=null,L=!1;const A=H=>H.length===1&&H>="0"&&H<="9",s=()=>{Lt(f,w)?!L&&_===null&&(_=setTimeout(()=>p(!0),oa)):(L=!1,_!==null&&(clearTimeout(_),_=null),p(!1))},d=H=>{if(w.add(H.key.toLowerCase()),A(H.key)&&Lt(f,w)){L=!0,_!==null&&(clearTimeout(_),_=null),p(!1);return}s()},D=H=>{w.delete(H.key.toLowerCase()),s()},I=()=>{w.clear(),L=!1,_!==null&&(clearTimeout(_),_=null),p(!1)};return window.addEventListener("keydown",d,!0),window.addEventListener("keyup",D,!0),window.addEventListener("blur",I),()=>{window.removeEventListener("keydown",d,!0),window.removeEventListener("keyup",D,!0),window.removeEventListener("blur",I),_!==null&&clearTimeout(_)}},[f]);const S=on(mt(Gn,{activationConstraint:{distance:8}}),mt(qn,{activationConstraint:{delay:200,tolerance:6}})),k=o?.tabs??aa,O=k.find(w=>w.id===o?.activeTabId)??null,oe=o?.isOpen?O?.mode??null:null,z=v?.files.length??0,G=Ce(w=>w.currentSessionId),Q=Ce(w=>!!w.newSessionDraft?.open),y=$e(w=>w.providers),b=$e(w=>w.currentProviderId),X=$e(w=>w.currentModelId),q=$e(w=>w.getCurrentModel()),K=$e(w=>w.getModelMetadata);$e(w=>w.modelsMetadata.size);const Y=es(r.useCallback(w=>G?w.sessionModelSelections.get(G)??null:null,[G])),ee=jn(G??""),E=r.useMemo(()=>{for(let w=ee.length-1;w>=0;w-=1){const _=ee[w];if(_?.info.role==="assistant")try{if(gt(_).total>0)return _}catch{continue}}return null},[ee]),j=r.useMemo(()=>{for(let w=ee.length-1;w>=0;w-=1){const _=ee[w]?.info;if(_.role!=="user")continue;const L=_.model,A=L?.providerID??L?.providerId,s=L?.modelID??L?.modelId;if(typeof A=="string"&&A.trim()&&typeof s=="string"&&s.trim())return{providerID:A,modelID:s}}return null},[ee])??(()=>{const w=E?.info.model,_=w?.providerID??w?.providerId,L=w?.modelID??w?.modelId;return _&&L?{providerID:_,modelID:L}:null})()??(Y?{providerID:Y.providerId,modelID:Y.modelId}:null)??(b&&X?{providerID:b,modelID:X}:null),re=(j?y.find(w=>w.id===j.providerID):void 0)?.models.find(w=>w.id===j?.modelID),$=j?K(j.providerID,j.modelID):void 0,F=Ze(re?.limit,"context")??$?.limit?.context??Ze(q?.limit,"context")??0,ie=Ze(re?.limit,"output")??$?.limit?.output??Ze(q?.limit,"output")??0,ce=E?(()=>{try{return gt(E)}catch{return null}})():null,he=E?.info?.usage,ge=he?yn(he):ce?.total??0,pe=!Q&&ge>0&&F>0?Math.min(ge/F*100,999):0,de=pe,ue=ce?wn({input:ce.input,cache:{read:ce.cacheRead,write:ce.cacheWrite}}):null,M=ue?.hasInput?ue.percent:null,B=r.useMemo(()=>{const w=!!E&&ge>0&&F>0;return{percentage:pe,totalTokens:ge,contextLimit:F,outputLimit:ie,cacheRead:ce?.cacheRead??null,cacheWrite:ce?.cacheWrite??null,cacheHitPercent:M,hasData:w}},[ce,M,F,E,ie,pe,ge]),U=ts(w=>G?w.reducer.bySession.get(G)?.extensionWidgets:void 0,(w,_)=>w===_,G?`session:${G}`:"chrome"),J=r.useMemo(()=>U?.size?[...U.entries()].map(([w,_])=>`${w}:${_.lines.join(`
|
|
136
|
-
`)}`).join(";"):"",[U]),ae=J!=="",xe=r.useRef({});r.useEffect(()=>{oe==="extensions"&&G&&J&&(xe.current[G]=J)},[oe,G,J]);const ve=G?xe.current[G]??"":"",ye=oe!=="extensions"&&J!==""&&ve!==J,P=zt(w=>n?w.entriesByDirectory[n]??null:null),se=r.useMemo(()=>{if(!P)return{isLoading:!0,hasResult:!1,hasGitHubRepo:!1,hasError:!1};const w=P.scope?.repositories??[];return{isLoading:P.isLoading,hasResult:!!(P.scope||P.error),hasGitHubRepo:w.some(_=>!!(_.host&&_.owner&&_.repo&&!_.disabledReason)),hasError:!!(P.error&&!P.scope)}},[P]),fe=r.useMemo(()=>ns({railOrder:i,tabs:k,githubScope:se,hasExtensionContent:ae}),[i,c,k,se,ae]),R=r.useCallback(w=>{const{active:_,over:L}=w;if(!L||_.id===L.id)return;const A=rs(ne.getState().contextRailOrder).map(D=>D.id),s=A.indexOf(_.id),d=A.indexOf(L.id);s===-1||d===-1||a(Yn(A,s,d))},[a]);return n?e.jsx("nav",{"aria-label":"Panel surfaces",className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:e.jsx(an,{sensors:S,collisionDetection:ln,onDragEnd:R,children:e.jsx(cn,{items:fe.map(w=>w.id),strategy:Jn,children:fe.map((w,_)=>{const L=w.id==="git"?Pt(u):null,A=L?{...w,...L}:w,s=A.label,d=w.id==="git"&&u===!0?z:0,D=d>0?d:null,I=w.id==="context",H=w.id==="extensions"?ye:!1;return e.jsx(ca,{surface:A,isActive:oe===w.mode,showActivityDot:H,label:s,description:A.description,badgeCount:D,badgeAriaLabel:D!==null?D===1?`${s}, ${D} changed file`:`${s}, ${D} changed files`:null,badgeDescription:D!==null?D===1?`${D} changed file`:`${D} changed files`:null,chartPercentage:I?de:void 0,chartDetails:I?B:void 0,orderNumber:_+1,showOrderNumber:T,onSelect:te=>m(n,te.mode)},w.id)})})})}):null},ua=(t,n)=>!t||n.length===0?"":JSON.stringify([t,n]),ha=(t,n,o,i)=>!o||i!==o||t.length===0?[]:Xe(t,n,a=>a.name,{limit:10,threshold:.4}),fa=new Set,pt=t=>{if(!t)return"";const n=t.replace(/\\/g,"/"),o=n.startsWith("//");let i=n.replace(/\/+/g,"/");o&&!i.startsWith("//")&&(i=`/${i}`);const a=i==="/",m=/^[A-Za-z]:\/$/.test(i);return!a&&!m&&(i=i.replace(/\/+$/,"")),i},pa=()=>{const t=ne(s=>s.isCommandPaletteOpen),n=ne(s=>s.setCommandPaletteOpen),o=ne(s=>s.setActiveMainTab),i=ne(s=>s.setSettingsDialogOpen),a=ne(s=>s.setSettingsPage),m=ne(s=>s.setSessionSwitcherOpen),x=ne(s=>s.toggleSidebar),c=ne(s=>s.openContextOverview),h=ne(s=>s.openContextSurface),g=ne(s=>s.openContextFile),v=ne(s=>s.shortcutOverrides),u=Ce(s=>s.openNewSessionDraft),l=Ce(s=>s.setCurrentSession),N=ss({archived:!1}),f=os(r.useCallback(s=>t?s.ids:fa,[t])),T=as(r.useCallback(s=>t?s.rankById:is,[t])),p=ir(s=>s.currentDirectory),S=Ht(s=>s.getActiveProject()),k=Ht(s=>s.projects),O=Je(),oe=lr(s=>s.searchFiles),{files:z,git:G}=vt(),Q=Nn(s=>s.ensureStatus),{isMobile:y}=at(),b=r.useMemo(()=>O?pt(O):null,[O]),[X,q]=r.useState(""),Y=ls(X,200).trim(),ee=X.trim();r.useEffect(()=>{t&&q("")},[t]),r.useEffect(()=>{if(!t||!G)return;const s=setTimeout(()=>{const d=new Set;for(const D of N){const I=lt(D);!I||d.has(I)||(d.add(I),Q(I,G))}},0);return()=>clearTimeout(s)},[t,N,G,Q]);const E=r.useCallback(()=>n(!1),[n]),Z=r.useCallback(s=>()=>{E(),s()},[E]),j=r.useMemo(()=>{const s=[{id:"new-session",title:"New Session",icon:e.jsx(V,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:"New Session",onSelect:Z(()=>{o("chat"),m(!1),u()})},{id:"add-project",title:"Add Project",icon:e.jsx(V,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:"Add Project",onSelect:Z(()=>{cs.requestDirectoryDialog()})},{id:"toggle-sidebar",title:y?"Show Session Switcher":"Toggle Sidebar",icon:e.jsx(V,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:y?"Show Session Switcher":"Toggle Sidebar",onSelect:Z(()=>{if(y){const{isSessionSwitcherOpen:d}=ne.getState();m(!d)}else x()})},{id:"toggle-terminal",title:"Toggle Terminal",icon:e.jsx(V,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:"Toggle Terminal",onSelect:Z(()=>{p&&h(p,"terminal")})},{id:"context-usage",title:"Show Context Usage",icon:e.jsx(V,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:"Show Context Usage",onSelect:Z(()=>{p&&c(p)})},{id:"open-settings",title:"Open Settings...",icon:e.jsx(V,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:"Open Settings...",onSelect:Z(()=>i(!0))}];return cr()&&s.splice(1,0,{id:"new-mini-chat",title:"New Mini Chat Window",icon:e.jsx(V,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:"New Mini Chat Window",onSelect:Z(()=>{hn("desktop_open_draft_mini_chat_window",{directory:pt(p||S?.path||""),projectId:S?.id??null}).catch(d=>{console.warn("[command-palette] failed to open draft mini chat window",d)})})}),s},[Z,y,o,m,u,x,h,p,c,i,S?.id,S?.path]),W=r.useMemo(()=>{const s=dr();return{isWeb:!s&&ur(),isDesktop:s,isMobile:y}},[y]),re=r.useMemo(()=>kr.filter(s=>s.slug!=="home").filter(s=>s.isAvailable?s.isAvailable(W):!0).map(s=>{const d=Pr(s.slug)??"settings-3",D=(s.keywords??[]).join(" ");return{id:`settings:${s.slug}`,title:s.title,icon:e.jsx(V,{name:d,className:"mr-2 h-4 w-4"}),searchText:`${s.title} ${s.group} ${D}`,onSelect:Z(()=>{a(s.slug),i(!0)})}}),[W,Z,a,i]),$=r.useMemo(()=>ds(N,f,T),[N,f,T]),F=us(),ie=r.useCallback((s,d)=>d&&F.get(d)?.trim()||null,[F]),[ce,he]=r.useState([]),[ge,pe]=r.useState(""),de=ua(b,Y);r.useEffect(()=>{if(!t){he([]),pe("");return}if(!de){he([]),pe("");return}if(!b){he([]),pe("");return}let s=!1;return oe(b,Y,10,{type:"file"}).then(d=>{s||(he(d.map(D=>({path:pt(D.path),name:D.name,relativePath:D.relativePath}))),pe(de))}).catch(()=>{s||(he([]),pe(de))}),()=>{s=!0}},[t,b,Y,de,oe]);const ue=ee.length>0,M=r.useMemo(()=>ue?Xe(j,ee,s=>s.searchText,{limit:7,noFuzzy:!0}):j.map(s=>({item:s,score:0})),[j,ee,ue]),B=r.useMemo(()=>ue?Xe(re,ee,s=>s.searchText,{limit:7,noFuzzy:!0}):[],[re,ee,ue]),U=r.useMemo(()=>ue?Xe($,ee,s=>s.title||"",{limit:7,threshold:.2}):$.slice(0,5).map(s=>({item:s,score:0})),[$,ee,ue]),J=r.useMemo(()=>t?ha(ce,Y,de,ge):[],[t,ce,ge,de,Y]),ae=t&&de.length>0&&ge!==de,xe=r.useMemo(()=>{if(!ue)return[];const s=k.map(d=>({...d,displayName:d.label||d.path.split("/").pop()||d.path,searchText:`${d.label||""} ${d.path}`}));return Xe(s,ee,d=>d.searchText,{limit:7,threshold:.4})},[k,ee,ue]),ve=M.map(s=>s.item),ye=B.map(s=>s.item),P=U.map(s=>s.item),se=ue?J.map(s=>s.item):[],fe=ue?xe.map(s=>s.item):[],R=r.useMemo(()=>{if(!ue)return["commands","sessions"];const s=D=>D.length?D[0].score:1/0,d=[{key:"commands",score:s(M)},{key:"settings",score:s(B)},{key:"sessions",score:s(U)},{key:"files",score:s(J)},{key:"projects",score:s(xe)}];return d.sort((D,I)=>D.score-I.score),d.map(D=>D.key)},[ue,M,B,U,J,xe]),w=r.useCallback(s=>{E(),l(s.id,lt(s))},[E,l]),_=r.useCallback(async s=>{if(!b)return;const d=await kn(z,s,{directory:b});if(!d.ok){je.error(Pn(d.reason));return}g(b,s),E()},[b,z,g,E]),L=r.useCallback((s,d)=>{E(),u({selectedProjectId:s,directoryOverride:d})},[E,u]),A=r.useCallback(s=>mn(gn(s,v)),[v]);return e.jsxs(St,{open:t,onOpenChange:n,children:[e.jsxs(Ct,{className:"sr-only",children:[e.jsx(Nt,{children:"Command Palette"}),e.jsx(kt,{children:"Search files, sessions, and commands."})]}),e.jsx(jt,{className:"overflow-hidden p-0",showCloseButton:!0,children:e.jsxs(hs,{shouldFilter:!1,className:"[&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-4 [&_[cmdk-input-wrapper]_svg]:w-4 [&_[cmdk-input]]:h-8 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-1.5 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4 [&_[cmdk-item]]:typography-meta",children:[e.jsx(fs,{value:X,onValueChange:q,placeholder:"Search files, sessions, commands..."}),e.jsxs(ps,{children:[e.jsx(ms,{children:"No results found."}),R.map(s=>s==="commands"&&ve.length>0?e.jsx(Ve,{children:ve.map(d=>e.jsxs(Ke,{value:d.id,onSelect:d.onSelect,children:[d.icon,e.jsx("span",{children:d.title}),d.shortcutId?e.jsx(gs,{children:A(d.shortcutId)}):null]},d.id))},"commands"):s==="settings"&&ye.length>0?e.jsx(Ve,{children:ye.map(d=>e.jsxs(Ke,{value:d.id,onSelect:d.onSelect,children:[d.icon,e.jsx("span",{children:d.title})]},d.id))},"settings"):s==="sessions"&&P.length>0?e.jsx(Ve,{children:P.map(d=>{const D=En(d),I=lt(d),H=ie(d.id,I);return e.jsxs(Ke,{value:`session:${d.id}`,onSelect:()=>w(d),children:[e.jsx(V,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"truncate",children:D}),H?e.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[e.jsx(V,{name:"git-branch",className:"h-3 w-3"}),e.jsx("span",{className:"truncate max-w-[160px]",children:H})]}):null]},d.id)})},"sessions"):s==="files"&&se.length>0?e.jsx(Ve,{children:se.map(d=>{const D=hr(d.relativePath||d.name,{maxLength:80});return e.jsxs(Ke,{value:`file:${d.path}`,onSelect:()=>{_(d.path)},children:[e.jsx(yt,{filePath:d.path,className:"mr-2 size-4 shrink-0"}),e.jsx("span",{className:"truncate","aria-label":d.relativePath,children:D})]},`file:${d.path}`)})},"files"):s==="projects"&&fe.length>0?e.jsx(Ve,{children:fe.map(d=>{const D=d.displayName;return e.jsxs(Ke,{value:`project:${d.id}`,onSelect:()=>L(d.id,d.path),children:[e.jsx(V,{name:"folder",className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"truncate",children:D}),e.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:d.path})]},`project:${d.id}`)})},"projects"):null),ae?e.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:"Searching files..."}):null]})]})})]})},ma=(t,n,o)=>pr(t)?mn(gn(t,o)):n,ga=()=>{const t=ne(m=>m.isHelpDialogOpen),n=ne(m=>m.setHelpDialogOpen),o=ne(m=>m.shortcutOverrides),i=fr(),a=[{categoryKey:"Navigation & Commands",items:[{id:"open_command_palette",descriptionKey:"Open Command Palette",icon:"command",keys:""},{id:"open_help",descriptionKey:"Show Keyboard Shortcuts (this dialog)",icon:"question",keys:""},{id:"toggle_sidebar",descriptionKey:"Toggle Session Sidebar",icon:"layout-left",keys:""},{id:"add_selection_to_chat",descriptionKey:"Add Selection to Chat",icon:"add",keys:""},{id:"open_model_selector",descriptionKey:"Open Model Selector",icon:"ai-generate-2",keys:""},{keys:["↑↓"],descriptionKey:"Navigate Models (in picker)",icon:"ai-generate-2"},{keys:["←→"],descriptionKey:"Adjust Thinking Mode (in picker, when supported)",icon:"brain-ai-3"},{id:"cycle_thinking_variant",descriptionKey:"Cycle thinking (global shortcut)",icon:"brain-ai-3",keys:""},{keys:[`Shift + Alt + ${i} + N`],descriptionKey:"New Window (desktop only)",icon:"window"}]},{categoryKey:"Session Management",items:[{id:"new_chat",descriptionKey:"Create New Session",icon:"add",keys:""},{id:"focus_input",descriptionKey:"Focus Chat Input",icon:"text",keys:""},{id:"cycle_session_folder",descriptionKey:"Cycle session folder",icon:"folder-open",keys:""},{id:"cycle_draft_folder",descriptionKey:"Cycle draft folder",icon:"folder-3",keys:""},{id:"open_timeline_dialog",descriptionKey:"Open conversation timeline",icon:"history",keys:""},{id:"abort_run",descriptionKey:"Abort active run (double press)",icon:"close-circle",keys:""}]},{categoryKey:"Panels",items:[{id:"open_right_sidebar",descriptionKey:"Open right sidebar",icon:"layout-right",keys:""},{id:"toggle_terminal",descriptionKey:"helpDialog.item.toggleTerminalDock",icon:"window",keys:""},{keys:[`${i} + 1...0`],descriptionKey:"Switch Context Panel Surface (number key)",icon:"layout-right"}]},{categoryKey:"Interface",items:[{id:"cycle_theme",descriptionKey:"Cycle Theme (Light → Dark → System)",icon:"palette",keys:""},{id:"toggle_services_menu",descriptionKey:"helpDialog.item.toggleServicesMenu",icon:"stack",keys:""},{id:"open_settings",descriptionKey:"Open Settings",icon:"settings-3",keys:""}]}];return e.jsx(St,{open:t,onOpenChange:n,children:e.jsxs(jt,{className:"w-[92vw] max-w-[1120px] h-[84vh] max-h-[900px] flex flex-col overflow-hidden",children:[e.jsxs(Ct,{children:[e.jsxs(Nt,{className:"flex items-center gap-2",children:[e.jsx(V,{name:"command",className:"h-5 w-5"}),"Keyboard Shortcuts"]}),e.jsx(kt,{children:"Use these keyboard shortcuts to navigate PiChamber efficiently"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto mt-3 pr-1",children:e.jsx("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-2 md:gap-x-10",children:a.map(m=>e.jsxs("div",{className:"min-w-0 break-inside-avoid",children:[e.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:m.categoryKey}),e.jsx("div",{className:"space-y-1",children:m.items.map(x=>{const c=x.id?ma(x.id,Array.isArray(x.keys)?x.keys[0]:x.keys,o):Array.isArray(x.keys)?x.keys:x.keys.split(" / ");return e.jsxs("div",{className:"flex items-center justify-between py-1 px-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[x.icon&&e.jsx(V,{name:x.icon,className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"typography-meta",children:x.descriptionKey})]}),e.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(c)?c:[c]).map((h,g)=>e.jsxs(r.Fragment,{children:[g>0&&e.jsx("span",{className:"typography-meta text-muted-foreground mx-1",children:"or"}),e.jsx("kbd",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 typography-meta font-mono bg-muted rounded border border-border/20",children:h})]},`${h}-${g}`))})]},x.id||x.descriptionKey)})})]},m.categoryKey))})})]})})},xa=r.createContext(null),wa=({children:t,value:n})=>e.jsx(xa.Provider,{value:n,children:t}),sn=_e(()=>Ee(()=>import("./GitView-DV3d0oSJ.js"),__vite__mapDeps([77,10,1,2,3,9,4,5,6,7,8,11,44,45,46,47,48,12,78,79,80,81,43,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,13,41,42,49,50])).then(t=>({default:t.GitView}))),ya=_e(()=>Ee(()=>import("./DiffView-Cay8VAqL.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,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51])).then(t=>({default:t.DiffView}))),ba=_e(()=>Ee(()=>import("./FilesView-CEeQzjc6.js"),__vite__mapDeps([52,1,2,3,4,5,6,7,8,9,10,11,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,49,50,32,33,17,18,19,20,21,22,23,24,25,26,27,28,29,30,69,70,44,45,46,47,48,71,72,14,15,16,31,34,35,36,37,38,39,40,73,74,75,76])).then(t=>({default:t.FilesView}))),va=_e(()=>Ee(()=>import("./DiagramView-GKGxPczP.js"),__vite__mapDeps([87,1,2,3,9,4,5,6,7,8,10,11,69,70])).then(t=>({default:t.DiagramView}))),Sa=_e(()=>Ee(()=>import("./SettingsView-CwSspvq-.js").then(t=>t.a),__vite__mapDeps([88,1,2,3,4,5,6,7,8,9,10,11,44,45,46,47,48,89,90,80,81])).then(t=>({default:t.SettingsView}))),ja=_e(()=>Ee(()=>import("./SettingsWindow-DkPv9MaU.js"),__vite__mapDeps([91,1,2,3,4,5,6,7,8,9,10,11,88,44,45,46,47,48,89,90,80,81])).then(t=>({default:t.SettingsWindow}))),Ca=()=>{const t=ne(j=>j.isSidebarOpen),n=ne(j=>j.activeMainTab),o=ne(j=>j.setIsMobile),i=ne(j=>j.isSessionSwitcherOpen),a=ne(j=>j.isSettingsDialogOpen),m=ne(j=>j.setSettingsDialogOpen),[x,c]=r.useState(!1);r.useEffect(()=>{a&&c(!0)},[a]),r.useEffect(()=>{const j=()=>ne.getState().closeMainSurfaces(),W=Ce.subscribe(($,F)=>{const ie=!!$.currentSessionId&&$.currentSessionId!==F.currentSessionId,ce=!!$.newSessionDraft?.open&&$.newSessionDraft!==F.newSessionDraft;(ie||ce)&&j()}),re=ne.subscribe(($,F)=>{$.activeMainTab!==F.activeMainTab&&j()});return()=>{W(),re()}},[]);const{isMobile:h}=at(),g=r.useRef(!1),[v,u]=r.useState(!1),[l,N]=r.useState(!1),[f,T]=r.useState(!1),[p,S]=r.useState(!1),k=r.useCallback(j=>{u(j),ne.getState().setSessionSwitcherOpen(j)},[]),O=r.useRef(typeof window>"u"?0:window.innerWidth),oe=r.useRef(null),z=r.useRef(!1),G=r.useRef(!1),Q=r.useRef(!1),y=r.useRef(null),b=r.useRef(null),X=Mt(-O.current),q=Ne.useRef(0),K=Mt(O.current),Y=Ne.useRef(0);Ne.useEffect(()=>{h&&(q.current=window.innerWidth,Y.current=window.innerWidth)},[h]),Ne.useEffect(()=>{if(!h)return;const j=()=>{const W=window.innerWidth;q.current=W,Y.current=W,v||X.get()<-10&&X.set(-W),l||K.get()>10&&K.set(W)};return window.addEventListener("resize",j),window.addEventListener("orientationchange",j),()=>{window.removeEventListener("resize",j),window.removeEventListener("orientationchange",j)}},[h,X,K,v,l]),Ne.useEffect(()=>{if(!h){T(!1);return}v&&T(!0);const j=q.current||O.current||(typeof window<"u"?window.innerWidth:0),W=Qe(X,v?0:-j,{type:"spring",stiffness:400,damping:35,mass:.8});return y.current=W,()=>W.stop()},[v,h,X]),Ne.useEffect(()=>{if(!h){S(!1);return}l&&S(!0);const j=Y.current||O.current||(typeof window<"u"?window.innerWidth:0),W=Qe(K,l?0:j,{type:"spring",stiffness:400,damping:35,mass:.8});return b.current=W,()=>W.stop()},[h,l,K]),Ne.useEffect(()=>{if(h)return X.on("change",j=>{const W=q.current||O.current,re=v||j>-W+.5;T($=>$===re?$:re)})},[h,X,v]),Ne.useEffect(()=>{if(h)return K.on("change",j=>{const W=Y.current||O.current,re=l||j<W-.5;S($=>$===re?$:re)})},[h,l,K]),Ne.useEffect(()=>{h&&!i&&v&&k(!1)},[i,h,v,k]),Ne.useEffect(()=>{if(!h){g.current=!1;return}g.current||(g.current=!0,k(!1),N(!1))},[h,k]),Ne.useEffect(()=>{if(!h||n!=="chat"||v||l||a)return;let j=!1,W;return($=>{W=window.setTimeout(()=>{if(j)return;const F=Ce.getState(),ie=ne.getState();ie.activeMainTab!=="chat"||ie.isSettingsDialogOpen||F.currentSessionId||F.newSessionDraft?.open||F.openNewSessionDraft({automatic:!0})},$)})(500),()=>{j=!0,W!==void 0&&window.clearTimeout(W)}},[n,h,a,v,l]),Ne.useEffect(()=>{!h||!a||(k(!1),N(!1))},[h,a,k]),r.useEffect(()=>{ne.getState().isMobile!==h&&o(h)},[h,o]);const ee=r.useCallback(()=>{v&&k(!1),N(!l)},[v,l,k]);Rr(oe,{enabled:h,leftOpen:v,rightOpen:l,leftWidth:()=>q.current||O.current||(typeof window<"u"?window.innerWidth:0),rightWidth:()=>Y.current||O.current||(typeof window<"u"?window.innerWidth:0),onLeftProgress:j=>{const W=q.current||O.current||(typeof window<"u"?window.innerWidth:0);X.set(W*(j-1))},onRightProgress:j=>{const W=Y.current||O.current||(typeof window<"u"?window.innerWidth:0);K.set(W*(1-j))},onLeftOpen:()=>{l&&N(!1),k(!0)},onLeftClose:()=>k(!1),onRightOpen:()=>{v&&k(!1),N(!0)},onRightClose:()=>N(!1),onDragStart:j=>{z.current=!0,j==="left"?(G.current=v,y.current?.stop(),f||T(!0)):(Q.current=l,b.current?.stop(),p||S(!0))},onDragEnd:(j,W)=>{if(z.current=!1,j==="left"&&typeof W=="boolean"){const re=G.current;if(W===re){const $=q.current||O.current||(typeof window<"u"?window.innerWidth:0),F=Qe(X,re?0:-$,{type:"spring",stiffness:400,damping:35,mass:.8});y.current=F}}if(j==="right"&&typeof W=="boolean"){const re=Q.current;if(W===re){const $=Y.current||O.current||(typeof window<"u"?window.innerWidth:0),F=Qe(K,re?0:$,{type:"spring",stiffness:400,damping:35,mass:.8});b.current=F}}}});const E=r.useMemo(()=>{if(!h&&n!=="terminal"&&n!=="diagram"||h&&n==="git"&&(l||p))return null;switch(n){case"git":return e.jsx(r.Suspense,{fallback:null,children:e.jsx(sn,{isActive:!0})});case"diff":return e.jsx(r.Suspense,{fallback:null,children:e.jsx(ya,{})});case"terminal":return e.jsx(bn,{onCloseView:()=>ne.getState().setActiveMainTab("chat")});case"files":return e.jsx(r.Suspense,{fallback:null,children:e.jsx(ba,{})});case"diagram":return e.jsx(r.Suspense,{fallback:null,children:e.jsx(va,{})});default:return null}},[n,h,p,l]),Z=n==="chat";return e.jsxs(Er,{children:[e.jsx(Tr,{}),e.jsxs("div",{"data-page-scroll-lock":"true",className:le("main-content-safe-area",h?"flex h-[100dvh] flex-col":"relative flex h-[100dvh]","bg-background"),children:[e.jsx(pa,{}),e.jsx(ga,{}),e.jsx(_r,{}),h?e.jsxs(wa,{value:{leftDrawerOpen:v,rightDrawerOpen:l,toggleLeftDrawer:()=>{const j=!v;l&&N(!1),k(j)},toggleRightDrawer:ee,leftDrawerX:X,rightDrawerX:K,leftDrawerWidth:q,rightDrawerWidth:Y,setMobileLeftDrawerOpen:k,setRightSidebarOpen:N},children:[!a&&e.jsx(Ot,{onToggleLeftDrawer:()=>{const j=!v;l&&N(!1),k(j)},onToggleRightDrawer:()=>{ee()},leftDrawerOpen:v,rightDrawerOpen:l}),e.jsx("div",{"data-page-scroll-lock":"true",className:le("flex flex-1 overflow-hidden relative",a&&"hidden"),children:e.jsxs("main",{ref:oe,className:"w-full h-full overflow-hidden bg-background relative","data-page-scroll-lock":"true",style:{touchAction:"pan-x pan-y"},children:[e.jsx("div",{className:le("absolute inset-0",!Z&&"invisible"),children:e.jsx(Pe,{children:e.jsx($t,{active:Z&&!a})})}),E&&e.jsx("div",{className:"absolute inset-0",children:e.jsx(Pe,{children:E})}),e.jsx(Pe,{children:e.jsx(Wt,{})}),e.jsx(It.div,{className:le("absolute inset-0 z-20 bg-sidebar",!f&&"pointer-events-none invisible"),"data-page-scroll-lock":"true",style:{x:X},"aria-hidden":!v,children:e.jsx(Pe,{children:e.jsx(Ft,{mobileVariant:!0,isVisible:f})})}),e.jsx(It.div,{className:le("absolute inset-0 z-20 bg-sidebar",!p&&"pointer-events-none invisible"),"data-page-scroll-lock":"true",style:{x:K},"aria-hidden":!l,children:e.jsx(Pe,{children:l||p?e.jsx(r.Suspense,{fallback:null,children:e.jsx(sn,{isActive:l})}):null})})]})}),a&&e.jsx("div",{className:"absolute inset-0 z-10 bg-background",style:{paddingTop:"var(--oc-safe-area-top, 0px)"},children:e.jsx(Pe,{children:e.jsx(r.Suspense,{fallback:null,children:e.jsx(Sa,{onClose:()=>m(!1)})})})})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ar,{}),e.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[e.jsx(Ws,{isOpen:t,isMobile:h,children:e.jsx(Ft,{isVisible:t})}),e.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[e.jsx(Ot,{}),e.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[e.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden border-t border-border bg-background","data-page-scroll-lock":"true",children:e.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true",children:e.jsxs("div",{className:"relative flex flex-1 min-h-0 min-w-0 overflow-hidden","data-page-scroll-lock":"true","data-chat-area":"true",children:[e.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[e.jsx("div",{className:le("absolute inset-0",!Z&&"invisible"),children:e.jsx(Pe,{children:e.jsx($t,{active:Z&&!a})})}),E&&e.jsx("div",{className:"absolute inset-0",children:e.jsx(Pe,{children:E})}),e.jsx(Pe,{children:e.jsx(Wt,{})})]}),e.jsx(ra,{})]})})}),e.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:e.jsx(Pe,{children:e.jsx(da,{})})})]})]})]}),x?e.jsx(r.Suspense,{fallback:null,children:e.jsx(ja,{open:a,onOpenChange:m})}):null]})]})]})},Na=()=>(Ss(),Ir(),e.jsxs(Lr,{children:[e.jsx(js,{embeddedBackgroundWorkEnabled:!0}),e.jsx(Cs,{}),e.jsx(Ca,{}),e.jsx(Or,{}),e.jsx(Ns,{}),e.jsx(ks,{})]}));function ka({apis:t}){const n=t??xn(),[o,i]=r.useState(0);return r.useEffect(()=>mr(a=>{if(a.runtimeKey===a.previousRuntimeKey){gr();return}Dr(a),i(m=>m+1)}),[]),r.useEffect(()=>{let a=!0,m=null,x=null,c=null;return xr().then(()=>{a&&(m=xs(),x=ws(),c=Mr())}),()=>{a=!1,m?.(),x?.(),c?.()}},[o]),r.useEffect(()=>{n&&wr(n)},[n]),n?e.jsx(Pe,{children:e.jsx("div",{className:"h-full w-full overflow-hidden bg-background text-foreground",children:e.jsx(ys,{apis:n,children:e.jsx(bs,{children:e.jsx(vs,{children:e.jsx(Na,{})})},o)})})}):e.jsx(Pe,{children:e.jsx("div",{className:"h-full w-full overflow-hidden bg-background text-foreground"})})}const Un=document.getElementById("root");if(!Un)throw new Error("Root element not found");Qn.createRoot(Un).render(e.jsx(Ne.StrictMode,{children:e.jsx(Ps,{children:e.jsx(Rs,{children:e.jsx(ka,{apis:xn()??void 0})})})}));
|
|
135
|
+
${w}${_}`),je.success("Preview console attached to chat")},[S,Q,b,F,y,t]),[B,U]=r.useState("unknown"),J=r.useRef(0),ae=r.useRef(0),xe=r.useRef(""),ve=r.useRef(""),ye=15e3;r.useEffect(()=>{if(!$){U("unknown"),xe.current="",J.current=0,ae.current=0;return}let R=!1,w=null;xe.current!==E&&(xe.current=E,J.current=Date.now(),ae.current=0);const _=L=>{w=setTimeout(()=>{R||a()},L)};return U("unknown"),(async()=>{const A=await(async()=>{try{return await rt($,{method:"GET",credentials:"include",cache:"no-store",redirect:"manual"})}catch{return null}})();if(R)return;if(!A){U("unreachable"),_(5e3);return}const s=So(A.headers,ve.current===E);if(s!=="none"){if(Re.delete(E),s==="retry-registration")ve.current=E,h({status:"loading"}),x();else{const I=await A.json().catch(()=>({}));if(R)return;const H=typeof I?.error=="string"?I.error:`HTTP ${A.status}`;h({status:"error",message:H})}return}if(A.status!==502){ve.current="",U("reachable");return}const d=J.current||Date.now();if(Date.now()-d<ye){U("starting"),ae.current+=1;const I=ae.current,H=Math.min(2e3,250*Math.pow(2,Math.min(4,I)));_(H);return}U("unreachable"),_(5e3)})(),()=>{R=!0,w&&clearTimeout(w)}},[E,$,i]);const P=K&&c.status==="ready"&&(B==="unknown"||B==="starting"),se=K&&c.status==="ready"&&B==="unreachable",fe=r.useCallback(R=>{if(!K||c.status!=="ready"||typeof window>"u")return;const w=R.currentTarget.contentWindow;if(w)try{const _=w.location,L=$n($);if(_.origin!==L||_.pathname.startsWith(c.proxyBasePath))return;const A=`${c.proxyBasePath}${_.pathname}${_.search}${_.hash}`;w.location.replace(A)}catch{}},[K,$,c]);return e.jsxs("div",{className:"absolute inset-0 flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[e.jsx("div",{className:"min-w-0 flex-1 truncate typography-micro text-muted-foreground",title:ie||t,children:ie||t||"No preview URL"}),e.jsx(me,{type:"button",size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>a(),title:"Reload preview","aria-label":"Reload preview",disabled:!F,children:e.jsx(V,{name:"refresh",className:"h-3.5 w-3.5"})}),e.jsx(me,{type:"button",size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{j&&st(j)},title:"Open in browser","aria-label":"Open in browser",disabled:!j,children:e.jsx(V,{name:"external-link",className:"h-3.5 w-3.5"})}),K?e.jsx(me,{type:"button",size:"sm",variant:O?"secondary":"ghost",className:"h-7 gap-1 px-2",onClick:()=>oe(R=>!R),title:"Inspect preview element","aria-label":"Inspect preview element",disabled:!u,children:e.jsx(V,{name:"cursor",className:"h-3.5 w-3.5"})}):null,K?e.jsxs(me,{type:"button",size:"sm",variant:N?"secondary":"ghost",className:"h-7 gap-1 px-2",onClick:()=>f(R=>!R),title:u?"Open preview console":"Waiting for preview console","aria-label":u?"Open preview console":"Waiting for preview console",disabled:!u&&S.length===0,children:[e.jsx(V,{name:"terminal-box",className:"h-3.5 w-3.5"}),pe>0?e.jsx("span",{className:"typography-micro text-status-error",children:pe}):null]}):null]}),e.jsxs("div",{className:"relative min-h-0 flex-1 bg-background",children:[P?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center text-sm text-muted-foreground",children:[e.jsx("div",{children:"Starting dev server..."}),e.jsx("div",{className:"text-xs opacity-70",children:"Waiting for the server to accept connections."})]}):se?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center text-sm text-muted-foreground",children:[e.jsx("div",{children:"Dev server is not responding."}),e.jsx("div",{className:"text-xs opacity-70",children:"Make sure your dev server is still running, then retry."}),e.jsx(me,{type:"button",size:"sm",variant:"outline",onClick:()=>a(),children:"Retry"})]}):F&&(!K||B==="reachable")?e.jsxs("div",{className:"relative h-full w-full",children:[e.jsx("iframe",{ref:g,src:F,title:"Preview",className:"h-full w-full border-0",style:{colorScheme:Z},onLoad:fe,sandbox:K?"allow-scripts allow-same-origin allow-forms allow-popups allow-downloads":"allow-scripts allow-forms"},`${F}:${i}`),O&&z?e.jsx("div",{className:"pointer-events-none absolute rounded-sm border-2 border-[var(--interactive-focus-ring)] bg-[var(--interactive-focus-ring)]/35",style:{left:z.bounds.x,top:z.bounds.y,width:z.bounds.width,height:z.bounds.height},children:e.jsxs("div",{className:"absolute -top-6 left-0 max-w-64 truncate rounded bg-[var(--surface-elevated)] px-2 py-0.5 typography-micro text-foreground shadow",children:[z.tag,z.text?` · ${z.text}`:""]})}):null]}):ce?e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-sm text-muted-foreground",children:"Connecting preview proxy..."}):he?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 px-6 text-sm text-muted-foreground",children:[e.jsx("div",{children:"Could not start preview proxy."}),c.status==="error"?e.jsx("div",{className:"text-center text-xs opacity-70",children:c.message}):null]}):e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-sm text-muted-foreground",children:"Preview needs a valid http(s) URL."}),N?e.jsxs("div",{className:"absolute inset-x-3 bottom-3 z-10 max-h-[45%] overflow-hidden rounded-xl border border-border/70 bg-[var(--surface-elevated)] shadow-lg",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border/50 px-3 py-2",children:[e.jsx("div",{className:"typography-ui-label text-foreground",children:"Preview console"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(me,{type:"button",size:"xs",variant:"ghost",onClick:M,disabled:S.length===0,children:"Attach"}),e.jsx(me,{type:"button",size:"xs",variant:"ghost",onClick:ue,disabled:S.length===0,children:"Copy"}),e.jsx(me,{type:"button",size:"xs",variant:"ghost",onClick:()=>k([]),disabled:S.length===0,children:"Clear"})]})]}),e.jsx("div",{className:"flex items-center gap-1 border-b border-border/30 px-3 py-1.5",children:["all","errors","warnings","logs"].map(R=>e.jsx(me,{type:"button",size:"xs",variant:T===R?"secondary":"ghost",onClick:()=>p(R),children:R==="all"?"All":R==="errors"?"Errors":R==="warnings"?"Warnings":"Logs"},R))}),e.jsx("div",{className:"max-h-64 overflow-auto p-2 typography-code text-xs",children:S.length===0?e.jsx("div",{className:"px-2 py-3 text-muted-foreground",children:"No preview console events yet."}):de.length===0?e.jsx("div",{className:"px-2 py-3 text-muted-foreground",children:"No events match this filter."}):de.map(R=>e.jsx("div",{className:"border-b border-border/30 px-2 py-1 last:border-b-0",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:le("shrink-0 uppercase",R.level==="error"||R.level==="runtime"||R.level==="resource"?"text-status-error":R.level==="warn"?"text-status-warning":"text-muted-foreground"),children:R.level}),e.jsx("span",{className:"min-w-0 break-words text-foreground",children:R.message})]})},R.id))})]}):null]})]})},At=t=>t,xt=t=>{const n=At(t).type;return typeof n=="string"?n:""},Co=t=>{const n=At(t).tool;return typeof n=="string"?n:""},No=t=>{const n=At(t).text;return typeof n=="string"?n:""},ko=t=>{const n=xt(t);return n==="tool"?Co(t).trim().toLowerCase()||"tool":n||"unknown"},Po=t=>{if(t.length===0)return"";const n=[];for(const o of t){const i=ko(o);n.includes(i)||n.push(i)}return n.join(" + ")},Ro=t=>t.replace(/\s+/g," ").trim(),Eo=t=>{for(const o of t)if(xt(o)==="text"){const i=Ro(No(o));if(i.length===0)continue;return i}const n=t.filter(o=>xt(o)!=="text").length;return n===0?"":`${n} attachment${n===1?"":"s"}`},To=(t,n,o)=>`${o(t)} / ${o(n)}`,_o=t=>{if(t==="12h")return!0;if(t==="24h")return!1},Ao=(t,n)=>{if(!t||!Number.isFinite(t))return"-";const o=_o(n);return new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:o===!1?"2-digit":"numeric",minute:"2-digit",...o===void 0?{}:{hour12:o}})},Do={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},nt={user:0,assistant:0,tool:0,other:0},Mo=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,ht=t=>gt(t),Io=(...t)=>{for(const n of t)if(typeof n=="string"&&n.trim().length>0)return n;return""},ke=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((n,o)=>n+ke(o),0):t&&typeof t=="object"?Object.values(t).reduce((n,o)=>n+ke(o),0):0,Lo=(t,n)=>{const o=t,i=typeof o.type=="string"?o.type:"";if(i==="reasoning")return{...nt,assistant:ke(o.text)+ke(o.content)};const a=Io(o.text,o.content,o.value,o.source?.value,o.source?.text?.value);return i==="tool"||n==="tool"?{user:0,assistant:0,tool:ke(o.input)+ke(o.output)+ke(o.error)+ke(o.call?.input)+ke(o.call?.output)+ke(o.call?.error)+ke(o.raw)+Math.round(ke(o.metadata)*.25)+Math.round(ke(o.state)*.1),other:0}:n==="user"?{user:a.length,assistant:0,tool:0,other:0}:n==="assistant"?{user:0,assistant:a.length,tool:0,other:0}:{user:0,assistant:0,tool:0,other:a.length}},nn=(t,n)=>({user:t.user+n.user,assistant:t.assistant+n.assistant,tool:t.tool+n.tool,other:t.other+n.other}),Oo=t=>{const n=qe(t.info);return n.isUser?"user":n.role==="assistant"?"assistant":n.role==="tool"?"tool":"other"},$o=(t,n)=>{if(t.length===0)return{...nt};const o=t.reduce((i,a)=>{const m=Oo(a);let x={...nt};for(const c of a.parts)x=nn(x,Lo(c,m));return nn(i,x)},{...nt});return o.user+=n.length,{user:Math.ceil(o.user/4),assistant:Math.ceil(o.assistant/4),tool:Math.ceil(o.tool/4),other:Math.ceil(o.other/4)}},Le=t=>t.toLocaleString("en-US"),Wo=t=>!Number.isFinite(t)||t<=0?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(0):new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:t<.01?4:2,maximumFractionDigits:t<.01?4:2}).format(t),Fo=(t,n)=>!t||!Number.isFinite(t)?"-":Yr(t,n,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),Bo=(t,n,o)=>{const i=t.find(m=>m.id===n),a=i?.models?.find(m=>m.id===o);return{providerName:i?.name||n||"-",modelName:a?.name||o||"-",contextLimit:typeof a?.limit?.context=="number"?a.limit.context:null}},zo=()=>{const t=ne(f=>f.timeFormatPreference),[n,o]=r.useState({}),{value:i,show:a,clear:m}=Xr(null,2e3),x=Ce(f=>f.currentSessionId),c=Ce(f=>f.currentSessionDirectory),h=qr(),g=jn(x??""),v=$e(f=>f.providers);r.useEffect(()=>{o(f=>Object.keys(f).length>0?{}:f),m()},[m,c,x]);const u=r.useCallback(async(f,T)=>{(await bt(T)).ok?a(f):m()},[m,a]),l=r.useMemo(()=>{const f=x?h.find($=>$.id===x)??null:null,T=g.filter($=>qe($.info).role==="assistant"),p=g.filter($=>qe($.info).isUser);let S=null;for(let $=T.length-1;$>=0;$-=1){const F=T[$];if(ht(F).total>0){S=F;break}}const k=S?ht(S):Do,O=S?.info?.usage,oe=wn({input:k.input,cache:{read:k.cacheRead,write:k.cacheWrite}}),z=T.reduce(($,F)=>{const ie=Mo(F.info.cost);return $+ie},0),G=S?.info?.model??null,Q=Bo(v,G?.providerID||"",G?.modelID||""),y=Q.contextLimit,b=O?yn(O):k.total,X=y&&y>0?Math.min(999,b/y*100):0,q=[...g].reverse().find($=>qe($.info).isUser&&typeof $.info.system=="string")?.info?.system||"",K=$o(g,q),Y=K.user,ee=K.assistant,E=K.tool,Z=O?0:Math.max(0,k.input-Y-ee-E),j=Y+ee+E+Z,W=g[0]?.info?.time?.created,re=g.length>0?g[g.length-1]?.info?.time?.created:null;return{sessionTitle:En(f),messagesCount:g.length,userMessagesCount:p.length,assistantMessagesCount:T.length,createdAt:f?.time?.created??W??null,lastActivityAt:re??f?.time?.created??null,providerModel:Q,tokenBreakdown:k,usagePercent:X,cacheHitRate:oe,totalAssistantCost:z,contextLimit:y,contextWindowTokens:b,hasUsage:O!==void 0,breakdown:{user:Y,assistant:ee,tool:E,other:Z},breakdownTotal:j}},[x,v,g,h]);if(!x)return e.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:"Open a session to inspect context."});const N=[{key:"user",label:"User",value:l.breakdown.user,color:"var(--status-success)"},{key:"assistant",label:"Assistant",value:l.breakdown.assistant,color:"var(--primary-base)"},{key:"tool",label:"Tool Calls",value:l.breakdown.tool,color:"var(--status-warning)"},...l.hasUsage?[]:[{key:"other",label:"Other",value:l.breakdown.other,color:"var(--surface-muted-foreground)"}]];return e.jsx("div",{className:"h-full overflow-y-auto bg-background",children:e.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:l.sessionTitle}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground/70",children:[e.jsxs("span",{children:[l.providerModel.providerName," / ",l.providerModel.modelName]}),l.createdAt&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("span",{children:Fo(l.createdAt,t)})]})]})]}),e.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsx("span",{className:"typography-micro text-muted-foreground",children:"Context"}),e.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground/70",children:[Le(l.contextWindowTokens),l.contextLimit?` / ${Le(l.contextLimit)}`:""]})]}),e.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:l.usagePercent>0&&e.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,l.usagePercent)}%`,backgroundColor:l.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}})}),e.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:`${l.usagePercent.toFixed(1)}% used`})]}),e.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:[{label:"Messages",value:Le(l.messagesCount)},{label:"User",value:Le(l.userMessagesCount)},{label:"Assistant",value:Le(l.assistantMessagesCount)},{label:"Cost",value:Wo(l.totalAssistantCost)}].map(f=>e.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5",children:[e.jsx("div",{className:"typography-micro text-muted-foreground/70",children:f.label}),e.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:f.value})]},f.label))}),e.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[e.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:"Last Assistant Message"}),e.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:"Input",value:l.tokenBreakdown.input,format:"count"},{label:"Output",value:l.tokenBreakdown.output,format:"count"},{label:"Reasoning",value:l.tokenBreakdown.reasoning,format:"count"},{label:"Cache Read",value:l.tokenBreakdown.cacheRead,format:"count"},{label:"Cache Write",value:l.tokenBreakdown.cacheWrite,format:"count"},{label:"Cache Hit",value:l.cacheHitRate.hasInput?l.cacheHitRate.percent:null,format:"percent"}].map(f=>e.jsxs("div",{children:[e.jsx("div",{className:"typography-micro text-muted-foreground/70",children:f.label}),e.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:f.value!==null&&f.value!==void 0?f.format==="percent"?`${f.value.toFixed(1)}%`:Le(f.value):"—"})]},f.label))})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:N.map(f=>f.value<=0||l.breakdownTotal<=0?null:e.jsx("div",{style:{width:`${f.value/l.breakdownTotal*100}%`,backgroundColor:f.color}},f.key))}),e.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:N.map(f=>{const T=l.breakdownTotal>0?f.value/l.breakdownTotal*100:0;return e.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:f.color}}),e.jsxs("span",{className:"typography-micro text-muted-foreground/70",children:[f.label," ",e.jsxs("span",{className:"tabular-nums",children:[T.toFixed(0),"%"]})]})]},f.key)})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"typography-micro text-muted-foreground",children:"Raw Messages"}),e.jsx("div",{className:"mt-2.5 space-y-1",children:[...g].reverse().map(f=>{const p=qe(f.info).role,S=p==="assistant",k=p==="user",O=n[f.info.id]===!0,oe=i===f.info.id,z=f.info.time?.created??null,G=Po(f.parts),Q=S?ht({info:f.info,parts:f.parts}):null,y=k?Eo(f.parts):"",b=Ao(z,t),X=G||"—",q=Q?To(Q.input,Q.output,Le):"",K=p||"unknown",Y=G?`${K}: ${G}`:K,ee=O?JSON.stringify({info:f.info,parts:f.parts},null,2):"";return e.jsxs("div",{className:"overflow-hidden rounded-lg bg-[var(--surface-elevated)]/70",children:[e.jsx("button",{type:"button",className:"w-full cursor-pointer px-3 py-1.5 text-left hover:bg-[var(--interactive-hover)]","aria-expanded":O,onClick:()=>{o(E=>({...E,[f.info.id]:E[f.info.id]!==!0}))},children:e.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:S?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[k?e.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[e.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",y]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:S?X:Y}),S&&e.jsx("span",{className:"text-right text-muted-foreground tabular-nums",children:q})]}),e.jsx("span",{className:"text-right text-muted-foreground",children:b})]})}),O&&e.jsx("div",{className:"border-t border-[var(--surface-subtle)] p-0",children:e.jsxs("div",{className:"group relative max-h-[26rem] w-full overflow-auto bg-[var(--surface-background)]",children:[e.jsx("div",{className:"absolute top-1 right-2 z-10 opacity-0 transition-opacity group-hover:opacity-100",children:e.jsx("button",{type:"button",className:"rounded p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",onClick:E=>{E.stopPropagation(),u(f.info.id,ee)},"aria-label":oe?"Copied":"Copy JSON",title:oe?"Copied":"Copy",children:oe?e.jsx(V,{name:"check",className:"size-3.5"}):e.jsx(V,{name:"file-copy",className:"size-3.5"})})}),e.jsx(Gr,{language:"json",code:ee,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},f.info.id)})})]})]})})},Uo=_e(()=>Ee(()=>import("./DiffView-BxwoRCYx.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,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52])).then(t=>({default:t.DiffView}))),Ho=_e(()=>Ee(()=>import("./FilesView-D_2QcdUt.js"),__vite__mapDeps([53,1,2,3,4,5,6,7,8,9,10,11,12,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,50,51,33,34,18,19,20,21,22,23,24,25,26,27,28,29,30,31,70,71,45,46,47,48,49,72,73,15,16,17,32,35,36,37,38,39,40,41,74,75,76,77])).then(t=>({default:t.FilesView}))),Vo=_e(()=>Ee(()=>import("./GitView-XBBheKRM.js"),__vite__mapDeps([78,6,1,2,3,10,4,5,7,8,9,11,12,45,46,47,48,49,13,79,80,81,82,44,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,14,42,43,50,51])).then(t=>({default:t.GitView}))),Ko=_e(()=>Ee(()=>import("./PullRequestsSurface-B3ictm4I.js"),__vite__mapDeps([83,6,1,2,3,84,4,5,7,8,9,10,11,12,45,46,47,48,49,85,79,80,44,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,14,42,43,50,51])).then(t=>({default:t.PullRequestsSurface}))),Xo=_e(()=>Ee(()=>import("./IssuesSurface-BA1kpvAJ.js"),__vite__mapDeps([86,1,2,3,84,4,5,6,7,8,9,10,11,12,45,46,47,48,49,85,79,80,87])).then(t=>({default:t.IssuesSurface}))),qo=380,Go=1400,zn=600,Yo=100,Jo=24,rn=t=>Number.isFinite(t)?Math.min(Go,Math.max(qo,Math.round(t))):zn,Qo=t=>{const n=t?.parentElement?.clientWidth;return!n||n<=0?null:n},Zo=(t,n)=>{if(!t)return"";const o=t.replace(/\\/g,"/"),i=n.replace(/\\/g,"/").replace(/\/+$/,"");return i&&o.startsWith(i+"/")?o.slice(i.length+1):o},wt=(t,n=null)=>t==="file"?"Files":t==="diff"?"Changes":t==="preview"?"Preview":t==="browser"?"Browser":t==="git"?Pt(n).label:t==="terminal"?"Terminal":t==="pull-requests"?"Pull requests":t==="issues"?"Issues":t==="extensions"?"Extensions":"Context",ea=t=>{if(!t)return null;const n=t.replace(/\\/g,"/").trim();if(!n)return null;const o=n.split("/").filter(Boolean);return o.length===0?n:o[o.length-1]||null},ta=(t,n=null)=>{if(t.label)return t.label;if(t.mode==="file")return ea(t.targetPath)||"Files";if(t.mode==="preview"){const o=t.targetPath;if(o)try{const i=new URL(o);return i.host||i.hostname||"Preview"}catch{}return"Preview"}return t.mode==="diff"?"Changes":wt(t.mode,n)},ft=(t,n=null)=>{if(t.mode==="file")return t.targetPath?e.jsx(yt,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return e.jsx(Nr,{className:"h-3.5 w-3.5"});if(t.mode==="git")return e.jsx(V,{name:Pt(n).icon,className:"h-3.5 w-3.5"});if(t.mode==="terminal")return e.jsx(V,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="context")return e.jsx(V,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="preview")return e.jsx(V,{name:"global",className:"h-3.5 w-3.5 text-[var(--status-info)]"});if(t.mode==="browser")return e.jsx(V,{name:"global",className:"h-3.5 w-3.5"});if(t.mode==="pull-requests")return e.jsx(V,{name:"git-pull-request",className:"h-3.5 w-3.5"});if(t.mode==="issues")return e.jsx(V,{name:"task",className:"h-3.5 w-3.5"});if(t.mode==="extensions")return e.jsx(V,{name:"plug-2",className:"h-3.5 w-3.5"})},na=(t,n)=>t.length<=n?t:`${t.slice(0,n-3)}...`,ra=()=>{const t=Je()??"",n=r.useMemo(()=>Te(t),[t]),o=ne(C=>n?C.contextPanelByDirectory[n]:void 0),i=ne(C=>C.closeContextPanel),a=ne(C=>C.closeContextPanelTab),m=ne(C=>C.openContextPanelTab),x=ne(C=>C.toggleContextPanelExpanded),c=ne(C=>C.setContextPanelWidth),h=ne(C=>C.setActiveContextPanelTab),g=ne(C=>C.reorderContextPanelTabs),v=Ae(C=>C.setSelectedPath),u=ne(C=>C.openContextPreview),l=ne(C=>C.contextEditorTreeVisible),N=ne(C=>C.toggleContextEditorTree),f=Ce(C=>C.currentSessionId),T=r.useMemo(()=>o?.tabs??[],[o?.tabs]),p=T.find(C=>C.id===o?.activeTabId)??T[T.length-1]??null,S=!!(o?.isOpen&&p),k=!!(S&&o?.expanded),[O,oe]=r.useState(null),z=o?.width,G=Zr,Q=O??(typeof window<"u"?window.innerWidth:zn*2),y=rn(z??Math.round(G*Q)),b=Cn(n||null),[X,q]=r.useState(!1),[K,Y]=r.useState(null),[ee,E]=r.useState(null),[Z,j]=r.useState(null),[W,re]=r.useState(null),$=r.useRef(0),F=r.useRef(y),ie=r.useRef(null),ce=r.useRef(null),he=r.useRef(null),ge=r.useRef(!1);r.useLayoutEffect(()=>{const C=he.current?.parentElement;if(!C||typeof ResizeObserver>"u")return;const Se=new ResizeObserver(()=>{oe(C.clientWidth||null)});return Se.observe(C),oe(C.clientWidth||null),()=>Se.disconnect()},[]),r.useEffect(()=>{if(!S||ge.current){ge.current=S;return}const C=window.requestAnimationFrame(()=>{he.current?.focus({preventScroll:!0})});return ge.current=!0,()=>window.cancelAnimationFrame(C)},[S]);const pe=r.useRef(null),de=r.useRef(null),ue=r.useCallback(()=>{de.current=null;const C=he.current,Se=ie.current;!C||Se===null||C.style.setProperty("--oc-context-panel-width",`${Se}px`)},[]);r.useEffect(()=>()=>{de.current!==null&&clearTimeout(de.current)},[]);const M=r.useCallback(C=>{const Se=rn(C),Me=pe.current;return Me===null?Se:Math.min(Se,Math.max(1,Me))},[]),B=r.useCallback(C=>{!S||k||!n||(ce.current=C.pointerId,q(!0),$.current=C.clientX,F.current=y,ie.current=y,pe.current=Qo(he.current),document.documentElement.style.cursor="col-resize",C.preventDefault())},[n,k,S,y]),U=r.useCallback(()=>{const C=M(ie.current??y);ie.current=null,pe.current=null,de.current!==null&&(clearTimeout(de.current),de.current=null),document.documentElement.style.cursor="",n&&c(n,C),q(!1),ce.current=null},[M,n,c,y]);r.useEffect(()=>{if(!X)return;const C=Ie=>{if(ce.current!==Ie.pointerId)return;const Hn=$.current-Ie.clientX,Dt=M(F.current+Hn);ie.current!==Dt&&(ie.current=Dt,de.current===null&&(de.current=setTimeout(ue,Yo)))},Se=Ie=>{ce.current===Ie.pointerId&&U()},Me=()=>{U()};return window.addEventListener("pointermove",C),window.addEventListener("pointerup",Se),window.addEventListener("pointercancel",Se),window.addEventListener("blur",Me),()=>{window.removeEventListener("pointermove",C),window.removeEventListener("pointerup",Se),window.removeEventListener("pointercancel",Se),window.removeEventListener("blur",Me)}},[ue,M,U,X]),r.useEffect(()=>{X||(ie.current=null,document.documentElement.style.cursor="")},[X]);const J=r.useCallback(()=>{n&&i(n)},[i,n]),ae=r.useCallback(()=>{n&&x(n)},[n,x]),xe=r.useCallback(C=>{C.key==="Escape"&&(Jr(C.target)||(C.preventDefault(),C.stopPropagation(),J()))},[J]);r.useEffect(()=>{if(!(!n||!p)&&p.mode==="file"&&p.targetPath){v(n,p.targetPath,{allowOutsideRoot:!0});return}},[p,n,v]);const ve=r.useCallback(C=>{!n||p?.mode!=="diff"||m(n,{mode:"diff",targetPath:p.targetPath,stagedDiff:C==="staged",diffScope:C})},[p,n,m]),ye=p?.mode==="file"||p?.mode==="preview",P=r.useMemo(()=>p?T.filter(C=>C.mode===p.mode):[],[p,T]),se=r.useMemo(()=>P.map(C=>{const Se=ta(C,b),Me=na(Se,Jo),Ie=Zo(C.targetPath,t);return{id:C.id,label:Me,icon:ft(C,b),title:Ie?`${Se}: ${Ie}`:Se,closeLabel:`Close ${Me} tab`}}),[P,t,b]),fe=p?.mode==="pull-requests",R=p?.mode==="issues",w=p?.mode==="context"?e.jsx(zo,{}):p?.mode==="extensions"?e.jsx(Qr,{sessionId:f}):p?.mode==="git"?e.jsx(r.Suspense,{fallback:null,children:e.jsx(Vo,{isActive:S,gitHeaderSlot:p?.mode==="git"?ee:null})}):p?.mode==="pull-requests"?e.jsx(r.Suspense,{fallback:null,children:e.jsx(Ko,{headerActionsSlot:fe?W:null,headerActionsPresentation:"desktop"},`pull-requests:${n}`)}):p?.mode==="issues"?e.jsx(r.Suspense,{fallback:null,children:e.jsx(Xo,{headerActionsSlot:R?W:null,headerActionsPresentation:"desktop"},`issues:${n}`)}):p?.mode==="preview"?e.jsx(jo,{rawUrl:p.targetPath??"",onNavigate:C=>u(t,C)}):e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[e.jsx(V,{name:"global",className:"h-12 w-12 text-muted-foreground/50"}),e.jsx("div",{className:"typography-ui-header text-foreground",children:"Preview"}),e.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:"Use Project Actions or a terminal Preview button to open a preview."})]}),_=r.useMemo(()=>T.filter(C=>C.mode==="browser"),[T]),L=r.useMemo(()=>T.filter(C=>C.mode==="diff"),[T]),A=r.useMemo(()=>T.some(C=>C.mode==="terminal"),[T]),s=r.useMemo(()=>T.some(C=>C.mode==="file"),[T]),d=r.useMemo(()=>T.some(C=>C.mode==="file"&&C.targetPath),[T]),D=p?.mode==="file",I=p?.mode==="terminal",H=p?.mode==="git",te=p?.mode==="diff",we=e.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[ye?e.jsx($s,{items:se,activeId:p?.id??null,onSelect:C=>{n&&h(n,C)},onClose:C=>{n&&a(n,C)},onReorder:(C,Se)=>{n&&g(n,C,Se)},layoutMode:"scrollable",variant:"default"}):I?e.jsx("div",{ref:C=>{Y(C)},className:"flex min-w-0 flex-1 items-center px-1"}):H?e.jsx("div",{ref:C=>{E(C)},className:"flex min-w-0 flex-1 items-center overflow-hidden px-1"}):te?e.jsx("div",{ref:C=>{j(C)},className:"flex min-w-0 flex-1 items-center overflow-hidden px-1"}):fe||R?e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[p?ft(p,b):null,e.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:p?wt(p.mode,b):null}),e.jsx("span",{className:"min-w-0 flex-1"}),e.jsx("div",{ref:C=>{re(C)},className:"flex shrink-0 items-center gap-1"})]}):e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[p?ft(p,b):null,e.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:p?wt(p.mode,b):null})]}),e.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[D?e.jsx(me,{type:"button",variant:"ghost",size:"sm",onClick:N,className:"h-8 w-8 p-0",title:"Toggle file tree","aria-label":"Toggle file tree","aria-pressed":l,children:e.jsx(V,{name:"layout-right",className:"size-4"})}):null,e.jsx(me,{type:"button",variant:"ghost",size:"sm",onClick:ae,className:"h-8 w-8 p-0",title:k?"Collapse panel":"Expand panel","aria-label":k?"Collapse panel":"Expand panel",children:k?e.jsx(V,{name:"fullscreen-exit",className:"size-4"}):e.jsx(V,{name:"fullscreen",className:"size-4"})}),e.jsx(me,{type:"button",variant:"ghost",size:"sm",onClick:J,className:"h-8 w-8 p-0",title:"Close panel","aria-label":"Close panel",children:e.jsx(V,{name:"close",className:"size-4"})})]})]}),be=S?k?{"--oc-context-panel-width":O!==null?`${O}px`:"100%",width:O!==null?`${O}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${y}px`}:{"--oc-context-panel-width":`${y}px`,width:0,maxWidth:"100%",overflowX:"clip"};return e.jsxs("aside",{ref:he,"data-context-panel":"true",tabIndex:-1,inert:!S||void 0,className:le("flex min-h-0 flex-col overflow-hidden bg-background",k?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!S&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:xe,style:be,children:[S&&!k&&e.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),S&&e.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!k&&e.jsx("div",{className:le("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",X&&"bg-[var(--interactive-border)]"),onPointerDown:B,role:"separator","aria-orientation":"vertical","aria-label":"Resize context panel"}),e.jsxs("div",{className:le("relative z-10 flex h-full min-h-0 shrink-0 flex-col duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none","transition-[width,opacity]",!S&&"pointer-events-none select-none opacity-0"),style:{width:k?O!==null?`${O}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!S,children:[we,e.jsxs("div",{className:le("relative min-h-0 flex-1 overflow-hidden",X&&"pointer-events-none"),children:[s?e.jsxs("div",{className:le("absolute inset-0 flex",D?"flex":"hidden"),children:[e.jsx("div",{className:"h-full min-w-0 flex-1",children:d?e.jsx(r.Suspense,{fallback:null,children:e.jsx(Ho,{mode:"editor-only",isVisible:S&&D})}):e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[e.jsx(V,{name:"file-code",className:"h-12 w-12 text-muted-foreground/50"}),e.jsx("div",{className:"typography-ui-header text-foreground",children:"No file open"}),e.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:"Pick a file from the tree to start editing."})]})}),e.jsx(yo,{visible:l})]}):null,_.map(C=>e.jsx("div",{className:le("absolute inset-0",p?.id!==C.id&&"hidden"),children:e.jsx(lo,{initialUrl:C.targetPath??"",directory:n,tabID:C.id})},C.id)),S?L.filter(C=>p?.id===C.id).map(C=>e.jsx("div",{className:"absolute inset-0",children:e.jsx(r.Suspense,{fallback:null,children:e.jsx(Uo,{hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:C.diffScope??(C.stagedDiff?"staged":"working"),onDiffScopeChange:ve,targetFilePath:C.targetPath,flushContent:!0,toolbarSlot:te?Z:null})})},C.id)):null,A?e.jsx("div",{className:le("absolute inset-0",p?.mode==="terminal"?"block":"hidden"),children:e.jsx(bn,{visible:S&&p?.mode==="terminal",terminalHeaderSlot:I?K:null})}):null,S&&!D&&p?.mode!=="browser"&&p?.mode!=="diff"&&p?.mode!=="terminal"?w:null]})]})]})},sa=150,oa=500,aa=[],Oe=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t),Ze=(t,n)=>{if(!t||typeof t!="object")return;const o=t[n];return typeof o=="number"&&Number.isFinite(o)?o:void 0},ia=t=>t>99?"99+":String(t),la=t=>t>=90?"text-[var(--status-error)]":t>=75?"text-[var(--status-warning)]":"text-[var(--status-success)]",ca=({surface:t,isActive:n,showActivityDot:o,label:i,description:a,badgeCount:m,badgeAriaLabel:x,badgeDescription:c,orderNumber:h,showOrderNumber:g,onSelect:v,chartPercentage:u,chartDetails:l})=>{const{attributes:N,listeners:f,setNodeRef:T,transform:p,transition:S,isDragging:k}=dn({id:t.id}),O=m!=null&&m>0?ia(m):null;return e.jsx("div",{ref:T,style:{transform:un.Translate.toString(p),transition:S},className:le("relative",k&&"z-10 opacity-70"),children:e.jsxs(We,{delayDuration:sa,children:[e.jsx(Fe,{asChild:!0,children:e.jsxs("button",{type:"button",...N,...f,onClick:()=>v(t),"aria-label":x??i,"aria-pressed":n,className:le("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",n?"text-primary":"text-muted-foreground hover:text-foreground"),children:[t.id==="context"&&typeof u=="number"?e.jsx(Ut,{percentage:u,className:"size-[18px] -rotate-90"}):e.jsx(V,{name:t.icon,className:"h-[18px] w-[18px]"}),g&&h!=null?e.jsx("span",{"aria-hidden":"true",className:"absolute right-0 top-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-surface-muted px-1 text-[0.625rem] font-medium leading-none text-muted-foreground",children:h===10?"0":h}):O?e.jsx("span",{"aria-hidden":"true",className:"absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[0.625rem] font-semibold leading-none",style:{backgroundColor:"var(--status-info-background)",color:"var(--status-info)"},children:O}):o?e.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null]})}),e.jsx(Be,{side:"left",sideOffset:8,className:t.id==="context"&&l?"p-0 border-0 bg-transparent shadow-none":void 0,children:t.id==="context"&&l?e.jsx("div",{className:"w-[300px] overflow-hidden rounded-lg border border-border/70 bg-[var(--surface-elevated)] p-2 shadow-[0_8px_24px_rgb(0_0_0_/_0.18)]",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5",children:[e.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:e.jsx(Ut,{percentage:l.percentage,className:"size-[18px] -rotate-90"})}),e.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:i}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground",children:l.hasData?e.jsxs("span",{className:"inline-flex items-baseline gap-1.5 tabular-nums",children:[e.jsxs("span",{className:le("font-semibold",la(l.percentage)),children:[l.percentage.toFixed(1),"%"]}),e.jsx("span",{className:"text-muted-foreground",children:`${Oe(l.totalTokens)}/${Oe(l.contextLimit)}`})]}):e.jsx("span",{className:"typography-micro text-muted-foreground",children:"No data yet"})})]}),l.hasData?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Used tokens"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:Oe(l.totalTokens)})]}),e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Context limit"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:Oe(l.contextLimit)})]}),e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Output limit"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:Oe(l.outputLimit)})]}),typeof l.cacheRead=="number"&&typeof l.cacheWrite=="number"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Cache read"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:Oe(l.cacheRead)})]}),e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Cache write"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:Oe(l.cacheWrite)})]})]}):null,typeof l.cacheHitPercent=="number"?e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Cache hit"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:`${l.cacheHitPercent.toFixed(1)}%`})]}):null]}):e.jsx("div",{className:"px-2.5 py-2 typography-micro text-muted-foreground",children:a})]})}):e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{children:i}),e.jsx("span",{className:"typography-micro text-muted-foreground",children:a}),c?e.jsx("span",{className:"typography-micro text-muted-foreground",children:c}):null]})})]})})},da=()=>{const t=Je(),n=t?or(t):"",o=ne(w=>n?w.contextPanelByDirectory[n]:void 0),i=ne(w=>w.contextRailOrder),a=ne(w=>w.setContextRailOrder),m=ne(w=>w.openContextSurface),x=ne(w=>w.shortcutOverrides),{screenWidth:c}=at(),{git:h,github:g}=vt(),v=Sn(n||null),u=Cn(n||null),l=Nn(w=>w.ensureStatus),N=zt(w=>w.ensureScope);r.useEffect(()=>{n&&l(n,h)},[n,l,h]),r.useEffect(()=>{!n||!g||N(n,g)},[n,N,g]);const f=r.useMemo(()=>ar("switch_context_surface",x),[x]),[T,p]=r.useState(!1);r.useEffect(()=>{const w=new Set;let _=null,L=!1;const A=H=>H.length===1&&H>="0"&&H<="9",s=()=>{Lt(f,w)?!L&&_===null&&(_=setTimeout(()=>p(!0),oa)):(L=!1,_!==null&&(clearTimeout(_),_=null),p(!1))},d=H=>{if(w.add(H.key.toLowerCase()),A(H.key)&&Lt(f,w)){L=!0,_!==null&&(clearTimeout(_),_=null),p(!1);return}s()},D=H=>{w.delete(H.key.toLowerCase()),s()},I=()=>{w.clear(),L=!1,_!==null&&(clearTimeout(_),_=null),p(!1)};return window.addEventListener("keydown",d,!0),window.addEventListener("keyup",D,!0),window.addEventListener("blur",I),()=>{window.removeEventListener("keydown",d,!0),window.removeEventListener("keyup",D,!0),window.removeEventListener("blur",I),_!==null&&clearTimeout(_)}},[f]);const S=on(mt(Gn,{activationConstraint:{distance:8}}),mt(qn,{activationConstraint:{delay:200,tolerance:6}})),k=o?.tabs??aa,O=k.find(w=>w.id===o?.activeTabId)??null,oe=o?.isOpen?O?.mode??null:null,z=v?.files.length??0,G=Ce(w=>w.currentSessionId),Q=Ce(w=>!!w.newSessionDraft?.open),y=$e(w=>w.providers),b=$e(w=>w.currentProviderId),X=$e(w=>w.currentModelId),q=$e(w=>w.getCurrentModel()),K=$e(w=>w.getModelMetadata);$e(w=>w.modelsMetadata.size);const Y=es(r.useCallback(w=>G?w.sessionModelSelections.get(G)??null:null,[G])),ee=jn(G??""),E=r.useMemo(()=>{for(let w=ee.length-1;w>=0;w-=1){const _=ee[w];if(_?.info.role==="assistant")try{if(gt(_).total>0)return _}catch{continue}}return null},[ee]),j=r.useMemo(()=>{for(let w=ee.length-1;w>=0;w-=1){const _=ee[w]?.info;if(_.role!=="user")continue;const L=_.model,A=L?.providerID??L?.providerId,s=L?.modelID??L?.modelId;if(typeof A=="string"&&A.trim()&&typeof s=="string"&&s.trim())return{providerID:A,modelID:s}}return null},[ee])??(()=>{const w=E?.info.model,_=w?.providerID??w?.providerId,L=w?.modelID??w?.modelId;return _&&L?{providerID:_,modelID:L}:null})()??(Y?{providerID:Y.providerId,modelID:Y.modelId}:null)??(b&&X?{providerID:b,modelID:X}:null),re=(j?y.find(w=>w.id===j.providerID):void 0)?.models.find(w=>w.id===j?.modelID),$=j?K(j.providerID,j.modelID):void 0,F=Ze(re?.limit,"context")??$?.limit?.context??Ze(q?.limit,"context")??0,ie=Ze(re?.limit,"output")??$?.limit?.output??Ze(q?.limit,"output")??0,ce=E?(()=>{try{return gt(E)}catch{return null}})():null,he=E?.info?.usage,ge=he?yn(he):ce?.total??0,pe=!Q&&ge>0&&F>0?Math.min(ge/F*100,999):0,de=pe,ue=ce?wn({input:ce.input,cache:{read:ce.cacheRead,write:ce.cacheWrite}}):null,M=ue?.hasInput?ue.percent:null,B=r.useMemo(()=>{const w=!!E&&ge>0&&F>0;return{percentage:pe,totalTokens:ge,contextLimit:F,outputLimit:ie,cacheRead:ce?.cacheRead??null,cacheWrite:ce?.cacheWrite??null,cacheHitPercent:M,hasData:w}},[ce,M,F,E,ie,pe,ge]),U=ts(w=>G?w.reducer.bySession.get(G)?.extensionWidgets:void 0,(w,_)=>w===_,G?`session:${G}`:"chrome"),J=r.useMemo(()=>U?.size?[...U.entries()].map(([w,_])=>`${w}:${_.lines.join(`
|
|
136
|
+
`)}`).join(";"):"",[U]),ae=J!=="",xe=r.useRef({});r.useEffect(()=>{oe==="extensions"&&G&&J&&(xe.current[G]=J)},[oe,G,J]);const ve=G?xe.current[G]??"":"",ye=oe!=="extensions"&&J!==""&&ve!==J,P=zt(w=>n?w.entriesByDirectory[n]??null:null),se=r.useMemo(()=>{if(!P)return{isLoading:!0,hasResult:!1,hasGitHubRepo:!1,hasError:!1};const w=P.scope?.repositories??[];return{isLoading:P.isLoading,hasResult:!!(P.scope||P.error),hasGitHubRepo:w.some(_=>!!(_.host&&_.owner&&_.repo&&!_.disabledReason)),hasError:!!(P.error&&!P.scope)}},[P]),fe=r.useMemo(()=>ns({railOrder:i,tabs:k,githubScope:se,hasExtensionContent:ae}),[i,c,k,se,ae]),R=r.useCallback(w=>{const{active:_,over:L}=w;if(!L||_.id===L.id)return;const A=rs(ne.getState().contextRailOrder).map(D=>D.id),s=A.indexOf(_.id),d=A.indexOf(L.id);s===-1||d===-1||a(Yn(A,s,d))},[a]);return n?e.jsx("nav",{"aria-label":"Panel surfaces",className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:e.jsx(an,{sensors:S,collisionDetection:ln,onDragEnd:R,children:e.jsx(cn,{items:fe.map(w=>w.id),strategy:Jn,children:fe.map((w,_)=>{const L=w.id==="git"?Pt(u):null,A=L?{...w,...L}:w,s=A.label,d=w.id==="git"&&u===!0?z:0,D=d>0?d:null,I=w.id==="context",H=w.id==="extensions"?ye:!1;return e.jsx(ca,{surface:A,isActive:oe===w.mode,showActivityDot:H,label:s,description:A.description,badgeCount:D,badgeAriaLabel:D!==null?D===1?`${s}, ${D} changed file`:`${s}, ${D} changed files`:null,badgeDescription:D!==null?D===1?`${D} changed file`:`${D} changed files`:null,chartPercentage:I?de:void 0,chartDetails:I?B:void 0,orderNumber:_+1,showOrderNumber:T,onSelect:te=>m(n,te.mode)},w.id)})})})}):null},ua=(t,n)=>!t||n.length===0?"":JSON.stringify([t,n]),ha=(t,n,o,i)=>!o||i!==o||t.length===0?[]:Xe(t,n,a=>a.name,{limit:10,threshold:.4}),fa=new Set,pt=t=>{if(!t)return"";const n=t.replace(/\\/g,"/"),o=n.startsWith("//");let i=n.replace(/\/+/g,"/");o&&!i.startsWith("//")&&(i=`/${i}`);const a=i==="/",m=/^[A-Za-z]:\/$/.test(i);return!a&&!m&&(i=i.replace(/\/+$/,"")),i},pa=()=>{const t=ne(s=>s.isCommandPaletteOpen),n=ne(s=>s.setCommandPaletteOpen),o=ne(s=>s.setActiveMainTab),i=ne(s=>s.setSettingsDialogOpen),a=ne(s=>s.setSettingsPage),m=ne(s=>s.setSessionSwitcherOpen),x=ne(s=>s.toggleSidebar),c=ne(s=>s.openContextOverview),h=ne(s=>s.openContextSurface),g=ne(s=>s.openContextFile),v=ne(s=>s.shortcutOverrides),u=Ce(s=>s.openNewSessionDraft),l=Ce(s=>s.setCurrentSession),N=ss({archived:!1}),f=os(r.useCallback(s=>t?s.ids:fa,[t])),T=as(r.useCallback(s=>t?s.rankById:is,[t])),p=ir(s=>s.currentDirectory),S=Ht(s=>s.getActiveProject()),k=Ht(s=>s.projects),O=Je(),oe=lr(s=>s.searchFiles),{files:z,git:G}=vt(),Q=Nn(s=>s.ensureStatus),{isMobile:y}=at(),b=r.useMemo(()=>O?pt(O):null,[O]),[X,q]=r.useState(""),Y=ls(X,200).trim(),ee=X.trim();r.useEffect(()=>{t&&q("")},[t]),r.useEffect(()=>{if(!t||!G)return;const s=setTimeout(()=>{const d=new Set;for(const D of N){const I=lt(D);!I||d.has(I)||(d.add(I),Q(I,G))}},0);return()=>clearTimeout(s)},[t,N,G,Q]);const E=r.useCallback(()=>n(!1),[n]),Z=r.useCallback(s=>()=>{E(),s()},[E]),j=r.useMemo(()=>{const s=[{id:"new-session",title:"New Session",icon:e.jsx(V,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:"New Session",onSelect:Z(()=>{o("chat"),m(!1),u()})},{id:"add-project",title:"Add Project",icon:e.jsx(V,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:"Add Project",onSelect:Z(()=>{cs.requestDirectoryDialog()})},{id:"toggle-sidebar",title:y?"Show Session Switcher":"Toggle Sidebar",icon:e.jsx(V,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:y?"Show Session Switcher":"Toggle Sidebar",onSelect:Z(()=>{if(y){const{isSessionSwitcherOpen:d}=ne.getState();m(!d)}else x()})},{id:"toggle-terminal",title:"Toggle Terminal",icon:e.jsx(V,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:"Toggle Terminal",onSelect:Z(()=>{p&&h(p,"terminal")})},{id:"context-usage",title:"Show Context Usage",icon:e.jsx(V,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:"Show Context Usage",onSelect:Z(()=>{p&&c(p)})},{id:"open-settings",title:"Open Settings...",icon:e.jsx(V,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:"Open Settings...",onSelect:Z(()=>i(!0))}];return cr()&&s.splice(1,0,{id:"new-mini-chat",title:"New Mini Chat Window",icon:e.jsx(V,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:"New Mini Chat Window",onSelect:Z(()=>{hn("desktop_open_draft_mini_chat_window",{directory:pt(p||S?.path||""),projectId:S?.id??null}).catch(d=>{console.warn("[command-palette] failed to open draft mini chat window",d)})})}),s},[Z,y,o,m,u,x,h,p,c,i,S?.id,S?.path]),W=r.useMemo(()=>{const s=dr();return{isWeb:!s&&ur(),isDesktop:s,isMobile:y}},[y]),re=r.useMemo(()=>kr.filter(s=>s.slug!=="home").filter(s=>s.isAvailable?s.isAvailable(W):!0).map(s=>{const d=Pr(s.slug)??"settings-3",D=(s.keywords??[]).join(" ");return{id:`settings:${s.slug}`,title:s.title,icon:e.jsx(V,{name:d,className:"mr-2 h-4 w-4"}),searchText:`${s.title} ${s.group} ${D}`,onSelect:Z(()=>{a(s.slug),i(!0)})}}),[W,Z,a,i]),$=r.useMemo(()=>ds(N,f,T),[N,f,T]),F=us(),ie=r.useCallback((s,d)=>d&&F.get(d)?.trim()||null,[F]),[ce,he]=r.useState([]),[ge,pe]=r.useState(""),de=ua(b,Y);r.useEffect(()=>{if(!t){he([]),pe("");return}if(!de){he([]),pe("");return}if(!b){he([]),pe("");return}let s=!1;return oe(b,Y,10,{type:"file"}).then(d=>{s||(he(d.map(D=>({path:pt(D.path),name:D.name,relativePath:D.relativePath}))),pe(de))}).catch(()=>{s||(he([]),pe(de))}),()=>{s=!0}},[t,b,Y,de,oe]);const ue=ee.length>0,M=r.useMemo(()=>ue?Xe(j,ee,s=>s.searchText,{limit:7,noFuzzy:!0}):j.map(s=>({item:s,score:0})),[j,ee,ue]),B=r.useMemo(()=>ue?Xe(re,ee,s=>s.searchText,{limit:7,noFuzzy:!0}):[],[re,ee,ue]),U=r.useMemo(()=>ue?Xe($,ee,s=>s.title||"",{limit:7,threshold:.2}):$.slice(0,5).map(s=>({item:s,score:0})),[$,ee,ue]),J=r.useMemo(()=>t?ha(ce,Y,de,ge):[],[t,ce,ge,de,Y]),ae=t&&de.length>0&&ge!==de,xe=r.useMemo(()=>{if(!ue)return[];const s=k.map(d=>({...d,displayName:d.label||d.path.split("/").pop()||d.path,searchText:`${d.label||""} ${d.path}`}));return Xe(s,ee,d=>d.searchText,{limit:7,threshold:.4})},[k,ee,ue]),ve=M.map(s=>s.item),ye=B.map(s=>s.item),P=U.map(s=>s.item),se=ue?J.map(s=>s.item):[],fe=ue?xe.map(s=>s.item):[],R=r.useMemo(()=>{if(!ue)return["commands","sessions"];const s=D=>D.length?D[0].score:1/0,d=[{key:"commands",score:s(M)},{key:"settings",score:s(B)},{key:"sessions",score:s(U)},{key:"files",score:s(J)},{key:"projects",score:s(xe)}];return d.sort((D,I)=>D.score-I.score),d.map(D=>D.key)},[ue,M,B,U,J,xe]),w=r.useCallback(s=>{E(),l(s.id,lt(s))},[E,l]),_=r.useCallback(async s=>{if(!b)return;const d=await kn(z,s,{directory:b});if(!d.ok){je.error(Pn(d.reason));return}g(b,s),E()},[b,z,g,E]),L=r.useCallback((s,d)=>{E(),u({selectedProjectId:s,directoryOverride:d})},[E,u]),A=r.useCallback(s=>mn(gn(s,v)),[v]);return e.jsxs(St,{open:t,onOpenChange:n,children:[e.jsxs(Ct,{className:"sr-only",children:[e.jsx(Nt,{children:"Command Palette"}),e.jsx(kt,{children:"Search files, sessions, and commands."})]}),e.jsx(jt,{className:"overflow-hidden p-0",showCloseButton:!0,children:e.jsxs(hs,{shouldFilter:!1,className:"[&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-4 [&_[cmdk-input-wrapper]_svg]:w-4 [&_[cmdk-input]]:h-8 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-1.5 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4 [&_[cmdk-item]]:typography-meta",children:[e.jsx(fs,{value:X,onValueChange:q,placeholder:"Search files, sessions, commands..."}),e.jsxs(ps,{children:[e.jsx(ms,{children:"No results found."}),R.map(s=>s==="commands"&&ve.length>0?e.jsx(Ve,{children:ve.map(d=>e.jsxs(Ke,{value:d.id,onSelect:d.onSelect,children:[d.icon,e.jsx("span",{children:d.title}),d.shortcutId?e.jsx(gs,{children:A(d.shortcutId)}):null]},d.id))},"commands"):s==="settings"&&ye.length>0?e.jsx(Ve,{children:ye.map(d=>e.jsxs(Ke,{value:d.id,onSelect:d.onSelect,children:[d.icon,e.jsx("span",{children:d.title})]},d.id))},"settings"):s==="sessions"&&P.length>0?e.jsx(Ve,{children:P.map(d=>{const D=En(d),I=lt(d),H=ie(d.id,I);return e.jsxs(Ke,{value:`session:${d.id}`,onSelect:()=>w(d),children:[e.jsx(V,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"truncate",children:D}),H?e.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[e.jsx(V,{name:"git-branch",className:"h-3 w-3"}),e.jsx("span",{className:"truncate max-w-[160px]",children:H})]}):null]},d.id)})},"sessions"):s==="files"&&se.length>0?e.jsx(Ve,{children:se.map(d=>{const D=hr(d.relativePath||d.name,{maxLength:80});return e.jsxs(Ke,{value:`file:${d.path}`,onSelect:()=>{_(d.path)},children:[e.jsx(yt,{filePath:d.path,className:"mr-2 size-4 shrink-0"}),e.jsx("span",{className:"truncate","aria-label":d.relativePath,children:D})]},`file:${d.path}`)})},"files"):s==="projects"&&fe.length>0?e.jsx(Ve,{children:fe.map(d=>{const D=d.displayName;return e.jsxs(Ke,{value:`project:${d.id}`,onSelect:()=>L(d.id,d.path),children:[e.jsx(V,{name:"folder",className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"truncate",children:D}),e.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:d.path})]},`project:${d.id}`)})},"projects"):null),ae?e.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:"Searching files..."}):null]})]})})]})},ma=(t,n,o)=>pr(t)?mn(gn(t,o)):n,ga=()=>{const t=ne(m=>m.isHelpDialogOpen),n=ne(m=>m.setHelpDialogOpen),o=ne(m=>m.shortcutOverrides),i=fr(),a=[{categoryKey:"Navigation & Commands",items:[{id:"open_command_palette",descriptionKey:"Open Command Palette",icon:"command",keys:""},{id:"open_help",descriptionKey:"Show Keyboard Shortcuts (this dialog)",icon:"question",keys:""},{id:"toggle_sidebar",descriptionKey:"Toggle Session Sidebar",icon:"layout-left",keys:""},{id:"add_selection_to_chat",descriptionKey:"Add Selection to Chat",icon:"add",keys:""},{id:"open_model_selector",descriptionKey:"Open Model Selector",icon:"ai-generate-2",keys:""},{keys:["↑↓"],descriptionKey:"Navigate Models (in picker)",icon:"ai-generate-2"},{keys:["←→"],descriptionKey:"Adjust Thinking Mode (in picker, when supported)",icon:"brain-ai-3"},{id:"cycle_thinking_variant",descriptionKey:"Cycle thinking (global shortcut)",icon:"brain-ai-3",keys:""},{keys:[`Shift + Alt + ${i} + N`],descriptionKey:"New Window (desktop only)",icon:"window"}]},{categoryKey:"Session Management",items:[{id:"new_chat",descriptionKey:"Create New Session",icon:"add",keys:""},{id:"focus_input",descriptionKey:"Focus Chat Input",icon:"text",keys:""},{id:"cycle_session_folder",descriptionKey:"Cycle session folder",icon:"folder-open",keys:""},{id:"cycle_draft_folder",descriptionKey:"Cycle draft folder",icon:"folder-3",keys:""},{id:"open_timeline_dialog",descriptionKey:"Open conversation timeline",icon:"history",keys:""},{id:"abort_run",descriptionKey:"Abort active run (double press)",icon:"close-circle",keys:""}]},{categoryKey:"Panels",items:[{id:"open_right_sidebar",descriptionKey:"Open right sidebar",icon:"layout-right",keys:""},{id:"toggle_terminal",descriptionKey:"helpDialog.item.toggleTerminalDock",icon:"window",keys:""},{keys:[`${i} + 1...0`],descriptionKey:"Switch Context Panel Surface (number key)",icon:"layout-right"}]},{categoryKey:"Interface",items:[{id:"cycle_theme",descriptionKey:"Cycle Theme (Light → Dark → System)",icon:"palette",keys:""},{id:"toggle_services_menu",descriptionKey:"helpDialog.item.toggleServicesMenu",icon:"stack",keys:""},{id:"open_settings",descriptionKey:"Open Settings",icon:"settings-3",keys:""}]}];return e.jsx(St,{open:t,onOpenChange:n,children:e.jsxs(jt,{className:"w-[92vw] max-w-[1120px] h-[84vh] max-h-[900px] flex flex-col overflow-hidden",children:[e.jsxs(Ct,{children:[e.jsxs(Nt,{className:"flex items-center gap-2",children:[e.jsx(V,{name:"command",className:"h-5 w-5"}),"Keyboard Shortcuts"]}),e.jsx(kt,{children:"Use these keyboard shortcuts to navigate PiChamber efficiently"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto mt-3 pr-1",children:e.jsx("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-2 md:gap-x-10",children:a.map(m=>e.jsxs("div",{className:"min-w-0 break-inside-avoid",children:[e.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:m.categoryKey}),e.jsx("div",{className:"space-y-1",children:m.items.map(x=>{const c=x.id?ma(x.id,Array.isArray(x.keys)?x.keys[0]:x.keys,o):Array.isArray(x.keys)?x.keys:x.keys.split(" / ");return e.jsxs("div",{className:"flex items-center justify-between py-1 px-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[x.icon&&e.jsx(V,{name:x.icon,className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"typography-meta",children:x.descriptionKey})]}),e.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(c)?c:[c]).map((h,g)=>e.jsxs(r.Fragment,{children:[g>0&&e.jsx("span",{className:"typography-meta text-muted-foreground mx-1",children:"or"}),e.jsx("kbd",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 typography-meta font-mono bg-muted rounded border border-border/20",children:h})]},`${h}-${g}`))})]},x.id||x.descriptionKey)})})]},m.categoryKey))})})]})})},xa=r.createContext(null),wa=({children:t,value:n})=>e.jsx(xa.Provider,{value:n,children:t}),sn=_e(()=>Ee(()=>import("./GitView-XBBheKRM.js"),__vite__mapDeps([78,6,1,2,3,10,4,5,7,8,9,11,12,45,46,47,48,49,13,79,80,81,82,44,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,14,42,43,50,51])).then(t=>({default:t.GitView}))),ya=_e(()=>Ee(()=>import("./DiffView-BxwoRCYx.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,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52])).then(t=>({default:t.DiffView}))),ba=_e(()=>Ee(()=>import("./FilesView-D_2QcdUt.js"),__vite__mapDeps([53,1,2,3,4,5,6,7,8,9,10,11,12,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,50,51,33,34,18,19,20,21,22,23,24,25,26,27,28,29,30,31,70,71,45,46,47,48,49,72,73,15,16,17,32,35,36,37,38,39,40,41,74,75,76,77])).then(t=>({default:t.FilesView}))),va=_e(()=>Ee(()=>import("./DiagramView-BpG1c3Hi.js"),__vite__mapDeps([88,1,2,3,10,4,5,6,7,8,9,11,12,70,71])).then(t=>({default:t.DiagramView}))),Sa=_e(()=>Ee(()=>import("./SettingsView-BiwlwnTK.js").then(t=>t.a),__vite__mapDeps([89,1,2,3,4,5,6,7,8,9,10,11,12,45,46,47,48,49,90,91,81,82])).then(t=>({default:t.SettingsView}))),ja=_e(()=>Ee(()=>import("./SettingsWindow-j0e99YI0.js"),__vite__mapDeps([92,1,2,3,4,5,6,7,8,9,10,11,12,89,45,46,47,48,49,90,91,81,82])).then(t=>({default:t.SettingsWindow}))),Ca=()=>{const t=ne(j=>j.isSidebarOpen),n=ne(j=>j.activeMainTab),o=ne(j=>j.setIsMobile),i=ne(j=>j.isSessionSwitcherOpen),a=ne(j=>j.isSettingsDialogOpen),m=ne(j=>j.setSettingsDialogOpen),[x,c]=r.useState(!1);r.useEffect(()=>{a&&c(!0)},[a]),r.useEffect(()=>{const j=()=>ne.getState().closeMainSurfaces(),W=Ce.subscribe(($,F)=>{const ie=!!$.currentSessionId&&$.currentSessionId!==F.currentSessionId,ce=!!$.newSessionDraft?.open&&$.newSessionDraft!==F.newSessionDraft;(ie||ce)&&j()}),re=ne.subscribe(($,F)=>{$.activeMainTab!==F.activeMainTab&&j()});return()=>{W(),re()}},[]);const{isMobile:h}=at(),g=r.useRef(!1),[v,u]=r.useState(!1),[l,N]=r.useState(!1),[f,T]=r.useState(!1),[p,S]=r.useState(!1),k=r.useCallback(j=>{u(j),ne.getState().setSessionSwitcherOpen(j)},[]),O=r.useRef(typeof window>"u"?0:window.innerWidth),oe=r.useRef(null),z=r.useRef(!1),G=r.useRef(!1),Q=r.useRef(!1),y=r.useRef(null),b=r.useRef(null),X=Mt(-O.current),q=Ne.useRef(0),K=Mt(O.current),Y=Ne.useRef(0);Ne.useEffect(()=>{h&&(q.current=window.innerWidth,Y.current=window.innerWidth)},[h]),Ne.useEffect(()=>{if(!h)return;const j=()=>{const W=window.innerWidth;q.current=W,Y.current=W,v||X.get()<-10&&X.set(-W),l||K.get()>10&&K.set(W)};return window.addEventListener("resize",j),window.addEventListener("orientationchange",j),()=>{window.removeEventListener("resize",j),window.removeEventListener("orientationchange",j)}},[h,X,K,v,l]),Ne.useEffect(()=>{if(!h){T(!1);return}v&&T(!0);const j=q.current||O.current||(typeof window<"u"?window.innerWidth:0),W=Qe(X,v?0:-j,{type:"spring",stiffness:400,damping:35,mass:.8});return y.current=W,()=>W.stop()},[v,h,X]),Ne.useEffect(()=>{if(!h){S(!1);return}l&&S(!0);const j=Y.current||O.current||(typeof window<"u"?window.innerWidth:0),W=Qe(K,l?0:j,{type:"spring",stiffness:400,damping:35,mass:.8});return b.current=W,()=>W.stop()},[h,l,K]),Ne.useEffect(()=>{if(h)return X.on("change",j=>{const W=q.current||O.current,re=v||j>-W+.5;T($=>$===re?$:re)})},[h,X,v]),Ne.useEffect(()=>{if(h)return K.on("change",j=>{const W=Y.current||O.current,re=l||j<W-.5;S($=>$===re?$:re)})},[h,l,K]),Ne.useEffect(()=>{h&&!i&&v&&k(!1)},[i,h,v,k]),Ne.useEffect(()=>{if(!h){g.current=!1;return}g.current||(g.current=!0,k(!1),N(!1))},[h,k]),Ne.useEffect(()=>{if(!h||n!=="chat"||v||l||a)return;let j=!1,W;return($=>{W=window.setTimeout(()=>{if(j)return;const F=Ce.getState(),ie=ne.getState();ie.activeMainTab!=="chat"||ie.isSettingsDialogOpen||F.currentSessionId||F.newSessionDraft?.open||F.openNewSessionDraft({automatic:!0})},$)})(500),()=>{j=!0,W!==void 0&&window.clearTimeout(W)}},[n,h,a,v,l]),Ne.useEffect(()=>{!h||!a||(k(!1),N(!1))},[h,a,k]),r.useEffect(()=>{ne.getState().isMobile!==h&&o(h)},[h,o]);const ee=r.useCallback(()=>{v&&k(!1),N(!l)},[v,l,k]);Rr(oe,{enabled:h,leftOpen:v,rightOpen:l,leftWidth:()=>q.current||O.current||(typeof window<"u"?window.innerWidth:0),rightWidth:()=>Y.current||O.current||(typeof window<"u"?window.innerWidth:0),onLeftProgress:j=>{const W=q.current||O.current||(typeof window<"u"?window.innerWidth:0);X.set(W*(j-1))},onRightProgress:j=>{const W=Y.current||O.current||(typeof window<"u"?window.innerWidth:0);K.set(W*(1-j))},onLeftOpen:()=>{l&&N(!1),k(!0)},onLeftClose:()=>k(!1),onRightOpen:()=>{v&&k(!1),N(!0)},onRightClose:()=>N(!1),onDragStart:j=>{z.current=!0,j==="left"?(G.current=v,y.current?.stop(),f||T(!0)):(Q.current=l,b.current?.stop(),p||S(!0))},onDragEnd:(j,W)=>{if(z.current=!1,j==="left"&&typeof W=="boolean"){const re=G.current;if(W===re){const $=q.current||O.current||(typeof window<"u"?window.innerWidth:0),F=Qe(X,re?0:-$,{type:"spring",stiffness:400,damping:35,mass:.8});y.current=F}}if(j==="right"&&typeof W=="boolean"){const re=Q.current;if(W===re){const $=Y.current||O.current||(typeof window<"u"?window.innerWidth:0),F=Qe(K,re?0:$,{type:"spring",stiffness:400,damping:35,mass:.8});b.current=F}}}});const E=r.useMemo(()=>{if(!h&&n!=="terminal"&&n!=="diagram"||h&&n==="git"&&(l||p))return null;switch(n){case"git":return e.jsx(r.Suspense,{fallback:null,children:e.jsx(sn,{isActive:!0})});case"diff":return e.jsx(r.Suspense,{fallback:null,children:e.jsx(ya,{})});case"terminal":return e.jsx(bn,{onCloseView:()=>ne.getState().setActiveMainTab("chat")});case"files":return e.jsx(r.Suspense,{fallback:null,children:e.jsx(ba,{})});case"diagram":return e.jsx(r.Suspense,{fallback:null,children:e.jsx(va,{})});default:return null}},[n,h,p,l]),Z=n==="chat";return e.jsxs(Er,{children:[e.jsx(Tr,{}),e.jsxs("div",{"data-page-scroll-lock":"true",className:le("main-content-safe-area",h?"flex h-[100dvh] flex-col":"relative flex h-[100dvh]","bg-background"),children:[e.jsx(pa,{}),e.jsx(ga,{}),e.jsx(_r,{}),h?e.jsxs(wa,{value:{leftDrawerOpen:v,rightDrawerOpen:l,toggleLeftDrawer:()=>{const j=!v;l&&N(!1),k(j)},toggleRightDrawer:ee,leftDrawerX:X,rightDrawerX:K,leftDrawerWidth:q,rightDrawerWidth:Y,setMobileLeftDrawerOpen:k,setRightSidebarOpen:N},children:[!a&&e.jsx(Ot,{onToggleLeftDrawer:()=>{const j=!v;l&&N(!1),k(j)},onToggleRightDrawer:()=>{ee()},leftDrawerOpen:v,rightDrawerOpen:l}),e.jsx("div",{"data-page-scroll-lock":"true",className:le("flex flex-1 overflow-hidden relative",a&&"hidden"),children:e.jsxs("main",{ref:oe,className:"w-full h-full overflow-hidden bg-background relative","data-page-scroll-lock":"true",style:{touchAction:"pan-x pan-y"},children:[e.jsx("div",{className:le("absolute inset-0",!Z&&"invisible"),children:e.jsx(Pe,{children:e.jsx($t,{active:Z&&!a})})}),E&&e.jsx("div",{className:"absolute inset-0",children:e.jsx(Pe,{children:E})}),e.jsx(Pe,{children:e.jsx(Wt,{})}),e.jsx(It.div,{className:le("absolute inset-0 z-20 bg-sidebar",!f&&"pointer-events-none invisible"),"data-page-scroll-lock":"true",style:{x:X},"aria-hidden":!v,children:e.jsx(Pe,{children:e.jsx(Ft,{mobileVariant:!0,isVisible:f})})}),e.jsx(It.div,{className:le("absolute inset-0 z-20 bg-sidebar",!p&&"pointer-events-none invisible"),"data-page-scroll-lock":"true",style:{x:K},"aria-hidden":!l,children:e.jsx(Pe,{children:l||p?e.jsx(r.Suspense,{fallback:null,children:e.jsx(sn,{isActive:l})}):null})})]})}),a&&e.jsx("div",{className:"absolute inset-0 z-10 bg-background",style:{paddingTop:"var(--oc-safe-area-top, 0px)"},children:e.jsx(Pe,{children:e.jsx(r.Suspense,{fallback:null,children:e.jsx(Sa,{onClose:()=>m(!1)})})})})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ar,{}),e.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[e.jsx(Ws,{isOpen:t,isMobile:h,children:e.jsx(Ft,{isVisible:t})}),e.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[e.jsx(Ot,{}),e.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[e.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden border-t border-border bg-background","data-page-scroll-lock":"true",children:e.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true",children:e.jsxs("div",{className:"relative flex flex-1 min-h-0 min-w-0 overflow-hidden","data-page-scroll-lock":"true","data-chat-area":"true",children:[e.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[e.jsx("div",{className:le("absolute inset-0",!Z&&"invisible"),children:e.jsx(Pe,{children:e.jsx($t,{active:Z&&!a})})}),E&&e.jsx("div",{className:"absolute inset-0",children:e.jsx(Pe,{children:E})}),e.jsx(Pe,{children:e.jsx(Wt,{})})]}),e.jsx(ra,{})]})})}),e.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:e.jsx(Pe,{children:e.jsx(da,{})})})]})]})]}),x?e.jsx(r.Suspense,{fallback:null,children:e.jsx(ja,{open:a,onOpenChange:m})}):null]})]})]})},Na=()=>(Ss(),Ir(),e.jsxs(Lr,{children:[e.jsx(js,{embeddedBackgroundWorkEnabled:!0}),e.jsx(Cs,{}),e.jsx(Ca,{}),e.jsx(Or,{}),e.jsx(Ns,{}),e.jsx(ks,{})]}));function ka({apis:t}){const n=t??xn(),[o,i]=r.useState(0);return r.useEffect(()=>mr(a=>{if(a.runtimeKey===a.previousRuntimeKey){gr();return}Dr(a),i(m=>m+1)}),[]),r.useEffect(()=>{let a=!0,m=null,x=null,c=null;return xr().then(()=>{a&&(m=xs(),x=ws(),c=Mr())}),()=>{a=!1,m?.(),x?.(),c?.()}},[o]),r.useEffect(()=>{n&&wr(n)},[n]),n?e.jsx(Pe,{children:e.jsx("div",{className:"h-full w-full overflow-hidden bg-background text-foreground",children:e.jsx(ys,{apis:n,children:e.jsx(bs,{children:e.jsx(vs,{children:e.jsx(Na,{})})},o)})})}):e.jsx(Pe,{children:e.jsx("div",{className:"h-full w-full overflow-hidden bg-background text-foreground"})})}const Un=document.getElementById("root");if(!Un)throw new Error("Root element not found");Qn.createRoot(Un).render(e.jsx(Ne.StrictMode,{children:e.jsx(Ps,{children:e.jsx(Rs,{children:e.jsx(ka,{apis:xn()??void 0})})})}));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/renderMobileApp-
|
|
2
|
-
import{_ as a}from"./vendor-vite-runtime-DD1OZmLC.js";import{c as m,g as f}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/renderMobileApp-CQ9tWYIj.js","assets/vendor-boot-Dgb9NVFe.js","assets/vendor-react-DASdDPIk.js","assets/vendor-clsx-B-dksMZM.js","assets/index-BnZVqcki.js","assets/vendor-zustand-CUi8eEds.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/index-BnieExes.css","assets/pi-session-focus-preference-Bmk1iOvn.js","assets/useAppFontEffects-DviRbaCJ.js","assets/runtimeSurface-DBiUWYK2.js","assets/nativeFileSave-BzhtrDoD.js","assets/runtimeEndpointReset-CtK4C_5h.js","assets/SessionUnreadDot-CmEF9sxM.js","assets/permissionStore-B9Hkrqny.js","assets/runtimeEndpointReset-BV3KOtdA.css","assets/vendor-xterm-xterm-css-DDGTF8rc.css","assets/vendor-aparajita-capacitor-secure-storage-BYohCVY0.js","assets/SettingsView-BiwlwnTK.js","assets/vendor-qrcode-Dv4uniC1.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/collapsible-C7oyikVm.js","assets/vendor-base-ui-BscvGUFt.js","assets/useSwitcherItems-Dej8BzXI.js","assets/vendor-katex-css-Cp579UoJ.css","assets/main-9O5IAtT_.js","assets/contextFileOpenGuard-BBzqKGei.js","assets/useFilesViewSearch-D2Au5Xgt.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as a}from"./vendor-vite-runtime-DD1OZmLC.js";import{c as m,g as f}from"./index-BnZVqcki.js";import{r as w}from"./runtimeSurface-DBiUWYK2.js";/* empty css */import"./vendor-zustand-CUi8eEds.js";import"./vendor-react-DASdDPIk.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";function _(t={}){const{immediate:r=!1,onNeedRefresh:i,onOfflineReady:n,onRegistered:s,onRegisteredSW:c,onRegisterError:d}=t;let o,u;const l=async(e=!0)=>{await u};async function p(){if("serviceWorker"in navigator){if(o=await a(async()=>{const{Workbox:e}=await import("./vendor-workbox-window-BIl4cyR9.js");return{Workbox:e}},[]).then(({Workbox:e})=>new e("/sw.js",{scope:"/",type:"classic"})).catch(e=>{d?.(e)}),!o)return;o.addEventListener("activated",e=>{(e.isUpdate||e.isExternal)&&window.location.reload()}),o.addEventListener("installed",e=>{e.isUpdate||n?.()}),o.register({immediate:r}).then(e=>{c?c("/sw.js",e):s?.(e)}).catch(e=>{d?.(e)})}}return u=p(),l}const v=w(),g=()=>!(!("serviceWorker"in navigator)||!window.isSecureContext||window.location.protocol!=="http:"&&window.location.protocol!=="https:"||document.prerendering||String(document.visibilityState)==="prerender"),S=t=>{let r=!1;const i=()=>{r||g()&&(r=!0,t())},n=()=>{setTimeout(i,0)};document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0}),(document.prerendering||String(document.visibilityState)==="prerender")&&document.addEventListener("visibilitychange",i,{once:!0})},E=()=>{S(()=>{try{_({onRegisterError(t){console.warn("[PWA] service worker registration skipped:",t)}})}catch(t){console.warn("[PWA] service worker registration skipped:",t)}})},R=async()=>{if(window.__PICHAMBER_RUNTIME_APIS__=m(),v==="mobile"){const{renderMobileApp:t}=await a(async()=>{const{renderMobileApp:r}=await import("./renderMobileApp-CQ9tWYIj.js").then(i=>i.r);return{renderMobileApp:r}},__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]));t();return}await f(),await a(()=>import("./main-9O5IAtT_.js"),__vite__mapDeps([27,1,2,3,4,5,6,7,8,9,14,11,12,13,15,16,17,18,28,29,26]))};R();E();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as E}from"./vendor-vite-runtime-DD1OZmLC.js";import{g as v,B as $}from"./vendor-marked-CX41MkDF.js";import{p}from"./vendor-dompurify-r8glNMJW.js";import{df as C,dg as O,dh as I}from"./useAppFontEffects
|
|
1
|
+
import{_ as E}from"./vendor-vite-runtime-DD1OZmLC.js";import{g as v,B as $}from"./vendor-marked-CX41MkDF.js";import{p}from"./vendor-dompurify-r8glNMJW.js";import{df as C,dg as O,dh as I}from"./useAppFontEffects-DviRbaCJ.js";import{p as P}from"./vendor-remend-BWYYytN3.js";const R=e=>e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"),x=["script","style"],A=e=>v.lexer(e),H=e=>/^\[[^\]]+\]:\s+\S+/m.test(e)||/^\[\^[^\]]+\]:\s+/m.test(e),D=e=>{const t=e.match(/^[ \t]{0,3}(`{3,}|~{3,})/);if(!t)return!1;const n=t[1];if(!n)return!1;const r=n[0],s=n.length,a=e.trimEnd().split(`
|
|
2
2
|
`).at(-1)?.trim()??"";return!new RegExp(`^[\\t ]{0,3}${r}{${s},}[\\t ]*$`).test(a)},pe=e=>{const t=e.replace(/^\n+/,"");return!!(/^[ \t]{0,3}(`{3,}|~{3,})/.test(t)||/^[ \t]{0,3}(?:> |[-*+] |\d+[.)] )/.test(t))},N=e=>{try{return P(e,{linkMode:"text-only"})}catch{return e}},g=(e,t)=>[{raw:e,src:e,mode:t?"live":"full",highlight:!t}],y=(e,t)=>{let n=-1;for(let s=e.length-1;s>=0;s-=1)if(e[s]?.type!=="space"){n=s;break}if(n<0)return[];const r=[];for(let s=0;s<e.length;s+=1){const a=e[s];if(!a||a.type==="space")continue;const i=a.raw??"",c=t.markLastLive&&s===n,o=a.type==="code"&&D(i);r.push({raw:i,src:o||c?i:N(i),mode:c?"live":"full",highlight:!t.cheap&&!o})}return r},b=(e,t,n=A)=>[{raw:e,src:e,mode:"full",highlight:!0}],F=2;class G{constructor(t=A){this.lex=t}prevText="";frozenSrc="";frozenBlocks=[];cached=null;update(t){if(this.cached&&t===this.prevText)return this.cached;if(this.prevText&&!t.startsWith(this.prevText)&&(this.frozenSrc="",this.frozenBlocks=[]),this.prevText=t,H(t))return this.frozenSrc="",this.frozenBlocks=[],this.cached=g(t,!0),this.cached;this.frozenSrc&&!t.startsWith(this.frozenSrc)&&(this.frozenSrc="",this.frozenBlocks=[]);const n=t.slice(this.frozenSrc.length);let r;try{r=this.lex(n)}catch{return this.cached=g(t,!0),this.cached}const s=[];for(let o=0;o<r.length;o+=1)r[o]?.type!=="space"&&s.push(o);const a=Math.max(0,s.length-F);if(a>0){const o=(s[a-1]??-1)+1,l=r.slice(0,o),d=y(l,{markLastLive:!1,cheap:!0});this.frozenBlocks=[...this.frozenBlocks,...d],this.frozenSrc+=l.map(m=>m.raw??"").join(""),r=r.slice(o)}const i=y(r,{markLastLive:!0,cheap:!0}),c=i.length>0?[...this.frozenBlocks,...i]:this.frozenBlocks.length>0?this.frozenBlocks:g(t,!0);return this.cached=c,c}}const j=32,h=new Map,q=e=>{const t=h.get(e);if(t)return h.delete(e),h.set(e,t),t;const n=new G;for(h.set(e,n);h.size>j;){const r=h.keys().next().value;if(typeof r!="string")break;h.delete(r)}return n},_=e=>{h.delete(e)},me=(e,t)=>{if(!e||e.length===0||e.length!==t.length||t[t.length-1]?.mode!=="live"||e[e.length-1]?.mode!=="live")return!1;for(let r=0;r<t.length-1;r+=1){const s=e[r],a=t[r];if(!s||!a||s.mode!=="full"||a.mode!=="full"||s.raw!==a.raw)return!1}return!0},u=e=>e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">");let k=null;const W=()=>(k||(k=E(()=>import("./vendor-katex-DZG0Ov6p.js"),[]).then(e=>e.default??e)),k),w=async(e,t,n)=>{try{return(await W()).renderToString(e,{displayMode:n,throwOnError:!1})}catch{return t}},B={name:"inlineMath",level:"inline",start(e){const t=e.indexOf("\\(");return t<0?void 0:t},tokenizer(e){const t=/^\\\(([\s\S]+?)\\\)/.exec(e);if(t)return{type:"inlineMath",raw:t[0],text:t[1]??""}},async renderer(e){const t=e;return w(t.text,t.raw,!1)}},T={name:"blockMath",level:"block",start(e){const t=e.indexOf("\\[");return t<0?void 0:t},tokenizer(e){const t=/^\\\[([\s\S]+?)\\\]/.exec(e);if(t)return{type:"blockMath",raw:t[0],text:t[1]??""}},async renderer(e){const t=e;return w(t.text,t.raw,!0)}},U={html({text:e}){return R(e)},link({href:e,title:t,text:n}){const r=e??"";if(C(r))return`<span data-pichamber-agent-mention="true" class="text-primary">${n}</span>`;const a=O(r);if(a)return`<a href="${u(r)}" data-skill-name="${u(a)}" class="text-primary hover:underline">${n}</a>`;const i=t?` title="${u(t)}"`:"";return`<a href="${u(r)}"${i} class="external-link" target="_blank" rel="noopener noreferrer">${n}</a>`}},S={gfm:!0,breaks:!1,renderer:U},X=new $(S),V=new $({...S,async:!0,extensions:[B,T]});v.use({...S,extensions:[B,T]});const Z=async e=>{const t=e.split(/(\$\$[\s\S]*?\$\$)/g);return(await Promise.all(t.map(async r=>{const s=/^\$\$([\s\S]*?)\$\$$/.exec(r)?.[1];return s===void 0?r:w(s,r,!0)}))).join("")},J=async e=>{if(e.indexOf("$")===-1)return e;const t=/(<(?:pre|code|kbd)[^>]*>[\s\S]*?<\/(?:pre|code|kbd)>)/gi,n=e.split(t);return(await Promise.all(n.map(async(s,a)=>a%2===1?s:Z(s)))).join("")},Q=/<pre><code(?:\s+class="language-([^"]*)")?>([\s\S]*?)<\/code><\/pre>/g,Y=1200,K=(e,t)=>{let n=1;for(let r=0;r<e.length;r+=1)if(e.charCodeAt(r)===10&&++n>t)return!0;return!1},ee=e=>e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&"),te=async e=>{const t=[...e.matchAll(Q)];if(t.length===0)return e;const n=Y;let r=e;for(const s of t){const[a,i,c]=s,o=(i||"text").toLowerCase();if(o==="mermaid")continue;const l=ee(c??"");if(K(l,n)){r=r.replace(a,()=>a.replace("<pre",`<pre data-md-lang="${o}"`));continue}const d=await I(l,o);if(d){const m=d.replace(/^<pre/,`<pre data-md-lang="${o}"`);r=r.replace(a,()=>m)}}return r},re={USE_PROFILES:{html:!0,mathMl:!0,svg:!0},ADD_TAGS:["svg","path","g","rect","line","polygon","polyline","circle","ellipse","text","tspan","defs","marker"],ADD_ATTR:["d","viewBox","preserveAspectRatio","xmlns","target","fill","stroke","stroke-width","transform","points","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","style"],FORBID_TAGS:[...x],FORBID_CONTENTS:[...x]};let z=!1;const ne=()=>{z||typeof window>"u"||!p.isSupported||(z=!0,p.addHook("afterSanitizeAttributes",e=>{e instanceof HTMLAnchorElement&&e.target==="_blank"&&e.setAttribute("rel","noopener noreferrer")}))},L=e=>p.isSupported?(ne(),p.sanitize(e,re)):"",se=240,f=new Map,ae=e=>{let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)},M=(e,t)=>{if(f.delete(e),f.set(e,t),f.size<=se)return;const n=f.keys().next().value;n&&f.delete(n)},oe=async e=>{const t=await V.parse(e.src),n=e.highlight?await J(t):t,r=e.highlight?await te(n):n;return L(r)},ie=e=>{if(!e)return"";const t=X.parse(e);return L(t)},ce=async(e,t,n)=>{if(!e)return n&&_(n),[];let r;return t?r=q(n).update(e):(_(n),r=b(e)),Promise.all(r.map(async(s,a)=>{if(s.mode==="live")return{id:`live:${a}`,html:"",mode:"live",raw:s.raw};const i=ae(s.raw),c=`${i}:${s.mode}:${s.highlight?1:0}`,o=`${n}:${a}:${s.mode}`,l=f.get(o);if(l&&l.hash===i)return M(o,l),{id:c,html:l.html,mode:s.mode,raw:s.raw};const d=await oe(s);return M(o,{hash:i,html:d}),{id:c,html:d,mode:s.mode,raw:s.raw}}))},ge=Object.freeze(Object.defineProperty({__proto__:null,renderMarkdownBlocks:ce,renderMarkdownSync:ie},Symbol.toStringTag,{value:"Module"}));export{ce as a,pe as b,me as i,ge as m,ie as r,q as s};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/renderElectronMiniChatApp-R5o9NwFC.js","assets/vendor-boot-Dgb9NVFe.js","assets/vendor-react-DASdDPIk.js","assets/vendor-clsx-B-dksMZM.js","assets/index-BnZVqcki.js","assets/vendor-zustand-CUi8eEds.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/index-BnieExes.css","assets/pi-session-focus-preference-Bmk1iOvn.js","assets/useAppFontEffects-DviRbaCJ.js","assets/runtimeSurface-DBiUWYK2.js","assets/nativeFileSave-BzhtrDoD.js","assets/vendor-katex-css-Cp579UoJ.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as o}from"./vendor-vite-runtime-DD1OZmLC.js";import{c as t}from"./index-BnZVqcki.js";/* empty css */import"./vendor-zustand-CUi8eEds.js";import"./vendor-react-DASdDPIk.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";window.__PICHAMBER_RUNTIME_APIS__=t();o(async()=>{const{renderElectronMiniChatApp:r}=await import("./renderElectronMiniChatApp-R5o9NwFC.js");return{renderElectronMiniChatApp:r}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14])).then(({renderElectronMiniChatApp:r})=>{r()});
|