@hienlh/ppm 0.17.41 → 0.17.43

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 (55) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/assets/skills/ppm/SKILL.md +1 -1
  3. package/assets/skills/ppm/references/http-api.md +1 -1
  4. package/dist/web/assets/{ai-resource-editor-bGSN2dFv.js → ai-resource-editor-CQWFrDeG.js} +1 -1
  5. package/dist/web/assets/{audio-preview-DnSpaaBX.js → audio-preview-Cyb8SLCu.js} +1 -1
  6. package/dist/web/assets/chat-tab-uBmb2rFB.js +13 -0
  7. package/dist/web/assets/code-editor-DTqFVL_2.js +10 -0
  8. package/dist/web/assets/{conflict-editor-LDIdkUJm.js → conflict-editor-BFiY6VyT.js} +3 -3
  9. package/dist/web/assets/csv-preview-DpeN7hH8.js +2 -0
  10. package/dist/web/assets/{database-viewer-RkxcBpY3.js → database-viewer-D9OT6V9B.js} +1 -1
  11. package/dist/web/assets/{diff-viewer-YTRJpdV6.js → diff-viewer-LqH4ARjy.js} +1 -1
  12. package/dist/web/assets/{docx-preview-B4B4W5LU.js → docx-preview-Dqzlw47y.js} +1 -1
  13. package/dist/web/assets/{extension-webview-CB8-nHNA.js → extension-webview-DsNuZtJO.js} +1 -1
  14. package/dist/web/assets/{git-log-panel-OXE-EtxM.js → git-log-panel-mcn-Atil.js} +1 -1
  15. package/dist/web/assets/{glide-data-grid-CCVPfJtk.js → glide-data-grid-CyZAiAgS.js} +4 -4
  16. package/dist/web/assets/group-chat-tab-CRkPysZw.js +1 -0
  17. package/dist/web/assets/{image-preview-CenSD210.js → image-preview-DnNyBpmU.js} +1 -1
  18. package/dist/web/assets/index-D4KFhwmL.js +50 -0
  19. package/dist/web/assets/keybindings-store-CtrEuZpU.js +1 -0
  20. package/dist/web/assets/{markdown-renderer-CyzYLWuu.js → markdown-renderer-BFwR1QYD.js} +2 -2
  21. package/dist/web/assets/{markdown-renderer-CAFmdvwK.js → markdown-renderer-DDFElf1k.js} +1 -1
  22. package/dist/web/assets/notification-store-BTo6li6s.js +1 -0
  23. package/dist/web/assets/{pdf-preview-CsOL51Lb.js → pdf-preview-DDRKbO4z.js} +1 -1
  24. package/dist/web/assets/{postgres-viewer-Dtt-XLSP.js → postgres-viewer-0UqxqUYu.js} +2 -2
  25. package/dist/web/assets/{settings-tab-BR9fp2pd.js → settings-tab-0VKOVbt2.js} +1 -1
  26. package/dist/web/assets/{sql-query-editor-BwquzTWY.js → sql-query-editor-Cf76aKfw.js} +1 -1
  27. package/dist/web/assets/{sqlite-viewer-YO4IEGzt.js → sqlite-viewer-CO6dK1CU.js} +1 -1
  28. package/dist/web/assets/{system-monitor-tab-C-WT_FG3.js → system-monitor-tab-BFBwiME3.js} +1 -1
  29. package/dist/web/assets/{terminal-tab-BqW8reuZ.js → terminal-tab-lu0ZsZmQ.js} +2 -2
  30. package/dist/web/assets/{tool-cards-DtF80k3f.js → tool-cards-CMQowijv.js} +3 -3
  31. package/dist/web/assets/{use-monaco-theme-CF_57XHm.js → use-monaco-theme-DU3LWaPu.js} +1 -1
  32. package/dist/web/assets/{video-preview-OoDYJ8U4.js → video-preview-CHUzaq4s.js} +1 -1
  33. package/dist/web/index.html +1 -1
  34. package/dist/web/sw.js +1 -1
  35. package/package.json +1 -1
  36. package/src/server/index.ts +2 -0
  37. package/src/server/middleware/gzip-json.ts +36 -0
  38. package/src/server/routes/files.ts +24 -0
  39. package/src/server/routes/static.ts +24 -3
  40. package/src/services/file-list-index.service.ts +34 -3
  41. package/src/services/file.service.ts +6 -0
  42. package/src/web/components/explorer/file-tree.tsx +115 -44
  43. package/src/web/components/explorer/flatten-visible-tree.ts +102 -0
  44. package/src/web/components/explorer/tree-node.tsx +82 -166
  45. package/src/web/components/explorer/use-tree-keyboard-nav.ts +3 -30
  46. package/src/web/hooks/use-chat.ts +13 -2
  47. package/src/web/stores/file-store.ts +101 -29
  48. package/src/web/stores/file-tree-prefetch.ts +57 -0
  49. package/dist/web/assets/chat-tab-Cvuo7XWm.js +0 -13
  50. package/dist/web/assets/code-editor-BvwCPxaD.js +0 -10
  51. package/dist/web/assets/csv-preview-47tAvhIq.js +0 -2
  52. package/dist/web/assets/group-chat-tab-D5rkf_zG.js +0 -1
  53. package/dist/web/assets/index-bQy6gwMT.js +0 -50
  54. package/dist/web/assets/keybindings-store-Bk2X4njD.js +0 -1
  55. package/dist/web/assets/notification-store-C9MS_FlD.js +0 -1
