@pi-chamber/web 0.8.1 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/assets/{DiagramEditor-D_3eJVSw.js → DiagramEditor-DerMrS6m.js} +1 -1
  2. package/dist/assets/{DiagramView-pGYm0-DR.js → DiagramView-DdipXAq8.js} +1 -1
  3. package/dist/assets/{DiffView-BApPTLGp.js → DiffView-Gh9wjthp.js} +1 -1
  4. package/dist/assets/FilesView-BXp0yc0j.js +6 -0
  5. package/dist/assets/{GitView-uW3w_LlQ.js → GitView-BmNCkkoC.js} +3 -3
  6. package/dist/assets/{JsonTreeView-CpgqCk9_.js → JsonTreeView-CxXRXXzk.js} +1 -1
  7. package/dist/assets/{MarkdownRendererImpl-fI6n3kqT.js → MarkdownRendererImpl-DNZQgQua.js} +1 -1
  8. package/dist/assets/{PatchDiff-BRloGXPs.js → PatchDiff-B_NFEIX7.js} +1 -1
  9. package/dist/assets/{SessionSwitcherContent-BQc-vW4s.js → SessionSwitcherContent-Q4P2TGBr.js} +1 -1
  10. package/dist/assets/{SessionSwitcherDropdown-v_8TaIZm.js → SessionSwitcherDropdown-Cgw2mQIO.js} +2 -2
  11. package/dist/assets/{SessionUnreadDot-A7vSfll2.js → SessionUnreadDot-BxtTkvHB.js} +1 -1
  12. package/dist/assets/SettingsView-CFzxRzUq.js +2 -0
  13. package/dist/assets/{SettingsWindow-D7UDhYd4.js → SettingsWindow-BEjHL1ET.js} +1 -1
  14. package/dist/assets/{ToolOutputDialog-wpU0ylYS.js → ToolOutputDialog-C_7vJLEq.js} +1 -1
  15. package/dist/assets/{ToolPartDiffPreview-BvoQK5Gm.js → ToolPartDiffPreview-ClV785zX.js} +1 -1
  16. package/dist/assets/{VirtualizedFileDiff-DdPbLdh7.js → VirtualizedFileDiff-DrxkW2WQ.js} +1 -1
  17. package/dist/assets/{collapsible-BO6FIjvn.js → collapsible-CR3-hRMy.js} +1 -1
  18. package/dist/assets/{computeVirtualFileMetrics-DMvXzUJh.js → computeVirtualFileMetrics-D0mQcleY.js} +1 -1
  19. package/dist/assets/{contextFileOpenGuard-BwXQVjtS.js → contextFileOpenGuard-BRc5Z0g-.js} +1 -1
  20. package/dist/assets/{gitStatusPredicates-CgNk6M2_.js → gitStatusPredicates-DBGDfr1K.js} +1 -1
  21. package/dist/assets/{index-C3SyF-cA.js → index-CMfiVUIr.js} +1 -1
  22. package/dist/assets/index-CzO3ooje.css +1 -0
  23. package/dist/assets/index-ivrh3jfy.js +8 -0
  24. package/dist/assets/{isDiffPlainText-BboRbmcm.js → isDiffPlainText-MmBA1REG.js} +1 -1
  25. package/dist/assets/{isFilePlainText-BpTnLRyI.js → isFilePlainText-bQAPxqO9.js} +1 -1
  26. package/dist/assets/{main-CMOAwZnJ.js → main-BoVfUG73.js} +8 -8
  27. package/dist/assets/{main-xLwCWLu-.js → main-zZrKd3hZ.js} +2 -2
  28. package/dist/assets/{markdownCore-CmFv4H-w.js → markdownCore-B9jXCPry.js} +1 -1
  29. package/dist/assets/{miniChat-Vwo4K1IK.js → miniChat-Di2oVS5o.js} +2 -2
  30. package/dist/assets/{mobile-BRaxtEoC.js → mobile-VU_G_SgX.js} +2 -2
  31. package/dist/assets/{renderElectronMiniChatApp-DM4rRUUz.js → renderElectronMiniChatApp-Bi1927c8.js} +2 -2
  32. package/dist/assets/{renderMobileApp-DWWewNhc.js → renderMobileApp-D9mxhuaM.js} +3 -3
  33. package/dist/assets/runtimeEndpointReset-DImT35Ug.js +54 -0
  34. package/dist/assets/{runtimeSurface-SmPSdfop.js → runtimeSurface-CBaS2Ank.js} +1 -1
  35. package/dist/assets/{useAppFontEffects-Bg-8jtrQ.js → useAppFontEffects-8ZU-TTIW.js} +105 -105
  36. package/dist/assets/{useFilesViewSearch-GLcYNIUV.js → useFilesViewSearch-COow9O9x.js} +1 -1
  37. package/dist/assets/{usePushVisibilityBeacon-VSYBfNoY.js → usePushVisibilityBeacon-zYd3ppNh.js} +1 -1
  38. package/dist/assets/{useSwitcherItems-BkEt9K-N.js → useSwitcherItems-DOQqhi-e.js} +1 -1
  39. package/dist/assets/{vendor-codemirror-language-data-B5cJDWBR.js → vendor-codemirror-language-data-B_0wrsbo.js} +2 -2
  40. package/dist/assets/{web-components-0H9kvZwn.js → web-components-C9ENH49P.js} +1 -1
  41. package/dist/index.html +4 -4
  42. package/dist/mini-chat.html +3 -3
  43. package/dist/mobile.html +3 -3
  44. package/package.json +1 -1
  45. package/server/lib/pi/routes.test.js +39 -0
  46. package/server/lib/pi/session-daemon/DOCUMENTATION.md +1 -1
  47. package/server/lib/pi/session-daemon/extension-bridge.js +14 -11
  48. package/server/lib/pi/session-daemon/prompt-operations.test.js +73 -6
  49. package/server/lib/pi/session-daemon/session-daemon.js +163 -21
  50. package/server/lib/relay/host-client.test.js +3 -1
  51. package/server/lib/ui-auth/DOCUMENTATION.md +1 -1
  52. package/server/lib/ui-auth/ui-auth.js +23 -26
  53. package/server/lib/ui-auth/ui-auth.test.js +27 -0
  54. package/dist/assets/FilesView-CiPpuGiF.js +0 -6
  55. package/dist/assets/SettingsView-CphlZvfd.js +0 -2
  56. package/dist/assets/index-BebQicw3.css +0 -1
  57. package/dist/assets/index-Bkz23mZq.js +0 -8
  58. package/dist/assets/runtimeEndpointReset-BF60eHSx.js +0 -54
@@ -1,6 +1,6 @@
1
1
  import crypto from 'crypto';
2
2
  import { promisify } from 'util';
3
- import { SignJWT, jwtVerify } from 'jose';
3
+ import { EncryptJWT, jwtDecrypt, SignJWT, jwtVerify } from 'jose';
4
4
  import fs from 'fs';
5
5
  import path from 'path';
6
6
  import { resolvePiChamberDataDir, resolvePiChamberDataPath } from '../pichamber-data-dir.js';
