planche 0.8.1 → 0.8.3

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 (98) hide show
  1. package/app/assets/AboutDialog-DuqxA9a9.js +1 -0
  2. package/app/assets/AiSettingsDialog-CgGNd3Oc.js +1 -0
  3. package/app/assets/ConnectDialog-H3vlQRP_.js +1 -0
  4. package/app/assets/CopyDatabaseDialog-CVoYRBig.js +1 -0
  5. package/app/assets/CopyTableDialog-DC1kxjD2.js +1 -0
  6. package/app/assets/CreateDatabaseDialog-BYwKAc5-.js +1 -0
  7. package/app/assets/CreateSchemaDialog-BhPRvUT-.js +1 -0
  8. package/app/assets/DataDiffDialog-CXMnUq1B.js +1 -0
  9. package/app/assets/DownloadToCSVDialog-Bc0PDZHm.js +3 -0
  10. package/app/assets/EditSchemaDialog-B4h1xWEz.js +2 -0
  11. package/app/assets/FindReplaceDialog-BkDPXuox.js +1 -0
  12. package/app/assets/{FlushDialog-Cu_3tGcK.js → FlushDialog-BlPJ6BTk.js} +1 -1
  13. package/app/assets/{GeneralSettingsDialog-xgxhF9Gn.js → GeneralSettingsDialog-ByNvtugk.js} +1 -1
  14. package/app/assets/GroupByDialog-B593U6zZ.js +1 -0
  15. package/app/assets/LicenseDialog-3TWjXiJM.js +1 -0
  16. package/app/assets/LinkColumnDialog-D3ygO1ut.js +1 -0
  17. package/app/assets/LocalHistoryDialog-DPgqYYkG.js +1 -0
  18. package/app/assets/McpSetupDialog-DOS0fPHQ.js +1 -0
  19. package/app/assets/ProcessListDialog-DNqFCxy7.js +1 -0
  20. package/app/assets/QuerySettingsDialog-BjD8gLmZ.js +1 -0
  21. package/app/assets/QuickCommandPalette-06i8D2JM.js +1 -0
  22. package/app/assets/RowFormDialog-pQYmxMrm.js +2 -0
  23. package/app/assets/{SafetySettingsDialog-D5yLNWsA.js → SafetySettingsDialog-a0Y03qEt.js} +1 -1
  24. package/app/assets/SchemaDiffDialog-DjuZiSux.js +7 -0
  25. package/app/assets/SchemaToHTMLDialog-NzNj1jXs.js +27 -0
  26. package/app/assets/StatusDialog-DVKcDDpl.js +1 -0
  27. package/app/assets/SyncDialog-CTyRxpKa.js +1 -0
  28. package/app/assets/TermsDialog-oo1J6DXC.js +1 -0
  29. package/app/assets/UserAddDialog-CtZpkft3.js +1 -0
  30. package/app/assets/UserManagerDialog-Dk1mzBsu.js +1 -0
  31. package/app/assets/VariablesDialog-Blu74K9P.js +1 -0
  32. package/app/assets/{connection-store-D-Lp5EFj.js → connection-store-B85kbJpB.js} +1 -1
  33. package/app/assets/{database-CfYjCIA2.js → database-BSXLJRzV.js} +1 -1
  34. package/app/assets/de-EBRzfz-s.js +2 -0
  35. package/app/assets/{engine-Ja9hkC7I.js → engine-DjP-Sw-S.js} +1 -1
  36. package/app/assets/{error-hints-9kGurk72.js → error-hints-BsG7qe62.js} +1 -1
  37. package/app/assets/fr-DERxGVO3.js +2 -0
  38. package/app/assets/{i18n-BQcNT-sS.js → i18n-C0aLwQ_k.js} +2 -2
  39. package/app/assets/index-Tw24-4of.js +959 -0
  40. package/app/assets/index-dwv2QL4R.css +2 -0
  41. package/app/assets/ja-C7vEFXh8.js +2 -0
  42. package/app/assets/ko-1oXH_x0o.js +2 -0
  43. package/app/assets/pro-upsell-DhbKIX46.js +1 -0
  44. package/app/assets/pro-usage-BxwRZwtM.js +1 -0
  45. package/app/assets/{query-execution-_bzhSmJm.js → query-execution-BeDEQ-3M.js} +2 -2
  46. package/app/assets/{query-store-Cf_KUo80.js → query-store-BqBiylGA.js} +1 -1
  47. package/app/assets/select-DEqoX1sU.js +1 -0
  48. package/app/assets/settings-controls-BepR6gzL.js +1 -0
  49. package/app/assets/tunneling-B7lL9I14.js +6 -0
  50. package/app/assets/zh-B-LYJHDx.js +2 -0
  51. package/app/index.html +24 -27
  52. package/app/landing.css +4 -2
  53. package/dist/index.js +49 -23
  54. package/package.json +1 -1
  55. package/app/assets/AboutDialog-3SX5EV22.js +0 -1
  56. package/app/assets/AiSettingsDialog-DIhTViGS.js +0 -1
  57. package/app/assets/ConnectDialog-B9B2pmBd.js +0 -1
  58. package/app/assets/CopyDatabaseDialog-DV7zQRd2.js +0 -1
  59. package/app/assets/CopyTableDialog-1A2wKslg.js +0 -1
  60. package/app/assets/CreateDatabaseDialog-CLiJJQgN.js +0 -1
  61. package/app/assets/CreateSchemaDialog-DD_28Eub.js +0 -1
  62. package/app/assets/DataDiffDialog-hIvWJqmh.js +0 -1
  63. package/app/assets/DownloadToCSVDialog-CLpJ8bDP.js +0 -3
  64. package/app/assets/EditSchemaDialog-B8ONt2sC.js +0 -2
  65. package/app/assets/FindReplaceDialog-H1fQsF0u.js +0 -1
  66. package/app/assets/GroupByDialog-BCDcazzJ.js +0 -1
  67. package/app/assets/LicenseDialog-DQHhxdtR.js +0 -1
  68. package/app/assets/LinkColumnDialog-V430TeVp.js +0 -1
  69. package/app/assets/LocalHistoryDialog-BA_7Fo9B.js +0 -1
  70. package/app/assets/McpSetupDialog-BFoqHq0W.js +0 -1
  71. package/app/assets/ProcessListDialog-C580troj.js +0 -1
  72. package/app/assets/QuerySettingsDialog-CxaKHHfo.js +0 -1
  73. package/app/assets/QuickCommandPalette-DI4_5uY6.js +0 -1
  74. package/app/assets/RowFormDialog-DXK8CWzh.js +0 -2
  75. package/app/assets/SchemaDiffDialog-DsXAMyhh.js +0 -7
  76. package/app/assets/SchemaToHTMLDialog-CDrt2YXj.js +0 -27
  77. package/app/assets/StatusDialog-CnIJeQpO.js +0 -1
  78. package/app/assets/SyncDialog-DXLRjtc3.js +0 -1
  79. package/app/assets/TermsDialog-D4K_QWCp.js +0 -1
  80. package/app/assets/UserAddDialog-DPBPQ90W.js +0 -1
  81. package/app/assets/UserManagerDialog-_slF5p1Y.js +0 -1
  82. package/app/assets/VariablesDialog-IdnBQyHZ.js +0 -1
  83. package/app/assets/de-U48bWKTK.js +0 -2
  84. package/app/assets/dist-BUXw8brT.js +0 -1
  85. package/app/assets/dist-BrzYmjQV.js +0 -1
  86. package/app/assets/dist-C2vlTGNz.js +0 -1
  87. package/app/assets/fr-B_almVyv.js +0 -2
  88. package/app/assets/ja-BS_mc_Gc.js +0 -2
  89. package/app/assets/ko-DgeKS5Bf.js +0 -2
  90. package/app/assets/main-BwM1zx0B.js +0 -959
  91. package/app/assets/main-D2x95iIF.css +0 -2
  92. package/app/assets/pro-upsell-BH-enstO.js +0 -1
  93. package/app/assets/pro-usage-D4Iv3hEs.js +0 -1
  94. package/app/assets/select-CtfiGpCP.js +0 -1
  95. package/app/assets/settings-controls-DyukG7E2.js +0 -1
  96. package/app/assets/table-copy-JytHH7NG.js +0 -1
  97. package/app/assets/tunneling-C--CCnwy.js +0 -6
  98. package/app/assets/zh-CoZStBZ6.js +0 -2
