opencami 1.5.0 → 1.5.1

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 (91) hide show
  1. package/dist/client/assets/{CSPContext-EgWK8bIJ.js → CSPContext-BBLAL_m_.js} +1 -1
  2. package/dist/client/assets/{DirectionContext-DXtY05YF.js → DirectionContext-DXnZc0zz.js} +1 -1
  3. package/dist/client/assets/{_sessionKey-B89e7G3y.js → _sessionKey-BidmO1-D.js} +32 -32
  4. package/dist/client/assets/agents-CtZs_u1j.js +2 -0
  5. package/dist/client/assets/agents-screen-Basce5qo.js +1 -0
  6. package/dist/client/assets/bots-C_dWjy3z.js +2 -0
  7. package/dist/client/assets/bots-screen-n_xhYOEE.js +1 -0
  8. package/dist/client/assets/{button-nDcsaNPl.js → button-BaHefIXU.js} +1 -1
  9. package/dist/client/assets/c-BIGW1oBm.js +1 -0
  10. package/dist/client/assets/{connect-w4lLOqiJ.js → connect-DHr3hhUR.js} +1 -1
  11. package/dist/client/assets/core-BrHBc0Zp.js +12 -0
  12. package/dist/client/assets/cpp-B-lmv-kZ.js +1 -0
  13. package/dist/client/assets/csharp-K5feNrxe.js +1 -0
  14. package/dist/client/assets/css-DPfMkruS.js +1 -0
  15. package/dist/client/assets/diff-D97Zzqfu.js +1 -0
  16. package/dist/client/assets/dockerfile-BcOcwvcX.js +1 -0
  17. package/dist/client/assets/engine-javascript-PwbX1GN8.js +141 -0
  18. package/dist/client/assets/file-explorer-screen-8t6M4Xco.js +1 -0
  19. package/dist/client/assets/files-BdlpK3Cy.js +2 -0
  20. package/dist/client/assets/go-Dn2_MT6a.js +1 -0
  21. package/dist/client/assets/graphql-ChdNCCLP.js +1 -0
  22. package/dist/client/assets/html-GMplVEZG.js +1 -0
  23. package/dist/client/assets/index-B2iG4EM1.js +3 -0
  24. package/dist/client/assets/{index-36G0WCxU.js → index-GTR-Xzl2.js} +1 -1
  25. package/dist/client/assets/index-T4TOjvD0.js +1 -0
  26. package/dist/client/assets/java-CylS5w8V.js +1 -0
  27. package/dist/client/assets/javascript-wDzz0qaB.js +1 -0
  28. package/dist/client/assets/json-Cp-IABpG.js +1 -0
  29. package/dist/client/assets/jsx-g9-lgVsj.js +1 -0
  30. package/dist/client/assets/{keyboard-shortcuts-dialog-BdCeXRjD.js → keyboard-shortcuts-dialog-CcKSlK52.js} +1 -1
  31. package/dist/client/assets/kotlin-BdnUsdx6.js +1 -0
  32. package/dist/client/assets/{main-B3N0eQFg.js → main-mIHr_ble.js} +3 -3
  33. package/dist/client/assets/markdown-Cvjx9yec.js +1 -0
  34. package/dist/client/assets/{opencami-logo-DD0DPFRQ.js → opencami-logo-CRIdKbbZ.js} +1 -1
  35. package/dist/client/assets/php-CDn_0X-4.js +1 -0
  36. package/dist/client/assets/python-B6aJPvgy.js +1 -0
  37. package/dist/client/assets/react-Cfq4ot0g.js +1 -0
  38. package/dist/client/assets/regexp-CDVJQ6XC.js +1 -0
  39. package/dist/client/assets/ruby-FDmvQDUv.js +1 -0
  40. package/dist/client/assets/rust-B1yitclQ.js +1 -0
  41. package/dist/client/assets/search-dialog-D19x_xaG.js +1 -0
  42. package/dist/client/assets/{session-export-dialog-DtHKG2zW.js → session-export-dialog-DRlJwhMa.js} +1 -1
  43. package/dist/client/assets/settings-dialog-BA5FjiyP.js +1 -0
  44. package/dist/client/assets/shell-DfDnw5Jg.js +1 -0
  45. package/dist/client/assets/skills-lmNPZksG.js +2 -0
  46. package/dist/client/assets/{skills-panel-BLUjzfjJ.js → skills-panel-Cv-N_MDk.js} +2 -2
  47. package/dist/client/assets/sql-BLtJtn59.js +1 -0
  48. package/dist/client/assets/styles-JgjN_ZCd.css +1 -0
  49. package/dist/client/assets/swift-Dg5xB15N.js +1 -0
  50. package/dist/client/assets/switch-Bh9tVOYh.js +1 -0
  51. package/dist/client/assets/tabs-BfaEc9zS.js +1 -0
  52. package/dist/client/assets/toml-vGWfd6FD.js +1 -0
  53. package/dist/client/assets/tooltip-w9D-e_R-.js +1 -0
  54. package/dist/client/assets/tsx-COt5Ahok.js +1 -0
  55. package/dist/client/assets/typescript-BPQ3VLAy.js +1 -0
  56. package/dist/client/assets/{use-file-explorer-state-BnaJEqRP.js → use-file-explorer-state-CLaDuI9X.js} +2 -2
  57. package/dist/client/assets/useButton-DsMdJPGn.js +1 -0
  58. package/dist/client/assets/{useCompositeItem-BgiEMKAt.js → useCompositeItem-CaYygSfB.js} +1 -1
  59. package/dist/client/assets/{useControlled-BhUuiHAm.js → useControlled-wOKVgKF4.js} +1 -1
  60. package/dist/client/assets/{useMutation-CFmVaBag.js → useMutation-fJnleJAb.js} +1 -1
  61. package/dist/client/assets/{visuallyHidden-DCCICp6T.js → visuallyHidden-CqGRL_Oq.js} +2 -2
  62. package/dist/client/assets/vitesse-dark-D0r3Knsf.js +1 -0
  63. package/dist/client/assets/vitesse-light-CVO1_9PV.js +1 -0
  64. package/dist/client/assets/xml-sdJ4AIDG.js +1 -0
  65. package/dist/client/assets/yaml-Buea-lGh.js +1 -0
  66. package/dist/server/assets/{_sessionKey-tRze5NLR.js → _sessionKey-B5UHBd2U.js} +16 -12
  67. package/dist/server/assets/{_tanstack-start-manifest_v-CyfoMvUa.js → _tanstack-start-manifest_v-D11xMFUx.js} +1 -1
  68. package/dist/server/assets/{connect-d3AqjAqe.js → connect-CbgijWz4.js} +1 -34
  69. package/dist/server/assets/{index-CRfLKh30.js → index--_jH_0mX.js} +1 -1
  70. package/dist/server/assets/{index-CNIATlJ9.js → index-Dl2BOKP7.js} +94 -79
  71. package/dist/server/assets/{router-rn7pJO_D.js → router-DJA7GtMo.js} +4 -4
  72. package/dist/server/assets/{search-dialog-Bz4Cu0KW.js → search-dialog-C2a3OYm_.js} +45 -81
  73. package/dist/server/assets/{settings-dialog-BBM7jCjE.js → settings-dialog-CHVzrou9.js} +9 -38
  74. package/dist/server/server.js +2 -2
  75. package/package.json +2 -1
  76. package/dist/client/assets/agents-screen-1BiEZ9od.js +0 -1
  77. package/dist/client/assets/agents-x54ocA9z.js +0 -2
  78. package/dist/client/assets/bots-screen-BNQciUeJ.js +0 -1
  79. package/dist/client/assets/bots-x86ZHG4b.js +0 -2
  80. package/dist/client/assets/file-explorer-screen-CAsjd3w8.js +0 -1
  81. package/dist/client/assets/files-Bype5Mnb.js +0 -2
  82. package/dist/client/assets/index-BXkRE220.js +0 -153
  83. package/dist/client/assets/react-B16OrBeM.js +0 -1
  84. package/dist/client/assets/search-dialog-BjTPceEl.js +0 -1
  85. package/dist/client/assets/settings-dialog-hiqdk_UD.js +0 -1
  86. package/dist/client/assets/skills-DhwyFq3y.js +0 -2
  87. package/dist/client/assets/styles-CHP4l6vZ.css +0 -1
  88. package/dist/client/assets/switch-J6wLIVu2.js +0 -1
  89. package/dist/client/assets/tabs-DvPgTz5I.js +0 -1
  90. package/dist/client/assets/tooltip-C14vdXHK.js +0 -1
  91. package/dist/client/assets/useButton-Bnnac1eR.js +0 -1
@@ -5,7 +5,7 @@ import { HugeiconsIcon } from "@hugeicons/react";
5
5
  import { Search01Icon, Cancel01Icon, Loading03Icon } from "@hugeicons/core-free-icons";
6
6
  import { D as DialogRoot, a as DialogContent } from "./use-file-explorer-state-Il1LlBAe.js";
7
7
  import { useQueryClient } from "@tanstack/react-query";
8
- import { c as chatQueryKeys } from "./_sessionKey-tRze5NLR.js";
8
+ import { c as chatQueryKeys } from "./_sessionKey-B5UHBd2U.js";
9
9
  import { c as cn } from "./button-CwY2OHFj.js";
10
10
  import "@base-ui/react/dialog";
11
11
  import "@base-ui/react/menu";
@@ -21,43 +21,10 @@ import "marked";
21
21
  import "react-markdown";
22
22
  import "remark-breaks";
23
23
  import "remark-gfm";
24
- import "./index-CNIATlJ9.js";
25
- import "shiki/core";
26
- import "shiki/engine/javascript";
27
- import "@shikijs/themes/vitesse-dark";
28
- import "@shikijs/themes/vitesse-light";
29
- import "@shikijs/langs/bash";
30
- import "@shikijs/langs/c";
31
- import "@shikijs/langs/cpp";
32
- import "@shikijs/langs/csharp";
33
- import "@shikijs/langs/css";
34
- import "@shikijs/langs/diff";
35
- import "@shikijs/langs/dockerfile";
36
- import "@shikijs/langs/go";
37
- import "@shikijs/langs/graphql";
38
- import "@shikijs/langs/html";
39
- import "@shikijs/langs/java";
40
- import "@shikijs/langs/javascript";
41
- import "@shikijs/langs/json";
42
- import "@shikijs/langs/jsx";
43
- import "@shikijs/langs/kotlin";
44
- import "@shikijs/langs/markdown";
45
- import "@shikijs/langs/php";
46
- import "@shikijs/langs/python";
47
- import "@shikijs/langs/regexp";
48
- import "@shikijs/langs/ruby";
49
- import "@shikijs/langs/rust";
50
- import "@shikijs/langs/shell";
51
- import "@shikijs/langs/sql";
52
- import "@shikijs/langs/swift";
53
- import "@shikijs/langs/toml";
54
- import "@shikijs/langs/typescript";
55
- import "@shikijs/langs/tsx";
56
- import "@shikijs/langs/xml";
57
- import "@shikijs/langs/yaml";
24
+ import "./index-Dl2BOKP7.js";
58
25
  import "zustand/middleware";
59
26
  import "react-dom";
60
- import "./router-rn7pJO_D.js";
27
+ import "./router-DJA7GtMo.js";
61
28
  import "node:crypto";
62
29
  import "ws";
63
30
  import "node:fs";
@@ -160,58 +127,55 @@ function useSearch({ sessions, currentFriendlyId, currentSessionKey }) {
160
127
  throw new DOMException("Search aborted", "AbortError");
161
128
  }
162
129
  const batch = sessions.slice(i, i + BATCH_SIZE);