@@ -399,40 +399,39 @@ export const createUiAuth = ({
399
399
  requireClientAuth = false,
400
400
  } = {}) => {
401
401
  const normalizedPassword = normalizePassword(password);
402
- const urlAuthTokens = new Map();
402
+ let jwtSecret = getOrCreateJwtSecret();
403
403
 
404
- const sweepUrlAuthTokens = () => {
405
- const now = Date.now();
406
- for (const [token, entry] of urlAuthTokens.entries()) {
407
- if (!entry || entry.expiresAt <= now) {
408
- urlAuthTokens.delete(token);
409
- }
410
- }
411
- };
404
+ const getUrlAuthEncryptionKey = () => crypto.createHash('sha256').update(jwtSecret).digest();
412
405
 
413
- const issueUrlAuthTokenForSession = (sessionToken) => {
414
- sweepUrlAuthTokens();
415
- const token = `${URL_AUTH_TOKEN_PREFIX}${crypto.randomBytes(24).toString('base64url')}`;
406
+ const issueUrlAuthTokenForSession = async (sessionToken) => {
416
407
  const expiresAt = Date.now() + URL_AUTH_TOKEN_TTL_MS;
417
- urlAuthTokens.set(token, { sessionToken, expiresAt });
418
- return { token, expiresAt };
408
+ const encryptedToken = await new EncryptJWT({ type: 'url-auth', sessionToken })
409
+ .setProtectedHeader({ alg: 'dir', enc: 'A256GCM' })
410
+ .setIssuedAt()
411
+ .setExpirationTime(Math.floor(expiresAt / 1000))
412
+ .encrypt(getUrlAuthEncryptionKey());
413
+ return { token: `${URL_AUTH_TOKEN_PREFIX}${encryptedToken}`, expiresAt };
419
414
  };
420
415
 
421
- const authenticateUrlAuthToken = (req) => {
416
+ const authenticateUrlAuthToken = async (req) => {
422
417
  if (!canUseUrlAuthTokenForRequest(req)) return null;
423
418
  const token = getUrlAuthTokenFromRequest(req);
424
419
  if (!token || !token.startsWith(URL_AUTH_TOKEN_PREFIX)) return null;
425
- const entry = urlAuthTokens.get(token);
426
- if (!entry || entry.expiresAt <= Date.now()) {
427
- urlAuthTokens.delete(token);
420
+ try {
421
+ const { payload } = await jwtDecrypt(token.slice(URL_AUTH_TOKEN_PREFIX.length), getUrlAuthEncryptionKey(), {
422
+ keyManagementAlgorithms: ['dir'],
423
+ contentEncryptionAlgorithms: ['A256GCM'],
424
+ });
425
+ if (payload.type !== 'url-auth' || typeof payload.sessionToken !== 'string' || !payload.sessionToken) return null;
426
+ return { ok: true, sessionToken: payload.sessionToken };
427
+ } catch {
428
428
  return null;
429
429
  }
430
- return { ok: true, sessionToken: entry.sessionToken || 'url:authenticated' };
431
430
  };
432
431
 
433
432
  const authenticateClientRequest = async (req, { allowUrlToken = true } = {}) => {
434
433
  if (allowUrlToken) {
435
- const urlAuth = authenticateUrlAuthToken(req);
434
+ const urlAuth = await authenticateUrlAuthToken(req);
436
435
  if (urlAuth) return urlAuth;
437
436
  }
438
437
  const token = getBearerTokenFromRequest(req);
@@ -554,14 +553,14 @@ export const createUiAuth = ({
554
553
  const clientAuth = await authenticateClientRequest(req, { allowUrlToken: false });
555
554
  if (clientAuth) {
556
555
  res.setHeader('Cache-Control', 'no-store');
557
- return res.json(issueUrlAuthTokenForSession(clientSessionToken(clientAuth)));
556
+ return res.json(await issueUrlAuthTokenForSession(clientSessionToken(clientAuth)));
558
557
  }
559
558
  if (requireClientAuth) {
560
559
  return res.status(401).json({ error: 'Client authentication required', locked: true, clientAuthRequired: true });
561
560
  }
562
561
  const sessionToken = await ensureSessionToken(req, res);
563
562
  res.setHeader('Cache-Control', 'no-store');
564
- return res.json(issueUrlAuthTokenForSession(sessionToken));
563
+ return res.json(await issueUrlAuthTokenForSession(sessionToken));
565
564
  },
566
565
  handlePasskeyStatus: (_req, res) => {
567
566
  res.json({ enabled: false, hasPasskeys: false, passkeyCount: 0, rpID: null });
@@ -600,7 +599,6 @@ export const createUiAuth = ({
600
599
 
601
600
  const salt = crypto.randomBytes(16);
602
601
  const expectedHash = crypto.scryptSync(normalizedPassword, salt, 64);
603
- let jwtSecret = getOrCreateJwtSecret();
604
602
  let passwordBinding = crypto.createHmac('sha256', jwtSecret).update(normalizedPassword).digest('hex');
605
603
  const resolveSessionTtlMs = (trustDevice) => (trustDevice ? TRUSTED_DEVICE_SESSION_TTL_MS : sessionTtlMs);
606
604
  let passkeyController = createUiPasskeys({
@@ -620,7 +618,6 @@ export const createUiAuth = ({
620
618
  const rotateJwtSecret = () => {
621
619
  const nextSecret = crypto.randomBytes(32).toString('hex');
622
620
  jwtSecret = persistJwtSecret(nextSecret);
623
- urlAuthTokens.clear();
624
621
  rebuildPasskeyController();
625
622
  };
626
623
 
@@ -793,7 +790,7 @@ export const createUiAuth = ({
793
790
  return respondUnauthorized(req, res);
794
791
  }
795
792
  res.setHeader('Cache-Control', 'no-store');
796
- return res.json(issueUrlAuthTokenForSession(sessionToken));
793
+ return res.json(await issueUrlAuthTokenForSession(sessionToken));
797
794
  };
798
795
 
799
796
  const handleSessionCreate = async (req, res) => {
@@ -228,6 +228,33 @@ describe('ui auth client credential seam', () => {
228
228
  }
229
229
  });
230
230
 
231
+ it('keeps terminal and dictation URL tokens valid across a server restart', async () => {
232
+ const createUiAuth = await loadCreateUiAuth();
233
+ const clientAuthController = {
234
+ authenticateBearerToken: async (token) => token === 'client-token' ? { ok: true, clientId: 'device-1' } : null,
235
+ };
236
+ const beforeRestart = createUiAuth({ password: 'secret', clientAuthController });
237
+ const mintRes = createResponse();
238
+ await beforeRestart.handleUrlAuthToken({
239
+ method: 'POST',
240
+ path: '/auth/url-token',
241
+ headers: { authorization: 'Bearer client-token', accept: 'application/json' },
242
+ }, mintRes);
243
+ beforeRestart.dispose();
244
+
245
+ const afterRestart = createUiAuth({ password: 'secret', clientAuthController });
246
+ for (const path of ['/api/terminal/ws', '/api/stt/ws']) {
247
+ const websocketReq = {
248
+ method: 'GET',
249
+ path,
250
+ url: `${path}?oc_url_token=${encodeURIComponent(mintRes.body.token)}`,
251
+ headers: { connection: 'Upgrade', upgrade: 'websocket' },
252
+ };
253
+ expect(await afterRestart.ensureSessionToken(websocketReq, createResponse())).toBe('client:device-1');
254
+ }
255
+ afterRestart.dispose();
256
+ });
257
+
231
258
  it('issues desktop client tokens with the UI session expiry', async () => {
232
259
  const createUiAuth = await loadCreateUiAuth();
233
260
  let createClientInput = null;
@@ -1,6 +0,0 @@
1
- import{j as e,R as o,b as Ds,r as k}from"./vendor-react-B5Z1Mdn3.js";import{c as H,G as As,H as Os,I as Ps,J as Ls,K as Is,u as he,L as ke,M as Vs,N as lt,O as Bs,P as $s,Q as Ws,g as cn,R as _s,T as ln,r as un,m as qs,U as rr,V as Us,k as Hs}from"./index-Bkz23mZq.js";import{bf as Ks,I as j,bg as mt,bh as Gs,b6 as ut,aQ as _n,aR as qn,bi as Un,bj as Hn,bk as Kn,bl as Gn,U,D as hr,a as gr,b as xr,af as Lt,t as ie,bm as It,bn as Js,bo as pt,ao as Jn,$ as dn,aL as Ys,aP as Yn,p as Xn,bp as Qn,o as Zn,n as mr,q as Xs,E as Le,F as Ie,G as Ve,j as Qs,aN as Zs,b9 as eo,aB as to,bb as ro,bq as fn,br as mn,L as no,be as ao,bs as so,bt as oo,bu as pn}from"./useAppFontEffects-Bg-8jtrQ.js";import{E as ce,D as $t,V as ea,s as io,d as co,e as lo,f as hn,k as nr,W as uo}from"./vendor-codemirror-view-Ct4T37Ue.js";import{H as gn,x as At,y as fo,i as mo,z as po}from"./vendor-codemirror-language-BByA_dGF.js";import{a as c,c as ho}from"./vendor-lezer-highlight-CDMHUZ74.js";import{i as ta,S as go,k as br,E as xo,o as Ue,a as bo}from"./vendor-codemirror-state-CNWM3Q8V.js";import{ensurePierreThemeRegistered as xn,getResolvedShikiTheme as vo}from"./appThemeRegistry-gegrE2dq.js";import{D as wo}from"./DiagramEditor-D_3eJVSw.js";import{C as yo,a as ko,b as jo,c as No,d as Co,e as Ot}from"./runtimeEndpointReset-BF60eHSx.js";import{s as ra,b as pr,c as na}from"./SessionUnreadDot-A7vSfll2.js";import{g as Vt,i as aa,a as vr,b as Wt,n as So,d as Ro,M as dt,c as de,s as Fo,e as Eo,f as zo,h as Mo,t as Pt,j as ar,u as To,k as Do,l as Ao,m as bn,o as Oo,p as vn}from"./useFilesViewSearch-GLcYNIUV.js";import{J as Po,F as Lo}from"./JsonTreeView-CpgqCk9_.js";import{h as Io,j as Vo,k as Bo,l as $o}from"./vendor-codemirror-commands-DYppkHEk.js";import{a as wn,g as Bt,b as yn,c as kn,o as Wo,d as _o}from"./vendor-codemirror-search-BV44140v.js";import{v as qo,g as Uo}from"./vendor-replit-codemirror-vim-CGHHNQxC.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zustand-GVb4H8HE.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-base-ui-vkqQ2P9o.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-react-dom-BZOGXAGe.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-use-sync-external-store-D0AXkdQC.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-sonner-BDtm25td.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./runtimeSurface-SmPSdfop.js";import"./vendor-dnd-kit-core-CP8ck10N.js";import"./vendor-dnd-kit-utilities-DTY1C6ST.js";import"./vendor-dnd-kit-accessibility-DZKKhs9S.js";import"./vendor-dnd-kit-sortable-B-Icjoj4.js";import"./vendor-cmdk-zXx6sGnS.js";import"./vendor-radix-ui-react-dialog-D2yhEu2p.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-8xy6TJML.js";import"./vendor-radix-ui-react-context-CFsX-AUC.js";import"./vendor-radix-ui-react-id-D2kS9K1j.js";import"./vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js";import"./vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js";import"./vendor-radix-ui-react-dismissable-layer-DrorBNg9.js";import"./vendor-radix-ui-react-primitive-DkH8dMOR.js";import"./vendor-radix-ui-react-slot-BIDFZX0-.js";import"./vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js";import"./vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js";import"./vendor-radix-ui-react-focus-scope-D2BkImwt.js";import"./vendor-radix-ui-react-portal-YgCRIyi7.js";import"./vendor-radix-ui-react-presence-D432pCMB.js";import"./vendor-radix-ui-react-focus-guards-BfdFmL7c.js";import"./vendor-react-remove-scroll-vR1dy1aP.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-CSAHp1YF.js";import"./vendor-react-style-singleton-Ctw6HnYx.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-Vv4V8Nd1.js";import"./vendor-use-callback-ref-CVVuCyLj.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-lang-javascript-DuOEwJ3f.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-autocomplete-wd6iRebq.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-lang-json-CZ07HmNC.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-djiuoTi8.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CKHqhW5R.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-DtcZDGqe.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-B5cJDWBR.js";import"./vendor-codemirror-lang-python-DzzokVau.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-tanstack-react-virtual-2skouoFw.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CfplGuM0.js";import"./vendor-motion-dom-DhJ-sYS5.js";import"./vendor-motion-utils-CKEGc_YG.js";import"./registerCustomTheme-DmolaWWZ.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-react-drawio-BYDptOsj.js";import"./permissionStore-iKN1K2_x.js";import"./web-components-0H9kvZwn.js";import"./computeVirtualFileMetrics-DMvXzUJh.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./Virtualizer-BSHVMKgK.js";import"./isFilePlainText-BpTnLRyI.js";function jn(t,r){const n=t.metadata.variant==="dark",s=t.config?.fonts?.mono||"monospace",i=t.colors.syntax.highlights||{},u=t.colors.syntax.tokens||{},d=r?.fontSize?`${r.fontSize}px`:"var(--text-code)",p=ce.theme({"&":{backgroundColor:"var(--background)",color:t.colors.syntax.base.foreground,fontSize:d,lineHeight:"1.5",position:"relative"},".cm-scroller":{fontFamily:s,backgroundColor:"var(--background)"},".cm-comment":{color:t.colors.syntax.base.comment},".cm-keyword":{color:t.colors.syntax.base.keyword},".cm-string":{color:t.colors.syntax.base.string},".cm-string-2":{color:u.stringEscape||t.colors.syntax.base.string},".cm-number":{color:t.colors.syntax.base.number},".cm-operator":{color:t.colors.syntax.base.operator},".cm-punctuation":{color:u.punctuation||t.colors.syntax.base.comment},".cm-atom":{color:u.boolean||t.colors.syntax.base.number},".cm-builtin":{color:u.functionCall||t.colors.syntax.base.function},".cm-def":{color:u.variableGlobal||t.colors.syntax.base.variable},".cm-attribute":{color:u.variableOther||u.variableProperty||t.colors.syntax.base.operator},".cm-meta":{color:t.colors.syntax.base.comment},".cm-property":{color:u.variableProperty||t.colors.syntax.base.keyword},".cm-variable":{color:t.colors.syntax.base.variable},".cm-variable-2":{color:u.variableOther||t.colors.syntax.base.function},".cm-variable-3":{color:u.variableGlobal||t.colors.syntax.base.type},".cm-tag":{color:u.tag||t.colors.syntax.base.keyword},".cm-link":{color:u.url||t.colors.syntax.base.keyword,textDecoration:"underline"},".cm-content":{caretColor:t.colors.interactive.cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:t.colors.interactive.cursor},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:t.colors.interactive.selection},".cm-gutters":{backgroundColor:"var(--background)",color:i.lineNumber||t.colors.syntax.base.comment,borderRight:`1px solid ${t.colors.interactive.border}`,position:"sticky",paddingRight:"8px",left:0,zIndex:2,boxShadow:"0 0 0 var(--background)"},".cm-gutter":{backgroundColor:"var(--background)"},".cm-gutterElement":{backgroundColor:"var(--background)"},".cm-lineNumbers":{backgroundColor:"var(--background)"},".cm-lineNumbers .cm-gutterElement":{paddingLeft:"8px",paddingRight:"8px",minWidth:"42px"},".cm-activeLineGutter":{color:i.lineNumberActive||t.colors.syntax.base.foreground},".cm-activeLine":{backgroundColor:t.colors.surface.overlay},".cm-panels":{backgroundColor:"transparent",color:t.colors.surface.foreground,position:"absolute",top:"0",right:"0",left:"auto",width:"auto",zIndex:10,pointerEvents:"none"},".cm-panels-top":{borderBottom:"none",position:"absolute",top:"6px",right:"14px",left:"auto",width:"auto"},".cm-panels-bottom":{position:"static",width:"100%",pointerEvents:"auto"},".cm-panels-bottom .cm-vim-panel":{borderTop:`1px solid ${t.colors.interactive.border}`,backgroundColor:t.colors.surface.elevated,color:t.colors.surface.mutedForeground,fontFamily:"var(--font-mono)",fontSize:"12px",minHeight:"22px",padding:"2px 8px"},".cm-panel.cm-search":{pointerEvents:"auto",padding:"4px",backgroundColor:`color-mix(in srgb, ${t.colors.surface.elevated} 85%, transparent)`,border:`1px solid ${t.colors.interactive.border}`,borderRadius:"10px",boxShadow:`0 2px 8px color-mix(in srgb, ${t.colors.surface.background} 60%, transparent)`,width:"auto",minWidth:"360px",maxWidth:"480px"},".cm-search":{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"0",width:"100%",color:t.colors.surface.foreground,fontFamily:"inherit",fontSize:"13px",lineHeight:"1"},".cm-search br":{display:"none"},".cm-search .cm-textfield":{appearance:"none",height:"26px",margin:0,padding:"0 8px",borderRadius:"6px !important",border:`1px solid ${t.colors.interactive.border}`,backgroundColor:t.colors.surface.background,color:t.colors.surface.foreground,fontFamily:"inherit",fontSize:"12px",lineHeight:"1",outline:"none",transition:"border-color 150ms ease"},".cm-search .cm-textfield::placeholder":{color:t.colors.surface.mutedForeground,opacity:1},".cm-search .cm-textfield:focus":{borderColor:t.colors.primary.base},'.cm-search .cm-textfield[name="search"]':{order:1,flex:"1 1 120px",maxWidth:"calc(100% - 142px)",minWidth:"100px"},".cm-search label":{order:2,display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:0,marginLeft:"1px",padding:0,borderRadius:"4px",border:"1px solid transparent",backgroundColor:"transparent",color:"transparent",cursor:"pointer",userSelect:"none",fontSize:"1px",lineHeight:"0",overflow:"hidden",position:"relative",transition:"background-color 120ms ease, border-color 120ms ease"},".cm-search label:hover":{backgroundColor:t.colors.interactive.hover},'.cm-search label:has(input[type="checkbox"]:checked)':{backgroundColor:t.colors.interactive.hover,borderColor:t.colors.interactive.border},'.cm-search [type="checkbox"]':{appearance:"none",WebkitAppearance:"none",width:"0",height:"0",margin:"0",padding:"0",border:"none",position:"absolute",opacity:"0",pointerEvents:"none"},".cm-search label::after":{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",fontSize:"13px",fontWeight:"600",lineHeight:"1",fontFamily:"inherit",color:t.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search label:hover::after":{color:t.colors.surface.foreground},'.cm-search label:has(input[type="checkbox"]:checked)::after':{color:t.colors.surface.foreground},'.cm-search label:has(input[name="case"])::after':{content:'"Aa"',fontSize:"12px",letterSpacing:"-0.5px"},'.cm-search label:has(input[name="re"])::after':{content:'".*"',fontSize:"13px",fontFamily:"monospace"},'.cm-search label:has(input[name="word"])::after':{content:'"ab"',fontSize:"12px",textDecoration:"underline",textUnderlineOffset:"2px"},".cm-search .cm-search-message":{order:3,color:t.colors.surface.mutedForeground,backgroundColor:"transparent",border:"none",borderRadius:"0",padding:"0 6px",fontSize:"11px",whiteSpace:"nowrap",lineHeight:"26px"},".cm-search .cm-button":{appearance:"none",WebkitAppearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:0,marginLeft:"1px",padding:0,borderRadius:"4px",border:"none",backgroundColor:"transparent",backgroundImage:"none",color:"transparent",cursor:"pointer",fontSize:"1px",fontWeight:"400",lineHeight:"0",overflow:"hidden",position:"relative",boxShadow:"none",transition:"background-color 120ms ease"},".cm-search .cm-button::after":{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",fontSize:"15px",lineHeight:"1",color:t.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search .cm-button:hover":{backgroundColor:t.colors.interactive.hover},".cm-search .cm-button:hover::after":{color:t.colors.surface.foreground},".cm-search .cm-button:active":{backgroundColor:t.colors.interactive.active},".cm-search .cm-button:focus-visible":{outline:"none",boxShadow:`0 0 0 1px ${t.colors.interactive.focusRing}`},".cm-search .cm-button:disabled":{opacity:.4,cursor:"default",pointerEvents:"none"},'.cm-search .cm-button[name="prev"]':{order:21,marginTop:"2px"},'.cm-search .cm-button[name="prev"]::after':{content:'"↑"'},'.cm-search .cm-button[name="next"]':{order:22,marginTop:"2px"},'.cm-search .cm-button[name="next"]::after':{content:'"↓"'},'.cm-search .cm-button[name="select"]':{order:23,marginTop:"2px"},'.cm-search .cm-button[name="select"]::after':{content:'"≡"',fontSize:"17px"},'.cm-panel.cm-search button[name="close"]':{order:5,appearance:"none",WebkitAppearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:"0 0 0 auto",padding:"0",borderRadius:"4px",border:"none",backgroundColor:"transparent",backgroundImage:"none",color:t.colors.surface.mutedForeground,cursor:"pointer",fontSize:"16px",lineHeight:"1",boxShadow:"none",position:"relative",overflow:"visible",transition:"background-color 120ms ease, color 120ms ease"},'.cm-panel.cm-search button[name="close"]:hover':{backgroundColor:t.colors.interactive.hover,color:t.colors.surface.foreground},'.cm-search .cm-button[name="replace"]':{order:24,marginTop:"2px"},'.cm-search .cm-button[name="replace"]::after':{content:'"⇄"'},'.cm-search .cm-button[name="replaceAll"], .cm-search .cm-button[name="replace-all"]':{order:25,marginTop:"2px"},'.cm-search .cm-button[name="replaceAll"]::after, .cm-search .cm-button[name="replace-all"]::after':{content:'"⇉"'},'.cm-search .cm-textfield[name="replace"]':{order:20,flex:"1 1 100%",maxWidth:"calc(100% - 142px)",minWidth:"80px",marginTop:"2px"},".cm-searchMatch":{backgroundColor:t.colors.status.infoBackground,boxShadow:`inset 0 0 0 1px ${t.colors.status.infoBorder}`,borderRadius:"2px"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:t.colors.interactive.selection,color:t.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${t.colors.interactive.borderFocus}`},"&.cm-focused":{outline:"none"}},{dark:n}),x=gn.define([{tag:[c.comment,c.docComment,c.meta,c.documentMeta],class:"cm-comment"},{tag:[c.keyword,c.controlKeyword,c.moduleKeyword,c.definitionKeyword,c.modifier],class:"cm-keyword"},{tag:[c.operatorKeyword,c.operator,c.derefOperator,c.updateOperator,c.definitionOperator,c.typeOperator,c.controlOperator,c.logicOperator,c.bitwiseOperator,c.arithmeticOperator,c.compareOperator],class:"cm-operator"},{tag:[c.punctuation,c.separator,c.bracket,c.paren,c.brace,c.squareBracket,c.angleBracket],class:"cm-punctuation"},{tag:[c.string,c.regexp,c.attributeValue,c.special(c.string),c.monospace],class:"cm-string"},{tag:c.escape,class:"cm-string-2"},{tag:[c.number,c.bool,c.atom,c.null,c.self],class:"cm-number"},{tag:[c.function(c.variableName),c.function(c.definition(c.variableName)),c.function(c.propertyName),c.standard(c.variableName),c.special(c.variableName)],class:"cm-builtin"},{tag:c.definition(c.variableName),class:"cm-def"},{tag:[c.variableName,c.local(c.variableName),c.constant(c.variableName),c.literal],class:"cm-variable"},{tag:c.propertyName,class:"cm-property"},{tag:c.attributeName,class:"cm-attribute"},{tag:[c.className,c.typeName,c.namespace],class:"cm-variable-3"},{tag:[c.tagName,c.labelName,c.annotation,c.macroName],class:"cm-tag"},{tag:c.link,class:"cm-link"},{tag:[c.heading,c.heading1,c.heading2,c.heading3,c.heading4,c.heading5,c.heading6],class:"cm-keyword"}]),N=gn.define([{tag:[c.comment,c.docComment,c.meta,c.documentMeta],color:t.colors.syntax.base.comment},{tag:[c.keyword,c.controlKeyword,c.moduleKeyword,c.definitionKeyword,c.modifier],color:t.colors.syntax.base.keyword},{tag:[c.operatorKeyword,c.operator,c.derefOperator,c.updateOperator,c.definitionOperator,c.typeOperator,c.controlOperator,c.logicOperator,c.bitwiseOperator,c.arithmeticOperator,c.compareOperator],color:t.colors.syntax.base.operator},{tag:[c.string,c.regexp,c.attributeValue,c.special(c.string),c.monospace],color:t.colors.syntax.base.string},{tag:c.escape,color:u.stringEscape||t.colors.syntax.base.string},{tag:[c.number,c.bool,c.atom,c.null,c.self],color:t.colors.syntax.base.number},{tag:[c.function(c.variableName),c.function(c.definition(c.variableName)),c.function(c.propertyName),c.standard(c.variableName),c.special(c.variableName)],color:t.colors.syntax.base.function},{tag:c.definition(c.variableName),color:u.variableGlobal||t.colors.syntax.base.variable},{tag:[c.variableName,c.local(c.variableName),c.constant(c.variableName),c.literal],color:t.colors.syntax.base.variable},{tag:c.propertyName,color:u.variableProperty||t.colors.syntax.base.variable},{tag:c.attributeName,color:u.variableOther||t.colors.syntax.base.variable},{tag:[c.className,c.typeName,c.namespace],color:t.colors.syntax.base.type},{tag:[c.tagName,c.labelName,c.annotation,c.macroName],color:u.tag||t.colors.syntax.base.keyword},{tag:c.link,color:u.url||t.colors.syntax.base.function,textDecoration:"underline"},{tag:[c.punctuation,c.separator,c.bracket,c.paren,c.brace,c.squareBracket,c.angleBracket],color:u.punctuation||t.colors.syntax.base.comment}]);return r?.syntaxColors===!1?[p]:[p,At(fo,{fallback:!0}),At(ho),At(x),At(N)]}const Ho=180,sa=go.define(),Ko=1,Go=2,Jo=4,Nn=new Map,Yo=(t,r)=>{const n=`${t}|${r}`,s=Nn.get(n);if(s)return s;let i="";t&&(i+=`color:${t};`),r&Ko&&(i+="font-style:italic;"),r&Go&&(i+="font-weight:bold;"),r&Jo&&(i+="text-decoration:underline;");const u=$t.mark({attributes:{style:i}});return Nn.set(n,u),u},Xo=(t,r)=>{const n=new br,s=t.state.doc,i=Math.min(r.length,s.lines);for(let u=0;u<i;u+=1){const d=r[u];if(!d||d.length===0)continue;const p=s.line(u+1);let x=p.from;for(const[N,g,z]of d){if(N<=0)continue;const m=x,R=Math.min(x+N,p.to);x+=N,!(R<=m)&&(!g&&!z||n.add(m,R,Yo(g,z)))}}return n.finish()},Qo=ta.define({create(){return $t.none},update(t,r){let n=t.map(r.changes);for(const s of r.effects)s.is(sa)&&(n=s.value);return n},provide:t=>ce.decorations.from(t)}),Zo=t=>ea.fromClass(class{timer;generation=0;constructor(r){this.tokenize(r)}update(r){r.docChanged&&this.schedule(r.view)}schedule(r){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.tokenize(r)},Ho)}async tokenize(r){const n=++this.generation,s=r.state.doc.toString(),i=await Ks(s,t.language,t.themeName,t.theme);i&&n===this.generation&&r.state.doc.length===s.length&&r.dispatch({effects:sa.of(Xo(r,i))})}destroy(){this.timer&&clearTimeout(this.timer)}}),ei=t=>[Qo,Zo(t)],Me=t=>(t||"").replace(/\\/g,"/").replace(/\/+$/g,""),tt=t=>{const r=Me(t);return!r||r==="/"?r||"/":r.split("/").filter(Boolean).at(-1)??r},oa=t=>{const r=Me(t);if(!r||r==="/")return null;const n=r.lastIndexOf("/");if(n<0)return null;if(n===0)return"/";const s=r.slice(0,n);return/^[A-Za-z]:$/.test(s)?`${s}/`:s},Cn=(t,r)=>{const n=Me(t),s=Me(r);return!n||!s?!1:n===s||n.startsWith(`${s}/`)},Sn=(t,r)=>{const n=Me(t);if(!n)return Me(r);if(n.startsWith("/")||/^[A-Za-z]:(\/|$)/.test(n))return n;const s=Me(r);return s?`${s}/${n}`:n},ti=(t,r)=>{const n=Me(t),s=Me(r);if(!n||n===s)return!1;const i=oa(n);return i?s&&Cn(n,s)?Cn(i,s):!0:!1},ri=t=>{if(typeof t!="number"||!Number.isFinite(t)||t<0)return"";if(t<1024)return`${t} B`;const r=["KB","MB","GB"];let n=t/1024;for(const s of r){if(n<1024||s===r[r.length-1])return`${n.toFixed(n>=10?0:1)} ${s}`;n/=1024}return""},ni=(t,r)=>!r||t===r?tt(t):t.startsWith(`${r}/`)?t.slice(r.length+1):t,ai=({root:t,directory:r,entries:n,query:s,searchResults:i,isSearching:u,directoryError:d,refreshing:p,editorPath:x,editor:N,onClose:g,onQueryChange:z,onOpenDirectory:m,onOpenFile:R,onBackFromEditor:C,onRefresh:w})=>{if(!t)return e.jsx(ft,{message:"Select a project to browse files."});if(x)return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-transparent text-foreground",children:[e.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-1 px-2 text-foreground",children:[e.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":"Back",onClick:C,style:{touchAction:"manipulation"},children:e.jsx(j,{name:"arrow-left",className:"size-5"})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:tt(x)})})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:N})]});const $=r===t?"Project files":tt(r),E=ti(r,t)?oa(r):null,l=!!E&&!s.trim(),V=E===t?"Project files":tt(E??"");return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-transparent text-foreground",children:[e.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-1 px-2 text-foreground",children:[g?e.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":"Close",onClick:g,style:{touchAction:"manipulation"},children:e.jsx(j,{name:"close",className:"size-5"})}):null,l&&E?e.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":`Back to ${tt(E)}`,onClick:()=>m(E),style:{touchAction:"manipulation"},children:e.jsx(j,{name:"arrow-left",className:"size-5"})}):null,e.jsx("div",{className:"min-w-0 flex-1 px-1",children:e.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:$})}),e.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":"Refresh files",onClick:w,style:{touchAction:"manipulation"},children:e.jsx(j,{name:"refresh",className:H("size-5",p&&"animate-spin")})})]}),e.jsx("div",{className:"shrink-0 px-3 pb-2 pt-1",children:e.jsxs("div",{className:"relative",children:[e.jsx(j,{name:"search",className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(mt,{value:s,onChange:B=>z(B.target.value),placeholder:"Search files",className:"h-11 pl-9"})]})}),e.jsx(Gs,{className:"min-h-0 w-full flex-1 overflow-y-auto pb-3",children:d?e.jsx(ft,{message:d}):s.trim()?e.jsx(si,{root:t,results:i,isSearching:u,onOpenFile:R}):n===void 0?e.jsx(ft,{loading:!0,message:"Loading..."}):e.jsxs("div",{className:"flex w-full min-w-0 flex-col",children:[l&&E?e.jsxs("button",{type:"button",className:ra,"aria-label":`Up one level to ${V}`,onClick:()=>m(E),style:{touchAction:"manipulation"},children:[e.jsx(j,{name:"arrow-left",className:H(pr(!0),"text-muted-foreground")}),e.jsx("span",{className:H(na(!0),"flex-1 text-muted-foreground"),children:"Up one level"})]}):null,n.length===0?e.jsx("div",{className:"px-3 py-8 text-center typography-ui-label text-muted-foreground",children:"This directory is empty."}):null,n.map(B=>e.jsx(ia,{name:B.name,path:B.path,directory:B.type==="directory",meta:B.type==="directory"?void 0:ri(B.size),onClick:()=>B.type==="directory"?m(Sn(B.path,r||t)):R(Sn(B.path,r||t))},B.path))]})})]})},ia=({name:t,path:r,directory:n,meta:s,onClick:i})=>e.jsxs("button",{type:"button",className:ra,onClick:i,style:{touchAction:"manipulation"},children:[n?e.jsx(j,{name:"folder-3-fill",className:H(pr(!0),"text-primary/80")}):e.jsx(ut,{filePath:r,className:pr(!0)}),e.jsx("span",{className:H(na(!0),"flex-1 text-foreground"),children:t}),s?e.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:s}):null,n?e.jsx(j,{name:"arrow-right-s",className:"size-4 shrink-0 text-muted-foreground/60"}):null]}),si=({root:t,results:r,isSearching:n,onOpenFile:s})=>n?e.jsx(ft,{loading:!0,message:"Loading..."}):r.length===0?e.jsx(ft,{message:"No files found."}):e.jsx("div",{className:"flex w-full min-w-0 flex-col",children:r.map(i=>e.jsx(ia,{name:tt(i.path),path:i.path,directory:!1,meta:i.relativePath??ni(i.path,t),onClick:()=>s(i.path)},i.path))}),ft=({message:t,loading:r=!1})=>e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:e.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[r?e.jsx(j,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):e.jsx(j,{name:"folder-open-fill",className:"size-6 text-muted-foreground"}),e.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:t})]})}),oi=({activeDialog:t,dialogData:r,dialogInputValue:n,onDialogInputChange:s,isDialogSubmitting:i,onDialogSubmit:u,onClose:d,inputRef:p})=>e.jsx(_n,{open:!!t,onOpenChange:x=>!x&&d(),children:e.jsxs(qn,{initialFocus:p,children:[e.jsxs(Un,{children:[e.jsxs(Hn,{children:[t==="createFile"&&"Create File",t==="createFolder"&&"Create Folder",t==="rename"&&"Rename",t==="delete"&&"Delete"]}),e.jsxs(Kn,{children:[t==="createFile"&&`Create a new file in ${r?.path??"root"}`,t==="createFolder"&&`Create a new folder in ${r?.path??"root"}`,t==="rename"&&`Rename ${r?.name??""}`,t==="delete"&&`Are you sure you want to delete ${r?.name??""}? This action cannot be undone.`]})]}),t!=="delete"&&e.jsx("div",{className:"py-4",children:e.jsx(mt,{value:n,onChange:x=>s(x.target.value),placeholder:t==="rename"?"New name":"Name",onKeyDown:x=>{x.key==="Enter"&&u()},ref:p})}),e.jsxs(Gn,{children:[e.jsx(U,{variant:"outline",onClick:d,disabled:i,children:"Cancel"}),e.jsx(U,{variant:t==="delete"?"destructive":"default",onClick:()=>{u()},disabled:i||t!=="delete"&&!n.trim(),children:i?e.jsx(j,{name:"loader-4",className:"size-4 animate-spin"}):t==="delete"?"Delete":"Confirm"})]})]})}),ii=({label:t,iconDataUrl:r})=>{const[n,s]=o.useState(!1),i=t.trim().slice(0,1).toUpperCase()||"?";return r&&!n?e.jsx("img",{src:r,alt:"",className:"size-4 rounded-sm",onError:()=>s(!0)}):e.jsx("span",{className:H("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),children:i})},ca=({filePath:t,extension:r})=>e.jsx(ut,{filePath:t,extension:r}),ci=({status:t})=>{const r={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"}[t];return e.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:r}})},Rn=({name:t})=>{const r=o.useRef(null),n=o.useRef(null),[s,i]=o.useState(!1);return o.useLayoutEffect(()=>{const u=r.current,d=n.current;if(!u||!d)return;const p=()=>{i(d.scrollWidth>u.clientWidth+1)};p();const x=new ResizeObserver(p);return x.observe(u),x.observe(d),()=>{x.disconnect()}},[t]),e.jsxs("span",{ref:r,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[e.jsx("span",{ref:n,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:t}),s?e.jsxs("span",{className:"open-file-name-marquee-track",children:[e.jsx("span",{className:"open-file-name-marquee-item",children:t}),e.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:t})]}):e.jsx("span",{className:"block min-w-0 truncate",children:t})]})},li=({node:t,root:r,isExpanded:n,isActive:s,isMobile:i,isBrowserClient:u,alwaysShowActions:d,status:p,badge:x,permissions:N,downloadFile:g,contextMenuPath:z,setContextMenuPath:m,rightClickMenuPath:R,setRightClickMenuPath:C,onSelect:w,onToggle:$,onRevealPath:E,onOpenDialog:l})=>{const V=t.type==="directory",{canRename:B,canCreateFile:I,canCreateFolder:_,canDelete:K,canReveal:W}=N,T=!V&&!!g,S=W&&!u,D=B||I||_||K||T||S,b=o.useCallback(O=>{D&&(O?.preventDefault(),C(t.path))},[D,t.path,C]),M=o.useCallback(()=>{V?$(t.path):w(t)},[V,t,w,$]),y=o.useCallback(O=>{O.stopPropagation(),C(null),m(t.path)},[t.path,m,C]),F=({Item:O,Separator:q})=>e.jsxs(e.Fragment,{children:[B&&e.jsxs(O,{onClick:P=>{P.stopPropagation(),l("rename",t)},children:[e.jsx(j,{name:"edit",className:"mr-2 size-4"})," ","Rename"]}),e.jsxs(O,{onClick:P=>{P.stopPropagation(),Lt(t.path).then(J=>{if(J.ok){ie.success("Path copied");return}ie.error("Copy failed")})},children:[e.jsx(j,{name:"file-copy",className:"mr-2 size-4"})," ","Copy Path"]}),e.jsxs(O,{onClick:P=>{P.stopPropagation();const J=Vt(r,t.path)||t.path;Lt(J).then(Q=>{if(Q.ok){ie.success("Relative path copied");return}ie.error("Copy failed")})},children:[e.jsx(j,{name:"file-copy-2",className:"mr-2 size-4"})," ","Copy Relative Path"]}),!V&&g&&e.jsxs(O,{onClick:P=>{P.stopPropagation(),g(t.path).catch(J=>{console.error("Download failed:",J),ie.error("Operation failed")})},children:[e.jsx(j,{name:"download",className:"mr-2 size-4"})," ",u?"Download":"Save"]}),S&&e.jsxs(O,{onClick:P=>{P.stopPropagation(),E(t.path)},children:[e.jsx(j,{name:"folder-received",className:"mr-2 size-4"})," ",As()]}),V&&(I||_)&&e.jsxs(e.Fragment,{children:[e.jsx(q,{}),I&&e.jsxs(O,{onClick:P=>{P.stopPropagation(),l("createFile",t)},children:[e.jsx(j,{name:"file-add",className:"mr-2 size-4"})," ","New File"]}),_&&e.jsxs(O,{onClick:P=>{P.stopPropagation(),l("createFolder",t)},children:[e.jsx(j,{name:"folder-add",className:"mr-2 size-4"})," ","New Folder"]})]}),K&&e.jsxs(e.Fragment,{children:[e.jsx(q,{}),e.jsxs(O,{onClick:P=>{P.stopPropagation(),l("delete",t)},className:"text-destructive focus:text-destructive",children:[e.jsx(j,{name:"delete-bin",className:"mr-2 size-4"})," ","Delete"]})]})]});return e.jsxs(yo,{open:R===t.path,onOpenChange:O=>C(O?t.path:null),children:[e.jsxs(ko,{render:e.jsx("div",{className:"group relative flex items-center",onContextMenu:i?void 0:b}),children:[e.jsxs("button",{type:"button",onClick:M,onContextMenu:i?void 0:b,className:H("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",s?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[V?n?e.jsx(j,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):e.jsx(j,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):e.jsx(ca,{filePath:t.path,extension:t.extension}),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:t.path,children:t.name}),!V&&p&&e.jsx(ci,{status:p}),V&&x&&e.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[x.modified>0&&e.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",x.modified]}),x.added>0&&e.jsxs("span",{className:"text-[var(--status-success)]",children:["+",x.added]})]})]}),D&&e.jsx("div",{className:H("absolute right-1 top-1/2 -translate-y-1/2",d?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:e.jsxs(hr,{open:z===t.path,onOpenChange:O=>m(O?t.path:null),children:[e.jsx(gr,{asChild:!0,children:e.jsx(U,{variant:"ghost",size:"icon",className:"size-6",onClick:y,children:e.jsx(j,{name:"more-2-fill",className:"size-4"})})}),e.jsx(xr,{align:"end",side:"bottom",onCloseAutoFocus:()=>m(null),children:F({Item:It,Separator:Js})})]})})]}),e.jsx(jo,{className:"min-w-[180px]",children:F({Item:No,Separator:Co})})]})},sr=(t,r,n)=>{const[s,i]=o.useState(""),[u,d]=o.useState(0);return o.useEffect(()=>{if(!t){i("");return}let p=!1;i("");const x=Os(),N=Ps(x);Ls(x).then(z=>{p||!z||(i(t),r(null))}).catch(z=>{p||(r(z instanceof Error?z.message:n),i(t))});const g=Is(()=>{p||(i(t),d(z=>z+1),r(null))});return()=>{p=!0,N(),g()}},[t,r,n]),{readyKey:s,nonce:u}},ui=t=>t!==null&&typeof t=="object"&&"updateStatus"in t&&typeof t.updateStatus=="function",di=t=>{const r=document.createElement("div");r.className="cm-vim-panel";const n=Uo(t);if(!n)return{top:!1,dom:r};n.state.statusbar=r;const s=n.state.vimPlugin;return ui(s)&&s.updateStatus(),{top:!1,dom:r,destroy(){n.state.statusbar===r&&(n.state.statusbar=null)}}};function Fn(t){return t?[qo(),io.of(di),co()]:[]}const fi={next:"Next match",prev:"Previous match",select:"Select all matches",replace:"Replace",replaceAll:"Replace all",close:"Close"},mi={case:"Match case",re:"Regular expression",word:"Match whole word"};function pi(t){const r=t.querySelector(".cm-search");if(r){for(const[n,s]of Object.entries(fi)){const i=r.querySelector(`button[name="${n}"]`);i&&!i.title&&(i.title=s)}for(const[n,s]of Object.entries(mi)){const u=r.querySelector(`input[name="${n}"]`)?.parentElement;u&&!u.title&&(u.title=s)}}}const or=new WeakMap;function hi(t,r){const n=Bt(t.state);if(!n.valid)return or.delete(t),0;const s=or.get(t);if(!r&&s?.doc===t.state.doc&&s.query.eq(n))return s.total;const i=n.getCursor(t.state);let u=0;for(let d=i.next();!d.done;d=i.next())u+=1;return or.set(t,{query:n,doc:t.state.doc,total:u}),u}function gi(t){const r=Bt(t.state);if(!r.valid)return 0;const n=t.state.selection.main,s=r.getCursor(t.state);let i=0,u=0;for(let d=s.next();!d.done;d=s.next()){const p=d.value;if(i+=1,u===0&&(u=i),n.from===p.from&&n.to===p.to||n.from<p.to&&n.to>p.from||p.from>=n.head)return i}return u}function En(t,r,n=!1){const s=t.querySelector(".cm-search");if(!s)return;let i=s.querySelector(".cm-search-message");if(!i){i=document.createElement("span"),i.className="cm-search-message",i.setAttribute("aria-live","polite");const p=s.querySelector('button[name="next"]'),x=p?.parentNode===s?p:s.firstChild;s.insertBefore(i,x)}const u=hi(r,n),d=u===0?0:gi(r);i.textContent=u===0?"":`${d}/${u}`}const zn=new Ue,Mn=new Ue,Tn=new Ue,Dn=new Ue,An=new Ue,On=new Ue,Pn=new Ue,Ln=t=>t,ir=po,xi=Wo,bi=_o;class vi extends uo{constructor(r,n){super(),this.id=r,this.containerMap=n}toDOM(){let r=this.containerMap.get(this.id);return r||(r=document.createElement("div"),r.className="oc-block-widget",r.dataset.widgetId=this.id,this.containerMap.set(this.id,r)),r}eq(r){return r.id===this.id}destroy(){}}const In=(t,r)=>!t||t.length===0?[]:ta.define({create(n){const s=new br,i=[...t].sort((u,d)=>u.afterLine-d.afterLine);for(const u of i){const d=n.doc.lines;if(u.afterLine>d)continue;const p=n.doc.line(u.afterLine);s.add(p.to,p.to,$t.widget({widget:new vi(u.id,r),block:!0,side:1}))}return s.finish()},update(n,s){return n.map(s.changes)},provide:n=>ce.decorations.from(n)}),Vn=t=>{if(!t)return[];const r=Math.max(1,t.start),n=Math.max(r,t.end);return ea.fromClass(class{decorations;constructor(s){this.decorations=this.build(s)}update(s){(s.docChanged||s.viewportChanged)&&(this.decorations=this.build(s.view))}build(s){const i=new br;for(let u=r;u<=n&&u<=s.state.doc.lines;u+=1){const d=s.state.doc.line(u);i.add(d.from,d.from,$t.line({class:"oc-cm-selected-line"}))}return i.finish()}},{decorations:s=>s.decorations})};function wi({value:t,onChange:r,extensions:n,className:s,readOnly:i,lineNumbersConfig:u,highlightLines:d,onViewReady:p,onViewDestroy:x,blockWidgets:N,enableSearch:g,searchOpen:z,onSearchOpenChange:m,vimMode:R}){const C=o.useRef(null),w=o.useRef(null),$=o.useRef(t),E=o.useRef(r),l=o.useRef(p),V=o.useRef(x),B=o.useRef(m),I=o.useRef(N),_=o.useRef(R),K=o.useRef(new Map),[W,T]=o.useState([]),S=o.useCallback(b=>{const M=(b??[]).map(y=>{const F=K.current.get(y.id);return F?{id:y.id,content:y.content,container:F}:null}).filter(y=>y!==null);T(y=>y.length===M.length&&y.every((F,O)=>{const q=M[O];return F.id===q.id&&F.content===q.content&&F.container===q.container})?y:M)},[]),D=o.useCallback(b=>{const M=C.current,y=b??w.current;if(!M||!y)return;const F=y.dom.querySelector(".cm-gutters"),O=F instanceof HTMLElement?F.getBoundingClientRect().width:0;M.style.setProperty("--oc-editor-gutter-width",`${O}px`)},[]);return o.useEffect(()=>{$.current=t},[t]),o.useEffect(()=>{E.current=r},[r]),o.useEffect(()=>{l.current=p,V.current=x},[p,x]),o.useEffect(()=>{B.current=m},[m]),o.useEffect(()=>{I.current=N,S(N)},[N,S]),o.useEffect(()=>{if(!C.current)return;const b=(()=>{if(typeof document>"u")return null;const y=document.querySelector('meta[name="csp-nonce"]')?.getAttribute("content");if(y)return y;const F=window.__PICHAMBER_CSP_NONCE__;return typeof F=="string"&&F.length>0?F:null})(),M=xo.create({doc:$.current,extensions:[...b?[ce.cspNonce.of(b)]:[],lo({fixed:!0}),zn.of(hn(u)),Io(),mo.of(" "),Pn.of(Fn(R)),nr.of([Vo,...Bo,...$o]),ce.updateListener.of(y=>{D(y.view),(y.viewportChanged||y.geometryChanged)&&S(I.current);const F=wn(y.startState),O=wn(y.state);F!==O&&B.current?.(O);const q=!Bt(y.startState).eq(Bt(y.state));if(O&&(F!==O||q||y.docChanged||y.selectionSet)&&En(y.view.dom,y.view,F!==O||q||y.docChanged),!y.docChanged)return;const P=y.state.doc.toString();$.current=P,E.current(P),S(I.current)}),Mn.of(ce.editable.of(!i)),Tn.of(n??[]),Dn.of(Vn(d)),An.of(In(N,K.current)),On.of(g?[yn({top:!0}),nr.of(Ln(kn))]:[])]});return w.current=new ce({state:M,parent:C.current}),ir(w.current,w.current.state.doc.length,200),w.current.requestMeasure(),requestAnimationFrame(()=>{D(w.current),S(I.current)}),w.current&&l.current?.(w.current),()=>{V.current?.(),w.current?.destroy(),w.current=null,T([])}},[I,D,S]),o.useEffect(()=>{const b=w.current;b&&(b.dispatch({effects:[zn.reconfigure(hn(u)),Mn.reconfigure(ce.editable.of(!i)),Tn.reconfigure(n??[]),Dn.reconfigure(Vn(d)),An.reconfigure(In(N,K.current)),On.reconfigure(g?[yn({top:!0}),nr.of(Ln(kn))]:[])]}),ir(b,b.state.doc.length,200),b.requestMeasure(),requestAnimationFrame(()=>{D(b),S(I.current)}))},[n,d,u,i,N,g,D,S]),o.useEffect(()=>{const b=w.current;if(!b){_.current=R;return}_.current!==R&&(_.current=R,b.dispatch({effects:Pn.reconfigure(Fn(R))}))},[R]),o.useEffect(()=>{const b=w.current;!b||g===!1||(z?(xi(b),requestAnimationFrame(()=>{pi(b.dom),En(b.dom,b,!0)})):bi(b))},[z,g]),o.useEffect(()=>{const b=w.current;if(!b)return;const M=b.state.doc.toString();M!==t&&(b.dispatch({changes:{from:0,to:M.length,insert:t}}),ir(b,b.state.doc.length,300),b.requestMeasure(),requestAnimationFrame(()=>D(b)))},[t,D]),e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:C,className:H("h-full w-full","[&_.cm-editor]:h-full [&_.cm-editor]:w-full","[&_.cm-scroller]:font-mono [&_.cm-scroller]:text-[var(--text-code)] [&_.cm-scroller]:leading-6","[&_.cm-lineNumbers]:text-[var(--tools-edit-line-number)]",s)}),W.map(b=>Ds.createPortal(b.content,b.container,b.id))]})}const Bn=({variant:t,selectedFile:r,loading:n,suppressLoadingIndicator:s,fileError:i,isSelectedImage:u,imageSrc:d,imagePreviewNonce:p,isSelectedPdf:x,pdfSrc:N,pdfPreviewNonce:g,isUnsupportedBinary:z,onDownload:m,enableRichPreviews:R,drawioViewMode:C,drawioRemountNonce:w,diagramEditorRef:$,diagramEditorXml:E,onDiagramChange:l,jsonViewMode:V,markdownViewMode:B,htmlViewMode:I,htmlLoading:_,htmlPreviewNonce:K,htmlPreviewSrc:W,fileContent:T,canUseShikiFileView:S,textViewMode:D,draftContent:b,onDraftChange:M,canEdit:y,vimMode:F,editorExtensions:O,editorWrapperRef:q,shouldMaskEditorForPendingNavigation:P,onEditorViewReady:J,onEditorViewDestroy:Q,enableSearch:ge=!1,searchOpen:xe,onSearchOpenChange:fe,pierreTheme:je,shikiThemeType:Be,wrapLines:be})=>{const ae=t==="fullscreen",se=ae?"p-4":"p-3",Ne=!!(r?.path&&pt(r.path)),Z=!!(r?.path&&aa(r.path)),L=!!(r?.path&&vr(r.path)),G=!!(r?.path&&Wt(r.path)),ne=()=>r?e.jsx("div",{className:"h-full",children:e.jsx(Lo,{file:{name:r.name,contents:b,lang:Yn(r.path)||void 0},options:{disableFileHeader:!0,overflow:be?"wrap":"scroll",theme:je,themeType:Be},className:"block h-full w-full",style:{height:"100%"}})}):null;return e.jsx(Jn,{outerClassName:"h-full min-w-0",className:"h-full min-w-0",children:r?n?s?e.jsx("div",{className:se}):e.jsxs("div",{className:`${se} flex items-center gap-2 typography-ui text-muted-foreground`,children:[e.jsx(j,{name:"loader-4",className:"size-4 animate-spin"}),ae?"Loading…":"Loading..."]}):i?e.jsx("div",{className:`${se} typography-ui text-[color:var(--status-error)]`,children:i}):u?e.jsx("div",{className:H("flex h-full items-center justify-center",se),children:e.jsx("img",{src:d,alt:r.name||"Image",className:H("max-w-full object-contain rounded-md border border-border/30 bg-primary/10",ae?"max-h-full":"max-h-[70vh]")},p)}):x?e.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:e.jsx("iframe",{src:N,className:"h-full w-full border-0",title:r.name},g)}):z?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[e.jsx("div",{className:"typography-ui-header text-foreground",children:"Cannot preview binary file"}),e.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:"This file is binary and cannot be edited in PiChamber. Download it to open with another app."}),m?e.jsxs(U,{type:"button",variant:"outline",size:"sm",onClick:m,children:[e.jsx(j,{name:"download",className:"mr-2 size-4"}),"Save file"]}):null]}):R&&Ne&&C==="preview"?e.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:e.jsx(wo,{ref:$,xml:E,onChange:l},`${r.path}:${w}`)}):R&&Z&&V==="tree"?e.jsx(dn,{fallback:e.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[e.jsx("div",{className:"mb-1 font-medium text-destructive",children:"JSON viewer unavailable"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Switch to text mode to view raw content."})]}),children:e.jsx("div",{className:"h-full overflow-auto",children:e.jsx(Po,{jsonString:T,maxHeight:"100%",initiallyExpandedDepth:2})})}):L&&B==="preview"?e.jsxs("div",{className:H("h-full overflow-auto",se),children:[T.length>500*1024?e.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:`This file is large (${Math.round(T.length/1024)}KB). Preview may be limited.`}):null,e.jsx(dn,{fallback:e.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[e.jsx("div",{className:"mb-1 font-medium text-destructive",children:"Preview unavailable"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Switch to edit mode to fix the issue."})]}),children:e.jsx(Ys,{content:T,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}):R&&G&&I==="preview"?_?e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:"Loading..."}):e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx("iframe",{src:W,className:"w-full h-full border-none",sandbox:"allow-scripts allow-same-origin allow-forms",title:"HTML Preview"},K)}):S&&D==="view"?ne():e.jsxs("div",{className:H("relative h-full",P&&"overflow-hidden"),ref:q,children:[e.jsx("div",{className:H("h-full",P&&"invisible"),children:e.jsx(wi,{value:b,onChange:M,readOnly:!y,vimMode:F,extensions:O,className:"h-full",onViewReady:J,onViewDestroy:Q,...ge?{enableSearch:!0,searchOpen:xe,onSearchOpenChange:fe}:{}})}),P?e.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:e.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[e.jsx(j,{name:"loader-4",className:"size-4 animate-spin"}),"Opening file at change..."]})}):null]}):e.jsx("div",{className:`${se} typography-ui text-muted-foreground`,children:"Pick a file from the tree."})})};async function yi(t,r,n){if(Xn(t)&&!Qn(t))return{kind:r?"desktop-image":"asset-image"};if(Zn(t))return{kind:"pdf"};if(mr(t))return{kind:"binary",detectedFromContent:!1};const i=await n(t);if(Xs(i))return{kind:"binary",detectedFromContent:!0};const u=So(i);return{kind:"text",content:u,draft:u.length>dt?`${u.slice(0,dt)}
2
-
3
- … truncated …`:u,lineEnding:Ro(i)}}function ki({isDirty:t,saveDraft:r}){const n=he(m=>m.setMainTabGuard),[s,i]=k.useState(!1),u=k.useRef(null),d=k.useRef(!1),p=k.useCallback(m=>d.current?(d.current=!1,!1):t?(u.current=m,i(!0),!0):!1,[t]);k.useEffect(()=>{if(!t){n(null);return}const m=R=>!p({kind:"tab",tab:R});return n(m),()=>{he.getState().mainTabGuard===m&&n(null)}},[t,p,n]);const x=k.useCallback(()=>{const m=u.current;return u.current=null,d.current=!0,i(!1),m?.kind==="tab"&&n(null),m},[n]),N=k.useCallback(()=>x(),[x]),g=k.useCallback(async()=>await r()?x():(d.current=!1,null),[r,x]),z=k.useCallback(m=>{m||i(!0)},[]);return{confirmOpen:s,discardAndTakeIntent:N,keepModalOpen:z,requestNavigation:p,saveAndTakeIntent:g}}function ji(t,r){if(t.state.doc.length!==r.length)return!1;if(r.length===0)return!0;const n=Math.min(128,r.length);if(t.state.sliceDoc(0,n)!==r.slice(0,n))return!1;const s=Math.max(0,r.length-n);return t.state.sliceDoc(s,r.length)===r.slice(s)}function Ni({root:t,selectedPath:r,loadedPath:n,fileLoading:s,fileError:i,isImage:u,isPdf:d,isUnsupportedBinary:p,canEdit:x,textViewMode:N,setTextViewMode:g,draftContent:z,confirmDiscardOpen:m,selectFilePath:R}){const C=he(S=>S.pendingFileNavigation),w=he(S=>S.setPendingFileNavigation),$=he(S=>S.pendingFileFocusPath),E=he(S=>S.setPendingFileFocusPath),l=k.useRef(null),[V,B]=k.useState(0),I=k.useRef(null),_=k.useRef({key:"",attempts:0}),K=k.useCallback(()=>{B(S=>S+1)},[]);k.useEffect(()=>()=>{I.current!==null&&window.cancelAnimationFrame(I.current)},[]),k.useEffect(()=>{if(!C||!t)return;const S=()=>{I.current===null&&(I.current=window.requestAnimationFrame(()=>{I.current=null,K()}))},D=()=>{w(null),_.current={key:"",attempts:0}},b=de(C.path);if(!b){D();return}const M=`${b}:${C.line}:${C.column??1}`;if(_.current.key!==M&&(_.current={key:M,attempts:0}),r!==b){m||R(b);return}if(s||n!==b)return;if(i||u||d||p){D();return}if(!x)return;if(N!=="edit"){g("edit");return}const y=l.current;if(!y||!ji(y,z)){S();return}const F=Math.max(1,Math.min(C.line,y.state.doc.lines)),O=y.state.doc.line(F),q=Math.max(1,C.column||1),P=O.from+Math.min(Math.max(0,O.to-O.from),q-1);if(!(y.state.selection.main.head===P)||_.current.attempts===0){_.current.attempts+=1,y.dispatch({selection:{anchor:P},effects:ce.scrollIntoView(P,{y:"center"})}),y.focus(),S();return}window.requestAnimationFrame(()=>{const Q=l.current;Q&&(Q.dispatch({selection:{anchor:P},effects:ce.scrollIntoView(P,{y:"center"})}),Q.focus())}),D()},[x,m,z,V,i,s,u,d,p,n,K,C,t,r,R,w,g,N]),k.useEffect(()=>{if(!$||!t)return;const S=de($);if(!S){E(null);return}r!==S||s||n!==S||(!i&&!u&&!d&&!p&&x&&N==="edit"&&l.current?.focus(),E(null))},[x,i,s,u,d,p,n,$,t,r,E,N]);const W=de(C?.path??"");return{editorViewRef:l,notifyEditorViewChanged:K,shouldMaskEditor:!!(C&&W&&r===W&&!s&&!i&&!u&&!d&&!p)}}function Ci(t){return!(!t.autoSaveEnabled||!t.isDirty||!t.canWrite||t.isSaving||t.fileLoading||t.isNonEditableBinary||!t.selectedFilePath||t.loadedFilePath!==t.selectedFilePath)}function Si(t){return t.selectedFilePath?t.isDirty?!(t.fileLoading||t.loadedFilePath!==t.selectedFilePath||t.isNonEditableBinary||t.draftContent===""&&t.fileContent!==""&&t.loadedFilePath!==t.selectedFilePath):!0:!1}const Ri=1500,Fi=2e3;function Ei({autoSaveEnabled:t,selectedPath:r,loadedPath:n,fileLoading:s,isDirty:i,draftContent:u,fileContent:d,lineEnding:p,isNonEditableBinary:x,writeFile:N,onSaved:g}){const[z,m]=k.useState(!1),[R,C]=k.useState("idle"),w=k.useRef(null),$=k.useRef(null),E=k.useCallback(()=>{w.current&&(clearTimeout(w.current),w.current=null)},[]),l=k.useCallback(()=>{C("saved"),$.current&&clearTimeout($.current),$.current=setTimeout(()=>{$.current=null,C("idle")},Fi)},[]),V=k.useCallback(async()=>{if(!r||!N)return ie.error("Saving not supported"),!1;if(!Si({selectedFilePath:r,loadedFilePath:n,fileLoading:s,isDirty:i,draftContent:u,fileContent:d,isNonEditableBinary:x}))return x?console.warn(`[saveDraft] refusing to save binary file "${r}".`):u===""&&d!==""&&n!==r&&console.warn(`[saveDraft] refusing to save empty draft for "${r}" (${d.length} bytes were expected). The file may have been read during a concurrent write (O_TRUNC race). Try again after content finishes loading if the save was intentional.`),!1;if(!i)return!0;m(!0);try{const I=Fo(u,p);return(await N(r,I))?.success?(g(r,u),!0):(ie.error("Failed to write file"),!1)}catch(I){return ie.error(I instanceof Error?I.message:"Save failed"),!1}finally{m(!1)}},[u,d,s,i,x,p,n,g,r,N]),B=k.useCallback(async()=>{if(E(),z)return!1;const I=await V();return I&&l(),I},[E,z,V,l]);return k.useEffect(()=>{t||(C("idle"),E())},[t,E]),k.useEffect(()=>{if(Ci({autoSaveEnabled:t,isDirty:i,canWrite:!!(r&&N),isSaving:z,fileLoading:s,selectedFilePath:r,loadedFilePath:n,isNonEditableBinary:x}))return w.current=setTimeout(()=>{w.current=null,V().then(I=>{I&&l()})},Ri),E},[t,E,u,s,i,x,z,n,V,r,l,N]),k.useEffect(()=>{C("idle"),m(!1)},[r]),k.useEffect(()=>()=>{E(),$.current&&clearTimeout($.current)},[E]),{autoSaveStatus:R,cancelPendingAutosave:E,isSaving:z,saveDraft:V,saveNow:B}}function zi(t,r){return r.mtimeMs!==void 0&&t.mtimeMs!==void 0&&r.mtimeMs!==t.mtimeMs||r.size!==t.size}function Mi({selectedPath:t,loadedPath:r,isDirty:n,readStat:s,onExternalChange:i,pollIntervalMs:u=2e3}){const d=k.useRef(null),p=k.useRef(n);p.current=n;const x=k.useCallback(N=>{d.current=N},[]);return k.useEffect(()=>{if(!t||r!==t)return;let N=!1;const g=window.setInterval(()=>{document.hidden||s(t).then(z=>{if(N||!z)return;const m=d.current;if(!m||m.path!==t){d.current=z;return}!zi(m,z)||p.current||(d.current=z,i())}).catch(()=>{})},u);return()=>{N=!0,window.clearInterval(g)}},[r,i,u,s,t]),{recordStat:x}}const cr="pichamber:files:md-viewer-mode",lr="pichamber:files:html-viewer-mode",ur="pichamber:files:json-viewer-mode",Ti=1500,Di=1500;function dr(t,r,n){try{const s=localStorage.getItem(t);if(s&&r.includes(s))return s}catch{}return n}function et(t,r){try{localStorage.setItem(t,r)}catch{}}function Ai({root:t,openPaths:r,selectedPath:n,defaultPreview:s,fileContent:i,draftContent:u,setDraftContent:d,autoSaveEnabled:p,writeFile:x,readStat:N,recordStat:g}){const[z,m]=k.useState("edit"),[R,C]=k.useState("edit"),[w,$]=k.useState("tree"),[E,l]=k.useState("edit"),[V,B]=k.useState("preview"),[I,_]=k.useState(0),[K,W]=k.useState(!1),T=k.useRef({}),S=k.useRef({}),D=k.useRef({}),b=k.useRef({}),M=k.useRef(""),y=k.useRef(""),F=k.useRef(null),O=k.useRef(null),q=k.useRef(null),P=k.useCallback(()=>{F.current&&(clearTimeout(F.current),F.current=null),q.current!==null&&(cancelAnimationFrame(q.current),q.current=null)},[]),J=k.useCallback(L=>{M.current=L,y.current=L},[]),Q=k.useCallback(()=>J(""),[J]);k.useEffect(()=>{if(!n)return;const L=s?"preview":"edit";m(T.current[n]??"edit"),C(S.current[n]??dr(cr,["preview","edit"],L)),l(D.current[n]??dr(lr,["preview","edit"],L)),B(b.current[n]??L),$(dr(ur,["tree","text"],s?"tree":"text"))},[s,n]);const ge=k.useCallback(L=>{n&&(T.current[n]=L),m(L)},[n]),xe=k.useCallback(L=>{n&&(S.current[n]=L),C(L),et(cr,L)},[n]),fe=k.useCallback(L=>{n&&(D.current[n]=L),l(L),et(lr,L)},[n]),je=k.useCallback(L=>{$(L),et(ur,L)},[]),Be=k.useCallback(L=>{if(n&&(b.current[n]=L),P(),L==="edit"){d(M.current||i),B(L);return}M.current=u;const G=n;B("edit"),q.current=requestAnimationFrame(()=>{q.current=requestAnimationFrame(()=>{q.current=null,!(t&&G&&ke.getState().byRoot[t]?.selectedPath!==G)&&(_(ne=>ne+1),B("preview"))})})},[P,u,i,t,n,d]),be=k.useCallback(async(L,G)=>{if(!x||G===y.current)return!1;if(!(await x(L,G))?.success)return ie.error("Failed to write file"),!1;J(G),d(G);const Y=await N(L).catch(()=>null);return Y&&g(Y),!0},[N,J,g,d,x]),ae=k.useCallback(()=>{W(!0),O.current&&clearTimeout(O.current),O.current=setTimeout(()=>W(!1),Di)},[]),se=k.useCallback(async(L,G)=>{F.current&&(clearTimeout(F.current),F.current=null);const ne=await be(L,G);return ne&&ae(),ne},[be,ae]),Ne=k.useCallback(L=>{M.current=L,!(!p||!n||V!=="preview"||!x)&&(F.current&&clearTimeout(F.current),F.current=setTimeout(()=>{F.current=null,be(n,L).then(G=>{G&&ae()}).catch(G=>{ie.error(G instanceof Error?G.message:"Save failed")})},Ti))},[p,V,be,n,ae,x]);k.useEffect(()=>P,[P,V,n]),k.useEffect(()=>()=>{O.current&&clearTimeout(O.current)},[]),k.useEffect(()=>{const L=ne=>{const Y=ne?"preview":"edit",He=ne?"tree":"text";for(const re of r)T.current[re]="edit",vr(re)&&(S.current[re]=Y),Wt(re)&&(D.current[re]=Y),pt(re)&&(b.current[re]=Y);m("edit"),C(Y),l(Y),B(Y),$(He),et(cr,Y),et(lr,Y),et(ur,He)},G=ne=>{L(!!ne.detail?.enabled)};return window.addEventListener("pichamber:file-viewer-preview-mode-changed",G),()=>window.removeEventListener("pichamber:file-viewer-preview-mode-changed",G)},[r]);const Z=pt(n??"")&&(M.current||u)||i;return{clearDiagramContent:Q,diagramEditorXml:Z,diagramSaved:K,drawioRemountNonce:I,drawioViewMode:V,handleDiagramChange:Ne,htmlViewMode:E,jsonViewMode:w,mdViewMode:R,recordDiagramContent:J,saveDiagramNow:se,saveDiagramXml:be,saveDrawioViewMode:Be,saveHtmlViewMode:fe,saveJsonViewMode:je,saveMdViewMode:xe,saveTextViewMode:ge,setTextViewMode:m,textViewMode:z}}function Oi({files:t,root:r,activeDirectory:n,expandedPaths:s,chrome:i,showHidden:u,showGitignored:d,removeExpandedPathsByPrefix:p}){const[x,N]=o.useState({}),[g,z]=o.useState({}),m=o.useRef(new Set),R=o.useRef(new Set),C=o.useRef(new Map),w=o.useRef(0),$=o.useCallback((W,T)=>{const S=[];for(const D of T){if(!D?.name||i==="desktop"&&!u&&D.name.startsWith(".")||i==="desktop"&&!d&&Eo(D.name))continue;const b=de(D.path||""),M=b?zo(b)?b:de(`${W}/${b}`):de(`${W}/${D.name}`),y=D.isDirectory?"directory":"file";S.push({name:D.name,path:M,type:y,extension:y==="file"&&D.name.includes(".")?D.name.split(".").pop()?.toLowerCase():void 0,size:D.size})}return Mo(S)},[i,d,u]),E=o.useCallback(async W=>{const T=de(W.trim());if(!T||m.current.has(T)||R.current.has(T))return;R.current=new Set(R.current).add(T);const S=w.current+1;w.current=S,C.current=new Map(C.current).set(T,S);const D=()=>C.current.get(T)===S;try{const b=t.listDirectory?(await t.listDirectory(T)).entries.map(M=>({name:M.name,path:M.path,isDirectory:M.isDirectory,size:M.size})):(await Vs(T)).map(M=>({name:M.name,path:M.path,isDirectory:M.isDirectory}));if(!D())return;m.current=new Set(m.current).add(T),z(M=>{if(!M[T])return M;const y={...M};return delete y[T],y}),N(M=>({...M,[T]:$(T,b)}))}catch(b){if(!D())return;const M=b instanceof Error?b.message:String(b??"");M==="Directory not found"&&r&&T!==r?(p(r,T),z(y=>{if(!y[T])return y;const F={...y};return delete F[T],F})):(console.error("Failed to load files directory:",b),z(y=>({...y,[T]:M})))}finally{D()&&(C.current=new Map(C.current),C.current.delete(T),R.current=new Set(R.current),R.current.delete(T))}},[t,$,p,r]),l=o.useCallback(()=>{m.current=new Set,R.current=new Set,C.current=new Map,z({}),N(W=>Object.keys(W).length===0?W:{})},[]),V=o.useCallback(async()=>{r&&(l(),await E(r))},[E,l,r]),B=o.useCallback(async W=>{if(!W){await V();return}const T=de(W);m.current=new Set(m.current),m.current.delete(T),R.current=new Set(R.current),R.current.delete(T),await E(T)},[E,V]),I=`${r}|h${u?"1":"0"}|g${d?"1":"0"}|${i}`,_=o.useRef("");o.useEffect(()=>{!r||_.current===I||(_.current=I,l(),E(r))},[E,l,r,I]),o.useEffect(()=>{n&&E(n)},[n,E]),o.useEffect(()=>{if(!t.listDirectory)return;const W=()=>{if(!document.hidden)for(const D of s)B(D)},T=()=>W();document.addEventListener("visibilitychange",T);const S=s.length>0?window.setInterval(W,8e3):null;return()=>{document.removeEventListener("visibilitychange",T),S!==null&&window.clearInterval(S)}},[s,t.listDirectory,B]);const K=o.useCallback(W=>m.current.has(de(W)),[]);return{childrenByDir:x,loadErrorsByDir:g,isLoaded:K,loadDirectory:E,refreshDirectory:B,refreshRoot:V}}const Pi=({showEditorTabsRow:t,isMobile:r,showMobilePageContent:n,onBackMobile:s,selectedFile:i,openFiles:u,root:d,alwaysShowActions:p,editorTabsOverflow:x,editorTabsScrollRef:N,onSelectFile:g,onCloseFile:z})=>t?e.jsxs("div",{className:"flex min-w-0 items-center px-3 py-1.5",children:[r&&n&&e.jsx("button",{type:"button",onClick:s,"aria-label":"Back",className:"inline-flex size-7 flex-shrink-0 items-center justify-center mr-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:e.jsx(j,{name:"arrow-left-s",className:"size-5"})}),r?i?e.jsxs(hr,{children:[e.jsx(gr,{asChild:!0,children:e.jsxs("button",{type:"button",className:"inline-flex min-w-0 max-w-full items-center gap-1 text-left typography-ui-label font-medium","aria-label":"Open files",children:[e.jsx(ut,{filePath:i.path,extension:i.extension,className:"size-3.5 flex-shrink-0"}),e.jsx(Rn,{name:i.name}),e.jsx(j,{name:"arrow-down-s",className:"size-4 flex-shrink-0 text-muted-foreground"})]})}),e.jsx(xr,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]",children:u.map(m=>{const R=i?.path===m.path;return e.jsxs(It,{onSelect:C=>{if(C.target.closest("[data-close-open-file]")){C.preventDefault();return}R||g(m)},className:H("flex min-w-0 items-center justify-between gap-2 overflow-hidden",R&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),children:[e.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[e.jsx(ut,{filePath:m.path,extension:m.extension,className:"size-3.5 flex-shrink-0"}),e.jsx(Rn,{name:m.name})]}),e.jsx("button",{type:"button","data-close-open-file":!0,onPointerDown:C=>{C.preventDefault(),C.stopPropagation()},onClick:C=>{C.preventDefault(),C.stopPropagation(),z(m.path)},className:"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]","aria-label":`Close ${m.name}`,children:e.jsx(j,{name:"close",className:"size-3.5"})})]},m.path)})})]}):e.jsx("div",{className:"typography-ui-label font-medium truncate",children:"Select a file"}):u.length>0?e.jsxs("div",{className:"relative min-w-0 flex-1",children:[x.left&&e.jsx("div",{className:"pointer-events-none absolute left-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-r from-background to-transparent"}),x.right&&e.jsx("div",{className:"pointer-events-none absolute right-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-l from-background to-transparent"}),e.jsx("div",{ref:N,className:"flex min-w-0 items-center gap-1 overflow-x-auto scrollbar-none",style:{scrollbarWidth:"none",msOverflowStyle:"none"},"data-no-drawer-swipe":"true",children:u.map(m=>{const R=i?.path===m.path;return e.jsxs("div",{title:Vt(d,m.path),className:H("group inline-flex items-center gap-1 rounded-md border px-2 py-1 typography-ui-label transition-colors whitespace-nowrap",R?"bg-[var(--interactive-selection)] border-[var(--primary-muted)] text-[var(--interactive-selection-foreground)]":"bg-transparent border-[var(--interactive-border)] text-[var(--surface-muted-foreground)] hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]"),children:[e.jsx(ut,{filePath:m.path,extension:m.extension,className:"size-3.5 flex-shrink-0"}),e.jsx("button",{type:"button",onClick:()=>{R||g(m)},className:"max-w-[12rem] truncate text-left",children:m.name}),e.jsx("button",{type:"button",onClick:C=>{C.stopPropagation(),z(m.path)},className:H("rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",!R&&!p&&"opacity-0 group-hover:opacity-100"),"aria-label":`Close ${m.name}`,children:e.jsx(j,{name:"close",className:"size-3.5"})})]},m.path)})})]}):e.jsx("div",{className:"typography-ui-label font-medium truncate",children:"Select a file"})]}):null,Li=(t,r)=>{if(!r)return null;const n=Number.parseInt(t.trim(),10);return!Number.isFinite(n)||n<1?null:Math.min(n,r.state.doc.lines)},$n=(t,r)=>{const n=t.state.doc.lineAt(r.main.head);return{lineNumber:n.number,character:r.main.head-n.from+1,selection:r}},Wn=(t,r,n)=>{const s=t.state.doc.line(r),i=Math.max(1,Math.min(n,s.length+1)),u=s.from+i-1;t.dispatch({selection:bo.cursor(u),effects:ce.scrollIntoView(u,{y:"center"})})};function Ii({open:t,onOpenChange:r,view:n,variant:s="overlay"}){const[i,u]=o.useState(""),d=o.useRef(null),p=o.useRef(!1),x=o.useRef(null),N=o.useRef(null),g=o.useMemo(()=>Li(i,n),[i,n]);o.useEffect(()=>{!t||!n||(p.current=!1,d.current=$n(n,n.state.selection),u(""))},[t,n]),o.useEffect(()=>{t&&window.requestAnimationFrame(()=>{N.current?.focus(),N.current?.select()})},[t]),o.useEffect(()=>{if(!(!t||!n||!d.current)){if(g===null){const{selection:w}=d.current;n.dispatch({selection:w,effects:ce.scrollIntoView(w.main.from,{y:"center"})});return}Wn(n,g,d.current.character)}},[g,t,n]);const z=o.useCallback(()=>{if(!n||p.current||!d.current)return;const{selection:w}=d.current;n.dispatch({selection:w,effects:ce.scrollIntoView(w.main.from,{y:"center"})})},[n]),m=o.useCallback(w=>{w||z(),r(w)},[r,z]),R=o.useCallback(()=>{!n||g===null||!d.current||(p.current=!0,Wn(n,g,d.current.character),r(!1),n.focus())},[g,r,n]);o.useEffect(()=>{if(!t)return;const w=E=>{const l=x.current,V=E.target;!l||!(V instanceof Node)||l.contains(V)||m(!1)},$=E=>{E.key==="Escape"&&(E.preventDefault(),m(!1))};return document.addEventListener("pointerdown",w,!0),document.addEventListener("keydown",$,!0),()=>{document.removeEventListener("pointerdown",w,!0),document.removeEventListener("keydown",$,!0)}},[m,t,s]);const C=o.useMemo(()=>n?g===null?`Current Line: ${(d.current??$n(n,n.state.selection)).lineNumber}. Type a line number between 1 and ${n.state.doc.lines} to navigate to.`:`Go to line ${g}`:"Editor unavailable.",[g,n]);return s==="inline"?t?e.jsxs("div",{ref:x,className:"ml-1 flex h-6 items-center gap-1",children:[e.jsx(mt,{ref:N,type:"number",min:1,step:1,inputMode:"numeric",value:i,onChange:w=>u(w.target.value),onKeyDown:w=>{w.key==="Enter"&&(w.preventDefault(),R())},placeholder:"Line",className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),e.jsx(U,{variant:"outline",size:"xs",onClick:R,disabled:!n||g===null,className:"h-6 px-2",children:"Go"})]}):null:e.jsx("div",{ref:x,className:H("absolute left-3 top-3 z-40 w-[min(32rem,calc(100%-1.5rem))] rounded-xl border border-[var(--interactive-border)] bg-[color:color-mix(in_srgb,var(--surface-elevated)_94%,transparent)] p-2.5 shadow-lg backdrop-blur-sm transition-all",t?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:e.jsxs("div",{className:"min-w-0",children:[e.jsx(mt,{ref:N,type:"number",min:1,step:1,inputMode:"numeric",value:i,onChange:w=>u(w.target.value),onKeyDown:w=>{w.key==="Enter"&&(w.preventDefault(),R())},placeholder:"Line number",className:"h-8 w-full rounded-md border-border/70 bg-background/60 typography-ui-label"}),e.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:C})]})})}const fr=({currentMode:t,onToggle:r})=>{const n=t==="preview",s=n?"Switch to edit mode":"Switch to preview mode",i=n?"Edit":"Preview";return e.jsxs(Le,{children:[e.jsx(Ie,{asChild:!0,children:e.jsx(U,{variant:"ghost",size:"sm",onClick:r,"aria-label":s,className:"h-5 w-5 p-0",children:n?e.jsx(j,{name:"eye",className:"size-4","aria-hidden":"true"}):e.jsx(j,{name:"eye-off",className:"size-4","aria-hidden":"true"})})}),e.jsx(Ve,{sideOffset:8,children:i})]})},Vi=({selectedFile:t,displaySelectedPath:r,layout:n="floating",exitFullscreenOnly:s=!1,canEdit:i,isEditingFile:u,isSaving:d,autoSaveEnabled:p,autoSaveStatus:x,isDirty:N,onSaveDraft:g,onToggleAutoSave:z,openInApps:m,openInCacheStale:R,onOpenInApp:C,onRefreshOpenInApps:w,onToolbarDropdownOpenChange:$,isSelectedImage:E,isSelectedPdf:l,isUnsupportedBinary:V,wrapLines:B,onToggleWrapLines:I,textViewMode:_,onToggleSearch:K,isGoToLineOpen:W,onOpenGoToLineChange:T,editorView:S,canUseShikiFileView:D,isJson:b,isHtml:M,onToggleTextViewMode:y,isMarkdown:F,mdViewMode:O,onToggleMdViewMode:q,isDrawio:P,drawioViewMode:J,onToggleDrawioViewMode:Q,diagramSaved:ge,onSaveDiagram:xe,jsonViewMode:fe,onToggleJsonViewMode:je,canCopy:Be,copiedContent:be,onCopyContent:ae,canCopyPath:se,copiedPath:Ne,onCopyPath:Z,onDownloadFile:L,isMobile:G,mode:ne,isFullscreen:Y,onToggleFullscreen:He,onExitFullscreen:re})=>{if(!t)return null;const Ke=n==="docked"?"pointer-events-auto flex flex-wrap items-center gap-1":"pointer-events-auto flex items-center gap-1 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-1 shadow-sm",oe=(le,Te)=>e.jsxs(Le,{children:[e.jsx(Ie,{asChild:!0,children:e.jsx("span",{className:"inline-flex",children:Te})}),e.jsx(Ve,{side:"bottom",sideOffset:6,children:le})]});return e.jsxs("div",{className:Ke,children:[i&&u&&e.jsxs(e.Fragment,{children:[d?e.jsxs("span",{className:"flex items-center gap-1 px-1 text-muted-foreground typography-meta",children:[e.jsx(j,{name:"loader-4",className:"size-3.5 animate-spin"}),"Saving..."]}):p&&x==="saved"&&!N?e.jsxs("span",{className:"flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta",children:[e.jsx(j,{name:"check",className:"size-3.5"}),"Saved"]}):N?oe(p?`Save now (${lt()}+S) - auto-saves after 1.5s`:`Save now (${lt()}+S)`,e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>{g()},className:"h-6 gap-1 px-1 text-muted-foreground opacity-80 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:p?`Save now (${lt()}+S) - auto-saves after 1.5s`:`Save now (${lt()}+S)`,"aria-label":`Save (${lt()}+S)`,children:e.jsx(j,{name:"save-3",className:"size-4"})})):null,oe(p?"Auto-save on":"Manual save",e.jsx(U,{variant:"ghost",size:"sm",onClick:z,className:H("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",p?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:p?"Auto-save on":"Manual save","aria-label":p?"Auto-save on":"Manual save",children:p?e.jsx(j,{name:"file-check-fill",className:"size-4"}):e.jsx(j,{name:"file-check",className:"size-4"})}))]}),e.jsxs(hr,{onOpenChange:$,children:[e.jsxs(Le,{children:[e.jsx(Ie,{asChild:!0,children:e.jsx("span",{className:"inline-flex",children:e.jsx(gr,{asChild:!0,children:e.jsx(U,{variant:"ghost",size:"sm",className:"size-6 p-0 text-foreground opacity-100 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Open in desktop app","aria-label":"Open in desktop app",children:e.jsx(j,{name:"file-transfer",className:"size-4"})})})})}),e.jsx(Ve,{side:"bottom",sideOffset:6,children:"Open in desktop app"})]}),e.jsxs(xr,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[m.map(le=>e.jsxs(It,{className:"flex items-center gap-2",onClick:()=>{C(le)},children:[e.jsx(ii,{label:le.label,iconDataUrl:le.iconDataUrl}),e.jsx("span",{className:"typography-ui-label text-foreground",children:le.label})]},le.id)),R?e.jsxs(It,{className:"flex items-center gap-2",onClick:()=>{w()},children:[e.jsx(j,{name:"refresh",className:"size-4"}),e.jsx("span",{className:"typography-ui-label text-foreground",children:"Refresh Apps"})]}):null]})]}),!E&&!l&&!V&&e.jsxs(e.Fragment,{children:[oe(B?"Disable line wrap":"Enable line wrap",e.jsx(U,{variant:"ghost",size:"sm",onClick:I,className:H("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",B?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:B?"Disable line wrap":"Enable line wrap",children:e.jsx(j,{name:"text-wrap",className:"size-4"})})),_==="edit"&&e.jsxs(e.Fragment,{children:[oe("Find in file",e.jsx(U,{variant:"ghost",size:"sm",onClick:le=>{K(),le.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Find in file",children:e.jsx(j,{name:"search",className:"size-4"})})),oe("Go to line",e.jsx(U,{variant:"ghost",size:"sm",onClick:le=>{T(!W),le.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Go to line",children:e.jsx(j,{name:"menu-fold-2",className:"size-4"})})),e.jsx(Ii,{open:W,onOpenChange:T,view:S,variant:"inline"})]})]}),D&&i&&!b&&!M&&e.jsx(fr,{currentMode:_==="view"?"preview":"edit",onToggle:y}),F&&oe(O==="preview"?"Switch to edit mode":"Switch to preview mode",e.jsx(U,{variant:"ghost",size:"sm",onClick:q,className:H("size-6 p-0 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] active:bg-[var(--interactive-hover)]",O==="preview"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)] focus-visible:bg-[var(--interactive-selection)] active:bg-[var(--interactive-selection)]":"text-muted-foreground opacity-65 hover:opacity-100"),title:O==="preview"?"Switch to edit mode":"Switch to preview mode","aria-label":O==="preview"?"Switch to edit mode":"Switch to preview mode",children:e.jsx(j,{name:O==="preview"?"eye":"eye-off",className:"size-4"})})),Wt(t?.path??"")&&e.jsx(fr,{currentMode:M?"preview":"edit",onToggle:y}),P&&e.jsxs(e.Fragment,{children:[e.jsx(fr,{currentMode:J,onToggle:Q}),J==="preview"&&e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>{xe()},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Save diagram",children:ge?e.jsx(j,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):e.jsx(j,{name:"save-3",className:"size-4"})})]}),b&&oe(fe==="tree"?"Switch to Text View":"Switch to Tree View",e.jsx(U,{variant:"ghost",size:"sm",onClick:je,className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:fe==="tree"?"Switch to Text View":"Switch to Tree View",children:fe==="tree"?e.jsx(j,{name:"code-sslash",className:"size-4"}):e.jsx(j,{name:"node-tree",className:"size-4"})})),Be&&oe("Copy file contents",e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>{ae()},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Copy file contents","aria-label":"Copy file contents",children:be?e.jsx(j,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):e.jsx(j,{name:"clipboard",className:"size-4"})})),se&&oe(`Copy file path (${r})`,e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>{Z()},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:`Copy file path (${r})`,"aria-label":`Copy file path (${r})`,children:Ne?e.jsx(j,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):e.jsx(j,{name:"file-copy-2",className:"size-4"})})),L&&oe("Save file",e.jsx(U,{variant:"ghost",size:"sm",onClick:L,className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Save file","aria-label":"Save file",children:e.jsx(j,{name:"download",className:"size-4"})})),s?oe("Exit fullscreen",e.jsx(U,{variant:"ghost",size:"sm",onClick:re,className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Exit fullscreen","aria-label":"Exit fullscreen",children:e.jsx(j,{name:"fullscreen-exit",className:"size-4"})})):!G&&ne==="full"&&oe(Y?"Exit fullscreen":"Fullscreen",e.jsx(U,{variant:"ghost",size:"sm",onClick:He,className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:Y?"Exit fullscreen":"Fullscreen","aria-label":Y?"Exit fullscreen":"Fullscreen",children:Y?e.jsx(j,{name:"fullscreen-exit",className:"size-4"}):e.jsx(j,{name:"fullscreen",className:"size-4"})}))]})},Bi=({open:t,onOpenChange:r,isSaving:n,onSaveAndContinue:s,onDiscardAndContinue:i})=>e.jsx(_n,{open:t,onOpenChange:r,children:e.jsxs(qn,{showCloseButton:!1,className:"max-w-md",children:[e.jsxs(Un,{children:[e.jsx(Hn,{children:"Unsaved changes"}),e.jsx(Kn,{children:"Save your edits before continuing?"})]}),e.jsxs(Gn,{children:[e.jsx(U,{variant:"outline",onClick:s,disabled:n,className:"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)] hover:bg-[rgb(var(--status-success)/0.2)]",children:"Save changes"}),e.jsx(U,{variant:"destructive",onClick:i,children:"Discard"})]})]})}),$i=({root:t,isMobile:r,searchQuery:n,onSearchQueryChange:s,searchInputRef:i,searching:u,searchResults:d,selectedFile:p,onSelectFile:x,onOpenDialog:N,currentDirectory:g,refreshRoot:z,childrenByDir:m,loadErrorsByDir:R,expandedPaths:C,isBrowserClient:w,alwaysShowActions:$,getFileStatus:E,getFolderBadge:l,fileRowPermissions:V,downloadFile:B,contextMenuPath:I,setContextMenuPath:_,rightClickMenuPath:K,setRightClickMenuPath:W,toggleDirectory:T,handleRevealPath:S,refreshDirectory:D})=>{const b=!!(t&&m[t]),M=t?R[t]:null;function y(F,O){const q=m[F]??[];return q.map((P,J)=>{const Q=P.type==="directory",ge=Q&&C.includes(P.path),xe=p?.path===P.path,fe=J===q.length-1;return e.jsxs("li",{className:"relative",children:[O>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),fe&&e.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-background"})]}),e.jsx(li,{node:P,root:t,isExpanded:ge,isActive:xe,isMobile:r,isBrowserClient:w,alwaysShowActions:$,status:Q?void 0:E(P.path),badge:Q?l(P.path):void 0,permissions:V,downloadFile:B,contextMenuPath:I,setContextMenuPath:_,rightClickMenuPath:K,setRightClickMenuPath:W,onSelect:x,onToggle:T,onRevealPath:S,onOpenDialog:N}),Q&&ge&&e.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[R[P.path]?e.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:R[P.path],children:R[P.path]}),e.jsxs(U,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{D(P.path)},children:[e.jsx(j,{name:"refresh",className:"size-3.5"}),"Refresh"]})]}):null,y(P.path,O+1)]})]},P.path)})}return e.jsxs("section",{className:H("flex min-h-0 flex-col overflow-hidden",r?"h-full w-full bg-background":"h-full rounded-xl border border-border/60 bg-background/70"),children:[e.jsx("div",{className:H("flex flex-col gap-2 py-2",r?"px-3":"px-2"),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 min-w-0",children:[e.jsx(j,{name:"search",className:"pointer-events-none absolute left-2 top-2 size-4 text-muted-foreground"}),e.jsx(mt,{ref:i,value:n,onChange:F=>s(F.target.value),placeholder:"Search files...",className:"h-8 pl-8 pr-8 typography-meta"}),n.trim().length>0&&e.jsx("button",{type:"button","aria-label":"Clear search",className:"absolute right-2 top-2 inline-flex size-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{s(""),i.current?.focus()},children:e.jsx(j,{name:"close",className:"size-4"})})]}),e.jsxs(Le,{children:[e.jsx(Ie,{asChild:!0,children:e.jsx("span",{className:"inline-flex flex-shrink-0",children:e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>N("createFile",{path:g,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:"New File","aria-label":"New File",children:e.jsx(j,{name:"file-add",className:"size-4"})})})}),e.jsx(Ve,{side:"bottom",sideOffset:6,children:"New File"})]}),e.jsxs(Le,{children:[e.jsx(Ie,{asChild:!0,children:e.jsx("span",{className:"inline-flex flex-shrink-0",children:e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>N("createFolder",{path:g,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:"New Folder","aria-label":"New Folder",children:e.jsx(j,{name:"folder-add",className:"size-4"})})})}),e.jsx(Ve,{side:"bottom",sideOffset:6,children:"New Folder"})]}),e.jsxs(Le,{children:[e.jsx(Ie,{asChild:!0,children:e.jsx("span",{className:"inline-flex flex-shrink-0",children:e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>{z()},className:"size-8 p-0 flex-shrink-0",title:"Refresh","aria-label":"Refresh",children:e.jsx(j,{name:"refresh",className:"size-4"})})})}),e.jsx(Ve,{side:"bottom",sideOffset:6,children:"Refresh"})]})]})}),e.jsx(Jn,{outerClassName:"flex-1 min-h-0",className:H("py-2",r?"px-3":"px-2"),children:e.jsx("ul",{className:"flex flex-col",children:u?e.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[e.jsx(j,{name:"loader-4",className:"size-4 animate-spin"}),"Searching..."]}):d.length>0?d.map(F=>{const O=p?.path===F.path;return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>{x(F)},className:H("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",O?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[e.jsx(ca,{filePath:F.path,extension:F.extension}),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},title:F.path,children:F.relativePath??F.path})]})},F.path)}):M?e.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[e.jsx("span",{className:"text-[var(--status-error)]",children:M}),e.jsxs(U,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{z()},children:[e.jsx(j,{name:"refresh",className:"size-3.5"}),"Refresh"]})]}):b?y(t,0):e.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:"Loading..."})})})]})},Ql=({mode:t="full",chrome:r="desktop",onClose:n})=>{const{files:s,runtime:i}=Qs(),u=r==="mobile",{currentTheme:d,availableThemes:p,lightThemeId:x,darkThemeId:N}=Zs(),{isMobile:g,isTablet:z,screenWidth:m}=eo(),R=Bs(i.platform),C=g||z,w=$s(),$=Ws(),E=to()??"",l=de(E.trim()),V=t!=="editor-only",B=t==="editor-only"&&!g,I=ro(E),[_,K]=o.useState(""),W=o.useRef(null),[T,S]=o.useState(!1),[D,b]=o.useState(l),[M,y]=o.useState(!1),[F,O]=o.useState(!0),[q,P]=o.useState(!1),[J,Q]=o.useState(!1),[ge,xe]=o.useState(!1),fe=o.useRef(null);o.useEffect(()=>{u&&(b(l),K(""),S(!1))},[u,l]);const je=o.useRef(0),Be=o.useCallback(a=>{je.current=Math.max(0,je.current+(a?1:-1))},[]),be=o.useCallback(a=>a instanceof Element?a.closest('[data-slot="dropdown-menu-content"], [data-slot="dropdown-menu-item"]')!==null:!1,[]);o.useEffect(()=>{if(!ge)return;const a=f=>{je.current>0||be(f.target)||fe.current&&!fe.current.contains(f.target)&&xe(!1)};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[be,ge]);const ae=o.useMemo(()=>p.find(a=>a.metadata.id===x)??cn(!1),[p,x]),se=o.useMemo(()=>p.find(a=>a.metadata.id===N)??cn(!0),[p,N]);o.useEffect(()=>{xn(ae),xn(se)},[ae,se]);const Ne=o.useMemo(()=>[],[]),Z=ke(a=>l?a.byRoot[l]?.openPaths??Ne:Ne),L=ke(a=>l?a.byRoot[l]?.selectedPath??null:null),G=ke(a=>l?a.byRoot[l]?.expandedPaths??Ne:Ne),ne=ke(a=>a.removeOpenPath),Y=ke(a=>a.removeOpenPathsByPrefix),He=ke(a=>a.removeExpandedPathsByPrefix),re=ke(a=>a.setSelectedPath),_t=ke(a=>a.toggleExpandedPath),Ke=ke(a=>a.expandPaths),{childrenByDir:oe,loadErrorsByDir:le,isLoaded:Te,loadDirectory:Ge,refreshDirectory:ht,refreshRoot:la}=Oi({files:s,root:l,activeDirectory:u?D:void 0,expandedPaths:G,chrome:r,showHidden:w,showGitignored:$,removeExpandedPathsByPrefix:He}),De=o.useCallback(a=>{const f=de(a),v=f.split("/"),A=v[v.length-1]||f,ee=A.includes(".")?A.split(".").pop()?.toLowerCase():void 0;return{name:A,path:f,type:"file",extension:ee}},[]),gt=o.useMemo(()=>Z.map(De),[Z,De]),qt=o.useMemo(()=>{if(L){const a=Pt(L);if(Z.some(f=>Pt(f)===a))return L}return Z[0]??null},[Z,L]),h=o.useMemo(()=>qt?De(qt):null,[qt,De]),Re=h?.path??"";o.useEffect(()=>{if(!l||!L)return;const a=Pt(L);Z.some(v=>Pt(v)===a)||re(l,Z[0]??null)},[Z,l,L,re]);const xt=!!(l&&Re&&!ar(Re,l)),wr=xt?fn(Re):void 0,ue=o.useMemo(()=>({allowOutsideWorkspace:t==="editor-only"&&xt,outsideFileGrant:wr,directory:l||void 0}),[t,xt,wr,l]),Ut=o.useRef(null),[ua,da]=o.useState({left:!1,right:!1}),yr=o.useCallback(()=>{const a=Ut.current;a&&da({left:a.scrollLeft>2,right:a.scrollLeft+a.clientWidth<a.scrollWidth-2})},[]),kr=o.useRef(yr);kr.current=yr,o.useEffect(()=>{const a=Ut.current;if(!a)return;const f=()=>kr.current();f(),a.addEventListener("scroll",f,{passive:!0});const v=new ResizeObserver(f);return v.observe(a),()=>{a.removeEventListener("scroll",f),v.disconnect()}},[gt.length]);const[ve,Fe]=o.useState(""),[Ht,rt]=o.useState(!1),[jr,we]=o.useState(null),[fa,$e]=o.useState(""),me=o.useRef(""),[nt,Ce]=o.useState(null),[at,Se]=o.useState(""),[ma,pa]=o.useState(`
4
- `),Nr=o.useRef(null),bt=o.useRef(0),st=o.useRef(null),[Cr,Sr]=o.useState(!1),vt=he(a=>a.autoSaveEnabled),ha=he(a=>a.setAutoSaveEnabled),ga=o.useRef(null),[xa,ba]=o.useState(null),[va,wa]=o.useState(null),{value:ya,show:ka}=mn(!1,1200),{value:ja,show:Na}=mn(!1,1200),[Ca,Rr]=o.useState(!1),Kt=o.useCallback(()=>{l&&re(l,null),Fe(""),we(null),$e(""),Ce(null),g&&S(!1)},[g,l,re]),{operation:Sa,target:Ra,inputValue:Fa,setInputValue:Ea,submitting:za,inputRef:Ma,open:Ta,close:Da,submit:Aa,capabilities:{canCreateFile:Fr,canCreateFolder:Er,canRename:zr,canDelete:Mr}}=To({files:s,root:l,selectedPath:h?.path??"",refreshDirectory:ht,removeOpenPathsByPrefix:Y,clearSelectedPath:Kt}),Tr=!!s.revealPath,Oa=Ot(a=>a.availableApps),Pa=Ot(a=>a.isCacheStale),Dr=Ot(a=>a.initialize),La=Ot(a=>a.loadInstalledApps);o.useEffect(()=>{Dr()},[Dr]);const Ia=o.useCallback(a=>{s.revealPath&&s.revealPath(a).catch(()=>{ie.error("Failed to reveal path")})},[s]),Va=o.useCallback(async a=>{if(!h?.path||await _s(h.path,a.id,a.appName)||await ln(h.path,a.appName))return;const A=Do(h.path)||l;A&&await ln(A,a.appName)||ie.error(`Failed to open in ${a.appName}`)},[l,h?.path]),Ar=he(a=>a.shortcutOverrides),Ba=he(a=>a.fileEditorKeymap),$a=no(a=>a.settingsDefaultFileViewerPreview),Or=he(a=>a.expandedEditorToolbar);o.useEffect(()=>{Se("")},[h?.path]);const Pr=o.useRef("");o.useEffect(()=>{!l||Pr.current===l||(Pr.current=l,Fe(""),we(null),$e(""),Ce(null),S(!1))},[l]);const Wa=u?D:E,{results:Lr,searching:Ir}=Ao({directory:Wa,query:_,chrome:r,showHidden:w,showGitignored:$}),Vr=o.useCallback(async(a,f)=>{if(s.readFile)return(await s.readFile(a,{...f??{},directory:l||void 0})).content??"";const v=new URLSearchParams({path:a});f?.allowOutsideWorkspace&&v.set("allowOutsideWorkspace","true"),f?.outsideFileGrant&&v.set("outsideFileGrant",f.outsideFileGrant),f?.optional&&v.set("optional","true"),l&&v.set("directory",l);const A=await un(`/api/fs/read?${v.toString()}`,{cache:f?.optional?"no-store":"default"});if(!A.ok){const ee=await A.json().catch(()=>({error:A.statusText}));throw new Error(ee.error||"Failed to read file")}return A.text()},[s,l]),Je=o.useCallback(async(a,f)=>{if(s.statFile){const v=await s.statFile(a,{...f??{},directory:l||void 0});return{path:v.path,size:v.size,mtimeMs:v.mtimeMs}}return null},[s,l]);o.useEffect(()=>{if(!l||!s.statFile||Z.length===0)return;let a=!1;const f=[...Z];return Promise.all(f.map(async v=>{try{const A=await s.statFile?.(v,{directory:l||void 0});!a&&A&&!A.isFile&&Y(l,v)}catch(A){!a&&bn(A)&&Y(l,v)}})),()=>{a=!0}},[s,Z,Y,l]);const Gt=o.useMemo(()=>ve.length>dt?`${ve.slice(0,dt)}
5
-
6
- … truncated …`:ve,[ve]),wt=at!==Gt,Br=o.useCallback(a=>Je(a,ue),[Je,ue]),_a=o.useCallback(()=>{Ce(null)},[]),{recordStat:Ae}=Mi({selectedPath:h?.path??null,loadedPath:nt,isDirty:wt,readStat:Br,onExternalChange:_a}),{clearDiagramContent:$r,diagramEditorXml:qa,diagramSaved:Ua,drawioRemountNonce:Ha,drawioViewMode:Jt,handleDiagramChange:Ka,htmlViewMode:yt,jsonViewMode:kt,mdViewMode:jt,recordDiagramContent:Nt,saveDiagramNow:Ga,saveDrawioViewMode:Ja,saveJsonViewMode:Ya,saveMdViewMode:Wr,saveTextViewMode:Xa,setTextViewMode:Yt,textViewMode:Ee}=Ai({root:l,openPaths:Z,selectedPath:h?.path??null,defaultPreview:$a,fileContent:ve,draftContent:at,setDraftContent:Se,autoSaveEnabled:vt,writeFile:s.writeFile,readStat:Br,recordStat:Ae}),Oe=o.useCallback(()=>jt,[jt]),Qa=o.useCallback((a,f)=>{if(Fe(f),l&&ar(a,l)){const v=Vt(l,a);v&&ao.requestGitRefresh({directory:l,paths:[v]})}pt(a)&&Nt(f),Je(a).then(v=>{v&&Ae(v)}).catch(()=>{})},[Je,Nt,Ae,l]),{autoSaveStatus:Za,isSaving:_r,saveDraft:qr,saveNow:Ur}=Ei({autoSaveEnabled:vt,selectedPath:h?.path??null,loadedPath:nt,fileLoading:Ht,isDirty:wt,draftContent:at,fileContent:ve,lineEnding:ma,isNonEditableBinary:!!(h?.path&&(mr(h.path)||Cr)),writeFile:s.writeFile,onSaved:Qa}),{confirmOpen:Hr,discardAndTakeIntent:Kr,keepModalOpen:es,requestNavigation:Ct,saveAndTakeIntent:Gr}=ki({isDirty:wt,saveDraft:qr});o.useEffect(()=>{const a=f=>{Us(f)&&(f.key.toLowerCase()==="s"?(f.preventDefault(),Ur()):f.key.toLowerCase()==="f"&&(f.preventDefault(),Q(!0)))};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[Ur]);const Jr=o.useCallback(async a=>{const f=bt.current+1;bt.current=f;const v=()=>{if(!l)return!1;const X=ke.getState().byRoot[l],qe=X?.selectedPath??X?.openPaths[0]??null;return bt.current===f&&qe===a.path};we(null),$e(""),Ce(null),Sr(!1),g&&S(!0);const A=fn(a.path),ee={allowOutsideWorkspace:t==="editor-only"&&!!l&&!ar(a.path,l),outsideFileGrant:A};let te=!1;rt(!0),await yi(a.path,i.isDesktop,X=>Vr(X,ee)).then(X=>{if(v()){if(X.kind!=="text"){if(Fe(""),Se(""),X.kind==="desktop-image"){te=!0;return}X.kind==="binary"&&Sr(X.detectedFromContent),Ce(a.path);return}pa(X.lineEnding),Fe(X.content),Nt(X.content),Se(X.draft),Ce(a.path),Je(a.path,ee).then(qe=>{qe&&v()&&Ae(qe)}).catch(()=>{})}}).catch(X=>{if(v()){if(Oo(X)){if(rt(!1),l&&re(l,null),we(null),Fe(""),Se(""),Ce(null),Ae(null),_.trim().length>0&&K(""),g&&S(!1),l){const Ze=[...vn(a.path,l),a.path];Ze.length>0&&Ke(l,Ze);for(const on of Ze)Te(on)||Ge(on)}return}if(bn(X)){l&&Y(l,a.path),Fe(""),Se(""),we(null),Ae(null),g&&S(!1);return}Fe(""),Se(""),we(X instanceof Error?X.message:"Failed to read file"),Ae(null)}}).finally(()=>{v()&&!te&&rt(!1)})},[Ke,Te,g,Ge,t,Vr,Je,Nt,Ae,Y,l,i.isDesktop,_,re]),St=o.useCallback(async(a,f)=>{if(!l)return;const v=vn(a,l),A=f?[...v,a]:v;A.length>0&&Ke(l,A);const ee=A.map(te=>{if(!Te(te))return Ge(te)}).filter(Boolean);await Promise.all(ee)},[Ke,Te,Ge,l]),Yr=o.useCallback((a,f)=>{const v=f.findIndex(A=>A.path===a);return v===-1||f.length<=1?null:f[v+1]??f[v-1]??null},[]),ze=o.useCallback(async a=>{Ct({kind:"select",file:a})||(l&&(re(l,a.path),St(a.path,!1)),we(null),$e(""),Fe(""),$r(),Se(""),Ce(null),g&&S(!0))},[$r,St,g,Ct,l,re]),ts=o.useCallback(a=>{ze(De(a))},[ze,De]),rs=o.useCallback(a=>{const f=de(a);f&&(K(""),b(f),S(!1))},[]),ns=o.useCallback(a=>{const f=de(a);f&&(S(!0),ze(De(f)))},[ze,De]),as=o.useCallback(async()=>{if(!(!D||M)){y(!0);try{await ht(D)}finally{y(!1)}}},[D,M,ht]);o.useEffect(()=>{h?.path&&St(h.path,!1)},[St,h?.path]),o.useEffect(()=>{if(!h){bt.current+=1,st.current=null,rt(!1);return}if(nt===h.path||st.current===h.path)return;const a=h.path;st.current=a,Jr(h).finally(()=>{st.current===a&&(st.current=null)})},[Jr,nt,h]);const Ye=o.useCallback(async a=>{if(a.kind==="select"){await ze(a.file);return}if(a.kind==="tab"){he.getState().setActiveMainTab(a.tab);return}l&&ne(l,a.path),h?.path===a.path&&(a.nextFile?await ze(a.nextFile):Kt())},[Kt,ze,ne,l,h?.path]),ss=o.useCallback(()=>{const a=Kr();Se(Gt),a&&Ye(a)},[Ye,Kr,Gt]),os=o.useCallback(async()=>{const a=await Gr();a&&await Ye(a)},[Ye,Gr]),is=o.useCallback(a=>{const f=h?.path===a,v={kind:"close",path:a,nextFile:Yr(a,gt)};f&&Ct(v)||Ye(v)},[Ye,Yr,gt,Ct,h?.path]),cs=o.useCallback(a=>{if(Z.includes(a))return"open";if(I?.files){const f=a.startsWith(l+"/")?a.slice(l.length+1):a,v=I.files.find(A=>A.path===f);if(v){if(v.index==="A"||v.working_dir==="?")return"git-added";if(v.index==="D")return"git-deleted";if(v.index==="M"||v.working_dir==="M")return"git-modified"}}return null},[Z,I,l]),ls=o.useCallback(a=>{if(!I?.files)return null;const f=a.startsWith(l+"/")?a.slice(l.length+1):a,v=f?`${f}/`:"";let A=0,ee=0;for(const te of I.files)te.path.startsWith(v)&&((te.index==="M"||te.working_dir==="M")&&A++,(te.index==="A"||te.working_dir==="?")&&ee++);return A+ee>0?{modified:A,added:ee}:null},[I,l]),us=o.useCallback(async a=>{const f=de(a);l&&(_t(l,f),Te(f)||await Ge(f))},[Te,Ge,l,_t]),ds=o.useMemo(()=>({canRename:zr,canCreateFile:Fr,canCreateFolder:Er,canDelete:Mr,canReveal:Tr}),[zr,Fr,Er,Mr,Tr]),ye=!!(h?.path&&Xn(h.path)),Xe=!!(h?.path&&Qn(h.path)),We=!!(h?.path&&Zn(h.path)),Xt=!!(h?.path&&(mr(h.path)||Cr)),Rt=Xt&&!ye&&!We,Qe=o.useMemo(()=>Vt(l,Re),[Re,l]),fs=!!(h&&(!ye||Xe)&&!We&&!Rt&&ve.length>0),ms=!!(h&&Qe.length>0),_e=!!(h&&!xt&&!Xt&&!ye&&s.writeFile&&ve.length<=dt),ot=!!(h?.path&&vr(h.path)),Qt=!!(h?.path&&aa(h.path)),it=!!(h?.path&&Wt(h.path)),Xr=!!(h?.path&&pt(h.path)),ps=!!(h&&!Xt&&!ye),{editorViewRef:pe,notifyEditorViewChanged:Ft,shouldMaskEditor:hs}=Ni({root:l,selectedPath:Re||null,loadedPath:nt,fileLoading:Ht,fileError:jr,isImage:ye,isPdf:We,isUnsupportedBinary:Rt,canEdit:_e,textViewMode:Ee,setTextViewMode:Yt,draftContent:at,confirmDiscardOpen:Hr,selectFilePath:ts}),Qr=ps&&!ot&&!Xr&&!(it&&yt==="preview"),gs=ot&&jt==="edit"||it&&yt==="edit"||Qt&&kt==="text"||!ot&&!it&&!Qt&&Ee==="edit",Et=o.useMemo(()=>Re?so(Re):null,[Re]),[Zr,Zt]=o.useState(null);o.useEffect(()=>{let a=!1;const f=h?.path;if(!f||Et){Zt(null);return}return Zt(null),oo(f).then(v=>{a||Zt(v)}),()=>{a=!0}},[h?.path,Et]),o.useEffect(()=>{!_e&&Ee==="edit"&&Yt("view")},[_e,Yt,Ee]);const Pe=o.useCallback(a=>{if(!g||!a||!a.hasFocus||typeof window>"u")return;const f=window.visualViewport;if(!f)return;const v=document.documentElement.clientHeight||window.innerHeight;if(Math.max(0,v-(f.offsetTop+f.height))<=0)return;const ee=a.state.selection.main.head,te=a.coordsAtPos(ee);if(!te)return;const X=Math.round(f.offsetTop+f.height),Ze=te.bottom+20-X;Ze<=0||(a.scrollDOM.scrollTop+=Ze)},[g]);o.useEffect(()=>{if(!g||typeof window>"u")return;const a=()=>{window.requestAnimationFrame(()=>{Pe(pe.current)})},f=window.visualViewport;return f?.addEventListener("resize",a),f?.addEventListener("scroll",a,{passive:!0}),document.addEventListener("selectionchange",a),()=>{f?.removeEventListener("resize",a),f?.removeEventListener("scroll",a),document.removeEventListener("selectionchange",a)}},[pe,g,Pe]),o.useEffect(()=>{if(!_e||Ee!=="edit"||g)return;const a=qs("open_go_to_line",Ar),f=v=>{const A=v.target;if(A?.closest('[role="dialog"]'))return;const ee=!!A?.closest(".cm-editor");A?.closest('input, textarea, [contenteditable="true"], [role="textbox"]')&&!ee||!document.activeElement?.closest(".cm-editor")||Hs(v,a)&&(v.preventDefault(),Rr(!0))};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[_e,g,Ar,Ee]);const zt=he(a=>a.editorFontSize),xs=o.useMemo(()=>{if(!h?.path)return[jn(d,{fontSize:zt})];const a=Yn(h.path),f=[jn(d,a?{syntaxColors:!1,fontSize:zt}:{fontSize:zt})],v=Et??Zr;return v&&f.push(v),a&&f.push(ei({language:a,themeName:d.metadata.id,theme:vo(d)})),F&&f.push(ce.lineWrapping),g&&f.push(ce.updateListener.of(A=>{A.view.hasFocus&&(A.selectionSet||A.focusChanged||A.viewportChanged||A.geometryChanged)&&window.requestAnimationFrame(()=>{Pe(A.view)})})),f},[d,h?.path,Et,Zr,F,g,Pe,zt]),bs=o.useMemo(()=>({light:ae.metadata.id,dark:se.metadata.id}),[ae.metadata.id,se.metadata.id]),Mt=h?.path&&ye&&!i.isDesktop&&!Xe?`${h.path}|${ue.allowOutsideWorkspace?"outside":"workspace"}|${ue.outsideFileGrant??""}`:"",Tt=h?.path&&We?`${h.path}|${ue.allowOutsideWorkspace?"outside":"workspace"}|${ue.outsideFileGrant??""}`:"",ct=h?.path&&it&&yt==="preview"?h.path:"",er="Failed to read file",{readyKey:en,nonce:vs}=sr(Mt,we,er),{readyKey:tn,nonce:ws}=sr(ct,we,er),{readyKey:rn,nonce:ys}=sr(Tt,we,er),ks=!!(Mt&&en!==Mt),js=!!(ct&&tn!==ct),Ns=!!(Tt&&rn!==Tt),Cs=h?.path&&ye?i.isDesktop?Xe?`data:${pn(h.path)};utf8,${encodeURIComponent(ve)}`:fa:Xe?`data:${pn(h.path)};utf8,${encodeURIComponent(ve)}`:en===Mt?rr().authenticatedAsset("/api/fs/raw",{path:h.path,allowOutsideWorkspace:ue.allowOutsideWorkspace?"true":void 0,outsideFileGrant:ue.outsideFileGrant,directory:l||void 0}):"":"",Ss=h?.path&&We&&rn===Tt?rr().authenticatedAsset("/api/fs/raw",{path:h.path,allowOutsideWorkspace:ue.allowOutsideWorkspace?"true":void 0,outsideFileGrant:ue.outsideFileGrant,directory:l||void 0}):"",Rs=ct&&tn===ct&&h?.path?(()=>{const a=h.path.split("/").map(f=>encodeURIComponent(f)).join("/");return rr().authenticatedAsset(`/api/fs/serve${a.startsWith("/")?a:`/${a}`}`)})():void 0;o.useEffect(()=>{let a=!1;return(async()=>{if(!i.isDesktop||!h?.path||!ye||Xe){me.current&&(URL.revokeObjectURL(me.current),me.current=""),$e("");return}we(null),me.current&&(URL.revokeObjectURL(me.current),me.current=""),await(s.readFileBinary?s.readFileBinary(h.path,ue).then(A=>A.dataUrl):(async()=>{const A=await un("/api/fs/raw",{query:{path:h.path,allowOutsideWorkspace:ue.allowOutsideWorkspace?"true":void 0,outsideFileGrant:ue.outsideFileGrant,directory:l||void 0}});if(!A.ok)throw new Error("Failed to read file");const ee=await A.blob(),te=URL.createObjectURL(ee);return a?(URL.revokeObjectURL(te),""):(me.current=te,te)})()).then(A=>{a||($e(A),Ce(h.path))}).catch(A=>{me.current&&(URL.revokeObjectURL(me.current),me.current=""),a||($e(""),we(A instanceof Error?A.message:"Failed to read file"),Ce(null))}).finally(()=>{a||rt(!1)})})(),()=>{a=!0}},[s,ye,Xe,l,i.isDesktop,h?.path,ue]),o.useEffect(()=>()=>{me.current&&(URL.revokeObjectURL(me.current),me.current="")},[]);const nn=o.useCallback(()=>{const a=s.downloadFile,f=h?.path;!a||!f||a(f).catch(v=>{console.error("Download failed:",v),ie.error("Operation failed")})},[s.downloadFile,h?.path]),tr=({exitFullscreenOnly:a=!1,layout:f="floating"}={})=>e.jsx(Vi,{selectedFile:h,displaySelectedPath:Qe,layout:f,exitFullscreenOnly:a,canEdit:_e,isEditingFile:gs,isSaving:_r,autoSaveEnabled:vt,autoSaveStatus:Za,isDirty:wt,onSaveDraft:qr,onToggleAutoSave:()=>ha(!vt),openInApps:Oa,openInCacheStale:Pa,onOpenInApp:Va,onRefreshOpenInApps:()=>La(!0),onToolbarDropdownOpenChange:Be,isSelectedImage:ye,isSelectedPdf:We,isUnsupportedBinary:Rt,wrapLines:F,onToggleWrapLines:()=>O(!F),textViewMode:Ee,onToggleSearch:()=>Q(!J),isGoToLineOpen:Ca,onOpenGoToLineChange:Rr,editorView:pe.current,canUseShikiFileView:Qr,isJson:Qt,isHtml:it,onToggleTextViewMode:()=>{Xa(Ee==="view"?"edit":"view")},isMarkdown:ot,mdViewMode:Oe(),onToggleMdViewMode:()=>Wr(Oe()==="preview"?"edit":"preview"),isDrawio:Xr,drawioViewMode:Jt,onToggleDrawioViewMode:()=>Ja(Jt==="preview"?"edit":"preview"),diagramSaved:Ua,onSaveDiagram:async()=>{const v=Nr.current?.getXml();h?.path&&v&&await Ga(h.path,v)},jsonViewMode:kt,onToggleJsonViewMode:()=>Ya(kt==="tree"?"text":"tree"),canCopy:fs,copiedContent:ya,onCopyContent:async()=>{(await Lt(ve)).ok?ka(!0):ie.error("Copy failed")},canCopyPath:ms,copiedPath:ja,onCopyPath:async()=>{(await Lt(Qe)).ok?Na(!0):ie.error("Copy failed")},onDownloadFile:s.downloadFile&&h?nn:void 0,isMobile:g,mode:t,isFullscreen:q,onToggleFullscreen:()=>P(!q),onExitFullscreen:()=>P(!1)}),Fs=o.useCallback(a=>{pe.current=a,Ft(),window.requestAnimationFrame(()=>{Pe(a)})},[pe,Ft,Pe]),Es=o.useCallback(()=>{pe.current&&(pe.current=null),Ft()},[pe,Ft]),zs=o.useCallback(a=>{pe.current=a,window.requestAnimationFrame(()=>{Pe(a)})},[pe,Pe]),Ms=o.useCallback(()=>{pe.current&&(pe.current=null)},[pe]),an={selectedFile:h,loading:Ht||ks||Ns,suppressLoadingIndicator:B,fileError:jr,isSelectedImage:ye,imageSrc:Cs,imagePreviewNonce:vs,isSelectedPdf:We,pdfSrc:Ss,pdfPreviewNonce:ys,isUnsupportedBinary:Rt,onDownload:s.downloadFile&&h?nn:void 0,drawioViewMode:Jt,drawioRemountNonce:Ha,diagramEditorRef:Nr,diagramEditorXml:qa,onDiagramChange:Ka,jsonViewMode:kt,markdownViewMode:jt,htmlViewMode:yt,htmlLoading:js,htmlPreviewNonce:ws,htmlPreviewSrc:Rs,fileContent:ve,canUseShikiFileView:Qr,textViewMode:Ee,draftContent:at,onDraftChange:Se,canEdit:_e,vimMode:Ba==="vim",editorExtensions:xs,shouldMaskEditorForPendingNavigation:hs,pierreTheme:bs,shikiThemeType:d.metadata.variant==="dark"?"dark":"light",wrapLines:F},Dt=e.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden",children:[e.jsx(Bi,{open:Hr,onOpenChange:es,isSaving:_r,onSaveAndContinue:()=>{os()},onDiscardAndContinue:ss}),e.jsxs("div",{className:H("flex flex-col flex-shrink-0",V&&"border-b border-border/40"),children:[e.jsx(Pi,{showEditorTabsRow:V,isMobile:g,showMobilePageContent:T,onBackMobile:()=>S(!1),selectedFile:h,openFiles:gt,root:l,alwaysShowActions:C,editorTabsOverflow:ua,editorTabsScrollRef:Ut,onSelectFile:ze,onCloseFile:is}),(Or||g)&&h?e.jsxs("div",{className:"flex min-w-0 items-center gap-3 border-t border-border/40 bg-[var(--surface-subtle)] px-3 py-1",children:[Qe&&!g?e.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta text-muted-foreground",title:Qe,children:Qe}):null,e.jsx("div",{className:"ml-auto min-w-0 shrink-0 overflow-x-auto",children:tr({layout:"docked"})})]}):null]}),e.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[h&&!J&&!(Or||g)&&e.jsx("div",{ref:fe,className:"absolute right-3 top-3 z-30",onMouseLeave:()=>{je.current>0||xe(!1)},children:ge?tr():e.jsxs("div",{className:"flex items-center gap-1",children:[ot?e.jsxs(Le,{children:[e.jsx(Ie,{asChild:!0,children:e.jsx("span",{className:"inline-flex",children:e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>Wr(Oe()==="preview"?"edit":"preview"),className:H("size-8 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-0 shadow-sm transition-colors",Oe()==="preview"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)]":"text-muted-foreground hover:text-foreground"),"aria-label":Oe()==="preview"?"Switch to edit mode":"Switch to preview mode",title:Oe()==="preview"?"Switch to edit mode":"Switch to preview mode",children:e.jsx(j,{name:Oe()==="preview"?"eye":"eye-off",className:"size-4"})})})}),e.jsx(Ve,{side:"bottom",sideOffset:6,children:Oe()==="preview"?"Switch to edit mode":"Switch to preview mode"})]}):null,e.jsxs(Le,{children:[e.jsx(Ie,{asChild:!0,children:e.jsx("span",{className:"inline-flex",onMouseEnter:()=>xe(!0),children:e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>xe(!0),className:"size-8 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-0 text-muted-foreground shadow-sm hover:text-foreground","aria-label":"Show editor controls",title:"Editor controls",children:e.jsx(j,{name:"more-2-fill",className:"size-4"})})})}),e.jsx(Ve,{side:"bottom",sideOffset:6,children:"Editor controls"})]})]})}),e.jsx(Bn,{variant:"embedded",...an,enableRichPreviews:!0,editorWrapperRef:ga,onEditorViewReady:Fs,onEditorViewDestroy:Es,enableSearch:!0,searchOpen:J,onSearchOpenChange:Q})]})]}),sn=e.jsx($i,{root:l,isMobile:g,searchQuery:_,onSearchQueryChange:K,searchInputRef:W,searching:Ir,searchResults:Lr,selectedFile:h,onSelectFile:ze,onOpenDialog:Ta,currentDirectory:E,refreshRoot:la,childrenByDir:oe,loadErrorsByDir:le,expandedPaths:G,isBrowserClient:R,alwaysShowActions:C,getFileStatus:cs,getFolderBadge:ls,fileRowPermissions:ds,downloadFile:s.downloadFile,contextMenuPath:xa,setContextMenuPath:ba,rightClickMenuPath:va,setRightClickMenuPath:wa,toggleDirectory:us,handleRevealPath:Ia,refreshDirectory:ht}),Ts=t==="full"&&q&&h&&e.jsx("div",{className:"absolute inset-0 z-50 flex flex-col bg-background",children:e.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[e.jsx("div",{className:"absolute right-4 top-4 z-30",children:tr({exitFullscreenOnly:!0})}),e.jsx(Bn,{variant:"fullscreen",...an,enableRichPreviews:!1,onEditorViewReady:zs,onEditorViewDestroy:Ms})]})});return u?e.jsx(ai,{root:l,directory:D||l,entries:D||l?oe[D||l]:void 0,query:_,searchResults:Lr,isSearching:Ir,directoryError:D||l?le[D||l]??null:null,refreshing:M,editorPath:T?h?.path??null:null,editor:Dt,onClose:n,onQueryChange:K,onOpenDirectory:rs,onOpenFile:ns,onBackFromEditor:()=>S(!1),onRefresh:()=>{as()}}):e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden bg-background relative",children:[e.jsx(oi,{activeDialog:Sa,dialogData:Ra,dialogInputValue:Fa,onDialogInputChange:Ea,isDialogSubmitting:za,onDialogSubmit:Aa,onClose:Da,inputRef:Ma}),Ts,g?T?Dt:sn:t==="editor-only"?e.jsx("div",{className:"flex flex-1 min-h-0 min-w-0 overflow-hidden",children:e.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden bg-background",children:Dt})}):e.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0 gap-3 px-3 pb-3 pt-2",children:[m>=700&&e.jsx("div",{className:"w-72 flex-shrink-0 min-h-0 overflow-hidden",children:sn}),e.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden rounded-xl border border-border/60 bg-background",children:Dt})]})]})};export{Ql as FilesView};