@hienlh/ppm 0.13.63 → 0.13.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/assets/skills/ppm/SKILL.md +1 -1
  3. package/assets/skills/ppm/references/http-api.md +2 -1
  4. package/bun.lock +2170 -0
  5. package/bunfig.toml +2 -0
  6. package/dist/web/assets/{audio-preview-D8onaG_2.js → audio-preview-Bog1sIoF.js} +1 -1
  7. package/dist/web/assets/{chat-tab-D1n2fmne.js → chat-tab-B-uVAh4d.js} +3 -3
  8. package/dist/web/assets/code-editor-cDv3opsJ.js +8 -0
  9. package/dist/web/assets/{conflict-editor-BaSyowCW.js → conflict-editor-D5sEfbcX.js} +1 -1
  10. package/dist/web/assets/{database-viewer-IDG5i3mc.js → database-viewer-BGBVsG5J.js} +1 -1
  11. package/dist/web/assets/{diff-viewer-D5SnxW8Y.js → diff-viewer-B-O1mvHO.js} +1 -1
  12. package/dist/web/assets/docx-preview-ByzSlSgn.js +12 -0
  13. package/dist/web/assets/{extension-webview-BUzklJiG.js → extension-webview-0qfU1r7z.js} +1 -1
  14. package/dist/web/assets/{git-log-panel-CkfQFd6J.js → git-log-panel-C1T8bav0.js} +1 -1
  15. package/dist/web/assets/{glide-data-grid-BJ3Wn9to.js → glide-data-grid-DV8ht1BP.js} +1 -1
  16. package/dist/web/assets/{image-preview-CJ8Qqjgt.js → image-preview-Dbo7SAVb.js} +1 -1
  17. package/dist/web/assets/{index-DwvSM9vu.css → index-BuXdQZjD.css} +1 -1
  18. package/dist/web/assets/{index-Di7q5I27.js → index-DU_JZ5MY.js} +3 -3
  19. package/dist/web/assets/keybindings-store-0FUOwc9I.js +1 -0
  20. package/dist/web/assets/{markdown-renderer-YnP2OcPh.js → markdown-renderer-D-QbsfIC.js} +1 -1
  21. package/dist/web/assets/notification-store-bwd1UKbs.js +1 -0
  22. package/dist/web/assets/{pdf-preview-D3Y2rNVC.js → pdf-preview-DV96VPTb.js} +1 -1
  23. package/dist/web/assets/{port-forwarding-tab-DvoM_j8q.js → port-forwarding-tab-C4OYC71C.js} +1 -1
  24. package/dist/web/assets/{postgres-viewer-BN_vFAqs.js → postgres-viewer-hb-_twEU.js} +1 -1
  25. package/dist/web/assets/{settings-tab-B52JczcO.js → settings-tab-BUCIqVAl.js} +1 -1
  26. package/dist/web/assets/{sql-query-editor-XkJZFBl5.js → sql-query-editor-C7YgtDR3.js} +1 -1
  27. package/dist/web/assets/{sqlite-viewer-DR2scYmN.js → sqlite-viewer-z3pGFSje.js} +1 -1
  28. package/dist/web/assets/{system-monitor-tab-QXA7p0VH.js → system-monitor-tab-Bj6pcRmV.js} +1 -1
  29. package/dist/web/assets/{terminal-tab-BI9y5tDL.js → terminal-tab-DbxLHofN.js} +1 -1
  30. package/dist/web/assets/{video-preview-EhN6q3Xv.js → video-preview-DylSBAzo.js} +1 -1
  31. package/dist/web/index.html +2 -2
  32. package/dist/web/sw.js +1 -1
  33. package/package.json +2 -1
  34. package/src/index.ts +0 -0
  35. package/src/server/routes/files.ts +20 -0
  36. package/src/server/routes/fs-browse.ts +16 -0
  37. package/src/web/components/editor/code-editor.tsx +5 -2
  38. package/src/web/components/editor/docx-preview.tsx +92 -0
  39. package/src/web/components/layout/command-palette-filter-chips.tsx +1 -1
  40. package/dist/web/assets/code-editor-D3ofpe9P.js +0 -8
  41. package/dist/web/assets/keybindings-store-D9NMYHYK.js +0 -1
  42. package/dist/web/assets/notification-store-CW0Alosv.js +0 -1
  43. /package/dist/web/assets/{vendor-xterm-t3d5xZdz.js → vendor-xterm-msgiskDb.js} +0 -0
@@ -2,6 +2,7 @@ import { Hono } from "hono";
2
2
  import { existsSync, mkdirSync, rmSync, statSync } from "fs";
3
3
  import { resolve } from "path";
4
4
  import { $ } from "bun";
5
+ import mammoth from "mammoth";
5
6
  import {
6
7
  browse,
7
8
  list,
@@ -75,6 +76,21 @@ fsBrowseRoutes.get("/raw", (c) => {
75
76
  }
76
77
  });
77
78
 
79
+ /** GET /api/fs/docx-html?path=/some/file.docx — convert .docx to HTML via mammoth */
80
+ fsBrowseRoutes.get("/docx-html", async (c) => {
81
+ try {
82
+ const filePath = c.req.query("path");
83
+ if (!filePath) return c.json(err("path is required"), 400);
84
+ if (!existsSync(filePath)) return c.json(err("File not found"), 404);
85
+
86
+ const buffer = await Bun.file(filePath).arrayBuffer();
87
+ const result = await mammoth.convertToHtml({ arrayBuffer: buffer });
88
+ return c.json(ok({ html: result.value, warnings: result.messages }));
89
+ } catch (e) {
90
+ return c.json(err((e as Error).message), errorStatus(e));
91
+ }
92
+ });
93
+
78
94
  /** DELETE /api/fs/rmdir — delete a directory { path } */