@@ -0,0 +1 @@
1
+ import{n as e}from"./ui-store-5IssrgmG.js";import{l as t,m as n,t as r}from"./button-B2EsmMJs.js";import{q as i,t as a}from"./index-Tw24-4of.js";import{a as o,i as s,n as c,o as l,r as u,t as d}from"./dialog-FBpgH0QJ.js";var f=t(),p=`https://planche.dev`,m=`/third-party-notices.txt`;function h(){let t=e(e=>e.activeDialog),h=e(e=>e.closeDialog),{t:g}=n();return(0,f.jsx)(d,{open:t===`about`,onOpenChange:e=>{e||h()},children:(0,f.jsxs)(c,{className:`sm:max-w-[440px]`,children:[(0,f.jsx)(o,{children:(0,f.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,f.jsx)(a,{size:44,className:`shrink-0`}),(0,f.jsxs)(`div`,{className:`grid gap-1`,children:[(0,f.jsx)(l,{children:g(`about.title`)}),(0,f.jsx)(u,{children:g(`about.tagline`)})]})]})}),(0,f.jsxs)(`div`,{className:`grid gap-3 text-sm`,children:[(0,f.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-4 gap-y-1`,children:[(0,f.jsx)(`dt`,{className:`text-muted-foreground`,children:g(`about.version`)}),(0,f.jsx)(`dd`,{children:`0.1.1`}),(0,f.jsx)(`dt`,{className:`text-muted-foreground`,children:g(`about.website`)}),(0,f.jsx)(`dd`,{children:(0,f.jsx)(`a`,{href:p,target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2`,children:p})}),(0,f.jsx)(`dt`,{className:`text-muted-foreground`,children:g(`about.licenses`)}),(0,f.jsx)(`dd`,{children:(0,f.jsx)(`a`,{href:m,target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2`,children:g(`about.licensesLink`)})}),(0,f.jsx)(`dt`,{className:`text-muted-foreground`,children:g(`about.legal`)}),(0,f.jsxs)(`dd`,{className:`flex gap-3`,children:[(0,f.jsx)(`a`,{href:i.terms,target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2`,children:g(`about.terms`)}),(0,f.jsx)(`a`,{href:i.privacy,target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2`,children:g(`about.privacy`)}),(0,f.jsx)(`a`,{href:i.refund,target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2`,children:g(`about.refund`)})]})]}),(0,f.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`© 2026 Juwon Jeong. `,g(`about.rights`)]}),(0,f.jsx)(`p`,{className:`rounded-md border bg-muted/40 p-3 text-xs text-muted-foreground`,children:g(`about.disclaimer`)}),(0,f.jsxs)(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/5 p-3 text-xs text-muted-foreground`,children:[(0,f.jsx)(`p`,{className:`mb-1 font-medium text-amber-600 dark:text-amber-400`,children:g(`pro.noticeTitle`)}),(0,f.jsx)(`p`,{children:g(`pro.notice`)})]})]}),(0,f.jsx)(s,{children:(0,f.jsx)(r,{onClick:h,children:g(`settings.done`)})})]})})}export{h as AboutDialog};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{h as t,n}from"./ui-store-5IssrgmG.js";import{l as r,m as i,t as a}from"./button-B2EsmMJs.js";import{a as o,i as s,n as c,r as l,t as u}from"./select-DEqoX1sU.js";import{i as d,n as f}from"./settings-store-DzQ3BP5e.js";import{b as p,c as m,d as h}from"./tunneling-B7lL9I14.js";import{c as g,l as _,w as v}from"./index-Tw24-4of.js";import{a as y,i as b,n as x,o as S,r as C,t as w}from"./dialog-FBpgH0QJ.js";var T=e(t(),1),E=r(),D={autoComplete:`off`,"data-1p-ignore":!0,"data-lpignore":`true`,"data-bwignore":!0};function O(){let{t:e}=i(),[t,n]=(0,T.useState)(null),[r,y]=(0,T.useState)(!1),[b,x]=(0,T.useState)(`anthropic`),[S,C]=(0,T.useState)(``),[w,O]=(0,T.useState)(``),[k,A]=(0,T.useState)(``),[j,M]=(0,T.useState)(!1),[N,P]=(0,T.useState)([]),[F,I]=(0,T.useState)(!1),[L,R]=(0,T.useState)(!1),[z,B]=(0,T.useState)(null),V=f(e=>e.setAiPreferences),H=(0,T.useCallback)(()=>{h().then(e=>{n(e);let t=f.getState().aiPreferences,r=e.storage!==`none`;x(r?e.provider:t.provider),C(r?e.model:t.model),O((r?e.baseUrl:t.baseUrl)??``),M(r?e.storage===`file`:t.remember),P(e.clis??[]),I(e.anthropicProfile===!0)}).catch(()=>y(!0))},[]);(0,T.useEffect)(H,[H]);let U=(0,T.useCallback)(e=>{x(e),C(t=>d(t,e))},[]),W=(0,T.useCallback)(()=>{R(!0),B(null),p({provider:b,model:S.trim()||void 0,baseUrl:w.trim()||void 0,key:k,remember:j}).then(t=>{n(t),A(``),V({provider:b,model:S.trim()||t.model,baseUrl:w.trim(),remember:j}),B(e(`settings.ai.saved`)),v()}).catch(e=>B(e instanceof Error?e.message:String(e))).finally(()=>R(!1))},[b,S,w,k,j,V,e]),G=(0,T.useCallback)(()=>{R(!0),B(null),m().then(e=>{n(e),A(``),v()}).catch(e=>B(e instanceof Error?e.message:String(e))).finally(()=>R(!1))},[]);if(r)return(0,E.jsx)(`p`,{className:`rounded-md border p-3 text-xs text-muted-foreground`,children:e(`settings.ai.unreachable`)});if(!t)return null;let K=t.fromEnvironment,q=b===`cli`||b===`anthropic-profile`;return(0,E.jsxs)(`div`,{className:`grid gap-3 rounded-md border p-3`,children:[(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings.ai.intro`)}),(0,E.jsx)(`p`,{className:`text-xs`,children:t.storage===`environment`?e(`settings.ai.configuredEnv`):t.storage===`file`?e(t.provider===`cli`||t.provider===`anthropic-profile`?`settings.ai.configuredChoice`:`settings.ai.configuredFile`,{path:t.path,provider:t.provider===`cli`?t.model:e(`settings.ai.profile`)}):t.storage===`session`?e(`settings.ai.configuredSession`):e(`settings.ai.none`)}),!K&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{className:`grid grid-cols-[1fr_220px] items-center gap-3`,children:[(0,E.jsx)(g,{htmlFor:`ai-provider`,className:`text-sm font-medium`,children:e(`settings.ai.provider`)}),(0,E.jsxs)(u,{value:b,onValueChange:e=>U(e),children:[(0,E.jsx)(s,{id:`ai-provider`,children:(0,E.jsx)(o,{})}),(0,E.jsxs)(c,{children:[(0,E.jsx)(l,{value:`anthropic`,children:`Anthropic`}),(0,E.jsx)(l,{value:`anthropic-profile`,children:e(`settings.ai.profile`)}),(0,E.jsx)(l,{value:`openai`,children:e(`settings.ai.openaiCompatible`)}),(0,E.jsx)(l,{value:`gemini`,children:`Google Gemini`}),(0,E.jsx)(l,{value:`cli`,children:e(`settings.ai.cli`)})]})]})]}),b===`cli`?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings.ai.cliHint`)}),N.length===0?(0,E.jsx)(`p`,{className:`rounded-md border p-2 text-xs text-muted-foreground`,children:e(`settings.ai.cliNone`)}):(0,E.jsxs)(`div`,{className:`grid grid-cols-[1fr_220px] items-center gap-3`,children:[(0,E.jsx)(g,{htmlFor:`ai-cli`,className:`text-sm font-medium`,children:e(`settings.ai.cliCommand`)}),(0,E.jsxs)(u,{value:N.includes(S)?S:N[0],onValueChange:C,children:[(0,E.jsx)(s,{id:`ai-cli`,children:(0,E.jsx)(o,{})}),(0,E.jsx)(c,{children:N.map(e=>(0,E.jsx)(l,{value:e,children:e},e))})]})]})]}):(0,E.jsxs)(`div`,{className:`grid gap-3`,children:[b===`anthropic-profile`&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings.ai.profileHint`)}),!F&&(0,E.jsx)(`p`,{className:`rounded-md border p-2 text-xs text-muted-foreground`,children:e(`settings.ai.profileNone`)})]}),(0,E.jsxs)(`div`,{className:`grid grid-cols-[1fr_220px] items-center gap-3`,children:[(0,E.jsx)(g,{htmlFor:`ai-model`,className:`text-sm font-medium`,children:e(`settings.ai.model`)}),(0,E.jsx)(_,{id:`ai-model`,value:S,onChange:e=>C(e.target.value),spellCheck:!1,...D})]})]}),b===`openai`&&(0,E.jsxs)(`div`,{className:`grid grid-cols-[1fr_220px] items-center gap-3`,children:[(0,E.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,E.jsx)(g,{htmlFor:`ai-base-url`,className:`text-sm font-medium`,children:e(`settings.ai.baseUrl`)}),(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`settings.ai.baseUrlHint`)})]}),(0,E.jsx)(_,{id:`ai-base-url`,value:w,onChange:e=>O(e.target.value),placeholder:`https://api.openai.com/v1`,spellCheck:!1,...D})]}),q||(0,E.jsxs)(`div`,{className:`grid gap-1`,children:[(0,E.jsx)(g,{htmlFor:`ai-key`,className:`text-sm font-medium`,children:e(`settings.ai.key`)}),(0,E.jsx)(_,{id:`ai-key`,type:`password`,value:k,onChange:e=>A(e.target.value),spellCheck:!1,placeholder:t.configured?`••••••••`:``,...D,autoComplete:`new-password`}),(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`settings.ai.keyHint`)})]}),q||(0,E.jsxs)(`label`,{htmlFor:`ai-remember`,className:`flex cursor-pointer items-start gap-3 rounded-md border p-3 hover:bg-accent/40`,children:[(0,E.jsx)(`input`,{id:`ai-remember`,type:`checkbox`,checked:j,onChange:e=>M(e.target.checked),className:`mt-0.5 size-4 accent-primary`}),(0,E.jsxs)(`span`,{className:`grid flex-1 gap-0.5`,children:[(0,E.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings.ai.remember`)}),(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`settings.ai.rememberHint`,{path:t.path})})]})]}),(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(a,{size:`sm`,onClick:W,disabled:L||(b===`cli`?N.length===0:!q&&!k.trim()),children:e(`settings.ai.save`)}),t.configured&&(0,E.jsx)(a,{size:`sm`,variant:`ghost`,onClick:G,disabled:L,children:e(`settings.ai.forget`)}),z&&(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:z})]})]})]})}function k(){let e=n(e=>e.activeDialog),t=n(e=>e.closeDialog),{t:r}=i();return(0,E.jsx)(w,{open:e===`ai-settings`,onOpenChange:e=>{e||t()},children:(0,E.jsxs)(x,{className:`sm:max-w-[560px]`,children:[(0,E.jsxs)(y,{children:[(0,E.jsx)(S,{children:r(`settings.ai.title`)}),(0,E.jsx)(C,{children:r(`settings.ai.description`)})]}),(0,E.jsx)(O,{}),(0,E.jsx)(b,{children:(0,E.jsx)(a,{onClick:t,children:r(`settings.done`)})})]})})}export{k as AiSettingsDialog};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{h as t,n,t as r}from"./ui-store-5IssrgmG.js";import{l as i,m as a,t as o}from"./button-B2EsmMJs.js";import{a as s,i as c,n as l,r as u,t as d}from"./select-DEqoX1sU.js";import{t as f}from"./connection-store-B85kbJpB.js";import{E as p,O as m,T as h,a as g,f as _,m as v}from"./tunneling-B7lL9I14.js";import{n as y}from"./query-store-BqBiylGA.js";import{S as b,d as x,g as S,i as C,l as w,r as T}from"./database-BSXLJRzV.js";import{n as E,t as D}from"./dbms-BwnatOMe.js";import{A as O,B as k,C as A,F as j,L as M,S as N,a as P,b as F,c as I,ct as ee,i as te,k as L,l as R,n as ne,o as z,r as re,s as B,u as V,v as ie,x as H,y as ae,yt as oe}from"./index-Tw24-4of.js";import{a as se,i as ce,n as le,o as ue,t as de}from"./dialog-FBpgH0QJ.js";var U=e(t(),1),W=new Set([`postgres:`,`postgresql:`]);function G(e){let t=e.trim().replace(/^psql\s+(['"])?/,``).replace(/['"]$/,``);if(!/^postgres(ql)?:\/\//i.test(t))return null;let n;try{n=new URL(t)}catch{return null}if(!W.has(n.protocol.toLowerCase())||!n.hostname)return null;let r=e=>{try{return decodeURIComponent(e)}catch{return e}},i={host:n.hostname};n.port&&(i.port=Number(n.port)),n.username&&(i.user=r(n.username)),n.password&&(i.pass=r(n.password));let a=r(n.pathname.replace(/^\//,``));return a&&(i.database=a),i}var K=new Set([`localhost`,`127.0.0.1`,`[::1]`,`::1`,`0.0.0.0`]);async function q(e,t){let n;try{let t=new URL(e);if(!K.has(t.hostname.toLowerCase()))return[];n=t.origin}catch{return[]}try{let e=await fetch(`${n}/cdn-cgi/local/explorer/api/d1/database`,{signal:t});if(!e.ok)return[];let r=await e.json(),i=new Map;for(let e of r.result??[])e.uuid&&i.set(e.uuid,{name:e.name??e.uuid,id:e.uuid});return[...i.values()]}catch{return[]}}var J=i(),Y=[`utf8`,`utf8mb4`,`latin1`,`ascii`,`euckr`,`sjis`,`big5`],X={enabled:!1,host:``,port:22,user:``,auth:`key`};function Z({label:e,htmlFor:t,children:n}){return(0,J.jsxs)(`div`,{className:`grid grid-cols-[120px_minmax(0,1fr)] items-center gap-2`,children:[(0,J.jsx)(I,{htmlFor:t,children:e}),n]})}function fe({value:e,onChange:t}){let{t:n}=a();function r(n,r){t({...e,[n]:r})}let[i,f]=(0,U.useState)([]),h=e.dbms===`d1`?e.devUrl??``:``;(0,U.useEffect)(()=>{if(!h){f([]);return}let e=new AbortController,t=setTimeout(()=>{q(h,e.signal).then(f)},300);return()=>{clearTimeout(t),e.abort()}},[h]);let g=e.dbms===`sqlite`,_=e.transport??`browser`,v=g&&_===`browser`,y=p.has(e.dbms),b=e.dbms===`d1`,x=e.dbms===`do`,S=D.find(t=>t.id===e.dbms)?.capabilities,C=e.ssh??X,[T,E]=(0,U.useState)(``),A=T.trim()===``?`empty`:G(T)?`applied`:`invalid`,j=e.dbms===`supabase`&&e.port===6543;function N(n){E(n);let r=G(n);r&&t({...e,host:r.host??e.host,port:r.port??D.find(t=>t.id===e.dbms)?.defaultPort??e.port,user:r.user??e.user,pass:r.pass??e.pass,database:r.database??e.database})}function P(n){t({...e,ssh:{...C,...n}})}async function F(e){e&&P({privateKey:await e.text(),privateKeyName:e.name})}return(0,J.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,J.jsx)(Z,{label:n(`connection.form.hostName`),htmlFor:`conn-hostName`,children:(0,J.jsx)(R,{id:`conn-hostName`,placeholder:n(`connection.form.hostNamePlaceholder`),value:e.hostName,onChange:e=>r(`hostName`,e.target.value)})}),(0,J.jsx)(Z,{label:n(`connection.form.dataSource`),children:(0,J.jsxs)(d,{value:e.dbms,onValueChange:n=>{let r=D.find(e=>e.id===n);if(!r)return;let i=r.id,a=p.has(i)||i===`d1`||i===`do`;E(``),t({...e,dbms:i,transactionMode:r.capabilities.transactions?e.transactionMode:`auto`,port:r.defaultPort??e.port,host:a&&e.host===`localhost`?``:!a&&e.host===``?`localhost`:e.host,user:a||y||b||x?B(i):e.user,devUrl:i===`do`?e.devUrl||`http://localhost:8787`:e.devUrl,database:e.database&&!a&&!y&&!b&&!x?e.database:z(i)??e.database})},children:[(0,J.jsx)(c,{id:`conn-dbms`,className:`w-full`,children:(0,J.jsx)(s,{})}),(0,J.jsx)(l,{children:D.map(e=>(0,J.jsx)(u,{value:e.id,children:(0,J.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(V,{dbms:e.id}),e.label]})},e.id))})]})}),y&&(0,J.jsx)(Z,{label:n(`connection.form.connectionString`),htmlFor:`conn-uri`,children:(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(R,{id:`conn-uri`,type:`password`,autoComplete:`new-password`,spellCheck:!1,className:`font-mono text-xs`,placeholder:e.dbms===`neon`?`postgresql://neondb_owner:npg_…@ep-….neon.tech/neondb?sslmode=require`:`postgresql://postgres.[ref]:[password]@aws-0-….pooler.supabase.com:5432/postgres`,value:T,onChange:e=>N(e.target.value)}),(0,J.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed ${A===`invalid`?`text-destructive`:`text-muted-foreground`}`,children:n(A===`invalid`?`connection.form.connectionStringInvalid`:A===`applied`?`connection.form.connectionStringApplied`:e.dbms===`neon`?`connection.form.neonHint`:`connection.form.supabaseHint`)})]})}),g&&(0,J.jsxs)(Z,{label:n(`connection.form.openVia`),children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,J.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm cursor-pointer`,children:[(0,J.jsx)(`input`,{type:`radio`,name:`transport`,value:`browser`,checked:_===`browser`,onChange:()=>r(`transport`,`browser`),className:`accent-primary`}),n(`connection.form.viaBrowser`)]}),(0,J.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm cursor-pointer`,children:[(0,J.jsx)(`input`,{type:`radio`,name:`transport`,value:`tunnel`,checked:_===`tunnel`,onChange:()=>r(`transport`,`tunnel`),className:`accent-primary`}),n(`connection.form.viaAgent`)]})]}),(0,J.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(_===`browser`?`connection.form.viaBrowserHint`:`connection.form.viaAgentHint`)})]}),v?(0,J.jsx)(Z,{label:n(`connection.form.databaseFile`),children:(0,J.jsxs)(`div`,{className:`min-w-0 text-xs text-muted-foreground leading-relaxed`,children:[e.file?(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,J.jsx)(`span`,{className:`min-w-0 break-all text-foreground`,title:e.file,children:e.file}),(0,J.jsx)(o,{type:`button`,variant:`outline`,size:`sm`,className:`h-6 shrink-0 px-2 text-xs`,onClick:()=>{w(e.id),r(`file`,``)},children:n(`connection.form.changeFile`)})]}):(0,J.jsx)(`p`,{children:n(`connection.form.filePickerHint`)}),(0,J.jsx)(`p`,{className:`mt-1`,children:n(`connection.form.fileRememberedHint`)})]})}):null,!v&&(0,J.jsx)(Z,{label:n(`connection.form.authToken`),htmlFor:`conn-authToken`,children:(0,J.jsx)(R,{id:`conn-authToken`,type:`password`,autoComplete:`new-password`,placeholder:n(`connection.form.authTokenPlaceholder`),value:e.authToken,onChange:e=>r(`authToken`,e.target.value.trim())})}),v?null:x?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{label:n(`connection.form.doDevUrl`),htmlFor:`conn-do-url`,children:(0,J.jsx)(R,{id:`conn-do-url`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`http://localhost:8787`,value:e.devUrl??``,onChange:e=>r(`devUrl`,e.target.value.trim())})}),(0,J.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.doHint`)}),(0,J.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.doLimitsHint`)})]}):b?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{label:n(`connection.form.d1DevUrl`),htmlFor:`conn-d1-dev`,children:(0,J.jsx)(R,{id:`conn-d1-dev`,autoComplete:`off`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`http://localhost:8787`,value:e.devUrl??``,onChange:e=>r(`devUrl`,e.target.value.trim())})}),(0,J.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1DevUrlHint`)}),(0,J.jsx)(Z,{label:n(`connection.form.d1AccountId`),htmlFor:`conn-d1-account`,children:(0,J.jsx)(R,{id:`conn-d1-account`,autoComplete:`off`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`023e105f4ecef8ad9ca31a8372d0c353`,value:e.accountId??``,onChange:e=>r(`accountId`,e.target.value.trim())})}),(0,J.jsx)(Z,{label:n(`connection.form.d1DatabaseId`),htmlFor:`conn-d1-database`,children:i.length>0?(0,J.jsxs)(d,{value:e.databaseId??``,onValueChange:e=>r(`databaseId`,e),children:[(0,J.jsx)(c,{id:`conn-d1-database`,children:(0,J.jsx)(s,{placeholder:n(`connection.form.d1PickDatabase`)})}),(0,J.jsx)(l,{children:i.map(e=>(0,J.jsxs)(u,{value:e.id,children:[e.name,` · `,e.id]},e.id))})]}):(0,J.jsx)(R,{id:`conn-d1-database`,autoComplete:`off`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`,value:e.databaseId??``,onChange:e=>r(`databaseId`,e.target.value.trim())})}),(0,J.jsx)(Z,{label:n(`connection.form.d1ApiToken`),htmlFor:`conn-pass`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(R,{id:`conn-pass`,type:`password`,autoComplete:`new-password`,value:e.pass,onChange:e=>r(`pass`,e.target.value.trim())}),(0,J.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs whitespace-nowrap cursor-pointer`,title:n(`connection.form.savePasswordHint`),children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:e.savePassword??!0,onChange:e=>r(`savePassword`,e.target.checked)}),n(`connection.form.savePassword`)]})]})}),(0,J.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1Hint`)}),(0,J.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1LimitsHint`)})]}):g?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{label:n(`connection.form.databaseFile`),htmlFor:`conn-file`,children:(0,J.jsx)(R,{id:`conn-file`,placeholder:n(`connection.form.filePathPlaceholder`),value:e.file??``,onChange:e=>r(`file`,e.target.value)})}),(0,J.jsx)(Z,{label:n(`connection.form.createIfMissing`),htmlFor:`conn-create`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`input`,{id:`conn-create`,type:`checkbox`,checked:e.createIfMissing??!1,onChange:e=>r(`createIfMissing`,e.target.checked),className:`size-4 accent-primary cursor-pointer`}),(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.createIfMissingHint`)})]})})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{label:n(`connection.form.host`),htmlFor:`conn-host`,children:(0,J.jsx)(R,{id:`conn-host`,placeholder:e.dbms===`neon`?`ep-….aws.neon.tech`:e.dbms===`supabase`?`aws-0-….pooler.supabase.com`:`localhost`,value:e.host,onChange:e=>r(`host`,e.target.value)})}),(0,J.jsx)(Z,{label:n(`connection.form.port`),htmlFor:`conn-port`,children:(0,J.jsx)(R,{id:`conn-port`,type:`number`,value:e.port,onChange:t=>r(`port`,Number(t.target.value)||D.find(t=>t.id===e.dbms)?.defaultPort||3306)})}),j&&(0,J.jsx)(`p`,{className:`col-start-2 rounded-md border border-yellow-500/40 bg-yellow-500/10 px-2 py-1.5 text-xs leading-relaxed text-foreground`,children:n(`connection.form.supabasePoolerWarning`)}),(m(e.dbms)||e.dbms===`mssql`||e.dbms===`oracle`)&&(0,J.jsx)(Z,{label:e.dbms===`oracle`?n(`connection.form.serviceName`):n(`connection.form.database`),htmlFor:`conn-database`,children:(0,J.jsx)(R,{id:`conn-database`,placeholder:z(e.dbms),value:e.database??``,onChange:e=>r(`database`,e.target.value.trim())})}),(0,J.jsx)(Z,{label:n(`connection.form.user`),htmlFor:`conn-user`,children:(0,J.jsx)(R,{id:`conn-user`,autoComplete:`off`,placeholder:B(e.dbms),value:e.user,onChange:e=>r(`user`,e.target.value)})}),(0,J.jsx)(Z,{label:n(`connection.form.password`),htmlFor:`conn-pass`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(R,{id:`conn-pass`,type:`password`,autoComplete:`new-password`,value:e.pass,onChange:e=>r(`pass`,e.target.value)}),(0,J.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs whitespace-nowrap cursor-pointer`,title:n(`connection.form.savePasswordHint`),children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:e.savePassword??!0,onChange:e=>r(`savePassword`,e.target.checked)}),n(`connection.form.savePassword`)]})]})}),y&&(0,J.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.managedTlsHint`)}),!y&&e.dbms!==`oracle`&&(0,J.jsx)(Z,{label:n(`connection.form.tls`),children:(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,J.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:e.ssl??!1,onChange:e=>r(`ssl`,e.target.checked),className:`size-4 accent-primary`}),n(`connection.form.tlsEnable`)]}),(0,J.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer ${e.ssl?``:`opacity-50`}`,title:n(`connection.form.tlsVerifyHint`),children:[(0,J.jsx)(`input`,{type:`checkbox`,disabled:!e.ssl,checked:e.sslVerify??!1,onChange:e=>r(`sslVerify`,e.target.checked),className:`size-4 accent-primary`}),n(`connection.form.tlsVerify`)]})]})}),!y&&(0,J.jsx)(Z,{label:n(`connection.form.charset`),children:(0,J.jsxs)(d,{value:e.charset,onValueChange:e=>r(`charset`,e),children:[(0,J.jsx)(c,{className:`w-full`,children:(0,J.jsx)(s,{})}),(0,J.jsx)(l,{children:Y.map(e=>(0,J.jsx)(u,{value:e,children:e},e))})]})})]}),!g&&!y&&!b&&!x&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`mt-1 flex items-center border-t pt-3 text-xs font-medium text-muted-foreground`,children:[n(`connection.form.ssh`),(0,J.jsx)(k,{className:`ml-2`})]}),(0,J.jsx)(Z,{label:n(`connection.form.sshTunnel`),htmlFor:`conn-ssh`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`input`,{id:`conn-ssh`,type:`checkbox`,checked:C.enabled,onChange:e=>{(!e.target.checked||M(`ssh_tunnel`))&&P({enabled:e.target.checked})},className:`size-4 accent-primary cursor-pointer`}),(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.sshTunnelHint`)})]})}),C.enabled&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{label:n(`connection.form.sshHost`),htmlFor:`conn-ssh-host`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(R,{id:`conn-ssh-host`,placeholder:n(`connection.form.sshHostPlaceholder`),value:C.host,onChange:e=>P({host:e.target.value.trim()})}),(0,J.jsx)(R,{"aria-label":n(`connection.form.sshPort`),type:`number`,className:`w-24 shrink-0`,value:C.port,onChange:e=>P({port:Number(e.target.value)||22})})]})}),(0,J.jsx)(Z,{label:n(`connection.form.sshUser`),htmlFor:`conn-ssh-user`,children:(0,J.jsx)(R,{id:`conn-ssh-user`,placeholder:n(`connection.form.sshUserPlaceholder`),value:C.user,onChange:e=>P({user:e.target.value.trim()})})}),(0,J.jsx)(Z,{label:n(`connection.form.sshAuth`),children:(0,J.jsxs)(d,{value:C.auth,onValueChange:e=>P({auth:e}),children:[(0,J.jsx)(c,{className:`w-full`,children:(0,J.jsx)(s,{})}),(0,J.jsxs)(l,{children:[(0,J.jsx)(u,{value:`key`,children:n(`connection.form.sshAuthKey`)}),(0,J.jsx)(u,{value:`password`,children:n(`connection.form.sshAuthPassword`)}),(0,J.jsx)(u,{value:`agent`,children:n(`connection.form.sshAuthAgent`)})]})]})}),C.auth===`password`&&(0,J.jsx)(Z,{label:n(`connection.form.sshPassword`),htmlFor:`conn-ssh-pass`,children:(0,J.jsx)(R,{id:`conn-ssh-pass`,type:`password`,autoComplete:`new-password`,value:C.password??``,onChange:e=>P({password:e.target.value})})}),C.auth===`key`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{label:n(`connection.form.sshKey`),htmlFor:`conn-ssh-key`,children:(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`input`,{id:`conn-ssh-key`,type:`file`,className:`hidden`,onChange:e=>{F(e.target.files?.[0]),e.target.value=``}}),(0,J.jsx)(o,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 shrink-0 px-2 text-xs`,onClick:()=>document.getElementById(`conn-ssh-key`)?.click(),children:C.privateKey?n(`connection.form.changeFile`):n(`connection.form.sshKeyPick`)}),(0,J.jsx)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,title:C.privateKeyName,children:C.privateKey?C.privateKeyName||n(`connection.form.sshKeyLoaded`):n(`connection.form.sshKeyHint`)})]})}),(0,J.jsx)(Z,{label:n(`connection.form.sshPassphrase`),htmlFor:`conn-ssh-passphrase`,children:(0,J.jsx)(R,{id:`conn-ssh-passphrase`,type:`password`,autoComplete:`new-password`,placeholder:n(`connection.form.sshPassphrasePlaceholder`),value:C.passphrase??``,onChange:e=>P({passphrase:e.target.value})})})]}),C.auth===`agent`&&(0,J.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshAuthAgentHint`)}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshTargetHint`)}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshSecretsHint`)})]})]}),(0,J.jsx)(Z,{label:n(`connection.form.autoConnection`),htmlFor:`conn-auto`,children:(0,J.jsx)(`div`,{className:`flex items-center`,children:(0,J.jsx)(`input`,{id:`conn-auto`,type:`checkbox`,checked:e.autoConnection,onChange:e=>r(`autoConnection`,e.target.checked),className:`size-4 accent-primary cursor-pointer`})})}),(0,J.jsx)(`div`,{className:`mt-1 border-t pt-3 text-xs font-medium text-muted-foreground`,children:n(`connection.form.safety`)}),(0,J.jsx)(Z,{label:n(`connection.form.environment`),children:(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[L.map(t=>{let n=(e.environmentColor??`none`)===t.id;return(0,J.jsx)(`button`,{type:`button`,title:O(t.id),"aria-label":O(t.id),"aria-pressed":n,onClick:()=>r(`environmentColor`,t.id),className:`size-6 rounded-full border-2 transition-transform ${n?`scale-110 border-foreground`:`border-transparent hover:scale-105`}`,style:{background:t.id===`none`?`repeating-linear-gradient(45deg, transparent, transparent 3px, var(--muted-foreground) 3px, var(--muted-foreground) 4px)`:t.hex}},t.id)}),(0,J.jsx)(`span`,{className:`ml-1 text-xs text-muted-foreground`,children:n(`connection.form.environmentHint`)})]})}),(0,J.jsx)(Z,{label:n(`connection.form.readOnly`),htmlFor:`conn-readonly`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`input`,{id:`conn-readonly`,type:`checkbox`,checked:e.readOnly??!1,onChange:e=>r(`readOnly`,e.target.checked),className:`size-4 accent-primary cursor-pointer`}),(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.readOnlyHint`)})]})}),S?.transactions!==!1&&(0,J.jsx)(Z,{label:n(`connection.form.transactions`),children:(0,J.jsxs)(d,{value:e.transactionMode??`auto`,onValueChange:e=>r(`transactionMode`,e),children:[(0,J.jsx)(c,{className:`w-full`,children:(0,J.jsx)(s,{})}),(0,J.jsxs)(l,{children:[(0,J.jsx)(u,{value:`auto`,children:n(`connection.form.txAuto`)}),(0,J.jsx)(u,{value:`manual`,children:n(`connection.form.txManual`)})]})]})})]})}function Q(){let{t:e}=a(),{activeDialog:t,closeDialog:i,showMessage:s}=n(),[c,l]=(0,U.useState)(!1),{savedConnections:u,addSavedConnection:d,updateSavedConnection:p,deleteSavedConnection:m,openConnection:w}=f(),D=r(`connect`)?.profileId,[O,k]=(0,U.useState)(()=>D??null),[M,I]=(0,U.useState)(()=>{let e=D?u.find(e=>e.id===D):void 0;return e?{...e}:null}),L=t===`connect`,[R,z]=(0,U.useState)(null),[B,W]=(0,U.useState)(null),G=j(e=>e.url),K=j(e=>e.token);(0,U.useEffect)(()=>{if(!L)return;let e=!1;return(async()=>{try{let t=await g();if(e||t.state!==`online`||!t.gateway){e||z(null);return}let n=await _();e||(z({name:n.gateway,profiles:n.profiles}),W(null))}catch(t){e||W(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[L,G,K]);function q(t){let r=u.find(e=>e.gatewayProfile===t.name);if(r){X(r);return}let i=re(t);d(i),X(i),n.getState().setFooterMessage(e(`connection.dialog.gatewayAdded`,{name:t.name}))}function Y(e){e||(i(),k(null),I(null))}function X(e){k(e.id),I({...e})}function Z(e){I(e),p(e.id,e)}function Q(){let e=P();d(e),k(e.id),I(e)}function pe(){O&&(m(O),k(null),I(null))}let[me,$]=(0,U.useState)(!1),he=y(e=>e.addQueryTab);function ge(t){let n=f.getState().activeConnections.some(e=>e.id===t.id);if(w(t),b.getState().removeTree(t.id),n){i(),k(null),I(null);return}he(t.id,{id:`tab-${Date.now()}`,title:e(`connection.dialog.firstQueryTab`),query:``,database:``,isExecuting:!1,results:[],error:null,executionTime:null}),i(),k(null),I(null)}async function _e(t){let r=await T(t.id,{interactive:!0});if(!r)return;let i={...t,file:r.fileName,serverConnectionId:r.connectionId};p(t.id,{file:r.fileName}),ge(i),f.getState().setFileDetached(t.id,r.fileDetached),r.restoredUnsaved?n.getState().setFooterMessage(e(r.diskChanged?`connection.dialog.restoredUnsavedDiskChanged`:`connection.dialog.restoredUnsaved`,{file:r.fileName})):r.wal&&!r.walApplied?n.getState().setFooterMessage(e(`connection.dialog.walPending`,{file:r.fileName})):r.walApplied&&n.getState().setFooterMessage(e(`connection.dialog.walApplied`,{file:r.fileName}))}async function ve(t,r){try{return await r(t)}catch(i){let a=v(i);if(!a||!(`ssh`in t)||!t.ssh||!await n.getState().requestDestructiveConfirm({title:e(`connection.dialog.hostKeyTitle`),description:e(`connection.dialog.hostKeyDescription`,a),confirmLabel:e(`connection.dialog.hostKeyAccept`)}))throw i;return r({...t,ssh:{...t.ssh,acceptHostKey:a.fingerprint}})}}async function ye(){if(M){$(!0);try{if(x(M)===`browser`){await _e(M);return}let t=await ve(h(M),e=>C(e,M.authToken||void 0));t.success?ge({...M,serverConnectionId:t.connectionId}):s({tone:`error`,title:e(`connection.dialog.connectFailedTitle`),description:t.message??e(`connection.dialog.unknownError`)})}catch(t){s({tone:`error`,title:e(`connection.dialog.connectFailedTitle`),description:t instanceof Error?t.message:String(t)})}finally{$(!1)}}}async function be(){if(M){if(x(M)===`browser`){s({tone:`info`,title:e(`connection.dialog.testConnection`),description:e(`connection.dialog.browserTestHint`)});return}l(!0);try{let t=await ve(h(M),e=>S(e,M.authToken||void 0));t.success?s({tone:`success`,title:e(`connection.dialog.testSuccess`),description:e(`connection.dialog.testSuccessDescription`)}):s({tone:`error`,title:e(`connection.dialog.testFailedTitle`),description:t.message??e(`connection.dialog.unknownError`)})}catch(t){s({tone:`error`,title:e(`connection.dialog.testFailedTitle`),description:t instanceof Error?t.message:String(t)})}finally{l(!1)}}}return(0,J.jsx)(de,{open:L,onOpenChange:Y,children:(0,J.jsxs)(le,{className:`sm:max-w-[1100px] h-[85vh] max-h-[85vh] flex flex-col`,children:[(0,J.jsx)(se,{children:(0,J.jsx)(ue,{children:e(`connection.dialog.title`)})}),(0,J.jsxs)(`p`,{className:`flex items-start gap-2 rounded-md border border-catppuccin-green/40 bg-catppuccin-green/10 px-3 py-2 text-xs leading-relaxed text-foreground`,children:[(0,J.jsx)(oe,{className:`mt-0.5 size-4 shrink-0 text-catppuccin-green`,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:e(`connection.dialog.privacy`)})]}),(0,J.jsxs)(`div`,{className:`flex flex-1 gap-4 overflow-hidden min-h-0`,children:[(0,J.jsxs)(`div`,{className:`w-[460px] shrink-0 border rounded-md overflow-hidden flex flex-col`,children:[(R||B)&&(0,J.jsxs)(`div`,{className:`border-b p-2 text-xs space-y-1 max-h-40 overflow-auto`,children:[(0,J.jsxs)(`p`,{className:`font-medium`,children:[e(`connection.dialog.gatewayTitle`),R?` — ${R.name}`:``]}),B&&(0,J.jsx)(`p`,{className:`text-destructive`,children:e(`connection.dialog.gatewayLoadFailed`,{error:B})}),R?.profiles.map(t=>(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 truncate`,children:[(0,J.jsx)(V,{dbms:ne[t.driver],className:`size-3.5`}),(0,J.jsx)(`span`,{className:`truncate`,children:t.name}),(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,t.readOnly?e(`connection.dialog.gatewayReadOnly`):e(`connection.dialog.gatewayWritable`),`)`]})]}),(0,J.jsx)(o,{size:`sm`,variant:`outline`,className:`h-6 px-2 text-xs`,onClick:()=>q(t),children:e(`connection.dialog.gatewayAdd`)})]},t.name))]}),(0,J.jsx)(ee,{className:`h-full`,children:(0,J.jsxs)(ie,{className:`table-fixed`,children:[(0,J.jsx)(N,{children:(0,J.jsxs)(A,{children:[(0,J.jsx)(H,{className:`w-[32%]`,children:e(`connection.dialog.colHostName`)}),(0,J.jsx)(H,{className:`w-[40%]`,children:e(`connection.dialog.colTarget`)}),(0,J.jsx)(H,{className:`w-[28%]`,children:e(`connection.dialog.colDbms`)})]})}),(0,J.jsx)(ae,{children:u.length===0?(0,J.jsx)(A,{children:(0,J.jsx)(F,{colSpan:3,className:`text-center text-muted-foreground`,children:e(`connection.dialog.noSaved`)})}):u.map(t=>(0,J.jsxs)(A,{"data-state":O===t.id?`selected`:void 0,className:`cursor-pointer`,onClick:()=>X(t),onDoubleClick:()=>{X(t),ye()},children:[(0,J.jsx)(F,{className:`truncate font-medium`,title:t.hostName,children:t.hostName||e(`connection.dialog.unnamed`)}),(0,J.jsx)(F,{className:`truncate`,title:t.dbms===`sqlite`?t.file:t.dbms===`d1`?t.databaseId:t.dbms===`do`?t.devUrl:`${t.user}@${t.host}:${t.port}`,children:t.dbms===`sqlite`?t.file||(x(t)===`browser`?e(`connection.dialog.pickOnConnect`):e(`connection.dialog.noFile`)):t.dbms===`d1`?t.databaseId||`—`:t.dbms===`do`?t.devUrl||`—`:`${t.user}@${t.host}:${t.port}`}),(0,J.jsx)(F,{className:`truncate`,title:E(t.dbms).label,children:(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(V,{dbms:t.dbms,className:`size-3.5`}),(0,J.jsx)(`span`,{className:`truncate`,children:E(t.dbms).label})]})})]},t.id))})]})})]}),(0,J.jsx)(`div`,{className:`flex-1 border rounded-md overflow-auto`,children:M?(0,J.jsxs)(J.Fragment,{children:[x(M)!==`browser`&&(0,J.jsx)(`div`,{className:`p-4 pb-0`,children:(0,J.jsx)(te,{})}),M.gatewayProfile?(0,J.jsxs)(`div`,{className:`p-4 space-y-2 text-sm`,children:[(0,J.jsxs)(`p`,{className:`font-medium flex items-center gap-2`,children:[(0,J.jsx)(V,{dbms:M.dbms,className:`size-4`}),M.hostName]}),(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:e(`connection.dialog.gatewayProfileHint`,{name:M.gatewayProfile})}),(0,J.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[M.readOnly?e(`connection.dialog.gatewayReadOnly`):e(`connection.dialog.gatewayWritable`),M.database?` · ${M.database}`:``]})]}):(0,J.jsx)(fe,{value:M,onChange:Z})]}):(0,J.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:e(`connection.dialog.selectPrompt`)})})]}),(0,J.jsxs)(ce,{className:`sm:justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(o,{variant:`outline`,onClick:Q,children:e(`connection.dialog.addNew`)}),(0,J.jsx)(o,{variant:`destructive`,onClick:pe,disabled:!O,children:e(`connection.dialog.delete`)})]}),(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(o,{variant:`outline`,onClick:be,disabled:!M||c,children:e(`connection.dialog.testConnection`)}),(0,J.jsx)(o,{onClick:ye,disabled:!M||me,children:e(`connection.dialog.connect`)}),(0,J.jsx)(o,{variant:`outline`,onClick:()=>Y(!1),children:e(`connection.dialog.close`)})]})]})]})})}export{Q as ConnectDialog};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{h as t,n,t as r}from"./ui-store-5IssrgmG.js";import{l as i,m as a,t as o}from"./button-B2EsmMJs.js";import{t as s}from"./connection-store-B85kbJpB.js";import{a as c}from"./database-BSXLJRzV.js";import{n as l}from"./engine-DjP-Sw-S.js";import{l as u,m as d}from"./query-execution-BeDEQ-3M.js";import{G as f,W as p,c as m,l as h}from"./index-Tw24-4of.js";import{a as g,i as _,n as v,o as y,t as b}from"./dialog-FBpgH0QJ.js";var x=e(t(),1),S=i();function C(){let{t:e}=a(),{activeDialog:t,closeDialog:i}=n(),C=r(`copy-database`),w=t===`copy-database`,T=C?.database??``,[E,D]=(0,x.useState)(``),[O,k]=(0,x.useState)(`structure_data`),[A,j]=(0,x.useState)(null),[M,N]=(0,x.useState)(null);function P(e){e||(i(),N(null),j(null),D(``),k(`structure_data`))}async function F(){let t=s.getState().activeConnectionId,n=E.trim();if(!t||!n||!T)return;N(null);let r=l(t),i=s.getState().activeConnections.find(e=>e.id===t);if(i?.serverConnectionId)try{j(e(`database.copy.creating`,{database:n})),await u(t,r.getQuery(`CREATE_DATABASE`,n,`utf8mb4`,`utf8mb4_general_ci`));let a=c(i.serverConnectionId),o=await r.introspect.listTables(a,T);for(let[r,i]of o.entries()){j(e(`database.copy.copying`,{table:i.name,index:r+1,total:o.length}));let a={connectionId:t,database:T,table:i.name},s={connectionId:t,database:n,table:i.name},c=await p(a,s);await f({source:a,target:s,mode:O,onConflict:`abort`,createSql:l(t).ddl.createTable(c)})}await d(t),P(!1)}catch(e){N(e instanceof Error?e.message:String(e))}finally{j(null)}}return(0,S.jsx)(b,{open:w,onOpenChange:P,children:(0,S.jsxs)(v,{className:`sm:max-w-[450px]`,children:[(0,S.jsx)(g,{children:(0,S.jsx)(y,{children:e(`database.copy.title`)})}),(0,S.jsxs)(`div`,{className:`space-y-4`,children:[(0,S.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,S.jsx)(m,{children:e(`database.copy.source`)}),(0,S.jsx)(h,{value:T,disabled:!0})]}),(0,S.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,S.jsx)(m,{htmlFor:`target-db-name`,children:e(`database.copy.target`)}),(0,S.jsx)(h,{id:`target-db-name`,value:E,onChange:e=>D(e.target.value),placeholder:e(`database.copy.targetPlaceholder`)})]}),(0,S.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,S.jsx)(m,{children:e(`database.copy.options`)}),(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,S.jsx)(`input`,{type:`radio`,name:`copy-option`,value:`structure_data`,checked:O===`structure_data`,onChange:()=>k(`structure_data`)}),e(`database.copy.structureAndData`)]}),(0,S.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,S.jsx)(`input`,{type:`radio`,name:`copy-option`,value:`structure_only`,checked:O===`structure_only`,onChange:()=>k(`structure_only`)}),e(`database.copy.structureOnly`)]})]})]})]}),A&&(0,S.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:A}),M&&(0,S.jsx)(`p`,{className:`px-1 text-xs text-destructive leading-relaxed`,children:M}),(0,S.jsxs)(_,{children:[(0,S.jsx)(o,{variant:`outline`,onClick:()=>P(!1),children:e(`database.copy.cancel`)}),(0,S.jsx)(o,{onClick:()=>void F(),disabled:!E.trim()||A!==null,children:e(`database.copy.copy`)})]})]})})}export{C as CopyDatabaseDialog};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{h as t,n,t as r}from"./ui-store-5IssrgmG.js";import{l as i,m as a,t as o}from"./button-B2EsmMJs.js";import{a as s,i as c,n as l,r as u,t as d}from"./select-DEqoX1sU.js";import{t as ee}from"./connection-store-B85kbJpB.js";import{a as f}from"./database-BSXLJRzV.js";import{n as p}from"./engine-DjP-Sw-S.js";import{t as te}from"./query-execution-BeDEQ-3M.js";import{G as ne,W as re,c as m,j as h,l as g}from"./index-Tw24-4of.js";import{a as ie,i as ae,n as oe,o as se,t as ce}from"./dialog-FBpgH0QJ.js";var _=e(t(),1),v=i(),y=e=>e instanceof Error?e.message:String(e),b=e=>e.hostName||e.host||e.file||e.id,le=`w-full rounded border bg-background px-2 py-1 text-xs font-mono outline-none focus:ring-1 focus:ring-primary disabled:opacity-50 min-h-[160px] resize-y`;function x(){let{t:e}=a(),t=n(e=>e.activeDialog),i=n(e=>e.closeDialog),x=n(e=>e.showMessage),S=r(`copy-table`),C=ee(e=>e.activeConnections),w=t===`copy-table`,T=S?.connectionId??``,E=String(S?.metadata?.database??``),D=S?.nodeText??``,O=C.find(e=>e.id===T),ue=C.filter(e=>e.serverConnectionId),[k,de]=(0,_.useState)(T),[A,j]=(0,_.useState)([]),[M,N]=(0,_.useState)(``),[P,F]=(0,_.useState)(D),[I,L]=(0,_.useState)(`structure_data`),[R,z]=(0,_.useState)(`abort`),[B,V]=(0,_.useState)(``),[H,U]=(0,_.useState)(null),[W,G]=(0,_.useState)(null),[K,q]=(0,_.useState)(null),[J,Y]=(0,_.useState)(!1),X=(0,_.useRef)(null),Z=C.find(e=>e.id===k),Q=Z?p(k):null,fe=!!O&&!!Z&&p(T).id===Q?.id;(0,_.useEffect)(()=>{if(!w||!Z?.serverConnectionId)return;let e=!1,t=p(k),n=f(Z.serverConnectionId);return(async()=>{j([]);try{let r=await t.introspect.listDatabases(n);if(e)return;j(r);let i=k===T,a=i||r.includes(E)?E:r[0]??``;N(a),F(e=>i&&a===E&&e===D?`${D}_copy`:e)}catch(t){e||q(y(t))}})(),()=>{e=!0}},[w,k]),(0,_.useEffect)(()=>{if(!w||!Z||!M||!P.trim()||!O)return;let e=!1;return(async()=>{U(null);try{let t=await re({connectionId:T,database:E,table:D},{connectionId:k,database:M,table:P.trim()});e||V(p(k).ddl.createTable(t))}catch(t){e||U(y(t))}})(),()=>{e=!0}},[w,k,M,P]);function $(e){if(!e){if(J){X.current?.abort();return}i()}}async function pe(){if(!M||!P.trim()||!B.trim())return;Y(!0),q(null),G({phase:`create`,copied:0,total:null});let t=new AbortController;X.current=t;try{let n=await ne({source:{connectionId:T,database:E,table:D},target:{connectionId:k,database:M,table:P.trim()},mode:I,onConflict:R,createSql:B},G,t.signal);i(),await x({title:e(`table.copy.doneTitle`),description:I===`structure_data`?e(`table.copy.doneRows`,{count:n.rows,table:P.trim()}):e(`table.copy.doneStructure`,{table:P.trim()}),tone:`success`})}catch(e){e instanceof te||q(y(e)),G(null)}finally{Y(!1),X.current=null}}let me=W?.phase===`copy`&&W.total?Math.min(100,Math.round(W.copied/W.total*100)):null,he=W?W.phase===`create`?e(`table.copy.progressCreate`):W.phase===`count`?e(`table.copy.progressCount`):W.phase===`copy`?e(`table.copy.progressRows`,{copied:W.copied,total:W.total??`?`}):e(`table.copy.progressDone`):``;return(0,v.jsx)(ce,{open:w,onOpenChange:$,children:(0,v.jsxs)(oe,{className:`sm:max-w-[640px]`,children:[(0,v.jsx)(ie,{children:(0,v.jsx)(se,{children:e(`table.copy.title`)})}),(0,v.jsxs)(`div`,{className:`space-y-4`,children:[(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(m,{children:e(`table.copy.source`)}),(0,v.jsx)(g,{value:O?`${b(O)} / ${E} / ${D}`:``,disabled:!0})]}),(0,v.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(m,{htmlFor:`copy-target-conn`,children:e(`table.copy.targetConnection`)}),(0,v.jsxs)(d,{value:k,onValueChange:de,disabled:J,children:[(0,v.jsx)(c,{id:`copy-target-conn`,className:`w-full`,children:(0,v.jsx)(s,{})}),(0,v.jsx)(l,{children:ue.map(t=>(0,v.jsxs)(u,{value:t.id,children:[b(t),t.readOnly?` (${e(`table.copy.readOnly`)})`:``]},t.id))})]})]}),(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(m,{htmlFor:`copy-target-db`,children:e(`table.copy.targetDatabase`)}),(0,v.jsxs)(d,{value:M,onValueChange:N,disabled:J||A.length===0,children:[(0,v.jsx)(c,{id:`copy-target-db`,className:`w-full`,children:(0,v.jsx)(s,{placeholder:e(`table.copy.loading`)})}),(0,v.jsx)(l,{children:A.map(e=>(0,v.jsx)(u,{value:e,children:e},e))})]})]})]}),(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(m,{htmlFor:`copy-target-table`,children:e(`table.copy.targetTable`)}),(0,v.jsx)(g,{id:`copy-target-table`,value:P,onChange:e=>F(e.target.value),disabled:J,spellCheck:!1})]}),(0,v.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(m,{children:e(`table.copy.what`)}),(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,v.jsx)(`input`,{type:`radio`,name:`copy-mode`,checked:I===`structure_data`,onChange:()=>L(`structure_data`),disabled:J}),e(`table.copy.structureAndData`)]}),(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,v.jsx)(`input`,{type:`radio`,name:`copy-mode`,checked:I===`structure_only`,onChange:()=>L(`structure_only`),disabled:J}),e(`table.copy.structureOnly`)]})]})]}),(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(m,{children:e(`table.copy.ifExists`)}),(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,v.jsx)(`input`,{type:`radio`,name:`copy-conflict`,checked:R===`abort`,onChange:()=>z(`abort`),disabled:J}),e(`table.copy.abort`)]}),(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer text-destructive`,children:[(0,v.jsx)(`input`,{type:`radio`,name:`copy-conflict`,checked:R===`drop`,onChange:()=>z(`drop`),disabled:J}),e(`table.copy.dropAndRecreate`)]})]})]})]}),(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(m,{htmlFor:`copy-ddl`,children:e(`table.copy.preview`)}),!fe&&Q&&(0,v.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`table.copy.crossEngineHint`,{engine:Q.label})}),(0,v.jsx)(`textarea`,{id:`copy-ddl`,className:le,value:B,onChange:e=>V(e.target.value),disabled:J,spellCheck:!1}),H&&(0,v.jsx)(`p`,{className:`text-xs text-destructive`,children:H})]}),W&&(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(h,{value:me??(W.phase===`done`?100:0)}),(0,v.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:he})]}),K&&(0,v.jsx)(`p`,{className:`text-sm text-destructive whitespace-pre-wrap`,children:K})]}),(0,v.jsxs)(ae,{children:[(0,v.jsx)(o,{variant:`outline`,onClick:()=>$(!1),children:e(J?`table.copy.stop`:`table.copy.cancel`)}),(0,v.jsx)(o,{onClick:()=>{pe()},disabled:J||!M||!P.trim()||!B.trim()||!!H,children:e(`table.copy.copy`)})]})]})})}export{x as CopyTableDialog};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{h as t,n}from"./ui-store-5IssrgmG.js";import{l as r,m as i,t as a}from"./button-B2EsmMJs.js";import{a as o,i as s,n as c,r as l,t as u}from"./select-DEqoX1sU.js";import{t as d}from"./connection-store-B85kbJpB.js";import{n as f}from"./engine-DjP-Sw-S.js";import{l as p,m}from"./query-execution-BeDEQ-3M.js";import{c as h,l as g}from"./index-Tw24-4of.js";import{a as _,i as v,n as y,o as b,t as x}from"./dialog-FBpgH0QJ.js";var S=e(t(),1),C=r(),w=[`utf8mb4`,`utf8`,`latin1`,`ascii`,`binary`,`cp1251`,`euckr`,`gb2312`,`gbk`,`sjis`,`ucs2`,`utf16`,`utf32`],T={utf8mb4:[`utf8mb4_general_ci`,`utf8mb4_unicode_ci`,`utf8mb4_bin`,`utf8mb4_0900_ai_ci`],utf8:[`utf8_general_ci`,`utf8_unicode_ci`,`utf8_bin`],latin1:[`latin1_swedish_ci`,`latin1_general_ci`,`latin1_bin`],ascii:[`ascii_general_ci`,`ascii_bin`],binary:[`binary`],cp1251:[`cp1251_general_ci`,`cp1251_bin`],euckr:[`euckr_korean_ci`,`euckr_bin`],gb2312:[`gb2312_chinese_ci`,`gb2312_bin`],gbk:[`gbk_chinese_ci`,`gbk_bin`],sjis:[`sjis_japanese_ci`,`sjis_bin`],ucs2:[`ucs2_general_ci`,`ucs2_unicode_ci`,`ucs2_bin`],utf16:[`utf16_general_ci`,`utf16_unicode_ci`,`utf16_bin`],utf32:[`utf32_general_ci`,`utf32_unicode_ci`,`utf32_bin`]};function E(){let{t:e}=i(),{activeDialog:t,closeDialog:r}=n(),E=t===`create-database`,[D,O]=(0,S.useState)(``),[k,A]=(0,S.useState)(`utf8mb4`),[j,M]=(0,S.useState)(`utf8mb4_general_ci`),[N,P]=(0,S.useState)(!1),[F,I]=(0,S.useState)(null);function L(e){e||(r(),I(null),O(``),A(`utf8mb4`),M(`utf8mb4_general_ci`))}function R(e){A(e);let t=T[e];M(t?.[0]??``)}async function z(){let e=d.getState().activeConnectionId,t=D.trim();if(!(!e||!t)){I(null),P(!0);try{let n=f(e).getQuery(`CREATE_DATABASE`,t,k,j);await p(e,n),await m(e),L(!1)}catch(e){I(e instanceof Error?e.message:String(e))}finally{P(!1)}}}let B=T[k]??[];return(0,C.jsx)(x,{open:E,onOpenChange:L,children:(0,C.jsxs)(y,{className:`sm:max-w-[450px]`,children:[(0,C.jsx)(_,{children:(0,C.jsx)(b,{children:e(`database.create.title`)})}),(0,C.jsxs)(`div`,{className:`space-y-4`,children:[(0,C.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,C.jsx)(h,{htmlFor:`db-name`,children:e(`database.create.name`)}),(0,C.jsx)(g,{id:`db-name`,value:D,onChange:e=>O(e.target.value),placeholder:e(`database.create.namePlaceholder`)})]}),(0,C.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,C.jsx)(h,{htmlFor:`db-charset`,children:e(`database.create.charset`)}),(0,C.jsxs)(u,{value:k,onValueChange:R,children:[(0,C.jsx)(s,{id:`db-charset`,className:`w-full`,children:(0,C.jsx)(o,{})}),(0,C.jsx)(c,{children:w.map(e=>(0,C.jsx)(l,{value:e,children:e},e))})]})]}),(0,C.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,C.jsx)(h,{htmlFor:`db-collation`,children:e(`database.create.collation`)}),(0,C.jsxs)(u,{value:j,onValueChange:M,children:[(0,C.jsx)(s,{id:`db-collation`,className:`w-full`,children:(0,C.jsx)(o,{})}),(0,C.jsx)(c,{children:B.map(e=>(0,C.jsx)(l,{value:e,children:e},e))})]})]})]}),F&&(0,C.jsx)(`p`,{className:`px-1 text-xs text-destructive leading-relaxed`,children:F}),(0,C.jsxs)(v,{children:[(0,C.jsx)(a,{variant:`outline`,onClick:()=>L(!1),children:e(`database.create.cancel`)}),(0,C.jsx)(a,{onClick:()=>void z(),disabled:!D.trim()||N,children:e(`database.create.create`)})]})]})})}export{E as CreateDatabaseDialog};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{h as t,n,t as r}from"./ui-store-5IssrgmG.js";import{l as i,m as a,t as o}from"./button-B2EsmMJs.js";import{t as s}from"./connection-store-B85kbJpB.js";import{n as c}from"./engine-DjP-Sw-S.js";import{l,m as u}from"./query-execution-BeDEQ-3M.js";import{c as d,l as f,rt as p}from"./index-Tw24-4of.js";import{a as m,i as h,n as g,o as _,t as v}from"./dialog-FBpgH0QJ.js";var y=e(t(),1),b=i();function x(){let{t:e}=a(),{activeDialog:t,closeDialog:i}=n(),x=r(`create-schema`),S=t===`create-schema`,[C,w]=(0,y.useState)(``),[T,E]=(0,y.useState)(!1),[D,O]=(0,y.useState)(null);function k(e){e||(i(),w(``),O(null))}async function A(){let e=x?.connectionId??s.getState().activeConnectionId,t=C.trim();if(!(!e||!t)){O(null),E(!0);try{await l(e,c(e).getQuery(`CREATE_SCHEMA`,t)),await u(e),k(!1)}catch(e){O(e instanceof Error?e.message:String(e))}finally{E(!1)}}}return(0,b.jsx)(v,{open:S,onOpenChange:k,children:(0,b.jsxs)(g,{className:`sm:max-w-[420px]`,children:[(0,b.jsx)(m,{children:(0,b.jsx)(_,{children:e(`database.schema.createTitle`)})}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(d,{htmlFor:`schema-name`,children:e(`database.schema.name`)}),(0,b.jsx)(f,{id:`schema-name`,value:C,autoFocus:!0,placeholder:e(`database.schema.namePlaceholder`),onChange:e=>w(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!p(e)&&A()}})]}),D&&(0,b.jsx)(`p`,{className:`text-xs text-destructive leading-relaxed`,children:D}),(0,b.jsxs)(h,{children:[(0,b.jsx)(o,{variant:`outline`,onClick:()=>k(!1),children:e(`database.schema.cancel`)}),(0,b.jsx)(o,{onClick:()=>void A(),disabled:!C.trim()||T,children:e(`database.schema.create`)})]})]})})}export{x as CreateSchemaDialog};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,h as n,n as r,t as i}from"./ui-store-5IssrgmG.js";import{l as a,m as o,t as s}from"./button-B2EsmMJs.js";import{a as c,i as l,n as u,r as d,t as f}from"./select-DEqoX1sU.js";import{t as p}from"./connection-store-B85kbJpB.js";import{a as m}from"./database-BSXLJRzV.js";import{n as h}from"./engine-DjP-Sw-S.js";import{t as g}from"./pro-usage-BxwRZwtM.js";import{U as _,_ as v,at as y,c as b,g as x,h as S}from"./index-Tw24-4of.js";import{a as ee,i as te,n as C,o as w,t as ne}from"./dialog-FBpgH0QJ.js";var T=e(n(),1),E=a(),D=e=>e instanceof Error?e.message:String(e),O=e=>e.hostName||e.host||e.file||e.id,k=5e4;function A({id:e,label:t,side:n,onChange:r,connections:i,disabled:a}){let{t:s}=o(),[p,g]=(0,T.useState)([]),[_,v]=(0,T.useState)([]),y=i.find(e=>e.id===n.connectionId);return(0,T.useEffect)(()=>{if(!y?.serverConnectionId)return;let e=!1;return(async()=>{try{let t=await h(y.id).introspect.listDatabases(m(y.serverConnectionId));if(e)return;g(t),t.includes(n.database)||r({connectionId:y.id,database:t[0]??``,table:``})}catch{e||g([])}})(),()=>{e=!0}},[y?.id,y?.serverConnectionId]),(0,T.useEffect)(()=>{if(!y?.serverConnectionId||!n.database)return;let e=!1;return(async()=>{try{let t=await h(y.id).introspect.listTables(m(y.serverConnectionId),n.database);if(e)return;let i=t.map(e=>e.name);v(i),n.table&&!i.includes(n.table)&&r({...n,table:``})}catch{e||v([])}})(),()=>{e=!0}},[y?.id,y?.serverConnectionId,n.database]),(0,E.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3`,children:[(0,E.jsx)(b,{className:`font-medium`,children:t}),(0,E.jsxs)(f,{value:n.connectionId,onValueChange:e=>r({connectionId:e,database:``,table:``}),disabled:a,children:[(0,E.jsx)(l,{id:`${e}-conn`,className:`w-full`,children:(0,E.jsx)(c,{placeholder:s(`database.diff.pickConnection`)})}),(0,E.jsx)(u,{children:i.map(e=>(0,E.jsx)(d,{value:e.id,children:O(e)},e.id))})]}),(0,E.jsxs)(f,{value:n.database,onValueChange:e=>r({...n,database:e,table:``}),disabled:a||p.length===0,children:[(0,E.jsx)(l,{id:`${e}-db`,className:`w-full`,children:(0,E.jsx)(c,{placeholder:s(`database.diff.pickDatabase`)})}),(0,E.jsx)(u,{children:p.map(e=>(0,E.jsx)(d,{value:e,children:e},e))})]}),(0,E.jsxs)(f,{value:n.table,onValueChange:e=>r({...n,table:e}),disabled:a||_.length===0,children:[(0,E.jsx)(l,{id:`${e}-table`,className:`w-full`,children:(0,E.jsx)(c,{placeholder:s(`database.dataDiff.pickTable`)})}),(0,E.jsx)(u,{children:_.map(e=>(0,E.jsx)(d,{value:e,children:e},e))})]})]})}async function j(e,t){let n=await _({connectionId:e.connectionId,database:e.database,table:e.table,limit:k,onProgress:t}),r=[];for await(let e of n.pages)r.push(...e);return{rows:r,columns:n.fields.map(e=>e.name),capped:r.length>=k}}function M({diff:e,row:t,other:n,changed:r}){let{t:i}=o(),a=[...e.keyColumns,...e.compareColumns];return(0,E.jsxs)(`table`,{className:`w-full text-xs font-mono`,children:[(0,E.jsx)(`thead`,{className:`text-muted-foreground`,children:(0,E.jsxs)(`tr`,{children:[(0,E.jsx)(`th`,{className:`text-left font-normal pr-2`,children:i(`database.diff.column`)}),(0,E.jsx)(`th`,{className:`text-left font-normal pr-2`,children:i(`database.diff.source`)}),(0,E.jsx)(`th`,{className:`text-left font-normal`,children:i(`database.diff.target`)})]})}),(0,E.jsx)(`tbody`,{children:a.map(e=>(0,E.jsxs)(`tr`,{className:r?.includes(e)?`text-amber-600 dark:text-amber-400`:``,children:[(0,E.jsx)(`td`,{className:`pr-2 align-top whitespace-nowrap`,children:e}),(0,E.jsx)(`td`,{className:`pr-2 align-top break-all`,children:x(t[e])}),(0,E.jsx)(`td`,{className:`align-top break-all`,children:n?x(n[e]):`—`})]},e))})]})}function N(){let{t:e}=o(),n=r(e=>e.activeDialog),a=r(e=>e.closeDialog),c=i(`data-diff`),l=p(e=>e.activeConnections),u=(0,T.useMemo)(()=>l.filter(e=>e.serverConnectionId),[l]),d=p(e=>e.activeConnectionId),f=n===`data-diff`,[_,b]=(0,T.useState)(()=>c&&u.some(e=>e.id===c.connectionId)?{connectionId:c.connectionId,database:c.database,table:c.table}:{connectionId:d&&u.some(e=>e.id===d)?d:u[0]?.id??``,database:``,table:``}),[O,N]=(0,T.useState)(()=>({connectionId:u.find(e=>e.id!==_.connectionId)?.id??_.connectionId,database:``,table:``})),[P,F]=(0,T.useState)([]),[I,L]=(0,T.useState)(null),[re,ie]=(0,T.useState)(!1),[R,z]=(0,T.useState)(`changed`),[B,V]=(0,T.useState)(0),[H,ae]=(0,T.useState)(!1),[U,W]=(0,T.useState)(!1),[G,K]=(0,T.useState)({source:null,target:null}),[q,J]=(0,T.useState)(null),oe=e=>N(e.database&&!e.table&&_.table?{...e,table:_.table}:e),Y=_.connectionId===O.connectionId&&_.database===O.database&&_.table===O.table,se=!!_.table&&!!O.table&&!Y,X=O.connectionId?h(O.connectionId):null;async function ce(){W(!0),J(null),L(null);try{let n=p.getState().activeConnections.find(e=>e.id===_.connectionId);if(!n?.serverConnectionId)throw Error(e(`services.query.notConnected`));let r=await h(_.connectionId).introspect.getPrimaryKeys(m(n.serverConnectionId),_.database,_.table);if(r.length===0)throw Error(e(`database.dataDiff.noPrimaryKey`,{table:_.table}));K({source:{loaded:0,total:null},target:{loaded:0,total:null}});let[i,a]=await Promise.all([j(_,e=>K(t=>({...t,source:e}))),j(O,e=>K(t=>({...t,target:e})))]);if(r.some(e=>!a.columns.includes(e)))throw Error(e(`database.dataDiff.keyMissingInTarget`,{columns:r.join(`, `)}));let o=v(i.rows,a.rows,r,i.columns,a.columns);F(r),ie(i.capped||a.capped),L(o),z(o.changed.length>0?`changed`:o.added.length>0?`added`:`removed`),V(0),g(`compare_data`),t(`data_diff`,{source_dbms:h(_.connectionId).id,target_dbms:X?.id??`unknown`,added:o.added.length,changed:o.changed.length,removed:o.removed.length})}catch(e){J(D(e))}finally{W(!1),K({source:null,target:null})}}let Z=e=>e?e.total===null?e.loaded.toLocaleString():`${e.loaded.toLocaleString()} / ${e.total.toLocaleString()}`:``,Q=(0,T.useMemo)(()=>I&&X?S(I,X,{database:O.database,table:O.table},{includeDeletes:H}):``,[I,X,O.database,O.table,H]);function le(){Q&&(y(O.connectionId,Q,O.database,e(`database.dataDiff.tabTitle`,{table:O.table})),a())}let $=I?R===`added`?I.added:R===`removed`?I.removed:I.changed.map(e=>e.source):[],ue=!!I&&I.added.length+I.changed.length+I.removed.length>0,de=e=>P.map(t=>x(e[t])).join(`, `);return(0,E.jsx)(ne,{open:f,onOpenChange:e=>{e||a()},children:(0,E.jsxs)(C,{className:`sm:max-w-[900px]`,children:[(0,E.jsx)(ee,{children:(0,E.jsx)(w,{children:e(`database.dataDiff.title`)})}),(0,E.jsxs)(`div`,{className:`space-y-3`,children:[(0,E.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,E.jsx)(A,{id:`ddiff-source`,label:e(`database.diff.source`),side:_,onChange:b,connections:u,disabled:U}),(0,E.jsx)(A,{id:`ddiff-target`,label:e(`database.diff.target`),side:O,onChange:oe,connections:u,disabled:U})]}),(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`database.dataDiff.hint`,{cap:k.toLocaleString()})}),Y&&_.table&&(0,E.jsx)(`p`,{className:`text-xs text-destructive`,children:e(`database.dataDiff.sameSide`)}),q&&(0,E.jsx)(`p`,{className:`text-sm text-destructive whitespace-pre-wrap`,children:q}),U&&(G.source||G.target)&&(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`database.dataDiff.loading`,{source:Z(G.source),target:Z(G.target)})}),I&&(0,E.jsxs)(`div`,{className:`space-y-2`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-xs`,children:[(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:e(`database.dataDiff.summary`,{key:P.join(`, `),added:I.added.length,changed:I.changed.length,removed:I.removed.length,identical:I.identical})}),re&&(0,E.jsx)(`span`,{className:`text-amber-600 dark:text-amber-400`,children:e(`database.dataDiff.capped`,{cap:k.toLocaleString()})}),(I.sourceOnlyColumns.length>0||I.targetOnlyColumns.length>0)&&(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:e(`database.dataDiff.ignoredColumns`,{columns:[...I.sourceOnlyColumns,...I.targetOnlyColumns].join(`, `)})})]}),(0,E.jsx)(`div`,{className:`flex gap-1 text-xs`,children:[`added`,`changed`,`removed`].map(t=>(0,E.jsx)(`button`,{type:`button`,onClick:()=>{z(t),V(0)},className:`rounded border px-2 py-0.5 ${R===t?`bg-accent`:``}`,children:e(`database.dataDiff.${t}`,{count:t===`added`?I.added.length:t===`removed`?I.removed.length:I.changed.length})},t))}),(0,E.jsxs)(`div`,{className:`grid grid-cols-[240px_1fr] gap-3 h-[280px]`,children:[(0,E.jsxs)(`ul`,{className:`overflow-auto rounded-md border text-sm font-mono`,children:[$.slice(0,2e3).map((e,t)=>(0,E.jsx)(`li`,{className:`px-2 py-1 cursor-pointer ${B===t?`bg-accent`:``}`,onClick:()=>V(t),children:de(e)},t)),$.length===0&&(0,E.jsx)(`li`,{className:`px-2 py-1 text-muted-foreground`,children:e(`database.dataDiff.none`)}),$.length>2e3&&(0,E.jsx)(`li`,{className:`px-2 py-1 text-muted-foreground`,children:e(`database.dataDiff.more`,{count:$.length-2e3})})]}),(0,E.jsx)(`div`,{className:`overflow-auto rounded-md border p-2`,children:$[B]?R===`changed`?(0,E.jsx)(M,{diff:I,row:I.changed[B].source,other:I.changed[B].target,changed:I.changed[B].columns}):R===`removed`?(0,E.jsx)(M,{diff:I,row:{},other:$[B]}):(0,E.jsx)(M,{diff:I,row:$[B]}):(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`database.diff.selectTable`)})})]}),(0,E.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[(0,E.jsx)(`input`,{type:`checkbox`,checked:H,onChange:e=>ae(e.target.checked)}),(0,E.jsx)(`span`,{className:H?`text-destructive`:``,children:e(`database.dataDiff.includeDeletes`)})]})]})]}),(0,E.jsxs)(te,{children:[(0,E.jsx)(s,{variant:`outline`,onClick:a,children:e(`database.diff.close`)}),(0,E.jsx)(s,{variant:`secondary`,onClick:()=>{ce()},disabled:!se||U,children:e(U?`database.diff.comparing`:`database.diff.compare`)}),(0,E.jsx)(s,{onClick:le,disabled:!ue,children:e(`database.diff.openScript`)})]})]})})}export{N as DataDiffDialog};
@@ -0,0 +1,3 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,h as n,n as r,t as i}from"./ui-store-5IssrgmG.js";import{l as a,m as o,t as s}from"./button-B2EsmMJs.js";import{a as c,i as l,n as u,r as d,t as f}from"./select-DEqoX1sU.js";import{t as p}from"./connection-store-B85kbJpB.js";import{n as ee}from"./query-store-BqBiylGA.js";import{a as te}from"./database-BSXLJRzV.js";import{o as m}from"./dbms-BwnatOMe.js";import{n as ne}from"./engine-DjP-Sw-S.js";import{n as re}from"./query-execution-BeDEQ-3M.js";import{U as h,c as g,j as _,l as v}from"./index-Tw24-4of.js";import{a as y,i as b,n as x,o as S,t as ie}from"./dialog-FBpgH0QJ.js";import{t as C}from"./file-name-CnYBZPf9.js";var w=e(n(),1);function T(e,t){let n=e==null?``:typeof e==`object`?JSON.stringify(e):String(e);return!(typeof e==`number`||typeof e==`bigint`||/^[-+]?\d+(\.\d+)?([eE][-+]?\d+)?$/.test(n))&&/^[=+\-@\t\r]/.test(n)&&(n=`'${n}`),n.includes(t)||n.includes(`"`)||n.includes(`
2
+ `)||n.includes(`\r`)?`"${n.replace(/"/g,`""`)}"`:n}var E=(e,t)=>e.map(e=>T(e,t)).join(t)+`
3
+ `,D=e=>e===` `,O=e=>D(e)?`TSV`:`CSV`,k=e=>D(e)?`.tsv`:`.csv`,A=e=>D(e)?`text/tab-separated-values`:`text/csv`;async function j(e,t){let n=C(e),r=A(t);if(typeof window.showSaveFilePicker==`function`)try{let e=await(await window.showSaveFilePicker({suggestedName:n,types:[{description:O(t),accept:{[r]:[k(t)]}}]})).createWritable();return await e.write(``),{write:t=>e.write(t),finish:()=>e.close(),abort:()=>e.abort()}}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)throw new M}let i=[``];return{write:async e=>{i.push(e)},finish:async()=>{let e=new Blob(i,{type:`${r};charset=utf-8;`}),t=URL.createObjectURL(e),a=document.createElement(`a`);a.href=t,a.download=n,a.click(),URL.revokeObjectURL(t)},abort:async()=>{i.length=0}}}var M=class extends Error{constructor(){super(`CSV export cancelled`)}};async function N(e){let n=await j(`${e.table}${k(e.delimiter)}`,e.delimiter),r=0;try{let i=await h({connectionId:e.connectionId,database:e.database,table:e.table,signal:e.signal,onProgress:e.onProgress}),a=i.fields.map(e=>e.name);e.includeHeaders&&await n.write(E(a,e.delimiter));for await(let t of i.pages)await n.write(t.map(t=>E(a.map(e=>t[e]),e.delimiter)).join(``)),r+=t.length;return await n.finish(),t(`export_csv`,{source:`table`,rows:r,format:O(e.delimiter)}),r}catch(e){throw await n.abort().catch(()=>void 0),e}}function P(e,n,r,i,a){let o=e.map(e=>e.name),s=[``];i&&s.push(E(o,r));for(let e of n)s.push(E(o.map(t=>e[t]),r));let c=new Blob(s,{type:`${A(r)};charset=utf-8;`}),l=URL.createObjectURL(c),u=document.createElement(`a`);u.href=l,u.download=C(a??`query_result${k(r)}`),u.click(),URL.revokeObjectURL(l),t(`export_csv`,{source:`result`,rows:n.length,format:O(r)})}var F=a(),I=[{value:`,`,label:`database.csv.delimiterComma`},{value:` `,label:`database.csv.delimiterTab`},{value:`;`,label:`database.csv.delimiterSemicolon`},{value:`|`,label:`database.csv.delimiterPipe`}];function L(){let{t:e}=o(),{activeDialog:t,closeDialog:n}=r(),a=i(`export-csv`),h=p(e=>e.activeConnectionId),C=ee(),T=t===`export-csv`,[E,O]=(0,w.useState)(`query_result`),[k,A]=(0,w.useState)(``),[j,L]=(0,w.useState)([]),[R,z]=(0,w.useState)(``),[B,V]=(0,w.useState)(`,`),[H,U]=(0,w.useState)(!0),[W,G]=(0,w.useState)(!1),[K,q]=(0,w.useState)(null),[J,Y]=(0,w.useState)(null),X=(0,w.useRef)(null),Z=D(B)?`TSV`:`CSV`,Q=()=>{if(a?.nodeText&&(a.nodeType===m.TABLE||a.nodeType===m.VIEW)){let e=a.metadata?.database;return{table:a.nodeText,database:typeof e==`string`?e:``}}if(!h)return null;let e=(C.tabs[h]??[]).find(e=>e.id===C.activeTabId[h]);return e?.sourceTable?{table:e.sourceTable.table,database:e.sourceTable.database}:null};(0,w.useEffect)(()=>{if(!T)return;let e=Q();V(a?.delimiter??`,`),e&&(A(e.table),O(`table_data`))},[T]),(0,w.useEffect)(()=>{if(!T||!h)return;let e=p.getState().activeConnections.find(e=>e.id===h);if(!e?.serverConnectionId)return;let t=!1;return(async()=>{try{let n=await ne(h).introspect.listDatabases(te(e.serverConnectionId));if(t)return;L(n);let r=C.tabs[h]?.find(e=>e.id===C.activeTabId[h])?.database||``,i=Q()?.database||``;z(e=>n.includes(i)?i:n.includes(e)?e:n.includes(r)?r:n.length===1?n[0]:``)}catch{t||L([])}})(),()=>{t=!0}},[T,h]);function $(e){if(!e){if(W){X.current?.abort();return}n(),O(`query_result`),A(``),V(`,`),U(!0)}}async function ae(){if(!h)return;if(Y(null),E===`query_result`){let e=C.activeTabId[h],t=(C.tabs[h]??[]).find(t=>t.id===e)?.results?.[0];if(!t||t.rows.length===0)return;P(t.fields,t.rows,B,H),n();return}if(!k.trim()||!R)return;let t=new AbortController;X.current=t,G(!0),q({loaded:0,total:null});try{let i=await N({connectionId:h,database:R,table:k.trim(),delimiter:B,includeHeaders:H,onProgress:q,signal:t.signal});r.getState().setFooterMessage(e(`database.csv.done`,{count:i,table:k.trim(),format:Z})),n()}catch(e){!(e instanceof M)&&!(e instanceof re&&t.signal.aborted)&&Y(e instanceof Error?e.message:String(e))}finally{G(!1),q(null),X.current=null}}let oe=K?.total?Math.min(100,Math.round(K.loaded/K.total*100)):null;return(0,F.jsx)(ie,{open:T,onOpenChange:$,children:(0,F.jsxs)(x,{className:`sm:max-w-[450px]`,children:[(0,F.jsx)(y,{children:(0,F.jsx)(S,{children:e(`database.csv.title`,{format:Z})})}),(0,F.jsxs)(`div`,{className:`space-y-4`,children:[(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(g,{children:e(`database.csv.target`)}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,F.jsx)(`input`,{type:`radio`,name:`csv-target`,value:`query_result`,checked:E===`query_result`,onChange:()=>O(`query_result`)}),e(`database.csv.targetQueryResult`)]}),(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,F.jsx)(`input`,{type:`radio`,name:`csv-target`,value:`table_data`,checked:E===`table_data`,onChange:()=>O(`table_data`)}),e(`database.csv.targetTableData`)]})]})]}),E===`table_data`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(g,{htmlFor:`csv-database`,children:e(`database.csv.database`)}),(0,F.jsxs)(f,{value:R,onValueChange:z,disabled:j.length===0,children:[(0,F.jsx)(l,{id:`csv-database`,className:`w-full`,children:(0,F.jsx)(c,{placeholder:e(`database.csv.databasePlaceholder`)})}),(0,F.jsx)(u,{children:j.map(e=>(0,F.jsx)(d,{value:e,children:e},e))})]})]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(g,{htmlFor:`csv-table-name`,children:e(`database.csv.tableName`)}),(0,F.jsx)(v,{id:`csv-table-name`,value:k,onChange:e=>A(e.target.value),placeholder:e(`database.csv.tableNamePlaceholder`)})]})]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(g,{htmlFor:`csv-delimiter`,children:e(`database.csv.delimiter`)}),(0,F.jsxs)(f,{value:B,onValueChange:V,children:[(0,F.jsx)(l,{id:`csv-delimiter`,className:`w-full`,children:(0,F.jsx)(c,{})}),(0,F.jsx)(u,{children:I.map(t=>(0,F.jsx)(d,{value:t.value,children:e(t.label)},t.value))})]})]}),(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:H,onChange:e=>U(e.target.checked)}),e(`database.csv.includeHeaders`)]})]}),K&&(0,F.jsxs)(`div`,{className:`space-y-1`,children:[(0,F.jsx)(_,{value:oe??0}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:K.total===null?e(`database.csv.progressUnknown`,{loaded:K.loaded}):e(`database.csv.progress`,{loaded:K.loaded,total:K.total})})]}),J&&(0,F.jsx)(`p`,{className:`text-sm text-destructive whitespace-pre-wrap`,children:J}),(0,F.jsxs)(b,{children:[(0,F.jsx)(s,{variant:`outline`,onClick:()=>$(!1),children:e(W?`database.csv.stop`:`database.csv.cancel`)}),(0,F.jsx)(s,{onClick:ae,disabled:W||E===`table_data`&&!k.trim(),children:e(W?`database.csv.downloading`:`database.csv.download`)})]})]})})}export{L as DownloadToCSVDialog};
@@ -0,0 +1,2 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{h as t,n,t as r}from"./ui-store-5IssrgmG.js";import{l as i,m as a,t as o}from"./button-B2EsmMJs.js";import{a as s,i as c,n as l,r as u,t as d}from"./select-DEqoX1sU.js";import{t as f}from"./connection-store-B85kbJpB.js";import{a as p}from"./database-BSXLJRzV.js";import{n as m}from"./engine-DjP-Sw-S.js";import{l as h,p as g}from"./query-execution-BeDEQ-3M.js";import{C as _,D as v,E as y,K as b,O as x,Q as S,S as C,T as ee,Xt as w,b as T,c as E,ct as D,l as O,ot as k,st as A,v as j,x as M,y as N}from"./index-Tw24-4of.js";import{a as P,i as te,n as ne,o as F,t as I}from"./dialog-FBpgH0QJ.js";var L=e(t(),1);function R(){return{id:crypto.randomUUID(),field:``,type:`varchar`,length:``,defaultValue:``,pk:!1,notNull:!1,unsigned:!1,autoIncrement:!1,zerofill:!1,comment:``}}function z(){return{id:crypto.randomUUID(),name:``,type:`INDEX`,columns:[]}}function B(){return{engine:`InnoDB`,charset:`utf8mb4`,collation:`utf8mb4_general_ci`,autoIncrement:``,comment:``}}function V(e,t,n,r,i){return{database:e,name:t,columns:n.map(e=>({name:e.field,type:e.type,length:e.length,defaultValue:e.defaultValue,primaryKey:e.pk,notNull:e.notNull,unsigned:e.unsigned,autoIncrement:e.autoIncrement,zerofill:e.zerofill,comment:e.comment})),indexes:r.map(e=>({name:e.name,type:e.type,columns:[...e.columns]})),options:{...i}}}var H=i(),U=`w-auto min-w-full [&_td]:bg-muted [&_td]:border-r [&_td]:border-border/60 [&_td:last-child]:border-r-0 [&_td]:p-0 [&_td]:h-8 [&_tr:nth-child(even)_td]:bg-muted/60 [&_tr:focus-within_td]:bg-primary/5`,W=`sticky top-0 z-10 bg-catppuccin-crust shadow-[inset_0_-1px_0_var(--border)] [&_th]:h-8 [&_th]:bg-catppuccin-crust [&_th]:font-semibold [&_th]:text-foreground [&_th]:uppercase [&_th]:tracking-wide [&_th]:text-[11px]`,G=`h-8 w-full min-w-0 rounded-none border-0 bg-transparent px-2 text-xs shadow-none ring-0 focus-visible:bg-primary/10 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary dark:bg-transparent`,K=`h-8 w-full min-w-0 rounded-none border-0 bg-transparent px-2 text-xs shadow-none focus-visible:bg-primary/10 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary data-[state=open]:bg-primary/10 dark:bg-transparent dark:hover:bg-transparent`;function re({columns:e,onChange:t}){let{t:n}=a(),r=k().getDataTypes(),i=(0,L.useCallback)((n,r,i)=>{t(e.map(e=>e.id===n?{...e,[r]:i}:e))},[e,t]);function f(){t([...e,R()])}function p(){e.length>0&&t(e.slice(0,-1))}return(0,H.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,H.jsx)(D,{className:`flex-1`,children:(0,H.jsxs)(j,{className:U,children:[(0,H.jsx)(C,{className:W,children:(0,H.jsxs)(_,{children:[(0,H.jsx)(M,{className:`w-[120px]`,children:n(`table.schema.colField`)}),(0,H.jsx)(M,{className:`w-[120px]`,children:n(`table.schema.colType`)}),(0,H.jsx)(M,{className:`w-[60px]`,children:n(`table.schema.colLength`)}),(0,H.jsx)(M,{className:`w-[100px]`,children:n(`table.schema.colDefault`)}),(0,H.jsx)(M,{className:`w-[40px]`,children:n(`table.schema.colPk`)}),(0,H.jsx)(M,{className:`w-[60px]`,children:n(`table.schema.colNotNull`)}),(0,H.jsx)(M,{className:`w-[60px]`,children:n(`table.schema.colUnsigned`)}),(0,H.jsx)(M,{className:`w-[70px]`,children:n(`table.schema.colAutoIncrement`)}),(0,H.jsx)(M,{className:`w-[60px]`,children:n(`table.schema.colZerofill`)}),(0,H.jsx)(M,{children:n(`table.schema.colComment`)})]})}),(0,H.jsx)(N,{children:e.length===0?(0,H.jsx)(_,{children:(0,H.jsx)(T,{colSpan:10,className:`text-center text-muted-foreground`,children:n(`table.schema.empty`)})}):e.map(e=>(0,H.jsxs)(_,{children:[(0,H.jsx)(T,{children:(0,H.jsx)(O,{className:G,value:e.field,onChange:t=>i(e.id,`field`,t.target.value),placeholder:`column_name`})}),(0,H.jsx)(T,{children:(0,H.jsxs)(d,{value:e.type,onValueChange:t=>i(e.id,`type`,t),children:[(0,H.jsx)(c,{className:K,children:(0,H.jsx)(s,{})}),(0,H.jsx)(l,{children:r.map(e=>(0,H.jsx)(u,{value:e,children:e},e))})]})}),(0,H.jsx)(T,{children:(0,H.jsx)(O,{className:G,value:e.length,onChange:t=>i(e.id,`length`,t.target.value)})}),(0,H.jsx)(T,{children:(0,H.jsx)(O,{className:G,value:e.defaultValue,onChange:t=>i(e.id,`defaultValue`,t.target.value),placeholder:`NULL`})}),(0,H.jsx)(T,{className:`text-center`,children:(0,H.jsx)(`input`,{type:`checkbox`,checked:e.pk,onChange:t=>i(e.id,`pk`,t.target.checked)})}),(0,H.jsx)(T,{className:`text-center`,children:(0,H.jsx)(`input`,{type:`checkbox`,checked:e.notNull,onChange:t=>i(e.id,`notNull`,t.target.checked)})}),(0,H.jsx)(T,{className:`text-center`,children:(0,H.jsx)(`input`,{type:`checkbox`,checked:e.unsigned,onChange:t=>i(e.id,`unsigned`,t.target.checked)})}),(0,H.jsx)(T,{className:`text-center`,children:(0,H.jsx)(`input`,{type:`checkbox`,checked:e.autoIncrement,onChange:t=>i(e.id,`autoIncrement`,t.target.checked)})}),(0,H.jsx)(T,{className:`text-center`,children:(0,H.jsx)(`input`,{type:`checkbox`,checked:e.zerofill,onChange:t=>i(e.id,`zerofill`,t.target.checked)})}),(0,H.jsx)(T,{children:(0,H.jsx)(O,{className:G,value:e.comment,onChange:t=>i(e.id,`comment`,t.target.value)})})]},e.id))})]})}),(0,H.jsxs)(`div`,{className:`flex gap-2 p-2 border-t`,children:[(0,H.jsx)(o,{size:`sm`,variant:`outline`,onClick:f,children:n(`table.schema.add`)}),(0,H.jsx)(o,{size:`sm`,variant:`outline`,onClick:p,disabled:e.length===0,children:n(`table.schema.remove`)})]})]})}var q=[`PRIMARY`,`UNIQUE`,`INDEX`,`FULLTEXT`];function J({open:e,index:t,availableColumns:n,onSave:r,onClose:i}){let{t:f}=a(),[p,m]=(0,L.useState)(t.name),[h,g]=(0,L.useState)(t.type),[_,v]=(0,L.useState)(t.columns);function y(e){v(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}function b(){r({id:t.id,name:h===`PRIMARY`?`PRIMARY`:p,type:h,columns:_})}return(0,H.jsx)(I,{open:e,onOpenChange:e=>{e||i()},children:(0,H.jsxs)(ne,{className:`sm:max-w-[500px]`,children:[(0,H.jsx)(P,{children:(0,H.jsx)(F,{children:t.name?f(`table.index.editTitle`):f(`table.index.addTitle`)})}),(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(E,{htmlFor:`idx-name`,children:f(`table.index.name`)}),(0,H.jsx)(O,{id:`idx-name`,value:h===`PRIMARY`?`PRIMARY`:p,onChange:e=>m(e.target.value),disabled:h===`PRIMARY`,placeholder:f(`table.index.namePlaceholder`)})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(E,{htmlFor:`idx-type`,children:f(`table.index.type`)}),(0,H.jsxs)(d,{value:h,onValueChange:e=>g(e),children:[(0,H.jsx)(c,{id:`idx-type`,className:`w-full`,children:(0,H.jsx)(s,{})}),(0,H.jsx)(l,{children:q.map(e=>(0,H.jsx)(u,{value:e,children:e},e))})]})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(E,{children:f(`table.index.columns`)}),(0,H.jsx)(`div`,{className:`border rounded-md p-2 max-h-[200px] overflow-y-auto space-y-1`,children:n.length===0?(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:f(`table.index.noColumns`)}):n.map(e=>(0,H.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer hover:bg-muted/50 rounded px-1 py-0.5`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:_.includes(e.field),onChange:()=>y(e.field)}),(0,H.jsx)(`span`,{children:e.field||f(`table.index.unnamed`)}),(0,H.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.type,`)`]})]},e.id))})]})]}),(0,H.jsxs)(te,{children:[(0,H.jsx)(o,{variant:`outline`,onClick:i,children:f(`table.index.cancel`)}),(0,H.jsx)(o,{onClick:b,disabled:_.length===0,children:f(`table.index.ok`)})]})]})})}function ie({indexes:e,availableColumns:t,onChange:n}){let{t:r}=a(),[i,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(!1);function u(){let e=z();s(e),l(!0)}function d(e){s({...e}),l(!0)}function f(){e.length>0&&n(e.slice(0,-1))}function p(t){e.find(e=>e.id===t.id)?n(e.map(e=>e.id===t.id?t:e)):n([...e,t]),l(!1),s(null)}function m(){l(!1),s(null)}return(0,H.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,H.jsx)(D,{className:`flex-1`,children:(0,H.jsxs)(j,{className:U+` [&_td]:px-2`,children:[(0,H.jsx)(C,{className:W,children:(0,H.jsxs)(_,{children:[(0,H.jsx)(M,{className:`w-[150px]`,children:r(`table.indexes.colName`)}),(0,H.jsx)(M,{className:`w-[120px]`,children:r(`table.indexes.colType`)}),(0,H.jsx)(M,{children:r(`table.indexes.colColumns`)})]})}),(0,H.jsx)(N,{children:e.length===0?(0,H.jsx)(_,{children:(0,H.jsx)(T,{colSpan:3,className:`text-center text-muted-foreground`,children:r(`table.indexes.empty`)})}):e.map(e=>(0,H.jsxs)(_,{className:`cursor-pointer`,onDoubleClick:()=>d(e),children:[(0,H.jsx)(T,{children:e.name}),(0,H.jsx)(T,{children:e.type}),(0,H.jsx)(T,{children:e.columns.join(`, `)})]},e.id))})]})}),(0,H.jsxs)(`div`,{className:`flex gap-2 p-2 border-t`,children:[(0,H.jsx)(o,{size:`sm`,variant:`outline`,onClick:u,children:r(`table.indexes.add`)}),(0,H.jsx)(o,{size:`sm`,variant:`outline`,onClick:f,disabled:e.length===0,children:r(`table.indexes.remove`)})]}),i&&(0,H.jsx)(J,{open:c,index:i,availableColumns:t,onSave:p,onClose:m})]})}var Y=[`InnoDB`,`MyISAM`,`MEMORY`,`CSV`,`ARCHIVE`,`BLACKHOLE`,`MRG_MYISAM`,`FEDERATED`,`PERFORMANCE_SCHEMA`],ae=[`utf8mb4`,`utf8`,`latin1`,`ascii`,`binary`,`cp1251`,`euckr`,`gb2312`,`gbk`,`sjis`,`ucs2`,`utf16`,`utf32`],X={utf8mb4:[`utf8mb4_general_ci`,`utf8mb4_unicode_ci`,`utf8mb4_bin`,`utf8mb4_0900_ai_ci`],utf8:[`utf8_general_ci`,`utf8_unicode_ci`,`utf8_bin`],latin1:[`latin1_swedish_ci`,`latin1_general_ci`,`latin1_bin`],ascii:[`ascii_general_ci`,`ascii_bin`],binary:[`binary`],cp1251:[`cp1251_general_ci`,`cp1251_bin`],euckr:[`euckr_korean_ci`,`euckr_bin`],gb2312:[`gb2312_chinese_ci`,`gb2312_bin`],gbk:[`gbk_chinese_ci`,`gbk_bin`],sjis:[`sjis_japanese_ci`,`sjis_bin`],ucs2:[`ucs2_general_ci`,`ucs2_unicode_ci`,`ucs2_bin`],utf16:[`utf16_general_ci`,`utf16_unicode_ci`,`utf16_bin`],utf32:[`utf32_general_ci`,`utf32_unicode_ci`,`utf32_bin`]};function oe({properties:e,onChange:t}){let{t:n}=a();function r(n,r){let i={...e,[n]:r};n===`charset`&&(i.collation=X[r]?.[0]??``),t(i)}let i=X[e.charset]??[];return(0,H.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(E,{htmlFor:`prop-engine`,children:n(`table.properties.engine`)}),(0,H.jsxs)(d,{value:e.engine,onValueChange:e=>r(`engine`,e),children:[(0,H.jsx)(c,{id:`prop-engine`,className:`w-full`,children:(0,H.jsx)(s,{})}),(0,H.jsx)(l,{children:Y.map(e=>(0,H.jsx)(u,{value:e,children:e},e))})]})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(E,{htmlFor:`prop-charset`,children:n(`table.properties.charset`)}),(0,H.jsxs)(d,{value:e.charset,onValueChange:e=>r(`charset`,e),children:[(0,H.jsx)(c,{id:`prop-charset`,className:`w-full`,children:(0,H.jsx)(s,{})}),(0,H.jsx)(l,{children:ae.map(e=>(0,H.jsx)(u,{value:e,children:e},e))})]})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(E,{htmlFor:`prop-collation`,children:n(`table.properties.collation`)}),(0,H.jsxs)(d,{value:e.collation,onValueChange:e=>r(`collation`,e),children:[(0,H.jsx)(c,{id:`prop-collation`,className:`w-full`,children:(0,H.jsx)(s,{})}),(0,H.jsx)(l,{children:i.map(e=>(0,H.jsx)(u,{value:e,children:e},e))})]})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(E,{htmlFor:`prop-auto-incr`,children:n(`table.properties.autoIncrement`)}),(0,H.jsx)(O,{id:`prop-auto-incr`,type:`number`,value:e.autoIncrement,onChange:e=>r(`autoIncrement`,e.target.value),placeholder:n(`table.properties.autoIncrementPlaceholder`)})]})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(E,{htmlFor:`prop-comment`,children:n(`table.properties.comment`)}),(0,H.jsx)(O,{id:`prop-comment`,value:e.comment,onChange:e=>r(`comment`,e.target.value)})]})]})}function se({connectionId:e,database:t,tableName:n,columns:r,indexes:i,properties:a}){let o=S(e=>e.themeId),s=A(e),c=o===`light`||o===`light-blue`||o===`solarized-light`?`vs`:`vs-dark`,l=(0,L.useMemo)(()=>s.ddl.createTable(V(t,n,r,i,a)),[s,t,n,r,i,a]);return(0,H.jsx)(`div`,{className:`h-[320px]`,children:(0,H.jsx)(w,{height:`100%`,language:`sql`,theme:c,value:l,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:13,lineNumbers:`on`,wordWrap:`on`}})})}function Z(e){return JSON.stringify([e.type,e.length,e.defaultValue,e.pk,e.notNull,e.unsigned,e.autoIncrement,e.zerofill,e.comment])}function Q(e){return{name:e.field,type:e.length?`${e.type}(${e.length})`:e.type,nullable:!e.notNull,key:e.pk?`PRI`:``,defaultValue:e.defaultValue===``?null:e.defaultValue,extra:e.autoIncrement?`auto_increment`:``,comment:e.comment,collation:null}}function $(e){return{name:e.name,type:e.type,columns:[...e.columns]}}function ce(e,t){return e.name===t.name&&e.type===t.type&&e.columns.join(`,`)===t.columns.join(`,`)}function le({engine:e,database:t,table:n,before:r,after:i}){let{ddl:a}=e,o=[],s=[],c=[],l=new Map(r.columns.map(e=>[e.id,e])),u=new Map(i.columns.map(e=>[e.id,e])),d=new Map(r.indexes.map(e=>[e.id,e])),f=new Map(i.indexes.map(e=>[e.id,e])),p=[];for(let[e,r]of d){let i=f.get(e);i?ce(r,i)||(o.push(a.dropIndex(t,n,r.name)),p.push(i)):o.push(a.dropIndex(t,n,r.name))}for(let[e,r]of u){let i=l.get(e);if(!i){r.field.trim()&&o.push(a.addColumn(t,n,Q(r)));continue}if(i.field!==r.field&&o.push(a.renameColumn(t,n,i.field,r.field)),Z(i)!==Z(r)){let e=a.alterColumn(t,n,Q(r));e?o.push(e):c.push(r.field)}}for(let[e,r]of l)if(!u.has(e)){let e=a.dropColumn(t,n,r.field);o.push(e),s.push(e)}for(let e of p)o.push(a.createIndex(t,n,$(e)));for(let[e,r]of f)!d.has(e)&&r.columns.length>0&&o.push(a.createIndex(t,n,$(r)));return{statements:o,destructive:s,unsupported:c}}function ue(){let{t:e}=a(),{activeDialog:t,closeDialog:i}=n(),s=r(`create-table`,`alter-table`,`duplicate-table-structure`),c=t===`create-table`||t===`alter-table`||t===`duplicate-table-structure`,l=t===`alter-table`,u=t===`duplicate-table-structure`,d=s?.nodeText??``,_=s?.metadata?.database??``,[S,C]=(0,L.useState)(``),[w,T]=(0,L.useState)([R()]),[D,k]=(0,L.useState)([]),[j,M]=(0,L.useState)(B()),[N,z]=(0,L.useState)(!1),[U,W]=(0,L.useState)(!1),[G,K]=(0,L.useState)(null),[q,J]=(0,L.useState)(null),Y=s?.connectionId??f.getState().activeConnectionId,ae=A(Y);(0,L.useEffect)(()=>{c&&(K(null),J(null),l||u?(C(u?`${d}_copy`:d),X()):(C(``),T([R()]),k([]),M(B())))},[c,t]);async function X(){let e=f.getState(),t=s?.connectionId??e.activeConnectionId,n=e.activeConnections.find(e=>e.id===t)?.serverConnectionId;if(!n||!_||!d)return;z(!0);let{introspect:r,capabilities:i}=m(t),a=p(n);try{let e=await r.listColumns(a,_,d),t=[];if(e.length>0){let n=e.map(e=>{let t=e.type,n=t.match(/^(\w+)(?:\(([^)]+)\))?/);return{id:crypto.randomUUID(),field:e.name,type:n?.[1]?.toLowerCase()??t.toLowerCase(),length:n?.[2]??``,defaultValue:e.defaultValue??``,pk:e.key===`PRI`,notNull:!e.nullable,unsigned:t.includes(`unsigned`),autoIncrement:e.extra.includes(`auto_increment`),zerofill:t.includes(`zerofill`),comment:e.comment}});T(n),t=n}let n=await r.listIndexes(a,_,d),o=[];if(n.length>0&&(o=n.map(e=>({id:crypto.randomUUID(),name:e.name,type:e.type===`SPATIAL`?`INDEX`:e.type,columns:[...e.columns]})),k(o)),J({columns:t,indexes:o}),i.tableProperties){let e=await r.getTableInfo(a,_,d);e&&M({engine:e.engine??`InnoDB`,charset:(e.collation??`utf8mb4`).replace(/_.*/,``),collation:e.collation??`utf8mb4_unicode_ci`,autoIncrement:e.autoIncrement??``,comment:e.comment})}}catch(e){console.error(`Failed to load table schema:`,e),K(e instanceof Error?e.message:String(e))}finally{z(!1)}}function Z(e){e||i()}async function Q(){let t=s?.connectionId??f.getState().activeConnectionId;if(!t||!S.trim())return;let n=m(t);K(null);let r,a=[];if(l){if(!q)return;let t=le({engine:n,database:_,table:d,before:q,after:{columns:w,indexes:D}});if(t.unsupported.length>0){K(e(`table.dialog.cannotAlterColumns`,{engine:n.label,columns:t.unsupported.join(`, `)}));return}if(t.statements.length===0){i();return}r=t.statements.join(`
2
+ `),a=t.destructive}else{let e=u?D.map(e=>({...e,name:b(e.name,d,S.trim())})):D;r=n.ddl.createTable(V(_,S.trim(),w,e,j))}W(!0);try{await h(t,r,{skipDestructiveConfirm:a.length===0}),await g(t,_),i()}catch(e){K(e instanceof Error?e.message:String(e))}finally{W(!1)}}let $=e(l?`table.dialog.alterTitle`:u?`table.dialog.duplicateTitle`:`table.dialog.createTitle`),ce=e(l?`table.dialog.alter`:`table.dialog.create`);return(0,H.jsx)(I,{open:c,onOpenChange:Z,children:(0,H.jsxs)(ne,{className:`sm:max-w-[1000px] max-h-[80vh] flex flex-col`,children:[(0,H.jsx)(P,{children:(0,H.jsx)(F,{children:$})}),(0,H.jsxs)(`div`,{className:`space-y-3 flex-1 overflow-hidden flex flex-col min-h-0`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5 px-1`,children:[(0,H.jsx)(E,{htmlFor:`table-name`,children:e(`table.dialog.tableName`)}),(0,H.jsx)(O,{id:`table-name`,value:S,onChange:e=>C(e.target.value),placeholder:e(`table.dialog.tableNamePlaceholder`),disabled:l})]}),N?(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-muted-foreground text-sm`,children:e(`table.dialog.loading`)}):(0,H.jsxs)(ee,{defaultValue:`schema`,className:`flex-1 min-h-0 flex flex-col`,children:[(0,H.jsxs)(v,{children:[(0,H.jsx)(x,{value:`schema`,children:e(`table.dialog.tabSchema`)}),(0,H.jsx)(x,{value:`indexes`,children:e(`table.dialog.tabIndexes`)}),ae.capabilities.tableProperties&&(0,H.jsx)(x,{value:`properties`,children:e(`table.dialog.tabProperties`)}),(0,H.jsx)(x,{value:`sql`,children:`SQL`})]}),(0,H.jsx)(y,{value:`schema`,className:`flex-1 min-h-0 overflow-auto border rounded-md`,children:(0,H.jsx)(re,{columns:w,onChange:T})}),(0,H.jsx)(y,{value:`indexes`,className:`flex-1 min-h-0 overflow-auto border rounded-md`,children:(0,H.jsx)(ie,{indexes:D,availableColumns:w,onChange:k})}),(0,H.jsx)(y,{value:`properties`,className:`flex-1 min-h-0 overflow-auto border rounded-md`,children:(0,H.jsx)(oe,{properties:j,onChange:M})}),(0,H.jsx)(y,{value:`sql`,className:`flex-1 min-h-0 border rounded-md`,children:(0,H.jsx)(se,{connectionId:Y,database:_,tableName:S,columns:w,indexes:D,properties:j})})]})]}),G&&(0,H.jsx)(`p`,{className:`px-1 text-xs text-destructive leading-relaxed`,children:G}),(0,H.jsxs)(te,{children:[(0,H.jsx)(o,{variant:`outline`,onClick:()=>Z(!1),children:e(`table.dialog.cancel`)}),(0,H.jsx)(o,{onClick:()=>void Q(),disabled:N||U||!S.trim(),children:U?e(`table.dialog.applying`):ce})]})]})})}export{ue as EditSchemaDialog};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{h as t,n}from"./ui-store-5IssrgmG.js";import{i as r,l as i,m as a,t as o}from"./button-B2EsmMJs.js";import{t as s}from"./chevron-up-CBnVjNE1.js";import{t as c}from"./connection-store-B85kbJpB.js";import{n as l}from"./query-store-BqBiylGA.js";import{n as u,o as d,s as f,t as p}from"./editor-registry-ukUyoekH.js";import{It as m,c as h,l as g,rt as _}from"./index-Tw24-4of.js";var v=e(t(),1),y=i();function b(){let{t:e}=a(),{activeDialog:t,closeDialog:i}=n(),[b,x]=(0,v.useState)(``),[S,C]=(0,v.useState)(``),[w,T]=(0,v.useState)(!1),[E,D]=(0,v.useState)(!1),[O,k]=(0,v.useState)(!1),[A,j]=(0,v.useState)(0),M=c(e=>e.activeConnectionId)??``,N=l(e=>M?e.activeTabId[M]:void 0)??``;if(t!==`find-replace`)return null;let P={query:b,caseSensitive:w,regex:E,wholeWord:O},F=M!==``&&N!==``&&b!==``;function I(){i()}function L(){j(F?u(M,N,P,`next`):0)}function R(){j(F?u(M,N,P,`prev`):0)}function z(){F&&j(f(M,N,P,S))}function B(){F&&(d(M,N,P,S),j(p(M,N,P)))}return(0,y.jsxs)(`div`,{className:`fixed top-12 right-4 z-50 bg-background border rounded-md shadow-lg p-3 w-[400px] space-y-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(g,{placeholder:e(`command.findReplace.findPlaceholder`),value:b,onChange:e=>x(e.target.value),onKeyDown:e=>{_(e)||(e.key===`Enter`&&(e.shiftKey?R():L()),e.key===`Escape`&&I())},className:`flex-1 h-7 text-sm`,autoFocus:!0}),(0,y.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap min-w-[60px] text-center`,children:A>0?e(`command.findReplace.found`,{count:A}):e(`command.findReplace.noResults`)}),(0,y.jsx)(o,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:R,title:e(`command.findReplace.previous`),children:(0,y.jsx)(s,{className:`h-4 w-4`})}),(0,y.jsx)(o,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:L,title:e(`command.findReplace.next`),children:(0,y.jsx)(m,{className:`h-4 w-4`})}),(0,y.jsx)(o,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:I,title:e(`command.findReplace.close`),children:(0,y.jsx)(r,{className:`h-4 w-4`})})]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(g,{placeholder:e(`command.findReplace.replacePlaceholder`),value:S,onChange:e=>C(e.target.value),onKeyDown:e=>{e.key===`Escape`&&I()},className:`flex-1 h-7 text-sm`}),(0,y.jsx)(o,{variant:`outline`,size:`sm`,className:`h-7 text-xs`,onClick:z,children:e(`command.findReplace.replace`)}),(0,y.jsx)(o,{variant:`outline`,size:`sm`,className:`h-7 text-xs`,onClick:B,children:e(`command.findReplace.all`)})]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,y.jsxs)(h,{className:`flex items-center gap-1.5 text-xs font-normal cursor-pointer`,children:[(0,y.jsx)(`input`,{type:`checkbox`,checked:w,onChange:e=>T(e.target.checked),className:`rounded border-input`}),e(`command.findReplace.caseSensitive`)]}),(0,y.jsxs)(h,{className:`flex items-center gap-1.5 text-xs font-normal cursor-pointer`,children:[(0,y.jsx)(`input`,{type:`checkbox`,checked:E,onChange:e=>D(e.target.checked),className:`rounded border-input`}),e(`command.findReplace.regex`)]}),(0,y.jsxs)(h,{className:`flex items-center gap-1.5 text-xs font-normal cursor-pointer`,children:[(0,y.jsx)(`input`,{type:`checkbox`,checked:O,onChange:e=>k(e.target.checked),className:`rounded border-input`}),e(`command.findReplace.wholeWord`)]})]})]})}export{b as FindReplaceDialog};
@@ -1 +1 @@
1
- import{n as e}from"./ui-store-5IssrgmG.js";import{l as t,m as n,t as r}from"./button-B2EsmMJs.js";import{t as i}from"./connection-store-D-Lp5EFj.js";import{c as a}from"./database-CfYjCIA2.js";import{a as o,i as s,n as c,o as l,t as u}from"./dialog-FBpgH0QJ.js";var d=t(),f=[`FLUSH HOSTS`,`FLUSH LOGS`,`FLUSH PRIVILEGES`,`FLUSH STATUS`,`FLUSH TABLES`,`FLUSH THREADS`,`FLUSH QUERY CACHE`,`FLUSH DES_KEY_FILE`,`FLUSH RELAY LOGS`,`FLUSH SLOW LOGS`,`FLUSH BINARY LOGS`,`FLUSH ENGINE LOGS`,`FLUSH ERROR LOGS`,`FLUSH GENERAL LOGS`,`FLUSH USER_RESOURCES`,`FLUSH OPTIMIZER_COSTS`];function p(){let e=i.getState();return e.activeConnections.find(t=>t.id===e.activeConnectionId)?.serverConnectionId??null}function m(){let{t}=n(),{activeDialog:i,closeDialog:m,setFooterMessage:h}=e(),g=i===`flush`;function _(e){e||m()}async function v(e){let n=p();if(!n){h(t(`command.noActiveConnection`));return}try{await a(n,e),h(t(`command.flush.executed`,{command:e}))}catch(n){h(t(`command.flush.executeError`,{command:e,message:n instanceof Error?n.message:String(n)}))}}return(0,d.jsx)(u,{open:g,onOpenChange:_,children:(0,d.jsxs)(c,{className:`sm:max-w-[500px]`,children:[(0,d.jsx)(o,{children:(0,d.jsx)(l,{children:t(`command.flush.title`)})}),(0,d.jsx)(`div`,{className:`grid grid-cols-2 gap-2 py-2`,children:f.map(e=>(0,d.jsx)(r,{variant:`outline`,size:`sm`,className:`justify-start text-xs h-8`,onClick:()=>{v(e)},children:e},e))}),(0,d.jsx)(s,{children:(0,d.jsx)(r,{variant:`outline`,onClick:()=>_(!1),children:t(`command.close`)})})]})})}export{m as FlushDialog};
1
+ import{n as e}from"./ui-store-5IssrgmG.js";import{l as t,m as n,t as r}from"./button-B2EsmMJs.js";import{t as i}from"./connection-store-B85kbJpB.js";import{c as a}from"./database-BSXLJRzV.js";import{a as o,i as s,n as c,o as l,t as u}from"./dialog-FBpgH0QJ.js";var d=t(),f=[`FLUSH HOSTS`,`FLUSH LOGS`,`FLUSH PRIVILEGES`,`FLUSH STATUS`,`FLUSH TABLES`,`FLUSH THREADS`,`FLUSH QUERY CACHE`,`FLUSH DES_KEY_FILE`,`FLUSH RELAY LOGS`,`FLUSH SLOW LOGS`,`FLUSH BINARY LOGS`,`FLUSH ENGINE LOGS`,`FLUSH ERROR LOGS`,`FLUSH GENERAL LOGS`,`FLUSH USER_RESOURCES`,`FLUSH OPTIMIZER_COSTS`];function p(){let e=i.getState();return e.activeConnections.find(t=>t.id===e.activeConnectionId)?.serverConnectionId??null}function m(){let{t}=n(),{activeDialog:i,closeDialog:m,setFooterMessage:h}=e(),g=i===`flush`;function _(e){e||m()}async function v(e){let n=p();if(!n){h(t(`command.noActiveConnection`));return}try{await a(n,e),h(t(`command.flush.executed`,{command:e}))}catch(n){h(t(`command.flush.executeError`,{command:e,message:n instanceof Error?n.message:String(n)}))}}return(0,d.jsx)(u,{open:g,onOpenChange:_,children:(0,d.jsxs)(c,{className:`sm:max-w-[500px]`,children:[(0,d.jsx)(o,{children:(0,d.jsx)(l,{children:t(`command.flush.title`)})}),(0,d.jsx)(`div`,{className:`grid grid-cols-2 gap-2 py-2`,children:f.map(e=>(0,d.jsx)(r,{variant:`outline`,size:`sm`,className:`justify-start text-xs h-8`,onClick:()=>{v(e)},children:e},e))}),(0,d.jsx)(s,{children:(0,d.jsx)(r,{variant:`outline`,onClick:()=>_(!1),children:t(`command.close`)})})]})})}export{m as FlushDialog};
@@ -1 +1 @@
1
- import{a as e,n as t}from"./ui-store-5IssrgmG.js";import{l as n,m as r,t as i}from"./button-B2EsmMJs.js";import{r as a,t as o}from"./i18n-BQcNT-sS.js";import{a as s,i as c,n as l,r as u,t as d}from"./select-CtfiGpCP.js";import{n as f}from"./settings-store-DzQ3BP5e.js";import{a as p,i as m,n as h,o as g,r as _,t as v}from"./dialog-FBpgH0QJ.js";import{t as y}from"./settings-controls-DyukG7E2.js";var b=n();function x(){let n=t(e=>e.activeDialog),x=t(e=>e.closeDialog),S=f(),{t:C}=r();return(0,b.jsx)(v,{open:n===`general-settings`,onOpenChange:e=>{e||x()},children:(0,b.jsxs)(h,{className:`sm:max-w-[560px]`,children:[(0,b.jsxs)(p,{children:[(0,b.jsx)(g,{children:C(`settings.general.title`)}),(0,b.jsx)(_,{children:C(`settings.general.description`)})]}),(0,b.jsxs)(`div`,{className:`grid gap-2`,children:[(0,b.jsx)(y,{id:`s-history`,checked:S.persistQueryHistory,onChange:e=>S.setPersistQueryHistory(e),label:C(`settings.persistHistory`),hint:C(`settings.persistHistoryHint`)}),(0,b.jsxs)(`div`,{className:`grid grid-cols-[1fr_200px] items-center gap-3 rounded-md border p-3`,children:[(0,b.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,b.jsx)(`span`,{className:`text-sm font-medium`,children:C(`settings.language`)}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:C(`settings.languageHint`)})]}),(0,b.jsxs)(d,{value:S.locale,onValueChange:e=>S.setLocale(e),children:[(0,b.jsx)(c,{children:(0,b.jsx)(s,{})}),(0,b.jsxs)(l,{children:[(0,b.jsx)(u,{value:`auto`,children:C(`language.auto`,{name:C(`language.${a()}`)})}),o.map(e=>(0,b.jsx)(u,{value:e,children:C(`language.${e}`)},e))]})]})]}),(0,b.jsx)(y,{id:`s-analytics`,checked:S.analyticsEnabled,onChange:S.setAnalyticsEnabled,label:C(`settings.analytics`),hint:e()?C(`settings.analyticsHint`):C(`settings.analyticsUnavailableHint`)})]}),(0,b.jsx)(m,{children:(0,b.jsx)(i,{onClick:x,children:C(`settings.done`)})})]})})}export{x as GeneralSettingsDialog};
1
+ import{a as e,n as t}from"./ui-store-5IssrgmG.js";import{l as n,m as r,t as i}from"./button-B2EsmMJs.js";import{r as a,t as o}from"./i18n-C0aLwQ_k.js";import{a as s,i as c,n as l,r as u,t as d}from"./select-DEqoX1sU.js";import{n as f}from"./settings-store-DzQ3BP5e.js";import{a as p,i as m,n as h,o as g,r as _,t as v}from"./dialog-FBpgH0QJ.js";import{t as y}from"./settings-controls-BepR6gzL.js";var b=n();function x(){let n=t(e=>e.activeDialog),x=t(e=>e.closeDialog),S=f(),{t:C}=r();return(0,b.jsx)(v,{open:n===`general-settings`,onOpenChange:e=>{e||x()},children:(0,b.jsxs)(h,{className:`sm:max-w-[560px]`,children:[(0,b.jsxs)(p,{children:[(0,b.jsx)(g,{children:C(`settings.general.title`)}),(0,b.jsx)(_,{children:C(`settings.general.description`)})]}),(0,b.jsxs)(`div`,{className:`grid gap-2`,children:[(0,b.jsx)(y,{id:`s-history`,checked:S.persistQueryHistory,onChange:e=>S.setPersistQueryHistory(e),label:C(`settings.persistHistory`),hint:C(`settings.persistHistoryHint`)}),(0,b.jsxs)(`div`,{className:`grid grid-cols-[1fr_200px] items-center gap-3 rounded-md border p-3`,children:[(0,b.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,b.jsx)(`span`,{className:`text-sm font-medium`,children:C(`settings.language`)}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:C(`settings.languageHint`)})]}),(0,b.jsxs)(d,{value:S.locale,onValueChange:e=>S.setLocale(e),children:[(0,b.jsx)(c,{children:(0,b.jsx)(s,{})}),(0,b.jsxs)(l,{children:[(0,b.jsx)(u,{value:`auto`,children:C(`language.auto`,{name:C(`language.${a()}`)})}),o.map(e=>(0,b.jsx)(u,{value:e,children:C(`language.${e}`)},e))]})]})]}),(0,b.jsx)(y,{id:`s-analytics`,checked:S.analyticsEnabled,onChange:S.setAnalyticsEnabled,label:C(`settings.analytics`),hint:e()?C(`settings.analyticsHint`):C(`settings.analyticsUnavailableHint`)})]}),(0,b.jsx)(m,{children:(0,b.jsx)(i,{onClick:x,children:C(`settings.done`)})})]})})}export{x as GeneralSettingsDialog};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,h as n,n as r,t as i}from"./ui-store-5IssrgmG.js";import{l as a,m as ee,t as o}from"./button-B2EsmMJs.js";import{a as s,i as c,n as l,r as u,t as d}from"./select-DEqoX1sU.js";import{t as f}from"./connection-store-B85kbJpB.js";import{a as p}from"./database-BSXLJRzV.js";import{n as m}from"./engine-DjP-Sw-S.js";import{a as te,d as ne}from"./query-execution-BeDEQ-3M.js";import{Ot as re,at as h,c as g,ct as ie,l as ae,pt as _}from"./index-Tw24-4of.js";import{a as oe,i as se,n as ce,o as v,r as y,t as le}from"./dialog-FBpgH0QJ.js";var b=e(n(),1),ue=[`SUM`,`AVG`,`MIN`,`MAX`],x=`row_count`;function S(e,t){if(t.columns.length===0)return``;let n=t=>e.quoteIdentifier(t),r=t.columns.map(n),i=[...r,`COUNT(*) AS ${n(x)}`];if(t.aggregate){let{fn:e,column:r}=t.aggregate;i.push(`${e}(${n(r)}) AS ${n(`${e.toLowerCase()}_${r}`)}`)}let a=[];return t.where&&a.push(t.where),a.push(`GROUP BY ${r.join(`, `)}`),t.minCount&&t.minCount>1&&a.push(`HAVING COUNT(*) >= ${Math.floor(t.minCount)}`),a.push(`ORDER BY COUNT(*) DESC`),t.limit>0&&a.push(e.limitClause(t.limit)),e.getQuery(`SELECT_TABLE`,t.database,t.table,i.join(`, `),a.join(` `))}function C(e){let t=new Set;for(let n of e){let e=n.columns[0];e&&t.add(e.toLowerCase())}return t}function w(e,t){return t.has(e.toLowerCase())}function de(e,t){let n=C(t);return e.some(e=>w(e,n))}var T=a(),E=`none`,fe=/\b(int|dec|numeric|number|float|double|real|money|serial)/i;function D(){let{t:e}=ee(),n=r(e=>e.activeDialog),a=r(e=>e.closeDialog),x=i(`group-by`),D=n===`group-by`,O=f(e=>e.activeConnections),pe=f(e=>e.activeConnectionId),me=(0,b.useMemo)(()=>O.filter(e=>e.serverConnectionId),[O]),[k,he]=(0,b.useState)(()=>x?.connectionId??pe??``),[A,j]=(0,b.useState)(()=>x?.database??``),[M,N]=(0,b.useState)(()=>x?.table??``),[P,F]=(0,b.useState)([]),[I,L]=(0,b.useState)([]),R=x&&k===x.connectionId&&A===x.database&&M===x.table?x.where??``:``,[z,ge]=(0,b.useState)([]),[B,_e]=(0,b.useState)([]),[V,H]=(0,b.useState)(()=>x?.column?[x.column]:[]),[U,ve]=(0,b.useState)(E),[W,ye]=(0,b.useState)(``),[G,be]=(0,b.useState)(`1`),[K,xe]=(0,b.useState)(!0),[q,J]=(0,b.useState)(``),[Se,Y]=(0,b.useState)(!1),X=e=>f.getState().activeConnections.find(t=>t.id===e)?.serverConnectionId;(0,b.useEffect)(()=>{if(!D||!k)return;let e=X(k);if(!e)return;let t=!1;return(async()=>{try{let n=await m(k).introspect.listDatabases(p(e));if(t)return;F(n),j(e=>e&&n.includes(e)?e:n[0]??``)}catch(e){t||J(e instanceof Error?e.message:String(e))}})(),()=>{t=!0}},[D,k]),(0,b.useEffect)(()=>{if(!D||!k||!A)return;let e=X(k);if(!e)return;let t=!1;return(async()=>{try{let n=await m(k).introspect.listTables(p(e),A);if(t)return;let r=n.map(e=>e.name);L(r),N(e=>e&&r.includes(e)?e:r[0]??``)}catch(e){t||J(e instanceof Error?e.message:String(e))}})(),()=>{t=!0}},[D,k,A]),(0,b.useEffect)(()=>{if(!D||!k||!M)return;let e=X(k);if(!e)return;let t=!1;return(async()=>{let n=p(e),r=m(k).introspect;try{let[e,i]=await Promise.all([r.listColumns(n,A,M),r.listIndexes(n,A,M).catch(()=>[])]);if(t)return;ge(e),_e(i),H(t=>t.filter(t=>e.some(e=>e.name===t)))}catch(e){t||J(e instanceof Error?e.message:String(e))}})(),()=>{t=!0}},[D,k,A,M]);let Ce=(0,b.useMemo)(()=>C(B),[B]),we=(0,b.useMemo)(()=>z.filter(e=>fe.test(e.type)),[z]),Z=(0,b.useMemo)(()=>!k||V.length===0?``:S(m(k),{database:A,table:M,columns:V,aggregate:U!==E&&W?{fn:U,column:W}:null,where:K?R:``,minCount:Number(G)||1,limit:ne()}),[k,A,M,V,U,W,G,K,R]),Q=V.length>0&&B.length>0&&!de(V,B);function Te(e){H(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}function $(e){t(`group_by`,{action:e,dbms:m(k).id,columns:V.length,aggregate:U,filtered:!!(K&&R),indexed:!Q})}function Ee(){Z&&($(`open`),h(k,Z,A,e(`database.groupBy.tabTitle`,{table:M})),a())}async function De(){if(!Z)return;$(`run`),Y(!0);let t=h(k,Z,A,e(`database.groupBy.tabTitle`,{table:M}));a();try{await te(k,t)}finally{Y(!1)}}return(0,T.jsx)(le,{open:D,onOpenChange:e=>{e||a()},children:(0,T.jsxs)(ce,{className:`flex max-h-[85vh] flex-col sm:max-w-[720px]`,children:[(0,T.jsxs)(oe,{children:[(0,T.jsx)(v,{children:e(`database.groupBy.title`)}),(0,T.jsx)(y,{children:e(`database.groupBy.description`,{table:M})})]}),q&&(0,T.jsx)(`p`,{className:`rounded-md border border-destructive/40 px-3 py-2 text-xs text-destructive`,children:q}),(0,T.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,T.jsxs)(`div`,{className:`space-y-1`,children:[(0,T.jsx)(g,{className:`text-xs`,children:e(`database.groupBy.connection`)}),(0,T.jsxs)(d,{value:k,onValueChange:he,children:[(0,T.jsx)(c,{className:`h-8 text-xs`,children:(0,T.jsx)(s,{})}),(0,T.jsx)(l,{children:me.map(e=>(0,T.jsx)(u,{value:e.id,children:e.hostName||e.host||e.file||e.id},e.id))})]})]}),(0,T.jsxs)(`div`,{className:`space-y-1`,children:[(0,T.jsx)(g,{className:`text-xs`,children:e(`database.groupBy.database`)}),(0,T.jsxs)(d,{value:A,onValueChange:j,children:[(0,T.jsx)(c,{className:`h-8 text-xs`,children:(0,T.jsx)(s,{})}),(0,T.jsx)(l,{children:P.map(e=>(0,T.jsx)(u,{value:e,children:e},e))})]})]}),(0,T.jsxs)(`div`,{className:`space-y-1`,children:[(0,T.jsx)(g,{className:`text-xs`,children:e(`database.groupBy.table`)}),(0,T.jsxs)(d,{value:M,onValueChange:N,children:[(0,T.jsx)(c,{className:`h-8 text-xs`,children:(0,T.jsx)(s,{})}),(0,T.jsx)(l,{children:I.map(e=>(0,T.jsx)(u,{value:e,children:e},e))})]})]})]}),(0,T.jsxs)(`div`,{className:`grid min-h-0 grid-cols-[1fr_1fr] gap-4`,children:[(0,T.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-1.5`,children:[(0,T.jsx)(g,{className:`text-xs`,children:e(`database.groupBy.columns`)}),(0,T.jsx)(ie,{className:`h-[260px] rounded-md border`,children:(0,T.jsx)(`ul`,{className:`p-1`,children:z.map(t=>{let n=w(t.name,Ce);return(0,T.jsx)(`li`,{children:(0,T.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded px-2 py-1 text-xs hover:bg-accent`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:V.includes(t.name),onChange:()=>Te(t.name)}),(0,T.jsx)(`span`,{className:`truncate font-medium`,children:t.name}),(0,T.jsx)(`span`,{className:`truncate text-muted-foreground`,children:t.type}),n&&(0,T.jsx)(re,{className:`ml-auto h-3 w-3 shrink-0 text-muted-foreground`,"aria-label":e(`database.groupBy.indexed`)})]})},t.name)})})})]}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,T.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,T.jsx)(g,{className:`text-xs`,children:e(`database.groupBy.aggregate`)}),(0,T.jsxs)(`div`,{className:`flex gap-2`,children:[(0,T.jsxs)(d,{value:U,onValueChange:ve,children:[(0,T.jsx)(c,{className:`h-8 w-[110px] text-xs`,children:(0,T.jsx)(s,{})}),(0,T.jsxs)(l,{children:[(0,T.jsx)(u,{value:E,children:e(`database.groupBy.countOnly`)}),ue.map(e=>(0,T.jsx)(u,{value:e,children:e},e))]})]}),(0,T.jsxs)(d,{value:W,onValueChange:ye,disabled:U===E,children:[(0,T.jsx)(c,{className:`h-8 flex-1 text-xs`,children:(0,T.jsx)(s,{placeholder:e(`database.groupBy.column`)})}),(0,T.jsx)(l,{children:we.map(e=>(0,T.jsx)(u,{value:e.name,children:e.name},e.name))})]})]})]}),(0,T.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,T.jsx)(g,{htmlFor:`gb-min`,className:`text-xs`,children:e(`database.groupBy.minCount`)}),(0,T.jsx)(ae,{id:`gb-min`,type:`number`,min:1,value:G,onChange:e=>be(e.target.value),className:`h-8 text-xs`})]}),R&&(0,T.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:K,onChange:e=>xe(e.target.checked)}),e(`database.groupBy.useFilter`)]}),Q&&(0,T.jsxs)(`p`,{className:`flex gap-1.5 rounded-md border border-dashed px-2 py-1.5 text-xs text-muted-foreground`,children:[(0,T.jsx)(_,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,T.jsx)(`span`,{children:e(`database.groupBy.noIndexWarning`)})]})]})]}),(0,T.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,T.jsx)(g,{className:`text-xs`,children:e(`database.groupBy.preview`)}),(0,T.jsx)(`pre`,{className:`max-h-[120px] overflow-auto rounded-md border bg-muted p-2 font-mono text-xs whitespace-pre-wrap`,children:Z||e(`database.groupBy.pickColumn`)})]}),(0,T.jsxs)(se,{children:[(0,T.jsx)(o,{variant:`outline`,onClick:a,children:e(`command.close`)}),(0,T.jsx)(o,{variant:`outline`,onClick:Ee,disabled:!Z,children:e(`database.groupBy.openInTab`)}),(0,T.jsx)(o,{onClick:De,disabled:!Z||Se,children:e(`database.groupBy.run`)})]})]})})}export{D as GroupByDialog};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{h as t,n,t as r}from"./ui-store-5IssrgmG.js";import{l as i,m as a,t as o}from"./button-B2EsmMJs.js";import{B as s,R as c,c as l,t as u,z as d}from"./index-Tw24-4of.js";import{a as f,i as p,n as m,o as h,r as g,t as _}from"./dialog-FBpgH0QJ.js";import{t as v}from"./pro-upsell-DhbKIX46.js";var y=e(t(),1),b=i();function x(e){return e.state===`invalid`?e.reason===`no-public-key`?`pro.notConfigured`:e.reason===`no-webcrypto`?`pro.noWebcrypto`:`pro.invalidKey`:null}function S(){let e=n(e=>e.activeDialog),t=n(e=>e.closeDialog),i=r(`license`),{key:S,status:C,activate:w,clear:T}=c(),{t:E}=a(),[D,O]=(0,y.useState)(S),[k,A]=(0,y.useState)(!1),[j,M]=(0,y.useState)(!i?.feature||!!S),N=(0,y.useRef)(null),[P,F]=(0,y.useState)(d()?null:E(`pro.notConfigured`)),I=async()=>{A(!0);let e=x(await w(D.trim()));F(e?E(e):null),A(!1)},L=C.state===`valid`||C.state===`expired`?C.claim:null,R=i?.feature?E(`pro.blocked`,{feature:E(`pro.features.${i.feature}`)}):null;return(0,b.jsx)(_,{open:e===`license`,onOpenChange:e=>{e||t()},children:(0,b.jsxs)(m,{className:`max-h-[85vh] overflow-y-auto sm:max-w-[560px]`,onOpenAutoFocus:e=>{N.current&&(e.preventDefault(),N.current.focus())},children:[(0,b.jsx)(f,{children:(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,b.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,b.jsx)(u,{size:44}),(0,b.jsx)(s,{className:`absolute -right-2 -bottom-1 ml-0`})]}),(0,b.jsxs)(`div`,{className:`grid gap-1`,children:[(0,b.jsx)(h,{children:E(`pro.licenseTitle`)}),(0,b.jsx)(g,{children:R??E(`pro.licenseDescription`)})]})]})}),(0,b.jsxs)(`div`,{className:`grid gap-3 text-sm`,children:[C.state===`valid`&&(0,b.jsxs)(`div`,{className:`rounded-md border border-emerald-500/40 bg-emerald-500/5 p-3 text-xs`,children:[(0,b.jsx)(`p`,{className:`font-medium text-emerald-600 dark:text-emerald-400`,children:E(`pro.active`)}),(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:E(`pro.licensedTo`,{email:L?.sub})}),(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:E(`pro.validUntil`,{date:L?.exp})})]}),C.state===`expired`&&(0,b.jsx)(`p`,{className:`rounded-md border border-amber-500/40 bg-amber-500/5 p-3 text-xs text-amber-600 dark:text-amber-400`,children:E(`pro.expiredOn`,{date:L?.exp})}),R&&(0,b.jsx)(v,{highlight:i?.feature,innerRef:N}),!j&&(0,b.jsx)(`button`,{type:`button`,onClick:()=>M(!0),className:`w-fit rounded-sm text-xs text-muted-foreground underline underline-offset-2 hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,children:E(`pro.haveKey`)}),(0,b.jsxs)(`div`,{className:j?`grid gap-1.5`:`hidden`,children:[(0,b.jsx)(l,{htmlFor:`license-key`,children:E(`pro.keyLabel`)}),(0,b.jsx)(`textarea`,{id:`license-key`,value:D,onChange:e=>{O(e.target.value),F(null)},spellCheck:!1,rows:3,className:`w-full resize-none rounded-md border bg-transparent p-2 font-mono text-xs outline-none focus-visible:ring-1 focus-visible:ring-ring`}),P&&(0,b.jsx)(`p`,{className:`text-xs text-destructive`,children:P})]})]}),(0,b.jsxs)(p,{children:[S&&(0,b.jsx)(o,{variant:`ghost`,onClick:()=>{T(),O(``)},children:E(`pro.remove`)}),j&&(0,b.jsx)(o,{disabled:k||!D.trim()||D.trim()===S,onClick:()=>{I()},children:E(`pro.activate`)}),(0,b.jsx)(o,{variant:`secondary`,onClick:t,children:E(`settings.done`)})]})]})})}export{S as LicenseDialog};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,h as n,n as r,t as i}from"./ui-store-5IssrgmG.js";import{l as a,m as o,t as s}from"./button-B2EsmMJs.js";import{a as c,i as l,n as u,r as d,t as f}from"./select-DEqoX1sU.js";import{t as p}from"./connection-store-B85kbJpB.js";import{a as m}from"./database-BSXLJRzV.js";import{n as h}from"./engine-DjP-Sw-S.js";import{t as ee}from"./pro-usage-BxwRZwtM.js";import{X as g,Z as _,c as v,l as y}from"./index-Tw24-4of.js";import{a as b,i as x,n as S,o as C,t as w}from"./dialog-FBpgH0QJ.js";var T=e(n(),1),E=a(),D=e=>e instanceof Error?e.message:String(e);function O(){let{t:e}=o(),n=r(e=>e.activeDialog),a=r(e=>e.closeDialog),O=i(`link-column`),k=n===`link-column`&&!!O,A=O?.connectionId??``,j=p(e=>e.activeConnections),M=j.filter(e=>e.serverConnectionId),N=_(e=>e.links),P=_(e=>e.setLink),F=_(e=>e.removeLink),I=O?g(N,A,O.database,O.table).find(e=>e.column===O.column)??null:null,[L,R]=(0,T.useState)(I?.targetConnectionId??A),z=j.find(e=>e.id===L)?.serverConnectionId,[B,V]=(0,T.useState)([]),[H,U]=(0,T.useState)([]),[W,G]=(0,T.useState)([]),[K,q]=(0,T.useState)(I?.targetDatabase??O?.database??``),[J,Y]=(0,T.useState)(I?.targetTable??``),[X,Z]=(0,T.useState)(I?.targetColumn??``),[Q,$]=(0,T.useState)(null);if((0,T.useEffect)(()=>{if(!k||!z)return;let e=!1;return(async()=>{try{let t=await h(L).introspect.listDatabases(m(z));if(e)return;V(t),q(e=>t.includes(e)?e:t[0]??``)}catch(t){e||$(D(t))}})(),()=>{e=!0}},[k,z,L]),(0,T.useEffect)(()=>{if(!k||!z||!K)return;let e=!1;return(async()=>{try{let t=await h(L).introspect.listTables(m(z),K);if(e)return;U(t.map(e=>e.name))}catch(t){e||$(D(t))}})(),()=>{e=!0}},[k,z,L,K]),(0,T.useEffect)(()=>{if(!k||!z||!K||!J)return;let e=!1;return(async()=>{try{let t=await h(L).introspect.listColumns(m(z),K,J);if(e)return;G(t.map(e=>e.name)),Z(e=>t.some(t=>t.name===e)?e:t.find(e=>e.key===`PRI`)?.name??t[0]?.name??``)}catch(t){e||$(D(t))}})(),()=>{e=!0}},[k,z,L,K,J]),!O)return null;function te(){if(!O||!K||!J||!X)return;let e=L!==A;P(A,{database:O.database,table:O.table,column:O.column,...e?{targetConnectionId:L}:{},targetDatabase:K,targetTable:J,targetColumn:X}),ee(`column_link`),t(`column_link_set`,{dbms:h(A).id,target_dbms:h(L).id,cross_database:K!==O.database,cross_connection:e}),a()}function ne(){O&&(F(A,O),a())}return(0,E.jsx)(w,{open:k,onOpenChange:e=>{e||a()},children:(0,E.jsxs)(S,{className:`sm:max-w-[460px]`,children:[(0,E.jsx)(b,{children:(0,E.jsx)(C,{children:e(`result.link.title`)})}),(0,E.jsxs)(`div`,{className:`space-y-4`,children:[(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(v,{children:e(`result.link.source`)}),(0,E.jsx)(y,{value:`${O.database}.${O.table}.${O.column}`,disabled:!0})]}),(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`result.link.hint`)}),(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(v,{htmlFor:`link-conn`,children:e(`result.link.targetConnection`)}),(0,E.jsxs)(f,{value:L,onValueChange:e=>{R(e),Y(``),U([]),G([])},children:[(0,E.jsx)(l,{id:`link-conn`,className:`w-full`,children:(0,E.jsx)(c,{})}),(0,E.jsx)(u,{children:M.map(e=>(0,E.jsx)(d,{value:e.id,children:e.hostName||e.host||e.file||e.id},e.id))})]})]}),(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(v,{htmlFor:`link-db`,children:e(`result.link.targetDatabase`)}),(0,E.jsxs)(f,{value:K,onValueChange:e=>{q(e),Y(``),G([])},children:[(0,E.jsx)(l,{id:`link-db`,className:`w-full`,children:(0,E.jsx)(c,{})}),(0,E.jsx)(u,{children:B.map(e=>(0,E.jsx)(d,{value:e,children:e},e))})]})]}),(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(v,{htmlFor:`link-table`,children:e(`result.link.targetTable`)}),(0,E.jsxs)(f,{value:J,onValueChange:Y,disabled:H.length===0,children:[(0,E.jsx)(l,{id:`link-table`,className:`w-full`,children:(0,E.jsx)(c,{placeholder:e(`result.link.pickTable`)})}),(0,E.jsx)(u,{children:H.map(e=>(0,E.jsx)(d,{value:e,children:e},e))})]})]}),(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(v,{htmlFor:`link-column`,children:e(`result.link.targetColumn`)}),(0,E.jsxs)(f,{value:X,onValueChange:Z,disabled:W.length===0,children:[(0,E.jsx)(l,{id:`link-column`,className:`w-full`,children:(0,E.jsx)(c,{placeholder:e(`result.link.pickColumn`)})}),(0,E.jsx)(u,{children:W.map(e=>(0,E.jsx)(d,{value:e,children:e},e))})]})]}),Q&&(0,E.jsx)(`p`,{className:`text-xs text-destructive`,children:Q})]}),(0,E.jsxs)(x,{children:[I&&(0,E.jsx)(s,{variant:`destructive`,onClick:ne,className:`mr-auto`,children:e(`result.link.remove`)}),(0,E.jsx)(s,{variant:`outline`,onClick:a,children:e(`result.link.cancel`)}),(0,E.jsx)(s,{onClick:te,disabled:!K||!J||!X,children:e(`result.link.save`)})]})]})})}export{O as LinkColumnDialog};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,h as n,i as r,n as i}from"./ui-store-5IssrgmG.js";import{l as a,m as o,t as s}from"./button-B2EsmMJs.js";import{i as c,t as l}from"./connection-store-B85kbJpB.js";import{n as u}from"./settings-store-DzQ3BP5e.js";import{n as d,t as f}from"./query-store-BqBiylGA.js";import{Q as p,Zt as m,at as h,bt as g,ct as _,l as v,mt as y}from"./index-Tw24-4of.js";import{a as b,i as x,n as ee,o as S,r as C,t as w}from"./dialog-FBpgH0QJ.js";var T=e(n(),1),E=a(),D={execute:`command.localHistory.reason.execute`,edit:`command.localHistory.reason.edit`,replaced:`command.localHistory.reason.replaced`,restore:`command.localHistory.reason.restore`,close:`command.localHistory.reason.close`},O=Object.freeze([]);function k(e){let t=(Date.now()-e)/36e5;return t<1?`<1h`:t<24?`1-24h`:t<168?`1-7d`:`7d+`}function A(){let{t:e}=o(),n=i(e=>e.activeDialog),a=i(e=>e.closeDialog),A=i(e=>e.setFooterMessage),j=l(e=>e.activeConnectionId),M=d(e=>j?e.activeTabId[j]:null),N=d(e=>j?e.tabs[j]??f:f),P=c(e=>j?e.revisions[j]??O:O),F=u(e=>e.persistQueryHistory),I=p(e=>e.themeId),L=I===`light`||I===`light-blue`||I===`solarized-light`?`vs`:`vs-dark`,[R,z]=(0,T.useState)(!0),[B,V]=(0,T.useState)(``),[H,U]=(0,T.useState)(null),[W,G]=(0,T.useState)(`current`),K=N.find(e=>e.id===M),q=n===`local-history`;(0,T.useEffect)(()=>{if(!q)return;let e=M?P.filter(e=>e.docId===M).length:0;t(`local_history_open`,{revisions:r(P.length),tab_revisions:r(e)})},[q]);let J=(0,T.useMemo)(()=>{let e=B.trim().toLowerCase();return P.filter(t=>R&&M&&t.docId!==M?!1:!e||t.text.toLowerCase().includes(e)||t.title.toLowerCase().includes(e))},[P,B,R,M]),Y=K?.query??``,X=J.find(e=>e.id===H)??J.find(e=>e.text!==Y)??J[0],Z=(0,T.useMemo)(()=>{if(!X)return;let e=P.filter(e=>e.docId===X.docId);return e[e.findIndex(e=>e.id===X.id)+1]},[P,X]),Q=W===`current`?Y:Z?.text??``;function $(e,n){t(`local_history_recover`,{action:e,reason:n.reason,age:k(n.timestamp),same_tab:n.docId===M,compare:W})}function te(){if(!j||!M||!X)return;$(`restore`,X);let t=d.getState();t.captureRevision(j,M,`restore`),t.setEditorContent(j,M,X.text),A(e(`command.localHistory.restored`)),a()}function ne(){!j||!X||($(`new_tab`,X),h(j,X.text,X.database,X.title),A(e(`command.localHistory.openedInTab`)),a())}function re(e){j&&(c.getState().removeRevision(j,e.id),H===e.id&&U(null))}function ie(){j&&(c.getState().clearRevisions(j),U(null))}return(0,E.jsx)(w,{open:q,onOpenChange:e=>{e||a()},children:(0,E.jsxs)(ee,{className:`flex max-h-[85vh] flex-col sm:max-w-[1000px]`,children:[(0,E.jsxs)(b,{children:[(0,E.jsx)(S,{children:e(`command.localHistory.title`)}),(0,E.jsx)(C,{children:e(`command.localHistory.description`)})]}),!F&&(0,E.jsx)(`p`,{className:`rounded-md border border-dashed px-3 py-2 text-xs text-muted-foreground`,children:e(`command.localHistory.notPersisted`)}),(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,E.jsxs)(`div`,{className:`relative min-w-[200px] flex-1`,children:[(0,E.jsx)(g,{className:`absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,E.jsx)(v,{value:B,onChange:e=>V(e.target.value),placeholder:e(`command.localHistory.searchPlaceholder`),className:`h-8 pl-7 text-xs`})]}),(0,E.jsxs)(`div`,{className:`flex overflow-hidden rounded-md border`,children:[(0,E.jsx)(`button`,{type:`button`,onClick:()=>z(!0),className:`px-2 py-1 text-xs ${R?`bg-accent`:`hover:bg-accent/50`}`,children:e(`command.localHistory.scopeTab`)}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>z(!1),className:`border-l px-2 py-1 text-xs ${R?`hover:bg-accent/50`:`bg-accent`}`,children:e(`command.localHistory.scopeAll`)})]}),(0,E.jsxs)(`div`,{className:`flex overflow-hidden rounded-md border`,children:[(0,E.jsx)(`button`,{type:`button`,onClick:()=>G(`current`),className:`px-2 py-1 text-xs ${W===`current`?`bg-accent`:`hover:bg-accent/50`}`,children:e(`command.localHistory.compareCurrent`)}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>G(`previous`),className:`border-l px-2 py-1 text-xs ${W===`previous`?`bg-accent`:`hover:bg-accent/50`}`,children:e(`command.localHistory.comparePrevious`)})]})]}),J.length===0?(0,E.jsx)(`div`,{className:`py-10 text-center text-sm text-muted-foreground`,children:P.length===0?e(`command.localHistory.empty`):e(`command.localHistory.noMatch`)}):(0,E.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[260px_1fr] gap-3`,children:[(0,E.jsx)(_,{className:`h-[440px] rounded-md border`,children:(0,E.jsx)(`ul`,{className:`divide-y`,children:J.map(t=>(0,E.jsxs)(`li`,{className:`group relative`,children:[(0,E.jsxs)(`button`,{type:`button`,onClick:()=>U(t.id),className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 pr-8 text-left text-xs hover:bg-accent ${t.id===X?.id?`bg-accent`:``}`,children:[(0,E.jsx)(`span`,{className:`font-medium`,children:new Date(t.timestamp).toLocaleString()}),(0,E.jsxs)(`span`,{className:`w-full truncate text-muted-foreground`,children:[t.title,` · `,e(D[t.reason]),` · `,e(`command.localHistory.chars`,{count:t.text.length})]})]}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>re(t),title:e(`command.localHistory.delete`),className:`absolute right-1.5 top-1.5 rounded p-1 text-muted-foreground opacity-0 hover:bg-destructive/10 hover:text-destructive group-hover:opacity-100`,children:(0,E.jsx)(y,{className:`h-3.5 w-3.5`})})]},t.id))})}),(0,E.jsxs)(`div`,{className:`flex h-[440px] flex-col overflow-hidden rounded-md border`,children:[(0,E.jsx)(`div`,{className:`border-b bg-muted/40 px-3 py-1.5 text-xs text-muted-foreground`,children:W===`current`?e(`command.localHistory.diffAgainstCurrent`):Z?e(`command.localHistory.diffAgainstPrevious`,{time:new Date(Z.timestamp).toLocaleString()}):e(`command.localHistory.noPrevious`)}),(0,E.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,E.jsx)(m,{language:`sql`,theme:L,original:X?.text??``,modified:Q,options:{readOnly:!0,renderSideBySide:!1,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12,renderOverviewRuler:!1}})})]})]}),(0,E.jsxs)(x,{className:`sm:justify-between`,children:[(0,E.jsx)(s,{variant:`ghost`,onClick:ie,disabled:P.length===0,children:e(`command.localHistory.clearAll`)}),(0,E.jsxs)(`div`,{className:`flex gap-2`,children:[(0,E.jsx)(s,{variant:`outline`,onClick:a,children:e(`command.close`)}),(0,E.jsx)(s,{variant:`outline`,onClick:ne,disabled:!X,children:e(`command.localHistory.openInNewTab`)}),(0,E.jsx)(s,{onClick:te,disabled:!X||!K,children:e(`command.localHistory.restore`)})]})]})]})})}export{A as LocalHistoryDialog};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{h as t,n}from"./ui-store-5IssrgmG.js";import{l as r,m as i,t as a}from"./button-B2EsmMJs.js";import{S as o,p as s}from"./tunneling-B7lL9I14.js";import{Lt as c,Mt as l}from"./index-Tw24-4of.js";import{a as u,i as d,n as f,o as p,r as m,t as h}from"./dialog-FBpgH0QJ.js";var g=e(t(),1),_=r();function v({text:e,label:t}){let[n,r]=(0,g.useState)(!1),i=(0,g.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1600)})},[e]);return(0,_.jsxs)(`div`,{className:`grid gap-1`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,_.jsx)(`span`,{className:`text-xs font-medium`,children:t}),(0,_.jsx)(a,{variant:`ghost`,size:`sm`,className:`h-6 gap-1 px-2 text-xs`,onClick:i,children:n?(0,_.jsx)(c,{className:`size-3`}):(0,_.jsx)(l,{className:`size-3`})})]}),(0,_.jsx)(`pre`,{"data-selectable":!0,className:`max-h-32 overflow-auto whitespace-pre-wrap break-all rounded-md border bg-muted/40 p-2 text-[11px] leading-snug`,children:e})]})}function y(){let e=n(e=>e.activeDialog),t=n(e=>e.closeDialog),{t:r}=i(),[c,l]=(0,g.useState)(null),[y,b]=(0,g.useState)(null),[x,S]=(0,g.useState)(!1),C=e===`mcp-setup`;(0,g.useEffect)(()=>{C&&s().then(e=>{l(e),S(!1)}).catch(e=>b(e instanceof Error?e.message:String(e)))},[C]);let w=(0,g.useCallback)(()=>{o().then(()=>{l(null),S(!0)})},[]),T=c?`claude mcp add --transport http planche ${c.url} \\\n -H "Authorization: Bearer ${c.token}"`:``,E=c?JSON.stringify({mcpServers:{planche:{type:`http`,url:c.url,headers:{Authorization:`Bearer ${c.token}`}}}},null,2):``;return(0,_.jsx)(h,{open:C,onOpenChange:e=>{e||t()},children:(0,_.jsxs)(f,{className:`sm:max-w-[620px]`,children:[(0,_.jsxs)(u,{children:[(0,_.jsx)(p,{children:r(`mcp.title`)}),(0,_.jsx)(m,{children:r(`mcp.description`)})]}),(0,_.jsxs)(`div`,{className:`grid gap-3`,children:[(0,_.jsx)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1.5 text-xs`,children:[[`readsLabel`,`reads`],[`writesLabel`,`writes`],[`needsLabel`,`needs`],[`tokenLabel`,`token`]].map(([e,t])=>(0,_.jsxs)(g.Fragment,{children:[(0,_.jsx)(`dt`,{className:`font-medium`,children:r(`mcp.${e}`)}),(0,_.jsx)(`dd`,{className:`text-muted-foreground`,children:r(`mcp.${t}`)})]},e))}),y&&(0,_.jsx)(`p`,{className:`rounded-md border border-destructive/40 p-2 text-xs text-destructive`,children:y}),x&&(0,_.jsx)(`p`,{className:`rounded-md border p-2 text-xs text-muted-foreground`,children:r(`mcp.revoked`)}),c&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(v,{text:T,label:r(`mcp.command`)}),(0,_.jsx)(v,{text:E,label:r(`mcp.json`)}),(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`mcp.stored`,{path:c.path})})]})]}),(0,_.jsxs)(d,{children:[c&&(0,_.jsx)(a,{variant:`ghost`,size:`sm`,onClick:w,children:r(`mcp.revoke`)}),(0,_.jsx)(a,{size:`sm`,onClick:t,children:r(`settings.done`)})]})]})})}export{y as McpSetupDialog};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{h as t,n}from"./ui-store-5IssrgmG.js";import{a as r,i,l as a,m as o,t as s}from"./button-B2EsmMJs.js";import{a as c}from"./i18n-C0aLwQ_k.js";import{t as l}from"./connection-store-B85kbJpB.js";import{c as u}from"./database-BSXLJRzV.js";import{t as d}from"./engine-DjP-Sw-S.js";import{Bt as f,C as p,Lt as ee,Mt as te,S as ne,Vt as re,b as m,bt as ie,v as h,x as g,xt as _,y as v,zt as ae}from"./index-Tw24-4of.js";import{a as oe,i as se,n as ce,o as le,t as ue}from"./dialog-FBpgH0QJ.js";var de=r(`list-ordered`,[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]),y=r(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),b=r(`skull`,[[`path`,{d:`m12.5 17-.5-1-.5 1h1z`,key:`3me087`}],[`path`,{d:`M15 22a1 1 0 0 0 1-1v-1a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20v1a1 1 0 0 0 1 1z`,key:`1o5pge`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}]]),x=r(`timer`,[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`,key:`14vaq8`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`,key:`17fdiu`}],[`circle`,{cx:`12`,cy:`14`,r:`8`,key:`1e1u0o`}]]),S=e(t(),1),C=a(),w=10,fe=[2,5,10,30];function T(){let e=l.getState();return e.activeConnections.find(t=>t.id===e.activeConnectionId)?.serverConnectionId??null}async function pe(){let e=T();if(!e)throw Error(c.t(`command.noActiveConnection`));let t=await u(e,d().getQuery(`SHOW_PROCESS_LIST`));return t.records.map(e=>{let n={};return t.fields.forEach((t,r)=>{n[t.name]=e[r]}),{...n,Id:String(n.Id)}})}function E(e){return/^(sleep|idle)/i.test(e.Command??``)}function me(e){return/lock/i.test(e.State??``)}function he(e){return/PROCESSLIST|pg_stat_activity/i.test(e.Info??``)}function D(e){let t=Number(e.Time);return Number.isFinite(t)?t:0}function O(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`}function k({icon:e,label:t,value:n,tone:r}){return(0,C.jsxs)(`div`,{className:`flex min-w-[120px] flex-1 items-center gap-2.5 rounded-md border bg-muted/30 px-3 py-1.5`,children:[(0,C.jsx)(`div`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md [&_svg]:size-3.5 ${r===`warn`?`bg-catppuccin-yellow/15 text-catppuccin-yellow`:`bg-primary/10 text-primary`}`,children:e}),(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:t}),(0,C.jsx)(`div`,{className:`truncate text-sm font-semibold tabular-nums`,children:n})]})]})}function A(){let{t:e}=o(),{activeDialog:t,closeDialog:r,setFooterMessage:a,requestDestructiveConfirm:c}=n(),[l,A]=(0,S.useState)([]),[j,M]=(0,S.useState)(!1),[N,P]=(0,S.useState)(5),[F,I]=(0,S.useState)(null),[L,R]=(0,S.useState)(``),[z,ge]=(0,S.useState)(!1),[B,_e]=(0,S.useState)(!0),[V,H]=(0,S.useState)(!1),[U,ve]=(0,S.useState)(null),[W,G]=(0,S.useState)(!1),K=(0,S.useRef)(null),q=t===`process-list`,J=(0,S.useCallback)(()=>Promise.resolve().then(()=>(H(!0),pe())).then(e=>{A(e),ve(new Date)}).catch(t=>a(e(`command.processList.loadError`,{message:t instanceof Error?t.message:String(t)}))).finally(()=>H(!1)),[a,e]);(0,S.useEffect)(()=>{q&&J()},[q,J]),(0,S.useEffect)(()=>(K.current&&=(clearInterval(K.current),null),j&&q&&(K.current=setInterval(()=>{J()},N*1e3)),()=>{K.current&&=(clearInterval(K.current),null)}),[j,N,q,J]);function Y(e){e||(M(!1),I(null),R(``),r())}let X=(0,S.useMemo)(()=>{let e=l.filter(E).length,t=l.filter(e=>!E(e)).reduce((e,t)=>Math.max(e,D(t)),0);return{total:l.length,active:l.length-e,idle:e,longest:t}},[l]),Z=(0,S.useMemo)(()=>{let e=L.trim().toLowerCase();return l.filter(t=>z&&E(t)?!1:!e||[t.Id,t.User,t.Host,t.db,t.Command,t.State,t.Info].some(t=>(t??``).toString().toLowerCase().includes(e))).sort((e,t)=>B?D(t)-D(e):D(e)-D(t))},[l,L,z,B]),Q=l.find(e=>e.Id===F)??null,ye=(0,S.useCallback)(()=>{Q?.Info&&navigator.clipboard.writeText(Q.Info).then(()=>{G(!0),setTimeout(()=>G(!1),1500)})},[Q]);async function $(t){let n=t??F;if(!n){a(e(`command.processList.selectToKill`));return}let r=T();if(!r)return;let i=l.find(e=>e.Id===n),o=d().getQuery(`KILL_QUERY`,String(n));if(await c({title:e(`command.processList.killConfirmTitle`,{id:n}),description:e(`command.processList.killConfirmDescription`,{user:i?.User??`?`,host:i?.Host??`?`}),confirmLabel:e(`command.processList.killProcess`),statements:[o]}))try{await u(r,o),a(e(`command.processList.killed`,{id:n})),F===n&&I(null),J()}catch(t){a(e(`command.processList.killError`,{message:t instanceof Error?t.message:String(t)}))}}return(0,C.jsx)(ue,{open:q,onOpenChange:Y,children:(0,C.jsxs)(ce,{className:`flex max-h-[85vh] flex-col sm:max-w-[1000px]`,children:[(0,C.jsx)(oe,{children:(0,C.jsxs)(le,{className:`flex items-center gap-2`,children:[e(`command.processList.title`),U&&(0,C.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:e(`command.processList.updatedAt`,{time:U.toLocaleTimeString(void 0,{hour12:!1})})})]})}),(0,C.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,C.jsx)(k,{icon:(0,C.jsx)(de,{}),label:e(`command.processList.stats.total`),value:X.total}),(0,C.jsx)(k,{icon:(0,C.jsx)(re,{}),label:e(`command.processList.stats.active`),value:X.active}),(0,C.jsx)(k,{icon:(0,C.jsx)(y,{}),label:e(`command.processList.stats.idle`),value:X.idle}),(0,C.jsx)(k,{icon:(0,C.jsx)(x,{}),label:e(`command.processList.stats.longest`),value:O(X.longest),tone:X.longest>=w?`warn`:void 0})]}),(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,C.jsxs)(`div`,{className:`relative`,children:[(0,C.jsx)(ie,{className:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,C.jsx)(`input`,{className:`h-7 w-56 rounded border bg-background pl-7 pr-6 text-xs placeholder:text-muted-foreground`,placeholder:e(`command.processList.filterPlaceholder`),value:L,onChange:e=>R(e.target.value)}),L&&(0,C.jsx)(`button`,{type:`button`,className:`absolute right-1.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>R(``),children:(0,C.jsx)(i,{className:`size-3`})})]}),(0,C.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs`,children:[(0,C.jsx)(`input`,{type:`checkbox`,className:`accent-primary`,checked:z,onChange:e=>ge(e.target.checked)}),e(`command.processList.hideIdle`)]}),(0,C.jsx)(`div`,{className:`flex-1`}),(0,C.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs`,children:[(0,C.jsx)(`input`,{type:`checkbox`,className:`accent-primary`,checked:j,onChange:e=>M(e.target.checked)}),e(`command.processList.autoRefresh`)]}),(0,C.jsx)(`select`,{className:`h-7 rounded border bg-background px-1.5 text-xs disabled:opacity-50`,value:N,onChange:e=>P(Number(e.target.value)),disabled:!j,children:fe.map(e=>(0,C.jsxs)(`option`,{value:e,children:[e,`s`]},e))}),(0,C.jsxs)(s,{variant:`outline`,size:`sm`,className:`h-7`,onClick:()=>{J()},disabled:V,children:[(0,C.jsx)(_,{className:`mr-1 size-3.5 ${V?`animate-spin`:``}`}),e(`command.processList.refresh`)]})]}),(0,C.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto rounded-md border`,children:(0,C.jsxs)(h,{className:`text-xs`,children:[(0,C.jsx)(ne,{className:`sticky top-0 z-10 bg-background`,children:(0,C.jsxs)(p,{children:[(0,C.jsx)(g,{className:`w-[70px]`,children:e(`command.processList.columns.id`)}),(0,C.jsx)(g,{className:`w-[100px]`,children:e(`command.processList.columns.user`)}),(0,C.jsx)(g,{className:`w-[130px]`,children:e(`command.processList.columns.host`)}),(0,C.jsx)(g,{className:`w-[100px]`,children:e(`command.processList.columns.db`)}),(0,C.jsx)(g,{className:`w-[90px]`,children:e(`command.processList.columns.command`)}),(0,C.jsx)(g,{className:`w-[80px] cursor-pointer select-none`,onClick:()=>_e(e=>!e),children:(0,C.jsxs)(`span`,{className:`flex items-center gap-1`,children:[e(`command.processList.columns.time`),B?(0,C.jsx)(f,{className:`size-3 text-primary`}):(0,C.jsx)(ae,{className:`size-3 text-primary`})]})}),(0,C.jsx)(g,{className:`w-[130px]`,children:e(`command.processList.columns.state`)}),(0,C.jsx)(g,{children:e(`command.processList.columns.info`)}),(0,C.jsx)(g,{className:`w-[50px]`})]})}),(0,C.jsx)(v,{children:Z.length===0?(0,C.jsx)(p,{children:(0,C.jsx)(m,{colSpan:9,className:`py-8 text-center text-muted-foreground`,children:l.length===0?e(`command.processList.empty`):e(`command.processList.noMatch`)})}):Z.map(t=>{let n=E(t),r=D(t),i=!n&&r>=w,a=me(t),o=he(t);return(0,C.jsxs)(p,{"data-state":F===t.Id?`selected`:void 0,className:`cursor-pointer ${n?`text-muted-foreground`:``} ${a?`bg-destructive/5`:i?`bg-catppuccin-yellow/5`:``}`,onClick:()=>I(t.Id),children:[(0,C.jsx)(m,{className:`font-mono tabular-nums`,children:(0,C.jsxs)(`span`,{className:`flex items-center gap-1`,children:[t.Id,o&&(0,C.jsx)(`span`,{className:`rounded bg-primary/10 px-1 text-[9px] font-semibold text-primary`,title:e(`command.processList.selfHint`),children:e(`command.processList.self`)})]})}),(0,C.jsx)(m,{children:t.User}),(0,C.jsx)(m,{className:`font-mono`,children:t.Host}),(0,C.jsx)(m,{className:`font-mono`,children:t.db??``}),(0,C.jsx)(m,{children:(0,C.jsx)(`span`,{className:`rounded px-1.5 py-px text-[10px] font-medium ${n?`bg-muted`:`bg-green-500/10 text-green-600 dark:text-green-400`}`,children:t.Command})}),(0,C.jsx)(m,{className:`tabular-nums ${i?`font-semibold text-catppuccin-yellow`:``}`,children:O(r)}),(0,C.jsx)(m,{className:a?`font-medium text-destructive`:``,children:t.State}),(0,C.jsx)(m,{className:`max-w-[260px] truncate font-mono`,title:t.Info??``,children:t.Info??``}),(0,C.jsx)(m,{className:`text-right`,children:(0,C.jsx)(`button`,{type:`button`,className:`rounded p-1 text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,title:e(`command.processList.kill`),onClick:e=>{e.stopPropagation(),$(t.Id)},children:(0,C.jsx)(b,{className:`size-3.5`})})})]},t.Id)})})]})}),Q&&(0,C.jsxs)(`div`,{className:`shrink-0 rounded-md border`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 border-b bg-muted/30 px-3 py-1`,children:[(0,C.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e(`command.processList.statementOf`,{id:Q.Id})}),(0,C.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[Q.User,`@`,Q.Host,Q.db?` · ${Q.db}`:``]}),(0,C.jsx)(`div`,{className:`flex-1`}),(0,C.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-40`,onClick:ye,disabled:!Q.Info,children:[W?(0,C.jsx)(ee,{className:`size-3`}):(0,C.jsx)(te,{className:`size-3`}),e(W?`command.processList.copied`:`command.processList.copy`)]})]}),(0,C.jsx)(`pre`,{className:`max-h-32 overflow-auto whitespace-pre-wrap break-words px-3 py-2 font-mono text-xs`,children:Q.Info||(0,C.jsx)(`span`,{className:`italic text-muted-foreground`,children:e(`command.processList.noStatement`)})})]}),(0,C.jsxs)(se,{children:[(0,C.jsx)(s,{variant:`destructive`,onClick:()=>{$()},disabled:!F,children:e(`command.processList.killProcess`)}),(0,C.jsx)(s,{variant:`outline`,onClick:()=>Y(!1),children:e(`command.close`)})]})]})})}export{A as ProcessListDialog};
@@ -0,0 +1 @@
1
+ import{n as e}from"./ui-store-5IssrgmG.js";import{l as t,m as n,t as r}from"./button-B2EsmMJs.js";import{a as i,i as a,n as o,r as s,t as c}from"./select-DEqoX1sU.js";import{n as l}from"./settings-store-DzQ3BP5e.js";import{c as u,l as d}from"./index-Tw24-4of.js";import{a as f,i as p,n as m,o as h,r as g,t as _}from"./dialog-FBpgH0QJ.js";import{t as v}from"./settings-controls-BepR6gzL.js";var y=t();function b(){let t=e(e=>e.activeDialog),b=e(e=>e.closeDialog),x=l(),S=x.update,{t:C}=n();return(0,y.jsx)(_,{open:t===`query-settings`,onOpenChange:e=>{e||b()},children:(0,y.jsxs)(m,{className:`sm:max-w-[560px]`,children:[(0,y.jsxs)(f,{children:[(0,y.jsx)(h,{children:C(`settings.query.title`)}),(0,y.jsx)(g,{children:C(`settings.query.description`)})]}),(0,y.jsxs)(`div`,{className:`grid gap-2`,children:[(0,y.jsx)(v,{id:`s-dryrun`,checked:x.previewAffectedRows,onChange:e=>S({previewAffectedRows:e}),pro:!0,label:`Dry run`,hint:`Before an UPDATE or DELETE runs, read its WHERE (joins included) as a SELECT and show how many rows it would change, with a sample of them, to confirm.`}),(0,y.jsxs)(`div`,{className:`grid grid-cols-[1fr_140px] items-center gap-3 rounded-md border p-3`,children:[(0,y.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,y.jsx)(u,{htmlFor:`s-limit`,className:`text-sm font-medium`,children:`Result row limit`}),(0,y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`LIMIT appended to SELECTs that have none. 0 disables.`})]}),(0,y.jsx)(d,{id:`s-limit`,type:`number`,min:0,step:100,value:x.resultRowLimit,onChange:e=>S({resultRowLimit:Math.max(0,Number(e.target.value)||0)})})]}),(0,y.jsxs)(`div`,{className:`grid grid-cols-[1fr_200px] items-center gap-3 rounded-md border p-3`,children:[(0,y.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,y.jsx)(`span`,{className:`text-sm font-medium`,children:`F9 / Run button executes`}),(0,y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Ctrl+Enter always runs the statement at the cursor; Ctrl+Shift+Enter the whole script.`})]}),(0,y.jsxs)(c,{value:x.executeScope,onValueChange:e=>S({executeScope:e}),children:[(0,y.jsx)(a,{children:(0,y.jsx)(i,{})}),(0,y.jsxs)(o,{children:[(0,y.jsx)(s,{value:`script`,children:`Whole script`}),(0,y.jsx)(s,{value:`statement`,children:`Statement at cursor`})]})]})]})]}),(0,y.jsx)(p,{children:(0,y.jsx)(r,{onClick:b,children:C(`settings.done`)})})]})})}export{b as QuerySettingsDialog};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,h as n,n as r}from"./ui-store-5IssrgmG.js";import{a as i,f as a,l as o,m as s,o as c,s as l}from"./button-B2EsmMJs.js";import{r as u,t as d}from"./i18n-C0aLwQ_k.js";import{_ as f,a as p,o as m,r as h,t as g}from"./dist-BYhFWvmC.js";import{t as _}from"./connection-store-B85kbJpB.js";import{n as v,r as y}from"./settings-store-DzQ3BP5e.js";import{n as b,t as ee}from"./query-store-BqBiylGA.js";import{n as x,t as S}from"./database-BSXLJRzV.js";import{c as C,i as w}from"./query-execution-BeDEQ-3M.js";import{$ as T,B as te,Ct as E,Dt as D,H as O,J as k,L as A,Lt as j,Mt as M,Q as N,St as ne,Tt as re,Vt as ie,Y as ae,_t as oe,bt as se,dt as ce,et as le,ft as ue,gt as de,ht as fe,jt as pe,kt as me,lt as he,ot as ge,tt as _e,ut as ve,vt as ye,wt as be,xt as xe}from"./index-Tw24-4of.js";import{a as Se,n as P,o as Ce,r as we,t as Te}from"./dialog-FBpgH0QJ.js";var Ee=i(`book-open`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),De=i(`copy-plus`,[[`line`,{x1:`15`,x2:`15`,y1:`12`,y2:`18`,key:`1p7wdc`}],[`line`,{x1:`12`,x2:`18`,y1:`15`,y2:`15`,key:`1nscbv`}],[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Oe=i(`corner-down-left`,[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]),ke=i(`database-zap`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 15 21.84`,key:`14ibmq`}],[`path`,{d:`M21 5V8`,key:`1marbg`}],[`path`,{d:`M21 12L18 17H22L19 22`,key:`zafso`}],[`path`,{d:`M3 12A9 3 0 0 0 14.59 14.87`,key:`1y4wr8`}]]),Ae=i(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),je=i(`file-spreadsheet`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 13h2`,key:`yr2amv`}],[`path`,{d:`M14 13h2`,key:`un5t4a`}],[`path`,{d:`M8 17h2`,key:`2yhykz`}],[`path`,{d:`M14 17h2`,key:`10kma7`}]]),Me=i(`git-compare`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`path`,{d:`M11 18H8a2 2 0 0 1-2-2V9`,key:`19pyzm`}]]),Ne=i(`git-compare-arrows`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`M12 18H7a2 2 0 0 1-2-2V9`,key:`16sdep`}],[`path`,{d:`m9 15 3 3-3 3`,key:`1m3kbl`}]]),Pe=i(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),Fe=i(`languages`,[[`path`,{d:`m5 8 6 6`,key:`1wu5hv`}],[`path`,{d:`m4 14 6-6 2-3`,key:`1k1g8d`}],[`path`,{d:`M2 5h12`,key:`or177f`}],[`path`,{d:`M7 2h1`,key:`1t2jsx`}],[`path`,{d:`m22 22-5-10-5 10`,key:`don7ne`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]),Ie=i(`network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),Le=i(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),Re=i(`replace`,[[`path`,{d:`M14 4a1 1 0 0 1 1-1`,key:`dhj8ez`}],[`path`,{d:`M15 10a1 1 0 0 1-1-1`,key:`1mnyi5`}],[`path`,{d:`M21 4a1 1 0 0 0-1-1`,key:`sfs9ap`}],[`path`,{d:`M21 9a1 1 0 0 1-1 1`,key:`mp6qeo`}],[`path`,{d:`m3 7 3 3 3-3`,key:`x25e72`}],[`path`,{d:`M6 10V5a2 2 0 0 1 2-2h2`,key:`15xut4`}],[`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1bkyp8`}]]),ze=i(`rocket`,[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]]),Be=i(`scale`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`m19 8 3 8a5 5 0 0 1-6 0zV7`,key:`zcdpyk`}],[`path`,{d:`M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1`,key:`1yorad`}],[`path`,{d:`m5 8 3 8a5 5 0 0 1-6 0zV7`,key:`eua70x`}],[`path`,{d:`M7 21h10`,key:`1b0cd5`}]]),Ve=i(`scroll-text`,[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]),He=i(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),Ue=i(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),We=i(`waypoints`,[[`path`,{d:`m10.586 5.414-5.172 5.172`,key:`4mc350`}],[`path`,{d:`m18.586 13.414-5.172 5.172`,key:`8c96vv`}],[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`circle`,{cx:`12`,cy:`20`,r:`2`,key:`144qzu`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}],[`circle`,{cx:`20`,cy:`12`,r:`2`,key:`1xzzfp`}],[`circle`,{cx:`4`,cy:`12`,r:`2`,key:`1hvhnz`}]]),F=e(n(),1),I=1,Ge=.9,Ke=.8,qe=.17,L=.1,R=.999,Je=.9999,z=.99,B=/[\\\/_+.#"@\[\(\{&]/,Ye=/[\\\/_+.#"@\[\(\{&]/g,Xe=/[\s-]/,Ze=/[\s-]/g;function V(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?I:z;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=V(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=I:B.test(e.charAt(l-1))?(d*=Ke,p=e.slice(i,l-1).match(Ye),p&&i>0&&(d*=R**+p.length)):Xe.test(e.charAt(l-1))?(d*=Ge,m=e.slice(i,l-1).match(Ze),m&&i>0&&(d*=R**+m.length)):(d*=qe,i>0&&(d*=R**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=Je)),(d<L&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=V(e,t,n,r,l+1,a+2,o),f*L>d&&(d=f*L)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function Qe(e){return e.toLowerCase().replace(Ze,` `)}function $e(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,V(e,t,Qe(e),Qe(t),0,0,{})}var H=`[cmdk-group=""]`,U=`[cmdk-group-items=""]`,et=`[cmdk-group-heading=""]`,tt=`[cmdk-item=""]`,nt=`${tt}:not([aria-disabled="true"])`,W=`cmdk-item-select`,G=`data-value`,rt=(e,t,n)=>$e(e,t,n),it=F.createContext(void 0),K=()=>F.useContext(it),at=F.createContext(void 0),q=()=>F.useContext(at),ot=F.createContext(void 0),st=F.forwardRef((e,t)=>{let n=X(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=X(()=>new Set),i=X(()=>new Map),a=X(()=>new Map),o=X(()=>new Set),s=vt(e),{label:c,children:u,value:d,onValueChange:p,filter:m,shouldFilter:h,loop:g,disablePointerSelection:_=!1,vimBindings:v=!0,...y}=e,b=f(),ee=f(),x=f(),S=F.useRef(null),C=bt();Y(()=>{if(d!==void 0){let e=d.trim();n.current.value=e,w.emit()}},[d]),Y(()=>{C(6,k)},[]);let w=F.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),C(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(x);e?e.focus():(i=document.getElementById(b))==null||i.focus()}if(C(7,()=>{n.current.selectedItemId=A()?.id,w.emit()}),r||C(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}w.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),T=F.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,te(t,r)),C(2,()=>{E(),w.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),C(3,()=>{O(),E(),n.current.value||D(),w.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();C(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),w.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:b,inputId:x,labelId:ee,listInnerRef:S}),[]);function te(e,t){let r=s.current?.filter??rt;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=S.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(U);t?t.appendChild(e.parentElement===t?e:e.closest(`${U} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${U} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=S.current?.querySelector(`${H}[${G}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(G);w.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=te(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(H)?.querySelector(et))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return S.current?.querySelector(`${tt}[aria-selected="true"]`)}function j(){return Array.from(S.current?.querySelectorAll(nt)||[])}function M(e){let t=j()[e];t&&w.setState(`value`,t.getAttribute(G))}function N(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&w.setState(`value`,a.getAttribute(G))}function ne(e){let t=A()?.closest(H),n;for(;t&&!n;)t=e>0?gt(t,H):_t(t,H),n=t?.querySelector(nt);n?w.setState(`value`,n.getAttribute(G)):N(e)}let re=()=>M(j().length-1),ie=e=>{e.preventDefault(),e.metaKey?re():e.altKey?ne(1):N(1)},ae=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?ne(-1):N(-1)};return F.createElement(l.div,{ref:t,tabIndex:-1,...y,"cmdk-root":``,onKeyDown:e=>{var t;(t=y.onKeyDown)==null||t.call(y,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:v&&e.ctrlKey&&ie(e);break;case`ArrowDown`:ie(e);break;case`p`:case`k`:v&&e.ctrlKey&&ae(e);break;case`ArrowUp`:ae(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),re();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(W);t.dispatchEvent(e)}}}}},F.createElement(`label`,{"cmdk-label":``,htmlFor:T.inputId,id:T.labelId,style:St},c),Q(e,e=>F.createElement(at.Provider,{value:w},F.createElement(it.Provider,{value:T},e))))}),ct=F.forwardRef((e,t)=>{let n=f(),r=F.useRef(null),i=F.useContext(ot),o=K(),s=vt(e),c=s.current?.forceMount??i?.forceMount;Y(()=>{if(!c)return o.item(n,i?.id)},[c]);let u=yt(n,r,[e.value,e.children,r],e.keywords),d=q(),p=Z(e=>e.value&&e.value===u.current),m=Z(e=>c||o.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);F.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(W,h),()=>t.removeEventListener(W,h)},[m,e.onSelect,e.disabled]);function h(){var e,t;g(),(t=(e=s.current).onSelect)==null||t.call(e,u.current)}function g(){d.setState(`value`,u.current,!0)}if(!m)return null;let{disabled:_,value:v,onSelect:y,forceMount:b,keywords:ee,...x}=e;return F.createElement(l.div,{ref:a(r,t),...x,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!_,"aria-selected":!!p,"data-disabled":!!_,"data-selected":!!p,onPointerMove:_||o.getDisablePointerSelection()?void 0:g,onClick:_?void 0:h},e.children)}),lt=F.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...o}=e,s=f(),c=F.useRef(null),u=F.useRef(null),d=f(),p=K(),m=Z(e=>i||p.filter()===!1?!0:!e.search||e.filtered.groups.has(s));Y(()=>p.group(s),[]),yt(s,c,[e.value,e.heading,u]);let h=F.useMemo(()=>({id:s,forceMount:i}),[i]);return F.createElement(l.div,{ref:a(c,t),...o,"cmdk-group":``,role:`presentation`,hidden:!m||void 0},n&&F.createElement(`div`,{ref:u,"cmdk-group-heading":``,"aria-hidden":!0,id:d},n),Q(e,e=>F.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?d:void 0},F.createElement(ot.Provider,{value:h},e))))}),ut=F.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=F.useRef(null),o=Z(e=>!e.search);return!n&&!o?null:F.createElement(l.div,{ref:a(i,t),...r,"cmdk-separator":``,role:`separator`})}),dt=F.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=q(),o=Z(e=>e.search),s=Z(e=>e.selectedItemId),c=K();return F.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),F.createElement(l.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),ft=F.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,o=F.useRef(null),s=F.useRef(null),c=Z(e=>e.selectedItemId),u=K();return F.useEffect(()=>{if(s.current&&o.current){let e=s.current,t=o.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),F.createElement(l.div,{ref:a(o,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":c,"aria-label":r,id:u.listId},Q(e,e=>F.createElement(`div`,{ref:a(s,u.listInnerRef),"cmdk-list-sizer":``},e)))}),pt=F.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return F.createElement(g,{open:n,onOpenChange:r},F.createElement(m,{container:o},F.createElement(p,{"cmdk-overlay":``,className:i}),F.createElement(h,{"aria-label":e.label,"cmdk-dialog":``,className:a},F.createElement(st,{ref:t,...s}))))}),mt=F.forwardRef((e,t)=>Z(e=>e.filtered.count===0)?F.createElement(l.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),ht=F.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return F.createElement(l.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Q(e,e=>F.createElement(`div`,{"aria-hidden":!0},e)))}),J=Object.assign(st,{List:ft,Item:ct,Input:dt,Group:lt,Separator:ut,Dialog:pt,Empty:mt,Loading:ht});function gt(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function _t(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function vt(e){let t=F.useRef(e);return Y(()=>{t.current=e}),t}var Y=typeof window>`u`?F.useEffect:F.useLayoutEffect;function X(e){let t=F.useRef();return t.current===void 0&&(t.current=e()),t}function Z(e){let t=q(),n=()=>e(t.snapshot());return F.useSyncExternalStore(t.subscribe,n,n)}function yt(e,t,n,r=[]){let i=F.useRef(),a=K();return Y(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(G,s),i.current=s}),i}var bt=()=>{let[e,t]=F.useState(),n=X(()=>new Map);return Y(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function xt(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function Q({asChild:e,children:t},n){return e&&F.isValidElement(t)?F.cloneElement(xt(t),{ref:t.ref},n(t.props.children)):n(t)}var St={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},$=o();function Ct({className:e,...t}){return(0,$.jsx)(J,{"data-slot":`command`,className:c(`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,e),...t})}function wt({title:e=`Command Palette`,description:t=`Search for a command to run...`,children:n,className:r,showCloseButton:i=!0,...a}){return(0,$.jsxs)(Te,{...a,children:[(0,$.jsxs)(Se,{className:`sr-only`,children:[(0,$.jsx)(Ce,{children:e}),(0,$.jsx)(we,{children:t})]}),(0,$.jsx)(P,{className:c(`overflow-hidden p-0`,r),showCloseButton:i,children:(0,$.jsx)(Ct,{className:`**:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5`,children:n})})]})}function Tt({className:e,...t}){return(0,$.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,$.jsx)(se,{className:`size-4 shrink-0 opacity-50`}),(0,$.jsx)(J.Input,{"data-slot":`command-input`,className:c(`flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,e),...t})]})}function Et({className:e,...t}){return(0,$.jsx)(J.List,{"data-slot":`command-list`,className:c(`max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto`,e),...t})}function Dt({...e}){return(0,$.jsx)(J.Empty,{"data-slot":`command-empty`,className:`py-6 text-center text-sm`,...e})}function Ot({className:e,...t}){return(0,$.jsx)(J.Group,{"data-slot":`command-group`,className:c(`overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground`,e),...t})}function kt({className:e,...t}){return(0,$.jsx)(J.Item,{"data-slot":`command-item`,className:c(`relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...t})}function At({className:e,...t}){return(0,$.jsx)(`span`,{"data-slot":`command-shortcut`,className:c(`ml-auto text-xs tracking-widest text-muted-foreground`,e),...t})}var jt={sky:`text-catppuccin-sky`,blue:`text-catppuccin-blue`,green:`text-catppuccin-green`,teal:`text-catppuccin-teal`,mauve:`text-catppuccin-mauve`,lavender:`text-catppuccin-lavender`,peach:`text-catppuccin-peach`,yellow:`text-catppuccin-yellow`,red:`text-catppuccin-red`};function Mt({theme:e}){let{background:t,blue:n,mauve:r,green:i}=e.colors;return(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 overflow-hidden rounded-sm border border-catppuccin-surface2`,children:[t,n,r,i].map((e,t)=>(0,$.jsx)(`span`,{className:`flex-1`,style:{backgroundColor:e}},t))})}function Nt(){let{t:e}=s(),{activeDialog:n,closeDialog:i,openDialog:a}=r(),o=r(e=>e.setWelcomeVisible),l=r(e=>e.setFooterMessage),{executeCurrentQuery:f,executeCurrentStatement:p,executeWholeScript:m,addNewQueryTab:h,disconnectActive:g}=_e(),{capabilities:se}=ge(),Se=y(),P=_(e=>e.activeConnections.find(t=>t.id===e.activeConnectionId)),Ce=_(e=>e.activeConnectionId?e.transactionOpen[e.activeConnectionId]??!1:!1),we=_(e=>e.updateProfile),Te=N(e=>e.themeId),I=N(e=>e.setTheme),Ge=v(e=>e.locale),Ke=v(e=>e.setLocale),qe=n===`quick-command`,L=P!==void 0,R=b(e=>{let t=_.getState().activeConnectionId;if(!t)return!1;let n=e.activeTabId[t];return(e.tabs[t]??ee).find(e=>e.id===n)?.isExecuting??!1});async function Je(){let e=_.getState().activeConnectionId;if(!e)return;let t=x(await S(e));t&&r.getState().setFooterMessage(t)}let z=(0,F.useCallback)(e=>{i(),e()},[i]),B=(0,F.useCallback)(e=>l(e instanceof Error?e.message:String(e)),[l]),Ye=()=>{let e=_.getState().activeConnectionId;e&&(le.getState().openERD(e),t(`erd_open`),b.getState().setActiveQueryTab(e,`erd`))},Xe=[{heading:e(`palette.groups.connection`),commands:[{id:`connect`,label:e(`palette.commands.connect`),icon:Le,tone:`sky`,shortcut:`Alt+N`,keywords:[`connect`,`server`,`profile`,`login`],disabled:!Se,action:()=>z(()=>a(`connect`))},{id:`disconnect`,label:e(`palette.commands.disconnect`),icon:ce,tone:`red`,keywords:[`disconnect`,`close`],disabled:!L,action:()=>z(()=>{g()})},{id:`read-only`,label:e(`menu.connection.readOnly`),icon:re,tone:`yellow`,keywords:[`read only`,`safety`,`guard`],disabled:!L,checked:P?.readOnly===!0,action:()=>z(()=>{P&&we(P.id,{readOnly:!P.readOnly})})},{id:`manual-transactions`,capability:`transactions`,label:e(`menu.connection.manualTransactions`),icon:D,tone:`lavender`,keywords:[`transaction`,`manual`,`autocommit`],disabled:!L,checked:P?.transactionMode===`manual`,action:()=>z(()=>{P&&we(P.id,{transactionMode:P.transactionMode===`manual`?`auto`:`manual`})})},{id:`commit`,capability:`transactions`,label:e(`toolbar.commit`),icon:j,tone:`green`,keywords:[`commit`,`transaction`],disabled:!Ce||!P,action:()=>z(()=>{P&&w(P.id).catch(B)})},{id:`rollback`,capability:`transactions`,label:e(`toolbar.rollback`),icon:ue,tone:`peach`,keywords:[`rollback`,`transaction`,`undo`],disabled:!Ce||!P,action:()=>z(()=>{P&&C(P.id).catch(B)})}]},{heading:e(`palette.groups.query`),commands:[{id:`execute`,label:e(`palette.commands.executeQuery`),icon:E,tone:`green`,shortcut:`F9`,keywords:[`run`,`execute`,`sql`],disabled:!L,action:()=>z(()=>{f()})},{id:`stop-query`,label:e(`result.running.stop`),icon:oe,tone:`red`,keywords:[`stop`,`cancel`,`abort`,`kill`],disabled:!R,action:()=>z(()=>{Je()})},{id:`execute-statement`,label:e(`menu.query.executeStatementAtCursor`),icon:Oe,tone:`green`,shortcut:`Ctrl+Enter`,keywords:[`run`,`statement`,`cursor`],disabled:!L,action:()=>z(()=>{p()})},{id:`execute-script`,label:e(`menu.query.executeWholeScript`),icon:Ve,tone:`teal`,shortcut:`Ctrl+Shift+Enter`,keywords:[`run`,`script`,`batch`],disabled:!L,action:()=>z(()=>{m()})},{id:`new-tab`,label:e(`palette.commands.newQueryTab`),icon:ne,tone:`blue`,shortcut:`Alt+T`,keywords:[`new`,`tab`,`editor`],disabled:!L,action:()=>z(()=>h())},{id:`find-replace`,label:e(`menu.query.findReplace`),icon:Re,tone:`lavender`,keywords:[`find`,`replace`,`search`],disabled:!L,action:()=>z(()=>a(`find-replace`))},{id:`local-history`,label:e(`menu.query.localHistory`),icon:Pe,tone:`mauve`,keywords:[`history`,`snapshot`,`undo`],disabled:!L,action:()=>z(()=>a(`local-history`))}]},{heading:e(`palette.groups.database`),commands:[{id:`create-db`,capability:`multipleDatabases`,label:e(`palette.commands.createDatabase`),icon:pe,tone:`blue`,keywords:[`create`,`database`,`schema`],disabled:!L,action:()=>z(()=>a(`create-database`))},{id:`alter-db`,capability:`multipleDatabases`,label:e(`menu.database.alter`),icon:ke,tone:`blue`,keywords:[`alter`,`database`,`charset`],disabled:!L,action:()=>z(()=>a(`alter-database`))},{id:`copy-db`,capability:`multipleDatabases`,label:e(`menu.database.copy`),icon:M,tone:`sky`,keywords:[`copy`,`clone`,`database`],disabled:!L,action:()=>z(()=>a(`copy-database`))},{id:`schema-diff`,label:e(`menu.database.compare`),icon:Me,tone:`mauve`,keywords:[`compare`,`diff`,`schema`,`sync`],pro:`compare_schemas`,disabled:!L,action:()=>z(()=>a(`schema-diff`))},{id:`data-diff`,label:e(`menu.database.compareData`),icon:Ne,tone:`mauve`,keywords:[`compare`,`diff`,`data`,`rows`],pro:`compare_data`,disabled:!L,action:()=>z(()=>a(`data-diff`))},{id:`group-by`,label:e(`menu.database.groupBy`),icon:ye,tone:`mauve`,keywords:[`group`,`count`,`aggregate`,`distinct`,`summary`],disabled:!L,action:()=>z(()=>a(`group-by`))}]},{heading:e(`palette.groups.table`),commands:[{id:`create-table`,label:e(`palette.commands.createTable`),icon:de,tone:`green`,keywords:[`create`,`table`],disabled:!L,action:()=>z(()=>a(`create-table`))},{id:`alter-table`,label:e(`palette.commands.alterTable`),icon:he,tone:`yellow`,keywords:[`alter`,`table`,`column`],disabled:!L,action:()=>z(()=>a(`alter-table`))},{id:`duplicate-table`,label:e(`menu.table.duplicateStructure`),icon:De,tone:`teal`,keywords:[`duplicate`,`structure`,`table`],disabled:!L,action:()=>z(()=>a(`duplicate-table-structure`))}]},{heading:e(`menu.export.title`),commands:[{id:`export-csv`,label:e(`menu.export.csv`),icon:je,tone:`green`,keywords:[`export`,`csv`,`excel`],disabled:!L,action:()=>z(()=>a(`export-csv`))},{id:`export-html`,label:e(`menu.export.schemaHtml`),icon:Ae,tone:`peach`,keywords:[`export`,`html`,`schema`,`documentation`],disabled:!L,action:()=>z(()=>a(`export-html`))}]},{heading:e(`palette.groups.tools`),commands:[{id:`process-list`,capability:`processList`,label:e(`palette.commands.processList`),icon:ie,tone:`red`,keywords:[`process`,`kill`,`connections`],disabled:!L,action:()=>z(()=>a(`process-list`))},{id:`variables`,capability:`variables`,label:e(`palette.commands.serverVariables`),icon:He,tone:`lavender`,keywords:[`variables`,`server`,`settings`],disabled:!L,action:()=>z(()=>a(`variables`))},{id:`status`,capability:`status`,label:e(`palette.commands.serverStatus`),icon:fe,tone:`teal`,keywords:[`status`,`server`,`metrics`],disabled:!L,action:()=>z(()=>a(`status`))},{id:`flush`,capability:`flush`,label:e(`palette.commands.flush`),icon:xe,tone:`peach`,keywords:[`flush`,`cache`,`reload`],disabled:!L,action:()=>z(()=>a(`flush`))},{id:`user-manager`,capability:`users`,label:e(`palette.commands.userManager`),icon:ve,tone:`blue`,keywords:[`users`,`grants`,`privileges`],disabled:!L,action:()=>z(()=>a(`user-manager`))},{id:`scratchpad`,label:e(`menu.tools.scratchpad`),icon:be,tone:`yellow`,keywords:[`scratchpad`,`sqlite`,`local`],pro:`scratchpad`,action:()=>z(()=>{ae().catch(B)})},{id:`federated`,label:e(`menu.tools.federated`),icon:We,tone:`mauve`,keywords:[`federated`,`cross`,`join`,`connections`],pro:`federated`,action:()=>z(()=>{O().catch(B)})},{id:`erd`,label:e(`menu.tools.viewErd`),icon:Ie,tone:`sky`,keywords:[`erd`,`diagram`,`relations`],disabled:!L,action:()=>z(Ye)}]},{heading:e(`menu.settings.theme`),commands:T().map(e=>({id:`theme-${e.id}`,label:e.name,tone:`lavender`,keywords:[`theme`,`color`,`appearance`,`dark`,`light`,e.id],checked:Te===e.id,swatch:e,action:()=>z(()=>I(e.id))}))},{heading:e(`menu.settings.language`),commands:[`auto`,...d].map(t=>({id:`locale-${t}`,label:t===`auto`?e(`language.auto`,{name:e(`language.${u()}`)}):e(`language.${t}`),icon:Fe,tone:`teal`,keywords:[`language`,`locale`,`i18n`,t],checked:Ge===t,action:()=>z(()=>Ke(t))}))},{heading:e(`menu.settings.title`),commands:[{id:`safety-settings`,label:e(`menu.settings.safety`),icon:Ue,tone:`yellow`,keywords:[`safety`,`settings`,`row limit`,`preferences`],action:()=>z(()=>a(`safety-settings`))}]},{heading:e(`menu.help.title`),commands:[{id:`documentation`,label:e(`menu.help.documentation`),icon:Ee,tone:`blue`,keywords:[`docs`,`documentation`,`manual`,`help`],action:()=>z(()=>{window.open(k(),`_blank`,`noopener,noreferrer`)})},{id:`getting-started`,label:e(`menu.help.gettingStarted`),icon:ze,tone:`green`,keywords:[`welcome`,`onboarding`,`sample`,`getting started`],action:()=>z(()=>o(!0))},{id:`terms`,label:e(`menu.help.terms`),icon:Be,tone:`peach`,keywords:[`terms`,`privacy`,`legal`],action:()=>z(()=>a(`terms`))},{id:`about`,label:e(`menu.help.about`),icon:me,tone:`sky`,keywords:[`about`,`version`,`agent`],action:()=>z(()=>a(`about`))}]}];function Ze(e){e||i()}let V=Xe.map(e=>({...e,commands:e.commands.filter(e=>!e.capability||se[e.capability])})).filter(e=>e.commands.length>0);return(0,$.jsxs)(wt,{open:qe,onOpenChange:Ze,title:e(`palette.title`),description:e(`palette.description`),children:[(0,$.jsx)(Tt,{placeholder:e(`palette.inputPlaceholder`)}),(0,$.jsxs)(Et,{className:`max-h-[60vh]`,children:[(0,$.jsx)(Dt,{children:e(`palette.empty`)}),V.map(e=>(0,$.jsx)(Ot,{heading:e.heading,children:e.commands.map(t=>(0,$.jsxs)(kt,{value:`${e.heading} ${t.label}`,keywords:t.keywords,disabled:t.disabled,onSelect:()=>{(!t.pro||A(t.pro))&&t.action()},children:[t.swatch?(0,$.jsx)(Mt,{theme:t.swatch}):t.icon?(0,$.jsx)(t.icon,{className:c(`size-4`,jt[t.tone])}):null,(0,$.jsx)(`span`,{className:`truncate`,children:t.label}),(0,$.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[t.pro&&(0,$.jsx)(te,{className:`ml-0`}),t.checked&&(0,$.jsx)(j,{className:`size-3.5 text-catppuccin-green`}),t.shortcut&&(0,$.jsx)(At,{className:`ml-0`,children:t.shortcut})]})]},t.id))},e.heading))]})]})}export{Nt as QuickCommandPalette};
@@ -0,0 +1,2 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{h as t,n,t as r}from"./ui-store-5IssrgmG.js";import{a as i,l as a,m as o,t as s}from"./button-B2EsmMJs.js";import{t as c}from"./connection-store-B85kbJpB.js";import{n as l}from"./settings-store-DzQ3BP5e.js";import{a as u}from"./database-BSXLJRzV.js";import{l as d,t as f}from"./query-execution-BeDEQ-3M.js";import{Et as p,Nt as m,Ot as h,Pt as g,Rt as _,d as v,f as y,m as b,p as x,st as S}from"./index-Tw24-4of.js";import{a as C,i as w,n as T,o as E,r as ee,t as D}from"./dialog-FBpgH0QJ.js";var O=i(`wand-sparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]),k=e(t(),1);function A(e){let t=e.slice(e.indexOf(`(`)+1,e.lastIndexOf(`)`)),n=[],r=/'((?:[^']|'')*)'/g,i;for(;i=r.exec(t);)n.push(i[1].replaceAll(`''`,`'`));return n}function j(e,t={}){let{oracleDate:n=!1}=t,r=e.type.trim(),i=r.toLowerCase(),a=/\bunsigned\b/.test(i);if(/^enum\(/.test(i))return{kind:`enum`,options:A(r)};if(/^set\(/.test(i))return{kind:`set`,options:A(r)};if(/^(tinyint\(1\)|bool|boolean|bit\(1\)|bit)(?![\w(])/.test(i))return{kind:`boolean`};let o=/^number(?:\((\d+|\*)(?:,\s*(-?\d+))?\))?$/.exec(i);if(o)return o[2]&&Number(o[2])>0?{kind:`decimal`}:o[1]?{kind:`integer`}:{kind:`decimal`};if(/^(tinyint|smallint|mediumint|int|integer|bigint|int2|int4|int8|serial|bigserial|smallserial)\b/.test(i))return{kind:`integer`,unsigned:a};if(/^(decimal|numeric|float|double|real|money|float4|float8|double precision)\b/.test(i))return{kind:`decimal`,unsigned:a};if(/^(datetime2|datetime|timestamp|smalldatetime|datetimeoffset)\b/.test(i))return{kind:`datetime`};if(/^date\b/.test(i))return{kind:n?`datetime`:`date`};if(/^(time|timetz)\b/.test(i))return{kind:`time`};if(/^(json|jsonb)\b/.test(i))return{kind:`json`};if(/^(uuid|uniqueidentifier)\b/.test(i))return{kind:`uuid`};if(/^(blob|tinyblob|mediumblob|longblob|binary|varbinary|bytea|raw|image|bfile)\b/.test(i))return{kind:`binary`};if(/^(text|ntext|tinytext|mediumtext|longtext|clob|nclob|long)\b/.test(i)||/^n?(?:var)?char2?\(max\)/.test(i))return{kind:`text`};let s=/^n?(?:var)?char2?(?:acter)?(?:\s+varying)?\((\d+)(?:\s+(?:char|byte))?\)/.exec(i);return s?{kind:`string`,maxLength:Number(s[1])}:{kind:`string`}}var M=/auto_increment|identity|generated/i;function N(e){return M.test(e.extra)||/^(serial|bigserial|smallserial)\b/i.test(e.type)?{mode:`auto`,text:``}:e.defaultValue===null?e.nullable?{mode:`null`,text:``}:{mode:`value`,text:``}:{mode:`default`,text:``}}function P(e){return e==null?{mode:`keep`,text:``}:{mode:`keep`,text:F(e)}}function F(e){if(e==null)return``;if(typeof e==`object`){if(ArrayBuffer.isView(e))return``;if(e instanceof Date)return e.toISOString();try{return JSON.stringify(e,null,2)}catch{return String(e)}}return String(e)}function I(e,t){let n=t.trim();switch(e.kind){case`integer`:{if(!/^[+-]?\d+$/.test(n))return{error:`integer`};if(e.unsigned&&n.startsWith(`-`))return{error:`unsigned`};let t=Number(n);return{value:Number.isSafeInteger(t)?t:BigInt(n)}}case`decimal`:return n===``||Number.isNaN(Number(n))?{error:`number`}:{value:Number(n)};case`boolean`:return{value:n===`true`||n===`1`};case`json`:try{return{value:JSON.parse(n===``?`null`:n)}}catch{return{error:`json`}}case`set`:return{value:n};case`date`:return n&&!/^\d{4}-\d{2}-\d{2}$/.test(n)?{error:`date`}:{value:n};case`datetime`:return n&&!/^\d{4}-\d{2}-\d{2}([ T]\d{2}:\d{2}(:\d{2}(\.\d+)?)?)?([+-]\d{2}:?\d{2}|Z)?$/.test(n)?{error:`datetime`}:{value:n};case`time`:return n&&!/^-?\d{1,3}:\d{2}(:\d{2}(\.\d+)?)?$/.test(n)?{error:`time`}:{value:n};default:return{value:t}}}var L=a(),R={integer:`result.rowForm.invalid.integer`,unsigned:`result.rowForm.invalid.unsigned`,number:`result.rowForm.invalid.number`,json:`result.rowForm.invalid.json`,date:`result.rowForm.invalid.date`,datetime:`result.rowForm.invalid.datetime`,time:`result.rowForm.invalid.time`};function z(e){return String(e).padStart(2,`0`)}function B(e){let t=new Date,n=`${t.getFullYear()}-${z(t.getMonth()+1)}-${z(t.getDate())}`,r=`${z(t.getHours())}:${z(t.getMinutes())}:${z(t.getSeconds())}`;return e===`date`?n:e===`time`?r:`${n} ${r}`}function V(e){let t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e.trim());if(!t)return;let n=new Date(Number(t[1]),Number(t[2])-1,Number(t[3]));return Number.isNaN(n.getTime())?void 0:n}function H({spec:e,state:t,disabled:n,onText:r}){let{t:i}=o(),a=`w-full rounded border bg-background px-2 py-1 text-sm font-mono outline-none focus:ring-1 focus:ring-primary disabled:opacity-50`;switch(e.kind){case`boolean`:return(0,L.jsxs)(`select`,{className:a,value:t.text===`true`||t.text===`1`?`true`:`false`,onChange:e=>r(e.target.value),disabled:n,children:[(0,L.jsx)(`option`,{value:`true`,children:`TRUE`}),(0,L.jsx)(`option`,{value:`false`,children:`FALSE`})]});case`enum`:return(0,L.jsxs)(`select`,{className:a,value:t.text,onChange:e=>r(e.target.value),disabled:n,children:[!e.options?.includes(t.text)&&(0,L.jsx)(`option`,{value:t.text,children:t.text||`—`}),e.options?.map(e=>(0,L.jsx)(`option`,{value:e,children:e},e))]});case`set`:{let i=new Set(t.text.split(`,`).map(e=>e.trim()).filter(Boolean));return(0,L.jsx)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1 rounded border bg-background px-2 py-1.5`,children:e.options?.map(t=>(0,L.jsxs)(`label`,{className:`flex items-center gap-1 text-xs font-mono`,children:[(0,L.jsx)(`input`,{type:`checkbox`,className:`accent-primary`,checked:i.has(t),disabled:n,onChange:n=>{let a=new Set(i);n.target.checked?a.add(t):a.delete(t),r(e.options.filter(e=>a.has(e)).join(`,`))}}),t]},t))})}case`integer`:case`decimal`:return(0,L.jsx)(`input`,{className:`${a} tabular-nums`,inputMode:`decimal`,value:t.text,onChange:e=>r(e.target.value),disabled:n,placeholder:e.kind===`integer`?`0`:`0.00`});case`date`:case`datetime`:{let[o,s]=t.text.trim().split(/[ T]/);return(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(`input`,{className:`${a} flex-1`,value:t.text,onChange:e=>r(e.target.value),disabled:n,placeholder:e.kind===`date`?`YYYY-MM-DD`:`YYYY-MM-DD HH:MM:SS`}),(0,L.jsxs)(y,{children:[(0,L.jsx)(b,{asChild:!0,children:(0,L.jsx)(`button`,{type:`button`,className:`rounded border bg-background p-1.5 text-muted-foreground hover:text-foreground disabled:opacity-50`,disabled:n,title:i(`result.rowForm.pickDate`),children:(0,L.jsx)(_,{className:`size-3.5`})})}),(0,L.jsx)(x,{className:`w-auto p-0`,align:`end`,children:(0,L.jsx)(v,{mode:`single`,selected:V(o??``),defaultMonth:V(o??``),onSelect:t=>{if(!t)return;let n=`${t.getFullYear()}-${z(t.getMonth()+1)}-${z(t.getDate())}`;r(e.kind===`date`?n:`${n} ${s||`00:00:00`}`)}})})]}),(0,L.jsx)(`button`,{type:`button`,className:`rounded border bg-background px-1.5 py-1 text-[10px] text-muted-foreground hover:text-foreground disabled:opacity-50`,disabled:n,onClick:()=>r(B(e.kind)),title:i(`result.rowForm.now`),children:(0,L.jsx)(m,{className:`size-3.5`})})]})}case`time`:return(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(`input`,{className:`${a} flex-1`,value:t.text,onChange:e=>r(e.target.value),disabled:n,placeholder:`HH:MM:SS`}),(0,L.jsx)(`button`,{type:`button`,className:`rounded border bg-background px-1.5 py-1 text-muted-foreground hover:text-foreground disabled:opacity-50`,disabled:n,onClick:()=>r(B(`time`)),title:i(`result.rowForm.now`),children:(0,L.jsx)(m,{className:`size-3.5`})})]});case`json`:{let e=!0;try{t.text.trim()&&JSON.parse(t.text)}catch{e=!1}return(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsx)(`textarea`,{className:`${a} min-h-[96px] resize-y text-xs ${e?``:`border-destructive`}`,value:t.text,onChange:e=>r(e.target.value),disabled:n,spellCheck:!1,placeholder:`{}`}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 rounded border bg-background px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground disabled:opacity-50`,disabled:n||!e||!t.text.trim(),onClick:()=>{try{r(JSON.stringify(JSON.parse(t.text),null,2))}catch{}},children:[(0,L.jsx)(O,{className:`size-3`}),i(`result.rowForm.formatJson`)]}),!e&&(0,L.jsx)(`span`,{className:`text-[10px] text-destructive`,children:i(`result.rowForm.invalid.json`)})]})]})}case`text`:return(0,L.jsx)(`textarea`,{className:`${a} min-h-[72px] resize-y`,value:t.text,onChange:e=>r(e.target.value),disabled:n,spellCheck:!1});case`binary`:return(0,L.jsx)(`div`,{className:`rounded border bg-muted/40 px-2 py-1 text-xs italic text-muted-foreground`,children:i(`result.rowForm.binaryUnsupported`)});case`uuid`:return(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(`input`,{className:`${a} flex-1`,value:t.text,onChange:e=>r(e.target.value),disabled:n,placeholder:`00000000-0000-0000-0000-000000000000`}),(0,L.jsx)(`button`,{type:`button`,className:`rounded border bg-background px-1.5 py-1 text-muted-foreground hover:text-foreground disabled:opacity-50`,disabled:n,onClick:()=>r(crypto.randomUUID()),title:i(`result.rowForm.generateUuid`),children:(0,L.jsx)(O,{className:`size-3.5`})})]});default:{let i=t.text.length>80||t.text.includes(`
2
+ `);return(0,L.jsxs)(`div`,{className:`space-y-0.5`,children:[i?(0,L.jsx)(`textarea`,{className:`${a} min-h-[56px] resize-y`,value:t.text,onChange:e=>r(e.target.value),disabled:n,spellCheck:!1}):(0,L.jsx)(`input`,{className:a,value:t.text,onChange:e=>r(e.target.value),disabled:n,maxLength:e.maxLength}),e.maxLength&&(0,L.jsxs)(`div`,{className:`text-right text-[10px] tabular-nums ${t.text.length>e.maxLength?`text-destructive`:`text-muted-foreground`}`,children:[t.text.length,`/`,e.maxLength]})]})}}}function U(){let{t:e}=o(),t=r(`row-form`),i=n(e=>e.closeDialog),a=n(e=>e.setFooterMessage),m=S(t?.connectionId??``),_=c(e=>t?e.transactionOpen[t.connectionId]:!1),[v,y]=(0,k.useState)(null),[b,x]=(0,k.useState)(null),[O,A]=(0,k.useState)({}),[M,F]=(0,k.useState)({}),[z,B]=(0,k.useState)(null),[V,U]=(0,k.useState)(!1),W=t?.mode===`edit`;(0,k.useEffect)(()=>{if(!t)return;let e=!1,n=u(t.serverConnectionId);return m.introspect.listColumns(n,t.database,t.table).then(n=>{if(e)return;y(n);let r={};for(let e of n)if(t.mode===`edit`){let n=t.fields.find(t=>t.orgName===e.name);r[e.name]=P(n?t.row?.[n.name]:void 0)}else r[e.name]=N(e);A(r)}).catch(t=>{e||x(t instanceof Error?t.message:String(t))}),()=>{e=!0}},[t?.serverConnectionId,t?.database,t?.table,t?.mode]);let G=(0,k.useMemo)(()=>new Map((v??[]).map(e=>[e.name,j(e,{oracleDate:m.id===`oracle`})])),[v,m.id]),K=(0,k.useCallback)((e,t)=>{A(n=>({...n,[e]:{...n[e],mode:t}})),F(t=>{let n={...t};return delete n[e],n})},[]),q=(0,k.useCallback)((e,t)=>{A(n=>({...n,[e]:{mode:`value`,text:t}})),F(t=>{let n={...t};return delete n[e],n})},[]),J=(0,k.useMemo)(()=>({__default:!0}),[]),Y=(0,k.useCallback)(()=>{if(!v)return null;let t=new Map,n={};for(let r of v){let i=O[r.name],a=G.get(r.name);if(!i||i.mode===`auto`||i.mode===`keep`)continue;if(i.mode===`null`){t.set(r.name,null);continue}if(i.mode==="default"){t.set(r.name,J);continue}let o=I(a,i.text);if(`error`in o){n[r.name]=e(R[o.error]??`result.rowForm.invalid.number`);continue}if(a.maxLength&&typeof o.value==`string`&&o.value.length>a.maxLength){n[r.name]=e(`result.rowForm.invalid.length`,{max:a.maxLength});continue}t.set(r.name,o.value)}return F(n),Object.keys(n).length>0?null:{values:t}},[v,O,G,e,J]),X=(0,k.useCallback)(e=>{if(!t)return null;let n=e=>e===J?`DEFAULT`:m.quoteLiteral(e);if(t.mode===`insert`){let r=[...e];return r.length===0?m.getQuery(`INSERT_DEFAULT_VALUES`,t.database,t.table):m.getQuery(`INSERT_TABLE`,t.database,t.table,r.map(([e])=>m.quoteIdentifier(e)).join(`, `),r.map(([,e])=>n(e)).join(`, `))}return!t.where||e.size===0?null:m.getQuery(`UPDATE_TABLE`,t.database,t.table,[...e].map(([e,t])=>`${m.quoteIdentifier(e)} = ${n(t)}`).join(`, `),t.where)},[t,m,J]),Z=(0,k.useMemo)(()=>{if(!v)return``;let e=new Map;for(let t of v){let n=O[t.name];if(!(!n||n.mode===`auto`||n.mode===`keep`)){if(n.mode===`null`)e.set(t.name,null);else if(n.mode==="default")e.set(t.name,J);else{let r=I(G.get(t.name),n.text);e.set(t.name,`error`in r?n.text:r.value)}}}return X(e)??``},[v,O,G,X,J]),Q=e=>{let n={};for(let[r,i]of e){if(i===J)continue;let e=t?.fields.find(e=>e.orgName===r);n[e?.name??r]=typeof i==`bigint`?i.toString():i}return n},te=()=>{let e=Y();!e||!t||(t.onStage?.(t.mode,Q(e.values)),i())},ne=async()=>{let r=Y();if(!r||!t)return;let o=X(r.values);if(!o){B(e(`result.rowForm.nothingToWrite`));return}U(!0),B(null);try{if(l.getState().previewGridCommit&&!await n.getState().requestDestructiveConfirm({title:e(W?`result.rowForm.confirmUpdateTitle`:`result.rowForm.confirmInsertTitle`,{table:`${t.database}.${t.table}`}),statements:[o],confirmLabel:e(W?`result.rowForm.update`:`result.rowForm.insert`)}))return;await d(t.connectionId,o,{database:t.database,skipDestructiveConfirm:!0}),a(e(W?`result.rowForm.updated`:`result.rowForm.inserted`,{table:`${t.database}.${t.table}`})),t.onCommitted?.(t.mode,Q(r.values)),i()}catch(e){if(e instanceof f)return;B(e instanceof Error?e.message:String(e))}finally{U(!1)}};if(!t)return null;let $=(e,t,n,r)=>(0,L.jsx)(`button`,{type:`button`,className:`rounded px-1.5 py-0.5 text-[10px] font-medium ${r===t?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`}`,onClick:()=>K(e,t),children:n});return(0,L.jsx)(D,{open:!0,onOpenChange:e=>{e||i()},children:(0,L.jsxs)(T,{className:`flex max-h-[90vh] flex-col sm:max-w-[860px]`,children:[(0,L.jsxs)(C,{children:[(0,L.jsx)(E,{children:e(W?`result.rowForm.editTitle`:`result.rowForm.insertTitle`)}),(0,L.jsxs)(ee,{className:`font-mono text-xs`,children:[t.database,`.`,t.table]})]}),(0,L.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto rounded-md border`,children:[b&&(0,L.jsx)(`div`,{className:`rounded border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:b}),!v&&!b&&(0,L.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-10 text-sm text-muted-foreground`,children:[(0,L.jsx)(p,{className:`size-4 animate-spin`}),e(`result.rowForm.loading`)]}),v&&(0,L.jsxs)(`table`,{className:`w-full border-separate border-spacing-0 text-sm`,children:[(0,L.jsx)(`thead`,{className:`sticky top-0 z-10 bg-background`,children:(0,L.jsxs)(`tr`,{className:`text-left text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,L.jsx)(`th`,{className:`w-[38%] border-b px-2 py-1.5 font-medium`,children:e(`result.rowForm.colColumn`)}),(0,L.jsx)(`th`,{className:`border-b px-2 py-1.5 font-medium`,children:e(`result.rowForm.colValue`)})]})}),(0,L.jsx)(`tbody`,{children:v.map(n=>{let r=O[n.name]??{mode:`value`,text:``},i=G.get(n.name),a=r.mode===`auto`,o=M[n.name],s=n.key===`PRI`,c=t.fields.find(e=>e.orgName===n.name),l=!!c&&!!t.row&&t.row[c.name]===null;return(0,L.jsxs)(`tr`,{className:`align-top ${o?`bg-destructive/5`:`hover:bg-muted/30`}`,children:[(0,L.jsxs)(`td`,{className:`border-b border-border/60 px-2 py-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,L.jsx)(`span`,{className:`truncate font-mono text-sm font-medium`,title:n.name,children:n.name}),s&&(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-0.5 rounded border border-catppuccin-yellow/50 px-1 text-[9px] font-semibold text-catppuccin-yellow`,children:[(0,L.jsx)(h,{className:`size-2.5`}),`PK`]})]}),(0,L.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-1.5 gap-y-0.5 text-[10px] text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`rounded bg-muted px-1 py-px font-mono`,children:n.type}),!n.nullable&&(0,L.jsx)(`span`,{children:`NOT NULL`}),n.defaultValue!==null&&(0,L.jsxs)(`span`,{className:`font-mono`,title:e(`result.rowForm.defaultValue`),children:[`= `,n.defaultValue]}),n.extra&&(0,L.jsx)(`span`,{children:n.extra})]}),n.comment&&(0,L.jsx)(`div`,{className:`mt-0.5 text-[10px] text-muted-foreground/80`,children:n.comment})]}),(0,L.jsx)(`td`,{className:`border-b border-border/60 px-2 py-2`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r.mode===`keep`?(0,L.jsx)(`div`,{className:`cursor-text truncate rounded border border-dashed bg-muted/30 px-2 py-1 font-mono text-xs text-muted-foreground`,onClick:()=>K(n.name,`value`),title:e(`result.rowForm.clickToChange`),children:l?(0,L.jsx)(`span`,{className:`italic`,children:`NULL`}):r.text||(0,L.jsx)(`span`,{className:`italic`,children:e(`result.rowForm.empty`)})}):r.mode===`value`?(0,L.jsx)(H,{spec:i,state:r,disabled:!1,onText:e=>q(n.name,e)}):(0,L.jsx)(`div`,{className:`rounded border border-dashed bg-muted/30 px-2 py-1 font-mono text-xs italic text-muted-foreground`,children:r.mode===`null`?`NULL`:r.mode==="default"?`DEFAULT (${n.defaultValue??``})`:e(`result.rowForm.autoHint`)}),o&&(0,L.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 text-[11px] text-destructive`,children:[(0,L.jsx)(g,{className:`size-3`}),o]})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5 rounded border bg-background p-0.5`,children:[W&&$(n.name,`keep`,e(`result.rowForm.mode.keep`),r.mode),(a||!W&&/auto_increment|identity/i.test(n.extra))&&$(n.name,`auto`,e(`result.rowForm.mode.auto`),r.mode),$(n.name,`value`,e(`result.rowForm.mode.value`),r.mode),n.nullable&&$(n.name,`null`,`NULL`,r.mode),n.defaultValue!==null&&$(n.name,`default`,`DEFAULT`,r.mode)]})]})})]},n.name)})})]})]}),v&&(0,L.jsxs)(`div`,{className:`shrink-0 rounded-md border bg-muted/30`,children:[(0,L.jsx)(`div`,{className:`border-b px-3 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e(`result.rowForm.preview`)}),(0,L.jsx)(`pre`,{className:`max-h-24 overflow-auto whitespace-pre-wrap break-words px-3 py-2 font-mono text-xs`,children:Z||(0,L.jsx)(`span`,{className:`italic text-muted-foreground`,children:e(`result.rowForm.nothingToWrite`)})})]}),z&&(0,L.jsx)(`div`,{className:`shrink-0 rounded border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:z}),(0,L.jsxs)(w,{className:`items-center`,children:[_&&(0,L.jsx)(`span`,{className:`mr-auto text-[11px] text-catppuccin-yellow`,children:e(`result.rowForm.inTransaction`)}),(0,L.jsx)(s,{variant:`outline`,onClick:()=>i(),disabled:V,children:e(`command.close`)}),t.onStage&&(0,L.jsx)(s,{variant:`outline`,onClick:te,disabled:V||!v,title:e(`result.rowForm.stageHint`),children:e(W?`result.rowForm.stageEdit`:`result.rowForm.stageInsert`)}),(0,L.jsxs)(s,{onClick:()=>void ne(),disabled:V||!v,children:[V&&(0,L.jsx)(p,{className:`mr-1 size-3.5 animate-spin`}),e(W?`result.rowForm.update`:`result.rowForm.insert`)]})]})]})})}export{U as RowFormDialog};
@@ -1 +1 @@
1
- import{n as e}from"./ui-store-5IssrgmG.js";import{l as t,m as n,t as r}from"./button-B2EsmMJs.js";import{n as i,t as a}from"./settings-store-DzQ3BP5e.js";import{a as o,i as s,n as c,o as l,r as u,t as d}from"./dialog-FBpgH0QJ.js";import{t as f}from"./settings-controls-DyukG7E2.js";var p=t();function m(){let t=e(e=>e.activeDialog),m=e(e=>e.closeDialog),h=i(),g=h.update,{t:_}=n();return(0,p.jsx)(d,{open:t===`safety-settings`,onOpenChange:e=>{e||m()},children:(0,p.jsxs)(c,{className:`sm:max-w-[560px]`,children:[(0,p.jsxs)(o,{children:[(0,p.jsx)(l,{children:_(`settings.title`)}),(0,p.jsx)(u,{children:_(`settings.description`)})]}),(0,p.jsxs)(`div`,{className:`grid gap-2`,children:[(0,p.jsx)(f,{id:`s-confirm`,checked:h.confirmDestructive,onChange:e=>g({confirmDestructive:e}),label:`Confirm destructive statements`,hint:`Ask before DROP TABLE/DATABASE, TRUNCATE, DELETE or UPDATE without WHERE, and ALTER … DROP COLUMN.`}),(0,p.jsx)(f,{id:`s-warn`,checked:h.warnInEditor,onChange:e=>g({warnInEditor:e}),label:`Warn in the editor`,hint:`Underline destructive statements and statements a read-only connection would refuse.`}),(0,p.jsx)(f,{id:`s-override`,checked:h.allowReadOnlyOverride,onChange:e=>g({allowReadOnlyOverride:e}),label:`Allow "Run anyway" on read-only connections`,hint:`When off, writes on a read-only connection are refused with no override.`}),(0,p.jsx)(f,{id:`s-preview`,checked:h.previewGridCommit,onChange:e=>g({previewGridCommit:e}),label:`Preview SQL before committing grid edits`,hint:`Show the generated UPDATE statements and ask for confirmation.`})]}),(0,p.jsxs)(s,{children:[(0,p.jsx)(r,{variant:`ghost`,onClick:()=>g(a),children:_(`settings.resetDefaults`)}),(0,p.jsx)(r,{onClick:m,children:_(`settings.done`)})]})]})})}export{m as SafetySettingsDialog};
1
+ import{n as e}from"./ui-store-5IssrgmG.js";import{l as t,m as n,t as r}from"./button-B2EsmMJs.js";import{n as i,t as a}from"./settings-store-DzQ3BP5e.js";import{a as o,i as s,n as c,o as l,r as u,t as d}from"./dialog-FBpgH0QJ.js";import{t as f}from"./settings-controls-BepR6gzL.js";var p=t();function m(){let t=e(e=>e.activeDialog),m=e(e=>e.closeDialog),h=i(),g=h.update,{t:_}=n();return(0,p.jsx)(d,{open:t===`safety-settings`,onOpenChange:e=>{e||m()},children:(0,p.jsxs)(c,{className:`sm:max-w-[560px]`,children:[(0,p.jsxs)(o,{children:[(0,p.jsx)(l,{children:_(`settings.title`)}),(0,p.jsx)(u,{children:_(`settings.description`)})]}),(0,p.jsxs)(`div`,{className:`grid gap-2`,children:[(0,p.jsx)(f,{id:`s-confirm`,checked:h.confirmDestructive,onChange:e=>g({confirmDestructive:e}),label:`Confirm destructive statements`,hint:`Ask before DROP TABLE/DATABASE, TRUNCATE, DELETE or UPDATE without WHERE, and ALTER … DROP COLUMN.`}),(0,p.jsx)(f,{id:`s-warn`,checked:h.warnInEditor,onChange:e=>g({warnInEditor:e}),label:`Warn in the editor`,hint:`Underline destructive statements and statements a read-only connection would refuse.`}),(0,p.jsx)(f,{id:`s-override`,checked:h.allowReadOnlyOverride,onChange:e=>g({allowReadOnlyOverride:e}),label:`Allow "Run anyway" on read-only connections`,hint:`When off, writes on a read-only connection are refused with no override.`}),(0,p.jsx)(f,{id:`s-preview`,checked:h.previewGridCommit,onChange:e=>g({previewGridCommit:e}),label:`Preview SQL before committing grid edits`,hint:`Show the generated UPDATE statements and ask for confirmation.`})]}),(0,p.jsxs)(s,{children:[(0,p.jsx)(r,{variant:`ghost`,onClick:()=>g(a),children:_(`settings.resetDefaults`)}),(0,p.jsx)(r,{onClick:m,children:_(`settings.done`)})]})]})})}export{m as SafetySettingsDialog};
@@ -0,0 +1,7 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,h as n,n as r,t as i}from"./ui-store-5IssrgmG.js";import{l as a,m as o,t as s}from"./button-B2EsmMJs.js";import{a as c,i as l,n as u,r as d,t as f}from"./select-DEqoX1sU.js";import{t as p}from"./connection-store-B85kbJpB.js";import{a as m}from"./database-BSXLJRzV.js";import{n as h}from"./engine-DjP-Sw-S.js";import{t as g}from"./pro-usage-BxwRZwtM.js";import{t as _}from"./table-definition-Bs5VSn0X.js";import{at as v,c as y,it as ee}from"./index-Tw24-4of.js";import{a as b,i as x,n as te,o as ne,t as S}from"./dialog-FBpgH0QJ.js";var C=e(n(),1),w=[`VIEW`,`PROCEDURE`,`FUNCTION`,`TRIGGER`,`EVENT`];function T(e,t){return e.replace(/\bDEFINER\s*=\s*(?:`[^`]*`|'[^']*'|"[^"]*"|\w+)@(?:`[^`]*`|'[^']*'|"[^"]*"|[\w.%-]+)/gi,``).replace(/\bSQL SECURITY (?:DEFINER|INVOKER)\b/gi,``).replace(/\bALGORITHM\s*=\s*\w+/gi,``).replace(RegExp(`[\`"\\[]?${t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}[\`"\\]]?\\.`,`gi`),``).replace(/\s+/g,` `).replace(/;\s*$/,``).trim()}function E(e,t){let n=[];for(let r of w){let i=e.objects?.get(r),a=t.objects?.get(r);if(!i&&!a)continue;let o=[...new Set([...i?.keys()??[],...a?.keys()??[]])].sort();for(let s of o){let o=i?.get(s)??null,c=a?.get(s)??null,l;l=o?c?o.sql!==null&&c.sql!==null&&T(o.sql,e.database)===T(c.sql,t.database)?`identical`:`changed`:`missingInTarget`:`missingInSource`,n.push({type:r,name:s,status:l,source:o,target:c})}}return n}var D=e=>e.toLowerCase().replace(/\s+/g,` `).trim(),O=e=>e===null?null:e.trim().replace(/^'(.*)'(?:::\w+)?$/s,`$1`),k=e=>e.addedColumns.length+e.removedColumns.length+e.changedColumns.length+e.addedIndexes.length+e.removedIndexes.length+e.changedIndexes.length>0;function A(e,t){let n=[];return D(e.type)!==D(t.type)&&n.push(`type`),e.nullable!==t.nullable&&n.push(`nullable`),O(e.defaultValue)!==O(t.defaultValue)&&n.push(`default`),e.extra.toLowerCase()!==t.extra.toLowerCase()&&n.push(`extra`),n}var j=(e,t)=>e.type===t.type&&e.columns.length===t.columns.length&&e.columns.every((e,n)=>e===t.columns[n]);function M(e,t,n){let r=t.columns.get(e)??[],i=n.columns.get(e)??[],a=new Map(i.map(e=>[e.name,e])),o=new Map(r.map(e=>[e.name,e])),s={table:e,addedColumns:r.filter(e=>!a.has(e.name)),removedColumns:i.filter(e=>!o.has(e.name)),changedColumns:[],addedIndexes:[],removedIndexes:[],changedIndexes:[]};for(let e of r){let t=a.get(e.name);if(!t)continue;let n=A(e,t);n.length>0&&s.changedColumns.push({name:e.name,source:e,target:t,attributes:n})}let c=t.indexes.get(e)??[],l=n.indexes.get(e)??[],u=new Map(l.map(e=>[e.name,e])),d=new Map(c.map(e=>[e.name,e]));s.addedIndexes=c.filter(e=>!u.has(e.name)),s.removedIndexes=l.filter(e=>!d.has(e.name));for(let e of c){let t=u.get(e.name);t&&!j(e,t)&&s.changedIndexes.push({name:e.name,source:e,target:t})}return s}function N(e,t){let n=new Set(t.tables),r=new Set(e.tables),i={missingInTarget:[],missingInSource:[],changed:[],identical:[],objects:E(e,t)};for(let r of e.tables){if(!n.has(r)){i.missingInTarget.push(r);continue}let a=M(r,e,t);k(a)?i.changed.push(a):i.identical.push(r)}return i.missingInSource=t.tables.filter(e=>!r.has(e)),i}var P=e=>e.split(`
2
+ `).map(e=>`-- ${e}`).join(`
3
+ `);function re(e,t,n,r,i={}){let a=n.ddl,o=r.database,s=e=>i.includeDrops?e:P(e),c=[`-- Schema sync: ${t.database} -> ${o} (${n.label})`,`-- Review before running. Statements that drop data are commented out unless "Include DROP statements" was checked.`,``];for(let r of e.missingInTarget)c.push(`-- Table ${r} is missing in the target`),c.push(F(r,t,n,o)),c.push(``);for(let t of e.changed){c.push(`-- Table ${t.table}`);for(let e of t.removedIndexes)c.push(s(a.dropIndex(o,t.table,e.name)));for(let e of t.changedIndexes)c.push(s(a.dropIndex(o,t.table,e.name)));for(let e of t.addedColumns)c.push(a.addColumn(o,t.table,e));for(let e of t.changedColumns){let r=a.alterColumn(o,t.table,e.source);c.push(r??P(`${n.label} cannot alter column ${e.name} in place (${e.attributes.join(`, `)}): recreate the table`))}for(let e of t.removedColumns)c.push(s(a.dropColumn(o,t.table,e.name)));for(let e of t.addedIndexes)c.push(a.createIndex(o,t.table,e));for(let e of t.changedIndexes)c.push(a.createIndex(o,t.table,e.source));c.push(``)}for(let t of e.missingInSource)c.push(`-- Table ${t} exists only in the target`),c.push(s(`DROP TABLE ${n.qualify(o,t)};`)),c.push(``);for(let t of e.objects){if(t.status===`identical`)continue;let e=`${t.type.charAt(0)}${t.type.slice(1).toLowerCase()} ${t.name}`,r=L(n,o,t);t.status===`missingInSource`?(c.push(`-- ${e} exists only in the target`),c.push(s(r))):(c.push(t.status===`changed`?`-- ${e} differs; recreated from the source`:`-- ${e} is missing in the target`),t.status===`changed`&&c.push(s(r)),c.push(t.source?.sql?R(t.source.sql):P(`the source engine did not return a CREATE statement for ${e}`))),c.push(``)}return c.join(`
4
+ `).replace(/\n{3,}/g,`
5
+
6
+ `).trim()+`
7
+ `}function F(e,t,n,r){let i=_(r,e,t.columns.get(e)??[],t.indexes.get(e)??[],null);return n.ddl.createTable(i)}var I={VIEW:`DROP_VIEW`,PROCEDURE:`DROP_PROCEDURE`,FUNCTION:`DROP_FUNCTION`,TRIGGER:`DROP_TRIGGER`,EVENT:`DROP_EVENT`};function L(e,t,n){let r=I[n.type];if(!e.hasQuery(r))return`-- ${e.label} has no ${n.type} objects`;let i=n.target?.table??n.source?.table??``;return`${e.getQuery(r,t,n.name,``,i).replace(/\s{2,}/g,` `).trim()};`}function R(e){let t=e.trim();return/;\s*$/.test(t)?t:`${t};`}var z=a(),B=e=>e instanceof Error?e.message:String(e),V=e=>`${e.type}:${e.name}`,H=e=>e.hostName||e.host||e.file||e.id;function U({id:e,label:t,side:n,onChange:r,connections:i,disabled:a}){let{t:s}=o(),[p,g]=(0,C.useState)([]),_=i.find(e=>e.id===n.connectionId);return(0,C.useEffect)(()=>{if(!_?.serverConnectionId)return;let e=!1,t=h(_.id),i=m(_.serverConnectionId);return(async()=>{try{let a=await t.introspect.listDatabases(i);if(e)return;g(a),a.includes(n.database)||r({connectionId:_.id,database:a[0]??``})}catch{e||g([])}})(),()=>{e=!0}},[_?.id,_?.serverConnectionId]),(0,z.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3`,children:[(0,z.jsx)(y,{className:`font-medium`,children:t}),(0,z.jsxs)(f,{value:n.connectionId,onValueChange:e=>r({connectionId:e,database:``}),disabled:a,children:[(0,z.jsx)(l,{id:`${e}-conn`,className:`w-full`,children:(0,z.jsx)(c,{placeholder:s(`database.diff.pickConnection`)})}),(0,z.jsx)(u,{children:i.map(e=>(0,z.jsx)(d,{value:e.id,children:H(e)},e.id))})]}),(0,z.jsxs)(f,{value:n.database,onValueChange:e=>r({...n,database:e}),disabled:a||p.length===0,children:[(0,z.jsx)(l,{id:`${e}-db`,className:`w-full`,children:(0,z.jsx)(c,{placeholder:s(`database.diff.pickDatabase`)})}),(0,z.jsx)(u,{children:p.map(e=>(0,z.jsx)(d,{value:e,children:e},e))})]})]})}async function W(e){let t=p.getState().activeConnections.find(t=>t.id===e.connectionId);if(!t?.serverConnectionId)throw Error(`Not connected`);let n=h(t.id),r=m(t.serverConnectionId),[i,a,o,s]=await Promise.all([n.introspect.listTables(r,e.database),n.introspect.listAllColumns(r,e.database),n.introspect.listAllIndexes(r,e.database),G(n,r,e.database)]);return{database:e.database,tables:i.map(e=>e.name).sort(),columns:a,indexes:o,objects:s}}async function G(e,t,n){let{introspect:r,capabilities:i}=e,a={VIEW:async()=>(await r.listViews(t,n)).map(e=>({name:e}))};i.procedures&&(a.PROCEDURE=async()=>(await r.listProcedures(t,n)).map(e=>({name:e}))),i.functions&&(a.FUNCTION=async()=>(await r.listFunctions(t,n)).map(e=>({name:e}))),i.triggers&&(a.TRIGGER=async()=>r.listTriggerDetails?r.listTriggerDetails(t,n):(await r.listTriggers(t,n)).map(e=>({name:e}))),i.events&&(a.EVENT=async()=>(await r.listEvents(t,n)).map(e=>({name:e})));let o=new Map;for(let e of w){let i=a[e];if(!i)continue;let s=await i(),c=new Map;for(let i of s){let a=null;try{a=await r.getCreateStatement(t,n,e,i.name)}catch{}c.set(i.name,i.table?{sql:a,table:i.table}:{sql:a})}o.set(e,c)}return o}function ie({diff:e}){let{t}=o(),n=e=>(0,z.jsx)(`pre`,{className:`whitespace-pre-wrap break-all text-xs font-mono`,children:e?e.sql??t(`database.diff.noDefinition`):`—`});return(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:t(`database.diff.source`)}),n(e.source)]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:t(`database.diff.target`)}),n(e.target)]})]})}var K=e=>`${e.type}${e.nullable?``:` NOT NULL`}${e.defaultValue===null?``:` DEFAULT ${e.defaultValue}`}${e.extra?` ${e.extra}`:``}`;function ae({diff:e}){let{t}=o(),n=[];for(let r of e.addedColumns)n.push({kind:t(`database.diff.column`),name:r.name,source:K(r),target:`—`,tone:`text-green-600 dark:text-green-400`});for(let r of e.removedColumns)n.push({kind:t(`database.diff.column`),name:r.name,source:`—`,target:K(r),tone:`text-destructive`});for(let r of e.changedColumns)n.push({kind:t(`database.diff.column`),name:`${r.name} (${r.attributes.join(`, `)})`,source:K(r.source),target:K(r.target),tone:`text-amber-600 dark:text-amber-400`});for(let r of e.addedIndexes)n.push({kind:t(`database.diff.index`),name:r.name,source:`${r.type} (${r.columns.join(`, `)})`,target:`—`,tone:`text-green-600 dark:text-green-400`});for(let r of e.removedIndexes)n.push({kind:t(`database.diff.index`),name:r.name,source:`—`,target:`${r.type} (${r.columns.join(`, `)})`,tone:`text-destructive`});for(let r of e.changedIndexes)n.push({kind:t(`database.diff.index`),name:r.name,source:`${r.source.type} (${r.source.columns.join(`, `)})`,target:`${r.target.type} (${r.target.columns.join(`, `)})`,tone:`text-amber-600 dark:text-amber-400`});return(0,z.jsxs)(`table`,{className:`w-full text-xs font-mono`,children:[(0,z.jsx)(`thead`,{className:`text-muted-foreground`,children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{className:`text-left font-normal pr-2`,children:t(`database.diff.object`)}),(0,z.jsx)(`th`,{className:`text-left font-normal pr-2`,children:t(`database.diff.source`)}),(0,z.jsx)(`th`,{className:`text-left font-normal`,children:t(`database.diff.target`)})]})}),(0,z.jsx)(`tbody`,{children:n.map((e,t)=>(0,z.jsxs)(`tr`,{className:e.tone,children:[(0,z.jsxs)(`td`,{className:`pr-2 align-top whitespace-nowrap`,children:[e.kind,` `,e.name]}),(0,z.jsx)(`td`,{className:`pr-2 align-top break-all`,children:e.source}),(0,z.jsx)(`td`,{className:`align-top break-all`,children:e.target})]},t))})]})}function q(){let{t:e}=o(),n=r(e=>e.activeDialog),a=r(e=>e.closeDialog),c=p(e=>e.activeConnections),l=(0,C.useMemo)(()=>c.filter(e=>e.serverConnectionId),[c]),u=p(e=>e.activeConnectionId),d=n===`schema-diff`,f=i(`schema-diff`),[m,_]=(0,C.useState)(()=>f&&l.some(e=>e.id===f.connectionId)?{connectionId:f.connectionId,database:f.database}:{connectionId:u&&l.some(e=>e.id===u)?u:l[0]?.id??``,database:``}),[y,w]=(0,C.useState)(()=>({connectionId:l.find(e=>e.id!==m.connectionId)?.id??m.connectionId,database:``})),[T,E]=(0,C.useState)(null),[D,O]=(0,C.useState)(null),[k,A]=(0,C.useState)(null),[j,M]=(0,C.useState)(!1),[P,F]=(0,C.useState)(!1),[I,L]=(0,C.useState)(!1),[R,H]=(0,C.useState)(null),G=m.connectionId===y.connectionId&&m.database===y.database,K=!!m.connectionId&&!!m.database&&!!y.connectionId&&!!y.database&&!G,q=y.connectionId?h(y.connectionId):null,J=m.connectionId?h(m.connectionId):null,oe=!!J&&!!q&&J.id!==q.id;async function se(){L(!0),H(null),O(null),A(null);try{let[e,n]=await Promise.all([W(m),W(y)]),r=N(e,n);E({source:e,target:n}),O(r);let i=f?.focus,a=null;if(i?.type===`TABLE`)a=r.changed.some(e=>e.table===i.name)?i.name:r.missingInTarget.includes(i.name)?`+${i.name}`:r.missingInSource.includes(i.name)?`-${i.name}`:null,r.identical.includes(i.name)&&F(!0);else if(i){let e=r.objects.find(e=>e.type===i.type&&e.name===i.name);e&&(a=V(e),e.status===`identical`&&F(!0))}A(a??r.changed[0]?.table??null),g(`compare_schemas`),t(`schema_diff`,{source_dbms:J?.id??`unknown`,target_dbms:q?.id??`unknown`,changed:r.changed.length,missing:r.missingInTarget.length+r.missingInSource.length})}catch(e){H(B(e))}finally{L(!1)}}let Y=(0,C.useMemo)(()=>!D||!T||!q?``:re(D,T.source,q,{database:y.database},{includeDrops:j}),[D,T,q,y.database,j]);function ce(){Y&&(v(y.connectionId,Y,y.database,e(`database.diff.tabTitle`,{database:y.database})),a())}let X=D?.changed.find(e=>e.table===k)??null,Z=D?.objects.find(e=>V(e)===k)??null,Q=D?.objects.filter(e=>e.status!==`identical`)??[],le=D?e(`database.diff.summary`,{changed:D.changed.length+Q.filter(e=>e.status===`changed`).length,missingTarget:D.missingInTarget.length+Q.filter(e=>e.status===`missingInTarget`).length,missingSource:D.missingInSource.length+Q.filter(e=>e.status===`missingInSource`).length,identical:D.identical.length+D.objects.filter(e=>e.status===`identical`).length}):``,$=!!D&&D.changed.length+D.missingInTarget.length+D.missingInSource.length+Q.length>0,ue=e=>e===`missingInTarget`?`text-green-600 dark:text-green-400`:e===`missingInSource`?`text-destructive`:e===`changed`?`text-amber-600 dark:text-amber-400`:`text-muted-foreground`,de=e=>e===`missingInTarget`?`+`:e===`missingInSource`?`-`:e===`changed`?`~`:`=`;return(0,z.jsx)(S,{open:d,onOpenChange:e=>{e||a()},children:(0,z.jsxs)(te,{className:`sm:max-w-[860px]`,children:[(0,z.jsx)(b,{children:(0,z.jsx)(ne,{children:e(`database.diff.title`)})}),(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,z.jsx)(U,{id:`diff-source`,label:e(`database.diff.source`),side:m,onChange:_,connections:l,disabled:I}),(0,z.jsx)(U,{id:`diff-target`,label:e(`database.diff.target`),side:y,onChange:w,connections:l,disabled:I})]}),oe&&(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`database.diff.crossEngineHint`)}),G&&m.database&&(0,z.jsx)(`p`,{className:`text-xs text-destructive`,children:e(`database.diff.sameSide`)}),R&&(0,z.jsx)(`p`,{className:`text-sm text-destructive whitespace-pre-wrap`,children:R}),D&&(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:le}),(0,z.jsxs)(`label`,{className:`flex items-center gap-1.5 cursor-pointer`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:P,onChange:e=>F(e.target.checked)}),e(`database.diff.showIdentical`)]})]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-[220px_1fr] gap-3 h-[300px]`,children:[(0,z.jsxs)(`ul`,{className:`overflow-auto rounded-md border text-sm`,children:[D.missingInTarget.map(e=>(0,z.jsxs)(`li`,{className:`px-2 py-1 cursor-pointer text-green-600 dark:text-green-400 ${k===`+${e}`?`bg-accent`:``}`,onClick:()=>A(`+${e}`),children:[`+ `,e]},`mt-${e}`)),D.changed.map(e=>(0,z.jsxs)(`li`,{className:`px-2 py-1 cursor-pointer text-amber-600 dark:text-amber-400 ${k===e.table?`bg-accent`:``}`,onClick:()=>A(e.table),children:[`~ `,e.table]},e.table)),D.missingInSource.map(e=>(0,z.jsxs)(`li`,{className:`px-2 py-1 cursor-pointer text-destructive ${k===`-${e}`?`bg-accent`:``}`,onClick:()=>A(`-${e}`),children:[`- `,e]},`ms-${e}`)),P&&D.identical.map(e=>(0,z.jsxs)(`li`,{className:`px-2 py-1 text-muted-foreground`,children:[`= `,e]},`id-${e}`)),D.objects.filter(e=>P||e.status!==`identical`).map(e=>(0,z.jsxs)(`li`,{className:`px-2 py-1 cursor-pointer ${ue(e.status)} ${k===V(e)?`bg-accent`:``}`,onClick:()=>A(V(e)),children:[de(e.status),` `,(0,z.jsxs)(`span`,{className:`text-muted-foreground`,children:[`[`,ee(e.type),`]`]}),` `,e.name]},V(e))),!$&&(0,z.jsx)(`li`,{className:`px-2 py-1 text-muted-foreground`,children:e(`database.diff.identicalAll`)})]}),(0,z.jsx)(`div`,{className:`overflow-auto rounded-md border p-2`,children:X?(0,z.jsx)(ae,{diff:X}):Z?(0,z.jsx)(ie,{diff:Z}):k?.startsWith(`+`)?(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`database.diff.missingInTarget`,{table:k.slice(1)})}):k?.startsWith(`-`)?(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`database.diff.missingInSource`,{table:k.slice(1)})}):(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`database.diff.selectTable`)})})]}),(0,z.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:j,onChange:e=>M(e.target.checked)}),(0,z.jsx)(`span`,{className:j?`text-destructive`:``,children:e(`database.diff.includeDrops`)})]})]})]}),(0,z.jsxs)(x,{children:[(0,z.jsx)(s,{variant:`outline`,onClick:a,children:e(`database.diff.close`)}),(0,z.jsx)(s,{variant:`secondary`,onClick:()=>{se()},disabled:!K||I,children:e(I?`database.diff.comparing`:`database.diff.compare`)}),(0,z.jsx)(s,{onClick:ce,disabled:!$,children:e(`database.diff.openScript`)})]})]})})}export{q as SchemaDiffDialog};