planche 0.8.4 → 0.8.5

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 (39) hide show
  1. package/app/assets/{aL0ab6hA.js → 1E6FYbv2.js} +1 -1
  2. package/app/assets/B-Mrqvrb.css +2 -0
  3. package/app/assets/{C-MJZp-k.js → B3uI9Ppb.js} +1 -1
  4. package/app/assets/{g4S828aR.js → B5OocgEJ.js} +1 -1
  5. package/app/assets/{B6gKGoJk.js → B8xQ2o-X.js} +1 -1
  6. package/app/assets/{3tVT9YMh.js → BGOnv2_O.js} +1 -1
  7. package/app/assets/{B2VNJYl8.js → BIjF9ulh.js} +1 -1
  8. package/app/assets/{DURNOOys.js → Bpg8LzYe.js} +1 -1
  9. package/app/assets/{BxOkJTYb.js → BunrDTHn.js} +1 -1
  10. package/app/assets/{Brk9GcZh.js → C3bMAsUp.js} +1 -1
  11. package/app/assets/{BQ74FNAM.js → C4il2fft.js} +1 -1
  12. package/app/assets/{1qhRpHKv.js → COIa4uoZ.js} +1 -1
  13. package/app/assets/{8OZbP3hw.js → CkgLFvM5.js} +1 -1
  14. package/app/assets/{nij0MMY5.js → Cx_chT_j.js} +1 -1
  15. package/app/assets/{2sxOfzyn.js → D7Ze5md9.js} +5 -5
  16. package/app/assets/{D2AdQhHv.js → DFNc4ghA.js} +1 -1
  17. package/app/assets/{vIgrQ7V1.js → DGD5v9rw.js} +1 -1
  18. package/app/assets/{f1Yh3VFu.js → DZH-tLW-.js} +1 -1
  19. package/app/assets/{DkdStXtl.js → D_2UqK4k.js} +1 -1
  20. package/app/assets/{BCZ2DwDi.js → Dd9Cr3e8.js} +1 -1
  21. package/app/assets/{7D95fvkQ.js → Dh3YJ3G1.js} +1 -1
  22. package/app/assets/{BrwCR6-9.js → DiaA_DOW.js} +1 -1
  23. package/app/assets/{D98JmiqU.js → DlKZCiMg.js} +2 -2
  24. package/app/assets/{MdnUPkBs.js → DmejZTwI.js} +1 -1
  25. package/app/assets/{OQSC6nip.js → DnjY8W6t.js} +1 -1
  26. package/app/assets/{C3uDTQB5.js → FnB_uI57.js} +1 -1
  27. package/app/assets/{oSIomP-s.js → IzH8qyLi.js} +1 -1
  28. package/app/assets/{CCBE6CSG.js → NY_tAtcY.js} +1 -1
  29. package/app/assets/{q4qvsmm4.js → QBd1UkiI.js} +1 -1
  30. package/app/assets/{DCkfyKy4.js → RIOwEE7M.js} +1 -1
  31. package/app/assets/{Bfw0mW2q.js → S4Oofhu9.js} +1 -1
  32. package/app/assets/{B4qi_yRV.js → cc05Z2oj.js} +1 -1
  33. package/app/assets/{B_0rFJQl.js → dxLVUFtU.js} +1 -1
  34. package/app/assets/{Clm7zeUD.js → fCzQKDqY.js} +1 -1
  35. package/app/assets/{BmSO6bVX.js → og5dTmtH.js} +1 -1
  36. package/app/assets/{Bfuq7Ecs.js → qbvehL2h.js} +1 -1
  37. package/app/index.html +3 -3
  38. package/package.json +1 -1
  39. package/app/assets/ZV96pIZb.css +0 -2
