@pi-chamber/web 0.9.9-rc.3 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +70 -67
  2. package/dist/assets/{DiagramView-Dy4F1cil.js → DiagramView-CbSxUe1D.js} +1 -1
  3. package/dist/assets/{DiffView-C76KYB1I.js → DiffView-VyBf4ilo.js} +1 -1
  4. package/dist/assets/{FileSaveConflictDialog-C-TUbGz7.js → FileSaveConflictDialog-BCvbQ234.js} +1 -1
  5. package/dist/assets/{FilesView-D05cD0Vv.js → FilesView-DasA5EU2.js} +1 -1
  6. package/dist/assets/{GitView-BrSR7uJk.js → GitView-DU3mOECp.js} +3 -3
  7. package/dist/assets/{JsonTreeView-Ds6UD-nj.js → JsonTreeView-xZiWDwua.js} +1 -1
  8. package/dist/assets/{MarkdownRendererImpl-D_ClsZYB.js → MarkdownRendererImpl-BBwdI2OF.js} +2 -2
  9. package/dist/assets/{PatchDiff-DaZ-PTug.js → PatchDiff-BhKm_JPT.js} +1 -1
  10. package/dist/assets/{SessionSwitcherContent-FaYzgplj.js → SessionSwitcherContent-DTGSP_RB.js} +1 -1
  11. package/dist/assets/{SessionSwitcherDropdown-D_9pieby.js → SessionSwitcherDropdown-CedOB-xC.js} +2 -2
  12. package/dist/assets/{SessionUnreadDot-DGuqqVhb.js → SessionUnreadDot-CZSNKram.js} +1 -1
  13. package/dist/assets/SettingsView-B5nmu8x4.js +2 -0
  14. package/dist/assets/{SettingsWindow-Dpw6aF2F.js → SettingsWindow-y33YrpBE.js} +1 -1
  15. package/dist/assets/{ToolOutputDialog-CcbJkYYg.js → ToolOutputDialog-JqIXJWAH.js} +3 -3
  16. package/dist/assets/{ToolPartDiffPreview-C0c8f4Nt.js → ToolPartDiffPreview-CRi_33jE.js} +1 -1
  17. package/dist/assets/{VirtualizedFileDiff-BvU0E4qX.js → VirtualizedFileDiff-ehLQSR5W.js} +4 -4
  18. package/dist/assets/{collapsible-B6bVtxgp.js → collapsible-Vypq-nMP.js} +1 -1
  19. package/dist/assets/{computeVirtualFileMetrics-hWwF-t_o.js → computeVirtualFileMetrics-BTfrj_fR.js} +2 -2
  20. package/dist/assets/{contextFileOpenGuard-Y5Z8LQyY.js → contextFileOpenGuard-Dl6mFfD1.js} +1 -1
  21. package/dist/assets/{gitStatusPredicates-Dmaw5g31.js → gitStatusPredicates-LAsJAhCL.js} +1 -1
  22. package/dist/assets/{index-BXgR2dKM.css → index-BXX8l7mM.css} +1 -1
  23. package/dist/assets/{index-BOtRfXre.js → index-DvNeSFO9.js} +1 -1
  24. package/dist/assets/{index-CqdQEvR2.js → index-OveFsNBm.js} +1 -1
  25. package/dist/assets/{isDiffPlainText-C1dRfEBh.js → isDiffPlainText-CNZohQ4q.js} +1 -1
  26. package/dist/assets/{isFilePlainText-wlC41gsX.js → isFilePlainText-Dz8UubRT.js} +1 -1
  27. package/dist/assets/{main-CkViwsz_.js → main-BsDkATRV.js} +3 -3
  28. package/dist/assets/{main-CfNlfHvj.js → main-C393Ywhx.js} +2 -2
  29. package/dist/assets/{markdownCore-Ci_ipXBM.js → markdownCore-Bz9-Y75q.js} +1 -1
  30. package/dist/assets/{miniChat-BFzjOj9l.js → miniChat-CWEerp3c.js} +2 -2
  31. package/dist/assets/{mobile-D4xKl_yN.js → mobile-YxV9KcxF.js} +2 -2
  32. package/dist/assets/{renderElectronMiniChatApp-BQBx6mC4.js → renderElectronMiniChatApp-GrLmBQRb.js} +2 -2
  33. package/dist/assets/{renderMobileApp-D1Q-yGOv.js → renderMobileApp-C29wquBe.js} +3 -3
  34. package/dist/assets/{runtimeEndpointReset-Co9SkOQC.js → runtimeEndpointReset-DHARMv9w.js} +14 -14
  35. package/dist/assets/{runtimeSurface-CPm7KWaN.js → runtimeSurface-DUXw4-oa.js} +1 -1
  36. package/dist/assets/{useAppFontEffects-D00QsL7D.js → useAppFontEffects-ad-lZJ6o.js} +86 -86
  37. package/dist/assets/{useFilesViewSearch-BsC82OOk.js → useFilesViewSearch-C4oOHPml.js} +1 -1
  38. package/dist/assets/{usePushVisibilityBeacon-Pg0Sln_M.js → usePushVisibilityBeacon-xd8Q10cI.js} +1 -1
  39. package/dist/assets/{useSwitcherItems-BXn8MrAT.js → useSwitcherItems-B6VC7tug.js} +1 -1
  40. package/dist/assets/{vendor-codemirror-language-data-DhJ96dYN.js → vendor-codemirror-language-data-B4j3gkaT.js} +2 -2
  41. package/dist/assets/{web-components-Bb-NxfNy.js → web-components-B0RFakat.js} +3 -3
  42. package/dist/index.html +4 -4
  43. package/dist/mini-chat.html +3 -3
  44. package/dist/mobile.html +3 -3
  45. package/package.json +1 -1
  46. package/dist/assets/SettingsView-C-YJztlm.js +0 -2
