planche 0.9.2 → 0.9.4
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.
- package/app/assets/{B4S-lOKS.js → 2HDxyxt3.js} +1 -1
- package/app/assets/{W7D4Svcn.js → 2WcjYcT6.js} +1 -1
- package/app/assets/{G06qjCej.js → 34iJa-68.js} +1 -1
- package/app/assets/{CFUkTo-F.js → 62772Vyq.js} +1 -1
- package/app/assets/{XCH_yrJ8.js → 7hKKrols.js} +1 -1
- package/app/assets/92hmrkfN.css +2 -0
- package/app/assets/{CTnwm-29.js → AR0v7sKO.js} +1 -1
- package/app/assets/B5FoXN4H.js +1 -0
- package/app/assets/{DCHRj2vY.js → BB2_KYgp.js} +1 -1
- package/app/assets/{Bbx7_Uyd.js → BHsv1P4D.js} +1 -1
- package/app/assets/{D3lUezEb.js → BI5Ig187.js} +1 -1
- package/app/assets/{ByKF67UY.js → BRKvj3qd.js} +1 -1
- package/app/assets/{CFu5QMhX.js → BTpuv2bS.js} +1 -1
- package/app/assets/{BkXrfAoR.js → BVZGLNq_.js} +1 -1
- package/app/assets/{Djxg54qH.js → BWPrOT1U.js} +1 -1
- package/app/assets/{84VwJAQi.js → BaTnCkNR.js} +1 -1
- package/app/assets/{7jG9Xw-H.js → BdhjYiGI.js} +1 -1
- package/app/assets/{D8_hwGjG.js → BihjBM79.js} +1 -1
- package/app/assets/{BrVnzO7b.js → Bjx1jzlk.js} +1 -1
- package/app/assets/{7jD5h8Yx.js → BkujllIu.js} +1 -1
- package/app/assets/{BPPUDpI0.js → BtBUwOf0.js} +1 -1
- package/app/assets/{B9dhM8vw.js → Buf-_p3w.js} +1 -1
- package/app/assets/{CrlnxAGW.js → BvkNY7SP.js} +1 -1
- package/app/assets/{BGvsBpIS.js → C-8Bh-gu.js} +1 -1
- package/app/assets/{BMFLhX-x.js → C1JbR1mO.js} +1 -1
- package/app/assets/{DPyLA6Dl.js → C3AWL5gC.js} +1 -1
- package/app/assets/{BQ1Rcyw6.js → C3aiaYZP.js} +1 -1
- package/app/assets/{Cu_sGzNJ.js → C76CctEl.js} +1 -1
- package/app/assets/{DHZOxCSJ.js → C82F2LSh.js} +1 -1
- package/app/assets/{CoZCOAph.js → CCJEQIo6.js} +1 -1
- package/app/assets/{DzdX4vRD.js → CDfygETm.js} +1 -1
- package/app/assets/{BixvbqFe.js → CGpFMM6B.js} +1 -1
- package/app/assets/{BRZhVXRC.js → CH4cEkW4.js} +1 -1
- package/app/assets/{D9QeXBOk.js → CKUISE0C.js} +1 -1
- package/app/assets/{BNB62Dfu.js → CN1CF2CU.js} +1 -1
- package/app/assets/{D0Ya12SQ.js → CRYDH2ct.js} +1 -1
- package/app/assets/{BnJGrP6V.js → CZRhmV_L.js} +2 -2
- package/app/assets/{C1gqjEN3.js → C_qmv4pB.js} +1 -1
- package/app/assets/{CgQ0qqq4.js → CcaDuuFY.js} +1 -1
- package/app/assets/{D1kyupCL.js → Cm-pfCIP.js} +1 -1
- package/app/assets/{BDtsGuIR.js → Cme0nCT7.js} +2 -2
- package/app/assets/{BhX9zWzC.js → CoUCmmSB.js} +1 -1
- package/app/assets/{B7zF7RU4.js → CtsakJNi.js} +1 -1
- package/app/assets/{DNHPk-9r.js → Cw4TnfXm.js} +1 -1
- package/app/assets/{BYvM8E39.js → CxaujQob.js} +1 -1
- package/app/assets/{CYz610vE.js → CyX8oVsa.js} +1 -1
- package/app/assets/{CRnmOOqq.js → D-DAzfgs.js} +1 -1
- package/app/assets/{BPmMKRmE.js → D3VPMNTU.js} +1 -1
- package/app/assets/{CExE8dKz.js → D4DxtYTA.js} +185 -184
- package/app/assets/{C6712dxU.js → D4c1cZWk.js} +1 -1
- package/app/assets/{C1kpKIsO.js → DG0u2CPf.js} +1 -1
- package/app/assets/{CHx7zgT8.js → DKObYbZY.js} +1 -1
- package/app/assets/{DU-Eln5x.js → DOy06rIE.js} +1 -1
- package/app/assets/{aIFwnVFr.js → DPKD37gk.js} +1 -1
- package/app/assets/{DpEN2jyA.js → DT8Xdk78.js} +1 -1
- package/app/assets/{Do7KpDxk.js → DXExbVos.js} +1 -1
- package/app/assets/{BSziALTN.js → DXQPcWS6.js} +1 -1
- package/app/assets/{kXDKfUfE.js → DjsycSVl.js} +1 -1
- package/app/assets/{CiL8zoYm.js → Dya0zxo6.js} +1 -1
- package/app/assets/{DTkqO0Em.js → IqMoIce-.js} +1 -1
- package/app/assets/{CrhJJH3f.js → MeOkctzz.js} +1 -1
- package/app/assets/{DF7EZh_S.js → NL8WOYEo.js} +1 -1
- package/app/assets/{D8dVzi6I.js → Ngd1VEiY.js} +1 -1
- package/app/assets/UEkRIZwQ.js +1 -0
- package/app/assets/{BGuDcBB_.js → UJzcIbfW.js} +1 -1
- package/app/assets/{C77ZEZfM.js → W81Xd8P5.js} +1 -1
- package/app/assets/{DaBfnZOJ.js → Yn5aIyLX.js} +1 -1
- package/app/assets/{BMBWoD5w.js → _N3A-NTc.js} +1 -1
- package/app/assets/{qRIRkBN0.js → gvCOWBS0.js} +1 -1
- package/app/assets/{S7HbowYz.js → iz6RnRcO.js} +71 -71
- package/app/assets/{DzRyVlxz.js → kTwcxyaO.js} +1 -1
- package/app/assets/{tJkeLYCp.js → oXAkF219.js} +1 -1
- package/app/assets/{BTaXXwBP.js → pDR31rvF.js} +1 -1
- package/app/assets/{BEH9Jqkv.js → u9a-WHjb.js} +1 -1
- package/app/assets/{BbOETtQZ.js → yLCKuLgs.js} +1 -1
- package/app/assets/{CaU3pCK6.js → yfRSh-O-.js} +1 -1
- package/app/assets/{BjwrN_ch.js → zdvaVsTo.js} +1 -1
- package/app/index.html +20 -20
- package/package.json +1 -1
- package/app/assets/9gOj-Ty3.js +0 -1
- package/app/assets/BFw3KCAr.js +0 -1
- package/app/assets/w46wk7KI.css +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./hePW80VL.js";import{p as t}from"./
|
|
1
|
+
import{r as e}from"./hePW80VL.js";import{p as t}from"./CyX8oVsa.js";import{t as n}from"./Dya0zxo6.js";import{i as r,r as i}from"./C76CctEl.js";import{a,i as o,n as s,o as c,t as l}from"./kTwcxyaO.js";import{a as u,i as d,n as f,r as p,t as m}from"./34iJa-68.js";import{t as h}from"./iz6RnRcO.js";import{n as g}from"./BihjBM79.js";import{c as _,l as v}from"./D4DxtYTA.js";import{n as y}from"./7hKKrols.js";var b=e(t(),1),x=i();function S(){let{t:e}=r(),{activeDialog:t,closeDialog:i,setFooterMessage:S}=g(),C=h(e=>e.activeConnectionId)??``,w=y(e=>e.addUser),[T,E]=(0,b.useState)(``),[D,O]=(0,b.useState)(`%`),[k,A]=(0,b.useState)(``),[j,M]=(0,b.useState)(``),[N,P]=(0,b.useState)(`caching_sha2_password`),F=t===`user-add`;function I(e){e||(L(),i())}function L(){E(``),O(`%`),A(``),M(``),P(`caching_sha2_password`)}function R(){if(!T.trim()){S(e(`user.add.usernameRequired`));return}if(k!==j){S(e(`user.add.passwordMismatch`));return}w(C,{user:T.trim(),host:D.trim()||`%`,privileges:[],maxQuestions:0,maxUpdates:0,maxConnections:0,maxUserConnections:0,plugin:N,authenticationString:``,passwordExpired:!1,accountLocked:!1}),S(e(`user.add.added`,{user:T,host:D})),L(),i()}return(0,x.jsx)(l,{open:F,onOpenChange:I,children:(0,x.jsxs)(s,{className:`sm:max-w-[450px]`,children:[(0,x.jsx)(a,{children:(0,x.jsx)(c,{children:e(`user.add.title`)})}),(0,x.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{htmlFor:`user-add-username`,children:e(`user.add.username`)}),(0,x.jsx)(v,{id:`user-add-username`,value:T,onChange:e=>E(e.target.value),placeholder:e(`user.add.usernamePlaceholder`)})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{htmlFor:`user-add-host`,children:e(`user.add.host`)}),(0,x.jsx)(v,{id:`user-add-host`,value:D,onChange:e=>O(e.target.value),placeholder:`%`})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{htmlFor:`user-add-password`,children:e(`user.add.password`)}),(0,x.jsx)(v,{id:`user-add-password`,type:`password`,value:k,onChange:e=>A(e.target.value),placeholder:e(`user.add.passwordPlaceholder`)})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{htmlFor:`user-add-confirm-password`,children:e(`user.add.confirmPassword`)}),(0,x.jsx)(v,{id:`user-add-confirm-password`,type:`password`,value:j,onChange:e=>M(e.target.value),placeholder:e(`user.add.confirmPasswordPlaceholder`)})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{children:e(`user.add.plugin`)}),(0,x.jsxs)(m,{value:N,onValueChange:P,children:[(0,x.jsx)(d,{className:`w-full`,children:(0,x.jsx)(u,{})}),(0,x.jsxs)(f,{children:[(0,x.jsx)(p,{value:`mysql_native_password`,children:`mysql_native_password`}),(0,x.jsx)(p,{value:`caching_sha2_password`,children:`caching_sha2_password`})]})]})]})]}),(0,x.jsxs)(o,{children:[(0,x.jsx)(n,{variant:`outline`,onClick:()=>I(!1),children:e(`user.add.cancel`)}),(0,x.jsx)(n,{onClick:R,children:e(`user.add.add`)})]})]})})}export{S as UserAddDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./
|
|
1
|
+
import{r as e}from"./C76CctEl.js";import{H as t}from"./D4DxtYTA.js";var n=e();function r({id:e,checked:r,onChange:i,label:a,hint:o,pro:s}){return(0,n.jsxs)(`label`,{htmlFor:e,className:`flex cursor-pointer items-start gap-3 rounded-md border p-3 hover:bg-accent/40`,children:[(0,n.jsx)(`input`,{id:e,type:`checkbox`,checked:r,onChange:e=>i(e.target.checked),className:`mt-0.5 size-4 accent-primary`}),(0,n.jsxs)(`span`,{className:`grid flex-1 gap-0.5`,children:[(0,n.jsxs)(`span`,{className:`flex items-center text-sm font-medium`,children:[a,s?(0,n.jsx)(t,{}):null]}),(0,n.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:o})]})]})}export{r as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./hePW80VL.js";import{p as t}from"./
|
|
1
|
+
import{r as e}from"./hePW80VL.js";import{p as t}from"./CyX8oVsa.js";import{t as n}from"./Dya0zxo6.js";import{i as r,n as i,r as a}from"./C76CctEl.js";import{a as o,i as s,n as c,o as l,r as ee,t as u}from"./kTwcxyaO.js";import{t as d}from"./iz6RnRcO.js";import{n as f}from"./DOy06rIE.js";import{n as p,t as m}from"./BihjBM79.js";import{a as h}from"./BVZGLNq_.js";import{a as g,f as _}from"./CZRhmV_L.js";import{Bt as v,Gt as y,Kt as b,Rt as x,Xt as S,_t as C,f as w,h as T,m as E,p as D}from"./D4DxtYTA.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:i}){let{t:a}=r(),o=`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:o,value:t.text===`true`||t.text===`1`?`true`:`false`,onChange:e=>i(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:o,value:t.text,onChange:e=>i(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 r=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:r.has(t),disabled:n,onChange:n=>{let a=new Set(r);n.target.checked?a.add(t):a.delete(t),i(e.options.filter(e=>a.has(e)).join(`,`))}}),t]},t))})}case`integer`:case`decimal`:return(0,L.jsx)(`input`,{className:`${o} tabular-nums`,inputMode:`decimal`,value:t.text,onChange:e=>i(e.target.value),disabled:n,placeholder:e.kind===`integer`?`0`:`0.00`});case`date`:case`datetime`:{let[r,s]=t.text.trim().split(/[ T]/);return(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(`input`,{className:`${o} flex-1`,value:t.text,onChange:e=>i(e.target.value),disabled:n,placeholder:e.kind===`date`?`YYYY-MM-DD`:`YYYY-MM-DD HH:MM:SS`}),(0,L.jsxs)(D,{children:[(0,L.jsx)(T,{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:a(`result.rowForm.pickDate`),children:(0,L.jsx)(S,{className:`size-3.5`})})}),(0,L.jsx)(E,{className:`w-auto p-0`,align:`end`,children:(0,L.jsx)(w,{mode:`single`,selected:V(r??``),defaultMonth:V(r??``),onSelect:t=>{if(!t)return;let n=`${t.getFullYear()}-${z(t.getMonth()+1)}-${z(t.getDate())}`;i(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:()=>i(B(e.kind)),title:a(`result.rowForm.now`),children:(0,L.jsx)(y,{className:`size-3.5`})})]})}case`time`:return(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(`input`,{className:`${o} flex-1`,value:t.text,onChange:e=>i(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:()=>i(B(`time`)),title:a(`result.rowForm.now`),children:(0,L.jsx)(y,{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:`${o} min-h-[96px] resize-y text-xs ${e?``:`border-destructive`}`,value:t.text,onChange:e=>i(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{i(JSON.stringify(JSON.parse(t.text),null,2))}catch{}},children:[(0,L.jsx)(O,{className:`size-3`}),a(`result.rowForm.formatJson`)]}),!e&&(0,L.jsx)(`span`,{className:`text-[10px] text-destructive`,children:a(`result.rowForm.invalid.json`)})]})]})}case`text`:return(0,L.jsx)(`textarea`,{className:`${o} min-h-[72px] resize-y`,value:t.text,onChange:e=>i(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:a(`result.rowForm.binaryUnsupported`)});case`uuid`:return(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(`input`,{className:`${o} flex-1`,value:t.text,onChange:e=>i(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:()=>i(crypto.randomUUID()),title:a(`result.rowForm.generateUuid`),children:(0,L.jsx)(O,{className:`size-3.5`})})]});default:{let r=t.text.length>80||t.text.includes(`
|
|
2
2
|
`);return(0,L.jsxs)(`div`,{className:`space-y-0.5`,children:[r?(0,L.jsx)(`textarea`,{className:`${o} min-h-[56px] resize-y`,value:t.text,onChange:e=>i(e.target.value),disabled:n,spellCheck:!1}):(0,L.jsx)(`input`,{className:o,value:t.text,onChange:e=>i(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}=r(),t=m(`row-form`),i=p(e=>e.closeDialog),a=p(e=>e.setFooterMessage),y=C(t?.connectionId??``),S=d(e=>t?e.transactionOpen[t.connectionId]:!1),[w,T]=(0,k.useState)(null),[E,D]=(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=h(t.serverConnectionId);return y.introspect.listColumns(n,t.database,t.table).then(n=>{if(e)return;T(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||D(t instanceof Error?t.message:String(t))}),()=>{e=!0}},[t?.serverConnectionId,t?.database,t?.table,t?.mode]);let G=(0,k.useMemo)(()=>new Map((w??[]).map(e=>[e.name,j(e,{oracleDate:y.id===`oracle`})])),[w,y.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(!w)return null;let t=new Map,n={};for(let r of w){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}},[w,O,G,e,J]),X=(0,k.useCallback)(e=>{if(!t)return null;let n=e=>e===J?`DEFAULT`:y.quoteLiteral(e);if(t.mode===`insert`){let r=[...e];return r.length===0?y.getQuery(`INSERT_DEFAULT_VALUES`,t.database,t.table):y.getQuery(`INSERT_TABLE`,t.database,t.table,r.map(([e])=>y.quoteIdentifier(e)).join(`, `),r.map(([,e])=>n(e)).join(`, `))}return!t.where||e.size===0?null:y.getQuery(`UPDATE_TABLE`,t.database,t.table,[...e].map(([e,t])=>`${y.quoteIdentifier(e)} = ${n(t)}`).join(`, `),t.where)},[t,y,J]),Z=(0,k.useMemo)(()=>{if(!w)return``;let e=new Map;for(let t of w){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)??``},[w,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 n=Y();if(!n||!t)return;let r=X(n.values);if(!r){B(e(`result.rowForm.nothingToWrite`));return}U(!0),B(null);try{if(f.getState().previewGridCommit&&!await p.getState().requestDestructiveConfirm({title:e(W?`result.rowForm.confirmUpdateTitle`:`result.rowForm.confirmInsertTitle`,{table:`${t.database}.${t.table}`}),statements:[r],confirmLabel:e(W?`result.rowForm.update`:`result.rowForm.insert`)}))return;await g(t.connectionId,r,{database:t.database,skipDestructiveConfirm:!0}),a(e(W?`result.rowForm.updated`:`result.rowForm.inserted`,{table:`${t.database}.${t.table}`})),t.onCommitted?.(t.mode,Q(n.values)),i()}catch(e){if(e instanceof _)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)(u,{open:!0,onOpenChange:e=>{e||i()},children:(0,L.jsxs)(c,{className:`flex max-h-[90vh] flex-col sm:max-w-[860px]`,children:[(0,L.jsxs)(o,{children:[(0,L.jsx)(l,{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:[E&&(0,L.jsx)(`div`,{className:`rounded border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:E}),!w&&!E&&(0,L.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-10 text-sm text-muted-foreground`,children:[(0,L.jsx)(x,{className:`size-4 animate-spin`}),e(`result.rowForm.loading`)]}),w&&(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:w.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)(v,{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)(b,{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)})})]})]}),w&&(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)(s,{className:`items-center`,children:[S&&(0,L.jsx)(`span`,{className:`mr-auto text-[11px] text-catppuccin-yellow`,children:e(`result.rowForm.inTransaction`)}),(0,L.jsx)(n,{variant:`outline`,onClick:()=>i(),disabled:V,children:e(`command.close`)}),t.onStage&&(0,L.jsx)(n,{variant:`outline`,onClick:te,disabled:V||!w,title:e(`result.rowForm.stageHint`),children:e(W?`result.rowForm.stageEdit`:`result.rowForm.stageInsert`)}),(0,L.jsxs)(n,{onClick:()=>void ne(),disabled:V||!w,children:[V&&(0,L.jsx)(x,{className:`mr-1 size-3.5 animate-spin`}),e(W?`result.rowForm.update`:`result.rowForm.insert`)]})]})]})})}export{U as RowFormDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./hePW80VL.js";import{p as t}from"./
|
|
1
|
+
import{r as e}from"./hePW80VL.js";import{p as t}from"./CyX8oVsa.js";import{r as n}from"./C76CctEl.js";var r=e(t(),1);n();var i=Object.defineProperty,a=(e,t)=>i(e,`name`,{value:t,configurable:!0}),o=r.createContext(void 0);function s(e){let t=r.useContext(o);return e||t||`ltr`}a(s,`useDirection`);var c=Object.defineProperty,l=(e,t)=>c(e,`name`,{value:t,configurable:!0});function u(e,[t,n]){return Math.min(n,Math.max(t,e))}l(u,`clamp`);export{s as n,u as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e}from"./iz6RnRcO.js";import{S as t}from"./zdvaVsTo.js";function n(n){t(n),e(n)}export{n as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./hePW80VL.js";import{p as t}from"./
|
|
1
|
+
import{r as e}from"./hePW80VL.js";import{p as t}from"./CyX8oVsa.js";import{a as n,s as r,u as i}from"./Dya0zxo6.js";import{r as a}from"./C76CctEl.js";import{O as o}from"./kTwcxyaO.js";var s=e(t(),1),c=a(),l=Object.defineProperty,u=(e,t)=>l(e,`name`,{value:t,configurable:!0}),d=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),f=s.forwardRef(u(function(e,t){return(0,c.jsx)(n.span,{...e,ref:t,style:{...d,...e.style}})},`VisuallyHidden`)),p=Object.defineProperty,m=(e,t)=>p(e,`name`,{value:t,configurable:!0});function h(e){let t=e+`CollectionProvider`,[n,a]=o(t),[l,u]=n(t,{collectionRef:{current:null},itemMap:new Map}),d=m(e=>{let{scope:t,children:n}=e,r=s.useRef(null),i=s.useRef(new Map).current;return(0,c.jsx)(l,{scope:t,itemMap:i,collectionRef:r,children:n})},`CollectionProvider`);d.displayName=t;let f=e+`CollectionSlot`,p=r(f),h=s.forwardRef((e,t)=>{let{scope:n,children:r}=e,a=u(f,n),o=i(t,a.collectionRef);return(0,c.jsx)(p,{ref:o,children:r})});h.displayName=f;let g=e+`CollectionItemSlot`,_=`data-radix-collection-item`,v=r(g),y=s.forwardRef((e,t)=>{let{scope:n,children:r,...a}=e,o=s.useRef(null),l=i(t,o),d=u(g,n);return s.useEffect(()=>(d.itemMap.set(o,{ref:o,...a}),()=>void d.itemMap.delete(o))),(0,c.jsx)(v,{[_]:``,ref:l,children:r})});y.displayName=g;function b(t){let n=u(e+`CollectionConsumer`,t);return s.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${_}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return m(b,`useCollection`),[{Provider:d,Slot:h,ItemSlot:y},b,a]}m(h,`createCollection`);var g=new WeakMap,_=class e extends Map{static{m(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],g.set(this,!0)}set(e,t){return g.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=this.#e.length,a=b(e),o=a>=0?a:i+a,s=o<0||o>=i?-1:o;if(s===this.size||r&&s===this.size-1||s===-1)return this.set(t,n),this;let c=this.size+ +!r;a<0&&o++;let l=[...this.#e],u,d=!1;for(let e=o;e<c;e++)if(o===e){let i=l[e];l[e]===t&&(i=l[e+1]),r&&this.delete(t),u=this.get(i),this.set(t,n)}else{!d&&l[e-1]===t&&(d=!0);let n=l[d?e:e-1],r=u;u=this.get(n),this.delete(n),this.set(n,r)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t!==void 0&&this.delete(t)}at(e){let t=v(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=v(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return v(this.#e,e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=r===0&&e.length===1?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&e.length===1?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(t===void 0)return r;t<0&&(t+=this.size),n!==void 0&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function v(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=y(e,t);return n===-1?void 0:e[n]}m(v,`at`);function y(e,t){let n=e.length,r=b(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}m(y,`toSafeIndex`);function b(e){return e!==e||e===0?0:Math.trunc(e)}m(b,`toSafeInteger`);function x(e){let t=e+`CollectionProvider`,[n,a]=o(t),[l,u]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new _,setItemMap:m(()=>void 0,`setItemMap`)}),d=m(({state:e,...t})=>e?(0,c.jsx)(p,{...t,state:e}):(0,c.jsx)(f,{...t}),`CollectionProvider`);d.displayName=t;let f=m(e=>{let t=C();return(0,c.jsx)(p,{...e,state:t})},`CollectionInit`);f.displayName=t+`Init`;let p=m(e=>{let{scope:t,children:n,state:r}=e,a=s.useRef(null),[o,u]=s.useState(null),d=i(a,u),[f,p]=r;return s.useEffect(()=>{if(!o)return;let e=T(()=>{});return e.observe(o,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[o]),(0,c.jsx)(l,{scope:t,itemMap:f,setItemMap:p,collectionRef:d,collectionRefObject:a,collectionElement:o,children:n})},`CollectionProviderImpl`);p.displayName=t+`Impl`;let h=e+`CollectionSlot`,g=r(h),v=s.forwardRef((e,t)=>{let{scope:n,children:r}=e,a=u(h,n),o=i(t,a.collectionRef);return(0,c.jsx)(g,{ref:o,children:r})});v.displayName=h;let y=e+`CollectionItemSlot`,b=r(y),x=s.forwardRef((e,t)=>{let{scope:n,children:r,...a}=e,o=s.useRef(null),[l,d]=s.useState(null),f=i(t,o,d),{setItemMap:p}=u(y,n),m=s.useRef(a);S(m.current,a)||(m.current=a);let h=m.current;return s.useEffect(()=>{let e=h;return p(t=>l?t.has(l)?t.set(l,{...e,element:l}).toSorted(w):(t.set(l,{...e,element:l}),t.toSorted(w)):t),()=>{p(e=>!l||!e.has(l)?e:(e.delete(l),new _(e)))}},[l,h,p]),(0,c.jsx)(b,{"data-radix-collection-item":``,ref:f,children:r})});x.displayName=y;function C(){return s.useState(new _)}m(C,`useInitCollection`);function E(t){let{itemMap:n}=u(e+`CollectionConsumer`,t);return n}return m(E,`useCollection`),[{Provider:d,Slot:v,ItemSlot:x},{createCollectionScope:a,useCollection:E,useInitCollection:C}]}m(x,`createCollection`);function S(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}m(S,`shallowEqual`);function C(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}m(C,`isElementPreceding`);function w(e,t){return!e[1].element||!t[1].element?0:C(e[1].element,t[1].element)?-1:1}m(w,`sortByDocumentPosition`);function T(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}m(T,`getChildListObserver`);export{f as n,d as r,h as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./hePW80VL.js";import{n as t,o as n,p as r}from"./
|
|
1
|
+
import{r as e}from"./hePW80VL.js";import{n as t,o as n,p as r}from"./CyX8oVsa.js";import{t as i}from"./Dya0zxo6.js";import{i as a,r as o}from"./C76CctEl.js";import{a as s,i as c,n as l,o as ee,r as u,t as d}from"./kTwcxyaO.js";import{i as f,t as p}from"./iz6RnRcO.js";import{n as m}from"./DOy06rIE.js";import{n as h}from"./BihjBM79.js";import{n as g,t as _}from"./C_qmv4pB.js";import{O as v,dn as y,jt as b,l as x,pt as S,tt as C,vt as w,wt as T}from"./D4DxtYTA.js";var E=e(r(),1),D=o(),O={execute:`command.localHistory.reason.execute`,edit:`command.localHistory.reason.edit`,replaced:`command.localHistory.reason.replaced`,restore:`command.localHistory.reason.restore`,close:`command.localHistory.reason.close`},k=Object.freeze([]);function A(e){let t=(Date.now()-e)/36e5;return t<1?`<1h`:t<24?`1-24h`:t<168?`1-7d`:`7d+`}function j(){let{t:e}=a(),r=h(e=>e.activeDialog),o=h(e=>e.closeDialog),j=h(e=>e.setFooterMessage),M=p(e=>e.activeConnectionId),N=g(e=>M?e.activeTabId[M]:null),P=g(e=>M?e.tabs[M]??_:_),F=f(e=>M?e.revisions[M]??k:k),I=m(e=>e.persistQueryHistory),L=C(e=>e.themeId),R=v(L),[z,B]=(0,E.useState)(!0),[V,H]=(0,E.useState)(``),[U,W]=(0,E.useState)(null),[G,K]=(0,E.useState)(`current`),q=P.find(e=>e.id===N),J=r===`local-history`;(0,E.useEffect)(()=>{if(!J)return;let e=N?F.filter(e=>e.docId===N).length:0;n(`local_history_open`,{revisions:t(F.length),tab_revisions:t(e)})},[J]);let Y=(0,E.useMemo)(()=>{let e=V.trim().toLowerCase();return F.filter(t=>z&&N&&t.docId!==N?!1:!e||t.text.toLowerCase().includes(e)||t.title.toLowerCase().includes(e))},[F,V,z,N]),X=q?.query??``,Z=Y.find(e=>e.id===U)??Y.find(e=>e.text!==X)??Y[0],Q=(0,E.useMemo)(()=>{if(!Z)return;let e=F.filter(e=>e.docId===Z.docId);return e[e.findIndex(e=>e.id===Z.id)+1]},[F,Z]),te=G===`current`?X:Q?.text??``;function $(e,t){n(`local_history_recover`,{action:e,reason:t.reason,age:A(t.timestamp),same_tab:t.docId===N,compare:G})}function ne(){if(!M||!N||!Z)return;$(`restore`,Z);let t=g.getState();t.captureRevision(M,N,`restore`),t.setEditorContent(M,N,Z.text),j(e(`command.localHistory.restored`)),o()}function re(){!M||!Z||($(`new_tab`,Z),S(M,Z.text,Z.database,Z.title),j(e(`command.localHistory.openedInTab`)),o())}function ie(e){M&&(f.getState().removeRevision(M,e.id),U===e.id&&W(null))}function ae(){M&&(f.getState().clearRevisions(M),W(null))}return(0,D.jsx)(d,{open:J,onOpenChange:e=>{e||o()},children:(0,D.jsxs)(l,{className:`flex max-h-[85vh] flex-col sm:max-w-[1000px]`,children:[(0,D.jsxs)(s,{children:[(0,D.jsx)(ee,{children:e(`command.localHistory.title`)}),(0,D.jsx)(u,{children:e(`command.localHistory.description`)})]}),!I&&(0,D.jsx)(`p`,{className:`rounded-md border border-dashed px-3 py-2 text-xs text-muted-foreground`,children:e(`command.localHistory.notPersisted`)}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,D.jsxs)(`div`,{className:`relative min-w-[200px] flex-1`,children:[(0,D.jsx)(b,{className:`absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,D.jsx)(x,{value:V,onChange:e=>H(e.target.value),placeholder:e(`command.localHistory.searchPlaceholder`),className:`h-8 pl-7 text-xs`})]}),(0,D.jsxs)(`div`,{className:`flex overflow-hidden rounded-md border`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:()=>B(!0),className:`px-2 py-1 text-xs ${z?`bg-accent`:`hover:bg-accent/50`}`,children:e(`command.localHistory.scopeTab`)}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>B(!1),className:`border-l px-2 py-1 text-xs ${z?`hover:bg-accent/50`:`bg-accent`}`,children:e(`command.localHistory.scopeAll`)})]}),(0,D.jsxs)(`div`,{className:`flex overflow-hidden rounded-md border`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:()=>K(`current`),className:`px-2 py-1 text-xs ${G===`current`?`bg-accent`:`hover:bg-accent/50`}`,children:e(`command.localHistory.compareCurrent`)}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>K(`previous`),className:`border-l px-2 py-1 text-xs ${G===`previous`?`bg-accent`:`hover:bg-accent/50`}`,children:e(`command.localHistory.comparePrevious`)})]})]}),Y.length===0?(0,D.jsx)(`div`,{className:`py-10 text-center text-sm text-muted-foreground`,children:F.length===0?e(`command.localHistory.empty`):e(`command.localHistory.noMatch`)}):(0,D.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[260px_1fr] gap-3`,children:[(0,D.jsx)(w,{className:`h-[440px] rounded-md border`,children:(0,D.jsx)(`ul`,{className:`divide-y`,children:Y.map(t=>(0,D.jsxs)(`li`,{className:`group relative`,children:[(0,D.jsxs)(`button`,{type:`button`,onClick:()=>W(t.id),className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 pr-8 text-left text-xs hover:bg-accent ${t.id===Z?.id?`bg-accent`:``}`,children:[(0,D.jsx)(`span`,{className:`font-medium`,children:new Date(t.timestamp).toLocaleString()}),(0,D.jsxs)(`span`,{className:`w-full truncate text-muted-foreground`,children:[t.title,` · `,e(O[t.reason]),` · `,e(`command.localHistory.chars`,{count:t.text.length})]})]}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>ie(t),title:e(`command.localHistory.delete`),className:`absolute right-1.5 top-1.5 rounded p-1 text-muted-foreground opacity-0 hover:bg-destructive/10 hover:text-destructive group-hover:opacity-100`,children:(0,D.jsx)(T,{className:`h-3.5 w-3.5`})})]},t.id))})}),(0,D.jsxs)(`div`,{className:`flex h-[440px] flex-col overflow-hidden rounded-md border`,children:[(0,D.jsx)(`div`,{className:`border-b bg-muted/40 px-3 py-1.5 text-xs text-muted-foreground`,children:G===`current`?e(`command.localHistory.diffAgainstCurrent`):Q?e(`command.localHistory.diffAgainstPrevious`,{time:new Date(Q.timestamp).toLocaleString()}):e(`command.localHistory.noPrevious`)}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,D.jsx)(y,{language:`sql`,theme:R,original:Z?.text??``,modified:te,options:{readOnly:!0,renderSideBySide:!1,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12,renderOverviewRuler:!1}})})]})]}),(0,D.jsxs)(c,{className:`sm:justify-between`,children:[(0,D.jsx)(i,{variant:`ghost`,onClick:ae,disabled:F.length===0,children:e(`command.localHistory.clearAll`)}),(0,D.jsxs)(`div`,{className:`flex gap-2`,children:[(0,D.jsx)(i,{variant:`outline`,onClick:o,children:e(`command.close`)}),(0,D.jsx)(i,{variant:`outline`,onClick:re,disabled:!Z,children:e(`command.localHistory.openInNewTab`)}),(0,D.jsx)(i,{onClick:ne,disabled:!Z||!q,children:e(`command.localHistory.restore`)})]})]})]})})}export{j as LocalHistoryDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./hePW80VL.js";import{p as t}from"./
|
|
1
|
+
import{r as e}from"./hePW80VL.js";import{p as t}from"./CyX8oVsa.js";import{t as n}from"./Dya0zxo6.js";import{i as r,r as i}from"./C76CctEl.js";import{a,i as o,n as s,o as c,t as l}from"./kTwcxyaO.js";import{t as u}from"./iz6RnRcO.js";import{n as d,t as f}from"./BihjBM79.js";import{r as p}from"./CH4cEkW4.js";import{a as m,h}from"./CZRhmV_L.js";import{c as g,l as _,ut as v}from"./D4DxtYTA.js";var y=e(t(),1),b=i();function x(){let{t:e}=r(),{activeDialog:t,closeDialog:i}=d(),x=f(`create-schema`),S=t===`create-schema`,[C,w]=(0,y.useState)(``),[T,E]=(0,y.useState)(!1),[D,O]=(0,y.useState)(null);function k(e){e||(i(),w(``),O(null))}async function A(){let e=x?.connectionId??u.getState().activeConnectionId,t=C.trim();if(!(!e||!t)){O(null),E(!0);try{await m(e,p(e).getQuery(`CREATE_SCHEMA`,t)),await h(e),k(!1)}catch(e){O(e instanceof Error?e.message:String(e))}finally{E(!1)}}}return(0,b.jsx)(l,{open:S,onOpenChange:k,children:(0,b.jsxs)(s,{className:`sm:max-w-[420px]`,children:[(0,b.jsx)(a,{children:(0,b.jsx)(c,{children:e(`database.schema.createTitle`)})}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(g,{htmlFor:`schema-name`,children:e(`database.schema.name`)}),(0,b.jsx)(_,{id:`schema-name`,value:C,autoFocus:!0,placeholder:e(`database.schema.namePlaceholder`),onChange:e=>w(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!v(e)&&A()}})]}),D&&(0,b.jsx)(`p`,{className:`text-xs text-destructive leading-relaxed`,children:D}),(0,b.jsxs)(o,{children:[(0,b.jsx)(n,{variant:`outline`,onClick:()=>k(!1),children:e(`database.schema.cancel`)}),(0,b.jsx)(n,{onClick:()=>void A(),disabled:!C.trim()||T,children:e(`database.schema.create`)})]})]})})}export{x as CreateSchemaDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./hePW80VL.js";import{o as t,p as n}from"./CYz610vE.js";import{a as r,i,t as a,u as o}from"./CiL8zoYm.js";import{i as s,r as c}from"./Cu_sGzNJ.js";import{C as l,D as u,O as d,T as f,a as p,i as m,n as ee,o as h,t as g}from"./DzRyVlxz.js";import{a as _,i as v,n as y,r as b,t as x}from"./G06qjCej.js";import{r as S,t as C}from"./Nro86Y63.js";import{A as w,f as T,j as E,t as D,w as O}from"./S7HbowYz.js";import{O as k,g as A,m as te,o as ne}from"./BjwrN_ch.js";import{n as j,t as re}from"./D8_hwGjG.js";import{n as ie}from"./C1gqjEN3.js";import{C as ae,_ as oe,f as M,i as se,r as ce,u as N}from"./BkXrfAoR.js";import{At as le,C as ue,H as de,Jt as fe,N as pe,P as me,S as P,T as F,a as he,an as I,b as ge,c as L,ct as _e,en as ve,i as ye,in as be,l as R,lt as xe,n as Se,nn as Ce,o as z,r as we,rn as Te,s as B,st as Ee,tn as V,u as H,vt as De,w as Oe,x as ke,z as Ae}from"./CExE8dKz.js";import{t as U}from"./CnYBZPf9.js";var W=e(n(),1),G=c(),K=Object.defineProperty,q=(e,t)=>K(e,`name`,{value:t,configurable:!0}),je=`DropdownMenu`,[Me,Ne]=d(je,[I]),J=I(),[Pe,Fe]=Me(je),Ie=q(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=J(t),u=W.useRef(null),[d,p]=f({prop:i,defaultProp:a??!1,onChange:o,caller:je});return(0,G.jsx)(Pe,{scope:t,triggerId:l(),triggerRef:u,contentId:l(),open:d,onOpenChange:p,onOpenToggle:W.useCallback(()=>p(e=>!e),[p]),modal:s,children:(0,G.jsx)(be,{...c,open:d,onOpenChange:p,dir:r,modal:s,children:n})})},`DropdownMenu`),Le=`DropdownMenuTrigger`,Re=W.forwardRef(q(function(e,t){let{__scopeDropdownMenu:n,disabled:i=!1,...a}=e,s=Fe(Le,n),c=J(n),l=o(t,s.triggerRef);return(0,G.jsx)(ve,{asChild:!0,...c,children:(0,G.jsx)(r.button,{type:`button`,id:s.triggerId,"aria-haspopup":`menu`,"aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?`open`:`closed`,"data-disabled":i?``:void 0,disabled:i,...a,ref:l,onPointerDown:u(e.onPointerDown,e=>{!i&&e.button===0&&e.ctrlKey===!1&&(s.onOpenToggle(),s.open||e.preventDefault())}),onKeyDown:u(e.onKeyDown,e=>{i||([`Enter`,` `].includes(e.key)&&s.onOpenToggle(),e.key===`ArrowDown`&&s.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),ze=q(e=>{let{__scopeDropdownMenu:t,...n}=e,r=J(t);return(0,G.jsx)(Te,{...r,...n})},`DropdownMenuPortal`),Be=`DropdownMenuContent`,Ve=W.forwardRef(q(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Fe(Be,n),a=J(n),o=W.useRef(!1);return(0,G.jsx)(V,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:u(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:u(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),He=W.forwardRef(q(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=J(n);return(0,G.jsx)(Ce,{...i,...r,ref:t})},`DropdownMenuItem`)),Ue=Ie,We=Re,Ge=ze,Ke=Ve,qe=He,Je=new Set([`postgres:`,`postgresql:`]);function Ye(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(!Je.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 Xe=new Set([`localhost`,`127.0.0.1`,`[::1]`,`::1`,`0.0.0.0`]);async function Ze(e,t){let n;try{let t=new URL(e);if(!Xe.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 Qe=[`utf8`,`utf8mb4`,`latin1`,`ascii`,`euckr`,`sjis`,`big5`],$e={enabled:!1,host:``,port:22,user:``,auth:`key`};function Y({label:e,htmlFor:t,children:n}){return(0,G.jsxs)(`div`,{className:`grid grid-cols-[120px_minmax(0,1fr)] items-center gap-2`,children:[(0,G.jsx)(L,{htmlFor:t,children:e}),n]})}function et({value:e,onChange:t}){let{t:n}=s();function r(n,r){t({...e,[n]:r})}let[i,o]=(0,W.useState)([]),c=e.dbms===`d1`?e.devUrl??``:``;(0,W.useEffect)(()=>{if(!c){o([]);return}let e=new AbortController,t=setTimeout(()=>{Ze(c,e.signal).then(o)},300);return()=>{clearTimeout(t),e.abort()}},[c]);let l=e.dbms===`sqlite`,u=e.transport??`browser`,d=l&&u===`browser`,f=C.has(e.dbms),p=e.dbms===`d1`,m=e.dbms===`do`,ee=w.find(t=>t.id===e.dbms)?.capabilities,h=e.ssh??$e,[g,T]=(0,W.useState)(``),D=g.trim()===``?`empty`:Ye(g)?`applied`:`invalid`,O=e.dbms===`supabase`&&e.port===6543;function k(n){T(n);let r=Ye(n);r&&t({...e,host:r.host??e.host,port:r.port??w.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 A(n){t({...e,ssh:{...h,...n}})}async function te(e){e&&A({privateKey:await e.text(),privateKeyName:e.name})}return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,G.jsx)(Y,{label:n(`connection.form.hostName`),htmlFor:`conn-hostName`,children:(0,G.jsx)(R,{id:`conn-hostName`,placeholder:n(`connection.form.hostNamePlaceholder`),value:e.hostName,onChange:e=>r(`hostName`,e.target.value)})}),(0,G.jsx)(Y,{label:n(`connection.form.dataSource`),children:(0,G.jsxs)(x,{value:e.dbms,onValueChange:n=>{let r=w.find(e=>e.id===n);if(!r)return;let i=r.id,a=C.has(i)||i===`d1`||i===`do`;T(``),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||f||p||m||e.user===B(e.dbms)?B(i):e.user,devUrl:i===`do`?e.devUrl||`http://localhost:8787`:e.devUrl,database:e.database&&!a&&!f&&!p&&!m?e.database:z(i)??e.database})},children:[(0,G.jsx)(v,{id:`conn-dbms`,className:`w-full`,children:(0,G.jsx)(_,{})}),(0,G.jsx)(y,{children:w.map(e=>(0,G.jsx)(b,{value:e.id,children:(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(H,{dbms:e.id}),e.label]})},e.id))})]})}),f&&(0,G.jsx)(Y,{label:n(`connection.form.connectionString`),htmlFor:`conn-uri`,children:(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.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:g,onChange:e=>k(e.target.value)}),(0,G.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`)})]})}),l&&(0,G.jsxs)(Y,{label:n(`connection.form.openVia`),children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`radio`,name:`transport`,value:`browser`,checked:u===`browser`,onChange:()=>r(`transport`,`browser`),className:`accent-primary`}),n(`connection.form.viaBrowser`)]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`radio`,name:`transport`,value:`tunnel`,checked:u===`tunnel`,onChange:()=>r(`transport`,`tunnel`),className:`accent-primary`}),n(`connection.form.viaAgent`)]})]}),(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(u===`browser`?`connection.form.viaBrowserHint`:`connection.form.viaAgentHint`)})]}),d?(0,G.jsx)(Y,{label:n(`connection.form.databaseFile`),children:(0,G.jsxs)(`div`,{className:`min-w-0 text-xs text-muted-foreground leading-relaxed`,children:[e.file?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,G.jsx)(`span`,{className:`min-w-0 break-all text-foreground`,title:e.file,children:e.file}),(0,G.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,className:`h-6 shrink-0 px-2 text-xs`,onClick:()=>{N(e.id),r(`file`,``)},children:n(`connection.form.changeFile`)})]}):(0,G.jsx)(`p`,{children:n(`connection.form.filePickerHint`)}),(0,G.jsx)(`p`,{className:`mt-1`,children:n(`connection.form.fileRememberedHint`)})]})}):null,!d&&(0,G.jsx)(Y,{label:n(`connection.form.authToken`),htmlFor:`conn-authToken`,children:(0,G.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())})}),d?null:m?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{label:n(`connection.form.doDevUrl`),htmlFor:`conn-do-url`,children:(0,G.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,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.doHint`)}),(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.doLimitsHint`)})]}):p?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{label:n(`connection.form.d1DevUrl`),htmlFor:`conn-d1-dev`,children:(0,G.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,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1DevUrlHint`)}),(0,G.jsx)(Y,{label:n(`connection.form.d1AccountId`),htmlFor:`conn-d1-account`,children:(0,G.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,G.jsx)(Y,{label:n(`connection.form.d1DatabaseId`),htmlFor:`conn-d1-database`,children:i.length>0?(0,G.jsxs)(x,{value:e.databaseId??``,onValueChange:e=>r(`databaseId`,e),children:[(0,G.jsx)(v,{id:`conn-d1-database`,children:(0,G.jsx)(_,{placeholder:n(`connection.form.d1PickDatabase`)})}),(0,G.jsx)(y,{children:i.map(e=>(0,G.jsxs)(b,{value:e.id,children:[e.name,` · `,e.id]},e.id))})]}):(0,G.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,G.jsx)(Y,{label:n(`connection.form.d1ApiToken`),htmlFor:`conn-pass`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(R,{id:`conn-pass`,type:`password`,autoComplete:`new-password`,value:e.pass,onChange:e=>r(`pass`,e.target.value.trim())}),(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs whitespace-nowrap cursor-pointer`,title:n(`connection.form.savePasswordHint`),children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:e.savePassword??!0,onChange:e=>r(`savePassword`,e.target.checked)}),n(`connection.form.savePassword`)]})]})}),(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1Hint`)}),(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1LimitsHint`)})]}):l?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{label:n(`connection.form.databaseFile`),htmlFor:`conn-file`,children:(0,G.jsx)(R,{id:`conn-file`,placeholder:n(`connection.form.filePathPlaceholder`),value:e.file??``,onChange:e=>r(`file`,e.target.value)})}),(0,G.jsx)(Y,{label:n(`connection.form.createIfMissing`),htmlFor:`conn-create`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.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,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.createIfMissingHint`)})]})})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{label:n(`connection.form.host`),htmlFor:`conn-host`,children:(0,G.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,G.jsx)(Y,{label:n(`connection.form.port`),htmlFor:`conn-port`,children:(0,G.jsx)(R,{id:`conn-port`,type:`number`,value:e.port,onChange:t=>r(`port`,Number(t.target.value)||w.find(t=>t.id===e.dbms)?.defaultPort||3306)})}),O&&(0,G.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`)}),z(e.dbms)!==void 0&&(0,G.jsx)(Y,{label:e.dbms===`oracle`?n(`connection.form.serviceName`):n(`connection.form.database`),htmlFor:`conn-database`,children:(0,G.jsx)(R,{id:`conn-database`,placeholder:z(e.dbms),value:e.database??``,onChange:e=>r(`database`,e.target.value.trim())})}),(0,G.jsx)(Y,{label:n(`connection.form.user`),htmlFor:`conn-user`,children:(0,G.jsx)(R,{id:`conn-user`,autoComplete:`off`,placeholder:B(e.dbms),value:e.user,onChange:e=>r(`user`,e.target.value)})}),(0,G.jsx)(Y,{label:n(`connection.form.password`),htmlFor:`conn-pass`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(R,{id:`conn-pass`,type:`password`,autoComplete:`new-password`,value:e.pass,onChange:e=>r(`pass`,e.target.value)}),(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs whitespace-nowrap cursor-pointer`,title:n(`connection.form.savePasswordHint`),children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:e.savePassword??!0,onChange:e=>r(`savePassword`,e.target.checked)}),n(`connection.form.savePassword`)]})]})}),f&&(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.managedTlsHint`)}),(()=>{let t=E(e.dbms),r=`formHint`in t?t.formHint:void 0;return r?(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(r)}):null})(),!f&&e.dbms!==`oracle`&&(0,G.jsx)(Y,{label:n(`connection.form.tls`),children:(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[(0,G.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,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer ${e.ssl?``:`opacity-50`}`,title:n(`connection.form.tlsVerifyHint`),children:[(0,G.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`)]})]})}),!f&&S(E(e.dbms))&&(0,G.jsx)(Y,{label:n(`connection.form.charset`),children:(0,G.jsxs)(x,{value:e.charset,onValueChange:e=>r(`charset`,e),children:[(0,G.jsx)(v,{className:`w-full`,children:(0,G.jsx)(_,{})}),(0,G.jsx)(y,{children:Qe.map(e=>(0,G.jsx)(b,{value:e,children:e},e))})]})})]}),!l&&!f&&!p&&!m&&(0,G.jsxs)(G.Fragment,{children:[(0,G.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,G.jsx)(de,{className:`ml-2`})]}),(0,G.jsx)(Y,{label:n(`connection.form.sshTunnel`),htmlFor:`conn-ssh`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{id:`conn-ssh`,type:`checkbox`,checked:h.enabled,onChange:e=>{(!e.target.checked||Ae(`ssh_tunnel`))&&A({enabled:e.target.checked})},className:`size-4 accent-primary cursor-pointer`}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.sshTunnelHint`)})]})}),h.enabled&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{label:n(`connection.form.sshHost`),htmlFor:`conn-ssh-host`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(R,{id:`conn-ssh-host`,placeholder:n(`connection.form.sshHostPlaceholder`),value:h.host,onChange:e=>A({host:e.target.value.trim()})}),(0,G.jsx)(R,{"aria-label":n(`connection.form.sshPort`),type:`number`,className:`w-24 shrink-0`,value:h.port,onChange:e=>A({port:Number(e.target.value)||22})})]})}),(0,G.jsx)(Y,{label:n(`connection.form.sshUser`),htmlFor:`conn-ssh-user`,children:(0,G.jsx)(R,{id:`conn-ssh-user`,placeholder:n(`connection.form.sshUserPlaceholder`),value:h.user,onChange:e=>A({user:e.target.value.trim()})})}),(0,G.jsx)(Y,{label:n(`connection.form.sshAuth`),children:(0,G.jsxs)(x,{value:h.auth,onValueChange:e=>A({auth:e}),children:[(0,G.jsx)(v,{className:`w-full`,children:(0,G.jsx)(_,{})}),(0,G.jsxs)(y,{children:[(0,G.jsx)(b,{value:`key`,children:n(`connection.form.sshAuthKey`)}),(0,G.jsx)(b,{value:`password`,children:n(`connection.form.sshAuthPassword`)}),(0,G.jsx)(b,{value:`agent`,children:n(`connection.form.sshAuthAgent`)})]})]})}),h.auth===`password`&&(0,G.jsx)(Y,{label:n(`connection.form.sshPassword`),htmlFor:`conn-ssh-pass`,children:(0,G.jsx)(R,{id:`conn-ssh-pass`,type:`password`,autoComplete:`new-password`,value:h.password??``,onChange:e=>A({password:e.target.value})})}),h.auth===`key`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{label:n(`connection.form.sshKey`),htmlFor:`conn-ssh-key`,children:(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`input`,{id:`conn-ssh-key`,type:`file`,className:`hidden`,onChange:e=>{te(e.target.files?.[0]),e.target.value=``}}),(0,G.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 shrink-0 px-2 text-xs`,onClick:()=>document.getElementById(`conn-ssh-key`)?.click(),children:h.privateKey?n(`connection.form.changeFile`):n(`connection.form.sshKeyPick`)}),(0,G.jsx)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,title:h.privateKeyName,children:h.privateKey?h.privateKeyName||n(`connection.form.sshKeyLoaded`):n(`connection.form.sshKeyHint`)})]})}),(0,G.jsx)(Y,{label:n(`connection.form.sshPassphrase`),htmlFor:`conn-ssh-passphrase`,children:(0,G.jsx)(R,{id:`conn-ssh-passphrase`,type:`password`,autoComplete:`new-password`,placeholder:n(`connection.form.sshPassphrasePlaceholder`),value:h.passphrase??``,onChange:e=>A({passphrase:e.target.value})})})]}),h.auth===`agent`&&(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshAuthAgentHint`)}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshTargetHint`)}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshSecretsHint`)})]})]}),(0,G.jsx)(Y,{label:n(`connection.form.autoConnection`),htmlFor:`conn-auto`,children:(0,G.jsx)(`div`,{className:`flex items-center`,children:(0,G.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,G.jsx)(`div`,{className:`mt-1 border-t pt-3 text-xs font-medium text-muted-foreground`,children:n(`connection.form.safety`)}),(0,G.jsx)(Y,{label:n(`connection.form.environment`),children:(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[pe.map(t=>{let n=(e.environmentColor??`none`)===t.id;return(0,G.jsx)(`button`,{type:`button`,title:me(t.id),"aria-label":me(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,G.jsx)(`span`,{className:`ml-1 text-xs text-muted-foreground`,children:n(`connection.form.environmentHint`)})]})}),(0,G.jsx)(Y,{label:n(`connection.form.readOnly`),htmlFor:`conn-readonly`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.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,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.readOnlyHint`)})]})}),ee?.transactions!==!1&&(0,G.jsx)(Y,{label:n(`connection.form.transactions`),children:(0,G.jsxs)(x,{value:e.transactionMode??`auto`,onValueChange:e=>r(`transactionMode`,e),children:[(0,G.jsx)(v,{className:`w-full`,children:(0,G.jsx)(_,{})}),(0,G.jsxs)(y,{children:[(0,G.jsx)(b,{value:`auto`,children:n(`connection.form.txAuto`)}),(0,G.jsx)(b,{value:`manual`,children:n(`connection.form.txManual`)})]})]})})]})}var tt=[`id`,`serverConnectionId`,`sample`,`scratchpad`,`autoConnection`];function nt(e){return!e.sample&&!e.scratchpad}function rt(e,t,n=new Date){let r=t?e:O(e),i={...r};for(let e of tt)delete i[e];if(i.pass||delete i.pass,i.authToken||delete i.authToken,r.ssh){let e={...r.ssh};for(let t of[`password`,`passphrase`,`privateKey`])e[t]||delete e[t];i.ssh=e}return{planche:`connection`,version:1,exportedAt:n.toISOString(),secrets:t,connection:i}}function it(e){let t;try{t=JSON.parse(e)}catch{throw Error(`Not a JSON file`)}let n=t;if(!n||n.planche!==`connection`||!n.connection||typeof n.connection!=`object`)throw Error(`Not a Planche connection file`);if(typeof n.connection.dbms!=`string`||!n.connection.dbms)throw Error(`The connection has no database type`);return n}var X=(e,t=``)=>typeof e==`string`?e:t,Z=e=>typeof e==`boolean`?e:void 0,at=(e,t)=>typeof e==`number`&&Number.isFinite(e)?e:t,Q=e=>e===void 0||e===``?void 0:e;function ot(e){if(!e||typeof e!=`object`)return;let t=e,n=t.auth===`key`||t.auth===`agent`?t.auth:`password`;return{enabled:t.enabled===!0,host:X(t.host),port:at(t.port,22),user:X(t.user),auth:n,password:Q(X(t.password)),privateKey:Q(X(t.privateKey)),privateKeyName:Q(X(t.privateKeyName)),passphrase:Q(X(t.passphrase))}}function st(e,t,n=crypto.randomUUID()){let r=e.connection,i=Z(r.savePassword),a={id:n,hostName:ct(X(r.hostName),t),host:X(r.host),user:X(r.user),pass:X(r.pass),charset:X(r.charset,`utf8`),port:at(r.port,0),dbms:r.dbms,database:Q(X(r.database)),transport:r.transport===`tunnel`||r.transport===`browser`?r.transport:void 0,file:Q(X(r.file)),createIfMissing:Z(r.createIfMissing),ssl:Z(r.ssl),sslVerify:Z(r.sslVerify),accountId:Q(X(r.accountId)),databaseId:Q(X(r.databaseId)),devUrl:Q(X(r.devUrl)),ssh:ot(r.ssh),gatewayProfile:Q(X(r.gatewayProfile)),autoConnection:!1,savePassword:i??!0,authToken:X(r.authToken),readOnly:Z(r.readOnly),environmentColor:Q(X(r.environmentColor)),transactionMode:Q(X(r.transactionMode))};for(let e of Object.keys(a))a[e]===void 0&&delete a[e];return a}function ct(e,t){if(!e||!t.some(t=>t.hostName===e))return e;for(let n=2;;n++){let r=`${e} (${n})`;if(!t.some(e=>e.hostName===r))return r}}async function lt(e,t,n=`application/json`){let r=U(e);if(typeof window.showSaveFilePicker==`function`)try{let e=await(await window.showSaveFilePicker({suggestedName:r,types:[{accept:{[n]:[`.${r.split(`.`).pop()??`txt`}`]}}]})).createWritable();return await e.write(t),await e.close(),!0}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return!1}let i=URL.createObjectURL(new Blob([t],{type:n})),a=document.createElement(`a`);return a.href=i,a.download=r,a.click(),URL.revokeObjectURL(i),!0}function ut(e=`.json,application/json`){return new Promise(t=>{let n=document.createElement(`input`);n.type=`file`,n.accept=e,n.onchange=async()=>{let e=n.files?.[0];t(e?await e.text():null)},n.oncancel=()=>t(null),n.click()})}function dt({...e}){return(0,G.jsx)(Ue,{"data-slot":`dropdown-menu`,...e})}function ft({...e}){return(0,G.jsx)(We,{"data-slot":`dropdown-menu-trigger`,...e})}function pt({className:e,sideOffset:t=4,...n}){return(0,G.jsx)(Ge,{children:(0,G.jsx)(Ke,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:i(`z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,e),...n})})}function mt({className:e,inset:t,variant:n=`default`,...r}){return(0,G.jsx)(qe,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:i(`relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!`,e),...r})}function $(e,n,r){let i=_e(r);return t(`connection_error`,{action:e,dbms:n,reason:i}),Ee(i)}function ht(){let{t:e}=s(),{activeDialog:t,closeDialog:n,showMessage:r}=j(),[i,o]=(0,W.useState)(!1),{savedConnections:c,addSavedConnection:l,updateSavedConnection:u,deleteSavedConnection:d,openConnection:f}=D(),_=re(`connect`)?.profileId,[v,y]=(0,W.useState)(()=>_??null),[b,x]=(0,W.useState)(()=>{let e=_?c.find(e=>e.id===_):void 0;return e?{...e}:null}),S=t===`connect`,[C,w]=(0,W.useState)(null),[O,N]=(0,W.useState)(null),de=xe(e=>e.url),pe=xe(e=>e.token);(0,W.useEffect)(()=>{if(!S)return;let e=!1;return(async()=>{try{let t=await ne();if(e||t.state!==`online`||!t.gateway){e||w(null);return}let n=await te();e||(w({name:n.gateway,profiles:n.profiles}),N(null))}catch(t){e||N(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[S,de,pe]);function me(t){let n=c.find(e=>e.gatewayProfile===t.name);if(n){L(n);return}let r=we(t);l(r),L(r),j.getState().setFooterMessage(e(`connection.dialog.gatewayAdded`,{name:t.name}))}function I(e){e||(n(),y(null),x(null))}function L(e){y(e.id),x({...e})}function _e(e){x(e),u(e.id,e)}function ve(){let e=he();l(e),y(e.id),x(e)}function be(){v&&(d(v),y(null),x(null))}async function R(t){let n=c.find(e=>e.id===v);if(!n||!nt(n))return;let r=n.hostName||e(`connection.dialog.unnamed`),i=rt(D.getState().resolveCredentials(n),t);await lt(`planche-connection-${r}.json`,JSON.stringify(i,null,2))&&j.getState().setFooterMessage(e(`connection.dialog.exported`,{name:r}))}async function Ce(){let t=await ut();if(t!==null)try{let n=st(it(t),D.getState().savedConnections);l(n),y(n.id),x(n),j.getState().setFooterMessage(e(`connection.dialog.imported`,{name:n.hostName||e(`connection.dialog.unnamed`)}))}catch(t){r({tone:`error`,title:e(`connection.dialog.importFailedTitle`),description:t instanceof Error?t.message:String(t)})}}let z=v!==null&&c.some(e=>e.id===v&&nt(e)),[Te,B]=(0,W.useState)(!1),Ee=ie(e=>e.addQueryTab);function V(t){let r=D.getState().activeConnections.some(e=>e.id===t.id);if(f(t),ae.getState().removeTree(t.id),T(t.id),r){n(),y(null),x(null);return}Ee(t.id,{id:`tab-${Date.now()}`,title:e(`connection.dialog.firstQueryTab`),query:``,database:``,isExecuting:!1,results:[],error:null,executionTime:null}),n(),y(null),x(null)}async function Ae(t){let n=await ce(t.id,{interactive:!0});if(!n)return;let r={...t,file:n.fileName,serverConnectionId:n.connectionId};u(t.id,{file:n.fileName}),V(r),D.getState().setFileDetached(t.id,n.fileDetached),n.restoredUnsaved?j.getState().setFooterMessage(e(n.diskChanged?`connection.dialog.restoredUnsavedDiskChanged`:`connection.dialog.restoredUnsaved`,{file:n.fileName})):n.wal&&!n.walApplied?j.getState().setFooterMessage(e(`connection.dialog.walPending`,{file:n.fileName})):n.walApplied&&j.getState().setFooterMessage(e(`connection.dialog.walApplied`,{file:n.fileName}))}async function U(t,n){try{return await n(t)}catch(r){let i=A(r);if(!i||!(`ssh`in t)||!t.ssh||!await j.getState().requestDestructiveConfirm({title:e(`connection.dialog.hostKeyTitle`),description:e(`connection.dialog.hostKeyDescription`,i),confirmLabel:e(`connection.dialog.hostKeyAccept`)}))throw r;return n({...t,ssh:{...t.ssh,acceptHostKey:i.fingerprint}})}}async function K(){if(b){B(!0);try{if(M(b)===`browser`){await Ae(b);return}let t=await U(k(b),e=>se(e,b.authToken||void 0));if(t.success)V({...b,serverConnectionId:t.connectionId});else{let n=$(`connect`,b.dbms,Error(t.message??``));r({tone:`error`,title:e(`connection.dialog.connectFailedTitle`),description:t.message??e(`connection.dialog.unknownError`),...n})}}catch(t){let n=$(`connect`,b.dbms,t);r({tone:`error`,title:e(`connection.dialog.connectFailedTitle`),description:t instanceof Error?t.message:String(t),...n})}finally{B(!1)}}}async function q(){if(b){if(M(b)===`browser`){r({tone:`info`,title:e(`connection.dialog.testConnection`),description:e(`connection.dialog.browserTestHint`)});return}o(!0);try{let t=await U(k(b),e=>oe(e,b.authToken||void 0));if(t.success)r({tone:`success`,title:e(`connection.dialog.testSuccess`),description:e(`connection.dialog.testSuccessDescription`)});else{let n=$(`test`,b.dbms,Error(t.message??``));r({tone:`error`,title:e(`connection.dialog.testFailedTitle`),description:t.message??e(`connection.dialog.unknownError`),...n})}}catch(t){let n=$(`test`,b.dbms,t);r({tone:`error`,title:e(`connection.dialog.testFailedTitle`),description:t instanceof Error?t.message:String(t),...n})}finally{o(!1)}}}return(0,G.jsx)(g,{open:S,onOpenChange:I,children:(0,G.jsxs)(ee,{className:`sm:max-w-[1100px] h-[85vh] max-h-[85vh] flex flex-col`,children:[(0,G.jsx)(p,{children:(0,G.jsx)(h,{children:e(`connection.dialog.title`)})}),(0,G.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,G.jsx)(le,{className:`mt-0.5 size-4 shrink-0 text-catppuccin-green`,"aria-hidden":!0}),(0,G.jsx)(`span`,{children:e(`connection.dialog.privacy`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-1 gap-4 overflow-hidden min-h-0`,children:[(0,G.jsxs)(`div`,{className:`w-[460px] shrink-0 border rounded-md overflow-hidden flex flex-col`,children:[(C||O)&&(0,G.jsxs)(`div`,{className:`border-b p-2 text-xs space-y-1 max-h-40 overflow-auto`,children:[(0,G.jsxs)(`p`,{className:`font-medium`,children:[e(`connection.dialog.gatewayTitle`),C?` — ${C.name}`:``]}),O&&(0,G.jsx)(`p`,{className:`text-destructive`,children:e(`connection.dialog.gatewayLoadFailed`,{error:O})}),C?.profiles.map(t=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5 truncate`,children:[(0,G.jsx)(H,{dbms:Se[t.driver],className:`size-3.5`}),(0,G.jsx)(`span`,{className:`truncate`,children:t.name}),(0,G.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,t.readOnly?e(`connection.dialog.gatewayReadOnly`):e(`connection.dialog.gatewayWritable`),`)`]})]}),(0,G.jsx)(a,{size:`sm`,variant:`outline`,className:`h-6 px-2 text-xs`,onClick:()=>me(t),children:e(`connection.dialog.gatewayAdd`)})]},t.name))]}),(0,G.jsx)(De,{className:`h-full`,children:(0,G.jsxs)(ge,{className:`table-fixed`,children:[(0,G.jsx)(Oe,{children:(0,G.jsxs)(F,{children:[(0,G.jsx)(ue,{className:`w-[32%]`,children:e(`connection.dialog.colHostName`)}),(0,G.jsx)(ue,{className:`w-[40%]`,children:e(`connection.dialog.colTarget`)}),(0,G.jsx)(ue,{className:`w-[28%]`,children:e(`connection.dialog.colDbms`)})]})}),(0,G.jsx)(ke,{children:c.length===0?(0,G.jsx)(F,{children:(0,G.jsx)(P,{colSpan:3,className:`text-center text-muted-foreground`,children:e(`connection.dialog.noSaved`)})}):c.map(t=>(0,G.jsxs)(F,{"data-state":v===t.id?`selected`:void 0,className:`cursor-pointer`,onClick:()=>L(t),onDoubleClick:()=>{L(t),K()},children:[(0,G.jsx)(P,{className:`truncate font-medium`,title:t.hostName,children:t.hostName||e(`connection.dialog.unnamed`)}),(0,G.jsx)(P,{className:`truncate`,title:t.dbms===`sqlite`?t.file:t.dbms===`d1`?t.databaseId:t.dbms===`do`?t.devUrl:`${t.user?`${t.user}@`:``}${t.host}:${t.port}`,children:t.dbms===`sqlite`?t.file||(M(t)===`browser`?e(`connection.dialog.pickOnConnect`):e(`connection.dialog.noFile`)):t.dbms===`d1`?t.databaseId||`—`:t.dbms===`do`?t.devUrl||`—`:`${t.user?`${t.user}@`:``}${t.host}:${t.port}`}),(0,G.jsx)(P,{className:`truncate`,title:E(t.dbms).label,children:(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(H,{dbms:t.dbms,className:`size-3.5`}),(0,G.jsx)(`span`,{className:`truncate`,children:E(t.dbms).label})]})})]},t.id))})]})})]}),(0,G.jsx)(`div`,{className:`flex-1 border rounded-md overflow-auto`,children:b?(0,G.jsxs)(G.Fragment,{children:[M(b)!==`browser`&&(0,G.jsx)(`div`,{className:`p-4 pb-0`,children:(0,G.jsx)(ye,{})}),b.gatewayProfile?(0,G.jsxs)(`div`,{className:`p-4 space-y-2 text-sm`,children:[(0,G.jsxs)(`p`,{className:`font-medium flex items-center gap-2`,children:[(0,G.jsx)(H,{dbms:b.dbms,className:`size-4`}),b.hostName]}),(0,G.jsx)(`p`,{className:`text-muted-foreground`,children:e(`connection.dialog.gatewayProfileHint`,{name:b.gatewayProfile})}),(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[b.readOnly?e(`connection.dialog.gatewayReadOnly`):e(`connection.dialog.gatewayWritable`),b.database?` · ${b.database}`:``]})]}):(0,G.jsx)(et,{value:b,onChange:_e})]}):(0,G.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:e(`connection.dialog.selectPrompt`)})})]}),(0,G.jsxs)(m,{className:`sm:justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(a,{variant:`outline`,onClick:ve,children:e(`connection.dialog.addNew`)}),(0,G.jsx)(a,{variant:`destructive`,onClick:be,disabled:!v,children:e(`connection.dialog.delete`)}),(0,G.jsxs)(dt,{children:[(0,G.jsx)(ft,{asChild:!0,children:(0,G.jsxs)(a,{variant:`outline`,disabled:!z,children:[e(`connection.dialog.export`),(0,G.jsx)(fe,{className:`ml-1 size-3.5`,"aria-hidden":!0})]})}),(0,G.jsxs)(pt,{align:`start`,children:[(0,G.jsx)(mt,{onSelect:()=>void R(!1),children:e(`connection.dialog.exportWithoutSecrets`)}),(0,G.jsx)(mt,{onSelect:()=>void R(!0),children:e(`connection.dialog.exportWithSecrets`)})]})]}),(0,G.jsx)(a,{variant:`outline`,onClick:()=>void Ce(),children:e(`connection.dialog.import`)})]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(a,{variant:`outline`,onClick:q,disabled:!b||i,children:e(`connection.dialog.testConnection`)}),(0,G.jsx)(a,{onClick:K,disabled:!b||Te,children:e(`connection.dialog.connect`)}),(0,G.jsx)(a,{variant:`outline`,onClick:()=>I(!1),children:e(`connection.dialog.close`)})]})]})]})})}export{ht as ConnectDialog};
|
|
1
|
+
import{r as e}from"./hePW80VL.js";import{o as t,p as n}from"./CyX8oVsa.js";import{a as r,i,t as a,u as o}from"./Dya0zxo6.js";import{i as s,r as c}from"./C76CctEl.js";import{C as l,D as u,O as d,T as f,a as p,i as m,n as ee,o as h,t as g}from"./kTwcxyaO.js";import{a as _,i as v,n as y,r as b,t as x}from"./34iJa-68.js";import{r as S,t as C}from"./Nro86Y63.js";import{A as w,f as T,j as E,t as D,w as O}from"./iz6RnRcO.js";import{O as k,g as A,m as te,o as ne}from"./zdvaVsTo.js";import{n as j,t as re}from"./BihjBM79.js";import{n as ie}from"./C_qmv4pB.js";import{C as ae,_ as oe,f as M,i as se,r as ce,u as N}from"./BVZGLNq_.js";import{At as le,C as ue,H as de,Jt as fe,N as pe,P as me,S as P,T as F,a as he,an as I,b as ge,c as L,ct as _e,en as ve,i as ye,in as be,l as R,lt as xe,n as Se,nn as Ce,o as z,r as we,rn as Te,s as B,st as Ee,tn as V,u as H,vt as De,w as Oe,x as ke,z as Ae}from"./D4DxtYTA.js";import{t as U}from"./CnYBZPf9.js";var W=e(n(),1),G=c(),K=Object.defineProperty,q=(e,t)=>K(e,`name`,{value:t,configurable:!0}),je=`DropdownMenu`,[Me,Ne]=d(je,[I]),J=I(),[Pe,Fe]=Me(je),Ie=q(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=J(t),u=W.useRef(null),[d,p]=f({prop:i,defaultProp:a??!1,onChange:o,caller:je});return(0,G.jsx)(Pe,{scope:t,triggerId:l(),triggerRef:u,contentId:l(),open:d,onOpenChange:p,onOpenToggle:W.useCallback(()=>p(e=>!e),[p]),modal:s,children:(0,G.jsx)(be,{...c,open:d,onOpenChange:p,dir:r,modal:s,children:n})})},`DropdownMenu`),Le=`DropdownMenuTrigger`,Re=W.forwardRef(q(function(e,t){let{__scopeDropdownMenu:n,disabled:i=!1,...a}=e,s=Fe(Le,n),c=J(n),l=o(t,s.triggerRef);return(0,G.jsx)(ve,{asChild:!0,...c,children:(0,G.jsx)(r.button,{type:`button`,id:s.triggerId,"aria-haspopup":`menu`,"aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?`open`:`closed`,"data-disabled":i?``:void 0,disabled:i,...a,ref:l,onPointerDown:u(e.onPointerDown,e=>{!i&&e.button===0&&e.ctrlKey===!1&&(s.onOpenToggle(),s.open||e.preventDefault())}),onKeyDown:u(e.onKeyDown,e=>{i||([`Enter`,` `].includes(e.key)&&s.onOpenToggle(),e.key===`ArrowDown`&&s.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),ze=q(e=>{let{__scopeDropdownMenu:t,...n}=e,r=J(t);return(0,G.jsx)(Te,{...r,...n})},`DropdownMenuPortal`),Be=`DropdownMenuContent`,Ve=W.forwardRef(q(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Fe(Be,n),a=J(n),o=W.useRef(!1);return(0,G.jsx)(V,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:u(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:u(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),He=W.forwardRef(q(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=J(n);return(0,G.jsx)(Ce,{...i,...r,ref:t})},`DropdownMenuItem`)),Ue=Ie,We=Re,Ge=ze,Ke=Ve,qe=He,Je=new Set([`postgres:`,`postgresql:`]);function Ye(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(!Je.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 Xe=new Set([`localhost`,`127.0.0.1`,`[::1]`,`::1`,`0.0.0.0`]);async function Ze(e,t){let n;try{let t=new URL(e);if(!Xe.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 Qe=[`utf8`,`utf8mb4`,`latin1`,`ascii`,`euckr`,`sjis`,`big5`],$e={enabled:!1,host:``,port:22,user:``,auth:`key`};function Y({label:e,htmlFor:t,children:n}){return(0,G.jsxs)(`div`,{className:`grid grid-cols-[120px_minmax(0,1fr)] items-center gap-2`,children:[(0,G.jsx)(L,{htmlFor:t,children:e}),n]})}function et({value:e,onChange:t}){let{t:n}=s();function r(n,r){t({...e,[n]:r})}let[i,o]=(0,W.useState)([]),c=e.dbms===`d1`?e.devUrl??``:``;(0,W.useEffect)(()=>{if(!c){o([]);return}let e=new AbortController,t=setTimeout(()=>{Ze(c,e.signal).then(o)},300);return()=>{clearTimeout(t),e.abort()}},[c]);let l=e.dbms===`sqlite`,u=e.transport??`browser`,d=l&&u===`browser`,f=C.has(e.dbms),p=e.dbms===`d1`,m=e.dbms===`do`,ee=w.find(t=>t.id===e.dbms)?.capabilities,h=e.ssh??$e,[g,T]=(0,W.useState)(``),D=g.trim()===``?`empty`:Ye(g)?`applied`:`invalid`,O=e.dbms===`supabase`&&e.port===6543;function k(n){T(n);let r=Ye(n);r&&t({...e,host:r.host??e.host,port:r.port??w.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 A(n){t({...e,ssh:{...h,...n}})}async function te(e){e&&A({privateKey:await e.text(),privateKeyName:e.name})}return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,G.jsx)(Y,{label:n(`connection.form.hostName`),htmlFor:`conn-hostName`,children:(0,G.jsx)(R,{id:`conn-hostName`,placeholder:n(`connection.form.hostNamePlaceholder`),value:e.hostName,onChange:e=>r(`hostName`,e.target.value)})}),(0,G.jsx)(Y,{label:n(`connection.form.dataSource`),children:(0,G.jsxs)(x,{value:e.dbms,onValueChange:n=>{let r=w.find(e=>e.id===n);if(!r)return;let i=r.id,a=C.has(i)||i===`d1`||i===`do`;T(``),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||f||p||m||e.user===B(e.dbms)?B(i):e.user,devUrl:i===`do`?e.devUrl||`http://localhost:8787`:e.devUrl,database:e.database&&!a&&!f&&!p&&!m?e.database:z(i)??e.database})},children:[(0,G.jsx)(v,{id:`conn-dbms`,className:`w-full`,children:(0,G.jsx)(_,{})}),(0,G.jsx)(y,{children:w.map(e=>(0,G.jsx)(b,{value:e.id,children:(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(H,{dbms:e.id}),e.label]})},e.id))})]})}),f&&(0,G.jsx)(Y,{label:n(`connection.form.connectionString`),htmlFor:`conn-uri`,children:(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.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:g,onChange:e=>k(e.target.value)}),(0,G.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`)})]})}),l&&(0,G.jsxs)(Y,{label:n(`connection.form.openVia`),children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`radio`,name:`transport`,value:`browser`,checked:u===`browser`,onChange:()=>r(`transport`,`browser`),className:`accent-primary`}),n(`connection.form.viaBrowser`)]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`radio`,name:`transport`,value:`tunnel`,checked:u===`tunnel`,onChange:()=>r(`transport`,`tunnel`),className:`accent-primary`}),n(`connection.form.viaAgent`)]})]}),(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(u===`browser`?`connection.form.viaBrowserHint`:`connection.form.viaAgentHint`)})]}),d?(0,G.jsx)(Y,{label:n(`connection.form.databaseFile`),children:(0,G.jsxs)(`div`,{className:`min-w-0 text-xs text-muted-foreground leading-relaxed`,children:[e.file?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,G.jsx)(`span`,{className:`min-w-0 break-all text-foreground`,title:e.file,children:e.file}),(0,G.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,className:`h-6 shrink-0 px-2 text-xs`,onClick:()=>{N(e.id),r(`file`,``)},children:n(`connection.form.changeFile`)})]}):(0,G.jsx)(`p`,{children:n(`connection.form.filePickerHint`)}),(0,G.jsx)(`p`,{className:`mt-1`,children:n(`connection.form.fileRememberedHint`)})]})}):null,!d&&(0,G.jsx)(Y,{label:n(`connection.form.authToken`),htmlFor:`conn-authToken`,children:(0,G.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())})}),d?null:m?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{label:n(`connection.form.doDevUrl`),htmlFor:`conn-do-url`,children:(0,G.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,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.doHint`)}),(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.doLimitsHint`)})]}):p?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{label:n(`connection.form.d1DevUrl`),htmlFor:`conn-d1-dev`,children:(0,G.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,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1DevUrlHint`)}),(0,G.jsx)(Y,{label:n(`connection.form.d1AccountId`),htmlFor:`conn-d1-account`,children:(0,G.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,G.jsx)(Y,{label:n(`connection.form.d1DatabaseId`),htmlFor:`conn-d1-database`,children:i.length>0?(0,G.jsxs)(x,{value:e.databaseId??``,onValueChange:e=>r(`databaseId`,e),children:[(0,G.jsx)(v,{id:`conn-d1-database`,children:(0,G.jsx)(_,{placeholder:n(`connection.form.d1PickDatabase`)})}),(0,G.jsx)(y,{children:i.map(e=>(0,G.jsxs)(b,{value:e.id,children:[e.name,` · `,e.id]},e.id))})]}):(0,G.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,G.jsx)(Y,{label:n(`connection.form.d1ApiToken`),htmlFor:`conn-pass`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(R,{id:`conn-pass`,type:`password`,autoComplete:`new-password`,value:e.pass,onChange:e=>r(`pass`,e.target.value.trim())}),(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs whitespace-nowrap cursor-pointer`,title:n(`connection.form.savePasswordHint`),children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:e.savePassword??!0,onChange:e=>r(`savePassword`,e.target.checked)}),n(`connection.form.savePassword`)]})]})}),(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1Hint`)}),(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1LimitsHint`)})]}):l?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{label:n(`connection.form.databaseFile`),htmlFor:`conn-file`,children:(0,G.jsx)(R,{id:`conn-file`,placeholder:n(`connection.form.filePathPlaceholder`),value:e.file??``,onChange:e=>r(`file`,e.target.value)})}),(0,G.jsx)(Y,{label:n(`connection.form.createIfMissing`),htmlFor:`conn-create`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.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,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.createIfMissingHint`)})]})})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{label:n(`connection.form.host`),htmlFor:`conn-host`,children:(0,G.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,G.jsx)(Y,{label:n(`connection.form.port`),htmlFor:`conn-port`,children:(0,G.jsx)(R,{id:`conn-port`,type:`number`,value:e.port,onChange:t=>r(`port`,Number(t.target.value)||w.find(t=>t.id===e.dbms)?.defaultPort||3306)})}),O&&(0,G.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`)}),z(e.dbms)!==void 0&&(0,G.jsx)(Y,{label:e.dbms===`oracle`?n(`connection.form.serviceName`):n(`connection.form.database`),htmlFor:`conn-database`,children:(0,G.jsx)(R,{id:`conn-database`,placeholder:z(e.dbms),value:e.database??``,onChange:e=>r(`database`,e.target.value.trim())})}),(0,G.jsx)(Y,{label:n(`connection.form.user`),htmlFor:`conn-user`,children:(0,G.jsx)(R,{id:`conn-user`,autoComplete:`off`,placeholder:B(e.dbms),value:e.user,onChange:e=>r(`user`,e.target.value)})}),(0,G.jsx)(Y,{label:n(`connection.form.password`),htmlFor:`conn-pass`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(R,{id:`conn-pass`,type:`password`,autoComplete:`new-password`,value:e.pass,onChange:e=>r(`pass`,e.target.value)}),(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs whitespace-nowrap cursor-pointer`,title:n(`connection.form.savePasswordHint`),children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:e.savePassword??!0,onChange:e=>r(`savePassword`,e.target.checked)}),n(`connection.form.savePassword`)]})]})}),f&&(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.managedTlsHint`)}),(()=>{let t=E(e.dbms),r=`formHint`in t?t.formHint:void 0;return r?(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(r)}):null})(),!f&&e.dbms!==`oracle`&&(0,G.jsx)(Y,{label:n(`connection.form.tls`),children:(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[(0,G.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,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer ${e.ssl?``:`opacity-50`}`,title:n(`connection.form.tlsVerifyHint`),children:[(0,G.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`)]})]})}),!f&&S(E(e.dbms))&&(0,G.jsx)(Y,{label:n(`connection.form.charset`),children:(0,G.jsxs)(x,{value:e.charset,onValueChange:e=>r(`charset`,e),children:[(0,G.jsx)(v,{className:`w-full`,children:(0,G.jsx)(_,{})}),(0,G.jsx)(y,{children:Qe.map(e=>(0,G.jsx)(b,{value:e,children:e},e))})]})})]}),!l&&!f&&!p&&!m&&(0,G.jsxs)(G.Fragment,{children:[(0,G.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,G.jsx)(de,{className:`ml-2`})]}),(0,G.jsx)(Y,{label:n(`connection.form.sshTunnel`),htmlFor:`conn-ssh`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{id:`conn-ssh`,type:`checkbox`,checked:h.enabled,onChange:e=>{(!e.target.checked||Ae(`ssh_tunnel`))&&A({enabled:e.target.checked})},className:`size-4 accent-primary cursor-pointer`}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.sshTunnelHint`)})]})}),h.enabled&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{label:n(`connection.form.sshHost`),htmlFor:`conn-ssh-host`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(R,{id:`conn-ssh-host`,placeholder:n(`connection.form.sshHostPlaceholder`),value:h.host,onChange:e=>A({host:e.target.value.trim()})}),(0,G.jsx)(R,{"aria-label":n(`connection.form.sshPort`),type:`number`,className:`w-24 shrink-0`,value:h.port,onChange:e=>A({port:Number(e.target.value)||22})})]})}),(0,G.jsx)(Y,{label:n(`connection.form.sshUser`),htmlFor:`conn-ssh-user`,children:(0,G.jsx)(R,{id:`conn-ssh-user`,placeholder:n(`connection.form.sshUserPlaceholder`),value:h.user,onChange:e=>A({user:e.target.value.trim()})})}),(0,G.jsx)(Y,{label:n(`connection.form.sshAuth`),children:(0,G.jsxs)(x,{value:h.auth,onValueChange:e=>A({auth:e}),children:[(0,G.jsx)(v,{className:`w-full`,children:(0,G.jsx)(_,{})}),(0,G.jsxs)(y,{children:[(0,G.jsx)(b,{value:`key`,children:n(`connection.form.sshAuthKey`)}),(0,G.jsx)(b,{value:`password`,children:n(`connection.form.sshAuthPassword`)}),(0,G.jsx)(b,{value:`agent`,children:n(`connection.form.sshAuthAgent`)})]})]})}),h.auth===`password`&&(0,G.jsx)(Y,{label:n(`connection.form.sshPassword`),htmlFor:`conn-ssh-pass`,children:(0,G.jsx)(R,{id:`conn-ssh-pass`,type:`password`,autoComplete:`new-password`,value:h.password??``,onChange:e=>A({password:e.target.value})})}),h.auth===`key`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{label:n(`connection.form.sshKey`),htmlFor:`conn-ssh-key`,children:(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`input`,{id:`conn-ssh-key`,type:`file`,className:`hidden`,onChange:e=>{te(e.target.files?.[0]),e.target.value=``}}),(0,G.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 shrink-0 px-2 text-xs`,onClick:()=>document.getElementById(`conn-ssh-key`)?.click(),children:h.privateKey?n(`connection.form.changeFile`):n(`connection.form.sshKeyPick`)}),(0,G.jsx)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,title:h.privateKeyName,children:h.privateKey?h.privateKeyName||n(`connection.form.sshKeyLoaded`):n(`connection.form.sshKeyHint`)})]})}),(0,G.jsx)(Y,{label:n(`connection.form.sshPassphrase`),htmlFor:`conn-ssh-passphrase`,children:(0,G.jsx)(R,{id:`conn-ssh-passphrase`,type:`password`,autoComplete:`new-password`,placeholder:n(`connection.form.sshPassphrasePlaceholder`),value:h.passphrase??``,onChange:e=>A({passphrase:e.target.value})})})]}),h.auth===`agent`&&(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshAuthAgentHint`)}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshTargetHint`)}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshSecretsHint`)})]})]}),(0,G.jsx)(Y,{label:n(`connection.form.autoConnection`),htmlFor:`conn-auto`,children:(0,G.jsx)(`div`,{className:`flex items-center`,children:(0,G.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,G.jsx)(`div`,{className:`mt-1 border-t pt-3 text-xs font-medium text-muted-foreground`,children:n(`connection.form.safety`)}),(0,G.jsx)(Y,{label:n(`connection.form.environment`),children:(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[pe.map(t=>{let n=(e.environmentColor??`none`)===t.id;return(0,G.jsx)(`button`,{type:`button`,title:me(t.id),"aria-label":me(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,G.jsx)(`span`,{className:`ml-1 text-xs text-muted-foreground`,children:n(`connection.form.environmentHint`)})]})}),(0,G.jsx)(Y,{label:n(`connection.form.readOnly`),htmlFor:`conn-readonly`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.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,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.readOnlyHint`)})]})}),ee?.transactions!==!1&&(0,G.jsx)(Y,{label:n(`connection.form.transactions`),children:(0,G.jsxs)(x,{value:e.transactionMode??`auto`,onValueChange:e=>r(`transactionMode`,e),children:[(0,G.jsx)(v,{className:`w-full`,children:(0,G.jsx)(_,{})}),(0,G.jsxs)(y,{children:[(0,G.jsx)(b,{value:`auto`,children:n(`connection.form.txAuto`)}),(0,G.jsx)(b,{value:`manual`,children:n(`connection.form.txManual`)})]})]})})]})}var tt=[`id`,`serverConnectionId`,`sample`,`scratchpad`,`autoConnection`];function nt(e){return!e.sample&&!e.scratchpad}function rt(e,t,n=new Date){let r=t?e:O(e),i={...r};for(let e of tt)delete i[e];if(i.pass||delete i.pass,i.authToken||delete i.authToken,r.ssh){let e={...r.ssh};for(let t of[`password`,`passphrase`,`privateKey`])e[t]||delete e[t];i.ssh=e}return{planche:`connection`,version:1,exportedAt:n.toISOString(),secrets:t,connection:i}}function it(e){let t;try{t=JSON.parse(e)}catch{throw Error(`Not a JSON file`)}let n=t;if(!n||n.planche!==`connection`||!n.connection||typeof n.connection!=`object`)throw Error(`Not a Planche connection file`);if(typeof n.connection.dbms!=`string`||!n.connection.dbms)throw Error(`The connection has no database type`);return n}var X=(e,t=``)=>typeof e==`string`?e:t,Z=e=>typeof e==`boolean`?e:void 0,at=(e,t)=>typeof e==`number`&&Number.isFinite(e)?e:t,Q=e=>e===void 0||e===``?void 0:e;function ot(e){if(!e||typeof e!=`object`)return;let t=e,n=t.auth===`key`||t.auth===`agent`?t.auth:`password`;return{enabled:t.enabled===!0,host:X(t.host),port:at(t.port,22),user:X(t.user),auth:n,password:Q(X(t.password)),privateKey:Q(X(t.privateKey)),privateKeyName:Q(X(t.privateKeyName)),passphrase:Q(X(t.passphrase))}}function st(e,t,n=crypto.randomUUID()){let r=e.connection,i=Z(r.savePassword),a={id:n,hostName:ct(X(r.hostName),t),host:X(r.host),user:X(r.user),pass:X(r.pass),charset:X(r.charset,`utf8`),port:at(r.port,0),dbms:r.dbms,database:Q(X(r.database)),transport:r.transport===`tunnel`||r.transport===`browser`?r.transport:void 0,file:Q(X(r.file)),createIfMissing:Z(r.createIfMissing),ssl:Z(r.ssl),sslVerify:Z(r.sslVerify),accountId:Q(X(r.accountId)),databaseId:Q(X(r.databaseId)),devUrl:Q(X(r.devUrl)),ssh:ot(r.ssh),gatewayProfile:Q(X(r.gatewayProfile)),autoConnection:!1,savePassword:i??!0,authToken:X(r.authToken),readOnly:Z(r.readOnly),environmentColor:Q(X(r.environmentColor)),transactionMode:Q(X(r.transactionMode))};for(let e of Object.keys(a))a[e]===void 0&&delete a[e];return a}function ct(e,t){if(!e||!t.some(t=>t.hostName===e))return e;for(let n=2;;n++){let r=`${e} (${n})`;if(!t.some(e=>e.hostName===r))return r}}async function lt(e,t,n=`application/json`){let r=U(e);if(typeof window.showSaveFilePicker==`function`)try{let e=await(await window.showSaveFilePicker({suggestedName:r,types:[{accept:{[n]:[`.${r.split(`.`).pop()??`txt`}`]}}]})).createWritable();return await e.write(t),await e.close(),!0}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return!1}let i=URL.createObjectURL(new Blob([t],{type:n})),a=document.createElement(`a`);return a.href=i,a.download=r,a.click(),URL.revokeObjectURL(i),!0}function ut(e=`.json,application/json`){return new Promise(t=>{let n=document.createElement(`input`);n.type=`file`,n.accept=e,n.onchange=async()=>{let e=n.files?.[0];t(e?await e.text():null)},n.oncancel=()=>t(null),n.click()})}function dt({...e}){return(0,G.jsx)(Ue,{"data-slot":`dropdown-menu`,...e})}function ft({...e}){return(0,G.jsx)(We,{"data-slot":`dropdown-menu-trigger`,...e})}function pt({className:e,sideOffset:t=4,...n}){return(0,G.jsx)(Ge,{children:(0,G.jsx)(Ke,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:i(`z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,e),...n})})}function mt({className:e,inset:t,variant:n=`default`,...r}){return(0,G.jsx)(qe,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:i(`relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!`,e),...r})}function $(e,n,r){let i=_e(r);return t(`connection_error`,{action:e,dbms:n,reason:i}),Ee(i)}function ht(){let{t:e}=s(),{activeDialog:t,closeDialog:n,showMessage:r}=j(),[i,o]=(0,W.useState)(!1),{savedConnections:c,addSavedConnection:l,updateSavedConnection:u,deleteSavedConnection:d,openConnection:f}=D(),_=re(`connect`)?.profileId,[v,y]=(0,W.useState)(()=>_??null),[b,x]=(0,W.useState)(()=>{let e=_?c.find(e=>e.id===_):void 0;return e?{...e}:null}),S=t===`connect`,[C,w]=(0,W.useState)(null),[O,N]=(0,W.useState)(null),de=xe(e=>e.url),pe=xe(e=>e.token);(0,W.useEffect)(()=>{if(!S)return;let e=!1;return(async()=>{try{let t=await ne();if(e||t.state!==`online`||!t.gateway){e||w(null);return}let n=await te();e||(w({name:n.gateway,profiles:n.profiles}),N(null))}catch(t){e||N(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[S,de,pe]);function me(t){let n=c.find(e=>e.gatewayProfile===t.name);if(n){L(n);return}let r=we(t);l(r),L(r),j.getState().setFooterMessage(e(`connection.dialog.gatewayAdded`,{name:t.name}))}function I(e){e||(n(),y(null),x(null))}function L(e){y(e.id),x({...e})}function _e(e){x(e),u(e.id,e)}function ve(){let e=he();l(e),y(e.id),x(e)}function be(){v&&(d(v),y(null),x(null))}async function R(t){let n=c.find(e=>e.id===v);if(!n||!nt(n))return;let r=n.hostName||e(`connection.dialog.unnamed`),i=rt(D.getState().resolveCredentials(n),t);await lt(`planche-connection-${r}.json`,JSON.stringify(i,null,2))&&j.getState().setFooterMessage(e(`connection.dialog.exported`,{name:r}))}async function Ce(){let t=await ut();if(t!==null)try{let n=st(it(t),D.getState().savedConnections);l(n),y(n.id),x(n),j.getState().setFooterMessage(e(`connection.dialog.imported`,{name:n.hostName||e(`connection.dialog.unnamed`)}))}catch(t){r({tone:`error`,title:e(`connection.dialog.importFailedTitle`),description:t instanceof Error?t.message:String(t)})}}let z=v!==null&&c.some(e=>e.id===v&&nt(e)),[Te,B]=(0,W.useState)(!1),Ee=ie(e=>e.addQueryTab);function V(t){let r=D.getState().activeConnections.some(e=>e.id===t.id);if(f(t),ae.getState().removeTree(t.id),T(t.id),r){n(),y(null),x(null);return}Ee(t.id,{id:`tab-${Date.now()}`,title:e(`connection.dialog.firstQueryTab`),query:``,database:``,isExecuting:!1,results:[],error:null,executionTime:null}),n(),y(null),x(null)}async function Ae(t){let n=await ce(t.id,{interactive:!0});if(!n)return;let r={...t,file:n.fileName,serverConnectionId:n.connectionId};u(t.id,{file:n.fileName}),V(r),D.getState().setFileDetached(t.id,n.fileDetached),n.restoredUnsaved?j.getState().setFooterMessage(e(n.diskChanged?`connection.dialog.restoredUnsavedDiskChanged`:`connection.dialog.restoredUnsaved`,{file:n.fileName})):n.wal&&!n.walApplied?j.getState().setFooterMessage(e(`connection.dialog.walPending`,{file:n.fileName})):n.walApplied&&j.getState().setFooterMessage(e(`connection.dialog.walApplied`,{file:n.fileName}))}async function U(t,n){try{return await n(t)}catch(r){let i=A(r);if(!i||!(`ssh`in t)||!t.ssh||!await j.getState().requestDestructiveConfirm({title:e(`connection.dialog.hostKeyTitle`),description:e(`connection.dialog.hostKeyDescription`,i),confirmLabel:e(`connection.dialog.hostKeyAccept`)}))throw r;return n({...t,ssh:{...t.ssh,acceptHostKey:i.fingerprint}})}}async function K(){if(b){B(!0);try{if(M(b)===`browser`){await Ae(b);return}let t=await U(k(b),e=>se(e,b.authToken||void 0));if(t.success)V({...b,serverConnectionId:t.connectionId});else{let n=$(`connect`,b.dbms,Error(t.message??``));r({tone:`error`,title:e(`connection.dialog.connectFailedTitle`),description:t.message??e(`connection.dialog.unknownError`),...n})}}catch(t){let n=$(`connect`,b.dbms,t);r({tone:`error`,title:e(`connection.dialog.connectFailedTitle`),description:t instanceof Error?t.message:String(t),...n})}finally{B(!1)}}}async function q(){if(b){if(M(b)===`browser`){r({tone:`info`,title:e(`connection.dialog.testConnection`),description:e(`connection.dialog.browserTestHint`)});return}o(!0);try{let t=await U(k(b),e=>oe(e,b.authToken||void 0));if(t.success)r({tone:`success`,title:e(`connection.dialog.testSuccess`),description:e(`connection.dialog.testSuccessDescription`)});else{let n=$(`test`,b.dbms,Error(t.message??``));r({tone:`error`,title:e(`connection.dialog.testFailedTitle`),description:t.message??e(`connection.dialog.unknownError`),...n})}}catch(t){let n=$(`test`,b.dbms,t);r({tone:`error`,title:e(`connection.dialog.testFailedTitle`),description:t instanceof Error?t.message:String(t),...n})}finally{o(!1)}}}return(0,G.jsx)(g,{open:S,onOpenChange:I,children:(0,G.jsxs)(ee,{className:`sm:max-w-[1100px] h-[85vh] max-h-[85vh] flex flex-col`,children:[(0,G.jsx)(p,{children:(0,G.jsx)(h,{children:e(`connection.dialog.title`)})}),(0,G.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,G.jsx)(le,{className:`mt-0.5 size-4 shrink-0 text-catppuccin-green`,"aria-hidden":!0}),(0,G.jsx)(`span`,{children:e(`connection.dialog.privacy`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-1 gap-4 overflow-hidden min-h-0`,children:[(0,G.jsxs)(`div`,{className:`w-[460px] shrink-0 border rounded-md overflow-hidden flex flex-col`,children:[(C||O)&&(0,G.jsxs)(`div`,{className:`border-b p-2 text-xs space-y-1 max-h-40 overflow-auto`,children:[(0,G.jsxs)(`p`,{className:`font-medium`,children:[e(`connection.dialog.gatewayTitle`),C?` — ${C.name}`:``]}),O&&(0,G.jsx)(`p`,{className:`text-destructive`,children:e(`connection.dialog.gatewayLoadFailed`,{error:O})}),C?.profiles.map(t=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5 truncate`,children:[(0,G.jsx)(H,{dbms:Se[t.driver],className:`size-3.5`}),(0,G.jsx)(`span`,{className:`truncate`,children:t.name}),(0,G.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,t.readOnly?e(`connection.dialog.gatewayReadOnly`):e(`connection.dialog.gatewayWritable`),`)`]})]}),(0,G.jsx)(a,{size:`sm`,variant:`outline`,className:`h-6 px-2 text-xs`,onClick:()=>me(t),children:e(`connection.dialog.gatewayAdd`)})]},t.name))]}),(0,G.jsx)(De,{className:`h-full`,children:(0,G.jsxs)(ge,{className:`table-fixed`,children:[(0,G.jsx)(Oe,{children:(0,G.jsxs)(F,{children:[(0,G.jsx)(ue,{className:`w-[32%]`,children:e(`connection.dialog.colHostName`)}),(0,G.jsx)(ue,{className:`w-[40%]`,children:e(`connection.dialog.colTarget`)}),(0,G.jsx)(ue,{className:`w-[28%]`,children:e(`connection.dialog.colDbms`)})]})}),(0,G.jsx)(ke,{children:c.length===0?(0,G.jsx)(F,{children:(0,G.jsx)(P,{colSpan:3,className:`text-center text-muted-foreground`,children:e(`connection.dialog.noSaved`)})}):c.map(t=>(0,G.jsxs)(F,{"data-state":v===t.id?`selected`:void 0,className:`cursor-pointer`,onClick:()=>L(t),onDoubleClick:()=>{L(t),K()},children:[(0,G.jsx)(P,{className:`truncate font-medium`,title:t.hostName,children:t.hostName||e(`connection.dialog.unnamed`)}),(0,G.jsx)(P,{className:`truncate`,title:t.dbms===`sqlite`?t.file:t.dbms===`d1`?t.databaseId:t.dbms===`do`?t.devUrl:`${t.user?`${t.user}@`:``}${t.host}:${t.port}`,children:t.dbms===`sqlite`?t.file||(M(t)===`browser`?e(`connection.dialog.pickOnConnect`):e(`connection.dialog.noFile`)):t.dbms===`d1`?t.databaseId||`—`:t.dbms===`do`?t.devUrl||`—`:`${t.user?`${t.user}@`:``}${t.host}:${t.port}`}),(0,G.jsx)(P,{className:`truncate`,title:E(t.dbms).label,children:(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(H,{dbms:t.dbms,className:`size-3.5`}),(0,G.jsx)(`span`,{className:`truncate`,children:E(t.dbms).label})]})})]},t.id))})]})})]}),(0,G.jsx)(`div`,{className:`flex-1 border rounded-md overflow-auto`,children:b?(0,G.jsxs)(G.Fragment,{children:[M(b)!==`browser`&&(0,G.jsx)(`div`,{className:`p-4 pb-0`,children:(0,G.jsx)(ye,{})}),b.gatewayProfile?(0,G.jsxs)(`div`,{className:`p-4 space-y-2 text-sm`,children:[(0,G.jsxs)(`p`,{className:`font-medium flex items-center gap-2`,children:[(0,G.jsx)(H,{dbms:b.dbms,className:`size-4`}),b.hostName]}),(0,G.jsx)(`p`,{className:`text-muted-foreground`,children:e(`connection.dialog.gatewayProfileHint`,{name:b.gatewayProfile})}),(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[b.readOnly?e(`connection.dialog.gatewayReadOnly`):e(`connection.dialog.gatewayWritable`),b.database?` · ${b.database}`:``]})]}):(0,G.jsx)(et,{value:b,onChange:_e})]}):(0,G.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:e(`connection.dialog.selectPrompt`)})})]}),(0,G.jsxs)(m,{className:`sm:justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(a,{variant:`outline`,onClick:ve,children:e(`connection.dialog.addNew`)}),(0,G.jsx)(a,{variant:`destructive`,onClick:be,disabled:!v,children:e(`connection.dialog.delete`)}),(0,G.jsxs)(dt,{children:[(0,G.jsx)(ft,{asChild:!0,children:(0,G.jsxs)(a,{variant:`outline`,disabled:!z,children:[e(`connection.dialog.export`),(0,G.jsx)(fe,{className:`ml-1 size-3.5`,"aria-hidden":!0})]})}),(0,G.jsxs)(pt,{align:`start`,children:[(0,G.jsx)(mt,{onSelect:()=>void R(!1),children:e(`connection.dialog.exportWithoutSecrets`)}),(0,G.jsx)(mt,{onSelect:()=>void R(!0),children:e(`connection.dialog.exportWithSecrets`)})]})]}),(0,G.jsx)(a,{variant:`outline`,onClick:()=>void Ce(),children:e(`connection.dialog.import`)})]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(a,{variant:`outline`,onClick:q,disabled:!b||i,children:e(`connection.dialog.testConnection`)}),(0,G.jsx)(a,{onClick:K,disabled:!b||Te,children:e(`connection.dialog.connect`)}),(0,G.jsx)(a,{variant:`outline`,onClick:()=>I(!1),children:e(`connection.dialog.close`)})]})]})]})})}export{ht as ConnectDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./hePW80VL.js";import{p as t}from"./
|
|
1
|
+
import{r as e}from"./hePW80VL.js";import{p as t}from"./CyX8oVsa.js";import{t as n}from"./Dya0zxo6.js";import{i as r,r as i}from"./C76CctEl.js";import{a,i as o,n as ee,o as te,t as ne}from"./kTwcxyaO.js";import{a as s,i as c,n as l,r as u,t as d}from"./34iJa-68.js";import{t as re}from"./iz6RnRcO.js";import{n as f,t as ie}from"./BihjBM79.js";import{a as ae}from"./BVZGLNq_.js";import{r as p}from"./CH4cEkW4.js";import{f as m}from"./CZRhmV_L.js";import{F as oe,K as se,c as h,l as g,q as ce}from"./D4DxtYTA.js";var _=e(t(),1),v=i(),y=e=>e instanceof Error?e.message:String(e),b=e=>e.hostName||e.host||e.file||e.id,le=`w-full rounded border bg-background px-2 py-1 text-xs font-mono outline-none focus:ring-1 focus:ring-primary disabled:opacity-50 min-h-[160px] resize-y`;function x(){let{t:e}=r(),t=f(e=>e.activeDialog),i=f(e=>e.closeDialog),x=f(e=>e.showMessage),S=ie(`copy-table`),C=re(e=>e.activeConnections),w=t===`copy-table`,T=S?.connectionId??``,E=String(S?.metadata?.database??``),D=S?.nodeText??``,O=C.find(e=>e.id===T),ue=C.filter(e=>e.serverConnectionId),[k,de]=(0,_.useState)(T),[A,j]=(0,_.useState)([]),[M,N]=(0,_.useState)(``),[P,F]=(0,_.useState)(D),[I,L]=(0,_.useState)(`structure_data`),[R,z]=(0,_.useState)(`abort`),[B,V]=(0,_.useState)(``),[H,U]=(0,_.useState)(null),[W,G]=(0,_.useState)(null),[K,q]=(0,_.useState)(null),[J,Y]=(0,_.useState)(!1),X=(0,_.useRef)(null),Z=C.find(e=>e.id===k),Q=Z?p(k):null,fe=!!O&&!!Z&&p(T).id===Q?.id;(0,_.useEffect)(()=>{if(!w||!Z?.serverConnectionId)return;let e=!1,t=p(k),n=ae(Z.serverConnectionId);return(async()=>{j([]);try{let r=await t.introspect.listDatabases(n);if(e)return;j(r);let i=k===T,a=i||r.includes(E)?E:r[0]??``;N(a),F(e=>i&&a===E&&e===D?`${D}_copy`:e)}catch(t){e||q(y(t))}})(),()=>{e=!0}},[w,k]),(0,_.useEffect)(()=>{if(!w||!Z||!M||!P.trim()||!O)return;let e=!1;return(async()=>{U(null);try{let t=await se({connectionId:T,database:E,table:D},{connectionId:k,database:M,table:P.trim()});e||V(p(k).ddl.createTable(t))}catch(t){e||U(y(t))}})(),()=>{e=!0}},[w,k,M,P]);function $(e){if(!e){if(J){X.current?.abort();return}i()}}async function pe(){if(!M||!P.trim()||!B.trim())return;Y(!0),q(null),G({phase:`create`,copied:0,total:null});let t=new AbortController;X.current=t;try{let n=await ce({source:{connectionId:T,database:E,table:D},target:{connectionId:k,database:M,table:P.trim()},mode:I,onConflict:R,createSql:B},G,t.signal);i(),await x({title:e(`table.copy.doneTitle`),description:I===`structure_data`?e(`table.copy.doneRows`,{count:n.rows,table:P.trim()}):e(`table.copy.doneStructure`,{table:P.trim()}),tone:`success`})}catch(e){e instanceof m||q(y(e)),G(null)}finally{Y(!1),X.current=null}}let me=W?.phase===`copy`&&W.total?Math.min(100,Math.round(W.copied/W.total*100)):null,he=W?W.phase===`create`?e(`table.copy.progressCreate`):W.phase===`count`?e(`table.copy.progressCount`):W.phase===`copy`?e(`table.copy.progressRows`,{copied:W.copied,total:W.total??`?`}):e(`table.copy.progressDone`):``;return(0,v.jsx)(ne,{open:w,onOpenChange:$,children:(0,v.jsxs)(ee,{className:`sm:max-w-[640px]`,children:[(0,v.jsx)(a,{children:(0,v.jsx)(te,{children:e(`table.copy.title`)})}),(0,v.jsxs)(`div`,{className:`space-y-4`,children:[(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(h,{children:e(`table.copy.source`)}),(0,v.jsx)(g,{value:O?`${b(O)} / ${E} / ${D}`:``,disabled:!0})]}),(0,v.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(h,{htmlFor:`copy-target-conn`,children:e(`table.copy.targetConnection`)}),(0,v.jsxs)(d,{value:k,onValueChange:de,disabled:J,children:[(0,v.jsx)(c,{id:`copy-target-conn`,className:`w-full`,children:(0,v.jsx)(s,{})}),(0,v.jsx)(l,{children:ue.map(t=>(0,v.jsxs)(u,{value:t.id,children:[b(t),t.readOnly?` (${e(`table.copy.readOnly`)})`:``]},t.id))})]})]}),(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(h,{htmlFor:`copy-target-db`,children:e(`table.copy.targetDatabase`)}),(0,v.jsxs)(d,{value:M,onValueChange:N,disabled:J||A.length===0,children:[(0,v.jsx)(c,{id:`copy-target-db`,className:`w-full`,children:(0,v.jsx)(s,{placeholder:e(`table.copy.loading`)})}),(0,v.jsx)(l,{children:A.map(e=>(0,v.jsx)(u,{value:e,children:e},e))})]})]})]}),(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(h,{htmlFor:`copy-target-table`,children:e(`table.copy.targetTable`)}),(0,v.jsx)(g,{id:`copy-target-table`,value:P,onChange:e=>F(e.target.value),disabled:J,spellCheck:!1})]}),(0,v.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(h,{children:e(`table.copy.what`)}),(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,v.jsx)(`input`,{type:`radio`,name:`copy-mode`,checked:I===`structure_data`,onChange:()=>L(`structure_data`),disabled:J}),e(`table.copy.structureAndData`)]}),(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,v.jsx)(`input`,{type:`radio`,name:`copy-mode`,checked:I===`structure_only`,onChange:()=>L(`structure_only`),disabled:J}),e(`table.copy.structureOnly`)]})]})]}),(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(h,{children:e(`table.copy.ifExists`)}),(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,v.jsx)(`input`,{type:`radio`,name:`copy-conflict`,checked:R===`abort`,onChange:()=>z(`abort`),disabled:J}),e(`table.copy.abort`)]}),(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer text-destructive`,children:[(0,v.jsx)(`input`,{type:`radio`,name:`copy-conflict`,checked:R===`drop`,onChange:()=>z(`drop`),disabled:J}),e(`table.copy.dropAndRecreate`)]})]})]})]}),(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(h,{htmlFor:`copy-ddl`,children:e(`table.copy.preview`)}),!fe&&Q&&(0,v.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`table.copy.crossEngineHint`,{engine:Q.label})}),(0,v.jsx)(`textarea`,{id:`copy-ddl`,className:le,value:B,onChange:e=>V(e.target.value),disabled:J,spellCheck:!1}),H&&(0,v.jsx)(`p`,{className:`text-xs text-destructive`,children:H})]}),W&&(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(oe,{value:me??(W.phase===`done`?100:0)}),(0,v.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:he})]}),K&&(0,v.jsx)(`p`,{className:`text-sm text-destructive whitespace-pre-wrap`,children:K})]}),(0,v.jsxs)(o,{children:[(0,v.jsx)(n,{variant:`outline`,onClick:()=>$(!1),children:e(J?`table.copy.stop`:`table.copy.cancel`)}),(0,v.jsx)(n,{onClick:()=>{pe()},disabled:J||!M||!P.trim()||!B.trim()||!!H,children:e(`table.copy.copy`)})]})]})})}export{x as CopyTableDialog};
|