@hienlh/ppm 0.22.0 → 0.22.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/CLAUDE.md +1 -1
  3. package/assets/skills/ppm/SKILL.md +1 -1
  4. package/assets/skills/ppm/references/cli-reference.md +4 -4
  5. package/assets/skills/ppm/references/http-api.md +1 -1
  6. package/dist/web/assets/accounts-settings-section-CLEAA_Jc.js +1 -0
  7. package/dist/web/assets/{ai-resource-editor-CdDpOwjh.js → ai-resource-editor-C4ecid2g.js} +1 -1
  8. package/dist/web/assets/ai-settings-section-BOwGdiyH.js +1 -0
  9. package/dist/web/assets/ai-settings-section-Cqz13gRt.js +1 -0
  10. package/dist/web/assets/{api-client-C1ZwRL4Y.js → api-client-Jn3njtNw.js} +1 -1
  11. package/dist/web/assets/api-client-rSFnnCj4.js +1 -0
  12. package/dist/web/assets/{api-settings-_7Q-ULxp.js → api-settings-BxijvPBR.js} +1 -1
  13. package/dist/web/assets/{api-themes-DRAERo4Q.js → api-themes-CSUarkzD.js} +1 -1
  14. package/dist/web/assets/{appearance-settings-section-DLoPK0LD.js → appearance-settings-section-DbA8L-Vz.js} +1 -1
  15. package/dist/web/assets/{audio-preview-DsYvgKqj.js → audio-preview-CxJd8wRV.js} +1 -1
  16. package/dist/web/assets/{branch-review-tab-G84Ojzae.js → branch-review-tab-CMTa2uSR.js} +1 -1
  17. package/dist/web/assets/chat-tab-BpdgqjSL.js +15 -0
  18. package/dist/web/assets/{code-editor-D04iUPsZ.js → code-editor-B7y7-5KE.js} +4 -4
  19. package/dist/web/assets/{codex-daily-guard-BSccLRGT.js → codex-daily-guard-ChDPiXDx.js} +1 -1
  20. package/dist/web/assets/{conflict-editor-C4ay676e.js → conflict-editor-Axs9Ad7A.js} +3 -3
  21. package/dist/web/assets/{csv-preview-DbwEmG7o.js → csv-preview-DTUAW2HW.js} +1 -1
  22. package/dist/web/assets/{database-viewer-S6LsALjX.js → database-viewer-qXDiWeXj.js} +1 -1
  23. package/dist/web/assets/{diff-viewer-3oBA7vgQ.js → diff-viewer-BtLiSpqe.js} +1 -1
  24. package/dist/web/assets/{docx-preview-CXuk-emm.js → docx-preview-Dxvy6h13.js} +1 -1
  25. package/dist/web/assets/{editor-language-service-DJmaKVY0.js → editor-language-service-D75GuLXP.js} +1 -1
  26. package/dist/web/assets/{explorer-body-BQ0jyAGv.js → explorer-body-xg1-MhlW.js} +2 -2
  27. package/dist/web/assets/{explorer-window-content-jdkWt34J.js → explorer-window-content-BeQocW3i.js} +1 -1
  28. package/dist/web/assets/extension-manager-section-Bm2v3P-n.js +1 -0
  29. package/dist/web/assets/{extension-webview-BGSDUbdK.js → extension-webview-CzxrAHyL.js} +1 -1
  30. package/dist/web/assets/{file-icons-BXdvggK2.js → file-icons-wS-OmEVu.js} +1 -1
  31. package/dist/web/assets/{file-store-ojgMXgAw.js → file-store-Ds3qJ4hC.js} +1 -1
  32. package/dist/web/assets/{files-settings-section-Gnyd7han.js → files-settings-section-Bd-_GeZU.js} +1 -1
  33. package/dist/web/assets/{format-file-meta-C77h04cZ.js → format-file-meta-PPi3ptkm.js} +1 -1
  34. package/dist/web/assets/{general-settings-section-V6Khh15V.js → general-settings-section-CfNPHQUk.js} +1 -1
  35. package/dist/web/assets/{git-log-panel-Bi513qjT.js → git-log-panel-CtGxPzH6.js} +1 -1
  36. package/dist/web/assets/{git-repo-store-88Z8v-pF.js → git-repo-store-BCEPfUGT.js} +1 -1
  37. package/dist/web/assets/{glide-data-grid-DnQwYSmQ.js → glide-data-grid-iSo2vP0q.js} +1 -1
  38. package/dist/web/assets/{group-chat-tab-DpczdwyV.js → group-chat-tab-D1lx0zz-.js} +1 -1
  39. package/dist/web/assets/{image-preview-CzCc4_Do.js → image-preview-DeGD0HJu.js} +1 -1
  40. package/dist/web/assets/index-CN0G8uYY.js +52 -0
  41. package/dist/web/assets/{jira-watcher-section-f2HUbGDY.js → jira-watcher-section-kyifZPTv.js} +1 -1
  42. package/dist/web/assets/keybindings-store-L5vV8DEJ.js +1 -0
  43. package/dist/web/assets/{keyboard-shortcuts-section-BpvVEw_Y.js → keyboard-shortcuts-section-D2uJq4x9.js} +1 -1
  44. package/dist/web/assets/markdown-renderer-BX1Q00sC.js +3 -0
  45. package/dist/web/assets/markdown-renderer-CLUux0vA.js +1 -0
  46. package/dist/web/assets/{media-url-yfqHpPz0.js → media-url-DKK0YHxL.js} +1 -1
  47. package/dist/web/assets/{mobile-explorer-sheet-Bol3XAO1.js → mobile-explorer-sheet-BHQDzpwK.js} +1 -1
  48. package/dist/web/assets/notification-store-BHgSy-ci.js +1 -0
  49. package/dist/web/assets/panel-store-D20Zuf3i.js +1 -0
  50. package/dist/web/assets/{pdf-preview-CmBI6E7d.js → pdf-preview-DAcfhfGm.js} +1 -1
  51. package/dist/web/assets/{postgres-viewer-8ZAqEALv.js → postgres-viewer-DPRsmgP5.js} +1 -1
  52. package/dist/web/assets/{ppmbot-settings-section-DKJUA3Kq.js → ppmbot-settings-section-B5N1jHgm.js} +1 -1
  53. package/dist/web/assets/{problems-panel-CFcoUx8h.js → problems-panel-D_wZ4_Qg.js} +1 -1
  54. package/dist/web/assets/{process-table-EKr2dqG6.js → process-table-DahflyQn.js} +1 -1
  55. package/dist/web/assets/{project-framework-store-B70Q3dNM.js → project-framework-store-ViZgce6y.js} +1 -1
  56. package/dist/web/assets/{project-store-B87hLRSk.js → project-store-hNvwfqX3.js} +1 -1
  57. package/dist/web/assets/{proxy-settings-section-B7qRVl8w.js → proxy-settings-section-CLg_nlxn.js} +1 -1
  58. package/dist/web/assets/{query-audit-section-By6qyqdB.js → query-audit-section-BrfSo0s_.js} +1 -1
  59. package/dist/web/assets/{remote-desktop-clipboard-notice-0WDYsyCA.js → remote-desktop-clipboard-notice-Fi6cieGM.js} +1 -1
  60. package/dist/web/assets/{remote-desktop-mobile-sheet-COYDg16H.js → remote-desktop-mobile-sheet-lLZ-oK73.js} +2 -2
  61. package/dist/web/assets/{remote-desktop-mobile-view-2DqSuS2U.js → remote-desktop-mobile-view-j3v-4rYa.js} +1 -1
  62. package/dist/web/assets/{remote-desktop-readiness-gate-Dm_qMJMH.js → remote-desktop-readiness-gate-CeLvcX_w.js} +1 -1
  63. package/dist/web/assets/{remote-desktop-window-content-UodhsF7W.js → remote-desktop-window-content-lwbkLsTC.js} +1 -1
  64. package/dist/web/assets/{run-in-terminal-CdefEe_R.js → run-in-terminal-D7W4IKb9.js} +1 -1
  65. package/dist/web/assets/{schedules-settings-section-bG2lYfGv.js → schedules-settings-section-C8OS0o80.js} +1 -1
  66. package/dist/web/assets/{send-to-chat-F207yH3u.js → send-to-chat-DNKhmHbi.js} +1 -1
  67. package/dist/web/assets/{settings-body-C06bFarv.js → settings-body-DgN22Z0W.js} +2 -2
  68. package/dist/web/assets/{settings-store-krC6bc79.js → settings-store-CsVSVgLp.js} +2 -2
  69. package/dist/web/assets/{settings-tab-34RSaASd.js → settings-tab-ChOs94iB.js} +1 -1
  70. package/dist/web/assets/{settings-window-content-Dr_2lmHH.js → settings-window-content-BnKMmg2a.js} +1 -1
  71. package/dist/web/assets/{sql-query-editor-BgRH0cHD.js → sql-query-editor-BJZIIQsm.js} +1 -1
  72. package/dist/web/assets/{sqlite-viewer-DUxGslpa.js → sqlite-viewer--cMeCZum.js} +1 -1
  73. package/dist/web/assets/{system-monitor-body-IZuLn7Qh.js → system-monitor-body-CXiIrn0N.js} +2 -2
  74. package/dist/web/assets/system-monitor-tab-BJKrTSl0.js +1 -0
  75. package/dist/web/assets/{system-monitor-window-content-CEaFISgj.js → system-monitor-window-content-Dy9fZJE3.js} +1 -1
  76. package/dist/web/assets/{tab-host-window-content-D0TN8Wrq.js → tab-host-window-content-BezqrAwC.js} +1 -1
  77. package/dist/web/assets/{tab-store-OJa1GPCq.js → tab-store-krAuHQ6_.js} +1 -1
  78. package/dist/web/assets/{team-member-sheet-DDPNcCjd.js → team-member-sheet-CVM2QC3H.js} +2 -2
  79. package/dist/web/assets/{team-member-window-content-DCiW_1-E.js → team-member-window-content-D4RYKplm.js} +1 -1
  80. package/dist/web/assets/{terminal-tab-4ypP0NDY.js → terminal-tab-jikhQLct.js} +3 -3
  81. package/dist/web/assets/{tool-cards-Dd6E7Q3k.js → tool-cards-D5jCQvqn.js} +2 -2
  82. package/dist/web/assets/{use-blob-url-CPtCcY3i.js → use-blob-url-DMGlPCQD.js} +1 -1
  83. package/dist/web/assets/{use-inline-blame-vrfFHuaR.js → use-inline-blame-BF8Y1KfV.js} +3 -3
  84. package/dist/web/assets/{use-lsp-CsuZu49X.js → use-lsp-Bx4oVtlk.js} +1 -1
  85. package/dist/web/assets/{use-monaco-theme-BIVYJBIn.js → use-monaco-theme-DHczXLMb.js} +1 -1
  86. package/dist/web/assets/{use-websocket-BMbufhX7.js → use-websocket-BWZkbleJ.js} +1 -1
  87. package/dist/web/assets/{video-preview-Byj8P_jA.js → video-preview-D191TvX9.js} +1 -1
  88. package/dist/web/assets/{window-pip-registry-yD6esSju.js → window-pip-registry-D1oXq-Dq.js} +1 -1
  89. package/dist/web/assets/ws-auth-BG-cdrQ8.js +1 -0
  90. package/dist/web/index.html +13 -13
  91. package/dist/web/sw.js +1 -1
  92. package/docs/architecture/ai-chat-and-providers.md +9 -0
  93. package/docs/architecture/workspace-and-ui.md +13 -0
  94. package/package.json +1 -1
  95. package/packages/ext-git-graph/src/webview-html.test.ts +30 -5
  96. package/packages/ext-git-graph/src/webview-html.ts +99 -31
  97. package/src/cli/commands/init.ts +1 -0
  98. package/src/providers/codex-app-server/codex-history.ts +26 -7
  99. package/src/providers/codex-app-server/codex-provider.ts +6 -4
  100. package/src/server/routes/chat.ts +1 -1
  101. package/src/server/routes/settings.ts +11 -5
  102. package/src/services/config.service.ts +2 -0
  103. package/src/services/edge-forwarder.ts +191 -191
  104. package/src/services/windows-process-tree.ts +351 -351
  105. package/src/shared/codex-daily-guard.ts +12 -5
  106. package/src/types/chat.ts +1 -1
  107. package/src/types/config.ts +12 -1
  108. package/src/web/components/chat/chat-tab.tsx +162 -38
  109. package/src/web/components/chat/message-input.tsx +24 -0
  110. package/src/web/components/chat/model-thinking-selector.tsx +25 -5
  111. package/src/web/components/chat/new-chat-provider-gate.tsx +68 -0
  112. package/src/web/components/extensions/extension-tree-view.tsx +4 -11
  113. package/src/web/components/layout/command-palette.tsx +2 -18
  114. package/src/web/components/layout/editor-panel.tsx +1 -1
  115. package/src/web/components/layout/reparenting-tab.tsx +4 -2
  116. package/src/web/components/layout/tab-bar.tsx +1 -1
  117. package/src/web/components/settings/accounts/account-card.tsx +2 -2
  118. package/src/web/components/settings/accounts/codex-accounts-section.tsx +4 -4
  119. package/src/web/components/settings/ai-settings-section.tsx +36 -0
  120. package/src/web/components/settings/extension-manager-section.tsx +8 -1
  121. package/src/web/hooks/use-draft.ts +25 -4
  122. package/src/web/hooks/use-usage.ts +6 -4
  123. package/src/web/lib/api-client.ts +7 -1
  124. package/src/web/lib/api-settings.ts +1 -0
  125. package/src/web/lib/extension-icons.ts +70 -0
  126. package/src/web/lib/new-chat-provider.ts +8 -0
  127. package/src/web/lib/tab-type-icons.ts +14 -0
  128. package/src/web/stores/panel-store.ts +46 -3
  129. package/dist/web/assets/accounts-settings-section-BVr9-FZJ.js +0 -1
  130. package/dist/web/assets/ai-settings-section-B1hQyjAd.js +0 -1
  131. package/dist/web/assets/ai-settings-section-X2UOfSaS.js +0 -1
  132. package/dist/web/assets/api-client-pQL53cDQ.js +0 -1
  133. package/dist/web/assets/chat-tab-DQJfjm8E.js +0 -15
  134. package/dist/web/assets/extension-manager-section-DG1guILi.js +0 -1
  135. package/dist/web/assets/index-DU68xk06.js +0 -52
  136. package/dist/web/assets/keybindings-store-DCRsnKg5.js +0 -1
  137. package/dist/web/assets/markdown-renderer-Bcaf9_bA.js +0 -1
  138. package/dist/web/assets/markdown-renderer-DGJp8HC3.js +0 -3
  139. package/dist/web/assets/notification-store-BXt54VIn.js +0 -1
  140. package/dist/web/assets/panel-store-CboGJAwh.js +0 -1
  141. package/dist/web/assets/system-monitor-tab-DiSA490Z.js +0 -1
  142. package/dist/web/assets/ws-auth-CEYVQ8NH.js +0 -1
  143. package/packages/vscode-compat/node_modules/.bin/tsc.bunx +0 -0
  144. package/packages/vscode-compat/node_modules/.bin/tsc.exe +0 -0
  145. package/packages/vscode-compat/node_modules/.bin/tsserver.bunx +0 -0
  146. package/packages/vscode-compat/node_modules/.bin/tsserver.exe +0 -0
  147. package/src/web/hooks/use-delayed-flag.ts +0 -35
