@yancyyu/openhermit 1.6.27 → 1.6.29

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.
Files changed (101) hide show
  1. package/README.md +7 -1
  2. package/bin/hermit.mjs +2 -2
  3. package/dist-renderer/assets/ProjectEditorOverlay-CQm6jUR1.js +52 -0
  4. package/dist-renderer/assets/{TeamGraphOverlay-DVq8rt6_.js → TeamGraphOverlay-h0WDfifv.js} +1 -1
  5. package/dist-renderer/assets/{_basePickBy-ZbF0pKvS.js → _basePickBy-CgG_tjgX.js} +1 -1
  6. package/dist-renderer/assets/{_baseUniq-BBLBOeXc.js → _baseUniq-DwPTU9lP.js} +1 -1
  7. package/dist-renderer/assets/{arc-wGaEgkCf.js → arc-7nIrGRzY.js} +1 -1
  8. package/dist-renderer/assets/{architectureDiagram-VXUJARFQ-BpMkdC35.js → architectureDiagram-VXUJARFQ-BYhA6Ev2.js} +1 -1
  9. package/dist-renderer/assets/{blockDiagram-VD42YOAC-C8Z1xhG4.js → blockDiagram-VD42YOAC-BVpZUGDg.js} +1 -1
  10. package/dist-renderer/assets/{c4Diagram-YG6GDRKO-CJmlw9LA.js → c4Diagram-YG6GDRKO-DsdreMQ9.js} +1 -1
  11. package/dist-renderer/assets/channel-C0SqeFU7.js +1 -0
  12. package/dist-renderer/assets/{chunk-4BX2VUAB-CHPHiRPP.js → chunk-4BX2VUAB-CcoAs7Jd.js} +1 -1
  13. package/dist-renderer/assets/{chunk-55IACEB6-DyVohOQb.js → chunk-55IACEB6-CGGAOoXd.js} +1 -1
  14. package/dist-renderer/assets/{chunk-B4BG7PRW-p5bffh_R.js → chunk-B4BG7PRW-FhpTEPvD.js} +1 -1
  15. package/dist-renderer/assets/{chunk-DI55MBZ5-BnfGPSUu.js → chunk-DI55MBZ5-DoYySbm1.js} +1 -1
  16. package/dist-renderer/assets/{chunk-FMBD7UC4-B6SCKseX.js → chunk-FMBD7UC4-e9l2tGHG.js} +1 -1
  17. package/dist-renderer/assets/{chunk-QN33PNHL-L12RvLBR.js → chunk-QN33PNHL-DeiXVTCy.js} +1 -1
  18. package/dist-renderer/assets/{chunk-QZHKN3VN-DeH1Kxge.js → chunk-QZHKN3VN-DC2UJLJM.js} +1 -1
  19. package/dist-renderer/assets/{chunk-TZMSLE5B-BWnjzSlI.js → chunk-TZMSLE5B-BHFD9eZI.js} +1 -1
  20. package/dist-renderer/assets/classDiagram-2ON5EDUG-DWew1HpM.js +1 -0
  21. package/dist-renderer/assets/classDiagram-v2-WZHVMYZB-DWew1HpM.js +1 -0
  22. package/dist-renderer/assets/clone-Dm-k63Yr.js +1 -0
  23. package/dist-renderer/assets/{cose-bilkent-S5V4N54A-BtzoT5fu.js → cose-bilkent-S5V4N54A-BdybQraU.js} +1 -1
  24. package/dist-renderer/assets/{dagre-6UL2VRFP-CBBvuoUD.js → dagre-6UL2VRFP-DdF3pwM3.js} +1 -1
  25. package/dist-renderer/assets/{diagram-PSM6KHXK-Be9BAKws.js → diagram-PSM6KHXK-B9Ldd3nh.js} +1 -1
  26. package/dist-renderer/assets/{diagram-QEK2KX5R-BDS4PI_i.js → diagram-QEK2KX5R-XEqkrbpu.js} +1 -1
  27. package/dist-renderer/assets/{diagram-S2PKOQOG-2Rameaq7.js → diagram-S2PKOQOG-CipwtY59.js} +1 -1
  28. package/dist-renderer/assets/{erDiagram-Q2GNP2WA-CSIzCEZD.js → erDiagram-Q2GNP2WA-BB-2ISGo.js} +1 -1
  29. package/dist-renderer/assets/{flowDiagram-NV44I4VS-ForEIVM5.js → flowDiagram-NV44I4VS-B8XmJ0u2.js} +1 -1
  30. package/dist-renderer/assets/{ganttDiagram-JELNMOA3-BJrli_xr.js → ganttDiagram-JELNMOA3-D-8XglBb.js} +1 -1
  31. package/dist-renderer/assets/{gitGraphDiagram-V2S2FVAM-C_4GuLno.js → gitGraphDiagram-V2S2FVAM-DL4ChakD.js} +1 -1
  32. package/dist-renderer/assets/{graph-B1EAT_gw.js → graph-BiFNoBjP.js} +1 -1
  33. package/dist-renderer/assets/{index-eKRmS5kI.js → index-6m1ZAymG.js} +1 -1
  34. package/dist-renderer/assets/index-BhellmRb.css +1 -0
  35. package/dist-renderer/assets/{index-DYdseEwc.js → index-BowUl0Jb.js} +518 -514
  36. package/dist-renderer/assets/{index-DR602dwJ.js → index-Dp3kJTEe.js} +1 -1
  37. package/dist-renderer/assets/{index-Dwr5wu5x.js → index-TOpt_T7A.js} +1 -1
  38. package/dist-renderer/assets/{index-DOA_jbYb.js → index-qNBNjW4K.js} +1 -1
  39. package/dist-renderer/assets/{index-k4tnOFC5.js → index-vAykq1H1.js} +1 -1
  40. package/dist-renderer/assets/{infoDiagram-HS3SLOUP-DjI0uaMz.js → infoDiagram-HS3SLOUP-DRIBfHDi.js} +1 -1
  41. package/dist-renderer/assets/{journeyDiagram-XKPGCS4Q-jQ6Thae-.js → journeyDiagram-XKPGCS4Q-BOMiigU4.js} +1 -1
  42. package/dist-renderer/assets/{kanban-definition-3W4ZIXB7-CKw6InbL.js → kanban-definition-3W4ZIXB7-DDxeyjod.js} +1 -1
  43. package/dist-renderer/assets/{layout-Dad20y3V.js → layout-DNANbrI4.js} +1 -1
  44. package/dist-renderer/assets/{linear-vMgo_2Cv.js → linear-DxEJi1yT.js} +1 -1
  45. package/dist-renderer/assets/{mindmap-definition-VGOIOE7T-DYp6YoHL.js → mindmap-definition-VGOIOE7T-nBfGriW8.js} +1 -1
  46. package/dist-renderer/assets/{pieDiagram-ADFJNKIX-BytBecG9.js → pieDiagram-ADFJNKIX-Din5j6sV.js} +1 -1
  47. package/dist-renderer/assets/{quadrantDiagram-AYHSOK5B-RUaspLsc.js → quadrantDiagram-AYHSOK5B-DMVK2BEQ.js} +1 -1
  48. package/dist-renderer/assets/{requirementDiagram-UZGBJVZJ-rR2B1Use.js → requirementDiagram-UZGBJVZJ-6SC94Gg_.js} +1 -1
  49. package/dist-renderer/assets/{sankeyDiagram-TZEHDZUN-BJi5qYhq.js → sankeyDiagram-TZEHDZUN-CD2gghhu.js} +1 -1
  50. package/dist-renderer/assets/{sequenceDiagram-WL72ISMW-BM-wggUb.js → sequenceDiagram-WL72ISMW-BnhkN7nZ.js} +1 -1
  51. package/dist-renderer/assets/{stateDiagram-FKZM4ZOC-BqmcVjnj.js → stateDiagram-FKZM4ZOC-Bn8XdYX-.js} +1 -1
  52. package/dist-renderer/assets/{stateDiagram-v2-4FDKWEC3-By3JDVbB.js → stateDiagram-v2-4FDKWEC3-1b6sI1_g.js} +1 -1
  53. package/dist-renderer/assets/{timeline-definition-IT6M3QCI-szH0GUyk.js → timeline-definition-IT6M3QCI-CNs3RPoa.js} +1 -1
  54. package/dist-renderer/assets/treemap-GDKQZRPO-DU_yr827.js +162 -0
  55. package/dist-renderer/assets/{xychartDiagram-PRI3JC2R-dwDpvw0w.js → xychartDiagram-PRI3JC2R-B8o5J2f3.js} +1 -1
  56. package/dist-renderer/index.html +2 -2
  57. package/package.json +1 -1
  58. package/src/main/server.ts +800 -163
  59. package/src/main/services/session-intelligence/SessionUsageParser.ts +446 -0
  60. package/src/main/services/session-intelligence/UsageTelemetryService.ts +252 -0
  61. package/src/main/services/teams-mvp/CollaborationBoardService.ts +310 -0
  62. package/src/main/services/teams-mvp/TaskDispatchService.ts +880 -95
  63. package/src/main/services/teams-mvp/TeamProvisioningService.ts +58 -19
  64. package/src/main/services/teams-mvp/TeamWorkspaceService.ts +25 -2
  65. package/src/main/services/teams-mvp/index.ts +3 -0
  66. package/src/renderer/App.tsx +5 -0
  67. package/src/renderer/api/httpClient.ts +67 -0
  68. package/src/renderer/components/dashboard/DashboardView.tsx +6 -105
  69. package/src/renderer/components/layout/PaneContent.tsx +2 -0
  70. package/src/renderer/components/layout/SortableTab.tsx +1 -0
  71. package/src/renderer/components/layout/TabBarActions.tsx +12 -12
  72. package/src/renderer/components/schedules/SchedulesView.tsx +54 -22
  73. package/src/renderer/components/settings/SettingsTabs.tsx +2 -2
  74. package/src/renderer/components/settings/sections/AdvancedSection.tsx +1 -1
  75. package/src/renderer/components/settings/sections/TaskBusSection.tsx +511 -81
  76. package/src/renderer/components/tasks/TasksView.tsx +343 -0
  77. package/src/renderer/components/team/TeamDetailView.tsx +20 -98
  78. package/src/renderer/components/team/dialogs/LaunchTeamDialog.tsx +1 -1
  79. package/src/renderer/components/team/editor/EditorContextMenu.tsx +8 -23
  80. package/src/renderer/components/team/editor/EditorFileTree.tsx +0 -4
  81. package/src/renderer/components/team/editor/EditorSelectionMenu.tsx +1 -8
  82. package/src/renderer/components/team/editor/ProjectEditorOverlay.tsx +0 -10
  83. package/src/renderer/components/team/kanban/KanbanBoard.tsx +5 -1
  84. package/src/renderer/components/team/members/MemberDetailDialog.tsx +8 -33
  85. package/src/renderer/components/team/messages/MessageComposer.tsx +39 -3
  86. package/src/renderer/components/team/messages/MessagesPanel.tsx +72 -2
  87. package/src/renderer/components/team/messages/StatusBlock.tsx +2 -24
  88. package/src/renderer/components/team/schedule/ScheduleEmptyState.tsx +1 -1
  89. package/src/renderer/components/ui/MentionableTextarea.tsx +0 -1
  90. package/src/renderer/store/slices/scheduleSlice.ts +21 -0
  91. package/src/renderer/store/slices/teamSlice.ts +59 -23
  92. package/src/renderer/types/tabs.ts +1 -0
  93. package/src/shared/types/api.ts +29 -0
  94. package/src/shared/types/team.ts +109 -1
  95. package/dist-renderer/assets/ProjectEditorOverlay-BBwYdXPv.js +0 -57
  96. package/dist-renderer/assets/channel-DJUrwVrK.js +0 -1
  97. package/dist-renderer/assets/classDiagram-2ON5EDUG-blc3DrH7.js +0 -1
  98. package/dist-renderer/assets/classDiagram-v2-WZHVMYZB-blc3DrH7.js +0 -1
  99. package/dist-renderer/assets/clone-BftjWakJ.js +0 -1
  100. package/dist-renderer/assets/index-CWpFqEvz.css +0 -1
  101. package/dist-renderer/assets/treemap-GDKQZRPO-BCMlh-Ex.js +0 -162
@@ -133,6 +133,9 @@ export type TeamReviewState = 'none' | 'review' | 'needsFix' | 'approved';
133
133
 
134
134
  export type DispatchStatus =
135
135
  | 'dispatched'
136
+ | 'pending_accept'
137
+ | 'accepted'
138
+ | 'rejected'
136
139
  | 'received'
137
140
  | 'in_progress'
138
141
  | 'completed'
@@ -148,6 +151,15 @@ export interface DispatchMeta {
148
151
  receivedAt?: string;
149
152
  completedAt?: string;
150
153
  remoteTaskId?: string;
154
+ deadline?: string;
155
+ acceptedAt?: string;
156
+ rejectedAt?: string;
157
+ rejectionReason?: string;
158
+ }
159
+
160
+ export interface AgentCapability {
161
+ skill: string;
162
+ description: string;
151
163
  }
152
164
 
