@pi-chamber/web 1.0.6-rc.3 → 1.0.6-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{DiagramView-Dq5w8TCG.js → DiagramView-BZ--w7Lh.js} +1 -1
- package/dist/assets/DiffView-Dtn6otnT.js +18 -0
- package/dist/assets/{FileSaveConflictDialog-dFqLbFzT.js → FileSaveConflictDialog-p1ik30al.js} +2 -2
- package/dist/assets/FilesView-D0Z0VmQm.js +6 -0
- package/dist/assets/{GitHubDetailScaffold-B2HRjT8V.js → GitHubDetailScaffold-a27RksFo.js} +4 -4
- package/dist/assets/{GitHubLinkPicker-D7I3J9_O.js → GitHubLinkPicker-B0CfzNfk.js} +1 -1
- package/dist/assets/GitHubListPrimitives-LFdR70l6.js +1 -0
- package/dist/assets/GitView-BNkoaVYl.js +9 -0
- package/dist/assets/{IssuesSurface-Bya7OsRl.js → IssuesSurface-D4kD7_VW.js} +3 -3
- package/dist/assets/{JsonTreeView-BJr5kBg4.js → JsonTreeView-CEiJsFnP.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-418ChlsN.js +12 -0
- package/dist/assets/{PatchDiff-B6RBZULC.js → PatchDiff-BtOv_oLB.js} +1 -1
- package/dist/assets/{PierreDiffViewer-YJJQkE7t.js → PierreDiffViewer-CkuyY9ne.js} +15 -3
- package/dist/assets/{PullRequestsSurface-D8JpzP5l.js → PullRequestsSurface-PML07zr-.js} +2 -2
- package/dist/assets/SessionSwitcherContent-DkfjRgwv.js +1 -0
- package/dist/assets/{SessionSwitcherDropdown-CEAid1Bd.js → SessionSwitcherDropdown-CEw8BEs6.js} +2 -2
- package/dist/assets/SessionUnreadDot-DXUn8-ss.js +1 -0
- package/dist/assets/SettingsView-BvUeFUqw.js +6 -0
- package/dist/assets/{SettingsWindow-5dK-buUn.js → SettingsWindow-D03Z9QyW.js} +1 -1
- package/dist/assets/{StickyHorizontalScrollbar-p7EbL2-E.js → StickyHorizontalScrollbar-CONTbZgX.js} +1 -1
- package/dist/assets/{ToolOutputDialog-gITobhpo.js → ToolOutputDialog-DibddNlz.js} +5 -5
- package/dist/assets/{ToolPartDiffPreview-nOJxBl-Y.js → ToolPartDiffPreview-Bx7T1M2f.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-BmJk6XJm.js → VirtualizedFileDiff-BY-mDMT8.js} +4 -4
- package/dist/assets/{Virtualizer-DNJrJKVb.js → Virtualizer-cIf8dSOQ.js} +1 -1
- package/dist/assets/{collapsible-0yfy07W2.js → collapsible-BhQdnj8G.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-BCFpa-1q.js → computeVirtualFileMetrics-CzkFqhaU.js} +1 -1
- package/dist/assets/{contextFileOpenGuard-BCi5nTZp.js → contextFileOpenGuard-CjCOK8EB.js} +1 -1
- package/dist/assets/fileTreeStatus-CPTpyKOV.js +7 -0
- package/dist/assets/gitStatusPredicates-_GNbGCCb.js +1 -0
- package/dist/assets/{githubLink-CCmFsyTF.js → githubLink-CwIFogWd.js} +2 -2
- package/dist/assets/index-Cfrwo5uQ.js +11 -0
- package/dist/assets/index-D7k62S9M.css +1 -0
- package/dist/assets/{index-BaeFf5Q8.js → index-DjOKW10B.js} +1 -1
- package/dist/assets/main-1wmEZ4Is.js +137 -0
- package/dist/assets/{main-CgXs2e27.js → main-C51a3z3b.js} +2 -2
- package/dist/assets/{markdownCore-DTNVLpYS.js → markdownCore-Dsr6dY5C.js} +1 -1
- package/dist/assets/{miniChat-CrAin_em.js → miniChat-DCxCx1fF.js} +2 -2
- package/dist/assets/{mobile-EK9oTupb.js → mobile-D6Ac2Mu3.js} +2 -2
- package/dist/assets/{nativeFileSave-Bhafll_7.js → nativeFileSave-P_Eg5Dgb.js} +1 -1
- package/dist/assets/{pi-session-focus-preference-BoN1cyoG.js → pi-session-focus-preference-DjDyjZ1C.js} +1 -1
- package/dist/assets/{renderDiffWithHighlighter-DixZh5Zd.js → renderDiffWithHighlighter-CK_inhQE.js} +1 -1
- package/dist/assets/renderElectronMiniChatApp-wBNgFl0U.js +2 -0
- package/dist/assets/{renderFileWithHighlighter-s6fQq9eg.js → renderFileWithHighlighter-B_PFeRW5.js} +1 -1
- package/dist/assets/renderMobileApp-B3mhxGnb.js +11 -0
- package/dist/assets/runtimeEndpointReset-D8lAOCUB.js +62 -0
- package/dist/assets/{runtimeSurface-CJN1oo_1.js → runtimeSurface-C3YPOBlg.js} +1 -1
- package/dist/assets/useAppFontEffects-CoFst31H.js +215 -0
- package/dist/assets/{useGitHubRemoteSearch-CZ92xKSw.js → useGitHubRemoteSearch-C0-6hhMJ.js} +1 -1
- package/dist/assets/useSwitcherItems-DHCCg4GF.js +1 -0
- package/dist/assets/{vendor-aparajita-capacitor-secure-storage-BLsm9T1Y.js → vendor-aparajita-capacitor-secure-storage-B9_YeZyx.js} +1 -1
- package/dist/assets/{vendor-base-ui-C7vVMZTg.js → vendor-base-ui-CKSCJw-4.js} +1 -1
- package/dist/assets/{vendor-boot-CoTxysn6.js → vendor-boot-Ciu-Edvy.js} +18 -18
- package/dist/assets/{vendor-capacitor-app-NX6DULfp.js → vendor-capacitor-app-Bpy_aPMq.js} +1 -1
- package/dist/assets/{vendor-capacitor-keyboard-DJD81I9f.js → vendor-capacitor-keyboard-DO8AIjrZ.js} +1 -1
- package/dist/assets/{vendor-capacitor-status-bar-DV24OoQV.js → vendor-capacitor-status-bar-SQkytwUW.js} +1 -1
- package/dist/assets/{vendor-codemirror-autocomplete-qsuH4Dh-.js → vendor-codemirror-autocomplete-CInQsE8a.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-angular-ZHWyBf7j.js → vendor-codemirror-lang-angular-QbsN3LGE.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-cpp-pCTOmv-k.js → vendor-codemirror-lang-cpp-BT5U7lxV.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-css-2bFuyM70.js → vendor-codemirror-lang-css-dF-Dxbty.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-go-DrG_c7D7.js → vendor-codemirror-lang-go-e4dp1bar.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-html-BV8lrR8v.js → vendor-codemirror-lang-html-DKcbBVQ4.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-java-DrsvH6T2.js → vendor-codemirror-lang-java-CB2-FWv6.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-javascript-Dkzl3s07.js → vendor-codemirror-lang-javascript-B1zJk7xE.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-jinja-8Nn3bnoP.js → vendor-codemirror-lang-jinja-BsERjdSd.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-json-CsdmtHhi.js → vendor-codemirror-lang-json-C0pZ0NhY.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-less-DJuZ4cZe.js → vendor-codemirror-lang-less-_N9HmR4h.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-liquid-D2RO-Pzr.js → vendor-codemirror-lang-liquid-D02xJRCD.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-markdown-C0Zu3b3n.js → vendor-codemirror-lang-markdown-_6ojeUuZ.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-php-CuDtt2Zj.js → vendor-codemirror-lang-php-DguCnbJA.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-python-Cv2exx_M.js → vendor-codemirror-lang-python-Byr5gw5f.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-rust-C4TxJ6Rg.js → vendor-codemirror-lang-rust-DN6Wh0eK.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sass-BmtPz8kf.js → vendor-codemirror-lang-sass-DOlEW7q1.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sql-BF1ZaXqJ.js → vendor-codemirror-lang-sql-BJzE9Dby.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-vue-DZgXrP2k.js → vendor-codemirror-lang-vue-DR8E-2nr.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-wast-DsnaGtL_.js → vendor-codemirror-lang-wast-n6lcDH5S.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-xml-D8DzzFat.js → vendor-codemirror-lang-xml-Cf2lmlmY.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-yaml-D5hBv7m6.js → vendor-codemirror-lang-yaml-DSR_E0yh.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-vn2RyN9T.js → vendor-codemirror-language-data-CSid5JuX.js} +2 -2
- package/dist/assets/{vendor-codemirror-search-BVCYIV0D.js → vendor-codemirror-search-8lY3lt6q.js} +1 -1
- package/dist/assets/{vendor-lezer-cpp-vqXSn3lv.js → vendor-lezer-cpp-DZYTDKiD.js} +1 -1
- package/dist/assets/{vendor-lezer-css-JnEzSyZR.js → vendor-lezer-css-6qV4fYNQ.js} +1 -1
- package/dist/assets/{vendor-lezer-go-dD2gQMIL.js → vendor-lezer-go-BDi_Iblq.js} +1 -1
- package/dist/assets/{vendor-lezer-html-Cr3U-1pu.js → vendor-lezer-html-BjqcY-oJ.js} +1 -1
- package/dist/assets/{vendor-lezer-java-CRM0IMCo.js → vendor-lezer-java-J2BXqz1h.js} +1 -1
- package/dist/assets/{vendor-lezer-javascript-B3s21DIS.js → vendor-lezer-javascript-CiQ9F8yX.js} +1 -1
- package/dist/assets/{vendor-lezer-json-DPFM6EBV.js → vendor-lezer-json-BxN83KKR.js} +1 -1
- package/dist/assets/{vendor-lezer-lr-Bllrq8hY.js → vendor-lezer-lr-BVsDua_K.js} +1 -1
- package/dist/assets/{vendor-lezer-markdown-6-3PLvXG.js → vendor-lezer-markdown-BkMtRQ3X.js} +1 -1
- package/dist/assets/{vendor-lezer-php-DOyzfHRl.js → vendor-lezer-php-B3XqnXdP.js} +1 -1
- package/dist/assets/{vendor-lezer-python-CdHdN5qt.js → vendor-lezer-python-D342CidI.js} +1 -1
- package/dist/assets/{vendor-lezer-rust-CqnW8EMH.js → vendor-lezer-rust-Dbfg_4LA.js} +1 -1
- package/dist/assets/{vendor-lezer-sass-BbcF4y6A.js → vendor-lezer-sass-ClxPaFt1.js} +1 -1
- package/dist/assets/{vendor-lezer-xml-C31AyWoo.js → vendor-lezer-xml-I_S6FQ1u.js} +1 -1
- package/dist/assets/{vendor-lezer-yaml-Cv908yC2.js → vendor-lezer-yaml-COA6HWLP.js} +1 -1
- package/dist/assets/{vendor-replit-codemirror-vim-Cwhyn_5f.js → vendor-replit-codemirror-vim-7IE2zVmx.js} +1 -1
- package/dist/assets/{web-components-Bz5oGa3p.js → web-components-CzkvK_V5.js} +1 -1
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +1 -1
- package/server/lib/git/DOCUMENTATION.md +1 -0
- package/server/lib/git/routes.js +14 -0
- package/server/lib/git/routes.test.js +37 -0
- package/server/lib/git/service.js +27 -0
- package/server/lib/git/service.test.js +32 -0
- package/server/lib/pi/routes.js +63 -1
- package/server/lib/pi/routes.test.js +77 -0
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +1 -1
- package/server/lib/pi/session-shelf-store.js +181 -0
- package/server/lib/pi/session-shelf-store.test.js +73 -0
- package/server/lib/pi/ui-settings-store.js +1 -0
- package/dist/assets/DiffView-CFIjN2zy.js +0 -18
- package/dist/assets/FilesView-D0b2mEKA.js +0 -6
- package/dist/assets/GitHubListPrimitives-Dw5LAmzm.js +0 -1
- package/dist/assets/GitView-Dhr7qVeI.js +0 -9
- package/dist/assets/MarkdownRendererImpl-DadkFPCz.js +0 -12
- package/dist/assets/SessionSwitcherContent-CJ6C2ZKG.js +0 -1
- package/dist/assets/SessionUnreadDot-I1_tmqY9.js +0 -1
- package/dist/assets/SettingsView-B-b76XDV.js +0 -6
- package/dist/assets/gitStatusPredicates-BQOqDJU1.js +0 -1
- package/dist/assets/index-C2ISrmRR.js +0 -11
- package/dist/assets/index-DgwThEwf.css +0 -1
- package/dist/assets/main-DoVzQV56.js +0 -137
- package/dist/assets/renderElectronMiniChatApp-0MqKeGfI.js +0 -2
- package/dist/assets/renderMobileApp-BLoXL_J8.js +0 -11
- package/dist/assets/runtimeEndpointReset-Bv2Y1fMm.js +0 -62
- package/dist/assets/useAppFontEffects-D2xXdmYC.js +0 -215
- package/dist/assets/useFilesViewSearch-BKotcAUN.js +0 -7
- package/dist/assets/useSwitcherItems-BfA4omGb.js +0 -1
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import{j as t,aP as Nt}from"./vendor-boot-CoTxysn6.js";import{R as r}from"./vendor-react-Bz1tRBxM.js";import{f as ne,h as Y,b as et,q as ze}from"./index-C2ISrmRR.js";import{eh as Ct,dW as St,ef as Lt,aO as tt,cG as nt,dv as Dt,d0 as De,B as je,I as W,z as st,bh as ce,t as it,e7 as rt,a$ as kt,b0 as Rt,b1 as Et,bu as Ge,dl as At,ei as Tt,ej as Mt,y as It,as as Pt,bw as $t,cH as Wt,dT as _t,h as Bt,b9 as Ot,aB as zt,aQ as Gt,aR as Ht,aS as Ut}from"./useAppFontEffects-D2xXdmYC.js";import{d as ot,b as Vt,i as He,a as Ue,c as Kt,C as qt}from"./gitStatusPredicates-BQOqDJU1.js";import{p as Xt}from"./VirtualizedFileDiff-BmJk6XJm.js";import{P as Qt}from"./PierreDiffViewer-YJJQkE7t.js";import{v as Yt,g as Jt}from"./contextFileOpenGuard-BCi5nTZp.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CXhN0IMY.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";import"./runtimeSurface-CJN1oo_1.js";import"./nativeFileSave-Bhafll_7.js";import"./web-components-Bz5oGa3p.js";import"./computeVirtualFileMetrics-BCFpa-1q.js";import"./vendor-shiki-BEwTOAFg.js";import"./vendor-shikijs-core-Ck_OPM_T.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-DPFxvYtK.js";import"./vendor-hast-util-to-html-O3stl53j.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-C40bX6nM.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-DrfmQi8i.js";import"./vendor-pierre-theming-BO6EPniU.js";import"./vendor-shikijs-engine-javascript-DL394yyj.js";import"./vendor-oniguruma-to-es-DgwFOwdE.js";import"./vendor-oniguruma-parser-BrbMHgHx.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./renderDiffWithHighlighter-DixZh5Zd.js";import"./vendor-diff-C3JhlQdm.js";import"./StickyHorizontalScrollbar-p7EbL2-E.js";import"./runtimeEndpointReset-Bv2Y1fMm.js";import"./SessionUnreadDot-I1_tmqY9.js";/* empty css */import"./permissionStore-zIpxq9Pq.js";import"./appThemeRegistry-Ca8eGRB9.js";import"./registerCustomTheme-C-h6lsYW.js";function Zt(n,s=10){const e=[];let i;for(const l of n.split(`
|
|
2
|
-
`)){const f=l.match(Ct);if(f!=null){i!=null&&(i.hunkLines.length>0&&(Ee(i,s,"trailing"),Ie(i,e)),i=void 0);const d=parseInt(f[3]),y=parseInt(f[1]),m=parseInt(f[4]??"1"),c=parseInt(f[2]??"1");isNaN(d)||isNaN(y)||isNaN(m)||isNaN(c)?e.push(l):i={additionStart:d,deletionStart:y,additionCount:0,deletionCount:0,hunkLines:[],contextLines:[]};continue}if(i==null){e.push(l);continue}if(l.startsWith(" "))i.contextLines.push(l);else if(l!==""){if(i.hunkLines.length>0&&i.contextLines.length>s*2){const d=i.contextLines.length-s*2,y=i.contextLines.slice(-s);Ee(i,s,"trailing");const{additionCount:m,deletionCount:c}=i;Ie(i,e),i={additionStart:i.additionStart+m+d,deletionStart:i.deletionStart+c+d,deletionCount:0,additionCount:0,contextLines:y,hunkLines:[]}}Ee(i,s,i.hunkLines.length===0?"leading":"before-change"),i.hunkLines.push(l),l.startsWith("+")?i.additionCount+=1:l.startsWith("-")&&(i.deletionCount+=1)}}i!=null&&i.hunkLines.length>0&&(Ee(i,s,"trailing"),Ie(i,e));const a=e.join(`
|
|
3
|
-
`);return n.endsWith(`
|
|
4
|
-
`)?`${a}
|
|
5
|
-
`:a}function Ee(n,s,e){if(e==="leading"&&n.contextLines.length>s){const i=n.contextLines.length-s;n.contextLines.splice(0,i),n.additionStart+=i,n.deletionStart+=i}return e==="trailing"&&n.contextLines.length>s&&(n.contextLines.length=s),n.contextLines.length>0&&(n.hunkLines.push(...n.contextLines),n.additionCount+=n.contextLines.length,n.deletionCount+=n.contextLines.length,n.contextLines.length=0),n}function Ie(n,s){s.push(`@@ -${Ve(n.deletionStart,n.deletionCount)} +${Ve(n.additionStart,n.additionCount)} @@`),s.push(...n.hunkLines)}function Ve(n,s){return s===1?`${n}`:`${n},${s}`}const en=64,tn=3,pe=new Map,nn=(n,s,e=tn)=>{const i=`${n}\0${e}\0${s}`,a=pe.get(i);if(a)return pe.delete(i),pe.set(i,a),a;const l=rn(s),f=l?St(Zt(s,e),{oldFile:{name:n,contents:l.before},newFile:{name:n,contents:l.after}})??qe(n):Lt(sn(n,s))[0]?.files[0]??qe(n);for(pe.set(i,f);pe.size>en;){const d=pe.keys().next().value;if(!d)break;pe.delete(d)}return f},sn=(n,s)=>!s.trim()||s.startsWith("diff --git ")||/^--- [^\n]*\r?\n\+\+\+ /m.test(s)?s:`Index: ${n}
|
|
6
|
-
===================================================================
|
|
7
|
-
--- ${n}
|
|
8
|
-
+++ ${n}
|
|
9
|
-
${s}`,rn=n=>{if(!n.startsWith("diff --git ")&&!/^--- [^\n]*\t?\r?\n\+\+\+ [^\n]*\t?(?:\r?\n|$)/m.test(n))return;const s=[...n.matchAll(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@[^\n]*(?:\r?\n|$)/gm)];if(s.length!==1)return;const e=s[0],i=Number.parseInt(e[1]??"",10),a=Number.parseInt(e[2]??"",10);if(i>1||a>1||!Number.isFinite(i)||!Number.isFinite(a))return;const l=(e.index??0)+e[0].length,f=n.slice(l),d=[],y=[];let m;for(const c of f.split(/\r?\n/)){if(c.startsWith("diff --git ")||c.startsWith("@@ "))break;if(c.startsWith("\\")){if(m==="-"||m===" "){const p=d.at(-1);p&&(p.newline=!1)}if(m==="+"||m===" "){const p=y.at(-1);p&&(p.newline=!1)}continue}if(c.startsWith("-")){d.push({text:c.slice(1),newline:!0}),m="-";continue}if(c.startsWith("+")){y.push({text:c.slice(1),newline:!0}),m="+";continue}c.startsWith(" ")&&(d.push({text:c.slice(1),newline:!0}),y.push({text:c.slice(1),newline:!0}),m=" ")}return{before:Ke(d),after:Ke(y)}},Ke=n=>n.map(s=>s.text+(s.newline?`
|
|
10
|
-
`:"")).join(""),qe=n=>Xt({name:n,contents:""},{name:n,contents:""}),on=n=>/^Binary files .+ differ$/m.test(n)||/^GIT binary patch$/m.test(n),$e=(n,s,e)=>on(s)?{original:"",modified:"",isBinary:!0,patch:s,contextMode:e}:{original:"",modified:"",patch:s,fileDiff:nn(n,s),contextMode:e},at=(n,s,e)=>{const i=n??0,a=s??0;return!i&&!a?null:t.jsxs("span",{className:ne("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",e?.className),children:[i?t.jsxs("span",{style:{color:"var(--status-success)"},children:["+",i]}):null,a?t.jsxs("span",{style:{color:"var(--status-error)"},children:["-",a]}):null]})},an=r.memo(function({changedFiles:s,selectedFile:e,onSelectFile:i}){return s.length===0?null:t.jsx(tt,{outerClassName:"flex-1 min-h-0",className:"px-1 py-2",children:t.jsx("ul",{className:"flex flex-col gap-1",children:s.map(a=>{const l=ot(a),f=e===a.path;return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>i(a.path),className:ne("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",f?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[t.jsx(nt,{filePath:a.path,className:"h-3.5 w-3.5 flex-shrink-0"}),t.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:l.color},title:l.description,"aria-label":l.description,children:l.code}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:a.path,children:a.path}),at(a.insertions,a.deletions)]})},a.path)})})})});function ln(n,s,e){return n==="staged"?{source:"staged",staged:!0}:n==="working"?{source:"unstaged",staged:!1}:{source:"head",staged:e.staged&&s.path===e.path||Vt(s)}}const cn=r.memo(function(){return t.jsx("div",{className:"rounded-lg border border-border/60 bg-background px-3 py-2",children:t.jsx("div",{className:"typography-meta text-muted-foreground",children:"Content of this file cannot be viewed."})})}),un=r.memo(function({filePath:s,diff:e,renderSideBySide:i}){const a=e.original.length>0,l=e.modified.length>0,f=i?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",d=i?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";return t.jsx("div",{className:"w-full overflow-auto p-4",style:{contain:"layout"},children:t.jsxs("div",{className:f,children:[a&&t.jsxs("div",{className:d,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:"Original"}),t.jsx("img",{src:e.original,alt:`Original: ${s}`,className:i?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),l&&t.jsxs("div",{className:d,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:a?"Modified":"New"}),t.jsx("img",{src:e.modified,alt:`Modified: ${s}`,className:i?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]})]})})}),dn=r.memo(function({filePath:s,diff:e,renderSideBySide:i,wrapLines:a}){const l=r.useMemo(()=>Dt(s)||"text",[s]);return e.isBinary?t.jsx(cn,{}):De(s)?t.jsx(un,{filePath:s,diff:e,renderSideBySide:i}):t.jsx("div",{className:"w-full",style:{contain:"layout"},children:t.jsx(Qt,{original:e.original,modified:e.modified,fileDiff:e.fileDiff,language:l,fileName:s,renderSideBySide:i,wrapLines:a,layout:"inline"})})}),Pe=({label:n,icon:s,loading:e,disabled:i,tone:a,onClick:l})=>t.jsx(je,{variant:"ghost",size:"sm",className:ne("h-6 w-6 rounded-none bg-transparent p-0 text-muted-foreground opacity-70 hover:bg-transparent hover:text-foreground hover:opacity-100",a==="failure"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",a==="success"&&"text-[var(--status-success)] hover:text-[var(--status-success)]"),disabled:i,title:n,"aria-label":n,onClick:f=>{f.stopPropagation(),l()},children:e?t.jsx(W,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(W,{name:s,className:s==="add"?"size-4":"size-3.5"})}),fn=r.memo(function({filePath:s,staged:e,busyAction:i,disabled:a,onAction:l}){return t.jsx("div",{className:"flex items-center gap-0.5 rounded-full border border-[var(--interactive-border)]/45 bg-[var(--surface-background)]/95 px-1 py-0.5 shadow-sm backdrop-blur-md",children:e?t.jsx(Pe,{label:`Unstage ${s}`,icon:"arrow-go-back",loading:i==="unstage",disabled:a,onClick:()=>l("unstage")}):t.jsxs(t.Fragment,{children:[t.jsx(Pe,{label:`Revert changes in ${s}`,icon:"arrow-go-back",loading:i==="discard",disabled:a,tone:"failure",onClick:()=>l("discard")}),t.jsx(Pe,{label:`Stage ${s}`,icon:"add",loading:i==="stage",disabled:a,tone:"success",onClick:()=>l("stage")})]})})}),lt=3,pn=1e6,hn=15e3,Xe=500,mn=r.memo(function({directory:s,file:e,layout:i,wrapLines:a,isSelected:l,isExpanded:f,isMounted:d,onSelect:y,onExpandedChange:m,registerSectionRef:c,showOpenInEditorAction:p=!1,isOpeningInEditor:F=!1,onOpenInEditor:R,diffSource:x,staged:C=!1,showFileActions:g=!0,loadFullFiles:h=!1,initialDiffData:H=null}){const{git:M}=st(),E=ce(r.useCallback(u=>u.directories.get(s)?.diffCache.get(e.path)??null,[s,e.path])),S=ce(u=>u.setDiff),_=ce(u=>u.fetchStatus),j=Y(u=>u.setDiffFileLayout),w=Y(u=>u.setDiffWrapLines),[L,D]=r.useState(0),[A,k]=r.useState(null),[I,B]=r.useState(!1),[$,ee]=r.useState(null),[ue,Ne]=r.useState(!1),[b,se]=r.useState(null),U=r.useRef(null),ie=r.useRef(null),K=r.useMemo(()=>ot(e),[e]),J=i==="side-by-side",O=h?"full":"patch",re=`${e.index}:${e.working_dir}:${e.insertions}:${e.deletions}`,q=r.useMemo(()=>H||(b?.source===x?b.data:x!=="head"||!E?null:{original:E.original,modified:E.modified,isBinary:E.isBinary,contextMode:"full"}),[E,x,H,b]),he=q?.contextMode===O,de=r.useCallback(u=>{ie.current=u,c(e.path,u)},[e.path,c]),me=r.useCallback(u=>{m(e.path,u)},[e.path,m]),ge=r.useCallback(()=>{y(e.path)},[e.path,y]);r.useEffect(()=>{se(null),k(null),U.current=null},[x,re]),r.useEffect(()=>{if(!f||!d)return;if(!s||H||q&&he){U.current=null,B(!1);return}const u=`${s}::${e.path}::${x}::${re}::${O}::${L}`;if(U.current===u)return;U.current=u,k(null),B(!0);let P=!1;const te=et(),xe=h?pn:lt,be=De(e.path)?M.getGitFileDiff(s,{path:e.path,staged:x==="staged"}):M.getGitDiff(s,{path:e.path,source:x,contextLines:xe}),ae=hn,le=new Promise((V,X)=>{setTimeout(()=>X(new Error(`Timed out after ${ae}ms`)),ae)});return Promise.race([be,le]).then(V=>{if(!P){if("diff"in V){const X=$e(e.path,V.diff,O);se({source:x,data:X})}else{const X={original:V.original??"",modified:V.modified??"",isBinary:V.isBinary,contextMode:"full"};x==="head"?S(s,e.path,X,te):se({source:x,data:X})}B(!1)}}).catch(V=>{if(P)return;const X=V instanceof Error?V.message:String(V);k(X),B(!1)}),()=>{P=!0,U.current===u&&(U.current=null)}},[O,q,he,L,x,s,e.path,re,M,H,f,d,h,S]);const oe=r.useCallback(()=>{me(!f),ge()},[me,ge,f]),Ce=r.useCallback(async u=>{if(!(!s||$!==null)){ee(u);try{u==="stage"?await M.stageGitFile(s,e.path):u==="unstage"?await M.unstageGitFile(s,e.path):await M.revertGitFile(s,e.path,{scope:"working"}),D(P=>P+1),await _(s,M)}catch(P){const te=u==="unstage"?"Failed to unstage changes":u==="stage"?"Failed to stage changes":"Failed to revert changes";it.error(P instanceof Error?P.message:te)}finally{ee(P=>P===u?null:P)}}},[s,_,e.path,$,M]);return t.jsxs("div",{ref:de,className:ne("scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0"),children:[t.jsx("div",{className:ne("z-30 border-b border-[var(--interactive-border)]/35 bg-[var(--surface-elevated)]/90 backdrop-blur-md supports-[backdrop-filter]:bg-[var(--surface-elevated)]/80","sticky top-0"),children:t.jsxs("div",{role:"button",tabIndex:0,onClick:oe,onKeyDown:u=>{u.target===u.currentTarget&&(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),oe())},className:ne("cursor-pointer","group/header relative grid min-h-9 w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 overflow-hidden px-3 py-2","bg-transparent","text-muted-foreground hover:text-foreground",l?"bg-[var(--interactive-selection)]/35":null),children:[t.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),t.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:f?t.jsx(W,{name:"arrow-down-s",className:"size-4"}):t.jsx(W,{name:"arrow-right-s",className:"size-4"})}),t.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:K.color},title:K.description,"aria-label":K.description,children:K.code}),t.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:e.path,children:t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(nt,{filePath:e.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const u=e.path.lastIndexOf("/");if(u===-1)return t.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:e.path});const P=e.path.slice(0,u),te=e.path.slice(u+1);return t.jsxs("span",{className:"flex min-w-0 items-baseline overflow-hidden",children:[t.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:P}),t.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[t.jsx("span",{className:"text-muted-foreground",children:"/"}),t.jsx("span",{className:"text-foreground",children:te})]})]})})()]})})]}),t.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[at(e.insertions,e.deletions),p&&R?t.jsx(je,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:"Open this file in editor at change",onClick:u=>{u.stopPropagation(),R(e.path,q)},disabled:F,children:F?t.jsx(W,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(W,{name:"edit",className:"size-3.5"})}):null,t.jsx(rt,{mode:J?"side-by-side":"unified",onModeChange:u=>{const P=u==="side-by-side"?"side-by-side":"inline";j(e.path,P)},className:"opacity-70"}),t.jsxs(kt,{children:[t.jsx(Rt,{asChild:!0,children:t.jsx(je,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:"File view options","aria-label":"File view options",onClick:u=>{u.stopPropagation()},onPointerDown:u=>{u.stopPropagation()},children:t.jsx(W,{name:"more-2-fill",className:"size-3.5"})})}),t.jsxs(Et,{align:"end",onClick:u=>{u.stopPropagation()},onPointerDown:u=>{u.stopPropagation()},children:[t.jsxs(Ge,{onSelect:()=>{w(!a)},children:[t.jsx(W,{name:"text-wrap",className:"size-4"}),t.jsx("span",{className:"flex-1",children:"Wrap lines"}),a?t.jsx(W,{name:"check",className:"size-4"}):null]}),t.jsxs(Ge,{onSelect:()=>{j(e.path,J?"inline":"side-by-side")},children:[t.jsx(W,{name:J?"align-justify":"layout-column",className:"size-4"}),J?"Switch to unified view":"Switch to side-by-side view"]})]})]})]})]})}),f&&t.jsxs("div",{className:"relative overflow-clip bg-background",children:[!d&&!A?t.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,A?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:"Failed to load diff"}),t.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:A}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>D(u=>u+1),children:"Retry"})]}):null,d&&I&&!q&&!A?t.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx(W,{name:"loader-4",className:"size-4 animate-spin"}),"Loading diff..."]}):null,d&&q&&!ue&&e.insertions+e.deletions>Xe?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:`Large diff (${e.insertions+e.deletions} changed lines)`}),t.jsx("div",{className:"typography-meta text-muted-foreground",children:"Rendering may be slow. You can still view the diff by clicking below."}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>Ne(!0),children:"Render anyway"})]}):null,d&&q&&(ue||e.insertions+e.deletions<=Xe)?t.jsxs(t.Fragment,{children:[t.jsx(dn,{filePath:e.path,diff:q,renderSideBySide:J,wrapLines:a}),g?t.jsx("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20",children:t.jsx("div",{className:"pointer-events-auto",children:t.jsx(fn,{filePath:e.path,staged:C,busyAction:$,disabled:$!==null,onAction:Ce})})}):null]}):null]})]})}),gn=1100,Qe=300,xn=n=>n<=6?n:n<=12?6:n<=25?4:2,bn=(n,s)=>At(n,s),Ye=(n,s)=>{const e=n.split(`
|
|
11
|
-
`),i=s.split(`
|
|
12
|
-
`),a=Math.min(e.length,i.length);for(let l=0;l<a;l+=1)if(e[l]!==i[l])return l+1;return i.length>e.length?e.length+1:e.length>i.length?Math.max(1,i.length):1},yn=n=>Array.isArray(n)?n.filter(s=>!s||typeof s!="object"?!1:typeof s.file=="string"):[],wn=n=>n.split(/^diff --git /m).slice(1).flatMap(e=>{const[i=""]=e.split(`
|
|
13
|
-
`,1),a=i.lastIndexOf(" b/");if(a<=2)return[];const l=i.slice(2,a),f=i.slice(a+3).trim(),d=`diff --git ${e}`,y=d.includes(`
|
|
14
|
-
new file mode `)?"added":d.includes(`
|
|
15
|
-
deleted file mode `)?"deleted":d.includes(`
|
|
16
|
-
rename from `)?"renamed":"modified";let m=0,c=0;for(const p of d.split(`
|
|
17
|
-
`))p.startsWith("+")&&!p.startsWith("+++")&&(m+=1),p.startsWith("-")&&!p.startsWith("---")&&(c+=1);return[{file:y==="deleted"?l:f,status:y,additions:m,deletions:c,patch:d}]}),Fn=n=>n==="added"?"A":n==="deleted"?"D":"M";function vn({activeDiffScope:n,effectiveDirectory:s,branchBase:e,branchHead:i,git:a,sessionMessageRecords:l}){const[f,d]=r.useState([]),[y,m]=r.useState(null),[c,p]=r.useState(!1),F=r.useMemo(()=>{const C=Tt(l,{showTextJustificationActivity:!1,mergeHiddenUserTurns:!0});for(let g=C.turns.length-1;g>=0;g-=1){const h=C.turns[g];if(!h)continue;const H=h.activityParts.map(S=>S.part).filter(S=>S.type==="tool"),M=Mt(H);if(M.length>0)return M.map(S=>({file:S.path,status:"modified",additions:S.additions,deletions:S.deletions,patch:S.patch}));const E=yn(h.userMessage.info?.summary?.diffs);if(E.length>0)return E}return[]},[l]);r.useEffect(()=>{if(n!=="branch"||!s||!e||!i||!a.getGitRangeDiff){d([]),m(null),p(!1);return}let C=!1;return p(!0),m(null),a.getGitRangeDiff(s,{base:e,head:i,contextLines:lt}).then(g=>{C||(d(wn(g.diff??"")),p(!1))}).catch(g=>{C||(d([]),p(!1),m(g instanceof Error?g.message:String(g)))}),()=>{C=!0}},[n,e,i,s,a]);const R=r.useMemo(()=>{const C=new Map;for(const g of F)if(g.file){if(typeof g.patch=="string"){C.set(g.file,$e(g.file,g.patch,"patch"));continue}typeof g.before!="string"&&typeof g.after!="string"||C.set(g.file,{original:g.before??"",modified:g.after??"",contextMode:"full"})}return C},[F]),x=r.useMemo(()=>{const C=new Map;for(const g of f)!g.file||typeof g.patch!="string"||C.set(g.file,$e(g.file,g.patch,"patch"));return C},[f]);return{branchDiffs:f,branchDiffError:y,branchDiffLoading:c,lastTurnDiffs:F,lastTurnDiffData:R,branchDiffData:x}}const Je=(n,s)=>{if(s.length===0)return null;let e=null,i=null;for(const l of s)l.top<=n?(!e||l.top>e.top)&&(e=l):(!i||l.top<i.top)&&(i=l);const a=e??i;return a?{path:a.path,topOffset:a.top-n}:null},jn=(n,s,e,i)=>Math.min(Math.max(0,i),Math.max(0,n+e-s));function Nn({pinSelectedFileHeaderToTopOnNavigate:n,scrollRequestNonce:s,changedFiles:e,expandedFiles:i,setMountedStackedFiles:a,fileDiffRefreshNonce:l}){const f=r.useRef(null),d=r.useRef(new Map),[y,m]=r.useState(null),c=r.useRef(null),p=r.useRef(null),F=r.useRef(!1),R=r.useRef(null),x=r.useRef(i),C=r.useRef(null);r.useLayoutEffect(()=>{x.current=i},[i]);const g=r.useRef(null),h=r.useCallback(()=>{const j=f.current;if(!j)return null;const w=j.getBoundingClientRect().top,L=[];for(const[D,A]of d.current)A&&L.push({path:D,top:A.getBoundingClientRect().top});return Je(w,L)},[]),H=r.useCallback(()=>{c.current=null,F.current=!1,m(null),p.current!==null&&(window.cancelAnimationFrame(p.current),p.current=null)},[]),M=r.useCallback(()=>{R.current=null;const j=f.current;if(!j)return;const w=j.getBoundingClientRect(),L=w.top-Qe,D=w.bottom+Qe,A={},k=[];for(const[I,B]of d.current){if(!B)continue;const $=B.getBoundingClientRect();k.push({path:I,top:$.top}),x.current.has(I)&&($.bottom<L||$.top>D||(A[I]=!0))}C.current=Je(w.top,k),a(I=>{let B=!1;const $=new Set(I);for(const ee of Object.keys(A))$.has(ee)||($.add(ee),B=!0);return B?$:I})},[a]),E=r.useCallback(()=>{typeof window>"u"||R.current===null&&(R.current=window.requestAnimationFrame(M))},[M]);r.useEffect(()=>{const j=f.current;if(j)return E(),j.addEventListener("scroll",E,{passive:!0}),window.addEventListener("resize",E),()=>{j.removeEventListener("scroll",E),window.removeEventListener("resize",E),R.current!==null&&(window.cancelAnimationFrame(R.current),R.current=null)}},[e,i,E]),r.useLayoutEffect(()=>{const j=g.current;if(!j)return;g.current=null;const w=f.current,L=d.current.get(j.path);if(!w||!L)return;const D=w.getBoundingClientRect().top,A=L.getBoundingClientRect().top-D;w.scrollTop=jn(w.scrollTop,j.topOffset,A,w.scrollHeight-w.clientHeight),C.current=j},[l]);const S=r.useCallback((j,w)=>{const L=d.current;w?L.set(j,w):L.delete(j),E()},[E]),_=r.useCallback(j=>{const w=d.current.get(j),L=f.current;if(!w||!L)return!1;const D=w.getBoundingClientRect().top-L.getBoundingClientRect().top;return L.scrollTo({top:L.scrollTop+D,behavior:"auto"}),!0},[]);return r.useEffect(()=>{if(!c.current)return;let w=0;const L=20;let D=!1;const A=(I=!0)=>{D||(D=!0,c.current=null,F.current=!1,I&&m(null),p.current!==null&&(window.cancelAnimationFrame(p.current),p.current=null))},k=()=>{if(D){p.current=null;return}const I=c.current;if(!I){A(),p.current=null;return}if(!_(I)){w+=1,w<L?p.current=window.requestAnimationFrame(k):(A(),p.current=null);return}if(n&&F.current){m(I),A(!1);return}A()};return p.current=window.requestAnimationFrame(k),()=>{D=!0,p.current!==null&&(window.cancelAnimationFrame(p.current),p.current=null)}},[n,s,_]),{diffScrollRef:f,fileSectionRefs:d,pinnedStackedTarget:y,pendingScrollTargetRef:c,shouldPinAfterAlignRef:F,pendingScrollAnchorRestoreRef:g,lastScrollAnchorRef:C,captureScrollAnchor:h,cancelPendingScrollAlignment:H,queueVisibleStackedFilesSync:E,registerSectionRef:S,scrollToFile:_}}const Ze=n=>{if(!n)return null;const s=n.split(`
|
|
18
|
-
`);let e=null;for(const i of s){const a=i.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(a){const l=Number.parseInt(a[1]??"",10);e=Number.isFinite(l)&&l>=1?l:null;continue}if(e!==null){if(i.startsWith(" ")){e+=1;continue}if(i.startsWith("+"))return e;if(i.startsWith("-"))return Math.max(1,e)}}return null};function Cn({effectiveDirectory:n,activeDiffStaged:s,git:e,files:i,setDiff:a,openContextFileAtLine:l}){const[f,d]=r.useState(null),y=r.useCallback(async(m,c)=>{if(!n||!m)return;d(m);const p=et();try{let F=null;if(c?.patch&&!c.isBinary&&!De(m)?F=Ze(c.patch):c&&c.contextMode==="full"&&!c.isBinary&&!De(m)&&(F=Ye(c.original,c.modified)),F===null)try{const h=await e.getGitDiff(n,{path:m,staged:s,contextLines:3});F=Ze(h.diff)}catch{F=null}let R=c;if(F===null||!R){const h=await e.getGitFileDiff(n,{path:m,staged:s});R={original:h.original??"",modified:h.modified??"",isBinary:h.isBinary},s||a(n,m,R,p??void 0)}const x=F??(R.isBinary||De(m)?1:Ye(R.original,R.modified)),C=bn(n,m),g=await Yt(i,C,{directory:n});if(!g.ok){it.error(Jt(g.reason));return}l(n,C,x,1)}finally{d(F=>F===m?null:F)}},[s,n,i,e,l,a]);return{openingEditorFilePath:f,openFileInEditorAtChange:y}}function Sn(n){const{hideStackedFileSidebar:s=!1,stackedDefaultCollapsedAll:e=!1,pinSelectedFileHeaderToTopOnNavigate:i=!1,diffScope:a="all",branchBase:l=null,branchHead:f=null,targetFilePath:d=null}=n,{git:y,files:m}=st(),c=It(),{screenWidth:p,isMobile:F}=Pt(),R=$t(c??null),x=Wt(c??null),C=_t(c??null),g=ce(o=>o.setActiveDirectory),h=ce(o=>o.ensureStatus),H=ce(o=>o.fetchStatus),M=ce(o=>o.clearDiffCache),E=ce(o=>o.setDiff),[S,_]=r.useState(null),[j,w]=r.useState(!1),[L,D]=r.useState(()=>new Set),[A,k]=r.useState(()=>new Set),[I,B]=r.useState(!1),[$,ee]=r.useState(0),[ue,Ne]=r.useState(()=>new Map),[b,se]=r.useState(a);r.useEffect(()=>{se(a)},[a]);const U=Y(o=>o.pendingDiffFile),ie=Y(o=>o.pendingDiffStaged),K=Y(o=>o.pendingDiffScope),J=Y(o=>o.setPendingDiffFile),O=Y(o=>o.diffLayoutPreference),re=Y(o=>o.diffFileLayout),q=Y(o=>o.setDiffFileLayout),he=Y(o=>o.diffWrapLinesOverride),de=Y(o=>o.wrapLinesByDefault),me=Y(o=>o.setDiffWrapLines),ge=Y(o=>o.openContextFileAtLine),oe=Bt(o=>o.currentSessionId),Ce=Ot(oe??""),u=he??de,te=(b==="staged"?!0:b==="working"?!1:null)??j,xe=F||p<=768,be=!s&&!xe&&p>=1024,ae=r.useRef(null),{branchDiffs:le,branchDiffError:V,branchDiffLoading:X,lastTurnDiffs:Z,lastTurnDiffData:Q,branchDiffData:ke}=vn({activeDiffScope:b,effectiveDirectory:c,branchBase:l,branchHead:f,git:y,sessionMessageRecords:Ce}),z=r.useMemo(()=>{if(b==="turn"||b==="branch")return(b==="branch"?le:Z).map(T=>({path:T.file??"",index:"",working_dir:Fn(T.status),insertions:T.additions??0,deletions:T.deletions??0,isNew:T.status==="added"})).filter(T=>T.path).sort((T,G)=>T.path.localeCompare(G.path));if(!x?.files)return[];const o=x.diffStats??{},N=b==="staged"?He:b==="working"?Ue:()=>!0;return x.files.filter(N).map(v=>({...v,insertions:o[v.path]?.insertions??0,deletions:o[v.path]?.deletions??0,isNew:Kt(v)})).sort((v,T)=>v.path.localeCompare(T.path))},[b,le,Z,x]),Ae=r.useMemo(()=>x?.files?x.files.filter(Ue).length:0,[x]),ct=r.useMemo(()=>x?.files?x.files.filter(He).length:0,[x]),ut=Z.length,dt=x?.files?.length??0,ft=le.length,{diffScrollRef:pt,pinnedStackedTarget:ht,pendingScrollTargetRef:ye,shouldPinAfterAlignRef:we,pendingScrollAnchorRestoreRef:We,lastScrollAnchorRef:_e,captureScrollAnchor:Be,cancelPendingScrollAlignment:Fe,queueVisibleStackedFilesSync:Re,registerSectionRef:mt,scrollToFile:Oe}=Nn({pinSelectedFileHeaderToTopOnNavigate:i,scrollRequestNonce:$,changedFiles:z,expandedFiles:L,setMountedStackedFiles:k,fileDiffRefreshNonce:ue}),ve=r.useCallback(o=>{D(N=>{if(N.has(o))return N;const v=new Set(N);return v.add(o),v})},[]),Te=r.useMemo(()=>z.map(o=>o.path).join("\0"),[z]);r.useEffect(()=>{const o=Te?Te.split("\0"):[],N=new Set(o),v=`${c??""}:${b}:${e?"collapsed":"default"}`,T=ae.current!==v;ae.current=v,D(G=>{if(T){const fe=e?0:xn(o.length);return new Set(o.slice(0,fe))}let Se=!1;const Le=new Set;for(const fe of G){if(!N.has(fe)){Se=!0;continue}Le.add(fe)}return Se?Le:G}),k(G=>{if(T)return new Set;let Se=!1;const Le=new Set;for(const fe of G){if(!N.has(fe)){Se=!0;continue}Le.add(fe)}return Se?Le:G})},[b,Te,c,k,e]);const Me=r.useCallback(o=>{const N=re[o.path];if(N)return N;if(O==="inline")return"inline";if(O==="side-by-side")return"side-by-side";const v=p<gn;return o.isNew||v?"inline":"side-by-side"},[re,O,p]),gt=r.useMemo(()=>z.length===0?null:z.every(o=>Me(o)==="side-by-side")?"side-by-side":"inline",[z,Me]);r.useEffect(()=>{c&&(g(c),h(c,y))},[c,g,h,y]),r.useEffect(()=>{if(c)return zt.onGitRefreshHint(o=>{ze(o.directory)===ze(c)&&(o.paths?.length&&(We.current=Be()??_e.current,M(c,o.paths),Ne(N=>{const v=new Map(N);for(const T of o.paths??[])v.set(T,(v.get(T)??0)+1);return v})),H(c,y,{silent:!0}))})},[Be,M,c,H,y,_e,We]),r.useEffect(()=>{b!=="all"&&!K||U&&(K&&se(K),_(U),w(K==="staged"||!K&&ie),J(null),we.current=!0,ye.current=U,ve(U),ee(o=>o+1))},[b,ve,U,K,ie,ye,J,we]),r.useEffect(()=>{if(b==="all")return;const o=d?.trim();o&&(_(o),w(b==="staged"),we.current=!0,ye.current=o,ve(o),ee(N=>N+1))},[b,ve,ye,we,d]),r.useEffect(()=>{if(!S)return;z.some(N=>N.path===S)||(_(null),w(!1))},[z,S]);const xt=r.useCallback((o,N)=>{Fe(),D(v=>{const T=v.has(o);if(N===T)return v;const G=new Set(v);return N?G.add(o):G.delete(o),G}),k(v=>{const T=v.has(o);if(N===T)return v;const G=new Set(v);return N?G.add(o):G.delete(o),G}),Re()},[Fe,Re,k]),bt=r.useCallback(()=>{Fe(),D(o=>o.size>0?new Set:new Set(z.map(N=>N.path))),k(new Set),Re()},[Fe,z,Re,k]),yt=r.useCallback(o=>{},[]),wt=r.useCallback(o=>{Fe(),_(o),w(!1),we.current=!0,ye.current=o,ve(o),ee(N=>N+1),Oe(o)},[Fe,ve,ye,Oe,we]),Ft=r.useCallback(o=>{const N=o==="side-by-side"?"side-by-side":"inline";z.forEach(v=>{q(v.path,N)})},[z,q]),{openingEditorFilePath:vt,openFileInEditorAtChange:jt}=Cn({effectiveDirectory:c,activeDiffStaged:te,git:y,files:m,setDiff:E,openContextFileAtLine:ge});return{git:y,files:m,effectiveDirectory:c,screenWidth:p,isMobile:F,isGitRepo:R,status:x,isLoadingStatus:C,activeDiffScope:b,setActiveDiffScope:se,branchDiffs:le,branchDiffError:V,branchDiffLoading:X,diffWrapLines:u,setDiffWrapLines:me,displayFileStaged:j,displayFile:S,pinnedStackedTarget:ht,expandedFiles:L,mountedStackedFiles:A,loadFullFiles:I,setLoadFullFiles:B,fileDiffRefreshNonce:ue,showFileSidebar:be,diffScrollRef:pt,lastTurnDiffData:Q,branchDiffData:ke,changedFiles:z,workingFileCount:Ae,stagedFileCount:ct,turnFileCount:ut,allFileCount:dt,branchFileCount:ft,currentLayoutForAllFiles:gt,openingEditorFilePath:vt,registerSectionRef:mt,handleStackedEntryExpandedChange:xt,handleExpandOrCollapseAll:bt,handleSelectFile:yt,handleSelectFileAndScroll:wt,handleHeaderLayoutChange:Ft,openFileInEditorAtChange:jt,getLayoutForFile:Me}}const Ns=({hideStackedFileSidebar:n=!1,stackedDefaultCollapsedAll:s=!1,pinSelectedFileHeaderToTopOnNavigate:e=!1,showOpenInEditorAction:i=!1,diffScope:a="all",onDiffScopeChange:l,branchBase:f=null,branchHead:d=null,targetFilePath:y=null,flushContent:m=!1,hideToolbar:c=!1,onHeaderControlsStateChange:p,toolbarSlot:F=null})=>{const{effectiveDirectory:R,isGitRepo:x,status:C,isLoadingStatus:g,activeDiffScope:h,setActiveDiffScope:H,branchDiffError:M,branchDiffLoading:E,diffWrapLines:S,setDiffWrapLines:_,displayFileStaged:j,displayFile:w,pinnedStackedTarget:L,expandedFiles:D,mountedStackedFiles:A,loadFullFiles:k,setLoadFullFiles:I,fileDiffRefreshNonce:B,showFileSidebar:$,diffScrollRef:ee,lastTurnDiffData:ue,branchDiffData:Ne,changedFiles:b,workingFileCount:se,stagedFileCount:U,turnFileCount:ie,allFileCount:K,branchFileCount:J,currentLayoutForAllFiles:O,openingEditorFilePath:re,registerSectionRef:q,handleStackedEntryExpandedChange:he,handleExpandOrCollapseAll:de,handleSelectFile:me,handleSelectFileAndScroll:ge,handleHeaderLayoutChange:oe,openFileInEditorAtChange:Ce,getLayoutForFile:u}=Sn({hideStackedFileSidebar:n,stackedDefaultCollapsedAll:s,pinSelectedFileHeaderToTopOnNavigate:e,diffScope:a,branchBase:f,branchHead:d,targetFilePath:y});r.useEffect(()=>{c&&l?.(h)},[h,c,l]);const P=r.useCallback(()=>{I(Z=>!Z)},[I]),te=r.useCallback(()=>{_(!S)},[S,_]),xe=r.useCallback(()=>{oe(O==="side-by-side"?"unified":"side-by-side")},[O,oe]),be=D.size,ae=r.useMemo(()=>({turnCount:ie,branchCount:J,expandedCount:be,totalCount:b.length,loadFullFiles:k,wrapLines:S,layoutMode:O,onExpandOrCollapseAll:de,onToggleLoadFullFiles:P,onToggleWrapLines:te,onToggleLayout:xe}),[ie,J,be,b.length,k,S,O,de,P,te,xe]);r.useEffect(()=>{c&&p?.(ae)},[c,ae,p]);const le=()=>{if(!R)return null;const Z={path:w,staged:j};return t.jsxs("div",{className:ne("flex min-w-0 flex-1 min-h-0 h-full",m?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[$&&t.jsxs("section",{className:"hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[t.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:"Files"}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:b.length})]}),t.jsx(an,{changedFiles:b,selectedFile:null,onSelectFile:ge})]}),t.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:t.jsxs(tt,{ref:ee,outerClassName:"min-h-0 h-full",className:"[overflow-anchor:none]",disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:[t.jsx("div",{className:"flex flex-col [overflow-anchor:none]","data-diff-virtual-content":!0,children:b.map(Q=>{const ke=ln(h,Q,Z);return t.jsx(mn,{directory:R,file:Q,layout:u(Q),wrapLines:S,isSelected:!1,isExpanded:D.has(Q.path),isMounted:A.has(Q.path)||Q.path===L,onSelect:me,onExpandedChange:he,registerSectionRef:q,showOpenInEditorAction:i&&h!=="turn"&&h!=="branch",isOpeningInEditor:re===Q.path,onOpenInEditor:(z,Ae)=>{Ce(z,Ae)},diffSource:ke.source,staged:ke.staged,showFileActions:h!=="turn"&&h!=="branch",loadFullFiles:k,initialDiffData:h==="turn"?ue.get(Q.path)??null:h==="branch"?Ne.get(Q.path)??null:null},`${Q.path}:${B.get(Q.path)??0}`)})}),t.jsx("div",{"aria-hidden":"true",className:"h-16 shrink-0"})]})})]})},V=()=>R?h!=="turn"&&g&&!C?t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(W,{name:"loader-4",className:"size-4 animate-spin"}),"Loading repository status..."]}):h!=="turn"&&h!=="branch"&&x===!1?t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"Not a git repository. Use the Git tab to initialize or change directories."}):h==="branch"&&E?t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(W,{name:"loader-4",className:"size-4 animate-spin"}),"Loading branch changes..."]}):h==="branch"&&M?t.jsx("div",{className:"flex flex-1 items-center justify-center px-4 text-center text-sm text-muted-foreground",children:`Failed to load branch changes: ${M}`}):b.length===0?t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:h==="turn"?"No last turn changes to display":"Working tree clean, no changes to display"}):le():t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"Select a session directory to view diffs"}),X=t.jsxs("div",{className:F?"flex min-w-0 flex-1 items-center gap-1.5":"@container/diff-toolbar flex min-w-0 items-center gap-2 px-3 py-2 bg-background",children:[(x!==!1||h==="turn")&&(h==="all"||h==="working"||h==="staged"||h==="turn"||h==="branch")?t.jsx(qt,{scope:h,isGitRepo:x,branchAvailable:!!(f&&d),allCount:K,workingCount:se,stagedCount:U,turnCount:ie,branchCount:J,onScopeChange:Z=>{H(Z),l?.(Z)}}):t.jsx("div",{className:"flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0",children:t.jsx("span",{className:"typography-ui-label font-medium text-foreground",children:g&&!C?"Loading changes...":b.length===1?`${b.length} file changed`:`${b.length} files changed`})}),b.length>0&&t.jsxs(je,{variant:"ghost",size:"sm",onClick:de,className:ne("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ml-auto"),title:D.size>0?"Collapse all":"Expand all",children:[t.jsx(W,{name:"expand-up-down",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:D.size>0?"Collapse all":"Expand all"})]}),b.length>0&&h!=="turn"&&h!=="branch"&&t.jsxs(Gt,{children:[t.jsx(Ht,{asChild:!0,children:t.jsx(je,{variant:"ghost",size:"sm",onClick:()=>I(Z=>!Z),"aria-pressed":k,"aria-label":k?"Unload full files":"Load full files",className:ne("h-7 w-7 flex-shrink-0 p-0 text-muted-foreground hover:text-foreground",k&&"bg-interactive-selection text-interactive-selection-foreground"),children:t.jsx(W,{name:"file-download",className:"size-4"})})}),t.jsx(Ut,{children:t.jsx("p",{children:k?"Unload full files":"Load full files"})})]}),b.length>0&&t.jsx(je,{variant:"ghost",size:"sm",onClick:()=>_(!S),className:ne("h-5 w-5 p-0 transition-opacity",S?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:S?"Disable line wrap":"Enable line wrap",children:t.jsx(W,{name:"text-wrap",className:"size-4"})}),O&&t.jsx(rt,{mode:O==="side-by-side"?"side-by-side":"unified",onModeChange:oe})]});return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background",children:[F?Nt.createPortal(X,F):c?null:X,V()]})};export{Ns as DiffView};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{aj as No,cf as St,cg as Tn,E as c,ah as va,Q as pe,ch as So,ci as Ro,O as ba,M as rn,ap as wa,S as Fo,aq as In,j as t,ak as Eo,c6 as zo,af as Mo,cj as Do,c9 as st,ck as Tr,c5 as To,J as Ao,U as Cn,cl as Oo,cm as Lo,c8 as Po,aP as Io,cn as Bo,X as $o,L as Vo}from"./vendor-boot-CoTxysn6.js";import{R as s,a as y}from"./vendor-react-Bz1tRBxM.js";import{f as J,a as ya,a9 as ka,_ as Wo,j as _o,cD as Ko,M as qo,cE as Ho,h as ke,cF as ja,at as Ee,b as Go,o as Uo,G as Jo,cw as Nt,cy as Xo,bM as Yo,A as Ar,cG as Qo,Z as Or,z as Lr,O as Nn,am as Zo}from"./index-C2ISrmRR.js";import{ds as ei,cG as bt,B as q,I as F,at as zt,dt as ti,av as Ca,aw as Na,ax as Sa,ay as Ra,az as Fa,aA as Ea,a$ as Bn,b0 as $n,b1 as Vn,ah as Zt,t as he,bu as en,bK as ni,du as tn,aO as za,E as Pr,aP as ri,dv as Ma,d0 as Da,dw as Ta,c$ as Aa,c_ as An,d1 as ai,aQ as Xe,aR as Ye,aS as Qe,z as si,bL as oi,as as ii,y as ci,cH as li,dx as Ir,cI as Br,aB as ui,dy as $r}from"./useAppFontEffects-D2xXdmYC.js";import{javascript as xt}from"./vendor-codemirror-lang-javascript-Dkzl3s07.js";import{json as Oa}from"./vendor-codemirror-lang-json-CsdmtHhi.js";import{css as La}from"./vendor-codemirror-lang-css-2bFuyM70.js";import{html as On}from"./vendor-codemirror-lang-html-BV8lrR8v.js";import{markdown as Pa}from"./vendor-codemirror-lang-markdown-C0Zu3b3n.js";import{l as Ia}from"./vendor-codemirror-language-data-vn2RyN9T.js";import{python as Ba}from"./vendor-codemirror-lang-python-Cv2exx_M.js";import{shell as di}from"./shell-CjFT_Tl9.js";import{ensurePierreThemeRegistered as Vr,getResolvedShikiTheme as fi}from"./appThemeRegistry-Ca8eGRB9.js";import{D as mi,i as $a,b as Va,s as pi,F as hi}from"./FileSaveConflictDialog-dFqLbFzT.js";import{h as Wr,aG as gi,aH as xi,aI as vi,aJ as bi,aK as wi,aP as Yt}from"./runtimeEndpointReset-Bv2Y1fMm.js";import{e as Ln,h as Wa,i as _a}from"./SessionUnreadDot-I1_tmqY9.js";import{g as Rt,c as Ka,d as qa,e as Wn,n as yi,f as ki,M as Ft,h as se,j as ji,s as Ci,i as Ni,a as Si,t as Qt,k as Sn,b as Ri,l as Fi,u as Ei,m as _r,o as zi,p as Kr}from"./useFilesViewSearch-BKotcAUN.js";import{J as Mi,F as Di}from"./JsonTreeView-BJr5kBg4.js";import{a as qr,g as nn,b as Hr,c as Gr,o as Ti,d as Ai}from"./vendor-codemirror-search-BVCYIV0D.js";import{v as Oi,g as Li}from"./vendor-replit-codemirror-vim-Cwhyn_5f.js";import{P as Pi,S as Ii}from"./StickyHorizontalScrollbar-p7EbL2-E.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CXhN0IMY.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";import"./runtimeSurface-CJN1oo_1.js";import"./nativeFileSave-Bhafll_7.js";import"./vendor-lezer-javascript-B3s21DIS.js";import"./vendor-lezer-lr-Bllrq8hY.js";import"./vendor-codemirror-autocomplete-qsuH4Dh-.js";import"./vendor-lezer-json-DPFM6EBV.js";import"./vendor-lezer-css-JnEzSyZR.js";import"./vendor-lezer-html-Cr3U-1pu.js";import"./vendor-lezer-markdown-6-3PLvXG.js";import"./vendor-lezer-python-CdHdN5qt.js";import"./registerCustomTheme-C-h6lsYW.js";import"./themeResolver-DrfmQi8i.js";import"./vendor-pierre-theming-BO6EPniU.js";import"./vendor-shikijs-core-Ck_OPM_T.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-DPFxvYtK.js";import"./vendor-hast-util-to-html-O3stl53j.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-C40bX6nM.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-react-drawio-IYnLUY5N.js";/* empty css */import"./permissionStore-zIpxq9Pq.js";import"./web-components-Bz5oGa3p.js";import"./computeVirtualFileMetrics-BCFpa-1q.js";import"./vendor-shiki-BEwTOAFg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./vendor-shikijs-engine-javascript-DL394yyj.js";import"./vendor-oniguruma-to-es-DgwFOwdE.js";import"./vendor-oniguruma-parser-BrbMHgHx.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./Virtualizer-DNJrJKVb.js";import"./renderFileWithHighlighter-s6fQq9eg.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";const Pn=No.define(di);function Bi(e){const n=e.trim().toLowerCase();switch(n){case"bash":case"sh":case"zsh":case"shell":case"shellsession":case"console":return Pn;case"json":case"jsonc":case"json5":return Oa().language;case"js":case"javascript":return xt().language;case"jsx":return xt({jsx:!0}).language;case"ts":case"typescript":return xt({typescript:!0}).language;case"tsx":return xt({typescript:!0,jsx:!0}).language;case"html":return On().language;case"css":return La().language;case"py":case"python":return Ba().language;case"md":case"markdown":case"mdown":case"mkd":return Pa().language;case"heex":case"eex":case"leex":return On().language;default:return va.matchLanguageName(Ia,n,!0)}}const Ha=e=>e.split("/").pop()?.toLowerCase()??"",$i=e=>{const n=Ha(e);return n?va.matchFilename(Ia,n):null},Vi=()=>St(Tn.define([{tag:[c.heading1,c.heading2,c.heading3,c.heading4,c.heading5,c.heading6],fontWeight:"600"},{tag:c.strong,fontWeight:"600"},{tag:c.emphasis,fontStyle:"italic"},{tag:c.strikethrough,textDecoration:"line-through"},{tag:[c.link,c.url],color:"var(--markdown-link, currentColor)",textDecoration:"underline"},{tag:c.monospace,color:"var(--markdown-inline-code, currentColor)",backgroundColor:"var(--markdown-inline-code-bg, transparent)"},{tag:c.quote,color:"var(--markdown-blockquote, currentColor)",fontStyle:"italic"},{tag:c.list,color:"color-mix(in srgb, var(--muted-foreground) 40%, var(--foreground) 60%)"},{tag:c.heading,color:"var(--markdown-heading1, currentColor)"}]));function Wi(e){const n=e.toLowerCase();switch(Ha(n)){case"makefile":case"gnumakefile":return Pn}const i=n.lastIndexOf("."),o=i>=0?n.slice(i+1):"";switch(o){case"ts":case"tsx":case"mts":case"cts":return xt({typescript:!0,jsx:o==="tsx"});case"js":case"jsx":case"mjs":case"cjs":return xt({typescript:!1,jsx:o==="jsx"});case"json":case"jsonc":case"json5":case"jsonl":case"ndjson":case"geojson":return Oa();case"css":case"scss":case"sass":case"less":return La();case"html":case"htm":case"xml":case"drawio":case"dio":return On();case"md":case"mdx":case"markdown":case"mdown":case"mkd":return[Pa({codeLanguages:Bi}),Vi()];case"sh":case"bash":case"zsh":case"fish":case"env":return Pn;case"py":case"pyw":case"pyi":return Ba();default:return null}}async function _i(e){const n=$i(e);if(!n)return null;if(n.support)return n.support;try{return await n.load()}catch{return null}}function Ur(e,n){const a=e.metadata.variant==="dark",i=e.config?.fonts?.mono||"monospace",o=e.colors.syntax.highlights||{},u=e.colors.syntax.tokens||{},d=n?.fontSize?`${n.fontSize}px`:"var(--text-code)",f=pe.theme({"&":{backgroundColor:"var(--background)",color:e.colors.syntax.base.foreground,fontSize:d,lineHeight:"1.5",position:"relative"},".cm-scroller":{fontFamily:i,backgroundColor:"var(--background)"},".cm-comment":{color:e.colors.syntax.base.comment},".cm-keyword":{color:e.colors.syntax.base.keyword},".cm-string":{color:e.colors.syntax.base.string},".cm-string-2":{color:u.stringEscape||e.colors.syntax.base.string},".cm-number":{color:e.colors.syntax.base.number},".cm-operator":{color:e.colors.syntax.base.operator},".cm-punctuation":{color:u.punctuation||e.colors.syntax.base.comment},".cm-atom":{color:u.boolean||e.colors.syntax.base.number},".cm-builtin":{color:u.functionCall||e.colors.syntax.base.function},".cm-def":{color:u.variableGlobal||e.colors.syntax.base.variable},".cm-attribute":{color:u.variableOther||u.variableProperty||e.colors.syntax.base.operator},".cm-meta":{color:e.colors.syntax.base.comment},".cm-property":{color:u.variableProperty||e.colors.syntax.base.keyword},".cm-variable":{color:e.colors.syntax.base.variable},".cm-variable-2":{color:u.variableOther||e.colors.syntax.base.function},".cm-variable-3":{color:u.variableGlobal||e.colors.syntax.base.type},".cm-tag":{color:u.tag||e.colors.syntax.base.keyword},".cm-link":{color:u.url||e.colors.syntax.base.keyword,textDecoration:"underline"},".cm-content":{caretColor:e.colors.interactive.cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:e.colors.interactive.cursor},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e.colors.interactive.selection},".cm-gutters":{backgroundColor:"var(--background)",color:o.lineNumber||e.colors.syntax.base.comment,borderRight:`1px solid ${e.colors.interactive.border}`,position:"sticky",paddingRight:"8px",left:0,zIndex:2,boxShadow:"0 0 0 var(--background)"},".cm-gutter":{backgroundColor:"var(--background)"},".cm-gutterElement":{backgroundColor:"var(--background)"},".cm-lineNumbers":{backgroundColor:"var(--background)"},".cm-lineNumbers .cm-gutterElement":{paddingLeft:"8px",paddingRight:"8px",minWidth:"42px"},".cm-activeLineGutter":{color:o.lineNumberActive||e.colors.syntax.base.foreground},".cm-activeLine":{backgroundColor:e.colors.surface.overlay},".cm-panels":{backgroundColor:"transparent",color:e.colors.surface.foreground,position:"absolute",top:"0",right:"0",left:"auto",width:"auto",zIndex:10,pointerEvents:"none"},".cm-panels-top":{borderBottom:"none",position:"absolute",top:"6px",right:"14px",left:"auto",width:"auto"},".cm-panels-bottom":{position:"static",width:"100%",pointerEvents:"auto"},".cm-panels-bottom .cm-vim-panel":{borderTop:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.elevated,color:e.colors.surface.mutedForeground,fontFamily:"var(--font-mono)",fontSize:"12px",minHeight:"22px",padding:"2px 8px"},".cm-panel.cm-search":{pointerEvents:"auto",padding:"4px",backgroundColor:`color-mix(in srgb, ${e.colors.surface.elevated} 85%, transparent)`,border:`1px solid ${e.colors.interactive.border}`,borderRadius:"10px",boxShadow:`0 2px 8px color-mix(in srgb, ${e.colors.surface.background} 60%, transparent)`,width:"auto",minWidth:"360px",maxWidth:"480px"},".cm-search":{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"0",width:"100%",color:e.colors.surface.foreground,fontFamily:"inherit",fontSize:"13px",lineHeight:"1"},".cm-search br":{display:"none"},".cm-search .cm-textfield":{appearance:"none",height:"26px",margin:0,padding:"0 8px",borderRadius:"6px !important",border:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.background,color:e.colors.surface.foreground,fontFamily:"inherit",fontSize:"12px",lineHeight:"1",outline:"none",transition:"border-color 150ms ease"},".cm-search .cm-textfield::placeholder":{color:e.colors.surface.mutedForeground,opacity:1},".cm-search .cm-textfield:focus":{borderColor:e.colors.primary.base},'.cm-search .cm-textfield[name="search"]':{order:1,flex:"1 1 120px",maxWidth:"calc(100% - 142px)",minWidth:"100px"},".cm-search label":{order:2,display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:0,marginLeft:"1px",padding:0,borderRadius:"4px",border:"1px solid transparent",backgroundColor:"transparent",color:"transparent",cursor:"pointer",userSelect:"none",fontSize:"1px",lineHeight:"0",overflow:"hidden",position:"relative",transition:"background-color 120ms ease, border-color 120ms ease"},".cm-search label:hover":{backgroundColor:e.colors.interactive.hover},'.cm-search label:has(input[type="checkbox"]:checked)':{backgroundColor:e.colors.interactive.hover,borderColor:e.colors.interactive.border},'.cm-search [type="checkbox"]':{appearance:"none",WebkitAppearance:"none",width:"0",height:"0",margin:"0",padding:"0",border:"none",position:"absolute",opacity:"0",pointerEvents:"none"},".cm-search label::after":{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",fontSize:"13px",fontWeight:"600",lineHeight:"1",fontFamily:"inherit",color:e.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search label:hover::after":{color:e.colors.surface.foreground},'.cm-search label:has(input[type="checkbox"]:checked)::after':{color:e.colors.surface.foreground},'.cm-search label:has(input[name="case"])::after':{content:'"Aa"',fontSize:"12px",letterSpacing:"-0.5px"},'.cm-search label:has(input[name="re"])::after':{content:'".*"',fontSize:"13px",fontFamily:"monospace"},'.cm-search label:has(input[name="word"])::after':{content:'"ab"',fontSize:"12px",textDecoration:"underline",textUnderlineOffset:"2px"},".cm-search .cm-search-message":{order:3,color:e.colors.surface.mutedForeground,backgroundColor:"transparent",border:"none",borderRadius:"0",padding:"0 6px",fontSize:"11px",whiteSpace:"nowrap",lineHeight:"26px"},".cm-search .cm-button":{appearance:"none",WebkitAppearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:0,marginLeft:"1px",padding:0,borderRadius:"4px",border:"none",backgroundColor:"transparent",backgroundImage:"none",color:"transparent",cursor:"pointer",fontSize:"1px",fontWeight:"400",lineHeight:"0",overflow:"hidden",position:"relative",boxShadow:"none",transition:"background-color 120ms ease"},".cm-search .cm-button::after":{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",fontSize:"15px",lineHeight:"1",color:e.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search .cm-button:hover":{backgroundColor:e.colors.interactive.hover},".cm-search .cm-button:hover::after":{color:e.colors.surface.foreground},".cm-search .cm-button:active":{backgroundColor:e.colors.interactive.active},".cm-search .cm-button:focus-visible":{outline:"none",boxShadow:`0 0 0 1px ${e.colors.interactive.focusRing}`},".cm-search .cm-button:disabled":{opacity:.4,cursor:"default",pointerEvents:"none"},'.cm-search .cm-button[name="prev"]':{order:21,marginTop:"2px"},'.cm-search .cm-button[name="prev"]::after':{content:'"↑"'},'.cm-search .cm-button[name="next"]':{order:22,marginTop:"2px"},'.cm-search .cm-button[name="next"]::after':{content:'"↓"'},'.cm-search .cm-button[name="select"]':{order:23,marginTop:"2px"},'.cm-search .cm-button[name="select"]::after':{content:'"≡"',fontSize:"17px"},'.cm-panel.cm-search button[name="close"]':{order:5,appearance:"none",WebkitAppearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:"0 0 0 auto",padding:"0",borderRadius:"4px",border:"none",backgroundColor:"transparent",backgroundImage:"none",color:e.colors.surface.mutedForeground,cursor:"pointer",fontSize:"16px",lineHeight:"1",boxShadow:"none",position:"relative",overflow:"visible",transition:"background-color 120ms ease, color 120ms ease"},'.cm-panel.cm-search button[name="close"]:hover':{backgroundColor:e.colors.interactive.hover,color:e.colors.surface.foreground},'.cm-search .cm-button[name="replace"]':{order:24,marginTop:"2px"},'.cm-search .cm-button[name="replace"]::after':{content:'"⇄"'},'.cm-search .cm-button[name="replaceAll"], .cm-search .cm-button[name="replace-all"]':{order:25,marginTop:"2px"},'.cm-search .cm-button[name="replaceAll"]::after, .cm-search .cm-button[name="replace-all"]::after':{content:'"⇉"'},'.cm-search .cm-textfield[name="replace"]':{order:20,flex:"1 1 100%",maxWidth:"calc(100% - 142px)",minWidth:"80px",marginTop:"2px"},".cm-searchMatch":{backgroundColor:e.colors.status.infoBackground,boxShadow:`inset 0 0 0 1px ${e.colors.status.infoBorder}`,borderRadius:"2px"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:e.colors.interactive.selection,color:e.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${e.colors.interactive.borderFocus}`},"&.cm-focused":{outline:"none"}},{dark:a}),g=Tn.define([{tag:[c.comment,c.docComment,c.meta,c.documentMeta],class:"cm-comment"},{tag:[c.keyword,c.controlKeyword,c.moduleKeyword,c.definitionKeyword,c.modifier],class:"cm-keyword"},{tag:[c.operatorKeyword,c.operator,c.derefOperator,c.updateOperator,c.definitionOperator,c.typeOperator,c.controlOperator,c.logicOperator,c.bitwiseOperator,c.arithmeticOperator,c.compareOperator],class:"cm-operator"},{tag:[c.punctuation,c.separator,c.bracket,c.paren,c.brace,c.squareBracket,c.angleBracket],class:"cm-punctuation"},{tag:[c.string,c.regexp,c.attributeValue,c.special(c.string),c.monospace],class:"cm-string"},{tag:c.escape,class:"cm-string-2"},{tag:[c.number,c.bool,c.atom,c.null,c.self],class:"cm-number"},{tag:[c.function(c.variableName),c.function(c.definition(c.variableName)),c.function(c.propertyName),c.standard(c.variableName),c.special(c.variableName)],class:"cm-builtin"},{tag:c.definition(c.variableName),class:"cm-def"},{tag:[c.variableName,c.local(c.variableName),c.constant(c.variableName),c.literal],class:"cm-variable"},{tag:c.propertyName,class:"cm-property"},{tag:c.attributeName,class:"cm-attribute"},{tag:[c.className,c.typeName,c.namespace],class:"cm-variable-3"},{tag:[c.tagName,c.labelName,c.annotation,c.macroName],class:"cm-tag"},{tag:c.link,class:"cm-link"},{tag:[c.heading,c.heading1,c.heading2,c.heading3,c.heading4,c.heading5,c.heading6],class:"cm-keyword"}]),w=Tn.define([{tag:[c.comment,c.docComment,c.meta,c.documentMeta],color:e.colors.syntax.base.comment},{tag:[c.keyword,c.controlKeyword,c.moduleKeyword,c.definitionKeyword,c.modifier],color:e.colors.syntax.base.keyword},{tag:[c.operatorKeyword,c.operator,c.derefOperator,c.updateOperator,c.definitionOperator,c.typeOperator,c.controlOperator,c.logicOperator,c.bitwiseOperator,c.arithmeticOperator,c.compareOperator],color:e.colors.syntax.base.operator},{tag:[c.string,c.regexp,c.attributeValue,c.special(c.string),c.monospace],color:e.colors.syntax.base.string},{tag:c.escape,color:u.stringEscape||e.colors.syntax.base.string},{tag:[c.number,c.bool,c.atom,c.null,c.self],color:e.colors.syntax.base.number},{tag:[c.function(c.variableName),c.function(c.definition(c.variableName)),c.function(c.propertyName),c.standard(c.variableName),c.special(c.variableName)],color:e.colors.syntax.base.function},{tag:c.definition(c.variableName),color:u.variableGlobal||e.colors.syntax.base.variable},{tag:[c.variableName,c.local(c.variableName),c.constant(c.variableName),c.literal],color:e.colors.syntax.base.variable},{tag:c.propertyName,color:u.variableProperty||e.colors.syntax.base.variable},{tag:c.attributeName,color:u.variableOther||e.colors.syntax.base.variable},{tag:[c.className,c.typeName,c.namespace],color:e.colors.syntax.base.type},{tag:[c.tagName,c.labelName,c.annotation,c.macroName],color:u.tag||e.colors.syntax.base.keyword},{tag:c.link,color:u.url||e.colors.syntax.base.function,textDecoration:"underline"},{tag:[c.punctuation,c.separator,c.bracket,c.paren,c.brace,c.squareBracket,c.angleBracket],color:u.punctuation||e.colors.syntax.base.comment}]);return n?.syntaxColors===!1?[f]:[f,St(So,{fallback:!0}),St(Ro),St(g),St(w)]}const Ki=180,Ga=Fo.define(),qi=1,Hi=2,Gi=4,Jr=new Map,Ui=(e,n)=>{const a=`${e}|${n}`,i=Jr.get(a);if(i)return i;let o="";e&&(o+=`color:${e};`),n&qi&&(o+="font-style:italic;"),n&Hi&&(o+="font-weight:bold;"),n&Gi&&(o+="text-decoration:underline;");const u=rn.mark({attributes:{style:o}});return Jr.set(a,u),u},Ji=(e,n)=>{const a=new In,i=e.state.doc,o=Math.min(n.length,i.lines);for(let u=0;u<o;u+=1){const d=n[u];if(!d||d.length===0)continue;const f=i.line(u+1);let g=f.from;for(const[w,N,x]of d){if(w<=0)continue;const b=g,j=Math.min(g+w,f.to);g+=w,!(j<=b)&&(!N&&!x||a.add(b,j,Ui(N,x)))}}return a.finish()},Xi=ba.define({create(){return rn.none},update(e,n){let a=e.map(n.changes);for(const i of n.effects)i.is(Ga)&&(a=i.value);return a},provide:e=>pe.decorations.from(e)}),Yi=e=>wa.fromClass(class{timer;generation=0;constructor(n){this.tokenize(n)}update(n){n.docChanged&&this.schedule(n.view)}schedule(n){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.tokenize(n)},Ki)}async tokenize(n){const a=++this.generation,i=n.state.doc.toString(),o=await ei(i,e.language,e.themeName,e.theme);o&&a===this.generation&&n.state.doc.length===i.length&&n.dispatch({effects:Ga.of(Ji(n,o))})}destroy(){this.timer&&clearTimeout(this.timer)}}),Qi=e=>[Xi,Yi(e)],We=e=>(e||"").replace(/\\/g,"/").replace(/\/+$/g,""),vt=e=>{const n=We(e);return!n||n==="/"?n||"/":n.split("/").filter(Boolean).at(-1)??n},Ua=e=>{const n=We(e);if(!n||n==="/")return null;const a=n.lastIndexOf("/");if(a<0)return null;if(a===0)return"/";const i=n.slice(0,a);return/^[A-Za-z]:$/.test(i)?`${i}/`:i},Xr=(e,n)=>{const a=We(e),i=We(n);return!a||!i?!1:a===i||a.startsWith(`${i}/`)},Yr=(e,n)=>{const a=We(e);if(!a)return We(n);if(a.startsWith("/")||/^[A-Za-z]:(\/|$)/.test(a))return a;const i=We(n);return i?`${i}/${a}`:a},Zi=(e,n)=>{const a=We(e),i=We(n);if(!a||a===i)return!1;const o=Ua(a);return o?i&&Xr(a,i)?Xr(o,i):!0:!1},ec=e=>{if(typeof e!="number"||!Number.isFinite(e)||e<0)return"";if(e<1024)return`${e} B`;const n=["KB","MB","GB"];let a=e/1024;for(const i of n){if(a<1024||i===n[n.length-1])return`${a.toFixed(a>=10?0:1)} ${i}`;a/=1024}return""},tc=(e,n)=>!n||e===n?vt(e):e.startsWith(`${n}/`)?e.slice(n.length+1):e,nc=({root:e,directory:n,entries:a,query:i,searchResults:o,isSearching:u,directoryError:d,refreshing:f,editorPath:g,editor:w,onClose:N,onQueryChange:x,onOpenDirectory:b,onOpenFile:j,onBackFromEditor:C,onRefresh:v})=>{if(!e)return t.jsx(Et,{message:"Select a project to browse files."});if(g)return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsx(Wr,{leading:t.jsx(q,{type:"button",variant:"ghost",size:"icon","aria-label":"Back",onClick:C,style:{touchAction:"manipulation"},children:t.jsx(F,{name:"arrow-left",className:"size-4"})}),icon:t.jsx(bt,{filePath:g,className:"size-4 shrink-0"}),title:vt(g)}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:w})]});const P=n===e?"Project files":vt(n),I=Zi(n,e)?Ua(n):null,l=!!I&&!i.trim(),V=I===e?"Project files":vt(I??""),G=N||l&&I?t.jsxs(t.Fragment,{children:[N?t.jsx(q,{type:"button",variant:"ghost",size:"icon","aria-label":"Close",onClick:N,style:{touchAction:"manipulation"},children:t.jsx(F,{name:"close",className:"size-4"})}):null,l&&I?t.jsx(q,{type:"button",variant:"ghost",size:"icon","aria-label":`Back to ${vt(I)}`,onClick:()=>b(I),style:{touchAction:"manipulation"},children:t.jsx(F,{name:"arrow-left",className:"size-4"})}):null]}):void 0;return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsx(Wr,{leading:G,icon:n===e?"file-text":"folder",title:P,actions:t.jsx(q,{type:"button",variant:"ghost",size:"icon","aria-label":"Refresh files",onClick:v,style:{touchAction:"manipulation"},children:t.jsx(F,{name:"refresh",className:J("size-4",f&&"animate-spin")})})}),t.jsx("div",{className:"shrink-0 px-3 py-2",children:t.jsxs("div",{className:"relative",children:[t.jsx(F,{name:"search",className:"pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),t.jsx(zt,{value:i,onChange:T=>x(T.target.value),placeholder:"Search files",className:"h-8 pl-7"})]})}),t.jsx(ti,{className:"min-h-0 w-full flex-1 overflow-y-auto pb-3",children:d?t.jsx(Et,{message:d}):i.trim()?t.jsx(rc,{root:e,results:o,isSearching:u,onOpenFile:j}):a===void 0?t.jsx(Et,{loading:!0,message:"Loading..."}):t.jsxs("div",{className:"flex w-full min-w-0 flex-col px-1",children:[l&&I?t.jsxs("button",{type:"button",className:J(_a,"px-2"),"aria-label":`Up one level to ${V}`,onClick:()=>b(I),style:{touchAction:"manipulation"},children:[t.jsx(F,{name:"arrow-left",className:J(Ln(!0),"text-muted-foreground")}),t.jsx("span",{className:J(Wa(!0),"flex-1 text-muted-foreground"),children:"Up one level"})]}):null,a.length===0?t.jsx("div",{className:"px-3 py-8 text-center typography-ui-label text-muted-foreground",children:"This directory is empty."}):null,a.map(T=>t.jsx(Ja,{name:T.name,path:T.path,directory:T.type==="directory",meta:T.type==="directory"?void 0:ec(T.size),onClick:()=>T.type==="directory"?b(Yr(T.path,n||e)):j(Yr(T.path,n||e))},T.path))]})})]})},Ja=({name:e,path:n,directory:a,meta:i,onClick:o})=>t.jsxs("button",{type:"button",className:J(_a,"px-2"),onClick:o,style:{touchAction:"manipulation"},children:[a?t.jsx(F,{name:"folder-3-fill",className:J(Ln(!0),"text-primary/80")}):t.jsx(bt,{filePath:n,className:Ln(!0)}),t.jsx("span",{className:J(Wa(!0),"flex-1 text-foreground"),children:e}),i?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:i}):null,a?t.jsx(F,{name:"arrow-right-s",className:"size-4 shrink-0 text-muted-foreground/60"}):null]}),rc=({root:e,results:n,isSearching:a,onOpenFile:i})=>a?t.jsx(Et,{loading:!0,message:"Loading..."}):n.length===0?t.jsx(Et,{message:"No files found."}):t.jsx("div",{className:"flex w-full min-w-0 flex-col px-1",children:n.map(o=>t.jsx(Ja,{name:vt(o.path),path:o.path,directory:!1,meta:o.relativePath??tc(o.path,e),onClick:()=>i(o.path)},o.path))}),Et=({message:e,loading:n=!1})=>t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[n?t.jsx(F,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):t.jsx(F,{name:"folder-open-fill",className:"size-6 text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:e})]})}),ac=({activeDialog:e,dialogData:n,dialogInputValue:a,onDialogInputChange:i,isDialogSubmitting:o,onDialogSubmit:u,onClose:d,inputRef:f})=>t.jsx(Ca,{open:!!e,onOpenChange:g=>!g&&d(),children:t.jsxs(Na,{initialFocus:f,children:[t.jsxs(Sa,{children:[t.jsxs(Ra,{children:[e==="createFile"&&"Create File",e==="createFolder"&&"Create Folder",e==="rename"&&"Rename",e==="delete"&&"Delete"]}),t.jsxs(Fa,{children:[e==="createFile"&&`Create a new file in ${n?.path??"root"}`,e==="createFolder"&&`Create a new folder in ${n?.path??"root"}`,e==="rename"&&`Rename ${n?.name??""}`,e==="delete"&&`Are you sure you want to delete ${n?.name??""}? This action cannot be undone.`]})]}),e!=="delete"&&t.jsx("div",{className:"py-4",children:t.jsx(zt,{value:a,onChange:g=>i(g.target.value),placeholder:e==="rename"?"New name":"Name",onKeyDown:g=>{g.key==="Enter"&&u()},ref:f})}),t.jsxs(Ea,{children:[t.jsx(q,{variant:"outline",onClick:d,disabled:o,children:"Cancel"}),t.jsx(q,{variant:e==="delete"?"destructive":"default",onClick:()=>{u()},disabled:o||e!=="delete"&&!a.trim(),children:o?t.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}):e==="delete"?"Delete":"Confirm"})]})]})}),sc=({label:e,iconDataUrl:n})=>{const[a,i]=s.useState(!1),o=e.trim().slice(0,1).toUpperCase()||"?";return n&&!a?t.jsx("img",{src:n,alt:"",className:"size-4 rounded-sm",onError:()=>i(!0)}):t.jsx("span",{className:J("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),children:o})},Xa=({filePath:e,extension:n})=>t.jsx(bt,{filePath:e,extension:n}),oc=({status:e})=>{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)"}[e];return t.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:n}})},Qr=({name:e})=>{const n=s.useRef(null),a=s.useRef(null),[i,o]=s.useState(!1);return s.useLayoutEffect(()=>{const u=n.current,d=a.current;if(!u||!d)return;const f=()=>{o(d.scrollWidth>u.clientWidth+1)};f();const g=new ResizeObserver(f);return g.observe(u),g.observe(d),()=>{g.disconnect()}},[e]),t.jsxs("span",{ref:n,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[t.jsx("span",{ref:a,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:e}),i?t.jsxs("span",{className:"open-file-name-marquee-track",children:[t.jsx("span",{className:"open-file-name-marquee-item",children:e}),t.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:e})]}):t.jsx("span",{className:"block min-w-0 truncate",children:e})]})},ic=({node:e,root:n,isExpanded:a,isActive:i,isMobile:o,isBrowserClient:u,alwaysShowActions:d,status:f,badge:g,permissions:w,downloadFile:N,contextMenuPath:x,setContextMenuPath:b,rightClickMenuPath:j,setRightClickMenuPath:C,onSelect:v,onToggle:P,onRevealPath:I,onOpenDialog:l})=>{const V=e.type==="directory",{canRename:G,canCreateFile:T,canCreateFolder:_,canDelete:H,canReveal:K}=w,X=!V&&!!N,L=ya()&&ka(),O=K&&!u&&L,k=G||T||_||H||X||O,$=s.useCallback(S=>{k&&(S?.preventDefault(),C(e.path))},[k,e.path,C]),E=s.useCallback(()=>{V?P(e.path):v(e)},[V,e,v,P]),R=s.useCallback(S=>{S.stopPropagation(),C(null),b(e.path)},[e.path,b,C]),m=({Item:S,Separator:A})=>t.jsxs(t.Fragment,{children:[G&&t.jsxs(S,{onClick:z=>{z.stopPropagation(),l("rename",e)},children:[t.jsx(F,{name:"edit",className:"mr-2 size-4"})," ","Rename"]}),t.jsxs(S,{onClick:z=>{z.stopPropagation(),Zt(e.path).then(U=>{if(U.ok){he.success("Path copied");return}he.error("Copy failed")})},children:[t.jsx(F,{name:"file-copy",className:"mr-2 size-4"})," ","Copy Path"]}),t.jsxs(S,{onClick:z=>{z.stopPropagation();const U=Rt(n,e.path)||e.path;Zt(U).then(Q=>{if(Q.ok){he.success("Relative path copied");return}he.error("Copy failed")})},children:[t.jsx(F,{name:"file-copy-2",className:"mr-2 size-4"})," ","Copy Relative Path"]}),!V&&N&&t.jsxs(S,{onClick:z=>{z.stopPropagation(),N(e.path).catch(U=>{console.error("Download failed:",U),he.error("Operation failed")})},children:[t.jsx(F,{name:"download",className:"mr-2 size-4"})," ",u?"Download":"Save"]}),O&&t.jsxs(S,{onClick:z=>{z.stopPropagation(),I(e.path)},children:[t.jsx(F,{name:"folder-received",className:"mr-2 size-4"})," ",Wo()]}),V&&(T||_)&&t.jsxs(t.Fragment,{children:[t.jsx(A,{}),T&&t.jsxs(S,{onClick:z=>{z.stopPropagation(),l("createFile",e)},children:[t.jsx(F,{name:"file-add",className:"mr-2 size-4"})," ","New File"]}),_&&t.jsxs(S,{onClick:z=>{z.stopPropagation(),l("createFolder",e)},children:[t.jsx(F,{name:"folder-add",className:"mr-2 size-4"})," ","New Folder"]})]}),H&&t.jsxs(t.Fragment,{children:[t.jsx(A,{}),t.jsxs(S,{onClick:z=>{z.stopPropagation(),l("delete",e)},className:"text-destructive focus:text-destructive",children:[t.jsx(F,{name:"delete-bin",className:"mr-2 size-4"})," ","Delete"]})]})]});return t.jsxs(gi,{open:j===e.path,onOpenChange:S=>C(S?e.path:null),children:[t.jsxs(xi,{render:t.jsx("div",{className:"group relative flex items-center",onContextMenu:o?void 0:$}),children:[t.jsxs("button",{type:"button",onClick:E,onContextMenu:o?void 0:$,className:J("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",i?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[V?a?t.jsx(F,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):t.jsx(F,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):t.jsx(Xa,{filePath:e.path,extension:e.extension}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:e.path,children:e.name}),!V&&f&&t.jsx(oc,{status:f}),V&&g&&t.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[g.modified>0&&t.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",g.modified]}),g.added>0&&t.jsxs("span",{className:"text-[var(--status-success)]",children:["+",g.added]})]})]}),k&&t.jsx("div",{className:J("absolute right-1 top-1/2 -translate-y-1/2",d?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:t.jsxs(Bn,{open:x===e.path,onOpenChange:S=>b(S?e.path:null),children:[t.jsx($n,{asChild:!0,children:t.jsx(q,{variant:"ghost",size:"icon",className:"size-6",onClick:R,children:t.jsx(F,{name:"more-2-fill",className:"size-4"})})}),t.jsx(Vn,{align:"end",side:"bottom",onCloseAutoFocus:()=>b(null),children:m({Item:en,Separator:ni})})]})})]}),t.jsx(vi,{className:"min-w-[180px]",children:m({Item:bi,Separator:wi})})]})},Rn=(e,n,a)=>{const[i,o]=s.useState(""),[u,d]=s.useState(0);return s.useEffect(()=>{if(!e){o("");return}let f=!1;o("");const g=_o(),w=Ko(g);qo(g).then(x=>{f||!x||(o(e),n(null))}).catch(x=>{f||(n(x instanceof Error?x.message:a),o(e))});const N=Ho(()=>{f||(o(e),d(x=>x+1),n(null))});return()=>{f=!0,w(),N()}},[e,n,a]),{readyKey:i,nonce:u}},cc=e=>e!==null&&typeof e=="object"&&"updateStatus"in e&&typeof e.updateStatus=="function",lc=e=>{const n=document.createElement("div");n.className="cm-vim-panel";const a=Li(e);if(!a)return{top:!1,dom:n};a.state.statusbar=n;const i=a.state.vimPlugin;return cc(i)&&i.updateStatus(),{top:!1,dom:n,destroy(){a.state.statusbar===n&&(a.state.statusbar=null)}}};function Zr(e){return e?[Oi(),Eo.of(lc),zo()]:[]}const uc={next:"Next match",prev:"Previous match",select:"Select all matches",replace:"Replace",replaceAll:"Replace all",close:"Close"},dc={case:"Match case",re:"Regular expression",word:"Match whole word"};function fc(e){const n=e.querySelector(".cm-search");if(n){for(const[a,i]of Object.entries(uc)){const o=n.querySelector(`button[name="${a}"]`);o&&!o.title&&(o.title=i)}for(const[a,i]of Object.entries(dc)){const u=n.querySelector(`input[name="${a}"]`)?.parentElement;u&&!u.title&&(u.title=i)}}}const Fn=new WeakMap;function mc(e,n){const a=nn(e.state);if(!a.valid)return Fn.delete(e),0;const i=Fn.get(e);if(!n&&i?.doc===e.state.doc&&i.query.eq(a))return i.total;const o=a.getCursor(e.state);let u=0;for(let d=o.next();!d.done;d=o.next())u+=1;return Fn.set(e,{query:a,doc:e.state.doc,total:u}),u}function pc(e){const n=nn(e.state);if(!n.valid)return 0;const a=e.state.selection.main,i=n.getCursor(e.state);let o=0,u=0;for(let d=i.next();!d.done;d=i.next()){const f=d.value;if(o+=1,u===0&&(u=o),a.from===f.from&&a.to===f.to||a.from<f.to&&a.to>f.from||f.from>=a.head)return o}return u}function ea(e,n,a=!1){const i=e.querySelector(".cm-search");if(!i)return;let o=i.querySelector(".cm-search-message");if(!o){o=document.createElement("span"),o.className="cm-search-message",o.setAttribute("aria-live","polite");const f=i.querySelector('button[name="next"]'),g=f?.parentNode===i?f:i.firstChild;i.insertBefore(o,g)}const u=mc(n,a),d=u===0?0:pc(n);o.textContent=u===0?"":`${d}/${u}`}const ta=new st,na=new st,ra=new st,aa=new st,sa=new st,oa=new st,ia=new st,ca=e=>e,En=Bo,hc=Ti,gc=Ai;class xc extends $o{constructor(n,a){super(),this.id=n,this.containerMap=a}id;containerMap;toDOM(){let n=this.containerMap.get(this.id);return n||(n=document.createElement("div"),n.className="oc-block-widget",n.dataset.widgetId=this.id,this.containerMap.set(this.id,n)),n}eq(n){return n.id===this.id}destroy(){}}const la=(e,n)=>!e||e.length===0?[]:ba.define({create(a){const i=new In,o=[...e].sort((u,d)=>u.afterLine-d.afterLine);for(const u of o){const d=a.doc.lines;if(u.afterLine>d)continue;const f=a.doc.line(u.afterLine);i.add(f.to,f.to,rn.widget({widget:new xc(u.id,n),block:!0,side:1}))}return i.finish()},update(a,i){return a.map(i.changes)},provide:a=>pe.decorations.from(a)}),ua=e=>{if(!e)return[];const n=Math.max(1,e.start),a=Math.max(n,e.end);return wa.fromClass(class{decorations;constructor(i){this.decorations=this.build(i)}update(i){(i.docChanged||i.viewportChanged)&&(this.decorations=this.build(i.view))}build(i){const o=new In;for(let u=n;u<=a&&u<=i.state.doc.lines;u+=1){const d=i.state.doc.line(u);o.add(d.from,d.from,rn.line({class:"oc-cm-selected-line"}))}return o.finish()}},{decorations:i=>i.decorations})};function vc({value:e,onChange:n,extensions:a,className:i,readOnly:o,lineNumbersConfig:u,highlightLines:d,onViewReady:f,onViewDestroy:g,blockWidgets:w,enableSearch:N,searchOpen:x,onSearchOpenChange:b,vimMode:j}){const C=s.useRef(null),v=s.useRef(null),P=s.useRef(e),I=s.useRef(n),l=s.useRef(f),V=s.useRef(g),G=s.useRef(b),T=s.useRef(w),_=s.useRef(j),H=s.useRef(new Map),[K,X]=s.useState([]),L=s.useCallback(k=>{const $=(k??[]).map(E=>{const R=H.current.get(E.id);return R?{id:E.id,content:E.content,container:R}:null}).filter(E=>E!==null);X(E=>E.length===$.length&&E.every((R,m)=>{const S=$[m];return R.id===S.id&&R.content===S.content&&R.container===S.container})?E:$)},[]),O=s.useCallback(k=>{const $=C.current,E=k??v.current;if(!$||!E)return;const R=E.dom.querySelector(".cm-gutters"),m=R instanceof HTMLElement?R.getBoundingClientRect().width:0;$.style.setProperty("--oc-editor-gutter-width",`${m}px`)},[]);return s.useEffect(()=>{P.current=e},[e]),s.useEffect(()=>{I.current=n},[n]),s.useEffect(()=>{l.current=f,V.current=g},[f,g]),s.useEffect(()=>{G.current=b},[b]),s.useEffect(()=>{T.current=w,L(w)},[w,L]),s.useEffect(()=>{if(!C.current)return;const k=(()=>{if(typeof document>"u")return null;const E=document.querySelector('meta[name="csp-nonce"]')?.getAttribute("content");if(E)return E;const R=window.__PICHAMBER_CSP_NONCE__;return typeof R=="string"&&R.length>0?R:null})(),$=Mo.create({doc:P.current,extensions:[...k?[pe.cspNonce.of(k)]:[],Do({fixed:!0}),ta.of(Tr(u)),To(),Ao.of(" "),ia.of(Zr(j)),Cn.of([Oo,...Lo,...Po]),pe.updateListener.of(E=>{O(E.view),(E.viewportChanged||E.geometryChanged)&&L(T.current);const R=qr(E.startState),m=qr(E.state);R!==m&&G.current?.(m);const S=!nn(E.startState).eq(nn(E.state));if(m&&(R!==m||S||E.docChanged||E.selectionSet)&&ea(E.view.dom,E.view,R!==m||S||E.docChanged),!E.docChanged)return;const A=E.state.doc.toString();P.current=A,I.current(A),L(T.current)}),na.of(pe.editable.of(!o)),ra.of(a??[]),aa.of(ua(d)),sa.of(la(w,H.current)),oa.of(N?[Hr({top:!0}),Cn.of(ca(Gr))]:[])]});return v.current=new pe({state:$,parent:C.current}),En(v.current,v.current.state.doc.length,200),v.current.requestMeasure(),requestAnimationFrame(()=>{O(v.current),L(T.current)}),v.current&&l.current?.(v.current),()=>{V.current?.(),v.current?.destroy(),v.current=null,X([])}},[T,O,L]),s.useEffect(()=>{const k=v.current;k&&(k.dispatch({effects:[ta.reconfigure(Tr(u)),na.reconfigure(pe.editable.of(!o)),ra.reconfigure(a??[]),aa.reconfigure(ua(d)),sa.reconfigure(la(w,H.current)),oa.reconfigure(N?[Hr({top:!0}),Cn.of(ca(Gr))]:[])]}),En(k,k.state.doc.length,200),k.requestMeasure(),requestAnimationFrame(()=>{O(k),L(T.current)}))},[a,d,u,o,w,N,O,L]),s.useEffect(()=>{const k=v.current;if(!k){_.current=j;return}_.current!==j&&(_.current=j,k.dispatch({effects:ia.reconfigure(Zr(j))}))},[j]),s.useEffect(()=>{const k=v.current;!k||N===!1||(x?(hc(k),requestAnimationFrame(()=>{fc(k.dom),ea(k.dom,k,!0)})):gc(k))},[x,N]),s.useEffect(()=>{const k=v.current;if(!k)return;const $=k.state.doc.toString();$!==e&&(k.dispatch({changes:{from:0,to:$.length,insert:e}}),En(k,k.state.doc.length,300),k.requestMeasure(),requestAnimationFrame(()=>O(k)))},[e,O]),t.jsxs(t.Fragment,{children:[t.jsx("div",{ref:C,className:J("h-full w-full","[&_.cm-editor]:h-full [&_.cm-editor]:w-full","[&_.cm-scroller]:font-mono [&_.cm-scroller]:text-[var(--text-code)] [&_.cm-scroller]:leading-6","[&_.cm-lineNumbers]:text-[var(--tools-edit-line-number)]",i)}),K.map(k=>Io.createPortal(k.content,k.container,k.id))]})}const da=({variant:e,selectedFile:n,loading:a,suppressLoadingIndicator:i,fileError:o,isSelectedImage:u,imageSrc:d,imagePreviewNonce:f,isSelectedPdf:g,pdfSrc:w,pdfPreviewNonce:N,isUnsupportedBinary:x,onDownload:b,enableRichPreviews:j,drawioViewMode:C,drawioRemountNonce:v,diagramEditorRef:P,diagramEditorXml:I,onDiagramChange:l,jsonViewMode:V,markdownViewMode:G,htmlViewMode:T,htmlLoading:_,htmlPreviewNonce:H,htmlPreviewSrc:K,fileContent:X,canUseShikiFileView:L,textViewMode:O,draftContent:k,onDraftChange:$,canEdit:E,vimMode:R,editorExtensions:m,editorWrapperRef:S,shouldMaskEditorForPendingNavigation:A,onEditorViewReady:z,onEditorViewDestroy:U,enableSearch:Q=!1,searchOpen:ae,onSearchOpenChange:oe,pierreTheme:W,shikiThemeType:te,wrapLines:je})=>{const ze=e==="fullscreen",ue=ze?"p-4":"p-3",Ze=!!(n?.path&&tn(n.path)),_e=!!(n?.path&&Ka(n.path)),Le=!!(n?.path&&qa(n.path)),xe=!!(n?.path&&Wn(n.path)),de=s.useRef(null),ne=()=>n?t.jsxs("div",{className:"relative h-full",ref:de,children:[t.jsx(Di,{file:{name:n.name,contents:k,lang:Ma(n.path)||void 0},options:{disableFileHeader:!0,overflow:je?"wrap":"scroll",theme:W,themeType:te,...je?{}:{unsafeCSS:Pi}},className:"block h-full w-full",style:{height:"100%"}}),t.jsx(Ii,{hostRef:de,enabled:!je})]}):null;return t.jsx(za,{outerClassName:"h-full min-w-0",className:"h-full min-w-0",children:n?a?i?t.jsx("div",{className:ue}):t.jsxs("div",{className:`${ue} flex items-center gap-2 typography-ui text-muted-foreground`,children:[t.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),ze?"Loading…":"Loading..."]}):o?t.jsx("div",{className:`${ue} typography-ui text-[color:var(--status-error)]`,children:o}):u?t.jsx("div",{className:J("flex h-full items-center justify-center",ue),children:t.jsx("img",{src:d,alt:n.name||"Image",className:J("max-w-full object-contain rounded-md border border-border/30 bg-primary/10",ze?"max-h-full":"max-h-[70vh]")},f)}):g?t.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:t.jsx("iframe",{src:w,className:"h-full w-full border-0",title:n.name},N)}):x?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[t.jsx("div",{className:"typography-ui-header text-foreground",children:"Cannot preview binary file"}),t.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:"This file is binary and cannot be edited in PiChamber. Download it to open with another app."}),b?t.jsxs(q,{type:"button",variant:"outline",size:"sm",onClick:b,children:[t.jsx(F,{name:"download",className:"mr-2 size-4"}),"Save file"]}):null]}):j&&Ze&&C==="preview"?t.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:t.jsx(mi,{ref:P,xml:I,onChange:l},`${n.path}:${v}`)}):j&&_e&&V==="tree"?t.jsx(Pr,{fallback:t.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[t.jsx("div",{className:"mb-1 font-medium text-destructive",children:"JSON viewer unavailable"}),t.jsx("div",{className:"text-sm text-muted-foreground",children:"Switch to text mode to view raw content."})]}),children:t.jsx("div",{className:"h-full overflow-auto",children:t.jsx(Mi,{jsonString:X,maxHeight:"100%",initiallyExpandedDepth:2})})}):Le&&G==="preview"?t.jsxs("div",{className:J("h-full overflow-auto",ue),children:[X.length>500*1024?t.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:`This file is large (${Math.round(X.length/1024)}KB). Preview may be limited.`}):null,t.jsx(Pr,{fallback:t.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[t.jsx("div",{className:"mb-1 font-medium text-destructive",children:"Preview unavailable"}),t.jsx("div",{className:"text-sm text-muted-foreground",children:"Switch to edit mode to fix the issue."})]}),children:t.jsx(ri,{content:X,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}):j&&xe&&T==="preview"?_?t.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:"Loading..."}):t.jsx("div",{className:"h-full overflow-hidden",children:t.jsx("iframe",{src:K,className:"w-full h-full border-none",sandbox:"allow-scripts allow-same-origin allow-forms",title:"HTML Preview"},H)}):L&&O==="view"?ne():t.jsxs("div",{className:J("relative h-full",A&&"overflow-hidden"),ref:S,children:[t.jsx("div",{className:J("h-full",A&&"invisible"),children:t.jsx(vc,{value:k,onChange:$,readOnly:!E,vimMode:R,extensions:m,className:"h-full",onViewReady:z,onViewDestroy:U,...Q?{enableSearch:!0,searchOpen:ae,onSearchOpenChange:oe}:{}})}),A?t.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:t.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[t.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),"Opening file at change..."]})}):null]}):t.jsx("div",{className:`${ue} typography-ui text-muted-foreground`,children:"Pick a file from the tree."})})};async function bc(e,n,a){if(Da(e)&&!Ta(e))return{kind:n?"desktop-image":"asset-image"};if(Aa(e))return{kind:"pdf"};if(An(e))return{kind:"binary",detectedFromContent:!1};const o=await a(e);if(ai(o))return{kind:"binary",detectedFromContent:!0};const u=yi(o);return{kind:"text",content:u,draft:u.length>Ft?`${u.slice(0,Ft)}
|
|
2
|
-
|
|
3
|
-
… truncated …`:u,lineEnding:ki(o)}}function wc({isDirty:e,saveDraft:n}){const a=ke(b=>b.setMainTabGuard),[i,o]=y.useState(!1),u=y.useRef(null),d=y.useRef(!1),f=y.useCallback(b=>d.current?(d.current=!1,!1):e?(u.current=b,o(!0),!0):!1,[e]);y.useEffect(()=>{if(!e){a(null);return}const b=j=>!f({kind:"tab",tab:j});return a(b),()=>{ke.getState().mainTabGuard===b&&a(null)}},[e,f,a]);const g=y.useCallback(()=>{const b=u.current;return u.current=null,d.current=!0,o(!1),b?.kind==="tab"&&a(null),b},[a]),w=y.useCallback(()=>g(),[g]),N=y.useCallback(async()=>await n()?g():(d.current=!1,null),[n,g]),x=y.useCallback(b=>{b||o(!0)},[]);return{confirmOpen:i,discardAndTakeIntent:w,keepModalOpen:x,requestNavigation:f,saveAndTakeIntent:N}}function yc(e,n){if(e.state.doc.length!==n.length)return!1;if(n.length===0)return!0;const a=Math.min(128,n.length);if(e.state.sliceDoc(0,a)!==n.slice(0,a))return!1;const i=Math.max(0,n.length-a);return e.state.sliceDoc(i,n.length)===n.slice(i)}function kc({root:e,selectedPath:n,loadedPath:a,fileLoading:i,fileError:o,isImage:u,isPdf:d,isUnsupportedBinary:f,canEdit:g,textViewMode:w,setTextViewMode:N,draftContent:x,confirmDiscardOpen:b,selectFilePath:j}){const C=ke(L=>L.pendingFileNavigation),v=ke(L=>L.setPendingFileNavigation),P=ke(L=>L.pendingFileFocusPath),I=ke(L=>L.setPendingFileFocusPath),l=y.useRef(null),[V,G]=y.useState(0),T=y.useRef(null),_=y.useRef({key:"",attempts:0}),H=y.useCallback(()=>{G(L=>L+1)},[]);y.useEffect(()=>()=>{T.current!==null&&window.cancelAnimationFrame(T.current)},[]),y.useEffect(()=>{if(!C||!e)return;const L=()=>{T.current===null&&(T.current=window.requestAnimationFrame(()=>{T.current=null,H()}))},O=()=>{v(null),_.current={key:"",attempts:0}},k=se(C.path);if(!k){O();return}const $=`${k}:${C.line}:${C.column??1}`;if(_.current.key!==$&&(_.current={key:$,attempts:0}),n!==k){b||j(k);return}if(i||a!==k)return;if(o||u||d||f){O();return}if(!g)return;if(w!=="edit"){N("edit");return}const E=l.current;if(!E||!yc(E,x)){L();return}const R=Math.max(1,Math.min(C.line,E.state.doc.lines)),m=E.state.doc.line(R),S=Math.max(1,C.column||1),A=m.from+Math.min(Math.max(0,m.to-m.from),S-1);if(!(E.state.selection.main.head===A)||_.current.attempts===0){_.current.attempts+=1,E.dispatch({selection:{anchor:A},effects:pe.scrollIntoView(A,{y:"center"})}),E.focus(),L();return}window.requestAnimationFrame(()=>{const U=l.current;U&&(U.dispatch({selection:{anchor:A},effects:pe.scrollIntoView(A,{y:"center"})}),U.focus())}),O()},[g,b,x,V,o,i,u,d,f,a,H,C,e,n,j,v,N,w]),y.useEffect(()=>{if(!P||!e)return;const L=se(P);if(!L){I(null);return}n!==L||i||a!==L||(!o&&!u&&!d&&!f&&g&&w==="edit"&&l.current?.focus(),I(null))},[g,o,i,u,d,f,a,P,e,n,I,w]);const K=se(C?.path??"");return{editorViewRef:l,notifyEditorViewChanged:H,shouldMaskEditor:!!(C&&K&&n===K&&!i&&!o&&!u&&!d&&!f)}}function jc(e){return!(!e.autoSaveEnabled||!e.isDirty||!e.canWrite||e.isSaving||e.fileLoading||e.isNonEditableBinary||!e.selectedFilePath||e.loadedFilePath!==e.selectedFilePath)}function Cc(e){return e.selectedFilePath?e.isDirty?!(e.fileLoading||e.loadedFilePath!==e.selectedFilePath||e.isNonEditableBinary||e.draftContent===""&&e.fileContent!==""&&e.loadedFilePath!==e.selectedFilePath):!0:!1}const Nc=1500,Sc=2e3;function Rc({autoSaveEnabled:e,selectedPath:n,loadedPath:a,fileLoading:i,isDirty:o,draftContent:u,fileContent:d,lineEnding:f,isNonEditableBinary:g,writeFile:w,expectedRevision:N,onSaved:x,captureSaveScope:b,currentSaveScope:j,onConflict:C}){const[v,P]=y.useState(!1),[I,l]=y.useState("idle"),[V,G]=y.useState(null),T=y.useRef(null),_=y.useRef(null),H=y.useRef(C);H.current=C;const K=y.useRef(b);K.current=b;const X=y.useRef(j);X.current=j;const L=y.useCallback(R=>R?$a(R,X.current?.()??null):!0,[]),O=y.useCallback(()=>{T.current&&(clearTimeout(T.current),T.current=null)},[]),k=y.useCallback(()=>{l("saved"),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{_.current=null,l("idle")},Sc)},[]),$=y.useCallback(async R=>{if(!n||!w)return he.error("Saving not supported"),!1;if(!Cc({selectedFilePath:n,loadedFilePath:a,fileLoading:i,isDirty:o,draftContent:u,fileContent:d,isNonEditableBinary:g}))return g?console.warn(`[saveDraft] refusing to save binary file "${n}".`):u===""&&d!==""&&a!==n&&console.warn(`[saveDraft] refusing to save empty draft for "${n}" (${d.length} bytes were expected). The file may have been read during a concurrent write (O_TRUNC race). Try again after content finishes loading if the save was intentional.`),!1;if(!o)return!0;P(!0);const m=K.current?.()??null;try{const S=ji(u,f),A=Va(N,R?.overwrite),z=await w(n,S,A);return z?.success?L(m)?(G(null),x(n,u,z?.revision,m),!0):!1:(he.error("Failed to write file"),!1)}catch(S){if(ja(S)){if(!L(m))return!1;const A={path:n,currentRevision:S.currentRevision??null,exists:S.exists};return G(A),H.current?.(A),!1}return he.error(S instanceof Error?S.message:"Save failed"),!1}finally{P(!1)}},[u,N,d,i,o,g,L,f,a,x,n,w]),E=y.useCallback(async R=>{if(O(),v)return!1;const m=await $(R);return m&&k(),m},[O,v,$,k]);return y.useEffect(()=>{e||(l("idle"),O())},[e,O]),y.useEffect(()=>{if(jc({autoSaveEnabled:e,isDirty:o,canWrite:!!(n&&w),isSaving:v,fileLoading:i,selectedFilePath:n,loadedFilePath:a,isNonEditableBinary:g}))return T.current=setTimeout(()=>{T.current=null,$().then(R=>{R&&k()})},Nc),O},[e,O,u,i,o,g,v,a,$,n,k,w]),y.useEffect(()=>{l("idle"),P(!1),G(null)},[n]),y.useEffect(()=>()=>{O(),_.current&&clearTimeout(_.current)},[O]),{autoSaveStatus:I,cancelPendingAutosave:O,isSaving:v,saveConflict:V,clearSaveConflict:()=>G(null),saveDraft:$,saveNow:E}}function Fc(e,n){return typeof e.revision=="string"&&typeof n.revision=="string"&&e.revision!==n.revision?!0:n.mtimeMs!==void 0&&e.mtimeMs!==void 0&&n.mtimeMs!==e.mtimeMs||n.size!==e.size}function Ec({selectedPath:e,loadedPath:n,isDirty:a,readStat:i,onExternalChange:o,pollIntervalMs:u=2e3}){const d=y.useRef(null),f=y.useRef(a);f.current=a;const g=y.useCallback(w=>{d.current=w},[]);return y.useEffect(()=>{if(!e||n!==e)return;let w=!1;const N=window.setInterval(()=>{if(document.hidden)return;const x=d.current,b=x&&x.path===e&&typeof x.revision=="string"?x.revision:null;i(e,{knownRevision:b}).then(j=>{if(w||!j)return;const C=d.current;if(!C||C.path!==e){d.current=j;return}!Fc(C,j)||f.current||(d.current=j,o())}).catch(()=>{})},u);return()=>{w=!0,window.clearInterval(N)}},[n,o,u,i,e]),{recordStat:g}}const fa="pichamber:files:md-viewer-mode",ma="pichamber:files:html-viewer-mode",pa="pichamber:files:json-viewer-mode",zc=1500,Mc=1500;function zn(e,n,a){try{const i=localStorage.getItem(e);if(i&&n.includes(i))return i}catch{}return a}function Mn(e,n){try{localStorage.setItem(e,n)}catch{}}function Dc({root:e,selectedPath:n,fileContent:a,draftContent:i,setDraftContent:o,autoSaveEnabled:u,writeFile:d,expectedRevision:f,captureSaveScope:g,currentSaveScope:w,onSaved:N,onConflict:x}){const[b,j]=y.useState("edit"),[C,v]=y.useState("edit"),[P,I]=y.useState("text"),[l,V]=y.useState("edit"),[G,T]=y.useState("edit"),[_,H]=y.useState(0),[K,X]=y.useState(!1),L=y.useRef({}),O=y.useRef({}),k=y.useRef({}),$=y.useRef({}),E=y.useRef(""),R=y.useRef(""),m=y.useRef(null),S=y.useRef(null),A=y.useRef(null),z=y.useRef(f);z.current=f;const U=y.useRef(g);U.current=g;const Q=y.useRef(w);Q.current=w;const ae=y.useRef(N);ae.current=N;const oe=y.useRef(x);oe.current=x;const W=y.useCallback(()=>{m.current&&(clearTimeout(m.current),m.current=null),A.current!==null&&(cancelAnimationFrame(A.current),A.current=null)},[]),te=y.useCallback(B=>{E.current=B,R.current=B},[]),je=y.useCallback(()=>te(""),[te]);y.useEffect(()=>{n&&(j(L.current[n]??"edit"),v(O.current[n]??zn(fa,["preview","edit"],"edit")),V(k.current[n]??zn(ma,["preview","edit"],"edit")),T($.current[n]??"edit"),I(zn(pa,["tree","text"],"text")))},[n]);const ze=y.useCallback(B=>{n&&(L.current[n]=B),j(B)},[n]),ue=y.useCallback(B=>{n&&(O.current[n]=B),v(B),Mn(fa,B)},[n]),Ze=y.useCallback(B=>{n&&(k.current[n]=B),V(B),Mn(ma,B)},[n]),_e=y.useCallback(B=>{I(B),Mn(pa,B)},[]),Le=y.useCallback(B=>{if(n&&($.current[n]=B),W(),B==="edit"){o(E.current||a),T(B);return}E.current=i;const ce=n;T("edit"),A.current=requestAnimationFrame(()=>{A.current=requestAnimationFrame(()=>{A.current=null,!(e&&ce&&Ee.getState().byRoot[e]?.selectedPath!==ce)&&(H(Y=>Y+1),T("preview"))})})},[W,i,a,e,n,o]),xe=y.useCallback(B=>B?$a(B,Q.current?.()??null):!0,[]),de=y.useCallback(async(B,ce,Y)=>{if(!d||ce===R.current)return!1;const ee=U.current?.()??null;if(ee&&ee.path!==B)return!1;try{const fe=await d(B,ce,Va(z.current,Y?.overwrite));return fe?.success?xe(ee)?(te(ce),o(ce),ae.current?.(B,ce,fe?.revision,ee),!0):!1:(he.error("Failed to write file"),!1)}catch(fe){return ja(fe)?(xe(ee)&&oe.current?.({path:B,currentRevision:fe.currentRevision??null,exists:fe.exists,xml:ce}),!1):(he.error(fe instanceof Error?fe.message:"Save failed"),!1)}},[xe,te,o,d]),ne=y.useCallback(()=>{X(!0),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>X(!1),Mc)},[]),ge=y.useCallback(async(B,ce,Y)=>{m.current&&(clearTimeout(m.current),m.current=null);const ee=await de(B,ce,Y);return ee&&ne(),ee},[de,ne]),ot=y.useCallback(B=>{E.current=B,!(!u||!n||G!=="preview"||!d)&&(m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{m.current=null,de(n,B).then(ce=>{ce&&ne()})},zc))},[u,G,de,n,ne,d]);y.useEffect(()=>W,[W,G,n]),y.useEffect(()=>()=>{S.current&&clearTimeout(S.current)},[]);const Ke=tn(n??"")&&(E.current||i)||a;return{clearDiagramContent:je,diagramEditorXml:Ke,diagramSaved:K,drawioRemountNonce:_,drawioViewMode:G,handleDiagramChange:ot,htmlViewMode:l,jsonViewMode:P,mdViewMode:C,recordDiagramContent:te,saveDiagramNow:ge,saveDiagramXml:de,saveDrawioViewMode:Le,saveHtmlViewMode:Ze,saveJsonViewMode:_e,saveMdViewMode:ue,saveTextViewMode:ze,setTextViewMode:j,textViewMode:b}}function Tc(e,n){return e==="mobile"?!0:n==="full"}function Ac(e,n){if(e===n)return!0;if(e.length!==n.length)return!1;for(let a=0;a<e.length;a+=1){const i=e[a],o=n[a];if(i.name!==o.name||i.path!==o.path||i.type!==o.type||i.extension!==o.extension||i.relativePath!==o.relativePath||i.size!==o.size)return!1}return!0}function Oc({files:e,root:n,activeDirectory:a,expandedPaths:i,chrome:o,showGitignored:u,removeExpandedPathsByPrefix:d,enabled:f=!0,visible:g=!0}){const[w,N]=s.useState({}),[x,b]=s.useState({}),j=s.useRef(new Set),C=s.useRef(new Set),v=s.useRef(new Map),P=s.useRef(new Map),I=s.useRef(0),l=s.useRef(!1),[V,G]=s.useState(()=>Go());s.useEffect(()=>Uo(R=>{G(R.runtimeKey)}),[]),s.useEffect(()=>(l.current=!1,()=>{l.current=!0,P.current=new Map,C.current=new Set,v.current=new Map}),[]);const T=s.useCallback((R,m)=>{const S=[];for(const A of m){if(!A?.name||o==="desktop"&&!u&&Ci(A.name))continue;const z=se(A.path||""),U=z?Ni(z)?z:se(`${R}/${z}`):se(`${R}/${A.name}`),Q=A.isDirectory?"directory":"file";S.push({name:A.name,path:U,type:Q,extension:Q==="file"&&A.name.includes(".")?A.name.split(".").pop()?.toLowerCase():void 0,size:A.size})}return Si(S)},[o,u]),_=`${V}|${n}|g${u?"1":"0"}|${o}`,H=s.useRef(_);H.current=_;const K=s.useCallback(async R=>{if(!f)return;const m=se(R.trim());if(!m||j.current.has(m))return;const S=v.current.get(m);if(S){await S;return}const A=H.current,z=I.current+1;I.current=z,P.current=new Map(P.current).set(m,z),C.current=new Set(C.current).add(m);const U=()=>!l.current&&H.current===A&&P.current.get(m)===z,Q=(async()=>{try{const ae=e.listDirectory?(await e.listDirectory(m)).entries.map(W=>({name:W.name,path:W.path,isDirectory:W.isDirectory,size:W.size})):(await Jo(m)).map(W=>({name:W.name,path:W.path,isDirectory:W.isDirectory}));if(!U())return;j.current=new Set(j.current).add(m),b(W=>{if(!W[m])return W;const te={...W};return delete te[m],te});const oe=T(m,ae);N(W=>{const te=W[m];return te&&Ac(te,oe)?W:{...W,[m]:oe}})}catch(ae){if(!U())return;const oe=ae instanceof Error?ae.message:String(ae??"");oe==="Directory not found"&&n&&m!==n?(d(n,m),b(W=>{if(!W[m])return W;const te={...W};return delete te[m],te})):(console.error("Failed to load files directory:",ae),b(W=>({...W,[m]:oe})))}finally{P.current.get(m)===z&&(P.current=new Map(P.current),P.current.delete(m))}})();v.current.set(m,Q);try{await Q}finally{v.current.get(m)===Q&&(v.current.delete(m),C.current=new Set(C.current),C.current.delete(m))}},[f,e,T,d,n]),X=s.useCallback(()=>{j.current=new Set,C.current=new Set,v.current=new Map,P.current=new Map,b({}),N(R=>Object.keys(R).length===0?R:{})},[]),L=s.useCallback(async()=>{!f||!n||(X(),await K(n))},[f,K,X,n]),O=s.useCallback(async R=>{if(!f)return;if(!R){await L();return}const m=se(R);j.current=new Set(j.current),j.current.delete(m),C.current=new Set(C.current),C.current.delete(m),v.current.delete(m),P.current=new Map(P.current),P.current.delete(m),await K(m)},[f,K,L]),k=s.useRef("");s.useEffect(()=>{k.current!==_&&(k.current=_,X())},[X,_]),s.useEffect(()=>{!f||!g||!n||j.current.has(se(n))||K(n)},[f,K,n,_,g]),s.useEffect(()=>{!f||!g||!a||K(a)},[a,f,K,g]),s.useEffect(()=>{if(!f||!g||!e.listDirectory)return;const R=z=>{const U=se(z);return v.current.has(U)||C.current.has(U)},m=()=>{if(!(typeof document<"u"&&document.hidden))for(const z of i)R(z)||O(z)},S=()=>{typeof document<"u"&&document.hidden||m()};typeof document<"u"&&document.addEventListener("visibilitychange",S);const A=i.length>0?window.setInterval(m,8e3):null;return()=>{typeof document<"u"&&document.removeEventListener("visibilitychange",S),A!==null&&window.clearInterval(A)}},[f,i,e.listDirectory,O,g]);const $=s.useRef(f&&g);s.useEffect(()=>{const R=f&&g,m=$.current;if($.current=R,!(!R||m)){if(!e.listDirectory){n&&!j.current.has(se(n))&&K(n);return}if(i.length===0){n&&!j.current.has(se(n))&&K(n);return}for(const S of i){const A=se(S);v.current.has(A)||C.current.has(A)||O(S)}}},[f,i,e.listDirectory,K,O,n,g]);const E=s.useCallback(R=>j.current.has(se(R)),[]);return{childrenByDir:w,loadErrorsByDir:x,isLoaded:E,loadDirectory:K,refreshDirectory:O,refreshRoot:L}}const Lc=({showEditorTabsRow:e,isMobile:n,showMobilePageContent:a,onBackMobile:i,selectedFile:o,openFiles:u,root:d,alwaysShowActions:f,editorTabsOverflow:g,editorTabsScrollRef:w,onSelectFile:N,onCloseFile:x})=>e?t.jsxs("div",{className:"flex min-w-0 items-center px-3 py-1.5",children:[n&&a&&t.jsx("button",{type:"button",onClick:i,"aria-label":"Back",className:"inline-flex size-7 flex-shrink-0 items-center justify-center mr-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:t.jsx(F,{name:"arrow-left-s",className:"size-5"})}),n?o?t.jsxs(Bn,{children:[t.jsx($n,{asChild:!0,children:t.jsxs("button",{type:"button",className:"inline-flex min-w-0 max-w-full items-center gap-1 text-left typography-ui-label font-medium","aria-label":"Open files",children:[t.jsx(bt,{filePath:o.path,extension:o.extension,className:"size-3.5 flex-shrink-0"}),t.jsx(Qr,{name:o.name}),t.jsx(F,{name:"arrow-down-s",className:"size-4 flex-shrink-0 text-muted-foreground"})]})}),t.jsx(Vn,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]",children:u.map(b=>{const j=o?.path===b.path;return t.jsxs(en,{onSelect:C=>{if(C.target.closest("[data-close-open-file]")){C.preventDefault();return}j||N(b)},className:J("flex min-w-0 items-center justify-between gap-2 overflow-hidden",j&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),children:[t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[t.jsx(bt,{filePath:b.path,extension:b.extension,className:"size-3.5 flex-shrink-0"}),t.jsx(Qr,{name:b.name})]}),t.jsx("button",{type:"button","data-close-open-file":!0,onPointerDown:C=>{C.preventDefault(),C.stopPropagation()},onClick:C=>{C.preventDefault(),C.stopPropagation(),x(b.path)},className:"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]","aria-label":`Close ${b.name}`,children:t.jsx(F,{name:"close",className:"size-3.5"})})]},b.path)})})]}):t.jsx("div",{className:"typography-ui-label font-medium truncate",children:"Select a file"}):u.length>0?t.jsxs("div",{className:"relative min-w-0 flex-1",children:[g.left&&t.jsx("div",{className:"pointer-events-none absolute left-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-r from-background to-transparent"}),g.right&&t.jsx("div",{className:"pointer-events-none absolute right-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-l from-background to-transparent"}),t.jsx("div",{ref:w,className:"flex min-w-0 items-center gap-1 overflow-x-auto scrollbar-none",style:{scrollbarWidth:"none",msOverflowStyle:"none"},"data-no-drawer-swipe":"true",children:u.map(b=>{const j=o?.path===b.path;return t.jsxs("div",{title:Rt(d,b.path),className:J("group inline-flex items-center gap-1 rounded-md border px-2 py-1 typography-ui-label transition-colors whitespace-nowrap",j?"bg-[var(--interactive-selection)] border-[var(--primary-muted)] text-[var(--interactive-selection-foreground)]":"bg-transparent border-[var(--interactive-border)] text-[var(--surface-muted-foreground)] hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]"),children:[t.jsx(bt,{filePath:b.path,extension:b.extension,className:"size-3.5 flex-shrink-0"}),t.jsx("button",{type:"button",onClick:()=>{j||N(b)},className:"max-w-[12rem] truncate text-left",children:b.name}),t.jsx("button",{type:"button",onClick:C=>{C.stopPropagation(),x(b.path)},className:J("rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",!j&&!f&&"opacity-0 group-hover:opacity-100"),"aria-label":`Close ${b.name}`,children:t.jsx(F,{name:"close",className:"size-3.5"})})]},b.path)})})]}):t.jsx("div",{className:"typography-ui-label font-medium truncate",children:"Select a file"})]}):null,Pc=(e,n)=>{if(!n)return null;const a=Number.parseInt(e.trim(),10);return!Number.isFinite(a)||a<1?null:Math.min(a,n.state.doc.lines)},ha=(e,n)=>{const a=e.state.doc.lineAt(n.main.head);return{lineNumber:a.number,character:n.main.head-a.from+1,selection:n}},ga=(e,n,a)=>{const i=e.state.doc.line(n),o=Math.max(1,Math.min(a,i.length+1)),u=i.from+o-1;e.dispatch({selection:Vo.cursor(u),effects:pe.scrollIntoView(u,{y:"center"})})};function Ic({open:e,onOpenChange:n,view:a,variant:i="overlay"}){const[o,u]=s.useState(""),d=s.useRef(null),f=s.useRef(!1),g=s.useRef(null),w=s.useRef(null),N=s.useMemo(()=>Pc(o,a),[o,a]);s.useEffect(()=>{!e||!a||(f.current=!1,d.current=ha(a,a.state.selection),u(""))},[e,a]),s.useEffect(()=>{e&&window.requestAnimationFrame(()=>{w.current?.focus(),w.current?.select()})},[e]),s.useEffect(()=>{if(!(!e||!a||!d.current)){if(N===null){const{selection:v}=d.current;a.dispatch({selection:v,effects:pe.scrollIntoView(v.main.from,{y:"center"})});return}ga(a,N,d.current.character)}},[N,e,a]);const x=s.useCallback(()=>{if(!a||f.current||!d.current)return;const{selection:v}=d.current;a.dispatch({selection:v,effects:pe.scrollIntoView(v.main.from,{y:"center"})})},[a]),b=s.useCallback(v=>{v||x(),n(v)},[n,x]),j=s.useCallback(()=>{!a||N===null||!d.current||(f.current=!0,ga(a,N,d.current.character),n(!1),a.focus())},[N,n,a]);s.useEffect(()=>{if(!e)return;const v=I=>{const l=g.current,V=I.target;!l||!(V instanceof Node)||l.contains(V)||b(!1)},P=I=>{I.key==="Escape"&&(I.preventDefault(),b(!1))};return document.addEventListener("pointerdown",v,!0),document.addEventListener("keydown",P,!0),()=>{document.removeEventListener("pointerdown",v,!0),document.removeEventListener("keydown",P,!0)}},[b,e,i]);const C=s.useMemo(()=>a?N===null?`Current Line: ${(d.current??ha(a,a.state.selection)).lineNumber}. Type a line number between 1 and ${a.state.doc.lines} to navigate to.`:`Go to line ${N}`:"Editor unavailable.",[N,a]);return i==="inline"?e?t.jsxs("div",{ref:g,className:"ml-1 flex h-6 items-center gap-1",children:[t.jsx(zt,{ref:w,type:"number",min:1,step:1,inputMode:"numeric",value:o,onChange:v=>u(v.target.value),onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),j())},placeholder:"Line",className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),t.jsx(q,{variant:"outline",size:"xs",onClick:j,disabled:!a||N===null,className:"h-6 px-2",children:"Go"})]}):null:t.jsx("div",{ref:g,className:J("absolute left-3 top-3 z-40 w-[min(32rem,calc(100%-1.5rem))] rounded-xl border border-[var(--interactive-border)] bg-[color:color-mix(in_srgb,var(--surface-elevated)_94%,transparent)] p-2.5 shadow-lg backdrop-blur-sm transition-all",e?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:t.jsxs("div",{className:"min-w-0",children:[t.jsx(zt,{ref:w,type:"number",min:1,step:1,inputMode:"numeric",value:o,onChange:v=>u(v.target.value),onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),j())},placeholder:"Line number",className:"h-8 w-full rounded-md border-border/70 bg-background/60 typography-ui-label"}),t.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:C})]})})}const Dn=({currentMode:e,onToggle:n})=>{const a=e==="preview",i=a?"Switch to edit mode":"Switch to preview mode",o=a?"Edit":"Preview";return t.jsxs(Xe,{children:[t.jsx(Ye,{asChild:!0,children:t.jsx(q,{variant:"ghost",size:"sm",onClick:n,"aria-label":i,className:"h-5 w-5 p-0",children:a?t.jsx(F,{name:"eye",className:"size-4","aria-hidden":"true"}):t.jsx(F,{name:"eye-off",className:"size-4","aria-hidden":"true"})})}),t.jsx(Qe,{sideOffset:8,children:o})]})},Bc=({selectedFile:e,displaySelectedPath:n,layout:a="floating",exitFullscreenOnly:i=!1,canEdit:o,isEditingFile:u,isSaving:d,autoSaveEnabled:f,autoSaveStatus:g,isDirty:w,onSaveDraft:N,onToggleAutoSave:x,canOpenInDesktopApp:b=!0,openInApps:j,openInCacheStale:C,onOpenInApp:v,onRefreshOpenInApps:P,onToolbarDropdownOpenChange:I,isSelectedImage:l,isSelectedPdf:V,isUnsupportedBinary:G,wrapLines:T,onToggleWrapLines:_,textViewMode:H,onToggleSearch:K,isGoToLineOpen:X,onOpenGoToLineChange:L,editorView:O,canUseShikiFileView:k,isJson:$,isHtml:E,onToggleTextViewMode:R,isMarkdown:m,mdViewMode:S,onToggleMdViewMode:A,isDrawio:z,drawioViewMode:U,onToggleDrawioViewMode:Q,diagramSaved:ae,onSaveDiagram:oe,jsonViewMode:W,onToggleJsonViewMode:te,canCopy:je,copiedContent:ze,onCopyContent:ue,canCopyPath:Ze,copiedPath:_e,onCopyPath:Le,onDownloadFile:xe,isMobile:de,mode:ne,isFullscreen:ge,onToggleFullscreen:ot,onExitFullscreen:Ke})=>{if(!e)return null;const ce=a==="docked"?"pointer-events-auto flex flex-wrap items-center gap-1":"pointer-events-auto flex items-center gap-1 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-1 shadow-sm",Y=(ee,fe)=>t.jsxs(Xe,{children:[t.jsx(Ye,{asChild:!0,children:t.jsx("span",{className:"inline-flex",children:fe})}),t.jsx(Qe,{side:"bottom",sideOffset:6,children:ee})]});return t.jsxs("div",{className:ce,children:[o&&u&&t.jsxs(t.Fragment,{children:[d?t.jsxs("span",{className:"flex items-center gap-1 px-1 text-muted-foreground typography-meta",children:[t.jsx(F,{name:"loader-4",className:"size-3.5 animate-spin"}),"Saving..."]}):f&&g==="saved"&&!w?t.jsxs("span",{className:"flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta",children:[t.jsx(F,{name:"check",className:"size-3.5"}),"Saved"]}):w?Y(f?`Save now (${Nt()}+S) - auto-saves after 1.5s`:`Save now (${Nt()}+S)`,t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>{N()},className:"h-6 gap-1 px-1 text-muted-foreground opacity-80 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:f?`Save now (${Nt()}+S) - auto-saves after 1.5s`:`Save now (${Nt()}+S)`,"aria-label":`Save (${Nt()}+S)`,children:t.jsx(F,{name:"save-3",className:"size-4"})})):null,Y(f?"Auto-save on":"Manual save",t.jsx(q,{variant:"ghost",size:"sm",onClick:x,className:J("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",f?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:f?"Auto-save on":"Manual save","aria-label":f?"Auto-save on":"Manual save",children:f?t.jsx(F,{name:"file-check-fill",className:"size-4"}):t.jsx(F,{name:"file-check",className:"size-4"})}))]}),b?t.jsxs(Bn,{onOpenChange:I,children:[t.jsxs(Xe,{children:[t.jsx(Ye,{asChild:!0,children:t.jsx("span",{className:"inline-flex",children:t.jsx($n,{asChild:!0,children:t.jsx(q,{variant:"ghost",size:"sm",className:"size-6 p-0 text-foreground opacity-100 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Open in desktop app","aria-label":"Open in desktop app",children:t.jsx(F,{name:"file-transfer",className:"size-4"})})})})}),t.jsx(Qe,{side:"bottom",sideOffset:6,children:"Open in desktop app"})]}),t.jsxs(Vn,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[j.map(ee=>t.jsxs(en,{className:"flex items-center gap-2",onClick:()=>{v(ee)},children:[t.jsx(sc,{label:ee.label,iconDataUrl:ee.iconDataUrl}),t.jsx("span",{className:"typography-ui-label text-foreground",children:ee.label})]},ee.id)),C?t.jsxs(en,{className:"flex items-center gap-2",onClick:()=>{P()},children:[t.jsx(F,{name:"refresh",className:"size-4"}),t.jsx("span",{className:"typography-ui-label text-foreground",children:"Refresh Apps"})]}):null]})]}):null,!l&&!V&&!G&&t.jsxs(t.Fragment,{children:[Y(T?"Disable line wrap":"Enable line wrap",t.jsx(q,{variant:"ghost",size:"sm",onClick:_,className:J("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",T?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:T?"Disable line wrap":"Enable line wrap",children:t.jsx(F,{name:"text-wrap",className:"size-4"})})),H==="edit"&&t.jsxs(t.Fragment,{children:[Y("Find in file",t.jsx(q,{variant:"ghost",size:"sm",onClick:ee=>{K(),ee.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Find in file",children:t.jsx(F,{name:"search",className:"size-4"})})),Y("Go to line",t.jsx(q,{variant:"ghost",size:"sm",onClick:ee=>{L(!X),ee.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Go to line",children:t.jsx(F,{name:"menu-fold-2",className:"size-4"})})),t.jsx(Ic,{open:X,onOpenChange:L,view:O,variant:"inline"})]})]}),k&&o&&!$&&!E&&t.jsx(Dn,{currentMode:H==="view"?"preview":"edit",onToggle:R}),m&&Y(S==="preview"?"Switch to edit mode":"Switch to preview mode",t.jsx(q,{variant:"ghost",size:"sm",onClick:A,className:J("size-6 p-0 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] active:bg-[var(--interactive-hover)]",S==="preview"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)] focus-visible:bg-[var(--interactive-selection)] active:bg-[var(--interactive-selection)]":"text-muted-foreground opacity-65 hover:opacity-100"),title:S==="preview"?"Switch to edit mode":"Switch to preview mode","aria-label":S==="preview"?"Switch to edit mode":"Switch to preview mode",children:t.jsx(F,{name:S==="preview"?"eye":"eye-off",className:"size-4"})})),Wn(e?.path??"")&&t.jsx(Dn,{currentMode:E?"preview":"edit",onToggle:R}),z&&t.jsxs(t.Fragment,{children:[t.jsx(Dn,{currentMode:U,onToggle:Q}),U==="preview"&&t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>{oe()},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Save diagram",children:ae?t.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):t.jsx(F,{name:"save-3",className:"size-4"})})]}),$&&Y(W==="tree"?"Switch to Text View":"Switch to Tree View",t.jsx(q,{variant:"ghost",size:"sm",onClick:te,className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:W==="tree"?"Switch to Text View":"Switch to Tree View",children:W==="tree"?t.jsx(F,{name:"code-sslash",className:"size-4"}):t.jsx(F,{name:"node-tree",className:"size-4"})})),je&&Y("Copy file contents",t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>{ue()},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Copy file contents","aria-label":"Copy file contents",children:ze?t.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):t.jsx(F,{name:"clipboard",className:"size-4"})})),Ze&&Y(`Copy file path (${n})`,t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>{Le()},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:`Copy file path (${n})`,"aria-label":`Copy file path (${n})`,children:_e?t.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):t.jsx(F,{name:"file-copy-2",className:"size-4"})})),xe&&Y("Save file",t.jsx(q,{variant:"ghost",size:"sm",onClick:xe,className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Save file","aria-label":"Save file",children:t.jsx(F,{name:"download",className:"size-4"})})),i?Y("Exit fullscreen",t.jsx(q,{variant:"ghost",size:"sm",onClick:Ke,className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Exit fullscreen","aria-label":"Exit fullscreen",children:t.jsx(F,{name:"fullscreen-exit",className:"size-4"})})):!de&&ne==="full"&&Y(ge?"Exit fullscreen":"Fullscreen",t.jsx(q,{variant:"ghost",size:"sm",onClick:ot,className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:ge?"Exit fullscreen":"Fullscreen","aria-label":ge?"Exit fullscreen":"Fullscreen",children:ge?t.jsx(F,{name:"fullscreen-exit",className:"size-4"}):t.jsx(F,{name:"fullscreen",className:"size-4"})}))]})},$c=({open:e,onOpenChange:n,isSaving:a,onSaveAndContinue:i,onDiscardAndContinue:o})=>t.jsx(Ca,{open:e,onOpenChange:n,children:t.jsxs(Na,{showCloseButton:!1,className:"max-w-md",children:[t.jsxs(Sa,{children:[t.jsx(Ra,{children:"Unsaved changes"}),t.jsx(Fa,{children:"Save your edits before continuing?"})]}),t.jsxs(Ea,{children:[t.jsx(q,{variant:"outline",onClick:i,disabled:a,className:"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)] hover:bg-[rgb(var(--status-success)/0.2)]",children:"Save changes"}),t.jsx(q,{variant:"destructive",onClick:o,children:"Discard"})]})]})}),xa=(e,n)=>e.startsWith(`${n}/`)?e.slice(n.length+1):e,Vc=e=>e.index==="A"||e.working_dir==="?"?"git-added":e.index==="D"?"git-deleted":e.index==="M"||e.working_dir==="M"?"git-modified":null,Wc=({root:e,openPaths:n,gitFiles:a})=>{const i=new Set(n),o=new Map,u=new Map,d={modified:0,added:0};for(const w of a??[]){o.has(w.path)||o.set(w.path,w);const N=+(w.index==="M"||w.working_dir==="M"),x=+(w.index==="A"||w.working_dir==="?");if(N===0&&x===0)continue;d.modified+=N,d.added+=x;const b=w.path.split("/");for(let j=1;j<b.length;j+=1){const C=b.slice(0,j).join("/");if(!C)continue;let v=u.get(C);v||(v={modified:0,added:0},u.set(C,v)),v.modified+=N,v.added+=x}}return{getFileStatus:w=>{if(i.has(w))return"open";if(o.size===0)return null;const N=xa(w,e),x=o.get(N);return x?Vc(x):null},getFolderBadge:w=>{if(!a)return null;const N=xa(w,e);if(!N)return d.modified+d.added>0?{...d}:null;const x=u.get(N);return x?{...x}:null}}},_c=e=>new Set(e),Kc=({root:e,isMobile:n,searchQuery:a,onSearchQueryChange:i,searchInputRef:o,searching:u,searchResults:d,selectedFile:f,onSelectFile:g,onOpenDialog:w,currentDirectory:N,refreshRoot:x,childrenByDir:b,loadErrorsByDir:j,expandedPaths:C,isBrowserClient:v,alwaysShowActions:P,getFileStatus:I,getFolderBadge:l,fileRowPermissions:V,downloadFile:G,contextMenuPath:T,setContextMenuPath:_,rightClickMenuPath:H,setRightClickMenuPath:K,toggleDirectory:X,handleRevealPath:L,refreshDirectory:O})=>{const k=!!(e&&b[e]),$=e?j[e]:null,E=s.useMemo(()=>_c(C),[C]);function R(m,S){const A=b[m]??[];return A.map((z,U)=>{const Q=z.type==="directory",ae=Q&&E.has(z.path),oe=f?.path===z.path,W=U===A.length-1;return t.jsxs("li",{className:"relative",children:[S>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),W&&t.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-background"})]}),t.jsx(ic,{node:z,root:e,isExpanded:ae,isActive:oe,isMobile:n,isBrowserClient:v,alwaysShowActions:P,status:Q?void 0:I(z.path),badge:Q?l(z.path):void 0,permissions:V,downloadFile:G,contextMenuPath:T,setContextMenuPath:_,rightClickMenuPath:H,setRightClickMenuPath:K,onSelect:g,onToggle:X,onRevealPath:L,onOpenDialog:w}),Q&&ae&&t.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[j[z.path]?t.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:j[z.path],children:j[z.path]}),t.jsxs(q,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{O(z.path)},children:[t.jsx(F,{name:"refresh",className:"size-3.5"}),"Refresh"]})]}):null,R(z.path,S+1)]})]},z.path)})}return t.jsxs("section",{className:J("flex min-h-0 flex-col overflow-hidden",n?"h-full w-full bg-background":"h-full rounded-xl border border-border/60 bg-background/70"),children:[t.jsx("div",{className:J("flex flex-col gap-2 py-2",n?"px-3":"px-2"),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"relative flex-1 min-w-0",children:[t.jsx(F,{name:"search",className:"pointer-events-none absolute left-2 top-2 size-4 text-muted-foreground"}),t.jsx(zt,{ref:o,value:a,onChange:m=>i(m.target.value),placeholder:"Search files...",className:"h-8 pl-8 pr-8 typography-meta"}),a.trim().length>0&&t.jsx("button",{type:"button","aria-label":"Clear search",className:"absolute right-2 top-2 inline-flex size-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{i(""),o.current?.focus()},children:t.jsx(F,{name:"close",className:"size-4"})})]}),t.jsxs(Xe,{children:[t.jsx(Ye,{asChild:!0,children:t.jsx("span",{className:"inline-flex flex-shrink-0",children:t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>w("createFile",{path:N,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:"New File","aria-label":"New File",children:t.jsx(F,{name:"file-add",className:"size-4"})})})}),t.jsx(Qe,{side:"bottom",sideOffset:6,children:"New File"})]}),t.jsxs(Xe,{children:[t.jsx(Ye,{asChild:!0,children:t.jsx("span",{className:"inline-flex flex-shrink-0",children:t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>w("createFolder",{path:N,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:"New Folder","aria-label":"New Folder",children:t.jsx(F,{name:"folder-add",className:"size-4"})})})}),t.jsx(Qe,{side:"bottom",sideOffset:6,children:"New Folder"})]}),t.jsxs(Xe,{children:[t.jsx(Ye,{asChild:!0,children:t.jsx("span",{className:"inline-flex flex-shrink-0",children:t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>{x()},className:"size-8 p-0 flex-shrink-0",title:"Refresh","aria-label":"Refresh",children:t.jsx(F,{name:"refresh",className:"size-4"})})})}),t.jsx(Qe,{side:"bottom",sideOffset:6,children:"Refresh"})]})]})}),t.jsx(za,{outerClassName:"flex-1 min-h-0",className:J("py-2",n?"px-3":"px-2"),children:t.jsx("ul",{className:"flex flex-col",children:u?t.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[t.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),"Searching..."]}):d.length>0?d.map(m=>{const S=f?.path===m.path;return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>{g(m)},className:J("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",S?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[t.jsx(Xa,{filePath:m.path,extension:m.extension}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},title:m.path,children:m.relativePath??m.path})]})},m.path)}):$?t.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[t.jsx("span",{className:"text-[var(--status-error)]",children:$}),t.jsxs(q,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{x()},children:[t.jsx(F,{name:"refresh",className:"size-3.5"}),"Refresh"]})]}):k?R(e,0):t.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:"Loading..."})})})]})},iu=({mode:e="full",chrome:n="desktop",onClose:a,isVisible:i=!0})=>{const{files:o,runtime:u}=si(),d=n==="mobile",{currentTheme:f,availableThemes:g,lightThemeId:w,darkThemeId:N}=oi(),{isMobile:x,isTablet:b,screenWidth:j}=ii(),C=Xo(u.platform),v=x||b,P=Yo(),I=ci()??"",l=se(I.trim()),V=Tc(n,e),G=e!=="editor-only",T=e==="editor-only"&&!x,_=li(I),[H,K]=s.useState(""),X=s.useRef(null),[L,O]=s.useState(!1),[k,$]=s.useState(l),[E,R]=s.useState(!1),[m,S]=s.useState(null),A=ke(r=>r.wrapLinesByDefault),z=m??A,U=s.useCallback(r=>{S(r)},[]),[Q,ae]=s.useState(!1),[oe,W]=s.useState(!1),[te,je]=s.useState(!1),ze=s.useRef(null);s.useEffect(()=>{d&&($(l),K(""),O(!1))},[d,l]);const ue=s.useRef(0),Ze=s.useCallback(r=>{ue.current=Math.max(0,ue.current+(r?1:-1))},[]),_e=s.useCallback(r=>r instanceof Element?r.closest('[data-slot="dropdown-menu-content"], [data-slot="dropdown-menu-item"]')!==null:!1,[]);s.useEffect(()=>{if(!te)return;const r=h=>{ue.current>0||_e(h.target)||ze.current&&!ze.current.contains(h.target)&&je(!1)};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[_e,te]);const Le=s.useMemo(()=>g.find(r=>r.metadata.id===w)??Ar(!1),[g,w]),xe=s.useMemo(()=>g.find(r=>r.metadata.id===N)??Ar(!0),[g,N]);s.useEffect(()=>{Vr(Le),Vr(xe)},[Le,xe]);const de=s.useMemo(()=>[],[]),ne=Ee(r=>l?r.byRoot[l]?.openPaths??de:de),ge=Ee(r=>l?r.byRoot[l]?.selectedPath??null:null),ot=Ee(r=>l?r.byRoot[l]?.expandedPaths??de:de),Ke=Ee(r=>r.removeOpenPath),B=Ee(r=>r.removeOpenPathsByPrefix),ce=Ee(r=>r.removeExpandedPathsByPrefix),Y=Ee(r=>r.setSelectedPath),ee=Ee(r=>r.toggleExpandedPath),fe=Ee(r=>r.expandPaths),{childrenByDir:_n,loadErrorsByDir:Kn,isLoaded:it,loadDirectory:ct,refreshDirectory:Mt,refreshRoot:Ya}=Oc({files:o,root:l,activeDirectory:d?k:void 0,expandedPaths:ot,chrome:n,showGitignored:P,removeExpandedPathsByPrefix:ce,enabled:V,visible:i}),qe=s.useCallback(r=>{const h=se(r),M=h.split("/"),D=M[M.length-1]||h,re=D.includes(".")?D.split(".").pop()?.toLowerCase():void 0;return{name:D,path:h,type:"file",extension:re}},[]),Dt=s.useMemo(()=>ne.map(qe),[ne,qe]),an=s.useMemo(()=>{if(ge){const r=Qt(ge);if(ne.some(h=>Qt(h)===r))return ge}return ne[0]??null},[ne,ge]),p=s.useMemo(()=>an?qe(an):null,[an,qe]),Be=p?.path??"";s.useEffect(()=>{if(!l||!ge)return;const r=Qt(ge);ne.some(M=>Qt(M)===r)||Y(l,ne[0]??null)},[ne,l,ge,Y]);const Tt=!!(l&&Be&&!Sn(Be,l)),qn=Tt?Ir(Be):void 0,le=s.useMemo(()=>({allowOutsideWorkspace:e==="editor-only"&&Tt,outsideFileGrant:qn,directory:l||void 0}),[e,Tt,qn,l]),sn=s.useRef(null),[Qa,Za]=s.useState({left:!1,right:!1}),Hn=s.useCallback(()=>{const r=sn.current;r&&Za({left:r.scrollLeft>2,right:r.scrollLeft+r.clientWidth<r.scrollWidth-2})},[]),Gn=s.useRef(Hn);Gn.current=Hn,s.useEffect(()=>{const r=sn.current;if(!r)return;const h=()=>Gn.current();h(),r.addEventListener("scroll",h,{passive:!0});const M=new ResizeObserver(h);return M.observe(r),()=>{r.removeEventListener("scroll",h),M.disconnect()}},[Dt.length]);const[Ce,Pe]=s.useState(""),[on,lt]=s.useState(!1),[Un,ve]=s.useState(null),[es,He]=s.useState(""),be=s.useRef(""),[et,Ne]=s.useState(null),[ut,Se]=s.useState(void 0),[Jn,Re]=s.useState(null),we=Ee(r=>r.activeRuntimeKey),[me,Ie]=s.useState(null),[cn,Xn]=s.useState(!1),[ts,Me]=s.useState(!1),[dt,Fe]=s.useState(""),[ns,rs]=s.useState(`
|
|
4
|
-
`),Yn=s.useRef(null),De=s.useRef(0),ft=s.useRef(null),[Qn,ln]=s.useState(!1),At=ke(r=>r.autoSaveEnabled),as=ke(r=>r.setAutoSaveEnabled),ss=s.useRef(null),[os,is]=s.useState(null),[cs,ls]=s.useState(null),{value:us,show:ds}=Br(!1,1200),{value:fs,show:ms}=Br(!1,1200),[ps,hs]=s.useState(!1),wt=s.useCallback(()=>{l&&Y(l,null),Pe(""),ve(null),He(""),Ne(null),Se(void 0),Re(null),Ie(null),Me(!1),x&&O(!1)},[x,l,Y]),{operation:gs,target:xs,inputValue:vs,setInputValue:bs,submitting:ws,inputRef:ys,open:ks,close:js,submit:Cs,capabilities:{canCreateFile:Zn,canCreateFolder:er,canRename:tr,canDelete:nr}}=Ri({files:o,root:l,selectedPath:p?.path??"",refreshDirectory:Mt,removeOpenPathsByPrefix:B,clearSelectedPath:wt}),rr=!!o.revealPath,un=ya()&&ka(),Ns=Yt(r=>r.availableApps),Ss=Yt(r=>r.isCacheStale),ar=Yt(r=>r.initialize),Rs=Yt(r=>r.loadInstalledApps);s.useEffect(()=>{un&&ar()},[un,ar]);const Fs=s.useCallback(r=>{o.revealPath&&o.revealPath(r).catch(()=>{he.error("Failed to reveal path")})},[o]),Es=s.useCallback(async r=>{if(!p?.path||await Qo(p.path,r.id,r.appName)||await Or(p.path,r.appName))return;const D=Fi(p.path)||l;D&&await Or(D,r.appName)||he.error(`Failed to open in ${r.appName}`)},[l,p?.path]),zs=ke(r=>r.fileEditorKeymap),sr=ke(r=>r.expandedEditorToolbar);s.useEffect(()=>{Fe("")},[p?.path]);const or=s.useRef("");s.useEffect(()=>{!l||or.current===l||(or.current=l,Pe(""),ve(null),He(""),Ne(null),Se(void 0),Re(null),Ie(null),Me(!1),O(!1))},[l]);const ir=s.useRef(we);s.useEffect(()=>{ir.current!==we&&(ir.current=we,De.current+=1,ft.current=null,Pe(""),Fe(""),ve(null),lt(!1),He(""),Ne(null),Se(void 0),Re(null),Ie(null),Me(!1),ln(!1))},[we]);const Ms=d?k:I,{results:cr,searching:lr}=Ei({directory:Ms,query:H,chrome:n,showGitignored:P}),Ot=s.useCallback(async(r,h)=>{if(o.readFile){const Oe=await o.readFile(r,{...h??{},directory:l||void 0});return{content:Oe.content??"",revision:Oe.revision,exists:Oe.exists}}const M=new URLSearchParams({path:r});h?.allowOutsideWorkspace&&M.set("allowOutsideWorkspace","true"),h?.outsideFileGrant&&M.set("outsideFileGrant",h.outsideFileGrant),h?.optional&&M.set("optional","true"),l&&M.set("directory",l);const D=await Lr(`/api/fs/read?${M.toString()}`,{cache:h?.optional?"no-store":"default"});if(!D.ok){const Oe=await D.json().catch(()=>({error:D.statusText}));throw new Error(Oe.error||"Failed to read file")}const re=await D.text(),Z=D.headers?.get?.("x-pichamber-file-revision"),Ae=D.headers?.get?.("x-pichamber-file-exists")!=="false";return{content:re,revision:typeof Z=="string"&&Z.length>0?Z:Ae?void 0:null,exists:Ae}},[o,l]),mt=s.useCallback(async(r,h)=>{if(o.statFile){const M=await o.statFile(r,{...h??{},directory:l||void 0});return{path:M.path,size:M.size,mtimeMs:M.mtimeMs,revision:M.revision}}return null},[o,l]);s.useEffect(()=>{if(!l||!o.statFile||ne.length===0)return;let r=!1;const h=[...ne];return Promise.all(h.map(async M=>{try{const D=await o.statFile?.(M,{directory:l||void 0});!r&&D&&!D.isFile&&B(l,M)}catch(D){!r&&_r(D)&&B(l,M)}})),()=>{r=!0}},[o,ne,B,l]);const dn=s.useMemo(()=>Ce.length>Ft?`${Ce.slice(0,Ft)}
|
|
5
|
-
|
|
6
|
-
… truncated …`:Ce,[Ce]),Lt=dt!==dn,Ds=s.useCallback((r,h)=>mt(r,{...le,...h}),[mt,le]),Ts=s.useCallback(()=>{Ne(null),Se(void 0),Re(null)},[]),{recordStat:tt}=Ec({selectedPath:p?.path??null,loadedPath:et,isDirty:Lt,readStat:Ds,onExternalChange:Ts}),ur=s.useRef(null),dr=s.useCallback((r,h,M,D)=>{Pe(h);const re=D?.generation??De.current;if(typeof M<"u"&&(Se(M),Re({runtimeKey:D?.runtimeKey??we,root:D?.root??l,path:r,generation:re})),l&&Sn(r,l)){const Z=Rt(l,r);Z&&ui.requestGitRefresh({directory:l,paths:[Z]})}tn(r)&&ur.current?.(h),mt(r).then(Z=>{Z&&De.current===re&&tt(Z)}).catch(()=>{})},[we,mt,tt,l]),fn=s.useCallback(()=>p?.path?{runtimeKey:we,root:l,path:p.path,generation:De.current}:null,[we,l,p?.path]),fr=fn,mr=s.useCallback(async(r,h=null)=>{const M=De.current,D=r.path;let re=null,Z=r.currentRevision,Ve=r.exists;try{if(Ve){const Ae=await Ot(D,le);re=Ae.content,typeof Ae.revision=="string"&&(Z=Ae.revision),Ve=Ae.exists!==!1}}catch{}De.current===M&&(Ie({path:D,displayPath:Rt(l,D)||D,exists:Ve,currentRevision:Z,currentContent:re,diagramXml:h}),Me(!1))},[Ot,l,le]),pr=s.useMemo(()=>{if(!p?.path||et!==p.path)return;const r=Jn;if(r){if(pi({...r},{runtimeKey:we,root:l,path:p.path,generation:De.current}))return typeof ut=="string"||ut===null?"__stale__":void 0;if(typeof ut=="string"||ut===null)return ut}},[we,et,ut,Jn,l,p?.path]),{clearDiagramContent:hr,diagramEditorXml:As,diagramSaved:Os,drawioRemountNonce:Ls,drawioViewMode:mn,handleDiagramChange:Ps,htmlViewMode:Pt,jsonViewMode:It,mdViewMode:Bt,recordDiagramContent:pn,saveDiagramNow:hn,saveDrawioViewMode:Is,saveJsonViewMode:Bs,saveMdViewMode:gr,saveTextViewMode:$s,setTextViewMode:gn,textViewMode:nt}=Dc({root:l,selectedPath:p?.path??null,fileContent:Ce,draftContent:dt,setDraftContent:Fe,autoSaveEnabled:At,writeFile:o.writeFile,expectedRevision:pr,captureSaveScope:fn,currentSaveScope:fr,onSaved:dr,onConflict:r=>{mr(r,r.xml)}});ur.current=pn;const Ge=s.useCallback(()=>Bt,[Bt]),{autoSaveStatus:Vs,isSaving:xn,clearSaveConflict:rt,saveDraft:xr,saveNow:$t}=Rc({autoSaveEnabled:At,selectedPath:p?.path??null,loadedPath:et,fileLoading:on,isDirty:Lt,draftContent:dt,fileContent:Ce,lineEnding:ns,isNonEditableBinary:!!(p?.path&&(An(p.path)||Qn)),writeFile:o.writeFile,expectedRevision:pr,onSaved:dr,captureSaveScope:fn,currentSaveScope:fr,onConflict:r=>{mr(r)}}),{confirmOpen:vr,discardAndTakeIntent:br,keepModalOpen:Ws,requestNavigation:Vt,saveAndTakeIntent:wr}=wc({isDirty:Lt,saveDraft:xr});s.useEffect(()=>{const r=h=>{Zo(h)&&(h.key.toLowerCase()==="s"?(h.preventDefault(),$t()):h.key.toLowerCase()==="f"&&(h.preventDefault(),W(!0)))};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[$t]);const yr=s.useCallback(async r=>{const h=De.current+1;De.current=h;const M=we,D=l,re=()=>{if(!l||M!==we||D!==l)return!1;const ie=Ee.getState().byRoot[l],Je=ie?.selectedPath??ie?.openPaths[0]??null;return De.current===h&&Je===r.path};ve(null),He(""),Ne(null),Se(void 0),Re(null),Ie(null),Me(!1),rt(),ln(!1),x&&O(!0);const Z=Ir(r.path),Ve={allowOutsideWorkspace:e==="editor-only"&&!!l&&!Sn(r.path,l),outsideFileGrant:Z};let Ae=!1;lt(!0);let Oe;await bc(r.path,u.isDesktop,ie=>Ot(ie,Ve).then(Je=>(Oe=Je.revision,Je.content))).then(ie=>{if(re()){if(ie.kind!=="text"){if(Pe(""),Fe(""),ie.kind==="desktop-image"){Ae=!0;return}ie.kind==="binary"&&ln(ie.detectedFromContent),Ne(r.path);return}rs(ie.lineEnding),Pe(ie.content),pn(ie.content),Fe(ie.draft),Ne(r.path),Se(Oe),Re({runtimeKey:M,root:D,path:r.path,generation:h}),mt(r.path,Ve).then(Je=>{Je&&re()&&tt(Je)}).catch(()=>{})}}).catch(ie=>{if(re()){if(zi(ie)){if(lt(!1),l&&Y(l,null),ve(null),Pe(""),Fe(""),Ne(null),Se(void 0),Re(null),tt(null),H.trim().length>0&&K(""),x&&O(!1),l){const jn=[...Kr(r.path,l),r.path];jn.length>0&&fe(l,jn);for(const Dr of jn)it(Dr)||ct(Dr)}return}if(_r(ie)){l&&B(l,r.path),Pe(""),Fe(""),ve(null),Se(void 0),Re(null),tt(null),x&&O(!1);return}Pe(""),Fe(""),ve(ie instanceof Error?ie.message:"Failed to read file"),Se(void 0),Re(null),tt(null)}}).finally(()=>{re()&&!Ae&<(!1)})},[we,rt,fe,it,x,ct,e,Ot,mt,pn,tt,B,l,u.isDesktop,H,Y]),Wt=s.useCallback(async(r,h)=>{if(!l||!V)return;const M=Kr(r,l),D=h?[...M,r]:M;D.length>0&&fe(l,D);const re=D.map(Z=>{if(!it(Z))return ct(Z)}).filter(Boolean);await Promise.all(re)},[fe,it,ct,V,l]),kr=s.useCallback((r,h)=>{const M=h.findIndex(D=>D.path===r);return M===-1||h.length<=1?null:h[M+1]??h[M-1]??null},[]),$e=s.useCallback(async r=>{Vt({kind:"select",file:r})||(l&&(Y(l,r.path),Wt(r.path,!1)),ve(null),He(""),Pe(""),hr(),Fe(""),Ne(null),Se(void 0),Re(null),Ie(null),Me(!1),rt(),x&&O(!0))},[hr,rt,Wt,x,Vt,l,Y]),_s=s.useCallback(r=>{$e(qe(r))},[$e,qe]),Ks=s.useCallback(r=>{const h=se(r);h&&(K(""),$(h),O(!1))},[]),qs=s.useCallback(r=>{const h=se(r);h&&(O(!0),$e(qe(h)))},[$e,qe]),Hs=s.useCallback(async()=>{if(!(!k||E)){R(!0);try{await Mt(k)}finally{R(!1)}}},[k,E,Mt]),Gs=s.useCallback(()=>{const r=me;if(r){if(!r.exists){l&&Ke(l,r.path),wt(),Ie(null),Me(!1),rt();return}Fe(""),Ne(null),Se(void 0),Re(null),Ie(null),Me(!1),rt()}},[rt,wt,Ke,l,me]),Us=s.useCallback(async()=>{if(!(!me||cn)){Xn(!0);try{(me.diagramXml!==null?await hn(me.path,me.diagramXml,{overwrite:!0}):await $t({overwrite:!0}))&&(Ie(null),Me(!1))}finally{Xn(!1)}}},[cn,me,hn,$t]),Js=s.useCallback(()=>{Ie(null),Me(!1)},[]);s.useEffect(()=>{!p?.path||!V||!i||Wt(p.path,!1)},[Wt,i,V,p?.path]),s.useEffect(()=>{if(!p){De.current+=1,ft.current=null,lt(!1);return}if(et===p.path||ft.current===p.path)return;const r=p.path;ft.current=r,yr(p).finally(()=>{ft.current===r&&(ft.current=null)})},[yr,et,p]);const pt=s.useCallback(async r=>{if(r.kind==="select"){await $e(r.file);return}if(r.kind==="tab"){ke.getState().setActiveMainTab(r.tab);return}l&&Ke(l,r.path),p?.path===r.path&&(r.nextFile?await $e(r.nextFile):wt())},[wt,$e,Ke,l,p?.path]),Xs=s.useCallback(()=>{const r=br();Fe(dn),r&&pt(r)},[pt,br,dn]),Ys=s.useCallback(async()=>{const r=await wr();r&&await pt(r)},[pt,wr]),Qs=s.useCallback(r=>{const h=p?.path===r,M={kind:"close",path:r,nextFile:kr(r,Dt)};h&&Vt(M)||pt(M)},[pt,kr,Dt,Vt,p?.path]),_t=s.useMemo(()=>Wc({root:l,openPaths:ne,gitFiles:_?.files}),[l,ne,_]),Zs=s.useCallback(r=>_t.getFileStatus(r),[_t]),eo=s.useCallback(r=>_t.getFolderBadge(r),[_t]),to=s.useCallback(async r=>{const h=se(r);!l||!V||(ee(l,h),it(h)||await ct(h))},[it,ct,V,l,ee]),no=s.useMemo(()=>({canRename:tr,canCreateFile:Zn,canCreateFolder:er,canDelete:nr,canReveal:rr}),[tr,Zn,er,nr,rr]),Te=!!(p?.path&&Da(p.path)),ht=!!(p?.path&&Ta(p.path)),at=!!(p?.path&&Aa(p.path)),vn=!!(p?.path&&(An(p.path)||Qn)),Kt=vn&&!Te&&!at,gt=s.useMemo(()=>Rt(l,Be),[Be,l]),ro=!!(p&&(!Te||ht)&&!at&&!Kt&&Ce.length>0),ao=!!(p&>.length>0),yt=!!(p&&!Tt&&!vn&&!Te&&o.writeFile&&Ce.length<=Ft),kt=!!(p?.path&&qa(p.path)),bn=!!(p?.path&&Ka(p.path)),jt=!!(p?.path&&Wn(p.path)),jr=!!(p?.path&&tn(p.path)),so=!!(p&&!vn&&!Te),{editorViewRef:ye,notifyEditorViewChanged:qt,shouldMaskEditor:oo}=kc({root:l,selectedPath:Be||null,loadedPath:et,fileLoading:on,fileError:Un,isImage:Te,isPdf:at,isUnsupportedBinary:Kt,canEdit:yt,textViewMode:nt,setTextViewMode:gn,draftContent:dt,confirmDiscardOpen:vr,selectFilePath:_s}),Cr=so&&!kt&&!jr&&!(jt&&Pt==="preview"),io=kt&&Bt==="edit"||jt&&Pt==="edit"||bn&&It==="text"||!kt&&!jt&&!bn&&nt==="edit",Ht=s.useMemo(()=>Be?Wi(Be):null,[Be]),[Nr,wn]=s.useState(null);s.useEffect(()=>{let r=!1;const h=p?.path;if(!h||Ht){wn(null);return}return wn(null),_i(h).then(M=>{r||wn(M)}),()=>{r=!0}},[p?.path,Ht]),s.useEffect(()=>{!yt&&nt==="edit"&&gn("view")},[yt,gn,nt]);const Ue=s.useCallback(r=>{if(!x||!r||!r.hasFocus||typeof window>"u")return;const h=window.visualViewport;if(!h)return;const M=document.documentElement.clientHeight||window.innerHeight;if(Math.max(0,M-(h.offsetTop+h.height))<=0)return;const re=r.state.selection.main.head,Z=r.coordsAtPos(re);if(!Z)return;const Ve=Math.round(h.offsetTop+h.height),Oe=Z.bottom+20-Ve;Oe<=0||(r.scrollDOM.scrollTop+=Oe)},[x]);s.useEffect(()=>{if(!x||typeof window>"u")return;const r=()=>{window.requestAnimationFrame(()=>{Ue(ye.current)})},h=window.visualViewport;return h?.addEventListener("resize",r),h?.addEventListener("scroll",r,{passive:!0}),document.addEventListener("selectionchange",r),()=>{h?.removeEventListener("resize",r),h?.removeEventListener("scroll",r),document.removeEventListener("selectionchange",r)}},[ye,x,Ue]);const Gt=ke(r=>r.editorFontSize),co=s.useMemo(()=>{if(!p?.path)return[Ur(f,{fontSize:Gt})];const r=Ma(p.path),h=[Ur(f,r?{syntaxColors:!1,fontSize:Gt}:{fontSize:Gt})],M=Ht??Nr;return M&&h.push(M),r&&h.push(Qi({language:r,themeName:f.metadata.id,theme:fi(f)})),z&&h.push(pe.lineWrapping),x&&h.push(pe.updateListener.of(D=>{D.view.hasFocus&&(D.selectionSet||D.focusChanged||D.viewportChanged||D.geometryChanged)&&window.requestAnimationFrame(()=>{Ue(D.view)})})),h},[f,p?.path,Ht,Nr,z,x,Ue,Gt]),lo=s.useMemo(()=>({light:Le.metadata.id,dark:xe.metadata.id}),[Le.metadata.id,xe.metadata.id]),Ut=p?.path&&Te&&!u.isDesktop&&!ht?`${p.path}|${le.allowOutsideWorkspace?"outside":"workspace"}|${le.outsideFileGrant??""}`:"",Jt=p?.path&&at?`${p.path}|${le.allowOutsideWorkspace?"outside":"workspace"}|${le.outsideFileGrant??""}`:"",Ct=p?.path&&jt&&Pt==="preview"?p.path:"",yn="Failed to read file",{readyKey:Sr,nonce:uo}=Rn(Ut,ve,yn),{readyKey:Rr,nonce:fo}=Rn(Ct,ve,yn),{readyKey:Fr,nonce:mo}=Rn(Jt,ve,yn),po=!!(Ut&&Sr!==Ut),ho=!!(Ct&&Rr!==Ct),go=!!(Jt&&Fr!==Jt),xo=p?.path&&Te?u.isDesktop?ht?`data:${$r(p.path)};utf8,${encodeURIComponent(Ce)}`:es:ht?`data:${$r(p.path)};utf8,${encodeURIComponent(Ce)}`:Sr===Ut?Nn().authenticatedAsset("/api/fs/raw",{path:p.path,allowOutsideWorkspace:le.allowOutsideWorkspace?"true":void 0,outsideFileGrant:le.outsideFileGrant,directory:l||void 0}):"":"",vo=p?.path&&at&&Fr===Jt?Nn().authenticatedAsset("/api/fs/raw",{path:p.path,allowOutsideWorkspace:le.allowOutsideWorkspace?"true":void 0,outsideFileGrant:le.outsideFileGrant,directory:l||void 0}):"",bo=Ct&&Rr===Ct&&p?.path?(()=>{const r=p.path.split("/").map(h=>encodeURIComponent(h)).join("/");return Nn().authenticatedAsset(`/api/fs/serve${r.startsWith("/")?r:`/${r}`}`)})():void 0;s.useEffect(()=>{let r=!1;return(async()=>{if(!u.isDesktop||!p?.path||!Te||ht){be.current&&(URL.revokeObjectURL(be.current),be.current=""),He("");return}ve(null),be.current&&(URL.revokeObjectURL(be.current),be.current=""),await(o.readFileBinary?o.readFileBinary(p.path,le).then(D=>D.dataUrl):(async()=>{const D=await Lr("/api/fs/raw",{query:{path:p.path,allowOutsideWorkspace:le.allowOutsideWorkspace?"true":void 0,outsideFileGrant:le.outsideFileGrant,directory:l||void 0}});if(!D.ok)throw new Error("Failed to read file");const re=await D.blob(),Z=URL.createObjectURL(re);return r?(URL.revokeObjectURL(Z),""):(be.current=Z,Z)})()).then(D=>{r||(He(D),Ne(p.path))}).catch(D=>{be.current&&(URL.revokeObjectURL(be.current),be.current=""),r||(He(""),ve(D instanceof Error?D.message:"Failed to read file"),Ne(null))}).finally(()=>{r||lt(!1)})})(),()=>{r=!0}},[o,Te,ht,l,u.isDesktop,p?.path,le]),s.useEffect(()=>()=>{be.current&&(URL.revokeObjectURL(be.current),be.current="")},[]);const Er=s.useCallback(()=>{const r=o.downloadFile,h=p?.path;!r||!h||r(h).catch(M=>{console.error("Download failed:",M),he.error("Operation failed")})},[o.downloadFile,p?.path]),kn=({exitFullscreenOnly:r=!1,layout:h="floating"}={})=>t.jsx(Bc,{selectedFile:p,displaySelectedPath:gt,layout:h,exitFullscreenOnly:r,canEdit:yt,isEditingFile:io,isSaving:xn,autoSaveEnabled:At,autoSaveStatus:Vs,isDirty:Lt,onSaveDraft:xr,onToggleAutoSave:()=>as(!At),canOpenInDesktopApp:un,openInApps:Ns,openInCacheStale:Ss,onOpenInApp:Es,onRefreshOpenInApps:()=>Rs(!0),onToolbarDropdownOpenChange:Ze,isSelectedImage:Te,isSelectedPdf:at,isUnsupportedBinary:Kt,wrapLines:z,onToggleWrapLines:()=>U(!z),textViewMode:nt,onToggleSearch:()=>W(!oe),isGoToLineOpen:ps,onOpenGoToLineChange:hs,editorView:ye.current,canUseShikiFileView:Cr,isJson:bn,isHtml:jt,onToggleTextViewMode:()=>{$s(nt==="view"?"edit":"view")},isMarkdown:kt,mdViewMode:Ge(),onToggleMdViewMode:()=>gr(Ge()==="preview"?"edit":"preview"),isDrawio:jr,drawioViewMode:mn,onToggleDrawioViewMode:()=>Is(mn==="preview"?"edit":"preview"),diagramSaved:Os,onSaveDiagram:async()=>{const M=Yn.current?.getXml();p?.path&&M&&await hn(p.path,M)},jsonViewMode:It,onToggleJsonViewMode:()=>Bs(It==="tree"?"text":"tree"),canCopy:ro,copiedContent:us,onCopyContent:async()=>{(await Zt(Ce)).ok?ds(!0):he.error("Copy failed")},canCopyPath:ao,copiedPath:fs,onCopyPath:async()=>{(await Zt(gt)).ok?ms(!0):he.error("Copy failed")},onDownloadFile:o.downloadFile&&p?Er:void 0,isMobile:x,mode:e,isFullscreen:Q,onToggleFullscreen:()=>ae(!Q),onExitFullscreen:()=>ae(!1)}),wo=s.useCallback(r=>{ye.current=r,qt(),window.requestAnimationFrame(()=>{Ue(r)})},[ye,qt,Ue]),yo=s.useCallback(()=>{ye.current&&(ye.current=null),qt()},[ye,qt]),ko=s.useCallback(r=>{ye.current=r,window.requestAnimationFrame(()=>{Ue(r)})},[ye,Ue]),jo=s.useCallback(()=>{ye.current&&(ye.current=null)},[ye]),zr={selectedFile:p,loading:on||po||go,suppressLoadingIndicator:T,fileError:Un,isSelectedImage:Te,imageSrc:xo,imagePreviewNonce:uo,isSelectedPdf:at,pdfSrc:vo,pdfPreviewNonce:mo,isUnsupportedBinary:Kt,onDownload:o.downloadFile&&p?Er:void 0,drawioViewMode:mn,drawioRemountNonce:Ls,diagramEditorRef:Yn,diagramEditorXml:As,onDiagramChange:Ps,jsonViewMode:It,markdownViewMode:Bt,htmlViewMode:Pt,htmlLoading:ho,htmlPreviewNonce:fo,htmlPreviewSrc:bo,fileContent:Ce,canUseShikiFileView:Cr,textViewMode:nt,draftContent:dt,onDraftChange:Fe,canEdit:yt,vimMode:zs==="vim",editorExtensions:co,shouldMaskEditorForPendingNavigation:oo,pierreTheme:lo,shikiThemeType:f.metadata.variant==="dark"?"dark":"light",wrapLines:z},Xt=t.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden",children:[t.jsx($c,{open:vr,onOpenChange:Ws,isSaving:xn,onSaveAndContinue:()=>{Ys()},onDiscardAndContinue:Xs}),t.jsx(hi,{open:!!me,conflict:me?{path:me.path,displayPath:me.displayPath,exists:me.exists,currentRevision:me.currentRevision,currentContent:me.currentContent,dirtyContent:me.diagramXml??dt}:null,isResolving:cn||xn,showCompare:ts,onToggleCompare:()=>Me(r=>!r),onReload:Gs,onOverwrite:()=>{Us()},onClose:Js}),t.jsxs("div",{className:J("flex flex-col flex-shrink-0",G&&"border-b border-border/40"),children:[t.jsx(Lc,{showEditorTabsRow:G,isMobile:x,showMobilePageContent:L,onBackMobile:()=>O(!1),selectedFile:p,openFiles:Dt,root:l,alwaysShowActions:v,editorTabsOverflow:Qa,editorTabsScrollRef:sn,onSelectFile:$e,onCloseFile:Qs}),(sr||x)&&p?t.jsxs("div",{className:"flex min-w-0 items-center gap-3 border-t border-border/40 bg-[var(--surface-subtle)] px-3 py-1",children:[gt&&!x?t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta text-muted-foreground",title:gt,children:gt}):null,t.jsx("div",{className:"ml-auto min-w-0 shrink-0 overflow-x-auto",children:kn({layout:"docked"})})]}):null]}),t.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[p&&!oe&&!(sr||x)&&t.jsx("div",{ref:ze,className:"absolute right-3 top-3 z-30",onMouseLeave:()=>{ue.current>0||je(!1)},children:te?kn():t.jsxs("div",{className:"flex items-center gap-1",children:[kt?t.jsxs(Xe,{children:[t.jsx(Ye,{asChild:!0,children:t.jsx("span",{className:"inline-flex",children:t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>gr(Ge()==="preview"?"edit":"preview"),className:J("size-8 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-0 shadow-sm transition-colors",Ge()==="preview"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)]":"text-muted-foreground hover:text-foreground"),"aria-label":Ge()==="preview"?"Switch to edit mode":"Switch to preview mode",title:Ge()==="preview"?"Switch to edit mode":"Switch to preview mode",children:t.jsx(F,{name:Ge()==="preview"?"eye":"eye-off",className:"size-4"})})})}),t.jsx(Qe,{side:"bottom",sideOffset:6,children:Ge()==="preview"?"Switch to edit mode":"Switch to preview mode"})]}):null,t.jsxs(Xe,{children:[t.jsx(Ye,{asChild:!0,children:t.jsx("span",{className:"inline-flex",onMouseEnter:()=>je(!0),children:t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>je(!0),className:"size-8 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-0 text-muted-foreground shadow-sm hover:text-foreground","aria-label":"Show editor controls",title:"Editor controls",children:t.jsx(F,{name:"more-2-fill",className:"size-4"})})})}),t.jsx(Qe,{side:"bottom",sideOffset:6,children:"Editor controls"})]})]})}),t.jsx(da,{variant:"embedded",...zr,enableRichPreviews:!0,editorWrapperRef:ss,onEditorViewReady:wo,onEditorViewDestroy:yo,enableSearch:!0,searchOpen:oe,onSearchOpenChange:W})]})]}),Mr=t.jsx(Kc,{root:l,isMobile:x,searchQuery:H,onSearchQueryChange:K,searchInputRef:X,searching:lr,searchResults:cr,selectedFile:p,onSelectFile:$e,onOpenDialog:ks,currentDirectory:I,refreshRoot:Ya,childrenByDir:_n,loadErrorsByDir:Kn,expandedPaths:ot,isBrowserClient:C,alwaysShowActions:v,getFileStatus:Zs,getFolderBadge:eo,fileRowPermissions:no,downloadFile:o.downloadFile,contextMenuPath:os,setContextMenuPath:is,rightClickMenuPath:cs,setRightClickMenuPath:ls,toggleDirectory:to,handleRevealPath:Fs,refreshDirectory:Mt}),Co=e==="full"&&Q&&p&&t.jsx("div",{className:"absolute inset-0 z-50 flex flex-col bg-background",children:t.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[t.jsx("div",{className:"absolute right-4 top-4 z-30",children:kn({exitFullscreenOnly:!0})}),t.jsx(da,{variant:"fullscreen",...zr,enableRichPreviews:!1,onEditorViewReady:ko,onEditorViewDestroy:jo})]})});return d?t.jsx(nc,{root:l,directory:k||l,entries:k||l?_n[k||l]:void 0,query:H,searchResults:cr,isSearching:lr,directoryError:k||l?Kn[k||l]??null:null,refreshing:E,editorPath:L?p?.path??null:null,editor:Xt,onClose:a,onQueryChange:K,onOpenDirectory:Ks,onOpenFile:qs,onBackFromEditor:()=>O(!1),onRefresh:()=>{Hs()}}):t.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden bg-background relative",children:[t.jsx(ac,{activeDialog:gs,dialogData:xs,dialogInputValue:vs,onDialogInputChange:bs,isDialogSubmitting:ws,onDialogSubmit:Cs,onClose:js,inputRef:ys}),Co,x?L?Xt:Mr:e==="editor-only"?t.jsx("div",{className:"flex flex-1 min-h-0 min-w-0 overflow-hidden",children:t.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden bg-background",children:Xt})}):t.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0 gap-3 px-3 pb-3 pt-2",children:[j>=700&&t.jsx("div",{className:"w-72 flex-shrink-0 min-h-0 overflow-hidden",children:Mr}),t.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden rounded-xl border border-border/60 bg-background",children:Xt})]})]})};export{iu as FilesView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./vendor-boot-CoTxysn6.js";import{R as u}from"./vendor-react-Bz1tRBxM.js";import{I as o,B as l,at as f}from"./useAppFontEffects-D2xXdmYC.js";import{f as m}from"./index-C2ISrmRR.js";import{R as b,S as g}from"./GitHubDetailScaffold-B2HRjT8V.js";const G=({options:r,value:s,onChange:t,ariaLabel:a})=>e.jsx("div",{role:"tablist","aria-label":a,className:"flex flex-wrap gap-1",children:r.map(i=>{const n=i.id===s;return e.jsx(l,{type:"button",variant:"chip",size:"xs",role:"tab","aria-selected":n,"aria-pressed":n,onClick:()=>t(i.id),className:m(n&&"bg-interactive-selection text-interactive-selection-foreground"),children:i.label},i.id)})}),S=({value:r,onChange:s,placeholder:t,ariaLabel:a})=>{const[i,n]=u.useState(r);u.useEffect(()=>n(r),[r]);const c=u.useRef(s);return c.current=s,u.useEffect(()=>{if(i===r)return;const d=setTimeout(()=>c.current(i),80);return()=>clearTimeout(d)},[i,r]),e.jsxs("span",{className:"relative block min-w-0 flex-1",children:[e.jsx(o,{name:"search","aria-hidden":"true",className:"pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx(f,{value:i,onChange:d=>n(d.target.value),placeholder:t??"Search","aria-label":a??"Search",className:"h-8 pl-7"})]})},H=({rows:r=7,label:s})=>{const t=["w-3/5","w-2/5","w-1/2","w-2/3","w-2/5","w-3/5","w-1/2"],a=["w-2/5","w-1/3","w-2/5","w-1/4","w-1/3","w-2/5","w-1/3"];return e.jsx("div",{role:"status","aria-label":s,className:"flex animate-pulse flex-col p-1",children:Array.from({length:r},(i,n)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-md px-2 py-2",children:[e.jsx("span",{"aria-hidden":"true",className:"size-4 shrink-0 rounded-full bg-muted-foreground/15"}),e.jsxs("span",{className:"min-w-0 flex-1 space-y-1.5",children:[e.jsx("span",{"aria-hidden":"true",className:m("block h-3.5 rounded bg-muted-foreground/15",t[n%t.length])}),e.jsx("span",{"aria-hidden":"true",className:m("block h-3 rounded bg-muted-foreground/15",a[n%a.length])})]}),e.jsxs("span",{className:"flex shrink-0 flex-col items-end gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",className:"block h-3 w-12 rounded bg-muted-foreground/15"}),e.jsx("span",{"aria-hidden":"true",className:"block h-3 w-10 rounded bg-muted-foreground/15"})]})]},n))})},p=({icon:r,title:s,description:t,action:a})=>e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-1.5 p-6 text-center",children:[e.jsx(o,{name:r,"aria-hidden":"true",className:"size-6 text-muted-foreground/60"}),e.jsx("p",{className:"typography-ui-label font-medium text-foreground",children:s}),t?e.jsx("p",{className:"max-w-60 typography-micro text-muted-foreground",children:t}):null,a]}),j=({hasMore:r,isLoading:s,onLoadMore:t,label:a})=>r?e.jsx("div",{className:"flex justify-center px-2 py-2",children:e.jsx(l,{type:"button",variant:"outline",size:"sm",onClick:t,disabled:s,children:s?"Loading…":a??"Load more"})}):null,z=({summary:r,summaryTitle:s})=>e.jsx("footer",{className:"flex shrink-0 items-center justify-between border-t border-border/60 px-2 py-1.5 typography-micro text-muted-foreground",children:e.jsx("span",{className:"min-w-0 truncate",title:s??r,children:r})}),C=({matchSummary:r,searching:s,onSearchAll:t})=>e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 border-t border-border/60 px-2 py-1.5 typography-micro text-muted-foreground",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",title:r,children:r}),e.jsx(l,{type:"button",variant:"ghost",size:"xs",onClick:t,disabled:s,children:s?"Searching…":"Search all on GitHub"})]}),R=({title:r,isSearching:s,error:t,hasResults:a,hasMore:i,isLoadingMore:n,onRetry:c,onLoadMore:d,children:h})=>{const x=t?.kind==="rate-limited"?"GitHub rate limit reached — try again in a little while.":"Couldn't search GitHub.";return e.jsxs("section",{"aria-label":r,className:"border-t border-border/60",children:[e.jsx("p",{className:"px-3 pb-0.5 pt-1.5 typography-micro font-medium text-muted-foreground",children:r}),t&&!a?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-3 py-2 typography-micro text-muted-foreground",children:[e.jsx(o,{name:"error-warning",className:"size-3.5 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1",children:x}),e.jsx(l,{type:"button",variant:"outline",size:"xs",onClick:c,children:"Retry"})]}):null,t&&a?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-3 py-1 typography-micro text-muted-foreground",children:[e.jsx("span",{className:"min-w-0 flex-1",children:x}),e.jsx(l,{type:"button",variant:"ghost",size:"xs",onClick:c,children:"Retry"})]}):null,!t&&s&&!a?e.jsx("p",{className:"px-3 py-2 typography-micro text-muted-foreground",role:"status",children:"Searching GitHub…"}):null,a?e.jsx("div",{className:"flex flex-col p-1 pt-0.5",children:h}):null,!t&&a?e.jsx(j,{hasMore:i,isLoading:n,onLoadMore:d,label:"Load more results"}):null]})},E=({error:r,onRetry:s,label:t})=>{if(!b(r))return null;const a=g(r);return e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-3 py-2 typography-micro text-foreground",role:"alert","aria-label":`${t} failed to load`,children:[e.jsx(o,{name:"error-warning",className:"size-4 shrink-0 text-[var(--status-error)]"}),e.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[t," failed to load",r?` — ${a}`:""]}),e.jsx(l,{type:"button",variant:"outline",size:"xs",onClick:s,children:"Retry"})]})},L=({number:r,kindLabel:s,onOpen:t})=>e.jsx("div",{className:"flex flex-col p-1",children:e.jsxs("button",{type:"button",onClick:t,"aria-label":`Open ${s} #${r}`,className:"group/github-row flex w-full items-center gap-2 rounded-md px-2 py-1 text-left hover:bg-interactive-hover",children:[e.jsx("span",{className:"inline-flex w-4 shrink-0 items-center justify-center",children:e.jsx(o,{name:"external-link",className:"size-3.5 text-muted-foreground","aria-hidden":"true"})}),e.jsxs("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:["Open #",r]}),e.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:"Not in the loaded list"})]})}),I=({onRetry:r})=>e.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-[var(--status-warning-border)] bg-[var(--status-warning-background)] px-3 py-1.5 typography-micro text-foreground",children:[e.jsx(o,{name:"error-warning",className:"size-3.5 shrink-0 text-[var(--status-warning)]"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:"Showing saved results — last refresh failed"}),e.jsx("button",{type:"button",onClick:r,className:"shrink-0 underline","aria-label":"Retry GitHub refresh",children:"Retry"})]}),T=({kind:r,noItemsTitle:s,noItemsBody:t,noItemsIcon:a,noItemsAction:i,onClearFilters:n})=>r==="no-match"?e.jsx(p,{icon:"search",title:"Nothing matches these filters",description:"Try fewer words, or search by number, author, or label.",action:n?e.jsx(l,{type:"button",variant:"outline",size:"sm",onClick:n,children:"Clear filters"}):void 0}):e.jsx(p,{icon:a??"git-pull-request",title:s,description:t,action:i});export{H as G,E as S,p as a,I as b,S as c,T as d,L as e,j as f,R as g,C as h,z as i,G as j};
|