@@ -1,2 +1,2 @@
1
- import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{C as t,S as n}from"./vendor-markdown-CuWCHIVb.js";import{$t as r,Ar as i,At as a,Br as o,N as s,O as c,On as l,Ot as u,Qn as d,Un as f,Ut as p,Vn as m,Vt as h,d as g,in as _,ir as v,j as y,kr as b,l as x,lt as S,mt as C,nr as ee,nt as te,p as ne,q as re,qn as ie,qt as ae,r as oe,st as se,tt as ce,u as le,ut as ue,w as de,wr as fe,zt as w}from"./icons-DQjqk0lJ.js";import{t as pe}from"./createLucideIcon-DoiEKeJ_.js";import{r as me,s as T}from"./api-client-C1ZwRL4Y.js";import{t as he}from"./react-Bghu0NUO.js";import{n as E}from"./utils-Bmf_8h7Y.js";import{t as ge}from"./window-store-UC1jJeLM.js";import{t as _e}from"./tab-store-OJa1GPCq.js";import{o as ve}from"./file-store-ojgMXgAw.js";import{n as D}from"./use-is-mobile-TkcwP1Gx.js";import{a as ye,l as be,n as xe,o as Se,p as Ce,r as we,s as Te,t as Ee,u as O}from"./format-file-meta-C77h04cZ.js";import{t as De}from"./file-icons-BXdvggK2.js";import{i as Oe,n as ke,o as Ae,r as k,t as je}from"./mobile-bottom-sheet-C3TniEP-.js";import{At as Me,Ct as Ne,Dt as A,Ft as Pe,Gt as Fe,Ht as Ie,It as j,Kt as Le,Lt as Re,Mt as M,Nt as ze,Ot as Be,Pt as Ve,Qt as He,St as Ue,Ut as We,Vt as Ge,Wt as Ke,Xt as qe,_t as Je,at as Ye,bt as Xe,ct as Ze,dt as Qe,g as $e,gt as et,ht as tt,it as N,jt as nt,kt as P,lt as rt,ot as it,pt as F,st as at,ut as I,vt as L,wt as R,xt as ot,yt as st,zt as ct}from"./index-DU68xk06.js";import{a as z,o as B,s as lt}from"./can-open-in-ppm-cv5--yHX.js";var ut=pe(`network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),dt=`ppm-explorer-pins`,ft=50;function pt(){try{let e=localStorage.getItem(dt),t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(e=>!!e&&typeof e.path==`string`&&typeof e.name==`string`).slice(0,ft):[]}catch{return[]}}function mt(e){try{localStorage.setItem(dt,JSON.stringify(e))}catch{}}var V=he((e,t)=>({pins:pt(),isPinned:e=>t().pins.some(t=>t.path===e),pin:n=>{if(t().isPinned(n.path))return;let r=[...t().pins,n].slice(0,ft);mt(r),e({pins:r})},unpin:n=>{let r=t().pins.filter(e=>e.path!==n);mt(r),e({pins:r})}}));function ht(e){return z(e.name)?(_e.getState().openTab({type:lt(e.name)===`sqlite`?`sqlite`:`editor`,title:e.name,projectId:null,metadata:{filePath:e.path},closable:!0}),!0):!1}function gt(e){return ge.getState().open(`explorer`,{path:e})}async function _t(e){let t=e.filter(e=>e.type===`file`),n=e.length-t.length;n>0&&T.warning(n===1?`Folders cannot be downloaded`:`${n} folders skipped`);for(let e of t)try{Ce(await O.downloadUrl(e.path),e.name)}catch(t){T.error(`Download failed: ${e.name}`,{description:t instanceof Error?t.message:void 0})}}async function vt(e,t){e.length!==0&&(await He(e.join(`
2
- `)),T.success(e.length===1?`${t} copied`:`${e.length} ${t.toLowerCase()}s copied`))}var yt=/[<>:"|?*]/,bt=/[\u0000-\u001f]/,xt=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function St(e,t){if(!e)return`Name cannot be empty`;if(e===`.`||e===`..`)return`Reserved name`;if(e.includes(`/`)||e.includes(`\\`))return`Name cannot contain path separators`;if(bt.test(e))return`Invalid character in name`;if(t===`win32`){if(yt.test(e))return`Cannot contain < > : " | ? *`;if(xt.test(e))return`"${e}" is a reserved Windows name`;if(e.endsWith(`.`)||e.endsWith(` `))return`Cannot end with a dot or space`}return null}async function Ct(e,t,n,r){let i=Te(e,t,r);try{return n===`folder`?await O.mkdir(i,!1):await O.touch(i),Ue(e),!0}catch(e){return T.error(n===`folder`?`Could not create folder`:`Could not create file`,{description:xe(e)}),!1}}async function wt(e,t,n){try{return await O.rename(e,t),Ue(Ee(e,n)),!0}catch(e){return T.error(`Rename failed`,{description:xe(e)}),!1}}async function Tt(e,t,n){let r={removed:0,needsPermanent:[]},i=new Set;for(let a of e){i.add(Ee(a,n));try{await O.remove(a,t),r.removed++}catch(e){if(e instanceof be&&e.code===`NO_TRASH`){r.needsPermanent.push(a);continue}T.error(`Delete failed`,{description:xe(e)})}}if(Ue(...i),r.removed>0){let e=`${r.removed} item${r.removed===1?``:`s`}`;T.success(t?`Deleted ${e}`:`Moved ${e} to Trash`)}return r}function Et(e,t){let n=e?Array.from({length:e.length},(t,n)=>e.item(n)).filter(e=>e!=null):[];return t(),n}var H=e(t(),1),U=n();function Dt(e){let t=(0,H.useRef)(null),n=(0,H.useRef)(null),r=typeof document<`u`&&`webkitdirectory`in document.createElement(`input`),i=t=>{let n=Et(t.target.files,()=>{t.target.value=``});n.length!==0&&e(n.map(e=>({file:e,relativePath:e.webkitRelativePath||e.name})))};return{supportsFolderPicker:r,openFilePicker:()=>t.current?.click(),openFolderPicker:()=>n.current?.click(),inputs:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`input`,{ref:t,type:`file`,multiple:!0,hidden:!0,onChange:i,"data-testid":`explorer-upload-file-input`}),r&&(0,U.jsx)(`input`,{ref:n,webkitdirectory:``,type:`file`,multiple:!0,hidden:!0,onChange:i,"data-testid":`explorer-upload-folder-input`})]})}}function Ot(e,t){let n=(0,H.useCallback)((t,n)=>rt(t,n,e.sep,e),[e]),r=Dt(e=>void n(e,t()));return{uploadInto:n,openUploadPicker:r.openFilePicker,openUploadFolderPicker:r.openFolderPicker,supportsFolderUpload:r.supportsFolderPicker,uploadInputs:r.inputs}}function kt(e,t,n,r){let i=R(e=>e.patch),a=Ze(),o=at(),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(null),[d,f]=(0,H.useState)(null),p=(0,H.useRef)(t);p.current=t;let m=(0,H.useRef)(a);m.current=a;let h=(0,H.useRef)(o);h.current=o;let g=(0,H.useMemo)(()=>({get sep(){return p.current?.sep??`/`},resolve:e=>m.current.resolve(e),startBatch:()=>m.current.startBatch(),endBatch:()=>m.current.endBatch(),confirmPermanentOverwrite:e=>h.current.confirm(e)}),[]),_=()=>p.current?.path??``,v=Ot(g,_),y=(0,H.useMemo)(()=>({openEntry:e=>{e.type===`directory`?n.go(e.path):ht(e)},openInNewWindow:e=>{gt(e.type===`directory`?e.path:p.current?.path??e.path)},openInTerminal:e=>{Qe(e?.type===`directory`?e.path:_())},cut:e=>Xe(e.map(e=>e.path),`cut`),copy:e=>Xe(e.map(e=>e.path),`copy`),paste:e=>void st(e??_(),g),transferInto:async(e,t,n)=>{let r=await ot(e,t,n,g);if(r.succeeded>0){let e=n===`copy`?`Copied`:`Moved`;T.success(`${e} ${r.succeeded} item${r.succeeded===1?``:`s`}`)}},uploadInto:v.uploadInto,openUploadPicker:v.openUploadPicker,openUploadFolderPicker:v.openUploadFolderPicker,supportsFolderUpload:v.supportsFolderUpload,startRename:t=>{f(null),i(e,{inlineEdit:{kind:`rename`,path:t.path,initial:t.name}})},startCreate:t=>{f(null),i(e,{inlineEdit:{kind:t,initial:``}})},cancelInline:()=>{f(null),i(e,{inlineEdit:null})},commitInline:async t=>{let n=p.current,a=n?.inlineEdit;if(!n||!a)return;let o=t.trim();if(a.kind===`rename`&&o===a.initial){i(e,{inlineEdit:null});return}let s=St(o,r);if(s){f(s);return}f(null),(a.kind===`rename`?await wt(a.path,o,n.sep):await Ct(n.path,o,a.kind===`new-folder`?`folder`:`file`,n.sep))&&i(e,{inlineEdit:null})},trash:e=>{Tt(e.map(e=>e.path),!1,p.current?.sep??`/`).then(e=>{e.needsPermanent.length>0&&c({paths:e.needsPermanent,names:e.needsPermanent.map(e=>e.split(/[/\\]/).pop()??e)})})},confirmPermanentDelete:e=>{e.length!==0&&c({paths:e.map(e=>e.path),names:e.map(e=>e.name)})},download:e=>void _t(e),copyPath:e=>void vt(e,`Path`),copyName:e=>void vt(e,`Name`),togglePin:(e,t)=>{let n=V.getState();n.isPinned(e)?n.unpin(e):n.pin({path:e,name:t})},showProperties:e=>u(e)}),[e,i,n,g,r,v]),b=(0,H.useCallback)(()=>{let e=s;c(null),e&&Tt(e.paths,!0,p.current?.sep??`/`)},[s]);return{actions:y,dialogs:{collision:a.state,pendingDelete:s,permanentOverwrite:o.state,properties:l,inlineError:d,closeDelete:()=>c(null),runPermanentDelete:b,closeProperties:()=>u(null),uploadInputs:v.uploadInputs}}}var At=e=>(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,...e,children:(0,U.jsx)(`path`,{stroke:`#64748B`,strokeWidth:`2`,d:`M7.784 5H5a2 2 0 00-2 2v10a2 2 0 002 2h14a2 2 0 002-2V9.875a2 2 0 00-2-2h-6.284a2 2 0 01-1.27-.455L9.054 5.455A2 2 0 007.783 5z`})}),jt=e=>(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,...e,children:(0,U.jsx)(`path`,{fill:`#64748B`,stroke:`#64748B`,strokeWidth:`2`,d:`M7.784 5H5a2 2 0 00-2 2v10a2 2 0 002 2h14a2 2 0 002-2V9.875a2 2 0 00-2-2h-6.284a2 2 0 01-1.27-.455L9.054 5.455A2 2 0 007.783 5z`})}),Mt=At,Nt=jt,Pt=(0,H.createContext)({closed:Mt,open:Nt}),Ft=Pt.Provider;function W({name:e,kind:t,open:n,className:r}){let i=(0,H.useContext)(Pt),o=E(`shrink-0`,r);return t===`directory`?(0,U.jsx)(n?i.open:i.closed,{className:o}):t===`symlink`?(0,U.jsx)(a,{className:E(o,`text-text-2`)}):t===`unknown`?(0,U.jsx)(h,{className:E(o,`text-text-subtle`)}):(0,U.jsx)(De,{name:e,className:o})}function It({className:e}){return(0,U.jsx)(W,{name:``,kind:`directory`,className:E(`size-4 shrink-0`,e)})}var Lt={fixed:w,removable:i,network:ut,unknown:w};function G({label:e,path:t,active:n,icon:r,onNavigate:i,onUnpin:a,run:o,uploadRun:s}){let c=L(),l=N({targetDir:t,run:o,onFiles:s});return(0,U.jsxs)(`div`,{className:`group/place relative flex items-center`,children:[(0,U.jsxs)(`button`,{type:`button`,title:t,onClick:()=>i(t),className:E(`flex w-full items-center gap-2 rounded px-2 py-1 text-left text-[13px]`,c?`min-h-[44px]`:`min-h-0`,`can-hover:hover:bg-surface-elevated`,n?`bg-accent-wash text-text`:`text-text-2`,l.isOver&&`ring-1 ring-dashed ring-primary bg-primary/10`),...l.handlers,children:[(0,U.jsx)(r,{className:`size-4 shrink-0 text-text-subtle`}),(0,U.jsx)(`span`,{className:`truncate`,children:e})]}),a&&(0,U.jsx)(`button`,{type:`button`,"aria-label":`Unpin ${e}`,title:`Unpin`,onClick:a,className:`absolute right-1 rounded p-1 text-text-subtle can-hover:opacity-0 can-hover:group-hover/place:opacity-100 can-hover:hover:text-text`,children:(0,U.jsx)(f,{className:`size-3.5`})})]})}function K({title:e,children:t}){return(0,U.jsxs)(`div`,{className:`pb-2`,children:[(0,U.jsx)(`p`,{className:`px-2 pb-0.5 pt-2 text-[10px] font-semibold uppercase tracking-wide text-text-subtle`,children:e}),t]})}var Rt={home:`Home`,pinned:`Quick access`,known:`Folders`,drives:`Drives`};function zt({host:e,currentPath:t,onNavigate:n,vocab:r=Rt}){let i=V(e=>e.pins),a=V(e=>e.unpin),o=e=>e===t,{run:s,uploadRun:c,prompts:l}=Ye(e?.sep??`/`,e?.platform);return(0,U.jsxs)(`aside`,{"aria-label":`Places`,"data-testid":`explorer-sidebar`,className:`hidden w-44 shrink-0 overflow-y-auto border-r border-border bg-[var(--x-sidebar-bg,var(--panel-2))] px-1 py-1 sm:block`,children:[i.length>0&&(0,U.jsx)(K,{title:`Pinned`,children:i.map(e=>(0,U.jsx)(G,{label:e.name,path:e.path,icon:f,active:o(e.path),onNavigate:n,onUnpin:()=>a(e.path),run:s,uploadRun:c},e.path))}),e&&e.pinned.length>0&&(0,U.jsx)(K,{title:r.pinned,children:e.pinned.map(e=>(0,U.jsx)(G,{label:e.name,path:e.path,icon:It,active:o(e.path),onNavigate:n,run:s,uploadRun:c},e.path))}),e&&(0,U.jsxs)(K,{title:r.known,children:[(0,U.jsx)(G,{label:r.home,path:e.homedir,icon:It,active:o(e.homedir),onNavigate:n,run:s,uploadRun:c}),e.knownFolders.map(e=>(0,U.jsx)(G,{label:e.name,path:e.path,icon:It,active:o(e.path),onNavigate:n,run:s,uploadRun:c},e.path))]}),e&&e.drives.length>0&&(0,U.jsx)(K,{title:r.drives,children:e.drives.map(e=>(0,U.jsx)(G,{label:e.label?`${e.label} (${e.name})`:e.name,path:e.path,icon:Lt[e.kind],active:o(e.path),onNavigate:n,run:s,uploadRun:c},e.path))}),e?.warnings.map(e=>(0,U.jsxs)(`p`,{className:`flex gap-1.5 px-2 py-1 text-[11px] leading-snug text-text-subtle`,children:[(0,U.jsx)(oe,{className:`mt-0.5 size-3 shrink-0`}),(0,U.jsx)(`span`,{children:e})]},e)),l]})}var q=new Intl.Collator(void 0,{numeric:!0,sensitivity:`base`});function Bt(e,t,n){switch(e){case`size`:return(t.size??0)-(n.size??0);case`modified`:return new Date(t.modified).getTime()-new Date(n.modified).getTime();case`kind`:{let e=q.compare(B(t.name),B(n.name));return e===0?q.compare(t.name,n.name):e}case`name`:return q.compare(t.name,n.name)}}function Vt(e,t,n){let r=t.trim().toLowerCase(),i=r?e.filter(e=>e.name.toLowerCase().includes(r)):e,a=n.dir===`asc`?1:-1;return[...i].sort((e,t)=>{let r=e.type===`directory`;if(r!==(t.type===`directory`))return r?-1:1;let i=Bt(n.key,e,t);return(i===0?q.compare(e.name,t.name):i)*a})}function Ht(e){return e.reduce((e,t)=>e+(t.type===`file`?t.size??0:0),0)}function Ut({entries:e,selection:t,truncated:n}){let r=e.filter(e=>t.has(e.path)),i=[`${e.length}${n?`+`:``} item${e.length===1?``:`s`}`];if(r.length>0){i.push(`${r.length} selected`);let e=Ht(r);e>0&&i.push(Se(e))}return(0,U.jsxs)(`div`,{"data-testid":`explorer-status`,className:`flex shrink-0 items-center gap-2 border-t border-border bg-panel-2 px-2 py-1 text-[11px] text-text-subtle`,children:[i.join(` · `),n&&(0,U.jsx)(`span`,{className:`ml-auto`,children:`Listing capped — narrow the filter to see the rest.`})]})}var Wt=3;function Gt({crumbs:e,onNavigate:t,className:n,sep:r}){let{run:i,prompts:a}=Ye(r);if(e.length===0)return(0,U.jsx)(`div`,{className:n});let o=e.length>Wt+2,s=o?e.slice(0,1):e,c=o?e.slice(1,e.length-Wt):[],u=o?e.slice(e.length-Wt):[];return(0,U.jsxs)(`nav`,{"aria-label":`Path`,className:E(`flex min-w-0 items-center gap-0.5 text-xs`,n),children:[s.map(n=>(0,U.jsxs)(`span`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,U.jsx)(Kt,{crumb:n,last:!o&&n===e[e.length-1],onNavigate:t,run:i}),(0,U.jsx)(y,{className:`size-3 shrink-0 text-text-subtle`})]},n.path)),o&&(0,U.jsxs)(ct,{children:[(0,U.jsx)(qe,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Show hidden path segments`,className:`rounded px-1 py-0.5 text-text-2 can-hover:hover:bg-surface-elevated`,children:(0,U.jsx)(l,{className:`size-3.5`})})}),(0,U.jsx)(Ge,{align:`start`,className:`max-h-72 overflow-y-auto`,children:c.map(e=>(0,U.jsx)(Ie,{onClick:()=>t(e.path),children:e.name},e.path))})]}),o&&(0,U.jsx)(y,{className:`size-3 shrink-0 text-text-subtle`}),u.map((e,n)=>(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-0.5`,children:[(0,U.jsx)(Kt,{crumb:e,last:n===u.length-1,onNavigate:t,run:i}),n<u.length-1&&(0,U.jsx)(y,{className:`size-3 shrink-0 text-text-subtle`})]},e.path)),a]})}function Kt({crumb:e,last:t,onNavigate:n,run:r}){let i=N({targetDir:e.path,run:r});return(0,U.jsx)(`button`,{type:`button`,onClick:()=>n(e.path),className:E(`max-w-[12rem] truncate rounded px-1 py-0.5 can-hover:hover:bg-surface-elevated`,t?`font-medium text-text`:`text-text-2`,i.isOver&&`ring-1 ring-dashed ring-primary bg-primary/10`),...i.handlers,children:e.name})}var J=[{key:`name`,label:`Name`},{key:`size`,label:`Size`},{key:`modified`,label:`Modified`},{key:`kind`,label:`Kind`}],qt=[{dir:`asc`,label:`Ascending`},{dir:`desc`,label:`Descending`}];function Jt(e){return J.find(t=>t.key===e)?.label??e}function Yt(e){return qt.find(t=>t.dir===e)?.label??e}function Y(e){return E(`relative flex size-7 shrink-0 items-center justify-center rounded text-text-subtle can-hover:hover:bg-surface-elevated can-hover:hover:text-text disabled:opacity-30`,e&&`before:absolute before:-inset-2 before:content-['']`)}function Xt({coarse:e}){let t=R(e=>e.sort),n=R(e=>e.setPrefs),r=`Sort`,i=`${r}: ${Jt(t.key)}, ${Yt(t.dir)}`;return(0,U.jsxs)(ct,{children:[(0,U.jsx)(qe,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":r,title:i,className:Y(e),children:(0,U.jsx)(ne,{className:`size-4`})})}),(0,U.jsxs)(Ge,{align:`end`,children:[(0,U.jsx)(We,{children:`Sort by`}),(0,U.jsx)(Ke,{value:t.key,onValueChange:e=>n({sort:{key:e,dir:t.dir}}),children:J.map(({key:e,label:t})=>(0,U.jsx)(Fe,{value:e,children:t},e))}),(0,U.jsx)(Le,{}),(0,U.jsx)(We,{children:`Order`}),(0,U.jsx)(Ke,{value:t.dir,onValueChange:e=>n({sort:{key:t.key,dir:e}}),children:qt.map(({dir:e,label:t})=>(0,U.jsx)(Fe,{value:e,children:t},e))})]})]})}function X({targets:e,currentDir:t,hasClipboard:n,isPinned:r,actions:i}){let a=D(),o=e.length===1?e[0]:null,s=e.length>0&&e.every(e=>e.type===`directory`),c=e.length,l=c>1?` ${c} items`:``,u=R(e=>e.sort),d=R(e=>e.setPrefs);return c===0?(0,U.jsxs)(Be,{children:[(0,U.jsx)(P,{onClick:()=>i.startCreate(`new-file`),children:`New File`}),(0,U.jsx)(P,{onClick:()=>i.startCreate(`new-folder`),children:`New Folder`}),(0,U.jsx)(M,{}),(0,U.jsx)(P,{disabled:!n,onClick:()=>i.paste(),children:`Paste`}),(0,U.jsx)(M,{}),(0,U.jsx)(P,{onClick:()=>i.openUploadPicker(),children:`Upload Files…`}),i.supportsFolderUpload&&(0,U.jsx)(P,{onClick:()=>i.openUploadFolderPicker(),children:`Upload Folder…`}),(0,U.jsx)(M,{}),(0,U.jsx)(P,{onClick:()=>i.openInTerminal(),children:`Open in Terminal`}),(0,U.jsx)(M,{}),(0,U.jsxs)(ze,{children:[(0,U.jsx)(Pe,{children:`Sort by`}),(0,U.jsxs)(Ve,{children:[(0,U.jsx)(Me,{value:u.key,onValueChange:e=>d({sort:{key:e,dir:u.dir}}),children:J.map(({key:e,label:t})=>(0,U.jsx)(nt,{value:e,children:t},e))}),(0,U.jsx)(M,{}),(0,U.jsx)(Me,{value:u.dir,onValueChange:e=>d({sort:{key:u.key,dir:e}}),children:qt.map(({dir:e,label:t})=>(0,U.jsx)(nt,{value:e,children:t},e))})]})]}),(0,U.jsx)(M,{}),(0,U.jsx)(P,{onClick:()=>i.copyPath([t]),children:`Copy Path`})]}):(0,U.jsxs)(Be,{children:[o&&(o.type===`directory`||z(o.name))&&(0,U.jsx)(P,{onClick:()=>i.openEntry(o),children:`Open`}),s&&o&&!a&&(0,U.jsx)(P,{onClick:()=>i.openInNewWindow(o),children:`Open in New Window`}),s&&o&&(0,U.jsx)(P,{onClick:()=>i.openInTerminal(o),children:`Open in Terminal`}),(0,U.jsx)(M,{}),(0,U.jsxs)(P,{onClick:()=>i.cut(e),children:[`Cut`,l]}),(0,U.jsxs)(P,{onClick:()=>i.copy(e),children:[`Copy`,l]}),s&&o&&(0,U.jsx)(P,{disabled:!n,onClick:()=>i.paste(o.path),children:`Paste`}),(0,U.jsx)(M,{}),o&&(0,U.jsx)(P,{onClick:()=>i.startRename(o),children:`Rename`}),(0,U.jsxs)(P,{onClick:()=>i.trash(e),children:[`Move to Trash`,l]}),(0,U.jsx)(P,{variant:`destructive`,onClick:()=>i.confirmPermanentDelete(e),children:`Delete permanently`}),(0,U.jsx)(M,{}),(0,U.jsx)(P,{onClick:()=>i.copyPath(e.map(e=>e.path)),children:`Copy Path`}),(0,U.jsx)(P,{onClick:()=>i.copyName(e.map(e=>e.name)),children:`Copy Name`}),e.some(e=>e.type===`file`)&&(0,U.jsx)(P,{onClick:()=>i.download(e),children:`Download`}),s&&o&&(0,U.jsx)(P,{onClick:()=>i.togglePin(o.path,o.name),children:r(o.path)?`Unpin from Sidebar`:`Pin to Sidebar`}),o&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(M,{}),(0,U.jsx)(P,{onClick:()=>i.showProperties(o),children:`Properties`})]})]})}function Zt(e){let{entry:t,dragPaths:n,run:r,springLoad:i,origin:a=`explorer`,projectName:o,extraData:s,onDragStarted:c,onFiles:l}=e,u=et({paths:n,origin:a,projectName:o,extraData:s,onDragStarted:c}),d=N({targetDir:t.type===`directory`?t.path:null,run:r,springLoad:t.type===`directory`?i:void 0,onFiles:l});return{props:(0,H.useMemo)(()=>({...u,...d.handlers}),[u,d.handlers]),isDropTarget:d.isOver}}function Qt(e){return e.type===`directory`||z(e.name)?`open`:`sheet`}function $t(e){return e.startsWith(`on`)&&e.length>2&&e[2]===e[2]?.toUpperCase()}function en(e,t){return n=>{e?.(n),t?.(n)}}function tn(e,t){if(!e)return t;let n={...e};for(let[e,r]of Object.entries(t)){let t=n[e];if($t(e)&&typeof t==`function`&&typeof r==`function`){n[e]=en(t,r);continue}if(e===`style`&&t&&r){n[e]={...t,...r};continue}if(e===`className`){n[e]=E(t,r);continue}r!==void 0&&(n[e]=r)}return n}function nn({entry:e,selected:t,currentDir:n,hasClipboard:r,isPinned:i,actions:a,rowHeight:o,onSelect:s,onOpen:c}){let l=Zt({entry:e,dragPaths:[e.path],run:a.transferInto,springLoad:s,onFiles:a.uploadInto});return(0,U.jsxs)(A,{children:[(0,U.jsx)(j,{asChild:!0,children:(0,U.jsx)(rn,{entry:e,selected:t,rowHeight:o,onSelect:s,onOpen:c,dnd:l.props,dropActive:l.isDropTarget})}),(0,U.jsx)(X,{targets:[e],currentDir:n,hasClipboard:r,isPinned:i,actions:a})]})}var rn=(0,H.forwardRef)(function({entry:e,selected:t,rowHeight:n,onSelect:r,onOpen:i,dnd:a,dropActive:o,...s},c){let l=Je(r),u=D(),{setOpen:d}=(0,H.useContext)(ke),f=()=>{r(),!(!u||e.type===`directory`)&&(Qt(e)===`open`?i():d(!0))};return(0,U.jsxs)(`div`,{ref:c,...tn({...s,...l,...a},{role:`option`,"aria-selected":t,"data-testid":`explorer-column-row`,"data-path":e.path,title:e.name,style:{height:n},onContextMenu:e=>{r(),e.stopPropagation()},onClick:f,onDoubleClick:i,className:E(`flex w-full items-center gap-1.5 px-2 text-[13px] select-none`,`can-hover:hover:bg-surface-elevated`,t&&`bg-accent-wash text-text`,o&&`ring-1 ring-dashed ring-primary bg-primary/10`)}),children:[(0,U.jsx)(W,{name:e.name,kind:e.kind,className:`size-4 shrink-0`}),(0,U.jsx)(`span`,{className:E(`flex-1 truncate`,t?`text-text`:`text-text-2`),children:e.name}),e.type===`directory`&&(0,U.jsx)(`span`,{className:`text-text-subtle`,children:`›`})]})});function an({path:e,entries:t,loading:n,error:r,selectedPath:i,isFocused:a,currentDir:o,hasClipboard:s,isPinned:c,actions:l,rowHeight:u,onSelect:d,onOpen:f,onFocus:p,fullWidth:m}){let h=(0,H.useRef)(null);I(h);let g=m?48:u,_=Re({count:t.length,getScrollElement:()=>h.current,estimateSize:()=>g,overscan:8}),v=N({targetDir:e,run:l.transferInto,onFiles:l.uploadInto,disabled:m});return(0,U.jsx)(`div`,{className:E(`flex h-full shrink-0 flex-col`,!m&&`border-r border-border`,a&&`bg-panel-2/40`),style:m?void 0:{width:220},children:(0,U.jsxs)(`div`,{ref:h,role:`listbox`,"aria-label":e,className:E(`flex-1 overflow-y-auto outline-none`,v.isOver&&`ring-1 ring-dashed ring-primary bg-primary/10`),...v.handlers,children:[n&&t.length===0&&(0,U.jsx)(`p`,{className:`p-2 text-xs text-text-subtle`,children:`Loading…`}),r&&(0,U.jsx)(`p`,{className:`p-2 text-xs text-error`,children:r}),!n&&!r&&t.length===0&&(0,U.jsx)(`p`,{className:`p-2 text-xs text-text-subtle`,children:`Empty`}),(0,U.jsx)(`div`,{className:`relative w-full`,style:{height:_.getTotalSize()},children:_.getVirtualItems().map(e=>{let n=t[e.index],r=n.path===i;return(0,U.jsx)(`div`,{className:`absolute left-0 top-0 w-full`,style:{transform:`translateY(${e.start}px)`},children:(0,U.jsx)(nn,{entry:n,selected:r,currentDir:o,hasClipboard:s,isPinned:c,actions:l,rowHeight:g,onSelect:()=>{p(),d(n)},onOpen:()=>f(n)})},n.path)})})]})})}function on({containerRef:e,onKeyDown:t,backgroundLongPress:n,columns:r,focusedIndex:i,setFocusedIndex:a,selectedPathFor:o,slice:s,hasClipboard:c,isPinned:l,actions:u,onSelect:d,onOpen:f}){let p=r[i];return(0,U.jsxs)(A,{children:[(0,U.jsx)(j,{asChild:!0,children:(0,U.jsxs)(`div`,{ref:e,tabIndex:0,"data-testid":`explorer-columns`,"aria-label":`Column view`,onKeyDown:t,className:`flex h-full min-h-0 w-full flex-col outline-none`,...n,children:[i>0&&(0,U.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>e-1),"aria-label":`Back`,className:`flex h-11 shrink-0 items-center gap-1.5 border-b border-border px-3 text-sm text-text-2 active:bg-surface-elevated`,children:[(0,U.jsx)(x,{className:`size-4`}),` Back`]}),p&&(0,U.jsx)(`div`,{className:`min-h-0 flex-1 motion-safe:animate-in motion-safe:slide-in-from-right-4 motion-safe:duration-150`,children:(0,U.jsx)(an,{path:p.path,entries:p.entries,loading:p.loading,error:p.error,selectedPath:o(i),isFocused:!0,fullWidth:!0,rowHeight:48,currentDir:s.path,hasClipboard:c,isPinned:l,actions:u,onSelect:e=>d(i,e),onOpen:f,onFocus:()=>{}})},p.path)]})}),(0,U.jsx)(X,{targets:[],currentDir:s.path,hasClipboard:c,isPinned:l,actions:u})]})}var sn=0,cn=[];function ln(){return new Promise(e=>{let t=!1,n=()=>{sn++,e(()=>{if(t)return;t=!0,sn--;let e=cn.shift();e&&e()})};sn<24?n():cn.push(n)})}function un({entry:e,size:t,className:n}){let[r,i]=(0,H.useState)(null),[a,o]=(0,H.useState)(!1),s=(0,H.useRef)(null),c=(0,H.useRef)(null);return(0,H.useEffect)(()=>{i(null),o(!1)},[e.path]),(0,H.useEffect)(()=>{let t=s.current;if(!t||r||a)return;let n=new AbortController,l=null,u=new IntersectionObserver(t=>{t[0]?.isIntersecting&&(u.disconnect(),(async()=>{if(l=await ln(),n.signal.aborted){l();return}try{let t=me(),r=await fetch(`/api/fs/raw?path=${encodeURIComponent(e.path)}`,{headers:t?{Authorization:`Bearer ${t}`}:{},signal:n.signal});if(!r.ok)throw Error(String(r.status));let a=await r.blob();if(n.signal.aborted)return;let o=URL.createObjectURL(a);c.current=o,i(o)}catch{n.signal.aborted||o(!0)}finally{l?.()}})())},{rootMargin:`200px`});return u.observe(t),()=>{n.abort(),u.disconnect(),l?.()}},[e.path,r,a]),(0,H.useEffect)(()=>()=>{c.current&&URL.revokeObjectURL(c.current)},[]),a||!r?(0,U.jsx)(`div`,{ref:s,className:E(`flex items-center justify-center`,n),style:{width:t,height:t},children:(0,U.jsx)(W,{name:e.name,kind:e.kind,className:`size-1/2`})}):(0,U.jsx)(`div`,{ref:s,className:E(`flex items-center justify-center overflow-hidden`,n),style:{width:t,height:t},children:(0,U.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:`max-h-full max-w-full rounded object-contain`,onError:()=>o(!0)})})}function dn({entry:e,onOpen:t}){return e?(0,U.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col items-center gap-3 overflow-y-auto p-4 text-center`,children:[(0,U.jsx)(`div`,{className:`flex h-24 w-24 shrink-0 items-center justify-center`,children:e.type!==`directory`&&lt(e.name)===`image`?(0,U.jsx)(un,{entry:e,size:96}):(0,U.jsx)(W,{name:e.name,kind:e.kind,className:`size-16`})}),(0,U.jsx)(`p`,{className:`w-full truncate text-sm font-medium text-text`,title:e.name,children:e.name}),(0,U.jsxs)(`dl`,{className:`w-full space-y-1 text-left text-xs text-text-2`,children:[(0,U.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,U.jsx)(`dt`,{className:`text-text-subtle`,children:`Kind`}),(0,U.jsx)(`dd`,{className:`truncate`,children:e.type===`directory`?`Folder`:B(e.name)||`File`})]}),e.type!==`directory`&&(0,U.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,U.jsx)(`dt`,{className:`text-text-subtle`,children:`Size`}),(0,U.jsx)(`dd`,{children:Se(e.size)})]}),(0,U.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,U.jsx)(`dt`,{className:`text-text-subtle`,children:`Modified`}),(0,U.jsx)(`dd`,{className:`truncate`,children:we(e.modified)})]})]}),z(e.name)&&(0,U.jsx)(`button`,{type:`button`,onClick:()=>t(e),className:`mt-2 w-full rounded border border-border bg-panel-2 py-1.5 text-xs font-medium text-text can-hover:hover:bg-surface-elevated`,children:`Open`})]},e.path):(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center p-4 text-center text-xs text-text-subtle`,children:`Select a file to preview`})}function fn(e,t){switch(t.type){case`sync`:{let{paths:n,lastEntries:r,lastLoading:i,makeAbort:a}=t,o=n.length-1,s=n.map((t,n)=>{let s=e.columns[n],c=n===o;return s&&s.path===t?c?{...s,entries:r,loading:i,error:null}:s:c?{path:t,entries:r,loading:i,error:null,abort:a()}:{path:t,entries:[],loading:!0,error:null,abort:a()}}),c=[];for(let t=0;t<e.columns.length;t++){let n=e.columns[t],r=s[t];(!r||r.path!==n.path)&&c.push(n.abort)}return{columns:s,staleControllers:c}}case`loaded`:return{columns:e.columns.map(e=>e.path===t.path?{...e,entries:t.entries,loading:!1,error:null}:e),staleControllers:[]};case`error`:return{columns:e.columns.map(e=>e.path===t.path?{...e,loading:!1,error:t.message}:e),staleControllers:[]}}}function pn(e,t,n){let[r,i]=(0,H.useReducer)(fn,{columns:[],staleControllers:[]}),a=(0,H.useRef)(new Set);(0,H.useEffect)(()=>{i({type:`sync`,paths:e,lastEntries:t,lastLoading:n,makeAbort:()=>new AbortController})},[e.join(`\0`),t,n]),(0,H.useEffect)(()=>{for(let e of r.staleControllers)e.abort()},[r.staleControllers]);let o=(0,H.useRef)(r.columns);return o.current=r.columns,(0,H.useEffect)(()=>()=>{for(let e of o.current)e.abort.abort()},[]),(0,H.useEffect)(()=>{let e=r.columns.length-1;r.columns.forEach((t,n)=>{n!==e&&(!t.loading||a.current.has(t.abort)||(a.current.add(t.abort),O.browse(t.path,{signal:t.abort.signal}).then(e=>{a.current.delete(t.abort),!t.abort.signal.aborted&&i({type:`loaded`,path:t.path,entries:e.entries})}).catch(e=>{a.current.delete(t.abort),!(t.abort.signal.aborted||e instanceof DOMException&&e.name===`AbortError`)&&i({type:`error`,path:t.path,message:e instanceof Error?e.message:`Failed to read directory`})})))})},[r.columns]),{columns:r.columns}}var mn=720;function hn({slice:e,entries:t,actions:n,selection:r,hasClipboard:i,isPinned:a,nav:o,backgroundLongPress:s,rowHeight:c}){let{columns:l}=pn((0,H.useMemo)(()=>e.breadcrumbs.length>0?e.breadcrumbs.map(e=>e.path):[e.path],[e.breadcrumbs,e.path]),t,e.loading),u=D(),d=(0,H.useRef)(null);I(d);let[f,p]=(0,H.useState)(l.length-1),[m,h]=(0,H.useState)(0),g=(0,H.useRef)(l.length);(0,H.useEffect)(()=>{let e=d.current;if(!e)return;let t=()=>h(e.clientWidth);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),(0,H.useEffect)(()=>{if(l.length===g.current)return;g.current=l.length,p(l.length-1);let e=d.current;if(!e)return;let t=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches===!0;e.scrollTo({left:e.scrollWidth,behavior:t?`auto`:`smooth`})},[l.length]);let _=(0,H.useMemo)(()=>{if(!e.anchor)return null;for(let t of l){let n=t.entries.find(t=>t.path===e.anchor);if(n)return n}return null},[l,e.anchor]),v=t=>t===l.length-1?e.anchor:l[t+1]?.path??null,y=e=>{let t=l[e];if(!t)return null;let n=v(e);return t.entries.find(e=>e.path===n)??null},b=(e,t)=>{p(e),t.type===`directory`?o.go(t.path):r.selectOnly(t.path)},x=e=>n.openEntry(e),S=e=>{if(!(e.altKey||e.ctrlKey||e.metaKey)){if(e.key===`ArrowRight`&&f<l.length-1){e.preventDefault(),e.stopPropagation(),p(f+1);return}if(e.key===`ArrowLeft`&&f>0){e.preventDefault(),e.stopPropagation(),p(f-1);return}if(e.key===`ArrowUp`||e.key===`ArrowDown`){let t=l[f];if(!t)return;e.preventDefault(),e.stopPropagation();let n=y(f),r=n?t.entries.findIndex(e=>e.path===n.path):-1,i=e.key===`ArrowDown`?1:-1,a=Math.min(t.entries.length-1,Math.max(0,r<0?0:r+i)),o=t.entries[a];o&&b(f,o);return}if(e.key===`Enter`){let t=y(f);t&&(e.preventDefault(),e.stopPropagation(),x(t))}}},C=m>=mn;return u?(0,U.jsx)(on,{containerRef:d,onKeyDown:S,backgroundLongPress:s,columns:l,focusedIndex:f,setFocusedIndex:p,selectedPathFor:v,slice:e,hasClipboard:i,isPinned:a,actions:n,onSelect:b,onOpen:x}):(0,U.jsxs)(A,{children:[(0,U.jsx)(j,{asChild:!0,children:(0,U.jsxs)(`div`,{ref:d,tabIndex:0,"data-testid":`explorer-columns`,"aria-label":`Column view`,onKeyDown:S,className:`flex h-full min-h-0 w-full overflow-x-auto outline-none`,...s,children:[l.map((t,r)=>(0,U.jsx)(an,{path:t.path,entries:t.entries,loading:t.loading,error:t.error,selectedPath:v(r),isFocused:r===f,currentDir:e.path,hasClipboard:i,isPinned:a,actions:n,rowHeight:c,onSelect:e=>b(r,e),onOpen:x,onFocus:()=>p(r)},t.path)),C&&(0,U.jsx)(`div`,{className:`min-w-[240px] flex-1 border-l border-border bg-panel-2/30`,children:(0,U.jsx)(dn,{entry:_,onOpen:x})})]})}),(0,U.jsx)(X,{targets:[],currentDir:e.path,hasClipboard:i,isPinned:a,actions:n})]})}function Z(e,t){if(e.selection.size>0)return t.filter(t=>e.selection.has(t.path));let n=t.find(t=>t.path===e.anchor);return n?[n]:[]}function gn({slice:e,entries:t,actions:n,selection:r,nav:i}){return(0,H.useCallback)(a=>{if(!e)return;let o=a.target;if(o.tagName===`INPUT`||o.tagName===`TEXTAREA`||o.isContentEditable)return;let s=a.ctrlKey||a.metaKey,c=Z(e,t);if(s)switch(a.key.toLowerCase()){case`a`:a.preventDefault(),r.selectAll();return;case`c`:a.preventDefault(),n.copy(c);return;case`x`:a.preventDefault(),n.cut(c);return;case`v`:a.preventDefault(),n.paste();return;default:return}switch(a.key){case`ArrowDown`:a.preventDefault(),r.moveTo(1,a.shiftKey);return;case`ArrowUp`:a.preventDefault(),r.moveTo(-1,a.shiftKey);return;case`Home`:a.preventDefault(),t[0]&&r.selectOnly(t[0].path);return;case`End`:a.preventDefault(),t.length>0&&r.selectOnly(t[t.length-1].path);return;case`ArrowLeft`:a.altKey&&(a.preventDefault(),i.back());return;case`ArrowRight`:a.altKey&&(a.preventDefault(),i.forward());return;case`Backspace`:a.preventDefault(),i.back();return;case`Enter`:a.preventDefault(),c.length===1&&n.openEntry(c[0]);return;case`F2`:a.preventDefault(),c.length===1&&n.startRename(c[0]);return;case`Delete`:if(a.preventDefault(),c.length===0)return;a.shiftKey?n.confirmPermanentDelete(c):n.trash(c);return;case`Escape`:r.clear();return}a.key.length===1&&!a.altKey&&(a.preventDefault(),r.typeAhead(a.key))},[e,t,n,r,i])}function _n(e,t){let n=D(),r=F(e=>e.selectMode),{setOpen:i}=(0,H.useContext)(ke);return{isMobile:n,selectMode:r,handleTap:(a,o)=>n?r?(t.onRowClick(a.path,{shiftKey:!1,ctrlKey:!0,metaKey:!1}),!0):(o||t.selectOnly(a.path),Qt(a)===`open`?e.openEntry(a):i(!0),!0):!1}}function vn({initial:e,error:t,onCommit:n,onCancel:r,className:i}){let[a,o]=(0,H.useState)(e),s=(0,H.useRef)(null);return(0,H.useEffect)(()=>{let t=s.current;if(!t)return;t.focus();let n=e.lastIndexOf(`.`);n>0?t.setSelectionRange(0,n):t.select()},[e]),(0,U.jsxs)(`div`,{className:`relative flex-1 min-w-0`,children:[(0,U.jsx)(`input`,{ref:s,value:a,"aria-label":`Name`,"aria-invalid":!!t,onChange:e=>o(e.target.value),onBlur:()=>n(a),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?n(a):e.key===`Escape`&&r()},className:E(`w-full rounded-[var(--rad-sm)] border bg-panel px-1.5 py-0.5 text-[13px] text-text outline-none`,t?`border-error`:`border-primary`,i)}),t&&(0,U.jsx)(`span`,{className:`absolute left-0 top-full z-10 mt-0.5 rounded border border-border bg-panel-2 px-1.5 py-0.5 text-[11px] text-error shadow-sm`,children:t})]})}var yn=(0,H.memo)(function(e){let{entry:t,currentDir:n,hasClipboard:r,isPinned:i,actions:a,menuTargets:o}=e,s=Zt({entry:t,dragPaths:(0,H.useMemo)(()=>o.map(e=>e.path),[o]),run:a.transferInto,onFiles:a.uploadInto});return(0,U.jsxs)(A,{children:[(0,U.jsx)(j,{asChild:!0,children:(0,U.jsx)(bn,{...e,dnd:s.props,dropActive:s.isDropTarget})}),(0,U.jsx)(X,{targets:o,currentDir:n,hasClipboard:r,isPinned:i,actions:a})]})}),bn=(0,H.forwardRef)(function({entry:e,selected:t,focused:n,cut:r,renaming:i,tileWidth:a,actions:o,selection:s,inlineError:c,currentDir:l,hasClipboard:u,isPinned:d,menuTargets:f,dnd:p,dropActive:m,...h},g){let _=Je(()=>{t||s.selectOnly(e.path)}),{isMobile:v,selectMode:y,handleTap:b}=_n(o,s),x=e.type!==`directory`&&lt(e.name)===`image`;return(0,U.jsxs)(`div`,{ref:g,...tn({...h,..._,...p},{role:`gridcell`,"aria-selected":t,"data-testid":`explorer-tile`,"data-path":e.path,title:e.name,style:a?{width:a}:void 0,onContextMenu:n=>{t||s.selectOnly(e.path),n.stopPropagation()},onClick:n=>{b(e,t)||s.onRowClick(e.path,n)},onDoubleClick:()=>o.openEntry(e),className:E(`relative flex flex-col items-center gap-1 rounded p-2 text-center select-none`,!a&&`w-full`,`can-hover:hover:bg-surface-elevated`,n&&!t&&`bg-surface-elevated`,t&&`bg-accent-wash`,r&&`opacity-40`,m&&`ring-1 ring-dashed ring-primary bg-primary/10`)}),children:[v&&y&&(0,U.jsx)(`span`,{"aria-hidden":!0,className:E(`absolute left-1.5 top-1.5 flex size-5 items-center justify-center rounded border`,t?`border-primary bg-primary text-primary-foreground`:`border-border bg-panel`),children:t&&(0,U.jsx)(de,{className:`size-3.5`})}),(0,U.jsx)(`div`,{className:`flex h-12 w-12 shrink-0 items-center justify-center`,children:x?(0,U.jsx)(un,{entry:e,size:48}):(0,U.jsx)(W,{name:e.name,kind:e.kind,className:`size-12`})}),i?(0,U.jsx)(vn,{initial:e.name,error:c,onCommit:e=>void o.commitInline(e),onCancel:o.cancelInline}):(0,U.jsx)(`span`,{className:E(`line-clamp-2 w-full break-words text-[12px] leading-tight`,t?`text-text`:`text-text-2`),children:e.name})]})}),xn=96,Sn=88,Cn=4,wn=16,Tn=3;function En({slice:e,entries:t,actions:n,selection:r,inlineError:i,hasClipboard:a,isPinned:o,backgroundLongPress:s}){let c=ve(e=>e.clipboard?.operation===`cut`?e.clipboard.paths:null),l=(0,H.useRef)(null);I(l);let u=D(),[d,f]=(0,H.useState)(u?Tn:1);(0,H.useEffect)(()=>{if(u){f(Tn);return}let e=l.current;if(!e)return;let t=()=>{let t=e.clientWidth-wn+Cn;f(Math.max(1,Math.floor(t/(xn+Cn))))};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[u]);let p=Re({count:Math.ceil(t.length/d),getScrollElement:()=>l.current,estimateSize:()=>Sn,overscan:4}),m=e.anchor?t.findIndex(t=>t.path===e.anchor):-1,h=m>=0?Math.floor(m/d):-1;(0,H.useEffect)(()=>{h>=0&&p.scrollToIndex(h,{align:`auto`})},[h]);let g=(0,H.useMemo)(()=>Z(e,t),[e,t]),_=e.inlineEdit?.kind===`new-file`||e.inlineEdit?.kind===`new-folder`,v=N({targetDir:e.path,run:n.transferInto,onFiles:n.uploadInto}),y=e=>{if(!(e.altKey||e.ctrlKey||e.metaKey))switch(e.key){case`ArrowDown`:e.preventDefault(),e.stopPropagation(),r.moveTo(d,e.shiftKey);return;case`ArrowUp`:e.preventDefault(),e.stopPropagation(),r.moveTo(-d,e.shiftKey);return;case`ArrowLeft`:e.preventDefault(),e.stopPropagation(),r.moveTo(-1,e.shiftKey);return;case`ArrowRight`:e.preventDefault(),e.stopPropagation(),r.moveTo(1,e.shiftKey);return}};return(0,U.jsxs)(A,{children:[(0,U.jsx)(j,{asChild:!0,children:(0,U.jsxs)(`div`,{ref:l,role:`grid`,tabIndex:0,"data-testid":`explorer-icons`,"aria-label":`File icons`,onKeyDown:y,onMouseDown:e=>{e.target===e.currentTarget&&r.clear()},className:E(`h-full flex-1 overflow-auto p-2 outline-none`,v.isOver&&`ring-1 ring-dashed ring-primary bg-primary/10`),...s,...v.handlers,children:[_&&(0,U.jsx)(`div`,{className:`mb-2 flex flex-col items-center gap-1 p-2`,style:u?void 0:{width:xn},children:(0,U.jsx)(vn,{initial:``,error:i,onCommit:e=>void n.commitInline(e),onCancel:n.cancelInline})}),(0,U.jsx)(`div`,{className:`relative w-full`,style:{height:p.getTotalSize()},children:p.getVirtualItems().map(s=>{let l=s.index*d,f=t.slice(l,l+d);return(0,U.jsx)(`div`,{role:`row`,className:E(`absolute left-0 top-0 w-full gap-1`,u?`grid grid-cols-3`:`flex`),style:{transform:`translateY(${s.start}px)`},children:f.map(t=>(0,U.jsx)(yn,{entry:t,currentDir:e.path,selected:e.selection.has(t.path),focused:e.anchor===t.path,cut:c?.includes(t.path)===!0,renaming:e.inlineEdit?.kind===`rename`&&e.inlineEdit.path===t.path,tileWidth:u?void 0:xn,menuTargets:e.selection.has(t.path)?g:[t],actions:n,selection:r,hasClipboard:a,isPinned:o,inlineError:i},t.path))},s.index)})}),t.length===0&&!e.loading&&!_&&(0,U.jsx)(`p`,{className:`p-3 text-xs text-text-subtle`,children:e.filter?`No entries match the filter.`:`This folder is empty.`})]})}),(0,U.jsx)(X,{targets:[],currentDir:e.path,hasClipboard:a,isPinned:o,actions:n})]})}var Dn=(0,H.memo)(function(e){let{entry:t,currentDir:n,hasClipboard:r,isPinned:i,actions:a,menuTargets:o}=e,s=Zt({entry:t,dragPaths:(0,H.useMemo)(()=>o.map(e=>e.path),[o]),run:a.transferInto,onFiles:a.uploadInto});return(0,U.jsxs)(A,{children:[(0,U.jsx)(j,{asChild:!0,children:(0,U.jsx)(On,{...e,dnd:s.props,dropActive:s.isDropTarget})}),(0,U.jsx)(X,{targets:o,currentDir:n,hasClipboard:r,isPinned:i,actions:a})]})}),On=(0,H.forwardRef)(function({entry:e,selected:t,focused:n,cut:r,renaming:i,height:a,actions:o,selection:s,inlineError:c,currentDir:l,hasClipboard:u,isPinned:d,menuTargets:f,dnd:p,dropActive:m,...h},g){let _=Je(()=>{t||s.selectOnly(e.path)}),{isMobile:v,selectMode:y,handleTap:b}=_n(o,s);return(0,U.jsxs)(`div`,{ref:g,...tn({...h,..._,...p},{role:`row`,"aria-selected":t,"data-testid":`explorer-row`,"data-path":e.path,title:e.name,style:{height:a},onContextMenu:n=>{t||s.selectOnly(e.path),n.stopPropagation()},onClick:n=>{b(e,t)||s.onRowClick(e.path,n)},onDoubleClick:()=>o.openEntry(e),className:E(`flex w-full items-center gap-2 px-2 text-[13px] select-none`,`can-hover:hover:bg-surface-elevated`,n&&!t&&`bg-surface-elevated`,t&&`bg-accent-wash`,r&&`opacity-40`,m&&`ring-1 ring-dashed ring-primary bg-primary/10`)}),children:[v&&y&&(0,U.jsx)(`span`,{"aria-hidden":!0,className:E(`flex size-5 shrink-0 items-center justify-center rounded border`,t?`border-primary bg-primary text-primary-foreground`:`border-border`),children:t&&(0,U.jsx)(de,{className:`size-3.5`})}),(0,U.jsx)(W,{name:e.name,kind:e.kind,className:`size-4`}),i?(0,U.jsx)(vn,{initial:e.name,error:c,onCommit:e=>void o.commitInline(e),onCancel:o.cancelInline}):(0,U.jsx)(`span`,{className:E(`flex-1 truncate`,t?`text-text`:`text-text-2`),children:e.name}),(0,U.jsx)(`span`,{className:`w-20 shrink-0 text-right tabular-nums text-text-subtle`,children:e.type===`directory`?``:Se(e.size)}),(0,U.jsx)(`span`,{className:`hidden w-24 shrink-0 text-right text-text-subtle sm:inline`,children:ye(e.modified)}),(0,U.jsx)(`span`,{className:`hidden w-16 shrink-0 truncate text-right text-text-subtle md:inline`,children:e.type===`directory`?`Folder`:B(e.name)||`File`})]})}),kn={name:`flex-1 text-left`,size:`w-20 text-right`,modified:`hidden w-24 text-right sm:block`,kind:`hidden w-16 text-right md:block`},An=J.map(e=>({...e,className:kn[e.key]}));function jn({slice:e,entries:t,actions:n,selection:r,inlineError:i,hasClipboard:a,isPinned:o,rowHeight:l,backgroundLongPress:u}){let d=R(e=>e.sort),f=R(e=>e.setPrefs),p=ve(e=>e.clipboard?.operation===`cut`?e.clipboard.paths:null),m=(0,H.useRef)(null);I(m);let h=$e(),g=L(),_=Re({count:t.length,getScrollElement:()=>m.current,estimateSize:()=>l,overscan:12}),v=e.anchor?t.findIndex(t=>t.path===e.anchor):-1;(0,H.useEffect)(()=>{v>=0&&_.scrollToIndex(v,{align:`auto`})},[v]);let y=(0,H.useMemo)(()=>Z(e,t),[e,t]),b=e.inlineEdit?.kind===`new-file`||e.inlineEdit?.kind===`new-folder`,x=N({targetDir:e.path,run:n.transferInto,onFiles:n.uploadInto}),S=e=>f({sort:{key:e,dir:d.key===e&&d.dir===`asc`?`desc`:`asc`}});return(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,U.jsx)(`div`,{role:`row`,className:E(`flex shrink-0 items-center gap-2 border-b border-border bg-[var(--x-toolbar-bg,var(--panel-2))] px-2 py-1 text-[11px] font-medium text-text-subtle`,h.id===`windows`&&`divide-x divide-border`),children:An.map(e=>(0,U.jsxs)(`button`,{type:`button`,"aria-label":`Sort by ${e.label}`,onClick:()=>S(e.key),className:E(`relative flex items-center gap-0.5 can-hover:hover:text-text`,h.id===`windows`&&e.key!==`name`&&`pl-2`,e.className,e.key!==`name`&&`justify-end`,g&&`before:absolute before:-inset-x-2 before:-inset-y-3 before:content-['']`),children:[e.label,d.key===e.key&&(d.dir===`asc`?(0,U.jsx)(s,{className:`size-3`}):(0,U.jsx)(c,{className:`size-3`}))]},e.key))}),(0,U.jsxs)(A,{children:[(0,U.jsx)(j,{asChild:!0,children:(0,U.jsxs)(`div`,{ref:m,role:`grid`,tabIndex:0,"data-testid":`explorer-list`,"aria-label":`File list`,onMouseDown:e=>{e.target===e.currentTarget&&r.clear()},className:E(`flex-1 overflow-auto outline-none`,x.isOver&&`ring-1 ring-dashed ring-primary bg-primary/10`),...u,...x.handlers,children:[b&&(0,U.jsxs)(`div`,{className:`flex items-center gap-2 px-2`,style:{height:l},children:[(0,U.jsx)(`span`,{className:`size-4 shrink-0`}),(0,U.jsx)(vn,{initial:``,error:i,onCommit:e=>void n.commitInline(e),onCancel:n.cancelInline})]}),(0,U.jsx)(`div`,{className:`relative w-full`,style:{height:_.getTotalSize()},children:_.getVirtualItems().map(s=>{let c=t[s.index];return(0,U.jsx)(`div`,{className:E(`absolute left-0 top-0 w-full`,h.id===`macos`&&s.index%2==1&&`bg-panel-2/40`),style:{transform:`translateY(${s.start}px)`},children:(0,U.jsx)(Dn,{entry:c,currentDir:e.path,selected:e.selection.has(c.path),focused:e.anchor===c.path,cut:p?.includes(c.path)===!0,renaming:e.inlineEdit?.kind===`rename`&&e.inlineEdit.path===c.path,height:l,menuTargets:e.selection.has(c.path)?y:[c],actions:n,selection:r,hasClipboard:a,isPinned:o,inlineError:i})},c.path)})}),t.length===0&&!e.loading&&!b&&(0,U.jsx)(`p`,{className:`p-3 text-xs text-text-subtle`,children:e.filter?`No entries match the filter.`:`This folder is empty.`})]})}),(0,U.jsx)(X,{targets:[],currentDir:e.path,hasClipboard:a,isPinned:o,actions:n})]})]})}var Mn={list:jn,icons:En,columns:hn},Nn=Object.keys(Mn);function Pn(e){return Mn[e]??jn}var Fn={list:_,icons:r,columns:ce},In={list:`List view`,icons:`Icons view`,columns:`Column view`};function Ln({windowId:e,slice:t,nav:n,actions:r}){let i=R(e=>e.patch),a=R(e=>e.showHidden),s=R(e=>e.viewMode),c=R(e=>e.setPrefs),[l,u]=(0,H.useState)(!1),[f,p]=(0,H.useState)(t.path);(0,H.useEffect)(()=>p(t.path),[t.path]);let h=L();return(0,U.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1 border-b border-border bg-[var(--x-toolbar-bg,var(--panel-2))] px-1.5 py-1`,children:[(0,U.jsx)(`button`,{type:`button`,"aria-label":`Back`,title:`Back`,disabled:!n.canGoBack,onClick:n.back,className:Y(h),children:(0,U.jsx)(x,{className:`size-4`})}),(0,U.jsx)(`button`,{type:`button`,"aria-label":`Forward`,title:`Forward`,disabled:!n.canGoForward,onClick:n.forward,className:Y(h),children:(0,U.jsx)(le,{className:`size-4`})}),(0,U.jsx)(`button`,{type:`button`,"aria-label":`Up one level`,title:`Up`,disabled:!t.parent,onClick:n.up,className:Y(h),children:(0,U.jsx)(g,{className:`size-4`})}),(0,U.jsx)(`button`,{type:`button`,"aria-label":`Refresh`,title:`Refresh`,onClick:n.refresh,className:Y(h),children:(0,U.jsx)(d,{className:E(`size-4`,t.loading&&`animate-spin`)})}),(0,U.jsxs)(`div`,{className:`flex min-w-[8rem] flex-1 items-center gap-1 rounded border border-border bg-panel px-1`,children:[l?(0,U.jsx)(`input`,{autoFocus:!0,"aria-label":`Path`,value:f,onChange:e=>p(e.target.value),onBlur:()=>u(!1),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?(n.go(f.trim()),u(!1)):e.key===`Escape`&&(p(t.path),u(!1))},className:`min-w-0 flex-1 bg-transparent py-1 font-mono text-xs text-text outline-none`}):(0,U.jsx)(Gt,{crumbs:t.breadcrumbs,onNavigate:n.go,sep:t.sep,className:`flex-1 overflow-hidden py-0.5`}),(0,U.jsx)(`button`,{type:`button`,"aria-label":l?`Show breadcrumb`:`Edit path`,title:l?`Show breadcrumb`:`Edit path`,onClick:()=>u(e=>!e),className:Y(h),children:(0,U.jsx)(m,{className:`size-3.5`})})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1 rounded border border-border bg-panel px-1`,children:[(0,U.jsx)(v,{className:`size-3.5 shrink-0 text-text-subtle`}),(0,U.jsx)(`input`,{"aria-label":`Filter entries`,placeholder:`Filter`,value:t.filter,onChange:t=>i(e,{filter:t.target.value}),onKeyDown:t=>{t.stopPropagation(),t.key===`Escape`&&i(e,{filter:``})},className:`w-24 min-w-0 bg-transparent py-1 text-xs text-text outline-none placeholder:text-text-subtle`}),t.filter&&(0,U.jsx)(`button`,{type:`button`,"aria-label":`Clear filter`,onClick:()=>i(e,{filter:``}),className:Y(h),children:(0,U.jsx)(o,{className:`size-3.5`})})]}),Nn.length>1&&Nn.map(e=>{let t=Fn[e];return(0,U.jsx)(`button`,{type:`button`,"aria-label":In[e],title:In[e],"aria-pressed":s===e,onClick:()=>c({viewMode:e}),className:E(Y(h),s===e&&`bg-accent-wash text-primary`),children:(0,U.jsx)(t,{className:`size-4`})},e)}),(0,U.jsx)(Xt,{coarse:h}),r.supportsFolderUpload?(0,U.jsxs)(ct,{children:[(0,U.jsx)(qe,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Upload`,title:`Upload`,className:Y(h),children:(0,U.jsx)(b,{className:`size-4`})})}),(0,U.jsxs)(Ge,{align:`end`,children:[(0,U.jsx)(Ie,{onClick:()=>r.openUploadPicker(),children:`Upload Files…`}),(0,U.jsx)(Ie,{onClick:()=>r.openUploadFolderPicker(),children:`Upload Folder…`})]})]}):(0,U.jsx)(`button`,{type:`button`,"aria-label":`Upload`,title:`Upload`,onClick:()=>r.openUploadPicker(),className:Y(h),children:(0,U.jsx)(b,{className:`size-4`})}),(0,U.jsx)(`button`,{type:`button`,"aria-label":a?`Hide hidden files`:`Show hidden files`,title:a?`Hide hidden files`:`Show hidden files`,"aria-pressed":a,onClick:()=>c({showHidden:!a}),className:E(Y(h),a&&`bg-accent-wash text-primary`),children:a?(0,U.jsx)(S,{className:`size-4`}):(0,U.jsx)(ue,{className:`size-4`})})]})}var Rn={list:_,icons:r,columns:ce},zn={list:`List`,icons:`Icons`,columns:`Columns`};function Bn(e){return{name:e.breadcrumbs[e.breadcrumbs.length-1]?.name??e.path,path:e.path,type:`directory`,kind:`directory`,modified:``}}function Vn({open:e,onClose:t,slice:n,actions:r,entries:i}){let a=R(e=>e.viewMode),o=R(e=>e.sort),s=R(e=>e.showHidden),c=R(e=>e.setPrefs),l=Z(n,i);return(0,U.jsxs)(je,{open:e,onClose:t,className:`p-2`,children:[(0,U.jsx)(Ae,{children:`View`}),(0,U.jsx)(`div`,{className:`flex gap-1 px-2 pb-2`,children:Nn.map(e=>{let n=Rn[e];return(0,U.jsxs)(`button`,{type:`button`,"aria-pressed":a===e,onClick:()=>{c({viewMode:e}),t()},className:E(`flex flex-1 flex-col items-center gap-1 rounded-lg py-2 text-xs active:bg-surface-elevated`,a===e?`bg-accent-wash text-primary`:`text-text-2`),children:[(0,U.jsx)(n,{className:`size-4`}),zn[e]]},e)})}),(0,U.jsx)(Oe,{}),(0,U.jsx)(Ae,{children:`Sort by`}),(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1 px-2 pb-2`,children:J.map(({key:e,label:n})=>(0,U.jsxs)(`button`,{type:`button`,"aria-pressed":o.key===e,onClick:()=>{c({sort:{key:e,dir:o.key===e&&o.dir===`asc`?`desc`:`asc`}}),t()},className:E(`inline-flex min-h-11 items-center justify-center rounded-full border px-3 py-1.5 text-xs active:bg-surface-elevated`,o.key===e?`border-primary bg-accent-wash text-text`:`border-border text-text-2`),children:[n,o.key===e?o.dir===`asc`?` ↑`:` ↓`:``]},e))}),(0,U.jsx)(Oe,{}),(0,U.jsxs)(k,{onClick:()=>c({showHidden:!s}),children:[s?(0,U.jsx)(S,{className:`size-4`}):(0,U.jsx)(ue,{className:`size-4`}),s?`Hide hidden files`:`Show hidden files`]}),(0,U.jsx)(Oe,{}),(0,U.jsxs)(k,{variant:`destructive`,disabled:l.length===0,onClick:()=>r.confirmPermanentDelete(l),children:[(0,U.jsx)(fe,{className:`size-4`}),`Delete permanently`,l.length>1?` (${l.length})`:``]}),(0,U.jsxs)(k,{onClick:()=>r.showProperties(Bn(n)),children:[(0,U.jsx)(ae,{className:`size-4`}),`Properties of this folder`]})]})}function Q({icon:e,label:t,onClick:n,disabled:r,destructive:i}){return(0,U.jsxs)(`button`,{type:`button`,"aria-label":t,title:t,disabled:r,onClick:n,className:`flex min-w-[44px] flex-1 flex-col items-center gap-0.5 rounded-lg py-1.5 text-[10px] active:bg-surface-elevated disabled:opacity-30 ${i?`text-error`:`text-text-2`}`,children:[(0,U.jsx)(e,{className:`size-5`}),(0,U.jsx)(`span`,{className:`truncate`,children:t})]})}function Hn({slice:e,nav:t,actions:n,entries:r,hasClipboard:i}){let a=F(e=>e.selectMode),s=F(e=>e.setSelectMode),[c,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(!1),m=r.filter(t=>e.selection.has(t.path));return a?(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-t border-border px-1 py-1`,children:[(0,U.jsx)(Q,{icon:o,label:`Cancel`,onClick:()=>{s(!1)}}),(0,U.jsxs)(`span`,{className:`px-1 text-xs text-text-subtle`,children:[m.length,` selected`]}),(0,U.jsx)(`div`,{className:`flex-1`}),(0,U.jsx)(Q,{icon:ee,label:`Cut`,disabled:m.length===0,onClick:()=>n.cut(m)}),(0,U.jsx)(Q,{icon:te,label:`Copy`,disabled:m.length===0,onClick:()=>n.copy(m)}),(0,U.jsx)(Q,{icon:fe,label:`Trash`,disabled:m.length===0,destructive:!0,onClick:()=>n.trash(m)}),(0,U.jsx)(Q,{icon:se,label:`Download`,disabled:!m.some(e=>e.type===`file`),onClick:()=>n.download(m)}),m.length===1&&(0,U.jsx)(Q,{icon:ae,label:`Info`,onClick:()=>n.showProperties(m[0])})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-t border-border px-1 py-1`,children:[(0,U.jsx)(Q,{icon:x,label:`Back`,disabled:!t.canGoBack,onClick:t.back}),(0,U.jsx)(Q,{icon:ie,label:`New`,onClick:()=>d(!0)}),(0,U.jsx)(Q,{icon:re,label:`Paste`,disabled:!i,onClick:()=>n.paste()}),(0,U.jsx)(Q,{icon:de,label:`Select`,onClick:()=>s(!0)}),(0,U.jsx)(Q,{icon:l,label:`More`,onClick:()=>p(!0)})]}),(0,U.jsxs)(je,{open:c,onClose:()=>d(!1),className:`p-2`,children:[(0,U.jsxs)(k,{onClick:()=>n.startCreate(`new-file`),children:[(0,U.jsx)(C,{className:`size-4`}),` New File`]}),(0,U.jsxs)(k,{onClick:()=>n.startCreate(`new-folder`),children:[(0,U.jsx)(u,{className:`size-4`}),` New Folder`]}),(0,U.jsxs)(k,{onClick:()=>{d(!1),n.openUploadPicker()},children:[(0,U.jsx)(b,{className:`size-4`}),` Upload Files…`]})]}),(0,U.jsx)(Vn,{open:f,onClose:()=>p(!1),slice:e,actions:n,entries:r})]})}function Un(e){return e.breadcrumbs[e.breadcrumbs.length-1]?.name??e.path}function Wn({slice:e,onClose:t}){return(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border px-3 py-2.5`,children:[(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[15px] font-semibold text-text`,children:Un(e)}),(0,U.jsx)(`button`,{type:`button`,"aria-label":`Close file explorer`,title:`Close`,onClick:t,className:`flex size-11 shrink-0 items-center justify-center rounded-full text-text-2 active:bg-surface-elevated`,children:(0,U.jsx)(o,{className:`size-5`})})]})}var Gn=`size-4 shrink-0 text-text-subtle`,Kn={fixed:w,removable:i,network:ut,unknown:w};function qn(){return(0,U.jsx)(W,{name:``,kind:`directory`,className:Gn})}function $({label:e,path:t,active:n,icon:r,onNavigate:i}){return(0,U.jsxs)(`button`,{type:`button`,title:t,onClick:()=>i(t),className:E(`flex min-h-[44px] w-full items-center gap-2.5 rounded-lg px-3 text-left text-sm active:bg-surface-elevated`,n?`bg-accent-wash text-text`:`text-text-2`),children:[r,(0,U.jsx)(`span`,{className:`truncate`,children:e})]})}function Jn({title:e,children:t}){return(0,U.jsxs)(`div`,{className:`pb-2`,children:[(0,U.jsx)(`p`,{className:`px-3 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-wide text-text-subtle`,children:e}),t]})}function Yn({open:e,onClose:t,host:n,currentPath:r,vocab:i,onNavigate:a}){let o=V(e=>e.pins),s=e=>e===r;return(0,U.jsx)(je,{open:e,onClose:t,zIndex:65,className:`p-1`,children:(0,U.jsxs)(`div`,{className:`max-h-[70vh] overflow-y-auto px-1 pb-2`,children:[o.length>0&&(0,U.jsx)(Jn,{title:`Pinned`,children:o.map(e=>(0,U.jsx)($,{label:e.name,path:e.path,icon:(0,U.jsx)(f,{className:Gn}),active:s(e.path),onNavigate:a},e.path))}),n&&n.pinned.length>0&&(0,U.jsx)(Jn,{title:i.pinned,children:n.pinned.map(e=>(0,U.jsx)($,{label:e.name,path:e.path,icon:qn(),active:s(e.path),onNavigate:a},e.path))}),n&&(0,U.jsxs)(Jn,{title:i.known,children:[(0,U.jsx)($,{label:i.home,path:n.homedir,icon:qn(),active:s(n.homedir),onNavigate:a}),n.knownFolders.map(e=>(0,U.jsx)($,{label:e.name,path:e.path,icon:qn(),active:s(e.path),onNavigate:a},e.path))]}),n&&n.drives.length>0&&(0,U.jsx)(Jn,{title:i.drives,children:n.drives.map(e=>{let t=Kn[e.kind];return(0,U.jsx)($,{label:e.label?`${e.label} (${e.name})`:e.name,path:e.path,icon:(0,U.jsx)(t,{className:Gn}),active:s(e.path),onNavigate:a},e.path)})})]})})}function Xn({className:e}){return(0,U.jsx)(W,{name:``,kind:`directory`,className:e})}var Zn={fixed:w,removable:i,network:ut,unknown:w};function Qn({chip:e,active:t,onNavigate:n}){let r=e.icon;return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(e.path),title:e.path,className:E(`flex h-11 shrink-0 items-center gap-1.5 rounded-full border px-3 text-[13px] active:bg-surface-elevated`,t?`border-primary bg-accent-wash text-text`:`border-border text-text-2`),children:[(0,U.jsx)(r,{className:`size-4 shrink-0 text-text-subtle`}),(0,U.jsx)(`span`,{className:`max-w-[9rem] truncate`,children:e.label})]})}function $n({host:e,currentPath:t,onNavigate:n,vocab:r}){let i=V(e=>e.pins),[a,o]=(0,H.useState)(!1);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 overflow-x-auto touch-pan-x border-b border-border px-2 py-1.5`,children:[[...i.map(e=>({key:`pin:${e.path}`,label:e.name,path:e.path,icon:f})),...e?[{key:`home`,label:r.home,path:e.homedir,icon:Xn}]:[],...e?.pinned.map(e=>({key:`os:${e.path}`,label:e.name,path:e.path,icon:Xn}))??[],...e?.drives.map(e=>({key:`drive:${e.path}`,label:e.label?`${e.label} (${e.name})`:e.name,path:e.path,icon:Zn[e.kind]}))??[]].map(e=>(0,U.jsx)(Qn,{chip:e,active:e.path===t,onNavigate:n},e.key)),(0,U.jsx)(`button`,{type:`button`,"aria-label":`All places`,title:`All places`,onClick:()=>o(!0),className:`flex h-11 shrink-0 items-center gap-1 rounded-full border border-border px-3 text-[13px] text-text-2 active:bg-surface-elevated`,children:(0,U.jsx)(l,{className:`size-4`})})]}),(0,U.jsx)(Yn,{open:a,onClose:()=>o(!1),host:e,currentPath:t,vocab:r,onNavigate:e=>{o(!1),n(e)}})]})}function er(e,t,n){let r=(0,H.useRef)(null),i=R(e=>e.patch),a=(0,H.useRef)(t?.path??``);a.current=t?.path??``;let o=(0,H.useRef)(n);o.current=n;let s=(0,H.useCallback)(async t=>{r.current?.abort();let n=new AbortController;r.current=n,i(e,{loading:!0,error:null});try{let r=await O.browse(t,{showHidden:o.current,signal:n.signal});if(n.signal.aborted)return;i(e,{entries:r.entries,breadcrumbs:r.breadcrumbs,parent:r.parent,sep:r.sep,truncated:r.truncated===!0,loading:!1,error:null})}catch(t){if(n.signal.aborted||t instanceof DOMException&&t.name===`AbortError`)return;i(e,{loading:!1,entries:[],error:t instanceof be?{message:t.message,code:t.code,hint:t.hint}:{message:t instanceof Error?t.message:`Failed to read directory`,code:`EUNKNOWN`}})}},[e,i]),c=t?.path;(0,H.useEffect)(()=>{if(c)return s(c),()=>r.current?.abort()},[c,n,s]),(0,H.useEffect)(()=>Ne(e=>{e===a.current&&s(e)}),[s]);let l=(0,H.useCallback)((t,n)=>{let r=R.getState().slices[e];if(!r||t===r.path)return;let a=n?.replace?[...r.history.slice(0,r.historyIndex),t]:[...r.history.slice(0,r.historyIndex+1),t];i(e,{path:t,history:a.slice(-100),historyIndex:Math.min(a.length,100)-1,selection:new Set,anchor:null,filter:``,inlineEdit:null}),ge.getState().setPayload(e,{path:t})},[e,i]),u=(0,H.useCallback)(t=>{let n=R.getState().slices[e];if(!n)return;let r=n.historyIndex+t,a=n.history[r];a!=null&&(i(e,{path:a,historyIndex:r,selection:new Set,anchor:null,filter:``,inlineEdit:null}),ge.getState().setPayload(e,{path:a}))},[e,i]),d=(0,H.useCallback)(()=>u(-1),[u]),f=(0,H.useCallback)(()=>u(1),[u]),p=(0,H.useCallback)(()=>{let t=R.getState().slices[e];t?.parent&&l(t.parent)},[e,l]),m=(0,H.useCallback)(()=>{a.current&&s(a.current)},[s]),h=(t?.historyIndex??0)>0,g=t?t.historyIndex<t.history.length-1:!1;return(0,H.useMemo)(()=>({go:l,back:d,forward:f,up:p,refresh:m,canGoBack:h,canGoForward:g}),[l,d,f,p,m,h,g])}function tr(e,t,n){let r=t==null?-1:e.indexOf(t),i=e.indexOf(n);if(i<0)return[];if(r<0)return[n];let[a,o]=r<=i?[r,i]:[i,r];return e.slice(a,o+1)}function nr(e,t,n){switch(n.type){case`clear`:return{selection:new Set,anchor:null};case`select-all`:return{selection:new Set(t),anchor:e.anchor??t[0]??null};case`set`:return{selection:new Set(n.paths),anchor:n.anchor===void 0?n.paths[n.paths.length-1]??null:n.anchor};case`click`:if(n.ctrl){let t=new Set(e.selection);return t.has(n.path)?t.delete(n.path):t.add(n.path),{selection:t,anchor:n.path}}if(n.shift){let r=tr(t,e.anchor,n.path);return{selection:new Set(r),anchor:e.anchor??n.path}}return{selection:new Set([n.path]),anchor:n.path}}}function rr(e,t,n){if(e.length===0)return null;let r=t==null?-1:e.indexOf(t);return r<0?n>0?e[0]:e[e.length-1]:e[Math.min(e.length-1,Math.max(0,r+n))]}function ir(e,t,n){if(!t)return-1;let r=t.toLowerCase(),i=n<0?0:n+1;for(let t=0;t<e.length;t++){let n=(i+t)%e.length;if(e[n].toLowerCase().startsWith(r))return n}return-1}function ar(e,t){let n=R(e=>e.patch),r=(0,H.useRef)(t);r.current=t;let i=(0,H.useRef)({text:``,at:0}),a=(0,H.useCallback)(t=>{let i=R.getState().slices[e];i&&n(e,nr(i,r.current,t))},[e,n]),o=(0,H.useCallback)((t,n)=>{let i=R.getState().slices[e];if(!i)return;let o=rr(r.current,i.anchor,t);o!=null&&a({type:`click`,path:o,shift:n})},[e,a]),s=(0,H.useCallback)(t=>{let n=R.getState().slices[e];if(!n)return null;let o=Date.now(),s=o-i.current.at>800?t:i.current.text+t;i.current={text:s,at:o};let c=r.current,l=ir(c.map(e=>e.split(/[/\\]/).pop()??e),s,s.length===1&&n.anchor?c.indexOf(n.anchor):-1);return l<0?null:(a({type:`click`,path:c[l]}),c[l])},[e,a]),c=(0,H.useCallback)((e,t)=>a({type:`click`,path:e,shift:t.shiftKey,ctrl:t.ctrlKey||t.metaKey}),[a]),l=(0,H.useCallback)(e=>a({type:`click`,path:e}),[a]),u=(0,H.useCallback)(()=>a({type:`select-all`}),[a]),d=(0,H.useCallback)(()=>a({type:`clear`}),[a]),f=(0,H.useCallback)((e,t)=>a({type:`set`,paths:e,anchor:t}),[a]);return(0,H.useMemo)(()=>({onRowClick:c,selectOnly:l,selectAll:u,clear:d,setSelection:f,moveTo:o,typeAhead:s}),[c,l,u,d,f,o,s])}var or=28,sr=36,cr=48;function lr({windowId:e,initialPath:t,variant:n=`window`}){let r=R(e=>e.ensure);(0,H.useEffect)(()=>r(e,t),[r,e,t]);let i=R(t=>t.slices[e]),a=R(e=>e.showHidden),o=R(e=>e.viewMode),s=R(e=>e.sort),{host:c}=tt(),l=ve(e=>(e.clipboard?.paths.length??0)>0),u=V(e=>e.isPinned),d=L(),f=$e(),m=er(e,i,a),{actions:h,dialogs:g}=kt(e,i,m,c?.platform),_=(0,H.useMemo)(()=>i?Vt(i.entries,i.filter,s):[],[i?.entries,i?.filter,s]),v=ar(e,(0,H.useMemo)(()=>_.map(e=>e.path),[_])),y=gn({slice:i,entries:_,actions:h,selection:v,nav:m}),b=Je(),x=F(e=>e.close);if(!i)return null;let S=Pn(o),C=n===`sheet`,ee=C?cr:d?sr:or;return(0,U.jsxs)(`div`,{"data-skin":f.id,style:{fontFamily:`var(--x-font)`},className:`flex h-full min-h-0 w-full flex-col bg-panel text-text`,children:[C?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Wn,{slice:i,onClose:x}),(0,U.jsx)($n,{host:c,currentPath:i.path,onNavigate:m.go,vocab:f.vocab})]}):(0,U.jsx)(Ln,{windowId:e,slice:i,nav:m,actions:h}),i.error&&(0,U.jsxs)(`div`,{className:`flex items-start gap-2 border-b border-border bg-error/10 px-2 py-1.5 text-xs text-error`,children:[(0,U.jsx)(oe,{className:`mt-0.5 size-3.5 shrink-0`}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`p`,{className:`break-words`,children:i.error.message}),i.error.hint&&(0,U.jsx)(`p`,{className:`mt-0.5 text-text-2`,children:i.error.hint})]}),c&&(0,U.jsxs)(`button`,{type:`button`,onClick:()=>m.go(c.homedir),className:`flex shrink-0 items-center gap-1 rounded border border-border px-1.5 py-0.5 text-text-2 can-hover:hover:bg-surface-elevated`,children:[(0,U.jsx)(p,{className:`size-3`}),` Go home`]})]}),(0,U.jsx)(Ft,{value:{closed:f.FolderIcon,open:f.FolderOpenIcon},children:(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[!C&&(0,U.jsx)(zt,{host:c,currentPath:i.path,onNavigate:m.go,vocab:f.vocab}),(0,U.jsx)(`div`,{className:`min-w-0 flex-1`,onKeyDown:y,children:(0,U.jsx)(S,{windowId:e,slice:i,entries:_,actions:h,selection:v,inlineError:g.inlineError,hasClipboard:l,isPinned:u,rowHeight:ee,nav:m,backgroundLongPress:b})})]})}),C?(0,U.jsx)(Hn,{slice:i,nav:m,actions:h,entries:_,hasClipboard:l}):(0,U.jsx)(Ut,{entries:_,selection:i.selection,truncated:i.truncated}),(0,U.jsx)(it,{dialogs:g,platform:c?.platform,sep:i.sep})]})}export{lr as t};
1
+ import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{C as t,S as n}from"./vendor-markdown-CuWCHIVb.js";import{$t as r,Ar as i,At as a,Br as o,N as s,O as c,On as l,Ot as u,Qn as d,Un as f,Ut as p,Vn as m,Vt as h,d as g,in as _,ir as v,j as y,kr as b,l as x,lt as S,mt as C,nr as ee,nt as te,p as ne,q as re,qn as ie,qt as ae,r as oe,st as se,tt as ce,u as le,ut as ue,w as de,wr as fe,zt as w}from"./icons-DQjqk0lJ.js";import{t as pe}from"./createLucideIcon-DoiEKeJ_.js";import{r as me,s as T}from"./api-client-Jn3njtNw.js";import{t as he}from"./react-Bghu0NUO.js";import{n as E}from"./utils-Bmf_8h7Y.js";import{t as ge}from"./window-store-UC1jJeLM.js";import{t as _e}from"./tab-store-krAuHQ6_.js";import{o as ve}from"./file-store-Ds3qJ4hC.js";import{n as D}from"./use-is-mobile-TkcwP1Gx.js";import{a as ye,l as be,n as xe,o as Se,p as Ce,r as we,s as Te,t as Ee,u as O}from"./format-file-meta-PPi3ptkm.js";import{t as De}from"./file-icons-wS-OmEVu.js";import{i as Oe,n as ke,o as Ae,r as k,t as je}from"./mobile-bottom-sheet-C3TniEP-.js";import{$t as Me,At as Ne,Ct as Pe,Dt as A,Ft as Fe,Gt as Ie,Ht as Le,It as j,Kt as Re,Lt as ze,Mt as M,Nt as Be,Ot as Ve,Pt as He,St as Ue,Ut as We,Vt as Ge,Wt as Ke,Xt as qe,_t as Je,at as Ye,bt as Xe,ct as Ze,dt as Qe,g as $e,gt as et,ht as tt,it as N,jt as nt,kt as P,lt as rt,ot as it,pt as F,st as at,ut as I,vt as L,wt as R,xt as ot,yt as st,zt as ct}from"./index-CN0G8uYY.js";import{a as z,o as B,s as lt}from"./can-open-in-ppm-cv5--yHX.js";var ut=pe(`network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),dt=`ppm-explorer-pins`,ft=50;function pt(){try{let e=localStorage.getItem(dt),t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(e=>!!e&&typeof e.path==`string`&&typeof e.name==`string`).slice(0,ft):[]}catch{return[]}}function mt(e){try{localStorage.setItem(dt,JSON.stringify(e))}catch{}}var V=he((e,t)=>({pins:pt(),isPinned:e=>t().pins.some(t=>t.path===e),pin:n=>{if(t().isPinned(n.path))return;let r=[...t().pins,n].slice(0,ft);mt(r),e({pins:r})},unpin:n=>{let r=t().pins.filter(e=>e.path!==n);mt(r),e({pins:r})}}));function ht(e){return z(e.name)?(_e.getState().openTab({type:lt(e.name)===`sqlite`?`sqlite`:`editor`,title:e.name,projectId:null,metadata:{filePath:e.path},closable:!0}),!0):!1}function gt(e){return ge.getState().open(`explorer`,{path:e})}async function _t(e){let t=e.filter(e=>e.type===`file`),n=e.length-t.length;n>0&&T.warning(n===1?`Folders cannot be downloaded`:`${n} folders skipped`);for(let e of t)try{Ce(await O.downloadUrl(e.path),e.name)}catch(t){T.error(`Download failed: ${e.name}`,{description:t instanceof Error?t.message:void 0})}}async function vt(e,t){e.length!==0&&(await Me(e.join(`
2
+ `)),T.success(e.length===1?`${t} copied`:`${e.length} ${t.toLowerCase()}s copied`))}var yt=/[<>:"|?*]/,bt=/[\u0000-\u001f]/,xt=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function St(e,t){if(!e)return`Name cannot be empty`;if(e===`.`||e===`..`)return`Reserved name`;if(e.includes(`/`)||e.includes(`\\`))return`Name cannot contain path separators`;if(bt.test(e))return`Invalid character in name`;if(t===`win32`){if(yt.test(e))return`Cannot contain < > : " | ? *`;if(xt.test(e))return`"${e}" is a reserved Windows name`;if(e.endsWith(`.`)||e.endsWith(` `))return`Cannot end with a dot or space`}return null}async function Ct(e,t,n,r){let i=Te(e,t,r);try{return n===`folder`?await O.mkdir(i,!1):await O.touch(i),Ue(e),!0}catch(e){return T.error(n===`folder`?`Could not create folder`:`Could not create file`,{description:xe(e)}),!1}}async function wt(e,t,n){try{return await O.rename(e,t),Ue(Ee(e,n)),!0}catch(e){return T.error(`Rename failed`,{description:xe(e)}),!1}}async function Tt(e,t,n){let r={removed:0,needsPermanent:[]},i=new Set;for(let a of e){i.add(Ee(a,n));try{await O.remove(a,t),r.removed++}catch(e){if(e instanceof be&&e.code===`NO_TRASH`){r.needsPermanent.push(a);continue}T.error(`Delete failed`,{description:xe(e)})}}if(Ue(...i),r.removed>0){let e=`${r.removed} item${r.removed===1?``:`s`}`;T.success(t?`Deleted ${e}`:`Moved ${e} to Trash`)}return r}function Et(e,t){let n=e?Array.from({length:e.length},(t,n)=>e.item(n)).filter(e=>e!=null):[];return t(),n}var H=e(t(),1),U=n();function Dt(e){let t=(0,H.useRef)(null),n=(0,H.useRef)(null),r=typeof document<`u`&&`webkitdirectory`in document.createElement(`input`),i=t=>{let n=Et(t.target.files,()=>{t.target.value=``});n.length!==0&&e(n.map(e=>({file:e,relativePath:e.webkitRelativePath||e.name})))};return{supportsFolderPicker:r,openFilePicker:()=>t.current?.click(),openFolderPicker:()=>n.current?.click(),inputs:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`input`,{ref:t,type:`file`,multiple:!0,hidden:!0,onChange:i,"data-testid":`explorer-upload-file-input`}),r&&(0,U.jsx)(`input`,{ref:n,webkitdirectory:``,type:`file`,multiple:!0,hidden:!0,onChange:i,"data-testid":`explorer-upload-folder-input`})]})}}function Ot(e,t){let n=(0,H.useCallback)((t,n)=>rt(t,n,e.sep,e),[e]),r=Dt(e=>void n(e,t()));return{uploadInto:n,openUploadPicker:r.openFilePicker,openUploadFolderPicker:r.openFolderPicker,supportsFolderUpload:r.supportsFolderPicker,uploadInputs:r.inputs}}function kt(e,t,n,r){let i=R(e=>e.patch),a=Ze(),o=at(),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(null),[d,f]=(0,H.useState)(null),p=(0,H.useRef)(t);p.current=t;let m=(0,H.useRef)(a);m.current=a;let h=(0,H.useRef)(o);h.current=o;let g=(0,H.useMemo)(()=>({get sep(){return p.current?.sep??`/`},resolve:e=>m.current.resolve(e),startBatch:()=>m.current.startBatch(),endBatch:()=>m.current.endBatch(),confirmPermanentOverwrite:e=>h.current.confirm(e)}),[]),_=()=>p.current?.path??``,v=Ot(g,_),y=(0,H.useMemo)(()=>({openEntry:e=>{e.type===`directory`?n.go(e.path):ht(e)},openInNewWindow:e=>{gt(e.type===`directory`?e.path:p.current?.path??e.path)},openInTerminal:e=>{Qe(e?.type===`directory`?e.path:_())},cut:e=>Xe(e.map(e=>e.path),`cut`),copy:e=>Xe(e.map(e=>e.path),`copy`),paste:e=>void st(e??_(),g),transferInto:async(e,t,n)=>{let r=await ot(e,t,n,g);if(r.succeeded>0){let e=n===`copy`?`Copied`:`Moved`;T.success(`${e} ${r.succeeded} item${r.succeeded===1?``:`s`}`)}},uploadInto:v.uploadInto,openUploadPicker:v.openUploadPicker,openUploadFolderPicker:v.openUploadFolderPicker,supportsFolderUpload:v.supportsFolderUpload,startRename:t=>{f(null),i(e,{inlineEdit:{kind:`rename`,path:t.path,initial:t.name}})},startCreate:t=>{f(null),i(e,{inlineEdit:{kind:t,initial:``}})},cancelInline:()=>{f(null),i(e,{inlineEdit:null})},commitInline:async t=>{let n=p.current,a=n?.inlineEdit;if(!n||!a)return;let o=t.trim();if(a.kind===`rename`&&o===a.initial){i(e,{inlineEdit:null});return}let s=St(o,r);if(s){f(s);return}f(null),(a.kind===`rename`?await wt(a.path,o,n.sep):await Ct(n.path,o,a.kind===`new-folder`?`folder`:`file`,n.sep))&&i(e,{inlineEdit:null})},trash:e=>{Tt(e.map(e=>e.path),!1,p.current?.sep??`/`).then(e=>{e.needsPermanent.length>0&&c({paths:e.needsPermanent,names:e.needsPermanent.map(e=>e.split(/[/\\]/).pop()??e)})})},confirmPermanentDelete:e=>{e.length!==0&&c({paths:e.map(e=>e.path),names:e.map(e=>e.name)})},download:e=>void _t(e),copyPath:e=>void vt(e,`Path`),copyName:e=>void vt(e,`Name`),togglePin:(e,t)=>{let n=V.getState();n.isPinned(e)?n.unpin(e):n.pin({path:e,name:t})},showProperties:e=>u(e)}),[e,i,n,g,r,v]),b=(0,H.useCallback)(()=>{let e=s;c(null),e&&Tt(e.paths,!0,p.current?.sep??`/`)},[s]);return{actions:y,dialogs:{collision:a.state,pendingDelete:s,permanentOverwrite:o.state,properties:l,inlineError:d,closeDelete:()=>c(null),runPermanentDelete:b,closeProperties:()=>u(null),uploadInputs:v.uploadInputs}}}var At=e=>(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,...e,children:(0,U.jsx)(`path`,{stroke:`#64748B`,strokeWidth:`2`,d:`M7.784 5H5a2 2 0 00-2 2v10a2 2 0 002 2h14a2 2 0 002-2V9.875a2 2 0 00-2-2h-6.284a2 2 0 01-1.27-.455L9.054 5.455A2 2 0 007.783 5z`})}),jt=e=>(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,...e,children:(0,U.jsx)(`path`,{fill:`#64748B`,stroke:`#64748B`,strokeWidth:`2`,d:`M7.784 5H5a2 2 0 00-2 2v10a2 2 0 002 2h14a2 2 0 002-2V9.875a2 2 0 00-2-2h-6.284a2 2 0 01-1.27-.455L9.054 5.455A2 2 0 007.783 5z`})}),Mt=At,Nt=jt,Pt=(0,H.createContext)({closed:Mt,open:Nt}),Ft=Pt.Provider;function W({name:e,kind:t,open:n,className:r}){let i=(0,H.useContext)(Pt),o=E(`shrink-0`,r);return t===`directory`?(0,U.jsx)(n?i.open:i.closed,{className:o}):t===`symlink`?(0,U.jsx)(a,{className:E(o,`text-text-2`)}):t===`unknown`?(0,U.jsx)(h,{className:E(o,`text-text-subtle`)}):(0,U.jsx)(De,{name:e,className:o})}function It({className:e}){return(0,U.jsx)(W,{name:``,kind:`directory`,className:E(`size-4 shrink-0`,e)})}var Lt={fixed:w,removable:i,network:ut,unknown:w};function G({label:e,path:t,active:n,icon:r,onNavigate:i,onUnpin:a,run:o,uploadRun:s}){let c=L(),l=N({targetDir:t,run:o,onFiles:s});return(0,U.jsxs)(`div`,{className:`group/place relative flex items-center`,children:[(0,U.jsxs)(`button`,{type:`button`,title:t,onClick:()=>i(t),className:E(`flex w-full items-center gap-2 rounded px-2 py-1 text-left text-[13px]`,c?`min-h-[44px]`:`min-h-0`,`can-hover:hover:bg-surface-elevated`,n?`bg-accent-wash text-text`:`text-text-2`,l.isOver&&`ring-1 ring-dashed ring-primary bg-primary/10`),...l.handlers,children:[(0,U.jsx)(r,{className:`size-4 shrink-0 text-text-subtle`}),(0,U.jsx)(`span`,{className:`truncate`,children:e})]}),a&&(0,U.jsx)(`button`,{type:`button`,"aria-label":`Unpin ${e}`,title:`Unpin`,onClick:a,className:`absolute right-1 rounded p-1 text-text-subtle can-hover:opacity-0 can-hover:group-hover/place:opacity-100 can-hover:hover:text-text`,children:(0,U.jsx)(f,{className:`size-3.5`})})]})}function K({title:e,children:t}){return(0,U.jsxs)(`div`,{className:`pb-2`,children:[(0,U.jsx)(`p`,{className:`px-2 pb-0.5 pt-2 text-[10px] font-semibold uppercase tracking-wide text-text-subtle`,children:e}),t]})}var Rt={home:`Home`,pinned:`Quick access`,known:`Folders`,drives:`Drives`};function zt({host:e,currentPath:t,onNavigate:n,vocab:r=Rt}){let i=V(e=>e.pins),a=V(e=>e.unpin),o=e=>e===t,{run:s,uploadRun:c,prompts:l}=Ye(e?.sep??`/`,e?.platform);return(0,U.jsxs)(`aside`,{"aria-label":`Places`,"data-testid":`explorer-sidebar`,className:`hidden w-44 shrink-0 overflow-y-auto border-r border-border bg-[var(--x-sidebar-bg,var(--panel-2))] px-1 py-1 sm:block`,children:[i.length>0&&(0,U.jsx)(K,{title:`Pinned`,children:i.map(e=>(0,U.jsx)(G,{label:e.name,path:e.path,icon:f,active:o(e.path),onNavigate:n,onUnpin:()=>a(e.path),run:s,uploadRun:c},e.path))}),e&&e.pinned.length>0&&(0,U.jsx)(K,{title:r.pinned,children:e.pinned.map(e=>(0,U.jsx)(G,{label:e.name,path:e.path,icon:It,active:o(e.path),onNavigate:n,run:s,uploadRun:c},e.path))}),e&&(0,U.jsxs)(K,{title:r.known,children:[(0,U.jsx)(G,{label:r.home,path:e.homedir,icon:It,active:o(e.homedir),onNavigate:n,run:s,uploadRun:c}),e.knownFolders.map(e=>(0,U.jsx)(G,{label:e.name,path:e.path,icon:It,active:o(e.path),onNavigate:n,run:s,uploadRun:c},e.path))]}),e&&e.drives.length>0&&(0,U.jsx)(K,{title:r.drives,children:e.drives.map(e=>(0,U.jsx)(G,{label:e.label?`${e.label} (${e.name})`:e.name,path:e.path,icon:Lt[e.kind],active:o(e.path),onNavigate:n,run:s,uploadRun:c},e.path))}),e?.warnings.map(e=>(0,U.jsxs)(`p`,{className:`flex gap-1.5 px-2 py-1 text-[11px] leading-snug text-text-subtle`,children:[(0,U.jsx)(oe,{className:`mt-0.5 size-3 shrink-0`}),(0,U.jsx)(`span`,{children:e})]},e)),l]})}var q=new Intl.Collator(void 0,{numeric:!0,sensitivity:`base`});function Bt(e,t,n){switch(e){case`size`:return(t.size??0)-(n.size??0);case`modified`:return new Date(t.modified).getTime()-new Date(n.modified).getTime();case`kind`:{let e=q.compare(B(t.name),B(n.name));return e===0?q.compare(t.name,n.name):e}case`name`:return q.compare(t.name,n.name)}}function Vt(e,t,n){let r=t.trim().toLowerCase(),i=r?e.filter(e=>e.name.toLowerCase().includes(r)):e,a=n.dir===`asc`?1:-1;return[...i].sort((e,t)=>{let r=e.type===`directory`;if(r!==(t.type===`directory`))return r?-1:1;let i=Bt(n.key,e,t);return(i===0?q.compare(e.name,t.name):i)*a})}function Ht(e){return e.reduce((e,t)=>e+(t.type===`file`?t.size??0:0),0)}function Ut({entries:e,selection:t,truncated:n}){let r=e.filter(e=>t.has(e.path)),i=[`${e.length}${n?`+`:``} item${e.length===1?``:`s`}`];if(r.length>0){i.push(`${r.length} selected`);let e=Ht(r);e>0&&i.push(Se(e))}return(0,U.jsxs)(`div`,{"data-testid":`explorer-status`,className:`flex shrink-0 items-center gap-2 border-t border-border bg-panel-2 px-2 py-1 text-[11px] text-text-subtle`,children:[i.join(` · `),n&&(0,U.jsx)(`span`,{className:`ml-auto`,children:`Listing capped — narrow the filter to see the rest.`})]})}var Wt=3;function Gt({crumbs:e,onNavigate:t,className:n,sep:r}){let{run:i,prompts:a}=Ye(r);if(e.length===0)return(0,U.jsx)(`div`,{className:n});let o=e.length>Wt+2,s=o?e.slice(0,1):e,c=o?e.slice(1,e.length-Wt):[],u=o?e.slice(e.length-Wt):[];return(0,U.jsxs)(`nav`,{"aria-label":`Path`,className:E(`flex min-w-0 items-center gap-0.5 text-xs`,n),children:[s.map(n=>(0,U.jsxs)(`span`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,U.jsx)(Kt,{crumb:n,last:!o&&n===e[e.length-1],onNavigate:t,run:i}),(0,U.jsx)(y,{className:`size-3 shrink-0 text-text-subtle`})]},n.path)),o&&(0,U.jsxs)(ct,{children:[(0,U.jsx)(qe,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Show hidden path segments`,className:`rounded px-1 py-0.5 text-text-2 can-hover:hover:bg-surface-elevated`,children:(0,U.jsx)(l,{className:`size-3.5`})})}),(0,U.jsx)(Ge,{align:`start`,className:`max-h-72 overflow-y-auto`,children:c.map(e=>(0,U.jsx)(Le,{onClick:()=>t(e.path),children:e.name},e.path))})]}),o&&(0,U.jsx)(y,{className:`size-3 shrink-0 text-text-subtle`}),u.map((e,n)=>(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-0.5`,children:[(0,U.jsx)(Kt,{crumb:e,last:n===u.length-1,onNavigate:t,run:i}),n<u.length-1&&(0,U.jsx)(y,{className:`size-3 shrink-0 text-text-subtle`})]},e.path)),a]})}function Kt({crumb:e,last:t,onNavigate:n,run:r}){let i=N({targetDir:e.path,run:r});return(0,U.jsx)(`button`,{type:`button`,onClick:()=>n(e.path),className:E(`max-w-[12rem] truncate rounded px-1 py-0.5 can-hover:hover:bg-surface-elevated`,t?`font-medium text-text`:`text-text-2`,i.isOver&&`ring-1 ring-dashed ring-primary bg-primary/10`),...i.handlers,children:e.name})}var J=[{key:`name`,label:`Name`},{key:`size`,label:`Size`},{key:`modified`,label:`Modified`},{key:`kind`,label:`Kind`}],qt=[{dir:`asc`,label:`Ascending`},{dir:`desc`,label:`Descending`}];function Jt(e){return J.find(t=>t.key===e)?.label??e}function Yt(e){return qt.find(t=>t.dir===e)?.label??e}function Y(e){return E(`relative flex size-7 shrink-0 items-center justify-center rounded text-text-subtle can-hover:hover:bg-surface-elevated can-hover:hover:text-text disabled:opacity-30`,e&&`before:absolute before:-inset-2 before:content-['']`)}function Xt({coarse:e}){let t=R(e=>e.sort),n=R(e=>e.setPrefs),r=`Sort`,i=`${r}: ${Jt(t.key)}, ${Yt(t.dir)}`;return(0,U.jsxs)(ct,{children:[(0,U.jsx)(qe,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":r,title:i,className:Y(e),children:(0,U.jsx)(ne,{className:`size-4`})})}),(0,U.jsxs)(Ge,{align:`end`,children:[(0,U.jsx)(We,{children:`Sort by`}),(0,U.jsx)(Ke,{value:t.key,onValueChange:e=>n({sort:{key:e,dir:t.dir}}),children:J.map(({key:e,label:t})=>(0,U.jsx)(Ie,{value:e,children:t},e))}),(0,U.jsx)(Re,{}),(0,U.jsx)(We,{children:`Order`}),(0,U.jsx)(Ke,{value:t.dir,onValueChange:e=>n({sort:{key:t.key,dir:e}}),children:qt.map(({dir:e,label:t})=>(0,U.jsx)(Ie,{value:e,children:t},e))})]})]})}function X({targets:e,currentDir:t,hasClipboard:n,isPinned:r,actions:i}){let a=D(),o=e.length===1?e[0]:null,s=e.length>0&&e.every(e=>e.type===`directory`),c=e.length,l=c>1?` ${c} items`:``,u=R(e=>e.sort),d=R(e=>e.setPrefs);return c===0?(0,U.jsxs)(Ve,{children:[(0,U.jsx)(P,{onClick:()=>i.startCreate(`new-file`),children:`New File`}),(0,U.jsx)(P,{onClick:()=>i.startCreate(`new-folder`),children:`New Folder`}),(0,U.jsx)(M,{}),(0,U.jsx)(P,{disabled:!n,onClick:()=>i.paste(),children:`Paste`}),(0,U.jsx)(M,{}),(0,U.jsx)(P,{onClick:()=>i.openUploadPicker(),children:`Upload Files…`}),i.supportsFolderUpload&&(0,U.jsx)(P,{onClick:()=>i.openUploadFolderPicker(),children:`Upload Folder…`}),(0,U.jsx)(M,{}),(0,U.jsx)(P,{onClick:()=>i.openInTerminal(),children:`Open in Terminal`}),(0,U.jsx)(M,{}),(0,U.jsxs)(Be,{children:[(0,U.jsx)(Fe,{children:`Sort by`}),(0,U.jsxs)(He,{children:[(0,U.jsx)(Ne,{value:u.key,onValueChange:e=>d({sort:{key:e,dir:u.dir}}),children:J.map(({key:e,label:t})=>(0,U.jsx)(nt,{value:e,children:t},e))}),(0,U.jsx)(M,{}),(0,U.jsx)(Ne,{value:u.dir,onValueChange:e=>d({sort:{key:u.key,dir:e}}),children:qt.map(({dir:e,label:t})=>(0,U.jsx)(nt,{value:e,children:t},e))})]})]}),(0,U.jsx)(M,{}),(0,U.jsx)(P,{onClick:()=>i.copyPath([t]),children:`Copy Path`})]}):(0,U.jsxs)(Ve,{children:[o&&(o.type===`directory`||z(o.name))&&(0,U.jsx)(P,{onClick:()=>i.openEntry(o),children:`Open`}),s&&o&&!a&&(0,U.jsx)(P,{onClick:()=>i.openInNewWindow(o),children:`Open in New Window`}),s&&o&&(0,U.jsx)(P,{onClick:()=>i.openInTerminal(o),children:`Open in Terminal`}),(0,U.jsx)(M,{}),(0,U.jsxs)(P,{onClick:()=>i.cut(e),children:[`Cut`,l]}),(0,U.jsxs)(P,{onClick:()=>i.copy(e),children:[`Copy`,l]}),s&&o&&(0,U.jsx)(P,{disabled:!n,onClick:()=>i.paste(o.path),children:`Paste`}),(0,U.jsx)(M,{}),o&&(0,U.jsx)(P,{onClick:()=>i.startRename(o),children:`Rename`}),(0,U.jsxs)(P,{onClick:()=>i.trash(e),children:[`Move to Trash`,l]}),(0,U.jsx)(P,{variant:`destructive`,onClick:()=>i.confirmPermanentDelete(e),children:`Delete permanently`}),(0,U.jsx)(M,{}),(0,U.jsx)(P,{onClick:()=>i.copyPath(e.map(e=>e.path)),children:`Copy Path`}),(0,U.jsx)(P,{onClick:()=>i.copyName(e.map(e=>e.name)),children:`Copy Name`}),e.some(e=>e.type===`file`)&&(0,U.jsx)(P,{onClick:()=>i.download(e),children:`Download`}),s&&o&&(0,U.jsx)(P,{onClick:()=>i.togglePin(o.path,o.name),children:r(o.path)?`Unpin from Sidebar`:`Pin to Sidebar`}),o&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(M,{}),(0,U.jsx)(P,{onClick:()=>i.showProperties(o),children:`Properties`})]})]})}function Zt(e){let{entry:t,dragPaths:n,run:r,springLoad:i,origin:a=`explorer`,projectName:o,extraData:s,onDragStarted:c,onFiles:l}=e,u=et({paths:n,origin:a,projectName:o,extraData:s,onDragStarted:c}),d=N({targetDir:t.type===`directory`?t.path:null,run:r,springLoad:t.type===`directory`?i:void 0,onFiles:l});return{props:(0,H.useMemo)(()=>({...u,...d.handlers}),[u,d.handlers]),isDropTarget:d.isOver}}function Qt(e){return e.type===`directory`||z(e.name)?`open`:`sheet`}function $t(e){return e.startsWith(`on`)&&e.length>2&&e[2]===e[2]?.toUpperCase()}function en(e,t){return n=>{e?.(n),t?.(n)}}function tn(e,t){if(!e)return t;let n={...e};for(let[e,r]of Object.entries(t)){let t=n[e];if($t(e)&&typeof t==`function`&&typeof r==`function`){n[e]=en(t,r);continue}if(e===`style`&&t&&r){n[e]={...t,...r};continue}if(e===`className`){n[e]=E(t,r);continue}r!==void 0&&(n[e]=r)}return n}function nn({entry:e,selected:t,currentDir:n,hasClipboard:r,isPinned:i,actions:a,rowHeight:o,onSelect:s,onOpen:c}){let l=Zt({entry:e,dragPaths:[e.path],run:a.transferInto,springLoad:s,onFiles:a.uploadInto});return(0,U.jsxs)(A,{children:[(0,U.jsx)(j,{asChild:!0,children:(0,U.jsx)(rn,{entry:e,selected:t,rowHeight:o,onSelect:s,onOpen:c,dnd:l.props,dropActive:l.isDropTarget})}),(0,U.jsx)(X,{targets:[e],currentDir:n,hasClipboard:r,isPinned:i,actions:a})]})}var rn=(0,H.forwardRef)(function({entry:e,selected:t,rowHeight:n,onSelect:r,onOpen:i,dnd:a,dropActive:o,...s},c){let l=Je(r),u=D(),{setOpen:d}=(0,H.useContext)(ke),f=()=>{r(),!(!u||e.type===`directory`)&&(Qt(e)===`open`?i():d(!0))};return(0,U.jsxs)(`div`,{ref:c,...tn({...s,...l,...a},{role:`option`,"aria-selected":t,"data-testid":`explorer-column-row`,"data-path":e.path,title:e.name,style:{height:n},onContextMenu:e=>{r(),e.stopPropagation()},onClick:f,onDoubleClick:i,className:E(`flex w-full items-center gap-1.5 px-2 text-[13px] select-none`,`can-hover:hover:bg-surface-elevated`,t&&`bg-accent-wash text-text`,o&&`ring-1 ring-dashed ring-primary bg-primary/10`)}),children:[(0,U.jsx)(W,{name:e.name,kind:e.kind,className:`size-4 shrink-0`}),(0,U.jsx)(`span`,{className:E(`flex-1 truncate`,t?`text-text`:`text-text-2`),children:e.name}),e.type===`directory`&&(0,U.jsx)(`span`,{className:`text-text-subtle`,children:`›`})]})});function an({path:e,entries:t,loading:n,error:r,selectedPath:i,isFocused:a,currentDir:o,hasClipboard:s,isPinned:c,actions:l,rowHeight:u,onSelect:d,onOpen:f,onFocus:p,fullWidth:m}){let h=(0,H.useRef)(null);I(h);let g=m?48:u,_=ze({count:t.length,getScrollElement:()=>h.current,estimateSize:()=>g,overscan:8}),v=N({targetDir:e,run:l.transferInto,onFiles:l.uploadInto,disabled:m});return(0,U.jsx)(`div`,{className:E(`flex h-full shrink-0 flex-col`,!m&&`border-r border-border`,a&&`bg-panel-2/40`),style:m?void 0:{width:220},children:(0,U.jsxs)(`div`,{ref:h,role:`listbox`,"aria-label":e,className:E(`flex-1 overflow-y-auto outline-none`,v.isOver&&`ring-1 ring-dashed ring-primary bg-primary/10`),...v.handlers,children:[n&&t.length===0&&(0,U.jsx)(`p`,{className:`p-2 text-xs text-text-subtle`,children:`Loading…`}),r&&(0,U.jsx)(`p`,{className:`p-2 text-xs text-error`,children:r}),!n&&!r&&t.length===0&&(0,U.jsx)(`p`,{className:`p-2 text-xs text-text-subtle`,children:`Empty`}),(0,U.jsx)(`div`,{className:`relative w-full`,style:{height:_.getTotalSize()},children:_.getVirtualItems().map(e=>{let n=t[e.index],r=n.path===i;return(0,U.jsx)(`div`,{className:`absolute left-0 top-0 w-full`,style:{transform:`translateY(${e.start}px)`},children:(0,U.jsx)(nn,{entry:n,selected:r,currentDir:o,hasClipboard:s,isPinned:c,actions:l,rowHeight:g,onSelect:()=>{p(),d(n)},onOpen:()=>f(n)})},n.path)})})]})})}function on({containerRef:e,onKeyDown:t,backgroundLongPress:n,columns:r,focusedIndex:i,setFocusedIndex:a,selectedPathFor:o,slice:s,hasClipboard:c,isPinned:l,actions:u,onSelect:d,onOpen:f}){let p=r[i];return(0,U.jsxs)(A,{children:[(0,U.jsx)(j,{asChild:!0,children:(0,U.jsxs)(`div`,{ref:e,tabIndex:0,"data-testid":`explorer-columns`,"aria-label":`Column view`,onKeyDown:t,className:`flex h-full min-h-0 w-full flex-col outline-none`,...n,children:[i>0&&(0,U.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>e-1),"aria-label":`Back`,className:`flex h-11 shrink-0 items-center gap-1.5 border-b border-border px-3 text-sm text-text-2 active:bg-surface-elevated`,children:[(0,U.jsx)(x,{className:`size-4`}),` Back`]}),p&&(0,U.jsx)(`div`,{className:`min-h-0 flex-1 motion-safe:animate-in motion-safe:slide-in-from-right-4 motion-safe:duration-150`,children:(0,U.jsx)(an,{path:p.path,entries:p.entries,loading:p.loading,error:p.error,selectedPath:o(i),isFocused:!0,fullWidth:!0,rowHeight:48,currentDir:s.path,hasClipboard:c,isPinned:l,actions:u,onSelect:e=>d(i,e),onOpen:f,onFocus:()=>{}})},p.path)]})}),(0,U.jsx)(X,{targets:[],currentDir:s.path,hasClipboard:c,isPinned:l,actions:u})]})}var sn=0,cn=[];function ln(){return new Promise(e=>{let t=!1,n=()=>{sn++,e(()=>{if(t)return;t=!0,sn--;let e=cn.shift();e&&e()})};sn<24?n():cn.push(n)})}function un({entry:e,size:t,className:n}){let[r,i]=(0,H.useState)(null),[a,o]=(0,H.useState)(!1),s=(0,H.useRef)(null),c=(0,H.useRef)(null);return(0,H.useEffect)(()=>{i(null),o(!1)},[e.path]),(0,H.useEffect)(()=>{let t=s.current;if(!t||r||a)return;let n=new AbortController,l=null,u=new IntersectionObserver(t=>{t[0]?.isIntersecting&&(u.disconnect(),(async()=>{if(l=await ln(),n.signal.aborted){l();return}try{let t=me(),r=await fetch(`/api/fs/raw?path=${encodeURIComponent(e.path)}`,{headers:t?{Authorization:`Bearer ${t}`}:{},signal:n.signal});if(!r.ok)throw Error(String(r.status));let a=await r.blob();if(n.signal.aborted)return;let o=URL.createObjectURL(a);c.current=o,i(o)}catch{n.signal.aborted||o(!0)}finally{l?.()}})())},{rootMargin:`200px`});return u.observe(t),()=>{n.abort(),u.disconnect(),l?.()}},[e.path,r,a]),(0,H.useEffect)(()=>()=>{c.current&&URL.revokeObjectURL(c.current)},[]),a||!r?(0,U.jsx)(`div`,{ref:s,className:E(`flex items-center justify-center`,n),style:{width:t,height:t},children:(0,U.jsx)(W,{name:e.name,kind:e.kind,className:`size-1/2`})}):(0,U.jsx)(`div`,{ref:s,className:E(`flex items-center justify-center overflow-hidden`,n),style:{width:t,height:t},children:(0,U.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:`max-h-full max-w-full rounded object-contain`,onError:()=>o(!0)})})}function dn({entry:e,onOpen:t}){return e?(0,U.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col items-center gap-3 overflow-y-auto p-4 text-center`,children:[(0,U.jsx)(`div`,{className:`flex h-24 w-24 shrink-0 items-center justify-center`,children:e.type!==`directory`&&lt(e.name)===`image`?(0,U.jsx)(un,{entry:e,size:96}):(0,U.jsx)(W,{name:e.name,kind:e.kind,className:`size-16`})}),(0,U.jsx)(`p`,{className:`w-full truncate text-sm font-medium text-text`,title:e.name,children:e.name}),(0,U.jsxs)(`dl`,{className:`w-full space-y-1 text-left text-xs text-text-2`,children:[(0,U.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,U.jsx)(`dt`,{className:`text-text-subtle`,children:`Kind`}),(0,U.jsx)(`dd`,{className:`truncate`,children:e.type===`directory`?`Folder`:B(e.name)||`File`})]}),e.type!==`directory`&&(0,U.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,U.jsx)(`dt`,{className:`text-text-subtle`,children:`Size`}),(0,U.jsx)(`dd`,{children:Se(e.size)})]}),(0,U.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,U.jsx)(`dt`,{className:`text-text-subtle`,children:`Modified`}),(0,U.jsx)(`dd`,{className:`truncate`,children:we(e.modified)})]})]}),z(e.name)&&(0,U.jsx)(`button`,{type:`button`,onClick:()=>t(e),className:`mt-2 w-full rounded border border-border bg-panel-2 py-1.5 text-xs font-medium text-text can-hover:hover:bg-surface-elevated`,children:`Open`})]},e.path):(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center p-4 text-center text-xs text-text-subtle`,children:`Select a file to preview`})}function fn(e,t){switch(t.type){case`sync`:{let{paths:n,lastEntries:r,lastLoading:i,makeAbort:a}=t,o=n.length-1,s=n.map((t,n)=>{let s=e.columns[n],c=n===o;return s&&s.path===t?c?{...s,entries:r,loading:i,error:null}:s:c?{path:t,entries:r,loading:i,error:null,abort:a()}:{path:t,entries:[],loading:!0,error:null,abort:a()}}),c=[];for(let t=0;t<e.columns.length;t++){let n=e.columns[t],r=s[t];(!r||r.path!==n.path)&&c.push(n.abort)}return{columns:s,staleControllers:c}}case`loaded`:return{columns:e.columns.map(e=>e.path===t.path?{...e,entries:t.entries,loading:!1,error:null}:e),staleControllers:[]};case`error`:return{columns:e.columns.map(e=>e.path===t.path?{...e,loading:!1,error:t.message}:e),staleControllers:[]}}}function pn(e,t,n){let[r,i]=(0,H.useReducer)(fn,{columns:[],staleControllers:[]}),a=(0,H.useRef)(new Set);(0,H.useEffect)(()=>{i({type:`sync`,paths:e,lastEntries:t,lastLoading:n,makeAbort:()=>new AbortController})},[e.join(`\0`),t,n]),(0,H.useEffect)(()=>{for(let e of r.staleControllers)e.abort()},[r.staleControllers]);let o=(0,H.useRef)(r.columns);return o.current=r.columns,(0,H.useEffect)(()=>()=>{for(let e of o.current)e.abort.abort()},[]),(0,H.useEffect)(()=>{let e=r.columns.length-1;r.columns.forEach((t,n)=>{n!==e&&(!t.loading||a.current.has(t.abort)||(a.current.add(t.abort),O.browse(t.path,{signal:t.abort.signal}).then(e=>{a.current.delete(t.abort),!t.abort.signal.aborted&&i({type:`loaded`,path:t.path,entries:e.entries})}).catch(e=>{a.current.delete(t.abort),!(t.abort.signal.aborted||e instanceof DOMException&&e.name===`AbortError`)&&i({type:`error`,path:t.path,message:e instanceof Error?e.message:`Failed to read directory`})})))})},[r.columns]),{columns:r.columns}}var mn=720;function hn({slice:e,entries:t,actions:n,selection:r,hasClipboard:i,isPinned:a,nav:o,backgroundLongPress:s,rowHeight:c}){let{columns:l}=pn((0,H.useMemo)(()=>e.breadcrumbs.length>0?e.breadcrumbs.map(e=>e.path):[e.path],[e.breadcrumbs,e.path]),t,e.loading),u=D(),d=(0,H.useRef)(null);I(d);let[f,p]=(0,H.useState)(l.length-1),[m,h]=(0,H.useState)(0),g=(0,H.useRef)(l.length);(0,H.useEffect)(()=>{let e=d.current;if(!e)return;let t=()=>h(e.clientWidth);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),(0,H.useEffect)(()=>{if(l.length===g.current)return;g.current=l.length,p(l.length-1);let e=d.current;if(!e)return;let t=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches===!0;e.scrollTo({left:e.scrollWidth,behavior:t?`auto`:`smooth`})},[l.length]);let _=(0,H.useMemo)(()=>{if(!e.anchor)return null;for(let t of l){let n=t.entries.find(t=>t.path===e.anchor);if(n)return n}return null},[l,e.anchor]),v=t=>t===l.length-1?e.anchor:l[t+1]?.path??null,y=e=>{let t=l[e];if(!t)return null;let n=v(e);return t.entries.find(e=>e.path===n)??null},b=(e,t)=>{p(e),t.type===`directory`?o.go(t.path):r.selectOnly(t.path)},x=e=>n.openEntry(e),S=e=>{if(!(e.altKey||e.ctrlKey||e.metaKey)){if(e.key===`ArrowRight`&&f<l.length-1){e.preventDefault(),e.stopPropagation(),p(f+1);return}if(e.key===`ArrowLeft`&&f>0){e.preventDefault(),e.stopPropagation(),p(f-1);return}if(e.key===`ArrowUp`||e.key===`ArrowDown`){let t=l[f];if(!t)return;e.preventDefault(),e.stopPropagation();let n=y(f),r=n?t.entries.findIndex(e=>e.path===n.path):-1,i=e.key===`ArrowDown`?1:-1,a=Math.min(t.entries.length-1,Math.max(0,r<0?0:r+i)),o=t.entries[a];o&&b(f,o);return}if(e.key===`Enter`){let t=y(f);t&&(e.preventDefault(),e.stopPropagation(),x(t))}}},C=m>=mn;return u?(0,U.jsx)(on,{containerRef:d,onKeyDown:S,backgroundLongPress:s,columns:l,focusedIndex:f,setFocusedIndex:p,selectedPathFor:v,slice:e,hasClipboard:i,isPinned:a,actions:n,onSelect:b,onOpen:x}):(0,U.jsxs)(A,{children:[(0,U.jsx)(j,{asChild:!0,children:(0,U.jsxs)(`div`,{ref:d,tabIndex:0,"data-testid":`explorer-columns`,"aria-label":`Column view`,onKeyDown:S,className:`flex h-full min-h-0 w-full overflow-x-auto outline-none`,...s,children:[l.map((t,r)=>(0,U.jsx)(an,{path:t.path,entries:t.entries,loading:t.loading,error:t.error,selectedPath:v(r),isFocused:r===f,currentDir:e.path,hasClipboard:i,isPinned:a,actions:n,rowHeight:c,onSelect:e=>b(r,e),onOpen:x,onFocus:()=>p(r)},t.path)),C&&(0,U.jsx)(`div`,{className:`min-w-[240px] flex-1 border-l border-border bg-panel-2/30`,children:(0,U.jsx)(dn,{entry:_,onOpen:x})})]})}),(0,U.jsx)(X,{targets:[],currentDir:e.path,hasClipboard:i,isPinned:a,actions:n})]})}function Z(e,t){if(e.selection.size>0)return t.filter(t=>e.selection.has(t.path));let n=t.find(t=>t.path===e.anchor);return n?[n]:[]}function gn({slice:e,entries:t,actions:n,selection:r,nav:i}){return(0,H.useCallback)(a=>{if(!e)return;let o=a.target;if(o.tagName===`INPUT`||o.tagName===`TEXTAREA`||o.isContentEditable)return;let s=a.ctrlKey||a.metaKey,c=Z(e,t);if(s)switch(a.key.toLowerCase()){case`a`:a.preventDefault(),r.selectAll();return;case`c`:a.preventDefault(),n.copy(c);return;case`x`:a.preventDefault(),n.cut(c);return;case`v`:a.preventDefault(),n.paste();return;default:return}switch(a.key){case`ArrowDown`:a.preventDefault(),r.moveTo(1,a.shiftKey);return;case`ArrowUp`:a.preventDefault(),r.moveTo(-1,a.shiftKey);return;case`Home`:a.preventDefault(),t[0]&&r.selectOnly(t[0].path);return;case`End`:a.preventDefault(),t.length>0&&r.selectOnly(t[t.length-1].path);return;case`ArrowLeft`:a.altKey&&(a.preventDefault(),i.back());return;case`ArrowRight`:a.altKey&&(a.preventDefault(),i.forward());return;case`Backspace`:a.preventDefault(),i.back();return;case`Enter`:a.preventDefault(),c.length===1&&n.openEntry(c[0]);return;case`F2`:a.preventDefault(),c.length===1&&n.startRename(c[0]);return;case`Delete`:if(a.preventDefault(),c.length===0)return;a.shiftKey?n.confirmPermanentDelete(c):n.trash(c);return;case`Escape`:r.clear();return}a.key.length===1&&!a.altKey&&(a.preventDefault(),r.typeAhead(a.key))},[e,t,n,r,i])}function _n(e,t){let n=D(),r=F(e=>e.selectMode),{setOpen:i}=(0,H.useContext)(ke);return{isMobile:n,selectMode:r,handleTap:(a,o)=>n?r?(t.onRowClick(a.path,{shiftKey:!1,ctrlKey:!0,metaKey:!1}),!0):(o||t.selectOnly(a.path),Qt(a)===`open`?e.openEntry(a):i(!0),!0):!1}}function vn({initial:e,error:t,onCommit:n,onCancel:r,className:i}){let[a,o]=(0,H.useState)(e),s=(0,H.useRef)(null);return(0,H.useEffect)(()=>{let t=s.current;if(!t)return;t.focus();let n=e.lastIndexOf(`.`);n>0?t.setSelectionRange(0,n):t.select()},[e]),(0,U.jsxs)(`div`,{className:`relative flex-1 min-w-0`,children:[(0,U.jsx)(`input`,{ref:s,value:a,"aria-label":`Name`,"aria-invalid":!!t,onChange:e=>o(e.target.value),onBlur:()=>n(a),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?n(a):e.key===`Escape`&&r()},className:E(`w-full rounded-[var(--rad-sm)] border bg-panel px-1.5 py-0.5 text-[13px] text-text outline-none`,t?`border-error`:`border-primary`,i)}),t&&(0,U.jsx)(`span`,{className:`absolute left-0 top-full z-10 mt-0.5 rounded border border-border bg-panel-2 px-1.5 py-0.5 text-[11px] text-error shadow-sm`,children:t})]})}var yn=(0,H.memo)(function(e){let{entry:t,currentDir:n,hasClipboard:r,isPinned:i,actions:a,menuTargets:o}=e,s=Zt({entry:t,dragPaths:(0,H.useMemo)(()=>o.map(e=>e.path),[o]),run:a.transferInto,onFiles:a.uploadInto});return(0,U.jsxs)(A,{children:[(0,U.jsx)(j,{asChild:!0,children:(0,U.jsx)(bn,{...e,dnd:s.props,dropActive:s.isDropTarget})}),(0,U.jsx)(X,{targets:o,currentDir:n,hasClipboard:r,isPinned:i,actions:a})]})}),bn=(0,H.forwardRef)(function({entry:e,selected:t,focused:n,cut:r,renaming:i,tileWidth:a,actions:o,selection:s,inlineError:c,currentDir:l,hasClipboard:u,isPinned:d,menuTargets:f,dnd:p,dropActive:m,...h},g){let _=Je(()=>{t||s.selectOnly(e.path)}),{isMobile:v,selectMode:y,handleTap:b}=_n(o,s),x=e.type!==`directory`&&lt(e.name)===`image`;return(0,U.jsxs)(`div`,{ref:g,...tn({...h,..._,...p},{role:`gridcell`,"aria-selected":t,"data-testid":`explorer-tile`,"data-path":e.path,title:e.name,style:a?{width:a}:void 0,onContextMenu:n=>{t||s.selectOnly(e.path),n.stopPropagation()},onClick:n=>{b(e,t)||s.onRowClick(e.path,n)},onDoubleClick:()=>o.openEntry(e),className:E(`relative flex flex-col items-center gap-1 rounded p-2 text-center select-none`,!a&&`w-full`,`can-hover:hover:bg-surface-elevated`,n&&!t&&`bg-surface-elevated`,t&&`bg-accent-wash`,r&&`opacity-40`,m&&`ring-1 ring-dashed ring-primary bg-primary/10`)}),children:[v&&y&&(0,U.jsx)(`span`,{"aria-hidden":!0,className:E(`absolute left-1.5 top-1.5 flex size-5 items-center justify-center rounded border`,t?`border-primary bg-primary text-primary-foreground`:`border-border bg-panel`),children:t&&(0,U.jsx)(de,{className:`size-3.5`})}),(0,U.jsx)(`div`,{className:`flex h-12 w-12 shrink-0 items-center justify-center`,children:x?(0,U.jsx)(un,{entry:e,size:48}):(0,U.jsx)(W,{name:e.name,kind:e.kind,className:`size-12`})}),i?(0,U.jsx)(vn,{initial:e.name,error:c,onCommit:e=>void o.commitInline(e),onCancel:o.cancelInline}):(0,U.jsx)(`span`,{className:E(`line-clamp-2 w-full break-words text-[12px] leading-tight`,t?`text-text`:`text-text-2`),children:e.name})]})}),xn=96,Sn=88,Cn=4,wn=16,Tn=3;function En({slice:e,entries:t,actions:n,selection:r,inlineError:i,hasClipboard:a,isPinned:o,backgroundLongPress:s}){let c=ve(e=>e.clipboard?.operation===`cut`?e.clipboard.paths:null),l=(0,H.useRef)(null);I(l);let u=D(),[d,f]=(0,H.useState)(u?Tn:1);(0,H.useEffect)(()=>{if(u){f(Tn);return}let e=l.current;if(!e)return;let t=()=>{let t=e.clientWidth-wn+Cn;f(Math.max(1,Math.floor(t/(xn+Cn))))};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[u]);let p=ze({count:Math.ceil(t.length/d),getScrollElement:()=>l.current,estimateSize:()=>Sn,overscan:4}),m=e.anchor?t.findIndex(t=>t.path===e.anchor):-1,h=m>=0?Math.floor(m/d):-1;(0,H.useEffect)(()=>{h>=0&&p.scrollToIndex(h,{align:`auto`})},[h]);let g=(0,H.useMemo)(()=>Z(e,t),[e,t]),_=e.inlineEdit?.kind===`new-file`||e.inlineEdit?.kind===`new-folder`,v=N({targetDir:e.path,run:n.transferInto,onFiles:n.uploadInto}),y=e=>{if(!(e.altKey||e.ctrlKey||e.metaKey))switch(e.key){case`ArrowDown`:e.preventDefault(),e.stopPropagation(),r.moveTo(d,e.shiftKey);return;case`ArrowUp`:e.preventDefault(),e.stopPropagation(),r.moveTo(-d,e.shiftKey);return;case`ArrowLeft`:e.preventDefault(),e.stopPropagation(),r.moveTo(-1,e.shiftKey);return;case`ArrowRight`:e.preventDefault(),e.stopPropagation(),r.moveTo(1,e.shiftKey);return}};return(0,U.jsxs)(A,{children:[(0,U.jsx)(j,{asChild:!0,children:(0,U.jsxs)(`div`,{ref:l,role:`grid`,tabIndex:0,"data-testid":`explorer-icons`,"aria-label":`File icons`,onKeyDown:y,onMouseDown:e=>{e.target===e.currentTarget&&r.clear()},className:E(`h-full flex-1 overflow-auto p-2 outline-none`,v.isOver&&`ring-1 ring-dashed ring-primary bg-primary/10`),...s,...v.handlers,children:[_&&(0,U.jsx)(`div`,{className:`mb-2 flex flex-col items-center gap-1 p-2`,style:u?void 0:{width:xn},children:(0,U.jsx)(vn,{initial:``,error:i,onCommit:e=>void n.commitInline(e),onCancel:n.cancelInline})}),(0,U.jsx)(`div`,{className:`relative w-full`,style:{height:p.getTotalSize()},children:p.getVirtualItems().map(s=>{let l=s.index*d,f=t.slice(l,l+d);return(0,U.jsx)(`div`,{role:`row`,className:E(`absolute left-0 top-0 w-full gap-1`,u?`grid grid-cols-3`:`flex`),style:{transform:`translateY(${s.start}px)`},children:f.map(t=>(0,U.jsx)(yn,{entry:t,currentDir:e.path,selected:e.selection.has(t.path),focused:e.anchor===t.path,cut:c?.includes(t.path)===!0,renaming:e.inlineEdit?.kind===`rename`&&e.inlineEdit.path===t.path,tileWidth:u?void 0:xn,menuTargets:e.selection.has(t.path)?g:[t],actions:n,selection:r,hasClipboard:a,isPinned:o,inlineError:i},t.path))},s.index)})}),t.length===0&&!e.loading&&!_&&(0,U.jsx)(`p`,{className:`p-3 text-xs text-text-subtle`,children:e.filter?`No entries match the filter.`:`This folder is empty.`})]})}),(0,U.jsx)(X,{targets:[],currentDir:e.path,hasClipboard:a,isPinned:o,actions:n})]})}var Dn=(0,H.memo)(function(e){let{entry:t,currentDir:n,hasClipboard:r,isPinned:i,actions:a,menuTargets:o}=e,s=Zt({entry:t,dragPaths:(0,H.useMemo)(()=>o.map(e=>e.path),[o]),run:a.transferInto,onFiles:a.uploadInto});return(0,U.jsxs)(A,{children:[(0,U.jsx)(j,{asChild:!0,children:(0,U.jsx)(On,{...e,dnd:s.props,dropActive:s.isDropTarget})}),(0,U.jsx)(X,{targets:o,currentDir:n,hasClipboard:r,isPinned:i,actions:a})]})}),On=(0,H.forwardRef)(function({entry:e,selected:t,focused:n,cut:r,renaming:i,height:a,actions:o,selection:s,inlineError:c,currentDir:l,hasClipboard:u,isPinned:d,menuTargets:f,dnd:p,dropActive:m,...h},g){let _=Je(()=>{t||s.selectOnly(e.path)}),{isMobile:v,selectMode:y,handleTap:b}=_n(o,s);return(0,U.jsxs)(`div`,{ref:g,...tn({...h,..._,...p},{role:`row`,"aria-selected":t,"data-testid":`explorer-row`,"data-path":e.path,title:e.name,style:{height:a},onContextMenu:n=>{t||s.selectOnly(e.path),n.stopPropagation()},onClick:n=>{b(e,t)||s.onRowClick(e.path,n)},onDoubleClick:()=>o.openEntry(e),className:E(`flex w-full items-center gap-2 px-2 text-[13px] select-none`,`can-hover:hover:bg-surface-elevated`,n&&!t&&`bg-surface-elevated`,t&&`bg-accent-wash`,r&&`opacity-40`,m&&`ring-1 ring-dashed ring-primary bg-primary/10`)}),children:[v&&y&&(0,U.jsx)(`span`,{"aria-hidden":!0,className:E(`flex size-5 shrink-0 items-center justify-center rounded border`,t?`border-primary bg-primary text-primary-foreground`:`border-border`),children:t&&(0,U.jsx)(de,{className:`size-3.5`})}),(0,U.jsx)(W,{name:e.name,kind:e.kind,className:`size-4`}),i?(0,U.jsx)(vn,{initial:e.name,error:c,onCommit:e=>void o.commitInline(e),onCancel:o.cancelInline}):(0,U.jsx)(`span`,{className:E(`flex-1 truncate`,t?`text-text`:`text-text-2`),children:e.name}),(0,U.jsx)(`span`,{className:`w-20 shrink-0 text-right tabular-nums text-text-subtle`,children:e.type===`directory`?``:Se(e.size)}),(0,U.jsx)(`span`,{className:`hidden w-24 shrink-0 text-right text-text-subtle sm:inline`,children:ye(e.modified)}),(0,U.jsx)(`span`,{className:`hidden w-16 shrink-0 truncate text-right text-text-subtle md:inline`,children:e.type===`directory`?`Folder`:B(e.name)||`File`})]})}),kn={name:`flex-1 text-left`,size:`w-20 text-right`,modified:`hidden w-24 text-right sm:block`,kind:`hidden w-16 text-right md:block`},An=J.map(e=>({...e,className:kn[e.key]}));function jn({slice:e,entries:t,actions:n,selection:r,inlineError:i,hasClipboard:a,isPinned:o,rowHeight:l,backgroundLongPress:u}){let d=R(e=>e.sort),f=R(e=>e.setPrefs),p=ve(e=>e.clipboard?.operation===`cut`?e.clipboard.paths:null),m=(0,H.useRef)(null);I(m);let h=$e(),g=L(),_=ze({count:t.length,getScrollElement:()=>m.current,estimateSize:()=>l,overscan:12}),v=e.anchor?t.findIndex(t=>t.path===e.anchor):-1;(0,H.useEffect)(()=>{v>=0&&_.scrollToIndex(v,{align:`auto`})},[v]);let y=(0,H.useMemo)(()=>Z(e,t),[e,t]),b=e.inlineEdit?.kind===`new-file`||e.inlineEdit?.kind===`new-folder`,x=N({targetDir:e.path,run:n.transferInto,onFiles:n.uploadInto}),S=e=>f({sort:{key:e,dir:d.key===e&&d.dir===`asc`?`desc`:`asc`}});return(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,U.jsx)(`div`,{role:`row`,className:E(`flex shrink-0 items-center gap-2 border-b border-border bg-[var(--x-toolbar-bg,var(--panel-2))] px-2 py-1 text-[11px] font-medium text-text-subtle`,h.id===`windows`&&`divide-x divide-border`),children:An.map(e=>(0,U.jsxs)(`button`,{type:`button`,"aria-label":`Sort by ${e.label}`,onClick:()=>S(e.key),className:E(`relative flex items-center gap-0.5 can-hover:hover:text-text`,h.id===`windows`&&e.key!==`name`&&`pl-2`,e.className,e.key!==`name`&&`justify-end`,g&&`before:absolute before:-inset-x-2 before:-inset-y-3 before:content-['']`),children:[e.label,d.key===e.key&&(d.dir===`asc`?(0,U.jsx)(s,{className:`size-3`}):(0,U.jsx)(c,{className:`size-3`}))]},e.key))}),(0,U.jsxs)(A,{children:[(0,U.jsx)(j,{asChild:!0,children:(0,U.jsxs)(`div`,{ref:m,role:`grid`,tabIndex:0,"data-testid":`explorer-list`,"aria-label":`File list`,onMouseDown:e=>{e.target===e.currentTarget&&r.clear()},className:E(`flex-1 overflow-auto outline-none`,x.isOver&&`ring-1 ring-dashed ring-primary bg-primary/10`),...u,...x.handlers,children:[b&&(0,U.jsxs)(`div`,{className:`flex items-center gap-2 px-2`,style:{height:l},children:[(0,U.jsx)(`span`,{className:`size-4 shrink-0`}),(0,U.jsx)(vn,{initial:``,error:i,onCommit:e=>void n.commitInline(e),onCancel:n.cancelInline})]}),(0,U.jsx)(`div`,{className:`relative w-full`,style:{height:_.getTotalSize()},children:_.getVirtualItems().map(s=>{let c=t[s.index];return(0,U.jsx)(`div`,{className:E(`absolute left-0 top-0 w-full`,h.id===`macos`&&s.index%2==1&&`bg-panel-2/40`),style:{transform:`translateY(${s.start}px)`},children:(0,U.jsx)(Dn,{entry:c,currentDir:e.path,selected:e.selection.has(c.path),focused:e.anchor===c.path,cut:p?.includes(c.path)===!0,renaming:e.inlineEdit?.kind===`rename`&&e.inlineEdit.path===c.path,height:l,menuTargets:e.selection.has(c.path)?y:[c],actions:n,selection:r,hasClipboard:a,isPinned:o,inlineError:i})},c.path)})}),t.length===0&&!e.loading&&!b&&(0,U.jsx)(`p`,{className:`p-3 text-xs text-text-subtle`,children:e.filter?`No entries match the filter.`:`This folder is empty.`})]})}),(0,U.jsx)(X,{targets:[],currentDir:e.path,hasClipboard:a,isPinned:o,actions:n})]})]})}var Mn={list:jn,icons:En,columns:hn},Nn=Object.keys(Mn);function Pn(e){return Mn[e]??jn}var Fn={list:_,icons:r,columns:ce},In={list:`List view`,icons:`Icons view`,columns:`Column view`};function Ln({windowId:e,slice:t,nav:n,actions:r}){let i=R(e=>e.patch),a=R(e=>e.showHidden),s=R(e=>e.viewMode),c=R(e=>e.setPrefs),[l,u]=(0,H.useState)(!1),[f,p]=(0,H.useState)(t.path);(0,H.useEffect)(()=>p(t.path),[t.path]);let h=L();return(0,U.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1 border-b border-border bg-[var(--x-toolbar-bg,var(--panel-2))] px-1.5 py-1`,children:[(0,U.jsx)(`button`,{type:`button`,"aria-label":`Back`,title:`Back`,disabled:!n.canGoBack,onClick:n.back,className:Y(h),children:(0,U.jsx)(x,{className:`size-4`})}),(0,U.jsx)(`button`,{type:`button`,"aria-label":`Forward`,title:`Forward`,disabled:!n.canGoForward,onClick:n.forward,className:Y(h),children:(0,U.jsx)(le,{className:`size-4`})}),(0,U.jsx)(`button`,{type:`button`,"aria-label":`Up one level`,title:`Up`,disabled:!t.parent,onClick:n.up,className:Y(h),children:(0,U.jsx)(g,{className:`size-4`})}),(0,U.jsx)(`button`,{type:`button`,"aria-label":`Refresh`,title:`Refresh`,onClick:n.refresh,className:Y(h),children:(0,U.jsx)(d,{className:E(`size-4`,t.loading&&`animate-spin`)})}),(0,U.jsxs)(`div`,{className:`flex min-w-[8rem] flex-1 items-center gap-1 rounded border border-border bg-panel px-1`,children:[l?(0,U.jsx)(`input`,{autoFocus:!0,"aria-label":`Path`,value:f,onChange:e=>p(e.target.value),onBlur:()=>u(!1),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?(n.go(f.trim()),u(!1)):e.key===`Escape`&&(p(t.path),u(!1))},className:`min-w-0 flex-1 bg-transparent py-1 font-mono text-xs text-text outline-none`}):(0,U.jsx)(Gt,{crumbs:t.breadcrumbs,onNavigate:n.go,sep:t.sep,className:`flex-1 overflow-hidden py-0.5`}),(0,U.jsx)(`button`,{type:`button`,"aria-label":l?`Show breadcrumb`:`Edit path`,title:l?`Show breadcrumb`:`Edit path`,onClick:()=>u(e=>!e),className:Y(h),children:(0,U.jsx)(m,{className:`size-3.5`})})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1 rounded border border-border bg-panel px-1`,children:[(0,U.jsx)(v,{className:`size-3.5 shrink-0 text-text-subtle`}),(0,U.jsx)(`input`,{"aria-label":`Filter entries`,placeholder:`Filter`,value:t.filter,onChange:t=>i(e,{filter:t.target.value}),onKeyDown:t=>{t.stopPropagation(),t.key===`Escape`&&i(e,{filter:``})},className:`w-24 min-w-0 bg-transparent py-1 text-xs text-text outline-none placeholder:text-text-subtle`}),t.filter&&(0,U.jsx)(`button`,{type:`button`,"aria-label":`Clear filter`,onClick:()=>i(e,{filter:``}),className:Y(h),children:(0,U.jsx)(o,{className:`size-3.5`})})]}),Nn.length>1&&Nn.map(e=>{let t=Fn[e];return(0,U.jsx)(`button`,{type:`button`,"aria-label":In[e],title:In[e],"aria-pressed":s===e,onClick:()=>c({viewMode:e}),className:E(Y(h),s===e&&`bg-accent-wash text-primary`),children:(0,U.jsx)(t,{className:`size-4`})},e)}),(0,U.jsx)(Xt,{coarse:h}),r.supportsFolderUpload?(0,U.jsxs)(ct,{children:[(0,U.jsx)(qe,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Upload`,title:`Upload`,className:Y(h),children:(0,U.jsx)(b,{className:`size-4`})})}),(0,U.jsxs)(Ge,{align:`end`,children:[(0,U.jsx)(Le,{onClick:()=>r.openUploadPicker(),children:`Upload Files…`}),(0,U.jsx)(Le,{onClick:()=>r.openUploadFolderPicker(),children:`Upload Folder…`})]})]}):(0,U.jsx)(`button`,{type:`button`,"aria-label":`Upload`,title:`Upload`,onClick:()=>r.openUploadPicker(),className:Y(h),children:(0,U.jsx)(b,{className:`size-4`})}),(0,U.jsx)(`button`,{type:`button`,"aria-label":a?`Hide hidden files`:`Show hidden files`,title:a?`Hide hidden files`:`Show hidden files`,"aria-pressed":a,onClick:()=>c({showHidden:!a}),className:E(Y(h),a&&`bg-accent-wash text-primary`),children:a?(0,U.jsx)(S,{className:`size-4`}):(0,U.jsx)(ue,{className:`size-4`})})]})}var Rn={list:_,icons:r,columns:ce},zn={list:`List`,icons:`Icons`,columns:`Columns`};function Bn(e){return{name:e.breadcrumbs[e.breadcrumbs.length-1]?.name??e.path,path:e.path,type:`directory`,kind:`directory`,modified:``}}function Vn({open:e,onClose:t,slice:n,actions:r,entries:i}){let a=R(e=>e.viewMode),o=R(e=>e.sort),s=R(e=>e.showHidden),c=R(e=>e.setPrefs),l=Z(n,i);return(0,U.jsxs)(je,{open:e,onClose:t,className:`p-2`,children:[(0,U.jsx)(Ae,{children:`View`}),(0,U.jsx)(`div`,{className:`flex gap-1 px-2 pb-2`,children:Nn.map(e=>{let n=Rn[e];return(0,U.jsxs)(`button`,{type:`button`,"aria-pressed":a===e,onClick:()=>{c({viewMode:e}),t()},className:E(`flex flex-1 flex-col items-center gap-1 rounded-lg py-2 text-xs active:bg-surface-elevated`,a===e?`bg-accent-wash text-primary`:`text-text-2`),children:[(0,U.jsx)(n,{className:`size-4`}),zn[e]]},e)})}),(0,U.jsx)(Oe,{}),(0,U.jsx)(Ae,{children:`Sort by`}),(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1 px-2 pb-2`,children:J.map(({key:e,label:n})=>(0,U.jsxs)(`button`,{type:`button`,"aria-pressed":o.key===e,onClick:()=>{c({sort:{key:e,dir:o.key===e&&o.dir===`asc`?`desc`:`asc`}}),t()},className:E(`inline-flex min-h-11 items-center justify-center rounded-full border px-3 py-1.5 text-xs active:bg-surface-elevated`,o.key===e?`border-primary bg-accent-wash text-text`:`border-border text-text-2`),children:[n,o.key===e?o.dir===`asc`?` ↑`:` ↓`:``]},e))}),(0,U.jsx)(Oe,{}),(0,U.jsxs)(k,{onClick:()=>c({showHidden:!s}),children:[s?(0,U.jsx)(S,{className:`size-4`}):(0,U.jsx)(ue,{className:`size-4`}),s?`Hide hidden files`:`Show hidden files`]}),(0,U.jsx)(Oe,{}),(0,U.jsxs)(k,{variant:`destructive`,disabled:l.length===0,onClick:()=>r.confirmPermanentDelete(l),children:[(0,U.jsx)(fe,{className:`size-4`}),`Delete permanently`,l.length>1?` (${l.length})`:``]}),(0,U.jsxs)(k,{onClick:()=>r.showProperties(Bn(n)),children:[(0,U.jsx)(ae,{className:`size-4`}),`Properties of this folder`]})]})}function Q({icon:e,label:t,onClick:n,disabled:r,destructive:i}){return(0,U.jsxs)(`button`,{type:`button`,"aria-label":t,title:t,disabled:r,onClick:n,className:`flex min-w-[44px] flex-1 flex-col items-center gap-0.5 rounded-lg py-1.5 text-[10px] active:bg-surface-elevated disabled:opacity-30 ${i?`text-error`:`text-text-2`}`,children:[(0,U.jsx)(e,{className:`size-5`}),(0,U.jsx)(`span`,{className:`truncate`,children:t})]})}function Hn({slice:e,nav:t,actions:n,entries:r,hasClipboard:i}){let a=F(e=>e.selectMode),s=F(e=>e.setSelectMode),[c,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(!1),m=r.filter(t=>e.selection.has(t.path));return a?(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-t border-border px-1 py-1`,children:[(0,U.jsx)(Q,{icon:o,label:`Cancel`,onClick:()=>{s(!1)}}),(0,U.jsxs)(`span`,{className:`px-1 text-xs text-text-subtle`,children:[m.length,` selected`]}),(0,U.jsx)(`div`,{className:`flex-1`}),(0,U.jsx)(Q,{icon:ee,label:`Cut`,disabled:m.length===0,onClick:()=>n.cut(m)}),(0,U.jsx)(Q,{icon:te,label:`Copy`,disabled:m.length===0,onClick:()=>n.copy(m)}),(0,U.jsx)(Q,{icon:fe,label:`Trash`,disabled:m.length===0,destructive:!0,onClick:()=>n.trash(m)}),(0,U.jsx)(Q,{icon:se,label:`Download`,disabled:!m.some(e=>e.type===`file`),onClick:()=>n.download(m)}),m.length===1&&(0,U.jsx)(Q,{icon:ae,label:`Info`,onClick:()=>n.showProperties(m[0])})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-t border-border px-1 py-1`,children:[(0,U.jsx)(Q,{icon:x,label:`Back`,disabled:!t.canGoBack,onClick:t.back}),(0,U.jsx)(Q,{icon:ie,label:`New`,onClick:()=>d(!0)}),(0,U.jsx)(Q,{icon:re,label:`Paste`,disabled:!i,onClick:()=>n.paste()}),(0,U.jsx)(Q,{icon:de,label:`Select`,onClick:()=>s(!0)}),(0,U.jsx)(Q,{icon:l,label:`More`,onClick:()=>p(!0)})]}),(0,U.jsxs)(je,{open:c,onClose:()=>d(!1),className:`p-2`,children:[(0,U.jsxs)(k,{onClick:()=>n.startCreate(`new-file`),children:[(0,U.jsx)(C,{className:`size-4`}),` New File`]}),(0,U.jsxs)(k,{onClick:()=>n.startCreate(`new-folder`),children:[(0,U.jsx)(u,{className:`size-4`}),` New Folder`]}),(0,U.jsxs)(k,{onClick:()=>{d(!1),n.openUploadPicker()},children:[(0,U.jsx)(b,{className:`size-4`}),` Upload Files…`]})]}),(0,U.jsx)(Vn,{open:f,onClose:()=>p(!1),slice:e,actions:n,entries:r})]})}function Un(e){return e.breadcrumbs[e.breadcrumbs.length-1]?.name??e.path}function Wn({slice:e,onClose:t}){return(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border px-3 py-2.5`,children:[(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[15px] font-semibold text-text`,children:Un(e)}),(0,U.jsx)(`button`,{type:`button`,"aria-label":`Close file explorer`,title:`Close`,onClick:t,className:`flex size-11 shrink-0 items-center justify-center rounded-full text-text-2 active:bg-surface-elevated`,children:(0,U.jsx)(o,{className:`size-5`})})]})}var Gn=`size-4 shrink-0 text-text-subtle`,Kn={fixed:w,removable:i,network:ut,unknown:w};function qn(){return(0,U.jsx)(W,{name:``,kind:`directory`,className:Gn})}function $({label:e,path:t,active:n,icon:r,onNavigate:i}){return(0,U.jsxs)(`button`,{type:`button`,title:t,onClick:()=>i(t),className:E(`flex min-h-[44px] w-full items-center gap-2.5 rounded-lg px-3 text-left text-sm active:bg-surface-elevated`,n?`bg-accent-wash text-text`:`text-text-2`),children:[r,(0,U.jsx)(`span`,{className:`truncate`,children:e})]})}function Jn({title:e,children:t}){return(0,U.jsxs)(`div`,{className:`pb-2`,children:[(0,U.jsx)(`p`,{className:`px-3 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-wide text-text-subtle`,children:e}),t]})}function Yn({open:e,onClose:t,host:n,currentPath:r,vocab:i,onNavigate:a}){let o=V(e=>e.pins),s=e=>e===r;return(0,U.jsx)(je,{open:e,onClose:t,zIndex:65,className:`p-1`,children:(0,U.jsxs)(`div`,{className:`max-h-[70vh] overflow-y-auto px-1 pb-2`,children:[o.length>0&&(0,U.jsx)(Jn,{title:`Pinned`,children:o.map(e=>(0,U.jsx)($,{label:e.name,path:e.path,icon:(0,U.jsx)(f,{className:Gn}),active:s(e.path),onNavigate:a},e.path))}),n&&n.pinned.length>0&&(0,U.jsx)(Jn,{title:i.pinned,children:n.pinned.map(e=>(0,U.jsx)($,{label:e.name,path:e.path,icon:qn(),active:s(e.path),onNavigate:a},e.path))}),n&&(0,U.jsxs)(Jn,{title:i.known,children:[(0,U.jsx)($,{label:i.home,path:n.homedir,icon:qn(),active:s(n.homedir),onNavigate:a}),n.knownFolders.map(e=>(0,U.jsx)($,{label:e.name,path:e.path,icon:qn(),active:s(e.path),onNavigate:a},e.path))]}),n&&n.drives.length>0&&(0,U.jsx)(Jn,{title:i.drives,children:n.drives.map(e=>{let t=Kn[e.kind];return(0,U.jsx)($,{label:e.label?`${e.label} (${e.name})`:e.name,path:e.path,icon:(0,U.jsx)(t,{className:Gn}),active:s(e.path),onNavigate:a},e.path)})})]})})}function Xn({className:e}){return(0,U.jsx)(W,{name:``,kind:`directory`,className:e})}var Zn={fixed:w,removable:i,network:ut,unknown:w};function Qn({chip:e,active:t,onNavigate:n}){let r=e.icon;return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(e.path),title:e.path,className:E(`flex h-11 shrink-0 items-center gap-1.5 rounded-full border px-3 text-[13px] active:bg-surface-elevated`,t?`border-primary bg-accent-wash text-text`:`border-border text-text-2`),children:[(0,U.jsx)(r,{className:`size-4 shrink-0 text-text-subtle`}),(0,U.jsx)(`span`,{className:`max-w-[9rem] truncate`,children:e.label})]})}function $n({host:e,currentPath:t,onNavigate:n,vocab:r}){let i=V(e=>e.pins),[a,o]=(0,H.useState)(!1);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 overflow-x-auto touch-pan-x border-b border-border px-2 py-1.5`,children:[[...i.map(e=>({key:`pin:${e.path}`,label:e.name,path:e.path,icon:f})),...e?[{key:`home`,label:r.home,path:e.homedir,icon:Xn}]:[],...e?.pinned.map(e=>({key:`os:${e.path}`,label:e.name,path:e.path,icon:Xn}))??[],...e?.drives.map(e=>({key:`drive:${e.path}`,label:e.label?`${e.label} (${e.name})`:e.name,path:e.path,icon:Zn[e.kind]}))??[]].map(e=>(0,U.jsx)(Qn,{chip:e,active:e.path===t,onNavigate:n},e.key)),(0,U.jsx)(`button`,{type:`button`,"aria-label":`All places`,title:`All places`,onClick:()=>o(!0),className:`flex h-11 shrink-0 items-center gap-1 rounded-full border border-border px-3 text-[13px] text-text-2 active:bg-surface-elevated`,children:(0,U.jsx)(l,{className:`size-4`})})]}),(0,U.jsx)(Yn,{open:a,onClose:()=>o(!1),host:e,currentPath:t,vocab:r,onNavigate:e=>{o(!1),n(e)}})]})}function er(e,t,n){let r=(0,H.useRef)(null),i=R(e=>e.patch),a=(0,H.useRef)(t?.path??``);a.current=t?.path??``;let o=(0,H.useRef)(n);o.current=n;let s=(0,H.useCallback)(async t=>{r.current?.abort();let n=new AbortController;r.current=n,i(e,{loading:!0,error:null});try{let r=await O.browse(t,{showHidden:o.current,signal:n.signal});if(n.signal.aborted)return;i(e,{entries:r.entries,breadcrumbs:r.breadcrumbs,parent:r.parent,sep:r.sep,truncated:r.truncated===!0,loading:!1,error:null})}catch(t){if(n.signal.aborted||t instanceof DOMException&&t.name===`AbortError`)return;i(e,{loading:!1,entries:[],error:t instanceof be?{message:t.message,code:t.code,hint:t.hint}:{message:t instanceof Error?t.message:`Failed to read directory`,code:`EUNKNOWN`}})}},[e,i]),c=t?.path;(0,H.useEffect)(()=>{if(c)return s(c),()=>r.current?.abort()},[c,n,s]),(0,H.useEffect)(()=>Pe(e=>{e===a.current&&s(e)}),[s]);let l=(0,H.useCallback)((t,n)=>{let r=R.getState().slices[e];if(!r||t===r.path)return;let a=n?.replace?[...r.history.slice(0,r.historyIndex),t]:[...r.history.slice(0,r.historyIndex+1),t];i(e,{path:t,history:a.slice(-100),historyIndex:Math.min(a.length,100)-1,selection:new Set,anchor:null,filter:``,inlineEdit:null}),ge.getState().setPayload(e,{path:t})},[e,i]),u=(0,H.useCallback)(t=>{let n=R.getState().slices[e];if(!n)return;let r=n.historyIndex+t,a=n.history[r];a!=null&&(i(e,{path:a,historyIndex:r,selection:new Set,anchor:null,filter:``,inlineEdit:null}),ge.getState().setPayload(e,{path:a}))},[e,i]),d=(0,H.useCallback)(()=>u(-1),[u]),f=(0,H.useCallback)(()=>u(1),[u]),p=(0,H.useCallback)(()=>{let t=R.getState().slices[e];t?.parent&&l(t.parent)},[e,l]),m=(0,H.useCallback)(()=>{a.current&&s(a.current)},[s]),h=(t?.historyIndex??0)>0,g=t?t.historyIndex<t.history.length-1:!1;return(0,H.useMemo)(()=>({go:l,back:d,forward:f,up:p,refresh:m,canGoBack:h,canGoForward:g}),[l,d,f,p,m,h,g])}function tr(e,t,n){let r=t==null?-1:e.indexOf(t),i=e.indexOf(n);if(i<0)return[];if(r<0)return[n];let[a,o]=r<=i?[r,i]:[i,r];return e.slice(a,o+1)}function nr(e,t,n){switch(n.type){case`clear`:return{selection:new Set,anchor:null};case`select-all`:return{selection:new Set(t),anchor:e.anchor??t[0]??null};case`set`:return{selection:new Set(n.paths),anchor:n.anchor===void 0?n.paths[n.paths.length-1]??null:n.anchor};case`click`:if(n.ctrl){let t=new Set(e.selection);return t.has(n.path)?t.delete(n.path):t.add(n.path),{selection:t,anchor:n.path}}if(n.shift){let r=tr(t,e.anchor,n.path);return{selection:new Set(r),anchor:e.anchor??n.path}}return{selection:new Set([n.path]),anchor:n.path}}}function rr(e,t,n){if(e.length===0)return null;let r=t==null?-1:e.indexOf(t);return r<0?n>0?e[0]:e[e.length-1]:e[Math.min(e.length-1,Math.max(0,r+n))]}function ir(e,t,n){if(!t)return-1;let r=t.toLowerCase(),i=n<0?0:n+1;for(let t=0;t<e.length;t++){let n=(i+t)%e.length;if(e[n].toLowerCase().startsWith(r))return n}return-1}function ar(e,t){let n=R(e=>e.patch),r=(0,H.useRef)(t);r.current=t;let i=(0,H.useRef)({text:``,at:0}),a=(0,H.useCallback)(t=>{let i=R.getState().slices[e];i&&n(e,nr(i,r.current,t))},[e,n]),o=(0,H.useCallback)((t,n)=>{let i=R.getState().slices[e];if(!i)return;let o=rr(r.current,i.anchor,t);o!=null&&a({type:`click`,path:o,shift:n})},[e,a]),s=(0,H.useCallback)(t=>{let n=R.getState().slices[e];if(!n)return null;let o=Date.now(),s=o-i.current.at>800?t:i.current.text+t;i.current={text:s,at:o};let c=r.current,l=ir(c.map(e=>e.split(/[/\\]/).pop()??e),s,s.length===1&&n.anchor?c.indexOf(n.anchor):-1);return l<0?null:(a({type:`click`,path:c[l]}),c[l])},[e,a]),c=(0,H.useCallback)((e,t)=>a({type:`click`,path:e,shift:t.shiftKey,ctrl:t.ctrlKey||t.metaKey}),[a]),l=(0,H.useCallback)(e=>a({type:`click`,path:e}),[a]),u=(0,H.useCallback)(()=>a({type:`select-all`}),[a]),d=(0,H.useCallback)(()=>a({type:`clear`}),[a]),f=(0,H.useCallback)((e,t)=>a({type:`set`,paths:e,anchor:t}),[a]);return(0,H.useMemo)(()=>({onRowClick:c,selectOnly:l,selectAll:u,clear:d,setSelection:f,moveTo:o,typeAhead:s}),[c,l,u,d,f,o,s])}var or=28,sr=36,cr=48;function lr({windowId:e,initialPath:t,variant:n=`window`}){let r=R(e=>e.ensure);(0,H.useEffect)(()=>r(e,t),[r,e,t]);let i=R(t=>t.slices[e]),a=R(e=>e.showHidden),o=R(e=>e.viewMode),s=R(e=>e.sort),{host:c}=tt(),l=ve(e=>(e.clipboard?.paths.length??0)>0),u=V(e=>e.isPinned),d=L(),f=$e(),m=er(e,i,a),{actions:h,dialogs:g}=kt(e,i,m,c?.platform),_=(0,H.useMemo)(()=>i?Vt(i.entries,i.filter,s):[],[i?.entries,i?.filter,s]),v=ar(e,(0,H.useMemo)(()=>_.map(e=>e.path),[_])),y=gn({slice:i,entries:_,actions:h,selection:v,nav:m}),b=Je(),x=F(e=>e.close);if(!i)return null;let S=Pn(o),C=n===`sheet`,ee=C?cr:d?sr:or;return(0,U.jsxs)(`div`,{"data-skin":f.id,style:{fontFamily:`var(--x-font)`},className:`flex h-full min-h-0 w-full flex-col bg-panel text-text`,children:[C?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Wn,{slice:i,onClose:x}),(0,U.jsx)($n,{host:c,currentPath:i.path,onNavigate:m.go,vocab:f.vocab})]}):(0,U.jsx)(Ln,{windowId:e,slice:i,nav:m,actions:h}),i.error&&(0,U.jsxs)(`div`,{className:`flex items-start gap-2 border-b border-border bg-error/10 px-2 py-1.5 text-xs text-error`,children:[(0,U.jsx)(oe,{className:`mt-0.5 size-3.5 shrink-0`}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`p`,{className:`break-words`,children:i.error.message}),i.error.hint&&(0,U.jsx)(`p`,{className:`mt-0.5 text-text-2`,children:i.error.hint})]}),c&&(0,U.jsxs)(`button`,{type:`button`,onClick:()=>m.go(c.homedir),className:`flex shrink-0 items-center gap-1 rounded border border-border px-1.5 py-0.5 text-text-2 can-hover:hover:bg-surface-elevated`,children:[(0,U.jsx)(p,{className:`size-3`}),` Go home`]})]}),(0,U.jsx)(Ft,{value:{closed:f.FolderIcon,open:f.FolderOpenIcon},children:(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[!C&&(0,U.jsx)(zt,{host:c,currentPath:i.path,onNavigate:m.go,vocab:f.vocab}),(0,U.jsx)(`div`,{className:`min-w-0 flex-1`,onKeyDown:y,children:(0,U.jsx)(S,{windowId:e,slice:i,entries:_,actions:h,selection:v,inlineError:g.inlineError,hasClipboard:l,isPinned:u,rowHeight:ee,nav:m,backgroundLongPress:b})})]})}),C?(0,U.jsx)(Hn,{slice:i,nav:m,actions:h,entries:_,hasClipboard:l}):(0,U.jsx)(Ut,{entries:_,selection:i.selection,truncated:i.truncated}),(0,U.jsx)(it,{dialogs:g,platform:c?.platform,sep:i.sep})]})}export{lr as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{C as t,S as n}from"./vendor-markdown-CuWCHIVb.js";import"./vendor-ui-DmZ-Mb-H.js";import"./icons-DQjqk0lJ.js";import{t as r}from"./explorer-body-BQ0jyAGv.js";import"./api-client-C1ZwRL4Y.js";import"./settings-store-krC6bc79.js";import"./vendor-mermaid-BitiXJlL.js";import"./portal-container-context-BarKmT4S.js";import"./panel-store-CboGJAwh.js";import"./window-store-UC1jJeLM.js";import"./project-framework-store-B70Q3dNM.js";import"./tab-store-OJa1GPCq.js";import"./context-menu-C6pIsf83.js";import"./file-store-ojgMXgAw.js";import"./use-is-mobile-TkcwP1Gx.js";import"./window-pip-registry-yD6esSju.js";import"./format-file-meta-C77h04cZ.js";import"./button-B9CTrsEf.js";import"./dialog-B84_DJQ8.js";import"./file-icons-BXdvggK2.js";import"./mobile-bottom-sheet-C3TniEP-.js";import"./use-visual-viewport-Lp878uzs.js";import{ht as i,mt as a,wt as o}from"./index-DU68xk06.js";var s=e(t(),1),c=n();function l({id:e,payload:t}){let{host:n,error:l}=i(),u=o(e=>e.discard);(0,s.useEffect)(()=>()=>u(e),[e,u]);let d=(typeof t?.path==`string`?t.path:``)||a()||n?.homedir||``;return d?(0,c.jsx)(r,{windowId:e,initialPath:d}):(0,c.jsx)(`div`,{className:`flex h-full items-center justify-center p-4 text-xs text-text-2`,children:l?`Could not reach the host: ${l}`:`Loading…`})}export{l as default};
1
+ import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{C as t,S as n}from"./vendor-markdown-CuWCHIVb.js";import"./vendor-ui-DmZ-Mb-H.js";import"./icons-DQjqk0lJ.js";import{t as r}from"./explorer-body-xg1-MhlW.js";import"./api-client-Jn3njtNw.js";import"./settings-store-CsVSVgLp.js";import"./vendor-mermaid-BitiXJlL.js";import"./portal-container-context-BarKmT4S.js";import"./panel-store-D20Zuf3i.js";import"./window-store-UC1jJeLM.js";import"./project-framework-store-ViZgce6y.js";import"./tab-store-krAuHQ6_.js";import"./context-menu-C6pIsf83.js";import"./file-store-Ds3qJ4hC.js";import"./use-is-mobile-TkcwP1Gx.js";import"./window-pip-registry-D1oXq-Dq.js";import"./format-file-meta-PPi3ptkm.js";import"./button-B9CTrsEf.js";import"./dialog-B84_DJQ8.js";import"./file-icons-wS-OmEVu.js";import"./mobile-bottom-sheet-C3TniEP-.js";import"./use-visual-viewport-Lp878uzs.js";import{ht as i,mt as a,wt as o}from"./index-CN0G8uYY.js";var s=e(t(),1),c=n();function l({id:e,payload:t}){let{host:n,error:l}=i(),u=o(e=>e.discard);(0,s.useEffect)(()=>()=>u(e),[e,u]);let d=(typeof t?.path==`string`?t.path:``)||a()||n?.homedir||``;return d?(0,c.jsx)(r,{windowId:e,initialPath:d}):(0,c.jsx)(`div`,{className:`flex h-full items-center justify-center p-4 text-xs text-text-2`,children:l?`Could not reach the host: ${l}`:`Loading…`})}export{l as default};
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{C as t,S as n}from"./vendor-markdown-CuWCHIVb.js";import"./vendor-ui-DmZ-Mb-H.js";import{At as r,Jn as i,Yn as a,ln as o,qn as s,wr as c}from"./icons-DQjqk0lJ.js";import{t as l}from"./createLucideIcon-DoiEKeJ_.js";import{n as u,s as d}from"./api-client-Jn3njtNw.js";import{t as f}from"./button-B9CTrsEf.js";import{t as p}from"./input-C7Q8FxeL.js";import{Qt as m}from"./index-CN0G8uYY.js";var h=l(`power-off`,[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),g=e(t(),1),_=n();function v(){let[e,t]=(0,g.useState)([]),[n,l]=(0,g.useState)(!0),[v,y]=(0,g.useState)(``),[b,x]=(0,g.useState)(!1),[S,C]=(0,g.useState)(``),[w,T]=(0,g.useState)(!1),[E,D]=(0,g.useState)(null),[O,k]=(0,g.useState)(null),A=(0,g.useCallback)(async()=>{try{t(await u.get(`/api/extensions`))}catch(e){console.error(`Failed to load extensions:`,e)}finally{l(!1)}},[]);(0,g.useEffect)(()=>{A()},[A]);let j=async()=>{let e=v.trim();if(e){x(!0);try{await u.post(`/api/extensions/install`,{name:e}),d.success(`Installed ${e}`),y(``),A()}catch(e){d.error(e.message||`Install failed`)}finally{x(!1)}}},M=async e=>{D(e.id);try{await u.patch(`/api/extensions/${e.id}`,{enabled:!e.enabled}),A()}catch(e){d.error(e.message||`Toggle failed`)}finally{D(null)}},N=async e=>{k(e);try{await u.del(`/api/extensions/${e}`),d.success(`Removed ${e}`),A()}catch(e){d.error(e.message||`Remove failed`)}finally{k(null)}};return n?(0,_.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,_.jsx)(o,{className:`size-4 animate-spin text-muted-foreground`})}):(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`section`,{className:`space-y-2`,children:[(0,_.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:`Install Extension`}),(0,_.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,_.jsx)(p,{value:v,onChange:e=>y(e.target.value),onKeyDown:e=>{e.key===`Enter`&&j()},placeholder:`npm package name (e.g. @ppm/ext-myext)`,className:`h-8 text-xs flex-1`}),(0,_.jsxs)(f,{variant:`outline`,size:`sm`,className:`h-8 text-xs px-3 gap-1 cursor-pointer`,disabled:!v.trim()||b,onClick:j,children:[b?(0,_.jsx)(o,{className:`size-3 animate-spin`}):(0,_.jsx)(s,{className:`size-3`}),`Install`]})]}),(0,_.jsx)(`button`,{onClick:()=>T(!w),className:`text-[11px] text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,children:w?`Hide`:`Dev link local extension...`}),w&&(0,_.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,_.jsx)(p,{value:S,onChange:e=>C(e.target.value),placeholder:`Local path (e.g. ./packages/ext-myext)`,className:`h-8 text-xs flex-1`}),(0,_.jsxs)(f,{variant:`outline`,size:`sm`,className:`h-8 text-xs px-3 gap-1 cursor-pointer`,disabled:!S.trim(),onClick:async()=>{try{await u.post(`/api/extensions/dev-link`,{path:S.trim()}),d.success(`Dev-linked successfully`),C(``),A()}catch(e){d.error(e.message||`Dev link failed`)}},children:[(0,_.jsx)(r,{className:`size-3`}),`Link`]})]})]}),(0,_.jsxs)(`section`,{className:`space-y-2`,children:[(0,_.jsxs)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:[`Installed (`,e.length,`)`]}),e.length===0?(0,_.jsx)(`p`,{className:`text-[11px] text-muted-foreground py-4 text-center`,children:`No extensions installed`}):(0,_.jsx)(`div`,{className:`space-y-1`,children:e.map(e=>(0,_.jsxs)(`div`,{className:`flex items-center gap-2 px-2.5 py-2 rounded-lg bg-muted/50 hover:bg-muted transition-colors`,children:[(0,_.jsx)(`div`,{className:`size-8 rounded-md bg-background flex items-center justify-center shrink-0`,children:(0,_.jsx)(m(e.icon)??a,{className:`size-4 text-muted-foreground`})}),(0,_.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,_.jsx)(`p`,{className:`text-xs font-medium truncate`,children:e.displayName||e.id}),(0,_.jsxs)(`p`,{className:`text-[11px] text-muted-foreground truncate`,children:[e.id,` v`,e.version,e.activated&&(0,_.jsx)(`span`,{className:`ml-1 text-success`,children:`active`})]})]}),(0,_.jsx)(f,{variant:`ghost`,size:`icon`,className:`size-7 shrink-0 cursor-pointer`,title:e.enabled?`Disable`:`Enable`,disabled:E===e.id,onClick:()=>M(e),children:E===e.id?(0,_.jsx)(o,{className:`size-3.5 animate-spin`}):e.enabled?(0,_.jsx)(i,{className:`size-3.5 text-success`}):(0,_.jsx)(h,{className:`size-3.5 text-muted-foreground`})}),(0,_.jsx)(f,{variant:`ghost`,size:`icon`,className:`size-7 shrink-0 cursor-pointer text-destructive hover:text-destructive`,title:`Remove`,disabled:O===e.id,onClick:()=>N(e.id),children:O===e.id?(0,_.jsx)(o,{className:`size-3.5 animate-spin`}):(0,_.jsx)(c,{className:`size-3.5`})})]},e.id))})]})]})}export{v as ExtensionManagerSection};
@@ -1,4 +1,4 @@
1
- import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{C as t,S as n}from"./vendor-markdown-CuWCHIVb.js";import"./vendor-ui-DmZ-Mb-H.js";import{ln as r}from"./icons-DQjqk0lJ.js";import{r as i}from"./api-client-C1ZwRL4Y.js";import{r as a,t as o}from"./git-repo-store-88Z8v-pF.js";import{t as s}from"./apply-theme-CbR31K6I.js";import{rn as c}from"./index-DU68xk06.js";var l=e(t(),1),u=[[`--bg`,`--bg-solid`],[`--surface`,`--panel`],[`--selected`,`--accent-wash`],[`--text`,`--text`],[`--subtext`,`--text-2`],[`--subtle`,`--text-3`],[`--border`,`--border-soft`],[`--border2`,`--border`],[`--blue`,`--accent`],[`--green`,`--success`],[`--yellow`,`--warning`],[`--red`,`--error`]];function d(e){let t=[];for(let[n,r]of u){let i=e(r).replace(/[<>]/g,``).trim();i&&t.push(`${n}: ${i};`)}return t.length?`:root[data-ppm-theme] { ${t.join(` `)} }`:``}function f(e){let t=getComputedStyle(e);return{mode:e.classList.contains(`dark`)?`dark`:`light`,css:d(e=>t.getPropertyValue(e))}}var p=`ppm:theme`,m=`<script>
1
+ import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{C as t,S as n}from"./vendor-markdown-CuWCHIVb.js";import"./vendor-ui-DmZ-Mb-H.js";import{ln as r}from"./icons-DQjqk0lJ.js";import{r as i}from"./api-client-Jn3njtNw.js";import{r as a,t as o}from"./git-repo-store-BCEPfUGT.js";import{t as s}from"./apply-theme-CbR31K6I.js";import{in as c}from"./index-CN0G8uYY.js";var l=e(t(),1),u=[[`--bg`,`--bg-solid`],[`--surface`,`--panel`],[`--selected`,`--accent-wash`],[`--text`,`--text`],[`--subtext`,`--text-2`],[`--subtle`,`--text-3`],[`--border`,`--border-soft`],[`--border2`,`--border`],[`--blue`,`--accent`],[`--green`,`--success`],[`--yellow`,`--warning`],[`--red`,`--error`]];function d(e){let t=[];for(let[n,r]of u){let i=e(r).replace(/[<>]/g,``).trim();i&&t.push(`${n}: ${i};`)}return t.length?`:root[data-ppm-theme] { ${t.join(` `)} }`:``}function f(e){let t=getComputedStyle(e);return{mode:e.classList.contains(`dark`)?`dark`:`light`,css:d(e=>t.getPropertyValue(e))}}var p=`ppm:theme`,m=`<script>
2
2
  window.addEventListener("message",function(e){
3
3
  if(e.source!==window.parent)return;
4
4
  var m=e.data;