@@ -0,0 +1,10 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/markdown-renderer-DDFElf1k.js","assets/vendor-mermaid-CYOBtZtD.js","assets/rolldown-runtime-FhOqtrmT.js","assets/vendor-ui-DMRGWRuc.js","assets/vendor-markdown-CKTlmXbz.js","assets/markdown-renderer-BFwR1QYD.js","assets/index-D4KFhwmL.js","assets/dialog-HHdNInEH.js","assets/utils-E0yyGxXt.js","assets/createLucideIcon-ConhwJnb.js","assets/x-BsFLg-T8.js","assets/eye-off-Rq1n2-oe.js","assets/bot-E9mcVZnr.js","assets/context-menu-DIiZdfbE.js","assets/chevron-right-DeUue2aK.js","assets/use-is-mobile-BcuCjH19.js","assets/sparkles-B3DmG8PJ.js","assets/database-COYAMZaw.js","assets/plus-DcuJuDC3.js","assets/api-client-COQtP-dB.js","assets/react-8hrD3-kv.js","assets/api-settings-Do0Z0IRN.js","assets/project-store-D0ALup9Z.js","assets/panel-store-CpKvXNnm.js","assets/settings-store-BbFtHCGd.js","assets/tab-store-BQmDVh9c.js","assets/apply-theme-BSJDABU3.js","assets/resolve-theme-B9Mgd5GG.js","assets/index-BEB87kj8.css","assets/image-gallery-CObzTisL.js","assets/csv-preview-DpeN7hH8.js","assets/lib-DTaN9riD.js","assets/csv-parser-DVHBcvuE.js","assets/image-preview-DnNyBpmU.js","assets/file-exclamation-point-DBEC-Kst.js","assets/use-blob-url-B3YovXF6.js","assets/pdf-preview-DDRKbO4z.js","assets/video-preview-CHUzaq4s.js","assets/audio-preview-Cyb8SLCu.js","assets/docx-preview-Dqzlw47y.js"])))=>i.map(i=>d[i]);
2
+ import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,y as n}from"./vendor-markdown-CKTlmXbz.js";import"./vendor-ui-DMRGWRuc.js";import{t as r}from"./createLucideIcon-ConhwJnb.js";import{t as i}from"./chevron-right-DeUue2aK.js";import{a,c as o,i as s,n as c,o as l,t as u}from"./dialog-HHdNInEH.js";import{t as d}from"./code-TekEnDFM.js";import{t as f}from"./database-COYAMZaw.js";import{n as p,r as m}from"./plus-DcuJuDC3.js";import{t as ee}from"./file-exclamation-point-DBEC-Kst.js";import{a as h,i as te,r as ne,t as g}from"./glide-data-grid-CyZAiAgS.js";import{t as re}from"./shield-check-C3qYSU8a.js";import{t as ie}from"./shield-off-D5tU7gQT.js";import{t as _}from"./table-Di8pv2Y_.js";import{t as v}from"./x-BsFLg-T8.js";import{i as ae,n as y}from"./api-client-COQtP-dB.js";import{q as b}from"./vendor-mermaid-CYOBtZtD.js";import{t as oe}from"./settings-store-BbFtHCGd.js";import{t as x}from"./utils-E0yyGxXt.js";import{t as se}from"./panel-store-CpKvXNnm.js";import{i as S}from"./project-store-D0ALup9Z.js";import{t as ce}from"./tab-store-BQmDVh9c.js";import{$ as C,A as le,Gt as ue,Pt as w,Q as T,U as de,Wt as fe,X as E,Z as D,at as O,cn as k,dn as A,en as j,et as M,fn as N,gt as P,hn as pe,in as me,j as he,jt as ge,ln as _e,nt as ve,o as ye,on as be,rt as xe,sn as F,tt as I,un as L}from"./index-D4KFhwmL.js";import"./data-grid-types-BuMHLKXV.js";import{t as Se}from"./use-monaco-theme-DU3LWaPu.js";var Ce=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(t(),1),z=n();function we(e){let t=e.startsWith(`/`),n=e.split(/[/\\]/).filter(Boolean),r=e=>{let r=(t?`/`:``)+n.slice(0,e+1).join(`/`);return/^[A-Za-z]:$/.test(r)?r+`/`:r},i=t?`/`:(n[0]??``)+`/`;return n.map((e,t)=>({name:e,absPath:r(t),parentDir:t>0?r(t-1):i}))}async function Te(e){return(await y.get(`/api/fs/browse?path=${encodeURIComponent(e)}`)).entries}function B({filePath:e,projectName:t,tabId:n,className:r}){let{updateTab:a,openTab:o}=ce(E(e=>({updateTab:e.updateTab,openTab:e.openTab}))),s=(0,R.useRef)(null),c=(0,R.useMemo)(()=>we(e),[e]);(0,R.useEffect)(()=>{s.current&&(s.current.scrollLeft=s.current.scrollWidth)},[c]);let l=(0,R.useCallback)((e,r)=>{let i=x(e),s={filePath:e,projectName:t};r.metaKey||r.ctrlKey?o({type:`editor`,title:i,metadata:s,projectId:t,closable:!0}):a(n,{title:i,metadata:s})},[t,n,o,a]);return(0,z.jsx)(`div`,{ref:s,className:r,children:c.map((e,t)=>(0,z.jsxs)(`div`,{className:`flex items-center shrink-0`,children:[t>0&&(0,z.jsx)(i,{className:`size-3 text-muted-foreground shrink-0 mx-0.5`}),(0,z.jsx)(Ee,{segment:e,isLast:t===c.length-1,onFileClick:l})]},e.absPath))})}function Ee({segment:e,isLast:t,onFileClick:n}){let[r,i]=(0,R.useState)(null),[a,o]=(0,R.useState)(null);function s(t){t&&r===null&&Te(e.parentDir).then(i).catch(e=>{o(e.message||`Failed to browse`),i([])})}return(0,z.jsxs)(D,{onOpenChange:s,children:[(0,z.jsx)(xe,{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)(T,{align:`start`,className:`max-h-[300px] overflow-y-auto p-1`,children:r===null?(0,z.jsx)(C,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):a?(0,z.jsx)(C,{disabled:!0,className:`text-xs text-destructive`,children:a}):r.length===0?(0,z.jsx)(C,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Empty`}):r.map(t=>(0,z.jsx)(V,{entry:t,activePath:e.absPath,onFileClick:n},t.path))})]})}function V({entry:e,activePath:t,onFileClick:n}){let r=H(e.name,e.type===`directory`),i=e.path===t,[a,o]=(0,R.useState)(null);if(e.type===`directory`){function s(t){t&&a===null&&Te(e.path).then(o).catch(()=>o([]))}return(0,z.jsxs)(M,{onOpenChange:s,children:[(0,z.jsxs)(ve,{className:`text-xs gap-1.5 ${i?`bg-muted`:``}`,children:[(0,z.jsx)(r,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,z.jsx)(`span`,{className:`truncate`,children:e.name})]}),(0,z.jsx)(I,{className:`max-h-[300px] overflow-y-auto p-1`,children:a===null?(0,z.jsx)(C,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):a.length===0?(0,z.jsx)(C,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Empty`}):a.map(e=>(0,z.jsx)(V,{entry:e,activePath:t,onFileClick:n},e.path))})]})}return(0,z.jsxs)(C,{className:`text-xs gap-1.5 cursor-pointer ${i?`bg-muted`:``}`,onClick:t=>n(e.path,t),children:[(0,z.jsx)(r,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,z.jsx)(`span`,{className:`truncate`,children:e.name})]})}var De={ts:L,tsx:L,js:L,jsx:L,py:L,rs:L,go:L,html:L,css:L,scss:L,json:A,md:_e,txt:_e,yaml:k,yml:k};function H(e,t){return t?be:De[e.split(`.`).pop()?.toLowerCase()??``]??F}function U(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 Oe(e){return[...e].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1)}function ke({filePath:e,projectName:t,tabId:n,className:r}){let a=P(e=>e.tree),{updateTab:o,openTab:s}=ce(E(e=>({updateTab:e.updateTab,openTab:e.openTab}))),c=S(e=>e.projects.find(e=>e.name===t)?.path??``),l=(0,R.useRef)(null),{prefixParts:u,relativePath:d,isExternal:f}=(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,isExternal:!1}}return{prefixParts:[],relativePath:t,isExternal:/^(\/|[A-Za-z]:[/\\])/.test(e)}},[e,c]),p=(0,R.useMemo)(()=>U(a,d.split(`/`).filter(Boolean)),[a,d]);(0,R.useEffect)(()=>{l.current&&(l.current.scrollLeft=l.current.scrollWidth)},[p]);function m(e,r){let i=x(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 f?(0,z.jsx)(B,{filePath:e,projectName:t,tabId:n,className:r}):(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)(i,{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}`)),p.map((e,n)=>(0,z.jsxs)(`div`,{className:`flex items-center shrink-0`,children:[(n>0||u.length>0)&&(0,z.jsx)(i,{className:`size-3 text-muted-foreground shrink-0 mx-0.5`}),(0,z.jsx)(W,{segment:e,isLast:n===p.length-1,projectName:t,onFileClick:m})]},e.fullPath))]})}function W({segment:e,isLast:t,projectName:n,onFileClick:r}){let i=P(e=>e.loadChildren),a=P(e=>e.loadedPaths),o=(0,R.useMemo)(()=>Oe(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)(D,{onOpenChange:c,children:[(0,z.jsx)(xe,{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)(T,{align:`start`,className:`max-h-[300px] p-1`,children:o.length===0?(0,z.jsx)(C,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):o.map(t=>(0,z.jsx)(G,{node:t,projectName:n,activePath:e.fullPath,onFileClick:r},t.path))})]})}function G({node:e,projectName:t,activePath:n,onFileClick:r}){let i=H(e.name,e.type===`directory`),a=e.path===n,o=P(e=>e.loadChildren),s=P(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)(M,{onOpenChange:u,children:[(0,z.jsxs)(ve,{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)(I,{className:`max-h-[300px] overflow-y-auto p-1`,children:c.length===0?(0,z.jsx)(C,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):Oe(c).map(e=>(0,z.jsx)(G,{node:e,projectName:t,activePath:n,onFileClick:r},e.path))})]})}return(0,z.jsxs)(C,{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 K({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 Ae({ext:e,mdMode:t,onMdModeChange:n,csvMode:r,onCsvModeChange:i,wordWrap:a,onToggleWordWrap:o,onRefresh:s,refreshing:c,filePath:l,projectName:u,className:f}){return(0,z.jsxs)(`div`,{className:f,children:[(e===`md`||e===`mdx`)&&n&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(K,{active:t===`edit`,onClick:()=>n(`edit`),icon:d,label:`Edit`}),(0,z.jsx)(K,{active:t===`preview`,onClick:()=>n(`preview`),icon:p,label:`Preview`})]}),e===`csv`&&i&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(K,{active:r===`table`,onClick:()=>i(`table`),icon:_,label:`Table`}),(0,z.jsx)(K,{active:r===`raw`,onClick:()=>i(`raw`),icon:d,label:`Raw`})]}),(0,z.jsx)(K,{active:a,onClick:o,icon:w,label:`Wrap`}),s&&(0,z.jsxs)(`button`,{type:`button`,onClick:s,disabled:c,title:`Reload file from disk`,className:`flex items-center gap-1 px-2 py-1 rounded text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,children:[(0,z.jsx)(fe,{className:`size-3 ${c?`animate-spin`:``}`}),(0,z.jsx)(`span`,{className:`hidden sm:inline`,children:`Refresh`})]}),l&&u&&(0,z.jsx)(K,{active:!1,onClick:()=>O(u,l),icon:m,label:`Download`})]})}var je=[{id:`plaintext`,label:`Plain Text`},{id:`javascript`,label:`JavaScript`},{id:`typescript`,label:`TypeScript`},{id:`sql`,label:`SQL`},{id:`json`,label:`JSON`},{id:`xml`,label:`XML`},{id:`html`,label:`HTML`},{id:`css`,label:`CSS`},{id:`python`,label:`Python`},{id:`markdown`,label:`Markdown`},{id:`yaml`,label:`YAML`},{id:`shell`,label:`Shell`}];function Me({value:e,onChange:t}){return(0,z.jsxs)(`div`,{className:`shrink-0 flex items-center gap-1 px-2 border-l border-border`,children:[(0,z.jsx)(L,{className:`size-3 text-muted-foreground`}),(0,z.jsx)(`select`,{value:e,onChange:e=>t(e.target.value),className:`h-5 text-[10px] bg-transparent border border-border rounded px-1 text-foreground outline-none max-w-[120px]`,title:`Select editor language`,children:je.map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.label},e.id))})]})}function Ne({open:e,defaultName:t,content:n,onSave:r,onCancel:i}){let[d,f]=(0,R.useState)(t),[p,m]=(0,R.useState)(!1),[ee,h]=(0,R.useState)(``),te=S(e=>e.activeProject),ne=(0,R.useCallback)(()=>{let e=d.trim();if(!e){h(`Filename cannot be empty`);return}if(/[/\\]/.test(e)){h(`Filename cannot contain / or \\`);return}h(``),m(!0)},[d]),g=(0,R.useCallback)(e=>{let t=e.includes(`\\`)?`\\`:`/`;r(e.endsWith(t)?`${e}${d.trim()}`:`${e}${t}${d.trim()}`,n)},[d,n,r]);return p?(0,z.jsx)(he,{open:!0,mode:`folder`,root:te?.path,title:`Save "${d.trim()}" to...`,onSelect:g,onCancel:()=>m(!1)}):(0,z.jsx)(u,{open:e,onOpenChange:e=>{e||i()},children:(0,z.jsxs)(c,{className:`sm:max-w-md`,children:[(0,z.jsx)(a,{children:(0,z.jsx)(l,{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)(de,{value:d,onChange:e=>{f(e.target.value),h(``)},onKeyDown:e=>{e.key===`Enter`&&ne()},placeholder:`e.g. my-file.ts`,autoFocus:!0}),ee&&(0,z.jsx)(`p`,{className:`text-xs text-destructive`,children:ee})]}),(0,z.jsxs)(s,{children:[(0,z.jsx)(o,{variant:`outline`,onClick:i,children:`Cancel`}),(0,z.jsx)(o,{onClick:ne,children:`Choose Folder...`})]})]})})}var q=typeof window<`u`&&window.isSecureContext,Pe=[`(`,`)`,`{`,`}`,`[`,`]`,`<`,`>`,`;`,`:`,`=`,`"`,`'`,"`",`/`,`\\`,`_`,`#`],Fe=`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`,Ie=`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`,Le=`w-px h-5 bg-border mx-0.5 shrink-0`;function Re({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:[!q&&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)(v,{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:q?s:c,className:Fe,title:`Paste`,children:(0,z.jsx)(pe,{size:14})}),(0,z.jsx)(`button`,{type:`button`,onClick:u,className:Fe,title:`Undo`,children:(0,z.jsx)(ge,{size:14})}),(0,z.jsx)(`button`,{type:`button`,onClick:d,className:Fe,title:`Redo`,children:(0,z.jsx)(Ce,{size:14})}),(0,z.jsx)(`div`,{className:Le}),(0,z.jsx)(`button`,{type:`button`,onClick:f,className:Ie,children:`Tab`}),(0,z.jsx)(`div`,{className:Le}),Pe.map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:Ie,children:e},e))]})]})}var J=(0,R.lazy)(()=>b(()=>import(`./markdown-renderer-DDFElf1k.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,27,28,29]))),ze=(0,R.lazy)(()=>b(()=>import(`./csv-preview-DpeN7hH8.js`).then(e=>({default:e.CsvPreview})),__vite__mapDeps([30,2,6,1,3,4,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,31,32]))),Be=(0,R.lazy)(()=>b(()=>import(`./image-preview-DnNyBpmU.js`).then(e=>({default:e.ImagePreview})),__vite__mapDeps([33,6,2,1,3,4,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,34,35]))),Ve=(0,R.lazy)(()=>b(()=>import(`./pdf-preview-DDRKbO4z.js`).then(e=>({default:e.PdfPreview})),__vite__mapDeps([36,2,6,1,3,4,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,34]))),He=(0,R.lazy)(()=>b(()=>import(`./video-preview-CHUzaq4s.js`).then(e=>({default:e.VideoPreview})),__vite__mapDeps([37,6,2,1,3,4,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,34,35]))),Ue=(0,R.lazy)(()=>b(()=>import(`./audio-preview-Cyb8SLCu.js`).then(e=>({default:e.AudioPreview})),__vite__mapDeps([38,6,2,1,3,4,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,34,35]))),We=(0,R.lazy)(()=>b(()=>import(`./docx-preview-Dqzlw47y.js`).then(e=>({default:e.DocxPreview})),__vite__mapDeps([39,2,6,1,3,4,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,34]))),Ge=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`ico`]),Ke=new Set([`mp4`,`webm`,`mov`,`ogg`,`avi`,`mkv`]),qe=new Set([`mp3`,`wav`,`flac`,`aac`,`m4a`,`wma`]),Je=new Set([`db`,`sqlite`,`sqlite3`]);function Ye(e){return e.split(`.`).pop()?.toLowerCase()??``}function Xe(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`}[Ye(e)]??`plaintext`}var Ze=(0,R.memo)(function({metadata:e,tabId:t}){let n=e?.filePath,r=e?.projectName,i=e?.inlineContent,a=e?.inlineLanguage,[o,s]=(0,R.useState)(i??null),[c,l]=(0,R.useState)(`utf-8`),[u,d]=(0,R.useState)(!0),[p,m]=(0,R.useState)(null),[g,_]=(0,R.useState)(!1),v=(0,R.useRef)(null),b=(0,R.useRef)(``),S=(0,R.useRef)(null),{tabs:C,updateTab:w}=ce(E(e=>({tabs:e.tabs,updateTab:e.updateTab}))),{wordWrap:T,toggleWordWrap:de}=oe(E(e=>({wordWrap:e.wordWrap,toggleWordWrap:e.toggleWordWrap}))),fe=Se(),D=e?.isUntitled===!0,O=e?.unsavedContent,[k,A]=(0,R.useState)(!1),M=C.find(e=>e.id===t),N=n?Ye(n):``,P=Ge.has(N),pe=N===`pdf`,me=N===`docx`,he=Ke.has(N),ge=qe.has(N),_e=Je.has(N),ve=N===`md`||N===`mdx`,be=N===`csv`,xe=e?.language,F=a??xe??Xe(n??``),I=F===`sql`,[L,Ce]=(0,R.useState)(`preview`),[we,Te]=(0,R.useState)(`table`),{connections:B,cachedTables:Ee,refreshTables:V,updateConnection:De}=le(),H=n?`ppm:sql-conn:${n}`:t?`ppm:sql-conn:tab:${t}`:null,[U,Oe]=(0,R.useState)(()=>{if(!H)return null;let e=localStorage.getItem(H);return e?Number(e):null}),W=(0,R.useRef)(null),G=(0,R.useRef)(null),K=(0,R.useMemo)(()=>B.find(e=>e.id===U)??null,[B,U]),je=i!=null&&(a===`json`||a===`xml`),[q,Pe]=(0,R.useState)(!1),Fe=(0,R.useCallback)(()=>{if(i)if(q)s(i),Pe(!1);else{let e=i.trimStart();if(a===`json`)try{s(JSON.stringify(JSON.parse(e),null,2)),Pe(!0)}catch{}else if(a===`xml`){let t=0;s(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
+ `)),Pe(!0)}}},[i,a,q]),Ie=(0,R.useCallback)(e=>{Oe(e),H&&localStorage.setItem(H,String(e)),V(e).catch(()=>{})},[H,V]),Le=(0,R.useCallback)(n=>{t&&w(t,{metadata:{...e,language:n}})},[t,e,w]),J=(0,R.useMemo)(()=>{if(!I||!U)return;let e=(Ee.get(U)??[]).map(e=>({name:e.tableName,schema:e.schemaName}));if(e.length!==0)return{tables:e,getColumns:async(e,t)=>y.get(`/api/db/connections/${U}/schema?table=${encodeURIComponent(e)}${t?`&schema=${encodeURIComponent(t)}`:``}`)}},[I,U,Ee]);(0,R.useEffect)(()=>{if(!(!W.current||!J))return G.current?.dispose(),ne(),G.current=W.current.languages.registerCompletionItemProvider(`sql`,te(W.current,J)),()=>{G.current?.dispose()}},[J]);let Ze=ce(e=>e.openTab),[Y,et]=(0,R.useState)(null),[tt,nt]=(0,R.useState)(null),[rt,it]=(0,R.useState)(!1),[at,ot]=(0,R.useState)(``),st=(0,R.useCallback)(async e=>{if(K){it(!0),nt(null),ot(e);try{et(await y.post(`/api/db/connections/${K.id}/query`,{sql:e}))}catch(e){nt(e.message),et(null)}finally{it(!1)}}},[K]),ct=(0,R.useCallback)(()=>{!K||!at||Ze({type:`database`,title:`${K.name} · Query`,projectId:null,closable:!0,metadata:{connectionId:K.id,connectionName:K.name,dbType:K.type,initialSql:at}})},[K,Ze,at]),lt=(0,R.useCallback)(()=>{if(!S.current||!K)return;let e=S.current,t=e.getSelection();st(t&&!t.isEmpty()?e.getModel()?.getValueInRange(t)??e.getValue():e.getValue())},[K,st]),ut=typeof window<`u`&&`ontouchstart`in window,dt=(0,R.useRef)(null),[ft,pt]=(0,R.useState)(null);(0,R.useEffect)(()=>{if(!ut)return;let e=window.visualViewport;if(!e)return;let t=()=>{let t=dt.current;if(!t)return;let n=t.getBoundingClientRect().top;pt(e.height-Math.max(0,n))};return e.addEventListener(`resize`,t),e.addEventListener(`scroll`,t),()=>{e.removeEventListener(`resize`,t),e.removeEventListener(`scroll`,t)}},[ut]);let Z=(0,R.useRef)([]),mt=(0,R.useRef)(st);mt.current=st,(0,R.useEffect)(()=>()=>{Z.current.forEach(e=>e.dispose()),Z.current=[]},[]),(0,R.useEffect)(()=>{_e&&t&&w(t,{type:`sqlite`})},[_e,t,w]);let Q=n?/^(\/|[A-Za-z]:[/\\])/.test(n):!1;(0,R.useEffect)(()=>{if(i!=null){d(!1);return}if(D){s(O??``),b.current=O??``,d(!1),O&&_(!0);return}if(!n||!Q&&!r)return;if(P||pe||me||he||ge){d(!1);return}d(!0),m(null);let e=Q?`/api/fs/read?path=${encodeURIComponent(n)}`:`${ae(r)}/files/read?path=${encodeURIComponent(n)}`;return y.get(e).then(e=>{s(e.content),e.encoding&&l(e.encoding),b.current=e.content,d(!1)}).catch(e=>{m(e instanceof Error?e.message:`Failed to load file`),d(!1)}),()=>{v.current&&clearTimeout(v.current)}},[n,r,P,pe,me,Q,D]);let[ht,gt]=(0,R.useState)(!1),_t=(0,R.useCallback)(()=>{if(!n||i!=null||D||!Q&&!r)return;let e=Q?`/api/fs/read?path=${encodeURIComponent(n)}`:`${ae(r)}/files/read?path=${encodeURIComponent(n)}`;gt(!0),y.get(e).then(e=>{s(e.content),b.current=e.content,e.encoding&&l(e.encoding),_(!1),m(null)}).catch(e=>m(e instanceof Error?e.message:`Failed to reload file`)).finally(()=>gt(!1))},[n,r,Q,i,D]),vt=(0,R.useRef)(g);vt.current=g,(0,R.useEffect)(()=>{if(!n||!r||i!=null||D)return;let e=e=>{let t=e.detail;if(t.projectName!==r||t.path!==n||vt.current)return;let i=Q?`/api/fs/read?path=${encodeURIComponent(n)}`:`${ae(r)}/files/read?path=${encodeURIComponent(n)}`;y.get(i).then(e=>{e.content!==b.current&&(s(e.content),b.current=e.content,e.encoding&&l(e.encoding))}).catch(()=>{})};return window.addEventListener(`file:changed`,e),()=>window.removeEventListener(`file:changed`,e)},[n,r,Q,i,D]),(0,R.useEffect)(()=>{if(!M||i!=null)return;let t=D?`Untitled-${e?.untitledNumber??1}`:n?x(n):`Untitled`,r=g?`${t} \u25CF`:t;M.title!==r&&w(M.id,{title:r})},[g]);let yt=(0,R.useCallback)(async e=>{if(n&&!(!Q&&!r))try{Q?await y.put(`/api/fs/write`,{path:n,content:e}):await y.put(`${ae(r)}/files/write`,{path:n,content:e}),_(!1)}catch{}},[n,r,Q]);function bt(n){let r=n??``;s(r),b.current=r,_(!0),v.current&&clearTimeout(v.current),D?v.current=setTimeout(()=>{t&&w(t,{metadata:{...e,unsavedContent:b.current}})},2e3):v.current=setTimeout(()=>yt(b.current),1e3)}let xt=(0,R.useCallback)(async(e,n)=>{try{if(v.current&&clearTimeout(v.current),await y.put(`/api/fs/write`,{path:e,content:n}),t){let{closeTab:n,openTab:r}=se.getState();n(t),r({type:`editor`,title:x(e),projectId:null,metadata:{filePath:e},closable:!0})}_(!1),A(!1)}catch{}},[t]),$=e?.lineNumber,St=e?.endLine,Ct=e?.revealAt,wt=(0,R.useCallback)(()=>{let e=S.current;if(!(!e||!$||$<=0)){if(e.revealLineInCenter($),e.setPosition({lineNumber:$,column:1}),St&&St>=$){let t=e.getModel(),n=t?.getLineCount()??$,r=Math.min(St,n),i=t?.getLineMaxColumn(r)??1;e.setSelection({startLineNumber:$,startColumn:1,endLineNumber:r,endColumn:i})}e.focus()}},[$,St]);(0,R.useEffect)(()=>{Ct!=null&&wt()},[Ct,wt]);let Tt=(0,R.useCallback)((e,t)=>{if(S.current=e,W.current=t,$&&$>0&&setTimeout(()=>wt(),100),D&&e.addCommand(t.KeyMod.CtrlCmd|t.KeyCode.KeyS,()=>A(!0)),e.addCommand(t.KeyMod.Alt|t.KeyCode.KeyZ,()=>oe.getState().toggleWordWrap()),t.languages.typescript.typescriptDefaults.setDiagnosticsOptions({noSemanticValidation:!0,noSyntaxValidation:!0,noSuggestionDiagnostics:!0}),t.languages.typescript.javascriptDefaults.setDiagnosticsOptions({noSemanticValidation:!0,noSyntaxValidation:!0,noSuggestionDiagnostics:!0}),J&&(G.current?.dispose(),G.current=t.languages.registerCompletionItemProvider(`sql`,te(t,J))),I){e.addAction({id:`run-sql-at-cursor`,label:`Run Statement at Cursor`,keybindings:[t.KeyMod.CtrlCmd|t.KeyCode.Enter],run:e=>{let t=e.getPosition();if(!t)return;let n=h(e.getValue(),t.lineNumber);n&&mt.current(n)}}),Z.current.forEach(e=>e.dispose()),Z.current=[];let n=e.getModel(),r=e.addCommand(0,(e,t)=>{t&&mt.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=/^(BEGIN|COMMIT|ROLLBACK|END)(;|\s|$)/i,l=-1,u=[],d=(e,n,i=`▷ Run`)=>{let a=n.trim();!a||a.startsWith(`--`)||t.push({range:{startLineNumber:e,startColumn:1,endLineNumber:e,endColumn:1},command:{id:r,title:i,arguments:[a]}})};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=[]}if(o.push(i[e]),(t.match(/\$\$/g)||[]).length%2==1&&(s=!s),!s&&t.endsWith(`;`)){let e=o.join(`
7
+ `).trim(),t=/^BEGIN(;|\s|$)/i.test(e),n=/^(COMMIT|ROLLBACK|END)(;|\s|$)/i.test(e);l===-1&&t?(l=a,u=[e]):l>-1?(u.push(e),!n&&!c.test(e)&&d(a,e),n&&(d(l,u.join(`
8
+ `),`▷ Run Transaction`),l=-1,u=[])):d(a,e),a=-1,o=[]}}return l>-1&&u.length>1&&d(l,u.join(`
9
+ `),`▷ Run Transaction`),a>0&&o.join(``).trim()&&d(a,o.join(`
10
+ `)),{lenses:t,dispose:()=>{}}}});Z.current.push(e);let i=t.languages.registerFoldingRangeProvider(`sql`,{provideFoldingRanges:e=>{if(e!==n)return[];let r=[],i=e.getLineCount(),a=[];for(let n=1;n<=i;n++){let i=e.getLineContent(n).trim();if(/^BEGIN(;|\s|$)/i.test(i))a.push(n);else if(/^(COMMIT|ROLLBACK|END)(;|\s|$)/i.test(i)&&a.length>0){let e=a.pop();r.push({start:e,end:n,kind:t.languages.FoldingRangeKind.Region})}}return r}});Z.current.push(i)}}},[J,I]);if(!i&&!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(u)return(0,z.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-text-secondary`,children:[(0,z.jsx)(j,{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(P)return(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(X,{}),children:(0,z.jsx)(Be,{filePath:n,projectName:r})});if(pe)return(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(X,{}),children:(0,z.jsx)(Ve,{filePath:n,projectName:r})});if(me)return(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(X,{}),children:(0,z.jsx)(We,{filePath:n,projectName:r})});if(he)return(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(X,{}),children:(0,z.jsx)(He,{filePath:n,projectName:r})});if(ge)return(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(X,{}),children:(0,z.jsx)(Ue,{filePath:n,projectName:r})});if(c===`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 Et=I?(0,z.jsxs)(`div`,{className:`shrink-0 flex items-center gap-1 px-2 border-l border-border`,children:[(0,z.jsx)(f,{className:`size-3 text-muted-foreground`}),(0,z.jsxs)(`select`,{value:U??``,onChange:e=>{let t=Number(e.target.value);t&&Ie(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:lt,disabled:!K,className:`p-0.5 rounded text-muted-foreground hover:text-primary disabled:opacity-30 transition-colors`,title:`Run SQL`,children:(0,z.jsx)(ue,{className:`size-3.5`})}),K&&(0,z.jsx)(`button`,{type:`button`,onClick:()=>De(K.id,{readonly:K.readonly?0:1}),className:`flex items-center gap-0.5 px-1 py-0.5 rounded text-[10px] transition-colors ${K.readonly?`text-muted-foreground hover:text-foreground`:`bg-destructive/15 text-destructive`}`,title:K.readonly?`Readonly — click to allow writes`:`WRITE mode — click to enable readonly`,children:K.readonly?(0,z.jsx)(re,{className:`size-3`}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(ie,{className:`size-3`}),(0,z.jsx)(`span`,{className:`font-medium`,children:`WRITE`})]})})]}):null;return(0,z.jsxs)(`div`,{ref:dt,className:`flex flex-col h-full w-full overflow-hidden`,style:ft?{height:`${ft}px`,maxHeight:`${ft}px`}:void 0,children:[i!=null&&je&&(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:Fe,className:`text-[10px] px-2 py-0.5 rounded border border-border hover:bg-muted transition-colors text-foreground`,children:q?`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)(ke,{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`}),(0,z.jsx)(Me,{value:F,onChange:Le}),Et,(0,z.jsx)(Ae,{ext:N,mdMode:L,onMdModeChange:Ce,csvMode:we,onCsvModeChange:Te,wordWrap:T,onToggleWordWrap:de,onRefresh:_t,refreshing:ht,filePath:n,projectName:r,className:`shrink-0 flex items-center gap-1 px-2`})]}),i==null&&t&&(D||n&&!r)&&(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:D?`Untitled-${e?.untitledNumber??1}`:n?x(n):`Untitled`}),(0,z.jsx)(Me,{value:F,onChange:Le}),Et]}),be&&we===`table`?(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,z.jsx)(j,{className:`size-5 animate-spin text-text-subtle`})}),children:(0,z.jsx)(ze,{content:o??``,onContentChange:bt,wordWrap:T})}):ve&&L===`preview`?(0,z.jsx)($e,{content:o??``}):(0,z.jsx)(`div`,{className:`flex-1 overflow-hidden min-h-0`,children:(0,z.jsx)(ye,{height:`100%`,language:F,value:o??``,onChange:i==null?bt:void 0,onMount:Tt,theme:fe,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:i!=null},loading:(0,z.jsx)(j,{className:`size-5 animate-spin text-text-subtle`})},F)}),I&&(Y||tt||rt)&&(0,z.jsx)(Qe,{result:Y,error:tt,loading:rt,connName:K?.name,onClose:()=>{et(null),nt(null),it(!1)},onOpenInTab:ct}),ut&&(0,z.jsx)(Re,{editorRef:S,readOnly:i!=null}),k&&(0,z.jsx)(Ne,{open:k,defaultName:`Untitled-${e?.untitledNumber??1}`,content:b.current,onSave:xt,onCancel:()=>A(!1)})]})}),Y=()=>{};function Qe({result:e,error:t,loading:n,connName:r,onClose:i,onOpenInTab:a}){let o=(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]),s=(0,R.useMemo)(()=>(e?.columns??[]).map(e=>({name:e,type:`text`,nullable:!0,pk:!1,defaultValue:null})),[e?.columns]),[c,l]=(0,R.useState)(250),u=(0,R.useCallback)(e=>{e.preventDefault();let t=e.clientY,n=c,r=e=>l(Math.max(80,n+(t-e.clientY))),i=()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)},[c]);return(0,z.jsxs)(`div`,{className:`shrink-0 border-t border-border flex flex-col`,style:{height:c},children:[(0,z.jsx)(`div`,{onMouseDown:u,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)(f,{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:a,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)(N,{className:`size-3`}),(0,z.jsx)(`span`,{className:`hidden sm:inline`,children:`Open in Tab`})]}),(0,z.jsx)(`button`,{type:`button`,onClick:i,title:`Close results`,className:`p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors`,children:(0,z.jsx)(v,{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)(j,{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-success`,children:[e.rowsAffected,` row(s) affected`]}),o&&(0,z.jsx)(g,{columns:o.columns,rows:o.rows,total:o.total,limit:o.limit,schema:s,loading:!1,page:1,onPageChange:Y,onCellUpdate:Y,orderBy:null,orderDir:`ASC`,onToggleSort:Y,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 X(){return(0,z.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,z.jsx)(j,{className:`size-5 animate-spin text-text-subtle`})})}function $e({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)(J,{content:e,className:`flex-1 overflow-auto p-4`})})}export{Ze as CodeEditor};
@@ -1,7 +1,7 @@
1
- import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,y as n}from"./vendor-markdown-CKTlmXbz.js";import"./vendor-ui-DMRGWRuc.js";import{i as r,n as i}from"./api-client-COQtP-dB.js";import"./vendor-mermaid-CYOBtZtD.js";import{t as a}from"./settings-store-BbFtHCGd.js";import{$t as o,Y as s,o as c}from"./index-bQy6gwMT.js";import{t as l}from"./use-monaco-theme-CF_57XHm.js";var u=e(t(),1),d=n();function f(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`,go:`go`,rs:`rust`,java:`java`,rb:`ruby`,php:`php`,swift:`swift`,sql:`sql`,xml:`xml`,toml:`toml`}[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function p(e){let t=e.split(`
1
+ import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,y as n}from"./vendor-markdown-CKTlmXbz.js";import"./vendor-ui-DMRGWRuc.js";import{i as r,n as i}from"./api-client-COQtP-dB.js";import"./vendor-mermaid-CYOBtZtD.js";import{t as a}from"./settings-store-BbFtHCGd.js";import{X as o,en as s,o as c}from"./index-D4KFhwmL.js";import{t as l}from"./use-monaco-theme-DU3LWaPu.js";var u=e(t(),1),d=n();function f(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`,go:`go`,rs:`rust`,java:`java`,rb:`ruby`,php:`php`,swift:`swift`,sql:`sql`,xml:`xml`,toml:`toml`}[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function p(e){let t=e.split(`
2
2
  `),n=[],r=0,i=0;for(;r<t.length;){let e=t[r];if(e.startsWith(`<<<<<<<`)){let a=r,o=e.substring(7).trim(),s=[];for(r++;r<t.length&&!t[r].startsWith(`=======`);)s.push(t[r]),r++;if(r>=t.length)break;let c=r,l=[];for(r++;r<t.length&&!t[r].startsWith(`>>>>>>>`);)l.push(t[r]),r++;if(r>=t.length)break;let u=t[r].substring(7).trim();n.push({id:i++,startLine:a+1,separatorLine:c+1,endLine:r+1,currentContent:s.join(`
3
3
  `),incomingContent:l.join(`
4
- `),currentLabel:o,incomingLabel:u})}r++}return n}function m({metadata:e}){let t=e?.filePath,n=e?.projectName,[m,g]=(0,u.useState)(null),[_,v]=(0,u.useState)(!0),[y,b]=(0,u.useState)(null),[x,S]=(0,u.useState)(0),C=(0,u.useRef)(null),w=(0,u.useRef)(null),T=(0,u.useRef)([]),E=(0,u.useRef)(null),{wordWrap:D}=a(s(e=>({wordWrap:e.wordWrap}))),O=l(),k=(0,u.useRef)(null),[A,j]=(0,u.useState)();(0,u.useEffect)(()=>{let e=k.current;if(!e)return;let t=new ResizeObserver(([e])=>{e&&j(Math.floor(e.contentRect.height))});return t.observe(e),()=>t.disconnect()},[]),(0,u.useEffect)(()=>{!t||!n||(v(!0),i.get(`${r(n)}/files/read?path=${encodeURIComponent(t)}`).then(e=>{g(e.content),v(!1)}).catch(e=>{b(e.message||`Failed to load file`),v(!1)}))},[t,n]);let M=(0,u.useCallback)(()=>{let e=C.current,t=w.current;if(!e||!t)return;let n=p(e.getModel()?.getValue()||``);S(n.length);for(let t of T.current)e.removeContentWidget(t);if(T.current=[],E.current&&E.current.clear(),n.length===0)return;let r=[];for(let e of n)r.push({range:new t.Range(e.startLine,1,e.startLine,1),options:{isWholeLine:!0,className:`conflict-marker-line`,glyphMarginClassName:`conflict-glyph-current`}}),r.push({range:new t.Range(e.separatorLine,1,e.separatorLine,1),options:{isWholeLine:!0,className:`conflict-marker-line`}}),r.push({range:new t.Range(e.endLine,1,e.endLine,1),options:{isWholeLine:!0,className:`conflict-marker-line`,glyphMarginClassName:`conflict-glyph-incoming`}}),e.separatorLine-e.startLine>1&&r.push({range:new t.Range(e.startLine+1,1,e.separatorLine-1,1),options:{isWholeLine:!0,className:`conflict-current-content`}}),e.endLine-e.separatorLine>1&&r.push({range:new t.Range(e.separatorLine+1,1,e.endLine-1,1),options:{isWholeLine:!0,className:`conflict-incoming-content`}});E.current=e.createDecorationsCollection(r);for(let r of n){let n=`conflict-widget-${r.id}`,i=document.createElement(`div`);i.className=`conflict-actions`,i.innerHTML=`<span class="conflict-label">Current Change (${h(r.currentLabel||`HEAD`)})</span><button class="conflict-btn conflict-btn-current" data-action="current">Accept Current</button><button class="conflict-btn conflict-btn-incoming" data-action="incoming">Accept Incoming</button><button class="conflict-btn conflict-btn-both" data-action="both">Accept Both</button>`,i.addEventListener(`click`,e=>{let t=e.target.closest(`[data-action]`);if(!t)return;let n=t.getAttribute(`data-action`);N(r.id,n)});let a={getId:()=>n,getDomNode:()=>i,getPosition:()=>({position:{lineNumber:r.startLine,column:1},preference:[t.editor.ContentWidgetPositionPreference.ABOVE]})};e.addContentWidget(a),T.current.push(a)}},[]),N=(0,u.useCallback)((e,t)=>{let n=C.current,r=w.current;if(!n||!r)return;let i=n.getModel();if(!i)return;let a=p(i.getValue()).find(t=>t.id===e);if(!a)return;let o;switch(t){case`current`:o=a.currentContent;break;case`incoming`:o=a.incomingContent;break;case`both`:o=a.currentContent+`
4
+ `),currentLabel:o,incomingLabel:u})}r++}return n}function m({metadata:e}){let t=e?.filePath,n=e?.projectName,[m,g]=(0,u.useState)(null),[_,v]=(0,u.useState)(!0),[y,b]=(0,u.useState)(null),[x,S]=(0,u.useState)(0),C=(0,u.useRef)(null),w=(0,u.useRef)(null),T=(0,u.useRef)([]),E=(0,u.useRef)(null),{wordWrap:D}=a(o(e=>({wordWrap:e.wordWrap}))),O=l(),k=(0,u.useRef)(null),[A,j]=(0,u.useState)();(0,u.useEffect)(()=>{let e=k.current;if(!e)return;let t=new ResizeObserver(([e])=>{e&&j(Math.floor(e.contentRect.height))});return t.observe(e),()=>t.disconnect()},[]),(0,u.useEffect)(()=>{!t||!n||(v(!0),i.get(`${r(n)}/files/read?path=${encodeURIComponent(t)}`).then(e=>{g(e.content),v(!1)}).catch(e=>{b(e.message||`Failed to load file`),v(!1)}))},[t,n]);let M=(0,u.useCallback)(()=>{let e=C.current,t=w.current;if(!e||!t)return;let n=p(e.getModel()?.getValue()||``);S(n.length);for(let t of T.current)e.removeContentWidget(t);if(T.current=[],E.current&&E.current.clear(),n.length===0)return;let r=[];for(let e of n)r.push({range:new t.Range(e.startLine,1,e.startLine,1),options:{isWholeLine:!0,className:`conflict-marker-line`,glyphMarginClassName:`conflict-glyph-current`}}),r.push({range:new t.Range(e.separatorLine,1,e.separatorLine,1),options:{isWholeLine:!0,className:`conflict-marker-line`}}),r.push({range:new t.Range(e.endLine,1,e.endLine,1),options:{isWholeLine:!0,className:`conflict-marker-line`,glyphMarginClassName:`conflict-glyph-incoming`}}),e.separatorLine-e.startLine>1&&r.push({range:new t.Range(e.startLine+1,1,e.separatorLine-1,1),options:{isWholeLine:!0,className:`conflict-current-content`}}),e.endLine-e.separatorLine>1&&r.push({range:new t.Range(e.separatorLine+1,1,e.endLine-1,1),options:{isWholeLine:!0,className:`conflict-incoming-content`}});E.current=e.createDecorationsCollection(r);for(let r of n){let n=`conflict-widget-${r.id}`,i=document.createElement(`div`);i.className=`conflict-actions`,i.innerHTML=`<span class="conflict-label">Current Change (${h(r.currentLabel||`HEAD`)})</span><button class="conflict-btn conflict-btn-current" data-action="current">Accept Current</button><button class="conflict-btn conflict-btn-incoming" data-action="incoming">Accept Incoming</button><button class="conflict-btn conflict-btn-both" data-action="both">Accept Both</button>`,i.addEventListener(`click`,e=>{let t=e.target.closest(`[data-action]`);if(!t)return;let n=t.getAttribute(`data-action`);N(r.id,n)});let a={getId:()=>n,getDomNode:()=>i,getPosition:()=>({position:{lineNumber:r.startLine,column:1},preference:[t.editor.ContentWidgetPositionPreference.ABOVE]})};e.addContentWidget(a),T.current.push(a)}},[]),N=(0,u.useCallback)((e,t)=>{let n=C.current,r=w.current;if(!n||!r)return;let i=n.getModel();if(!i)return;let a=p(i.getValue()).find(t=>t.id===e);if(!a)return;let o;switch(t){case`current`:o=a.currentContent;break;case`incoming`:o=a.incomingContent;break;case`both`:o=a.currentContent+`
5
5
  `+a.incomingContent;break}let s=new r.Range(a.startLine,1,a.endLine+1,1);i.pushEditOperations([],[{range:s,text:o+`
6
6
  `}],()=>null),P(i.getValue()),setTimeout(()=>M(),50)},[M]),P=(0,u.useCallback)(async e=>{if(!(!t||!n))try{await i.put(`${r(n)}/files/write`,{path:t,content:e})}catch(e){console.error(`[conflict-editor] save failed:`,e)}},[t,n]),F=(e,t)=>{C.current=e,w.current=t;let n=e.getDomNode()?.ownerDocument??document;if(!n.getElementById(`conflict-editor-styles`)){let e=n.createElement(`style`);e.id=`conflict-editor-styles`,e.textContent=`
7
7
  .conflict-current-content { background: color-mix(in srgb, var(--color-success) 10%, transparent) !important; }
@@ -16,4 +16,4 @@ import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,y as n}from"./v
16
16
  .conflict-btn-current { color: var(--color-success); background: color-mix(in srgb, var(--color-success) 15%, transparent); }
17
17
  .conflict-btn-incoming { color: var(--color-primary); background: color-mix(in srgb, var(--color-primary) 15%, transparent); }
18
18
  .conflict-btn-both { color: #a855f7; background: rgba(168, 85, 247, 0.15); }
19
- `,n.head?.appendChild(e)}M()},I=t?.split(/[\\/]/).pop()??`unknown`,L=f(I);return _?(0,d.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,d.jsx)(o,{className:`size-6 animate-spin text-primary`})}):y?(0,d.jsx)(`div`,{className:`flex items-center justify-center h-full text-destructive`,children:y}):(0,d.jsxs)(`div`,{className:`h-full w-full flex flex-col`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 text-xs border-b border-border bg-muted/50 flex-shrink-0`,children:[(0,d.jsx)(`span`,{className:`font-medium`,children:I}),(0,d.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}),x>0?(0,d.jsxs)(`span`,{className:`text-destructive font-medium`,children:[x,` conflict`,x===1?``:`s`,` remaining`]}):(0,d.jsx)(`span`,{className:`text-success font-medium`,children:`All conflicts resolved`})]}),(0,d.jsx)(`div`,{ref:k,className:`flex-1 min-h-0`,children:m!==null&&A&&(0,d.jsx)(c,{height:A,language:L,value:m,onMount:F,theme:O,options:{fontSize:13,fontFamily:`Menlo, Monaco, Consolas, monospace`,wordWrap:D?`on`:`off`,glyphMargin:!0,readOnly:!1,automaticLayout:!0,scrollBeyondLastLine:!1,minimap:{enabled:!1}}})})]})}function h(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}export{m as ConflictEditor};
19
+ `,n.head?.appendChild(e)}M()},I=t?.split(/[\\/]/).pop()??`unknown`,L=f(I);return _?(0,d.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,d.jsx)(s,{className:`size-6 animate-spin text-primary`})}):y?(0,d.jsx)(`div`,{className:`flex items-center justify-center h-full text-destructive`,children:y}):(0,d.jsxs)(`div`,{className:`h-full w-full flex flex-col`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 text-xs border-b border-border bg-muted/50 flex-shrink-0`,children:[(0,d.jsx)(`span`,{className:`font-medium`,children:I}),(0,d.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}),x>0?(0,d.jsxs)(`span`,{className:`text-destructive font-medium`,children:[x,` conflict`,x===1?``:`s`,` remaining`]}):(0,d.jsx)(`span`,{className:`text-success font-medium`,children:`All conflicts resolved`})]}),(0,d.jsx)(`div`,{ref:k,className:`flex-1 min-h-0`,children:m!==null&&A&&(0,d.jsx)(c,{height:A,language:L,value:m,onMount:F,theme:O,options:{fontSize:13,fontFamily:`Menlo, Monaco, Consolas, monospace`,wordWrap:D?`on`:`off`,glyphMargin:!0,readOnly:!1,automaticLayout:!0,scrollBeyondLastLine:!1,minimap:{enabled:!1}}})})]})}function h(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}export{m as ConflictEditor};
@@ -0,0 +1,2 @@
1
+ import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,y as n}from"./vendor-markdown-CKTlmXbz.js";import"./vendor-ui-DMRGWRuc.js";import{En as r,Tn as i,Y as a}from"./index-D4KFhwmL.js";import{n as o,t as s}from"./csv-parser-DVHBcvuE.js";import{i as c,n as l,r as u,t as d}from"./lib-DTaN9riD.js";var f=e(t(),1),p=n();function m({content:e,onContentChange:t,wordWrap:n}){let m=(0,f.useMemo)(()=>s(e),[e]),[g,_]=(0,f.useState)(()=>m.rows),[v,y]=(0,f.useState)([]),b=(0,f.useRef)(null),x=(0,f.useRef)(!1);(0,f.useEffect)(()=>{if(x.current){x.current=!1;return}_(m.rows)},[m.rows]);let S=m.headers,C=(0,f.useCallback)((e,n,r)=>{_(i=>{let a=i.map((t,n)=>n===e?[...t]:t);return a[e][n]=r,x.current=!0,t(o(S,a)),a})},[S,t]),w=l({data:g,columns:(0,f.useMemo)(()=>S.map((e,t)=>({id:`col-${t}`,header:e||`Column ${t+1}`,accessorFn:e=>e[t]??``,cell:({row:e,getValue:r})=>(0,p.jsx)(h,{value:r(),onSave:n=>C(e.index,t,n),wordWrap:n}),size:150,minSize:80})),[S,C,n]),state:{sorting:v},onSortingChange:y,getCoreRowModel:u(),getSortedRowModel:c(),enableColumnResizing:!0,columnResizeMode:`onChange`}),{rows:T}=w.getRowModel(),E=a({count:T.length,getScrollElement:()=>b.current,estimateSize:()=>32,overscan:20});return S.length===0?(0,p.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`Empty CSV file`}):(0,p.jsx)(`div`,{ref:b,className:`flex-1 overflow-auto`,children:(0,p.jsxs)(`table`,{className:`w-full text-xs font-mono border-collapse`,children:[(0,p.jsx)(`thead`,{className:`sticky top-0 bg-background z-10 border-b border-border block`,children:w.getHeaderGroups().map(e=>(0,p.jsx)(`tr`,{className:`flex w-full`,children:e.headers.map(e=>(0,p.jsxs)(`th`,{className:`relative text-left px-2 py-1.5 font-medium text-muted-foreground select-none cursor-pointer hover:bg-muted/50 border-r border-border last:border-r-0`,style:{width:e.getSize(),minWidth:e.getSize()},onClick:e.column.getToggleSortingHandler(),children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,p.jsx)(`span`,{className:`truncate`,children:d(e.column.columnDef.header,e.getContext())}),e.column.getIsSorted()===`asc`&&(0,p.jsx)(i,{className:`size-3 shrink-0`}),e.column.getIsSorted()===`desc`&&(0,p.jsx)(r,{className:`size-3 shrink-0`})]}),(0,p.jsx)(`div`,{onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),onClick:e=>e.stopPropagation(),className:`absolute right-0 top-0 h-full w-1 cursor-col-resize hover:bg-primary/50 active:bg-primary`})]},e.id))},e.id))}),(0,p.jsx)(`tbody`,{style:{height:E.getTotalSize(),position:`relative`,display:`block`},children:E.getVirtualItems().map(e=>{let t=T[e.index];return(0,p.jsx)(`tr`,{"data-index":e.index,ref:e=>E.measureElement(e),style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`,display:`flex`},children:t.getVisibleCells().map(e=>(0,p.jsx)(`td`,{className:`px-2 py-1 border-b border-border/50 border-r border-r-border/30 last:border-r-0 ${n?`whitespace-pre-wrap break-words`:`truncate`}`,style:{width:e.column.getSize(),minWidth:e.column.getSize()},children:d(e.column.columnDef.cell,e.getContext())},e.id))},t.id)})})]})})}function h({value:e,onSave:t,wordWrap:n}){let[r,i]=(0,f.useState)(!1),[a,o]=(0,f.useState)(e),s=(0,f.useRef)(null),c=(0,f.useCallback)(e=>{e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[]);return(0,f.useEffect)(()=>{r&&s.current&&(s.current.focus(),c(s.current))},[r,c]),r?(0,p.jsx)(`textarea`,{ref:s,className:`w-full bg-transparent outline-none border border-primary/50 rounded text-xs font-mono resize-none p-0.5`,style:{minHeight:a.includes(`
2
+ `)?48:20},rows:1,value:a,onChange:e=>{o(e.target.value),c(e.target)},onBlur:()=>{i(!1),a!==e&&t(a)},onKeyDown:n=>{n.key===`Enter`&&!n.shiftKey?(n.preventDefault(),i(!1),a!==e&&t(a)):n.key===`Escape`&&(i(!1),o(e))}}):(0,p.jsx)(`span`,{className:`block cursor-text ${n?`whitespace-pre-wrap break-words`:`truncate`}`,onClick:()=>{o(e),i(!0)},children:e||`\xA0`})}export{m as CsvPreview};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,y as n}from"./vendor-markdown-CKTlmXbz.js";import"./vendor-ui-DMRGWRuc.js";import{t as r}from"./database-COYAMZaw.js";import{n as i,t as a}from"./glide-data-grid-CCVPfJtk.js";import{t as o}from"./shield-check-C3qYSU8a.js";import{t as s}from"./shield-off-D5tU7gQT.js";import{n as c,s as l}from"./api-client-COQtP-dB.js";import"./vendor-mermaid-CYOBtZtD.js";import"./settings-store-BbFtHCGd.js";import"./panel-store-CpKvXNnm.js";import{t as u}from"./tab-store-BQmDVh9c.js";import{$t as d,A as f,Ut as p,rn as m}from"./index-bQy6gwMT.js";import"./data-grid-types-BuMHLKXV.js";import"./use-monaco-theme-CF_57XHm.js";import{t as h}from"./sql-query-editor-BwquzTWY.js";var g=e(t(),1);function _(e,t,n,r){return`ppm-db-${e}-${n}.${t}-p${r}`}function v(e,t,n,r){try{let i=sessionStorage.getItem(_(e,t,n,r));return i?JSON.parse(i):null}catch{return null}}function y(e,t,n,r,i,a){try{sessionStorage.setItem(_(e,t,n,r),JSON.stringify({data:i,cols:a}))}catch{}}function b(e){let t=`/api/db/connections/${e}`,[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(`public`),[o,s]=(0,g.useState)(null),[u,d]=(0,g.useState)([]),[f,p]=(0,g.useState)(!1),[m,h]=(0,g.useState)(null),[_,b]=(0,g.useState)(1),[x,S]=(0,g.useState)(null),[C,w]=(0,g.useState)(null),[T,E]=(0,g.useState)(!1),[D,O]=(0,g.useState)(null),[k,A]=(0,g.useState)(`ASC`),j=(0,g.useRef)(null),M=(0,g.useCallback)(async(r,a,o,l,u)=>{let f=r??n,m=a??i;if(!f)return;j.current=null,p(!0);let g=l===void 0?D:l,v=u??k;try{let n=g?`&orderBy=${encodeURIComponent(g)}&orderDir=${v}`:``,[r,i]=await Promise.all([c.get(`${t}/data?table=${encodeURIComponent(f)}&schema=${m}&page=${o??_}&limit=100${n}`),c.get(`${t}/schema?table=${encodeURIComponent(f)}&schema=${m}`)]);s(r),d(i),y(e,f,m,o??_,r,i)}catch(e){h(e.message)}finally{p(!1)}},[t,e,n,i,_,D,k]),N=(0,g.useCallback)((t,n=`public`)=>{r(t),a(n),b(1),S(null);let i=v(e,t,n,1);i?(s(i.data),d(i.cols),p(!1),M(t,n,1)):M(t,n,1)},[e,M]),P=(0,g.useCallback)(e=>{b(e),M(void 0,void 0,e)},[M]),F=(0,g.useCallback)(async e=>{j.current={sql:e,mode:`table`},p(!0);try{let n=await c.post(`${t}/query`,{sql:e,source:`filter`});n.changeType===`select`&&s({columns:n.columns,rows:n.rows,total:n.rows.length,page:1,limit:n.rows.length})}catch(e){h(e.message)}finally{p(!1)}},[t]),I=(0,g.useCallback)(async e=>{E(!0),w(null);try{let r=await c.post(`${t}/query`,{sql:e});S(r),r.changeType===`modify`?(j.current=null,M(n??void 0,i)):j.current={sql:e,mode:`query`}}catch(e){w(e.message)}finally{E(!1)}},[t,n,i,M]),L=(0,g.useCallback)((e,t)=>{let n=j.current;if(n?.mode===`table`){F(n.sql);return}M(e,t)},[F,M]),R=(0,g.useCallback)((e,t)=>{let n=t.message;h(n),l.error(`${e} failed`,{description:n})},[]),z=(0,g.useCallback)(async(e,r,a,o)=>{if(!n)return;let s=n,l=i;try{await c.put(`${t}/cell`,{table:s,schema:l,pkColumn:e,pkValue:r,column:a,value:o}),L(s,l)}catch(e){R(`Update cell`,e)}},[t,n,i,L,R]),B=(0,g.useCallback)(async(e,r)=>{if(!n)return;let a=n,o=i;try{await c.del(`${t}/row`,{table:a,schema:o,pkColumn:e,pkValue:r}),L(a,o)}catch(e){R(`Delete row`,e)}},[t,n,i,L,R]);return{selectedTable:n,selectedSchema:i,selectTable:N,tableData:o,schema:u,loading:f,error:m,page:_,setPage:P,orderBy:D,orderDir:k,toggleSort:(0,g.useCallback)(e=>{let t,n=`ASC`;D===e?k===`ASC`?(t=e,n=`DESC`):(t=null,n=`ASC`):(t=e,n=`ASC`),O(t),A(n),b(1),M(void 0,void 0,1,t,n)},[D,k,M]),clearSort:(0,g.useCallback)(()=>{O(null),A(`ASC`),b(1),M(void 0,void 0,1,null,`ASC`)},[M]),queryResult:x,queryError:C,queryLoading:T,executeQuery:I,updateCell:z,deleteRow:B,bulkDelete:(0,g.useCallback)(async(e,r)=>{if(!n)return;let a=n,o=i;try{await c.post(`${t}/rows/delete`,{table:a,schema:o,pkColumn:e,pkValues:r}),L(a,o)}catch(e){R(`Delete rows`,e)}},[t,n,i,L,R]),insertRow:(0,g.useCallback)(async e=>{if(!n)return;let r=n,a=i;try{await c.post(`${t}/row`,{table:r,schema:a,values:e}),L(r,a)}catch(e){throw R(`Insert row`,e),e}},[t,n,i,L,R]),refreshData:M,queryAsTable:F,reload:(0,g.useCallback)(()=>{let e=j.current;if(e?.mode===`query`){I(e.sql);return}if(e?.mode===`table`){F(e.sql);return}M()},[I,F,M])}}var x=n();function S(e){let t={},n=/"(\w+)"\s+ILIKE\s+'%([^']*?)%'/gi,r;for(;(r=n.exec(e))!==null;)t[r[1]]=r[2].replace(/''/g,`'`);return t}function C({metadata:e,tabId:t}){let n=e?.connectionId,l=e?.connectionName,_=e?.tableName,v=e?.schemaName??`public`,y=e?.initialSql,C=e?.currentSql,w=u(e=>e.updateTab),E=(0,g.useRef)(e);E.current=e;let D=(0,g.useCallback)(e=>{t&&w(t,{metadata:{...E.current,currentSql:e}})},[t,w]),O=b(n),{connections:k,updateConnection:A}=f(),j=(0,g.useMemo)(()=>k.find(e=>e.id===n),[k,n]),[M,N]=(0,g.useState)([]),[P,F]=(0,g.useState)(180),I=(0,g.useRef)(null),[L,R]=(0,g.useState)({}),z=(0,g.useMemo)(()=>{if(y&&!O.selectedTable)return y;if(O.selectedTable){let e=`SELECT * FROM "${O.selectedTable}"`,t=Object.entries(L).filter(([,e])=>e.trim()).map(([e,t])=>`"${e}" ILIKE '%${t.replace(/'/g,`''`)}%'`);t.length>0&&(e+=` WHERE ${t.join(` AND `)}`),O.orderBy&&(e+=` ORDER BY "${O.orderBy}" ${O.orderDir}`);let n=(O.page-1)*100;return e+=` LIMIT 100`,n>0&&(e+=` OFFSET ${n}`),e}return`SELECT * FROM `},[y,O.selectedTable,O.orderBy,O.orderDir,O.page,L]),B=(0,g.useCallback)(e=>{R(e)},[]),V=(0,g.useRef)(void 0),H=(0,g.useRef)(!1);(0,g.useEffect)(()=>{if(!O.selectedTable)return;let e=Object.values(L).some(e=>e.trim());if(!(!e&&!H.current))return H.current=e,clearTimeout(V.current),V.current=setTimeout(()=>{e?O.queryAsTable(z):O.refreshData()},500),()=>clearTimeout(V.current)},[L]);let U=(0,g.useCallback)(e=>{e.preventDefault();let t=e.clientY,n=P,r=e=>{let r=e.clientY-t;F(Math.max(80,Math.min(n+r,(I.current?.clientHeight??600)-100)))},i=()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)},[P]);(0,g.useEffect)(()=>{c.get(`/api/db/connections/${n}/tables?cached=1`).then(e=>N(e.map(e=>({name:e.name,schema:e.schema})))).catch(()=>{})},[n]);let W=(0,g.useMemo)(()=>{if(M.length!==0)return{tables:M,getColumns:async(e,t)=>await c.get(`/api/db/connections/${n}/schema?table=${encodeURIComponent(e)}${t?`&schema=${encodeURIComponent(t)}`:``}`)}},[n,M]),G=(0,g.useRef)(!1);(0,g.useEffect)(()=>{G.current||(G.current=!0,y?O.executeQuery(y):_&&O.selectTable(_,v))},[_,v,y]);let[K,q]=(0,g.useState)(!!y),J=(0,g.useCallback)(e=>{let t=e.trim();if(O.selectedTable&&RegExp(`^SELECT\\s+\\*\\s+FROM\\s+"?${O.selectedTable.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}"?\\b`,`i`).test(t)){R(S(t)),O.queryAsTable(t);return}q(!0),O.executeQuery(e)},[O.executeQuery,O.queryAsTable,O.selectedTable]),Y=(0,g.useCallback)(e=>{q(!1),O.toggleSort(e)},[O.toggleSort]),X=(0,g.useCallback)(()=>{q(!1),O.clearSort()},[O.clearSort]),ee=(0,g.useCallback)(e=>{q(!1),O.setPage(e)},[O.setPage]),Z=O.queryResult,Q=K&&!!(Z||O.queryError),$=O.selectedTable&&!Q,te=!($&&O.tableData)&&!Q&&(O.loading||O.queryLoading);return(0,x.jsx)(`div`,{ref:I,className:`flex h-full w-full overflow-hidden`,children:(0,x.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b border-border bg-background shrink-0`,children:[(0,x.jsx)(r,{className:`size-3.5 text-muted-foreground`}),(0,x.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:l??`Database`}),O.selectedTable&&(0,x.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`/ `,O.selectedTable]}),(0,x.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[O.tableData&&(0,x.jsx)(i,{columns:O.tableData.columns,rows:O.tableData.rows,filename:l?`${l}-${O.selectedTable??`data`}`:O.selectedTable??`data`,exportAllUrl:O.selectedTable?`/api/db/connections/${n}/export?table=${encodeURIComponent(O.selectedTable)}&schema=${O.selectedSchema}`:void 0}),j&&(0,x.jsx)(`button`,{type:`button`,onClick:()=>A(j.id,{readonly:j.readonly?0:1}),className:`flex items-center gap-0.5 px-1 py-0.5 rounded text-[10px] transition-colors ${j.readonly?`text-muted-foreground hover:text-foreground`:`bg-destructive/15 text-destructive`}`,title:j.readonly?`Readonly — click to allow writes`:`WRITE mode — click to enable readonly`,children:j.readonly?(0,x.jsx)(o,{className:`size-3`}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(s,{className:`size-3`}),(0,x.jsx)(`span`,{className:`font-medium`,children:`WRITE`})]})}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>O.reload(),title:`Reload data`,className:`p-1 rounded text-muted-foreground hover:text-foreground transition-colors`,children:(0,x.jsx)(p,{className:`size-3 ${O.loading||O.queryLoading?`animate-spin`:``}`})})]})]}),(0,x.jsx)(`div`,{className:`shrink-0 border-b border-border`,style:{height:P},children:(0,x.jsx)(h,{onExecute:J,loading:O.queryLoading,defaultValue:z,schemaInfo:W,onSqlChange:D,persistedSql:C})}),(0,x.jsx)(`div`,{onMouseDown:U,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,x.jsx)(m,{className:`size-3 text-muted-foreground/50`})}),(0,x.jsxs)(`div`,{className:`flex-1 overflow-hidden`,children:[$&&O.tableData&&(0,x.jsx)(a,{columns:O.tableData.columns,rows:O.tableData.rows,total:O.tableData.total,limit:O.tableData.limit,schema:O.schema,loading:O.loading,page:O.page,onPageChange:ee,onCellUpdate:O.updateCell,onRowDelete:O.deleteRow,orderBy:O.orderBy,orderDir:O.orderDir,onToggleSort:Y,onClearSort:X,onBulkDelete:O.bulkDelete,onInsertRow:O.insertRow,connectionId:n,selectedTable:O.selectedTable,selectedSchema:O.selectedSchema,connectionName:l,columnFilters:L,onColumnFilter:B}),Q&&(0,x.jsx)(T,{result:Z,error:O.queryError,loading:O.queryLoading,schema:O.schema,connectionName:l}),te&&(0,x.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:(0,x.jsx)(d,{className:`size-4 animate-spin`})})]})]})})}var w=()=>{};function T({result:e,error:t,loading:n,schema:r,connectionName:i}){let o=(0,g.useMemo)(()=>e?.changeType===`select`&&e.rows.length>0?{columns:e.columns,rows:e.rows,total:e.rows.length,limit:e.rows.length}:null,[e]),s=(0,g.useMemo)(()=>r?.length?r:(e?.columns??[]).map(e=>({name:e,type:`text`,nullable:!0,pk:!1,defaultValue:null})),[r,e?.columns]);return(0,x.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden text-xs`,children:[t&&(0,x.jsx)(`div`,{className:`px-3 py-2 text-destructive bg-destructive/5 shrink-0`,children:t}),e?.changeType===`modify`&&(0,x.jsxs)(`div`,{className:`px-3 py-2 text-success shrink-0`,children:[e.rowsAffected,` row(s) affected`,e.executionTimeMs!=null&&(0,x.jsxs)(`span`,{className:`text-muted-foreground ml-2`,children:[e.executionTimeMs,`ms`]})]}),o&&(0,x.jsxs)(`div`,{className:`flex-1 overflow-hidden`,children:[(0,x.jsx)(a,{columns:o.columns,rows:o.rows,total:o.total,limit:o.limit,schema:s,loading:!!n,page:1,onPageChange:w,onCellUpdate:w,orderBy:null,orderDir:`ASC`,onToggleSort:w,connectionName:i}),e?.executionTimeMs!=null&&(0,x.jsxs)(`div`,{className:`px-3 py-0.5 border-t border-border text-[10px] text-muted-foreground shrink-0`,children:[e.rows.length,` rows · `,e.executionTimeMs,`ms`]})]}),e?.changeType===`select`&&e.rows.length===0&&(0,x.jsxs)(`div`,{className:`px-3 py-2 text-muted-foreground shrink-0`,children:[`No results`,e.executionTimeMs!=null&&(0,x.jsxs)(`span`,{className:`ml-2 text-muted-foreground/60`,children:[e.executionTimeMs,`ms`]})]}),!e&&!t&&(0,x.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:n?(0,x.jsx)(d,{className:`size-4 animate-spin`}):`Run a query to see results`})]})}export{C as DatabaseViewer};
1
+ import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,y as n}from"./vendor-markdown-CKTlmXbz.js";import"./vendor-ui-DMRGWRuc.js";import{t as r}from"./database-COYAMZaw.js";import{n as i,t as a}from"./glide-data-grid-CyZAiAgS.js";import{t as o}from"./shield-check-C3qYSU8a.js";import{t as s}from"./shield-off-D5tU7gQT.js";import{n as c,s as l}from"./api-client-COQtP-dB.js";import"./vendor-mermaid-CYOBtZtD.js";import"./settings-store-BbFtHCGd.js";import"./panel-store-CpKvXNnm.js";import{t as u}from"./tab-store-BQmDVh9c.js";import{A as d,Wt as f,en as p,in as m}from"./index-D4KFhwmL.js";import"./data-grid-types-BuMHLKXV.js";import"./use-monaco-theme-DU3LWaPu.js";import{t as h}from"./sql-query-editor-Cf76aKfw.js";var g=e(t(),1);function _(e,t,n,r){return`ppm-db-${e}-${n}.${t}-p${r}`}function v(e,t,n,r){try{let i=sessionStorage.getItem(_(e,t,n,r));return i?JSON.parse(i):null}catch{return null}}function y(e,t,n,r,i,a){try{sessionStorage.setItem(_(e,t,n,r),JSON.stringify({data:i,cols:a}))}catch{}}function b(e){let t=`/api/db/connections/${e}`,[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(`public`),[o,s]=(0,g.useState)(null),[u,d]=(0,g.useState)([]),[f,p]=(0,g.useState)(!1),[m,h]=(0,g.useState)(null),[_,b]=(0,g.useState)(1),[x,S]=(0,g.useState)(null),[C,w]=(0,g.useState)(null),[T,E]=(0,g.useState)(!1),[D,O]=(0,g.useState)(null),[k,A]=(0,g.useState)(`ASC`),j=(0,g.useRef)(null),M=(0,g.useCallback)(async(r,a,o,l,u)=>{let f=r??n,m=a??i;if(!f)return;j.current=null,p(!0);let g=l===void 0?D:l,v=u??k;try{let n=g?`&orderBy=${encodeURIComponent(g)}&orderDir=${v}`:``,[r,i]=await Promise.all([c.get(`${t}/data?table=${encodeURIComponent(f)}&schema=${m}&page=${o??_}&limit=100${n}`),c.get(`${t}/schema?table=${encodeURIComponent(f)}&schema=${m}`)]);s(r),d(i),y(e,f,m,o??_,r,i)}catch(e){h(e.message)}finally{p(!1)}},[t,e,n,i,_,D,k]),N=(0,g.useCallback)((t,n=`public`)=>{r(t),a(n),b(1),S(null);let i=v(e,t,n,1);i?(s(i.data),d(i.cols),p(!1),M(t,n,1)):M(t,n,1)},[e,M]),P=(0,g.useCallback)(e=>{b(e),M(void 0,void 0,e)},[M]),F=(0,g.useCallback)(async e=>{j.current={sql:e,mode:`table`},p(!0);try{let n=await c.post(`${t}/query`,{sql:e,source:`filter`});n.changeType===`select`&&s({columns:n.columns,rows:n.rows,total:n.rows.length,page:1,limit:n.rows.length})}catch(e){h(e.message)}finally{p(!1)}},[t]),I=(0,g.useCallback)(async e=>{E(!0),w(null);try{let r=await c.post(`${t}/query`,{sql:e});S(r),r.changeType===`modify`?(j.current=null,M(n??void 0,i)):j.current={sql:e,mode:`query`}}catch(e){w(e.message)}finally{E(!1)}},[t,n,i,M]),L=(0,g.useCallback)((e,t)=>{let n=j.current;if(n?.mode===`table`){F(n.sql);return}M(e,t)},[F,M]),R=(0,g.useCallback)((e,t)=>{let n=t.message;h(n),l.error(`${e} failed`,{description:n})},[]),z=(0,g.useCallback)(async(e,r,a,o)=>{if(!n)return;let s=n,l=i;try{await c.put(`${t}/cell`,{table:s,schema:l,pkColumn:e,pkValue:r,column:a,value:o}),L(s,l)}catch(e){R(`Update cell`,e)}},[t,n,i,L,R]),B=(0,g.useCallback)(async(e,r)=>{if(!n)return;let a=n,o=i;try{await c.del(`${t}/row`,{table:a,schema:o,pkColumn:e,pkValue:r}),L(a,o)}catch(e){R(`Delete row`,e)}},[t,n,i,L,R]);return{selectedTable:n,selectedSchema:i,selectTable:N,tableData:o,schema:u,loading:f,error:m,page:_,setPage:P,orderBy:D,orderDir:k,toggleSort:(0,g.useCallback)(e=>{let t,n=`ASC`;D===e?k===`ASC`?(t=e,n=`DESC`):(t=null,n=`ASC`):(t=e,n=`ASC`),O(t),A(n),b(1),M(void 0,void 0,1,t,n)},[D,k,M]),clearSort:(0,g.useCallback)(()=>{O(null),A(`ASC`),b(1),M(void 0,void 0,1,null,`ASC`)},[M]),queryResult:x,queryError:C,queryLoading:T,executeQuery:I,updateCell:z,deleteRow:B,bulkDelete:(0,g.useCallback)(async(e,r)=>{if(!n)return;let a=n,o=i;try{await c.post(`${t}/rows/delete`,{table:a,schema:o,pkColumn:e,pkValues:r}),L(a,o)}catch(e){R(`Delete rows`,e)}},[t,n,i,L,R]),insertRow:(0,g.useCallback)(async e=>{if(!n)return;let r=n,a=i;try{await c.post(`${t}/row`,{table:r,schema:a,values:e}),L(r,a)}catch(e){throw R(`Insert row`,e),e}},[t,n,i,L,R]),refreshData:M,queryAsTable:F,reload:(0,g.useCallback)(()=>{let e=j.current;if(e?.mode===`query`){I(e.sql);return}if(e?.mode===`table`){F(e.sql);return}M()},[I,F,M])}}var x=n();function S(e){let t={},n=/"(\w+)"\s+ILIKE\s+'%([^']*?)%'/gi,r;for(;(r=n.exec(e))!==null;)t[r[1]]=r[2].replace(/''/g,`'`);return t}function C({metadata:e,tabId:t}){let n=e?.connectionId,l=e?.connectionName,_=e?.tableName,v=e?.schemaName??`public`,y=e?.initialSql,C=e?.currentSql,w=u(e=>e.updateTab),E=(0,g.useRef)(e);E.current=e;let D=(0,g.useCallback)(e=>{t&&w(t,{metadata:{...E.current,currentSql:e}})},[t,w]),O=b(n),{connections:k,updateConnection:A}=d(),j=(0,g.useMemo)(()=>k.find(e=>e.id===n),[k,n]),[M,N]=(0,g.useState)([]),[P,F]=(0,g.useState)(180),I=(0,g.useRef)(null),[L,R]=(0,g.useState)({}),z=(0,g.useMemo)(()=>{if(y&&!O.selectedTable)return y;if(O.selectedTable){let e=`SELECT * FROM "${O.selectedTable}"`,t=Object.entries(L).filter(([,e])=>e.trim()).map(([e,t])=>`"${e}" ILIKE '%${t.replace(/'/g,`''`)}%'`);t.length>0&&(e+=` WHERE ${t.join(` AND `)}`),O.orderBy&&(e+=` ORDER BY "${O.orderBy}" ${O.orderDir}`);let n=(O.page-1)*100;return e+=` LIMIT 100`,n>0&&(e+=` OFFSET ${n}`),e}return`SELECT * FROM `},[y,O.selectedTable,O.orderBy,O.orderDir,O.page,L]),B=(0,g.useCallback)(e=>{R(e)},[]),V=(0,g.useRef)(void 0),H=(0,g.useRef)(!1);(0,g.useEffect)(()=>{if(!O.selectedTable)return;let e=Object.values(L).some(e=>e.trim());if(!(!e&&!H.current))return H.current=e,clearTimeout(V.current),V.current=setTimeout(()=>{e?O.queryAsTable(z):O.refreshData()},500),()=>clearTimeout(V.current)},[L]);let U=(0,g.useCallback)(e=>{e.preventDefault();let t=e.clientY,n=P,r=e=>{let r=e.clientY-t;F(Math.max(80,Math.min(n+r,(I.current?.clientHeight??600)-100)))},i=()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)},[P]);(0,g.useEffect)(()=>{c.get(`/api/db/connections/${n}/tables?cached=1`).then(e=>N(e.map(e=>({name:e.name,schema:e.schema})))).catch(()=>{})},[n]);let W=(0,g.useMemo)(()=>{if(M.length!==0)return{tables:M,getColumns:async(e,t)=>await c.get(`/api/db/connections/${n}/schema?table=${encodeURIComponent(e)}${t?`&schema=${encodeURIComponent(t)}`:``}`)}},[n,M]),G=(0,g.useRef)(!1);(0,g.useEffect)(()=>{G.current||(G.current=!0,y?O.executeQuery(y):_&&O.selectTable(_,v))},[_,v,y]);let[K,q]=(0,g.useState)(!!y),J=(0,g.useCallback)(e=>{let t=e.trim();if(O.selectedTable&&RegExp(`^SELECT\\s+\\*\\s+FROM\\s+"?${O.selectedTable.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}"?\\b`,`i`).test(t)){R(S(t)),O.queryAsTable(t);return}q(!0),O.executeQuery(e)},[O.executeQuery,O.queryAsTable,O.selectedTable]),Y=(0,g.useCallback)(e=>{q(!1),O.toggleSort(e)},[O.toggleSort]),X=(0,g.useCallback)(()=>{q(!1),O.clearSort()},[O.clearSort]),ee=(0,g.useCallback)(e=>{q(!1),O.setPage(e)},[O.setPage]),Z=O.queryResult,Q=K&&!!(Z||O.queryError),$=O.selectedTable&&!Q,te=!($&&O.tableData)&&!Q&&(O.loading||O.queryLoading);return(0,x.jsx)(`div`,{ref:I,className:`flex h-full w-full overflow-hidden`,children:(0,x.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b border-border bg-background shrink-0`,children:[(0,x.jsx)(r,{className:`size-3.5 text-muted-foreground`}),(0,x.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:l??`Database`}),O.selectedTable&&(0,x.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`/ `,O.selectedTable]}),(0,x.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[O.tableData&&(0,x.jsx)(i,{columns:O.tableData.columns,rows:O.tableData.rows,filename:l?`${l}-${O.selectedTable??`data`}`:O.selectedTable??`data`,exportAllUrl:O.selectedTable?`/api/db/connections/${n}/export?table=${encodeURIComponent(O.selectedTable)}&schema=${O.selectedSchema}`:void 0}),j&&(0,x.jsx)(`button`,{type:`button`,onClick:()=>A(j.id,{readonly:j.readonly?0:1}),className:`flex items-center gap-0.5 px-1 py-0.5 rounded text-[10px] transition-colors ${j.readonly?`text-muted-foreground hover:text-foreground`:`bg-destructive/15 text-destructive`}`,title:j.readonly?`Readonly — click to allow writes`:`WRITE mode — click to enable readonly`,children:j.readonly?(0,x.jsx)(o,{className:`size-3`}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(s,{className:`size-3`}),(0,x.jsx)(`span`,{className:`font-medium`,children:`WRITE`})]})}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>O.reload(),title:`Reload data`,className:`p-1 rounded text-muted-foreground hover:text-foreground transition-colors`,children:(0,x.jsx)(f,{className:`size-3 ${O.loading||O.queryLoading?`animate-spin`:``}`})})]})]}),(0,x.jsx)(`div`,{className:`shrink-0 border-b border-border`,style:{height:P},children:(0,x.jsx)(h,{onExecute:J,loading:O.queryLoading,defaultValue:z,schemaInfo:W,onSqlChange:D,persistedSql:C})}),(0,x.jsx)(`div`,{onMouseDown:U,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,x.jsx)(m,{className:`size-3 text-muted-foreground/50`})}),(0,x.jsxs)(`div`,{className:`flex-1 overflow-hidden`,children:[$&&O.tableData&&(0,x.jsx)(a,{columns:O.tableData.columns,rows:O.tableData.rows,total:O.tableData.total,limit:O.tableData.limit,schema:O.schema,loading:O.loading,page:O.page,onPageChange:ee,onCellUpdate:O.updateCell,onRowDelete:O.deleteRow,orderBy:O.orderBy,orderDir:O.orderDir,onToggleSort:Y,onClearSort:X,onBulkDelete:O.bulkDelete,onInsertRow:O.insertRow,connectionId:n,selectedTable:O.selectedTable,selectedSchema:O.selectedSchema,connectionName:l,columnFilters:L,onColumnFilter:B}),Q&&(0,x.jsx)(T,{result:Z,error:O.queryError,loading:O.queryLoading,schema:O.schema,connectionName:l}),te&&(0,x.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:(0,x.jsx)(p,{className:`size-4 animate-spin`})})]})]})})}var w=()=>{};function T({result:e,error:t,loading:n,schema:r,connectionName:i}){let o=(0,g.useMemo)(()=>e?.changeType===`select`&&e.rows.length>0?{columns:e.columns,rows:e.rows,total:e.rows.length,limit:e.rows.length}:null,[e]),s=(0,g.useMemo)(()=>r?.length?r:(e?.columns??[]).map(e=>({name:e,type:`text`,nullable:!0,pk:!1,defaultValue:null})),[r,e?.columns]);return(0,x.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden text-xs`,children:[t&&(0,x.jsx)(`div`,{className:`px-3 py-2 text-destructive bg-destructive/5 shrink-0`,children:t}),e?.changeType===`modify`&&(0,x.jsxs)(`div`,{className:`px-3 py-2 text-success shrink-0`,children:[e.rowsAffected,` row(s) affected`,e.executionTimeMs!=null&&(0,x.jsxs)(`span`,{className:`text-muted-foreground ml-2`,children:[e.executionTimeMs,`ms`]})]}),o&&(0,x.jsxs)(`div`,{className:`flex-1 overflow-hidden`,children:[(0,x.jsx)(a,{columns:o.columns,rows:o.rows,total:o.total,limit:o.limit,schema:s,loading:!!n,page:1,onPageChange:w,onCellUpdate:w,orderBy:null,orderDir:`ASC`,onToggleSort:w,connectionName:i}),e?.executionTimeMs!=null&&(0,x.jsxs)(`div`,{className:`px-3 py-0.5 border-t border-border text-[10px] text-muted-foreground shrink-0`,children:[e.rows.length,` rows · `,e.executionTimeMs,`ms`]})]}),e?.changeType===`select`&&e.rows.length===0&&(0,x.jsxs)(`div`,{className:`px-3 py-2 text-muted-foreground shrink-0`,children:[`No results`,e.executionTimeMs!=null&&(0,x.jsxs)(`span`,{className:`ml-2 text-muted-foreground/60`,children:[e.executionTimeMs,`ms`]})]}),!e&&!t&&(0,x.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:n?(0,x.jsx)(p,{className:`size-4 animate-spin`}):`Run a query to see results`})]})}export{C as DatabaseViewer};
@@ -1,4 +1,4 @@
1
- import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,y as n}from"./vendor-markdown-CKTlmXbz.js";import"./vendor-ui-DMRGWRuc.js";import{i as r,n as i}from"./api-client-COQtP-dB.js";import"./vendor-mermaid-CYOBtZtD.js";import{t as a}from"./settings-store-BbFtHCGd.js";import{$t as o,Nt as s,Y as c,ln as l,s as u}from"./index-bQy6gwMT.js";import{t as d}from"./use-monaco-theme-CF_57XHm.js";var f=e(t(),1),p=n();function m(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`}[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function h({metadata:e}){let t=e?.filePath,n=e?.projectName,h=e?.ref1,_=e?.ref2,v=e?.file1,y=e?.file2,b=e?.original,x=e?.modified,S=b!=null||x!=null,C=!!(v&&y),[w,T]=(0,f.useState)(null),[E,D]=(0,f.useState)(null),[O,k]=(0,f.useState)(null),[A,j]=(0,f.useState)(!S),[M,N]=(0,f.useState)(null),{wordWrap:P,toggleWordWrap:F}=a(c(e=>({wordWrap:e.wordWrap,toggleWordWrap:e.toggleWordWrap}))),I=d(),L=(0,f.useRef)(null),R=(0,f.useRef)(null),[z,B]=(0,f.useState)(!1),[V,H]=(0,f.useState)();(0,f.useEffect)(()=>{let e=L.current;if(!e)return;let t=new ResizeObserver(([e])=>{e&&H(Math.floor(e.contentRect.height))});return t.observe(e),()=>t.disconnect()},[A,M]),(0,f.useEffect)(()=>{if(S||!n)return;if(j(!0),N(null),k(null),D(null),T(null),v&&y){let e=new URLSearchParams({file1:v,file2:y});i.get(`${r(n)}/files/compare?${e}`).then(e=>{D(e),j(!1)}).catch(e=>{N(e instanceof Error?e.message:`Failed to compare files`),j(!1)});return}if(t){let e=new URLSearchParams({file:t});h&&e.set(`ref`,h),_&&e.set(`ref2`,_),i.get(`${r(n)}/git/file-full-diff?${e}`).then(e=>{k(e),j(!1)}).catch(e=>{N(e instanceof Error?e.message:`Failed to load diff`),j(!1)});return}let e;if(h||_){let t=new URLSearchParams;h&&t.set(`ref1`,h),_&&t.set(`ref2`,_),e=`${r(n)}/git/diff?${t}`}else e=`${r(n)}/git/diff`;i.get(e).then(e=>{T(e.diff),j(!1)}).catch(e=>{N(e instanceof Error?e.message:`Failed to load diff`),j(!1)})},[t,n,h,_,v,y,S]);let{original:U,modified:W}=(0,f.useMemo)(()=>S?{original:b??``,modified:x??``}:C&&E?E:O||(w?g(w):{original:``,modified:``}),[w,S,b,x,C,E,O]),G=(0,f.useMemo)(()=>{let e=t??y??v;return e?m(e):`plaintext`},[t,v,y]),K=typeof window<`u`&&window.innerWidth<768,q=!K;return(0,f.useEffect)(()=>{let e=R.current;if(!e)return;let t=K||P?`on`:`off`;e.updateOptions({diffWordWrap:t}),e.getOriginalEditor().updateOptions({wordWrapOverride2:t}),e.getModifiedEditor().updateOptions({wordWrapOverride2:t})},[P,K,z]),!n&&!S?(0,p.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`No project selected.`}):A?(0,p.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,p.jsx)(o,{className:`size-5 animate-spin`}),(0,p.jsx)(`span`,{className:`text-sm`,children:`Loading diff...`})]}):M?(0,p.jsx)(`div`,{className:`flex items-center justify-center h-full text-destructive text-sm`,children:M}):!S&&!C&&!O&&!U&&!W?(0,p.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,p.jsx)(l,{className:`size-8`}),(0,p.jsx)(`p`,{className:`text-sm`,children:`No content changes`}),t&&(0,p.jsx)(`p`,{className:`text-xs font-mono`,children:t})]}):(0,p.jsxs)(`div`,{className:`flex flex-col h-full`,children:[!K&&(0,p.jsx)(`div`,{className:`flex items-center justify-end gap-0.5 px-2 py-0.5 border-b border-border shrink-0`,children:(0,p.jsx)(`button`,{type:`button`,onClick:F,title:`Toggle word wrap`,className:`p-1 rounded hover:bg-muted transition-colors ${P?`bg-muted text-foreground`:``}`,children:(0,p.jsx)(s,{className:`size-3.5`})})}),(0,p.jsx)(`div`,{ref:L,className:`flex-1 overflow-hidden`,children:V&&V>0?(0,p.jsx)(u,{height:V,language:G,original:U,modified:W,theme:I,onMount:e=>{R.current=e,B(!0)},options:{fontSize:K?11:13,fontFamily:`Menlo, Monaco, Consolas, monospace`,diffWordWrap:K||P?`on`:`off`,renderSideBySide:q,useInlineViewWhenSpaceIsLimited:!1,readOnly:!0,automaticLayout:!0,scrollBeyondLastLine:!1},loading:(0,p.jsx)(o,{className:`size-5 animate-spin text-muted-foreground`})}):(0,p.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,p.jsx)(o,{className:`size-5 animate-spin text-muted-foreground`})})})]})}function g(e){let t=e.split(`
1
+ import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,y as n}from"./vendor-markdown-CKTlmXbz.js";import"./vendor-ui-DMRGWRuc.js";import{i as r,n as i}from"./api-client-COQtP-dB.js";import"./vendor-mermaid-CYOBtZtD.js";import{t as a}from"./settings-store-BbFtHCGd.js";import{Pt as o,X as s,en as c,s as l,un as u}from"./index-D4KFhwmL.js";import{t as d}from"./use-monaco-theme-DU3LWaPu.js";var f=e(t(),1),p=n();function m(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`}[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function h({metadata:e}){let t=e?.filePath,n=e?.projectName,h=e?.ref1,_=e?.ref2,v=e?.file1,y=e?.file2,b=e?.original,x=e?.modified,S=b!=null||x!=null,C=!!(v&&y),[w,T]=(0,f.useState)(null),[E,D]=(0,f.useState)(null),[O,k]=(0,f.useState)(null),[A,j]=(0,f.useState)(!S),[M,N]=(0,f.useState)(null),{wordWrap:P,toggleWordWrap:F}=a(s(e=>({wordWrap:e.wordWrap,toggleWordWrap:e.toggleWordWrap}))),I=d(),L=(0,f.useRef)(null),R=(0,f.useRef)(null),[z,B]=(0,f.useState)(!1),[V,H]=(0,f.useState)();(0,f.useEffect)(()=>{let e=L.current;if(!e)return;let t=new ResizeObserver(([e])=>{e&&H(Math.floor(e.contentRect.height))});return t.observe(e),()=>t.disconnect()},[A,M]),(0,f.useEffect)(()=>{if(S||!n)return;if(j(!0),N(null),k(null),D(null),T(null),v&&y){let e=new URLSearchParams({file1:v,file2:y});i.get(`${r(n)}/files/compare?${e}`).then(e=>{D(e),j(!1)}).catch(e=>{N(e instanceof Error?e.message:`Failed to compare files`),j(!1)});return}if(t){let e=new URLSearchParams({file:t});h&&e.set(`ref`,h),_&&e.set(`ref2`,_),i.get(`${r(n)}/git/file-full-diff?${e}`).then(e=>{k(e),j(!1)}).catch(e=>{N(e instanceof Error?e.message:`Failed to load diff`),j(!1)});return}let e;if(h||_){let t=new URLSearchParams;h&&t.set(`ref1`,h),_&&t.set(`ref2`,_),e=`${r(n)}/git/diff?${t}`}else e=`${r(n)}/git/diff`;i.get(e).then(e=>{T(e.diff),j(!1)}).catch(e=>{N(e instanceof Error?e.message:`Failed to load diff`),j(!1)})},[t,n,h,_,v,y,S]);let{original:U,modified:W}=(0,f.useMemo)(()=>S?{original:b??``,modified:x??``}:C&&E?E:O||(w?g(w):{original:``,modified:``}),[w,S,b,x,C,E,O]),G=(0,f.useMemo)(()=>{let e=t??y??v;return e?m(e):`plaintext`},[t,v,y]),K=typeof window<`u`&&window.innerWidth<768,q=!K;return(0,f.useEffect)(()=>{let e=R.current;if(!e)return;let t=K||P?`on`:`off`;e.updateOptions({diffWordWrap:t}),e.getOriginalEditor().updateOptions({wordWrapOverride2:t}),e.getModifiedEditor().updateOptions({wordWrapOverride2:t})},[P,K,z]),!n&&!S?(0,p.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`No project selected.`}):A?(0,p.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,p.jsx)(c,{className:`size-5 animate-spin`}),(0,p.jsx)(`span`,{className:`text-sm`,children:`Loading diff...`})]}):M?(0,p.jsx)(`div`,{className:`flex items-center justify-center h-full text-destructive text-sm`,children:M}):!S&&!C&&!O&&!U&&!W?(0,p.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,p.jsx)(u,{className:`size-8`}),(0,p.jsx)(`p`,{className:`text-sm`,children:`No content changes`}),t&&(0,p.jsx)(`p`,{className:`text-xs font-mono`,children:t})]}):(0,p.jsxs)(`div`,{className:`flex flex-col h-full`,children:[!K&&(0,p.jsx)(`div`,{className:`flex items-center justify-end gap-0.5 px-2 py-0.5 border-b border-border shrink-0`,children:(0,p.jsx)(`button`,{type:`button`,onClick:F,title:`Toggle word wrap`,className:`p-1 rounded hover:bg-muted transition-colors ${P?`bg-muted text-foreground`:``}`,children:(0,p.jsx)(o,{className:`size-3.5`})})}),(0,p.jsx)(`div`,{ref:L,className:`flex-1 overflow-hidden`,children:V&&V>0?(0,p.jsx)(l,{height:V,language:G,original:U,modified:W,theme:I,onMount:e=>{R.current=e,B(!0)},options:{fontSize:K?11:13,fontFamily:`Menlo, Monaco, Consolas, monospace`,diffWordWrap:K||P?`on`:`off`,renderSideBySide:q,useInlineViewWhenSpaceIsLimited:!1,readOnly:!0,automaticLayout:!0,scrollBeyondLastLine:!1},loading:(0,p.jsx)(c,{className:`size-5 animate-spin text-muted-foreground`})}):(0,p.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,p.jsx)(c,{className:`size-5 animate-spin text-muted-foreground`})})})]})}function g(e){let t=e.split(`
2
2
  `),n=[],r=[],i=!1;for(let e of t)if(!(e.startsWith(`diff --git`)||e.startsWith(`diff --no-index`)||e.startsWith(`index `)||e.startsWith(`new file`)||e.startsWith(`deleted file`)||e.startsWith(`old mode`)||e.startsWith(`new mode`)||e.startsWith(`---`)||e.startsWith(`+++`)||e.startsWith(`Binary files`)||e.startsWith(`\\ No newline`))){if(e.startsWith(`@@`)){i=!0;continue}if(i)if(e.startsWith(`-`))n.push(e.slice(1));else if(e.startsWith(`+`))r.push(e.slice(1));else{let t=e.startsWith(` `)?e.slice(1):e;n.push(t),r.push(t)}}return{original:n.join(`
3
3
  `),modified:r.join(`
4
4
  `)}}export{h as DiffViewer};