@@ -1,4 +1,4 @@
1
- import{j as t,R as a,b as io,r as w}from"./vendor-react-B5Z1Mdn3.js";import{o as X,F as co,h as lo,bT as uo,D as fo,bU as mo,u as Fe,bV as us,J as Re,a as po,z as ho,K as go,bW as kt,G as xo,I as vo,Z as Nn,bX as bo,aq as Sn,m as Rn,E as yr,aK as yo}from"./index-BOtRfXre.js";import{c2 as wo,I as F,ad as Rt,c3 as ko,a0 as jt,af as ds,ag as fs,ah as ms,ai as ps,aj as hs,ak as gs,B as H,a1 as Mr,a4 as Tr,a6 as Dr,a7 as Yt,t as me,a8 as Zt,a9 as jo,c4 as Qt,ae as xs,E as Fn,aX as Co,c5 as vs,c6 as bs,c7 as ys,c8 as ws,c9 as Er,ca as No,a2 as Xe,a3 as Ye,a5 as Ze,aa as So,al as Ro,Z as Fo,ab as Eo,ac as zo,cb as En,am as zn,aF as Mo,cc as To,cd as Do,ce as Mn}from"./useAppFontEffects-D00QsL7D.js";import{E as pe,D as tr,V as ks,s as Ao,d as Oo,e as Po,f as Tn,k as wr,W as Lo}from"./vendor-codemirror-view-Ct4T37Ue.js";import{H as Dn,x as Ht,y as Io,i as Bo,z as $o}from"./vendor-codemirror-language-BByA_dGF.js";import{a as c,c as Vo}from"./vendor-lezer-highlight-CDMHUZ74.js";import{i as js,S as Wo,k as Ar,E as _o,o as at,a as Ko}from"./vendor-codemirror-state-CNWM3Q8V.js";import{ensurePierreThemeRegistered as An,getResolvedShikiTheme as qo}from"./appThemeRegistry-gegrE2dq.js";import{D as Go,i as Cs,b as Ns,s as Uo,F as Ho}from"./FileSaveConflictDialog-C-TUbGz7.js";import{q as Jo,t as Xo,v as Yo,w as Zo,x as Qo,J as Jt}from"./runtimeEndpointReset-Co9SkOQC.js";import{j as Ss,h as zr,i as Rs}from"./SessionUnreadDot-DGuqqVhb.js";import{g as Ct,c as Fs,d as Es,e as Or,n as ei,f as ti,M as Nt,h as oe,j as ri,s as ni,i as si,a as ai,t as Xt,k as kr,b as oi,l as ii,u as ci,m as On,o as li,p as Pn}from"./useFilesViewSearch-BsC82OOk.js";import{J as ui,F as di}from"./JsonTreeView-Ds6UD-nj.js";import{h as fi,k as mi,l as pi,j as hi}from"./vendor-codemirror-commands-CNlncqrr.js";import{a as Ln,g as er,b as In,c as Bn,o as gi,d as xi}from"./vendor-codemirror-search-BV44140v.js";import{v as vi,g as bi}from"./vendor-replit-codemirror-vim-DaSwPsXt.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-DXSHfszQ.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-BZOGXAGe.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-CPm7KWaN.js";import"./vendor-dnd-kit-core-C9qcAm_1.js";import"./vendor-dnd-kit-utilities-DTY1C6ST.js";import"./vendor-dnd-kit-accessibility-DZKKhs9S.js";import"./vendor-dnd-kit-sortable-D8ozj8M-.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-DhJ96dYN.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"./vendor-xterm-xterm-CrXqRur4.js";import"./permissionStore-iKN1K2_x.js";import"./web-components-Bb-NxfNy.js";import"./computeVirtualFileMetrics-hWwF-t_o.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-wlC41gsX.js";function $n(e,r){const s=e.metadata.variant==="dark",i=e.config?.fonts?.mono||"monospace",o=e.colors.syntax.highlights||{},u=e.colors.syntax.tokens||{},f=r?.fontSize?`${r.fontSize}px`:"var(--text-code)",m=pe.theme({"&":{backgroundColor:"var(--background)",color:e.colors.syntax.base.foreground,fontSize:f,lineHeight:"1.5",position:"relative"},".cm-scroller":{fontFamily:i,backgroundColor:"var(--background)"},".cm-comment":{color:e.colors.syntax.base.comment},".cm-keyword":{color:e.colors.syntax.base.keyword},".cm-string":{color:e.colors.syntax.base.string},".cm-string-2":{color:u.stringEscape||e.colors.syntax.base.string},".cm-number":{color:e.colors.syntax.base.number},".cm-operator":{color:e.colors.syntax.base.operator},".cm-punctuation":{color:u.punctuation||e.colors.syntax.base.comment},".cm-atom":{color:u.boolean||e.colors.syntax.base.number},".cm-builtin":{color:u.functionCall||e.colors.syntax.base.function},".cm-def":{color:u.variableGlobal||e.colors.syntax.base.variable},".cm-attribute":{color:u.variableOther||u.variableProperty||e.colors.syntax.base.operator},".cm-meta":{color:e.colors.syntax.base.comment},".cm-property":{color:u.variableProperty||e.colors.syntax.base.keyword},".cm-variable":{color:e.colors.syntax.base.variable},".cm-variable-2":{color:u.variableOther||e.colors.syntax.base.function},".cm-variable-3":{color:u.variableGlobal||e.colors.syntax.base.type},".cm-tag":{color:u.tag||e.colors.syntax.base.keyword},".cm-link":{color:u.url||e.colors.syntax.base.keyword,textDecoration:"underline"},".cm-content":{caretColor:e.colors.interactive.cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:e.colors.interactive.cursor},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e.colors.interactive.selection},".cm-gutters":{backgroundColor:"var(--background)",color:o.lineNumber||e.colors.syntax.base.comment,borderRight:`1px solid ${e.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:o.lineNumberActive||e.colors.syntax.base.foreground},".cm-activeLine":{backgroundColor:e.colors.surface.overlay},".cm-panels":{backgroundColor:"transparent",color:e.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 ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.elevated,color:e.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, ${e.colors.surface.elevated} 85%, transparent)`,border:`1px solid ${e.colors.interactive.border}`,borderRadius:"10px",boxShadow:`0 2px 8px color-mix(in srgb, ${e.colors.surface.background} 60%, transparent)`,width:"auto",minWidth:"360px",maxWidth:"480px"},".cm-search":{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"0",width:"100%",color:e.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 ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.background,color:e.colors.surface.foreground,fontFamily:"inherit",fontSize:"12px",lineHeight:"1",outline:"none",transition:"border-color 150ms ease"},".cm-search .cm-textfield::placeholder":{color:e.colors.surface.mutedForeground,opacity:1},".cm-search .cm-textfield:focus":{borderColor:e.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:e.colors.interactive.hover},'.cm-search label:has(input[type="checkbox"]:checked)':{backgroundColor:e.colors.interactive.hover,borderColor:e.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:e.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search label:hover::after":{color:e.colors.surface.foreground},'.cm-search label:has(input[type="checkbox"]:checked)::after':{color:e.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:e.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:e.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search .cm-button:hover":{backgroundColor:e.colors.interactive.hover},".cm-search .cm-button:hover::after":{color:e.colors.surface.foreground},".cm-search .cm-button:active":{backgroundColor:e.colors.interactive.active},".cm-search .cm-button:focus-visible":{outline:"none",boxShadow:`0 0 0 1px ${e.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:e.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:e.colors.interactive.hover,color:e.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:e.colors.status.infoBackground,boxShadow:`inset 0 0 0 1px ${e.colors.status.infoBorder}`,borderRadius:"2px"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:e.colors.interactive.selection,color:e.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${e.colors.interactive.borderFocus}`},"&.cm-focused":{outline:"none"}},{dark:s}),g=Dn.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"}]),y=Dn.define([{tag:[c.comment,c.docComment,c.meta,c.documentMeta],color:e.colors.syntax.base.comment},{tag:[c.keyword,c.controlKeyword,c.moduleKeyword,c.definitionKeyword,c.modifier],color:e.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:e.colors.syntax.base.operator},{tag:[c.string,c.regexp,c.attributeValue,c.special(c.string),c.monospace],color:e.colors.syntax.base.string},{tag:c.escape,color:u.stringEscape||e.colors.syntax.base.string},{tag:[c.number,c.bool,c.atom,c.null,c.self],color:e.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:e.colors.syntax.base.function},{tag:c.definition(c.variableName),color:u.variableGlobal||e.colors.syntax.base.variable},{tag:[c.variableName,c.local(c.variableName),c.constant(c.variableName),c.literal],color:e.colors.syntax.base.variable},{tag:c.propertyName,color:u.variableProperty||e.colors.syntax.base.variable},{tag:c.attributeName,color:u.variableOther||e.colors.syntax.base.variable},{tag:[c.className,c.typeName,c.namespace],color:e.colors.syntax.base.type},{tag:[c.tagName,c.labelName,c.annotation,c.macroName],color:u.tag||e.colors.syntax.base.keyword},{tag:c.link,color:u.url||e.colors.syntax.base.function,textDecoration:"underline"},{tag:[c.punctuation,c.separator,c.bracket,c.paren,c.brace,c.squareBracket,c.angleBracket],color:u.punctuation||e.colors.syntax.base.comment}]);return r?.syntaxColors===!1?[m]:[m,Ht(Io,{fallback:!0}),Ht(Vo),Ht(g),Ht(y)]}const yi=180,zs=Wo.define(),wi=1,ki=2,ji=4,Vn=new Map,Ci=(e,r)=>{const s=`${e}|${r}`,i=Vn.get(s);if(i)return i;let o="";e&&(o+=`color:${e};`),r&wi&&(o+="font-style:italic;"),r&ki&&(o+="font-weight:bold;"),r&ji&&(o+="text-decoration:underline;");const u=tr.mark({attributes:{style:o}});return Vn.set(s,u),u},Ni=(e,r)=>{const s=new Ar,i=e.state.doc,o=Math.min(r.length,i.lines);for(let u=0;u<o;u+=1){const f=r[u];if(!f||f.length===0)continue;const m=i.line(u+1);let g=m.from;for(const[y,S,x]of f){if(y<=0)continue;const b=g,j=Math.min(g+y,m.to);g+=y,!(j<=b)&&(!S&&!x||s.add(b,j,Ci(S,x)))}}return s.finish()},Si=js.define({create(){return tr.none},update(e,r){let s=e.map(r.changes);for(const i of r.effects)i.is(zs)&&(s=i.value);return s},provide:e=>pe.decorations.from(e)}),Ri=e=>ks.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)},yi)}async tokenize(r){const s=++this.generation,i=r.state.doc.toString(),o=await wo(i,e.language,e.themeName,e.theme);o&&s===this.generation&&r.state.doc.length===i.length&&r.dispatch({effects:zs.of(Ni(r,o))})}destroy(){this.timer&&clearTimeout(this.timer)}}),Fi=e=>[Si,Ri(e)],Ke=e=>(e||"").replace(/\\/g,"/").replace(/\/+$/g,""),ht=e=>{const r=Ke(e);return!r||r==="/"?r||"/":r.split("/").filter(Boolean).at(-1)??r},Ms=e=>{const r=Ke(e);if(!r||r==="/")return null;const s=r.lastIndexOf("/");if(s<0)return null;if(s===0)return"/";const i=r.slice(0,s);return/^[A-Za-z]:$/.test(i)?`${i}/`:i},Wn=(e,r)=>{const s=Ke(e),i=Ke(r);return!s||!i?!1:s===i||s.startsWith(`${i}/`)},_n=(e,r)=>{const s=Ke(e);if(!s)return Ke(r);if(s.startsWith("/")||/^[A-Za-z]:(\/|$)/.test(s))return s;const i=Ke(r);return i?`${i}/${s}`:s},Ei=(e,r)=>{const s=Ke(e),i=Ke(r);if(!s||s===i)return!1;const o=Ms(s);return o?i&&Wn(s,i)?Wn(o,i):!0:!1},zi=e=>{if(typeof e!="number"||!Number.isFinite(e)||e<0)return"";if(e<1024)return`${e} B`;const r=["KB","MB","GB"];let s=e/1024;for(const i of r){if(s<1024||i===r[r.length-1])return`${s.toFixed(s>=10?0:1)} ${i}`;s/=1024}return""},Mi=(e,r)=>!r||e===r?ht(e):e.startsWith(`${r}/`)?e.slice(r.length+1):e,Ti=({root:e,directory:r,entries:s,query:i,searchResults:o,isSearching:u,directoryError:f,refreshing:m,editorPath:g,editor:y,onClose:S,onQueryChange:x,onOpenDirectory:b,onOpenFile:j,onBackFromEditor:C,onRefresh:v})=>{if(!e)return t.jsx(St,{message:"Select a project to browse files."});if(g)return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-transparent text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-1 px-2 text-foreground",children:[t.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:t.jsx(F,{name:"arrow-left",className:"size-5"})}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:ht(g)})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:y})]});const P=r===e?"Project files":ht(r),I=Ei(r,e)?Ms(r):null,l=!!I&&!i.trim(),B=I===e?"Project files":ht(I??"");return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-transparent text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-1 px-2 text-foreground",children:[S?t.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:S,style:{touchAction:"manipulation"},children:t.jsx(F,{name:"close",className:"size-5"})}):null,l&&I?t.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 ${ht(I)}`,onClick:()=>b(I),style:{touchAction:"manipulation"},children:t.jsx(F,{name:"arrow-left",className:"size-5"})}):null,t.jsx("div",{className:"min-w-0 flex-1 px-1",children:t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:P})}),t.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:v,style:{touchAction:"manipulation"},children:t.jsx(F,{name:"refresh",className:X("size-5",m&&"animate-spin")})})]}),t.jsx("div",{className:"shrink-0 px-3 pb-2 pt-1",children:t.jsxs("div",{className:"relative",children:[t.jsx(F,{name:"search",className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(Rt,{value:i,onChange:L=>x(L.target.value),placeholder:"Search files",className:"h-11 pl-9"})]})}),t.jsx(ko,{className:"min-h-0 w-full flex-1 overflow-y-auto pb-3",children:f?t.jsx(St,{message:f}):i.trim()?t.jsx(Di,{root:e,results:o,isSearching:u,onOpenFile:j}):s===void 0?t.jsx(St,{loading:!0,message:"Loading..."}):t.jsxs("div",{className:"flex w-full min-w-0 flex-col",children:[l&&I?t.jsxs("button",{type:"button",className:Ss,"aria-label":`Up one level to ${B}`,onClick:()=>b(I),style:{touchAction:"manipulation"},children:[t.jsx(F,{name:"arrow-left",className:X(zr(!0),"text-muted-foreground")}),t.jsx("span",{className:X(Rs(!0),"flex-1 text-muted-foreground"),children:"Up one level"})]}):null,s.length===0?t.jsx("div",{className:"px-3 py-8 text-center typography-ui-label text-muted-foreground",children:"This directory is empty."}):null,s.map(L=>t.jsx(Ts,{name:L.name,path:L.path,directory:L.type==="directory",meta:L.type==="directory"?void 0:zi(L.size),onClick:()=>L.type==="directory"?b(_n(L.path,r||e)):j(_n(L.path,r||e))},L.path))]})})]})},Ts=({name:e,path:r,directory:s,meta:i,onClick:o})=>t.jsxs("button",{type:"button",className:Ss,onClick:o,style:{touchAction:"manipulation"},children:[s?t.jsx(F,{name:"folder-3-fill",className:X(zr(!0),"text-primary/80")}):t.jsx(jt,{filePath:r,className:zr(!0)}),t.jsx("span",{className:X(Rs(!0),"flex-1 text-foreground"),children:e}),i?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:i}):null,s?t.jsx(F,{name:"arrow-right-s",className:"size-4 shrink-0 text-muted-foreground/60"}):null]}),Di=({root:e,results:r,isSearching:s,onOpenFile:i})=>s?t.jsx(St,{loading:!0,message:"Loading..."}):r.length===0?t.jsx(St,{message:"No files found."}):t.jsx("div",{className:"flex w-full min-w-0 flex-col",children:r.map(o=>t.jsx(Ts,{name:ht(o.path),path:o.path,directory:!1,meta:o.relativePath??Mi(o.path,e),onClick:()=>i(o.path)},o.path))}),St=({message:e,loading:r=!1})=>t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[r?t.jsx(F,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):t.jsx(F,{name:"folder-open-fill",className:"size-6 text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:e})]})}),Ai=({activeDialog:e,dialogData:r,dialogInputValue:s,onDialogInputChange:i,isDialogSubmitting:o,onDialogSubmit:u,onClose:f,inputRef:m})=>t.jsx(ds,{open:!!e,onOpenChange:g=>!g&&f(),children:t.jsxs(fs,{initialFocus:m,children:[t.jsxs(ms,{children:[t.jsxs(ps,{children:[e==="createFile"&&"Create File",e==="createFolder"&&"Create Folder",e==="rename"&&"Rename",e==="delete"&&"Delete"]}),t.jsxs(hs,{children:[e==="createFile"&&`Create a new file in ${r?.path??"root"}`,e==="createFolder"&&`Create a new folder in ${r?.path??"root"}`,e==="rename"&&`Rename ${r?.name??""}`,e==="delete"&&`Are you sure you want to delete ${r?.name??""}? This action cannot be undone.`]})]}),e!=="delete"&&t.jsx("div",{className:"py-4",children:t.jsx(Rt,{value:s,onChange:g=>i(g.target.value),placeholder:e==="rename"?"New name":"Name",onKeyDown:g=>{g.key==="Enter"&&u()},ref:m})}),t.jsxs(gs,{children:[t.jsx(H,{variant:"outline",onClick:f,disabled:o,children:"Cancel"}),t.jsx(H,{variant:e==="delete"?"destructive":"default",onClick:()=>{u()},disabled:o||e!=="delete"&&!s.trim(),children:o?t.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}):e==="delete"?"Delete":"Confirm"})]})]})}),Oi=({label:e,iconDataUrl:r})=>{const[s,i]=a.useState(!1),o=e.trim().slice(0,1).toUpperCase()||"?";return r&&!s?t.jsx("img",{src:r,alt:"",className:"size-4 rounded-sm",onError:()=>i(!0)}):t.jsx("span",{className:X("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),children:o})},Ds=({filePath:e,extension:r})=>t.jsx(jt,{filePath:e,extension:r}),Pi=({status:e})=>{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)"}[e];return t.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:r}})},Kn=({name:e})=>{const r=a.useRef(null),s=a.useRef(null),[i,o]=a.useState(!1);return a.useLayoutEffect(()=>{const u=r.current,f=s.current;if(!u||!f)return;const m=()=>{o(f.scrollWidth>u.clientWidth+1)};m();const g=new ResizeObserver(m);return g.observe(u),g.observe(f),()=>{g.disconnect()}},[e]),t.jsxs("span",{ref:r,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[t.jsx("span",{ref:s,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:e}),i?t.jsxs("span",{className:"open-file-name-marquee-track",children:[t.jsx("span",{className:"open-file-name-marquee-item",children:e}),t.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:e})]}):t.jsx("span",{className:"block min-w-0 truncate",children:e})]})},Li=({node:e,root:r,isExpanded:s,isActive:i,isMobile:o,isBrowserClient:u,alwaysShowActions:f,status:m,badge:g,permissions:y,downloadFile:S,contextMenuPath:x,setContextMenuPath:b,rightClickMenuPath:j,setRightClickMenuPath:C,onSelect:v,onToggle:P,onRevealPath:I,onOpenDialog:l})=>{const B=e.type==="directory",{canRename:L,canCreateFile:W,canCreateFolder:$,canDelete:G,canReveal:K}=y,J=!B&&!!S,D=K&&!u,T=L||W||$||G||J||D,k=a.useCallback(d=>{T&&(d?.preventDefault(),C(e.path))},[T,e.path,C]),V=a.useCallback(()=>{B?P(e.path):v(e)},[B,e,v,P]),E=a.useCallback(d=>{d.stopPropagation(),C(null),b(e.path)},[e.path,b,C]),R=({Item:d,Separator:A})=>t.jsxs(t.Fragment,{children:[L&&t.jsxs(d,{onClick:N=>{N.stopPropagation(),l("rename",e)},children:[t.jsx(F,{name:"edit",className:"mr-2 size-4"})," ","Rename"]}),t.jsxs(d,{onClick:N=>{N.stopPropagation(),Yt(e.path).then(O=>{if(O.ok){me.success("Path copied");return}me.error("Copy failed")})},children:[t.jsx(F,{name:"file-copy",className:"mr-2 size-4"})," ","Copy Path"]}),t.jsxs(d,{onClick:N=>{N.stopPropagation();const O=Ct(r,e.path)||e.path;Yt(O).then(Y=>{if(Y.ok){me.success("Relative path copied");return}me.error("Copy failed")})},children:[t.jsx(F,{name:"file-copy-2",className:"mr-2 size-4"})," ","Copy Relative Path"]}),!B&&S&&t.jsxs(d,{onClick:N=>{N.stopPropagation(),S(e.path).catch(O=>{console.error("Download failed:",O),me.error("Operation failed")})},children:[t.jsx(F,{name:"download",className:"mr-2 size-4"})," ",u?"Download":"Save"]}),D&&t.jsxs(d,{onClick:N=>{N.stopPropagation(),I(e.path)},children:[t.jsx(F,{name:"folder-received",className:"mr-2 size-4"})," ",co()]}),B&&(W||$)&&t.jsxs(t.Fragment,{children:[t.jsx(A,{}),W&&t.jsxs(d,{onClick:N=>{N.stopPropagation(),l("createFile",e)},children:[t.jsx(F,{name:"file-add",className:"mr-2 size-4"})," ","New File"]}),$&&t.jsxs(d,{onClick:N=>{N.stopPropagation(),l("createFolder",e)},children:[t.jsx(F,{name:"folder-add",className:"mr-2 size-4"})," ","New Folder"]})]}),G&&t.jsxs(t.Fragment,{children:[t.jsx(A,{}),t.jsxs(d,{onClick:N=>{N.stopPropagation(),l("delete",e)},className:"text-destructive focus:text-destructive",children:[t.jsx(F,{name:"delete-bin",className:"mr-2 size-4"})," ","Delete"]})]})]});return t.jsxs(Jo,{open:j===e.path,onOpenChange:d=>C(d?e.path:null),children:[t.jsxs(Xo,{render:t.jsx("div",{className:"group relative flex items-center",onContextMenu:o?void 0:k}),children:[t.jsxs("button",{type:"button",onClick:V,onContextMenu:o?void 0:k,className:X("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",i?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[B?s?t.jsx(F,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):t.jsx(F,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):t.jsx(Ds,{filePath:e.path,extension:e.extension}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:e.path,children:e.name}),!B&&m&&t.jsx(Pi,{status:m}),B&&g&&t.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[g.modified>0&&t.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",g.modified]}),g.added>0&&t.jsxs("span",{className:"text-[var(--status-success)]",children:["+",g.added]})]})]}),T&&t.jsx("div",{className:X("absolute right-1 top-1/2 -translate-y-1/2",f?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:t.jsxs(Mr,{open:x===e.path,onOpenChange:d=>b(d?e.path:null),children:[t.jsx(Tr,{asChild:!0,children:t.jsx(H,{variant:"ghost",size:"icon",className:"size-6",onClick:E,children:t.jsx(F,{name:"more-2-fill",className:"size-4"})})}),t.jsx(Dr,{align:"end",side:"bottom",onCloseAutoFocus:()=>b(null),children:R({Item:Zt,Separator:jo})})]})})]}),t.jsx(Yo,{className:"min-w-[180px]",children:R({Item:Zo,Separator:Qo})})]})},jr=(e,r,s)=>{const[i,o]=a.useState(""),[u,f]=a.useState(0);return a.useEffect(()=>{if(!e){o("");return}let m=!1;o("");const g=lo(),y=uo(g);fo(g).then(x=>{m||!x||(o(e),r(null))}).catch(x=>{m||(r(x instanceof Error?x.message:s),o(e))});const S=mo(()=>{m||(o(e),f(x=>x+1),r(null))});return()=>{m=!0,y(),S()}},[e,r,s]),{readyKey:i,nonce:u}},Ii=e=>e!==null&&typeof e=="object"&&"updateStatus"in e&&typeof e.updateStatus=="function",Bi=e=>{const r=document.createElement("div");r.className="cm-vim-panel";const s=bi(e);if(!s)return{top:!1,dom:r};s.state.statusbar=r;const i=s.state.vimPlugin;return Ii(i)&&i.updateStatus(),{top:!1,dom:r,destroy(){s.state.statusbar===r&&(s.state.statusbar=null)}}};function qn(e){return e?[vi(),Ao.of(Bi),Oo()]:[]}const $i={next:"Next match",prev:"Previous match",select:"Select all matches",replace:"Replace",replaceAll:"Replace all",close:"Close"},Vi={case:"Match case",re:"Regular expression",word:"Match whole word"};function Wi(e){const r=e.querySelector(".cm-search");if(r){for(const[s,i]of Object.entries($i)){const o=r.querySelector(`button[name="${s}"]`);o&&!o.title&&(o.title=i)}for(const[s,i]of Object.entries(Vi)){const u=r.querySelector(`input[name="${s}"]`)?.parentElement;u&&!u.title&&(u.title=i)}}}const Cr=new WeakMap;function _i(e,r){const s=er(e.state);if(!s.valid)return Cr.delete(e),0;const i=Cr.get(e);if(!r&&i?.doc===e.state.doc&&i.query.eq(s))return i.total;const o=s.getCursor(e.state);let u=0;for(let f=o.next();!f.done;f=o.next())u+=1;return Cr.set(e,{query:s,doc:e.state.doc,total:u}),u}function Ki(e){const r=er(e.state);if(!r.valid)return 0;const s=e.state.selection.main,i=r.getCursor(e.state);let o=0,u=0;for(let f=i.next();!f.done;f=i.next()){const m=f.value;if(o+=1,u===0&&(u=o),s.from===m.from&&s.to===m.to||s.from<m.to&&s.to>m.from||m.from>=s.head)return o}return u}function Gn(e,r,s=!1){const i=e.querySelector(".cm-search");if(!i)return;let o=i.querySelector(".cm-search-message");if(!o){o=document.createElement("span"),o.className="cm-search-message",o.setAttribute("aria-live","polite");const m=i.querySelector('button[name="next"]'),g=m?.parentNode===i?m:i.firstChild;i.insertBefore(o,g)}const u=_i(r,s),f=u===0?0:Ki(r);o.textContent=u===0?"":`${f}/${u}`}const Un=new at,Hn=new at,Jn=new at,Xn=new at,Yn=new at,Zn=new at,Qn=new at,es=e=>e,Nr=$o,qi=gi,Gi=xi;class Ui extends Lo{constructor(r,s){super(),this.id=r,this.containerMap=s}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 ts=(e,r)=>!e||e.length===0?[]:js.define({create(s){const i=new Ar,o=[...e].sort((u,f)=>u.afterLine-f.afterLine);for(const u of o){const f=s.doc.lines;if(u.afterLine>f)continue;const m=s.doc.line(u.afterLine);i.add(m.to,m.to,tr.widget({widget:new Ui(u.id,r),block:!0,side:1}))}return i.finish()},update(s,i){return s.map(i.changes)},provide:s=>pe.decorations.from(s)}),rs=e=>{if(!e)return[];const r=Math.max(1,e.start),s=Math.max(r,e.end);return ks.fromClass(class{decorations;constructor(i){this.decorations=this.build(i)}update(i){(i.docChanged||i.viewportChanged)&&(this.decorations=this.build(i.view))}build(i){const o=new Ar;for(let u=r;u<=s&&u<=i.state.doc.lines;u+=1){const f=i.state.doc.line(u);o.add(f.from,f.from,tr.line({class:"oc-cm-selected-line"}))}return o.finish()}},{decorations:i=>i.decorations})};function Hi({value:e,onChange:r,extensions:s,className:i,readOnly:o,lineNumbersConfig:u,highlightLines:f,onViewReady:m,onViewDestroy:g,blockWidgets:y,enableSearch:S,searchOpen:x,onSearchOpenChange:b,vimMode:j}){const C=a.useRef(null),v=a.useRef(null),P=a.useRef(e),I=a.useRef(r),l=a.useRef(m),B=a.useRef(g),L=a.useRef(b),W=a.useRef(y),$=a.useRef(j),G=a.useRef(new Map),[K,J]=a.useState([]),D=a.useCallback(k=>{const V=(k??[]).map(E=>{const R=G.current.get(E.id);return R?{id:E.id,content:E.content,container:R}:null}).filter(E=>E!==null);J(E=>E.length===V.length&&E.every((R,d)=>{const A=V[d];return R.id===A.id&&R.content===A.content&&R.container===A.container})?E:V)},[]),T=a.useCallback(k=>{const V=C.current,E=k??v.current;if(!V||!E)return;const R=E.dom.querySelector(".cm-gutters"),d=R instanceof HTMLElement?R.getBoundingClientRect().width:0;V.style.setProperty("--oc-editor-gutter-width",`${d}px`)},[]);return a.useEffect(()=>{P.current=e},[e]),a.useEffect(()=>{I.current=r},[r]),a.useEffect(()=>{l.current=m,B.current=g},[m,g]),a.useEffect(()=>{L.current=b},[b]),a.useEffect(()=>{W.current=y,D(y)},[y,D]),a.useEffect(()=>{if(!C.current)return;const k=(()=>{if(typeof document>"u")return null;const E=document.querySelector('meta[name="csp-nonce"]')?.getAttribute("content");if(E)return E;const R=window.__PICHAMBER_CSP_NONCE__;return typeof R=="string"&&R.length>0?R:null})(),V=_o.create({doc:P.current,extensions:[...k?[pe.cspNonce.of(k)]:[],Po({fixed:!0}),Un.of(Tn(u)),fi(),Bo.of(" "),Qn.of(qn(j)),wr.of([mi,...pi,...hi]),pe.updateListener.of(E=>{T(E.view),(E.viewportChanged||E.geometryChanged)&&D(W.current);const R=Ln(E.startState),d=Ln(E.state);R!==d&&L.current?.(d);const A=!er(E.startState).eq(er(E.state));if(d&&(R!==d||A||E.docChanged||E.selectionSet)&&Gn(E.view.dom,E.view,R!==d||A||E.docChanged),!E.docChanged)return;const N=E.state.doc.toString();P.current=N,I.current(N),D(W.current)}),Hn.of(pe.editable.of(!o)),Jn.of(s??[]),Xn.of(rs(f)),Yn.of(ts(y,G.current)),Zn.of(S?[In({top:!0}),wr.of(es(Bn))]:[])]});return v.current=new pe({state:V,parent:C.current}),Nr(v.current,v.current.state.doc.length,200),v.current.requestMeasure(),requestAnimationFrame(()=>{T(v.current),D(W.current)}),v.current&&l.current?.(v.current),()=>{B.current?.(),v.current?.destroy(),v.current=null,J([])}},[W,T,D]),a.useEffect(()=>{const k=v.current;k&&(k.dispatch({effects:[Un.reconfigure(Tn(u)),Hn.reconfigure(pe.editable.of(!o)),Jn.reconfigure(s??[]),Xn.reconfigure(rs(f)),Yn.reconfigure(ts(y,G.current)),Zn.reconfigure(S?[In({top:!0}),wr.of(es(Bn))]:[])]}),Nr(k,k.state.doc.length,200),k.requestMeasure(),requestAnimationFrame(()=>{T(k),D(W.current)}))},[s,f,u,o,y,S,T,D]),a.useEffect(()=>{const k=v.current;if(!k){$.current=j;return}$.current!==j&&($.current=j,k.dispatch({effects:Qn.reconfigure(qn(j))}))},[j]),a.useEffect(()=>{const k=v.current;!k||S===!1||(x?(qi(k),requestAnimationFrame(()=>{Wi(k.dom),Gn(k.dom,k,!0)})):Gi(k))},[x,S]),a.useEffect(()=>{const k=v.current;if(!k)return;const V=k.state.doc.toString();V!==e&&(k.dispatch({changes:{from:0,to:V.length,insert:e}}),Nr(k,k.state.doc.length,300),k.requestMeasure(),requestAnimationFrame(()=>T(k)))},[e,T]),t.jsxs(t.Fragment,{children:[t.jsx("div",{ref:C,className:X("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)]",i)}),K.map(k=>io.createPortal(k.content,k.container,k.id))]})}const ns=({variant:e,selectedFile:r,loading:s,suppressLoadingIndicator:i,fileError:o,isSelectedImage:u,imageSrc:f,imagePreviewNonce:m,isSelectedPdf:g,pdfSrc:y,pdfPreviewNonce:S,isUnsupportedBinary:x,onDownload:b,enableRichPreviews:j,drawioViewMode:C,drawioRemountNonce:v,diagramEditorRef:P,diagramEditorXml:I,onDiagramChange:l,jsonViewMode:B,markdownViewMode:L,htmlViewMode:W,htmlLoading:$,htmlPreviewNonce:G,htmlPreviewSrc:K,fileContent:J,canUseShikiFileView:D,textViewMode:T,draftContent:k,onDraftChange:V,canEdit:E,vimMode:R,editorExtensions:d,editorWrapperRef:A,shouldMaskEditorForPendingNavigation:N,onEditorViewReady:O,onEditorViewDestroy:Y,enableSearch:ee=!1,searchOpen:ne,onSearchOpenChange:te,pierreTheme:q,shikiThemeType:Q,wrapLines:Qe})=>{const Oe=e==="fullscreen",le=Oe?"p-4":"p-3",Pe=!!(r?.path&&Qt(r.path)),Le=!!(r?.path&&Fs(r.path)),se=!!(r?.path&&Es(r.path)),ue=!!(r?.path&&Or(r.path)),we=()=>r?t.jsx("div",{className:"h-full",children:t.jsx(di,{file:{name:r.name,contents:k,lang:vs(r.path)||void 0},options:{disableFileHeader:!0,overflow:Qe?"wrap":"scroll",theme:q,themeType:Q},className:"block h-full w-full",style:{height:"100%"}})}):null;return t.jsx(xs,{outerClassName:"h-full min-w-0",className:"h-full min-w-0",children:r?s?i?t.jsx("div",{className:le}):t.jsxs("div",{className:`${le} flex items-center gap-2 typography-ui text-muted-foreground`,children:[t.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),Oe?"Loading…":"Loading..."]}):o?t.jsx("div",{className:`${le} typography-ui text-[color:var(--status-error)]`,children:o}):u?t.jsx("div",{className:X("flex h-full items-center justify-center",le),children:t.jsx("img",{src:f,alt:r.name||"Image",className:X("max-w-full object-contain rounded-md border border-border/30 bg-primary/10",Oe?"max-h-full":"max-h-[70vh]")},m)}):g?t.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:t.jsx("iframe",{src:y,className:"h-full w-full border-0",title:r.name},S)}):x?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[t.jsx("div",{className:"typography-ui-header text-foreground",children:"Cannot preview binary file"}),t.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."}),b?t.jsxs(H,{type:"button",variant:"outline",size:"sm",onClick:b,children:[t.jsx(F,{name:"download",className:"mr-2 size-4"}),"Save file"]}):null]}):j&&Pe&&C==="preview"?t.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:t.jsx(Go,{ref:P,xml:I,onChange:l},`${r.path}:${v}`)}):j&&Le&&B==="tree"?t.jsx(Fn,{fallback:t.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[t.jsx("div",{className:"mb-1 font-medium text-destructive",children:"JSON viewer unavailable"}),t.jsx("div",{className:"text-sm text-muted-foreground",children:"Switch to text mode to view raw content."})]}),children:t.jsx("div",{className:"h-full overflow-auto",children:t.jsx(ui,{jsonString:J,maxHeight:"100%",initiallyExpandedDepth:2})})}):se&&L==="preview"?t.jsxs("div",{className:X("h-full overflow-auto",le),children:[J.length>500*1024?t.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(J.length/1024)}KB). Preview may be limited.`}):null,t.jsx(Fn,{fallback:t.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[t.jsx("div",{className:"mb-1 font-medium text-destructive",children:"Preview unavailable"}),t.jsx("div",{className:"text-sm text-muted-foreground",children:"Switch to edit mode to fix the issue."})]}),children:t.jsx(Co,{content:J,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}):j&&ue&&W==="preview"?$?t.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:"Loading..."}):t.jsx("div",{className:"h-full overflow-hidden",children:t.jsx("iframe",{src:K,className:"w-full h-full border-none",sandbox:"allow-scripts allow-same-origin allow-forms",title:"HTML Preview"},G)}):D&&T==="view"?we():t.jsxs("div",{className:X("relative h-full",N&&"overflow-hidden"),ref:A,children:[t.jsx("div",{className:X("h-full",N&&"invisible"),children:t.jsx(Hi,{value:k,onChange:V,readOnly:!E,vimMode:R,extensions:d,className:"h-full",onViewReady:O,onViewDestroy:Y,...ee?{enableSearch:!0,searchOpen:ne,onSearchOpenChange:te}:{}})}),N?t.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:t.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[t.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),"Opening file at change..."]})}):null]}):t.jsx("div",{className:`${le} typography-ui text-muted-foreground`,children:"Pick a file from the tree."})})};async function Ji(e,r,s){if(bs(e)&&!ys(e))return{kind:r?"desktop-image":"asset-image"};if(ws(e))return{kind:"pdf"};if(Er(e))return{kind:"binary",detectedFromContent:!1};const o=await s(e);if(No(o))return{kind:"binary",detectedFromContent:!0};const u=ei(o);return{kind:"text",content:u,draft:u.length>Nt?`${u.slice(0,Nt)}
1
+ import{j as t,R as a,b as io,r as w}from"./vendor-react-B5Z1Mdn3.js";import{o as X,F as co,h as lo,bU as uo,D as fo,bV as mo,u as Fe,bW as us,J as Re,a as po,z as ho,K as go,bX as kt,G as xo,I as vo,Z as Nn,bY as bo,al as Sn,m as Rn,E as yr,aG as yo}from"./index-DvNeSFO9.js";import{c3 as wo,I as F,ae as Rt,c4 as ko,a1 as jt,ag as ds,ah as fs,ai as ms,aj as ps,ak as hs,al as gs,B as H,a2 as Mr,a5 as Tr,a7 as Dr,a8 as Yt,t as me,a9 as Zt,aa as jo,c5 as Qt,af as xs,E as Fn,aY as Co,c6 as vs,c7 as bs,c8 as ys,c9 as ws,ca as Er,cb as No,a3 as Xe,a4 as Ye,a6 as Ze,ab as So,am as Ro,_ as Fo,ac as Eo,ad as zo,cc as En,an as zn,aG as Mo,cd as To,ce as Do,cf as Mn}from"./useAppFontEffects-ad-lZJ6o.js";import{E as pe,D as tr,V as ks,s as Ao,d as Oo,e as Po,f as Tn,k as wr,W as Lo}from"./vendor-codemirror-view-Ct4T37Ue.js";import{H as Dn,x as Ht,y as Io,i as Bo,z as $o}from"./vendor-codemirror-language-BByA_dGF.js";import{a as c,c as Vo}from"./vendor-lezer-highlight-CDMHUZ74.js";import{i as js,S as Wo,k as Ar,E as _o,o as at,a as Ko}from"./vendor-codemirror-state-CNWM3Q8V.js";import{ensurePierreThemeRegistered as An,getResolvedShikiTheme as qo}from"./appThemeRegistry-gegrE2dq.js";import{D as Go,i as Cs,b as Ns,s as Uo,F as Ho}from"./FileSaveConflictDialog-BCvbQ234.js";import{p as Jo,q as Xo,t as Yo,v as Zo,w as Qo,I as Jt}from"./runtimeEndpointReset-DHARMv9w.js";import{j as Ss,h as zr,i as Rs}from"./SessionUnreadDot-CZSNKram.js";import{g as Ct,c as Fs,d as Es,e as Or,n as ei,f as ti,M as Nt,h as oe,j as ri,s as ni,i as si,a as ai,t as Xt,k as kr,b as oi,l as ii,u as ci,m as On,o as li,p as Pn}from"./useFilesViewSearch-C4oOHPml.js";import{J as ui,F as di}from"./JsonTreeView-xZiWDwua.js";import{h as fi,k as mi,l as pi,j as hi}from"./vendor-codemirror-commands-CNlncqrr.js";import{a as Ln,g as er,b as In,c as Bn,o as gi,d as xi}from"./vendor-codemirror-search-BV44140v.js";import{v as vi,g as bi}from"./vendor-replit-codemirror-vim-DaSwPsXt.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-DXSHfszQ.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-BZOGXAGe.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-DUXw4-oa.js";import"./vendor-dnd-kit-core-C9qcAm_1.js";import"./vendor-dnd-kit-utilities-DTY1C6ST.js";import"./vendor-dnd-kit-accessibility-DZKKhs9S.js";import"./vendor-dnd-kit-sortable-D8ozj8M-.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-B4j3gkaT.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"./vendor-xterm-xterm-CrXqRur4.js";import"./permissionStore-iKN1K2_x.js";import"./web-components-B0RFakat.js";import"./computeVirtualFileMetrics-BTfrj_fR.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-Dz8UubRT.js";function $n(e,r){const s=e.metadata.variant==="dark",i=e.config?.fonts?.mono||"monospace",o=e.colors.syntax.highlights||{},u=e.colors.syntax.tokens||{},f=r?.fontSize?`${r.fontSize}px`:"var(--text-code)",m=pe.theme({"&":{backgroundColor:"var(--background)",color:e.colors.syntax.base.foreground,fontSize:f,lineHeight:"1.5",position:"relative"},".cm-scroller":{fontFamily:i,backgroundColor:"var(--background)"},".cm-comment":{color:e.colors.syntax.base.comment},".cm-keyword":{color:e.colors.syntax.base.keyword},".cm-string":{color:e.colors.syntax.base.string},".cm-string-2":{color:u.stringEscape||e.colors.syntax.base.string},".cm-number":{color:e.colors.syntax.base.number},".cm-operator":{color:e.colors.syntax.base.operator},".cm-punctuation":{color:u.punctuation||e.colors.syntax.base.comment},".cm-atom":{color:u.boolean||e.colors.syntax.base.number},".cm-builtin":{color:u.functionCall||e.colors.syntax.base.function},".cm-def":{color:u.variableGlobal||e.colors.syntax.base.variable},".cm-attribute":{color:u.variableOther||u.variableProperty||e.colors.syntax.base.operator},".cm-meta":{color:e.colors.syntax.base.comment},".cm-property":{color:u.variableProperty||e.colors.syntax.base.keyword},".cm-variable":{color:e.colors.syntax.base.variable},".cm-variable-2":{color:u.variableOther||e.colors.syntax.base.function},".cm-variable-3":{color:u.variableGlobal||e.colors.syntax.base.type},".cm-tag":{color:u.tag||e.colors.syntax.base.keyword},".cm-link":{color:u.url||e.colors.syntax.base.keyword,textDecoration:"underline"},".cm-content":{caretColor:e.colors.interactive.cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:e.colors.interactive.cursor},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e.colors.interactive.selection},".cm-gutters":{backgroundColor:"var(--background)",color:o.lineNumber||e.colors.syntax.base.comment,borderRight:`1px solid ${e.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:o.lineNumberActive||e.colors.syntax.base.foreground},".cm-activeLine":{backgroundColor:e.colors.surface.overlay},".cm-panels":{backgroundColor:"transparent",color:e.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 ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.elevated,color:e.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, ${e.colors.surface.elevated} 85%, transparent)`,border:`1px solid ${e.colors.interactive.border}`,borderRadius:"10px",boxShadow:`0 2px 8px color-mix(in srgb, ${e.colors.surface.background} 60%, transparent)`,width:"auto",minWidth:"360px",maxWidth:"480px"},".cm-search":{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"0",width:"100%",color:e.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 ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.background,color:e.colors.surface.foreground,fontFamily:"inherit",fontSize:"12px",lineHeight:"1",outline:"none",transition:"border-color 150ms ease"},".cm-search .cm-textfield::placeholder":{color:e.colors.surface.mutedForeground,opacity:1},".cm-search .cm-textfield:focus":{borderColor:e.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:e.colors.interactive.hover},'.cm-search label:has(input[type="checkbox"]:checked)':{backgroundColor:e.colors.interactive.hover,borderColor:e.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:e.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search label:hover::after":{color:e.colors.surface.foreground},'.cm-search label:has(input[type="checkbox"]:checked)::after':{color:e.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:e.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:e.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search .cm-button:hover":{backgroundColor:e.colors.interactive.hover},".cm-search .cm-button:hover::after":{color:e.colors.surface.foreground},".cm-search .cm-button:active":{backgroundColor:e.colors.interactive.active},".cm-search .cm-button:focus-visible":{outline:"none",boxShadow:`0 0 0 1px ${e.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:e.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:e.colors.interactive.hover,color:e.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:e.colors.status.infoBackground,boxShadow:`inset 0 0 0 1px ${e.colors.status.infoBorder}`,borderRadius:"2px"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:e.colors.interactive.selection,color:e.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${e.colors.interactive.borderFocus}`},"&.cm-focused":{outline:"none"}},{dark:s}),g=Dn.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"}]),y=Dn.define([{tag:[c.comment,c.docComment,c.meta,c.documentMeta],color:e.colors.syntax.base.comment},{tag:[c.keyword,c.controlKeyword,c.moduleKeyword,c.definitionKeyword,c.modifier],color:e.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:e.colors.syntax.base.operator},{tag:[c.string,c.regexp,c.attributeValue,c.special(c.string),c.monospace],color:e.colors.syntax.base.string},{tag:c.escape,color:u.stringEscape||e.colors.syntax.base.string},{tag:[c.number,c.bool,c.atom,c.null,c.self],color:e.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:e.colors.syntax.base.function},{tag:c.definition(c.variableName),color:u.variableGlobal||e.colors.syntax.base.variable},{tag:[c.variableName,c.local(c.variableName),c.constant(c.variableName),c.literal],color:e.colors.syntax.base.variable},{tag:c.propertyName,color:u.variableProperty||e.colors.syntax.base.variable},{tag:c.attributeName,color:u.variableOther||e.colors.syntax.base.variable},{tag:[c.className,c.typeName,c.namespace],color:e.colors.syntax.base.type},{tag:[c.tagName,c.labelName,c.annotation,c.macroName],color:u.tag||e.colors.syntax.base.keyword},{tag:c.link,color:u.url||e.colors.syntax.base.function,textDecoration:"underline"},{tag:[c.punctuation,c.separator,c.bracket,c.paren,c.brace,c.squareBracket,c.angleBracket],color:u.punctuation||e.colors.syntax.base.comment}]);return r?.syntaxColors===!1?[m]:[m,Ht(Io,{fallback:!0}),Ht(Vo),Ht(g),Ht(y)]}const yi=180,zs=Wo.define(),wi=1,ki=2,ji=4,Vn=new Map,Ci=(e,r)=>{const s=`${e}|${r}`,i=Vn.get(s);if(i)return i;let o="";e&&(o+=`color:${e};`),r&wi&&(o+="font-style:italic;"),r&ki&&(o+="font-weight:bold;"),r&ji&&(o+="text-decoration:underline;");const u=tr.mark({attributes:{style:o}});return Vn.set(s,u),u},Ni=(e,r)=>{const s=new Ar,i=e.state.doc,o=Math.min(r.length,i.lines);for(let u=0;u<o;u+=1){const f=r[u];if(!f||f.length===0)continue;const m=i.line(u+1);let g=m.from;for(const[y,S,x]of f){if(y<=0)continue;const b=g,j=Math.min(g+y,m.to);g+=y,!(j<=b)&&(!S&&!x||s.add(b,j,Ci(S,x)))}}return s.finish()},Si=js.define({create(){return tr.none},update(e,r){let s=e.map(r.changes);for(const i of r.effects)i.is(zs)&&(s=i.value);return s},provide:e=>pe.decorations.from(e)}),Ri=e=>ks.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)},yi)}async tokenize(r){const s=++this.generation,i=r.state.doc.toString(),o=await wo(i,e.language,e.themeName,e.theme);o&&s===this.generation&&r.state.doc.length===i.length&&r.dispatch({effects:zs.of(Ni(r,o))})}destroy(){this.timer&&clearTimeout(this.timer)}}),Fi=e=>[Si,Ri(e)],Ke=e=>(e||"").replace(/\\/g,"/").replace(/\/+$/g,""),ht=e=>{const r=Ke(e);return!r||r==="/"?r||"/":r.split("/").filter(Boolean).at(-1)??r},Ms=e=>{const r=Ke(e);if(!r||r==="/")return null;const s=r.lastIndexOf("/");if(s<0)return null;if(s===0)return"/";const i=r.slice(0,s);return/^[A-Za-z]:$/.test(i)?`${i}/`:i},Wn=(e,r)=>{const s=Ke(e),i=Ke(r);return!s||!i?!1:s===i||s.startsWith(`${i}/`)},_n=(e,r)=>{const s=Ke(e);if(!s)return Ke(r);if(s.startsWith("/")||/^[A-Za-z]:(\/|$)/.test(s))return s;const i=Ke(r);return i?`${i}/${s}`:s},Ei=(e,r)=>{const s=Ke(e),i=Ke(r);if(!s||s===i)return!1;const o=Ms(s);return o?i&&Wn(s,i)?Wn(o,i):!0:!1},zi=e=>{if(typeof e!="number"||!Number.isFinite(e)||e<0)return"";if(e<1024)return`${e} B`;const r=["KB","MB","GB"];let s=e/1024;for(const i of r){if(s<1024||i===r[r.length-1])return`${s.toFixed(s>=10?0:1)} ${i}`;s/=1024}return""},Mi=(e,r)=>!r||e===r?ht(e):e.startsWith(`${r}/`)?e.slice(r.length+1):e,Ti=({root:e,directory:r,entries:s,query:i,searchResults:o,isSearching:u,directoryError:f,refreshing:m,editorPath:g,editor:y,onClose:S,onQueryChange:x,onOpenDirectory:b,onOpenFile:j,onBackFromEditor:C,onRefresh:v})=>{if(!e)return t.jsx(St,{message:"Select a project to browse files."});if(g)return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-transparent text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-1 px-2 text-foreground",children:[t.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:t.jsx(F,{name:"arrow-left",className:"size-5"})}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:ht(g)})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:y})]});const P=r===e?"Project files":ht(r),I=Ei(r,e)?Ms(r):null,l=!!I&&!i.trim(),B=I===e?"Project files":ht(I??"");return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-transparent text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-1 px-2 text-foreground",children:[S?t.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:S,style:{touchAction:"manipulation"},children:t.jsx(F,{name:"close",className:"size-5"})}):null,l&&I?t.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 ${ht(I)}`,onClick:()=>b(I),style:{touchAction:"manipulation"},children:t.jsx(F,{name:"arrow-left",className:"size-5"})}):null,t.jsx("div",{className:"min-w-0 flex-1 px-1",children:t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:P})}),t.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:v,style:{touchAction:"manipulation"},children:t.jsx(F,{name:"refresh",className:X("size-5",m&&"animate-spin")})})]}),t.jsx("div",{className:"shrink-0 px-3 pb-2 pt-1",children:t.jsxs("div",{className:"relative",children:[t.jsx(F,{name:"search",className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(Rt,{value:i,onChange:L=>x(L.target.value),placeholder:"Search files",className:"h-11 pl-9"})]})}),t.jsx(ko,{className:"min-h-0 w-full flex-1 overflow-y-auto pb-3",children:f?t.jsx(St,{message:f}):i.trim()?t.jsx(Di,{root:e,results:o,isSearching:u,onOpenFile:j}):s===void 0?t.jsx(St,{loading:!0,message:"Loading..."}):t.jsxs("div",{className:"flex w-full min-w-0 flex-col",children:[l&&I?t.jsxs("button",{type:"button",className:Ss,"aria-label":`Up one level to ${B}`,onClick:()=>b(I),style:{touchAction:"manipulation"},children:[t.jsx(F,{name:"arrow-left",className:X(zr(!0),"text-muted-foreground")}),t.jsx("span",{className:X(Rs(!0),"flex-1 text-muted-foreground"),children:"Up one level"})]}):null,s.length===0?t.jsx("div",{className:"px-3 py-8 text-center typography-ui-label text-muted-foreground",children:"This directory is empty."}):null,s.map(L=>t.jsx(Ts,{name:L.name,path:L.path,directory:L.type==="directory",meta:L.type==="directory"?void 0:zi(L.size),onClick:()=>L.type==="directory"?b(_n(L.path,r||e)):j(_n(L.path,r||e))},L.path))]})})]})},Ts=({name:e,path:r,directory:s,meta:i,onClick:o})=>t.jsxs("button",{type:"button",className:Ss,onClick:o,style:{touchAction:"manipulation"},children:[s?t.jsx(F,{name:"folder-3-fill",className:X(zr(!0),"text-primary/80")}):t.jsx(jt,{filePath:r,className:zr(!0)}),t.jsx("span",{className:X(Rs(!0),"flex-1 text-foreground"),children:e}),i?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:i}):null,s?t.jsx(F,{name:"arrow-right-s",className:"size-4 shrink-0 text-muted-foreground/60"}):null]}),Di=({root:e,results:r,isSearching:s,onOpenFile:i})=>s?t.jsx(St,{loading:!0,message:"Loading..."}):r.length===0?t.jsx(St,{message:"No files found."}):t.jsx("div",{className:"flex w-full min-w-0 flex-col",children:r.map(o=>t.jsx(Ts,{name:ht(o.path),path:o.path,directory:!1,meta:o.relativePath??Mi(o.path,e),onClick:()=>i(o.path)},o.path))}),St=({message:e,loading:r=!1})=>t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[r?t.jsx(F,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):t.jsx(F,{name:"folder-open-fill",className:"size-6 text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:e})]})}),Ai=({activeDialog:e,dialogData:r,dialogInputValue:s,onDialogInputChange:i,isDialogSubmitting:o,onDialogSubmit:u,onClose:f,inputRef:m})=>t.jsx(ds,{open:!!e,onOpenChange:g=>!g&&f(),children:t.jsxs(fs,{initialFocus:m,children:[t.jsxs(ms,{children:[t.jsxs(ps,{children:[e==="createFile"&&"Create File",e==="createFolder"&&"Create Folder",e==="rename"&&"Rename",e==="delete"&&"Delete"]}),t.jsxs(hs,{children:[e==="createFile"&&`Create a new file in ${r?.path??"root"}`,e==="createFolder"&&`Create a new folder in ${r?.path??"root"}`,e==="rename"&&`Rename ${r?.name??""}`,e==="delete"&&`Are you sure you want to delete ${r?.name??""}? This action cannot be undone.`]})]}),e!=="delete"&&t.jsx("div",{className:"py-4",children:t.jsx(Rt,{value:s,onChange:g=>i(g.target.value),placeholder:e==="rename"?"New name":"Name",onKeyDown:g=>{g.key==="Enter"&&u()},ref:m})}),t.jsxs(gs,{children:[t.jsx(H,{variant:"outline",onClick:f,disabled:o,children:"Cancel"}),t.jsx(H,{variant:e==="delete"?"destructive":"default",onClick:()=>{u()},disabled:o||e!=="delete"&&!s.trim(),children:o?t.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}):e==="delete"?"Delete":"Confirm"})]})]})}),Oi=({label:e,iconDataUrl:r})=>{const[s,i]=a.useState(!1),o=e.trim().slice(0,1).toUpperCase()||"?";return r&&!s?t.jsx("img",{src:r,alt:"",className:"size-4 rounded-sm",onError:()=>i(!0)}):t.jsx("span",{className:X("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),children:o})},Ds=({filePath:e,extension:r})=>t.jsx(jt,{filePath:e,extension:r}),Pi=({status:e})=>{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)"}[e];return t.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:r}})},Kn=({name:e})=>{const r=a.useRef(null),s=a.useRef(null),[i,o]=a.useState(!1);return a.useLayoutEffect(()=>{const u=r.current,f=s.current;if(!u||!f)return;const m=()=>{o(f.scrollWidth>u.clientWidth+1)};m();const g=new ResizeObserver(m);return g.observe(u),g.observe(f),()=>{g.disconnect()}},[e]),t.jsxs("span",{ref:r,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[t.jsx("span",{ref:s,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:e}),i?t.jsxs("span",{className:"open-file-name-marquee-track",children:[t.jsx("span",{className:"open-file-name-marquee-item",children:e}),t.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:e})]}):t.jsx("span",{className:"block min-w-0 truncate",children:e})]})},Li=({node:e,root:r,isExpanded:s,isActive:i,isMobile:o,isBrowserClient:u,alwaysShowActions:f,status:m,badge:g,permissions:y,downloadFile:S,contextMenuPath:x,setContextMenuPath:b,rightClickMenuPath:j,setRightClickMenuPath:C,onSelect:v,onToggle:P,onRevealPath:I,onOpenDialog:l})=>{const B=e.type==="directory",{canRename:L,canCreateFile:W,canCreateFolder:$,canDelete:G,canReveal:K}=y,J=!B&&!!S,D=K&&!u,T=L||W||$||G||J||D,k=a.useCallback(d=>{T&&(d?.preventDefault(),C(e.path))},[T,e.path,C]),V=a.useCallback(()=>{B?P(e.path):v(e)},[B,e,v,P]),E=a.useCallback(d=>{d.stopPropagation(),C(null),b(e.path)},[e.path,b,C]),R=({Item:d,Separator:A})=>t.jsxs(t.Fragment,{children:[L&&t.jsxs(d,{onClick:N=>{N.stopPropagation(),l("rename",e)},children:[t.jsx(F,{name:"edit",className:"mr-2 size-4"})," ","Rename"]}),t.jsxs(d,{onClick:N=>{N.stopPropagation(),Yt(e.path).then(O=>{if(O.ok){me.success("Path copied");return}me.error("Copy failed")})},children:[t.jsx(F,{name:"file-copy",className:"mr-2 size-4"})," ","Copy Path"]}),t.jsxs(d,{onClick:N=>{N.stopPropagation();const O=Ct(r,e.path)||e.path;Yt(O).then(Y=>{if(Y.ok){me.success("Relative path copied");return}me.error("Copy failed")})},children:[t.jsx(F,{name:"file-copy-2",className:"mr-2 size-4"})," ","Copy Relative Path"]}),!B&&S&&t.jsxs(d,{onClick:N=>{N.stopPropagation(),S(e.path).catch(O=>{console.error("Download failed:",O),me.error("Operation failed")})},children:[t.jsx(F,{name:"download",className:"mr-2 size-4"})," ",u?"Download":"Save"]}),D&&t.jsxs(d,{onClick:N=>{N.stopPropagation(),I(e.path)},children:[t.jsx(F,{name:"folder-received",className:"mr-2 size-4"})," ",co()]}),B&&(W||$)&&t.jsxs(t.Fragment,{children:[t.jsx(A,{}),W&&t.jsxs(d,{onClick:N=>{N.stopPropagation(),l("createFile",e)},children:[t.jsx(F,{name:"file-add",className:"mr-2 size-4"})," ","New File"]}),$&&t.jsxs(d,{onClick:N=>{N.stopPropagation(),l("createFolder",e)},children:[t.jsx(F,{name:"folder-add",className:"mr-2 size-4"})," ","New Folder"]})]}),G&&t.jsxs(t.Fragment,{children:[t.jsx(A,{}),t.jsxs(d,{onClick:N=>{N.stopPropagation(),l("delete",e)},className:"text-destructive focus:text-destructive",children:[t.jsx(F,{name:"delete-bin",className:"mr-2 size-4"})," ","Delete"]})]})]});return t.jsxs(Jo,{open:j===e.path,onOpenChange:d=>C(d?e.path:null),children:[t.jsxs(Xo,{render:t.jsx("div",{className:"group relative flex items-center",onContextMenu:o?void 0:k}),children:[t.jsxs("button",{type:"button",onClick:V,onContextMenu:o?void 0:k,className:X("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",i?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[B?s?t.jsx(F,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):t.jsx(F,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):t.jsx(Ds,{filePath:e.path,extension:e.extension}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:e.path,children:e.name}),!B&&m&&t.jsx(Pi,{status:m}),B&&g&&t.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[g.modified>0&&t.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",g.modified]}),g.added>0&&t.jsxs("span",{className:"text-[var(--status-success)]",children:["+",g.added]})]})]}),T&&t.jsx("div",{className:X("absolute right-1 top-1/2 -translate-y-1/2",f?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:t.jsxs(Mr,{open:x===e.path,onOpenChange:d=>b(d?e.path:null),children:[t.jsx(Tr,{asChild:!0,children:t.jsx(H,{variant:"ghost",size:"icon",className:"size-6",onClick:E,children:t.jsx(F,{name:"more-2-fill",className:"size-4"})})}),t.jsx(Dr,{align:"end",side:"bottom",onCloseAutoFocus:()=>b(null),children:R({Item:Zt,Separator:jo})})]})})]}),t.jsx(Yo,{className:"min-w-[180px]",children:R({Item:Zo,Separator:Qo})})]})},jr=(e,r,s)=>{const[i,o]=a.useState(""),[u,f]=a.useState(0);return a.useEffect(()=>{if(!e){o("");return}let m=!1;o("");const g=lo(),y=uo(g);fo(g).then(x=>{m||!x||(o(e),r(null))}).catch(x=>{m||(r(x instanceof Error?x.message:s),o(e))});const S=mo(()=>{m||(o(e),f(x=>x+1),r(null))});return()=>{m=!0,y(),S()}},[e,r,s]),{readyKey:i,nonce:u}},Ii=e=>e!==null&&typeof e=="object"&&"updateStatus"in e&&typeof e.updateStatus=="function",Bi=e=>{const r=document.createElement("div");r.className="cm-vim-panel";const s=bi(e);if(!s)return{top:!1,dom:r};s.state.statusbar=r;const i=s.state.vimPlugin;return Ii(i)&&i.updateStatus(),{top:!1,dom:r,destroy(){s.state.statusbar===r&&(s.state.statusbar=null)}}};function qn(e){return e?[vi(),Ao.of(Bi),Oo()]:[]}const $i={next:"Next match",prev:"Previous match",select:"Select all matches",replace:"Replace",replaceAll:"Replace all",close:"Close"},Vi={case:"Match case",re:"Regular expression",word:"Match whole word"};function Wi(e){const r=e.querySelector(".cm-search");if(r){for(const[s,i]of Object.entries($i)){const o=r.querySelector(`button[name="${s}"]`);o&&!o.title&&(o.title=i)}for(const[s,i]of Object.entries(Vi)){const u=r.querySelector(`input[name="${s}"]`)?.parentElement;u&&!u.title&&(u.title=i)}}}const Cr=new WeakMap;function _i(e,r){const s=er(e.state);if(!s.valid)return Cr.delete(e),0;const i=Cr.get(e);if(!r&&i?.doc===e.state.doc&&i.query.eq(s))return i.total;const o=s.getCursor(e.state);let u=0;for(let f=o.next();!f.done;f=o.next())u+=1;return Cr.set(e,{query:s,doc:e.state.doc,total:u}),u}function Ki(e){const r=er(e.state);if(!r.valid)return 0;const s=e.state.selection.main,i=r.getCursor(e.state);let o=0,u=0;for(let f=i.next();!f.done;f=i.next()){const m=f.value;if(o+=1,u===0&&(u=o),s.from===m.from&&s.to===m.to||s.from<m.to&&s.to>m.from||m.from>=s.head)return o}return u}function Gn(e,r,s=!1){const i=e.querySelector(".cm-search");if(!i)return;let o=i.querySelector(".cm-search-message");if(!o){o=document.createElement("span"),o.className="cm-search-message",o.setAttribute("aria-live","polite");const m=i.querySelector('button[name="next"]'),g=m?.parentNode===i?m:i.firstChild;i.insertBefore(o,g)}const u=_i(r,s),f=u===0?0:Ki(r);o.textContent=u===0?"":`${f}/${u}`}const Un=new at,Hn=new at,Jn=new at,Xn=new at,Yn=new at,Zn=new at,Qn=new at,es=e=>e,Nr=$o,qi=gi,Gi=xi;class Ui extends Lo{constructor(r,s){super(),this.id=r,this.containerMap=s}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 ts=(e,r)=>!e||e.length===0?[]:js.define({create(s){const i=new Ar,o=[...e].sort((u,f)=>u.afterLine-f.afterLine);for(const u of o){const f=s.doc.lines;if(u.afterLine>f)continue;const m=s.doc.line(u.afterLine);i.add(m.to,m.to,tr.widget({widget:new Ui(u.id,r),block:!0,side:1}))}return i.finish()},update(s,i){return s.map(i.changes)},provide:s=>pe.decorations.from(s)}),rs=e=>{if(!e)return[];const r=Math.max(1,e.start),s=Math.max(r,e.end);return ks.fromClass(class{decorations;constructor(i){this.decorations=this.build(i)}update(i){(i.docChanged||i.viewportChanged)&&(this.decorations=this.build(i.view))}build(i){const o=new Ar;for(let u=r;u<=s&&u<=i.state.doc.lines;u+=1){const f=i.state.doc.line(u);o.add(f.from,f.from,tr.line({class:"oc-cm-selected-line"}))}return o.finish()}},{decorations:i=>i.decorations})};function Hi({value:e,onChange:r,extensions:s,className:i,readOnly:o,lineNumbersConfig:u,highlightLines:f,onViewReady:m,onViewDestroy:g,blockWidgets:y,enableSearch:S,searchOpen:x,onSearchOpenChange:b,vimMode:j}){const C=a.useRef(null),v=a.useRef(null),P=a.useRef(e),I=a.useRef(r),l=a.useRef(m),B=a.useRef(g),L=a.useRef(b),W=a.useRef(y),$=a.useRef(j),G=a.useRef(new Map),[K,J]=a.useState([]),D=a.useCallback(k=>{const V=(k??[]).map(E=>{const R=G.current.get(E.id);return R?{id:E.id,content:E.content,container:R}:null}).filter(E=>E!==null);J(E=>E.length===V.length&&E.every((R,d)=>{const A=V[d];return R.id===A.id&&R.content===A.content&&R.container===A.container})?E:V)},[]),T=a.useCallback(k=>{const V=C.current,E=k??v.current;if(!V||!E)return;const R=E.dom.querySelector(".cm-gutters"),d=R instanceof HTMLElement?R.getBoundingClientRect().width:0;V.style.setProperty("--oc-editor-gutter-width",`${d}px`)},[]);return a.useEffect(()=>{P.current=e},[e]),a.useEffect(()=>{I.current=r},[r]),a.useEffect(()=>{l.current=m,B.current=g},[m,g]),a.useEffect(()=>{L.current=b},[b]),a.useEffect(()=>{W.current=y,D(y)},[y,D]),a.useEffect(()=>{if(!C.current)return;const k=(()=>{if(typeof document>"u")return null;const E=document.querySelector('meta[name="csp-nonce"]')?.getAttribute("content");if(E)return E;const R=window.__PICHAMBER_CSP_NONCE__;return typeof R=="string"&&R.length>0?R:null})(),V=_o.create({doc:P.current,extensions:[...k?[pe.cspNonce.of(k)]:[],Po({fixed:!0}),Un.of(Tn(u)),fi(),Bo.of(" "),Qn.of(qn(j)),wr.of([mi,...pi,...hi]),pe.updateListener.of(E=>{T(E.view),(E.viewportChanged||E.geometryChanged)&&D(W.current);const R=Ln(E.startState),d=Ln(E.state);R!==d&&L.current?.(d);const A=!er(E.startState).eq(er(E.state));if(d&&(R!==d||A||E.docChanged||E.selectionSet)&&Gn(E.view.dom,E.view,R!==d||A||E.docChanged),!E.docChanged)return;const N=E.state.doc.toString();P.current=N,I.current(N),D(W.current)}),Hn.of(pe.editable.of(!o)),Jn.of(s??[]),Xn.of(rs(f)),Yn.of(ts(y,G.current)),Zn.of(S?[In({top:!0}),wr.of(es(Bn))]:[])]});return v.current=new pe({state:V,parent:C.current}),Nr(v.current,v.current.state.doc.length,200),v.current.requestMeasure(),requestAnimationFrame(()=>{T(v.current),D(W.current)}),v.current&&l.current?.(v.current),()=>{B.current?.(),v.current?.destroy(),v.current=null,J([])}},[W,T,D]),a.useEffect(()=>{const k=v.current;k&&(k.dispatch({effects:[Un.reconfigure(Tn(u)),Hn.reconfigure(pe.editable.of(!o)),Jn.reconfigure(s??[]),Xn.reconfigure(rs(f)),Yn.reconfigure(ts(y,G.current)),Zn.reconfigure(S?[In({top:!0}),wr.of(es(Bn))]:[])]}),Nr(k,k.state.doc.length,200),k.requestMeasure(),requestAnimationFrame(()=>{T(k),D(W.current)}))},[s,f,u,o,y,S,T,D]),a.useEffect(()=>{const k=v.current;if(!k){$.current=j;return}$.current!==j&&($.current=j,k.dispatch({effects:Qn.reconfigure(qn(j))}))},[j]),a.useEffect(()=>{const k=v.current;!k||S===!1||(x?(qi(k),requestAnimationFrame(()=>{Wi(k.dom),Gn(k.dom,k,!0)})):Gi(k))},[x,S]),a.useEffect(()=>{const k=v.current;if(!k)return;const V=k.state.doc.toString();V!==e&&(k.dispatch({changes:{from:0,to:V.length,insert:e}}),Nr(k,k.state.doc.length,300),k.requestMeasure(),requestAnimationFrame(()=>T(k)))},[e,T]),t.jsxs(t.Fragment,{children:[t.jsx("div",{ref:C,className:X("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)]",i)}),K.map(k=>io.createPortal(k.content,k.container,k.id))]})}const ns=({variant:e,selectedFile:r,loading:s,suppressLoadingIndicator:i,fileError:o,isSelectedImage:u,imageSrc:f,imagePreviewNonce:m,isSelectedPdf:g,pdfSrc:y,pdfPreviewNonce:S,isUnsupportedBinary:x,onDownload:b,enableRichPreviews:j,drawioViewMode:C,drawioRemountNonce:v,diagramEditorRef:P,diagramEditorXml:I,onDiagramChange:l,jsonViewMode:B,markdownViewMode:L,htmlViewMode:W,htmlLoading:$,htmlPreviewNonce:G,htmlPreviewSrc:K,fileContent:J,canUseShikiFileView:D,textViewMode:T,draftContent:k,onDraftChange:V,canEdit:E,vimMode:R,editorExtensions:d,editorWrapperRef:A,shouldMaskEditorForPendingNavigation:N,onEditorViewReady:O,onEditorViewDestroy:Y,enableSearch:ee=!1,searchOpen:ne,onSearchOpenChange:te,pierreTheme:q,shikiThemeType:Q,wrapLines:Qe})=>{const Oe=e==="fullscreen",le=Oe?"p-4":"p-3",Pe=!!(r?.path&&Qt(r.path)),Le=!!(r?.path&&Fs(r.path)),se=!!(r?.path&&Es(r.path)),ue=!!(r?.path&&Or(r.path)),we=()=>r?t.jsx("div",{className:"h-full",children:t.jsx(di,{file:{name:r.name,contents:k,lang:vs(r.path)||void 0},options:{disableFileHeader:!0,overflow:Qe?"wrap":"scroll",theme:q,themeType:Q},className:"block h-full w-full",style:{height:"100%"}})}):null;return t.jsx(xs,{outerClassName:"h-full min-w-0",className:"h-full min-w-0",children:r?s?i?t.jsx("div",{className:le}):t.jsxs("div",{className:`${le} flex items-center gap-2 typography-ui text-muted-foreground`,children:[t.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),Oe?"Loading…":"Loading..."]}):o?t.jsx("div",{className:`${le} typography-ui text-[color:var(--status-error)]`,children:o}):u?t.jsx("div",{className:X("flex h-full items-center justify-center",le),children:t.jsx("img",{src:f,alt:r.name||"Image",className:X("max-w-full object-contain rounded-md border border-border/30 bg-primary/10",Oe?"max-h-full":"max-h-[70vh]")},m)}):g?t.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:t.jsx("iframe",{src:y,className:"h-full w-full border-0",title:r.name},S)}):x?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[t.jsx("div",{className:"typography-ui-header text-foreground",children:"Cannot preview binary file"}),t.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."}),b?t.jsxs(H,{type:"button",variant:"outline",size:"sm",onClick:b,children:[t.jsx(F,{name:"download",className:"mr-2 size-4"}),"Save file"]}):null]}):j&&Pe&&C==="preview"?t.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:t.jsx(Go,{ref:P,xml:I,onChange:l},`${r.path}:${v}`)}):j&&Le&&B==="tree"?t.jsx(Fn,{fallback:t.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[t.jsx("div",{className:"mb-1 font-medium text-destructive",children:"JSON viewer unavailable"}),t.jsx("div",{className:"text-sm text-muted-foreground",children:"Switch to text mode to view raw content."})]}),children:t.jsx("div",{className:"h-full overflow-auto",children:t.jsx(ui,{jsonString:J,maxHeight:"100%",initiallyExpandedDepth:2})})}):se&&L==="preview"?t.jsxs("div",{className:X("h-full overflow-auto",le),children:[J.length>500*1024?t.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(J.length/1024)}KB). Preview may be limited.`}):null,t.jsx(Fn,{fallback:t.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[t.jsx("div",{className:"mb-1 font-medium text-destructive",children:"Preview unavailable"}),t.jsx("div",{className:"text-sm text-muted-foreground",children:"Switch to edit mode to fix the issue."})]}),children:t.jsx(Co,{content:J,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}):j&&ue&&W==="preview"?$?t.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:"Loading..."}):t.jsx("div",{className:"h-full overflow-hidden",children:t.jsx("iframe",{src:K,className:"w-full h-full border-none",sandbox:"allow-scripts allow-same-origin allow-forms",title:"HTML Preview"},G)}):D&&T==="view"?we():t.jsxs("div",{className:X("relative h-full",N&&"overflow-hidden"),ref:A,children:[t.jsx("div",{className:X("h-full",N&&"invisible"),children:t.jsx(Hi,{value:k,onChange:V,readOnly:!E,vimMode:R,extensions:d,className:"h-full",onViewReady:O,onViewDestroy:Y,...ee?{enableSearch:!0,searchOpen:ne,onSearchOpenChange:te}:{}})}),N?t.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:t.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[t.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),"Opening file at change..."]})}):null]}):t.jsx("div",{className:`${le} typography-ui text-muted-foreground`,children:"Pick a file from the tree."})})};async function Ji(e,r,s){if(bs(e)&&!ys(e))return{kind:r?"desktop-image":"asset-image"};if(ws(e))return{kind:"pdf"};if(Er(e))return{kind:"binary",detectedFromContent:!1};const o=await s(e);if(No(o))return{kind:"binary",detectedFromContent:!0};const u=ei(o);return{kind:"text",content:u,draft:u.length>Nt?`${u.slice(0,Nt)}
2
2
 
3
3
  … truncated …`:u,lineEnding:ti(o)}}function Xi({isDirty:e,saveDraft:r}){const s=Fe(b=>b.setMainTabGuard),[i,o]=w.useState(!1),u=w.useRef(null),f=w.useRef(!1),m=w.useCallback(b=>f.current?(f.current=!1,!1):e?(u.current=b,o(!0),!0):!1,[e]);w.useEffect(()=>{if(!e){s(null);return}const b=j=>!m({kind:"tab",tab:j});return s(b),()=>{Fe.getState().mainTabGuard===b&&s(null)}},[e,m,s]);const g=w.useCallback(()=>{const b=u.current;return u.current=null,f.current=!0,o(!1),b?.kind==="tab"&&s(null),b},[s]),y=w.useCallback(()=>g(),[g]),S=w.useCallback(async()=>await r()?g():(f.current=!1,null),[r,g]),x=w.useCallback(b=>{b||o(!0)},[]);return{confirmOpen:i,discardAndTakeIntent:y,keepModalOpen:x,requestNavigation:m,saveAndTakeIntent:S}}function Yi(e,r){if(e.state.doc.length!==r.length)return!1;if(r.length===0)return!0;const s=Math.min(128,r.length);if(e.state.sliceDoc(0,s)!==r.slice(0,s))return!1;const i=Math.max(0,r.length-s);return e.state.sliceDoc(i,r.length)===r.slice(i)}function Zi({root:e,selectedPath:r,loadedPath:s,fileLoading:i,fileError:o,isImage:u,isPdf:f,isUnsupportedBinary:m,canEdit:g,textViewMode:y,setTextViewMode:S,draftContent:x,confirmDiscardOpen:b,selectFilePath:j}){const C=Fe(D=>D.pendingFileNavigation),v=Fe(D=>D.setPendingFileNavigation),P=Fe(D=>D.pendingFileFocusPath),I=Fe(D=>D.setPendingFileFocusPath),l=w.useRef(null),[B,L]=w.useState(0),W=w.useRef(null),$=w.useRef({key:"",attempts:0}),G=w.useCallback(()=>{L(D=>D+1)},[]);w.useEffect(()=>()=>{W.current!==null&&window.cancelAnimationFrame(W.current)},[]),w.useEffect(()=>{if(!C||!e)return;const D=()=>{W.current===null&&(W.current=window.requestAnimationFrame(()=>{W.current=null,G()}))},T=()=>{v(null),$.current={key:"",attempts:0}},k=oe(C.path);if(!k){T();return}const V=`${k}:${C.line}:${C.column??1}`;if($.current.key!==V&&($.current={key:V,attempts:0}),r!==k){b||j(k);return}if(i||s!==k)return;if(o||u||f||m){T();return}if(!g)return;if(y!=="edit"){S("edit");return}const E=l.current;if(!E||!Yi(E,x)){D();return}const R=Math.max(1,Math.min(C.line,E.state.doc.lines)),d=E.state.doc.line(R),A=Math.max(1,C.column||1),N=d.from+Math.min(Math.max(0,d.to-d.from),A-1);if(!(E.state.selection.main.head===N)||$.current.attempts===0){$.current.attempts+=1,E.dispatch({selection:{anchor:N},effects:pe.scrollIntoView(N,{y:"center"})}),E.focus(),D();return}window.requestAnimationFrame(()=>{const Y=l.current;Y&&(Y.dispatch({selection:{anchor:N},effects:pe.scrollIntoView(N,{y:"center"})}),Y.focus())}),T()},[g,b,x,B,o,i,u,f,m,s,G,C,e,r,j,v,S,y]),w.useEffect(()=>{if(!P||!e)return;const D=oe(P);if(!D){I(null);return}r!==D||i||s!==D||(!o&&!u&&!f&&!m&&g&&y==="edit"&&l.current?.focus(),I(null))},[g,o,i,u,f,m,s,P,e,r,I,y]);const K=oe(C?.path??"");return{editorViewRef:l,notifyEditorViewChanged:G,shouldMaskEditor:!!(C&&K&&r===K&&!i&&!o&&!u&&!f&&!m)}}function Qi(e){return!(!e.autoSaveEnabled||!e.isDirty||!e.canWrite||e.isSaving||e.fileLoading||e.isNonEditableBinary||!e.selectedFilePath||e.loadedFilePath!==e.selectedFilePath)}function ec(e){return e.selectedFilePath?e.isDirty?!(e.fileLoading||e.loadedFilePath!==e.selectedFilePath||e.isNonEditableBinary||e.draftContent===""&&e.fileContent!==""&&e.loadedFilePath!==e.selectedFilePath):!0:!1}const tc=1500,rc=2e3;function nc({autoSaveEnabled:e,selectedPath:r,loadedPath:s,fileLoading:i,isDirty:o,draftContent:u,fileContent:f,lineEnding:m,isNonEditableBinary:g,writeFile:y,expectedRevision:S,onSaved:x,captureSaveScope:b,currentSaveScope:j,onConflict:C}){const[v,P]=w.useState(!1),[I,l]=w.useState("idle"),[B,L]=w.useState(null),W=w.useRef(null),$=w.useRef(null),G=w.useRef(C);G.current=C;const K=w.useRef(b);K.current=b;const J=w.useRef(j);J.current=j;const D=w.useCallback(R=>R?Cs(R,J.current?.()??null):!0,[]),T=w.useCallback(()=>{W.current&&(clearTimeout(W.current),W.current=null)},[]),k=w.useCallback(()=>{l("saved"),$.current&&clearTimeout($.current),$.current=setTimeout(()=>{$.current=null,l("idle")},rc)},[]),V=w.useCallback(async R=>{if(!r||!y)return me.error("Saving not supported"),!1;if(!ec({selectedFilePath:r,loadedFilePath:s,fileLoading:i,isDirty:o,draftContent:u,fileContent:f,isNonEditableBinary:g}))return g?console.warn(`[saveDraft] refusing to save binary file "${r}".`):u===""&&f!==""&&s!==r&&console.warn(`[saveDraft] refusing to save empty draft for "${r}" (${f.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(!o)return!0;P(!0);const d=K.current?.()??null;try{const A=ri(u,m),N=Ns(S,R?.overwrite),O=await y(r,A,N);return O?.success?D(d)?(L(null),x(r,u,O?.revision,d),!0):!1:(me.error("Failed to write file"),!1)}catch(A){if(us(A)){if(!D(d))return!1;const N={path:r,currentRevision:A.currentRevision??null,exists:A.exists};return L(N),G.current?.(N),!1}return me.error(A instanceof Error?A.message:"Save failed"),!1}finally{P(!1)}},[u,S,f,i,o,g,D,m,s,x,r,y]),E=w.useCallback(async R=>{if(T(),v)return!1;const d=await V(R);return d&&k(),d},[T,v,V,k]);return w.useEffect(()=>{e||(l("idle"),T())},[e,T]),w.useEffect(()=>{if(Qi({autoSaveEnabled:e,isDirty:o,canWrite:!!(r&&y),isSaving:v,fileLoading:i,selectedFilePath:r,loadedFilePath:s,isNonEditableBinary:g}))return W.current=setTimeout(()=>{W.current=null,V().then(R=>{R&&k()})},tc),T},[e,T,u,i,o,g,v,s,V,r,k,y]),w.useEffect(()=>{l("idle"),P(!1),L(null)},[r]),w.useEffect(()=>()=>{T(),$.current&&clearTimeout($.current)},[T]),{autoSaveStatus:I,cancelPendingAutosave:T,isSaving:v,saveConflict:B,clearSaveConflict:()=>L(null),saveDraft:V,saveNow:E}}function sc(e,r){return typeof e.revision=="string"&&typeof r.revision=="string"&&e.revision!==r.revision?!0:r.mtimeMs!==void 0&&e.mtimeMs!==void 0&&r.mtimeMs!==e.mtimeMs||r.size!==e.size}function ac({selectedPath:e,loadedPath:r,isDirty:s,readStat:i,onExternalChange:o,pollIntervalMs:u=2e3}){const f=w.useRef(null),m=w.useRef(s);m.current=s;const g=w.useCallback(y=>{f.current=y},[]);return w.useEffect(()=>{if(!e||r!==e)return;let y=!1;const S=window.setInterval(()=>{if(document.hidden)return;const x=f.current,b=x&&x.path===e&&typeof x.revision=="string"?x.revision:null;i(e,{knownRevision:b}).then(j=>{if(y||!j)return;const C=f.current;if(!C||C.path!==e){f.current=j;return}!sc(C,j)||m.current||(f.current=j,o())}).catch(()=>{})},u);return()=>{y=!0,window.clearInterval(S)}},[r,o,u,i,e]),{recordStat:g}}const ss="pichamber:files:md-viewer-mode",as="pichamber:files:html-viewer-mode",os="pichamber:files:json-viewer-mode",oc=1500,ic=1500;function Sr(e,r,s){try{const i=localStorage.getItem(e);if(i&&r.includes(i))return i}catch{}return s}function Rr(e,r){try{localStorage.setItem(e,r)}catch{}}function cc({root:e,selectedPath:r,fileContent:s,draftContent:i,setDraftContent:o,autoSaveEnabled:u,writeFile:f,expectedRevision:m,captureSaveScope:g,currentSaveScope:y,onSaved:S,onConflict:x}){const[b,j]=w.useState("edit"),[C,v]=w.useState("edit"),[P,I]=w.useState("text"),[l,B]=w.useState("edit"),[L,W]=w.useState("edit"),[$,G]=w.useState(0),[K,J]=w.useState(!1),D=w.useRef({}),T=w.useRef({}),k=w.useRef({}),V=w.useRef({}),E=w.useRef(""),R=w.useRef(""),d=w.useRef(null),A=w.useRef(null),N=w.useRef(null),O=w.useRef(m);O.current=m;const Y=w.useRef(g);Y.current=g;const ee=w.useRef(y);ee.current=y;const ne=w.useRef(S);ne.current=S;const te=w.useRef(x);te.current=x;const q=w.useCallback(()=>{d.current&&(clearTimeout(d.current),d.current=null),N.current!==null&&(cancelAnimationFrame(N.current),N.current=null)},[]),Q=w.useCallback(_=>{E.current=_,R.current=_},[]),Qe=w.useCallback(()=>Q(""),[Q]);w.useEffect(()=>{r&&(j(D.current[r]??"edit"),v(T.current[r]??Sr(ss,["preview","edit"],"edit")),B(k.current[r]??Sr(as,["preview","edit"],"edit")),W(V.current[r]??"edit"),I(Sr(os,["tree","text"],"text")))},[r]);const Oe=w.useCallback(_=>{r&&(D.current[r]=_),j(_)},[r]),le=w.useCallback(_=>{r&&(T.current[r]=_),v(_),Rr(ss,_)},[r]),Pe=w.useCallback(_=>{r&&(k.current[r]=_),B(_),Rr(as,_)},[r]),Le=w.useCallback(_=>{I(_),Rr(os,_)},[]),se=w.useCallback(_=>{if(r&&(V.current[r]=_),q(),_==="edit"){o(E.current||s),W(_);return}E.current=i;const U=r;W("edit"),N.current=requestAnimationFrame(()=>{N.current=requestAnimationFrame(()=>{N.current=null,!(e&&U&&Re.getState().byRoot[e]?.selectedPath!==U)&&(G(ae=>ae+1),W("preview"))})})},[q,i,s,e,r,o]),ue=w.useCallback(_=>_?Cs(_,ee.current?.()??null):!0,[]),we=w.useCallback(async(_,U,ae)=>{if(!f||U===R.current)return!1;const ge=Y.current?.()??null;if(ge&&ge.path!==_)return!1;try{const de=await f(_,U,Ns(O.current,ae?.overwrite));return de?.success?ue(ge)?(Q(U),o(U),ne.current?.(_,U,de?.revision,ge),!0):!1:(me.error("Failed to write file"),!1)}catch(de){return us(de)?(ue(ge)&&te.current?.({path:_,currentRevision:de.currentRevision??null,exists:de.exists,xml:U}),!1):(me.error(de instanceof Error?de.message:"Save failed"),!1)}},[ue,Q,o,f]),he=w.useCallback(()=>{J(!0),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>J(!1),ic)},[]),Ie=w.useCallback(async(_,U,ae)=>{d.current&&(clearTimeout(d.current),d.current=null);const ge=await we(_,U,ae);return ge&&he(),ge},[we,he]),gt=w.useCallback(_=>{E.current=_,!(!u||!r||L!=="preview"||!f)&&(d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,we(r,_).then(U=>{U&&he()})},oc))},[u,L,we,r,he,f]);w.useEffect(()=>q,[q,L,r]),w.useEffect(()=>()=>{A.current&&clearTimeout(A.current)},[]);const Ee=Qt(r??"")&&(E.current||i)||s;return{clearDiagramContent:Qe,diagramEditorXml:Ee,diagramSaved:K,drawioRemountNonce:$,drawioViewMode:L,handleDiagramChange:gt,htmlViewMode:l,jsonViewMode:P,mdViewMode:C,recordDiagramContent:Q,saveDiagramNow:Ie,saveDiagramXml:we,saveDrawioViewMode:se,saveHtmlViewMode:Pe,saveJsonViewMode:Le,saveMdViewMode:le,saveTextViewMode:Oe,setTextViewMode:j,textViewMode:b}}function lc(e,r){return e==="mobile"?!0:r==="full"}function uc(e,r){if(e===r)return!0;if(e.length!==r.length)return!1;for(let s=0;s<e.length;s+=1){const i=e[s],o=r[s];if(i.name!==o.name||i.path!==o.path||i.type!==o.type||i.extension!==o.extension||i.relativePath!==o.relativePath||i.size!==o.size)return!1}return!0}function dc({files:e,root:r,activeDirectory:s,expandedPaths:i,chrome:o,showGitignored:u,removeExpandedPathsByPrefix:f,enabled:m=!0,visible:g=!0}){const[y,S]=a.useState({}),[x,b]=a.useState({}),j=a.useRef(new Set),C=a.useRef(new Set),v=a.useRef(new Map),P=a.useRef(new Map),I=a.useRef(0),l=a.useRef(!1),[B,L]=a.useState(()=>po());a.useEffect(()=>ho(R=>{L(R.runtimeKey)}),[]),a.useEffect(()=>(l.current=!1,()=>{l.current=!0,P.current=new Map,C.current=new Set,v.current=new Map}),[]);const W=a.useCallback((R,d)=>{const A=[];for(const N of d){if(!N?.name||o==="desktop"&&!u&&ni(N.name))continue;const O=oe(N.path||""),Y=O?si(O)?O:oe(`${R}/${O}`):oe(`${R}/${N.name}`),ee=N.isDirectory?"directory":"file";A.push({name:N.name,path:Y,type:ee,extension:ee==="file"&&N.name.includes(".")?N.name.split(".").pop()?.toLowerCase():void 0,size:N.size})}return ai(A)},[o,u]),$=`${B}|${r}|g${u?"1":"0"}|${o}`,G=a.useRef($);G.current=$;const K=a.useCallback(async R=>{if(!m)return;const d=oe(R.trim());if(!d||j.current.has(d))return;const A=v.current.get(d);if(A){await A;return}const N=G.current,O=I.current+1;I.current=O,P.current=new Map(P.current).set(d,O),C.current=new Set(C.current).add(d);const Y=()=>!l.current&&G.current===N&&P.current.get(d)===O,ee=(async()=>{try{const ne=e.listDirectory?(await e.listDirectory(d)).entries.map(q=>({name:q.name,path:q.path,isDirectory:q.isDirectory,size:q.size})):(await go(d)).map(q=>({name:q.name,path:q.path,isDirectory:q.isDirectory}));if(!Y())return;j.current=new Set(j.current).add(d),b(q=>{if(!q[d])return q;const Q={...q};return delete Q[d],Q});const te=W(d,ne);S(q=>{const Q=q[d];return Q&&uc(Q,te)?q:{...q,[d]:te}})}catch(ne){if(!Y())return;const te=ne instanceof Error?ne.message:String(ne??"");te==="Directory not found"&&r&&d!==r?(f(r,d),b(q=>{if(!q[d])return q;const Q={...q};return delete Q[d],Q})):(console.error("Failed to load files directory:",ne),b(q=>({...q,[d]:te})))}finally{P.current.get(d)===O&&(P.current=new Map(P.current),P.current.delete(d))}})();v.current.set(d,ee);try{await ee}finally{v.current.get(d)===ee&&(v.current.delete(d),C.current=new Set(C.current),C.current.delete(d))}},[m,e,W,f,r]),J=a.useCallback(()=>{j.current=new Set,C.current=new Set,v.current=new Map,P.current=new Map,b({}),S(R=>Object.keys(R).length===0?R:{})},[]),D=a.useCallback(async()=>{!m||!r||(J(),await K(r))},[m,K,J,r]),T=a.useCallback(async R=>{if(!m)return;if(!R){await D();return}const d=oe(R);j.current=new Set(j.current),j.current.delete(d),C.current=new Set(C.current),C.current.delete(d),v.current.delete(d),P.current=new Map(P.current),P.current.delete(d),await K(d)},[m,K,D]),k=a.useRef("");a.useEffect(()=>{k.current!==$&&(k.current=$,J())},[J,$]),a.useEffect(()=>{!m||!g||!r||j.current.has(oe(r))||K(r)},[m,K,r,$,g]),a.useEffect(()=>{!m||!g||!s||K(s)},[s,m,K,g]),a.useEffect(()=>{if(!m||!g||!e.listDirectory)return;const R=O=>{const Y=oe(O);return v.current.has(Y)||C.current.has(Y)},d=()=>{if(!(typeof document<"u"&&document.hidden))for(const O of i)R(O)||T(O)},A=()=>{typeof document<"u"&&document.hidden||d()};typeof document<"u"&&document.addEventListener("visibilitychange",A);const N=i.length>0?window.setInterval(d,8e3):null;return()=>{typeof document<"u"&&document.removeEventListener("visibilitychange",A),N!==null&&window.clearInterval(N)}},[m,i,e.listDirectory,T,g]);const V=a.useRef(m&&g);a.useEffect(()=>{const R=m&&g,d=V.current;if(V.current=R,!(!R||d)){if(!e.listDirectory){r&&!j.current.has(oe(r))&&K(r);return}if(i.length===0){r&&!j.current.has(oe(r))&&K(r);return}for(const A of i){const N=oe(A);v.current.has(N)||C.current.has(N)||T(A)}}},[m,i,e.listDirectory,K,T,r,g]);const E=a.useCallback(R=>j.current.has(oe(R)),[]);return{childrenByDir:y,loadErrorsByDir:x,isLoaded:E,loadDirectory:K,refreshDirectory:T,refreshRoot:D}}const fc=({showEditorTabsRow:e,isMobile:r,showMobilePageContent:s,onBackMobile:i,selectedFile:o,openFiles:u,root:f,alwaysShowActions:m,editorTabsOverflow:g,editorTabsScrollRef:y,onSelectFile:S,onCloseFile:x})=>e?t.jsxs("div",{className:"flex min-w-0 items-center px-3 py-1.5",children:[r&&s&&t.jsx("button",{type:"button",onClick:i,"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:t.jsx(F,{name:"arrow-left-s",className:"size-5"})}),r?o?t.jsxs(Mr,{children:[t.jsx(Tr,{asChild:!0,children:t.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:[t.jsx(jt,{filePath:o.path,extension:o.extension,className:"size-3.5 flex-shrink-0"}),t.jsx(Kn,{name:o.name}),t.jsx(F,{name:"arrow-down-s",className:"size-4 flex-shrink-0 text-muted-foreground"})]})}),t.jsx(Dr,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]",children:u.map(b=>{const j=o?.path===b.path;return t.jsxs(Zt,{onSelect:C=>{if(C.target.closest("[data-close-open-file]")){C.preventDefault();return}j||S(b)},className:X("flex min-w-0 items-center justify-between gap-2 overflow-hidden",j&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),children:[t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[t.jsx(jt,{filePath:b.path,extension:b.extension,className:"size-3.5 flex-shrink-0"}),t.jsx(Kn,{name:b.name})]}),t.jsx("button",{type:"button","data-close-open-file":!0,onPointerDown:C=>{C.preventDefault(),C.stopPropagation()},onClick:C=>{C.preventDefault(),C.stopPropagation(),x(b.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 ${b.name}`,children:t.jsx(F,{name:"close",className:"size-3.5"})})]},b.path)})})]}):t.jsx("div",{className:"typography-ui-label font-medium truncate",children:"Select a file"}):u.length>0?t.jsxs("div",{className:"relative min-w-0 flex-1",children:[g.left&&t.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"}),g.right&&t.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"}),t.jsx("div",{ref:y,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(b=>{const j=o?.path===b.path;return t.jsxs("div",{title:Ct(f,b.path),className:X("group inline-flex items-center gap-1 rounded-md border px-2 py-1 typography-ui-label transition-colors whitespace-nowrap",j?"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:[t.jsx(jt,{filePath:b.path,extension:b.extension,className:"size-3.5 flex-shrink-0"}),t.jsx("button",{type:"button",onClick:()=>{j||S(b)},className:"max-w-[12rem] truncate text-left",children:b.name}),t.jsx("button",{type:"button",onClick:C=>{C.stopPropagation(),x(b.path)},className:X("rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",!j&&!m&&"opacity-0 group-hover:opacity-100"),"aria-label":`Close ${b.name}`,children:t.jsx(F,{name:"close",className:"size-3.5"})})]},b.path)})})]}):t.jsx("div",{className:"typography-ui-label font-medium truncate",children:"Select a file"})]}):null,mc=(e,r)=>{if(!r)return null;const s=Number.parseInt(e.trim(),10);return!Number.isFinite(s)||s<1?null:Math.min(s,r.state.doc.lines)},is=(e,r)=>{const s=e.state.doc.lineAt(r.main.head);return{lineNumber:s.number,character:r.main.head-s.from+1,selection:r}},cs=(e,r,s)=>{const i=e.state.doc.line(r),o=Math.max(1,Math.min(s,i.length+1)),u=i.from+o-1;e.dispatch({selection:Ko.cursor(u),effects:pe.scrollIntoView(u,{y:"center"})})};function pc({open:e,onOpenChange:r,view:s,variant:i="overlay"}){const[o,u]=a.useState(""),f=a.useRef(null),m=a.useRef(!1),g=a.useRef(null),y=a.useRef(null),S=a.useMemo(()=>mc(o,s),[o,s]);a.useEffect(()=>{!e||!s||(m.current=!1,f.current=is(s,s.state.selection),u(""))},[e,s]),a.useEffect(()=>{e&&window.requestAnimationFrame(()=>{y.current?.focus(),y.current?.select()})},[e]),a.useEffect(()=>{if(!(!e||!s||!f.current)){if(S===null){const{selection:v}=f.current;s.dispatch({selection:v,effects:pe.scrollIntoView(v.main.from,{y:"center"})});return}cs(s,S,f.current.character)}},[S,e,s]);const x=a.useCallback(()=>{if(!s||m.current||!f.current)return;const{selection:v}=f.current;s.dispatch({selection:v,effects:pe.scrollIntoView(v.main.from,{y:"center"})})},[s]),b=a.useCallback(v=>{v||x(),r(v)},[r,x]),j=a.useCallback(()=>{!s||S===null||!f.current||(m.current=!0,cs(s,S,f.current.character),r(!1),s.focus())},[S,r,s]);a.useEffect(()=>{if(!e)return;const v=I=>{const l=g.current,B=I.target;!l||!(B instanceof Node)||l.contains(B)||b(!1)},P=I=>{I.key==="Escape"&&(I.preventDefault(),b(!1))};return document.addEventListener("pointerdown",v,!0),document.addEventListener("keydown",P,!0),()=>{document.removeEventListener("pointerdown",v,!0),document.removeEventListener("keydown",P,!0)}},[b,e,i]);const C=a.useMemo(()=>s?S===null?`Current Line: ${(f.current??is(s,s.state.selection)).lineNumber}. Type a line number between 1 and ${s.state.doc.lines} to navigate to.`:`Go to line ${S}`:"Editor unavailable.",[S,s]);return i==="inline"?e?t.jsxs("div",{ref:g,className:"ml-1 flex h-6 items-center gap-1",children:[t.jsx(Rt,{ref:y,type:"number",min:1,step:1,inputMode:"numeric",value:o,onChange:v=>u(v.target.value),onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),j())},placeholder:"Line",className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),t.jsx(H,{variant:"outline",size:"xs",onClick:j,disabled:!s||S===null,className:"h-6 px-2",children:"Go"})]}):null:t.jsx("div",{ref:g,className:X("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",e?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:t.jsxs("div",{className:"min-w-0",children:[t.jsx(Rt,{ref:y,type:"number",min:1,step:1,inputMode:"numeric",value:o,onChange:v=>u(v.target.value),onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),j())},placeholder:"Line number",className:"h-8 w-full rounded-md border-border/70 bg-background/60 typography-ui-label"}),t.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:e,onToggle:r})=>{const s=e==="preview",i=s?"Switch to edit mode":"Switch to preview mode",o=s?"Edit":"Preview";return t.jsxs(Xe,{children:[t.jsx(Ye,{asChild:!0,children:t.jsx(H,{variant:"ghost",size:"sm",onClick:r,"aria-label":i,className:"h-5 w-5 p-0",children:s?t.jsx(F,{name:"eye",className:"size-4","aria-hidden":"true"}):t.jsx(F,{name:"eye-off",className:"size-4","aria-hidden":"true"})})}),t.jsx(Ze,{sideOffset:8,children:o})]})},hc=({selectedFile:e,displaySelectedPath:r,layout:s="floating",exitFullscreenOnly:i=!1,canEdit:o,isEditingFile:u,isSaving:f,autoSaveEnabled:m,autoSaveStatus:g,isDirty:y,onSaveDraft:S,onToggleAutoSave:x,openInApps:b,openInCacheStale:j,onOpenInApp:C,onRefreshOpenInApps:v,onToolbarDropdownOpenChange:P,isSelectedImage:I,isSelectedPdf:l,isUnsupportedBinary:B,wrapLines:L,onToggleWrapLines:W,textViewMode:$,onToggleSearch:G,isGoToLineOpen:K,onOpenGoToLineChange:J,editorView:D,canUseShikiFileView:T,isJson:k,isHtml:V,onToggleTextViewMode:E,isMarkdown:R,mdViewMode:d,onToggleMdViewMode:A,isDrawio:N,drawioViewMode:O,onToggleDrawioViewMode:Y,diagramSaved:ee,onSaveDiagram:ne,jsonViewMode:te,onToggleJsonViewMode:q,canCopy:Q,copiedContent:Qe,onCopyContent:Oe,canCopyPath:le,copiedPath:Pe,onCopyPath:Le,onDownloadFile:se,isMobile:ue,mode:we,isFullscreen:he,onToggleFullscreen:Ie,onExitFullscreen:gt})=>{if(!e)return null;const _=s==="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",U=(ae,ge)=>t.jsxs(Xe,{children:[t.jsx(Ye,{asChild:!0,children:t.jsx("span",{className:"inline-flex",children:ge})}),t.jsx(Ze,{side:"bottom",sideOffset:6,children:ae})]});return t.jsxs("div",{className:_,children:[o&&u&&t.jsxs(t.Fragment,{children:[f?t.jsxs("span",{className:"flex items-center gap-1 px-1 text-muted-foreground typography-meta",children:[t.jsx(F,{name:"loader-4",className:"size-3.5 animate-spin"}),"Saving..."]}):m&&g==="saved"&&!y?t.jsxs("span",{className:"flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta",children:[t.jsx(F,{name:"check",className:"size-3.5"}),"Saved"]}):y?U(m?`Save now (${kt()}+S) - auto-saves after 1.5s`:`Save now (${kt()}+S)`,t.jsx(H,{variant:"ghost",size:"sm",onClick:()=>{S()},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:m?`Save now (${kt()}+S) - auto-saves after 1.5s`:`Save now (${kt()}+S)`,"aria-label":`Save (${kt()}+S)`,children:t.jsx(F,{name:"save-3",className:"size-4"})})):null,U(m?"Auto-save on":"Manual save",t.jsx(H,{variant:"ghost",size:"sm",onClick:x,className:X("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",m?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:m?"Auto-save on":"Manual save","aria-label":m?"Auto-save on":"Manual save",children:m?t.jsx(F,{name:"file-check-fill",className:"size-4"}):t.jsx(F,{name:"file-check",className:"size-4"})}))]}),t.jsxs(Mr,{onOpenChange:P,children:[t.jsxs(Xe,{children:[t.jsx(Ye,{asChild:!0,children:t.jsx("span",{className:"inline-flex",children:t.jsx(Tr,{asChild:!0,children:t.jsx(H,{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:t.jsx(F,{name:"file-transfer",className:"size-4"})})})})}),t.jsx(Ze,{side:"bottom",sideOffset:6,children:"Open in desktop app"})]}),t.jsxs(Dr,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[b.map(ae=>t.jsxs(Zt,{className:"flex items-center gap-2",onClick:()=>{C(ae)},children:[t.jsx(Oi,{label:ae.label,iconDataUrl:ae.iconDataUrl}),t.jsx("span",{className:"typography-ui-label text-foreground",children:ae.label})]},ae.id)),j?t.jsxs(Zt,{className:"flex items-center gap-2",onClick:()=>{v()},children:[t.jsx(F,{name:"refresh",className:"size-4"}),t.jsx("span",{className:"typography-ui-label text-foreground",children:"Refresh Apps"})]}):null]})]}),!I&&!l&&!B&&t.jsxs(t.Fragment,{children:[U(L?"Disable line wrap":"Enable line wrap",t.jsx(H,{variant:"ghost",size:"sm",onClick:W,className:X("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",L?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:L?"Disable line wrap":"Enable line wrap",children:t.jsx(F,{name:"text-wrap",className:"size-4"})})),$==="edit"&&t.jsxs(t.Fragment,{children:[U("Find in file",t.jsx(H,{variant:"ghost",size:"sm",onClick:ae=>{G(),ae.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:t.jsx(F,{name:"search",className:"size-4"})})),U("Go to line",t.jsx(H,{variant:"ghost",size:"sm",onClick:ae=>{J(!K),ae.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:t.jsx(F,{name:"menu-fold-2",className:"size-4"})})),t.jsx(pc,{open:K,onOpenChange:J,view:D,variant:"inline"})]})]}),T&&o&&!k&&!V&&t.jsx(Fr,{currentMode:$==="view"?"preview":"edit",onToggle:E}),R&&U(d==="preview"?"Switch to edit mode":"Switch to preview mode",t.jsx(H,{variant:"ghost",size:"sm",onClick:A,className:X("size-6 p-0 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] active:bg-[var(--interactive-hover)]",d==="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:d==="preview"?"Switch to edit mode":"Switch to preview mode","aria-label":d==="preview"?"Switch to edit mode":"Switch to preview mode",children:t.jsx(F,{name:d==="preview"?"eye":"eye-off",className:"size-4"})})),Or(e?.path??"")&&t.jsx(Fr,{currentMode:V?"preview":"edit",onToggle:E}),N&&t.jsxs(t.Fragment,{children:[t.jsx(Fr,{currentMode:O,onToggle:Y}),O==="preview"&&t.jsx(H,{variant:"ghost",size:"sm",onClick:()=>{ne()},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Save diagram",children:ee?t.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):t.jsx(F,{name:"save-3",className:"size-4"})})]}),k&&U(te==="tree"?"Switch to Text View":"Switch to Tree View",t.jsx(H,{variant:"ghost",size:"sm",onClick:q,className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:te==="tree"?"Switch to Text View":"Switch to Tree View",children:te==="tree"?t.jsx(F,{name:"code-sslash",className:"size-4"}):t.jsx(F,{name:"node-tree",className:"size-4"})})),Q&&U("Copy file contents",t.jsx(H,{variant:"ghost",size:"sm",onClick:()=>{Oe()},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:Qe?t.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):t.jsx(F,{name:"clipboard",className:"size-4"})})),le&&U(`Copy file path (${r})`,t.jsx(H,{variant:"ghost",size:"sm",onClick:()=>{Le()},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:Pe?t.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):t.jsx(F,{name:"file-copy-2",className:"size-4"})})),se&&U("Save file",t.jsx(H,{variant:"ghost",size:"sm",onClick:se,className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Save file","aria-label":"Save file",children:t.jsx(F,{name:"download",className:"size-4"})})),i?U("Exit fullscreen",t.jsx(H,{variant:"ghost",size:"sm",onClick:gt,className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Exit fullscreen","aria-label":"Exit fullscreen",children:t.jsx(F,{name:"fullscreen-exit",className:"size-4"})})):!ue&&we==="full"&&U(he?"Exit fullscreen":"Fullscreen",t.jsx(H,{variant:"ghost",size:"sm",onClick:Ie,className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:he?"Exit fullscreen":"Fullscreen","aria-label":he?"Exit fullscreen":"Fullscreen",children:he?t.jsx(F,{name:"fullscreen-exit",className:"size-4"}):t.jsx(F,{name:"fullscreen",className:"size-4"})}))]})},gc=({open:e,onOpenChange:r,isSaving:s,onSaveAndContinue:i,onDiscardAndContinue:o})=>t.jsx(ds,{open:e,onOpenChange:r,children:t.jsxs(fs,{showCloseButton:!1,className:"max-w-md",children:[t.jsxs(ms,{children:[t.jsx(ps,{children:"Unsaved changes"}),t.jsx(hs,{children:"Save your edits before continuing?"})]}),t.jsxs(gs,{children:[t.jsx(H,{variant:"outline",onClick:i,disabled:s,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"}),t.jsx(H,{variant:"destructive",onClick:o,children:"Discard"})]})]})}),ls=(e,r)=>e.startsWith(`${r}/`)?e.slice(r.length+1):e,xc=e=>e.index==="A"||e.working_dir==="?"?"git-added":e.index==="D"?"git-deleted":e.index==="M"||e.working_dir==="M"?"git-modified":null,vc=({root:e,openPaths:r,gitFiles:s})=>{const i=new Set(r),o=new Map,u=new Map,f={modified:0,added:0};for(const y of s??[]){o.has(y.path)||o.set(y.path,y);const S=+(y.index==="M"||y.working_dir==="M"),x=+(y.index==="A"||y.working_dir==="?");if(S===0&&x===0)continue;f.modified+=S,f.added+=x;const b=y.path.split("/");for(let j=1;j<b.length;j+=1){const C=b.slice(0,j).join("/");if(!C)continue;let v=u.get(C);v||(v={modified:0,added:0},u.set(C,v)),v.modified+=S,v.added+=x}}return{getFileStatus:y=>{if(i.has(y))return"open";if(o.size===0)return null;const S=ls(y,e),x=o.get(S);return x?xc(x):null},getFolderBadge:y=>{if(!s)return null;const S=ls(y,e);if(!S)return f.modified+f.added>0?{...f}:null;const x=u.get(S);return x?{...x}:null}}},bc=e=>new Set(e),yc=({root:e,isMobile:r,searchQuery:s,onSearchQueryChange:i,searchInputRef:o,searching:u,searchResults:f,selectedFile:m,onSelectFile:g,onOpenDialog:y,currentDirectory:S,refreshRoot:x,childrenByDir:b,loadErrorsByDir:j,expandedPaths:C,isBrowserClient:v,alwaysShowActions:P,getFileStatus:I,getFolderBadge:l,fileRowPermissions:B,downloadFile:L,contextMenuPath:W,setContextMenuPath:$,rightClickMenuPath:G,setRightClickMenuPath:K,toggleDirectory:J,handleRevealPath:D,refreshDirectory:T})=>{const k=!!(e&&b[e]),V=e?j[e]:null,E=a.useMemo(()=>bc(C),[C]);function R(d,A){const N=b[d]??[];return N.map((O,Y)=>{const ee=O.type==="directory",ne=ee&&E.has(O.path),te=m?.path===O.path,q=Y===N.length-1;return t.jsxs("li",{className:"relative",children:[A>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),q&&t.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-background"})]}),t.jsx(Li,{node:O,root:e,isExpanded:ne,isActive:te,isMobile:r,isBrowserClient:v,alwaysShowActions:P,status:ee?void 0:I(O.path),badge:ee?l(O.path):void 0,permissions:B,downloadFile:L,contextMenuPath:W,setContextMenuPath:$,rightClickMenuPath:G,setRightClickMenuPath:K,onSelect:g,onToggle:J,onRevealPath:D,onOpenDialog:y}),ee&&ne&&t.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[j[O.path]?t.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:j[O.path],children:j[O.path]}),t.jsxs(H,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{T(O.path)},children:[t.jsx(F,{name:"refresh",className:"size-3.5"}),"Refresh"]})]}):null,R(O.path,A+1)]})]},O.path)})}return t.jsxs("section",{className:X("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:[t.jsx("div",{className:X("flex flex-col gap-2 py-2",r?"px-3":"px-2"),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"relative flex-1 min-w-0",children:[t.jsx(F,{name:"search",className:"pointer-events-none absolute left-2 top-2 size-4 text-muted-foreground"}),t.jsx(Rt,{ref:o,value:s,onChange:d=>i(d.target.value),placeholder:"Search files...",className:"h-8 pl-8 pr-8 typography-meta"}),s.trim().length>0&&t.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:()=>{i(""),o.current?.focus()},children:t.jsx(F,{name:"close",className:"size-4"})})]}),t.jsxs(Xe,{children:[t.jsx(Ye,{asChild:!0,children:t.jsx("span",{className:"inline-flex flex-shrink-0",children:t.jsx(H,{variant:"ghost",size:"sm",onClick:()=>y("createFile",{path:S,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:"New File","aria-label":"New File",children:t.jsx(F,{name:"file-add",className:"size-4"})})})}),t.jsx(Ze,{side:"bottom",sideOffset:6,children:"New File"})]}),t.jsxs(Xe,{children:[t.jsx(Ye,{asChild:!0,children:t.jsx("span",{className:"inline-flex flex-shrink-0",children:t.jsx(H,{variant:"ghost",size:"sm",onClick:()=>y("createFolder",{path:S,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:"New Folder","aria-label":"New Folder",children:t.jsx(F,{name:"folder-add",className:"size-4"})})})}),t.jsx(Ze,{side:"bottom",sideOffset:6,children:"New Folder"})]}),t.jsxs(Xe,{children:[t.jsx(Ye,{asChild:!0,children:t.jsx("span",{className:"inline-flex flex-shrink-0",children:t.jsx(H,{variant:"ghost",size:"sm",onClick:()=>{x()},className:"size-8 p-0 flex-shrink-0",title:"Refresh","aria-label":"Refresh",children:t.jsx(F,{name:"refresh",className:"size-4"})})})}),t.jsx(Ze,{side:"bottom",sideOffset:6,children:"Refresh"})]})]})}),t.jsx(xs,{outerClassName:"flex-1 min-h-0",className:X("py-2",r?"px-3":"px-2"),children:t.jsx("ul",{className:"flex flex-col",children:u?t.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[t.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),"Searching..."]}):f.length>0?f.map(d=>{const A=m?.path===d.path;return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>{g(d)},className:X("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",A?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[t.jsx(Ds,{filePath:d.path,extension:d.extension}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},title:d.path,children:d.relativePath??d.path})]})},d.path)}):V?t.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[t.jsx("span",{className:"text-[var(--status-error)]",children:V}),t.jsxs(H,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{x()},children:[t.jsx(F,{name:"refresh",className:"size-3.5"}),"Refresh"]})]}):k?R(e,0):t.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:"Loading..."})})})]})},Tu=({mode:e="full",chrome:r="desktop",onClose:s,isVisible:i=!0})=>{const{files:o,runtime:u}=So(),f=r==="mobile",{currentTheme:m,availableThemes:g,lightThemeId:y,darkThemeId:S}=Ro(),{isMobile:x,isTablet:b,screenWidth:j}=Fo(),C=xo(u.platform),v=x||b,P=vo(),I=Eo()??"",l=oe(I.trim()),B=lc(r,e),L=e!=="editor-only",W=e==="editor-only"&&!x,$=zo(I),[G,K]=a.useState(""),J=a.useRef(null),[D,T]=a.useState(!1),[k,V]=a.useState(l),[E,R]=a.useState(!1),[d,A]=a.useState(!0),[N,O]=a.useState(!1),[Y,ee]=a.useState(!1),[ne,te]=a.useState(!1),q=a.useRef(null);a.useEffect(()=>{f&&(V(l),K(""),T(!1))},[f,l]);const Q=a.useRef(0),Qe=a.useCallback(n=>{Q.current=Math.max(0,Q.current+(n?1:-1))},[]),Oe=a.useCallback(n=>n instanceof Element?n.closest('[data-slot="dropdown-menu-content"], [data-slot="dropdown-menu-item"]')!==null:!1,[]);a.useEffect(()=>{if(!ne)return;const n=h=>{Q.current>0||Oe(h.target)||q.current&&!q.current.contains(h.target)&&te(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[Oe,ne]);const le=a.useMemo(()=>g.find(n=>n.metadata.id===y)??Nn(!1),[g,y]),Pe=a.useMemo(()=>g.find(n=>n.metadata.id===S)??Nn(!0),[g,S]);a.useEffect(()=>{An(le),An(Pe)},[le,Pe]);const Le=a.useMemo(()=>[],[]),se=Re(n=>l?n.byRoot[l]?.openPaths??Le:Le),ue=Re(n=>l?n.byRoot[l]?.selectedPath??null:null),we=Re(n=>l?n.byRoot[l]?.expandedPaths??Le:Le),he=Re(n=>n.removeOpenPath),Ie=Re(n=>n.removeOpenPathsByPrefix),gt=Re(n=>n.removeExpandedPathsByPrefix),Ee=Re(n=>n.setSelectedPath),_=Re(n=>n.toggleExpandedPath),U=Re(n=>n.expandPaths),{childrenByDir:ae,loadErrorsByDir:ge,isLoaded:de,loadDirectory:ot,refreshDirectory:Ft,refreshRoot:As}=dc({files:o,root:l,activeDirectory:f?k:void 0,expandedPaths:we,chrome:r,showGitignored:P,removeExpandedPathsByPrefix:gt,enabled:B,visible:i}),qe=a.useCallback(n=>{const h=oe(n),z=h.split("/"),M=z[z.length-1]||h,re=M.includes(".")?M.split(".").pop()?.toLowerCase():void 0;return{name:M,path:h,type:"file",extension:re}},[]),Et=a.useMemo(()=>se.map(qe),[se,qe]),rr=a.useMemo(()=>{if(ue){const n=Xt(ue);if(se.some(h=>Xt(h)===n))return ue}return se[0]??null},[se,ue]),p=a.useMemo(()=>rr?qe(rr):null,[rr,qe]),Ve=p?.path??"";a.useEffect(()=>{if(!l||!ue)return;const n=Xt(ue);se.some(z=>Xt(z)===n)||Ee(l,se[0]??null)},[se,l,ue,Ee]);const zt=!!(l&&Ve&&!kr(Ve,l)),Pr=zt?En(Ve):void 0,ce=a.useMemo(()=>({allowOutsideWorkspace:e==="editor-only"&&zt,outsideFileGrant:Pr,directory:l||void 0}),[e,zt,Pr,l]),nr=a.useRef(null),[Os,Ps]=a.useState({left:!1,right:!1}),Lr=a.useCallback(()=>{const n=nr.current;n&&Ps({left:n.scrollLeft>2,right:n.scrollLeft+n.clientWidth<n.scrollWidth-2})},[]),Ir=a.useRef(Lr);Ir.current=Lr,a.useEffect(()=>{const n=nr.current;if(!n)return;const h=()=>Ir.current();h(),n.addEventListener("scroll",h,{passive:!0});const z=new ResizeObserver(h);return z.observe(n),()=>{n.removeEventListener("scroll",h),z.disconnect()}},[Et.length]);const[ke,Be]=a.useState(""),[sr,it]=a.useState(!1),[Br,xe]=a.useState(null),[Ls,Ge]=a.useState(""),ve=a.useRef(""),[et,je]=a.useState(null),[ct,Ce]=a.useState(void 0),[$r,Ne]=a.useState(null),be=Re(n=>n.activeRuntimeKey),[fe,$e]=a.useState(null),[ar,Vr]=a.useState(!1),[Is,ze]=a.useState(!1),[lt,Se]=a.useState(""),[Bs,$s]=a.useState(`
4
4
  `),Wr=a.useRef(null),Me=a.useRef(0),ut=a.useRef(null),[_r,or]=a.useState(!1),Mt=Fe(n=>n.autoSaveEnabled),Vs=Fe(n=>n.setAutoSaveEnabled),Ws=a.useRef(null),[_s,Ks]=a.useState(null),[qs,Gs]=a.useState(null),{value:Us,show:Hs}=zn(!1,1200),{value:Js,show:Xs}=zn(!1,1200),[Ys,Zs]=a.useState(!1),xt=a.useCallback(()=>{l&&Ee(l,null),Be(""),xe(null),Ge(""),je(null),Ce(void 0),Ne(null),$e(null),ze(!1),x&&T(!1)},[x,l,Ee]),{operation:Qs,target:ea,inputValue:ta,setInputValue:ra,submitting:na,inputRef:sa,open:aa,close:oa,submit:ia,capabilities:{canCreateFile:Kr,canCreateFolder:qr,canRename:Gr,canDelete:Ur}}=oi({files:o,root:l,selectedPath:p?.path??"",refreshDirectory:Ft,removeOpenPathsByPrefix:Ie,clearSelectedPath:xt}),Hr=!!o.revealPath,ca=Jt(n=>n.availableApps),la=Jt(n=>n.isCacheStale),Jr=Jt(n=>n.initialize),ua=Jt(n=>n.loadInstalledApps);a.useEffect(()=>{Jr()},[Jr]);const da=a.useCallback(n=>{o.revealPath&&o.revealPath(n).catch(()=>{me.error("Failed to reveal path")})},[o]),fa=a.useCallback(async n=>{if(!p?.path||await bo(p.path,n.id,n.appName)||await Sn(p.path,n.appName))return;const M=ii(p.path)||l;M&&await Sn(M,n.appName)||me.error(`Failed to open in ${n.appName}`)},[l,p?.path]),ma=Fe(n=>n.fileEditorKeymap),Xr=Fe(n=>n.expandedEditorToolbar);a.useEffect(()=>{Se("")},[p?.path]);const Yr=a.useRef("");a.useEffect(()=>{!l||Yr.current===l||(Yr.current=l,Be(""),xe(null),Ge(""),je(null),Ce(void 0),Ne(null),$e(null),ze(!1),T(!1))},[l]);const Zr=a.useRef(be);a.useEffect(()=>{Zr.current!==be&&(Zr.current=be,Me.current+=1,ut.current=null,Be(""),Se(""),xe(null),it(!1),Ge(""),je(null),Ce(void 0),Ne(null),$e(null),ze(!1),or(!1))},[be]);const pa=f?k:I,{results:Qr,searching:en}=ci({directory:pa,query:G,chrome:r,showGitignored:P}),Tt=a.useCallback(async(n,h)=>{if(o.readFile){const Ae=await o.readFile(n,{...h??{},directory:l||void 0});return{content:Ae.content??"",revision:Ae.revision,exists:Ae.exists}}const z=new URLSearchParams({path:n});h?.allowOutsideWorkspace&&z.set("allowOutsideWorkspace","true"),h?.outsideFileGrant&&z.set("outsideFileGrant",h.outsideFileGrant),h?.optional&&z.set("optional","true"),l&&z.set("directory",l);const M=await Rn(`/api/fs/read?${z.toString()}`,{cache:h?.optional?"no-store":"default"});if(!M.ok){const Ae=await M.json().catch(()=>({error:M.statusText}));throw new Error(Ae.error||"Failed to read file")}const re=await M.text(),Z=M.headers?.get?.("x-pichamber-file-revision"),De=M.headers?.get?.("x-pichamber-file-exists")!=="false";return{content:re,revision:typeof Z=="string"&&Z.length>0?Z:De?void 0:null,exists:De}},[o,l]),dt=a.useCallback(async(n,h)=>{if(o.statFile){const z=await o.statFile(n,{...h??{},directory:l||void 0});return{path:z.path,size:z.size,mtimeMs:z.mtimeMs,revision:z.revision}}return null},[o,l]);a.useEffect(()=>{if(!l||!o.statFile||se.length===0)return;let n=!1;const h=[...se];return Promise.all(h.map(async z=>{try{const M=await o.statFile?.(z,{directory:l||void 0});!n&&M&&!M.isFile&&Ie(l,z)}catch(M){!n&&On(M)&&Ie(l,z)}})),()=>{n=!0}},[o,se,Ie,l]);const ir=a.useMemo(()=>ke.length>Nt?`${ke.slice(0,Nt)}