@ironmussa/funny 0.1.0 → 0.1.2

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 (159) hide show
  1. package/README.md +231 -214
  2. package/bin/funny.js +80 -80
  3. package/package.json +79 -59
  4. package/packages/client/dist/assets/AddProjectView-yopCTuKC.js +1 -0
  5. package/packages/client/dist/assets/AllThreadsView-vCQJYKkF.js +2 -0
  6. package/packages/client/dist/assets/AnalyticsView-vz1-NSOv.js +36 -0
  7. package/packages/client/dist/assets/App-BEFplUGa.js +2 -0
  8. package/packages/client/dist/assets/AutomationInboxView-Dj7f9gOu.js +1 -0
  9. package/packages/client/dist/assets/CircuitBreakerDialog-C76CZi4q.js +1 -0
  10. package/packages/client/dist/assets/CommandPalette-7Y8qqH7R.js +1 -0
  11. package/packages/client/dist/assets/LiveColumnsView-CSRiYBNg.js +1 -0
  12. package/packages/client/dist/assets/LoginPage-C61IUXzX.js +1 -0
  13. package/packages/client/dist/assets/MobilePage-B4kbWfE1.js +1 -0
  14. package/packages/client/dist/assets/MonacoEditorDialog-PPXTSIdX.js +1 -0
  15. package/packages/client/dist/assets/PreviewBrowser-Bo2zmDPh.js +2 -0
  16. package/packages/client/dist/assets/PromptInput-Cq_fXmwj.js +1 -0
  17. package/packages/client/dist/assets/ReviewPane-1r1cuH2I.js +10 -0
  18. package/packages/client/dist/assets/SettingsDetailView-D-J9TfZx.js +1 -0
  19. package/packages/client/dist/assets/SetupWizard-BbLWm6BX.js +1 -0
  20. package/packages/client/dist/assets/Sidebar-3Jd5JyAp.js +1 -0
  21. package/packages/client/dist/assets/SlideUpPrompt-_ulHi9sN.js +1 -0
  22. package/packages/client/dist/assets/TerminalPanel-BiLDlQZQ.js +4 -0
  23. package/packages/client/dist/assets/ThreadListView-DthHUodE.js +1 -0
  24. package/packages/client/dist/assets/ThreadView-DsqoxCXZ.js +16 -0
  25. package/packages/client/dist/assets/ToolCallGroup-BgROpRwn.js +22 -0
  26. package/packages/client/dist/assets/_basePickBy-BeHeP2rS.js +1 -0
  27. package/packages/client/dist/assets/_baseUniq-CZf5jOXa.js +1 -0
  28. package/packages/client/dist/assets/ansi_to_html-DYje8R53.js +3 -0
  29. package/packages/client/dist/assets/app-store-B3iAaYzj.js +1 -0
  30. package/packages/client/dist/assets/architectureDiagram-VXUJARFQ-CysgSV_T.js +36 -0
  31. package/packages/client/dist/assets/arrow-down-DQYiOM3D.js +1 -0
  32. package/packages/client/dist/assets/arrow-right-Bbusk4uX.js +1 -0
  33. package/packages/client/dist/assets/automation-store-DiFgwQi4.js +1 -0
  34. package/packages/client/dist/assets/badge-CrCqde50.js +1 -0
  35. package/packages/client/dist/assets/blockDiagram-VD42YOAC-DU32EjW8.js +122 -0
  36. package/packages/client/dist/assets/breadcrumb-BiY69_Mg.js +1 -0
  37. package/packages/client/dist/assets/button-D8qrc3hb.js +1 -0
  38. package/packages/client/dist/assets/c4Diagram-YG6GDRKO-D31N17G_.js +10 -0
  39. package/packages/client/dist/assets/check-Dj_ZR5Y7.js +1 -0
  40. package/packages/client/dist/assets/chevron-down-BJhJsMnL.js +1 -0
  41. package/packages/client/dist/assets/chevron-left-BVsM9RGq.js +1 -0
  42. package/packages/client/dist/assets/chevron-right-PEOnBrxM.js +1 -0
  43. package/packages/client/dist/assets/chevrons-up-down-Sa8XJRBx.js +1 -0
  44. package/packages/client/dist/assets/chunk-4BX2VUAB-CSqlINSL.js +1 -0
  45. package/packages/client/dist/assets/chunk-55IACEB6-D5_ai8AA.js +1 -0
  46. package/packages/client/dist/assets/chunk-B4BG7PRW-DKOAlNfo.js +165 -0
  47. package/packages/client/dist/assets/chunk-DI55MBZ5-BNwqKgG-.js +220 -0
  48. package/packages/client/dist/assets/chunk-FMBD7UC4-MKWtG46g.js +15 -0
  49. package/packages/client/dist/assets/chunk-QN33PNHL-BWGv-iLk.js +1 -0
  50. package/packages/client/dist/assets/chunk-QZHKN3VN-Brx07f_u.js +1 -0
  51. package/packages/client/dist/assets/chunk-TZMSLE5B-Cgz2v9ud.js +1 -0
  52. package/packages/client/dist/assets/circle-x-BNvrcCvx.js +1 -0
  53. package/packages/client/dist/assets/classDiagram-2ON5EDUG-Bi8VPWgp.js +1 -0
  54. package/packages/client/dist/assets/classDiagram-v2-WZHVMYZB-Bi8VPWgp.js +1 -0
  55. package/packages/client/dist/assets/clipboard-list-zkC7qTDO.js +1 -0
  56. package/packages/client/dist/assets/clone-CzE9L7Ig.js +1 -0
  57. package/packages/client/dist/assets/collapsible-DP3s_8s3.js +1 -0
  58. package/packages/client/dist/assets/columns-3-DhvlrNjA.js +1 -0
  59. package/packages/client/dist/assets/command-DOlrnbnh.js +1 -0
  60. package/packages/client/dist/assets/copy-DXKK6zMx.js +1 -0
  61. package/packages/client/dist/assets/cose-bilkent-S5V4N54A-DabFXskf.js +1 -0
  62. package/packages/client/dist/assets/createLucideIcon-CsWFljth.js +1 -0
  63. package/packages/client/dist/assets/cytoscape.esm-5J0xJHOV.js +321 -0
  64. package/packages/client/dist/assets/dagre-6UL2VRFP-BgQrFrWh.js +4 -0
  65. package/packages/client/dist/assets/diagram-PSM6KHXK-B0rQdwLC.js +24 -0
  66. package/packages/client/dist/assets/diagram-QEK2KX5R-aX13lt6A.js +43 -0
  67. package/packages/client/dist/assets/diagram-S2PKOQOG-cgHvdjCm.js +24 -0
  68. package/packages/client/dist/assets/dialog-DapeOKPE.js +1 -0
  69. package/packages/client/dist/assets/draft-store-DnVbStYY.js +1 -0
  70. package/packages/client/dist/assets/dropdown-menu-Bi54WPTK.js +1 -0
  71. package/packages/client/dist/assets/editor-utils-DgK9pIvP.js +2 -0
  72. package/packages/client/dist/assets/erDiagram-Q2GNP2WA-DwocRLhB.js +60 -0
  73. package/packages/client/dist/assets/external-link-Dg0Hq511.js +1 -0
  74. package/packages/client/dist/assets/eye-BAXsQYWt.js +1 -0
  75. package/packages/client/dist/assets/eye-off-ICXVwkI1.js +1 -0
  76. package/packages/client/dist/assets/flowDiagram-NV44I4VS-C0ldc02M.js +162 -0
  77. package/packages/client/dist/assets/folder-d8RRIu-j.js +1 -0
  78. package/packages/client/dist/assets/folder-open-BbwqJxUi.js +1 -0
  79. package/packages/client/dist/assets/ganttDiagram-JELNMOA3-DxdfUar4.js +267 -0
  80. package/packages/client/dist/assets/git-merge-CB0ebeXg.js +1 -0
  81. package/packages/client/dist/assets/gitGraphDiagram-V2S2FVAM-uM_Ec7JF.js +65 -0
  82. package/packages/client/dist/assets/github-DiENtmNz.js +1 -0
  83. package/packages/client/dist/assets/globe-B1hiCqlb.js +1 -0
  84. package/packages/client/dist/assets/graph-Qo1vygVG.js +1 -0
  85. package/packages/client/dist/assets/history-D7cvrs7x.js +1 -0
  86. package/packages/client/dist/assets/inbox-4g-W9WtW.js +1 -0
  87. package/packages/client/dist/assets/index-BplxL2Qj.js +1 -0
  88. package/packages/client/dist/assets/index-DmIp58b6.js +1 -0
  89. package/packages/client/dist/assets/index-Z_QI94Zg.js +18 -0
  90. package/packages/client/dist/assets/{index-B0nLATLY.js → index-cSW024sc.js} +1 -1
  91. package/packages/client/dist/assets/index-zxpgGDAW.css +1 -0
  92. package/packages/client/dist/assets/infoDiagram-HS3SLOUP-C-koF35b.js +2 -0
  93. package/packages/client/dist/assets/input-Dyxe5hqI.js +1 -0
  94. package/packages/client/dist/assets/internal-editor-store-CuhCMFlj.js +1 -0
  95. package/packages/client/dist/assets/journeyDiagram-XKPGCS4Q-DRqupubT.js +139 -0
  96. package/packages/client/dist/assets/kanban-definition-3W4ZIXB7-BvWguxdE.js +89 -0
  97. package/packages/client/dist/assets/katex-DhXJpUyf.js +261 -0
  98. package/packages/client/dist/assets/layout-UD4laNpY.js +1 -0
  99. package/packages/client/dist/assets/markdown-9_JKOUHQ.js +29 -0
  100. package/packages/client/dist/assets/maximize-2-DW-IsQiI.js +1 -0
  101. package/packages/client/dist/assets/mermaid-C0IQv4mH.js +250 -0
  102. package/packages/client/dist/assets/mindmap-definition-VGOIOE7T-C0fzBd6g.js +68 -0
  103. package/packages/client/dist/assets/minimize-2-CWn5BNKr.js +1 -0
  104. package/packages/client/dist/assets/monaco-CvC2RZDL.js +11 -0
  105. package/packages/client/dist/assets/{motion-DRu4QWVj.js → motion-Cyp39Uo1.js} +1 -1
  106. package/packages/client/dist/assets/pencil-pMey300q.js +1 -0
  107. package/packages/client/dist/assets/pieDiagram-ADFJNKIX-CUBE4hL3.js +30 -0
  108. package/packages/client/dist/assets/pin-off-DpiyTpTd.js +1 -0
  109. package/packages/client/dist/assets/pin-uzq68OVB.js +1 -0
  110. package/packages/client/dist/assets/plus-ChfperZy.js +1 -0
  111. package/packages/client/dist/assets/popover-CRZjc4jI.js +1 -0
  112. package/packages/client/dist/assets/project-chip-CkL3EaeE.js +5 -0
  113. package/packages/client/dist/assets/providers-Bv7fzJNY.js +1 -0
  114. package/packages/client/dist/assets/quadrantDiagram-AYHSOK5B-DF7I9OHz.js +7 -0
  115. package/packages/client/dist/assets/refresh-cw-Svvcff2v.js +1 -0
  116. package/packages/client/dist/assets/requirementDiagram-UZGBJVZJ-BBI4q-3_.js +64 -0
  117. package/packages/client/dist/assets/review-pane-store-CrK1Czq6.js +1 -0
  118. package/packages/client/dist/assets/rotate-ccw-DFiWNcpH.js +1 -0
  119. package/packages/client/dist/assets/sankeyDiagram-TZEHDZUN-lqpKxyZi.js +10 -0
  120. package/packages/client/dist/assets/scroll-area-Bj4yTRJP.js +1 -0
  121. package/packages/client/dist/assets/search-JGV9EPmW.js +1 -0
  122. package/packages/client/dist/assets/select-CkTnmILP.js +1 -0
  123. package/packages/client/dist/assets/sequenceDiagram-WL72ISMW-DHImpRwJ.js +145 -0
  124. package/packages/client/dist/assets/shallow-B0DA4RsP.js +1 -0
  125. package/packages/client/dist/assets/square-BqmNpRIH.js +1 -0
  126. package/packages/client/dist/assets/stateDiagram-FKZM4ZOC-C7L7Pt_V.js +1 -0
  127. package/packages/client/dist/assets/stateDiagram-v2-4FDKWEC3-FyYG2QfD.js +1 -0
  128. package/packages/client/dist/assets/{syntax-qKqB8BhQ.js → syntax-CG1UoaFw.js} +17 -17
  129. package/packages/client/dist/assets/terminal-CuAYwdh-.js +1 -0
  130. package/packages/client/dist/assets/timeline-definition-IT6M3QCI-BGABo1HM.js +61 -0
  131. package/packages/client/dist/assets/trash-2-QvY6JeI_.js +1 -0
  132. package/packages/client/dist/assets/treemap-GDKQZRPO-DZ7i2Nwu.js +160 -0
  133. package/packages/client/dist/assets/upload-DXXUmYu2.js +1 -0
  134. package/packages/client/dist/assets/use-minute-tick-BoS3Ec2H.js +1 -0
  135. package/packages/client/dist/assets/use-ws-BIe6kKa2.js +48 -0
  136. package/packages/client/dist/assets/utils-VDOOGGvU.js +2 -0
  137. package/packages/client/dist/assets/x-AprddF_b.js +1 -0
  138. package/packages/client/dist/assets/xychartDiagram-PRI3JC2R-D_bazwNo.js +7 -0
  139. package/packages/client/dist/index.html +9 -13
  140. package/packages/server/dist/index.js +117479 -69360
  141. package/packages/server/dist/index.js.map +682 -138
  142. package/packages/server/dist/pty-helper.mjs +115 -115
  143. package/packages/client/dist/assets/AddProjectView-CODm54MP.js +0 -1
  144. package/packages/client/dist/assets/AllThreadsView--Dd7YSK5.js +0 -1
  145. package/packages/client/dist/assets/AnalyticsView-eRhWGG3y.js +0 -36
  146. package/packages/client/dist/assets/AutomationInboxView-DwBaGJed.js +0 -1
  147. package/packages/client/dist/assets/CircuitBreakerDialog-C2iBwp5W.js +0 -1
  148. package/packages/client/dist/assets/CommandPalette-BXweSrdO.js +0 -1
  149. package/packages/client/dist/assets/ReviewPane-DxtlJNNu.js +0 -10
  150. package/packages/client/dist/assets/SettingsDetailView-BKh9OBM2.js +0 -1
  151. package/packages/client/dist/assets/SetupWizard-BekJX-tc.js +0 -1
  152. package/packages/client/dist/assets/TerminalPanel-DC4U0OTm.js +0 -4
  153. package/packages/client/dist/assets/ThreadListView-B6HvQ8NV.js +0 -1
  154. package/packages/client/dist/assets/arrow-right-3Bby9NNK.js +0 -1
  155. package/packages/client/dist/assets/command-B76T8z-A.js +0 -1
  156. package/packages/client/dist/assets/index-BRi6al6L.js +0 -99
  157. package/packages/client/dist/assets/index-DXO1sSe9.css +0 -1
  158. package/packages/client/dist/assets/markdown-B7CXSXYD.js +0 -29
  159. package/packages/client/dist/assets/review-pane-store-BLhxZHRI.js +0 -1