@@ -1,4 +1,4 @@
1
- import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,y as n}from"./vendor-markdown-CKTlmXbz.js";import"./vendor-ui-DMRGWRuc.js";import{t as r}from"./file-exclamation-point-DBEC-Kst.js";import{i,n as a}from"./api-client-COQtP-dB.js";import{$t as o}from"./index-bQy6gwMT.js";var s=e(t(),1),c=n();function l({filePath:e,projectName:t}){let[n,l]=(0,s.useState)(null),[u,d]=(0,s.useState)(!0),[f,p]=(0,s.useState)(null);return(0,s.useEffect)(()=>{d(!0),p(null);let n=/^(\/|[A-Za-z]:[/\\])/.test(e)?`/api/fs/docx-html?path=${encodeURIComponent(e)}`:`${i(t)}/files/docx-html?path=${encodeURIComponent(e)}`;a.get(n).then(e=>{l(e.html),d(!1)}).catch(e=>{p(e instanceof Error?e.message:`Failed to convert docx`),d(!1)})},[e,t]),(0,s.useEffect)(()=>{let n=n=>{let r=n.detail;if(r.projectName!==t||r.path!==e)return;let o=/^(\/|[A-Za-z]:[/\\])/.test(e)?`/api/fs/docx-html?path=${encodeURIComponent(e)}`:`${i(t)}/files/docx-html?path=${encodeURIComponent(e)}`;a.get(o).then(e=>l(e.html)).catch(()=>{})};return window.addEventListener(`file:changed`,n),()=>window.removeEventListener(`file:changed`,n)},[e,t]),u?(0,c.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-text-secondary`,children:[(0,c.jsx)(o,{className:`size-5 animate-spin`}),(0,c.jsx)(`span`,{className:`text-sm`,children:`Converting document...`})]}):f?(0,c.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,c.jsx)(r,{className:`size-10 text-text-subtle`}),(0,c.jsx)(`p`,{className:`text-sm`,children:`Failed to load document.`}),(0,c.jsx)(`p`,{className:`text-xs text-text-subtle`,children:f})]}):(0,c.jsx)(`div`,{className:`h-full overflow-auto bg-white dark:bg-bg`,children:(0,c.jsx)(`div`,{className:`docx-preview max-w-3xl mx-auto px-6 py-8 text-sm text-foreground leading-relaxed
1
+ import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,y as n}from"./vendor-markdown-CKTlmXbz.js";import"./vendor-ui-DMRGWRuc.js";import{t as r}from"./file-exclamation-point-DBEC-Kst.js";import{i,n as a}from"./api-client-COQtP-dB.js";import{en as o}from"./index-D4KFhwmL.js";var s=e(t(),1),c=n();function l({filePath:e,projectName:t}){let[n,l]=(0,s.useState)(null),[u,d]=(0,s.useState)(!0),[f,p]=(0,s.useState)(null);return(0,s.useEffect)(()=>{d(!0),p(null);let n=/^(\/|[A-Za-z]:[/\\])/.test(e)?`/api/fs/docx-html?path=${encodeURIComponent(e)}`:`${i(t)}/files/docx-html?path=${encodeURIComponent(e)}`;a.get(n).then(e=>{l(e.html),d(!1)}).catch(e=>{p(e instanceof Error?e.message:`Failed to convert docx`),d(!1)})},[e,t]),(0,s.useEffect)(()=>{let n=n=>{let r=n.detail;if(r.projectName!==t||r.path!==e)return;let o=/^(\/|[A-Za-z]:[/\\])/.test(e)?`/api/fs/docx-html?path=${encodeURIComponent(e)}`:`${i(t)}/files/docx-html?path=${encodeURIComponent(e)}`;a.get(o).then(e=>l(e.html)).catch(()=>{})};return window.addEventListener(`file:changed`,n),()=>window.removeEventListener(`file:changed`,n)},[e,t]),u?(0,c.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-text-secondary`,children:[(0,c.jsx)(o,{className:`size-5 animate-spin`}),(0,c.jsx)(`span`,{className:`text-sm`,children:`Converting document...`})]}):f?(0,c.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,c.jsx)(r,{className:`size-10 text-text-subtle`}),(0,c.jsx)(`p`,{className:`text-sm`,children:`Failed to load document.`}),(0,c.jsx)(`p`,{className:`text-xs text-text-subtle`,children:f})]}):(0,c.jsx)(`div`,{className:`h-full overflow-auto bg-white dark:bg-bg`,children:(0,c.jsx)(`div`,{className:`docx-preview max-w-3xl mx-auto px-6 py-8 text-sm text-foreground leading-relaxed
2
2
  [&_table]:border-collapse [&_table]:w-full [&_table]:my-3
3
3
  [&_td]:border [&_td]:border-border [&_td]:px-2 [&_td]:py-1
4
4
  [&_th]:border [&_th]:border-border [&_th]:px-2 [&_th]:py-1 [&_th]:font-semibold [&_th]:bg-muted/50
@@ -1,3 +1,3 @@
1
- import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,y as n}from"./vendor-markdown-CKTlmXbz.js";import"./vendor-ui-DMRGWRuc.js";import{r}from"./api-client-COQtP-dB.js";import{$t as i,ct as a}from"./index-bQy6gwMT.js";var o=e(t(),1),s=n(),c=`<script>
1
+ import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,y as n}from"./vendor-markdown-CKTlmXbz.js";import"./vendor-ui-DMRGWRuc.js";import{r}from"./api-client-COQtP-dB.js";import{en as i,lt as a}from"./index-D4KFhwmL.js";var o=e(t(),1),s=n(),c=`<script>
2
2
  function acquireVsCodeApi(){return{postMessage:function(m){window.parent.postMessage(m,"*")},getState:function(){try{return JSON.parse(sessionStorage.getItem("vscode-state")||"null")}catch{return null}},setState:function(s){sessionStorage.setItem("vscode-state",JSON.stringify(s));return s}}}
3
3
  <\/script>`;function l(e){if(!e)return e;let t=e.indexOf(`<head>`);return t===-1?c+e:e.slice(0,t+6)+c+e.slice(t+6)}function u({metadata:e}){let t=e?.panelId,n=e?.viewType,c=e?.projectName||void 0,[u,d]=(0,o.useState)(!1),f=a(e=>e.contributions!==null),p=a(e=>{if(t&&e.webviewPanels[t])return e.webviewPanels[t];if(n){let t=n.includes(`.`)?n:`${n}.view`,r=Object.values(e.webviewPanels).filter(e=>e.viewType===n||e.viewType===t);return r.find(e=>e.projectName&&e.projectName===c)??r.find(e=>!e.projectName||!c)}}),m=p?.id??t,h=(0,o.useRef)(null),g=p?.html??``,_=l(g),v=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(p||!n||!f||c&&c===v.current)return;c&&(v.current=c);let e=n.includes(`.`)?n:`${n}.view`,t=!1;async function i(){let n=[];if(c)try{let e=r(),t=(await(await fetch(`/api/projects`,e?{headers:{Authorization:`Bearer ${e}`}}:{})).json()).data?.find(e=>e.name===c);t&&(n=[t.path])}catch{}t||window.dispatchEvent(new CustomEvent(`ext:command:execute`,{detail:{command:e,args:n,recovery:!0}}))}return i(),()=>{t=!0}},[p,n,c,f]);let y=e?.extensionId,b=a(e=>{if(y&&e.activationErrors[y])return e.activationErrors[y];if(n){for(let[t,r]of Object.entries(e.activationErrors))if(t===`ext-${n}`)return r}}),x=(0,o.useCallback)(()=>{if(d(!1),!n)return;let e=n.includes(`.`)?n:`${n}.view`;(async()=>{try{let t=r(),n=(await(await fetch(`/api/projects`,t?{headers:{Authorization:`Bearer ${t}`}}:{})).json()).data?.find(e=>e.name===c),i=n?[n.path]:[];window.dispatchEvent(new CustomEvent(`ext:command:execute`,{detail:{command:e,args:i,recovery:!0}}))}catch{}})()},[n,c]),S=(0,o.useRef)(null),C=(0,o.useRef)(n),w=(0,o.useRef)(c);return(0,o.useEffect)(()=>{S.current=m??null},[m]),(0,o.useEffect)(()=>{C.current=n},[n]),(0,o.useEffect)(()=>{w.current=c},[c]),(0,o.useEffect)(()=>()=>{let e=S.current;if(e){let t=C.current;a.getState().removeWebviewPanel(e),window.dispatchEvent(new CustomEvent(`ext:webview:close`,{detail:{panelId:e,viewType:t,projectName:w.current}}))}},[]),(0,o.useEffect)(()=>{if(p){d(!1);return}if(!f||!n)return;let e=0,t=setInterval(()=>{if(e++,e>3){clearInterval(t),d(!0);return}x()},2e3);return()=>clearInterval(t)},[p,f,n,x]),(0,o.useEffect)(()=>{if(!m)return;let e=e=>{h.current&&e.source===h.current.contentWindow&&window.dispatchEvent(new CustomEvent(`ext:webview:send`,{detail:{panelId:m,message:e.data}}))};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[m]),(0,o.useEffect)(()=>{if(!m)return;let e=e=>{let{panelId:t,message:n}=e.detail;t===m&&h.current?.contentWindow?.postMessage(n,`*`)};return window.addEventListener(`ext:webview:message`,e),()=>window.removeEventListener(`ext:webview:message`,e)},[m]),!p||!g?(0,s.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-sm text-text-subtle`,children:u?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`span`,{className:`text-destructive font-medium`,children:`Extension failed to load`}),b&&(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground max-w-md text-center`,children:b}),(0,s.jsx)(`button`,{onClick:x,className:`text-xs text-primary hover:underline`,children:`Retry`})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i,{className:`size-5 animate-spin`}),(0,s.jsx)(`span`,{children:`Loading extension...`})]})}):(0,s.jsx)(`div`,{className:`h-full w-full relative`,children:(0,s.jsx)(`iframe`,{ref:h,srcDoc:_,sandbox:`allow-scripts`,className:`w-full h-full border-0 bg-white dark:bg-bg`,title:p.title},m)})}export{u as ExtensionWebview};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,y as n}from"./vendor-markdown-CKTlmXbz.js";import"./vendor-ui-DMRGWRuc.js";import{t as r}from"./createLucideIcon-ConhwJnb.js";import{i,n as a}from"./api-client-COQtP-dB.js";import{n as o}from"./utils-E0yyGxXt.js";import{i as s}from"./project-store-D0ALup9Z.js";import{$t as c,It as l,Tn as u,Ut as d,Y as f,in as p,pn as m,wn as h}from"./index-bQy6gwMT.js";var g=r(`cloud-off`,[[`path`,{d:`M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057`,key:`1uxyv8`}],[`path`,{d:`M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78`,key:`99tcn7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),_=e(t(),1),v=n(),y=[`#2563eb`,`#16a34a`,`#d97706`,`#9333ea`,`#dc2626`,`#0891b2`,`#c026d3`,`#ea580c`];function b(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return y[Math.abs(t)%y.length]}function x({name:e,syncState:t,isHead:n,isTag:r,className:i}){let a=r?`#d97706`:b(e),s=r?l:t===`synced`?m:t===`ahead`?h:t===`behind`?u:t===`remote-only`?m:g,c=r?`Tag: ${e}`:t===`synced`?`${e} — synced with remote`:t===`ahead`?`${e} — ahead of remote`:t===`behind`?`${e} — behind remote`:t===`remote-only`?`${e} — remote only`:`${e} — local only`;return(0,v.jsxs)(`span`,{className:o(`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-[11px] font-medium leading-tight max-w-[220px]`,n&&`ring-1 ring-offset-1 ring-offset-background`,t===`remote-only`&&`opacity-70`,i),style:{borderColor:a,backgroundColor:a+`1A`,color:`var(--text)`,...n?{"--tw-ring-color":a}:{}},title:c,children:[(0,v.jsx)(s,{className:`size-3 shrink-0`,style:{color:a}}),(0,v.jsx)(`span`,{className:`truncate`,children:e})]})}function S(e,t,n,r){let i=[],a=e===r;for(let e of t)e.startsWith(`tag: `)&&i.push({name:e.slice(5),syncState:`synced`,isTag:!0});let o=n.filter(t=>t.commitHash===e),s=o.filter(e=>!e.remote),c=o.filter(e=>e.remote);new Set(s.map(e=>e.name));let l=new Set;for(let e of s){let t=`local-only`;e.remotes.length>0&&(t=e.ahead>0&&e.behind===0?`ahead`:e.behind>0&&e.ahead===0?`behind`:`synced`),i.push({name:e.name,syncState:t,isHead:a&&e.current});for(let t of c){let n=t.name.replace(/^remotes\//,``),r=n.indexOf(`/`);r<0||n.slice(r+1)===e.name&&l.add(t.name)}}for(let e of c){if(l.has(e.name))continue;let t=e.name.replace(/^remotes\//,``);i.push({name:t,syncState:`remote-only`})}return i}var C=100;function w({metadata:e}){let t=e?.projectName??s(f(e=>e.activeProject))?.name,[n,r]=(0,_.useState)(null),[o,l]=(0,_.useState)(!1),[u,m]=(0,_.useState)(!0),h=(0,_.useRef)(null),g=(0,_.useCallback)(async(e=0,n=!1)=>{if(t){l(!0);try{let o=await a.get(`${i(t)}/git/graph?max=${C}&skip=${e}`);r(e=>n&&e?{...o,commits:[...e.commits,...o.commits]}:o),m(o.commits.length===C)}catch{}l(!1)}},[t]);(0,_.useEffect)(()=>{g()},[g]);let y=(0,_.useCallback)(()=>{o||!u||!n||g(n.commits.length,!0)},[o,u,n,g]),b=(0,_.useCallback)(e=>{let t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<200&&y()},[y]);return t?(0,v.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border shrink-0`,children:[(0,v.jsx)(p,{className:`size-4 text-text-secondary`}),(0,v.jsx)(`span`,{className:`text-xs font-medium text-text-primary`,children:`Git Log`}),(0,v.jsx)(`span`,{className:`text-[10px] text-text-subtle`,children:n?`${n.commits.length} commits`:``}),(0,v.jsx)(`div`,{className:`flex-1`}),(0,v.jsx)(`button`,{onClick:()=>g(),disabled:o,className:`p-1 rounded text-text-subtle hover:text-text-secondary transition-colors`,title:`Refresh`,children:(0,v.jsx)(d,{className:`size-3.5 ${o?`animate-spin`:``}`})})]}),!n&&o?(0,v.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,v.jsx)(c,{className:`size-5 animate-spin text-primary`})}):n&&n.commits.length===0?(0,v.jsx)(`div`,{className:`flex items-center justify-center h-full text-text-secondary text-sm`,children:`No commits yet`}):n?(0,v.jsxs)(`div`,{ref:h,className:`flex-1 overflow-y-auto min-h-0`,onScroll:b,children:[n.commits.map(e=>(0,v.jsx)(T,{commit:e,branches:n.branches,head:n.head},e.hash)),o&&(0,v.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,v.jsx)(c,{className:`size-4 animate-spin text-text-subtle`})}),!u&&n.commits.length>0&&(0,v.jsx)(`div`,{className:`text-center text-[10px] text-text-subtle py-3`,children:`End of history`})]}):null]}):(0,v.jsx)(`div`,{className:`flex items-center justify-center h-full text-text-secondary text-sm`,children:`Select a project to view git log`})}function T({commit:e,branches:t,head:n}){let r=e.hash===n,i=S(e.hash,e.refs,t,n);return(0,v.jsxs)(`div`,{className:`flex items-start gap-2 px-3 py-1.5 border-b border-border/50 hover:bg-surface-elevated transition-colors ${r?`bg-primary/5`:``}`,children:[(0,v.jsx)(`div`,{className:`flex items-center pt-1 shrink-0`,children:(0,v.jsx)(`span`,{className:`size-2.5 rounded-full border-2 ${r?`border-primary bg-primary`:`border-text-subtle bg-transparent`}`})}),(0,v.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[i.length>0&&(0,v.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 mb-0.5`,children:i.map(e=>(0,v.jsx)(x,{...e},`${e.name}-${e.syncState}`))}),(0,v.jsx)(`p`,{className:`text-xs text-text-primary truncate leading-snug`,children:e.subject}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,v.jsx)(`span`,{className:`text-[10px] font-mono text-text-subtle`,children:e.abbreviatedHash}),(0,v.jsx)(`span`,{className:`text-[10px] text-text-subtle truncate`,children:e.authorName}),(0,v.jsx)(`span`,{className:`text-[10px] text-text-subtle shrink-0`,children:E(e.authorDate)})]})]})]})}function E(e){let t=new Date(e),n=Date.now()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`now`;if(r<60)return`${r}m`;let i=Math.floor(r/60);if(i<24)return`${i}h`;let a=Math.floor(i/24);return a<30?`${a}d`:t.toLocaleDateString(`en`,{month:`short`,day:`numeric`})}export{w as GitLogPanel};
1
+ import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,y as n}from"./vendor-markdown-CKTlmXbz.js";import"./vendor-ui-DMRGWRuc.js";import{t as r}from"./createLucideIcon-ConhwJnb.js";import{i,n as a}from"./api-client-COQtP-dB.js";import{n as o}from"./utils-E0yyGxXt.js";import{i as s}from"./project-store-D0ALup9Z.js";import{En as c,Lt as l,Tn as u,Wt as d,X as f,an as p,en as m,mn as h}from"./index-D4KFhwmL.js";var g=r(`cloud-off`,[[`path`,{d:`M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057`,key:`1uxyv8`}],[`path`,{d:`M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78`,key:`99tcn7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),_=e(t(),1),v=n(),y=[`#2563eb`,`#16a34a`,`#d97706`,`#9333ea`,`#dc2626`,`#0891b2`,`#c026d3`,`#ea580c`];function b(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return y[Math.abs(t)%y.length]}function x({name:e,syncState:t,isHead:n,isTag:r,className:i}){let a=r?`#d97706`:b(e),s=r?l:t===`synced`?h:t===`ahead`?u:t===`behind`?c:t===`remote-only`?h:g,d=r?`Tag: ${e}`:t===`synced`?`${e} — synced with remote`:t===`ahead`?`${e} — ahead of remote`:t===`behind`?`${e} — behind remote`:t===`remote-only`?`${e} — remote only`:`${e} — local only`;return(0,v.jsxs)(`span`,{className:o(`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-[11px] font-medium leading-tight max-w-[220px]`,n&&`ring-1 ring-offset-1 ring-offset-background`,t===`remote-only`&&`opacity-70`,i),style:{borderColor:a,backgroundColor:a+`1A`,color:`var(--text)`,...n?{"--tw-ring-color":a}:{}},title:d,children:[(0,v.jsx)(s,{className:`size-3 shrink-0`,style:{color:a}}),(0,v.jsx)(`span`,{className:`truncate`,children:e})]})}function S(e,t,n,r){let i=[],a=e===r;for(let e of t)e.startsWith(`tag: `)&&i.push({name:e.slice(5),syncState:`synced`,isTag:!0});let o=n.filter(t=>t.commitHash===e),s=o.filter(e=>!e.remote),c=o.filter(e=>e.remote);new Set(s.map(e=>e.name));let l=new Set;for(let e of s){let t=`local-only`;e.remotes.length>0&&(t=e.ahead>0&&e.behind===0?`ahead`:e.behind>0&&e.ahead===0?`behind`:`synced`),i.push({name:e.name,syncState:t,isHead:a&&e.current});for(let t of c){let n=t.name.replace(/^remotes\//,``),r=n.indexOf(`/`);r<0||n.slice(r+1)===e.name&&l.add(t.name)}}for(let e of c){if(l.has(e.name))continue;let t=e.name.replace(/^remotes\//,``);i.push({name:t,syncState:`remote-only`})}return i}var C=100;function w({metadata:e}){let t=e?.projectName??s(f(e=>e.activeProject))?.name,[n,r]=(0,_.useState)(null),[o,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(!0),h=(0,_.useRef)(null),g=(0,_.useCallback)(async(e=0,n=!1)=>{if(t){c(!0);try{let o=await a.get(`${i(t)}/git/graph?max=${C}&skip=${e}`);r(e=>n&&e?{...o,commits:[...e.commits,...o.commits]}:o),u(o.commits.length===C)}catch{}c(!1)}},[t]);(0,_.useEffect)(()=>{g()},[g]);let y=(0,_.useCallback)(()=>{o||!l||!n||g(n.commits.length,!0)},[o,l,n,g]),b=(0,_.useCallback)(e=>{let t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<200&&y()},[y]);return t?(0,v.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border shrink-0`,children:[(0,v.jsx)(p,{className:`size-4 text-text-secondary`}),(0,v.jsx)(`span`,{className:`text-xs font-medium text-text-primary`,children:`Git Log`}),(0,v.jsx)(`span`,{className:`text-[10px] text-text-subtle`,children:n?`${n.commits.length} commits`:``}),(0,v.jsx)(`div`,{className:`flex-1`}),(0,v.jsx)(`button`,{onClick:()=>g(),disabled:o,className:`p-1 rounded text-text-subtle hover:text-text-secondary transition-colors`,title:`Refresh`,children:(0,v.jsx)(d,{className:`size-3.5 ${o?`animate-spin`:``}`})})]}),!n&&o?(0,v.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,v.jsx)(m,{className:`size-5 animate-spin text-primary`})}):n&&n.commits.length===0?(0,v.jsx)(`div`,{className:`flex items-center justify-center h-full text-text-secondary text-sm`,children:`No commits yet`}):n?(0,v.jsxs)(`div`,{ref:h,className:`flex-1 overflow-y-auto min-h-0`,onScroll:b,children:[n.commits.map(e=>(0,v.jsx)(T,{commit:e,branches:n.branches,head:n.head},e.hash)),o&&(0,v.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,v.jsx)(m,{className:`size-4 animate-spin text-text-subtle`})}),!l&&n.commits.length>0&&(0,v.jsx)(`div`,{className:`text-center text-[10px] text-text-subtle py-3`,children:`End of history`})]}):null]}):(0,v.jsx)(`div`,{className:`flex items-center justify-center h-full text-text-secondary text-sm`,children:`Select a project to view git log`})}function T({commit:e,branches:t,head:n}){let r=e.hash===n,i=S(e.hash,e.refs,t,n);return(0,v.jsxs)(`div`,{className:`flex items-start gap-2 px-3 py-1.5 border-b border-border/50 hover:bg-surface-elevated transition-colors ${r?`bg-primary/5`:``}`,children:[(0,v.jsx)(`div`,{className:`flex items-center pt-1 shrink-0`,children:(0,v.jsx)(`span`,{className:`size-2.5 rounded-full border-2 ${r?`border-primary bg-primary`:`border-text-subtle bg-transparent`}`})}),(0,v.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[i.length>0&&(0,v.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 mb-0.5`,children:i.map(e=>(0,v.jsx)(x,{...e},`${e.name}-${e.syncState}`))}),(0,v.jsx)(`p`,{className:`text-xs text-text-primary truncate leading-snug`,children:e.subject}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,v.jsx)(`span`,{className:`text-[10px] font-mono text-text-subtle`,children:e.abbreviatedHash}),(0,v.jsx)(`span`,{className:`text-[10px] text-text-subtle truncate`,children:e.authorName}),(0,v.jsx)(`span`,{className:`text-[10px] text-text-subtle shrink-0`,children:E(e.authorDate)})]})]})]})}function E(e){let t=new Date(e),n=Date.now()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`now`;if(r<60)return`${r}m`;let i=Math.floor(r/60);if(i<24)return`${i}h`;let a=Math.floor(i/24);return a<30?`${a}d`:t.toLocaleDateString(`en`,{month:`short`,day:`numeric`})}export{w as GitLogPanel};