wind-agent-cli 1.38.2 → 1.39.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/README.md +8 -1
- package/dist/api-docs.html +4 -3
- package/dist/assets/{CodeEditor-C6BtLdoC.js → CodeEditor-C8eMIGen.js} +1 -1
- package/dist/assets/{FileTree-CGxNFZda.js → FileTree-D52nAPO4.js} +1 -1
- package/dist/assets/{GitPanel-BV-IAyEC.js → GitPanel-DgeKbZsW.js} +1 -1
- package/dist/assets/{MarkdownPreview-DVoEzpoc.js → MarkdownPreview-B00VQTx6.js} +1 -1
- package/dist/assets/{Shell-CUTO-THd.js → Shell-twzi9t5B.js} +7 -7
- package/dist/assets/{StandaloneShell-BKM1qxUc.js → StandaloneShell-DH_GBJMj.js} +1 -1
- package/dist/assets/{TaskMasterPanel-DDDCVF6M.js → TaskMasterPanel-BY-pMPMl.js} +2 -2
- package/dist/assets/{abnfDiagram-N423BO3Z-Crubtav6.js → abnfDiagram-N423BO3Z-BwBdstkH.js} +1 -1
- package/dist/assets/{arc-h9xb7EWA.js → arc-C0IOpbFP.js} +1 -1
- package/dist/assets/{architectureDiagram-T3A2C74G-BmMQp4MC.js → architectureDiagram-T3A2C74G-C-Wkj_AY.js} +1 -1
- package/dist/assets/{blockDiagram-VBNYF7ZC-BtD-zDnJ.js → blockDiagram-VBNYF7ZC-_sXAZKku.js} +1 -1
- package/dist/assets/{c4Diagram-5PPSVZJV-D18s6J-v.js → c4Diagram-5PPSVZJV-C0DUsZv8.js} +1 -1
- package/dist/assets/channel-B6xiB58V.js +1 -0
- package/dist/assets/{chunk-2GRJ4B5K-BHIcCvB_.js → chunk-2GRJ4B5K-D2TFB_6A.js} +1 -1
- package/dist/assets/{chunk-2Q5K7J3B-DcX4AeRe.js → chunk-2Q5K7J3B-B_co_2bI.js} +1 -1
- package/dist/assets/{chunk-5RXB4S5H-CZwYDv9K.js → chunk-5RXB4S5H-BcUSLq4H.js} +1 -1
- package/dist/assets/{chunk-5VM5RSS4-CR-F7R13.js → chunk-5VM5RSS4-0mQFBKSp.js} +1 -1
- package/dist/assets/{chunk-6Q2QTUOP-BPP216SB.js → chunk-6Q2QTUOP-BAkqmW1M.js} +1 -1
- package/dist/assets/{chunk-GF5L2VYU-CcFeSmHe.js → chunk-GF5L2VYU-Cyz0Xl7f.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-C5T_9-OI.js → chunk-JWPE2WC7-DYO47aT-.js} +1 -1
- package/dist/assets/{chunk-KBJHAD2P-g5eR5X5h.js → chunk-KBJHAD2P-DvXEzV8J.js} +1 -1
- package/dist/assets/{chunk-RYQCIY6F-76WBDsoZ.js → chunk-RYQCIY6F-Beut8dYt.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-DGuy3LLn.js → chunk-XXDRQBXY-DLIy1GFl.js} +1 -1
- package/dist/assets/classDiagram-JCYQIIEL-C7xIPTll.js +1 -0
- package/dist/assets/classDiagram-v2-OCEON4UE-C7xIPTll.js +1 -0
- package/dist/assets/{cose-bilkent-JH36ORCC-Cg4R1M0H.js → cose-bilkent-JH36ORCC-DynbO4dj.js} +1 -1
- package/dist/assets/{cynefin-VYW2F7L2-Cbmals-o.js → cynefin-VYW2F7L2-CYTJsH3o.js} +1 -1
- package/dist/assets/{cynefinDiagram-MW4NZA55-CI79hpHc.js → cynefinDiagram-MW4NZA55-ftj-lAeE.js} +1 -1
- package/dist/assets/{dagre-VZM6K2ZE-r3Uz8Fhv.js → dagre-VZM6K2ZE-C1kSFboe.js} +1 -1
- package/dist/assets/{diagram-7IWD3JNH-ClRIkmQw.js → diagram-7IWD3JNH-CqXHTFrY.js} +1 -1
- package/dist/assets/{diagram-B4RE2ZJO-C71qkNlS.js → diagram-B4RE2ZJO-B84n3Zko.js} +1 -1
- package/dist/assets/{diagram-LBJQPF4R-CC7ShhCC.js → diagram-LBJQPF4R-B710SefS.js} +1 -1
- package/dist/assets/{diagram-Q27KOJAE-DPHL4vnP.js → diagram-Q27KOJAE-CmVPl9pq.js} +1 -1
- package/dist/assets/{diagram-UB23O5K3-CP_My5E9.js → diagram-UB23O5K3-LozbeaFL.js} +1 -1
- package/dist/assets/{ebnfDiagram-BXEA7PRR-BQe4AU9Z.js → ebnfDiagram-BXEA7PRR-B321UBUA.js} +1 -1
- package/dist/assets/{erDiagram-JOGREHBK-CFidQ-d5.js → erDiagram-JOGREHBK-CTbw676k.js} +1 -1
- package/dist/assets/feature-chat-pY0kOrz2.js +88 -0
- package/dist/assets/feature-workspace-FLomYkPq.js +39 -0
- package/dist/assets/{flowDiagram-UKHOOZJN-X5fPFxbp.js → flowDiagram-UKHOOZJN-BWVKTWlw.js} +1 -1
- package/dist/assets/{ganttDiagram-PKOTCBZU-CILFHjP8.js → ganttDiagram-PKOTCBZU-BAj9eeeX.js} +1 -1
- package/dist/assets/{gitGraphDiagram-DS77QQ5N-DCQCtC_g.js → gitGraphDiagram-DS77QQ5N-DcVMRU7N.js} +1 -1
- package/dist/assets/{index-cNARKAN2.js → index-BYFstHFT.js} +1 -1
- package/dist/assets/index-BbBSplOU.js +35 -0
- package/dist/assets/{index-D0vbG70l.js → index-BrWTp075.js} +1 -1
- package/dist/assets/index-CHukVVB2.css +1 -0
- package/dist/assets/{index-Bo9nFrtn.js → index-k9M0VaFg.js} +1 -1
- package/dist/assets/{infoDiagram-6WML65LV-Da145n1G.js → infoDiagram-6WML65LV-V6wz33B4.js} +1 -1
- package/dist/assets/{ishikawaDiagram-WSZJBQD7-DGUP61eq.js → ishikawaDiagram-WSZJBQD7-Dd-WNPyK.js} +1 -1
- package/dist/assets/{journeyDiagram-NVQOT4AX-BqfnKWDJ.js → journeyDiagram-NVQOT4AX-D9VCuCeA.js} +1 -1
- package/dist/assets/{kanban-definition-27J2QSJJ-US6pQfNy.js → kanban-definition-27J2QSJJ-CUtwDOl-.js} +1 -1
- package/dist/assets/{linear-d91wK5kZ.js → linear-D_XGf1jO.js} +1 -1
- package/dist/assets/{mermaid.core-BsWqrIaW.js → mermaid.core-DOnsXioB.js} +4 -4
- package/dist/assets/{mindmap-definition-FAOFIHXS-CXWD2UbS.js → mindmap-definition-FAOFIHXS-DAYNL5ZV.js} +1 -1
- package/dist/assets/{pegDiagram-VL7TDLO6-BVzfDR-8.js → pegDiagram-VL7TDLO6-B5FX3-E6.js} +1 -1
- package/dist/assets/{pieDiagram-7S7Q4E2Y-PNpHZnJ9.js → pieDiagram-7S7Q4E2Y-EbnDBVd0.js} +1 -1
- package/dist/assets/{quadrantDiagram-CIZ2JOQS-DxCI4i3K.js → quadrantDiagram-CIZ2JOQS-C1koOtwT.js} +1 -1
- package/dist/assets/{railroadDiagram-AXF67PYL-BYkvo3om.js → railroadDiagram-AXF67PYL-D52xmshj.js} +1 -1
- package/dist/assets/{requirementDiagram-LRYGKXZP-LUtvOYtV.js → requirementDiagram-LRYGKXZP-B7VbfNnW.js} +1 -1
- package/dist/assets/{sankeyDiagram-W5VNT64P-CVyI8YeM.js → sankeyDiagram-W5VNT64P-CeRG1vHN.js} +1 -1
- package/dist/assets/{sequenceDiagram-SI44F4Z6-1vuRFolM.js → sequenceDiagram-SI44F4Z6-CfKHnmSE.js} +1 -1
- package/dist/assets/{sizeCapture-X5ZJPWSS-o4oVZXe8.js → sizeCapture-X5ZJPWSS-DJTzyd0S.js} +1 -1
- package/dist/assets/{stateDiagram-OKZ733FA-WedLIlXF.js → stateDiagram-OKZ733FA-DN0c7IYD.js} +1 -1
- package/dist/assets/stateDiagram-v2-UEYNNEHI-DbihlVOQ.js +1 -0
- package/dist/assets/{swimlanes-SLNWSIFB-CpeXuk67.js → swimlanes-SLNWSIFB-CaaJpBDA.js} +2 -2
- package/dist/assets/swimlanesDiagram-ULZ7WXOC-BBRevuGP.js +8 -0
- package/dist/assets/{timeline-definition-Z64GVDOM-DFcPWe47.js → timeline-definition-Z64GVDOM-CrzHN7d2.js} +1 -1
- package/dist/assets/{vennDiagram-T6HMQDX7-BH8C1C49.js → vennDiagram-T6HMQDX7-BTldHIjo.js} +1 -1
- package/dist/assets/{wardleyDiagram-T6FBY63Y-K1Ew0uit.js → wardleyDiagram-T6FBY63Y-D9Y50OsZ.js} +1 -1
- package/dist/assets/{xychartDiagram-ELKLHX3M-CQHlqWY2.js → xychartDiagram-ELKLHX3M-DjxSJ3aF.js} +1 -1
- package/dist/favicon.png +0 -0
- package/dist/icons/icon-128x128.png +0 -0
- package/dist/icons/icon-144x144.png +0 -0
- package/dist/icons/icon-152x152.png +0 -0
- package/dist/icons/icon-180x180.png +0 -0
- package/dist/icons/icon-192x192.png +0 -0
- package/dist/icons/icon-384x384.png +0 -0
- package/dist/icons/icon-512x512.png +0 -0
- package/dist/icons/icon-72x72.png +0 -0
- package/dist/icons/icon-96x96.png +0 -0
- package/dist/icons/icon-maskable-192x192.png +0 -0
- package/dist/icons/icon-maskable-512x512.png +0 -0
- package/dist/icons/new.png +0 -0
- package/dist/index.html +4 -4
- package/dist/logo-128.png +0 -0
- package/dist/logo-256.png +0 -0
- package/dist/sw.js +1 -1
- package/dist-server/server/index.js +2 -0
- package/dist-server/server/index.js.map +1 -1
- package/dist-server/server/modules/agent/agent.routes.js +14 -2
- package/dist-server/server/modules/agent/agent.routes.js.map +1 -1
- package/dist-server/server/modules/agent/tests/agent.routes.test.js +1 -0
- package/dist-server/server/modules/agent/tests/agent.routes.test.js.map +1 -1
- package/dist-server/server/modules/commands/commands.routes.js +2 -1
- package/dist-server/server/modules/commands/commands.routes.js.map +1 -1
- package/dist-server/server/modules/database/migrations.js +43 -0
- package/dist-server/server/modules/database/migrations.js.map +1 -1
- package/dist-server/server/modules/database/tests/projects.db.integration.test.js +24 -1
- package/dist-server/server/modules/database/tests/projects.db.integration.test.js.map +1 -1
- package/dist-server/server/modules/notifications/services/notification-orchestrator.service.js +2 -0
- package/dist-server/server/modules/notifications/services/notification-orchestrator.service.js.map +1 -1
- package/dist-server/server/modules/providers/list/opencode/opencode-session-synchronizer.provider.js +10 -1
- package/dist-server/server/modules/providers/list/opencode/opencode-session-synchronizer.provider.js.map +1 -1
- package/dist-server/server/modules/providers/list/pi/index.js +5 -0
- package/dist-server/server/modules/providers/list/pi/index.js.map +1 -0
- package/dist-server/server/modules/providers/list/pi/pi-auth.provider.js +55 -0
- package/dist-server/server/modules/providers/list/pi/pi-auth.provider.js.map +1 -0
- package/dist-server/server/modules/providers/list/pi/pi-mcp.provider.js +23 -0
- package/dist-server/server/modules/providers/list/pi/pi-mcp.provider.js.map +1 -0
- package/dist-server/server/modules/providers/list/pi/pi-models.provider.js +99 -0
- package/dist-server/server/modules/providers/list/pi/pi-models.provider.js.map +1 -0
- package/dist-server/server/modules/providers/list/pi/pi-runtime.provider.js +262 -0
- package/dist-server/server/modules/providers/list/pi/pi-runtime.provider.js.map +1 -0
- package/dist-server/server/modules/providers/list/pi/pi-session-synchronizer.provider.js +136 -0
- package/dist-server/server/modules/providers/list/pi/pi-session-synchronizer.provider.js.map +1 -0
- package/dist-server/server/modules/providers/list/pi/pi-sessions.provider.js +225 -0
- package/dist-server/server/modules/providers/list/pi/pi-sessions.provider.js.map +1 -0
- package/dist-server/server/modules/providers/list/pi/pi-skills.provider.js +31 -0
- package/dist-server/server/modules/providers/list/pi/pi-skills.provider.js.map +1 -0
- package/dist-server/server/modules/providers/list/pi/pi.provider.js +22 -0
- package/dist-server/server/modules/providers/list/pi/pi.provider.js.map +1 -0
- package/dist-server/server/modules/providers/provider.registry.js +2 -0
- package/dist-server/server/modules/providers/provider.registry.js.map +1 -1
- package/dist-server/server/modules/providers/provider.routes.js +2 -1
- package/dist-server/server/modules/providers/provider.routes.js.map +1 -1
- package/dist-server/server/modules/providers/services/provider-capabilities.service.js +26 -0
- package/dist-server/server/modules/providers/services/provider-capabilities.service.js.map +1 -1
- package/dist-server/server/modules/providers/services/session-synchronizer.service.js +1 -0
- package/dist-server/server/modules/providers/services/session-synchronizer.service.js.map +1 -1
- package/dist-server/server/modules/providers/services/sessions-watcher.service.js +5 -0
- package/dist-server/server/modules/providers/services/sessions-watcher.service.js.map +1 -1
- package/dist-server/server/modules/providers/tests/mcp.test.js +4 -2
- package/dist-server/server/modules/providers/tests/mcp.test.js.map +1 -1
- package/dist-server/server/modules/providers/tests/opencode-sessions.test.js +56 -5
- package/dist-server/server/modules/providers/tests/opencode-sessions.test.js.map +1 -1
- package/dist-server/server/modules/providers/tests/pi-provider.test.js +244 -0
- package/dist-server/server/modules/providers/tests/pi-provider.test.js.map +1 -0
- package/dist-server/server/modules/providers/tests/provider-runtime.service.test.js +9 -0
- package/dist-server/server/modules/providers/tests/provider-runtime.service.test.js.map +1 -1
- package/dist-server/server/shared/utils.js +19 -0
- package/dist-server/server/shared/utils.js.map +1 -1
- package/package.json +1 -1
- package/public/api-docs.html +4 -3
- package/scripts/generate-pwa-icons.ps1 +1 -1
- package/server/index.ts +2 -0
- package/server/modules/agent/agent.module.ts +1 -1
- package/server/modules/agent/agent.routes.ts +15 -2
- package/server/modules/agent/tests/agent.routes.test.ts +1 -0
- package/server/modules/commands/commands.routes.ts +2 -1
- package/server/modules/database/migrations.ts +52 -0
- package/server/modules/database/tests/projects.db.integration.test.ts +28 -1
- package/server/modules/notifications/services/notification-orchestrator.service.js +2 -0
- package/server/modules/providers/README.md +5 -1
- package/server/modules/providers/list/opencode/opencode-session-synchronizer.provider.ts +18 -0
- package/server/modules/providers/list/pi/index.ts +4 -0
- package/server/modules/providers/list/pi/pi-auth.provider.ts +58 -0
- package/server/modules/providers/list/pi/pi-mcp.provider.ts +33 -0
- package/server/modules/providers/list/pi/pi-models.provider.ts +114 -0
- package/server/modules/providers/list/pi/pi-runtime.provider.ts +271 -0
- package/server/modules/providers/list/pi/pi-session-synchronizer.provider.ts +134 -0
- package/server/modules/providers/list/pi/pi-sessions.provider.ts +206 -0
- package/server/modules/providers/list/pi/pi-skills.provider.ts +37 -0
- package/server/modules/providers/list/pi/pi.provider.ts +33 -0
- package/server/modules/providers/provider.registry.ts +2 -0
- package/server/modules/providers/provider.routes.ts +1 -0
- package/server/modules/providers/services/provider-capabilities.service.ts +32 -0
- package/server/modules/providers/services/session-synchronizer.service.ts +1 -0
- package/server/modules/providers/services/sessions-watcher.service.ts +5 -0
- package/server/modules/providers/tests/mcp.test.ts +4 -2
- package/server/modules/providers/tests/opencode-sessions.test.ts +81 -6
- package/server/modules/providers/tests/pi-provider.test.ts +244 -0
- package/server/modules/providers/tests/provider-runtime.service.test.ts +10 -0
- package/server/shared/types.ts +1 -1
- package/server/shared/utils.ts +23 -0
- package/dist/assets/channel-CuR3zGvy.js +0 -1
- package/dist/assets/classDiagram-JCYQIIEL-BWpl-4NG.js +0 -1
- package/dist/assets/classDiagram-v2-OCEON4UE-BWpl-4NG.js +0 -1
- package/dist/assets/feature-chat-CHKsDTs-.js +0 -88
- package/dist/assets/feature-workspace-BodovOw6.js +0 -39
- package/dist/assets/index-Bn37f1jp.js +0 -35
- package/dist/assets/index-Cr5MbHuj.css +0 -1
- package/dist/assets/stateDiagram-v2-UEYNNEHI-BqzvLVVB.js +0 -1
- package/dist/assets/swimlanesDiagram-ULZ7WXOC-CeI6fByR.js +0 -8
- package/dist/icons/new-icon.png +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# WindCli
|
|
2
2
|
|
|
3
|
-
A web-based UI for Claude Code, Codex, Cursor CLI, and
|
|
3
|
+
A web-based UI for Claude Code, Codex, Cursor CLI, OpenCode, and Pi Coding Agent.
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
@@ -12,6 +12,13 @@ grateful to the original project and its contributors for the foundation.
|
|
|
12
12
|
|
|
13
13
|
Requires Node.js 22 or newer.
|
|
14
14
|
|
|
15
|
+
Pi support uses the external `pi` executable from
|
|
16
|
+
`@earendil-works/pi-coding-agent` 0.84.2 or newer. Install it separately and
|
|
17
|
+
authenticate a model in the Pi TUI with `/login` (or configure the relevant
|
|
18
|
+
provider environment variable). WindCli does not read or manage upstream API
|
|
19
|
+
keys. Pi sessions are discovered from `PI_CODING_AGENT_SESSION_DIR`, then the
|
|
20
|
+
global Pi `sessionDir` setting, then `~/.pi/agent/sessions`.
|
|
21
|
+
|
|
15
22
|
```sh
|
|
16
23
|
npx wind-agent-cli
|
|
17
24
|
```
|
package/dist/api-docs.html
CHANGED
|
@@ -489,7 +489,7 @@
|
|
|
489
489
|
<span class="endpoint-path"><span class="api-url">http://localhost:3001</span>/api/agent</span>
|
|
490
490
|
</div>
|
|
491
491
|
|
|
492
|
-
<p>Trigger an AI agent (Claude, Cursor, Codex, or
|
|
492
|
+
<p>Trigger an AI agent (Claude, Cursor, Codex, OpenCode, or Pi) to work on a project.</p>
|
|
493
493
|
|
|
494
494
|
<h4>Request Body Parameters</h4>
|
|
495
495
|
<table>
|
|
@@ -537,14 +537,14 @@
|
|
|
537
537
|
<td>string</td>
|
|
538
538
|
<td><span class="badge badge-optional">Optional</span></td>
|
|
539
539
|
<td id="model-options-cell">
|
|
540
|
-
Model identifier for the AI provider (loading from
|
|
540
|
+
Model identifier for the AI provider. Pi model identifiers use the complete <code>provider/model</code> value (loading from providers...)
|
|
541
541
|
</td>
|
|
542
542
|
</tr>
|
|
543
543
|
<tr>
|
|
544
544
|
<td><code>effort</code></td>
|
|
545
545
|
<td>string</td>
|
|
546
546
|
<td><span class="badge badge-optional">Optional</span></td>
|
|
547
|
-
<td>Reasoning effort for Claude, Codex, and
|
|
547
|
+
<td>Reasoning effort for Claude, Codex, OpenCode, and Pi models that expose effort metadata. Pi accepts <code>off</code>, <code>minimal</code>, <code>low</code>, <code>medium</code>, <code>high</code>, <code>xhigh</code>, and <code>max</code>. Use <code>default</code> or omit it to let the provider decide.</td>
|
|
548
548
|
</tr>
|
|
549
549
|
<tr>
|
|
550
550
|
<td><code>cleanup</code></td>
|
|
@@ -839,6 +839,7 @@ data: {"type":"done"}</code></pre>
|
|
|
839
839
|
{ id: 'codex', name: 'OpenAI' },
|
|
840
840
|
{ id: 'cursor', name: 'Cursor' },
|
|
841
841
|
{ id: 'opencode', name: 'OpenCode' },
|
|
842
|
+
{ id: 'pi', name: 'Pi' },
|
|
842
843
|
];
|
|
843
844
|
|
|
844
845
|
async function populateModels() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as S,j as h}from"./vendor-react-C2GTiUCy.js";import{T as zt,P as _t,E as U,S as he,g as kn,V as Se,F as ye,a as Ge,b as Te,D,G as Le,W as Ne,l as Ct,h as Ce,C as Pn,c as $n,d as Et,L as Ut,s as Vt,t as x,e as Gt,f as Lt,i as Nt,j as He,k as Mt,n as Zt,p as be,q as qn,r as $e,u as jn,v as Wn,N as Rn,I as Xn,w as zn,x as G,y as te,z as _n,A as Cn,B as En,H as Un,J as Je,K as Vn,O as Gn,Q as Ln,m as Nn,U as Mn,X as Zn,Y as An,Z as Dn,_ as In,M as Bn,R as Yn,o as Fn}from"./MarkdownPreview-DVoEzpoc.js";import{c as Ke,g as Hn,a as Jn,h as Kn,u as er}from"./feature-workspace-BodovOw6.js";import{o as tr,q as nr,bq as rr,a9 as et,S as ir,aa as or,at as ar,b2 as sr,b3 as Or,X as lr}from"./vendor-ui-CAUHSABu.js";import{u as dr}from"./vendor-i18n-B6HjLCnN.js";import"./vendor-markdown-DkITEES2.js";import"./feature-chat-CHKsDTs-.js";import"./vendor-data-DsEZeNPr.js";class q{constructor(t,n,i,o){this.fromA=t,this.toA=n,this.fromB=i,this.toB=o}offset(t,n=t){return new q(this.fromA+t,this.toA+t,this.fromB+n,this.toB+n)}}function J(e,t,n,i,o,r){if(e==i)return[];let s=Ze(e,t,n,i,o,r),a=Ae(e,t+s,n,i,o+s,r);t+=s,n-=a,o+=s,r-=a;let d=n-t,c=r-o;if(!d||!c)return[new q(t,n,o,r)];if(d>c){let O=e.slice(t,n).indexOf(i.slice(o,r));if(O>-1)return[new q(t,t+O,o,o),new q(t+O+c,n,r,r)]}else if(c>d){let O=i.slice(o,r).indexOf(e.slice(t,n));if(O>-1)return[new q(t,t,o,o+O),new q(n,n,o+O+d,r)]}if(d==1||c==1)return[new q(t,n,o,r)];let l=It(e,t,n,i,o,r);if(l){let[O,f,m]=l;return J(e,t,O,i,o,f).concat(J(e,O+m,n,i,f+m,r))}return cr(e,t,n,i,o,r)}let se=1e9,Oe=0,Me=!1;function cr(e,t,n,i,o,r){let s=n-t,a=r-o;if(se<1e9&&Math.min(s,a)>se*16||Oe>0&&Date.now()>Oe)return Math.min(s,a)>se*64?[new q(t,n,o,r)]:tt(e,t,n,i,o,r);let d=Math.ceil((s+a)/2);qe.reset(d),je.reset(d);let c=(m,u)=>e.charCodeAt(t+m)==i.charCodeAt(o+u),l=(m,u)=>e.charCodeAt(n-m-1)==i.charCodeAt(r-u-1),O=(s-a)%2!=0?je:null,f=O?null:qe;for(let m=0;m<d;m++){if(m>se||Oe>0&&!(m&63)&&Date.now()>Oe)return tt(e,t,n,i,o,r);let u=qe.advance(m,s,a,d,O,!1,c)||je.advance(m,s,a,d,f,!0,l);if(u)return hr(e,t,n,t+u[0],i,o,r,o+u[1])}return[new q(t,n,o,r)]}class At{constructor(){this.vec=[]}reset(t){this.len=t<<1;for(let n=0;n<this.len;n++)this.vec[n]=-1;this.vec[t+1]=0,this.start=this.end=0}advance(t,n,i,o,r,s,a){for(let d=-t+this.start;d<=t-this.end;d+=2){let c=o+d,l=d==-t||d!=t&&this.vec[c-1]<this.vec[c+1]?this.vec[c+1]:this.vec[c-1]+1,O=l-d;for(;l<n&&O<i&&a(l,O);)l++,O++;if(this.vec[c]=l,l>n)this.end+=2;else if(O>i)this.start+=2;else if(r){let f=o+(n-i)-d;if(f>=0&&f<this.len&&r.vec[f]!=-1)if(s){let m=r.vec[f];if(m>=n-l)return[m,o+m-f]}else{let m=n-r.vec[f];if(l>=m)return[l,O]}}}return null}}const qe=new At,je=new At;function hr(e,t,n,i,o,r,s,a){let d=!1;return!ne(e,i)&&++i==n&&(d=!0),!ne(o,a)&&++a==s&&(d=!0),d?[new q(t,n,r,s)]:J(e,t,i,o,r,a).concat(J(e,i,n,o,a,s))}function Dt(e,t){let n=1,i=Math.min(e,t);for(;n<i;)n=n<<1;return n}function Ze(e,t,n,i,o,r){if(t==n||t==r||e.charCodeAt(t)!=i.charCodeAt(o))return 0;let s=Dt(n-t,r-o);for(let a=t,d=o;;){let c=a+s,l=d+s;if(c>n||l>r||e.slice(a,c)!=i.slice(d,l)){if(s==1)return a-t-(ne(e,a)?0:1);s=s>>1}else{if(c==n||l==r)return c-t;a=c,d=l}}}function Ae(e,t,n,i,o,r){if(t==n||o==r||e.charCodeAt(n-1)!=i.charCodeAt(r-1))return 0;let s=Dt(n-t,r-o);for(let a=n,d=r;;){let c=a-s,l=d-s;if(c<t||l<o||e.slice(c,a)!=i.slice(l,d)){if(s==1)return n-a-(ne(e,a)?0:1);s=s>>1}else{if(c==t||l==o)return n-c;a=c,d=l}}}function Ee(e,t,n,i,o,r,s,a){let d=i.slice(o,r),c=null;for(;;){if(c||s<a)return c;for(let l=t+s;;){ne(e,l)||l++;let O=l+s;if(ne(e,O)||(O+=O==l+1?1:-1),O>=n)break;let f=e.slice(l,O),m=-1;for(;(m=d.indexOf(f,m+1))!=-1;){let u=Ze(e,O,n,i,o+m+f.length,r),g=Ae(e,t,l,i,o,o+m),p=f.length+u+g;(!c||c[2]<p)&&(c=[l-g,o+m-g,p])}l=O}if(a<0)return c;s=s>>1}}function It(e,t,n,i,o,r){let s=n-t,a=r-o;if(s<a){let d=It(i,o,r,e,t,n);return d&&[d[1],d[0],d[2]]}return s<4||a*2<s?null:Ee(e,t,n,i,o,r,Math.floor(s/4),-1)}function tt(e,t,n,i,o,r){Me=!0;let s=n-t,a=r-o,d;if(s<a){let f=Ee(i,o,r,e,t,n,Math.floor(s/6),50);d=f&&[f[1],f[0],f[2]]}else d=Ee(e,t,n,i,o,r,Math.floor(a/6),50);if(!d)return[new q(t,n,o,r)];let[c,l,O]=d;return J(e,t,c,i,o,l).concat(J(e,c+O,n,i,l+O,r))}function Bt(e,t){for(let n=1;n<e.length;n++){let i=e[n-1],o=e[n];i.toA>o.fromA-t&&i.toB>o.fromB-t&&(e[n-1]=new q(i.fromA,o.toA,i.fromB,o.toB),e.splice(n--,1))}}function fr(e,t,n){for(;;){Bt(n,1);let i=!1;for(let o=0;o<n.length;o++){let r=n[o],s,a;(s=Ze(e,r.fromA,r.toA,t,r.fromB,r.toB))&&(r=n[o]=new q(r.fromA+s,r.toA,r.fromB+s,r.toB)),(a=Ae(e,r.fromA,r.toA,t,r.fromB,r.toB))&&(r=n[o]=new q(r.fromA,r.toA-a,r.fromB,r.toB-a));let d=r.toA-r.fromA,c=r.toB-r.fromB;if(d&&c)continue;let l=r.fromA-(o?n[o-1].toA:0),O=(o<n.length-1?n[o+1].fromA:e.length)-r.toA;if(!l||!O)continue;let f=d?e.slice(r.fromA,r.toA):t.slice(r.fromB,r.toB);l<=f.length&&e.slice(r.fromA-l,r.fromA)==f.slice(f.length-l)?(n[o]=new q(r.fromA-l,r.toA-l,r.fromB-l,r.toB-l),i=!0):O<=f.length&&e.slice(r.toA,r.toA+O)==f.slice(0,O)&&(n[o]=new q(r.fromA+O,r.toA+O,r.fromB+O,r.toB+O),i=!0)}if(!i)break}return n}function mr(e,t,n){for(let i=0,o=0;o<e.length;o++){let r=e[o],s=r.toA-r.fromA,a=r.toB-r.fromB;if(s&&a||s>3||a>3){let d=o==e.length-1?t.length:e[o+1].fromA,c=r.fromA-i,l=d-r.toA,O=rt(t,r.fromA,c),f=nt(t,r.toA,l),m=r.fromA-O,u=f-r.toA;if((!s||!a)&&m&&u){let g=Math.max(s,a),[p,Q,k]=s?[t,r.fromA,r.toA]:[n,r.fromB,r.toB];g>m&&t.slice(O,r.fromA)==p.slice(k-m,k)?(r=e[o]=new q(O,O+s,r.fromB-m,r.toB-m),O=r.fromA,f=nt(t,r.toA,d-r.toA)):g>u&&t.slice(r.toA,f)==p.slice(Q,Q+u)&&(r=e[o]=new q(f-s,f,r.fromB+u,r.toB+u),f=r.toA,O=rt(t,r.fromA,r.fromA-i)),m=r.fromA-O,u=f-r.toA}if(m||u)r=e[o]=new q(r.fromA-m,r.toA+u,r.fromB-m,r.toB+u);else if(s){if(!a){let g=ot(t,r.fromA,r.toA),p,Q=g<0?-1:it(t,r.toA,r.fromA);g>-1&&(p=g-r.fromA)<=l&&t.slice(r.fromA,g)==t.slice(r.toA,r.toA+p)?r=e[o]=r.offset(p):Q>-1&&(p=r.toA-Q)<=c&&t.slice(r.fromA-p,r.fromA)==t.slice(Q,r.toA)&&(r=e[o]=r.offset(-p))}}else{let g=ot(n,r.fromB,r.toB),p,Q=g<0?-1:it(n,r.toB,r.fromB);g>-1&&(p=g-r.fromB)<=l&&n.slice(r.fromB,g)==n.slice(r.toB,r.toB+p)?r=e[o]=r.offset(p):Q>-1&&(p=r.toB-Q)<=c&&n.slice(r.fromB-p,r.fromB)==n.slice(Q,r.toB)&&(r=e[o]=r.offset(-p))}}i=r.toA}return Bt(e,3),e}let H;try{H=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch{}function Yt(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function Ft(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?Yt(n)?1:0:H?!Kt(n)||t==e.length-1?H.test(String.fromCharCode(n))?1:0:H.test(e.slice(t,t+2))?2:0:0}function Ht(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?Yt(n)?1:0:H?!en(n)||t==1?H.test(String.fromCharCode(n))?1:0:H.test(e.slice(t-2,t))?2:0:0}const Jt=8;function nt(e,t,n){if(t==e.length||!Ht(e,t))return t;for(let i=t,o=t+n,r=0;r<Jt;r++){let s=Ft(e,i);if(!s||i+s>o)return i;i+=s}return t}function rt(e,t,n){if(!t||!Ft(e,t))return t;for(let i=t,o=t-n,r=0;r<Jt;r++){let s=Ht(e,i);if(!s||i-s<o)return i;i-=s}return t}function it(e,t,n){for(;t!=n;t--)if(e.charCodeAt(t-1)==10)return t;return-1}function ot(e,t,n){for(;t!=n;t++)if(e.charCodeAt(t)==10)return t;return-1}const Kt=e=>e>=55296&&e<=56319,en=e=>e>=56320&&e<=57343;function ne(e,t){return!t||t==e.length||!Kt(e.charCodeAt(t-1))||!en(e.charCodeAt(t))}function ur(e,t,n){var i;return se=((i=n?.scanLimit)!==null&&i!==void 0?i:1e9)>>1,Oe=n?.timeout?Date.now()+n.timeout:0,Me=!1,fr(e,t,J(e,0,e.length,t,0,t.length))}function tn(){return!Me}function nn(e,t,n){return mr(ur(e,t,n),e,t)}const A=ye.define({combine:e=>e[0]}),gr=Ge.define(),rn=ye.define(),C=he.define({create(e){return null},update(e,t){for(let n of t.effects)n.is(gr)&&(e=n.value);for(let n of t.state.facet(rn))e=n(e,t);return e}});function De(e){let t=e.field(C,!1);if(!t)return null;let n=e.facet(A);return{chunks:t,side:n?n.side:null}}class ee{constructor(t,n,i,o,r,s=!0){this.changes=t,this.fromA=n,this.toA=i,this.fromB=o,this.toB=r,this.precise=s}offset(t,n){return t||n?new ee(this.changes,this.fromA+t,this.toA+t,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(t,n,i){let o=nn(t.toString(),n.toString(),i);return on(o,t,n,0,0,tn())}static updateA(t,n,i,o,r){return dt(lt(t,o,!0,i.length),t,n,i,r)}static updateB(t,n,i,o,r){return dt(lt(t,o,!1,n.length),t,n,i,r)}}function at(e,t,n,i){let o=n.lineAt(e),r=i.lineAt(t);return o.to==e&&r.to==t&&e<n.length&&t<i.length?[e+1,t+1]:[o.from,r.from]}function st(e,t,n,i){let o=n.lineAt(e),r=i.lineAt(t);return o.from==e&&r.from==t?[e,t]:[o.to+1,r.to+1]}function on(e,t,n,i,o,r){let s=[];for(let a=0;a<e.length;a++){let d=e[a],[c,l]=at(d.fromA+i,d.fromB+o,t,n),[O,f]=st(d.toA+i,d.toB+o,t,n),m=[d.offset(-c+i,-l+o)];for(;a<e.length-1;){let u=e[a+1],[g,p]=at(u.fromA+i,u.fromB+o,t,n);if(g>O+1&&p>f+1)break;m.push(u.offset(-c+i,-l+o)),[O,f]=st(u.toA+i,u.toB+o,t,n),a++}s.push(new ee(m,c,Math.max(c,O),l,Math.max(l,f),r))}return s}const ge=1e3;function Ot(e,t,n,i){let o=0,r=e.length;for(;;){if(o==r){let l=0,O=0;o&&({toA:l,toB:O}=e[o-1]);let f=t-(n?l:O);return[l+f,O+f]}let s=o+r>>1,a=e[s],[d,c]=n?[a.fromA,a.toA]:[a.fromB,a.toB];if(d>t)r=s;else if(c<=t)o=s+1;else return i?[a.fromA,a.fromB]:[a.toA,a.toB]}}function lt(e,t,n,i){let o=[];return t.iterChangedRanges((r,s,a,d)=>{let c=0,l=n?t.length:i,O=0,f=n?i:t.length;r>ge&&([c,O]=Ot(e,r-ge,n,!0)),s<t.length-ge&&([l,f]=Ot(e,s+ge,n,!1));let m=d-a-(s-r),u,[g,p]=n?[m,0]:[0,m];o.length&&(u=o[o.length-1]).toA>=c?o[o.length-1]={fromA:u.fromA,fromB:u.fromB,toA:l,toB:f,diffA:u.diffA+g,diffB:u.diffB+p}:o.push({fromA:c,toA:l,fromB:O,toB:f,diffA:g,diffB:p})}),o}function dt(e,t,n,i,o){if(!e.length)return t;let r=[];for(let s=0,a=0,d=0,c=0;;s++){let l=s==e.length?null:e[s],O=l?l.fromA+a:n.length,f=l?l.fromB+d:i.length;for(;c<t.length;){let p=t[c];if(p.toA+a>O||p.toB+d>f)break;r.push(p.offset(a,d)),c++}if(!l)break;let m=l.toA+a+l.diffA,u=l.toB+d+l.diffB,g=nn(n.sliceString(O,m),i.sliceString(f,u),o);for(let p of on(g,n,i,O,f,tn()))r.push(p);for(a+=l.diffA,d+=l.diffB;c<t.length;){let p=t[c];if(p.fromA+a>m&&p.fromB+d>u)break;c++}}return r}const pr={scanLimit:500},an=Se.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=ft(e))}update(e){(e.docChanged||e.viewportChanged||Qr(e.startState,e.state)||xr(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=ft(e.view))}},{decorations:e=>e.deco});function Qr(e,t){return e.field(C,!1)!=t.field(C,!1)}function xr(e,t){return e.facet(A)!=t.facet(A)}const ct=D.line({class:"cm-changedLine"}),sn=D.mark({class:"cm-changedText"}),vr=D.mark({tagName:"ins",class:"cm-insertedLine"}),Tr=D.mark({tagName:"del",class:"cm-deletedLine"}),ht=new class extends Le{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function Sr(e,t,n,i,o,r){let s=n?e.fromA:e.fromB,a=n?e.toA:e.toB,d=0;if(s!=a){o.add(s,s,ct),o.add(s,a,n?Tr:vr),r&&r.add(s,s,ht);for(let c=t.iterRange(s,a-1),l=s;!c.next().done;){if(c.lineBreak){l++,o.add(l,l,ct),r&&r.add(l,l,ht);continue}let O=l+c.value.length;if(i)for(;d<e.changes.length;){let f=e.changes[d],m=s+(n?f.fromA:f.fromB),u=s+(n?f.toA:f.toB),g=Math.max(l,m),p=Math.min(O,u);if(g<p&&o.add(g,p,sn),u<O)d++;else break}l=O}}}function ft(e){let t=e.state.field(C),{side:n,highlightChanges:i,markGutter:o,overrideChunk:r}=e.state.facet(A),s=n=="a",a=new Te,d=o?new Te:null,{from:c,to:l}=e.viewport;for(let O of t){if((s?O.fromA:O.fromB)>=l)break;(s?O.toA:O.toB)>c&&(!r||!r(e.state,O,a,d))&&Sr(O,e.state.doc,s,i,a,d)}return{deco:a.finish(),gutter:d&&d.finish()}}const Ue=Ge.define({map:(e,t)=>t.mapPos(e)});class yr extends Ne{constructor(t){super(),this.lines=t}eq(t){return this.lines==t.lines}toDOM(t){let n=document.createElement("div");return n.className="cm-collapsedLines",n.textContent=t.state.phrase("$ unchanged lines",this.lines),n.addEventListener("click",i=>{let o=t.posAtDOM(i.target);t.dispatch({effects:Ue.of(o)});let{side:r,sibling:s}=t.state.facet(A);s&&s().dispatch({effects:Ue.of(br(o,t.state.field(C),r=="a"))})}),n}ignoreEvent(t){return t instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}}function br(e,t,n){let i=0,o=0;for(let r=0;;r++){let s=r<t.length?t[r]:null;if(!s||(n?s.fromA:s.fromB)>=e)return o+(e-i);[i,o]=n?[s.toA,s.toB]:[s.toB,s.toA]}}const wr=he.define({create(e){return D.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(Ue)&&(e=e.update({filter:i=>i!=n.value}));return e},provide:e=>U.decorations.from(e)});function kr({margin:e=3,minSize:t=4}){return wr.init(n=>Pr(n,e,t))}function Pr(e,t,n){let i=new Te,o=e.facet(A).side=="a",r=e.field(C),s=1;for(let a=0;;a++){let d=a<r.length?r[a]:null,c=a?s+t:1,l=d?e.doc.lineAt(o?d.fromA:d.fromB).number-1-t:e.doc.lines,O=l-c+1;if(O>=n&&i.add(e.doc.line(c).from,e.doc.line(l).to,D.replace({widget:new yr(O),block:!0})),!d)break;s=e.doc.lineAt(Math.min(e.doc.length,o?d.toA:d.toB)).number}return i.finish()}const $r=U.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat"},"&.cm-merge-b .cm-deletedText":{background:"#ff000033"},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer","&:before":{content:'"⦚"',marginInlineEnd:"7px"},"&:after":{content:'"⦚"',marginInlineStart:"7px"}},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"},".cm-inlineChangedLineGutter":{background:"#75d"}}),qr=new class extends Le{constructor(){super(...arguments),this.elementClass="cm-deletedLineGutter"}},jr=_t.low(kn({class:"cm-changeGutter",markers:e=>{var t;return((t=e.plugin(an))===null||t===void 0?void 0:t.gutter)||$n.empty},widgetMarker:(e,t)=>t instanceof On?qr:null}));function Wr(e){var t;let n=typeof e.original=="string"?zt.of(e.original.split(/\r?\n/)):e.original,i=e.diffConfig||pr;return[_t.low(an),_r,$r,U.editorAttributes.of({class:"cm-merge-b"}),rn.of((o,r)=>{let s=r.effects.find(a=>a.is(Ie));return s&&(o=ee.updateA(o,s.value.doc,r.startState.doc,s.value.changes,i)),r.docChanged&&(o=ee.updateB(o,r.state.field(re),r.newDoc,r.changes,i)),o}),A.of({highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1,syntaxHighlightDeletions:e.syntaxHighlightDeletions!==!1,syntaxHighlightDeletionsMaxLength:3e3,mergeControls:(t=e.mergeControls)!==null&&t!==void 0?t:!0,overrideChunk:e.allowInlineDiffs?Vr:void 0,side:"b"}),re.init(()=>n),e.gutter!==!1?jr:[],e.collapseUnchanged?kr(e.collapseUnchanged):[],C.init(o=>ee.build(n,o.doc,i))]}const Ie=Ge.define(),re=he.define({create:()=>zt.empty,update(e,t){for(let n of t.effects)n.is(Ie)&&(e=n.value.doc);return e}}),mt=new WeakMap;class On extends Ne{constructor(t){super(),this.buildDOM=t,this.dom=null}eq(t){return this.dom==t.dom}toDOM(t){return this.dom||(this.dom=this.buildDOM(t))}}function Rr(e,t,n){let i=mt.get(t.changes);if(i)return i;let o=s=>{let{highlightChanges:a,syntaxHighlightDeletions:d,syntaxHighlightDeletionsMaxLength:c,mergeControls:l}=e.facet(A),O=document.createElement("div");if(O.className="cm-deletedChunk",l){let y=O.appendChild(document.createElement("div"));y.className="cm-chunkButtons";let P=T=>{T.preventDefault(),Xr(s,s.posAtDOM(O))},v=T=>{T.preventDefault(),zr(s,s.posAtDOM(O))};if(typeof l=="function")y.appendChild(l("accept",P)),y.appendChild(l("reject",v));else{let T=y.appendChild(document.createElement("button"));T.name="accept",T.textContent=e.phrase("Accept"),T.onmousedown=P;let b=y.appendChild(document.createElement("button"));b.name="reject",b.textContent=e.phrase("Reject"),b.onmousedown=v}}if(n||t.fromA>=t.toA)return O;let f=s.state.field(re).sliceString(t.fromA,t.endA),m=d&&e.facet(Ct),u=k(),g=t.changes,p=0,Q=!1;function k(){let y=O.appendChild(document.createElement("div"));return y.className="cm-deletedLine",y.appendChild(document.createElement("del"))}function $(y,P,v){for(let T=y;T<P;){if(f.charAt(T)==`
|
|
1
|
+
import{r as S,j as h}from"./vendor-react-C2GTiUCy.js";import{T as zt,P as _t,E as U,S as he,g as kn,V as Se,F as ye,a as Ge,b as Te,D,G as Le,W as Ne,l as Ct,h as Ce,C as Pn,c as $n,d as Et,L as Ut,s as Vt,t as x,e as Gt,f as Lt,i as Nt,j as He,k as Mt,n as Zt,p as be,q as qn,r as $e,u as jn,v as Wn,N as Rn,I as Xn,w as zn,x as G,y as te,z as _n,A as Cn,B as En,H as Un,J as Je,K as Vn,O as Gn,Q as Ln,m as Nn,U as Mn,X as Zn,Y as An,Z as Dn,_ as In,M as Bn,R as Yn,o as Fn}from"./MarkdownPreview-B00VQTx6.js";import{c as Ke,g as Hn,a as Jn,h as Kn,u as er}from"./feature-workspace-FLomYkPq.js";import{o as tr,q as nr,bq as rr,a9 as et,S as ir,aa as or,at as ar,b2 as sr,b3 as Or,X as lr}from"./vendor-ui-CAUHSABu.js";import{u as dr}from"./vendor-i18n-B6HjLCnN.js";import"./vendor-markdown-DkITEES2.js";import"./feature-chat-pY0kOrz2.js";import"./vendor-data-DsEZeNPr.js";class q{constructor(t,n,i,o){this.fromA=t,this.toA=n,this.fromB=i,this.toB=o}offset(t,n=t){return new q(this.fromA+t,this.toA+t,this.fromB+n,this.toB+n)}}function J(e,t,n,i,o,r){if(e==i)return[];let s=Ze(e,t,n,i,o,r),a=Ae(e,t+s,n,i,o+s,r);t+=s,n-=a,o+=s,r-=a;let d=n-t,c=r-o;if(!d||!c)return[new q(t,n,o,r)];if(d>c){let O=e.slice(t,n).indexOf(i.slice(o,r));if(O>-1)return[new q(t,t+O,o,o),new q(t+O+c,n,r,r)]}else if(c>d){let O=i.slice(o,r).indexOf(e.slice(t,n));if(O>-1)return[new q(t,t,o,o+O),new q(n,n,o+O+d,r)]}if(d==1||c==1)return[new q(t,n,o,r)];let l=It(e,t,n,i,o,r);if(l){let[O,f,m]=l;return J(e,t,O,i,o,f).concat(J(e,O+m,n,i,f+m,r))}return cr(e,t,n,i,o,r)}let se=1e9,Oe=0,Me=!1;function cr(e,t,n,i,o,r){let s=n-t,a=r-o;if(se<1e9&&Math.min(s,a)>se*16||Oe>0&&Date.now()>Oe)return Math.min(s,a)>se*64?[new q(t,n,o,r)]:tt(e,t,n,i,o,r);let d=Math.ceil((s+a)/2);qe.reset(d),je.reset(d);let c=(m,u)=>e.charCodeAt(t+m)==i.charCodeAt(o+u),l=(m,u)=>e.charCodeAt(n-m-1)==i.charCodeAt(r-u-1),O=(s-a)%2!=0?je:null,f=O?null:qe;for(let m=0;m<d;m++){if(m>se||Oe>0&&!(m&63)&&Date.now()>Oe)return tt(e,t,n,i,o,r);let u=qe.advance(m,s,a,d,O,!1,c)||je.advance(m,s,a,d,f,!0,l);if(u)return hr(e,t,n,t+u[0],i,o,r,o+u[1])}return[new q(t,n,o,r)]}class At{constructor(){this.vec=[]}reset(t){this.len=t<<1;for(let n=0;n<this.len;n++)this.vec[n]=-1;this.vec[t+1]=0,this.start=this.end=0}advance(t,n,i,o,r,s,a){for(let d=-t+this.start;d<=t-this.end;d+=2){let c=o+d,l=d==-t||d!=t&&this.vec[c-1]<this.vec[c+1]?this.vec[c+1]:this.vec[c-1]+1,O=l-d;for(;l<n&&O<i&&a(l,O);)l++,O++;if(this.vec[c]=l,l>n)this.end+=2;else if(O>i)this.start+=2;else if(r){let f=o+(n-i)-d;if(f>=0&&f<this.len&&r.vec[f]!=-1)if(s){let m=r.vec[f];if(m>=n-l)return[m,o+m-f]}else{let m=n-r.vec[f];if(l>=m)return[l,O]}}}return null}}const qe=new At,je=new At;function hr(e,t,n,i,o,r,s,a){let d=!1;return!ne(e,i)&&++i==n&&(d=!0),!ne(o,a)&&++a==s&&(d=!0),d?[new q(t,n,r,s)]:J(e,t,i,o,r,a).concat(J(e,i,n,o,a,s))}function Dt(e,t){let n=1,i=Math.min(e,t);for(;n<i;)n=n<<1;return n}function Ze(e,t,n,i,o,r){if(t==n||t==r||e.charCodeAt(t)!=i.charCodeAt(o))return 0;let s=Dt(n-t,r-o);for(let a=t,d=o;;){let c=a+s,l=d+s;if(c>n||l>r||e.slice(a,c)!=i.slice(d,l)){if(s==1)return a-t-(ne(e,a)?0:1);s=s>>1}else{if(c==n||l==r)return c-t;a=c,d=l}}}function Ae(e,t,n,i,o,r){if(t==n||o==r||e.charCodeAt(n-1)!=i.charCodeAt(r-1))return 0;let s=Dt(n-t,r-o);for(let a=n,d=r;;){let c=a-s,l=d-s;if(c<t||l<o||e.slice(c,a)!=i.slice(l,d)){if(s==1)return n-a-(ne(e,a)?0:1);s=s>>1}else{if(c==t||l==o)return n-c;a=c,d=l}}}function Ee(e,t,n,i,o,r,s,a){let d=i.slice(o,r),c=null;for(;;){if(c||s<a)return c;for(let l=t+s;;){ne(e,l)||l++;let O=l+s;if(ne(e,O)||(O+=O==l+1?1:-1),O>=n)break;let f=e.slice(l,O),m=-1;for(;(m=d.indexOf(f,m+1))!=-1;){let u=Ze(e,O,n,i,o+m+f.length,r),g=Ae(e,t,l,i,o,o+m),p=f.length+u+g;(!c||c[2]<p)&&(c=[l-g,o+m-g,p])}l=O}if(a<0)return c;s=s>>1}}function It(e,t,n,i,o,r){let s=n-t,a=r-o;if(s<a){let d=It(i,o,r,e,t,n);return d&&[d[1],d[0],d[2]]}return s<4||a*2<s?null:Ee(e,t,n,i,o,r,Math.floor(s/4),-1)}function tt(e,t,n,i,o,r){Me=!0;let s=n-t,a=r-o,d;if(s<a){let f=Ee(i,o,r,e,t,n,Math.floor(s/6),50);d=f&&[f[1],f[0],f[2]]}else d=Ee(e,t,n,i,o,r,Math.floor(a/6),50);if(!d)return[new q(t,n,o,r)];let[c,l,O]=d;return J(e,t,c,i,o,l).concat(J(e,c+O,n,i,l+O,r))}function Bt(e,t){for(let n=1;n<e.length;n++){let i=e[n-1],o=e[n];i.toA>o.fromA-t&&i.toB>o.fromB-t&&(e[n-1]=new q(i.fromA,o.toA,i.fromB,o.toB),e.splice(n--,1))}}function fr(e,t,n){for(;;){Bt(n,1);let i=!1;for(let o=0;o<n.length;o++){let r=n[o],s,a;(s=Ze(e,r.fromA,r.toA,t,r.fromB,r.toB))&&(r=n[o]=new q(r.fromA+s,r.toA,r.fromB+s,r.toB)),(a=Ae(e,r.fromA,r.toA,t,r.fromB,r.toB))&&(r=n[o]=new q(r.fromA,r.toA-a,r.fromB,r.toB-a));let d=r.toA-r.fromA,c=r.toB-r.fromB;if(d&&c)continue;let l=r.fromA-(o?n[o-1].toA:0),O=(o<n.length-1?n[o+1].fromA:e.length)-r.toA;if(!l||!O)continue;let f=d?e.slice(r.fromA,r.toA):t.slice(r.fromB,r.toB);l<=f.length&&e.slice(r.fromA-l,r.fromA)==f.slice(f.length-l)?(n[o]=new q(r.fromA-l,r.toA-l,r.fromB-l,r.toB-l),i=!0):O<=f.length&&e.slice(r.toA,r.toA+O)==f.slice(0,O)&&(n[o]=new q(r.fromA+O,r.toA+O,r.fromB+O,r.toB+O),i=!0)}if(!i)break}return n}function mr(e,t,n){for(let i=0,o=0;o<e.length;o++){let r=e[o],s=r.toA-r.fromA,a=r.toB-r.fromB;if(s&&a||s>3||a>3){let d=o==e.length-1?t.length:e[o+1].fromA,c=r.fromA-i,l=d-r.toA,O=rt(t,r.fromA,c),f=nt(t,r.toA,l),m=r.fromA-O,u=f-r.toA;if((!s||!a)&&m&&u){let g=Math.max(s,a),[p,Q,k]=s?[t,r.fromA,r.toA]:[n,r.fromB,r.toB];g>m&&t.slice(O,r.fromA)==p.slice(k-m,k)?(r=e[o]=new q(O,O+s,r.fromB-m,r.toB-m),O=r.fromA,f=nt(t,r.toA,d-r.toA)):g>u&&t.slice(r.toA,f)==p.slice(Q,Q+u)&&(r=e[o]=new q(f-s,f,r.fromB+u,r.toB+u),f=r.toA,O=rt(t,r.fromA,r.fromA-i)),m=r.fromA-O,u=f-r.toA}if(m||u)r=e[o]=new q(r.fromA-m,r.toA+u,r.fromB-m,r.toB+u);else if(s){if(!a){let g=ot(t,r.fromA,r.toA),p,Q=g<0?-1:it(t,r.toA,r.fromA);g>-1&&(p=g-r.fromA)<=l&&t.slice(r.fromA,g)==t.slice(r.toA,r.toA+p)?r=e[o]=r.offset(p):Q>-1&&(p=r.toA-Q)<=c&&t.slice(r.fromA-p,r.fromA)==t.slice(Q,r.toA)&&(r=e[o]=r.offset(-p))}}else{let g=ot(n,r.fromB,r.toB),p,Q=g<0?-1:it(n,r.toB,r.fromB);g>-1&&(p=g-r.fromB)<=l&&n.slice(r.fromB,g)==n.slice(r.toB,r.toB+p)?r=e[o]=r.offset(p):Q>-1&&(p=r.toB-Q)<=c&&n.slice(r.fromB-p,r.fromB)==n.slice(Q,r.toB)&&(r=e[o]=r.offset(-p))}}i=r.toA}return Bt(e,3),e}let H;try{H=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch{}function Yt(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function Ft(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?Yt(n)?1:0:H?!Kt(n)||t==e.length-1?H.test(String.fromCharCode(n))?1:0:H.test(e.slice(t,t+2))?2:0:0}function Ht(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?Yt(n)?1:0:H?!en(n)||t==1?H.test(String.fromCharCode(n))?1:0:H.test(e.slice(t-2,t))?2:0:0}const Jt=8;function nt(e,t,n){if(t==e.length||!Ht(e,t))return t;for(let i=t,o=t+n,r=0;r<Jt;r++){let s=Ft(e,i);if(!s||i+s>o)return i;i+=s}return t}function rt(e,t,n){if(!t||!Ft(e,t))return t;for(let i=t,o=t-n,r=0;r<Jt;r++){let s=Ht(e,i);if(!s||i-s<o)return i;i-=s}return t}function it(e,t,n){for(;t!=n;t--)if(e.charCodeAt(t-1)==10)return t;return-1}function ot(e,t,n){for(;t!=n;t++)if(e.charCodeAt(t)==10)return t;return-1}const Kt=e=>e>=55296&&e<=56319,en=e=>e>=56320&&e<=57343;function ne(e,t){return!t||t==e.length||!Kt(e.charCodeAt(t-1))||!en(e.charCodeAt(t))}function ur(e,t,n){var i;return se=((i=n?.scanLimit)!==null&&i!==void 0?i:1e9)>>1,Oe=n?.timeout?Date.now()+n.timeout:0,Me=!1,fr(e,t,J(e,0,e.length,t,0,t.length))}function tn(){return!Me}function nn(e,t,n){return mr(ur(e,t,n),e,t)}const A=ye.define({combine:e=>e[0]}),gr=Ge.define(),rn=ye.define(),C=he.define({create(e){return null},update(e,t){for(let n of t.effects)n.is(gr)&&(e=n.value);for(let n of t.state.facet(rn))e=n(e,t);return e}});function De(e){let t=e.field(C,!1);if(!t)return null;let n=e.facet(A);return{chunks:t,side:n?n.side:null}}class ee{constructor(t,n,i,o,r,s=!0){this.changes=t,this.fromA=n,this.toA=i,this.fromB=o,this.toB=r,this.precise=s}offset(t,n){return t||n?new ee(this.changes,this.fromA+t,this.toA+t,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(t,n,i){let o=nn(t.toString(),n.toString(),i);return on(o,t,n,0,0,tn())}static updateA(t,n,i,o,r){return dt(lt(t,o,!0,i.length),t,n,i,r)}static updateB(t,n,i,o,r){return dt(lt(t,o,!1,n.length),t,n,i,r)}}function at(e,t,n,i){let o=n.lineAt(e),r=i.lineAt(t);return o.to==e&&r.to==t&&e<n.length&&t<i.length?[e+1,t+1]:[o.from,r.from]}function st(e,t,n,i){let o=n.lineAt(e),r=i.lineAt(t);return o.from==e&&r.from==t?[e,t]:[o.to+1,r.to+1]}function on(e,t,n,i,o,r){let s=[];for(let a=0;a<e.length;a++){let d=e[a],[c,l]=at(d.fromA+i,d.fromB+o,t,n),[O,f]=st(d.toA+i,d.toB+o,t,n),m=[d.offset(-c+i,-l+o)];for(;a<e.length-1;){let u=e[a+1],[g,p]=at(u.fromA+i,u.fromB+o,t,n);if(g>O+1&&p>f+1)break;m.push(u.offset(-c+i,-l+o)),[O,f]=st(u.toA+i,u.toB+o,t,n),a++}s.push(new ee(m,c,Math.max(c,O),l,Math.max(l,f),r))}return s}const ge=1e3;function Ot(e,t,n,i){let o=0,r=e.length;for(;;){if(o==r){let l=0,O=0;o&&({toA:l,toB:O}=e[o-1]);let f=t-(n?l:O);return[l+f,O+f]}let s=o+r>>1,a=e[s],[d,c]=n?[a.fromA,a.toA]:[a.fromB,a.toB];if(d>t)r=s;else if(c<=t)o=s+1;else return i?[a.fromA,a.fromB]:[a.toA,a.toB]}}function lt(e,t,n,i){let o=[];return t.iterChangedRanges((r,s,a,d)=>{let c=0,l=n?t.length:i,O=0,f=n?i:t.length;r>ge&&([c,O]=Ot(e,r-ge,n,!0)),s<t.length-ge&&([l,f]=Ot(e,s+ge,n,!1));let m=d-a-(s-r),u,[g,p]=n?[m,0]:[0,m];o.length&&(u=o[o.length-1]).toA>=c?o[o.length-1]={fromA:u.fromA,fromB:u.fromB,toA:l,toB:f,diffA:u.diffA+g,diffB:u.diffB+p}:o.push({fromA:c,toA:l,fromB:O,toB:f,diffA:g,diffB:p})}),o}function dt(e,t,n,i,o){if(!e.length)return t;let r=[];for(let s=0,a=0,d=0,c=0;;s++){let l=s==e.length?null:e[s],O=l?l.fromA+a:n.length,f=l?l.fromB+d:i.length;for(;c<t.length;){let p=t[c];if(p.toA+a>O||p.toB+d>f)break;r.push(p.offset(a,d)),c++}if(!l)break;let m=l.toA+a+l.diffA,u=l.toB+d+l.diffB,g=nn(n.sliceString(O,m),i.sliceString(f,u),o);for(let p of on(g,n,i,O,f,tn()))r.push(p);for(a+=l.diffA,d+=l.diffB;c<t.length;){let p=t[c];if(p.fromA+a>m&&p.fromB+d>u)break;c++}}return r}const pr={scanLimit:500},an=Se.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=ft(e))}update(e){(e.docChanged||e.viewportChanged||Qr(e.startState,e.state)||xr(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=ft(e.view))}},{decorations:e=>e.deco});function Qr(e,t){return e.field(C,!1)!=t.field(C,!1)}function xr(e,t){return e.facet(A)!=t.facet(A)}const ct=D.line({class:"cm-changedLine"}),sn=D.mark({class:"cm-changedText"}),vr=D.mark({tagName:"ins",class:"cm-insertedLine"}),Tr=D.mark({tagName:"del",class:"cm-deletedLine"}),ht=new class extends Le{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function Sr(e,t,n,i,o,r){let s=n?e.fromA:e.fromB,a=n?e.toA:e.toB,d=0;if(s!=a){o.add(s,s,ct),o.add(s,a,n?Tr:vr),r&&r.add(s,s,ht);for(let c=t.iterRange(s,a-1),l=s;!c.next().done;){if(c.lineBreak){l++,o.add(l,l,ct),r&&r.add(l,l,ht);continue}let O=l+c.value.length;if(i)for(;d<e.changes.length;){let f=e.changes[d],m=s+(n?f.fromA:f.fromB),u=s+(n?f.toA:f.toB),g=Math.max(l,m),p=Math.min(O,u);if(g<p&&o.add(g,p,sn),u<O)d++;else break}l=O}}}function ft(e){let t=e.state.field(C),{side:n,highlightChanges:i,markGutter:o,overrideChunk:r}=e.state.facet(A),s=n=="a",a=new Te,d=o?new Te:null,{from:c,to:l}=e.viewport;for(let O of t){if((s?O.fromA:O.fromB)>=l)break;(s?O.toA:O.toB)>c&&(!r||!r(e.state,O,a,d))&&Sr(O,e.state.doc,s,i,a,d)}return{deco:a.finish(),gutter:d&&d.finish()}}const Ue=Ge.define({map:(e,t)=>t.mapPos(e)});class yr extends Ne{constructor(t){super(),this.lines=t}eq(t){return this.lines==t.lines}toDOM(t){let n=document.createElement("div");return n.className="cm-collapsedLines",n.textContent=t.state.phrase("$ unchanged lines",this.lines),n.addEventListener("click",i=>{let o=t.posAtDOM(i.target);t.dispatch({effects:Ue.of(o)});let{side:r,sibling:s}=t.state.facet(A);s&&s().dispatch({effects:Ue.of(br(o,t.state.field(C),r=="a"))})}),n}ignoreEvent(t){return t instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}}function br(e,t,n){let i=0,o=0;for(let r=0;;r++){let s=r<t.length?t[r]:null;if(!s||(n?s.fromA:s.fromB)>=e)return o+(e-i);[i,o]=n?[s.toA,s.toB]:[s.toB,s.toA]}}const wr=he.define({create(e){return D.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(Ue)&&(e=e.update({filter:i=>i!=n.value}));return e},provide:e=>U.decorations.from(e)});function kr({margin:e=3,minSize:t=4}){return wr.init(n=>Pr(n,e,t))}function Pr(e,t,n){let i=new Te,o=e.facet(A).side=="a",r=e.field(C),s=1;for(let a=0;;a++){let d=a<r.length?r[a]:null,c=a?s+t:1,l=d?e.doc.lineAt(o?d.fromA:d.fromB).number-1-t:e.doc.lines,O=l-c+1;if(O>=n&&i.add(e.doc.line(c).from,e.doc.line(l).to,D.replace({widget:new yr(O),block:!0})),!d)break;s=e.doc.lineAt(Math.min(e.doc.length,o?d.toA:d.toB)).number}return i.finish()}const $r=U.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat"},"&.cm-merge-b .cm-deletedText":{background:"#ff000033"},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer","&:before":{content:'"⦚"',marginInlineEnd:"7px"},"&:after":{content:'"⦚"',marginInlineStart:"7px"}},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"},".cm-inlineChangedLineGutter":{background:"#75d"}}),qr=new class extends Le{constructor(){super(...arguments),this.elementClass="cm-deletedLineGutter"}},jr=_t.low(kn({class:"cm-changeGutter",markers:e=>{var t;return((t=e.plugin(an))===null||t===void 0?void 0:t.gutter)||$n.empty},widgetMarker:(e,t)=>t instanceof On?qr:null}));function Wr(e){var t;let n=typeof e.original=="string"?zt.of(e.original.split(/\r?\n/)):e.original,i=e.diffConfig||pr;return[_t.low(an),_r,$r,U.editorAttributes.of({class:"cm-merge-b"}),rn.of((o,r)=>{let s=r.effects.find(a=>a.is(Ie));return s&&(o=ee.updateA(o,s.value.doc,r.startState.doc,s.value.changes,i)),r.docChanged&&(o=ee.updateB(o,r.state.field(re),r.newDoc,r.changes,i)),o}),A.of({highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1,syntaxHighlightDeletions:e.syntaxHighlightDeletions!==!1,syntaxHighlightDeletionsMaxLength:3e3,mergeControls:(t=e.mergeControls)!==null&&t!==void 0?t:!0,overrideChunk:e.allowInlineDiffs?Vr:void 0,side:"b"}),re.init(()=>n),e.gutter!==!1?jr:[],e.collapseUnchanged?kr(e.collapseUnchanged):[],C.init(o=>ee.build(n,o.doc,i))]}const Ie=Ge.define(),re=he.define({create:()=>zt.empty,update(e,t){for(let n of t.effects)n.is(Ie)&&(e=n.value.doc);return e}}),mt=new WeakMap;class On extends Ne{constructor(t){super(),this.buildDOM=t,this.dom=null}eq(t){return this.dom==t.dom}toDOM(t){return this.dom||(this.dom=this.buildDOM(t))}}function Rr(e,t,n){let i=mt.get(t.changes);if(i)return i;let o=s=>{let{highlightChanges:a,syntaxHighlightDeletions:d,syntaxHighlightDeletionsMaxLength:c,mergeControls:l}=e.facet(A),O=document.createElement("div");if(O.className="cm-deletedChunk",l){let y=O.appendChild(document.createElement("div"));y.className="cm-chunkButtons";let P=T=>{T.preventDefault(),Xr(s,s.posAtDOM(O))},v=T=>{T.preventDefault(),zr(s,s.posAtDOM(O))};if(typeof l=="function")y.appendChild(l("accept",P)),y.appendChild(l("reject",v));else{let T=y.appendChild(document.createElement("button"));T.name="accept",T.textContent=e.phrase("Accept"),T.onmousedown=P;let b=y.appendChild(document.createElement("button"));b.name="reject",b.textContent=e.phrase("Reject"),b.onmousedown=v}}if(n||t.fromA>=t.toA)return O;let f=s.state.field(re).sliceString(t.fromA,t.endA),m=d&&e.facet(Ct),u=k(),g=t.changes,p=0,Q=!1;function k(){let y=O.appendChild(document.createElement("div"));return y.className="cm-deletedLine",y.appendChild(document.createElement("del"))}function $(y,P,v){for(let T=y;T<P;){if(f.charAt(T)==`
|
|
2
2
|
`){u.firstChild||u.appendChild(document.createElement("br")),u=k(),T++;continue}let b=P,V=v+(Q?" cm-deletedText":""),R=!1,z=f.indexOf(`
|
|
3
3
|
`,T);if(z>-1&&z<P&&(b=z),a&&p<g.length){let W=Math.max(0,Q?g[p].toA:g[p].fromA);W<=b&&(b=W,Q&&p++,R=!0)}if(b>T){let W=document.createTextNode(f.slice(T,b));if(V){let E=u.appendChild(document.createElement("span"));E.className=V,E.appendChild(W)}else u.appendChild(W);T=b}R&&(Q=!Q)}}if(m&&t.toA-t.fromA<=c){let y=m.parser.parse(f),P=0;Ce(y,{style:v=>Et(e,v)},(v,T,b)=>{v>P&&$(P,v,""),$(v,T,b),P=T}),$(P,f.length,"")}else $(0,f.length,"");return u.firstChild||u.appendChild(document.createElement("br")),O},r=D.widget({block:!0,side:-1,widget:new On(o)});return mt.set(t.changes,r),r}function Xr(e,t){let{state:n}=e,i=t??n.selection.main.head,o=e.state.field(C).find(d=>d.fromB<=i&&d.endB>=i);if(!o)return!1;let r=e.state.sliceDoc(o.fromB,Math.max(o.fromB,o.toB-1)),s=e.state.field(re);o.fromB!=o.toB&&o.toA<=s.length&&(r+=e.state.lineBreak);let a=Pn.of({from:o.fromA,to:Math.min(s.length,o.toA),insert:r},s.length);return e.dispatch({effects:Ie.of({doc:a.apply(s),changes:a}),userEvent:"accept"}),!0}function zr(e,t){let{state:n}=e,i=t??n.selection.main.head,o=n.field(C).find(a=>a.fromB<=i&&a.endB>=i);if(!o)return!1;let s=n.field(re).sliceString(o.fromA,Math.max(o.fromA,o.toA-1));return o.fromA!=o.toA&&o.toB<=n.doc.length&&(s+=n.lineBreak),e.dispatch({changes:{from:o.fromB,to:Math.min(n.doc.length,o.toB),insert:s},userEvent:"revert"}),!0}function ut(e){let t=new Te;for(let n of e.field(C)){let i=e.facet(A).overrideChunk&&ln(e,n);t.add(n.fromB,n.fromB,Rr(e,n,!!i))}return t.finish()}const _r=he.define({create:e=>ut(e),update(e,t){return t.state.field(C,!1)!=t.startState.field(C,!1)?ut(t.state):e},provide:e=>U.decorations.from(e)}),gt=new WeakMap;function ln(e,t){let n=gt.get(t);if(n!==void 0)return n;n=null;let i=e.field(re),o=e.doc,r=i.lineAt(t.endA).number-i.lineAt(t.fromA).number+1,s=o.lineAt(t.endB).number-o.lineAt(t.fromB).number+1;e:if(r==s&&r<10){let a=[],d=0,c=t.fromA,l=t.fromB;for(let O of t.changes){if(O.fromA<O.toA){d+=O.toA-O.fromA;let f=i.sliceString(c+O.fromA,c+O.toA);if(/\n/.test(f))break e;a.push(D.widget({widget:new Cr(f),side:-1}).range(l+O.fromB))}O.fromB<O.toB&&a.push(sn.range(l+O.fromB,l+O.toB))}d<t.endA-t.fromA-r*2&&(n=a)}return gt.set(t,n),n}class Cr extends Ne{constructor(t){super(),this.text=t}eq(t){return this.text==t.text}toDOM(t){let n=document.createElement("del");return n.className="cm-deletedText",n.textContent=this.text,n}}const Er=new class extends Le{constructor(){super(...arguments),this.elementClass="cm-inlineChangedLineGutter"}},Ur=D.line({class:"cm-inlineChangedLine"});function Vr(e,t,n,i){let o=ln(e,t),r=0;if(!o)return!1;for(let s=e.doc.lineAt(t.fromB);;){for(i&&i.add(s.from,s.from,Er),n.add(s.from,s.from,Ur);r<o.length&&o[r].to<=s.to;){let a=o[r++];n.add(a.from,a.to,a.value)}if(s.to>=t.endB)break;s=e.doc.lineAt(s.to+1)}return!0}const Gr=["zip","tar","gz","rar","7z","bz2","xz","exe","dll","so","dylib","app","dmg","msi","mp3","mp4","wav","avi","mov","mkv","flv","wmv","m4a","ogg","pdf","doc","docx","xls","xlsx","ppt","pptx","odt","ods","odp","ttf","otf","woff","woff2","eot","db","sqlite","sqlite3","bin","dat","iso","img","class","jar","war","pyc","pyo"],pt=e=>{const t=e.split(".").pop()?.toLowerCase();return Gr.includes(t??"")},dn={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",svg:"image/svg+xml",webp:"image/webp",ico:"image/x-icon",bmp:"image/bmp",avif:"image/avif",apng:"image/apng",pdf:"application/pdf",mp4:"video/mp4",webm:"video/webm",ogv:"video/ogg",mov:"video/quicktime",m4v:"video/x-m4v",mp3:"audio/mpeg",wav:"audio/wav",m4a:"audio/mp4",aac:"audio/aac",flac:"audio/flac",opus:"audio/opus",oga:"audio/ogg",ogg:"audio/ogg",weba:"audio/webm"},cn=e=>e.split(".").pop()?.toLowerCase()??"",Lr=e=>e==="application/pdf"?"pdf":e.startsWith("image/")?"image":e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":null,Qt=e=>{const t=dn[cn(e)];return t?Lr(t):null},xt=e=>dn[cn(e)],vt=e=>e instanceof Error?e.message:String(e),Nr=({file:e,projectPath:t})=>{const[n,i]=S.useState(""),[o,r]=S.useState(!0),[s,a]=S.useState(!1),[d,c]=S.useState(!1),[l,O]=S.useState(null),[f,m]=S.useState(!1),u=Qt(e.name),g=e.projectId??t,p=e.path,Q=e.name,k=e.diffInfo?.new_string,$=e.diffInfo?.old_string;S.useEffect(()=>{(async()=>{try{if(r(!0),m(!1),Qt(e.name)){i(""),r(!1);return}if(pt(e.name)){i(""),m(!0),r(!1);return}if(e.diffInfo&&k!==void 0&&$!==void 0){i(k),r(!1);return}if(!g)throw new Error("Missing project identifier");const T=await Ke.readFile(g,p);if(!T.ok)throw new Error(`Failed to load file: ${T.status} ${T.statusText}`);const b=await T.json();i(b.content)}catch(T){const b=vt(T);console.error("Error loading file:",T),i(`// Error loading file: ${b}
|
|
4
4
|
// File: ${Q}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as a,j as t}from"./vendor-react-C2GTiUCy.js";import{c as ee,a5 as lt,a6 as at,a7 as st,a8 as it,f as U,I as Ne,B as z,a as ct,a9 as dt}from"./feature-workspace-BodovOw6.js";import{Q as W,b4 as ce,$ as B,b5 as ge,b6 as be,ak as ye,S as A,b7 as de,b8 as te,b9 as we,ba as re,U as X,bb as je,a4 as Z,bc as ue,as as qe,bd as J,k as Y,be as ne,bf as le,bg as Q,w as ut,bh as H,bi as De,bj as ft,bk as Ie,ar as ae,a0 as se,J as Re,bl as pt,bm as mt,aO as ie,bn as Ae,bo as xt,bp as ht,bq as xe,aC as Le,r as Me,q as Ue,aa as Oe,l as ve,a1 as oe,R as Ce,t as gt,N as bt,F as Fe,T as Ke,b as Ze,L as Je,C as yt,ay as wt,a9 as jt,br as vt,X as Te,n as Ct,a2 as kt,o as Nt}from"./vendor-ui-CAUHSABu.js";import{J as Ft}from"./vendor-data-DsEZeNPr.js";import{u as V}from"./vendor-i18n-B6HjLCnN.js";import"./vendor-markdown-DkITEES2.js";const _e="w-4 h-4 flex-shrink-0",Pe={js:{icon:ae,color:"text-yellow-500"},jsx:{icon:ae,color:"text-yellow-500"},mjs:{icon:ae,color:"text-yellow-500"},cjs:{icon:ae,color:"text-yellow-500"},ts:{icon:se,color:"text-blue-500"},tsx:{icon:se,color:"text-blue-500"},mts:{icon:se,color:"text-blue-500"},py:{icon:xe,color:"text-emerald-500"},pyw:{icon:xe,color:"text-emerald-500"},pyi:{icon:xe,color:"text-emerald-400"},ipynb:{icon:ht,color:"text-orange-500"},rs:{icon:de,color:"text-orange-600"},toml:{icon:A,color:"text-gray-500"},go:{icon:ce,color:"text-cyan-500"},rb:{icon:je,color:"text-red-500"},erb:{icon:je,color:"text-red-400"},php:{icon:xt,color:"text-violet-500"},java:{icon:Ae,color:"text-red-600"},jar:{icon:Ae,color:"text-red-500"},kt:{icon:ce,color:"text-violet-500"},kts:{icon:ce,color:"text-violet-400"},c:{icon:ie,color:"text-blue-600"},h:{icon:ie,color:"text-blue-400"},cpp:{icon:ie,color:"text-blue-700"},hpp:{icon:ie,color:"text-blue-500"},cc:{icon:ie,color:"text-blue-700"},cs:{icon:ce,color:"text-purple-600"},swift:{icon:we,color:"text-orange-500"},lua:{icon:mt,color:"text-blue-500"},r:{icon:pt,color:"text-blue-600"},html:{icon:Re,color:"text-orange-600"},htm:{icon:Re,color:"text-orange-600"},css:{icon:te,color:"text-blue-500"},scss:{icon:te,color:"text-pink-500"},sass:{icon:te,color:"text-pink-400"},less:{icon:te,color:"text-indigo-500"},vue:{icon:se,color:"text-emerald-500"},svelte:{icon:se,color:"text-orange-500"},json:{icon:re,color:"text-yellow-600"},jsonc:{icon:re,color:"text-yellow-500"},json5:{icon:re,color:"text-yellow-500"},yaml:{icon:A,color:"text-purple-400"},yml:{icon:A,color:"text-purple-400"},xml:{icon:ae,color:"text-orange-500"},csv:{icon:Ie,color:"text-green-600"},tsv:{icon:Ie,color:"text-green-500"},sql:{icon:ft,color:"text-blue-500"},graphql:{icon:De,color:"text-pink-500"},gql:{icon:De,color:"text-pink-500"},proto:{icon:ue,color:"text-green-500"},env:{icon:Z,color:"text-yellow-600"},md:{icon:ye,color:"text-blue-500"},mdx:{icon:ye,color:"text-blue-400"},txt:{icon:B,color:"text-gray-500"},doc:{icon:B,color:"text-blue-600"},docx:{icon:B,color:"text-blue-600"},pdf:{icon:be,color:"text-red-600"},rtf:{icon:B,color:"text-gray-500"},tex:{icon:ge,color:"text-teal-600"},rst:{icon:B,color:"text-gray-400"},sh:{icon:X,color:"text-green-500"},bash:{icon:X,color:"text-green-500"},zsh:{icon:X,color:"text-green-400"},fish:{icon:X,color:"text-green-400"},ps1:{icon:X,color:"text-blue-400"},bat:{icon:X,color:"text-gray-500"},cmd:{icon:X,color:"text-gray-500"},png:{icon:H,color:"text-purple-500"},jpg:{icon:H,color:"text-purple-500"},jpeg:{icon:H,color:"text-purple-500"},gif:{icon:H,color:"text-purple-400"},webp:{icon:H,color:"text-purple-400"},ico:{icon:H,color:"text-purple-400"},bmp:{icon:H,color:"text-purple-400"},tiff:{icon:H,color:"text-purple-400"},svg:{icon:ut,color:"text-amber-500"},mp3:{icon:Q,color:"text-pink-500"},wav:{icon:Q,color:"text-pink-500"},ogg:{icon:Q,color:"text-pink-400"},flac:{icon:Q,color:"text-pink-400"},aac:{icon:Q,color:"text-pink-400"},m4a:{icon:Q,color:"text-pink-400"},mp4:{icon:le,color:"text-rose-500"},mov:{icon:le,color:"text-rose-500"},avi:{icon:le,color:"text-rose-500"},webm:{icon:le,color:"text-rose-400"},mkv:{icon:le,color:"text-rose-400"},ttf:{icon:ne,color:"text-red-500"},otf:{icon:ne,color:"text-red-500"},woff:{icon:ne,color:"text-red-400"},woff2:{icon:ne,color:"text-red-400"},eot:{icon:ne,color:"text-red-400"},zip:{icon:Y,color:"text-amber-600"},tar:{icon:Y,color:"text-amber-600"},gz:{icon:Y,color:"text-amber-600"},bz2:{icon:Y,color:"text-amber-600"},rar:{icon:Y,color:"text-amber-500"},"7z":{icon:Y,color:"text-amber-500"},lock:{icon:W,color:"text-gray-500"},exe:{icon:J,color:"text-gray-500"},bin:{icon:J,color:"text-gray-500"},dll:{icon:J,color:"text-gray-400"},so:{icon:J,color:"text-gray-400"},dylib:{icon:J,color:"text-gray-400"},wasm:{icon:J,color:"text-purple-500"},ini:{icon:A,color:"text-gray-500"},cfg:{icon:A,color:"text-gray-500"},conf:{icon:A,color:"text-gray-500"},log:{icon:ge,color:"text-gray-400"},map:{icon:qe,color:"text-gray-400"}},$e={Dockerfile:{icon:ue,color:"text-blue-500"},"docker-compose.yml":{icon:ue,color:"text-blue-500"},"docker-compose.yaml":{icon:ue,color:"text-blue-500"},".dockerignore":{icon:ue,color:"text-gray-500"},".gitignore":{icon:A,color:"text-gray-500"},".gitmodules":{icon:A,color:"text-gray-500"},".gitattributes":{icon:A,color:"text-gray-500"},".editorconfig":{icon:A,color:"text-gray-500"},".prettierrc":{icon:A,color:"text-pink-400"},".prettierignore":{icon:A,color:"text-gray-500"},".eslintrc":{icon:A,color:"text-violet-500"},".eslintrc.js":{icon:A,color:"text-violet-500"},".eslintrc.json":{icon:A,color:"text-violet-500"},".eslintrc.cjs":{icon:A,color:"text-violet-500"},"eslint.config.js":{icon:A,color:"text-violet-500"},"eslint.config.mjs":{icon:A,color:"text-violet-500"},".env":{icon:Z,color:"text-yellow-600"},".env.local":{icon:Z,color:"text-yellow-600"},".env.development":{icon:Z,color:"text-yellow-500"},".env.production":{icon:Z,color:"text-yellow-600"},".env.example":{icon:Z,color:"text-yellow-400"},"package.json":{icon:re,color:"text-green-500"},"package-lock.json":{icon:W,color:"text-gray-500"},"yarn.lock":{icon:W,color:"text-blue-400"},"pnpm-lock.yaml":{icon:W,color:"text-orange-400"},"bun.lockb":{icon:W,color:"text-gray-400"},"Cargo.toml":{icon:de,color:"text-orange-600"},"Cargo.lock":{icon:W,color:"text-orange-400"},Gemfile:{icon:je,color:"text-red-500"},"Gemfile.lock":{icon:W,color:"text-red-400"},Makefile:{icon:X,color:"text-gray-500"},"CMakeLists.txt":{icon:de,color:"text-blue-500"},"tsconfig.json":{icon:re,color:"text-blue-500"},"jsconfig.json":{icon:re,color:"text-yellow-500"},"vite.config.ts":{icon:we,color:"text-purple-500"},"vite.config.js":{icon:we,color:"text-purple-500"},"webpack.config.js":{icon:de,color:"text-blue-500"},"tailwind.config.js":{icon:te,color:"text-cyan-500"},"tailwind.config.ts":{icon:te,color:"text-cyan-500"},"postcss.config.js":{icon:de,color:"text-red-400"},"babel.config.js":{icon:A,color:"text-yellow-500"},".babelrc":{icon:A,color:"text-yellow-500"},"README.md":{icon:ye,color:"text-blue-500"},LICENSE:{icon:be,color:"text-gray-500"},"LICENSE.md":{icon:be,color:"text-gray-500"},"CHANGELOG.md":{icon:ge,color:"text-blue-400"},"requirements.txt":{icon:B,color:"text-emerald-400"},"go.mod":{icon:ce,color:"text-cyan-500"},"go.sum":{icon:W,color:"text-cyan-400"}};function Tt(e){if($e[e])return $e[e];if(e.startsWith(".env"))return{icon:Z,color:"text-yellow-600"};const r=e.split(".").pop()?.toLowerCase();return r&&Pe[r]?Pe[r]:{icon:qe,color:"text-muted-foreground"}}function Et(){const[e,r]=a.useState(()=>new Set),o=a.useCallback(s=>{r(u=>{const c=new Set(u);return c.has(s)?c.delete(s):c.add(s),c})},[]),l=a.useCallback(s=>{s.length!==0&&r(u=>{const c=new Set(u);return s.forEach(x=>c.add(x)),c})},[]),i=a.useCallback(()=>{r(new Set)},[]);return{expandedDirs:e,toggleDirectory:o,expandDirectories:l,collapseAll:i}}const ze="Unable to load the file tree for this project.";function St(e){try{const r=JSON.parse(e),o=typeof r=="object"&&r!==null&&"error"in r?r.error:null;return typeof o=="string"&&o.trim()?o:null}catch{return null}}function Dt(e){const[r,o]=a.useState([]),[l,i]=a.useState(!1),[s,u]=a.useState(null),[c,x]=a.useState(0),b=a.useRef(null),g=a.useCallback(()=>{x(v=>v+1)},[]);return a.useEffect(()=>{const v=e?.projectId;if(!v){o([]),i(!1),u(null);return}b.current&&b.current.abort(),b.current=new AbortController;let d=!0;return(async()=>{d&&(i(!0),u(null));try{const y=await ee.getFiles(v,{signal:b.current.signal});if(!y.ok){const N=await y.text();console.error("File fetch failed:",y.status,N),d&&(o([]),u(St(N)??ze));return}const E=await y.json();d&&o(E)}catch(y){if(y.name==="AbortError")return;console.error("Error fetching files:",y),d&&(o([]),u(ze))}finally{d&&i(!1)}})(),()=>{d=!1,b.current?.abort()}},[e?.projectId,c]),{files:r,loading:l,error:s,refreshFiles:g}}const It=/[<>:"/\\|?*\x00-\x1f]/,Rt=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/i;function At({selectedProject:e,onRefresh:r,showToast:o}){const{t:l}=V(),[i,s]=a.useState(null),[u,c]=a.useState(""),[x,b]=a.useState({isOpen:!1,item:null}),[g,v]=a.useState(!1),[d,f]=a.useState(""),[y,E]=a.useState("file"),[N,S]=a.useState(""),[L,D]=a.useState(!1),R=a.useCallback(m=>!m||!m.trim()?l("fileTree.validation.emptyName","Filename cannot be empty"):It.test(m)?l("fileTree.validation.invalidChars","Filename contains invalid characters"):Rt.test(m)?l("fileTree.validation.reserved","Filename is a reserved name"):/^\.+$/.test(m)?l("fileTree.validation.dotsOnly","Filename cannot be only dots"):null,[l]),M=a.useCallback(m=>{s(m),c(m.name),v(!1)},[]),h=a.useCallback(()=>{s(null),c("")},[]),n=a.useCallback(async()=>{if(!i||!e)return;const m=R(u);if(m){o(m,"error");return}if(u===i.name){h();return}D(!0);try{const k=await ee.renameFile(e.projectId,{oldPath:i.path,newName:u});if(!k.ok){const T=await k.json();throw new Error(T.error||"Failed to rename")}o(l("fileTree.toast.renamed","Renamed successfully"),"success"),r(),h()}catch(k){o(k.message,"error")}finally{D(!1)}},[i,u,e,R,o,l,r,h]),p=a.useCallback(m=>{b({isOpen:!0,item:m})},[]),w=a.useCallback(()=>{b({isOpen:!1,item:null})},[]),C=a.useCallback(async()=>{const{item:m}=x;if(!(!m||!e)){D(!0);try{const k=await ee.deleteFile(e.projectId,{path:m.path,type:m.type});if(!k.ok){const T=await k.json();throw new Error(T.error||"Failed to delete")}o(m.type==="directory"?l("fileTree.toast.folderDeleted","Folder deleted"):l("fileTree.toast.fileDeleted","File deleted"),"success"),r(),w()}catch(k){o(k.message,"error")}finally{D(!1)}}},[x,e,o,l,r,w]),F=a.useCallback((m,k)=>{f(m||""),E(k),S(k==="file"?"untitled.txt":"new-folder"),v(!0),s(null)},[]),I=a.useCallback(()=>{v(!1),f(""),S("")},[]),P=a.useCallback(async()=>{if(!e)return;const m=R(N);if(m){o(m,"error");return}D(!0);try{const k=await ee.createFile(e.projectId,{path:d,type:y,name:N});if(!k.ok){const T=await k.json();throw new Error(T.error||"Failed to create")}o(y==="file"?l("fileTree.toast.fileCreated","File created successfully"):l("fileTree.toast.folderCreated","Folder created successfully"),"success"),r(),I()}catch(k){o(k.message,"error")}finally{D(!1)}},[e,d,y,N,R,o,l,r,I]),G=a.useCallback(m=>{navigator.clipboard.writeText(m.path).catch(()=>{o(l("fileTree.toast.copyFailed","Failed to copy path"),"error")}),o(l("fileTree.toast.pathCopied","Path copied to clipboard"),"success")},[o,l]),_=a.useCallback((m,k)=>{const T=URL.createObjectURL(m),K=document.createElement("a");K.href=T,K.download=k,document.body.appendChild(K),K.click(),document.body.removeChild(K),URL.revokeObjectURL(T)},[]),O=a.useCallback(async m=>{if(!e)return;const k=await ee.readFileBlob(e.projectId,m.path);if(!k.ok)throw new Error("Failed to download file");const T=await k.blob();_(T,m.name)},[e,_]),q=a.useCallback(async m=>{if(!e)return;const k=new Ft,T=async($,Ee)=>{const Se=Ee?`${Ee}/${$.name}`:$.name;if($.type==="file"){const fe=await ee.readFileBlob(e.projectId,$.path);if(!fe.ok)throw new Error(`Failed to download "${$.name}" for ZIP export`);const nt=await fe.arrayBuffer();k.file(Se,nt)}else if($.type==="directory"&&$.children)for(const fe of $.children)await T(fe,Se)};if(m.children&&m.children.length>0)for(const $ of m.children)await T($,"");const K=await k.generateAsync({type:"blob"});_(K,`${m.name}.zip`),o(l("fileTree.toast.folderDownloaded","Folder downloaded as ZIP"),"success")},[e,o,l,_]),j=a.useCallback(async m=>{if(e){D(!0);try{m.type==="directory"?await q(m):await O(m)}catch(k){o(k.message,"error")}finally{D(!1)}}},[q,O,e,o]);return{renamingItem:i,renameValue:u,handleStartRename:M,handleCancelRename:h,handleConfirmRename:n,setRenameValue:c,deleteConfirmation:x,handleStartDelete:p,handleCancelDelete:w,handleConfirmDelete:C,isCreating:g,newItemParent:d,newItemType:y,newItemName:N,handleStartCreate:F,handleCancelCreate:I,handleConfirmCreate:P,setNewItemName:S,handleCopyPath:G,handleDownload:j,operationLoading:L,validateFilename:R}}const Be="file-tree-view-mode",Lt="detailed",Mt=["simple","compact","detailed"],Ye=200,Ut=Ye*1024*1024,ke=`${Ye}MB`,Ve=20,Ot=new Set(["png","jpg","jpeg","gif","svg","webp","ico","bmp"]);function Qe(e,r){return e.reduce((o,l)=>{const i=l.name.toLowerCase().includes(r),s=l.type==="directory"&&l.children?Qe(l.children,r):[];return(i||s.length>0)&&o.push({...l,children:s}),o},[])}function _t(e){const r=[],o=l=>{l.forEach(i=>{i.type==="directory"&&i.children&&i.children.length>0&&(r.push(i.path),o(i.children))})};return o(e),r}function Pt(e){if(!e||e===0)return"0 B";const r=1024,o=["B","KB","MB","GB"],l=Math.floor(Math.log(e)/Math.log(r));return`${(e/Math.pow(r,l)).toFixed(1).replace(/\.0$/,"")} ${o[l]}`}function $t(e,r){if(!e)return"-";const o=new Date,l=new Date(e),i=Math.floor((o.getTime()-l.getTime())/1e3);return i<60?r("fileTree.justNow"):i<3600?r("fileTree.minAgo",{count:Math.floor(i/60)}):i<86400?r("fileTree.hoursAgo",{count:Math.floor(i/3600)}):i<2592e3?r("fileTree.daysAgo",{count:Math.floor(i/86400)}):l.toLocaleDateString()}function zt(e){const r=e.split(".").pop()?.toLowerCase();return!!(r&&Ot.has(r))}function Bt({files:e,expandDirectories:r}){const[o,l]=a.useState(""),[i,s]=a.useState(e);return a.useEffect(()=>{const u=o.trim().toLowerCase();if(!u){s(e);return}const c=Qe(e,u);s(c),r(_t(c))},[e,o,r]),{searchQuery:o,setSearchQuery:l,filteredFiles:i}}function Vt(){const[e,r]=a.useState(Lt);a.useEffect(()=>{try{const l=localStorage.getItem(Be);l&&Mt.includes(l)&&r(l)}catch{}},[]);const o=a.useCallback(l=>{r(l);try{localStorage.setItem(Be,l)}catch{}},[]);return{viewMode:e,changeViewMode:o}}const Gt=1400,Ht=3200,Ge=e=>e===1?"file":"files",et=e=>e.webkitRelativePath||e.name,tt=e=>et(e).split(/[\\/]/).pop()||e.name,Wt=e=>{if(e.length>Ve)return`You can upload up to ${Ve} files at once.`;const r=e.find(o=>o.size>Ut);return r?`${tt(r)} is larger than ${ke}.`:null},Xt=e=>{if(!e.responseText)return{};try{return JSON.parse(e.responseText)}catch{return{}}},qt=(e,r)=>e!==r?`Uploaded ${e} of ${r} ${Ge(r)}`:`Uploaded ${e} ${Ge(e)} successfully`,Kt=(e,r)=>{const o=new FormData,l=[];return o.append("targetPath",r),o.append("requestedFileCount",String(e.length)),e.forEach(i=>{const s=et(i),u=new File([i],s.split(/[\\/]/).pop()||i.name,{type:i.type,lastModified:i.lastModified});o.append("files",u),l.push(s)}),o.append("relativePaths",JSON.stringify(l)),o},Zt=(e,r,o)=>new Promise((l,i)=>{const s=new XMLHttpRequest;s.open("POST",`/api/file-tree/projects/${encodeURIComponent(e)}/files/upload`);const u=lt();!at&&u&&s.setRequestHeader("Authorization",`Bearer ${u}`),s.upload.onprogress=c=>{c.lengthComputable&&o(Math.min(99,Math.round(c.loaded/c.total*100)))},s.onload=()=>{const c=s.getResponseHeader("X-Refreshed-Token");c&&st(c),s.getResponseHeader("X-Auth-Error")&&it();const x=Xt(s);if(s.status>=200&&s.status<300){l(x);return}i(new Error(x.error||x.message||`Upload failed with status ${s.status}`))},s.onerror=()=>i(new Error("Upload failed. Check your connection and try again.")),s.onabort=()=>i(new Error("Upload canceled.")),s.send(r)}),rt=async(e,r="")=>{const o=[],l=e.createReader();let i=[],s;do s=await new Promise((c,x)=>{l.readEntries(c,x)}),i=i.concat(s);while(s.length>0);const u=[".DS_Store","Thumbs.db","desktop.ini"];for(const c of i){const x=r?`${r}/${c.name}`:c.name;if(c.isFile){const b=c,g=await new Promise((d,f)=>{b.file(d,f)});if(u.includes(g.name))continue;const v=new File([g],x,{type:g.type,lastModified:g.lastModified});o.push(v)}else if(c.isDirectory){const g=await rt(c,x);o.push(...g)}}return o},Jt=async e=>{const r=[],{items:o}=e;if(o){for(const l of Array.from(o)){if(l.kind!=="file")continue;const i=l.webkitGetAsEntry?l.webkitGetAsEntry():null;if(!i){const s=l.getAsFile();s&&r.push(s);continue}if(i.isFile){const s=await new Promise((u,c)=>{i.file(u,c)});r.push(s)}else if(i.isDirectory){const s=await rt(i,i.name);r.push(...s)}}return r}for(const l of Array.from(e.files))r.push(l);return r},Yt=({selectedProject:e,onRefresh:r,showToast:o})=>{const[l,i]=a.useState(!1),[s,u]=a.useState(null),[c,x]=a.useState(!1),[b,g]=a.useState(null),v=a.useRef(null),d=a.useRef(null),f=a.useCallback(()=>{d.current&&(clearTimeout(d.current),d.current=null)},[]),y=a.useCallback(n=>{f(),d.current=setTimeout(()=>{g(null),d.current=null},n)},[f]);a.useEffect(()=>f,[f]);const E=a.useCallback((n,p,w="",C,F=0)=>{g({status:"error",progress:F,fileCount:p,fileName:C,targetPath:w,error:n}),y(Ht)},[y]),N=a.useCallback(async(n,p="")=>{if(n.length===0){u(null);return}const w=n.length===1?tt(n[0]):void 0;if(!e){const I="Select a project before uploading files.";o(I,"error"),E(I,n.length,p,w);return}const C=Wt(n);if(C){o(C,"error"),E(C,n.length,p,w);return}f(),x(!0),g({status:"uploading",progress:0,fileCount:n.length,fileName:w,targetPath:p});let F=0;try{const I=await Zt(e.projectId,Kt(n,p),_=>{F=_,g(O=>O&&O.status==="uploading"?{...O,progress:_}:O)}),P=typeof I.uploadedCount=="number"?I.uploadedCount:I.files?.length??n.length,G=typeof I.requestedFileCount=="number"?I.requestedFileCount:n.length;g({status:"complete",progress:100,fileCount:G,uploadedCount:P,fileName:w,targetPath:p}),o(qt(P,G),"success"),y(Gt),r()}catch(I){const P=I instanceof Error?I.message:"Upload failed";console.error("Upload error:",I),o(P,"error"),E(P,n.length,p,w,F)}finally{x(!1),u(null)}},[f,r,y,e,E,o]),S=a.useCallback(async n=>{await N(Array.from(n),"")},[N]),L=a.useCallback(n=>{n.preventDefault(),n.stopPropagation(),i(!0)},[]),D=a.useCallback(n=>{n.preventDefault(),n.stopPropagation(),u(null)},[]),R=a.useCallback(n=>{n.preventDefault(),n.stopPropagation(),v.current&&!v.current.contains(n.relatedTarget)&&(i(!1),u(null))},[]),M=a.useCallback(async n=>{n.preventDefault(),n.stopPropagation(),i(!1);const p=s||"";try{const w=await Jt(n.dataTransfer);await N(w,p)}catch(w){const C=w instanceof Error?w.message:"Could not read dropped files";console.error("Upload error:",w),o(C,"error"),E(C,0,p),u(null)}},[s,E,o,N]),h=a.useCallback((n,p)=>{n.preventDefault(),n.stopPropagation(),u(p)},[]);return{isDragOver:l,dropTarget:s,operationLoading:c,uploadProgress:b,treeRef:v,uploadFiles:N,handleFileSelect:S,handleDragEnter:L,handleDragOver:D,handleDragLeave:R,handleDrop:M,handleItemDragOver:h,setDropTarget:u}};function he({icon:e,title:r,description:o}){return t.jsxs("div",{className:"py-8 text-center",children:[t.jsx("div",{className:"mx-auto mb-3 flex h-12 w-12 items-center justify-center rounded-lg bg-muted",children:t.jsx(e,{className:"h-6 w-6 text-muted-foreground"})}),t.jsx("h4",{className:"mb-1 font-medium text-foreground",children:r}),t.jsx("p",{className:"text-sm text-muted-foreground",children:o})]})}const He=200,We=300,pe=10;function Qt(e,r){const o=e+He>window.innerWidth?window.innerWidth-He-pe:e,l=r+We>window.innerHeight?window.innerHeight-We-pe:r;return{x:Math.max(pe,o),y:Math.max(pe,l)}}function er({children:e,item:r,onRename:o,onDelete:l,onNewFile:i,onNewFolder:s,onUpload:u,onRefresh:c,onCopyPath:x,onDownload:b,isLoading:g=!1,className:v=""}){const{t:d}=V(),[f,y]=a.useState(!1),[E,N]=a.useState({x:0,y:0}),S=a.useRef(null),L=a.useCallback(()=>{y(!1)},[]),D=a.useCallback(h=>{h.preventDefault(),h.stopPropagation(),N(Qt(h.clientX,h.clientY)),y(!0)},[]),R=a.useCallback(h=>{L(),h?.()},[L]),M=a.useMemo(()=>r?.type==="file"?[{key:"rename",icon:Le,label:d("fileTree.context.rename","Rename"),onSelect:()=>o?.(r)},{key:"delete",icon:Me,label:d("fileTree.context.delete","Delete"),onSelect:()=>l?.(r),isDanger:!0},{key:"copyPath",icon:Ue,label:d("fileTree.context.copyPath","Copy Path"),onSelect:()=>x?.(r),showDividerBefore:!0},{key:"download",icon:Oe,label:d("fileTree.context.download","Download"),onSelect:()=>b?.(r)}]:r?.type==="directory"?[{key:"newFile",icon:B,label:d("fileTree.context.newFile","New File"),onSelect:()=>i?.(r.path)},{key:"newFolder",icon:ve,label:d("fileTree.context.newFolder","New Folder"),onSelect:()=>s?.(r.path)},{key:"upload",icon:oe,label:d("fileTree.context.upload","Upload Files"),onSelect:()=>u?.(r.path)},{key:"rename",icon:Le,label:d("fileTree.context.rename","Rename"),onSelect:()=>o?.(r),showDividerBefore:!0},{key:"delete",icon:Me,label:d("fileTree.context.delete","Delete"),onSelect:()=>l?.(r),isDanger:!0},{key:"copyPath",icon:Ue,label:d("fileTree.context.copyPath","Copy Path"),onSelect:()=>x?.(r),showDividerBefore:!0},{key:"download",icon:Oe,label:d("fileTree.context.download","Download"),onSelect:()=>b?.(r)}]:[{key:"newFile",icon:B,label:d("fileTree.context.newFile","New File"),onSelect:()=>i?.("")},{key:"newFolder",icon:ve,label:d("fileTree.context.newFolder","New Folder"),onSelect:()=>s?.("")},{key:"upload",icon:oe,label:d("fileTree.context.upload","Upload Files"),onSelect:()=>u?.("")},{key:"refresh",icon:Ce,label:d("fileTree.context.refresh","Refresh"),onSelect:c,showDividerBefore:!0}],[r,x,l,b,i,s,c,o,u,d]);return a.useEffect(()=>{if(!f)return;const h=p=>{const w=S.current;w&&!w.contains(p.target)&&L()},n=p=>{p.key==="Escape"&&L()};return document.addEventListener("mousedown",h),document.addEventListener("keydown",n),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",n)}},[L,f]),a.useEffect(()=>{if(!f)return;const h=n=>{const p=S.current?.querySelectorAll('[role="menuitem"]:not([disabled])');if(!p||p.length===0)return;const w=document.activeElement,C=Array.from(p).findIndex(F=>F===w);if(n.key==="ArrowDown"){n.preventDefault();const F=C<p.length-1?C+1:0;p[F]?.focus()}else if(n.key==="ArrowUp"){n.preventDefault();const F=C>0?C-1:p.length-1;p[F]?.focus()}else(n.key==="Enter"||n.key===" ")&&w?.hasAttribute("role")&&(n.preventDefault(),w.click())};return document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h)}},[f]),t.jsxs(t.Fragment,{children:[t.jsx("div",{onContextMenu:D,className:U("contents",v),children:e}),f&&t.jsx("div",{ref:S,role:"menu","aria-label":d("fileTree.context.menuLabel","File context menu"),style:{position:"fixed",left:E.x,top:E.y,zIndex:9999},className:U("min-w-[180px] py-1 px-1","bg-popover border border-border rounded-lg shadow-lg","animate-in fade-in-0 zoom-in-95","data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95"),children:g?t.jsxs("div",{className:"flex items-center justify-center py-4",children:[t.jsx(Ce,{className:"h-4 w-4 animate-spin text-muted-foreground"}),t.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:d("fileTree.context.loading","Loading...")})]}):M.map(h=>t.jsxs(a.Fragment,{children:[h.showDividerBefore&&t.jsx("div",{className:"mx-2 my-1 h-px bg-border"}),t.jsxs("button",{role:"menuitem",tabIndex:h.isDisabled?-1:0,disabled:g||h.isDisabled,onClick:()=>R(h.onSelect),className:U("w-full flex items-center gap-3 px-3 py-2 text-sm text-left rounded-md transition-colors","focus:outline-none focus:bg-accent",h.isDisabled?"opacity-50 cursor-not-allowed":h.isDanger?"text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-950":"hover:bg-accent",g&&"pointer-events-none"),children:[h.icon&&t.jsx(h.icon,{className:"h-4 w-4 flex-shrink-0"}),t.jsx("span",{className:"flex-1",children:h.label}),h.shortcut&&t.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:h.shortcut})]})]},h.key))})]})}function tr(e){const r=e.split(/[\\/]/);return r.pop(),r.join("/")}function me({item:e,isOpen:r,renderFileIcon:o}){return e.type==="directory"?t.jsxs("span",{className:"flex flex-shrink-0 items-center gap-0.5",children:[t.jsx(gt,{className:U("w-3.5 h-3.5 text-muted-foreground/70 transition-transform duration-150",r&&"rotate-90")}),r?t.jsx(bt,{className:"h-4 w-4 flex-shrink-0 text-blue-500"}):t.jsx(Fe,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]}):t.jsx("span",{className:"ml-[18px] flex flex-shrink-0 items-center",children:o(e.name)})}function ot({item:e,level:r,viewMode:o,expandedDirs:l,onItemClick:i,renderFileIcon:s,formatFileSize:u,formatRelativeTime:c,onRename:x,onDelete:b,onNewFile:g,onNewFolder:v,onCopyPath:d,onDownload:f,onUpload:y,onRefresh:E,dropTarget:N,onItemDragOver:S,renamingItem:L,renameValue:D,setRenameValue:R,handleConfirmRename:M,handleCancelRename:h,renameInputRef:n,operationLoading:p}){const{t:w}=V(),C=e.type==="directory",F=C&&l.has(e.path),I=!!(C&&e.children&&e.children.length>0),P=L?.path===e.path,G=C?e.path:tr(e.path),_=C&&N===e.path,O=U("text-[13px] leading-tight truncate",C?"font-medium text-foreground":"text-foreground/90"),q=U(o==="detailed"?"group grid grid-cols-12 gap-2 py-[3px] pr-2 hover:bg-accent/60 cursor-pointer items-center rounded-sm transition-colors duration-100":o==="compact"?"group flex items-center justify-between py-[3px] pr-2 hover:bg-accent/60 cursor-pointer rounded-sm transition-colors duration-100":"group flex items-center gap-1.5 py-[3px] pr-2 cursor-pointer rounded-sm hover:bg-accent/60 transition-colors duration-100",C&&F&&"border-l-2 border-primary/30",C&&!F||!C?"border-l-2 border-transparent":"","relative",_&&"bg-blue-500/10 ring-1 ring-inset ring-blue-500/40");if(P&&R&&M&&h)return t.jsxs("div",{className:U(q,"bg-accent/30"),style:{paddingLeft:`${r*16+4}px`},onClick:T=>T.stopPropagation(),children:[t.jsx(me,{item:e,isOpen:F,renderFileIcon:s}),t.jsx(Ne,{ref:n,type:"text",value:D||"",onChange:T=>R(T.target.value),onKeyDown:T=>{T.stopPropagation(),T.key==="Enter"&&M(),T.key==="Escape"&&h()},onBlur:()=>{setTimeout(()=>{M()},100)},className:"h-6 flex-1 text-sm",disabled:p})]});const j=C&&y&&t.jsx("button",{type:"button",onClick:T=>{T.stopPropagation(),y(e.path)},title:w("fileTree.uploadToFolder",'Upload files to "{{folder}}"',{folder:e.name}),"aria-label":w("fileTree.uploadToFolder",'Upload files to "{{folder}}"',{folder:e.name}),className:U("absolute right-1 top-1/2 -translate-y-1/2 rounded p-1","bg-background/80 text-muted-foreground opacity-0 transition-opacity","group-hover:opacity-100 focus-visible:opacity-100 hover:bg-accent hover:text-foreground"),children:t.jsx(oe,{className:"h-3.5 w-3.5"})}),m=t.jsxs("div",{className:q,style:{paddingLeft:`${r*16+4}px`},onClick:()=>i(e),onDragOver:S?T=>S(T,G):void 0,children:[o==="detailed"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"col-span-5 flex min-w-0 items-center gap-1.5",children:[t.jsx(me,{item:e,isOpen:F,renderFileIcon:s}),t.jsx("span",{className:O,children:e.name})]}),t.jsx("div",{className:"col-span-2 text-sm tabular-nums text-muted-foreground",children:e.type==="file"?u(e.size):""}),t.jsx("div",{className:"col-span-3 text-sm text-muted-foreground",children:c(e.modified)}),t.jsx("div",{className:"col-span-2 font-mono text-sm text-muted-foreground",children:e.permissionsRwx||""})]}):o==="compact"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx(me,{item:e,isOpen:F,renderFileIcon:s}),t.jsx("span",{className:O,children:e.name})]}),t.jsx("div",{className:"ml-2 flex flex-shrink-0 items-center gap-3 text-sm text-muted-foreground",children:e.type==="file"&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"tabular-nums",children:u(e.size)}),t.jsx("span",{className:"font-mono",children:e.permissionsRwx})]})})]}):t.jsxs(t.Fragment,{children:[t.jsx(me,{item:e,isOpen:F,renderFileIcon:s}),t.jsx("span",{className:O,children:e.name})]}),j]}),k=x||b||g||v||d||f||E;return t.jsxs("div",{className:"select-none",children:[k?t.jsx(er,{item:e,onRename:x,onDelete:b,onNewFile:g,onNewFolder:v,onUpload:y,onCopyPath:d,onDownload:f,onRefresh:E,children:m}):m,C&&F&&I&&t.jsxs("div",{className:"relative",children:[t.jsx("span",{className:"absolute bottom-0 top-0 border-l border-border/40",style:{left:`${r*16+14}px`},"aria-hidden":"true"}),e.children?.map(T=>t.jsx(ot,{item:T,level:r+1,viewMode:o,expandedDirs:l,onItemClick:i,renderFileIcon:s,formatFileSize:u,formatRelativeTime:c,onRename:x,onDelete:b,onNewFile:g,onNewFolder:v,onCopyPath:d,onDownload:f,onUpload:y,onRefresh:E,dropTarget:N,onItemDragOver:S,renamingItem:L,renameValue:D,setRenameValue:R,handleConfirmRename:M,handleCancelRename:h,renameInputRef:n,operationLoading:p},T.path))]})]})}function rr({items:e,viewMode:r,expandedDirs:o,onItemClick:l,renderFileIcon:i,formatFileSize:s,formatRelativeTime:u,onRename:c,onDelete:x,onNewFile:b,onNewFolder:g,onCopyPath:v,onDownload:d,onUpload:f,onRefresh:y,dropTarget:E,onItemDragOver:N,renamingItem:S,renameValue:L,setRenameValue:D,handleConfirmRename:R,handleCancelRename:M,renameInputRef:h,operationLoading:n}){return t.jsx("div",{children:e.map(p=>t.jsx(ot,{item:p,level:0,viewMode:r,expandedDirs:o,onItemClick:l,renderFileIcon:i,formatFileSize:s,formatRelativeTime:u,onRename:c,onDelete:x,onNewFile:b,onNewFolder:g,onCopyPath:v,onDownload:d,onUpload:f,onRefresh:y,dropTarget:E,onItemDragOver:N,renamingItem:S,renameValue:L,setRenameValue:D,handleConfirmRename:R,handleCancelRename:M,renameInputRef:h,operationLoading:n},p.path))})}function or({files:e,filteredFiles:r,error:o,searchQuery:l,viewMode:i,expandedDirs:s,onItemClick:u,renderFileIcon:c,formatFileSize:x,formatRelativeTime:b,onRename:g,onDelete:v,onNewFile:d,onNewFolder:f,onCopyPath:y,onDownload:E,onUpload:N,onRefresh:S,dropTarget:L,onItemDragOver:D,renamingItem:R,renameValue:M,setRenameValue:h,handleConfirmRename:n,handleCancelRename:p,renameInputRef:w,operationLoading:C}){const{t:F}=V();return t.jsx(t.Fragment,{children:o?t.jsx(he,{icon:Ke,title:F("fileTree.loadFailed"),description:o}):e.length===0?t.jsx(he,{icon:Fe,title:F("fileTree.noFilesFound"),description:F("fileTree.checkProjectPath")}):r.length===0&&l?t.jsx(he,{icon:Ze,title:F("fileTree.noMatchesFound"),description:F("fileTree.tryDifferentSearch")}):t.jsx(rr,{items:r,viewMode:i,expandedDirs:s,onItemClick:u,renderFileIcon:c,formatFileSize:x,formatRelativeTime:b,onRename:g,onDelete:v,onNewFile:d,onNewFolder:f,onCopyPath:y,onDownload:E,onUpload:N,onRefresh:S,dropTarget:L,onItemDragOver:D,renamingItem:R,renameValue:M,setRenameValue:h,handleConfirmRename:n,handleCancelRename:p,renameInputRef:w,operationLoading:C})})}function nr(){const{t:e}=V();return t.jsx("div",{className:"border-b border-border px-3 pb-1 pt-1.5",children:t.jsxs("div",{className:"grid grid-cols-12 gap-2 px-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:[t.jsx("div",{className:"col-span-5",children:e("fileTree.name")}),t.jsx("div",{className:"col-span-2",children:e("fileTree.size")}),t.jsx("div",{className:"col-span-3",children:e("fileTree.modified")}),t.jsx("div",{className:"col-span-2",children:e("fileTree.permissions")})]})})}function lr({viewMode:e,onViewModeChange:r,searchQuery:o,onSearchQueryChange:l,onNewFile:i,onNewFolder:s,onUploadFiles:u,onRefresh:c,onCollapseAll:x,loading:b,operationLoading:g,isUploading:v,uploadProgress:d}){const{t:f}=V(),y=a.useRef(null),E=N=>{const{files:S}=N.target;S&&S.length>0&&u?.(S),N.target.value=""};return t.jsxs("div",{className:"space-y-2 border-b border-border px-3 pb-2 pt-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h3",{className:"text-sm font-medium text-foreground",children:f("fileTree.files")}),t.jsxs("div",{className:"flex items-center gap-0.5",children:[u&&t.jsxs(t.Fragment,{children:[t.jsx("input",{ref:y,type:"file",multiple:!0,className:"hidden",onChange:E,tabIndex:-1,"aria-hidden":"true"}),t.jsxs(z,{variant:"ghost",size:"sm",className:"relative h-7 w-7 p-0",onClick:()=>y.current?.click(),title:v?f("fileTree.uploadingFiles","Uploading files"):f("fileTree.uploadFiles","Upload files (max {{size}} each)",{size:ke}),"aria-label":f("fileTree.uploadFiles","Upload files (max {{size}} each)",{size:ke}),disabled:g,children:[v?t.jsx(Je,{className:"h-3.5 w-3.5 animate-spin"}):t.jsx(oe,{className:"h-3.5 w-3.5"}),v&&typeof d=="number"&&t.jsx("span",{className:"absolute bottom-0.5 left-1/2 h-0.5 w-4 -translate-x-1/2 overflow-hidden rounded-full bg-primary/20",children:t.jsx("span",{className:"block h-full rounded-full bg-primary transition-[width] duration-150",style:{width:`${d}%`}})})]})]}),i&&t.jsx(z,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:i,title:f("fileTree.newFile","New File (Cmd+N)"),"aria-label":f("fileTree.newFile","New File (Cmd+N)"),disabled:g,children:t.jsx(B,{className:"h-3.5 w-3.5"})}),s&&t.jsx(z,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:s,title:f("fileTree.newFolder","New Folder (Cmd+Shift+N)"),"aria-label":f("fileTree.newFolder","New Folder (Cmd+Shift+N)"),disabled:g,children:t.jsx(ve,{className:"h-3.5 w-3.5"})}),c&&t.jsx(z,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:c,title:f("fileTree.refresh","Refresh"),"aria-label":f("fileTree.refresh","Refresh"),disabled:g,children:t.jsx(Ce,{className:U("w-3.5 h-3.5",b&&"animate-spin")})}),x&&t.jsx(z,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:x,title:f("fileTree.collapseAll","Collapse All"),"aria-label":f("fileTree.collapseAll","Collapse All"),children:t.jsx(yt,{className:"h-3.5 w-3.5"})}),t.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),t.jsx(z,{variant:e==="simple"?"default":"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>r("simple"),title:f("fileTree.simpleView"),"aria-label":f("fileTree.simpleView"),children:t.jsx(wt,{className:"h-3.5 w-3.5"})}),t.jsx(z,{variant:e==="compact"?"default":"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>r("compact"),title:f("fileTree.compactView"),"aria-label":f("fileTree.compactView"),children:t.jsx(jt,{className:"h-3.5 w-3.5"})}),t.jsx(z,{variant:e==="detailed"?"default":"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>r("detailed"),title:f("fileTree.detailedView"),"aria-label":f("fileTree.detailedView"),children:t.jsx(vt,{className:"h-3.5 w-3.5"})})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx(Ze,{className:"absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),t.jsx(Ne,{type:"text",placeholder:f("fileTree.searchPlaceholder"),value:o,onChange:N=>l(N.target.value),className:"h-8 pl-8 pr-8 text-sm"}),o&&t.jsx(z,{variant:"ghost",size:"sm",className:"absolute right-0.5 top-1/2 h-5 w-5 -translate-y-1/2 p-0 hover:bg-accent",onClick:()=>l(""),title:f("fileTree.clearSearch"),"aria-label":f("fileTree.clearSearch"),children:t.jsx(Te,{className:"h-3 w-3"})})]})]})}function ar(){const{t:e}=V();return t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsx("div",{className:"text-sm text-muted-foreground",children:e("fileTree.loading")})})}const sr=e=>Math.min(100,Math.max(0,e)),Xe=e=>e===1?"file":"files";function ir({upload:e}){const{t:r}=V();if(!e)return null;const o=sr(e.progress),l=e.status==="uploading",i=e.status==="complete",s=e.status==="error",u=e.fileCount===1&&e.fileName?e.fileName:`${e.fileCount} ${Xe(e.fileCount)}`,c=l?r("fileTree.uploadingFiles","Uploading files"):i?r("fileTree.uploadComplete","Upload complete"):r("fileTree.uploadFailed","Upload failed"),x=s?e.error:i&&typeof e.uploadedCount=="number"?r("fileTree.uploadedCount","Uploaded {{uploaded}} of {{total}} {{label}}",{uploaded:e.uploadedCount,total:e.fileCount,label:Xe(e.fileCount)}):u,b=s?Ct:i?kt:oe;return t.jsxs("div",{className:U("border-b px-3 py-2 transition-colors",s?"border-red-500/20 bg-red-500/10 text-red-700 dark:text-red-300":i?"border-emerald-500/20 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":"border-primary/20 bg-primary/10 text-foreground"),children:[t.jsxs("div",{className:"flex min-h-[36px] items-center gap-2",children:[t.jsx("div",{className:U("flex h-7 w-7 shrink-0 items-center justify-center rounded-md",s?"bg-red-500/15":i?"bg-emerald-500/15":"bg-primary/15"),children:t.jsx(b,{className:U("h-3.5 w-3.5",l&&"animate-pulse")})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"truncate text-xs font-medium",children:c}),t.jsx("span",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground",children:l?`${o}%`:i?r("common.done","Done"):r("common.failed","Failed")})]}),t.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground",children:x})]})]}),t.jsx("div",{className:"mt-2 h-1.5 overflow-hidden rounded-full bg-background/80",children:t.jsx("div",{className:U("h-full rounded-full transition-[width] duration-200",s?"bg-red-500":i?"bg-emerald-500":"bg-primary"),style:{width:`${s?Math.max(o,8):o}%`}})})]})}function cr({file:e,onClose:r}){const o=`/api/file-tree/projects/${e.projectId}/files/content?path=${encodeURIComponent(e.path)}`,[l,i]=a.useState(null),[s,u]=a.useState(null),[c,x]=a.useState(!0);return a.useEffect(()=>{let b=null;const g=new AbortController;return(async()=>{try{x(!0),u(null),i(null);const d=await ct(o,{signal:g.signal});if(!d.ok)throw new Error(`Request failed with status ${d.status}`);const f=await d.blob();b=URL.createObjectURL(f),i(b)}catch(d){if(d instanceof Error&&d.name==="AbortError")return;console.error("Error loading image:",d),u("Unable to load image")}finally{x(!1)}})(),()=>{g.abort(),b&&URL.revokeObjectURL(b)}},[o]),t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50",children:t.jsxs("div",{className:"mx-4 max-h-[90vh] w-full max-w-4xl overflow-hidden rounded-lg bg-white shadow-xl dark:bg-gray-800",children:[t.jsxs("div",{className:"flex items-center justify-between border-b p-4",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:e.name}),t.jsx(z,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:t.jsx(Te,{className:"h-4 w-4"})})]}),t.jsxs("div",{className:"flex min-h-[400px] items-center justify-center bg-gray-50 p-4 dark:bg-gray-900",children:[c&&t.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400",children:t.jsx("p",{children:"Loading image..."})}),!c&&l&&t.jsx("img",{src:l,alt:e.name,className:"max-h-[70vh] max-w-full rounded-lg object-contain shadow-md"}),!c&&!l&&t.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[t.jsx("p",{children:s||"Unable to load image"}),t.jsx("p",{className:"mt-2 break-all text-sm",children:e.path})]})]}),t.jsx("div",{className:"border-t bg-gray-50 p-4 dark:bg-gray-800",children:t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:e.path})})]})})}function hr({selectedProject:e,onFileOpen:r}){const{t:o}=V(),[l,i]=a.useState(null),[s,u]=a.useState(null),c=a.useRef(null),x=a.useRef(null),b=a.useCallback((j,m)=>{u({message:j,type:m})},[]);a.useEffect(()=>{if(s){const j=setTimeout(()=>u(null),3e3);return()=>clearTimeout(j)}},[s]);const{files:g,loading:v,error:d,refreshFiles:f}=Dt(e),{viewMode:y,changeViewMode:E}=Vt(),{expandedDirs:N,toggleDirectory:S,expandDirectories:L,collapseAll:D}=Et(),{searchQuery:R,setSearchQuery:M,filteredFiles:h}=Bt({files:g,expandDirectories:L}),n=At({selectedProject:e,onRefresh:f,showToast:b}),p=Yt({selectedProject:e,onRefresh:f,showToast:b}),w=n.operationLoading||p.operationLoading,C=a.useRef(null),F=a.useRef(""),{uploadFiles:I}=p,P=a.useCallback(j=>{F.current=j,C.current?.click()},[]),G=a.useCallback(j=>{const{files:m}=j.target;m&&m.length>0&&I(Array.from(m),F.current),j.target.value=""},[I]);a.useEffect(()=>{n.isCreating&&c.current&&(c.current.focus(),c.current.select())},[n.isCreating]),a.useEffect(()=>{n.renamingItem&&x.current&&(x.current.focus(),x.current.select())},[n.renamingItem]);const _=a.useCallback(j=>{const{icon:m,color:k}=Tt(j);return t.jsx(m,{className:U(_e,k)})},[]),O=a.useCallback(j=>{if(j.type==="directory"){S(j.path);return}if(zt(j.name)&&e){i({name:j.name,path:j.path,projectPath:e.path,projectId:e.projectId});return}r?.(j.path)},[r,e,S]),q=a.useCallback(j=>$t(j,o),[o]);return v?t.jsx(ar,{}):t.jsxs("div",{ref:p.treeRef,className:"relative flex h-full flex-col bg-background",onDragEnter:p.handleDragEnter,onDragOver:p.handleDragOver,onDragLeave:p.handleDragLeave,onDrop:p.handleDrop,children:[t.jsx("input",{ref:C,type:"file",multiple:!0,className:"hidden",onChange:G,tabIndex:-1,"aria-hidden":"true"}),p.isDragOver&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-50 flex items-center justify-center border-2 border-dashed border-blue-500 bg-blue-500/10",children:t.jsxs("div",{className:"flex items-center gap-3 rounded-lg bg-background/95 px-6 py-4 shadow-lg",children:[t.jsx(oe,{className:"h-6 w-6 text-blue-500"}),t.jsx("span",{className:"text-sm font-medium",children:p.dropTarget?o("fileTree.dropToUploadTo",'Drop files to upload to "{{folder}}"',{folder:p.dropTarget.split(/[\\/]/).pop()}):o("fileTree.dropToUpload","Drop files to upload")})]})}),t.jsx(lr,{viewMode:y,onViewModeChange:E,searchQuery:R,onSearchQueryChange:M,onUploadFiles:p.handleFileSelect,onNewFile:()=>n.handleStartCreate("","file"),onNewFolder:()=>n.handleStartCreate("","directory"),onRefresh:f,onCollapseAll:D,loading:v,operationLoading:w,isUploading:p.uploadProgress?.status==="uploading",uploadProgress:p.uploadProgress?.progress??null}),t.jsx(ir,{upload:p.uploadProgress}),y==="detailed"&&h.length>0&&t.jsx(nr,{}),t.jsxs(dt,{className:"flex-1 px-2 py-1",children:[n.isCreating&&t.jsxs("div",{className:"mb-1 flex items-center gap-1.5 py-[3px] pr-2",style:{paddingLeft:`${(n.newItemParent.split("/").length-1)*16+4}px`},children:[n.newItemType==="directory"?t.jsx(Fe,{className:U(_e,"text-blue-500")}):t.jsx("span",{className:"ml-[18px]",children:_(n.newItemName)}),t.jsx(Ne,{ref:c,type:"text",value:n.newItemName,onChange:j=>n.setNewItemName(j.target.value),onKeyDown:j=>{j.stopPropagation(),j.key==="Enter"&&n.handleConfirmCreate(),j.key==="Escape"&&n.handleCancelCreate()},onBlur:()=>{setTimeout(()=>{n.isCreating&&n.handleConfirmCreate()},100)},className:"h-6 flex-1 text-sm",disabled:w})]}),t.jsx(or,{files:g,filteredFiles:h,error:d,searchQuery:R,viewMode:y,expandedDirs:N,onItemClick:O,renderFileIcon:_,formatFileSize:Pt,formatRelativeTime:q,onRename:n.handleStartRename,onDelete:n.handleStartDelete,onNewFile:j=>n.handleStartCreate(j,"file"),onNewFolder:j=>n.handleStartCreate(j,"directory"),onCopyPath:n.handleCopyPath,onDownload:n.handleDownload,onUpload:P,onRefresh:f,dropTarget:p.dropTarget,onItemDragOver:p.handleItemDragOver,renamingItem:n.renamingItem,renameValue:n.renameValue,setRenameValue:n.setRenameValue,handleConfirmRename:n.handleConfirmRename,handleCancelRename:n.handleCancelRename,renameInputRef:x,operationLoading:w})]}),l&&t.jsx(cr,{file:l,onClose:()=>i(null)}),n.deleteConfirmation.isOpen&&n.deleteConfirmation.item&&t.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/50",children:t.jsxs("div",{className:"mx-4 max-w-sm rounded-lg border border-border bg-background p-4 shadow-lg",children:[t.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[t.jsx("div",{className:"rounded-full bg-red-100 p-2 dark:bg-red-900/30",children:t.jsx(Ke,{className:"h-5 w-5 text-red-600 dark:text-red-400"})}),t.jsxs("div",{children:[t.jsx("h3",{className:"font-medium text-foreground",children:o("fileTree.delete.title","Delete {{type}}",{type:n.deleteConfirmation.item.type==="directory"?"Folder":"File"})}),t.jsx("p",{className:"text-sm text-muted-foreground",children:n.deleteConfirmation.item.name})]})]}),t.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:n.deleteConfirmation.item.type==="directory"?o("fileTree.delete.folderWarning","This folder and all its contents will be permanently deleted."):o("fileTree.delete.fileWarning","This file will be permanently deleted.")}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{onClick:n.handleCancelDelete,disabled:w,className:"rounded-md px-3 py-1.5 text-sm transition-colors hover:bg-accent",children:o("common.cancel","Cancel")}),t.jsxs("button",{onClick:n.handleConfirmDelete,disabled:w,className:"flex items-center gap-2 rounded-md bg-red-600 px-3 py-1.5 text-sm text-white transition-colors hover:bg-red-700 disabled:opacity-50",children:[w&&t.jsx(Je,{className:"h-4 w-4 animate-spin"}),o("fileTree.delete.confirm","Delete")]})]})]})}),s&&t.jsxs("div",{className:U("fixed bottom-4 right-4 z-[9999] px-4 py-2 rounded-lg shadow-lg flex items-center gap-2 animate-in slide-in-from-bottom-2",s.type==="success"?"bg-green-600 text-white":"bg-red-600 text-white"),children:[s.type==="success"?t.jsx(Nt,{className:"h-4 w-4"}):t.jsx(Te,{className:"h-4 w-4"}),t.jsx("span",{className:"text-sm",children:s.message})]})]})}export{hr as default};
|
|
1
|
+
import{r as a,j as t}from"./vendor-react-C2GTiUCy.js";import{c as ee,a5 as lt,a6 as at,a7 as st,a8 as it,f as U,I as Ne,B as z,a as ct,a9 as dt}from"./feature-workspace-FLomYkPq.js";import{Q as W,b4 as ce,$ as B,b5 as ge,b6 as be,ak as ye,S as A,b7 as de,b8 as te,b9 as we,ba as re,U as X,bb as je,a4 as Z,bc as ue,as as qe,bd as J,k as Y,be as ne,bf as le,bg as Q,w as ut,bh as H,bi as De,bj as ft,bk as Ie,ar as ae,a0 as se,J as Re,bl as pt,bm as mt,aO as ie,bn as Ae,bo as xt,bp as ht,bq as xe,aC as Le,r as Me,q as Ue,aa as Oe,l as ve,a1 as oe,R as Ce,t as gt,N as bt,F as Fe,T as Ke,b as Ze,L as Je,C as yt,ay as wt,a9 as jt,br as vt,X as Te,n as Ct,a2 as kt,o as Nt}from"./vendor-ui-CAUHSABu.js";import{J as Ft}from"./vendor-data-DsEZeNPr.js";import{u as V}from"./vendor-i18n-B6HjLCnN.js";import"./vendor-markdown-DkITEES2.js";const _e="w-4 h-4 flex-shrink-0",Pe={js:{icon:ae,color:"text-yellow-500"},jsx:{icon:ae,color:"text-yellow-500"},mjs:{icon:ae,color:"text-yellow-500"},cjs:{icon:ae,color:"text-yellow-500"},ts:{icon:se,color:"text-blue-500"},tsx:{icon:se,color:"text-blue-500"},mts:{icon:se,color:"text-blue-500"},py:{icon:xe,color:"text-emerald-500"},pyw:{icon:xe,color:"text-emerald-500"},pyi:{icon:xe,color:"text-emerald-400"},ipynb:{icon:ht,color:"text-orange-500"},rs:{icon:de,color:"text-orange-600"},toml:{icon:A,color:"text-gray-500"},go:{icon:ce,color:"text-cyan-500"},rb:{icon:je,color:"text-red-500"},erb:{icon:je,color:"text-red-400"},php:{icon:xt,color:"text-violet-500"},java:{icon:Ae,color:"text-red-600"},jar:{icon:Ae,color:"text-red-500"},kt:{icon:ce,color:"text-violet-500"},kts:{icon:ce,color:"text-violet-400"},c:{icon:ie,color:"text-blue-600"},h:{icon:ie,color:"text-blue-400"},cpp:{icon:ie,color:"text-blue-700"},hpp:{icon:ie,color:"text-blue-500"},cc:{icon:ie,color:"text-blue-700"},cs:{icon:ce,color:"text-purple-600"},swift:{icon:we,color:"text-orange-500"},lua:{icon:mt,color:"text-blue-500"},r:{icon:pt,color:"text-blue-600"},html:{icon:Re,color:"text-orange-600"},htm:{icon:Re,color:"text-orange-600"},css:{icon:te,color:"text-blue-500"},scss:{icon:te,color:"text-pink-500"},sass:{icon:te,color:"text-pink-400"},less:{icon:te,color:"text-indigo-500"},vue:{icon:se,color:"text-emerald-500"},svelte:{icon:se,color:"text-orange-500"},json:{icon:re,color:"text-yellow-600"},jsonc:{icon:re,color:"text-yellow-500"},json5:{icon:re,color:"text-yellow-500"},yaml:{icon:A,color:"text-purple-400"},yml:{icon:A,color:"text-purple-400"},xml:{icon:ae,color:"text-orange-500"},csv:{icon:Ie,color:"text-green-600"},tsv:{icon:Ie,color:"text-green-500"},sql:{icon:ft,color:"text-blue-500"},graphql:{icon:De,color:"text-pink-500"},gql:{icon:De,color:"text-pink-500"},proto:{icon:ue,color:"text-green-500"},env:{icon:Z,color:"text-yellow-600"},md:{icon:ye,color:"text-blue-500"},mdx:{icon:ye,color:"text-blue-400"},txt:{icon:B,color:"text-gray-500"},doc:{icon:B,color:"text-blue-600"},docx:{icon:B,color:"text-blue-600"},pdf:{icon:be,color:"text-red-600"},rtf:{icon:B,color:"text-gray-500"},tex:{icon:ge,color:"text-teal-600"},rst:{icon:B,color:"text-gray-400"},sh:{icon:X,color:"text-green-500"},bash:{icon:X,color:"text-green-500"},zsh:{icon:X,color:"text-green-400"},fish:{icon:X,color:"text-green-400"},ps1:{icon:X,color:"text-blue-400"},bat:{icon:X,color:"text-gray-500"},cmd:{icon:X,color:"text-gray-500"},png:{icon:H,color:"text-purple-500"},jpg:{icon:H,color:"text-purple-500"},jpeg:{icon:H,color:"text-purple-500"},gif:{icon:H,color:"text-purple-400"},webp:{icon:H,color:"text-purple-400"},ico:{icon:H,color:"text-purple-400"},bmp:{icon:H,color:"text-purple-400"},tiff:{icon:H,color:"text-purple-400"},svg:{icon:ut,color:"text-amber-500"},mp3:{icon:Q,color:"text-pink-500"},wav:{icon:Q,color:"text-pink-500"},ogg:{icon:Q,color:"text-pink-400"},flac:{icon:Q,color:"text-pink-400"},aac:{icon:Q,color:"text-pink-400"},m4a:{icon:Q,color:"text-pink-400"},mp4:{icon:le,color:"text-rose-500"},mov:{icon:le,color:"text-rose-500"},avi:{icon:le,color:"text-rose-500"},webm:{icon:le,color:"text-rose-400"},mkv:{icon:le,color:"text-rose-400"},ttf:{icon:ne,color:"text-red-500"},otf:{icon:ne,color:"text-red-500"},woff:{icon:ne,color:"text-red-400"},woff2:{icon:ne,color:"text-red-400"},eot:{icon:ne,color:"text-red-400"},zip:{icon:Y,color:"text-amber-600"},tar:{icon:Y,color:"text-amber-600"},gz:{icon:Y,color:"text-amber-600"},bz2:{icon:Y,color:"text-amber-600"},rar:{icon:Y,color:"text-amber-500"},"7z":{icon:Y,color:"text-amber-500"},lock:{icon:W,color:"text-gray-500"},exe:{icon:J,color:"text-gray-500"},bin:{icon:J,color:"text-gray-500"},dll:{icon:J,color:"text-gray-400"},so:{icon:J,color:"text-gray-400"},dylib:{icon:J,color:"text-gray-400"},wasm:{icon:J,color:"text-purple-500"},ini:{icon:A,color:"text-gray-500"},cfg:{icon:A,color:"text-gray-500"},conf:{icon:A,color:"text-gray-500"},log:{icon:ge,color:"text-gray-400"},map:{icon:qe,color:"text-gray-400"}},$e={Dockerfile:{icon:ue,color:"text-blue-500"},"docker-compose.yml":{icon:ue,color:"text-blue-500"},"docker-compose.yaml":{icon:ue,color:"text-blue-500"},".dockerignore":{icon:ue,color:"text-gray-500"},".gitignore":{icon:A,color:"text-gray-500"},".gitmodules":{icon:A,color:"text-gray-500"},".gitattributes":{icon:A,color:"text-gray-500"},".editorconfig":{icon:A,color:"text-gray-500"},".prettierrc":{icon:A,color:"text-pink-400"},".prettierignore":{icon:A,color:"text-gray-500"},".eslintrc":{icon:A,color:"text-violet-500"},".eslintrc.js":{icon:A,color:"text-violet-500"},".eslintrc.json":{icon:A,color:"text-violet-500"},".eslintrc.cjs":{icon:A,color:"text-violet-500"},"eslint.config.js":{icon:A,color:"text-violet-500"},"eslint.config.mjs":{icon:A,color:"text-violet-500"},".env":{icon:Z,color:"text-yellow-600"},".env.local":{icon:Z,color:"text-yellow-600"},".env.development":{icon:Z,color:"text-yellow-500"},".env.production":{icon:Z,color:"text-yellow-600"},".env.example":{icon:Z,color:"text-yellow-400"},"package.json":{icon:re,color:"text-green-500"},"package-lock.json":{icon:W,color:"text-gray-500"},"yarn.lock":{icon:W,color:"text-blue-400"},"pnpm-lock.yaml":{icon:W,color:"text-orange-400"},"bun.lockb":{icon:W,color:"text-gray-400"},"Cargo.toml":{icon:de,color:"text-orange-600"},"Cargo.lock":{icon:W,color:"text-orange-400"},Gemfile:{icon:je,color:"text-red-500"},"Gemfile.lock":{icon:W,color:"text-red-400"},Makefile:{icon:X,color:"text-gray-500"},"CMakeLists.txt":{icon:de,color:"text-blue-500"},"tsconfig.json":{icon:re,color:"text-blue-500"},"jsconfig.json":{icon:re,color:"text-yellow-500"},"vite.config.ts":{icon:we,color:"text-purple-500"},"vite.config.js":{icon:we,color:"text-purple-500"},"webpack.config.js":{icon:de,color:"text-blue-500"},"tailwind.config.js":{icon:te,color:"text-cyan-500"},"tailwind.config.ts":{icon:te,color:"text-cyan-500"},"postcss.config.js":{icon:de,color:"text-red-400"},"babel.config.js":{icon:A,color:"text-yellow-500"},".babelrc":{icon:A,color:"text-yellow-500"},"README.md":{icon:ye,color:"text-blue-500"},LICENSE:{icon:be,color:"text-gray-500"},"LICENSE.md":{icon:be,color:"text-gray-500"},"CHANGELOG.md":{icon:ge,color:"text-blue-400"},"requirements.txt":{icon:B,color:"text-emerald-400"},"go.mod":{icon:ce,color:"text-cyan-500"},"go.sum":{icon:W,color:"text-cyan-400"}};function Tt(e){if($e[e])return $e[e];if(e.startsWith(".env"))return{icon:Z,color:"text-yellow-600"};const r=e.split(".").pop()?.toLowerCase();return r&&Pe[r]?Pe[r]:{icon:qe,color:"text-muted-foreground"}}function Et(){const[e,r]=a.useState(()=>new Set),o=a.useCallback(s=>{r(u=>{const c=new Set(u);return c.has(s)?c.delete(s):c.add(s),c})},[]),l=a.useCallback(s=>{s.length!==0&&r(u=>{const c=new Set(u);return s.forEach(x=>c.add(x)),c})},[]),i=a.useCallback(()=>{r(new Set)},[]);return{expandedDirs:e,toggleDirectory:o,expandDirectories:l,collapseAll:i}}const ze="Unable to load the file tree for this project.";function St(e){try{const r=JSON.parse(e),o=typeof r=="object"&&r!==null&&"error"in r?r.error:null;return typeof o=="string"&&o.trim()?o:null}catch{return null}}function Dt(e){const[r,o]=a.useState([]),[l,i]=a.useState(!1),[s,u]=a.useState(null),[c,x]=a.useState(0),b=a.useRef(null),g=a.useCallback(()=>{x(v=>v+1)},[]);return a.useEffect(()=>{const v=e?.projectId;if(!v){o([]),i(!1),u(null);return}b.current&&b.current.abort(),b.current=new AbortController;let d=!0;return(async()=>{d&&(i(!0),u(null));try{const y=await ee.getFiles(v,{signal:b.current.signal});if(!y.ok){const N=await y.text();console.error("File fetch failed:",y.status,N),d&&(o([]),u(St(N)??ze));return}const E=await y.json();d&&o(E)}catch(y){if(y.name==="AbortError")return;console.error("Error fetching files:",y),d&&(o([]),u(ze))}finally{d&&i(!1)}})(),()=>{d=!1,b.current?.abort()}},[e?.projectId,c]),{files:r,loading:l,error:s,refreshFiles:g}}const It=/[<>:"/\\|?*\x00-\x1f]/,Rt=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/i;function At({selectedProject:e,onRefresh:r,showToast:o}){const{t:l}=V(),[i,s]=a.useState(null),[u,c]=a.useState(""),[x,b]=a.useState({isOpen:!1,item:null}),[g,v]=a.useState(!1),[d,f]=a.useState(""),[y,E]=a.useState("file"),[N,S]=a.useState(""),[L,D]=a.useState(!1),R=a.useCallback(m=>!m||!m.trim()?l("fileTree.validation.emptyName","Filename cannot be empty"):It.test(m)?l("fileTree.validation.invalidChars","Filename contains invalid characters"):Rt.test(m)?l("fileTree.validation.reserved","Filename is a reserved name"):/^\.+$/.test(m)?l("fileTree.validation.dotsOnly","Filename cannot be only dots"):null,[l]),M=a.useCallback(m=>{s(m),c(m.name),v(!1)},[]),h=a.useCallback(()=>{s(null),c("")},[]),n=a.useCallback(async()=>{if(!i||!e)return;const m=R(u);if(m){o(m,"error");return}if(u===i.name){h();return}D(!0);try{const k=await ee.renameFile(e.projectId,{oldPath:i.path,newName:u});if(!k.ok){const T=await k.json();throw new Error(T.error||"Failed to rename")}o(l("fileTree.toast.renamed","Renamed successfully"),"success"),r(),h()}catch(k){o(k.message,"error")}finally{D(!1)}},[i,u,e,R,o,l,r,h]),p=a.useCallback(m=>{b({isOpen:!0,item:m})},[]),w=a.useCallback(()=>{b({isOpen:!1,item:null})},[]),C=a.useCallback(async()=>{const{item:m}=x;if(!(!m||!e)){D(!0);try{const k=await ee.deleteFile(e.projectId,{path:m.path,type:m.type});if(!k.ok){const T=await k.json();throw new Error(T.error||"Failed to delete")}o(m.type==="directory"?l("fileTree.toast.folderDeleted","Folder deleted"):l("fileTree.toast.fileDeleted","File deleted"),"success"),r(),w()}catch(k){o(k.message,"error")}finally{D(!1)}}},[x,e,o,l,r,w]),F=a.useCallback((m,k)=>{f(m||""),E(k),S(k==="file"?"untitled.txt":"new-folder"),v(!0),s(null)},[]),I=a.useCallback(()=>{v(!1),f(""),S("")},[]),P=a.useCallback(async()=>{if(!e)return;const m=R(N);if(m){o(m,"error");return}D(!0);try{const k=await ee.createFile(e.projectId,{path:d,type:y,name:N});if(!k.ok){const T=await k.json();throw new Error(T.error||"Failed to create")}o(y==="file"?l("fileTree.toast.fileCreated","File created successfully"):l("fileTree.toast.folderCreated","Folder created successfully"),"success"),r(),I()}catch(k){o(k.message,"error")}finally{D(!1)}},[e,d,y,N,R,o,l,r,I]),G=a.useCallback(m=>{navigator.clipboard.writeText(m.path).catch(()=>{o(l("fileTree.toast.copyFailed","Failed to copy path"),"error")}),o(l("fileTree.toast.pathCopied","Path copied to clipboard"),"success")},[o,l]),_=a.useCallback((m,k)=>{const T=URL.createObjectURL(m),K=document.createElement("a");K.href=T,K.download=k,document.body.appendChild(K),K.click(),document.body.removeChild(K),URL.revokeObjectURL(T)},[]),O=a.useCallback(async m=>{if(!e)return;const k=await ee.readFileBlob(e.projectId,m.path);if(!k.ok)throw new Error("Failed to download file");const T=await k.blob();_(T,m.name)},[e,_]),q=a.useCallback(async m=>{if(!e)return;const k=new Ft,T=async($,Ee)=>{const Se=Ee?`${Ee}/${$.name}`:$.name;if($.type==="file"){const fe=await ee.readFileBlob(e.projectId,$.path);if(!fe.ok)throw new Error(`Failed to download "${$.name}" for ZIP export`);const nt=await fe.arrayBuffer();k.file(Se,nt)}else if($.type==="directory"&&$.children)for(const fe of $.children)await T(fe,Se)};if(m.children&&m.children.length>0)for(const $ of m.children)await T($,"");const K=await k.generateAsync({type:"blob"});_(K,`${m.name}.zip`),o(l("fileTree.toast.folderDownloaded","Folder downloaded as ZIP"),"success")},[e,o,l,_]),j=a.useCallback(async m=>{if(e){D(!0);try{m.type==="directory"?await q(m):await O(m)}catch(k){o(k.message,"error")}finally{D(!1)}}},[q,O,e,o]);return{renamingItem:i,renameValue:u,handleStartRename:M,handleCancelRename:h,handleConfirmRename:n,setRenameValue:c,deleteConfirmation:x,handleStartDelete:p,handleCancelDelete:w,handleConfirmDelete:C,isCreating:g,newItemParent:d,newItemType:y,newItemName:N,handleStartCreate:F,handleCancelCreate:I,handleConfirmCreate:P,setNewItemName:S,handleCopyPath:G,handleDownload:j,operationLoading:L,validateFilename:R}}const Be="file-tree-view-mode",Lt="detailed",Mt=["simple","compact","detailed"],Ye=200,Ut=Ye*1024*1024,ke=`${Ye}MB`,Ve=20,Ot=new Set(["png","jpg","jpeg","gif","svg","webp","ico","bmp"]);function Qe(e,r){return e.reduce((o,l)=>{const i=l.name.toLowerCase().includes(r),s=l.type==="directory"&&l.children?Qe(l.children,r):[];return(i||s.length>0)&&o.push({...l,children:s}),o},[])}function _t(e){const r=[],o=l=>{l.forEach(i=>{i.type==="directory"&&i.children&&i.children.length>0&&(r.push(i.path),o(i.children))})};return o(e),r}function Pt(e){if(!e||e===0)return"0 B";const r=1024,o=["B","KB","MB","GB"],l=Math.floor(Math.log(e)/Math.log(r));return`${(e/Math.pow(r,l)).toFixed(1).replace(/\.0$/,"")} ${o[l]}`}function $t(e,r){if(!e)return"-";const o=new Date,l=new Date(e),i=Math.floor((o.getTime()-l.getTime())/1e3);return i<60?r("fileTree.justNow"):i<3600?r("fileTree.minAgo",{count:Math.floor(i/60)}):i<86400?r("fileTree.hoursAgo",{count:Math.floor(i/3600)}):i<2592e3?r("fileTree.daysAgo",{count:Math.floor(i/86400)}):l.toLocaleDateString()}function zt(e){const r=e.split(".").pop()?.toLowerCase();return!!(r&&Ot.has(r))}function Bt({files:e,expandDirectories:r}){const[o,l]=a.useState(""),[i,s]=a.useState(e);return a.useEffect(()=>{const u=o.trim().toLowerCase();if(!u){s(e);return}const c=Qe(e,u);s(c),r(_t(c))},[e,o,r]),{searchQuery:o,setSearchQuery:l,filteredFiles:i}}function Vt(){const[e,r]=a.useState(Lt);a.useEffect(()=>{try{const l=localStorage.getItem(Be);l&&Mt.includes(l)&&r(l)}catch{}},[]);const o=a.useCallback(l=>{r(l);try{localStorage.setItem(Be,l)}catch{}},[]);return{viewMode:e,changeViewMode:o}}const Gt=1400,Ht=3200,Ge=e=>e===1?"file":"files",et=e=>e.webkitRelativePath||e.name,tt=e=>et(e).split(/[\\/]/).pop()||e.name,Wt=e=>{if(e.length>Ve)return`You can upload up to ${Ve} files at once.`;const r=e.find(o=>o.size>Ut);return r?`${tt(r)} is larger than ${ke}.`:null},Xt=e=>{if(!e.responseText)return{};try{return JSON.parse(e.responseText)}catch{return{}}},qt=(e,r)=>e!==r?`Uploaded ${e} of ${r} ${Ge(r)}`:`Uploaded ${e} ${Ge(e)} successfully`,Kt=(e,r)=>{const o=new FormData,l=[];return o.append("targetPath",r),o.append("requestedFileCount",String(e.length)),e.forEach(i=>{const s=et(i),u=new File([i],s.split(/[\\/]/).pop()||i.name,{type:i.type,lastModified:i.lastModified});o.append("files",u),l.push(s)}),o.append("relativePaths",JSON.stringify(l)),o},Zt=(e,r,o)=>new Promise((l,i)=>{const s=new XMLHttpRequest;s.open("POST",`/api/file-tree/projects/${encodeURIComponent(e)}/files/upload`);const u=lt();!at&&u&&s.setRequestHeader("Authorization",`Bearer ${u}`),s.upload.onprogress=c=>{c.lengthComputable&&o(Math.min(99,Math.round(c.loaded/c.total*100)))},s.onload=()=>{const c=s.getResponseHeader("X-Refreshed-Token");c&&st(c),s.getResponseHeader("X-Auth-Error")&&it();const x=Xt(s);if(s.status>=200&&s.status<300){l(x);return}i(new Error(x.error||x.message||`Upload failed with status ${s.status}`))},s.onerror=()=>i(new Error("Upload failed. Check your connection and try again.")),s.onabort=()=>i(new Error("Upload canceled.")),s.send(r)}),rt=async(e,r="")=>{const o=[],l=e.createReader();let i=[],s;do s=await new Promise((c,x)=>{l.readEntries(c,x)}),i=i.concat(s);while(s.length>0);const u=[".DS_Store","Thumbs.db","desktop.ini"];for(const c of i){const x=r?`${r}/${c.name}`:c.name;if(c.isFile){const b=c,g=await new Promise((d,f)=>{b.file(d,f)});if(u.includes(g.name))continue;const v=new File([g],x,{type:g.type,lastModified:g.lastModified});o.push(v)}else if(c.isDirectory){const g=await rt(c,x);o.push(...g)}}return o},Jt=async e=>{const r=[],{items:o}=e;if(o){for(const l of Array.from(o)){if(l.kind!=="file")continue;const i=l.webkitGetAsEntry?l.webkitGetAsEntry():null;if(!i){const s=l.getAsFile();s&&r.push(s);continue}if(i.isFile){const s=await new Promise((u,c)=>{i.file(u,c)});r.push(s)}else if(i.isDirectory){const s=await rt(i,i.name);r.push(...s)}}return r}for(const l of Array.from(e.files))r.push(l);return r},Yt=({selectedProject:e,onRefresh:r,showToast:o})=>{const[l,i]=a.useState(!1),[s,u]=a.useState(null),[c,x]=a.useState(!1),[b,g]=a.useState(null),v=a.useRef(null),d=a.useRef(null),f=a.useCallback(()=>{d.current&&(clearTimeout(d.current),d.current=null)},[]),y=a.useCallback(n=>{f(),d.current=setTimeout(()=>{g(null),d.current=null},n)},[f]);a.useEffect(()=>f,[f]);const E=a.useCallback((n,p,w="",C,F=0)=>{g({status:"error",progress:F,fileCount:p,fileName:C,targetPath:w,error:n}),y(Ht)},[y]),N=a.useCallback(async(n,p="")=>{if(n.length===0){u(null);return}const w=n.length===1?tt(n[0]):void 0;if(!e){const I="Select a project before uploading files.";o(I,"error"),E(I,n.length,p,w);return}const C=Wt(n);if(C){o(C,"error"),E(C,n.length,p,w);return}f(),x(!0),g({status:"uploading",progress:0,fileCount:n.length,fileName:w,targetPath:p});let F=0;try{const I=await Zt(e.projectId,Kt(n,p),_=>{F=_,g(O=>O&&O.status==="uploading"?{...O,progress:_}:O)}),P=typeof I.uploadedCount=="number"?I.uploadedCount:I.files?.length??n.length,G=typeof I.requestedFileCount=="number"?I.requestedFileCount:n.length;g({status:"complete",progress:100,fileCount:G,uploadedCount:P,fileName:w,targetPath:p}),o(qt(P,G),"success"),y(Gt),r()}catch(I){const P=I instanceof Error?I.message:"Upload failed";console.error("Upload error:",I),o(P,"error"),E(P,n.length,p,w,F)}finally{x(!1),u(null)}},[f,r,y,e,E,o]),S=a.useCallback(async n=>{await N(Array.from(n),"")},[N]),L=a.useCallback(n=>{n.preventDefault(),n.stopPropagation(),i(!0)},[]),D=a.useCallback(n=>{n.preventDefault(),n.stopPropagation(),u(null)},[]),R=a.useCallback(n=>{n.preventDefault(),n.stopPropagation(),v.current&&!v.current.contains(n.relatedTarget)&&(i(!1),u(null))},[]),M=a.useCallback(async n=>{n.preventDefault(),n.stopPropagation(),i(!1);const p=s||"";try{const w=await Jt(n.dataTransfer);await N(w,p)}catch(w){const C=w instanceof Error?w.message:"Could not read dropped files";console.error("Upload error:",w),o(C,"error"),E(C,0,p),u(null)}},[s,E,o,N]),h=a.useCallback((n,p)=>{n.preventDefault(),n.stopPropagation(),u(p)},[]);return{isDragOver:l,dropTarget:s,operationLoading:c,uploadProgress:b,treeRef:v,uploadFiles:N,handleFileSelect:S,handleDragEnter:L,handleDragOver:D,handleDragLeave:R,handleDrop:M,handleItemDragOver:h,setDropTarget:u}};function he({icon:e,title:r,description:o}){return t.jsxs("div",{className:"py-8 text-center",children:[t.jsx("div",{className:"mx-auto mb-3 flex h-12 w-12 items-center justify-center rounded-lg bg-muted",children:t.jsx(e,{className:"h-6 w-6 text-muted-foreground"})}),t.jsx("h4",{className:"mb-1 font-medium text-foreground",children:r}),t.jsx("p",{className:"text-sm text-muted-foreground",children:o})]})}const He=200,We=300,pe=10;function Qt(e,r){const o=e+He>window.innerWidth?window.innerWidth-He-pe:e,l=r+We>window.innerHeight?window.innerHeight-We-pe:r;return{x:Math.max(pe,o),y:Math.max(pe,l)}}function er({children:e,item:r,onRename:o,onDelete:l,onNewFile:i,onNewFolder:s,onUpload:u,onRefresh:c,onCopyPath:x,onDownload:b,isLoading:g=!1,className:v=""}){const{t:d}=V(),[f,y]=a.useState(!1),[E,N]=a.useState({x:0,y:0}),S=a.useRef(null),L=a.useCallback(()=>{y(!1)},[]),D=a.useCallback(h=>{h.preventDefault(),h.stopPropagation(),N(Qt(h.clientX,h.clientY)),y(!0)},[]),R=a.useCallback(h=>{L(),h?.()},[L]),M=a.useMemo(()=>r?.type==="file"?[{key:"rename",icon:Le,label:d("fileTree.context.rename","Rename"),onSelect:()=>o?.(r)},{key:"delete",icon:Me,label:d("fileTree.context.delete","Delete"),onSelect:()=>l?.(r),isDanger:!0},{key:"copyPath",icon:Ue,label:d("fileTree.context.copyPath","Copy Path"),onSelect:()=>x?.(r),showDividerBefore:!0},{key:"download",icon:Oe,label:d("fileTree.context.download","Download"),onSelect:()=>b?.(r)}]:r?.type==="directory"?[{key:"newFile",icon:B,label:d("fileTree.context.newFile","New File"),onSelect:()=>i?.(r.path)},{key:"newFolder",icon:ve,label:d("fileTree.context.newFolder","New Folder"),onSelect:()=>s?.(r.path)},{key:"upload",icon:oe,label:d("fileTree.context.upload","Upload Files"),onSelect:()=>u?.(r.path)},{key:"rename",icon:Le,label:d("fileTree.context.rename","Rename"),onSelect:()=>o?.(r),showDividerBefore:!0},{key:"delete",icon:Me,label:d("fileTree.context.delete","Delete"),onSelect:()=>l?.(r),isDanger:!0},{key:"copyPath",icon:Ue,label:d("fileTree.context.copyPath","Copy Path"),onSelect:()=>x?.(r),showDividerBefore:!0},{key:"download",icon:Oe,label:d("fileTree.context.download","Download"),onSelect:()=>b?.(r)}]:[{key:"newFile",icon:B,label:d("fileTree.context.newFile","New File"),onSelect:()=>i?.("")},{key:"newFolder",icon:ve,label:d("fileTree.context.newFolder","New Folder"),onSelect:()=>s?.("")},{key:"upload",icon:oe,label:d("fileTree.context.upload","Upload Files"),onSelect:()=>u?.("")},{key:"refresh",icon:Ce,label:d("fileTree.context.refresh","Refresh"),onSelect:c,showDividerBefore:!0}],[r,x,l,b,i,s,c,o,u,d]);return a.useEffect(()=>{if(!f)return;const h=p=>{const w=S.current;w&&!w.contains(p.target)&&L()},n=p=>{p.key==="Escape"&&L()};return document.addEventListener("mousedown",h),document.addEventListener("keydown",n),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",n)}},[L,f]),a.useEffect(()=>{if(!f)return;const h=n=>{const p=S.current?.querySelectorAll('[role="menuitem"]:not([disabled])');if(!p||p.length===0)return;const w=document.activeElement,C=Array.from(p).findIndex(F=>F===w);if(n.key==="ArrowDown"){n.preventDefault();const F=C<p.length-1?C+1:0;p[F]?.focus()}else if(n.key==="ArrowUp"){n.preventDefault();const F=C>0?C-1:p.length-1;p[F]?.focus()}else(n.key==="Enter"||n.key===" ")&&w?.hasAttribute("role")&&(n.preventDefault(),w.click())};return document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h)}},[f]),t.jsxs(t.Fragment,{children:[t.jsx("div",{onContextMenu:D,className:U("contents",v),children:e}),f&&t.jsx("div",{ref:S,role:"menu","aria-label":d("fileTree.context.menuLabel","File context menu"),style:{position:"fixed",left:E.x,top:E.y,zIndex:9999},className:U("min-w-[180px] py-1 px-1","bg-popover border border-border rounded-lg shadow-lg","animate-in fade-in-0 zoom-in-95","data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95"),children:g?t.jsxs("div",{className:"flex items-center justify-center py-4",children:[t.jsx(Ce,{className:"h-4 w-4 animate-spin text-muted-foreground"}),t.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:d("fileTree.context.loading","Loading...")})]}):M.map(h=>t.jsxs(a.Fragment,{children:[h.showDividerBefore&&t.jsx("div",{className:"mx-2 my-1 h-px bg-border"}),t.jsxs("button",{role:"menuitem",tabIndex:h.isDisabled?-1:0,disabled:g||h.isDisabled,onClick:()=>R(h.onSelect),className:U("w-full flex items-center gap-3 px-3 py-2 text-sm text-left rounded-md transition-colors","focus:outline-none focus:bg-accent",h.isDisabled?"opacity-50 cursor-not-allowed":h.isDanger?"text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-950":"hover:bg-accent",g&&"pointer-events-none"),children:[h.icon&&t.jsx(h.icon,{className:"h-4 w-4 flex-shrink-0"}),t.jsx("span",{className:"flex-1",children:h.label}),h.shortcut&&t.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:h.shortcut})]})]},h.key))})]})}function tr(e){const r=e.split(/[\\/]/);return r.pop(),r.join("/")}function me({item:e,isOpen:r,renderFileIcon:o}){return e.type==="directory"?t.jsxs("span",{className:"flex flex-shrink-0 items-center gap-0.5",children:[t.jsx(gt,{className:U("w-3.5 h-3.5 text-muted-foreground/70 transition-transform duration-150",r&&"rotate-90")}),r?t.jsx(bt,{className:"h-4 w-4 flex-shrink-0 text-blue-500"}):t.jsx(Fe,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]}):t.jsx("span",{className:"ml-[18px] flex flex-shrink-0 items-center",children:o(e.name)})}function ot({item:e,level:r,viewMode:o,expandedDirs:l,onItemClick:i,renderFileIcon:s,formatFileSize:u,formatRelativeTime:c,onRename:x,onDelete:b,onNewFile:g,onNewFolder:v,onCopyPath:d,onDownload:f,onUpload:y,onRefresh:E,dropTarget:N,onItemDragOver:S,renamingItem:L,renameValue:D,setRenameValue:R,handleConfirmRename:M,handleCancelRename:h,renameInputRef:n,operationLoading:p}){const{t:w}=V(),C=e.type==="directory",F=C&&l.has(e.path),I=!!(C&&e.children&&e.children.length>0),P=L?.path===e.path,G=C?e.path:tr(e.path),_=C&&N===e.path,O=U("text-[13px] leading-tight truncate",C?"font-medium text-foreground":"text-foreground/90"),q=U(o==="detailed"?"group grid grid-cols-12 gap-2 py-[3px] pr-2 hover:bg-accent/60 cursor-pointer items-center rounded-sm transition-colors duration-100":o==="compact"?"group flex items-center justify-between py-[3px] pr-2 hover:bg-accent/60 cursor-pointer rounded-sm transition-colors duration-100":"group flex items-center gap-1.5 py-[3px] pr-2 cursor-pointer rounded-sm hover:bg-accent/60 transition-colors duration-100",C&&F&&"border-l-2 border-primary/30",C&&!F||!C?"border-l-2 border-transparent":"","relative",_&&"bg-blue-500/10 ring-1 ring-inset ring-blue-500/40");if(P&&R&&M&&h)return t.jsxs("div",{className:U(q,"bg-accent/30"),style:{paddingLeft:`${r*16+4}px`},onClick:T=>T.stopPropagation(),children:[t.jsx(me,{item:e,isOpen:F,renderFileIcon:s}),t.jsx(Ne,{ref:n,type:"text",value:D||"",onChange:T=>R(T.target.value),onKeyDown:T=>{T.stopPropagation(),T.key==="Enter"&&M(),T.key==="Escape"&&h()},onBlur:()=>{setTimeout(()=>{M()},100)},className:"h-6 flex-1 text-sm",disabled:p})]});const j=C&&y&&t.jsx("button",{type:"button",onClick:T=>{T.stopPropagation(),y(e.path)},title:w("fileTree.uploadToFolder",'Upload files to "{{folder}}"',{folder:e.name}),"aria-label":w("fileTree.uploadToFolder",'Upload files to "{{folder}}"',{folder:e.name}),className:U("absolute right-1 top-1/2 -translate-y-1/2 rounded p-1","bg-background/80 text-muted-foreground opacity-0 transition-opacity","group-hover:opacity-100 focus-visible:opacity-100 hover:bg-accent hover:text-foreground"),children:t.jsx(oe,{className:"h-3.5 w-3.5"})}),m=t.jsxs("div",{className:q,style:{paddingLeft:`${r*16+4}px`},onClick:()=>i(e),onDragOver:S?T=>S(T,G):void 0,children:[o==="detailed"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"col-span-5 flex min-w-0 items-center gap-1.5",children:[t.jsx(me,{item:e,isOpen:F,renderFileIcon:s}),t.jsx("span",{className:O,children:e.name})]}),t.jsx("div",{className:"col-span-2 text-sm tabular-nums text-muted-foreground",children:e.type==="file"?u(e.size):""}),t.jsx("div",{className:"col-span-3 text-sm text-muted-foreground",children:c(e.modified)}),t.jsx("div",{className:"col-span-2 font-mono text-sm text-muted-foreground",children:e.permissionsRwx||""})]}):o==="compact"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx(me,{item:e,isOpen:F,renderFileIcon:s}),t.jsx("span",{className:O,children:e.name})]}),t.jsx("div",{className:"ml-2 flex flex-shrink-0 items-center gap-3 text-sm text-muted-foreground",children:e.type==="file"&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"tabular-nums",children:u(e.size)}),t.jsx("span",{className:"font-mono",children:e.permissionsRwx})]})})]}):t.jsxs(t.Fragment,{children:[t.jsx(me,{item:e,isOpen:F,renderFileIcon:s}),t.jsx("span",{className:O,children:e.name})]}),j]}),k=x||b||g||v||d||f||E;return t.jsxs("div",{className:"select-none",children:[k?t.jsx(er,{item:e,onRename:x,onDelete:b,onNewFile:g,onNewFolder:v,onUpload:y,onCopyPath:d,onDownload:f,onRefresh:E,children:m}):m,C&&F&&I&&t.jsxs("div",{className:"relative",children:[t.jsx("span",{className:"absolute bottom-0 top-0 border-l border-border/40",style:{left:`${r*16+14}px`},"aria-hidden":"true"}),e.children?.map(T=>t.jsx(ot,{item:T,level:r+1,viewMode:o,expandedDirs:l,onItemClick:i,renderFileIcon:s,formatFileSize:u,formatRelativeTime:c,onRename:x,onDelete:b,onNewFile:g,onNewFolder:v,onCopyPath:d,onDownload:f,onUpload:y,onRefresh:E,dropTarget:N,onItemDragOver:S,renamingItem:L,renameValue:D,setRenameValue:R,handleConfirmRename:M,handleCancelRename:h,renameInputRef:n,operationLoading:p},T.path))]})]})}function rr({items:e,viewMode:r,expandedDirs:o,onItemClick:l,renderFileIcon:i,formatFileSize:s,formatRelativeTime:u,onRename:c,onDelete:x,onNewFile:b,onNewFolder:g,onCopyPath:v,onDownload:d,onUpload:f,onRefresh:y,dropTarget:E,onItemDragOver:N,renamingItem:S,renameValue:L,setRenameValue:D,handleConfirmRename:R,handleCancelRename:M,renameInputRef:h,operationLoading:n}){return t.jsx("div",{children:e.map(p=>t.jsx(ot,{item:p,level:0,viewMode:r,expandedDirs:o,onItemClick:l,renderFileIcon:i,formatFileSize:s,formatRelativeTime:u,onRename:c,onDelete:x,onNewFile:b,onNewFolder:g,onCopyPath:v,onDownload:d,onUpload:f,onRefresh:y,dropTarget:E,onItemDragOver:N,renamingItem:S,renameValue:L,setRenameValue:D,handleConfirmRename:R,handleCancelRename:M,renameInputRef:h,operationLoading:n},p.path))})}function or({files:e,filteredFiles:r,error:o,searchQuery:l,viewMode:i,expandedDirs:s,onItemClick:u,renderFileIcon:c,formatFileSize:x,formatRelativeTime:b,onRename:g,onDelete:v,onNewFile:d,onNewFolder:f,onCopyPath:y,onDownload:E,onUpload:N,onRefresh:S,dropTarget:L,onItemDragOver:D,renamingItem:R,renameValue:M,setRenameValue:h,handleConfirmRename:n,handleCancelRename:p,renameInputRef:w,operationLoading:C}){const{t:F}=V();return t.jsx(t.Fragment,{children:o?t.jsx(he,{icon:Ke,title:F("fileTree.loadFailed"),description:o}):e.length===0?t.jsx(he,{icon:Fe,title:F("fileTree.noFilesFound"),description:F("fileTree.checkProjectPath")}):r.length===0&&l?t.jsx(he,{icon:Ze,title:F("fileTree.noMatchesFound"),description:F("fileTree.tryDifferentSearch")}):t.jsx(rr,{items:r,viewMode:i,expandedDirs:s,onItemClick:u,renderFileIcon:c,formatFileSize:x,formatRelativeTime:b,onRename:g,onDelete:v,onNewFile:d,onNewFolder:f,onCopyPath:y,onDownload:E,onUpload:N,onRefresh:S,dropTarget:L,onItemDragOver:D,renamingItem:R,renameValue:M,setRenameValue:h,handleConfirmRename:n,handleCancelRename:p,renameInputRef:w,operationLoading:C})})}function nr(){const{t:e}=V();return t.jsx("div",{className:"border-b border-border px-3 pb-1 pt-1.5",children:t.jsxs("div",{className:"grid grid-cols-12 gap-2 px-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:[t.jsx("div",{className:"col-span-5",children:e("fileTree.name")}),t.jsx("div",{className:"col-span-2",children:e("fileTree.size")}),t.jsx("div",{className:"col-span-3",children:e("fileTree.modified")}),t.jsx("div",{className:"col-span-2",children:e("fileTree.permissions")})]})})}function lr({viewMode:e,onViewModeChange:r,searchQuery:o,onSearchQueryChange:l,onNewFile:i,onNewFolder:s,onUploadFiles:u,onRefresh:c,onCollapseAll:x,loading:b,operationLoading:g,isUploading:v,uploadProgress:d}){const{t:f}=V(),y=a.useRef(null),E=N=>{const{files:S}=N.target;S&&S.length>0&&u?.(S),N.target.value=""};return t.jsxs("div",{className:"space-y-2 border-b border-border px-3 pb-2 pt-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h3",{className:"text-sm font-medium text-foreground",children:f("fileTree.files")}),t.jsxs("div",{className:"flex items-center gap-0.5",children:[u&&t.jsxs(t.Fragment,{children:[t.jsx("input",{ref:y,type:"file",multiple:!0,className:"hidden",onChange:E,tabIndex:-1,"aria-hidden":"true"}),t.jsxs(z,{variant:"ghost",size:"sm",className:"relative h-7 w-7 p-0",onClick:()=>y.current?.click(),title:v?f("fileTree.uploadingFiles","Uploading files"):f("fileTree.uploadFiles","Upload files (max {{size}} each)",{size:ke}),"aria-label":f("fileTree.uploadFiles","Upload files (max {{size}} each)",{size:ke}),disabled:g,children:[v?t.jsx(Je,{className:"h-3.5 w-3.5 animate-spin"}):t.jsx(oe,{className:"h-3.5 w-3.5"}),v&&typeof d=="number"&&t.jsx("span",{className:"absolute bottom-0.5 left-1/2 h-0.5 w-4 -translate-x-1/2 overflow-hidden rounded-full bg-primary/20",children:t.jsx("span",{className:"block h-full rounded-full bg-primary transition-[width] duration-150",style:{width:`${d}%`}})})]})]}),i&&t.jsx(z,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:i,title:f("fileTree.newFile","New File (Cmd+N)"),"aria-label":f("fileTree.newFile","New File (Cmd+N)"),disabled:g,children:t.jsx(B,{className:"h-3.5 w-3.5"})}),s&&t.jsx(z,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:s,title:f("fileTree.newFolder","New Folder (Cmd+Shift+N)"),"aria-label":f("fileTree.newFolder","New Folder (Cmd+Shift+N)"),disabled:g,children:t.jsx(ve,{className:"h-3.5 w-3.5"})}),c&&t.jsx(z,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:c,title:f("fileTree.refresh","Refresh"),"aria-label":f("fileTree.refresh","Refresh"),disabled:g,children:t.jsx(Ce,{className:U("w-3.5 h-3.5",b&&"animate-spin")})}),x&&t.jsx(z,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:x,title:f("fileTree.collapseAll","Collapse All"),"aria-label":f("fileTree.collapseAll","Collapse All"),children:t.jsx(yt,{className:"h-3.5 w-3.5"})}),t.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),t.jsx(z,{variant:e==="simple"?"default":"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>r("simple"),title:f("fileTree.simpleView"),"aria-label":f("fileTree.simpleView"),children:t.jsx(wt,{className:"h-3.5 w-3.5"})}),t.jsx(z,{variant:e==="compact"?"default":"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>r("compact"),title:f("fileTree.compactView"),"aria-label":f("fileTree.compactView"),children:t.jsx(jt,{className:"h-3.5 w-3.5"})}),t.jsx(z,{variant:e==="detailed"?"default":"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>r("detailed"),title:f("fileTree.detailedView"),"aria-label":f("fileTree.detailedView"),children:t.jsx(vt,{className:"h-3.5 w-3.5"})})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx(Ze,{className:"absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),t.jsx(Ne,{type:"text",placeholder:f("fileTree.searchPlaceholder"),value:o,onChange:N=>l(N.target.value),className:"h-8 pl-8 pr-8 text-sm"}),o&&t.jsx(z,{variant:"ghost",size:"sm",className:"absolute right-0.5 top-1/2 h-5 w-5 -translate-y-1/2 p-0 hover:bg-accent",onClick:()=>l(""),title:f("fileTree.clearSearch"),"aria-label":f("fileTree.clearSearch"),children:t.jsx(Te,{className:"h-3 w-3"})})]})]})}function ar(){const{t:e}=V();return t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsx("div",{className:"text-sm text-muted-foreground",children:e("fileTree.loading")})})}const sr=e=>Math.min(100,Math.max(0,e)),Xe=e=>e===1?"file":"files";function ir({upload:e}){const{t:r}=V();if(!e)return null;const o=sr(e.progress),l=e.status==="uploading",i=e.status==="complete",s=e.status==="error",u=e.fileCount===1&&e.fileName?e.fileName:`${e.fileCount} ${Xe(e.fileCount)}`,c=l?r("fileTree.uploadingFiles","Uploading files"):i?r("fileTree.uploadComplete","Upload complete"):r("fileTree.uploadFailed","Upload failed"),x=s?e.error:i&&typeof e.uploadedCount=="number"?r("fileTree.uploadedCount","Uploaded {{uploaded}} of {{total}} {{label}}",{uploaded:e.uploadedCount,total:e.fileCount,label:Xe(e.fileCount)}):u,b=s?Ct:i?kt:oe;return t.jsxs("div",{className:U("border-b px-3 py-2 transition-colors",s?"border-red-500/20 bg-red-500/10 text-red-700 dark:text-red-300":i?"border-emerald-500/20 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":"border-primary/20 bg-primary/10 text-foreground"),children:[t.jsxs("div",{className:"flex min-h-[36px] items-center gap-2",children:[t.jsx("div",{className:U("flex h-7 w-7 shrink-0 items-center justify-center rounded-md",s?"bg-red-500/15":i?"bg-emerald-500/15":"bg-primary/15"),children:t.jsx(b,{className:U("h-3.5 w-3.5",l&&"animate-pulse")})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"truncate text-xs font-medium",children:c}),t.jsx("span",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground",children:l?`${o}%`:i?r("common.done","Done"):r("common.failed","Failed")})]}),t.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground",children:x})]})]}),t.jsx("div",{className:"mt-2 h-1.5 overflow-hidden rounded-full bg-background/80",children:t.jsx("div",{className:U("h-full rounded-full transition-[width] duration-200",s?"bg-red-500":i?"bg-emerald-500":"bg-primary"),style:{width:`${s?Math.max(o,8):o}%`}})})]})}function cr({file:e,onClose:r}){const o=`/api/file-tree/projects/${e.projectId}/files/content?path=${encodeURIComponent(e.path)}`,[l,i]=a.useState(null),[s,u]=a.useState(null),[c,x]=a.useState(!0);return a.useEffect(()=>{let b=null;const g=new AbortController;return(async()=>{try{x(!0),u(null),i(null);const d=await ct(o,{signal:g.signal});if(!d.ok)throw new Error(`Request failed with status ${d.status}`);const f=await d.blob();b=URL.createObjectURL(f),i(b)}catch(d){if(d instanceof Error&&d.name==="AbortError")return;console.error("Error loading image:",d),u("Unable to load image")}finally{x(!1)}})(),()=>{g.abort(),b&&URL.revokeObjectURL(b)}},[o]),t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50",children:t.jsxs("div",{className:"mx-4 max-h-[90vh] w-full max-w-4xl overflow-hidden rounded-lg bg-white shadow-xl dark:bg-gray-800",children:[t.jsxs("div",{className:"flex items-center justify-between border-b p-4",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:e.name}),t.jsx(z,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:t.jsx(Te,{className:"h-4 w-4"})})]}),t.jsxs("div",{className:"flex min-h-[400px] items-center justify-center bg-gray-50 p-4 dark:bg-gray-900",children:[c&&t.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400",children:t.jsx("p",{children:"Loading image..."})}),!c&&l&&t.jsx("img",{src:l,alt:e.name,className:"max-h-[70vh] max-w-full rounded-lg object-contain shadow-md"}),!c&&!l&&t.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[t.jsx("p",{children:s||"Unable to load image"}),t.jsx("p",{className:"mt-2 break-all text-sm",children:e.path})]})]}),t.jsx("div",{className:"border-t bg-gray-50 p-4 dark:bg-gray-800",children:t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:e.path})})]})})}function hr({selectedProject:e,onFileOpen:r}){const{t:o}=V(),[l,i]=a.useState(null),[s,u]=a.useState(null),c=a.useRef(null),x=a.useRef(null),b=a.useCallback((j,m)=>{u({message:j,type:m})},[]);a.useEffect(()=>{if(s){const j=setTimeout(()=>u(null),3e3);return()=>clearTimeout(j)}},[s]);const{files:g,loading:v,error:d,refreshFiles:f}=Dt(e),{viewMode:y,changeViewMode:E}=Vt(),{expandedDirs:N,toggleDirectory:S,expandDirectories:L,collapseAll:D}=Et(),{searchQuery:R,setSearchQuery:M,filteredFiles:h}=Bt({files:g,expandDirectories:L}),n=At({selectedProject:e,onRefresh:f,showToast:b}),p=Yt({selectedProject:e,onRefresh:f,showToast:b}),w=n.operationLoading||p.operationLoading,C=a.useRef(null),F=a.useRef(""),{uploadFiles:I}=p,P=a.useCallback(j=>{F.current=j,C.current?.click()},[]),G=a.useCallback(j=>{const{files:m}=j.target;m&&m.length>0&&I(Array.from(m),F.current),j.target.value=""},[I]);a.useEffect(()=>{n.isCreating&&c.current&&(c.current.focus(),c.current.select())},[n.isCreating]),a.useEffect(()=>{n.renamingItem&&x.current&&(x.current.focus(),x.current.select())},[n.renamingItem]);const _=a.useCallback(j=>{const{icon:m,color:k}=Tt(j);return t.jsx(m,{className:U(_e,k)})},[]),O=a.useCallback(j=>{if(j.type==="directory"){S(j.path);return}if(zt(j.name)&&e){i({name:j.name,path:j.path,projectPath:e.path,projectId:e.projectId});return}r?.(j.path)},[r,e,S]),q=a.useCallback(j=>$t(j,o),[o]);return v?t.jsx(ar,{}):t.jsxs("div",{ref:p.treeRef,className:"relative flex h-full flex-col bg-background",onDragEnter:p.handleDragEnter,onDragOver:p.handleDragOver,onDragLeave:p.handleDragLeave,onDrop:p.handleDrop,children:[t.jsx("input",{ref:C,type:"file",multiple:!0,className:"hidden",onChange:G,tabIndex:-1,"aria-hidden":"true"}),p.isDragOver&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-50 flex items-center justify-center border-2 border-dashed border-blue-500 bg-blue-500/10",children:t.jsxs("div",{className:"flex items-center gap-3 rounded-lg bg-background/95 px-6 py-4 shadow-lg",children:[t.jsx(oe,{className:"h-6 w-6 text-blue-500"}),t.jsx("span",{className:"text-sm font-medium",children:p.dropTarget?o("fileTree.dropToUploadTo",'Drop files to upload to "{{folder}}"',{folder:p.dropTarget.split(/[\\/]/).pop()}):o("fileTree.dropToUpload","Drop files to upload")})]})}),t.jsx(lr,{viewMode:y,onViewModeChange:E,searchQuery:R,onSearchQueryChange:M,onUploadFiles:p.handleFileSelect,onNewFile:()=>n.handleStartCreate("","file"),onNewFolder:()=>n.handleStartCreate("","directory"),onRefresh:f,onCollapseAll:D,loading:v,operationLoading:w,isUploading:p.uploadProgress?.status==="uploading",uploadProgress:p.uploadProgress?.progress??null}),t.jsx(ir,{upload:p.uploadProgress}),y==="detailed"&&h.length>0&&t.jsx(nr,{}),t.jsxs(dt,{className:"flex-1 px-2 py-1",children:[n.isCreating&&t.jsxs("div",{className:"mb-1 flex items-center gap-1.5 py-[3px] pr-2",style:{paddingLeft:`${(n.newItemParent.split("/").length-1)*16+4}px`},children:[n.newItemType==="directory"?t.jsx(Fe,{className:U(_e,"text-blue-500")}):t.jsx("span",{className:"ml-[18px]",children:_(n.newItemName)}),t.jsx(Ne,{ref:c,type:"text",value:n.newItemName,onChange:j=>n.setNewItemName(j.target.value),onKeyDown:j=>{j.stopPropagation(),j.key==="Enter"&&n.handleConfirmCreate(),j.key==="Escape"&&n.handleCancelCreate()},onBlur:()=>{setTimeout(()=>{n.isCreating&&n.handleConfirmCreate()},100)},className:"h-6 flex-1 text-sm",disabled:w})]}),t.jsx(or,{files:g,filteredFiles:h,error:d,searchQuery:R,viewMode:y,expandedDirs:N,onItemClick:O,renderFileIcon:_,formatFileSize:Pt,formatRelativeTime:q,onRename:n.handleStartRename,onDelete:n.handleStartDelete,onNewFile:j=>n.handleStartCreate(j,"file"),onNewFolder:j=>n.handleStartCreate(j,"directory"),onCopyPath:n.handleCopyPath,onDownload:n.handleDownload,onUpload:P,onRefresh:f,dropTarget:p.dropTarget,onItemDragOver:p.handleItemDragOver,renamingItem:n.renamingItem,renameValue:n.renameValue,setRenameValue:n.setRenameValue,handleConfirmRename:n.handleConfirmRename,handleCancelRename:n.handleCancelRename,renameInputRef:x,operationLoading:w})]}),l&&t.jsx(cr,{file:l,onClose:()=>i(null)}),n.deleteConfirmation.isOpen&&n.deleteConfirmation.item&&t.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/50",children:t.jsxs("div",{className:"mx-4 max-w-sm rounded-lg border border-border bg-background p-4 shadow-lg",children:[t.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[t.jsx("div",{className:"rounded-full bg-red-100 p-2 dark:bg-red-900/30",children:t.jsx(Ke,{className:"h-5 w-5 text-red-600 dark:text-red-400"})}),t.jsxs("div",{children:[t.jsx("h3",{className:"font-medium text-foreground",children:o("fileTree.delete.title","Delete {{type}}",{type:n.deleteConfirmation.item.type==="directory"?"Folder":"File"})}),t.jsx("p",{className:"text-sm text-muted-foreground",children:n.deleteConfirmation.item.name})]})]}),t.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:n.deleteConfirmation.item.type==="directory"?o("fileTree.delete.folderWarning","This folder and all its contents will be permanently deleted."):o("fileTree.delete.fileWarning","This file will be permanently deleted.")}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{onClick:n.handleCancelDelete,disabled:w,className:"rounded-md px-3 py-1.5 text-sm transition-colors hover:bg-accent",children:o("common.cancel","Cancel")}),t.jsxs("button",{onClick:n.handleConfirmDelete,disabled:w,className:"flex items-center gap-2 rounded-md bg-red-600 px-3 py-1.5 text-sm text-white transition-colors hover:bg-red-700 disabled:opacity-50",children:[w&&t.jsx(Je,{className:"h-4 w-4 animate-spin"}),o("fileTree.delete.confirm","Delete")]})]})]})}),s&&t.jsxs("div",{className:U("fixed bottom-4 right-4 z-[9999] px-4 py-2 rounded-lg shadow-lg flex items-center gap-2 animate-in slide-in-from-bottom-2",s.type==="success"?"bg-green-600 text-white":"bg-red-600 text-white"),children:[s.type==="success"?t.jsx(Nt,{className:"h-4 w-4"}):t.jsx(Te,{className:"h-4 w-4"}),t.jsx("span",{className:"text-sm",children:s.message})]})]})}export{hr as default};
|