@@ -1,115 +1,115 @@
1
- import * as pty from 'node-pty';
2
- import { platform } from 'os';
3
- import { createInterface } from 'readline';
4
-
5
- const isWindows = platform() === 'win32';
6
- const activePtys = new Map();
7
-
8
- // Input stream (stdin) - expect line-delimited JSON commands
9
- const rl = createInterface({
10
- input: process.stdin,
11
- output: process.stdout,
12
- terminal: false
13
- });
14
-
15
- rl.on('line', (line) => {
16
- try {
17
- const msg = JSON.parse(line);
18
- handleMessage(msg);
19
- } catch (err) {
20
- console.error('Failed to parse input:', err);
21
- }
22
- });
23
-
24
- function send(type, data) {
25
- console.log(JSON.stringify({ type, data }));
26
- }
27
-
28
- function handleMessage(msg) {
29
- const { type, ...args } = msg;
30
-
31
- switch (type) {
32
- case 'spawn':
33
- spawnPty(args.id, args.cwd, args.cols, args.rows, args.env);
34
- break;
35
- case 'write':
36
- writePty(args.id, args.data);
37
- break;
38
- case 'resize':
39
- resizePty(args.id, args.cols, args.rows);
40
- break;
41
- case 'kill':
42
- killPty(args.id);
43
- break;
44
- default:
45
- console.error('Unknown message type:', type);
46
- }
47
- }
48
-
49
- function spawnPty(id, cwd, cols, rows, env) {
50
- if (activePtys.has(id)) return;
51
-
52
- try {
53
- const shell = isWindows ? 'powershell.exe' : (process.env.SHELL || 'bash');
54
-
55
- // Merge provided env with process.env
56
- const ptyEnv = { ...process.env, ...env };
57
-
58
- const ptyProcess = pty.spawn(shell, [], {
59
- name: 'xterm-256color',
60
- cols: cols || 80,
61
- rows: rows || 24,
62
- cwd: cwd || process.cwd(),
63
- env: ptyEnv
64
- });
65
-
66
- activePtys.set(id, ptyProcess);
67
-
68
- ptyProcess.onData((data) => {
69
- send('pty:data', { ptyId: id, data });
70
- });
71
-
72
- ptyProcess.onExit(({ exitCode, signal }) => {
73
- send('pty:exit', { ptyId: id, exitCode, signal });
74
- activePtys.delete(id);
75
- });
76
-
77
- } catch (err) {
78
- console.error(`Failed to spawn PTY ${id}:`, err);
79
- send('pty:error', { ptyId: id, error: err.message });
80
- }
81
- }
82
-
83
- function writePty(id, data) {
84
- const ptyProcess = activePtys.get(id);
85
- if (ptyProcess) {
86
- try {
87
- ptyProcess.write(data);
88
- } catch (err) {
89
- console.error(`Failed to write to PTY ${id}:`, err);
90
- }
91
- }
92
- }
93
-
94
- function resizePty(id, cols, rows) {
95
- const ptyProcess = activePtys.get(id);
96
- if (ptyProcess) {
97
- try {
98
- ptyProcess.resize(cols, rows);
99
- } catch (err) {
100
- console.error(`Failed to resize PTY ${id}:`, err);
101
- }
102
- }
103
- }
104
-
105
- function killPty(id) {
106
- const ptyProcess = activePtys.get(id);
107
- if (ptyProcess) {
108
- try {
109
- ptyProcess.kill();
110
- } catch (err) {
111
- // ignore
112
- }
113
- activePtys.delete(id);
114
- }
115
- }
1
+ import { platform } from 'os';
2
+ import { createInterface } from 'readline';
3
+
4
+ import * as pty from 'node-pty';
5
+
6
+ const isWindows = platform() === 'win32';
7
+ const activePtys = new Map();
8
+
9
+ // Input stream (stdin) - expect line-delimited JSON commands
10
+ const rl = createInterface({
11
+ input: process.stdin,
12
+ output: process.stdout,
13
+ terminal: false,
14
+ });
15
+
16
+ rl.on('line', (line) => {
17
+ try {
18
+ const msg = JSON.parse(line);
19
+ handleMessage(msg);
20
+ } catch (err) {
21
+ console.error('Failed to parse input:', err);
22
+ }
23
+ });
24
+
25
+ function send(type, data) {
26
+ console.log(JSON.stringify({ type, data }));
27
+ }
28
+
29
+ function handleMessage(msg) {
30
+ const { type, ...args } = msg;
31
+
32
+ switch (type) {
33
+ case 'spawn':
34
+ spawnPty(args.id, args.cwd, args.cols, args.rows, args.env);
35
+ break;
36
+ case 'write':
37
+ writePty(args.id, args.data);
38
+ break;
39
+ case 'resize':
40
+ resizePty(args.id, args.cols, args.rows);
41
+ break;
42
+ case 'kill':
43
+ killPty(args.id);
44
+ break;
45
+ default:
46
+ console.error('Unknown message type:', type);
47
+ }
48
+ }
49
+
50
+ function spawnPty(id, cwd, cols, rows, env) {
51
+ if (activePtys.has(id)) return;
52
+
53
+ try {
54
+ const shell = isWindows ? 'powershell.exe' : process.env.SHELL || 'bash';
55
+
56
+ // Merge provided env with process.env
57
+ const ptyEnv = { ...process.env, ...env };
58
+
59
+ const ptyProcess = pty.spawn(shell, [], {
60
+ name: 'xterm-256color',
61
+ cols: cols || 80,
62
+ rows: rows || 24,
63
+ cwd: cwd || process.cwd(),
64
+ env: ptyEnv,
65
+ });
66
+
67
+ activePtys.set(id, ptyProcess);
68
+
69
+ ptyProcess.onData((data) => {
70
+ send('pty:data', { ptyId: id, data });
71
+ });
72
+
73
+ ptyProcess.onExit(({ exitCode, signal }) => {
74
+ send('pty:exit', { ptyId: id, exitCode, signal });
75
+ activePtys.delete(id);
76
+ });
77
+ } catch (err) {
78
+ console.error(`Failed to spawn PTY ${id}:`, err);
79
+ send('pty:error', { ptyId: id, error: err.message });
80
+ }
81
+ }
82
+
83
+ function writePty(id, data) {
84
+ const ptyProcess = activePtys.get(id);
85
+ if (ptyProcess) {
86
+ try {
87
+ ptyProcess.write(data);
88
+ } catch (err) {
89
+ console.error(`Failed to write to PTY ${id}:`, err);
90
+ }
91
+ }
92
+ }
93
+
94
+ function resizePty(id, cols, rows) {
95
+ const ptyProcess = activePtys.get(id);
96
+ if (ptyProcess) {
97
+ try {
98
+ ptyProcess.resize(cols, rows);
99
+ } catch (err) {
100
+ console.error(`Failed to resize PTY ${id}:`, err);
101
+ }
102
+ }
103
+ }
104
+
105
+ function killPty(id) {
106
+ const ptyProcess = activePtys.get(id);
107
+ if (ptyProcess) {
108
+ try {
109
+ ptyProcess.kill();
110
+ } catch {
111
+ // ignore
112
+ }
113
+ activePtys.delete(id);
114
+ }
115
+ }
@@ -1 +0,0 @@
1
- import{d as a,j as e}from"./markdown-B7CXSXYD.js";import{$ as q,d as te,a as j,D as ce,e as oe,f as ie,g as de,B as i,aY as ue,aV as ne,S as me,I as V,a5 as xe,aZ as ke,o as he,j as fe,l as X,L as U,X as ye,ai as Ce,E as Pe,az as Se,aE as Q,t as R,q as Re,h as Ie}from"./index-BRi6al6L.js";import{A as De}from"./arrow-right-3Bby9NNK.js";import"./syntax-qKqB8BhQ.js";import"./motion-DRu4QWVj.js";const ze=[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]],ee=q("github",ze);const Fe=[["path",{d:"M10 16h.01",key:"1bzywj"}],["path",{d:"M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"18tbho"}],["path",{d:"M21.946 12.013H2.054",key:"zqlbp7"}],["path",{d:"M6 16h.01",key:"1pmjb7"}]],Me=q("hard-drive",Fe);const _e=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],Ee=q("house",_e);const Ae=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],le=q("lock",Ae);const Oe=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],Ge=q("log-out",Oe);function Le(t){if(!t)return[];const y=/^[A-Za-z]:\\/.test(t),d=y?"\\":"/",u=t.split(d).filter(Boolean),c=[];if(y){c.push({label:u[0],path:u[0]+"\\"});for(let l=1;l<u.length;l++)c.push({label:u[l],path:u.slice(0,l+1).join(d)+(l<u.length-1,"")})}else{c.push({label:"/",path:"/"});for(let l=0;l<u.length;l++)c.push({label:u[l],path:"/"+u.slice(0,l+1).join(d)})}return c}function pe({onSelect:t,onClose:y}){const{t:d}=te(),[u,c]=a.useState(""),[l,g]=a.useState(null),[v,N]=a.useState([]),[A,O]=a.useState([]),[M,_]=a.useState(""),[f,P]=a.useState(!0),[w,I]=a.useState(""),[S,r]=a.useState(""),m=a.useRef([]),h=a.useRef(-1),[E,H]=a.useState(-1),G=a.useRef(!1),Z=E>0,Y=E<m.current.length-1;a.useEffect(()=>{(async()=>{const n=await j.browseRoots();if(n.isErr()){I(n.error.message),P(!1);return}const o=n.value;O(o.roots||[]),_(o.home||"");const x=localStorage.getItem("funny:last-browse-path");if(x&&x!==o.home){const z=await j.browseList(x);z.isErr()||z.value.error?(localStorage.removeItem("funny:last-browse-path"),k(o.home)):(c(z.value.path),g(z.value.parent),N(z.value.dirs),L(z.value.path),P(!1))}else k(o.home)})()},[]);const W=a.useMemo(()=>{if(!S.trim())return v;const n=S.toLowerCase();return v.filter(o=>o.name.toLowerCase().includes(n))},[v,S]),L=a.useCallback(n=>{if(G.current){G.current=!1;return}const o=h.current;m.current=m.current.slice(0,o+1),m.current.push(n),h.current=m.current.length-1,H(h.current)},[]),k=async n=>{P(!0),I(""),r("");const o=await j.browseList(n);if(o.isErr()){I(o.error.message),P(!1);return}const x=o.value;if(x.path&&c(x.path),x.parent!==void 0&&g(x.parent),x.dirs&&N(x.dirs),x.error){I(x.error),P(!1);return}L(x.path),localStorage.setItem("funny:last-browse-path",x.path),P(!1)},C=a.useCallback(()=>{h.current<=0||(h.current--,H(h.current),G.current=!0,k(m.current[h.current]))},[]),J=a.useCallback(()=>{h.current>=m.current.length-1||(h.current++,H(h.current),G.current=!0,k(m.current[h.current]))},[]),D=a.useMemo(()=>Le(u),[u]);return e.jsx(ce,{open:!0,onOpenChange:n=>!n&&y(),children:e.jsxs(oe,{className:"max-w-md p-0 gap-0 flex flex-col",style:{height:"480px"},children:[e.jsx(ie,{className:"p-4 pb-0",children:e.jsx(de,{className:"text-sm",children:d("folderPicker.title")})}),e.jsxs("div",{className:"flex items-center gap-1 px-4 py-2 border-b border-border bg-muted/30",children:[e.jsx(i,{variant:"ghost",size:"icon",onClick:C,disabled:!Z,className:"h-6 w-6 flex-shrink-0",title:d("folderPicker.back"),children:e.jsx(ue,{className:"h-3.5 w-3.5"})}),e.jsx(i,{variant:"ghost",size:"icon",onClick:J,disabled:!Y,className:"h-6 w-6 flex-shrink-0",title:d("folderPicker.forward"),children:e.jsx(De,{className:"h-3.5 w-3.5"})}),e.jsxs("div",{className:"flex-1 flex items-center gap-0.5 overflow-x-auto no-scrollbar min-w-0",children:[D.length===0&&e.jsx("span",{className:"text-xs text-muted-foreground",children:d("folderPicker.loading")}),D.map((n,o)=>e.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[o>0&&e.jsx(ne,{className:"h-3 w-3 text-muted-foreground/50 flex-shrink-0"}),e.jsx("button",{onClick:()=>k(n.path),className:`text-xs px-1 py-0.5 rounded hover:bg-accent hover:text-foreground transition-colors truncate max-w-[120px] ${o===D.length-1?"text-foreground font-medium":"text-muted-foreground"}`,title:n.path,children:n.label})]},n.path))]})]}),e.jsxs("div",{className:"flex gap-1 px-4 py-1.5 border-b border-border",children:[e.jsxs(i,{variant:"ghost",size:"sm",onClick:()=>k(M),className:"h-6 text-xs text-muted-foreground px-2",children:[e.jsx(Ee,{className:"h-3 w-3 mr-1"}),d("folderPicker.home")]}),A.map(n=>e.jsxs(i,{variant:"ghost",size:"sm",onClick:()=>k(n),className:"h-6 text-xs text-muted-foreground px-2",title:n,children:[e.jsx(Me,{className:"h-3 w-3 mr-1"}),n.replace(":\\","")]},n))]}),!f&&v.length>0&&e.jsx("div",{className:"px-4 py-2 border-b border-border",children:e.jsxs("div",{className:"relative",children:[e.jsx(me,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-muted-foreground"}),e.jsx(V,{type:"text",value:S,onChange:n=>r(n.target.value),placeholder:d("folderPicker.searchPlaceholder"),className:"h-7 pl-7 pr-2 text-xs",autoFocus:!1})]})}),e.jsxs(xe,{className:"flex-1 p-2",children:[w&&e.jsx("p",{className:"text-xs text-status-error px-2 py-1",children:w}),f&&!w&&e.jsx("p",{className:"text-xs text-muted-foreground px-2 py-4 text-center",children:d("folderPicker.loading")}),!f&&v.length===0&&!w&&e.jsx("p",{className:"text-xs text-muted-foreground px-2 py-4 text-center",children:d("folderPicker.noSubdirs")}),!f&&v.length>0&&W.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground px-2 py-4 text-center",children:d("folderPicker.noResults")}),W.map(n=>e.jsxs("button",{onClick:()=>k(n.path),className:"w-full flex items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",children:[e.jsx(ke,{className:"h-3.5 w-3.5 flex-shrink-0 text-status-info"}),e.jsx("span",{className:"truncate",children:n.name}),e.jsx(ne,{className:"h-3 w-3 flex-shrink-0 ml-auto opacity-40"})]},n.path))]}),e.jsxs(he,{className:"p-4 border-t border-border",children:[e.jsx(i,{variant:"outline",size:"sm",onClick:y,children:d("folderPicker.cancel")}),e.jsx(i,{size:"sm",onClick:()=>t(u),disabled:!u,children:d("folderPicker.selectFolder")})]})]})})}function Ve(){const{t}=te(),y=fe(),d=X(s=>s.loadProjects),u=X(s=>s.setAddProjectOpen),[c,l]=a.useState("checking"),[g,v]=a.useState(null),[N,A]=a.useState(""),[O,M]=a.useState(""),[_,f]=a.useState(""),[P,w]=a.useState(5),[I,S]=a.useState(!1),r=a.useRef(null),[m,h]=a.useState([]),[E,H]=a.useState(""),[G,Z]=a.useState(1),[Y,W]=a.useState(!1),[L,k]=a.useState(!1),[C,J]=a.useState(null),[D,n]=a.useState(""),[o,x]=a.useState(""),[z,K]=a.useState(!1),[He,se]=a.useState(!1),T=a.useRef(null);a.useEffect(()=>{(async()=>{const s=await j.githubStatus();s.isOk()&&s.value.connected?(await ae(),l("repos")):l("connect")})()},[]);const ae=async()=>{const s=await j.githubUser();s.isOk()&&v(s.value)},$=a.useCallback(async(s,b,F=!1)=>{k(!0);const p=await j.githubRepos({page:b,per_page:30,search:s||void 0,sort:"updated"});p.isOk()&&(h(B=>F?[...B,...p.value.repos]:p.value.repos),W(p.value.hasMore)),k(!1)},[]);a.useEffect(()=>{c==="repos"&&$("",1)},[c,$]),a.useEffect(()=>{if(c==="repos")return T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{Z(1),$(E,1)},300),()=>{T.current&&clearTimeout(T.current)}},[E,c,$]),a.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]);const ge=async()=>{const s=await j.githubStartDevice();if(s.isErr()){R.error(s.error.message);return}const b=s.value;A(b.device_code),M(b.user_code),f(b.verification_uri),w(b.interval),l("device-flow"),re(b.device_code,b.interval)},re=(s,b)=>{r.current&&clearInterval(r.current),r.current=setInterval(async()=>{const F=await j.githubPoll(s);if(F.isErr())return;const p=F.value;p.status==="success"?(r.current&&clearInterval(r.current),await ae(),l("repos"),R.success(t("github.connected",{login:""}))):p.status==="expired"||p.status==="denied"?(r.current&&clearInterval(r.current),R.error(p.status==="expired"?t("github.deviceFlow.expired"):t("github.deviceFlow.denied")),l("connect")):p.interval&&(r.current&&clearInterval(r.current),re(s,p.interval))},(b+1)*1e3)},je=()=>{navigator.clipboard.writeText(O),S(!0),setTimeout(()=>S(!1),2e3)},ve=s=>{J(s),x(s.name),l("clone-config")},be=async()=>{if(!C||!D||!o)return;se(!0),l("cloning");const s=await j.cloneRepo(C.clone_url,D,o);if(s.isErr()){R.error(s.error.message),se(!1),l("clone-config");return}R.success(t("github.clone.success")),await d(),u(!1),y(`/projects/${s.value.id}`)},Ne=async()=>{await j.githubDisconnect(),v(null),h([]),l("connect"),R.success(t("github.disconnected"))},we=s=>{const b=Date.now()-new Date(s).getTime(),F=Math.floor(b/6e4);if(F<60)return t("time.minutes",{count:F});const p=Math.floor(F/60);if(p<24)return t("time.hours",{count:p});const B=Math.floor(p/24);return B<30?t("time.days",{count:B}):t("time.months",{count:Math.floor(B/30)})};return c==="checking"?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(U,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):c==="connect"?e.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-muted flex items-center justify-center",children:e.jsx(ee,{className:"h-6 w-6"})}),e.jsxs("div",{className:"text-center space-y-1",children:[e.jsx("h3",{className:"font-medium",children:t("github.connectGithub")}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-xs",children:t("github.connectDesc")})]}),e.jsxs(i,{onClick:ge,children:[e.jsx(ee,{className:"h-4 w-4 mr-2"}),t("github.connectGithub")]})]}):c==="device-flow"?e.jsxs("div",{className:"flex flex-col items-center gap-5 py-8",children:[e.jsxs("div",{className:"text-center space-y-1",children:[e.jsx("h3",{className:"font-medium",children:t("github.deviceFlow.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("github.deviceFlow.desc")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"text-2xl font-mono font-bold tracking-widest bg-muted px-4 py-2 rounded-md",children:O}),e.jsx(i,{variant:"outline",size:"sm",onClick:je,children:I?e.jsx(ye,{className:"h-4 w-4"}):e.jsx(Ce,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(i,{variant:"outline",onClick:()=>window.open(_,"_blank"),children:[e.jsx(Pe,{className:"h-4 w-4 mr-2"}),t("github.deviceFlow.openGithub")]})}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(U,{className:"h-4 w-4 animate-spin"}),t("github.deviceFlow.waitingAuth")]}),e.jsx(i,{variant:"ghost",size:"sm",className:"text-muted-foreground",onClick:()=>{r.current&&clearInterval(r.current),l("connect")},children:t("common.cancel")})]}):c==="repos"?e.jsxs("div",{className:"flex flex-col h-full",children:[g&&e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("img",{src:g.avatar_url,alt:g.login,className:"h-6 w-6 rounded-full"}),e.jsx("span",{className:"text-sm font-medium",children:g.login}),e.jsxs(i,{variant:"ghost",size:"sm",className:"ml-auto h-7 text-xs text-muted-foreground",onClick:Ne,children:[e.jsx(Ge,{className:"h-3 w-3 mr-1"}),t("github.disconnect")]})]}),e.jsxs("div",{className:"relative mb-3",children:[e.jsx(me,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(V,{className:"w-full h-auto pl-8 pr-3 py-1.5",placeholder:t("github.repos.searchPlaceholder"),value:E,onChange:s=>H(s.target.value)})]}),e.jsxs(xe,{className:"flex-1 -mx-1",children:[m.map(s=>e.jsxs("button",{onClick:()=>ve(s),className:"w-full flex flex-col gap-0.5 rounded-md px-3 py-2 text-left hover:bg-accent transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium truncate",children:s.full_name}),s.private?e.jsx(le,{className:"h-3 w-3 text-status-pending flex-shrink-0"}):e.jsx(Se,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"})]}),s.description&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[s.language&&e.jsx("span",{children:s.language}),e.jsx("span",{children:we(s.updated_at)})]})]},s.id)),L&&e.jsx("div",{className:"flex justify-center py-4",children:e.jsx(U,{className:"h-4 w-4 animate-spin text-muted-foreground"})}),!L&&m.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:t("github.repos.noRepos")}),Y&&!L&&e.jsx("div",{className:"flex justify-center py-2",children:e.jsx(i,{variant:"ghost",size:"sm",onClick:()=>{const s=G+1;Z(s),$(E,s,!0)},children:t("github.repos.loadMore")})})]})]}):c==="clone-config"&&C?e.jsxs("div",{className:"space-y-4",children:[e.jsxs(i,{variant:"ghost",size:"sm",className:"text-muted-foreground -ml-2",onClick:()=>l("repos"),children:[e.jsx(ue,{className:"h-3.5 w-3.5 mr-1"}),t("github.repos.title")]}),e.jsxs("div",{className:"rounded-md border border-border p-3 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:C.full_name}),C.private&&e.jsx(le,{className:"h-3 w-3 text-status-pending"})]}),C.description&&e.jsx("p",{className:"text-xs text-muted-foreground",children:C.description})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:t("github.clone.destination")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(V,{className:"flex-1",placeholder:t("github.clone.destinationDesc"),value:D,onChange:s=>n(s.target.value)}),e.jsx(i,{variant:"outline",size:"sm",onClick:()=>K(!0),children:e.jsx(Q,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:t("github.clone.projectName")}),e.jsx(V,{value:o,onChange:s=>x(s.target.value)})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(i,{variant:"outline",className:"flex-1",onClick:()=>l("repos"),children:t("common.cancel")}),e.jsx(i,{className:"flex-1",onClick:be,disabled:!D||!o,children:t("github.clone.cloneAndCreate")})]}),z&&e.jsx(pe,{onSelect:s=>{n(s),K(!1)},onClose:()=>K(!1)})]}):c==="cloning"?e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(U,{className:"h-8 w-8 animate-spin text-primary"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("github.clone.cloning",{repo:C?.full_name})})]}):null}function Ze(){const{t}=te(),y=fe(),d=X(r=>r.loadProjects),u=X(r=>r.setAddProjectOpen),[c,l]=a.useState("local"),[g,v]=a.useState(""),[N,A]=a.useState(""),[O,M]=a.useState(!1),[_,f]=a.useState(!1),[P,w]=a.useState(!1),I=async()=>{w(!1),f(!0);const r=await j.gitInit(N);if(r.isErr()){R.error(r.error.message),f(!1);return}const m=await j.createProject(g,N);if(m.isErr()){R.error(m.error.message),f(!1);return}await d(),u(!1),y(`/projects/${m.value.id}`),f(!1)},S=async()=>{if(!g||!N||_)return;f(!0);const r=await j.createProject(g,N);if(r.isErr()){if(r.error.message?.includes("Not a git repository")){f(!1),w(!0);return}R.error(r.error.message),f(!1);return}await d(),u(!1),y(`/projects/${r.value.id}`),f(!1)};return e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsxs("div",{className:"w-full max-w-md space-y-6 px-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("div",{className:"mx-auto w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(Re,{className:"h-6 w-6 text-primary"})}),e.jsx("h2",{className:"text-xl font-semibold",children:t("sidebar.addProject")})]}),e.jsxs("div",{className:"flex gap-1 rounded-lg bg-muted p-1",children:[e.jsxs("button",{className:`flex-1 flex items-center justify-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium transition-colors ${c==="local"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>l("local"),children:[e.jsx(Q,{className:"h-3.5 w-3.5"}),t("github.localFolder")]}),e.jsxs("button",{className:`flex-1 flex items-center justify-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium transition-colors ${c==="github"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>l("github"),children:[e.jsx(ee,{className:"h-3.5 w-3.5"}),t("github.cloneFromGithub")]})]}),c==="local"?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:t("sidebar.addProjectDescription",{defaultValue:"Enter the project name and select the folder path."})}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:t("sidebar.projectName")}),e.jsx(V,{placeholder:t("sidebar.projectName"),value:g,onChange:r=>v(r.target.value),autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:t("sidebar.absolutePath")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(V,{className:"flex-1",placeholder:t("sidebar.absolutePath"),value:N,onChange:r=>A(r.target.value)}),e.jsx(i,{variant:"outline",size:"sm",onClick:()=>M(!0),title:t("sidebar.browseFolder"),children:e.jsx(Q,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(i,{variant:"outline",className:"flex-1",onClick:()=>u(!1),children:t("common.cancel",{defaultValue:"Cancel"})}),e.jsx(i,{className:"flex-1",onClick:S,disabled:_||!g||!N,children:_?e.jsxs(e.Fragment,{children:[e.jsx(U,{className:"h-4 w-4 animate-spin mr-2"}),t("common.loading")]}):t("sidebar.add")})]})]}):e.jsx(Ve,{})]}),O&&e.jsx(pe,{onSelect:async r=>{if(A(r),M(!1),!g){const m=await j.repoName(r);if(m.isOk()&&m.value.name)v(m.value.name);else{const h=r.split(/[\\/]/).filter(Boolean).pop()||"";v(h)}}},onClose:()=>M(!1)}),e.jsx(ce,{open:P,onOpenChange:w,children:e.jsxs(oe,{children:[e.jsxs(ie,{children:[e.jsx(de,{children:t("confirm.gitInitTitle",{defaultValue:"Initialize Git Repository"})}),e.jsx(Ie,{children:t("confirm.notGitRepo",{path:N})})]}),e.jsxs(he,{children:[e.jsx(i,{variant:"outline",onClick:()=>w(!1),children:t("common.cancel",{defaultValue:"Cancel"})}),e.jsx(i,{onClick:I,children:t("confirm.gitInitAction",{defaultValue:"Initialize"})})]})]})})]})}export{Ze as AddProjectView};
@@ -1 +0,0 @@
1
- import{j as e,d as n}from"./markdown-B7CXSXYD.js";import{d as G,D as Me,e as Fe,f as Be,g as $e,h as Ee,P as Ge,i as Ke,j as pe,k as W,l as X,u as we,t as J,a as xe,m as qe,n as _e,o as He,B as Y,p as We,s as ue,c as w,q as Ne,r as ae,v as ne,w as oe,S as me,I as ze,x as Le,y as Je,z as ye,A as Ve,F as Qe,G as Xe,H as Te,J as Se,K as Ce,M as Ye,N as Ze,O as et,Q as tt,R as st,U as rt,V as at,W as Oe,X as Q,Y as ke,Z as Ie,_ as Pe}from"./index-BRi6al6L.js";import{H as De,n as V,T as nt}from"./ThreadListView-B6HvQ8NV.js";import"./syntax-qKqB8BhQ.js";import"./motion-DRu4QWVj.js";function ot({open:s,onClose:l,onSubmit:j,loading:f=!1,projectId:m}){const{t:p}=G(),x=async(h,o,g)=>{await j(h,o,g),l()};return e.jsx(Me,{open:s,onOpenChange:h=>{h||l()},children:e.jsxs(Fe,{className:"sm:max-w-3xl p-0 gap-0",children:[e.jsxs(Be,{className:"px-4 pt-4 pb-2",children:[e.jsx($e,{className:"text-sm",children:p("kanban.addThread","Add new thread")}),e.jsx(Ee,{className:"sr-only",children:p("thread.describeTask","Describe the task for the agent")})]}),e.jsx("div",{className:"px-4 pb-4",children:e.jsx(Ge,{onSubmit:x,loading:f,isNewThread:!0,projectId:m},m)})]})})}const Ae=["backlog","in_progress","review","done","archived"];function lt({thread:s,projectInfo:l,onDelete:j,search:f,ghost:m,contentSnippet:p}){const{t:x}=G(),h=pe(),o=Le(k=>k.statusByThread),g=n.useRef(null),[d,I]=n.useState(!1);n.useEffect(()=>{const k=g.current;if(k)return Je({element:k,getInitialData:()=>({type:"kanban-card",threadId:s.id,sourceStage:s.archived?"archived":s.stage||"backlog",projectId:s.projectId}),onDragStart:()=>I(!0),onDrop:()=>I(!1)})},[s.id,s.stage,s.archived,s.projectId]);const C=ye[s.status].icon,T=ye[s.status].className,P=o[s.id],b=P?Ve[P.state]:null,v=b?.icon;return e.jsxs("div",{ref:g,className:w("group/card relative rounded-md border bg-card p-2.5 cursor-pointer transition-opacity",d&&"opacity-40",m&&!d&&"opacity-50 hover:opacity-80"),onClick:()=>{d||h(`/projects/${s.projectId}/threads/${s.id}`)},children:[e.jsx("button",{className:"absolute top-1.5 right-1.5 p-1 rounded opacity-0 group-hover/card:opacity-100 transition-opacity hover:bg-destructive/10 hover:text-destructive text-muted-foreground",onClick:k=>{k.stopPropagation(),j(s)},children:e.jsx(Qe,{className:"h-3.5 w-3.5"})}),l&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded inline-block mb-1",style:{backgroundColor:l.color?`${l.color}1A`:"#3b82f61A",color:l.color||"#3b82f6"},children:l.name}),e.jsx(De,{text:s.title,query:f||"",className:"text-xs font-medium mb-1.5 line-clamp-3 pr-5 block"}),p&&f&&!V(s.title).includes(V(f))&&e.jsx(De,{text:p,query:f,className:"text-[11px] text-muted-foreground mb-1.5 line-clamp-2 block italic"}),e.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1 min-w-0",children:[e.jsx(C,{className:w("h-3 w-3 shrink-0",T)}),e.jsx("span",{className:"text-xs text-muted-foreground truncate",children:x(`thread.status.${s.status}`)}),s.provider==="external"&&e.jsx(Xe,{variant:"outline",className:"text-[10px] px-1 py-0 h-4 font-medium",children:"External"}),b&&v?e.jsxs(Te,{children:[e.jsx(Se,{asChild:!0,children:e.jsx(v,{className:w("h-3 w-3 shrink-0",b.className)})}),e.jsxs(Ce,{side:"top",className:"text-xs",children:[e.jsx("div",{children:x(b.labelKey)}),s.branch&&e.jsx("div",{className:"text-muted-foreground",children:s.branch})]})]}):s.branch?e.jsxs(Te,{children:[e.jsx(Se,{asChild:!0,children:e.jsx(Ye,{className:"h-3 w-3 shrink-0 text-muted-foreground"})}),e.jsx(Ce,{side:"top",className:"text-xs",children:s.branch})]}):null]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0 text-xs text-muted-foreground",children:[e.jsx("span",{children:Ze(s.completedAt||s.createdAt,x)}),s.cost>0&&e.jsxs("span",{children:["$",s.cost.toFixed(3)]})]})]})]})}function ct({projectId:s,projects:l,onSelect:j}){const{t:f}=G(),[m,p]=n.useState(!1),[x,h]=n.useState(""),o=n.useRef(null);if(s)return e.jsx("button",{className:"ml-auto p-0.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",onClick:()=>j(s),title:f("kanban.addThread"),children:e.jsx(Ne,{className:"h-4 w-4"})});const g=x?l.filter(d=>d.name.toLowerCase().includes(x.toLowerCase())):l;return e.jsxs(ae,{open:m,onOpenChange:d=>{p(d),d||h("")},children:[e.jsx(ne,{asChild:!0,children:e.jsx("button",{className:"ml-auto p-0.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",title:f("kanban.addThread"),children:e.jsx(Ne,{className:"h-4 w-4"})})}),e.jsxs(oe,{align:"start",className:"w-56 p-0",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-2 border-b border-border/50",children:[e.jsx(me,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),e.jsx(ze,{ref:o,value:x,onChange:d=>h(d.target.value),placeholder:f("kanban.searchProject"),className:"flex-1 h-auto border-0 bg-transparent text-xs shadow-none focus-visible:ring-0 px-0 py-0 placeholder:text-muted-foreground",autoFocus:!0})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto py-1",children:g.length===0?e.jsx("div",{className:"text-xs text-muted-foreground text-center py-3",children:f("commandPalette.noResults")}):g.map(d=>e.jsxs("button",{className:"w-full text-left px-2.5 py-1.5 text-xs hover:bg-accent transition-colors flex items-center gap-2",onClick:()=>{p(!1),h(""),j(d.id)},children:[e.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:d.color||"#3b82f6"}}),e.jsx("span",{className:"truncate",children:d.name})]},d.id))})]})]})}function dt({stage:s,threads:l,projectInfoById:j,onDelete:f,projectId:m,projects:p,onAddThread:x,search:h,contentSnippets:o}){const{t:g}=G(),d=n.useRef(null),[I,C]=n.useState(!1),[T,P]=n.useState(20);n.useEffect(()=>{const i=d.current;if(i)return We({element:i,getData:()=>({type:"kanban-column",stage:s}),canDrop:({source:$})=>$.data.type==="kanban-card",onDragEnter:()=>C(!0),onDragLeave:()=>C(!1),onDrop:()=>C(!1)})},[s]),n.useEffect(()=>{P(20)},[l.length]);const b=ue[s].icon,v=ue[s].className,k=l.slice(0,T),O=l.length>T;return e.jsxs("div",{ref:d,className:w("flex flex-col w-80 min-w-[20rem] flex-shrink-0 rounded-lg bg-secondary/30 transition-colors",I&&"ring-2 ring-ring bg-secondary/50"),children:[e.jsxs("div",{className:"px-3 py-2.5 border-b border-border/50 flex items-center gap-2",children:[e.jsx(b,{className:w("h-4 w-4",v)}),e.jsx("span",{className:"font-medium text-sm",children:g(ue[s].labelKey)}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",l.length,")"]}),p.length>0&&s!=="review"&&s!=="done"&&s!=="archived"&&e.jsx(ct,{projectId:m,projects:p,onSelect:i=>x(i,s)})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-2 space-y-2 min-h-[200px]",children:l.length===0?e.jsx("div",{className:"text-center text-xs text-muted-foreground py-8",children:g("kanban.emptyColumn")}):e.jsxs(e.Fragment,{children:[k.map(i=>e.jsx(lt,{thread:i,projectInfo:j?.[i.projectId],onDelete:f,search:h,ghost:s==="archived",contentSnippet:o?.get(i.id)},i.id)),O&&e.jsx("button",{onClick:()=>P(i=>i+20),className:"w-full py-2 text-xs text-muted-foreground hover:text-foreground hover:bg-accent rounded-md transition-colors",children:g("kanban.loadMore",{count:Math.min(20,l.length-T)})})]})})]})}function it({threads:s,projectId:l,search:j,contentSnippets:f}){const{t:m}=G();Ke();const p=pe(),x=W(r=>r.updateThreadStage),h=W(r=>r.archiveThread),o=W(r=>r.unarchiveThread),g=W(r=>r.deleteThread),d=W(r=>r.selectedThreadId),I=X(r=>r.projects),C=X(r=>r.loadThreadsForProject),T=we(r=>r.defaultThreadMode),P=we(r=>r.toolPermissions),[b,v]=n.useState(null),[k,O]=n.useState(!1),[i,$]=n.useState(void 0),[K,L]=n.useState("backlog"),[R,D]=n.useState(!1),[Z,z]=n.useState(!1),ee=n.useCallback((r,u)=>{$(r),L(u),O(!0)},[]),F=n.useCallback(r=>{v({threadId:r.id,projectId:r.projectId,title:r.title,isWorktree:r.mode==="worktree"&&!!r.branch})},[]),te=n.useCallback(async()=>{if(!b)return;z(!0);const{threadId:r,projectId:u,title:N}=b,y=d===r;await g(r,u),z(!1),v(null),J.success(m("toast.threadDeleted",{title:N})),y&&p(`/projects/${u}`)},[b,d,g,p,m]),U=n.useCallback(async(r,u,N)=>{if(!i||R)return;D(!0);const y=u.threadMode||T;if(u.sendToBacklog||K==="backlog"){const B=await xe.createIdleThread({projectId:i,title:r.slice(0,200),mode:y,baseBranch:u.baseBranch,prompt:r});if(B.isErr()){J.error(B.error.message),D(!1);return}await C(i),D(!1),J.success(m("toast.threadCreated",{title:r.slice(0,200)}))}else{const{allowedTools:B,disallowedTools:E}=qe(P),A=await xe.createThread({projectId:i,title:r.slice(0,200),mode:y,model:u.model,permissionMode:u.mode,baseBranch:u.baseBranch,prompt:r,images:N,allowedTools:B,disallowedTools:E});if(A.isErr()){J.error(A.error.message),D(!1);return}await C(i),D(!1),J.success(m("toast.threadCreated",{title:r.slice(0,200)}))}},[i,K,R,T,P,C,m]),le=n.useMemo(()=>{if(l)return;const r={};for(const u of I)r[u.id]={name:u.name,color:u.color};return r},[l,I]),q=n.useMemo(()=>{const r={backlog:[],in_progress:[],review:[],done:[],archived:[]};for(const u of s){const N=u.archived?"archived":u.stage||"backlog";r[N]&&r[N].push(u)}for(const u of Ae)r[u].sort((N,y)=>{if(N.pinned!==y.pinned)return N.pinned?-1:1;const S=N.completedAt||N.createdAt,B=y.completedAt||y.createdAt;return new Date(B).getTime()-new Date(S).getTime()});return r},[s]),_=n.useCallback(({source:r,location:u})=>{const N=u.current.dropTargets;if(!N.length||r.data.type!=="kanban-card")return;const y=r.data.threadId,S=r.data.sourceStage,B=r.data.projectId,E=N.find(ce=>ce.data.type==="kanban-column");if(!E)return;const A=E.data.stage;if(A===S)return;const H=l||B;A==="archived"?h(y,H):S==="archived"?o(y,H,A):x(y,H,A)},[l,x,h,o]);return n.useEffect(()=>_e({onDrop:_}),[_]),e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex gap-3 h-full overflow-x-auto p-4",children:Ae.map(r=>e.jsx(dt,{stage:r,threads:q[r],projectInfoById:le,onDelete:F,projectId:l,projects:I,onAddThread:ee,search:j,contentSnippets:f},r))}),e.jsx(Me,{open:!!b,onOpenChange:r=>{r||v(null)},children:e.jsxs(Fe,{className:"max-w-sm",children:[e.jsxs(Be,{children:[e.jsx($e,{children:m("dialog.deleteThread")}),e.jsx(Ee,{className:"break-all",children:m("dialog.deleteThreadDesc",{title:b?.title&&b.title.length>80?b.title.slice(0,80)+"…":b?.title})})]}),b?.isWorktree&&e.jsx("p",{className:"text-xs text-status-warning/80 bg-status-warning/10 rounded-md px-3 py-2",children:m("dialog.worktreeWarning")}),e.jsxs(He,{children:[e.jsx(Y,{variant:"outline",size:"sm",onClick:()=>v(null),children:m("common.cancel")}),e.jsx(Y,{variant:"destructive",size:"sm",onClick:te,loading:Z,children:m("common.delete")})]})]})}),e.jsx(ot,{open:k,onClose:()=>O(!1),onSubmit:U,loading:R,projectId:i})]})}const re=20;function he({label:s,options:l,selected:j,onToggle:f,counts:m}){const p=j.size,x=p===0?s:p===1?l.find(h=>j.has(h.value))?.label??s:`${s} (${p})`;return e.jsxs(ae,{children:[e.jsx(ne,{asChild:!0,children:e.jsxs("button",{className:w("inline-flex items-center gap-1 px-2 py-1 text-xs rounded-md border transition-colors whitespace-nowrap",p>0?"bg-accent text-accent-foreground border-accent-foreground/20":"bg-transparent text-muted-foreground border-border hover:bg-accent/50 hover:text-foreground"),children:[x,e.jsx(Oe,{className:"h-3 w-3 opacity-50"})]})}),e.jsx(oe,{align:"start",className:"w-auto min-w-[160px] p-1",children:l.map(h=>{const o=j.has(h.value),g=m?.[h.value];return e.jsxs("button",{onClick:()=>f(h.value),className:w("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded-sm transition-colors text-left","hover:bg-accent hover:text-accent-foreground",o&&"text-accent-foreground"),children:[e.jsx("span",{className:w("flex h-3.5 w-3.5 items-center justify-center rounded-sm border",o?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30"),children:o&&e.jsx(Q,{className:"h-2.5 w-2.5"})}),e.jsx("span",{className:"flex-1",children:h.label}),g!=null&&g>0&&e.jsx("span",{className:"text-muted-foreground tabular-nums",children:g})]},h.value)})})]})}function gt(){const{t:s}=G(),l=pe(),[j,f]=et(),m=X(t=>t.allThreadsProjectId),p=X(t=>t.threadsByProject),x=X(t=>t.projects),h=Le(t=>t.statusByThread),[o,g]=n.useState(()=>j.get("project")||null),[d,I]=n.useState(()=>{const t=j.get("view");if(t==="list"||t==="board")return t;const a=localStorage.getItem("threadViewMode");return a==="board"||a==="list"?a:"list"}),C=t=>{const a={},c=t?.project!==void 0?t.project:o,M=t?.view??d;return c&&(a.project=c),M==="board"&&(a.view="board"),a};n.useEffect(()=>{const t=j.get("project")||null,a=j.get("view");t!==o&&g(t),(a==="list"||a==="board")&&a!==d&&I(a)},[j]);const T=o?x.find(t=>t.id===o):null,P=t=>{g(t),i(1),f(C({project:t}),{replace:!0})},b=t=>{I(t),localStorage.setItem("threadViewMode",t),f(C({view:t}),{replace:!0})},[v,k]=n.useState(""),[O,i]=n.useState(1),[$,K]=n.useState(new Set),[L,R]=n.useState(new Set),[D,Z]=n.useState(new Set),[z,ee]=n.useState(!1),[F,te]=n.useState("updated"),[U,le]=n.useState("desc"),[q,_]=n.useState(new Map),r=n.useRef(void 0);n.useEffect(()=>{r.current&&clearTimeout(r.current);const t=v.trim();if(!t){_(new Map);return}return r.current=setTimeout(()=>{const a=o||void 0;xe.searchThreadContent(t,a).then(c=>{if(c.isOk()){const M=new Map,{threadIds:ie,snippets:se}=c.value;for(const ve of ie)M.set(ve,se[ve]||"");_(M)}})},300),()=>{r.current&&clearTimeout(r.current)}},[v,o]);const u=n.useMemo(()=>{const t={};for(const a of x)t[a.id]={name:a.name,color:a.color};return t},[x]),N=n.useMemo(()=>{const t={};for(const a of x)t[a.id]=a.name;return t},[x]),y=n.useMemo(()=>{const t=Object.values(p).flat();return o?t.filter(a=>a.projectId===o):t},[p,o]),S=n.useMemo(()=>d==="board"||z?y:y.filter(t=>!t.archived),[y,z,d]),B=tt(s),E=n.useMemo(()=>{let t=S;if(v.trim()){const a=V(v);t=t.filter(c=>V(c.title).includes(a)||c.branch&&V(c.branch).includes(a)||V(c.status).includes(a)||!o&&N[c.projectId]&&V(N[c.projectId]).includes(a)||q.has(c.id))}return $.size>0&&(t=t.filter(a=>$.has(a.status))),L.size>0&&(t=t.filter(a=>{const c=h[a.id];return c?L.has(c.state):!1})),D.size>0&&(t=t.filter(a=>D.has(a.mode))),t=[...t].sort((a,c)=>{const M=F==="updated"?a.completedAt??a.createdAt:a.createdAt,ie=F==="updated"?c.completedAt??c.createdAt:c.createdAt,se=new Date(M).getTime()-new Date(ie).getTime();return U==="desc"?-se:se}),t},[S,v,$,L,D,h,o,N,F,U,q]),A=Math.min(O,Math.max(1,Math.ceil(E.length/re))),H=E.slice((A-1)*re,A*re),ce=()=>{k(""),K(new Set),R(new Set),Z(new Set),ee(!1),o&&g(null),f(C({project:null}),{replace:!0}),i(1)},ge=t=>{k(t),i(1)},de=t=>a=>{t(c=>{const M=new Set(c);return M.has(a)?M.delete(a):M.add(a),M}),i(1)},fe=$.size>0||L.size>0||D.size>0||z||!!o;if(!m)return null;const je=n.useMemo(()=>{const t={};for(const a of S)t[a.status]=(t[a.status]||0)+1;return t},[S]),be=n.useMemo(()=>{const t={};for(const a of S){const c=h[a.id];c&&(t[c.state]=(t[c.state]||0)+1)}return t},[S,h]),Re=["running","waiting","completed","failed","stopped","pending","interrupted"],Ue=["dirty","unpushed","pushed","merged","clean"];return e.jsxs("div",{className:"flex-1 flex flex-col h-full min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border",children:[e.jsx(Y,{variant:"ghost",size:"icon-xs",onClick:()=>{l(o?`/projects/${o}`:"/")},className:"text-muted-foreground hover:text-foreground",children:o?e.jsx(st,{className:"h-4 w-4"}):e.jsx(me,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"text-sm font-medium",children:s(o&&T?"allThreads.title":"allThreads.globalTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:o&&T?`${T.name} · ${S.length} ${s("allThreads.threads")}`:`${x.length} ${s("allThreads.projects")} · ${S.length} ${s("allThreads.threads")}`})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"flex items-center gap-1 bg-secondary/50 rounded-md p-0.5",children:[e.jsx(Y,{variant:d==="list"?"secondary":"ghost",size:"icon-xs",onClick:()=>b("list"),className:"h-6 w-6",title:s("kanban.listView"),children:e.jsx(rt,{className:"h-3.5 w-3.5"})}),e.jsx(Y,{variant:d==="board"?"secondary":"ghost",size:"icon-xs",onClick:()=>b("board"),className:"h-6 w-6",title:s("kanban.boardView"),children:e.jsx(at,{className:"h-3.5 w-3.5"})})]})})]}),e.jsxs("div",{className:"px-4 py-2 border-b border-border/50 flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx(me,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-muted-foreground text-sm"}),e.jsx(ze,{type:"text",placeholder:s(o?"allThreads.searchPlaceholder":"allThreads.globalSearchPlaceholder"),value:v,onChange:t=>ge(t.target.value),className:"w-44 h-7 pl-6 pr-2 py-1 text-xs md:text-xs bg-transparent"})]}),e.jsx("div",{className:"w-px h-4 bg-border"}),e.jsxs(ae,{children:[e.jsx(ne,{asChild:!0,children:e.jsxs("button",{className:w("inline-flex items-center gap-1 px-2 py-1 text-xs rounded-md border transition-colors whitespace-nowrap",o?"bg-accent text-accent-foreground border-accent-foreground/20":"bg-transparent text-muted-foreground border-border hover:bg-accent/50 hover:text-foreground"),children:[o&&T?T.name:s("allThreads.filterProject"),e.jsx(Oe,{className:"h-3 w-3 opacity-50"})]})}),e.jsxs(oe,{align:"start",className:"w-auto min-w-[180px] max-h-[300px] overflow-y-auto p-1",children:[e.jsxs("button",{onClick:()=>P(null),className:w("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded-sm transition-colors text-left","hover:bg-accent hover:text-accent-foreground",!o&&"text-accent-foreground"),children:[e.jsx("span",{className:w("flex h-3.5 w-3.5 items-center justify-center rounded-full border",o?"border-muted-foreground/30":"bg-primary border-primary text-primary-foreground"),children:!o&&e.jsx(Q,{className:"h-2.5 w-2.5"})}),e.jsx("span",{className:"flex-1",children:s("allThreads.allProjects")})]}),x.map(t=>{const a=o===t.id;return e.jsxs("button",{onClick:()=>P(t.id),className:w("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded-sm transition-colors text-left","hover:bg-accent hover:text-accent-foreground",a&&"text-accent-foreground"),children:[e.jsx("span",{className:w("flex h-3.5 w-3.5 items-center justify-center rounded-full border",a?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30"),children:a&&e.jsx(Q,{className:"h-2.5 w-2.5"})}),e.jsx("span",{className:"flex-1 truncate",children:t.name})]},t.id)})]})]}),e.jsx(he,{label:s("allThreads.filterStatus"),options:Re.filter(t=>(je[t]||0)>0).map(t=>({value:t,label:B[t]})),selected:$,onToggle:de(K),counts:je}),e.jsx(he,{label:"Git",options:Ue.filter(t=>(be[t]||0)>0).map(t=>({value:t,label:s(`gitStatus.${t}`)})),selected:L,onToggle:de(R),counts:be}),e.jsx(he,{label:s("allThreads.filterMode"),options:[{value:"local",label:s("thread.mode.local")},{value:"worktree",label:s("thread.mode.worktree")}],selected:D,onToggle:de(Z)}),e.jsx("div",{className:"w-px h-4 bg-border"}),e.jsxs(ae,{children:[e.jsx(ne,{asChild:!0,children:e.jsxs("button",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs rounded-md border bg-transparent text-muted-foreground border-border hover:bg-accent/50 hover:text-foreground transition-colors whitespace-nowrap",children:[s("allThreads.sortLabel"),": ",s(F==="updated"?"allThreads.sortUpdated":"allThreads.sortCreated"),U==="desc"?e.jsx(ke,{className:"h-3 w-3"}):e.jsx(Ie,{className:"h-3 w-3"})]})}),e.jsxs(oe,{align:"start",className:"w-auto min-w-[140px] p-1",children:[e.jsxs("button",{onClick:()=>{te("updated"),i(1)},className:w("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded-sm transition-colors text-left","hover:bg-accent hover:text-accent-foreground"),children:[e.jsx("span",{className:w("flex h-3.5 w-3.5 items-center justify-center rounded-full border",F==="updated"?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30"),children:F==="updated"&&e.jsx(Q,{className:"h-2.5 w-2.5"})}),s("allThreads.sortUpdated")]}),e.jsxs("button",{onClick:()=>{te("created"),i(1)},className:w("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded-sm transition-colors text-left","hover:bg-accent hover:text-accent-foreground"),children:[e.jsx("span",{className:w("flex h-3.5 w-3.5 items-center justify-center rounded-full border",F==="created"?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30"),children:F==="created"&&e.jsx(Q,{className:"h-2.5 w-2.5"})}),s("allThreads.sortCreated")]}),e.jsx("div",{className:"h-px bg-border my-1"}),e.jsx("button",{onClick:()=>{le(t=>t==="desc"?"asc":"desc"),i(1)},className:"flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded-sm transition-colors text-left hover:bg-accent hover:text-accent-foreground",children:U==="desc"?e.jsxs(e.Fragment,{children:[e.jsx(ke,{className:"h-3 w-3"}),s("allThreads.sortDesc")]}):e.jsxs(e.Fragment,{children:[e.jsx(Ie,{className:"h-3 w-3"}),s("allThreads.sortAsc")]})})]})]}),e.jsxs("button",{onClick:()=>{ee(!z),i(1)},className:w("inline-flex items-center gap-1 px-2 py-1 text-xs rounded-md border transition-colors whitespace-nowrap",z?"bg-status-warning/10 border-status-warning/20 text-status-warning/80":"bg-transparent text-muted-foreground border-border hover:bg-accent/50 hover:text-foreground"),children:[e.jsx(Pe,{className:"h-3 w-3"}),s("allThreads.showArchived")]}),fe&&e.jsx("button",{onClick:ce,className:"px-2 py-1 text-xs text-muted-foreground hover:text-foreground transition-colors whitespace-nowrap",children:s("allThreads.clearFilters")})]}),e.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:d==="board"?e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(it,{threads:E,projectId:o||void 0,search:v,contentSnippets:q})}):e.jsx("div",{className:"px-4 py-3 h-full",children:e.jsx(nt,{className:"h-full",autoFocusSearch:!1,threads:H,totalCount:E.length,search:v,onSearchChange:ge,searchPlaceholder:s(o?"allThreads.searchPlaceholder":"allThreads.globalSearchPlaceholder"),page:A,onPageChange:i,pageSize:re,emptyMessage:s("allThreads.noThreads"),searchEmptyMessage:s("allThreads.noMatch"),onThreadClick:t=>l(`/projects/${t.projectId}/threads/${t.id}`),paginationLabel:({total:t})=>`${t} ${s("allThreads.threads")}${v||fe?` ${s("allThreads.found")}`:""}`,hideSearch:!0,renderExtraBadges:t=>{const a=h[t.id],c=a?Ve[a.state]:null;return e.jsxs(e.Fragment,{children:[!o&&u[t.projectId]&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded",style:{backgroundColor:u[t.projectId].color?`${u[t.projectId].color}1A`:"#3b82f61A",color:u[t.projectId].color||"#3b82f6"},children:u[t.projectId].name}),!!t.archived&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-xs text-status-warning/80 bg-status-warning/10 px-1.5 py-0.5 rounded",children:[e.jsx(Pe,{className:"h-2.5 w-2.5"}),s("allThreads.archived")]}),c&&e.jsx("span",{className:w("text-xs px-1.5 py-0.5 rounded bg-secondary",c.className),children:s(c.labelKey)}),e.jsx("span",{className:"text-xs text-muted-foreground bg-secondary px-1.5 py-0.5 rounded",children:s(`thread.mode.${t.mode}`)})]})}})})})]})}export{gt as AllThreadsView};