79
95
  fsBrowseRoutes.delete("/rmdir", async (c) => {
80
96
  try {
@@ -27,6 +27,7 @@ const ImagePreview = lazy(() => import("./image-preview").then((m) => ({ default
27
27
  const PdfPreview = lazy(() => import("./pdf-preview").then((m) => ({ default: m.PdfPreview })));
28
28
  const VideoPreview = lazy(() => import("./video-preview").then((m) => ({ default: m.VideoPreview })));
29
29
  const AudioPreview = lazy(() => import("./audio-preview").then((m) => ({ default: m.AudioPreview })));
30
+ const DocxPreview = lazy(() => import("./docx-preview").then((m) => ({ default: m.DocxPreview })));
30
31
 
31
32
  /** Image extensions renderable inline */
32
33
  const IMAGE_EXTS = new Set(["png", "jpg", "jpeg", "gif", "webp", "svg", "ico"]);
@@ -87,6 +88,7 @@ export const CodeEditor = memo(function CodeEditor({ metadata, tabId }: CodeEdit
87
88
  const ext = filePath ? getFileExt(filePath) : "";
88
89
  const isImage = IMAGE_EXTS.has(ext);
89
90
  const isPdf = ext === "pdf";
91
+ const isDocx = ext === "docx";
90
92
  const isVideo = VIDEO_EXTS.has(ext);
91
93
  const isAudio = AUDIO_EXTS.has(ext);
92
94
  const isSqlite = SQLITE_EXTS.has(ext);
@@ -273,7 +275,7 @@ export const CodeEditor = memo(function CodeEditor({ metadata, tabId }: CodeEdit
273
275
  }
274
276
  if (!filePath) return;
275
277
  if (!isExternalFile && !projectName) return;
276
- if (isImage || isPdf || isVideo || isAudio) { setLoading(false); return; }
278
+ if (isImage || isPdf || isDocx || isVideo || isAudio) { setLoading(false); return; }
277
279
 
278
280
  setLoading(true);
279
281
  setError(null);
@@ -296,7 +298,7 @@ export const CodeEditor = memo(function CodeEditor({ metadata, tabId }: CodeEdit
296
298
  });
297
299
 
298
300
  return () => { if (saveTimerRef.current) clearTimeout(saveTimerRef.current); };
299
- }, [filePath, projectName, isImage, isPdf, isExternalFile, isUntitled]);
301
+ }, [filePath, projectName, isImage, isPdf, isDocx, isExternalFile, isUntitled]);
300
302
 
301
303
  // Real-time reload: listen for file:changed WS events, re-fetch if editor is clean
302
304
  const unsavedRef = useRef(unsaved);
@@ -511,6 +513,7 @@ export const CodeEditor = memo(function CodeEditor({ metadata, tabId }: CodeEdit
511
513
 
512
514
  if (isImage) return <Suspense fallback={<LoadingSpinner />}><ImagePreview filePath={filePath!} projectName={projectName!} /></Suspense>;
513
515
  if (isPdf) return <Suspense fallback={<LoadingSpinner />}><PdfPreview filePath={filePath!} projectName={projectName!} /></Suspense>;
516
+ if (isDocx) return <Suspense fallback={<LoadingSpinner />}><DocxPreview filePath={filePath!} projectName={projectName} /></Suspense>;
514
517
  if (isVideo) return <Suspense fallback={<LoadingSpinner />}><VideoPreview filePath={filePath!} projectName={projectName!} /></Suspense>;
515
518
  if (isAudio) return <Suspense fallback={<LoadingSpinner />}><AudioPreview filePath={filePath!} projectName={projectName!} /></Suspense>;
516
519
 
@@ -0,0 +1,92 @@
1
+ import { useEffect, useState } from "react";
2
+ import { Loader2, FileWarning } from "lucide-react";
3
+ import { api, projectUrl } from "@/lib/api-client";
4
+
5
+ interface DocxPreviewProps {
6
+ filePath: string;
7
+ projectName?: string;
8
+ }
9
+
10
+ /** Preview .docx files by converting to HTML via mammoth on the backend */
11
+ export function DocxPreview({ filePath, projectName }: DocxPreviewProps) {
12
+ const [html, setHtml] = useState<string | null>(null);
13
+ const [loading, setLoading] = useState(true);
14
+ const [error, setError] = useState<string | null>(null);
15
+
16
+ useEffect(() => {
17
+ setLoading(true);
18
+ setError(null);
19
+
20
+ const isExternal = /^(\/|[A-Za-z]:[/\\])/.test(filePath);
21
+ const url = isExternal
22
+ ? `/api/fs/docx-html?path=${encodeURIComponent(filePath)}`
23
+ : `${projectUrl(projectName!)}/files/docx-html?path=${encodeURIComponent(filePath)}`;
24
+
25
+ api
26
+ .get<{ html: string }>(url)
27
+ .then((data) => {
28
+ setHtml(data.html);
29
+ setLoading(false);
30
+ })
31
+ .catch((err) => {
32
+ setError(err instanceof Error ? err.message : "Failed to convert docx");
33
+ setLoading(false);
34
+ });
35
+ }, [filePath, projectName]);
36
+
37
+ // Re-fetch on file change events
38
+ useEffect(() => {
39
+ const handler = (e: Event) => {
40
+ const detail = (e as CustomEvent).detail;
41
+ if (detail.projectName !== projectName || detail.path !== filePath) return;
42
+
43
+ const isExternal = /^(\/|[A-Za-z]:[/\\])/.test(filePath);
44
+ const url = isExternal
45
+ ? `/api/fs/docx-html?path=${encodeURIComponent(filePath)}`
46
+ : `${projectUrl(projectName!)}/files/docx-html?path=${encodeURIComponent(filePath)}`;
47
+
48
+ api.get<{ html: string }>(url).then((data) => setHtml(data.html)).catch(() => {});
49
+ };
50
+ window.addEventListener("file:changed", handler);
51
+ return () => window.removeEventListener("file:changed", handler);
52
+ }, [filePath, projectName]);
53
+
54
+ if (loading) {
55
+ return (
56
+ <div className="flex items-center justify-center h-full gap-2 text-text-secondary">
57
+ <Loader2 className="size-5 animate-spin" />
58
+ <span className="text-sm">Converting document...</span>
59
+ </div>
60
+ );
61
+ }
62
+
63
+ if (error) {
64
+ return (
65
+ <div className="flex flex-col items-center justify-center h-full gap-3 text-text-secondary">
66
+ <FileWarning className="size-10 text-text-subtle" />
67
+ <p className="text-sm">Failed to load document.</p>
68
+ <p className="text-xs text-text-subtle">{error}</p>
69
+ </div>
70
+ );
71
+ }
72
+
73
+ return (
74
+ <div className="h-full overflow-auto bg-white dark:bg-zinc-900">
75
+ <div
76
+ className="docx-preview max-w-3xl mx-auto px-6 py-8 text-sm text-foreground leading-relaxed
77
+ [&_table]:border-collapse [&_table]:w-full [&_table]:my-3
78
+ [&_td]:border [&_td]:border-border [&_td]:px-2 [&_td]:py-1
79
+ [&_th]:border [&_th]:border-border [&_th]:px-2 [&_th]:py-1 [&_th]:font-semibold [&_th]:bg-muted/50
80
+ [&_img]:max-w-full [&_img]:h-auto [&_img]:rounded
81
+ [&_h1]:text-2xl [&_h1]:font-bold [&_h1]:mt-6 [&_h1]:mb-3
82
+ [&_h2]:text-xl [&_h2]:font-semibold [&_h2]:mt-5 [&_h2]:mb-2
83
+ [&_h3]:text-lg [&_h3]:font-medium [&_h3]:mt-4 [&_h3]:mb-2
84
+ [&_p]:my-2
85
+ [&_ul]:list-disc [&_ul]:pl-6 [&_ul]:my-2
86
+ [&_ol]:list-decimal [&_ol]:pl-6 [&_ol]:my-2
87
+ [&_li]:my-0.5"
88
+ dangerouslySetInnerHTML={{ __html: html ?? "" }}
89
+ />
90
+ </div>
91
+ );
92
+ }
@@ -44,7 +44,7 @@ export function CommandPaletteFilterChips({
44
44
  aria-checked={isActive}
45
45
  aria-label={`Filter by ${meta.label}`}
46
46
  onClick={() => onToggle(group)}
47
- className={`inline-flex items-center gap-1 shrink-0 rounded-full border px-2.5 min-h-[44px] text-xs font-medium transition-colors ${
47
+ className={`inline-flex items-center gap-1 shrink-0 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${
48
48
  isActive
49
49
  ? "bg-accent/15 border-accent text-accent"
50
50
  : "bg-surface border-border text-text-subtle hover:bg-surface-elevated"
@@ -1,8 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/markdown-renderer-YnP2OcPh.js","assets/rolldown-runtime-FhOqtrmT.js","assets/index-Di7q5I27.js","assets/vendor-mermaid-DCie7hiR.js","assets/vendor-ui-UXCWAcmi.js","assets/vendor-markdown-0Mxgxy0L.js","assets/input-B78ol0hV.js","assets/utils-E0yyGxXt.js","assets/createLucideIcon-BjHrJDVb.js","assets/x-DfF6D5Js.js","assets/settings-store-CSDOihqv.js","assets/react-CfveccaI.js","assets/api-client-DiZgVOok.js","assets/eye-off-BacF7RVS.js","assets/ai-settings-section-BH2UOQH-.js","assets/chevron-down-BMo4cBth.js","assets/globe-CQ8NAYvi.js","assets/trash-2-DkIfBY8d.js","assets/refresh-cw-CRD2qr4U.js","assets/api-settings-uQKmeGkl.js","assets/database-Dc8mr-dP.js","assets/chevron-right-CD8e6Aj4.js","assets/search-D90WJ5fo.js","assets/panel-store-B1pOXkyS.js","assets/project-store-BnvrVKBw.js","assets/tab-store-DzftzxTL.js","assets/index-DwvSM9vu.css","assets/csv-preview-DgArUJhd.js","assets/lib-DrypSCq8.js","assets/arrow-down-D825m4vm.js","assets/arrow-up-Rcw6_KKu.js","assets/csv-parser-D8VHWVA6.js","assets/image-preview-CJ8Qqjgt.js","assets/file-exclamation-point-B__2Hrd6.js","assets/use-blob-url-DCUIEzjB.js","assets/pdf-preview-D3Y2rNVC.js","assets/video-preview-EhN6q3Xv.js","assets/audio-preview-D8onaG_2.js"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import"./vendor-ui-UXCWAcmi.js";import{t as r}from"./createLucideIcon-BjHrJDVb.js";import{t as i}from"./database-Dc8mr-dP.js";import{t as a}from"./chevron-right-CD8e6Aj4.js";import{a as o,l as s,n as c,o as l,r as u,s as d,t as f}from"./input-B78ol0hV.js";import{t as p}from"./code-DiNmA3eR.js";import{i as m,r as h}from"./trash-2-DkIfBY8d.js";import{t as ee}from"./file-exclamation-point-B__2Hrd6.js";import{i as g,r as te,t as _}from"./glide-data-grid-BJ3Wn9to.js";import{t as v}from"./table-2wDtM4_B.js";import{t as y}from"./text-wrap-AZErifCu.js";import{t as b}from"./x-DfF6D5Js.js";import{i as ne,t as x}from"./api-client-DiZgVOok.js";import{n as re}from"./settings-store-CSDOihqv.js";import{K as S}from"./vendor-mermaid-DCie7hiR.js";import{t as C}from"./utils-E0yyGxXt.js";import{t as ie}from"./panel-store-B1pOXkyS.js";import{n as w}from"./project-store-BnvrVKBw.js";import{t as ae}from"./tab-store-DzftzxTL.js";import{H as T,O as E,X as oe,_ as se,at as ce,ct as D,d as O,et as k,f as le,ft as A,h as j,it as M,l as N,lt as P,m as F,o as ue,ot as I,p as de,rt as fe,s as pe,st as L,tt as me,u as he,v as ge}from"./index-Di7q5I27.js";import"./data-grid-types-C29KDkZJ.js";import{n as _e,t as ve}from"./use-monaco-theme-qx6SfVRk.js";var ye=r(`redo-2`,[[`path`,{d:`m15 14 5-5-5-5`,key:`12vg1m`}],[`path`,{d:`M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13`,key:`6uklza`}]]),R=e(n(),1),z=t(),B={ts:L,tsx:L,js:L,jsx:L,py:L,rs:L,go:L,html:L,css:L,scss:L,json:D,md:I,txt:I,yaml:ce,yml:ce};function be(e,t){return t?fe:B[e.split(`.`).pop()?.toLowerCase()??``]??M}function xe(e,t){let n=[],r=e,i=``;for(let e=0;e<t.length;e++){let a=t[e],o=t.slice(0,e+1).join(`/`),s=r.find(e=>e.name===a);if(n.push({name:a,fullPath:o,node:s??null,siblings:r,parentPath:i}),s?.children)i=s.path,r=s.children;else{for(let r=e+1;r<t.length;r++)n.push({name:t[r],fullPath:t.slice(0,r+1).join(`/`),node:null,siblings:[],parentPath:t.slice(0,r).join(`/`)});break}}return n}function V(e){return[...e].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1)}function Se({filePath:e,projectName:t,tabId:n,className:r}){let i=E(e=>e.tree),{updateTab:o,openTab:s}=ae(se(e=>({updateTab:e.updateTab,openTab:e.openTab}))),c=w(e=>e.projects.find(e=>e.name===t)?.path??``),l=(0,R.useRef)(null),{prefixParts:u,relativePath:d}=(0,R.useMemo)(()=>{let t=e.startsWith(`/`)?e.slice(1):e,n=c.startsWith(`/`)?c.slice(1):c;if(n&&t.startsWith(n+`/`)){let e=t.slice(n.length+1);return{prefixParts:n.split(`/`),relativePath:e}}return{prefixParts:[],relativePath:t}},[e,c]),f=(0,R.useMemo)(()=>xe(i,d.split(`/`).filter(Boolean)),[i,d]);(0,R.useEffect)(()=>{l.current&&(l.current.scrollLeft=l.current.scrollWidth)},[f]);function p(e,r){let i=C(e);r.metaKey||r.ctrlKey?s({type:`editor`,title:i,metadata:{filePath:e,projectName:t},projectId:t,closable:!0}):o(n,{title:i,metadata:{filePath:e,projectName:t}})}return(0,z.jsxs)(`div`,{ref:l,className:r,children:[u.map((e,t)=>(0,z.jsxs)(`div`,{className:`flex items-center shrink-0`,children:[t>0&&(0,z.jsx)(a,{className:`size-3 text-muted-foreground shrink-0 mx-0.5`}),(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground px-1 py-0.5`,children:e})]},`prefix-${t}`)),f.map((e,n)=>(0,z.jsxs)(`div`,{className:`flex items-center shrink-0`,children:[(n>0||u.length>0)&&(0,z.jsx)(a,{className:`size-3 text-muted-foreground shrink-0 mx-0.5`}),(0,z.jsx)(Ce,{segment:e,isLast:n===f.length-1,projectName:t,onFileClick:p})]},e.fullPath))]})}function Ce({segment:e,isLast:t,projectName:n,onFileClick:r}){let i=E(e=>e.loadChildren),a=E(e=>e.loadedPaths),o=(0,R.useMemo)(()=>V(e.siblings),[e.siblings]),s=a.has(e.parentPath);function c(t){if(t&&!s){let t=e.parentPath.split(`/`).filter(Boolean);(async()=>{for(let e=0;e<=t.length;e++)await i(n,t.slice(0,e).join(`/`))})()}}return(0,z.jsxs)(N,{onOpenChange:c,children:[(0,z.jsx)(j,{asChild:!0,children:(0,z.jsx)(`button`,{type:`button`,className:`text-xs px-1 py-0.5 rounded hover:bg-muted transition-colors truncate max-w-[120px] ${t?`text-foreground font-medium`:`text-muted-foreground`}`,children:e.name})}),(0,z.jsx)(he,{align:`start`,className:`max-h-[300px] p-1`,children:o.length===0?(0,z.jsx)(O,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):o.map(t=>(0,z.jsx)(H,{node:t,projectName:n,activePath:e.fullPath,onFileClick:r},t.path))})]})}function H({node:e,projectName:t,activePath:n,onFileClick:r}){let i=be(e.name,e.type===`directory`),a=e.path===n,o=E(e=>e.loadChildren),s=E(e=>e.loadedPaths);if(e.type===`directory`){let c=e.children??[],l=s.has(e.path);function u(n){n&&!l&&o(t,e.path)}return(0,z.jsxs)(le,{onOpenChange:u,children:[(0,z.jsxs)(F,{className:`text-xs gap-1.5 ${a?`bg-muted`:``}`,children:[(0,z.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,z.jsx)(`span`,{className:`truncate`,children:e.name})]}),(0,z.jsx)(de,{className:`max-h-[300px] overflow-y-auto p-1`,children:c.length===0?(0,z.jsx)(O,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):V(c).map(e=>(0,z.jsx)(H,{node:e,projectName:t,activePath:n,onFileClick:r},e.path))})]})}return(0,z.jsxs)(O,{className:`text-xs gap-1.5 cursor-pointer ${a?`bg-muted`:``}`,onSelect:e=>{},onClick:t=>{r(e.path,t)},children:[(0,z.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,z.jsx)(`span`,{className:`truncate`,children:e.name})]})}function U({active:e,onClick:t,icon:n,label:r}){return(0,z.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-1 px-2 py-1 rounded text-xs transition-colors ${e?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[(0,z.jsx)(n,{className:`size-3`}),(0,z.jsx)(`span`,{className:`hidden sm:inline`,children:r})]})}function we({ext:e,mdMode:t,onMdModeChange:n,csvMode:r,onCsvModeChange:i,wordWrap:a,onToggleWordWrap:o,filePath:s,projectName:c,className:l}){return(0,z.jsxs)(`div`,{className:l,children:[(e===`md`||e===`mdx`)&&n&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(U,{active:t===`edit`,onClick:()=>n(`edit`),icon:p,label:`Edit`}),(0,z.jsx)(U,{active:t===`preview`,onClick:()=>n(`preview`),icon:h,label:`Preview`})]}),e===`csv`&&i&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(U,{active:r===`table`,onClick:()=>i(`table`),icon:v,label:`Table`}),(0,z.jsx)(U,{active:r===`raw`,onClick:()=>i(`raw`),icon:p,label:`Raw`})]}),(0,z.jsx)(U,{active:a,onClick:o,icon:y,label:`Wrap`}),s&&c&&(0,z.jsx)(U,{active:!1,onClick:()=>ge(c,s),icon:m,label:`Download`})]})}function Te({open:e,defaultName:t,content:n,onSave:r,onCancel:i}){let[a,p]=(0,R.useState)(t),[m,h]=(0,R.useState)(!1),[ee,g]=(0,R.useState)(``),te=w(e=>e.activeProject),_=(0,R.useCallback)(()=>{let e=a.trim();if(!e){g(`Filename cannot be empty`);return}if(/[/\\]/.test(e)){g(`Filename cannot contain / or \\`);return}g(``),h(!0)},[a]),v=(0,R.useCallback)(e=>{let t=e.includes(`\\`)?`\\`:`/`;r(e.endsWith(t)?`${e}${a.trim()}`:`${e}${t}${a.trim()}`,n)},[a,n,r]);return m?(0,z.jsx)(pe,{open:!0,mode:`folder`,root:te?.path,title:`Save "${a.trim()}" to...`,onSelect:v,onCancel:()=>h(!1)}):(0,z.jsx)(c,{open:e,onOpenChange:e=>{e||i()},children:(0,z.jsxs)(u,{className:`sm:max-w-md`,children:[(0,z.jsx)(l,{children:(0,z.jsx)(d,{children:`Save As`})}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[(0,z.jsx)(`label`,{className:`text-sm text-muted-foreground`,children:`Filename`}),(0,z.jsx)(f,{value:a,onChange:e=>{p(e.target.value),g(``)},onKeyDown:e=>{e.key===`Enter`&&_()},placeholder:`e.g. my-file.ts`,autoFocus:!0}),ee&&(0,z.jsx)(`p`,{className:`text-xs text-destructive`,children:ee})]}),(0,z.jsxs)(o,{children:[(0,z.jsx)(s,{variant:`outline`,onClick:i,children:`Cancel`}),(0,z.jsx)(s,{onClick:_,children:`Choose Folder...`})]})]})})}var W=typeof window<`u`&&window.isSecureContext,Ee=[`(`,`)`,`{`,`}`,`[`,`]`,`<`,`>`,`;`,`:`,`=`,`"`,`'`,"`",`/`,`\\`,`_`,`#`],G=`px-2 py-1.5 rounded text-xs min-w-[36px] min-h-[32px] bg-surface-elevated text-text-primary active:bg-primary active:text-primary-foreground transition-colors select-none`,K=`px-3 py-1.5 rounded text-xs font-mono min-w-[36px] min-h-[32px] bg-surface-elevated text-text-primary active:bg-primary active:text-primary-foreground transition-colors select-none`,De=`w-px h-5 bg-border mx-0.5 shrink-0`;function Oe({editorRef:e,readOnly:t}){let n=(0,R.useCallback)(()=>e.current,[e]),r=(0,R.useCallback)(e=>{let t=n();if(!t)return;t.focus();let r=t.getSelection();r&&t.executeEdits(`mobile-toolbar`,[{range:r,text:e}])},[n]),[i,a]=(0,R.useState)(!1),o=(0,R.useRef)(null),s=(0,R.useCallback)(async()=>{try{let e=await navigator.clipboard.readText();e&&r(e)}catch{}},[r]),c=(0,R.useCallback)(()=>{a(!0),requestAnimationFrame(()=>o.current?.focus())},[]),l=(0,R.useCallback)(e=>{e.preventDefault();let t=e.clipboardData.getData(`text/plain`);t&&(a(!1),r(t))},[r]),u=(0,R.useCallback)(()=>{let e=n();e&&(e.focus(),e.trigger(`mobile-toolbar`,`undo`,null))},[n]),d=(0,R.useCallback)(()=>{let e=n();e&&(e.focus(),e.trigger(`mobile-toolbar`,`redo`,null))},[n]),f=(0,R.useCallback)(()=>{let e=n();e&&(e.focus(),e.trigger(`mobile-toolbar`,`tab`,null))},[n]);return t?null:(0,z.jsxs)(`div`,{className:`shrink-0 border-t border-border bg-surface`,children:[!W&&i&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 border-b border-border bg-muted/50`,children:[(0,z.jsx)(`textarea`,{ref:o,onPaste:l,placeholder:`Long-press here → Paste`,className:`flex-1 h-8 rounded border border-border bg-background text-foreground text-xs px-2 py-1.5 resize-none focus:outline-none focus:ring-1 focus:ring-primary`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>a(!1),className:`p-1.5 rounded text-muted-foreground active:bg-muted transition-colors`,children:(0,z.jsx)(b,{size:14})})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1.5 overflow-x-auto`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:W?s:c,className:G,title:`Paste`,children:(0,z.jsx)(A,{size:14})}),(0,z.jsx)(`button`,{type:`button`,onClick:u,className:G,title:`Undo`,children:(0,z.jsx)(T,{size:14})}),(0,z.jsx)(`button`,{type:`button`,onClick:d,className:G,title:`Redo`,children:(0,z.jsx)(ye,{size:14})}),(0,z.jsx)(`div`,{className:De}),(0,z.jsx)(`button`,{type:`button`,onClick:f,className:K,children:`Tab`}),(0,z.jsx)(`div`,{className:De}),Ee.map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:K,children:e},e))]})]})}var ke=(0,R.lazy)(()=>S(()=>import(`./markdown-renderer-YnP2OcPh.js`).then(e=>({default:e.MarkdownRenderer})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]))),Ae=(0,R.lazy)(()=>S(()=>import(`./csv-preview-DgArUJhd.js`).then(e=>({default:e.CsvPreview})),__vite__mapDeps([27,1,4,5,28,29,8,30,31]))),je=(0,R.lazy)(()=>S(()=>import(`./image-preview-CJ8Qqjgt.js`).then(e=>({default:e.ImagePreview})),__vite__mapDeps([32,2,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,33,34]))),Me=(0,R.lazy)(()=>S(()=>import(`./pdf-preview-D3Y2rNVC.js`).then(e=>({default:e.PdfPreview})),__vite__mapDeps([35,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,33]))),Ne=(0,R.lazy)(()=>S(()=>import(`./video-preview-EhN6q3Xv.js`).then(e=>({default:e.VideoPreview})),__vite__mapDeps([36,2,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,33,34]))),Pe=(0,R.lazy)(()=>S(()=>import(`./audio-preview-D8onaG_2.js`).then(e=>({default:e.AudioPreview})),__vite__mapDeps([37,2,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,33,34]))),Fe=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`ico`]),Ie=new Set([`mp4`,`webm`,`mov`,`ogg`,`avi`,`mkv`]),Le=new Set([`mp3`,`wav`,`flac`,`aac`,`m4a`,`wma`]),Re=new Set([`db`,`sqlite`,`sqlite3`]);function ze(e){return e.split(`.`).pop()?.toLowerCase()??``}function Be(e){return{js:`javascript`,jsx:`javascript`,ts:`typescript`,tsx:`typescript`,py:`python`,html:`html`,css:`css`,scss:`scss`,json:`json`,md:`markdown`,mdx:`markdown`,yaml:`yaml`,yml:`yaml`,sh:`shell`,bash:`shell`,sql:`sql`}[ze(e)]??`plaintext`}var q=(0,R.memo)(function({metadata:e,tabId:t}){let n=e?.filePath,r=e?.projectName,a=e?.inlineContent,o=e?.inlineLanguage,[s,c]=(0,R.useState)(a??null),[l,u]=(0,R.useState)(`utf-8`),[d,f]=(0,R.useState)(!0),[p,m]=(0,R.useState)(null),[h,_]=(0,R.useState)(!1),v=(0,R.useRef)(null),y=(0,R.useRef)(``),b=(0,R.useRef)(null),{tabs:S,updateTab:w}=ae(se(e=>({tabs:e.tabs,updateTab:e.updateTab}))),{wordWrap:T,toggleWordWrap:E}=re(se(e=>({wordWrap:e.wordWrap,toggleWordWrap:e.toggleWordWrap}))),ce=ve(),D=e?.isUntitled===!0,O=e?.unsavedContent,[le,A]=(0,R.useState)(!1),j=S.find(e=>e.id===t),M=n?ze(n):``,N=Fe.has(M),P=M===`pdf`,F=Ie.has(M),I=Le.has(M),de=Re.has(M),fe=M===`md`||M===`mdx`,pe=M===`csv`,L=M===`sql`,[me,he]=(0,R.useState)(`preview`),[ge,ye]=(0,R.useState)(`table`),{connections:B,cachedTables:be,refreshTables:xe}=ue(),[V,Ce]=(0,R.useState)(()=>{if(!L||!n)return null;let e=localStorage.getItem(`ppm:sql-conn:${n}`);return e?Number(e):null}),H=(0,R.useRef)(null),U=(0,R.useRef)(null),W=(0,R.useMemo)(()=>B.find(e=>e.id===V)??null,[B,V]),Ee=a!=null&&(o===`json`||o===`xml`),[G,K]=(0,R.useState)(!1),De=(0,R.useCallback)(()=>{if(a)if(G)c(a),K(!1);else{let e=a.trimStart();if(o===`json`)try{c(JSON.stringify(JSON.parse(e),null,2)),K(!0)}catch{}else if(o===`xml`){let t=0;c(e.replace(/(>)(<)(\/*)/g,`$1
3
- $2$3`).split(`
4
- `).map(e=>{let n=e.trim();n.startsWith(`</`)&&(t=Math.max(0,t-1));let r=` `.repeat(t)+n;return n.startsWith(`<`)&&!n.startsWith(`</`)&&!n.endsWith(`/>`)&&!n.includes(`</`)&&t++,r}).join(`
5
- `)),K(!0)}}},[a,o,G]),ke=(0,R.useCallback)(e=>{Ce(e),n&&localStorage.setItem(`ppm:sql-conn:${n}`,String(e)),xe(e).catch(()=>{})},[n,xe]),q=(0,R.useMemo)(()=>{if(!L||!V)return;let e=(be.get(V)??[]).map(e=>({name:e.tableName,schema:e.schemaName}));if(e.length!==0)return{tables:e,getColumns:async(e,t)=>x.get(`/api/db/connections/${V}/schema?table=${encodeURIComponent(e)}${t?`&schema=${encodeURIComponent(t)}`:``}`)}},[L,V,be]);(0,R.useEffect)(()=>{if(!(!H.current||!q))return U.current?.dispose(),te(),U.current=H.current.languages.registerCompletionItemProvider(`sql`,g(H.current,q)),()=>{U.current?.dispose()}},[q]);let J=ae(e=>e.openTab),[Ue,We]=(0,R.useState)(null),[Ge,Ke]=(0,R.useState)(null),[qe,Je]=(0,R.useState)(!1),[Ye,Xe]=(0,R.useState)(``),X=(0,R.useCallback)(async e=>{if(W){Je(!0),Ke(null),Xe(e);try{We(await x.post(`/api/db/connections/${W.id}/query`,{sql:e}))}catch(e){Ke(e.message),We(null)}finally{Je(!1)}}},[W]),Ze=(0,R.useCallback)(()=>{!W||!Ye||J({type:`database`,title:`${W.name} · Query`,projectId:null,closable:!0,metadata:{connectionId:W.id,connectionName:W.name,dbType:W.type,initialSql:Ye}})},[W,J,Ye]),Qe=(0,R.useCallback)(()=>{if(!b.current||!W)return;let e=b.current,t=e.getSelection();X(t&&!t.isEmpty()?e.getModel()?.getValueInRange(t)??e.getValue():e.getValue())},[W,X]),$e=typeof window<`u`&&`ontouchstart`in window,et=(0,R.useRef)(null),[tt,nt]=(0,R.useState)(null);(0,R.useEffect)(()=>{if(!$e)return;let e=window.visualViewport;if(!e)return;let t=()=>{let t=et.current;if(!t)return;let n=t.getBoundingClientRect().top;nt(e.height-Math.max(0,n))};return e.addEventListener(`resize`,t),e.addEventListener(`scroll`,t),()=>{e.removeEventListener(`resize`,t),e.removeEventListener(`scroll`,t)}},[$e]);let Z=(0,R.useRef)([]),rt=(0,R.useRef)(X);rt.current=X,(0,R.useEffect)(()=>()=>{Z.current.forEach(e=>e.dispose()),Z.current=[]},[]),(0,R.useEffect)(()=>{de&&t&&w(t,{type:`sqlite`})},[de,t,w]);let Q=n?/^(\/|[A-Za-z]:[/\\])/.test(n):!1;(0,R.useEffect)(()=>{if(a!=null){f(!1);return}if(D){c(O??``),y.current=O??``,f(!1),O&&_(!0);return}if(!n||!Q&&!r)return;if(N||P||F||I){f(!1);return}f(!0),m(null);let e=Q?`/api/fs/read?path=${encodeURIComponent(n)}`:`${ne(r)}/files/read?path=${encodeURIComponent(n)}`;return x.get(e).then(e=>{c(e.content),e.encoding&&u(e.encoding),y.current=e.content,f(!1)}).catch(e=>{m(e instanceof Error?e.message:`Failed to load file`),f(!1)}),()=>{v.current&&clearTimeout(v.current)}},[n,r,N,P,Q,D]);let it=(0,R.useRef)(h);it.current=h,(0,R.useEffect)(()=>{if(!n||!r||a!=null||D)return;let e=e=>{let t=e.detail;if(t.projectName!==r||t.path!==n||it.current)return;let i=Q?`/api/fs/read?path=${encodeURIComponent(n)}`:`${ne(r)}/files/read?path=${encodeURIComponent(n)}`;x.get(i).then(e=>{e.content!==y.current&&(c(e.content),y.current=e.content,e.encoding&&u(e.encoding))}).catch(()=>{})};return window.addEventListener(`file:changed`,e),()=>window.removeEventListener(`file:changed`,e)},[n,r,Q,a,D]),(0,R.useEffect)(()=>{if(!j||a!=null)return;let t=D?`Untitled-${e?.untitledNumber??1}`:n?C(n):`Untitled`,r=h?`${t} \u25CF`:t;j.title!==r&&w(j.id,{title:r})},[h]);let at=(0,R.useCallback)(async e=>{if(n&&!(!Q&&!r))try{Q?await x.put(`/api/fs/write`,{path:n,content:e}):await x.put(`${ne(r)}/files/write`,{path:n,content:e}),_(!1)}catch{}},[n,r,Q]);function ot(n){let r=n??``;c(r),y.current=r,_(!0),v.current&&clearTimeout(v.current),D?v.current=setTimeout(()=>{t&&w(t,{metadata:{...e,unsavedContent:y.current}})},2e3):v.current=setTimeout(()=>at(y.current),1e3)}let st=(0,R.useCallback)(async(e,n)=>{try{if(v.current&&clearTimeout(v.current),await x.put(`/api/fs/write`,{path:e,content:n}),t){let{closeTab:n,openTab:r}=ie.getState();n(t),r({type:`editor`,title:C(e),projectId:null,metadata:{filePath:e},closable:!0})}_(!1),A(!1)}catch{}},[t]),$=e?.lineNumber,ct=(0,R.useCallback)((e,t)=>{if(b.current=e,H.current=t,$&&$>0&&setTimeout(()=>{e.revealLineInCenter($),e.setPosition({lineNumber:$,column:1}),e.focus()},100),D&&e.addCommand(t.KeyMod.CtrlCmd|t.KeyCode.KeyS,()=>A(!0)),e.addCommand(t.KeyMod.Alt|t.KeyCode.KeyZ,()=>re.getState().toggleWordWrap()),t.languages.typescript.typescriptDefaults.setDiagnosticsOptions({noSemanticValidation:!0,noSyntaxValidation:!0,noSuggestionDiagnostics:!0}),t.languages.typescript.javascriptDefaults.setDiagnosticsOptions({noSemanticValidation:!0,noSyntaxValidation:!0,noSuggestionDiagnostics:!0}),q&&(U.current?.dispose(),U.current=t.languages.registerCompletionItemProvider(`sql`,g(t,q))),L){Z.current.forEach(e=>e.dispose()),Z.current=[];let n=e.getModel(),r=e.addCommand(0,(e,t)=>{t&&rt.current(t)});if(r&&n){let e=t.languages.registerCodeLensProvider(`sql`,{provideCodeLenses:e=>{if(e!==n)return{lenses:[],dispose:()=>{}};let t=[],i=e.getValue().split(`
6
- `),a=-1,o=[],s=!1,c=(e,n)=>{let i=n.trim();!i||i.startsWith(`--`)||t.push({range:{startLineNumber:e,startColumn:1,endLineNumber:e,endColumn:1},command:{id:r,title:`▷ Run`,arguments:[i]}})};for(let e=0;e<i.length;e++){let t=i[e].trim();if(a===-1){if(!t||t.startsWith(`--`))continue;a=e+1,o=[]}o.push(i[e]),(t.match(/\$\$/g)||[]).length%2==1&&(s=!s),!s&&t.endsWith(`;`)&&(c(a,o.join(`
7
- `)),a=-1,o=[])}return a>0&&o.join(``).trim()&&c(a,o.join(`
8
- `)),{lenses:t,dispose:()=>{}}}});Z.current.push(e)}}},[q]);if(!a&&!D&&(!n||!Q&&!r))return(0,z.jsx)(`div`,{className:`flex items-center justify-center h-full text-text-secondary text-sm`,children:`No file selected.`});if(d)return(0,z.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-text-secondary`,children:[(0,z.jsx)(k,{className:`size-5 animate-spin`}),(0,z.jsx)(`span`,{className:`text-sm`,children:`Loading file...`})]});if(p)return(0,z.jsx)(`div`,{className:`flex items-center justify-center h-full text-error text-sm`,children:p});if(N)return(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(Y,{}),children:(0,z.jsx)(je,{filePath:n,projectName:r})});if(P)return(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(Y,{}),children:(0,z.jsx)(Me,{filePath:n,projectName:r})});if(F)return(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(Y,{}),children:(0,z.jsx)(Ne,{filePath:n,projectName:r})});if(I)return(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(Y,{}),children:(0,z.jsx)(Pe,{filePath:n,projectName:r})});if(l===`base64`)return(0,z.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,z.jsx)(ee,{className:`size-10 text-text-subtle`}),(0,z.jsx)(`p`,{className:`text-sm`,children:`This file is a binary format and cannot be displayed.`}),(0,z.jsx)(`p`,{className:`text-xs text-text-subtle`,children:n})]});let lt=L?(0,z.jsxs)(`div`,{className:`shrink-0 flex items-center gap-1 px-2 border-l border-border`,children:[(0,z.jsx)(i,{className:`size-3 text-muted-foreground`}),(0,z.jsxs)(`select`,{value:V??``,onChange:e=>{let t=Number(e.target.value);t&&ke(t)},className:`h-5 text-[10px] bg-transparent border border-border rounded px-1 text-foreground outline-none max-w-[140px]`,title:`Select connection for autocomplete`,children:[(0,z.jsx)(`option`,{value:``,children:`Connection…`}),B.map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,z.jsx)(`button`,{type:`button`,onClick:Qe,disabled:!W,className:`p-0.5 rounded text-muted-foreground hover:text-primary disabled:opacity-30 transition-colors`,title:`Run SQL`,children:(0,z.jsx)(oe,{className:`size-3.5`})})]}):null;return(0,z.jsxs)(`div`,{ref:et,className:`flex flex-col h-full w-full overflow-hidden`,style:tt?{height:`${tt}px`,maxHeight:`${tt}px`}:void 0,children:[a!=null&&Ee&&(0,z.jsx)(`div`,{className:`flex items-center h-7 border-b border-border bg-background shrink-0 px-2 gap-2`,children:(0,z.jsx)(`button`,{type:`button`,onClick:De,className:`text-[10px] px-2 py-0.5 rounded border border-border hover:bg-muted transition-colors text-foreground`,children:G?`Raw`:`Beautify`})}),n&&r&&t&&(0,z.jsxs)(`div`,{className:`hidden md:flex items-center h-7 border-b border-border bg-background shrink-0`,children:[(0,z.jsx)(Se,{filePath:n,projectName:r,tabId:t,className:`flex items-center flex-1 min-w-0 overflow-x-auto scrollbar-none px-2 gap-0.5`}),lt,(0,z.jsx)(we,{ext:M,mdMode:me,onMdModeChange:he,csvMode:ge,onCsvModeChange:ye,wordWrap:T,onToggleWordWrap:E,filePath:n,projectName:r,className:`shrink-0 flex items-center gap-1 px-2`})]}),L&&(!r||!t)&&(0,z.jsxs)(`div`,{className:`hidden md:flex items-center h-7 border-b border-border bg-background shrink-0 px-2`,children:[(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground truncate flex-1`,children:n?C(n):`SQL`}),lt]}),pe&&ge===`table`?(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,z.jsx)(k,{className:`size-5 animate-spin text-text-subtle`})}),children:(0,z.jsx)(Ae,{content:s??``,onContentChange:ot,wordWrap:T})}):fe&&me===`preview`?(0,z.jsx)(He,{content:s??``}):(0,z.jsx)(`div`,{className:`flex-1 overflow-hidden min-h-0`,children:(0,z.jsx)(_e,{height:`100%`,language:o??Be(n??``),value:s??``,onChange:a==null?ot:void 0,onMount:ct,theme:ce,options:{fontSize:13,fontFamily:`Menlo, Monaco, Consolas, monospace`,wordWrap:T?`on`:`off`,minimap:{enabled:!1},scrollBeyondLastLine:!1,automaticLayout:!0,lineNumbers:`on`,folding:!0,bracketPairColorization:{enabled:!0},readOnly:a!=null},loading:(0,z.jsx)(k,{className:`size-5 animate-spin text-text-subtle`})})}),L&&(Ue||Ge||qe)&&(0,z.jsx)(Ve,{result:Ue,error:Ge,loading:qe,connName:W?.name,onClose:()=>{We(null),Ke(null),Je(!1)},onOpenInTab:Ze}),$e&&(0,z.jsx)(Oe,{editorRef:b,readOnly:a!=null}),le&&(0,z.jsx)(Te,{open:le,defaultName:`Untitled-${e?.untitledNumber??1}`,content:y.current,onSave:st,onCancel:()=>A(!1)})]})}),J=()=>{};function Ve({result:e,error:t,loading:n,connName:r,onClose:a,onOpenInTab:o}){let s=(0,R.useMemo)(()=>e?.changeType===`select`&&e.rows.length>0?{columns:e.columns,rows:e.rows,total:e.rows.length,limit:e.rows.length}:null,[e]),c=(0,R.useMemo)(()=>(e?.columns??[]).map(e=>({name:e,type:`text`,nullable:!0,pk:!1,defaultValue:null})),[e?.columns]),[l,u]=(0,R.useState)(250),d=(0,R.useCallback)(e=>{e.preventDefault();let t=e.clientY,n=l,r=e=>u(Math.max(80,n+(t-e.clientY))),i=()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)},[l]);return(0,z.jsxs)(`div`,{className:`shrink-0 border-t border-border flex flex-col`,style:{height:l},children:[(0,z.jsx)(`div`,{onMouseDown:d,className:`shrink-0 h-1.5 cursor-row-resize bg-border/50 hover:bg-primary/30 flex items-center justify-center transition-colors`,children:(0,z.jsx)(me,{className:`size-3 text-muted-foreground/50`})}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1 bg-muted/50 border-b border-border shrink-0`,children:[(0,z.jsx)(i,{className:`size-3 text-muted-foreground`}),(0,z.jsxs)(`span`,{className:`text-xs font-medium text-foreground truncate flex-1`,children:[r?`${r} · Results`:`Query Results`,e?.executionTimeMs!=null&&(0,z.jsxs)(`span`,{className:`text-muted-foreground ml-1.5 font-normal`,children:[e.executionTimeMs,`ms`]})]}),(0,z.jsxs)(`button`,{type:`button`,onClick:o,title:`Open in DB Viewer tab`,className:`flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] text-muted-foreground hover:text-foreground hover:bg-muted transition-colors`,children:[(0,z.jsx)(P,{className:`size-3`}),(0,z.jsx)(`span`,{className:`hidden sm:inline`,children:`Open in Tab`})]}),(0,z.jsx)(`button`,{type:`button`,onClick:a,title:`Close results`,className:`p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors`,children:(0,z.jsx)(b,{className:`size-3`})})]}),(0,z.jsxs)(`div`,{className:`flex-1 overflow-hidden min-h-0`,children:[n&&(0,z.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,z.jsx)(k,{className:`size-4 animate-spin text-muted-foreground`})}),t&&(0,z.jsx)(`div`,{className:`px-3 py-2 text-xs text-destructive bg-destructive/5`,children:t}),e?.changeType===`modify`&&(0,z.jsxs)(`div`,{className:`px-3 py-2 text-xs text-green-500`,children:[e.rowsAffected,` row(s) affected`]}),s&&(0,z.jsx)(_,{columns:s.columns,rows:s.rows,total:s.total,limit:s.limit,schema:c,loading:!1,page:1,onPageChange:J,onCellUpdate:J,orderBy:null,orderDir:`ASC`,onToggleSort:J,connectionName:r}),e?.changeType===`select`&&e.rows.length===0&&(0,z.jsx)(`div`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:`No results`})]})]})}function Y(){return(0,z.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,z.jsx)(k,{className:`size-5 animate-spin text-text-subtle`})})}function He({content:e}){return(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(`div`,{className:`animate-pulse h-4 bg-muted rounded m-4`}),children:(0,z.jsx)(ke,{content:e,className:`flex-1 overflow-auto p-4`})})}export{q as CodeEditor};
@@ -1 +0,0 @@
1
- import"./vendor-markdown-0Mxgxy0L.js";import"./api-client-DiZgVOok.js";import{D as e}from"./index-Di7q5I27.js";export{e as useKeybindingsStore};
@@ -1 +0,0 @@
1
- import"./vendor-markdown-0Mxgxy0L.js";import"./api-client-DiZgVOok.js";import{P as e}from"./index-Di7q5I27.js";export{e as useNotificationStore};