@dotdirfm/ui 0.1.5 → 0.1.6

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.
package/dist/dotdir.js CHANGED
@@ -110,14 +110,14 @@ Press **Cancel** to stop. Files already copied will remain at the destination.
110
110
  Files are being moved to the destination.
111
111
 
112
112
  Press **Cancel** to stop. Files already moved will remain at the destination and will not be restored automatically.
113
- `};function ge(){let e=(0,c.useContext)(fe),t=e?.dialog??null;if(!t)return null;let n=me(t,e);if(!n)return null;let r=he[t.type];return(0,l.jsx)(ee,{helpText:r,children:n})}function _e(){let e=(0,c.useContext)(fe);if(!e)throw Error(`useDialog must be used within DialogProvider`);return e}var ve=(0,d.atom)(null);function B(){let e=(0,d.useAtomValue)(ve);if(!e)throw Error(`Bridge not initialized. Make sure to call initBridge() before rendering.`);return e}function ye({bridge:e,children:t}){let[n,r]=(0,d.useAtom)(ve);return(0,c.useEffect)(()=>{r(e)},[e,r]),n?(0,l.jsx)(l.Fragment,{children:t}):null}var be=[{command:`dotdir.toggleHiddenFiles`,title:`Toggle Hidden Files`,category:`View`},{command:`dotdir.togglePanels`,title:`Toggle Panels`,category:`View`},{command:`dotdir.showExtensions`,title:`Show Extensions`,shortTitle:`Plugins`,category:`View`},{command:`dotdir.showCommandPalette`,title:`Show All Commands`,category:`View`},{command:`dotdir.closeViewer`,title:`Close Viewer`,category:`View`},{command:`dotdir.closeEditor`,title:`Close Editor`,category:`View`},{command:`dotdir.switchPanel`,title:`Switch Panel`,category:`Navigation`},{command:`dotdir.focusLeftPanel`,title:`Focus Left Panel`,category:`Navigation`},{command:`dotdir.focusRightPanel`,title:`Focus Right Panel`,category:`Navigation`},{command:`dotdir.cancelNavigation`,title:`Cancel Navigation`,category:`Navigation`},{command:`dotdir.goToParent`,title:`Go to Parent Directory`,category:`Navigation`},{command:`dotdir.goHome`,title:`Go to Home Directory`,category:`Navigation`},{command:`dotdir.refresh`,title:`Refresh`,category:`File`},{command:`dotdir.newTab`,title:`New Tab`,category:`File`},{command:`dotdir.closeTab`,title:`Close Tab`,category:`File`},{command:`dotdir.previewInOppositePanel`,title:`Show Preview in Opposite Panel`,category:`File`},{command:`dotdir.openCurrentFolderInOppositePanelCurrentTab`,title:`Open Current Folder in Opposite Panel (Current Tab)`,category:`File`},{command:`dotdir.openCurrentFolderInOppositePanelNewTab`,title:`Open Current Folder in Opposite Panel (New Tab)`,category:`File`},{command:`dotdir.openSelectedFolderInOppositePanelCurrentTab`,title:`Open Selected Folder in Opposite Panel (Current Tab)`,category:`File`},{command:`dotdir.openSelectedFolderInOppositePanelNewTab`,title:`Open Selected Folder in Opposite Panel (New Tab)`,category:`File`},{command:`dotdir.openCreateFile`,title:`Open / Create File`,shortTitle:`New File`,category:`File`},{command:`dotdir.makeFolder`,title:`Make Folder`,shortTitle:`MkDir`,category:`File`},{command:`dotdir.viewFile`,title:`View File`,shortTitle:`View`,category:`File`},{command:`dotdir.editFile`,title:`Edit File`,shortTitle:`Edit`,category:`File`},{command:`dotdir.exit`,title:`Exit`,shortTitle:`Quit`,category:`Application`},{command:`terminal.execute`,title:`Execute in Terminal`,category:`Terminal`},{command:`list.cursorUp`,title:`Cursor Up`,category:`Navigation`},{command:`list.cursorDown`,title:`Cursor Down`,category:`Navigation`},{command:`list.cursorLeft`,title:`Cursor Left (Previous Column)`,category:`Navigation`},{command:`list.cursorRight`,title:`Cursor Right (Next Column)`,category:`Navigation`},{command:`list.cursorHome`,title:`Cursor to First`,category:`Navigation`},{command:`list.cursorEnd`,title:`Cursor to Last`,category:`Navigation`},{command:`list.cursorPageUp`,title:`Cursor Page Up`,category:`Navigation`},{command:`list.cursorPageDown`,title:`Cursor Page Down`,category:`Navigation`},{command:`list.selectUp`,title:`Select Up`,category:`Navigation`},{command:`list.selectDown`,title:`Select Down`,category:`Navigation`},{command:`list.selectLeft`,title:`Select Left`,category:`Navigation`},{command:`list.selectRight`,title:`Select Right`,category:`Navigation`},{command:`list.selectHome`,title:`Select to First`,category:`Navigation`},{command:`list.selectEnd`,title:`Select to Last`,category:`Navigation`},{command:`list.selectPageUp`,title:`Select Page Up`,category:`Navigation`},{command:`list.selectPageDown`,title:`Select Page Down`,category:`Navigation`},{command:`list.execute`,title:`Execute in Terminal`,category:`Navigation`},{command:`list.open`,title:`Open`,category:`Navigation`},{command:`list.viewFile`,title:`View File`,shortTitle:`View`,category:`Navigation`},{command:`list.editFile`,title:`Edit File`,shortTitle:`Edit`,category:`Navigation`},{command:`list.moveToTrash`,title:`Move to Trash`,shortTitle:`Trash`,category:`File`},{command:`list.permanentDelete`,title:`Permanently Delete`,shortTitle:`Del Perm`,category:`File`},{command:`list.copy`,title:`Copy`,shortTitle:`Copy`,category:`File`},{command:`list.move`,title:`Move`,shortTitle:`Move`,category:`File`},{command:`list.rename`,title:`Rename`,shortTitle:`Rename`,category:`File`},{command:`list.pasteFilename`,title:`Paste Filename to Command Line`,category:`File`},{command:`list.pastePath`,title:`Paste Path to Command Line`,category:`File`},{command:`commandLine.execute`,title:`Execute Command Line`,category:`Command Line`},{command:`commandLine.clear`,title:`Clear Command Line`,category:`Command Line`},{command:`commandLine.deleteLeft`,title:`Delete Left`,category:`Command Line`},{command:`commandLine.deleteRight`,title:`Delete Right`,category:`Command Line`},{command:`commandLine.moveWordLeft`,title:`Move Word Left`,category:`Command Line`},{command:`commandLine.moveWordRight`,title:`Move Word Right`,category:`Command Line`},{command:`commandLine.home`,title:`Move to Start`,category:`Command Line`},{command:`commandLine.end`,title:`Move to End`,category:`Command Line`},{command:`commandLine.selectAll`,title:`Select All`,category:`Command Line`},{command:`commandLine.selectLeft`,title:`Extend Selection Left`,category:`Command Line`},{command:`commandLine.selectRight`,title:`Extend Selection Right`,category:`Command Line`},{command:`commandLine.selectHome`,title:`Extend Selection to Start`,category:`Command Line`},{command:`commandLine.selectEnd`,title:`Extend Selection to End`,category:`Command Line`},{command:`commandLine.copy`,title:`Copy Selection`,category:`Command Line`},{command:`commandLine.cut`,title:`Cut Selection`,category:`Command Line`},{command:`commandLine.paste`,title:`Paste from Clipboard`,category:`Command Line`}],V=new class e{contributions=new Map;handlers=new Map;keybindingLayers={default:[],extension:[],user:[]};contextGetter=()=>({});contextValues={};listeners=new Set;batchDepth=0;batchDirty=!1;beginBatch(){this.batchDepth++}endBatch(){this.batchDepth--,this.batchDepth===0&&this.batchDirty&&(this.batchDirty=!1,this.notifyListeners())}setContext(e,t){this.contextValues[e]!==t&&(this.contextValues[e]=t,this.batchDepth>0?this.batchDirty=!0:this.notifyListeners())}getContext(e){return this.contextValues[e]}registerContributions(e){for(let t of e)this.contributions.set(t.command,t);return this.notifyListeners(),()=>{for(let t of e)this.contributions.delete(t.command);this.notifyListeners()}}registerCommand(e,t){return this.handlers.set(e,t),this.notifyListeners(),()=>{this.handlers.delete(e),this.notifyListeners()}}registerKeybinding(e,t=`default`){return this.keybindingLayers[t].push(e),this.notifyListeners(),()=>{let n=this.keybindingLayers[t],r=n.indexOf(e);r>=0&&n.splice(r,1),this.notifyListeners()}}setLayerKeybindings(e,t){this.keybindingLayers[e]=t,this.notifyListeners()}clearLayerKeybindings(e){this.keybindingLayers[e]=[],this.notifyListeners()}setContextGetter(e){this.contextGetter=e}async executeCommand(e,...t){let n=this.handlers.get(e);if(!n){console.warn(`Command not found: ${e}`);return}try{await n(...t)}catch(t){console.error(`Command ${e} failed:`,t)}}getCommand(e){let t=this.contributions.get(e);if(t)return{id:t.command,title:t.title,shortTitle:t.shortTitle,category:t.category,icon:t.icon}}getAllCommands(){return Array.from(this.contributions.values()).map(e=>({id:e.command,title:e.title,shortTitle:e.shortTitle,category:e.category,icon:e.icon}))}getKeybindings(){let e=new Map;for(let t of[`default`,`extension`,`user`])for(let n of this.keybindingLayers[t]){let t=`${this.normalizeKey(this.isMac()?n.mac??n.key:n.key)}|${n.when??``}`;e.set(t,n)}return Array.from(e.values())}getKeybindingsForLayer(e){return[...this.keybindingLayers[e]]}getKeybindingForCommand(e){return this.getKeybindings().find(t=>t.command===e)}evaluateWhen(t){if(!t)return!0;let n=this.contextGetter(),r=v.current,i={...n,...this.contextValues,focusPanel:r===`panel`,focusViewer:r===`viewer`,focusEditor:r===`editor`,focusTerminal:r===`terminal`,focusCommandPalette:r===`commandPalette`,focusModal:r===`modal`};return e.evalWhen(t,i)}static evalWhen(e,t){try{return e.split(/\s*&&\s*/).every(e=>e.trim().split(/\s*\|\|\s*/).some(e=>{let n=e.trim(),r=n.startsWith(`!`),i=r?n.slice(1):n;return r?!t[i]:!!t[i]}))}catch{return!0}}handleKeyboardEvent(e){let t=this.eventToKeyCombo(e);if(!t)return!1;for(let n of[`user`,`extension`,`default`])for(let r of this.keybindingLayers[n])if(this.normalizeKey(this.isMac()?r.mac??r.key:r.key)===t&&this.evaluateWhen(r.when))return e.preventDefault(),e.stopPropagation(),this.executeCommand(r.command),!0;return!1}isMac(){return navigator.platform.toUpperCase().includes(`MAC`)}physicalCodeToKeyPart(e){if(e.startsWith(`Key`)&&e.length===4)return e[3].toLowerCase();if(e.startsWith(`Digit`))return e.slice(5);let t=/^Numpad(\d)$/.exec(e);if(t)return t[1];let n=/^F(\d{1,2})$/.exec(e);if(n)return`f${n[1]}`;let r={Space:`space`,Enter:`enter`,NumpadEnter:`enter`,Tab:`tab`,Escape:`escape`,Backspace:`backspace`,Delete:`delete`,Insert:`insert`,ArrowUp:`up`,ArrowDown:`down`,ArrowLeft:`left`,ArrowRight:`right`,Home:`home`,End:`end`,PageUp:`pageup`,PageDown:`pagedown`,Minus:`-`,Equal:`=`,BracketLeft:`[`,BracketRight:`]`,Backslash:`\\`,Semicolon:`;`,Quote:`'`,Comma:`,`,Period:`.`,Slash:`/`,Backquote:"`",IntlBackslash:`\\`};return r[e]?r[e]:null}keyStringToKeyPart(e){if(!e||[`Control`,`Alt`,`Shift`,`Meta`].includes(e))return null;if(e.length===1)return e.toLowerCase();let t=e.toLowerCase();return t===` `?t=`space`:t===`arrowup`?t=`up`:t===`arrowdown`?t=`down`:t===`arrowleft`?t=`left`:t===`arrowright`?t=`right`:t===`escape`?t=`escape`:t===`enter`?t=`enter`:t===`backspace`?t=`backspace`:t===`delete`?t=`delete`:t===`tab`&&(t=`tab`),t}eventToKeyCombo(e){if([`Control`,`Alt`,`Shift`,`Meta`].includes(e.key))return null;let t=[];(e.ctrlKey||e.metaKey)&&t.push(`ctrl`),e.altKey&&t.push(`alt`),e.shiftKey&&t.push(`shift`);let n=(e.code&&this.physicalCodeToKeyPart(e.code))??this.keyStringToKeyPart(e.key);return n?(t.push(n),t.join(`+`)):null}normalizeKey(e){return e.toLowerCase().replace(/cmd/g,`ctrl`).replace(/meta/g,`ctrl`).replace(/mod/g,`ctrl`).split(`+`).map(e=>e.trim()).sort((e,t)=>{let n=[`ctrl`,`alt`,`shift`],r=n.indexOf(e),i=n.indexOf(t);return r>=0&&i>=0?r-i:r>=0?-1:i>=0?1:0}).join(`+`)}onChange(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notifyListeners(){for(let e of this.listeners)e()}};function xe(e){let t=navigator.platform.toUpperCase().includes(`MAC`);return(t?e.mac??e.key:e.key).split(`+`).map(e=>{let n=e.trim().toLowerCase();if(t){if(n===`ctrl`||n===`cmd`||n===`mod`)return`⌘`;if(n===`alt`)return`⌥`;if(n===`shift`)return`⇧`}else{if(n===`ctrl`||n===`cmd`||n===`mod`)return`Ctrl`;if(n===`alt`)return`Alt`;if(n===`shift`)return`Shift`}return n===`enter`?`↵`:n===`escape`?`Esc`:n===`backspace`?`⌫`:n===`delete`?`Del`:n===`up`?`↑`:n===`down`?`↓`:n===`left`?`←`:n===`right`?`→`:n===`space`?`Space`:n===`tab`?`Tab`:n.toUpperCase()}).join(t?``:`+`)}var Se=(0,d.atom)(!1),Ce=(0,d.atom)(void 0),we=(0,d.atom)(void 0),Te=(0,d.atom)([]),Ee=(0,d.atom)(!1),De=(0,d.atom)([]),Oe=(0,d.atom)(!1),ke=(0,d.atom)(`dark`),Ae=(0,d.atom)(!0);(0,d.atom)(!0);var je=(0,d.atom)(0),Me=(0,d.atom)(null),Ne=(0,d.atom)(`left`),Pe=(0,d.atom)(!1),Fe=(0,d.atom)(!1),Ie=(0,d.atom)(null),Le=(0,d.atom)(null),Re=(0,d.atom)(``),ze=(0,d.atom)(null),Be=(0,d.atom)(null),Ve=`_disabled_11mfr_28`,He={"action-bar":`_action-bar_11mfr_1`,"action-bar-item":`_action-bar-item_11mfr_13`,disabled:Ve,"action-bar-key":`_action-bar-key_11mfr_40`,"action-bar-label":`_action-bar-label_11mfr_41`};function Ue(e,t,n){let r=[];return e&&r.push(`ctrl`),n&&r.push(`alt`),t&&r.push(`shift`),r.length>0?r.join(`+`)+`+`:``}function We(){let[e,t]=(0,c.useState)([]),[n,r]=(0,c.useState)({ctrl:!1,shift:!1,alt:!1}),i=(0,c.useCallback)(()=>{let e=Ue(n.ctrl,n.shift,n.alt),r=V.getKeybindings(),i=[];for(let t=1;t<=12;t++){let n=e+`f${t}`,a=r.find(e=>e.key.toLowerCase().replace(/\s/g,``)===n);if(a&&V.evaluateWhen(a.when)){let e=V.getCommand(a.command);i.push({fKey:t,command:e,keybinding:a});continue}i.push({fKey:t})}t(i)},[n]);(0,c.useEffect)(()=>(i(),V.onChange(i)),[i]),(0,c.useEffect)(()=>{let e=e=>{r({ctrl:e.ctrlKey||e.metaKey,shift:e.shiftKey,alt:e.altKey})},t=e=>{r({ctrl:e.ctrlKey||e.metaKey,shift:e.shiftKey,alt:e.altKey})},n=()=>{r({ctrl:!1,shift:!1,alt:!1})};return window.addEventListener(`keydown`,e),window.addEventListener(`keyup`,t),window.addEventListener(`blur`,n),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`keyup`,t),window.removeEventListener(`blur`,n)}},[]);let a=(0,c.useCallback)(e=>{e.command&&V.executeCommand(e.command.id)},[]);return(0,l.jsx)(`div`,{className:He[`action-bar`],children:e.map(e=>(0,l.jsxs)(`div`,{className:C(He,`action-bar-item`,!e.command&&`disabled`),onClick:()=>a(e),children:[(0,l.jsxs)(`span`,{className:He[`action-bar-key`],children:[`F`,e.fKey]}),(0,l.jsx)(`span`,{className:He[`action-bar-label`],children:e.command?e.command.shortTitle??e.command.title:``})]},e.fKey))})}function Ge(e,t,n){return t.map(t=>e.registerKeybinding(t,n))}var Ke=[{command:`dotdir.toggleHiddenFiles`,key:`ctrl+.`,mac:`cmd+.`},{command:`dotdir.togglePanels`,key:`ctrl+o`,mac:`cmd+o`,when:`!terminalCommandRunning`},{command:`dotdir.showExtensions`,key:`f11`},{command:`dotdir.switchPanel`,key:`tab`,when:`focusPanel && !dialogOpen`},{command:`dotdir.cancelNavigation`,key:`escape`,when:`focusPanel`},{command:`dotdir.goToParent`,key:`alt+pageup`,when:`focusPanel`},{command:`dotdir.goHome`,key:`ctrl+home`,mac:`cmd+home`},{command:`dotdir.newTab`,key:`ctrl+t`,mac:`cmd+t`,when:`focusPanel`},{command:`dotdir.closeTab`,key:`ctrl+w`,mac:`cmd+w`,when:`focusPanel`},{command:`dotdir.previewInOppositePanel`,key:`ctrl+shift+o`,mac:`cmd+shift+o`,when:`focusPanel && listItemIsFile`},{command:`dotdir.refresh`,key:`ctrl+r`,mac:`cmd+r`,when:`focusPanel`},{command:`dotdir.openCreateFile`,key:`shift+f4`,when:`focusPanel`},{command:`dotdir.makeFolder`,key:`f7`,when:`focusPanel`},{command:`dotdir.showCommandPalette`,key:`cmd+shift+p`},{command:`dotdir.showCommandPalette`,key:`cmd+p`},{command:`dotdir.closeViewer`,key:`escape`,when:`focusViewer`},{command:`dotdir.closeEditor`,key:`escape`,when:`focusEditor`},{command:`dotdir.exit`,key:`f10`},{command:`dotdir.exit`,key:`cmd+q`,mac:`cmd+q`}],qe=[{command:`commandLine.execute`,key:`enter`,when:`focusPanel && commandLineHasText`},{command:`commandLine.clear`,key:`escape`,when:`focusPanel && commandLineHasText`},{command:`commandLine.deleteLeft`,key:`backspace`,when:`focusPanel && commandLineHasText`},{command:`commandLine.deleteRight`,key:`delete`,when:`focusPanel && commandLineHasText`},{command:`commandLine.moveWordLeft`,key:`ctrl+left`,when:`focusPanel && commandLineHasText`},{command:`commandLine.moveWordRight`,key:`ctrl+right`,when:`focusPanel && commandLineHasText`},{command:`commandLine.home`,key:`home`,when:`focusPanel && commandLineHasText`},{command:`commandLine.end`,key:`end`,when:`focusPanel && commandLineHasText`},{command:`commandLine.selectAll`,key:`ctrl+a`,when:`focusPanel && commandLineHasText`},{command:`commandLine.copy`,key:`ctrl+c`,when:`focusPanel && commandLineHasText`},{command:`commandLine.cut`,key:`ctrl+x`,when:`focusPanel && commandLineHasText`},{command:`commandLine.paste`,key:`ctrl+v`,when:`focusPanel`}],Je=[{command:`list.cursorUp`,key:`up`,when:`focusPanel`},{command:`list.cursorDown`,key:`down`,when:`focusPanel`},{command:`list.cursorLeft`,key:`left`,when:`focusPanel`},{command:`list.cursorRight`,key:`right`,when:`focusPanel`},{command:`list.cursorHome`,key:`home`,when:`focusPanel`},{command:`list.cursorEnd`,key:`end`,when:`focusPanel`},{command:`list.cursorPageUp`,key:`pageup`,when:`focusPanel`},{command:`list.cursorPageDown`,key:`pagedown`,when:`focusPanel`},{command:`list.selectUp`,key:`shift+up`,when:`focusPanel`},{command:`list.selectDown`,key:`shift+down`,when:`focusPanel`},{command:`list.selectLeft`,key:`shift+left`,when:`focusPanel`},{command:`list.selectRight`,key:`shift+right`,when:`focusPanel`},{command:`list.selectHome`,key:`shift+home`,when:`focusPanel`},{command:`list.selectEnd`,key:`shift+end`,when:`focusPanel`},{command:`list.selectPageUp`,key:`shift+pageup`,when:`focusPanel`},{command:`list.selectPageDown`,key:`shift+pagedown`,when:`focusPanel`},{command:`list.execute`,key:`enter`,when:`focusPanel && listItemIsExecutable && !commandLineHasText`},{command:`list.open`,key:`enter`,when:`focusPanel && !listItemIsExecutable && !commandLineHasText`},{command:`list.open`,key:`alt+pagedown`,when:`focusPanel`},{command:`list.viewFile`,key:`f3`,when:`focusPanel && listItemHasViewer`},{command:`list.editFile`,key:`f4`,when:`focusPanel && listItemHasEditor`},{command:`list.moveToTrash`,key:`f8`,when:`focusPanel`},{command:`list.permanentDelete`,key:`shift+delete`,when:`focusPanel`},{command:`list.copy`,key:`f5`,when:`focusPanel`},{command:`list.move`,key:`f6`,when:`focusPanel`},{command:`list.rename`,key:`shift+f6`,when:`focusPanel`},{command:`list.pasteFilename`,key:`ctrl+enter`,when:`focusPanel`},{command:`list.pastePath`,key:`ctrl+f`,when:`focusPanel`}];function Ye(e){return Qe(e,Ke,`default`)}function Xe(e){return Qe(e,qe,`default`)}function Ze(e){return Qe(e,Je,`default`)}function Qe(e,t,n){return Ge(e,t,n)}function $e(e,t){return e.registerKeybinding(t,`extension`)}function et(e,t){return Ge(e,t,`extension`)}var tt=`_hidden_l0nwk_20`,nt=`_active_l0nwk_145`,H={"terminal-and-panels":`_terminal-and-panels_l0nwk_1`,"command-line":`_command-line_l0nwk_7`,hidden:tt,"command-line-prompt":`_command-line-prompt_l0nwk_24`,"command-line-input":`_command-line-input_l0nwk_35`,"command-line-text":`_command-line-text_l0nwk_42`,"command-line-cursor":`_command-line-cursor_l0nwk_46`,"command-line-selected":`_command-line-selected_l0nwk_66`,"terminal-background":`_terminal-background_l0nwk_71`,"terminal-panel":`_terminal-panel_l0nwk_82`,"terminal-body":`_terminal-body_l0nwk_92`,"terminal-container":`_terminal-container_l0nwk_101`,"terminal-toolbar":`_terminal-toolbar_l0nwk_108`,"terminal-tabs":`_terminal-tabs_l0nwk_122`,"terminal-tab":`_terminal-tab_l0nwk_122`,active:nt,"terminal-tab-add":`_terminal-tab-add_l0nwk_150`,"terminal-tab-status":`_terminal-tab-status_l0nwk_155`,"status-running":`_status-running_l0nwk_163`,"status-starting":`_status-starting_l0nwk_167`,"status-error":`_status-error_l0nwk_171`,"status-exited":`_status-exited_l0nwk_175`,"terminal-tab-label":`_terminal-tab-label_l0nwk_179`,"terminal-tab-close":`_terminal-tab-close_l0nwk_185`,"terminal-profile-picker":`_terminal-profile-picker_l0nwk_190`,"terminal-profile-label":`_terminal-profile-label_l0nwk_197`,"terminal-profile-shell":`_terminal-profile-shell_l0nwk_213`,"terminal-status-error":`_terminal-status-error_l0nwk_222`,"terminal-loading":`_terminal-loading_l0nwk_230`};function rt(){let e=(0,d.useAtomValue)(Re),t=(0,d.useAtomValue)(Ae),n=(0,d.useAtomValue)(ze),r=(0,d.useSetAtom)(Be),[i,a]=(0,c.useState)(``),[o,s]=(0,c.useState)(0),[u,f]=(0,c.useState)(0),p=(0,c.useRef)(!1),m=(0,c.useRef)(null),h=(0,c.useRef)(i),g=(0,c.useRef)(o),_=(0,c.useRef)(u),v=(0,c.useRef)(null);h.current=i,g.current=o,_.current=u,n&&(v.current=n),(0,c.useEffect)(()=>(r(()=>e=>{let t=g.current,n=_.current,r=Math.min(t,n),i=Math.max(t,n),o=r+e.length;a(t=>t.slice(0,r)+e+t.slice(i)),s(o),f(o)}),()=>r(()=>()=>{})),[r]),(0,c.useEffect)(()=>{V.setContext(`commandLineHasText`,t&&i.length>0)},[t,i]);let y=(0,c.useCallback)(()=>{let e=g.current,t=_.current;if(e===t)return!1;let n=Math.min(e,t),r=Math.max(e,t);return a(e=>e.slice(0,n)+e.slice(r)),s(n),f(n),!0},[]),b=(0,c.useCallback)((e,t)=>{s(e),t||f(e)},[]);(0,c.useEffect)(()=>{let e=[];return e.push(V.registerCommand(`commandLine.execute`,()=>{let e=h.current.trim();e&&(v.current?.(e),a(``),s(0),f(0))})),e.push(V.registerCommand(`commandLine.clear`,()=>{g.current===_.current?(a(``),s(0),f(0)):f(g.current)})),e.push(V.registerCommand(`commandLine.deleteLeft`,()=>{let e=g.current;e===_.current?e>0&&(a(t=>t.slice(0,e-1)+t.slice(e)),s(e-1),f(e-1)):y()})),e.push(V.registerCommand(`commandLine.deleteRight`,()=>{if(!y()){let e=g.current;e<h.current.length&&a(t=>t.slice(0,e)+t.slice(e+1))}})),e.push(V.registerCommand(`commandLine.moveWordLeft`,()=>{let e=h.current,t=g.current;for(;t>0&&e[t-1]===` `;)t--;for(;t>0&&e[t-1]!==` `;)t--;b(t,!1)})),e.push(V.registerCommand(`commandLine.moveWordRight`,()=>{let e=h.current,t=g.current;for(;t<e.length&&e[t]!==` `;)t++;for(;t<e.length&&e[t]===` `;)t++;b(t,!1)})),e.push(V.registerCommand(`commandLine.home`,()=>b(0,!1))),e.push(V.registerCommand(`commandLine.end`,()=>b(h.current.length,!1))),e.push(V.registerCommand(`commandLine.selectAll`,()=>{h.current.length!==0&&(f(0),s(h.current.length))})),e.push(V.registerCommand(`commandLine.selectLeft`,()=>b(Math.max(0,g.current-1),!0))),e.push(V.registerCommand(`commandLine.selectRight`,()=>b(Math.min(h.current.length,g.current+1),!0))),e.push(V.registerCommand(`commandLine.selectHome`,()=>b(0,!0))),e.push(V.registerCommand(`commandLine.selectEnd`,()=>b(h.current.length,!0))),e.push(V.registerCommand(`commandLine.copy`,()=>{let e=g.current,t=_.current;if(e===t)return;let n=Math.min(e,t),r=Math.max(e,t);navigator.clipboard.writeText(h.current.slice(n,r)).catch(()=>{})})),e.push(V.registerCommand(`commandLine.cut`,()=>{let e=g.current,t=_.current;if(e===t)return;let n=Math.min(e,t),r=Math.max(e,t);navigator.clipboard.writeText(h.current.slice(n,r)).catch(()=>{}),y()})),e.push(V.registerCommand(`commandLine.paste`,()=>{navigator.clipboard.readText().then(e=>{if(!e)return;let t=g.current,n=_.current,r=Math.min(t,n),i=Math.max(t,n),o=r+e.length;a(t=>t.slice(0,r)+e+t.slice(i)),s(o),f(o)}).catch(()=>{})})),()=>{for(let t of e)t()}},[y,b]),(0,c.useEffect)(()=>{if(!t)return;let e=[];return e.push(...Xe(V)),()=>{for(let t of e)t()}},[t]),(0,c.useEffect)(()=>{if(!t)return;let e=e=>{let t=e.target;if(t&&!t.closest?.(`.${H[`terminal-container`]}`)&&!t.closest?.(`dialog`)&&!(e.ctrlKey||e.metaKey)&&!e.altKey&&!e.metaKey&&e.key.length===1){e.preventDefault(),e.stopPropagation();let t=g.current,n=_.current,r=Math.min(t,n),i=Math.max(t,n);a(t=>t.slice(0,r)+e.key+t.slice(i)),s(r+1),f(r+1)}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let x=(0,c.useCallback)((e,t)=>{let n=m.current;if(!n)return h.current.length;let r=n.getBoundingClientRect(),i=document.elementFromPoint(e,t);if(!i||!n.contains(i))return e<r.left?0:h.current.length;let a=i;for(;a&&a!==n&&!a.hasAttribute(`data-start`);)a=a.parentElement;if(!a||a===n||!a.hasAttribute(`data-start`))return e<r.left?0:h.current.length;let o=parseInt(a.getAttribute(`data-start`),10),s=a.firstChild;if(!(s instanceof Text)||!s.textContent?.length)return o;let c=s.textContent.length,l=document.createRange(),u=0,d=c;for(;u<d;){let t=u+d>>1;l.setStart(s,t),l.setEnd(s,t+1),l.getBoundingClientRect().right<=e?u=t+1:d=t}if(u<c){l.setStart(s,u),l.setEnd(s,u+1);let t=l.getBoundingClientRect();e>=t.left+t.width/2&&u++}return Math.min(o+u,h.current.length)},[]),S=(0,c.useCallback)(e=>{e.preventDefault();let t=x(e.clientX,e.clientY);s(t),f(t),p.current=!0;let n=e=>{p.current&&s(x(e.clientX,e.clientY))},r=()=>{p.current=!1,window.removeEventListener(`mousemove`,n),window.removeEventListener(`mouseup`,r)};window.addEventListener(`mousemove`,n),window.addEventListener(`mouseup`,r)},[x]),w=e.length>40?`…`+e.slice(e.length-39):e,T=Math.min(o,u)<Math.max(o,u),E;return E=T?o<=u?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`span`,{className:H[`command-line-text`],"data-start":0,children:i.slice(0,o)}),(0,l.jsx)(`span`,{className:H[`command-line-cursor`]}),(0,l.jsx)(`span`,{className:H[`command-line-selected`],"data-start":o,children:i.slice(o,u)}),(0,l.jsx)(`span`,{className:H[`command-line-text`],"data-start":u,children:i.slice(u)})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`span`,{className:H[`command-line-text`],"data-start":0,children:i.slice(0,u)}),(0,l.jsx)(`span`,{className:H[`command-line-selected`],"data-start":u,children:i.slice(u,o)}),(0,l.jsx)(`span`,{className:H[`command-line-cursor`]}),(0,l.jsx)(`span`,{className:H[`command-line-text`],"data-start":o,children:i.slice(o)})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`span`,{className:H[`command-line-text`],"data-start":0,children:i.slice(0,o)}),(0,l.jsx)(`span`,{className:H[`command-line-cursor`]}),(0,l.jsx)(`span`,{className:H[`command-line-text`],"data-start":o,children:i.slice(o)})]}),(0,l.jsxs)(`div`,{className:C(H,`command-line`,!t&&`hidden`),children:[(0,l.jsxs)(`span`,{className:H[`command-line-prompt`],children:[w,`>`]}),(0,l.jsx)(`span`,{ref:m,className:H[`command-line-input`],onMouseDown:S,children:E})]})}var it={"command-palette-dialog":`_command-palette-dialog_2w2i0_1`,"command-palette":`_command-palette_2w2i0_1`,"command-item-keybinding":`_command-item-keybinding_2w2i0_73`,"command-item-title":`_command-item-title_2w2i0_78`};function at({open:e,onOpenChange:t}){let n=(0,c.useRef)(null),[r,i]=(0,c.useState)(``),[a,o]=(0,c.useState)([]),[s,u]=(0,c.useState)([]);(0,c.useEffect)(()=>{if(e){let e=requestAnimationFrame(()=>{n.current?.focus()});return()=>cancelAnimationFrame(e)}},[e]),(0,c.useEffect)(()=>{let t=()=>{o(V.getAllCommands()),u(V.getKeybindings())};if(t(),e)return V.onChange(t)},[e]);let d=(0,c.useMemo)(()=>a.map(e=>({command:e,keybinding:s.find(t=>t.command===e.id),displayTitle:e.category?`${e.category}: ${e.title}`:e.title})),[a,s]),p=(0,c.useMemo)(()=>{let e=new Map;for(let t of d){let n=t.command.category??`General`;e.has(n)||e.set(n,[]),e.get(n).push(t)}return Array.from(e.entries()).sort((e,t)=>e[0].localeCompare(t[0]))},[d]),m=(0,c.useCallback)(e=>{t(!1),i(``),V.executeCommand(e)},[t]);(0,c.useEffect)(()=>{e||i(``)},[e]),(0,c.useEffect)(()=>{if(e)return v.push(`commandPalette`),()=>v.pop(`commandPalette`)},[e]);let h=(0,c.useCallback)(e=>{e.stopPropagation()},[]);return e?(0,l.jsx)(D,{className:it[`command-palette-dialog`],onClose:()=>t(!1),initialFocusRef:n,placement:`top`,children:(0,l.jsxs)(f.Command,{className:it[`command-palette`],onKeyDown:h,shouldFilter:!0,children:[(0,l.jsx)(f.Command.Input,{ref:n,value:r,onValueChange:i,placeholder:`Type a command or search...`,...b}),(0,l.jsxs)(f.Command.List,{children:[(0,l.jsx)(f.Command.Empty,{children:`No results found.`}),p.map(([e,t])=>(0,l.jsx)(f.Command.Group,{heading:e,children:t.map(({command:e,keybinding:t,displayTitle:n})=>(0,l.jsxs)(f.Command.Item,{value:n,onSelect:()=>m(e.id),children:[(0,l.jsx)(`span`,{className:it[`command-item-title`],children:e.title}),t&&(0,l.jsx)(`span`,{className:it[`command-item-keybinding`],children:xe(t)})]},e.id))},e))]})]})}):null}function ot(){let[e,t]=(0,d.useAtom)(Fe);return(0,c.useEffect)(()=>{let n=n=>{if(e&&n.key===`Escape`){n.preventDefault(),n.stopPropagation(),t(!1);return}if(e&&(n.metaKey||n.ctrlKey)&&n.key.toLowerCase()===`p`){n.preventDefault(),n.stopPropagation(),t(e=>!e);return}if(!e){if(n.target.closest(`.${H[`terminal-container`]}`)){let e=n.metaKey||n.ctrlKey,t=e&&[`c`,`d`,`z`,`v`].includes(n.key.toLowerCase());if(!e||t)return}V.handleKeyboardEvent(n)}};return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[e]),{open:e,setOpen:t}}var st=/^[A-Za-z]:$/,ct=/^[A-Za-z]:\/$/;function lt(e){return e.startsWith(`//`)}function ut(e){return lt(e)?`//${e.slice(2).replace(/\/+/g,`/`)}`:e.replace(/\/+/g,`/`)}function dt(e){return e.startsWith(`/`)||lt(e)||/^[A-Za-z]:\//.test(e)}function U(e){if(!e)return e;let t=ut(e.replace(/\\/g,`/`));return t=t.replace(/\/\.\//g,`/`).replace(/^\.\//,``),t.endsWith(`/.`)&&(t=t.slice(0,-2)),st.test(t)&&(t=`${t}/`),t.length>1&&t.endsWith(`/`)&&!ct.test(t)&&(t=t.replace(/\/+$/,``)),t}function ft(e){let t=U(e);return lt(t)?t.slice(2).split(`/`).filter(Boolean).length===2:!1}function pt(e){let t=U(e);return t===`/`||ct.test(t)||ft(t)}function W(e){let t=U(e);if(!t)return`.`;if(pt(t))return t;let n=t.replace(/\/+$/,``),r=n.lastIndexOf(`/`);if(r<0)return`.`;if(r===0)return`/`;let i=n.slice(0,r);return st.test(i)?`${i}/`:i||`/`}function G(...e){let t=``;for(let n of e){if(!n)continue;let e=U(n);if(!t||dt(e)){t=e;continue}t=U(`${t.replace(/\/+$/,``)}/${e.replace(/^\/+/,``)}`)}return t}function mt(e){let t=ut(e.replace(/\\/g,`/`));if(!t)return t;let n=/^([A-Za-z]):(\/.*)?$/i.exec(t);if(n){let e=n[1].toUpperCase(),t=ht((n[2]??`/`).replace(/^\//,``).split(`/`).filter(e=>e!==``),!0);return t.length===0?`${e}:/`:`${e}:/${t.join(`/`)}`}if(lt(t)){let e=t.slice(2).split(`/`).filter(Boolean);if(e.length<2)return t;let n=`//${e[0]}/${e[1]}`,r=ht(e.slice(2),!0);return r.length?`${n}/${r.join(`/`)}`:n}let r=t.startsWith(`/`),i=ht((r?t.slice(1):t).split(`/`).filter(e=>e!==``),r);return r?i.length?`/${i.join(`/`)}`:`/`:i.length?i.join(`/`):`.`}function ht(e,t){let n=[];for(let r of e)r===`.`||r===``||(r===`..`?n.length>0?n.pop():t||n.push(`..`):n.push(r));return n}function K(e){let t=U(e);if(!t||pt(t))return``;let n=t.replace(/\/+$/,``),r=n.lastIndexOf(`/`),i=r<0?n:n.slice(r+1);return i.endsWith(`\0`)?i.slice(0,-1):i}var gt=new Set([`.exe`,`.com`,`.bat`,`.cmd`,`.msi`,`.scr`,`.ps1`,`.vbs`,`.js`,`.wsf`]);function _t(e,t){if(e&73)return!0;let n=t.lastIndexOf(`.`);if(n<0)return!1;let r=t.slice(n).toLowerCase();return gt.has(r)}var vt=`\0`;function yt(e){let t=e.indexOf(vt);if(t>=0){let n=e.slice(0,t),r=e.slice(t+1),i=yt(n);if(i.length>0&&(i[i.length-1]={label:i[i.length-1].label,path:n+vt}),r&&r!==`/`){let e=r.replace(/^\//,``).split(`/`).filter(Boolean),t=``;for(let r of e)t=t+`/`+r,i.push({label:r,path:n+vt+t})}return i}let n=U(e);if(!n)return[];let r=[];if(/^[A-Za-z]:\//.test(n)){let e=n.slice(0,3),t=n.slice(3),i=t?n.slice(0,2):e.replace(`/`,`\\`);if(r.push({label:i,path:e}),!t)return r;let a=t.split(`/`).filter(Boolean),o=e;for(let e of a)o=o.replace(/\/?$/,``)+`/`+e,r.push({label:e,path:o});return r}if(lt(n)){let e=n.slice(2).replace(/\/+$/,``).split(`/`).filter(Boolean);if(e.length>=2){r.push({label:`\\\\`+e[0]+`\\`+e[1],path:`//`+e[0]+`/`+e[1]});let t=`//`+e[0]+`/`+e[1];for(let n=2;n<e.length;n++)t=t+`/`+e[n],r.push({label:e[n],path:t})}return r}if(n.startsWith(`/`)){r.push({label:`/`,path:`/`});let e=n.slice(1).split(`/`).filter(Boolean),t=`/`;for(let n of e)t=t.replace(/\/?$/,``)+`/`+n,r.push({label:n,path:t});return r}let i=n.split(`/`).filter(Boolean),a=``;for(let e of i)a=a?a+`/`+e:e,r.push({label:e,path:a});return r}async function bt(e,t){return e.fs.readFile(U(t))}async function xt(e,t){return bt(e,t)}async function St(e,t){let n=await bt(e,t);return new TextDecoder().decode(n)}var Ct=0,wt=class{#e;#t=new Map;#n=new Map;#r=null;#i=0;constructor(e,t){this.bridge=e,this.#e=t}#a(){this.#r||=this.bridge.fs.onFsChange(e=>{this.#o(e)})}async observe(e){this.#a();let t=U(e);if(this.#n.has(t))return;let n=this.#i,r=`fso-${Ct++}`;this.#t.set(r,t),this.#n.set(t,r);let i=await this.bridge.fs.watch(r,t);if(n!==this.#i){i&&this.bridge.fs.unwatch(r);return}i||(this.#t.delete(r),this.#n.delete(t),this.#e([{root:{path:t},changedHandle:null,relativePathComponents:[],type:`errored`}],this))}unobserve(e){let t=U(e),n=this.#n.get(t);n!=null&&(this.bridge.fs.unwatch(n),this.#t.delete(n),this.#n.delete(t))}sync(e){this.#a();let t=new Set(e);for(let[e,n]of this.#n)t.has(e)||(this.bridge.fs.unwatch(n),this.#t.delete(n),this.#n.delete(e));for(let e of t)this.#n.has(e)||this.observe(e)}disconnect(){this.#i++;for(let e of this.#t.keys())this.bridge.fs.unwatch(e);this.#t.clear(),this.#n.clear(),this.#r&&=(this.#r(),null)}#o(e){let t=this.#t.get(e.watchId);if(!t)return;let n=e.name?{path:G(t,e.name),name:e.name}:null,r=e.name?[e.name]:[];this.#e([{root:{path:t},changedHandle:n,relativePathComponents:r,type:e.type}],this)}},Tt=new Map;function Et(e){return{async readFile(t){return xt(e,t)},async readFileRange(t,n,r){let i=await e.fs.open(t);try{return await e.fs.read(i,n,r)}finally{await e.fs.close(i)}}}}function Dt(e,t,n){let r=t+``+n,i=Tt.get(r);if(i)return i;let a=(async()=>{let r=await St(e,G(t,n)),i=Et(e);return new Promise((e,t)=>{let a=setTimeout(()=>{t(Error(`fsProvider "${n}" did not register within 5 s`))},5e3),o=new Blob([r],{type:`application/javascript`}),s=URL.createObjectURL(o),c=document.createElement(`script`);c.src=s,c.onerror=()=>{clearTimeout(a),URL.revokeObjectURL(s),t(Error(`Failed to load fsProvider script "${n}"`))},c.onload=()=>{URL.revokeObjectURL(s),clearTimeout(a);let r=window.__dotdirProviderReady;if(typeof r!=`function`){t(Error(`fsProvider "${n}" did not set window.__dotdirProviderReady`));return}window.__dotdirProviderReady=void 0;try{e(r(i))}catch(e){t(e)}},document.head.appendChild(c)})})();return a.catch(()=>Tt.delete(r)),Tt.set(r,a),a}function Ot(){Tt.clear()}var kt=null;function At(e){kt=e}function jt(){return kt??document.documentElement}function Mt(e){return e.includes(`\0`)}function Nt(e){let t=e.lastIndexOf(`\0`);if(t<0)throw Error(`Not a container path: `+JSON.stringify(e));let n=e.slice(0,t),r=e.slice(t+1);return{containerFile:n,innerPath:r.startsWith(`/`)?r:`/`+r}}function Pt(e,t){let n=t.startsWith(`/`)?t:`/`+t;return n.length>1&&n.endsWith(`/`)&&(n=n.slice(0,-1)),e+`\0`+n}function Ft(e){return e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`)}function It(e){return e.replace(/\\/g,`/`).replace(/(^|\/)([A-Za-z]):(?=\/|$)/g,`$1$2/`)}function Lt(e){let t=e.startsWith(`/`)?e:`/${e}`;return`__TAURI_INTERNALS__`in window?typeof navigator<`u`&&/Windows/i.test(navigator.userAgent)?`http://vfs.localhost${Ft(It(t))}`:`vfs://vfs${Ft(t)}`:`${window.location.origin}/vfs/${Ft(t.replace(/^\/+/,``))}`}function Rt(e,t){if(e===`*`||e===`*.*`)return!0;if(e.startsWith(`*.`)){let n=e.slice(1);return t.toLowerCase().endsWith(n.toLowerCase())}return t.toLowerCase()===e.toLowerCase()}function zt(e,t){return e.some(e=>Rt(e,t))}function Bt(e,t){let n=e.filter(e=>zt(e.contribution.patterns,t));return n.length===0?null:(n.sort((e,t)=>(t.contribution.priority??0)-(e.contribution.priority??0)),n[0])}var Vt=class{entries=[];listeners=new Set;clear(){this.entries=[]}register(e,t){this.entries.push({contribution:e,extensionDirPath:t})}resolve(e){return Bt(this.entries,e)}getAll(){return this.entries}onChange(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notifyListeners(){for(let e of this.listeners)e()}},Ht=class{entries=[];listeners=new Set;clear(){this.entries=[]}register(e,t){this.entries.push({contribution:e,extensionDirPath:t})}resolve(e){return Bt(this.entries,e)}getAll(){return this.entries}onChange(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notifyListeners(){for(let e of this.listeners)e()}},Ut=class{entries=[];listeners=new Set;clear(){this.entries=[]}register(e,t){this.entries.push({contribution:e,extensionDirPath:t})}resolve(e){return Bt(this.entries,e)}onChange(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notifyListeners(){for(let e of this.listeners)e()}},Wt=new Vt,Gt=new Ht,Kt=new Ut;function qt(e){Wt.clear(),Gt.clear(),Kt.clear();for(let t of e){if(t.viewers)for(let e of t.viewers)Wt.register(e,t.dirPath);if(t.editors)for(let e of t.editors)Gt.register(e,t.dirPath);if(t.fsProviders)for(let e of t.fsProviders)Kt.register(e,t.dirPath)}Wt.notifyListeners(),Gt.notifyListeners(),Kt.notifyListeners()}var Jt=[{cssVar:`--bg`,keys:[`editor.background`]},{cssVar:`--fg`,keys:[`editor.foreground`,`foreground`]},{cssVar:`--bg-secondary`,keys:[`sideBar.background`,`editorGroupHeader.tabsBackground`]},{cssVar:`--fg-secondary`,keys:[`sideBar.foreground`,`foreground`]},{cssVar:`--fg-muted`,keys:[`descriptionForeground`,`tab.inactiveForeground`]},{cssVar:`--border`,keys:[`panel.border`,`sideBar.border`,`widget.border`,`editorGroup.border`]},{cssVar:`--border-active`,keys:[`focusBorder`]},{cssVar:`--entry-hover`,keys:[`list.hoverBackground`]},{cssVar:`--entry-selected`,keys:[`list.activeSelectionBackground`,`list.focusBackground`,`selection.background`]},{cssVar:`--entry-selected-fg`,keys:[`list.activeSelectionForeground`,`list.focusForeground`]},{cssVar:`--entry-selected-inactive`,keys:[`list.inactiveSelectionBackground`]},{cssVar:`--entry-selected-inactive-fg`,keys:[`list.inactiveSelectionForeground`]},{cssVar:`--error-bg`,keys:[`inputValidation.errorBackground`]},{cssVar:`--error-fg`,keys:[`errorForeground`,`editorError.foreground`]},{cssVar:`--accent`,keys:[`button.background`,`textLink.foreground`,`focusBorder`]},{cssVar:`--accent-fg`,keys:[`button.foreground`]},{cssVar:`--action-bar-border`,keys:[`activityBar.border`]},{cssVar:`--action-bar-bg`,keys:[`activityBar.background`]},{cssVar:`--action-bar-fg`,keys:[`activityBar.foreground`]},{cssVar:`--action-bar-badge-bg`,keys:[`activityBarBadge.background`]},{cssVar:`--action-bar-badge-fg`,keys:[`activityBarBadge.foreground`]}];async function Yt(e,t,n=3){let r=(0,p.parse)(await St(e,t),void 0,{allowTrailingComma:!0});if(r.include&&n>0){let i=G(W(t),r.include);try{let t=await Yt(e,i,n-1);r.colors={...t.colors,...r.colors},!r.tokenColors&&t.tokenColors&&(r.tokenColors=t.tokenColors)}catch{}}return r}var Xt=[],Zt=0,Qt=null,$t=[];function en(){return Qt}function tn(e){return $t.push(e),()=>{$t=$t.filter(t=>t!==e)}}function nn(){if(Qt)for(let e of $t)e(Qt)}function rn(e){an();let t=jt().style;for(let n of Jt)for(let r of n.keys){let i=e[r];if(i){t.setProperty(n.cssVar,i),Xt.push(n.cssVar);break}}}function an(){Zt++;let e=jt().style;for(let t of Xt)e.removeProperty(t);Xt=[];let t=Qt!==null;if(Qt=null,t)for(let e of $t)e({kind:jt().dataset.theme===`light`?`light`:`dark`})}function on(e){return e===`vs`||e===`hc-light`?`light`:`dark`}async function sn(e,t,n){let r=++Zt,i=await Yt(e,t);return r===Zt?(i.colors&&rn(i.colors),Qt={kind:n?on(n):i.type===`light`?`light`:`dark`,colors:i.colors,tokenColors:i.tokenColors},nn(),i):i}var cn=null;function ln(e){cn=e}function q(){return cn}var un={"file-viewer":`_file-viewer_1gb4m_1`,"file-viewer-inline":`_file-viewer-inline_1gb4m_17`,"file-viewer-overlay":`_file-viewer-overlay_1gb4m_30`,"file-editor-overlay":`_file-editor-overlay_1gb4m_31`,"file-editor":`_file-editor_1gb4m_31`};async function dn(e,t,n,r){let{containerFile:i,innerPath:a}=Nt(t),o=Kt.resolve(K(i));if(!o)throw Error(`No fsProvider registered for "${K(i)}"`);if(o.contribution.runtime===`backend`&&e.fsProvider){let t=G(o.extensionDirPath,o.contribution.entry);return e.fsProvider.readFileRange(t,i,a,n,r)}let s=await Dt(e,o.extensionDirPath,o.contribution.entry);if(!s.readFileRange)throw Error(`Provider does not support readFileRange`);return s.readFileRange(i,a,n,r)}function fn(e){let{extensionDirPath:t,entry:n,kind:r,props:i,onClose:a,className:o,style:s,active:u}=e,d=B(),f=(0,c.useRef)(null),[p,m]=(0,c.useState)(null),[h,g]=(0,c.useState)(!0),_=(0,c.useRef)(a);_.current=a;let y=r===`viewer`&&!!i.inline,b=r===`editor`||r===`viewer`&&!y,x=(0,c.useRef)(null),S=(0,c.useRef)(!1),C=(0,c.useRef)(!1);(0,c.useEffect)(()=>{y&&(x.current=document.activeElement,S.current=!1,C.current=!1)},[y]),(0,c.useEffect)(()=>{if(!b||h||C.current)return;C.current=!0;let e=f.current;e&&setTimeout(()=>{try{e.focus(),e.contentWindow?.focus?.()}catch{}},0)},[b,h]),(0,c.useEffect)(()=>{if(!y)return;let e=e=>{let t=e;if(!t)return!1;let n=t.tagName?.toLowerCase();return n===`input`||n===`textarea`||n===`select`||n===`button`||t.isContentEditable},t=t=>{if(t.key===`Tab`&&!(t.ctrlKey||t.metaKey||t.altKey)&&!t.shiftKey){if(S.current){t.preventDefault(),t.stopPropagation();return}if(v.current===`panel`&&!e(t.target)){t.preventDefault(),t.stopPropagation(),S.current=!0,v.push(`viewer`);try{f.current?.focus(),f.current?.contentWindow?.focus?.()}catch{}}}};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[y]);let w=(0,c.useRef)(null),T=(0,c.useRef)(null);(0,c.useEffect)(()=>{if(u!==!1)return;let e=f.current;if(e){let t=r===`viewer`?{filePath:``,fileName:``,fileSize:0}:{filePath:``,fileName:``,langId:`plaintext`};try{e.contentWindow?.postMessage({type:`dotdir:update`,props:t},`*`)}catch{}}let t=w.current;t&&(d.fs.close(t.fd).catch(()=>{}),w.current=null)},[u,r]);let E=(0,c.useRef)(e.kind===`viewer`?e.onExecuteCommand:void 0);e.kind===`viewer`&&(E.current=e.onExecuteCommand);let D=(0,c.useRef)(e.kind===`editor`?e.onDirtyChange:void 0);e.kind===`editor`&&(D.current=e.onDirtyChange);let O=(0,c.useCallback)(()=>({async readFile(e){let t=U(e);return Mt(t)?dn(d,t,0,64*1024*1024):d.fs.readFile(t)},async readFileRange(e,t,n){let r=U(e);if(Mt(r))return dn(d,r,t,n);let i=w.current,a=i;if(!a||a.path!==r){if(i)try{await d.fs.close(i.fd)}catch{}a={fd:await d.fs.open(r),size:(await d.fs.stat(r)).size,path:r},w.current=a}let o=Math.max(0,Math.floor(t)),s=Math.max(0,Math.floor(n)),c=Math.max(0,a.size-o),l=Math.min(s,c);return l===0?new ArrayBuffer(0):d.fs.read(a.fd,o,l)},async readFileText(e){let t=U(e);if(Mt(t)){let t=await this.readFile(e);return new TextDecoder().decode(t)}return St(d,t)},async statFile(e){let t=U(e);if(Mt(t))return{size:(await dn(d,t,0,64*1024*1024)).byteLength,mtimeMs:0};let n=await d.fs.stat(t),r=w.current;return r&&r.path===t&&r.size!==n.size&&(r.size=n.size),n},onFileChange(e){let t=T.current;if(!t)return()=>{};let n=U(t),r=W(n),i=K(n),a=`viewer-${Math.random().toString(36).slice(2)}`,o=!1,s=d.fs.onFsChange(t=>{if(!o&&!(t.watchId!==a||!t.name)&&t.name===i&&(t.type===`modified`||t.type===`appeared`)){let t=w.current;t&&t.path===n&&(d.fs.close(t.fd).catch(()=>{}),w.current=null),e()}});return(async()=>{await d.fs.watch(a,r)||(o=!0,s())})(),()=>{o||(o=!0,d.fs.unwatch(a),s())}},async writeFile(e,t){await d.fs.writeFile(e,t)},async getTheme(){return d.theme.get()},getColorTheme(){return en()},onThemeChange(e){let t=tn(e);return()=>t()},onClose(){_.current()},async executeCommand(e,t){let n=E.current;if(!n)throw Error(`No command handler registered`);return n(e,t)},registerCommand(e,t){return V.registerCommand(e,t)},registerKeybinding(e){return $e(V,{command:e.command,key:e.key,mac:e.mac,when:e.when})},async getExtensionResourceUrl(e){throw U(e).replace(/^\/+/,``).includes(`..`)?Error(`Invalid extension resource path`):Error(`Extension resource URL not available in mount-point mode`)}}),[]),k=(0,c.useCallback)(()=>{let e={};try{let t=getComputedStyle(jt());for(let n=0;n<t.length;n++){let r=t[n];if(!r||!r.startsWith(`--`))continue;let i=t.getPropertyValue(r);i&&(e[r]=i.trim())}}catch{}return e},[]);(0,c.useEffect)(()=>{let e=!1,a=f.current;if(!a)return;g(!0),m(null);let o=O(),s=a.contentWindow;if(!s)return;let c=U(n.replace(/^\.\//,``))||`index.js`,l=G(t,c),u=Lt(l),p=/\.mjs(?:\?|$)/i.test(c),h=1,_=new Map,b=new Map,C=new Map,E=new Map,D=t=>{if(t.source!==s)return;let n=t.data;if(!(!n||typeof n!=`object`)){if(n.type===`ext:commandResult`){let e=Number(n.callId),t=_.get(e);if(!t)return;_.delete(e),n.error?t.reject(Error(String(n.error))):t.resolve();return}if(n.type===`ext:call`){let e=n.id,t=String(n.method??``),r=Array.isArray(n.args)?n.args:[];(async()=>{try{let n=o[t];if(typeof n!=`function`)throw Error(`Host method not found: ${t}`);let i=await n.apply(o,r);s.postMessage({type:`host:reply`,id:e,result:i},`*`)}catch(t){let n=t instanceof Error?t.message:t&&typeof t==`object`&&`message`in t?String(t.message):String(t);s.postMessage({type:`host:reply`,id:e,error:n},`*`)}})().catch(()=>{});return}if(n.type===`ext:subscribe`){let e=String(n.cbId??``),t=String(n.method??``);if(!e||b.has(e))return;if(t===`onFileChange`){if(!o.onFileChange)return;let t=o.onFileChange(()=>{try{s.postMessage({type:`host:callback`,cbId:e},`*`)}catch{}});b.set(e,t);return}if(t===`onThemeChange`){if(!o.onThemeChange)return;let t=o.onThemeChange(t=>{try{s.postMessage({type:`host:callback`,cbId:e,payload:t},`*`)}catch{}});b.set(e,t);return}return}if(n.type===`ext:unsubscribe`){let e=String(n.cbId??``),t=b.get(e);if(t){try{t()}catch{}b.delete(e)}return}if(n.type===`ext:registerCommand`){let e=String(n.handlerId??``),t=String(n.commandId??``);if(!e||!t||C.has(e))return;let r=V.registerCommand(t,async(...t)=>{let n=h++;await new Promise((r,i)=>{_.set(n,{resolve:r,reject:i}),s.postMessage({type:`host:runCommand`,handlerId:e,callId:n,args:t},`*`)})});C.set(e,r);return}if(n.type===`ext:unregisterCommand`){let e=String(n.handlerId??``),t=C.get(e);if(t){try{t()}catch{}C.delete(e)}return}if(n.type===`ext:registerKeybinding`){let e=String(n.bindingId??``),t=n.binding;if(!e||!t||typeof t!=`object`||E.has(e))return;let r=$e(V,{command:t.command,key:t.key,mac:t.mac,when:t.when});E.set(e,r);return}if(n.type===`ext:unregisterKeybinding`){let e=String(n.bindingId??``),t=E.get(e);if(t){try{t()}catch{}E.delete(e)}return}if(n.type===`dotdir:bootstrap-ready`)M();else if(n.type===`dotdir:ready`)e||g(!1);else if(n.type===`dotdir:error`)e||(m(String(n.message??`Extension error`)),g(!1));else if(n.type===`dotdir:iframeKeyDown`)try{let e=String(n.key??``).toLowerCase();if(y&&e===`tab`&&S.current){S.current=!1;try{v.pop(`viewer`)}catch{}try{x.current?.focus?.()}catch{}return}if(y&&!S.current)return;let t={key:n.key,ctrlKey:!!n.ctrlKey,metaKey:!!n.metaKey,altKey:!!n.altKey,shiftKey:!!n.shiftKey,repeat:!!n.repeat,preventDefault(){},stopPropagation(){}};V.handleKeyboardEvent(t)}catch{}}};window.addEventListener(`message`,D);let A=()=>{try{a.contentWindow?.postMessage({type:`dotdir:themeVars`,themeVars:k()},`*`)}catch{}},j=tn(()=>A()),ee=!1,M=async()=>{if(ee)return;ee=!0,T.current=i.filePath;let t;if(p)try{t=await St(d,l)}catch(t){e||(m(`Failed to read ESM entry: ${t instanceof Error?t.message:t&&typeof t==`object`&&`message`in t?String(t.message):String(t)}`),g(!1));return}a.contentWindow?.postMessage({type:`dotdir:init`,kind:r,entryUrl:u,entryScript:t,props:i,themeVars:k(),colorTheme:o.getColorTheme?.()??null},`*`)},N=()=>{setTimeout(()=>{!e&&!ee&&(m(`Extension bootstrap did not respond`),g(!1))},3e3)};return a.addEventListener(`load`,N),()=>{e=!0,window.removeEventListener(`message`,D),a.removeEventListener(`load`,N),j();try{a.contentWindow?.postMessage({type:`dotdir:dispose`},`*`)}catch{}for(let[,e]of b)try{e()}catch{}b.clear();for(let[,e]of C)try{e()}catch{}C.clear();for(let[,e]of E)try{e()}catch{}E.clear(),_.clear();let t=w.current;t&&(d.fs.close(t.fd).catch(()=>{}),w.current=null)}},[t,n,r,O,k]);let A=(0,c.useRef)(i);if((0,c.useEffect)(()=>{if(u===!1){A.current=null;return}let e=f.current;if(!(!e||h||p)&&A.current!==i){A.current=i,T.current=i.filePath;try{e.contentWindow?.postMessage({type:`dotdir:update`,props:i},`*`)}catch{}}},[i,r,h,p,u]),p)return(0,l.jsxs)(`div`,{className:o,style:{...s,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`var(--error-fg, #f44)`},children:[`Failed to load `,r,`: `,p]});let j=Lt(`/_ext/${W(G(t,U(n.replace(/^\.\//,``))||`index.js`)).replace(/^\//,``)}/`);return(0,l.jsxs)(`div`,{className:o,style:{...s,position:`relative`},children:[h&&(0,l.jsxs)(`div`,{style:{position:`absolute`,inset:0,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`var(--fg-muted, #888)`},children:[`Loading `,r,`…`]}),j&&(0,l.jsx)(`iframe`,{ref:f,src:j,sandbox:`allow-scripts allow-top-navigation-to-custom-protocols`,style:{width:`100%`,height:`100%`,border:`none`,display:h?`none`:`block`,background:`transparent`},title:`${r} extension`})]})}function pn({extensionDirPath:e,entry:t,filePath:n,fileName:r,fileSize:i,inline:a,visible:o,onClose:s,onExecuteCommand:u}){let d=(0,c.useRef)(!1),f=o??!0,p=(0,c.useCallback)(()=>{requestAnimationFrame(()=>{q()?.focus()})},[]),m=(0,c.useCallback)(()=>{s(),p()},[s,p]);(0,c.useEffect)(()=>{if(!a){if(f)d.current||=(v.push(`viewer`),!0);else if(d.current){try{v.pop(`viewer`)}catch{}d.current=!1}}},[a,f]),(0,c.useEffect)(()=>()=>{if(d.current){try{v.pop(`viewer`)}catch{}d.current=!1}},[]);let h=(0,c.useMemo)(()=>({filePath:n,fileName:r,fileSize:i,inline:a}),[n,r,i,a]),g=(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`6px 10px`,borderBottom:`1px solid var(--border, #333)`,flexShrink:0,minHeight:38,boxSizing:`border-box`},children:[(0,l.jsx)(`span`,{style:{flex:1,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},title:r,children:r}),(0,l.jsx)(`button`,{type:`button`,title:`Close (Esc)`,onClick:m,style:{background:`transparent`,border:`none`,cursor:`pointer`,fontSize:18,padding:`0 8px`,flexShrink:0,color:`inherit`},"aria-label":`Close`,children:`×`})]}),_=(0,l.jsx)(fn,{kind:`viewer`,extensionDirPath:e,entry:t,props:h,active:f,onClose:m,onExecuteCommand:u,style:{width:`100%`,height:`100%`}});return a?(0,l.jsx)(`div`,{className:`${un[`file-viewer`]} ${un[`file-viewer-inline`]}`,style:{display:`flex`,flexDirection:`column`,height:`100%`},children:(0,l.jsx)(`div`,{style:{flex:1,minHeight:0},children:_})}):(0,l.jsx)(`div`,{className:un[`file-viewer-overlay`],style:{display:f?`flex`:`none`},children:(0,l.jsxs)(`div`,{className:un[`file-viewer`],style:{display:`flex`,flexDirection:`column`,padding:0},children:[g,(0,l.jsx)(`div`,{style:{flex:1,minHeight:0},children:_})]})})}function mn({extensionDirPath:e,entry:t,filePath:n,fileName:r,langId:i,visible:a,onClose:o,onDirtyChange:s,languages:u,grammars:d}){let[f,p]=(0,c.useState)(i),m=(0,c.useRef)(!1),h=a??!0,g=(0,c.useCallback)(()=>{requestAnimationFrame(()=>{q()?.focus()})},[]),_=(0,c.useCallback)(()=>{o(),g()},[o,g]);(0,c.useEffect)(()=>{p(i)},[i]),(0,c.useEffect)(()=>{if(h)m.current||=(v.push(`editor`),!0);else if(m.current){try{v.pop(`editor`)}catch{}m.current=!1}},[h]),(0,c.useEffect)(()=>()=>{if(m.current){try{v.pop(`editor`)}catch{}m.current=!1}},[]);let y=(0,c.useMemo)(()=>({filePath:n,fileName:r,langId:f,extensionDirPath:e,languages:u,grammars:d,inline:!1}),[n,r,f,e,u,d]),b=e=>{let t=e.target.value;p(t)},x=(0,c.useMemo)(()=>{let e=u??[],t=new Set;return e.filter(e=>t.has(e.id)?!1:(t.add(e.id),!0))},[u]),S=x.length>0;return(0,l.jsx)(`div`,{className:un[`file-editor-overlay`],style:{display:h?`flex`:`none`},children:(0,l.jsxs)(`div`,{className:un[`file-editor`],style:{display:`flex`,flexDirection:`column`,padding:0},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`6px 10px`,borderBottom:`1px solid var(--border, #333)`,flexShrink:0,minHeight:38,boxSizing:`border-box`},children:[(0,l.jsx)(`span`,{style:{flex:1,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},title:r,children:r}),S&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`label`,{htmlFor:`editor-lang-select`,style:{whiteSpace:`nowrap`},children:`Language:`}),(0,l.jsxs)(`select`,{id:`editor-lang-select`,value:f,onChange:b,style:{minWidth:120,padding:`2px 6px`},children:[(0,l.jsx)(`option`,{value:`plaintext`,children:`Plain Text`}),x.map(e=>(0,l.jsx)(`option`,{value:e.id,children:e.aliases?.[0]??e.id},e.id))]})]}),(0,l.jsx)(`button`,{type:`button`,title:`Close (Esc)`,onClick:_,style:{background:`transparent`,border:`none`,cursor:`pointer`,fontSize:18,padding:`0 8px`,flexShrink:0,color:`inherit`},"aria-label":`Close`,children:`×`})]}),(0,l.jsx)(`div`,{style:{flex:1,minHeight:0},children:(0,l.jsx)(fn,{kind:`editor`,extensionDirPath:e,entry:t,props:y,active:h,onClose:_,onDirtyChange:s,style:{width:`100%`,height:`100%`}})})]})})}var hn="(function(){let e=/^[A-Za-z]:$/,t=/^[A-Za-z]:\\/$/;function n(e){return e.startsWith(`//`)}function r(e){return n(e)?`//${e.slice(2).replace(/\\/+/g,`/`)}`:e.replace(/\\/+/g,`/`)}function i(e){return e.startsWith(`/`)||n(e)||/^[A-Za-z]:\\//.test(e)}function a(n){if(!n)return n;let i=r(n.replace(/\\\\/g,`/`));return i=i.replace(/\\/\\.\\//g,`/`).replace(/^\\.\\//,``),i.endsWith(`/.`)&&(i=i.slice(0,-2)),e.test(i)&&(i=`${i}/`),i.length>1&&i.endsWith(`/`)&&!t.test(i)&&(i=i.replace(/\\/+$/,``)),i}function o(e){let t=a(e);return n(t)?t.slice(2).split(`/`).filter(Boolean).length===2:!1}function s(e){let n=a(e);return n===`/`||t.test(n)||o(n)}function c(t){let n=a(t);if(!n)return`.`;if(s(n))return n;let r=n.replace(/\\/+$/,``),i=r.lastIndexOf(`/`);if(i<0)return`.`;if(i===0)return`/`;let o=r.slice(0,i);return e.test(o)?`${o}/`:o||`/`}function l(...e){let t=``;for(let n of e){if(!n)continue;let e=a(n);if(!t||i(e)){t=e;continue}t=a(`${t.replace(/\\/+$/,``)}/${e.replace(/^\\/+/,``)}`)}return t}let u=0,d=new Map,f=new Map,p=new Map,m=new Map;function h(e){return new Promise((t,n)=>{let r=u++;d.set(r,{resolve:t,reject:n}),self.postMessage({type:`readFile`,id:r,path:e})})}function g(e){return`${e.ref.publisher}.${e.ref.name}.${e.ref.version}`}function _(e,t){let n=e.manifest.activationEvents??[];return n.length===0?t===`*`:n.includes(`*`)||n.includes(t)}async function v(e){let t=await h(e);if(t==null)throw Error(`Browser script not found: ${e}`);let n=URL.createObjectURL(new Blob([t],{type:`text/javascript`}));try{return await import(n)}finally{URL.revokeObjectURL(n)}}async function y(e){let t=g(e);if(p.has(t)||!e.manifest.browser)return;let n=a(e.manifest.browser).replace(/^\\/+/,``),r=await v(l(e.dirPath,n)),i=r.activate??r.default?.activate,o=r.deactivate??r.default?.deactivate;if(typeof i!=`function`){console.warn(`[ExtHost] ${t} browser entry has no activate() export`);return}let s=[],c={commands:{registerCommand:(e,t)=>{m.set(e,t);let n={dispose:()=>{m.get(e)===t&&m.delete(e)}};return s.push(n),n},registerKeybinding:e=>({dispose(){}})}},u={subscriptions:s,dotdir:c};self.dotdir=c,await i(u),p.set(t,{subscriptions:s,deactivate:o})}async function b(e){for(let t of f.values())if(t.manifest.browser&&_(t,e))try{await y(t)}catch(e){console.error(`[ExtHost] activate failed:`,g(t),e)}}async function x(e,t){await b(`onCommand:${e}`);let n=m.get(e);n&&await n(...t)}function S(e){return`${e.publisher}-${e.name}-${e.version}`}async function C(e){try{let t=await h(l(e,`package.json`));if(t===null)return null;let n=JSON.parse(t),r={publisher:n.publisher||`unknown`,name:n.name||`unknown`,version:n.version||`0.0.0`},i,a;if(n.contributes?.iconTheme?.path){let t=l(e,n.contributes.iconTheme.path);i=t,a=c(t)}let o=n.contributes?.languages,s;if(n.contributes?.grammars?.length){s=[];for(let t of n.contributes.grammars)try{let n=l(e,t.path);s.push({contribution:t,path:n})}catch{}}let u;n.contributes?.themes?.length&&(u=n.contributes.themes.map((t,n)=>({id:t.id||`${t.label}#${n}`,label:t.label,uiTheme:t.uiTheme,jsonPath:l(e,t.path)})));let d=n.contributes?.viewers,f=n.contributes?.editors,p=n.contributes?.commands,m=n.contributes?.keybindings,g=n.contributes?.fsProviders,_;if(n.contributes?.shellIntegrations?.length){_=[];for(let t of n.contributes.shellIntegrations){let n=await h(l(e,t.scriptPath));n!==null&&_.push({shell:t.shell,label:t.label,script:n,executableCandidates:t.executableCandidates??[],platforms:t.platforms,hiddenCdTemplate:t.hiddenCdTemplate,cwdEscape:t.cwdEscape,lineEnding:t.lineEnding,spawnArgs:t.spawnArgs,scriptArg:t.scriptArg})}}return{ref:r,manifest:n,dirPath:e,iconThemeFssPath:i,iconThemeBasePath:a,colorThemes:u,languages:o,grammarRefs:s,viewers:d,editors:f,commands:p,keybindings:m,fsProviders:g,shellIntegrations:_}}catch{return null}}async function w(e){let t=[],n=l(e,`.dotdir`,`extensions`),r;try{let e=await h(l(n,`extensions.json`));if(e===null)return t;let i=JSON.parse(e);r=Array.isArray(i)?i:[]}catch{return t}for(let e of r){if(!e.publisher||!e.name||!e.version)continue;let r=await C(e.path?a(e.path):l(n,S(e)));r&&t.push(r)}console.log(`[ExtHost] loaded`,t.length,`extensions; FSS:`,t.filter(e=>e.iconThemeFss).map(e=>`${e.ref.publisher}.${e.ref.name}`),`vscode:`,t.filter(e=>e.vscodeIconThemePath).map(e=>`${e.ref.publisher}.${e.ref.name}`)),f.clear();for(let e of t)f.set(g(e),e);return t}self.onmessage=e=>{let t=e.data;if(t.type===`start`)w(t.homePath).then(async e=>{await b(`*`),self.postMessage({type:`loaded`,extensions:e})}).catch(e=>{let t=e instanceof Error?e.message:e&&typeof e==`object`&&`message`in e?String(e.message):String(e);self.postMessage({type:`error`,message:t})});else if(t.type===`activateByEvent`){let e=Number(t.requestId);b(String(t.event??``)).then(()=>{self.postMessage({type:`requestResult`,requestId:e,result:null})}).catch(t=>{let n=t instanceof Error?t.message:String(t);self.postMessage({type:`requestResult`,requestId:e,error:n})})}else if(t.type===`executeCommand`){let e=Number(t.requestId);x(String(t.command??``),Array.isArray(t.args)?t.args:[]).then(()=>{self.postMessage({type:`requestResult`,requestId:e,result:null})}).catch(t=>{let n=t instanceof Error?t.message:String(t);self.postMessage({type:`requestResult`,requestId:e,error:n})})}else if(t.type===`readFileResult`){let e=d.get(t.id);e&&(d.delete(t.id),t.error?e.resolve(null):e.resolve(t.data))}}})();",gn=typeof self<`u`&&self.Blob&&new Blob([`(self.URL || self.webkitURL).revokeObjectURL(self.location.href);`,hn],{type:`text/javascript;charset=utf-8`});function _n(e){let t;try{if(t=gn&&(self.URL||self.webkitURL).createObjectURL(gn),!t)throw``;let n=new Worker(t,{name:e?.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch{return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(hn),{name:e?.name})}}var vn=class{worker=null;homePath=null;listeners=[];starting=!1;nextRequestId=1;pendingRequests=new Map;constructor(e){this.bridge=e}onLoaded(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(t=>t!==e)}}async start(){if(!this.starting){this.starting=!0;try{this.homePath||=await this.bridge.utils.getHomePath(),this.spawnWorker()}finally{this.starting=!1}}}async restart(){this.worker?.terminate(),this.worker=null;for(let[,e]of this.pendingRequests)e.reject(Error(`Extension host restarted`));this.pendingRequests.clear(),await this.start()}dispose(){this.worker?.terminate(),this.worker=null;for(let[,e]of this.pendingRequests)e.reject(Error(`Extension host disposed`));this.pendingRequests.clear(),this.listeners=[]}async activateByEvent(e){await this.request({type:`activateByEvent`,event:e})}async executeCommand(e,t=[]){await this.request({type:`executeCommand`,command:e,args:t})}spawnWorker(){let e=new _n;e.onmessage=t=>{let n=t.data;if(n.type===`readFile`)this.handleFileRead(e,n.id,n.path);else if(n.type===`loaded`){let e=n.extensions,t=e.filter(e=>e.iconThemeFss).map(e=>`${e.ref.publisher}.${e.ref.name}`),r=e.filter(e=>e.vscodeIconThemePath).map(e=>`${e.ref.publisher}.${e.ref.name}`);console.log(`[ExtHost] loaded`,e.length,`extensions; FSS:`,t,`vscode:`,r);for(let t of this.listeners)t(e)}else if(n.type===`error`)console.error(`[ExtensionHost] Worker error:`,n.message);else if(n.type===`requestResult`){let e=Number(n.requestId),t=this.pendingRequests.get(e);if(!t)return;this.pendingRequests.delete(e),n.error?t.reject(Error(String(n.error))):t.resolve(n.result)}},e.onerror=e=>{console.error(`[ExtensionHost] Worker runtime error:`,e)},this.worker=e,(async()=>{e.postMessage({type:`start`,homePath:this.homePath})})()}async request(e){if(this.worker||await this.start(),!this.worker)throw Error(`Extension host is not running`);let t=this.nextRequestId++;return await new Promise((n,r)=>{this.pendingRequests.set(t,{resolve:n,reject:r}),this.worker.postMessage({...e,requestId:t})})}async handleFileRead(e,t,n){try{let r=U(n),i=await St(this.bridge,r);console.log(`[ExtHost] readFile ok`,r),e.postMessage({type:`readFileResult`,id:t,data:i})}catch(r){console.error(`[ExtHost] readFile failed`,n,r),e.postMessage({type:`readFileResult`,id:t,data:null,error:`read failed`})}}},yn=(0,d.atom)(e=>{let t=e(ve);if(!t)throw Error(`Bridge not initialized.`);return new vn(t)});function bn(){return(0,d.useAtomValue)(yn)}var xn=`https://dotdir.dev`;function Sn(e){return`${e.publisher}-${e.name}-${e.version}`}async function Cn(e){return G(await e.utils.getHomePath(),`.dotdir`,`extensions`)}async function wn(e){let t=await Cn(e);try{let n=await St(e,G(t,`extensions.json`)),r=JSON.parse(n);return Array.isArray(r)?r:[]}catch{return[]}}async function Tn(e,t){let n=await Cn(e);await e.fs.writeFile(G(n,`extensions.json`),JSON.stringify(t,null,2))}async function En(e=``,t=1){let n=new URLSearchParams({page:String(t),pageSize:`30`});e&&n.set(`q`,e);let r=await fetch(`${xn}/api/extensions/search?${n}`);if(!r.ok)throw Error(`Failed to search marketplace`);return r.json()}async function Dn(e){let t=new DecompressionStream(`deflate-raw`),n=t.writable.getWriter(),r=t.readable.getReader();n.write(e),n.close();let i=[];for(;;){let{done:e,value:t}=await r.read();if(e)break;i.push(t)}let a=i.reduce((e,t)=>e+t.length,0),o=new Uint8Array(a),s=0;for(let e of i)o.set(e,s),s+=e.length;return o}async function On(e){let t=new Uint8Array(e),n=new Map,r=e=>t[e]|t[e+1]<<8,i=e=>(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0,a=-1;for(let e=t.length-22;e>=Math.max(0,t.length-65557);e--)if(i(e)===101010256){a=e;break}if(a===-1)throw Error(`Invalid ZIP archive`);let o=i(a+16),s=r(a+10),c=o;for(let e=0;e<s&&i(c)===33639248;e++){let e=r(c+10),a=i(c+20),o=r(c+28),s=r(c+30),l=r(c+32),u=i(c+42),d=new TextDecoder().decode(t.slice(c+46,c+46+o));if(c+=46+o+s+l,d.endsWith(`/`))continue;let f=r(u+26),p=r(u+28),m=u+30+f+p,h=t.slice(m,m+a),g;if(e===0)g=h;else if(e===8)g=await Dn(h);else continue;n.set(d,g)}return n}function kn(e){let t=[...e];if(t.length===0)return``;let n=t[0],r=n.indexOf(`/`);if(r===-1)return``;let i=n.slice(0,r+1);return t.every(e=>e.startsWith(i))?i:``}async function An(e,t,n,r){let i=`${xn}/api/extensions/${t}/${n}/${r}/download`,a=await fetch(i);if(!a.ok)throw Error(`Download failed: ${a.statusText}`);let o=await On(await a.arrayBuffer()),s=await Cn(e),c={publisher:t,name:n,version:r},l=G(s,Sn(c)),u=kn(o.keys());for(let[t,n]of o){let r=u?t.slice(u.length):t;r&&await e.fs.writeBinaryFile(G(l,r),n)}let d=(await wn(e)).filter(e=>!(e.publisher===t&&e.name===n));d.push(c),await Tn(e,d)}async function jn(e){let t=new Uint8Array(e),n=new Map,r=e=>t[e]|t[e+1]<<8,i=e=>(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0,a=-1;for(let e=t.length-22;e>=Math.max(0,t.length-65557);e--)if(i(e)===101010256){a=e;break}if(a===-1)throw Error(`Invalid VSIX archive`);let o=i(a+16),s=r(a+10),c=o;for(let e=0;e<s&&i(c)===33639248;e++){let e=r(c+10),a=i(c+20),o=r(c+28),s=r(c+30),l=r(c+32),u=i(c+42),d=new TextDecoder().decode(t.slice(c+46,c+46+o));if(c+=46+o+s+l,d.endsWith(`/`)||!d.startsWith(`extension/`))continue;let f=r(u+26),p=r(u+28),m=u+30+f+p,h=t.slice(m,m+a),g;if(e===0)g=h;else if(e===8)g=await Dn(h);else continue;let _=d.slice(10);_&&n.set(_,g)}return n}async function Mn(e,t,n,r){let i=new AbortController,a=setTimeout(()=>i.abort(),3e4),o;try{o=await fetch(r,{signal:i.signal})}catch(e){if(clearTimeout(a),e instanceof Error&&e.name===`AbortError`)throw Error(`Download timed out - VS Code marketplace may be blocked by CORS`);let t=e instanceof Error?e.message:e&&typeof e==`object`&&`message`in e?String(e.message):String(e);throw Error(`Download failed: ${t}`)}if(clearTimeout(a),!o.ok)throw Error(`Download failed: ${o.status} ${o.statusText}`);let s=await jn(await o.arrayBuffer()),c=s.get(`package.json`);if(!c)throw Error(`Invalid VSIX: no package.json`);let l=JSON.parse(new TextDecoder().decode(c)).version||`0.0.0`,u=await Cn(e),d={publisher:t,name:n,version:l},f=G(u,Sn(d));for(let[t,n]of s){let r=G(f,t),i=t.split(`.`).pop()?.toLowerCase()??``;[`json`,`txt`,`md`,`js`,`ts`,`css`,`html`,`xml`,`yaml`,`yml`,`tmLanguage`,`tmGrammar`].includes(i)||t.endsWith(`.tmLanguage.json`)||t.endsWith(`.language-configuration.json`)?await e.fs.writeFile(r,new TextDecoder().decode(n)):await e.fs.writeBinaryFile(r,n)}let p=(await wn(e)).filter(e=>!(e.publisher===t&&e.name===n));p.push(d),await Tn(e,p)}async function Nn(e,t){if(!await e.fs.exists(t))return;let n=await e.fs.delete.start([t]);await new Promise((t,r)=>{let i=e.fs.delete.onProgress(e=>{if(e.deleteId!==n)return;let a=e.event;a.kind===`done`?(i(),t()):a.kind===`error`&&(i(),r(Error(a.message)))})})}async function Pn(e,t,n){let r=await wn(e),i=r.find(e=>e.publisher===t&&e.name===n);i&&!i.path&&await Nn(e,G(await Cn(e),Sn(i))),await Tn(e,r.filter(e=>!(e.publisher===t&&e.name===n)))}function Fn(e){return e.iconThemeFss||e.iconThemeFssPath||e.vscodeIconThemePath?`${e.ref.publisher}.${e.ref.name}`:null}function In(e,t){return`${e.ref.publisher}.${e.ref.name}:${t}`}function Ln(e,t){for(let n of e)if(n.colorThemes){for(let e of n.colorThemes)if(In(n,e.id)===t)return{ext:n,theme:e}}return null}var Rn=`https://marketplace.visualstudio.com/_apis/public/gallery`;async function zn(e,t=1){let n={filters:[{criteria:[{filterType:8,value:`Microsoft.VisualStudio.Code`},...e?[{filterType:10,value:e}]:[]],pageNumber:t,pageSize:30,sortBy:e?0:4,sortOrder:0}],assetTypes:[],flags:914},r=await fetch(`${Rn}/extensionquery`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json;api-version=7.1-preview.1`},body:JSON.stringify(n)});if(!r.ok)throw Error(`VS Code marketplace request failed`);let i=(await r.json()).results?.[0]?.extensions??[];return{extensions:i,total:i.length}}function Bn(e){return e.statistics?.find(e=>e.statisticName===`install`)?.value??0}function Vn(e){return e.versions?.[0]?.version??null}function Hn(e){let t=e.versions?.[0];return t?`${t.assetUri}/Microsoft.VisualStudio.Services.VSIXPackage`:null}function Un(e){let t=e.versions?.[0];return t?`${t.assetUri}/Microsoft.VisualStudio.Services.Icons.Default`:null}async function Wn(e,t){let{name:n,getPath:r,validate:i,defaultValue:a,onLoad:o}=t,s=a,c=null,l=null,u=null,d=new Set;function f(){for(let e of d)try{e(s)}catch(e){console.error(`[${n}] Listener error:`,e)}}async function m(){try{let t=c??await r();c=t;let a=await St(e,t),l=[],u=(0,p.parse)(a,l,{allowTrailingComma:!0});if(l.length>0){console.error(`[${n}] Parse errors:`);for(let e of l)console.error(` - ${(0,p.printParseErrorCode)(e.error)} at offset ${e.offset}`);return}let d=i(u);if(d===null)return;s=d,console.log(`[${n}] Loaded`),o?.(s),f()}catch(e){e&&typeof e.message==`string`&&(e.message===`ENOENT`||e.message?.includes(`not found`)||e.name===`NotFoundError`)?(s=a,o?.(s),f()):console.error(`[${n}] Failed to load:`,e)}}async function h(){try{let t=c??await r();c=t;let i=W(t),a=K(t);l=`${n}-${Date.now()}`,await e.fs.watch(l,i),u=e.fs.onFsChange(e=>{e.watchId===l&&e.name===a&&(console.log(`[${n}] Detected change, reloading...`),m())})}catch(e){console.error(`[${n}] Failed to setup watch:`,e)}}return await m(),await h(),{getValue:()=>s,setValue(e){s=e},onChange(e){return d.add(e),()=>d.delete(e)},async dispose(){if(u&&=(u(),null),l){try{await e.fs.unwatch(l)}catch{}l=null}d.clear()}}}var Gn=null,Kn=null,qn=null;function Jn(e){return typeof e!=`object`||!e||Array.isArray(e)?(console.error(`[userSettings] settings.json must be an object`),null):e}function Yn(e,t){if(!Gn)return;let n={...Gn.getValue(),...t};Gn.setValue(n),qn&&clearTimeout(qn),qn=setTimeout(()=>{qn=null,Xn(e,n)},500)}async function Xn(e,t){try{Kn||=G(await e.utils.getHomePath(),`.dotdir`,`settings.json`),await e.fs.writeFile(Kn,JSON.stringify(t,null,2))}catch(e){console.error(`[userSettings] Failed to save settings:`,e)}}function Zn(e){return Gn?.onChange(e)??(()=>{})}async function Qn(e){return Gn=await Wn(e,{name:`userSettings`,getPath:async()=>G(await e.utils.getHomePath(),`.dotdir`,`settings.json`),validate:Jn,defaultValue:{}}),Gn.getValue()}var $n=(0,d.atom)({}),er=(0,d.atom)(!1),tr=null;function nr(){let e=(0,d.useAtomValue)($n),t=(0,d.useAtomValue)(er),n=(0,d.useSetAtom)($n),r=(0,d.useSetAtom)(er),i=B();return(0,c.useEffect)(()=>(tr||=Qn(i),tr.then(e=>{n(e),r(!0)}),Zn(n)),[n,r,i]),{settings:e,ready:t,updateSettings:(0,c.useCallback)(e=>{n(t=>({...t,...e})),Yn(i,e)},[n])}}var rr=`_active_jpq35_71`,ir=`_install_jpq35_261`,ar=`_uninstall_jpq35_266`,or=`_installed_jpq35_276`,J={"ext-panel":`_ext-panel_jpq35_1`,"ext-panel-header":`_ext-panel-header_jpq35_17`,"ext-panel-title":`_ext-panel-title_jpq35_28`,"ext-panel-close":`_ext-panel-close_jpq35_34`,"ext-panel-tabs":`_ext-panel-tabs_jpq35_49`,"ext-tab":`_ext-tab_jpq35_55`,active:rr,"ext-search":`_ext-search_jpq35_76`,"ext-source-selector":`_ext-source-selector_jpq35_82`,"ext-source-btn":`_ext-source-btn_jpq35_88`,"ext-error":`_ext-error_jpq35_129`,"ext-list":`_ext-list_jpq35_137`,"ext-empty":`_ext-empty_jpq35_143`,"ext-item":`_ext-item_jpq35_150`,"ext-icon":`_ext-icon_jpq35_162`,"ext-info":`_ext-info_jpq35_184`,"ext-name":`_ext-name_jpq35_189`,"ext-publisher":`_ext-publisher_jpq35_198`,"ext-desc":`_ext-desc_jpq35_204`,"ext-meta":`_ext-meta_jpq35_214`,"ext-theme-badge":`_ext-theme-badge_jpq35_223`,"ext-actions":`_ext-actions_jpq35_234`,"ext-btn":`_ext-btn_jpq35_241`,install:ir,uninstall:ar,installed:or,"ext-color-themes":`_ext-color-themes_jpq35_281`,"ext-color-theme-btn":`_ext-color-theme-btn_jpq35_288`,"ext-color-theme-indicator":`_ext-color-theme-indicator_jpq35_296`};function sr(e){return e instanceof Error?e.message:e&&typeof e==`object`&&`message`in e?String(e.message):String(e)}function cr(){let e=B(),t=(0,d.useSetAtom)(Se),[n,r]=(0,d.useAtom)(Ce),[i,a]=(0,d.useAtom)(we),o=(0,d.useAtomValue)(Te),s=(0,c.useRef)(null),u=bn(),[f,p]=(0,c.useState)(`marketplace`),[m,h]=(0,c.useState)(`vscode`),[g,_]=(0,c.useState)(``),[y,x]=(0,c.useState)([]),[S,w]=(0,c.useState)([]),[T,E]=(0,c.useState)(!1),[O,k]=(0,c.useState)(null),[A,j]=(0,c.useState)(``),ee=(0,c.useRef)(null),{settings:M,updateSettings:N}=nr();(0,c.useEffect)(()=>(v.push(`modal`),()=>{v.pop(`modal`)}),[t]);let te=(0,c.useCallback)(async(e,t)=>{E(!0),j(``);try{t===`vscode`?(w((await zn(e)).extensions),x([])):(x((await En(e)).extensions),w([]))}catch{j(`Could not reach ${t===`vscode`?`VS Code`:`.dir`} marketplace`)}E(!1)},[]);(0,c.useEffect)(()=>{te(``,m)},[te,m]);let ne=e=>{_(e),ee.current&&clearTimeout(ee.current),ee.current=setTimeout(()=>te(e,m),300)},P=async t=>{let n=Hn(t);if(n){k(`${t.publisher.publisherName}.${t.extensionName}`),j(``);try{await Mn(e,t.publisher.publisherName,t.extensionName,n),u.restart()}catch(e){j(`Install failed: ${sr(e)}`)}k(null)}},F=new Set(o.map(e=>`${e.ref.publisher}.${e.ref.name}`)),I=async t=>{if(t.latest_version){k(`${t.publisher.username}.${t.name}`),j(``);try{await An(e,t.publisher.username,t.name,t.latest_version.version),u.restart()}catch(e){j(`Install failed: ${sr(e)}`)}k(null)}},L=async t=>{let o=`${t.publisher}.${t.name}`;k(o),j(``);try{await Pn(e,t.publisher,t.name);let s=!1;n===o&&(delete M.iconTheme,r(void 0),s=!0),i?.startsWith(o+`:`)&&(delete M.colorTheme,a(void 0),s=!0),s&&N(M),u.restart()}catch(e){j(`Uninstall failed: ${sr(e)}`)}k(null)},re=async e=>{let t=Fn(e);if(!t)return;let i=t===n?void 0:t;i?M.iconTheme=i:delete M.iconTheme,N(M),r(i)},ie=async(e,t)=>{let n=In(e,t),r=n===i?void 0:n;r?M.colorTheme=r:delete M.colorTheme,N(M),a(r)},ae=e=>e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(0)} KB`:`${(e/1024/1024).toFixed(1)} MB`;return(0,l.jsxs)(D,{className:J[`ext-panel`],onClose:()=>t(!1),initialFocusRef:s,children:[(0,l.jsxs)(`div`,{className:J[`ext-panel-header`],children:[(0,l.jsx)(`span`,{className:J[`ext-panel-title`],children:`Extensions`}),(0,l.jsx)(`button`,{className:J[`ext-panel-close`],onClick:()=>t(!1),children:`✕`})]}),(0,l.jsxs)(`div`,{className:J[`ext-panel-tabs`],children:[(0,l.jsx)(`button`,{className:C(J,`ext-tab`,f===`marketplace`&&`active`),onClick:()=>p(`marketplace`),children:`Marketplace`}),(0,l.jsxs)(`button`,{className:C(J,`ext-tab`,f===`installed`&&`active`),onClick:()=>p(`installed`),children:[`Installed (`,o.length,`)`]})]}),f===`marketplace`&&(0,l.jsxs)(`div`,{className:J[`ext-search`],children:[(0,l.jsxs)(`div`,{className:J[`ext-source-selector`],children:[(0,l.jsx)(`button`,{className:C(J,`ext-source-btn`,m===`vscode`&&`active`),onClick:()=>{h(`vscode`),_(``)},children:`VS Code`}),(0,l.jsx)(`button`,{className:C(J,`ext-source-btn`,m===`dotdir`&&`active`),onClick:()=>{h(`dotdir`),_(``)},children:`.dir`})]}),(0,l.jsx)(`input`,{ref:s,type:`text`,placeholder:`Search extensions...`,value:g,onChange:e=>ne(e.target.value),...b})]}),A&&(0,l.jsx)(`div`,{className:J[`ext-error`],children:A}),(0,l.jsxs)(`div`,{className:J[`ext-list`],children:[f===`marketplace`&&m===`dotdir`&&(T?(0,l.jsx)(`div`,{className:J[`ext-empty`],children:`Searching...`}):y.length===0?(0,l.jsx)(`div`,{className:J[`ext-empty`],children:`No extensions found`}):y.map(e=>{let t=`${e.publisher.username}.${e.name}`,n=F.has(t),r=O===t;return(0,l.jsxs)(`div`,{className:J[`ext-item`],children:[(0,l.jsx)(`div`,{className:J[`ext-icon`],children:e.icon_url?(0,l.jsx)(`img`,{src:e.icon_url,width:36,height:36,alt:``}):e.display_name[0]?.toUpperCase()??`?`}),(0,l.jsxs)(`div`,{className:J[`ext-info`],children:[(0,l.jsx)(`div`,{className:J[`ext-name`],children:e.display_name}),(0,l.jsx)(`div`,{className:J[`ext-publisher`],children:e.publisher.display_name||e.publisher.username}),(0,l.jsx)(`div`,{className:J[`ext-desc`],children:e.description}),(0,l.jsxs)(`div`,{className:J[`ext-meta`],children:[e.latest_version&&(0,l.jsxs)(`span`,{children:[`v`,e.latest_version.version]}),e.latest_version&&(0,l.jsx)(`span`,{children:ae(e.latest_version.archive_size)}),(0,l.jsxs)(`span`,{children:[`↓ `,e.total_downloads]})]})]}),(0,l.jsx)(`div`,{className:J[`ext-actions`],children:n?(0,l.jsx)(`button`,{className:C(J,`ext-btn`,`installed`),disabled:!0,children:`Installed`}):(0,l.jsx)(`button`,{className:C(J,`ext-btn`,`install`),disabled:r||!e.latest_version,onClick:()=>I(e),children:r?`Installing...`:`Install`})})]},e.id)})),f===`marketplace`&&m===`vscode`&&(T?(0,l.jsx)(`div`,{className:J[`ext-empty`],children:`Searching...`}):S.length===0?(0,l.jsx)(`div`,{className:J[`ext-empty`],children:`No extensions found`}):S.map(e=>{let t=`${e.publisher.publisherName}.${e.extensionName}`,n=F.has(t),r=O===t,i=Vn(e),a=Un(e),o=Bn(e);return(0,l.jsxs)(`div`,{className:J[`ext-item`],children:[(0,l.jsx)(`div`,{className:J[`ext-icon`],children:a?(0,l.jsx)(`img`,{src:a,width:36,height:36,alt:``}):e.displayName[0]?.toUpperCase()??`?`}),(0,l.jsxs)(`div`,{className:J[`ext-info`],children:[(0,l.jsx)(`div`,{className:J[`ext-name`],children:e.displayName}),(0,l.jsx)(`div`,{className:J[`ext-publisher`],children:e.publisher.displayName||e.publisher.publisherName}),(0,l.jsx)(`div`,{className:J[`ext-desc`],children:e.shortDescription}),(0,l.jsxs)(`div`,{className:J[`ext-meta`],children:[i&&(0,l.jsxs)(`span`,{children:[`v`,i]}),(0,l.jsxs)(`span`,{children:[`↓ `,o.toLocaleString()]})]})]}),(0,l.jsx)(`div`,{className:J[`ext-actions`],children:n?(0,l.jsx)(`button`,{className:C(J,`ext-btn`,`installed`),disabled:!0,children:`Installed`}):(0,l.jsx)(`button`,{className:C(J,`ext-btn`,`install`),disabled:r||!i,onClick:()=>P(e),children:r?`Installing...`:`Install`})})]},t)})),f===`installed`&&(o.length===0?(0,l.jsx)(`div`,{className:J[`ext-empty`],children:`No extensions installed`}):o.map(e=>{let t=`${e.ref.publisher}.${e.ref.name}`,r=O===t,a=Fn(e),o=a!=null&&a===n,s=e.colorThemes&&e.colorThemes.length>0;return(0,l.jsxs)(`div`,{className:J[`ext-item`],children:[(0,l.jsx)(`div`,{className:J[`ext-icon`],children:e.iconUrl?(0,l.jsx)(`img`,{src:e.iconUrl,width:36,height:36,alt:``}):(e.manifest.displayName||e.manifest.name)[0]?.toUpperCase()??`?`}),(0,l.jsxs)(`div`,{className:J[`ext-info`],children:[(0,l.jsx)(`div`,{className:J[`ext-name`],children:e.manifest.displayName||e.manifest.name}),(0,l.jsx)(`div`,{className:J[`ext-publisher`],children:e.manifest.publisher}),(0,l.jsx)(`div`,{className:J[`ext-desc`],children:e.manifest.description||``}),(0,l.jsxs)(`div`,{className:J[`ext-meta`],children:[(0,l.jsxs)(`span`,{children:[`v`,e.ref.version]}),a&&(0,l.jsx)(`span`,{className:C(J,`ext-theme-badge`,o&&`active`),children:o?`● Icon theme`:`Icon theme`}),s&&(0,l.jsxs)(`span`,{className:J[`ext-theme-badge`],children:[e.colorThemes.length,` color theme`,e.colorThemes.length>1?`s`:``]}),e.languages&&e.languages.length>0&&(0,l.jsxs)(`span`,{className:J[`ext-theme-badge`],children:[e.languages.length,` language`,e.languages.length>1?`s`:``]}),e.grammarRefs&&e.grammarRefs.length>0&&(0,l.jsxs)(`span`,{className:J[`ext-theme-badge`],children:[e.grammarRefs.length,` grammar`,e.grammarRefs.length>1?`s`:``]})]}),s&&(0,l.jsx)(`div`,{className:J[`ext-color-themes`],children:e.colorThemes.map(t=>{let n=In(e,t.id)===i;return(0,l.jsxs)(`button`,{className:C(J,`ext-btn`,`ext-color-theme-btn`,n?`installed`:`install`),onClick:()=>ie(e,t.id),children:[(0,l.jsx)(`span`,{className:J[`ext-color-theme-indicator`],"data-ui-theme":t.uiTheme}),t.label,n&&` ●`]},t.id)})})]}),(0,l.jsxs)(`div`,{className:J[`ext-actions`],children:[a&&(0,l.jsx)(`button`,{className:C(J,`ext-btn`,o?`installed`:`install`),onClick:()=>re(e),children:o?`Deactivate`:`Activate`}),(0,l.jsx)(`button`,{className:C(J,`ext-btn`,`uninstall`),disabled:r,onClick:()=>L(e.ref),children:r?`Removing...`:`Uninstall`})]})]},t)}))]})]})}var Y=new class{tail=Promise.resolve();enqueue(e){this.tail=this.tail.then(async()=>{try{let t=e();t&&typeof t.then==`function`&&(await t,await new Promise(e=>setTimeout(e,0)))}catch{}})}},lr=200,ur=new Map,dr=new Map;function fr(e){return e.startsWith(`/`)||/^[A-Za-z]:/.test(e)}function pr(e){return`data:image/svg+xml,${encodeURIComponent(e)}`}function mr(e){let t=ur.get(e);t!==void 0&&(ur.delete(e),ur.set(e,t))}function hr(){for(;ur.size>lr;){let e=ur.keys().next().value;ur.delete(e)}}async function gr(e,t){let n=U(t);try{let r=await St(e,n);ur.set(t,pr(r)),hr()}catch(e){throw console.warn(`[IconCache] loadIconAbsolute failed`,n,e),e}}async function _r(e){let t=await fetch(`/icons/${e}`);if(!t.ok)return;let n=await t.text();ur.set(e,pr(n)),hr()}function vr(e){return e===`_default`||e.startsWith(`_default_`)}async function yr(e,t){let n=[];for(let r of t){if(vr(r)||ur.has(r))continue;if(dr.has(r)){n.push(dr.get(r));continue}let t=(async()=>{try{fr(r)?await gr(e,r):await _r(r)}catch(e){console.warn(`[IconCache] loadIcons failed for`,r.slice(-60),e)}finally{dr.delete(r)}})();dr.set(r,t),n.push(t)}await Promise.all(n)}function br(e){let t=ur.get(e);return t!==void 0&&mr(e),t}function xr(e){return`data:image/svg+xml,${encodeURIComponent(e)}`}var Sr=class{theme=null;loadingIcons=new Map;themeKind=`dark`;constructor(e){this.bridge=e}async load(e){let t=await St(this.bridge,e);this.theme={json:JSON.parse(t),basePath:W(e),iconCache:new Map}}setTheme(e){this.themeKind=e}clear(){this.theme=null,this.loadingIcons.clear()}isLoaded(){return this.theme!==null}getEffectiveMap(e,t){return this.themeKind===`light`&&t!==void 0?t:e}resolveIcon(e,t,n,r,i){if(!this.theme)return null;let{json:a}=this.theme,o=this.themeKind===`light`?a.light:void 0,s;if(t){let t=this.getEffectiveMap(n?a.folderNamesExpanded:a.folderNames,n?o?.folderNamesExpanded:o?.folderNames);s=t?.[e]?t[e]:t?.[e.toLowerCase()]?t[e.toLowerCase()]:r?this.getEffectiveMap(n?a.rootFolderExpanded:a.rootFolder,void 0)??this.getEffectiveMap(n?a.folderExpanded:a.folder,n?o?.folderExpanded:o?.folder):this.getEffectiveMap(n?a.folderExpanded:a.folder,n?o?.folderExpanded:o?.folder)}else{let t=this.getEffectiveMap(a.fileNames,o?.fileNames);if(t?.[e])s=t[e];else if(t?.[e.toLowerCase()])s=t[e.toLowerCase()];else{let t=this.getEffectiveMap(a.fileExtensions,o?.fileExtensions);if(t){let n=e.split(`.`);for(let e=1;e<n.length;e++){let r=n.slice(e).join(`.`).toLowerCase();if(t[r]){s=t[r];break}}}!s&&i&&a.languageIds?.[i]&&(s=a.languageIds[i]),s||=this.getEffectiveMap(a.file,o?.file)}}if(!s)return null;let c=a.iconDefinitions[s];return c?.iconPath?G(this.theme.basePath,c.iconPath):null}async loadIcon(e){if(!this.theme)return null;let t=this.theme.iconCache.get(e);if(t)return t;let n=this.loadingIcons.get(e);if(n)return n;let r=(async()=>{try{let t=await xt(this.bridge,e),n=e.split(`.`).pop()?.toLowerCase()??``,r;if(n===`svg`)r=xr(new TextDecoder().decode(t));else{let e=n===`png`?`image/png`:n===`jpg`||n===`jpeg`?`image/jpeg`:n===`webp`?`image/webp`:`application/octet-stream`,i=new Blob([t],{type:e});r=URL.createObjectURL(i)}return this.theme?.iconCache.set(e,r),r}catch{return null}finally{this.loadingIcons.delete(e)}})();return this.loadingIcons.set(e,r),r}async preloadIcons(e){await Promise.all(e.map(e=>this.loadIcon(e)))}getCachedIcon(e){return this.theme?.iconCache.get(e)??null}},Cr=(0,d.atom)(e=>{let t=e(ve);if(!t)throw Error(`Bridge not initialized.`);return new Sr(t)});function wr(){return(0,d.useAtomValue)(Cr)}var Tr={folder:`data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22%2390a4ae%22%3E%3Cpath%20d%3D%22M10%204H4c-1.1%200-2%20.9-2%202v12c0%201.1.9%202%202%202h16c1.1%200%202-.9%202-2V8c0-1.1-.9-2-2-2h-8l-2-2z%22%2F%3E%3C%2Fsvg%3E`,folderOpen:`data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22%2390a4ae%22%3E%3Cpath%20d%3D%22M20%206h-8l-2-2H4c-1.1%200-2%20.9-2%202v12c0%201.1.9%202%202%202h16c1.1%200%202-.9%202-2V8c0-1.1-.9-2-2-2zm0%2012H4V8h16v10z%22%2F%3E%3C%2Fsvg%3E`,file:`data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22%2390a4ae%22%3E%3Cpath%20d%3D%22M14%202H6c-1.1%200-2%20.9-2%202v16c0%201.1.9%202%202%202h12c1.1%200%202-.9%202-2V8l-6-6zm4%2018H6V4h7v5h5v11z%22%2F%3E%3C%2Fsvg%3E`},Er=`fss`,Dr=[];function Or(){let e=wr();return{setIconTheme:async(t,n)=>{if(Er=t,t===`vscode`&&n)try{await e.load(n),jr()}catch{Er=`none`,jr()}else e.clear(),jr()}}}function kr(){let e=wr();return{setIconThemeKind:t=>{e.setTheme(t)}}}function Ar(e){return Dr.push(e),()=>{Dr=Dr.filter(t=>t!==e)}}function jr(){for(let e of Dr)e()}function Mr(){let e=wr();return(t,n,r,i,a,o)=>{let s=n?r?Tr.folderOpen:Tr.folder:Tr.file;if(Er===`vscode`&&e.isLoaded()){let o=e.resolveIcon(t,n,r,i,a);return o?{path:o,url:e.getCachedIcon(o),fallbackUrl:s}:{path:`_default`,url:s,fallbackUrl:s}}return Er===`fss`&&o?{path:o,url:br(o)??null,fallbackUrl:s}:{path:`_default`,url:s,fallbackUrl:s}}}function Nr(){let e=wr(),t=B();return async n=>{Er===`vscode`&&e.isLoaded()?await e.preloadIcons(n):await yr(t,n)}}function Pr(){let e=wr();return t=>t===`_default_folder`?Tr.folder:t===`_default_folder_open`?Tr.folderOpen:t===`_default_file`?Tr.file:Er===`vscode`&&e.isLoaded()?e.getCachedIcon(t):br(t)??null}var Fr=null;function Ir(e){Fr=e}function Lr(){return Fr}var Rr=(0,m.createLayer)(`
113
+ `};function ge(){let e=(0,c.useContext)(fe),t=e?.dialog??null;if(!t)return null;let n=me(t,e);if(!n)return null;let r=he[t.type];return(0,l.jsx)(ee,{helpText:r,children:n})}function _e(){let e=(0,c.useContext)(fe);if(!e)throw Error(`useDialog must be used within DialogProvider`);return e}var ve=(0,d.atom)(null);function B(){let e=(0,d.useAtomValue)(ve);if(!e)throw Error(`Bridge not initialized. Make sure to call initBridge() before rendering.`);return e}function ye({bridge:e,children:t}){let[n,r]=(0,d.useAtom)(ve);return(0,c.useEffect)(()=>{r(e)},[e,r]),n?(0,l.jsx)(l.Fragment,{children:t}):null}var be=[{command:`dotdir.toggleHiddenFiles`,title:`Toggle Hidden Files`,category:`View`},{command:`dotdir.togglePanels`,title:`Toggle Panels`,category:`View`},{command:`dotdir.showExtensions`,title:`Show Extensions`,shortTitle:`Plugins`,category:`View`},{command:`dotdir.showCommandPalette`,title:`Show All Commands`,category:`View`},{command:`dotdir.closeViewer`,title:`Close Viewer`,category:`View`},{command:`dotdir.closeEditor`,title:`Close Editor`,category:`View`},{command:`dotdir.switchPanel`,title:`Switch Panel`,category:`Navigation`},{command:`dotdir.focusLeftPanel`,title:`Focus Left Panel`,category:`Navigation`},{command:`dotdir.focusRightPanel`,title:`Focus Right Panel`,category:`Navigation`},{command:`dotdir.cancelNavigation`,title:`Cancel Navigation`,category:`Navigation`},{command:`dotdir.goToParent`,title:`Go to Parent Directory`,category:`Navigation`},{command:`dotdir.goHome`,title:`Go to Home Directory`,category:`Navigation`},{command:`dotdir.refresh`,title:`Refresh`,category:`File`},{command:`dotdir.newTab`,title:`New Tab`,category:`File`},{command:`dotdir.closeTab`,title:`Close Tab`,category:`File`},{command:`dotdir.previewInOppositePanel`,title:`Show Preview in Opposite Panel`,category:`File`},{command:`dotdir.openCurrentFolderInOppositePanelCurrentTab`,title:`Open Current Folder in Opposite Panel (Current Tab)`,category:`File`},{command:`dotdir.openCurrentFolderInOppositePanelNewTab`,title:`Open Current Folder in Opposite Panel (New Tab)`,category:`File`},{command:`dotdir.openSelectedFolderInOppositePanelCurrentTab`,title:`Open Selected Folder in Opposite Panel (Current Tab)`,category:`File`},{command:`dotdir.openSelectedFolderInOppositePanelNewTab`,title:`Open Selected Folder in Opposite Panel (New Tab)`,category:`File`},{command:`dotdir.openCreateFile`,title:`Open / Create File`,shortTitle:`New File`,category:`File`},{command:`dotdir.makeFolder`,title:`Make Folder`,shortTitle:`MkDir`,category:`File`},{command:`dotdir.viewFile`,title:`View File`,shortTitle:`View`,category:`File`},{command:`dotdir.editFile`,title:`Edit File`,shortTitle:`Edit`,category:`File`},{command:`dotdir.exit`,title:`Exit`,shortTitle:`Quit`,category:`Application`},{command:`terminal.execute`,title:`Execute in Terminal`,category:`Terminal`},{command:`list.cursorUp`,title:`Cursor Up`,category:`Navigation`},{command:`list.cursorDown`,title:`Cursor Down`,category:`Navigation`},{command:`list.cursorLeft`,title:`Cursor Left (Previous Column)`,category:`Navigation`},{command:`list.cursorRight`,title:`Cursor Right (Next Column)`,category:`Navigation`},{command:`list.cursorHome`,title:`Cursor to First`,category:`Navigation`},{command:`list.cursorEnd`,title:`Cursor to Last`,category:`Navigation`},{command:`list.cursorPageUp`,title:`Cursor Page Up`,category:`Navigation`},{command:`list.cursorPageDown`,title:`Cursor Page Down`,category:`Navigation`},{command:`list.selectUp`,title:`Select Up`,category:`Navigation`},{command:`list.selectDown`,title:`Select Down`,category:`Navigation`},{command:`list.selectLeft`,title:`Select Left`,category:`Navigation`},{command:`list.selectRight`,title:`Select Right`,category:`Navigation`},{command:`list.selectHome`,title:`Select to First`,category:`Navigation`},{command:`list.selectEnd`,title:`Select to Last`,category:`Navigation`},{command:`list.selectPageUp`,title:`Select Page Up`,category:`Navigation`},{command:`list.selectPageDown`,title:`Select Page Down`,category:`Navigation`},{command:`list.execute`,title:`Execute in Terminal`,category:`Navigation`},{command:`list.open`,title:`Open`,category:`Navigation`},{command:`list.viewFile`,title:`View File`,shortTitle:`View`,category:`Navigation`},{command:`list.editFile`,title:`Edit File`,shortTitle:`Edit`,category:`Navigation`},{command:`list.moveToTrash`,title:`Move to Trash`,shortTitle:`Trash`,category:`File`},{command:`list.permanentDelete`,title:`Permanently Delete`,shortTitle:`Del Perm`,category:`File`},{command:`list.copy`,title:`Copy`,shortTitle:`Copy`,category:`File`},{command:`list.move`,title:`Move`,shortTitle:`Move`,category:`File`},{command:`list.rename`,title:`Rename`,shortTitle:`Rename`,category:`File`},{command:`list.pasteFilename`,title:`Paste Filename to Command Line`,category:`File`},{command:`list.pastePath`,title:`Paste Path to Command Line`,category:`File`},{command:`commandLine.execute`,title:`Execute Command Line`,category:`Command Line`},{command:`commandLine.clear`,title:`Clear Command Line`,category:`Command Line`},{command:`commandLine.deleteLeft`,title:`Delete Left`,category:`Command Line`},{command:`commandLine.deleteRight`,title:`Delete Right`,category:`Command Line`},{command:`commandLine.moveWordLeft`,title:`Move Word Left`,category:`Command Line`},{command:`commandLine.moveWordRight`,title:`Move Word Right`,category:`Command Line`},{command:`commandLine.home`,title:`Move to Start`,category:`Command Line`},{command:`commandLine.end`,title:`Move to End`,category:`Command Line`},{command:`commandLine.selectAll`,title:`Select All`,category:`Command Line`},{command:`commandLine.selectLeft`,title:`Extend Selection Left`,category:`Command Line`},{command:`commandLine.selectRight`,title:`Extend Selection Right`,category:`Command Line`},{command:`commandLine.selectHome`,title:`Extend Selection to Start`,category:`Command Line`},{command:`commandLine.selectEnd`,title:`Extend Selection to End`,category:`Command Line`},{command:`commandLine.copy`,title:`Copy Selection`,category:`Command Line`},{command:`commandLine.cut`,title:`Cut Selection`,category:`Command Line`},{command:`commandLine.paste`,title:`Paste from Clipboard`,category:`Command Line`}],V=new class e{contributions=new Map;handlers=new Map;keybindingLayers={default:[],extension:[],user:[]};contextGetter=()=>({});contextValues={};listeners=new Set;batchDepth=0;batchDirty=!1;beginBatch(){this.batchDepth++}endBatch(){this.batchDepth--,this.batchDepth===0&&this.batchDirty&&(this.batchDirty=!1,this.notifyListeners())}setContext(e,t){this.contextValues[e]!==t&&(this.contextValues[e]=t,this.batchDepth>0?this.batchDirty=!0:this.notifyListeners())}getContext(e){return this.contextValues[e]}registerContributions(e){for(let t of e)this.contributions.set(t.command,t);return this.notifyListeners(),()=>{for(let t of e)this.contributions.delete(t.command);this.notifyListeners()}}registerCommand(e,t){return this.handlers.set(e,t),this.notifyListeners(),()=>{this.handlers.delete(e),this.notifyListeners()}}registerKeybinding(e,t=`default`){return this.keybindingLayers[t].push(e),this.notifyListeners(),()=>{let n=this.keybindingLayers[t],r=n.indexOf(e);r>=0&&n.splice(r,1),this.notifyListeners()}}setLayerKeybindings(e,t){this.keybindingLayers[e]=t,this.notifyListeners()}clearLayerKeybindings(e){this.keybindingLayers[e]=[],this.notifyListeners()}setContextGetter(e){this.contextGetter=e}async executeCommand(e,...t){let n=this.handlers.get(e);if(!n){console.warn(`Command not found: ${e}`);return}try{await n(...t)}catch(t){console.error(`Command ${e} failed:`,t)}}getCommand(e){let t=this.contributions.get(e);if(t)return{id:t.command,title:t.title,shortTitle:t.shortTitle,category:t.category,icon:t.icon}}getAllCommands(){return Array.from(this.contributions.values()).map(e=>({id:e.command,title:e.title,shortTitle:e.shortTitle,category:e.category,icon:e.icon}))}getKeybindings(){let e=new Map;for(let t of[`default`,`extension`,`user`])for(let n of this.keybindingLayers[t]){let t=`${this.normalizeKey(this.isMac()?n.mac??n.key:n.key)}|${n.when??``}`;e.set(t,n)}return Array.from(e.values())}getKeybindingsForLayer(e){return[...this.keybindingLayers[e]]}getKeybindingForCommand(e){return this.getKeybindings().find(t=>t.command===e)}evaluateWhen(t){if(!t)return!0;let n=this.contextGetter(),r=v.current,i={...n,...this.contextValues,focusPanel:r===`panel`,focusViewer:r===`viewer`,focusEditor:r===`editor`,focusTerminal:r===`terminal`,focusCommandPalette:r===`commandPalette`,focusModal:r===`modal`};return e.evalWhen(t,i)}static evalWhen(e,t){try{return e.split(/\s*&&\s*/).every(e=>e.trim().split(/\s*\|\|\s*/).some(e=>{let n=e.trim(),r=n.startsWith(`!`),i=r?n.slice(1):n;return r?!t[i]:!!t[i]}))}catch{return!0}}handleKeyboardEvent(e){let t=this.eventToKeyCombo(e);if(!t)return!1;for(let n of[`user`,`extension`,`default`])for(let r of this.keybindingLayers[n])if(this.normalizeKey(this.isMac()?r.mac??r.key:r.key)===t&&this.evaluateWhen(r.when))return e.preventDefault(),e.stopPropagation(),this.executeCommand(r.command),!0;return!1}isMac(){return navigator.platform.toUpperCase().includes(`MAC`)}physicalCodeToKeyPart(e){if(e.startsWith(`Key`)&&e.length===4)return e[3].toLowerCase();if(e.startsWith(`Digit`))return e.slice(5);let t=/^Numpad(\d)$/.exec(e);if(t)return t[1];let n=/^F(\d{1,2})$/.exec(e);if(n)return`f${n[1]}`;let r={Space:`space`,Enter:`enter`,NumpadEnter:`enter`,Tab:`tab`,Escape:`escape`,Backspace:`backspace`,Delete:`delete`,Insert:`insert`,ArrowUp:`up`,ArrowDown:`down`,ArrowLeft:`left`,ArrowRight:`right`,Home:`home`,End:`end`,PageUp:`pageup`,PageDown:`pagedown`,Minus:`-`,Equal:`=`,BracketLeft:`[`,BracketRight:`]`,Backslash:`\\`,Semicolon:`;`,Quote:`'`,Comma:`,`,Period:`.`,Slash:`/`,Backquote:"`",IntlBackslash:`\\`};return r[e]?r[e]:null}keyStringToKeyPart(e){if(!e||[`Control`,`Alt`,`Shift`,`Meta`].includes(e))return null;if(e.length===1)return e.toLowerCase();let t=e.toLowerCase();return t===` `?t=`space`:t===`arrowup`?t=`up`:t===`arrowdown`?t=`down`:t===`arrowleft`?t=`left`:t===`arrowright`?t=`right`:t===`escape`?t=`escape`:t===`enter`?t=`enter`:t===`backspace`?t=`backspace`:t===`delete`?t=`delete`:t===`tab`&&(t=`tab`),t}eventToKeyCombo(e){if([`Control`,`Alt`,`Shift`,`Meta`].includes(e.key))return null;let t=[];(e.ctrlKey||e.metaKey)&&t.push(`ctrl`),e.altKey&&t.push(`alt`),e.shiftKey&&t.push(`shift`);let n=(e.code&&this.physicalCodeToKeyPart(e.code))??this.keyStringToKeyPart(e.key);return n?(t.push(n),t.join(`+`)):null}normalizeKey(e){return e.toLowerCase().replace(/cmd/g,`ctrl`).replace(/meta/g,`ctrl`).replace(/mod/g,`ctrl`).split(`+`).map(e=>e.trim()).sort((e,t)=>{let n=[`ctrl`,`alt`,`shift`],r=n.indexOf(e),i=n.indexOf(t);return r>=0&&i>=0?r-i:r>=0?-1:i>=0?1:0}).join(`+`)}onChange(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notifyListeners(){for(let e of this.listeners)e()}};function xe(e){let t=navigator.platform.toUpperCase().includes(`MAC`);return(t?e.mac??e.key:e.key).split(`+`).map(e=>{let n=e.trim().toLowerCase();if(t){if(n===`ctrl`||n===`cmd`||n===`mod`)return`⌘`;if(n===`alt`)return`⌥`;if(n===`shift`)return`⇧`}else{if(n===`ctrl`||n===`cmd`||n===`mod`)return`Ctrl`;if(n===`alt`)return`Alt`;if(n===`shift`)return`Shift`}return n===`enter`?`↵`:n===`escape`?`Esc`:n===`backspace`?`⌫`:n===`delete`?`Del`:n===`up`?`↑`:n===`down`?`↓`:n===`left`?`←`:n===`right`?`→`:n===`space`?`Space`:n===`tab`?`Tab`:n.toUpperCase()}).join(t?``:`+`)}var Se=(0,d.atom)(!1),Ce=(0,d.atom)(void 0),we=(0,d.atom)(void 0),Te=(0,d.atom)([]),Ee=(0,d.atom)(!1),De=(0,d.atom)([]),Oe=(0,d.atom)(!1),ke=(0,d.atom)(`dark`),Ae=(0,d.atom)(!0);(0,d.atom)(!0);var je=(0,d.atom)(0),Me=(0,d.atom)(null),Ne=(0,d.atom)(`left`),Pe=(0,d.atom)(!1),Fe=(0,d.atom)(!1),Ie=(0,d.atom)(null),Le=(0,d.atom)(null),Re=(0,d.atom)(``),ze=(0,d.atom)(null),Be=(0,d.atom)(null),Ve=`_disabled_11mfr_28`,He={"action-bar":`_action-bar_11mfr_1`,"action-bar-item":`_action-bar-item_11mfr_13`,disabled:Ve,"action-bar-key":`_action-bar-key_11mfr_40`,"action-bar-label":`_action-bar-label_11mfr_41`};function Ue(e,t,n){let r=[];return e&&r.push(`ctrl`),n&&r.push(`alt`),t&&r.push(`shift`),r.length>0?r.join(`+`)+`+`:``}function We(){let[e,t]=(0,c.useState)([]),[n,r]=(0,c.useState)({ctrl:!1,shift:!1,alt:!1}),i=(0,c.useCallback)(()=>{let e=Ue(n.ctrl,n.shift,n.alt),r=V.getKeybindings(),i=[];for(let t=1;t<=12;t++){let n=e+`f${t}`,a=r.find(e=>e.key.toLowerCase().replace(/\s/g,``)===n);if(a&&V.evaluateWhen(a.when)){let e=V.getCommand(a.command);i.push({fKey:t,command:e,keybinding:a});continue}i.push({fKey:t})}t(i)},[n]);(0,c.useEffect)(()=>(i(),V.onChange(i)),[i]),(0,c.useEffect)(()=>{let e=e=>{r({ctrl:e.ctrlKey||e.metaKey,shift:e.shiftKey,alt:e.altKey})},t=e=>{r({ctrl:e.ctrlKey||e.metaKey,shift:e.shiftKey,alt:e.altKey})},n=()=>{r({ctrl:!1,shift:!1,alt:!1})};return window.addEventListener(`keydown`,e),window.addEventListener(`keyup`,t),window.addEventListener(`blur`,n),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`keyup`,t),window.removeEventListener(`blur`,n)}},[]);let a=(0,c.useCallback)(e=>{e.command&&V.executeCommand(e.command.id)},[]);return(0,l.jsx)(`div`,{className:He[`action-bar`],children:e.map(e=>(0,l.jsxs)(`div`,{className:C(He,`action-bar-item`,!e.command&&`disabled`),onClick:()=>a(e),children:[(0,l.jsxs)(`span`,{className:He[`action-bar-key`],children:[`F`,e.fKey]}),(0,l.jsx)(`span`,{className:He[`action-bar-label`],children:e.command?e.command.shortTitle??e.command.title:``})]},e.fKey))})}function Ge(e,t,n){return t.map(t=>e.registerKeybinding(t,n))}var Ke=[{command:`dotdir.toggleHiddenFiles`,key:`ctrl+.`,mac:`cmd+.`},{command:`dotdir.togglePanels`,key:`ctrl+o`,mac:`cmd+o`,when:`!terminalCommandRunning`},{command:`dotdir.showExtensions`,key:`f11`},{command:`dotdir.switchPanel`,key:`tab`,when:`focusPanel && !dialogOpen`},{command:`dotdir.cancelNavigation`,key:`escape`,when:`focusPanel`},{command:`dotdir.goToParent`,key:`alt+pageup`,when:`focusPanel`},{command:`dotdir.goHome`,key:`ctrl+home`,mac:`cmd+home`},{command:`dotdir.newTab`,key:`ctrl+t`,mac:`cmd+t`,when:`focusPanel`},{command:`dotdir.closeTab`,key:`ctrl+w`,mac:`cmd+w`,when:`focusPanel`},{command:`dotdir.previewInOppositePanel`,key:`ctrl+shift+o`,mac:`cmd+shift+o`,when:`focusPanel && listItemIsFile`},{command:`dotdir.refresh`,key:`ctrl+r`,mac:`cmd+r`,when:`focusPanel`},{command:`dotdir.openCreateFile`,key:`shift+f4`,when:`focusPanel`},{command:`dotdir.makeFolder`,key:`f7`,when:`focusPanel`},{command:`dotdir.showCommandPalette`,key:`cmd+shift+p`},{command:`dotdir.showCommandPalette`,key:`cmd+p`},{command:`dotdir.closeViewer`,key:`escape`,when:`focusViewer`},{command:`dotdir.closeEditor`,key:`escape`,when:`focusEditor`},{command:`dotdir.exit`,key:`f10`},{command:`dotdir.exit`,key:`cmd+q`,mac:`cmd+q`}],qe=[{command:`commandLine.execute`,key:`enter`,when:`focusPanel && commandLineHasText`},{command:`commandLine.clear`,key:`escape`,when:`focusPanel && commandLineHasText`},{command:`commandLine.deleteLeft`,key:`backspace`,when:`focusPanel && commandLineHasText`},{command:`commandLine.deleteRight`,key:`delete`,when:`focusPanel && commandLineHasText`},{command:`commandLine.moveWordLeft`,key:`ctrl+left`,when:`focusPanel && commandLineHasText`},{command:`commandLine.moveWordRight`,key:`ctrl+right`,when:`focusPanel && commandLineHasText`},{command:`commandLine.home`,key:`home`,when:`focusPanel && commandLineHasText`},{command:`commandLine.end`,key:`end`,when:`focusPanel && commandLineHasText`},{command:`commandLine.selectAll`,key:`ctrl+a`,when:`focusPanel && commandLineHasText`},{command:`commandLine.copy`,key:`ctrl+c`,when:`focusPanel && commandLineHasText`},{command:`commandLine.cut`,key:`ctrl+x`,when:`focusPanel && commandLineHasText`},{command:`commandLine.paste`,key:`ctrl+v`,when:`focusPanel`}],Je=[{command:`list.cursorUp`,key:`up`,when:`focusPanel`},{command:`list.cursorDown`,key:`down`,when:`focusPanel`},{command:`list.cursorLeft`,key:`left`,when:`focusPanel`},{command:`list.cursorRight`,key:`right`,when:`focusPanel`},{command:`list.cursorHome`,key:`home`,when:`focusPanel`},{command:`list.cursorEnd`,key:`end`,when:`focusPanel`},{command:`list.cursorPageUp`,key:`pageup`,when:`focusPanel`},{command:`list.cursorPageDown`,key:`pagedown`,when:`focusPanel`},{command:`list.selectUp`,key:`shift+up`,when:`focusPanel`},{command:`list.selectDown`,key:`shift+down`,when:`focusPanel`},{command:`list.selectLeft`,key:`shift+left`,when:`focusPanel`},{command:`list.selectRight`,key:`shift+right`,when:`focusPanel`},{command:`list.selectHome`,key:`shift+home`,when:`focusPanel`},{command:`list.selectEnd`,key:`shift+end`,when:`focusPanel`},{command:`list.selectPageUp`,key:`shift+pageup`,when:`focusPanel`},{command:`list.selectPageDown`,key:`shift+pagedown`,when:`focusPanel`},{command:`list.execute`,key:`enter`,when:`focusPanel && listItemIsExecutable && !commandLineHasText`},{command:`list.open`,key:`enter`,when:`focusPanel && !listItemIsExecutable && !commandLineHasText`},{command:`list.open`,key:`alt+pagedown`,when:`focusPanel`},{command:`list.viewFile`,key:`f3`,when:`focusPanel && listItemHasViewer`},{command:`list.editFile`,key:`f4`,when:`focusPanel && listItemHasEditor`},{command:`list.moveToTrash`,key:`f8`,when:`focusPanel`},{command:`list.permanentDelete`,key:`shift+delete`,when:`focusPanel`},{command:`list.copy`,key:`f5`,when:`focusPanel`},{command:`list.move`,key:`f6`,when:`focusPanel`},{command:`list.rename`,key:`shift+f6`,when:`focusPanel`},{command:`list.pasteFilename`,key:`ctrl+enter`,when:`focusPanel`},{command:`list.pastePath`,key:`ctrl+f`,when:`focusPanel`}];function Ye(e){return Qe(e,Ke,`default`)}function Xe(e){return Qe(e,qe,`default`)}function Ze(e){return Qe(e,Je,`default`)}function Qe(e,t,n){return Ge(e,t,n)}function $e(e,t){return e.registerKeybinding(t,`extension`)}function et(e,t){return Ge(e,t,`extension`)}var tt=`_hidden_l0nwk_20`,nt=`_active_l0nwk_145`,H={"terminal-and-panels":`_terminal-and-panels_l0nwk_1`,"command-line":`_command-line_l0nwk_7`,hidden:tt,"command-line-prompt":`_command-line-prompt_l0nwk_24`,"command-line-input":`_command-line-input_l0nwk_35`,"command-line-text":`_command-line-text_l0nwk_42`,"command-line-cursor":`_command-line-cursor_l0nwk_46`,"command-line-selected":`_command-line-selected_l0nwk_66`,"terminal-background":`_terminal-background_l0nwk_71`,"terminal-panel":`_terminal-panel_l0nwk_82`,"terminal-body":`_terminal-body_l0nwk_92`,"terminal-container":`_terminal-container_l0nwk_101`,"terminal-toolbar":`_terminal-toolbar_l0nwk_108`,"terminal-tabs":`_terminal-tabs_l0nwk_122`,"terminal-tab":`_terminal-tab_l0nwk_122`,active:nt,"terminal-tab-add":`_terminal-tab-add_l0nwk_150`,"terminal-tab-status":`_terminal-tab-status_l0nwk_155`,"status-running":`_status-running_l0nwk_163`,"status-starting":`_status-starting_l0nwk_167`,"status-error":`_status-error_l0nwk_171`,"status-exited":`_status-exited_l0nwk_175`,"terminal-tab-label":`_terminal-tab-label_l0nwk_179`,"terminal-tab-close":`_terminal-tab-close_l0nwk_185`,"terminal-profile-picker":`_terminal-profile-picker_l0nwk_190`,"terminal-profile-label":`_terminal-profile-label_l0nwk_197`,"terminal-profile-shell":`_terminal-profile-shell_l0nwk_213`,"terminal-status-error":`_terminal-status-error_l0nwk_222`,"terminal-loading":`_terminal-loading_l0nwk_230`};function rt(){let e=(0,d.useAtomValue)(Re),t=(0,d.useAtomValue)(Ae),n=(0,d.useAtomValue)(ze),r=(0,d.useSetAtom)(Be),[i,a]=(0,c.useState)(``),[o,s]=(0,c.useState)(0),[u,f]=(0,c.useState)(0),p=(0,c.useRef)(!1),m=(0,c.useRef)(null),h=(0,c.useRef)(i),g=(0,c.useRef)(o),_=(0,c.useRef)(u),v=(0,c.useRef)(null);h.current=i,g.current=o,_.current=u,n&&(v.current=n),(0,c.useEffect)(()=>(r(()=>e=>{let t=g.current,n=_.current,r=Math.min(t,n),i=Math.max(t,n),o=r+e.length;a(t=>t.slice(0,r)+e+t.slice(i)),s(o),f(o)}),()=>r(()=>()=>{})),[r]),(0,c.useEffect)(()=>{V.setContext(`commandLineHasText`,t&&i.length>0)},[t,i]);let y=(0,c.useCallback)(()=>{let e=g.current,t=_.current;if(e===t)return!1;let n=Math.min(e,t),r=Math.max(e,t);return a(e=>e.slice(0,n)+e.slice(r)),s(n),f(n),!0},[]),b=(0,c.useCallback)((e,t)=>{s(e),t||f(e)},[]);(0,c.useEffect)(()=>{let e=[];return e.push(V.registerCommand(`commandLine.execute`,()=>{let e=h.current.trim();e&&(v.current?.(e),a(``),s(0),f(0))})),e.push(V.registerCommand(`commandLine.clear`,()=>{g.current===_.current?(a(``),s(0),f(0)):f(g.current)})),e.push(V.registerCommand(`commandLine.deleteLeft`,()=>{let e=g.current;e===_.current?e>0&&(a(t=>t.slice(0,e-1)+t.slice(e)),s(e-1),f(e-1)):y()})),e.push(V.registerCommand(`commandLine.deleteRight`,()=>{if(!y()){let e=g.current;e<h.current.length&&a(t=>t.slice(0,e)+t.slice(e+1))}})),e.push(V.registerCommand(`commandLine.moveWordLeft`,()=>{let e=h.current,t=g.current;for(;t>0&&e[t-1]===` `;)t--;for(;t>0&&e[t-1]!==` `;)t--;b(t,!1)})),e.push(V.registerCommand(`commandLine.moveWordRight`,()=>{let e=h.current,t=g.current;for(;t<e.length&&e[t]!==` `;)t++;for(;t<e.length&&e[t]===` `;)t++;b(t,!1)})),e.push(V.registerCommand(`commandLine.home`,()=>b(0,!1))),e.push(V.registerCommand(`commandLine.end`,()=>b(h.current.length,!1))),e.push(V.registerCommand(`commandLine.selectAll`,()=>{h.current.length!==0&&(f(0),s(h.current.length))})),e.push(V.registerCommand(`commandLine.selectLeft`,()=>b(Math.max(0,g.current-1),!0))),e.push(V.registerCommand(`commandLine.selectRight`,()=>b(Math.min(h.current.length,g.current+1),!0))),e.push(V.registerCommand(`commandLine.selectHome`,()=>b(0,!0))),e.push(V.registerCommand(`commandLine.selectEnd`,()=>b(h.current.length,!0))),e.push(V.registerCommand(`commandLine.copy`,()=>{let e=g.current,t=_.current;if(e===t)return;let n=Math.min(e,t),r=Math.max(e,t);navigator.clipboard.writeText(h.current.slice(n,r)).catch(()=>{})})),e.push(V.registerCommand(`commandLine.cut`,()=>{let e=g.current,t=_.current;if(e===t)return;let n=Math.min(e,t),r=Math.max(e,t);navigator.clipboard.writeText(h.current.slice(n,r)).catch(()=>{}),y()})),e.push(V.registerCommand(`commandLine.paste`,()=>{navigator.clipboard.readText().then(e=>{if(!e)return;let t=g.current,n=_.current,r=Math.min(t,n),i=Math.max(t,n),o=r+e.length;a(t=>t.slice(0,r)+e+t.slice(i)),s(o),f(o)}).catch(()=>{})})),()=>{for(let t of e)t()}},[y,b]),(0,c.useEffect)(()=>{if(!t)return;let e=[];return e.push(...Xe(V)),()=>{for(let t of e)t()}},[t]),(0,c.useEffect)(()=>{if(!t)return;let e=e=>{let t=e.target;if(t&&!t.closest?.(`.${H[`terminal-container`]}`)&&!t.closest?.(`dialog`)&&!(e.ctrlKey||e.metaKey)&&!e.altKey&&!e.metaKey&&e.key.length===1){e.preventDefault(),e.stopPropagation();let t=g.current,n=_.current,r=Math.min(t,n),i=Math.max(t,n);a(t=>t.slice(0,r)+e.key+t.slice(i)),s(r+1),f(r+1)}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let x=(0,c.useCallback)((e,t)=>{let n=m.current;if(!n)return h.current.length;let r=n.getBoundingClientRect(),i=document.elementFromPoint(e,t);if(!i||!n.contains(i))return e<r.left?0:h.current.length;let a=i;for(;a&&a!==n&&!a.hasAttribute(`data-start`);)a=a.parentElement;if(!a||a===n||!a.hasAttribute(`data-start`))return e<r.left?0:h.current.length;let o=parseInt(a.getAttribute(`data-start`),10),s=a.firstChild;if(!(s instanceof Text)||!s.textContent?.length)return o;let c=s.textContent.length,l=document.createRange(),u=0,d=c;for(;u<d;){let t=u+d>>1;l.setStart(s,t),l.setEnd(s,t+1),l.getBoundingClientRect().right<=e?u=t+1:d=t}if(u<c){l.setStart(s,u),l.setEnd(s,u+1);let t=l.getBoundingClientRect();e>=t.left+t.width/2&&u++}return Math.min(o+u,h.current.length)},[]),S=(0,c.useCallback)(e=>{e.preventDefault();let t=x(e.clientX,e.clientY);s(t),f(t),p.current=!0;let n=e=>{p.current&&s(x(e.clientX,e.clientY))},r=()=>{p.current=!1,window.removeEventListener(`mousemove`,n),window.removeEventListener(`mouseup`,r)};window.addEventListener(`mousemove`,n),window.addEventListener(`mouseup`,r)},[x]),w=e.length>40?`…`+e.slice(e.length-39):e,T=Math.min(o,u)<Math.max(o,u),E;return E=T?o<=u?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`span`,{className:H[`command-line-text`],"data-start":0,children:i.slice(0,o)}),(0,l.jsx)(`span`,{className:H[`command-line-cursor`]}),(0,l.jsx)(`span`,{className:H[`command-line-selected`],"data-start":o,children:i.slice(o,u)}),(0,l.jsx)(`span`,{className:H[`command-line-text`],"data-start":u,children:i.slice(u)})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`span`,{className:H[`command-line-text`],"data-start":0,children:i.slice(0,u)}),(0,l.jsx)(`span`,{className:H[`command-line-selected`],"data-start":u,children:i.slice(u,o)}),(0,l.jsx)(`span`,{className:H[`command-line-cursor`]}),(0,l.jsx)(`span`,{className:H[`command-line-text`],"data-start":o,children:i.slice(o)})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`span`,{className:H[`command-line-text`],"data-start":0,children:i.slice(0,o)}),(0,l.jsx)(`span`,{className:H[`command-line-cursor`]}),(0,l.jsx)(`span`,{className:H[`command-line-text`],"data-start":o,children:i.slice(o)})]}),(0,l.jsxs)(`div`,{className:C(H,`command-line`,!t&&`hidden`),children:[(0,l.jsxs)(`span`,{className:H[`command-line-prompt`],children:[w,`>`]}),(0,l.jsx)(`span`,{ref:m,className:H[`command-line-input`],onMouseDown:S,children:E})]})}var it={"command-palette-dialog":`_command-palette-dialog_2w2i0_1`,"command-palette":`_command-palette_2w2i0_1`,"command-item-keybinding":`_command-item-keybinding_2w2i0_73`,"command-item-title":`_command-item-title_2w2i0_78`};function at({open:e,onOpenChange:t}){let n=(0,c.useRef)(null),[r,i]=(0,c.useState)(``),[a,o]=(0,c.useState)([]),[s,u]=(0,c.useState)([]);(0,c.useEffect)(()=>{if(e){let e=requestAnimationFrame(()=>{n.current?.focus()});return()=>cancelAnimationFrame(e)}},[e]),(0,c.useEffect)(()=>{let t=()=>{o(V.getAllCommands()),u(V.getKeybindings())};if(t(),e)return V.onChange(t)},[e]);let d=(0,c.useMemo)(()=>a.map(e=>({command:e,keybinding:s.find(t=>t.command===e.id),displayTitle:e.category?`${e.category}: ${e.title}`:e.title})),[a,s]),p=(0,c.useMemo)(()=>{let e=new Map;for(let t of d){let n=t.command.category??`General`;e.has(n)||e.set(n,[]),e.get(n).push(t)}return Array.from(e.entries()).sort((e,t)=>e[0].localeCompare(t[0]))},[d]),m=(0,c.useCallback)(e=>{t(!1),i(``),V.executeCommand(e)},[t]);(0,c.useEffect)(()=>{e||i(``)},[e]),(0,c.useEffect)(()=>{if(e)return v.push(`commandPalette`),()=>v.pop(`commandPalette`)},[e]);let h=(0,c.useCallback)(e=>{e.stopPropagation()},[]);return e?(0,l.jsx)(D,{className:it[`command-palette-dialog`],onClose:()=>t(!1),initialFocusRef:n,placement:`top`,children:(0,l.jsxs)(f.Command,{className:it[`command-palette`],onKeyDown:h,shouldFilter:!0,children:[(0,l.jsx)(f.Command.Input,{ref:n,value:r,onValueChange:i,placeholder:`Type a command or search...`,...b}),(0,l.jsxs)(f.Command.List,{children:[(0,l.jsx)(f.Command.Empty,{children:`No results found.`}),p.map(([e,t])=>(0,l.jsx)(f.Command.Group,{heading:e,children:t.map(({command:e,keybinding:t,displayTitle:n})=>(0,l.jsxs)(f.Command.Item,{value:n,onSelect:()=>m(e.id),children:[(0,l.jsx)(`span`,{className:it[`command-item-title`],children:e.title}),t&&(0,l.jsx)(`span`,{className:it[`command-item-keybinding`],children:xe(t)})]},e.id))},e))]})]})}):null}function ot(){let[e,t]=(0,d.useAtom)(Fe);return(0,c.useEffect)(()=>{let n=n=>{if(e&&n.key===`Escape`){n.preventDefault(),n.stopPropagation(),t(!1);return}if(e&&(n.metaKey||n.ctrlKey)&&n.key.toLowerCase()===`p`){n.preventDefault(),n.stopPropagation(),t(e=>!e);return}};return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[e]),{open:e,setOpen:t}}var st=/^[A-Za-z]:$/,ct=/^[A-Za-z]:\/$/;function lt(e){return e.startsWith(`//`)}function ut(e){return lt(e)?`//${e.slice(2).replace(/\/+/g,`/`)}`:e.replace(/\/+/g,`/`)}function dt(e){return e.startsWith(`/`)||lt(e)||/^[A-Za-z]:\//.test(e)}function U(e){if(!e)return e;let t=ut(e.replace(/\\/g,`/`));return t=t.replace(/\/\.\//g,`/`).replace(/^\.\//,``),t.endsWith(`/.`)&&(t=t.slice(0,-2)),st.test(t)&&(t=`${t}/`),t.length>1&&t.endsWith(`/`)&&!ct.test(t)&&(t=t.replace(/\/+$/,``)),t}function ft(e){let t=U(e);return lt(t)?t.slice(2).split(`/`).filter(Boolean).length===2:!1}function pt(e){let t=U(e);return t===`/`||ct.test(t)||ft(t)}function W(e){let t=U(e);if(!t)return`.`;if(pt(t))return t;let n=t.replace(/\/+$/,``),r=n.lastIndexOf(`/`);if(r<0)return`.`;if(r===0)return`/`;let i=n.slice(0,r);return st.test(i)?`${i}/`:i||`/`}function G(...e){let t=``;for(let n of e){if(!n)continue;let e=U(n);if(!t||dt(e)){t=e;continue}t=U(`${t.replace(/\/+$/,``)}/${e.replace(/^\/+/,``)}`)}return t}function mt(e){let t=ut(e.replace(/\\/g,`/`));if(!t)return t;let n=/^([A-Za-z]):(\/.*)?$/i.exec(t);if(n){let e=n[1].toUpperCase(),t=ht((n[2]??`/`).replace(/^\//,``).split(`/`).filter(e=>e!==``),!0);return t.length===0?`${e}:/`:`${e}:/${t.join(`/`)}`}if(lt(t)){let e=t.slice(2).split(`/`).filter(Boolean);if(e.length<2)return t;let n=`//${e[0]}/${e[1]}`,r=ht(e.slice(2),!0);return r.length?`${n}/${r.join(`/`)}`:n}let r=t.startsWith(`/`),i=ht((r?t.slice(1):t).split(`/`).filter(e=>e!==``),r);return r?i.length?`/${i.join(`/`)}`:`/`:i.length?i.join(`/`):`.`}function ht(e,t){let n=[];for(let r of e)r===`.`||r===``||(r===`..`?n.length>0?n.pop():t||n.push(`..`):n.push(r));return n}function K(e){let t=U(e);if(!t||pt(t))return``;let n=t.replace(/\/+$/,``),r=n.lastIndexOf(`/`),i=r<0?n:n.slice(r+1);return i.endsWith(`\0`)?i.slice(0,-1):i}var gt=new Set([`.exe`,`.com`,`.bat`,`.cmd`,`.msi`,`.scr`,`.ps1`,`.vbs`,`.js`,`.wsf`]);function _t(e,t){if(e&73)return!0;let n=t.lastIndexOf(`.`);if(n<0)return!1;let r=t.slice(n).toLowerCase();return gt.has(r)}var vt=`\0`;function yt(e){let t=e.indexOf(vt);if(t>=0){let n=e.slice(0,t),r=e.slice(t+1),i=yt(n);if(i.length>0&&(i[i.length-1]={label:i[i.length-1].label,path:n+vt}),r&&r!==`/`){let e=r.replace(/^\//,``).split(`/`).filter(Boolean),t=``;for(let r of e)t=t+`/`+r,i.push({label:r,path:n+vt+t})}return i}let n=U(e);if(!n)return[];let r=[];if(/^[A-Za-z]:\//.test(n)){let e=n.slice(0,3),t=n.slice(3),i=t?n.slice(0,2):e.replace(`/`,`\\`);if(r.push({label:i,path:e}),!t)return r;let a=t.split(`/`).filter(Boolean),o=e;for(let e of a)o=o.replace(/\/?$/,``)+`/`+e,r.push({label:e,path:o});return r}if(lt(n)){let e=n.slice(2).replace(/\/+$/,``).split(`/`).filter(Boolean);if(e.length>=2){r.push({label:`\\\\`+e[0]+`\\`+e[1],path:`//`+e[0]+`/`+e[1]});let t=`//`+e[0]+`/`+e[1];for(let n=2;n<e.length;n++)t=t+`/`+e[n],r.push({label:e[n],path:t})}return r}if(n.startsWith(`/`)){r.push({label:`/`,path:`/`});let e=n.slice(1).split(`/`).filter(Boolean),t=`/`;for(let n of e)t=t.replace(/\/?$/,``)+`/`+n,r.push({label:n,path:t});return r}let i=n.split(`/`).filter(Boolean),a=``;for(let e of i)a=a?a+`/`+e:e,r.push({label:e,path:a});return r}async function bt(e,t){return e.fs.readFile(U(t))}async function xt(e,t){return bt(e,t)}async function St(e,t){let n=await bt(e,t);return new TextDecoder().decode(n)}var Ct=0,wt=class{#e;#t=new Map;#n=new Map;#r=null;#i=0;constructor(e,t){this.bridge=e,this.#e=t}#a(){this.#r||=this.bridge.fs.onFsChange(e=>{this.#o(e)})}async observe(e){this.#a();let t=U(e);if(this.#n.has(t))return;let n=this.#i,r=`fso-${Ct++}`;this.#t.set(r,t),this.#n.set(t,r);let i=await this.bridge.fs.watch(r,t);if(n!==this.#i){i&&this.bridge.fs.unwatch(r);return}i||(this.#t.delete(r),this.#n.delete(t),this.#e([{root:{path:t},changedHandle:null,relativePathComponents:[],type:`errored`}],this))}unobserve(e){let t=U(e),n=this.#n.get(t);n!=null&&(this.bridge.fs.unwatch(n),this.#t.delete(n),this.#n.delete(t))}sync(e){this.#a();let t=new Set(e);for(let[e,n]of this.#n)t.has(e)||(this.bridge.fs.unwatch(n),this.#t.delete(n),this.#n.delete(e));for(let e of t)this.#n.has(e)||this.observe(e)}disconnect(){this.#i++;for(let e of this.#t.keys())this.bridge.fs.unwatch(e);this.#t.clear(),this.#n.clear(),this.#r&&=(this.#r(),null)}#o(e){let t=this.#t.get(e.watchId);if(!t)return;let n=e.name?{path:G(t,e.name),name:e.name}:null,r=e.name?[e.name]:[];this.#e([{root:{path:t},changedHandle:n,relativePathComponents:r,type:e.type}],this)}},Tt=new Map;function Et(e){return{async readFile(t){return xt(e,t)},async readFileRange(t,n,r){let i=await e.fs.open(t);try{return await e.fs.read(i,n,r)}finally{await e.fs.close(i)}}}}function Dt(e,t,n){let r=t+``+n,i=Tt.get(r);if(i)return i;let a=(async()=>{let r=await St(e,G(t,n)),i=Et(e);return new Promise((e,t)=>{let a=setTimeout(()=>{t(Error(`fsProvider "${n}" did not register within 5 s`))},5e3),o=new Blob([r],{type:`application/javascript`}),s=URL.createObjectURL(o),c=document.createElement(`script`);c.src=s,c.onerror=()=>{clearTimeout(a),URL.revokeObjectURL(s),t(Error(`Failed to load fsProvider script "${n}"`))},c.onload=()=>{URL.revokeObjectURL(s),clearTimeout(a);let r=window.__dotdirProviderReady;if(typeof r!=`function`){t(Error(`fsProvider "${n}" did not set window.__dotdirProviderReady`));return}window.__dotdirProviderReady=void 0;try{e(r(i))}catch(e){t(e)}},document.head.appendChild(c)})})();return a.catch(()=>Tt.delete(r)),Tt.set(r,a),a}function Ot(){Tt.clear()}var kt=null;function At(e){kt=e}function q(){return kt}var jt=null;function Mt(e){jt=e}function Nt(){return jt??document.documentElement}function Pt(e){return e.includes(`\0`)}function Ft(e){let t=e.lastIndexOf(`\0`);if(t<0)throw Error(`Not a container path: `+JSON.stringify(e));let n=e.slice(0,t),r=e.slice(t+1);return{containerFile:n,innerPath:r.startsWith(`/`)?r:`/`+r}}function It(e,t){let n=t.startsWith(`/`)?t:`/`+t;return n.length>1&&n.endsWith(`/`)&&(n=n.slice(0,-1)),e+`\0`+n}function Lt(e){return e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`)}function Rt(e){return e.replace(/\\/g,`/`).replace(/(^|\/)([A-Za-z]):(?=\/|$)/g,`$1$2/`)}function zt(e){let t=e.startsWith(`/`)?e:`/${e}`;return`__TAURI_INTERNALS__`in window?typeof navigator<`u`&&/Windows/i.test(navigator.userAgent)?`http://vfs.localhost${Lt(Rt(t))}`:`vfs://vfs${Lt(t)}`:`${window.location.origin}/vfs/${Lt(t.replace(/^\/+/,``))}`}function Bt(e,t){if(e===`*`||e===`*.*`)return!0;if(e.startsWith(`*.`)){let n=e.slice(1);return t.toLowerCase().endsWith(n.toLowerCase())}return t.toLowerCase()===e.toLowerCase()}function Vt(e,t){return e.some(e=>Bt(e,t))}function Ht(e,t){let n=e.filter(e=>Vt(e.contribution.patterns,t));return n.length===0?null:(n.sort((e,t)=>(t.contribution.priority??0)-(e.contribution.priority??0)),n[0])}var Ut=class{entries=[];listeners=new Set;clear(){this.entries=[]}register(e,t){this.entries.push({contribution:e,extensionDirPath:t})}resolve(e){return Ht(this.entries,e)}getAll(){return this.entries}onChange(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notifyListeners(){for(let e of this.listeners)e()}},Wt=class{entries=[];listeners=new Set;clear(){this.entries=[]}register(e,t){this.entries.push({contribution:e,extensionDirPath:t})}resolve(e){return Ht(this.entries,e)}getAll(){return this.entries}onChange(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notifyListeners(){for(let e of this.listeners)e()}},Gt=class{entries=[];listeners=new Set;clear(){this.entries=[]}register(e,t){this.entries.push({contribution:e,extensionDirPath:t})}resolve(e){return Ht(this.entries,e)}onChange(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notifyListeners(){for(let e of this.listeners)e()}},Kt=new Ut,qt=new Wt,Jt=new Gt;function Yt(e){Kt.clear(),qt.clear(),Jt.clear();for(let t of e){if(t.viewers)for(let e of t.viewers)Kt.register(e,t.dirPath);if(t.editors)for(let e of t.editors)qt.register(e,t.dirPath);if(t.fsProviders)for(let e of t.fsProviders)Jt.register(e,t.dirPath)}Kt.notifyListeners(),qt.notifyListeners(),Jt.notifyListeners()}var Xt=[{cssVar:`--bg`,keys:[`editor.background`]},{cssVar:`--fg`,keys:[`editor.foreground`,`foreground`]},{cssVar:`--bg-secondary`,keys:[`sideBar.background`,`editorGroupHeader.tabsBackground`]},{cssVar:`--fg-secondary`,keys:[`sideBar.foreground`,`foreground`]},{cssVar:`--fg-muted`,keys:[`descriptionForeground`,`tab.inactiveForeground`]},{cssVar:`--border`,keys:[`panel.border`,`sideBar.border`,`widget.border`,`editorGroup.border`]},{cssVar:`--border-active`,keys:[`focusBorder`]},{cssVar:`--entry-hover`,keys:[`list.hoverBackground`]},{cssVar:`--entry-selected`,keys:[`list.activeSelectionBackground`,`list.focusBackground`,`selection.background`]},{cssVar:`--entry-selected-fg`,keys:[`list.activeSelectionForeground`,`list.focusForeground`]},{cssVar:`--entry-selected-inactive`,keys:[`list.inactiveSelectionBackground`]},{cssVar:`--entry-selected-inactive-fg`,keys:[`list.inactiveSelectionForeground`]},{cssVar:`--error-bg`,keys:[`inputValidation.errorBackground`]},{cssVar:`--error-fg`,keys:[`errorForeground`,`editorError.foreground`]},{cssVar:`--accent`,keys:[`button.background`,`textLink.foreground`,`focusBorder`]},{cssVar:`--accent-fg`,keys:[`button.foreground`]},{cssVar:`--action-bar-border`,keys:[`activityBar.border`]},{cssVar:`--action-bar-bg`,keys:[`activityBar.background`]},{cssVar:`--action-bar-fg`,keys:[`activityBar.foreground`]},{cssVar:`--action-bar-badge-bg`,keys:[`activityBarBadge.background`]},{cssVar:`--action-bar-badge-fg`,keys:[`activityBarBadge.foreground`]}];async function Zt(e,t,n=3){let r=(0,p.parse)(await St(e,t),void 0,{allowTrailingComma:!0});if(r.include&&n>0){let i=G(W(t),r.include);try{let t=await Zt(e,i,n-1);r.colors={...t.colors,...r.colors},!r.tokenColors&&t.tokenColors&&(r.tokenColors=t.tokenColors)}catch{}}return r}var Qt=[],$t=0,en=null,tn=[];function nn(){return en}function rn(e){return tn.push(e),()=>{tn=tn.filter(t=>t!==e)}}function an(){if(en)for(let e of tn)e(en)}function on(e){sn();let t=Nt().style;for(let n of Xt)for(let r of n.keys){let i=e[r];if(i){t.setProperty(n.cssVar,i),Qt.push(n.cssVar);break}}}function sn(){$t++;let e=Nt().style;for(let t of Qt)e.removeProperty(t);Qt=[];let t=en!==null;if(en=null,t)for(let e of tn)e({kind:Nt().dataset.theme===`light`?`light`:`dark`})}function cn(e){return e===`vs`||e===`hc-light`?`light`:`dark`}async function ln(e,t,n){let r=++$t,i=await Zt(e,t);return r===$t?(i.colors&&on(i.colors),en={kind:n?cn(n):i.type===`light`?`light`:`dark`,colors:i.colors,tokenColors:i.tokenColors},an(),i):i}var un={"file-viewer":`_file-viewer_1gb4m_1`,"file-viewer-inline":`_file-viewer-inline_1gb4m_17`,"file-viewer-overlay":`_file-viewer-overlay_1gb4m_30`,"file-editor-overlay":`_file-editor-overlay_1gb4m_31`,"file-editor":`_file-editor_1gb4m_31`};async function dn(e,t,n,r){let{containerFile:i,innerPath:a}=Ft(t),o=Jt.resolve(K(i));if(!o)throw Error(`No fsProvider registered for "${K(i)}"`);if(o.contribution.runtime===`backend`&&e.fsProvider){let t=G(o.extensionDirPath,o.contribution.entry);return e.fsProvider.readFileRange(t,i,a,n,r)}let s=await Dt(e,o.extensionDirPath,o.contribution.entry);if(!s.readFileRange)throw Error(`Provider does not support readFileRange`);return s.readFileRange(i,a,n,r)}function fn(e){let{extensionDirPath:t,entry:n,kind:r,props:i,onClose:a,className:o,style:s,active:u}=e,d=B(),f=(0,c.useRef)(null),[p,m]=(0,c.useState)(null),[h,g]=(0,c.useState)(!0),_=(0,c.useRef)(a);_.current=a;let y=r===`viewer`&&!!i.inline,b=r===`viewer`&&!y,x=(0,c.useRef)(null),S=(0,c.useRef)(!1),C=(0,c.useRef)(!1);(0,c.useEffect)(()=>{y&&(x.current=document.activeElement,S.current=!1,C.current=!1)},[y]),(0,c.useEffect)(()=>{if(!b||h||C.current)return;C.current=!0;let e=f.current;e&&setTimeout(()=>{try{e.focus(),e.contentWindow?.focus?.()}catch{}},0)},[b,h]),(0,c.useEffect)(()=>{if(!y)return;let e=e=>{let t=e;if(!t)return!1;let n=t.tagName?.toLowerCase();return n===`input`||n===`textarea`||n===`select`||n===`button`||t.isContentEditable},t=t=>{if(t.key===`Tab`&&!(t.ctrlKey||t.metaKey||t.altKey)&&!t.shiftKey){if(S.current){t.preventDefault(),t.stopPropagation();return}if(v.current===`panel`&&!e(t.target)){t.preventDefault(),t.stopPropagation(),S.current=!0,v.push(`viewer`);try{f.current?.focus(),f.current?.contentWindow?.focus?.()}catch{}}}};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[y]);let w=(0,c.useRef)(null),T=(0,c.useRef)(null);(0,c.useEffect)(()=>{if(u!==!1)return;let e=f.current;if(e){let t=r===`viewer`?{filePath:``,fileName:``,fileSize:0}:{filePath:``,fileName:``,langId:`plaintext`};try{e.contentWindow?.postMessage({type:`dotdir:update`,props:t},`*`)}catch{}}let t=w.current;t&&(d.fs.close(t.fd).catch(()=>{}),w.current=null)},[u,r]);let E=(0,c.useRef)(e.kind===`viewer`?e.onExecuteCommand:void 0);e.kind===`viewer`&&(E.current=e.onExecuteCommand);let D=(0,c.useRef)(e.kind===`editor`?e.onDirtyChange:void 0);e.kind===`editor`&&(D.current=e.onDirtyChange);let O=(0,c.useCallback)(()=>({async readFile(e){let t=U(e);return Pt(t)?dn(d,t,0,64*1024*1024):d.fs.readFile(t)},async readFileRange(e,t,n){let r=U(e);if(Pt(r))return dn(d,r,t,n);let i=w.current,a=i;if(!a||a.path!==r){if(i)try{await d.fs.close(i.fd)}catch{}a={fd:await d.fs.open(r),size:(await d.fs.stat(r)).size,path:r},w.current=a}let o=Math.max(0,Math.floor(t)),s=Math.max(0,Math.floor(n)),c=Math.max(0,a.size-o),l=Math.min(s,c);return l===0?new ArrayBuffer(0):d.fs.read(a.fd,o,l)},async readFileText(e){let t=U(e);if(Pt(t)){let t=await this.readFile(e);return new TextDecoder().decode(t)}return St(d,t)},async statFile(e){let t=U(e);if(Pt(t))return{size:(await dn(d,t,0,64*1024*1024)).byteLength,mtimeMs:0};let n=await d.fs.stat(t),r=w.current;return r&&r.path===t&&r.size!==n.size&&(r.size=n.size),n},onFileChange(e){let t=T.current;if(!t)return()=>{};let n=U(t),r=W(n),i=K(n),a=`viewer-${Math.random().toString(36).slice(2)}`,o=!1,s=d.fs.onFsChange(t=>{if(!o&&!(t.watchId!==a||!t.name)&&t.name===i&&(t.type===`modified`||t.type===`appeared`)){let t=w.current;t&&t.path===n&&(d.fs.close(t.fd).catch(()=>{}),w.current=null),e()}});return(async()=>{await d.fs.watch(a,r)||(o=!0,s())})(),()=>{o||(o=!0,d.fs.unwatch(a),s())}},async writeFile(e,t){await d.fs.writeFile(e,t)},async getTheme(){return d.theme.get()},getColorTheme(){return nn()},onThemeChange(e){let t=rn(e);return()=>t()},onClose(){_.current()},async executeCommand(e,t){let n=E.current;if(!n)throw Error(`No command handler registered`);return n(e,t)},registerCommand(e,t){return V.registerCommand(e,t)},registerKeybinding(e){return $e(V,{command:e.command,key:e.key,mac:e.mac,when:e.when})},async getExtensionResourceUrl(e){throw U(e).replace(/^\/+/,``).includes(`..`)?Error(`Invalid extension resource path`):Error(`Extension resource URL not available in mount-point mode`)}}),[]),k=(0,c.useCallback)(()=>{let e={};try{let t=getComputedStyle(Nt());for(let n=0;n<t.length;n++){let r=t[n];if(!r||!r.startsWith(`--`))continue;let i=t.getPropertyValue(r);i&&(e[r]=i.trim())}}catch{}return e},[]);(0,c.useEffect)(()=>{let e=!1,a=f.current;if(!a)return;g(!0),m(null);let o=O(),s=a.contentWindow;if(!s)return;let c=U(n.replace(/^\.\//,``))||`index.js`,l=G(t,c),u=zt(l),p=/\.mjs(?:\?|$)/i.test(c),h=1,_=new Map,b=new Map,C=new Map,E=new Map,D=t=>{if(t.source!==s)return;let n=t.data;if(!(!n||typeof n!=`object`)){if(n.type===`ext:commandResult`){let e=Number(n.callId),t=_.get(e);if(!t)return;_.delete(e),n.error?t.reject(Error(String(n.error))):t.resolve();return}if(n.type===`ext:call`){let e=n.id,t=String(n.method??``),r=Array.isArray(n.args)?n.args:[];(async()=>{try{let n=o[t];if(typeof n!=`function`)throw Error(`Host method not found: ${t}`);let i=await n.apply(o,r);s.postMessage({type:`host:reply`,id:e,result:i},`*`)}catch(t){let n=t instanceof Error?t.message:t&&typeof t==`object`&&`message`in t?String(t.message):String(t);s.postMessage({type:`host:reply`,id:e,error:n},`*`)}})().catch(()=>{});return}if(n.type===`ext:subscribe`){let e=String(n.cbId??``),t=String(n.method??``);if(!e||b.has(e))return;if(t===`onFileChange`){if(!o.onFileChange)return;let t=o.onFileChange(()=>{try{s.postMessage({type:`host:callback`,cbId:e},`*`)}catch{}});b.set(e,t);return}if(t===`onThemeChange`){if(!o.onThemeChange)return;let t=o.onThemeChange(t=>{try{s.postMessage({type:`host:callback`,cbId:e,payload:t},`*`)}catch{}});b.set(e,t);return}return}if(n.type===`ext:unsubscribe`){let e=String(n.cbId??``),t=b.get(e);if(t){try{t()}catch{}b.delete(e)}return}if(n.type===`ext:registerCommand`){let e=String(n.handlerId??``),t=String(n.commandId??``);if(!e||!t||C.has(e))return;let r=V.registerCommand(t,async(...t)=>{let n=h++;await new Promise((r,i)=>{_.set(n,{resolve:r,reject:i}),s.postMessage({type:`host:runCommand`,handlerId:e,callId:n,args:t},`*`)})});C.set(e,r);return}if(n.type===`ext:unregisterCommand`){let e=String(n.handlerId??``),t=C.get(e);if(t){try{t()}catch{}C.delete(e)}return}if(n.type===`ext:registerKeybinding`){let e=String(n.bindingId??``),t=n.binding;if(!e||!t||typeof t!=`object`||E.has(e))return;let r=$e(V,{command:t.command,key:t.key,mac:t.mac,when:t.when});E.set(e,r);return}if(n.type===`ext:unregisterKeybinding`){let e=String(n.bindingId??``),t=E.get(e);if(t){try{t()}catch{}E.delete(e)}return}if(n.type===`dotdir:bootstrap-ready`)M();else if(n.type===`dotdir:ready`)e||g(!1);else if(n.type===`dotdir:error`)e||(m(String(n.message??`Extension error`)),g(!1));else if(n.type===`dotdir:iframeKeyDown`)try{let e=String(n.key??``).toLowerCase();if(y&&e===`tab`&&S.current){S.current=!1;try{v.pop(`viewer`)}catch{}try{x.current?.focus?.()}catch{}return}if(y&&!S.current)return;let t={key:n.key,ctrlKey:!!n.ctrlKey,metaKey:!!n.metaKey,altKey:!!n.altKey,shiftKey:!!n.shiftKey,repeat:!!n.repeat,preventDefault(){},stopPropagation(){}};V.handleKeyboardEvent(t)}catch{}}};window.addEventListener(`message`,D);let A=()=>{try{a.contentWindow?.postMessage({type:`dotdir:themeVars`,themeVars:k()},`*`)}catch{}},j=rn(()=>A()),ee=!1,M=async()=>{if(ee)return;ee=!0,T.current=i.filePath;let t;if(p)try{t=await St(d,l)}catch(t){e||(m(`Failed to read ESM entry: ${t instanceof Error?t.message:t&&typeof t==`object`&&`message`in t?String(t.message):String(t)}`),g(!1));return}a.contentWindow?.postMessage({type:`dotdir:init`,kind:r,entryUrl:u,entryScript:t,props:i,themeVars:k(),colorTheme:o.getColorTheme?.()??null},`*`)},N=()=>{setTimeout(()=>{!e&&!ee&&(m(`Extension bootstrap did not respond`),g(!1))},3e3)};return a.addEventListener(`load`,N),()=>{e=!0,window.removeEventListener(`message`,D),a.removeEventListener(`load`,N),j();try{a.contentWindow?.postMessage({type:`dotdir:dispose`},`*`)}catch{}for(let[,e]of b)try{e()}catch{}b.clear();for(let[,e]of C)try{e()}catch{}C.clear();for(let[,e]of E)try{e()}catch{}E.clear(),_.clear();let t=w.current;t&&(d.fs.close(t.fd).catch(()=>{}),w.current=null)}},[t,n,r,O,k]);let A=(0,c.useRef)(i);if((0,c.useEffect)(()=>{if(u===!1){A.current=null;return}let e=f.current;if(!(!e||h||p)&&A.current!==i){A.current=i,T.current=i.filePath;try{e.contentWindow?.postMessage({type:`dotdir:update`,props:i},`*`)}catch{}}},[i,r,h,p,u]),p)return(0,l.jsxs)(`div`,{className:o,style:{...s,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`var(--error-fg, #f44)`},children:[`Failed to load `,r,`: `,p]});let j=zt(`/_ext/${W(G(t,U(n.replace(/^\.\//,``))||`index.js`)).replace(/^\//,``)}/`);return(0,l.jsxs)(`div`,{className:o,style:{...s,position:`relative`},children:[h&&(0,l.jsxs)(`div`,{style:{position:`absolute`,inset:0,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`var(--fg-muted, #888)`},children:[`Loading `,r,`…`]}),j&&(0,l.jsx)(`iframe`,{ref:f,src:j,sandbox:`allow-scripts allow-top-navigation-to-custom-protocols`,style:{width:`100%`,height:`100%`,border:`none`,display:h?`none`:`block`,background:`transparent`},title:`${r} extension`})]})}function pn({extensionDirPath:e,entry:t,filePath:n,fileName:r,fileSize:i,inline:a,visible:o,onClose:s,onExecuteCommand:u}){let d=(0,c.useRef)(!1),f=(0,c.useRef)(null),p=o??!0,m=(0,c.useCallback)(()=>{v.set(`panel`);let e=(t=0)=>{let n=f.current;if(n&&n.isConnected)try{n.focus({preventScroll:!0});return}catch{try{n.focus();return}catch{}}let r=q();if(r){r.focus();return}t<2&&requestAnimationFrame(()=>e(t+1))};requestAnimationFrame(()=>e())},[]),h=(0,c.useCallback)(()=>{s(),m()},[s,m]);(0,c.useEffect)(()=>{if(!a){if(p)d.current||=(f.current=document.activeElement,v.push(`viewer`),!0);else if(d.current){try{v.pop(`viewer`)}catch{}d.current=!1}}},[a,p]),(0,c.useEffect)(()=>()=>{if(d.current){try{v.pop(`viewer`)}catch{}d.current=!1}},[]);let g=(0,c.useMemo)(()=>({filePath:n,fileName:r,fileSize:i,inline:a}),[n,r,i,a]),_=(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`6px 10px`,borderBottom:`1px solid var(--border, #333)`,flexShrink:0,minHeight:38,boxSizing:`border-box`},children:[(0,l.jsx)(`span`,{style:{flex:1,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},title:r,children:r}),(0,l.jsx)(`button`,{type:`button`,title:`Close (Esc)`,onClick:h,style:{background:`transparent`,border:`none`,cursor:`pointer`,fontSize:18,padding:`0 8px`,flexShrink:0,color:`inherit`},"aria-label":`Close`,children:`×`})]}),y=(0,l.jsx)(fn,{kind:`viewer`,extensionDirPath:e,entry:t,props:g,active:p,onClose:h,onExecuteCommand:u,style:{width:`100%`,height:`100%`}});return a?(0,l.jsx)(`div`,{className:`${un[`file-viewer`]} ${un[`file-viewer-inline`]}`,style:{display:`flex`,flexDirection:`column`,height:`100%`},children:(0,l.jsx)(`div`,{style:{flex:1,minHeight:0},children:y})}):(0,l.jsx)(`div`,{className:un[`file-viewer-overlay`],style:{display:p?`flex`:`none`},children:(0,l.jsxs)(`div`,{className:un[`file-viewer`],style:{display:`flex`,flexDirection:`column`,padding:0},children:[_,(0,l.jsx)(`div`,{style:{flex:1,minHeight:0},children:y})]})})}function mn({extensionDirPath:e,entry:t,filePath:n,fileName:r,langId:i,visible:a,onClose:o,onDirtyChange:s,languages:u,grammars:d}){let[f,p]=(0,c.useState)(i),m=(0,c.useRef)(!1),h=(0,c.useRef)(null),g=a??!0,_=(0,c.useCallback)(()=>{v.set(`panel`);let e=(t=0)=>{let n=h.current;if(n&&n.isConnected)try{n.focus({preventScroll:!0});return}catch{try{n.focus();return}catch{}}let r=q();if(r){r.focus();return}t<2&&requestAnimationFrame(()=>e(t+1))};requestAnimationFrame(()=>e())},[]),y=(0,c.useCallback)(()=>{o(),_()},[o,_]);(0,c.useEffect)(()=>{p(i)},[i]),(0,c.useEffect)(()=>{if(g)m.current||=(h.current=document.activeElement,v.push(`editor`),!0);else if(m.current){try{v.pop(`editor`)}catch{}m.current=!1}},[g]),(0,c.useEffect)(()=>()=>{if(m.current){try{v.pop(`editor`)}catch{}m.current=!1}},[]);let b=(0,c.useMemo)(()=>({filePath:n,fileName:r,langId:f,extensionDirPath:e,languages:u,grammars:d,inline:!1}),[n,r,f,e,u,d]),x=e=>{let t=e.target.value;p(t)},S=(0,c.useMemo)(()=>{let e=u??[],t=new Set;return e.filter(e=>t.has(e.id)?!1:(t.add(e.id),!0))},[u]),C=S.length>0;return(0,l.jsx)(`div`,{className:un[`file-editor-overlay`],style:{display:g?`flex`:`none`},children:(0,l.jsxs)(`div`,{className:un[`file-editor`],style:{display:`flex`,flexDirection:`column`,padding:0},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`6px 10px`,borderBottom:`1px solid var(--border, #333)`,flexShrink:0,minHeight:38,boxSizing:`border-box`},children:[(0,l.jsx)(`span`,{style:{flex:1,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},title:r,children:r}),C&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`label`,{htmlFor:`editor-lang-select`,style:{whiteSpace:`nowrap`},children:`Language:`}),(0,l.jsxs)(`select`,{id:`editor-lang-select`,value:f,onChange:x,style:{minWidth:120,padding:`2px 6px`},children:[(0,l.jsx)(`option`,{value:`plaintext`,children:`Plain Text`}),S.map(e=>(0,l.jsx)(`option`,{value:e.id,children:e.aliases?.[0]??e.id},e.id))]})]}),(0,l.jsx)(`button`,{type:`button`,title:`Close (Esc)`,onClick:y,style:{background:`transparent`,border:`none`,cursor:`pointer`,fontSize:18,padding:`0 8px`,flexShrink:0,color:`inherit`},"aria-label":`Close`,children:`×`})]}),(0,l.jsx)(`div`,{style:{flex:1,minHeight:0},children:(0,l.jsx)(fn,{kind:`editor`,extensionDirPath:e,entry:t,props:b,active:g,onClose:y,onDirtyChange:s,style:{width:`100%`,height:`100%`}})})]})})}var hn="(function(){let e=/^[A-Za-z]:$/,t=/^[A-Za-z]:\\/$/;function n(e){return e.startsWith(`//`)}function r(e){return n(e)?`//${e.slice(2).replace(/\\/+/g,`/`)}`:e.replace(/\\/+/g,`/`)}function i(e){return e.startsWith(`/`)||n(e)||/^[A-Za-z]:\\//.test(e)}function a(n){if(!n)return n;let i=r(n.replace(/\\\\/g,`/`));return i=i.replace(/\\/\\.\\//g,`/`).replace(/^\\.\\//,``),i.endsWith(`/.`)&&(i=i.slice(0,-2)),e.test(i)&&(i=`${i}/`),i.length>1&&i.endsWith(`/`)&&!t.test(i)&&(i=i.replace(/\\/+$/,``)),i}function o(e){let t=a(e);return n(t)?t.slice(2).split(`/`).filter(Boolean).length===2:!1}function s(e){let n=a(e);return n===`/`||t.test(n)||o(n)}function c(t){let n=a(t);if(!n)return`.`;if(s(n))return n;let r=n.replace(/\\/+$/,``),i=r.lastIndexOf(`/`);if(i<0)return`.`;if(i===0)return`/`;let o=r.slice(0,i);return e.test(o)?`${o}/`:o||`/`}function l(...e){let t=``;for(let n of e){if(!n)continue;let e=a(n);if(!t||i(e)){t=e;continue}t=a(`${t.replace(/\\/+$/,``)}/${e.replace(/^\\/+/,``)}`)}return t}let u=0,d=new Map,f=new Map,p=new Map,m=new Map;function h(e){return new Promise((t,n)=>{let r=u++;d.set(r,{resolve:t,reject:n}),self.postMessage({type:`readFile`,id:r,path:e})})}function g(e){return`${e.ref.publisher}.${e.ref.name}.${e.ref.version}`}function _(e,t){let n=e.manifest.activationEvents??[];return n.length===0?t===`*`:n.includes(`*`)||n.includes(t)}async function v(e){let t=await h(e);if(t==null)throw Error(`Browser script not found: ${e}`);let n=URL.createObjectURL(new Blob([t],{type:`text/javascript`}));try{return await import(n)}finally{URL.revokeObjectURL(n)}}async function y(e){let t=g(e);if(p.has(t)||!e.manifest.browser)return;let n=a(e.manifest.browser).replace(/^\\/+/,``),r=await v(l(e.dirPath,n)),i=r.activate??r.default?.activate,o=r.deactivate??r.default?.deactivate;if(typeof i!=`function`){console.warn(`[ExtHost] ${t} browser entry has no activate() export`);return}let s=[],c={commands:{registerCommand:(e,t)=>{m.set(e,t);let n={dispose:()=>{m.get(e)===t&&m.delete(e)}};return s.push(n),n},registerKeybinding:e=>({dispose(){}})}},u={subscriptions:s,dotdir:c};self.dotdir=c,await i(u),p.set(t,{subscriptions:s,deactivate:o})}async function b(e){for(let t of f.values())if(t.manifest.browser&&_(t,e))try{await y(t)}catch(e){console.error(`[ExtHost] activate failed:`,g(t),e)}}async function x(e,t){await b(`onCommand:${e}`);let n=m.get(e);n&&await n(...t)}function S(e){return`${e.publisher}-${e.name}-${e.version}`}async function C(e){try{let t=await h(l(e,`package.json`));if(t===null)return null;let n=JSON.parse(t),r={publisher:n.publisher||`unknown`,name:n.name||`unknown`,version:n.version||`0.0.0`},i,a;if(n.contributes?.iconTheme?.path){let t=l(e,n.contributes.iconTheme.path);i=t,a=c(t)}let o=n.contributes?.languages,s;if(n.contributes?.grammars?.length){s=[];for(let t of n.contributes.grammars)try{let n=l(e,t.path);s.push({contribution:t,path:n})}catch{}}let u;n.contributes?.themes?.length&&(u=n.contributes.themes.map((t,n)=>({id:t.id||`${t.label}#${n}`,label:t.label,uiTheme:t.uiTheme,jsonPath:l(e,t.path)})));let d=n.contributes?.viewers,f=n.contributes?.editors,p=n.contributes?.commands,m=n.contributes?.keybindings,g=n.contributes?.fsProviders,_;if(n.contributes?.shellIntegrations?.length){_=[];for(let t of n.contributes.shellIntegrations){let n=await h(l(e,t.scriptPath));n!==null&&_.push({shell:t.shell,label:t.label,script:n,executableCandidates:t.executableCandidates??[],platforms:t.platforms,hiddenCdTemplate:t.hiddenCdTemplate,cwdEscape:t.cwdEscape,lineEnding:t.lineEnding,spawnArgs:t.spawnArgs,scriptArg:t.scriptArg})}}return{ref:r,manifest:n,dirPath:e,iconThemeFssPath:i,iconThemeBasePath:a,colorThemes:u,languages:o,grammarRefs:s,viewers:d,editors:f,commands:p,keybindings:m,fsProviders:g,shellIntegrations:_}}catch{return null}}async function w(e){let t=[],n=l(e,`.dotdir`,`extensions`),r;try{let e=await h(l(n,`extensions.json`));if(e===null)return t;let i=JSON.parse(e);r=Array.isArray(i)?i:[]}catch{return t}for(let e of r){if(!e.publisher||!e.name||!e.version)continue;let r=await C(e.path?a(e.path):l(n,S(e)));r&&t.push(r)}console.log(`[ExtHost] loaded`,t.length,`extensions; FSS:`,t.filter(e=>e.iconThemeFss).map(e=>`${e.ref.publisher}.${e.ref.name}`),`vscode:`,t.filter(e=>e.vscodeIconThemePath).map(e=>`${e.ref.publisher}.${e.ref.name}`)),f.clear();for(let e of t)f.set(g(e),e);return t}self.onmessage=e=>{let t=e.data;if(t.type===`start`)w(t.homePath).then(async e=>{await b(`*`),self.postMessage({type:`loaded`,extensions:e})}).catch(e=>{let t=e instanceof Error?e.message:e&&typeof e==`object`&&`message`in e?String(e.message):String(e);self.postMessage({type:`error`,message:t})});else if(t.type===`activateByEvent`){let e=Number(t.requestId);b(String(t.event??``)).then(()=>{self.postMessage({type:`requestResult`,requestId:e,result:null})}).catch(t=>{let n=t instanceof Error?t.message:String(t);self.postMessage({type:`requestResult`,requestId:e,error:n})})}else if(t.type===`executeCommand`){let e=Number(t.requestId);x(String(t.command??``),Array.isArray(t.args)?t.args:[]).then(()=>{self.postMessage({type:`requestResult`,requestId:e,result:null})}).catch(t=>{let n=t instanceof Error?t.message:String(t);self.postMessage({type:`requestResult`,requestId:e,error:n})})}else if(t.type===`readFileResult`){let e=d.get(t.id);e&&(d.delete(t.id),t.error?e.resolve(null):e.resolve(t.data))}}})();",gn=typeof self<`u`&&self.Blob&&new Blob([`(self.URL || self.webkitURL).revokeObjectURL(self.location.href);`,hn],{type:`text/javascript;charset=utf-8`});function _n(e){let t;try{if(t=gn&&(self.URL||self.webkitURL).createObjectURL(gn),!t)throw``;let n=new Worker(t,{name:e?.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch{return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(hn),{name:e?.name})}}var vn=class{worker=null;homePath=null;listeners=[];starting=!1;nextRequestId=1;pendingRequests=new Map;constructor(e){this.bridge=e}onLoaded(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(t=>t!==e)}}async start(){if(!this.starting){this.starting=!0;try{this.homePath||=await this.bridge.utils.getHomePath(),this.spawnWorker()}finally{this.starting=!1}}}async restart(){this.worker?.terminate(),this.worker=null;for(let[,e]of this.pendingRequests)e.reject(Error(`Extension host restarted`));this.pendingRequests.clear(),await this.start()}dispose(){this.worker?.terminate(),this.worker=null;for(let[,e]of this.pendingRequests)e.reject(Error(`Extension host disposed`));this.pendingRequests.clear(),this.listeners=[]}async activateByEvent(e){await this.request({type:`activateByEvent`,event:e})}async executeCommand(e,t=[]){await this.request({type:`executeCommand`,command:e,args:t})}spawnWorker(){let e=new _n;e.onmessage=t=>{let n=t.data;if(n.type===`readFile`)this.handleFileRead(e,n.id,n.path);else if(n.type===`loaded`){let e=n.extensions,t=e.filter(e=>e.iconThemeFss).map(e=>`${e.ref.publisher}.${e.ref.name}`),r=e.filter(e=>e.vscodeIconThemePath).map(e=>`${e.ref.publisher}.${e.ref.name}`);console.log(`[ExtHost] loaded`,e.length,`extensions; FSS:`,t,`vscode:`,r);for(let t of this.listeners)t(e)}else if(n.type===`error`)console.error(`[ExtensionHost] Worker error:`,n.message);else if(n.type===`requestResult`){let e=Number(n.requestId),t=this.pendingRequests.get(e);if(!t)return;this.pendingRequests.delete(e),n.error?t.reject(Error(String(n.error))):t.resolve(n.result)}},e.onerror=e=>{console.error(`[ExtensionHost] Worker runtime error:`,e)},this.worker=e,(async()=>{e.postMessage({type:`start`,homePath:this.homePath})})()}async request(e){if(this.worker||await this.start(),!this.worker)throw Error(`Extension host is not running`);let t=this.nextRequestId++;return await new Promise((n,r)=>{this.pendingRequests.set(t,{resolve:n,reject:r}),this.worker.postMessage({...e,requestId:t})})}async handleFileRead(e,t,n){try{let r=U(n),i=await St(this.bridge,r);console.log(`[ExtHost] readFile ok`,r),e.postMessage({type:`readFileResult`,id:t,data:i})}catch(r){console.error(`[ExtHost] readFile failed`,n,r),e.postMessage({type:`readFileResult`,id:t,data:null,error:`read failed`})}}},yn=(0,d.atom)(e=>{let t=e(ve);if(!t)throw Error(`Bridge not initialized.`);return new vn(t)});function bn(){return(0,d.useAtomValue)(yn)}var xn=`https://dotdir.dev`;function Sn(e){return`${e.publisher}-${e.name}-${e.version}`}async function Cn(e){return G(await e.utils.getHomePath(),`.dotdir`,`extensions`)}async function wn(e){let t=await Cn(e);try{let n=await St(e,G(t,`extensions.json`)),r=JSON.parse(n);return Array.isArray(r)?r:[]}catch{return[]}}async function Tn(e,t){let n=await Cn(e);await e.fs.writeFile(G(n,`extensions.json`),JSON.stringify(t,null,2))}async function En(e=``,t=1){let n=new URLSearchParams({page:String(t),pageSize:`30`});e&&n.set(`q`,e);let r=await fetch(`${xn}/api/extensions/search?${n}`);if(!r.ok)throw Error(`Failed to search marketplace`);return r.json()}async function Dn(e){let t=new DecompressionStream(`deflate-raw`),n=t.writable.getWriter(),r=t.readable.getReader();n.write(e),n.close();let i=[];for(;;){let{done:e,value:t}=await r.read();if(e)break;i.push(t)}let a=i.reduce((e,t)=>e+t.length,0),o=new Uint8Array(a),s=0;for(let e of i)o.set(e,s),s+=e.length;return o}async function On(e){let t=new Uint8Array(e),n=new Map,r=e=>t[e]|t[e+1]<<8,i=e=>(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0,a=-1;for(let e=t.length-22;e>=Math.max(0,t.length-65557);e--)if(i(e)===101010256){a=e;break}if(a===-1)throw Error(`Invalid ZIP archive`);let o=i(a+16),s=r(a+10),c=o;for(let e=0;e<s&&i(c)===33639248;e++){let e=r(c+10),a=i(c+20),o=r(c+28),s=r(c+30),l=r(c+32),u=i(c+42),d=new TextDecoder().decode(t.slice(c+46,c+46+o));if(c+=46+o+s+l,d.endsWith(`/`))continue;let f=r(u+26),p=r(u+28),m=u+30+f+p,h=t.slice(m,m+a),g;if(e===0)g=h;else if(e===8)g=await Dn(h);else continue;n.set(d,g)}return n}function kn(e){let t=[...e];if(t.length===0)return``;let n=t[0],r=n.indexOf(`/`);if(r===-1)return``;let i=n.slice(0,r+1);return t.every(e=>e.startsWith(i))?i:``}async function An(e,t,n,r){let i=`${xn}/api/extensions/${t}/${n}/${r}/download`,a=await fetch(i);if(!a.ok)throw Error(`Download failed: ${a.statusText}`);let o=await On(await a.arrayBuffer()),s=await Cn(e),c={publisher:t,name:n,version:r},l=G(s,Sn(c)),u=kn(o.keys());for(let[t,n]of o){let r=u?t.slice(u.length):t;r&&await e.fs.writeBinaryFile(G(l,r),n)}let d=(await wn(e)).filter(e=>!(e.publisher===t&&e.name===n));d.push(c),await Tn(e,d)}async function jn(e){let t=new Uint8Array(e),n=new Map,r=e=>t[e]|t[e+1]<<8,i=e=>(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0,a=-1;for(let e=t.length-22;e>=Math.max(0,t.length-65557);e--)if(i(e)===101010256){a=e;break}if(a===-1)throw Error(`Invalid VSIX archive`);let o=i(a+16),s=r(a+10),c=o;for(let e=0;e<s&&i(c)===33639248;e++){let e=r(c+10),a=i(c+20),o=r(c+28),s=r(c+30),l=r(c+32),u=i(c+42),d=new TextDecoder().decode(t.slice(c+46,c+46+o));if(c+=46+o+s+l,d.endsWith(`/`)||!d.startsWith(`extension/`))continue;let f=r(u+26),p=r(u+28),m=u+30+f+p,h=t.slice(m,m+a),g;if(e===0)g=h;else if(e===8)g=await Dn(h);else continue;let _=d.slice(10);_&&n.set(_,g)}return n}async function Mn(e,t,n,r){let i=new AbortController,a=setTimeout(()=>i.abort(),3e4),o;try{o=await fetch(r,{signal:i.signal})}catch(e){if(clearTimeout(a),e instanceof Error&&e.name===`AbortError`)throw Error(`Download timed out - VS Code marketplace may be blocked by CORS`);let t=e instanceof Error?e.message:e&&typeof e==`object`&&`message`in e?String(e.message):String(e);throw Error(`Download failed: ${t}`)}if(clearTimeout(a),!o.ok)throw Error(`Download failed: ${o.status} ${o.statusText}`);let s=await jn(await o.arrayBuffer()),c=s.get(`package.json`);if(!c)throw Error(`Invalid VSIX: no package.json`);let l=JSON.parse(new TextDecoder().decode(c)).version||`0.0.0`,u=await Cn(e),d={publisher:t,name:n,version:l},f=G(u,Sn(d));for(let[t,n]of s){let r=G(f,t),i=t.split(`.`).pop()?.toLowerCase()??``;[`json`,`txt`,`md`,`js`,`ts`,`css`,`html`,`xml`,`yaml`,`yml`,`tmLanguage`,`tmGrammar`].includes(i)||t.endsWith(`.tmLanguage.json`)||t.endsWith(`.language-configuration.json`)?await e.fs.writeFile(r,new TextDecoder().decode(n)):await e.fs.writeBinaryFile(r,n)}let p=(await wn(e)).filter(e=>!(e.publisher===t&&e.name===n));p.push(d),await Tn(e,p)}async function Nn(e,t){if(!await e.fs.exists(t))return;let n=await e.fs.delete.start([t]);await new Promise((t,r)=>{let i=e.fs.delete.onProgress(e=>{if(e.deleteId!==n)return;let a=e.event;a.kind===`done`?(i(),t()):a.kind===`error`&&(i(),r(Error(a.message)))})})}async function Pn(e,t,n){let r=await wn(e),i=r.find(e=>e.publisher===t&&e.name===n);i&&!i.path&&await Nn(e,G(await Cn(e),Sn(i))),await Tn(e,r.filter(e=>!(e.publisher===t&&e.name===n)))}function Fn(e){return e.iconThemeFss||e.iconThemeFssPath||e.vscodeIconThemePath?`${e.ref.publisher}.${e.ref.name}`:null}function In(e,t){return`${e.ref.publisher}.${e.ref.name}:${t}`}function Ln(e,t){for(let n of e)if(n.colorThemes){for(let e of n.colorThemes)if(In(n,e.id)===t)return{ext:n,theme:e}}return null}var Rn=`https://marketplace.visualstudio.com/_apis/public/gallery`;async function zn(e,t=1){let n={filters:[{criteria:[{filterType:8,value:`Microsoft.VisualStudio.Code`},...e?[{filterType:10,value:e}]:[]],pageNumber:t,pageSize:30,sortBy:e?0:4,sortOrder:0}],assetTypes:[],flags:914},r=await fetch(`${Rn}/extensionquery`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json;api-version=7.1-preview.1`},body:JSON.stringify(n)});if(!r.ok)throw Error(`VS Code marketplace request failed`);let i=(await r.json()).results?.[0]?.extensions??[];return{extensions:i,total:i.length}}function Bn(e){return e.statistics?.find(e=>e.statisticName===`install`)?.value??0}function Vn(e){return e.versions?.[0]?.version??null}function Hn(e){let t=e.versions?.[0];return t?`${t.assetUri}/Microsoft.VisualStudio.Services.VSIXPackage`:null}function Un(e){let t=e.versions?.[0];return t?`${t.assetUri}/Microsoft.VisualStudio.Services.Icons.Default`:null}async function Wn(e,t){let{name:n,getPath:r,validate:i,defaultValue:a,onLoad:o}=t,s=a,c=null,l=null,u=null,d=new Set;function f(){for(let e of d)try{e(s)}catch(e){console.error(`[${n}] Listener error:`,e)}}async function m(){try{let t=c??await r();c=t;let a=await St(e,t),l=[],u=(0,p.parse)(a,l,{allowTrailingComma:!0});if(l.length>0){console.error(`[${n}] Parse errors:`);for(let e of l)console.error(` - ${(0,p.printParseErrorCode)(e.error)} at offset ${e.offset}`);return}let d=i(u);if(d===null)return;s=d,console.log(`[${n}] Loaded`),o?.(s),f()}catch(e){e&&typeof e.message==`string`&&(e.message===`ENOENT`||e.message?.includes(`not found`)||e.name===`NotFoundError`)?(s=a,o?.(s),f()):console.error(`[${n}] Failed to load:`,e)}}async function h(){try{let t=c??await r();c=t;let i=W(t),a=K(t);l=`${n}-${Date.now()}`,await e.fs.watch(l,i),u=e.fs.onFsChange(e=>{e.watchId===l&&e.name===a&&(console.log(`[${n}] Detected change, reloading...`),m())})}catch(e){console.error(`[${n}] Failed to setup watch:`,e)}}return await m(),await h(),{getValue:()=>s,setValue(e){s=e},onChange(e){return d.add(e),()=>d.delete(e)},async dispose(){if(u&&=(u(),null),l){try{await e.fs.unwatch(l)}catch{}l=null}d.clear()}}}var Gn=null,Kn=null,qn=null;function Jn(e){return typeof e!=`object`||!e||Array.isArray(e)?(console.error(`[userSettings] settings.json must be an object`),null):e}function Yn(e,t){if(!Gn)return;let n={...Gn.getValue(),...t};Gn.setValue(n),qn&&clearTimeout(qn),qn=setTimeout(()=>{qn=null,Xn(e,n)},500)}async function Xn(e,t){try{Kn||=G(await e.utils.getHomePath(),`.dotdir`,`settings.json`),await e.fs.writeFile(Kn,JSON.stringify(t,null,2))}catch(e){console.error(`[userSettings] Failed to save settings:`,e)}}function Zn(e){return Gn?.onChange(e)??(()=>{})}async function Qn(e){return Gn=await Wn(e,{name:`userSettings`,getPath:async()=>G(await e.utils.getHomePath(),`.dotdir`,`settings.json`),validate:Jn,defaultValue:{}}),Gn.getValue()}var $n=(0,d.atom)({}),er=(0,d.atom)(!1),tr=null;function nr(){let e=(0,d.useAtomValue)($n),t=(0,d.useAtomValue)(er),n=(0,d.useSetAtom)($n),r=(0,d.useSetAtom)(er),i=B();return(0,c.useEffect)(()=>(tr||=Qn(i),tr.then(e=>{n(e),r(!0)}),Zn(n)),[n,r,i]),{settings:e,ready:t,updateSettings:(0,c.useCallback)(e=>{n(t=>({...t,...e})),Yn(i,e)},[n])}}var rr=`_active_jpq35_71`,ir=`_install_jpq35_261`,ar=`_uninstall_jpq35_266`,or=`_installed_jpq35_276`,J={"ext-panel":`_ext-panel_jpq35_1`,"ext-panel-header":`_ext-panel-header_jpq35_17`,"ext-panel-title":`_ext-panel-title_jpq35_28`,"ext-panel-close":`_ext-panel-close_jpq35_34`,"ext-panel-tabs":`_ext-panel-tabs_jpq35_49`,"ext-tab":`_ext-tab_jpq35_55`,active:rr,"ext-search":`_ext-search_jpq35_76`,"ext-source-selector":`_ext-source-selector_jpq35_82`,"ext-source-btn":`_ext-source-btn_jpq35_88`,"ext-error":`_ext-error_jpq35_129`,"ext-list":`_ext-list_jpq35_137`,"ext-empty":`_ext-empty_jpq35_143`,"ext-item":`_ext-item_jpq35_150`,"ext-icon":`_ext-icon_jpq35_162`,"ext-info":`_ext-info_jpq35_184`,"ext-name":`_ext-name_jpq35_189`,"ext-publisher":`_ext-publisher_jpq35_198`,"ext-desc":`_ext-desc_jpq35_204`,"ext-meta":`_ext-meta_jpq35_214`,"ext-theme-badge":`_ext-theme-badge_jpq35_223`,"ext-actions":`_ext-actions_jpq35_234`,"ext-btn":`_ext-btn_jpq35_241`,install:ir,uninstall:ar,installed:or,"ext-color-themes":`_ext-color-themes_jpq35_281`,"ext-color-theme-btn":`_ext-color-theme-btn_jpq35_288`,"ext-color-theme-indicator":`_ext-color-theme-indicator_jpq35_296`};function sr(e){return e instanceof Error?e.message:e&&typeof e==`object`&&`message`in e?String(e.message):String(e)}function cr(){let e=B(),t=(0,d.useSetAtom)(Se),[n,r]=(0,d.useAtom)(Ce),[i,a]=(0,d.useAtom)(we),o=(0,d.useAtomValue)(Te),s=(0,c.useRef)(null),u=bn(),[f,p]=(0,c.useState)(`marketplace`),[m,h]=(0,c.useState)(`vscode`),[g,_]=(0,c.useState)(``),[y,x]=(0,c.useState)([]),[S,w]=(0,c.useState)([]),[T,E]=(0,c.useState)(!1),[O,k]=(0,c.useState)(null),[A,j]=(0,c.useState)(``),ee=(0,c.useRef)(null),{settings:M,updateSettings:N}=nr();(0,c.useEffect)(()=>(v.push(`modal`),()=>{v.pop(`modal`)}),[t]);let te=(0,c.useCallback)(async(e,t)=>{E(!0),j(``);try{t===`vscode`?(w((await zn(e)).extensions),x([])):(x((await En(e)).extensions),w([]))}catch{j(`Could not reach ${t===`vscode`?`VS Code`:`.dir`} marketplace`)}E(!1)},[]);(0,c.useEffect)(()=>{te(``,m)},[te,m]);let ne=e=>{_(e),ee.current&&clearTimeout(ee.current),ee.current=setTimeout(()=>te(e,m),300)},P=async t=>{let n=Hn(t);if(n){k(`${t.publisher.publisherName}.${t.extensionName}`),j(``);try{await Mn(e,t.publisher.publisherName,t.extensionName,n),u.restart()}catch(e){j(`Install failed: ${sr(e)}`)}k(null)}},F=new Set(o.map(e=>`${e.ref.publisher}.${e.ref.name}`)),I=async t=>{if(t.latest_version){k(`${t.publisher.username}.${t.name}`),j(``);try{await An(e,t.publisher.username,t.name,t.latest_version.version),u.restart()}catch(e){j(`Install failed: ${sr(e)}`)}k(null)}},L=async t=>{let o=`${t.publisher}.${t.name}`;k(o),j(``);try{await Pn(e,t.publisher,t.name);let s=!1;n===o&&(delete M.iconTheme,r(void 0),s=!0),i?.startsWith(o+`:`)&&(delete M.colorTheme,a(void 0),s=!0),s&&N(M),u.restart()}catch(e){j(`Uninstall failed: ${sr(e)}`)}k(null)},re=async e=>{let t=Fn(e);if(!t)return;let i=t===n?void 0:t;i?M.iconTheme=i:delete M.iconTheme,N(M),r(i)},ie=async(e,t)=>{let n=In(e,t),r=n===i?void 0:n;r?M.colorTheme=r:delete M.colorTheme,N(M),a(r)},ae=e=>e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(0)} KB`:`${(e/1024/1024).toFixed(1)} MB`;return(0,l.jsxs)(D,{className:J[`ext-panel`],onClose:()=>t(!1),initialFocusRef:s,children:[(0,l.jsxs)(`div`,{className:J[`ext-panel-header`],children:[(0,l.jsx)(`span`,{className:J[`ext-panel-title`],children:`Extensions`}),(0,l.jsx)(`button`,{className:J[`ext-panel-close`],onClick:()=>t(!1),children:`✕`})]}),(0,l.jsxs)(`div`,{className:J[`ext-panel-tabs`],children:[(0,l.jsx)(`button`,{className:C(J,`ext-tab`,f===`marketplace`&&`active`),onClick:()=>p(`marketplace`),children:`Marketplace`}),(0,l.jsxs)(`button`,{className:C(J,`ext-tab`,f===`installed`&&`active`),onClick:()=>p(`installed`),children:[`Installed (`,o.length,`)`]})]}),f===`marketplace`&&(0,l.jsxs)(`div`,{className:J[`ext-search`],children:[(0,l.jsxs)(`div`,{className:J[`ext-source-selector`],children:[(0,l.jsx)(`button`,{className:C(J,`ext-source-btn`,m===`vscode`&&`active`),onClick:()=>{h(`vscode`),_(``)},children:`VS Code`}),(0,l.jsx)(`button`,{className:C(J,`ext-source-btn`,m===`dotdir`&&`active`),onClick:()=>{h(`dotdir`),_(``)},children:`.dir`})]}),(0,l.jsx)(`input`,{ref:s,type:`text`,placeholder:`Search extensions...`,value:g,onChange:e=>ne(e.target.value),...b})]}),A&&(0,l.jsx)(`div`,{className:J[`ext-error`],children:A}),(0,l.jsxs)(`div`,{className:J[`ext-list`],children:[f===`marketplace`&&m===`dotdir`&&(T?(0,l.jsx)(`div`,{className:J[`ext-empty`],children:`Searching...`}):y.length===0?(0,l.jsx)(`div`,{className:J[`ext-empty`],children:`No extensions found`}):y.map(e=>{let t=`${e.publisher.username}.${e.name}`,n=F.has(t),r=O===t;return(0,l.jsxs)(`div`,{className:J[`ext-item`],children:[(0,l.jsx)(`div`,{className:J[`ext-icon`],children:e.icon_url?(0,l.jsx)(`img`,{src:e.icon_url,width:36,height:36,alt:``}):e.display_name[0]?.toUpperCase()??`?`}),(0,l.jsxs)(`div`,{className:J[`ext-info`],children:[(0,l.jsx)(`div`,{className:J[`ext-name`],children:e.display_name}),(0,l.jsx)(`div`,{className:J[`ext-publisher`],children:e.publisher.display_name||e.publisher.username}),(0,l.jsx)(`div`,{className:J[`ext-desc`],children:e.description}),(0,l.jsxs)(`div`,{className:J[`ext-meta`],children:[e.latest_version&&(0,l.jsxs)(`span`,{children:[`v`,e.latest_version.version]}),e.latest_version&&(0,l.jsx)(`span`,{children:ae(e.latest_version.archive_size)}),(0,l.jsxs)(`span`,{children:[`↓ `,e.total_downloads]})]})]}),(0,l.jsx)(`div`,{className:J[`ext-actions`],children:n?(0,l.jsx)(`button`,{className:C(J,`ext-btn`,`installed`),disabled:!0,children:`Installed`}):(0,l.jsx)(`button`,{className:C(J,`ext-btn`,`install`),disabled:r||!e.latest_version,onClick:()=>I(e),children:r?`Installing...`:`Install`})})]},e.id)})),f===`marketplace`&&m===`vscode`&&(T?(0,l.jsx)(`div`,{className:J[`ext-empty`],children:`Searching...`}):S.length===0?(0,l.jsx)(`div`,{className:J[`ext-empty`],children:`No extensions found`}):S.map(e=>{let t=`${e.publisher.publisherName}.${e.extensionName}`,n=F.has(t),r=O===t,i=Vn(e),a=Un(e),o=Bn(e);return(0,l.jsxs)(`div`,{className:J[`ext-item`],children:[(0,l.jsx)(`div`,{className:J[`ext-icon`],children:a?(0,l.jsx)(`img`,{src:a,width:36,height:36,alt:``}):e.displayName[0]?.toUpperCase()??`?`}),(0,l.jsxs)(`div`,{className:J[`ext-info`],children:[(0,l.jsx)(`div`,{className:J[`ext-name`],children:e.displayName}),(0,l.jsx)(`div`,{className:J[`ext-publisher`],children:e.publisher.displayName||e.publisher.publisherName}),(0,l.jsx)(`div`,{className:J[`ext-desc`],children:e.shortDescription}),(0,l.jsxs)(`div`,{className:J[`ext-meta`],children:[i&&(0,l.jsxs)(`span`,{children:[`v`,i]}),(0,l.jsxs)(`span`,{children:[`↓ `,o.toLocaleString()]})]})]}),(0,l.jsx)(`div`,{className:J[`ext-actions`],children:n?(0,l.jsx)(`button`,{className:C(J,`ext-btn`,`installed`),disabled:!0,children:`Installed`}):(0,l.jsx)(`button`,{className:C(J,`ext-btn`,`install`),disabled:r||!i,onClick:()=>P(e),children:r?`Installing...`:`Install`})})]},t)})),f===`installed`&&(o.length===0?(0,l.jsx)(`div`,{className:J[`ext-empty`],children:`No extensions installed`}):o.map(e=>{let t=`${e.ref.publisher}.${e.ref.name}`,r=O===t,a=Fn(e),o=a!=null&&a===n,s=e.colorThemes&&e.colorThemes.length>0;return(0,l.jsxs)(`div`,{className:J[`ext-item`],children:[(0,l.jsx)(`div`,{className:J[`ext-icon`],children:e.iconUrl?(0,l.jsx)(`img`,{src:e.iconUrl,width:36,height:36,alt:``}):(e.manifest.displayName||e.manifest.name)[0]?.toUpperCase()??`?`}),(0,l.jsxs)(`div`,{className:J[`ext-info`],children:[(0,l.jsx)(`div`,{className:J[`ext-name`],children:e.manifest.displayName||e.manifest.name}),(0,l.jsx)(`div`,{className:J[`ext-publisher`],children:e.manifest.publisher}),(0,l.jsx)(`div`,{className:J[`ext-desc`],children:e.manifest.description||``}),(0,l.jsxs)(`div`,{className:J[`ext-meta`],children:[(0,l.jsxs)(`span`,{children:[`v`,e.ref.version]}),a&&(0,l.jsx)(`span`,{className:C(J,`ext-theme-badge`,o&&`active`),children:o?`● Icon theme`:`Icon theme`}),s&&(0,l.jsxs)(`span`,{className:J[`ext-theme-badge`],children:[e.colorThemes.length,` color theme`,e.colorThemes.length>1?`s`:``]}),e.languages&&e.languages.length>0&&(0,l.jsxs)(`span`,{className:J[`ext-theme-badge`],children:[e.languages.length,` language`,e.languages.length>1?`s`:``]}),e.grammarRefs&&e.grammarRefs.length>0&&(0,l.jsxs)(`span`,{className:J[`ext-theme-badge`],children:[e.grammarRefs.length,` grammar`,e.grammarRefs.length>1?`s`:``]})]}),s&&(0,l.jsx)(`div`,{className:J[`ext-color-themes`],children:e.colorThemes.map(t=>{let n=In(e,t.id)===i;return(0,l.jsxs)(`button`,{className:C(J,`ext-btn`,`ext-color-theme-btn`,n?`installed`:`install`),onClick:()=>ie(e,t.id),children:[(0,l.jsx)(`span`,{className:J[`ext-color-theme-indicator`],"data-ui-theme":t.uiTheme}),t.label,n&&` ●`]},t.id)})})]}),(0,l.jsxs)(`div`,{className:J[`ext-actions`],children:[a&&(0,l.jsx)(`button`,{className:C(J,`ext-btn`,o?`installed`:`install`),onClick:()=>re(e),children:o?`Deactivate`:`Activate`}),(0,l.jsx)(`button`,{className:C(J,`ext-btn`,`uninstall`),disabled:r,onClick:()=>L(e.ref),children:r?`Removing...`:`Uninstall`})]})]},t)}))]})]})}var Y=new class{tail=Promise.resolve();enqueue(e){this.tail=this.tail.then(async()=>{try{let t=e();t&&typeof t.then==`function`&&(await t,await new Promise(e=>setTimeout(e,0)))}catch{}})}},lr=200,ur=new Map,dr=new Map;function fr(e){return e.startsWith(`/`)||/^[A-Za-z]:/.test(e)}function pr(e){return`data:image/svg+xml,${encodeURIComponent(e)}`}function mr(e){let t=ur.get(e);t!==void 0&&(ur.delete(e),ur.set(e,t))}function hr(){for(;ur.size>lr;){let e=ur.keys().next().value;ur.delete(e)}}async function gr(e,t){let n=U(t);try{let r=await St(e,n);ur.set(t,pr(r)),hr()}catch(e){throw console.warn(`[IconCache] loadIconAbsolute failed`,n,e),e}}async function _r(e){let t=await fetch(`/icons/${e}`);if(!t.ok)return;let n=await t.text();ur.set(e,pr(n)),hr()}function vr(e){return e===`_default`||e.startsWith(`_default_`)}async function yr(e,t){let n=[];for(let r of t){if(vr(r)||ur.has(r))continue;if(dr.has(r)){n.push(dr.get(r));continue}let t=(async()=>{try{fr(r)?await gr(e,r):await _r(r)}catch(e){console.warn(`[IconCache] loadIcons failed for`,r.slice(-60),e)}finally{dr.delete(r)}})();dr.set(r,t),n.push(t)}await Promise.all(n)}function br(e){let t=ur.get(e);return t!==void 0&&mr(e),t}function xr(e){return`data:image/svg+xml,${encodeURIComponent(e)}`}var Sr=class{theme=null;loadingIcons=new Map;themeKind=`dark`;constructor(e){this.bridge=e}async load(e){let t=await St(this.bridge,e);this.theme={json:JSON.parse(t),basePath:W(e),iconCache:new Map}}setTheme(e){this.themeKind=e}clear(){this.theme=null,this.loadingIcons.clear()}isLoaded(){return this.theme!==null}getEffectiveMap(e,t){return this.themeKind===`light`&&t!==void 0?t:e}resolveIcon(e,t,n,r,i){if(!this.theme)return null;let{json:a}=this.theme,o=this.themeKind===`light`?a.light:void 0,s;if(t){let t=this.getEffectiveMap(n?a.folderNamesExpanded:a.folderNames,n?o?.folderNamesExpanded:o?.folderNames);s=t?.[e]?t[e]:t?.[e.toLowerCase()]?t[e.toLowerCase()]:r?this.getEffectiveMap(n?a.rootFolderExpanded:a.rootFolder,void 0)??this.getEffectiveMap(n?a.folderExpanded:a.folder,n?o?.folderExpanded:o?.folder):this.getEffectiveMap(n?a.folderExpanded:a.folder,n?o?.folderExpanded:o?.folder)}else{let t=this.getEffectiveMap(a.fileNames,o?.fileNames);if(t?.[e])s=t[e];else if(t?.[e.toLowerCase()])s=t[e.toLowerCase()];else{let t=this.getEffectiveMap(a.fileExtensions,o?.fileExtensions);if(t){let n=e.split(`.`);for(let e=1;e<n.length;e++){let r=n.slice(e).join(`.`).toLowerCase();if(t[r]){s=t[r];break}}}!s&&i&&a.languageIds?.[i]&&(s=a.languageIds[i]),s||=this.getEffectiveMap(a.file,o?.file)}}if(!s)return null;let c=a.iconDefinitions[s];return c?.iconPath?G(this.theme.basePath,c.iconPath):null}async loadIcon(e){if(!this.theme)return null;let t=this.theme.iconCache.get(e);if(t)return t;let n=this.loadingIcons.get(e);if(n)return n;let r=(async()=>{try{let t=await xt(this.bridge,e),n=e.split(`.`).pop()?.toLowerCase()??``,r;if(n===`svg`)r=xr(new TextDecoder().decode(t));else{let e=n===`png`?`image/png`:n===`jpg`||n===`jpeg`?`image/jpeg`:n===`webp`?`image/webp`:`application/octet-stream`,i=new Blob([t],{type:e});r=URL.createObjectURL(i)}return this.theme?.iconCache.set(e,r),r}catch{return null}finally{this.loadingIcons.delete(e)}})();return this.loadingIcons.set(e,r),r}async preloadIcons(e){await Promise.all(e.map(e=>this.loadIcon(e)))}getCachedIcon(e){return this.theme?.iconCache.get(e)??null}},Cr=(0,d.atom)(e=>{let t=e(ve);if(!t)throw Error(`Bridge not initialized.`);return new Sr(t)});function wr(){return(0,d.useAtomValue)(Cr)}var Tr={folder:`data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22%2390a4ae%22%3E%3Cpath%20d%3D%22M10%204H4c-1.1%200-2%20.9-2%202v12c0%201.1.9%202%202%202h16c1.1%200%202-.9%202-2V8c0-1.1-.9-2-2-2h-8l-2-2z%22%2F%3E%3C%2Fsvg%3E`,folderOpen:`data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22%2390a4ae%22%3E%3Cpath%20d%3D%22M20%206h-8l-2-2H4c-1.1%200-2%20.9-2%202v12c0%201.1.9%202%202%202h16c1.1%200%202-.9%202-2V8c0-1.1-.9-2-2-2zm0%2012H4V8h16v10z%22%2F%3E%3C%2Fsvg%3E`,file:`data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22%2390a4ae%22%3E%3Cpath%20d%3D%22M14%202H6c-1.1%200-2%20.9-2%202v16c0%201.1.9%202%202%202h12c1.1%200%202-.9%202-2V8l-6-6zm4%2018H6V4h7v5h5v11z%22%2F%3E%3C%2Fsvg%3E`},Er=`fss`,Dr=[];function Or(){let e=wr();return{setIconTheme:async(t,n)=>{if(Er=t,t===`vscode`&&n)try{await e.load(n),jr()}catch{Er=`none`,jr()}else e.clear(),jr()}}}function kr(){let e=wr();return{setIconThemeKind:t=>{e.setTheme(t)}}}function Ar(e){return Dr.push(e),()=>{Dr=Dr.filter(t=>t!==e)}}function jr(){for(let e of Dr)e()}function Mr(){let e=wr();return(t,n,r,i,a,o)=>{let s=n?r?Tr.folderOpen:Tr.folder:Tr.file;if(Er===`vscode`&&e.isLoaded()){let o=e.resolveIcon(t,n,r,i,a);return o?{path:o,url:e.getCachedIcon(o),fallbackUrl:s}:{path:`_default`,url:s,fallbackUrl:s}}return Er===`fss`&&o?{path:o,url:br(o)??null,fallbackUrl:s}:{path:`_default`,url:s,fallbackUrl:s}}}function Nr(){let e=wr(),t=B();return async n=>{Er===`vscode`&&e.isLoaded()?await e.preloadIcons(n):await yr(t,n)}}function Pr(){let e=wr();return t=>t===`_default_folder`?Tr.folder:t===`_default_folder_open`?Tr.folderOpen:t===`_default_file`?Tr.file:Er===`vscode`&&e.isLoaded()?e.getCachedIcon(t):br(t)??null}var Fr=null;function Ir(e){Fr=e}function Lr(){return Fr}var Rr=(0,m.createLayer)(`
114
114
  folder { font-weight: bold; }
115
115
 
116
116
  @sorting {
117
117
  folder { group-first: true; }
118
118
  file[executable] { priority: 1; }
119
119
  }
120
- `,`/`,m.LayerPriority.GLOBAL),zr=[];function Br(e,t){return e.replace(/url\(([^)]+)\)/g,(e,n)=>{let r=n.trim();return r.startsWith(`/`)||/^[A-Za-z]:/.test(r)?e:`url(${G(t,r.replace(/^\.\//,``))})`})}function Vr(e,t){let n=e.filter(e=>e.iconThemeFss!=null&&e.iconThemeBasePath!=null),r=t?n.filter(e=>`${e.ref.publisher}.${e.ref.name}`===t):[];console.log(`[FSS] setExtensionLayers`,{total:e.length,withFss:n.map(e=>`${e.ref.publisher}.${e.ref.name}`),activeIconTheme:t??`(all)`,layersAdded:r.map(e=>`${e.ref.publisher}.${e.ref.name}`)}),zr=r.map(e=>(0,m.createLayer)(Br(e.iconThemeFss,U(e.iconThemeBasePath)),`/`,m.LayerPriority.USER))}var Hr=new Map;function Ur(e){Hr.delete(e)}function Wr(e=`dark`){let t=new m.LayeredResolver;return t.addLayer(Rr),t.setTheme(e),t}async function Gr(e,t,n){let r=[],i=n;for(;;){r.push(i);let e=W(i);if(e===i)break;i=e}for(let t of r)if(K(t)!==`.dotdir`&&!Hr.has(t)){let n=G(t,`.dotdir`);try{Hr.set(t,await St(e,G(n,`fs.css`)))}catch{Hr.set(t,null)}}let a=[Rr,...zr];for(let e of r){let t=Hr.get(e);if(t!=null){let n=e===`/`?0:e.split(`/`).filter(Boolean).length,r=G(e,`.dotdir`);a.push((0,m.createLayer)(Br(t,r),e,m.LayerPriority.nestedPriority(n)))}}t.setLayers(a)}function Kr(e){if(!e)return null;let t=/^url\(([^)]+)\)$/.exec(String(e));return t?t[1]:null}function qr(e,t){let n=e.resolveStyle(t),r=e.resolveSorting(t);return{color:n.color==null?void 0:String(n.color),opacity:n.opacity==null?void 0:Number(n.opacity),fontWeight:n[`font-weight`]==null?void 0:n[`font-weight`],fontStyle:n[`font-style`]==null?void 0:String(n[`font-style`]),fontStretch:n[`font-stretch`]==null?void 0:String(n[`font-stretch`]),fontVariant:n[`font-variant`]==null?void 0:String(n[`font-variant`]),textDecoration:n[`text-decoration`]==null?void 0:String(n[`text-decoration`]),icon:Kr(n.icon),sortPriority:typeof r.priority==`number`?r.priority:0,groupFirst:r[`group-first`]===!0}}function Jr(e){let[t,n]=(0,c.useState)(()=>typeof window>`u`?!1:window.matchMedia(e).matches);return(0,c.useEffect)(()=>{if(typeof window>`u`)return;let t=window.matchMedia(e),r=()=>n(t.matches);return r(),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}var Yr=`_breadcrumbs_15ml8_25`,Xr=`_entry_15ml8_151`,Zr=`_selected_15ml8_166`,Qr=`_marked_15ml8_176`,X={"file-list":`_file-list_15ml8_1`,"active-panel":`_active-panel_15ml8_7`,"path-bar":`_path-bar_15ml8_7`,breadcrumbs:Yr,"is-cropped-left":`_is-cropped-left_15ml8_44`,"is-cropped-right":`_is-cropped-right_15ml8_53`,"breadcrumb-copied-tooltip":`_breadcrumb-copied-tooltip_15ml8_67`,"breadcrumb-segment":`_breadcrumb-segment_15ml8_84`,"breadcrumb-segment-text":`_breadcrumb-segment-text_15ml8_100`,"breadcrumb-separator":`_breadcrumb-separator_15ml8_104`,"file-list-body":`_file-list-body_15ml8_111`,"columns-scroller-root":`_columns-scroller-root_15ml8_117`,"columns-scroller-content":`_columns-scroller-content_15ml8_123`,"columns-borders":`_columns-borders_15ml8_135`,"columns-border":`_columns-border_15ml8_135`,entry:Xr,"no-hover":`_no-hover_15ml8_162`,selected:Zr,"inactive-panel":`_inactive-panel_15ml8_171`,marked:Qr,"entry-icon":`_entry-icon_15ml8_195`,"entry-name":`_entry-name_15ml8_201`,"entry-size":`_entry-size_15ml8_208`,"file-info-footer":`_file-info-footer_15ml8_217`,"file-info-name":`_file-info-name_15ml8_231`,"file-info-link":`_file-info-link_15ml8_238`,"file-info-size":`_file-info-size_15ml8_247`,"file-info-date":`_file-info-date_15ml8_253`,"panel-summary":`_panel-summary_15ml8_259`},$r=(0,c.memo)(function({currentPath:e,onNavigate:t}){let n=(0,c.useRef)(null),r=(0,c.useRef)(!0),i=(0,c.useRef)(!1),[a,o]=(0,c.useState)(!1),[s,u]=(0,c.useState)(!1),[d,f]=(0,c.useState)(!1),p=(0,c.useRef)(null),m=(0,c.useMemo)(()=>yt(e),[e]),h=(0,c.useCallback)((n,r,i)=>{i?navigator.clipboard.writeText(e).then(()=>{p.current&&clearTimeout(p.current),f(!0),p.current=setTimeout(()=>{f(!1),p.current=null},1e3)}):t(n.path)},[e,t]);(0,c.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]);let g=(0,c.useCallback)(()=>{let e=n.current;if(!e)return;let t=Math.max(0,e.scrollWidth-e.clientWidth),r=e.scrollLeft>0,i=e.scrollLeft<t-1;o(e=>e===r?e:r),u(e=>e===i?e:i)},[]),_=(0,c.useCallback)(()=>{let e=n.current;e&&(i.current=!0,e.scrollLeft=e.scrollWidth,queueMicrotask(()=>{i.current=!1}))},[]);if((0,c.useLayoutEffect)(()=>{_(),r.current=!0,g()},[e,_,g]),(0,c.useEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{g()},i=new ResizeObserver(()=>{(r.current||e.scrollLeft>e.scrollWidth-e.clientWidth)&&_(),g()});return i.observe(e),e.addEventListener(`scroll`,t,{passive:!0}),()=>{i.disconnect(),e.removeEventListener(`scroll`,t)}},[_,g]),m.length===0)return null;let v=/^[A-Za-z]:[\\/]/.test(e)||e.includes(`\\`)?`\\`:`/`;return(0,l.jsxs)(`div`,{className:C(X,`breadcrumbs`,a&&`is-cropped-left`,s&&`is-cropped-right`),ref:n,onWheel:e=>{let t=n.current;if(!t)return;let i=Math.max(0,t.scrollWidth-t.clientWidth);r.current=t.scrollLeft+(Math.abs(e.deltaY)>Math.abs(e.deltaX)?e.deltaY:e.deltaX)>=i-1,Math.abs(e.deltaY)>Math.abs(e.deltaX)&&e.deltaY!==0&&(t.scrollLeft+=e.deltaY,e.preventDefault())},children:[m.map((e,t)=>{let n=t===m.length-1;return(0,l.jsxs)(c.Fragment,{children:[(0,l.jsx)(`div`,{className:X[`breadcrumb-segment`],onClick:r=>{r.stopPropagation(),h(e,t,n)},children:(0,l.jsx)(`span`,{className:X[`breadcrumb-segment-text`],children:e.label})}),!n&&e.label!==`/`&&(0,l.jsx)(`span`,{className:X[`breadcrumb-separator`],"aria-hidden":!0,children:v})]},`${t}-${e.path}`)}),d&&(0,l.jsx)(`span`,{className:X[`breadcrumb-copied-tooltip`],role:`status`,children:`Path copied to clipboard`})]})}),ei=({children:e,scrollHeight:t,scrollTop:n,lineSize:r,velocityFactor:i=20,frictionFactor:a=.95,style:o,onScroll:s})=>{let u=(0,c.useRef)(null),d=(0,c.useRef)(n),f=(0,c.useRef)(s),p=Jr(`(pointer: coarse)`);return d.current=n,f.current=s,(0,c.useEffect)(()=>{let e=u.current;if(!e)return;let n,o=0,s=0,c=!1,l=e=>{if(!f.current)return;let n=d.current+e;n=Math.min(n,t),n=Math.max(0,n),d.current!==n&&(d.current=n,f.current(n))},m=navigator.platform.startsWith(`Win`),h=e=>{e.preventDefault(),e.stopPropagation(),l(r&&m?Math.sign(e.deltaY)*r:e.deltaY)},g=e=>{n=e.clientY,o=performance.now(),c=!1,s=0},_=t=>{if(n==null)return;let r=t.clientY,i=n-r;if(Math.abs(i)<3)return;e.setPointerCapture(t.pointerId),l(i),n=r;let a=performance.now(),c=a-o;o=a,c>0&&(s=i/c),t.preventDefault()},v=t=>{if(n==null)return;n=void 0,e.releasePointerCapture(t.pointerId);let r=()=>{Math.abs(s)>.1?(l(s*i),s*=a,requestAnimationFrame(r)):c=!1};c||(c=!0,requestAnimationFrame(r))};return e.addEventListener(`wheel`,h,{passive:!1}),p&&(e.addEventListener(`pointerdown`,g),e.addEventListener(`pointermove`,_),e.addEventListener(`pointerup`,v),e.addEventListener(`pointercancel`,v)),()=>{e.removeEventListener(`wheel`,h),p&&(e.removeEventListener(`pointerdown`,g),e.removeEventListener(`pointermove`,_),e.removeEventListener(`pointerup`,v),e.removeEventListener(`pointercancel`,v))}},[i,a,t,r,p]),(0,l.jsx)(`div`,{style:{overflow:`hidden`,position:`relative`,touchAction:`none`,...o},children:(0,l.jsx)(`div`,{ref:u,style:{position:`absolute`,inset:0,pointerEvents:`auto`},children:e})})};function ti(e){let[t,n]=(0,c.useState)({width:0,height:0});return(0,c.useEffect)(()=>{let t=e.current;if(!t)return;let r=new ResizeObserver(([e])=>{let{width:t,height:r}=e.contentRect;n(e=>e.width===t&&e.height===r?e:{width:t,height:r})});return r.observe(t),()=>r.disconnect()},[e]),t}var ni=(0,c.memo)(function({index:e,isActive:t,isSelected:n,width:r,height:i,renderItem:a}){return(0,l.jsx)(`div`,{style:{width:r,height:i},children:a(e,t,n)})}),ri=(0,c.memo)(function(e){let{topmostIndex:t}=e,{activeIndex:n,totalCount:r,itemHeight:i,minColumnWidth:a,far:o=!1,selectedKeys:s,getItemKey:u,renderItem:d,onPosChange:f,onItemsPerColumnChanged:p,onColumnCountChanged:m}=e;if(!Number.isInteger(i)||i<=0)throw Error(`itemHeight should be positive`);let h=(0,c.useRef)(f),g=(0,c.useRef)(p),_=(0,c.useRef)(m);h.current=f,g.current=p,_.current=m;let v=(0,c.useRef)(null),{width:y,height:b}=ti(v),x=a!=null&&y>0?Math.max(1,Math.floor(y/a)):1,S=Math.max(1,Math.floor(b/i));(0,c.useLayoutEffect)(()=>{g.current?.(S)},[S]),(0,c.useLayoutEffect)(()=>{_.current?.(x)},[x]);let C=e.topmostIndex;n<t?t=n:n>t+x*S-1?t=n-x*S+1:t>r-x*S&&(t=Math.max(0,r-x*S)),(0,c.useEffect)(()=>{t!==C&&h.current?.(t,n)});let w=(0,c.useRef)(t),T=(0,c.useRef)(n);w.current=t,T.current=n;let E=(0,c.useCallback)(e=>{let t=Math.round(e/i),n=t-T.current;if(n){let e=o?w.current+n:w.current;h.current?.(e,t)}},[i,o]),D=Math.min(r,t+S*x),O=`${100/x}%`,k=[];for(let e=t;e<D;e++){let t=u?u(e):e;k.push((0,l.jsx)(ni,{index:e,isActive:n===e,isSelected:s?.has(t)??!1,width:O,height:i,renderItem:d},t))}let A=D-t,j=x-Math.ceil(A/S);for(let e=0;e<j;e++)k.push((0,l.jsx)(`div`,{style:{height:`100%`,width:O}},`empty-${e}`));return(0,l.jsxs)(`div`,{className:X[`columns-scroller-root`],ref:v,children:[(0,l.jsx)(`div`,{className:X[`columns-borders`],style:{gridTemplateColumns:`repeat(${x}, 1fr)`},children:Array.from({length:x},(e,t)=>(0,l.jsx)(`div`,{className:X[`columns-border`]},t))}),(0,l.jsx)(ei,{scrollTop:n*i,scrollHeight:(r-1)*i,lineSize:i,style:{height:`100%`},onScroll:E,children:(0,l.jsx)(`div`,{className:X[`columns-scroller-content`],style:{height:S*i},children:k})})]})}),ii=26;function ai(e){let t;if(typeof e==`number`)t=e;else if(typeof e==`bigint`)t=Number(e);else return``;return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} K`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} M`:`${(t/(1024*1024*1024)).toFixed(1)} G`}function oi(e){if(!e)return``;let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function si(e,t,n){return Math.max(t,Math.min(n,e))}var ci=(0,c.memo)(function({currentPath:e,parentNode:t,entries:n,onNavigate:r,selectionKey:i,active:a,resolver:o,requestedActiveName:s,requestedTopmostName:u,onStateChange:d}){let f=(0,c.useRef)(null),[p,m]=(0,c.useState)(0),[h,g]=(0,c.useState)(0),[_,v]=(0,c.useState)(1),[y,b]=(0,c.useState)(1),[x,S]=(0,c.useState)(0),[w,T]=(0,c.useState)(new Set),[E,D]=(0,c.useState)(!1),O=(0,c.useRef)(E);O.current=E;let k=Jr(`(pointer: coarse)`),A=(0,c.useRef)(w);A.current=w;let j=(0,c.useRef)(void 0),ee=(0,c.useRef)(e),M=(0,c.useRef)([]),N=(0,c.useRef)(p);N.current=p;let te=(0,c.useRef)(h);te.current=h;let ne=(0,c.useRef)(e);ne.current=e;let P=(0,c.useRef)(r);P.current=r;let F=(0,c.useCallback)(()=>{O.current||D(!0)},[]),I=(0,c.useCallback)(()=>{O.current&&D(!1)},[]),L=Pr(),re=(0,c.useCallback)(e=>{if(e)return L(e)??void 0},[L]),ie=Mr(),ae=(0,c.useMemo)(()=>{let e=n.map(e=>{e={...e,parent:t};let n=qr(o,e),r=e.type===`folder`,i=ie(e.name,r,!1,!1,e.lang,n.icon);return{entry:e,style:n,iconPath:i.path,iconFallbackUrl:i.fallbackUrl}});return e.sort((e,t)=>e.style.groupFirst===t.style.groupFirst?e.style.sortPriority===t.style.sortPriority?e.entry.name.localeCompare(t.entry.name):t.style.sortPriority-e.style.sortPriority:e.style.groupFirst?-1:1),e},[n,e]),R=(0,c.useMemo)(()=>{let e=[];if(t){let n={...t,stateFlags:1},r=qr(o,n),i=ie(`..`,!0,!0,!1,``,r.icon);e.push({entry:{...n,name:`..`},style:r,iconPath:i.path,iconFallbackUrl:i.fallbackUrl})}for(let t of ae)e.push(t);return e},[ae,t]),z=(0,c.useRef)(R);z.current=R;let oe=(0,c.useMemo)(()=>{let e=new Set;for(let{iconPath:t}of R)t&&e.add(t);return[...e]},[R]),se=Nr();(0,c.useEffect)(()=>{let e=!1;return se(oe).then(()=>{e||S(e=>e+1)}),()=>{e=!0}},[oe]),(0,c.useEffect)(()=>Ar(()=>{S(e=>e+1)}),[]),(0,c.useEffect)(()=>{let t=ee.current;if(ee.current=e,t===e){m(e=>Math.min(e,R.length-1));return}if(t.startsWith(e)){let n=M.current;for(;n.length>0&&n[n.length-1].path!==e;)n.pop();let r=n.pop();if(r){let e=R.findIndex(e=>e.entry.name===r.selectedName),t=R.findIndex(e=>e.entry.name===r.topmostName);m(e>=0?e:0),g(t>=0?t:0);return}let i=t.slice(e.length).replace(/^\//,``).split(`/`)[0].replace(/\0.*$/,``);if(i){let e=R.findIndex(e=>e.entry.name===i);if(e>=0){m(e),g(Math.max(0,e-5));return}}}m(0),g(0)},[e,R]),(0,c.useEffect)(()=>{if(!s)return;let e=z.current.findIndex(e=>e.entry.name===s);e>=0&&m(e)},[s]),(0,c.useEffect)(()=>{if(!u)return;let e=z.current.findIndex(e=>e.entry.name===u);e>=0&&g(e)},[u]);let ce=(0,c.useRef)(d);ce.current=d;let le=(0,c.useRef)(void 0);(0,c.useEffect)(()=>{ce.current&&(clearTimeout(le.current),le.current=setTimeout(()=>{let e=z.current[N.current]?.entry.name,t=z.current[te.current]?.entry.name;ce.current?.(e,t)},150))},[p,h,R]),(0,c.useEffect)(()=>()=>{if(clearTimeout(le.current),!ce.current)return;let e=z.current[N.current]?.entry.name,t=z.current[te.current]?.entry.name;ce.current(e,t)},[]);let ue=(0,c.useCallback)(e=>{P.current(e)},[]),de=(0,c.useCallback)((e,t,n)=>{let r=z.current;if(j.current===void 0){let t=r[e]?.entry.name;j.current=t?!A.current.has(t):!0}let i=j.current,a=Math.min(e,t),o=Math.max(e,t);T(e=>{let s=new Set(e);for(let e=a;e<=o;e++){if(n===`exclude-active`&&e===t)continue;let a=r[e]?.entry.name;a&&(i?s.add(a):s.delete(a))}return s}),m(si(t,0,r.length-1))},[]);(0,c.useEffect)(()=>{if(!a)return;let e=e=>{!e.shiftKey&&j.current!==void 0&&(j.current=void 0)};return window.addEventListener(`keyup`,e),()=>window.removeEventListener(`keyup`,e)},[a]),(0,c.useEffect)(()=>{T(new Set),j.current=void 0},[e,i]);let fe=(0,c.useCallback)(async e=>{if(e.name===`..`)await P.current(W(ne.current));else if(e.type===`folder`){let t=z.current[N.current]?.entry.name,n=z.current[te.current]?.entry.name;t&&M.current.push({path:ne.current,selectedName:t,topmostName:n??t}),await P.current(G(ne.current,e.name))}else e.type===`file`&&V.executeCommand(`dotdir.viewFile`,e.path,e.name,Number(e.meta.size))},[]),pe=Math.min(R.length,_*y),me=(0,c.useRef)(_);me.current=_;let he=(0,c.useRef)(pe);he.current=pe,(0,c.useEffect)(()=>{g(e=>{let t=_*y;return p<e?p:p>e+t-1?p-t+1:e})},[p,_,y]);let ge=(0,c.useCallback)(()=>{let e=z.current[N.current],t=e?.entry.type===`file`,n=t&&e!=null&&!!e.entry.meta.executable,r=e?.entry.name??``;V.beginBatch(),V.setContext(`listItemIsFile`,t),V.setContext(`listItemIsFolder`,!t&&e!=null),V.setContext(`listItemIsExecutable`,n),V.setContext(`listItemHasViewer`,t&&Wt.resolve(r)!==null),V.setContext(`listItemHasEditor`,t&&Gt.resolve(r)!==null),V.endBatch()},[]);(0,c.useEffect)(()=>{a&&ge()},[a,p,R,ge]),(0,c.useEffect)(()=>{if(!a)return;let e=Wt.onChange(ge),t=Gt.onChange(ge);return()=>{e(),t()}},[a,ge]),(0,c.useEffect)(()=>{if(a)return ln({focus:()=>{f.current?.focus({preventScroll:!0})},cursorUp:()=>Y.enqueue(()=>{F(),m(e=>Math.max(0,e-1))}),cursorDown:()=>Y.enqueue(()=>{F(),m(e=>Math.min(z.current.length-1,e+1))}),cursorLeft:()=>Y.enqueue(()=>{F(),m(e=>Math.max(0,e-me.current))}),cursorRight:()=>Y.enqueue(()=>{F(),m(e=>Math.min(z.current.length-1,e+me.current))}),cursorHome:()=>Y.enqueue(()=>{F(),m(0)}),cursorEnd:()=>Y.enqueue(()=>{F(),m(z.current.length-1)}),cursorPageUp:()=>Y.enqueue(()=>{F(),m(e=>Math.max(0,e-he.current+1))}),cursorPageDown:()=>Y.enqueue(()=>{F(),m(e=>Math.min(z.current.length-1,e+he.current-1))}),selectUp:()=>Y.enqueue(()=>{F();let e=N.current;de(e,Math.max(0,e-1),e===0?`include-active`:`exclude-active`)}),selectDown:()=>Y.enqueue(()=>{F();let e=N.current,t=z.current.length-1;de(e,Math.min(t,e+1),e===t?`include-active`:`exclude-active`)}),selectLeft:()=>Y.enqueue(()=>{F();let e=N.current;de(e,Math.max(0,e-me.current),`include-active`)}),selectRight:()=>Y.enqueue(()=>{F();let e=N.current;de(e,Math.min(z.current.length-1,e+me.current),`include-active`)}),selectHome:()=>Y.enqueue(()=>{F(),de(N.current,0,`include-active`)}),selectEnd:()=>Y.enqueue(()=>{F(),de(N.current,z.current.length-1,`include-active`)}),selectPageUp:()=>Y.enqueue(()=>{F();let e=N.current;de(e,Math.max(0,e-he.current+1),`include-active`)}),selectPageDown:()=>Y.enqueue(()=>{F();let e=N.current;de(e,Math.min(z.current.length-1,e+he.current-1),`include-active`)}),execute:()=>Y.enqueue(async()=>{let e=z.current[N.current];!e||e.entry.type!==`file`||e.entry.meta.executable&&V.executeCommand(`terminal.execute`,e.entry.path)}),open:()=>Y.enqueue(async()=>{let e=z.current[N.current];e&&await fe(e.entry)}),viewFile:()=>Y.enqueue(()=>{let e=z.current[N.current];e&&e.entry.type===`file`&&V.executeCommand(`dotdir.viewFile`,e.entry.path,e.entry.name,Number(e.entry.meta.size))}),editFile:()=>Y.enqueue(()=>{let e=z.current[N.current];if(e&&e.entry.type===`file`){let t=typeof e.entry.lang==`string`&&e.entry.lang?e.entry.lang:`plaintext`;V.executeCommand(`dotdir.editFile`,e.entry.path,e.entry.name,Number(e.entry.meta.size),t)}}),moveToTrash:()=>Y.enqueue(()=>{let e=Lr();if(!e)return;let t=A.current,n=z.current,r=()=>P.current(ne.current),i=t.size>0?n.filter(e=>t.has(e.entry.name)).map(e=>e.entry.path):(()=>{let e=n[N.current];return e?[e.entry.path]:[]})();i.length!==0&&e.moveToTrash(i,r)}),permanentDelete:()=>Y.enqueue(()=>{let e=Lr();if(!e)return;let t=A.current,n=z.current,r=()=>P.current(ne.current),i=t.size>0?n.filter(e=>t.has(e.entry.name)).map(e=>e.entry.path):(()=>{let e=n[N.current];return e?[e.entry.path]:[]})();i.length!==0&&e.permanentDelete(i,r)}),copy:()=>Y.enqueue(()=>{let e=Lr();if(!e)return;let t=A.current,n=z.current,r=()=>P.current(ne.current),i=t.size>0?n.filter(e=>t.has(e.entry.name)).map(e=>e.entry.path):(()=>{let e=n[N.current];return e?[e.entry.path]:[]})();i.length!==0&&e.copy(i,r)}),move:()=>Y.enqueue(()=>{let e=Lr();if(!e)return;let t=A.current,n=z.current,r=()=>P.current(ne.current),i=t.size>0?n.filter(e=>t.has(e.entry.name)).map(e=>e.entry.path):(()=>{let e=n[N.current];return e?[e.entry.path]:[]})();i.length!==0&&e.move(i,r)}),rename:()=>Y.enqueue(()=>{let e=Lr();if(!e)return;let t=z.current[N.current];t&&e.rename(t.entry.path,t.entry.name,()=>P.current(ne.current))}),pasteFilename:()=>Y.enqueue(()=>{let e=z.current[N.current];if(!e)return;let t=Lr();if(!t)return;let n=e.entry.name,r=/^[a-zA-Z0-9._+-]+$/.test(n)?n:JSON.stringify(n);t.pasteToCommandLine(r)}),pastePath:()=>Y.enqueue(()=>{let e=z.current[N.current];if(!e)return;let t=Lr();if(!t)return;let n=(e.entry.path??``).split(`\0`)[0],r=/^[a-zA-Z0-9._+/:-]+$/.test(n)?n:JSON.stringify(n);t.pasteToCommandLine(r)})}),()=>ln(null)},[a,F,fe,de]);let _e=(0,c.useRef)(y);_e.current=y;let ve=(0,c.useCallback)(e=>{v(e),g(t=>Math.max(0,Math.min(t,z.current.length-e*_e.current)))},[]),B=(0,c.useCallback)(e=>{b(e)},[]),ye=(0,c.useCallback)((e,t)=>{let n=z.current.length;m(si(t,0,n-1)),g(si(e,0,n-1))},[]),be=(0,c.useCallback)(e=>z.current[e]?.entry.name??e,[]),xe=(0,c.useRef)(0),Se=(0,c.useCallback)((e,t,n)=>{let r=z.current[e];if(!r)return null;let{entry:i,style:a,iconPath:o,iconFallbackUrl:s}=r,c=re(o)??s,u=i.type===`file`&&!!i.meta.executable;return(0,l.jsxs)(`div`,{className:C(X,`entry`,t&&`selected`,n&&`marked`),style:{height:ii,opacity:a.opacity},onMouseDown:t=>{t.stopPropagation(),I();let n=Date.now();n-xe.current<300?(xe.current=0,u?Y.enqueue(()=>V.executeCommand(`terminal.execute`,i.path)):Y.enqueue(()=>fe(i))):(xe.current=n,Y.enqueue(()=>m(e)))},children:[(0,l.jsx)(`span`,{className:X[`entry-icon`],children:(0,l.jsx)(`img`,{src:c,width:16,height:16,alt:``})}),(0,l.jsx)(`span`,{className:X[`entry-name`],style:{color:a.color,fontWeight:a.fontWeight,fontStyle:a.fontStyle,fontStretch:a.fontStretch,fontVariant:a.fontVariant,textDecoration:a.textDecoration},children:i.name}),`size`in i.meta&&i.type===`file`&&(0,l.jsx)(`span`,{className:X[`entry-size`],children:ai(i.meta.size)})]})},[fe,x,I]),Ce=R[p],we=Ce?.entry.name??``,Te=Ce?oi(Number(Ce.entry.meta.mtimeMs??0)):``,Ee=(()=>{if(!Ce)return``;let e=Ce.entry;if(e.name===`..`)return`Up`;let t=e.meta.entryKind??(e.type===`folder`?`directory`:`file`),n=e.meta.nlink??1;switch(t){case`directory`:return n>1?`DIR [${n}]`:`DIR`;case`symlink`:return``;case`block_device`:return`BLK DEV`;case`char_device`:return`CHR DEV`;case`named_pipe`:return`FIFO`;case`socket`:return`SOCK`;case`whiteout`:return`WHT`;case`door`:return`DOOR`;case`event_port`:return`EVT PORT`;case`unknown`:return`?`;default:{let t=ai(e.meta.size);return n>1?`${t} [${n}]`:t}}})(),De=!Ce||(Ce.entry.meta.entryKind??``)!==`symlink`?``:`\u2192 ${Ce.entry.meta.linkTarget??`?`}`,Oe=(0,c.useMemo)(()=>R.filter(e=>e.entry.type===`file`).length,[R]),ke=(0,c.useMemo)(()=>R.reduce((e,t)=>t.entry.type===`file`&&typeof t.entry.meta.size==`number`?e+t.entry.meta.size:e,0),[R]),Ae=(0,c.useMemo)(()=>{if(w.size===0)return null;let e=0,t=0;for(let n of R)w.has(n.entry.name)&&(e++,n.entry.type===`file`&&typeof n.entry.meta.size==`number`&&(t+=n.entry.meta.size));return{count:e,size:t}},[w,R]);return(0,l.jsxs)(`div`,{ref:f,tabIndex:0,className:C(X,`file-list`,k||E?`no-hover`:null,a?`active-panel`:`inactive-panel`),onMouseMoveCapture:I,onMouseDownCapture:()=>{I(),f.current?.focus({preventScroll:!0})},children:[(0,l.jsx)(`div`,{className:X[`path-bar`],children:(0,l.jsx)($r,{currentPath:e,onNavigate:ue})}),(0,l.jsx)(`div`,{className:X[`file-list-body`],children:(0,l.jsx)(ri,{topmostIndex:h,activeIndex:p,totalCount:R.length,itemHeight:ii,minColumnWidth:250,far:!0,selectedKeys:w,getItemKey:be,renderItem:Se,onPosChange:ye,onItemsPerColumnChanged:ve,onColumnCountChanged:B})}),(0,l.jsxs)(`div`,{className:X[`file-info-footer`],children:[(0,l.jsx)(`span`,{className:X[`file-info-name`],children:we}),De&&(0,l.jsx)(`span`,{className:X[`file-info-link`],children:De}),(0,l.jsx)(`span`,{className:X[`file-info-size`],children:Ee}),(0,l.jsx)(`span`,{className:X[`file-info-date`],children:Te})]}),(0,l.jsx)(`div`,{className:X[`panel-summary`],children:Ae?`${Ae.count} selected, ${ai(Ae.size)}`:`${Oe.toLocaleString()} file${Oe===1?``:`s`}, ${ai(ke)}`})]})}),li=`_hidden_1i903_12`,ui=`_panel_1i903_1`,di=`_active_1i903_33`,fi=`_temp_1i903_123`,Z={"panels-overlay":`_panels-overlay_1i903_1`,hidden:li,panel:ui,active:di,"panel-progress":`_panel-progress_1i903_37`,"progress-slide":`_progress-slide_1i903_1`,"panel-tabs":`_panel-tabs_1i903_67`,"panel-tabs-list":`_panel-tabs-list_1i903_77`,"panel-tab":`_panel-tab_1i903_67`,"panel-tab-label":`_panel-tab-label_1i903_106`,temp:fi,"panel-tab-close":`_panel-tab-close_1i903_127`,"panel-tab-new":`_panel-tab-new_1i903_147`,"panel-tab-dragging":`_panel-tab-dragging_1i903_166`,"panel-tab-drop-indicator":`_panel-tab-drop-indicator_1i903_170`,"panel-content":`_panel-content_1i903_180`};function pi(e){return e.type===`filelist`?K(e.path)||e.path||`File list`:e.name}var mi=(0,c.memo)(function({tabs:e,activeTabId:t,onSelectTab:n,onDoubleClickTab:r,onCloseTab:i,onNewTab:a,onReorderTabs:o}){let s=(0,c.useRef)(null),u=(0,c.useRef)([]),d=(0,c.useRef)(null),[f,p]=(0,c.useState)(null);u.current=e.map((e,t)=>u.current[t]??null);let m=(0,c.useCallback)(e=>{let t=s.current;t&&(t.scrollLeft+=e.deltaY===0?e.deltaX:e.deltaY)},[]),h=(0,c.useCallback)(e=>{if(!s.current)return null;let t=u.current;for(let n=0;n<t.length;n++){let r=t[n];if(!r)continue;let i=r.getBoundingClientRect();if(e<i.left+i.width/2)return n}return t.length},[]),g=(0,c.useCallback)((e,t)=>{d.current=t,e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,String(t)),e.dataTransfer.setDragImage(new Image,0,0),requestAnimationFrame(()=>{e.target.classList.add(Z[`panel-tab-dragging`])})},[]),_=(0,c.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`,p(h(e.clientX))},[h]),v=(0,c.useCallback)(e=>{e.preventDefault();let t=d.current,n=h(e.clientX);t!=null&&n!=null&&o&&(n>t?o(t,n-1):n<t&&o(t,n)),d.current=null,p(null)},[h,o]),y=(0,c.useCallback)(e=>{s.current?.contains(e.relatedTarget)||p(null)},[]),b=(0,c.useCallback)(e=>{e.target.classList.remove(Z[`panel-tab-dragging`]),d.current=null,p(null)},[]);return(0,c.useEffect)(()=>{let e=s.current;if(!e)return;let t=e=>e.preventDefault();return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]),(0,l.jsxs)(`div`,{className:Z[`panel-tabs`],children:[(0,l.jsxs)(`div`,{className:Z[`panel-tabs-list`],ref:s,onWheel:m,onDragOver:_,onDrop:v,onDragLeave:y,children:[e.flatMap((e,a)=>{let o=e.type===`preview`&&e.isTemp,s=e.id===t;return[f===a?(0,l.jsx)(`div`,{className:Z[`panel-tab-drop-indicator`],"aria-hidden":!0},`drop-${a}`):null,(0,l.jsxs)(`div`,{ref:e=>{u.current[a]=e},className:C(Z,`panel-tab`,s&&`active`,o&&`temp`),onClick:()=>n(e.id),onDoubleClick:t=>{t.preventDefault(),r(e.id)},title:e.path,draggable:!0,onDragStart:e=>g(e,a),onDragEnd:b,children:[(0,l.jsx)(`span`,{className:Z[`panel-tab-label`],children:pi(e)}),i&&(0,l.jsx)(`button`,{type:`button`,className:Z[`panel-tab-close`],onClick:t=>{t.stopPropagation(),i(e.id)},"aria-label":`Close tab`,children:`×`})]},e.id)]}),f===e.length?(0,l.jsx)(`div`,{className:Z[`panel-tab-drop-indicator`],"aria-hidden":!0},`drop-end`):null]}),(0,l.jsx)(`button`,{type:`button`,className:Z[`panel-tab-new`],onClick:a,"aria-label":`New tab`,title:`New tab`,children:`+`})]})}),hi=0;function gi(){return`tab-${++hi}`}function _i(e){return{id:gi(),type:`filelist`,path:e}}function vi(e,t,n,r){return{id:gi(),type:`preview`,path:e,name:t,size:n,isTemp:!0,sourcePanel:r}}var yi=_i(``),bi=_i(``),xi=(0,d.atom)([yi]),Si=(0,d.atom)([bi]),Ci=(0,d.atom)(yi.id),wi=(0,d.atom)(bi.id),Ti=(0,d.atom)(e=>e(xi).findIndex(t=>t.id===e(Ci))),Ei=(0,d.atom)(e=>e(Si).findIndex(t=>t.id===e(wi))),Di=(0,d.atom)(e=>{let t=e(Ci);return e(xi).find(e=>e.id===t)??null}),Oi=(0,d.atom)(e=>{let t=e(wi);return e(Si).find(e=>e.id===t)??null});(0,d.atom)(e=>e(Ne)===`left`?e(xi):e(Si)),(0,d.atom)(e=>e(Ne)===`left`?e(Ci):e(wi)),(0,d.atom)(e=>e(Ne)===`left`?e(Ti):e(Ei)),(0,d.atom)(e=>e(Ne)===`left`?e(Di):e(Oi));var ki=null;function Ai(e){ki=e}function ji(){return ki}function Mi({side:e,panel:t,onRememberExpectedTerminalCwd:n,selectionKey:r,requestedActiveName:i,requestedTopmostName:a,initialPanelState:o,onStateChange:s}){let u=(0,d.useAtomValue)(Ne),f=(0,d.useSetAtom)(Ne),p=u===e,[m,h]=(0,d.useAtom)(e===`left`?xi:Si),[g,_]=(0,d.useAtom)(e===`left`?Ci:wi),v=(0,d.useAtomValue)(e===`left`?Ti:Ei),y=m[v],b=o?.tabs?.[v],x=(0,d.useAtomValue)(Pe),S=(0,c.useMemo)(()=>x?t.entries:t.entries.filter(e=>!e.meta.hidden),[x,t.entries]),w=(0,c.useRef)(t);w.current=t;let T=(0,c.useRef)(m);T.current=m;let E=(0,c.useRef)(g);E.current=g;let D=(0,c.useCallback)(e=>_(e),[_]),O=(0,c.useCallback)(e=>{h(t=>t.map(t=>t.id===e&&t.type===`preview`&&t.isTemp?{...t,isTemp:!1}:t))},[]),k=(0,c.useCallback)(async e=>{let t=T.current;if(t.length>1){let n=t.findIndex(t=>t.id===e),r=t.filter(t=>t.id!==e);E.current===e&&_(r[Math.min(n,r.length-1)]?.id??``),h(r);return}let n=await B().utils.getHomePath(),r=_i(n);h([r]),_(r.id),w.current.navigateTo(n)},[]),A=(0,c.useCallback)((e,t)=>{h(n=>{let r=[...n],[i]=r.splice(e,1);return r.splice(t,0,i),r})},[]),j=(0,c.useCallback)(()=>{let e=w.current.currentPath,t=_i(e);h(e=>[...e,t]),_(t.id),w.current.navigateTo(e)},[h,_]);return(0,c.useEffect)(()=>{if(p)return Ai({newTab:j,closeActiveTab:()=>k(E.current)}),()=>Ai(null)},[p,j,k]),(0,l.jsxs)(`div`,{className:C(Z,`panel`,p&&`active`),onClick:()=>f(e),children:[t.navigating&&(0,l.jsx)(`div`,{className:Z[`panel-progress`]}),(0,l.jsx)(mi,{tabs:m,activeTabId:g,onSelectTab:D,onDoubleClickTab:O,onCloseTab:k,onNewTab:j,onReorderTabs:A}),(0,l.jsx)(`div`,{className:Z[`panel-content`],children:y?.type===`filelist`?(0,l.jsx)(ci,{currentPath:t.currentPath,parentNode:t.parentNode,entries:S,onNavigate:r=>(f(e),n(r),t.navigateTo(r)),selectionKey:r,active:p,resolver:t.resolver,requestedActiveName:i??(b?.type===`filelist`?b.selectedName:void 0),requestedTopmostName:a??(b?.type===`filelist`?b.topmostName:void 0),onStateChange:s},y.id):y?.type===`preview`?(()=>{let e=y;if(e.type!==`preview`)return null;let t=Wt.resolve(e.name);return t?(0,l.jsx)(pn,{extensionDirPath:t.extensionDirPath,entry:t.contribution.entry,filePath:e.path,fileName:e.name,fileSize:e.size,inline:!0,onClose:()=>k(e.id)}):(0,l.jsx)(`div`,{style:{padding:16,color:`var(--fg-muted, #888)`,textAlign:`center`},children:`No viewer extension for this file type. Install viewer extensions from the extensions panel.`})})():null})]})}function Q(e){let t=e.replace(/\\/g,`/`),n=t.match(/^\/([A-Za-z]:(?:\/.*)?)/);return U(n?n[1]:t)}function Ni(e,t){switch(t){case`posix`:return`'`+e.replace(/'/g,`'\\''`)+`'`;case`powershell`:return`'`+e.replace(/'/g,`''`)+`'`;case`cmd`:return`"`+e.replace(/"/g,`""`)+`"`}}function Pi(e,t){let n=Ni(Q(e),t.cwdEscape);return t.hiddenCdTemplate.replace(/\{\{cwd\}\}/g,n)+(t.lineEnding??`
120
+ `,`/`,m.LayerPriority.GLOBAL),zr=[];function Br(e,t){return e.replace(/url\(([^)]+)\)/g,(e,n)=>{let r=n.trim();return r.startsWith(`/`)||/^[A-Za-z]:/.test(r)?e:`url(${G(t,r.replace(/^\.\//,``))})`})}function Vr(e,t){let n=e.filter(e=>e.iconThemeFss!=null&&e.iconThemeBasePath!=null),r=t?n.filter(e=>`${e.ref.publisher}.${e.ref.name}`===t):[];console.log(`[FSS] setExtensionLayers`,{total:e.length,withFss:n.map(e=>`${e.ref.publisher}.${e.ref.name}`),activeIconTheme:t??`(all)`,layersAdded:r.map(e=>`${e.ref.publisher}.${e.ref.name}`)}),zr=r.map(e=>(0,m.createLayer)(Br(e.iconThemeFss,U(e.iconThemeBasePath)),`/`,m.LayerPriority.USER))}var Hr=new Map;function Ur(e){Hr.delete(e)}function Wr(e=`dark`){let t=new m.LayeredResolver;return t.addLayer(Rr),t.setTheme(e),t}async function Gr(e,t,n){let r=[],i=n;for(;;){r.push(i);let e=W(i);if(e===i)break;i=e}for(let t of r)if(K(t)!==`.dotdir`&&!Hr.has(t)){let n=G(t,`.dotdir`);try{Hr.set(t,await St(e,G(n,`fs.css`)))}catch{Hr.set(t,null)}}let a=[Rr,...zr];for(let e of r){let t=Hr.get(e);if(t!=null){let n=e===`/`?0:e.split(`/`).filter(Boolean).length,r=G(e,`.dotdir`);a.push((0,m.createLayer)(Br(t,r),e,m.LayerPriority.nestedPriority(n)))}}t.setLayers(a)}function Kr(e){if(!e)return null;let t=/^url\(([^)]+)\)$/.exec(String(e));return t?t[1]:null}function qr(e,t){let n=e.resolveStyle(t),r=e.resolveSorting(t);return{color:n.color==null?void 0:String(n.color),opacity:n.opacity==null?void 0:Number(n.opacity),fontWeight:n[`font-weight`]==null?void 0:n[`font-weight`],fontStyle:n[`font-style`]==null?void 0:String(n[`font-style`]),fontStretch:n[`font-stretch`]==null?void 0:String(n[`font-stretch`]),fontVariant:n[`font-variant`]==null?void 0:String(n[`font-variant`]),textDecoration:n[`text-decoration`]==null?void 0:String(n[`text-decoration`]),icon:Kr(n.icon),sortPriority:typeof r.priority==`number`?r.priority:0,groupFirst:r[`group-first`]===!0}}function Jr(e){let[t,n]=(0,c.useState)(()=>typeof window>`u`?!1:window.matchMedia(e).matches);return(0,c.useEffect)(()=>{if(typeof window>`u`)return;let t=window.matchMedia(e),r=()=>n(t.matches);return r(),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}var Yr=`_breadcrumbs_15ml8_25`,Xr=`_entry_15ml8_151`,Zr=`_selected_15ml8_166`,Qr=`_marked_15ml8_176`,X={"file-list":`_file-list_15ml8_1`,"active-panel":`_active-panel_15ml8_7`,"path-bar":`_path-bar_15ml8_7`,breadcrumbs:Yr,"is-cropped-left":`_is-cropped-left_15ml8_44`,"is-cropped-right":`_is-cropped-right_15ml8_53`,"breadcrumb-copied-tooltip":`_breadcrumb-copied-tooltip_15ml8_67`,"breadcrumb-segment":`_breadcrumb-segment_15ml8_84`,"breadcrumb-segment-text":`_breadcrumb-segment-text_15ml8_100`,"breadcrumb-separator":`_breadcrumb-separator_15ml8_104`,"file-list-body":`_file-list-body_15ml8_111`,"columns-scroller-root":`_columns-scroller-root_15ml8_117`,"columns-scroller-content":`_columns-scroller-content_15ml8_123`,"columns-borders":`_columns-borders_15ml8_135`,"columns-border":`_columns-border_15ml8_135`,entry:Xr,"no-hover":`_no-hover_15ml8_162`,selected:Zr,"inactive-panel":`_inactive-panel_15ml8_171`,marked:Qr,"entry-icon":`_entry-icon_15ml8_195`,"entry-name":`_entry-name_15ml8_201`,"entry-size":`_entry-size_15ml8_208`,"file-info-footer":`_file-info-footer_15ml8_217`,"file-info-name":`_file-info-name_15ml8_231`,"file-info-link":`_file-info-link_15ml8_238`,"file-info-size":`_file-info-size_15ml8_247`,"file-info-date":`_file-info-date_15ml8_253`,"panel-summary":`_panel-summary_15ml8_259`},$r=(0,c.memo)(function({currentPath:e,onNavigate:t}){let n=(0,c.useRef)(null),r=(0,c.useRef)(!0),i=(0,c.useRef)(!1),[a,o]=(0,c.useState)(!1),[s,u]=(0,c.useState)(!1),[d,f]=(0,c.useState)(!1),p=(0,c.useRef)(null),m=(0,c.useMemo)(()=>yt(e),[e]),h=(0,c.useCallback)((n,r,i)=>{i?navigator.clipboard.writeText(e).then(()=>{p.current&&clearTimeout(p.current),f(!0),p.current=setTimeout(()=>{f(!1),p.current=null},1e3)}):t(n.path)},[e,t]);(0,c.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]);let g=(0,c.useCallback)(()=>{let e=n.current;if(!e)return;let t=Math.max(0,e.scrollWidth-e.clientWidth),r=e.scrollLeft>0,i=e.scrollLeft<t-1;o(e=>e===r?e:r),u(e=>e===i?e:i)},[]),_=(0,c.useCallback)(()=>{let e=n.current;e&&(i.current=!0,e.scrollLeft=e.scrollWidth,queueMicrotask(()=>{i.current=!1}))},[]);if((0,c.useLayoutEffect)(()=>{_(),r.current=!0,g()},[e,_,g]),(0,c.useEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{g()},i=new ResizeObserver(()=>{(r.current||e.scrollLeft>e.scrollWidth-e.clientWidth)&&_(),g()});return i.observe(e),e.addEventListener(`scroll`,t,{passive:!0}),()=>{i.disconnect(),e.removeEventListener(`scroll`,t)}},[_,g]),m.length===0)return null;let v=/^[A-Za-z]:[\\/]/.test(e)||e.includes(`\\`)?`\\`:`/`;return(0,l.jsxs)(`div`,{className:C(X,`breadcrumbs`,a&&`is-cropped-left`,s&&`is-cropped-right`),ref:n,onWheel:e=>{let t=n.current;if(!t)return;let i=Math.max(0,t.scrollWidth-t.clientWidth);r.current=t.scrollLeft+(Math.abs(e.deltaY)>Math.abs(e.deltaX)?e.deltaY:e.deltaX)>=i-1,Math.abs(e.deltaY)>Math.abs(e.deltaX)&&e.deltaY!==0&&(t.scrollLeft+=e.deltaY,e.preventDefault())},children:[m.map((e,t)=>{let n=t===m.length-1;return(0,l.jsxs)(c.Fragment,{children:[(0,l.jsx)(`div`,{className:X[`breadcrumb-segment`],onClick:r=>{r.stopPropagation(),h(e,t,n)},children:(0,l.jsx)(`span`,{className:X[`breadcrumb-segment-text`],children:e.label})}),!n&&e.label!==`/`&&(0,l.jsx)(`span`,{className:X[`breadcrumb-separator`],"aria-hidden":!0,children:v})]},`${t}-${e.path}`)}),d&&(0,l.jsx)(`span`,{className:X[`breadcrumb-copied-tooltip`],role:`status`,children:`Path copied to clipboard`})]})}),ei=({children:e,scrollHeight:t,scrollTop:n,lineSize:r,velocityFactor:i=20,frictionFactor:a=.95,style:o,onScroll:s})=>{let u=(0,c.useRef)(null),d=(0,c.useRef)(n),f=(0,c.useRef)(s),p=Jr(`(pointer: coarse)`);return d.current=n,f.current=s,(0,c.useEffect)(()=>{let e=u.current;if(!e)return;let n,o=0,s=0,c=!1,l=e=>{if(!f.current)return;let n=d.current+e;n=Math.min(n,t),n=Math.max(0,n),d.current!==n&&(d.current=n,f.current(n))},m=navigator.platform.startsWith(`Win`),h=e=>{e.preventDefault(),e.stopPropagation(),l(r&&m?Math.sign(e.deltaY)*r:e.deltaY)},g=e=>{n=e.clientY,o=performance.now(),c=!1,s=0},_=t=>{if(n==null)return;let r=t.clientY,i=n-r;if(Math.abs(i)<3)return;e.setPointerCapture(t.pointerId),l(i),n=r;let a=performance.now(),c=a-o;o=a,c>0&&(s=i/c),t.preventDefault()},v=t=>{if(n==null)return;n=void 0,e.releasePointerCapture(t.pointerId);let r=()=>{Math.abs(s)>.1?(l(s*i),s*=a,requestAnimationFrame(r)):c=!1};c||(c=!0,requestAnimationFrame(r))};return e.addEventListener(`wheel`,h,{passive:!1}),p&&(e.addEventListener(`pointerdown`,g),e.addEventListener(`pointermove`,_),e.addEventListener(`pointerup`,v),e.addEventListener(`pointercancel`,v)),()=>{e.removeEventListener(`wheel`,h),p&&(e.removeEventListener(`pointerdown`,g),e.removeEventListener(`pointermove`,_),e.removeEventListener(`pointerup`,v),e.removeEventListener(`pointercancel`,v))}},[i,a,t,r,p]),(0,l.jsx)(`div`,{style:{overflow:`hidden`,position:`relative`,touchAction:`none`,...o},children:(0,l.jsx)(`div`,{ref:u,style:{position:`absolute`,inset:0,pointerEvents:`auto`},children:e})})};function ti(e){let[t,n]=(0,c.useState)({width:0,height:0});return(0,c.useEffect)(()=>{let t=e.current;if(!t)return;let r=new ResizeObserver(([e])=>{let{width:t,height:r}=e.contentRect;n(e=>e.width===t&&e.height===r?e:{width:t,height:r})});return r.observe(t),()=>r.disconnect()},[e]),t}var ni=(0,c.memo)(function({index:e,isActive:t,isSelected:n,width:r,height:i,renderItem:a}){return(0,l.jsx)(`div`,{style:{width:r,height:i},children:a(e,t,n)})}),ri=(0,c.memo)(function(e){let{topmostIndex:t}=e,{activeIndex:n,totalCount:r,itemHeight:i,minColumnWidth:a,far:o=!1,selectedKeys:s,getItemKey:u,renderItem:d,onPosChange:f,onItemsPerColumnChanged:p,onColumnCountChanged:m}=e;if(!Number.isInteger(i)||i<=0)throw Error(`itemHeight should be positive`);let h=(0,c.useRef)(f),g=(0,c.useRef)(p),_=(0,c.useRef)(m);h.current=f,g.current=p,_.current=m;let v=(0,c.useRef)(null),{width:y,height:b}=ti(v),x=a!=null&&y>0?Math.max(1,Math.floor(y/a)):1,S=Math.max(1,Math.floor(b/i));(0,c.useLayoutEffect)(()=>{g.current?.(S)},[S]),(0,c.useLayoutEffect)(()=>{_.current?.(x)},[x]);let C=e.topmostIndex;n<t?t=n:n>t+x*S-1?t=n-x*S+1:t>r-x*S&&(t=Math.max(0,r-x*S)),(0,c.useEffect)(()=>{t!==C&&h.current?.(t,n)});let w=(0,c.useRef)(t),T=(0,c.useRef)(n);w.current=t,T.current=n;let E=(0,c.useCallback)(e=>{let t=Math.round(e/i),n=t-T.current;if(n){let e=o?w.current+n:w.current;h.current?.(e,t)}},[i,o]),D=Math.min(r,t+S*x),O=`${100/x}%`,k=[];for(let e=t;e<D;e++){let t=u?u(e):e;k.push((0,l.jsx)(ni,{index:e,isActive:n===e,isSelected:s?.has(t)??!1,width:O,height:i,renderItem:d},t))}let A=D-t,j=x-Math.ceil(A/S);for(let e=0;e<j;e++)k.push((0,l.jsx)(`div`,{style:{height:`100%`,width:O}},`empty-${e}`));return(0,l.jsxs)(`div`,{className:X[`columns-scroller-root`],ref:v,children:[(0,l.jsx)(`div`,{className:X[`columns-borders`],style:{gridTemplateColumns:`repeat(${x}, 1fr)`},children:Array.from({length:x},(e,t)=>(0,l.jsx)(`div`,{className:X[`columns-border`]},t))}),(0,l.jsx)(ei,{scrollTop:n*i,scrollHeight:(r-1)*i,lineSize:i,style:{height:`100%`},onScroll:E,children:(0,l.jsx)(`div`,{className:X[`columns-scroller-content`],style:{height:S*i},children:k})})]})}),ii=26;function ai(e){let t;if(typeof e==`number`)t=e;else if(typeof e==`bigint`)t=Number(e);else return``;return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} K`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} M`:`${(t/(1024*1024*1024)).toFixed(1)} G`}function oi(e){if(!e)return``;let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function si(e,t,n){return Math.max(t,Math.min(n,e))}var ci=(0,c.memo)(function({currentPath:e,parentNode:t,entries:n,onNavigate:r,selectionKey:i,active:a,resolver:o,requestedActiveName:s,requestedTopmostName:u,onStateChange:d}){let f=(0,c.useRef)(null),[p,m]=(0,c.useState)(0),[h,g]=(0,c.useState)(0),[_,v]=(0,c.useState)(1),[y,b]=(0,c.useState)(1),[x,S]=(0,c.useState)(0),[w,T]=(0,c.useState)(new Set),[E,D]=(0,c.useState)(!1),O=(0,c.useRef)(E);O.current=E;let k=Jr(`(pointer: coarse)`),A=(0,c.useRef)(w);A.current=w;let j=(0,c.useRef)(void 0),ee=(0,c.useRef)(e),M=(0,c.useRef)([]),N=(0,c.useRef)(p);N.current=p;let te=(0,c.useRef)(h);te.current=h;let ne=(0,c.useRef)(e);ne.current=e;let P=(0,c.useRef)(r);P.current=r;let F=(0,c.useCallback)(()=>{O.current||D(!0)},[]),I=(0,c.useCallback)(()=>{O.current&&D(!1)},[]),L=Pr(),re=(0,c.useCallback)(e=>{if(e)return L(e)??void 0},[L]),ie=Mr(),ae=(0,c.useMemo)(()=>{let e=n.map(e=>{e={...e,parent:t};let n=qr(o,e),r=e.type===`folder`,i=ie(e.name,r,!1,!1,e.lang,n.icon);return{entry:e,style:n,iconPath:i.path,iconFallbackUrl:i.fallbackUrl}});return e.sort((e,t)=>e.style.groupFirst===t.style.groupFirst?e.style.sortPriority===t.style.sortPriority?e.entry.name.localeCompare(t.entry.name):t.style.sortPriority-e.style.sortPriority:e.style.groupFirst?-1:1),e},[n,e]),R=(0,c.useMemo)(()=>{let e=[];if(t){let n={...t,stateFlags:1},r=qr(o,n),i=ie(`..`,!0,!0,!1,``,r.icon);e.push({entry:{...n,name:`..`},style:r,iconPath:i.path,iconFallbackUrl:i.fallbackUrl})}for(let t of ae)e.push(t);return e},[ae,t]),z=(0,c.useRef)(R);z.current=R;let oe=(0,c.useMemo)(()=>{let e=new Set;for(let{iconPath:t}of R)t&&e.add(t);return[...e]},[R]),se=Nr();(0,c.useEffect)(()=>{let e=!1;return se(oe).then(()=>{e||S(e=>e+1)}),()=>{e=!0}},[oe]),(0,c.useEffect)(()=>Ar(()=>{S(e=>e+1)}),[]),(0,c.useEffect)(()=>{let t=ee.current;if(ee.current=e,t===e){m(e=>Math.min(e,R.length-1));return}if(t.startsWith(e)){let n=M.current;for(;n.length>0&&n[n.length-1].path!==e;)n.pop();let r=n.pop();if(r){let e=R.findIndex(e=>e.entry.name===r.selectedName),t=R.findIndex(e=>e.entry.name===r.topmostName);m(e>=0?e:0),g(t>=0?t:0);return}let i=t.slice(e.length).replace(/^\//,``).split(`/`)[0].replace(/\0.*$/,``);if(i){let e=R.findIndex(e=>e.entry.name===i);if(e>=0){m(e),g(Math.max(0,e-5));return}}}m(0),g(0)},[e,R]),(0,c.useEffect)(()=>{if(!s)return;let e=z.current.findIndex(e=>e.entry.name===s);e>=0&&m(e)},[s]),(0,c.useEffect)(()=>{if(!u)return;let e=z.current.findIndex(e=>e.entry.name===u);e>=0&&g(e)},[u]);let ce=(0,c.useRef)(d);ce.current=d;let le=(0,c.useRef)(void 0);(0,c.useEffect)(()=>{ce.current&&(clearTimeout(le.current),le.current=setTimeout(()=>{let e=z.current[N.current]?.entry.name,t=z.current[te.current]?.entry.name;ce.current?.(e,t)},150))},[p,h,R]),(0,c.useEffect)(()=>()=>{if(clearTimeout(le.current),!ce.current)return;let e=z.current[N.current]?.entry.name,t=z.current[te.current]?.entry.name;ce.current(e,t)},[]);let ue=(0,c.useCallback)(e=>{P.current(e)},[]),de=(0,c.useCallback)((e,t,n)=>{let r=z.current;if(j.current===void 0){let t=r[e]?.entry.name;j.current=t?!A.current.has(t):!0}let i=j.current,a=Math.min(e,t),o=Math.max(e,t);T(e=>{let s=new Set(e);for(let e=a;e<=o;e++){if(n===`exclude-active`&&e===t)continue;let a=r[e]?.entry.name;a&&(i?s.add(a):s.delete(a))}return s}),m(si(t,0,r.length-1))},[]);(0,c.useEffect)(()=>{if(!a)return;let e=e=>{!e.shiftKey&&j.current!==void 0&&(j.current=void 0)};return window.addEventListener(`keyup`,e),()=>window.removeEventListener(`keyup`,e)},[a]),(0,c.useEffect)(()=>{T(new Set),j.current=void 0},[e,i]);let fe=(0,c.useCallback)(async e=>{if(e.name===`..`)await P.current(W(ne.current));else if(e.type===`folder`){let t=z.current[N.current]?.entry.name,n=z.current[te.current]?.entry.name;t&&M.current.push({path:ne.current,selectedName:t,topmostName:n??t}),await P.current(G(ne.current,e.name))}else e.type===`file`&&V.executeCommand(`dotdir.viewFile`,e.path,e.name,Number(e.meta.size))},[]),pe=Math.min(R.length,_*y),me=(0,c.useRef)(_);me.current=_;let he=(0,c.useRef)(pe);he.current=pe,(0,c.useEffect)(()=>{g(e=>{let t=_*y;return p<e?p:p>e+t-1?p-t+1:e})},[p,_,y]);let ge=(0,c.useCallback)(()=>{let e=z.current[N.current],t=e?.entry.type===`file`,n=t&&e!=null&&!!e.entry.meta.executable,r=e?.entry.name??``;V.beginBatch(),V.setContext(`listItemIsFile`,t),V.setContext(`listItemIsFolder`,!t&&e!=null),V.setContext(`listItemIsExecutable`,n),V.setContext(`listItemHasViewer`,t&&Kt.resolve(r)!==null),V.setContext(`listItemHasEditor`,t&&qt.resolve(r)!==null),V.endBatch()},[]);(0,c.useEffect)(()=>{a&&ge()},[a,p,R,ge]),(0,c.useEffect)(()=>{if(!a)return;let e=Kt.onChange(ge),t=qt.onChange(ge);return()=>{e(),t()}},[a,ge]),(0,c.useEffect)(()=>{if(a)return At({focus:()=>{f.current?.focus({preventScroll:!0})},cursorUp:()=>Y.enqueue(()=>{F(),m(e=>Math.max(0,e-1))}),cursorDown:()=>Y.enqueue(()=>{F(),m(e=>Math.min(z.current.length-1,e+1))}),cursorLeft:()=>Y.enqueue(()=>{F(),m(e=>Math.max(0,e-me.current))}),cursorRight:()=>Y.enqueue(()=>{F(),m(e=>Math.min(z.current.length-1,e+me.current))}),cursorHome:()=>Y.enqueue(()=>{F(),m(0)}),cursorEnd:()=>Y.enqueue(()=>{F(),m(z.current.length-1)}),cursorPageUp:()=>Y.enqueue(()=>{F(),m(e=>Math.max(0,e-he.current+1))}),cursorPageDown:()=>Y.enqueue(()=>{F(),m(e=>Math.min(z.current.length-1,e+he.current-1))}),selectUp:()=>Y.enqueue(()=>{F();let e=N.current;de(e,Math.max(0,e-1),e===0?`include-active`:`exclude-active`)}),selectDown:()=>Y.enqueue(()=>{F();let e=N.current,t=z.current.length-1;de(e,Math.min(t,e+1),e===t?`include-active`:`exclude-active`)}),selectLeft:()=>Y.enqueue(()=>{F();let e=N.current;de(e,Math.max(0,e-me.current),`include-active`)}),selectRight:()=>Y.enqueue(()=>{F();let e=N.current;de(e,Math.min(z.current.length-1,e+me.current),`include-active`)}),selectHome:()=>Y.enqueue(()=>{F(),de(N.current,0,`include-active`)}),selectEnd:()=>Y.enqueue(()=>{F(),de(N.current,z.current.length-1,`include-active`)}),selectPageUp:()=>Y.enqueue(()=>{F();let e=N.current;de(e,Math.max(0,e-he.current+1),`include-active`)}),selectPageDown:()=>Y.enqueue(()=>{F();let e=N.current;de(e,Math.min(z.current.length-1,e+he.current-1),`include-active`)}),execute:()=>Y.enqueue(async()=>{let e=z.current[N.current];!e||e.entry.type!==`file`||e.entry.meta.executable&&V.executeCommand(`terminal.execute`,e.entry.path)}),open:()=>Y.enqueue(async()=>{let e=z.current[N.current];e&&await fe(e.entry)}),viewFile:()=>Y.enqueue(()=>{let e=z.current[N.current];e&&e.entry.type===`file`&&V.executeCommand(`dotdir.viewFile`,e.entry.path,e.entry.name,Number(e.entry.meta.size))}),editFile:()=>Y.enqueue(()=>{let e=z.current[N.current];if(e&&e.entry.type===`file`){let t=typeof e.entry.lang==`string`&&e.entry.lang?e.entry.lang:`plaintext`;V.executeCommand(`dotdir.editFile`,e.entry.path,e.entry.name,Number(e.entry.meta.size),t)}}),moveToTrash:()=>Y.enqueue(()=>{let e=Lr();if(!e)return;let t=A.current,n=z.current,r=()=>P.current(ne.current),i=t.size>0?n.filter(e=>t.has(e.entry.name)).map(e=>e.entry.path):(()=>{let e=n[N.current];return e?[e.entry.path]:[]})();i.length!==0&&e.moveToTrash(i,r)}),permanentDelete:()=>Y.enqueue(()=>{let e=Lr();if(!e)return;let t=A.current,n=z.current,r=()=>P.current(ne.current),i=t.size>0?n.filter(e=>t.has(e.entry.name)).map(e=>e.entry.path):(()=>{let e=n[N.current];return e?[e.entry.path]:[]})();i.length!==0&&e.permanentDelete(i,r)}),copy:()=>Y.enqueue(()=>{let e=Lr();if(!e)return;let t=A.current,n=z.current,r=()=>P.current(ne.current),i=t.size>0?n.filter(e=>t.has(e.entry.name)).map(e=>e.entry.path):(()=>{let e=n[N.current];return e?[e.entry.path]:[]})();i.length!==0&&e.copy(i,r)}),move:()=>Y.enqueue(()=>{let e=Lr();if(!e)return;let t=A.current,n=z.current,r=()=>P.current(ne.current),i=t.size>0?n.filter(e=>t.has(e.entry.name)).map(e=>e.entry.path):(()=>{let e=n[N.current];return e?[e.entry.path]:[]})();i.length!==0&&e.move(i,r)}),rename:()=>Y.enqueue(()=>{let e=Lr();if(!e)return;let t=z.current[N.current];t&&e.rename(t.entry.path,t.entry.name,()=>P.current(ne.current))}),pasteFilename:()=>Y.enqueue(()=>{let e=z.current[N.current];if(!e)return;let t=Lr();if(!t)return;let n=e.entry.name,r=/^[a-zA-Z0-9._+-]+$/.test(n)?n:JSON.stringify(n);t.pasteToCommandLine(r)}),pastePath:()=>Y.enqueue(()=>{let e=z.current[N.current];if(!e)return;let t=Lr();if(!t)return;let n=(e.entry.path??``).split(`\0`)[0],r=/^[a-zA-Z0-9._+/:-]+$/.test(n)?n:JSON.stringify(n);t.pasteToCommandLine(r)})}),()=>At(null)},[a,F,fe,de]);let _e=(0,c.useRef)(y);_e.current=y;let ve=(0,c.useCallback)(e=>{v(e),g(t=>Math.max(0,Math.min(t,z.current.length-e*_e.current)))},[]),B=(0,c.useCallback)(e=>{b(e)},[]),ye=(0,c.useCallback)((e,t)=>{let n=z.current.length;m(si(t,0,n-1)),g(si(e,0,n-1))},[]),be=(0,c.useCallback)(e=>z.current[e]?.entry.name??e,[]),xe=(0,c.useRef)(0),Se=(0,c.useCallback)((e,t,n)=>{let r=z.current[e];if(!r)return null;let{entry:i,style:a,iconPath:o,iconFallbackUrl:s}=r,c=re(o)??s,u=i.type===`file`&&!!i.meta.executable;return(0,l.jsxs)(`div`,{className:C(X,`entry`,t&&`selected`,n&&`marked`),style:{height:ii,opacity:a.opacity},onMouseDown:t=>{t.stopPropagation(),I();let n=Date.now();n-xe.current<300?(xe.current=0,u?Y.enqueue(()=>V.executeCommand(`terminal.execute`,i.path)):Y.enqueue(()=>fe(i))):(xe.current=n,Y.enqueue(()=>m(e)))},children:[(0,l.jsx)(`span`,{className:X[`entry-icon`],children:(0,l.jsx)(`img`,{src:c,width:16,height:16,alt:``})}),(0,l.jsx)(`span`,{className:X[`entry-name`],style:{color:a.color,fontWeight:a.fontWeight,fontStyle:a.fontStyle,fontStretch:a.fontStretch,fontVariant:a.fontVariant,textDecoration:a.textDecoration},children:i.name}),`size`in i.meta&&i.type===`file`&&(0,l.jsx)(`span`,{className:X[`entry-size`],children:ai(i.meta.size)})]})},[fe,x,I]),Ce=R[p],we=Ce?.entry.name??``,Te=Ce?oi(Number(Ce.entry.meta.mtimeMs??0)):``,Ee=(()=>{if(!Ce)return``;let e=Ce.entry;if(e.name===`..`)return`Up`;let t=e.meta.entryKind??(e.type===`folder`?`directory`:`file`),n=e.meta.nlink??1;switch(t){case`directory`:return n>1?`DIR [${n}]`:`DIR`;case`symlink`:return``;case`block_device`:return`BLK DEV`;case`char_device`:return`CHR DEV`;case`named_pipe`:return`FIFO`;case`socket`:return`SOCK`;case`whiteout`:return`WHT`;case`door`:return`DOOR`;case`event_port`:return`EVT PORT`;case`unknown`:return`?`;default:{let t=ai(e.meta.size);return n>1?`${t} [${n}]`:t}}})(),De=!Ce||(Ce.entry.meta.entryKind??``)!==`symlink`?``:`\u2192 ${Ce.entry.meta.linkTarget??`?`}`,Oe=(0,c.useMemo)(()=>R.filter(e=>e.entry.type===`file`).length,[R]),ke=(0,c.useMemo)(()=>R.reduce((e,t)=>t.entry.type===`file`&&typeof t.entry.meta.size==`number`?e+t.entry.meta.size:e,0),[R]),Ae=(0,c.useMemo)(()=>{if(w.size===0)return null;let e=0,t=0;for(let n of R)w.has(n.entry.name)&&(e++,n.entry.type===`file`&&typeof n.entry.meta.size==`number`&&(t+=n.entry.meta.size));return{count:e,size:t}},[w,R]);return(0,l.jsxs)(`div`,{ref:f,tabIndex:0,className:C(X,`file-list`,k||E?`no-hover`:null,a?`active-panel`:`inactive-panel`),onMouseMoveCapture:I,onMouseDownCapture:()=>{I(),f.current?.focus({preventScroll:!0})},children:[(0,l.jsx)(`div`,{className:X[`path-bar`],children:(0,l.jsx)($r,{currentPath:e,onNavigate:ue})}),(0,l.jsx)(`div`,{className:X[`file-list-body`],children:(0,l.jsx)(ri,{topmostIndex:h,activeIndex:p,totalCount:R.length,itemHeight:ii,minColumnWidth:250,far:!0,selectedKeys:w,getItemKey:be,renderItem:Se,onPosChange:ye,onItemsPerColumnChanged:ve,onColumnCountChanged:B})}),(0,l.jsxs)(`div`,{className:X[`file-info-footer`],children:[(0,l.jsx)(`span`,{className:X[`file-info-name`],children:we}),De&&(0,l.jsx)(`span`,{className:X[`file-info-link`],children:De}),(0,l.jsx)(`span`,{className:X[`file-info-size`],children:Ee}),(0,l.jsx)(`span`,{className:X[`file-info-date`],children:Te})]}),(0,l.jsx)(`div`,{className:X[`panel-summary`],children:Ae?`${Ae.count} selected, ${ai(Ae.size)}`:`${Oe.toLocaleString()} file${Oe===1?``:`s`}, ${ai(ke)}`})]})}),li=`_hidden_1i903_12`,ui=`_panel_1i903_1`,di=`_active_1i903_33`,fi=`_temp_1i903_123`,Z={"panels-overlay":`_panels-overlay_1i903_1`,hidden:li,panel:ui,active:di,"panel-progress":`_panel-progress_1i903_37`,"progress-slide":`_progress-slide_1i903_1`,"panel-tabs":`_panel-tabs_1i903_67`,"panel-tabs-list":`_panel-tabs-list_1i903_77`,"panel-tab":`_panel-tab_1i903_67`,"panel-tab-label":`_panel-tab-label_1i903_106`,temp:fi,"panel-tab-close":`_panel-tab-close_1i903_127`,"panel-tab-new":`_panel-tab-new_1i903_147`,"panel-tab-dragging":`_panel-tab-dragging_1i903_166`,"panel-tab-drop-indicator":`_panel-tab-drop-indicator_1i903_170`,"panel-content":`_panel-content_1i903_180`};function pi(e){return e.type===`filelist`?K(e.path)||e.path||`File list`:e.name}var mi=(0,c.memo)(function({tabs:e,activeTabId:t,onSelectTab:n,onDoubleClickTab:r,onCloseTab:i,onNewTab:a,onReorderTabs:o}){let s=(0,c.useRef)(null),u=(0,c.useRef)([]),d=(0,c.useRef)(null),[f,p]=(0,c.useState)(null);u.current=e.map((e,t)=>u.current[t]??null);let m=(0,c.useCallback)(e=>{let t=s.current;t&&(t.scrollLeft+=e.deltaY===0?e.deltaX:e.deltaY)},[]),h=(0,c.useCallback)(e=>{if(!s.current)return null;let t=u.current;for(let n=0;n<t.length;n++){let r=t[n];if(!r)continue;let i=r.getBoundingClientRect();if(e<i.left+i.width/2)return n}return t.length},[]),g=(0,c.useCallback)((e,t)=>{d.current=t,e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,String(t)),e.dataTransfer.setDragImage(new Image,0,0),requestAnimationFrame(()=>{e.target.classList.add(Z[`panel-tab-dragging`])})},[]),_=(0,c.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`,p(h(e.clientX))},[h]),v=(0,c.useCallback)(e=>{e.preventDefault();let t=d.current,n=h(e.clientX);t!=null&&n!=null&&o&&(n>t?o(t,n-1):n<t&&o(t,n)),d.current=null,p(null)},[h,o]),y=(0,c.useCallback)(e=>{s.current?.contains(e.relatedTarget)||p(null)},[]),b=(0,c.useCallback)(e=>{e.target.classList.remove(Z[`panel-tab-dragging`]),d.current=null,p(null)},[]);return(0,c.useEffect)(()=>{let e=s.current;if(!e)return;let t=e=>e.preventDefault();return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]),(0,l.jsxs)(`div`,{className:Z[`panel-tabs`],children:[(0,l.jsxs)(`div`,{className:Z[`panel-tabs-list`],ref:s,onWheel:m,onDragOver:_,onDrop:v,onDragLeave:y,children:[e.flatMap((e,a)=>{let o=e.type===`preview`&&e.isTemp,s=e.id===t;return[f===a?(0,l.jsx)(`div`,{className:Z[`panel-tab-drop-indicator`],"aria-hidden":!0},`drop-${a}`):null,(0,l.jsxs)(`div`,{ref:e=>{u.current[a]=e},className:C(Z,`panel-tab`,s&&`active`,o&&`temp`),onClick:()=>n(e.id),onDoubleClick:t=>{t.preventDefault(),r(e.id)},title:e.path,draggable:!0,onDragStart:e=>g(e,a),onDragEnd:b,children:[(0,l.jsx)(`span`,{className:Z[`panel-tab-label`],children:pi(e)}),i&&(0,l.jsx)(`button`,{type:`button`,className:Z[`panel-tab-close`],onClick:t=>{t.stopPropagation(),i(e.id)},"aria-label":`Close tab`,children:`×`})]},e.id)]}),f===e.length?(0,l.jsx)(`div`,{className:Z[`panel-tab-drop-indicator`],"aria-hidden":!0},`drop-end`):null]}),(0,l.jsx)(`button`,{type:`button`,className:Z[`panel-tab-new`],onClick:a,"aria-label":`New tab`,title:`New tab`,children:`+`})]})}),hi=0;function gi(){return`tab-${++hi}`}function _i(e){return{id:gi(),type:`filelist`,path:e}}function vi(e,t,n,r){return{id:gi(),type:`preview`,path:e,name:t,size:n,isTemp:!0,sourcePanel:r}}var yi=_i(``),bi=_i(``),xi=(0,d.atom)([yi]),Si=(0,d.atom)([bi]),Ci=(0,d.atom)(yi.id),wi=(0,d.atom)(bi.id),Ti=(0,d.atom)(e=>e(xi).findIndex(t=>t.id===e(Ci))),Ei=(0,d.atom)(e=>e(Si).findIndex(t=>t.id===e(wi))),Di=(0,d.atom)(e=>{let t=e(Ci);return e(xi).find(e=>e.id===t)??null}),Oi=(0,d.atom)(e=>{let t=e(wi);return e(Si).find(e=>e.id===t)??null});(0,d.atom)(e=>e(Ne)===`left`?e(xi):e(Si)),(0,d.atom)(e=>e(Ne)===`left`?e(Ci):e(wi)),(0,d.atom)(e=>e(Ne)===`left`?e(Ti):e(Ei)),(0,d.atom)(e=>e(Ne)===`left`?e(Di):e(Oi));var ki=null;function Ai(e){ki=e}function ji(){return ki}function Mi({side:e,panel:t,onRememberExpectedTerminalCwd:n,selectionKey:r,requestedActiveName:i,requestedTopmostName:a,initialPanelState:o,onStateChange:s}){let u=(0,d.useAtomValue)(Ne),f=(0,d.useSetAtom)(Ne),p=u===e,[m,h]=(0,d.useAtom)(e===`left`?xi:Si),[g,_]=(0,d.useAtom)(e===`left`?Ci:wi),v=(0,d.useAtomValue)(e===`left`?Ti:Ei),y=m[v],b=o?.tabs?.[v],x=(0,d.useAtomValue)(Pe),S=(0,c.useMemo)(()=>x?t.entries:t.entries.filter(e=>!e.meta.hidden),[x,t.entries]),w=(0,c.useRef)(t);w.current=t;let T=(0,c.useRef)(m);T.current=m;let E=(0,c.useRef)(g);E.current=g;let D=(0,c.useCallback)(e=>_(e),[_]),O=(0,c.useCallback)(e=>{h(t=>t.map(t=>t.id===e&&t.type===`preview`&&t.isTemp?{...t,isTemp:!1}:t))},[]),k=(0,c.useCallback)(async e=>{let t=T.current;if(t.length>1){let n=t.findIndex(t=>t.id===e),r=t.filter(t=>t.id!==e);E.current===e&&_(r[Math.min(n,r.length-1)]?.id??``),h(r);return}let n=await B().utils.getHomePath(),r=_i(n);h([r]),_(r.id),w.current.navigateTo(n)},[]),A=(0,c.useCallback)((e,t)=>{h(n=>{let r=[...n],[i]=r.splice(e,1);return r.splice(t,0,i),r})},[]),j=(0,c.useCallback)(()=>{let e=w.current.currentPath,t=_i(e);h(e=>[...e,t]),_(t.id),w.current.navigateTo(e)},[h,_]);return(0,c.useEffect)(()=>{if(p)return Ai({newTab:j,closeActiveTab:()=>k(E.current)}),()=>Ai(null)},[p,j,k]),(0,l.jsxs)(`div`,{className:C(Z,`panel`,p&&`active`),onClick:()=>f(e),children:[t.navigating&&(0,l.jsx)(`div`,{className:Z[`panel-progress`]}),(0,l.jsx)(mi,{tabs:m,activeTabId:g,onSelectTab:D,onDoubleClickTab:O,onCloseTab:k,onNewTab:j,onReorderTabs:A}),(0,l.jsx)(`div`,{className:Z[`panel-content`],children:y?.type===`filelist`?(0,l.jsx)(ci,{currentPath:t.currentPath,parentNode:t.parentNode,entries:S,onNavigate:r=>(f(e),n(r),t.navigateTo(r)),selectionKey:r,active:p,resolver:t.resolver,requestedActiveName:i??(b?.type===`filelist`?b.selectedName:void 0),requestedTopmostName:a??(b?.type===`filelist`?b.topmostName:void 0),onStateChange:s},y.id):y?.type===`preview`?(()=>{let e=y;if(e.type!==`preview`)return null;let t=Kt.resolve(e.name);return t?(0,l.jsx)(pn,{extensionDirPath:t.extensionDirPath,entry:t.contribution.entry,filePath:e.path,fileName:e.name,fileSize:e.size,inline:!0,onClose:()=>k(e.id)}):(0,l.jsx)(`div`,{style:{padding:16,color:`var(--fg-muted, #888)`,textAlign:`center`},children:`No viewer extension for this file type. Install viewer extensions from the extensions panel.`})})():null})]})}function Q(e){let t=e.replace(/\\/g,`/`),n=t.match(/^\/([A-Za-z]:(?:\/.*)?)/);return U(n?n[1]:t)}function Ni(e,t){switch(t){case`posix`:return`'`+e.replace(/'/g,`'\\''`)+`'`;case`powershell`:return`'`+e.replace(/'/g,`''`)+`'`;case`cmd`:return`"`+e.replace(/"/g,`""`)+`"`}}function Pi(e,t){let n=Ni(Q(e),t.cwdEscape);return t.hiddenCdTemplate.replace(/\{\{cwd\}\}/g,n)+(t.lineEnding??`
121
121
  `)}function Fi(){return{background:`#11131a`,foreground:`#d7dae0`,cursor:`#f5f7ff`,selectionBackground:`rgba(128, 146, 255, 0.28)`}}function Ii({session:e,expanded:t=!1,focusRequestKey:n=0}){let r=(0,c.useRef)(null),i=(0,c.useRef)(null),a=(0,c.useRef)(null),o=(0,c.useRef)(null),s=(0,c.useRef)(!1),u=(0,c.useRef)(!1),d=(0,c.useRef)(t);d.current=t;let f=(0,c.useRef)({w:0,h:0});return(0,c.useEffect)(()=>{f.current={w:0,h:0};let t=r.current;if(!t)return;let n=new h.FitAddon,c=new g.Terminal({allowProposedApi:!0,cursorBlink:!1,fontSize:13,fontFamily:`Menlo, Monaco, "Courier New", monospace`,scrollOnUserInput:!0,scrollback:1e3,cursorStyle:`bar`,cursorInactiveStyle:`none`,theme:Fi()}),l=()=>{i.current!==null&&cancelAnimationFrame(i.current),i.current=requestAnimationFrame(()=>{i.current=null;let r=t.parentElement;if(!r||r.clientWidth<20||r.clientHeight<20)return;let a=r.clientWidth,o=r.clientHeight,s=f.current;s.w===a&&s.h===o||(f.current={w:a,h:o},n.fit(),e.resize(Math.max(2,c.cols),Math.max(1,c.rows)))})},p=t=>{t&&(e.setOscHooksSuppressed(!0),u.current=!0,c.write(t,()=>{u.current=!1,e.setOscHooksSuppressed(!1)}))},m=()=>{let t=e.getReplayData();c.reset(),p(t)};c.loadAddon(n),c.open(t),a.current=c;let _=[c.parser.registerOscHandler(7,t=>{let n=t.match(/^file:\/\/[^/]*(\/.*)/);if(!n)return!1;let r=Q(decodeURIComponent(n[1]));return e.notifyOsc7FromXterm(r),!0}),c.parser.registerOscHandler(779,t=>(e.notifyDotDirPromptOsc(t),!0))];o.current=n;let y=()=>{s.current||!d.current||(s.current=!0,v.push(`terminal`))},b=()=>{s.current&&(s.current=!1,v.pop(`terminal`))};c.attachCustomKeyEventHandler(e=>(y(),!(e.key.toLowerCase()===`o`&&e.ctrlKey&&!e.metaKey&&!e.shiftKey&&!e.altKey))),l(),m();let x=e.subscribe(e=>{e.type===`data`?(c.write(e.data),c.scrollToBottom(),l()):e.type===`status`&&e.status===`error`&&e.error?(c.write(`\r\n[Terminal error: ${e.error}]\r\n`),c.scrollToBottom(),l()):e.type===`status`&&e.status===`exited`?(c.write(`\r
122
122
  [Process exited]\r
123
123
  `),c.scrollToBottom(),l()):e.type===`capabilities`&&l()}),S=c.onData(t=>{u.current||(c.scrollToBottom(),e.write(t))}),C=c.onResize(({cols:t,rows:n})=>{e.resize(Math.max(2,t),Math.max(1,n))}),w=new ResizeObserver(e=>{let t=e[0];if(!t)return;let{width:n,height:r}=t.contentRect;if(n<20||r<20)return;let i=f.current;i.w===n&&i.h===r||l()});w.observe(t.parentElement??t);let T=()=>{y(),c.focus()},E=()=>{y()},D=e=>{let n=e.relatedTarget;n instanceof Node&&t.contains(n)||b()};return t.addEventListener(`pointerdown`,T),t.addEventListener(`focusin`,E),t.addEventListener(`focusout`,D),l(),()=>{t.removeEventListener(`pointerdown`,T),t.removeEventListener(`focusin`,E),t.removeEventListener(`focusout`,D),b(),w.disconnect(),C.dispose(),S.dispose(),x();for(let e of _)e.dispose();i.current!==null&&cancelAnimationFrame(i.current),a.current=null,o.current=null,c.dispose()}},[e]),(0,c.useEffect)(()=>{let e=a.current;!e||!t||(s.current||(s.current=!0,v.push(`terminal`)),e.focus())},[t,n]),(0,c.useEffect)(()=>{let n=a.current,r=o.current;!n||!r||(i.current!==null&&cancelAnimationFrame(i.current),i.current=requestAnimationFrame(()=>{i.current=null;let a=e.getReplayData();a&&(n.clear(),e.setOscHooksSuppressed(!0),u.current=!0,n.write(a,()=>{u.current=!1,e.setOscHooksSuppressed(!1)})),r.fit(),e.resize(Math.max(2,n.cols),Math.max(1,n.rows)),t&&n.scrollToBottom(),t?(s.current||(s.current=!0,v.push(`terminal`)),n.focus()):s.current?(s.current=!1,v.pop(`terminal`),n.blur()):n.blur()}))},[t]),(0,l.jsx)(`div`,{ref:r,className:H[`terminal-container`]})}var Li=(0,d.atom)([]),Ri=(0,d.atom)(null),zi=class e{static replayLimit=64*1024;listeners=new Set;decoder=new TextDecoder;initialCwd;ptyId=null;currentCwd;status=`idle`;capabilities;launchInfo=null;replayData=``;inputBuffer=``;activeCommand=null;suppressNextCommandFinish=!1;cleanupData=null;cleanupExit=null;pendingCwdSync=null;profile;oscHooksSuppressed=!1;constructor(e,t,n){this.bridge=e;let r=Q(t);this.initialCwd=r,this.profile=n,this.currentCwd=r,this.capabilities={cwd:r,profileId:n.id,hasOsc7Cwd:!1,hasDotDirOsc:!1,promptReady:!1,commandRunning:!1,lastCommand:null}}subscribe(e){return this.listeners.add(e),this.launchInfo&&e({type:`launch`,launch:this.launchInfo}),e({type:`status`,status:this.status}),e({type:`capabilities`,capabilities:this.capabilities}),this.replayData&&e({type:`data`,data:this.replayData}),()=>{this.listeners.delete(e)}}getCapabilities(){return this.capabilities}getReplayData(){return this.replayData}setOscHooksSuppressed(e){this.oscHooksSuppressed=e}notifyOsc7FromXterm(e){this.oscHooksSuppressed||this.applyCwdUpdate(Q(e),this.capabilities.commandRunning)}notifyDotDirPromptOsc(e){if(this.oscHooksSuppressed)return;let t=e.replace(/^;/,``).trimStart();if(t.startsWith(`S`)){this.suppressNextCommandFinish||(this.capabilities.hasDotDirOsc||(this.capabilities={...this.capabilities,hasDotDirOsc:!0}),this.capabilities.commandRunning||(this.capabilities={...this.capabilities,commandRunning:!0,promptReady:!1}),this.emitCapabilities());return}t.startsWith(`F`)&&(this.capabilities.hasDotDirOsc||(this.capabilities={...this.capabilities,hasDotDirOsc:!0},this.emitCapabilities()),this.finishCommand())}async start(){if(!(this.ptyId!==null||this.status===`starting`)){this.setStatus(`starting`);try{let e=await this.bridge.pty.spawn(this.initialCwd,this.profile.shell,{spawnArgs:this.profile.spawnArgs.length>0?this.profile.spawnArgs:void 0});this.acceptLaunch(e),this.cleanupData=this.bridge.pty.onData((e,t)=>{e===this.ptyId&&this.handleData(typeof t==`string`?t:this.decoder.decode(t,{stream:!0}))}),this.cleanupExit=this.bridge.pty.onExit(e=>{e===this.ptyId&&(this.activeCommand&&this.emit({type:`command-finish`,command:this.activeCommand}),this.activeCommand=null,this.capabilities={...this.capabilities,commandRunning:!1,promptReady:!1},this.emitCapabilities(),this.ptyId=null,this.setStatus(`exited`))})}catch(e){let t=e instanceof Error?e.message:String(e);throw this.setStatus(`error`,t),e}}}async write(e){this.ptyId!==null&&(this.consumeUserInput(e),await this.bridge.pty.write(this.ptyId,e))}async writeHidden(e){this.ptyId!==null&&(this.suppressNextCommandFinish=!0,await this.bridge.pty.write(this.ptyId,e))}async resize(e,t){this.ptyId!==null&&await this.bridge.pty.resize(this.ptyId,Math.max(2,e),Math.max(1,t))}async syncToCwd(e){let t=Q(e);if(!(this.ptyId===null||t===this.currentCwd)){if(this.capabilities.commandRunning||this.inputBuffer.length>0&&v.is(`terminal`)){this.pendingCwdSync=t;return}this.pendingCwdSync=null,await this.writeHidden(Pi(t,this.profile))}}async refreshPrompt(){this.ptyId!==null&&(this.capabilities.commandRunning||await this.bridge.pty.write(this.ptyId,`\r`))}async dispose(){if(this.cleanupData?.(),this.cleanupData=null,this.cleanupExit?.(),this.cleanupExit=null,this.pendingCwdSync=null,this.ptyId!==null){let e=this.ptyId;this.ptyId=null,await this.bridge.pty.close(e)}}acceptLaunch(e){let t=Q(e.cwd);this.launchInfo=e,this.ptyId=e.ptyId,this.currentCwd=t,this.capabilities={...this.capabilities,cwd:t,profileId:this.profile.id},this.emit({type:`launch`,launch:e}),this.emitCapabilities(),this.setStatus(`running`)}handleData(e){this.appendVisibleData(e)}appendVisibleData(t){t&&(this.replayData=(this.replayData+t).slice(-e.replayLimit),this.emit({type:`data`,data:t}))}finishCommand(){if(this.suppressNextCommandFinish){this.suppressNextCommandFinish=!1;return}this.activeCommand&&this.emit({type:`command-finish`,command:this.activeCommand}),this.activeCommand=null,this.capabilities={...this.capabilities,commandRunning:!1,promptReady:!0},this.emitCapabilities(),this.flushPendingCwdSync()}applyCwdUpdate(e,t){let n=Q(e);n!==this.currentCwd&&(this.currentCwd=n,this.capabilities={...this.capabilities,cwd:n,hasOsc7Cwd:!0},this.emit({type:`cwd`,cwd:n,userInitiated:t}),this.emitCapabilities())}consumeUserInput(e){for(let t of e)if(t===`\r`||t===`
@@ -127,4 +127,4 @@ folder { font-weight: bold; }
127
127
  `;await n.session.write(e+i)},[]),dispose:(0,c.useCallback)(()=>{for(let e of a.current)e.session.dispose();n([]),i(null)},[n,i])}}function qi(){let e=(0,d.useAtomValue)(De),t=(0,d.useAtomValue)(Oe),{sessions:n,activeSessionId:r,activeSession:i,activate:a,createSession:o,closeSession:s,switchActiveProfile:c}=Ki(),u=i?.profileId??null,f=i?e.find(e=>e.id===i.profileId)?.shell??null:null,p=i?.error??null;return(0,l.jsxs)(`div`,{className:H[`terminal-toolbar`],children:[(0,l.jsxs)(`div`,{className:H[`terminal-tabs`],children:[n.map(e=>(0,l.jsxs)(`button`,{type:`button`,className:C(H,`terminal-tab`,e.id===r&&`active`),onClick:()=>a(e.id),children:[(0,l.jsx)(`span`,{className:C(H,`terminal-tab-status`,`status-${e.status}`)}),(0,l.jsx)(`span`,{className:H[`terminal-tab-label`],children:e.profileLabel}),n.length>1&&(0,l.jsx)(`span`,{className:H[`terminal-tab-close`],onClick:t=>{t.stopPropagation(),s(e.id)},children:`x`})]},e.id)),(0,l.jsx)(`button`,{type:`button`,className:C(H,`terminal-tab`,`terminal-tab-add`),onClick:()=>o(u??e[0]?.id),children:`+`})]}),(0,l.jsxs)(`label`,{className:H[`terminal-profile-picker`],children:[(0,l.jsx)(`span`,{className:H[`terminal-profile-label`],children:`Shell`}),(0,l.jsx)(`select`,{value:u??``,disabled:!t||e.length===0||!r,onChange:e=>c(e.target.value),children:e.map(e=>(0,l.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),r&&(0,l.jsx)(`div`,{className:H[`terminal-profile-shell`],children:f??``}),p&&(0,l.jsx)(`div`,{className:H[`terminal-status-error`],children:p})]})}function Ji(){let{activeSession:e}=Ki(),t=(0,d.useAtomValue)(Ae),n=(0,d.useAtomValue)(je);return(0,l.jsx)(`div`,{className:H[`terminal-panel`],children:(0,l.jsx)(`div`,{className:H[`terminal-body`],children:e?(0,l.jsx)(Ii,{session:e.session,expanded:!t,focusRequestKey:n},e.id):(0,l.jsx)(`div`,{className:H[`terminal-loading`],children:`Loading terminal...`})})})}var Yi={left:`right`,right:`left`},Xi={left:`leftPanel`,right:`rightPanel`},Zi=[`left`,`right`];function Qi(e,t){return e?e.some(e=>e===t||e===`darwin`&&t===`macos`||e===`unix`&&(t===`macos`||t===`linux`)):!0}function $i(e,t){return e.replace(/\$([A-Za-z_][A-Za-z0-9_]*)/g,(e,n)=>t[n]??``)}function ea(e){let t=e.toLowerCase();return t===`cmd`?{hiddenCdTemplate:`@cd /d {{cwd}}`,cwdEscape:`cmd`,lineEnding:`\r
128
128
  `,spawnArgs:[]}:t===`powershell`||t===`pwsh`?{hiddenCdTemplate:`Set-Location -LiteralPath {{cwd}}`,cwdEscape:`powershell`,lineEnding:`\r
129
129
  `,spawnArgs:[]}:{hiddenCdTemplate:`cd {{cwd}}`,cwdEscape:`posix`,lineEnding:`
130
- `,spawnArgs:[]}}function ta(e,t,n){let r=ea(n.shell);return{id:e,label:t,shell:e,hiddenCdTemplate:n.hiddenCdTemplate??r.hiddenCdTemplate,cwdEscape:n.cwdEscape??r.cwdEscape,lineEnding:n.lineEnding??r.lineEnding,spawnArgs:n.spawnArgs??r.spawnArgs}}async function na(e,t,n){let r=n.__platform__??``,i=n.SHELL??``,a=[],o={},s=new Set,c=[];for(let e of t)for(let t of e.shellIntegrations??[])Qi(t.platforms,r)&&c.push(t);if(i&&r!==`windows`){let t=i.split(`/`).pop()??``,n=c.find(e=>e.shell===t);if(n&&!s.has(i))try{await e.fs.exists(i)&&(s.add(i),a.push(ta(i,n.label,n)),o[i]={script:n.script,scriptArg:n.scriptArg??!1})}catch{}}for(let t of c)for(let r of t.executableCandidates){let i=$i(r,n);if(!(!i||s.has(i)))try{if(await e.fs.exists(i)){s.add(i),a.push(ta(i,t.label,t)),o[i]={script:t.script,scriptArg:t.scriptArg??!1};break}}catch{}}return{profiles:a,shellScripts:o}}function ra({settingsLoaded:e,onRefreshPanels:t}){let n=B(),r=bn(),i=(0,d.useAtomValue)(Ce),a=(0,d.useAtomValue)(we),o=(0,d.useAtomValue)(ke),s=(0,d.useSetAtom)(Te),l=(0,d.useSetAtom)(Ee),u=(0,d.useSetAtom)(De),f=(0,d.useSetAtom)(Oe),{setIconTheme:p}=Or(),{setIconThemeKind:m}=kr(),h=(0,c.useRef)(i);h.current=i;let g=(0,c.useRef)(a);g.current=a;let _=(0,c.useRef)(t);_.current=t;let v=(0,c.useRef)([]),y=(0,c.useRef)([]),b=(0,c.useRef)(!1);(0,c.useEffect)(()=>{let e=a?Ln(v.current,a):null,t=e?on(e.theme.uiTheme):o===`light`||o===`high-contrast-light`?`light`:`dark`;jt().dataset.theme=t,m(t)},[o,a]);let x=(0,c.useCallback)(async(e,t)=>{if(!t)return;let r=e.find(e=>`${e.ref.publisher}.${e.ref.name}`===t);if(r?.iconThemeFssPath&&!r.iconThemeFss)try{r.iconThemeFss=await St(n,r.iconThemeFssPath),r.iconThemeBasePath||=W(r.iconThemeFssPath)}catch{}},[n]);(0,c.useEffect)(()=>{b.current&&(async()=>{let e=v.current;if(await x(e,i),Vr(e,i),!i)p(`fss`);else{let t=e.find(e=>`${e.ref.publisher}.${e.ref.name}`===i);t?.vscodeIconThemePath?p(`vscode`,t.vscodeIconThemePath):t?.iconThemeFssPath?p(`fss`):p(`none`)}_.current()})()},[i,x]),(0,c.useEffect)(()=>{if(b.current)if(!a)an();else{let e=Ln(v.current,a);e&&sn(n,e.theme.jsonPath,e.theme.uiTheme).catch(()=>an())}},[a]),(0,c.useEffect)(()=>{if(!e)return;le.initialize();let t=async e=>{le.clear();for(let t of e)if(t.languages)for(let e of t.languages)le.registerLanguage(e);await le.activateGrammars()},i=async(e,t)=>{if(!t){await p(`fss`);return}let n=e.find(e=>`${e.ref.publisher}.${e.ref.name}`===t);n?.vscodeIconThemePath?await p(`vscode`,n.vscodeIconThemePath):n?.iconThemeFssPath?await p(`fss`):await p(`none`)},a=async(e,t)=>{if(!t){an();return}let r=Ln(e,t);if(r){let e=on(r.theme.uiTheme);jt().dataset.theme=e,m(e);try{await sn(n,r.theme.jsonPath,r.theme.uiTheme)}catch(e){console.warn(`[ExtHost] Failed to load color theme:`,t,e),an()}}else an()},o=e=>{for(let e of y.current)try{e()}catch{}y.current=[];for(let t of e){if(t.commands){let e=V.registerContributions(t.commands);y.current.push(e);for(let e of t.commands){let t=V.registerCommand(e.command,async(...t)=>{await r.executeCommand(e.command,t)});y.current.push(t)}}t.keybindings?.length&&y.current.push(...et(V,t.keybindings))}},c=r.onLoaded(e=>{(async()=>{if(v.current=e,s(e),qt(e),Ot(),n.fsProvider){for(let t of e)for(let e of t.fsProviders??[])if(e.runtime===`backend`){let r=G(t.dirPath,e.entry);n.fsProvider.load(r).catch(()=>{})}}n.utils.getEnv().then(t=>na(n,e,t).then(({profiles:e,shellScripts:t})=>{u(e),f(!0),n.pty.setShellIntegrations&&Object.keys(t).length>0&&n.pty.setShellIntegrations(t).catch(()=>{})})).catch(()=>{f(!0)}),await x(e,h.current),Vr(e,h.current),t(e),o(e),Promise.all([i(e,h.current),a(e,g.current)]).then(()=>{l(!0),b.current=!0,_.current()})})()});return r.start(),()=>{c();for(let e of y.current)try{e()}catch{}y.current=[],r.dispose()}},[e,x,s,u,f,l])}async function ia(e,t,n){let r=await e(t);if(r.length===0)return[{innerPath:t,destRelPath:n}];let i=[];for(let a of r){let r=t===`/`?`/${a.name}`:`${t}/${a.name}`,o=`${n}/${a.name}`;i.push(...await ia(e,r,o))}return i}function aa(e,t,n,r){let{showDialog:i,closeDialog:a,updateDialog:o}=_e(),s=B(),l=(0,c.useRef)(null),u=(0,c.useRef)(null),d=(0,c.useRef)(null),f=(0,c.useRef)(null),p=(0,c.useRef)(null),m=(0,c.useRef)(null),h=(0,c.useCallback)(()=>{r(e=>e+1),t.current.navigateTo(t.current.currentPath),n.current.navigateTo(n.current.currentPath)},[r,t,n]),g=(0,c.useCallback)((e,t)=>{e.length!==0&&i({type:`message`,title:`Move to Trash`,message:e.length===1?`Move "${K(e[0])}" to Trash?`:`Move ${e.length} items to Trash?`,variant:`default`,buttons:[{label:`Cancel`},{label:`Move to Trash`,default:!0,onClick:async()=>{try{await s.fs.moveToTrash(e),t()}catch(e){i({type:`message`,title:`Error`,message:e instanceof Error?e.message:String(e),variant:`error`})}}}]})},[i]),_=(0,c.useCallback)((e,t)=>{e.length!==0&&i({type:`message`,title:`Permanently Delete`,message:e.length===1?`Permanently delete "${K(e[0])}"? This cannot be undone.`:`Permanently delete ${e.length} items? This cannot be undone.`,variant:`default`,buttons:[{label:`Cancel`},{label:`Delete`,default:!0,onClick:async()=>{try{let t={type:`deleteProgress`,filesDone:0,currentFile:`Preparing...`,onCancel:()=>{i({type:`cancelDeleteConfirm`,onResume:()=>{m.current&&i(m.current)},onCancelDeletion:()=>{p.current!==null&&s.fs.delete.cancel(p.current),p.current=null,m.current=null,a()}})}};m.current=t,i(t);let n=await s.fs.delete.start(e);m.current!==null&&(p.current=n)}catch(e){p.current=null,m.current=null,a(),i({type:`message`,title:`Error`,message:e instanceof Error?e.message:String(e),variant:`error`})}}}]})},[i,a]),v=(0,c.useCallback)((r,c)=>{let d=(e.current===`left`?n.current:t.current).currentPath;!d||r.length===0||i({type:`copyConfig`,itemCount:r.length,destPath:d,onConfirm:async(e,t)=>{try{if(r.some(e=>Mt(e))){if(!r.every(e=>Mt(e)))throw Error(`Cannot copy files from archives and local files in the same operation`);let e={type:`copyProgress`,bytesCopied:0,bytesTotal:0,filesDone:0,filesTotal:0,currentFile:`Collecting files...`,onCancel:a};u.current=e,i(e);let n=[];for(let e of r){let{containerFile:t,innerPath:r}=Nt(e),i=Kt.resolve(K(t));if(!i)throw Error(`No fsProvider registered for "${K(t)}"`);let a=null,o=null;i.contribution.runtime===`backend`&&s.fsProvider?a=G(i.extensionDirPath,i.contribution.entry):o=await Dt(s,i.extensionDirPath,i.contribution.entry),(await ia(async e=>a?s.fsProvider.listEntries(a,t,e):(await o.listEntries(t,e)).map(e=>({name:e.name,kind:e.type})),r,K(r))).forEach(e=>n.push({...e,hostFile:t,wasmPath:a,provider:o}))}o({filesTotal:n.length,currentFile:`Extracting...`}),u.current={...e,filesTotal:n.length,currentFile:`Extracting...`};let l=0;for(let{innerPath:e,destRelPath:r,hostFile:i,wasmPath:a,provider:c}of n){let n=G(t,r);o({currentFile:K(r),filesDone:l}),s.fs.createDir&&await s.fs.createDir(W(n)).catch(()=>{});let u;if(a)u=await s.fsProvider.readFileRange(a,i,e,0,64*1024*1024);else{if(!c?.readFileRange)throw Error(`Provider does not support readFileRange`);u=await c.readFileRange(i,e,0,64*1024*1024)}await s.fs.writeBinaryFile(n,new Uint8Array(u)),l++}u.current=null,a(),c();return}let n={type:`copyProgress`,bytesCopied:0,bytesTotal:0,filesDone:0,filesTotal:0,currentFile:`Preparing...`,onCancel:()=>{i({type:`cancelCopyConfirm`,onResume:()=>{u.current&&i(u.current)},onCancelCopy:()=>{l.current!==null&&s.fs.copy.cancel(l.current),l.current=null,u.current=null,a(),c()}})}};u.current=n,i(n);let d=await s.fs.copy.start(r,t,e);u.current!==null&&(l.current=d)}catch(e){l.current=null,u.current=null,a(),i({type:`message`,title:`Copy Error`,message:e instanceof Error?e.message:String(e),variant:`error`})}},onCancel:()=>{}})},[i,a]);(0,c.useEffect)(()=>s.fs.copy.onProgress(e=>{if(l.current===null)if(u.current!==null)l.current=e.copyId;else return;else if(e.copyId!==l.current)return;let t=e.event;switch(t.kind){case`progress`:{let e={bytesCopied:t.bytesCopied,bytesTotal:t.bytesTotal,filesDone:t.filesDone,filesTotal:t.filesTotal,currentFile:t.currentFile};u.current&&={...u.current,...e},o(e);break}case`conflict`:i({type:`copyConflict`,src:t.src,dest:t.dest,srcSize:t.srcSize,srcMtimeMs:t.srcMtimeMs,destSize:t.destSize,destMtimeMs:t.destMtimeMs,onResolve:e=>{s.fs.copy.resolveConflict(l.current,e),u.current&&i(u.current)}});break;case`done`:l.current=null,u.current=null,a(),h();break;case`error`:l.current=null,u.current=null,a(),i({type:`message`,title:`Copy Error`,message:t.message,variant:`error`}),h();break}}),[i,a,o,h]);let y=(0,c.useCallback)((r,o)=>{let c=(e.current===`left`?n.current:t.current).currentPath;!c||r.length===0||i({type:`moveConfig`,itemCount:r.length,destPath:c,onConfirm:async(e,t)=>{try{let n={type:`moveProgress`,bytesCopied:0,bytesTotal:0,filesDone:0,filesTotal:0,currentFile:`Preparing...`,onCancel:()=>{i({type:`cancelMoveConfirm`,onResume:()=>{f.current&&i(f.current)},onCancelMove:()=>{d.current!==null&&s.fs.move.cancel(d.current),d.current=null,f.current=null,a(),o()}})}};f.current=n,i(n);let c=await s.fs.move.start(r,t,e);f.current!==null&&(d.current=c)}catch(e){d.current=null,f.current=null,a(),i({type:`message`,title:`Move Error`,message:e instanceof Error?e.message:String(e),variant:`error`})}},onCancel:()=>{}})},[i,a]);return(0,c.useEffect)(()=>s.fs.move.onProgress(e=>{if(d.current===null)if(f.current!==null)d.current=e.moveId;else return;else if(e.moveId!==d.current)return;let t=e.event;switch(t.kind){case`progress`:{let e={bytesCopied:t.bytesCopied,bytesTotal:t.bytesTotal,filesDone:t.filesDone,filesTotal:t.filesTotal,currentFile:t.currentFile};f.current&&={...f.current,...e},o(e);break}case`conflict`:i({type:`moveConflict`,src:t.src,dest:t.dest,srcSize:t.srcSize,srcMtimeMs:t.srcMtimeMs,destSize:t.destSize,destMtimeMs:t.destMtimeMs,onResolve:e=>{s.fs.move.resolveConflict(d.current,e),f.current&&i(f.current)}});break;case`done`:d.current=null,f.current=null,a(),h();break;case`error`:d.current=null,f.current=null,a(),i({type:`message`,title:`Move Error`,message:t.message,variant:`error`}),h();break}}),[i,a,o,h]),(0,c.useEffect)(()=>s.fs.delete.onProgress(e=>{if(p.current===null)if(m.current!==null)p.current=e.deleteId;else return;else if(e.deleteId!==p.current)return;let t=e.event;switch(t.kind){case`progress`:{let e={filesDone:t.filesDone,currentFile:t.currentFile};m.current&&={...m.current,...e},o(e);break}case`done`:p.current=null,m.current=null,a(),h();break;case`error`:p.current=null,m.current=null,a(),i({type:`message`,title:`Delete Error`,message:t.message,variant:`error`}),h();break}}),[i,a,o,h]),{handleCopy:v,handleMove:y,handleMoveToTrash:g,handlePermanentDelete:_,handleRename:(0,c.useCallback)((e,t,n)=>{i({type:`rename`,currentName:t,onConfirm:async t=>{try{await s.fs.rename.rename(e,t),n()}catch(e){i({type:`message`,title:`Rename Error`,message:e instanceof Error?e.message:String(e),variant:`error`})}},onCancel:()=>{}})},[i])}}function oa(e){let t=e.trim();if(!t)return null;if(/^cd::/i.test(t)){let e=t.match(/^cd::\s*(\S+)\s*$/i);return e?{kind:`setAlias`,alias:e[1]}:{kind:`error`,message:`Usage: cd::alias — save current folder as alias`}}if(/^cd:/i.test(t)){let e=t.match(/^cd:\s*(\S+)\s*$/i);return e?{kind:`goAlias`,alias:e[1]}:{kind:`error`,message:`Usage: cd:alias — go to folder saved under alias`}}if(/^cd(?:\s|$)/i.test(t)||/^cd$/i.test(t)){let e=t.match(/^cd(?:\s+(.*))?$/i);if(!e)return null;let n=(e[1]??``).trim();return(n.startsWith(`"`)&&n.endsWith(`"`)||n.startsWith(`'`)&&n.endsWith(`'`))&&(n=n.slice(1,-1)),{kind:`chdir`,pathArg:n}}return null}async function sa(e,t,n){let r=t.trim();if(!r)return Q(await e.utils.getHomePath());let i=r;if(i.startsWith(`~`)){let t=await e.utils.getHomePath(),n=Q(t);if(i===`~`||i===`~/`)return n;let r=i.slice(1).replace(/^\//,``);i=r?G(t,r):t}return Q(mt(U(i.startsWith(`/`)||i.startsWith(`//`)||/^[A-Za-z]:\//.test(i)||/^[A-Za-z]:$/i.test(i)?i:G(n,i))))}async function ca(e,t){if(!await e.fs.exists(t))return!1;try{return await e.fs.entries(t),!0}catch{return!1}}function la(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function ua(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}var da,fa=`__TAURI_TO_IPC_KEY__`;function pa(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}async function $(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}var ma=class{get rid(){return la(this,da,`f`)}constructor(e){da.set(this,void 0),ua(this,da,e,`f`)}async close(){return $(`plugin:resources|close`,{rid:this.rid})}};da=new WeakMap;function ha(){return!!(globalThis||window).isTauri}var ga=class{constructor(...e){this.type=`Logical`,e.length===1?`Logical`in e[0]?(this.width=e[0].Logical.width,this.height=e[0].Logical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toPhysical(e){return new _a(this.width*e,this.height*e)}[fa](){return{width:this.width,height:this.height}}toJSON(){return this[fa]()}},_a=class{constructor(...e){this.type=`Physical`,e.length===1?`Physical`in e[0]?(this.width=e[0].Physical.width,this.height=e[0].Physical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toLogical(e){return new ga(this.width/e,this.height/e)}[fa](){return{width:this.width,height:this.height}}toJSON(){return this[fa]()}},va=class{constructor(e){this.size=e}toLogical(e){return this.size instanceof ga?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof _a?this.size:this.size.toPhysical(e)}[fa](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[fa]()}},ya=class{constructor(...e){this.type=`Logical`,e.length===1?`Logical`in e[0]?(this.x=e[0].Logical.x,this.y=e[0].Logical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toPhysical(e){return new ba(this.x*e,this.y*e)}[fa](){return{x:this.x,y:this.y}}toJSON(){return this[fa]()}},ba=class{constructor(...e){this.type=`Physical`,e.length===1?`Physical`in e[0]?(this.x=e[0].Physical.x,this.y=e[0].Physical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toLogical(e){return new ya(this.x/e,this.y/e)}[fa](){return{x:this.x,y:this.y}}toJSON(){return this[fa]()}},xa=class{constructor(e){this.position=e}toLogical(e){return this.position instanceof ya?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof ba?this.position:this.position.toPhysical(e)}[fa](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[fa]()}},Sa;(function(e){e.WINDOW_RESIZED=`tauri://resize`,e.WINDOW_MOVED=`tauri://move`,e.WINDOW_CLOSE_REQUESTED=`tauri://close-requested`,e.WINDOW_DESTROYED=`tauri://destroyed`,e.WINDOW_FOCUS=`tauri://focus`,e.WINDOW_BLUR=`tauri://blur`,e.WINDOW_SCALE_FACTOR_CHANGED=`tauri://scale-change`,e.WINDOW_THEME_CHANGED=`tauri://theme-changed`,e.WINDOW_CREATED=`tauri://window-created`,e.WEBVIEW_CREATED=`tauri://webview-created`,e.DRAG_ENTER=`tauri://drag-enter`,e.DRAG_OVER=`tauri://drag-over`,e.DRAG_DROP=`tauri://drag-drop`,e.DRAG_LEAVE=`tauri://drag-leave`})(Sa||={});async function Ca(e,t){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(e,t),await $(`plugin:event|unlisten`,{event:e,eventId:t})}async function wa(e,t,n){return $(`plugin:event|listen`,{event:e,target:typeof n?.target==`string`?{kind:`AnyLabel`,label:n.target}:n?.target??{kind:`Any`},handler:pa(t)}).then(t=>async()=>Ca(e,t))}async function Ta(e,t,n){return wa(e,n=>{Ca(e,n.id),t(n)},n)}async function Ea(e,t){await $(`plugin:event|emit`,{event:e,payload:t})}async function Da(e,t,n){await $(`plugin:event|emit_to`,{target:typeof e==`string`?{kind:`AnyLabel`,label:e}:e,event:t,payload:n})}var Oa=class e extends ma{constructor(e){super(e)}static async new(t,n,r){return $(`plugin:image|new`,{rgba:ka(t),width:n,height:r}).then(t=>new e(t))}static async fromBytes(t){return $(`plugin:image|from_bytes`,{bytes:ka(t)}).then(t=>new e(t))}static async fromPath(t){return $(`plugin:image|from_path`,{path:t}).then(t=>new e(t))}async rgba(){return $(`plugin:image|rgba`,{rid:this.rid}).then(e=>new Uint8Array(e))}async size(){return $(`plugin:image|size`,{rid:this.rid})}};function ka(e){return e==null?null:typeof e==`string`?e:e instanceof Oa?e.rid:e}var Aa;(function(e){e[e.Critical=1]=`Critical`,e[e.Informational=2]=`Informational`})(Aa||={});var ja=class{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}},Ma;(function(e){e.None=`none`,e.Normal=`normal`,e.Indeterminate=`indeterminate`,e.Paused=`paused`,e.Error=`error`})(Ma||={});function Na(){return new Ia(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function Pa(){return $(`plugin:window|get_all_windows`).then(e=>e.map(e=>new Ia(e,{skip:!0})))}var Fa=[`tauri://created`,`tauri://error`],Ia=class{constructor(e,t={}){this.label=e,this.listeners=Object.create(null),t?.skip||$(`plugin:window|create`,{options:{...t,parent:typeof t.parent==`string`?t.parent:t.parent?.label,label:e}}).then(async()=>this.emit(`tauri://created`)).catch(async e=>this.emit(`tauri://error`,e))}static async getByLabel(e){return(await Pa()).find(t=>t.label===e)??null}static getCurrent(){return Na()}static async getAll(){return Pa()}static async getFocusedWindow(){for(let e of await Pa())if(await e.isFocused())return e;return null}async listen(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:wa(e,t,{target:{kind:`Window`,label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:Ta(e,t,{target:{kind:`Window`,label:this.label}})}async emit(e,t){if(Fa.includes(e)){for(let n of this.listeners[e]||[])n({event:e,id:-1,payload:t});return}return Ea(e,t)}async emitTo(e,t,n){if(Fa.includes(t)){for(let e of this.listeners[t]||[])e({event:t,id:-1,payload:n});return}return Da(e,t,n)}_handleTauriEvent(e,t){return Fa.includes(e)?(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0):!1}async scaleFactor(){return $(`plugin:window|scale_factor`,{label:this.label})}async innerPosition(){return $(`plugin:window|inner_position`,{label:this.label}).then(e=>new ba(e))}async outerPosition(){return $(`plugin:window|outer_position`,{label:this.label}).then(e=>new ba(e))}async innerSize(){return $(`plugin:window|inner_size`,{label:this.label}).then(e=>new _a(e))}async outerSize(){return $(`plugin:window|outer_size`,{label:this.label}).then(e=>new _a(e))}async isFullscreen(){return $(`plugin:window|is_fullscreen`,{label:this.label})}async isMinimized(){return $(`plugin:window|is_minimized`,{label:this.label})}async isMaximized(){return $(`plugin:window|is_maximized`,{label:this.label})}async isFocused(){return $(`plugin:window|is_focused`,{label:this.label})}async isDecorated(){return $(`plugin:window|is_decorated`,{label:this.label})}async isResizable(){return $(`plugin:window|is_resizable`,{label:this.label})}async isMaximizable(){return $(`plugin:window|is_maximizable`,{label:this.label})}async isMinimizable(){return $(`plugin:window|is_minimizable`,{label:this.label})}async isClosable(){return $(`plugin:window|is_closable`,{label:this.label})}async isVisible(){return $(`plugin:window|is_visible`,{label:this.label})}async title(){return $(`plugin:window|title`,{label:this.label})}async theme(){return $(`plugin:window|theme`,{label:this.label})}async isAlwaysOnTop(){return $(`plugin:window|is_always_on_top`,{label:this.label})}async center(){return $(`plugin:window|center`,{label:this.label})}async requestUserAttention(e){let t=null;return e&&(t=e===Aa.Critical?{type:`Critical`}:{type:`Informational`}),$(`plugin:window|request_user_attention`,{label:this.label,value:t})}async setResizable(e){return $(`plugin:window|set_resizable`,{label:this.label,value:e})}async setEnabled(e){return $(`plugin:window|set_enabled`,{label:this.label,value:e})}async isEnabled(){return $(`plugin:window|is_enabled`,{label:this.label})}async setMaximizable(e){return $(`plugin:window|set_maximizable`,{label:this.label,value:e})}async setMinimizable(e){return $(`plugin:window|set_minimizable`,{label:this.label,value:e})}async setClosable(e){return $(`plugin:window|set_closable`,{label:this.label,value:e})}async setTitle(e){return $(`plugin:window|set_title`,{label:this.label,value:e})}async maximize(){return $(`plugin:window|maximize`,{label:this.label})}async unmaximize(){return $(`plugin:window|unmaximize`,{label:this.label})}async toggleMaximize(){return $(`plugin:window|toggle_maximize`,{label:this.label})}async minimize(){return $(`plugin:window|minimize`,{label:this.label})}async unminimize(){return $(`plugin:window|unminimize`,{label:this.label})}async show(){return $(`plugin:window|show`,{label:this.label})}async hide(){return $(`plugin:window|hide`,{label:this.label})}async close(){return $(`plugin:window|close`,{label:this.label})}async destroy(){return $(`plugin:window|destroy`,{label:this.label})}async setDecorations(e){return $(`plugin:window|set_decorations`,{label:this.label,value:e})}async setShadow(e){return $(`plugin:window|set_shadow`,{label:this.label,value:e})}async setEffects(e){return $(`plugin:window|set_effects`,{label:this.label,value:e})}async clearEffects(){return $(`plugin:window|set_effects`,{label:this.label,value:null})}async setAlwaysOnTop(e){return $(`plugin:window|set_always_on_top`,{label:this.label,value:e})}async setAlwaysOnBottom(e){return $(`plugin:window|set_always_on_bottom`,{label:this.label,value:e})}async setContentProtected(e){return $(`plugin:window|set_content_protected`,{label:this.label,value:e})}async setSize(e){return $(`plugin:window|set_size`,{label:this.label,value:e instanceof va?e:new va(e)})}async setMinSize(e){return $(`plugin:window|set_min_size`,{label:this.label,value:e instanceof va?e:e?new va(e):null})}async setMaxSize(e){return $(`plugin:window|set_max_size`,{label:this.label,value:e instanceof va?e:e?new va(e):null})}async setSizeConstraints(e){function t(e){return e?{Logical:e}:null}return $(`plugin:window|set_size_constraints`,{label:this.label,value:{minWidth:t(e?.minWidth),minHeight:t(e?.minHeight),maxWidth:t(e?.maxWidth),maxHeight:t(e?.maxHeight)}})}async setPosition(e){return $(`plugin:window|set_position`,{label:this.label,value:e instanceof xa?e:new xa(e)})}async setFullscreen(e){return $(`plugin:window|set_fullscreen`,{label:this.label,value:e})}async setSimpleFullscreen(e){return $(`plugin:window|set_simple_fullscreen`,{label:this.label,value:e})}async setFocus(){return $(`plugin:window|set_focus`,{label:this.label})}async setFocusable(e){return $(`plugin:window|set_focusable`,{label:this.label,value:e})}async setIcon(e){return $(`plugin:window|set_icon`,{label:this.label,value:ka(e)})}async setSkipTaskbar(e){return $(`plugin:window|set_skip_taskbar`,{label:this.label,value:e})}async setCursorGrab(e){return $(`plugin:window|set_cursor_grab`,{label:this.label,value:e})}async setCursorVisible(e){return $(`plugin:window|set_cursor_visible`,{label:this.label,value:e})}async setCursorIcon(e){return $(`plugin:window|set_cursor_icon`,{label:this.label,value:e})}async setBackgroundColor(e){return $(`plugin:window|set_background_color`,{color:e})}async setCursorPosition(e){return $(`plugin:window|set_cursor_position`,{label:this.label,value:e instanceof xa?e:new xa(e)})}async setIgnoreCursorEvents(e){return $(`plugin:window|set_ignore_cursor_events`,{label:this.label,value:e})}async startDragging(){return $(`plugin:window|start_dragging`,{label:this.label})}async startResizeDragging(e){return $(`plugin:window|start_resize_dragging`,{label:this.label,value:e})}async setBadgeCount(e){return $(`plugin:window|set_badge_count`,{label:this.label,value:e})}async setBadgeLabel(e){return $(`plugin:window|set_badge_label`,{label:this.label,value:e})}async setOverlayIcon(e){return $(`plugin:window|set_overlay_icon`,{label:this.label,value:e?ka(e):void 0})}async setProgressBar(e){return $(`plugin:window|set_progress_bar`,{label:this.label,value:e})}async setVisibleOnAllWorkspaces(e){return $(`plugin:window|set_visible_on_all_workspaces`,{label:this.label,value:e})}async setTitleBarStyle(e){return $(`plugin:window|set_title_bar_style`,{label:this.label,value:e})}async setTheme(e){return $(`plugin:window|set_theme`,{label:this.label,value:e})}async onResized(e){return this.listen(Sa.WINDOW_RESIZED,t=>{t.payload=new _a(t.payload),e(t)})}async onMoved(e){return this.listen(Sa.WINDOW_MOVED,t=>{t.payload=new ba(t.payload),e(t)})}async onCloseRequested(e){return this.listen(Sa.WINDOW_CLOSE_REQUESTED,async t=>{let n=new ja(t);await e(n),n.isPreventDefault()||await this.destroy()})}async onDragDropEvent(e){let t=await this.listen(Sa.DRAG_ENTER,t=>{e({...t,payload:{type:`enter`,paths:t.payload.paths,position:new ba(t.payload.position)}})}),n=await this.listen(Sa.DRAG_OVER,t=>{e({...t,payload:{type:`over`,position:new ba(t.payload.position)}})}),r=await this.listen(Sa.DRAG_DROP,t=>{e({...t,payload:{type:`drop`,paths:t.payload.paths,position:new ba(t.payload.position)}})}),i=await this.listen(Sa.DRAG_LEAVE,t=>{e({...t,payload:{type:`leave`}})});return()=>{t(),r(),n(),i()}}async onFocusChanged(e){let t=await this.listen(Sa.WINDOW_FOCUS,t=>{e({...t,payload:!0})}),n=await this.listen(Sa.WINDOW_BLUR,t=>{e({...t,payload:!1})});return()=>{t(),n()}}async onScaleChanged(e){return this.listen(Sa.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(Sa.WINDOW_THEME_CHANGED,e)}},La;(function(e){e.Disabled=`disabled`,e.Throttle=`throttle`,e.Suspend=`suspend`})(La||={});var Ra;(function(e){e.Default=`default`,e.FluentOverlay=`fluentOverlay`})(Ra||={});var za;(function(e){e.AppearanceBased=`appearanceBased`,e.Light=`light`,e.Dark=`dark`,e.MediumLight=`mediumLight`,e.UltraDark=`ultraDark`,e.Titlebar=`titlebar`,e.Selection=`selection`,e.Menu=`menu`,e.Popover=`popover`,e.Sidebar=`sidebar`,e.HeaderView=`headerView`,e.Sheet=`sheet`,e.WindowBackground=`windowBackground`,e.HudWindow=`hudWindow`,e.FullScreenUI=`fullScreenUI`,e.Tooltip=`tooltip`,e.ContentBackground=`contentBackground`,e.UnderWindowBackground=`underWindowBackground`,e.UnderPageBackground=`underPageBackground`,e.Mica=`mica`,e.Blur=`blur`,e.Acrylic=`acrylic`,e.Tabbed=`tabbed`,e.TabbedDark=`tabbedDark`,e.TabbedLight=`tabbedLight`})(za||={});var Ba;(function(e){e.FollowsWindowActiveState=`followsWindowActiveState`,e.Active=`active`,e.Inactive=`inactive`})(Ba||={});function Va(e){let t=B(),n=(0,c.useRef)(e);n.current=e;let r=(0,d.useAtomValue)(Te),i=(0,c.useRef)(r);i.current=r;let{updateSettings:a}=nr(),[o,s]=(0,d.useAtom)(Ne),l=(0,d.useSetAtom)(Pe),u=(0,d.useSetAtom)(Ae),f=(0,d.useSetAtom)(Se),p=(0,d.useSetAtom)(Ie),m=(0,d.useSetAtom)(Le),h=(0,d.useSetAtom)(Fe),g=(0,c.useRef)(o);g.current=o,(0,c.useEffect)(()=>{let e=[];return e.push(V.registerCommand(`dotdir.toggleHiddenFiles`,()=>l(e=>{let t=!e;return a({showHidden:t}),t}))),e.push(V.registerCommand(`dotdir.togglePanels`,()=>u(e=>{let t=!e;return t&&v.set(`panel`),t}))),e.push(V.registerCommand(`dotdir.showExtensions`,()=>f(!0))),e.push(V.registerCommand(`dotdir.showCommandPalette`,()=>h(e=>!e))),e.push(V.registerCommand(`dotdir.closeViewer`,()=>p(null))),e.push(V.registerCommand(`dotdir.closeEditor`,()=>m(null))),e.push(V.registerCommand(`dotdir.switchPanel`,()=>s(e=>e===`left`?`right`:`left`))),e.push(V.registerCommand(`dotdir.focusLeftPanel`,()=>s(`left`))),e.push(V.registerCommand(`dotdir.focusRightPanel`,()=>s(`right`))),e.push(V.registerCommand(`dotdir.cancelNavigation`,()=>{n.current.leftRef.current.cancelNavigation(),n.current.rightRef.current.cancelNavigation()})),e.push(V.registerCommand(`dotdir.goToParent`,()=>{let{leftRef:e,rightRef:t}=n.current,r=g.current===`left`?e.current:t.current,i=r.currentPath;if(Mt(i)){let{containerFile:e,innerPath:t}=Nt(i);if(t===`/`||t===``){r.navigateTo(W(e),!1,K(e));return}}let a=W(i);a!==i&&r.navigateTo(a)})),e.push(V.registerCommand(`dotdir.goHome`,async()=>{let{leftRef:e,rightRef:r}=n.current,i=await t.utils.getHomePath();(g.current===`left`?e.current:r.current).navigateTo(i)})),e.push(V.registerCommand(`dotdir.refresh`,()=>{let{leftRef:e,rightRef:t}=n.current,r=g.current===`left`?e.current:t.current;r.navigateTo(r.currentPath)})),e.push(V.registerCommand(`dotdir.newTab`,()=>void ji()?.newTab())),e.push(V.registerCommand(`dotdir.closeTab`,()=>void ji()?.closeActiveTab())),e.push(V.registerCommand(`dotdir.previewInOppositePanel`,()=>n.current.onPreviewInOppositePanel())),e.push(V.registerCommand(`dotdir.openCurrentFolderInOppositePanelCurrentTab`,()=>n.current.onOpenCurrentFolderInOppositeCurrentTab())),e.push(V.registerCommand(`dotdir.openCurrentFolderInOppositePanelNewTab`,()=>n.current.onOpenCurrentFolderInOppositeNewTab())),e.push(V.registerCommand(`dotdir.openSelectedFolderInOppositePanelCurrentTab`,()=>n.current.onOpenSelectedFolderInOppositeCurrentTab())),e.push(V.registerCommand(`dotdir.openSelectedFolderInOppositePanelNewTab`,()=>n.current.onOpenSelectedFolderInOppositeNewTab())),e.push(V.registerCommand(`dotdir.openCreateFile`,()=>{let{leftRef:e,rightRef:t,showDialog:r,onOpenCreateFileConfirm:a}=n.current,o=(g.current===`left`?e.current:t.current).currentPath,s=i.current.flatMap(e=>e.languages??[]),c=new Set;r({type:`openCreateFile`,currentPath:o,languages:s.filter(e=>c.has(e.id)?!1:(c.add(e.id),!0)).map(e=>({id:e.id,label:e.aliases?.[0]??e.id})),onConfirm:a,onCancel:()=>{}})})),e.push(V.registerCommand(`dotdir.makeFolder`,()=>{let{leftRef:e,rightRef:r,showDialog:i}=n.current,a=g.current===`left`?e.current:r.current,o=a.currentPath;i({type:`makeFolder`,currentPath:o,onConfirm:async e=>{let n=e=>o?`${o.replace(/\/?$/,``)}/${e}`:e;if(e.mode===`single`){let r=n(e.name);t.fs.createDir&&await t.fs.createDir(r),a.navigateTo(r);return}for(let r of e.names){let e=n(r);t.fs.createDir&&await t.fs.createDir(e)}a.navigateTo(o)},onCancel:()=>{}})})),e.push(V.registerCommand(`dotdir.exit`,async()=>{ha()?await Na().close():window.close()})),e.push(V.registerCommand(`terminal.execute`,async e=>{let t=K(e),r=/^[a-zA-Z0-9._+-]+$/.test(t)?`./${t}`:`./${JSON.stringify(t)}`;await n.current.onExecuteInTerminal(`${r}\r`)})),e.push(V.registerCommand(`dotdir.viewFile`,(e,t,r)=>{n.current.onViewFile(e,t,r)})),e.push(V.registerCommand(`dotdir.editFile`,(e,t,r,i)=>{let a=n.current.editorFileSizeLimit;a>0&&r>a||n.current.onEditFile(e,t,r,i)})),e.push(V.registerCommand(`list.cursorUp`,()=>q()?.cursorUp())),e.push(V.registerCommand(`list.cursorDown`,()=>q()?.cursorDown())),e.push(V.registerCommand(`list.cursorLeft`,()=>q()?.cursorLeft())),e.push(V.registerCommand(`list.cursorRight`,()=>q()?.cursorRight())),e.push(V.registerCommand(`list.cursorHome`,()=>q()?.cursorHome())),e.push(V.registerCommand(`list.cursorEnd`,()=>q()?.cursorEnd())),e.push(V.registerCommand(`list.cursorPageUp`,()=>q()?.cursorPageUp())),e.push(V.registerCommand(`list.cursorPageDown`,()=>q()?.cursorPageDown())),e.push(V.registerCommand(`list.selectUp`,()=>q()?.selectUp())),e.push(V.registerCommand(`list.selectDown`,()=>q()?.selectDown())),e.push(V.registerCommand(`list.selectLeft`,()=>q()?.selectLeft())),e.push(V.registerCommand(`list.selectRight`,()=>q()?.selectRight())),e.push(V.registerCommand(`list.selectHome`,()=>q()?.selectHome())),e.push(V.registerCommand(`list.selectEnd`,()=>q()?.selectEnd())),e.push(V.registerCommand(`list.selectPageUp`,()=>q()?.selectPageUp())),e.push(V.registerCommand(`list.selectPageDown`,()=>q()?.selectPageDown())),e.push(V.registerCommand(`list.execute`,()=>q()?.execute())),e.push(V.registerCommand(`list.open`,()=>q()?.open())),e.push(V.registerCommand(`list.viewFile`,()=>q()?.viewFile())),e.push(V.registerCommand(`list.editFile`,()=>q()?.editFile())),e.push(V.registerCommand(`list.moveToTrash`,()=>q()?.moveToTrash())),e.push(V.registerCommand(`list.permanentDelete`,()=>q()?.permanentDelete())),e.push(V.registerCommand(`list.copy`,()=>q()?.copy())),e.push(V.registerCommand(`list.move`,()=>q()?.move())),e.push(V.registerCommand(`list.rename`,()=>q()?.rename())),e.push(V.registerCommand(`list.pasteFilename`,()=>q()?.pasteFilename())),e.push(V.registerCommand(`list.pastePath`,()=>q()?.pastePath())),e.push(...Ye(V)),e.push(...Ze(V)),()=>{for(let t of e)t()}},[s,l,u,f,p,m,h,a])}var Ha=function(e){return e[e.None=0]=`None`,e[e.Expanded=1]=`Expanded`,e[e.Selected=2]=`Selected`,e[e.Hovered=4]=`Hovered`,e[e.Active=8]=`Active`,e[e.DragOver=16]=`DragOver`,e[e.Focused=32]=`Focused`,e}({});Ha.Expanded,Ha.Selected,Ha.Hovered,Ha.Active,Ha.DragOver,Ha.Focused;function Ua(e){let t=e.name.indexOf(`.`),n=e.name.lastIndexOf(`.`),r=``,i=``;return e.type===`file`&&t>0&&(i=e.name.substring(t+1),r=n>0?e.name.substring(n+1):i),{type:e.type,name:e.name,baseExt:r,fullExt:i,lang:e.lang??``,path:e.path,parent:e.parent,stateFlags:e.stateFlags??Ha.None,meta:e.meta??{}}}function Wa(e){if(W(e)===e)return;let t=[],n=e;for(;;){t.push(n);let e=W(n);if(e===n)break;n=e}t.reverse();let r;for(let e of t)r=Ua({name:K(e)||e,type:`folder`,path:e,parent:r});return r}function Ga(e){return e.kind===`directory`||e.kind===`symlink`&&(e.mode&61440)==16384}function Ka(e,t,n){let r=Ga(e),i={size:e.size,mtimeMs:e.mtimeMs,mode:e.mode,nlink:e.nlink,kind:e.kind,hidden:e.hidden,linkTarget:e.linkTarget};return Ua({name:e.name,type:r?`folder`:`file`,lang:r?``:le.detectLanguage(e.name),meta:{size:i.size,mtimeMs:i.mtimeMs,executable:!r&&_t(i.mode??0,e.name),hidden:i.hidden??e.name.startsWith(`.`),nlink:i.nlink??1,entryKind:i.kind??(r?`directory`:`file`),linkTarget:i.linkTarget},path:G(t,e.name),parent:n})}async function qa(e,t){let n=t;for(;;){if(await e.fs.exists(n))return n;let t=W(n);if(t===n||pt(n))return n;n=t}}function Ja(e){let t=[],n=e;for(;;){t.push(n);let e=W(n);if(e===n)break;n=e}return t}var Ya={currentPath:``,parentNode:void 0,entries:[],requestedCursor:void 0};function Xa(e){let t=B(),n=(0,d.useAtomValue)(ke),[r,i]=(0,c.useState)(Ya),[a,o]=(0,c.useState)(!1),s=(0,c.useRef)(null),l=(0,c.useRef)(null),u=(0,c.useMemo)(()=>Wr(n),[n]),f=(0,c.useRef)(u);f.current=u;let p=(0,c.useRef)(null),m=(0,c.useRef)(null),h=(0,c.useRef)(``),g=(0,c.useRef)(e);g.current=e,(0,c.useEffect)(()=>{h.current&&v(h.current,!0)},[u]);let _=(0,c.useCallback)(e=>{let t=p.current,n=Ja(e),r=[];for(let e of n)r.push(e),r.push(G(e,`.dotdir`));t.sync(r)},[]),v=(0,c.useCallback)(async(e,n=!1,r)=>{if(!n&&h.current===e&&l.current)return;l.current?.abort();let a=new AbortController;l.current=a,s.current=setTimeout(()=>o(!0),300);try{let n=(async()=>{if(h.current=e,Mt(e)){let{containerFile:n,innerPath:o}=Nt(e),s=Kt.resolve(K(n));if(!s)throw Error(`No fsProvider registered for "${K(n)}"`);let c;if(s.contribution.runtime===`backend`&&t.fsProvider){let e=G(s.extensionDirPath,s.contribution.entry),r=await t.fsProvider.listEntries(e,n,o);if(a.signal.aborted)return;c=r.map(e=>({name:e.name,type:e.kind,size:e.size,mtimeMs:e.mtimeMs}))}else{let e=await Dt(t,s.extensionDirPath,s.contribution.entry);if(a.signal.aborted||(c=await e.listEntries(n,o),a.signal.aborted))return}let l=Wa(e);i({currentPath:e,parentNode:l,entries:c.map(e=>{let t=(o===`/`?``:o)+`/`+e.name;return Ua({name:e.name,type:e.type===`directory`?`folder`:`file`,lang:e.type===`file`?le.detectLanguage(e.name):``,meta:{size:e.size??0,mtimeMs:e.mtimeMs??0,executable:!1,hidden:e.name.startsWith(`.`),nlink:1,entryKind:e.type===`directory`?`directory`:`file`},path:Pt(n,t),parent:l})}),requestedCursor:r})}else{if(await Gr(t,f.current,e),a.signal.aborted)return;let n=Wa(e),o=await t.fs.entries(e);if(a.signal.aborted)return;let s=o.map(t=>Ka(t,e,n));if(a.signal.aborted)return;i({currentPath:e,parentNode:n,entries:s,requestedCursor:r}),_(e)}})();n.catch(()=>{}),await Promise.race([n,new Promise(e=>{a.signal.addEventListener(`abort`,()=>e(),{once:!0})})])}catch(e){if(!a.signal.aborted){let t=e&&typeof e==`object`&&`message`in e?e.message:String(e);g.current(`Failed to read directory: ${t}`)}}finally{l.current===a&&(l.current=null),clearTimeout(s.current),s.current=null,o(!1)}},[_]),y=(0,c.useCallback)(()=>{l.current?.abort(),l.current=null,s.current&&=(clearTimeout(s.current),null),o(!1)},[]);(0,c.useEffect)(()=>(p.current=new wt(t,e=>{let n=h.current;if(!n)return;let r=!1,i=!1,a=!1;for(let t of e){let e=t.root.path,o=t.relativePathComponents[0]??null,s=t.type;e===n?s===`errored`?a=!0:r=!0:e.endsWith(`/.dotdir`)?o===`fs.css`&&(Ur(W(e)),i=!0):(n.startsWith(e+`/`)||n===e)&&(o===`.dotdir`?(Ur(e),i=!0):o&&o===n.slice(e.length+1).split(`/`)[0]&&s===`disappeared`&&(a=!0))}if(a){m.current&&=(clearTimeout(m.current),null),qa(t,n).then(e=>{b.current(e)});return}(r||i)&&(m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{m.current=null,b.current(h.current)},100))}),()=>{p.current?.disconnect(),p.current=null,m.current&&=(clearTimeout(m.current),null)}),[]);let b=(0,c.useRef)(v);b.current=v;let x=(0,c.useCallback)(()=>{b.current(h.current,!0)},[]);return{...r,navigateTo:v,navigating:a,cancelNavigation:y,refresh:x,resolver:f.current}}function Za({activePanelCwd:e,onNavigatePanel:t}){let n=B(),r=(0,d.useAtomValue)(De),i=(0,d.useAtomValue)(Oe),a=(0,d.useAtomValue)(Ae),o=(0,d.useSetAtom)(Ae),s=(0,d.useSetAtom)(je),l=(0,d.useAtomValue)(Me),u=(0,d.useSetAtom)(Me),f=(0,d.useSetAtom)(Re),{activeSession:p,activeSessionId:m,setProfiles:h,setCurrentCwd:g,restartAll:_,dispose:y,writeToActiveSession:b,executeCommandInCwd:x}=Ki(),S=(0,c.useRef)(e);S.current=e;let C=(0,c.useRef)(t);C.current=t;let w=(0,c.useRef)(!1),T=(0,c.useRef)(null),E=(0,c.useCallback)(e=>{T.current&&=(clearTimeout(T.current),null),o(e)},[o]);(0,c.useEffect)(()=>{if(!p){E(!0),V.setContext(`terminalCommandRunning`,!1);return}let e=p.session.getCapabilities().commandRunning;return E(!e),V.setContext(`terminalCommandRunning`,e),p.session.subscribe(e=>{if(e.type===`command-start`)E(!1),V.setContext(`terminalCommandRunning`,!0);else if(e.type===`command-finish`)E(!0),V.setContext(`terminalCommandRunning`,!1);else if(e.type===`capabilities`){let t=e.capabilities.commandRunning;E(!t),V.setContext(`terminalCommandRunning`,t)}})},[m,E]),(0,c.useEffect)(()=>{i&&r.length>0&&h(r,e)},[i,r]),(0,c.useEffect)(()=>()=>{y()},[y]),(0,c.useEffect)(()=>{g(e)},[e,g]),(0,c.useEffect)(()=>{if(n.onReconnect)return n.onReconnect(()=>_())},[_]),(0,c.useEffect)(()=>{if(p?.cwd&&p.cwdUserInitiated){let e=Q(U(p.cwd));if(e===Q(S.current))return;C.current(e),u(null)}},[p,u]);let D=l??e;(0,c.useEffect)(()=>{f(D)},[D,f]),(0,c.useEffect)(()=>{l&&Q(e)===l&&u(null)},[e,l,u]),(0,c.useEffect)(()=>{if(!a)return;let e=requestAnimationFrame(()=>{v.set(`panel`)});return()=>cancelAnimationFrame(e)},[a]);let O=(0,c.useCallback)(e=>{u(Q(e))},[u]);return{activeCwd:D,writeToTerminal:(0,c.useCallback)(e=>b(e),[b]),runCommand:(0,c.useCallback)(async(e,t)=>{w.current=!0,o(!1),v.set(`terminal`),s(e=>e+1),await x(e,t)},[o,s,x]),rememberExpectedTerminalCwd:O}}var Qa={},$a=null,eo=null;async function to(e){return $a||=G(await e.utils.getHomePath(),`.dotdir`,`ui-state.json`),$a}async function no(e){try{let t=await St(e,await to(e)),n=JSON.parse(t);typeof n==`object`&&n&&!Array.isArray(n)&&(Qa=n)}catch{}return Qa}function ro(e,t){Qa={...Qa,...t},eo&&clearTimeout(eo),eo=setTimeout(()=>{eo=null,ao(e,Qa)},500)}function io(e){eo&&=(clearTimeout(eo),null),ao(e,Qa)}async function ao(e,t){try{let n=await to(e);await e.fs.writeFile(n,JSON.stringify(t,null,2))}catch(e){console.error(`[uiState] Failed to save:`,e)}}function oo({ready:e,setLeftTabs:t,setRightTabs:n,setLeftActiveTabId:r,setRightActiveTabId:i,leftTabSelectionRef:a,rightTabSelectionRef:o,prevLeftActiveTabIdRef:s,prevRightActiveTabIdRef:l,onAfterRestore:u}){let d=B(),[f,p]=(0,c.useState)(!1),m=(0,c.useRef)({}),[h,g]=(0,c.useState)(!1),[_,v]=(0,c.useState)(void 0),[y,b]=(0,c.useState)(void 0),[x,S]=(0,c.useState)(void 0);return(0,c.useEffect)(()=>{no(d).then(e=>{m.current=e,g(!0)})},[]),(0,c.useEffect)(()=>{if(!e||!h)return;let c=m.current,d=e=>e?.tabs?.length?e.tabs.map(e=>e.type===`filelist`?_i(e.path):{id:gi(),type:`preview`,path:e.path,name:e.name,size:e.size,isTemp:!1}):e?.currentPath?[_i(e.currentPath)]:null,f=(e,t,n)=>{if(!(!t?.length||!n?.tabs?.length))for(let r=0;r<t.length&&r<n.tabs.length;r++){let i=t[r],a=n.tabs[r];i.type===`filelist`&&a.type===`filelist`&&(a.selectedName!=null||a.topmostName!=null)&&(e.current[i.id]={selectedName:a.selectedName,topmostName:a.topmostName})}},g=d(c.leftPanel),_=d(c.rightPanel);g&&f(a,g,c.leftPanel),_&&f(o,_,c.rightPanel);let y=g?Math.min(c.leftPanel?.activeTabIndex??0,g.length-1):0,x=_?Math.min(c.rightPanel?.activeTabIndex??0,_.length-1):0,C=g?.[y]?.id,w=_?.[x]?.id;C&&(s.current=C),w&&(l.current=w),g&&t(g),_&&n(_),C&&r(C),w&&i(w),c.leftPanel&&v(c.leftPanel),c.rightPanel&&b(c.rightPanel),c.activePanel&&S(c.activePanel),p(!0),u()},[e,h]),{settingsLoaded:f,initialLeftPanel:_,initialRightPanel:y,initialActivePanel:x,setInitialLeftPanel:v,setInitialRightPanel:b,setInitialActivePanel:S}}function so({activePanel:e,settingsLoaded:t,left:n,right:r,leftTabsRef:i,rightTabsRef:a,leftActiveTabIdRef:o,rightActiveTabIdRef:s,leftTabSelectionRef:l,rightTabSelectionRef:u,leftSelectedNameRef:d,rightSelectedNameRef:f,setLeftTabs:p,setRightTabs:m,setLeftActiveTabId:h,setRightActiveTabId:g}){let _=B(),v=(0,c.useRef)(null),y=(0,c.useRef)({}),b=(0,c.useCallback)((e,t,n)=>{let r=e===`left`?l:u;return{tabs:t.map(e=>{if(e.type===`filelist`){let t=r.current[e.id],n={type:`filelist`,path:e.path};return t?.selectedName!=null&&(n.selectedName=t.selectedName),t?.topmostName!=null&&(n.topmostName=t.topmostName),n}return{type:`preview`,path:e.path,name:e.name,size:e.size}}),activeTabIndex:Math.max(0,t.findIndex(e=>e.id===n))}},[l,u]),x=(0,c.useCallback)(()=>{v.current&&=(clearTimeout(v.current),null);let e=y.current;for(let t of Zi){let c=Xi[t];e[c]||(e[c]={currentPath:t===`left`?n.currentPath:r.currentPath});let l=t===`left`?i:a,u=t===`left`?o:s;Object.assign(e[c],b(t,l.current,u.current))}ro(_,e),io(_),y.current={}},[b,n.currentPath,r.currentPath,i,a,o,s]),S=(0,c.useCallback)(()=>{v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{v.current=null,ro(_,y.current),y.current={}},1e4)},[_]);(0,c.useEffect)(()=>{let e=()=>{x()};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[x]);let C=(0,c.useCallback)((e,t,c)=>{let _=e===`left`?i:a,v=e===`left`?o:s,x=e===`left`?l:u,C=e===`left`?d:f,w=e===`left`?n:r,T=_.current.find(e=>e.id===v.current);T?.type===`filelist`&&(x.current[T.id]={selectedName:t,topmostName:c}),C.current=t,y.current[Xi[e]]={currentPath:w.currentPath,...b(e,_.current,v.current)},S();let E=Yi[e],D=E===`left`?i:a,O=E===`right`?m:p,k=E===`right`?g:h,A=D.current.find(t=>t.type===`preview`&&t.isTemp&&t.sourcePanel===e);if(!A||!t)return;let j=w.entries.find(e=>e.name===t);if(!j||j.type!==`file`)return;let ee=j.path,M=j.name,N=Number(j.meta.size);A.type===`preview`&&A.path===ee&&A.name===M||(O(t=>t.map(t=>t.id===A.id?{id:t.id,type:`preview`,path:ee,name:M,size:N,isTemp:!0,sourcePanel:e}:t)),k(A.id))},[n,r,b,S,i,a,o,s,l,u,d,f,m,p,g,h]);return(0,c.useEffect)(()=>{t&&ro(_,{activePanel:e})},[e,t]),{handlePanelStateChange:C}}function co(e){return Array.isArray(e)?e.filter(e=>{if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.command==`string`&&typeof t.key==`string`}).map(e=>({command:e.command,key:e.key,mac:typeof e.mac==`string`?e.mac:void 0,when:typeof e.when==`string`?e.when:void 0})):(console.error(`[userKeybindings] keybindings.json must be an array`),null)}async function lo(e){await Wn(e,{name:`userKeybindings`,getPath:async()=>G(await e.utils.getHomePath(),`.dotdir`,`keybindings.json`),validate:co,defaultValue:[],onLoad:e=>{V.setLayerKeybindings(`user`,e),console.log(`[userKeybindings] Applied ${e.length} keybindings`)}})}var uo=new Set([`png`,`jpg`,`jpeg`,`gif`,`bmp`,`webp`,`ico`,`svg`,`avif`,`tiff`,`tif`]),fo=new Set([`mp4`,`webm`,`ogv`,`ogg`,`mov`,`m4v`]);function po(e){let t=e.lastIndexOf(`.`);return t<0?``:e.slice(t+1).toLowerCase()}function mo(e){return uo.has(po(e))}function ho(e){return fo.has(po(e))}function go(e){return mo(e)||ho(e)}var _o=`_app_4bfa7_56`,vo=`_loading_4bfa7_69`,yo={"dotdir-root":`_dotdir-root_4bfa7_1`,app:_o,"status-bar":`_status-bar_4bfa7_64`,loading:vo};function bo({widget:e}){let t=(0,c.useRef)(null),n=B(),{settings:r,ready:i,updateSettings:a}=nr(),o=(0,c.useRef)(r);o.current=r;let s=(0,d.useSetAtom)(ke),{dialog:u,showDialog:f}=_e(),[p,m]=(0,d.useAtom)(Pe),h=(0,c.useCallback)(e=>{f({type:`message`,title:`Error`,message:e,variant:`error`})},[f]),g=Xa(h),_=Xa(h),[y,b]=(0,d.useAtom)(Ne),x=(0,d.useAtomValue)(Ae),[S,w]=(0,d.useAtom)(Ie),[T,E]=(0,d.useAtom)(Le),[D,O]=(0,c.useState)(null),[k,A]=(0,c.useState)(null),j=(0,d.useAtomValue)(Se),ee=(0,d.useSetAtom)(Ce),M=(0,d.useSetAtom)(we),[N,te]=(0,c.useState)(0),[ne,P]=(0,d.useAtom)(xi),[F,I]=(0,d.useAtom)(Si),[L,re]=(0,d.useAtom)(Ci),[ie,R]=(0,d.useAtom)(wi),z=(0,c.useRef)(void 0),oe=(0,c.useRef)(void 0),se=(0,c.useRef)({}),ce=(0,c.useRef)({}),le=(0,c.useRef)(L),ue=(0,c.useRef)(ie),de=(0,d.useAtomValue)(Te),fe=(0,d.useAtomValue)(Ee),pe=(0,c.useRef)(ne);pe.current=ne;let me=(0,c.useRef)(F);me.current=F;let he=(0,c.useRef)(L);he.current=L;let ve=(0,c.useRef)(ie);ve.current=ie;let[ye,be]=(0,c.useState)(0),xe=ot(),De=(0,d.useSetAtom)(ze),Oe=(0,d.useAtomValue)(Be),je=(0,c.useRef)(()=>{});Oe&&(je.current=Oe),(0,c.useEffect)(()=>{i&&(r.iconTheme&&ee(r.iconTheme),r.colorTheme!==void 0&&M(r.colorTheme||void 0),r.editorFileSizeLimit!==void 0&&te(r.editorFileSizeLimit),r.showHidden!==void 0&&m(r.showHidden))},[r,i]);let{settingsLoaded:Me,initialLeftPanel:Fe,initialRightPanel:Re,initialActivePanel:Ve,setInitialLeftPanel:He,setInitialRightPanel:Ue,setInitialActivePanel:Ge}=oo({ready:i,setLeftTabs:P,setRightTabs:I,setLeftActiveTabId:re,setRightActiveTabId:R,leftTabSelectionRef:se,rightTabSelectionRef:ce,prevLeftActiveTabIdRef:le,prevRightActiveTabIdRef:ue,onAfterRestore:(0,c.useCallback)(()=>{lo(n)},[n])}),Ke=(0,c.useRef)(y);Ke.current=y;let qe=(0,c.useRef)(g.navigateTo);qe.current=y===`left`?g.navigateTo:_.navigateTo;let Je=(0,c.useRef)(g);Je.current=g;let Ye=(0,c.useRef)(_);Ye.current=_;let Xe=(0,c.useRef)(``),Ze=(0,c.useCallback)(async e=>{let t=oa(e);if(!t){Ot.runCommand(e,Xe.current);return}if(t.kind===`error`){f({type:`message`,title:`cd`,message:t.message,variant:`error`});return}let r=Ke.current===`left`?Je.current:Ye.current,i=r.currentPath;if(t.kind===`setAlias`){a({pathAliases:{...o.current.pathAliases,[t.alias]:Q(i)}});return}if(t.kind===`goAlias`){let e=o.current.pathAliases?.[t.alias];if(!e){f({type:`message`,title:`cd`,message:`Unknown alias: ${t.alias}`,variant:`error`});return}let i=Q(mt(U(e)));if(!await ca(n,i)){f({type:`message`,title:`cd`,message:`Folder not found: ${i}`,variant:`error`});return}await r.navigateTo(i);return}if(t.kind===`chdir`){let e=await sa(n,t.pathArg,i);if(!await ca(n,e)){f({type:`message`,title:`cd`,message:`Path not found: ${e}`,variant:`error`});return}await r.navigateTo(e)}},[f]);(0,c.useEffect)(()=>{De(()=>Ze)},[Ze,De]);let{handleCopy:Qe,handleMove:$e,handleMoveToTrash:et,handlePermanentDelete:tt,handleRename:nt}=aa(Ke,Je,Ye,be);(0,c.useEffect)(()=>{Ir({moveToTrash:et,permanentDelete:tt,copy:Qe,move:$e,rename:nt,pasteToCommandLine:e=>je.current(e)})},[et,tt,Qe,$e,nt]),(0,c.useEffect)(()=>{V.setContext(`leftPanelActive`,y===`left`),V.setContext(`rightPanelActive`,y===`right`)},[y]),(0,c.useEffect)(()=>{V.setContext(`dialogOpen`,u!==null)},[u]);let it=(0,c.useCallback)((e,t,n)=>{if(Kt.resolve(K(e))){qe.current(e+`\0`);return}w({path:e,name:t,size:n,panel:Ke.current})},[]),st=(0,c.useCallback)((e,t,n,r)=>{E({path:e,name:t,size:n,langId:r})},[]),ct=(0,c.useCallback)(async(e,t,r)=>{let i=await n.fs.exists(e);i||await n.fs.writeFile(e,``),E({path:e,name:t,size:i?(await n.fs.stat(e)).size:0,langId:r})},[]),lt=S?S.panel===`left`?g.entries:_.entries:[],ut=(0,c.useCallback)((e,t)=>t.some(t=>{if(t.startsWith(`*.`)){let n=t.slice(1).toLowerCase();return e.toLowerCase().endsWith(n)}return e.toLowerCase()===t.toLowerCase()}),[]),dt=(0,c.useCallback)(e=>S?(p?lt:lt.filter(e=>!e.meta.hidden)).filter(t=>t.type===`file`&&ut(t.name,e)).map(e=>({path:e.path,name:e.name,size:Number(e.meta.size)})).sort((e,t)=>e.name.localeCompare(t.name)):[],[S,lt,p,ut]),ft=(0,c.useCallback)(async(e,t)=>{let{patterns:n}=t??{};if(!n||!S)return;let r=dt(n),i=r.findIndex(e=>e.path===S.path);if(e===`navigatePrev`){if(i>0){let e=r[i-1];w(t=>t?{...e,panel:t.panel}:null)}return}if(e===`navigateNext`){if(i>=0&&i<r.length-1){let e=r[i+1];w(t=>t?{...e,panel:t.panel}:null)}return}if(e===`getFileIndex`)return{index:i,total:r.length}},[S,dt]),pt=S?Wt.resolve(S.name):null,W=T?Gt.resolve(T.name):null;(0,c.useEffect)(()=>{pt&&O(e=>e?.dirPath===pt.extensionDirPath&&e?.entry===pt.contribution.entry?e:{dirPath:pt.extensionDirPath,entry:pt.contribution.entry})},[pt?.extensionDirPath,pt?.contribution.entry]),(0,c.useEffect)(()=>{W&&A(e=>e?.dirPath===W.extensionDirPath&&e?.entry===W.contribution.entry?e:{dirPath:W.extensionDirPath,entry:W.contribution.entry})},[W?.extensionDirPath,W?.contribution.entry]);let G=S&&go(S.name)?S.name:void 0,ht=g.requestedCursor??(S?.panel===`left`?G:void 0),gt=_.requestedCursor??(S?.panel===`right`?G:void 0),{handlePanelStateChange:_t}=so({activePanel:y,settingsLoaded:Me,left:g,right:_,leftTabsRef:pe,rightTabsRef:me,leftActiveTabIdRef:he,rightActiveTabIdRef:ve,leftTabSelectionRef:se,rightTabSelectionRef:ce,leftSelectedNameRef:z,rightSelectedNameRef:oe,setLeftTabs:P,setRightTabs:I,setLeftActiveTabId:re,setRightActiveTabId:R}),vt=(0,c.useCallback)(()=>{let e=Ke.current,t=Yi[e],n=e===`left`?g.currentPath:_.currentPath,r=(t===`left`?he:ve).current,i=t===`left`?P:I,a=t===`left`?g:_;i(e=>e.map(e=>e.id===r&&e.type===`filelist`?{...e,path:n}:e)),a.navigateTo(n),b(t)},[g.currentPath,_.currentPath,g,_]),yt=(0,c.useCallback)(()=>{let e=Ke.current,t=Yi[e],n=e===`left`?g.currentPath:_.currentPath,r=_i(n),i=t===`left`?P:I,a=t===`left`?re:R,o=t===`left`?g:_;i(e=>[...e,r]),a(r.id),o.navigateTo(n),b(t)},[g.currentPath,_.currentPath,g,_]),bt=(0,c.useCallback)(()=>{let e=Ke.current,t=e===`left`?g.entries:_.entries,n=e===`left`?z.current:oe.current,r=n?t.find(e=>e.name===n):void 0;if(!r||r.type!==`folder`)return;let i=r.path,a=Yi[e],o=(a===`left`?he:ve).current,s=a===`left`?P:I,c=a===`left`?g:_;s(e=>e.map(e=>e.id===o&&e.type===`filelist`?{...e,path:i}:e)),c.navigateTo(i),b(a)},[g.entries,_.entries,g,_]),xt=(0,c.useCallback)(()=>{let e=Ke.current,t=e===`left`?g.entries:_.entries,n=e===`left`?z.current:oe.current,r=n?t.find(e=>e.name===n):void 0;if(!r||r.type!==`folder`)return;let i=r.path,a=Yi[e],o=_i(i),s=a===`left`?P:I,c=a===`left`?re:R,l=a===`left`?g:_;s(e=>[...e,o]),c(o.id),l.navigateTo(i),b(a)},[g.entries,_.entries,g,_]),St=(0,c.useCallback)(()=>{let e=Ke.current,t=e===`left`?g.entries:_.entries,n=e===`left`?z.current:oe.current,r=n?t.find(e=>e.name===n):void 0;if(!r||r.type!==`file`)return;let i=r.path,a=r.name,o=Number(r.meta.size),s=e,c=Yi[e],l=(c===`left`?pe:me).current,u=c===`left`?P:I,d=c===`left`?re:R,f=l.find(e=>e.type===`preview`&&e.isTemp);if(f&&f.type===`preview`)u(e=>e.map(e=>e.id===f.id?{...e,path:i,name:a,size:o,sourcePanel:s}:e)),d(f.id);else{let e=vi(i,a,o,s);u(t=>[...t,e]),d(e.id)}b(c)},[g.entries,_.entries]);(0,c.useEffect)(()=>(n.theme.get().then(e=>s(e)),n.theme.onChange(e=>s(e))),[]);let Ct=(0,c.useRef)(g.currentPath);Ct.current=g.currentPath;let wt=(0,c.useRef)(_.currentPath);wt.current=_.currentPath,(0,c.useEffect)(()=>{if(le.current===L)return;le.current=L;let e=pe.current.find(e=>e.id===L);e?.type===`filelist`&&e.path!=null&&g.navigateTo(e.path)},[L]),(0,c.useEffect)(()=>{if(ue.current===ie)return;ue.current=ie;let e=me.current.find(e=>e.id===ie);e?.type===`filelist`&&e.path!=null&&_.navigateTo(e.path)},[ie]);let Tt=(0,c.useRef)(g.currentPath),Et=(0,c.useRef)(_.currentPath);(0,c.useEffect)(()=>{Tt.current!==g.currentPath&&(Tt.current=g.currentPath,P(e=>{let t=e.findIndex(e=>e.id===L);if(t<0)return e;let n=e[t];if(n?.type!==`filelist`||n.path===g.currentPath)return e;let r=[...e];return r[t]={...n,path:g.currentPath},r}))},[g.currentPath,L]),(0,c.useEffect)(()=>{Et.current!==_.currentPath&&(Et.current=_.currentPath,I(e=>{let t=e.findIndex(e=>e.id===ie);if(t<0)return e;let n=e[t];if(n?.type!==`filelist`||n.path===_.currentPath)return e;let r=[...e];return r[t]={...n,path:_.currentPath},r}))},[_.currentPath,ie]),(0,c.useEffect)(()=>{if(!Me)return;let e=async(e,t,r)=>{let i=t?.currentPath??r;i&&(await n.fs.exists(i)||(i=await qa(n,i))),i||=await n.utils.getHomePath(),await e.navigateTo(i)};e(g,Fe),e(_,Re),Ve&&b(Ve),setTimeout(()=>{He(void 0),Ue(void 0),Ge(void 0)},500)},[Me]),ra({settingsLoaded:Me,onRefreshPanels:()=>{Je.current.refresh(),Ye.current.refresh()}});let Dt=(0,c.useCallback)(e=>{(Ke.current===`left`?Je.current:Ye.current).navigateTo(e)},[]),Ot=Za({activePanelCwd:y===`left`?g.currentPath:_.currentPath,onNavigatePanel:Dt});return Xe.current=Ot.activeCwd,Va({leftRef:Je,rightRef:Ye,onPreviewInOppositePanel:St,onOpenCurrentFolderInOppositeCurrentTab:vt,onOpenCurrentFolderInOppositeNewTab:yt,onOpenSelectedFolderInOppositeCurrentTab:bt,onOpenSelectedFolderInOppositeNewTab:xt,onOpenCreateFileConfirm:ct,showDialog:f,onViewFile:it,onEditFile:st,onExecuteInTerminal:e=>Ot.writeToTerminal(e),editorFileSizeLimit:N}),(0,c.useEffect)(()=>{let e=e=>{let t=e;if(!t)return!1;let n=t.tagName?.toLowerCase();return n===`input`||n===`textarea`||n===`select`||t.isContentEditable},n=n=>{let r=t.current,i=n.target;if(!r||!i||!r.contains(i)||e(i))return;let a=v.current;a!==`panel`&&a!==`viewer`&&a!==`editor`||V.handleKeyboardEvent(n)};return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[]),(0,c.useEffect)(()=>{if(n.onReconnect)return n.onReconnect(()=>{Je.current.navigateTo(Ct.current),Ye.current.navigateTo(wt.current)})},[]),!g.currentPath||!_.currentPath||!fe?(0,l.jsx)(`div`,{className:yo.loading,children:`Loading...`}):(0,l.jsxs)(`div`,{ref:t,className:yo.app,children:[(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:H[`terminal-and-panels`],children:[(0,l.jsx)(`div`,{className:H[`terminal-background`],children:(0,l.jsx)(Ji,{})}),(0,l.jsxs)(`div`,{className:C(Z,`panels-overlay`,!x&&`hidden`),children:[(0,l.jsx)(Mi,{side:`left`,panel:g,onRememberExpectedTerminalCwd:Ot.rememberExpectedTerminalCwd,selectionKey:ye,requestedActiveName:ht,initialPanelState:Fe,onStateChange:(e,t)=>_t(`left`,e,t)}),(0,l.jsx)(Mi,{side:`right`,panel:_,onRememberExpectedTerminalCwd:Ot.rememberExpectedTerminalCwd,selectionKey:ye,requestedActiveName:gt,initialPanelState:Re,onStateChange:(e,t)=>_t(`right`,e,t)})]})]}),(0,l.jsx)(rt,{}),(0,l.jsx)(qi,{})]}),(0,l.jsxs)(`div`,{className:yo[`status-bar`],children:[(0,l.jsx)(We,{}),e]}),S&&!pt&&(0,l.jsx)(ae,{title:`No viewer`,message:`No viewer extension found for this file type. Install viewer extensions (e.g. Image Viewer, File Viewer) from the extensions panel.`,onClose:()=>w(null)}),D&&(0,l.jsx)(pn,{extensionDirPath:D.dirPath,entry:D.entry,filePath:S?.path??``,fileName:S?.name??``,fileSize:S?.size??0,visible:S!=null&&pt!=null,onClose:()=>w(null),onExecuteCommand:ft},`viewer:${D.dirPath}:${D.entry}`),T&&!W&&(0,l.jsx)(ae,{title:`No editor`,message:`No editor extension found for this file type. Install an editor extension (e.g. Monaco Editor) from the extensions panel.`,onClose:()=>E(null)}),k&&(()=>{let e=de.flatMap(e=>e.languages??[]),t=de.flatMap(e=>e.grammarRefs??[]).map(e=>({contribution:e.contribution,path:e.path}));return(0,l.jsx)(mn,{extensionDirPath:k.dirPath,entry:k.entry,filePath:T?.path??``,fileName:T?.name??``,langId:T?.langId??`plaintext`,visible:T!=null&&W!=null,onClose:()=>E(null),languages:e,grammars:t},`editor:${k.dirPath}:${k.entry}`)})(),j&&(0,l.jsx)(cr,{}),(0,l.jsx)(ge,{}),(0,l.jsx)(at,{open:xe.open,onOpenChange:xe.setOpen})]})}function xo({bridge:e,widget:t}){let n=(0,c.useRef)(null);return(0,c.useEffect)(()=>{V.registerContributions(be)},[]),(0,c.useEffect)(()=>{let e=n.current;if(e)return At(e),()=>{n.current===e&&At(null)}},[]),(0,l.jsx)(`div`,{ref:n,className:yo[`dotdir-root`],children:(0,l.jsx)(d.Provider,{children:(0,l.jsx)(ye,{bridge:e,children:(0,l.jsx)(_,{children:(0,l.jsx)(pe,{children:(0,l.jsx)(bo,{widget:t})})})})})})}exports.DotDir=xo,exports.basename=K,exports.dirname=W,exports.join=G,exports.normalizePath=U;
130
+ `,spawnArgs:[]}}function ta(e,t,n){let r=ea(n.shell);return{id:e,label:t,shell:e,hiddenCdTemplate:n.hiddenCdTemplate??r.hiddenCdTemplate,cwdEscape:n.cwdEscape??r.cwdEscape,lineEnding:n.lineEnding??r.lineEnding,spawnArgs:n.spawnArgs??r.spawnArgs}}async function na(e,t,n){let r=n.__platform__??``,i=n.SHELL??``,a=[],o={},s=new Set,c=[];for(let e of t)for(let t of e.shellIntegrations??[])Qi(t.platforms,r)&&c.push(t);if(i&&r!==`windows`){let t=i.split(`/`).pop()??``,n=c.find(e=>e.shell===t);if(n&&!s.has(i))try{await e.fs.exists(i)&&(s.add(i),a.push(ta(i,n.label,n)),o[i]={script:n.script,scriptArg:n.scriptArg??!1})}catch{}}for(let t of c)for(let r of t.executableCandidates){let i=$i(r,n);if(!(!i||s.has(i)))try{if(await e.fs.exists(i)){s.add(i),a.push(ta(i,t.label,t)),o[i]={script:t.script,scriptArg:t.scriptArg??!1};break}}catch{}}return{profiles:a,shellScripts:o}}function ra({settingsLoaded:e,onRefreshPanels:t}){let n=B(),r=bn(),i=(0,d.useAtomValue)(Ce),a=(0,d.useAtomValue)(we),o=(0,d.useAtomValue)(ke),s=(0,d.useSetAtom)(Te),l=(0,d.useSetAtom)(Ee),u=(0,d.useSetAtom)(De),f=(0,d.useSetAtom)(Oe),{setIconTheme:p}=Or(),{setIconThemeKind:m}=kr(),h=(0,c.useRef)(i);h.current=i;let g=(0,c.useRef)(a);g.current=a;let _=(0,c.useRef)(t);_.current=t;let v=(0,c.useRef)([]),y=(0,c.useRef)([]),b=(0,c.useRef)(!1);(0,c.useEffect)(()=>{let e=a?Ln(v.current,a):null,t=e?cn(e.theme.uiTheme):o===`light`||o===`high-contrast-light`?`light`:`dark`;Nt().dataset.theme=t,m(t)},[o,a]);let x=(0,c.useCallback)(async(e,t)=>{if(!t)return;let r=e.find(e=>`${e.ref.publisher}.${e.ref.name}`===t);if(r?.iconThemeFssPath&&!r.iconThemeFss)try{r.iconThemeFss=await St(n,r.iconThemeFssPath),r.iconThemeBasePath||=W(r.iconThemeFssPath)}catch{}},[n]);(0,c.useEffect)(()=>{b.current&&(async()=>{let e=v.current;if(await x(e,i),Vr(e,i),!i)p(`fss`);else{let t=e.find(e=>`${e.ref.publisher}.${e.ref.name}`===i);t?.vscodeIconThemePath?p(`vscode`,t.vscodeIconThemePath):t?.iconThemeFssPath?p(`fss`):p(`none`)}_.current()})()},[i,x]),(0,c.useEffect)(()=>{if(b.current)if(!a)sn();else{let e=Ln(v.current,a);e&&ln(n,e.theme.jsonPath,e.theme.uiTheme).catch(()=>sn())}},[a]),(0,c.useEffect)(()=>{if(!e)return;le.initialize();let t=async e=>{le.clear();for(let t of e)if(t.languages)for(let e of t.languages)le.registerLanguage(e);await le.activateGrammars()},i=async(e,t)=>{if(!t){await p(`fss`);return}let n=e.find(e=>`${e.ref.publisher}.${e.ref.name}`===t);n?.vscodeIconThemePath?await p(`vscode`,n.vscodeIconThemePath):n?.iconThemeFssPath?await p(`fss`):await p(`none`)},a=async(e,t)=>{if(!t){sn();return}let r=Ln(e,t);if(r){let e=cn(r.theme.uiTheme);Nt().dataset.theme=e,m(e);try{await ln(n,r.theme.jsonPath,r.theme.uiTheme)}catch(e){console.warn(`[ExtHost] Failed to load color theme:`,t,e),sn()}}else sn()},o=e=>{for(let e of y.current)try{e()}catch{}y.current=[];for(let t of e){if(t.commands){let e=V.registerContributions(t.commands);y.current.push(e);for(let e of t.commands){let t=V.registerCommand(e.command,async(...t)=>{await r.executeCommand(e.command,t)});y.current.push(t)}}t.keybindings?.length&&y.current.push(...et(V,t.keybindings))}},c=r.onLoaded(e=>{(async()=>{if(v.current=e,s(e),Yt(e),Ot(),n.fsProvider){for(let t of e)for(let e of t.fsProviders??[])if(e.runtime===`backend`){let r=G(t.dirPath,e.entry);n.fsProvider.load(r).catch(()=>{})}}n.utils.getEnv().then(t=>na(n,e,t).then(({profiles:e,shellScripts:t})=>{u(e),f(!0),n.pty.setShellIntegrations&&Object.keys(t).length>0&&n.pty.setShellIntegrations(t).catch(()=>{})})).catch(()=>{f(!0)}),await x(e,h.current),Vr(e,h.current),t(e),o(e),Promise.all([i(e,h.current),a(e,g.current)]).then(()=>{l(!0),b.current=!0,_.current()})})()});return r.start(),()=>{c();for(let e of y.current)try{e()}catch{}y.current=[],r.dispose()}},[e,x,s,u,f,l])}async function ia(e,t,n){let r=await e(t);if(r.length===0)return[{innerPath:t,destRelPath:n}];let i=[];for(let a of r){let r=t===`/`?`/${a.name}`:`${t}/${a.name}`,o=`${n}/${a.name}`;i.push(...await ia(e,r,o))}return i}function aa(e,t,n,r){let{showDialog:i,closeDialog:a,updateDialog:o}=_e(),s=B(),l=(0,c.useRef)(null),u=(0,c.useRef)(null),d=(0,c.useRef)(null),f=(0,c.useRef)(null),p=(0,c.useRef)(null),m=(0,c.useRef)(null),h=(0,c.useCallback)(()=>{r(e=>e+1),t.current.navigateTo(t.current.currentPath),n.current.navigateTo(n.current.currentPath)},[r,t,n]),g=(0,c.useCallback)((e,t)=>{e.length!==0&&i({type:`message`,title:`Move to Trash`,message:e.length===1?`Move "${K(e[0])}" to Trash?`:`Move ${e.length} items to Trash?`,variant:`default`,buttons:[{label:`Cancel`},{label:`Move to Trash`,default:!0,onClick:async()=>{try{await s.fs.moveToTrash(e),t()}catch(e){i({type:`message`,title:`Error`,message:e instanceof Error?e.message:String(e),variant:`error`})}}}]})},[i]),_=(0,c.useCallback)((e,t)=>{e.length!==0&&i({type:`message`,title:`Permanently Delete`,message:e.length===1?`Permanently delete "${K(e[0])}"? This cannot be undone.`:`Permanently delete ${e.length} items? This cannot be undone.`,variant:`default`,buttons:[{label:`Cancel`},{label:`Delete`,default:!0,onClick:async()=>{try{let t={type:`deleteProgress`,filesDone:0,currentFile:`Preparing...`,onCancel:()=>{i({type:`cancelDeleteConfirm`,onResume:()=>{m.current&&i(m.current)},onCancelDeletion:()=>{p.current!==null&&s.fs.delete.cancel(p.current),p.current=null,m.current=null,a()}})}};m.current=t,i(t);let n=await s.fs.delete.start(e);m.current!==null&&(p.current=n)}catch(e){p.current=null,m.current=null,a(),i({type:`message`,title:`Error`,message:e instanceof Error?e.message:String(e),variant:`error`})}}}]})},[i,a]),v=(0,c.useCallback)((r,c)=>{let d=(e.current===`left`?n.current:t.current).currentPath;!d||r.length===0||i({type:`copyConfig`,itemCount:r.length,destPath:d,onConfirm:async(e,t)=>{try{if(r.some(e=>Pt(e))){if(!r.every(e=>Pt(e)))throw Error(`Cannot copy files from archives and local files in the same operation`);let e={type:`copyProgress`,bytesCopied:0,bytesTotal:0,filesDone:0,filesTotal:0,currentFile:`Collecting files...`,onCancel:a};u.current=e,i(e);let n=[];for(let e of r){let{containerFile:t,innerPath:r}=Ft(e),i=Jt.resolve(K(t));if(!i)throw Error(`No fsProvider registered for "${K(t)}"`);let a=null,o=null;i.contribution.runtime===`backend`&&s.fsProvider?a=G(i.extensionDirPath,i.contribution.entry):o=await Dt(s,i.extensionDirPath,i.contribution.entry),(await ia(async e=>a?s.fsProvider.listEntries(a,t,e):(await o.listEntries(t,e)).map(e=>({name:e.name,kind:e.type})),r,K(r))).forEach(e=>n.push({...e,hostFile:t,wasmPath:a,provider:o}))}o({filesTotal:n.length,currentFile:`Extracting...`}),u.current={...e,filesTotal:n.length,currentFile:`Extracting...`};let l=0;for(let{innerPath:e,destRelPath:r,hostFile:i,wasmPath:a,provider:c}of n){let n=G(t,r);o({currentFile:K(r),filesDone:l}),s.fs.createDir&&await s.fs.createDir(W(n)).catch(()=>{});let u;if(a)u=await s.fsProvider.readFileRange(a,i,e,0,64*1024*1024);else{if(!c?.readFileRange)throw Error(`Provider does not support readFileRange`);u=await c.readFileRange(i,e,0,64*1024*1024)}await s.fs.writeBinaryFile(n,new Uint8Array(u)),l++}u.current=null,a(),c();return}let n={type:`copyProgress`,bytesCopied:0,bytesTotal:0,filesDone:0,filesTotal:0,currentFile:`Preparing...`,onCancel:()=>{i({type:`cancelCopyConfirm`,onResume:()=>{u.current&&i(u.current)},onCancelCopy:()=>{l.current!==null&&s.fs.copy.cancel(l.current),l.current=null,u.current=null,a(),c()}})}};u.current=n,i(n);let d=await s.fs.copy.start(r,t,e);u.current!==null&&(l.current=d)}catch(e){l.current=null,u.current=null,a(),i({type:`message`,title:`Copy Error`,message:e instanceof Error?e.message:String(e),variant:`error`})}},onCancel:()=>{}})},[i,a]);(0,c.useEffect)(()=>s.fs.copy.onProgress(e=>{if(l.current===null)if(u.current!==null)l.current=e.copyId;else return;else if(e.copyId!==l.current)return;let t=e.event;switch(t.kind){case`progress`:{let e={bytesCopied:t.bytesCopied,bytesTotal:t.bytesTotal,filesDone:t.filesDone,filesTotal:t.filesTotal,currentFile:t.currentFile};u.current&&={...u.current,...e},o(e);break}case`conflict`:i({type:`copyConflict`,src:t.src,dest:t.dest,srcSize:t.srcSize,srcMtimeMs:t.srcMtimeMs,destSize:t.destSize,destMtimeMs:t.destMtimeMs,onResolve:e=>{s.fs.copy.resolveConflict(l.current,e),u.current&&i(u.current)}});break;case`done`:l.current=null,u.current=null,a(),h();break;case`error`:l.current=null,u.current=null,a(),i({type:`message`,title:`Copy Error`,message:t.message,variant:`error`}),h();break}}),[i,a,o,h]);let y=(0,c.useCallback)((r,o)=>{let c=(e.current===`left`?n.current:t.current).currentPath;!c||r.length===0||i({type:`moveConfig`,itemCount:r.length,destPath:c,onConfirm:async(e,t)=>{try{let n={type:`moveProgress`,bytesCopied:0,bytesTotal:0,filesDone:0,filesTotal:0,currentFile:`Preparing...`,onCancel:()=>{i({type:`cancelMoveConfirm`,onResume:()=>{f.current&&i(f.current)},onCancelMove:()=>{d.current!==null&&s.fs.move.cancel(d.current),d.current=null,f.current=null,a(),o()}})}};f.current=n,i(n);let c=await s.fs.move.start(r,t,e);f.current!==null&&(d.current=c)}catch(e){d.current=null,f.current=null,a(),i({type:`message`,title:`Move Error`,message:e instanceof Error?e.message:String(e),variant:`error`})}},onCancel:()=>{}})},[i,a]);return(0,c.useEffect)(()=>s.fs.move.onProgress(e=>{if(d.current===null)if(f.current!==null)d.current=e.moveId;else return;else if(e.moveId!==d.current)return;let t=e.event;switch(t.kind){case`progress`:{let e={bytesCopied:t.bytesCopied,bytesTotal:t.bytesTotal,filesDone:t.filesDone,filesTotal:t.filesTotal,currentFile:t.currentFile};f.current&&={...f.current,...e},o(e);break}case`conflict`:i({type:`moveConflict`,src:t.src,dest:t.dest,srcSize:t.srcSize,srcMtimeMs:t.srcMtimeMs,destSize:t.destSize,destMtimeMs:t.destMtimeMs,onResolve:e=>{s.fs.move.resolveConflict(d.current,e),f.current&&i(f.current)}});break;case`done`:d.current=null,f.current=null,a(),h();break;case`error`:d.current=null,f.current=null,a(),i({type:`message`,title:`Move Error`,message:t.message,variant:`error`}),h();break}}),[i,a,o,h]),(0,c.useEffect)(()=>s.fs.delete.onProgress(e=>{if(p.current===null)if(m.current!==null)p.current=e.deleteId;else return;else if(e.deleteId!==p.current)return;let t=e.event;switch(t.kind){case`progress`:{let e={filesDone:t.filesDone,currentFile:t.currentFile};m.current&&={...m.current,...e},o(e);break}case`done`:p.current=null,m.current=null,a(),h();break;case`error`:p.current=null,m.current=null,a(),i({type:`message`,title:`Delete Error`,message:t.message,variant:`error`}),h();break}}),[i,a,o,h]),{handleCopy:v,handleMove:y,handleMoveToTrash:g,handlePermanentDelete:_,handleRename:(0,c.useCallback)((e,t,n)=>{i({type:`rename`,currentName:t,onConfirm:async t=>{try{await s.fs.rename.rename(e,t),n()}catch(e){i({type:`message`,title:`Rename Error`,message:e instanceof Error?e.message:String(e),variant:`error`})}},onCancel:()=>{}})},[i])}}function oa(e){let t=e.trim();if(!t)return null;if(/^cd::/i.test(t)){let e=t.match(/^cd::\s*(\S+)\s*$/i);return e?{kind:`setAlias`,alias:e[1]}:{kind:`error`,message:`Usage: cd::alias — save current folder as alias`}}if(/^cd:/i.test(t)){let e=t.match(/^cd:\s*(\S+)\s*$/i);return e?{kind:`goAlias`,alias:e[1]}:{kind:`error`,message:`Usage: cd:alias — go to folder saved under alias`}}if(/^cd(?:\s|$)/i.test(t)||/^cd$/i.test(t)){let e=t.match(/^cd(?:\s+(.*))?$/i);if(!e)return null;let n=(e[1]??``).trim();return(n.startsWith(`"`)&&n.endsWith(`"`)||n.startsWith(`'`)&&n.endsWith(`'`))&&(n=n.slice(1,-1)),{kind:`chdir`,pathArg:n}}return null}async function sa(e,t,n){let r=t.trim();if(!r)return Q(await e.utils.getHomePath());let i=r;if(i.startsWith(`~`)){let t=await e.utils.getHomePath(),n=Q(t);if(i===`~`||i===`~/`)return n;let r=i.slice(1).replace(/^\//,``);i=r?G(t,r):t}return Q(mt(U(i.startsWith(`/`)||i.startsWith(`//`)||/^[A-Za-z]:\//.test(i)||/^[A-Za-z]:$/i.test(i)?i:G(n,i))))}async function ca(e,t){if(!await e.fs.exists(t))return!1;try{return await e.fs.entries(t),!0}catch{return!1}}function la(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function ua(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}var da,fa=`__TAURI_TO_IPC_KEY__`;function pa(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}async function $(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}var ma=class{get rid(){return la(this,da,`f`)}constructor(e){da.set(this,void 0),ua(this,da,e,`f`)}async close(){return $(`plugin:resources|close`,{rid:this.rid})}};da=new WeakMap;function ha(){return!!(globalThis||window).isTauri}var ga=class{constructor(...e){this.type=`Logical`,e.length===1?`Logical`in e[0]?(this.width=e[0].Logical.width,this.height=e[0].Logical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toPhysical(e){return new _a(this.width*e,this.height*e)}[fa](){return{width:this.width,height:this.height}}toJSON(){return this[fa]()}},_a=class{constructor(...e){this.type=`Physical`,e.length===1?`Physical`in e[0]?(this.width=e[0].Physical.width,this.height=e[0].Physical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toLogical(e){return new ga(this.width/e,this.height/e)}[fa](){return{width:this.width,height:this.height}}toJSON(){return this[fa]()}},va=class{constructor(e){this.size=e}toLogical(e){return this.size instanceof ga?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof _a?this.size:this.size.toPhysical(e)}[fa](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[fa]()}},ya=class{constructor(...e){this.type=`Logical`,e.length===1?`Logical`in e[0]?(this.x=e[0].Logical.x,this.y=e[0].Logical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toPhysical(e){return new ba(this.x*e,this.y*e)}[fa](){return{x:this.x,y:this.y}}toJSON(){return this[fa]()}},ba=class{constructor(...e){this.type=`Physical`,e.length===1?`Physical`in e[0]?(this.x=e[0].Physical.x,this.y=e[0].Physical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toLogical(e){return new ya(this.x/e,this.y/e)}[fa](){return{x:this.x,y:this.y}}toJSON(){return this[fa]()}},xa=class{constructor(e){this.position=e}toLogical(e){return this.position instanceof ya?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof ba?this.position:this.position.toPhysical(e)}[fa](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[fa]()}},Sa;(function(e){e.WINDOW_RESIZED=`tauri://resize`,e.WINDOW_MOVED=`tauri://move`,e.WINDOW_CLOSE_REQUESTED=`tauri://close-requested`,e.WINDOW_DESTROYED=`tauri://destroyed`,e.WINDOW_FOCUS=`tauri://focus`,e.WINDOW_BLUR=`tauri://blur`,e.WINDOW_SCALE_FACTOR_CHANGED=`tauri://scale-change`,e.WINDOW_THEME_CHANGED=`tauri://theme-changed`,e.WINDOW_CREATED=`tauri://window-created`,e.WEBVIEW_CREATED=`tauri://webview-created`,e.DRAG_ENTER=`tauri://drag-enter`,e.DRAG_OVER=`tauri://drag-over`,e.DRAG_DROP=`tauri://drag-drop`,e.DRAG_LEAVE=`tauri://drag-leave`})(Sa||={});async function Ca(e,t){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(e,t),await $(`plugin:event|unlisten`,{event:e,eventId:t})}async function wa(e,t,n){return $(`plugin:event|listen`,{event:e,target:typeof n?.target==`string`?{kind:`AnyLabel`,label:n.target}:n?.target??{kind:`Any`},handler:pa(t)}).then(t=>async()=>Ca(e,t))}async function Ta(e,t,n){return wa(e,n=>{Ca(e,n.id),t(n)},n)}async function Ea(e,t){await $(`plugin:event|emit`,{event:e,payload:t})}async function Da(e,t,n){await $(`plugin:event|emit_to`,{target:typeof e==`string`?{kind:`AnyLabel`,label:e}:e,event:t,payload:n})}var Oa=class e extends ma{constructor(e){super(e)}static async new(t,n,r){return $(`plugin:image|new`,{rgba:ka(t),width:n,height:r}).then(t=>new e(t))}static async fromBytes(t){return $(`plugin:image|from_bytes`,{bytes:ka(t)}).then(t=>new e(t))}static async fromPath(t){return $(`plugin:image|from_path`,{path:t}).then(t=>new e(t))}async rgba(){return $(`plugin:image|rgba`,{rid:this.rid}).then(e=>new Uint8Array(e))}async size(){return $(`plugin:image|size`,{rid:this.rid})}};function ka(e){return e==null?null:typeof e==`string`?e:e instanceof Oa?e.rid:e}var Aa;(function(e){e[e.Critical=1]=`Critical`,e[e.Informational=2]=`Informational`})(Aa||={});var ja=class{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}},Ma;(function(e){e.None=`none`,e.Normal=`normal`,e.Indeterminate=`indeterminate`,e.Paused=`paused`,e.Error=`error`})(Ma||={});function Na(){return new Ia(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function Pa(){return $(`plugin:window|get_all_windows`).then(e=>e.map(e=>new Ia(e,{skip:!0})))}var Fa=[`tauri://created`,`tauri://error`],Ia=class{constructor(e,t={}){this.label=e,this.listeners=Object.create(null),t?.skip||$(`plugin:window|create`,{options:{...t,parent:typeof t.parent==`string`?t.parent:t.parent?.label,label:e}}).then(async()=>this.emit(`tauri://created`)).catch(async e=>this.emit(`tauri://error`,e))}static async getByLabel(e){return(await Pa()).find(t=>t.label===e)??null}static getCurrent(){return Na()}static async getAll(){return Pa()}static async getFocusedWindow(){for(let e of await Pa())if(await e.isFocused())return e;return null}async listen(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:wa(e,t,{target:{kind:`Window`,label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:Ta(e,t,{target:{kind:`Window`,label:this.label}})}async emit(e,t){if(Fa.includes(e)){for(let n of this.listeners[e]||[])n({event:e,id:-1,payload:t});return}return Ea(e,t)}async emitTo(e,t,n){if(Fa.includes(t)){for(let e of this.listeners[t]||[])e({event:t,id:-1,payload:n});return}return Da(e,t,n)}_handleTauriEvent(e,t){return Fa.includes(e)?(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0):!1}async scaleFactor(){return $(`plugin:window|scale_factor`,{label:this.label})}async innerPosition(){return $(`plugin:window|inner_position`,{label:this.label}).then(e=>new ba(e))}async outerPosition(){return $(`plugin:window|outer_position`,{label:this.label}).then(e=>new ba(e))}async innerSize(){return $(`plugin:window|inner_size`,{label:this.label}).then(e=>new _a(e))}async outerSize(){return $(`plugin:window|outer_size`,{label:this.label}).then(e=>new _a(e))}async isFullscreen(){return $(`plugin:window|is_fullscreen`,{label:this.label})}async isMinimized(){return $(`plugin:window|is_minimized`,{label:this.label})}async isMaximized(){return $(`plugin:window|is_maximized`,{label:this.label})}async isFocused(){return $(`plugin:window|is_focused`,{label:this.label})}async isDecorated(){return $(`plugin:window|is_decorated`,{label:this.label})}async isResizable(){return $(`plugin:window|is_resizable`,{label:this.label})}async isMaximizable(){return $(`plugin:window|is_maximizable`,{label:this.label})}async isMinimizable(){return $(`plugin:window|is_minimizable`,{label:this.label})}async isClosable(){return $(`plugin:window|is_closable`,{label:this.label})}async isVisible(){return $(`plugin:window|is_visible`,{label:this.label})}async title(){return $(`plugin:window|title`,{label:this.label})}async theme(){return $(`plugin:window|theme`,{label:this.label})}async isAlwaysOnTop(){return $(`plugin:window|is_always_on_top`,{label:this.label})}async center(){return $(`plugin:window|center`,{label:this.label})}async requestUserAttention(e){let t=null;return e&&(t=e===Aa.Critical?{type:`Critical`}:{type:`Informational`}),$(`plugin:window|request_user_attention`,{label:this.label,value:t})}async setResizable(e){return $(`plugin:window|set_resizable`,{label:this.label,value:e})}async setEnabled(e){return $(`plugin:window|set_enabled`,{label:this.label,value:e})}async isEnabled(){return $(`plugin:window|is_enabled`,{label:this.label})}async setMaximizable(e){return $(`plugin:window|set_maximizable`,{label:this.label,value:e})}async setMinimizable(e){return $(`plugin:window|set_minimizable`,{label:this.label,value:e})}async setClosable(e){return $(`plugin:window|set_closable`,{label:this.label,value:e})}async setTitle(e){return $(`plugin:window|set_title`,{label:this.label,value:e})}async maximize(){return $(`plugin:window|maximize`,{label:this.label})}async unmaximize(){return $(`plugin:window|unmaximize`,{label:this.label})}async toggleMaximize(){return $(`plugin:window|toggle_maximize`,{label:this.label})}async minimize(){return $(`plugin:window|minimize`,{label:this.label})}async unminimize(){return $(`plugin:window|unminimize`,{label:this.label})}async show(){return $(`plugin:window|show`,{label:this.label})}async hide(){return $(`plugin:window|hide`,{label:this.label})}async close(){return $(`plugin:window|close`,{label:this.label})}async destroy(){return $(`plugin:window|destroy`,{label:this.label})}async setDecorations(e){return $(`plugin:window|set_decorations`,{label:this.label,value:e})}async setShadow(e){return $(`plugin:window|set_shadow`,{label:this.label,value:e})}async setEffects(e){return $(`plugin:window|set_effects`,{label:this.label,value:e})}async clearEffects(){return $(`plugin:window|set_effects`,{label:this.label,value:null})}async setAlwaysOnTop(e){return $(`plugin:window|set_always_on_top`,{label:this.label,value:e})}async setAlwaysOnBottom(e){return $(`plugin:window|set_always_on_bottom`,{label:this.label,value:e})}async setContentProtected(e){return $(`plugin:window|set_content_protected`,{label:this.label,value:e})}async setSize(e){return $(`plugin:window|set_size`,{label:this.label,value:e instanceof va?e:new va(e)})}async setMinSize(e){return $(`plugin:window|set_min_size`,{label:this.label,value:e instanceof va?e:e?new va(e):null})}async setMaxSize(e){return $(`plugin:window|set_max_size`,{label:this.label,value:e instanceof va?e:e?new va(e):null})}async setSizeConstraints(e){function t(e){return e?{Logical:e}:null}return $(`plugin:window|set_size_constraints`,{label:this.label,value:{minWidth:t(e?.minWidth),minHeight:t(e?.minHeight),maxWidth:t(e?.maxWidth),maxHeight:t(e?.maxHeight)}})}async setPosition(e){return $(`plugin:window|set_position`,{label:this.label,value:e instanceof xa?e:new xa(e)})}async setFullscreen(e){return $(`plugin:window|set_fullscreen`,{label:this.label,value:e})}async setSimpleFullscreen(e){return $(`plugin:window|set_simple_fullscreen`,{label:this.label,value:e})}async setFocus(){return $(`plugin:window|set_focus`,{label:this.label})}async setFocusable(e){return $(`plugin:window|set_focusable`,{label:this.label,value:e})}async setIcon(e){return $(`plugin:window|set_icon`,{label:this.label,value:ka(e)})}async setSkipTaskbar(e){return $(`plugin:window|set_skip_taskbar`,{label:this.label,value:e})}async setCursorGrab(e){return $(`plugin:window|set_cursor_grab`,{label:this.label,value:e})}async setCursorVisible(e){return $(`plugin:window|set_cursor_visible`,{label:this.label,value:e})}async setCursorIcon(e){return $(`plugin:window|set_cursor_icon`,{label:this.label,value:e})}async setBackgroundColor(e){return $(`plugin:window|set_background_color`,{color:e})}async setCursorPosition(e){return $(`plugin:window|set_cursor_position`,{label:this.label,value:e instanceof xa?e:new xa(e)})}async setIgnoreCursorEvents(e){return $(`plugin:window|set_ignore_cursor_events`,{label:this.label,value:e})}async startDragging(){return $(`plugin:window|start_dragging`,{label:this.label})}async startResizeDragging(e){return $(`plugin:window|start_resize_dragging`,{label:this.label,value:e})}async setBadgeCount(e){return $(`plugin:window|set_badge_count`,{label:this.label,value:e})}async setBadgeLabel(e){return $(`plugin:window|set_badge_label`,{label:this.label,value:e})}async setOverlayIcon(e){return $(`plugin:window|set_overlay_icon`,{label:this.label,value:e?ka(e):void 0})}async setProgressBar(e){return $(`plugin:window|set_progress_bar`,{label:this.label,value:e})}async setVisibleOnAllWorkspaces(e){return $(`plugin:window|set_visible_on_all_workspaces`,{label:this.label,value:e})}async setTitleBarStyle(e){return $(`plugin:window|set_title_bar_style`,{label:this.label,value:e})}async setTheme(e){return $(`plugin:window|set_theme`,{label:this.label,value:e})}async onResized(e){return this.listen(Sa.WINDOW_RESIZED,t=>{t.payload=new _a(t.payload),e(t)})}async onMoved(e){return this.listen(Sa.WINDOW_MOVED,t=>{t.payload=new ba(t.payload),e(t)})}async onCloseRequested(e){return this.listen(Sa.WINDOW_CLOSE_REQUESTED,async t=>{let n=new ja(t);await e(n),n.isPreventDefault()||await this.destroy()})}async onDragDropEvent(e){let t=await this.listen(Sa.DRAG_ENTER,t=>{e({...t,payload:{type:`enter`,paths:t.payload.paths,position:new ba(t.payload.position)}})}),n=await this.listen(Sa.DRAG_OVER,t=>{e({...t,payload:{type:`over`,position:new ba(t.payload.position)}})}),r=await this.listen(Sa.DRAG_DROP,t=>{e({...t,payload:{type:`drop`,paths:t.payload.paths,position:new ba(t.payload.position)}})}),i=await this.listen(Sa.DRAG_LEAVE,t=>{e({...t,payload:{type:`leave`}})});return()=>{t(),r(),n(),i()}}async onFocusChanged(e){let t=await this.listen(Sa.WINDOW_FOCUS,t=>{e({...t,payload:!0})}),n=await this.listen(Sa.WINDOW_BLUR,t=>{e({...t,payload:!1})});return()=>{t(),n()}}async onScaleChanged(e){return this.listen(Sa.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(Sa.WINDOW_THEME_CHANGED,e)}},La;(function(e){e.Disabled=`disabled`,e.Throttle=`throttle`,e.Suspend=`suspend`})(La||={});var Ra;(function(e){e.Default=`default`,e.FluentOverlay=`fluentOverlay`})(Ra||={});var za;(function(e){e.AppearanceBased=`appearanceBased`,e.Light=`light`,e.Dark=`dark`,e.MediumLight=`mediumLight`,e.UltraDark=`ultraDark`,e.Titlebar=`titlebar`,e.Selection=`selection`,e.Menu=`menu`,e.Popover=`popover`,e.Sidebar=`sidebar`,e.HeaderView=`headerView`,e.Sheet=`sheet`,e.WindowBackground=`windowBackground`,e.HudWindow=`hudWindow`,e.FullScreenUI=`fullScreenUI`,e.Tooltip=`tooltip`,e.ContentBackground=`contentBackground`,e.UnderWindowBackground=`underWindowBackground`,e.UnderPageBackground=`underPageBackground`,e.Mica=`mica`,e.Blur=`blur`,e.Acrylic=`acrylic`,e.Tabbed=`tabbed`,e.TabbedDark=`tabbedDark`,e.TabbedLight=`tabbedLight`})(za||={});var Ba;(function(e){e.FollowsWindowActiveState=`followsWindowActiveState`,e.Active=`active`,e.Inactive=`inactive`})(Ba||={});function Va(e){let t=B(),n=(0,c.useRef)(e);n.current=e;let r=(0,d.useAtomValue)(Te),i=(0,c.useRef)(r);i.current=r;let{updateSettings:a}=nr(),[o,s]=(0,d.useAtom)(Ne),l=(0,d.useSetAtom)(Pe),u=(0,d.useSetAtom)(Ae),f=(0,d.useSetAtom)(Se),p=(0,d.useSetAtom)(Ie),m=(0,d.useSetAtom)(Le),h=(0,d.useSetAtom)(Fe),g=(0,c.useRef)(o);g.current=o,(0,c.useEffect)(()=>{let e=[];return e.push(V.registerCommand(`dotdir.toggleHiddenFiles`,()=>l(e=>{let t=!e;return a({showHidden:t}),t}))),e.push(V.registerCommand(`dotdir.togglePanels`,()=>u(e=>{let t=!e;return t&&v.set(`panel`),t}))),e.push(V.registerCommand(`dotdir.showExtensions`,()=>f(!0))),e.push(V.registerCommand(`dotdir.showCommandPalette`,()=>h(e=>!e))),e.push(V.registerCommand(`dotdir.closeViewer`,()=>p(null))),e.push(V.registerCommand(`dotdir.closeEditor`,()=>m(null))),e.push(V.registerCommand(`dotdir.switchPanel`,()=>s(e=>e===`left`?`right`:`left`))),e.push(V.registerCommand(`dotdir.focusLeftPanel`,()=>s(`left`))),e.push(V.registerCommand(`dotdir.focusRightPanel`,()=>s(`right`))),e.push(V.registerCommand(`dotdir.cancelNavigation`,()=>{n.current.leftRef.current.cancelNavigation(),n.current.rightRef.current.cancelNavigation()})),e.push(V.registerCommand(`dotdir.goToParent`,()=>{let{leftRef:e,rightRef:t}=n.current,r=g.current===`left`?e.current:t.current,i=r.currentPath;if(Pt(i)){let{containerFile:e,innerPath:t}=Ft(i);if(t===`/`||t===``){r.navigateTo(W(e),!1,K(e));return}}let a=W(i);a!==i&&r.navigateTo(a)})),e.push(V.registerCommand(`dotdir.goHome`,async()=>{let{leftRef:e,rightRef:r}=n.current,i=await t.utils.getHomePath();(g.current===`left`?e.current:r.current).navigateTo(i)})),e.push(V.registerCommand(`dotdir.refresh`,()=>{let{leftRef:e,rightRef:t}=n.current,r=g.current===`left`?e.current:t.current;r.navigateTo(r.currentPath)})),e.push(V.registerCommand(`dotdir.newTab`,()=>void ji()?.newTab())),e.push(V.registerCommand(`dotdir.closeTab`,()=>void ji()?.closeActiveTab())),e.push(V.registerCommand(`dotdir.previewInOppositePanel`,()=>n.current.onPreviewInOppositePanel())),e.push(V.registerCommand(`dotdir.openCurrentFolderInOppositePanelCurrentTab`,()=>n.current.onOpenCurrentFolderInOppositeCurrentTab())),e.push(V.registerCommand(`dotdir.openCurrentFolderInOppositePanelNewTab`,()=>n.current.onOpenCurrentFolderInOppositeNewTab())),e.push(V.registerCommand(`dotdir.openSelectedFolderInOppositePanelCurrentTab`,()=>n.current.onOpenSelectedFolderInOppositeCurrentTab())),e.push(V.registerCommand(`dotdir.openSelectedFolderInOppositePanelNewTab`,()=>n.current.onOpenSelectedFolderInOppositeNewTab())),e.push(V.registerCommand(`dotdir.openCreateFile`,()=>{let{leftRef:e,rightRef:t,showDialog:r,onOpenCreateFileConfirm:a}=n.current,o=(g.current===`left`?e.current:t.current).currentPath,s=i.current.flatMap(e=>e.languages??[]),c=new Set;r({type:`openCreateFile`,currentPath:o,languages:s.filter(e=>c.has(e.id)?!1:(c.add(e.id),!0)).map(e=>({id:e.id,label:e.aliases?.[0]??e.id})),onConfirm:a,onCancel:()=>{}})})),e.push(V.registerCommand(`dotdir.makeFolder`,()=>{let{leftRef:e,rightRef:r,showDialog:i}=n.current,a=g.current===`left`?e.current:r.current,o=a.currentPath;i({type:`makeFolder`,currentPath:o,onConfirm:async e=>{let n=e=>o?`${o.replace(/\/?$/,``)}/${e}`:e;if(e.mode===`single`){let r=n(e.name);t.fs.createDir&&await t.fs.createDir(r),a.navigateTo(r);return}for(let r of e.names){let e=n(r);t.fs.createDir&&await t.fs.createDir(e)}a.navigateTo(o)},onCancel:()=>{}})})),e.push(V.registerCommand(`dotdir.exit`,async()=>{ha()?await Na().close():window.close()})),e.push(V.registerCommand(`terminal.execute`,async e=>{let t=K(e),r=/^[a-zA-Z0-9._+-]+$/.test(t)?`./${t}`:`./${JSON.stringify(t)}`;await n.current.onExecuteInTerminal(`${r}\r`)})),e.push(V.registerCommand(`dotdir.viewFile`,(e,t,r)=>{n.current.onViewFile(e,t,r)})),e.push(V.registerCommand(`dotdir.editFile`,(e,t,r,i)=>{let a=n.current.editorFileSizeLimit;a>0&&r>a||n.current.onEditFile(e,t,r,i)})),e.push(V.registerCommand(`list.cursorUp`,()=>q()?.cursorUp())),e.push(V.registerCommand(`list.cursorDown`,()=>q()?.cursorDown())),e.push(V.registerCommand(`list.cursorLeft`,()=>q()?.cursorLeft())),e.push(V.registerCommand(`list.cursorRight`,()=>q()?.cursorRight())),e.push(V.registerCommand(`list.cursorHome`,()=>q()?.cursorHome())),e.push(V.registerCommand(`list.cursorEnd`,()=>q()?.cursorEnd())),e.push(V.registerCommand(`list.cursorPageUp`,()=>q()?.cursorPageUp())),e.push(V.registerCommand(`list.cursorPageDown`,()=>q()?.cursorPageDown())),e.push(V.registerCommand(`list.selectUp`,()=>q()?.selectUp())),e.push(V.registerCommand(`list.selectDown`,()=>q()?.selectDown())),e.push(V.registerCommand(`list.selectLeft`,()=>q()?.selectLeft())),e.push(V.registerCommand(`list.selectRight`,()=>q()?.selectRight())),e.push(V.registerCommand(`list.selectHome`,()=>q()?.selectHome())),e.push(V.registerCommand(`list.selectEnd`,()=>q()?.selectEnd())),e.push(V.registerCommand(`list.selectPageUp`,()=>q()?.selectPageUp())),e.push(V.registerCommand(`list.selectPageDown`,()=>q()?.selectPageDown())),e.push(V.registerCommand(`list.execute`,()=>q()?.execute())),e.push(V.registerCommand(`list.open`,()=>q()?.open())),e.push(V.registerCommand(`list.viewFile`,()=>q()?.viewFile())),e.push(V.registerCommand(`list.editFile`,()=>q()?.editFile())),e.push(V.registerCommand(`list.moveToTrash`,()=>q()?.moveToTrash())),e.push(V.registerCommand(`list.permanentDelete`,()=>q()?.permanentDelete())),e.push(V.registerCommand(`list.copy`,()=>q()?.copy())),e.push(V.registerCommand(`list.move`,()=>q()?.move())),e.push(V.registerCommand(`list.rename`,()=>q()?.rename())),e.push(V.registerCommand(`list.pasteFilename`,()=>q()?.pasteFilename())),e.push(V.registerCommand(`list.pastePath`,()=>q()?.pastePath())),e.push(...Ye(V)),e.push(...Ze(V)),()=>{for(let t of e)t()}},[s,l,u,f,p,m,h,a])}var Ha=function(e){return e[e.None=0]=`None`,e[e.Expanded=1]=`Expanded`,e[e.Selected=2]=`Selected`,e[e.Hovered=4]=`Hovered`,e[e.Active=8]=`Active`,e[e.DragOver=16]=`DragOver`,e[e.Focused=32]=`Focused`,e}({});Ha.Expanded,Ha.Selected,Ha.Hovered,Ha.Active,Ha.DragOver,Ha.Focused;function Ua(e){let t=e.name.indexOf(`.`),n=e.name.lastIndexOf(`.`),r=``,i=``;return e.type===`file`&&t>0&&(i=e.name.substring(t+1),r=n>0?e.name.substring(n+1):i),{type:e.type,name:e.name,baseExt:r,fullExt:i,lang:e.lang??``,path:e.path,parent:e.parent,stateFlags:e.stateFlags??Ha.None,meta:e.meta??{}}}function Wa(e){if(W(e)===e)return;let t=[],n=e;for(;;){t.push(n);let e=W(n);if(e===n)break;n=e}t.reverse();let r;for(let e of t)r=Ua({name:K(e)||e,type:`folder`,path:e,parent:r});return r}function Ga(e){return e.kind===`directory`||e.kind===`symlink`&&(e.mode&61440)==16384}function Ka(e,t,n){let r=Ga(e),i={size:e.size,mtimeMs:e.mtimeMs,mode:e.mode,nlink:e.nlink,kind:e.kind,hidden:e.hidden,linkTarget:e.linkTarget};return Ua({name:e.name,type:r?`folder`:`file`,lang:r?``:le.detectLanguage(e.name),meta:{size:i.size,mtimeMs:i.mtimeMs,executable:!r&&_t(i.mode??0,e.name),hidden:i.hidden??e.name.startsWith(`.`),nlink:i.nlink??1,entryKind:i.kind??(r?`directory`:`file`),linkTarget:i.linkTarget},path:G(t,e.name),parent:n})}async function qa(e,t){let n=t;for(;;){if(await e.fs.exists(n))return n;let t=W(n);if(t===n||pt(n))return n;n=t}}function Ja(e){let t=[],n=e;for(;;){t.push(n);let e=W(n);if(e===n)break;n=e}return t}var Ya={currentPath:``,parentNode:void 0,entries:[],requestedCursor:void 0};function Xa(e){let t=B(),n=(0,d.useAtomValue)(ke),[r,i]=(0,c.useState)(Ya),[a,o]=(0,c.useState)(!1),s=(0,c.useRef)(null),l=(0,c.useRef)(null),u=(0,c.useMemo)(()=>Wr(n),[n]),f=(0,c.useRef)(u);f.current=u;let p=(0,c.useRef)(null),m=(0,c.useRef)(null),h=(0,c.useRef)(``),g=(0,c.useRef)(e);g.current=e,(0,c.useEffect)(()=>{h.current&&v(h.current,!0)},[u]);let _=(0,c.useCallback)(e=>{let t=p.current,n=Ja(e),r=[];for(let e of n)r.push(e),r.push(G(e,`.dotdir`));t.sync(r)},[]),v=(0,c.useCallback)(async(e,n=!1,r)=>{if(!n&&h.current===e&&l.current)return;l.current?.abort();let a=new AbortController;l.current=a,s.current=setTimeout(()=>o(!0),300);try{let n=(async()=>{if(h.current=e,Pt(e)){let{containerFile:n,innerPath:o}=Ft(e),s=Jt.resolve(K(n));if(!s)throw Error(`No fsProvider registered for "${K(n)}"`);let c;if(s.contribution.runtime===`backend`&&t.fsProvider){let e=G(s.extensionDirPath,s.contribution.entry),r=await t.fsProvider.listEntries(e,n,o);if(a.signal.aborted)return;c=r.map(e=>({name:e.name,type:e.kind,size:e.size,mtimeMs:e.mtimeMs}))}else{let e=await Dt(t,s.extensionDirPath,s.contribution.entry);if(a.signal.aborted||(c=await e.listEntries(n,o),a.signal.aborted))return}let l=Wa(e);i({currentPath:e,parentNode:l,entries:c.map(e=>{let t=(o===`/`?``:o)+`/`+e.name;return Ua({name:e.name,type:e.type===`directory`?`folder`:`file`,lang:e.type===`file`?le.detectLanguage(e.name):``,meta:{size:e.size??0,mtimeMs:e.mtimeMs??0,executable:!1,hidden:e.name.startsWith(`.`),nlink:1,entryKind:e.type===`directory`?`directory`:`file`},path:It(n,t),parent:l})}),requestedCursor:r})}else{if(await Gr(t,f.current,e),a.signal.aborted)return;let n=Wa(e),o=await t.fs.entries(e);if(a.signal.aborted)return;let s=o.map(t=>Ka(t,e,n));if(a.signal.aborted)return;i({currentPath:e,parentNode:n,entries:s,requestedCursor:r}),_(e)}})();n.catch(()=>{}),await Promise.race([n,new Promise(e=>{a.signal.addEventListener(`abort`,()=>e(),{once:!0})})])}catch(e){if(!a.signal.aborted){let t=e&&typeof e==`object`&&`message`in e?e.message:String(e);g.current(`Failed to read directory: ${t}`)}}finally{l.current===a&&(l.current=null),clearTimeout(s.current),s.current=null,o(!1)}},[_]),y=(0,c.useCallback)(()=>{l.current?.abort(),l.current=null,s.current&&=(clearTimeout(s.current),null),o(!1)},[]);(0,c.useEffect)(()=>(p.current=new wt(t,e=>{let n=h.current;if(!n)return;let r=!1,i=!1,a=!1;for(let t of e){let e=t.root.path,o=t.relativePathComponents[0]??null,s=t.type;e===n?s===`errored`?a=!0:r=!0:e.endsWith(`/.dotdir`)?o===`fs.css`&&(Ur(W(e)),i=!0):(n.startsWith(e+`/`)||n===e)&&(o===`.dotdir`?(Ur(e),i=!0):o&&o===n.slice(e.length+1).split(`/`)[0]&&s===`disappeared`&&(a=!0))}if(a){m.current&&=(clearTimeout(m.current),null),qa(t,n).then(e=>{b.current(e)});return}(r||i)&&(m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{m.current=null,b.current(h.current)},100))}),()=>{p.current?.disconnect(),p.current=null,m.current&&=(clearTimeout(m.current),null)}),[]);let b=(0,c.useRef)(v);b.current=v;let x=(0,c.useCallback)(()=>{b.current(h.current,!0)},[]);return{...r,navigateTo:v,navigating:a,cancelNavigation:y,refresh:x,resolver:f.current}}function Za({activePanelCwd:e,onNavigatePanel:t}){let n=B(),r=(0,d.useAtomValue)(De),i=(0,d.useAtomValue)(Oe),a=(0,d.useAtomValue)(Ae),o=(0,d.useSetAtom)(Ae),s=(0,d.useSetAtom)(je),l=(0,d.useAtomValue)(Me),u=(0,d.useSetAtom)(Me),f=(0,d.useSetAtom)(Re),{activeSession:p,activeSessionId:m,setProfiles:h,setCurrentCwd:g,restartAll:_,dispose:y,writeToActiveSession:b,executeCommandInCwd:x}=Ki(),S=(0,c.useRef)(e);S.current=e;let C=(0,c.useRef)(t);C.current=t;let w=(0,c.useRef)(!1),T=(0,c.useRef)(null),E=(0,c.useCallback)(e=>{T.current&&=(clearTimeout(T.current),null),o(e)},[o]);(0,c.useEffect)(()=>{if(!p){E(!0),V.setContext(`terminalCommandRunning`,!1);return}let e=p.session.getCapabilities().commandRunning;return E(!e),V.setContext(`terminalCommandRunning`,e),p.session.subscribe(e=>{if(e.type===`command-start`)E(!1),V.setContext(`terminalCommandRunning`,!0);else if(e.type===`command-finish`)E(!0),V.setContext(`terminalCommandRunning`,!1);else if(e.type===`capabilities`){let t=e.capabilities.commandRunning;E(!t),V.setContext(`terminalCommandRunning`,t)}})},[m,E]),(0,c.useEffect)(()=>{i&&r.length>0&&h(r,e)},[i,r]),(0,c.useEffect)(()=>()=>{y()},[y]),(0,c.useEffect)(()=>{g(e)},[e,g]),(0,c.useEffect)(()=>{if(n.onReconnect)return n.onReconnect(()=>_())},[_]),(0,c.useEffect)(()=>{if(p?.cwd&&p.cwdUserInitiated){let e=Q(U(p.cwd));if(e===Q(S.current))return;C.current(e),u(null)}},[p,u]);let D=l??e;(0,c.useEffect)(()=>{f(D)},[D,f]),(0,c.useEffect)(()=>{l&&Q(e)===l&&u(null)},[e,l,u]),(0,c.useEffect)(()=>{if(!a)return;let e=requestAnimationFrame(()=>{v.set(`panel`)});return()=>cancelAnimationFrame(e)},[a]);let O=(0,c.useCallback)(e=>{u(Q(e))},[u]);return{activeCwd:D,writeToTerminal:(0,c.useCallback)(e=>b(e),[b]),runCommand:(0,c.useCallback)(async(e,t)=>{w.current=!0,o(!1),v.set(`terminal`),s(e=>e+1),await x(e,t)},[o,s,x]),rememberExpectedTerminalCwd:O}}var Qa={},$a=null,eo=null;async function to(e){return $a||=G(await e.utils.getHomePath(),`.dotdir`,`ui-state.json`),$a}async function no(e){try{let t=await St(e,await to(e)),n=JSON.parse(t);typeof n==`object`&&n&&!Array.isArray(n)&&(Qa=n)}catch{}return Qa}function ro(e,t){Qa={...Qa,...t},eo&&clearTimeout(eo),eo=setTimeout(()=>{eo=null,ao(e,Qa)},500)}function io(e){eo&&=(clearTimeout(eo),null),ao(e,Qa)}async function ao(e,t){try{let n=await to(e);await e.fs.writeFile(n,JSON.stringify(t,null,2))}catch(e){console.error(`[uiState] Failed to save:`,e)}}function oo({ready:e,setLeftTabs:t,setRightTabs:n,setLeftActiveTabId:r,setRightActiveTabId:i,leftTabSelectionRef:a,rightTabSelectionRef:o,prevLeftActiveTabIdRef:s,prevRightActiveTabIdRef:l,onAfterRestore:u}){let d=B(),[f,p]=(0,c.useState)(!1),m=(0,c.useRef)({}),[h,g]=(0,c.useState)(!1),[_,v]=(0,c.useState)(void 0),[y,b]=(0,c.useState)(void 0),[x,S]=(0,c.useState)(void 0);return(0,c.useEffect)(()=>{no(d).then(e=>{m.current=e,g(!0)})},[]),(0,c.useEffect)(()=>{if(!e||!h)return;let c=m.current,d=e=>e?.tabs?.length?e.tabs.map(e=>e.type===`filelist`?_i(e.path):{id:gi(),type:`preview`,path:e.path,name:e.name,size:e.size,isTemp:!1}):e?.currentPath?[_i(e.currentPath)]:null,f=(e,t,n)=>{if(!(!t?.length||!n?.tabs?.length))for(let r=0;r<t.length&&r<n.tabs.length;r++){let i=t[r],a=n.tabs[r];i.type===`filelist`&&a.type===`filelist`&&(a.selectedName!=null||a.topmostName!=null)&&(e.current[i.id]={selectedName:a.selectedName,topmostName:a.topmostName})}},g=d(c.leftPanel),_=d(c.rightPanel);g&&f(a,g,c.leftPanel),_&&f(o,_,c.rightPanel);let y=g?Math.min(c.leftPanel?.activeTabIndex??0,g.length-1):0,x=_?Math.min(c.rightPanel?.activeTabIndex??0,_.length-1):0,C=g?.[y]?.id,w=_?.[x]?.id;C&&(s.current=C),w&&(l.current=w),g&&t(g),_&&n(_),C&&r(C),w&&i(w),c.leftPanel&&v(c.leftPanel),c.rightPanel&&b(c.rightPanel),c.activePanel&&S(c.activePanel),p(!0),u()},[e,h]),{settingsLoaded:f,initialLeftPanel:_,initialRightPanel:y,initialActivePanel:x,setInitialLeftPanel:v,setInitialRightPanel:b,setInitialActivePanel:S}}function so({activePanel:e,settingsLoaded:t,left:n,right:r,leftTabsRef:i,rightTabsRef:a,leftActiveTabIdRef:o,rightActiveTabIdRef:s,leftTabSelectionRef:l,rightTabSelectionRef:u,leftSelectedNameRef:d,rightSelectedNameRef:f,setLeftTabs:p,setRightTabs:m,setLeftActiveTabId:h,setRightActiveTabId:g}){let _=B(),v=(0,c.useRef)(null),y=(0,c.useRef)({}),b=(0,c.useCallback)((e,t,n)=>{let r=e===`left`?l:u;return{tabs:t.map(e=>{if(e.type===`filelist`){let t=r.current[e.id],n={type:`filelist`,path:e.path};return t?.selectedName!=null&&(n.selectedName=t.selectedName),t?.topmostName!=null&&(n.topmostName=t.topmostName),n}return{type:`preview`,path:e.path,name:e.name,size:e.size}}),activeTabIndex:Math.max(0,t.findIndex(e=>e.id===n))}},[l,u]),x=(0,c.useCallback)(()=>{v.current&&=(clearTimeout(v.current),null);let e=y.current;for(let t of Zi){let c=Xi[t];e[c]||(e[c]={currentPath:t===`left`?n.currentPath:r.currentPath});let l=t===`left`?i:a,u=t===`left`?o:s;Object.assign(e[c],b(t,l.current,u.current))}ro(_,e),io(_),y.current={}},[b,n.currentPath,r.currentPath,i,a,o,s]),S=(0,c.useCallback)(()=>{v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{v.current=null,ro(_,y.current),y.current={}},1e4)},[_]);(0,c.useEffect)(()=>{let e=()=>{x()};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[x]);let C=(0,c.useCallback)((e,t,c)=>{let _=e===`left`?i:a,v=e===`left`?o:s,x=e===`left`?l:u,C=e===`left`?d:f,w=e===`left`?n:r,T=_.current.find(e=>e.id===v.current);T?.type===`filelist`&&(x.current[T.id]={selectedName:t,topmostName:c}),C.current=t,y.current[Xi[e]]={currentPath:w.currentPath,...b(e,_.current,v.current)},S();let E=Yi[e],D=E===`left`?i:a,O=E===`right`?m:p,k=E===`right`?g:h,A=D.current.find(t=>t.type===`preview`&&t.isTemp&&t.sourcePanel===e);if(!A||!t)return;let j=w.entries.find(e=>e.name===t);if(!j||j.type!==`file`)return;let ee=j.path,M=j.name,N=Number(j.meta.size);A.type===`preview`&&A.path===ee&&A.name===M||(O(t=>t.map(t=>t.id===A.id?{id:t.id,type:`preview`,path:ee,name:M,size:N,isTemp:!0,sourcePanel:e}:t)),k(A.id))},[n,r,b,S,i,a,o,s,l,u,d,f,m,p,g,h]);return(0,c.useEffect)(()=>{t&&ro(_,{activePanel:e})},[e,t]),{handlePanelStateChange:C}}function co(e){return Array.isArray(e)?e.filter(e=>{if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.command==`string`&&typeof t.key==`string`}).map(e=>({command:e.command,key:e.key,mac:typeof e.mac==`string`?e.mac:void 0,when:typeof e.when==`string`?e.when:void 0})):(console.error(`[userKeybindings] keybindings.json must be an array`),null)}async function lo(e){await Wn(e,{name:`userKeybindings`,getPath:async()=>G(await e.utils.getHomePath(),`.dotdir`,`keybindings.json`),validate:co,defaultValue:[],onLoad:e=>{V.setLayerKeybindings(`user`,e),console.log(`[userKeybindings] Applied ${e.length} keybindings`)}})}var uo=new Set([`png`,`jpg`,`jpeg`,`gif`,`bmp`,`webp`,`ico`,`svg`,`avif`,`tiff`,`tif`]),fo=new Set([`mp4`,`webm`,`ogv`,`ogg`,`mov`,`m4v`]);function po(e){let t=e.lastIndexOf(`.`);return t<0?``:e.slice(t+1).toLowerCase()}function mo(e){return uo.has(po(e))}function ho(e){return fo.has(po(e))}function go(e){return mo(e)||ho(e)}var _o=`_app_4bfa7_56`,vo=`_loading_4bfa7_69`,yo={"dotdir-root":`_dotdir-root_4bfa7_1`,app:_o,"status-bar":`_status-bar_4bfa7_64`,loading:vo};function bo({widget:e}){let t=(0,c.useRef)(null),n=B(),{settings:r,ready:i,updateSettings:a}=nr(),o=(0,c.useRef)(r);o.current=r;let s=(0,d.useSetAtom)(ke),{dialog:u,showDialog:f}=_e(),[p,m]=(0,d.useAtom)(Pe),h=(0,c.useCallback)(e=>{f({type:`message`,title:`Error`,message:e,variant:`error`})},[f]),g=Xa(h),_=Xa(h),[y,b]=(0,d.useAtom)(Ne),x=(0,d.useAtomValue)(Ae),[S,w]=(0,d.useAtom)(Ie),[T,E]=(0,d.useAtom)(Le),[D,O]=(0,c.useState)(null),[k,A]=(0,c.useState)(null),j=(0,d.useAtomValue)(Se),ee=(0,d.useSetAtom)(Ce),M=(0,d.useSetAtom)(we),[N,te]=(0,c.useState)(0),[ne,P]=(0,d.useAtom)(xi),[F,I]=(0,d.useAtom)(Si),[L,re]=(0,d.useAtom)(Ci),[ie,R]=(0,d.useAtom)(wi),z=(0,c.useRef)(void 0),oe=(0,c.useRef)(void 0),se=(0,c.useRef)({}),ce=(0,c.useRef)({}),le=(0,c.useRef)(L),ue=(0,c.useRef)(ie),de=(0,d.useAtomValue)(Te),fe=(0,d.useAtomValue)(Ee),pe=(0,c.useRef)(ne);pe.current=ne;let me=(0,c.useRef)(F);me.current=F;let he=(0,c.useRef)(L);he.current=L;let ve=(0,c.useRef)(ie);ve.current=ie;let[ye,be]=(0,c.useState)(0),xe=ot(),De=(0,d.useSetAtom)(ze),Oe=(0,d.useAtomValue)(Be),je=(0,c.useRef)(()=>{});Oe&&(je.current=Oe),(0,c.useEffect)(()=>{i&&(r.iconTheme&&ee(r.iconTheme),r.colorTheme!==void 0&&M(r.colorTheme||void 0),r.editorFileSizeLimit!==void 0&&te(r.editorFileSizeLimit),r.showHidden!==void 0&&m(r.showHidden))},[r,i]);let{settingsLoaded:Me,initialLeftPanel:Fe,initialRightPanel:Re,initialActivePanel:Ve,setInitialLeftPanel:He,setInitialRightPanel:Ue,setInitialActivePanel:Ge}=oo({ready:i,setLeftTabs:P,setRightTabs:I,setLeftActiveTabId:re,setRightActiveTabId:R,leftTabSelectionRef:se,rightTabSelectionRef:ce,prevLeftActiveTabIdRef:le,prevRightActiveTabIdRef:ue,onAfterRestore:(0,c.useCallback)(()=>{lo(n)},[n])}),Ke=(0,c.useRef)(y);Ke.current=y;let qe=(0,c.useRef)(g.navigateTo);qe.current=y===`left`?g.navigateTo:_.navigateTo;let Je=(0,c.useRef)(g);Je.current=g;let Ye=(0,c.useRef)(_);Ye.current=_;let Xe=(0,c.useRef)(``),Ze=(0,c.useCallback)(async e=>{let t=oa(e);if(!t){Ot.runCommand(e,Xe.current);return}if(t.kind===`error`){f({type:`message`,title:`cd`,message:t.message,variant:`error`});return}let r=Ke.current===`left`?Je.current:Ye.current,i=r.currentPath;if(t.kind===`setAlias`){a({pathAliases:{...o.current.pathAliases,[t.alias]:Q(i)}});return}if(t.kind===`goAlias`){let e=o.current.pathAliases?.[t.alias];if(!e){f({type:`message`,title:`cd`,message:`Unknown alias: ${t.alias}`,variant:`error`});return}let i=Q(mt(U(e)));if(!await ca(n,i)){f({type:`message`,title:`cd`,message:`Folder not found: ${i}`,variant:`error`});return}await r.navigateTo(i);return}if(t.kind===`chdir`){let e=await sa(n,t.pathArg,i);if(!await ca(n,e)){f({type:`message`,title:`cd`,message:`Path not found: ${e}`,variant:`error`});return}await r.navigateTo(e)}},[f]);(0,c.useEffect)(()=>{De(()=>Ze)},[Ze,De]);let{handleCopy:Qe,handleMove:$e,handleMoveToTrash:et,handlePermanentDelete:tt,handleRename:nt}=aa(Ke,Je,Ye,be);(0,c.useEffect)(()=>{Ir({moveToTrash:et,permanentDelete:tt,copy:Qe,move:$e,rename:nt,pasteToCommandLine:e=>je.current(e)})},[et,tt,Qe,$e,nt]),(0,c.useEffect)(()=>{V.setContext(`leftPanelActive`,y===`left`),V.setContext(`rightPanelActive`,y===`right`)},[y]),(0,c.useEffect)(()=>{V.setContext(`dialogOpen`,u!==null)},[u]);let it=(0,c.useCallback)((e,t,n)=>{if(Jt.resolve(K(e))){qe.current(e+`\0`);return}w({path:e,name:t,size:n,panel:Ke.current})},[]),st=(0,c.useCallback)((e,t,n,r)=>{E({path:e,name:t,size:n,langId:r})},[]),ct=(0,c.useCallback)(async(e,t,r)=>{let i=await n.fs.exists(e);i||await n.fs.writeFile(e,``),E({path:e,name:t,size:i?(await n.fs.stat(e)).size:0,langId:r})},[]),lt=S?S.panel===`left`?g.entries:_.entries:[],ut=(0,c.useCallback)((e,t)=>t.some(t=>{if(t.startsWith(`*.`)){let n=t.slice(1).toLowerCase();return e.toLowerCase().endsWith(n)}return e.toLowerCase()===t.toLowerCase()}),[]),dt=(0,c.useCallback)(e=>S?(p?lt:lt.filter(e=>!e.meta.hidden)).filter(t=>t.type===`file`&&ut(t.name,e)).map(e=>({path:e.path,name:e.name,size:Number(e.meta.size)})).sort((e,t)=>e.name.localeCompare(t.name)):[],[S,lt,p,ut]),ft=(0,c.useCallback)(async(e,t)=>{let{patterns:n}=t??{};if(!n||!S)return;let r=dt(n),i=r.findIndex(e=>e.path===S.path);if(e===`navigatePrev`){if(i>0){let e=r[i-1];w(t=>t?{...e,panel:t.panel}:null)}return}if(e===`navigateNext`){if(i>=0&&i<r.length-1){let e=r[i+1];w(t=>t?{...e,panel:t.panel}:null)}return}if(e===`getFileIndex`)return{index:i,total:r.length}},[S,dt]),pt=S?Kt.resolve(S.name):null,W=T?qt.resolve(T.name):null;(0,c.useEffect)(()=>{pt&&O(e=>e?.dirPath===pt.extensionDirPath&&e?.entry===pt.contribution.entry?e:{dirPath:pt.extensionDirPath,entry:pt.contribution.entry})},[pt?.extensionDirPath,pt?.contribution.entry]),(0,c.useEffect)(()=>{W&&A(e=>e?.dirPath===W.extensionDirPath&&e?.entry===W.contribution.entry?e:{dirPath:W.extensionDirPath,entry:W.contribution.entry})},[W?.extensionDirPath,W?.contribution.entry]);let G=S&&go(S.name)?S.name:void 0,ht=g.requestedCursor??(S?.panel===`left`?G:void 0),gt=_.requestedCursor??(S?.panel===`right`?G:void 0),{handlePanelStateChange:_t}=so({activePanel:y,settingsLoaded:Me,left:g,right:_,leftTabsRef:pe,rightTabsRef:me,leftActiveTabIdRef:he,rightActiveTabIdRef:ve,leftTabSelectionRef:se,rightTabSelectionRef:ce,leftSelectedNameRef:z,rightSelectedNameRef:oe,setLeftTabs:P,setRightTabs:I,setLeftActiveTabId:re,setRightActiveTabId:R}),vt=(0,c.useCallback)(()=>{let e=Ke.current,t=Yi[e],n=e===`left`?g.currentPath:_.currentPath,r=(t===`left`?he:ve).current,i=t===`left`?P:I,a=t===`left`?g:_;i(e=>e.map(e=>e.id===r&&e.type===`filelist`?{...e,path:n}:e)),a.navigateTo(n),b(t)},[g.currentPath,_.currentPath,g,_]),yt=(0,c.useCallback)(()=>{let e=Ke.current,t=Yi[e],n=e===`left`?g.currentPath:_.currentPath,r=_i(n),i=t===`left`?P:I,a=t===`left`?re:R,o=t===`left`?g:_;i(e=>[...e,r]),a(r.id),o.navigateTo(n),b(t)},[g.currentPath,_.currentPath,g,_]),bt=(0,c.useCallback)(()=>{let e=Ke.current,t=e===`left`?g.entries:_.entries,n=e===`left`?z.current:oe.current,r=n?t.find(e=>e.name===n):void 0;if(!r||r.type!==`folder`)return;let i=r.path,a=Yi[e],o=(a===`left`?he:ve).current,s=a===`left`?P:I,c=a===`left`?g:_;s(e=>e.map(e=>e.id===o&&e.type===`filelist`?{...e,path:i}:e)),c.navigateTo(i),b(a)},[g.entries,_.entries,g,_]),xt=(0,c.useCallback)(()=>{let e=Ke.current,t=e===`left`?g.entries:_.entries,n=e===`left`?z.current:oe.current,r=n?t.find(e=>e.name===n):void 0;if(!r||r.type!==`folder`)return;let i=r.path,a=Yi[e],o=_i(i),s=a===`left`?P:I,c=a===`left`?re:R,l=a===`left`?g:_;s(e=>[...e,o]),c(o.id),l.navigateTo(i),b(a)},[g.entries,_.entries,g,_]),St=(0,c.useCallback)(()=>{let e=Ke.current,t=e===`left`?g.entries:_.entries,n=e===`left`?z.current:oe.current,r=n?t.find(e=>e.name===n):void 0;if(!r||r.type!==`file`)return;let i=r.path,a=r.name,o=Number(r.meta.size),s=e,c=Yi[e],l=(c===`left`?pe:me).current,u=c===`left`?P:I,d=c===`left`?re:R,f=l.find(e=>e.type===`preview`&&e.isTemp);if(f&&f.type===`preview`)u(e=>e.map(e=>e.id===f.id?{...e,path:i,name:a,size:o,sourcePanel:s}:e)),d(f.id);else{let e=vi(i,a,o,s);u(t=>[...t,e]),d(e.id)}b(c)},[g.entries,_.entries]);(0,c.useEffect)(()=>(n.theme.get().then(e=>s(e)),n.theme.onChange(e=>s(e))),[]);let Ct=(0,c.useRef)(g.currentPath);Ct.current=g.currentPath;let wt=(0,c.useRef)(_.currentPath);wt.current=_.currentPath,(0,c.useEffect)(()=>{if(le.current===L)return;le.current=L;let e=pe.current.find(e=>e.id===L);e?.type===`filelist`&&e.path!=null&&g.navigateTo(e.path)},[L]),(0,c.useEffect)(()=>{if(ue.current===ie)return;ue.current=ie;let e=me.current.find(e=>e.id===ie);e?.type===`filelist`&&e.path!=null&&_.navigateTo(e.path)},[ie]);let Tt=(0,c.useRef)(g.currentPath),Et=(0,c.useRef)(_.currentPath);(0,c.useEffect)(()=>{Tt.current!==g.currentPath&&(Tt.current=g.currentPath,P(e=>{let t=e.findIndex(e=>e.id===L);if(t<0)return e;let n=e[t];if(n?.type!==`filelist`||n.path===g.currentPath)return e;let r=[...e];return r[t]={...n,path:g.currentPath},r}))},[g.currentPath,L]),(0,c.useEffect)(()=>{Et.current!==_.currentPath&&(Et.current=_.currentPath,I(e=>{let t=e.findIndex(e=>e.id===ie);if(t<0)return e;let n=e[t];if(n?.type!==`filelist`||n.path===_.currentPath)return e;let r=[...e];return r[t]={...n,path:_.currentPath},r}))},[_.currentPath,ie]),(0,c.useEffect)(()=>{if(!Me)return;let e=async(e,t,r)=>{let i=t?.currentPath??r;i&&(await n.fs.exists(i)||(i=await qa(n,i))),i||=await n.utils.getHomePath(),await e.navigateTo(i)};e(g,Fe),e(_,Re),Ve&&b(Ve),setTimeout(()=>{He(void 0),Ue(void 0),Ge(void 0)},500)},[Me]),ra({settingsLoaded:Me,onRefreshPanels:()=>{Je.current.refresh(),Ye.current.refresh()}});let Dt=(0,c.useCallback)(e=>{(Ke.current===`left`?Je.current:Ye.current).navigateTo(e)},[]),Ot=Za({activePanelCwd:y===`left`?g.currentPath:_.currentPath,onNavigatePanel:Dt});return Xe.current=Ot.activeCwd,Va({leftRef:Je,rightRef:Ye,onPreviewInOppositePanel:St,onOpenCurrentFolderInOppositeCurrentTab:vt,onOpenCurrentFolderInOppositeNewTab:yt,onOpenSelectedFolderInOppositeCurrentTab:bt,onOpenSelectedFolderInOppositeNewTab:xt,onOpenCreateFileConfirm:ct,showDialog:f,onViewFile:it,onEditFile:st,onExecuteInTerminal:e=>Ot.writeToTerminal(e),editorFileSizeLimit:N}),(0,c.useEffect)(()=>{let e=e=>{let t=e;if(!t)return!1;let n=t.tagName?.toLowerCase();return n===`input`||n===`textarea`||n===`select`||t.isContentEditable},n=n=>{let r=t.current,i=n.target;if(!r||!i||!r.contains(i)||e(i))return;let a=v.current;a!==`panel`&&a!==`viewer`&&a!==`editor`||V.handleKeyboardEvent(n)};return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[]),(0,c.useEffect)(()=>{if(n.onReconnect)return n.onReconnect(()=>{Je.current.navigateTo(Ct.current),Ye.current.navigateTo(wt.current)})},[]),!g.currentPath||!_.currentPath||!fe?(0,l.jsx)(`div`,{className:yo.loading,children:`Loading...`}):(0,l.jsxs)(`div`,{ref:t,className:yo.app,children:[(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:H[`terminal-and-panels`],children:[(0,l.jsx)(`div`,{className:H[`terminal-background`],children:(0,l.jsx)(Ji,{})}),(0,l.jsxs)(`div`,{className:C(Z,`panels-overlay`,!x&&`hidden`),children:[(0,l.jsx)(Mi,{side:`left`,panel:g,onRememberExpectedTerminalCwd:Ot.rememberExpectedTerminalCwd,selectionKey:ye,requestedActiveName:ht,initialPanelState:Fe,onStateChange:(e,t)=>_t(`left`,e,t)}),(0,l.jsx)(Mi,{side:`right`,panel:_,onRememberExpectedTerminalCwd:Ot.rememberExpectedTerminalCwd,selectionKey:ye,requestedActiveName:gt,initialPanelState:Re,onStateChange:(e,t)=>_t(`right`,e,t)})]})]}),(0,l.jsx)(rt,{}),(0,l.jsx)(qi,{})]}),(0,l.jsxs)(`div`,{className:yo[`status-bar`],children:[(0,l.jsx)(We,{}),e]}),S&&!pt&&(0,l.jsx)(ae,{title:`No viewer`,message:`No viewer extension found for this file type. Install viewer extensions (e.g. Image Viewer, File Viewer) from the extensions panel.`,onClose:()=>w(null)}),D&&S&&pt&&(0,l.jsx)(pn,{extensionDirPath:D.dirPath,entry:D.entry,filePath:S.path,fileName:S.name,fileSize:S.size,onClose:()=>w(null),onExecuteCommand:ft},`viewer:${D.dirPath}:${D.entry}`),T&&!W&&(0,l.jsx)(ae,{title:`No editor`,message:`No editor extension found for this file type. Install an editor extension (e.g. Monaco Editor) from the extensions panel.`,onClose:()=>E(null)}),k&&T&&W&&(()=>{let e=de.flatMap(e=>e.languages??[]),t=de.flatMap(e=>e.grammarRefs??[]).map(e=>({contribution:e.contribution,path:e.path}));return(0,l.jsx)(mn,{extensionDirPath:k.dirPath,entry:k.entry,filePath:T.path,fileName:T.name,langId:T.langId,onClose:()=>E(null),languages:e,grammars:t},`editor:${k.dirPath}:${k.entry}`)})(),j&&(0,l.jsx)(cr,{}),(0,l.jsx)(ge,{}),(0,l.jsx)(at,{open:xe.open,onOpenChange:xe.setOpen})]})}function xo({bridge:e,widget:t}){let n=(0,c.useRef)(null);return(0,c.useEffect)(()=>{V.registerContributions(be)},[]),(0,c.useEffect)(()=>{let e=n.current;if(e)return Mt(e),()=>{n.current===e&&Mt(null)}},[]),(0,l.jsx)(`div`,{ref:n,className:yo[`dotdir-root`],children:(0,l.jsx)(d.Provider,{children:(0,l.jsx)(ye,{bridge:e,children:(0,l.jsx)(_,{children:(0,l.jsx)(pe,{children:(0,l.jsx)(bo,{widget:t})})})})})})}exports.DotDir=xo,exports.basename=K,exports.dirname=W,exports.join=G,exports.normalizePath=U;