@@ -1 +1 @@
1
- import{r as e}from"./hePW80VL.js";import{c as t,h as n,n as r,t as i}from"./XzPc-eVf.js";import{l as a,m as o,t as s}from"./CKOS5Y-e.js";import{a as c,i as l,n as u,r as d,t as f}from"./DkdStXtl.js";import{t as p}from"./DTxGpkJp.js";import{a as m}from"./Cw_LYT6k.js";import{n as h}from"./DbRMSZEW.js";import{t as g}from"./B3LyCSVJ.js";import{V as _,_ as v,at as y,c as b,g as x,h as S}from"./2sxOfzyn.js";import{a as ee,i as te,n as C,o as w,t as ne}from"./DxuXBECK.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};
1
+ import{r as e}from"./hePW80VL.js";import{c as t,h as n,n as r,t as i}from"./XzPc-eVf.js";import{l as a,m as o,t as s}from"./CKOS5Y-e.js";import{a as c,i as l,n as u,r as d,t as f}from"./D_2UqK4k.js";import{t as p}from"./DTxGpkJp.js";import{a as m}from"./Cw_LYT6k.js";import{n as h}from"./DbRMSZEW.js";import{t as g}from"./B3LyCSVJ.js";import{V as _,_ as v,at as y,c as b,g as x,h as S}from"./D7Ze5md9.js";import{a as ee,i as te,n as C,o as w,t as ne}from"./DxuXBECK.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};
@@ -1 +1 @@
1
- import{r as e}from"./hePW80VL.js";import{h as t,n}from"./XzPc-eVf.js";import{l as r,m as i,t as a}from"./CKOS5Y-e.js";import{a as o}from"./ClyAuDY9.js";import{t as s}from"./DTxGpkJp.js";import{c}from"./Cw_LYT6k.js";import{t as l}from"./DbRMSZEW.js";import{C as u,S as d,b as f,ct as p,l as m,v as h,x as g,y as _}from"./2sxOfzyn.js";import{a as v,i as y,n as b,o as x,t as S}from"./DxuXBECK.js";var C=e(t(),1),w=r();function T(){let e=s.getState();return e.activeConnections.find(t=>t.id===e.activeConnectionId)?.serverConnectionId??null}async function E(e){let t=T();if(!t)throw Error(o.t(`command.noActiveConnection`));let n=l().getQuery(e===`global`?`SHOW_GLOBAL_VARIABLES`:`SHOW_SESSION_VARIABLES`);return(await c(t,n)).records.map(e=>({Variable_name:e[0],Value:e[1]}))}function D(){let{t:e}=i(),{activeDialog:t,closeDialog:r,setFooterMessage:o}=n(),[s,c]=(0,C.useState)([]),[l,T]=(0,C.useState)(``),[D,O]=(0,C.useState)(`session`),k=t===`variables`,A=(0,C.useCallback)(t=>E(t).then(c).catch(t=>o(e(`command.variables.loadError`,{message:t instanceof Error?t.message:String(t)}))),[o,e]);(0,C.useEffect)(()=>{k&&A(D)},[k,D,A]);let j=(0,C.useMemo)(()=>{if(!l.trim())return s;let e=l.toLowerCase();return s.filter(t=>t.Variable_name.toLowerCase().includes(e)||t.Value.toLowerCase().includes(e))},[s,l]);function M(e){e||(T(``),r())}function N(e){O(e)}return(0,w.jsx)(S,{open:k,onOpenChange:M,children:(0,w.jsxs)(b,{className:`sm:max-w-[900px] max-h-[80vh] flex flex-col`,children:[(0,w.jsx)(v,{children:(0,w.jsx)(x,{children:e(`command.variables.title`)})}),(0,w.jsxs)(`div`,{className:`flex items-center gap-3 pb-2`,children:[(0,w.jsxs)(`div`,{className:`flex gap-1`,children:[(0,w.jsx)(a,{variant:D===`session`?`default`:`outline`,size:`sm`,onClick:()=>N(`session`),children:e(`command.scope.session`)}),(0,w.jsx)(a,{variant:D===`global`?`default`:`outline`,size:`sm`,onClick:()=>N(`global`),children:e(`command.scope.global`)})]}),(0,w.jsx)(m,{placeholder:e(`command.variables.filterPlaceholder`),value:l,onChange:e=>T(e.target.value),className:`max-w-xs`})]}),(0,w.jsx)(`div`,{className:`flex-1 border rounded-md overflow-hidden min-h-0`,children:(0,w.jsx)(p,{className:`h-[400px]`,children:(0,w.jsxs)(h,{children:[(0,w.jsx)(d,{children:(0,w.jsxs)(u,{children:[(0,w.jsx)(g,{className:`w-[300px]`,children:e(`command.variableName`)}),(0,w.jsx)(g,{children:e(`command.value`)})]})}),(0,w.jsx)(_,{children:j.length===0?(0,w.jsx)(u,{children:(0,w.jsx)(f,{colSpan:2,className:`text-center text-muted-foreground`,children:e(`command.variables.empty`)})}):j.map(e=>(0,w.jsxs)(u,{children:[(0,w.jsx)(f,{className:`font-mono text-xs`,children:e.Variable_name}),(0,w.jsx)(f,{className:`font-mono text-xs`,children:e.Value})]},e.Variable_name))})]})})}),(0,w.jsx)(y,{children:(0,w.jsx)(a,{variant:`outline`,onClick:()=>M(!1),children:e(`command.close`)})})]})})}export{D as VariablesDialog};
1
+ import{r as e}from"./hePW80VL.js";import{h as t,n}from"./XzPc-eVf.js";import{l as r,m as i,t as a}from"./CKOS5Y-e.js";import{a as o}from"./ClyAuDY9.js";import{t as s}from"./DTxGpkJp.js";import{c}from"./Cw_LYT6k.js";import{t as l}from"./DbRMSZEW.js";import{C as u,S as d,b as f,ct as p,l as m,v as h,x as g,y as _}from"./D7Ze5md9.js";import{a as v,i as y,n as b,o as x,t as S}from"./DxuXBECK.js";var C=e(t(),1),w=r();function T(){let e=s.getState();return e.activeConnections.find(t=>t.id===e.activeConnectionId)?.serverConnectionId??null}async function E(e){let t=T();if(!t)throw Error(o.t(`command.noActiveConnection`));let n=l().getQuery(e===`global`?`SHOW_GLOBAL_VARIABLES`:`SHOW_SESSION_VARIABLES`);return(await c(t,n)).records.map(e=>({Variable_name:e[0],Value:e[1]}))}function D(){let{t:e}=i(),{activeDialog:t,closeDialog:r,setFooterMessage:o}=n(),[s,c]=(0,C.useState)([]),[l,T]=(0,C.useState)(``),[D,O]=(0,C.useState)(`session`),k=t===`variables`,A=(0,C.useCallback)(t=>E(t).then(c).catch(t=>o(e(`command.variables.loadError`,{message:t instanceof Error?t.message:String(t)}))),[o,e]);(0,C.useEffect)(()=>{k&&A(D)},[k,D,A]);let j=(0,C.useMemo)(()=>{if(!l.trim())return s;let e=l.toLowerCase();return s.filter(t=>t.Variable_name.toLowerCase().includes(e)||t.Value.toLowerCase().includes(e))},[s,l]);function M(e){e||(T(``),r())}function N(e){O(e)}return(0,w.jsx)(S,{open:k,onOpenChange:M,children:(0,w.jsxs)(b,{className:`sm:max-w-[900px] max-h-[80vh] flex flex-col`,children:[(0,w.jsx)(v,{children:(0,w.jsx)(x,{children:e(`command.variables.title`)})}),(0,w.jsxs)(`div`,{className:`flex items-center gap-3 pb-2`,children:[(0,w.jsxs)(`div`,{className:`flex gap-1`,children:[(0,w.jsx)(a,{variant:D===`session`?`default`:`outline`,size:`sm`,onClick:()=>N(`session`),children:e(`command.scope.session`)}),(0,w.jsx)(a,{variant:D===`global`?`default`:`outline`,size:`sm`,onClick:()=>N(`global`),children:e(`command.scope.global`)})]}),(0,w.jsx)(m,{placeholder:e(`command.variables.filterPlaceholder`),value:l,onChange:e=>T(e.target.value),className:`max-w-xs`})]}),(0,w.jsx)(`div`,{className:`flex-1 border rounded-md overflow-hidden min-h-0`,children:(0,w.jsx)(p,{className:`h-[400px]`,children:(0,w.jsxs)(h,{children:[(0,w.jsx)(d,{children:(0,w.jsxs)(u,{children:[(0,w.jsx)(g,{className:`w-[300px]`,children:e(`command.variableName`)}),(0,w.jsx)(g,{children:e(`command.value`)})]})}),(0,w.jsx)(_,{children:j.length===0?(0,w.jsx)(u,{children:(0,w.jsx)(f,{colSpan:2,className:`text-center text-muted-foreground`,children:e(`command.variables.empty`)})}):j.map(e=>(0,w.jsxs)(u,{children:[(0,w.jsx)(f,{className:`font-mono text-xs`,children:e.Variable_name}),(0,w.jsx)(f,{className:`font-mono text-xs`,children:e.Value})]},e.Variable_name))})]})})}),(0,w.jsx)(y,{children:(0,w.jsx)(a,{variant:`outline`,onClick:()=>M(!1),children:e(`command.close`)})})]})})}export{D as VariablesDialog};
@@ -1 +1 @@
1
- import{r as e}from"./hePW80VL.js";import{h as t,n}from"./XzPc-eVf.js";import{l as r,m as i,t as a}from"./CKOS5Y-e.js";import{a as o,i as s,n as c,r as l,t as u}from"./DkdStXtl.js";import{i as d,n as f}from"./BBSxV90W.js";import{b as p,c as m,d as h}from"./BdPEUnLq.js";import{c as g,l as _,w as v}from"./2sxOfzyn.js";import{a as y,i as b,n as x,o as S,r as C,t as w}from"./DxuXBECK.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};
1
+ import{r as e}from"./hePW80VL.js";import{h as t,n}from"./XzPc-eVf.js";import{l as r,m as i,t as a}from"./CKOS5Y-e.js";import{a as o,i as s,n as c,r as l,t as u}from"./D_2UqK4k.js";import{i as d,n as f}from"./BBSxV90W.js";import{b as p,c as m,d as h}from"./BdPEUnLq.js";import{c as g,l as _,w as v}from"./D7Ze5md9.js";import{a as y,i as b,n as x,o as S,r as C,t as w}from"./DxuXBECK.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};
@@ -1 +1 @@
1
- import{a as e,n as t}from"./XzPc-eVf.js";import{l as n,m as r,t as i}from"./CKOS5Y-e.js";import{r as a,t as o}from"./ClyAuDY9.js";import{a as s,i as c,n as l,r as u,t as d}from"./DkdStXtl.js";import{n as f}from"./BBSxV90W.js";import{a as p,i as m,n as h,o as g,r as _,t as v}from"./DxuXBECK.js";import{t as y}from"./CCBE6CSG.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"./XzPc-eVf.js";import{l as n,m as r,t as i}from"./CKOS5Y-e.js";import{r as a,t as o}from"./ClyAuDY9.js";import{a as s,i as c,n as l,r as u,t as d}from"./D_2UqK4k.js";import{n as f}from"./BBSxV90W.js";import{a as p,i as m,n as h,o as g,r as _,t as v}from"./DxuXBECK.js";import{t as y}from"./NY_tAtcY.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 +1 @@
1
- import{r as e}from"./hePW80VL.js";import{h as t,n,t as r}from"./XzPc-eVf.js";import{l as i,m as a,t as o}from"./CKOS5Y-e.js";import{a as s,i as c,n as l,r as u,t as d}from"./DkdStXtl.js";import{f,t as p}from"./DTxGpkJp.js";import{E as m,O as h,T as g,a as _,f as v,m as y}from"./BdPEUnLq.js";import{n as b}from"./CChaTOPr.js";import{S as x,d as S,g as C,i as w,l as T,r as E}from"./Cw_LYT6k.js";import{n as D,t as O}from"./C1RY7wUM.js";import{A as k,C as A,F as j,R 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,nt as z,o as B,r as re,s as V,u as H,v as ie,x as U,y as ae,yt as oe}from"./2sxOfzyn.js";import{a as se,i as ce,n as le,o as ue,t as de}from"./DxuXBECK.js";var W=e(t(),1),G=new Set([`postgres:`,`postgresql:`]);function K(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(!G.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 q=new Set([`localhost`,`127.0.0.1`,`[::1]`,`::1`,`0.0.0.0`]);async function J(e,t){let n;try{let t=new URL(e);if(!q.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 Y=i(),X=[`utf8`,`utf8mb4`,`latin1`,`ascii`,`euckr`,`sjis`,`big5`],Z={enabled:!1,host:``,port:22,user:``,auth:`key`};function Q({label:e,htmlFor:t,children:n}){return(0,Y.jsxs)(`div`,{className:`grid grid-cols-[120px_minmax(0,1fr)] items-center gap-2`,children:[(0,Y.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,W.useState)([]),p=e.dbms===`d1`?e.devUrl??``:``;(0,W.useEffect)(()=>{if(!p){f([]);return}let e=new AbortController,t=setTimeout(()=>{J(p,e.signal).then(f)},300);return()=>{clearTimeout(t),e.abort()}},[p]);let g=e.dbms===`sqlite`,_=e.transport??`browser`,v=g&&_===`browser`,y=m.has(e.dbms),b=e.dbms===`d1`,x=e.dbms===`do`,S=O.find(t=>t.id===e.dbms)?.capabilities,C=e.ssh??Z,[w,E]=(0,W.useState)(``),D=w.trim()===``?`empty`:K(w)?`applied`:`invalid`,A=e.dbms===`supabase`&&e.port===6543;function N(n){E(n);let r=K(n);r&&t({...e,host:r.host??e.host,port:r.port??O.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,Y.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,Y.jsx)(Q,{label:n(`connection.form.hostName`),htmlFor:`conn-hostName`,children:(0,Y.jsx)(R,{id:`conn-hostName`,placeholder:n(`connection.form.hostNamePlaceholder`),value:e.hostName,onChange:e=>r(`hostName`,e.target.value)})}),(0,Y.jsx)(Q,{label:n(`connection.form.dataSource`),children:(0,Y.jsxs)(d,{value:e.dbms,onValueChange:n=>{let r=O.find(e=>e.id===n);if(!r)return;let i=r.id,a=m.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?V(i):e.user,devUrl:i===`do`?e.devUrl||`http://localhost:8787`:e.devUrl,database:e.database&&!a&&!y&&!b&&!x?e.database:B(i)??e.database})},children:[(0,Y.jsx)(c,{id:`conn-dbms`,className:`w-full`,children:(0,Y.jsx)(s,{})}),(0,Y.jsx)(l,{children:O.map(e=>(0,Y.jsx)(u,{value:e.id,children:(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(H,{dbms:e.id}),e.label]})},e.id))})]})}),y&&(0,Y.jsx)(Q,{label:n(`connection.form.connectionString`),htmlFor:`conn-uri`,children:(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.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:w,onChange:e=>N(e.target.value)}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed ${D===`invalid`?`text-destructive`:`text-muted-foreground`}`,children:n(D===`invalid`?`connection.form.connectionStringInvalid`:D===`applied`?`connection.form.connectionStringApplied`:e.dbms===`neon`?`connection.form.neonHint`:`connection.form.supabaseHint`)})]})}),g&&(0,Y.jsxs)(Q,{label:n(`connection.form.openVia`),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm cursor-pointer`,children:[(0,Y.jsx)(`input`,{type:`radio`,name:`transport`,value:`browser`,checked:_===`browser`,onChange:()=>r(`transport`,`browser`),className:`accent-primary`}),n(`connection.form.viaBrowser`)]}),(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm cursor-pointer`,children:[(0,Y.jsx)(`input`,{type:`radio`,name:`transport`,value:`tunnel`,checked:_===`tunnel`,onChange:()=>r(`transport`,`tunnel`),className:`accent-primary`}),n(`connection.form.viaAgent`)]})]}),(0,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(_===`browser`?`connection.form.viaBrowserHint`:`connection.form.viaAgentHint`)})]}),v?(0,Y.jsx)(Q,{label:n(`connection.form.databaseFile`),children:(0,Y.jsxs)(`div`,{className:`min-w-0 text-xs text-muted-foreground leading-relaxed`,children:[e.file?(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 break-all text-foreground`,title:e.file,children:e.file}),(0,Y.jsx)(o,{type:`button`,variant:`outline`,size:`sm`,className:`h-6 shrink-0 px-2 text-xs`,onClick:()=>{T(e.id),r(`file`,``)},children:n(`connection.form.changeFile`)})]}):(0,Y.jsx)(`p`,{children:n(`connection.form.filePickerHint`)}),(0,Y.jsx)(`p`,{className:`mt-1`,children:n(`connection.form.fileRememberedHint`)})]})}):null,!v&&(0,Y.jsx)(Q,{label:n(`connection.form.authToken`),htmlFor:`conn-authToken`,children:(0,Y.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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:n(`connection.form.doDevUrl`),htmlFor:`conn-do-url`,children:(0,Y.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,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.doHint`)}),(0,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.doLimitsHint`)})]}):b?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:n(`connection.form.d1DevUrl`),htmlFor:`conn-d1-dev`,children:(0,Y.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,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1DevUrlHint`)}),(0,Y.jsx)(Q,{label:n(`connection.form.d1AccountId`),htmlFor:`conn-d1-account`,children:(0,Y.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,Y.jsx)(Q,{label:n(`connection.form.d1DatabaseId`),htmlFor:`conn-d1-database`,children:i.length>0?(0,Y.jsxs)(d,{value:e.databaseId??``,onValueChange:e=>r(`databaseId`,e),children:[(0,Y.jsx)(c,{id:`conn-d1-database`,children:(0,Y.jsx)(s,{placeholder:n(`connection.form.d1PickDatabase`)})}),(0,Y.jsx)(l,{children:i.map(e=>(0,Y.jsxs)(u,{value:e.id,children:[e.name,` · `,e.id]},e.id))})]}):(0,Y.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,Y.jsx)(Q,{label:n(`connection.form.d1ApiToken`),htmlFor:`conn-pass`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(R,{id:`conn-pass`,type:`password`,autoComplete:`new-password`,value:e.pass,onChange:e=>r(`pass`,e.target.value.trim())}),(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs whitespace-nowrap cursor-pointer`,title:n(`connection.form.savePasswordHint`),children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:e.savePassword??!0,onChange:e=>r(`savePassword`,e.target.checked)}),n(`connection.form.savePassword`)]})]})}),(0,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1Hint`)}),(0,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1LimitsHint`)})]}):g?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:n(`connection.form.databaseFile`),htmlFor:`conn-file`,children:(0,Y.jsx)(R,{id:`conn-file`,placeholder:n(`connection.form.filePathPlaceholder`),value:e.file??``,onChange:e=>r(`file`,e.target.value)})}),(0,Y.jsx)(Q,{label:n(`connection.form.createIfMissing`),htmlFor:`conn-create`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.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,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.createIfMissingHint`)})]})})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:n(`connection.form.host`),htmlFor:`conn-host`,children:(0,Y.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,Y.jsx)(Q,{label:n(`connection.form.port`),htmlFor:`conn-port`,children:(0,Y.jsx)(R,{id:`conn-port`,type:`number`,value:e.port,onChange:t=>r(`port`,Number(t.target.value)||O.find(t=>t.id===e.dbms)?.defaultPort||3306)})}),A&&(0,Y.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`)}),(h(e.dbms)||e.dbms===`mssql`||e.dbms===`oracle`)&&(0,Y.jsx)(Q,{label:e.dbms===`oracle`?n(`connection.form.serviceName`):n(`connection.form.database`),htmlFor:`conn-database`,children:(0,Y.jsx)(R,{id:`conn-database`,placeholder:B(e.dbms),value:e.database??``,onChange:e=>r(`database`,e.target.value.trim())})}),(0,Y.jsx)(Q,{label:n(`connection.form.user`),htmlFor:`conn-user`,children:(0,Y.jsx)(R,{id:`conn-user`,autoComplete:`off`,placeholder:V(e.dbms),value:e.user,onChange:e=>r(`user`,e.target.value)})}),(0,Y.jsx)(Q,{label:n(`connection.form.password`),htmlFor:`conn-pass`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(R,{id:`conn-pass`,type:`password`,autoComplete:`new-password`,value:e.pass,onChange:e=>r(`pass`,e.target.value)}),(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs whitespace-nowrap cursor-pointer`,title:n(`connection.form.savePasswordHint`),children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:e.savePassword??!0,onChange:e=>r(`savePassword`,e.target.checked)}),n(`connection.form.savePassword`)]})]})}),y&&(0,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.managedTlsHint`)}),!y&&e.dbms!==`oracle`&&(0,Y.jsx)(Q,{label:n(`connection.form.tls`),children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[(0,Y.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,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer ${e.ssl?``:`opacity-50`}`,title:n(`connection.form.tlsVerifyHint`),children:[(0,Y.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,Y.jsx)(Q,{label:n(`connection.form.charset`),children:(0,Y.jsxs)(d,{value:e.charset,onValueChange:e=>r(`charset`,e),children:[(0,Y.jsx)(c,{className:`w-full`,children:(0,Y.jsx)(s,{})}),(0,Y.jsx)(l,{children:X.map(e=>(0,Y.jsx)(u,{value:e,children:e},e))})]})})]}),!g&&!y&&!b&&!x&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.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,Y.jsx)(M,{className:`ml-2`})]}),(0,Y.jsx)(Q,{label:n(`connection.form.sshTunnel`),htmlFor:`conn-ssh`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`input`,{id:`conn-ssh`,type:`checkbox`,checked:C.enabled,onChange:e=>{(!e.target.checked||j(`ssh_tunnel`))&&P({enabled:e.target.checked})},className:`size-4 accent-primary cursor-pointer`}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.sshTunnelHint`)})]})}),C.enabled&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:n(`connection.form.sshHost`),htmlFor:`conn-ssh-host`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(R,{id:`conn-ssh-host`,placeholder:n(`connection.form.sshHostPlaceholder`),value:C.host,onChange:e=>P({host:e.target.value.trim()})}),(0,Y.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,Y.jsx)(Q,{label:n(`connection.form.sshUser`),htmlFor:`conn-ssh-user`,children:(0,Y.jsx)(R,{id:`conn-ssh-user`,placeholder:n(`connection.form.sshUserPlaceholder`),value:C.user,onChange:e=>P({user:e.target.value.trim()})})}),(0,Y.jsx)(Q,{label:n(`connection.form.sshAuth`),children:(0,Y.jsxs)(d,{value:C.auth,onValueChange:e=>P({auth:e}),children:[(0,Y.jsx)(c,{className:`w-full`,children:(0,Y.jsx)(s,{})}),(0,Y.jsxs)(l,{children:[(0,Y.jsx)(u,{value:`key`,children:n(`connection.form.sshAuthKey`)}),(0,Y.jsx)(u,{value:`password`,children:n(`connection.form.sshAuthPassword`)}),(0,Y.jsx)(u,{value:`agent`,children:n(`connection.form.sshAuthAgent`)})]})]})}),C.auth===`password`&&(0,Y.jsx)(Q,{label:n(`connection.form.sshPassword`),htmlFor:`conn-ssh-pass`,children:(0,Y.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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:n(`connection.form.sshKey`),htmlFor:`conn-ssh-key`,children:(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`input`,{id:`conn-ssh-key`,type:`file`,className:`hidden`,onChange:e=>{F(e.target.files?.[0]),e.target.value=``}}),(0,Y.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,Y.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,Y.jsx)(Q,{label:n(`connection.form.sshPassphrase`),htmlFor:`conn-ssh-passphrase`,children:(0,Y.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,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshAuthAgentHint`)}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshTargetHint`)}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshSecretsHint`)})]})]}),(0,Y.jsx)(Q,{label:n(`connection.form.autoConnection`),htmlFor:`conn-auto`,children:(0,Y.jsx)(`div`,{className:`flex items-center`,children:(0,Y.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,Y.jsx)(`div`,{className:`mt-1 border-t pt-3 text-xs font-medium text-muted-foreground`,children:n(`connection.form.safety`)}),(0,Y.jsx)(Q,{label:n(`connection.form.environment`),children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[L.map(t=>{let n=(e.environmentColor??`none`)===t.id;return(0,Y.jsx)(`button`,{type:`button`,title:k(t.id),"aria-label":k(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,Y.jsx)(`span`,{className:`ml-1 text-xs text-muted-foreground`,children:n(`connection.form.environmentHint`)})]})}),(0,Y.jsx)(Q,{label:n(`connection.form.readOnly`),htmlFor:`conn-readonly`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.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,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.readOnlyHint`)})]})}),S?.transactions!==!1&&(0,Y.jsx)(Q,{label:n(`connection.form.transactions`),children:(0,Y.jsxs)(d,{value:e.transactionMode??`auto`,onValueChange:e=>r(`transactionMode`,e),children:[(0,Y.jsx)(c,{className:`w-full`,children:(0,Y.jsx)(s,{})}),(0,Y.jsxs)(l,{children:[(0,Y.jsx)(u,{value:`auto`,children:n(`connection.form.txAuto`)}),(0,Y.jsx)(u,{value:`manual`,children:n(`connection.form.txManual`)})]})]})})]})}function $(){let{t:e}=a(),{activeDialog:t,closeDialog:i,showMessage:s}=n(),[c,l]=(0,W.useState)(!1),{savedConnections:u,addSavedConnection:d,updateSavedConnection:m,deleteSavedConnection:h,openConnection:T}=p(),O=r(`connect`)?.profileId,[k,j]=(0,W.useState)(()=>O??null),[M,I]=(0,W.useState)(()=>{let e=O?u.find(e=>e.id===O):void 0;return e?{...e}:null}),L=t===`connect`,[R,B]=(0,W.useState)(null),[V,G]=(0,W.useState)(null),K=z(e=>e.url),q=z(e=>e.token);(0,W.useEffect)(()=>{if(!L)return;let e=!1;return(async()=>{try{let t=await _();if(e||t.state!==`online`||!t.gateway){e||B(null);return}let n=await v();e||(B({name:n.gateway,profiles:n.profiles}),G(null))}catch(t){e||G(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[L,K,q]);function J(t){let r=u.find(e=>e.gatewayProfile===t.name);if(r){Z(r);return}let i=re(t);d(i),Z(i),n.getState().setFooterMessage(e(`connection.dialog.gatewayAdded`,{name:t.name}))}function X(e){e||(i(),j(null),I(null))}function Z(e){j(e.id),I({...e})}function Q(e){I(e),m(e.id,e)}function $(){let e=P();d(e),j(e.id),I(e)}function pe(){k&&(h(k),j(null),I(null))}let[me,he]=(0,W.useState)(!1),ge=b(e=>e.addQueryTab);function _e(t){let n=p.getState().activeConnections.some(e=>e.id===t.id);if(T(t),x.getState().removeTree(t.id),f(t.id),n){i(),j(null),I(null);return}ge(t.id,{id:`tab-${Date.now()}`,title:e(`connection.dialog.firstQueryTab`),query:``,database:``,isExecuting:!1,results:[],error:null,executionTime:null}),i(),j(null),I(null)}async function ve(t){let r=await E(t.id,{interactive:!0});if(!r)return;let i={...t,file:r.fileName,serverConnectionId:r.connectionId};m(t.id,{file:r.fileName}),_e(i),p.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 ye(t,r){try{return await r(t)}catch(i){let a=y(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 be(){if(M){he(!0);try{if(S(M)===`browser`){await ve(M);return}let t=await ye(g(M),e=>w(e,M.authToken||void 0));t.success?_e({...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{he(!1)}}}async function xe(){if(M){if(S(M)===`browser`){s({tone:`info`,title:e(`connection.dialog.testConnection`),description:e(`connection.dialog.browserTestHint`)});return}l(!0);try{let t=await ye(g(M),e=>C(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,Y.jsx)(de,{open:L,onOpenChange:X,children:(0,Y.jsxs)(le,{className:`sm:max-w-[1100px] h-[85vh] max-h-[85vh] flex flex-col`,children:[(0,Y.jsx)(se,{children:(0,Y.jsx)(ue,{children:e(`connection.dialog.title`)})}),(0,Y.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,Y.jsx)(oe,{className:`mt-0.5 size-4 shrink-0 text-catppuccin-green`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:e(`connection.dialog.privacy`)})]}),(0,Y.jsxs)(`div`,{className:`flex flex-1 gap-4 overflow-hidden min-h-0`,children:[(0,Y.jsxs)(`div`,{className:`w-[460px] shrink-0 border rounded-md overflow-hidden flex flex-col`,children:[(R||V)&&(0,Y.jsxs)(`div`,{className:`border-b p-2 text-xs space-y-1 max-h-40 overflow-auto`,children:[(0,Y.jsxs)(`p`,{className:`font-medium`,children:[e(`connection.dialog.gatewayTitle`),R?` — ${R.name}`:``]}),V&&(0,Y.jsx)(`p`,{className:`text-destructive`,children:e(`connection.dialog.gatewayLoadFailed`,{error:V})}),R?.profiles.map(t=>(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 truncate`,children:[(0,Y.jsx)(H,{dbms:ne[t.driver],className:`size-3.5`}),(0,Y.jsx)(`span`,{className:`truncate`,children:t.name}),(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,t.readOnly?e(`connection.dialog.gatewayReadOnly`):e(`connection.dialog.gatewayWritable`),`)`]})]}),(0,Y.jsx)(o,{size:`sm`,variant:`outline`,className:`h-6 px-2 text-xs`,onClick:()=>J(t),children:e(`connection.dialog.gatewayAdd`)})]},t.name))]}),(0,Y.jsx)(ee,{className:`h-full`,children:(0,Y.jsxs)(ie,{className:`table-fixed`,children:[(0,Y.jsx)(N,{children:(0,Y.jsxs)(A,{children:[(0,Y.jsx)(U,{className:`w-[32%]`,children:e(`connection.dialog.colHostName`)}),(0,Y.jsx)(U,{className:`w-[40%]`,children:e(`connection.dialog.colTarget`)}),(0,Y.jsx)(U,{className:`w-[28%]`,children:e(`connection.dialog.colDbms`)})]})}),(0,Y.jsx)(ae,{children:u.length===0?(0,Y.jsx)(A,{children:(0,Y.jsx)(F,{colSpan:3,className:`text-center text-muted-foreground`,children:e(`connection.dialog.noSaved`)})}):u.map(t=>(0,Y.jsxs)(A,{"data-state":k===t.id?`selected`:void 0,className:`cursor-pointer`,onClick:()=>Z(t),onDoubleClick:()=>{Z(t),be()},children:[(0,Y.jsx)(F,{className:`truncate font-medium`,title:t.hostName,children:t.hostName||e(`connection.dialog.unnamed`)}),(0,Y.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||(S(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,Y.jsx)(F,{className:`truncate`,title:D(t.dbms).label,children:(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(H,{dbms:t.dbms,className:`size-3.5`}),(0,Y.jsx)(`span`,{className:`truncate`,children:D(t.dbms).label})]})})]},t.id))})]})})]}),(0,Y.jsx)(`div`,{className:`flex-1 border rounded-md overflow-auto`,children:M?(0,Y.jsxs)(Y.Fragment,{children:[S(M)!==`browser`&&(0,Y.jsx)(`div`,{className:`p-4 pb-0`,children:(0,Y.jsx)(te,{})}),M.gatewayProfile?(0,Y.jsxs)(`div`,{className:`p-4 space-y-2 text-sm`,children:[(0,Y.jsxs)(`p`,{className:`font-medium flex items-center gap-2`,children:[(0,Y.jsx)(H,{dbms:M.dbms,className:`size-4`}),M.hostName]}),(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:e(`connection.dialog.gatewayProfileHint`,{name:M.gatewayProfile})}),(0,Y.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[M.readOnly?e(`connection.dialog.gatewayReadOnly`):e(`connection.dialog.gatewayWritable`),M.database?` · ${M.database}`:``]})]}):(0,Y.jsx)(fe,{value:M,onChange:Q})]}):(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:e(`connection.dialog.selectPrompt`)})})]}),(0,Y.jsxs)(ce,{className:`sm:justify-between`,children:[(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(o,{variant:`outline`,onClick:$,children:e(`connection.dialog.addNew`)}),(0,Y.jsx)(o,{variant:`destructive`,onClick:pe,disabled:!k,children:e(`connection.dialog.delete`)})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(o,{variant:`outline`,onClick:xe,disabled:!M||c,children:e(`connection.dialog.testConnection`)}),(0,Y.jsx)(o,{onClick:be,disabled:!M||me,children:e(`connection.dialog.connect`)}),(0,Y.jsx)(o,{variant:`outline`,onClick:()=>X(!1),children:e(`connection.dialog.close`)})]})]})]})})}export{$ as ConnectDialog};
1
+ import{r as e}from"./hePW80VL.js";import{h as t,n,t as r}from"./XzPc-eVf.js";import{l as i,m as a,t as o}from"./CKOS5Y-e.js";import{a as s,i as c,n as l,r as u,t as d}from"./D_2UqK4k.js";import{f,t as p}from"./DTxGpkJp.js";import{E as m,O as h,T as g,a as _,f as v,m as y}from"./BdPEUnLq.js";import{n as b}from"./CChaTOPr.js";import{S as x,d as S,g as C,i as w,l as T,r as E}from"./Cw_LYT6k.js";import{n as D,t as O}from"./C1RY7wUM.js";import{A as k,C as A,F as j,R 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,nt as z,o as B,r as re,s as V,u as H,v as ie,x as U,y as ae,yt as oe}from"./D7Ze5md9.js";import{a as se,i as ce,n as le,o as ue,t as de}from"./DxuXBECK.js";var W=e(t(),1),G=new Set([`postgres:`,`postgresql:`]);function K(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(!G.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 q=new Set([`localhost`,`127.0.0.1`,`[::1]`,`::1`,`0.0.0.0`]);async function J(e,t){let n;try{let t=new URL(e);if(!q.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 Y=i(),X=[`utf8`,`utf8mb4`,`latin1`,`ascii`,`euckr`,`sjis`,`big5`],Z={enabled:!1,host:``,port:22,user:``,auth:`key`};function Q({label:e,htmlFor:t,children:n}){return(0,Y.jsxs)(`div`,{className:`grid grid-cols-[120px_minmax(0,1fr)] items-center gap-2`,children:[(0,Y.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,W.useState)([]),p=e.dbms===`d1`?e.devUrl??``:``;(0,W.useEffect)(()=>{if(!p){f([]);return}let e=new AbortController,t=setTimeout(()=>{J(p,e.signal).then(f)},300);return()=>{clearTimeout(t),e.abort()}},[p]);let g=e.dbms===`sqlite`,_=e.transport??`browser`,v=g&&_===`browser`,y=m.has(e.dbms),b=e.dbms===`d1`,x=e.dbms===`do`,S=O.find(t=>t.id===e.dbms)?.capabilities,C=e.ssh??Z,[w,E]=(0,W.useState)(``),D=w.trim()===``?`empty`:K(w)?`applied`:`invalid`,A=e.dbms===`supabase`&&e.port===6543;function N(n){E(n);let r=K(n);r&&t({...e,host:r.host??e.host,port:r.port??O.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,Y.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,Y.jsx)(Q,{label:n(`connection.form.hostName`),htmlFor:`conn-hostName`,children:(0,Y.jsx)(R,{id:`conn-hostName`,placeholder:n(`connection.form.hostNamePlaceholder`),value:e.hostName,onChange:e=>r(`hostName`,e.target.value)})}),(0,Y.jsx)(Q,{label:n(`connection.form.dataSource`),children:(0,Y.jsxs)(d,{value:e.dbms,onValueChange:n=>{let r=O.find(e=>e.id===n);if(!r)return;let i=r.id,a=m.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?V(i):e.user,devUrl:i===`do`?e.devUrl||`http://localhost:8787`:e.devUrl,database:e.database&&!a&&!y&&!b&&!x?e.database:B(i)??e.database})},children:[(0,Y.jsx)(c,{id:`conn-dbms`,className:`w-full`,children:(0,Y.jsx)(s,{})}),(0,Y.jsx)(l,{children:O.map(e=>(0,Y.jsx)(u,{value:e.id,children:(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(H,{dbms:e.id}),e.label]})},e.id))})]})}),y&&(0,Y.jsx)(Q,{label:n(`connection.form.connectionString`),htmlFor:`conn-uri`,children:(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.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:w,onChange:e=>N(e.target.value)}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed ${D===`invalid`?`text-destructive`:`text-muted-foreground`}`,children:n(D===`invalid`?`connection.form.connectionStringInvalid`:D===`applied`?`connection.form.connectionStringApplied`:e.dbms===`neon`?`connection.form.neonHint`:`connection.form.supabaseHint`)})]})}),g&&(0,Y.jsxs)(Q,{label:n(`connection.form.openVia`),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm cursor-pointer`,children:[(0,Y.jsx)(`input`,{type:`radio`,name:`transport`,value:`browser`,checked:_===`browser`,onChange:()=>r(`transport`,`browser`),className:`accent-primary`}),n(`connection.form.viaBrowser`)]}),(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm cursor-pointer`,children:[(0,Y.jsx)(`input`,{type:`radio`,name:`transport`,value:`tunnel`,checked:_===`tunnel`,onChange:()=>r(`transport`,`tunnel`),className:`accent-primary`}),n(`connection.form.viaAgent`)]})]}),(0,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(_===`browser`?`connection.form.viaBrowserHint`:`connection.form.viaAgentHint`)})]}),v?(0,Y.jsx)(Q,{label:n(`connection.form.databaseFile`),children:(0,Y.jsxs)(`div`,{className:`min-w-0 text-xs text-muted-foreground leading-relaxed`,children:[e.file?(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 break-all text-foreground`,title:e.file,children:e.file}),(0,Y.jsx)(o,{type:`button`,variant:`outline`,size:`sm`,className:`h-6 shrink-0 px-2 text-xs`,onClick:()=>{T(e.id),r(`file`,``)},children:n(`connection.form.changeFile`)})]}):(0,Y.jsx)(`p`,{children:n(`connection.form.filePickerHint`)}),(0,Y.jsx)(`p`,{className:`mt-1`,children:n(`connection.form.fileRememberedHint`)})]})}):null,!v&&(0,Y.jsx)(Q,{label:n(`connection.form.authToken`),htmlFor:`conn-authToken`,children:(0,Y.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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:n(`connection.form.doDevUrl`),htmlFor:`conn-do-url`,children:(0,Y.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,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.doHint`)}),(0,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.doLimitsHint`)})]}):b?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:n(`connection.form.d1DevUrl`),htmlFor:`conn-d1-dev`,children:(0,Y.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,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1DevUrlHint`)}),(0,Y.jsx)(Q,{label:n(`connection.form.d1AccountId`),htmlFor:`conn-d1-account`,children:(0,Y.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,Y.jsx)(Q,{label:n(`connection.form.d1DatabaseId`),htmlFor:`conn-d1-database`,children:i.length>0?(0,Y.jsxs)(d,{value:e.databaseId??``,onValueChange:e=>r(`databaseId`,e),children:[(0,Y.jsx)(c,{id:`conn-d1-database`,children:(0,Y.jsx)(s,{placeholder:n(`connection.form.d1PickDatabase`)})}),(0,Y.jsx)(l,{children:i.map(e=>(0,Y.jsxs)(u,{value:e.id,children:[e.name,` · `,e.id]},e.id))})]}):(0,Y.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,Y.jsx)(Q,{label:n(`connection.form.d1ApiToken`),htmlFor:`conn-pass`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(R,{id:`conn-pass`,type:`password`,autoComplete:`new-password`,value:e.pass,onChange:e=>r(`pass`,e.target.value.trim())}),(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs whitespace-nowrap cursor-pointer`,title:n(`connection.form.savePasswordHint`),children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:e.savePassword??!0,onChange:e=>r(`savePassword`,e.target.checked)}),n(`connection.form.savePassword`)]})]})}),(0,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1Hint`)}),(0,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1LimitsHint`)})]}):g?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:n(`connection.form.databaseFile`),htmlFor:`conn-file`,children:(0,Y.jsx)(R,{id:`conn-file`,placeholder:n(`connection.form.filePathPlaceholder`),value:e.file??``,onChange:e=>r(`file`,e.target.value)})}),(0,Y.jsx)(Q,{label:n(`connection.form.createIfMissing`),htmlFor:`conn-create`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.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,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.createIfMissingHint`)})]})})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:n(`connection.form.host`),htmlFor:`conn-host`,children:(0,Y.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,Y.jsx)(Q,{label:n(`connection.form.port`),htmlFor:`conn-port`,children:(0,Y.jsx)(R,{id:`conn-port`,type:`number`,value:e.port,onChange:t=>r(`port`,Number(t.target.value)||O.find(t=>t.id===e.dbms)?.defaultPort||3306)})}),A&&(0,Y.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`)}),(h(e.dbms)||e.dbms===`mssql`||e.dbms===`oracle`)&&(0,Y.jsx)(Q,{label:e.dbms===`oracle`?n(`connection.form.serviceName`):n(`connection.form.database`),htmlFor:`conn-database`,children:(0,Y.jsx)(R,{id:`conn-database`,placeholder:B(e.dbms),value:e.database??``,onChange:e=>r(`database`,e.target.value.trim())})}),(0,Y.jsx)(Q,{label:n(`connection.form.user`),htmlFor:`conn-user`,children:(0,Y.jsx)(R,{id:`conn-user`,autoComplete:`off`,placeholder:V(e.dbms),value:e.user,onChange:e=>r(`user`,e.target.value)})}),(0,Y.jsx)(Q,{label:n(`connection.form.password`),htmlFor:`conn-pass`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(R,{id:`conn-pass`,type:`password`,autoComplete:`new-password`,value:e.pass,onChange:e=>r(`pass`,e.target.value)}),(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs whitespace-nowrap cursor-pointer`,title:n(`connection.form.savePasswordHint`),children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:e.savePassword??!0,onChange:e=>r(`savePassword`,e.target.checked)}),n(`connection.form.savePassword`)]})]})}),y&&(0,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.managedTlsHint`)}),!y&&e.dbms!==`oracle`&&(0,Y.jsx)(Q,{label:n(`connection.form.tls`),children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[(0,Y.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,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer ${e.ssl?``:`opacity-50`}`,title:n(`connection.form.tlsVerifyHint`),children:[(0,Y.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,Y.jsx)(Q,{label:n(`connection.form.charset`),children:(0,Y.jsxs)(d,{value:e.charset,onValueChange:e=>r(`charset`,e),children:[(0,Y.jsx)(c,{className:`w-full`,children:(0,Y.jsx)(s,{})}),(0,Y.jsx)(l,{children:X.map(e=>(0,Y.jsx)(u,{value:e,children:e},e))})]})})]}),!g&&!y&&!b&&!x&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.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,Y.jsx)(M,{className:`ml-2`})]}),(0,Y.jsx)(Q,{label:n(`connection.form.sshTunnel`),htmlFor:`conn-ssh`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`input`,{id:`conn-ssh`,type:`checkbox`,checked:C.enabled,onChange:e=>{(!e.target.checked||j(`ssh_tunnel`))&&P({enabled:e.target.checked})},className:`size-4 accent-primary cursor-pointer`}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.sshTunnelHint`)})]})}),C.enabled&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:n(`connection.form.sshHost`),htmlFor:`conn-ssh-host`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(R,{id:`conn-ssh-host`,placeholder:n(`connection.form.sshHostPlaceholder`),value:C.host,onChange:e=>P({host:e.target.value.trim()})}),(0,Y.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,Y.jsx)(Q,{label:n(`connection.form.sshUser`),htmlFor:`conn-ssh-user`,children:(0,Y.jsx)(R,{id:`conn-ssh-user`,placeholder:n(`connection.form.sshUserPlaceholder`),value:C.user,onChange:e=>P({user:e.target.value.trim()})})}),(0,Y.jsx)(Q,{label:n(`connection.form.sshAuth`),children:(0,Y.jsxs)(d,{value:C.auth,onValueChange:e=>P({auth:e}),children:[(0,Y.jsx)(c,{className:`w-full`,children:(0,Y.jsx)(s,{})}),(0,Y.jsxs)(l,{children:[(0,Y.jsx)(u,{value:`key`,children:n(`connection.form.sshAuthKey`)}),(0,Y.jsx)(u,{value:`password`,children:n(`connection.form.sshAuthPassword`)}),(0,Y.jsx)(u,{value:`agent`,children:n(`connection.form.sshAuthAgent`)})]})]})}),C.auth===`password`&&(0,Y.jsx)(Q,{label:n(`connection.form.sshPassword`),htmlFor:`conn-ssh-pass`,children:(0,Y.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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:n(`connection.form.sshKey`),htmlFor:`conn-ssh-key`,children:(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`input`,{id:`conn-ssh-key`,type:`file`,className:`hidden`,onChange:e=>{F(e.target.files?.[0]),e.target.value=``}}),(0,Y.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,Y.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,Y.jsx)(Q,{label:n(`connection.form.sshPassphrase`),htmlFor:`conn-ssh-passphrase`,children:(0,Y.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,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshAuthAgentHint`)}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshTargetHint`)}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshSecretsHint`)})]})]}),(0,Y.jsx)(Q,{label:n(`connection.form.autoConnection`),htmlFor:`conn-auto`,children:(0,Y.jsx)(`div`,{className:`flex items-center`,children:(0,Y.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,Y.jsx)(`div`,{className:`mt-1 border-t pt-3 text-xs font-medium text-muted-foreground`,children:n(`connection.form.safety`)}),(0,Y.jsx)(Q,{label:n(`connection.form.environment`),children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[L.map(t=>{let n=(e.environmentColor??`none`)===t.id;return(0,Y.jsx)(`button`,{type:`button`,title:k(t.id),"aria-label":k(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,Y.jsx)(`span`,{className:`ml-1 text-xs text-muted-foreground`,children:n(`connection.form.environmentHint`)})]})}),(0,Y.jsx)(Q,{label:n(`connection.form.readOnly`),htmlFor:`conn-readonly`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.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,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.readOnlyHint`)})]})}),S?.transactions!==!1&&(0,Y.jsx)(Q,{label:n(`connection.form.transactions`),children:(0,Y.jsxs)(d,{value:e.transactionMode??`auto`,onValueChange:e=>r(`transactionMode`,e),children:[(0,Y.jsx)(c,{className:`w-full`,children:(0,Y.jsx)(s,{})}),(0,Y.jsxs)(l,{children:[(0,Y.jsx)(u,{value:`auto`,children:n(`connection.form.txAuto`)}),(0,Y.jsx)(u,{value:`manual`,children:n(`connection.form.txManual`)})]})]})})]})}function $(){let{t:e}=a(),{activeDialog:t,closeDialog:i,showMessage:s}=n(),[c,l]=(0,W.useState)(!1),{savedConnections:u,addSavedConnection:d,updateSavedConnection:m,deleteSavedConnection:h,openConnection:T}=p(),O=r(`connect`)?.profileId,[k,j]=(0,W.useState)(()=>O??null),[M,I]=(0,W.useState)(()=>{let e=O?u.find(e=>e.id===O):void 0;return e?{...e}:null}),L=t===`connect`,[R,B]=(0,W.useState)(null),[V,G]=(0,W.useState)(null),K=z(e=>e.url),q=z(e=>e.token);(0,W.useEffect)(()=>{if(!L)return;let e=!1;return(async()=>{try{let t=await _();if(e||t.state!==`online`||!t.gateway){e||B(null);return}let n=await v();e||(B({name:n.gateway,profiles:n.profiles}),G(null))}catch(t){e||G(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[L,K,q]);function J(t){let r=u.find(e=>e.gatewayProfile===t.name);if(r){Z(r);return}let i=re(t);d(i),Z(i),n.getState().setFooterMessage(e(`connection.dialog.gatewayAdded`,{name:t.name}))}function X(e){e||(i(),j(null),I(null))}function Z(e){j(e.id),I({...e})}function Q(e){I(e),m(e.id,e)}function $(){let e=P();d(e),j(e.id),I(e)}function pe(){k&&(h(k),j(null),I(null))}let[me,he]=(0,W.useState)(!1),ge=b(e=>e.addQueryTab);function _e(t){let n=p.getState().activeConnections.some(e=>e.id===t.id);if(T(t),x.getState().removeTree(t.id),f(t.id),n){i(),j(null),I(null);return}ge(t.id,{id:`tab-${Date.now()}`,title:e(`connection.dialog.firstQueryTab`),query:``,database:``,isExecuting:!1,results:[],error:null,executionTime:null}),i(),j(null),I(null)}async function ve(t){let r=await E(t.id,{interactive:!0});if(!r)return;let i={...t,file:r.fileName,serverConnectionId:r.connectionId};m(t.id,{file:r.fileName}),_e(i),p.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 ye(t,r){try{return await r(t)}catch(i){let a=y(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 be(){if(M){he(!0);try{if(S(M)===`browser`){await ve(M);return}let t=await ye(g(M),e=>w(e,M.authToken||void 0));t.success?_e({...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{he(!1)}}}async function xe(){if(M){if(S(M)===`browser`){s({tone:`info`,title:e(`connection.dialog.testConnection`),description:e(`connection.dialog.browserTestHint`)});return}l(!0);try{let t=await ye(g(M),e=>C(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,Y.jsx)(de,{open:L,onOpenChange:X,children:(0,Y.jsxs)(le,{className:`sm:max-w-[1100px] h-[85vh] max-h-[85vh] flex flex-col`,children:[(0,Y.jsx)(se,{children:(0,Y.jsx)(ue,{children:e(`connection.dialog.title`)})}),(0,Y.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,Y.jsx)(oe,{className:`mt-0.5 size-4 shrink-0 text-catppuccin-green`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:e(`connection.dialog.privacy`)})]}),(0,Y.jsxs)(`div`,{className:`flex flex-1 gap-4 overflow-hidden min-h-0`,children:[(0,Y.jsxs)(`div`,{className:`w-[460px] shrink-0 border rounded-md overflow-hidden flex flex-col`,children:[(R||V)&&(0,Y.jsxs)(`div`,{className:`border-b p-2 text-xs space-y-1 max-h-40 overflow-auto`,children:[(0,Y.jsxs)(`p`,{className:`font-medium`,children:[e(`connection.dialog.gatewayTitle`),R?` — ${R.name}`:``]}),V&&(0,Y.jsx)(`p`,{className:`text-destructive`,children:e(`connection.dialog.gatewayLoadFailed`,{error:V})}),R?.profiles.map(t=>(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 truncate`,children:[(0,Y.jsx)(H,{dbms:ne[t.driver],className:`size-3.5`}),(0,Y.jsx)(`span`,{className:`truncate`,children:t.name}),(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,t.readOnly?e(`connection.dialog.gatewayReadOnly`):e(`connection.dialog.gatewayWritable`),`)`]})]}),(0,Y.jsx)(o,{size:`sm`,variant:`outline`,className:`h-6 px-2 text-xs`,onClick:()=>J(t),children:e(`connection.dialog.gatewayAdd`)})]},t.name))]}),(0,Y.jsx)(ee,{className:`h-full`,children:(0,Y.jsxs)(ie,{className:`table-fixed`,children:[(0,Y.jsx)(N,{children:(0,Y.jsxs)(A,{children:[(0,Y.jsx)(U,{className:`w-[32%]`,children:e(`connection.dialog.colHostName`)}),(0,Y.jsx)(U,{className:`w-[40%]`,children:e(`connection.dialog.colTarget`)}),(0,Y.jsx)(U,{className:`w-[28%]`,children:e(`connection.dialog.colDbms`)})]})}),(0,Y.jsx)(ae,{children:u.length===0?(0,Y.jsx)(A,{children:(0,Y.jsx)(F,{colSpan:3,className:`text-center text-muted-foreground`,children:e(`connection.dialog.noSaved`)})}):u.map(t=>(0,Y.jsxs)(A,{"data-state":k===t.id?`selected`:void 0,className:`cursor-pointer`,onClick:()=>Z(t),onDoubleClick:()=>{Z(t),be()},children:[(0,Y.jsx)(F,{className:`truncate font-medium`,title:t.hostName,children:t.hostName||e(`connection.dialog.unnamed`)}),(0,Y.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||(S(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,Y.jsx)(F,{className:`truncate`,title:D(t.dbms).label,children:(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(H,{dbms:t.dbms,className:`size-3.5`}),(0,Y.jsx)(`span`,{className:`truncate`,children:D(t.dbms).label})]})})]},t.id))})]})})]}),(0,Y.jsx)(`div`,{className:`flex-1 border rounded-md overflow-auto`,children:M?(0,Y.jsxs)(Y.Fragment,{children:[S(M)!==`browser`&&(0,Y.jsx)(`div`,{className:`p-4 pb-0`,children:(0,Y.jsx)(te,{})}),M.gatewayProfile?(0,Y.jsxs)(`div`,{className:`p-4 space-y-2 text-sm`,children:[(0,Y.jsxs)(`p`,{className:`font-medium flex items-center gap-2`,children:[(0,Y.jsx)(H,{dbms:M.dbms,className:`size-4`}),M.hostName]}),(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:e(`connection.dialog.gatewayProfileHint`,{name:M.gatewayProfile})}),(0,Y.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[M.readOnly?e(`connection.dialog.gatewayReadOnly`):e(`connection.dialog.gatewayWritable`),M.database?` · ${M.database}`:``]})]}):(0,Y.jsx)(fe,{value:M,onChange:Q})]}):(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:e(`connection.dialog.selectPrompt`)})})]}),(0,Y.jsxs)(ce,{className:`sm:justify-between`,children:[(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(o,{variant:`outline`,onClick:$,children:e(`connection.dialog.addNew`)}),(0,Y.jsx)(o,{variant:`destructive`,onClick:pe,disabled:!k,children:e(`connection.dialog.delete`)})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(o,{variant:`outline`,onClick:xe,disabled:!M||c,children:e(`connection.dialog.testConnection`)}),(0,Y.jsx)(o,{onClick:be,disabled:!M||me,children:e(`connection.dialog.connect`)}),(0,Y.jsx)(o,{variant:`outline`,onClick:()=>X(!1),children:e(`connection.dialog.close`)})]})]})]})})}export{$ as ConnectDialog};
@@ -1 +1 @@
1
- import{r as e}from"./hePW80VL.js";import{h as t,n}from"./XzPc-eVf.js";import{l as r,m as i,t as a}from"./CKOS5Y-e.js";import{At as o,I as s,M as c,N as l,P as u,c as d,l as f,tt as p}from"./2sxOfzyn.js";import{a as m,i as h,n as g,o as _,r as v,t as y}from"./DxuXBECK.js";import{t as b}from"./8OZbP3hw.js";var x=e(t(),1);function S(){let e=s(e=>e.status.state===`valid`);return!u()||e}var C=r(),w={offline:`sync.offline`,server:`sync.serverError`,unauthorized:`sync.serverError`,conflict:`sync.serverError`,"bad-passphrase":`sync.wrongPassphrase`,malformed:`sync.wrongPassphrase`,unsupported:`sync.serverError`};function T(){let e=n(e=>e.activeDialog),t=n(e=>e.closeDialog),{phase:r,user:s,busy:u,error:T,lastSyncedAt:E,vault:D,refresh:O,createVault:k,unlock:A,push:j,signOut:M,forgetVault:N,closeAccount:P,setError:F}=c(),{t:I}=i(),L=S(),[R,z]=(0,x.useState)(``),[B,V]=(0,x.useState)(``),[H,U]=(0,x.useState)(!1),[W,G]=(0,x.useState)(!1);(0,x.useEffect)(()=>{O()},[O]);let K=R.length>0&&R.length<10,q=B.length>0&&R!==B,J=R.length>=10&&R===B,Y=T?I(w[T]??`sync.serverError`):null,X=D?Object.keys(D.profiles).length:0,Z=()=>{z(``),V(``),F(null)};return(0,C.jsx)(y,{open:e===`sync`,onOpenChange:e=>{e||t()},children:(0,C.jsxs)(g,{className:`max-h-[85vh] overflow-y-auto sm:max-w-[560px]`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,C.jsxs)(m,{children:[(0,C.jsx)(_,{children:I(`sync.title`)}),(0,C.jsxs)(v,{children:[I(`sync.description`),s&&(0,C.jsx)(`span`,{className:`mt-1 block text-xs`,children:I(`sync.signedInAs`,{email:s.email??s.id})})]})]}),(0,C.jsxs)(`div`,{className:`grid gap-3 text-sm`,children:[(0,C.jsx)(`p`,{className:`rounded-md border bg-muted/40 p-3 text-xs text-muted-foreground`,children:I(`sync.stored`)}),r===`unavailable`&&(0,C.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:p()?I(`sync.unavailable`):I(`sync.notDeployed`)}),r===`signed-out`&&(0,C.jsxs)(a,{onClick:()=>{window.location.href=l(`github`,window.location.href)},children:[(0,C.jsx)(o,{className:`size-4`}),I(`sync.signIn`)]}),s&&!L&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:I(`sync.needsPro`)}),(0,C.jsx)(b,{highlight:`sync`})]}),L&&r===`no-vault`&&(0,C.jsxs)(`div`,{className:`grid gap-2`,children:[(0,C.jsx)(`p`,{className:`text-sm font-medium`,children:I(`sync.createTitle`)}),(0,C.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:I(`sync.createHint`)}),(0,C.jsx)(d,{htmlFor:`sync-pass`,children:I(`sync.passphrase`)}),(0,C.jsx)(f,{id:`sync-pass`,type:`password`,autoComplete:`new-password`,value:R,onChange:e=>{z(e.target.value),F(null)}}),(0,C.jsx)(d,{htmlFor:`sync-confirm`,children:I(`sync.confirm`)}),(0,C.jsx)(f,{id:`sync-confirm`,type:`password`,autoComplete:`new-password`,value:B,onChange:e=>{V(e.target.value),F(null)}}),K&&(0,C.jsx)(`p`,{className:`text-xs text-destructive`,children:I(`sync.tooShort`,{count:10})}),q&&(0,C.jsx)(`p`,{className:`text-xs text-destructive`,children:I(`sync.mismatch`)}),(0,C.jsx)(a,{disabled:!J||u,onClick:()=>{k(R).then(Z)},children:I(`sync.enable`)})]}),L&&r===`locked`&&(0,C.jsxs)(`div`,{className:`grid gap-2`,children:[(0,C.jsx)(`p`,{className:`text-sm font-medium`,children:I(`sync.unlockTitle`)}),(0,C.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:I(`sync.unlockHint`)}),(0,C.jsx)(d,{htmlFor:`sync-unlock`,children:I(`sync.passphrase`)}),(0,C.jsx)(f,{id:`sync-unlock`,type:`password`,autoComplete:`current-password`,value:R,onChange:e=>{z(e.target.value),F(null)}}),(0,C.jsx)(a,{disabled:!R||u,onClick:()=>{A(R).then(Z)},children:I(`sync.unlock`)})]}),L&&r===`ready`&&(0,C.jsxs)(`div`,{className:`grid gap-2`,children:[(0,C.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[E?I(`sync.lastSynced`,{when:new Date(E).toLocaleString()}):I(`sync.neverSynced`),` · `,I(`sync.profiles`,{count:X})]}),(0,C.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,C.jsx)(a,{variant:`secondary`,disabled:u,onClick:()=>{U(!1),j()},children:I(`sync.syncNow`)}),(0,C.jsx)(a,{variant:`ghost`,disabled:u,onClick:()=>{c.getState().lock(),Z()},children:I(`sync.changePassphrase`)})]}),H?(0,C.jsxs)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 p-3`,children:[(0,C.jsx)(`p`,{className:`mb-2 text-xs`,children:I(`sync.deleteVaultConfirm`)}),(0,C.jsxs)(`div`,{className:`flex gap-2`,children:[(0,C.jsx)(a,{variant:`destructive`,disabled:u,onClick:()=>{N().then(()=>U(!1))},children:I(`sync.deleteVault`)}),(0,C.jsx)(a,{variant:`ghost`,onClick:()=>U(!1),children:I(`settings.done`)})]})]}):(0,C.jsx)(a,{variant:`ghost`,className:`justify-start px-0 text-destructive`,onClick:()=>U(!0),children:I(`sync.deleteVault`)})]}),s&&(W?(0,C.jsxs)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 p-3`,children:[(0,C.jsx)(`p`,{className:`mb-2 text-xs`,children:I(`sync.deleteAccountConfirm`)}),(0,C.jsxs)(`div`,{className:`flex gap-2`,children:[(0,C.jsx)(a,{variant:`destructive`,disabled:u,onClick:()=>{P().then(()=>G(!1))},children:I(`sync.deleteAccount`)}),(0,C.jsx)(a,{variant:`ghost`,onClick:()=>G(!1),children:I(`settings.done`)})]})]}):(0,C.jsx)(`button`,{type:`button`,onClick:()=>G(!0),className:`w-fit rounded-sm text-xs text-muted-foreground underline underline-offset-2 hover:text-destructive focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,children:I(`sync.deleteAccount`)})),u&&(0,C.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:I(`sync.working`)}),Y&&(0,C.jsx)(`p`,{className:`text-xs text-destructive`,children:Y})]}),(0,C.jsxs)(h,{children:[s&&(0,C.jsx)(a,{variant:`ghost`,disabled:u,onClick:()=>{M().then(Z)},children:I(`sync.signOut`)}),(0,C.jsx)(a,{onClick:t,children:I(`settings.done`)})]})]})})}export{T as SyncDialog};
1
+ import{r as e}from"./hePW80VL.js";import{h as t,n}from"./XzPc-eVf.js";import{l as r,m as i,t as a}from"./CKOS5Y-e.js";import{At as o,I as s,M as c,N as l,P as u,c as d,l as f,tt as p}from"./D7Ze5md9.js";import{a as m,i as h,n as g,o as _,r as v,t as y}from"./DxuXBECK.js";import{t as b}from"./CkgLFvM5.js";var x=e(t(),1);function S(){let e=s(e=>e.status.state===`valid`);return!u()||e}var C=r(),w={offline:`sync.offline`,server:`sync.serverError`,unauthorized:`sync.serverError`,conflict:`sync.serverError`,"bad-passphrase":`sync.wrongPassphrase`,malformed:`sync.wrongPassphrase`,unsupported:`sync.serverError`};function T(){let e=n(e=>e.activeDialog),t=n(e=>e.closeDialog),{phase:r,user:s,busy:u,error:T,lastSyncedAt:E,vault:D,refresh:O,createVault:k,unlock:A,push:j,signOut:M,forgetVault:N,closeAccount:P,setError:F}=c(),{t:I}=i(),L=S(),[R,z]=(0,x.useState)(``),[B,V]=(0,x.useState)(``),[H,U]=(0,x.useState)(!1),[W,G]=(0,x.useState)(!1);(0,x.useEffect)(()=>{O()},[O]);let K=R.length>0&&R.length<10,q=B.length>0&&R!==B,J=R.length>=10&&R===B,Y=T?I(w[T]??`sync.serverError`):null,X=D?Object.keys(D.profiles).length:0,Z=()=>{z(``),V(``),F(null)};return(0,C.jsx)(y,{open:e===`sync`,onOpenChange:e=>{e||t()},children:(0,C.jsxs)(g,{className:`max-h-[85vh] overflow-y-auto sm:max-w-[560px]`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,C.jsxs)(m,{children:[(0,C.jsx)(_,{children:I(`sync.title`)}),(0,C.jsxs)(v,{children:[I(`sync.description`),s&&(0,C.jsx)(`span`,{className:`mt-1 block text-xs`,children:I(`sync.signedInAs`,{email:s.email??s.id})})]})]}),(0,C.jsxs)(`div`,{className:`grid gap-3 text-sm`,children:[(0,C.jsx)(`p`,{className:`rounded-md border bg-muted/40 p-3 text-xs text-muted-foreground`,children:I(`sync.stored`)}),r===`unavailable`&&(0,C.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:p()?I(`sync.unavailable`):I(`sync.notDeployed`)}),r===`signed-out`&&(0,C.jsxs)(a,{onClick:()=>{window.location.href=l(`github`,window.location.href)},children:[(0,C.jsx)(o,{className:`size-4`}),I(`sync.signIn`)]}),s&&!L&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:I(`sync.needsPro`)}),(0,C.jsx)(b,{highlight:`sync`})]}),L&&r===`no-vault`&&(0,C.jsxs)(`div`,{className:`grid gap-2`,children:[(0,C.jsx)(`p`,{className:`text-sm font-medium`,children:I(`sync.createTitle`)}),(0,C.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:I(`sync.createHint`)}),(0,C.jsx)(d,{htmlFor:`sync-pass`,children:I(`sync.passphrase`)}),(0,C.jsx)(f,{id:`sync-pass`,type:`password`,autoComplete:`new-password`,value:R,onChange:e=>{z(e.target.value),F(null)}}),(0,C.jsx)(d,{htmlFor:`sync-confirm`,children:I(`sync.confirm`)}),(0,C.jsx)(f,{id:`sync-confirm`,type:`password`,autoComplete:`new-password`,value:B,onChange:e=>{V(e.target.value),F(null)}}),K&&(0,C.jsx)(`p`,{className:`text-xs text-destructive`,children:I(`sync.tooShort`,{count:10})}),q&&(0,C.jsx)(`p`,{className:`text-xs text-destructive`,children:I(`sync.mismatch`)}),(0,C.jsx)(a,{disabled:!J||u,onClick:()=>{k(R).then(Z)},children:I(`sync.enable`)})]}),L&&r===`locked`&&(0,C.jsxs)(`div`,{className:`grid gap-2`,children:[(0,C.jsx)(`p`,{className:`text-sm font-medium`,children:I(`sync.unlockTitle`)}),(0,C.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:I(`sync.unlockHint`)}),(0,C.jsx)(d,{htmlFor:`sync-unlock`,children:I(`sync.passphrase`)}),(0,C.jsx)(f,{id:`sync-unlock`,type:`password`,autoComplete:`current-password`,value:R,onChange:e=>{z(e.target.value),F(null)}}),(0,C.jsx)(a,{disabled:!R||u,onClick:()=>{A(R).then(Z)},children:I(`sync.unlock`)})]}),L&&r===`ready`&&(0,C.jsxs)(`div`,{className:`grid gap-2`,children:[(0,C.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[E?I(`sync.lastSynced`,{when:new Date(E).toLocaleString()}):I(`sync.neverSynced`),` · `,I(`sync.profiles`,{count:X})]}),(0,C.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,C.jsx)(a,{variant:`secondary`,disabled:u,onClick:()=>{U(!1),j()},children:I(`sync.syncNow`)}),(0,C.jsx)(a,{variant:`ghost`,disabled:u,onClick:()=>{c.getState().lock(),Z()},children:I(`sync.changePassphrase`)})]}),H?(0,C.jsxs)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 p-3`,children:[(0,C.jsx)(`p`,{className:`mb-2 text-xs`,children:I(`sync.deleteVaultConfirm`)}),(0,C.jsxs)(`div`,{className:`flex gap-2`,children:[(0,C.jsx)(a,{variant:`destructive`,disabled:u,onClick:()=>{N().then(()=>U(!1))},children:I(`sync.deleteVault`)}),(0,C.jsx)(a,{variant:`ghost`,onClick:()=>U(!1),children:I(`settings.done`)})]})]}):(0,C.jsx)(a,{variant:`ghost`,className:`justify-start px-0 text-destructive`,onClick:()=>U(!0),children:I(`sync.deleteVault`)})]}),s&&(W?(0,C.jsxs)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 p-3`,children:[(0,C.jsx)(`p`,{className:`mb-2 text-xs`,children:I(`sync.deleteAccountConfirm`)}),(0,C.jsxs)(`div`,{className:`flex gap-2`,children:[(0,C.jsx)(a,{variant:`destructive`,disabled:u,onClick:()=>{P().then(()=>G(!1))},children:I(`sync.deleteAccount`)}),(0,C.jsx)(a,{variant:`ghost`,onClick:()=>G(!1),children:I(`settings.done`)})]})]}):(0,C.jsx)(`button`,{type:`button`,onClick:()=>G(!0),className:`w-fit rounded-sm text-xs text-muted-foreground underline underline-offset-2 hover:text-destructive focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,children:I(`sync.deleteAccount`)})),u&&(0,C.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:I(`sync.working`)}),Y&&(0,C.jsx)(`p`,{className:`text-xs text-destructive`,children:Y})]}),(0,C.jsxs)(h,{children:[s&&(0,C.jsx)(a,{variant:`ghost`,disabled:u,onClick:()=>{M().then(Z)},children:I(`sync.signOut`)}),(0,C.jsx)(a,{onClick:t,children:I(`settings.done`)})]})]})})}export{T as SyncDialog};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./hePW80VL.js";import{h as t,n}from"./XzPc-eVf.js";import{l as r,m as i,t as a}from"./CKOS5Y-e.js";import{a as o,i as s,n as c,r as l,t as u}from"./DkdStXtl.js";import{t as d}from"./DTxGpkJp.js";import{n as f}from"./CChaTOPr.js";import{S as p,a as m}from"./Cw_LYT6k.js";import{n as h}from"./DbRMSZEW.js";import{o as g,r as _}from"./BM5G_YA7.js";import{c as v,ct as y}from"./2sxOfzyn.js";import{a as b,i as x,n as S,o as C,t as w}from"./DxuXBECK.js";import{t as T}from"./CnYBZPf9.js";var E=e(t(),1),D=r();function O(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function k(){let{t:e}=i(),{activeDialog:t,closeDialog:r}=n(),{activeConnectionId:k,activeConnections:A}=d(),{trees:j}=p(),M=f(),N=t===`export-html`,P=(0,E.useMemo)(()=>k?_(j[k]??[]):[],[k,j]),F=(0,E.useMemo)(()=>{if(!k)return``;let e=M.activeTabId[k];return(M.tabs[k]??[]).find(t=>t.id===e)?.database||``},[k,M.activeTabId,M.tabs]),[I,L]=(0,E.useState)(``),R=(0,E.useMemo)(()=>!k||!I?[]:g(j[k]??[],I),[k,I,j]),[z,B]=(0,E.useState)([]),[V,H]=(0,E.useState)(!0),[U,W]=(0,E.useState)(!0),[G,K]=(0,E.useState)(!0),[q,J]=(0,E.useState)(!1);(0,E.useEffect)(()=>{N&&F&&L(F)},[N,F]);function Y(e){e||(r(),L(``),B([]),H(!0),W(!0),K(!0))}function X(e){B(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}function Z(){B(R.length===z.length?[]:[...R])}async function Q(){if(z.length===0||!k)return;let t=A.find(e=>e.id===k);if(!t?.serverConnectionId)return;J(!0);let{introspect:n}=h(k),i=m(t.serverConnectionId),a=(e,t,n)=>{let r=`<h3>${O(e)}</h3>\n<table border="1" cellpadding="4" cellspacing="0">\n`;r+=`<tr>${t.map(e=>`<th>${O(e)}</th>`).join(``)}</tr>\n`;for(let e of n)r+=`<tr>${e.map(e=>`<td>${O(e==null?`NULL`:String(e))}</td>`).join(``)}</tr>\n`;return r+`</table>
1
+ import{r as e}from"./hePW80VL.js";import{h as t,n}from"./XzPc-eVf.js";import{l as r,m as i,t as a}from"./CKOS5Y-e.js";import{a as o,i as s,n as c,r as l,t as u}from"./D_2UqK4k.js";import{t as d}from"./DTxGpkJp.js";import{n as f}from"./CChaTOPr.js";import{S as p,a as m}from"./Cw_LYT6k.js";import{n as h}from"./DbRMSZEW.js";import{o as g,r as _}from"./BM5G_YA7.js";import{c as v,ct as y}from"./D7Ze5md9.js";import{a as b,i as x,n as S,o as C,t as w}from"./DxuXBECK.js";import{t as T}from"./CnYBZPf9.js";var E=e(t(),1),D=r();function O(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function k(){let{t:e}=i(),{activeDialog:t,closeDialog:r}=n(),{activeConnectionId:k,activeConnections:A}=d(),{trees:j}=p(),M=f(),N=t===`export-html`,P=(0,E.useMemo)(()=>k?_(j[k]??[]):[],[k,j]),F=(0,E.useMemo)(()=>{if(!k)return``;let e=M.activeTabId[k];return(M.tabs[k]??[]).find(t=>t.id===e)?.database||``},[k,M.activeTabId,M.tabs]),[I,L]=(0,E.useState)(``),R=(0,E.useMemo)(()=>!k||!I?[]:g(j[k]??[],I),[k,I,j]),[z,B]=(0,E.useState)([]),[V,H]=(0,E.useState)(!0),[U,W]=(0,E.useState)(!0),[G,K]=(0,E.useState)(!0),[q,J]=(0,E.useState)(!1);(0,E.useEffect)(()=>{N&&F&&L(F)},[N,F]);function Y(e){e||(r(),L(``),B([]),H(!0),W(!0),K(!0))}function X(e){B(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}function Z(){B(R.length===z.length?[]:[...R])}async function Q(){if(z.length===0||!k)return;let t=A.find(e=>e.id===k);if(!t?.serverConnectionId)return;J(!0);let{introspect:n}=h(k),i=m(t.serverConnectionId),a=(e,t,n)=>{let r=`<h3>${O(e)}</h3>\n<table border="1" cellpadding="4" cellspacing="0">\n`;r+=`<tr>${t.map(e=>`<th>${O(e)}</th>`).join(``)}</tr>\n`;for(let e of n)r+=`<tr>${e.map(e=>`<td>${O(e==null?`NULL`:String(e))}</td>`).join(``)}</tr>\n`;return r+`</table>
2
2
  `};try{let t=[];for(let r of z){let o=`<h2>${O(r)}</h2>\n`;if(V){let t=await n.listColumns(i,I,r);t.length>0&&(o+=a(e(`database.html.sectionColumns`),[`Field`,`Type`,`Null`,`Key`,`Default`,`Extra`,`Comment`],t.map(e=>[e.name,e.type,e.nullable?`YES`:`NO`,e.key,e.defaultValue,e.extra,e.comment])))}if(U){let t=await n.listIndexes(i,I,r);t.length>0&&(o+=a(e(`database.html.sectionIndexes`),[`Key_name`,`Type`,`Columns`],t.map(e=>[e.name,e.type,e.columns.join(`, `)])))}if(G){let t=await n.getTableInfo(i,I,r);t&&(o+=a(e(`database.html.sectionProperties`),[`Name`,`Engine`,`Collation`,`Rows`,`Data_length`,`Create_time`,`Update_time`,`Comment`],[[t.name,t.engine,t.collation,t.rows,t.dataLength,t.createTime,t.updateTime,t.comment]]))}t.push(o)}let r=`<!DOCTYPE html>
3
3
  <html lang="en">
4
4
  <head>
@@ -1,2 +1,2 @@
1
- import{r as e}from"./hePW80VL.js";import{h as t,n,t as r}from"./XzPc-eVf.js";import{a as i,l as a,m as o,t as s}from"./CKOS5Y-e.js";import{t as c}from"./DTxGpkJp.js";import{n as l}from"./BBSxV90W.js";import{a as u}from"./Cw_LYT6k.js";import{l as d,t as f}from"./D98JmiqU.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"./2sxOfzyn.js";import{a as C,i as w,n as T,o as E,r as ee,t as D}from"./DxuXBECK.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(`
1
+ import{r as e}from"./hePW80VL.js";import{h as t,n,t as r}from"./XzPc-eVf.js";import{a as i,l as a,m as o,t as s}from"./CKOS5Y-e.js";import{t as c}from"./DTxGpkJp.js";import{n as l}from"./BBSxV90W.js";import{a as u}from"./Cw_LYT6k.js";import{l as d,t as f}from"./DlKZCiMg.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"./D7Ze5md9.js";import{a as C,i as w,n as T,o as E,r as ee,t as D}from"./DxuXBECK.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
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};
package/app/index.html CHANGED
@@ -50,7 +50,7 @@
50
50
  "offers": { "@type": "Offer", "price": "0", "priceCurrency": "USD" }
51
51
  }
52
52
  </script>
53
- <script type="module" crossorigin src="/assets/2sxOfzyn.js"></script>
53
+ <script type="module" crossorigin src="/assets/D7Ze5md9.js"></script>
54
54
  <link rel="modulepreload" crossorigin href="/assets/hePW80VL.js">
55
55
  <link rel="modulepreload" crossorigin href="/assets/XzPc-eVf.js">
56
56
  <link rel="modulepreload" crossorigin href="/assets/CKOS5Y-e.js">
@@ -68,10 +68,10 @@
68
68
  <link rel="modulepreload" crossorigin href="/assets/DAFA-E1-.js">
69
69
  <link rel="modulepreload" crossorigin href="/assets/BM5G_YA7.js">
70
70
  <link rel="modulepreload" crossorigin href="/assets/CfsL8_WC.js">
71
- <link rel="modulepreload" crossorigin href="/assets/D98JmiqU.js">
71
+ <link rel="modulepreload" crossorigin href="/assets/DlKZCiMg.js">
72
72
  <link rel="modulepreload" crossorigin href="/assets/B3LyCSVJ.js">
73
73
  <link rel="modulepreload" crossorigin href="/assets/Bs5VSn0X.js">
74
- <link rel="stylesheet" crossorigin href="/assets/ZV96pIZb.css">
74
+ <link rel="stylesheet" crossorigin href="/assets/B-Mrqvrb.css">
75
75
  </head>
76
76
  <body>
77
77
  <div id="boot">Loading…</div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "planche",
3
- "version": "0.8.4",
3
+ "version": "0.8.5",
4
4
  "description": "Local agent for Planche — lets the browser-based Planche SQL client reach MySQL/MariaDB/PostgreSQL/SQLite/SQL Server/Oracle/Neon/Supabase/Cloudflare D1 databases and local Durable Object storage from your machine.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "homepage": "https://planche.dev",