@tencent-ai/codebuddy-code 2.134.0-dev.c172de2.202608121546 → 2.135.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/dist/codebuddy-headless.js +118 -118
- package/dist/codebuddy.js +80 -80
- package/dist/web-ui/assets/{CanvasPaneStandaloneView-DgMTB0Mb.js → CanvasPaneStandaloneView-DeJD7bJv.js} +1 -1
- package/dist/web-ui/assets/{CanvasView-3QngUA7x.js → CanvasView-V2DzC5ig.js} +1 -1
- package/dist/web-ui/assets/{DocsView-BoczVSee.js → DocsView-BwjfIgJw.js} +1 -1
- package/dist/web-ui/assets/EditorView-DEmkNiHo.js +95 -0
- package/dist/web-ui/assets/{KeybindingsView-BiwRw-4R.js → KeybindingsView-CLga9s1T.js} +1 -1
- package/dist/web-ui/assets/{LogsView-B8XmcVTr.js → LogsView-Bd11aAMW.js} +2 -2
- package/dist/web-ui/assets/{MetricsView-lzImG0av.js → MetricsView-Byap1DzP.js} +4 -4
- package/dist/web-ui/assets/{RemoteControlView-Bv4Ym4nD.js → RemoteControlView-BqiUehl-.js} +4 -4
- package/dist/web-ui/assets/StatsView-Cr230NV8.js +12 -0
- package/dist/web-ui/assets/{TracesView-kF2Bi6Uu.js → TracesView-bKA1QIAI.js} +3 -3
- package/dist/web-ui/assets/{WorkersView-VzjZfrZu.js → WorkersView-DY0kEifB.js} +4 -4
- package/dist/web-ui/assets/{canvas-store-CX4TeurF.js → canvas-store-hkRzwbw-.js} +1 -1
- package/dist/web-ui/assets/{cssMode-CEfvy9LI.js → cssMode-DVvwMwN6.js} +1 -1
- package/dist/web-ui/assets/{editor.main-BeJ0HdEs.js → editor.main-vO8swxPL.js} +3 -3
- package/dist/web-ui/assets/{freemarker2-DnkFzY6t.js → freemarker2-BY-2-rq2.js} +1 -1
- package/dist/web-ui/assets/{handlebars-1NAOMqYh.js → handlebars-D_vy9gpm.js} +1 -1
- package/dist/web-ui/assets/{html-BP0ejrFF.js → html-GglpzIxT.js} +1 -1
- package/dist/web-ui/assets/{htmlMode-Djp_2npQ.js → htmlMode-DUBQpmgz.js} +1 -1
- package/dist/web-ui/assets/index-C74qhjeJ.css +32 -0
- package/dist/web-ui/assets/{index-DNUXcSh8.js → index-DC-fErwI.js} +216 -216
- package/dist/web-ui/assets/{javascript-J-jeSPRJ.js → javascript-C9og_HZL.js} +1 -1
- package/dist/web-ui/assets/{jsonMode-DwxnBMDi.js → jsonMode-Cs25xE2e.js} +1 -1
- package/dist/web-ui/assets/{liquid-p7dNfV0Z.js → liquid-BQ5j4ocH.js} +1 -1
- package/dist/web-ui/assets/{lspLanguageFeatures-DEpBaaQs.js → lspLanguageFeatures-k6vDy77A.js} +1 -1
- package/dist/web-ui/assets/{mdx-QX-6YS-2.js → mdx-BnZXGp9g.js} +1 -1
- package/dist/web-ui/assets/{minus-CjhfXa84.js → minus-CND1LKfM.js} +1 -1
- package/dist/web-ui/assets/{python-DXTI7QZI.js → python-B65aRwBG.js} +1 -1
- package/dist/web-ui/assets/{razor-BwsYliyu.js → razor-OgH9GFyd.js} +1 -1
- package/dist/web-ui/assets/{server-DTGjlz_2.js → server-C_x9ee7t.js} +1 -1
- package/dist/web-ui/assets/{tsMode-CAro1DF_.js → tsMode-DQdvo31S.js} +1 -1
- package/dist/web-ui/assets/{typescript-MzPA2Aci.js → typescript-B4pz8IUO.js} +1 -1
- package/dist/web-ui/assets/{worker-store-CeRgJcBb.js → worker-store-CC1BvZFl.js} +1 -1
- package/dist/web-ui/assets/{xml-_dZXiOu_.js → xml-BWp6ggOb.js} +1 -1
- package/dist/web-ui/assets/{yaml-BrzS0hUR.js → yaml-26TypAAl.js} +1 -1
- package/dist/web-ui/index.html +21 -5
- package/dist/web-ui/sw.js +1 -1
- package/package.json +2 -3
- package/product.cloudhosted.json +2 -2
- package/product.internal.json +2 -2
- package/product.ioa.json +2 -2
- package/product.json +2 -2
- package/product.selfhosted.json +2 -2
- package/vendor/shim/brokered-bin/codebuddy-toybox-dispatch +32 -0
- package/dist/web-ui/assets/EditorView-BUsQ-90n.js +0 -90
- package/dist/web-ui/assets/StatsView-BWPSIETb.js +0 -12
- package/dist/web-ui/assets/index-Bcw4ajER.css +0 -32
package/dist/web-ui/sw.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
if(!self.define){let s,l={};const e=(e,i)=>(e=new URL(e+".js",i).href,l[e]||new Promise(l=>{if("document"in self){const s=document.createElement("script");s.src=e,s.onload=l,document.head.appendChild(s)}else s=e,importScripts(e),l()}).then(()=>{let s=l[e];if(!s)throw new Error(`Module ${e} didn’t register its module`);return s}));self.define=(i,r)=>{const n=s||("document"in self?document.currentScript.src:"")||location.href;if(l[n])return;let u={};const o=s=>e(s,n),t={module:{uri:n},exports:u,require:o};l[n]=Promise.all(i.map(s=>t[s]||o(s))).then(s=>(r(...s),u))}}define(["./workbox-fed2bdfe"],function(s){"use strict";self.skipWaiting(),s.clientsClaim(),s.precacheAndRoute([{url:"sandbox_proxy.html",revision:"e54bd087bf8b90d87d84c3cd8f2c22e9"},{url:"pwa-icon.svg",revision:"673adddf1548f59682764258005b6034"},{url:"logo.svg",revision:"269aa921a3f446f8e17843c89ed7bf35"},{url:"index.html",revision:"
|
|
1
|
+
if(!self.define){let s,l={};const e=(e,i)=>(e=new URL(e+".js",i).href,l[e]||new Promise(l=>{if("document"in self){const s=document.createElement("script");s.src=e,s.onload=l,document.head.appendChild(s)}else s=e,importScripts(e),l()}).then(()=>{let s=l[e];if(!s)throw new Error(`Module ${e} didn’t register its module`);return s}));self.define=(i,r)=>{const n=s||("document"in self?document.currentScript.src:"")||location.href;if(l[n])return;let u={};const o=s=>e(s,n),t={module:{uri:n},exports:u,require:o};l[n]=Promise.all(i.map(s=>t[s]||o(s))).then(s=>(r(...s),u))}}define(["./workbox-fed2bdfe"],function(s){"use strict";self.skipWaiting(),s.clientsClaim(),s.precacheAndRoute([{url:"sandbox_proxy.html",revision:"e54bd087bf8b90d87d84c3cd8f2c22e9"},{url:"pwa-icon.svg",revision:"673adddf1548f59682764258005b6034"},{url:"logo.svg",revision:"269aa921a3f446f8e17843c89ed7bf35"},{url:"index.html",revision:"9c44a1551760fde47ac195434b607561"},{url:"assets/yaml-26TypAAl.js",revision:null},{url:"assets/xml-BWp6ggOb.js",revision:null},{url:"assets/worker-store-CC1BvZFl.js",revision:null},{url:"assets/workbox-window.prod.es5-BBnX5xw4.js",revision:null},{url:"assets/wgsl-BTesnYfV.js",revision:null},{url:"assets/vendor-D35k0Cos.js",revision:null},{url:"assets/vb-Db0cS2oM.js",revision:null},{url:"assets/typespec-Btyra-wh.js",revision:null},{url:"assets/typescript-B4pz8IUO.js",revision:null},{url:"assets/twig-Csy3S7wG.js",revision:null},{url:"assets/tsMode-DQdvo31S.js",revision:null},{url:"assets/tcl-Dm6ycUr_.js",revision:null},{url:"assets/systemverilog-Bs9z6M-B.js",revision:null},{url:"assets/swift-Bqt4WxQ4.js",revision:null},{url:"assets/st-CHwy0fLd.js",revision:null},{url:"assets/sql-ClhHkBeG.js",revision:null},{url:"assets/sparql-CJmd_6j2.js",revision:null},{url:"assets/sophia-CnS9iZB_.js",revision:null},{url:"assets/solidity-Db0IVjzk.js",revision:null},{url:"assets/shell-DiJ1NA_G.js",revision:null},{url:"assets/server-C_x9ee7t.js",revision:null},{url:"assets/scss-CBJaRo0y.js",revision:null},{url:"assets/scheme-BPhDTwHR.js",revision:null},{url:"assets/scala-D9hQfWCl.js",revision:null},{url:"assets/sb-BBc9UKZt.js",revision:null},{url:"assets/rust-BzKRNQWT.js",revision:null},{url:"assets/ruby-zBfavPgS.js",revision:null},{url:"assets/restructuredtext-CqXO7rUv.js",revision:null},{url:"assets/redshift-Bs9aos_-.js",revision:null},{url:"assets/redis-Bu5POkcn.js",revision:null},{url:"assets/razor-OgH9GFyd.js",revision:null},{url:"assets/r-j7ic8hl3.js",revision:null},{url:"assets/qsharp-Bw9ernYp.js",revision:null},{url:"assets/python-B65aRwBG.js",revision:null},{url:"assets/pug-8SOpv6rk.js",revision:null},{url:"assets/protobuf-Brw8urJB.js",revision:null},{url:"assets/powershell-COWaemsV.js",revision:null},{url:"assets/powerquery-tScXyioY.js",revision:null},{url:"assets/postiats-CocnycG-.js",revision:null},{url:"assets/pla-DSh2-awV.js",revision:null},{url:"assets/php-BBUBE1dy.js",revision:null},{url:"assets/pgsql-BlNEE0v7.js",revision:null},{url:"assets/perl-Ub6l9XKa.js",revision:null},{url:"assets/pascaligo-DtZ0uQbO.js",revision:null},{url:"assets/pascal-vHIfCaH5.js",revision:null},{url:"assets/octicons-CaZ_fok2.woff2",revision:null},{url:"assets/objective-c-BDtDVThU.js",revision:null},{url:"assets/mysql-C_tMU-Nz.js",revision:null},{url:"assets/msdax-DmeGPVcC.js",revision:null},{url:"assets/mips-CiqrrVzr.js",revision:null},{url:"assets/minus-CND1LKfM.js",revision:null},{url:"assets/mfixx-CpAhKOZz.woff2",revision:null},{url:"assets/mdx-BnZXGp9g.js",revision:null},{url:"assets/markdown-DIY6o85n.js",revision:null},{url:"assets/markdown-BFxVWTOG.js",revision:null},{url:"assets/m3-B8OfTtLu.js",revision:null},{url:"assets/lua-Cyyb5UIc.js",revision:null},{url:"assets/lspLanguageFeatures-k6vDy77A.js",revision:null},{url:"assets/liquid-BQ5j4ocH.js",revision:null},{url:"assets/lexon-OrD6JF1K.js",revision:null},{url:"assets/less-9HpZscsL.js",revision:null},{url:"assets/kotlin-s7OhZKlX.js",revision:null},{url:"assets/julia-cl7-CwDS.js",revision:null},{url:"assets/jsonMode-Cs25xE2e.js",revision:null},{url:"assets/javascript-C9og_HZL.js",revision:null},{url:"assets/java-CXBNlu9o.js",revision:null},{url:"assets/ini-Kd9XrMLS.js",revision:null},{url:"assets/index-DixJ0kqk.js",revision:null},{url:"assets/index-DC-fErwI.js",revision:null},{url:"assets/index-C74qhjeJ.css",revision:null},{url:"assets/htmlMode-DUBQpmgz.js",revision:null},{url:"assets/html-GglpzIxT.js",revision:null},{url:"assets/hcl-DtV1sZF8.js",revision:null},{url:"assets/handlebars-D_vy9gpm.js",revision:null},{url:"assets/graphql-BxJiqAUM.js",revision:null},{url:"assets/go-acbASCJo.js",revision:null},{url:"assets/fsharp-PahG7c26.js",revision:null},{url:"assets/freemarker2-BY-2-rq2.js",revision:null},{url:"assets/fontawesome-B-jkhYfk.woff2",revision:null},{url:"assets/flow9-BeJ5waoc.js",revision:null},{url:"assets/file-icons-C0jOugUK.woff2",revision:null},{url:"assets/elixir-BkW5O-1t.js",revision:null},{url:"assets/editor-B_19GPAS.css",revision:null},{url:"assets/ecl-BEgZUVRK.js",revision:null},{url:"assets/dockerfile-BG73LgW2.js",revision:null},{url:"assets/devopicons-QN4QXivI.woff2",revision:null},{url:"assets/dart-BOtBlQCF.js",revision:null},{url:"assets/cypher-cTPe9QuQ.js",revision:null},{url:"assets/cssMode-DVvwMwN6.js",revision:null},{url:"assets/css-DdJfP1eB.js",revision:null},{url:"assets/csp-D-4FJmMZ.js",revision:null},{url:"assets/csharp-Co3qMtFm.js",revision:null},{url:"assets/cpp-BbWJElDN.js",revision:null},{url:"assets/coffee-Bd8akH9Z.js",revision:null},{url:"assets/clojure-Dnu-v4kV.js",revision:null},{url:"assets/canvas-store-hkRzwbw-.js",revision:null},{url:"assets/cameligo-Bf6VGUru.js",revision:null},{url:"assets/bicep-CFznDFnq.js",revision:null},{url:"assets/bat-BwHxbl9M.js",revision:null},{url:"assets/azcli-Y6nb8tq_.js",revision:null},{url:"assets/apex-DNDY2TF8.js",revision:null},{url:"assets/abap-DLDM7-KI.js",revision:null},{url:"assets/WorkersView-DY0kEifB.js",revision:null},{url:"assets/TracesView-bKA1QIAI.js",revision:null},{url:"assets/StatsView-Cr230NV8.js",revision:null},{url:"assets/RemoteControlView-BqiUehl-.js",revision:null},{url:"assets/MetricsView-Byap1DzP.js",revision:null},{url:"assets/LogsView-Bd11aAMW.js",revision:null},{url:"assets/KeybindingsView-CLga9s1T.js",revision:null},{url:"assets/EditorView-DEmkNiHo.js",revision:null},{url:"assets/DocsView-BwjfIgJw.js",revision:null},{url:"assets/CanvasView-V2DzC5ig.js",revision:null},{url:"assets/CanvasPaneStandaloneView-DeJD7bJv.js",revision:null},{url:"logo.svg",revision:"269aa921a3f446f8e17843c89ed7bf35"},{url:"pwa-icon.svg",revision:"673adddf1548f59682764258005b6034"},{url:"manifest.webmanifest",revision:"7a003d0094122eb3e607566c757e9885"}],{}),s.cleanupOutdatedCaches(),s.registerRoute(new s.NavigationRoute(s.createHandlerBoundToURL("/index.html"),{denylist:[/^\/api/,/^\/gateway/,/^\/docs\//]})),s.registerRoute(/^https:\/\/fonts\.googleapis\.com/,new s.StaleWhileRevalidate({cacheName:"google-fonts-stylesheets",plugins:[]}),"GET"),s.registerRoute(/^https:\/\/fonts\.gstatic\.com/,new s.CacheFirst({cacheName:"google-fonts-webfonts",plugins:[new s.ExpirationPlugin({maxEntries:20,maxAgeSeconds:31536e3})]}),"GET")});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tencent-ai/codebuddy-code",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.135.0",
|
|
4
4
|
"description": "Use CodeBuddy, Tencent's AI assistant, right from your terminal. CodeBuddy can understand your codebase, edit files, run terminal commands, and handle entire workflows for you.",
|
|
5
5
|
"main": "lib/node/index.js",
|
|
6
6
|
"typings": "lib/node/index.d.ts",
|
|
@@ -43,8 +43,7 @@
|
|
|
43
43
|
"url": "https://cnb.cool/codebuddy/codebuddy-code/-/issues"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
|
-
"access": "public"
|
|
47
|
-
"tag": "dev"
|
|
46
|
+
"access": "public"
|
|
48
47
|
},
|
|
49
48
|
"scripts": {},
|
|
50
49
|
"devDependencies": {}
|
package/product.cloudhosted.json
CHANGED
|
@@ -812,6 +812,6 @@
|
|
|
812
812
|
"SelectImage": true,
|
|
813
813
|
"SkipToolCallSupportCheck": true
|
|
814
814
|
},
|
|
815
|
-
"commit": "
|
|
816
|
-
"date": "2026-08-
|
|
815
|
+
"commit": "ea5459981b09e2a5721020d6b4c4c7b4f2205db1",
|
|
816
|
+
"date": "2026-08-12T12:58:58.723Z"
|
|
817
817
|
}
|
package/product.internal.json
CHANGED
package/product.ioa.json
CHANGED
package/product.json
CHANGED
|
@@ -1812,6 +1812,6 @@
|
|
|
1812
1812
|
"description": "tool-repl-description"
|
|
1813
1813
|
}
|
|
1814
1814
|
],
|
|
1815
|
-
"commit": "
|
|
1816
|
-
"date": "2026-08-
|
|
1815
|
+
"commit": "ea5459981b09e2a5721020d6b4c4c7b4f2205db1",
|
|
1816
|
+
"date": "2026-08-12T12:58:58.730Z"
|
|
1817
1817
|
}
|
package/product.selfhosted.json
CHANGED
|
@@ -349,6 +349,6 @@
|
|
|
349
349
|
"ScheduledTasks": true,
|
|
350
350
|
"SkipToolCallSupportCheck": true
|
|
351
351
|
},
|
|
352
|
-
"commit": "
|
|
353
|
-
"date": "2026-08-
|
|
352
|
+
"commit": "ea5459981b09e2a5721020d6b4c4c7b4f2205db1",
|
|
353
|
+
"date": "2026-08-12T12:58:58.723Z"
|
|
354
354
|
}
|
|
@@ -9,6 +9,38 @@ __cb_cleanup() { /bin/rm -f "$__cb_err" 2>/dev/null || true; }
|
|
|
9
9
|
|
|
10
10
|
__cb_should_fallback() { case "$1" in *"Unknown command "*|*"Unknown option "*|*"unknown option "*|*"unrecognized option "*) return 0 ;; *) return 1 ;; esac; }
|
|
11
11
|
|
|
12
|
+
__cb_check_program_policy() {
|
|
13
|
+
[ -n "${CODEBUDDY_SANDBOX_PROGRAM_POLICY_COMMAND:-}" ] || return 0
|
|
14
|
+
if [ -z "${CODEBUDDY_SANDBOX_BROKER_IPC_ADDRESS:-}" ] \
|
|
15
|
+
|| [ -z "${CODEBUDDY_SANDBOX_BROKER_SESSION_ID:-}" ] \
|
|
16
|
+
|| [ ! -f "$__cb_broker_client" ]; then
|
|
17
|
+
printf '%s' 'Brokered program policy check unavailable' >&2
|
|
18
|
+
return 13
|
|
19
|
+
fi
|
|
20
|
+
|
|
21
|
+
NODE_OPTIONS= "${CODEBUDDY_NODE_BIN:-node}" - "$__cb_broker_client" "$1" <<'NODE'
|
|
22
|
+
const { sendBrokerRequestSync } = require(process.argv[2]);
|
|
23
|
+
const program = process.argv[3];
|
|
24
|
+
const response = sendBrokerRequestSync({
|
|
25
|
+
command: process.env.CODEBUDDY_SANDBOX_PROGRAM_POLICY_COMMAND,
|
|
26
|
+
program,
|
|
27
|
+
sessionId: process.env.CODEBUDDY_SANDBOX_BROKER_SESSION_ID,
|
|
28
|
+
toolCallId: process.env.CODEBUDDY_SANDBOX_BROKER_TOOL_CALL_ID,
|
|
29
|
+
brokerTraceId: process.env.CODEBUDDY_SANDBOX_BROKER_TRACE_ID,
|
|
30
|
+
runtime: 'toybox-dispatch',
|
|
31
|
+
});
|
|
32
|
+
if (response && response.ok === true && response.decision === 'allow') {
|
|
33
|
+
process.exit(0);
|
|
34
|
+
}
|
|
35
|
+
process.stderr.write(response && response.error ? response.error : `Brokered program policy denied "${program}"`);
|
|
36
|
+
process.exit(response && response.reason === 'forbidden_program' ? 126 : 13);
|
|
37
|
+
NODE
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
__cb_check_program_policy "$__cb_app"
|
|
41
|
+
__cb_program_policy_status=$?
|
|
42
|
+
[ "$__cb_program_policy_status" -eq 0 ] || exit "$__cb_program_policy_status"
|
|
43
|
+
|
|
12
44
|
__cb_path_without_brokered_dir() {
|
|
13
45
|
__cb_old_ifs="$IFS"
|
|
14
46
|
IFS=:; __cb_new_path=
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DNUXcSh8.js","assets/markdown-DIY6o85n.js","assets/vendor-D35k0Cos.js","assets/index-Bcw4ajER.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{c as J,u as Q,i as ot,s as qt,L as pe,t as X,v as Kt,w as Ve,x as Ut,h as Re,e as dt,y as Ye,_ as Ie,z as Gt,A as Qt,G as Ce,B as Xt,P as xe,D as ht,H as Yt,I as ke,J as oe,K as Jt,X as ut,n as Z,N as Zt,O as es,Q as mt,d as ft,R as ts,j as ss,o as as,k as ns,p as is,g as pt,U as rs,m as se,V as cs,W as De,Y as ls,Z as Y,$ as os,a as ds,M as hs,T as us,a0 as xt,a1 as ms,a2 as Je,l as qe,a3 as fs,a4 as ps,a5 as gt,a6 as Ke,C as xs,E as bt,a7 as gs,a8 as bs,a9 as js,aa as vs,S as ys,ab as ks,ac as Cs,ad as ws,ae as Ns,af as Ss,ag as Ms}from"./index-DNUXcSh8.js";import{a as i,j as e,M as Ps,c as Ds}from"./markdown-DIY6o85n.js";import{M as Le}from"./minus-CjhfXa84.js";import"./vendor-D35k0Cos.js";/**
|
|
3
|
-
* @license lucide-react v1.18.0 - ISC
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the ISC license.
|
|
6
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/const zs=[["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M22 9v7",key:"pvm9v3"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}],["circle",{cx:"18.5",cy:"12.5",r:"3.5",key:"z97x68"}]],Es=J("case-sensitive",zs);/**
|
|
8
|
-
* @license lucide-react v1.18.0 - ISC
|
|
9
|
-
*
|
|
10
|
-
* This source code is licensed under the ISC license.
|
|
11
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
-
*/const Ts=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Rs=J("chevron-left",Ts);/**
|
|
13
|
-
* @license lucide-react v1.18.0 - ISC
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the ISC license.
|
|
16
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/const Ls=[["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],$s=J("copy-minus",Ls);/**
|
|
18
|
-
* @license lucide-react v1.18.0 - ISC
|
|
19
|
-
*
|
|
20
|
-
* This source code is licensed under the ISC license.
|
|
21
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
-
*/const _s=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Fs=J("eye-off",_s);/**
|
|
23
|
-
* @license lucide-react v1.18.0 - ISC
|
|
24
|
-
*
|
|
25
|
-
* This source code is licensed under the ISC license.
|
|
26
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
27
|
-
*/const As=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Is=J("eye",As);/**
|
|
28
|
-
* @license lucide-react v1.18.0 - ISC
|
|
29
|
-
*
|
|
30
|
-
* This source code is licensed under the ISC license.
|
|
31
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
32
|
-
*/const Os=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]],Bs=J("file-plus",Os);/**
|
|
33
|
-
* @license lucide-react v1.18.0 - ISC
|
|
34
|
-
*
|
|
35
|
-
* This source code is licensed under the ISC license.
|
|
36
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
37
|
-
*/const Ws=[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]],jt=J("files",Ws);/**
|
|
38
|
-
* @license lucide-react v1.18.0 - ISC
|
|
39
|
-
*
|
|
40
|
-
* This source code is licensed under the ISC license.
|
|
41
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
42
|
-
*/const Hs=[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3-3-3 3",key:"e37ymu"}],["path",{d:"m15 5-3 3-3-3",key:"19d6lf"}]],Vs=J("fold-vertical",Hs);/**
|
|
43
|
-
* @license lucide-react v1.18.0 - ISC
|
|
44
|
-
*
|
|
45
|
-
* This source code is licensed under the ISC license.
|
|
46
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
47
|
-
*/const qs=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Ks=J("folder-plus",qs);/**
|
|
48
|
-
* @license lucide-react v1.18.0 - ISC
|
|
49
|
-
*
|
|
50
|
-
* This source code is licensed under the ISC license.
|
|
51
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
52
|
-
*/const Us=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],Gs=J("house",Us);/**
|
|
53
|
-
* @license lucide-react v1.18.0 - ISC
|
|
54
|
-
*
|
|
55
|
-
* This source code is licensed under the ISC license.
|
|
56
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
57
|
-
*/const Qs=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],vt=J("list",Qs);/**
|
|
58
|
-
* @license lucide-react v1.18.0 - ISC
|
|
59
|
-
*
|
|
60
|
-
* This source code is licensed under the ISC license.
|
|
61
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
62
|
-
*/const Xs=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}]],Ys=J("panel-bottom",Xs);/**
|
|
63
|
-
* @license lucide-react v1.18.0 - ISC
|
|
64
|
-
*
|
|
65
|
-
* This source code is licensed under the ISC license.
|
|
66
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
67
|
-
*/const Js=[["path",{d:"M17 3v10",key:"15fgeh"}],["path",{d:"m12.67 5.5 8.66 5",key:"1gpheq"}],["path",{d:"m12.67 10.5 8.66-5",key:"1dkfa6"}],["path",{d:"M9 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-2z",key:"swwfx4"}]],Zs=J("regex",Js);/**
|
|
68
|
-
* @license lucide-react v1.18.0 - ISC
|
|
69
|
-
*
|
|
70
|
-
* This source code is licensed under the ISC license.
|
|
71
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
72
|
-
*/const ea=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]],ta=J("scan",ea);/**
|
|
73
|
-
* @license lucide-react v1.18.0 - ISC
|
|
74
|
-
*
|
|
75
|
-
* This source code is licensed under the ISC license.
|
|
76
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
77
|
-
*/const sa=[["path",{d:"m17 14 3 3.3a1 1 0 0 1-.7 1.7H4.7a1 1 0 0 1-.7-1.7L7 14h-.3a1 1 0 0 1-.7-1.7L9 9h-.2A1 1 0 0 1 8 7.3L12 3l4 4.3a1 1 0 0 1-.8 1.7H15l3 3.3a1 1 0 0 1-.7 1.7H17Z",key:"cpyugq"}],["path",{d:"M12 22v-3",key:"kmzjlo"}]],yt=J("tree-pine",sa);/**
|
|
78
|
-
* @license lucide-react v1.18.0 - ISC
|
|
79
|
-
*
|
|
80
|
-
* This source code is licensed under the ISC license.
|
|
81
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
82
|
-
*/const aa=[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m15 5-3-3-3 3",key:"itvq4r"}]],na=J("unfold-vertical",aa);/**
|
|
83
|
-
* @license lucide-react v1.18.0 - ISC
|
|
84
|
-
*
|
|
85
|
-
* This source code is licensed under the ISC license.
|
|
86
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
87
|
-
*/const ia=[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}],["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]],ra=J("whole-word",ia);function Ze(t,s){const n=X.getState().pendingReveal;if(!n||n.path!==s)return!1;X.getState().setPendingReveal(null);const{line:a,col:r,query:c}=n,l=t.getModel();if(!l)return!1;const o=r&&r>0?r:1;if(t.revealLineInCenter(a),t.setPosition({lineNumber:a,column:o}),t.focus(),c){const d=l.findMatches(c,!1,!1,!1,null,!0);if(d.length>0){const m=d.find(u=>u.range.startLineNumber>=a)||d[0];t.setSelection(m.range),t.revealRangeInCenter(m.range);const x=d.map(u=>({range:u.range,options:{className:"search-find-match",overviewRuler:{color:"#d7ba7d",position:1}}})),y=t.deltaDecorations([],x);setTimeout(()=>{try{t.deltaDecorations(y,[])}catch{}},5e3)}}return!0}function kt({path:t,content:s,language:n,onContentChange:a,onSave:r,minimap:c=!0,onCursorChange:l}){const{t:o}=Q(),{resolved:d}=ot(),m=i.useRef(null),x=i.useRef(l);x.current=l;const y=d==="dark"?"cbc-dark":"cbc-light",[u,C]=i.useState(!1);i.useEffect(()=>{let f=!1;return qt().then(()=>{f||C(!0)}),()=>{f=!0}},[]);const k=e.jsxs("div",{className:"flex items-center justify-center h-full gap-2",style:{color:"var(--color-text-tertiary)"},children:[e.jsx(pe,{size:16,className:"animate-spin"}),e.jsx("span",{style:{fontSize:13},children:o("editor.loading")})]}),L=i.useCallback((f,j)=>{m.current=f,j.editor.defineTheme("cbc-dark",{base:"vs-dark",inherit:!0,rules:[],colors:{"editor.background":"#121314"}}),j.editor.defineTheme("cbc-light",{base:"vs",inherit:!0,rules:[],colors:{"editor.background":"#ffffff"}}),j.editor.setTheme(y),f.addCommand(j.KeyMod.CtrlCmd|j.KeyCode.KeyS,()=>{r()});const w=()=>{const v=x.current;if(!v)return;const P=f.getPosition(),$=f.getSelection();if(!P)return;let _=0,F=0;if($&&!$.isEmpty()){const A=f.getModel();A&&(_=A.getValueInRange($).length,F=Math.abs($.endLineNumber-$.startLineNumber)+1)}v(P.lineNumber,P.column,_,F)};f.onDidChangeCursorPosition(w),f.onDidChangeCursorSelection(w),w()},[r]),M=i.useCallback(f=>{f!==void 0&&a(f)},[a]);i.useEffect(()=>{const f=m.current;if(!f)return;const j=f.getModel();j&&s.length>0&&j.getValue()!==s&&j.setValue(s)},[s]);const g=X(f=>f.pendingReveal);return i.useEffect(()=>{if(!g||g.path!==t)return;if(m.current){Ze(m.current,t);return}let f=0;const j=setInterval(()=>{f++,m.current?(Ze(m.current,t),clearInterval(j)):f>=50&&clearInterval(j)},50);return()=>clearInterval(j)},[t,g]),u?e.jsx(Kt,{height:"100%",language:n,theme:y,defaultValue:s,onChange:M,onMount:L,loading:k,options:{fontSize:13,fontFamily:"'Menlo', 'Monaco', 'Consolas', 'Courier New', monospace",lineHeight:20,minimap:{enabled:c,maxColumn:80},scrollBeyondLastLine:!1,automaticLayout:!0,wordWrap:"off",tabSize:4,insertSpaces:!0,renderWhitespace:"selection",bracketPairColorization:{enabled:!0},padding:{top:8},smoothScrolling:!0,cursorBlinking:"smooth",cursorSmoothCaretAnimation:"on",fixedOverflowWidgets:!0}},t):k}async function ee(t,s){var l;const n=Ve(),a={...s,...n?{cwd:n}:{}},r=await Ut(`/api/v1/git/${t}`,{method:"POST",headers:{...Re(),"Content-Type":"application/json"},body:JSON.stringify(a)});if(!r.ok){const o=await r.json().catch(()=>({error:{message:r.statusText}}));throw new Error(((l=o.error)==null?void 0:l.message)||`Git API error: ${r.status}`)}const c=await r.json();return c.data??c}async function ca(){return ee("status")}async function et(t){await ee("stage",{paths:t})}async function tt(t){await ee("unstage",{paths:t})}async function la(t){return ee("commit",{message:t})}async function Ct(t,s){return ee("diff",{path:t,staged:s})}async function $e(t,s){await ee("discard",{paths:t,useTrash:s})}async function oa(){return(await ee("branches")).branches}async function da(t){return ee("branch/switch",{name:t})}async function ha(t,s=!0){return ee("branch/create",{name:t,checkout:s})}async function ua(){return ee("push")}async function ma(){return ee("pull")}async function fa(t){return(await ee("log",{limit:t})).entries}const pa=1e3,xa=2e3,ga=3e3;let Me=null,Pe=null,ge=null,Ee=null,_e=!1,Fe=!1;async function ba(){try{const{authHeaders:t}=await Ie(async()=>{const{authHeaders:a}=await import("./index-DNUXcSh8.js").then(r=>r.aM);return{authHeaders:a}},__vite__mapDeps([0,1,2,3])),{fetchWithRetry:s}=await Ie(async()=>{const{fetchWithRetry:a}=await import("./index-DNUXcSh8.js").then(r=>r.aL);return{fetchWithRetry:a}},__vite__mapDeps([0,1,2,3])),n=await s("/api/v1/info",{headers:t()});if(n.ok){const a=await n.json();return(a.data??a).cwd||void 0}}catch{}}const ie=dt((t,s)=>({isGitRepo:!1,loading:!1,error:null,files:[],currentBranch:null,ahead:0,behind:0,remote:null,branches:[],branchesLoading:!1,selectedFile:null,selectedFileStaged:!1,diffResult:null,diffLoading:!1,commitMessage:"",committing:!1,pushing:!1,pulling:!1,lastOperationMessage:null,refresh:async()=>{if(_e)return;_e=!0,s().files.length===0&&!s().isGitRepo&&t({loading:!0,error:null});try{const a=await ca();t({isGitRepo:a.isGitRepo,files:a.files,currentBranch:a.branch,ahead:a.ahead,behind:a.behind,remote:a.remote,loading:!1})}catch(a){t({loading:!1,error:a.message})}finally{_e=!1}},loadBranches:async()=>{t({branchesLoading:!0});try{const n=await oa();t({branches:n,branchesLoading:!1})}catch{t({branchesLoading:!1})}},stageFile:async n=>{await et([n]),await s().refresh()},unstageFile:async n=>{await tt([n]),await s().refresh()},stageAll:async()=>{const n=s().files.filter(a=>!a.staged).map(a=>a.path);n.length>0&&(await et(n),await s().refresh())},unstageAll:async()=>{const n=s().files.filter(a=>a.staged).map(a=>a.path);n.length>0&&(await tt(n),await s().refresh())},discardFile:async n=>{await $e([n],!0),await s().refresh()},discardAll:async()=>{const n=s().files.filter(c=>!c.staged),a=n.filter(c=>c.status!=="untracked"),r=n.filter(c=>c.status==="untracked");a.length>0&&await $e(a.map(c=>c.path)),r.length>0&&await $e(r.map(c=>c.path),!0),await s().refresh()},commit:async()=>{const n=s().commitMessage.trim();if(n){t({committing:!0});try{const a=await la(n);t({committing:!1,commitMessage:"",lastOperationMessage:a.success?"Committed successfully":a.message}),await s().refresh()}catch(a){t({committing:!1,lastOperationMessage:a.message})}}},push:async()=>{t({pushing:!0});try{const n=await ua();t({pushing:!1,lastOperationMessage:n.success?"Pushed successfully":n.message}),await s().refresh()}catch(n){t({pushing:!1,lastOperationMessage:n.message})}},pull:async()=>{t({pulling:!0});try{const n=await ma();t({pulling:!1,lastOperationMessage:n.success?"Pulled successfully":n.message}),await s().refresh()}catch(n){t({pulling:!1,lastOperationMessage:n.message})}},switchBranch:async n=>{try{const a=await da(n);t({lastOperationMessage:a.success?`Switched to ${n}`:a.message}),await s().refresh()}catch(a){t({lastOperationMessage:a.message})}},createBranch:async n=>{try{const a=await ha(n);t({lastOperationMessage:a.success?`Created branch ${n}`:a.message}),await s().refresh(),await s().loadBranches()}catch(a){t({lastOperationMessage:a.message})}},selectFile:async(n,a)=>{if(s().selectedFile===n&&s().selectedFileStaged===a){t({selectedFile:null,diffResult:null,selectedFileStaged:!1});return}t({selectedFile:n,selectedFileStaged:a,diffLoading:!0,diffResult:null});try{const r=await Ct(n,a);t({diffResult:r,diffLoading:!1})}catch{t({diffLoading:!1})}},clearSelection:()=>t({selectedFile:null,diffResult:null,selectedFileStaged:!1}),setCommitMessage:n=>t({commitMessage:n}),clearOperationMessage:()=>t({lastOperationMessage:null}),startWatching:async()=>{if(Fe)return;let n=Ve();if(n||(n=await ba()),!n)return;Fe=!0;const a=c=>{ge&&clearTimeout(ge),ge=setTimeout(()=>{ge=null,s().refresh()},c)},r=new Set(["index","HEAD","FETCH_HEAD","ORIG_HEAD","refs"]);Me=Ye(`${n}/.git`,!1,c=>{var o;const l=(o=c.entry)==null?void 0:o.name;l&&r.has(l)&&a(pa)},()=>{Me=null}),Pe=Ye(n,!0,()=>{a(xa)},()=>{Pe=null}),Ee=setInterval(()=>{s().refresh()},ga)},stopWatching:async()=>{Fe=!1,Me&&(Me.close(),Me=null),Pe&&(Pe.close(),Pe=null),ge&&(clearTimeout(ge),ge=null),Ee&&(clearInterval(Ee),Ee=null)}}));Gt(async()=>{const t=ie.getState();await t.stopWatching(),t.refresh(),await t.startWatching()});function wt({currentBranch:t,branches:s,branchesLoading:n,onSwitch:a,onCreate:r,onLoadBranches:c,actions:l,defaultOpen:o,onClose:d}){const{t:m}=Q(),[x,y]=i.useState(o??!1),[u,C]=i.useState(""),[k,L]=i.useState(""),[M,g]=i.useState(0),[f,j]=i.useState(!1),w=i.useRef(null),v=i.useCallback(h=>{y(h),h||d==null||d()},[d]);i.useEffect(()=>{const h=setTimeout(()=>L(u),100);return()=>clearTimeout(h)},[u]),i.useEffect(()=>{x&&c()},[x,c]),i.useEffect(()=>{x?setTimeout(()=>{var h;return(h=w.current)==null?void 0:h.focus()},0):(C(""),L(""),g(0),j(!1))},[x]);const{localBranches:P,remoteBranches:$,flatList:_}=i.useMemo(()=>{let h;if(k){const q=[];for(const K of s){const B=Qt(k,K.name);B.match&&q.push({...K,_score:B.score})}q.sort((K,B)=>B._score-K._score),h=q}else h=s;const N=h.filter(q=>!q.isRemote),H=h.filter(q=>q.isRemote),U=[...N,...H];return{localBranches:N,remoteBranches:H,flatList:U}},[s,k]);i.useEffect(()=>{g(0)},[u]);const F=i.useCallback(h=>{h.key==="Escape"?v(!1):h.key==="ArrowDown"?(h.preventDefault(),g(N=>Math.min(N+1,_.length-1))):h.key==="ArrowUp"?(h.preventDefault(),g(N=>Math.max(N-1,0))):h.key==="Enter"&&(h.preventDefault(),f?u.trim()&&(r(u.trim()),v(!1)):_[M]?(a(_[M].name),v(!1)):u.trim()&&_.length===0&&(r(u.trim()),v(!1)))},[_,M,f,u,a,r]),A=i.useCallback(h=>{a(h),v(!1)},[a]),V=i.useCallback(()=>{j(!0),setTimeout(()=>{var h;return(h=w.current)==null?void 0:h.focus()},0)},[]),E=i.useCallback(()=>{u.trim()&&(r(u.trim()),v(!1))},[u,r]);return e.jsxs("div",{className:"branch-picker",children:[!o&&e.jsxs("div",{className:"branch-picker-header",children:[e.jsxs("button",{className:"branch-picker-trigger",onClick:()=>v(!x),title:t||"",children:[e.jsx(Ce,{size:14,className:"branch-picker-icon"}),e.jsx("span",{className:"branch-picker-name",children:t||"No branch"})]}),l]}),x&&Xt.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"branch-picker-backdrop",onClick:()=>v(!1)}),e.jsxs("div",{className:"branch-picker-dropdown",onKeyDown:F,onMouseDown:h=>h.stopPropagation(),onClick:h=>h.stopPropagation(),children:[e.jsx("div",{className:"branch-picker-search",children:e.jsx("input",{ref:w,className:"branch-picker-input",type:"text",value:u,onChange:h=>C(h.target.value),placeholder:f?m("ide.scm.newBranchPlaceholder")||"New branch name...":m("ide.scm.branchSearchPlaceholder")||"Select a branch or tag to checkout"})}),!f&&e.jsx("div",{className:"branch-picker-actions",children:e.jsxs("button",{className:"branch-picker-action",onClick:V,children:[e.jsx(xe,{size:14}),e.jsx("span",{children:m("ide.scm.createBranch")||"Create new branch..."})]})}),f&&e.jsx("div",{className:"branch-picker-actions",children:e.jsxs("button",{className:"branch-picker-action branch-picker-action-confirm",onClick:E,disabled:!u.trim(),children:[e.jsx(xe,{size:14}),e.jsx("span",{children:u.trim()?`Create branch "${u.trim()}"`:m("ide.scm.newBranchPlaceholder")||"Type branch name..."})]})}),_.length>0&&e.jsx(ja,{flatList:_,localCount:P.length,remoteCount:$.length,currentBranch:t,highlightIdx:M,onSelect:A,onHover:g}),n&&_.length===0&&e.jsx("div",{className:"branch-picker-empty",children:"Loading..."}),!n&&_.length===0&&!f&&e.jsx("div",{className:"branch-picker-empty",children:k?m("ide.scm.noBranchMatch")||"No matching branches":m("ide.scm.noBranchMatch")||"No branches found"})]})]}),document.body)]})}const be=40,Te=24;function ja({flatList:t,localCount:s,remoteCount:n,currentBranch:a,highlightIdx:r,onSelect:c,onHover:l}){const o=i.useRef(null),[d,m]=i.useState(0),[x,y]=i.useState(300);i.useEffect(()=>{const g=o.current;if(!g)return;const f=new ResizeObserver(j=>{for(const w of j)y(w.contentRect.height)});return f.observe(g),()=>f.disconnect()},[]),i.useEffect(()=>{const g=o.current;if(!g)return;const f=r*be;f<g.scrollTop?g.scrollTop=f:f+be>g.scrollTop+x&&(g.scrollTop=f+be-x)},[r,x]);const u=i.useCallback(g=>{m(g.target.scrollTop)},[]),C=t.length*be+(s>0&&n>0?Te:0)+(n>0?Te:0),k=Math.max(0,Math.floor(d/be)-2),L=Math.min(t.length,Math.ceil((d+x)/be)+2),M=[];s>0&&n>0&&k===0&&M.push(e.jsx("div",{className:"branch-picker-group-label",style:{height:Te},children:"branches"},"label-local"));for(let g=k;g<L;g++){const f=t[g];f&&(g===s&&n>0&&M.push(e.jsx("div",{className:"branch-picker-group-label",style:{height:Te},children:"remotes"},"label-remote")),M.push(e.jsx(va,{branch:f,isCurrent:f.name===a,isHighlighted:g===r,dataIdx:g,onSelect:c,onHover:()=>l(g)},f.name)))}return e.jsx("div",{ref:o,className:"branch-picker-list",onScroll:u,children:e.jsx("div",{style:{height:C,position:"relative"},children:e.jsx("div",{style:{position:"absolute",top:k*be,left:0,right:0},children:M})})})}function va({branch:t,isCurrent:s,isHighlighted:n,dataIdx:a,onSelect:r,onHover:c}){return e.jsxs("div",{className:`branch-picker-item ${n?"highlighted":""} ${s?"current":""}`,"data-idx":a,onClick:()=>r(t.name),onMouseEnter:c,title:t.lastCommitMessage?`${t.name}
|
|
88
|
-
${t.lastCommitAuthor} • ${t.lastCommitHash} • ${t.lastCommitMessage}`:t.name,children:[e.jsxs("div",{className:"branch-picker-item-main",children:[e.jsx(Ce,{size:14,className:"branch-picker-item-icon"}),e.jsx("span",{className:"branch-picker-item-name",children:t.name}),t.lastCommitDate&&e.jsx("span",{className:"branch-picker-item-date",children:t.lastCommitDate}),s&&e.jsx(ht,{size:14,className:"branch-picker-item-check"}),t.ahead||t.behind?e.jsxs("span",{className:"branch-picker-item-sync",children:[t.ahead?`↑${t.ahead}`:"",t.behind?`↓${t.behind}`:""]}):null]}),t.lastCommitMessage&&e.jsxs("div",{className:"branch-picker-item-detail",children:[e.jsx("span",{className:"branch-picker-item-author",children:t.lastCommitAuthor}),e.jsx("span",{className:"branch-picker-item-separator",children:"•"}),e.jsx("span",{className:"branch-picker-item-hash",children:t.lastCommitHash}),e.jsx("span",{className:"branch-picker-item-separator",children:"•"}),e.jsx("span",{className:"branch-picker-item-message",children:t.lastCommitMessage})]})]})}const st={image:"Image",svg:"SVG",markdown:"Markdown Preview",pdf:"PDF",binary:"Binary"};function Nt({language:t,cursorLine:s,cursorColumn:n,selectedCount:a,selectedLines:r,viewMode:c="editor",imageInfo:l,zoom:o,extraRight:d}){const{t:m}=Q();if(c==="image"||c==="svg")return e.jsxs("div",{className:"editor-statusbar",children:[e.jsxs("div",{className:"editor-statusbar-left",children:[e.jsx(Ae,{}),l&&e.jsxs("span",{className:"editor-statusbar-item",children:[l.width," × ",l.height]})]}),e.jsxs("div",{className:"editor-statusbar-right",children:[o!=null&&e.jsxs("span",{className:"editor-statusbar-item",children:[Math.round(o*100),"%"]}),e.jsx("span",{className:"editor-statusbar-item",children:st[c]}),d]})]});if(c!=="editor")return e.jsxs("div",{className:"editor-statusbar",children:[e.jsx("div",{className:"editor-statusbar-left",children:e.jsx(Ae,{})}),e.jsxs("div",{className:"editor-statusbar-right",children:[e.jsx("span",{className:"editor-statusbar-item",children:st[c]||c}),d]})]});const x=`Ln ${s}, Col ${n}`,y=a&&a>0?r&&r>1?` (${a} ${m("editor.selected")}, ${r} ${m("editor.lines")})`:` (${a} ${m("editor.selected")})`:"";return e.jsxs("div",{className:"editor-statusbar",children:[e.jsxs("div",{className:"editor-statusbar-left",children:[e.jsx(Ae,{}),e.jsxs("span",{className:"editor-statusbar-item",children:[x,y]})]}),e.jsxs("div",{className:"editor-statusbar-right",children:[e.jsx("span",{className:"editor-statusbar-item",children:t}),e.jsx("span",{className:"editor-statusbar-item",children:"UTF-8"}),e.jsx("span",{className:"editor-statusbar-item",children:"LF"}),e.jsx("span",{className:"editor-statusbar-item",children:"Spaces: 4"}),d]})]})}function Ae(){const{currentBranch:t,branches:s,branchesLoading:n,isGitRepo:a,switchBranch:r,createBranch:c,loadBranches:l,refresh:o}=ie(),[d,m]=i.useState(!1);i.useEffect(()=>{o()},[o]);const x=i.useCallback(u=>{r(u),m(!1)},[r]),y=i.useCallback(u=>{c(u),m(!1)},[c]);return a?e.jsxs("span",{className:"editor-statusbar-branch",onClick:u=>{u.stopPropagation(),m(C=>!C)},onPointerDown:u=>u.stopPropagation(),onMouseDown:u=>u.stopPropagation(),children:[e.jsx(Ce,{size:12}),e.jsx("span",{children:t||"No branch"}),d&&e.jsx(wt,{currentBranch:t,branches:s,branchesLoading:n,onSwitch:x,onCreate:y,onLoadBranches:l,defaultOpen:!0,onClose:()=>m(!1)})]}):null}function St({actions:t}={}){const{t:s}=Q(),{tabs:n,activeTabId:a,rootPath:r,setActiveTab:c,closeTab:l,closeOtherTabs:o,closeAllTabs:d,closeTabsToRight:m,closeSavedTabs:x,reorderTabs:y,pinTab:u,unpinTab:C}=X(),[k,L]=i.useState(null),M=i.useRef(null),[g,f]=i.useState(null),j=i.useRef(-1),w=i.useRef(null),[v,P]=i.useState(!1),[$,_]=i.useState(!1),F=i.useMemo(()=>Yt(n),[n]),A=i.useCallback(()=>{const p=w.current;p&&(P(p.scrollLeft>0),_(p.scrollLeft+p.clientWidth<p.scrollWidth-1))},[]);i.useEffect(()=>{const p=w.current;if(!p)return;A(),p.addEventListener("scroll",A,{passive:!0});const S=new ResizeObserver(A);return S.observe(p),()=>{p.removeEventListener("scroll",A),S.disconnect()}},[A,n.length]),i.useEffect(()=>{if(!a||!w.current)return;const S=w.current.querySelector(".editor-tab.active");S&&S.scrollIntoView({block:"nearest",inline:"nearest",behavior:"smooth"})},[a]);const V=i.useCallback(()=>{var p;(p=w.current)==null||p.scrollBy({left:-150,behavior:"smooth"})},[]),E=i.useCallback(()=>{var p;(p=w.current)==null||p.scrollBy({left:150,behavior:"smooth"})},[]),h=i.useCallback((p,S)=>{p.preventDefault(),L({x:p.clientX,y:p.clientY,tabId:S})},[]),N=i.useCallback(()=>{L(null)},[]),H=i.useCallback((p,S)=>{p.button===1&&(p.preventDefault(),l(S))},[l]),U=i.useCallback((p,S)=>{j.current=S,p.dataTransfer.effectAllowed="move",p.currentTarget instanceof HTMLElement&&p.dataTransfer.setDragImage(p.currentTarget,0,0)},[]),q=i.useCallback((p,S)=>{p.preventDefault(),p.dataTransfer.dropEffect="move",f(S)},[]),K=i.useCallback((p,S)=>{p.preventDefault();const b=j.current;b>=0&&b!==S&&y(b,S),j.current=-1,f(null)},[y]),B=i.useCallback(()=>{j.current=-1,f(null)},[]),T=i.useCallback(p=>{const S=n.find(b=>b.id===p);S&&ke(S.path),N()},[n,N]),D=i.useCallback(p=>{const S=n.find(b=>b.id===p);if(S&&r){const b=S.path.startsWith(r+"/")?S.path.slice(r.length+1):S.path;ke(b)}else S&&ke(S.path);N()},[n,r,N]),R=i.useCallback(p=>{const S=n.find(b=>b.id===p);if(S){const{selectPath:b,toggleExpand:W,expandedPaths:ae}=X.getState(),de=S.path.split("/");for(let he=1;he<de.length;he++){const je=de.slice(0,he).join("/");je&&!ae.has(je)&&W(je)}b(S.path)}N()},[n,N]);if(n.length===0)return null;const I=k?n.find(p=>p.id===k.tabId):null;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"editor-tabs-wrapper",children:[v&&e.jsx("button",{className:"editor-tabs-scroll-btn",onClick:V,children:e.jsx(Rs,{size:14})}),e.jsx("div",{className:"editor-tabs",ref:w,children:n.map((p,S)=>e.jsxs("div",{className:`editor-tab${p.id===a?" active":""}${g===S?" drag-indicator":""}`,onClick:()=>c(p.id),onMouseDown:b=>H(b,p.id),onContextMenu:b=>h(b,p.id),title:p.path,draggable:!0,onDragStart:b=>U(b,S),onDragOver:b=>q(b,S),onDrop:b=>K(b,S),onDragEnd:B,children:[e.jsx(oe,{name:p.name,type:"file",size:14}),e.jsx("span",{className:"editor-tab-name",children:p.name}),F.get(p.id)&&e.jsx("span",{className:"editor-tab-description",children:F.get(p.id)}),p.isPinned?p.isDirty?e.jsx("span",{className:"dirty-dot"}):e.jsx("span",{className:"pin-icon",children:e.jsx(Jt,{size:14})}):p.isDirty?e.jsx("span",{className:"dirty-dot"}):e.jsx("button",{className:"close-btn",onClick:b=>{b.stopPropagation(),l(p.id)},children:e.jsx(ut,{size:12})})]},p.id))}),$&&e.jsx("button",{className:"editor-tabs-scroll-btn",onClick:E,children:e.jsx(Z,{size:14})}),t&&e.jsx("div",{className:"editor-tabs-actions",children:t})]}),k&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"editor-context-overlay",onClick:N}),e.jsxs("div",{ref:M,className:"editor-context-menu",style:{left:k.x,top:k.y},children:[I!=null&&I.isPinned?e.jsx("button",{onClick:()=>{C(k.tabId),N()},children:s("editor.unpin")}):e.jsx("button",{onClick:()=>{u(k.tabId),N()},children:s("editor.pin")}),e.jsx("div",{className:"editor-context-separator"}),e.jsx("button",{onClick:()=>T(k.tabId),children:s("editor.copyPath")}),e.jsx("button",{onClick:()=>D(k.tabId),children:s("editor.copyRelativePath")}),e.jsx("button",{onClick:()=>R(k.tabId),children:s("editor.revealInExplorer")}),e.jsx("div",{className:"editor-context-separator"}),e.jsx("button",{onClick:()=>{l(k.tabId),N()},children:s("editor.close")}),e.jsx("button",{onClick:()=>{o(k.tabId),N()},children:s("editor.closeOthers")}),e.jsx("button",{onClick:()=>{m(k.tabId),N()},children:s("editor.closeToRight")}),e.jsx("button",{onClick:()=>{x(),N()},children:s("editor.closeSaved")}),e.jsx("button",{onClick:()=>{d(),N()},children:s("editor.closeAll")})]})]})]})}const ya=ss,Ue=ts;function at({path:t,onImageInfo:s,onZoomChange:n}){const{t:a}=Q(),r=i.useRef(null),c=i.useRef(null),[l,o]=i.useState("fit"),d=mt(Ue(t)),[m,x]=i.useState(null),[y,u]=i.useState(!1),[C,k]=i.useState({x:0,y:0}),L=i.useRef({x:0,y:0,tx:0,ty:0}),M=i.useCallback(()=>{if(!r.current||!m)return 1;const E=r.current.clientWidth-40,h=r.current.clientHeight-80;return E<=0||h<=0?1:Math.min(E/m.w,h/m.h,1)},[m]),g=l==="fit"?M():l,f=i.useCallback(()=>{const E=c.current;if(!E)return;const h=E.naturalWidth,N=E.naturalHeight;x({w:h,h:N}),s==null||s({width:h,height:N})},[s]);i.useEffect(()=>{n==null||n(g)},[g,n]);const j=i.useCallback(E=>{!E.ctrlKey&&!E.metaKey||(E.preventDefault(),o(h=>{const N=h==="fit"?M():h,H=E.deltaY<0?.1:-.1;return Math.min(5,Math.max(.1,N+H))}))},[M]),w=i.useCallback(E=>{l!=="fit"&&(E.preventDefault(),u(!0),L.current={x:E.clientX,y:E.clientY,tx:C.x,ty:C.y})},[l,C]),v=i.useCallback(E=>{if(!y)return;const h=E.clientX-L.current.x,N=E.clientY-L.current.y;k({x:L.current.tx+h,y:L.current.ty+N})},[y]),P=i.useCallback(()=>{u(!1)},[]),$=()=>o(E=>Math.min(5,(E==="fit"?M():E)+.1)),_=()=>o(E=>Math.max(.1,(E==="fit"?M():E)-.1)),F=()=>{o("fit"),k({x:0,y:0})},A=()=>{o(1),k({x:0,y:0})},V=g>=3;return e.jsxs("div",{ref:r,className:"file-preview-image-container checkerboard",onWheel:j,onMouseDown:w,onMouseMove:v,onMouseUp:P,onMouseLeave:P,style:{cursor:l!=="fit"?y?"grabbing":"grab":"default"},children:[d&&e.jsx("img",{ref:c,src:d,alt:t,onLoad:f,className:V?"pixelated":"",style:{transform:`translate(${C.x}px, ${C.y}px) scale(${g})`,transformOrigin:"center center",maxWidth:"none",maxHeight:"none",userSelect:"none",pointerEvents:"none"},draggable:!1}),e.jsxs("div",{className:"image-zoom-toolbar",children:[e.jsx("button",{onClick:_,title:a("filePreview.zoomOut"),children:e.jsx(Le,{size:16})}),e.jsxs("span",{className:"image-zoom-label",children:[Math.round(g*100),"%"]}),e.jsx("button",{onClick:$,title:a("filePreview.zoomIn"),children:e.jsx(xe,{size:16})}),e.jsx("button",{onClick:F,title:a("filePreview.fitToWindow"),children:e.jsx(ft,{size:16})}),e.jsx("button",{onClick:A,title:a("filePreview.actualSize"),children:e.jsx(ta,{size:16})})]})]})}function ka({className:t,children:s}){const n=ot(c=>c.resolved),a=(t||"").match(/language-(\w+)/),r=String(s).replace(/\n$/,"");return a?e.jsx("div",{className:"relative group my-3",children:e.jsx(ya,{style:n==="dark"?as:ns,language:a[1],PreTag:"div",customStyle:{margin:0,borderRadius:"8px",fontSize:"13px",lineHeight:"1.6"},codeTagProps:{style:{background:"transparent",textShadow:"none"}},children:r})}):e.jsx("code",{className:"bg-[var(--color-bg-tertiary)] px-1.5 py-0.5 rounded text-[13px]",children:s})}function Ca({content:t}){return e.jsx("div",{className:"file-preview-markdown",children:e.jsx("div",{className:"file-preview-markdown-content",children:e.jsx(Ps,{remarkPlugins:[Ds],components:{code:ka},children:t})})})}function wa({path:t}){const{t:s}=Q(),n=mt(Ue(t));return n?e.jsx("iframe",{src:n,className:"file-preview-pdf",title:s("filePreview.pdfPreview")}):null}function Na({path:t,name:s}){const{t:n}=Q(),a=i.useCallback(()=>{fetch(Ue(t),{headers:Re()}).then(r=>{if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.blob()}).then(r=>{const c=URL.createObjectURL(r),l=document.createElement("a");l.href=c,l.download=s,l.click(),URL.revokeObjectURL(c)}).catch(r=>{console.warn("[FilePreview] download failed:",String(r))})},[t,s]);return e.jsxs("div",{className:"file-preview-binary",children:[e.jsx(Zt,{size:48,className:"text-[var(--color-text-tertiary)]"}),e.jsx("div",{className:"mt-4 text-lg font-medium text-[var(--color-text-primary)]",children:s}),e.jsx("div",{className:"mt-2 text-sm text-[var(--color-text-secondary)]",children:n("filePreview.binaryNotSupported")}),e.jsxs("button",{onClick:a,className:"mt-4 inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-[var(--color-bg-tertiary)] text-[var(--color-text-primary)] hover:bg-[var(--color-bg-quaternary)] transition-colors text-sm",children:[e.jsx(es,{size:16}),n("filePreview.download")]})]})}function Mt({path:t,name:s,content:n,viewMode:a,onImageInfo:r,onZoomChange:c}){switch(a){case"image":return e.jsx(at,{path:t,onImageInfo:r,onZoomChange:c});case"svg":return e.jsx(at,{path:t,onImageInfo:r,onZoomChange:c});case"markdown":return e.jsx(Ca,{content:n});case"pdf":return e.jsx(wa,{path:t});case"binary":return e.jsx(Na,{path:t,name:s});default:return null}}function Sa(t,s=300){const[n,a]=i.useState(!1);return i.useEffect(()=>{if(!t){a(!1);return}const r=setTimeout(()=>a(!0),s);return()=>clearTimeout(r)},[t,s]),n}function Ma(t){switch(t){case"modified":return"M";case"added":return"A";case"untracked":return"U";case"deleted":return"D";case"conflicted":return"C";case"renamed":return"R";case"copied":return"C";default:return""}}function Pt({node:t,depth:s,isExpanded:n,isSelected:a,isMultiSelected:r,isRenaming:c,expandedPaths:l,selectedPath:o,selectedPaths:d,renamingPath:m,gitStatusMap:x,onToggleExpand:y,onSelect:u,onOpenFile:C,onConfirmRename:k,onCancelRename:L,onContextMenu:M,onDragStart:g,onDrop:f}){const j=t.type==="directory",w=12+s*12,v=x.get(t.path),P=X(b=>b.showHiddenFiles),$=Sa(!!t.isLoading),_=i.useMemo(()=>Dt(t.children,P),[t.children,P]),[F,A]=i.useState(t.name),V=i.useRef(null),[E,h]=i.useState(!1);i.useEffect(()=>{if(c&&V.current){A(t.name),V.current.focus();const b=t.name.lastIndexOf(".");!j&&b>0?V.current.setSelectionRange(0,b):V.current.select()}},[c,t.name,j]);const N=i.useCallback(b=>{c||(u(t.path,{ctrl:b.ctrlKey||b.metaKey,shift:b.shiftKey}),j?y(t.path):!b.ctrlKey&&!b.metaKey&&!b.shiftKey&&C(t.path,t.name))},[c,t.path,j,t.name,u,y,C]),H=i.useCallback(()=>{c||j||C(t.path,t.name)},[c,j,t.path,t.name,C]),U=i.useCallback(b=>{b.stopPropagation(),b.key==="Enter"?(b.preventDefault(),k(t.path,F)):b.key==="Escape"&&(b.preventDefault(),L())},[t.path,F,k,L]),q=i.useCallback(()=>{k(t.path,F)},[t.path,F,k]),K=i.useCallback(b=>{b.preventDefault(),M(b,t.path)},[M,t.path]),B=i.useCallback(b=>{const W=r?[...d]:[t.path];b.dataTransfer.effectAllowed="copyMove",b.dataTransfer.setData("text/plain",JSON.stringify(W)),b.dataTransfer.setData("application/x-file-paths",JSON.stringify(W)),g(W)},[r,d,t.path,g]),T=i.useCallback(b=>{j&&(b.preventDefault(),b.dataTransfer.dropEffect="move",h(!0))},[j]),D=i.useCallback(()=>{h(!1)},[]),R=i.useCallback(b=>{b.preventDefault(),h(!1),j&&f(t.path)},[j,t.path,f]),I=a||r,p=12,S=12;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`file-tree-item ${I?"selected":""} ${E?"drag-over":""}`,onClick:N,onDoubleClick:H,onContextMenu:K,draggable:!c,onDragStart:B,onDragOver:T,onDragLeave:D,onDrop:R,"data-path":t.path,title:t.path,children:[Array.from({length:s},(b,W)=>e.jsx("span",{className:"file-tree-indent-guide",style:{left:S+W*p+6}},W)),e.jsx("span",{style:{width:w,flexShrink:0}}),j?$?e.jsx(pe,{size:16,className:"file-tree-chevron animate-spin"}):e.jsx(Z,{size:16,className:`file-tree-chevron ${n?"expanded":""}`}):e.jsx(oe,{name:t.name,type:t.type,isExpanded:n,size:16}),c?e.jsx("input",{ref:V,className:"file-tree-rename-input",value:F,onChange:b=>A(b.target.value),onKeyDown:U,onBlur:q,onClick:b=>b.stopPropagation()}):e.jsx("span",{className:`file-tree-item-name${v?` git-status-${v}`:""}`,children:t.name}),v&&!j&&e.jsx("span",{className:`file-tree-git-badge git-status-${v}`,children:Ma(v)})]}),j&&n&&_.map(b=>e.jsx(Pt,{node:b,depth:s+1,isExpanded:l.has(b.path),isSelected:o===b.path,isMultiSelected:d.has(b.path),isRenaming:m===b.path,expandedPaths:l,selectedPath:o,selectedPaths:d,renamingPath:m,gitStatusMap:x,onToggleExpand:y,onSelect:u,onOpenFile:C,onConfirmRename:k,onCancelRename:L,onContextMenu:M,onDragStart:g,onDrop:f},b.path))]})}const Pa=new Set([".git","node_modules",".vscode",".idea",".DS_Store","Thumbs.db","__pycache__",".cache",".next",".nuxt",".svn",".hg",".pytest_cache",".mypy_cache",".tox",".eggs",".sass-cache"]);function Da(t){return t.startsWith(".")||Pa.has(t)}function Dt(t,s){return t?s?t:t.filter(n=>!Da(n.name)):[]}function zt(t){var Ge;const{t:s}=Q(),n=is(z=>z.info),{rootPath:a,tree:r,treeLoading:c,treeError:l,expandedPaths:o,selectedPath:d,selectedPaths:m,renamingPath:x,setRootPath:y,toggleExpand:u,selectPath:C,openFile:k,refreshTree:L,collapseAll:M,createNewFile:g,createNewFolder:f,startRename:j,startCreateFile:w,startCreateFolder:v,confirmRename:P,cancelRename:$,deleteSelected:_,moveToDirectory:F,showHiddenFiles:A,toggleShowHiddenFiles:V}=X(),E=ie(z=>z.files),h=i.useMemo(()=>{const z=new Map;if(!E.length||!a)return z;const O={conflicted:6,deleted:5,modified:4,renamed:3,added:2,copied:1,untracked:0};for(const G of E){const re=G.path.startsWith("/")?G.path:`${a}/${G.path}`;z.set(re,G.status);let ne=re.substring(0,re.lastIndexOf("/"));for(;ne&&ne.length>=a.length;){const Ne=z.get(ne);(!Ne||(O[G.status]??0)>(O[Ne]??0))&&z.set(ne,G.status),ne=ne.substring(0,ne.lastIndexOf("/"))}}return z},[E,a]),N=i.useMemo(()=>Dt(r==null?void 0:r.children,A),[r==null?void 0:r.children,A]),[H,U]=i.useState(!1),[q,K]=i.useState(!1),[B,T]=i.useState(!1),D=i.useRef(null),[R,I]=i.useState(null),p=i.useRef([]);i.useEffect(()=>{const z=pt().has("path");n!=null&&n.cwd&&!a&&!z?y(n.cwd):a&&!r&&!c&&!l&&y(a)},[n==null?void 0:n.cwd,a,r,c,l,y]);const S=i.useCallback(z=>{T(!1),y(z)},[y]),b=i.useCallback((z,O)=>{k(z,O)},[k]),W=i.useCallback((z,O)=>{P(z,O)},[P]),ae=i.useCallback((z,O)=>{z.preventDefault(),m.has(O)||C(O),I({x:z.clientX,y:z.clientY,path:O})},[m,C]),de=i.useCallback(()=>I(null),[]),he=i.useCallback(()=>{R&&(j(R.path),I(null))},[R,j]),je=i.useCallback(()=>{I(null),_()},[_]),ue=i.useCallback((z,O)=>{if(!z)return null;if(z.path===O)return z;if(z.children)for(const G of z.children){const re=ue(G,O);if(re)return re}return null},[]),ve=R?((Ge=ue(r,R.path))==null?void 0:Ge.type)==="directory":!1,te=i.useCallback(()=>{if(R){const z=ue(r,R.path),O=(z==null?void 0:z.type)==="directory"?R.path:R.path.substring(0,R.path.lastIndexOf("/"));if(O){o.has(O)||u(O);const G=O+"/__new_file__";w(G)}I(null)}},[R,r,o,u,w,ue]),we=i.useCallback(()=>{if(R){const z=ue(r,R.path),O=(z==null?void 0:z.type)==="directory"?R.path:R.path.substring(0,R.path.lastIndexOf("/"));if(O){o.has(O)||u(O);const G=O+"/__new_folder__";v(G)}I(null)}},[R,r,o,u,v,ue]),ze=i.useCallback(()=>{R&&(ke(R.path),I(null))},[R]),It=i.useCallback(()=>{if(R&&a){const z=R.path.startsWith(a+"/")?R.path.slice(a.length+1):R.path;ke(z),I(null)}},[R,a]),Ot=i.useCallback(z=>{p.current=z},[]),Bt=i.useCallback(z=>{p.current.length>0&&(F(p.current,z),p.current=[])},[F]),Wt=i.useCallback(z=>{var re,ne,Ne,Qe;if(x||!r)return;const O=rs(r,o);if(O.length===0)return;const G=d?O.indexOf(d):-1;switch(z.key){case"ArrowDown":{z.preventDefault();const me=G<O.length-1?G+1:0;C(O[me],{shift:z.shiftKey}),(ne=(re=D.current)==null?void 0:re.querySelector(`[data-path="${CSS.escape(O[me])}"]`))==null||ne.scrollIntoView({block:"nearest"});break}case"ArrowUp":{z.preventDefault();const me=G>0?G-1:O.length-1;C(O[me],{shift:z.shiftKey}),(Qe=(Ne=D.current)==null?void 0:Ne.querySelector(`[data-path="${CSS.escape(O[me])}"]`))==null||Qe.scrollIntoView({block:"nearest"});break}case"ArrowRight":{z.preventDefault(),d&&!o.has(d)&&u(d);break}case"ArrowLeft":{z.preventDefault(),d&&o.has(d)&&u(d);break}case"Enter":{z.preventDefault(),d&&j(d);break}case"Delete":case"Backspace":{z.preventDefault(),m.size>0&&_();break}case" ":{if(z.preventDefault(),d){const me=Se=>{if(!Se)return null;if(Se.path===d)return Se;if(Se.children)for(const Vt of Se.children){const Xe=me(Vt);if(Xe)return Xe}return null},ye=me(r);(ye==null?void 0:ye.type)==="directory"?u(d):ye&&k(ye.path,ye.name)}break}}},[r,o,d,m,x,C,u,j,k,_]);i.useEffect(()=>{if(!d)return;const z=setTimeout(()=>{var G;const O=(G=D.current)==null?void 0:G.querySelector(`[data-path="${CSS.escape(d)}"]`);O==null||O.scrollIntoView({block:"nearest",behavior:"smooth"})},60);return()=>clearTimeout(z)},[d]);const Ht=(r==null?void 0:r.name)||(a==null?void 0:a.split("/").pop())||"WORKSPACE";return e.jsxs("div",{className:"file-tree",ref:D,tabIndex:0,onKeyDown:Wt,onClick:()=>{var z;return(z=D.current)==null?void 0:z.focus()},children:[e.jsx("div",{className:"file-tree-title-bar",children:e.jsx("span",{className:"file-tree-title-text",children:s("editor.explorer")})}),e.jsxs("div",{className:"file-tree-section-header",onClick:()=>U(!H),onMouseEnter:()=>K(!0),onMouseLeave:()=>K(!1),children:[H?e.jsx(Z,{size:12,style:{flexShrink:0}}):e.jsx(se,{size:12,style:{flexShrink:0}}),e.jsx("span",{className:"file-tree-section-name",children:Ht.toUpperCase()}),q&&!H&&e.jsxs("div",{className:"file-tree-section-actions",onClick:z=>z.stopPropagation(),children:[e.jsx("button",{className:"file-tree-section-action",onClick:g,title:s("editor.newFile"),children:e.jsx(Bs,{size:14})}),e.jsx("button",{className:"file-tree-section-action",onClick:f,title:s("editor.newFolder"),children:e.jsx(Ks,{size:14})}),e.jsx("button",{className:"file-tree-section-action",onClick:()=>T(!0),title:s("editor.openFolder"),children:e.jsx(cs,{size:14})}),e.jsx("button",{className:"file-tree-section-action",onClick:L,title:s("editor.refresh"),children:e.jsx(De,{size:14})}),e.jsx("button",{className:"file-tree-section-action",onClick:M,title:s("editor.collapseAll"),children:e.jsx($s,{size:14})}),e.jsx("button",{className:"file-tree-section-action",onClick:V,title:s(A?"editor.hideHiddenFiles":"editor.showHiddenFiles"),children:A?e.jsx(Is,{size:14}):e.jsx(Fs,{size:14})})]})]}),B&&e.jsx(ls,{initialPath:a||(n==null?void 0:n.cwd)||"/",onSelect:S,onClose:()=>T(!1)}),!H&&e.jsxs("div",{className:"file-tree-content",children:[c&&!r&&e.jsx("div",{className:"file-tree-loading",children:e.jsx(pe,{size:16,className:"animate-spin"})}),!c&&!r&&l&&a&&e.jsxs("div",{className:"file-tree-empty",children:[e.jsx("span",{children:s("editor.loadError")}),e.jsxs("button",{className:"file-tree-retry-btn",onClick:()=>y(a),children:[e.jsx(De,{size:12}),s("editor.refresh")]}),(n==null?void 0:n.cwd)&&a!==n.cwd&&e.jsxs("button",{className:"file-tree-retry-btn",onClick:()=>y(n.cwd),children:[e.jsx(Gs,{size:12}),s("editor.backToWorkDir")]})]}),N.map(z=>e.jsx(Pt,{node:z,depth:0,isExpanded:o.has(z.path),isSelected:d===z.path,isMultiSelected:m.has(z.path),isRenaming:x===z.path,expandedPaths:o,selectedPath:d,selectedPaths:m,renamingPath:x,gitStatusMap:h,onToggleExpand:u,onSelect:C,onOpenFile:b,onConfirmRename:W,onCancelRename:$,onContextMenu:ae,onDragStart:Ot,onDrop:Bt},z.path)),N.length===0&&(r==null?void 0:r.children)&&e.jsx("div",{className:"file-tree-empty",children:s("editor.emptyFolder")})]}),R&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"editor-context-overlay",onClick:de}),e.jsxs("div",{className:"editor-context-menu",style:{left:R.x,top:R.y},children:[ve&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:te,children:s("editor.newFile")}),e.jsx("button",{onClick:we,children:s("editor.newFolder")}),e.jsx("div",{className:"editor-context-separator"})]}),e.jsx("button",{onClick:ze,children:s("editor.copyPath")}),e.jsx("button",{onClick:It,children:s("editor.copyRelativePath")}),e.jsx("div",{className:"editor-context-separator"}),m.size<=1&&e.jsx("button",{onClick:he,children:s("editor.rename")}),e.jsx("button",{className:"danger",onClick:je,children:m.size>1?`${s("editor.delete")} (${m.size})`:s("editor.delete")})]})]})]})}function za(t,s){fetch(`/api/v1/pty/${t}/input/send`,{method:"POST",headers:{...Re(),"Content-Type":"application/json"},body:JSON.stringify({data:s})}).catch(()=>{})}function Ea(t){return/^[a-zA-Z0-9_./-]+$/.test(t)?t:`'${t.replace(/'/g,"'\\''")}'`}function Et(){const{t}=Q(),{bottomTerminals:s,activeBottomTerminalId:n,bottomPanelMaximized:a,createBottomTerminal:r,closeBottomTerminal:c,closeOtherBottomTerminals:l,closeBottomTerminalsToRight:o,closeAllBottomTerminals:d,setActiveBottomTerminal:m,setBottomPanelCollapsed:x,toggleBottomPanelMaximize:y}=Y(),u=os(h=>h.cwd),[C,k]=i.useState(null),L=i.useCallback((h,N)=>{h.preventDefault(),k({x:h.clientX,y:h.clientY,tabId:N})},[]),M=i.useCallback(()=>{k(null)},[]),g=ds(h=>h.panes),f=i.useRef(null);i.useEffect(()=>{const h=setTimeout(()=>{window.dispatchEvent(new Event("resize"))},60);return()=>clearTimeout(h)},[]),i.useEffect(()=>{if(!n||!f.current)return;const N=f.current.querySelector(".ide-bottom-tab.active");N&&N.scrollIntoView({block:"nearest",inline:"nearest",behavior:"smooth"})},[n]);const j=i.useCallback(()=>{r()},[r]),w=i.useCallback((h,N)=>{h.stopPropagation(),c(N)},[c]),v=i.useCallback(()=>{x(!0)},[x]),[P,$]=i.useState(!1),_=i.useRef(0),F=i.useCallback(h=>{h.preventDefault(),h.stopPropagation(),_.current++,(h.dataTransfer.types.includes("text/plain")||h.dataTransfer.types.includes("application/x-file-paths"))&&$(!0)},[]),A=i.useCallback(h=>{h.preventDefault(),h.stopPropagation(),h.dataTransfer.dropEffect="copy"},[]),V=i.useCallback(h=>{h.preventDefault(),h.stopPropagation(),_.current--,_.current<=0&&(_.current=0,$(!1))},[]),E=i.useCallback(h=>{h.preventDefault(),h.stopPropagation(),$(!1),_.current=0;let N=[];const H=h.dataTransfer.getData("application/x-file-paths")||h.dataTransfer.getData("text/plain");if(H)try{const B=JSON.parse(H);Array.isArray(B)&&(N=B)}catch{N=[H]}if(N.length===0&&h.dataTransfer.files.length>0)for(let B=0;B<h.dataTransfer.files.length;B++){const T=h.dataTransfer.files[B],D=T.path||T.webkitRelativePath||T.name;D&&N.push(D)}if(N.length===0)return;const U=n;if(!U)return;const q=g[U];if(!(q!=null&&q.ptySessionId))return;const K=N.map(Ea).join(" ");za(q.ptySessionId,K),setTimeout(()=>{const B=document.querySelector('.ide-bottom-terminal-wrap[style*="flex"] .xterm-helper-textarea');B==null||B.focus()},50)},[n,g]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`ide-bottom-panel ${P?"drop-highlight":""}`,onDragEnter:F,onDragOver:A,onDragLeave:V,onDrop:E,children:[e.jsxs("div",{className:"ide-bottom-tabs",children:[e.jsx("div",{className:"ide-bottom-tabs-list",ref:f,onDoubleClick:h=>{h.target===h.currentTarget&&j()},children:s.map((h,N)=>{const H=g[h],U=(H==null?void 0:H.title)||`Terminal ${N+1}`,q=h===n;return e.jsxs("button",{className:`ide-bottom-tab ${q?"active":""}`,onClick:()=>m(h),onDoubleClick:()=>y(),onContextMenu:K=>L(K,h),children:[e.jsx("span",{className:"ide-bottom-tab-title",title:U,children:U}),e.jsx("span",{className:"ide-bottom-tab-close",onClick:K=>w(K,h),children:e.jsx(ut,{size:14})})]},h)})}),e.jsxs("div",{className:"ide-bottom-tabs-actions",children:[e.jsx("button",{className:"ide-bottom-action-btn",onClick:j,title:t("ide.newTerminal"),children:e.jsx(xe,{size:16})}),e.jsx("button",{className:"ide-bottom-action-btn",onClick:y,title:a?t("ide.restorePanel")||"Restore Panel Size":t("ide.maximizePanel")||"Maximize Panel",children:a?e.jsx(hs,{size:16}):e.jsx(ft,{size:16})}),e.jsx("button",{className:"ide-bottom-action-btn",onClick:v,title:t("ide.hidePanel"),children:e.jsx(se,{size:16})})]})]}),e.jsxs("div",{className:"ide-bottom-content",children:[s.map(h=>e.jsx("div",{className:"ide-bottom-terminal-wrap",style:{display:h===n?"flex":"none"},children:e.jsx(us,{paneId:h,initialCwd:u})},h)),s.length===0&&e.jsx("div",{className:"ide-bottom-empty",children:e.jsxs("button",{className:"ide-bottom-empty-btn",onClick:j,children:[e.jsx(xe,{size:16}),e.jsx("span",{children:t("ide.newTerminal")||"New Terminal"})]})})]})]}),C&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"editor-context-overlay",onClick:M}),e.jsxs("div",{className:"editor-context-menu",style:{left:C.x,top:C.y},children:[e.jsx("button",{onClick:()=>{c(C.tabId),M()},children:t("terminal.close")}),e.jsx("button",{onClick:()=>{l(C.tabId),M()},children:t("terminal.closeOthers")}),e.jsx("button",{onClick:()=>{o(C.tabId),M()},children:t("terminal.closeToRight")}),e.jsx("div",{className:"editor-context-separator"}),e.jsx("button",{onClick:()=>{d(),M()},children:t("terminal.closeAll")})]})]})]})}function nt(t){const{direction:s,initialSize:n,minSize:a=120,maxSize:r,collapsible:c=!0,collapseThreshold:l,defaultCollapsed:o=!1,onResize:d,onCollapse:m,onMaximize:x,maximizeThreshold:y=.92,reverse:u=!1}=t,[C,k]=i.useState(n),[L,M]=i.useState(o),[g,f]=i.useState(!1),j=i.useRef(null),w=i.useRef(n);i.useEffect(()=>{L||k(n)},[n,L]),i.useEffect(()=>{M(o)},[o]);const v=l??a*.6,P=i.useCallback(()=>{if(r)return r;const E=j.current;if(!(E!=null&&E.parentElement))return 1/0;const h=E.parentElement.getBoundingClientRect();return(s==="horizontal"?h.width:h.height)*.8},[s,r]),$=i.useCallback(E=>{const h=Math.max(a,Math.min(P(),E));k(h),w.current=h,d==null||d(h)},[a,P,d]),_=i.useCallback(()=>{M(E=>{const h=!E;if(h)w.current=C;else{const N=Math.max(a,w.current);k(N),d==null||d(N)}return m==null||m(h),h})},[C,a,d,m]),F=i.useCallback((E,h)=>{f(!0);const N=j.current;if(!N)return;const H=L?0:C,U=P(),K=(s==="horizontal"?N.clientWidth:N.clientHeight)*y;let B=!1;const T=()=>{f(!1),document.removeEventListener("pointermove",R),document.removeEventListener("pointerup",I),document.removeEventListener("pointercancel",I),document.body.style.cursor="",document.body.style.userSelect="",document.body.classList.remove("ide-sash-dragging")},D=(p,S)=>{if(B)return;let b;s==="horizontal"?b=p-E:b=S-h,u&&(b=-b);const W=H+b;if(c&&W<v){L||(w.current=C>a?C:n,M(!0),m==null||m(!0));return}if(x&&W>=K){B=!0,x(),T();return}L&&W>=a&&(M(!1),m==null||m(!1));const ae=Math.max(a,Math.min(U,W));k(ae),d==null||d(ae)},R=p=>D(p.clientX,p.clientY),I=()=>T();document.addEventListener("pointermove",R),document.addEventListener("pointerup",I),document.addEventListener("pointercancel",I),document.body.style.cursor=s==="horizontal"?"col-resize":"row-resize",document.body.style.userSelect="none",document.body.classList.add("ide-sash-dragging")},[L,C,s,u,c,v,a,n,P,d,m,x,y]),A=i.useCallback(E=>{E.preventDefault(),E.stopPropagation(),F(E.clientX,E.clientY)},[F]),V=["ide-sash",s==="horizontal"?"ide-sash-vertical":"ide-sash-horizontal",g?"dragging":""].filter(Boolean).join(" ");return{size:L?0:C,collapsed:L,sashProps:{onPointerDown:A,onDoubleClick:_,className:V},containerRef:j,setSize:$,toggleCollapse:_,dragging:g}}function Ta(t){return[...t].sort((s,n)=>s.type==="directory"&&n.type!=="directory"?-1:s.type!=="directory"&&n.type==="directory"?1:s.name.localeCompare(n.name,void 0,{numeric:!0,sensitivity:"base"}))}function Ra({filePath:t,rootPath:s,onSegmentClick:n,onOpenFile:a}){const c=(t.startsWith(s)?t.slice(s.length).replace(/^\//,""):t).split("/").filter(Boolean),[l,o]=i.useState(null),[d,m]=i.useState([]),[x,y]=i.useState(!1),[u,C]=i.useState(-1),k=i.useRef(null),L=i.useRef(null),M=i.useCallback(async(v,P)=>{const $=P.getBoundingClientRect();o({dirPath:v,anchorRect:$}),y(!0),m([]),C(-1);try{const _=await xt(v);m(Ta(_.map(F=>({name:F.name,path:F.path,type:F.type}))))}catch{m([])}y(!1)},[]),g=i.useCallback(()=>{o(null),m([]),C(-1)},[]),f=i.useCallback(v=>{v.type==="directory"?(n(v.path),g()):(a(v.path),g())},[n,a,g]);i.useEffect(()=>{if(!l)return;const v=P=>{if(P.key==="Escape"){P.preventDefault(),g();return}P.key==="ArrowDown"?(P.preventDefault(),C($=>$<d.length-1?$+1:0)):P.key==="ArrowUp"?(P.preventDefault(),C($=>$>0?$-1:d.length-1)):P.key==="Enter"&&u>=0&&u<d.length&&(P.preventDefault(),f(d[u]))};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[l,d,u,g,f]),i.useEffect(()=>{var v;u>=0&&L.current&&((v=L.current.querySelectorAll(".breadcrumb-dropdown-item")[u])==null||v.scrollIntoView({block:"nearest"}))},[u]);const j=i.useCallback((v,P)=>{v.stopPropagation();const $=v.currentTarget;l&&l.dirPath===P?g():M(P,$)},[l,M,g]),w=i.useCallback((v,P)=>{v.stopPropagation();const $=v.currentTarget;l&&l.dirPath===P?g():M(P,$)},[l,M,g]);return e.jsxs("div",{className:"editor-breadcrumbs",children:[e.jsx("span",{style:{display:"inline-flex",alignItems:"center"},children:e.jsx("span",{className:`editor-breadcrumb-segment ${c.length===0?"active":""}`,onClick:v=>j(v,s),children:e.jsx("span",{children:s.split("/").pop()||s})})}),c.map((v,P)=>{const $=P===c.length-1,_=s+"/"+c.slice(0,P+1).join("/"),F=P===0?s:s+"/"+c.slice(0,P).join("/");return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center"},children:[e.jsx("span",{className:"editor-breadcrumb-separator",children:e.jsx(Z,{size:10})}),e.jsxs("span",{className:`editor-breadcrumb-segment ${$?"active":""} ${(l==null?void 0:l.dirPath)===($?F:_)?"dropdown-open":""}`,onClick:A=>$?w(A,F):j(A,_),children:[$&&e.jsx(oe,{name:v,type:"file",size:14}),e.jsx("span",{style:$?{fontWeight:500}:void 0,children:v})]})]},_)}),l&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"breadcrumb-dropdown-overlay",onClick:g}),e.jsx("div",{ref:k,className:"breadcrumb-dropdown",style:{left:Math.min(l.anchorRect.left,window.innerWidth-260),top:l.anchorRect.bottom+2},children:x?e.jsx("div",{className:"breadcrumb-dropdown-loading",children:e.jsx(pe,{size:14,className:"animate-spin"})}):d.length===0?e.jsx("div",{className:"breadcrumb-dropdown-empty",children:"Empty"}):e.jsx("div",{className:"breadcrumb-dropdown-list",ref:L,children:d.map((v,P)=>{const $=v.path===t,_=P===u;return e.jsxs("div",{className:`breadcrumb-dropdown-item ${$?"current":""} ${_?"highlighted":""}`,onClick:()=>f(v),children:[v.type==="directory"?e.jsx(Z,{size:12,style:{flexShrink:0,opacity:.5}}):e.jsx(oe,{name:v.name,type:v.type,size:16}),e.jsx("span",{className:"breadcrumb-dropdown-item-name",children:v.name})]},v.path)})})})]})]})}function La(t,s){const n=t.toLowerCase(),a=s.toLowerCase();let r=0,c=0,l=-1;for(let o=0;o<a.length&&r<n.length;o++)a[o]===n[r]&&(c+=o===l+1?2:1,(o===0||a[o-1]==="/"||a[o-1]===".")&&(c+=3),l=o,r++);return{match:r===n.length,score:c}}const it=20,$a=3;function Tt({isOpen:t,onClose:s,onSelect:n,rootPath:a}){const{t:r}=Q(),[c,l]=i.useState(""),[o,d]=i.useState(0),[m,x]=i.useState([]),[y,u]=i.useState(!1),C=i.useRef(null),k=i.useRef(null),L=i.useRef(""),M=i.useRef([]),g=i.useCallback(async(w,v,P)=>{if(v>$a)return[];try{const $=await xt(w),_=[];for(const F of $){const A=P?`${P}/${F.name}`:F.name;if(F.type==="file"&&!ms(F.path))_.push({name:F.name,path:F.path,relativePath:A});else if(F.type==="directory"&&!F.name.startsWith(".")&&F.name!=="node_modules"){const V=await g(F.path,v+1,A);_.push(...V)}}return _}catch{return[]}},[]);i.useEffect(()=>{if(t){if(l(""),d(0),setTimeout(()=>{var w;return(w=C.current)==null?void 0:w.focus()},0),L.current===a&&M.current.length>0){x(M.current);return}u(!0),g(a,0,"").then(w=>{L.current=a,M.current=w,x(w),u(!1)})}},[t,a,g]);const f=i.useMemo(()=>{if(!c.trim())return m.slice(0,it);const w=[];for(const v of m){const P=La(c,v.relativePath);P.match&&w.push({entry:v,score:P.score})}return w.sort((v,P)=>P.score-v.score),w.slice(0,it).map(v=>v.entry)},[m,c]);i.useEffect(()=>{d(0)},[f.length,c]);const j=i.useCallback(w=>{switch(w.key){case"ArrowDown":w.preventDefault(),d(v=>(v+1)%Math.max(f.length,1));break;case"ArrowUp":w.preventDefault(),d(v=>(v-1+f.length)%Math.max(f.length,1));break;case"Enter":w.preventDefault(),f[o]&&n(f[o].path);break;case"Escape":w.preventDefault(),s();break}},[f,o,n,s]);return i.useEffect(()=>{var v;const w=(v=k.current)==null?void 0:v.children[o];w==null||w.scrollIntoView({block:"nearest"})},[o]),t?e.jsx("div",{className:"quick-open-overlay",onClick:s,children:e.jsxs("div",{className:"quick-open-dialog",onClick:w=>w.stopPropagation(),onKeyDown:j,children:[e.jsx("input",{ref:C,className:"quick-open-input",type:"text",value:c,onChange:w=>l(w.target.value),placeholder:r("editor.quickOpenPlaceholder")}),e.jsx("div",{className:"quick-open-list",ref:k,children:y?e.jsx("div",{className:"quick-open-empty",children:r("editor.quickOpenLoading")}):f.length===0?e.jsx("div",{className:"quick-open-empty",children:(c.trim(),r("editor.quickOpenEmpty"))}):f.map((w,v)=>e.jsxs("div",{className:`quick-open-item${v===o?" active":""}`,onClick:()=>n(w.path),onMouseEnter:()=>d(v),children:[e.jsx(oe,{name:w.name,type:"file",size:14}),e.jsx("span",{className:"quick-open-item-name",children:w.name}),e.jsx("span",{className:"quick-open-item-path",children:w.relativePath})]},w.path))})]})}):null}function _a({gitFileCount:t=0}){const{t:s}=Q(),n=Y(x=>x.activePanel),a=Y(x=>x.sidePanelCollapsed),r=Y(x=>x.toggleActivePanel),c=Y(x=>x.bottomPanelCollapsed),l=Y(x=>x.toggleBottomPanel),o=Je(x=>x.isOpen),d=Je(x=>x.toggle),m=i.useCallback(x=>n===x&&!a,[n,a]);return e.jsxs("div",{className:"ide-activity-bar",children:[e.jsxs("div",{className:"ide-activity-bar-top",children:[e.jsx("button",{className:`ide-activity-btn ${m("explorer")?"active":""}`,onClick:()=>r("explorer"),title:s("ide.explorer")||"Explorer",children:e.jsx(jt,{size:22,strokeWidth:1.5})}),e.jsx("button",{className:`ide-activity-btn ${m("search")?"active":""}`,onClick:()=>r("search"),title:s("ide.search")||"Search",children:e.jsx(qe,{size:22,strokeWidth:1.5})}),e.jsxs("button",{className:`ide-activity-btn ${m("source-control")?"active":""}`,onClick:()=>r("source-control"),title:s("ide.sourceControl")||"Source Control",children:[e.jsx(Ce,{size:22,strokeWidth:1.5}),t>0&&e.jsx("span",{className:"ide-activity-badge",children:t>99?"99+":t})]})]}),e.jsxs("div",{className:"ide-activity-bar-bottom",children:[e.jsx("button",{className:`ide-activity-btn ${c?"":"active"}`,onClick:l,title:s("ide.terminal")||"Terminal",children:e.jsx(Ys,{size:22,strokeWidth:1.5})}),e.jsx("button",{className:`ide-activity-btn ${o?"active":""}`,onClick:d,title:s("sidebar.toggle")||"Toggle Sidebar",children:e.jsx(fs,{size:22,strokeWidth:1.5})})]})]})}function Fa(){try{const t=localStorage.getItem("cbc_search_prefs");if(t)return{...rt,...JSON.parse(t)}}catch{}return rt}const rt={viewMode:"tree",caseSensitive:!1,isRegex:!1,wholeWord:!1,query:"",includePattern:"",excludePattern:"",useDefaultExcludes:!0};function ce(t){try{localStorage.setItem("cbc_search_prefs",JSON.stringify(t))}catch{}}function le(t){return{viewMode:t.viewMode,caseSensitive:t.caseSensitive,isRegex:t.isRegex,wholeWord:t.wholeWord,query:t.query,includePattern:t.includePattern,excludePattern:t.excludePattern,useDefaultExcludes:t.useDefaultExcludes}}const fe=Fa(),Aa=dt((t,s)=>({query:fe.query,isRegex:fe.isRegex,caseSensitive:fe.caseSensitive,wholeWord:fe.wholeWord,includePattern:fe.includePattern,excludePattern:fe.excludePattern,useDefaultExcludes:fe.useDefaultExcludes,viewMode:fe.viewMode,results:[],searching:!1,totalMatches:0,fileCount:0,error:null,setQuery:n=>{t({query:n}),ce(le({...s(),query:n}))},search:async()=>{var y;const{query:n,isRegex:a,caseSensitive:r,wholeWord:c,includePattern:l,excludePattern:o,useDefaultExcludes:d}=s();if(!n.trim())return;const m=Ve();let x=o||void 0;if(d){const u="node_modules,**/.git,**/dist,**/build,**/.next,**/coverage";x=x?`${x},${u}`:u}t({searching:!0,error:null,results:[],totalMatches:0,fileCount:0});try{const u=await fetch("/api/v1/fs/search-content",{method:"POST",headers:{...Re(),"Content-Type":"application/json"},body:JSON.stringify({query:n.trim(),cwd:m||void 0,isRegex:a,caseSensitive:r,wholeWord:c,includeGlob:l||void 0,excludeGlob:x,maxResults:200})});if(u.ok){const C=await u.json(),L=(C.data??C).results||[],M=new Map;for(const f of L)M.has(f.path)||M.set(f.path,[]),M.get(f.path).push(f);const g=[];for(const[f,j]of M)g.push({path:f,matches:j});t({results:g,totalMatches:L.length,fileCount:g.length,searching:!1})}else{const C=await u.json().catch(()=>null),k=((y=C==null?void 0:C.error)==null?void 0:y.message)||`HTTP ${u.status}`;t({searching:!1,error:k})}}catch(u){t({searching:!1,error:u.message||"Search failed"})}},toggleRegex:()=>{t(n=>({isRegex:!n.isRegex})),ce(le(s()))},toggleCaseSensitive:()=>{t(n=>({caseSensitive:!n.caseSensitive})),ce(le(s()))},toggleWholeWord:()=>{t(n=>({wholeWord:!n.wholeWord})),ce(le(s()))},setIncludePattern:n=>{t({includePattern:n}),ce(le({...s(),includePattern:n}))},setExcludePattern:n=>{t({excludePattern:n}),ce(le({...s(),excludePattern:n}))},toggleUseDefaultExcludes:()=>{t(n=>({useDefaultExcludes:!n.useDefaultExcludes})),ce(le(s()))},setViewMode:n=>{t({viewMode:n}),ce(le(s()))},clear:()=>{t({query:"",includePattern:"",excludePattern:"",results:[],totalMatches:0,fileCount:0,searching:!1,error:null}),ce(le(s()))}}));function Ia(t){const s={children:[]};for(const a of t){const r=a.path.split("/");let c=s;for(let l=0;l<r.length;l++){const o=r[l];if(l===r.length-1)c.children.push({name:o,fullPath:a.path,isDir:!1,children:[],matches:a.matches,matchCount:a.matches.length});else{let m=c.children.find(x=>x.isDir&&x.name===o);m||(m={name:o,fullPath:r.slice(0,l+1).join("/"),isDir:!0,children:[],matchCount:0},c.children.push(m)),c=m}}}function n(a){if(a.isDir&&a.children.length===1&&a.children[0].isDir){const l=a.children[0];return n({...l,name:`${a.name}/${l.name}`})}const r=a.children.map(n),c=r.reduce((l,o)=>l+o.matchCount,0);return{...a,children:r,matchCount:a.isDir?c:a.matchCount}}return s.children.map(n)}function Rt(){const{t}=Q(),{query:s,isRegex:n,caseSensitive:a,wholeWord:r,includePattern:c,excludePattern:l,useDefaultExcludes:o,viewMode:d,results:m,searching:x,totalMatches:y,fileCount:u,error:C,setQuery:k,search:L,toggleRegex:M,toggleCaseSensitive:g,toggleWholeWord:f,setIncludePattern:j,setExcludePattern:w,toggleUseDefaultExcludes:v,setViewMode:P}=Aa(),{openFile:$}=X(),_=i.useRef(null),[F,A]=i.useState(new Set),[V,E]=i.useState(!0);i.useEffect(()=>{var T;(T=_.current)==null||T.focus()},[]);const h=i.useCallback(()=>{const T=new Set;for(const D of m){T.add(D.path);const R=D.path.split("/");for(let I=1;I<R.length;I++)T.add(R.slice(0,I).join("/"))}return T},[m]);i.useEffect(()=>{A(h()),E(!0)},[h]);const N=i.useMemo(()=>Ia(m),[m]),H=i.useCallback(T=>{T.key==="Enter"&&(T.preventDefault(),L())},[L]),U=i.useCallback(T=>{A(D=>{const R=new Set(D);return R.has(T)?R.delete(T):R.add(T),R})},[]),q=i.useCallback(()=>{A(new Set),E(!1)},[]),K=i.useCallback(()=>{A(h()),E(!0)},[h]),B=i.useCallback((T,D)=>{const R=D?{line:D,query:s.trim()}:void 0;$(T,void 0,R)},[$,s]);return e.jsxs("div",{className:"search-panel",children:[e.jsx("div",{className:"scm-header",children:e.jsx("span",{className:"scm-header-title",children:t("ide.search.title")})}),e.jsxs("div",{className:"search-input-section",children:[e.jsxs("div",{className:"search-field",children:[e.jsx("input",{ref:_,className:"search-field-input",value:s,onChange:T=>k(T.target.value),onKeyDown:H,placeholder:t("ide.search.placeholder")}),e.jsxs("div",{className:"search-field-actions",children:[e.jsx("button",{className:`search-field-btn ${a?"active":""}`,onClick:g,title:t("ide.search.matchCase"),children:e.jsx(Es,{size:14})}),e.jsx("button",{className:`search-field-btn ${r?"active":""}`,onClick:f,title:t("ide.search.wholeWord"),children:e.jsx(ra,{size:14})}),e.jsx("button",{className:`search-field-btn ${n?"active":""}`,onClick:M,title:t("ide.search.regex"),children:e.jsx(Zs,{size:14})})]})]}),e.jsxs("div",{className:"search-filter-section",children:[e.jsx("span",{className:"search-filter-label",children:t("ide.search.filesToInclude")}),e.jsx("div",{className:"search-field",children:e.jsx("input",{className:"search-field-input",value:c,onChange:T=>j(T.target.value),onKeyDown:H,placeholder:t("ide.search.includePlaceholder")||"e.g. *.ts, src/**/include"})})]}),e.jsxs("div",{className:"search-filter-section",children:[e.jsx("span",{className:"search-filter-label",children:t("ide.search.filesToExclude")}),e.jsxs("div",{className:"search-field",children:[e.jsx("input",{className:"search-field-input",value:l,onChange:T=>w(T.target.value),onKeyDown:H,placeholder:t("ide.search.excludePlaceholder")||"e.g. node_modules, *.min.js"}),e.jsx("div",{className:"search-field-actions",children:e.jsx("button",{className:`search-field-btn ${o?"active":""}`,onClick:v,title:t("ide.search.useExcludeSettings")||"Use Exclude Settings and Ignore Files",children:e.jsx(ps,{size:14})})})]})]})]}),(x||y>0||C)&&e.jsxs("div",{className:"search-status-bar",children:[x&&e.jsxs("div",{className:"search-status",children:[e.jsx(pe,{size:14,className:"animate-spin"}),e.jsx("span",{children:t("ide.search.searching")})]}),!x&&y>0&&e.jsx("div",{className:"search-status",children:e.jsxs("span",{children:[y," results in ",u," files"]})}),C&&e.jsx("div",{className:"search-status search-error",children:C.includes("timed out")?t("ide.search.timedOut"):t("ide.search.failed")}),y>0&&e.jsxs("div",{className:"search-status-actions",children:[e.jsx("button",{className:`scm-icon-btn ${d==="list"?"active":""}`,onClick:()=>P("list"),title:t("ide.listView"),children:e.jsx(vt,{size:14})}),e.jsx("button",{className:`scm-icon-btn ${d==="tree"?"active":""}`,onClick:()=>P("tree"),title:t("ide.treeView"),children:e.jsx(yt,{size:14})}),e.jsx("button",{className:"scm-icon-btn",onClick:V?q:K,title:V?"Collapse All":"Expand All",children:V?e.jsx(Vs,{size:14}):e.jsx(na,{size:14})})]})]}),e.jsxs("div",{className:"search-results",children:[d==="tree"&&N.map(T=>e.jsx(Lt,{node:T,depth:0,expandedPaths:F,onToggle:U,onFileClick:B,query:s},T.fullPath)),d==="list"&&m.map(T=>e.jsxs("div",{className:"search-tree-group",children:[e.jsxs("div",{className:"search-tree-file",style:{paddingLeft:"4px"},onClick:()=>U(T.path),children:[F.has(T.path)?e.jsx(se,{size:14}):e.jsx(Z,{size:14}),e.jsx(oe,{name:T.path.split("/").pop()||"",type:"file",size:14}),e.jsx("span",{className:"search-tree-name",children:T.path.split("/").pop()}),e.jsx("span",{className:"search-list-filepath",children:T.path}),e.jsx("span",{className:"search-tree-badge",children:T.matches.length})]}),F.has(T.path)&&e.jsx("div",{className:"search-tree-matches",children:T.matches.map((D,R)=>e.jsx("div",{className:"search-tree-match",style:{paddingLeft:"24px"},onClick:()=>B(T.path,D.line),children:e.jsx($t,{text:D.text,query:s})},R))})]},T.path)),!x&&s&&y===0&&!C&&e.jsxs("div",{className:"scm-empty",children:[e.jsx(qe,{size:20,strokeWidth:1.5,style:{opacity:.3}}),e.jsx("span",{children:t("ide.search.noResults")})]})]})]})}function Lt({node:t,depth:s,expandedPaths:n,onToggle:a,onFileClick:r,query:c}){const l=n.has(t.fullPath),o=s*14;if(t.isDir)return e.jsxs("div",{className:"search-tree-group",children:[e.jsxs("div",{className:"search-tree-dir",style:{paddingLeft:`${o+4}px`},onClick:()=>a(t.fullPath),children:[l?e.jsx(se,{size:14}):e.jsx(Z,{size:14}),e.jsx(gt,{size:14,className:"scm-tree-folder-icon"}),e.jsx("span",{className:"search-tree-name",children:t.name}),e.jsx("span",{className:"search-tree-badge",children:t.matchCount})]}),l&&t.children.map(m=>e.jsx(Lt,{node:m,depth:s+1,expandedPaths:n,onToggle:a,onFileClick:r,query:c},m.fullPath))]});const d=t.name;return e.jsxs("div",{className:"search-tree-group",children:[e.jsxs("div",{className:"search-tree-file",style:{paddingLeft:`${o+4}px`},onClick:()=>a(t.fullPath),children:[l?e.jsx(se,{size:14}):e.jsx(Z,{size:14}),e.jsx(oe,{name:d,type:"file",size:14}),e.jsx("span",{className:"search-tree-name",children:d}),e.jsx("span",{className:"search-tree-badge",children:t.matchCount})]}),l&&t.matches&&e.jsx("div",{className:"search-tree-matches",children:t.matches.map((m,x)=>e.jsx("div",{className:"search-tree-match",style:{paddingLeft:`${o+24}px`},onClick:()=>r(t.fullPath,m.line),children:e.jsx($t,{text:m.text,query:c})},x))})]})}function $t({text:t,query:s}){if(!s)return e.jsx("span",{className:"search-match-text",children:t});const n=[],a=t.toLowerCase(),r=s.toLowerCase();let c=0,l=a.indexOf(r),o=0;for(;l!==-1&&o<10;)l>c&&n.push(e.jsx("span",{children:t.slice(c,l)},o++)),n.push(e.jsx("span",{className:"search-highlight",children:t.slice(l,l+s.length)},o++)),c=l+s.length,l=a.indexOf(r,c);return c<t.length&&n.push(e.jsx("span",{children:t.slice(c)},o++)),e.jsx("span",{className:"search-match-text",children:n})}function Oa(t,s){const n={children:[]};for(const a of t){const r=s(a).split("/");let c=n;for(let l=0;l<r.length;l++){const o=r[l],d=l===r.length-1,m=r.slice(0,l+1).join("/");if(d)c.children.push({name:o,path:m,isDir:!1,children:[],data:a});else{let x=c.children.find(y=>y.isDir&&y.name===o);x||(x={name:o,path:m,isDir:!0,children:[]},c.children.push(x)),c=x}}}return n.children.map(Oe)}function Oe(t){if(t.isDir&&t.children.length===1&&t.children[0].isDir){const s=t.children[0];return Oe({...s,name:`${t.name}/${s.name}`})}return{...t,children:t.children.map(Oe)}}const _t={modified:{label:"M",color:"var(--color-accent-yellow)"},added:{label:"A",color:"var(--color-accent-green)"},deleted:{label:"D",color:"var(--color-accent-red)"},renamed:{label:"R",color:"var(--color-accent-blue)"},copied:{label:"C",color:"var(--color-accent-blue)"},untracked:{label:"U",color:"var(--color-accent-green)"},conflicted:{label:"!",color:"var(--color-accent-red)"}};function Ft({file:t,onStage:s,onUnstage:n,onDiscard:a,onOpenFile:r}){const{t:c}=Q(),l=i.useCallback(o=>{o.stopPropagation(),ke(t.path)},[t.path]);return e.jsxs("div",{className:"scm-file-actions",children:[e.jsx("button",{className:"scm-file-action-btn",onClick:l,title:c("ide.scm.copyPath"),children:e.jsx(xs,{size:13})}),r&&t.status!=="deleted"&&e.jsx("button",{className:"scm-file-action-btn",onClick:o=>{o.stopPropagation(),r(t.path)},title:c("ide.scm.openFile"),children:e.jsx(bt,{size:13})}),a&&e.jsx("button",{className:"scm-file-action-btn",onClick:o=>{o.stopPropagation(),a(t.path)},title:c("ide.scm.discard"),children:e.jsx(Ke,{size:13})}),s&&e.jsx("button",{className:"scm-file-action-btn",onClick:o=>{o.stopPropagation(),s(t.path)},title:c("ide.scm.stage"),children:e.jsx(xe,{size:13})}),n&&e.jsx("button",{className:"scm-file-action-btn",onClick:o=>{o.stopPropagation(),n(t.path)},title:c("ide.scm.unstage"),children:e.jsx(Le,{size:13})})]})}function Ba({files:t,sectionTitle:s,sectionCount:n,sectionActions:a,onStage:r,onUnstage:c,onDiscard:l,onSelect:o,onOpenFile:d}){const[m,x]=i.useState(!0);return e.jsxs("div",{className:"scm-file-list",children:[s&&e.jsxs("div",{className:"scm-tree-section-root",onClick:()=>x(y=>!y),children:[m?e.jsx(se,{size:14}):e.jsx(Z,{size:14}),e.jsx("span",{className:"scm-tree-section-title",children:s}),n!==void 0&&e.jsx("span",{className:"scm-section-count",children:n}),a&&e.jsx("div",{className:"scm-file-actions",children:a})]}),(!s||m)&&t.map(y=>{const u=_t[y.status]||{label:"?",color:"var(--color-text-tertiary)"},C=y.path.split("/").pop()||y.path,k=y.path.includes("/")?y.path.substring(0,y.path.lastIndexOf("/")):"";return e.jsxs("div",{className:"scm-file-item",onClick:()=>o==null?void 0:o(y.path),children:[e.jsx(oe,{name:C,type:"file",size:16}),e.jsx("span",{className:"scm-file-name-text",children:C}),k&&e.jsx("span",{className:"scm-file-path-desc",children:k}),e.jsx(Ft,{file:y,onStage:r,onUnstage:c,onDiscard:l,onOpenFile:d}),e.jsx("span",{className:"scm-file-status",style:{color:u.color},children:u.label})]},`${y.path}-${y.staged}`)})]})}function Be({node:t,depth:s,onStage:n,onUnstage:a,onDiscard:r,onSelect:c,onOpenFile:l}){const{t:o}=Q(),[d,m]=i.useState(!0);function x(g){if(!g.isDir)return null;const f=He(g);return f.length===0?null:f.some(j=>j.status==="modified")?"var(--color-accent-yellow)":f.some(j=>j.status==="untracked"||j.status==="added")?"var(--color-accent-green)":"var(--color-text-tertiary)"}const y=x(t),u=He(t),C=i.useCallback(g=>{g.stopPropagation(),n&&u.forEach(f=>n(f.path))},[n,u]),k=i.useCallback(g=>{g.stopPropagation(),r&&u.forEach(f=>r(f.path))},[r,u]),L=i.useCallback(g=>{g.stopPropagation(),a&&u.forEach(f=>a(f.path))},[a,u]),M=s*16+4;return e.jsxs("div",{className:"scm-tree-group",children:[e.jsxs("div",{className:"scm-tree-dir",style:{paddingLeft:`${M}px`},onClick:()=>m(g=>!g),children:[Array.from({length:s},(g,f)=>e.jsx("span",{className:"scm-tree-indent-guide",style:{left:`${f*16+12}px`}},f)),d?e.jsx(se,{size:14}):e.jsx(Z,{size:14}),e.jsx(gt,{size:14,className:"scm-tree-folder-icon"}),e.jsx("span",{className:"scm-tree-dir-name",children:t.name}),e.jsxs("div",{className:"scm-file-actions",children:[r&&e.jsx("button",{className:"scm-file-action-btn",onClick:k,title:o("ide.scm.discardAll"),children:e.jsx(Ke,{size:13})}),n&&e.jsx("button",{className:"scm-file-action-btn",onClick:C,title:o("ide.scm.stageAll"),children:e.jsx(xe,{size:13})}),a&&e.jsx("button",{className:"scm-file-action-btn",onClick:L,title:o("ide.scm.unstageAll"),children:e.jsx(Le,{size:13})})]}),y&&e.jsx("span",{className:"scm-tree-dir-dot",style:{background:y}})]}),d&&t.children.map(g=>g.isDir?e.jsx(Be,{node:g,depth:s+1,onStage:n,onUnstage:a,onDiscard:r,onSelect:c,onOpenFile:l},g.path):e.jsx(We,{node:g,depth:s+1,onStage:n,onUnstage:a,onDiscard:r,onSelect:c,onOpenFile:l},g.path))]})}function We({node:t,depth:s,onStage:n,onUnstage:a,onDiscard:r,onSelect:c,onOpenFile:l}){const o=t.data,d=_t[o.status]||{label:"?",color:"var(--color-text-tertiary)"};return e.jsxs("div",{className:"scm-file-item",style:{paddingLeft:`${s*16+20}px`},onClick:()=>c==null?void 0:c(o.path),children:[Array.from({length:s},(m,x)=>e.jsx("span",{className:"scm-tree-indent-guide",style:{left:`${x*16+12}px`}},x)),e.jsx(oe,{name:t.name,type:"file",size:16}),e.jsx("span",{className:"scm-file-name-text",children:t.name}),e.jsx(Ft,{file:o,onStage:n,onUnstage:a,onDiscard:r,onOpenFile:l}),e.jsx("span",{className:"scm-file-status",style:{color:d.color},children:d.label})]})}function He(t){return t.isDir?t.children.flatMap(He):t.data?[t.data]:[]}function Wa({files:t,sectionTitle:s,sectionCount:n,sectionActions:a,onStage:r,onUnstage:c,onDiscard:l,onSelect:o,onOpenFile:d}){const[m,x]=i.useState(!0),y=Oa(t,u=>u.path);return s?e.jsxs("div",{className:"scm-file-list scm-tree-view",children:[e.jsxs("div",{className:"scm-tree-section-root",onClick:()=>x(u=>!u),children:[m?e.jsx(se,{size:14}):e.jsx(Z,{size:14}),e.jsx("span",{className:"scm-tree-section-title",children:s}),n!==void 0&&e.jsx("span",{className:"scm-section-count",children:n}),a&&e.jsx("div",{className:"scm-file-actions",children:a})]}),m&&y.map(u=>u.isDir?e.jsx(Be,{node:u,depth:1,onStage:r,onUnstage:c,onDiscard:l,onSelect:o,onOpenFile:d},u.path):e.jsx(We,{node:u,depth:1,onStage:r,onUnstage:c,onDiscard:l,onSelect:o,onOpenFile:d},u.path))]}):e.jsx("div",{className:"scm-file-list scm-tree-view",children:y.map(u=>u.isDir?e.jsx(Be,{node:u,depth:0,onStage:r,onUnstage:c,onDiscard:l,onSelect:o,onOpenFile:d},u.path):e.jsx(We,{node:u,depth:0,onStage:r,onUnstage:c,onDiscard:l,onSelect:o,onOpenFile:d},u.path))})}function ct(t){return t.viewMode==="tree"?e.jsx(Wa,{...t}):e.jsx(Ba,{...t})}const lt=["var(--color-accent-green)","var(--color-accent-blue)","var(--color-accent-yellow)","var(--color-accent-purple)","var(--color-accent-red)"];function Ha(t){try{const s=new Date(t),a=new Date().getTime()-s.getTime(),r=Math.floor(a/6e4);if(r<60)return`${r}m ago`;const c=Math.floor(r/60);if(c<24)return`${c}h ago`;const l=Math.floor(c/24);return l<7?`${l}d ago`:s.toLocaleDateString()}catch{return t}}function Va(){const{t}=Q(),[s,n]=i.useState(!1),[a,r]=i.useState([]),[c,l]=i.useState(!1),o=i.useCallback(async()=>{l(!0);try{const d=await fa(30);r(d)}catch{}l(!1)},[]);return i.useEffect(()=>{s&&a.length===0&&!c&&o()},[s,a.length,c,o]),e.jsxs("div",{className:"scm-graph",children:[e.jsxs("button",{className:"scm-section-header",onClick:()=>n(d=>!d),children:[s?e.jsx(se,{size:14}):e.jsx(Z,{size:14}),e.jsx("span",{children:t("ide.scm.graph")}),s&&e.jsx("button",{className:"scm-icon-btn",onClick:d=>{d.stopPropagation(),o()},title:t("ide.refresh"),children:e.jsx(De,{size:12,className:c?"animate-spin":""})})]}),s&&e.jsxs("div",{className:"scm-graph-list",children:[c&&a.length===0&&e.jsx("div",{className:"scm-graph-loading",children:e.jsx(pe,{size:14,className:"animate-spin"})}),a.map((d,m)=>e.jsxs("div",{className:"scm-graph-entry",title:`${d.hash}
|
|
89
|
-
${d.author}
|
|
90
|
-
${d.date}`,children:[e.jsx("span",{className:"scm-graph-dot",style:{background:lt[m%lt.length]}}),e.jsx("span",{className:"scm-graph-msg",children:d.message}),e.jsx("span",{className:"scm-graph-time",children:Ha(d.date)})]},d.hash))]})]})}function At(){const{t}=Q(),{isGitRepo:s,loading:n,files:a,currentBranch:r,ahead:c,behind:l,pushing:o,pulling:d,branches:m,branchesLoading:x,lastOperationMessage:y,refresh:u,loadBranches:C,stageFile:k,unstageFile:L,stageAll:M,unstageAll:g,discardFile:f,discardAll:j,push:w,pull:v,switchBranch:P,createBranch:$,clearOperationMessage:_}=ie(),F=X(D=>D.openFile),A=Y(D=>D.scmViewMode),V=Y(D=>D.setScmViewMode),[E,h]=i.useState(!0),[N,H]=i.useState(!0);i.useEffect(()=>{u(),ie.getState().startWatching()},[u]),i.useEffect(()=>{if(y){const D=setTimeout(_,3e3);return()=>clearTimeout(D)}},[y,_]);const U=P,q=i.useCallback(async(D,R)=>{Y.getState().bottomPanelMaximized&&Y.setState({bottomPanelMaximized:!1});try{const I=await Ct(D,R);X.getState().openDiffTab(D,{oldText:I.oldText,newText:I.newText,staged:R})}catch{}},[]),K=F,B=a.filter(D=>D.staged),T=a.filter(D=>!D.staged);return s?e.jsxs("div",{className:"scm-panel",children:[e.jsxs("div",{className:"scm-header",children:[e.jsx("span",{className:"scm-header-title",children:t("ide.scm.title")}),e.jsxs("div",{className:"scm-header-actions",children:[e.jsx("button",{className:`scm-icon-btn ${A==="list"?"active":""}`,onClick:()=>V("list"),title:t("ide.listView"),children:e.jsx(vt,{size:14})}),e.jsx("button",{className:`scm-icon-btn ${A==="tree"?"active":""}`,onClick:()=>V("tree"),title:t("ide.treeView"),children:e.jsx(yt,{size:14})}),e.jsx("button",{className:"scm-icon-btn",onClick:u,disabled:n,title:t("ide.refresh"),children:e.jsx(De,{size:14,className:n?"animate-spin":""})})]})]}),e.jsxs("div",{className:"scm-scroll",children:[e.jsxs("div",{className:"scm-section",children:[e.jsxs("button",{className:"scm-section-header",onClick:()=>h(D=>!D),children:[E?e.jsx(se,{size:14}):e.jsx(Z,{size:14}),e.jsx("span",{children:t("ide.scm.repositories")})]}),E&&e.jsx(wt,{currentBranch:r,branches:m,branchesLoading:x,onSwitch:U,onCreate:$,onLoadBranches:C,actions:e.jsxs(e.Fragment,{children:[(c>0||l>0)&&e.jsxs("span",{className:"scm-branch-sync",children:[c>0&&e.jsxs("span",{children:["↑",c]}),l>0&&e.jsxs("span",{children:["↓",l]})]}),e.jsxs("div",{className:"scm-branch-actions",children:[e.jsx("button",{className:"scm-icon-btn",onClick:v,disabled:d,title:t("ide.scm.pull"),children:d?e.jsx(pe,{size:14,className:"animate-spin"}):e.jsx(gs,{size:14})}),e.jsx("button",{className:"scm-icon-btn",onClick:w,disabled:o,title:t("ide.scm.push"),children:o?e.jsx(pe,{size:14,className:"animate-spin"}):e.jsx(bs,{size:14})}),e.jsx("button",{className:"scm-icon-btn",onClick:u,disabled:n,title:t("ide.refresh"),children:e.jsx(De,{size:12,className:n?"animate-spin":""})})]})]})})]}),e.jsxs("div",{className:"scm-section",children:[e.jsxs("button",{className:"scm-section-header",onClick:()=>H(D=>!D),children:[N?e.jsx(se,{size:14}):e.jsx(Z,{size:14}),e.jsx("span",{children:t("ide.scm.changes")}),e.jsx("span",{className:"scm-section-count",children:a.length})]}),y&&e.jsx("div",{className:"scm-operation-msg",children:y}),N&&e.jsxs(e.Fragment,{children:[B.length>0&&e.jsx(ct,{files:B,viewMode:A,sectionTitle:t("ide.scm.stagedChanges"),sectionCount:B.length,sectionActions:e.jsx("button",{className:"scm-file-action-btn",onClick:()=>g(),title:t("ide.scm.unstageAll"),children:e.jsx(Le,{size:13})}),onUnstage:L,onSelect:D=>q(D,!0),onOpenFile:K}),T.length>0&&e.jsx(ct,{files:T,viewMode:A,sectionTitle:t("ide.scm.changes"),sectionCount:T.length,sectionActions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"scm-file-action-btn",onClick:()=>j(),title:t("ide.scm.discardAll"),children:e.jsx(Ke,{size:13})}),e.jsx("button",{className:"scm-file-action-btn",onClick:()=>M(),title:t("ide.scm.stageAll"),children:e.jsx(xe,{size:13})})]}),onStage:k,onDiscard:f,onSelect:D=>q(D,!1),onOpenFile:K}),a.length===0&&!n&&e.jsxs("div",{className:"scm-empty",children:[e.jsx(ht,{size:20,strokeWidth:1.5,style:{opacity:.3}}),e.jsx("span",{children:t("ide.scm.noChanges")})]})]})]}),e.jsx(Va,{})]})]}):e.jsxs("div",{className:"scm-panel",children:[e.jsx("div",{className:"scm-header",children:e.jsx("span",{className:"scm-header-title",children:t("ide.scm.title")})}),e.jsxs("div",{className:"ide-panel-placeholder",children:[e.jsx(Ce,{size:32,strokeWidth:1,style:{opacity:.2}}),e.jsx("div",{className:"ide-panel-placeholder-text",children:t("ide.scm.notGitRepo")})]})]})}function qa({activePanel:t,onMenuClick:s}){return e.jsxs("div",{className:"ide-side-panel-content",children:[t==="explorer"&&e.jsx(zt,{onMenuClick:s}),t==="search"&&e.jsx(Rt,{}),t==="source-control"&&e.jsx(At,{})]})}function Ka({onMenuClick:t,activeTab:s,mdToggleBtn:n,cursorInfo:a,imageInfo:r,previewZoom:c,isMarkdownSource:l,quickOpenVisible:o,setQuickOpenVisible:d,onContentChange:m,onSave:x,onCursorChange:y,onImageInfo:u,onZoomChange:C}){const{t:k}=Q(),{rootPath:L,openFile:M,revealInTree:g}=X(),{activePanel:f,sidePanelWidth:j,sidePanelCollapsed:w,setSidePanelWidth:v,setSidePanelCollapsed:P,bottomPanelHeight:$,bottomPanelCollapsed:_,bottomPanelMaximized:F,setBottomPanelHeight:A,setBottomPanelCollapsed:V,toggleBottomPanelMaximize:E}=Y(),h=nt({direction:"horizontal",initialSize:j,minSize:160,maxSize:600,collapsible:!0,defaultCollapsed:w,onResize:v,onCollapse:P}),N=nt({direction:"vertical",initialSize:$,minSize:140,maxSize:typeof window<"u"?Math.max(300,window.innerHeight-80):500,collapsible:!0,defaultCollapsed:_,reverse:!0,onResize:A,onCollapse:V,onMaximize:E,maximizeThreshold:.85}),H=ie(D=>D.files.length);i.useEffect(()=>(ie.getState().refresh(),ie.getState().startWatching(),()=>{ie.getState().stopWatching()}),[]);const U=typeof navigator<"u"&&navigator.platform.includes("Mac"),q=()=>s?s.viewMode==="diff"&&s.diffData?e.jsx("div",{className:"editor-container",children:e.jsx(js,{path:s.path,oldText:s.diffData.oldText,newText:s.diffData.newText})}):s.viewMode==="editor"||l?e.jsx("div",{className:"editor-container",children:e.jsx(kt,{path:s.path,content:s.content,language:s.language,onContentChange:m,onSave:x,minimap:!0,onCursorChange:y})}):e.jsx(Mt,{path:s.path,name:s.name,content:s.content,viewMode:s.viewMode,onImageInfo:u,onZoomChange:C}):e.jsx(Ua,{isMac:U,t:k}),K=o&&L&&e.jsx(Tt,{isOpen:o,onClose:()=>d(!1),onSelect:D=>{M(D),d(!1)},rootPath:L}),B=f&&!h.collapsed,T=!N.collapsed;return e.jsxs("div",{className:"ide-layout",children:[K,e.jsxs("div",{className:"ide-layout-row",ref:h.containerRef,children:[e.jsx(_a,{gitFileCount:H}),B&&e.jsxs("div",{className:"ide-side-panel",style:{width:h.size},children:[e.jsx(qa,{activePanel:f,onMenuClick:t}),e.jsx("div",{...h.sashProps})]}),e.jsxs("div",{className:"ide-main-area",ref:N.containerRef,children:[!F&&e.jsxs("div",{className:"ide-editor-area",style:{flex:T?void 0:1,height:T?`calc(100% - ${N.size}px)`:"100%"},children:[e.jsx(St,{actions:n}),s&&L&&e.jsx(Ra,{filePath:s.path,rootPath:L,onSegmentClick:g,onOpenFile:M}),e.jsx("div",{className:"ide-editor-content",onDragOver:D=>{D.preventDefault(),D.dataTransfer.dropEffect="copy"},onDrop:D=>{D.preventDefault();const R=D.dataTransfer.getData("application/x-file-paths")||D.dataTransfer.getData("text/plain");if(R){try{const I=JSON.parse(R),p=Array.isArray(I)?I:[R];p.length>0&&M(p[0])}catch{R&&M(R)}setTimeout(()=>{const I=document.querySelector(".ide-editor-content .monaco-editor textarea");I==null||I.focus()},100)}},children:q()})]}),T&&e.jsxs(e.Fragment,{children:[!F&&e.jsx("div",{...N.sashProps}),e.jsx("div",{className:"ide-bottom-panel-wrap",style:{height:F?"100%":N.size},children:e.jsx(Et,{})})]})]})]}),e.jsx("div",{className:"ide-statusbar-drag-zone",onPointerDown:N.sashProps.onPointerDown,onDoubleClick:N.sashProps.onDoubleClick,children:e.jsx(Nt,{language:(s==null?void 0:s.language)||"",cursorLine:a.line,cursorColumn:a.col,selectedCount:a.selectedChars,selectedLines:a.selectedLines,viewMode:s?l?"editor":s.viewMode:"editor",imageInfo:r,zoom:c})})]})}function Ua({isMac:t,t:s}){const n=i.useRef(null),[a,r]=i.useState(!1);return i.useEffect(()=>{const c=n.current;if(!c)return;const l=new ResizeObserver(o=>{for(const d of o)r(d.contentRect.height<300)});return l.observe(c),()=>l.disconnect()},[]),e.jsxs("div",{className:"editor-empty",ref:n,children:[e.jsx("div",{className:"ide-empty-icon",children:e.jsx("img",{src:vs,alt:"CodeBuddy",width:"64",height:"64",style:{opacity:.15,filter:"grayscale(1)"}})}),!a&&e.jsxs("div",{className:"editor-empty-shortcuts",children:[e.jsxs("div",{className:"editor-empty-hint",children:[e.jsxs("kbd",{children:[t?"⌘":"Ctrl","+P"]}),e.jsx("span",{children:s("editor.quickOpen")})]}),e.jsxs("div",{className:"editor-empty-hint",children:[e.jsxs("kbd",{children:[t?"⌘":"Ctrl","+B"]}),e.jsx("span",{children:s("ide.toggleSidebar")||"Toggle Sidebar"})]}),e.jsxs("div",{className:"editor-empty-hint",children:[e.jsxs("kbd",{children:[t?"⌃":"Ctrl","+`"]}),e.jsx("span",{children:s("ide.toggleTerminal")||"Toggle Terminal"})]})]})]})}function Ga(){const{t}=Q(),s=Y(c=>c.activeMobilePanel),n=Y(c=>c.setActiveMobilePanel),a=ie(c=>c.files.length),r=[{id:"explorer",icon:e.jsx(jt,{size:20,strokeWidth:1.5}),label:t("ide.explorer")||"Explorer"},{id:"search",icon:e.jsx(qe,{size:20,strokeWidth:1.5}),label:t("ide.search")||"Search"},{id:"source-control",icon:e.jsx(Ce,{size:20,strokeWidth:1.5}),label:t("ide.sourceControl")||"Source Control",badge:a},{id:"terminal",icon:e.jsx(ys,{size:20,strokeWidth:1.5}),label:t("ide.terminal")||"Terminal"}];return e.jsx("div",{className:"mobile-tab-bar",children:r.map(c=>e.jsxs("button",{className:`mobile-tab-bar-btn ${s===c.id?"active":""}`,onClick:()=>n(c.id),children:[e.jsxs("span",{className:"mobile-tab-bar-icon",children:[c.icon,c.badge!=null&&c.badge>0&&e.jsx("span",{className:"mobile-tab-bar-badge",children:c.badge>99?"99+":c.badge})]}),e.jsx("span",{className:"mobile-tab-bar-label",children:c.label})]},c.id))})}const Qa=1e3;function en({onMenuClick:t}){const{t:s}=Q(),{tabs:n,activeTabId:a,updateTabContent:r,saveTab:c,closeTab:l}=X(),{setRootPath:o,openFile:d,rootPath:m,revealInTree:x}=X(),[y,u]=i.useState(!1),C=Y(p=>p.toggleBottomPanel),k=ks(),[L,M]=i.useState(!1),g=i.useRef("");i.useEffect(()=>{const p=async()=>{if(Ss()!=="editor")return;const b=pt(),W=b.get("path");if(!W)return;const ae=b.get("line"),de=b.get("col"),he=`${W}:${ae}:${de}`;if(he===g.current)return;if(g.current=he,!X.getState().rootPath){const te=b.get("folder")||new URLSearchParams(window.location.search).get("folder");te&&await o(te)}const ue=await Ms(W),ve=X.getState().rootPath;if(ue==="directory")ve&&(W===ve||W.startsWith(ve+"/"))?x(W):(await o(W),Ie(async()=>{const{useFolderStore:te}=await import("./index-DNUXcSh8.js").then(we=>we.aN);return{useFolderStore:te}},__vite__mapDeps([0,1,2,3])).then(({useFolderStore:te})=>{te.getState().setFolder(W)}));else{if(!ve){const ze=W.substring(0,W.lastIndexOf("/"));ze&&await o(ze)}const te=ae?parseInt(ae,10):void 0,we=te?{line:te,col:de?parseInt(de,10):1,query:""}:void 0;d(W,void 0,we),x(W)}};p();const S=()=>p();return window.addEventListener("hashchange",S),()=>window.removeEventListener("hashchange",S)},[]),i.useEffect(()=>{k||M(!1)},[k]),i.useEffect(()=>{k&&a&&M(!0)},[k,a,n.length]);const f=X(p=>p.pendingReveal);i.useEffect(()=>{k&&f&&a&&M(!0)},[k,f,a]),i.useEffect(()=>{if(!a)return;const p=X.getState().tabs.find(S=>S.id===a);p&&x(p.path)},[a,x]);const j=n.find(p=>p.id===a)||null,w=i.useRef(),v=i.useCallback(p=>{if(!a)return;r(a,p),clearTimeout(w.current);const S=a;w.current=setTimeout(()=>{const b=X.getState().tabs.find(W=>W.id===S);!b||!b.isDirty||c(S)},Qa)},[a,r,c]);i.useEffect(()=>()=>clearTimeout(w.current),[]),i.useEffect(()=>{const p=S=>{const b=S.metaKey||S.ctrlKey;if(b&&S.key==="p"&&!S.shiftKey&&(S.preventDefault(),u(!0)),b&&S.key==="w"&&!S.shiftKey&&(S.preventDefault(),a&&l(a)),b&&S.key==="b"&&!S.shiftKey){S.preventDefault();const W=Y.getState();W.setSidePanelCollapsed(!W.sidePanelCollapsed)}b&&S.key==="`"&&(S.preventDefault(),C())};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[a,l,C]);const P=i.useCallback(()=>{clearTimeout(w.current),a&&c(a)},[a,c]),[$,_]=i.useState({line:1,col:1,selectedChars:0,selectedLines:0}),F=i.useCallback((p,S,b,W)=>{_({line:p,col:S,selectedChars:b,selectedLines:W})},[]),[A,V]=i.useState(null),[E,h]=i.useState(1),[N,H]=i.useState(new Set),U=(j==null?void 0:j.viewMode)==="markdown"&&!N.has(j.id),q=i.useCallback(()=>{a&&H(p=>{const S=new Set(p);return S.has(a)?S.delete(a):S.add(a),S})},[a]),K=(j==null?void 0:j.viewMode)==="markdown"?U?e.jsx("button",{className:"editor-action-btn",onClick:q,title:s("editor.preview"),children:e.jsx(Cs,{size:16})}):e.jsx("button",{className:"editor-action-btn",onClick:q,title:s("editor.source"),children:e.jsx(ws,{size:16})}):null,B=i.useCallback(()=>{const p=new URLSearchParams(window.location.search);p.set("standalone","1"),window.open(`#/editor?${p.toString()}`,"_blank","noopener,noreferrer")},[]),T=e.jsxs(e.Fragment,{children:[K,e.jsx("button",{className:"editor-action-btn",onClick:B,title:s("editor.openInNewWindow"),children:e.jsx(bt,{size:16})})]}),D=Y(p=>p.activeMobilePanel),R=Y(p=>p.createBottomTerminal),I=Y(p=>p.bottomTerminals);if(i.useEffect(()=>{k&&D==="terminal"&&I.length===0&&R()},[k,D,I.length,R]),k){const p=y&&m&&e.jsx(Tt,{isOpen:y,onClose:()=>u(!1),onSelect:b=>{d(b),u(!1)},rootPath:m}),S=j?j.viewMode==="editor"||U?e.jsx("div",{className:"editor-container",children:e.jsx(kt,{path:j.path,content:j.content,language:j.language,onContentChange:v,onSave:P,minimap:!1,onCursorChange:F})}):e.jsx(Mt,{path:j.path,name:j.name,content:j.content,viewMode:j.viewMode,onImageInfo:V,onZoomChange:h}):null;return e.jsxs("div",{className:"editor-view editor-view-mobile",children:[p,e.jsxs("div",{className:"mobile-panel-content",children:[D==="explorer"&&e.jsx("div",{className:"editor-sidebar editor-sidebar-mobile",children:e.jsx(zt,{onMenuClick:t})}),D==="search"&&e.jsx(Rt,{}),D==="source-control"&&e.jsx(At,{}),D==="terminal"&&e.jsx("div",{className:"mobile-terminal-panel",children:e.jsx(Et,{})})]}),e.jsx("div",{className:`editor-mobile-panel ${L?"open":""}`,children:e.jsxs("div",{className:"editor-main",children:[e.jsxs("div",{className:"editor-mobile-header",children:[e.jsx("button",{className:"editor-mobile-back",onClick:()=>M(!1),children:e.jsx(Ns,{size:18})}),e.jsx("div",{className:"editor-mobile-tabs-wrap",children:e.jsx(St,{actions:T})})]}),S,j&&e.jsx(Nt,{language:j.language,cursorLine:$.line,cursorColumn:$.col,selectedCount:$.selectedChars,selectedLines:$.selectedLines,viewMode:U?"editor":j.viewMode,imageInfo:A,zoom:E})]})}),e.jsx(Ga,{})]})}return e.jsx("div",{className:"editor-view",children:e.jsx(Ka,{onMenuClick:t,activeTab:j,editorContent:null,mdToggleBtn:T,cursorInfo:$,imageInfo:A,previewZoom:E,isMarkdownSource:U,quickOpenVisible:y,setQuickOpenVisible:u,onContentChange:v,onSave:P,onCursorChange:F,onImageInfo:V,onZoomChange:h})})}export{en as EditorView};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import{a as p,j as e}from"./markdown-DIY6o85n.js";import{c as O,e as Z,ax as $,u as D,i as U,ay as B,az as K,aA as w,aB as J,aC as V,ar as q,r as X,aD as Y,W as Q}from"./index-DNUXcSh8.js";import"./vendor-D35k0Cos.js";/**
|
|
2
|
-
* @license lucide-react v1.18.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const ee=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],te=O("code-xml",ee);/**
|
|
7
|
-
* @license lucide-react v1.18.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const se=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],ae=O("trending-up",se),ne=Z((t,n)=>({stats:null,statsLoading:!1,statsError:null,sessionStats:null,sessionLoading:!1,sessionError:null,fetchStats:async()=>{t({statsLoading:!n().stats,statsError:null});try{t({stats:await $("/api/v1/stats"),statsLoading:!1})}catch(a){t({statsError:a.message,statsLoading:!1})}},fetchSessionStats:async()=>{t({sessionLoading:!n().sessionStats,sessionError:null});try{t({sessionStats:await $("/api/v1/stats/session"),sessionLoading:!1})}catch(a){t({sessionError:a.message,sessionLoading:!1})}},fetchAll:async()=>{await Promise.all([n().fetchStats(),n().fetchSessionStats()])}}));function k(t){return t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"k":t.toString()}function P(t){if(t<=0)return"-";const n=Math.floor(t/1e3),a=Math.floor(n/60),r=Math.floor(a/60);return r>0?`${r}h ${a%60}m ${n%60}s`:a>0?`${a}m ${n%60}s`:`${n}s`}function F(t){return t.replace(/^anthropic\./,"").replace(/^openai\./,"").replace(/-\d{8}$/,"").replace(/@.*$/,"")}function oe(t){return new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric"})}const re=["#ebedf0","#9be9a8","#40c463","#30a14e","#216e39"],ie=["#161b22","#0e4429","#006d32","#26a641","#39d353"],z=["#3b82f6","#10b981","#8b5cf6"],le=[{name:"The Little Prince",tokens:22e3},{name:"The Old Man and the Sea",tokens:35e3},{name:"A Christmas Carol",tokens:37e3},{name:"Animal Farm",tokens:39e3},{name:"Fahrenheit 451",tokens:6e4},{name:"The Great Gatsby",tokens:62e3},{name:"Brave New World",tokens:83e3},{name:"Harry Potter and the Philosopher's Stone",tokens:103e3},{name:"1984",tokens:123e3},{name:"Pride and Prejudice",tokens:156e3},{name:"Dune",tokens:244e3},{name:"A Game of Thrones",tokens:381e3},{name:"The Lord of the Rings",tokens:576e3},{name:"War and Peace",tokens:73e4}],ce=[{name:"朝花夕拾",tokens:18e3},{name:"骆驼祥子",tokens:6e4},{name:"活着",tokens:72e3},{name:"围城",tokens:84e3},{name:"三体",tokens:126e3},{name:"射雕英雄传",tokens:234e3},{name:"红楼梦",tokens:438e3},{name:"三国演义",tokens:48e4},{name:"西游记",tokens:492e3},{name:"水浒传",tokens:576e3},{name:"平凡的世界",tokens:6e5},{name:"金庸全集",tokens:636e4}],de=[{en:"a TED talk",zh:"一场 TED 演讲",minutes:18},{en:"an episode of The Office",zh:"一集《办公室》",minutes:22},{en:"listening to Abbey Road",zh:"听一遍《Abbey Road》专辑",minutes:47},{en:"a yoga class",zh:"一节瑜伽课",minutes:60},{en:"a World Cup soccer match",zh:"一场世界杯比赛",minutes:90},{en:"a half marathon (average time)",zh:"一场半程马拉松",minutes:120},{en:"the movie Inception",zh:"电影《盗梦空间》",minutes:148},{en:"watching Titanic",zh:"电影《泰坦尼克号》",minutes:195},{en:"a transatlantic flight",zh:"一趟跨大西洋航班",minutes:420},{en:"a full night of sleep",zh:"一整晚的睡眠",minutes:480}];function xe(t,n,a,r){const s=[],o=r==="zh"?ce:le;if(n>0){for(const i of o)if(n>=i.tokens){const l=n/i.tokens;s.push(l>=2?a("stats.funFact.moreTokens").replace("{times}",String(Math.floor(l))).replace("{book}",i.name):a("stats.funFact.sameTokens").replace("{book}",i.name))}}if(t.longestSession){const i=t.longestSession.duration/6e4;for(const l of de){const x=i/l.minutes;if(x>=2){const c=r==="zh"?l.zh:l.en;s.push(a("stats.funFact.longerSession").replace("{times}",String(Math.floor(x))).replace("{activity}",c))}}}return s.length===0?"":s[Math.floor(Math.random()*s.length)]}function me({dailyModelTokens:t,topModels:n}){const a=p.useMemo(()=>{const o={top:20,right:20,bottom:40,left:60},i=700-o.left-o.right,l=220-o.top-o.bottom;let x=0;for(const g of t)for(const y of n){const h=g.tokensByModel[y.id]||0;h>x&&(x=h)}x===0&&(x=1);const c=n.map((g,y)=>{const h=t.map((N,E)=>{const T=o.left+E/Math.max(t.length-1,1)*i,A=N.tokensByModel[g.id]||0,C=o.top+l-A/x*l;return`${T},${C}`});return t.some(N=>(N.tokensByModel[g.id]||0)>0)?{path:`M${h.join("L")}`,color:z[y%z.length],id:g.id,label:g.label}:null}).filter(Boolean),f=Array.from({length:5},(g,y)=>{const h=x*(1-y/4);return{y:o.top+y/4*l,label:k(Math.round(h))}}),j=Math.min(5,t.length),m=Math.max(1,Math.floor((t.length-1)/(j-1))),M=Array.from({length:j},(g,y)=>{const h=Math.min(y*m,t.length-1);return{x:o.left+h/Math.max(t.length-1,1)*i,label:oe(t[h].date)}});return{W:700,H:220,PAD:o,CW:i,CH:l,lines:c,yGridLines:f,xLabels:M}},[t,n]);return e.jsxs("div",{children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("svg",{viewBox:`0 0 ${a.W} ${a.H}`,className:"w-full min-w-[500px]",style:{maxHeight:"240px"},children:[a.yGridLines.map((r,s)=>e.jsxs("g",{children:[e.jsx("line",{x1:a.PAD.left,y1:r.y,x2:a.W-a.PAD.right,y2:r.y,className:"stroke-border-primary",strokeWidth:.5,strokeDasharray:"4 4"}),e.jsx("text",{x:a.PAD.left-8,y:r.y+4,textAnchor:"end",className:"fill-text-tertiary",fontSize:10,children:r.label})]},s)),a.lines.map((r,s)=>e.jsx("path",{d:r.path,fill:"none",stroke:r.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},s)),a.xLabels.map((r,s)=>e.jsx("text",{x:r.x,y:a.H-10,textAnchor:"middle",className:"fill-text-tertiary",fontSize:10,children:r.label},s))]})}),e.jsx("div",{className:"flex gap-4 mt-2 justify-center",children:a.lines.map(r=>e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full",style:{backgroundColor:r.color}}),e.jsx("span",{children:r.label})]},r.id))})]})}function he({stats:t}){const{t:n}=D(),a=p.useMemo(()=>Object.entries(t.modelUsage).map(([s,o])=>{const i=o.inputTokens>0?o.cacheReadInputTokens/o.inputTokens*100:0;return{name:s,shortName:o.displayName||F(s),inputTokens:o.inputTokens,outputTokens:o.outputTokens,cacheReadInputTokens:o.cacheReadInputTokens,cacheHitRate:i,total:o.inputTokens+o.outputTokens,costUSD:o.costUSD}}).sort((s,o)=>o.total-s.total),[t.modelUsage]),r=p.useMemo(()=>a.reduce((s,o)=>s+o.total,0),[a]);return a.length===0?e.jsx("div",{className:"text-center py-12 text-text-tertiary",children:n("stats.noData")}):e.jsxs(e.Fragment,{children:[t.dailyModelTokens.length>=2&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-sm font-medium text-text-primary mb-3",children:n("stats.tokensPerDay")}),e.jsx(me,{dailyModelTokens:t.dailyModelTokens,topModels:a.slice(0,3).map(s=>({id:s.name,label:s.shortName}))})]}),e.jsx("h2",{className:"text-sm font-medium text-text-primary mb-3",children:n("stats.allModels")}),e.jsx("div",{className:"space-y-3",children:a.map(s=>{const o=r>0?s.total/r*100:0;return e.jsxs("div",{className:"bg-bg-secondary rounded-lg p-3 border border-border-primary",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium text-text-primary",children:s.shortName}),e.jsxs("span",{className:"text-xs text-text-tertiary",children:[o.toFixed(1),"%"]})]}),e.jsx("div",{className:"h-1.5 bg-bg-tertiary rounded-full mb-2",children:e.jsx("div",{className:"h-full rounded-full bg-accent-brand transition-all duration-500",style:{width:`${Math.min(o,100)}%`}})}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2 text-xs text-text-secondary",children:[e.jsxs("span",{children:[n("stats.input"),": ",k(s.inputTokens)]}),e.jsxs("span",{children:[n("stats.output"),": ",k(s.outputTokens)]}),s.cacheReadInputTokens>0&&e.jsxs("span",{children:[n("stats.cacheHitRate"),": ",s.cacheHitRate.toFixed(1),"%"]}),s.costUSD>0&&e.jsxs("span",{children:[n("stats.cost"),": $",s.costUSD.toFixed(2)]})]})]},s.name)})})]})}function ue({dailyActivity:t}){const{t:n}=D(),r=U(i=>i.resolved)==="dark"?ie:re,s=p.useMemo(()=>{const j=new Map;for(const d of t)j.set(d.date,d.messageCount);const m=t.map(d=>d.messageCount).filter(d=>d>0).sort((d,L)=>d-L),M=m.length>0?m[Math.floor(m.length*.25)]:0,g=m.length>0?m[Math.floor(m.length*.5)]:0,y=m.length>0?m[Math.floor(m.length*.75)]:0,h=d=>d===0||m.length===0?0:d>=y?4:d>=g?3:d>=M?2:1,v=new Date;v.setHours(0,0,0,0);const N=new Date(v);N.setDate(v.getDate()-v.getDay());const E=new Date(N);E.setDate(E.getDate()-357);const T=[],A=[];let C=-1;const u=new Date(E);for(let d=0;d<52;d++)for(let L=0;L<7;L++){if(u>v){u.setDate(u.getDate()+1);continue}const G=u.getFullYear(),H=String(u.getMonth()+1).padStart(2,"0"),R=String(u.getDate()).padStart(2,"0"),_=`${G}-${H}-${R}`,I=j.get(_)||0;if(L===0&&u.getMonth()!==C){const W=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];A.push({text:W[u.getMonth()],x:32+d*14}),C=u.getMonth()}T.push({key:_,x:32+d*14,y:20+L*14,level:h(I),date:_,count:I}),u.setDate(u.getDate()+1)}return{cells:T,monthLabels:A,width:770,height:128,CELL_SIZE:12,TOP_PADDING:20,LEFT_PADDING:32,CELL_GAP:2}},[t]),o=["","Mon","","Wed","","Fri",""];return e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("svg",{width:s.width,height:s.height+30,viewBox:`0 0 ${s.width} ${s.height+30}`,className:"min-w-[500px]",children:[s.monthLabels.map((i,l)=>e.jsx("text",{x:i.x,y:s.TOP_PADDING-6,className:"fill-text-tertiary",fontSize:10,children:i.text},l)),o.map((i,l)=>i?e.jsx("text",{x:s.LEFT_PADDING-6,y:s.TOP_PADDING+l*(s.CELL_SIZE+s.CELL_GAP)+s.CELL_SIZE-2,className:"fill-text-tertiary",fontSize:10,textAnchor:"end",children:i},l):null),s.cells.map(i=>e.jsx("rect",{x:i.x,y:i.y,width:s.CELL_SIZE,height:s.CELL_SIZE,rx:2,fill:r[i.level],children:e.jsxs("title",{children:[i.date,": ",i.count," ",n("stats.heatmap.messages")]})},i.key)),(()=>{const i=s.height+4,l=s.LEFT_PADDING;return e.jsxs("g",{children:[e.jsx("text",{x:l,y:i+10,className:"fill-text-tertiary",fontSize:10,children:n("stats.heatmap.less")}),r.map((x,c)=>e.jsx("rect",{x:l+30+c*(s.CELL_SIZE+2),y:i,width:s.CELL_SIZE,height:s.CELL_SIZE,rx:2,fill:x},c)),e.jsx("text",{x:l+30+5*(s.CELL_SIZE+2)+4,y:i+10,className:"fill-text-tertiary",fontSize:10,children:n("stats.heatmap.more")})]})})()]})})}function pe({sessionStats:t}){const{t:n}=D(),a=p.useMemo(()=>Object.values(t.tokenUsageByModel).reduce((r,s)=>r+s.inputTokens+s.outputTokens,0),[t.tokenUsageByModel]);return e.jsxs("div",{className:"flex flex-wrap gap-3 mb-6 p-3 bg-bg-secondary/50 rounded-xl border border-border-primary/50",children:[e.jsx(S,{label:n("stats.session.title"),icon:e.jsx(te,{size:12})}),e.jsx(S,{label:n("stats.session.apiDuration"),value:P(t.apiDuration)}),e.jsx(S,{label:n("stats.session.wallTime"),value:P(t.runningTime)}),e.jsx(S,{label:n("stats.session.linesAdded"),value:`+${t.fileChangeStats.totalAddedLines}`,valueClass:"text-green-500"}),e.jsx(S,{label:n("stats.session.linesDeleted"),value:`-${t.fileChangeStats.totalDeletedLines}`,valueClass:"text-red-500"}),e.jsx(S,{label:n("stats.session.tokens"),value:k(a)})]})}function S({label:t,value:n,icon:a,valueClass:r}){return e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[a,e.jsx("span",{className:"text-text-tertiary",children:t}),n&&e.jsx("span",{className:`font-medium text-text-primary ${r||""}`,children:n})]})}function b({icon:t,label:n,value:a}){return e.jsxs("div",{className:"bg-bg-secondary rounded-xl p-4 border border-border-primary",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"text-text-tertiary",children:t}),e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:n})]}),e.jsx("div",{className:"text-lg font-semibold text-text-primary",style:{fontVariantNumeric:"tabular-nums"},children:a})]})}function fe({stats:t,sessionStats:n}){const{t:a,resolved:r}=D(),s=p.useMemo(()=>Object.entries(t.modelUsage).sort(([,c],[,f])=>f.inputTokens+f.outputTokens-(c.inputTokens+c.outputTokens)),[t.modelUsage]),o=p.useMemo(()=>s.reduce((c,[,f])=>c+f.inputTokens+f.outputTokens,0),[s]),i=p.useMemo(()=>{const c=s.reduce((j,[,m])=>j+m.inputTokens,0),f=s.reduce((j,[,m])=>j+m.cacheReadInputTokens,0);return c>0?f/c*100:0},[s]),l=s[0],x=p.useMemo(()=>xe(t,o,a,r),[t,o,a,r]);return e.jsxs(e.Fragment,{children:[n&&e.jsx(pe,{sessionStats:n}),t.dailyActivity.length>0&&e.jsx("div",{className:"mb-6",children:e.jsx(ue,{dailyActivity:t.dailyActivity})}),l&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-4",children:[e.jsx(b,{icon:e.jsx(B,{size:16}),label:a("stats.favoriteModel"),value:l[1].displayName||F(l[0])}),e.jsx(b,{icon:e.jsx(K,{size:16}),label:a("stats.totalTokens"),value:k(o)}),e.jsx(b,{icon:e.jsx(w,{size:16}),label:a("stats.cacheHitRate"),value:`${i.toFixed(1)}%`})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4 mb-6",children:[e.jsx(b,{icon:e.jsx(J,{size:16}),label:a("stats.sessions"),value:k(t.totalSessions)}),e.jsx(b,{icon:e.jsx(V,{size:16}),label:a("stats.longestSession"),value:t.longestSession?P(t.longestSession.duration):a("stats.na")}),e.jsx(b,{icon:e.jsx(ae,{size:16}),label:a("stats.activeDays"),value:`${t.activeDays}/${t.totalDays}`}),e.jsx(b,{icon:e.jsx(w,{size:16}),label:a("stats.currentStreak"),value:`${t.streaks.currentStreak} ${a("stats.days")}`}),e.jsx(b,{icon:e.jsx(w,{size:16}),label:a("stats.longestStreak"),value:`${t.streaks.longestStreak} ${a("stats.days")}`}),e.jsx(b,{icon:e.jsx(q,{size:16}),label:a("stats.peakHour"),value:t.peakActivityHour!==null?`${t.peakActivityHour}:00-${t.peakActivityHour+1}:00`:a("stats.na")})]}),x&&e.jsx("div",{className:"p-3 bg-bg-secondary/50 rounded-lg border border-border-primary/50 text-sm text-accent-brand",children:x})]})}function ge({toolUsage:t}){var s;const{t:n}=D(),a=t.slice(0,20),r=((s=a[0])==null?void 0:s.count)||0;return a.length===0?e.jsx("div",{className:"text-center py-12 text-text-tertiary",children:n("stats.noData")}):e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-sm font-medium text-text-primary mb-4",children:n("stats.topTools")}),e.jsx("div",{className:"space-y-2",children:a.map(o=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs text-text-secondary w-28 text-right truncate font-mono",children:o.toolName}),e.jsx("div",{className:"flex-1 h-6 bg-bg-tertiary rounded overflow-hidden",children:e.jsx("div",{className:"h-full bg-accent-brand/60 rounded transition-all duration-500 flex items-center pl-2",style:{width:`${Math.max(o.count/r*100,2)}%`},children:o.count/r>.15&&e.jsx("span",{className:"text-[10px] text-text-primary font-mono",children:k(o.count)})})}),o.count/r<=.15&&e.jsx("span",{className:"text-xs text-text-tertiary w-12 font-mono",children:k(o.count)})]},o.toolName))})]})}function Ne(){const{t}=D(),{stats:n,statsLoading:a,statsError:r,sessionStats:s,fetchAll:o}=ne(),[i,l]=p.useState("overview");if(p.useEffect(()=>{o()},[o]),a&&!n)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(X,{size:"large",text:t("stats.loading")})});if(r&&!n)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-text-secondary mb-4",children:r}),e.jsx("button",{onClick:o,className:"px-4 py-2 bg-accent-brand text-accent-brand-foreground rounded-lg text-sm",children:t("stats.refresh")})]})});const x=[{key:"overview",label:t("stats.tab.overview")},{key:"models",label:t("stats.tab.models")},{key:"tools",label:t("stats.tab.tools")}];return e.jsxs("div",{className:"flex-1 overflow-auto p-4 md:p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{size:20,className:"text-accent-brand"}),e.jsx("h1",{className:"text-lg font-semibold text-text-primary",children:t("stats.title")})]}),e.jsxs("button",{onClick:o,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm text-text-secondary
|
|
12
|
-
hover:text-text-primary hover:bg-bg-hover rounded-lg transition-colors`,title:t("stats.refresh"),children:[e.jsx(Q,{size:14}),e.jsx("span",{children:t("stats.refresh")})]})]}),e.jsx("div",{className:"flex gap-1 mb-6 bg-bg-secondary rounded-lg p-1 w-fit",children:x.map(c=>e.jsx("button",{onClick:()=>l(c.key),className:`px-4 py-1.5 text-sm rounded-md transition-colors ${i===c.key?"bg-bg-primary text-text-primary font-medium shadow-sm":"text-text-secondary hover:text-text-primary"}`,children:c.label},c.key))}),n?e.jsxs(e.Fragment,{children:[i==="overview"&&e.jsx(fe,{stats:n,sessionStats:s}),i==="models"&&e.jsx(he,{stats:n}),i==="tools"&&e.jsx(ge,{toolUsage:n.toolUsage}),e.jsx("div",{className:"mt-8 text-xs text-text-tertiary text-center",children:t("stats.timeRange").replace("{days}",String(n.totalDays))})]}):e.jsx("div",{className:"text-center py-12 text-text-tertiary",children:t("stats.noData")})]})}export{Ne as StatsView};
|