planche 0.8.7 → 0.8.8
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/{HNvyS0OG.js → 40YxirOy.js} +1 -1
- package/app/assets/{C3S71So3.js → 8DjNs_2Q.js} +1 -1
- package/app/assets/{BLcW8KqJ.js → 9U3RO0MO.js} +1 -1
- package/app/assets/{DwhUAD0k.js → 9YYClKHB.js} +1 -1
- package/app/assets/{CMRtomUk.js → B7ofUN9Z.js} +1 -1
- package/app/assets/{Bxw3grU1.js → B_UAjgBr.js} +20 -20
- package/app/assets/{DNpCwjdk.js → Baj0YiGk.js} +1 -1
- package/app/assets/{ChiscGY_.js → BjlaUaDI.js} +1 -1
- package/app/assets/{DGXqbK7m.js → BteHmqJi.js} +1 -1
- package/app/assets/{0Fs8FEUD.js → BwrB7xZ-.js} +1 -1
- package/app/assets/{BHp-ICZv.js → BxdVjvjj.js} +1 -1
- package/app/assets/{DsllOXPq.js → Bz1cma8F.js} +1 -1
- package/app/assets/{Y9NV3E8q.js → C8pwHENI.js} +1 -1
- package/app/assets/{5Jrsnc1i.js → CCQZjXae.js} +2 -2
- package/app/assets/{CCwciyHS.js → CCcRP83D.js} +1 -1
- package/app/assets/{DUyKev3g.js → CFzRFS2A.js} +1 -1
- package/app/assets/{CU8MbklZ.js → CKDAL3sp.js} +1 -1
- package/app/assets/{Lv_K3w8K.js → COkWw8gt.js} +1 -1
- package/app/assets/{BaiI2zwt.js → COuEjUso.js} +1 -1
- package/app/assets/{DTqOQG1i.js → CYAMmigV.js} +1 -1
- package/app/assets/{7lSlYhqB.js → CcgrsKRV.js} +1 -1
- package/app/assets/{CKB3jCfp.js → Cni8dWDa.js} +1 -1
- package/app/assets/{D8WkLv3B.js → CoElGuoC.js} +1 -1
- package/app/assets/{kMxR92IL.js → D7TzN7zW.js} +1 -1
- package/app/assets/{Cy3jxi5W.js → DUi2bIfW.js} +1 -1
- package/app/assets/{CyNRK4kc.js → Dc-epzIX.js} +1 -1
- package/app/assets/{c2vgLpEV.js → DmnLfXty.js} +1 -1
- package/app/assets/{D2srGZZJ.js → DnMHkY8_.js} +1 -1
- package/app/assets/{D5KYAPHx.js → DouS7NHO.js} +1 -1
- package/app/assets/{c6OX2yNi.js → DprcmWG4.js} +1 -1
- package/app/assets/{GuPQTKm6.js → HtYgLQZp.js} +1 -1
- package/app/assets/{B2l0e8gZ.js → KZSCUzXE.js} +1 -1
- package/app/assets/{BgFzEiCb.css → MJ9qDdN_.css} +1 -1
- package/app/assets/{CJmQYjPl.js → ZjgMfDAG.js} +1 -1
- package/app/assets/{CgRvgqaA.js → xc6SHidZ.js} +1 -1
- package/app/assets/{DQsFpqjm.js → zrrdltej.js} +1 -1
- package/app/index.html +3 -3
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./hePW80VL.js";import{h as t,n,t as r}from"./XzPc-eVf.js";import{l as i,m as a,o,p as s,s as c,t as l}from"./CKOS5Y-e.js";import{S as u,_ as d,x as f,y as p}from"./CZQ1r4zz.js";import{a as m,i as h,n as g,r as _,t as v}from"./DsllOXPq.js";import{T as y,f as ee,t as b}from"./B3nhMsGp.js";import{E as x,O as S,T as C,a as w,f as T,m as te}from"./Ca4g4XbM.js";import{n as ne}from"./BNkgLUl5.js";import{S as E,d as D,g as re,i as ie,l as O,r as ae}from"./CtXRSNHU.js";import{n as oe,t as k}from"./BfSKVZnY.js";import{A,C as j,Gt as se,I as ce,Jt as M,Kt as N,Lt as le,S as ue,Ut as P,Wt as de,a as fe,b as F,bt as pe,c as me,i as he,j as I,l as L,lt as ge,n as _e,o as R,qt as ve,r as ye,rt as be,s as z,u as B,v as xe,x as V,y as Se,z as H}from"./Bxw3grU1.js";import{a as Ce,i as we,n as Te,o as Ee,t as De}from"./DxuXBECK.js";import{t as Oe}from"./CnYBZPf9.js";var U=e(t(),1),W=i(),G=Object.defineProperty,K=(e,t)=>G(e,`name`,{value:t,configurable:!0}),q=`DropdownMenu`,[J,ke]=u(q,[M]),Y=M(),[Ae,je]=J(q),Me=K(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=Y(t),l=U.useRef(null),[u,f]=p({prop:i,defaultProp:a??!1,onChange:o,caller:q});return(0,W.jsx)(Ae,{scope:t,triggerId:d(),triggerRef:l,contentId:d(),open:u,onOpenChange:f,onOpenToggle:U.useCallback(()=>f(e=>!e),[f]),modal:s,children:(0,W.jsx)(ve,{...c,open:u,onOpenChange:f,dir:r,modal:s,children:n})})},`DropdownMenu`),Ne=`DropdownMenuTrigger`,Pe=U.forwardRef(K(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=je(Ne,n),o=Y(n),l=s(t,a.triggerRef);return(0,W.jsx)(P,{asChild:!0,...o,children:(0,W.jsx)(c.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:l,onPointerDown:f(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:f(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),Fe=K(e=>{let{__scopeDropdownMenu:t,...n}=e,r=Y(t);return(0,W.jsx)(N,{...r,...n})},`DropdownMenuPortal`),Ie=`DropdownMenuContent`,Le=U.forwardRef(K(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=je(Ie,n),a=Y(n),o=U.useRef(!1);return(0,W.jsx)(de,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:f(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:f(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`)),Re=U.forwardRef(K(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Y(n);return(0,W.jsx)(se,{...i,...r,ref:t})},`DropdownMenuItem`)),ze=Me,Be=Pe,Ve=Fe,He=Le,Ue=Re,We=new Set([`postgres:`,`postgresql:`]);function Ge(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(!We.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 Ke=new Set([`localhost`,`127.0.0.1`,`[::1]`,`::1`,`0.0.0.0`]);async function qe(e,t){let n;try{let t=new URL(e);if(!Ke.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 Je=[`utf8`,`utf8mb4`,`latin1`,`ascii`,`euckr`,`sjis`,`big5`],Ye={enabled:!1,host:``,port:22,user:``,auth:`key`};function X({label:e,htmlFor:t,children:n}){return(0,W.jsxs)(`div`,{className:`grid grid-cols-[120px_minmax(0,1fr)] items-center gap-2`,children:[(0,W.jsx)(me,{htmlFor:t,children:e}),n]})}function Xe({value:e,onChange:t}){let{t:n}=a();function r(n,r){t({...e,[n]:r})}let[i,o]=(0,U.useState)([]),s=e.dbms===`d1`?e.devUrl??``:``;(0,U.useEffect)(()=>{if(!s){o([]);return}let e=new AbortController,t=setTimeout(()=>{qe(s,e.signal).then(o)},300);return()=>{clearTimeout(t),e.abort()}},[s]);let c=e.dbms===`sqlite`,u=e.transport??`browser`,d=c&&u===`browser`,f=x.has(e.dbms),p=e.dbms===`d1`,y=e.dbms===`do`,ee=k.find(t=>t.id===e.dbms)?.capabilities,b=e.ssh??Ye,[C,w]=(0,U.useState)(``),T=C.trim()===``?`empty`:Ge(C)?`applied`:`invalid`,te=e.dbms===`supabase`&&e.port===6543;function ne(n){w(n);let r=Ge(n);r&&t({...e,host:r.host??e.host,port:r.port??k.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 E(n){t({...e,ssh:{...b,...n}})}async function D(e){e&&E({privateKey:await e.text(),privateKeyName:e.name})}return(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,W.jsx)(X,{label:n(`connection.form.hostName`),htmlFor:`conn-hostName`,children:(0,W.jsx)(L,{id:`conn-hostName`,placeholder:n(`connection.form.hostNamePlaceholder`),value:e.hostName,onChange:e=>r(`hostName`,e.target.value)})}),(0,W.jsx)(X,{label:n(`connection.form.dataSource`),children:(0,W.jsxs)(v,{value:e.dbms,onValueChange:n=>{let r=k.find(e=>e.id===n);if(!r)return;let i=r.id,a=x.has(i)||i===`d1`||i===`do`;w(``),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||y?z(i):e.user,devUrl:i===`do`?e.devUrl||`http://localhost:8787`:e.devUrl,database:e.database&&!a&&!f&&!p&&!y?e.database:R(i)??e.database})},children:[(0,W.jsx)(h,{id:`conn-dbms`,className:`w-full`,children:(0,W.jsx)(m,{})}),(0,W.jsx)(g,{children:k.map(e=>(0,W.jsx)(_,{value:e.id,children:(0,W.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(B,{dbms:e.id}),e.label]})},e.id))})]})}),f&&(0,W.jsx)(X,{label:n(`connection.form.connectionString`),htmlFor:`conn-uri`,children:(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(L,{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:C,onChange:e=>ne(e.target.value)}),(0,W.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed ${T===`invalid`?`text-destructive`:`text-muted-foreground`}`,children:n(T===`invalid`?`connection.form.connectionStringInvalid`:T===`applied`?`connection.form.connectionStringApplied`:e.dbms===`neon`?`connection.form.neonHint`:`connection.form.supabaseHint`)})]})}),c&&(0,W.jsxs)(X,{label:n(`connection.form.openVia`),children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,W.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm cursor-pointer`,children:[(0,W.jsx)(`input`,{type:`radio`,name:`transport`,value:`browser`,checked:u===`browser`,onChange:()=>r(`transport`,`browser`),className:`accent-primary`}),n(`connection.form.viaBrowser`)]}),(0,W.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm cursor-pointer`,children:[(0,W.jsx)(`input`,{type:`radio`,name:`transport`,value:`tunnel`,checked:u===`tunnel`,onChange:()=>r(`transport`,`tunnel`),className:`accent-primary`}),n(`connection.form.viaAgent`)]})]}),(0,W.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,W.jsx)(X,{label:n(`connection.form.databaseFile`),children:(0,W.jsxs)(`div`,{className:`min-w-0 text-xs text-muted-foreground leading-relaxed`,children:[e.file?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,W.jsx)(`span`,{className:`min-w-0 break-all text-foreground`,title:e.file,children:e.file}),(0,W.jsx)(l,{type:`button`,variant:`outline`,size:`sm`,className:`h-6 shrink-0 px-2 text-xs`,onClick:()=>{O(e.id),r(`file`,``)},children:n(`connection.form.changeFile`)})]}):(0,W.jsx)(`p`,{children:n(`connection.form.filePickerHint`)}),(0,W.jsx)(`p`,{className:`mt-1`,children:n(`connection.form.fileRememberedHint`)})]})}):null,!d&&(0,W.jsx)(X,{label:n(`connection.form.authToken`),htmlFor:`conn-authToken`,children:(0,W.jsx)(L,{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:y?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(X,{label:n(`connection.form.doDevUrl`),htmlFor:`conn-do-url`,children:(0,W.jsx)(L,{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,W.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.doHint`)}),(0,W.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.doLimitsHint`)})]}):p?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(X,{label:n(`connection.form.d1DevUrl`),htmlFor:`conn-d1-dev`,children:(0,W.jsx)(L,{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,W.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1DevUrlHint`)}),(0,W.jsx)(X,{label:n(`connection.form.d1AccountId`),htmlFor:`conn-d1-account`,children:(0,W.jsx)(L,{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,W.jsx)(X,{label:n(`connection.form.d1DatabaseId`),htmlFor:`conn-d1-database`,children:i.length>0?(0,W.jsxs)(v,{value:e.databaseId??``,onValueChange:e=>r(`databaseId`,e),children:[(0,W.jsx)(h,{id:`conn-d1-database`,children:(0,W.jsx)(m,{placeholder:n(`connection.form.d1PickDatabase`)})}),(0,W.jsx)(g,{children:i.map(e=>(0,W.jsxs)(_,{value:e.id,children:[e.name,` · `,e.id]},e.id))})]}):(0,W.jsx)(L,{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,W.jsx)(X,{label:n(`connection.form.d1ApiToken`),htmlFor:`conn-pass`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(L,{id:`conn-pass`,type:`password`,autoComplete:`new-password`,value:e.pass,onChange:e=>r(`pass`,e.target.value.trim())}),(0,W.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs whitespace-nowrap cursor-pointer`,title:n(`connection.form.savePasswordHint`),children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:e.savePassword??!0,onChange:e=>r(`savePassword`,e.target.checked)}),n(`connection.form.savePassword`)]})]})}),(0,W.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1Hint`)}),(0,W.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1LimitsHint`)})]}):c?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(X,{label:n(`connection.form.databaseFile`),htmlFor:`conn-file`,children:(0,W.jsx)(L,{id:`conn-file`,placeholder:n(`connection.form.filePathPlaceholder`),value:e.file??``,onChange:e=>r(`file`,e.target.value)})}),(0,W.jsx)(X,{label:n(`connection.form.createIfMissing`),htmlFor:`conn-create`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.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,W.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.createIfMissingHint`)})]})})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(X,{label:n(`connection.form.host`),htmlFor:`conn-host`,children:(0,W.jsx)(L,{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,W.jsx)(X,{label:n(`connection.form.port`),htmlFor:`conn-port`,children:(0,W.jsx)(L,{id:`conn-port`,type:`number`,value:e.port,onChange:t=>r(`port`,Number(t.target.value)||k.find(t=>t.id===e.dbms)?.defaultPort||3306)})}),te&&(0,W.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`)}),(S(e.dbms)||e.dbms===`mssql`||e.dbms===`oracle`)&&(0,W.jsx)(X,{label:e.dbms===`oracle`?n(`connection.form.serviceName`):n(`connection.form.database`),htmlFor:`conn-database`,children:(0,W.jsx)(L,{id:`conn-database`,placeholder:R(e.dbms),value:e.database??``,onChange:e=>r(`database`,e.target.value.trim())})}),(0,W.jsx)(X,{label:n(`connection.form.user`),htmlFor:`conn-user`,children:(0,W.jsx)(L,{id:`conn-user`,autoComplete:`off`,placeholder:z(e.dbms),value:e.user,onChange:e=>r(`user`,e.target.value)})}),(0,W.jsx)(X,{label:n(`connection.form.password`),htmlFor:`conn-pass`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(L,{id:`conn-pass`,type:`password`,autoComplete:`new-password`,value:e.pass,onChange:e=>r(`pass`,e.target.value)}),(0,W.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs whitespace-nowrap cursor-pointer`,title:n(`connection.form.savePasswordHint`),children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:e.savePassword??!0,onChange:e=>r(`savePassword`,e.target.checked)}),n(`connection.form.savePassword`)]})]})}),f&&(0,W.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.managedTlsHint`)}),!f&&e.dbms!==`oracle`&&(0,W.jsx)(X,{label:n(`connection.form.tls`),children:(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,W.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[(0,W.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,W.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer ${e.ssl?``:`opacity-50`}`,title:n(`connection.form.tlsVerifyHint`),children:[(0,W.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&&(0,W.jsx)(X,{label:n(`connection.form.charset`),children:(0,W.jsxs)(v,{value:e.charset,onValueChange:e=>r(`charset`,e),children:[(0,W.jsx)(h,{className:`w-full`,children:(0,W.jsx)(m,{})}),(0,W.jsx)(g,{children:Je.map(e=>(0,W.jsx)(_,{value:e,children:e},e))})]})})]}),!c&&!f&&!p&&!y&&(0,W.jsxs)(W.Fragment,{children:[(0,W.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,W.jsx)(H,{className:`ml-2`})]}),(0,W.jsx)(X,{label:n(`connection.form.sshTunnel`),htmlFor:`conn-ssh`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{id:`conn-ssh`,type:`checkbox`,checked:b.enabled,onChange:e=>{(!e.target.checked||ce(`ssh_tunnel`))&&E({enabled:e.target.checked})},className:`size-4 accent-primary cursor-pointer`}),(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.sshTunnelHint`)})]})}),b.enabled&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(X,{label:n(`connection.form.sshHost`),htmlFor:`conn-ssh-host`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(L,{id:`conn-ssh-host`,placeholder:n(`connection.form.sshHostPlaceholder`),value:b.host,onChange:e=>E({host:e.target.value.trim()})}),(0,W.jsx)(L,{"aria-label":n(`connection.form.sshPort`),type:`number`,className:`w-24 shrink-0`,value:b.port,onChange:e=>E({port:Number(e.target.value)||22})})]})}),(0,W.jsx)(X,{label:n(`connection.form.sshUser`),htmlFor:`conn-ssh-user`,children:(0,W.jsx)(L,{id:`conn-ssh-user`,placeholder:n(`connection.form.sshUserPlaceholder`),value:b.user,onChange:e=>E({user:e.target.value.trim()})})}),(0,W.jsx)(X,{label:n(`connection.form.sshAuth`),children:(0,W.jsxs)(v,{value:b.auth,onValueChange:e=>E({auth:e}),children:[(0,W.jsx)(h,{className:`w-full`,children:(0,W.jsx)(m,{})}),(0,W.jsxs)(g,{children:[(0,W.jsx)(_,{value:`key`,children:n(`connection.form.sshAuthKey`)}),(0,W.jsx)(_,{value:`password`,children:n(`connection.form.sshAuthPassword`)}),(0,W.jsx)(_,{value:`agent`,children:n(`connection.form.sshAuthAgent`)})]})]})}),b.auth===`password`&&(0,W.jsx)(X,{label:n(`connection.form.sshPassword`),htmlFor:`conn-ssh-pass`,children:(0,W.jsx)(L,{id:`conn-ssh-pass`,type:`password`,autoComplete:`new-password`,value:b.password??``,onChange:e=>E({password:e.target.value})})}),b.auth===`key`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(X,{label:n(`connection.form.sshKey`),htmlFor:`conn-ssh-key`,children:(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(`input`,{id:`conn-ssh-key`,type:`file`,className:`hidden`,onChange:e=>{D(e.target.files?.[0]),e.target.value=``}}),(0,W.jsx)(l,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 shrink-0 px-2 text-xs`,onClick:()=>document.getElementById(`conn-ssh-key`)?.click(),children:b.privateKey?n(`connection.form.changeFile`):n(`connection.form.sshKeyPick`)}),(0,W.jsx)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,title:b.privateKeyName,children:b.privateKey?b.privateKeyName||n(`connection.form.sshKeyLoaded`):n(`connection.form.sshKeyHint`)})]})}),(0,W.jsx)(X,{label:n(`connection.form.sshPassphrase`),htmlFor:`conn-ssh-passphrase`,children:(0,W.jsx)(L,{id:`conn-ssh-passphrase`,type:`password`,autoComplete:`new-password`,placeholder:n(`connection.form.sshPassphrasePlaceholder`),value:b.passphrase??``,onChange:e=>E({passphrase:e.target.value})})})]}),b.auth===`agent`&&(0,W.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshAuthAgentHint`)}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshTargetHint`)}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshSecretsHint`)})]})]}),(0,W.jsx)(X,{label:n(`connection.form.autoConnection`),htmlFor:`conn-auto`,children:(0,W.jsx)(`div`,{className:`flex items-center`,children:(0,W.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,W.jsx)(`div`,{className:`mt-1 border-t pt-3 text-xs font-medium text-muted-foreground`,children:n(`connection.form.safety`)}),(0,W.jsx)(X,{label:n(`connection.form.environment`),children:(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[A.map(t=>{let n=(e.environmentColor??`none`)===t.id;return(0,W.jsx)(`button`,{type:`button`,title:I(t.id),"aria-label":I(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,W.jsx)(`span`,{className:`ml-1 text-xs text-muted-foreground`,children:n(`connection.form.environmentHint`)})]})}),(0,W.jsx)(X,{label:n(`connection.form.readOnly`),htmlFor:`conn-readonly`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.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,W.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.readOnlyHint`)})]})}),ee?.transactions!==!1&&(0,W.jsx)(X,{label:n(`connection.form.transactions`),children:(0,W.jsxs)(v,{value:e.transactionMode??`auto`,onValueChange:e=>r(`transactionMode`,e),children:[(0,W.jsx)(h,{className:`w-full`,children:(0,W.jsx)(m,{})}),(0,W.jsxs)(g,{children:[(0,W.jsx)(_,{value:`auto`,children:n(`connection.form.txAuto`)}),(0,W.jsx)(_,{value:`manual`,children:n(`connection.form.txManual`)})]})]})})]})}var Ze=[`id`,`serverConnectionId`,`sample`,`scratchpad`,`autoConnection`];function Qe(e){return!e.sample&&!e.scratchpad}function $e(e,t,n=new Date){let r=t?e:y(e),i={...r};for(let e of Ze)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 et(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 Z=(e,t=``)=>typeof e==`string`?e:t,Q=e=>typeof e==`boolean`?e:void 0,tt=(e,t)=>typeof e==`number`&&Number.isFinite(e)?e:t,$=e=>e===void 0||e===``?void 0:e;function nt(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:Z(t.host),port:tt(t.port,22),user:Z(t.user),auth:n,password:$(Z(t.password)),privateKey:$(Z(t.privateKey)),privateKeyName:$(Z(t.privateKeyName)),passphrase:$(Z(t.passphrase))}}function rt(e,t,n=crypto.randomUUID()){let r=e.connection,i=Q(r.savePassword),a={id:n,hostName:it(Z(r.hostName),t),host:Z(r.host),user:Z(r.user),pass:Z(r.pass),charset:Z(r.charset,`utf8`),port:tt(r.port,0),dbms:r.dbms,database:$(Z(r.database)),transport:r.transport===`tunnel`||r.transport===`browser`?r.transport:void 0,file:$(Z(r.file)),createIfMissing:Q(r.createIfMissing),ssl:Q(r.ssl),sslVerify:Q(r.sslVerify),accountId:$(Z(r.accountId)),databaseId:$(Z(r.databaseId)),devUrl:$(Z(r.devUrl)),ssh:nt(r.ssh),gatewayProfile:$(Z(r.gatewayProfile)),autoConnection:!1,savePassword:i??!0,authToken:Z(r.authToken),readOnly:Q(r.readOnly),environmentColor:$(Z(r.environmentColor)),transactionMode:$(Z(r.transactionMode))};for(let e of Object.keys(a))a[e]===void 0&&delete a[e];return a}function it(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 at(e,t,n=`application/json`){let r=Oe(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 ot(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 st({...e}){return(0,W.jsx)(ze,{"data-slot":`dropdown-menu`,...e})}function ct({...e}){return(0,W.jsx)(Be,{"data-slot":`dropdown-menu-trigger`,...e})}function lt({className:e,sideOffset:t=4,...n}){return(0,W.jsx)(Ve,{children:(0,W.jsx)(He,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:o(`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 ut({className:e,inset:t,variant:n=`default`,...r}){return(0,W.jsx)(Ue,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:o(`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 dt(){let{t:e}=a(),{activeDialog:t,closeDialog:i,showMessage:o}=n(),[s,c]=(0,U.useState)(!1),{savedConnections:u,addSavedConnection:d,updateSavedConnection:f,deleteSavedConnection:p,openConnection:m}=b(),h=r(`connect`)?.profileId,[g,_]=(0,U.useState)(()=>h??null),[v,y]=(0,U.useState)(()=>{let e=h?u.find(e=>e.id===h):void 0;return e?{...e}:null}),x=t===`connect`,[S,O]=(0,U.useState)(null),[k,A]=(0,U.useState)(null),se=be(e=>e.url),ce=be(e=>e.token);(0,U.useEffect)(()=>{if(!x)return;let e=!1;return(async()=>{try{let t=await w();if(e||t.state!==`online`||!t.gateway){e||O(null);return}let n=await T();e||(O({name:n.gateway,profiles:n.profiles}),A(null))}catch(t){e||A(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[x,se,ce]);function M(t){let r=u.find(e=>e.gatewayProfile===t.name);if(r){P(r);return}let i=ye(t);d(i),P(i),n.getState().setFooterMessage(e(`connection.dialog.gatewayAdded`,{name:t.name}))}function N(e){e||(i(),_(null),y(null))}function P(e){_(e.id),y({...e})}function de(e){y(e),f(e.id,e)}function me(){let e=fe();d(e),_(e.id),y(e)}function I(){g&&(p(g),_(null),y(null))}async function L(t){let r=u.find(e=>e.id===g);if(!r||!Qe(r))return;let i=r.hostName||e(`connection.dialog.unnamed`),a=$e(b.getState().resolveCredentials(r),t);await at(`planche-connection-${i}.json`,JSON.stringify(a,null,2))&&n.getState().setFooterMessage(e(`connection.dialog.exported`,{name:i}))}async function R(){let t=await ot();if(t!==null)try{let r=rt(et(t),b.getState().savedConnections);d(r),_(r.id),y(r),n.getState().setFooterMessage(e(`connection.dialog.imported`,{name:r.hostName||e(`connection.dialog.unnamed`)}))}catch(t){o({tone:`error`,title:e(`connection.dialog.importFailedTitle`),description:t instanceof Error?t.message:String(t)})}}let ve=g!==null&&u.some(e=>e.id===g&&Qe(e)),[z,H]=(0,U.useState)(!1),Oe=ne(e=>e.addQueryTab);function G(t){let n=b.getState().activeConnections.some(e=>e.id===t.id);if(m(t),E.getState().removeTree(t.id),ee(t.id),n){i(),_(null),y(null);return}Oe(t.id,{id:`tab-${Date.now()}`,title:e(`connection.dialog.firstQueryTab`),query:``,database:``,isExecuting:!1,results:[],error:null,executionTime:null}),i(),_(null),y(null)}async function K(t){let r=await ae(t.id,{interactive:!0});if(!r)return;let i={...t,file:r.fileName,serverConnectionId:r.connectionId};f(t.id,{file:r.fileName}),G(i),b.getState().setFileDetached(t.id,r.fileDetached),r.restoredUnsaved?n.getState().setFooterMessage(e(r.diskChanged?`connection.dialog.restoredUnsavedDiskChanged`:`connection.dialog.restoredUnsaved`,{file:r.fileName})):r.wal&&!r.walApplied?n.getState().setFooterMessage(e(`connection.dialog.walPending`,{file:r.fileName})):r.walApplied&&n.getState().setFooterMessage(e(`connection.dialog.walApplied`,{file:r.fileName}))}async function q(t,r){try{return await r(t)}catch(i){let a=te(i);if(!a||!(`ssh`in t)||!t.ssh||!await n.getState().requestDestructiveConfirm({title:e(`connection.dialog.hostKeyTitle`),description:e(`connection.dialog.hostKeyDescription`,a),confirmLabel:e(`connection.dialog.hostKeyAccept`)}))throw i;return r({...t,ssh:{...t.ssh,acceptHostKey:a.fingerprint}})}}async function J(){if(v){H(!0);try{if(D(v)===`browser`){await K(v);return}let t=await q(C(v),e=>ie(e,v.authToken||void 0));t.success?G({...v,serverConnectionId:t.connectionId}):o({tone:`error`,title:e(`connection.dialog.connectFailedTitle`),description:t.message??e(`connection.dialog.unknownError`)})}catch(t){o({tone:`error`,title:e(`connection.dialog.connectFailedTitle`),description:t instanceof Error?t.message:String(t)})}finally{H(!1)}}}async function ke(){if(v){if(D(v)===`browser`){o({tone:`info`,title:e(`connection.dialog.testConnection`),description:e(`connection.dialog.browserTestHint`)});return}c(!0);try{let t=await q(C(v),e=>re(e,v.authToken||void 0));t.success?o({tone:`success`,title:e(`connection.dialog.testSuccess`),description:e(`connection.dialog.testSuccessDescription`)}):o({tone:`error`,title:e(`connection.dialog.testFailedTitle`),description:t.message??e(`connection.dialog.unknownError`)})}catch(t){o({tone:`error`,title:e(`connection.dialog.testFailedTitle`),description:t instanceof Error?t.message:String(t)})}finally{c(!1)}}}return(0,W.jsx)(De,{open:x,onOpenChange:N,children:(0,W.jsxs)(Te,{className:`sm:max-w-[1100px] h-[85vh] max-h-[85vh] flex flex-col`,children:[(0,W.jsx)(Ce,{children:(0,W.jsx)(Ee,{children:e(`connection.dialog.title`)})}),(0,W.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,W.jsx)(pe,{className:`mt-0.5 size-4 shrink-0 text-catppuccin-green`,"aria-hidden":!0}),(0,W.jsx)(`span`,{children:e(`connection.dialog.privacy`)})]}),(0,W.jsxs)(`div`,{className:`flex flex-1 gap-4 overflow-hidden min-h-0`,children:[(0,W.jsxs)(`div`,{className:`w-[460px] shrink-0 border rounded-md overflow-hidden flex flex-col`,children:[(S||k)&&(0,W.jsxs)(`div`,{className:`border-b p-2 text-xs space-y-1 max-h-40 overflow-auto`,children:[(0,W.jsxs)(`p`,{className:`font-medium`,children:[e(`connection.dialog.gatewayTitle`),S?` — ${S.name}`:``]}),k&&(0,W.jsx)(`p`,{className:`text-destructive`,children:e(`connection.dialog.gatewayLoadFailed`,{error:k})}),S?.profiles.map(t=>(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5 truncate`,children:[(0,W.jsx)(B,{dbms:_e[t.driver],className:`size-3.5`}),(0,W.jsx)(`span`,{className:`truncate`,children:t.name}),(0,W.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,t.readOnly?e(`connection.dialog.gatewayReadOnly`):e(`connection.dialog.gatewayWritable`),`)`]})]}),(0,W.jsx)(l,{size:`sm`,variant:`outline`,className:`h-6 px-2 text-xs`,onClick:()=>M(t),children:e(`connection.dialog.gatewayAdd`)})]},t.name))]}),(0,W.jsx)(ge,{className:`h-full`,children:(0,W.jsxs)(xe,{className:`table-fixed`,children:[(0,W.jsx)(ue,{children:(0,W.jsxs)(j,{children:[(0,W.jsx)(V,{className:`w-[32%]`,children:e(`connection.dialog.colHostName`)}),(0,W.jsx)(V,{className:`w-[40%]`,children:e(`connection.dialog.colTarget`)}),(0,W.jsx)(V,{className:`w-[28%]`,children:e(`connection.dialog.colDbms`)})]})}),(0,W.jsx)(Se,{children:u.length===0?(0,W.jsx)(j,{children:(0,W.jsx)(F,{colSpan:3,className:`text-center text-muted-foreground`,children:e(`connection.dialog.noSaved`)})}):u.map(t=>(0,W.jsxs)(j,{"data-state":g===t.id?`selected`:void 0,className:`cursor-pointer`,onClick:()=>P(t),onDoubleClick:()=>{P(t),J()},children:[(0,W.jsx)(F,{className:`truncate font-medium`,title:t.hostName,children:t.hostName||e(`connection.dialog.unnamed`)}),(0,W.jsx)(F,{className:`truncate`,title:t.dbms===`sqlite`?t.file:t.dbms===`d1`?t.databaseId:t.dbms===`do`?t.devUrl:`${t.user}@${t.host}:${t.port}`,children:t.dbms===`sqlite`?t.file||(D(t)===`browser`?e(`connection.dialog.pickOnConnect`):e(`connection.dialog.noFile`)):t.dbms===`d1`?t.databaseId||`—`:t.dbms===`do`?t.devUrl||`—`:`${t.user}@${t.host}:${t.port}`}),(0,W.jsx)(F,{className:`truncate`,title:oe(t.dbms).label,children:(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(B,{dbms:t.dbms,className:`size-3.5`}),(0,W.jsx)(`span`,{className:`truncate`,children:oe(t.dbms).label})]})})]},t.id))})]})})]}),(0,W.jsx)(`div`,{className:`flex-1 border rounded-md overflow-auto`,children:v?(0,W.jsxs)(W.Fragment,{children:[D(v)!==`browser`&&(0,W.jsx)(`div`,{className:`p-4 pb-0`,children:(0,W.jsx)(he,{})}),v.gatewayProfile?(0,W.jsxs)(`div`,{className:`p-4 space-y-2 text-sm`,children:[(0,W.jsxs)(`p`,{className:`font-medium flex items-center gap-2`,children:[(0,W.jsx)(B,{dbms:v.dbms,className:`size-4`}),v.hostName]}),(0,W.jsx)(`p`,{className:`text-muted-foreground`,children:e(`connection.dialog.gatewayProfileHint`,{name:v.gatewayProfile})}),(0,W.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[v.readOnly?e(`connection.dialog.gatewayReadOnly`):e(`connection.dialog.gatewayWritable`),v.database?` · ${v.database}`:``]})]}):(0,W.jsx)(Xe,{value:v,onChange:de})]}):(0,W.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:e(`connection.dialog.selectPrompt`)})})]}),(0,W.jsxs)(we,{className:`sm:justify-between`,children:[(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(l,{variant:`outline`,onClick:me,children:e(`connection.dialog.addNew`)}),(0,W.jsx)(l,{variant:`destructive`,onClick:I,disabled:!g,children:e(`connection.dialog.delete`)}),(0,W.jsxs)(st,{children:[(0,W.jsx)(ct,{asChild:!0,children:(0,W.jsxs)(l,{variant:`outline`,disabled:!ve,children:[e(`connection.dialog.export`),(0,W.jsx)(le,{className:`ml-1 size-3.5`,"aria-hidden":!0})]})}),(0,W.jsxs)(lt,{align:`start`,children:[(0,W.jsx)(ut,{onSelect:()=>void L(!1),children:e(`connection.dialog.exportWithoutSecrets`)}),(0,W.jsx)(ut,{onSelect:()=>void L(!0),children:e(`connection.dialog.exportWithSecrets`)})]})]}),(0,W.jsx)(l,{variant:`outline`,onClick:()=>void R(),children:e(`connection.dialog.import`)})]}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(l,{variant:`outline`,onClick:ke,disabled:!v||s,children:e(`connection.dialog.testConnection`)}),(0,W.jsx)(l,{onClick:J,disabled:!v||z,children:e(`connection.dialog.connect`)}),(0,W.jsx)(l,{variant:`outline`,onClick:()=>N(!1),children:e(`connection.dialog.close`)})]})]})]})})}export{dt as ConnectDialog};
|
|
1
|
+
import{r as e}from"./hePW80VL.js";import{h as t,n,t as r}from"./XzPc-eVf.js";import{l as i,m as a,o,p as s,s as c,t as l}from"./CKOS5Y-e.js";import{S as u,_ as d,x as f,y as p}from"./CZQ1r4zz.js";import{a as m,i as h,n as g,r as _,t as v}from"./Bz1cma8F.js";import{T as y,f as ee,t as b}from"./B3nhMsGp.js";import{E as x,O as S,T as C,a as w,f as T,m as te}from"./Ca4g4XbM.js";import{n as ne}from"./BNkgLUl5.js";import{S as E,d as D,g as re,i as ie,l as O,r as ae}from"./CtXRSNHU.js";import{n as oe,t as k}from"./BfSKVZnY.js";import{A,C as j,Gt as se,I as ce,Jt as M,Kt as N,Lt as le,S as ue,Ut as P,Wt as de,a as fe,b as F,bt as pe,c as me,i as he,j as I,l as L,lt as ge,n as _e,o as R,qt as ve,r as ye,rt as be,s as z,u as B,v as xe,x as V,y as Se,z as H}from"./B_UAjgBr.js";import{a as Ce,i as we,n as Te,o as Ee,t as De}from"./DxuXBECK.js";import{t as Oe}from"./CnYBZPf9.js";var U=e(t(),1),W=i(),G=Object.defineProperty,K=(e,t)=>G(e,`name`,{value:t,configurable:!0}),q=`DropdownMenu`,[J,ke]=u(q,[M]),Y=M(),[Ae,je]=J(q),Me=K(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=Y(t),l=U.useRef(null),[u,f]=p({prop:i,defaultProp:a??!1,onChange:o,caller:q});return(0,W.jsx)(Ae,{scope:t,triggerId:d(),triggerRef:l,contentId:d(),open:u,onOpenChange:f,onOpenToggle:U.useCallback(()=>f(e=>!e),[f]),modal:s,children:(0,W.jsx)(ve,{...c,open:u,onOpenChange:f,dir:r,modal:s,children:n})})},`DropdownMenu`),Ne=`DropdownMenuTrigger`,Pe=U.forwardRef(K(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=je(Ne,n),o=Y(n),l=s(t,a.triggerRef);return(0,W.jsx)(P,{asChild:!0,...o,children:(0,W.jsx)(c.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:l,onPointerDown:f(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:f(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),Fe=K(e=>{let{__scopeDropdownMenu:t,...n}=e,r=Y(t);return(0,W.jsx)(N,{...r,...n})},`DropdownMenuPortal`),Ie=`DropdownMenuContent`,Le=U.forwardRef(K(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=je(Ie,n),a=Y(n),o=U.useRef(!1);return(0,W.jsx)(de,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:f(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:f(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`)),Re=U.forwardRef(K(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Y(n);return(0,W.jsx)(se,{...i,...r,ref:t})},`DropdownMenuItem`)),ze=Me,Be=Pe,Ve=Fe,He=Le,Ue=Re,We=new Set([`postgres:`,`postgresql:`]);function Ge(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(!We.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 Ke=new Set([`localhost`,`127.0.0.1`,`[::1]`,`::1`,`0.0.0.0`]);async function qe(e,t){let n;try{let t=new URL(e);if(!Ke.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 Je=[`utf8`,`utf8mb4`,`latin1`,`ascii`,`euckr`,`sjis`,`big5`],Ye={enabled:!1,host:``,port:22,user:``,auth:`key`};function X({label:e,htmlFor:t,children:n}){return(0,W.jsxs)(`div`,{className:`grid grid-cols-[120px_minmax(0,1fr)] items-center gap-2`,children:[(0,W.jsx)(me,{htmlFor:t,children:e}),n]})}function Xe({value:e,onChange:t}){let{t:n}=a();function r(n,r){t({...e,[n]:r})}let[i,o]=(0,U.useState)([]),s=e.dbms===`d1`?e.devUrl??``:``;(0,U.useEffect)(()=>{if(!s){o([]);return}let e=new AbortController,t=setTimeout(()=>{qe(s,e.signal).then(o)},300);return()=>{clearTimeout(t),e.abort()}},[s]);let c=e.dbms===`sqlite`,u=e.transport??`browser`,d=c&&u===`browser`,f=x.has(e.dbms),p=e.dbms===`d1`,y=e.dbms===`do`,ee=k.find(t=>t.id===e.dbms)?.capabilities,b=e.ssh??Ye,[C,w]=(0,U.useState)(``),T=C.trim()===``?`empty`:Ge(C)?`applied`:`invalid`,te=e.dbms===`supabase`&&e.port===6543;function ne(n){w(n);let r=Ge(n);r&&t({...e,host:r.host??e.host,port:r.port??k.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 E(n){t({...e,ssh:{...b,...n}})}async function D(e){e&&E({privateKey:await e.text(),privateKeyName:e.name})}return(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,W.jsx)(X,{label:n(`connection.form.hostName`),htmlFor:`conn-hostName`,children:(0,W.jsx)(L,{id:`conn-hostName`,placeholder:n(`connection.form.hostNamePlaceholder`),value:e.hostName,onChange:e=>r(`hostName`,e.target.value)})}),(0,W.jsx)(X,{label:n(`connection.form.dataSource`),children:(0,W.jsxs)(v,{value:e.dbms,onValueChange:n=>{let r=k.find(e=>e.id===n);if(!r)return;let i=r.id,a=x.has(i)||i===`d1`||i===`do`;w(``),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||y?z(i):e.user,devUrl:i===`do`?e.devUrl||`http://localhost:8787`:e.devUrl,database:e.database&&!a&&!f&&!p&&!y?e.database:R(i)??e.database})},children:[(0,W.jsx)(h,{id:`conn-dbms`,className:`w-full`,children:(0,W.jsx)(m,{})}),(0,W.jsx)(g,{children:k.map(e=>(0,W.jsx)(_,{value:e.id,children:(0,W.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(B,{dbms:e.id}),e.label]})},e.id))})]})}),f&&(0,W.jsx)(X,{label:n(`connection.form.connectionString`),htmlFor:`conn-uri`,children:(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(L,{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:C,onChange:e=>ne(e.target.value)}),(0,W.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed ${T===`invalid`?`text-destructive`:`text-muted-foreground`}`,children:n(T===`invalid`?`connection.form.connectionStringInvalid`:T===`applied`?`connection.form.connectionStringApplied`:e.dbms===`neon`?`connection.form.neonHint`:`connection.form.supabaseHint`)})]})}),c&&(0,W.jsxs)(X,{label:n(`connection.form.openVia`),children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,W.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm cursor-pointer`,children:[(0,W.jsx)(`input`,{type:`radio`,name:`transport`,value:`browser`,checked:u===`browser`,onChange:()=>r(`transport`,`browser`),className:`accent-primary`}),n(`connection.form.viaBrowser`)]}),(0,W.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm cursor-pointer`,children:[(0,W.jsx)(`input`,{type:`radio`,name:`transport`,value:`tunnel`,checked:u===`tunnel`,onChange:()=>r(`transport`,`tunnel`),className:`accent-primary`}),n(`connection.form.viaAgent`)]})]}),(0,W.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,W.jsx)(X,{label:n(`connection.form.databaseFile`),children:(0,W.jsxs)(`div`,{className:`min-w-0 text-xs text-muted-foreground leading-relaxed`,children:[e.file?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,W.jsx)(`span`,{className:`min-w-0 break-all text-foreground`,title:e.file,children:e.file}),(0,W.jsx)(l,{type:`button`,variant:`outline`,size:`sm`,className:`h-6 shrink-0 px-2 text-xs`,onClick:()=>{O(e.id),r(`file`,``)},children:n(`connection.form.changeFile`)})]}):(0,W.jsx)(`p`,{children:n(`connection.form.filePickerHint`)}),(0,W.jsx)(`p`,{className:`mt-1`,children:n(`connection.form.fileRememberedHint`)})]})}):null,!d&&(0,W.jsx)(X,{label:n(`connection.form.authToken`),htmlFor:`conn-authToken`,children:(0,W.jsx)(L,{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:y?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(X,{label:n(`connection.form.doDevUrl`),htmlFor:`conn-do-url`,children:(0,W.jsx)(L,{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,W.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.doHint`)}),(0,W.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.doLimitsHint`)})]}):p?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(X,{label:n(`connection.form.d1DevUrl`),htmlFor:`conn-d1-dev`,children:(0,W.jsx)(L,{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,W.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1DevUrlHint`)}),(0,W.jsx)(X,{label:n(`connection.form.d1AccountId`),htmlFor:`conn-d1-account`,children:(0,W.jsx)(L,{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,W.jsx)(X,{label:n(`connection.form.d1DatabaseId`),htmlFor:`conn-d1-database`,children:i.length>0?(0,W.jsxs)(v,{value:e.databaseId??``,onValueChange:e=>r(`databaseId`,e),children:[(0,W.jsx)(h,{id:`conn-d1-database`,children:(0,W.jsx)(m,{placeholder:n(`connection.form.d1PickDatabase`)})}),(0,W.jsx)(g,{children:i.map(e=>(0,W.jsxs)(_,{value:e.id,children:[e.name,` · `,e.id]},e.id))})]}):(0,W.jsx)(L,{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,W.jsx)(X,{label:n(`connection.form.d1ApiToken`),htmlFor:`conn-pass`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(L,{id:`conn-pass`,type:`password`,autoComplete:`new-password`,value:e.pass,onChange:e=>r(`pass`,e.target.value.trim())}),(0,W.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs whitespace-nowrap cursor-pointer`,title:n(`connection.form.savePasswordHint`),children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:e.savePassword??!0,onChange:e=>r(`savePassword`,e.target.checked)}),n(`connection.form.savePassword`)]})]})}),(0,W.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1Hint`)}),(0,W.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1LimitsHint`)})]}):c?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(X,{label:n(`connection.form.databaseFile`),htmlFor:`conn-file`,children:(0,W.jsx)(L,{id:`conn-file`,placeholder:n(`connection.form.filePathPlaceholder`),value:e.file??``,onChange:e=>r(`file`,e.target.value)})}),(0,W.jsx)(X,{label:n(`connection.form.createIfMissing`),htmlFor:`conn-create`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.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,W.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.createIfMissingHint`)})]})})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(X,{label:n(`connection.form.host`),htmlFor:`conn-host`,children:(0,W.jsx)(L,{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,W.jsx)(X,{label:n(`connection.form.port`),htmlFor:`conn-port`,children:(0,W.jsx)(L,{id:`conn-port`,type:`number`,value:e.port,onChange:t=>r(`port`,Number(t.target.value)||k.find(t=>t.id===e.dbms)?.defaultPort||3306)})}),te&&(0,W.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`)}),(S(e.dbms)||e.dbms===`mssql`||e.dbms===`oracle`)&&(0,W.jsx)(X,{label:e.dbms===`oracle`?n(`connection.form.serviceName`):n(`connection.form.database`),htmlFor:`conn-database`,children:(0,W.jsx)(L,{id:`conn-database`,placeholder:R(e.dbms),value:e.database??``,onChange:e=>r(`database`,e.target.value.trim())})}),(0,W.jsx)(X,{label:n(`connection.form.user`),htmlFor:`conn-user`,children:(0,W.jsx)(L,{id:`conn-user`,autoComplete:`off`,placeholder:z(e.dbms),value:e.user,onChange:e=>r(`user`,e.target.value)})}),(0,W.jsx)(X,{label:n(`connection.form.password`),htmlFor:`conn-pass`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(L,{id:`conn-pass`,type:`password`,autoComplete:`new-password`,value:e.pass,onChange:e=>r(`pass`,e.target.value)}),(0,W.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs whitespace-nowrap cursor-pointer`,title:n(`connection.form.savePasswordHint`),children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:e.savePassword??!0,onChange:e=>r(`savePassword`,e.target.checked)}),n(`connection.form.savePassword`)]})]})}),f&&(0,W.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.managedTlsHint`)}),!f&&e.dbms!==`oracle`&&(0,W.jsx)(X,{label:n(`connection.form.tls`),children:(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,W.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[(0,W.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,W.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer ${e.ssl?``:`opacity-50`}`,title:n(`connection.form.tlsVerifyHint`),children:[(0,W.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&&(0,W.jsx)(X,{label:n(`connection.form.charset`),children:(0,W.jsxs)(v,{value:e.charset,onValueChange:e=>r(`charset`,e),children:[(0,W.jsx)(h,{className:`w-full`,children:(0,W.jsx)(m,{})}),(0,W.jsx)(g,{children:Je.map(e=>(0,W.jsx)(_,{value:e,children:e},e))})]})})]}),!c&&!f&&!p&&!y&&(0,W.jsxs)(W.Fragment,{children:[(0,W.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,W.jsx)(H,{className:`ml-2`})]}),(0,W.jsx)(X,{label:n(`connection.form.sshTunnel`),htmlFor:`conn-ssh`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{id:`conn-ssh`,type:`checkbox`,checked:b.enabled,onChange:e=>{(!e.target.checked||ce(`ssh_tunnel`))&&E({enabled:e.target.checked})},className:`size-4 accent-primary cursor-pointer`}),(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.sshTunnelHint`)})]})}),b.enabled&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(X,{label:n(`connection.form.sshHost`),htmlFor:`conn-ssh-host`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(L,{id:`conn-ssh-host`,placeholder:n(`connection.form.sshHostPlaceholder`),value:b.host,onChange:e=>E({host:e.target.value.trim()})}),(0,W.jsx)(L,{"aria-label":n(`connection.form.sshPort`),type:`number`,className:`w-24 shrink-0`,value:b.port,onChange:e=>E({port:Number(e.target.value)||22})})]})}),(0,W.jsx)(X,{label:n(`connection.form.sshUser`),htmlFor:`conn-ssh-user`,children:(0,W.jsx)(L,{id:`conn-ssh-user`,placeholder:n(`connection.form.sshUserPlaceholder`),value:b.user,onChange:e=>E({user:e.target.value.trim()})})}),(0,W.jsx)(X,{label:n(`connection.form.sshAuth`),children:(0,W.jsxs)(v,{value:b.auth,onValueChange:e=>E({auth:e}),children:[(0,W.jsx)(h,{className:`w-full`,children:(0,W.jsx)(m,{})}),(0,W.jsxs)(g,{children:[(0,W.jsx)(_,{value:`key`,children:n(`connection.form.sshAuthKey`)}),(0,W.jsx)(_,{value:`password`,children:n(`connection.form.sshAuthPassword`)}),(0,W.jsx)(_,{value:`agent`,children:n(`connection.form.sshAuthAgent`)})]})]})}),b.auth===`password`&&(0,W.jsx)(X,{label:n(`connection.form.sshPassword`),htmlFor:`conn-ssh-pass`,children:(0,W.jsx)(L,{id:`conn-ssh-pass`,type:`password`,autoComplete:`new-password`,value:b.password??``,onChange:e=>E({password:e.target.value})})}),b.auth===`key`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(X,{label:n(`connection.form.sshKey`),htmlFor:`conn-ssh-key`,children:(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(`input`,{id:`conn-ssh-key`,type:`file`,className:`hidden`,onChange:e=>{D(e.target.files?.[0]),e.target.value=``}}),(0,W.jsx)(l,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 shrink-0 px-2 text-xs`,onClick:()=>document.getElementById(`conn-ssh-key`)?.click(),children:b.privateKey?n(`connection.form.changeFile`):n(`connection.form.sshKeyPick`)}),(0,W.jsx)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,title:b.privateKeyName,children:b.privateKey?b.privateKeyName||n(`connection.form.sshKeyLoaded`):n(`connection.form.sshKeyHint`)})]})}),(0,W.jsx)(X,{label:n(`connection.form.sshPassphrase`),htmlFor:`conn-ssh-passphrase`,children:(0,W.jsx)(L,{id:`conn-ssh-passphrase`,type:`password`,autoComplete:`new-password`,placeholder:n(`connection.form.sshPassphrasePlaceholder`),value:b.passphrase??``,onChange:e=>E({passphrase:e.target.value})})})]}),b.auth===`agent`&&(0,W.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshAuthAgentHint`)}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshTargetHint`)}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshSecretsHint`)})]})]}),(0,W.jsx)(X,{label:n(`connection.form.autoConnection`),htmlFor:`conn-auto`,children:(0,W.jsx)(`div`,{className:`flex items-center`,children:(0,W.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,W.jsx)(`div`,{className:`mt-1 border-t pt-3 text-xs font-medium text-muted-foreground`,children:n(`connection.form.safety`)}),(0,W.jsx)(X,{label:n(`connection.form.environment`),children:(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[A.map(t=>{let n=(e.environmentColor??`none`)===t.id;return(0,W.jsx)(`button`,{type:`button`,title:I(t.id),"aria-label":I(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,W.jsx)(`span`,{className:`ml-1 text-xs text-muted-foreground`,children:n(`connection.form.environmentHint`)})]})}),(0,W.jsx)(X,{label:n(`connection.form.readOnly`),htmlFor:`conn-readonly`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.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,W.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.readOnlyHint`)})]})}),ee?.transactions!==!1&&(0,W.jsx)(X,{label:n(`connection.form.transactions`),children:(0,W.jsxs)(v,{value:e.transactionMode??`auto`,onValueChange:e=>r(`transactionMode`,e),children:[(0,W.jsx)(h,{className:`w-full`,children:(0,W.jsx)(m,{})}),(0,W.jsxs)(g,{children:[(0,W.jsx)(_,{value:`auto`,children:n(`connection.form.txAuto`)}),(0,W.jsx)(_,{value:`manual`,children:n(`connection.form.txManual`)})]})]})})]})}var Ze=[`id`,`serverConnectionId`,`sample`,`scratchpad`,`autoConnection`];function Qe(e){return!e.sample&&!e.scratchpad}function $e(e,t,n=new Date){let r=t?e:y(e),i={...r};for(let e of Ze)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 et(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 Z=(e,t=``)=>typeof e==`string`?e:t,Q=e=>typeof e==`boolean`?e:void 0,tt=(e,t)=>typeof e==`number`&&Number.isFinite(e)?e:t,$=e=>e===void 0||e===``?void 0:e;function nt(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:Z(t.host),port:tt(t.port,22),user:Z(t.user),auth:n,password:$(Z(t.password)),privateKey:$(Z(t.privateKey)),privateKeyName:$(Z(t.privateKeyName)),passphrase:$(Z(t.passphrase))}}function rt(e,t,n=crypto.randomUUID()){let r=e.connection,i=Q(r.savePassword),a={id:n,hostName:it(Z(r.hostName),t),host:Z(r.host),user:Z(r.user),pass:Z(r.pass),charset:Z(r.charset,`utf8`),port:tt(r.port,0),dbms:r.dbms,database:$(Z(r.database)),transport:r.transport===`tunnel`||r.transport===`browser`?r.transport:void 0,file:$(Z(r.file)),createIfMissing:Q(r.createIfMissing),ssl:Q(r.ssl),sslVerify:Q(r.sslVerify),accountId:$(Z(r.accountId)),databaseId:$(Z(r.databaseId)),devUrl:$(Z(r.devUrl)),ssh:nt(r.ssh),gatewayProfile:$(Z(r.gatewayProfile)),autoConnection:!1,savePassword:i??!0,authToken:Z(r.authToken),readOnly:Q(r.readOnly),environmentColor:$(Z(r.environmentColor)),transactionMode:$(Z(r.transactionMode))};for(let e of Object.keys(a))a[e]===void 0&&delete a[e];return a}function it(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 at(e,t,n=`application/json`){let r=Oe(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 ot(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 st({...e}){return(0,W.jsx)(ze,{"data-slot":`dropdown-menu`,...e})}function ct({...e}){return(0,W.jsx)(Be,{"data-slot":`dropdown-menu-trigger`,...e})}function lt({className:e,sideOffset:t=4,...n}){return(0,W.jsx)(Ve,{children:(0,W.jsx)(He,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:o(`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 ut({className:e,inset:t,variant:n=`default`,...r}){return(0,W.jsx)(Ue,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:o(`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 dt(){let{t:e}=a(),{activeDialog:t,closeDialog:i,showMessage:o}=n(),[s,c]=(0,U.useState)(!1),{savedConnections:u,addSavedConnection:d,updateSavedConnection:f,deleteSavedConnection:p,openConnection:m}=b(),h=r(`connect`)?.profileId,[g,_]=(0,U.useState)(()=>h??null),[v,y]=(0,U.useState)(()=>{let e=h?u.find(e=>e.id===h):void 0;return e?{...e}:null}),x=t===`connect`,[S,O]=(0,U.useState)(null),[k,A]=(0,U.useState)(null),se=be(e=>e.url),ce=be(e=>e.token);(0,U.useEffect)(()=>{if(!x)return;let e=!1;return(async()=>{try{let t=await w();if(e||t.state!==`online`||!t.gateway){e||O(null);return}let n=await T();e||(O({name:n.gateway,profiles:n.profiles}),A(null))}catch(t){e||A(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[x,se,ce]);function M(t){let r=u.find(e=>e.gatewayProfile===t.name);if(r){P(r);return}let i=ye(t);d(i),P(i),n.getState().setFooterMessage(e(`connection.dialog.gatewayAdded`,{name:t.name}))}function N(e){e||(i(),_(null),y(null))}function P(e){_(e.id),y({...e})}function de(e){y(e),f(e.id,e)}function me(){let e=fe();d(e),_(e.id),y(e)}function I(){g&&(p(g),_(null),y(null))}async function L(t){let r=u.find(e=>e.id===g);if(!r||!Qe(r))return;let i=r.hostName||e(`connection.dialog.unnamed`),a=$e(b.getState().resolveCredentials(r),t);await at(`planche-connection-${i}.json`,JSON.stringify(a,null,2))&&n.getState().setFooterMessage(e(`connection.dialog.exported`,{name:i}))}async function R(){let t=await ot();if(t!==null)try{let r=rt(et(t),b.getState().savedConnections);d(r),_(r.id),y(r),n.getState().setFooterMessage(e(`connection.dialog.imported`,{name:r.hostName||e(`connection.dialog.unnamed`)}))}catch(t){o({tone:`error`,title:e(`connection.dialog.importFailedTitle`),description:t instanceof Error?t.message:String(t)})}}let ve=g!==null&&u.some(e=>e.id===g&&Qe(e)),[z,H]=(0,U.useState)(!1),Oe=ne(e=>e.addQueryTab);function G(t){let n=b.getState().activeConnections.some(e=>e.id===t.id);if(m(t),E.getState().removeTree(t.id),ee(t.id),n){i(),_(null),y(null);return}Oe(t.id,{id:`tab-${Date.now()}`,title:e(`connection.dialog.firstQueryTab`),query:``,database:``,isExecuting:!1,results:[],error:null,executionTime:null}),i(),_(null),y(null)}async function K(t){let r=await ae(t.id,{interactive:!0});if(!r)return;let i={...t,file:r.fileName,serverConnectionId:r.connectionId};f(t.id,{file:r.fileName}),G(i),b.getState().setFileDetached(t.id,r.fileDetached),r.restoredUnsaved?n.getState().setFooterMessage(e(r.diskChanged?`connection.dialog.restoredUnsavedDiskChanged`:`connection.dialog.restoredUnsaved`,{file:r.fileName})):r.wal&&!r.walApplied?n.getState().setFooterMessage(e(`connection.dialog.walPending`,{file:r.fileName})):r.walApplied&&n.getState().setFooterMessage(e(`connection.dialog.walApplied`,{file:r.fileName}))}async function q(t,r){try{return await r(t)}catch(i){let a=te(i);if(!a||!(`ssh`in t)||!t.ssh||!await n.getState().requestDestructiveConfirm({title:e(`connection.dialog.hostKeyTitle`),description:e(`connection.dialog.hostKeyDescription`,a),confirmLabel:e(`connection.dialog.hostKeyAccept`)}))throw i;return r({...t,ssh:{...t.ssh,acceptHostKey:a.fingerprint}})}}async function J(){if(v){H(!0);try{if(D(v)===`browser`){await K(v);return}let t=await q(C(v),e=>ie(e,v.authToken||void 0));t.success?G({...v,serverConnectionId:t.connectionId}):o({tone:`error`,title:e(`connection.dialog.connectFailedTitle`),description:t.message??e(`connection.dialog.unknownError`)})}catch(t){o({tone:`error`,title:e(`connection.dialog.connectFailedTitle`),description:t instanceof Error?t.message:String(t)})}finally{H(!1)}}}async function ke(){if(v){if(D(v)===`browser`){o({tone:`info`,title:e(`connection.dialog.testConnection`),description:e(`connection.dialog.browserTestHint`)});return}c(!0);try{let t=await q(C(v),e=>re(e,v.authToken||void 0));t.success?o({tone:`success`,title:e(`connection.dialog.testSuccess`),description:e(`connection.dialog.testSuccessDescription`)}):o({tone:`error`,title:e(`connection.dialog.testFailedTitle`),description:t.message??e(`connection.dialog.unknownError`)})}catch(t){o({tone:`error`,title:e(`connection.dialog.testFailedTitle`),description:t instanceof Error?t.message:String(t)})}finally{c(!1)}}}return(0,W.jsx)(De,{open:x,onOpenChange:N,children:(0,W.jsxs)(Te,{className:`sm:max-w-[1100px] h-[85vh] max-h-[85vh] flex flex-col`,children:[(0,W.jsx)(Ce,{children:(0,W.jsx)(Ee,{children:e(`connection.dialog.title`)})}),(0,W.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,W.jsx)(pe,{className:`mt-0.5 size-4 shrink-0 text-catppuccin-green`,"aria-hidden":!0}),(0,W.jsx)(`span`,{children:e(`connection.dialog.privacy`)})]}),(0,W.jsxs)(`div`,{className:`flex flex-1 gap-4 overflow-hidden min-h-0`,children:[(0,W.jsxs)(`div`,{className:`w-[460px] shrink-0 border rounded-md overflow-hidden flex flex-col`,children:[(S||k)&&(0,W.jsxs)(`div`,{className:`border-b p-2 text-xs space-y-1 max-h-40 overflow-auto`,children:[(0,W.jsxs)(`p`,{className:`font-medium`,children:[e(`connection.dialog.gatewayTitle`),S?` — ${S.name}`:``]}),k&&(0,W.jsx)(`p`,{className:`text-destructive`,children:e(`connection.dialog.gatewayLoadFailed`,{error:k})}),S?.profiles.map(t=>(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5 truncate`,children:[(0,W.jsx)(B,{dbms:_e[t.driver],className:`size-3.5`}),(0,W.jsx)(`span`,{className:`truncate`,children:t.name}),(0,W.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,t.readOnly?e(`connection.dialog.gatewayReadOnly`):e(`connection.dialog.gatewayWritable`),`)`]})]}),(0,W.jsx)(l,{size:`sm`,variant:`outline`,className:`h-6 px-2 text-xs`,onClick:()=>M(t),children:e(`connection.dialog.gatewayAdd`)})]},t.name))]}),(0,W.jsx)(ge,{className:`h-full`,children:(0,W.jsxs)(xe,{className:`table-fixed`,children:[(0,W.jsx)(ue,{children:(0,W.jsxs)(j,{children:[(0,W.jsx)(V,{className:`w-[32%]`,children:e(`connection.dialog.colHostName`)}),(0,W.jsx)(V,{className:`w-[40%]`,children:e(`connection.dialog.colTarget`)}),(0,W.jsx)(V,{className:`w-[28%]`,children:e(`connection.dialog.colDbms`)})]})}),(0,W.jsx)(Se,{children:u.length===0?(0,W.jsx)(j,{children:(0,W.jsx)(F,{colSpan:3,className:`text-center text-muted-foreground`,children:e(`connection.dialog.noSaved`)})}):u.map(t=>(0,W.jsxs)(j,{"data-state":g===t.id?`selected`:void 0,className:`cursor-pointer`,onClick:()=>P(t),onDoubleClick:()=>{P(t),J()},children:[(0,W.jsx)(F,{className:`truncate font-medium`,title:t.hostName,children:t.hostName||e(`connection.dialog.unnamed`)}),(0,W.jsx)(F,{className:`truncate`,title:t.dbms===`sqlite`?t.file:t.dbms===`d1`?t.databaseId:t.dbms===`do`?t.devUrl:`${t.user}@${t.host}:${t.port}`,children:t.dbms===`sqlite`?t.file||(D(t)===`browser`?e(`connection.dialog.pickOnConnect`):e(`connection.dialog.noFile`)):t.dbms===`d1`?t.databaseId||`—`:t.dbms===`do`?t.devUrl||`—`:`${t.user}@${t.host}:${t.port}`}),(0,W.jsx)(F,{className:`truncate`,title:oe(t.dbms).label,children:(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(B,{dbms:t.dbms,className:`size-3.5`}),(0,W.jsx)(`span`,{className:`truncate`,children:oe(t.dbms).label})]})})]},t.id))})]})})]}),(0,W.jsx)(`div`,{className:`flex-1 border rounded-md overflow-auto`,children:v?(0,W.jsxs)(W.Fragment,{children:[D(v)!==`browser`&&(0,W.jsx)(`div`,{className:`p-4 pb-0`,children:(0,W.jsx)(he,{})}),v.gatewayProfile?(0,W.jsxs)(`div`,{className:`p-4 space-y-2 text-sm`,children:[(0,W.jsxs)(`p`,{className:`font-medium flex items-center gap-2`,children:[(0,W.jsx)(B,{dbms:v.dbms,className:`size-4`}),v.hostName]}),(0,W.jsx)(`p`,{className:`text-muted-foreground`,children:e(`connection.dialog.gatewayProfileHint`,{name:v.gatewayProfile})}),(0,W.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[v.readOnly?e(`connection.dialog.gatewayReadOnly`):e(`connection.dialog.gatewayWritable`),v.database?` · ${v.database}`:``]})]}):(0,W.jsx)(Xe,{value:v,onChange:de})]}):(0,W.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:e(`connection.dialog.selectPrompt`)})})]}),(0,W.jsxs)(we,{className:`sm:justify-between`,children:[(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(l,{variant:`outline`,onClick:me,children:e(`connection.dialog.addNew`)}),(0,W.jsx)(l,{variant:`destructive`,onClick:I,disabled:!g,children:e(`connection.dialog.delete`)}),(0,W.jsxs)(st,{children:[(0,W.jsx)(ct,{asChild:!0,children:(0,W.jsxs)(l,{variant:`outline`,disabled:!ve,children:[e(`connection.dialog.export`),(0,W.jsx)(le,{className:`ml-1 size-3.5`,"aria-hidden":!0})]})}),(0,W.jsxs)(lt,{align:`start`,children:[(0,W.jsx)(ut,{onSelect:()=>void L(!1),children:e(`connection.dialog.exportWithoutSecrets`)}),(0,W.jsx)(ut,{onSelect:()=>void L(!0),children:e(`connection.dialog.exportWithSecrets`)})]})]}),(0,W.jsx)(l,{variant:`outline`,onClick:()=>void R(),children:e(`connection.dialog.import`)})]}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(l,{variant:`outline`,onClick:ke,disabled:!v||s,children:e(`connection.dialog.testConnection`)}),(0,W.jsx)(l,{onClick:J,disabled:!v||z,children:e(`connection.dialog.connect`)}),(0,W.jsx)(l,{variant:`outline`,onClick:()=>N(!1),children:e(`connection.dialog.close`)})]})]})]})})}export{dt as ConnectDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{l as e}from"./CKOS5Y-e.js";import{z as t}from"./
|
|
1
|
+
import{l as e}from"./CKOS5Y-e.js";import{z as t}from"./B_UAjgBr.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 +1 @@
|
|
|
1
|
-
import{r as e}from"./hePW80VL.js";import{h as t,n}from"./XzPc-eVf.js";import{l as r,m as i,t as a}from"./CKOS5Y-e.js";import{a as o}from"./fDSXGLmI.js";import{t as s}from"./B3nhMsGp.js";import{c}from"./CtXRSNHU.js";import{t as l}from"./Cr6Fx4T5.js";import{C as u,S as d,b as f,l as p,lt as m,v as h,x as g,y as _}from"./
|
|
1
|
+
import{r as e}from"./hePW80VL.js";import{h as t,n}from"./XzPc-eVf.js";import{l as r,m as i,t as a}from"./CKOS5Y-e.js";import{a as o}from"./fDSXGLmI.js";import{t as s}from"./B3nhMsGp.js";import{c}from"./CtXRSNHU.js";import{t as l}from"./Cr6Fx4T5.js";import{C as u,S as d,b as f,l as p,lt as m,v as h,x as g,y as _}from"./B_UAjgBr.js";import{a as v,i as y,n as b,o as x,t as S}from"./DxuXBECK.js";var C=e(t(),1),w=r();function T(){let e=s.getState();return e.activeConnections.find(t=>t.id===e.activeConnectionId)?.serverConnectionId??null}async function E(e){let t=T();if(!t)throw Error(o.t(`command.noActiveConnection`));let n=l().getQuery(e===`global`?`SHOW_GLOBAL_VARIABLES`:`SHOW_SESSION_VARIABLES`);return(await c(t,n)).records.map(e=>({Variable_name:e[0],Value:e[1]}))}function D(){let{t:e}=i(),{activeDialog:t,closeDialog:r,setFooterMessage:o}=n(),[s,c]=(0,C.useState)([]),[l,T]=(0,C.useState)(``),[D,O]=(0,C.useState)(`session`),k=t===`variables`,A=(0,C.useCallback)(t=>E(t).then(c).catch(t=>o(e(`command.variables.loadError`,{message:t instanceof Error?t.message:String(t)}))),[o,e]);(0,C.useEffect)(()=>{k&&A(D)},[k,D,A]);let j=(0,C.useMemo)(()=>{if(!l.trim())return s;let e=l.toLowerCase();return s.filter(t=>t.Variable_name.toLowerCase().includes(e)||t.Value.toLowerCase().includes(e))},[s,l]);function M(e){e||(T(``),r())}function N(e){O(e)}return(0,w.jsx)(S,{open:k,onOpenChange:M,children:(0,w.jsxs)(b,{className:`sm:max-w-[900px] max-h-[80vh] flex flex-col`,children:[(0,w.jsx)(v,{children:(0,w.jsx)(x,{children:e(`command.variables.title`)})}),(0,w.jsxs)(`div`,{className:`flex items-center gap-3 pb-2`,children:[(0,w.jsxs)(`div`,{className:`flex gap-1`,children:[(0,w.jsx)(a,{variant:D===`session`?`default`:`outline`,size:`sm`,onClick:()=>N(`session`),children:e(`command.scope.session`)}),(0,w.jsx)(a,{variant:D===`global`?`default`:`outline`,size:`sm`,onClick:()=>N(`global`),children:e(`command.scope.global`)})]}),(0,w.jsx)(p,{placeholder:e(`command.variables.filterPlaceholder`),value:l,onChange:e=>T(e.target.value),className:`max-w-xs`})]}),(0,w.jsx)(`div`,{className:`flex-1 border rounded-md overflow-hidden min-h-0`,children:(0,w.jsx)(m,{className:`h-[400px]`,children:(0,w.jsxs)(h,{children:[(0,w.jsx)(d,{children:(0,w.jsxs)(u,{children:[(0,w.jsx)(g,{className:`w-[300px]`,children:e(`command.variableName`)}),(0,w.jsx)(g,{children:e(`command.value`)})]})}),(0,w.jsx)(_,{children:j.length===0?(0,w.jsx)(u,{children:(0,w.jsx)(f,{colSpan:2,className:`text-center text-muted-foreground`,children:e(`command.variables.empty`)})}):j.map(e=>(0,w.jsxs)(u,{children:[(0,w.jsx)(f,{className:`font-mono text-xs`,children:e.Variable_name}),(0,w.jsx)(f,{className:`font-mono text-xs`,children:e.Value})]},e.Variable_name))})]})})}),(0,w.jsx)(y,{children:(0,w.jsx)(a,{variant:`outline`,onClick:()=>M(!1),children:e(`command.close`)})})]})})}export{D as VariablesDialog};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./hePW80VL.js";import{c as t,h as n,n as r,t as i}from"./XzPc-eVf.js";import{l as a,m as o,t as s}from"./CKOS5Y-e.js";import{a as c,i as l,n as u,r as d,t as f}from"./
|
|
1
|
+
import{r as e}from"./hePW80VL.js";import{c as t,h as n,n as r,t as i}from"./XzPc-eVf.js";import{l as a,m as o,t as s}from"./CKOS5Y-e.js";import{a as c,i as l,n as u,r as d,t as f}from"./Bz1cma8F.js";import{t as p}from"./B3nhMsGp.js";import{a as m}from"./CtXRSNHU.js";import{n as h}from"./Cr6Fx4T5.js";import{t as g}from"./4_c4BD6i.js";import{t as _}from"./Bs5VSn0X.js";import{at as v,c as y,ot as ee}from"./B_UAjgBr.js";import{a as b,i as x,n as te,o as ne,t as S}from"./DxuXBECK.js";var C=e(n(),1),w=[`VIEW`,`PROCEDURE`,`FUNCTION`,`TRIGGER`,`EVENT`];function T(e,t){return e.replace(/\bDEFINER\s*=\s*(?:`[^`]*`|'[^']*'|"[^"]*"|\w+)@(?:`[^`]*`|'[^']*'|"[^"]*"|[\w.%-]+)/gi,``).replace(/\bSQL SECURITY (?:DEFINER|INVOKER)\b/gi,``).replace(/\bALGORITHM\s*=\s*\w+/gi,``).replace(RegExp(`[\`"\\[]?${t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}[\`"\\]]?\\.`,`gi`),``).replace(/\s+/g,` `).replace(/;\s*$/,``).trim()}function E(e,t){let n=[];for(let r of w){let i=e.objects?.get(r),a=t.objects?.get(r);if(!i&&!a)continue;let o=[...new Set([...i?.keys()??[],...a?.keys()??[]])].sort();for(let s of o){let o=i?.get(s)??null,c=a?.get(s)??null,l;l=o?c?o.sql!==null&&c.sql!==null&&T(o.sql,e.database)===T(c.sql,t.database)?`identical`:`changed`:`missingInTarget`:`missingInSource`,n.push({type:r,name:s,status:l,source:o,target:c})}}return n}var D=e=>e.toLowerCase().replace(/\s+/g,` `).trim(),O=e=>e===null?null:e.trim().replace(/^'(.*)'(?:::\w+)?$/s,`$1`),k=e=>e.addedColumns.length+e.removedColumns.length+e.changedColumns.length+e.addedIndexes.length+e.removedIndexes.length+e.changedIndexes.length>0;function A(e,t){let n=[];return D(e.type)!==D(t.type)&&n.push(`type`),e.nullable!==t.nullable&&n.push(`nullable`),O(e.defaultValue)!==O(t.defaultValue)&&n.push(`default`),e.extra.toLowerCase()!==t.extra.toLowerCase()&&n.push(`extra`),n}var j=(e,t)=>e.type===t.type&&e.columns.length===t.columns.length&&e.columns.every((e,n)=>e===t.columns[n]);function M(e,t,n){let r=t.columns.get(e)??[],i=n.columns.get(e)??[],a=new Map(i.map(e=>[e.name,e])),o=new Map(r.map(e=>[e.name,e])),s={table:e,addedColumns:r.filter(e=>!a.has(e.name)),removedColumns:i.filter(e=>!o.has(e.name)),changedColumns:[],addedIndexes:[],removedIndexes:[],changedIndexes:[]};for(let e of r){let t=a.get(e.name);if(!t)continue;let n=A(e,t);n.length>0&&s.changedColumns.push({name:e.name,source:e,target:t,attributes:n})}let c=t.indexes.get(e)??[],l=n.indexes.get(e)??[],u=new Map(l.map(e=>[e.name,e])),d=new Map(c.map(e=>[e.name,e]));s.addedIndexes=c.filter(e=>!u.has(e.name)),s.removedIndexes=l.filter(e=>!d.has(e.name));for(let e of c){let t=u.get(e.name);t&&!j(e,t)&&s.changedIndexes.push({name:e.name,source:e,target:t})}return s}function N(e,t){let n=new Set(t.tables),r=new Set(e.tables),i={missingInTarget:[],missingInSource:[],changed:[],identical:[],objects:E(e,t)};for(let r of e.tables){if(!n.has(r)){i.missingInTarget.push(r);continue}let a=M(r,e,t);k(a)?i.changed.push(a):i.identical.push(r)}return i.missingInSource=t.tables.filter(e=>!r.has(e)),i}var P=e=>e.split(`
|
|
2
2
|
`).map(e=>`-- ${e}`).join(`
|
|
3
3
|
`);function re(e,t,n,r,i={}){let a=n.ddl,o=r.database,s=e=>i.includeDrops?e:P(e),c=[`-- Schema sync: ${t.database} -> ${o} (${n.label})`,`-- Review before running. Statements that drop data are commented out unless "Include DROP statements" was checked.`,``];for(let r of e.missingInTarget)c.push(`-- Table ${r} is missing in the target`),c.push(F(r,t,n,o)),c.push(``);for(let t of e.changed){c.push(`-- Table ${t.table}`);for(let e of t.removedIndexes)c.push(s(a.dropIndex(o,t.table,e.name)));for(let e of t.changedIndexes)c.push(s(a.dropIndex(o,t.table,e.name)));for(let e of t.addedColumns)c.push(a.addColumn(o,t.table,e));for(let e of t.changedColumns){let r=a.alterColumn(o,t.table,e.source);c.push(r??P(`${n.label} cannot alter column ${e.name} in place (${e.attributes.join(`, `)}): recreate the table`))}for(let e of t.removedColumns)c.push(s(a.dropColumn(o,t.table,e.name)));for(let e of t.addedIndexes)c.push(a.createIndex(o,t.table,e));for(let e of t.changedIndexes)c.push(a.createIndex(o,t.table,e.source));c.push(``)}for(let t of e.missingInSource)c.push(`-- Table ${t} exists only in the target`),c.push(s(`DROP TABLE ${n.qualify(o,t)};`)),c.push(``);for(let t of e.objects){if(t.status===`identical`)continue;let e=`${t.type.charAt(0)}${t.type.slice(1).toLowerCase()} ${t.name}`,r=L(n,o,t);t.status===`missingInSource`?(c.push(`-- ${e} exists only in the target`),c.push(s(r))):(c.push(t.status===`changed`?`-- ${e} differs; recreated from the source`:`-- ${e} is missing in the target`),t.status===`changed`&&c.push(s(r)),c.push(t.source?.sql?R(t.source.sql):P(`the source engine did not return a CREATE statement for ${e}`))),c.push(``)}return c.join(`
|
|
4
4
|
`).replace(/\n{3,}/g,`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./hePW80VL.js";import{h as t,n,t as r}from"./XzPc-eVf.js";import{l as i,m as a,t as o}from"./CKOS5Y-e.js";import{a as s,i as c,n as l,r as u,t as d}from"./DsllOXPq.js";import{t as f}from"./B3nhMsGp.js";import{a as p}from"./CtXRSNHU.js";import{n as m}from"./Cr6Fx4T5.js";import{l as h,p as g}from"./5Jrsnc1i.js";import{$t as _,C as v,D as y,E as b,G as ee,O as te,S as x,T as S,Z as C,b as w,c as T,ct as ne,k as E,l as D,lt as O,st as k,v as A,x as j,y as M}from"./Bxw3grU1.js";import{a as N,i as P,n as F,o as I,t as L}from"./DxuXBECK.js";var R=e(t(),1);function z(){return{id:crypto.randomUUID(),field:``,type:`varchar`,length:``,defaultValue:``,pk:!1,notNull:!1,unsigned:!1,autoIncrement:!1,zerofill:!1,comment:``}}function B(){return{id:crypto.randomUUID(),name:``,type:`INDEX`,columns:[]}}function re(){return{engine:`InnoDB`,charset:`utf8mb4`,collation:`utf8mb4_general_ci`,autoIncrement:``,comment:``}}function ie(e,t,n,r,i){return{database:e,name:t,columns:n.map(e=>({name:e.field,type:e.type,length:e.length,defaultValue:e.defaultValue,primaryKey:e.pk,notNull:e.notNull,unsigned:e.unsigned,autoIncrement:e.autoIncrement,zerofill:e.zerofill,comment:e.comment})),indexes:r.map(e=>({name:e.name,type:e.type,columns:[...e.columns]})),options:{...i}}}var V=i(),H=`w-auto min-w-full [&_td]:bg-muted [&_td]:border-r [&_td]:border-border/60 [&_td:last-child]:border-r-0 [&_td]:p-0 [&_td]:h-8 [&_tr:nth-child(even)_td]:bg-muted/60 [&_tr:focus-within_td]:bg-primary/5`,U=`sticky top-0 z-10 bg-catppuccin-crust shadow-[inset_0_-1px_0_var(--border)] [&_th]:h-8 [&_th]:bg-catppuccin-crust [&_th]:font-semibold [&_th]:text-foreground [&_th]:uppercase [&_th]:tracking-wide [&_th]:text-[11px]`,W=`h-8 w-full min-w-0 rounded-none border-0 bg-transparent px-2 text-xs shadow-none ring-0 focus-visible:bg-primary/10 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary dark:bg-transparent`,G=`h-8 w-full min-w-0 rounded-none border-0 bg-transparent px-2 text-xs shadow-none focus-visible:bg-primary/10 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary data-[state=open]:bg-primary/10 dark:bg-transparent dark:hover:bg-transparent`;function ae({columns:e,onChange:t}){let{t:n}=a(),r=k().getDataTypes(),i=(0,R.useCallback)((n,r,i)=>{t(e.map(e=>e.id===n?{...e,[r]:i}:e))},[e,t]);function f(){t([...e,z()])}function p(){e.length>0&&t(e.slice(0,-1))}return(0,V.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,V.jsx)(O,{className:`flex-1`,children:(0,V.jsxs)(A,{className:H,children:[(0,V.jsx)(x,{className:U,children:(0,V.jsxs)(v,{children:[(0,V.jsx)(j,{className:`w-[120px]`,children:n(`table.schema.colField`)}),(0,V.jsx)(j,{className:`w-[120px]`,children:n(`table.schema.colType`)}),(0,V.jsx)(j,{className:`w-[60px]`,children:n(`table.schema.colLength`)}),(0,V.jsx)(j,{className:`w-[100px]`,children:n(`table.schema.colDefault`)}),(0,V.jsx)(j,{className:`w-[40px]`,children:n(`table.schema.colPk`)}),(0,V.jsx)(j,{className:`w-[60px]`,children:n(`table.schema.colNotNull`)}),(0,V.jsx)(j,{className:`w-[60px]`,children:n(`table.schema.colUnsigned`)}),(0,V.jsx)(j,{className:`w-[70px]`,children:n(`table.schema.colAutoIncrement`)}),(0,V.jsx)(j,{className:`w-[60px]`,children:n(`table.schema.colZerofill`)}),(0,V.jsx)(j,{children:n(`table.schema.colComment`)})]})}),(0,V.jsx)(M,{children:e.length===0?(0,V.jsx)(v,{children:(0,V.jsx)(w,{colSpan:10,className:`text-center text-muted-foreground`,children:n(`table.schema.empty`)})}):e.map(e=>(0,V.jsxs)(v,{children:[(0,V.jsx)(w,{children:(0,V.jsx)(D,{className:W,value:e.field,onChange:t=>i(e.id,`field`,t.target.value),placeholder:`column_name`})}),(0,V.jsx)(w,{children:(0,V.jsxs)(d,{value:e.type,onValueChange:t=>i(e.id,`type`,t),children:[(0,V.jsx)(c,{className:G,children:(0,V.jsx)(s,{})}),(0,V.jsx)(l,{children:r.map(e=>(0,V.jsx)(u,{value:e,children:e},e))})]})}),(0,V.jsx)(w,{children:(0,V.jsx)(D,{className:W,value:e.length,onChange:t=>i(e.id,`length`,t.target.value)})}),(0,V.jsx)(w,{children:(0,V.jsx)(D,{className:W,value:e.defaultValue,onChange:t=>i(e.id,`defaultValue`,t.target.value),placeholder:`NULL`})}),(0,V.jsx)(w,{className:`text-center`,children:(0,V.jsx)(`input`,{type:`checkbox`,checked:e.pk,onChange:t=>i(e.id,`pk`,t.target.checked)})}),(0,V.jsx)(w,{className:`text-center`,children:(0,V.jsx)(`input`,{type:`checkbox`,checked:e.notNull,onChange:t=>i(e.id,`notNull`,t.target.checked)})}),(0,V.jsx)(w,{className:`text-center`,children:(0,V.jsx)(`input`,{type:`checkbox`,checked:e.unsigned,onChange:t=>i(e.id,`unsigned`,t.target.checked)})}),(0,V.jsx)(w,{className:`text-center`,children:(0,V.jsx)(`input`,{type:`checkbox`,checked:e.autoIncrement,onChange:t=>i(e.id,`autoIncrement`,t.target.checked)})}),(0,V.jsx)(w,{className:`text-center`,children:(0,V.jsx)(`input`,{type:`checkbox`,checked:e.zerofill,onChange:t=>i(e.id,`zerofill`,t.target.checked)})}),(0,V.jsx)(w,{children:(0,V.jsx)(D,{className:W,value:e.comment,onChange:t=>i(e.id,`comment`,t.target.value)})})]},e.id))})]})}),(0,V.jsxs)(`div`,{className:`flex gap-2 p-2 border-t`,children:[(0,V.jsx)(o,{size:`sm`,variant:`outline`,onClick:f,children:n(`table.schema.add`)}),(0,V.jsx)(o,{size:`sm`,variant:`outline`,onClick:p,disabled:e.length===0,children:n(`table.schema.remove`)})]})]})}var K=[`PRIMARY`,`UNIQUE`,`INDEX`,`FULLTEXT`];function q({open:e,index:t,availableColumns:n,onSave:r,onClose:i}){let{t:f}=a(),[p,m]=(0,R.useState)(t.name),[h,g]=(0,R.useState)(t.type),[_,v]=(0,R.useState)(t.columns);function y(e){v(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}function b(){r({id:t.id,name:h===`PRIMARY`?`PRIMARY`:p,type:h,columns:_})}return(0,V.jsx)(L,{open:e,onOpenChange:e=>{e||i()},children:(0,V.jsxs)(F,{className:`sm:max-w-[500px]`,children:[(0,V.jsx)(N,{children:(0,V.jsx)(I,{children:t.name?f(`table.index.editTitle`):f(`table.index.addTitle`)})}),(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{htmlFor:`idx-name`,children:f(`table.index.name`)}),(0,V.jsx)(D,{id:`idx-name`,value:h===`PRIMARY`?`PRIMARY`:p,onChange:e=>m(e.target.value),disabled:h===`PRIMARY`,placeholder:f(`table.index.namePlaceholder`)})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{htmlFor:`idx-type`,children:f(`table.index.type`)}),(0,V.jsxs)(d,{value:h,onValueChange:e=>g(e),children:[(0,V.jsx)(c,{id:`idx-type`,className:`w-full`,children:(0,V.jsx)(s,{})}),(0,V.jsx)(l,{children:K.map(e=>(0,V.jsx)(u,{value:e,children:e},e))})]})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{children:f(`table.index.columns`)}),(0,V.jsx)(`div`,{className:`border rounded-md p-2 max-h-[200px] overflow-y-auto space-y-1`,children:n.length===0?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:f(`table.index.noColumns`)}):n.map(e=>(0,V.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer hover:bg-muted/50 rounded px-1 py-0.5`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:_.includes(e.field),onChange:()=>y(e.field)}),(0,V.jsx)(`span`,{children:e.field||f(`table.index.unnamed`)}),(0,V.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.type,`)`]})]},e.id))})]})]}),(0,V.jsxs)(P,{children:[(0,V.jsx)(o,{variant:`outline`,onClick:i,children:f(`table.index.cancel`)}),(0,V.jsx)(o,{onClick:b,disabled:_.length===0,children:f(`table.index.ok`)})]})]})})}function oe({indexes:e,availableColumns:t,onChange:n}){let{t:r}=a(),[i,s]=(0,R.useState)(null),[c,l]=(0,R.useState)(!1);function u(){let e=B();s(e),l(!0)}function d(e){s({...e}),l(!0)}function f(){e.length>0&&n(e.slice(0,-1))}function p(t){e.find(e=>e.id===t.id)?n(e.map(e=>e.id===t.id?t:e)):n([...e,t]),l(!1),s(null)}function m(){l(!1),s(null)}return(0,V.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,V.jsx)(O,{className:`flex-1`,children:(0,V.jsxs)(A,{className:H+` [&_td]:px-2`,children:[(0,V.jsx)(x,{className:U,children:(0,V.jsxs)(v,{children:[(0,V.jsx)(j,{className:`w-[150px]`,children:r(`table.indexes.colName`)}),(0,V.jsx)(j,{className:`w-[120px]`,children:r(`table.indexes.colType`)}),(0,V.jsx)(j,{children:r(`table.indexes.colColumns`)})]})}),(0,V.jsx)(M,{children:e.length===0?(0,V.jsx)(v,{children:(0,V.jsx)(w,{colSpan:3,className:`text-center text-muted-foreground`,children:r(`table.indexes.empty`)})}):e.map(e=>(0,V.jsxs)(v,{className:`cursor-pointer`,onDoubleClick:()=>d(e),children:[(0,V.jsx)(w,{children:e.name}),(0,V.jsx)(w,{children:e.type}),(0,V.jsx)(w,{children:e.columns.join(`, `)})]},e.id))})]})}),(0,V.jsxs)(`div`,{className:`flex gap-2 p-2 border-t`,children:[(0,V.jsx)(o,{size:`sm`,variant:`outline`,onClick:u,children:r(`table.indexes.add`)}),(0,V.jsx)(o,{size:`sm`,variant:`outline`,onClick:f,disabled:e.length===0,children:r(`table.indexes.remove`)})]}),i&&(0,V.jsx)(q,{open:c,index:i,availableColumns:t,onSave:p,onClose:m})]})}var J=[`InnoDB`,`MyISAM`,`MEMORY`,`CSV`,`ARCHIVE`,`BLACKHOLE`,`MRG_MYISAM`,`FEDERATED`,`PERFORMANCE_SCHEMA`],Y=[`utf8mb4`,`utf8`,`latin1`,`ascii`,`binary`,`cp1251`,`euckr`,`gb2312`,`gbk`,`sjis`,`ucs2`,`utf16`,`utf32`],X={utf8mb4:[`utf8mb4_general_ci`,`utf8mb4_unicode_ci`,`utf8mb4_bin`,`utf8mb4_0900_ai_ci`],utf8:[`utf8_general_ci`,`utf8_unicode_ci`,`utf8_bin`],latin1:[`latin1_swedish_ci`,`latin1_general_ci`,`latin1_bin`],ascii:[`ascii_general_ci`,`ascii_bin`],binary:[`binary`],cp1251:[`cp1251_general_ci`,`cp1251_bin`],euckr:[`euckr_korean_ci`,`euckr_bin`],gb2312:[`gb2312_chinese_ci`,`gb2312_bin`],gbk:[`gbk_chinese_ci`,`gbk_bin`],sjis:[`sjis_japanese_ci`,`sjis_bin`],ucs2:[`ucs2_general_ci`,`ucs2_unicode_ci`,`ucs2_bin`],utf16:[`utf16_general_ci`,`utf16_unicode_ci`,`utf16_bin`],utf32:[`utf32_general_ci`,`utf32_unicode_ci`,`utf32_bin`]};function se({properties:e,onChange:t}){let{t:n}=a();function r(n,r){let i={...e,[n]:r};n===`charset`&&(i.collation=X[r]?.[0]??``),t(i)}let i=X[e.charset]??[];return(0,V.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{htmlFor:`prop-engine`,children:n(`table.properties.engine`)}),(0,V.jsxs)(d,{value:e.engine,onValueChange:e=>r(`engine`,e),children:[(0,V.jsx)(c,{id:`prop-engine`,className:`w-full`,children:(0,V.jsx)(s,{})}),(0,V.jsx)(l,{children:J.map(e=>(0,V.jsx)(u,{value:e,children:e},e))})]})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{htmlFor:`prop-charset`,children:n(`table.properties.charset`)}),(0,V.jsxs)(d,{value:e.charset,onValueChange:e=>r(`charset`,e),children:[(0,V.jsx)(c,{id:`prop-charset`,className:`w-full`,children:(0,V.jsx)(s,{})}),(0,V.jsx)(l,{children:Y.map(e=>(0,V.jsx)(u,{value:e,children:e},e))})]})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{htmlFor:`prop-collation`,children:n(`table.properties.collation`)}),(0,V.jsxs)(d,{value:e.collation,onValueChange:e=>r(`collation`,e),children:[(0,V.jsx)(c,{id:`prop-collation`,className:`w-full`,children:(0,V.jsx)(s,{})}),(0,V.jsx)(l,{children:i.map(e=>(0,V.jsx)(u,{value:e,children:e},e))})]})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{htmlFor:`prop-auto-incr`,children:n(`table.properties.autoIncrement`)}),(0,V.jsx)(D,{id:`prop-auto-incr`,type:`number`,value:e.autoIncrement,onChange:e=>r(`autoIncrement`,e.target.value),placeholder:n(`table.properties.autoIncrementPlaceholder`)})]})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{htmlFor:`prop-comment`,children:n(`table.properties.comment`)}),(0,V.jsx)(D,{id:`prop-comment`,value:e.comment,onChange:e=>r(`comment`,e.target.value)})]})]})}function ce({connectionId:e,database:t,tableName:n,columns:r,indexes:i,properties:a}){let o=C(e=>e.themeId),s=ne(e),c=S(o),l=(0,R.useMemo)(()=>s.ddl.createTable(ie(t,n,r,i,a)),[s,t,n,r,i,a]);return(0,V.jsx)(`div`,{className:`h-[320px]`,children:(0,V.jsx)(_,{height:`100%`,language:`sql`,theme:c,value:l,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:13,lineNumbers:`on`,wordWrap:`on`}})})}function Z(e){return JSON.stringify([e.type,e.length,e.defaultValue,e.pk,e.notNull,e.unsigned,e.autoIncrement,e.zerofill,e.comment])}function Q(e){return{name:e.field,type:e.length?`${e.type}(${e.length})`:e.type,nullable:!e.notNull,key:e.pk?`PRI`:``,defaultValue:e.defaultValue===``?null:e.defaultValue,extra:e.autoIncrement?`auto_increment`:``,comment:e.comment,collation:null}}function $(e){return{name:e.name,type:e.type,columns:[...e.columns]}}function le(e,t){return e.name===t.name&&e.type===t.type&&e.columns.join(`,`)===t.columns.join(`,`)}function ue({engine:e,database:t,table:n,before:r,after:i}){let{ddl:a}=e,o=[],s=[],c=[],l=new Map(r.columns.map(e=>[e.id,e])),u=new Map(i.columns.map(e=>[e.id,e])),d=new Map(r.indexes.map(e=>[e.id,e])),f=new Map(i.indexes.map(e=>[e.id,e])),p=[];for(let[e,r]of d){let i=f.get(e);i?le(r,i)||(o.push(a.dropIndex(t,n,r.name)),p.push(i)):o.push(a.dropIndex(t,n,r.name))}for(let[e,r]of u){let i=l.get(e);if(!i){r.field.trim()&&o.push(a.addColumn(t,n,Q(r)));continue}if(i.field!==r.field&&o.push(a.renameColumn(t,n,i.field,r.field)),Z(i)!==Z(r)){let e=a.alterColumn(t,n,Q(r));e?o.push(e):c.push(r.field)}}for(let[e,r]of l)if(!u.has(e)){let e=a.dropColumn(t,n,r.field);o.push(e),s.push(e)}for(let e of p)o.push(a.createIndex(t,n,$(e)));for(let[e,r]of f)!d.has(e)&&r.columns.length>0&&o.push(a.createIndex(t,n,$(r)));return{statements:o,destructive:s,unsupported:c}}function de(){let{t:e}=a(),{activeDialog:t,closeDialog:i}=n(),s=r(`create-table`,`alter-table`,`duplicate-table-structure`),c=t===`create-table`||t===`alter-table`||t===`duplicate-table-structure`,l=t===`alter-table`,u=t===`duplicate-table-structure`,d=s?.nodeText??``,_=s?.metadata?.database??``,[v,x]=(0,R.useState)(``),[S,C]=(0,R.useState)([z()]),[w,O]=(0,R.useState)([]),[k,A]=(0,R.useState)(re()),[j,M]=(0,R.useState)(!1),[B,H]=(0,R.useState)(!1),[U,W]=(0,R.useState)(null),[G,K]=(0,R.useState)(null),q=s?.connectionId??f.getState().activeConnectionId,J=ne(q);(0,R.useEffect)(()=>{c&&(W(null),K(null),l||u?(x(u?`${d}_copy`:d),Y()):(x(``),C([z()]),O([]),A(re())))},[c,t]);async function Y(){let e=f.getState(),t=s?.connectionId??e.activeConnectionId,n=e.activeConnections.find(e=>e.id===t)?.serverConnectionId;if(!n||!_||!d)return;M(!0);let{introspect:r,capabilities:i}=m(t),a=p(n);try{let e=await r.listColumns(a,_,d),t=[];if(e.length>0){let n=e.map(e=>{let t=e.type,n=t.match(/^(\w+)(?:\(([^)]+)\))?/);return{id:crypto.randomUUID(),field:e.name,type:n?.[1]?.toLowerCase()??t.toLowerCase(),length:n?.[2]??``,defaultValue:e.defaultValue??``,pk:e.key===`PRI`,notNull:!e.nullable,unsigned:t.includes(`unsigned`),autoIncrement:e.extra.includes(`auto_increment`),zerofill:t.includes(`zerofill`),comment:e.comment}});C(n),t=n}let n=await r.listIndexes(a,_,d),o=[];if(n.length>0&&(o=n.map(e=>({id:crypto.randomUUID(),name:e.name,type:e.type===`SPATIAL`?`INDEX`:e.type,columns:[...e.columns]})),O(o)),K({columns:t,indexes:o}),i.tableProperties){let e=await r.getTableInfo(a,_,d);e&&A({engine:e.engine??`InnoDB`,charset:(e.collation??`utf8mb4`).replace(/_.*/,``),collation:e.collation??`utf8mb4_unicode_ci`,autoIncrement:e.autoIncrement??``,comment:e.comment})}}catch(e){console.error(`Failed to load table schema:`,e),W(e instanceof Error?e.message:String(e))}finally{M(!1)}}function X(e){e||i()}async function Z(){let t=s?.connectionId??f.getState().activeConnectionId;if(!t||!v.trim())return;let n=m(t);W(null);let r,a=[];if(l){if(!G)return;let t=ue({engine:n,database:_,table:d,before:G,after:{columns:S,indexes:w}});if(t.unsupported.length>0){W(e(`table.dialog.cannotAlterColumns`,{engine:n.label,columns:t.unsupported.join(`, `)}));return}if(t.statements.length===0){i();return}r=t.statements.join(`
|
|
1
|
+
import{r as e}from"./hePW80VL.js";import{h as t,n,t as r}from"./XzPc-eVf.js";import{l as i,m as a,t as o}from"./CKOS5Y-e.js";import{a as s,i as c,n as l,r as u,t as d}from"./Bz1cma8F.js";import{t as f}from"./B3nhMsGp.js";import{a as p}from"./CtXRSNHU.js";import{n as m}from"./Cr6Fx4T5.js";import{l as h,p as g}from"./CCQZjXae.js";import{$t as _,C as v,D as y,E as b,G as ee,O as te,S as x,T as S,Z as C,b as w,c as T,ct as ne,k as E,l as D,lt as O,st as k,v as A,x as j,y as M}from"./B_UAjgBr.js";import{a as N,i as P,n as F,o as I,t as L}from"./DxuXBECK.js";var R=e(t(),1);function z(){return{id:crypto.randomUUID(),field:``,type:`varchar`,length:``,defaultValue:``,pk:!1,notNull:!1,unsigned:!1,autoIncrement:!1,zerofill:!1,comment:``}}function B(){return{id:crypto.randomUUID(),name:``,type:`INDEX`,columns:[]}}function re(){return{engine:`InnoDB`,charset:`utf8mb4`,collation:`utf8mb4_general_ci`,autoIncrement:``,comment:``}}function ie(e,t,n,r,i){return{database:e,name:t,columns:n.map(e=>({name:e.field,type:e.type,length:e.length,defaultValue:e.defaultValue,primaryKey:e.pk,notNull:e.notNull,unsigned:e.unsigned,autoIncrement:e.autoIncrement,zerofill:e.zerofill,comment:e.comment})),indexes:r.map(e=>({name:e.name,type:e.type,columns:[...e.columns]})),options:{...i}}}var V=i(),H=`w-auto min-w-full [&_td]:bg-muted [&_td]:border-r [&_td]:border-border/60 [&_td:last-child]:border-r-0 [&_td]:p-0 [&_td]:h-8 [&_tr:nth-child(even)_td]:bg-muted/60 [&_tr:focus-within_td]:bg-primary/5`,U=`sticky top-0 z-10 bg-catppuccin-crust shadow-[inset_0_-1px_0_var(--border)] [&_th]:h-8 [&_th]:bg-catppuccin-crust [&_th]:font-semibold [&_th]:text-foreground [&_th]:uppercase [&_th]:tracking-wide [&_th]:text-[11px]`,W=`h-8 w-full min-w-0 rounded-none border-0 bg-transparent px-2 text-xs shadow-none ring-0 focus-visible:bg-primary/10 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary dark:bg-transparent`,G=`h-8 w-full min-w-0 rounded-none border-0 bg-transparent px-2 text-xs shadow-none focus-visible:bg-primary/10 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary data-[state=open]:bg-primary/10 dark:bg-transparent dark:hover:bg-transparent`;function ae({columns:e,onChange:t}){let{t:n}=a(),r=k().getDataTypes(),i=(0,R.useCallback)((n,r,i)=>{t(e.map(e=>e.id===n?{...e,[r]:i}:e))},[e,t]);function f(){t([...e,z()])}function p(){e.length>0&&t(e.slice(0,-1))}return(0,V.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,V.jsx)(O,{className:`flex-1`,children:(0,V.jsxs)(A,{className:H,children:[(0,V.jsx)(x,{className:U,children:(0,V.jsxs)(v,{children:[(0,V.jsx)(j,{className:`w-[120px]`,children:n(`table.schema.colField`)}),(0,V.jsx)(j,{className:`w-[120px]`,children:n(`table.schema.colType`)}),(0,V.jsx)(j,{className:`w-[60px]`,children:n(`table.schema.colLength`)}),(0,V.jsx)(j,{className:`w-[100px]`,children:n(`table.schema.colDefault`)}),(0,V.jsx)(j,{className:`w-[40px]`,children:n(`table.schema.colPk`)}),(0,V.jsx)(j,{className:`w-[60px]`,children:n(`table.schema.colNotNull`)}),(0,V.jsx)(j,{className:`w-[60px]`,children:n(`table.schema.colUnsigned`)}),(0,V.jsx)(j,{className:`w-[70px]`,children:n(`table.schema.colAutoIncrement`)}),(0,V.jsx)(j,{className:`w-[60px]`,children:n(`table.schema.colZerofill`)}),(0,V.jsx)(j,{children:n(`table.schema.colComment`)})]})}),(0,V.jsx)(M,{children:e.length===0?(0,V.jsx)(v,{children:(0,V.jsx)(w,{colSpan:10,className:`text-center text-muted-foreground`,children:n(`table.schema.empty`)})}):e.map(e=>(0,V.jsxs)(v,{children:[(0,V.jsx)(w,{children:(0,V.jsx)(D,{className:W,value:e.field,onChange:t=>i(e.id,`field`,t.target.value),placeholder:`column_name`})}),(0,V.jsx)(w,{children:(0,V.jsxs)(d,{value:e.type,onValueChange:t=>i(e.id,`type`,t),children:[(0,V.jsx)(c,{className:G,children:(0,V.jsx)(s,{})}),(0,V.jsx)(l,{children:r.map(e=>(0,V.jsx)(u,{value:e,children:e},e))})]})}),(0,V.jsx)(w,{children:(0,V.jsx)(D,{className:W,value:e.length,onChange:t=>i(e.id,`length`,t.target.value)})}),(0,V.jsx)(w,{children:(0,V.jsx)(D,{className:W,value:e.defaultValue,onChange:t=>i(e.id,`defaultValue`,t.target.value),placeholder:`NULL`})}),(0,V.jsx)(w,{className:`text-center`,children:(0,V.jsx)(`input`,{type:`checkbox`,checked:e.pk,onChange:t=>i(e.id,`pk`,t.target.checked)})}),(0,V.jsx)(w,{className:`text-center`,children:(0,V.jsx)(`input`,{type:`checkbox`,checked:e.notNull,onChange:t=>i(e.id,`notNull`,t.target.checked)})}),(0,V.jsx)(w,{className:`text-center`,children:(0,V.jsx)(`input`,{type:`checkbox`,checked:e.unsigned,onChange:t=>i(e.id,`unsigned`,t.target.checked)})}),(0,V.jsx)(w,{className:`text-center`,children:(0,V.jsx)(`input`,{type:`checkbox`,checked:e.autoIncrement,onChange:t=>i(e.id,`autoIncrement`,t.target.checked)})}),(0,V.jsx)(w,{className:`text-center`,children:(0,V.jsx)(`input`,{type:`checkbox`,checked:e.zerofill,onChange:t=>i(e.id,`zerofill`,t.target.checked)})}),(0,V.jsx)(w,{children:(0,V.jsx)(D,{className:W,value:e.comment,onChange:t=>i(e.id,`comment`,t.target.value)})})]},e.id))})]})}),(0,V.jsxs)(`div`,{className:`flex gap-2 p-2 border-t`,children:[(0,V.jsx)(o,{size:`sm`,variant:`outline`,onClick:f,children:n(`table.schema.add`)}),(0,V.jsx)(o,{size:`sm`,variant:`outline`,onClick:p,disabled:e.length===0,children:n(`table.schema.remove`)})]})]})}var K=[`PRIMARY`,`UNIQUE`,`INDEX`,`FULLTEXT`];function q({open:e,index:t,availableColumns:n,onSave:r,onClose:i}){let{t:f}=a(),[p,m]=(0,R.useState)(t.name),[h,g]=(0,R.useState)(t.type),[_,v]=(0,R.useState)(t.columns);function y(e){v(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}function b(){r({id:t.id,name:h===`PRIMARY`?`PRIMARY`:p,type:h,columns:_})}return(0,V.jsx)(L,{open:e,onOpenChange:e=>{e||i()},children:(0,V.jsxs)(F,{className:`sm:max-w-[500px]`,children:[(0,V.jsx)(N,{children:(0,V.jsx)(I,{children:t.name?f(`table.index.editTitle`):f(`table.index.addTitle`)})}),(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{htmlFor:`idx-name`,children:f(`table.index.name`)}),(0,V.jsx)(D,{id:`idx-name`,value:h===`PRIMARY`?`PRIMARY`:p,onChange:e=>m(e.target.value),disabled:h===`PRIMARY`,placeholder:f(`table.index.namePlaceholder`)})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{htmlFor:`idx-type`,children:f(`table.index.type`)}),(0,V.jsxs)(d,{value:h,onValueChange:e=>g(e),children:[(0,V.jsx)(c,{id:`idx-type`,className:`w-full`,children:(0,V.jsx)(s,{})}),(0,V.jsx)(l,{children:K.map(e=>(0,V.jsx)(u,{value:e,children:e},e))})]})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{children:f(`table.index.columns`)}),(0,V.jsx)(`div`,{className:`border rounded-md p-2 max-h-[200px] overflow-y-auto space-y-1`,children:n.length===0?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:f(`table.index.noColumns`)}):n.map(e=>(0,V.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer hover:bg-muted/50 rounded px-1 py-0.5`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:_.includes(e.field),onChange:()=>y(e.field)}),(0,V.jsx)(`span`,{children:e.field||f(`table.index.unnamed`)}),(0,V.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.type,`)`]})]},e.id))})]})]}),(0,V.jsxs)(P,{children:[(0,V.jsx)(o,{variant:`outline`,onClick:i,children:f(`table.index.cancel`)}),(0,V.jsx)(o,{onClick:b,disabled:_.length===0,children:f(`table.index.ok`)})]})]})})}function oe({indexes:e,availableColumns:t,onChange:n}){let{t:r}=a(),[i,s]=(0,R.useState)(null),[c,l]=(0,R.useState)(!1);function u(){let e=B();s(e),l(!0)}function d(e){s({...e}),l(!0)}function f(){e.length>0&&n(e.slice(0,-1))}function p(t){e.find(e=>e.id===t.id)?n(e.map(e=>e.id===t.id?t:e)):n([...e,t]),l(!1),s(null)}function m(){l(!1),s(null)}return(0,V.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,V.jsx)(O,{className:`flex-1`,children:(0,V.jsxs)(A,{className:H+` [&_td]:px-2`,children:[(0,V.jsx)(x,{className:U,children:(0,V.jsxs)(v,{children:[(0,V.jsx)(j,{className:`w-[150px]`,children:r(`table.indexes.colName`)}),(0,V.jsx)(j,{className:`w-[120px]`,children:r(`table.indexes.colType`)}),(0,V.jsx)(j,{children:r(`table.indexes.colColumns`)})]})}),(0,V.jsx)(M,{children:e.length===0?(0,V.jsx)(v,{children:(0,V.jsx)(w,{colSpan:3,className:`text-center text-muted-foreground`,children:r(`table.indexes.empty`)})}):e.map(e=>(0,V.jsxs)(v,{className:`cursor-pointer`,onDoubleClick:()=>d(e),children:[(0,V.jsx)(w,{children:e.name}),(0,V.jsx)(w,{children:e.type}),(0,V.jsx)(w,{children:e.columns.join(`, `)})]},e.id))})]})}),(0,V.jsxs)(`div`,{className:`flex gap-2 p-2 border-t`,children:[(0,V.jsx)(o,{size:`sm`,variant:`outline`,onClick:u,children:r(`table.indexes.add`)}),(0,V.jsx)(o,{size:`sm`,variant:`outline`,onClick:f,disabled:e.length===0,children:r(`table.indexes.remove`)})]}),i&&(0,V.jsx)(q,{open:c,index:i,availableColumns:t,onSave:p,onClose:m})]})}var J=[`InnoDB`,`MyISAM`,`MEMORY`,`CSV`,`ARCHIVE`,`BLACKHOLE`,`MRG_MYISAM`,`FEDERATED`,`PERFORMANCE_SCHEMA`],Y=[`utf8mb4`,`utf8`,`latin1`,`ascii`,`binary`,`cp1251`,`euckr`,`gb2312`,`gbk`,`sjis`,`ucs2`,`utf16`,`utf32`],X={utf8mb4:[`utf8mb4_general_ci`,`utf8mb4_unicode_ci`,`utf8mb4_bin`,`utf8mb4_0900_ai_ci`],utf8:[`utf8_general_ci`,`utf8_unicode_ci`,`utf8_bin`],latin1:[`latin1_swedish_ci`,`latin1_general_ci`,`latin1_bin`],ascii:[`ascii_general_ci`,`ascii_bin`],binary:[`binary`],cp1251:[`cp1251_general_ci`,`cp1251_bin`],euckr:[`euckr_korean_ci`,`euckr_bin`],gb2312:[`gb2312_chinese_ci`,`gb2312_bin`],gbk:[`gbk_chinese_ci`,`gbk_bin`],sjis:[`sjis_japanese_ci`,`sjis_bin`],ucs2:[`ucs2_general_ci`,`ucs2_unicode_ci`,`ucs2_bin`],utf16:[`utf16_general_ci`,`utf16_unicode_ci`,`utf16_bin`],utf32:[`utf32_general_ci`,`utf32_unicode_ci`,`utf32_bin`]};function se({properties:e,onChange:t}){let{t:n}=a();function r(n,r){let i={...e,[n]:r};n===`charset`&&(i.collation=X[r]?.[0]??``),t(i)}let i=X[e.charset]??[];return(0,V.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{htmlFor:`prop-engine`,children:n(`table.properties.engine`)}),(0,V.jsxs)(d,{value:e.engine,onValueChange:e=>r(`engine`,e),children:[(0,V.jsx)(c,{id:`prop-engine`,className:`w-full`,children:(0,V.jsx)(s,{})}),(0,V.jsx)(l,{children:J.map(e=>(0,V.jsx)(u,{value:e,children:e},e))})]})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{htmlFor:`prop-charset`,children:n(`table.properties.charset`)}),(0,V.jsxs)(d,{value:e.charset,onValueChange:e=>r(`charset`,e),children:[(0,V.jsx)(c,{id:`prop-charset`,className:`w-full`,children:(0,V.jsx)(s,{})}),(0,V.jsx)(l,{children:Y.map(e=>(0,V.jsx)(u,{value:e,children:e},e))})]})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{htmlFor:`prop-collation`,children:n(`table.properties.collation`)}),(0,V.jsxs)(d,{value:e.collation,onValueChange:e=>r(`collation`,e),children:[(0,V.jsx)(c,{id:`prop-collation`,className:`w-full`,children:(0,V.jsx)(s,{})}),(0,V.jsx)(l,{children:i.map(e=>(0,V.jsx)(u,{value:e,children:e},e))})]})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{htmlFor:`prop-auto-incr`,children:n(`table.properties.autoIncrement`)}),(0,V.jsx)(D,{id:`prop-auto-incr`,type:`number`,value:e.autoIncrement,onChange:e=>r(`autoIncrement`,e.target.value),placeholder:n(`table.properties.autoIncrementPlaceholder`)})]})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{htmlFor:`prop-comment`,children:n(`table.properties.comment`)}),(0,V.jsx)(D,{id:`prop-comment`,value:e.comment,onChange:e=>r(`comment`,e.target.value)})]})]})}function ce({connectionId:e,database:t,tableName:n,columns:r,indexes:i,properties:a}){let o=C(e=>e.themeId),s=ne(e),c=S(o),l=(0,R.useMemo)(()=>s.ddl.createTable(ie(t,n,r,i,a)),[s,t,n,r,i,a]);return(0,V.jsx)(`div`,{className:`h-[320px]`,children:(0,V.jsx)(_,{height:`100%`,language:`sql`,theme:c,value:l,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:13,lineNumbers:`on`,wordWrap:`on`}})})}function Z(e){return JSON.stringify([e.type,e.length,e.defaultValue,e.pk,e.notNull,e.unsigned,e.autoIncrement,e.zerofill,e.comment])}function Q(e){return{name:e.field,type:e.length?`${e.type}(${e.length})`:e.type,nullable:!e.notNull,key:e.pk?`PRI`:``,defaultValue:e.defaultValue===``?null:e.defaultValue,extra:e.autoIncrement?`auto_increment`:``,comment:e.comment,collation:null}}function $(e){return{name:e.name,type:e.type,columns:[...e.columns]}}function le(e,t){return e.name===t.name&&e.type===t.type&&e.columns.join(`,`)===t.columns.join(`,`)}function ue({engine:e,database:t,table:n,before:r,after:i}){let{ddl:a}=e,o=[],s=[],c=[],l=new Map(r.columns.map(e=>[e.id,e])),u=new Map(i.columns.map(e=>[e.id,e])),d=new Map(r.indexes.map(e=>[e.id,e])),f=new Map(i.indexes.map(e=>[e.id,e])),p=[];for(let[e,r]of d){let i=f.get(e);i?le(r,i)||(o.push(a.dropIndex(t,n,r.name)),p.push(i)):o.push(a.dropIndex(t,n,r.name))}for(let[e,r]of u){let i=l.get(e);if(!i){r.field.trim()&&o.push(a.addColumn(t,n,Q(r)));continue}if(i.field!==r.field&&o.push(a.renameColumn(t,n,i.field,r.field)),Z(i)!==Z(r)){let e=a.alterColumn(t,n,Q(r));e?o.push(e):c.push(r.field)}}for(let[e,r]of l)if(!u.has(e)){let e=a.dropColumn(t,n,r.field);o.push(e),s.push(e)}for(let e of p)o.push(a.createIndex(t,n,$(e)));for(let[e,r]of f)!d.has(e)&&r.columns.length>0&&o.push(a.createIndex(t,n,$(r)));return{statements:o,destructive:s,unsupported:c}}function de(){let{t:e}=a(),{activeDialog:t,closeDialog:i}=n(),s=r(`create-table`,`alter-table`,`duplicate-table-structure`),c=t===`create-table`||t===`alter-table`||t===`duplicate-table-structure`,l=t===`alter-table`,u=t===`duplicate-table-structure`,d=s?.nodeText??``,_=s?.metadata?.database??``,[v,x]=(0,R.useState)(``),[S,C]=(0,R.useState)([z()]),[w,O]=(0,R.useState)([]),[k,A]=(0,R.useState)(re()),[j,M]=(0,R.useState)(!1),[B,H]=(0,R.useState)(!1),[U,W]=(0,R.useState)(null),[G,K]=(0,R.useState)(null),q=s?.connectionId??f.getState().activeConnectionId,J=ne(q);(0,R.useEffect)(()=>{c&&(W(null),K(null),l||u?(x(u?`${d}_copy`:d),Y()):(x(``),C([z()]),O([]),A(re())))},[c,t]);async function Y(){let e=f.getState(),t=s?.connectionId??e.activeConnectionId,n=e.activeConnections.find(e=>e.id===t)?.serverConnectionId;if(!n||!_||!d)return;M(!0);let{introspect:r,capabilities:i}=m(t),a=p(n);try{let e=await r.listColumns(a,_,d),t=[];if(e.length>0){let n=e.map(e=>{let t=e.type,n=t.match(/^(\w+)(?:\(([^)]+)\))?/);return{id:crypto.randomUUID(),field:e.name,type:n?.[1]?.toLowerCase()??t.toLowerCase(),length:n?.[2]??``,defaultValue:e.defaultValue??``,pk:e.key===`PRI`,notNull:!e.nullable,unsigned:t.includes(`unsigned`),autoIncrement:e.extra.includes(`auto_increment`),zerofill:t.includes(`zerofill`),comment:e.comment}});C(n),t=n}let n=await r.listIndexes(a,_,d),o=[];if(n.length>0&&(o=n.map(e=>({id:crypto.randomUUID(),name:e.name,type:e.type===`SPATIAL`?`INDEX`:e.type,columns:[...e.columns]})),O(o)),K({columns:t,indexes:o}),i.tableProperties){let e=await r.getTableInfo(a,_,d);e&&A({engine:e.engine??`InnoDB`,charset:(e.collation??`utf8mb4`).replace(/_.*/,``),collation:e.collation??`utf8mb4_unicode_ci`,autoIncrement:e.autoIncrement??``,comment:e.comment})}}catch(e){console.error(`Failed to load table schema:`,e),W(e instanceof Error?e.message:String(e))}finally{M(!1)}}function X(e){e||i()}async function Z(){let t=s?.connectionId??f.getState().activeConnectionId;if(!t||!v.trim())return;let n=m(t);W(null);let r,a=[];if(l){if(!G)return;let t=ue({engine:n,database:_,table:d,before:G,after:{columns:S,indexes:w}});if(t.unsupported.length>0){W(e(`table.dialog.cannotAlterColumns`,{engine:n.label,columns:t.unsupported.join(`, `)}));return}if(t.statements.length===0){i();return}r=t.statements.join(`
|
|
2
2
|
`),a=t.destructive}else{let e=u?w.map(e=>({...e,name:ee(e.name,d,v.trim())})):w;r=n.ddl.createTable(ie(_,v.trim(),S,e,k))}H(!0);try{await h(t,r,{skipDestructiveConfirm:a.length===0}),await g(t,_),i()}catch(e){W(e instanceof Error?e.message:String(e))}finally{H(!1)}}let Q=e(l?`table.dialog.alterTitle`:u?`table.dialog.duplicateTitle`:`table.dialog.createTitle`),$=e(l?`table.dialog.alter`:`table.dialog.create`);return(0,V.jsx)(L,{open:c,onOpenChange:X,children:(0,V.jsxs)(F,{className:`sm:max-w-[1000px] max-h-[80vh] flex flex-col`,children:[(0,V.jsx)(N,{children:(0,V.jsx)(I,{children:Q})}),(0,V.jsxs)(`div`,{className:`space-y-3 flex-1 overflow-hidden flex flex-col min-h-0`,children:[(0,V.jsxs)(`div`,{className:`space-y-1.5 px-1`,children:[(0,V.jsx)(T,{htmlFor:`table-name`,children:e(`table.dialog.tableName`)}),(0,V.jsx)(D,{id:`table-name`,value:v,onChange:e=>x(e.target.value),placeholder:e(`table.dialog.tableNamePlaceholder`),disabled:l})]}),j?(0,V.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-muted-foreground text-sm`,children:e(`table.dialog.loading`)}):(0,V.jsxs)(b,{defaultValue:`schema`,className:`flex-1 min-h-0 flex flex-col`,children:[(0,V.jsxs)(te,{children:[(0,V.jsx)(E,{value:`schema`,children:e(`table.dialog.tabSchema`)}),(0,V.jsx)(E,{value:`indexes`,children:e(`table.dialog.tabIndexes`)}),J.capabilities.tableProperties&&(0,V.jsx)(E,{value:`properties`,children:e(`table.dialog.tabProperties`)}),(0,V.jsx)(E,{value:`sql`,children:`SQL`})]}),(0,V.jsx)(y,{value:`schema`,className:`flex-1 min-h-0 overflow-auto border rounded-md`,children:(0,V.jsx)(ae,{columns:S,onChange:C})}),(0,V.jsx)(y,{value:`indexes`,className:`flex-1 min-h-0 overflow-auto border rounded-md`,children:(0,V.jsx)(oe,{indexes:w,availableColumns:S,onChange:O})}),(0,V.jsx)(y,{value:`properties`,className:`flex-1 min-h-0 overflow-auto border rounded-md`,children:(0,V.jsx)(se,{properties:k,onChange:A})}),(0,V.jsx)(y,{value:`sql`,className:`flex-1 min-h-0 border rounded-md`,children:(0,V.jsx)(ce,{connectionId:q,database:_,tableName:v,columns:S,indexes:w,properties:k})})]})]}),U&&(0,V.jsx)(`p`,{className:`px-1 text-xs text-destructive leading-relaxed`,children:U}),(0,V.jsxs)(P,{children:[(0,V.jsx)(o,{variant:`outline`,onClick:()=>X(!1),children:e(`table.dialog.cancel`)}),(0,V.jsx)(o,{onClick:()=>void Z(),disabled:j||B||!v.trim(),children:B?e(`table.dialog.applying`):$})]})]})})}export{de as EditSchemaDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./hePW80VL.js";import{h as t}from"./XzPc-eVf.js";import{b as n,l as r,o as i,p as a,s as o,u as s}from"./CKOS5Y-e.js";import{r as c,t as l}from"./CytzrZ6l.js";import{S as u,_ as d,b as f,d as p,f as m,g as h,h as g,m as _,p as v,u as y,v as b,x,y as S}from"./CZQ1r4zz.js";import{n as C,t as w}from"./BVrYyQUV.js";import{t as T}from"./CmJ3siBN.js";import{Lt as E,Qt as D,Rt as O,Xt as k,Yt as A,Zt as j}from"./Bxw3grU1.js";var M=e(n(),1),N=e(t(),1),P=Object.defineProperty,ee=(e,t)=>P(e,`name`,{value:t,configurable:!0});function F(e){let t=N.useRef({value:e,previous:e});return N.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}ee(F,`usePrevious`);var I=r(),L=Object.defineProperty,R=(e,t)=>L(e,`name`,{value:t,configurable:!0}),z=[` `,`Enter`,`ArrowUp`,`ArrowDown`],B=[` `,`Enter`],V=`Select`,[H,U,W]=l(V),[G,te]=u(V,[W,D]),K=D(),[ne,q]=G(V),[re,ie]=G(V);function J(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:f,disabled:p,required:m,form:h,internal_do_not_use_render:g}=e,_=K(t),[v,y]=N.useState(null),[b,x]=N.useState(null),[w,T]=N.useState(!1),E=C(l),[D,O]=S({prop:r,defaultProp:i??!1,onChange:a,caller:V}),[k,A]=S({prop:o,defaultProp:s,onChange:c,caller:V}),M=N.useRef(null),P=N.useRef(k);N.useEffect(()=>{let e=h?v?.ownerDocument.getElementById(h):v?.form;if(e instanceof HTMLFormElement){let t=R(()=>A(P.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[h,v,A]);let ee=!v||!!h||!!v.closest(`form`),[F,L]=N.useState(new Set),z=d(),B=Array.from(F).map(e=>e.props.value).join(`;`),U=N.useCallback(e=>{L(t=>new Set(t).add(e))},[]),W=N.useCallback(e=>{L(t=>{let n=new Set(t);return n.delete(e),n})},[]),G={required:m,trigger:v,onTriggerChange:y,valueNode:b,onValueNodeChange:x,valueNodeHasChildren:w,onValueNodeHasChildrenChange:T,contentId:z,value:k,onValueChange:A,open:D,onOpenChange:O,dir:E,triggerPointerDownPosRef:M,disabled:p,name:u,autoComplete:f,form:h,nativeOptions:F,nativeSelectKey:B,isFormControl:ee};return(0,I.jsx)(j,{..._,children:(0,I.jsx)(ne,{scope:t,...G,children:(0,I.jsx)(H.Provider,{scope:t,children:(0,I.jsx)(re,{scope:t,onNativeOptionAdd:U,onNativeOptionRemove:W,children:Ve(g)?g(G):n})})})})}R(J,`SelectProvider`);var ae=R(e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,I.jsx)(J,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,I.jsxs)(I.Fragment,{children:[n,e?(0,I.jsx)(Be,{__scopeSelect:t}):null]})})},`Select`),oe=`SelectTrigger`,se=N.forwardRef(R(function(e,t){let{__scopeSelect:n,disabled:r=!1,...i}=e,s=K(n),c=q(oe,n),l=c.disabled||r,u=a(t,c.onTriggerChange),d=U(n),f=N.useRef(`touch`),[p,m,h]=He(e=>{let t=d().filter(e=>!e.disabled),n=Ue(t,e,t.find(e=>e.value===c.value));n!==void 0&&c.onValueChange(n.value)}),g=R(e=>{l||(c.onOpenChange(!0),h()),e&&(c.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,I.jsx)(A,{asChild:!0,...s,children:(0,I.jsx)(o.button,{type:`button`,role:`combobox`,"aria-controls":c.open?c.contentId:void 0,"aria-expanded":c.open,"aria-required":c.required,"aria-autocomplete":`none`,dir:c.dir,"data-state":c.open?`open`:`closed`,disabled:l,"data-disabled":l?``:void 0,"data-placeholder":$(c.value)?``:void 0,...i,ref:u,onClick:x(i.onClick,e=>{e.currentTarget.focus(),f.current!==`mouse`&&g(e)}),onPointerDown:x(i.onPointerDown,e=>{f.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(g(e),e.preventDefault())}),onKeyDown:x(i.onKeyDown,e=>{let t=p.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&m(e.key),!(t&&e.key===` `)&&z.includes(e.key)&&(g(),e.preventDefault())})})})},`SelectTrigger`)),ce=`SelectValue`,le=N.forwardRef(R(function(e,t){let{__scopeSelect:n,className:r,style:i,children:s,placeholder:c=``,...l}=e,u=q(ce,n),{onValueNodeHasChildrenChange:d}=u,p=s!==void 0,m=a(t,u.onValueNodeChange);f(()=>{d(p)},[d,p]);let h=$(u.value);return(0,I.jsx)(o.span,{...l,asChild:!h&&l.asChild,ref:m,style:{pointerEvents:`none`},children:(0,I.jsx)(N.Fragment,{children:h?c:s},h?`placeholder`:`value`)})},`SelectValue`)),ue=N.forwardRef(R(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,I.jsx)(o.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})},`SelectIcon`)),[de,fe]=G(`SelectPortal`,{forceMount:void 0}),pe=R(e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,I.jsx)(de,{scope:e.__scopeSelect,forceMount:n,children:(0,I.jsx)(v,{asChild:!0,...r})})},`SelectPortal`),Y=`SelectContent`,me=N.forwardRef(R(function(e,t){let n=fe(Y,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=q(Y,e.__scopeSelect),[o,s]=N.useState();return f(()=>{s(new DocumentFragment)},[]),(0,I.jsx)(b,{present:r||a.open,children:({present:e})=>e?(0,I.jsx)(ve,{...i,ref:t}):(0,I.jsx)(he,{...i,fragment:o})})},`SelectContent`)),he=N.forwardRef(R(function(e,t){let{__scopeSelect:n,children:r,fragment:i}=e;return i?M.createPortal((0,I.jsx)(ge,{scope:n,children:(0,I.jsx)(H.Slot,{scope:n,children:(0,I.jsx)(`div`,{ref:t,children:r})})}),i):null},`SelectContentFragment`)),X=10,[ge,Z]=G(Y),_e=s(`SelectContent.RemoveScroll`),ve=N.forwardRef(R(function(e,t){let{__scopeSelect:n}=e,{position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:o,onPointerDownOutside:s,side:c,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:v,sticky:b,hideWhenDetached:S,avoidCollisions:C,...w}=e,T=q(Y,n),[E,D]=N.useState(null),[O,k]=N.useState(null),A=a(t,D),[j,M]=N.useState(null),[P,ee]=N.useState(null),F=U(n),[L,z]=N.useState(!1),B=N.useRef(!1);N.useEffect(()=>{if(E)return y(E)},[E]),m();let V=N.useCallback(e=>{let[t,...n]=F().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&O&&(O.scrollTop=0),n===r&&O&&(O.scrollTop=O.scrollHeight),n?.focus(),document.activeElement!==i))return},[F,O]),H=N.useCallback(()=>V([j,E]),[V,j,E]);N.useEffect(()=>{L&&H()},[L,H]);let{onOpenChange:W,triggerPointerDownPosRef:G}=T;N.useEffect(()=>{if(E){let e={x:0,y:0},t=R(t=>{e={x:Math.abs(Math.round(t.pageX)-(G.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(G.current?.y??0))}},`handlePointerMove`),n=R(n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(E)||W(!1),document.removeEventListener(`pointermove`,t),G.current=null},`handlePointerUp`);return G.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[E,W,G]),N.useEffect(()=>{let e=R(()=>W(!1),`close`);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[W]);let[te,K]=He(e=>{let t=F().filter(e=>!e.disabled),n=Ue(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),ne=N.useCallback((e,t,n)=>{let r=!B.current&&!n;(T.value!==void 0&&T.value===t||r)&&(M(e),r&&(B.current=!0))},[T.value]),re=N.useCallback(()=>E?.focus(),[E]),ie=N.useCallback((e,t,n)=>{let r=!B.current&&!n;(T.value!==void 0&&T.value===t||r)&&ee(e)},[T.value]),J=r===`popper`?be:ye,ae=J===be?{side:c,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:v,sticky:b,hideWhenDetached:S,avoidCollisions:C}:{};return(0,I.jsx)(ge,{scope:n,content:E,viewport:O,onViewportChange:k,itemRefCallback:ne,selectedItem:j,onItemLeave:re,itemTextRefCallback:ie,focusSelectedItem:H,selectedItemText:P,position:r,isPositioned:L,searchRef:te,children:(0,I.jsx)(p,{as:_e,allowPinchZoom:!0,children:(0,I.jsx)(_,{asChild:!0,trapped:T.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:x(i,e=>{T.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,I.jsx)(g,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>T.onOpenChange(!1),children:(0,I.jsx)(J,{role:`listbox`,id:T.contentId,"data-state":T.open?`open`:`closed`,dir:T.dir,onContextMenu:e=>e.preventDefault(),...w,...ae,onPlaced:()=>z(!0),ref:A,style:{display:`flex`,flexDirection:`column`,outline:`none`,...w.style},onKeyDown:x(w.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&K(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=F().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>V(t)),e.preventDefault()}})})})})})})},`SelectContentImpl`)),ye=N.forwardRef(R(function(e,t){let{__scopeSelect:n,onPlaced:r,...i}=e,s=q(Y,n),c=Z(Y,n),[l,u]=N.useState(null),[d,p]=N.useState(null),m=a(t,p),h=U(n),g=N.useRef(!1),_=N.useRef(!0),{viewport:v,selectedItem:y,selectedItemText:b,focusSelectedItem:x}=c,S=N.useCallback(()=>{if(s.trigger&&s.valueNode&&l&&d&&v&&y&&b){let e=s.trigger.getBoundingClientRect(),t=d.getBoundingClientRect(),n=s.valueNode.getBoundingClientRect(),i=b.getBoundingClientRect();if(s.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,s=e.width+o,c=Math.max(s,t.width),u=window.innerWidth-X,d=w(a,[X,Math.max(X,u-c)]);l.style.minWidth=s+`px`,l.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,s=e.width+o,c=Math.max(s,t.width),u=window.innerWidth-X,d=w(a,[X,Math.max(X,u-c)]);l.style.minWidth=s+`px`,l.style.right=d+`px`}let a=h(),o=window.innerHeight-X*2,c=v.scrollHeight,u=window.getComputedStyle(d),f=parseInt(u.borderTopWidth,10),p=parseInt(u.paddingTop,10),m=parseInt(u.borderBottomWidth,10),_=parseInt(u.paddingBottom,10),x=f+p+c+_+m,S=Math.min(y.offsetHeight*5,x),C=window.getComputedStyle(v),T=parseInt(C.paddingTop,10),E=parseInt(C.paddingBottom,10),D=e.top+e.height/2-X,O=o-D,k=y.offsetHeight/2,A=y.offsetTop+k,j=f+p+A,M=x-j;if(j<=D){let e=a.length>0&&y===a[a.length-1].ref.current;l.style.bottom=`0px`;let t=d.clientHeight-v.offsetTop-v.offsetHeight,n=j+Math.max(O,k+(e?E:0)+t+m);l.style.height=n+`px`}else{let e=a.length>0&&y===a[0].ref.current;l.style.top=`0px`;let t=Math.max(D,f+v.offsetTop+(e?T:0)+k)+M;l.style.height=t+`px`,v.scrollTop=j-D+v.offsetTop}l.style.margin=`${X}px 0`,l.style.minHeight=S+`px`,l.style.maxHeight=o+`px`,r?.(),requestAnimationFrame(()=>g.current=!0)}},[h,s.trigger,s.valueNode,l,d,v,y,b,s.dir,r]);f(()=>S(),[S]);let[C,T]=N.useState();f(()=>{d&&T(window.getComputedStyle(d).zIndex)},[d]);let E=N.useCallback(e=>{e&&_.current===!0&&(S(),x?.(),_.current=!1)},[S,x]);return(0,I.jsx)(xe,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:g,onScrollButtonChange:E,children:(0,I.jsx)(`div`,{ref:u,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:C},children:(0,I.jsx)(o.div,{...i,ref:m,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})},`SelectItemAlignedPosition`)),be=N.forwardRef(R(function(e,t){let{__scopeSelect:n,align:r=`start`,collisionPadding:i=X,...a}=e,o=K(n);return(0,I.jsx)(k,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})},`SelectPopperPosition`)),[xe,Se]=G(Y,{}),Ce=`SelectViewport`,we=N.forwardRef(R(function(e,t){let{__scopeSelect:n,nonce:r,...i}=e,s=Z(Ce,n),c=Se(Ce,n),l=a(t,s.onViewportChange),u=N.useRef(0);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,I.jsx)(H.Slot,{scope:n,children:(0,I.jsx)(o.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:l,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:x(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=c;if(r?.current&&n){let e=Math.abs(u.current-t.scrollTop);if(e>0){let r=window.innerHeight-X*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}u.current=t.scrollTop})})})]})},`SelectViewport`)),[Te,Ee]=G(`SelectGroup`),De=`SelectItem`,[Oe,ke]=G(De),Ae=N.forwardRef(R(function(e,t){let{__scopeSelect:n,value:r,disabled:i=!1,textValue:s,...c}=e,l=q(De,n),u=Z(De,n),f=l.value===r,[p,m]=N.useState(s??``),[g,_]=N.useState(!1),v=h(e=>u.itemRefCallback?.(e,r,i)),y=a(t,v),b=d(),S=N.useRef(`touch`),C=R(()=>{i||(l.onValueChange(r),l.onOpenChange(!1))},`handleSelect`);return(0,I.jsx)(Oe,{scope:n,value:r,disabled:i,textId:b,isSelected:f,onItemTextChange:N.useCallback(e=>{m(t=>t||(e?.textContent??``).trim())},[]),children:(0,I.jsx)(H.ItemSlot,{scope:n,value:r,disabled:i,textValue:p,children:(0,I.jsx)(o.div,{role:`option`,"aria-labelledby":b,"data-highlighted":g?``:void 0,"aria-selected":f&&g,"data-state":f?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...c,ref:y,onFocus:x(c.onFocus,()=>_(!0)),onBlur:x(c.onBlur,()=>_(!1)),onClick:x(c.onClick,()=>{S.current!==`mouse`&&C()}),onPointerUp:x(c.onPointerUp,()=>{S.current===`mouse`&&C()}),onPointerDown:x(c.onPointerDown,e=>{S.current=e.pointerType}),onPointerMove:x(c.onPointerMove,e=>{S.current=e.pointerType,i?u.onItemLeave?.():S.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:x(c.onPointerLeave,e=>{e.currentTarget===document.activeElement&&u.onItemLeave?.()}),onKeyDown:x(c.onKeyDown,e=>{i||e.target!==e.currentTarget||(u.searchRef?.current===``||e.key!==` `)&&(B.includes(e.key)&&C(),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),Q=`SelectItemText`,je=N.forwardRef(R(function(e,t){let{__scopeSelect:n,className:r,style:i,...s}=e,c=q(Q,n),l=Z(Q,n),u=ke(Q,n),d=ie(Q,n),[p,m]=N.useState(null),g=h(e=>l.itemTextRefCallback?.(e,u.value,u.disabled)),_=a(t,m,u.onItemTextChange,g),v=p?.textContent,y=N.useMemo(()=>(0,I.jsx)(`option`,{value:u.value,disabled:u.disabled,children:v},u.value),[u.disabled,u.value,v]),{onNativeOptionAdd:b,onNativeOptionRemove:x}=d;return f(()=>(b(y),()=>x(y)),[b,x,y]),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o.span,{id:u.textId,...s,ref:_}),u.isSelected&&c.valueNode&&!c.valueNodeHasChildren&&!$(c.value)?M.createPortal(s.children,c.valueNode):null]})},`SelectItemText`)),Me=`SelectItemIndicator`,Ne=N.forwardRef(R(function(e,t){let{__scopeSelect:n,...r}=e;return ke(Me,n).isSelected?(0,I.jsx)(o.span,{"aria-hidden":!0,...r,ref:t}):null},`SelectItemIndicator`)),Pe=`SelectScrollUpButton`,Fe=N.forwardRef(R(function(e,t){let n=Z(Pe,e.__scopeSelect),r=Se(Pe,e.__scopeSelect),[i,o]=N.useState(!1),s=a(t,r.onScrollButtonChange);return f(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;o(e)};R(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,I.jsx)(Re,{...e,ref:s,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null},`SelectScrollUpButton`)),Ie=`SelectScrollDownButton`,Le=N.forwardRef(R(function(e,t){let n=Z(Ie,e.__scopeSelect),r=Se(Ie,e.__scopeSelect),[i,o]=N.useState(!1),s=a(t,r.onScrollButtonChange);return f(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;o(n)};R(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,I.jsx)(Re,{...e,ref:s,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null},`SelectScrollDownButton`)),Re=N.forwardRef(R(function(e,t){let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=Z(`SelectScrollButton`,n),s=N.useRef(null),c=U(n),l=N.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return N.useEffect(()=>()=>l(),[l]),f(()=>{c().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[c]),(0,I.jsx)(o.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:x(i.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(r,50))}),onPointerMove:x(i.onPointerMove,()=>{a.onItemLeave?.(),s.current===null&&(s.current=window.setInterval(r,50))}),onPointerLeave:x(i.onPointerLeave,()=>{l()})})},`SelectScrollButtonImpl`)),ze=`SelectBubbleInput`,Be=N.forwardRef(R(function({__scopeSelect:e,...t},n){let r=q(ze,e),{value:i,onValueChange:s,required:l,disabled:u,name:d,autoComplete:f,form:p}=r,{nativeOptions:m,nativeSelectKey:h}=r,g=N.useRef(null),_=a(n,g),v=i??``,y=F(v),b=Array.from(m).some(e=>(e.props.value??``)===``);return N.useEffect(()=>{let e=g.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(y!==v&&n){let t=new Event(`change`,{bubbles:!0});n.call(e,v),e.dispatchEvent(t)}},[y,v]),(0,I.jsxs)(o.select,{"aria-hidden":!0,required:l,tabIndex:-1,name:d,autoComplete:f,disabled:u,form:p,onChange:e=>s(e.target.value),...t,style:{...c,...t.style},ref:_,defaultValue:v,children:[$(i)&&!b?(0,I.jsx)(`option`,{value:``}):null,Array.from(m)]},h)},`SelectBubbleInput`));function Ve(e){return typeof e==`function`}R(Ve,`isFunction`);function $(e){return e===``||e===void 0}R($,`shouldShowPlaceholder`);function He(e){let t=h(e),n=N.useRef(``),r=N.useRef(0),i=N.useCallback(e=>{let i=n.current+e;t(i),R((function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(i)},[t]),a=N.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return N.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}R(He,`useTypeaheadSearch`);function Ue(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=We(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}R(Ue,`findNextItem`);function We(e,t){return e.map((n,r)=>e[(t+r)%e.length])}R(We,`wrapArray`);function Ge({...e}){return(0,I.jsx)(ae,{"data-slot":`select`,...e})}function Ke({...e}){return(0,I.jsx)(le,{"data-slot":`select-value`,...e})}function qe({className:e,size:t=`default`,children:n,...r}){return(0,I.jsxs)(se,{"data-slot":`select-trigger`,"data-size":t,className:i(`flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,I.jsx)(ue,{asChild:!0,children:(0,I.jsx)(E,{className:`size-4 opacity-50`})})]})}function Je({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...a}){return(0,I.jsx)(pe,{children:(0,I.jsxs)(me,{"data-slot":`select-content`,className:i(`relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover 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`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...a,children:[(0,I.jsx)(Xe,{}),(0,I.jsx)(we,{className:i(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,I.jsx)(Ze,{})]})})}function Ye({className:e,children:t,...n}){return(0,I.jsxs)(Ae,{"data-slot":`select-item`,className:i(`relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,I.jsx)(`span`,{"data-slot":`select-item-indicator`,className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,I.jsx)(Ne,{children:(0,I.jsx)(O,{className:`size-4`})})}),(0,I.jsx)(je,{children:t})]})}function Xe({className:e,...t}){return(0,I.jsx)(Fe,{"data-slot":`select-scroll-up-button`,className:i(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(T,{className:`size-4`})})}function Ze({className:e,...t}){return(0,I.jsx)(Le,{"data-slot":`select-scroll-down-button`,className:i(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(E,{className:`size-4`})})}export{Ke as a,qe as i,Je as n,Ye as r,Ge as t};
|
|
1
|
+
import{r as e}from"./hePW80VL.js";import{h as t}from"./XzPc-eVf.js";import{b as n,l as r,o as i,p as a,s as o,u as s}from"./CKOS5Y-e.js";import{r as c,t as l}from"./CytzrZ6l.js";import{S as u,_ as d,b as f,d as p,f as m,g as h,h as g,m as _,p as v,u as y,v as b,x,y as S}from"./CZQ1r4zz.js";import{n as C,t as w}from"./BVrYyQUV.js";import{t as T}from"./CmJ3siBN.js";import{Lt as E,Qt as D,Rt as O,Xt as k,Yt as A,Zt as j}from"./B_UAjgBr.js";var M=e(n(),1),N=e(t(),1),P=Object.defineProperty,ee=(e,t)=>P(e,`name`,{value:t,configurable:!0});function F(e){let t=N.useRef({value:e,previous:e});return N.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}ee(F,`usePrevious`);var I=r(),L=Object.defineProperty,R=(e,t)=>L(e,`name`,{value:t,configurable:!0}),z=[` `,`Enter`,`ArrowUp`,`ArrowDown`],B=[` `,`Enter`],V=`Select`,[H,U,W]=l(V),[G,te]=u(V,[W,D]),K=D(),[ne,q]=G(V),[re,ie]=G(V);function J(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:f,disabled:p,required:m,form:h,internal_do_not_use_render:g}=e,_=K(t),[v,y]=N.useState(null),[b,x]=N.useState(null),[w,T]=N.useState(!1),E=C(l),[D,O]=S({prop:r,defaultProp:i??!1,onChange:a,caller:V}),[k,A]=S({prop:o,defaultProp:s,onChange:c,caller:V}),M=N.useRef(null),P=N.useRef(k);N.useEffect(()=>{let e=h?v?.ownerDocument.getElementById(h):v?.form;if(e instanceof HTMLFormElement){let t=R(()=>A(P.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[h,v,A]);let ee=!v||!!h||!!v.closest(`form`),[F,L]=N.useState(new Set),z=d(),B=Array.from(F).map(e=>e.props.value).join(`;`),U=N.useCallback(e=>{L(t=>new Set(t).add(e))},[]),W=N.useCallback(e=>{L(t=>{let n=new Set(t);return n.delete(e),n})},[]),G={required:m,trigger:v,onTriggerChange:y,valueNode:b,onValueNodeChange:x,valueNodeHasChildren:w,onValueNodeHasChildrenChange:T,contentId:z,value:k,onValueChange:A,open:D,onOpenChange:O,dir:E,triggerPointerDownPosRef:M,disabled:p,name:u,autoComplete:f,form:h,nativeOptions:F,nativeSelectKey:B,isFormControl:ee};return(0,I.jsx)(j,{..._,children:(0,I.jsx)(ne,{scope:t,...G,children:(0,I.jsx)(H.Provider,{scope:t,children:(0,I.jsx)(re,{scope:t,onNativeOptionAdd:U,onNativeOptionRemove:W,children:Ve(g)?g(G):n})})})})}R(J,`SelectProvider`);var ae=R(e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,I.jsx)(J,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,I.jsxs)(I.Fragment,{children:[n,e?(0,I.jsx)(Be,{__scopeSelect:t}):null]})})},`Select`),oe=`SelectTrigger`,se=N.forwardRef(R(function(e,t){let{__scopeSelect:n,disabled:r=!1,...i}=e,s=K(n),c=q(oe,n),l=c.disabled||r,u=a(t,c.onTriggerChange),d=U(n),f=N.useRef(`touch`),[p,m,h]=He(e=>{let t=d().filter(e=>!e.disabled),n=Ue(t,e,t.find(e=>e.value===c.value));n!==void 0&&c.onValueChange(n.value)}),g=R(e=>{l||(c.onOpenChange(!0),h()),e&&(c.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,I.jsx)(A,{asChild:!0,...s,children:(0,I.jsx)(o.button,{type:`button`,role:`combobox`,"aria-controls":c.open?c.contentId:void 0,"aria-expanded":c.open,"aria-required":c.required,"aria-autocomplete":`none`,dir:c.dir,"data-state":c.open?`open`:`closed`,disabled:l,"data-disabled":l?``:void 0,"data-placeholder":$(c.value)?``:void 0,...i,ref:u,onClick:x(i.onClick,e=>{e.currentTarget.focus(),f.current!==`mouse`&&g(e)}),onPointerDown:x(i.onPointerDown,e=>{f.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(g(e),e.preventDefault())}),onKeyDown:x(i.onKeyDown,e=>{let t=p.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&m(e.key),!(t&&e.key===` `)&&z.includes(e.key)&&(g(),e.preventDefault())})})})},`SelectTrigger`)),ce=`SelectValue`,le=N.forwardRef(R(function(e,t){let{__scopeSelect:n,className:r,style:i,children:s,placeholder:c=``,...l}=e,u=q(ce,n),{onValueNodeHasChildrenChange:d}=u,p=s!==void 0,m=a(t,u.onValueNodeChange);f(()=>{d(p)},[d,p]);let h=$(u.value);return(0,I.jsx)(o.span,{...l,asChild:!h&&l.asChild,ref:m,style:{pointerEvents:`none`},children:(0,I.jsx)(N.Fragment,{children:h?c:s},h?`placeholder`:`value`)})},`SelectValue`)),ue=N.forwardRef(R(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,I.jsx)(o.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})},`SelectIcon`)),[de,fe]=G(`SelectPortal`,{forceMount:void 0}),pe=R(e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,I.jsx)(de,{scope:e.__scopeSelect,forceMount:n,children:(0,I.jsx)(v,{asChild:!0,...r})})},`SelectPortal`),Y=`SelectContent`,me=N.forwardRef(R(function(e,t){let n=fe(Y,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=q(Y,e.__scopeSelect),[o,s]=N.useState();return f(()=>{s(new DocumentFragment)},[]),(0,I.jsx)(b,{present:r||a.open,children:({present:e})=>e?(0,I.jsx)(ve,{...i,ref:t}):(0,I.jsx)(he,{...i,fragment:o})})},`SelectContent`)),he=N.forwardRef(R(function(e,t){let{__scopeSelect:n,children:r,fragment:i}=e;return i?M.createPortal((0,I.jsx)(ge,{scope:n,children:(0,I.jsx)(H.Slot,{scope:n,children:(0,I.jsx)(`div`,{ref:t,children:r})})}),i):null},`SelectContentFragment`)),X=10,[ge,Z]=G(Y),_e=s(`SelectContent.RemoveScroll`),ve=N.forwardRef(R(function(e,t){let{__scopeSelect:n}=e,{position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:o,onPointerDownOutside:s,side:c,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:v,sticky:b,hideWhenDetached:S,avoidCollisions:C,...w}=e,T=q(Y,n),[E,D]=N.useState(null),[O,k]=N.useState(null),A=a(t,D),[j,M]=N.useState(null),[P,ee]=N.useState(null),F=U(n),[L,z]=N.useState(!1),B=N.useRef(!1);N.useEffect(()=>{if(E)return y(E)},[E]),m();let V=N.useCallback(e=>{let[t,...n]=F().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&O&&(O.scrollTop=0),n===r&&O&&(O.scrollTop=O.scrollHeight),n?.focus(),document.activeElement!==i))return},[F,O]),H=N.useCallback(()=>V([j,E]),[V,j,E]);N.useEffect(()=>{L&&H()},[L,H]);let{onOpenChange:W,triggerPointerDownPosRef:G}=T;N.useEffect(()=>{if(E){let e={x:0,y:0},t=R(t=>{e={x:Math.abs(Math.round(t.pageX)-(G.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(G.current?.y??0))}},`handlePointerMove`),n=R(n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(E)||W(!1),document.removeEventListener(`pointermove`,t),G.current=null},`handlePointerUp`);return G.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[E,W,G]),N.useEffect(()=>{let e=R(()=>W(!1),`close`);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[W]);let[te,K]=He(e=>{let t=F().filter(e=>!e.disabled),n=Ue(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),ne=N.useCallback((e,t,n)=>{let r=!B.current&&!n;(T.value!==void 0&&T.value===t||r)&&(M(e),r&&(B.current=!0))},[T.value]),re=N.useCallback(()=>E?.focus(),[E]),ie=N.useCallback((e,t,n)=>{let r=!B.current&&!n;(T.value!==void 0&&T.value===t||r)&&ee(e)},[T.value]),J=r===`popper`?be:ye,ae=J===be?{side:c,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:v,sticky:b,hideWhenDetached:S,avoidCollisions:C}:{};return(0,I.jsx)(ge,{scope:n,content:E,viewport:O,onViewportChange:k,itemRefCallback:ne,selectedItem:j,onItemLeave:re,itemTextRefCallback:ie,focusSelectedItem:H,selectedItemText:P,position:r,isPositioned:L,searchRef:te,children:(0,I.jsx)(p,{as:_e,allowPinchZoom:!0,children:(0,I.jsx)(_,{asChild:!0,trapped:T.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:x(i,e=>{T.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,I.jsx)(g,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>T.onOpenChange(!1),children:(0,I.jsx)(J,{role:`listbox`,id:T.contentId,"data-state":T.open?`open`:`closed`,dir:T.dir,onContextMenu:e=>e.preventDefault(),...w,...ae,onPlaced:()=>z(!0),ref:A,style:{display:`flex`,flexDirection:`column`,outline:`none`,...w.style},onKeyDown:x(w.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&K(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=F().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>V(t)),e.preventDefault()}})})})})})})},`SelectContentImpl`)),ye=N.forwardRef(R(function(e,t){let{__scopeSelect:n,onPlaced:r,...i}=e,s=q(Y,n),c=Z(Y,n),[l,u]=N.useState(null),[d,p]=N.useState(null),m=a(t,p),h=U(n),g=N.useRef(!1),_=N.useRef(!0),{viewport:v,selectedItem:y,selectedItemText:b,focusSelectedItem:x}=c,S=N.useCallback(()=>{if(s.trigger&&s.valueNode&&l&&d&&v&&y&&b){let e=s.trigger.getBoundingClientRect(),t=d.getBoundingClientRect(),n=s.valueNode.getBoundingClientRect(),i=b.getBoundingClientRect();if(s.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,s=e.width+o,c=Math.max(s,t.width),u=window.innerWidth-X,d=w(a,[X,Math.max(X,u-c)]);l.style.minWidth=s+`px`,l.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,s=e.width+o,c=Math.max(s,t.width),u=window.innerWidth-X,d=w(a,[X,Math.max(X,u-c)]);l.style.minWidth=s+`px`,l.style.right=d+`px`}let a=h(),o=window.innerHeight-X*2,c=v.scrollHeight,u=window.getComputedStyle(d),f=parseInt(u.borderTopWidth,10),p=parseInt(u.paddingTop,10),m=parseInt(u.borderBottomWidth,10),_=parseInt(u.paddingBottom,10),x=f+p+c+_+m,S=Math.min(y.offsetHeight*5,x),C=window.getComputedStyle(v),T=parseInt(C.paddingTop,10),E=parseInt(C.paddingBottom,10),D=e.top+e.height/2-X,O=o-D,k=y.offsetHeight/2,A=y.offsetTop+k,j=f+p+A,M=x-j;if(j<=D){let e=a.length>0&&y===a[a.length-1].ref.current;l.style.bottom=`0px`;let t=d.clientHeight-v.offsetTop-v.offsetHeight,n=j+Math.max(O,k+(e?E:0)+t+m);l.style.height=n+`px`}else{let e=a.length>0&&y===a[0].ref.current;l.style.top=`0px`;let t=Math.max(D,f+v.offsetTop+(e?T:0)+k)+M;l.style.height=t+`px`,v.scrollTop=j-D+v.offsetTop}l.style.margin=`${X}px 0`,l.style.minHeight=S+`px`,l.style.maxHeight=o+`px`,r?.(),requestAnimationFrame(()=>g.current=!0)}},[h,s.trigger,s.valueNode,l,d,v,y,b,s.dir,r]);f(()=>S(),[S]);let[C,T]=N.useState();f(()=>{d&&T(window.getComputedStyle(d).zIndex)},[d]);let E=N.useCallback(e=>{e&&_.current===!0&&(S(),x?.(),_.current=!1)},[S,x]);return(0,I.jsx)(xe,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:g,onScrollButtonChange:E,children:(0,I.jsx)(`div`,{ref:u,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:C},children:(0,I.jsx)(o.div,{...i,ref:m,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})},`SelectItemAlignedPosition`)),be=N.forwardRef(R(function(e,t){let{__scopeSelect:n,align:r=`start`,collisionPadding:i=X,...a}=e,o=K(n);return(0,I.jsx)(k,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})},`SelectPopperPosition`)),[xe,Se]=G(Y,{}),Ce=`SelectViewport`,we=N.forwardRef(R(function(e,t){let{__scopeSelect:n,nonce:r,...i}=e,s=Z(Ce,n),c=Se(Ce,n),l=a(t,s.onViewportChange),u=N.useRef(0);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,I.jsx)(H.Slot,{scope:n,children:(0,I.jsx)(o.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:l,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:x(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=c;if(r?.current&&n){let e=Math.abs(u.current-t.scrollTop);if(e>0){let r=window.innerHeight-X*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}u.current=t.scrollTop})})})]})},`SelectViewport`)),[Te,Ee]=G(`SelectGroup`),De=`SelectItem`,[Oe,ke]=G(De),Ae=N.forwardRef(R(function(e,t){let{__scopeSelect:n,value:r,disabled:i=!1,textValue:s,...c}=e,l=q(De,n),u=Z(De,n),f=l.value===r,[p,m]=N.useState(s??``),[g,_]=N.useState(!1),v=h(e=>u.itemRefCallback?.(e,r,i)),y=a(t,v),b=d(),S=N.useRef(`touch`),C=R(()=>{i||(l.onValueChange(r),l.onOpenChange(!1))},`handleSelect`);return(0,I.jsx)(Oe,{scope:n,value:r,disabled:i,textId:b,isSelected:f,onItemTextChange:N.useCallback(e=>{m(t=>t||(e?.textContent??``).trim())},[]),children:(0,I.jsx)(H.ItemSlot,{scope:n,value:r,disabled:i,textValue:p,children:(0,I.jsx)(o.div,{role:`option`,"aria-labelledby":b,"data-highlighted":g?``:void 0,"aria-selected":f&&g,"data-state":f?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...c,ref:y,onFocus:x(c.onFocus,()=>_(!0)),onBlur:x(c.onBlur,()=>_(!1)),onClick:x(c.onClick,()=>{S.current!==`mouse`&&C()}),onPointerUp:x(c.onPointerUp,()=>{S.current===`mouse`&&C()}),onPointerDown:x(c.onPointerDown,e=>{S.current=e.pointerType}),onPointerMove:x(c.onPointerMove,e=>{S.current=e.pointerType,i?u.onItemLeave?.():S.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:x(c.onPointerLeave,e=>{e.currentTarget===document.activeElement&&u.onItemLeave?.()}),onKeyDown:x(c.onKeyDown,e=>{i||e.target!==e.currentTarget||(u.searchRef?.current===``||e.key!==` `)&&(B.includes(e.key)&&C(),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),Q=`SelectItemText`,je=N.forwardRef(R(function(e,t){let{__scopeSelect:n,className:r,style:i,...s}=e,c=q(Q,n),l=Z(Q,n),u=ke(Q,n),d=ie(Q,n),[p,m]=N.useState(null),g=h(e=>l.itemTextRefCallback?.(e,u.value,u.disabled)),_=a(t,m,u.onItemTextChange,g),v=p?.textContent,y=N.useMemo(()=>(0,I.jsx)(`option`,{value:u.value,disabled:u.disabled,children:v},u.value),[u.disabled,u.value,v]),{onNativeOptionAdd:b,onNativeOptionRemove:x}=d;return f(()=>(b(y),()=>x(y)),[b,x,y]),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o.span,{id:u.textId,...s,ref:_}),u.isSelected&&c.valueNode&&!c.valueNodeHasChildren&&!$(c.value)?M.createPortal(s.children,c.valueNode):null]})},`SelectItemText`)),Me=`SelectItemIndicator`,Ne=N.forwardRef(R(function(e,t){let{__scopeSelect:n,...r}=e;return ke(Me,n).isSelected?(0,I.jsx)(o.span,{"aria-hidden":!0,...r,ref:t}):null},`SelectItemIndicator`)),Pe=`SelectScrollUpButton`,Fe=N.forwardRef(R(function(e,t){let n=Z(Pe,e.__scopeSelect),r=Se(Pe,e.__scopeSelect),[i,o]=N.useState(!1),s=a(t,r.onScrollButtonChange);return f(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;o(e)};R(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,I.jsx)(Re,{...e,ref:s,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null},`SelectScrollUpButton`)),Ie=`SelectScrollDownButton`,Le=N.forwardRef(R(function(e,t){let n=Z(Ie,e.__scopeSelect),r=Se(Ie,e.__scopeSelect),[i,o]=N.useState(!1),s=a(t,r.onScrollButtonChange);return f(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;o(n)};R(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,I.jsx)(Re,{...e,ref:s,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null},`SelectScrollDownButton`)),Re=N.forwardRef(R(function(e,t){let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=Z(`SelectScrollButton`,n),s=N.useRef(null),c=U(n),l=N.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return N.useEffect(()=>()=>l(),[l]),f(()=>{c().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[c]),(0,I.jsx)(o.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:x(i.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(r,50))}),onPointerMove:x(i.onPointerMove,()=>{a.onItemLeave?.(),s.current===null&&(s.current=window.setInterval(r,50))}),onPointerLeave:x(i.onPointerLeave,()=>{l()})})},`SelectScrollButtonImpl`)),ze=`SelectBubbleInput`,Be=N.forwardRef(R(function({__scopeSelect:e,...t},n){let r=q(ze,e),{value:i,onValueChange:s,required:l,disabled:u,name:d,autoComplete:f,form:p}=r,{nativeOptions:m,nativeSelectKey:h}=r,g=N.useRef(null),_=a(n,g),v=i??``,y=F(v),b=Array.from(m).some(e=>(e.props.value??``)===``);return N.useEffect(()=>{let e=g.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(y!==v&&n){let t=new Event(`change`,{bubbles:!0});n.call(e,v),e.dispatchEvent(t)}},[y,v]),(0,I.jsxs)(o.select,{"aria-hidden":!0,required:l,tabIndex:-1,name:d,autoComplete:f,disabled:u,form:p,onChange:e=>s(e.target.value),...t,style:{...c,...t.style},ref:_,defaultValue:v,children:[$(i)&&!b?(0,I.jsx)(`option`,{value:``}):null,Array.from(m)]},h)},`SelectBubbleInput`));function Ve(e){return typeof e==`function`}R(Ve,`isFunction`);function $(e){return e===``||e===void 0}R($,`shouldShowPlaceholder`);function He(e){let t=h(e),n=N.useRef(``),r=N.useRef(0),i=N.useCallback(e=>{let i=n.current+e;t(i),R((function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(i)},[t]),a=N.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return N.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}R(He,`useTypeaheadSearch`);function Ue(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=We(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}R(Ue,`findNextItem`);function We(e,t){return e.map((n,r)=>e[(t+r)%e.length])}R(We,`wrapArray`);function Ge({...e}){return(0,I.jsx)(ae,{"data-slot":`select`,...e})}function Ke({...e}){return(0,I.jsx)(le,{"data-slot":`select-value`,...e})}function qe({className:e,size:t=`default`,children:n,...r}){return(0,I.jsxs)(se,{"data-slot":`select-trigger`,"data-size":t,className:i(`flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,I.jsx)(ue,{asChild:!0,children:(0,I.jsx)(E,{className:`size-4 opacity-50`})})]})}function Je({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...a}){return(0,I.jsx)(pe,{children:(0,I.jsxs)(me,{"data-slot":`select-content`,className:i(`relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover 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`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...a,children:[(0,I.jsx)(Xe,{}),(0,I.jsx)(we,{className:i(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,I.jsx)(Ze,{})]})})}function Ye({className:e,children:t,...n}){return(0,I.jsxs)(Ae,{"data-slot":`select-item`,className:i(`relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,I.jsx)(`span`,{"data-slot":`select-item-indicator`,className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,I.jsx)(Ne,{children:(0,I.jsx)(O,{className:`size-4`})})}),(0,I.jsx)(je,{children:t})]})}function Xe({className:e,...t}){return(0,I.jsx)(Fe,{"data-slot":`select-scroll-up-button`,className:i(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(T,{className:`size-4`})})}function Ze({className:e,...t}){return(0,I.jsx)(Le,{"data-slot":`select-scroll-down-button`,className:i(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(E,{className:`size-4`})})}export{Ke as a,qe as i,Je as n,Ye as r,Ge as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./hePW80VL.js";import{h as t,n}from"./XzPc-eVf.js";import{l as r,m as i,t as a}from"./CKOS5Y-e.js";import{F as o,L as s,N as c,P as l,c as u,jt as d,l as f,nt as p}from"./
|
|
1
|
+
import{r as e}from"./hePW80VL.js";import{h as t,n}from"./XzPc-eVf.js";import{l as r,m as i,t as a}from"./CKOS5Y-e.js";import{F as o,L as s,N as c,P as l,c as u,jt as d,l as f,nt as p}from"./B_UAjgBr.js";import{a as m,i as h,n as g,o as _,r as v,t as y}from"./DxuXBECK.js";import{t as b}from"./CFzRFS2A.js";var x=e(t(),1);function S(){let e=s(e=>e.status.state===`valid`);return!o()||e}var C=r(),w={offline:`sync.offline`,server:`sync.serverError`,unauthorized:`sync.serverError`,conflict:`sync.serverError`,"bad-passphrase":`sync.wrongPassphrase`,malformed:`sync.wrongPassphrase`,unsupported:`sync.serverError`};function T(){let e=n(e=>e.activeDialog),t=n(e=>e.closeDialog),{phase:r,user:o,busy:s,error:T,lastSyncedAt:E,vault:D,refresh:O,createVault:k,unlock:A,push:j,signOut:M,forgetVault:N,closeAccount:P,setError:F}=c(),{t:I}=i(),L=S(),[R,z]=(0,x.useState)(``),[B,V]=(0,x.useState)(``),[H,U]=(0,x.useState)(!1),[W,G]=(0,x.useState)(!1);(0,x.useEffect)(()=>{O()},[O]);let K=R.length>0&&R.length<10,q=B.length>0&&R!==B,J=R.length>=10&&R===B,Y=T?I(w[T]??`sync.serverError`):null,X=D?Object.keys(D.profiles).length:0,Z=()=>{z(``),V(``),F(null)};return(0,C.jsx)(y,{open:e===`sync`,onOpenChange:e=>{e||t()},children:(0,C.jsxs)(g,{className:`max-h-[85vh] overflow-y-auto sm:max-w-[560px]`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,C.jsxs)(m,{children:[(0,C.jsx)(_,{children:I(`sync.title`)}),(0,C.jsxs)(v,{children:[I(`sync.description`),o&&(0,C.jsx)(`span`,{className:`mt-1 block text-xs`,children:I(`sync.signedInAs`,{email:o.email??o.id})})]})]}),(0,C.jsxs)(`div`,{className:`grid gap-3 text-sm`,children:[(0,C.jsx)(`p`,{className:`rounded-md border bg-muted/40 p-3 text-xs text-muted-foreground`,children:I(`sync.stored`)}),r===`unavailable`&&(0,C.jsx)(`p`,{className:`rounded-md border border-amber-500/40 bg-amber-500/5 p-3 text-xs text-amber-600 dark:text-amber-400`,children:p()?I(`sync.unavailable`):I(`sync.notDeployed`)}),r===`signed-out`&&(0,C.jsxs)(a,{onClick:()=>{window.location.href=l(`github`,window.location.href)},children:[(0,C.jsx)(d,{className:`size-4`}),I(`sync.signIn`)]}),o&&!L&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:I(`sync.needsPro`)}),(0,C.jsx)(b,{highlight:`sync`})]}),L&&r===`no-vault`&&(0,C.jsxs)(`div`,{className:`grid gap-2`,children:[(0,C.jsx)(`p`,{className:`text-sm font-medium`,children:I(`sync.createTitle`)}),(0,C.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:I(`sync.createHint`)}),(0,C.jsx)(u,{htmlFor:`sync-pass`,children:I(`sync.passphrase`)}),(0,C.jsx)(f,{id:`sync-pass`,type:`password`,autoComplete:`new-password`,value:R,onChange:e=>{z(e.target.value),F(null)}}),(0,C.jsx)(u,{htmlFor:`sync-confirm`,children:I(`sync.confirm`)}),(0,C.jsx)(f,{id:`sync-confirm`,type:`password`,autoComplete:`new-password`,value:B,onChange:e=>{V(e.target.value),F(null)}}),K&&(0,C.jsx)(`p`,{className:`text-xs text-destructive`,children:I(`sync.tooShort`,{count:10})}),q&&(0,C.jsx)(`p`,{className:`text-xs text-destructive`,children:I(`sync.mismatch`)}),(0,C.jsx)(a,{disabled:!J||s,onClick:()=>{k(R).then(Z)},children:I(`sync.enable`)})]}),L&&r===`locked`&&(0,C.jsxs)(`div`,{className:`grid gap-2`,children:[(0,C.jsx)(`p`,{className:`text-sm font-medium`,children:I(`sync.unlockTitle`)}),(0,C.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:I(`sync.unlockHint`)}),(0,C.jsx)(u,{htmlFor:`sync-unlock`,children:I(`sync.passphrase`)}),(0,C.jsx)(f,{id:`sync-unlock`,type:`password`,autoComplete:`current-password`,value:R,onChange:e=>{z(e.target.value),F(null)}}),(0,C.jsx)(a,{disabled:!R||s,onClick:()=>{A(R).then(Z)},children:I(`sync.unlock`)})]}),L&&r===`ready`&&(0,C.jsxs)(`div`,{className:`grid gap-2`,children:[(0,C.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[E?I(`sync.lastSynced`,{when:new Date(E).toLocaleString()}):I(`sync.neverSynced`),` · `,I(`sync.profiles`,{count:X})]}),(0,C.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,C.jsx)(a,{variant:`secondary`,disabled:s,onClick:()=>{U(!1),j()},children:I(`sync.syncNow`)}),(0,C.jsx)(a,{variant:`ghost`,disabled:s,onClick:()=>{c.getState().lock(),Z()},children:I(`sync.changePassphrase`)})]}),H?(0,C.jsxs)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 p-3`,children:[(0,C.jsx)(`p`,{className:`mb-2 text-xs`,children:I(`sync.deleteVaultConfirm`)}),(0,C.jsxs)(`div`,{className:`flex gap-2`,children:[(0,C.jsx)(a,{variant:`destructive`,disabled:s,onClick:()=>{N().then(()=>U(!1))},children:I(`sync.deleteVault`)}),(0,C.jsx)(a,{variant:`ghost`,onClick:()=>U(!1),children:I(`settings.done`)})]})]}):(0,C.jsx)(a,{variant:`ghost`,className:`justify-start px-0 text-destructive`,onClick:()=>U(!0),children:I(`sync.deleteVault`)})]}),o&&(W?(0,C.jsxs)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 p-3`,children:[(0,C.jsx)(`p`,{className:`mb-2 text-xs`,children:I(`sync.deleteAccountConfirm`)}),(0,C.jsxs)(`div`,{className:`flex gap-2`,children:[(0,C.jsx)(a,{variant:`destructive`,disabled:s,onClick:()=>{P().then(()=>G(!1))},children:I(`sync.deleteAccount`)}),(0,C.jsx)(a,{variant:`ghost`,onClick:()=>G(!1),children:I(`settings.done`)})]})]}):(0,C.jsx)(`button`,{type:`button`,onClick:()=>G(!0),className:`w-fit rounded-sm text-xs text-muted-foreground underline underline-offset-2 hover:text-destructive focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,children:I(`sync.deleteAccount`)})),s&&(0,C.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:I(`sync.working`)}),Y&&(0,C.jsx)(`p`,{className:`text-xs text-destructive`,children:Y})]}),(0,C.jsxs)(h,{children:[o&&(0,C.jsx)(a,{variant:`ghost`,disabled:s,onClick:()=>{M().then(Z)},children:I(`sync.signOut`)}),(0,C.jsx)(a,{onClick:t,children:I(`settings.done`)})]})]})})}export{T as SyncDialog};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/
|
|
2
|
-
import{r as e}from"./hePW80VL.js";import{c as t,h as n,n as r}from"./XzPc-eVf.js";import{a as i,i as a}from"./fDSXGLmI.js";import{_ as o,g as s,h as c,m as l,p as u,s as d,t as f}from"./B3nhMsGp.js";import{n as p}from"./BBSxV90W.js";import{D as m}from"./Ca4g4XbM.js";import{t as h}from"./Bit0Kfog.js";import{n as g}from"./BNkgLUl5.js";import{S as _,a as v,c as y}from"./CtXRSNHU.js";import{a as b}from"./BfSKVZnY.js";import{n as x,r as ee}from"./Cr6Fx4T5.js";import{i as te}from"./DAFA-E1-.js";import{c as S,d as C,f as w,l as ne,p as re,t as T}from"./CgWXabLX.js";import{n as E,t as D}from"./D8QuNkWm.js";function O(e){return f.getState().activeConnections.find(t=>t.id===e)?.database||D(_.getState().trees[e]??[])}function ie(e,t,n,r){return x(e).tree.objectPath(t,n,r,O(e))}function k(e,t){return x(e).tree.namespacePath(t,O(e))}function A(e,t){for(let n of e){if(n.id===t)return n;let e=A(n.children,t);if(e)return e}return null}async function ae(e,t,n){let r=_.getState;for(let i=0;i<t.length;i++){let a=r().trees[e];if(!a)return!1;let o=A(a,t[i]);if(!o)return!1;if(i===t.length-1)return r().setSelected(e,o.id),!0;o.children.length===0&&!o.isLeaf?await n(e,o):o.isExpanded||r().setExpanded(e,o.id,!0)}return!1}function j(e,t){for(let n of e){if(n.id===t)return n;let e=j(n.children,t);if(e)return e}return null}function M(e,t){let n=_.getState(),r=n.trees[e];if(!r||!t)return;let i=k(e,t),a=null;for(let t of i){let i=j(r,t);if(!i||(a=i,i.isLeaf))break;!i.isExpanded&&i.children.length>0&&n.setExpanded(e,i.id,!0)}!a||a.id!==i[i.length-1]||(n.setSelected(e,a.id),!a.isExpanded&&a.children.length>0&&n.setExpanded(e,a.id,!0))}var N=e(n(),1);function oe(e,t,n){let r=[];function i(e){for(let n of e){if(r.push(n),n.id===t||n.children.length>0&&i(n.children))return!0;r.pop()}return!1}i(e);for(let e=r.length-1;e>=0;e--)if(r[e].type===n)return r[e];return null}function P(e,t){for(let n of e){if(n.id===t)return n;if(n.children.length>0){let e=P(n.children,t);if(e)return e}}return null}var F=h(`schemaTreeLoadingRoots`,()=>new Set);h(`schemaTreeCacheWriter`,()=>{let e={};return _.subscribe(t=>{if(t.trees!==e){for(let[n,r]of Object.entries(t.trees)){if(r===e[n])continue;let t=f.getState().activeConnections.find(e=>e.id===n);t&&u(t)&&c(n,s(t),r)}e=t.trees}})});function I(e){let t=f.getState().activeConnections.find(t=>t.id===e);return t?.serverConnectionId?{engine:x(e),run:v(t.serverConnectionId),database:t.database||void 0}:null}function se(){let{setTree:e,setChildren:t,setNodeMetadata:n,setLoading:a}=_(),c=(0,N.useCallback)(async t=>{let n=I(t);if(n&&!F.has(t)){F.add(t);try{let r=f.getState().activeConnections.find(e=>e.id===t),i=r&&u(r)?await l(t,s(r)):null;e(t,i??await n.engine.tree.loadRoot(n))}catch(n){let a=n instanceof Error?n.message:String(n);console.error(`Failed to load databases:`,n),r.getState().setFooterMessage(i.t(`schema.tree.loadDatabasesFailed`,{message:a})),e(t,[])}finally{F.delete(t)}}},[e]),d=(0,N.useCallback)(async(e,r)=>{if(!_.getState().trees[e])return;let i=I(e);if(i&&!r.isLeaf){a(e,r.id,!0);try{let a=await i.engine.tree.loadChildren(i,r);t(e,r.id,a),Promise.all(a.filter(e=>e.type===o.FOLDER&&e.metadata?.countable).map(async t=>{try{let r=await i.engine.tree.loadChildren(i,t);n(e,t.id,{count:r.length})}catch(e){console.error(`Failed to count ${t.text}:`,e)}}))}catch(t){console.error(`Failed to load children:`,t),a(e,r.id,!1)}}},[t,n,a]);return{loadDatabases:c,loadChildren:d,refreshNode:(0,N.useCallback)(async(e,t)=>{await d(e,t)},[d]),createNode:b,findNode:P,findAncestor:oe}}async function L(e,t){T(e,t);let n=_.getState().trees[e];if(!n||!t)return;let r=I(e);if(!r)return;let i=k(e,t),a=E(n,i[i.length-1]);!a||a.children.length===0||await Promise.all(a.children.filter(e=>e.type===o.FOLDER).map(async t=>{try{let n=await r.engine.tree.loadChildren(r,t),i=_.getState();(t.children.length>0||t.isExpanded)&&i.setChildren(e,t.id,n),t.metadata?.countable&&i.setNodeMetadata(e,t.id,{count:n.length})}catch(e){console.error(`Failed to refresh ${t.text}:`,e)}}))}async function ce(e){T(e);let t=I(e);t&&_.getState().setTree(e,await t.engine.tree.loadRoot(t))}var R=class extends Error{sql;constructor(e,t){super(e),this.name=`QueryError`,this.sql=t}},z=class extends Error{constructor(e=`Cancelled`){super(e),this.name=`ExecutionCancelled`}};function B(e){let t=e.fields??[],n=e.records??[];return{fields:t.map(e=>({name:e.name,type:e.type,orgTable:e.orgTable??e.table??``,orgName:e.orgName??e.name,db:e.db??``})),rows:n.map(e=>{let n={};return t.forEach((t,r)=>{n[t.name]=e[r]}),n}),affectedRows:e.affectedRows??0,insertId:e.insertId??0,message:e.message??(n.length>0?i.t(`services.query.rowsReturned`,{count:n.length}):i.t(`services.query.rowsAffected`,{count:e.affectedRows??0}))}}async function V(e,t,n,r=ee(t),i){let a=new Set(e.fields.map(e=>e.orgTable).filter(Boolean));if(a.size!==1)return e;let o=[...a][0];try{let a=i??await r.introspect.getPrimaryKeys(v(t),n,o);a.length>0&&(e.primaryKeys=a)}catch{}return!e.primaryKeys?.length&&e.fields.some(e=>e.name===`_rowid_`)&&(e.primaryKeys=[m]),e}var H=new Set([`SELECT`,`SHOW`,`EXPLAIN`,`DESCRIBE`,`DESC`,`HELP`,`VALUES`,`TABLE`,`WITH`,`USE`,`SET`,`CHECK`,`CHECKSUM`]);function U(e){return e.kind===`PRAGMA`?!e.sql.includes(`=`):!(!H.has(e.kind)||e.destructive||e.kind===`SELECT`&&C(e,`INTO`))}var W=new Set([`INSERT`,`UPDATE`,`DELETE`,`REPLACE`,`MERGE`,`LOAD`]),le=new Set([`CREATE`,`ALTER`,`DROP`,`TRUNCATE`,`RENAME`,`GRANT`,`REVOKE`,`FLUSH`,`LOCK`,`UNLOCK`]),ue=new Set([`CREATE`,`ALTER`,`DROP`,`RENAME`]);function de(e){return W.has(e.kind)||!!e.destructive?.dataLoss}function G(e,t,n=`limit`){if(t<=0||e.kind!==`SELECT`||e.limit!==null||C(e,`LIMIT`)||C(e,`INTO`)||C(e,`FOR`)||C(e,`LOCK`))return{sql:e.sql,limited:!1};if(n===`top`){if(C(e,`TOP`)||C(e,`OFFSET`))return{sql:e.sql,limited:!1};let n=re(e);return n===-1?{sql:e.sql,limited:!1}:{sql:`${e.sql.slice(0,n)} TOP ${t}${e.sql.slice(n)}`,limited:!0}}return n===`fetch`?C(e,`FETCH`)||/\bROWNUM\b/i.test(e.sql)?{sql:e.sql,limited:!1}:{sql:`${e.sql} FETCH FIRST ${t} ROWS ONLY`,limited:!0}:{sql:`${e.sql} LIMIT ${t}`,limited:!0}}function fe(e,t=0){let n=K();return n<=0?``:e.limitClause(n,t)}function K(){return p.getState().resultRowLimit}function pe(e){let t=e.destructive,n=t.names.length?t.names.join(`, `):i.t(`services.destructive.unknownTarget`);switch(t.action){case`DROP`:return`DROP ${t.objectType} ${n}`;case`TRUNCATE`:return`TRUNCATE ${n}`;case`DELETE_ALL`:return i.t(`services.destructive.deleteAll`,{target:n});case`UPDATE_ALL`:return i.t(`services.destructive.updateAll`,{target:n});case`ALTER_DROP`:return i.t(`services.destructive.alterDrop`,{target:n})}}async function me(e){if(!p.getState().confirmDestructive)return!0;let t=e.filter(e=>e.destructive?.dataLoss);return t.length===0||r.getState().requestDestructiveConfirm({title:i.t(`services.destructive.title`,{count:t.length}),description:i.t(`services.destructive.description`),statements:t.map(pe),confirmLabel:i.t(`services.runAnyway`)})}async function he(e,t){if(!e.readOnly)return;let n=t.filter(e=>!U(e));if(n.length===0)return;let a=`${e.hostName||e.host}`;if(!p.getState().allowReadOnlyOverride)throw new R(i.t(`services.readOnly.refused`,{label:a,count:n.length}));if(!await r.getState().requestDestructiveConfirm({title:i.t(`services.readOnly.title`,{label:a}),description:i.t(`services.readOnly.description`),statements:n.map(e=>e.sql.length>120?e.sql.slice(0,117)+`...`:e.sql),confirmLabel:i.t(`services.runAnyway`)}))throw new z(`Cancelled: connection is read-only.`)}function q(e,t){let n=f.getState(),r=n.activeConnections.find(t=>t.id===e);if(!r?.serverConnectionId)throw new R(i.t(`services.query.notConnected`));if(n.pendingReopen[e])throw new R(i.t(`services.query.fileNotOpen`));return{connId:e,serverConnId:r.serverConnectionId,conn:r,engine:x(e),tabId:t}}async function J(e,t,n){let r=new S(e.engine).statements(t);if(e.conn.scratchpad){let{materializeFederated:t}=await a(async()=>{let{materializeFederated:e}=await import(`./Bxw3grU1.js`).then(e=>e.B);return{materializeFederated:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]));for(let n of r)n.sql=await t(e.connId,n.sql)}if(await he(e.conn,r),!n.skipDestructiveConfirm&&!await me(r))throw new z;return r}async function Y(e,n,a){let{connId:o,serverConnId:s,engine:c,tabId:l}=e,u=n.stmt?.kind??``,d=()=>f.getState();if(e.conn.transactionMode===`manual`&&c.capabilities.transactions&&n.stmt&&de(n.stmt)&&!d().transactionOpen[o]){let e=await y(s,c.getQuery(`START_TRANSACTION`),a||void 0);if(!e.success)throw new R(e.message??i.t(`services.transaction.startFailed`));d().setTransactionOpen(o,!0),r.getState().setFooterMessage(i.t(`services.transaction.started`))}let p=await y(s,n.sql,a||void 0);if(!p.success){let r=p.message??i.t(`services.query.failed`);throw g.getState().recordExecution({connectionId:o,tabId:l,query:n.sql,database:a,executionTime:p.execTime,error:r,kind:u||void 0}),t(`query_execute`,{dbms:e.conn.dbms,kind:u||`unknown`,source:l?`editor`:`app`,success:!1}),new R(r,n.sql)}let m=B(p);return u===`COMMIT`||u===`ROLLBACK`?d().setTransactionOpen(o,!1):u===`START`||u===`BEGIN`?d().setTransactionOpen(o,!0):le.has(u)&&d().transactionOpen[o]&&c.capabilities.implicitCommitDdl&&(d().setTransactionOpen(o,!1),r.getState().setFooterMessage(i.t(`services.transaction.implicitCommit`,{kind:u}))),ue.has(u)&&L(o,a),e.skipHistory||g.getState().recordExecution({connectionId:o,tabId:l,query:n.sql,database:a,executionTime:p.execTime,kind:u||void 0,...m.fields.length>0?{rowCount:m.rows.length}:{affectedRows:m.affectedRows}}),t(`query_execute`,{dbms:e.conn.dbms,kind:u||`unknown`,source:l?`editor`:`app`,success:!0,exec_time_ms:Math.round(p.execTime??0)}),{qr:m,execTime:p.execTime}}async function ge(e,t,n={}){let r=q(e,n.tabId??null);r.skipHistory=n.skipHistory;let a=t.trim();if(!a)throw new R(i.t(`services.query.nothingToExecute`));let o=await J(r,a,n),s=n.database??``;n.previewWrites&&p.getState().previewAffectedRows&&await Q(r,o,s);let c=o.length>0?o.map(e=>({sql:e.sql,stmt:e})):[{sql:a,stmt:null}],l=null;for(let e of c){let{qr:t}=await Y(r,e,s);n.primaryKeys&&t.fields.length>0&&s&&await V(t,r.serverConnId,s,r.engine,Array.isArray(n.primaryKeys)?n.primaryKeys:void 0),l=t}return l}function _e(e,t){return X(e,t)?.sql??null}function X(e,t){let n=g.getState().tabs[e]?.find(e=>e.id===t);if(!n)return null;let r=te(e,t);if(r&&`selection`in r)return{sql:r.selection,start:r.start};let i=r&&`cursorOffset`in r?r.cursorOffset:n.query.length,a=new S(x(e)).statements(n.query);if(a.length===0)return null;let o=a.find(e=>i>=w(e)&&i<=e.end)??[...a].reverse().find(e=>e.end<=i)??a[0];return{sql:o.sql,start:w(o)}}async function ve(e,n,r={}){let o=()=>g.getState(),s=o().tabs[e]?.find(e=>e.id===n);if(!s)return;let c=(r.sql??s.query)?.trim();if(!c)return;let l,u;try{l=q(e,n),u=await J(l,c,{})}catch(t){if(t instanceof z){t.message!==`Cancelled`&&o().setError(e,n,t.message);return}o().setError(e,n,t instanceof Error?t.message:String(t));return}let f=p.getState(),m=new Map;if(f.previewAffectedRows)try{m=await Q(l,u,s.database||``)}catch(e){if(e instanceof z)return;throw e}let h=m.size===1,_=u.length>0?u.map(e=>({...G(e,f.resultRowLimit,l.engine.syntax.limitStyle),stmt:e})):[{sql:c,limited:!1,stmt:null}],v=r.sql?r.sqlOffset??null:0;a(async()=>{let{readStructures:e}=await import(`./Bxw3grU1.js`).then(e=>e.tt);return{readStructures:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22])).then(({readStructures:t})=>t(e,n,u.length>0?u.map(e=>({sql:e.sql,start:v===null?null:v+w(e)})):[{sql:c,start:v}])),o().captureRevision(e,n,`execute`),o().setExecuting(e,n,!0),o().setError(e,n,null);let y=[],b=s.database||``;try{for(let r of _){let{qr:a,execTime:s}=await Y(l,r,b);if(a.sql=r.stmt?.sql??r.sql,a.executionTime=s,r.limited&&a.rows.length>=f.resultRowLimit&&(a.limited=!0,a.message=i.t(`services.query.rowsReturnedLimited`,{count:a.rows.length,limit:f.resultRowLimit})),!b&&a.fields.length>0){let t=a.fields.find(e=>e.db)?.db;t&&(b=t,o().setDatabase(e,n,b),M(e,b))}a.fields.length>0&&b&&await V(a,l.serverConnId,b,l.engine);let c=h&&r.stmt?m.get(r.stmt):void 0;c!==void 0&&Number.isFinite(a.affectedRows)&&a.affectedRows!==c&&(a.warning=i.t(`services.query.dryRunMismatch`,{predicted:c,actual:a.affectedRows}),t(`dry_run_mismatch`,{dbms:l.conn.dbms,kind:r.stmt?.kind??`unknown`})),y.push(a)}o().setResults(e,n,y)}catch(t){y.length>0&&o().setResults(e,n,y),o().setError(e,n,t instanceof Error?t.message:String(t),t instanceof R?t.sql:null),t instanceof R&&d(`query_error`)}finally{o().setExecuting(e,n,!1)}}var Z=50;function ye(e,t,n){return e.syntax.limitStyle===`top`?t.replace(/^SELECT\b/i,`SELECT TOP ${n}`):`${t} ${e.limitClause(n)}`}async function Q(e,t,n){let i=new Map;for(let a of t){if(a.kind!==`UPDATE`&&a.kind!==`DELETE`)continue;let t=ne(a);if(!t)continue;let o=null,s=[],c=[],l,u=await y(e.serverConnId,t.count,n||void 0);if(u.success){let r=Number(u.records[0]?.[0]);o=Number.isFinite(r)?r:null;let i=await y(e.serverConnId,t.limited?t.select:ye(e.engine,t.select,Z),n||void 0);i.success?(s=i.fields.map(e=>e.name),c=i.records):l=i.message}else l=u.message;if(!await r.getState().requestDryRun({statement:a.sql,previewSql:t.select,count:o,fields:s,rows:c,truncated:o!==null&&c.length<o,error:l}))throw new z;o!==null&&i.set(a,o)}return i}async function $(e,t){let n=f.getState(),a=n.activeConnections.find(t=>t.id===e);if(!a?.serverConnectionId)return;let o=x(e);try{let e=await y(a.serverConnectionId,o.getQuery(t));if(!e.success)throw new R(e.message??i.t(`services.transaction.commandFailed`,{name:t}));r.getState().setFooterMessage(t===`COMMIT`?i.t(`services.transaction.committed`):i.t(`services.transaction.rolledBack`))}catch(e){r.getState().setFooterMessage(i.t(`services.transaction.commandFailedWith`,{name:t,message:e instanceof Error?e.message:String(e)}))}finally{n.setTransactionOpen(e,!1)}}var be=e=>$(e,`COMMIT`),xe=e=>$(e,`ROLLBACK`);export{ae as _,ve as a,xe as c,K as d,fe as f,M as g,se as h,be as i,ge as l,ce as m,R as n,_e as o,L as p,G as r,U as s,z as t,X as u,ie as v};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/B_UAjgBr.js","assets/hePW80VL.js","assets/XzPc-eVf.js","assets/CKOS5Y-e.js","assets/fDSXGLmI.js","assets/CytzrZ6l.js","assets/CZQ1r4zz.js","assets/BVrYyQUV.js","assets/eFSiW0Lh.js","assets/B3nhMsGp.js","assets/BBSxV90W.js","assets/Ca4g4XbM.js","assets/Bit0Kfog.js","assets/BNkgLUl5.js","assets/CtXRSNHU.js","assets/BfSKVZnY.js","assets/Cr6Fx4T5.js","assets/DAFA-E1-.js","assets/CgWXabLX.js","assets/D8QuNkWm.js","assets/4_c4BD6i.js","assets/Bs5VSn0X.js","assets/MJ9qDdN_.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./hePW80VL.js";import{c as t,h as n,n as r}from"./XzPc-eVf.js";import{a as i,i as a}from"./fDSXGLmI.js";import{_ as o,g as s,h as c,m as l,p as u,s as d,t as f}from"./B3nhMsGp.js";import{n as p}from"./BBSxV90W.js";import{D as m}from"./Ca4g4XbM.js";import{t as h}from"./Bit0Kfog.js";import{n as g}from"./BNkgLUl5.js";import{S as _,a as v,c as y}from"./CtXRSNHU.js";import{a as b}from"./BfSKVZnY.js";import{n as x,r as ee}from"./Cr6Fx4T5.js";import{i as te}from"./DAFA-E1-.js";import{c as S,d as C,f as w,l as ne,p as re,t as T}from"./CgWXabLX.js";import{n as E,t as D}from"./D8QuNkWm.js";function O(e){return f.getState().activeConnections.find(t=>t.id===e)?.database||D(_.getState().trees[e]??[])}function ie(e,t,n,r){return x(e).tree.objectPath(t,n,r,O(e))}function k(e,t){return x(e).tree.namespacePath(t,O(e))}function A(e,t){for(let n of e){if(n.id===t)return n;let e=A(n.children,t);if(e)return e}return null}async function ae(e,t,n){let r=_.getState;for(let i=0;i<t.length;i++){let a=r().trees[e];if(!a)return!1;let o=A(a,t[i]);if(!o)return!1;if(i===t.length-1)return r().setSelected(e,o.id),!0;o.children.length===0&&!o.isLeaf?await n(e,o):o.isExpanded||r().setExpanded(e,o.id,!0)}return!1}function j(e,t){for(let n of e){if(n.id===t)return n;let e=j(n.children,t);if(e)return e}return null}function M(e,t){let n=_.getState(),r=n.trees[e];if(!r||!t)return;let i=k(e,t),a=null;for(let t of i){let i=j(r,t);if(!i||(a=i,i.isLeaf))break;!i.isExpanded&&i.children.length>0&&n.setExpanded(e,i.id,!0)}!a||a.id!==i[i.length-1]||(n.setSelected(e,a.id),!a.isExpanded&&a.children.length>0&&n.setExpanded(e,a.id,!0))}var N=e(n(),1);function oe(e,t,n){let r=[];function i(e){for(let n of e){if(r.push(n),n.id===t||n.children.length>0&&i(n.children))return!0;r.pop()}return!1}i(e);for(let e=r.length-1;e>=0;e--)if(r[e].type===n)return r[e];return null}function P(e,t){for(let n of e){if(n.id===t)return n;if(n.children.length>0){let e=P(n.children,t);if(e)return e}}return null}var F=h(`schemaTreeLoadingRoots`,()=>new Set);h(`schemaTreeCacheWriter`,()=>{let e={};return _.subscribe(t=>{if(t.trees!==e){for(let[n,r]of Object.entries(t.trees)){if(r===e[n])continue;let t=f.getState().activeConnections.find(e=>e.id===n);t&&u(t)&&c(n,s(t),r)}e=t.trees}})});function I(e){let t=f.getState().activeConnections.find(t=>t.id===e);return t?.serverConnectionId?{engine:x(e),run:v(t.serverConnectionId),database:t.database||void 0}:null}function se(){let{setTree:e,setChildren:t,setNodeMetadata:n,setLoading:a}=_(),c=(0,N.useCallback)(async t=>{let n=I(t);if(n&&!F.has(t)){F.add(t);try{let r=f.getState().activeConnections.find(e=>e.id===t),i=r&&u(r)?await l(t,s(r)):null;e(t,i??await n.engine.tree.loadRoot(n))}catch(n){let a=n instanceof Error?n.message:String(n);console.error(`Failed to load databases:`,n),r.getState().setFooterMessage(i.t(`schema.tree.loadDatabasesFailed`,{message:a})),e(t,[])}finally{F.delete(t)}}},[e]),d=(0,N.useCallback)(async(e,r)=>{if(!_.getState().trees[e])return;let i=I(e);if(i&&!r.isLeaf){a(e,r.id,!0);try{let a=await i.engine.tree.loadChildren(i,r);t(e,r.id,a),Promise.all(a.filter(e=>e.type===o.FOLDER&&e.metadata?.countable).map(async t=>{try{let r=await i.engine.tree.loadChildren(i,t);n(e,t.id,{count:r.length})}catch(e){console.error(`Failed to count ${t.text}:`,e)}}))}catch(t){console.error(`Failed to load children:`,t),a(e,r.id,!1)}}},[t,n,a]);return{loadDatabases:c,loadChildren:d,refreshNode:(0,N.useCallback)(async(e,t)=>{await d(e,t)},[d]),createNode:b,findNode:P,findAncestor:oe}}async function L(e,t){T(e,t);let n=_.getState().trees[e];if(!n||!t)return;let r=I(e);if(!r)return;let i=k(e,t),a=E(n,i[i.length-1]);!a||a.children.length===0||await Promise.all(a.children.filter(e=>e.type===o.FOLDER).map(async t=>{try{let n=await r.engine.tree.loadChildren(r,t),i=_.getState();(t.children.length>0||t.isExpanded)&&i.setChildren(e,t.id,n),t.metadata?.countable&&i.setNodeMetadata(e,t.id,{count:n.length})}catch(e){console.error(`Failed to refresh ${t.text}:`,e)}}))}async function ce(e){T(e);let t=I(e);t&&_.getState().setTree(e,await t.engine.tree.loadRoot(t))}var R=class extends Error{sql;constructor(e,t){super(e),this.name=`QueryError`,this.sql=t}},z=class extends Error{constructor(e=`Cancelled`){super(e),this.name=`ExecutionCancelled`}};function B(e){let t=e.fields??[],n=e.records??[];return{fields:t.map(e=>({name:e.name,type:e.type,orgTable:e.orgTable??e.table??``,orgName:e.orgName??e.name,db:e.db??``})),rows:n.map(e=>{let n={};return t.forEach((t,r)=>{n[t.name]=e[r]}),n}),affectedRows:e.affectedRows??0,insertId:e.insertId??0,message:e.message??(n.length>0?i.t(`services.query.rowsReturned`,{count:n.length}):i.t(`services.query.rowsAffected`,{count:e.affectedRows??0}))}}async function V(e,t,n,r=ee(t),i){let a=new Set(e.fields.map(e=>e.orgTable).filter(Boolean));if(a.size!==1)return e;let o=[...a][0];try{let a=i??await r.introspect.getPrimaryKeys(v(t),n,o);a.length>0&&(e.primaryKeys=a)}catch{}return!e.primaryKeys?.length&&e.fields.some(e=>e.name===`_rowid_`)&&(e.primaryKeys=[m]),e}var H=new Set([`SELECT`,`SHOW`,`EXPLAIN`,`DESCRIBE`,`DESC`,`HELP`,`VALUES`,`TABLE`,`WITH`,`USE`,`SET`,`CHECK`,`CHECKSUM`]);function U(e){return e.kind===`PRAGMA`?!e.sql.includes(`=`):!(!H.has(e.kind)||e.destructive||e.kind===`SELECT`&&C(e,`INTO`))}var W=new Set([`INSERT`,`UPDATE`,`DELETE`,`REPLACE`,`MERGE`,`LOAD`]),le=new Set([`CREATE`,`ALTER`,`DROP`,`TRUNCATE`,`RENAME`,`GRANT`,`REVOKE`,`FLUSH`,`LOCK`,`UNLOCK`]),ue=new Set([`CREATE`,`ALTER`,`DROP`,`RENAME`]);function de(e){return W.has(e.kind)||!!e.destructive?.dataLoss}function G(e,t,n=`limit`){if(t<=0||e.kind!==`SELECT`||e.limit!==null||C(e,`LIMIT`)||C(e,`INTO`)||C(e,`FOR`)||C(e,`LOCK`))return{sql:e.sql,limited:!1};if(n===`top`){if(C(e,`TOP`)||C(e,`OFFSET`))return{sql:e.sql,limited:!1};let n=re(e);return n===-1?{sql:e.sql,limited:!1}:{sql:`${e.sql.slice(0,n)} TOP ${t}${e.sql.slice(n)}`,limited:!0}}return n===`fetch`?C(e,`FETCH`)||/\bROWNUM\b/i.test(e.sql)?{sql:e.sql,limited:!1}:{sql:`${e.sql} FETCH FIRST ${t} ROWS ONLY`,limited:!0}:{sql:`${e.sql} LIMIT ${t}`,limited:!0}}function fe(e,t=0){let n=K();return n<=0?``:e.limitClause(n,t)}function K(){return p.getState().resultRowLimit}function pe(e){let t=e.destructive,n=t.names.length?t.names.join(`, `):i.t(`services.destructive.unknownTarget`);switch(t.action){case`DROP`:return`DROP ${t.objectType} ${n}`;case`TRUNCATE`:return`TRUNCATE ${n}`;case`DELETE_ALL`:return i.t(`services.destructive.deleteAll`,{target:n});case`UPDATE_ALL`:return i.t(`services.destructive.updateAll`,{target:n});case`ALTER_DROP`:return i.t(`services.destructive.alterDrop`,{target:n})}}async function me(e){if(!p.getState().confirmDestructive)return!0;let t=e.filter(e=>e.destructive?.dataLoss);return t.length===0||r.getState().requestDestructiveConfirm({title:i.t(`services.destructive.title`,{count:t.length}),description:i.t(`services.destructive.description`),statements:t.map(pe),confirmLabel:i.t(`services.runAnyway`)})}async function he(e,t){if(!e.readOnly)return;let n=t.filter(e=>!U(e));if(n.length===0)return;let a=`${e.hostName||e.host}`;if(!p.getState().allowReadOnlyOverride)throw new R(i.t(`services.readOnly.refused`,{label:a,count:n.length}));if(!await r.getState().requestDestructiveConfirm({title:i.t(`services.readOnly.title`,{label:a}),description:i.t(`services.readOnly.description`),statements:n.map(e=>e.sql.length>120?e.sql.slice(0,117)+`...`:e.sql),confirmLabel:i.t(`services.runAnyway`)}))throw new z(`Cancelled: connection is read-only.`)}function q(e,t){let n=f.getState(),r=n.activeConnections.find(t=>t.id===e);if(!r?.serverConnectionId)throw new R(i.t(`services.query.notConnected`));if(n.pendingReopen[e])throw new R(i.t(`services.query.fileNotOpen`));return{connId:e,serverConnId:r.serverConnectionId,conn:r,engine:x(e),tabId:t}}async function J(e,t,n){let r=new S(e.engine).statements(t);if(e.conn.scratchpad){let{materializeFederated:t}=await a(async()=>{let{materializeFederated:e}=await import(`./B_UAjgBr.js`).then(e=>e.B);return{materializeFederated:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]));for(let n of r)n.sql=await t(e.connId,n.sql)}if(await he(e.conn,r),!n.skipDestructiveConfirm&&!await me(r))throw new z;return r}async function Y(e,n,a){let{connId:o,serverConnId:s,engine:c,tabId:l}=e,u=n.stmt?.kind??``,d=()=>f.getState();if(e.conn.transactionMode===`manual`&&c.capabilities.transactions&&n.stmt&&de(n.stmt)&&!d().transactionOpen[o]){let e=await y(s,c.getQuery(`START_TRANSACTION`),a||void 0);if(!e.success)throw new R(e.message??i.t(`services.transaction.startFailed`));d().setTransactionOpen(o,!0),r.getState().setFooterMessage(i.t(`services.transaction.started`))}let p=await y(s,n.sql,a||void 0);if(!p.success){let r=p.message??i.t(`services.query.failed`);throw g.getState().recordExecution({connectionId:o,tabId:l,query:n.sql,database:a,executionTime:p.execTime,error:r,kind:u||void 0}),t(`query_execute`,{dbms:e.conn.dbms,kind:u||`unknown`,source:l?`editor`:`app`,success:!1}),new R(r,n.sql)}let m=B(p);return u===`COMMIT`||u===`ROLLBACK`?d().setTransactionOpen(o,!1):u===`START`||u===`BEGIN`?d().setTransactionOpen(o,!0):le.has(u)&&d().transactionOpen[o]&&c.capabilities.implicitCommitDdl&&(d().setTransactionOpen(o,!1),r.getState().setFooterMessage(i.t(`services.transaction.implicitCommit`,{kind:u}))),ue.has(u)&&L(o,a),e.skipHistory||g.getState().recordExecution({connectionId:o,tabId:l,query:n.sql,database:a,executionTime:p.execTime,kind:u||void 0,...m.fields.length>0?{rowCount:m.rows.length}:{affectedRows:m.affectedRows}}),t(`query_execute`,{dbms:e.conn.dbms,kind:u||`unknown`,source:l?`editor`:`app`,success:!0,exec_time_ms:Math.round(p.execTime??0)}),{qr:m,execTime:p.execTime}}async function ge(e,t,n={}){let r=q(e,n.tabId??null);r.skipHistory=n.skipHistory;let a=t.trim();if(!a)throw new R(i.t(`services.query.nothingToExecute`));let o=await J(r,a,n),s=n.database??``;n.previewWrites&&p.getState().previewAffectedRows&&await Q(r,o,s);let c=o.length>0?o.map(e=>({sql:e.sql,stmt:e})):[{sql:a,stmt:null}],l=null;for(let e of c){let{qr:t}=await Y(r,e,s);n.primaryKeys&&t.fields.length>0&&s&&await V(t,r.serverConnId,s,r.engine,Array.isArray(n.primaryKeys)?n.primaryKeys:void 0),l=t}return l}function _e(e,t){return X(e,t)?.sql??null}function X(e,t){let n=g.getState().tabs[e]?.find(e=>e.id===t);if(!n)return null;let r=te(e,t);if(r&&`selection`in r)return{sql:r.selection,start:r.start};let i=r&&`cursorOffset`in r?r.cursorOffset:n.query.length,a=new S(x(e)).statements(n.query);if(a.length===0)return null;let o=a.find(e=>i>=w(e)&&i<=e.end)??[...a].reverse().find(e=>e.end<=i)??a[0];return{sql:o.sql,start:w(o)}}async function ve(e,n,r={}){let o=()=>g.getState(),s=o().tabs[e]?.find(e=>e.id===n);if(!s)return;let c=(r.sql??s.query)?.trim();if(!c)return;let l,u;try{l=q(e,n),u=await J(l,c,{})}catch(t){if(t instanceof z){t.message!==`Cancelled`&&o().setError(e,n,t.message);return}o().setError(e,n,t instanceof Error?t.message:String(t));return}let f=p.getState(),m=new Map;if(f.previewAffectedRows)try{m=await Q(l,u,s.database||``)}catch(e){if(e instanceof z)return;throw e}let h=m.size===1,_=u.length>0?u.map(e=>({...G(e,f.resultRowLimit,l.engine.syntax.limitStyle),stmt:e})):[{sql:c,limited:!1,stmt:null}],v=r.sql?r.sqlOffset??null:0;a(async()=>{let{readStructures:e}=await import(`./B_UAjgBr.js`).then(e=>e.tt);return{readStructures:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22])).then(({readStructures:t})=>t(e,n,u.length>0?u.map(e=>({sql:e.sql,start:v===null?null:v+w(e)})):[{sql:c,start:v}])),o().captureRevision(e,n,`execute`),o().setExecuting(e,n,!0),o().setError(e,n,null);let y=[],b=s.database||``;try{for(let r of _){let{qr:a,execTime:s}=await Y(l,r,b);if(a.sql=r.stmt?.sql??r.sql,a.executionTime=s,r.limited&&a.rows.length>=f.resultRowLimit&&(a.limited=!0,a.message=i.t(`services.query.rowsReturnedLimited`,{count:a.rows.length,limit:f.resultRowLimit})),!b&&a.fields.length>0){let t=a.fields.find(e=>e.db)?.db;t&&(b=t,o().setDatabase(e,n,b),M(e,b))}a.fields.length>0&&b&&await V(a,l.serverConnId,b,l.engine);let c=h&&r.stmt?m.get(r.stmt):void 0;c!==void 0&&Number.isFinite(a.affectedRows)&&a.affectedRows!==c&&(a.warning=i.t(`services.query.dryRunMismatch`,{predicted:c,actual:a.affectedRows}),t(`dry_run_mismatch`,{dbms:l.conn.dbms,kind:r.stmt?.kind??`unknown`})),y.push(a)}o().setResults(e,n,y)}catch(t){y.length>0&&o().setResults(e,n,y),o().setError(e,n,t instanceof Error?t.message:String(t),t instanceof R?t.sql:null),t instanceof R&&d(`query_error`)}finally{o().setExecuting(e,n,!1)}}var Z=50;function ye(e,t,n){return e.syntax.limitStyle===`top`?t.replace(/^SELECT\b/i,`SELECT TOP ${n}`):`${t} ${e.limitClause(n)}`}async function Q(e,t,n){let i=new Map;for(let a of t){if(a.kind!==`UPDATE`&&a.kind!==`DELETE`)continue;let t=ne(a);if(!t)continue;let o=null,s=[],c=[],l,u=await y(e.serverConnId,t.count,n||void 0);if(u.success){let r=Number(u.records[0]?.[0]);o=Number.isFinite(r)?r:null;let i=await y(e.serverConnId,t.limited?t.select:ye(e.engine,t.select,Z),n||void 0);i.success?(s=i.fields.map(e=>e.name),c=i.records):l=i.message}else l=u.message;if(!await r.getState().requestDryRun({statement:a.sql,previewSql:t.select,count:o,fields:s,rows:c,truncated:o!==null&&c.length<o,error:l}))throw new z;o!==null&&i.set(a,o)}return i}async function $(e,t){let n=f.getState(),a=n.activeConnections.find(t=>t.id===e);if(!a?.serverConnectionId)return;let o=x(e);try{let e=await y(a.serverConnectionId,o.getQuery(t));if(!e.success)throw new R(e.message??i.t(`services.transaction.commandFailed`,{name:t}));r.getState().setFooterMessage(t===`COMMIT`?i.t(`services.transaction.committed`):i.t(`services.transaction.rolledBack`))}catch(e){r.getState().setFooterMessage(i.t(`services.transaction.commandFailedWith`,{name:t,message:e instanceof Error?e.message:String(e)}))}finally{n.setTransactionOpen(e,!1)}}var be=e=>$(e,`COMMIT`),xe=e=>$(e,`ROLLBACK`);export{ae as _,ve as a,xe as c,K as d,fe as f,M as g,se as h,be as i,ge as l,ce as m,R as n,_e as o,L as p,G as r,U as s,z as t,X as u,ie as v};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,n as t}from"./XzPc-eVf.js";import{l as n,m as r,t as i}from"./CKOS5Y-e.js";import{r as a,t as o}from"./fDSXGLmI.js";import{a as s,i as c,n as l,r as u,t as d}from"./
|
|
1
|
+
import{a as e,n as t}from"./XzPc-eVf.js";import{l as n,m as r,t as i}from"./CKOS5Y-e.js";import{r as a,t as o}from"./fDSXGLmI.js";import{a as s,i as c,n as l,r as u,t as d}from"./Bz1cma8F.js";import{n as f}from"./BBSxV90W.js";import{a as p,i as m,n as h,o as g,r as _,t as v}from"./DxuXBECK.js";import{t as y}from"./BjlaUaDI.js";var b=n();function x(){let n=t(e=>e.activeDialog),x=t(e=>e.closeDialog),S=f(),{t:C}=r();return(0,b.jsx)(v,{open:n===`general-settings`,onOpenChange:e=>{e||x()},children:(0,b.jsxs)(h,{className:`sm:max-w-[560px]`,children:[(0,b.jsxs)(p,{children:[(0,b.jsx)(g,{children:C(`settings.general.title`)}),(0,b.jsx)(_,{children:C(`settings.general.description`)})]}),(0,b.jsxs)(`div`,{className:`grid gap-2`,children:[(0,b.jsx)(y,{id:`s-history`,checked:S.persistQueryHistory,onChange:e=>S.setPersistQueryHistory(e),label:C(`settings.persistHistory`),hint:C(`settings.persistHistoryHint`)}),(0,b.jsxs)(`div`,{className:`grid grid-cols-[1fr_200px] items-center gap-3 rounded-md border p-3`,children:[(0,b.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,b.jsx)(`span`,{className:`text-sm font-medium`,children:C(`settings.language`)}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:C(`settings.languageHint`)})]}),(0,b.jsxs)(d,{value:S.locale,onValueChange:e=>S.setLocale(e),children:[(0,b.jsx)(c,{children:(0,b.jsx)(s,{})}),(0,b.jsxs)(l,{children:[(0,b.jsx)(u,{value:`auto`,children:C(`language.auto`,{name:C(`language.${a()}`)})}),o.map(e=>(0,b.jsx)(u,{value:e,children:C(`language.${e}`)},e))]})]})]}),(0,b.jsx)(y,{id:`s-analytics`,checked:S.analyticsEnabled,onChange:S.setAnalyticsEnabled,label:C(`settings.analytics`),hint:e()?C(`settings.analyticsHint`):C(`settings.analyticsUnavailableHint`)})]}),(0,b.jsx)(m,{children:(0,b.jsx)(i,{onClick:x,children:C(`settings.done`)})})]})})}export{x as GeneralSettingsDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{l as e,m as t}from"./CKOS5Y-e.js";import{t as n}from"./neLPq0_M.js";import{Rt as r}from"./
|
|
1
|
+
import{l as e,m as t}from"./CKOS5Y-e.js";import{t as n}from"./neLPq0_M.js";import{Rt as r}from"./B_UAjgBr.js";var i={currency:`USD`,annualPerMonth:8,annualTotal:96,monthly:10},a=e=>`$${e}`,o=e(),s=`https://planche.dev/pricing/`;function c({highlight:e,innerRef:c}){let{t:l}=t(),u=e?[e,...n.filter(t=>t!==e)]:[...n];return(0,o.jsxs)(`div`,{className:`grid gap-3 rounded-xl border border-primary/50 bg-muted/20 p-4 shadow-[inset_0_0_0_1px_hsl(var(--primary)/0.15)]`,children:[(0,o.jsx)(`p`,{className:`text-[0.7rem] font-semibold uppercase tracking-[0.09em] text-muted-foreground`,children:`Pro`}),(0,o.jsxs)(`div`,{className:`grid gap-1`,children:[(0,o.jsxs)(`p`,{className:`flex items-baseline gap-1.5`,children:[(0,o.jsx)(`span`,{className:`text-3xl font-semibold leading-none text-foreground`,children:a(i.annualPerMonth)}),(0,o.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:l(`pro.perMonth`)})]}),(0,o.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l(`pro.priceNote`,{annual:a(i.annualTotal),monthly:a(i.monthly)})})]}),(0,o.jsx)(`ul`,{className:`grid gap-2 text-xs`,children:u.map(t=>(0,o.jsxs)(`li`,{className:`flex gap-2`,children:[(0,o.jsx)(r,{className:`mt-0.5 size-3 shrink-0 ${t===e?`text-primary`:`text-emerald-500/80`}`}),(0,o.jsxs)(`span`,{className:`grid gap-0.5`,children:[(0,o.jsx)(`span`,{className:t===e?`font-medium text-foreground`:`text-foreground/90`,children:l(`pro.features.${t}`)}),(0,o.jsx)(`span`,{className:`text-muted-foreground`,children:l(`pro.featureDetails.${t}`)})]})]},t))}),(0,o.jsx)(`a`,{ref:c,href:s,target:`_blank`,rel:`noreferrer`,className:`rounded-md bg-primary px-4 py-2 text-center text-sm font-medium text-primary-foreground hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:l(`pro.pricing`)})]})}export{c as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./hePW80VL.js";import{h as t,n}from"./XzPc-eVf.js";import{l as r,m as i,t as a}from"./CKOS5Y-e.js";import{a as o,i as s,n as c,r as l,t as u}from"./
|
|
1
|
+
import{r as e}from"./hePW80VL.js";import{h as t,n}from"./XzPc-eVf.js";import{l as r,m as i,t as a}from"./CKOS5Y-e.js";import{a as o,i as s,n as c,r as l,t as u}from"./Bz1cma8F.js";import{t as d}from"./B3nhMsGp.js";import{n as f}from"./Cr6Fx4T5.js";import{l as p,m}from"./CCQZjXae.js";import{c as h,l as g}from"./B_UAjgBr.js";import{a as _,i as v,n as y,o as b,t as x}from"./DxuXBECK.js";var S=e(t(),1),C=r(),w=[`utf8mb4`,`utf8`,`latin1`,`ascii`,`binary`,`cp1251`,`euckr`,`gb2312`,`gbk`,`sjis`,`ucs2`,`utf16`,`utf32`],T={utf8mb4:[`utf8mb4_general_ci`,`utf8mb4_unicode_ci`,`utf8mb4_bin`,`utf8mb4_0900_ai_ci`],utf8:[`utf8_general_ci`,`utf8_unicode_ci`,`utf8_bin`],latin1:[`latin1_swedish_ci`,`latin1_general_ci`,`latin1_bin`],ascii:[`ascii_general_ci`,`ascii_bin`],binary:[`binary`],cp1251:[`cp1251_general_ci`,`cp1251_bin`],euckr:[`euckr_korean_ci`,`euckr_bin`],gb2312:[`gb2312_chinese_ci`,`gb2312_bin`],gbk:[`gbk_chinese_ci`,`gbk_bin`],sjis:[`sjis_japanese_ci`,`sjis_bin`],ucs2:[`ucs2_general_ci`,`ucs2_unicode_ci`,`ucs2_bin`],utf16:[`utf16_general_ci`,`utf16_unicode_ci`,`utf16_bin`],utf32:[`utf32_general_ci`,`utf32_unicode_ci`,`utf32_bin`]};function E(){let{t:e}=i(),{activeDialog:t,closeDialog:r}=n(),E=t===`create-database`,[D,O]=(0,S.useState)(``),[k,A]=(0,S.useState)(`utf8mb4`),[j,M]=(0,S.useState)(`utf8mb4_general_ci`),[N,P]=(0,S.useState)(!1),[F,I]=(0,S.useState)(null);function L(e){e||(r(),I(null),O(``),A(`utf8mb4`),M(`utf8mb4_general_ci`))}function R(e){A(e);let t=T[e];M(t?.[0]??``)}async function z(){let e=d.getState().activeConnectionId,t=D.trim();if(!(!e||!t)){I(null),P(!0);try{let n=f(e).getQuery(`CREATE_DATABASE`,t,k,j);await p(e,n),await m(e),L(!1)}catch(e){I(e instanceof Error?e.message:String(e))}finally{P(!1)}}}let B=T[k]??[];return(0,C.jsx)(x,{open:E,onOpenChange:L,children:(0,C.jsxs)(y,{className:`sm:max-w-[450px]`,children:[(0,C.jsx)(_,{children:(0,C.jsx)(b,{children:e(`database.create.title`)})}),(0,C.jsxs)(`div`,{className:`space-y-4`,children:[(0,C.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,C.jsx)(h,{htmlFor:`db-name`,children:e(`database.create.name`)}),(0,C.jsx)(g,{id:`db-name`,value:D,onChange:e=>O(e.target.value),placeholder:e(`database.create.namePlaceholder`)})]}),(0,C.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,C.jsx)(h,{htmlFor:`db-charset`,children:e(`database.create.charset`)}),(0,C.jsxs)(u,{value:k,onValueChange:R,children:[(0,C.jsx)(s,{id:`db-charset`,className:`w-full`,children:(0,C.jsx)(o,{})}),(0,C.jsx)(c,{children:w.map(e=>(0,C.jsx)(l,{value:e,children:e},e))})]})]}),(0,C.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,C.jsx)(h,{htmlFor:`db-collation`,children:e(`database.create.collation`)}),(0,C.jsxs)(u,{value:j,onValueChange:M,children:[(0,C.jsx)(s,{id:`db-collation`,className:`w-full`,children:(0,C.jsx)(o,{})}),(0,C.jsx)(c,{children:B.map(e=>(0,C.jsx)(l,{value:e,children:e},e))})]})]})]}),F&&(0,C.jsx)(`p`,{className:`px-1 text-xs text-destructive leading-relaxed`,children:F}),(0,C.jsxs)(v,{children:[(0,C.jsx)(a,{variant:`outline`,onClick:()=>L(!1),children:e(`database.create.cancel`)}),(0,C.jsx)(a,{onClick:()=>void z(),disabled:!D.trim()||N,children:e(`database.create.create`)})]})]})})}export{E as CreateDatabaseDialog};
|