153
165
  export interface DiscoverableTeam {
@@ -156,6 +168,9 @@ export interface DiscoverableTeam {
156
168
  location: 'local' | 'remote';
157
169
  status: 'online' | 'offline';
158
170
  collaboration: boolean;
171
+ capabilities?: AgentCapability[];
172
+ description?: string;
173
+ harness?: string;
159
174
  }
160
175
 
161
176
  export interface TaskBusConfig {
@@ -166,6 +181,13 @@ export interface TaskBusConfig {
166
181
  password?: string;
167
182
  db?: number;
168
183
  };
184
+ collaboration?: boolean;
185
+ telemetry?: {
186
+ enabled: boolean;
187
+ uploadEnabled?: boolean;
188
+ /** Data source platform. Currently only 'claudecode'. */
189
+ platform: 'claudecode';
190
+ };
169
191
  }
170
192
 
171
193
  export interface TaskDispatchPayload {
@@ -180,6 +202,8 @@ export interface TaskDispatchPayload {
180
202
  promptTaskRefs?: string[];
181
203
  };
182
204
  dispatchedAt: string;
205
+ deadline?: string;
206
+ needsHumanReview?: boolean;
183
207
  }
184
208
 
185
209
  export interface TaskStatusUpdate {
@@ -198,6 +222,81 @@ export interface TaskAckPayload {
198
222
  timestamp: string;
199
223
  }
200
224
 
225
+ export interface TaskHandshakeResponse {
226
+ dispatchId: string;
227
+ type: 'task_accept' | 'task_reject' | 'task_deliver' | 'task_approve' | 'task_revision';
228
+ fromTeam: string;
229
+ toTeam: string;
230
+ remoteTaskId?: string;
231
+ reason?: string;
232
+ result?: string;
233
+ feedback?: string;
234
+ acceptedAt?: string;
235
+ rejectedAt?: string;
236
+ deliveredAt?: string;
237
+ approvedAt?: string;
238
+ }
239
+
240
+ // ---------------------------------------------------------------------------
241
+ // Collaboration Board — global cross-team task view
242
+ // ---------------------------------------------------------------------------
243
+
244
+ export type CollabTaskStatus =
245
+ | 'pending_accept'
246
+ | 'accepted'
247
+ | 'delivered'
248
+ | 'approved'
249
+ | 'revision'
250
+ | 'rejected'
251
+ | 'failed';
252
+
253
+ export type CollabTaskEventType =
254
+ | 'task_sent'
255
+ | 'task_accepted'
256
+ | 'task_rejected'
257
+ | 'task_delivered'
258
+ | 'revision_requested'
259
+ | 'task_approved'
260
+ | 'task_failed';
261
+
262
+ export interface CollabTaskEvent {
263
+ eventId: string;
264
+ dispatchId: string;
265
+ version: number;
266
+ type: CollabTaskEventType;
267
+ actor: {
268
+ type: 'user' | 'team' | 'agent' | 'system';
269
+ id: string;
270
+ };
271
+ payload?: Record<string, unknown>;
272
+ createdAt: string;
273
+ }
274
+
275
+ export interface CollabTask {
276
+ id: string;
277
+ dispatchId: string;
278
+ subject: string;
279
+ description?: string;
280
+ fromTeam: string;
281
+ fromTeamDisplay: string;
282
+ toTeam: string;
283
+ toTeamDisplay: string;
284
+ status: CollabTaskStatus;
285
+ version?: number;
286
+ reason?: string;
287
+ result?: string;
288
+ feedback?: string;
289
+ deadline?: string;
290
+ needsHumanReview: boolean;
291
+ revisionCount: number;
292
+ createdAt: string;
293
+ updatedAt: string;
294
+ acceptedAt?: string;
295
+ rejectedAt?: string;
296
+ deliveredAt?: string;
297
+ approvedAt?: string;
298
+ }
299
+
201
300
  export interface TaskWorkInterval {
202
301
  /** ISO timestamp when task entered in_progress */
203
302
  startedAt: string;
@@ -858,7 +957,15 @@ export type TeamLaunchAggregateState =
858
957
  | 'partial_skipped';
859
958
  export type PersistedTeamLaunchPhase = 'active' | 'finished' | 'reconciled';
860
959
 
861
- export type KanbanColumnId = 'todo' | 'in_progress' | 'done' | 'review' | 'approved';
960
+ export type KanbanColumnId =
961
+ | 'todo'
962
+ | 'in_progress'
963
+ | 'done'
964
+ | 'review'
965
+ | 'approved'
966
+ | 'pending_accept'
967
+ | 'delivered'
968
+ | 'revision';
862
969
 
863
970
  export interface KanbanTaskState {
864
971
  column: Extract<KanbanColumnId, 'review' | 'approved'>;
@@ -1694,6 +1801,7 @@ export interface CrossTeamSendRequest {
1694
1801
  toTeam: string;
1695
1802
  timestamp?: string;
1696
1803
  messageId?: string;
1804
+ sessionKey?: string;
1697
1805
  conversationId?: string;
1698
1806
  replyToConversationId?: string;
1699
1807
  text: string;
@@ -1,57 +0,0 @@
1
- import{bD as de,bE as w,bF as Re,r as s,bG as Ce,bH as As,bI as Ls,E as pe,bJ as Os,bK as zs,q as e,bL as $s,bM as Ks,bN as Kt,bO as Gt,bP as Gs,bQ as Bs,bR as Us,bS as Vs,bT as H,bU as X,bV as sn,bW as rn,bX as q,bY as mt,bZ as he,b_ as on,b$ as P,c0 as Ws,c1 as tt,c2 as Hs,c3 as Xs,c4 as qs,c5 as Ys,c6 as Qs,c7 as Zs,c8 as Js,c9 as er,ca as tr,cb as nr,cc as sr,cd as rr,ce as or,cf as ar,cg as Bt,ch as ir,ci as an,cj as cn,ck as cr,cl as lr,cm as dr,cn as ur,co as xr,cp as je,cq as nt,cr as fr,cs as Ee,ct as hr,cu as gt,cv as ln,cw as mr,cx as dn,cy as un,cz as bt,cA as pr,cB as gr,cC as br,cD as st,cE as vr,cF as Be,cG as $,cH as Ie,cI as Cr,cJ as jr,cK as yr,cL as Nr,cM as wr,cN as Sr,cO as kr,cP as Mr,cQ as Tr,cR as Er,cS as Rr,cT as Ir,cU as Ze,cV as Dr,cW as Pr,cX as vt,cY as xn,cZ as fn,c_ as hn,c$ as _r,d0 as Fr,d1 as Ar,d2 as mn,d3 as pn,d4 as gn,d5 as Le,d6 as Oe,d7 as ze,d8 as $e,d9 as Ye,da as Qe,db as bn,dc as vn,dd as Lr,de as Ue,df as Or,dg as zr,dh as $r,di as Kr,dj as Gr,dk as Br,dl as Ur,dm as Vr,dn as Wr,dp as Hr,dq as Xr,dr as qr,ds as Yr,dt as Qr,du as Zr,dv as Fe,dw as Jr,dx as Ut,dy as eo,dz as to,dA as Vt,dB as no,dC as so,dD as ro,dE as Wt}from"./index-DYdseEwc.js";import"./splashScene-C8lWNnm4.js";/**
2
- * @license lucide-react v0.577.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const oo=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],ao=de("arrow-down",oo);/**
7
- * @license lucide-react v0.577.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const io=[["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M22 9v7",key:"pvm9v3"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}],["circle",{cx:"18.5",cy:"12.5",r:"3.5",key:"z97x68"}]],co=de("case-sensitive",io);/**
12
- * @license lucide-react v0.577.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const lo=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]],Ht=de("clipboard-copy",lo);/**
17
- * @license lucide-react v0.577.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const uo=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],xo=de("columns-2",uo);/**
22
- * @license lucide-react v0.577.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const fo=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]],Cn=de("file-plus",fo);/**
27
- * @license lucide-react v0.577.0 - ISC
28
- *
29
- * This source code is licensed under the ISC license.
30
- * See the LICENSE file in the root directory of this source tree.
31
- */const ho=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 17h.01",key:"p32p05"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}]],mo=de("file-question-mark",ho);/**
32
- * @license lucide-react v0.577.0 - ISC
33
- *
34
- * This source code is licensed under the ISC license.
35
- * See the LICENSE file in the root directory of this source tree.
36
- */const po=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],jn=de("folder-plus",po);/**
37
- * @license lucide-react v0.577.0 - ISC
38
- *
39
- * This source code is licensed under the ISC license.
40
- * See the LICENSE file in the root directory of this source tree.
41
- */const go=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]],yn=de("list-todo",go);/**
42
- * @license lucide-react v0.577.0 - ISC
43
- *
44
- * This source code is licensed under the ISC license.
45
- * See the LICENSE file in the root directory of this source tree.
46
- */const bo=[["path",{d:"M17 3v10",key:"15fgeh"}],["path",{d:"m12.67 5.5 8.66 5",key:"1gpheq"}],["path",{d:"m12.67 10.5 8.66-5",key:"1dkfa6"}],["path",{d:"M9 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-2z",key:"swwfx4"}]],vo=de("regex",bo);/**
47
- * @license lucide-react v0.577.0 - ISC
48
- *
49
- * This source code is licensed under the ISC license.
50
- * See the LICENSE file in the root directory of this source tree.
51
- */const Co=[["path",{d:"m16 16-3 3 3 3",key:"117b85"}],["path",{d:"M3 12h14.5a1 1 0 0 1 0 7H13",key:"18xa6z"}],["path",{d:"M3 19h6",key:"1ygdsz"}],["path",{d:"M3 5h18",key:"1u36vt"}]],jo=de("text-wrap",Co);/**
52
- * @license lucide-react v0.577.0 - ISC
53
- *
54
- * This source code is licensed under the ISC license.
55
- * See the LICENSE file in the root directory of this source tree.
56
- */const yo=[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}],["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]],No=de("whole-word",yo);function wo(t){return n=>{if(!(n.metaKey||n.ctrlKey))return;const r=As(n);if(r==="p"&&!n.shiftKey){n.preventDefault(),n.stopPropagation(),t.onToggleQuickOpen();return}if(r==="f"&&n.shiftKey){n.preventDefault(),n.stopPropagation(),t.onToggleSearchPanel();return}if(r==="f"&&!n.shiftKey){n.preventDefault(),n.stopPropagation();const a=t.getEditorView();a&&Ls(a);return}if(r==="g"&&!n.shiftKey){n.preventDefault(),n.stopPropagation(),t.onToggleGoToLine();return}if(r==="s"&&!n.shiftKey){n.preventDefault(),n.stopPropagation(),t.activeTabId&&t.saveFile(t.activeTabId);return}if(r==="s"&&n.shiftKey){n.preventDefault(),n.stopPropagation(),t.hasUnsavedChanges()&&t.saveAllFiles();return}if(r==="m"&&n.shiftKey){n.preventDefault(),n.stopPropagation(),t.onToggleMdSplit?.();return}if(r==="v"&&n.shiftKey){n.preventDefault(),n.stopPropagation(),t.onToggleMdPreview?.();return}if(r==="w"&&n.shiftKey&&!n.altKey){n.preventDefault(),n.stopPropagation(),t.onToggleLineWrap();return}if(r==="w"&&!n.shiftKey&&!n.altKey){if(n.preventDefault(),n.stopPropagation(),t.activeTabId){const a=new CustomEvent("editor-close-tab",{detail:t.activeTabId});window.dispatchEvent(a)}return}if(r==="b"){n.preventDefault(),n.stopPropagation(),t.onToggleSidebar();return}if(r==="]"&&n.shiftKey){n.preventDefault(),n.stopPropagation();const a=t.openTabs.findIndex(i=>i.id===t.activeTabId);a!==-1&&a<t.openTabs.length-1?t.setActiveEditorTab(t.openTabs[a+1].id):t.openTabs.length>0&&t.setActiveEditorTab(t.openTabs[0].id);return}if(r==="["&&n.shiftKey){n.preventDefault(),n.stopPropagation();const a=t.openTabs.findIndex(i=>i.id===t.activeTabId);a>0?t.setActiveEditorTab(t.openTabs[a-1].id):t.openTabs.length>0&&t.setActiveEditorTab(t.openTabs[t.openTabs.length-1].id);return}if(n.ctrlKey&&r==="Tab"){n.preventDefault(),n.stopPropagation();const a=t.openTabs.findIndex(i=>i.id===t.activeTabId);if(n.shiftKey){const i=a>0?a-1:t.openTabs.length-1;t.openTabs[i]&&t.setActiveEditorTab(t.openTabs[i].id)}else{const i=a<t.openTabs.length-1?a+1:0;t.openTabs[i]&&t.setActiveEditorTab(t.openTabs[i].id)}}}}function So({onToggleQuickOpen:t,onToggleSearchPanel:n,onToggleGoToLine:o,onToggleSidebar:r,onClose:a,onToggleMdSplit:i,onToggleMdPreview:u}){const{openTabs:f,activeTabId:l}=w(Re(N=>({openTabs:N.editorOpenTabs,activeTabId:N.editorActiveTabId}))),c=w(N=>N.setActiveEditorTab),x=w(N=>N.saveFile),d=w(N=>N.saveAllFiles),m=w(N=>N.hasUnsavedChanges),y=w(N=>N.toggleLineWrap),b=s.useRef(null);b.current={activeTabId:l,openTabs:f,setActiveEditorTab:c,saveFile:x,saveAllFiles:d,hasUnsavedChanges:m,onToggleQuickOpen:t,onToggleSearchPanel:n,onToggleGoToLine:o,onToggleSidebar:r,onToggleLineWrap:y,onToggleMdSplit:i,onToggleMdPreview:u,getEditorView:()=>Ce.getView()};const v=s.useCallback(N=>{wo(b.current)(N)},[]);s.useEffect(()=>(window.addEventListener("keydown",v,!0),()=>window.removeEventListener("keydown",v,!0)),[v])}function ko(){if(typeof navigator>"u")return!1;const t=navigator.userAgentData?.platform??navigator.userAgent;return/mac/i.test(t)}const Nn=ko();function se(t,n){return Nn?t:n}const wn=999,ft=he.memo(function({active:n,onClick:o,tooltip:r,shortcut:a,children:i}){return e.jsxs(H,{children:[e.jsx(X,{asChild:!0,children:e.jsx("button",{type:"button",className:on("flex size-[22px] items-center justify-center rounded transition-colors",n?"bg-blue-500/20 text-blue-400":"text-[var(--color-text-muted)] hover:bg-[var(--color-surface-raised)] hover:text-[var(--color-text-secondary)]"),onClick:o,tabIndex:-1,children:i})}),e.jsxs(q,{side:"bottom",children:[e.jsx("span",{children:r}),a&&e.jsx("span",{className:"ml-1.5 text-[var(--color-text-muted)]",children:a})]})]})});function Mo(t,n){if(!t.valid||!t.search)return 0;try{const o=t.getCursor(n);let r=0;for(;!o.next().done;)if(r++,r>wn)return-1;return r}catch{return 0}}const To=({view:t,initialSearch:n,initialReplace:o,initialCaseSensitive:r,initialRegexp:a,initialWholeWord:i,registerUpdateNotifier:u})=>{const[f,l]=s.useState(n),[c,x]=s.useState(o),[d,m]=s.useState(r),[y,b]=s.useState(a),[v,N]=s.useState(i),[C,S]=s.useState(!1),[R,O]=s.useState(0),K=s.useRef(null);s.useEffect(()=>{requestAnimationFrame(()=>{K.current?.focus(),K.current?.select()})},[]);const I=s.useMemo(()=>new $s({search:f,replace:c,caseSensitive:d,regexp:y,wholeWord:v}),[f,c,d,y,v]);s.useEffect(()=>{t.dispatch({effects:Ks.of(I)})},[I,t]),s.useEffect(()=>{u(()=>O(D=>D+1))},[u]);const j=s.useMemo(()=>Mo(I,t.state),[I,t,R]),M=s.useCallback(()=>{Kt(t)},[t]),_=s.useCallback(()=>{Gt(t)},[t]),T=s.useCallback(()=>{Gs(t)},[t]),L=s.useCallback(()=>{Bs(t)},[t]),B=s.useCallback(()=>{Us(t),t.focus()},[t]),ae=s.useCallback(D=>{D.key==="Escape"?(D.preventDefault(),B()):D.key==="Enter"&&(D.preventDefault(),D.shiftKey?Gt(t):Kt(t))},[t,B]),ie=s.useCallback(D=>{D.key==="Escape"?(D.preventDefault(),B()):D.key==="Enter"&&(D.preventDefault(),T())},[B,T]),ue=f?j===-1?`${wn}+`:j===0?"无结果":`${j} found`:"";return e.jsx(Vs,{delayDuration:400,children:e.jsxs("div",{className:"flex flex-col gap-1 px-2 py-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs(H,{children:[e.jsx(X,{asChild:!0,children:e.jsx("button",{type:"button",className:"flex h-[22px] w-5 items-center justify-center rounded text-[var(--color-text-muted)] transition-colors hover:text-[var(--color-text-secondary)]",onClick:()=>S(D=>!D),tabIndex:-1,children:C?e.jsx(sn,{className:"size-3.5"}):e.jsx(rn,{className:"size-3.5"})})}),e.jsx(q,{side:"bottom",children:"显示/隐藏替换"})]}),e.jsx(mt,{ref:K,className:"h-[26px] min-w-[180px] flex-1 rounded border-[var(--color-border)] bg-[var(--color-surface)] px-2 text-xs",placeholder:"搜索",value:f,onChange:D=>l(D.target.value),onKeyDown:ae,spellCheck:!1}),e.jsx(ft,{active:d,onClick:()=>m(D=>!D),tooltip:"区分大小写",children:e.jsx(co,{className:"size-[14px]"})}),e.jsx(ft,{active:v,onClick:()=>N(D=>!D),tooltip:"全词匹配",children:e.jsx(No,{className:"size-[14px]"})}),e.jsx(ft,{active:y,onClick:()=>b(D=>!D),tooltip:"使用正则表达式",children:e.jsx(vo,{className:"size-[14px]"})}),e.jsx("div",{className:"mx-0.5 h-4 w-px bg-[var(--color-border)]"}),ue&&e.jsx("span",{className:on("min-w-[60px] whitespace-nowrap text-center text-xs tabular-nums",j===0&&f?"text-red-400":"text-[var(--color-text-muted)]"),children:ue}),e.jsxs(H,{children:[e.jsx(X,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon",className:"size-[22px] text-[var(--color-text-muted)] hover:text-[var(--color-text)]",onClick:_,disabled:j===0,tabIndex:-1,children:e.jsx(Ws,{className:"size-3.5"})})}),e.jsxs(q,{side:"bottom",children:["上一个匹配 ",e.jsx("span",{className:"text-[var(--color-text-muted)]",children:"⇧Enter"})]})]}),e.jsxs(H,{children:[e.jsx(X,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon",className:"size-[22px] text-[var(--color-text-muted)] hover:text-[var(--color-text)]",onClick:M,disabled:j===0,tabIndex:-1,children:e.jsx(ao,{className:"size-3.5"})})}),e.jsxs(q,{side:"bottom",children:["下一个匹配 ",e.jsx("span",{className:"text-[var(--color-text-muted)]",children:"Enter"})]})]}),e.jsxs(H,{children:[e.jsx(X,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon",className:"size-[22px] text-[var(--color-text-muted)] hover:text-[var(--color-text)]",onClick:B,tabIndex:-1,children:e.jsx(tt,{className:"size-3.5"})})}),e.jsxs(q,{side:"bottom",children:["关闭 ",e.jsx("span",{className:"text-[var(--color-text-muted)]",children:"Esc"})]})]})]}),C&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-5 shrink-0"}),e.jsx(mt,{className:"h-[26px] min-w-[180px] flex-1 rounded border-[var(--color-border)] bg-[var(--color-surface)] px-2 text-xs",placeholder:"替换",value:c,onChange:D=>x(D.target.value),onKeyDown:ie,spellCheck:!1}),e.jsxs(H,{children:[e.jsx(X,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"sm",className:"h-[22px] px-2 text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text)]",onClick:T,disabled:j===0,tabIndex:-1,children:"替换"})}),e.jsx(q,{side:"bottom",children:"替换下一个"})]}),e.jsxs(H,{children:[e.jsx(X,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"sm",className:"h-[22px] px-2 text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text)]",onClick:L,disabled:j===0,tabIndex:-1,children:"全部"})}),e.jsx(q,{side:"bottom",children:"全部替换"})]})]})]})})};function Eo(t){const n=document.createElement("div"),o=Os.createRoot(n),r=zs(t.state),a=t.state.selection.main,i=a.empty?"":t.state.sliceDoc(a.from,a.to),u=i&&!i.includes(`
57
- `)?i:r.search;let f=null;return o.render(e.jsx(To,{view:t,initialSearch:u,initialReplace:r.replace,initialCaseSensitive:r.caseSensitive,initialRegexp:r.regexp,initialWholeWord:r.wholeWord,registerUpdateNotifier:l=>{f=l}})),{dom:n,top:!0,update(l){l.docChanged&&f?.()},destroy(){f=null,o.unmount()}}}const Ro=pe.theme({".cm-panels":{backgroundColor:"var(--color-surface)",color:"var(--color-text)",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},".cm-panels-top":{borderBottom:"1px solid var(--color-border)"},".cm-panels-bottom":{borderTop:"1px solid var(--color-border)"},".cm-searchMatch":{backgroundColor:"var(--highlight-bg-inactive)",borderRadius:"2px"},".cm-searchMatch-selected":{backgroundColor:"var(--highlight-bg) !important",borderRadius:"2px"}}),Io=150,Xt=5e3;function qt(t,n){const o=t.coordsAtPos(n.to);if(!o)return null;let r=t.state.sliceDoc(n.from,n.to);return r.length>Xt&&(r=r.slice(0,Xt)+"…"),{text:r,filePath:"",fromLine:t.state.doc.lineAt(n.from).number,toLine:t.state.doc.lineAt(n.to).number,screenRect:{top:o.top,right:o.right??o.left,bottom:o.bottom}}}const Do=30,Po=300,_o=3e4,Fo=500*1024,Yt=10,Qt=new Hs;function Ao(t,n,o,r,a,i){const u=qs(t),f=Ys(t),l=[Qs,Zs(ir),Js(),er(),tr(),nr(),sr(),rr(),or(),ar({createPanel:Eo}),Ro,Bt.of([{key:"Mod-s",run:()=>(n(),!0)},{key:"Mod-z",run:c=>an(c)},{key:"Mod-Shift-z",run:c=>cn(c)}]),Bt.of([...cr,...lr,...dr.filter(c=>c.run!==xr),...ur]),pe.updateListener.of(c=>{if(c.docChanged&&o(),c.selectionSet||c.docChanged){const x=c.state.selection.main.head,d=c.state.doc.lineAt(x);r(d.number,x-d.from+1);const m=c.state.selection.main;m.empty?a(null):a(qt(c.view,m))}}),pe.domEventHandlers({scroll:(c,x)=>{const d=x.state.selection.main;d.empty||i(qt(x,d))}})];return u?l.push(u):f&&l.push(f.support??[]),l}function Lo(t,n){try{if(n.length>Fo)return;const o=`editor-draft:${t}`,r=JSON.stringify({content:n,timestamp:Date.now()});localStorage.setItem(o,r),Oo()}catch{}}function Oo(){try{const t=[];for(let n=0;n<localStorage.length;n++){const o=localStorage.key(n);if(o?.startsWith("editor-draft:"))try{const r=JSON.parse(localStorage.getItem(o));t.push({key:o,timestamp:r.timestamp})}catch{localStorage.removeItem(o)}}if(t.length>Yt){t.sort((o,r)=>o.timestamp-r.timestamp);const n=t.slice(0,t.length-Yt);for(const o of n)localStorage.removeItem(o.key)}}catch{}}const zo=150,$o=({filePath:t,content:n,fileName:o,mtimeMs:r,onCursorChange:a,onDraftRecovered:i,onSelectionChange:u,onDocChange:f})=>{const l=s.useRef(null),c=s.useRef(null),x=s.useRef(new Map),d=s.useRef(new Map),m=s.useRef([]),y=s.useRef(null),b=s.useRef(null),v=s.useRef(null),N=s.useRef(null),C=w(p=>p.markFileModified),S=w(p=>p.discardChanges),R=w(p=>p.saveFile),O=w(p=>p.editorLineWrap),K=s.useRef(t);K.current=t;const I=s.useRef(a);I.current=a;const j=s.useRef(i);j.current=i;const M=s.useRef(u);M.current=u;const _=s.useRef(f);_.current=f;const T=s.useRef(O);T.current=O;const L=s.useCallback(()=>{R(K.current)},[R]),B=s.useCallback(()=>{y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{C(K.current)},Po),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{const p=c.current;p&&Lo(K.current,p.state.doc.toString())},_o),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{const p=c.current;p&&_.current?.(p.state.doc.toString())},zo)},[C]),ae=s.useCallback((p,E)=>{I.current?.(p,E)},[]),ie=s.useCallback(p=>{if(!p){v.current&&clearTimeout(v.current),M.current?.(null);return}v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{M.current?.({...p,filePath:K.current})},Io)},[]),ue=s.useCallback(p=>{v.current&&clearTimeout(v.current),p?M.current?.({...p,filePath:K.current}):M.current?.(null)},[]),D=s.useCallback(p=>{const E=m.current,F=E.indexOf(p);for(F!==-1&&E.splice(F,1),E.push(p);E.length>Do;){const W=E.shift();x.current.delete(W),d.current.delete(W),S(W)}},[S]);s.useEffect(()=>{if(!l.current)return;const p=Ao(o,L,B,ae,ie,ue);p.push(Qt.of(T.current?pe.lineWrapping:[]));let E=x.current.get(t);if(!E){let we=n,ge=!1;try{const be=localStorage.getItem(`editor-draft:${t}`);if(be){const Se=JSON.parse(be),J=r??0;J===0||Se.timestamp>J?(we=Se.content,ge=!0):localStorage.removeItem(`editor-draft:${t}`)}}catch{}E=Xs.create({doc:we,extensions:p}),x.current.set(t,E),ge&&(C(t),j.current?.(t))}D(t);const F=new pe({state:E,parent:l.current}),W=d.current.get(t);W!==void 0&&(F.scrollDOM.scrollTop=W),c.current=F,Ce.register(x.current,d.current,F);const ce=F.state.selection.main.head,te=F.state.doc.lineAt(ce);I.current?.(te.number,ce-te.from+1);const le=d.current,re=x.current,V=y,xe=b,Z=v,fe=N;return()=>{le.set(t,F.scrollDOM.scrollTop),re.set(t,F.state),V.current&&clearTimeout(V.current),xe.current&&clearTimeout(xe.current),Z.current&&clearTimeout(Z.current),fe.current&&clearTimeout(fe.current),F.destroy(),c.current=null}},[t]),s.useEffect(()=>{const p=c.current;p&&p.dispatch({effects:Qt.reconfigure(O?pe.lineWrapping:[])})},[O]);const Q=w(p=>p.editorPendingGoToLine),A=w(p=>p.setPendingGoToLine);return s.useEffect(()=>{const p=c.current;if(!p||!Q)return;const E=p.state.doc.lines,F=Math.min(Math.max(1,Q),E),W=p.state.doc.line(F);p.dispatch({selection:{anchor:W.from},effects:pe.scrollIntoView(W.from,{y:"center"})}),A(null)},[Q,A,t]),s.useEffect(()=>()=>{Ce.unregister()},[]),e.jsx("div",{ref:l,className:"size-full overflow-hidden"})},Ko=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico"]),Go=10*1024*1024;function Bo(t){const n=t.lastIndexOf(".");return n===-1?"":t.slice(n+1).toLowerCase()}function Sn(t){const n=Bo(t);return Ko.has(n)?"image":"unknown"}function Uo(t,n){return Sn(t)==="image"?n<=Go:!1}const kn=({filePath:t,fileName:n,size:o})=>{const r=w(u=>u.editorProjectPath),a=o<1024?`${o} B`:o<1024*1024?`${(o/1024).toFixed(1)} KB`:`${(o/1024/1024).toFixed(1)} MB`,i=()=>{je.openPath(t,r??void 0).catch(console.error)};return e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 text-text-muted",children:[e.jsx(mo,{className:"size-12 opacity-30"}),e.jsx("p",{className:"text-sm font-medium text-text-secondary",children:n}),e.jsxs("p",{className:"text-xs",children:["Binary file (",a,")"]}),e.jsx(P,{variant:"outline",size:"sm",className:"mt-2",onClick:i,children:"Open in System Viewer"})]})},Vo=({filePath:t,fileName:n,size:o})=>{const r=w(S=>S.editorProjectPath),[a,i]=s.useState(null),[u,f]=s.useState(!0),[l,c]=s.useState(null),[x,d]=s.useState(!1),[m,y]=s.useState(null),b=s.useRef(null);s.useEffect(()=>{f(!0),c(null),i(null),y(null),d(!1)},[t]),s.useEffect(()=>{let S=!1;return je.editor.readBinaryPreview(t).then(R=>{S||i(`data:${R.mimeType};base64,${R.base64}`)}).catch(R=>{S||c(R.message)}).finally(()=>{S||f(!1)}),()=>{S=!0}},[t]);const v=s.useCallback(()=>{const S=b.current;S&&y({w:S.naturalWidth,h:S.naturalHeight})},[]),N=s.useCallback(()=>{je.openPath(t,r??void 0).catch(console.error)},[t,r]),C=o<1024?`${o} B`:o<1024*1024?`${(o/1024).toFixed(1)} KB`:`${(o/1024/1024).toFixed(1)} MB`;return u?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 text-text-muted",children:[e.jsx(nt,{className:"size-8 animate-spin opacity-40"}),e.jsx("p",{className:"text-xs",children:"正在加载预览…"})]}):l||!a?e.jsx(kn,{filePath:t,fileName:n,size:o}):e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-4 p-6",children:[e.jsx("button",{type:"button",className:"checkerboard-bg flex max-h-[60vh] max-w-[80%] cursor-zoom-in items-center justify-center overflow-hidden rounded-lg border border-border-subtle p-1",onClick:()=>d(!0),"aria-label":"打开完整尺寸预览",children:e.jsx("img",{ref:b,src:a,alt:n,className:"max-h-[60vh] object-contain",onLoad:v,draggable:!1})}),e.jsxs("p",{className:"text-xs text-text-muted",children:[n,m?` — ${m.w}×${m.h}`:"",` — ${C}`]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(P,{variant:"outline",size:"sm",onClick:N,children:"Open in System Viewer"})}),e.jsx(fr,{open:x,onClose:()=>d(!1),src:a,alt:n})]})},Wo=({filePath:t,size:n})=>{const o=Ee(t)||t;return Sn(o)==="image"&&Uo(o,n)?e.jsx(Vo,{filePath:t,fileName:o,size:n}):e.jsx(kn,{filePath:t,fileName:o,size:n})},Ho=[{keys:se("⌘ P","Ctrl+P"),label:"快速打开"},{keys:se("⌘ ⇧ F","Ctrl+Shift+F"),label:"在文件中搜索"},{keys:se("⌘ S","Ctrl+S"),label:"保存"},{keys:se("⌘ B","Ctrl+B"),label:"切换侧边栏"},{keys:se("⌘ G","Ctrl+G"),label:"跳转到行"},{keys:"Esc",label:"关闭编辑器"}],Xo=()=>e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-4 text-text-muted",children:[e.jsx(hr,{className:"size-12 opacity-30"}),e.jsx("p",{className:"text-sm",children:"从文件树中选择文件开始编辑"}),e.jsx("div",{className:"mt-2 grid grid-cols-2 gap-x-6 gap-y-1.5",children:Ho.map(t=>e.jsxs("div",{className:"flex items-center justify-between gap-4 text-xs",children:[e.jsx("span",{className:"text-text-muted",children:t.label}),e.jsx("kbd",{className:"rounded border border-border bg-surface-raised px-1.5 py-0.5 font-mono text-[10px] text-text-secondary",children:t.keys})]},t.keys))})]});class qo extends he.Component{state={hasError:!1,error:null};static getDerivedStateFromError(n){return{hasError:!0,error:n.message}}componentDidCatch(n,o){console.error(`[EditorErrorBoundary] ${this.props.filePath}:`,n,o.componentStack)}handleRetry=()=>{this.setState({hasError:!1,error:null}),this.props.onRetry?.()};render(){return this.state.hasError?e.jsxs("div",{role:"alert","aria-live":"polite",className:"flex h-full flex-col items-center justify-center gap-3 text-text-muted",children:[e.jsx(gt,{"aria-hidden":"true",className:"size-12 text-red-400 opacity-50"}),e.jsxs("p",{className:"max-w-md text-center text-sm text-text-secondary",children:["编辑器崩溃:",this.state.error??"未知错误"]}),e.jsx("button",{type:"button",onClick:this.handleRetry,className:"rounded border border-border px-3 py-1.5 text-xs text-text-secondary transition-colors hover:bg-surface-raised",children:"重试"})]}):e.jsx(e.Fragment,{children:this.props.children})}}const Yo=({error:t,onRetry:n,onClose:o})=>e.jsxs("div",{role:"alert","aria-live":"polite",className:"flex h-full flex-col items-center justify-center gap-3 text-text-muted",children:[e.jsx(gt,{"aria-hidden":"true",className:"size-12 text-yellow-500 opacity-50"}),e.jsx("p",{className:"max-w-md text-center text-sm text-text-secondary",children:t}),e.jsxs("div",{className:"flex gap-2",children:[n&&e.jsx(P,{variant:"outline",size:"sm",onClick:n,children:"重试"}),o&&e.jsx(P,{variant:"outline",size:"sm",onClick:o,children:"关闭标签页"})]})]});function Qo(t){return[...t].sort((n,o)=>n.isFile!==o.isFile?n.isFile?1:-1:n.name.localeCompare(o.name))}var pt=["Enter"," "],Zo=["ArrowDown","PageUp","Home"],Mn=["ArrowUp","PageDown","End"],Jo=[...Zo,...Mn],ea={ltr:[...pt,"ArrowRight"],rtl:[...pt,"ArrowLeft"]},ta={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Ve="Menu",[Ke,na,sa]=mr(Ve),[ye,Tn]=ln(Ve,[sa,dn,un]),rt=dn(),En=un(),[ra,Ne]=ye(Ve),[oa,We]=ye(Ve),Rn=t=>{const{__scopeMenu:n,open:o=!1,children:r,dir:a,onOpenChange:i,modal:u=!0}=t,f=rt(n),[l,c]=s.useState(null),x=s.useRef(!1),d=bt(i),m=pr(a);return s.useEffect(()=>{const y=()=>{x.current=!0,document.addEventListener("pointerdown",b,{capture:!0,once:!0}),document.addEventListener("pointermove",b,{capture:!0,once:!0})},b=()=>x.current=!1;return document.addEventListener("keydown",y,{capture:!0}),()=>{document.removeEventListener("keydown",y,{capture:!0}),document.removeEventListener("pointerdown",b,{capture:!0}),document.removeEventListener("pointermove",b,{capture:!0})}},[]),e.jsx(gr,{...f,children:e.jsx(ra,{scope:n,open:o,onOpenChange:d,content:l,onContentChange:c,children:e.jsx(oa,{scope:n,onClose:s.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:x,dir:m,modal:u,children:r})})})};Rn.displayName=Ve;var aa="MenuAnchor",Ct=s.forwardRef((t,n)=>{const{__scopeMenu:o,...r}=t,a=rt(o);return e.jsx(br,{...a,...r,ref:n})});Ct.displayName=aa;var jt="MenuPortal",[ia,In]=ye(jt,{forceMount:void 0}),Dn=t=>{const{__scopeMenu:n,forceMount:o,children:r,container:a}=t,i=Ne(jt,n);return e.jsx(ia,{scope:n,forceMount:o,children:e.jsx(st,{present:o||i.open,children:e.jsx(vr,{asChild:!0,container:a,children:r})})})};Dn.displayName=jt;var oe="MenuContent",[ca,yt]=ye(oe),Pn=s.forwardRef((t,n)=>{const o=In(oe,t.__scopeMenu),{forceMount:r=o.forceMount,...a}=t,i=Ne(oe,t.__scopeMenu),u=We(oe,t.__scopeMenu);return e.jsx(Ke.Provider,{scope:t.__scopeMenu,children:e.jsx(st,{present:r||i.open,children:e.jsx(Ke.Slot,{scope:t.__scopeMenu,children:u.modal?e.jsx(la,{...a,ref:n}):e.jsx(da,{...a,ref:n})})})})}),la=s.forwardRef((t,n)=>{const o=Ne(oe,t.__scopeMenu),r=s.useRef(null),a=Be(n,r);return s.useEffect(()=>{const i=r.current;if(i)return Cr(i)},[]),e.jsx(Nt,{...t,ref:a,trapFocus:o.open,disableOutsidePointerEvents:o.open,disableOutsideScroll:!0,onFocusOutside:$(t.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>o.onOpenChange(!1)})}),da=s.forwardRef((t,n)=>{const o=Ne(oe,t.__scopeMenu);return e.jsx(Nt,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>o.onOpenChange(!1)})}),ua=Sr("MenuContent.ScrollLock"),Nt=s.forwardRef((t,n)=>{const{__scopeMenu:o,loop:r=!1,trapFocus:a,onOpenAutoFocus:i,onCloseAutoFocus:u,disableOutsidePointerEvents:f,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:x,onFocusOutside:d,onInteractOutside:m,onDismiss:y,disableOutsideScroll:b,...v}=t,N=Ne(oe,o),C=We(oe,o),S=rt(o),R=En(o),O=na(o),[K,I]=s.useState(null),j=s.useRef(null),M=Be(n,j,N.onContentChange),_=s.useRef(0),T=s.useRef(""),L=s.useRef(0),B=s.useRef(null),ae=s.useRef("right"),ie=s.useRef(0),ue=b?wr:s.Fragment,D=b?{as:ua,allowPinchZoom:!0}:void 0,Q=p=>{const E=T.current+p,F=O().filter(V=>!V.disabled),W=document.activeElement,ce=F.find(V=>V.ref.current===W)?.textValue,te=F.map(V=>V.textValue),le=Na(te,E,ce),re=F.find(V=>V.textValue===le)?.ref.current;(function V(xe){T.current=xe,window.clearTimeout(_.current),xe!==""&&(_.current=window.setTimeout(()=>V(""),1e3))})(E),re&&setTimeout(()=>re.focus())};s.useEffect(()=>()=>window.clearTimeout(_.current),[]),Nr();const A=s.useCallback(p=>ae.current===B.current?.side&&Sa(p,B.current?.area),[]);return e.jsx(ca,{scope:o,searchRef:T,onItemEnter:s.useCallback(p=>{A(p)&&p.preventDefault()},[A]),onItemLeave:s.useCallback(p=>{A(p)||(j.current?.focus(),I(null))},[A]),onTriggerLeave:s.useCallback(p=>{A(p)&&p.preventDefault()},[A]),pointerGraceTimerRef:L,onPointerGraceIntentChange:s.useCallback(p=>{B.current=p},[]),children:e.jsx(ue,{...D,children:e.jsx(kr,{asChild:!0,trapped:a,onMountAutoFocus:$(i,p=>{p.preventDefault(),j.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:u,children:e.jsx(Mr,{asChild:!0,disableOutsidePointerEvents:f,onEscapeKeyDown:c,onPointerDownOutside:x,onFocusOutside:d,onInteractOutside:m,onDismiss:y,children:e.jsx(Tr,{asChild:!0,...R,dir:C.dir,orientation:"vertical",loop:r,currentTabStopId:K,onCurrentTabStopIdChange:I,onEntryFocus:$(l,p=>{C.isUsingKeyboardRef.current||p.preventDefault()}),preventScrollOnEntryFocus:!0,children:e.jsx(Er,{role:"menu","aria-orientation":"vertical","data-state":qn(N.open),"data-radix-menu-content":"",dir:C.dir,...S,...v,ref:M,style:{outline:"none",...v.style},onKeyDown:$(v.onKeyDown,p=>{const F=p.target.closest("[data-radix-menu-content]")===p.currentTarget,W=p.ctrlKey||p.altKey||p.metaKey,ce=p.key.length===1;F&&(p.key==="Tab"&&p.preventDefault(),!W&&ce&&Q(p.key));const te=j.current;if(p.target!==te||!Jo.includes(p.key))return;p.preventDefault();const re=O().filter(V=>!V.disabled).map(V=>V.ref.current);Mn.includes(p.key)&&re.reverse(),ja(re)}),onBlur:$(t.onBlur,p=>{p.currentTarget.contains(p.target)||(window.clearTimeout(_.current),T.current="")}),onPointerMove:$(t.onPointerMove,Ge(p=>{const E=p.target,F=ie.current!==p.clientX;if(p.currentTarget.contains(E)&&F){const W=p.clientX>ie.current?"right":"left";ae.current=W,ie.current=p.clientX}}))})})})})})})});Pn.displayName=oe;var xa="MenuGroup",wt=s.forwardRef((t,n)=>{const{__scopeMenu:o,...r}=t;return e.jsx(Ie.div,{role:"group",...r,ref:n})});wt.displayName=xa;var fa="MenuLabel",_n=s.forwardRef((t,n)=>{const{__scopeMenu:o,...r}=t;return e.jsx(Ie.div,{...r,ref:n})});_n.displayName=fa;var Je="MenuItem",Zt="menu.itemSelect",ot=s.forwardRef((t,n)=>{const{disabled:o=!1,onSelect:r,...a}=t,i=s.useRef(null),u=We(Je,t.__scopeMenu),f=yt(Je,t.__scopeMenu),l=Be(n,i),c=s.useRef(!1),x=()=>{const d=i.current;if(!o&&d){const m=new CustomEvent(Zt,{bubbles:!0,cancelable:!0});d.addEventListener(Zt,y=>r?.(y),{once:!0}),yr(d,m),m.defaultPrevented?c.current=!1:u.onClose()}};return e.jsx(Fn,{...a,ref:l,disabled:o,onClick:$(t.onClick,x),onPointerDown:d=>{t.onPointerDown?.(d),c.current=!0},onPointerUp:$(t.onPointerUp,d=>{c.current||d.currentTarget?.click()}),onKeyDown:$(t.onKeyDown,d=>{const m=f.searchRef.current!=="";o||m&&d.key===" "||pt.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});ot.displayName=Je;var Fn=s.forwardRef((t,n)=>{const{__scopeMenu:o,disabled:r=!1,textValue:a,...i}=t,u=yt(Je,o),f=En(o),l=s.useRef(null),c=Be(n,l),[x,d]=s.useState(!1),[m,y]=s.useState("");return s.useEffect(()=>{const b=l.current;b&&y((b.textContent??"").trim())},[i.children]),e.jsx(Ke.ItemSlot,{scope:o,disabled:r,textValue:a??m,children:e.jsx(jr,{asChild:!0,...f,focusable:!r,children:e.jsx(Ie.div,{role:"menuitem","data-highlighted":x?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...i,ref:c,onPointerMove:$(t.onPointerMove,Ge(b=>{r?u.onItemLeave(b):(u.onItemEnter(b),b.defaultPrevented||b.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:$(t.onPointerLeave,Ge(b=>u.onItemLeave(b))),onFocus:$(t.onFocus,()=>d(!0)),onBlur:$(t.onBlur,()=>d(!1))})})})}),ha="MenuCheckboxItem",An=s.forwardRef((t,n)=>{const{checked:o=!1,onCheckedChange:r,...a}=t;return e.jsx(Kn,{scope:t.__scopeMenu,checked:o,children:e.jsx(ot,{role:"menuitemcheckbox","aria-checked":et(o)?"mixed":o,...a,ref:n,"data-state":kt(o),onSelect:$(a.onSelect,()=>r?.(et(o)?!0:!o),{checkForDefaultPrevented:!1})})})});An.displayName=ha;var Ln="MenuRadioGroup",[ma,pa]=ye(Ln,{value:void 0,onValueChange:()=>{}}),On=s.forwardRef((t,n)=>{const{value:o,onValueChange:r,...a}=t,i=bt(r);return e.jsx(ma,{scope:t.__scopeMenu,value:o,onValueChange:i,children:e.jsx(wt,{...a,ref:n})})});On.displayName=Ln;var zn="MenuRadioItem",$n=s.forwardRef((t,n)=>{const{value:o,...r}=t,a=pa(zn,t.__scopeMenu),i=o===a.value;return e.jsx(Kn,{scope:t.__scopeMenu,checked:i,children:e.jsx(ot,{role:"menuitemradio","aria-checked":i,...r,ref:n,"data-state":kt(i),onSelect:$(r.onSelect,()=>a.onValueChange?.(o),{checkForDefaultPrevented:!1})})})});$n.displayName=zn;var St="MenuItemIndicator",[Kn,ga]=ye(St,{checked:!1}),Gn=s.forwardRef((t,n)=>{const{__scopeMenu:o,forceMount:r,...a}=t,i=ga(St,o);return e.jsx(st,{present:r||et(i.checked)||i.checked===!0,children:e.jsx(Ie.span,{...a,ref:n,"data-state":kt(i.checked)})})});Gn.displayName=St;var ba="MenuSeparator",Bn=s.forwardRef((t,n)=>{const{__scopeMenu:o,...r}=t;return e.jsx(Ie.div,{role:"separator","aria-orientation":"horizontal",...r,ref:n})});Bn.displayName=ba;var va="MenuArrow",Un=s.forwardRef((t,n)=>{const{__scopeMenu:o,...r}=t,a=rt(o);return e.jsx(Rr,{...a,...r,ref:n})});Un.displayName=va;var Ca="MenuSub",[Bi,Vn]=ye(Ca),Ae="MenuSubTrigger",Wn=s.forwardRef((t,n)=>{const o=Ne(Ae,t.__scopeMenu),r=We(Ae,t.__scopeMenu),a=Vn(Ae,t.__scopeMenu),i=yt(Ae,t.__scopeMenu),u=s.useRef(null),{pointerGraceTimerRef:f,onPointerGraceIntentChange:l}=i,c={__scopeMenu:t.__scopeMenu},x=s.useCallback(()=>{u.current&&window.clearTimeout(u.current),u.current=null},[]);return s.useEffect(()=>x,[x]),s.useEffect(()=>{const d=f.current;return()=>{window.clearTimeout(d),l(null)}},[f,l]),e.jsx(Ct,{asChild:!0,...c,children:e.jsx(Fn,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":a.contentId,"data-state":qn(o.open),...t,ref:Ir(n,a.onTriggerChange),onClick:d=>{t.onClick?.(d),!(t.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),o.open||o.onOpenChange(!0))},onPointerMove:$(t.onPointerMove,Ge(d=>{i.onItemEnter(d),!d.defaultPrevented&&!t.disabled&&!o.open&&!u.current&&(i.onPointerGraceIntentChange(null),u.current=window.setTimeout(()=>{o.onOpenChange(!0),x()},100))})),onPointerLeave:$(t.onPointerLeave,Ge(d=>{x();const m=o.content?.getBoundingClientRect();if(m){const y=o.content?.dataset.side,b=y==="right",v=b?-5:5,N=m[b?"left":"right"],C=m[b?"right":"left"];i.onPointerGraceIntentChange({area:[{x:d.clientX+v,y:d.clientY},{x:N,y:m.top},{x:C,y:m.top},{x:C,y:m.bottom},{x:N,y:m.bottom}],side:y}),window.clearTimeout(f.current),f.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(d),d.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:$(t.onKeyDown,d=>{const m=i.searchRef.current!=="";t.disabled||m&&d.key===" "||ea[r.dir].includes(d.key)&&(o.onOpenChange(!0),o.content?.focus(),d.preventDefault())})})})});Wn.displayName=Ae;var Hn="MenuSubContent",Xn=s.forwardRef((t,n)=>{const o=In(oe,t.__scopeMenu),{forceMount:r=o.forceMount,...a}=t,i=Ne(oe,t.__scopeMenu),u=We(oe,t.__scopeMenu),f=Vn(Hn,t.__scopeMenu),l=s.useRef(null),c=Be(n,l);return e.jsx(Ke.Provider,{scope:t.__scopeMenu,children:e.jsx(st,{present:r||i.open,children:e.jsx(Ke.Slot,{scope:t.__scopeMenu,children:e.jsx(Nt,{id:f.contentId,"aria-labelledby":f.triggerId,...a,ref:c,align:"start",side:u.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:x=>{u.isUsingKeyboardRef.current&&l.current?.focus(),x.preventDefault()},onCloseAutoFocus:x=>x.preventDefault(),onFocusOutside:$(t.onFocusOutside,x=>{x.target!==f.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:$(t.onEscapeKeyDown,x=>{u.onClose(),x.preventDefault()}),onKeyDown:$(t.onKeyDown,x=>{const d=x.currentTarget.contains(x.target),m=ta[u.dir].includes(x.key);d&&m&&(i.onOpenChange(!1),f.trigger?.focus(),x.preventDefault())})})})})})});Xn.displayName=Hn;function qn(t){return t?"open":"closed"}function et(t){return t==="indeterminate"}function kt(t){return et(t)?"indeterminate":t?"checked":"unchecked"}function ja(t){const n=document.activeElement;for(const o of t)if(o===n||(o.focus(),document.activeElement!==n))return}function ya(t,n){return t.map((o,r)=>t[(n+r)%t.length])}function Na(t,n,o){const a=n.length>1&&Array.from(n).every(c=>c===n[0])?n[0]:n,i=o?t.indexOf(o):-1;let u=ya(t,Math.max(i,0));a.length===1&&(u=u.filter(c=>c!==o));const l=u.find(c=>c.toLowerCase().startsWith(a.toLowerCase()));return l!==o?l:void 0}function wa(t,n){const{x:o,y:r}=t;let a=!1;for(let i=0,u=n.length-1;i<n.length;u=i++){const f=n[i],l=n[u],c=f.x,x=f.y,d=l.x,m=l.y;x>r!=m>r&&o<(d-c)*(r-x)/(m-x)+c&&(a=!a)}return a}function Sa(t,n){if(!n)return!1;const o={x:t.clientX,y:t.clientY};return wa(o,n)}function Ge(t){return n=>n.pointerType==="mouse"?t(n):void 0}var ka=Rn,Ma=Ct,Ta=Dn,Ea=Pn,Ra=wt,Ia=_n,Da=ot,Pa=An,_a=On,Fa=$n,Aa=Gn,La=Bn,Oa=Un,za=Wn,$a=Xn,Mt="ContextMenu",[Ka]=ln(Mt,[Tn]),Y=Tn(),[Ga,Yn]=Ka(Mt),Qn=t=>{const{__scopeContextMenu:n,children:o,onOpenChange:r,dir:a,modal:i=!0}=t,[u,f]=s.useState(!1),l=Y(n),c=bt(r),x=s.useCallback(d=>{f(d),c(d)},[c]);return e.jsx(Ga,{scope:n,open:u,onOpenChange:x,modal:i,children:e.jsx(ka,{...l,dir:a,open:u,onOpenChange:x,modal:i,children:o})})};Qn.displayName=Mt;var Zn="ContextMenuTrigger",Jn=s.forwardRef((t,n)=>{const{__scopeContextMenu:o,disabled:r=!1,...a}=t,i=Yn(Zn,o),u=Y(o),f=s.useRef({x:0,y:0}),l=s.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...f.current})}),c=s.useRef(0),x=s.useCallback(()=>window.clearTimeout(c.current),[]),d=m=>{f.current={x:m.clientX,y:m.clientY},i.onOpenChange(!0)};return s.useEffect(()=>x,[x]),s.useEffect(()=>void(r&&x()),[r,x]),e.jsxs(e.Fragment,{children:[e.jsx(Ma,{...u,virtualRef:l}),e.jsx(Ie.span,{"data-state":i.open?"open":"closed","data-disabled":r?"":void 0,...a,ref:n,style:{WebkitTouchCallout:"none",...t.style},onContextMenu:r?t.onContextMenu:$(t.onContextMenu,m=>{x(),d(m),m.preventDefault()}),onPointerDown:r?t.onPointerDown:$(t.onPointerDown,qe(m=>{x(),c.current=window.setTimeout(()=>d(m),700)})),onPointerMove:r?t.onPointerMove:$(t.onPointerMove,qe(x)),onPointerCancel:r?t.onPointerCancel:$(t.onPointerCancel,qe(x)),onPointerUp:r?t.onPointerUp:$(t.onPointerUp,qe(x))})]})});Jn.displayName=Zn;var Ba="ContextMenuPortal",es=t=>{const{__scopeContextMenu:n,...o}=t,r=Y(n);return e.jsx(Ta,{...r,...o})};es.displayName=Ba;var ts="ContextMenuContent",ns=s.forwardRef((t,n)=>{const{__scopeContextMenu:o,...r}=t,a=Yn(ts,o),i=Y(o),u=s.useRef(!1);return e.jsx(Ea,{...i,...r,ref:n,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:f=>{t.onCloseAutoFocus?.(f),!f.defaultPrevented&&u.current&&f.preventDefault(),u.current=!1},onInteractOutside:f=>{t.onInteractOutside?.(f),!f.defaultPrevented&&!a.modal&&(u.current=!0)},style:{...t.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});ns.displayName=ts;var Ua="ContextMenuGroup",Va=s.forwardRef((t,n)=>{const{__scopeContextMenu:o,...r}=t,a=Y(o);return e.jsx(Ra,{...a,...r,ref:n})});Va.displayName=Ua;var Wa="ContextMenuLabel",Ha=s.forwardRef((t,n)=>{const{__scopeContextMenu:o,...r}=t,a=Y(o);return e.jsx(Ia,{...a,...r,ref:n})});Ha.displayName=Wa;var Xa="ContextMenuItem",ss=s.forwardRef((t,n)=>{const{__scopeContextMenu:o,...r}=t,a=Y(o);return e.jsx(Da,{...a,...r,ref:n})});ss.displayName=Xa;var qa="ContextMenuCheckboxItem",Ya=s.forwardRef((t,n)=>{const{__scopeContextMenu:o,...r}=t,a=Y(o);return e.jsx(Pa,{...a,...r,ref:n})});Ya.displayName=qa;var Qa="ContextMenuRadioGroup",Za=s.forwardRef((t,n)=>{const{__scopeContextMenu:o,...r}=t,a=Y(o);return e.jsx(_a,{...a,...r,ref:n})});Za.displayName=Qa;var Ja="ContextMenuRadioItem",ei=s.forwardRef((t,n)=>{const{__scopeContextMenu:o,...r}=t,a=Y(o);return e.jsx(Fa,{...a,...r,ref:n})});ei.displayName=Ja;var ti="ContextMenuItemIndicator",ni=s.forwardRef((t,n)=>{const{__scopeContextMenu:o,...r}=t,a=Y(o);return e.jsx(Aa,{...a,...r,ref:n})});ni.displayName=ti;var si="ContextMenuSeparator",rs=s.forwardRef((t,n)=>{const{__scopeContextMenu:o,...r}=t,a=Y(o);return e.jsx(La,{...a,...r,ref:n})});rs.displayName=si;var ri="ContextMenuArrow",oi=s.forwardRef((t,n)=>{const{__scopeContextMenu:o,...r}=t,a=Y(o);return e.jsx(Oa,{...a,...r,ref:n})});oi.displayName=ri;var ai="ContextMenuSubTrigger",ii=s.forwardRef((t,n)=>{const{__scopeContextMenu:o,...r}=t,a=Y(o);return e.jsx(za,{...a,...r,ref:n})});ii.displayName=ai;var ci="ContextMenuSubContent",li=s.forwardRef((t,n)=>{const{__scopeContextMenu:o,...r}=t,a=Y(o);return e.jsx($a,{...a,...r,ref:n,style:{...t.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});li.displayName=ci;function qe(t){return n=>n.pointerType!=="mouse"?t(n):void 0}var os=Qn,as=Jn,is=es,cs=ns,ee=ss,Te=rs;const di=({children:t,projectPath:n,onNewFile:o,onNewFolder:r,onDelete:a,onRename:i,onCreateTask:u,onSendMessage:f})=>{const[l,c]=s.useState(null),x=s.useRef(null),d=s.useCallback(y=>{let b=y.target;for(;b&&b!==y.currentTarget;){const v=b.getAttribute("data-editor-path");if(v){const N=b.getAttribute("data-editor-type"),C=b.getAttribute("data-editor-sensitive");c({path:v,isDir:N==="directory",isSensitive:C==="true"});return}b=b.parentElement}c(null)},[]),m=l?l.isDir?l.path:l.path.substring(0,Ze(l.path)):null;return e.jsxs(os,{children:[e.jsx(as,{asChild:!0,children:e.jsx("div",{ref:x,onContextMenu:d,className:"h-full",children:t})}),e.jsx(is,{children:e.jsxs(cs,{className:"z-50 min-w-[180px] rounded-md border border-border-emphasis bg-surface-overlay p-1 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:[m&&e.jsxs(e.Fragment,{children:[e.jsxs(ee,{className:"flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-xs text-text outline-none hover:bg-surface-raised focus:bg-surface-raised",onSelect:()=>o(m),children:[e.jsx(Cn,{className:"size-3.5 text-text-muted"}),"New File"]}),e.jsxs(ee,{className:"flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-xs text-text outline-none hover:bg-surface-raised focus:bg-surface-raised",onSelect:()=>r(m),children:[e.jsx(jn,{className:"size-3.5 text-text-muted"}),"New Folder"]}),e.jsx(Te,{className:"my-1 h-px bg-border"})]}),l&&e.jsxs(e.Fragment,{children:[e.jsxs(ee,{className:"flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-xs text-text outline-none hover:bg-surface-raised focus:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-50",disabled:l.isSensitive,onSelect:()=>i(l.path),children:[e.jsx(Dr,{className:"size-3.5 text-text-muted"}),"Rename"]}),e.jsxs(ee,{className:"flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-xs text-red-400 outline-none hover:bg-surface-raised focus:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-50",disabled:l.isSensitive,onSelect:()=>a(l.path),children:[e.jsx(Pr,{className:"size-3.5"}),"Delete"]}),e.jsx(Te,{className:"my-1 h-px bg-border"})]}),l&&e.jsxs(e.Fragment,{children:[e.jsxs(ee,{className:"flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-xs text-text outline-none hover:bg-surface-raised focus:bg-surface-raised",onSelect:()=>void navigator.clipboard.writeText(l.path),children:[e.jsx(Ht,{className:"size-3.5 text-text-muted"}),"Copy Path"]}),n&&l.path.startsWith(n)&&e.jsxs(ee,{className:"flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-xs text-text outline-none hover:bg-surface-raised focus:bg-surface-raised",onSelect:()=>{const y=l.path.slice(n.length+1);navigator.clipboard.writeText(y)},children:[e.jsx(Ht,{className:"size-3.5 text-text-muted"}),"Copy Relative Path"]}),e.jsx(Te,{className:"my-1 h-px bg-border"}),e.jsxs(ee,{className:"flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-xs text-text outline-none hover:bg-surface-raised focus:bg-surface-raised",onSelect:()=>{je.showInFolder(l.path)},children:[e.jsx(vt,{className:"size-3.5 text-text-muted"}),"Reveal in Finder"]})]}),l&&!l.isDir&&(u||f)&&e.jsxs(e.Fragment,{children:[e.jsx(Te,{className:"my-1 h-px bg-border"}),f&&e.jsxs(ee,{className:"flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-xs text-text outline-none hover:bg-surface-raised focus:bg-surface-raised",onSelect:()=>f(l.path),children:[e.jsx(xn,{className:"size-3.5 text-text-muted"}),"Write Teammate"]}),u&&e.jsxs(ee,{className:"flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-xs text-text outline-none hover:bg-surface-raised focus:bg-surface-raised",onSelect:()=>u(l.path),children:[e.jsx(yn,{className:"size-3.5 text-text-muted"}),"Create Task"]})]})]})})]})},ui={modified:{letter:"M",color:"text-orange-400"},untracked:{letter:"U",color:"text-green-400"},staged:{letter:"A",color:"text-green-400"},deleted:{letter:"D",color:"text-red-400"},conflict:{letter:"C",color:"text-red-400 font-bold"},renamed:{letter:"R",color:"text-cyan-400"}},xi=he.memo(function({status:n}){const o=ui[n];return e.jsx("span",{className:`ml-auto shrink-0 text-[10px] leading-none ${o.color}`,title:n,children:o.letter})}),fi=/[\x00-\x1f/\\:*?"<>|]/;function hi(t){const n=t.trim();return n.length===0?"Name cannot be empty":n==="."||n===".."?"Invalid name":fi.test(n)?"Name contains invalid characters":n.length>255?"Name is too long":null}const mi=({type:t,parentDir:n,onSubmit:o,onCancel:r})=>{const[a,i]=s.useState(""),[u,f]=s.useState(null),l=s.useRef(null),c=s.useRef(null);s.useEffect(()=>{const b=setTimeout(()=>{l.current?.focus()},100);return()=>clearTimeout(b)},[]),s.useEffect(()=>{const b=N=>{c.current&&!c.current.contains(N.target)&&r()},v=setTimeout(()=>{document.addEventListener("pointerdown",b,!0)},150);return()=>{clearTimeout(v),document.removeEventListener("pointerdown",b,!0)}},[r]);const x=s.useCallback(()=>{const b=a.trim(),v=hi(b);if(v){f(v);return}o(b)},[a,o]),d=s.useCallback(b=>{b.key==="Enter"?(b.preventDefault(),x()):b.key==="Escape"&&(b.preventDefault(),r()),b.stopPropagation()},[x,r]),m=s.useCallback(b=>{i(b.target.value),f(null)},[]),y=t==="file"?Cn:jn;return e.jsxs("div",{ref:c,className:"flex flex-col px-2 py-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(y,{className:"size-3.5 shrink-0 text-text-muted"}),e.jsx("input",{ref:l,type:"text",value:a,onChange:m,onKeyDown:d,onBlur:()=>requestAnimationFrame(()=>l.current?.focus()),placeholder:t==="file"?"文件名...":"文件夹名...",className:"min-w-0 flex-1 rounded border border-border-emphasis bg-surface px-1.5 py-0.5 text-xs text-text outline-none focus:border-blue-500","aria-label":t==="file"?"新文件名":"新文件夹名"})]}),u&&e.jsx("span",{className:"mt-0.5 pl-5 text-[10px] text-red-400",children:u})]})},pi=28,ls=12,ds=12,gi=500;let ht=0;const bi=({selectedFilePath:t,onFileSelect:n,onCreateTask:o,onSendMessage:r})=>{ht++,ht%5===0&&console.debug(`[perf] EditorFileTree render #${ht}`);const{fileTree:a,expandedDirs:i,loading:u,error:f,gitFiles:l,projectPath:c}=w(Re(g=>({fileTree:g.editorFileTree,expandedDirs:g.editorExpandedDirs,loading:g.editorFileTreeLoading,error:g.editorFileTreeError,gitFiles:g.editorGitFiles,projectPath:g.editorProjectPath}))),x=w(g=>g.expandDirectory),d=w(g=>g.collapseDirectory),m=w(g=>g.createFileInTree),y=w(g=>g.createDirInTree),b=w(g=>g.deleteFileFromTree),v=w(g=>g.moveFileInTree),N=w(g=>g.renameFileInTree),C=w(g=>g.openFile),[S,R]=s.useState(null),[O,K]=s.useState(null),[I,j]=s.useState(null),[M,_]=s.useState(null),[T,L]=s.useState(null),B=s.useRef(null),ae=s.useRef(null),[ie,ue]=s.useState(!1);s.useEffect(()=>{const g=requestAnimationFrame(()=>{requestAnimationFrame(()=>ue(!0))});return()=>cancelAnimationFrame(g)},[]),s.useEffect(()=>()=>{B.current&&clearTimeout(B.current)},[]);const D=fn(hn(bn,{activationConstraint:{distance:5}})),Q=s.useMemo(()=>{if(!a)return[];const g=performance.now(),k=Qo(fs(a)),z=performance.now()-g;return z>2&&console.debug(`[perf] treeNodes: ${z.toFixed(1)}ms, nodes=${k.length}`),k},[a]),A=s.useMemo(()=>{const g=performance.now(),k=[];hs(Q,i,k,0);const z=performance.now()-g;return z>2&&console.debug(`[perf] flatItems: ${z.toFixed(1)}ms, items=${k.length}`),k},[Q,i]),p=s.useMemo(()=>{const g=new Map;for(const k of A)g.set(k.node.fullPath,k);return g},[A]),E=s.useMemo(()=>{if(!S)return null;const{parentDir:g}=S,k=A.findIndex(z=>z.node.fullPath===g);return k===-1?{index:0,depth:0}:{index:k+1,depth:A[k].depth+1}},[S,A]),F=_r({count:A.length+(E?1:0),getScrollElement:()=>ae.current,estimateSize:()=>pi,overscan:ie?M?20:10:3});s.useEffect(()=>{if(!t)return;const g=A.findIndex(k=>k.node.fullPath===t);g>=0&&F.scrollToIndex(g,{align:"center"})},[t,A,F]);const W=s.useMemo(()=>{const g=performance.now(),k=new Map;if(!l?.length||!c)return k;for(const U of l){const ke=Fr(c,...Ar(U.path));k.set(ke,U.status)}const z=performance.now()-g;return z>2&&console.debug(`[perf] gitStatusMap: ${z.toFixed(1)}ms, files=${l.length}`),k},[l,c]),ce=t,te=s.useCallback(g=>{g.data&&(g.data.isSensitive||(g.isFile?n(g.data.path):i[g.fullPath]?d(g.fullPath):x(g.fullPath)))},[n,i,x,d]),le=s.useCallback(g=>{g!==c&&!i[g]&&x(g),R({parentDir:g,type:"file"})},[c,i,x]),re=s.useCallback(g=>{g!==c&&!i[g]&&x(g),R({parentDir:g,type:"directory"})},[c,i,x]),V=s.useCallback(g=>{j(g)},[]),xe=s.useCallback(async()=>{I&&(await b(I),j(null))},[I,b]),Z=s.useCallback(()=>{j(null)},[]),fe=s.useCallback(g=>{K(g)},[]),we=s.useCallback(async g=>{O&&(await N(O,g),K(null))},[O,N]),ge=s.useCallback(()=>{K(null)},[]),be=s.useCallback(async g=>{if(S){if(S.type==="file"){const k=await m(S.parentDir,g);k&&C(k)}else await y(S.parentDir,g);R(null)}},[S,m,y,C]),Se=s.useCallback(()=>{R(null)},[]),J=s.useCallback(()=>{B.current&&(clearTimeout(B.current),B.current=null)},[]),He=s.useCallback(g=>{const k=String(g.active.id),z=p.get(k);z&&_(z)},[p]),ve=s.useCallback(g=>{const{over:k}=g;if(!k||!M){L(null),J();return}const z=String(k.id);let U=null;if(z==="root-drop-zone")U=c;else if(z.startsWith("drop:"))U=z.slice(5);else{const ke=p.get(z);if(ke){const De=ke.node.fullPath;U=De.substring(0,Ze(De))}}U!==T&&(L(U),J(),U&&U!==c&&!i[U]&&(B.current=setTimeout(()=>{x(U)},gi)))},[M,T,c,p,i,x,J]),Xe=s.useCallback(g=>{J();const k=M?.node.fullPath;if(!k||!T||!g.over){_(null),L(null);return}const z=T;if(k.substring(0,Ze(k))===z){_(null),L(null);return}if(mn(k,z)){_(null),L(null);return}if(M?.node.data?.isSensitive){_(null),L(null);return}v(k,z),_(null),L(null)},[M,T,v,J]),at=s.useCallback(()=>{J(),_(null),L(null)},[J]);return f?e.jsxs("div",{className:"p-3 text-xs text-red-400",children:["文件加载失败:",f]}):u&&!a?e.jsx("div",{className:"p-3 text-xs text-text-muted",children:"正在加载文件..."}):Q.length===0?e.jsx("div",{className:"p-3 text-xs text-text-muted",children:"未找到文件"}):e.jsxs(di,{projectPath:c,onNewFile:le,onNewFolder:re,onDelete:V,onRename:fe,onCreateTask:o,onSendMessage:r,children:[e.jsxs(pn,{sensors:D,onDragStart:He,onDragOver:ve,onDragEnd:Xe,onDragCancel:at,autoScroll:{threshold:{x:0,y:.15}},children:[e.jsxs(us,{ref:ae,projectPath:c,isDropTarget:T===c,children:[e.jsx("div",{style:{height:`${F.getTotalSize()}px`,width:"100%",position:"relative"},children:F.getVirtualItems().map(g=>{const{index:k}=g;if(k===E?.index)return e.jsx("div",{style:{position:"absolute",top:`${g.start}px`,left:0,width:"100%",height:`${g.size}px`,paddingLeft:`${Math.min(E.depth,ds)*ls}px`},children:e.jsx(mi,{type:S.type,parentDir:S.parentDir,onSubmit:be,onCancel:Se})},"__new-item-input__");const z=E&&k>E.index?k-1:k,U=A[z];return e.jsx("div",{style:{position:"absolute",top:`${g.start}px`,left:0,width:"100%",height:`${g.size}px`},children:e.jsx(xs,{item:U,activeNodePath:ce,gitStatus:W.get(U.node.fullPath),dropTargetPath:T,isDragActive:!!M,onClick:te,isRenaming:O===U.node.fullPath,onRenameSubmit:we,onRenameCancel:ge})},U.node.fullPath)})}),M&&e.jsx("div",{className:"h-16 w-full shrink-0","aria-label":"拖到此处可移到项目根目录"})]}),e.jsx(gn,{dropAnimation:null,children:M&&e.jsx(vi,{item:M})})]}),e.jsx(Le,{open:!!I,onOpenChange:g=>!g&&Z(),children:e.jsxs(Oe,{className:"w-96 max-w-96",children:[e.jsxs(ze,{children:[e.jsx($e,{className:"text-sm",children:"移到废纸篓"}),e.jsxs(Ye,{children:["将 “",I?Ee(I):"","” 移到废纸篓?"]})]}),e.jsxs(Qe,{children:[e.jsx(P,{variant:"ghost",size:"sm",onClick:Z,children:"取消"}),e.jsx(P,{variant:"destructive",size:"sm",onClick:()=>void xe(),children:"移到废纸篓"})]})]})})]})},us=he.forwardRef(({projectPath:t,isDropTarget:n,children:o},r)=>{const{setNodeRef:a}=vn({id:"root-drop-zone",data:{isRoot:!0,path:t}}),i=s.useCallback(u=>{a(u),typeof r=="function"?r(u):r&&(r.current=u)},[r,a]);return e.jsx("div",{ref:i,className:`scrollbar-thin h-full overflow-y-auto transition-colors ${n?"bg-blue-400/5 ring-1 ring-inset ring-blue-400/30":""}`,role:"tree",children:o})});us.displayName="RootDropZone";const xs=he.memo(({item:t,activeNodePath:n,gitStatus:o,dropTargetPath:r,isDragActive:a,onClick:i,isRenaming:u,onRenameSubmit:f,onRenameCancel:l})=>{const{node:c,depth:x,isExpanded:d}=t,m=n===c.fullPath,y=Math.min(x,ds),b=c.data?.isSensitive,{attributes:v,listeners:N,setNodeRef:C,isDragging:S}=Lr({id:c.fullPath,data:{node:c,depth:x},disabled:!!b}),{setNodeRef:R}=vn({id:"drop:"+c.fullPath,data:{node:c},disabled:c.isFile}),O=s.useCallback(L=>{C(L),c.isFile||R(L)},[C,R,c.isFile]),K=!c.isFile&&r===c.fullPath,I=r!=null&&r!==c.fullPath&&mn(r,c.fullPath),j={};c.data&&(j["data-editor-path"]=c.data.path,j["data-editor-type"]=c.data.type,c.data.isSensitive&&(j["data-editor-sensitive"]="true"));const M=()=>{a||i(c)},_=L=>{(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),M())};let T;return c.data?.isSensitive?T=e.jsx(Or,{className:"size-3.5 shrink-0 text-yellow-500"}):c.isFile?T=e.jsx(Ue,{fileName:c.name,className:"size-3.5"}):d?T=e.jsx(vt,{className:"size-3.5 shrink-0 text-text-muted"}):T=e.jsx(zr,{className:"size-3.5 shrink-0 text-text-muted"}),e.jsxs("div",{ref:O,...v,...N,role:"treeitem","aria-selected":c.isFile?m:void 0,"aria-expanded":c.isFile?void 0:d,className:`flex h-full cursor-pointer select-none items-center gap-1 truncate px-2 text-xs transition-colors hover:bg-surface-raised ${m?"bg-surface-raised text-text":"text-text-secondary"} ${S?"opacity-30":""} ${K?"rounded bg-blue-400/10 ring-2 ring-blue-400/50":""} ${I&&!K?"border-l-2 border-l-blue-400/40 bg-blue-400/5":""}`,style:{paddingLeft:`${y*ls+8}px`},onClick:M,onKeyDown:_,tabIndex:0,title:c.data?.path??c.fullPath,...j,children:[!c.isFile&&(d?e.jsx(sn,{className:"size-3 shrink-0 text-text-muted"}):e.jsx(rn,{className:"size-3 shrink-0 text-text-muted"})),T,u?e.jsx(Ci,{initialName:c.name,onSubmit:f,onCancel:l}):e.jsx("span",{className:"truncate",children:c.name}),!u&&o&&e.jsx(xi,{status:o})]})});xs.displayName="DraggableTreeItem";const vi=({item:t})=>{const{node:n}=t;let o;return n.isFile?o=e.jsx(Ue,{fileName:n.name,className:"size-3.5"}):o=e.jsx(vt,{className:"size-3.5 text-text-muted"}),e.jsxs("div",{className:"flex items-center gap-1.5 rounded border border-border-emphasis bg-surface-overlay px-3 py-1 text-xs text-text shadow-lg",children:[o,e.jsx("span",{className:"truncate",children:n.name})]})},Ci=({initialName:t,onSubmit:n,onCancel:o})=>{const[r,a]=s.useState(t),i=s.useRef(!1),u=s.useRef(null);s.useEffect(()=>{const l=setTimeout(()=>{const c=u.current;if(!c)return;c.focus();const x=t.lastIndexOf(".");x>0?c.setSelectionRange(0,x):c.select()},100);return()=>clearTimeout(l)},[t]),s.useEffect(()=>{const l=x=>{u.current&&!u.current.contains(x.target)&&f()},c=setTimeout(()=>{document.addEventListener("pointerdown",l,!0)},150);return()=>{clearTimeout(c),document.removeEventListener("pointerdown",l,!0)}},[]);const f=()=>{if(i.current)return;i.current=!0;const l=u.current?.value.trim()??"";l&&l!==t?n(l):o()};return e.jsx("input",{ref:u,value:r,onChange:l=>a(l.target.value),onKeyDown:l=>{l.key==="Enter"?(l.preventDefault(),f()):l.key==="Escape"&&(l.preventDefault(),o()),l.stopPropagation()},onBlur:()=>requestAnimationFrame(()=>u.current?.focus()),onClick:l=>l.stopPropagation(),className:"min-w-0 flex-1 rounded border border-blue-400/50 bg-surface px-1 py-0 text-xs text-text outline-none focus:ring-1 focus:ring-blue-400/50"})};function fs(t){return Array.isArray(t)?t.flatMap(n=>{if(!n||typeof n!="object")return[];const o=n;if(typeof o.name!="string"||typeof o.path!="string"||o.type!=="file"&&o.type!=="directory")return[];const r={...o,children:Array.isArray(o.children)?o.children:void 0};return[{name:r.name,fullPath:r.path,isFile:r.type==="file",data:r,children:fs(r.children)}]}):[]}function hs(t,n,o,r){for(const a of t){const i=!a.isFile&&n[a.fullPath]===!0;o.push({node:a,depth:r,isExpanded:i}),i&&a.children.length>0&&hs(a.children,n,o,r+1)}}const Jt=8,en=68,ji=32,yi=({info:t,containerRect:n,onSendMessage:o,onCreateTask:r})=>{if(!t.text.trim())return null;const a=t.screenRect.top-n.top,i=t.screenRect.right-n.left+Jt,u=t.screenRect.top-n.top;if(t.screenRect.bottom-n.top<0||u>n.height)return null;const l=Math.max(0,Math.min(a,n.height-ji)),c=i+en>n.width?t.screenRect.right-n.left-en-Jt:i;return e.jsxs("div",{className:"pointer-events-auto absolute z-20 flex items-center gap-0.5 rounded-md border border-border-emphasis bg-surface-overlay p-0.5 shadow-lg animate-in fade-in-0 zoom-in-95",style:{top:l,left:Math.max(0,c)},children:[e.jsx(tn,{icon:e.jsx(xn,{className:"size-3.5"}),label:"Write Teammate",onClick:o}),e.jsx(tn,{icon:e.jsx(yn,{className:"size-3.5"}),label:"Create Task",onClick:r})]})},tn=({icon:t,label:n,onClick:o})=>e.jsxs(H,{children:[e.jsx(X,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon",tabIndex:-1,"aria-label":n,onClick:o,onMouseDown:r=>r.preventDefault(),className:"size-7 p-1.5 text-text-secondary",children:t})}),e.jsx(q,{side:"top",sideOffset:6,children:n})]}),Ni=[{title:"文件操作",shortcuts:[{mac:"⌘ P",other:"Ctrl+P",description:"快速打开"},{mac:"⌘ S",other:"Ctrl+S",description:"保存"},{mac:"⌘ ⇧ S",other:"Ctrl+Shift+S",description:"全部保存"},{mac:"⌘ W",other:"Ctrl+W",description:"关闭标签页"}]},{title:"搜索",shortcuts:[{mac:"⌘ F",other:"Ctrl+F",description:"在文件中查找"},{mac:"⌘ ⇧ F",other:"Ctrl+Shift+F",description:"在文件中搜索"},{mac:"⌘ G",other:"Ctrl+G",description:"跳转到行"}]},{title:"导航",shortcuts:[{mac:"⌘ ⇧ ]",other:"Ctrl+Shift+]",description:"下一个标签页"},{mac:"⌘ ⇧ [",other:"Ctrl+Shift+[",description:"上一个标签页"},{mac:"⌃ Tab",other:"Ctrl+Tab",description:"循环切换标签页"},{mac:"⌘ B",other:"Ctrl+B",description:"切换侧边栏"}]},{title:"编辑",shortcuts:[{mac:"⌘ Z",other:"Ctrl+Z",description:"撤销"},{mac:"⌘ ⇧ Z",other:"Ctrl+Y",description:"重做"},{mac:"⌘ D",other:"Ctrl+D",description:"选择下一个匹配项"},{mac:"⌘ /",other:"Ctrl+/",description:"切换注释"}]},{title:"Markdown",shortcuts:[{mac:"⌘ ⇧ M",other:"Ctrl+Shift+M",description:"拆分预览"},{mac:"⌘ ⇧ V",other:"Ctrl+Shift+V",description:"完整预览"}]},{title:"通用",shortcuts:[{mac:"Esc",other:"Esc",description:"关闭编辑器"}]}],wi=({onClose:t})=>{const n=s.useMemo(()=>Ni.map(o=>({...o,shortcuts:o.shortcuts.map(r=>({keys:Nn?r.mac:r.other,description:r.description}))})),[]);return e.jsx(Le,{open:!0,onOpenChange:o=>!o&&t(),children:e.jsxs(Oe,{className:"w-[480px] max-w-[480px]",children:[e.jsx(ze,{children:e.jsx($e,{className:"text-sm",children:"快捷键"})}),e.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-4",children:n.map(o=>e.jsxs("div",{children:[e.jsx("h3",{className:"mb-1.5 text-xs font-medium text-text-secondary",children:o.title}),e.jsx("div",{className:"space-y-1",children:o.shortcuts.map(r=>e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-text-muted",children:r.description}),e.jsx("kbd",{className:"rounded border border-border bg-surface-raised px-1.5 py-0.5 font-mono text-[10px] text-text-secondary",children:r.keys})]},r.keys))})]},o.title))})]})})},Si=he.memo(function({line:n,col:o,language:r}){const{gitBranch:a,isGitRepo:i,watcherEnabled:u}=w(Re(l=>({gitBranch:l.editorGitBranch,isGitRepo:l.editorIsGitRepo,watcherEnabled:l.editorWatcherEnabled}))),f=w(l=>l.toggleWatcher);return e.jsxs("div",{className:"flex h-6 shrink-0 items-center justify-between border-t border-border bg-surface-sidebar px-3 text-[11px] text-text-muted",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{children:["Ln ",n,", Col ",o]}),i&&a&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx($r,{className:"size-3"}),a]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(H,{children:[e.jsx(X,{asChild:!0,children:e.jsx("button",{type:"button",onClick:()=>void f(!u),className:`rounded px-1.5 py-0.5 text-[10px] font-medium transition-colors ${u?"bg-green-500/15 text-green-400 hover:bg-green-500/20":"text-text-muted hover:bg-surface-raised hover:text-text-secondary"}`,"aria-label":u?"Disable file watcher":"Enable file watcher","aria-pressed":u,children:u?"watching":"watch"})}),e.jsx(q,{side:"top",children:u?"Disable external change watcher":"Watch for external changes"})]}),e.jsx("span",{children:r}),e.jsx("span",{children:"UTF-8"}),e.jsx("span",{children:"Spaces: 2"})]})]})}),ki=({children:t,tabId:n,tabIndex:o,totalTabs:r,onClose:a,onCloseOthers:i,onCloseToLeft:u,onCloseToRight:f,onCloseAll:l})=>{const c=o>0,x=o<r-1,d=r>1;return e.jsxs(os,{children:[e.jsx(as,{asChild:!0,children:e.jsx("div",{className:"flex h-full",children:t})}),e.jsx(is,{children:e.jsxs(cs,{className:"z-50 min-w-[180px] rounded-md border border-border-emphasis bg-surface-overlay p-1 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:[e.jsx(ee,{className:"flex cursor-pointer items-center rounded px-2 py-1.5 text-xs text-text outline-none hover:bg-surface-raised focus:bg-surface-raised",onSelect:()=>a(n),children:"Close"}),e.jsx(ee,{className:"flex cursor-pointer items-center rounded px-2 py-1.5 text-xs text-text outline-none hover:bg-surface-raised focus:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-40",disabled:!d,onSelect:()=>i(n),children:"Close Others"}),e.jsx(Te,{className:"my-1 h-px bg-border"}),e.jsx(ee,{className:"flex cursor-pointer items-center rounded px-2 py-1.5 text-xs text-text outline-none hover:bg-surface-raised focus:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-40",disabled:!c,onSelect:()=>u(n),children:"Close Tabs to the Left"}),e.jsx(ee,{className:"flex cursor-pointer items-center rounded px-2 py-1.5 text-xs text-text outline-none hover:bg-surface-raised focus:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-40",disabled:!x,onSelect:()=>f(n),children:"Close Tabs to the Right"}),e.jsx(Te,{className:"my-1 h-px bg-border"}),e.jsx(ee,{className:"flex cursor-pointer items-center rounded px-2 py-1.5 text-xs text-text outline-none hover:bg-surface-raised focus:bg-surface-raised",onSelect:l,children:"Close All"})]})})]})},Mi=({onRequestCloseTab:t})=>{const{tabs:n,activeTabId:o,modifiedFiles:r}=w(Re(C=>({tabs:C.editorOpenTabs,activeTabId:C.editorActiveTabId,modifiedFiles:C.editorModifiedFiles}))),a=w(C=>C.setActiveEditorTab),i=w(C=>C.reorderEditorTabs),u=w(C=>C.closeOtherEditorTabs),f=w(C=>C.closeEditorTabsToLeft),l=w(C=>C.closeEditorTabsToRight),c=w(C=>C.closeAllEditorTabs),[x,d]=s.useState(null),m=s.useMemo(()=>n.map(C=>C.id),[n]),y=fn(hn(bn,{activationConstraint:{distance:5}})),b=s.useCallback(C=>{const S=n.find(R=>R.id===C.active.id);d(S??null)},[n]),v=s.useCallback(C=>{d(null);const{active:S,over:R}=C;R&&S.id!==R.id&&i(String(S.id),String(R.id))},[i]),N=s.useCallback(()=>{d(null)},[]);return n.length===0?null:e.jsxs(pn,{sensors:y,collisionDetection:Kr,onDragStart:b,onDragEnd:v,onDragCancel:N,children:[e.jsx("div",{className:"flex h-8 shrink-0 items-center overflow-x-auto border-b border-border bg-surface-sidebar",role:"tablist",children:e.jsx(Gr,{items:m,strategy:Br,children:n.map((C,S)=>e.jsx(Ti,{tab:C,tabIndex:S,totalTabs:n.length,isActive:C.id===o,isModified:!!r[C.filePath],onActivate:()=>a(C.id),onRequestClose:t,onCloseOthers:u,onCloseToLeft:f,onCloseToRight:l,onCloseAll:c},C.id))})}),e.jsx(gn,{dropAnimation:null,children:x&&e.jsx(Ei,{tab:x})})]})},Ti=({tab:t,tabIndex:n,totalTabs:o,isActive:r,isModified:a,onActivate:i,onRequestClose:u,onCloseOthers:f,onCloseToLeft:l,onCloseToRight:c,onCloseAll:x})=>{const{attributes:d,listeners:m,setNodeRef:y,transform:b,transition:v,isDragging:N}=Ur({id:t.id}),C={transform:Vr.Transform.toString(b),transition:N?"none":v,opacity:N?.3:1},S=O=>{O.stopPropagation(),u(t.id)},R=O=>{O.button===1&&(O.preventDefault(),u(t.id))};return e.jsx("div",{ref:y,style:C,className:"flex h-full shrink-0",...d,...m,children:e.jsx(ki,{tabId:t.id,tabIndex:n,totalTabs:o,onClose:u,onCloseOthers:f,onCloseToLeft:l,onCloseToRight:c,onCloseAll:x,children:e.jsxs(H,{children:[e.jsx(X,{asChild:!0,children:e.jsxs("button",{onClick:i,onAuxClick:R,role:"tab","aria-selected":r,className:`group flex h-full shrink-0 cursor-grab items-center gap-1.5 border-r border-border px-3 text-xs transition-colors ${r?"bg-surface text-text":"bg-surface-sidebar text-text-muted hover:bg-surface-raised hover:text-text-secondary"}`,children:[a&&e.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-amber-400","aria-label":"Unsaved changes"}),e.jsx(Ue,{fileName:t.fileName,className:"size-3.5"}),e.jsxs("span",{className:"max-w-40 truncate",children:[t.fileName,t.disambiguatedLabel&&e.jsx("span",{className:"ml-1 text-text-muted",children:t.disambiguatedLabel})]}),e.jsx("span",{onClick:S,onPointerDown:O=>O.stopPropagation(),className:"ml-1 rounded p-0.5 opacity-0 transition-opacity hover:bg-surface-raised group-hover:opacity-100",role:"button","aria-label":`Close ${t.fileName}`,tabIndex:-1,children:e.jsx(tt,{className:"size-3"})})]})}),e.jsx(q,{side:"bottom",children:t.filePath})]})})})},Ei=({tab:t})=>e.jsxs("div",{className:"flex items-center gap-1.5 rounded border border-border-emphasis bg-surface-raised px-3 py-1 text-xs text-text shadow-lg",children:[e.jsx(Ue,{fileName:t.fileName,className:"size-3.5"}),e.jsx("span",{className:"max-w-40 truncate",children:t.fileName})]}),Ri=({isMarkdown:t=!1,mdPreviewMode:n="off",onToggleSplit:o,onToggleFullPreview:r})=>{const{activeTabId:a,modifiedFiles:i,saving:u,lineWrap:f}=w(Re(v=>({activeTabId:v.editorActiveTabId,modifiedFiles:v.editorModifiedFiles,saving:v.editorSaving,lineWrap:v.editorLineWrap}))),l=w(v=>v.saveFile),c=w(v=>v.toggleLineWrap);if(!a)return null;const x=!!i[a],d=!!u[a],m=()=>{l(a)},y=()=>{const v=Ce.getView();v&&an(v)},b=()=>{const v=Ce.getView();v&&cn(v)};return e.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-1 border-b border-border bg-surface px-2",children:[e.jsx(Me,{icon:e.jsx(Wr,{className:"size-3.5"}),label:"Save",shortcut:se("⌘ S","Ctrl+S"),onClick:m,disabled:!x||d}),e.jsx(Me,{icon:e.jsx(Hr,{className:"size-3.5"}),label:"Undo",shortcut:se("⌘ Z","Ctrl+Z"),onClick:y}),e.jsx(Me,{icon:e.jsx(Xr,{className:"size-3.5"}),label:"Redo",shortcut:se("⌘ ⇧ Z","Ctrl+Y"),onClick:b}),e.jsx("div",{className:"mx-1 h-4 w-px bg-border"}),e.jsx(Me,{icon:e.jsx(jo,{className:"size-3.5"}),label:f?"Disable word wrap":"Enable word wrap",shortcut:se("⌘ ⇧ W","Ctrl+Shift+W"),onClick:c,active:f}),t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mx-1 h-4 w-px bg-border"}),e.jsx(Me,{icon:e.jsx(xo,{className:"size-3.5"}),label:n==="split"?"Close split preview":"Split preview",shortcut:se("⌘ ⇧ M","Ctrl+Shift+M"),onClick:o??(()=>{}),active:n==="split"}),e.jsx(Me,{icon:e.jsx(qr,{className:"size-3.5"}),label:n==="preview"?"Close preview":"Full preview",shortcut:se("⌘ ⇧ V","Ctrl+Shift+V"),onClick:r??(()=>{}),active:n==="preview"})]})]})},Me=he.memo(function({icon:n,label:o,shortcut:r,onClick:a,disabled:i=!1,active:u=!1}){return e.jsxs(H,{children:[e.jsx(X,{asChild:!0,children:e.jsx(P,{variant:"ghost",onClick:a,disabled:i,className:`h-auto gap-1 px-1.5 py-0.5 text-xs ${u?"bg-surface-raised text-text":"text-text-muted"}`,"aria-label":`${o} (${r})`,"aria-pressed":u,children:n})}),e.jsxs(q,{side:"bottom",children:[o," (",r,")"]})]})});function Ii(t,n){const o=t.trim();if(!o)return null;const[r,a]=o.split(":"),i=a?parseInt(a,10):void 0;if(i!==void 0&&(isNaN(i)||i<1))return null;const u=r.trim();if(!u)return null;const f=n.state.doc.lines;if(u.endsWith("%")){const x=parseFloat(u.slice(0,-1));return isNaN(x)?null:{line:Math.max(1,Math.min(f,Math.round(x/100*f))),col:i}}if(u.startsWith("+")||u.startsWith("-")){const x=parseInt(u,10);if(isNaN(x))return null;const d=n.state.selection.main.head,m=n.state.doc.lineAt(d).number;return{line:Math.max(1,Math.min(f,m+x)),col:i}}const l=parseInt(u,10);return isNaN(l)?null:{line:Math.max(1,Math.min(f,l)),col:i}}const Di=({onClose:t})=>{const[n,o]=s.useState(""),r=s.useRef(null);s.useEffect(()=>{r.current?.focus()},[]),s.useEffect(()=>{const c=x=>{x.key==="Escape"&&(x.preventDefault(),x.stopPropagation(),t())};return window.addEventListener("keydown",c,!0),()=>window.removeEventListener("keydown",c,!0)},[t]);const a=s.useCallback(()=>{const c=Ce.getView();if(!c)return;const x=Ii(n,c);if(!x)return;const d=c.state.doc.line(x.line),m=x.col?Math.min(x.col-1,d.length):0,y=d.from+m;c.dispatch({selection:{anchor:y},effects:pe.scrollIntoView(y,{y:"center"})}),c.focus(),t()},[n,t]),i=s.useCallback(c=>{c.key==="Enter"&&(c.preventDefault(),a())},[a]),u=Ce.getView(),f=u?.state.doc.lines??0,l=u?u.state.doc.lineAt(u.state.selection.main.head).number:0;return e.jsxs("div",{className:"fixed inset-0 z-[60] flex items-start justify-center pt-[15vh]",children:[e.jsx("div",{className:"fixed inset-0 bg-black/40",onClick:t,onKeyDown:c=>{c.key==="Escape"&&t()},role:"presentation"}),e.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"跳转到行",className:"relative z-10 w-[360px] overflow-hidden rounded-lg border border-border-emphasis bg-surface shadow-2xl",children:e.jsxs("div",{className:"flex flex-col gap-2 p-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("span",{className:"text-xs text-text-secondary",children:["跳转到行"," ",e.jsxs("span",{className:"text-text-muted",children:["(当前:",l,",总行数:",f,")"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(mt,{ref:r,className:"h-8 flex-1 bg-transparent text-sm",placeholder:"行号、+偏移、-偏移或百分比",value:n,onChange:c=>o(c.target.value),onKeyDown:i,spellCheck:!1,autoComplete:"off"}),e.jsx(P,{variant:"secondary",size:"sm",className:"h-8 px-4",onClick:a,disabled:!n.trim(),children:"跳转"})]})]})})]})},Pi=.2,_i=.8,nn=4,Fi=he.memo(function({content:n,mode:o,splitRatio:r,onSplitRatioChange:a,viewKey:i,baseDir:u}){const[f,l]=s.useState(!1),c=s.useRef(null),x=Yr(o==="split",i),d=s.useCallback(v=>{const N=c.current?.parentElement;if(!N)return;const C=N.getBoundingClientRect(),S=v.clientX-C.left,R=Math.min(_i,Math.max(Pi,S/C.width));a(R)},[a]),m=s.useCallback(()=>{l(!1)},[]);s.useEffect(()=>{if(f)return document.addEventListener("mousemove",d),document.addEventListener("mouseup",m),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",m),document.body.style.cursor="",document.body.style.userSelect=""}},[f,d,m]);const y=v=>{v.preventDefault(),l(!0)},b=o==="preview"?"100%":`calc(${(1-r)*100}% - ${nn}px)`;return e.jsxs("div",{ref:c,className:"flex h-full",style:{width:b},children:[o==="split"&&e.jsx("div",{className:`shrink-0 cursor-col-resize border-x border-border transition-colors ${f?"bg-blue-500/50":"hover:bg-blue-500/30"}`,style:{width:nn},onMouseDown:y}),e.jsx("div",{className:"flex-1 overflow-hidden bg-surface",children:e.jsx(Qr,{content:n,scrollRef:x.previewScrollRef,onScroll:x.handlePreviewScroll,baseDir:u})})]})}),Ai=({onClose:t,onSelectFile:n})=>{const o=w(d=>d.editorProjectPath),r=s.useRef(null),[a,i]=s.useState([]),[u,f]=s.useState(!0);s.useEffect(()=>{let d=!1;return f(!0),je.editor.listFiles().then(m=>{d||(i(m),f(!1))}).catch(()=>{d||f(!1)}),()=>{d=!0}},[o]);const l=s.useCallback(d=>{d.key==="Escape"&&(d.preventDefault(),d.stopPropagation(),t())},[t]);s.useEffect(()=>(window.addEventListener("keydown",l,!0),()=>window.removeEventListener("keydown",l,!0)),[l]);const c=s.useCallback(d=>{const m=a.find(y=>y.relativePath===d);m&&(n(m.path),t())},[a,n,t]),x=s.useMemo(()=>a.map(d=>({...d,iconInfo:Zr(d.name)})),[a]);return e.jsxs("div",{className:"fixed inset-0 z-[60] flex items-start justify-center pt-[15vh]",children:[e.jsx("div",{className:"fixed inset-0 bg-black/40",onClick:t,onKeyDown:d=>{d.key==="Escape"&&t()},role:"presentation"}),e.jsx("div",{ref:r,role:"dialog","aria-modal":"true","aria-label":"快速打开",className:"relative z-10 w-[520px] overflow-hidden rounded-lg border border-border-emphasis bg-surface shadow-2xl",children:e.jsxs(Fe,{label:"快速打开",shouldFilter:!0,children:[e.jsx(Fe.Input,{placeholder:"按文件名搜索...",className:"w-full border-b border-border bg-transparent px-4 py-3 text-sm text-text outline-none placeholder:text-text-muted",autoFocus:!0}),e.jsxs(Fe.List,{className:"max-h-80 overflow-y-auto p-1",children:[u&&e.jsxs("div",{className:"flex items-center justify-center gap-2 p-6 text-sm text-text-muted",children:[e.jsx(nt,{className:"size-4 animate-spin"}),e.jsx("span",{children:"正在加载文件..."})]}),!u&&e.jsx(Fe.Empty,{className:"p-6 text-center text-sm text-text-muted",children:"未找到文件"}),x.map(d=>{const m=d.iconInfo.icon;return e.jsxs(Fe.Item,{value:d.relativePath,onSelect:()=>c(d.relativePath),className:"flex cursor-pointer items-center gap-2 rounded px-3 py-1.5 text-sm text-text-secondary aria-selected:bg-surface-raised aria-selected:text-text",children:[e.jsx(m,{className:"size-4 shrink-0",style:{color:d.iconInfo.color}}),e.jsx("span",{className:"truncate font-medium",children:d.name}),e.jsx("span",{className:"ml-auto truncate text-xs text-text-muted",children:d.relativePath})]},d.path)})]})]})})]})},Li=300,Oi=({projectPath:t,onClose:n,onSelectMatch:o})=>{const[r,a]=s.useState(""),[i,u]=s.useState(!1),[f,l]=s.useState(null),[c,x]=s.useState(!1),[d,m]=s.useState(null),[y,b]=s.useState(new Set),v=s.useRef(null),N=s.useRef(void 0),C=s.useRef(0);s.useEffect(()=>{v.current?.focus()},[]),s.useEffect(()=>{const j=M=>{M.key==="Escape"&&(M.preventDefault(),M.stopPropagation(),n())};return window.addEventListener("keydown",j,!0),()=>window.removeEventListener("keydown",j,!0)},[n]);const S=s.useCallback(async(j,M)=>{if(!j.trim()){l(null),x(!1),m(null);return}const _=++C.current;x(!0),m(null);try{const T=await je.editor.searchInFiles({query:j,caseSensitive:M});if(C.current!==_)return;l(T);const L=new Set(T.results.slice(0,5).map(B=>B.filePath));b(L)}catch(T){if(C.current!==_)return;const L=T instanceof Error?T.message:String(T);m(L)}finally{C.current===_&&x(!1)}},[]),R=s.useCallback(j=>{a(j),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{S(j,i)},Li)},[i,S]),O=s.useCallback(()=>{const j=!i;u(j),r.trim()&&(N.current&&clearTimeout(N.current),S(r,j))},[i,r,S]),K=s.useCallback(j=>{b(M=>{const _=new Set(M);return _.has(j)?_.delete(j):_.add(j),_})},[]),I=s.useCallback(j=>j.startsWith(t)?j.slice(t.length+1):j,[t]);return e.jsxs("div",{className:"flex h-full flex-col border-r border-border bg-surface-sidebar",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"在文件中搜索"}),e.jsxs(H,{children:[e.jsx(X,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon",className:"size-6 text-text-muted",onClick:n,"aria-label":"关闭搜索",children:e.jsx(tt,{className:"size-3.5"})})}),e.jsx(q,{side:"bottom",children:"关闭搜索(Esc)"})]})]}),e.jsxs("div",{className:"border-b border-border p-2",children:[e.jsxs("div",{className:"flex items-center gap-1 rounded border border-border bg-surface px-2 py-1",children:[e.jsx(Jr,{className:"size-3.5 shrink-0 text-text-muted"}),e.jsx("input",{ref:v,type:"text",value:r,onChange:j=>R(j.target.value),placeholder:"搜索...",className:"flex-1 bg-transparent text-xs text-text outline-none placeholder:text-text-muted"}),c&&e.jsx(nt,{className:"size-3 shrink-0 animate-spin text-text-muted"})]}),e.jsx("div",{className:"mt-1.5 flex items-center gap-2",children:e.jsxs(H,{children:[e.jsx(X,{asChild:!0,children:e.jsx("button",{onClick:O,className:`rounded px-1.5 py-0.5 text-[10px] font-medium transition-colors ${i?"bg-blue-500/20 text-blue-400":"text-text-muted hover:bg-surface-raised"}`,"aria-label":"区分大小写","aria-pressed":i,children:"Aa"})}),e.jsx(q,{side:"bottom",children:"区分大小写"})]})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[d&&e.jsx("div",{className:"p-3 text-xs text-red-400",children:d}),f?.totalMatches===0&&r.trim()&&e.jsx("div",{className:"p-4 text-center text-xs text-text-muted",children:"未找到结果"}),f&&f.totalMatches>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-b border-border px-3 py-1.5 text-[10px] text-text-muted",children:[f.results.length," 个文件中有 ",f.totalMatches," 个匹配",f.truncated&&"(已截断)"]}),f.results.map(j=>e.jsx(zi,{fileResult:j,relativePath:I(j.filePath),expanded:y.has(j.filePath),onToggle:()=>K(j.filePath),onSelectMatch:M=>o(j.filePath,M),query:r,caseSensitive:i},j.filePath))]})]})]})},zi=({fileResult:t,relativePath:n,expanded:o,onToggle:r,onSelectMatch:a,query:i,caseSensitive:u})=>{const f=Ee(n)||n,l=Ze(n),c=l>=0?n.slice(0,l):"";return e.jsxs("div",{className:"border-border/50 border-b",children:[e.jsxs("button",{onClick:r,className:"flex w-full items-center gap-1.5 px-3 py-1 text-left transition-colors hover:bg-surface-raised",children:[e.jsx("span",{className:"text-[10px] text-text-muted",children:o?"▼":"▶"}),e.jsx(Ue,{fileName:f,className:"size-3.5"}),e.jsx("span",{className:"truncate text-xs font-medium text-text",children:f}),c&&e.jsx("span",{className:"ml-1 truncate text-[10px] text-text-muted",children:c}),e.jsx("span",{className:"ml-auto shrink-0 text-[10px] text-text-muted",children:t.matches.length})]}),o&&e.jsx("div",{className:"pb-1",children:t.matches.map((x,d)=>e.jsxs("button",{onClick:()=>a(x.line),className:"flex w-full items-center gap-2 px-6 py-0.5 text-left transition-colors hover:bg-surface-raised",children:[e.jsx("span",{className:"w-8 shrink-0 text-right text-[10px] text-text-muted",children:x.line}),e.jsx($i,{text:x.lineContent,query:i,caseSensitive:u})]},`${x.line}-${d}`))})]})},$i=he.memo(function({text:n,query:o,caseSensitive:r}){if(!o)return e.jsx("span",{className:"truncate text-[11px] text-text-secondary",children:n});const a=r?n:n.toLowerCase(),i=r?o:o.toLowerCase(),u=[];let f=0,l=a.indexOf(i);for(;l!==-1;)l>f&&u.push(e.jsx("span",{className:"text-text-secondary",children:n.slice(f,l)},`t-${f}`)),u.push(e.jsx("span",{className:"rounded bg-yellow-500/30 text-yellow-200",children:n.slice(l,l+o.length)},`h-${l}`)),f=l+o.length,l=a.indexOf(i,f);return f<n.length&&u.push(e.jsx("span",{className:"text-text-secondary",children:n.slice(f)},`t-${f}`)),e.jsx("span",{className:"truncate text-[11px]",children:u})}),Ui=({projectPath:t,onClose:n,onEditorAction:o})=>{const{activeTabId:r,openTabs:a,modifiedFiles:i,saveErrors:u,externalChanges:f,conflictFile:l}=w(Re(h=>({activeTabId:h.editorActiveTabId,openTabs:h.editorOpenTabs,modifiedFiles:h.editorModifiedFiles,saveErrors:h.editorSaveError,externalChanges:h.editorExternalChanges,conflictFile:h.editorConflictFile}))),c=w(h=>h.openEditor),x=w(h=>h.closeEditor),d=w(h=>h.openFile),m=w(h=>h.closeEditorTab),y=w(h=>h.saveFile),b=w(h=>h.hasUnsavedChanges),v=w(h=>h.saveAllFiles),N=w(h=>h.discardChanges),C=w(h=>h.clearExternalChange),S=w(h=>h.forceOverwrite),R=w(h=>h.resolveConflict),O=w(h=>h.setFileMtime),K=w(h=>h.fetchGitStatus),[I,j]=s.useState(null),[M,_]=s.useState(!1),[T,L]=s.useState(null),[B,ae]=s.useState(1),[ie,ue]=s.useState(1),[D,Q]=s.useState(!1),[A,p]=s.useState(null),[E,F]=s.useState(null),[W,ce]=s.useState(0),[te,le]=s.useState(null),re=s.useRef(null),[V,xe]=s.useState(()=>new DOMRect),[Z,fe]=s.useState("off"),[we,ge]=s.useState(""),[be,Se]=s.useState(()=>{try{const h=localStorage.getItem("editor:mdSplitRatio");return h?Math.max(.2,Math.min(.8,Number(h))):.5}catch{return .5}}),[J,He]=s.useState(!1),[ve,Xe]=s.useState(!1),[at,g]=s.useState(!1),[k,z]=s.useState(!1),[U,ke]=s.useState(()=>{try{return localStorage.getItem("editor-sidebar-visible")!=="false"}catch{return!0}}),De=s.useRef(null),it=s.useRef(new Map),ct=a.find(h=>h.id===r)??null,Pe=ct?.language==="Markdown";s.useEffect(()=>{fe(Pe?h=>h==="off"?"split":h:"off")},[Pe,r]);const ms=s.useCallback(h=>{Se(h);try{localStorage.setItem("editor:mdSplitRatio",String(h))}catch{}},[]),ps=s.useCallback(h=>{ge(h)},[]),Tt=s.useCallback(()=>{fe(h=>h==="split"?"off":"split")},[]),Et=s.useCallback(()=>{fe(h=>h==="preview"?"off":"preview")},[]);s.useEffect(()=>{Z!=="off"&&I?.content&&ge(I.content)},[Z,I?.content]);const gs=we||I?.content||"",me=s.useCallback(async h=>{_(!0),L(null),j(null);try{const G=performance.now();let ne=it.current.get(h);const _s=!!ne;ne||(ne=je.editor.readFile(h),it.current.set(h,ne),ne.finally(()=>it.current.delete(h)));const _e=await ne,Fs=performance.now()-G;console.debug(`[perf] loadFileContent: IPC=${Fs.toFixed(1)}ms, size=${_e.size}, truncated=${_e.truncated}, cached=${_s}, file=${Ee(h)}`),j(_e),_e.mtimeMs&&O(h,_e.mtimeMs)}catch(G){const ne=G instanceof Error?G.message:String(G);L(ne)}finally{_(!1)}},[O]),Rt=r?u[r]??null:null,lt=w(h=>h.editorPendingRevealFile),It=w(h=>h.revealAndOpenFile);s.useEffect(()=>(c(t),()=>{x()}),[t,c,x]);const Dt=w(h=>h.editorFileTreeLoading),Pt=w(h=>h.editorFileTree!==null);s.useEffect(()=>{lt&&!Dt&&Pt&&It(lt)},[lt,Dt,Pt,It]),s.useEffect(()=>{const h=re.current;if(!h)return;const G=()=>xe(h.getBoundingClientRect());G();const ne=new ResizeObserver(G);return ne.observe(h),()=>ne.disconnect()},[]),s.useEffect(()=>{const h=G=>{if(G.key==="Escape"){if(G.defaultPrevented||J||ve||k||D||A||l)return;G.preventDefault(),dt()}G.key==="F5"&&(G.preventDefault(),zt())};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[J,ve,k,D,A,l]),s.useEffect(()=>{De.current?.focus()},[]),s.useEffect(()=>{if(le(null),!r){j(null),_(!1),L(null);return}me(r)},[r,me]),s.useEffect(()=>{r!==E&&F(null)},[r,E]);const _t=s.useCallback(h=>{d(h)},[d]),Ft=s.useCallback(()=>{r&&me(r)},[r,me]),bs=s.useCallback((h,G)=>{ae(h),ue(G)},[]),dt=s.useCallback(()=>{b()?Q(!0):n()},[n,b]),vs=s.useCallback(async()=>{await v(),Q(!1),n()},[v,n]),Cs=s.useCallback(()=>{Q(!1),n()},[n]),At=s.useCallback(()=>{Q(!1)},[]),ut=s.useCallback(h=>{i[h]?p(h):m(h)},[i,m]);s.useEffect(()=>{const h=G=>{const ne=G.detail;ut(ne)};return window.addEventListener("editor-close-tab",h),()=>window.removeEventListener("editor-close-tab",h)},[ut]);const js=s.useCallback(async()=>{A&&(await y(A),m(A),p(null))},[A,y,m]),ys=s.useCallback(()=>{A&&(m(A),p(null))},[A,m]),Lt=s.useCallback(()=>{p(null)},[]),Ns=s.useCallback(h=>{F(h)},[]),ws=s.useCallback(()=>{!E||!r||(N(E),F(null),j(null),ce(h=>h+1),me(r))},[E,r,N,me]),Ss=s.useCallback(()=>{F(null)},[]),ks=s.useCallback(()=>{l&&S(l)},[l,S]),Ot=s.useCallback(()=>{R()},[R]),Ms=s.useCallback(()=>{r&&(C(r),N(r),j(null),ce(h=>h+1),me(r))},[r,C,N,me]),Ts=s.useCallback(()=>{r&&C(r)},[r,C]),zt=s.useCallback(()=>{K()},[K]),Es=s.useCallback(()=>{He(h=>!h)},[]),Rs=s.useCallback(()=>{Xe(h=>!h)},[]),Is=s.useCallback(()=>{g(h=>!h)},[]),xt=s.useCallback(()=>{ke(h=>{const G=!h;try{localStorage.setItem("editor-sidebar-visible",String(G))}catch{}return G})},[]),$t=w(h=>h.setPendingGoToLine),Ds=s.useCallback((h,G)=>{$t(G),d(h)},[d,$t]);So({onToggleQuickOpen:Es,onToggleSearchPanel:Rs,onToggleGoToLine:Is,onToggleSidebar:xt,onClose:dt,onToggleMdSplit:Pe?Tt:void 0,onToggleMdPreview:Pe?Et:void 0});const Ps=Ee(t)||t;return e.jsxs("div",{ref:De,className:"fixed inset-0 z-50 m-0 flex h-screen w-screen flex-col overflow-hidden border-0 bg-surface",tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":"项目编辑器",children:[e.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between border-b border-border px-3",style:{paddingLeft:"var(--macos-traffic-light-padding-left, 72px)"},children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-secondary",children:[e.jsx("span",{className:"font-medium text-text",children:Ps}),e.jsx("span",{className:"text-text-muted",children:t})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs(H,{children:[e.jsx(X,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon",className:"size-7 text-text-muted",onClick:zt,"aria-label":"刷新(F5)",children:e.jsx(Ut,{className:"size-4"})})}),e.jsx(q,{side:"bottom",children:"刷新 Git 状态(F5)"})]}),e.jsxs(H,{children:[e.jsx(X,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon",className:"size-7 text-text-muted",onClick:()=>z(!0),"aria-label":"快捷键",children:e.jsx(eo,{className:"size-4"})})}),e.jsx(q,{side:"bottom",children:"快捷键"})]}),e.jsxs(H,{children:[e.jsx(X,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon",className:"size-7 text-text-muted",onClick:dt,"aria-label":"关闭编辑器",children:e.jsx(tt,{className:"size-4"})})}),e.jsx(q,{side:"bottom",children:"关闭编辑器(Esc)"})]})]})]}),e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[ve&&e.jsx("div",{className:"w-72 shrink-0",children:e.jsx(Oi,{projectPath:t,onClose:()=>Xe(!1),onSelectMatch:Ds})}),U&&!ve&&e.jsxs("div",{className:"flex w-60 shrink-0 flex-col border-r border-border bg-surface-sidebar",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border px-2 py-1",children:[e.jsx("span",{className:"text-[10px] font-medium uppercase tracking-wider text-text-muted",children:"资源管理器"}),e.jsxs(H,{children:[e.jsx(X,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon",className:"size-6 text-text-muted",onClick:xt,"aria-label":"隐藏侧边栏",children:e.jsx(to,{className:"size-3.5"})})}),e.jsxs(q,{side:"bottom",children:["隐藏侧边栏(",se("⌘ B","Ctrl+B"),")"]})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(bi,{selectedFilePath:r,onFileSelect:_t,onCreateTask:o?h=>o(Vt("createTask",h,t)):void 0,onSendMessage:o?h=>o(Vt("sendMessage",h,t)):void 0})})]}),!U&&!ve&&e.jsxs(H,{children:[e.jsx(X,{asChild:!0,children:e.jsx(P,{variant:"ghost",className:"flex h-full w-6 shrink-0 items-start justify-center rounded-none border-r border-border bg-surface-sidebar pt-2 text-text-muted",onClick:xt,"aria-label":"显示侧边栏",children:e.jsx(no,{className:"size-3.5"})})}),e.jsxs(q,{side:"right",children:["显示侧边栏(",se("⌘ B","Ctrl+B"),")"]})]}),e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx(Mi,{onRequestCloseTab:ut}),e.jsx(Ri,{isMarkdown:Pe,mdPreviewMode:Z,onToggleSplit:Tt,onToggleFullPreview:Et}),E&&r===E&&e.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b px-3 py-1.5 text-xs",style:{backgroundColor:"var(--warning-bg)",borderColor:"var(--warning-border)",color:"var(--warning-text)"},children:[e.jsx(so,{className:"size-3.5 shrink-0"}),e.jsx("span",{children:"已从上次会话恢复未保存的更改。"}),e.jsx(P,{variant:"ghost",size:"sm",className:"ml-auto h-auto px-2 py-0.5",onClick:Ss,children:"保留"}),e.jsx(P,{variant:"destructive",size:"sm",className:"h-auto px-2 py-0.5",onClick:ws,children:"丢弃"})]}),Rt&&e.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-red-500/30 bg-red-500/10 px-3 py-1.5 text-xs text-red-300",children:[e.jsx(gt,{className:"size-3.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:["保存失败:",Rt]}),e.jsx(P,{variant:"ghost",size:"sm",className:"ml-auto h-auto shrink-0 px-2 py-0.5",onClick:()=>r&&void y(r),children:"重试"})]}),r&&f[r]&&e.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-blue-400/30 bg-blue-100/50 px-3 py-1.5 text-xs text-blue-700 dark:border-blue-500/30 dark:bg-blue-500/10 dark:text-blue-300",children:[e.jsx(Ut,{className:"size-3.5 shrink-0"}),e.jsx("span",{children:f[r]==="delete"?"文件已从磁盘中删除。":"文件已在磁盘上被修改。"}),f[r]==="delete"?e.jsx(P,{variant:"ghost",size:"sm",className:"ml-auto h-auto px-2 py-0.5",onClick:()=>m(r),children:"关闭标签页"}):e.jsxs(e.Fragment,{children:[e.jsx(P,{variant:"ghost",size:"sm",className:"ml-auto h-auto px-2 py-0.5",onClick:Ms,children:"重新加载"}),e.jsx(P,{variant:"ghost",size:"sm",className:"h-auto px-2 py-0.5",onClick:Ts,children:"保留我的版本"})]})]}),e.jsxs("div",{ref:re,className:"relative flex-1 overflow-hidden",children:[M&&e.jsx("div",{className:"flex h-full items-center justify-center text-text-muted",children:e.jsx(nt,{className:"size-5 animate-spin"})}),T&&e.jsx(Yo,{error:T,onRetry:Ft}),I?.isBinary&&r&&e.jsx(Wo,{filePath:r,size:I.size}),I&&!I.isBinary&&r&&e.jsxs("div",{className:"flex h-full",children:[e.jsx("div",{className:"h-full overflow-hidden",style:{display:Z==="preview"?"none":"block",width:Z==="split"?`${be*100}%`:"100%"},children:e.jsx(qo,{filePath:r,onRetry:Ft,children:e.jsx($o,{filePath:r,content:I.content,fileName:Ee(r)||"file",mtimeMs:I.mtimeMs,onCursorChange:bs,onDraftRecovered:Ns,onSelectionChange:le,onDocChange:Z!=="off"?ps:void 0},`${r}-${W}`)})}),Z!=="off"&&e.jsx(Fi,{content:gs,mode:Z,splitRatio:be,onSplitRatioChange:ms,viewKey:r,baseDir:r?ro(r):void 0})]}),!M&&!T&&!I&&!r&&e.jsx(Xo,{}),te&&o&&e.jsx(yi,{info:te,containerRect:V,onSendMessage:()=>{o(Wt("sendMessage",te)),le(null)},onCreateTask:()=>{o(Wt("createTask",te)),le(null)}})]}),ct&&e.jsx(Si,{line:B,col:ie,language:ct.language})]})]}),J&&e.jsx(Ai,{onClose:()=>He(!1),onSelectFile:_t}),at&&e.jsx(Di,{onClose:()=>g(!1)}),k&&e.jsx(wi,{onClose:()=>z(!1)}),e.jsx(Le,{open:D,onOpenChange:h=>!h&&At(),children:e.jsxs(Oe,{className:"w-96 max-w-96",children:[e.jsxs(ze,{children:[e.jsx($e,{className:"text-sm",children:"未保存的更改"}),e.jsx(Ye,{children:"你有未保存的更改。要如何处理?"})]}),e.jsxs(Qe,{children:[e.jsx(P,{variant:"ghost",size:"sm",onClick:At,children:"取消"}),e.jsx(P,{variant:"destructive",size:"sm",onClick:Cs,children:"丢弃并关闭"}),e.jsx(P,{size:"sm",onClick:()=>void vs(),children:"全部保存并关闭"})]})]})}),e.jsx(Le,{open:!!l,onOpenChange:h=>!h&&Ot(),children:e.jsxs(Oe,{className:"w-96 max-w-96",children:[e.jsxs(ze,{children:[e.jsx($e,{className:"text-sm",children:"保存冲突"}),e.jsx(Ye,{children:"该文件在打开后被外部修改。是否用你的更改覆盖?"})]}),e.jsxs(Qe,{children:[e.jsx(P,{variant:"ghost",size:"sm",onClick:Ot,children:"取消"}),e.jsx(P,{variant:"destructive",size:"sm",onClick:ks,children:"覆盖"})]})]})}),e.jsx(Le,{open:!!A,onOpenChange:h=>!h&&Lt(),children:e.jsxs(Oe,{className:"w-96 max-w-96",children:[e.jsxs(ze,{children:[e.jsx($e,{className:"text-sm",children:"未保存的更改"}),e.jsx(Ye,{children:"此文件有未保存的更改。要如何处理?"})]}),e.jsxs(Qe,{children:[e.jsx(P,{variant:"ghost",size:"sm",onClick:Lt,children:"取消"}),e.jsx(P,{variant:"destructive",size:"sm",onClick:ys,children:"丢弃"}),e.jsx(P,{size:"sm",onClick:()=>void js(),children:"保存"})]})]})})]})};export{Ui as ProjectEditorOverlay};
@@ -1 +0,0 @@
1
- import{a6 as o,a7 as n}from"./index-DYdseEwc.js";const t=(a,r)=>o.lang.round(n.parse(a)[r]);export{t as c};
@@ -1 +0,0 @@
1
- import{s as a,c as s,a as e,C as t}from"./chunk-B4BG7PRW-p5bffh_R.js";import{_ as i}from"./index-DYdseEwc.js";import"./chunk-FMBD7UC4-B6SCKseX.js";import"./chunk-55IACEB6-DyVohOQb.js";import"./chunk-QN33PNHL-L12RvLBR.js";import"./splashScene-C8lWNnm4.js";var u={parser:e,get db(){return new t},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{u as diagram};
@@ -1 +0,0 @@
1
- import{s as a,c as s,a as e,C as t}from"./chunk-B4BG7PRW-p5bffh_R.js";import{_ as i}from"./index-DYdseEwc.js";import"./chunk-FMBD7UC4-B6SCKseX.js";import"./chunk-55IACEB6-DyVohOQb.js";import"./chunk-QN33PNHL-L12RvLBR.js";import"./splashScene-C8lWNnm4.js";var u={parser:e,get db(){return new t},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{u as diagram};
@@ -1 +0,0 @@
1
- import{b as r}from"./_baseUniq-BBLBOeXc.js";var e=4;function a(o){return r(o,e)}export{a as c};