{ if (deleteTarget) { if (deleteTarget.path === '__bulk__') { bulkDelete(); } else { handleDelete(deleteTarget.path, deleteTarget.name); } deleteTarget = null; } }} /> {#if terminalChatContextHidden} {:else if terminalChatContextPending}
{$i18n.t('Start the chat to use this terminal.')}
{:else if !selectedTerminal}
{$i18n.t('No Terminal connection configured.')}
{$i18n.t('Add your Open Terminal URL and API key in Settings → Integrations.')}
{:else}
!isSearching && handleDragOver(e)} on:dragleave={() => (isDragOver = false)} on:drop={(e) => !isSearching && handleDrop(e)} role="region" aria-label={$i18n.t('File browser')} > {#if isDragOver && !isSearching}
{$i18n.t('Drop to upload')}
{/if} {#if previewPort === null} { if (selectedFile) { const fileName = selectedFile.split('/').pop() ?? ''; openEntry({ name: fileName, type: 'file', size: 0 }); } else { refreshBrowser(); } }} onNewFolder={startNewFolder} onNewFile={startNewFile} onUploadFiles={handleUploadFiles} onDownloadDir={() => downloadFile(currentPath)} onMove={handleMovePaths} onSort={toggleSort} onToggleHidden={toggleHidden} > {#if (isMarkdown || isCsv || isHtml || isJson || isSvg || isNotebook) && fileContent !== null && !editing} {/if} {#if isTextFile} {#if isHtml && showRaw} {:else if isHtml} {:else if isMarkdown && showRaw} {:else if isMarkdown} {:else if isCode} {:else if editing} {:else} {/if} {/if} {#if fileContent !== null} {/if} {#if !selectedFile}
{#if searchQuery} {/if}
{/if} {#if selectedCount > 0 && !isSearching} { deleteTarget = { path: '__bulk__', name: `${selectedCount} items` }; showDeleteConfirm = true; }} onDownload={bulkDownload} onSelectAll={selectAll} onClear={clearSelection} /> {/if} {/if}
{ closeDirectoryMenu(); if (e.target === e.currentTarget && selectedCount > 0) clearSelection(); }} on:contextmenu={(e) => { if (selectedFile || previewPort !== null || isSearching) return; if ((e.target as HTMLElement)?.closest('[data-file-row]')) return; e.preventDefault(); directoryMenu = { x: e.clientX, y: e.clientY }; }} > {#if previewPort !== null} { previewPort = null; }} /> {:else if selectedFile !== null} { if (!excelWorkbook) return; selectedExcelSheet = sheet; const { excelToTable } = await import('$lib/utils/excelToTable'); const result = await excelToTable(excelWorkbook.Sheets[sheet]); const DOMPurify = (await import('dompurify')).default; fileOfficeHtml = DOMPurify.sanitize(result.html); }} baseUrl={selectedTerminal?.url ?? ''} apiKey={selectedTerminal?.key ?? ''} overlay={overlay || isDraggingHandle} onSave={async (content) => { const terminal = selectedTerminal; if (!terminal || !selectedFile || !selectedFileWritable) return; const fileName = selectedFile.split('/').pop() ?? 'file'; const dir = selectedFile.substring(0, selectedFile.lastIndexOf('/') + 1) || '/'; const file = new File([content], fileName, { type: 'text/plain' }); const result = await uploadToTerminal(terminal.url, terminal.key, dir, file); toast[result ? 'success' : 'error']( $i18n.t(result ? 'File saved' : 'Failed to save file') ); if (result) fileContent = content; }} /> {:else} {#if isSearching} {#if matchLoading}
{:else if matchError}
{matchError}
{:else if !matchResults?.length}
{$i18n.t('No matches')}
{:else} {#if filenameMatches.length > 0}
{$i18n.t('Filename matches')}
{#each filenameMatches as match (match.path)} {#if match.content_matches.length > 0} {@const preview = match.content_matches[0]} {/if} {/each} {/if} {#if contentOnlyMatches.length > 0}
{$i18n.t('Content matches')}
{#each contentOnlyMatches as match (match.path)} {#if match.content_matches.length > 0} {@const preview = match.content_matches[0]} {/if} {/each} {/if} {#if nextMatchOffset !== null}
{#if matchLoadingMore} {:else if matchLoadMoreError} {/if}
{/if} {/if} {:else if uploading}
{$i18n.t('Uploading...')}
{:else if loading || ($selectedTerminalId && $terminalServers === null)}
{:else if error}
{error}
{:else if visibleEntries.length === 0 && !creatingFolder && !creatingFile}
{$i18n.t('This folder is empty')}
{/if} {#if !isSearching && !loading && !error && !uploading && !($selectedTerminalId && $terminalServers === null)} {#if creatingFolder}
{ if (e.key === 'Enter') submitNewFolder(); if (e.key === 'Escape') { creatingFolder = false; newFolderName = ''; } }} on:blur={submitNewFolder} />
{/if} {#if creatingFile}
{ if (e.key === 'Enter') submitNewFile(); if (e.key === 'Escape') { creatingFile = false; newFileName = ''; } }} on:blur={submitNewFile} />
{/if} {#if visibleEntries.length > 0 || creatingFolder || creatingFile}
    {#each visibleEntries as entry (entry.fullPath)} openEntry({ ...row, fullPath: entry.fullPath, parentPath: entry.parentPath, depth: entry.depth, rowIndex: entry.rowIndex })} onDownload={downloadFile} onDelete={requestDelete} onMove={handleMovePaths} onRename={handleRename} onSelect={handleSelect} onLongPress={enterSelectionMode} onToggleExpand={toggleExpand} showDate={sortBy === 'date'} parentWritable={currentWritable} /> {/each}
{/if} {/if} {/if}
{#if selectedTerminal && !selectedFile && previewPort === null && !isSearching}
{ selectedFile = null; clearFilePreview(); previewPort = e.detail; }} />
{/if} {#if terminalEnabled}
{#if terminalExpanded}
{/if} {#if terminalExpanded}
{/if}
{/if} { if (!currentWritable || !directoryUploadInput?.files?.length) return; await handleUploadFiles(Array.from(directoryUploadInput.files)); directoryUploadInput.value = ''; }} /> {#if directoryMenu}
{/if}
{/if}