@pi-chamber/web 0.2.2 → 0.3.0
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/bin/cli.test.js +6 -8
- package/bin/lib/cli-tunnel-capabilities.js +0 -2
- package/dist/assets/{CommitSection-DPjTv8fA.js → CommitSection-BpbMC0et.js} +1 -1
- package/dist/assets/{DiagramEditor-ChOor9l9.js → DiagramEditor-dFTMKHuO.js} +1 -1
- package/dist/assets/{DiagramView-3hAT86v_.js → DiagramView-DVw_8Px1.js} +1 -1
- package/dist/assets/{DiffView-D1dyOiw2.js → DiffView-CkoY1oAM.js} +1 -1
- package/dist/assets/{FilesView-BCzghrc7.js → FilesView-C0hyg2pa.js} +6 -6
- package/dist/assets/{GitView-CYF1E1p4.js → GitView-D36hpDsb.js} +4 -4
- package/dist/assets/{JsonTreeView-CrJO6LNu.js → JsonTreeView-BF8S-bPN.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-BmKjrkGD.js → MarkdownRendererImpl-BVNChdig.js} +1 -1
- package/dist/assets/{PatchDiff-DgvPLx6x.js → PatchDiff-B--OaNB1.js} +1 -1
- package/dist/assets/{PierreDiffViewer-InnT0JVA.js → PierreDiffViewer-0Qkp9ICt.js} +1 -1
- package/dist/assets/{SessionSwitcherDropdown-C0OdvirK.js → SessionSwitcherDropdown-cFWgy1td.js} +101 -102
- package/dist/assets/SettingsView-D3ZZyjU3.js +4 -0
- package/dist/assets/SettingsWindow-BuJCvYoR.js +1 -0
- package/dist/assets/{ToolOutputDialog-gzwcb8nI.js → ToolOutputDialog-Bi9BoEe7.js} +4 -4
- package/dist/assets/{ToolPartDiffPreview-C45V5bhy.js → ToolPartDiffPreview-DGX7N4zr.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-uKfnkQWb.js → VirtualizedFileDiff-CxraYoDZ.js} +1 -1
- package/dist/assets/{collapsible-Bq8sDiKS.js → collapsible-d4-HChej.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-BPgZ_RSe.js → computeVirtualFileMetrics-BuD14qFL.js} +2 -2
- package/dist/assets/{contextFileOpenGuard-CydO7PkI.js → contextFileOpenGuard-DirV-hCs.js} +1 -1
- package/dist/assets/{index-BSuNNtBh.js → index-BWmmf5yJ.js} +1 -1
- package/dist/assets/{index-CH7o4-_q.js → index-DEYblXCW.js} +7 -7
- package/dist/assets/index-DLKBsLKY.css +1 -0
- package/dist/assets/{isDiffPlainText-f9b4cKNo.js → isDiffPlainText-LoMmNzmX.js} +1 -1
- package/dist/assets/{isFilePlainText-BjESb-gU.js → isFilePlainText-3Hj9i02t.js} +1 -1
- package/dist/assets/{main-B508FBXr.js → main-BsszlAdQ.js} +2 -2
- package/dist/assets/main-CUvZIN16.js +133 -0
- package/dist/assets/{markdownCore-BFmf8a-O.js → markdownCore-sGxk8jrc.js} +2 -2
- package/dist/assets/{miniChat-BTlz8IPL.js → miniChat-C6SDQL4G.js} +2 -2
- package/dist/assets/{mobile-DBkrRt80.js → mobile-DBW3XDmZ.js} +2 -2
- package/dist/assets/renderElectronMiniChatApp-B1_fTdN-.js +1 -0
- package/dist/assets/renderMobileApp-CFxZc_1a.js +14 -0
- package/dist/assets/{runtimeSurface-Bec4O8FD.js → runtimeSurface-9aJdtQbh.js} +1 -1
- package/dist/assets/{useInlineCommentController-CHmIm0Rr.js → useInlineCommentController-Cl--s6vE.js} +2 -2
- package/dist/assets/usePanelSlide-D5ffPTGM.js +56 -0
- package/dist/assets/{useWindowTitle-CE5N_NeU.js → useWindowTitle-C-AZD713.js} +3 -3
- package/dist/assets/{vendor-base-ui-DwfTg5wD.js → vendor-base-ui-DL8r2fgQ.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-q1yHU1R9.js → vendor-codemirror-language-data-HC9JT4I3.js} +2 -2
- package/dist/assets/{web-components-CLirSfwt.js → web-components-skJ_VpnT.js} +4 -4
- 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/package-manager.js +0 -34
- package/server/lib/pi/routes.js +32 -2
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +1 -1
- package/server/lib/pi/session-daemon/runtime-registry.js +3 -0
- package/server/lib/pi/session-daemon/session-daemon.js +150 -10
- package/server/lib/pi/session-daemon/session-daemon.test.js +22 -0
- package/server/lib/tunnels/DOCUMENTATION.md +6 -7
- package/server/lib/tunnels/executable-search.test.js +4 -4
- package/server/lib/tunnels/install-help.js +0 -10
- package/server/lib/tunnels/install-help.test.js +0 -9
- package/server/lib/tunnels/types.js +0 -1
- package/dist/assets/SettingsView-JAfC_cBL.js +0 -3
- package/dist/assets/SettingsWindow-BBEsjcJE.js +0 -1
- package/dist/assets/index-o4Eea60G.css +0 -1
- package/dist/assets/main-nG4uFyAy.js +0 -133
- package/dist/assets/renderElectronMiniChatApp-DW3fSR5w.js +0 -1
- package/dist/assets/renderMobileApp-9qkroKty.js +0 -14
- package/dist/assets/usePanelSlide-DCX8qQ4K.js +0 -56
- package/server/lib/ngrok-tunnel.js +0 -343
- package/server/lib/ngrok-tunnel.test.js +0 -50
- package/server/lib/tunnels/providers/ngrok.js +0 -32
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DiffView-D1dyOiw2.js","assets/vendor-react-DYyjh7Q0.js","assets/vendor-scheduler-7OC5HNn7.js","assets/index-CH7o4-_q.js","assets/vendor-zustand-CnsBKjP5.js","assets/index-o4Eea60G.css","assets/SessionSwitcherDropdown-C0OdvirK.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/runtimeSurface-Bec4O8FD.js","assets/vendor-dnd-kit-core-GipZW2tY.js","assets/vendor-dnd-kit-utilities-CrOcp0Bp.js","assets/vendor-dnd-kit-accessibility-Cv52zwWT.js","assets/vendor-dnd-kit-sortable-Ct2QxIHb.js","assets/vendor-base-ui-DwfTg5wD.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-react-dom-sVFnuruh.js","assets/vendor-floating-ui-dom-Bkw82kL9.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-use-sync-external-store-B7OScDIw.js","assets/vendor-cmdk-BCEUzcHE.js","assets/vendor-radix-ui-react-dialog-jX3Dld8c.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-D1GnwnP9.js","assets/vendor-radix-ui-react-context-CM4yFQ2I.js","assets/vendor-radix-ui-react-id-BcxRjnbX.js","assets/vendor-radix-ui-react-use-layout-effect-0fyGwS2_.js","assets/vendor-radix-ui-react-use-controllable-state-C_ecoh35.js","assets/vendor-radix-ui-react-dismissable-layer-M7LsH3yL.js","assets/vendor-radix-ui-react-primitive-CfpW6_IT.js","assets/vendor-radix-ui-react-slot-BxUc3Pvz.js","assets/vendor-radix-ui-react-use-callback-ref-UKEWHtoP.js","assets/vendor-radix-ui-react-use-escape-keydown-Co13lHGj.js","assets/vendor-radix-ui-react-focus-scope-C2K7lNPv.js","assets/vendor-radix-ui-react-portal-xlJWBfDg.js","assets/vendor-radix-ui-react-presence-Btn-Dp7L.js","assets/vendor-radix-ui-react-focus-guards-D5MZ0nQs.js","assets/vendor-react-remove-scroll-CfeMe0DL.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-C9YRs2nU.js","assets/vendor-react-style-singleton-B1H4bWSG.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-C-AuTczP.js","assets/vendor-use-callback-ref-CJB0R85I.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-E2vgV9K3.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-CNWM3Q8V.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-DSzLbZiS.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-BUlYhQ3o.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-BS2SpSAZ.js","assets/vendor-codemirror-lang-json-CqayksDf.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-Ba8JZ6fp.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-DK27qQri.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-CvO36Y1p.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-q1yHU1R9.js","assets/vendor-codemirror-lang-python-_2bIYTiJ.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-RrgJ8H_6.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tanstack-react-virtual-IrbCBGJ4.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-framer-motion-DJASDzNt.js","assets/vendor-motion-dom-DJLgZh4Q.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-sonner-dWA7qvjr.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/PierreDiffViewer-InnT0JVA.js","assets/web-components-CLirSfwt.js","assets/computeVirtualFileMetrics-BPgZ_RSe.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-BmJyTmjJ.js","assets/vendor-pierre-theming-C6Z4M5_u.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/VirtualizedFileDiff-uKfnkQWb.js","assets/isDiffPlainText-f9b4cKNo.js","assets/vendor-diff-C3JhlQdm.js","assets/usePanelSlide-DCX8qQ4K.js","assets/permissionStore-BRcQ9Jgt.js","assets/usePanelSlide-BV3KOtdA.css","assets/useInlineCommentController-CHmIm0Rr.js","assets/collapsible-Bq8sDiKS.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/contextFileOpenGuard-CydO7PkI.js","assets/FilesView-BCzghrc7.js","assets/vendor-codemirror-search-8kyQdB3f.js","assets/vendor-replit-codemirror-vim-BJY5fGLS.js","assets/JsonTreeView-CrJO6LNu.js","assets/Virtualizer-BxW2CJGB.js","assets/isFilePlainText-BjESb-gU.js","assets/DiagramEditor-ChOor9l9.js","assets/vendor-react-drawio-Boqanm0j.js","assets/GitView-CYF1E1p4.js","assets/CommitSection-DPjTv8fA.js","assets/DiagramView-3hAT86v_.js","assets/SettingsView-JAfC_cBL.js","assets/vendor-qrcode-COsmt6jn.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/SettingsWindow-BBEsjcJE.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{R as r,j as e,r as _e,e as Bn}from"./vendor-react-DYyjh7Q0.js";import"./vendor-katex-CHD9BdDO.js";import{u as Q,x as zn,y as Un,z as Hn,A as an,n as $e,B as Vn,a as ln,C as cn,r as it,D as Kn,E as Xn,F as qn,e as lt,G as dn,H as un,I as Gn,l as Yn,J as Jn,K as Qn,L as Zn,t as er,v as tr,o as hn,q as nr}from"./index-CH7o4-_q.js";import{_ as Le}from"./vendor-vite-runtime-DD1OZmLC.js";import{l as rr,p as sr,q as or,t as ar,v as ir,w as lr,P as pn,x as cr,T as fn,y as dr,z as ur,B as hr,m as pr,o as fr,j as mr,k as gr,H as Lt,C as Ot,A as $t,S as Wt,n as xr,f as wr,h as yr,F as br}from"./usePanelSlide-DCX8qQ4K.js";import{f as be,X as Me,I as U,as as vr,T as Be,q as ze,at as Sr,B as pe,s as Ue,au as jr,F as yt,av as bt,t as he,aw as Cr,C as vt,E as et,G as mn,ax as gn,Y as Ft,ay as kr,D as St,w as jt,x as Ct,y as kt,z as Nt,A as Nr,az as Pr,aA as Er,h as Ie,aB as Rr,aC as Tr,a5 as Dr,aD as Ye,aE as _r,aF as Ar,aG as Mr,aH as Ir,aI as Lr,U as We,aJ as xn,H as wn,aK as Or,aL as $r,aM as Wr,aN as Fr,aO as Br,aP as Pt,aQ as Et,aR as Rt,o as ct,aS as zr,P as yn,aT as Ur,aU as Hr,aV as Tt,K as bn,aW as Vr,aX as Kr,aY as Xr,aZ as Bt,a_ as Je,a$ as qr,c as Gr,d as Yr,b0 as Jr,b as zt,r as ht,b1 as Qr,b2 as Zr,b3 as es,b4 as vn,b5 as Sn,b6 as ts,b7 as ns,b8 as rs,b9 as ss,ba as qe,bb as Ge,bc as os,bd as as,be as is,bf as ls,ae as cs,ad as ds,af as us,ab as hs,ag as ps,ah as fs,ai as ms,ap as gs,aq as xs,ar as ws}from"./SessionSwitcherDropdown-C0OdvirK.js";import{v as jn,g as Cn}from"./contextFileOpenGuard-CydO7PkI.js";import{c as ys,d as Ut,T as bs,M as vs,D as Ss,e as js}from"./vendor-dnd-kit-core-GipZW2tY.js";import{a as Cs,S as ks,v as Ns,u as Ps}from"./vendor-dnd-kit-sortable-Ct2QxIHb.js";import{C as Es}from"./vendor-dnd-kit-utilities-CrOcp0Bp.js";import{u as Ht,a as nt,m as Vt}from"./vendor-framer-motion-DJASDzNt.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zustand-CnsBKjP5.js";import"./vendor-base-ui-DwfTg5wD.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-react-dom-sVFnuruh.js";import"./vendor-floating-ui-dom-Bkw82kL9.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-use-sync-external-store-B7OScDIw.js";import"./vendor-tanstack-react-virtual-IrbCBGJ4.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./permissionStore-BRcQ9Jgt.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./runtimeSurface-Bec4O8FD.js";import"./vendor-cmdk-BCEUzcHE.js";import"./vendor-radix-ui-react-dialog-jX3Dld8c.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-D1GnwnP9.js";import"./vendor-radix-ui-react-context-CM4yFQ2I.js";import"./vendor-radix-ui-react-id-BcxRjnbX.js";import"./vendor-radix-ui-react-use-layout-effect-0fyGwS2_.js";import"./vendor-radix-ui-react-use-controllable-state-C_ecoh35.js";import"./vendor-radix-ui-react-dismissable-layer-M7LsH3yL.js";import"./vendor-radix-ui-react-primitive-CfpW6_IT.js";import"./vendor-radix-ui-react-slot-BxUc3Pvz.js";import"./vendor-radix-ui-react-use-callback-ref-UKEWHtoP.js";import"./vendor-radix-ui-react-use-escape-keydown-Co13lHGj.js";import"./vendor-radix-ui-react-focus-scope-C2K7lNPv.js";import"./vendor-radix-ui-react-portal-xlJWBfDg.js";import"./vendor-radix-ui-react-presence-Btn-Dp7L.js";import"./vendor-radix-ui-react-focus-guards-D5MZ0nQs.js";import"./vendor-react-remove-scroll-CfeMe0DL.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-C9YRs2nU.js";import"./vendor-react-style-singleton-B1H4bWSG.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-C-AuTczP.js";import"./vendor-use-callback-ref-CJB0R85I.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-E2vgV9K3.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-DSzLbZiS.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-BUlYhQ3o.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-BS2SpSAZ.js";import"./vendor-codemirror-lang-json-CqayksDf.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-Ba8JZ6fp.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-DK27qQri.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-CvO36Y1p.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-q1yHU1R9.js";import"./vendor-codemirror-lang-python-_2bIYTiJ.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-RrgJ8H_6.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-sonner-dWA7qvjr.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-dnd-kit-accessibility-Cv52zwWT.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";const Kt=280,Xt=280,qt=500,Rs=({isOpen:t,isMobile:n,children:s,className:o,topBar:a})=>{const c=Q(E=>E.sidebarWidth),y=Q(E=>E.setSidebarWidth),[u,h]=r.useState(!1),g=r.useRef(0),b=r.useRef(c||Kt),p=r.useRef(null),d=r.useRef(null),j=r.useRef(null),f=r.useCallback(E=>Math.min(qt,Math.max(Xt,E)),[]),O=r.useCallback(E=>{const w=j.current;w&&(w.style.width=`${E}px`,w.style.minWidth=`${E}px`,w.style.maxWidth=`${E}px`,w.style.setProperty("--oc-left-sidebar-width",`${E}px`))},[]);r.useEffect(()=>{n&&u&&h(!1)},[n,u]),r.useEffect(()=>{u||(p.current=null,d.current=null)},[u]);const P=rr(t);if(n)return null;const I=Math.min(qt,Math.max(Xt,c||Kt)),$=t?I:0,F=E=>{if(t){try{E.currentTarget.setPointerCapture(E.pointerId)}catch{}d.current=E.pointerId,h(!0),g.current=E.clientX,b.current=$,p.current=$,O($),E.preventDefault()}},W=E=>{if(n||!u||d.current!==E.pointerId)return;const w=E.clientX-g.current,_=f(b.current+w);p.current!==_&&(p.current=_,O(_))},k=E=>{if(d.current!==E.pointerId||n)return;try{E.currentTarget.releasePointerCapture(E.pointerId)}catch{}const w=f(p.current??$);d.current=null,p.current=null,h(!1),y(w)},v=u?p.current??$:$,C=u?v:$;return e.jsxs("aside",{ref:j,className:be("relative flex h-full overflow-hidden border-r border-border motion-reduce:transition-none","bg-sidebar",!t&&"border-r-0",o),style:{width:`${C}px`,minWidth:`${C}px`,maxWidth:`${C}px`,"--oc-left-sidebar-width":`${u?v:I}px`,overflowX:"clip",transform:u||P.slidIn?"translateX(0)":"translateX(-100%)",transition:u?"none":P.transition},"aria-hidden":!t||C===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:be("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",u&&"bg-[var(--interactive-border)]"),onPointerDown:F,onPointerMove:W,onPointerUp:k,onPointerCancel:k,role:"separator","aria-orientation":"vertical","aria-label":"Resize left panel"}),e.jsxs("div",{className:be("relative z-10 flex h-full shrink-0 flex-col",u&&"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(Me,{children:s})})]})]})},Ts=t=>t.slice().sort((n,s)=>n.type!==s.type?n.type==="directory"?-1:1:n.name.localeCompare(s.name)),Pe=t=>{if(!t)return"";const n=t.replace(/\\/g,"/"),s=n.startsWith("//");let o=n.replace(/\/+$/g,"");return o=o.replace(/\/+/g,"/"),s&&!o.startsWith("//")&&(o=`/${o}`),o===""?n.startsWith("/")?"/":"":o},kn=(t,n)=>{const s=Pe(n),o=Pe(t).replace(/\/+$/,"");return s===o?".":!o||!s.startsWith(`${o}/`)?s:s.slice(o.length+1)},Ds=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),_s=new Set(["node_modules"]),As=t=>_s.has(t),Ms=t=>{const n=Pe(t);return n==="node_modules"||n.endsWith("/node_modules")||n.includes("/node_modules/")},Is=8,Oe=new Map,Dt=t=>JSON.stringify([ln(),t]),Ls=t=>{const n=Dt(t),s=Oe.get(n);return s?(s.touchedAt=Date.now(),Oe.delete(n),Oe.set(n,s),s):null},pt=t=>{const n=Dt(t),s=Oe.get(n);if(s)return s.touchedAt=Date.now(),s;if(Oe.size>=Is){const a=Oe.keys().next().value;a!==void 0&&Oe.delete(a)}const o={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return Oe.set(n,o),o},Os=t=>{Oe.delete(Dt(t))},Nn=(t,n)=>e.jsx(yt,{filePath:t,extension:n}),$s=({status:t})=>{const n={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"}[t];return e.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:n}})},Ws=({node:t,root:n,isExpanded:s,isActive:o,isBrowserClient:a,status:c,badge:y,permissions:u,downloadFile:h,onSelect:g,onToggle:b,onRevealPath:p,onOpenDialog:d})=>{const j=t.type==="directory",{canRename:f,canCreateFile:O,canCreateFolder:P,canDelete:I,canReveal:$}=u,F=!j&&!!h,W=$&&!a,k=f||O||P||I||F||W,[v,C]=r.useState(!1),[E,w]=r.useState(!1),_=r.useCallback(T=>{k&&(T?.preventDefault(),w(!0))},[k]),q=r.useCallback(()=>{j?b(t.path):g(t)},[j,t,g,b]),X=r.useCallback(T=>{T.stopPropagation(),w(!1),C(!0)},[]),H=({Item:T,Separator:z})=>e.jsxs(e.Fragment,{children:[f&&e.jsxs(T,{onClick:S=>{S.stopPropagation(),d("rename",t)},children:[e.jsx(U,{name:"edit",className:"mr-2 h-4 w-4"})," ","Rename"]}),e.jsxs(T,{onClick:S=>{S.stopPropagation(),bt(t.path).then(L=>{if(L.ok){he.success("Path copied");return}he.error("Copy failed")})},children:[e.jsx(U,{name:"file-copy",className:"mr-2 h-4 w-4"})," ","Copy Path"]}),!j&&h&&e.jsxs(T,{onClick:S=>{S.stopPropagation(),h(t.path).catch(L=>{console.error("Download failed:",L),he.error("Operation failed")})},children:[e.jsx(U,{name:"download",className:"mr-2 h-4 w-4"})," ",a?"Download":"Save"]}),W&&e.jsxs(T,{onClick:S=>{S.stopPropagation(),p(t.path)},children:[e.jsx(U,{name:"folder-received",className:"mr-2 h-4 w-4"})," ",Cr()]}),j&&(O||P)&&e.jsxs(e.Fragment,{children:[e.jsx(z,{}),O&&e.jsxs(T,{onClick:S=>{S.stopPropagation(),d("createFile",t)},children:[e.jsx(U,{name:"file-add",className:"mr-2 h-4 w-4"})," ","New File"]}),P&&e.jsxs(T,{onClick:S=>{S.stopPropagation(),d("createFolder",t)},children:[e.jsx(U,{name:"folder-add",className:"mr-2 h-4 w-4"})," ","New Folder"]})]}),I&&e.jsxs(e.Fragment,{children:[e.jsx(z,{}),e.jsxs(T,{onClick:S=>{S.stopPropagation(),d("delete",t)},className:"text-destructive focus:text-destructive",children:[e.jsx(U,{name:"delete-bin",className:"mr-2 h-4 w-4"})," ","Delete"]})]})]}),V=r.useCallback(T=>{const z=kn(n,t.path);!z||z==="."||(T.dataTransfer.setData("application/x-pichamber-file-path",z),T.dataTransfer.effectAllowed="copy")},[t.path,n]);return e.jsxs(sr,{open:E,onOpenChange:w,children:[e.jsxs(or,{render:e.jsx("div",{className:"group relative flex items-center",onContextMenu:_}),children:[e.jsxs("button",{type:"button",onClick:q,onContextMenu:_,draggable:!0,onDragStart:V,className:be("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",o?"bg-interactive-selection/70":"hover:bg-interactive-hover/40","cursor-grab active:cursor-grabbing"),children:[j?s?e.jsx(U,{name:"folder-open",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):e.jsx(U,{name:"folder-3",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):Nn(t.path,t.extension),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:t.path,children:t.name}),!j&&c&&e.jsx($s,{status:c}),j&&y&&e.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[y.modified>0&&e.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",y.modified]}),y.added>0&&e.jsxs("span",{className:"text-[var(--status-success)]",children:["+",y.added]})]})]}),k&&e.jsx("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 opacity-0 focus-within:opacity-100 group-hover:opacity-100",children:e.jsxs(vr,{open:v,onOpenChange:C,children:[e.jsxs(Be,{children:[e.jsx(ze,{asChild:!0,children:e.jsx("span",{className:"inline-flex",children:e.jsx(Sr,{asChild:!0,children:e.jsx(pe,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:X,title:"File menu","aria-label":"File menu",children:e.jsx(U,{name:"more-2-fill",className:"h-4 w-4"})})})})}),e.jsx(Ue,{side:"bottom",sideOffset:6,children:"File menu"})]}),e.jsx(jr,{align:"end",side:"bottom",onCloseAutoFocus:()=>C(!1),children:H({Item:Pr,Separator:Er})})]})})]}),e.jsx(ar,{className:"min-w-[180px]",children:H({Item:ir,Separator:lr})})]})},Fs=(t,n)=>t.node===n.node&&t.root===n.root&&t.isExpanded===n.isExpanded&&t.isActive===n.isActive&&t.isBrowserClient===n.isBrowserClient&&t.status===n.status&&t.badge===n.badge&&t.permissions===n.permissions&&t.downloadFile===n.downloadFile&&t.onSelect===n.onSelect&&t.onToggle===n.onToggle&&t.onRevealPath===n.onRevealPath&&t.onOpenDialog===n.onOpenDialog,Bs=r.memo(Ws,Fs),zs=()=>{const{files:t,runtime:n}=vt(),s=zn(n.platform),o=et()??"",a=Pe(o.trim()),c=Un(),y=Hn(),u=an(x=>x.searchFiles),h=Q(x=>x.openContextFile),g=mn(o),[b,p]=r.useState(""),d=gn(b,200),j=r.useRef(null),[f,O]=r.useState([]),[P,I]=r.useState(!1),[$,F]=r.useState({}),[W,k]=r.useState({}),v=r.useRef(new Set),C=r.useRef(new Set),E=r.useRef(null);r.useEffect(()=>{if(!a){F({}),k({}),v.current=new Set;return}const x=Ls(a);x?(F({...x.childrenByDir}),k({...x.loadErrorsByDir}),v.current=new Set(x.loadedDirs)):(F({}),k({}),v.current=new Set)},[a]),r.useEffect(()=>{if(!a)return;const x=pt(a);x.childrenByDir=$},[a,$]),r.useEffect(()=>{if(!a)return;const x=pt(a);x.loadErrorsByDir=W},[a,W]),r.useEffect(()=>{if(!a)return;const x=pt(a);x.loadedDirs=new Set(v.current)},[a,$,W]),r.useEffect(()=>()=>{if(!a)return;const x=Oe.get(a);x&&x.loadedDirs.size===0&&Object.keys(x.childrenByDir).length===0&&Os(a)},[a]);const w=r.useMemo(()=>[],[]),_=r.useMemo(()=>[],[]),q=$e(x=>a?x.byRoot[a]?.expandedPaths??w:w),X=$e(x=>a?x.byRoot[a]?.selectedPath??null:null),H=$e(x=>x.setSelectedPath),V=$e(x=>x.addOpenPath),T=$e(x=>x.removeOpenPathsByPrefix),z=$e(x=>x.toggleExpandedPath),S=$e(x=>x.collapseAllExpandedPaths),L=Q(x=>a?x.contextPanelByDirectory[a]?.tabs??_:_),ee=r.useMemo(()=>new Set(L.map(x=>x.mode==="file"?x.targetPath:null).filter(x=>typeof x=="string"&&x.length>0).map(x=>Pe(x))),[L]),[A,Z]=r.useState(null),[te,de]=r.useState(null),[fe,je]=r.useState(""),[ge,xe]=r.useState(!1),ae=!!t.writeFile,Ce=!!t.createDirectory,ke=!!t.rename,M=!!t.delete,B=!!t.revealPath,G=r.useMemo(()=>({canRename:ke,canCreateFile:ae,canCreateFolder:Ce,canDelete:M,canReveal:B}),[ke,ae,Ce,M,B]),ne=r.useCallback(x=>{t.revealPath&&t.revealPath(x).catch(()=>{he.error("Failed to reveal path")})},[t]),ie=r.useCallback((x,R)=>{Z(x),de(R),je(x==="rename"&&R.name||""),xe(!1)},[]),ye=r.useCallback((x,R)=>{const le=R.filter(D=>D&&typeof D.name=="string"&&D.name.length>0).filter(D=>c||!D.name.startsWith(".")).filter(D=>y||!As(D.name)).map(D=>{const se=D.name,K=Pe(D.path||""),me=K?Ds(K)?K:Pe(`${x}/${K}`):Pe(`${x}/${se}`),l=D.isDirectory?"directory":"file",Y=l==="file"&&se.includes(".")?se.split(".").pop()?.toLowerCase():void 0;return{name:se,path:me,type:l,extension:Y}});return Ts(le)},[y,c]),ue=r.useCallback(async(x,R)=>{const le=Pe(x.trim());if(!le||v.current.has(le)||C.current.has(le))return;C.current=new Set(C.current),C.current.add(le);const D=t.listDirectory?t.listDirectory(le).then(se=>se.entries.map(K=>({name:K.name,path:K.path,isDirectory:K.isDirectory}))):Vn(le).then(se=>se.map(K=>({name:K.name,path:K.path,isDirectory:K.isDirectory})));try{const se=await D;if(R?.())return;const K=ye(le,se);v.current=new Set(v.current),v.current.add(le),k(me=>{if(!me[le])return me;const l={...me};return delete l[le],l}),F(me=>({...me,[le]:K}))}catch(se){if(R?.())return;const K=se instanceof Error?se.message:String(se??"");console.error("Failed to load sidebar directory:",se),k(me=>({...me,[le]:K}))}finally{C.current=new Set(C.current),C.current.delete(le)}},[t,ye]),ve=r.useCallback(async()=>{if(!a)return;E.current?.abort();const x=new AbortController;E.current=x;try{const le=($e.getState().byRoot[a]?.expandedPaths??[]).map(K=>Pe(K)).filter(K=>!!K&&K!==a&&K.startsWith(`${a}/`)),D=[a,...le];v.current=new Set(v.current);for(const K of D)v.current.delete(K);k(K=>{if(Object.keys(K).length===0)return K;const me={...K};let l=!1;for(const Y of D)Y in me&&(delete me[Y],l=!0);return l?me:K});const se=()=>x.signal.aborted;await ue(a,se);for(let K=0;K<le.length&&!x.signal.aborted;K+=3){const me=le.slice(K,K+3);await Promise.all(me.map(l=>ue(l,se)))}}catch(R){if(x.signal.aborted)return;console.error("Failed to refresh sidebar tree:",R)}finally{E.current===x&&(E.current=null)}},[ue,a]),Ee=r.useCallback(async x=>{if(!x){await ve();return}const R=Pe(x);v.current=new Set(v.current),v.current.delete(R),C.current=new Set(C.current),C.current.delete(R),await ue(R)},[ue,ve]);r.useEffect(()=>{a&&(E.current?.abort(),v.current=new Set,C.current=new Set,k({}),F(x=>Object.keys(x).length===0?x:{}),ue(a))},[ue,a,c,y]),r.useEffect(()=>{if(!a||q.length===0)return;const x=q.map(D=>Pe(D)).filter(D=>!!D&&D!==a&&D.startsWith(`${a}/`)&&!v.current.has(D)&&!C.current.has(D)).sort((D,se)=>D.split("/").length-se.split("/").length);if(x.length===0)return;let R=!1;const le=()=>R;return(async()=>{for(let D=0;D<x.length&&!R;D+=3){const se=x.slice(D,D+3);await Promise.all(se.map(K=>ue(K,le)))}})(),()=>{R=!0}},[q,ue,a]),r.useEffect(()=>{if(!o){O([]),I(!1);return}const x=d.trim();if(!x){O([]),I(!1);return}let R=!1;return I(!0),u(o,x,150,{includeHidden:c,respectGitignore:!y,type:"file"}).then(le=>{if(R)return;const se=le.filter(K=>y||!Ms(K.path)).map(K=>({name:K.name,path:Pe(K.path),type:"file",extension:K.extension,relativePath:K.relativePath}));O(se)}).catch(()=>{R||O([])}).finally(()=>{R||I(!1)}),()=>{R=!0}},[o,d,u,c,y]);const Re=r.useMemo(()=>{const x=new Map;if(!g?.files)return x;for(const R of g.files)R.index==="A"||R.working_dir==="?"?x.set(R.path,"git-added"):R.index==="D"?x.set(R.path,"git-deleted"):(R.index==="M"||R.working_dir==="M")&&x.set(R.path,"git-modified");return x},[g]),De=r.useMemo(()=>{const x=new Map;if(!g?.files||!a)return x;for(const R of g.files){const le=R.index==="M"||R.working_dir==="M",D=R.index==="A"||R.working_dir==="?";if(!le&&!D)continue;const se=R.path.split("/");if(se.length<=1)continue;let K=a;for(let me=0;me<se.length-1;me++){K=`${K}/${se[me]}`;let l=x.get(K);l||(l={modified:0,added:0},x.set(K,l)),le&&l.modified++,D&&l.added++}}return x},[g,a]),N=r.useCallback(x=>{if(ee.has(x))return"open";if(Re.size===0)return null;const R=x.startsWith(a+"/")?x.slice(a.length+1):x;return Re.get(R)??null},[ee,Re,a]),oe=r.useCallback(x=>{if(De.size===0)return null;const R=De.get(x);return R&&R.modified+R.added>0?R:null},[De]),re=r.useCallback(async x=>{if(!a)return;const R=await jn(t,x.path,{directory:a});if(!R.ok){he.error(Cn(R.reason));return}H(a,x.path),V(a,x.path),h(a,x.path)},[V,t,h,a,H]),i=r.useCallback(async x=>{const R=Pe(x);a&&(z(a,R),v.current.has(R)||await ue(R))},[ue,a,z]),m=r.useCallback(async x=>{if(x?.preventDefault(),!te||!A)return;xe(!0);const R=()=>xe(!1),le=()=>Z(null);if(A==="createFile"){if(!fe.trim()){he.error("Filename is required"),R();return}if(!t.writeFile){he.error("Write not supported"),R();return}const D=te.path,se=D?`${D}/`:"",K=Pe(`${se}${fe.trim()}`);await t.writeFile(K,"").then(async me=>{me.success&&(he.success("File created"),await Ee(D)),le()}).catch(()=>he.error("Operation failed")).finally(R);return}if(A==="createFolder"){if(!fe.trim()){he.error("Folder name is required"),R();return}const D=te.path,se=D?`${D}/`:"",K=Pe(`${se}${fe.trim()}`);await t.createDirectory(K).then(async me=>{me.success&&(he.success("Folder created"),await Ee(D)),le()}).catch(()=>he.error("Operation failed")).finally(R);return}if(A==="rename"){if(!fe.trim()){he.error("Name is required"),R();return}if(!t.rename){he.error("Rename not supported"),R();return}const D=te.path,se=D.split("/").slice(0,-1).join("/"),K=se?`${se}/`:"",me=Pe(`${K}${fe.trim()}`);await t.rename(D,me).then(async l=>{l.success&&(he.success("Renamed successfully"),await Ee(se),a&&T(a,D),(X===D||X&&X.startsWith(`${D}/`))&&H(a,null)),le()}).catch(()=>he.error("Operation failed")).finally(R);return}if(A==="delete"){if(!t.delete){he.error("Delete not supported"),R();return}const D=te.path,se=D.split("/").slice(0,-1).join("/");await t.delete(D).then(async K=>{K.success&&(he.success("Deleted successfully"),await Ee(se),a&&T(a,D),(X===D||X&&X.startsWith(D+"/"))&&H(a,null)),le()}).catch(()=>he.error("Operation failed")).finally(R);return}R()},[A,te,fe,t,Ee,T,a,X,H]);function J(x,R){const le=$[x]??[];return le.map((D,se)=>{const K=D.type==="directory",me=K&&q.includes(D.path),l=X===D.path,Y=se===le.length-1;return e.jsxs("li",{className:"relative",children:[R>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),Y&&e.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-sidebar/50"})]}),e.jsx(Bs,{node:D,root:a,isExpanded:me,isActive:l,isBrowserClient:s,status:K?void 0:N(D.path),badge:K?oe(D.path):void 0,permissions:G,downloadFile:t.downloadFile,onSelect:re,onToggle:i,onRevealPath:ne,onOpenDialog:ie}),K&&me&&e.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[W[D.path]?e.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:W[D.path],children:W[D.path]}),e.jsxs(pe,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{Ee(D.path)},children:[e.jsx(U,{name:"refresh",className:"h-3.5 w-3.5"}),"Refresh"]})]}):null,J(D.path,R+1)]})]},D.path)})}const ce=!!(a&&$[a]),Ne=a?W[a]:null;return e.jsxs("section",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex flex-col gap-2 border-b border-border/40 px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[ae&&e.jsxs(Be,{children:[e.jsx(ze,{asChild:!0,children:e.jsx("span",{className:"inline-flex flex-shrink-0",children:e.jsx(pe,{variant:"ghost",size:"sm",onClick:()=>ie("createFile",{path:o,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:"New File","aria-label":"New File",children:e.jsx(U,{name:"file-add",className:"h-4 w-4"})})})}),e.jsx(Ue,{side:"bottom",sideOffset:6,children:"New File"})]}),Ce&&e.jsxs(Be,{children:[e.jsx(ze,{asChild:!0,children:e.jsx("span",{className:"inline-flex flex-shrink-0",children:e.jsx(pe,{variant:"ghost",size:"sm",onClick:()=>ie("createFolder",{path:o,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:"New Folder","aria-label":"New Folder",children:e.jsx(U,{name:"folder-add",className:"h-4 w-4"})})})}),e.jsx(Ue,{side:"bottom",sideOffset:6,children:"New Folder"})]}),e.jsxs(Be,{children:[e.jsx(ze,{asChild:!0,children:e.jsx("span",{className:"inline-flex flex-shrink-0",children:e.jsx(pe,{variant:"ghost",size:"sm",onClick:()=>{ve()},className:"h-8 w-8 p-0 flex-shrink-0",title:"Refresh","aria-label":"Refresh",children:e.jsx(U,{name:"refresh",className:"h-4 w-4"})})})}),e.jsx(Ue,{side:"bottom",sideOffset:6,children:"Refresh"})]}),e.jsxs(Be,{children:[e.jsx(ze,{asChild:!0,children:e.jsx("span",{className:"inline-flex flex-shrink-0",children:e.jsx(pe,{variant:"ghost",size:"sm",onClick:()=>{a&&S(a)},className:"h-8 w-8 p-0 flex-shrink-0",title:"Collapse all folders","aria-label":"Collapse all folders",children:e.jsx(U,{name:"collapse-vertical",className:"h-4 w-4"})})})}),e.jsx(Ue,{side:"bottom",sideOffset:6,children:"Collapse all folders"})]})]}),e.jsxs("div",{className:"relative min-w-0",children:[e.jsx(U,{name:"search",className:"pointer-events-none absolute left-2 top-2 h-4 w-4 text-muted-foreground"}),e.jsx(Ft,{ref:j,value:b,onChange:x=>p(x.target.value),placeholder:"Search files...",className:"h-8 pl-8 pr-8 typography-meta"}),b.trim().length>0?e.jsx("button",{type:"button","aria-label":"Clear search",className:"absolute right-2 top-2 inline-flex h-4 w-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{p(""),j.current?.focus()},children:e.jsx(U,{name:"close",className:"h-4 w-4"})}):null]})]}),e.jsx(kr,{outerClassName:"flex-1 min-h-0",className:"p-2",children:e.jsx("ul",{className:"flex flex-col",children:P?e.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[e.jsx(U,{name:"loader-4",className:"h-4 w-4 animate-spin"}),"Searching..."]}):f.length>0?f.map(x=>{const R=X===x.path;return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>re(x),draggable:!0,onDragStart:le=>{const D=x.relativePath||kn(a??"",x.path);!D||D==="."||(le.dataTransfer.setData("application/x-pichamber-file-path",D),le.dataTransfer.effectAllowed="copy")},className:be("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors cursor-grab active:cursor-grabbing",R?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),title:x.path,children:[Nn(x.path,x.extension),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},children:x.relativePath??x.path})]})},x.path)}):Ne?e.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[e.jsx("span",{children:Ne}),e.jsxs(pe,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{ve()},children:[e.jsx(U,{name:"refresh",className:"h-3.5 w-3.5"}),"Refresh"]})]}):ce&&a?J(a,0):e.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:"Loading..."})})}),e.jsx(St,{open:!!A,onOpenChange:x=>!x&&Z(null),children:e.jsxs(jt,{children:[e.jsxs(Ct,{children:[e.jsxs(kt,{children:[A==="createFile"&&"Create File",A==="createFolder"&&"Create Folder",A==="rename"&&"Rename",A==="delete"&&"Delete"]}),e.jsxs(Nt,{children:[A==="createFile"&&`Create a new file in ${te?.path??"root"}`,A==="createFolder"&&`Create a new folder in ${te?.path??"root"}`,A==="rename"&&`Rename ${te?.name??""}`,A==="delete"&&`Are you sure you want to delete ${te?.name??""}? This action cannot be undone.`]})]}),A!=="delete"&&e.jsx("div",{className:"py-4",children:e.jsx(Ft,{value:fe,onChange:x=>je(x.target.value),placeholder:A==="rename"?"New name":"Name",onKeyDown:x=>{x.key==="Enter"&&m()},autoFocus:!0})}),e.jsxs(Nr,{children:[e.jsx(pe,{variant:"outline",onClick:()=>Z(null),disabled:ge,children:"Cancel"}),e.jsx(pe,{variant:A==="delete"?"destructive":"default",onClick:()=>{m()},disabled:ge||A!=="delete"&&!fe.trim(),children:ge?e.jsx(U,{name:"loader-4",className:"size-4 animate-spin"}):A==="delete"?"Delete":"Confirm"})]})]})})]})},_t=t=>t,wt=t=>{const n=_t(t).type;return typeof n=="string"?n:""},Us=t=>{const n=_t(t).tool;return typeof n=="string"?n:""},Hs=t=>{const n=_t(t).text;return typeof n=="string"?n:""},Vs=t=>{const n=wt(t);return n==="tool"?Us(t).trim().toLowerCase()||"tool":n||"unknown"},Ks=t=>{if(t.length===0)return"";const n=[];for(const s of t){const o=Vs(s);n.includes(o)||n.push(o)}return n.join(" + ")},Xs=t=>t.replace(/\s+/g," ").trim(),qs=t=>{for(const s of t)if(wt(s)==="text"){const o=Xs(Hs(s));if(o.length===0)continue;return o}const n=t.filter(s=>wt(s)!=="text").length;return n===0?"":`${n} attachment${n===1?"":"s"}`},Gs=(t,n,s)=>`${s(t)} / ${s(n)}`,Ys=t=>{if(t==="12h")return!0;if(t==="24h")return!1},Js=(t,n)=>{if(!t||!Number.isFinite(t))return"-";const s=Ys(n);return new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:s===!1?"2-digit":"numeric",minute:"2-digit",...s===void 0?{}:{hour12:s}})},Qs={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},rt={user:0,assistant:0,tool:0,other:0},Zs=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,ft=t=>Ir(t),eo=(...t)=>{for(const n of t)if(typeof n=="string"&&n.trim().length>0)return n;return""},Ae=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((n,s)=>n+Ae(s),0):t&&typeof t=="object"?Object.values(t).reduce((n,s)=>n+Ae(s),0):0,to=(t,n)=>{const s=t,o=typeof s.type=="string"?s.type:"";if(o==="reasoning")return{...rt,assistant:Ae(s.text)+Ae(s.content)};const a=eo(s.text,s.content,s.value,s.source?.value,s.source?.text?.value);return o==="tool"||n==="tool"?{user:0,assistant:0,tool:Ae(s.input)+Ae(s.output)+Ae(s.error)+Ae(s.call?.input)+Ae(s.call?.output)+Ae(s.call?.error)+Ae(s.raw)+Math.round(Ae(s.metadata)*.25)+Math.round(Ae(s.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}},Gt=(t,n)=>({user:t.user+n.user,assistant:t.assistant+n.assistant,tool:t.tool+n.tool,other:t.other+n.other}),no=t=>{const n=Ye(t.info);return n.isUser?"user":n.role==="assistant"?"assistant":n.role==="tool"?"tool":"other"},ro=(t,n)=>{if(t.length===0)return{...rt};const s=t.reduce((o,a)=>{const c=no(a);let y={...rt};for(const u of a.parts)y=Gt(y,to(u,c));return Gt(o,y)},{...rt});return s.user+=n.length,{user:Math.ceil(s.user/4),assistant:Math.ceil(s.assistant/4),tool:Math.ceil(s.tool/4),other:Math.ceil(s.other/4)}},Fe=t=>t.toLocaleString("en-US"),so=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),oo=(t,n)=>!t||!Number.isFinite(t)?"-":Lr(t,n,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),ao=(t,n,s)=>{const o=t.find(c=>c.id===n),a=o?.models?.find(c=>c.id===s);return{providerName:o?.name||n||"-",modelName:a?.name||s||"-",contextLimit:typeof a?.limit?.context=="number"?a.limit.context:null}},io=()=>{const t=Q(f=>f.timeFormatPreference),[n,s]=r.useState({}),[o,a]=r.useState(null),c=r.useRef(null),y=Ie(f=>f.currentSessionId),u=Ie(f=>f.currentSessionDirectory),h=Rr(),g=Tr(y??""),b=Dr(f=>f.providers);r.useEffect(()=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null),s(f=>Object.keys(f).length>0?{}:f),a(null)},[u,y]),r.useEffect(()=>()=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null)},[]);const p=r.useCallback(async(f,O)=>{(await bt(O)).ok?(a(f),c.current!==null&&window.clearTimeout(c.current),c.current=window.setTimeout(()=>{a(I=>I===f?null:I),c.current=null},2e3)):a(null)},[]),d=r.useMemo(()=>{const f=y?h.find(A=>A.id===y)??null:null,O=g.filter(A=>Ye(A.info).role==="assistant"),P=g.filter(A=>Ye(A.info).isUser);let I=null;for(let A=O.length-1;A>=0;A-=1){const Z=O[A];if(ft(Z).total>0){I=Z;break}}const $=I?ft(I):Qs,F=I?.info?.usage,W=_r({input:$.input,cache:{read:$.cacheRead,write:$.cacheWrite}}),k=O.reduce((A,Z)=>{const te=Zs(Z.info.cost);return A+te},0),v=I?.info?.model??null,C=ao(b,v?.providerID||"",v?.modelID||""),E=C.contextLimit,w=F?Ar(F):$.total,_=E&&E>0?Math.min(999,w/E*100):0,q=[...g].reverse().find(A=>Ye(A.info).isUser&&typeof A.info.system=="string")?.info?.system||"",X=ro(g,q),H=X.user,V=X.assistant,T=X.tool,z=F?0:Math.max(0,$.input-H-V-T),S=H+V+T+z,L=g[0]?.info?.time?.created,ee=g.length>0?g[g.length-1]?.info?.time?.created:null;return{sessionTitle:f?.title||"Untitled Session",messagesCount:g.length,userMessagesCount:P.length,assistantMessagesCount:O.length,createdAt:f?.time?.created??L??null,lastActivityAt:ee??f?.time?.created??null,providerModel:C,tokenBreakdown:$,usagePercent:_,cacheHitRate:W,totalAssistantCost:k,contextLimit:E,contextWindowTokens:w,hasUsage:F!==void 0,breakdown:{user:H,assistant:V,tool:T,other:z},breakdownTotal:S}},[y,b,g,h]);if(!y)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 j=[{key:"user",label:"User",value:d.breakdown.user,color:"var(--status-success)"},{key:"assistant",label:"Assistant",value:d.breakdown.assistant,color:"var(--primary-base)"},{key:"tool",label:"Tool Calls",value:d.breakdown.tool,color:"var(--status-warning)"},...d.hasUsage?[]:[{key:"other",label:"Other",value:d.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:d.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:[d.providerModel.providerName," / ",d.providerModel.modelName]}),d.createdAt&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("span",{children:oo(d.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:[Fe(d.contextWindowTokens),d.contextLimit?` / ${Fe(d.contextLimit)}`:""]})]}),e.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:d.usagePercent>0&&e.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,d.usagePercent)}%`,backgroundColor:d.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:`${d.usagePercent.toFixed(1)}% used`})]}),e.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:[{label:"Messages",value:Fe(d.messagesCount)},{label:"User",value:Fe(d.userMessagesCount)},{label:"Assistant",value:Fe(d.assistantMessagesCount)},{label:"Cost",value:so(d.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:d.tokenBreakdown.input,format:"count"},{label:"Output",value:d.tokenBreakdown.output,format:"count"},{label:"Reasoning",value:d.tokenBreakdown.reasoning,format:"count"},{label:"Cache Read",value:d.tokenBreakdown.cacheRead,format:"count"},{label:"Cache Write",value:d.tokenBreakdown.cacheWrite,format:"count"},{label:"Cache Hit",value:d.cacheHitRate.hasInput?d.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)}%`:Fe(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:j.map(f=>f.value<=0||d.breakdownTotal<=0?null:e.jsx("div",{style:{width:`${f.value/d.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:j.map(f=>{const O=d.breakdownTotal>0?f.value/d.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:[O.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=Ye(f.info).role,I=P==="assistant",$=P==="user",F=n[f.info.id]===!0,W=o===f.info.id,k=f.info.time?.created??null,v=Ks(f.parts),C=I?ft({info:f.info,parts:f.parts}):null,E=$?qs(f.parts):"",w=Js(k,t),_=v||"—",q=C?Gs(C.input,C.output,Fe):"",X=P||"unknown",H=v?`${X}: ${v}`:X,V=F?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":F,onClick:()=>{s(T=>({...T,[f.info.id]:T[f.info.id]!==!0}))},children:e.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:I?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[$?e.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[e.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",E]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:I?_:H}),I&&e.jsx("span",{className:"text-right text-muted-foreground tabular-nums",children:q})]}),e.jsx("span",{className:"text-right text-muted-foreground",children:w})]})}),F&&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:T=>{T.stopPropagation(),p(f.info.id,V)},"aria-label":W?"Copied":"Copy JSON",title:W?"Copied":"Copy",children:W?e.jsx(U,{name:"check",className:"size-3.5"}):e.jsx(U,{name:"file-copy",className:"size-3.5"})})}),e.jsx(Mr,{language:"json",code:V,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},f.info.id)})})]})]})})},lo="x-pichamber-preview-target-error",co=t=>{const n=t.get(lo);return n==="missing"||n==="expired"||n==="invalid-token"?n:null},uo=(t,n)=>co(t)?n?"stop-retrying":"retry-registration":"none",ho=t=>{if(!t||typeof t!="object")return!1;const n=t;return typeof n.x=="number"&&typeof n.y=="number"},Yt=t=>!t||typeof t!="object"?!1:Object.values(t).every(n=>typeof n=="string"),Ve=t=>{if(!t||typeof t!="object")return!1;const n=t,s=n.bounds;return typeof n.tag=="string"&&typeof n.text=="string"&&typeof n.selector=="string"&&typeof n.path=="string"&&!!s&&typeof s?.x=="number"&&typeof s?.y=="number"&&typeof s?.width=="number"&&typeof s?.height=="number"&&ho(n.center)&&Yt(n.attributes)&&Yt(n.computedStyle)&&Array.isArray(n.ancestry)},At=({pageUrl:t,viewport:n,devicePixelRatio:s,target:o,screenshotAttached:a,intro:c})=>{const y=o.text.trim(),u=Object.entries(o.attributes).map(([j,f])=>`${j}="${f}"`).join(" "),h=o.computedStyle,g=o.bounds,b=o.center,p=c.replace(/[.:]+$/g,""),d=o.ancestry.map(j=>j.selectorPart).join(" > ");return[`${p}:`,`Page: ${t||"preview"}`,`Viewport: ${n.width}x${n.height}, DPR ${s}`,`Screenshot: ${a?"attached":"not attached"}`,`Element: ${o.tag}`,y?`Text: ${y}`:null,`- Selector: ${o.selector}`,`- Path: ${o.path}`,d?`- Ancestry: ${d}`:null,u?`- Attributes: ${u}`: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(b.x)}, y=${Math.round(b.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(j=>typeof j=="string").join(`
|
|
3
|
-
`)},Pn=async(t,n)=>{if(typeof window<"u")try{const s=t.getBoundingClientRect(),o=await cn("desktop_capture_page_rect",{x:s.left,y:s.top,width:s.width,height:s.height});if(!o)throw new Error("Desktop screenshot capture is not available");const a=new Image;await new Promise((f,O)=>{a.onload=()=>f(),a.onerror=()=>O(new Error("Failed to load desktop preview screenshot")),a.src=`data:${o.mime};base64,${o.base64}`});const c=Math.max(1,a.naturalWidth||o.width||Math.floor(s.width)),y=Math.max(1,a.naturalHeight||o.height||Math.floor(s.height)),h=Math.min(1,1200/c),g=document.createElement("canvas");g.width=Math.floor(c*h),g.height=Math.floor(y*h);const b=g.getContext("2d");if(!b)return null;b.scale(h,h),b.drawImage(a,0,0,c,y);const p=c/Math.max(1,s.width),d=y/Math.max(1,s.height);b.fillStyle="rgba(37, 99, 235, 0.28)",b.strokeStyle="rgb(37, 99, 235)",b.lineWidth=Math.max(2,2*p),b.fillRect(n.bounds.x*p,n.bounds.y*d,n.bounds.width*p,n.bounds.height*d),b.strokeRect(n.bounds.x*p,n.bounds.y*d,n.bounds.width*p,n.bounds.height*d);const j=await new Promise(f=>g.toBlob(f,"image/jpeg",.82));return j?new File([j],`preview-annotation-${Date.now()}.jpg`,{type:"image/jpeg"}):null}catch(s){return console.warn("[preview] failed to capture annotation screenshot:",s),null}return await Po(t,n)},Mt=async(t,n,s,o,a,c)=>{if(!t)return null;try{const y=new Image;await new Promise((P,I)=>{y.onload=()=>P(),y.onerror=()=>I(new Error("Failed to load desktop browser screenshot")),y.src=`data:image/jpeg;base64,${t}`});const u=Math.max(1,y.naturalWidth||n),h=Math.max(1,y.naturalHeight||s),b=Math.min(1,1200/u),p=document.createElement("canvas");p.width=Math.floor(u*b),p.height=Math.floor(h*b);const d=p.getContext("2d");if(!d)return null;d.scale(b,b),d.drawImage(y,0,0,u,h);const j=u/Math.max(1,o||u),f=h/Math.max(1,a||h);d.fillStyle="rgba(37, 99, 235, 0.14)",d.strokeStyle="rgb(37, 99, 235)",d.lineWidth=Math.max(2,2*j),d.fillRect(c.bounds.x*j,c.bounds.y*f,c.bounds.width*j,c.bounds.height*f),d.strokeRect(c.bounds.x*j,c.bounds.y*f,c.bounds.width*j,c.bounds.height*f);const O=await new Promise(P=>p.toBlob(P,"image/jpeg",.82));return O?new File([O],`browser-annotation-${Date.now()}.jpg`,{type:"image/jpeg"}):null}catch{return null}},Ke="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+/p9sAAAAASUVORK5CYII=",Te=new Map,mt=new Map,po=3e4,It=t=>{const n=Te.get(t);return n?n.expiresAt-Date.now()<=po?(Te.delete(t),null):n:null},fo=t=>{try{return new URL(t).origin}catch{return t}};function En(t){const n="#ffffff",s=t.defaultView??window;try{const o=t.body?s.getComputedStyle(t.body).backgroundColor:"";if(o&&o!=="rgba(0, 0, 0, 0)"&&o!=="transparent")return o;const a=s.getComputedStyle(t.documentElement).backgroundColor;if(a&&a!=="rgba(0, 0, 0, 0)"&&a!=="transparent")return a}catch{}return n}const Rn=t=>new Promise((n,s)=>{const o=new FileReader;o.onloadend=()=>n(typeof o.result=="string"?o.result:Ke),o.onerror=()=>s(o.error??new Error("Failed to read image blob")),o.readAsDataURL(t)}),mo=async(t,n=.82)=>{const s=await new Promise(o=>t.toBlob(o,"image/jpeg",n));return s&&(await Rn(s)).split(",",2)[1]||""},go=()=>{try{return!!window.__previewCaptureDebug}catch{return!1}},st=(...t)=>{go()&&console.info("[preview-capture]",...t)},Tn=(t,n=8)=>{const s=[];try{const o=t.querySelectorAll("*");for(const a of o){const c=a.scrollTop||0,y=a.scrollLeft||0;if(c<=0&&y<=0)continue;const u=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(s.push({selector:`${u}${h}${g}`,scrollTop:c,scrollLeft:y,clientWidth:a.clientWidth,clientHeight:a.clientHeight,scrollWidth:a.scrollWidth,scrollHeight:a.scrollHeight}),s.length>=n)break}}catch{}return s},Qe="data-oc-fixed-pin",xo=(t,n,s)=>{if(n<=0&&s<=0)return()=>{};const o=t.defaultView;if(!o)return()=>{};const a=[],c=[];try{for(const y of t.querySelectorAll("*")){if(o.getComputedStyle(y).position!=="fixed")continue;const u=y.getBoundingClientRect();if(!(u.width>0&&u.height>0))continue;y.setAttribute(Qe,JSON.stringify({top:u.top+s,left:u.left+n,width:u.width,height:u.height})),a.push(y);const h=y.tagName.toLowerCase(),g=typeof y.className=="string"&&y.className?`.${y.className.trim().split(/\s+/).slice(0,2).join(".")}`:"";c.push({selector:`${h}${g}`,top:Math.round(u.top),left:Math.round(u.left),width:Math.round(u.width),height:Math.round(u.height)})}}catch{}return st("tagged fixed elements",c),()=>{for(const y of a)try{y.removeAttribute(Qe)}catch{}}},wo={name:"oc-fixed-pin",afterClone(t){const n=t?.clone;if(!(!n||typeof n.querySelectorAll!="function"))for(const s of n.querySelectorAll(`[${Qe}]`)){let o;try{o=JSON.parse(s.getAttribute(Qe)||"")}catch{continue}s.style.setProperty("position","absolute","important"),s.style.setProperty("top",`${o.top}px`,"important"),s.style.setProperty("left",`${o.left}px`,"important"),s.style.setProperty("right","auto","important"),s.style.setProperty("bottom","auto","important"),s.style.setProperty("width",`${o.width}px`,"important"),s.style.setProperty("height",`${o.height}px`,"important"),s.removeAttribute(Qe)}}},He="data-oc-scroll-pin",yo=t=>{const n=[],s=Tn(t,64);try{const c=t.documentElement,y=t.body;for(const u of t.querySelectorAll("*")){const h=u.scrollTop||0,g=u.scrollLeft||0;if(h<=0&&g<=0)continue;const b=u!==c&&u!==y;b&&u.setAttribute(He,JSON.stringify({top:h,left:g})),n.push({el:u,top:h,left:g,tagged:b})}}catch{}return{reapply:()=>{for(const c of n)try{c.el.scrollHeight,c.el.scrollTop!==c.top&&(c.el.scrollTop=c.top),c.el.scrollLeft!==c.left&&(c.el.scrollLeft=c.left)}catch{}},cleanup:()=>{for(const c of n)if(c.tagged)try{c.el.removeAttribute(He)}catch{}},snapshot:s}},bo={name:"oc-nested-scroll",afterClone(t){const n=t?.clone;if(!n||typeof n.querySelectorAll!="function")return;const s=n.ownerDocument;if(s)for(const o of n.querySelectorAll(`[${He}]`)){let a;try{a=JSON.parse(o.getAttribute(He)||"")}catch{o.removeAttribute(He);continue}const c=`translate(${-a.left}px, ${-a.top}px)`,y=o.children.length===1&&o.firstElementChild instanceof HTMLElement&&o.firstElementChild.style.willChange==="transform"?o.firstElementChild:null;if(y)y.style.transform=c;else{o.style.overflow="hidden";const u=s.createElement("div");for(u.style.transform=c,u.style.willChange="transform",u.style.display="inline-block",u.style.width="100%";o.firstChild;)u.appendChild(o.firstChild);o.appendChild(u)}o.removeAttribute(He)}}},gt=async(t,n)=>{try{const s=await fetch(t,{credentials:n});return s.ok?await Rn(await s.blob()):null}catch{return null}},vo=async t=>{if(t.protocol!=="http:"&&t.protocol!=="https:")return"";const n=t.origin,s=It(n);if(s)return`${s.proxyBasePath}${t.pathname}${t.search}${t.hash}`;const o=mt.get(n),a=o??(async()=>{try{const y=await it("/api/preview/targets",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({url:t.toString(),allowExternal:!0})});if(!y.ok)return Te.delete(n),null;const u=await y.json(),h=typeof u.proxyBasePath=="string"?u.proxyBasePath:"",g=typeof u.expiresAt=="number"?u.expiresAt:0;if(!h)return Te.delete(n),null;const b={proxyBasePath:h,expiresAt:g};return Te.set(n,b),b}catch{return Te.delete(n),null}finally{mt.delete(n)}})();o||mt.set(n,a);const c=await a;return c?`${c.proxyBasePath}${t.pathname}${t.search}${t.hash}`:""},Dn=async(t,n)=>{if(!t||t.startsWith("data:"))return t;try{const s=new URL(t,n.baseURI);if(s.origin===window.location.origin||s.protocol!=="http:"&&s.protocol!=="https:")return await gt(s.toString(),"include")??Ke;const o=await vo(s),a=o?await gt(o,"include"):null;return a||(await gt(s.toString(),"omit")??Ke)}catch{return Ke}},So=async(t,n)=>{if(!t||t==="none"||!t.includes("url("))return t;const s=Array.from(t.matchAll(/url\((['"]?)(.*?)\1\)/g));let o=t;for(const a of s){const c=a[2]||"";if(!c||c.startsWith("data:"))continue;const y=await Dn(c,n);o=o.replace(a[0],`url("${y}")`)}return o},Jt=t=>t.complete?Promise.resolve():new Promise(n=>{t.addEventListener("load",()=>n(),{once:!0}),t.addEventListener("error",()=>n(),{once:!0})}),_n=t=>{const n=t.style.cssText;return()=>{t.style.cssText=n}},jo=t=>{const n=Number.parseFloat(t.lineHeight);if(Number.isFinite(n)&&n>0)return n;const s=Number.parseFloat(t.fontSize);return Number.isFinite(s)&&s>0?s*1.2:16},Co=(t,n,s)=>{const o=[],a=t.defaultView??window,y=Array.from(t.querySelectorAll('button, a, summary, label, [role="button"], [role="link"], [role="menuitem"], [role="tab"], nav *, header *'));for(const u of y){const h=u.textContent?.replace(/\s+/g," ").trim()??"";if(!h||!h.includes(" "))continue;const g=u.getBoundingClientRect();if(g.width<=0||g.height<=0||g.right<0||g.bottom<0||g.left>n||g.top>s)continue;const b=a.getComputedStyle(u);if(b.display==="none"||b.visibility==="hidden"||Number(b.opacity)===0)continue;const p=b.getPropertyValue("text-wrap"),d=b.getPropertyValue("text-wrap-mode"),j=b.whiteSpace.includes("nowrap")||p==="nowrap"||d==="nowrap",f=g.height<=jo(b)*1.7;!j&&(!f||g.width>n*.72)||(o.push(_n(u)),u.style.whiteSpace="nowrap",u.style.overflowWrap="normal",u.style.wordBreak="normal",u.style.setProperty("text-wrap","nowrap"),u.style.setProperty("text-wrap-mode","nowrap"))}return()=>{for(let u=o.length-1;u>=0;u-=1)o[u]?.()}},ko=(t,n,s,o)=>{const a=[],c=t.defaultView??window,y=c.scrollX||t.documentElement.scrollLeft||t.body?.scrollLeft||0,u=c.scrollY||t.documentElement.scrollTop||t.body?.scrollTop||0,h=Array.from(t.querySelectorAll("*")).filter(g=>{const b=c.getComputedStyle(g);if(b.position!=="fixed"||b.display==="none"||b.visibility==="hidden"||Number(b.opacity)===0)return!1;const p=g.getBoundingClientRect();return p.width>0&&p.height>0&&p.right>=0&&p.bottom>=0&&p.left<=n&&p.top<=s}).filter((g,b,p)=>!p.some((d,j)=>j<b&&d.contains(g)));for(const g of h){const b=g.getBoundingClientRect(),p=c.getComputedStyle(g),d=Math.ceil(b.width)+8,j=Math.ceil(b.height)+2;o?.add(g),a.push(_n(g)),g.style.position="absolute",g.style.top=`${b.top+u}px`,g.style.left=`${b.left+y}px`,g.style.right="auto",g.style.bottom="auto",g.style.width=`${d}px`,g.style.minWidth=`${d}px`,g.style.height=`${j}px`,g.style.minHeight=`${j}px`,g.style.margin="0",g.style.boxSizing="border-box",g.style.transform="none",p.zIndex!=="auto"&&(g.style.zIndex=p.zIndex)}return()=>{for(let g=a.length-1;g>=0;g-=1)a[g]?.()}},An=async(t,n,s,o={})=>{const a=[],c=t.defaultView??window,y=p=>{if(p===t.documentElement||p===t.body)return!0;try{const d=p.getBoundingClientRect();return d.width>0&&d.height>0&&d.right>=0&&d.bottom>=0&&d.left<=n&&d.top<=s}catch{return!1}};if(o.applyLayoutWorkarounds){const p=new WeakSet;a.push(ko(t,n,s,p)),a.push(Co(t,n,s))}const u=new Map;for(const p of Array.from(t.images))u.set(p,p.currentSrc||p.src||p.getAttribute("src")||"");const h=Array.from(t.querySelectorAll("picture"));for(const p of h){const d=Array.from(p.querySelectorAll("source"));if(d.length===0)continue;const j=d.map(f=>({source:f,srcset:f.getAttribute("srcset"),sizes:f.getAttribute("sizes")}));a.push(()=>{for(const f of j)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 d)f.removeAttribute("srcset"),f.removeAttribute("sizes")}const g=Array.from(t.images).filter(p=>y(p));await Promise.all(g.map(async p=>{const d=u.get(p)||p.currentSrc||p.src||p.getAttribute("src")||"";if(!d)return;await Jt(p);const j=await Dn(d,t),f={src:p.getAttribute("src"),srcset:p.getAttribute("srcset"),sizes:p.getAttribute("sizes")};a.push(()=>{f.src===null?p.removeAttribute("src"):p.setAttribute("src",f.src),f.srcset===null?p.removeAttribute("srcset"):p.setAttribute("srcset",f.srcset),f.sizes===null?p.removeAttribute("sizes"):p.setAttribute("sizes",f.sizes)}),p.removeAttribute("srcset"),p.removeAttribute("sizes"),p.setAttribute("src",j||Ke),await Jt(p)}));const b=Array.from(t.querySelectorAll("*")).filter(y);return await Promise.all(b.map(async p=>{const d=c.getComputedStyle(p).backgroundImage;if(!d||d==="none"||!d.includes("url("))return;const j=await So(d,t);if(j===d)return;const f=p.style.backgroundImage;a.push(()=>{p.style.backgroundImage=f}),p.style.backgroundImage=j})),()=>{for(let p=a.length-1;p>=0;p-=1)try{a[p]?.()}catch{}}};async function No(t,n){try{const s=t.contentWindow,o=t.contentDocument??s?.document,a=o?.documentElement;if(!s||!o||!a)return null;const c=t.getBoundingClientRect(),y=Math.max(1,Math.ceil(s.innerWidth||t.clientWidth||c.width)),u=Math.max(1,Math.ceil(s.innerHeight||t.clientHeight||c.height)),h=o.body,g=o.scrollingElement instanceof HTMLElement?o.scrollingElement:null,b=s.scrollX||0,p=s.scrollY||0,d=s.pageXOffset||0,j=s.pageYOffset||0,f=s.visualViewport?.pageLeft||s.visualViewport?.offsetLeft||0,O=s.visualViewport?.pageTop||s.visualViewport?.offsetTop||0,P=a.scrollLeft||0,I=a.scrollTop||0,$=h?.scrollLeft||0,F=h?.scrollTop||0,W=g?.scrollLeft||0,k=g?.scrollTop||0,v=Math.max(b,d,f,P,$,W),C=Math.max(p,j,O,I,F,k);st("scroll sources",{windowScrollX:b,windowScrollY:p,pageScrollX:d,pageScrollY:j,visualViewportScrollX:f,visualViewportScrollY:O,rootScrollX:P,rootScrollY:I,bodyScrollX:$,bodyScrollY:F,scrollingElementScrollX:W,scrollingElementScrollY:k,scrollingElementTag:g?.tagName?.toLowerCase()??null,resolvedScrollX:v,resolvedScrollY:C,nestedScrolledElements:Tn(o)});const E=Math.max(y,a.scrollWidth||0,h?.scrollWidth||0,Math.ceil(a.getBoundingClientRect().width||0)),w=Math.max(u,a.scrollHeight||0,h?.scrollHeight||0,Math.ceil(a.getBoundingClientRect().height||0)),_=Math.min(2,Math.max(1,window.devicePixelRatio||1)),q=a.style.scrollBehavior,X=h?.style.scrollBehavior??"";a.style.scrollBehavior="auto",h&&(h.style.scrollBehavior="auto");const H=yo(o);st("nested scroll snapshot",H.snapshot);let V=()=>{},T=()=>{};try{await o.fonts?.ready.catch(()=>{}),V=await An(o,y,u,{applyLayoutWorkarounds:!1}),s.scrollTo(v,C),T=xo(o,v,C),H.reapply();const{snapdom:z}=await Le(async()=>{const{snapdom:M}=await import("./vendor-zumer-snapdom-Btyu_Xi2.js");return{snapdom:M}},[]),S={backgroundColor:En(o),cache:"disabled",dpr:_,embedFonts:!0,fast:!1,height:w,outerShadows:!0,outerTransforms:!0,placeholders:!0,plugins:[wo,bo],quality:.82,width:E},ee=await(await z(a,S)).toCanvas();if(!ee.width||!ee.height)return null;const A=ee.width/Math.max(1,E),Z=ee.height/Math.max(1,w),te=Math.min(ee.width,Math.max(1,Math.round(y*A))),de=Math.min(ee.height,Math.max(1,Math.round(u*Z))),fe=Math.max(0,ee.width-te),je=Math.max(0,ee.height-de),ge=Math.min(fe,Math.max(0,Math.round(v*A))),xe=Math.min(je,Math.max(0,Math.round(C*Z)));st("capture geometry",{viewportWidth:y,viewportHeight:u,captureWidth:E,captureHeight:w,canvasWidth:ee.width,canvasHeight:ee.height,xScale:A,yScale:Z,sourceX:ge,sourceY:xe,sourceWidth:te,sourceHeight:de});const ae=o.createElement("canvas");ae.width=te,ae.height=de;const Ce=ae.getContext("2d");if(!Ce)return null;Ce.drawImage(ee,ge,xe,te,de,0,0,te,de);const ke=await mo(ae,.82);return ke?await Mt(ke,y,u,y,u,n):null}finally{T(),H.cleanup(),V(),s.scrollTo(v,C),H.reapply(),a.style.scrollBehavior=q,h&&(h.style.scrollBehavior=X)}}catch(s){return console.warn("[preview] failed to capture iframe DOM screenshot with snapDOM:",s),null}}async function Po(t,n){const s=await No(t,n);if(s)return s;try{const o=t.contentWindow,a=t.contentDocument??o?.document,c=a?.documentElement;if(!o||!a||!c)return null;const y=t.getBoundingClientRect(),u=Math.max(1,Math.ceil(o.innerWidth||t.clientWidth||y.width)),h=Math.max(1,Math.ceil(o.innerHeight||t.clientHeight||y.height)),g=o.scrollX||a.documentElement.scrollLeft||a.body?.scrollLeft||0,b=o.scrollY||a.documentElement.scrollTop||a.body?.scrollTop||0,p=a.body,d=Math.max(h,c.scrollHeight||0,p?.scrollHeight||0),j=Math.min(2,Math.max(1,window.devicePixelRatio||1)),f=c.style.scrollBehavior,O=p?.style.scrollBehavior??"";c.style.scrollBehavior="auto",p&&(p.style.scrollBehavior="auto");let P="",I=()=>{};try{await a.fonts?.ready.catch(()=>{}),I=await An(a,u,h,{applyLayoutWorkarounds:!0}),o.scrollTo(g,b);const{getFontEmbedCSS:F,toJpeg:W}=await Le(async()=>{const{getFontEmbedCSS:v,toJpeg:C}=await import("./vendor-html-to-image-BeoRn2gJ.js");return{getFontEmbedCSS:v,toJpeg:C}},[]),k=await F(c).catch(()=>"");P=await W(c,{quality:.82,pixelRatio:j,width:u,height:h,backgroundColor:En(a),imagePlaceholder:Ke,fontEmbedCSS:k||void 0,style:{transform:`translate(${-g}px, ${-b}px)`,transformOrigin:"top left",minWidth:`${u}px`,minHeight:`${d}px`},cacheBust:!0})}finally{I(),o.scrollTo(g,b),c.style.scrollBehavior=f,p&&(p.style.scrollBehavior=O)}const $=P.split(",",2)[1]||"";return $?await Mt($,u,h,u,h,n):null}catch(o){return console.warn("[preview] failed to capture iframe DOM screenshot:",o),null}}const Eo=We(()=>Le(()=>import("./DiffView-D1dyOiw2.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,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118])).then(t=>({default:t.DiffView}))),Ro=We(()=>Le(()=>import("./FilesView-BCzghrc7.js"),__vite__mapDeps([119,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,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,111,112,113,120,121,122,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,123,124,116,117,125,126,114,115])).then(t=>({default:t.FilesView}))),To=We(()=>Le(()=>import("./GitView-CYF1E1p4.js"),__vite__mapDeps([127,8,1,2,6,3,4,5,7,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,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,111,112,113,128,115,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,114,116,117])).then(t=>({default:t.GitView}))),Do=380,_o=1400,Mn=600,Ao=100,Mo=24,dt=new Map,Qt=200,Io=(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",Lo=t=>{if(!t)return"";const n=t.replace(/\\/g,"/"),s=n.startsWith("//");let o=n.replace(/\/+$/g,"");return o=o.replace(/\/+/g,"/"),s&&!o.startsWith("//")&&(o=`/${o}`),o===""?n.startsWith("/")?"/":"":o},Zt=t=>Number.isFinite(t)?Math.min(_o,Math.max(Do,Math.round(t))):Mn,Oo=t=>{const n=t?.parentElement?.clientWidth;return!n||n<=0?null:n},$o=(t,n)=>{if(!t)return"";const s=t.replace(/\\/g,"/"),o=n.replace(/\\/g,"/").replace(/\/+$/,"");return o&&s.startsWith(o+"/")?s.slice(o.length+1):s},In=(t,n=null)=>t==="chat"?"Chat":t==="file"?"Files":t==="diff"?"Changes":t==="preview"?"Preview":t==="browser"?"Browser":t==="git"?Pt(n).label:t==="notes"?"Project notes":t==="terminal"?"Terminal":"Context",Wo=t=>{if(!t)return null;const n=t.replace(/\\/g,"/").trim();if(!n)return null;const s=n.split("/").filter(Boolean);return s.length===0?n:s[s.length-1]||null},Fo=(t,n,s=null)=>{if(t.mode==="chat"){const o=ot(t.dedupeKey);if(o){const c=n.get(o)?.trim();if(c)return c}const a=t.sessionTitleFallback?.trim();return a||"Chat"}if(t.label)return t.label;if(t.mode==="file")return Wo(t.targetPath)||"Files";if(t.mode==="preview"){const o=t.targetPath;if(o)try{const a=new URL(o);return a.host||a.hostname||"Preview"}catch{}return"Preview"}return t.mode==="diff"?"Changes":In(t.mode,s)},en=(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(dr,{className:"h-3.5 w-3.5"});if(t.mode==="git")return e.jsx(U,{name:Pt(n).icon,className:"h-3.5 w-3.5"});if(t.mode==="notes")return e.jsx(U,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return e.jsx(U,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="context")return e.jsx(U,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return e.jsx(U,{name:"chat-4",className:"h-3.5 w-3.5"});if(t.mode==="preview")return e.jsx(U,{name:"global",className:"h-3.5 w-3.5 text-[var(--status-info)]"});if(t.mode==="browser")return e.jsx(U,{name:"global",className:"h-3.5 w-3.5"})},Bo=200,zo=480,Uo=({visible:t})=>{const n=Q(P=>P.contextEditorTreeWidth),s=Q(P=>P.setContextEditorTreeWidth),[o,a]=r.useState(!1),c=r.useRef(0),y=r.useRef(n),u=r.useRef(null),h=r.useRef(null),g=r.useRef(null),b=r.useCallback(P=>Math.min(zo,Math.max(Bo,Math.round(P))),[]),p=r.useCallback(P=>{const I=g.current;I&&(I.style.width=`${P}px`,I.style.setProperty("--oc-editor-tree-width",`${P}px`))},[]),d=P=>{if(t){try{P.currentTarget.setPointerCapture(P.pointerId)}catch{}h.current=P.pointerId,a(!0),c.current=P.clientX,y.current=n,u.current=n,P.preventDefault()}},j=P=>{if(!o||h.current!==P.pointerId)return;const I=c.current-P.clientX,$=b(y.current+I);u.current!==$&&(u.current=$,p($))},f=P=>{if(h.current!==P.pointerId)return;try{P.currentTarget.releasePointerCapture(P.pointerId)}catch{}const I=b(u.current??n);h.current=null,u.current=null,a(!1),s(I)},O=t?n:0;return e.jsxs("div",{ref:g,className:be("relative h-full flex-shrink-0 overflow-hidden border-l border-border bg-background will-change-[width] motion-reduce:transition-none",!t&&"border-l-0"),style:{width:`${o?u.current??O:O}px`,"--oc-editor-tree-width":`${o?u.current??n:n}px`,overflowX:"clip",transitionProperty:o?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&e.jsx("div",{className:be("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",o&&"bg-[var(--interactive-border)]"),onPointerDown:d,onPointerMove:j,onPointerUp:f,onPointerCancel:f,role:"separator","aria-orientation":"vertical","aria-label":"Resize context panel"}),e.jsx("div",{className:be("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",o&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)"},"aria-hidden":!t,children:e.jsx(zs,{})})]})},ot=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,Ho=(t,n)=>{if(t.size!==n.size)return!1;for(const[s,o]of t)if(n.get(s)!==o)return!1;return!0},Vo=(t,n)=>{if(n.length===0)return dt;const s=new Set(n),o=new Map;for(const a of t){if(!s.has(a.id))continue;const c=a.title?.trim();c&&o.set(a.id,c)}return o.size===0?dt:o},Ko=(t,n)=>{const s=Ur(),o=r.useRef(dt),a=r.useRef(n);return a.current=n,r.useSyncExternalStore(s.subscribe,r.useCallback(()=>{const c=Vo(s.getState().session,a.current);return Ho(o.current,c)?o.current:(o.current=c,c)},[s]),()=>dt)},Ln=`new Promise((resolve) => {
|
|
4
|
-
const existing = document.getElementById('__pichamber_desktop_browser_overlay');
|
|
5
|
-
if (existing) existing.remove();
|
|
6
|
-
if (typeof window.__pichamberDesktopBrowserCancelInspect === 'function') {
|
|
7
|
-
try { window.__pichamberDesktopBrowserCancelInspect(); } catch { /* webview not ready */ }
|
|
8
|
-
}
|
|
9
|
-
const overlay = document.createElement('div');
|
|
10
|
-
overlay.id = '__pichamber_desktop_browser_overlay';
|
|
11
|
-
overlay.style.cssText = 'position:fixed;z-index:2147483647;pointer-events:none;border:2px solid #60a5fa;background:rgba(96,165,250,.24);border-radius:3px;display:none;box-sizing:border-box;';
|
|
12
|
-
document.documentElement.appendChild(overlay);
|
|
13
|
-
const cssEscape = (value) => {
|
|
14
|
-
try { return CSS.escape(value); } catch { return String(value).replace(/[^a-zA-Z0-9_-]/g, '\\\\$&'); }
|
|
15
|
-
};
|
|
16
|
-
const selectorPart = (element) => {
|
|
17
|
-
const tag = element.tagName.toLowerCase();
|
|
18
|
-
if (element.id) return tag + '#' + cssEscape(element.id);
|
|
19
|
-
const className = String(element.className || '').trim().split(/\\s+/).filter(Boolean).slice(0, 3).map((part) => '.' + cssEscape(part)).join('');
|
|
20
|
-
return tag + className;
|
|
21
|
-
};
|
|
22
|
-
const metadata = (element) => {
|
|
23
|
-
const rect = element.getBoundingClientRect();
|
|
24
|
-
const style = getComputedStyle(element);
|
|
25
|
-
const ancestry = [];
|
|
26
|
-
let current = element;
|
|
27
|
-
while (current && current.nodeType === Node.ELEMENT_NODE && ancestry.length < 8) {
|
|
28
|
-
ancestry.unshift({ tag: current.tagName.toLowerCase(), id: current.id || undefined, className: typeof current.className === 'string' ? current.className : undefined, selectorPart: selectorPart(current) });
|
|
29
|
-
current = current.parentElement;
|
|
30
|
-
}
|
|
31
|
-
const attrs = {};
|
|
32
|
-
for (const attr of Array.from(element.attributes || []).slice(0, 16)) attrs[attr.name] = attr.value.slice(0, 300);
|
|
33
|
-
const path = ancestry.map((entry) => entry.selectorPart).join(' > ');
|
|
34
|
-
return {
|
|
35
|
-
frame: 'top',
|
|
36
|
-
tag: element.tagName.toLowerCase(),
|
|
37
|
-
text: String(element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim().slice(0, 500),
|
|
38
|
-
selector: element.id ? '#' + cssEscape(element.id) : path,
|
|
39
|
-
path,
|
|
40
|
-
bounds: { x: rect.x, y: rect.y, width: rect.width, height: rect.height },
|
|
41
|
-
center: { x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 },
|
|
42
|
-
attributes: attrs,
|
|
43
|
-
computedStyle: { display: style.display, position: style.position, fontWeight: style.fontWeight, fontSize: style.fontSize, lineHeight: style.lineHeight, fontFamily: style.fontFamily, color: style.color, backgroundColor: style.backgroundColor, zIndex: style.zIndex },
|
|
44
|
-
ancestry,
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
const move = (event) => {
|
|
48
|
-
const element = document.elementFromPoint(event.clientX, event.clientY);
|
|
49
|
-
if (!element || element === overlay || element === document.documentElement || element === document.body) return;
|
|
50
|
-
const rect = element.getBoundingClientRect();
|
|
51
|
-
overlay.style.display = 'block';
|
|
52
|
-
overlay.style.left = rect.left + 'px';
|
|
53
|
-
overlay.style.top = rect.top + 'px';
|
|
54
|
-
overlay.style.width = rect.width + 'px';
|
|
55
|
-
overlay.style.height = rect.height + 'px';
|
|
56
|
-
};
|
|
57
|
-
const cleanup = () => {
|
|
58
|
-
window.removeEventListener('mousemove', move, true);
|
|
59
|
-
window.removeEventListener('click', click, true);
|
|
60
|
-
window.removeEventListener('keydown', keydown, true);
|
|
61
|
-
if (window.__pichamberDesktopBrowserCancelInspect === cancel) {
|
|
62
|
-
delete window.__pichamberDesktopBrowserCancelInspect;
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
const cancel = () => {
|
|
66
|
-
cleanup();
|
|
67
|
-
overlay.remove();
|
|
68
|
-
resolve(null);
|
|
69
|
-
};
|
|
70
|
-
const click = (event) => {
|
|
71
|
-
event.preventDefault();
|
|
72
|
-
event.stopPropagation();
|
|
73
|
-
const element = document.elementFromPoint(event.clientX, event.clientY);
|
|
74
|
-
const result = element ? metadata(element) : null;
|
|
75
|
-
cleanup();
|
|
76
|
-
overlay.remove();
|
|
77
|
-
resolve(result);
|
|
78
|
-
};
|
|
79
|
-
const keydown = (event) => {
|
|
80
|
-
if (event.key !== 'Escape') return;
|
|
81
|
-
cancel();
|
|
82
|
-
};
|
|
83
|
-
window.__pichamberDesktopBrowserCancelInspect = cancel;
|
|
84
|
-
window.addEventListener('mousemove', move, true);
|
|
85
|
-
window.addEventListener('click', click, true);
|
|
86
|
-
window.addEventListener('keydown', keydown, true);
|
|
87
|
-
});`,at=`(() => {
|
|
88
|
-
if (typeof window.__pichamberDesktopBrowserCancelInspect === 'function') {
|
|
89
|
-
window.__pichamberDesktopBrowserCancelInspect();
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
const overlay = document.getElementById('__pichamber_desktop_browser_overlay');
|
|
93
|
-
if (overlay) overlay.remove();
|
|
94
|
-
})()`,Xo=`(() => {
|
|
95
|
-
if (window.__pichamberSameWebviewNavigationInstalled) return;
|
|
96
|
-
window.__pichamberSameWebviewNavigationInstalled = true;
|
|
97
|
-
|
|
98
|
-
const navigate = (rawUrl) => {
|
|
99
|
-
if (typeof rawUrl !== 'string' || rawUrl.length === 0) return false;
|
|
100
|
-
try {
|
|
101
|
-
const url = new URL(rawUrl, window.location.href);
|
|
102
|
-
if (url.protocol !== 'http:' && url.protocol !== 'https:') return false;
|
|
103
|
-
window.location.assign(url.href);
|
|
104
|
-
return true;
|
|
105
|
-
} catch (_error) {
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const originalOpen = window.open.bind(window);
|
|
111
|
-
window.open = (url, target, features) => {
|
|
112
|
-
if (navigate(url)) return null;
|
|
113
|
-
return originalOpen(url, target, features);
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
document.addEventListener('click', (event) => {
|
|
117
|
-
if (event.defaultPrevented) return;
|
|
118
|
-
const target = event.target;
|
|
119
|
-
if (!(target instanceof Element)) return;
|
|
120
|
-
const anchor = target.closest('a[target="_blank"][href]');
|
|
121
|
-
if (!(anchor instanceof HTMLAnchorElement)) return;
|
|
122
|
-
if (!navigate(anchor.href)) return;
|
|
123
|
-
event.preventDefault();
|
|
124
|
-
event.stopPropagation();
|
|
125
|
-
}, true);
|
|
126
|
-
})()`,Ze=t=>{const n=t.trim();if(!n)return"about:blank";try{const s=new URL(n.includes("://")?n:`https://${n}`);return s.protocol!=="http:"&&s.protocol!=="https:"?"about:blank":s.toString()}catch{return"about:blank"}},tn=async(t,n)=>{const s=t.contentWindow;if(!s)throw new Error("Iframe window is not available");const a=s.eval.call(s,n);return await Promise.resolve(a)},qo=(t,n)=>t.length<=n?t:`${t.slice(0,n-3)}...`,On=t=>{if(typeof window>"u")return"";try{return new URL(t||window.location.href,window.location.href).origin}catch{return window.location.origin}},nn=(t,n,s)=>{const o=On(n);t.postMessage(s,o)},Go=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}},rn=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}},Yo=({rawUrl:t,onNavigate:n})=>{const{currentTheme:s}=xn(),[o,a]=r.useReducer(N=>N+1,0),[c,y]=r.useReducer(N=>N+1,0),[u,h]=r.useState({status:"idle"}),[g,b]=r.useState(""),p=r.useRef(null),d=r.useRef(1),[j,f]=r.useState(!1),[O,P]=r.useState(!1),[I,$]=r.useState("all"),[F,W]=r.useState([]),[k,v]=r.useState(!1),[C,E]=r.useState(null),w=Ie(N=>N.currentSessionId),_=Ie(N=>N.newSessionDraft?.open),q=et(),X=Et(N=>N.addDraft),H=Rt(N=>N.addAttachedFile);let V=null;try{V=t?new URL(t):null}catch{V=null}const T=V?V.hostname==="localhost"||V.hostname==="127.0.0.1"||V.hostname==="::1"||V.hostname==="[::1]"||V.hostname==="0.0.0.0":!1,z=V?V.hostname==="0.0.0.0"?new URL(V.toString().replace("0.0.0.0","127.0.0.1")):V:null,S=z?z.toString():"",L=S?`${lt()||"same-origin"}|${S}`:"",ee=s.metadata.variant;r.useEffect(()=>{if(!S||!T){h({status:"idle"});return}const N=It(L);if(N?.previewToken){h({status:"ready",proxyBasePath:N.proxyBasePath,previewToken:N.previewToken,expiresAt:N.expiresAt});return}N&&Te.delete(L);let oe=!1;return h({status:"loading"}),(async()=>{try{const re=await it("/api/preview/targets",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({url:S})});if(!re.ok){Te.delete(L);const Ne=await re.json().catch(()=>({})),x=typeof Ne?.error=="string"?Ne.error:`HTTP ${re.status}`;oe||h({status:"error",message:x});return}const i=await re.json(),m=typeof i.proxyBasePath=="string"?i.proxyBasePath:"",J=typeof i.previewToken=="string"?i.previewToken:"",ce=typeof i.expiresAt=="number"?i.expiresAt:0;if(!m||!J){Te.delete(L),oe||h({status:"error",message:"Could not start preview proxy."});return}Te.set(L,{proxyBasePath:m,previewToken:J,expiresAt:ce}),oe||h({status:"ready",proxyBasePath:m,previewToken:J,expiresAt:ce})}catch(re){if(Te.delete(L),!oe){const i=re instanceof Error?re.message:String(re);h({status:"error",message:i})}}})(),()=>{oe=!0}},[T,L,c,S]);const A=z&&(z.protocol==="http:"||z.protocol==="https:")?z.toString():"",Z=T&&u.status==="ready"?`${u.proxyBasePath}|${u.previewToken||""}|${o}`:"";r.useEffect(()=>{if(!Z){b("");return}let N=!1;return b(""),dn(lt()).then(oe=>{!N&&oe&&b(Z)}).catch(()=>{}),()=>{N=!0}},[Z]);const te=T&&u.status==="ready"&&z&&g===Z?(()=>{const N=z.pathname||"/",oe=new URLSearchParams(z.search);oe.delete("oc_url_token"),oe.delete("oc_client_token"),oe.set("ocPreview",String(o)),oe.set("oc_preview_token",u.previewToken||"");const re=oe.toString(),i=z.hash||"";return un().authenticatedAsset(`${u.proxyBasePath}${N}${re?`?${re}`:""}${i}`)})():"",de=T?te:A,fe=T?Go(te):A,je=T&&(u.status==="loading"||u.status==="idle"||g!==Z),ge=T&&u.status==="error",xe=r.useCallback(N=>{const oe=w??(_?"draft":null);if(!oe||!q){he.error("Open a chat session before attaching preview annotations");return}const re=t||de||"",i=typeof window<"u"?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0},m=typeof window<"u"?window.devicePixelRatio:1;(async()=>{let J=!1;try{const ce=p.current,Ne=ce?await Pn(ce,N):null;Ne&&(await H(Ne),J=!0)}catch{J=!1}X({directory:q,sessionKey:oe},{source:"preview-annotation",fileLabel:re||"preview",startLine:1,endLine:1,code:At({pageUrl:re,viewport:i,devicePixelRatio:m,target:N,screenshotAttached:J,intro:"This is a selected DOM element from the in-app preview."}),language:"markdown",text:""}),he.success("Preview annotation attached to chat")})()},[H,X,w,q,de,_,t]);r.useEffect(()=>{f(!1),W([]),P(!1),$("all"),v(!1),E(null),d.current=1},[de]),r.useEffect(()=>{const N=p.current?.contentWindow;!j||!N||nn(N,te,{source:"pichamber-preview-parent",version:1,type:"set-inspect-mode",enabled:k})},[j,k,te]),r.useEffect(()=>{const N=p.current?.contentWindow;!j||!N||nn(N,te,{source:"pichamber-preview-parent",version:1,type:"set-color-scheme",scheme:ee})},[j,ee,te]),r.useEffect(()=>{if(!k||typeof window>"u")return;const N=oe=>{oe.key==="Escape"&&(oe.preventDefault(),oe.stopImmediatePropagation(),v(!1))};return window.addEventListener("keydown",N,!0),()=>window.removeEventListener("keydown",N,!0)},[k]),r.useEffect(()=>{if(!T||typeof window>"u")return;const N=i=>{if(typeof i=="string")return i;if(i==null)return"";try{return JSON.stringify(i)}catch{return String(i)}},oe=i=>{const m=d.current;d.current+=1,W(J=>{const ce=[...J,{...i,id:m}];return ce.length>Qt?ce.slice(ce.length-Qt):ce})},re=i=>{if(i.source!==p.current?.contentWindow)return;const m=i.data;if(!(!m||m.source!=="pichamber-preview-bridge"||m.version!==1)){if(m.type==="ready"){f(!0);return}if(m.type==="console"){const J=m.level==="error"||m.level==="warn"||m.level==="info"||m.level==="debug"?m.level:"log",ce=Array.isArray(m.args)?m.args.map(N).filter(Boolean):[];oe({level:J,message:ce.join(" "),ts:typeof m.ts=="number"?m.ts:Date.now()});return}if(m.type==="runtime-error"){const J=N(m.filename),ce=typeof m.line=="number"?m.line:null,Ne=typeof m.column=="number"?m.column:null,x=J?`${J}${ce!==null?`:${ce}${Ne!==null?`:${Ne}`:""}`:""}`:"",R=N(m.stack);oe({level:"runtime",message:N(m.message)||"Runtime error",details:[x,R].filter(Boolean).join(`
|
|
127
|
-
`),ts:typeof m.ts=="number"?m.ts:Date.now()});return}if(m.type==="resource-error"){const J=N(m.tag)||"resource",ce=N(m.url);oe({level:"resource",message:ce?`${J}: ${ce}`:J,details:N(m.outerHTML),ts:typeof m.ts=="number"?m.ts:Date.now()});return}if(m.type==="hover"){E(Ve(m.target)?m.target:null);return}if(m.type==="select"&&Ve(m.target)){E(m.target),v(!1),xe(m.target);return}if(m.type==="navigate-preview"){const J=typeof m.url=="string"?m.url:"",ce=m.navigation==="external"?"external":"proxy";if(J&&ce==="external"){ct(J);return}J&&n(J)}}};return window.addEventListener("message",re),()=>{window.removeEventListener("message",re)}},[xe,T,n]);const ae=F.filter(N=>N.level==="error"||N.level==="runtime"||N.level==="resource").length,Ce=F.filter(N=>Io(N,I)),ke=r.useCallback(()=>{const N=[`Preview URL: ${t||de||""}`,`Events: ${F.length}`,""].join(`
|
|
128
|
-
`),oe=F.map(re=>{const i=new Date(re.ts).toISOString(),m=re.details?`
|
|
129
|
-
${re.details}`:"";return`[${i}] [${re.level}] ${re.message}${m}`}).join(`
|
|
130
|
-
`);bt(`${N}${oe}`).then(re=>{re.ok?he.success("Preview console copied"):he.error("Failed to copy preview console")})},[F,de,t]),M=r.useCallback(()=>{const N=w??(_?"draft":null);if(!N||!q){he.error("Open a chat session before attaching preview logs");return}const oe=[`Preview URL: ${t||de||""}`,`Events: ${F.length}`,""].join(`
|
|
131
|
-
`),re=F.map(i=>{const m=new Date(i.ts).toISOString(),J=i.details?`
|
|
132
|
-
${i.details}`:"";return`[${m}] [${i.level}] ${i.message}${J}`}).join(`
|
|
133
|
-
`);X({directory:q,sessionKey:N},{source:"preview-console",fileLabel:t||de||"preview",startLine:1,endLine:Math.max(1,F.length),code:`${oe}${re}`,language:"text",text:"These are browser console logs from the dev server running for this project."}),he.success("Preview console attached to chat")},[X,F,w,q,de,_,t]),[B,G]=r.useState("unknown"),ne=r.useRef(0),ie=r.useRef(0),ye=r.useRef(""),ue=r.useRef(""),ve=15e3;r.useEffect(()=>{if(!te){G("unknown"),ye.current="",ne.current=0,ie.current=0;return}let N=!1,oe=null;ye.current!==L&&(ye.current=L,ne.current=Date.now(),ie.current=0);const re=i=>{oe=setTimeout(()=>{N||a()},i)};return G("unknown"),(async()=>{const m=await(async()=>{try{return await it(te,{method:"GET",credentials:"include",cache:"no-store",redirect:"manual"})}catch{return null}})();if(N)return;if(!m){G("unreachable"),re(5e3);return}const J=uo(m.headers,ue.current===L);if(J!=="none"){if(Te.delete(L),J==="retry-registration")ue.current=L,h({status:"loading"}),y();else{const x=await m.json().catch(()=>({}));if(N)return;const R=typeof x?.error=="string"?x.error:`HTTP ${m.status}`;h({status:"error",message:R})}return}if(m.status!==502){ue.current="",G("reachable");return}const ce=ne.current||Date.now();if(Date.now()-ce<ve){G("starting"),ie.current+=1;const x=ie.current,R=Math.min(2e3,250*Math.pow(2,Math.min(4,x)));re(R);return}G("unreachable"),re(5e3)})(),()=>{N=!0,oe&&clearTimeout(oe)}},[L,te,o]);const Ee=T&&u.status==="ready"&&(B==="unknown"||B==="starting"),Re=T&&u.status==="ready"&&B==="unreachable",De=r.useCallback(N=>{if(!T||u.status!=="ready"||typeof window>"u")return;const oe=N.currentTarget.contentWindow;if(oe)try{const re=oe.location,i=On(te);if(re.origin!==i||re.pathname.startsWith(u.proxyBasePath))return;const m=`${u.proxyBasePath}${re.pathname}${re.search}${re.hash}`;oe.location.replace(m)}catch{}},[T,te,u]);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:fe||t,children:fe||t||"No preview URL"}),e.jsx(pe,{type:"button",size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>a(),title:"Reload preview","aria-label":"Reload preview",disabled:!de,children:e.jsx(U,{name:"refresh",className:"h-3.5 w-3.5"})}),e.jsx(pe,{type:"button",size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{A&&ct(A)},title:"Open in browser","aria-label":"Open in browser",disabled:!A,children:e.jsx(U,{name:"external-link",className:"h-3.5 w-3.5"})}),T?e.jsx(pe,{type:"button",size:"sm",variant:k?"secondary":"ghost",className:"h-7 gap-1 px-2",onClick:()=>v(N=>!N),title:"Inspect preview element","aria-label":"Inspect preview element",disabled:!j,children:e.jsx(U,{name:"cursor",className:"h-3.5 w-3.5"})}):null,T?e.jsxs(pe,{type:"button",size:"sm",variant:O?"secondary":"ghost",className:"h-7 gap-1 px-2",onClick:()=>P(N=>!N),title:j?"Open preview console":"Waiting for preview console","aria-label":j?"Open preview console":"Waiting for preview console",disabled:!j&&F.length===0,children:[e.jsx(U,{name:"terminal-box",className:"h-3.5 w-3.5"}),ae>0?e.jsx("span",{className:"typography-micro text-status-error",children:ae}):null]}):null]}),e.jsxs("div",{className:"relative min-h-0 flex-1 bg-background",children:[Ee?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."})]}):Re?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(pe,{type:"button",size:"sm",variant:"outline",onClick:()=>a(),children:"Retry"})]}):de&&(!T||B==="reachable")?e.jsxs("div",{className:"relative h-full w-full",children:[e.jsx("iframe",{ref:p,src:de,title:"Preview",className:"h-full w-full border-0",style:{colorScheme:ee},onLoad:De,sandbox:T?"allow-scripts allow-same-origin allow-forms allow-popups allow-downloads":"allow-scripts allow-forms"},`${de}:${o}`),k&&C?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:C.bounds.x,top:C.bounds.y,width:C.bounds.width,height:C.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:[C.tag,C.text?` · ${C.text}`:""]})}):null]}):je?e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-sm text-muted-foreground",children:"Connecting preview proxy..."}):ge?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."}),u.status==="error"?e.jsx("div",{className:"text-center text-xs opacity-70",children:u.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."}),O?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(pe,{type:"button",size:"xs",variant:"ghost",onClick:M,disabled:F.length===0,children:"Attach"}),e.jsx(pe,{type:"button",size:"xs",variant:"ghost",onClick:ke,disabled:F.length===0,children:"Copy"}),e.jsx(pe,{type:"button",size:"xs",variant:"ghost",onClick:()=>W([]),disabled:F.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(N=>e.jsx(pe,{type:"button",size:"xs",variant:I===N?"secondary":"ghost",onClick:()=>$(N),children:N==="all"?"All":N==="errors"?"Errors":N==="warnings"?"Warnings":"Logs"},N))}),e.jsx("div",{className:"max-h-64 overflow-auto p-2 typography-code text-xs",children:F.length===0?e.jsx("div",{className:"px-2 py-3 text-muted-foreground",children:"No preview console events yet."}):Ce.length===0?e.jsx("div",{className:"px-2 py-3 text-muted-foreground",children:"No events match this filter."}):Ce.map(N=>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:be("shrink-0 uppercase",N.level==="error"||N.level==="runtime"||N.level==="resource"?"text-status-error":N.level==="warn"?"text-status-warning":"text-muted-foreground"),children:N.level}),e.jsx("span",{className:"min-w-0 break-words text-foreground",children:N.message})]})},N.id))})]}):null]})]})},Jo=()=>typeof window<"u"&&!!window.__PICHAMBER_ELECTRON__,Qo=({initialUrl:t,directory:n,tabID:s})=>{const o=r.useRef(null),a=Q(M=>M.setContextPanelTabTargetPath),c=Ze(t),y=c!=="about:blank"?c:"",[u,h]=r.useState(y),[g,b]=r.useState(y),[p,d]=r.useState(y),[j,f]=r.useState(()=>y?[y]:[]),[O,P]=r.useState(()=>y?0:-1),[I,$]=r.useReducer(M=>M+1,0),[F,W]=r.useState(!!y),[k,v]=r.useState(!1),[C,E]=r.useState(null),[w,_]=r.useState({status:"idle"}),[q,X]=r.useState(""),H=Ie(M=>M.currentSessionId),V=Ie(M=>M.newSessionDraft?.open),T=Et(M=>M.addDraft),z=Rt(M=>M.addAttachedFile),S=r.useCallback(M=>{!M||M==="about:blank"||!n||!s||a(n,s,M)},[n,s,a]),L=r.useCallback((M,B)=>{const G=Ze(M),ne=G!=="about:blank"?G:"";b(ne),h(ne),B?.inFrame?W(!1):(d(ne),W(!!ne)),S(ne),f(ie=>{if(!ne)return P(-1),[];if(B?.replaceHistory)return ie;const ye=O>=0?ie.slice(0,O+1):[];if(ye[ye.length-1]===ne)return P(ye.length-1),ye;const ve=[...ye,ne];return P(ve.length-1),ve})},[O,S]),ee=r.useCallback(M=>{const B=j[M];B&&(P(M),b(B),d(B),h(B),W(!0),S(B))},[j,S]),A=r.useCallback(()=>{if(g){W(!0);try{o.current?.contentWindow?.location.reload()}catch{$()}}},[g]);r.useEffect(()=>{if(!p){_({status:"idle"});return}const M=fo(p),B=It(M);if(B?.previewToken){_({status:"ready",proxyBasePath:B.proxyBasePath,previewToken:B.previewToken,expiresAt:B.expiresAt});return}B&&Te.delete(M);let G=!1;return _({status:"loading"}),W(!0),(async()=>{try{const ne=await it("/api/preview/targets",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({url:p,allowExternal:!0})});if(!ne.ok){const Ee=await ne.json().catch(()=>({})),Re=typeof Ee?.error=="string"?Ee.error:`HTTP ${ne.status}`;G||_({status:"error",message:Re});return}const ie=await ne.json(),ye=typeof ie.proxyBasePath=="string"?ie.proxyBasePath:"",ue=typeof ie.previewToken=="string"?ie.previewToken:"",ve=typeof ie.expiresAt=="number"?ie.expiresAt:0;if(!ye||!ue){G||_({status:"error",message:"Could not start preview proxy."});return}Te.set(M,{proxyBasePath:ye,previewToken:ue,expiresAt:ve}),G||_({status:"ready",proxyBasePath:ye,previewToken:ue,expiresAt:ve})}catch(ne){if(!G){const ie=ne instanceof Error?ne.message:String(ne);_({status:"error",message:ie})}}})(),()=>{G=!0}},[p]);const Z=p&&w.status==="ready"?`${w.proxyBasePath}|${w.previewToken||""}|${I}`:"";r.useEffect(()=>{if(!Z){X("");return}let M=!1;return X(""),dn(lt()).then(B=>{!M&&B&&X(Z)}).catch(()=>{}),()=>{M=!0}},[Z]);const te=r.useMemo(()=>{if(q!==Z||!p||w.status!=="ready")return"";try{const M=new URL(p),B=M.pathname||"/",G=new URLSearchParams(M.search);G.delete("oc_url_token"),G.delete("oc_client_token"),G.set("ocPreview",String(I)),G.set("oc_preview_token",w.previewToken||"");const ne=G.toString();return un().authenticatedAsset(`${w.proxyBasePath}${B}${ne?`?${ne}`:""}${M.hash}`)}catch{return""}},[p,w,Z,I,q]),de=te||(w.status==="error"?p:""),fe=r.useCallback(M=>{if(!M||!p||w.status!=="ready")return"";try{const B=new URL(M,window.location.origin),G=w.proxyBasePath.endsWith("/")?w.proxyBasePath.slice(0,-1):w.proxyBasePath;if(B.origin!==window.location.origin||!B.pathname.startsWith(G))return"";const ne=B.pathname.slice(G.length)||"/",ie=new URL(p).origin;return rn(new URL(`${ne}${B.search}${B.hash}`,ie).toString())}catch{return""}},[p,w]),je=r.useCallback(M=>{if(!M||!p||w.status!=="ready")return"";try{const B=new URL(M,window.location.origin),G=new URL(p).origin;if(B.origin!==window.location.origin||G===window.location.origin)return"";const ne=w.proxyBasePath.endsWith("/")?w.proxyBasePath.slice(0,-1):w.proxyBasePath;return B.pathname.startsWith(ne)?"":rn(new URL(`${B.pathname}${B.search}${B.hash}`,G).toString())}catch{return""}},[p,w]),ge=r.useCallback(M=>{const B=o.current?.contentWindow;B&&B.postMessage({source:"pichamber-preview-parent",version:1,type:"set-inspect-mode",enabled:M},window.location.origin)},[]),xe=r.useCallback(async M=>{const B=H??(V?"draft":null);if(!B){he.error("Open a chat session before attaching preview annotations");return}const G=o.current,ne=G?.contentWindow,ie=G?.getBoundingClientRect(),ye={width:Number.isFinite(ne?.innerWidth)?ne?.innerWidth??ie?.width??0:ie?.width??0,height:Number.isFinite(ne?.innerHeight)?ne?.innerHeight??ie?.height??0:ie?.height??0},ue=G?await Pn(G,M):null,ve=!!ue;ue&&await z(ue),T({directory:n,sessionKey:B},{source:"preview-annotation",fileLabel:g||"browser",startLine:1,endLine:1,code:At({pageUrl:g,viewport:ye,devicePixelRatio:window.devicePixelRatio||1,target:M,screenshotAttached:ve,intro:ve?"This is a selected DOM element from the in-app preview. A screenshot of the visible preview area with the selected element highlighted is attached.":"This is a selected DOM element from the in-app preview."}),language:"markdown",text:""}),he.success("Preview annotation attached to chat")},[z,T,H,g,n,V]),ae=r.useCallback(()=>{const M=o.current;E(null),ge(!1),M&&tn(M,at).catch(()=>{})},[ge]);r.useEffect(()=>{if(!k)return;const M=B=>{B.key==="Escape"&&(B.preventDefault(),B.stopImmediatePropagation(),v(!1),ae())};return window.addEventListener("keydown",M,!0),()=>window.removeEventListener("keydown",M,!0)},[ae,k]),r.useEffect(()=>()=>ae(),[ae]),r.useEffect(()=>{const M=B=>{if(B.source!==o.current?.contentWindow)return;const G=B.data;if(!(!G||G.source!=="pichamber-preview-bridge"||G.version!==1)){if(G.type==="ready"){const ne=typeof G.url=="string"?G.url:"",ie=fe(ne);ie&&ie!==g&&L(ie,{inFrame:!0});return}if(G.type==="hover"){E(Ve(G.target)?G.target:null);return}if(G.type==="select"&&Ve(G.target)){E(null),v(!1),ge(!1),xe(G.target);return}if(G.type==="navigate-preview"){const ne=typeof G.url=="string"?G.url:"",ie=je(ne);if(ie){L(ie);return}ne&&L(ne)}}};return window.addEventListener("message",M),()=>window.removeEventListener("message",M)},[L,xe,g,fe,je,ge]);const Ce=r.useCallback(()=>{const M=o.current;if(!(!M||!g)){if(k){v(!1),ae();return}if(te){E(null),v(!0),ge(!0);return}v(!0),(async()=>{try{const B=await tn(M,Ln);if(v(!1),!B||!Ve(B))return;await xe(B)}catch{v(!1),he.error("This page cannot be inspected from the browser panel.")}})()}},[xe,ae,g,k,ge,te]),ke=r.useCallback(()=>{try{const M=o.current?.contentWindow?.location.href||"",B=je(M);if(B){L(B,{inFrame:!0});return}}catch{}W(!1),k&&te&&ge(!0)},[L,je,k,ge,te]);return e.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",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(pe,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",disabled:O<=0,onClick:()=>ee(O-1),children:e.jsx(U,{name:"arrow-left",className:"h-3.5 w-3.5"})}),e.jsx(pe,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",disabled:O<0||O>=j.length-1,onClick:()=>ee(O+1),children:e.jsx(U,{name:"arrow-right",className:"h-3.5 w-3.5"})}),e.jsx(pe,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",disabled:!g,onClick:A,children:e.jsx(U,{name:"refresh",className:"h-3.5 w-3.5"})}),e.jsx("form",{className:"min-w-0 flex-1",onSubmit:M=>{M.preventDefault(),L(u)},children:e.jsx("input",{value:u,onChange:M=>h(M.target.value),className:"h-7 w-full rounded-md border border-border/50 bg-[var(--surface-elevated)] px-2 typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]","aria-label":"Browser address"})}),e.jsx(pe,{type:"button",variant:k?"secondary":"ghost",size:"sm",className:"h-7 w-7 p-0",disabled:!g,onClick:Ce,title:"Inspect preview element","aria-label":"Inspect preview element",children:e.jsx(U,{name:"cursor",className:"h-3.5 w-3.5"})}),e.jsx(pe,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",disabled:!g,onClick:()=>{ct(g)},children:e.jsx(U,{name:"external-link",className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"relative min-h-0 flex-1 bg-background",children:[de?e.jsxs("div",{className:"absolute inset-0",children:[e.jsx("iframe",{ref:o,src:de,title:"Web browser",className:"absolute inset-0 h-full w-full border-0 bg-background",allow:"clipboard-read; clipboard-write; fullscreen",allowFullScreen:!0,onLoad:ke},`${s}:${I}`),k&&C?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:C.bounds.x,top:C.bounds.y,width:C.bounds.width,height:C.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:[C.tag,C.text?` · ${C.text}`:""]})}):null]}):e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-6 bg-background p-6 text-center",children:[e.jsx(yn,{width:140,height:140,className:"opacity-20"}),e.jsx("span",{className:"typography-ui-header text-muted-foreground",children:"Web browser"}),e.jsx("span",{className:"max-w-sm typography-micro text-muted-foreground",children:"Enter an address above to start browsing the web"}),e.jsx("span",{className:"max-w-md typography-micro leading-relaxed text-status-warning/70",children:"Pages opened here run with full access to PiChamber — needed for inspect and screenshots. Only open sites you trust: a malicious page could read your data or act on your behalf."})]}),F?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/70 typography-micro text-muted-foreground",children:"Loading..."}):null]})]})},Zo=({initialUrl:t,directory:n,tabID:s})=>{const o=r.useRef(null),a=Q(w=>w.setContextPanelTabTargetPath),c=Ze(t),y=c!=="about:blank"?c:"",u=r.useRef(Ze(t)),[h,g]=r.useState(y),[b,p]=r.useState(y),[d,j]=r.useState(!1),[f,O]=r.useState(!0),P=r.useRef(null),I=f,$=r.useCallback(w=>{!w||w==="about:blank"||!n||!s||a(n,s,w)},[n,s,a]),F=Ie(w=>w.currentSessionId),W=Ie(w=>w.newSessionDraft?.open),k=Et(w=>w.addDraft),v=Rt(w=>w.addAttachedFile);r.useEffect(()=>{const w=o.current;if(!w)return;const _=()=>{try{const z=w.getURL();z&&z!=="about:blank"&&(p(z),g(z),$(z))}catch{}},q=z=>{const S=z.detail;typeof S?.url=="string"&&S.url&&(p(S.url),g(S.url),$(S.url))},X=()=>{P.current&&clearTimeout(P.current),P.current=setTimeout(()=>O(!0),200)},H=()=>{P.current&&clearTimeout(P.current),O(!1),_()},V=z=>{const S=z.detail;if(S?.disposition==="new-window"||S?.disposition==="foreground-tab"||S?.disposition==="background-tab"){z.preventDefault();const L=o.current;typeof L?.loadURL=="function"&&S.url&&L.loadURL(S.url)}},T=()=>{try{w.executeJavaScript?.(Xo,!0).catch(()=>{})}catch{}};w.addEventListener("did-navigate",q),w.addEventListener("did-navigate-in-page",q),w.addEventListener("did-start-loading",X),w.addEventListener("did-stop-loading",H),w.addEventListener("new-window",V),w.addEventListener("dom-ready",T);try{w.isLoading()||(O(!1),_())}catch{}return T(),()=>{P.current&&clearTimeout(P.current),w.removeEventListener("did-navigate",q),w.removeEventListener("did-navigate-in-page",q),w.removeEventListener("did-start-loading",X),w.removeEventListener("did-stop-loading",H),w.removeEventListener("new-window",V),w.removeEventListener("dom-ready",T)}},[$]),r.useEffect(()=>{const w=setTimeout(()=>O(!1),3e4);return()=>clearTimeout(w)},[]),r.useEffect(()=>{if(!d)return;const w=_=>{if(_.key!=="Escape")return;_.preventDefault(),_.stopImmediatePropagation(),j(!1);const q=o.current;try{q?.executeJavaScript?.(at).catch(()=>{})}catch{}};return window.addEventListener("keydown",w,!0),()=>window.removeEventListener("keydown",w,!0)},[d]),r.useEffect(()=>{const w=o.current;return()=>{try{const _=w?.getURL?.();_&&_!=="about:blank"&&a(n,s,_)}catch{}try{w?.executeJavaScript?.(at).catch(()=>{})}catch{}}},[n,s,a]);const C=r.useCallback(w=>{const _=o.current;if(typeof _?.loadURL!="function")return;const q=Ze(w);try{_.loadURL(q)}catch{}},[]),E=r.useCallback(()=>{const w=o.current;if(w){if(d){j(!1);try{w.executeJavaScript?.(at).catch(()=>{})}catch{}return}j(!0),w.executeJavaScript?.(Ln,!0).then(async _=>{if(j(!1),!_||!Ve(_))return;const q=F??(W?"draft":null);if(!q){he.error("Open a chat session before attaching preview annotations");return}const X=typeof w.getWebContentsId=="function"?w.getWebContentsId():null;if(X==null)return;const H=await zr("desktop_browser_capture_page",{webContentsId:X}),V=await w.executeJavaScript?.("({ width: window.innerWidth, height: window.innerHeight })",!0).catch(()=>null),T=Number.isFinite(V?.width)?V.width:H.width,z=Number.isFinite(V?.height)?V.height:H.height,S=await Mt(H.base64,H.width,H.height,T,z,_),L=!!S;S&&await v(S),k({directory:n,sessionKey:q},{source:"preview-annotation",fileLabel:b||"browser",startLine:1,endLine:1,code:At({pageUrl:b,viewport:{width:T,height:z},devicePixelRatio:window.devicePixelRatio||1,target:_,screenshotAttached:L,intro:"This is a selected DOM element from the in-app preview. A screenshot of the visible preview area with the selected element highlighted is attached."}),language:"markdown",text:""}),he.success("Preview annotation attached to chat")}).catch(()=>j(!1))}},[v,k,F,b,n,d,W]);return e.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",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(pe,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>{try{o.current?.goBack?.()}catch{}},children:e.jsx(U,{name:"arrow-left",className:"h-3.5 w-3.5"})}),e.jsx(pe,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>{try{o.current?.goForward?.()}catch{}},children:e.jsx(U,{name:"arrow-right",className:"h-3.5 w-3.5"})}),e.jsx(pe,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>{try{o.current?.reload?.()}catch{}},children:e.jsx(U,{name:"refresh",className:"h-3.5 w-3.5"})}),e.jsx("form",{className:"min-w-0 flex-1",onSubmit:w=>{w.preventDefault(),C(h)},children:e.jsx("input",{value:h,onChange:w=>g(w.target.value),className:"h-7 w-full rounded-md border border-border/50 bg-[var(--surface-elevated)] px-2 typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]","aria-label":"Browser address"})}),e.jsx(pe,{type:"button",variant:d?"secondary":"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:E,title:"Inspect preview element","aria-label":"Inspect preview element",children:e.jsx(U,{name:"cursor",className:"h-3.5 w-3.5"})}),e.jsx(pe,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>{ct(b)},children:e.jsx(U,{name:"external-link",className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"relative min-h-0 flex-1 bg-background",children:[e.jsx("webview",{ref:o,src:u.current,partition:"persist:pichamber-browser",allowpopups:!0,style:{width:"100%",height:"100%",border:"none"}}),(!b||b==="about:blank")&&!f?e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-6 bg-background p-6 text-center",children:[e.jsx(yn,{width:140,height:140,className:"opacity-20"}),e.jsx("span",{className:"typography-ui-header text-muted-foreground",children:"Web browser"})]}):null,I?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/70 typography-micro text-muted-foreground",children:"Loading..."}):null]})]})},ea=()=>{const t=et()??"",n=r.useMemo(()=>Lo(t),[t]),s=Q(l=>n?l.contextPanelByDirectory[n]:void 0),o=Q(l=>l.closeContextPanel),a=Q(l=>l.closeContextPanelTab),c=Q(l=>l.openContextPanelTab),y=Q(l=>l.toggleContextPanelExpanded),u=Q(l=>l.setContextPanelWidth),h=Q(l=>l.setActiveContextPanelTab),g=Q(l=>l.reorderContextPanelTabs),b=$e(l=>l.setSelectedPath),p=Q(l=>l.openContextPreview),d=Q(l=>l.contextEditorTreeVisible),j=Q(l=>l.toggleContextEditorTree),f=Q(l=>l.allowPromptingSubagentSessions),{themeMode:O,setThemeMode:P,lightThemeId:I,darkThemeId:$,currentTheme:F}=xn(),W=r.useMemo(()=>s?.tabs??[],[s?.tabs]),k=W.find(l=>l.id===s?.activeTabId)??W[W.length-1]??null,v=!!(s?.isOpen&&k),C=!!(v&&s?.expanded),[E,w]=r.useState(null),_=s?.width,q=Hr,X=E??(typeof window<"u"?window.innerWidth:Mn*2),H=Zt(_??Math.round(q*X)),V=r.useMemo(()=>{const l=[];for(const Y of W){if(Y.mode!=="chat")continue;const we=ot(Y.dedupeKey);we&&!l.includes(we)&&l.push(we)}return l},[W]),T=Ko(n||void 0,V),z=wn(n||null),[S,L]=r.useState(!1),ee=r.useRef(0),A=r.useRef(H),Z=r.useRef(null),te=r.useRef(null),de=r.useRef(null),fe=r.useRef(new Map),je=r.useRef(new Map),ge=r.useRef(!1);r.useLayoutEffect(()=>{const l=de.current?.parentElement;if(!l||typeof ResizeObserver>"u")return;const Y=new ResizeObserver(()=>{w(l.clientWidth||null)});return Y.observe(l),w(l.clientWidth||null),()=>Y.disconnect()},[]),r.useEffect(()=>{if(!v||ge.current){ge.current=v;return}const l=window.requestAnimationFrame(()=>{de.current?.focus({preventScroll:!0})});return ge.current=!0,()=>window.cancelAnimationFrame(l)},[v]);const xe=r.useRef(null),ae=r.useRef(null),Ce=r.useCallback(()=>{ae.current=null;const l=de.current,Y=Z.current;!l||Y===null||l.style.setProperty("--oc-context-panel-width",`${Y}px`)},[]);r.useEffect(()=>()=>{ae.current!==null&&clearTimeout(ae.current)},[]);const ke=r.useCallback(l=>{const Y=Zt(l),we=xe.current;return we===null?Y:Math.min(Y,Math.max(1,we))},[]),M=r.useCallback(l=>{!v||C||!n||(te.current=l.pointerId,L(!0),ee.current=l.clientX,A.current=H,Z.current=H,xe.current=Oo(de.current),document.documentElement.style.cursor="col-resize",l.preventDefault())},[n,C,v,H]),B=r.useCallback(()=>{const l=ke(Z.current??H);Z.current=null,xe.current=null,ae.current!==null&&(clearTimeout(ae.current),ae.current=null),document.documentElement.style.cursor="",n&&u(n,l),L(!1),te.current=null},[ke,n,u,H]);r.useEffect(()=>{if(!S)return;const l=Se=>{if(te.current!==Se.pointerId)return;const Xe=ee.current-Se.clientX,ut=ke(A.current+Xe);Z.current!==ut&&(Z.current=ut,ae.current===null&&(ae.current=setTimeout(Ce,Ao)))},Y=Se=>{te.current===Se.pointerId&&B()},we=()=>{B()};return window.addEventListener("pointermove",l),window.addEventListener("pointerup",Y),window.addEventListener("pointercancel",Y),window.addEventListener("blur",we),()=>{window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",Y),window.removeEventListener("pointercancel",Y),window.removeEventListener("blur",we)}},[Ce,ke,B,S]),r.useEffect(()=>{S||(Z.current=null,document.documentElement.style.cursor="")},[S]);const G=r.useCallback(()=>{n&&o(n)},[o,n]),ne=r.useCallback(()=>{n&&y(n)},[n,y]),ie=r.useCallback(l=>{l.key==="Escape"&&(Or(l.target)||(l.preventDefault(),l.stopPropagation(),G()))},[G]);r.useEffect(()=>{if(!(!n||!k)&&k.mode==="file"&&k.targetPath){b(n,k.targetPath,{allowOutsideRoot:!0});return}},[k,n,b]);const ye=k?.mode==="chat"?k.id:null,ue=k?.mode==="chat"?ot(k.dedupeKey):null;r.useEffect(()=>{if(!v||!n||!ue||typeof window>"u")return;const l=()=>{document.visibilityState==="hidden"||!document.hasFocus()||Wr(ue)};l();const Y=window.setInterval(l,1e4);return window.addEventListener("focus",l),window.addEventListener("blur",l),document.addEventListener("visibilitychange",l),()=>{window.clearInterval(Y),window.removeEventListener("focus",l),window.removeEventListener("blur",l),document.removeEventListener("visibilitychange",l)}},[ue,n,v]);const ve=r.useCallback((l,Y,we)=>$r(je.current,l,Y,n||null,we,{mode:O,lightThemeId:I,darkThemeId:$,currentTheme:F}),[F,$,n,I,O]);r.useEffect(()=>{const l=new Set(W.map(Y=>Y.id));for(const Y of je.current.keys())l.has(Y)||je.current.delete(Y)},[W]);const Ee=r.useCallback(l=>{!n||k?.mode!=="diff"||c(n,{mode:"diff",targetPath:k.targetPath,stagedDiff:l==="staged",diffScope:l})},[k,n,c]),Re=r.useCallback(()=>{if(typeof window>"u")return;const l={themeMode:O,lightThemeId:I,darkThemeId:$,currentTheme:F};for(const Y of fe.current.values()){const we=Y.contentWindow;we&&we.postMessage({type:"pichamber:theme-sync",payload:l},window.location.origin)}},[F,$,I,O]),De=r.useCallback(()=>{if(typeof window>"u")return;const l={allowPromptingSubagentSessions:f};for(const Y of fe.current.values()){const we=Y.contentWindow;we&&we.postMessage({type:"pichamber:chat-settings-sync",payload:l},window.location.origin)}},[f]),N=r.useCallback(()=>{if(!(typeof window>"u"))for(const[l,Y]of fe.current.entries()){const we=Y.contentWindow;if(!we)continue;const Se={visible:ye===l};we.postMessage({type:"pichamber:embedded-visibility",payload:Se},window.location.origin)}},[ye]);r.useEffect(()=>{if(typeof window>"u")return;const l=Y=>{if(Y.origin!==window.location.origin||!Array.from(fe.current.values()).some(tt=>tt.contentWindow===Y.source))return;const Se=Y.data;if(Se?.type===Fr){if(typeof Se.requestId!="string"||!Se.requestId)return;const tt=ln(),Fn={apiBaseUrl:lt(),clientToken:qn(),localOrigin:typeof window.__PICHAMBER_LOCAL_ORIGIN__=="string"?window.__PICHAMBER_LOCAL_ORIGIN__:"",runtimeHeaders:Xn(),relayHostId:tt.startsWith("host:")?tt.slice(5):"",relay:Kn()??void 0};Y.source?.postMessage({type:Br,requestId:Se.requestId,payload:Fn},Y.origin);return}if(Se?.type==="pichamber:theme-sync-request"){Re();return}if(Se?.type==="pichamber:chat-settings-request"){De();return}if(Se?.type!=="pichamber:cycle-theme-request")return;const Xe=["light","dark","system"],Wn=(Xe.indexOf(O)+1)%Xe.length;P(Xe[Wn])};return window.addEventListener("message",l),()=>window.removeEventListener("message",l)},[De,Re,P,O]),r.useLayoutEffect(()=>{W.some(Y=>Y.mode==="chat")&&(Re(),De(),N())},[$,I,De,N,Re,W,O]);const oe=k?.mode==="file"||k?.mode==="chat"||k?.mode==="preview",re=r.useMemo(()=>k?W.filter(l=>l.mode===k.mode):[],[k,W]),i=r.useMemo(()=>re.map(l=>{const Y=Fo(l,T,z),we=qo(Y,Mo),Se=$o(l.targetPath,t);return{id:l.id,label:we,icon:en(l,z),title:Se?`${Y}: ${Se}`:Y,closeLabel:`Close ${we} tab`}}),[re,t,z,T]),m=k?.mode==="context"?e.jsx(io,{}):k?.mode==="git"?e.jsx(r.Suspense,{fallback:null,children:e.jsx(To,{isActive:v})}):k?.mode==="notes"?e.jsx(pn,{}):k?.mode==="preview"?e.jsx(Yo,{rawUrl:k.targetPath??"",onNavigate:l=>p(t,l)}):e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[e.jsx(U,{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."})]}),J=r.useMemo(()=>W.filter(l=>l.mode==="chat"),[W]),ce=r.useMemo(()=>W.filter(l=>l.mode==="browser"),[W]),Ne=r.useMemo(()=>W.filter(l=>l.mode==="diff"),[W]),x=r.useMemo(()=>W.some(l=>l.mode==="terminal"),[W]),R=Jo()?Zo:Qo,le=r.useMemo(()=>W.some(l=>l.mode==="file"),[W]),D=r.useMemo(()=>W.some(l=>l.mode==="file"&&l.targetPath),[W]),se=k?.mode==="file",K=e.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[oe?e.jsx(cr,{items:i,activeId:k?.id??null,onSelect:l=>{n&&h(n,l)},onClose:l=>{n&&a(n,l)},onReorder:(l,Y)=>{n&&g(n,l,Y)},layoutMode:"scrollable",variant:"default"}):e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[k?en(k,z):null,e.jsx("span",{className:"truncate typography-ui-label text-foreground",children:k?In(k.mode,z):null})]}),e.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[se?e.jsx(pe,{type:"button",variant:"ghost",size:"sm",onClick:j,className:"h-7 w-7 p-0",title:"Toggle file tree","aria-label":"Toggle file tree","aria-pressed":d,children:e.jsx(U,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,e.jsx(pe,{type:"button",variant:"ghost",size:"sm",onClick:ne,className:"h-7 w-7 p-0",title:C?"Collapse panel":"Expand panel","aria-label":C?"Collapse panel":"Expand panel",children:C?e.jsx(U,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):e.jsx(U,{name:"fullscreen",className:"h-3.5 w-3.5"})}),e.jsx(pe,{type:"button",variant:"ghost",size:"sm",onClick:G,className:"h-7 w-7 p-0",title:"Close panel","aria-label":"Close panel",children:e.jsx(U,{name:"close",className:"h-3.5 w-3.5"})})]})]}),me=v?C?{"--oc-context-panel-width":E!==null?`${E}px`:"100%",width:E!==null?`${E}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${H}px`}:{"--oc-context-panel-width":`${H}px`,width:0,maxWidth:"100%",overflowX:"clip"};return e.jsxs("aside",{ref:de,"data-context-panel":"true",tabIndex:-1,inert:!v||void 0,className:be("flex min-h-0 flex-col overflow-hidden bg-background",C?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!v&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:ie,style:me,children:[v&&!C&&e.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),v&&e.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!C&&e.jsx("div",{className:be("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",S&&"bg-[var(--interactive-border)]"),onPointerDown:M,role:"separator","aria-orientation":"vertical","aria-label":"Resize context panel"}),e.jsxs("div",{className:be("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]",!v&&"pointer-events-none select-none opacity-0"),style:{width:C?E!==null?`${E}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!v,children:[K,e.jsxs("div",{className:be("relative min-h-0 flex-1 overflow-hidden",S&&"pointer-events-none"),children:[le?e.jsxs("div",{className:be("absolute inset-0 flex",se?"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(Ro,{mode:"editor-only"})}):e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[e.jsx(U,{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(Uo,{visible:d})]}):null,J.map(l=>{const Y=ot(l.dedupeKey);if(!Y)return null;const we=ve(l.id,Y,l.readOnly);return we?e.jsx("iframe",{ref:Se=>{if(!Se){fe.current.delete(l.id);return}fe.current.set(l.id,Se)},src:we,title:`Session chat ${Y}`,className:be("absolute inset-0 h-full w-full border-0 bg-background",ye===l.id?"block":"hidden"),onLoad:()=>{Re(),De(),N()}},l.id):null}),ce.map(l=>e.jsx("div",{className:be("absolute inset-0",k?.id!==l.id&&"hidden"),children:e.jsx(R,{initialUrl:l.targetPath??"",directory:n,tabID:l.id})},l.id)),v?Ne.filter(l=>k?.id===l.id).map(l=>e.jsx("div",{className:"absolute inset-0",children:e.jsx(r.Suspense,{fallback:null,children:e.jsx(Eo,{hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:l.diffScope??(l.stagedDiff?"staged":"working"),onDiffScopeChange:Ee,targetFilePath:l.targetPath,flushContent:!0})})},l.id)):null,x?e.jsx("div",{className:be("absolute inset-0",k?.mode==="terminal"?"block":"hidden"),children:e.jsx(fn,{visible:v&&k?.mode==="terminal"})}):null,v&&k?.mode!=="chat"&&!se&&k?.mode!=="browser"&&k?.mode!=="diff"&&k?.mode!=="terminal"?m:null]})]})]})},ta=150,na=500,ra=[],sa=t=>t>99?"99+":String(t),oa=({surface:t,isActive:n,showActivityDot:s,label:o,description:a,badgeCount:c,badgeAriaLabel:y,badgeDescription:u,orderNumber:h,showOrderNumber:g,onSelect:b})=>{const{attributes:p,listeners:d,setNodeRef:j,transform:f,transition:O,isDragging:P}=Ps({id:t.id}),I=c!=null&&c>0?sa(c):null;return e.jsx("div",{ref:j,style:{transform:Es.Translate.toString(f),transition:O},className:be("relative",P&&"z-10 opacity-70"),children:e.jsxs(Be,{delayDuration:ta,children:[e.jsx(ze,{asChild:!0,children:e.jsxs("button",{type:"button",...p,...d,onClick:()=>b(t),"aria-label":y??o,"aria-pressed":n,className:be("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:[e.jsx(U,{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}):I?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:I}):s?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(Ue,{side:"left",sideOffset:8,children:e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{children:o}),e.jsx("span",{className:"typography-micro text-muted-foreground",children:a}),u?e.jsx("span",{className:"typography-micro text-muted-foreground",children:u}):null]})})]})})},aa=()=>{const t=et(),n=t?Gn(t):"",s=Q(v=>n?v.contextPanelByDirectory[n]:void 0),o=Q(v=>v.contextRailOrder),a=Q(v=>v.setContextRailOrder),c=Q(v=>v.openContextSurface),y=Q(v=>v.shortcutOverrides),{screenWidth:u}=Tt(),{git:h}=vt(),g=mn(n||null),b=wn(n||null),p=bn(v=>v.ensureStatus);r.useEffect(()=>{n&&p(n,h)},[n,p,h]);const d=r.useMemo(()=>Vr("switch_context_surface",y),[y]),[j,f]=r.useState(!1);r.useEffect(()=>{const v=new Set;let C=null,E=!1;const w=V=>V.length===1&&V>="0"&&V<="9",_=()=>{Bt(d,v)?!E&&C===null&&(C=setTimeout(()=>f(!0),na)):(E=!1,C!==null&&(clearTimeout(C),C=null),f(!1))},q=V=>{if(v.add(V.key.toLowerCase()),w(V.key)&&Bt(d,v)){E=!0,C!==null&&(clearTimeout(C),C=null),f(!1);return}_()},X=V=>{v.delete(V.key.toLowerCase()),_()},H=()=>{v.clear(),E=!1,C!==null&&(clearTimeout(C),C=null),f(!1)};return window.addEventListener("keydown",q,!0),window.addEventListener("keyup",X,!0),window.addEventListener("blur",H),()=>{window.removeEventListener("keydown",q,!0),window.removeEventListener("keyup",X,!0),window.removeEventListener("blur",H),C!==null&&clearTimeout(C)}},[d]);const O=ys(Ut(vs,{activationConstraint:{distance:8}}),Ut(bs,{activationConstraint:{delay:200,tolerance:6}})),P=s?.tabs??ra,I=P.find(v=>v.id===s?.activeTabId)??null,$=s?.isOpen?I?.mode??null:null,F=g?.files.length??0,W=r.useMemo(()=>Kr({railOrder:o,tabs:P}),[o,u,P]),k=r.useCallback(v=>{const{active:C,over:E}=v;if(!E||C.id===E.id)return;const w=Xr(Q.getState().contextRailOrder).map(X=>X.id),_=w.indexOf(C.id),q=w.indexOf(E.id);_===-1||q===-1||a(Cs(w,_,q))},[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(Ss,{sensors:O,collisionDetection:js,onDragEnd:k,children:e.jsx(ks,{items:W.map(v=>v.id),strategy:Ns,children:W.map((v,C)=>{const E=v.id==="git"?Pt(b):null,w=E?{...v,...E}:v,_=w.label,q=v.id==="git"&&b===!0?F:0,X=q>0?q:null;return e.jsx(oa,{surface:w,isActive:$===v.mode,showActivityDot:!1,label:_,description:w.description,badgeCount:X,badgeAriaLabel:X!==null?X===1?"{label}, {count} changed file":"{label}, {count} changed files":null,badgeDescription:X!==null?X===1?"{count} changed file":"{count} changed files":null,orderNumber:C+1,showOrderNumber:j,onSelect:H=>c(n,H.mode)},v.id)})})})}):null},ia=(t,n)=>!t||n.length===0?"":JSON.stringify([t,n]),la=(t,n,s,o)=>!s||o!==s||t.length===0?[]:Je(t,n,a=>a.name,{limit:10,threshold:.4}),ca=new Set,xt=t=>{if(!t)return"";const n=t.replace(/\\/g,"/"),s=n.startsWith("//");let o=n.replace(/\/+/g,"/");s&&!o.startsWith("//")&&(o=`/${o}`);const a=o==="/",c=/^[A-Za-z]:\/$/.test(o);return!a&&!c&&(o=o.replace(/\/+$/,"")),o},da=()=>{const t=Q(i=>i.isCommandPaletteOpen),n=Q(i=>i.setCommandPaletteOpen),s=Q(i=>i.setActiveMainTab),o=Q(i=>i.setSettingsDialogOpen),a=Q(i=>i.setSettingsPage),c=Q(i=>i.setSessionSwitcherOpen),y=Q(i=>i.toggleSidebar),u=Q(i=>i.openContextOverview),h=Q(i=>i.openContextSurface),g=Q(i=>i.openContextFile),b=Q(i=>i.shortcutOverrides),p=Ie(i=>i.openNewSessionDraft),d=Ie(i=>i.setCurrentSession),j=qr({archived:!1}),f=Gr(r.useCallback(i=>t?i.ids:ca,[t])),O=Yr(r.useCallback(i=>t?i.rankById:Jr,[t])),P=Yn(i=>i.currentDirectory),I=zt(i=>i.getActiveProject()),$=zt(i=>i.projects),F=et(),W=an(i=>i.searchFiles),{files:k,git:v}=vt(),C=bn(i=>i.ensureStatus),{isMobile:E}=Tt(),w=r.useMemo(()=>F?xt(F):null,[F]),[_,q]=r.useState(""),H=gn(_,200).trim(),V=_.trim();r.useEffect(()=>{t&&q("")},[t]),r.useEffect(()=>{if(!t||!v)return;const i=setTimeout(()=>{const m=new Set;for(const J of j){const ce=ht(J);!ce||m.has(ce)||(m.add(ce),C(ce,v))}},0);return()=>clearTimeout(i)},[t,j,v,C]);const T=r.useCallback(()=>n(!1),[n]),z=r.useCallback(i=>()=>{T(),i()},[T]),S=r.useMemo(()=>{const i=[{id:"new-session",title:"New Session",icon:e.jsx(U,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:"New Session",onSelect:z(()=>{s("chat"),c(!1),p()})},{id:"add-project",title:"Add Project",icon:e.jsx(U,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:"Add Project",onSelect:z(()=>{Qr.requestDirectoryDialog()})},{id:"toggle-sidebar",title:E?"Show Session Switcher":"Toggle Sidebar",icon:e.jsx(U,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:E?"Show Session Switcher":"Toggle Sidebar",onSelect:z(()=>{if(E){const{isSessionSwitcherOpen:m}=Q.getState();c(!m)}else y()})},{id:"toggle-terminal",title:"Toggle Terminal",icon:e.jsx(U,{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(U,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:"Show Context Usage",onSelect:z(()=>{P&&u(P)})},{id:"open-settings",title:"Open Settings...",icon:e.jsx(U,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:"Open Settings...",onSelect:z(()=>o(!0))}];return Jn()&&i.splice(1,0,{id:"new-mini-chat",title:"New Mini Chat Window",icon:e.jsx(U,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:"New Mini Chat Window",onSelect:z(()=>{cn("desktop_open_draft_mini_chat_window",{directory:xt(P||I?.path||""),projectId:I?.id??null}).catch(m=>{console.warn("[command-palette] failed to open draft mini chat window",m)})})}),i},[z,E,s,c,p,y,h,P,u,o,I?.id,I?.path]),L=r.useMemo(()=>{const i=Qn();return{isWeb:!i&&Zn(),isDesktop:i,isMobile:E}},[E]),ee=r.useMemo(()=>ur.filter(i=>i.slug!=="home").filter(i=>i.isAvailable?i.isAvailable(L):!0).map(i=>{const m=hr(i.slug)??"settings-3",J=(i.keywords??[]).join(" ");return{id:`settings:${i.slug}`,title:i.title,icon:e.jsx(U,{name:m,className:"mr-2 h-4 w-4"}),searchText:`${i.title} ${i.group} ${J}`,onSelect:z(()=>{a(i.slug),o(!0)})}}),[L,z,a,o]),A=r.useMemo(()=>Zr(j,f,O),[j,f,O]),Z=es(),te=r.useCallback((i,m)=>m&&Z.get(m)?.trim()||null,[Z]),[de,fe]=r.useState([]),[je,ge]=r.useState(""),xe=ia(w,H);r.useEffect(()=>{if(!t){fe([]),ge("");return}if(!xe){fe([]),ge("");return}if(!w){fe([]),ge("");return}let i=!1;return W(w,H,10,{type:"file"}).then(m=>{i||(fe(m.map(J=>({path:xt(J.path),name:J.name,relativePath:J.relativePath}))),ge(xe))}).catch(()=>{i||(fe([]),ge(xe))}),()=>{i=!0}},[t,w,H,xe,W]);const ae=V.length>0,Ce=r.useMemo(()=>ae?Je(S,V,i=>i.searchText,{limit:7,noFuzzy:!0}):S.map(i=>({item:i,score:0})),[S,V,ae]),ke=r.useMemo(()=>ae?Je(ee,V,i=>i.searchText,{limit:7,noFuzzy:!0}):[],[ee,V,ae]),M=r.useMemo(()=>ae?Je(A,V,i=>i.title||"",{limit:7,threshold:.2}):A.slice(0,5).map(i=>({item:i,score:0})),[A,V,ae]),B=r.useMemo(()=>t?la(de,H,xe,je):[],[t,de,je,xe,H]),G=t&&xe.length>0&&je!==xe,ne=r.useMemo(()=>{if(!ae)return[];const i=$.map(m=>({...m,displayName:m.label||m.path.split("/").pop()||m.path,searchText:`${m.label||""} ${m.path}`}));return Je(i,V,m=>m.searchText,{limit:7,threshold:.4})},[$,V,ae]),ie=Ce.map(i=>i.item),ye=ke.map(i=>i.item),ue=M.map(i=>i.item),ve=ae?B.map(i=>i.item):[],Ee=ae?ne.map(i=>i.item):[],Re=r.useMemo(()=>{if(!ae)return["commands","sessions"];const i=J=>J.length?J[0].score:1/0,m=[{key:"commands",score:i(Ce)},{key:"settings",score:i(ke)},{key:"sessions",score:i(M)},{key:"files",score:i(B)},{key:"projects",score:i(ne)}];return m.sort((J,ce)=>J.score-ce.score),m.map(J=>J.key)},[ae,Ce,ke,M,B,ne]),De=r.useCallback(i=>{T(),d(i.id,ht(i))},[T,d]),N=r.useCallback(async i=>{if(!w)return;const m=await jn(k,i,{directory:w});if(!m.ok){he.error(Cn(m.reason));return}g(w,i),T()},[w,k,g,T]),oe=r.useCallback((i,m)=>{T(),p({selectedProjectId:i,directoryOverride:m})},[T,p]),re=r.useCallback(i=>vn(Sn(i,b)),[b]);return e.jsxs(St,{open:t,onOpenChange:n,children:[e.jsxs(Ct,{className:"sr-only",children:[e.jsx(kt,{children:"Command Palette"}),e.jsx(Nt,{children:"Search files, sessions, and commands."})]}),e.jsx(jt,{className:"overflow-hidden p-0",showCloseButton:!0,children:e.jsxs(ts,{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(ns,{value:_,onValueChange:q,placeholder:"Search files, sessions, commands..."}),e.jsxs(rs,{children:[e.jsx(ss,{children:"No results found."}),Re.map(i=>i==="commands"&&ie.length>0?e.jsx(qe,{children:ie.map(m=>e.jsxs(Ge,{value:m.id,onSelect:m.onSelect,children:[m.icon,e.jsx("span",{children:m.title}),m.shortcutId?e.jsx(os,{children:re(m.shortcutId)}):null]},m.id))},"commands"):i==="settings"&&ye.length>0?e.jsx(qe,{children:ye.map(m=>e.jsxs(Ge,{value:m.id,onSelect:m.onSelect,children:[m.icon,e.jsx("span",{children:m.title})]},m.id))},"settings"):i==="sessions"&&ue.length>0?e.jsx(qe,{children:ue.map(m=>{const J=m.title||"Untitled Session",ce=ht(m),Ne=te(m.id,ce);return e.jsxs(Ge,{value:`session:${m.id}`,onSelect:()=>De(m),children:[e.jsx(U,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"truncate",children:J}),Ne?e.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[e.jsx(U,{name:"git-branch",className:"h-3 w-3"}),e.jsx("span",{className:"truncate max-w-[160px]",children:Ne})]}):null]},m.id)})},"sessions"):i==="files"&&ve.length>0?e.jsx(qe,{children:ve.map(m=>{const J=as(m.relativePath||m.name,{maxLength:80});return e.jsxs(Ge,{value:`file:${m.path}`,onSelect:()=>{N(m.path)},children:[e.jsx(yt,{filePath:m.path,className:"mr-2 size-4 shrink-0"}),e.jsx("span",{className:"truncate","aria-label":m.relativePath,children:J})]},`file:${m.path}`)})},"files"):i==="projects"&&Ee.length>0?e.jsx(qe,{children:Ee.map(m=>{const J=m.displayName;return e.jsxs(Ge,{value:`project:${m.id}`,onSelect:()=>oe(m.id,m.path),children:[e.jsx(U,{name:"folder",className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"truncate",children:J}),e.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:m.path})]},`project:${m.id}`)})},"projects"):null),G?e.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:"Searching files..."}):null]})]})})]})},sn=(t,n,s)=>ls(t)?vn(Sn(t,s)):n,ua=()=>{const t=Q(c=>c.isHelpDialogOpen),n=Q(c=>c.setHelpDialogOpen),s=Q(c=>c.shortcutOverrides),o=is(),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 + ${o} + 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:"toggle_prompt_navigator",descriptionKey:"Toggle Prompt Navigator",icon:"list-unordered",keys:""},{id:"abort_run",descriptionKey:"Abort active run (double press)",icon:"close-circle",keys:""}]},{categoryKey:"Panels",items:[{id:"toggle_right_sidebar",descriptionKey:"helpDialog.item.toggleRightSidebar",icon:"layout-right",keys:""},{id:"open_right_sidebar_git",descriptionKey:"helpDialog.item.openRightSidebarGitTab",icon:"git-branch",keys:""},{id:"open_right_sidebar_files",descriptionKey:"helpDialog.item.openRightSidebarFilesTab",icon:"layout-right",keys:""},{id:"toggle_terminal",descriptionKey:"helpDialog.item.toggleTerminalDock",icon:"window",keys:""},{id:"toggle_terminal_expanded",descriptionKey:"helpDialog.item.toggleTerminalExpanded",icon:"window",keys:""},{keys:[`${o} + 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:"cycle_services_tab",descriptionKey:"helpDialog.item.cycleServicesTab",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:"max-w-2xl w-[min(42rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden",children:[e.jsxs(Ct,{children:[e.jsxs(kt,{className:"flex items-center gap-2",children:[e.jsx(U,{name:"command",className:"h-5 w-5"}),"Keyboard Shortcuts"]}),e.jsx(Nt,{children:"Use these keyboard shortcuts to navigate PiChamber efficiently"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto mt-3 pr-1",children:[e.jsx("div",{className:"space-y-4",children:a.map(c=>e.jsxs("div",{children:[e.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:c.categoryKey}),e.jsx("div",{className:"space-y-1",children:c.items.map(y=>{const u=y.id?sn(y.id,Array.isArray(y.keys)?y.keys[0]:y.keys,s):Array.isArray(y.keys)?y.keys:y.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:[y.icon&&e.jsx(U,{name:y.icon,className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"typography-meta",children:y.descriptionKey})]}),e.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(u)?u:[u]).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}`))})]},y.id||y.descriptionKey)})})]},c.categoryKey))}),e.jsx("div",{className:"mt-4 p-2 bg-muted/30 rounded-xl",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(U,{name:"question",className:"h-3.5 w-3.5 text-muted-foreground mt-0.5"}),e.jsxs("div",{className:"typography-meta text-muted-foreground",children:[e.jsx("p",{className:"font-medium mb-1",children:"Pro Tips:"}),e.jsxs("ul",{className:"space-y-0.5 typography-meta",children:[e.jsxs("li",{children:["• ",`Use Command Palette (${sn("open_command_palette",`${o} P`,s)}) to quickly access all actions`]}),e.jsxs("li",{children:["• ","The 5 most recent sessions appear in the Command Palette"]}),e.jsxs("li",{children:["• ","Theme cycling remembers your preference across sessions"]})]})]})]})})]})]})})},ha=r.createContext(null),pa=({children:t,value:n})=>e.jsx(ha.Provider,{value:n,children:t}),on=We(()=>Le(()=>import("./GitView-CYF1E1p4.js"),__vite__mapDeps([127,8,1,2,6,3,4,5,7,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,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,111,112,113,128,115,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,114,116,117])).then(t=>({default:t.GitView}))),fa=We(()=>Le(()=>import("./DiffView-D1dyOiw2.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,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118])).then(t=>({default:t.DiffView}))),ma=We(()=>Le(()=>import("./FilesView-BCzghrc7.js"),__vite__mapDeps([119,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,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,111,112,113,120,121,122,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,123,124,116,117,125,126,114,115])).then(t=>({default:t.FilesView}))),ga=We(()=>Le(()=>import("./DiagramView-3hAT86v_.js"),__vite__mapDeps([129,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,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,125,126])).then(t=>({default:t.DiagramView}))),xa=We(()=>Le(()=>import("./SettingsView-JAfC_cBL.js").then(t=>t.b),__vite__mapDeps([130,1,2,6,3,4,5,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,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,111,112,113,131,132,115])).then(t=>({default:t.SettingsView}))),wa=We(()=>Le(()=>import("./SettingsWindow-BBEsjcJE.js"),__vite__mapDeps([133,1,2,6,3,4,5,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,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,130,111,112,113,131,132,115])).then(t=>({default:t.SettingsWindow}))),ya=()=>{const t=Q(S=>S.isSidebarOpen),n=Q(S=>S.activeMainTab),s=Q(S=>S.setIsMobile),o=Q(S=>S.isSessionSwitcherOpen),a=Q(S=>S.isSettingsDialogOpen),c=Q(S=>S.setSettingsDialogOpen),[y,u]=r.useState(!1);r.useEffect(()=>{a&&u(!0)},[a]),r.useEffect(()=>{const S=()=>Q.getState().closeMainSurfaces(),L=Ie.subscribe((A,Z)=>{const te=!!A.currentSessionId&&A.currentSessionId!==Z.currentSessionId,de=!!A.newSessionDraft?.open&&A.newSessionDraft!==Z.newSessionDraft;(te||de)&&S()}),ee=Q.subscribe((A,Z)=>{A.activeMainTab!==Z.activeMainTab&&S()});return()=>{L(),ee()}},[]);const{isMobile:h}=Tt(),g=r.useRef(!1),[b,p]=r.useState(!1),[d,j]=r.useState(!1),[f,O]=r.useState(!1),[P,I]=r.useState(!1),$=r.useCallback(S=>{p(S),Q.getState().setSessionSwitcherOpen(S)},[]),F=r.useRef(typeof window>"u"?0:window.innerWidth),W=r.useRef(null),k=r.useRef(!1),v=r.useRef(!1),C=r.useRef(!1),E=r.useRef(null),w=r.useRef(null),_=Ht(-F.current),q=_e.useRef(0),X=Ht(F.current),H=_e.useRef(0);_e.useEffect(()=>{h&&(q.current=window.innerWidth,H.current=window.innerWidth)},[h]),_e.useEffect(()=>{if(!h)return;const S=()=>{const L=window.innerWidth;q.current=L,H.current=L,b||_.get()<-10&&_.set(-L),d||X.get()>10&&X.set(L)};return window.addEventListener("resize",S),window.addEventListener("orientationchange",S),()=>{window.removeEventListener("resize",S),window.removeEventListener("orientationchange",S)}},[h,_,X,b,d]),_e.useEffect(()=>{if(!h){O(!1);return}b&&O(!0);const S=q.current||F.current||(typeof window<"u"?window.innerWidth:0),L=nt(_,b?0:-S,{type:"spring",stiffness:400,damping:35,mass:.8});return E.current=L,()=>L.stop()},[b,h,_]),_e.useEffect(()=>{if(!h){I(!1);return}d&&I(!0);const S=H.current||F.current||(typeof window<"u"?window.innerWidth:0),L=nt(X,d?0:S,{type:"spring",stiffness:400,damping:35,mass:.8});return w.current=L,()=>L.stop()},[h,d,X]),_e.useEffect(()=>{if(h)return _.on("change",S=>{const L=q.current||F.current,ee=b||S>-L+.5;O(A=>A===ee?A:ee)})},[h,_,b]),_e.useEffect(()=>{if(h)return X.on("change",S=>{const L=H.current||F.current,ee=d||S<L-.5;I(A=>A===ee?A:ee)})},[h,d,X]),_e.useEffect(()=>{h&&!o&&b&&$(!1)},[o,h,b,$]),_e.useEffect(()=>{if(!h){g.current=!1;return}g.current||(g.current=!0,$(!1),j(!1))},[h,$]),_e.useEffect(()=>{if(!h||n!=="chat"||b||d||a)return;let S=!1,L;const ee=A=>{L=window.setTimeout(()=>{if(S)return;const Z=Ie.getState(),te=Q.getState();if(!(te.activeMainTab!=="chat"||te.isSettingsDialogOpen||Z.currentSessionId||Z.newSessionDraft?.open)){if(Z.isLoading){ee(250);return}Z.openNewSessionDraft({automatic:!0})}},A)};return ee(500),()=>{S=!0,L!==void 0&&window.clearTimeout(L)}},[n,h,a,b,d]),_e.useEffect(()=>{!h||!a||($(!1),j(!1))},[h,a,$]),r.useEffect(()=>{Q.getState().isMobile!==h&&s(h)},[h,s]);const V=r.useCallback(()=>{b&&$(!1),j(!d)},[b,d,$]);pr(W,{enabled:h,leftOpen:b,rightOpen:d,leftWidth:()=>q.current||F.current||(typeof window<"u"?window.innerWidth:0),rightWidth:()=>H.current||F.current||(typeof window<"u"?window.innerWidth:0),onLeftProgress:S=>{const L=q.current||F.current||(typeof window<"u"?window.innerWidth:0);_.set(L*(S-1))},onRightProgress:S=>{const L=H.current||F.current||(typeof window<"u"?window.innerWidth:0);X.set(L*(1-S))},onLeftOpen:()=>{d&&j(!1),$(!0)},onLeftClose:()=>$(!1),onRightOpen:()=>{b&&$(!1),j(!0)},onRightClose:()=>j(!1),onDragStart:S=>{k.current=!0,S==="left"?(v.current=b,E.current?.stop(),f||O(!0)):(C.current=d,w.current?.stop(),P||I(!0))},onDragEnd:(S,L)=>{if(k.current=!1,S==="left"&&typeof L=="boolean"){const ee=v.current;if(L===ee){const A=q.current||F.current||(typeof window<"u"?window.innerWidth:0),Z=nt(_,ee?0:-A,{type:"spring",stiffness:400,damping:35,mass:.8});E.current=Z}}if(S==="right"&&typeof L=="boolean"){const ee=C.current;if(L===ee){const A=H.current||F.current||(typeof window<"u"?window.innerWidth:0),Z=nt(X,ee?0:A,{type:"spring",stiffness:400,damping:35,mass:.8});w.current=Z}}}});const T=r.useMemo(()=>{if(!h&&n!=="terminal"&&n!=="diagram"||h&&n==="git"&&(d||P))return null;switch(n){case"git":return e.jsx(r.Suspense,{fallback:null,children:e.jsx(on,{isActive:!0})});case"diff":return e.jsx(r.Suspense,{fallback:null,children:e.jsx(fa,{})});case"terminal":return e.jsx(fn,{});case"files":return e.jsx(r.Suspense,{fallback:null,children:e.jsx(ma,{})});case"context":return e.jsx(r.Suspense,{fallback:null,children:e.jsx(pn,{})});case"diagram":return e.jsx(r.Suspense,{fallback:null,children:e.jsx(ga,{})});default:return null}},[n,h,P,d]),z=n==="chat";return e.jsxs(fr,{children:[e.jsx(mr,{}),e.jsxs("div",{"data-page-scroll-lock":"true",className:be("main-content-safe-area",h?"flex h-[100dvh] flex-col":"relative flex h-[100dvh]","bg-background"),children:[e.jsx(da,{}),e.jsx(ua,{}),e.jsx(gr,{}),h?e.jsxs(pa,{value:{leftDrawerOpen:b,rightDrawerOpen:d,toggleLeftDrawer:()=>{const S=!b;d&&j(!1),$(S)},toggleRightDrawer:V,leftDrawerX:_,rightDrawerX:X,leftDrawerWidth:q,rightDrawerWidth:H,setMobileLeftDrawerOpen:$,setRightSidebarOpen:j},children:[!a&&e.jsx(Lt,{onToggleLeftDrawer:()=>{const S=!b;d&&j(!1),$(S)},onToggleRightDrawer:()=>{V()},leftDrawerOpen:b,rightDrawerOpen:d}),e.jsx("div",{"data-page-scroll-lock":"true",className:be("flex flex-1 overflow-hidden relative",a&&"hidden"),children:e.jsxs("main",{ref:W,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:be("absolute inset-0",!z&&"invisible"),children:e.jsx(Me,{children:e.jsx(Ot,{active:z&&!a})})}),T&&e.jsx("div",{className:"absolute inset-0",children:e.jsx(Me,{children:T})}),e.jsx(Me,{children:e.jsx($t,{})}),e.jsx(Vt.div,{className:be("absolute inset-0 z-20 bg-sidebar",!f&&"pointer-events-none invisible"),"data-page-scroll-lock":"true",style:{x:_},"aria-hidden":!b,children:e.jsx(Me,{children:e.jsx(Wt,{mobileVariant:!0,isVisible:f})})}),e.jsx(Vt.div,{className:be("absolute inset-0 z-20 bg-sidebar",!P&&"pointer-events-none invisible"),"data-page-scroll-lock":"true",style:{x:X},"aria-hidden":!d,children:e.jsx(Me,{children:d||P?e.jsx(r.Suspense,{fallback:null,children:e.jsx(on,{isActive:d})}):null})})]})}),a&&e.jsx("div",{className:"absolute inset-0 z-10 bg-background",style:{paddingTop:"var(--oc-safe-area-top, 0px)"},children:e.jsx(Me,{children:e.jsx(r.Suspense,{fallback:null,children:e.jsx(xa,{onClose:()=>c(!1)})})})})]}):e.jsxs(e.Fragment,{children:[e.jsx(xr,{}),e.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[e.jsx(Rs,{isOpen:t,isMobile:h,className:"border-border",children:e.jsx(Wt,{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(Lt,{}),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:be("absolute inset-0",!z&&"invisible"),children:e.jsx(Me,{children:e.jsx(Ot,{active:z&&!a})})}),T&&e.jsx("div",{className:"absolute inset-0",children:e.jsx(Me,{children:T})}),e.jsx(Me,{children:e.jsx($t,{})})]}),e.jsx(ea,{})]})})}),e.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:e.jsx(Me,{children:e.jsx(aa,{})})})]})]})]}),y?e.jsx(r.Suspense,{fallback:null,children:e.jsx(wa,{open:a,onOpenChange:c})}):null]})]})]})},ba=()=>(hs(),yr(),e.jsxs(br,{children:[e.jsx(ps,{embeddedBackgroundWorkEnabled:!0}),e.jsx(ya,{}),e.jsx(fs,{}),e.jsx(ms,{})]}));function va({apis:t}){const n=t??hn(),[s,o]=r.useState(0);return r.useEffect(()=>er(a=>{a.runtimeKey!==a.previousRuntimeKey&&(wr(a),o(c=>c+1))}),[]),r.useEffect(()=>{tr()},[s]),r.useEffect(()=>{n&&nr(n)},[n]),n?e.jsx(Me,{children:e.jsx("div",{className:"h-full w-full overflow-hidden bg-background text-foreground",children:e.jsx(cs,{apis:n,children:e.jsx(ds,{children:e.jsx(us,{children:e.jsx(ba,{})})},s)})})}):e.jsx(Me,{children:e.jsx("div",{className:"h-full w-full overflow-hidden bg-background text-foreground"})})}const $n=document.getElementById("root");if(!$n)throw new Error("Root element not found");Bn.createRoot($n).render(e.jsx(_e.StrictMode,{children:e.jsx(gs,{children:e.jsx(xs,{children:e.jsx(ws,{children:e.jsx(va,{apis:hn()??void 0})})})})}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as n,R as a,e as ye,r as we}from"./vendor-react-DYyjh7Q0.js";import"./vendor-katex-CHD9BdDO.js";import{l as T,Q as ge,C as U,u as Y,J as xe,q as se,o as ve,w as Se,v as Ie}from"./index-CH7o4-_q.js";import{u as be,a as je,b as De,s as Ce,c as Pe,d as Me}from"./useWindowTitle-CE5N_NeU.js";import{c$ as Ee,h,bp as ke,b as Z,a5 as f,aB as ee,d0 as _e,C as Le,K as Ne,cN as Ae,ck as Re,cY as ie,cW as Oe,I as $,cX as Be,B as ae,f as Te,cV as N,d1 as ce,d2 as ze,c1 as Ue,t as We,b5 as He,aa as Fe,ab as $e,X as Ge,ad as Ve,ae as Ke,af as qe,ah as Je,ai as Xe,d3 as Qe,cl as Ye,ap as Ze,aq as et,ar as tt}from"./SessionSwitcherDropdown-C0OdvirK.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zustand-CnsBKjP5.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./runtimeSurface-Bec4O8FD.js";import"./vendor-dnd-kit-core-GipZW2tY.js";import"./vendor-dnd-kit-utilities-CrOcp0Bp.js";import"./vendor-dnd-kit-accessibility-Cv52zwWT.js";import"./vendor-dnd-kit-sortable-Ct2QxIHb.js";import"./vendor-base-ui-DwfTg5wD.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-react-dom-sVFnuruh.js";import"./vendor-floating-ui-dom-Bkw82kL9.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-use-sync-external-store-B7OScDIw.js";import"./vendor-cmdk-BCEUzcHE.js";import"./vendor-radix-ui-react-dialog-jX3Dld8c.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-D1GnwnP9.js";import"./vendor-radix-ui-react-context-CM4yFQ2I.js";import"./vendor-radix-ui-react-id-BcxRjnbX.js";import"./vendor-radix-ui-react-use-layout-effect-0fyGwS2_.js";import"./vendor-radix-ui-react-use-controllable-state-C_ecoh35.js";import"./vendor-radix-ui-react-dismissable-layer-M7LsH3yL.js";import"./vendor-radix-ui-react-primitive-CfpW6_IT.js";import"./vendor-radix-ui-react-slot-BxUc3Pvz.js";import"./vendor-radix-ui-react-use-callback-ref-UKEWHtoP.js";import"./vendor-radix-ui-react-use-escape-keydown-Co13lHGj.js";import"./vendor-radix-ui-react-focus-scope-C2K7lNPv.js";import"./vendor-radix-ui-react-portal-xlJWBfDg.js";import"./vendor-radix-ui-react-presence-Btn-Dp7L.js";import"./vendor-radix-ui-react-focus-guards-D5MZ0nQs.js";import"./vendor-react-remove-scroll-CfeMe0DL.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-C9YRs2nU.js";import"./vendor-react-style-singleton-B1H4bWSG.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-C-AuTczP.js";import"./vendor-use-callback-ref-CJB0R85I.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-E2vgV9K3.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-DSzLbZiS.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-BUlYhQ3o.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-BS2SpSAZ.js";import"./vendor-codemirror-lang-json-CqayksDf.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-Ba8JZ6fp.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-DK27qQri.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-CvO36Y1p.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-q1yHU1R9.js";import"./vendor-codemirror-lang-python-_2bIYTiJ.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-RrgJ8H_6.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tanstack-react-virtual-IrbCBGJ4.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-DJASDzNt.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-dWA7qvjr.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";const rt=({mode:e,children:r})=>n.jsx(Ee.Provider,{value:e,children:r}),nt=e=>{const r=typeof e=="string"?e.trim():"";if(!r)return"";const o=typeof window<"u"?window.__PICHAMBER_HOME__:"";if(o&&r===o)return"~";if(o&&r.startsWith(`${o}/`))return`~/${r.slice(o.length+1)}`;const d=r.split("/").filter(Boolean);return d.length<=3?r:`.../${d.slice(-3).join("/")}`},G=e=>{const r=typeof e=="string"?e.trim():"";if(!r)return"";const o=r.replace(/\\/g,"/");return o==="/"?"/":o.replace(/\/+$/,"")},ot=({mode:e})=>{const r=h(t=>t.currentSessionId),o=h(t=>!!t.newSessionDraft?.open),d=h(t=>t.newSessionDraft?.selectedProjectId??null),i=T(t=>t.currentDirectory),u=Z(t=>t.projects),c=Z(t=>t.getActiveProject()),M=f(t=>t.getCurrentModel),_=f(t=>t.providers),p=ee(),m=_e(r??""),E=Le(),D=Ne(t=>t.ensureStatus),k=h(t=>t.newSessionDraft?.open?G(t.newSessionDraft.directoryOverride??""):""),[w,v]=a.useState(!1),C=typeof window<"u"?window.__PICHAMBER_MACOS_MAJOR__??0:0,S=Number.isFinite(C)&&C>0,{usesFramelessChrome:x,side:A}=Ae(),s=S?C>=26?"h-12":C<=15?"h-14":"":"",g=a.useMemo(()=>r?p.find(t=>t.id===r)??null:null,[r,p]);a.useEffect(()=>{ge()&&U("desktop_get_window_pinned").then(t=>{typeof t?.pinned=="boolean"&&v(t.pinned)})},[]);const y=g?.title?.trim()||(o||e==="draft"?"New session":"Session"),I=G(g?.directory??null),V=G(i),b=I||k||V,te=nt(b);a.useEffect(()=>{b&&D(b,E.git).catch(()=>{})},[D,b,E.git]);const re=a.useMemo(()=>{const t=b;return t?u.map(l=>({...l,normalizedPath:G(l.path)})).filter(l=>l.normalizedPath&&(l.normalizedPath===t||t.startsWith(`${l.normalizedPath}/`))).sort((l,B)=>B.path.length-l.path.length)[0]??null:null},[b,u]),de=a.useMemo(()=>{const t=re??c;if(!t)return te||"PiChamber";const l=t.label?.trim();return l||(t.path.split(/[\\/]/).filter(Boolean).at(-1)??t.path)},[c,te,re]),K=Re(b||null),ne=K&&K!=="HEAD"?K:null,oe=M(),le=a.useMemo(()=>{for(let t=m.length-1;t>=0;t-=1){const l=m[t];if(l.role!=="assistant"||typeof l.providerID!="string"||typeof l.modelID!="string")continue;const F=_.find(z=>z.id===l.providerID)?.models.find(z=>z.id===l.modelID);if(F)return F}},[m,_]),W=oe?.limit?oe:le,R=W&&typeof W.limit=="object"&&W.limit!==null?W.limit:null,O=R&&typeof R.context=="number"?R.context:0,H=R&&typeof R.output=="number"?R.output:0,j=a.useMemo(()=>{if(!r||m.length===0)return null;let t,l;for(let X=m.length-1;X>=0;X-=1){const Q=m[X];if(Q.role!=="assistant")continue;const L=Q.tokens;if(!L)continue;if(L.input+L.output+L.reasoning+(L.cache?.read??0)+(L.cache?.write??0)>0){t=L,l=Q.id;break}}if(!t)return null;const B=t.input+t.output+t.reasoning+(t.cache?.read??0)+(t.cache?.write??0),F=O>0?O:2e5,z=O>0?Math.round(B/O*100):0,he=H>0?Math.round(t.output/H*100):void 0;return{totalTokens:B,percentage:z,contextLimit:O||0,outputLimit:H||void 0,normalizedOutput:he,thresholdLimit:F,lastMessageId:l}},[O,r,m,H]),[P,q]=a.useState(null),ue={WebkitAppRegion:"drag"},J={WebkitAppRegion:"no-drag"};a.useEffect(()=>{if(!r){q(t=>t===null?t:null);return}if(j&&j.totalTokens>0){q(t=>t&&t.totalTokens===j.totalTokens&&t.percentage===j.percentage&&t.contextLimit===j.contextLimit&&(t.outputLimit??0)===(j.outputLimit??0)&&(t.normalizedOutput??0)===(j.normalizedOutput??0)&&t.thresholdLimit===j.thresholdLimit&&t.lastMessageId===j.lastMessageId?t:j);return}q(t=>t===null?t:null)},[j,r]);const me=P&&P.contextLimit>0?Math.min(999,P.totalTokens/P.contextLimit*100):0,pe=a.useCallback(()=>{const t=!w;v(t),U("desktop_set_window_pinned",{pinned:t}).catch(()=>{v(!t)})},[w]),fe=a.useCallback(()=>{const t=r?{sessionId:r,directory:g?.directory??i??""}:{mode:"draft",directory:b||i||"",projectId:d};U("desktop_focus_main_window",t).then(l=>l?.focused===!0?U("desktop_close_current_window"):null)},[i,r,d,b,g]);return n.jsxs("header",{className:Te("flex items-center gap-3 bg-background pr-3",S?"pl-[5.5rem]":"pl-3",x?"h-12":s||"min-h-14"),style:ue,children:[x&&A==="left"?n.jsx(ie,{visible:!0,position:"left"}):null,n.jsx(Oe,{children:n.jsxs("button",{type:"button","aria-label":"Open session switcher",style:J,className:"flex min-w-0 max-w-full flex-col items-start rounded-md px-1 py-0.5 text-left transition-colors hover:bg-interactive-hover/60 focus-visible:outline-none focus-visible:bg-interactive-hover/60",children:[n.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:y}),n.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75",children:[n.jsx("span",{className:"truncate",children:de}),ne?n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[n.jsx($,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),n.jsx("span",{className:"truncate",children:ne})]}):null]})]})}),n.jsx("div",{className:"min-w-0 flex-1"}),P&&P.totalTokens>0?n.jsx(Be,{totalTokens:P.totalTokens,percentage:me,colorPercentage:P.percentage,contextLimit:P.contextLimit,outputLimit:P.outputLimit??0,className:"h-9 shrink-0 pl-1 pr-1 typography-ui-label",valueClassName:"font-semibold leading-none",hideIcon:!0,showPercentIcon:!0,percentIconClassName:"h-4.5 w-4.5"}):null,n.jsx(ae,{type:"button",variant:"ghost",size:"icon",onClick:pe,"aria-label":w?"Unpin Mini Chat window":"Pin Mini Chat window",title:w?"Unpin window":"Pin above other windows",style:J,children:w?n.jsx($,{name:"pushpin-2-fill",className:"h-4 w-4"}):n.jsx($,{name:"pushpin-2",className:"h-4 w-4"})}),n.jsx(ae,{type:"button",variant:"ghost",size:"icon",onClick:fe,"aria-label":"Open session in main window",title:"Open in main window",style:J,children:n.jsx($,{name:"external-link",className:"h-4 w-4"})}),n.jsx(ie,{visible:x&&A==="right",position:"right"})]})},st=({mode:e,autoOpenDraft:r=!1,unavailable:o=!1})=>{const d=h(i=>i.currentSessionId);return n.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:[n.jsx(ot,{mode:e}),n.jsx("main",{className:"min-h-0 flex-1",children:o?n.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center typography-ui-label text-muted-foreground",children:n.jsxs("div",{className:"max-w-sm rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-4 py-3",children:[n.jsx("div",{className:"font-medium text-foreground",children:"Session unavailable"}),n.jsx("div",{className:"mt-1 typography-small text-muted-foreground",children:"This session could not be loaded. It may have been deleted, archived, or opened from a different project context."})]})}):n.jsx(rt,{mode:"mini-chat",children:n.jsx(ke,{autoOpenDraft:r},d??"no-session")})})]})},it=()=>{const e=Y(i=>i.shortcutOverrides),r=T(i=>i.currentDirectory),o=Z(i=>i.getActiveProject()),d=h(i=>i.openNewSessionDraft);a.useEffect(()=>{const i=c=>He(c,e),u=c=>{if(N(c,i("focus_input"))){c.preventDefault(),ce();return}if(xe()&&N(c,i("new_mini_chat"))){c.preventDefault(),U("desktop_open_draft_mini_chat_window",{directory:r||o?.path||"",projectId:o?.id??null})?.catch(p=>{console.warn("[mini-chat-shortcuts] failed to open draft mini chat window",p)});return}if(N(c,i("new_chat"))){c.preventDefault(),d({selectedProjectId:o?.id??null,directoryOverride:r||o?.path||null,preserveDirectoryOverride:!!(r||o?.path)}),ce();return}if(N(c,i("open_model_selector"))){c.preventDefault();const{isModelSelectorOpen:p,setModelSelectorOpen:m}=Y.getState();m(!p);return}if(N(c,i("cycle_thinking_variant"))){if(f.getState().getCurrentModelVariants().length===0)return;c.preventDefault(),ze(1).then(E=>{const D=h.getState().currentSessionId,k=f.getState().currentAgentName,w=f.getState().currentProviderId,v=f.getState().currentModelId;D&&k&&w&&v&&Ue.getState().saveAgentModelVariantForSession(D,k,w,v,E)}).catch(()=>{We.error("Couldn't update thinking")});return}const M=N(c,i("cycle_favorite_model_forward")),_=N(c,i("cycle_favorite_model_backward"));if(M||_){const{favoriteModels:p,addRecentModel:m}=Y.getState();if(p.length===0)return;c.preventDefault();const{currentProviderId:E,currentModelId:D,setProvider:k,setModel:w}=f.getState(),v=p.findIndex(x=>x.providerID===E&&x.modelID===D),S=p[(v+(M?1:-1)+p.length)%p.length];k(S.providerID),w(S.modelID),m(S.providerID,S.modelID)}};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[o?.id,o?.path,r,d,e])},at="pichamber:mini-chat-presence",ct=()=>{const e=typeof window<"u"?new URLSearchParams(window.location.search):new URLSearchParams,r=e.get("mode")==="session"?"session":"draft",o=e.get("sessionId")?.trim()||null,d=e.get("directory")?.trim()||null,i=e.get("projectId")?.trim()||null;return{mode:r,sessionId:o,directory:d,projectId:i}},dt=({config:e})=>{const r=ee(),o=T(s=>s.currentDirectory),d=T(s=>s.setDirectory),i=h(s=>s.currentSessionId),u=h(s=>!!s.newSessionDraft?.open),c=h(s=>s.newSessionDraft?.open?s.newSessionDraft.bootstrapPendingDirectory??s.newSessionDraft.directoryOverride??"":""),M=h(s=>s.setCurrentSession),_=h(s=>s.openNewSessionDraft),p=f(s=>s.initializeApp),m=f(s=>s.isInitialized),E=f(s=>s.isConnected),D=f(s=>s.loadProviders),k=f(s=>s.loadAgents),w=f(s=>s.providers.length),v=f(s=>s.agents.length),C=Ye();a.useEffect(()=>{p()},[p]),a.useEffect(()=>{if(m)return;let s=!0,g=0;const y=window.setInterval(()=>{if(s){if(g+=1,g>10){window.clearInterval(y);return}f.getState().isInitialized||f.getState().initializeApp()}},1e3);return()=>{s=!1,window.clearInterval(y)}},[m]);const S=a.useRef(!1);a.useEffect(()=>{if(!S.current&&e.mode==="session"&&e.directory){if(o===e.directory){S.current=!0;return}d(e.directory,{showOverlay:!1}),S.current=!0}},[e.directory,e.mode,o,d]),a.useEffect(()=>{e.mode!=="draft"||!u||i||!c||o===c||d(c,{showOverlay:!1})},[e.mode,o,i,c,u,d]),a.useEffect(()=>{E&&(w===0&&D({source:"electronMiniChat:recovery"}),v===0&&k({source:"electronMiniChat:recovery"}))},[v,E,k,D,w]);const x=a.useRef(!1);a.useEffect(()=>{if(x.current||e.mode!=="session"||!e.sessionId)return;if(i===e.sessionId){x.current=!0;return}if(i){x.current=!0;return}const s=r.find(y=>y.id===e.sessionId);if(!s){C.ensureSessionRenderable(e.sessionId);return}const g=s.directory??e.directory;M(e.sessionId,g),x.current=!0},[e,i,r,M,C]),a.useEffect(()=>{const s=g=>{const y=g.detail,I=typeof y?.sessionId=="string"?y.sessionId.trim():"";if(!I||h.getState().currentSessionId===I)return;const V=typeof y?.directory=="string"&&y.directory.trim().length>0?y.directory.trim():r.find(b=>b.id===I)?.directory??null;C.ensureSessionRenderable(I),M(I,V),x.current=!0};return window.addEventListener("pichamber:open-session",s),()=>window.removeEventListener("pichamber:open-session",s)},[r,M,C]),a.useEffect(()=>{e.mode!=="draft"||u||i||_({selectedProjectId:e.projectId,directoryOverride:e.directory,preserveDirectoryOverride:!!e.directory})},[e,i,u,_]);const A=a.useRef(!1);return a.useEffect(()=>{if(A.current||!m)return;const s=()=>{if(A.current)return;A.current=!0;const I=typeof document<"u"?document.getElementById("initial-loading"):null;I&&(I.classList.add("fade-out"),window.setTimeout(()=>I.remove(),300))},g=e.mode==="session"?i===e.sessionId:u,y=window.setTimeout(s,g?100:1500);return()=>window.clearTimeout(y)},[m,e.mode,e.sessionId,i,u]),null},lt=()=>{const e=h(o=>o.currentSessionId),r=T(o=>o.currentDirectory);return a.useEffect(()=>{if(!e||!r||typeof BroadcastChannel>"u")return;const o=new BroadcastChannel(at),d=c=>{o.postMessage({type:"mini-chat-session-presence",sessionId:e,directory:r,viewed:c})};d(!0);const i=window.setInterval(()=>d(!0),5e3),u=()=>d(!1);return window.addEventListener("beforeunload",u),()=>{window.clearInterval(i),window.removeEventListener("beforeunload",u),d(!1),o.close()}},[r,e]),null},ut=e=>{const r=ee(),o=h(u=>u.currentSessionId),[d,i]=a.useState(!1);return a.useEffect(()=>{if(e.mode!=="session"||!e.sessionId||o===e.sessionId){i(!1);return}if(r.some(c=>c.id===e.sessionId)){i(!1);return}const u=window.setTimeout(()=>i(!0),5e3);return()=>window.clearTimeout(u)},[e.mode,e.sessionId,o,r]),d};function mt({apis:e}){const r=a.useMemo(()=>ct(),[]),o=T(d=>d.currentDirectory);return a.useEffect(()=>{Fe.setDirectory(o||r.directory||void 0)},[r.directory,o]),a.useEffect(()=>(se(e),()=>se(null)),[e]),$e(),it(),be({enabled:!0}),je(),n.jsx(Ge,{children:n.jsx(Ve,{directory:o||r.directory,children:n.jsx(Ke,{apis:e,children:n.jsx(qe,{delayDuration:300,skipDelayDuration:150,children:n.jsxs("div",{className:"h-full text-foreground bg-background",children:[n.jsx(pt,{config:r}),n.jsx(Je,{}),n.jsx(Xe,{})]})})})})})}const pt=({config:e})=>{const r=ut(e);return n.jsxs(n.Fragment,{children:[n.jsx(dt,{config:e}),n.jsx(lt,{}),n.jsx(Qe,{embeddedBackgroundWorkEnabled:!0}),n.jsx(st,{mode:e.mode,autoOpenDraft:e.mode==="draft",unavailable:r})]})},ft=()=>{Se().then(()=>{Promise.all([Ie(),De()]).catch(e=>{console.error("[mini-chat-main] settings init failed:",e)}),Ce(),Pe(),Me()}).catch(e=>{console.error("[mini-chat-main] appearance init failed:",e)})};function Fr(e){const r=e??ve();if(!r)throw new Error("Runtime APIs not registered");ft();const o=document.getElementById("root");if(!o)throw new Error("Root element not found");ye.createRoot(o).render(n.jsx(we.StrictMode,{children:n.jsx(Ze,{children:n.jsx(et,{children:n.jsx(tt,{children:n.jsx(mt,{apis:r})})})})}))}export{Fr as renderElectronMiniChatApp};
|