163
- const batchResults = await Promise.all(
130
+ const batchSettled = await Promise.allSettled(
164
131
  batch.map(async (session) => {
165
- try {
166
- const historyKey = chatQueryKeys.history(session.friendlyId, session.key);
167
- let historyData = queryClient.getQueryData(historyKey);
168
- if (!historyData) {
169
- const params = new URLSearchParams({
132
+ const historyKey = chatQueryKeys.history(session.friendlyId, session.key);
133
+ let historyData = queryClient.getQueryData(historyKey);
134
+ if (!historyData) {
135
+ const params = new URLSearchParams({
136
+ sessionKey: session.key,
137
+ friendlyId: session.friendlyId,
138
+ limit: "200"
139
+ });
140
+ const res = await fetch(`/api/history?${params.toString()}`, {
141
+ signal: controller.signal
142
+ });
143
+ if (res.ok) {
144
+ historyData = await res.json();
145
+ queryClient.setQueryData(historyKey, historyData);
146
+ }
147
+ }
148
+ if (!historyData?.messages) return [];
149
+ const sessionTitle = session.label || session.title || session.derivedTitle || session.friendlyId;
150
+ const sessionResults = [];
151
+ historyData.messages.forEach((message, index) => {
152
+ const text = extractTextFromMessage(message);
153
+ if (!text) return;
154
+ const lowerText = text.toLowerCase();
155
+ const matchIndex = lowerText.indexOf(normalizedQuery);
156
+ if (matchIndex !== -1) {
157
+ sessionResults.push({
170
158
  sessionKey: session.key,
171
159
  friendlyId: session.friendlyId,
172
- limit: "200"
173
- });
174
- const res = await fetch(`/api/history?${params.toString()}`, {
175
- signal: controller.signal
160
+ sessionTitle,
161
+ messageIndex: index,
162
+ messageId: typeof message.id === "string" ? message.id : void 0,
163
+ messageRole: message.role || "unknown",
164
+ messageText: text,
165
+ matchStart: matchIndex,
166
+ matchEnd: matchIndex + trimmedQuery.length,
167
+ timestamp: message.timestamp
176
168
  });
177
- if (res.ok) {
178
- historyData = await res.json();
179
- queryClient.setQueryData(historyKey, historyData);
180
- }
181
169
  }
182
- if (!historyData?.messages) return [];
183
- const sessionTitle = session.label || session.title || session.derivedTitle || session.friendlyId;
184
- const sessionResults = [];
185
- historyData.messages.forEach((message, index) => {
186
- const text = extractTextFromMessage(message);
187
- if (!text) return;
188
- const lowerText = text.toLowerCase();
189
- const matchIndex = lowerText.indexOf(normalizedQuery);
190
- if (matchIndex !== -1) {
191
- sessionResults.push({
192
- sessionKey: session.key,
193
- friendlyId: session.friendlyId,
194
- sessionTitle,
195
- messageIndex: index,
196
- messageId: typeof message.id === "string" ? message.id : void 0,
197
- messageRole: message.role || "unknown",
198
- messageText: text,
199
- matchStart: matchIndex,
200
- matchEnd: matchIndex + trimmedQuery.length,
201
- timestamp: message.timestamp
202
- });
203
- }
204
- });
205
- return sessionResults;
206
- } catch (error) {
207
- if (error instanceof DOMException && error.name === "AbortError") {
208
- throw error;
209
- }
210
- return [];
211
- }
170
+ });
171
+ return sessionResults;
212
172
  })
213
173
  );
214
- allResults.push(...batchResults.flat());
174
+ for (const result of batchSettled) {
175
+ if (result.status === "fulfilled") {
176
+ allResults.push(...result.value);
177
+ }
178
+ }
215
179
  allResults.sort((a, b) => (b.timestamp || 0) - (a.timestamp || 0));
216
180
  setGlobalResults([...allResults]);
217
181
  }
@@ -6,8 +6,8 @@ import { Cancel01Icon, Link01Icon, PaintBoardIcon, MessageEdit01Icon, UserIcon,
6
6
  import { D as DialogRoot, a as DialogContent, b as DialogTitle, c as DialogDescription, d as DialogClose } from "./use-file-explorer-state-Il1LlBAe.js";
7
7
  import { S as Switch } from "./switch-BbkUeVDV.js";
8
8
  import { T as Tabs, a as TabsList, b as TabsTab } from "./tabs-DDFZob0m.js";
9
- import { u as useChatSettings } from "./index-CNIATlJ9.js";
10
- import { u as useLlmSettings, g as getLlmProviderDefaults } from "./_sessionKey-tRze5NLR.js";
9
+ import { u as useChatSettings } from "./index-Dl2BOKP7.js";
10
+ import { u as useLlmSettings, g as getLlmProviderDefaults } from "./_sessionKey-B5UHBd2U.js";
11
11
  import "@base-ui/react/merge-props";
12
12
  import "@base-ui/react/use-render";
13
13
  import "class-variance-authority";
@@ -18,39 +18,6 @@ import "@base-ui/react/menu";
18
18
  import "zustand";
19
19
  import "@base-ui/react/switch";
20
20
  import "@base-ui/react/tabs";
21
- import "shiki/core";
22
- import "shiki/engine/javascript";
23
- import "@shikijs/themes/vitesse-dark";
24
- import "@shikijs/themes/vitesse-light";
25
- import "@shikijs/langs/bash";
26
- import "@shikijs/langs/c";
27
- import "@shikijs/langs/cpp";
28
- import "@shikijs/langs/csharp";
29
- import "@shikijs/langs/css";
30
- import "@shikijs/langs/diff";
31
- import "@shikijs/langs/dockerfile";
32
- import "@shikijs/langs/go";
33
- import "@shikijs/langs/graphql";
34
- import "@shikijs/langs/html";
35
- import "@shikijs/langs/java";
36
- import "@shikijs/langs/javascript";
37
- import "@shikijs/langs/json";
38
- import "@shikijs/langs/jsx";
39
- import "@shikijs/langs/kotlin";
40
- import "@shikijs/langs/markdown";
41
- import "@shikijs/langs/php";
42
- import "@shikijs/langs/python";
43
- import "@shikijs/langs/regexp";
44
- import "@shikijs/langs/ruby";
45
- import "@shikijs/langs/rust";
46
- import "@shikijs/langs/shell";
47
- import "@shikijs/langs/sql";
48
- import "@shikijs/langs/swift";
49
- import "@shikijs/langs/toml";
50
- import "@shikijs/langs/typescript";
51
- import "@shikijs/langs/tsx";
52
- import "@shikijs/langs/xml";
53
- import "@shikijs/langs/yaml";
54
21
  import "zustand/middleware";
55
22
  import "@tanstack/react-router";
56
23
  import "@tanstack/react-query";
@@ -66,7 +33,7 @@ import "react-markdown";
66
33
  import "remark-breaks";
67
34
  import "remark-gfm";
68
35
  import "react-dom";
69
- import "./router-rn7pJO_D.js";
36
+ import "./router-DJA7GtMo.js";
70
37
  import "node:crypto";
71
38
  import "ws";
72
39
  import "node:fs";
@@ -545,8 +512,7 @@ function SettingsDialog({
545
512
  { value: "light", label: "Light", icon: Sun01Icon },
546
513
  { value: "dark", label: "Dark", icon: Moon01Icon },
547
514
  { value: "chameleon", label: "Cham", icon: Leaf01Icon },
548
- { value: "frost-light", label: "Ice", icon: DropletIcon },
549
- { value: "frost-dark", label: "Noir", icon: DropletIcon }
515
+ { value: "frost-light", label: "Ice", icon: DropletIcon }
550
516
  ];
551
517
  function applyTheme(theme) {
552
518
  if (typeof document === "undefined") return;
@@ -1028,6 +994,11 @@ function SettingsDialog({
1028
994
  /* @__PURE__ */ jsxs("div", { className: "mt-4 pt-3 border-t border-primary-100", children: [
1029
995
  /* @__PURE__ */ jsx("div", { className: "text-sm text-primary-800 mb-2", children: llmSettings.llmProvider === "ollama" ? "API Key (optional)" : "API Key" }),
1030
996
  /* @__PURE__ */ jsx("div", { className: "text-xs text-primary-500 mb-2", children: llmSettings.llmProvider === "ollama" ? "Not required for local Ollama" : llmStatus.hasEnvKey && llmSettings.llmProvider === "openai" ? "Optional: Override server key with your own" : `Required for ${llmSettings.llmProvider === "openrouter" ? "OpenRouter" : "LLM features"} (stored locally)` }),
997
+ /* @__PURE__ */ jsxs("div", { className: "text-xs text-amber-600 bg-amber-50 border border-amber-200 rounded-md px-2 py-1.5 mb-2", children: [
998
+ "⚠️ ",
999
+ /* @__PURE__ */ jsx("strong", { children: "Security Note:" }),
1000
+ " API keys are stored in your browser's localStorage. This is convenient but not secure for shared computers. For production use, configure keys server-side via environment variables (OPENAI_API_KEY, OPENROUTER_API_KEY)."
1001
+ ] }),
1031
1002
  /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
1032
1003
  /* @__PURE__ */ jsx(
1033
1004
  "input",
@@ -184,7 +184,7 @@ function getResponse() {
184
184
  return event.res;
185
185
  }
186
186
  async function getStartManifest(matchedRoutes) {
187
- const { tsrStartManifest } = await import("./assets/_tanstack-start-manifest_v-CyfoMvUa.js");
187
+ const { tsrStartManifest } = await import("./assets/_tanstack-start-manifest_v-D11xMFUx.js");
188
188
  const startManifest = tsrStartManifest();
189
189
  const rootRoute = startManifest.routes[rootRouteId] = startManifest.routes[rootRouteId] || {};
190
190
  rootRoute.assets = rootRoute.assets || [];
@@ -656,7 +656,7 @@ function getStartResponseHeaders(opts) {
656
656
  let entriesPromise;
657
657
  let manifestPromise;
658
658
  async function loadEntries() {
659
- const routerEntry = await import("./assets/router-rn7pJO_D.js").then((n) => n.r);
659
+ const routerEntry = await import("./assets/router-DJA7GtMo.js").then((n) => n.r);
660
660
  const startEntry = await import("./assets/start-HYkvq4Ni.js");
661
661
  return { startEntry, routerEntry };
662
662
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencami",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "type": "module",
5
5
  "description": "OpenCami - A beautiful web client for OpenClaw",
6
6
  "bin": {
@@ -79,6 +79,7 @@
79
79
  "@tauri-apps/api": "^2.10.1",
80
80
  "@tauri-apps/cli": "^2.10.0",
81
81
  "@testing-library/dom": "^10.4.0",
82
+ "@testing-library/jest-dom": "^6.9.1",
82
83
  "@testing-library/react": "^16.2.0",
83
84
  "@types/node": "^22.10.2",
84
85
  "@types/react": "^19.2.0",
@@ -1 +0,0 @@
1
- import{u as L,r as t,j as e,L as O}from"./main-B3N0eQFg.js";import{u as Q,m as S,A as P}from"./visuallyHidden-DCCICp6T.js";import{c as B,j as U,B as f,H as p,I as q,C as K,ag as R,r as I,ah as V,h as H,V as G,ai as J}from"./button-nDcsaNPl.js";import{S as _}from"./switch-J6wLIVu2.js";import{s as X,e as Y,f as Z,g as $,h as ee,i as se,j as W}from"./tooltip-C14vdXHK.js";import{O as re,a as ae}from"./opencami-logo-DD0DPFRQ.js";import"./useControlled-BhUuiHAm.js";import"./useButton-Bnnac1eR.js";import"./DirectionContext-DXtY05YF.js";async function te(){const s=await fetch("/api/agents");if(!s.ok)throw new Error("Failed to fetch agents");return(await s.json()).agents??[]}async function E(s){return await(await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})).json()}function ie({agent:s,onEdit:d,onDelete:n}){const c=s.isDefault||s.id==="main",l=s.name||s.id.charAt(0).toUpperCase()+s.id.slice(1),m=s.model?s.model.split("/").pop():void 0;return e.jsx("div",{className:"group rounded-lg border border-primary-100 bg-surface p-4 transition-all duration-150 ease-out hover:border-primary-200 hover:shadow-sm",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("div",{className:"relative flex size-12 shrink-0 items-center justify-center rounded-lg bg-primary-50 text-xl",children:[s.emoji||"🤖",c&&e.jsx("span",{className:"absolute -top-1 -right-1 size-3 rounded-full bg-emerald-500 ring-2 ring-surface"})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("h4",{className:"text-[13px] font-semibold text-primary-900 leading-tight truncate",children:l}),l!==s.id&&e.jsx("span",{className:"text-[10px] font-mono text-primary-400 shrink-0",children:s.id})]}),c&&e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 text-[11px] font-medium rounded-full bg-emerald-50 text-emerald-600 border border-emerald-100 shrink-0",children:"Primary"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-3",children:[m&&e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 text-[10px] font-mono rounded-full bg-primary-50 text-primary-600 border border-primary-100 truncate max-w-[200px]",children:m}),s.sandbox!==void 0&&e.jsx("span",{className:B("inline-flex items-center px-2 py-0.5 text-[10px] font-medium rounded-full border",s.sandbox?"bg-amber-50 text-amber-600 border-amber-100":"bg-primary-50 text-primary-500 border-primary-100"),children:s.sandbox?"🔒 Sandbox":"🔓 Open"}),s.sessionScope&&e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 text-[10px] font-medium rounded-full bg-primary-50 text-primary-500 border border-primary-100",children:s.sessionScope==="per-sender"?"👤 Per-sender":"🌐 Global"})]}),s.tools&&s.tools.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1 mb-2",children:[s.tools.slice(0,6).map(i=>e.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 text-[10px] font-mono rounded bg-sky-50 text-sky-600 border border-sky-100",children:i},i)),s.tools.length>6&&e.jsxs("span",{className:"text-[10px] text-primary-400",children:["+",s.tools.length-6," more"]})]}),s.channelBindings&&s.channelBindings.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:s.channelBindings.map(i=>e.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 text-[10px] rounded bg-violet-50 text-violet-600 border border-violet-100",children:["#",i]},i))}),e.jsxs("div",{className:"flex items-center gap-3 pt-2 border-t border-primary-50",children:[s.workspace&&e.jsx("span",{className:"text-[11px] font-mono text-primary-400 truncate",title:s.workspace,children:s.workspace}),s.activeSessions!==void 0&&s.activeSessions>0&&e.jsxs("span",{className:"text-[11px] text-primary-400",children:[s.activeSessions," active session",s.activeSessions!==1?"s":""]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity duration-150",children:[e.jsx(f,{size:"icon-sm",variant:"ghost",onClick:d,"aria-label":"Edit agent",children:e.jsx(p,{icon:V,size:16,strokeWidth:1.5})}),!c&&e.jsx(f,{size:"icon-sm",variant:"ghost",onClick:n,"aria-label":"Delete agent",className:"text-red-500 hover:text-red-600",children:e.jsx(p,{icon:H,size:16,strokeWidth:1.5})})]})]})})}function D({label:s,placeholder:d,values:n,onChange:c}){const[l,m]=t.useState(""),i=o=>{(o.key==="Enter"||o.key===",")&&l.trim()&&(o.preventDefault(),n.includes(l.trim())||c([...n,l.trim()]),m("")),o.key==="Backspace"&&!l&&n.length>0&&c(n.slice(0,-1))};return e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-primary-600 mb-1",children:s}),e.jsxs("div",{className:"flex flex-wrap gap-1 p-2 rounded-md border border-primary-200 bg-surface min-h-[36px]",children:[n.map(o=>e.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-primary-100 px-2 py-0.5 text-xs text-primary-700",children:[o,e.jsx("button",{onClick:()=>c(n.filter(x=>x!==o)),className:"text-primary-400 hover:text-primary-600",children:"×"})]},o)),e.jsx("input",{value:l,onChange:o=>m(o.target.value),onKeyDown:i,placeholder:n.length===0?d:"",className:"flex-1 min-w-[80px] bg-transparent text-sm outline-none"})]})]})}function F({agent:s,onSave:d,onCancel:n,saving:c}){const[l,m]=t.useState(s?.name??""),[i,o]=t.useState(s?.workspace??""),[x,g]=t.useState(s?.emoji??""),[u,v]=t.useState(s?.avatar??""),[b,N]=t.useState(s?.model??""),[w,M]=t.useState(s?.sandbox??!1),[h,z]=t.useState(s?.tools??[]),[j,y]=t.useState(s?.deniedTools??[]),[k,A]=t.useState(s?.channelBindings??[]),[C,T]=t.useState(s?.sessionScope??"per-sender"),r=!!s;return e.jsxs("div",{className:"max-w-2xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h2",{className:"text-lg font-semibold text-primary-900",children:r?"Edit Agent":"Create Agent"}),e.jsx(f,{size:"icon-sm",variant:"ghost",onClick:n,children:e.jsx(p,{icon:G,size:18,strokeWidth:1.5})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"rounded-lg border border-primary-100 bg-surface p-4",children:[e.jsx("h3",{className:"text-xs font-medium text-primary-400 uppercase tracking-wider mb-3",children:"Basic Info"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"col-span-2 sm:col-span-1",children:[e.jsx("label",{className:"block text-xs text-primary-600 mb-1",children:"Name"}),e.jsx("input",{value:l,onChange:a=>m(a.target.value),placeholder:"my-agent",className:"w-full rounded-md border border-primary-200 bg-surface px-3 py-1.5 text-sm focus:outline-none focus:ring-2 focus:ring-primary-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-primary-600 mb-1",children:"Emoji"}),e.jsx("input",{value:x,onChange:a=>g(a.target.value),placeholder:"🤖",className:"w-full rounded-md border border-primary-200 bg-surface px-3 py-1.5 text-sm focus:outline-none focus:ring-2 focus:ring-primary-500"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"block text-xs text-primary-600 mb-1",children:"Avatar URL"}),e.jsx("input",{value:u,onChange:a=>v(a.target.value),placeholder:"https://...",className:"w-full rounded-md border border-primary-200 bg-surface px-3 py-1.5 text-sm font-mono focus:outline-none focus:ring-2 focus:ring-primary-500"})]})]})]}),e.jsxs("div",{className:"rounded-lg border border-primary-100 bg-surface p-4",children:[e.jsx("h3",{className:"text-xs font-medium text-primary-400 uppercase tracking-wider mb-3",children:"Model & Config"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-primary-600 mb-1",children:"Model"}),e.jsx("input",{value:b,onChange:a=>N(a.target.value),placeholder:"anthropic/claude-sonnet-4-20250514",className:"w-full rounded-md border border-primary-200 bg-surface px-3 py-1.5 text-sm font-mono focus:outline-none focus:ring-2 focus:ring-primary-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-primary-600 mb-1",children:"Workspace Path"}),e.jsx("input",{value:i,onChange:a=>o(a.target.value),placeholder:"/root/.openclaw/workspace-myagent",className:"w-full rounded-md border border-primary-200 bg-surface px-3 py-1.5 text-sm font-mono focus:outline-none focus:ring-2 focus:ring-primary-500"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-primary-800",children:"Sandbox Mode"}),e.jsx("div",{className:"text-xs text-primary-500",children:"Run agent in isolated sandbox"})]}),e.jsx(_,{checked:w,onCheckedChange:M})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-primary-600 mb-1",children:"Session Scope"}),e.jsxs("select",{value:C,onChange:a=>T(a.target.value),className:"w-full rounded-md border border-primary-200 bg-surface px-3 py-1.5 text-sm focus:outline-none focus:ring-2 focus:ring-primary-500",children:[e.jsx("option",{value:"per-sender",children:"Per-sender"}),e.jsx("option",{value:"global",children:"Global"})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border border-primary-100 bg-surface p-4",children:[e.jsx("h3",{className:"text-xs font-medium text-primary-400 uppercase tracking-wider mb-3",children:"Tools"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(D,{label:"Allowed Tools",placeholder:"Type tool name and press Enter",values:h,onChange:z}),e.jsx(D,{label:"Denied Tools",placeholder:"Type tool name and press Enter",values:j,onChange:y})]})]}),e.jsxs("div",{className:"rounded-lg border border-primary-100 bg-surface p-4",children:[e.jsx("h3",{className:"text-xs font-medium text-primary-400 uppercase tracking-wider mb-3",children:"Channel Bindings"}),e.jsx(D,{label:"Bound Channels",placeholder:"Type channel name and press Enter",values:k,onChange:A})]})]}),e.jsxs("div",{className:"mt-6 flex justify-end gap-2",children:[e.jsx(f,{size:"sm",variant:"outline",onClick:n,children:"Cancel"}),e.jsx(f,{size:"sm",onClick:()=>d({name:l,workspace:i,emoji:x,model:b,avatar:u,sandbox:w,tools:h,deniedTools:j,channelBindings:k,sessionScope:C}),disabled:!l.trim()||c,children:c?e.jsx(p,{icon:I,size:16,className:"animate-spin"}):r?"Save Changes":"Create Agent"})]})]})}function ne({agent:s,onConfirm:d,onCancel:n,deleting:c}){const[l,m]=t.useState(!1);return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:n,children:e.jsxs("div",{className:"w-[min(380px,90vw)] rounded-xl border border-primary-200 bg-surface p-5 shadow-xl",onClick:i=>i.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(p,{icon:J,size:20,className:"text-red-500"}),e.jsx("h3",{className:"text-sm font-medium text-primary-900",children:"Delete Agent"})]}),e.jsxs("p",{className:"text-sm text-primary-600 mb-4",children:["Are you sure you want to delete ",e.jsx("strong",{children:s.name}),"? This cannot be undone."]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-primary-700 mb-4 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:l,onChange:i=>m(i.target.checked),className:"rounded border-primary-300"}),"Also delete workspace files"]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(f,{size:"sm",variant:"outline",onClick:n,children:"Cancel"}),e.jsx(f,{size:"sm",onClick:()=>d(l),disabled:c,className:"bg-red-600 text-white hover:bg-red-700",children:c?e.jsx(p,{icon:I,size:16,className:"animate-spin"}):"Delete"})]})]})})}function fe(){const s=L(),[d,n]=t.useState([]),[c,l]=t.useState(!0),[m,i]=t.useState(null),[o,x]=t.useState(!1),[g,u]=t.useState("list"),[v,b]=t.useState(null),[N,w]=t.useState(null),h=Q({queryKey:se,queryFn:function(){return W(s)},initialData:function(){return W(s)},staleTime:1/0}).data?.isSidebarCollapsed??!1,z=t.useCallback(()=>{X(s,function(a){return{...a,isSidebarCollapsed:!a.isSidebarCollapsed}})},[s]),j=t.useMemo(()=>({duration:.15,ease:h?"easeIn":"easeOut"}),[h]),y=t.useCallback(async()=>{try{i(null);const r=await te();n(r)}catch(r){i(r instanceof Error?r.message:"Failed to load agents")}finally{l(!1)}},[]);t.useEffect(()=>{y()},[y]);const k=async r=>{x(!0);try{const a=await E({action:"create",name:r.name,workspace:r.workspace||void 0,emoji:r.emoji||void 0,avatar:r.avatar||void 0});if(a.error){i(a.error);return}u("list"),await y()}finally{x(!1)}},A=async r=>{if(v){x(!0);try{const a=await E({action:"update",agentId:v.id,name:r.name||void 0,workspace:r.workspace||void 0,model:r.model||void 0,avatar:r.avatar||void 0});if(a.error){i(a.error);return}b(null),u("list"),await y()}finally{x(!1)}}},C=async r=>{if(N){x(!0);try{const a=await E({action:"delete",agentId:N.id,deleteFiles:r});if(a.error){i(a.error);return}w(null),await y()}finally{x(!1)}}},T=e.jsxs(S.aside,{initial:!1,animate:{width:h?48:300},transition:j,className:"border-r border-primary-200 h-full overflow-hidden bg-primary-100 flex flex-col",children:[e.jsxs(S.div,{layout:!0,transition:{layout:j},className:"flex items-center h-12 px-2 justify-between",children:[e.jsx(P,{initial:!1,children:h?null:e.jsx(S.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:j,children:e.jsxs(O,{to:"/new",className:B(U({variant:"ghost",size:"sm"}),"w-full pl-1.5 justify-start"),children:[e.jsx(re,{className:"size-5"}),e.jsx(ae,{})]})})}),e.jsx(Y,{children:e.jsxs(Z,{children:[e.jsx($,{onClick:z,render:e.jsx(f,{size:"icon-sm",variant:"ghost",children:e.jsx(p,{icon:q,size:20,strokeWidth:1.5})})}),e.jsx(ee,{side:"right",children:h?"Open Sidebar":"Close Sidebar"})]})})]}),e.jsx("div",{className:"px-2 mb-4",children:e.jsxs(O,{to:"/",className:B(U({variant:"ghost",size:"sm"}),"w-full pl-1.5 justify-start"),children:[e.jsx(p,{icon:K,size:20,strokeWidth:1.5,className:"min-w-5"}),e.jsx(P,{initial:!1,mode:"wait",children:!h&&e.jsx(S.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:j,className:"overflow-hidden whitespace-nowrap",children:"Back to Chat"})})]})})]});return e.jsx("div",{className:"h-screen bg-surface text-primary-900",children:e.jsxs("div",{className:"h-full overflow-hidden grid grid-cols-[auto_1fr]",children:[T,e.jsxs("main",{"aria-label":"Agent manager",className:"flex flex-col h-full min-h-0",children:[e.jsx("header",{className:"border-b border-primary-200 px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-primary-900",children:"Agents"}),e.jsxs("p",{className:"text-xs text-primary-500 mt-0.5",children:[d.length," agent",d.length!==1?"s":""," configured"]})]}),g==="list"&&e.jsxs(f,{size:"sm",onClick:()=>{b(null),u("create")},children:[e.jsx(p,{icon:R,size:16,strokeWidth:1.5}),e.jsx("span",{className:"ml-1",children:"Create Agent"})]})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-auto p-6",children:[m&&e.jsx("div",{className:"mb-4 rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 p-3 text-sm text-red-600 dark:text-red-400",children:m}),c?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(p,{icon:I,size:24,className:"animate-spin text-primary-400"})}):g==="list"?e.jsxs("div",{className:"max-w-3xl mx-auto space-y-3",children:[d.map(r=>e.jsx(ie,{agent:r,onEdit:()=>{b(r),u("edit")},onDelete:()=>w(r)},r.id)),d.length===0&&e.jsxs("div",{className:"py-12 text-center",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-lg bg-primary-50 mb-3",children:e.jsx("span",{className:"text-2xl",children:"🤖"})}),e.jsx("p",{className:"text-sm text-primary-500",children:"No agents found"}),e.jsx("p",{className:"text-xs text-primary-400 mt-1",children:"Create one to get started"})]})]}):g==="create"?e.jsx(F,{onSave:k,onCancel:()=>u("list"),saving:o}):g==="edit"&&v?e.jsx(F,{agent:v,onSave:A,onCancel:()=>{b(null),u("list")},saving:o}):null]}),N&&e.jsx(ne,{agent:N,onConfirm:C,onCancel:()=>w(null),deleting:o})]})]})})}export{fe as AgentsScreen};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/agents-screen-1BiEZ9od.js","assets/main-B3N0eQFg.js","assets/visuallyHidden-DCCICp6T.js","assets/button-nDcsaNPl.js","assets/switch-J6wLIVu2.js","assets/useControlled-BhUuiHAm.js","assets/useButton-Bnnac1eR.js","assets/tooltip-C14vdXHK.js","assets/DirectionContext-DXtY05YF.js","assets/opencami-logo-DD0DPFRQ.js"])))=>i.map(i=>d[i]);
2
- import{j as e,r as t,_ as r}from"./main-B3N0eQFg.js";const n=t.lazy(()=>r(()=>import("./agents-screen-1BiEZ9od.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])).then(s=>({default:s.AgentsScreen})));function o(){return e.jsx(t.Suspense,{fallback:e.jsx("div",{className:"flex h-screen items-center justify-center text-primary-500 text-sm",children:"Loading…"}),children:e.jsx(n,{})})}export{o as component};
@@ -1 +0,0 @@
1
- import{u as g,j as e,r as f,L as v}from"./main-B3N0eQFg.js";import{H as o,r as h,c as d,i as x,L as w,B as k,af as C,m as b,C as E}from"./button-nDcsaNPl.js";import{S}from"./switch-J6wLIVu2.js";import{u as j,m as M,A as $}from"./visuallyHidden-DCCICp6T.js";import{u as N}from"./useMutation-CFmVaBag.js";import"./useControlled-BhUuiHAm.js";import"./useButton-Bnnac1eR.js";const y=["cron-jobs"];function A(){return j({queryKey:y,queryFn:async({signal:r})=>{const t=new AbortController,n=()=>t.abort();r.addEventListener("abort",n);try{const s=await fetch("/api/cron",{signal:t.signal});if(!s.ok)throw new Error("Failed to fetch cron jobs");const i=await s.json();return Array.isArray(i.jobs)?i.jobs:[]}finally{r.removeEventListener("abort",n)}},refetchInterval:3e4})}function D(r){return j({queryKey:["cron-job-runs",r],queryFn:async({signal:t})=>{if(!r)return[];const n=new AbortController,s=()=>n.abort();t.addEventListener("abort",s);try{const i=await fetch(`/api/cron?jobId=${encodeURIComponent(r)}`,{signal:n.signal});if(!i.ok)throw new Error("Failed to fetch cron job runs");const l=await i.json();return Array.isArray(l.runs)?l.runs:[]}finally{t.removeEventListener("abort",s)}},enabled:!!r})}function L(){const r=g();return N({mutationFn:async t=>{const n=new AbortController,s=await fetch("/api/cron",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jobId:t}),signal:n.signal});if(!s.ok)throw new Error("Failed to run cron job");return s.json()},onSuccess:()=>{r.invalidateQueries({queryKey:y})}})}function R(){const r=g();return N({mutationFn:async({jobId:t,enabled:n})=>{const s=new AbortController,i=await fetch("/api/cron",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({jobId:t,patch:{enabled:n}}),signal:s.signal});if(!i.ok)throw new Error("Failed to update cron job");return i.json()},onSuccess:()=>{r.invalidateQueries({queryKey:y})}})}function J(r){return!r||r<=0?"—":r<1e3?`${r}ms`:r<6e4?`${(r/1e3).toFixed(1)}s`:`${(r/6e4).toFixed(1)}m`}function z(r){return r?new Date(r).toLocaleString():"—"}function F({job:r}){const t=D(r.id),n=t.data??[];return e.jsx(M.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},className:"overflow-hidden",children:e.jsxs("div",{className:"space-y-4 border-t border-primary-100 bg-primary-50/50 px-4 py-4",children:[(r.payload.message||r.payload.prompt)&&e.jsxs("div",{children:[e.jsx("h5",{className:"text-xs font-medium text-primary-400 uppercase tracking-wider mb-2",children:"Prompt / Message"}),e.jsx("p",{className:"whitespace-pre-wrap break-words rounded-lg bg-surface border border-primary-100 p-3 text-sm text-primary-700 leading-relaxed",children:r.payload.message??r.payload.prompt})]}),r.delivery&&e.jsxs("div",{children:[e.jsx("h5",{className:"text-xs font-medium text-primary-400 uppercase tracking-wider mb-2",children:"Delivery"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.delivery.mode&&e.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 text-[11px] font-medium rounded-full bg-surface text-primary-600 border border-primary-100",children:["Mode: ",r.delivery.mode]}),r.delivery.channel&&e.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 text-[11px] font-medium rounded-full bg-surface text-primary-600 border border-primary-100",children:["Channel: ",r.delivery.channel]}),r.delivery.to&&e.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 text-[11px] font-medium rounded-full bg-surface text-primary-600 border border-primary-100",children:["To: ",r.delivery.to]})]})]}),r.payload.model&&e.jsxs("div",{children:[e.jsx("h5",{className:"text-xs font-medium text-primary-400 uppercase tracking-wider mb-2",children:"Model"}),e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 text-[10px] font-mono rounded-full bg-surface text-primary-600 border border-primary-100",children:r.payload.model})]}),r.state?.lastError&&e.jsxs("div",{children:[e.jsx("h5",{className:"text-xs font-medium text-red-500 uppercase tracking-wider mb-2",children:"Last Error"}),e.jsx("p",{className:"rounded-lg bg-red-50 border border-red-100 p-3 font-mono text-xs text-red-600 leading-relaxed",children:r.state.lastError})]}),e.jsxs("div",{children:[e.jsx("h5",{className:"text-xs font-medium text-primary-400 uppercase tracking-wider mb-2",children:"Recent Runs"}),t.isLoading?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-primary-500",children:[e.jsx(o,{icon:h,size:12,className:"animate-spin"}),"Loading..."]}):n.length===0?e.jsx("p",{className:"text-xs text-primary-400",children:"No run history available"}):e.jsx("div",{className:"space-y-1.5",children:n.slice(0,5).map(s=>e.jsxs("div",{className:"flex items-center gap-3 py-1.5 px-2 rounded-md bg-surface border border-primary-50",children:[e.jsx("span",{className:d("inline-block h-2 w-2 shrink-0 rounded-full",s.status==="ok"?"bg-emerald-500":"bg-red-500")}),e.jsx(o,{icon:x,size:11,strokeWidth:1.5,className:"text-primary-400"}),e.jsx("span",{className:"tabular-nums text-[11px] text-primary-600",children:z(s.ranAt)}),e.jsx("span",{className:"tabular-nums text-[11px] text-primary-400",children:J(s.durationMs)}),s.error&&e.jsx("span",{className:"truncate text-[11px] text-red-500 ml-auto",children:s.error})]},s.id))})]})]})})}function T(r){const t=r.trim().split(/\s+/);if(t.length<5)return r;const[n,s,i,l,c]=t,a=`${s.padStart(2,"0")}:${n.padStart(2,"0")}`;if(i==="*"&&l==="*"&&c==="*")return`Daily at ${a}`;if(i==="*"&&l==="*"&&c!=="*"){const m={0:"Sun",1:"Mon",2:"Tue",3:"Wed",4:"Thu",5:"Fri",6:"Sat",7:"Sun"};return`${c.split(",").map(u=>m[u]??u).join(", ")} at ${a}`}return r}function B(r){const t=r.schedule;return t.kind==="every"&&t.expr?`Every ${t.expr}`:t.kind==="at"&&t.expr?`Once at ${t.expr}`:t.kind==="cron"&&t.expr?T(t.expr):t.expr??"Unknown"}function W(r){if(!r)return"—";const t=Date.now()-r;return t<6e4?"just now":t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:new Date(r).toLocaleDateString()}function q(r){if(!r)return"—";const t=r-Date.now();return t<0?"overdue":t<6e4?"in <1m":t<36e5?`in ${Math.floor(t/6e4)}m`:t<864e5?`in ${Math.floor(t/36e5)}h`:new Date(r).toLocaleDateString()}function K({status:r}){return r==="ok"?e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 text-[11px] font-medium rounded-full bg-emerald-50 text-emerald-600 border border-emerald-100",children:"ok"}):r==="error"?e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 text-[11px] font-medium rounded-full bg-red-50 text-red-600 border border-red-100",children:"error"}):e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 text-[11px] font-medium rounded-full bg-primary-50 text-primary-400 border border-primary-100",children:"—"})}function O({jobs:r}){const[t,n]=f.useState(null),s=L(),i=R(),l=f.useCallback(a=>{i.mutate({jobId:a.id,enabled:!a.enabled})},[i]),c=f.useCallback(a=>{s.mutate(a)},[s]);return r.length===0?null:e.jsx("div",{className:"space-y-2",children:r.map(a=>{const m=t===a.id,p=s.isPending&&s.variables===a.id;return e.jsxs("div",{className:d("group rounded-lg border border-primary-100 bg-surface transition-all duration-150 ease-out",m?"border-primary-200 shadow-sm":"hover:border-primary-200 hover:shadow-sm"),children:[e.jsxs("button",{type:"button",onClick:()=>n(m?null:a.id),className:d("w-full p-4 text-left","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:rounded-lg"),children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-2",children:[e.jsx("h4",{className:d("text-[13px] font-semibold leading-tight truncate",a.enabled?"text-primary-900":"text-primary-400"),children:a.name??a.id}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[!a.enabled&&e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 text-[11px] font-medium rounded-full bg-primary-50 text-primary-400 border border-primary-100",children:"Disabled"}),e.jsx(K,{status:a.state?.lastStatus})]})]}),e.jsx("p",{className:"text-xs text-primary-500 leading-relaxed mb-3",children:B(a)}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-primary-50",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{className:"text-[11px] text-primary-400 flex items-center gap-1",children:[e.jsx(o,{icon:x,size:11,strokeWidth:1.5}),"Last: ",W(a.state?.lastRunAtMs)]}),e.jsxs("span",{className:"text-[11px] text-primary-400 flex items-center gap-1",children:[e.jsx(o,{icon:w,size:11,strokeWidth:1.5}),"Next: ",q(a.state?.nextRunAtMs)]})]}),e.jsxs("div",{className:"flex items-center gap-2",onClick:u=>u.stopPropagation(),children:[e.jsx(S,{checked:a.enabled,onCheckedChange:()=>l(a),"aria-label":`${a.enabled?"Disable":"Enable"} ${a.name??a.id}`,disabled:i.isPending}),e.jsx(k,{variant:"ghost",size:"icon-sm",onClick:()=>c(a.id),disabled:p,"aria-label":`Run ${a.name??a.id} now`,className:"text-primary-500 hover:text-primary-700",children:e.jsx(o,{icon:p?h:C,size:16,strokeWidth:1.5,className:d(p&&"animate-spin")})})]})]})]}),e.jsx($,{children:m&&e.jsx(F,{job:a})})]},a.id)})})}function P(r){if(!r)return"never";const t=Date.now()-r;return t<6e4?"just now":t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:new Date(r).toLocaleDateString()}function Q(r){for(const t of[" - "," | ",": "," / "]){const n=r.indexOf(t);if(n>0)return r.substring(0,n).trim()}return r}function I(r){const t=new Map;for(const n of r){const s=Q(n.name??n.id),i=t.get(s);i?i.push(n):t.set(s,[n])}return Array.from(t.entries()).map(([n,s])=>({name:n,jobs:s})).sort((n,s)=>n.name.localeCompare(s.name))}function H({bot:r}){const t=r.jobs.reduce((i,l)=>Math.max(i,l.state?.lastRunAtMs??0),0),n=r.jobs.some(i=>i.state?.lastStatus==="error"),s=r.jobs.filter(i=>i.enabled).length;return e.jsxs("div",{className:"group rounded-lg border border-primary-100 bg-surface p-4 transition-all duration-150 ease-out hover:border-primary-200 hover:shadow-sm",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:d("flex items-center justify-center w-10 h-10 rounded-lg",n?"bg-red-50":"bg-primary-50"),children:e.jsx(o,{icon:b,size:20,strokeWidth:1.5,className:n?"text-red-500":"text-primary-500"})}),e.jsx("h4",{className:"text-[13px] font-semibold text-primary-900 leading-tight truncate",children:r.name})]}),n&&e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 text-[11px] font-medium rounded-full bg-red-50 text-red-600 border border-red-100 shrink-0",children:"Error"})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-primary-50",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("span",{className:"text-[11px] text-primary-400 flex items-center gap-1",children:[e.jsx(o,{icon:x,size:11,strokeWidth:1.5}),P(t||void 0)]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 text-[10px] font-medium rounded-full bg-primary-50 text-primary-500 border border-primary-100",children:[r.jobs.length," job",r.jobs.length!==1?"s":""]}),s<r.jobs.length&&e.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 text-[10px] font-medium rounded-full bg-amber-50 text-amber-600 border border-amber-100",children:[r.jobs.length-s," disabled"]})]})]})]})}function ee(){const r=A(),t=r.data??[],n=f.useMemo(()=>I(t),[t]);return e.jsxs("div",{className:"flex h-screen flex-col bg-surface text-primary-900",children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 border-b border-primary-100",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(v,{to:"/chat/$sessionKey",params:{sessionKey:"main"},className:"p-1.5 -ml-1.5 rounded-md text-primary-500 hover:text-primary-700 hover:bg-primary-50 transition-colors duration-150","aria-label":"Back to Chat",children:e.jsx(o,{icon:E,size:18,strokeWidth:2})}),e.jsx("h2",{className:"text-base font-semibold text-primary-900",children:"Cron Jobs"})]}),e.jsxs("p",{className:"text-xs text-primary-500",children:[t.length," job",t.length!==1?"s":""," configured"]})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-4 pb-4 pt-4",children:r.isLoading?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(o,{icon:h,size:18,className:"animate-spin text-primary-300"})}):r.isError?e.jsxs("div",{className:"py-12 text-center",children:[e.jsx("p",{className:"text-sm text-red-500",children:r.error instanceof Error?r.error.message:"Failed to load cron jobs"}),e.jsx("button",{onClick:()=>{r.refetch()},className:"mt-2 text-xs font-medium text-primary-500 hover:text-primary-700 transition-colors duration-150",children:"Retry"})]}):t.length===0?e.jsxs("div",{className:"py-12 text-center",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-lg bg-primary-50 mb-3",children:e.jsx(o,{icon:x,size:24,className:"text-primary-400"})}),e.jsx("p",{className:"text-sm text-primary-500",children:"No cron jobs configured"}),e.jsx("p",{className:"text-xs text-primary-400 mt-1",children:"Jobs will appear here once created"})]}):e.jsxs("div",{className:"space-y-6",children:[n.length>0&&e.jsxs("section",{children:[e.jsxs("h3",{className:"text-xs font-medium text-primary-400 uppercase tracking-wider mb-3 flex items-center gap-2",children:[e.jsx(o,{icon:b,size:14,strokeWidth:1.5}),"Bots (",n.length,")"]}),e.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3",children:n.map(s=>e.jsx(H,{bot:s},s.name))})]}),e.jsxs("section",{children:[e.jsxs("h3",{className:"text-xs font-medium text-primary-400 uppercase tracking-wider mb-3 flex items-center gap-2",children:[e.jsx(o,{icon:x,size:14,strokeWidth:1.5}),"All Jobs (",t.length,")"]}),e.jsx("div",{className:"space-y-2",children:e.jsx(O,{jobs:t})})]})]})})]})}export{ee as BotsScreen};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/bots-screen-BNQciUeJ.js","assets/main-B3N0eQFg.js","assets/button-nDcsaNPl.js","assets/switch-J6wLIVu2.js","assets/useControlled-BhUuiHAm.js","assets/useButton-Bnnac1eR.js","assets/visuallyHidden-DCCICp6T.js","assets/useMutation-CFmVaBag.js"])))=>i.map(i=>d[i]);
2
- import{j as e,r as t,_ as r}from"./main-B3N0eQFg.js";const n=t.lazy(()=>r(()=>import("./bots-screen-BNQciUeJ.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])).then(s=>({default:s.BotsScreen})));function a(){return e.jsx(t.Suspense,{fallback:e.jsx("div",{className:"flex h-screen items-center justify-center text-sm text-primary-500",children:"Loading…"}),children:e.jsx(n,{})})}export{a as component};
@@ -1 +0,0 @@
1
- import{j as e,r,L as se,u as L}from"./main-B3N0eQFg.js";import{m as E,A as P,u as ie}from"./visuallyHidden-DCCICp6T.js";import{O as be,c as h,j as ne,B as k,H as j,I as ye,C as ve,o as je,l as we,R as Ce,p as Ne,U as ke,Y as ae,t as re,Z as ce,_ as De,$ as Se,G as Ee,a0 as Fe,a1 as ze,a2 as de,P as ue,a3 as Me,a4 as Re,a5 as Te,a6 as Le,a7 as Ue,a8 as $e,S as ee,a9 as Ke,V as Ie}from"./button-nDcsaNPl.js";import{e as A,f as W,g as B,h as O,s as Pe,i as Ae,j as te}from"./tooltip-C14vdXHK.js";import{q as F,M as We,n as Be,o as Oe,p as le,D as Q,a as _,b as V,c as H,d as G}from"./use-file-explorer-state-BnaJEqRP.js";import{u as U}from"./useMutation-CFmVaBag.js";import"./DirectionContext-DXtY05YF.js";import"./useButton-Bnnac1eR.js";import"./useCompositeItem-BgiEMKAt.js";import"./react-B16OrBeM.js";function qe({className:i}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"80",height:"80",viewBox:"0 0 80 80",fill:"none",className:i,children:[e.jsx("rect",{width:"80",height:"80",fill:"currentColor",className:"text-transparent"}),e.jsx("path",{d:"M61.9624 45.5729C62.5862 44.3371 63.0907 43.3377 63.4782 41.9826C69.8221 28.8286 70.5847 14.0975 67.1723 4.32469C65.8317 0.249835 62.7688 0.254311 62.6374 3.58605C61.355 12.189 58.9061 17.6275 57.1756 21.0554C52.8087 29.7058 45.9949 37.7278 39.3706 42.7305C28.6217 50.8021 25.0716 44.614 24.3711 37.8823C23.8822 32.1203 24.7206 25.5721 26.24 18.2889C27.102 15.3261 24.3944 13.9592 22.5223 16.4122C20.4062 19.3487 18.5586 22.4209 17.1838 25.7318C12.9928 33.4462 10.3896 45.3332 11.4505 57.6273C12.2296 63.5357 13.1688 68.4057 14.1079 73.2757C15.2695 79.0941 19.1598 79.5073 24.3117 78.0088C39.7921 74.0789 54.143 58.872 59.7093 49.1011C60.7255 48.0229 61.3494 46.7872 61.9624 45.5729Z",fill:"currentColor",className:"text-primary-950"})]})}function Qe(){return r.useMemo(()=>typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,[])}function _e({isCollapsed:i,onToggleCollapse:s,onSelectAction:n}){const{navigateTo:a,currentPath:o}=F(),c=Qe(),t=r.useMemo(()=>({duration:c?0:.15,ease:i?"easeIn":"easeOut"}),[i,c]),l=r.useCallback(d=>{a(d)},[a]),m=r.useCallback((d,N)=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),N())},[]),v=r.useMemo(()=>[{path:"/",icon:be,label:"Home",id:"home"}],[]),y=r.useMemo(()=>({className:"border-r border-primary-200 h-full overflow-hidden bg-primary-100 flex flex-col"}),[]),f=48,u=300;return e.jsxs(E.aside,{initial:!1,animate:{width:c?i?f:u:void 0},style:{width:c?void 0:i?f:u},transition:t,className:y.className,role:"navigation","aria-label":"File explorer navigation",children:[e.jsxs(E.div,{layout:!0,transition:{layout:t},className:h("flex items-center h-12 px-2 justify-between"),children:[e.jsx(P,{initial:!1,children:i?null:e.jsx(E.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:t,children:e.jsxs(se,{to:"/new",className:h(ne({variant:"ghost",size:"sm"}),"w-full pl-1.5 justify-start","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:[e.jsx(qe,{className:"size-5 rounded-sm","aria-hidden":"true"}),e.jsx("span",{children:"WebClaw"})]})})}),e.jsx(A,{children:e.jsxs(W,{children:[e.jsx(B,{onClick:s,onKeyDown:d=>m(d,s),render:e.jsx(k,{size:"icon-sm",variant:"ghost","aria-label":i?"Expand sidebar":"Collapse sidebar",className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:e.jsx(j,{icon:ye,size:20,strokeWidth:1.5,"aria-hidden":"true"})})}),e.jsx(O,{side:"right",children:i?"Expand sidebar":"Collapse sidebar"})]})})]}),e.jsx("div",{className:"px-2 mb-4",children:e.jsx(E.div,{layout:!0,transition:{layout:t},className:"w-full",children:e.jsx(A,{children:e.jsxs(W,{children:[e.jsx(B,{asChild:!0,children:e.jsxs(se,{to:"/chat/$sessionKey",params:{sessionKey:"main"},className:h(ne({variant:"ghost",size:"sm"}),"w-full pl-1.5 justify-start","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),onClick:n,children:[e.jsx(j,{icon:ve,size:20,strokeWidth:1.5,className:"min-w-5","aria-hidden":"true"}),e.jsx(P,{initial:!1,mode:"wait",children:i?null:e.jsx(E.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:t,className:"overflow-hidden whitespace-nowrap",children:"Back to Chat"})})]})}),i?e.jsx(O,{side:"right",children:"Back to Chat"}):null]})})})}),e.jsx("div",{className:"flex-1 min-h-0 relative overflow-hidden",children:e.jsx(P,{initial:!1,children:i?e.jsx(E.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:t,className:"px-2 space-y-1",children:v.map(d=>e.jsx(A,{children:e.jsxs(W,{children:[e.jsx(B,{onClick:()=>l(d.path),onKeyDown:N=>m(N,()=>l(d.path)),render:e.jsx(k,{size:"icon-sm",variant:"ghost","aria-current":o===d.path?"page":void 0,"aria-label":`Navigate to ${d.label}`,className:h("w-full text-primary-600 hover:text-primary-900","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",o===d.path&&"bg-primary-200 text-primary-900"),children:e.jsx(j,{icon:d.icon,size:20,strokeWidth:1.5,"aria-hidden":"true"})})}),e.jsx(O,{side:"right",children:d.label})]})},d.id))},"collapsed-content"):e.jsx(E.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:t,className:"absolute inset-0 pt-0 flex flex-col w-[300px] min-h-0",children:e.jsxs("div",{className:"flex-1 min-h-0 px-2",children:[e.jsx("div",{className:"mb-4",children:e.jsx("h2",{className:"text-sm font-medium text-primary-700 mb-3 px-1.5",children:"Quick Access"})}),e.jsx("nav",{className:"space-y-1",role:"list","aria-label":"Quick access folders",children:v.map(d=>e.jsx("div",{role:"listitem",children:e.jsxs(k,{variant:"ghost",size:"sm",onClick:()=>l(d.path),onKeyDown:N=>m(N,()=>l(d.path)),"aria-current":o===d.path?"page":void 0,className:h("w-full pl-1.5 justify-start text-primary-600 hover:text-primary-900","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",o===d.path&&"bg-primary-200 text-primary-900 font-medium"),"aria-label":`Navigate to ${d.label}`,children:[e.jsx(j,{icon:d.icon,size:20,strokeWidth:1.5,className:"min-w-5","aria-hidden":"true"}),e.jsx("span",{className:"overflow-hidden whitespace-nowrap min-w-0 truncate",children:d.label})]})},d.id))})]})},"content")})}),e.jsx("div",{className:"px-2 py-3 border-t border-primary-200 bg-primary-100",children:e.jsx(E.div,{layout:!0,transition:{layout:t},className:"w-full",children:e.jsx(A,{children:e.jsxs(W,{children:[e.jsx(B,{asChild:!0,children:e.jsxs(k,{variant:"ghost",size:i?"icon-sm":"sm",className:h(i?"w-full":"w-full justify-start pl-1.5","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":"Settings",children:[e.jsx(j,{icon:je,size:20,strokeWidth:1.5,className:"min-w-5","aria-hidden":"true"}),e.jsx(P,{initial:!1,mode:"wait",children:i?null:e.jsx(E.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:t,className:"overflow-hidden whitespace-nowrap",children:"Settings"})})]})}),i?e.jsx(O,{side:"right",children:"Settings"}):null]})})})})]})}function Ve(i,s){return i.isCollapsed===s.isCollapsed}const He=r.memo(_e,Ve);function Ge({path:i}){const{navigateTo:s}=F(),n=i==="/"?[]:i.split("/").filter(Boolean),a=[{name:"Home",path:"/"},...n.map((t,l)=>({name:t,path:"/"+n.slice(0,l+1).join("/")}))],o=r.useCallback(t=>{s(t)},[s]),c=r.useCallback((t,l)=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),s(l))},[s]);return e.jsx("nav",{"aria-label":"File navigation",className:"text-sm text-primary-600",children:e.jsx("ol",{className:"flex items-center gap-1",children:a.map((t,l)=>e.jsxs("li",{className:"flex items-center gap-1",children:[l>0?e.jsx(j,{icon:we,size:16,strokeWidth:1.5,className:"text-primary-400","aria-hidden":"true"}):null,e.jsxs("button",{type:"button",onClick:()=>o(t.path),onKeyDown:m=>c(m,t.path),"aria-current":l===a.length-1?"page":void 0,className:h("flex items-center gap-1.5 rounded-md px-2 py-1","transition-colors duration-150 ease-out","hover:bg-primary-100 hover:text-primary-900","focus-visible:bg-primary-100 focus-visible:text-primary-900","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",l===a.length-1?"text-primary-900 font-medium":"text-primary-600"),children:[l===0?e.jsx(j,{icon:Ce,size:16,strokeWidth:1.5,"aria-hidden":"true"}):null,e.jsx("span",{className:"whitespace-nowrap",children:t.name})]})]},t.path))})})}const Z=[{label:"Name",value:"name"},{label:"Size",value:"size"},{label:"Modified",value:"modified"}];function Je({onUpload:i,onCreateFolder:s}){const{viewMode:n,sortBy:a,sortAsc:o,setViewMode:c,setSortBy:t,toggleSort:l}=F(),m=r.useCallback(()=>{c("list")},[c]),v=r.useCallback(()=>{c("grid")},[c]),y=r.useCallback(u=>{t(u)},[t]),f=r.useCallback((u,d)=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),d())},[]);return e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center border border-primary-200 rounded-lg overflow-hidden",role:"group","aria-label":"View mode",children:[e.jsx(k,{size:"sm",variant:n==="list"?"default":"ghost",onClick:m,onKeyDown:u=>f(u,m),"aria-label":"Switch to list view","aria-pressed":n==="list",className:h("rounded-none border-0","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:e.jsx(j,{icon:Ne,size:18,strokeWidth:1.5,"aria-hidden":"true"})}),e.jsx(k,{size:"sm",variant:n==="grid"?"default":"ghost",onClick:v,onKeyDown:u=>f(u,v),"aria-label":"Switch to grid view","aria-pressed":n==="grid",className:h("rounded-none border-0 border-l border-primary-200","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:e.jsx(j,{icon:ke,size:18,strokeWidth:1.5,"aria-hidden":"true"})})]}),e.jsxs(We,{children:[e.jsx(Be,{render:e.jsxs(k,{variant:"ghost",size:"sm",className:h("gap-1","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":`Sort by ${Z.find(u=>u.value===a)?.label}, ${o?"ascending":"descending"}`,children:[e.jsxs("span",{children:["Sort: ",Z.find(u=>u.value===a)?.label]}),e.jsx(j,{icon:o?ae:re,size:16,strokeWidth:1.5,"aria-hidden":"true"})]})}),e.jsxs(Oe,{side:"bottom",align:"start",children:[Z.map(u=>e.jsx(le,{onClick:()=>y(u.value),className:h(a===u.value&&"bg-primary-100 text-primary-900","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none"),"aria-current":a===u.value?"true":"false",children:u.label},u.value)),e.jsxs(le,{onClick:l,className:"focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none",children:[e.jsx(j,{icon:o?re:ae,size:16,strokeWidth:1.5,"aria-hidden":"true"}),o?"Sort Descending":"Sort Ascending"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(k,{variant:"ghost",size:"sm",onClick:i,onKeyDown:u=>f(u,i),className:h("gap-2","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":"Upload files",children:[e.jsx(j,{icon:ce,size:18,strokeWidth:1.5,"aria-hidden":"true"}),e.jsx("span",{children:"Upload"})]}),e.jsxs(k,{variant:"ghost",size:"sm",onClick:s,onKeyDown:u=>f(u,s),className:h("gap-2","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":"Create new folder",children:[e.jsx(j,{icon:De,size:18,strokeWidth:1.5,"aria-hidden":"true"}),e.jsx("span",{children:"New Folder"})]})]})]})}const z={all:["files"],listing:i=>["files","listing",i],content:i=>["files","content",i]};function Xe(i){return ie({queryKey:z.content(i||""),queryFn:async({signal:s})=>{const n=await fetch(`/api/files/read?path=${encodeURIComponent(i)}`,{signal:s});if(!n.ok){const a=await n.json().catch(()=>({error:"Failed to read file"}));throw new Error(a.error||"Failed to read file")}return n.json()},enabled:!!i,staleTime:30*1e3,gcTime:300*1e3})}function Ye(){const i=L(),s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort()},[]),U({mutationFn:async({path:n,content:a})=>{s.current?.abort();const o=new AbortController;s.current=o;const c=await fetch("/api/files/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,content:a}),signal:o.signal});if(!c.ok){const t=await c.json().catch(()=>({error:"Failed to save file"}));throw new Error(t.error||"Failed to save file")}return c.json()},onSuccess:(n,a)=>{i.invalidateQueries({queryKey:z.content(a.path)});const o=a.path.split("/").slice(0,-1).join("/")||"/";i.invalidateQueries({queryKey:z.listing(o)})}})}function Ze(i){return ie({queryKey:z.listing(i),queryFn:async({signal:s})=>{const n=await fetch(`/api/files/list?path=${encodeURIComponent(i)}`,{signal:s});if(!n.ok){const a=await n.text();throw new Error(`Failed to load files: ${a}`)}return n.json()},staleTime:300*1e3,gcTime:600*1e3,retry:3})}function ei(){const i=new Set,s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort(),i.forEach(n=>URL.revokeObjectURL(n)),i.clear()},[]),U({mutationFn:async n=>{s.current?.abort();const a=new AbortController;s.current=a;const o=await fetch(`/api/files/download?path=${encodeURIComponent(n)}`,{signal:a.signal});if(!o.ok){const v=await o.text();throw new Error(`Download failed: ${v}`)}const c=await o.blob(),t=window.URL.createObjectURL(c);i.add(t);const l=n.split("/").pop()||"download",m=document.createElement("a");m.href=t,m.download=l,document.body.appendChild(m),m.click(),document.body.removeChild(m),setTimeout(()=>{i.has(t)&&(URL.revokeObjectURL(t),i.delete(t))},100)},onError:n=>{n instanceof Error&&n.name==="AbortError"||console.error("Download failed:",n)}})}function ii(){const i=L(),s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort()},[]),U({mutationFn:async({files:n,path:a})=>{s.current?.abort();const o=new AbortController;s.current=o;const c=[];for(let t=0;t<n.length;t++){const l=new FormData;l.append("path",a),l.append("file",n[t]);const m=await fetch("/api/files/upload",{method:"POST",body:l,signal:o.signal});if(!m.ok){const v=await m.text();throw new Error(`Upload failed for ${n[t].name}: ${v}`)}c.push(await m.json())}return c},onSuccess:(n,a)=>{i.invalidateQueries({queryKey:z.listing(a.path)})},onError:n=>{n instanceof Error&&n.name==="AbortError"||console.error("Upload failed:",n)}})}function si(){const i=L(),s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort()},[]),U({mutationFn:async n=>{s.current?.abort();const a=new AbortController;s.current=a;const o=await fetch(`/api/files/delete?path=${encodeURIComponent(n)}`,{method:"DELETE",signal:a.signal});if(!o.ok){const c=await o.text();throw new Error(`Delete failed: ${c}`)}return o.json()},onSuccess:(n,a)=>{const o=a.split("/").slice(0,-1).join("/")||"/";i.invalidateQueries({queryKey:z.listing(o)})},onError:n=>{n instanceof Error&&n.name==="AbortError"||console.error("Delete failed:",n)}})}function ni(){const i=L(),s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort()},[]),U({mutationFn:async({path:n,name:a})=>{s.current?.abort();const o=new AbortController;s.current=o;const c=await fetch("/api/files/mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:`${n}/${a}`}),signal:o.signal});if(!c.ok){const t=await c.text();throw new Error(`Create folder failed: ${t}`)}return c.json()},onSuccess:(n,a)=>{i.invalidateQueries({queryKey:z.listing(a.path)})},onError:n=>{n instanceof Error&&n.name==="AbortError"||console.error("Create folder failed:",n)}})}function ai(){const i=L(),s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort()},[]),U({mutationFn:async({oldPath:n,newName:a})=>{s.current?.abort();const o=new AbortController;s.current=o;const t=`${n.split("/").slice(0,-1).join("/")}/${a}`,l=await fetch("/api/files/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({src:n,dst:t}),signal:o.signal});if(!l.ok){const m=await l.text();throw new Error(`Rename failed: ${m}`)}return l.json()},onSuccess:(n,a)=>{const o=a.oldPath.split("/").slice(0,-1).join("/")||"/";i.invalidateQueries({queryKey:z.listing(o)})},onError:n=>{n instanceof Error&&n.name==="AbortError"||console.error("Rename failed:",n)}})}const ri=new Set(["txt","md","log","json","xml","yaml","yml","csv","ini","conf","cfg","js","ts","jsx","tsx","py","java","cpp","c","h","css","html","htm","php","rb","go","rs","sh","bash","zsh","toml","env","gitignore","dockerfile","makefile","sql","graphql","svelte","vue","scss","less"]);function me({item:i,children:s,onOpenFile:n}){const[a,o]=r.useState(!1),[c,t]=r.useState({x:0,y:0}),[l,m]=r.useState(!1),[v,y]=r.useState(!1),[f,u]=r.useState(i.name),[d,N]=r.useState(""),C=r.useRef(null),{navigateTo:w}=F(),p=ei(),x=si(),D=ai(),M=r.useCallback(b=>{switch(b){case"open":i.isDir&&w(i.path);break;case"edit":n&&n(i.path);break;case"download":i.isDir||p.mutate(i.path);break;case"rename":u(i.name),N(""),m(!0);break;case"delete":y(!0);break}},[i,p,w]),X=r.useCallback(b=>{b.preventDefault(),b.stopPropagation(),t({x:b.clientX,y:b.clientY}),o(!0)},[]),$=r.useCallback(async()=>{if(!f||f===i.name){m(!1);return}N("");try{await D.mutateAsync({oldPath:i.path,newName:f.trim()}),m(!1)}catch(b){const T=b instanceof Error?b.message:"Failed to rename";N(T)}},[f,i,D]),K=r.useCallback(async()=>{try{await x.mutateAsync(i.path),y(!1)}catch(b){console.error("Delete failed:",b)}},[i.path,x]),Y=r.useCallback(b=>{b.key==="Enter"?(b.preventDefault(),$()):b.key==="Escape"&&(b.preventDefault(),m(!1))},[$]),g=r.useCallback(b=>{u(b.target.value),d&&N("")},[d]);r.useEffect(()=>{if(l&&C.current){const b=C.current;if(b.focus(),!i.isDir&&i.extension){const T=i.name.replace(new RegExp(`\\.${i.extension}$`),"");b.setSelectionRange(0,T.length)}else b.select()}},[l,i]);const S=f.trim().length>0&&!/[<>:"/\\|?*]/.test(f)&&!f.includes("..")&&f!==i.name,R=()=>p.isPending?"Downloading…":"Download",fe=()=>D.isPending?"Renaming…":"Rename",he=()=>x.isPending?"Deleting…":"Delete";r.useEffect(()=>{if(!a)return;const b=()=>o(!1),T=ge=>{ge.key==="Escape"&&o(!1)},xe=setTimeout(()=>{document.addEventListener("click",b),document.addEventListener("contextmenu",b),document.addEventListener("keydown",T)},0);return()=>{clearTimeout(xe),document.removeEventListener("click",b),document.removeEventListener("contextmenu",b),document.removeEventListener("keydown",T)}},[a]);const I=r.useCallback(b=>{o(!1),M(b)},[M]);return e.jsxs(e.Fragment,{children:[e.jsx("div",{onContextMenu:X,children:s}),a?e.jsx("div",{className:"fixed inset-0 z-50","aria-modal":"true",role:"dialog",children:e.jsxs("div",{className:"fixed min-w-[140px] rounded-lg bg-primary-50 p-1 text-sm text-primary-900 shadow-lg outline outline-primary-900/10 z-50",style:{left:c.x,top:c.y},role:"menu",onClick:b=>b.stopPropagation(),children:[i.isDir?e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>I("open"),className:h("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-primary-900","hover:bg-primary-100 select-none font-[450]","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none"),children:[e.jsx(j,{icon:Se,size:16,strokeWidth:1.5,"aria-hidden":"true"}),"Open"]}):null,i.isDir?null:e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>I("download"),disabled:p.isPending,className:h("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-primary-900","hover:bg-primary-100 select-none font-[450]","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none"),children:[e.jsx(j,{icon:Ee,size:16,strokeWidth:1.5,"aria-hidden":"true"}),R()]}),!i.isDir&&ri.has(i.extension.toLowerCase())?e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>I("edit"),className:h("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-primary-900","hover:bg-primary-100 select-none font-[450]","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none"),children:[e.jsx(j,{icon:Fe,size:16,strokeWidth:1.5,"aria-hidden":"true"}),"Edit"]}):null,e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>I("rename"),className:h("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-primary-900","hover:bg-primary-100 select-none font-[450]","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none"),children:[e.jsx(j,{icon:ze,size:16,strokeWidth:1.5,"aria-hidden":"true"}),"Rename"]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>I("delete"),className:h("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm","text-red-600 hover:bg-red-50 select-none font-[450]","focus-visible:ring-2 focus-visible:ring-red-300 focus-visible:outline-none"),children:[e.jsx(j,{icon:de,size:16,strokeWidth:1.5,"aria-hidden":"true"}),"Delete"]})]})}):null,e.jsx(Q,{open:l,onOpenChange:m,children:e.jsx(_,{children:e.jsxs("div",{className:"p-6",children:[e.jsxs(V,{className:"mb-2",children:["Rename ",i.isDir?"Folder":"File"]}),e.jsxs(H,{className:"mb-4",children:['Enter a new name for "',i.name,'"']}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("label",{htmlFor:"rename-input",className:"block text-sm font-medium text-primary-900 mb-2",children:[i.isDir?"Folder":"File"," Name"]}),e.jsx("input",{id:"rename-input",ref:C,type:"text",value:f,onChange:g,onKeyDown:Y,autoFocus:!0,spellCheck:!1,"aria-describedby":d?"rename-error":void 0,"aria-invalid":d?"true":"false",className:h("w-full px-3 py-2 border rounded-lg","transition-colors duration-150 ease-out","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",d?"border-red-300 focus-visible:ring-red-300":"border-primary-200 focus:border-primary-300")}),d?e.jsx("p",{id:"rename-error",className:"text-sm text-red-600 mt-1",role:"alert","aria-live":"polite",children:d}):null]}),D.isPending?e.jsx("div",{className:"mb-4 p-3 bg-primary-50 rounded-lg","aria-live":"polite",children:e.jsx("p",{className:"text-sm text-primary-600",children:"Renaming…"})}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{disabled:D.isPending,className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:"Cancel"}),e.jsx(k,{onClick:$,disabled:!S||D.isPending,className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",(!S||D.isPending)&&"opacity-50 cursor-not-allowed"),children:fe()})]})]})})}),e.jsx(Q,{open:v,onOpenChange:y,children:e.jsx(_,{children:e.jsxs("div",{className:"p-6",children:[e.jsxs(V,{className:"mb-2",children:["Delete ",i.isDir?"Folder":"File"]}),e.jsxs(H,{className:"mb-4",children:['Are you sure you want to delete "',i.name,'"?',i.isDir?" This will delete the folder and all its contents.":""," ","This action cannot be undone."]}),x.isPending?e.jsx("div",{className:"mb-4 p-3 bg-red-50 rounded-lg","aria-live":"polite",children:e.jsx("p",{className:"text-sm text-red-700",children:"Deleting…"})}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{disabled:x.isPending,className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:"Cancel"}),e.jsx(k,{variant:"destructive",onClick:K,disabled:x.isPending,className:h("focus-visible:ring-2 focus-visible:ring-red-300 focus-visible:outline-none","touch-manipulation",x.isPending&&"opacity-50 cursor-not-allowed"),children:he()})]})]})})})]})}const ti=new Set(["txt","md","log","json","xml","yaml","yml","csv","ini","conf","cfg","js","ts","jsx","tsx","py","java","cpp","c","h","css","html","htm","php","rb","go","rs","sh","bash","zsh","toml","env","gitignore","dockerfile","makefile","sql","graphql","svelte","vue","scss","less"]);function J(i){if(i===0)return"0 B";const s=1024,n=["B","KB","MB","GB","TB"],a=Math.floor(Math.log(i)/Math.log(s));return parseFloat((i/Math.pow(s,a)).toFixed(1))+" "+n[a]}function q(i){const s=new Date(i),a=new Date().getTime()-s.getTime(),o=Math.floor(a/1e3),c=Math.floor(o/60),t=Math.floor(c/60),l=Math.floor(t/24);return l>7?s.toLocaleDateString():l>0?l===1?"yesterday":`${l} days ago`:t>0?t===1?"1 hour ago":`${t} hours ago`:c>0?c===1?"1 minute ago":`${c} minutes ago`:"just now"}function pe(i){if(i.isDir)return ue;const s=i.extension.toLowerCase();return["jpg","jpeg","png","gif","webp","svg","bmp"].includes(s)?Me:["mp4","avi","mkv","mov","wmv","flv","webm"].includes(s)?Re:["mp3","wav","flac","aac","ogg","m4a"].includes(s)?Te:["zip","rar","7z","tar","gz","bz2"].includes(s)?Le:["txt","md","log","json","xml","yaml","yml"].includes(s)?Ue:["js","ts","jsx","tsx","py","java","cpp","c","h","css","html","php","rb","go","rs"].includes(s)?$e:ee}function li(i,s,n){return r.useMemo(()=>[...i].sort((o,c)=>{if(o.isDir&&!c.isDir)return-1;if(!o.isDir&&c.isDir)return 1;let t=0;switch(s){case"name":t=o.name.localeCompare(c.name);break;case"size":t=o.size-c.size;break;case"modified":t=new Date(o.modified).getTime()-new Date(c.modified).getTime();break;default:t=o.name.localeCompare(c.name)}return n?t:-t}),[i,s,n])}function oi(){return r.useMemo(()=>typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,[])}function ci({viewMode:i}){const s=i==="grid"?12:8;return i==="grid"?e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 xl:grid-cols-8 gap-3 p-4","aria-busy":"true","aria-label":"Loading files",children:Array.from({length:s},(n,a)=>e.jsxs("div",{className:"flex flex-col items-center p-3 rounded-lg",children:[e.jsx("div",{className:"w-12 h-12 bg-primary-200 rounded animate-pulse mb-2"}),e.jsx("div",{className:"w-16 h-4 bg-primary-200 rounded animate-pulse"})]},a))}):e.jsx("div",{className:"divide-y divide-primary-200","aria-busy":"true","aria-label":"Loading files",children:Array.from({length:s},(n,a)=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e.jsx("div",{className:"w-6 h-6 bg-primary-200 rounded animate-pulse"}),e.jsx("div",{className:"flex-1 min-w-0 h-4 bg-primary-200 rounded animate-pulse"}),e.jsx("div",{className:"w-16 h-4 bg-primary-200 rounded animate-pulse"}),e.jsx("div",{className:"w-20 h-4 bg-primary-200 rounded animate-pulse"})]},a))})}const di=r.memo(function({item:s,isSelected:n,onClick:a,onDoubleClick:o,onKeyDown:c,onOpenFile:t,reduceMotion:l}){const m=r.useCallback(()=>{a(s)},[a,s]),v=r.useCallback(()=>{o(s)},[o,s]),y=r.useCallback(d=>{c(d,s)},[c,s]),f=()=>s.isDir?`${s.name}, folder`:`${s.name}, ${s.extension} file, ${J(s.size)}, modified ${q(s.modified)}`,u=e.jsxs(E.button,{type:"button",whileHover:l?{}:{scale:1.02},whileTap:l?{}:{scale:.98},transition:{duration:l?0:.15},onClick:m,onDoubleClick:v,onKeyDown:y,"aria-label":f(),className:h("flex flex-col items-center p-3 rounded-lg w-full border border-transparent","transition-all duration-150 ease-out","hover:bg-primary-50 hover:border-primary-100 focus-visible:bg-primary-50","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",n&&"bg-primary-100 border-primary-200"),children:[e.jsx(j,{icon:pe(s),size:40,strokeWidth:1,className:h("mb-2",s.isDir?"text-sky-500":"text-primary-500"),"aria-hidden":"true"}),e.jsx("span",{className:"text-[11px] text-center text-primary-900 font-medium truncate w-full min-w-0",children:s.name}),s.isDir?null:e.jsx("span",{className:"text-[10px] text-primary-400 mt-0.5 tabular-nums",children:J(s.size)})]});return e.jsx(me,{item:s,onOpenFile:t,children:u})}),ui=r.memo(function({item:s,isSelected:n,onClick:a,onDoubleClick:o,onKeyDown:c,onOpenFile:t,reduceMotion:l}){const m=r.useCallback(()=>{a(s)},[a,s]),v=r.useCallback(()=>{o(s)},[o,s]),y=r.useCallback(d=>{c(d,s)},[c,s]),f=()=>s.isDir?`${s.name}, folder, modified ${q(s.modified)}`:`${s.name}, ${s.extension} file, ${J(s.size)}, modified ${q(s.modified)}`,u=e.jsxs(E.button,{type:"button",whileHover:l?{}:{backgroundColor:"rgb(248 250 252)"},transition:{duration:l?0:.15},onClick:m,onDoubleClick:v,onKeyDown:y,"aria-label":f(),className:h("w-full grid grid-cols-[auto_1fr_auto_auto] gap-4 px-4 py-2.5 text-left","transition-all duration-150 ease-out","hover:bg-primary-50 focus-visible:bg-primary-50","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",n&&"bg-primary-100"),children:[e.jsx(j,{icon:pe(s),size:18,strokeWidth:1.5,className:h("mt-0.5 shrink-0",s.isDir?"text-sky-500":"text-primary-500"),"aria-hidden":"true"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("span",{className:"text-[13px] text-primary-900 font-medium truncate block",children:s.name})}),e.jsx("div",{className:"text-xs text-primary-500 text-right w-16 tabular-nums shrink-0",children:s.isDir?"—":J(s.size)}),e.jsx("div",{className:"text-xs text-primary-500 text-right w-20 tabular-nums shrink-0",children:q(s.modified)})]});return e.jsx(me,{item:s,onOpenFile:t,children:u})}),mi=e.jsx("div",{className:"flex items-center justify-center h-full py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-lg bg-primary-50 mb-3",children:e.jsx(j,{icon:ue,size:24,strokeWidth:1.5,className:"text-primary-400","aria-hidden":"true"})}),e.jsx("p",{className:"text-sm text-primary-500",children:"This folder is empty"}),e.jsx("p",{className:"text-xs text-primary-400 mt-1",children:"Upload files or create a new folder to get started"})]})});function pi({listing:i,loading:s,onOpenFile:n}){const{viewMode:a,sortBy:o,sortAsc:c,selectedFiles:t,navigateTo:l,toggleFileSelection:m}=F(),[v,y]=r.useState(0),f=r.useRef(null),u=oi(),d=li(i?.items||[],o,c),N=r.useCallback(p=>{m(p.path)},[m]),C=r.useCallback(p=>{p.isDir?l(p.path):n&&ti.has(p.extension.toLowerCase())&&n(p.path)},[l,n]),w=r.useCallback((p,x)=>{p.key==="Enter"?(p.preventDefault(),x.isDir?l(x.path):m(x.path)):p.key===" "&&(p.preventDefault(),m(x.path))},[l,m]);return r.useEffect(()=>{const p=x=>{if(d.length)switch(x.key){case"ArrowDown":x.preventDefault(),y(D=>Math.min(D+1,d.length-1));break;case"ArrowUp":x.preventDefault(),y(D=>Math.max(D-1,0));break;case"Home":x.preventDefault(),y(0);break;case"End":x.preventDefault(),y(d.length-1);break}};if(f.current)return f.current.addEventListener("keydown",p),()=>{f.current?.removeEventListener("keydown",p)}},[d.length]),s?e.jsx(ci,{viewMode:a}):i?d.length===0?mi:a==="grid"?e.jsx("div",{ref:f,className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 xl:grid-cols-8 gap-3 p-4 overflow-y-auto",role:"grid","aria-label":"Files grid",tabIndex:0,children:d.map((p,x)=>e.jsx("div",{role:"gridcell",children:e.jsx(di,{item:p,isSelected:t.has(p.path),onClick:N,onDoubleClick:C,onKeyDown:w,onOpenFile:n,reduceMotion:u})},p.path))}):e.jsx("div",{ref:f,className:"overflow-y-auto",role:"table","aria-label":"Files list",tabIndex:0,children:e.jsxs("div",{className:"divide-y divide-primary-100",children:[e.jsxs("div",{className:"grid grid-cols-[auto_1fr_auto_auto] gap-4 px-4 py-2 text-xs font-medium text-primary-400 uppercase tracking-wider bg-primary-50/50",role:"row",children:[e.jsx("div",{className:"w-6",role:"columnheader","aria-label":"File type"}),e.jsx("div",{role:"columnheader",children:"Name"}),e.jsx("div",{className:"w-16 text-right",role:"columnheader",children:"Size"}),e.jsx("div",{className:"w-20 text-right",role:"columnheader",children:"Modified"})]}),d.map((p,x)=>e.jsx("div",{role:"row",children:e.jsx(ui,{item:p,isSelected:t.has(p.path),onClick:N,onDoubleClick:C,onKeyDown:w,onOpenFile:n,reduceMotion:u})},p.path))]})}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("p",{className:"text-primary-500",children:"No listing available"})})}function oe(i){if(i===0)return"0 B";const s=1024,n=["B","KB","MB","GB"],a=Math.floor(Math.log(i)/Math.log(s));return parseFloat((i/Math.pow(s,a)).toFixed(1))+" "+n[a]}function fi({open:i,onOpenChange:s,currentPath:n}){const[a,o]=r.useState([]),[c,t]=r.useState(!1),[l,m]=r.useState("idle"),v=r.useRef(null),y=ii(),f=r.useCallback(()=>{o([]),m("idle"),v.current&&(v.current.value="")},[]),u=r.useCallback(g=>{if(!g)return;const S=Array.from(g).map(R=>({file:R,id:Math.random().toString(36).substr(2,9)}));o(R=>[...R,...S])},[]),d=r.useCallback(g=>{u(g.target.files)},[u]),N=r.useCallback(g=>{g.preventDefault(),t(!1),u(g.dataTransfer.files)},[u]),C=r.useCallback(g=>{g.preventDefault(),t(!0)},[]),w=r.useCallback(g=>{g.preventDefault(),t(!1)},[]),p=r.useCallback(g=>{o(S=>S.filter(R=>R.id!==g))},[]),x=r.useCallback(()=>{v.current?.click()},[]),D=r.useCallback(g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),x())},[x]),M=r.useCallback(async()=>{if(a.length===0)return;const g=new DataTransfer;a.forEach(({file:S})=>{g.items.add(S)}),m("uploading");try{await y.mutateAsync({files:g.files,path:n}),m("success"),f(),s(!1)}catch(S){m("error"),console.error("Upload failed:",S)}},[a,n,y,f,s]),X=r.useCallback(g=>{g||f(),s(g)},[f,s]),$=a.reduce((g,{file:S})=>g+S.size,0),K=a.length,Y=()=>y.isPending||l==="uploading"?"Uploading…":K===0?"Upload":K===1?"Upload 1 File":`Upload ${K} Files`;return e.jsx(Q,{open:i,onOpenChange:X,children:e.jsx(_,{className:"w-[min(500px,92vw)]",children:e.jsxs("div",{className:"p-6",children:[e.jsx(V,{className:"mb-2",children:"Upload Files"}),e.jsxs(H,{className:"mb-6",children:["Upload files to ",n==="/"?"root directory":n]}),e.jsxs("div",{onDrop:N,onDragOver:C,onDragLeave:w,onClick:x,onKeyDown:D,tabIndex:0,role:"button","aria-label":"Drop files here or click to choose files",className:h("border-2 border-dashed rounded-lg p-8 text-center cursor-pointer","transition-colors duration-150 ease-out","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",c?"border-primary-400 bg-primary-50":"border-primary-200 hover:border-primary-300 hover:bg-primary-50"),children:[e.jsx(j,{icon:ce,size:48,strokeWidth:1,className:"mx-auto text-primary-400 mb-4","aria-hidden":"true"}),e.jsx("p",{className:"text-primary-600 font-medium mb-2",children:"Drag and drop files here"}),e.jsx("p",{className:"text-sm text-primary-500 mb-4",children:"or"}),e.jsxs(k,{variant:"outline",className:h("gap-2","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":"Choose files from computer",children:[e.jsx(j,{icon:ee,size:18,strokeWidth:1.5,"aria-hidden":"true"}),e.jsx("span",{children:"Choose Files"})]}),e.jsx("input",{ref:v,type:"file",multiple:!0,onChange:d,className:"hidden","aria-hidden":"true"})]}),e.jsx(P,{children:a.length>0?e.jsxs(E.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"mt-6",children:[e.jsxs("h4",{className:"text-sm font-medium text-primary-900 mb-3",children:["Selected Files (",a.length,")"]}),e.jsx("div",{className:"max-h-32 overflow-y-auto border border-primary-200 rounded-lg",children:a.map(({file:g,id:S})=>e.jsxs(E.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},exit:{opacity:0,x:10},className:"flex items-center justify-between p-2 border-b border-primary-100 last:border-b-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx(j,{icon:ee,size:16,strokeWidth:1.5,className:"text-primary-600 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"text-sm text-primary-900 truncate min-w-0",children:g.name}),e.jsx("span",{className:"text-xs text-primary-500 shrink-0 tabular-nums",children:oe(g.size)})]}),e.jsx(k,{size:"icon-sm",variant:"ghost",onClick:()=>p(S),className:h("text-primary-500 hover:text-red-600 shrink-0","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":`Remove ${g.name} from upload list`,children:e.jsx(j,{icon:de,size:14,strokeWidth:1.5,"aria-hidden":"true"})})]},S))}),e.jsxs("p",{className:"text-xs text-primary-600 mt-2 tabular-nums",children:["Total size: ",oe($)]})]}):null}),y.isPending||l==="uploading"?e.jsxs(E.div,{initial:{opacity:0},animate:{opacity:1},className:"mt-4 p-3 bg-primary-50 rounded-lg","aria-live":"polite",children:[e.jsx("p",{className:"text-sm text-primary-600 mb-2",children:"Uploading files…"}),e.jsx("div",{className:"bg-primary-200 rounded-full h-2",role:"progressbar","aria-label":"Upload progress",children:e.jsx("div",{className:"bg-primary-600 h-2 rounded-full w-1/2 animate-pulse"})})]}):null,l==="success"?e.jsx("div",{className:"mt-4 p-3 bg-green-50 rounded-lg","aria-live":"polite",children:e.jsx("p",{className:"text-sm text-green-700",children:"Files uploaded successfully!"})}):null,l==="error"?e.jsx("div",{className:"mt-4 p-3 bg-red-50 rounded-lg","aria-live":"polite",children:e.jsx("p",{className:"text-sm text-red-700",children:"Upload failed. Please try again."})}):null,e.jsxs("div",{className:"flex justify-end gap-2 mt-6",children:[e.jsx(G,{disabled:y.isPending||l==="uploading",className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:"Cancel"}),e.jsx(k,{onClick:M,disabled:a.length===0||y.isPending||l==="uploading",className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:Y()})]})]})})})}function hi({open:i,onOpenChange:s,currentPath:n}){const[a,o]=r.useState(""),[c,t]=r.useState(""),l=ni(),m=r.useCallback(async()=>{if(a.trim()){t("");try{await l.mutateAsync({path:n,name:a.trim()}),o(""),s(!1)}catch(p){const x=p instanceof Error?p.message:"Failed to create folder";t(x),console.error("Create folder failed:",p)}}},[a,n,l,s]),v=r.useCallback(p=>{p||(o(""),t("")),s(p)},[s]),y=r.useCallback(p=>{p.key==="Enter"&&(p.preventDefault(),m())},[m]),f=r.useCallback(p=>{const x=p.target.value;o(x),c&&t("")},[c]),u=a.trim().length>0&&!/[<>:"/\\|?*]/.test(a)&&!a.includes(".."),d=()=>l.isPending?"Creating…":"Create Folder",C=a.trim()?a.includes("..")?'Folder name cannot contain ".."':/[<>:"/\\|?*]/.test(a)?'Invalid characters: < > : " / \\ | ? *':"":"",w=c||C;return e.jsx(Q,{open:i,onOpenChange:v,children:e.jsx(_,{children:e.jsxs("div",{className:"p-6",children:[e.jsx(V,{className:"mb-2",children:"Create New Folder"}),e.jsxs(H,{className:"mb-4",children:["Create a new folder in ",n==="/"?"root directory":n]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{htmlFor:"folder-name",className:"block text-sm font-medium text-primary-900 mb-2",children:"Folder Name"}),e.jsx("input",{id:"folder-name",type:"text",value:a,onChange:f,onKeyDown:y,placeholder:"Enter folder name",autoComplete:"off",spellCheck:!1,autoFocus:!0,"aria-describedby":w?"folder-name-error":void 0,"aria-invalid":w?"true":"false",className:h("w-full px-3 py-2 border rounded-lg","transition-colors duration-150 ease-out","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",w?"border-red-300 focus-visible:ring-red-300":"border-primary-200 focus:border-primary-300")}),w?e.jsx("p",{id:"folder-name-error",className:"text-sm text-red-600 mt-1",role:"alert","aria-live":"polite",children:c||C}):null]}),l.isPending?e.jsx("div",{className:"mb-4 p-3 bg-primary-50 rounded-lg","aria-live":"polite",children:e.jsx("p",{className:"text-sm text-primary-600",children:"Creating folder…"})}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{disabled:l.isPending,className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:"Cancel"}),e.jsx(k,{onClick:m,disabled:!u||l.isPending,className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",(!u||l.isPending)&&"opacity-50 cursor-not-allowed"),"aria-describedby":u?void 0:"create-button-help",children:d()})]}),!u&&a.length>0?e.jsx("p",{id:"create-button-help",className:"text-xs text-primary-500 mt-2",children:"Please enter a valid folder name"}):null]})})})}const xi={js:"JavaScript",ts:"TypeScript",jsx:"JSX",tsx:"TSX",py:"Python",json:"JSON",yaml:"YAML",yml:"YAML",md:"Markdown",html:"HTML",css:"CSS",scss:"SCSS",sh:"Shell",bash:"Bash",sql:"SQL",xml:"XML",toml:"TOML",ini:"INI",conf:"Config",cfg:"Config",env:"Env",txt:"Text",log:"Log",csv:"CSV",go:"Go",rs:"Rust",rb:"Ruby",php:"PHP",java:"Java",c:"C",cpp:"C++",h:"Header",dockerfile:"Dockerfile",makefile:"Makefile",graphql:"GraphQL",svelte:"Svelte",vue:"Vue"};function gi({filePath:i,onClose:s}){const n=Xe(i),a=Ye(),o=r.useRef(null),[c,t]=r.useState(null),[l,m]=r.useState(!1);r.useEffect(()=>{n.data&&c===null&&t(n.data.content)},[n.data,c]);const v=r.useMemo(()=>n.data?xi[n.data.extension.toLowerCase()]||n.data.extension.toUpperCase():"",[n.data]),y=r.useCallback(C=>{t(C.target.value),m(C.target.value!==n.data?.content)},[n.data]),f=r.useCallback(async()=>{if(c!==null)try{await a.mutateAsync({path:i,content:c}),m(!1)}catch{}},[i,c,a]),u=r.useCallback(()=>{l&&!window.confirm("You have unsaved changes. Discard them?")||s()},[l,s]);r.useEffect(()=>{const C=w=>{(w.ctrlKey||w.metaKey)&&w.key==="s"&&(w.preventDefault(),l&&f()),w.key==="Escape"&&u()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[f,u,l]);const d=r.useCallback(C=>{if(C.key==="Tab"){C.preventDefault();const w=C.currentTarget,p=w.selectionStart,x=w.selectionEnd,D=w.value,M=D.substring(0,p)+" "+D.substring(x);t(M),m(M!==n.data?.content),requestAnimationFrame(()=>{w.selectionStart=w.selectionEnd=p+2})}},[n.data]),N=i.split("/").pop()||i;return e.jsxs("div",{className:"fixed inset-0 z-50 bg-surface flex flex-col",children:[e.jsxs("header",{className:"flex items-center justify-between px-4 py-2 border-b border-primary-200 bg-primary-50",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("h2",{className:"text-sm font-semibold text-primary-900 truncate",children:N}),v?e.jsx("span",{className:"text-xs text-primary-500 bg-primary-100 px-2 py-0.5 rounded-full shrink-0",children:v}):null,l?e.jsx("span",{className:"text-xs text-amber-600 bg-amber-50 px-2 py-0.5 rounded-full shrink-0",children:"Unsaved"}):null,a.isError?e.jsx("span",{className:"text-xs text-red-600",children:a.error.message}):null]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(k,{size:"sm",variant:"default",onClick:f,disabled:!l||a.isPending,className:h((!l||a.isPending)&&"opacity-50 cursor-not-allowed"),children:[e.jsx(j,{icon:Ke,size:16,strokeWidth:1.5,"aria-hidden":"true"}),a.isPending?"Saving…":"Save"]}),e.jsx(k,{size:"icon-sm",variant:"ghost",onClick:u,"aria-label":"Close editor",children:e.jsx(j,{icon:Ie,size:20,strokeWidth:1.5,"aria-hidden":"true"})})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.isLoading?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("p",{className:"text-primary-500 text-sm",children:"Loading file…"})}):n.isError?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-red-600 text-sm mb-2",children:n.error instanceof Error?n.error.message:"Failed to load file"}),e.jsx(k,{size:"sm",variant:"secondary",onClick:()=>{n.refetch()},children:"Retry"})]})}):e.jsx("textarea",{ref:o,value:c??"",onChange:y,onKeyDown:d,spellCheck:!1,autoFocus:!0,className:h("w-full h-full p-4 resize-none","bg-primary-950 text-primary-100","font-mono text-sm leading-relaxed","focus:outline-none","selection:bg-blue-800/50")})}),n.data?e.jsxs("footer",{className:"flex items-center justify-between px-4 py-1 border-t border-primary-200 bg-primary-50 text-xs text-primary-500",children:[e.jsx("span",{children:i}),e.jsx("span",{children:bi(n.data.size)})]}):null]})}function bi(i){return i<1024?`${i} B`:i<1024*1024?`${(i/1024).toFixed(1)} KB`:`${(i/(1024*1024)).toFixed(1)} MB`}function Fi(){const i=L(),{currentPath:s,editingFile:n}=F(),[a,o]=r.useState(!1),[c,t]=r.useState(!1),l=Ze(s),v=ie({queryKey:Ae,queryFn:function(){return te(i)},initialData:function(){return te(i)},staleTime:1/0}).data?.isSidebarCollapsed??!1,y=r.useCallback(()=>{Pe(i,function(x){return{...x,isSidebarCollapsed:!x.isSidebarCollapsed}})},[i]),f=r.useCallback(()=>{o(!0)},[]),u=r.useCallback(()=>{t(!0)},[]),d=r.useCallback(p=>{F.getState().openInEditor(p)},[]),N=r.useCallback(()=>{F.getState().closeEditor()},[]),C=r.useMemo(()=>({display:"flex",flexDirection:"column",height:"100%",minHeight:0}),[]),w=e.jsx(He,{isCollapsed:v,onToggleCollapse:y,onSelectAction:()=>{}});return e.jsxs("div",{className:"h-screen bg-surface text-primary-900",children:[e.jsxs("div",{className:h("h-full overflow-hidden grid grid-cols-[auto_1fr]"),children:[w,e.jsxs("main",{"aria-label":"File explorer",style:C,children:[e.jsxs("header",{className:"border-b border-primary-100 px-4 py-3",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx(Ge,{path:s})}),e.jsx(Je,{onUpload:f,onCreateFolder:u})]}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-auto",children:[e.jsx(pi,{listing:l.data,loading:l.isLoading,onOpenFile:d}),l.isError?e.jsxs("div",{className:"p-4 text-center","aria-live":"polite",children:[e.jsx("p",{className:"text-red-600 text-sm",children:l.error instanceof Error?l.error.message:"Failed to load files"}),e.jsx("button",{onClick:()=>{l.refetch()},className:"mt-2 text-sm text-primary-600 hover:text-primary-900 underline focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none rounded-sm",children:"Retry"})]}):null]}),e.jsx(fi,{open:a,onOpenChange:o,currentPath:s}),e.jsx(hi,{open:c,onOpenChange:t,currentPath:s})]})]}),n?e.jsx(gi,{filePath:n,onClose:N}):null]})}export{Fi as FileExplorerScreen};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/file-explorer-screen-CAsjd3w8.js","assets/main-B3N0eQFg.js","assets/visuallyHidden-DCCICp6T.js","assets/button-nDcsaNPl.js","assets/tooltip-C14vdXHK.js","assets/DirectionContext-DXtY05YF.js","assets/useButton-Bnnac1eR.js","assets/use-file-explorer-state-BnaJEqRP.js","assets/useCompositeItem-BgiEMKAt.js","assets/react-B16OrBeM.js","assets/useMutation-CFmVaBag.js"])))=>i.map(i=>d[i]);
2
- import{j as e,r,_ as s}from"./main-B3N0eQFg.js";const n=r.lazy(()=>s(()=>import("./file-explorer-screen-CAsjd3w8.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).then(t=>({default:t.FileExplorerScreen})));function o(){return e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"flex h-screen items-center justify-center text-primary-500 text-sm",children:"Loading…"}),children:e.jsx(n,{})})}export{o as component};