@kazurolabs/psql-explorer 0.0.0-stage → 0.3.0
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/LICENSE +21 -0
- package/README.md +505 -2
- package/RELEASES.md +87 -0
- package/dist/app.js +39 -0
- package/dist/cli.js +307 -0
- package/dist/commands/configgen.js +128 -0
- package/dist/commands/explore.js +388 -0
- package/dist/commands/terminal-prompt.js +68 -0
- package/dist/config/load.js +324 -0
- package/dist/config/resolve-environment.js +112 -0
- package/dist/config/resolvers/env.js +12 -0
- package/dist/config/resolvers/file.js +24 -0
- package/dist/config/resolvers/groups.js +1 -0
- package/dist/config/resolvers/index.js +49 -0
- package/dist/config/resolvers/literal.js +7 -0
- package/dist/config/resolvers/prompt.js +159 -0
- package/dist/config/resolvers/stored.js +13 -0
- package/dist/config/resolvers/types.js +18 -0
- package/dist/config/resolvers/vault.js +283 -0
- package/dist/config/schema.js +24 -0
- package/dist/config/source.js +105 -0
- package/dist/db/connect.js +55 -0
- package/dist/db/identifiers.js +6 -0
- package/dist/db/paths.js +14 -0
- package/dist/db/store.js +323 -0
- package/dist/db/tester.js +190 -0
- package/dist/db/validate.js +99 -0
- package/dist/environments.js +140 -0
- package/dist/explorer/alter.js +493 -0
- package/dist/explorer/catalog.js +414 -0
- package/dist/explorer/connect-entry.js +42 -0
- package/dist/explorer/cypher-parse.js +478 -0
- package/dist/explorer/cypher.js +963 -0
- package/dist/explorer/ddl.js +502 -0
- package/dist/explorer/dependents.js +222 -0
- package/dist/explorer/design-load.js +254 -0
- package/dist/explorer/design.js +45 -0
- package/dist/explorer/edit.js +108 -0
- package/dist/explorer/explain.js +37 -0
- package/dist/explorer/filter.js +121 -0
- package/dist/explorer/format.js +134 -0
- package/dist/explorer/graph.js +679 -0
- package/dist/explorer/gucs.js +31 -0
- package/dist/explorer/profile.js +102 -0
- package/dist/explorer/references.js +95 -0
- package/dist/explorer/rows.js +64 -0
- package/dist/explorer/schema-diff.js +360 -0
- package/dist/explorer/search.js +309 -0
- package/dist/explorer/security.js +152 -0
- package/dist/explorer/seed.js +1376 -0
- package/dist/explorer/session.js +122 -0
- package/dist/explorer/stats.js +135 -0
- package/dist/explorer/timeout.js +13 -0
- package/dist/prompts.js +52 -0
- package/dist/screens/environments.js +229 -0
- package/dist/screens/explorer.js +145 -0
- package/dist/screens/header.js +8 -0
- package/dist/screens/index.js +13 -0
- package/dist/screens/new-connection.js +178 -0
- package/dist/screens/panes/common.js +35 -0
- package/dist/screens/panes/history.js +36 -0
- package/dist/screens/panes/info.js +61 -0
- package/dist/screens/panes/query.js +113 -0
- package/dist/screens/panes/table.js +178 -0
- package/dist/screens/panes/tables.js +142 -0
- package/dist/screens/prompt-modal.js +18 -0
- package/dist/screens/record-view.js +42 -0
- package/dist/screens/result-grid.js +126 -0
- package/dist/screens/scroll.js +12 -0
- package/dist/screens/splash.js +78 -0
- package/dist/screens/terminal.js +25 -0
- package/dist/screens/types.js +1 -0
- package/dist/services.js +1 -0
- package/dist/startup.js +84 -0
- package/dist/web/server.js +988 -0
- package/package.json +69 -5
- package/web/dist/assets/anton-latin-400-normal-AUNGEG_V.woff +0 -0
- package/web/dist/assets/anton-latin-400-normal-Byf51wtH.woff2 +0 -0
- package/web/dist/assets/anton-latin-ext-400-normal-BMODBQc6.woff +0 -0
- package/web/dist/assets/anton-latin-ext-400-normal-SyiqE2Jt.woff2 +0 -0
- package/web/dist/assets/anton-vietnamese-400-normal-2FfR1wHA.woff +0 -0
- package/web/dist/assets/anton-vietnamese-400-normal-CkBxLiRJ.woff2 +0 -0
- package/web/dist/assets/antonio-latin-400-normal-B7iMKlzw.woff +0 -0
- package/web/dist/assets/antonio-latin-400-normal-CZjzwNAN.woff2 +0 -0
- package/web/dist/assets/antonio-latin-700-normal-BY3mCh47.woff +0 -0
- package/web/dist/assets/antonio-latin-700-normal-DSH-lEDG.woff2 +0 -0
- package/web/dist/assets/antonio-latin-ext-400-normal-nE82dizb.woff2 +0 -0
- package/web/dist/assets/antonio-latin-ext-400-normal-qA9Jb92z.woff +0 -0
- package/web/dist/assets/antonio-latin-ext-700-normal-BdSkr58W.woff +0 -0
- package/web/dist/assets/antonio-latin-ext-700-normal-D-dvgqjr.woff2 +0 -0
- package/web/dist/assets/button-ClA70PLR.js +1 -0
- package/web/dist/assets/code-xml-CXkpHeU9.js +1 -0
- package/web/dist/assets/compare-view-DKl5l_Jw.js +2 -0
- package/web/dist/assets/copy-CCXzeW-s.js +1 -0
- package/web/dist/assets/cypher-view-Pd0WFH8F.js +13 -0
- package/web/dist/assets/design-view-CIHSmH4u.js +9 -0
- package/web/dist/assets/erd-view-CV7mFGAN.js +1 -0
- package/web/dist/assets/format-sql-BLj5_RDZ.js +5 -0
- package/web/dist/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/web/dist/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/web/dist/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/web/dist/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/web/dist/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/web/dist/assets/graph-force-yBLyErpS.js +1 -0
- package/web/dist/assets/graph-link-OCo_s0zO.js +1 -0
- package/web/dist/assets/graph-view-sM1OlByf.js +3 -0
- package/web/dist/assets/index-CDcnUacl.js +10 -0
- package/web/dist/assets/index-OzJqnJWG.css +2 -0
- package/web/dist/assets/key-round-Cv_7QeED.js +1 -0
- package/web/dist/assets/loader-circle-BK_GMdvN.js +1 -0
- package/web/dist/assets/orbitron-latin-700-normal-4jsRXGGJ.woff2 +0 -0
- package/web/dist/assets/orbitron-latin-700-normal-DmYOh-W9.woff +0 -0
- package/web/dist/assets/orbitron-latin-900-normal-BbJatbhp.woff +0 -0
- package/web/dist/assets/orbitron-latin-900-normal-DrIi7unX.woff2 +0 -0
- package/web/dist/assets/query-builder-view-ChNFb51g.js +4 -0
- package/web/dist/assets/rotate-ccw-CdCaf7Q6.js +1 -0
- package/web/dist/assets/route-DO6IZ7of.js +15 -0
- package/web/dist/assets/seed-view-DFNB8WHE.js +7 -0
- package/web/dist/assets/share-tech-mono-latin-400-normal-15MgdvEM.woff +0 -0
- package/web/dist/assets/share-tech-mono-latin-400-normal-CCqdbj5z.woff2 +0 -0
- package/web/dist/assets/shield-alert-CMS-3j4U.js +1 -0
- package/web/dist/assets/sliders-horizontal-Dg51yc-C.js +1 -0
- package/web/dist/assets/sql-tabs-B4jt6bQj.js +2 -0
- package/web/dist/assets/table-DfMz2f8M.js +1 -0
- package/web/dist/assets/triangle-alert-COGnHCD1.js +1 -0
- package/web/dist/assets/zone-D9dXk8tn.js +5 -0
- package/web/dist/index.html +26 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{$ as e,at as t,ct as n,o as r,ot as i,rt as a}from"./route-DO6IZ7of.js";import{t as o}from"./button-ClA70PLR.js";import{t as s}from"./key-round-Cv_7QeED.js";import{t as c}from"./rotate-ccw-CdCaf7Q6.js";import{a as l,i as u,n as d,o as f,r as p,t as m}from"./table-DfMz2f8M.js";import{Gt as h,K as g,Kt as _,Q as ee,Qt as v,Wt as y,Yt as b,nn as x,on as te,q as ne,qt as S}from"./index-CDcnUacl.js";var C={name:`git-branch`,size:24,node:[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]};C.node;var re=t(C),w=n(i(),1),T=a(),E=`border-input bg-background rounded-lg border px-2 py-1 text-sm`,D=new Set([`default`,`null`,`constant`,`someOf`,`reference`,`link`]),O={min:1,max:3};function ie(e,t){let n=new Map(t.map(e=>[e.name,e])),r=new Set(e.map(e=>e.name));return[...e.map(e=>({name:e.name,schema:e.to.schema,table:e.to.name,mode:n.get(e.name)?.mode??`random`,unique:n.get(e.name)?.unique??!1,key:e})),...t.filter(e=>!r.has(e.name)&&e.schema&&e.table).map(e=>({name:e.name,schema:e.schema,table:e.table,mode:e.mode??`random`,unique:e.unique??!1}))]}var k=(0,w.createContext)({environment:``,links:[]}),A=[{op:`eq`,label:`is`},{op:`ne`,label:`is not`},{op:`in`,label:`is one of`},{op:`gt`,label:`>`},{op:`gte`,label:`≥`},{op:`lt`,label:`<`},{op:`lte`,label:`≤`},{op:`null`,label:`is NULL`},{op:`notNull`,label:`is not NULL`}];function j(e,t,n){let r=Object.fromEntries((t?.options??[]).map(e=>[e.name,e.default??``]));return(n===`oneOf`||n===`someOf`)&&e.allowedValues&&(r.values=e.allowedValues.join(`
|
|
2
|
+
`)),{generator:n,options:r}}var ae={count:100,locale:`en`,seed:``,skipConflicts:!1,skipDuplicates:!1,links:[],perRow:{min:1,max:3}},M=(e,t,n)=>`psql-explorer:seed:${e}:${t}.${n}`;function oe(e){try{let t=window.localStorage.getItem(e);return t?JSON.parse(t):void 0}catch{return}}function se(e,t){try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}var N=(e,t,n)=>{window.location.hash=r({environment:e,seed:{schema:t,table:n}})};function P({environment:t,schema:n,table:r}){let i=y(()=>e.schemas(t),t),[a,o]=(0,w.useState)(n),s=a??n??i.data?.find(e=>e.name===`public`)?.name??i.data?.[0]?.name,c=y(()=>s?e.objects(t,s):Promise.resolve(void 0),`${t}\0${s??``}`),l=(c.data?.tables??[]).filter(e=>e.kind===`table`||e.kind===`partitioned`);return(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,T.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`span`,{className:`text-muted-foreground`,children:`Schema`}),(0,T.jsx)(`select`,{"aria-label":`Schema`,className:E,value:s??``,onChange:e=>o(e.target.value),children:i.data?.map(e=>(0,T.jsx)(`option`,{value:e.name,children:e.name},e.name))})]}),(0,T.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`span`,{className:`text-muted-foreground`,children:`Table`}),(0,T.jsxs)(`select`,{"aria-label":`Table`,className:E,value:s===n?r??``:``,onChange:e=>s&&e.target.value&&N(t,s,e.target.value),children:[(0,T.jsx)(`option`,{value:``,children:c.loading?`loading...`:l.length?`pick a table`:`no tables`}),l.map(e=>(0,T.jsxs)(`option`,{value:e.name,children:[e.name,e.estimatedRows!==null&&e.estimatedRows>=0?` (~${e.estimatedRows} rows)`:``]},e.name))]})]}),(i.error||c.error)&&(0,T.jsx)(`span`,{className:`text-destructive`,children:i.error??c.error})]})}function F({column:e,generators:t,value:n,onChange:r,noDefault:i}){let{links:a}=(0,w.useContext)(k),o=(0,w.useMemo)(()=>{let r=new Map;for(let o of t)o.id===`reference`&&!e.references||(o.id===`link`||o.id===`sequenceInGroup`)&&a.length===0&&n!==o.id||o.id==="default"&&i||o.id===`null`&&!e.nullable||o.id!=="default"&&e.generated||r.set(o.group,[...r.get(o.group)??[],o]);return[...r]},[t,e,i,a.length,n]);return(0,T.jsx)(`select`,{"aria-label":`Generator for ${e.name}`,className:`${E} w-full`,value:n,disabled:e.generated,onChange:e=>r(e.target.value),children:o.map(([e,t])=>(0,T.jsx)(`optgroup`,{label:e,children:t.map(e=>(0,T.jsx)(`option`,{value:e.id,children:e.label},e.id))},e))})}var I=e=>e.split(e.includes(`
|
|
3
|
+
`)?`
|
|
4
|
+
`:`,`).map(e=>e.trim()).filter(e=>e!==``);function L({column:e,plan:t,onChange:n}){let r=e.allowedValues??[],i=I(String(t.options?.values??``)),a=I(String(t.options?.weights??``)),s=new Map(i.map((e,t)=>[e,a[t]===void 0?1:Number(a[t])])),c=e=>{let i=r.filter(t=>e.has(t)),a=i.map(t=>e.get(t)),o=a.every(e=>e===a[0]);n({...t,options:{...t.options,values:i.join(`
|
|
5
|
+
`),weights:o?``:a.join(`
|
|
6
|
+
`)}})},l=(e,t)=>{let n=new Map(s);t===void 0?n.delete(e):n.set(e,t),c(n)},u=[...s.values()].reduce((e,t)=>e+(Number.isFinite(t)?t:0),0);return(0,T.jsxs)(`div`,{className:`flex w-full flex-col gap-1`,children:[(0,T.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`allowed values, and how often each is picked`}),(0,T.jsx)(o,{variant:`ghost`,size:`xs`,onClick:()=>c(new Map(r.map(e=>[e,s.get(e)??1]))),children:`all`}),(0,T.jsx)(o,{variant:`ghost`,size:`xs`,onClick:()=>c(new Map(i.map(e=>[e,1]))),children:`even`})]}),(0,T.jsx)(`div`,{className:`grid w-fit grid-cols-[auto_auto_auto_auto] items-center gap-x-3 gap-y-1`,children:r.map(e=>{let t=s.has(e),n=s.get(e)??1,r=t&&u>0?n/u*100:0;return(0,T.jsxs)(w.Fragment,{children:[(0,T.jsx)(`input`,{type:`checkbox`,"aria-label":`Pick ${e}`,checked:t,onChange:t=>l(e,t.target.checked?1:void 0)}),(0,T.jsx)(`span`,{className:`font-mono text-xs ${t?``:`text-muted-foreground line-through`}`,children:e}),(0,T.jsx)(`input`,{type:`number`,min:0,step:`any`,"aria-label":`Weight of ${e}`,disabled:!t,className:`${E} w-20`,value:t?n:``,onChange:t=>l(e,Number.isNaN(t.target.valueAsNumber)?0:Math.max(t.target.valueAsNumber,0))}),(0,T.jsxs)(`span`,{className:`flex items-center gap-1`,title:`${r.toFixed(1)}% of picks`,children:[(0,T.jsx)(`span`,{className:`bg-muted h-1.5 w-20 overflow-hidden rounded-full`,children:(0,T.jsx)(`span`,{className:`bg-primary block h-full`,style:{width:`${r}%`}})}),(0,T.jsx)(`span`,{className:`text-muted-foreground w-12 text-right text-xs tabular-nums`,children:t?`${Math.round(r)}%`:``})]})]},e)})}),i.length===0&&(0,T.jsx)(`span`,{className:`text-destructive text-xs`,children:`Tick at least one value.`}),t.generator===`someOf`&&(0,T.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Each array holds distinct values; heavier ones are picked first more often.`})]})}function R({column:e,generator:t,plan:n,onChange:r,inRule:i}){let a=(e,t)=>r({...n,options:{...n.options,[e]:t}});return(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n.generator===`link`&&(0,T.jsx)(B,{column:e,plan:n,onChange:r}),n.generator!==`link`&&t?.options?.map(t=>{let i=n.options?.[t.name]??t.default??``,o=(0,T.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t.label});if(e.allowedValues?.length&&(n.generator===`oneOf`||n.generator===`someOf`)){if(t.name===`weights`)return null;if(t.name===`values`)return(0,T.jsx)(L,{column:e,plan:n,onChange:r},t.name)}return t.type===`list`?(0,T.jsxs)(`label`,{className:`flex w-full flex-col gap-1`,children:[o,(0,T.jsx)(`textarea`,{rows:Math.min(Math.max(String(i).split(`
|
|
7
|
+
`).length,2),6),className:`${E} font-mono text-xs`,placeholder:`one value a line`,value:String(i),onChange:e=>a(t.name,e.target.value)})]},t.name):(0,T.jsxs)(`label`,{className:`flex items-center gap-1`,children:[o,(0,T.jsx)(`input`,{type:t.type===`number`?`number`:t.type===`date`?`date`:`text`,className:`${E} ${t.type===`text`?`w-56 font-mono text-xs`:t.type===`date`?`w-36`:`w-20`}`,value:String(i),onChange:e=>a(t.name,e.target.value)})]},t.name)}),e.type.endsWith(`[]`)&&!D.has(n.generator)&&(0,T.jsxs)(`span`,{className:`flex items-center gap-1`,title:`How many values each array holds, each made by the generator`,children:[(0,T.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`items`}),[`min`,`max`].map(t=>(0,T.jsx)(`input`,{type:`number`,min:0,max:100,"aria-label":`${t} items in ${e.name}`,className:`${E} w-16`,value:(n.items??O)[t],onChange:e=>r({...n,items:{...n.items??O,[t]:e.target.valueAsNumber}})},t))]}),e.nullable&&n.generator!=="default"&&n.generator!==`null`&&(0,T.jsxs)(`label`,{className:`flex items-center gap-1`,title:`The share of rows left NULL`,children:[(0,T.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`% null`}),(0,T.jsx)(`input`,{type:`number`,min:0,max:100,className:`${E} w-16`,value:n.nulls??0,onChange:e=>r({...n,nulls:Number(e.target.value)})})]}),n.generator===`template`&&(0,T.jsxs)(`span`,{className:`text-muted-foreground w-full text-xs`,children:[`Faker methods like `,(0,T.jsx)(`code`,{children:`{{person.lastName}}`}),`; another column of the row as`,` `,(0,T.jsx)(`code`,{children:`{{row.column_name}}`}),`; a column of a linked row as`,` `,(0,T.jsx)(`code`,{children:`{{link.link_name.column_name}}`}),`.`]}),n.generator===`sequenceInGroup`&&(0,T.jsxs)(`span`,{className:`text-muted-foreground w-full text-xs`,children:[`Starts again for each row of the tables linked with `,(0,T.jsx)(`em`,{children:`each of its rows`}),`, e.g. line numbers 1, 2, 3 of each order.`]}),!i&&n.generator!=="default"&&n.generator!==`null`&&(0,T.jsxs)(`label`,{className:`flex items-center gap-1 text-xs`,title:`Never repeat a value within one run (whichever case made it)`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:n.unique===!0,onChange:e=>r({...n,unique:e.target.checked})}),(0,T.jsx)(`span`,{className:`text-muted-foreground`,children:`unique`})]})]})}function z(t,n){return y(()=>n?e.relation(t,{kind:`table`,schema:n.schema,name:n.table}).then(e=>e.columns.map(e=>e.name)):Promise.resolve([]),`${t}\0${n?.schema??``}\0${n?.table??``}`)}function B({column:e,plan:t,onChange:n}){let{environment:r,links:i}=(0,w.useContext)(k),a=String(t.options?.link??``),o=i.find(e=>e.name===a),s=z(r,o),c=e=>n({...t,options:{...t.options,...e}});return i.length===0?(0,T.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Add a linked table above to take values from.`}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`label`,{className:`flex items-center gap-1`,children:[(0,T.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`link`}),(0,T.jsxs)(`select`,{"aria-label":`Link for ${e.name}`,className:E,value:a,onChange:e=>c({link:e.target.value,column:``}),children:[(0,T.jsx)(`option`,{value:``,children:`pick a link`}),i.map(e=>(0,T.jsxs)(`option`,{value:e.name,children:[e.name,` (`,e.table,`)`]},e.name))]})]}),o&&(0,T.jsxs)(`label`,{className:`flex items-center gap-1`,children:[(0,T.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`column`}),(0,T.jsxs)(`select`,{"aria-label":`Linked column for ${e.name}`,className:E,value:String(t.options?.column??``),onChange:e=>c({column:e.target.value}),children:[(0,T.jsx)(`option`,{value:``,children:s.loading?`loading...`:`pick a column`}),s.data?.map(e=>(0,T.jsx)(`option`,{value:e,children:e},e))]})]}),s.error&&(0,T.jsx)(`span`,{className:`text-destructive text-xs`,children:s.error})]})}function V({environment:t,schema:n,taken:r,onAdd:i}){let a=y(()=>e.schemas(t),t),[o,s]=(0,w.useState)(n),c=y(()=>o?e.objects(t,o):Promise.resolve(void 0),`${t}\0${o??``}`),l=(c.data?.tables??[]).filter(e=>e.kind!==`foreign`),u=e=>{if(!o||!e)return;let t=e;for(let n=2;r.has(t);n++)t=`${e}_${n}`;i({name:t,schema:o,table:e,mode:`random`})};return(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,T.jsx)(v,{className:`text-muted-foreground size-4`}),(0,T.jsx)(`select`,{"aria-label":`Schema of the linked table`,className:E,value:o??``,onChange:e=>s(e.target.value),children:a.data?.map(e=>(0,T.jsx)(`option`,{value:e.name,children:e.name},e.name))}),(0,T.jsxs)(`select`,{"aria-label":`Table to link`,className:E,value:``,onChange:e=>u(e.target.value),children:[(0,T.jsx)(`option`,{value:``,children:c.loading?`loading...`:`link another table`}),l.map(e=>(0,T.jsx)(`option`,{value:e.name,children:e.name},e.name))]}),(a.error||c.error)&&(0,T.jsx)(`span`,{className:`text-destructive`,children:a.error??c.error})]})}function ce({environment:e,schema:t,links:n,onChange:r}){let[i,a]=(0,w.useState)(!1),s=(e,t)=>{let{name:n,schema:i,table:a,mode:o,unique:s}={...e,...t};r(e.name,{name:n,schema:i,table:a,mode:o,unique:s})};return(0,T.jsxs)(`div`,{className:`mb-4 rounded-lg border p-3`,children:[(0,T.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center justify-between gap-2`,children:[(0,T.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,T.jsx)(x,{className:`size-4`}),` Linked tables`]}),!i&&(0,T.jsxs)(o,{variant:`ghost`,size:`xs`,onClick:()=>a(!0),children:[(0,T.jsx)(v,{}),` Link a table`]})]}),(0,T.jsxs)(`p`,{className:`text-muted-foreground mb-2 text-xs`,children:[`Each new row is given one row of every linked table, so all the columns that read a link (every column of a composite key, say) come from the same row. `,(0,T.jsx)(`em`,{children:`Each of its rows`}),` makes rows for every row of that table instead of a set number.`]}),n.length>0&&(0,T.jsx)(`div`,{className:`flex flex-col gap-1`,children:n.map(e=>(0,T.jsxs)(`div`,{className:`bg-muted/40 flex flex-wrap items-center gap-2 rounded-md px-2 py-1 text-sm`,children:[(0,T.jsx)(`span`,{className:`font-mono text-xs`,title:e.key?`A foreign key of this table`:`A link added here`,children:e.name}),(0,T.jsxs)(`span`,{className:`text-muted-foreground text-xs`,children:[e.key?`${e.key.fromColumns.join(`, `)} → `:`→ `,(0,T.jsxs)(`span`,{className:`text-foreground font-mono`,children:[e.schema,`.`,e.table,e.key&&` (${e.key.toColumns.join(`, `)})`]})]}),(0,T.jsxs)(`span`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,T.jsxs)(`select`,{"aria-label":`How rows of ${e.name} are used`,className:E,value:e.mode,onChange:t=>s(e,{mode:t.target.value}),children:[(0,T.jsx)(`option`,{value:`random`,children:`a random row for each new row`}),(0,T.jsx)(`option`,{value:`each`,children:`new rows for each of its rows`})]}),e.mode===`random`&&(0,T.jsxs)(`label`,{className:`flex items-center gap-1 text-xs`,title:`No row of it is picked twice, e.g. for a one-to-one key`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:e.unique,onChange:t=>s(e,{unique:t.target.checked})}),(0,T.jsx)(`span`,{className:`text-muted-foreground`,children:`each row once`})]}),!e.key&&(0,T.jsx)(o,{variant:`ghost`,size:`icon-sm`,"aria-label":`Remove ${e.name}`,onClick:()=>r(e.name,void 0),children:(0,T.jsx)(S,{})})]})]},e.name))}),i&&(0,T.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,T.jsx)(V,{environment:e,schema:t,taken:new Set(n.map(e=>e.name)),onAdd:e=>{r(e.name,e),a(!1)}}),(0,T.jsx)(o,{variant:`ghost`,size:`icon-sm`,"aria-label":`Cancel`,onClick:()=>a(!1),children:(0,T.jsx)(S,{})})]})]})}function le({column:e}){return(0,T.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:[e.primaryKey&&(0,T.jsxs)(_,{variant:`secondary`,className:`gap-1`,children:[(0,T.jsx)(s,{className:`size-3`}),` PK`]}),e.references&&(0,T.jsxs)(_,{variant:`outline`,className:`gap-1`,title:`references ${e.references.schema}.${e.references.table}.${e.references.column}`,children:[(0,T.jsx)(x,{className:`size-3`}),` `,e.references.table]}),e.unique&&!e.primaryKey&&(0,T.jsx)(_,{variant:`outline`,children:`unique`}),e.identity&&(0,T.jsx)(_,{variant:`outline`,children:`identity`}),e.generated&&(0,T.jsx)(_,{variant:`outline`,children:`generated`}),!e.nullable&&!e.primaryKey&&(0,T.jsx)(_,{variant:`outline`,children:`not null`})]})}function ue({preview:e}){return(0,T.jsxs)(`div`,{className:`mt-4`,children:[(0,T.jsxs)(`h3`,{className:`text-muted-foreground mb-2 text-xs uppercase tracking-widest`,children:[`Preview of the first `,e.rows.length,` of `,e.total.toLocaleString(),` rows`,e.skipped>0&&`, ${e.skipped} skipped for running out of unique values`]}),e.columns.length===0?(0,T.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Every column takes its default.`}):(0,T.jsx)(`div`,{className:`overflow-x-auto rounded-lg border`,children:(0,T.jsxs)(m,{children:[(0,T.jsx)(l,{children:(0,T.jsx)(f,{children:e.columns.map(e=>(0,T.jsx)(u,{children:e},e))})}),(0,T.jsx)(d,{children:e.rows.map((e,t)=>(0,T.jsx)(f,{children:e.map((e,t)=>(0,T.jsx)(p,{className:`max-w-64 truncate font-mono text-xs`,title:e??`NULL`,children:e===null?(0,T.jsx)(`span`,{className:`text-muted-foreground italic`,children:`NULL`}):e},t))},t))})]})}),(0,T.jsx)(g,{sql:e.sql})]})}function H({condition:e,target:t,onChange:n}){if(e.op===`null`||e.op===`notNull`)return null;let r=t?.type===`boolean`?[`true`,`false`]:t?.allowedValues;return r&&e.op!==`in`?(0,T.jsxs)(`select`,{"aria-label":`Value`,className:E,value:e.value??``,onChange:e=>n(e.target.value),children:[(0,T.jsx)(`option`,{value:``,children:`pick a value`}),r.map(e=>(0,T.jsx)(`option`,{value:e,children:e},e))]}):(0,T.jsx)(`input`,{"aria-label":`Value`,className:`${E} w-40`,placeholder:e.op===`in`?`a, b, c`:`value`,value:e.value??``,onChange:e=>n(e.target.value)})}function de({column:e,columns:t,generators:n,plan:r,onChange:i}){let a=new Map(n.map(e=>[e.id,e])),s=r.rules??[],c=t.filter(t=>t.name!==e.name),l=(e,t)=>{let n=t?s.map((n,r)=>r===e?t:n):s.filter((t,n)=>n!==e);i({...r,rules:n})};return(0,T.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[s.map((r,i)=>{let s=t.find(e=>e.name===r.when.column),u=e=>l(i,{...r,when:{...r.when,...e}});return(0,T.jsxs)(`div`,{className:`bg-muted/40 flex flex-wrap items-start gap-2 rounded-lg border p-2 text-sm`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,T.jsx)(`span`,{className:`text-muted-foreground w-10 text-xs uppercase`,children:i===0?`when`:`else if`}),(0,T.jsx)(`select`,{"aria-label":`Column to test`,className:E,value:r.when.column,onChange:e=>u({column:e.target.value,value:``}),children:c.map(e=>(0,T.jsx)(`option`,{value:e.name,children:e.name},e.name))}),(0,T.jsx)(`select`,{"aria-label":`Comparison`,className:E,value:r.when.op,onChange:e=>u({op:e.target.value}),children:A.map(({op:e,label:t})=>(0,T.jsx)(`option`,{value:e,children:t},e))}),(0,T.jsx)(H,{condition:r.when,target:s,onChange:e=>u({value:e})}),(0,T.jsx)(`span`,{className:`text-muted-foreground text-xs uppercase`,children:`use`}),(0,T.jsx)(`div`,{className:`w-52`,children:(0,T.jsx)(F,{column:e,generators:n,value:r.then.generator,noDefault:!0,onChange:t=>l(i,{...r,then:j(e,a.get(t),t)})})})]}),(0,T.jsx)(`div`,{className:`min-w-48 flex-1`,children:(0,T.jsx)(R,{column:e,generator:a.get(r.then.generator),plan:r.then,inRule:!0,onChange:e=>l(i,{...r,then:e})})}),(0,T.jsx)(o,{variant:`ghost`,size:`icon-sm`,"aria-label":`Remove condition`,onClick:()=>l(i,void 0),children:(0,T.jsx)(S,{})})]},i)}),(0,T.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Rows that match no condition use the generator above. Conditions are tried in order.`})]})}function U(t){let{environment:n,schema:r,table:i}=t,a=M(n,r,i),o=y(()=>e.seedSetup(n,{schema:r,name:i}),a);return o.error?(0,T.jsx)(`p`,{className:`text-destructive text-sm`,children:o.error}):o.data?(0,T.jsx)(W,{...t,storageKey:a,setup:o.data}):(0,T.jsx)(h,{className:`h-64`})}function W({environment:t,schema:n,table:i,info:a,write:s,storageKey:h,setup:g}){let _=(0,w.useMemo)(()=>Object.fromEntries(g.columns.map(e=>[e.name,e.suggestion])),[g]),[v]=(0,w.useState)(()=>oe(h)),[y,x]=(0,w.useState)(()=>({..._,...Object.fromEntries(Object.entries(v?.plans??{}).filter(([e])=>e in _))})),[S,C]=(0,w.useState)({...ae,...v?.settings}),[D,O]=(0,w.useState)(),[A,M]=(0,w.useState)(),[N,P]=(0,w.useState)(),[I,L]=(0,w.useState)(),z=(0,w.useRef)(void 0);(0,w.useEffect)(()=>se(h,{plans:y,settings:S}),[h,y,S]);let{columns:B,foreignKeys:V,generators:H,locales:U,maxRows:W}=g,G=new Map(H.map(e=>[e.id,e])),K=ie(V??[],S.links),q=K.filter(e=>e.mode===`each`),J=!!a?.readOnly&&!s.enabled,Y=e=>({count:e,columns:y,locale:S.locale,skipConflicts:S.skipConflicts,skipDuplicates:S.skipDuplicates,...S.seed.trim()===``?{}:{seed:Number(S.seed)},links:K.map(({name:e,schema:t,table:n,mode:r,unique:i})=>({name:e,schema:t,table:n,mode:r,unique:i})),...q.length>0?{perRow:S.perRow}:{}}),{min:X,max:Z}=S.perRow,Q=q.length>0?Number.isInteger(X)&&Number.isInteger(Z)&&X>=0&&Z>=Math.max(X,1):Number.isInteger(S.count)&&S.count>=1&&S.count<=W,fe=q.length>0?1:S.count,pe=(e,t)=>{C(n=>({...n,links:[...n.links.filter(t=>t.name!==e),...t?[t]:[]]})),O(void 0)},$=(e,t)=>{x(n=>({...n,[e]:t})),O(void 0)},me=(e,t)=>{let{unique:n,items:r,rules:i}=y[e.name]??{};$(e.name,{...j(e,G.get(t),t),unique:n,...r?{items:r}:{},...i?{rules:i}:{}})},he=(e,t)=>{let n=B.filter(t=>t.name!==e.name&&(y[t.name]??t.suggestion).generator!=="default")[0]??B.find(t=>t.name!==e.name);if(!n)return;let r=t.generator==="default"?e.valueSuggestion:t,{rules:i,unique:a,...o}=r;$(e.name,{...r,rules:[...t.rules??[],{when:{column:n.name,op:`eq`,value:``},then:o}]})};return(0,T.jsx)(k.Provider,{value:{environment:t,links:K},children:(0,T.jsxs)(`div`,{children:[(0,T.jsx)(ce,{environment:t,schema:n,links:K,onChange:pe}),(0,T.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,T.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[`Pick how each column of `,(0,T.jsxs)(`span`,{className:`text-foreground font-mono`,children:[n,`.`,i]}),` is filled. Columns left on `,(0,T.jsx)(`em`,{children:`Column default`}),` are not written.`]}),(0,T.jsxs)(o,{variant:`ghost`,size:`sm`,onClick:()=>{x(_),O(void 0)},children:[(0,T.jsx)(c,{}),` Suggested generators`]})]}),(0,T.jsx)(`div`,{className:`overflow-x-auto rounded-lg border`,children:(0,T.jsxs)(m,{children:[(0,T.jsx)(l,{children:(0,T.jsxs)(f,{children:[(0,T.jsx)(u,{className:`w-56`,children:`Column`}),(0,T.jsx)(u,{className:`w-64`,children:`Generator`}),(0,T.jsx)(u,{children:`Options`})]})}),(0,T.jsx)(d,{children:B.map(e=>{let t=y[e.name]??e.suggestion,n=(t.rules?.length??0)>0;return(0,T.jsxs)(w.Fragment,{children:[(0,T.jsxs)(f,{className:`align-top ${n?`border-b-0`:``}`,children:[(0,T.jsxs)(p,{className:`whitespace-normal`,children:[(0,T.jsx)(`div`,{className:`font-mono text-sm`,children:e.name}),(0,T.jsx)(`div`,{className:`text-muted-foreground font-mono text-xs`,children:e.type}),(0,T.jsx)(le,{column:e})]}),(0,T.jsxs)(p,{children:[n&&(0,T.jsx)(`span`,{className:`text-muted-foreground mb-1 block text-xs uppercase`,children:`otherwise`}),(0,T.jsx)(F,{column:e,generators:H,value:t.generator,noDefault:n,onChange:t=>me(e,t)}),!e.generated&&B.length>1&&(0,T.jsxs)(o,{variant:`ghost`,size:`xs`,className:`text-muted-foreground mt-1 flex`,title:`Use another generator for rows where another column has a certain value`,onClick:()=>he(e,t),children:[(0,T.jsx)(re,{}),` Add condition`]})]}),(0,T.jsx)(p,{className:`whitespace-normal`,children:(0,T.jsx)(R,{column:e,generator:G.get(t.generator),plan:t,onChange:t=>$(e.name,t)})})]}),n&&(0,T.jsx)(f,{className:`hover:bg-transparent`,children:(0,T.jsx)(p,{colSpan:3,className:`whitespace-normal pt-0`,children:(0,T.jsx)(de,{column:e,columns:B,generators:H,plan:t,onChange:t=>$(e.name,t.rules?.length?t:{...t,rules:void 0})})})})]},e.name)})})]})}),(0,T.jsxs)(`div`,{className:`bg-muted/40 mt-4 flex flex-wrap items-end gap-4 rounded-lg border p-3 text-sm`,children:[q.length>0?(0,T.jsxs)(`div`,{className:`flex flex-col gap-1`,title:`Picked at random between the two for each row`,children:[(0,T.jsxs)(`span`,{className:`text-muted-foreground text-xs`,children:[`Rows for each row of `,q.map(e=>e.table).join(` × `)]}),(0,T.jsx)(`span`,{className:`flex items-center gap-1`,children:[`min`,`max`].map((e,t)=>(0,T.jsxs)(w.Fragment,{children:[t>0&&(0,T.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`to`}),(0,T.jsx)(`input`,{type:`number`,min:0,"aria-label":`${e} rows for each linked row`,"aria-invalid":!Q,className:`${E} w-20`,value:Number.isNaN(S.perRow[e])?``:S.perRow[e],onChange:t=>{C({...S,perRow:{...S.perRow,[e]:t.target.valueAsNumber}}),O(void 0)}})]},e))})]}):(0,T.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,T.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Rows to insert`}),(0,T.jsx)(`input`,{type:`number`,min:1,max:W,"aria-invalid":!Q,className:`${E} w-28`,value:Number.isNaN(S.count)?``:S.count,onChange:e=>C({...S,count:e.target.valueAsNumber})})]}),(0,T.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,T.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Locale`}),(0,T.jsx)(`select`,{className:E,value:S.locale,onChange:e=>C({...S,locale:e.target.value}),children:U.map(e=>(0,T.jsx)(`option`,{value:e,children:e},e))})]}),(0,T.jsxs)(`label`,{className:`flex flex-col gap-1`,title:`The same seed makes the same rows again`,children:[(0,T.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Seed (optional)`}),(0,T.jsx)(`input`,{type:`number`,className:`${E} w-28`,placeholder:`random`,value:S.seed,onChange:e=>C({...S,seed:e.target.value})})]}),(0,T.jsxs)(`label`,{className:`flex items-center gap-2 pb-1.5`,title:`ON CONFLICT DO NOTHING`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:S.skipConflicts,onChange:e=>C({...S,skipConflicts:e.target.checked})}),`Skip rows that clash with existing ones`]}),(0,T.jsxs)(`label`,{className:`flex items-center gap-2 pb-1.5`,title:`When a unique column cannot find a value it has not made yet, leave that row out instead of failing the run`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:S.skipDuplicates,onChange:e=>C({...S,skipDuplicates:e.target.checked})}),`Skip rows that run out of unique values`]}),(0,T.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[J&&s.available&&(0,T.jsx)(ne,{write:s}),(0,T.jsxs)(o,{variant:`outline`,onClick:()=>{L(`preview`),P(void 0),M(void 0),e.previewSeed(t,{schema:n,name:i},Y(Math.max(Math.min(fe,W),1))).then(({preview:e})=>O(e),e=>P(e.message)).finally(()=>L(void 0))},disabled:!!I||!Q,children:[(0,T.jsx)(te,{}),` `,I===`preview`?`Generating...`:`Preview`]}),I===`insert`?(0,T.jsx)(o,{variant:`destructive`,onClick:()=>z.current?.abort(),children:`Cancel`}):(0,T.jsxs)(o,{onClick:()=>{let r=new AbortController;z.current=r,L(`insert`),P(void 0),M(void 0),e.runSeed(t,{schema:n,name:i},Y(fe),r.signal).then(({result:e})=>M(e),e=>P(r.signal.aborted?`Cancelled: nothing was inserted.`:e.message)).finally(()=>{z.current=void 0,L(void 0)})},disabled:!!I||!Q||J,title:J?`This environment is read only`:void 0,children:[(0,T.jsx)(b,{}),` Insert`,` `,q.length>0?D?`${D.total.toLocaleString()} `:``:Q?`${S.count.toLocaleString()} `:``,`rows`]})]})]}),J&&(0,T.jsx)(`p`,{className:`text-muted-foreground mt-2 text-sm`,children:s.available?`This environment is read only: switch on write mode to insert rows. Previews work either way.`:`This environment is read only, so rows can only be previewed here.`}),(S.skipConflicts||S.skipDuplicates)&&(0,T.jsx)(`p`,{className:`text-muted-foreground mt-2 text-sm`,children:`Skipped rows are left out, so a run may add a few fewer rows than asked for.`}),!Q&&(0,T.jsx)(`p`,{className:`text-destructive mt-2 text-sm`,children:q.length>0?`Rows for each linked row are whole numbers, the second at least 1 and no less than the first.`:`Rows to insert is a whole number from 1 to ${W.toLocaleString()}.`}),s.error&&(0,T.jsx)(`p`,{className:`text-destructive mt-2 text-sm`,children:s.error}),N&&(0,T.jsx)(`p`,{role:`alert`,className:`text-destructive mt-3 text-sm whitespace-pre-wrap`,children:N}),A&&(0,T.jsxs)(`div`,{role:`status`,className:`border-primary/40 mt-3 rounded-lg border p-3 text-sm`,children:[`Inserted `,(0,T.jsx)(`strong`,{children:A.inserted.toLocaleString()}),A.inserted!==A.requested&&` of ${A.requested.toLocaleString()}`,` rows into`,` `,(0,T.jsxs)(`span`,{className:`font-mono`,children:[n,`.`,i]}),` in `,ee(A.durationMs),`.`,A.skipped>0&&` ${A.skipped.toLocaleString()} ran out of unique values and were skipped.`,A.requested-A.skipped>A.inserted&&` ${(A.requested-A.skipped-A.inserted).toLocaleString()} clashed with existing rows and were skipped.`,` `,(0,T.jsx)(`a`,{className:`text-accent-text hover:underline`,href:r({environment:t,object:{kind:`table`,schema:n,name:i},tab:`rows`}),children:`Browse the rows`})]}),D&&(0,T.jsx)(ue,{preview:D})]})})}function G({environment:e,info:t,write:n,schema:r,table:i}){return t&&!t.seeder?(0,T.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[`The seeder is turned off for `,e,`. Add `,(0,T.jsx)(`code`,{children:`seeder: true`}),` to its explorer.yaml to use it.`]}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`h2`,{className:`text-accent-text mb-1 flex items-center gap-2 text-2xl`,children:[(0,T.jsx)(b,{className:`size-6`}),` Seed`]}),(0,T.jsx)(`p`,{className:`text-muted-foreground mb-4 text-sm`,children:`Fill a table with generated rows. They are inserted in one transaction, so a run adds all of them or none.`}),(0,T.jsx)(P,{environment:e,schema:r,table:i},`${r}\0${i}`),(0,T.jsx)(`div`,{className:`mt-4`,children:r&&i?(0,T.jsx)(U,{environment:e,schema:r,table:i,info:t,write:n},`${r}\0${i}`):(0,T.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Pick a table to seed.`})})]})}export{G as SeedView};
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{at as e}from"./route-DO6IZ7of.js";var t={name:`shield-alert`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]};t.node;var n=e(t);export{n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{at as e}from"./route-DO6IZ7of.js";var t={name:`sliders-horizontal`,size:24,node:[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]};t.node;var n=e(t);export{n as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{$ as e,G as t,H as n,K as r,Q as i,V as a,W as o,X as s,Y as c,Z as l,_ as u,a as d,at as f,ct as p,d as m,et as h,f as g,h as _,i as v,it as y,l as b,m as x,n as S,nt as C,ot as w,rt as T,tt as E,u as D,v as O,y as k}from"./route-DO6IZ7of.js";import{i as A,n as j,o as M,r as N,u as P}from"./graph-link-OCo_s0zO.js";import{A as F,I,L,M as R,N as z,P as B,R as ee,S as V,_ as H,a as U,b as W,c as G,j as te,n as ne,o as re,r as ie,s as K,t as q,v as ae,x as oe,z as se}from"./button-ClA70PLR.js";import{a as ce,d as le,i as ue,n as de,o as fe,t as pe,u as me}from"./zone-D9dXk8tn.js";import{t as he}from"./copy-CCXzeW-s.js";import{t as ge}from"./key-round-Cv_7QeED.js";import{t as _e}from"./loader-circle-BK_GMdvN.js";import{t as ve}from"./shield-alert-CMS-3j4U.js";import{t as ye}from"./sliders-horizontal-Dg51yc-C.js";import{a as be,i as xe,n as Se,o as Ce,r as we,t as Te}from"./table-DfMz2f8M.js";import{$ as Ee,$t as De,A as Oe,At as ke,B as Ae,Bt as J,C as je,Ct as Me,D as Ne,E as Pe,Et as Fe,F as Ie,Ft as Le,H as Re,Ht as ze,I as Be,It as Ve,J as He,Jt as Ue,K as We,Kt as Ge,L as Ke,Lt as qe,M as Je,N as Ye,Nt as Xe,O as Ze,Ot as Qe,P as $e,Q as et,Qt as tt,R as nt,Rt as rt,S as it,St as at,T as ot,Tt as st,Ut as ct,V as lt,Vt as ut,W as dt,Wt as ft,Xt as pt,Z as mt,Zt as ht,_ as gt,_t,a as vt,at as yt,b as bt,bt as xt,c as St,cn as Ct,ct as wt,d as Tt,dt as Et,et as Dt,f as Ot,ft as kt,g as At,gt as jt,h as Mt,ht as Nt,i as Pt,in as Ft,it as It,j as Lt,jt as Rt,k as zt,kt as Bt,l as Vt,lt as Ht,m as Ut,mt as Wt,n as Gt,nn as Kt,nt as qt,o as Jt,ot as Yt,p as Xt,pt as Zt,q as Qt,qt as $t,r as en,rt as tn,s as nn,sn as rn,st as an,t as on,tt as sn,u as cn,ut as ln,v as un,vt as dn,w as fn,wt as pn,x as mn,xt as hn,y as gn,yt as Y,z as _n}from"./index-CDcnUacl.js";import{t as vn}from"./format-sql-BLj5_RDZ.js";var yn={name:`box`,size:24,node:[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]};yn.node;var bn=f(yn),xn={name:`braces`,size:24,node:[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]],aliases:[`curly-braces`]};xn.node;var Sn=f(xn),Cn={name:`circle-alert`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]],aliases:[`alert-circle`]};Cn.node;var wn=f(Cn),Tn={name:`circle-check`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`check-circle-2`]};Tn.node;var En=f(Tn),Dn={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};Dn.node;var On=f(Dn),kn={name:`folder-tree`,size:24,node:[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]};kn.node;var An=f(kn),jn={name:`globe`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]};jn.node;var Mn=f(jn),Nn={name:`list-checks`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]};Nn.node;var Pn=f(Nn),Fn={name:`pin`,size:24,node:[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]};Fn.node;var In=f(Fn),Ln={name:`pin-off`,size:24,node:[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]};Ln.node;var Rn=f(Ln),zn={name:`rotate-ccw-clock`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]],aliases:[`history`]};zn.node;var Bn=f(zn),Vn={name:`save`,size:24,node:[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]};Vn.node;var Hn=f(Vn),Un={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};Un.node;var Wn=f(Un),Gn={name:`text-align-start`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]],aliases:[`text`,`align-left`]};Gn.node;var Kn=f(Gn),qn={name:`type`,size:24,node:[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]};qn.node;var Jn=f(qn),Yn={name:`workflow`,size:24,node:[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]};Yn.node;var Xn=f(Yn);function Zn(e,t){return t!=null&&!Ht(t)?0:typeof e==`function`?e():e}function Qn(e,t,n){let r=Zn(e,n);return typeof r==`number`?r:r?.[t]}function $n(e){return typeof e==`function`?e():e}function er(e,t){return t||e===`click`||e===`mousedown`}function tr(e){return e?.includes(`mouse`)&&e!==`mousedown`}function nr(e){let{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:r,floatingId:i,nested:a,onOpenChange:o}=e,s=t.useState(`open`),c=t.useState(`activeTriggerElement`),l=t.useState(n?`popupElement`:`positionerElement`),u=o;return t.useSyncedValue(`floatingId`,i),K(()=>{let e={open:s,floatingId:i,referenceElement:c,floatingElement:l};W(c)&&(e.domReferenceElement=c),r.state.positionReference===r.state.referenceElement&&(e.positionReference=c),r.update(e)},[s,i,c,l,r]),r.context.onOpenChange=u,r.context.nested=a,r}function rr(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new Tt({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0}),floatingId:t,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,openedWithoutTrigger:!1,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:z,inactiveTriggerProps:z,popupProps:z}}var ir=e=>e.triggerIdProp??e.activeTriggerId,ar=e=>e.openProp??e.open,or=e=>(e.popupElement?.id??e.floatingId)||void 0;function sr(e,t){return t!==void 0&&ar(e)&&ir(e)===t}function cr(e,t){return sr(e,t)?!0:t!==void 0&&ar(e)&&ir(e)==null&&!e.openedWithoutTrigger&&e.triggerCount===1}var lr={open:ar,mounted:e=>e.mounted,transitionStatus:e=>ar(e)&&!e.mounted?`starting`:e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:ir,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:or,isTriggerActive:(e,t)=>t!==void 0&&ir(e)===t,isOpenedByTrigger:(e,t)=>sr(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&ir(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>cr(e,t)?or(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement},X=p(w(),1),ur=Yt();function dr(e){let t=X.useCallback(t=>e===void 0?B:e.subscribeStore(t),[e]),n=X.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,ur.useSyncExternalStore)(t,n,()=>e?.serverStore)}var fr=at&&hn;function pr(e,t={}){let{enabled:n=!0,delay:r}=t,{events:i,dataRef:a}=e.context,o=X.useRef(!1),s=X.useRef(null),c=X.useRef(!0),l=Be();X.useEffect(()=>{let t=e.select(`domReferenceElement`);if(!n)return;let r=ae(t);function i(){let t=e.select(`domReferenceElement`);!e.select(`open`)&&oe(t)&&t===_t(ct(t))&&(o.current=!0,s.current=t)}function a(){c.current=!0}function l(){c.current=!1}return nt(Ke(r,`blur`,i),fr&&Ke(r,`keydown`,a,!0),fr&&Ke(r,`pointerdown`,l,!0))},[e,n]),X.useEffect(()=>{if(!n)return;function t(t){if(t.reason===`trigger-press`||t.reason===`escape-key`){let t=e.select(`domReferenceElement`);W(t)&&(s.current=t,o.current=!0)}}return i.on(`openchange`,t),()=>{i.off(`openchange`,t)}},[i,n,e]);let u=X.useMemo(()=>{function t(){o.current=!1,s.current=null}return{onMouseLeave(){t()},onFocus(n){let i=n.currentTarget;if(o.current){if(s.current===i)return;t()}let a=xt(n.nativeEvent);if(W(a)){if(fr&&!n.relatedTarget){if(!c.current&&!Zt(a))return}else if(!Wt(a))return}let u=kt(n.relatedTarget,e.context.triggerElements),{nativeEvent:d,currentTarget:f}=n;e.select(`open`)&&u||!r?e.setOpen(!0,J(qe,d,f)):l.start(r,()=>{o.current||e.setOpen(!0,J(qe,d,f))})},onBlur(n){t();let r=n.relatedTarget,i=n.nativeEvent,o=W(r)&&r.hasAttribute(Ye(`focus-guard`))&&r.getAttribute(`data-type`)===`outside`;l.start(0,()=>{let t=e.select(`domReferenceElement`),n=_t(ct(t));!r&&n===t||Y(a.current.floatingContext?.refs.floating.current,n)||Y(t,n)||o||kt(r??n,e.context.triggerElements)||e.setOpen(!1,J(qe,i))})}}},[a,r,e,l]);return X.useMemo(()=>n?{reference:u,trigger:u}:{},[n,u])}var mr=class e{pointerType=void 0;interactedInside=!1;handler=void 0;blockMouseMove=!0;performedPointerEventsMutation=!1;pointerEventsScopeElement=null;pointerEventsReferenceElement=null;pointerEventsFloatingElement=null;restTimeoutPending=!1;openChangeTimeout=new Ie;restTimeout=new Ie;handleCloseOptions=void 0;static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose},hr=new WeakMap;function gr(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&hr.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),hr.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function _r(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=hr.get(n);a&&a!==e&&gr(a),gr(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,hr.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function vr(e){let t=e.context.dataRef.current,n=L(()=>t.hoverInteractionState??mr.create()).current;return t.hoverInteractionState||=n,It(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function yr(e,t={}){let{enabled:n=!0,closeDelay:r=0,nodeId:i}=t,a=e.useState(`open`),o=e.useState(`floatingElement`),s=e.useState(`domReferenceElement`),{dataRef:c}=e.context,l=Ze(),u=Ne(),d=vr(e),f=Be(),p=G(()=>er(c.current.openEvent?.type,d.interactedInside)),m=G(()=>tr(c.current.openEvent?.type)),h=G(()=>{gr(d)});K(()=>{a||(d.pointerType=void 0,d.restTimeoutPending=!1,d.interactedInside=!1,h())},[a,d,h]),X.useEffect(()=>h,[h]),K(()=>{if(n&&a&&d.handleCloseOptions?.blockPointerEvents&&m()&&W(s)&&o){let e=s,t=o,n=ct(o),r=l?.nodesRef.current.find(e=>e.id===u)?.context?.elements.floating;r&&(r.style.pointerEvents=``);let i=d.pointerEventsScopeElement===t?null:d.pointerEventsScopeElement,a=r===t?null:r,c=d.handleCloseOptions?.getScope?.()??i??a??dn(e,`[data-rootownerid]`)??n.body;return _r(d,{scopeElement:c,referenceElement:e,floatingElement:t}),()=>{h()}}},[n,a,s,o,d,m,l,u,h]),X.useEffect(()=>{if(!n)return;function t(){return!!(l&&u&&ln(l.nodesRef.current,u).length>0)}function a(t){let n=Qn(r,`close`,d.pointerType),i=()=>{e.setOpen(!1,J(rt,t)),l?.events.emit(`floating.closed`,t)};n?d.openChangeTimeout.start(n,i):(d.openChangeTimeout.clear(),i())}function s(e){let t=xt(e);Et(t)?d.interactedInside=dn(t,`[aria-haspopup]`)!=null:d.interactedInside=!1}function g(){d.openChangeTimeout.clear(),f.clear(),l?.events.off(`floating.closed`,v),h()}function _(n){if(t()&&l){l.events.on(`floating.closed`,v);return}if(kt(n.relatedTarget,e.context.triggerElements))return;let r=c.current.floatingContext?.nodeId??i,o=n.relatedTarget;l&&r&&W(o)&&ln(l.nodesRef.current,r,!1).some(e=>Y(e.context?.elements.floating,o))||(d.handler?d.handler(n):(h(),m()&&!p()&&a(n)))}function v(n){l&&u&&!t()&&f.start(0,()=>{l.events.off(`floating.closed`,v),e.setOpen(!1,J(rt,n)),l.events.emit(`floating.closed`,n)})}let y=o;return nt(y&&Ke(y,`mouseenter`,g),y&&Ke(y,`mouseleave`,_),y&&Ke(y,`pointerdown`,s,!0),()=>{l?.events.off(`floating.closed`,v)})},[n,o,e,c,r,i,m,p,h,d,l,u,f])}var br=p(Ct(),1),xr={current:null};function Sr(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=xr,externalTree:l,isActiveTrigger:u=!0,getHandleCloseContext:d,isClosing:f,shouldOpen:p,guardStaleOpen:m=!1}=t,{dataRef:h,events:g}=e.context,_=Ze(l),v=vr(e),y=X.useRef(!1),b=Re(i),x=Re(r),S=Re(o),C=Re(n),w=Re(p),T=Re(f),E=G(()=>er(h.current.openEvent?.type,v.interactedInside)),D=G(()=>w.current?.()!==!1),O=G((t,n,r)=>{let i=e.context.triggerElements;if(i.hasElement(n))return!t||!Y(t,n);if(!W(r))return!1;let a=r;return i.hasMatchingElement(e=>Y(e,a))&&(!t||!Y(t,a))}),k=G(()=>{v.handler&&=(ct(e.select(`domReferenceElement`)).removeEventListener(`mousemove`,v.handler),void 0)}),A=G(()=>{gr(v)});return u&&(v.handleCloseOptions=i?.__options),X.useEffect(()=>k,[k]),X.useEffect(()=>{if(!n)return;function e(e){e.open?y.current=!1:(y.current=e.reason===rt,k(),v.openChangeTimeout.clear(),v.restTimeout.clear(),v.blockMouseMove=!0,v.restTimeoutPending=!1)}return g.on(`openchange`,e),()=>{g.off(`openchange`,e)}},[n,g,v,k]),X.useEffect(()=>{if(!n)return;function t(t,n=!0){let r=Qn(x.current,`close`,v.pointerType);r?v.openChangeTimeout.start(r,()=>{e.setOpen(!1,J(rt,t)),_?.events.emit(`floating.closed`,t)}):n&&(v.openChangeTimeout.clear(),e.setOpen(!1,J(rt,t)),_?.events.emit(`floating.closed`,t))}let r=c.current??(u?e.select(`domReferenceElement`):null);if(!W(r))return;function i(t){if(v.openChangeTimeout.clear(),v.blockMouseMove=!1,a&&!Ht(v.pointerType))return;let n=$n(S.current),r=Qn(x.current,`open`,v.pointerType),i=xt(t),o=t.currentTarget??null,s=e.select(`domReferenceElement`),c=o;if(W(i)&&!e.context.triggerElements.hasElement(i)){for(let t of e.context.triggerElements.elements())if(Y(t,i)){c=t;break}}W(o)&&W(s)&&!e.context.triggerElements.hasElement(o)&&Y(o,s)&&(c=s);let l=c!=null&&O(s,c,i),u=e.select(`open`),d=T.current?.()??e.select(`transitionStatus`)===`ending`,f=!u&&d&&y.current,p=!l&&W(c)&&W(s)&&Y(s,c)&&f,m=n>0&&!r,h=l&&(u||f)||p,g=!u||l;h?D()&&e.setOpen(!0,J(rt,t,c)):m||(r?v.openChangeTimeout.start(r,()=>{g&&D()&&e.setOpen(!0,J(rt,t,c))}):g&&D()&&e.setOpen(!0,J(rt,t,c)))}function o(n){if(E()){A();return}k();let r=e.select(`domReferenceElement`),i=ct(r);v.restTimeout.clear(),v.restTimeoutPending=!1;let a=h.current.floatingContext??d?.();if(!kt(n.relatedTarget,e.context.triggerElements)){if(b.current&&a){e.select(`open`)||v.openChangeTimeout.clear();let r=c.current;v.handler=b.current({...a,tree:_,x:n.clientX,y:n.clientY,onClose(){A(),k(),C.current&&!E()&&r===e.select(`domReferenceElement`)&&t(n,!0)}}),i.addEventListener(`mousemove`,v.handler),v.handler(n)}else v.pointerType===`touch`&&Y(e.select(`floatingElement`),n.relatedTarget)||t(n)}}function l(e){Y(r,e.relatedTarget)||(v.openChangeTimeout.clear(),v.restTimeout.clear(),v.restTimeoutPending=!1)}let f=m?Ke(r,`mouseout`,l):void 0;return s?nt(Ke(r,`mousemove`,i,{once:!0}),Ke(r,`mouseenter`,i),Ke(r,`mouseleave`,o),f):nt(Ke(r,`mouseenter`,i),Ke(r,`mouseleave`,o),f)},[k,A,h,x,e,n,b,v,u,O,E,a,s,S,c,_,C,d,T,D,m]),X.useMemo(()=>{if(!n)return;function t(e){v.pointerType=e.pointerType}return{onPointerDown:t,onPointerEnter:t,onMouseMove(t){let{nativeEvent:n}=t,r=t.currentTarget,i=e.select(`domReferenceElement`),o=e.select(`open`),s=O(i,r,t.target);if(a&&!Ht(v.pointerType))return;if(o&&s&&v.handleCloseOptions?.blockPointerEvents){let t=e.select(`floatingElement`);if(t){let e=v.handleCloseOptions?.getScope?.()??r.ownerDocument.body;_r(v,{scopeElement:e,referenceElement:r,floatingElement:t})}}let c=$n(S.current);if(o&&!s||c===0||!s&&v.restTimeoutPending&&t.movementX**2+t.movementY**2<2)return;v.restTimeout.clear();function l(){if(v.restTimeoutPending=!1,E())return;let t=e.select(`open`);!v.blockMouseMove&&(!t||s)&&D()&&e.setOpen(!0,J(rt,n,r))}v.pointerType===`touch`?br.flushSync(()=>{l()}):s&&o?l():(v.restTimeoutPending=!0,v.restTimeout.start(c,l))}}},[n,v,E,O,a,e,S,D])}var Cr=.1,wr=Cr*Cr,Z=.5;function Tr(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function Er(e,t,n,r,i,a,o,s,c,l){let u=!1;return Tr(e,t,n,r,i,a)&&(u=!u),Tr(e,t,i,a,o,s)&&(u=!u),Tr(e,t,o,s,c,l)&&(u=!u),Tr(e,t,c,l,n,r)&&(u=!u),u}function Dr(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function Or(e,t,n,r,i,a){return e>=Math.min(n,i)&&e<=Math.max(n,i)&&t>=Math.min(r,a)&&t<=Math.max(r,a)}function kr(e={}){let{blockPointerEvents:t=!1}=e,n=new Ie,r=({x:e,y:t,placement:r,elements:i,onClose:a,nodeId:o,tree:s})=>{let c=r?.split(`-`)[0],l=!1,u=null,d=null,f=typeof performance<`u`?performance.now():0;function p(e,t){let n=performance.now(),r=n-f;if(u===null||d===null||r===0)return u=e,d=t,f=n,!1;let i=e-u,a=t-d,o=i*i+a*a,s=r*r*wr;return u=e,d=t,f=n,o<s}function m(){n.clear(),a()}return function(r){n.clear();let a=i.domReference,u=i.floating;if(!a||!u||c==null||e==null||t==null)return;let{clientX:d,clientY:f}=r,h=xt(r),g=r.type===`mouseleave`,_=Y(u,h),v=Y(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&W(r.relatedTarget)&&Y(u,r.relatedTarget))return;function y(){return!!(s&&ln(s.nodesRef.current,o).length>0)}function b(){y()||m()}if(y())return;let x=a.getBoundingClientRect(),S=u.getBoundingClientRect(),C=e>S.right-S.width/2,w=t>S.bottom-S.height/2,T=S.width>x.width,E=S.height>x.height,D=(T?x:S).left,O=(T?x:S).right,k=(E?x:S).top,A=(E?x:S).bottom;if(c===`top`&&t>=x.bottom-1||c===`bottom`&&t<=x.top+1||c===`left`&&e>=x.right-1||c===`right`&&e<=x.left+1){b();return}let j=!1;switch(c){case`top`:j=Or(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=Or(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=Or(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=Or(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!Dr(d,f,x)||!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?Z/2:Z*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+Z+1,o=C||T?S.bottom-Z:S.top,s=C?T?S.bottom-Z:S.top:S.bottom-Z;M=Er(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?Z/2:Z*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-Z,o=C||T?S.top+Z:S.bottom,s=C?T?S.top+Z:S.bottom:S.top+Z;M=Er(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?Z/2:Z*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+Z+1,o=w||E?S.right-Z:S.left,s=w?E?S.right-Z:S.left:S.right-Z;M=Er(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?Z/2:Z*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-Z,o=w||E?S.left+Z:S.right,s=w?E?S.left+Z:S.right:S.left+Z;M=Er(d,f,a,r,a,i,o,S.top,s,S.bottom);break}}M?l||n.start(40,b):b()}};return r.__options={...e,blockPointerEvents:t},r}var Q=T(),Ar=[`statement_timeout`,`work_mem`,`search_path`,`role`,`enable_seqscan`,`enable_nestloop`,`random_page_cost`,`app.tenant_id`];function jr(e){let[t,n]=(0,X.useState)(()=>E(e));return{rows:t,change:t=>{n(t),C(e,h(t))},count:h(t).length}}function Mr({rows:e,change:t}){return(0,Q.jsx)(Q.Fragment,{children:(0,Q.jsxs)(`div`,{className:`basis-full space-y-2 border p-3`,role:`group`,"aria-label":`Session settings`,children:[(0,Q.jsx)(`datalist`,{id:`guc-names`,children:Ar.map(e=>(0,Q.jsx)(`option`,{value:e},e))}),e.map((n,r)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{className:`border-input bg-card w-56 border px-2 py-1 font-mono text-sm`,list:`guc-names`,placeholder:`name, e.g. statement_timeout`,"aria-label":`Setting name`,value:n.name,onChange:n=>t(e.map((e,t)=>t===r?{...e,name:n.target.value}:e))}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`=`}),(0,Q.jsx)(`input`,{className:`border-input bg-card w-56 border px-2 py-1 font-mono text-sm`,placeholder:`value, e.g. 5s`,"aria-label":`Setting value`,value:n.value,onChange:n=>t(e.map((e,t)=>t===r?{...e,value:n.target.value}:e))}),(0,Q.jsx)(q,{variant:`outline`,"aria-label":`Remove setting`,onClick:()=>t(e.filter((e,t)=>t!==r)),children:(0,Q.jsx)($t,{className:`size-4`})})]},r)),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(q,{variant:`outline`,onClick:()=>t([...e,{name:``,value:``}]),children:[(0,Q.jsx)(tt,{className:`size-4`}),` Add setting`]}),(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Set with set_config for the whole session before Run, Explain and export; remembered per environment in this browser.`})]})]})})}var Nr=`border-input bg-background rounded-lg border px-2 py-1 text-sm`,Pr=e=>e.trim().replace(/\s+/g,` `);function Fr({environment:t,sql:n,refresh:r,onPick:i}){let[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)([]),[l,u]=(0,X.useState)([]),[d,f]=(0,X.useState)(),[p,m]=(0,X.useState)(``),[h,g]=(0,X.useState)(``),[_,v]=(0,X.useState)(0);(0,X.useEffect)(()=>{let n=!0,r=window.setTimeout(()=>{Promise.all([e.history(t,a),e.saved(t)]).then(([e,t])=>{n&&(c(e),u(t),f(void 0))},e=>n&&f(e.message))},200);return()=>{n=!1,window.clearTimeout(r)}},[t,a,r,_]);let y=e=>e.then(()=>v(e=>e+1),e=>f(e.message)),b=a.trim().toLowerCase(),x=(0,X.useMemo)(()=>l.filter(e=>!b||e.name.toLowerCase().includes(b)||e.folder.toLowerCase().includes(b)||e.sql.toLowerCase().includes(b)),[l,b]),S=(0,X.useMemo)(()=>{let e=new Map;for(let t of x)e.set(t.folder,[...e.get(t.folder)??[],t]);return[...e]},[x]),C=[...new Set(l.map(e=>e.folder).filter(Boolean))];return(0,Q.jsxs)(`section`,{"aria-label":`History and saved queries`,className:`border-input mb-4 border p-3`,children:[(0,Q.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`search`,"aria-label":`Search history and saved queries`,placeholder:`Search history and saved queries`,value:a,onChange:e=>o(e.target.value),className:`${Nr} w-72`}),(0,Q.jsx)(`input`,{"aria-label":`Name for the query`,placeholder:`Name`,value:p,maxLength:80,onChange:e=>m(e.target.value),className:`${Nr} w-40`}),(0,Q.jsx)(`input`,{"aria-label":`Folder for the query`,placeholder:`Folder`,value:h,list:`query-folders`,maxLength:60,onChange:e=>g(e.target.value),className:`${Nr} w-36`}),(0,Q.jsx)(`datalist`,{id:`query-folders`,children:C.map(e=>(0,Q.jsx)(`option`,{value:e},e))}),(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,disabled:!n.trim(),onClick:()=>{y(e.saveQuery(t,{sql:n,name:p,folder:h})),m(``)},children:[(0,Q.jsx)(Hn,{}),` Save current query`]})]}),d&&(0,Q.jsx)(`p`,{className:`text-destructive mb-2 text-sm`,children:d}),(0,Q.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`mb-1 text-sm font-medium`,children:`Saved`}),S.length===0&&(0,Q.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:b?`No saved query matches.`:`Nothing saved yet. Name the query above and save it, or pin one from the history.`}),S.map(([n,r])=>(0,Q.jsxs)(`div`,{className:`mb-2`,children:[(n||S.length>1)&&(0,Q.jsx)(`p`,{className:`text-muted-foreground text-xs font-medium uppercase`,children:n||`No folder`}),(0,Q.jsx)(`ul`,{className:`text-sm`,children:r.map(n=>(0,Q.jsxs)(`li`,{className:`group flex items-center gap-2 py-0.5`,children:[(0,Q.jsx)(`button`,{type:`button`,title:n.sql,onClick:()=>i(n.sql,n.name),className:`hover:text-accent-text min-w-0 flex-1 truncate text-left`,children:n.name}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":n.pinned?`Unpin ${n.name}`:`Pin ${n.name}`,title:n.pinned?`Unpin`:`Pin to the top`,onClick:()=>y(e.updateSaved(t,n.id,{pinned:!n.pinned})),className:n.pinned?`text-accent-text`:`text-muted-foreground hover:text-foreground`,children:n.pinned?(0,Q.jsx)(In,{className:`size-3.5`}):(0,Q.jsx)(Rn,{className:`size-3.5`})}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Delete ${n.name}`,title:`Delete`,onClick:()=>y(e.deleteSaved(t,n.id)),className:`text-muted-foreground hover:text-destructive`,children:(0,Q.jsx)(Ue,{className:`size-3.5`})})]},n.id))})]},n))]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`mb-1 text-sm font-medium`,children:`History`}),s.length===0&&(0,Q.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:b?`No statement in the history matches.`:`No statements run yet.`}),(0,Q.jsx)(`ul`,{className:`max-h-72 overflow-auto text-sm`,children:s.map(n=>(0,Q.jsxs)(`li`,{className:`flex items-center gap-2 py-0.5`,children:[(0,Q.jsx)(`button`,{type:`button`,title:n.sql,onClick:()=>i(n.sql),className:`hover:text-accent-text min-w-0 flex-1 truncate text-left font-mono text-xs`,children:Pr(n.sql)}),(0,Q.jsxs)(`span`,{className:`shrink-0 text-xs ${n.error?`text-destructive`:`text-muted-foreground`}`,title:n.error??void 0,children:[n.error?`failed`:et(n.durationMs),` · `,mt(n.at)]}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Pin to saved queries`,title:`Pin to saved queries`,onClick:()=>y(e.saveQuery(t,{sql:n.sql,pinned:!0})),className:`text-muted-foreground hover:text-foreground`,children:(0,Q.jsx)(In,{className:`size-3.5`})})]},n.id))})]})]})]})}var Ir=X.createContext(void 0);function Lr(e){let t=X.useContext(Ir);if(t===void 0&&!e)throw Error(re(33));return t}var Rr=X.createContext(void 0);function zr(e){let t=X.useContext(Rr);if(t===void 0&&!e)throw Error(re(36));return t}var Br=X.createContext(void 0);function Vr(e=!0){let t=X.useContext(Br);if(t===void 0&&!e)throw Error(re(25));return t}var Hr=X.createContext(null);function Ur(e=`root`){let t=X.useContext(Hr),n=X.useContext(Rr);return t===null||n===void 0?null:(e===`submenu-trigger`?n.virtualFocus||n.parentVirtualFocus:n.virtualFocus)?t:null}var Wr={visible:!0,ref:null};function Gr(){return Wr}function Kr(e,t,n=`root`){let r=Ur(n),i=((n===`submenu-trigger`?r?.useSubmenuTrigger:r?.useItem)??Gr)({label:e.label,children:e.children,render:e.render}),a=I(t,i.ref);return{visible:i.visible,ref:a,props:i.props}}function qr(e){e.preventDefault()}function Jr(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,l=zr(),u=Vr(!0),d=c.type===`submenu-trigger`,f=d?l.parentVirtualFocus:l.virtualFocus,p=(d&&l.parent.type===`menu`?l.parent.store:l.store).useState(`webkitAriaSelected`,n),{events:m}=a.useState(`floatingTreeRoot`),h=a.useState(`open`),g=u!==void 0,_=!f&&h&&n?0:-1;return X.useMemo(()=>({id:r,role:`menuitem`,tabIndex:_,"aria-selected":p,onMouseDown:f?qr:void 0,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&m.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&m.emit(`close`,{domEvent:e.nativeEvent,reason:ke})},onMouseUp(e){if(u){let t=u.initialCursorPointRef.current;if(u.initialCursorPointRef.current=null,g&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||g&&!at&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!g||e.button===2)&&c.type===`regular-item`&&ie(s.current,e,{detail:1,pointerType:`mouse`})}}),[t,_,r,m,i,a.context.allowMouseUpTriggerRef,o,s,u,g,c.type,p,f])}var Yr={type:`regular-item`};function Xr(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=X.useRef(null),{getButtonProps:d,buttonRef:f}=ne({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=Jr({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=X.useCallback(e=>ee(p,{onMouseEnter(e){c.type===`submenu-trigger`&&c.setActive(e.nativeEvent)}},e,d),[p,d,c]),h=I(u,f);return X.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var Zr=X.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,{store:d}=zr(),f=pn({guess:!0,label:a}),p=st(i),m=d.useState(`disabled`),h=d.useState(`isActive`,f.index),g=d.useState(`floatingNodeId`),_=d.useState(`itemProps`),v=s||m,{getItemProps:y,itemRef:b}=Xr({closeOnClick:c,disabled:v,highlighted:h,id:p,store:d,nativeButton:o,nodeId:g,itemMetadata:Yr});return te(`div`,e,{state:{disabled:v,highlighted:h},props:[_,u,y],ref:[b,t,f.ref]})}),Qr=X.forwardRef(function(e,t){let n=Kr(e,t);return n.visible?(0,Q.jsx)(Zr,{...e,ref:n.ref}):null}),$r=X.createContext(void 0);function ei(){return X.useContext($r)}function ti(e,t){let n=F(e.render);if(X.isValidElement(n)){let e=n.props;if(Object.hasOwn(e,`id`))return e.id??``}return e.id??t}function ni(e,t,n){let r=ti(e,t),i=r===t?void 0:r;return[r,X.useCallback(e=>n?.(e?i:void 0),[i,n])]}function ri(e,t,n){let r=F(e.render),i=X.isValidElement(r)?r.props:void 0,a=e[`aria-label`]??i?.[`aria-label`],o=e[`aria-labelledby`]??i?.[`aria-labelledby`];return o==null&&!a&&(o=t?t.id||void 0:n||void 0),o}var ii=X.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,id:o,initialFocus:s,...c}=e,{store:l,defaultFloatingId:u,setRenderedFloatingId:d,virtualFocus:f,orientation:p}=zr(),m=ei(),{side:h,align:g}=Lr(),_=on(!0)!=null,v=l.useState(`open`),y=l.useState(`transitionStatus`),b=l.useState(`popupProps`),x=l.useState(`mounted`),S=l.useState(`instantType`),C=l.useState(`activeTriggerElement`),w=l.useState(`parent`),T=l.useState(`lastOpenChangeReason`),E=l.useState(`rootId`),D=l.useState(`floatingRootContext`),O=l.useState(`floatingTreeRoot`),k=l.useState(`closeDelay`),A=l.useState(`hoverEnabled`),j=l.useState(`disabled`),M=l.useState(`openMethod`),N=l.useState(`activeTriggerId`),P=l.useState(`listElement`),[F,I]=ni(e,u,d),L=ri(e,C,N),R=w.type===`menu`?m:void 0,z=w.type===`context-menu`,B=s??w.type!==`menu`;s===void 0&&P&&w.type!==`menu`&&(B=()=>l.state.activeIndex===null&&P),qt({open:v,ref:l.context.popupRef,onComplete(){v&&l.context.onOpenChangeComplete?.(!0)}}),X.useEffect(()=>{function e(e){l.setOpen(!1,J(e.reason,e.domEvent))}return O.events.on(`close`,e),()=>{O.events.off(`close`,e)}},[O.events,l]),yr(D,{enabled:A&&!j&&!z&&w.type!==`menubar`,closeDelay:k});let ee=l.useStateSetter(`popupElement`),{parentVirtualFocusRef:V,handleFocus:H}=(X.useContext(Hr)?.useParentHandoff??oi)(l,w,v,f),U={transitionStatus:y,side:h,align:g,open:v,nested:w.type===`menu`,instant:S},W=te(`div`,e,{state:U,ref:[t,l.context.popupRef,ee,I],stateAttributesMapping:Nt,props:[b,{id:F,...P?{role:`presentation`}:{role:`menu`,"aria-orientation":p===`horizontal`?`horizontal`:void 0,"aria-labelledby":L},onKeyDown(e){R?.onPopupKeyDown?.(e),_&&sn.has(e.key)&&e.stopPropagation()},onFocus:H},Pt(y),c,{"data-rootownerid":E}]}),G=w.type===void 0||z;(C||w.type===`menubar`&&T!==`outside-press`)&&(G=!0);let ne=R?.getReturnElement??V;return(0,Q.jsx)(je,{context:D,openInteractionType:M,modal:z,disabled:!x,returnFocus:a??ne??G,explicitReturnFocus:a===void 0&&ne?!1:void 0,initialFocus:B,restoreFocus:!0,getInsideElements:w.type===void 0?()=>[l.context.beforeTriggerFocusGuardRef.current]:void 0,externalTree:w.type===`menubar`?void 0:O,previousFocusableElement:C,nextFocusableElement:w.type===void 0?l.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:W})}),ai={parentVirtualFocusRef:void 0,handleFocus:void 0};function oi(){return ai}var si=X.forwardRef(function(e,t){let n=Ur()?.Popup??ii;return(0,Q.jsx)(n,{...e,ref:t})}),ci=X.createContext(void 0);function li(){let e=X.useContext(ci);if(e===void 0)throw Error(re(32));return e}var ui=X.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=zr();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,Q.jsx)(ci.Provider,{value:n,children:(0,Q.jsx)(Oe,{ref:t,...r,portalOwnerRole:o})})});function di(e){let{store:t,domReference:n,positionerElement:r,open:i}=e,a=X.useRef(null),o=X.useRef(null),s=tn(r);K(()=>{i||(o.current?.abort(),o.current=null,t.state.instantType===`trigger-change`&&t.set(`instantType`,void 0))},[i,t]),K(()=>{let e=n,r=a.current;if(e&&(a.current=e),!r||!e||e===r||!t.select(`open`))return;t.set(`instantType`,void 0);let i=new AbortController;return o.current=i,s(()=>{t.select(`open`)&&t.set(`instantType`,`trigger-change`)},i.signal),()=>{i.abort()}},[n,s,t])}var fi=X.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=Lt,style:g,..._}=e,{store:v,virtualFocus:y,syncHighlightedItem:b}=zr(),x=li(),S=Vr(!0),C=v.useState(`parent`),w=v.useState(`floatingRootContext`),T=v.useState(`floatingTreeRoot`),E=v.useState(`mounted`),D=v.useState(`open`),O=v.useState(`modal`),k=v.useState(`openMethod`),A=v.useState(`activeTriggerElement`),j=v.useState(`transitionStatus`),M=v.useState(`positionerElement`),N=v.useState(`instantType`),P=v.useState(`adaptiveOrigin`),F=v.useState(`lastOpenChangeReason`),I=v.useState(`floatingNodeId`),L=v.useState(`floatingParentNodeId`),R=w.useState(`domReferenceElement`),z=n,B=c,ee=l,V=s,H=h;C.type===`context-menu`&&(z=n??C.context?.anchor,V??=`start`,!o&&V!==`center`&&(ee=e.alignOffset??2,B=e.sideOffset??-5));let U=o,W=V;C.type===`menu`?(U??=`inline-end`,W??=`start`,H=e.collisionAvoidance??Je):C.type===`menubar`&&(U??=C.context.orientation===`vertical`?`inline-end`:`bottom`,W??=`start`);let G=C.type===`context-menu`,te=Jt({anchor:z,floatingRootContext:w,positionMethod:S?`fixed`:r,mounted:E,side:U,sideOffset:B,align:W,alignOffset:ee,arrowPadding:G?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:I,keepMounted:x,disableAnchorTracking:m,collisionAvoidance:H,shift:G?{crossAxis:!(`side`in H&&H.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:T,adaptiveOrigin:P,lazyFlip:y?`placement`:!1});X.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===I&&v.set(`hoverEnabled`,!1),e.nodeId!==I&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,J(Ve)))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[v,T.events,I]),X.useEffect(()=>{if(v.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==v.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;v.setOpen(!1,J(t))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[T.events,v]);let ne=Be();X.useEffect(()=>{D||ne.clear()},[D,ne]),X.useEffect(()=>{function e(e){if(D&&e.nodeId===v.select(`floatingParentNodeId`)){if(e.target&&A&&A!==e.target){let e=v.select(`closeDelay`);e>0?ne.isStarted()||ne.start(e,()=>{v.setOpen(!1,J(Ve))}):v.setOpen(!1,J(Ve))}else ne.clear()}}return T.events.on(`itemhover`,e),()=>{T.events.off(`itemhover`,e)}},[T.events,D,A,v,ne]),X.useEffect(()=>{let e={open:D,nodeId:I,parentNodeId:L,reason:v.select(`lastOpenChangeReason`)};T.events.emit(`menuopenchange`,e)},[T.events,D,v,I,L]),di({store:v,domReference:R,positionerElement:M,open:D});let re={open:D,side:te.side,align:te.align,anchorHidden:te.anchorHidden,nested:C.type===`menu`,instant:N},ie=C.type===`menubar`&&C.context.modal;Gt(D&&(ie||O&&F!==`trigger-hover`),k===`touch`,M,A);let K=en(e,re,{styles:te.positionerStyles,transitionStatus:j,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!E,inert:!D}),q=E&&C.type!==`menu`&&(C.type!==`menubar`&&O&&F!==`trigger-hover`||C.type===`menubar`&&C.context.modal),ae=null;return C.type===`menubar`?ae=C.context.contentElement:C.type===void 0&&(ae=A),(0,Q.jsxs)(Ir.Provider,{value:te,children:[q&&(0,Q.jsx)(vt,{ref:C.type===`context-menu`||C.type===`nested-context-menu`?C.context.internalBackdropRef:null,inert:yt(!D),cutout:ae}),(0,Q.jsx)(fn,{id:I,children:(0,Q.jsx)(ze,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,onMapChange:b,children:K})})]})}),pi=X.createContext(null);function mi(e){let t=X.useContext(pi);if(t===null&&!e)throw Error(re(5));return t}function hi(e){return e==null?Xe:e.type.startsWith(`key`)?Rt:e.type.startsWith(`mouse`)||e.type.startsWith(`pointer`)?Le:Xe}var gi={...lr,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,keyboardOpen:e=>e.keyboardOpen,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,listElement:e=>e.listElement,triggerControlsId:(e,t)=>{let n=lr.triggerPopupId(e,t);return n?e.listElement?.id||n:void 0},filterTriggerProps:e=>e.filterTriggerProps,inputProps:e=>e.inputProps,webkitAriaSelected:(e,t)=>hn&&e.inputFocused&&t?!0:void 0,highlightedItemId:e=>e.highlightedItem?.id||void 0,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType===`trigger-change`&&!lr.open(e)?void 0:e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},_i=class extends _n{constructor(e,t,n=!1){let r=new Ot,i=yi(r,t,n,e);super(i,vi(r),gi),this.observe(`parent`,e=>{e.type===`menu`?this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef:e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef)})}subscribeToParentMenu(){let e=this.state.parent;if(e.type!==`menu`)return;let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);return e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}setActiveIndex(e,t,n){if(this.state.activeIndex!==e){let r=(e===null?void 0:this.context.itemDomElements.current[e])===this.context.reportedItem;this.context.highlightReason=r?`none`:t,this.context.highlightEvent=r?void 0:n}this.set(`activeIndex`,e)}highlightItem(e,t,n){let r=this.context.itemDomElements.current.indexOf(e);r>-1&&this.setActiveIndex(r,t,n)}};function vi(e){return{positionerRef:X.createRef(),popupRef:X.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},highlightReason:`none`,highlightEvent:void 0,reportedItem:void 0,allowMouseUpTriggerRef:{current:!1},virtualFocusRef:void 0,triggerFocusTargetRef:X.createRef(),beforeTriggerFocusGuardRef:X.createRef(),beforeContentFocusGuardRef:X.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function yi(e,t,n=!1,r){return{...rr(e,t,n),disabled:!1,modal:!0,openMethod:null,keyboardOpen:!1,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,listElement:null,filterTriggerProps:z,inputProps:z,inputFocused:!1,highlightedItem:void 0,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new zt,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:z,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var bi=X.createContext(null);function xi(e,t){return(e===`trigger-press`||e===`item-press`)&&t?.detail===0}function Si(e,t){return e===`list-navigation`||xi(e,t)}var Ci=Ae(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,onItemHighlighted:a,defaultOpen:o=!1,disabled:s=!1,modal:c,loopFocus:l=!0,orientation:u=`vertical`,actionsRef:d,closeParentOnEsc:f=!1,handle:p,triggerId:m,defaultTriggerId:h=null,highlightItemOnHover:g=!0,isSubmenu:_=!1,virtualFocus:v=!1,virtualFocusRef:y,allowEscape:b=!0,resetOnPointerLeave:x=!0}=e,S=Vr(!0),C=zr(!0),w=mi(!0),T=C?.store,E=C?.virtualFocus??!1,D=X.useMemo(()=>_&&T?{type:`menu`,store:T}:w?{type:`menubar`,context:w}:S&&!T?{type:`context-menu`,context:S}:{type:void 0},[S,T,w,_]),O=st(),k=st(),[A,j]=X.useState(void 0),M=(A??k)||void 0,N=Ne(),P=D.type===`menu`?D.store:void 0,F=(n??o)&&P?.state.transitionStatus===`starting`,I=L(()=>F?P?.state.instantType:void 0).current,B=L(()=>{let e=new _i({open:o,openProp:n,activeTriggerId:h,triggerIdProp:m,parent:D,disabled:s,highlightItemOnHover:g,modal:D.type===void 0?c:void 0,rootId:O,instantType:I},M,N!=null);return e.context.virtualFocusRef=y,e}).current;B.useControlledProp(`openProp`,n),B.useControlledProp(`triggerIdProp`,m),B.useContextCallback(`onOpenChangeComplete`,i);let V=B.useState(`floatingTreeRoot`),H=Pe(V),U=B.useState(`open`),W=B.useState(`activeTriggerElement`),te=B.useState(`positionerElement`),ne=B.useState(`hoverEnabled`),re=B.useState(`disabled`),ie=B.useState(`lastOpenChangeReason`),q=B.useState(`parent`),ae=B.useState(`activeIndex`),oe=B.useState(`keyboardOpen`),se=B.useState(`payload`),ce=B.useState(`floatingParentNodeId`),le=X.useRef(null),ue=X.useRef(q.type!==`context-menu`),de=Be(),fe=X.useRef(!0),pe=Be(),me=ce!=null,{openMethod:he,triggerProps:ge}=St(U);B.useSyncedValues({disabled:s,highlightItemOnHover:g,modal:q.type===void 0?c:void 0,openMethod:he,rootId:O}),gt(B);let{forceUnmount:_e,transitionStatus:ve}=un(U,B,()=>{B.set(`allowMouseEnter`,!1)},F),ye=tn(B.context.popupRef);X.useEffect(()=>{if(I===void 0)return;let e=()=>{B.state.instantType===I&&B.set(`instantType`,void 0)};if(!U){e();return}if(ve!==void 0)return;if(B.context.popupRef.current==null){e();return}let t=new AbortController;return ye(e,t.signal),()=>{t.abort()}},[I,U,ve,ye,B]),K(()=>{S&&!C?B.update({parent:{type:`context-menu`,context:S},floatingNodeId:H,floatingParentNodeId:N}):(C||!B.select(`activeTriggerElement`))&&B.update({floatingNodeId:H,floatingParentNodeId:N})},[S,C,H,N,W,B]),X.useEffect(()=>{U||(le.current=null),q.type===`context-menu`&&(U?de.start(500,()=>{ue.current=!0}):(de.clear(),ue.current=!1))},[de,U,q.type]),K(()=>{!U&&!ne&&B.set(`hoverEnabled`,!0)},[U,ne,B]);let be=G((e,t)=>{let n=t.reason;if(!e&&!B.select(`open`)||U===e&&t.trigger===W&&ie===n)return;let i=Mt(t);if(!e&&t.trigger==null&&(t.trigger=W??void 0),r?.(e,t),t.isCanceled)return;B.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&n!==`item-press`&&a?.type===`click`&&a.pointerType===`touch`&&!fe.current)return;e&&n===`trigger-focus`?(fe.current=!1,pe.start(300,()=>{fe.current=!0})):(fe.current=!0,pe.clear());let o=!e&&(n===`escape-key`||n==null);le.current=t.event;let s=At(B.state,e,t.trigger,i());s.openChangeReason=n,s.keyboardOpen=e&&Si(n,a),s.instantType=q.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:xi(n,a)?`click`:o?`dismiss`:void 0,B.update(s)}),xe=nr({popupStore:B,floatingRootContext:B.state.floatingRootContext,floatingId:M,nested:N!=null,onOpenChange:be}),Se=xe.context.events;K(()=>{let e=({open:e,eventDetails:t})=>be(e,t);return Se.on(`setOpen`,e),()=>{Se?.off(`setOpen`,e)}},[Se,be]),K(()=>B.subscribeToParentMenu(),[B]);let Ce=X.useCallback(()=>{B.setOpen(!1,J(Bt))},[B]);X.useImperativeHandle(d,()=>({unmount:_e,close:Ce}),[_e,Ce]);let we;q.type===`context-menu`&&(we=q.context),X.useImperativeHandle(we?.positionerRef,()=>te,[te]),X.useImperativeHandle(we?.actionsRef,()=>({setOpen:be}),[be]);let Te=mn(xe,{enabled:!re,bubbles:{escapeKey:f&&q.type===`menu`},outsidePress(){return q.type!==`context-menu`||le.current?.type===`contextmenu`||ue.current},externalTree:me?V:void 0}),Ee=Dt(),De=cn(xe,{enabled:!re,listRef:B.context.itemDomElements,activeIndex:ae,virtual:v,nested:q.type===`menubar`||!v&&q.type!==void 0,parentOrientation:q.type===`menubar`?q.context.orientation:void 0,loopFocus:l,focusItemOnOpen:v?oe:void 0,allowEscape:v&&l&&b,orientation:u,triggerOrientation:v?`vertical`:u,rtl:Ee===`rtl`,disabledIndices:R,onNavigate(e,t){B.setActiveIndex(e,hi(t),t?.nativeEvent)},openOnArrowKeyDown:q.type!==`context-menu`&&!(v&&_),externalTree:!v&&me?V:void 0,nestedReturnFocusRef:P?.context.virtualFocusRef,focusItemOnHover:g,resetOnPointerLeave:x}),Oe=X.useCallback(e=>{B.context.typingRef.current=e},[B]),ke=Vt(xe,{enabled:!re&&!v,listRef:B.context.itemLabels,elementsRef:B.context.itemDomElements,activeIndex:ae,resetMs:500,onMatch:(e,t)=>{U&&e!==ae&&B.setActiveIndex(e,Rt,t.nativeEvent)},onTyping:Oe}),Ae=G(a),je=X.useRef(-1),Me=G(()=>{let e=B.state.activeIndex,t=e===null?void 0:B.context.itemDomElements.current[e]??void 0;if(t?.isConnected===!1)return;let n=t===void 0?-1:e;if(je.current===n&&B.context.reportedItem===t)return;je.current=n,B.context.reportedItem=t,v&&B.set(`highlightedItem`,t);let{highlightReason:r,highlightEvent:i}=B.context;B.context.highlightReason=Xe,B.context.highlightEvent=void 0,a&&Ae(t,ut(r,i,{label:t===void 0?void 0:B.context.itemLabels.current[n]??void 0}))});K(()=>{Me()},[ae,Me]);let Fe=X.useMemo(()=>{if(!v)return De.reference;if(!De.trigger)return z;let{onFocus:e,...t}=De.trigger;return t},[v,De.reference,De.trigger]);B.useSyncedValue(`inputProps`,v?De.reference??z:z);let Ie=X.useMemo(()=>{let e=ee(ke.reference,Fe,Te.reference,{onMouseMove(){B.set(`allowMouseEnter`,!0)}},ge);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=U,e},[B,ke.reference,Fe,Te.reference,ge,U]),Le=X.useMemo(()=>{let e=ee(De.trigger,Te.trigger,ge);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[De.trigger,Te.trigger,ge]);L(()=>(B.update({inactiveTriggerProps:Le}),null));let Re=X.useMemo(()=>ee(Xt,{onMouseMove(){B.set(`allowMouseEnter`,!0),q.type===`menu`&&B.set(`hoverEnabled`,!1)},onClick(){B.select(`hoverEnabled`)&&B.set(`hoverEnabled`,!1)},onKeyDown(e){let t=B.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},ke.floating,De.floating,Te.floating),[q.type,B,ke.floating,De.floating,Te.floating]),ze=De.item??z;gn(B,{floatingRootContext:xe,activeTriggerProps:Ie,inactiveTriggerProps:Le,popupProps:Re,itemProps:ze});let Ve=X.useMemo(()=>({store:B,parent:D,orientation:u,loopFocus:l,allowEscape:b,defaultFloatingId:k,setRenderedFloatingId:j,virtualFocus:v,parentVirtualFocus:E,syncHighlightedItem:Me}),[B,D,u,l,b,k,v,E,Me]),He=typeof t==`function`?t({payload:se}):t,Ue=(0,Q.jsxs)(Rr.Provider,{value:Ve,children:[p&&(0,Q.jsx)(Ut,{handle:p,store:B}),He]});return(q.type===void 0||q.type===`context-menu`)&&(Ue=(0,Q.jsx)(ot,{externalTree:V,children:Ue})),Ue});function wi(e){let t=X.useContext(bi);if(t===null)return(0,Q.jsx)(Ci,{...e});let n=t.Root;return(0,Q.jsx)(bi.Provider,{value:null,children:(0,Q.jsx)(n,{...t.options,...e})})}function Ti(e){let{render:t,className:n,style:r,state:i=z,props:a=R,refs:o=R,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=Me({metadata:s});return te(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function Ei(e){if(oe(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!V(e))return Ei(H(e))}function Di(e,t){function n(n,r,i){let a=n.currentTarget;br.flushSync(()=>{e.setOpen(!1,J(Qe,n.nativeEvent,a))}),an(a.isConnected?a:t.current,r,i)?.focus()}function r(t){n(t,-1,e.select(`positionerElement`))}function i(t){let r=e.select(`positionerElement`);r&&wt(t,r)?e.context.beforeContentFocusGuardRef.current?.focus():n(t,1,r)}return{handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function Oi(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=X.useRef(!1);return X.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,ct(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:z,[t,n,r])}var ki=lt(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=zr(!0),h=dr(d)??m?.store;if(!h)throw Error(re(85));let g=st(s),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerControlsId`,g),x=X.useRef(null),S=ji(),C=U(!0),w=Ze(),T=X.useMemo(()=>w??new zt,[w]),E=Pe(T),D=Ne(),{registerTrigger:O,isMountedByThisTrigger:k}=bt(g,x,h,{payload:f,closeDelay:u,parent:S,floatingTreeRoot:T,floatingNodeId:E,floatingParentNodeId:D,keyboardEventRelay:C?.relayKeyboardEvent}),A=S.type===`menubar`,j=h.useState(`disabled`),M=a||j||A&&S.context.disabled,{getButtonProps:N,buttonRef:P}=ne({disabled:M,native:o});X.useEffect(()=>{!y&&S.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,y,S.type]);let F=X.useRef(null),I=Be(),L=G(e=>{if(!F.current)return;I.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;Y(F.current,t)||Y(h.select(`positionerElement`),t)||t===F.current||t!=null&&Ei(t)===h.select(`rootId`)||nn(e,F.current)||T.events.emit(`close`,{domEvent:e,reason:Fe})});X.useEffect(()=>{let e=ct(F.current);if(y&&h.select(`lastOpenChangeReason`)===`trigger-hover`)return e.addEventListener(`mouseup`,L,{once:!0}),()=>{e.removeEventListener(`mouseup`,L)}},[y,L,h]);let R=A&&S.context.hasSubmenuOpen,B=Sr(v,{enabled:(c??R)&&!M&&(!A||R&&!k),handleClose:kr({blockPointerEvents:!A}),mouseOnly:!0,move:!1,restMs:S.type===void 0?l:void 0,delay:{close:u},triggerElementRef:x,externalTree:T,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),V=Ai(y,h.select(`lastOpenChangeReason`)),H=it(v,{enabled:!M,event:y&&A?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:S.type===void 0&&V}),W=pr(v,{enabled:!M&&R}),ie=Oi({open:y,enabled:A,mouseDownAction:`open`}),K=X.useMemo(()=>ee(W.reference,H.reference),[W.reference,H.reference]),q=h.useState(`triggerProps`,k),ae=h.useState(`filterTriggerProps`),{handlePreFocusGuardFocus:oe,handleFocusTargetFocus:se}=Di(h,x),ce={disabled:M,open:y},le=[F,t,P,O,x],ue=[K,B??z,q,{"aria-haspopup":`menu`,"aria-controls":b,id:g,onMouseDown:e=>{h.select(`open`)||(I.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),ct(e.currentTarget).addEventListener(`mouseup`,L,{once:!0}))}},ae,A?{role:`menuitem`}:{},ie,p,N],de=te(`button`,e,{enabled:!A,stateAttributesMapping:jt,state:ce,ref:le,props:ue});return A?(0,Q.jsx)(Ti,{tag:`button`,render:n,className:r,style:i,state:ce,refs:le,props:ue,stateAttributesMapping:jt}):y?(0,Q.jsxs)(X.Fragment,{children:[(0,Q.jsx)($e,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:oe},`${g}-pre-focus-guard`),(0,Q.jsx)(X.Fragment,{children:de},g),(0,Q.jsx)($e,{ref:h.context.triggerFocusTargetRef,onFocus:se},`${g}-post-focus-guard`)]}):(0,Q.jsx)(X.Fragment,{children:de},g)});function Ai(e,t){let n=Be(),[r,i]=X.useState(!1);return K(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function ji(){let e=mi(!0);return X.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var Mi=X.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return te(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})}),Ni=wi;function Pi(e){return(0,Q.jsx)(ki,{"data-slot":`dropdown-menu-trigger`,...e})}function Fi({className:e,align:t=`end`,sideOffset:n=4,...r}){return(0,Q.jsx)(ui,{children:(0,Q.jsx)(fi,{align:t,sideOffset:n,className:`isolate z-50`,children:(0,Q.jsx)(si,{"data-slot":`dropdown-menu-content`,className:y(`min-w-44 origin-(--transform-origin) overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r})})})}function Ii({className:e,...t}){return(0,Q.jsx)(Qr,{"data-slot":`dropdown-menu-item`,className:y(`relative flex w-full cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none data-highlighted:bg-accent data-highlighted: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`,e),...t})}function Li({className:e,...t}){return(0,Q.jsx)(Mi,{"data-slot":`dropdown-menu-separator`,className:y(`-mx-1 my-1 h-px bg-border`,e),...t})}var $=(e,t)=>{let n=e[t];if(typeof n!=`string`)return;let r=e.Alias;return typeof r==`string`?n.replace(RegExp(`\\b${r.replace(/\W/g,`\\$&`)}\\.`,`g`),``):n},Ri=(e,t)=>{let n=e[t];return Array.isArray(n)?n.map(String).join(`, `):void 0},zi=e=>`${Math.round(e).toLocaleString()} ${e===1?`row`:`rows`}`,Bi=e=>{let t=$(e,`Relation Name`);if(!t)return;let n=$(e,`Schema`);return n?`${n}.${t}`:t},Vi=e=>{let t=$(e,`Relation Name`);if(!t)return`a table`;let n=$(e,`Schema`);return`the ${n&&n!==`public`?`${n}.`:``}${t} table`},Hi=(e,t)=>t?` ${e} ${t.replace(/^\((.*)\)$/,`$1`)}.`:``,Ui={Inner:`only the pairs that match`,Left:`every row from the first side, with matches from the second where there are any`,Right:`every row from the second side, with matches from the first where there are any`,Full:`every row from both sides, matched where possible`,Semi:`the rows of the first side that have a match`,Anti:`the rows of the first side that have no match`};function Wi(e){let{title:t,...n}=Gi(e),r=Bi(e);return{title:t,phrase:r&&/Scan$/.test(e[`Node Type`])&&e[`Node Type`]!==`Bitmap Index Scan`?`${t.toLowerCase()} ${e[`Node Type`]===`Seq Scan`?`of`:`in`} ${r}`:t.toLowerCase(),...n}}function Gi(e){let t=e[`Node Type`],n=`Postgres expects about ${zi(e[`Plan Rows`])}.`,r=Hi(`Keeps only rows where`,$(e,`Filter`)),i=$(e,`Index Name`);switch(t){case`Seq Scan`:return{title:`Read every row`,detail:`Reads ${Vi(e)} from start to finish, one row after another.${r} ${n}`,hint:e[`Plan Rows`]>1e4?`Reading a big table in full is slow. An index on the filtered column can help.`:void 0};case`Index Scan`:case`Index Only Scan`:return{title:`Look rows up by index`,detail:`Jumps straight to the matching rows of ${Vi(e)} using the ${i} index${t===`Index Only Scan`?`, without touching the table itself`:``}.${Hi(`Matches rows where`,$(e,`Index Cond`))}${r} ${n}`};case`Bitmap Index Scan`:return{title:`Find matches in an index`,detail:`Collects the places of matching rows from the ${i} index.${Hi(`Matches rows where`,$(e,`Index Cond`))}`};case`Bitmap Heap Scan`:return{title:`Fetch the matching rows`,detail:`Reads ${Vi(e)} at the places the index found, in disk order.${Hi(`Re-checks that`,$(e,`Recheck Cond`))}${r} ${n}`};case`Nested Loop`:return{title:`Match rows one by one`,detail:`For each row of the first input, looks for matching rows in the second. Gives ${Ui[$(e,`Join Type`)??`Inner`]??`the matches`}.${Hi(`Join on`,$(e,`Join Filter`))} ${n}`,hint:`Fast when the first input is small. Slow when both inputs are large.`};case`Hash Join`:return{title:`Match rows with a lookup table`,detail:`Builds an in-memory lookup of one input, then checks each row of the other against it. Gives ${Ui[$(e,`Join Type`)??`Inner`]??`the matches`}.${Hi(`Join on`,$(e,`Hash Cond`))} ${n}`};case`Merge Join`:return{title:`Match two sorted lists`,detail:`Walks down both inputs in order and pairs up rows that match. Gives ${Ui[$(e,`Join Type`)??`Inner`]??`the matches`}.${Hi(`Join on`,$(e,`Merge Cond`))} ${n}`};case`Hash`:return{title:`Build a lookup table`,detail:`Holds the rows below in memory so the join can find them quickly.`};case`Sort`:return{title:`Sort the rows`,detail:`Puts the rows in order by ${Ri(e,`Sort Key`)??`the requested columns`}. ${n}`,hint:`Sorting a lot of rows takes memory and time. An index in the same order can avoid it.`};case`Incremental Sort`:return{title:`Finish sorting the rows`,detail:`The rows already come sorted by part of ${Ri(e,`Sort Key`)??`the order`}, so only the rest needs sorting.`};case`Aggregate`:case`HashAggregate`:case`GroupAggregate`:{let t=Ri(e,`Group Key`);return{title:t?`Group and summarise`:`Summarise all rows`,detail:t?`Groups the rows by ${t} and works out the totals, counts or averages for each group. ${n}`:`Combines all rows into a single result, such as a count or a total. ${n}`}}case`Limit`:return{title:`Stop early`,detail:`Takes only the first ${zi(e[`Plan Rows`])} and ignores the rest.`};case`Unique`:return{title:`Remove duplicates`,detail:`Drops rows that repeat the one before them.`};case`Materialize`:return{title:`Remember the rows`,detail:`Keeps the rows in memory so they can be read again without redoing the work.`};case`Gather`:case`Gather Merge`:return{title:`Combine parallel workers`,detail:`Several workers each handled part of the data. This step collects their results.`};case`Append`:case`Merge Append`:return{title:`Stack results together`,detail:`Joins the results of the steps below into one list, as UNION or partitions do.`};case`Result`:return{title:`Compute a value`,detail:`Works out a result without reading any table.`};case`Subquery Scan`:return{title:`Read a subquery`,detail:`Reads the output of a subquery as if it were a table.`};case`CTE Scan`:return{title:`Read a WITH query`,detail:`Reads the result of the WITH query ${$(e,`CTE Name`)??``}.`};case`Function Scan`:return{title:`Call a function`,detail:`Reads the rows the function ${$(e,`Function Name`)??``} returns.`};case`Values Scan`:return{title:`Read listed values`,detail:`Reads the values written out in the query.`};case`ModifyTable`:{let t=$(e,`Operation`)??`Change`;return{title:`${t} rows`,detail:`${t===`Insert`?`Adds rows to`:t===`Update`?`Changes rows in`:t===`Delete`?`Removes rows from`:`Changes`} ${Vi(e)}. Nothing was changed: explaining only plans the work.`}}default:return{title:String(t),detail:`A ${String(t)} step. ${n}`}}}function Ki(e){let t=(e.Plans??[]).map(Ki),n=t.reduce((e,t)=>e+t.node[`Total Cost`],0);return{node:e,...Wi(e),ownCost:Math.max(e[`Total Cost`]-n,0),children:t}}function qi(e){return e.children.reduce((e,t)=>{let n=qi(t);return n.ownCost>e.ownCost?n:e},e)}function Ji(e){let t=[],n=e=>{e.children.forEach(n),e.title!==`Build a lookup table`&&t.push(e.phrase)};return n(e),`Postgres will ${t.join(`, then `)}, and expects ${zi(e.node[`Plan Rows`])} back.`}var Yi=1e4,Xi=`"[^"]+"|[a-z_][a-z0-9_$]*`,Zi=`(?:::[a-z ]+?)?`,Qi=/\b(?:lower|upper|coalesce|date|date_trunc|to_char|btrim|trim|substr|substring|left|right|abs|round)\(|::date\b/i,$i=e=>/^[a-z_][a-z0-9_$]*$/.test(e)?e:`"${e.replaceAll(`"`,`""`)}"`,ea=e=>{let t=$(e,`Relation Name`);if(!t)return;let n=$(e,`Schema`);return{name:t,sql:n?`${$i(n)}.${$i(t)}`:$i(t)}},ta=(e,t,n,r=``)=>{let i=ea(e);if(i)return`CREATE INDEX ${`${i.name}_${t.join(`_`)}_idx`.replace(/\W+/g,`_`).slice(0,63)} ON ${i.sql}${r} (${n});`};function na(e){let t=[],n=RegExp(`[\\s(](${Xi})\\)?${Zi}\\s*(=|<>|<=|>=|<|>)\\s`,`gi`);for(let r of e.matchAll(n))t.some(e=>e.column===r[1])||t.push({column:r[1],equal:r[2]===`=`});return[...t.filter(e=>e.equal),...t.filter(e=>!e.equal)].map(e=>e.column).slice(0,3)}var ra=e=>[e,...e.children.flatMap(ra)],ia=e=>/Scan$/.test(e.node[`Node Type`]);function aa(e){let t=e.children.findLast(e=>e.node[`Node Type`]===`Seq Scan`),n=t?.node.Alias,r=$(e.node,`Join Filter`);if(!t||typeof n!=`string`||!r)return;let i=RegExp(`\\b${n.replace(/\W/g,`\\$&`)}\\.(${Xi})`,`i`).exec(r);return i?ta(t.node,[i[1]],i[1]):void 0}function oa(e){let t=ra(e).filter(e=>ia(e)&&e.node[`Relation Name`]),n=e.node[`Sort Key`];if(t.length!==1||!Array.isArray(n))return;let r=t[0].node.Alias,i=n.map(e=>String(e).replace(RegExp(`^${String(r).replace(/\W/g,`\\$&`)}\\.`),``)),a=RegExp(`^(${Xi})( (?:ASC|DESC))?( NULLS (?:FIRST|LAST))?$`,`i`);if(i.every(e=>a.test(e)))return ta(t[0].node,i.map(e=>e.split(` `)[0].replaceAll(`"`,``)),i.join(`, `))}function sa(e){let t=[],n=ra(e),r=e.node[`Total Cost`];for(let e of n){let{node:n}=e,i=n[`Node Type`],a=Bi(n),o=$(n,`Filter`),s=n[`Total Cost`]>1e3&&(n[`Plan Rows`]>Yi||e.ownCost>r*.3),c=o&&RegExp(`[\\s(](${Xi})\\)?${Zi}\\s*~~\\*?\\s*'%`,`i`).exec(o),l=o&&!Qi.test(o)?na(o):[];if(i===`Seq Scan`&&o&&e.ownCost>1e3&&(l.length>0||!Qi.test(o)&&!c)&&t.push({step:e,title:`Add an index on ${a}`,detail:`${a} is read in full to keep only the rows where ${o.replace(/^\((.*)\)$/,`$1`)}. An index on the column that condition tests would let Postgres go straight to those rows.`,sql:l.length>0?ta(n,l,l.join(`, `)):void 0}),i===`Seq Scan`&&!o&&n[`Plan Rows`]>Yi&&t.push({step:e,title:`Read less of ${a}`,detail:`All of ${a} (about ${zi(n[`Plan Rows`])}) is read. If you do not need every row, add a WHERE or a LIMIT.`}),i===`Nested Loop`&&e.children.some(e=>e.node[`Node Type`]===`Seq Scan`)&&e.children.every(e=>e.node[`Plan Rows`]>100)&&t.push({step:e,title:`Index the join column`,detail:`Rows are matched one by one while one side is read in full for each row of the other. An index on the join column of the inner table would avoid that.`,sql:aa(e)}),i===`Sort`&&s&&t.push({step:e,title:`Avoid the sort`,detail:`Sorting ${zi(n[`Plan Rows`])} by ${Ri(n,`Sort Key`)??`the order`} is a large share of the work. An index in that order, or a LIMIT, would avoid sorting them all.`,sql:oa(e)}),o&&Qi.test(o)&&ia(e)&&e.ownCost>1e3){let r=RegExp(`\\b(lower|upper)\\(\\(?(${Xi})\\)?${Zi}\\)`,`i`).exec(o);t.push({step:e,title:`Match the index to the expression`,detail:`The condition ${o.replace(/^\((.*)\)$/,`$1`)} wraps the column in a function or cast, which stops a plain index being used. Index the same expression, or compare the bare column.`,sql:r?ta(n,[r[1].toLowerCase(),r[2]],`${r[1].toLowerCase()}(${r[2]})`):void 0})}if(c&&ia(e)&&e.ownCost>1e3){let r=ta(n,[c[1],`trgm`],`${c[1]} gin_trgm_ops`,` USING gin`);t.push({step:e,title:`Avoid a leading wildcard`,detail:`A LIKE pattern that starts with % cannot use a normal index. A trigram index (pg_trgm) can, or the pattern can be anchored at the start.`,sql:r&&`CREATE EXTENSION IF NOT EXISTS pg_trgm;\n${r}`})}}return e.node[`Node Type`]!==`Limit`&&e.node[`Plan Rows`]>Yi&&!/^(Insert|Update|Delete)/.test($(e.node,`Operation`)??``)&&t.push({step:e,title:`Return fewer rows`,detail:`The query returns about ${zi(e.node[`Plan Rows`])}. If you only need some of them, add a WHERE or a LIMIT.`}),e.node[`Plan Width`]>200&&t.push({step:e,title:`Select only the columns you need`,detail:`Each row is about ${e.node[`Plan Width`]} bytes wide. Naming the columns you need instead of using * moves less data.`}),t}var ca=(e,t)=>{let n=e[t];return typeof n==`number`?n:void 0},la=e=>ca(e,`Actual Loops`)!==void 0,ua=e=>(ca(e,`Actual Total Time`)??0)*(ca(e,`Actual Loops`)??0);function da(e){let{node:t}=e,n=ca(t,`Actual Loops`);if(n===void 0)return;let r=ua(t),i=e.children.reduce((e,t)=>e+ua(t.node),0),a=t[`Plan Rows`]*Math.max(n,1),o=(ca(t,`Actual Rows`)??0)*n,s=Math.max(a,o,1)/Math.max(Math.min(a,o),1);return{totalMs:r,ownMs:Math.max(r-i,0),estimatedRows:a,actualRows:o,loops:n,misestimate:s,direction:o>=a?`more`:`fewer`,hitBlocks:ca(t,`Shared Hit Blocks`),readBlocks:ca(t,`Shared Read Blocks`)}}var fa=10,pa=100,ma=100;function ha(e,t){let{node:n}=e,r=[],i=n[`Node Type`],a=da(e),o=Bi(n);if(i===`Seq Scan`&&o){let e=(ca(n,`Rows Removed by Filter`)??0)*(a?.loops??1),i=t?.($(n,`Schema`),$(n,`Relation Name`)??``)??(a?a.actualRows+e:n[`Plan Rows`]);i>=Yi&&r.push({level:i>=Yi*100?`bad`:`warn`,label:`big seq scan`,detail:`Reads all of ${o} (about ${zi(i)}${a&&a.loops>1&&n[`Parallel Aware`]!==!0?`, ${a.loops} times`:``}). An index on the columns it filters or joins on would let Postgres read only the rows it needs.`})}if(a&&a.loops===0)r.push({level:`warn`,label:`never ran`,detail:`This step was never executed: the steps above it did not need its rows.`});else if(a&&a.misestimate>=fa&&Math.max(a.estimatedRows,a.actualRows)>=ma){let e=Math.round(a.misestimate).toLocaleString();r.push({level:a.misestimate>=pa?`bad`:`warn`,label:`${e}× ${a.direction}`,detail:`Postgres expected ${zi(a.estimatedRows)} but got ${zi(a.actualRows)}, ${e} times ${a.direction}. A plan built on a wrong guess picks the wrong joins and scans.${o?` If ${o} changed a lot lately, ANALYZE ${o} refreshes its statistics; if columns are correlated, CREATE STATISTICS can help.`:``}`})}if(a){let e=(ca(n,`Rows Removed by Filter`)??0)*a.loops;e>=Yi&&e>a.actualRows*10&&r.push({level:`warn`,label:`filtered out`,detail:`Read ${zi(e+a.actualRows)} to keep ${zi(a.actualRows)}: ${zi(e)} were thrown away by the filter. An index on the filtered column would skip them.`})}$(n,`Sort Space Type`)===`Disk`&&r.push({level:`bad`,label:`sort on disk`,detail:`The sort did not fit in work_mem and used ${ca(n,`Sort Space Used`)??`?`} kB on disk. Raising work_mem for this query, or sorting fewer rows, keeps it in memory.`});let s=ca(n,`Hash Batches`);return s!==void 0&&s>1&&r.push({level:`warn`,label:`hash on disk`,detail:`The lookup table did not fit in work_mem and was split into ${s} batches on disk. Raising work_mem keeps it in memory.`}),r}function ga(e){let t=$(e,`Join Type`),n=t&&t!==`Inner`?`${e[`Node Type`]} (${t})`:e[`Node Type`],r=Bi(e),i=$(e,`Alias`),a=$(e,`Index Name`),o=a?` using ${a}`:``;return r?{type:n,target:`${r}${i&&i!==$(e,`Relation Name`)?` ${i}`:``}${o}`}:a?{type:n,target:o.trim()}:{type:n,target:$(e,`CTE Name`)??$(e,`Function Name`)??$(e,`Subplan Name`)}}function _a(e){return[`Index Cond`,`Recheck Cond`,`Filter`,`Join Filter`,`Hash Cond`,`Merge Cond`,`Sort Key`,`Group Key`,`Output`].flatMap(t=>{let n=Array.isArray(e[t])?Ri(e,t):$(e,t);return n?[[t,n]]:[]})}var va=`psqlx1:`,ya=e=>{let t=``;for(let n of new TextEncoder().encode(e))t+=String.fromCharCode(n);return btoa(t).replaceAll(`+`,`-`).replaceAll(`/`,`_`).replaceAll(`=`,``)},ba=e=>{let t=atob(e.replaceAll(`-`,`+`).replaceAll(`_`,`/`));return new TextDecoder().decode(Uint8Array.from(t,e=>e.charCodeAt(0)))};function xa({sql:e,name:t}){return va+ya(JSON.stringify(t?{q:e,n:t}:{q:e}))}function Sa(e){let t=e.trim();if(t.startsWith(va))try{let{q:e,n}=JSON.parse(ba(t.slice(7)));return typeof e!=`string`||!e.trim()?void 0:{sql:e,...typeof n==`string`&&n.trim()?{name:n.trim().slice(0,40)}:{}}}catch{return}}var Ca=20,wa=200,Ta=(e,t)=>`psql-explorer:sql:${e}${t===`1`?``:`:${t}`}`;function Ea(e,t){try{window.localStorage.removeItem(Ta(e,t))}catch{}}function Da(e,t){try{return window.localStorage.getItem(Ta(e,t))??``}catch{return``}}function Oa(e,t,n){try{window.localStorage.setItem(Ta(e,t),n)}catch{}}function ka({zone:e,onChange:t}){let n=(0,X.useMemo)(()=>i(),[]),a=r();return(0,Q.jsxs)(`label`,{className:`text-muted-foreground flex items-center gap-1 text-xs`,title:`Days, months, ... of a timestamp with time zone are cut in this zone. A timestamp without time zone is used as it is.`,children:[(0,Q.jsx)(Mn,{className:`size-3.5`}),` Time zone`,(0,Q.jsxs)(`select`,{className:`border-input bg-card text-foreground max-w-44 border px-1 py-1`,value:e,onChange:e=>t(e.target.value),children:[(0,Q.jsx)(`option`,{value:``,children:`Database session`}),a&&(0,Q.jsxs)(`option`,{value:a,children:[`Browser (`,a,`)`]}),n.map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))]})]})}function Aa({table:e,highlight:t}){let n=e.columns.slice(0,Ca);for(let e of t??[])n.includes(e)||n.push(e);return(0,Q.jsxs)(`div`,{className:`w-80`,children:[(0,Q.jsxs)(`div`,{className:`bg-sidebar flex items-center gap-2 px-3 py-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-accent-text font-bold`,children:e.name}),(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e.schema}),e.kind!==`table`&&(0,Q.jsx)(Ge,{variant:`outline`,children:e.kind})]}),e.comment&&(0,Q.jsx)(`p`,{className:`text-muted-foreground border-border border-b px-3 py-1 text-xs`,children:e.comment}),(0,Q.jsxs)(`ul`,{className:`py-1 text-xs`,children:[n.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-0.5 ${t?.includes(e)?`bg-accent text-accent-foreground`:``}`,children:[(0,Q.jsx)(`span`,{className:`w-3.5 shrink-0`,children:e.primaryKey?(0,Q.jsx)(ge,{className:`size-3.5`}):e.references?(0,Q.jsx)(Kt,{className:`size-3.5`}):null}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.name}),e.default!==null&&(0,Q.jsxs)(`span`,{className:`text-muted-foreground/80 truncate font-mono`,title:`Default: ${e.default}`,children:[`= `,e.default]}),(0,Q.jsx)(`span`,{className:`text-muted-foreground ml-auto shrink-0 pl-2`,children:e.references?`→ ${e.references.table}`:`${e.type}${e.nullable?``:` !`}`})]},e.name)),e.columns.length>n.length&&(0,Q.jsxs)(`li`,{className:`text-muted-foreground px-3 py-0.5`,children:[`+`,e.columns.length-n.length,` more`]})]}),(0,Q.jsx)(`p`,{className:`text-muted-foreground border-border border-t px-3 py-1 text-xs`,children:`! not null · key = primary key · link = foreign key · = default`})]})}function ja({table:e,column:t}){let n=[[`Type`,t.type],[`Nullable`,t.nullable?`yes`:`no (NOT NULL)`]];t.default!==null&&n.push([`Default`,t.default]);let r=[t.primaryKey&&`primary key`,t.unique&&`unique`].filter(Boolean);if(r.length>0&&n.push([`Key`,r.join(`, `)]),t.references){let{schema:e,table:r,column:i}=t.references;n.push([`References`,`${e}.${r}(${i})`])}return(0,Q.jsxs)(`div`,{className:`w-80 px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex items-baseline gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-accent-text font-bold`,children:t.name}),(0,Q.jsxs)(`span`,{className:`text-muted-foreground text-xs`,children:[e.schema,`.`,e.name]})]}),(0,Q.jsx)(`dl`,{className:`grid grid-cols-[max-content_1fr] gap-x-3 gap-y-0.5 text-xs`,children:n.map(([e,t])=>(0,Q.jsxs)(`div`,{className:`contents`,children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,Q.jsx)(`dd`,{className:`break-all`,children:t})]},e))}),t.comment&&(0,Q.jsx)(`p`,{className:`text-muted-foreground mt-2 text-xs`,children:t.comment})]})}function Ma({help:e}){return(0,Q.jsxs)(`div`,{className:`space-y-0.5`,children:[e.functions.slice(0,4).map(t=>{let n=O(t.signature);return(0,Q.jsxs)(`div`,{className:`whitespace-nowrap`,children:[(0,Q.jsxs)(`span`,{className:`text-muted-foreground/70`,children:[t.name,`(`]}),n.map((t,n)=>(0,Q.jsxs)(`span`,{children:[n>0&&(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`, `}),(0,Q.jsx)(`span`,{className:n===e.index?`text-foreground font-bold`:`text-muted-foreground/70`,children:t})]},n)),(0,Q.jsxs)(`span`,{className:`text-muted-foreground/70`,children:[`)`,t.returns?` → ${t.returns}`:``]})]},`${t.schema}.${t.args}`)}),e.functions.length>4&&(0,Q.jsxs)(`div`,{className:`text-muted-foreground/70`,children:[`+`,e.functions.length-4,` more variants`]})]})}function Na({functions:e}){return(0,Q.jsx)(`div`,{className:`w-96 max-w-full px-3 py-2`,children:e.map(e=>(0,Q.jsxs)(`div`,{className:`mb-2 last:mb-0`,children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex items-baseline gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-accent-text font-bold`,children:e.name}),(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e.schema}),e.kind!==`function`&&(0,Q.jsx)(Ge,{variant:`outline`,children:e.kind})]}),(0,Q.jsxs)(`dl`,{className:`grid grid-cols-[max-content_1fr] gap-x-3 gap-y-0.5 text-xs`,children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Parameters`}),(0,Q.jsx)(`dd`,{className:`break-words`,children:e.signature||`none`}),e.returns&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Returns`}),(0,Q.jsx)(`dd`,{className:`break-words`,children:e.returns})]}),(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Language`}),(0,Q.jsx)(`dd`,{children:e.language})]}),e.comment&&(0,Q.jsx)(`p`,{className:`text-muted-foreground mt-1 text-xs`,children:e.comment})]},`${e.schema}.${e.name}(${e.args})`))})}function Pa({hover:e}){let t=(0,X.useRef)(null),[n,r]=(0,X.useState)({left:e.x,top:e.y+16});(0,X.useEffect)(()=>{let n=t.current?.getBoundingClientRect();if(!n)return;let i=Math.max(8,Math.min(e.x,window.innerWidth-n.width-8)),a=e.y+16,o=a+n.height>window.innerHeight-8?Math.max(8,e.y-n.height-8):a;r({left:i,top:o})},[e]);let{annotation:i}=e;return(0,Q.jsx)(`div`,{ref:t,role:`tooltip`,style:n,className:`bg-popover text-popover-foreground border-border pointer-events-none fixed z-50 max-h-[70vh] overflow-hidden border shadow-lg`,children:`functions`in i?(0,Q.jsx)(Na,{functions:i.functions}):i.columns?.length===1?(0,Q.jsx)(ja,{table:i.table,column:i.columns[0]}):(0,Q.jsx)(Aa,{table:i.table,highlight:i.columns})})}function Fa(e,t){if(!e)return;let n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),r=t;for(let e=n.nextNode();e;e=n.nextNode()){let t=e.textContent?.length??0;if(r<=t){let t=document.createRange();t.setStart(e,r),t.setEnd(e,r);let n=t.getClientRects()[0]??t.getBoundingClientRect();return n.height>0?n:void 0}r-=t}}var Ia=`font-mono text-sm leading-6`,La=`p-3`;function Ra({value:e,onChange:t,onRun:n,onFormat:r,onCursor:i,catalog:a,functions:s,zone:c}){let l=(0,X.useRef)(null),[d,f]=(0,X.useState)(),p=(0,X.useRef)(null),[h,v]=(0,X.useState)(0),[y,x]=(0,X.useState)(),[S,C]=(0,X.useState)(!1),[w,T]=(0,X.useState)(!1),[E,O]=(0,X.useState)(0),A=(0,X.useRef)(void 0),j=(0,X.useRef)(void 0),M=(0,X.useMemo)(()=>[...b(e,a),...D(e,s)].sort((e,t)=>e.start-t.start),[e,a,s]),N=(0,X.useMemo)(()=>{let t=[],n=0,r=k(e);for(let e of r){let r=M.find(t=>t.start===e.start),i=r?M.indexOf(r):-1,a=He(e);i>=0&&(a+=` text-accent-text underline decoration-dotted underline-offset-4`),t.push((0,Q.jsx)(`span`,{"data-known":i>=0?i:void 0,className:a,children:e.text},n++))}return t.push(`
|
|
2
|
+
`),t},[e,M]),P=(0,X.useMemo)(()=>S?m(e,h,a,w,c,s):void 0,[S,e,h,a,w,c,s]),F=n=>{if(!P)return;let r=e.slice(0,P.from)+n.insert+e.slice(P.to),i=P.from+n.insert.length;t(r),C(!1),T(!1),v(i),requestAnimationFrame(()=>p.current?.setSelectionRange(i,i))},[I,L]=(0,X.useState)(),[R,z]=(0,X.useState)(1);(0,X.useLayoutEffect)(()=>{let e=p.current;if(!e)return;let t=()=>e.clientWidth>0&&L(e.clientWidth);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),(0,X.useLayoutEffect)(()=>{l.current&&z(Math.round((l.current.offsetHeight-24)/24))},[e,I]),(0,X.useLayoutEffect)(()=>{p.current&&p.current.clientWidth>0&&L(p.current.clientWidth)},[R]);let[B,ee]=(0,X.useState)();(0,X.useLayoutEffect)(()=>{let e=p.current;if(!P||!e)return ee(void 0);let t=Fa(l.current,P.from),n=e.getBoundingClientRect(),r=t?t.left:n.left+12,i=t?t.bottom:n.top+12+24;ee({left:Math.max(8,Math.min(r,window.innerWidth-360)),top:i})},[P,e,I]);let V=(0,X.useMemo)(()=>y===void 0?void 0:u(e,y,s),[y,e,s]),[H,U]=(0,X.useState)();(0,X.useLayoutEffect)(()=>{let e=V&&y!==void 0?Fa(l.current,y):void 0;U(e?{left:Math.max(8,Math.min(e.left,window.innerWidth-400)),top:e.top-6}:void 0)},[V,y,e,I]);let W=`calc(${Math.min(Math.max(R,8),24)} * 1.5rem + 1.5rem)`,G=()=>{window.clearTimeout(A.current),j.current=void 0,f(void 0)};return(0,X.useEffect)(()=>()=>window.clearTimeout(A.current),[]),(0,Q.jsxs)(`div`,{className:`border-input bg-card focus-within:border-ring relative overflow-hidden border`,style:{height:W},children:[(0,Q.jsx)(`pre`,{ref:l,"aria-hidden":!0,className:`${Ia} ${La} pointer-events-none absolute top-0 left-0 m-0 whitespace-pre-wrap`,style:{width:I??`100%`,overflowWrap:`break-word`},children:N}),(0,Q.jsx)(`textarea`,{"aria-label":`SQL`,spellCheck:!1,value:e,placeholder:`SELECT * FROM ...`,ref:p,onChange:n=>{G();let r=n.target.value,o=n.target.selectionStart,s=r.length===e.length+1&&o===n.target.selectionEnd?_(r,o,a):void 0;s&&(r=s.sql,o=s.caret,requestAnimationFrame(()=>p.current?.setSelectionRange(o,o))),t(r),i(n.target.selectionStart,n.target.selectionEnd),O(0),v(o),T(!1),C(n.target.selectionStart===n.target.selectionEnd)},onSelect:e=>{i(e.currentTarget.selectionStart,e.currentTarget.selectionEnd);let{selectionStart:t,selectionEnd:n}=e.currentTarget;x(t===n?t:void 0)},onBlur:()=>(C(!1),T(!1),x(void 0)),onMouseDown:()=>(C(!1),T(!1)),onKeyUp:e=>{e.key.startsWith(`Arrow`)&&!P&&v(e.currentTarget.selectionStart)},onScroll:e=>{G(),l.current&&(l.current.style.transform=`translate(${-e.currentTarget.scrollLeft}px, ${-e.currentTarget.scrollTop}px)`)},onKeyDown:a=>{if(P&&!a.metaKey&&!a.ctrlKey){let e=P.items.length;if(a.key===`ArrowDown`||a.key===`ArrowUp`){a.preventDefault(),O((E+(a.key===`ArrowDown`?1:e-1))%e);return}if(a.key===`Enter`||a.key===`Tab`){a.preventDefault(),F(P.items[E]);return}if(a.key===`Escape`){a.preventDefault(),C(!1);return}}if(a.key===`Tab`&&!a.metaKey&&!a.ctrlKey&&!a.altKey){a.preventDefault();let{selectionStart:n,selectionEnd:r}=a.currentTarget,o=g(e,n,r,a.shiftKey);t(o.sql),i(o.from,o.to),requestAnimationFrame(()=>p.current?.setSelectionRange(o.from,o.to))}else if(a.key===` `&&a.ctrlKey)a.preventDefault(),v(a.currentTarget.selectionStart),T(!0),C(!0);else{if(a.key===`Enter`&&(a.metaKey||a.ctrlKey)){a.preventDefault();let{selectionStart:t,selectionEnd:r}=a.currentTarget;n(o(e,t,r))}(a.key===`f`||a.key===`F`)&&a.shiftKey&&(a.metaKey||a.ctrlKey)&&(a.preventDefault(),r(a.currentTarget.selectionStart,a.currentTarget.selectionEnd))}},onMouseMove:e=>{let{clientX:t,clientY:n}=e,r;for(let e of l.current?.querySelectorAll(`[data-known]`)??[])if([...e.getClientRects()].some(e=>t>=e.left&&t<=e.right&&n>=e.top&&n<=e.bottom)){r=M[Number(e.dataset.known)];break}r!==j.current&&(G(),r&&(j.current=r,A.current=window.setTimeout(()=>f({x:t,y:n,annotation:r}),wa)))},onMouseLeave:G,className:`${Ia} ${La} absolute inset-0 size-full resize-none overflow-x-hidden overflow-y-auto bg-transparent whitespace-pre-wrap text-transparent caret-current outline-none selection:bg-primary/30 placeholder:text-muted-foreground`,style:{color:`transparent`,caretColor:`var(--foreground)`,overflowWrap:`break-word`}}),P&&B&&(0,Q.jsx)(`ul`,{role:`listbox`,style:B,className:`bg-popover text-popover-foreground border-border fixed z-40 max-h-60 min-w-56 overflow-auto border text-xs shadow-lg`,children:P.items.map((e,t)=>{let n=e.related?Kt:e.fits?se:{column:rn,table:bn,schema:An,keyword:Jn,condition:Kt,function:Sn,type:ht}[e.kind];return(0,Q.jsxs)(`li`,{role:`option`,"aria-selected":t===E,ref:e=>{t===E&&e?.scrollIntoView({block:`nearest`})},onMouseDown:t=>{t.preventDefault(),F(e)},className:`flex cursor-pointer items-center gap-2 px-2 py-1 ${t===E?`bg-accent text-accent-foreground`:``}`,children:[(0,Q.jsx)(n,{className:`size-3.5 shrink-0 ${e.related||e.fits?`text-primary`:`text-muted-foreground`}`}),(0,Q.jsx)(`span`,{className:e.kind===`keyword`?`text-primary`:``,children:e.label}),(0,Q.jsx)(`span`,{className:`text-muted-foreground ml-auto pl-4 whitespace-nowrap`,children:e.detail})]},`${e.kind}:${e.label}:${e.detail??``}`)})}),V&&H&&!d&&(0,Q.jsx)(`div`,{role:`status`,style:{left:H.left,top:H.top,transform:`translateY(-100%)`},className:`bg-popover border-border pointer-events-none fixed z-30 max-w-[min(90vw,48rem)] overflow-hidden border px-2 py-1 font-mono text-xs shadow-md`,children:(0,Q.jsx)(Ma,{help:V})}),d&&(0,Q.jsx)(Pa,{hover:d})]})}var za=100,Ba=(e,t)=>`${t+1}. ${e.text.replace(/--[^\n]*|\/\*[\s\S]*?\*\//g,` `).trim().split(/\s+/).slice(0,2).join(` `)}`;function Va({text:e,name:t,type:n,onGroup:r,zone:i}){let a=l(n);return a?(0,Q.jsxs)(`select`,{"aria-label":`Group by part of ${t}`,title:`Group the result by a part of ${t}`,className:`text-muted-foreground border-input bg-card ml-2 max-w-24 border px-0.5 text-xs font-normal`,value:``,onChange:o=>{let l=c(a).find(e=>e.id===o.target.value);if(!l)return;let u=s({statement:e,column:t,type:n,bucket:l,zone:i});u&&r(u)},children:[(0,Q.jsx)(`option`,{value:``,children:`Group…`}),c(a).map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.label},e.id))]}):null}function Ha({environment:e,text:t,result:n,catalog:r,picked:i}){let a=(0,X.useMemo)(()=>N(b(t,r).map(e=>e.table),n.columns,r),[t,n.columns,r]),[o,s]=(0,X.useState)(``),c=a.find(e=>`${e.schema}.${e.name}`===o)??a[0];if(!c)return null;let l=A(c,n.columns,n.rows.filter((e,t)=>i.has(t))),u=l.length>0?j(e,c,l):void 0;return(0,Q.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2 text-xs`,children:[(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[i.size,` selected as rows of`]}),(0,Q.jsx)(`select`,{"aria-label":`Graph table`,value:`${c.schema}.${c.name}`,onChange:e=>s(e.target.value),className:`border-input bg-background rounded-lg border px-2 py-1`,children:a.map(e=>(0,Q.jsx)(`option`,{children:`${e.schema}.${e.name}`},`${e.schema}.${e.name}`))}),u?(0,Q.jsxs)(`a`,{href:u,className:`border-input hover:text-accent-text flex items-center gap-1 rounded-lg border px-2 py-1`,children:[(0,Q.jsx)(P,{className:`size-3.5`}),` Graph `,l.length,` `,l.length===1?`row`:`rows`]}):(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[`their `,c.columns.filter(e=>e.primaryKey).map(e=>e.name).join(`, `),` is NULL`]})]})}function Ua({environment:t,text:n,result:r,page:i,running:a,onPage:o,onGroup:s,zone:c,catalog:l}){let u=i*za,[d,f]=(0,X.useState)(),p=d?.result===r?d.rows:new Set,m=e=>f({result:r,rows:e}),h=(0,X.useMemo)(()=>N([],r.columns,l).length>0,[r.columns,l]),g=r.columns.length===0?`${r.command}${r.rowCount===null?``:` ${r.rowCount}`}`:r.rows.length===0?i>0?`no more rows`:`0 rows`:`rows ${u+1}-${u+r.rows.length}${r.truncated?``:` (${u+r.rows.length} in all)`}`;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`text-muted-foreground mb-2 text-xs`,children:[g,` in `,et(r.durationMs),r.columns.length>0&&Ee(r.rows.length,r.durationMs)&&` (${Ee(r.rows.length,r.durationMs)})`]}),r.columns.length>0&&(0,Q.jsx)(ce,{data:r,fetchAll:()=>e.exportSql(t,n),filename:`query-result`}),r.columns.length>0&&(0,Q.jsx)(M,{data:r,fetchAll:()=>e.exportSql(t,n),filename:`query-result`},n),h&&p.size>0&&(0,Q.jsx)(Ha,{environment:t,text:n,result:r,catalog:l,picked:p}),r.columns.length>0&&(0,Q.jsxs)(Te,{children:[(0,Q.jsx)(be,{children:(0,Q.jsxs)(Ce,{children:[h&&(0,Q.jsx)(xe,{className:`w-8`,children:(0,Q.jsx)(`input`,{type:`checkbox`,"aria-label":`Select all rows`,title:`Select rows to draw them as a graph`,checked:p.size===r.rows.length&&r.rows.length>0,onChange:e=>m(e.target.checked?new Set(r.rows.keys()):new Set)})}),r.columns.map((e,t)=>(0,Q.jsxs)(xe,{title:e.type,children:[e.name,(0,Q.jsx)(Va,{text:n,name:e.name,type:e.type,onGroup:s,zone:c})]},t))]})}),(0,Q.jsx)(Se,{children:r.rows.map((e,t)=>(0,Q.jsxs)(Ce,{children:[h&&(0,Q.jsx)(we,{children:(0,Q.jsx)(`input`,{type:`checkbox`,"aria-label":`Select row ${u+t+1}`,checked:p.has(t),onChange:e=>{let n=new Set(p);e.target.checked?n.add(t):n.delete(t),m(n)}})}),e.map((e,t)=>(0,Q.jsx)(we,{children:e===null?(0,Q.jsx)(`span`,{className:`text-muted-foreground italic`,children:`NULL`}):(0,Q.jsx)(fe,{value:e,type:r.columns[t].type,zone:c})},t))]},t))})]}),r.columns.length>0&&(i>0||r.truncated)&&(0,Q.jsx)(`div`,{className:`text-muted-foreground mt-3 flex items-center gap-4 text-xs`,children:(0,Q.jsx)(ue,{page:i,hasMore:r.truncated,disabled:a,onPage:o})})]})}function Wa({step:e,total:t,worst:n,numbers:r}){let i=t>0?e.ownCost/t:0,a=Math.round(i*100),o=e===n&&i>=.3;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`rounded-md border p-3 ${o?`border-primary`:``}`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`bg-muted text-muted-foreground flex size-5 shrink-0 items-center justify-center rounded-full text-xs`,children:r.get(e)}),(0,Q.jsx)(`span`,{className:`font-medium`,children:e.title}),o&&(0,Q.jsx)(Ge,{children:`Most of the work`}),(0,Q.jsxs)(`span`,{className:`text-muted-foreground ml-auto text-xs whitespace-nowrap`,children:[a<1?`<1`:a,`% of the effort`]})]}),(0,Q.jsx)(`p`,{className:`text-muted-foreground mt-2 text-sm`,children:e.detail}),e.hint&&(0,Q.jsxs)(`p`,{className:`mt-1 text-sm`,children:[`💡 `,e.hint]}),(0,Q.jsx)(`div`,{className:`bg-muted mt-2 h-1.5 overflow-hidden rounded-full`,children:(0,Q.jsx)(`div`,{className:`bg-primary h-full`,style:{width:`${Math.max(i*100,1)}%`}})})]}),e.children.length>0&&(0,Q.jsxs)(`div`,{className:`mt-2 ml-4 space-y-2 border-l-2 pl-4`,children:[(0,Q.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Gets its rows from:`}),e.children.map((e,i)=>(0,Q.jsx)(Wa,{step:e,total:t,worst:n,numbers:r},i))]})]})}var Ga=e=>e<1?`${e.toFixed(2)} ms`:e<1e3?`${e.toFixed(1)} ms`:`${(e/1e3).toFixed(2)} s`,Ka=e=>Math.round(e).toLocaleString();function qa({share:e,className:t=`bg-primary`}){return(0,Q.jsx)(`div`,{className:`bg-muted h-1.5 w-full overflow-hidden rounded-full`,children:(0,Q.jsx)(`div`,{className:`h-full ${t}`,style:{width:`${Math.min(Math.max(e*100,+(e>0)),100)}%`}})})}function Ja({root:e,numbers:t,suggestions:n,tableRows:r}){let i=la(e.node),a=e.node[`Total Cost`],o=da(e)?.totalMs??0,[s,c]=(0,X.useState)(()=>new Set),[l,u]=(0,X.useState)(()=>new Set),d=(e,t)=>{let n=new Set(e);return n.delete(t)||n.add(t),n},f=[],p=(e,t)=>{f.push({step:e,depth:t}),s.has(e)||e.children.forEach(e=>p(e,t+1))};p(e,0);let m=i?`minmax(18rem,1fr) 7rem 7rem 9rem 3.5rem`:`minmax(18rem,1fr) 7rem 8rem`;return(0,Q.jsxs)(`div`,{role:`tree`,"aria-label":`Plan`,className:`overflow-x-auto rounded-md border text-sm`,children:[(0,Q.jsxs)(`div`,{className:`text-muted-foreground bg-muted/40 grid gap-3 border-b px-3 py-1.5 text-xs`,style:{gridTemplateColumns:m},children:[(0,Q.jsx)(`span`,{children:`Step`}),(0,Q.jsx)(`span`,{title:`This step's own share of the planner's cost`,children:`Cost`}),i&&(0,Q.jsx)(`span`,{title:`Time in this step alone, over all its loops`,children:`Time`}),(0,Q.jsx)(`span`,{children:i?`Rows: expected → actual`:`Rows expected`}),i&&(0,Q.jsx)(`span`,{className:`text-right`,children:`Loops`})]}),f.map(({step:e,depth:f})=>{let p=da(e),h=ha(e,r),g=ga(e.node),_=n.filter(t=>t.step===e),v=l.has(e),y=h.some(e=>e.level===`bad`),b=h.find(e=>e.label.endsWith(`more`)||e.label.endsWith(`fewer`));return(0,Q.jsxs)(`div`,{role:`treeitem`,"aria-level":f+1,"aria-expanded":e.children.length>0?!s.has(e):void 0,className:`border-b last:border-b-0`,children:[(0,Q.jsxs)(`div`,{className:`hover:bg-muted/40 grid cursor-pointer items-center gap-3 px-3 py-1.5 ${y?`bg-destructive/5`:``}`,style:{gridTemplateColumns:m},onClick:()=>u(d(l,e)),children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,style:{paddingLeft:`${f*1.25}rem`},children:[e.children.length>0?(0,Q.jsx)(`button`,{type:`button`,"aria-label":s.has(e)?`Show the steps below`:`Hide the steps below`,className:`text-muted-foreground hover:text-foreground shrink-0`,onClick:t=>{t.stopPropagation(),c(d(s,e))},children:s.has(e)?(0,Q.jsx)(me,{className:`size-4`}):(0,Q.jsx)(le,{className:`size-4`})}):(0,Q.jsx)(`span`,{className:`w-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`bg-muted text-muted-foreground flex size-5 shrink-0 items-center justify-center rounded-full text-xs`,children:t.get(e)}),(0,Q.jsx)(`span`,{className:`font-medium whitespace-nowrap`,children:g.type}),g.target&&(0,Q.jsx)(`span`,{className:`text-muted-foreground min-w-0 truncate font-mono text-xs`,title:g.target,children:g.target}),h.map(e=>(0,Q.jsx)(Ge,{variant:e.level===`bad`?`destructive`:`outline`,title:e.detail,children:e.label},e.label)),_.length>0&&(0,Q.jsxs)(Ge,{variant:`secondary`,title:_.map(e=>e.title).join(`; `),children:[`💡 `,_.length]})]}),(0,Q.jsxs)(`div`,{title:`cost ${String(e.node[`Startup Cost`]??0)}..${e.node[`Total Cost`]}, ${Math.round(e.ownCost)} of it this step's own`,children:[(0,Q.jsx)(qa,{share:a>0?e.ownCost/a:0}),(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs tabular-nums`,children:Math.round(e.node[`Total Cost`]).toLocaleString()})]}),i&&(0,Q.jsxs)(`div`,{title:p?`${Ga(p.totalMs)} with the steps below it`:void 0,children:[(0,Q.jsx)(qa,{share:p&&o>0?p.ownMs/o:0,className:`bg-chart-2`}),(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs tabular-nums`,children:p?Ga(p.ownMs):`-`})]}),(0,Q.jsx)(`span`,{className:`tabular-nums`,children:p?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[Ka(p.estimatedRows),` → `]}),(0,Q.jsx)(`span`,{className:b?b.level===`bad`?`text-destructive font-semibold`:`font-semibold`:``,children:Ka(p.actualRows)})]}):`~${Ka(e.node[`Plan Rows`])}`}),i&&(0,Q.jsx)(`span`,{className:`text-muted-foreground text-right tabular-nums`,children:p?.loops.toLocaleString()??`-`})]}),v&&(0,Q.jsxs)(`div`,{className:`bg-muted/20 space-y-2 px-3 py-2`,style:{paddingLeft:`${f*1.25+3.25}rem`},children:[(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:e.detail}),_a(e.node).length>0&&(0,Q.jsx)(`dl`,{className:`grid grid-cols-[max-content_1fr] gap-x-4 gap-y-0.5 font-mono text-xs`,children:_a(e.node).map(([e,t])=>(0,Q.jsxs)(`div`,{className:`contents`,children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,Q.jsx)(`dd`,{className:`break-all`,children:t})]},e))}),p&&(p.hitBlocks!==void 0||p.readBlocks!==void 0)&&(0,Q.jsxs)(`p`,{className:`text-muted-foreground text-xs`,children:[`Buffers: `,(p.hitBlocks??0).toLocaleString(),` pages from memory, `,(p.readBlocks??0).toLocaleString(),` read in.`]}),h.map(e=>(0,Q.jsxs)(`p`,{className:e.level===`bad`?`text-destructive`:``,children:[`⚠ `,e.detail]},e.label)),e.hint&&(0,Q.jsxs)(`p`,{children:[`💡 `,e.hint]}),_.map((e,t)=>(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`p`,{children:[(0,Q.jsxs)(`span`,{className:`font-medium`,children:[e.title,`.`]}),` `,(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e.detail})]}),e.sql&&(0,Q.jsx)(We,{sql:e.sql})]},t))]})]},t.get(e))})]})}function Ya({plan:e,analyzed:t,tableRows:n}){let r=(0,X.useMemo)(()=>Ki(e),[e]),[i,a]=(0,X.useState)(`tree`),o=(0,X.useMemo)(()=>{let e=new Map,t=n=>{n.children.forEach(t),e.set(n,e.size+1)};return t(r),e},[r]),s=(0,X.useMemo)(()=>sa(r),[r]);return(0,Q.jsxs)(`div`,{className:`mb-6`,children:[(0,Q.jsx)(`p`,{className:`mb-1 text-sm`,children:Ji(r)}),t?(0,Q.jsxs)(`p`,{className:`text-muted-foreground mb-3 text-xs`,children:[`Measured by running the query`,t.executionMs!==null&&(0,Q.jsxs)(Q.Fragment,{children:[` in `,(0,Q.jsx)(`strong`,{className:`text-foreground`,children:Ga(t.executionMs)})]}),t.planningMs!==null&&(0,Q.jsxs)(Q.Fragment,{children:[` (planning took `,Ga(t.planningMs),`)`]}),`, inside a transaction that was rolled back. Times are per step without the steps below it; rows are over all loops. Click a step for details.`]}):(0,Q.jsx)(`p`,{className:`text-muted-foreground mb-3 text-xs`,children:`This is a plan, not a result: the query was not run, and the numbers are the planner's estimates. Use Explain analyze to measure it. Read the numbered steps from 1 upwards; click one for details.`}),(0,Q.jsx)(`div`,{role:`tablist`,"aria-label":`Plan view`,className:`mb-3 flex gap-1`,children:[`tree`,`words`].map(e=>(0,Q.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":i===e,onClick:()=>a(e),className:`border px-2 py-1 text-xs ${i===e?`border-primary bg-accent text-accent-foreground`:`border-border text-muted-foreground`}`,children:e===`tree`?`Tree`:`In words`},e))}),i===`tree`?(0,Q.jsx)(Ja,{root:r,numbers:o,suggestions:s,tableRows:n}):(0,Q.jsx)(Wa,{step:r,total:r.node[`Total Cost`],worst:qi(r),numbers:o}),(0,Q.jsx)(`h3`,{className:`mt-5 mb-2 text-sm font-medium`,children:`Ways to make it faster`}),s.length===0?(0,Q.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`None. Nothing in this plan stands out, so there is no change I would make.`}):(0,Q.jsx)(`ul`,{className:`space-y-2`,children:s.map((e,t)=>(0,Q.jsxs)(`li`,{className:`rounded-md border p-3 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,Q.jsxs)(`span`,{className:`text-muted-foreground ml-2 text-xs`,children:[`(step `,o.get(e.step),`)`]}),(0,Q.jsx)(`p`,{className:`text-muted-foreground mt-1`,children:e.detail}),e.sql&&(0,Q.jsx)(We,{sql:e.sql})]},t))}),s.some(e=>e.sql)&&(0,Q.jsx)(`p`,{className:`text-muted-foreground mt-2 text-xs`,children:`An index speeds up reads but makes writes a little slower and takes space, so try it on a copy of the data first.`})]})}function Xa(){let[e]=(0,X.useState)(()=>performance.now()),[t,n]=(0,X.useState)(e);return(0,X.useEffect)(()=>{let e=window.setInterval(()=>n(performance.now()),100);return()=>window.clearInterval(e)},[]),(0,Q.jsxs)(`span`,{role:`timer`,className:`text-muted-foreground w-16 text-sm tabular-nums`,children:[((t-e)/1e3).toFixed(1),` s`]})}function Za({label:e,done:t,icon:n,text:r,disabled:i}){let[a,o]=(0,X.useState)(!1);return(0,Q.jsxs)(Ii,{closeOnClick:!1,disabled:i,onClick:()=>navigator.clipboard.writeText(r()).then(()=>{o(!0),window.setTimeout(()=>o(!1),1500)},()=>{}),children:[a?(0,Q.jsx)(se,{}):(0,Q.jsx)(n,{}),` `,a?t:e]})}function Qa({environment:r,tab:i,name:s,active:c,protectedEnv:l,readOnly:u,write:f,statement:p}){let[m,h]=(0,X.useState)(()=>Da(r,i)),[g,_]=(0,X.useState)(pe),[y,b]=(0,X.useState)(!1),[C,w]=(0,X.useState)(!1),[T,E]=(0,X.useState)(!1),D=jr(r),[O,k]=(0,X.useState)(0),A=(0,X.useRef)(void 0),[j,M]=(0,X.useState)(!1),N=(0,X.useRef)(void 0),[P,F]=(0,X.useState)({}),[I,L]=(0,X.useState)(),[R,z]=(0,X.useState)(),{data:B}=ft(()=>e.catalog(r),r),{data:ee}=ft(()=>e.functions(r),r),V=(0,X.useMemo)(()=>{let e=new Map((B??[]).map(e=>[`${e.schema}.${e.name}`,e.estimatedRows]));return(t,n)=>t?e.get(`${t}.${n}`)??void 0:void 0},[B]);(0,X.useEffect)(()=>Oa(r,i,m),[r,i,m]);let[H,U]=(0,X.useState)({text:``,page:0}),W=e=>{c&&v(window.location.hash).sql&&d({environment:r,sql:!0,statement:e})},G=(t,n)=>{let i=new AbortController;A.current=i,b(!0),W({text:t,run:!0,page:n}),e.query(r,t,n*za,za,i.signal).then(e=>{dt(r,t,`public`,e.command),U({text:t,page:n}),z({result:e})},e=>z(i.signal.aborted?{error:`Cancelled.`}:{error:e.message})).finally(()=>{A.current===i&&(A.current=void 0),b(!1),k(e=>e+1)})},te=()=>A.current?.abort();(0,X.useEffect)(()=>()=>A.current?.abort(),[]);let ne=(t,n=!1)=>{M(!0),W({text:t,explain:!0,...n?{analyze:n}:{}}),(n?e.explainAnalyze(r,t).then(({plan:e,...t})=>z({plan:e,analyzed:t})):e.explain(r,t).then(({plan:e})=>z({plan:e}))).catch(e=>z({error:e.message})).finally(()=>M(!1))};(0,X.useEffect)(()=>{p&&(h(p.text),z(void 0),L(void 0),p.explain?ne(p.text.trim(),p.analyze&&S(p.text)):p.run&&S(p.text)&&G(p.text.trim(),p.page??0))},[r,p?.text,p?.explain,p?.analyze,p?.run,p?.page]);let re=(0,X.useMemo)(()=>n(m),[m]),ie=(0,X.useMemo)(()=>x(m,B??[]),[m,B]),[K,ae]=(0,X.useState)({}),oe=(0,X.useMemo)(()=>t(m),[m]),se=e=>{let t=n(e).filter(e=>!P[e.name]?.trim());if(t.length>0)z({error:`Give a value for ${t.map(e=>e.name).join(`, `)}.`});else return a(e,P)},ce=()=>{let e=N.current??{from:m.length,to:m.length};return o(m,Math.min(e.from,m.length),Math.min(e.to,m.length))},ue=e=>{let t=(e??ce()).trim();if(!t||y)return;let n=se(t);n!==void 0&&(L(void 0),G(n,0))},fe=async()=>{if(y||oe.length===0)return;let t=[];for(let e of oe){let n=se(e.text);if(n===void 0)return;t.push(n)}let n=t.map(e=>({text:e,page:0,status:`waiting`})),i=(e,t)=>L(n=>n&&{...n,entries:n.entries.map((n,r)=>r===e?{...n,...t}:n)}),a=new AbortController;A.current=a,b(!0),z(void 0),L({entries:n,shown:0});try{for(let n=0;n<t.length;n++){i(n,{status:`running`}),L(e=>e&&{...e,shown:n});try{let o=await e.query(r,t[n],0,za,a.signal);dt(r,t[n],`public`,o.command),i(n,{status:`done`,result:o})}catch(e){i(n,{status:`failed`,error:a.signal.aborted?`Cancelled.`:e.message});for(let e=n+1;e<t.length;e++)i(e,{status:`skipped`});break}}}finally{A.current===a&&(A.current=void 0),b(!1),k(e=>e+1)}},me=(t,n)=>{let i=I?.entries[t];if(!i||y)return;let a=new AbortController;A.current=a,b(!0),e.query(r,i.text,n*za,za,a.signal).then(e=>L(r=>r&&{...r,entries:r.entries.map((r,i)=>i===t?{...r,page:n,result:e,error:void 0}:r)}),e=>L(n=>n&&{...n,entries:n.entries.map((n,r)=>r===t?{...n,status:`failed`,error:a.signal.aborted?`Cancelled.`:e.message}:n)})).finally(()=>{A.current===a&&(A.current=void 0),b(!1)})},ge=(e,t)=>{let n=N.current,r=e??n?.from??0,i=t??n?.to??0;if(r!==i){let e=Math.min(r,i),t=Math.max(r,i);h(m.slice(0,e)+vn(m.slice(e,t)).trimEnd()+m.slice(t))}else h(vn(m));N.current=void 0},be=e=>{h(e),ue(e)},xe=e=>{_(e),de(e)},Se=(e=!1)=>{let t=ce().trim();if(!t||j)return;let n=se(t);n!==void 0&&(!e||S(n)||window.confirm(`Explain analyze runs the statement to measure it. It runs inside a transaction that is rolled back, so changed rows are not kept, but sequences still advance and triggers still fire. Run it?`))&&(L(void 0),ne(n,e))};return(0,Q.jsxs)(Q.Fragment,{children:[l&&(0,Q.jsxs)(`div`,{className:`mb-2 flex items-stretch gap-3`,children:[(0,Q.jsxs)(`div`,{role:`alert`,className:`flex flex-1 items-center gap-2 rounded-lg border px-3 py-2 text-sm ${f.enabled?`border-destructive bg-destructive text-white animate-pulse`:`border-destructive/40 bg-destructive/10 text-destructive`}`,children:[(0,Q.jsx)(ve,{className:`size-4 shrink-0`}),f.enabled?(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`strong`,{children:`WRITE MODE:`}),` you are connected to protected database`,` `,(0,Q.jsx)(`strong`,{children:r}),` and what you run can change or delete live data.`]}):(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`strong`,{children:r}),` is a protected database. These queries run against live data`,u?`, but the session is read only so nothing can be changed`:``,`.`]})]}),f.available&&(0,Q.jsx)(Qt,{write:f})]}),f.error&&(0,Q.jsx)(`p`,{className:`text-destructive mb-2 text-sm`,children:f.error}),(0,Q.jsx)(Ra,{value:m,onChange:h,onRun:ue,onFormat:ge,onCursor:(e,t)=>N.current={from:e,to:t},catalog:B??[],functions:ee??[],zone:g||void 0}),re.length>0&&(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3`,role:`group`,"aria-label":`Parameters`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Parameters`}),re.map(e=>{let t=K[e.name]?void 0:ie[e.name],n=t===`date`?`date`:t?`datetime-local`:void 0;return(0,Q.jsxs)(`label`,{className:`flex items-center gap-1 font-mono text-xs`,children:[e.name,(0,Q.jsx)(`input`,{"aria-label":`Value for ${e.name}`,type:n??`text`,step:n===`datetime-local`?1:void 0,value:n===`datetime-local`?(P[e.name]??``).replace(` `,`T`):P[e.name]??``,onChange:t=>F({...P,[e.name]:n===`datetime-local`?t.target.value.replace(`T`,` `):t.target.value}),className:`border-input bg-card border px-1 py-0.5 ${n?`w-auto`:`w-32`}`,placeholder:`value`}),ie[e.name]&&(0,Q.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground underline`,onClick:()=>{ae({...K,[e.name]:!K[e.name]}),F({...P,[e.name]:``})},children:K[e.name]?`picker`:`type`})]},e.name)}),(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Numbers, true, false and null go in as they are, anything else as text; put it in 'quotes' to keep a number as text.`})]}),(0,Q.jsxs)(`div`,{className:`mt-3 mb-6 flex flex-wrap items-center gap-3`,children:[y?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(q,{variant:`destructive`,onClick:te,children:[(0,Q.jsx)(Wn,{className:`size-4`}),` Cancel`]}),(0,Q.jsx)(Xa,{})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(q,{onClick:()=>ue(),disabled:!m.trim(),children:[(0,Q.jsx)(De,{className:`size-4`}),` `,oe.length>1?`Run statement`:`Run`]}),(0,Q.jsxs)(q,{variant:`outline`,onClick:fe,disabled:oe.length===0,children:[(0,Q.jsx)(Pn,{className:`size-4`}),` Run all`,oe.length>1?` (${oe.length})`:``]})]}),(0,Q.jsxs)(Ni,{children:[(0,Q.jsxs)(Pi,{render:(0,Q.jsx)(q,{variant:`outline`}),children:[(0,Q.jsx)(On,{className:`size-4`}),` More `,(0,Q.jsx)(le,{className:`size-4`})]}),(0,Q.jsxs)(Fi,{children:[(0,Q.jsxs)(Ii,{onClick:()=>Se(),disabled:j||!m.trim(),children:[(0,Q.jsx)(Xn,{}),` `,j?`Explaining...`:`Explain`]}),(0,Q.jsxs)(Ii,{onClick:()=>Se(!0),disabled:j||!m.trim(),title:`Run the statement (rolled back afterwards) to measure the time and rows of each step`,children:[(0,Q.jsx)(Ft,{}),` Explain analyze`]}),(0,Q.jsxs)(Ii,{onClick:()=>ge(),disabled:!m.trim(),title:`Format the selection, or all of the text (Cmd/Ctrl + Shift + F)`,children:[(0,Q.jsx)(Kn,{}),` Format`]}),(0,Q.jsxs)(Ii,{onClick:()=>w(!C),children:[(0,Q.jsx)(Bn,{}),` `,C?`Hide history`:`History`]}),(0,Q.jsxs)(Ii,{onClick:()=>E(!T),title:`Settings (GUCs) set on the session before each statement runs`,children:[(0,Q.jsx)(ye,{}),` Settings`,D.count>0?` (${D.count})`:``]}),(0,Q.jsx)(Li,{}),(0,Q.jsx)(Za,{label:`Copy`,done:`Copied`,icon:he,text:()=>m,disabled:!m.trim()}),(0,Q.jsx)(Za,{label:`Share`,done:`Share code copied`,icon:pt,text:()=>xa({sql:m,name:s}),disabled:!m.trim()}),(0,Q.jsx)(Li,{}),(0,Q.jsx)(`div`,{className:`px-1.5 py-1`,onKeyDown:e=>e.stopPropagation(),children:(0,Q.jsx)(ka,{zone:g,onChange:xe})})]})]}),T&&(0,Q.jsx)(Mr,{rows:D.rows,change:D.change}),(0,Q.jsxs)(`span`,{className:`text-muted-foreground text-xs`,children:[`⌘/Ctrl + Enter runs the selection, or the statement the cursor is in; ⌘/Ctrl + Shift + F formats. Ctrl + Space completes. Paste a share code anywhere on this page to open it in a new tab.`,` `,!B&&`Loading tables for hints...`]})]}),C&&(0,Q.jsx)(Fr,{environment:r,sql:m,refresh:O,onPick:e=>{h(e),z(void 0)}}),R?.error&&(0,Q.jsx)(`pre`,{className:`text-destructive text-sm whitespace-pre-wrap`,children:R.error}),I&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{role:`tablist`,"aria-label":`Statements`,className:`mb-3 flex flex-wrap gap-1`,children:I.entries.map((e,t)=>(0,Q.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":I.shown===t,onClick:()=>L({...I,shown:t}),className:`flex items-center gap-1 border px-2 py-1 text-xs ${I.shown===t?`border-primary bg-accent text-accent-foreground`:`border-border text-muted-foreground`}`,children:[e.status===`running`?(0,Q.jsx)(_e,{className:`size-3.5 animate-spin`}):e.status===`done`?(0,Q.jsx)(En,{className:`size-3.5`}):e.status===`failed`?(0,Q.jsx)(wn,{className:`text-destructive size-3.5`}):null,Ba(e,t)]},t))}),(()=>{let e=I.entries[I.shown];return e?(0,Q.jsxs)(`div`,{role:`tabpanel`,children:[(0,Q.jsx)(`pre`,{className:`text-muted-foreground mb-2 max-h-24 overflow-auto text-xs whitespace-pre-wrap`,children:e.text}),e.status===`waiting`&&(0,Q.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Waiting for the statements before it.`}),e.status===`running`&&(0,Q.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Running...`}),e.status===`skipped`&&(0,Q.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Not run: an earlier statement failed.`}),e.error&&(0,Q.jsx)(`pre`,{className:`text-destructive text-sm whitespace-pre-wrap`,children:e.error}),e.result&&(0,Q.jsx)(Ua,{environment:r,text:e.text,result:e.result,page:e.page,running:y,onPage:e=>me(I.shown,e),onGroup:be,zone:g||void 0,catalog:B??[]})]}):null})()]}),R?.plan&&(0,Q.jsx)(Ya,{plan:R.plan,analyzed:R.analyzed,tableRows:V}),R?.result&&(0,Q.jsx)(Ua,{environment:r,text:H.text,result:R.result,page:H.page,running:y,onPage:e=>G(H.text,e),onGroup:be,zone:g||void 0,catalog:B??[]})]})}var $a=e=>`psql-explorer:sql-tabs:${e}`;function eo(e){try{let t=JSON.parse(window.localStorage.getItem($a(e))??`null`);if(t&&Array.isArray(t.tabs)&&t.tabs.length>0)return t}catch{}return{tabs:[{id:`1`}],active:`1`,next:2}}function to({environment:e,statement:t,visible:n,...r}){let[i,a]=(0,X.useState)(()=>eo(e)),[o,s]=(0,X.useState)(),[c,l]=(0,X.useState)(),u=(0,X.useRef)(i.active);u.current=i.active,(0,X.useEffect)(()=>{try{window.localStorage.setItem($a(e),JSON.stringify(i))}catch{}},[e,i]),(0,X.useEffect)(()=>{t&&l(u.current)},[t?.text,t?.explain,t?.analyze,t?.run,t?.page]);let d=t=>{a(n=>{let r=String(n.next);return Oa(e,r,t.sql),{tabs:[...n.tabs,{id:r,name:t.name}],active:r,next:n.next+1}})};(0,X.useEffect)(()=>{if(!n)return;let e=e=>{let t=Sa(e.clipboardData?.getData(`text`)??``);t&&(e.preventDefault(),d(t))};return document.addEventListener(`paste`,e,!0),()=>document.removeEventListener(`paste`,e,!0)},[n,e]);let f=e=>e.name||`Query ${e.id}`,p=()=>a(e=>{let t=String(e.next);return{tabs:[...e.tabs,{id:t}],active:t,next:e.next+1}}),m=t=>{Ea(e,t),a(e=>{let n=e.tabs.filter(e=>e.id!==t);if(n.length===0)return{tabs:[{id:String(e.next)}],active:String(e.next),next:e.next+1};let r=e.tabs.findIndex(e=>e.id===t);return{...e,tabs:n,active:e.active===t?n[Math.min(r,n.length-1)].id:e.active}})},h=(e,t)=>{a(n=>({...n,tabs:n.tabs.map(n=>n.id===e?{...n,name:t.trim()||void 0}:n)})),s(void 0)};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{role:`tablist`,"aria-label":`Queries`,className:`mb-3 flex flex-wrap items-center gap-1`,children:[i.tabs.map(e=>{let t=e.id===i.active;return(0,Q.jsxs)(`div`,{className:`flex items-center border text-sm ${t?`border-primary text-accent-text`:`border-input text-muted-foreground hover:text-foreground`}`,children:[o===e.id?(0,Q.jsx)(`input`,{autoFocus:!0,"aria-label":`Tab name`,defaultValue:e.name??``,placeholder:`Query ${e.id}`,maxLength:40,onFocus:e=>e.currentTarget.select(),onBlur:t=>h(e.id,t.currentTarget.value),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&s(void 0)},className:`bg-transparent w-32 px-2 py-1 outline-none`}):(0,Q.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t,title:`Double-click to rename`,onClick:()=>a(t=>({...t,active:e.id})),onDoubleClick:()=>s(e.id),className:`max-w-48 truncate px-2 py-1`,children:f(e)}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Close ${f(e)}`,onClick:()=>m(e.id),className:`hover:text-destructive px-1 py-1`,children:(0,Q.jsx)($t,{className:`size-3`})})]},e.id)}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`New query tab`,title:`New query tab`,onClick:p,className:`text-muted-foreground hover:text-foreground border-input border p-1.5`,children:(0,Q.jsx)(tt,{className:`size-4`})})]}),i.tabs.map(n=>(0,Q.jsx)(`div`,{role:`tabpanel`,hidden:n.id!==i.active,children:(0,Q.jsx)(Qa,{environment:e,tab:n.id,name:n.name,active:n.id===i.active,statement:n.id===c?t:void 0,...r})},n.id))]})}export{to as SqlTabs};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{it as e,ot as t,rt as n}from"./route-DO6IZ7of.js";t();var r=n();function i({className:t,...n}){return(0,r.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,r.jsx)(`table`,{"data-slot":`table`,className:e(`w-full caption-bottom text-sm`,t),...n})})}function a({className:t,...n}){return(0,r.jsx)(`thead`,{"data-slot":`table-header`,className:e(`[&_tr]:border-b`,t),...n})}function o({className:t,...n}){return(0,r.jsx)(`tbody`,{"data-slot":`table-body`,className:e(`[&_tr:last-child]:border-0`,t),...n})}function s({className:t,...n}){return(0,r.jsx)(`tr`,{"data-slot":`table-row`,className:e(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,t),...n})}function c({className:t,...n}){return(0,r.jsx)(`th`,{"data-slot":`table-head`,className:e(`h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0`,t),...n})}function l({className:t,...n}){return(0,r.jsx)(`td`,{"data-slot":`table-cell`,className:e(`p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0`,t),...n})}export{a,c as i,o as n,s as o,l as r,i as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{at as e}from"./route-DO6IZ7of.js";var t={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};t.node;var n=e(t);export{n as t};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{Z as e,at as t,ct as n,ot as r,rt as i}from"./route-DO6IZ7of.js";import{t as a,z as o}from"./button-ClA70PLR.js";import{t as s}from"./copy-CCXzeW-s.js";var c={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};c.node;var l=t(c),u={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};u.node;var d=t(u),f={name:`download`,size:24,node:[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]};f.node;var p=t(f),m={name:`external-link`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]};m.node;var h=t(m),g=n(r(),1);function _(t){let n=t.toLowerCase();return e(n)===`timestamptz`?`timestamptz`:n.endsWith(`[]`)||n.startsWith(`_`)?`array`:n===`bytea`?`bytea`:/^(public\.)?"?(geometry|geography)"?(\(.*\))?$/.test(n)?`geometry`:/multirange$/.test(n)?`multirange`:/range$/.test(n)?`range`:`text`}function v(e){let t=/^(\d{4,})-(\d\d)-(\d\d)[ T](\d\d):(\d\d):(\d\d)(?:\.(\d+))?([+-]\d\d)(?::?(\d\d))?(?::?(\d\d))?$/.exec(e);if(!t)return;let[,n,r,i,a,o,s,c,l,u,d]=t,f=(l.startsWith(`-`)?-1:1)*(Math.abs(Number(l))*3600+Number(u??0)*60+Number(d??0)),p=Number(((c??`0`)+`00`).slice(0,3)),m=Date.UTC(Number(n),Number(r)-1,Number(i),Number(a),Number(o),Number(s),p);if(!Number.isNaN(m))return new Date(m-f*1e3)}function y(e,t){let n=v(e);if(n)try{let r=new Intl.DateTimeFormat(`en-GB`,{timeZone:t,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`,timeZoneName:`short`}).formatToParts(n),i=e=>r.find(t=>t.type===e)?.value??``,a=/\.(\d+)/.exec(e)?.[1];return`${i(`year`)}-${i(`month`)}-${i(`day`)} ${i(`hour`)}:${i(`minute`)}:${i(`second`)}${a?`.${a}`:``} ${i(`timeZoneName`)}`}catch{return}}function b(e){let t=e.replace(/^\[[^\]=]*\]=/,``),n=0,r=()=>{if(t[n]!==`{`)return;n++;let e=[];if(t[n]===`}`)return n++,e;for(;;){let i=t[n];if(i===`{`){let t=r();if(!t)return;e.push(t)}else if(i===`"`){n++;let r=``;for(;n<t.length&&t[n]!==`"`;)t[n]===`\\`&&n++,r+=t[n++]??``;if(t[n]!==`"`)return;n++,e.push(r)}else{let r=``;for(;n<t.length&&t[n]!==`,`&&t[n]!==`}`;)r+=t[n++];e.push(r===`NULL`?null:r)}if(t[n]===`,`)n++;else if(t[n]===`}`)return n++,e;else return}},i=r();return i&&n===t.length?i:void 0}function x(e){let t=0,n=1,r=(e,i)=>{n=Math.max(n,i);for(let n of e)Array.isArray(n)?r(n,i+1):t++};return r(e,1),{count:t,depth:n}}function S(e){if(e===`empty`)return{empty:!0};let t=/^([[(])(.*)([\])])$/s.exec(e);if(!t)return;let n=t[2],r=[],i=``,a=!1;for(let e=0;e<n.length;e++){let t=n[e];a?t===`"`&&n[e+1]===`"`?(i+=`"`,e++):t===`\\`?i+=n[++e]??``:t===`"`?a=!1:i+=t:t===`"`?a=!0:t===`,`&&r.length===0?(r.push(i),i=``):i+=t}if(r.push(i),r.length!==2)return;let[o,s]=r;return{empty:!1,lower:o===``?null:{value:o,inclusive:t[1]===`[`},upper:s===``?null:{value:s,inclusive:t[3]===`]`}}}function ee(e){let t=/^\{(.*)\}$/s.exec(e);if(!t)return;if(t[1]===``)return[];let n=[],r=0,i=!1,a=``;for(let e of t[1])e===`"`&&(i=!i),i||e!==`[`&&e!==`(`||r++,i||e!==`]`&&e!==`)`||r--,!i&&r===0&&e===`,`?(n.push(a),a=``):a+=e;n.push(a);let o=n.map(S);return o.every(e=>e)?o:void 0}function C(e){if(e.empty)return`empty`;let{lower:t,upper:n}=e;if(!t&&!n)return`everything`;let r=t?`${t.value} ${t.inclusive?`≤`:`<`} `:``;return n?`${r}x ${n.inclusive?`≤`:`<`} ${n.value}`:`x ${t.inclusive?`≥`:`>`} ${t.value}`}function te(e){if(!/^\\x([0-9a-fA-F]{2})*$/.test(e))return;let t=e.slice(2),n=new Uint8Array(t.length/2);for(let e=0;e<n.length;e++)n[e]=parseInt(t.slice(e*2,e*2+2),16);return n}function ne(e){let t=``;for(let n of e)t+=n.toString(16).padStart(2,`0`);return`\\x${t}`}var w=20971520;async function T(e,t){if(e.size>20971520)throw Error(`${e.name} is ${M(e.size)}; the limit is ${M(w)}`);if(_(t)===`bytea`)return ne(new Uint8Array(await e.arrayBuffer()));let n=await e.text();if(n.includes(`\0`))throw Error(`${e.name} is not text, so it cannot go in a ${t} column`);return n}var E=(e,t,n)=>n.every((n,r)=>e[t+r]===n);function D(e){if(E(e,0,[137,80,78,71,13,10,26,10]))return`image/png`;if(E(e,0,[255,216,255]))return`image/jpeg`;if(E(e,0,[71,73,70,56]))return`image/gif`;if(E(e,0,[82,73,70,70])&&E(e,8,[87,69,66,80]))return`image/webp`;if(E(e,0,[66,77]))return`image/bmp`}var re={"image/jpeg":`jpg`},O=e=>[...e].map(e=>e.charCodeAt(0)),ie=[{bytes:O(`%PDF-`),type:{mime:`application/pdf`,extension:`pdf`}},{bytes:[80,75,3,4],type:{mime:`application/zip`,extension:`zip`}},{bytes:[31,139,8],type:{mime:`application/gzip`,extension:`gz`}},{bytes:O(`BZh`),type:{mime:`application/x-bzip2`,extension:`bz2`}},{bytes:[253,...O(`7zXZ`),0],type:{mime:`application/x-xz`,extension:`xz`}},{bytes:[55,122,188,175,39,28],type:{mime:`application/x-7z-compressed`,extension:`7z`}},{bytes:[...O(`Rar!`),26,7],type:{mime:`application/vnd.rar`,extension:`rar`}},{at:257,bytes:O(`ustar`),type:{mime:`application/x-tar`,extension:`tar`}},{bytes:[...O(`SQLite format 3`),0],type:{mime:`application/vnd.sqlite3`,extension:`sqlite`}},{bytes:[0,0,1,0],type:{mime:`image/x-icon`,extension:`ico`}},{bytes:[...O(`II`),42,0],type:{mime:`image/tiff`,extension:`tiff`}},{bytes:[...O(`MM`),0,42],type:{mime:`image/tiff`,extension:`tiff`}},{at:4,bytes:O(`ftyp`),type:{mime:`video/mp4`,extension:`mp4`}},{bytes:O(`OggS`),type:{mime:`audio/ogg`,extension:`ogg`}},{bytes:O(`fLaC`),type:{mime:`audio/flac`,extension:`flac`}},{bytes:O(`ID3`),type:{mime:`audio/mpeg`,extension:`mp3`}},{bytes:[255,251],type:{mime:`audio/mpeg`,extension:`mp3`}},{bytes:[26,69,223,163],type:{mime:`video/webm`,extension:`webm`}},{bytes:O(`wOF2`),type:{mime:`font/woff2`,extension:`woff2`}}];function k(e){let t=D(e);if(t)return{mime:t,extension:re[t]??t.replace(`image/`,``)};if(E(e,0,O(`RIFF`))&&E(e,8,O(`WAVE`)))return{mime:`audio/wav`,extension:`wav`};let n=ie.find(({at:t=0,bytes:n})=>E(e,t,n));if(n)return n.type;if(e.length>0){let t;try{t=new TextDecoder(`utf-8`,{fatal:!0}).decode(e)}catch{}if(t!==void 0&&!/[\u0000-\u0008\u000e-\u001f]/.test(t))try{return JSON.parse(t),{mime:`application/json`,extension:`json`}}catch{return{mime:`text/plain`,extension:`txt`}}}return{mime:`application/octet-stream`,extension:`bin`}}function A(e,t,n=!1){return`${e}.${t.extension}${n?`.gz`:``}`}async function j(e){let t=new Blob([e]).stream().pipeThrough(new CompressionStream(`gzip`));return new Uint8Array(await new Response(t).arrayBuffer())}function M(e){return e<1024?`${e} byte${e===1?``:`s`}`:e<1048576?`${(e/1024).toFixed(1)} kB`:`${(e/1024/1024).toFixed(1)} MB`}function N(e,t=32){let n=[...e.slice(0,t)].map(e=>e.toString(16).padStart(2,`0`)).join(` `);return e.length>t?`${n} …`:n}var ae=[``,`Point`,`LineString`,`Polygon`,`MultiPoint`,`MultiLineString`,`MultiPolygon`,`GeometryCollection`];function oe(e){if(!/^([0-9a-fA-F]{2}){5,}$/.test(e)||e.length>2e6)return;let t=new Uint8Array(e.length/2);for(let n=0;n<t.length;n++)t[n]=parseInt(e.slice(n*2,n*2+2),16);let n=new DataView(t.buffer),r=0,i;try{let e=()=>{let t=n.getUint8(r++)===1,a=n.getUint32(r,t);r+=4;let o=!!(a&2147483648)||(a&65535)>=1e3,s=!!(a&1073741824);if(a&536870912){let e=n.getInt32(r,t);r+=4,i??=e}let c=(a&65535)%1e3,l=()=>{let e=n.getFloat64(r,t);return r+=8,e},u=()=>{let e=l(),t=l();return o&&l(),s&&l(),[e,t]},d=()=>{let e=n.getUint32(r,t);if(r+=4,e>1e6)throw RangeError(`too many`);return e},f=()=>Array.from({length:d()},u);switch(c){case 1:return{type:`Point`,points:[u()]};case 2:return{type:`LineString`,points:f()};case 3:return{type:`Polygon`,rings:Array.from({length:d()},f)};case 4:case 5:case 6:case 7:return{type:c===7?`Collection`:`Multi`,name:ae[c],parts:Array.from({length:d()},e)};default:throw RangeError(`unknown geometry`)}},a=e();return r===t.length?{srid:i,shape:a}:void 0}catch{return}}var P=e=>e.type===`Multi`||e.type===`Collection`?e.name:e.type;function F(e){return e.type===`Point`||e.type===`LineString`?e.points:e.type===`Polygon`?e.rings.flat():e.parts.flatMap(F)}function I(e){let t=F(e);if(t.length===0)return;let n=1/0,r=1/0,i=-1/0,a=-1/0;for(let[e,o]of t)n=Math.min(n,e),r=Math.min(r,o),i=Math.max(i,e),a=Math.max(a,o);return[n,r,i,a]}function L(e){let{shape:t,srid:n}=e,r=n?` · SRID ${n}`:``;if(t.type===`Point`)return`Point (${t.points[0].map(e=>+e.toFixed(6)).join(` `)})${r}`;let i=F(t).length;return`${P(t)}, ${i} point${i===1?``:`s`}${r}`}function se(e){if(e.srid!==4326)return;let t=I(e.shape);if(!t)return;let[n,r,i,a]=t,o=(n+i)/2,s=(r+a)/2;if(!(Math.abs(o)>180||Math.abs(s)>90))return`https://www.openstreetmap.org/?mlat=${s}&mlon=${o}#map=15/${s}/${o}`}var R=i(),z=80;function B({items:e}){return(0,R.jsx)(`ol`,{className:`list-decimal space-y-0.5 pl-5 text-xs`,children:e.map((e,t)=>Array.isArray(e)?(0,R.jsx)(`li`,{children:(0,R.jsx)(B,{items:e})},t):(0,R.jsx)(`li`,{className:e===null?`text-muted-foreground italic`:`break-all`,children:e===null?`NULL`:e},t))})}var V=(e,t,n)=>{let r=e=>`${e[0]},${-e[1]}`;if(e.type===`Point`)return e.points.map((e,r)=>(0,R.jsx)(`circle`,{cx:e[0],cy:-e[1],r:n,className:`fill-primary`,"data-point":!0},`${t}${r}`));if(e.type===`LineString`)return(0,R.jsx)(`polyline`,{points:e.points.map(r).join(` `),fill:`none`,className:`stroke-primary`,strokeWidth:2,vectorEffect:`non-scaling-stroke`},t);if(e.type===`Polygon`){let n=e.rings.map(e=>`M${e.map(r).join(`L`)}Z`).join(``);return(0,R.jsx)(`path`,{d:n,fillRule:`evenodd`,className:`fill-primary/20 stroke-primary`,strokeWidth:2,vectorEffect:`non-scaling-stroke`},t)}return e.parts.map((e,r)=>V(e,`${t}.${r}`,n))};function H({geometry:e}){let t=I(e.shape);if(!t)return(0,R.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Empty geometry.`});let[n,r,i,a]=t,o=Math.max(i-n,a-r)*.1||1;n-=o,r-=o,i+=o,a+=o;let s=se(e),c=e.shape.type===`Point`;return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`svg`,{role:`img`,"aria-label":`${P(e.shape)} preview`,viewBox:`${n} ${-a} ${i-n} ${a-r}`,preserveAspectRatio:`xMidYMid meet`,className:`bg-muted h-48 w-72`,children:(0,R.jsx)(`g`,{children:V(e.shape,`g`,o*.2)})}),(0,R.jsxs)(`p`,{className:`text-muted-foreground mt-1 text-xs`,children:[L(e),!c&&t&&` · x ${+t[0].toFixed(6)} to ${+t[2].toFixed(6)}, y ${+t[1].toFixed(6)} to ${+t[3].toFixed(6)}`]}),s&&(0,R.jsxs)(`a`,{href:s,target:`_blank`,rel:`noreferrer`,className:`text-accent-text inline-flex items-center gap-1 text-xs hover:underline`,onClick:e=>e.stopPropagation(),children:[`Open on OpenStreetMap `,(0,R.jsx)(h,{className:`size-3`})]})]})}function U(e,t){let[n,r]=(0,g.useState)();return(0,g.useEffect)(()=>{if(!e||!t)return r(void 0);let n=URL.createObjectURL(new Blob([e],{type:t}));return r(n),()=>URL.revokeObjectURL(n)},[e,t]),n}function W({bytes:e,file:t,url:n,name:r,size:i}){let[a,o]=(0,g.useState)(!1),s=`text-accent-text inline-flex items-center gap-1 text-xs hover:underline`,c=async()=>{o(!0);try{let n=await j(e),i=URL.createObjectURL(new Blob([n],{type:`application/gzip`})),a=document.createElement(`a`);a.href=i,a.download=A(r,t,!0),a.click(),URL.revokeObjectURL(i)}finally{o(!1)}};return(0,R.jsxs)(`span`,{className:`flex items-center gap-3`,children:[(0,R.jsxs)(`a`,{href:n,download:A(r,t),onClick:e=>e.stopPropagation(),className:s,children:[(0,R.jsx)(p,{className:`size-3`}),` Download `,i,` (.`,t.extension,`)`]}),t.extension!==`gz`&&(0,R.jsxs)(`button`,{type:`button`,disabled:a,onClick:e=>{e.stopPropagation(),c()},className:s,children:[(0,R.jsx)(p,{className:`size-3`}),` `,a?`Compressing...`:`as .gz`]})]})}function G(e,t,n,r){let i=_(t),a=(0,g.useMemo)(()=>i===`bytea`?te(e):void 0,[i,e]),o=(0,g.useMemo)(()=>a?D(a):void 0,[a]),s=U(o?a:void 0,o),c=(0,g.useMemo)(()=>a?k(a):void 0,[a]),l=U(a,c?.mime),u=(0,g.useMemo)(()=>i===`geometry`?oe(e):void 0,[i,e]);if(i===`timestamptz`&&n){let t=y(e,n);if(t)return{summary:t,title:`${e} (as the database wrote it)`}}if(i===`array`){let t=b(e);if(t){let{count:n,depth:r}=x(t),i=`${n} item${n===1?``:`s`}${r>1?`, ${r} levels`:``}`;return{summary:`${e}`,title:i,detail:n>0?(0,R.jsx)(B,{items:t}):void 0}}}if(i===`range`){let t=S(e);if(t)return{summary:C(t),title:e}}if(i===`multirange`){let t=ee(e);if(t)return{summary:t.map(C).join(` or `)||`empty`,title:e}}if(i===`geometry`&&u)return{summary:L(u),title:e.length>80?`${e.slice(0,80)}…`:e,detail:(0,R.jsx)(H,{geometry:u})};if(i===`bytea`&&a){let e=M(a.length),t=a&&c&&l&&(0,R.jsx)(W,{bytes:a,file:c,url:l,name:r,size:e});return o&&s?{summary:`${o.replace(`image/`,``).toUpperCase()} image, ${e}`,thumbnail:s,detail:(0,R.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[(0,R.jsx)(`img`,{src:s,alt:`${o} image, ${e}`,className:`bg-muted max-h-64 max-w-72 object-contain`}),t]})}:{summary:`${e}: ${N(a,12)}`,title:`${e}`,detail:(0,R.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[(0,R.jsx)(`pre`,{className:`max-w-96 text-xs break-all whitespace-pre-wrap`,children:N(a,256)}),t]})}}let d=e.length>z||e.includes(`
|
|
2
|
+
`);return{summary:e,title:d?void 0:e,detail:d?(0,R.jsx)(`span`,{className:`block max-w-[32rem] text-sm break-words whitespace-pre-wrap`,children:e}):void 0}}function ce({value:e,type:t,zone:n,name:r=`download`,open:i=!1,children:a}){let o=G(e,t,n,r),[s,c]=(0,g.useState)(!1),u=i||s;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{className:`flex max-w-80 items-center gap-1`,children:[o.thumbnail&&(0,R.jsx)(`img`,{src:o.thumbnail,alt:``,className:`size-5 shrink-0 object-cover`}),(0,R.jsx)(`span`,{className:`block min-w-0 truncate`,title:o.title??e,children:a??o.summary}),o.detail&&!i&&(0,R.jsx)(`button`,{type:`button`,"aria-expanded":s,"aria-label":s?`Show less`:`Show more`,title:s?`Show less`:`Show more`,onClick:e=>{e.stopPropagation(),c(!s)},className:`text-muted-foreground hover:text-foreground shrink-0`,children:s?(0,R.jsx)(l,{className:`size-3.5`}):(0,R.jsx)(d,{className:`size-3.5`})})]}),u&&o.detail&&(0,R.jsx)(`div`,{className:`mt-1 whitespace-normal`,children:o.detail})]})}var K={csv:{label:`CSV`,extension:`csv`,mime:`text/csv`},json:{label:`JSON`,extension:`json`,mime:`application/json`},sql:{label:`SQL INSERTs`,extension:`sql`,mime:`application/sql`}},q=e=>/[",\r\n]/.test(e)?`"${e.replaceAll(`"`,`""`)}"`:e;function le({columns:e,rows:t}){return[e.map(e=>q(e.name)).join(`,`),...t.map(e=>e.map(e=>e===null?``:q(e)).join(`,`))].map(e=>`${e}\r\n`).join(``)}var ue=new Set([`smallint`,`integer`,`real`,`double precision`,`oid`]);function de(e,t){if(e===null)return null;if(ue.has(t)){let t=Number(e);return Number.isFinite(t)?t:e}if(t===`boolean`)return e===`t`;if(t===`json`||t===`jsonb`)try{return JSON.parse(e)}catch{return e}return e}function fe({columns:e,rows:t}){let n=t.map(t=>Object.fromEntries(e.map((e,n)=>[e.name,de(t[n]??null,e.type)])));return`${JSON.stringify(n,null,2)}\n`}var J=e=>`"${e.replaceAll(`"`,`""`)}"`,pe=e=>e.split(`.`).map(e=>J(e.replace(/^"(.*)"$/,`$1`))).join(`.`),me=/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/,he=/^(smallint|integer|bigint|numeric|real|double precision|oid)/;function ge(e,t){return e===null?`NULL`:he.test(t)&&me.test(e)?e:t===`boolean`?e===`t`?`true`:`false`:`'${e.replaceAll(`'`,`''`)}'`}var Y=100;function X({columns:e,rows:t},n){if(t.length===0)return`-- no rows
|
|
3
|
+
`;let r=`INSERT INTO ${pe(n)} (${e.map(e=>J(e.name)).join(`, `)}) VALUES\n`,i=[];for(let n=0;n<t.length;n+=Y){let a=t.slice(n,n+Y).map(t=>` (${e.map((e,n)=>ge(t[n]??null,e.type)).join(`, `)})`);i.push(`${r}${a.join(`,
|
|
4
|
+
`)};\n`)}return i.join(`
|
|
5
|
+
`)}function _e(e,t,n){return t===`csv`?le(e):t===`json`?fe(e):X(e,n)}function ve(e,t,n){let r=URL.createObjectURL(new Blob([e],{type:`${n};charset=utf-8`})),i=document.createElement(`a`);i.href=r,i.download=t,document.body.append(i),i.click(),i.remove(),URL.revokeObjectURL(r)}var Z=`border-input bg-background rounded-lg border px-2 py-1 text-sm`;function ye({data:e,fetchAll:t,target:n,filename:r}){let[i,c]=(0,g.useState)(`csv`),[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(n??`table_name`),[m,h]=(0,g.useState)(),[_,v]=(0,g.useState)(),[y,b]=(0,g.useState)(),x=async n=>{h(n),b(void 0);try{let a=e;if(l){let e=await t();a=e,e.truncated&&b(`Only the first ${e.rows.length.toLocaleString()} rows are exported.`)}let o=_e(a,i,d.trim()||`table_name`);n===`copy`?await navigator.clipboard.writeText(o):ve(o,`${r}.${K[i].extension}`,K[i].mime),v(n),window.setTimeout(()=>v(void 0),1500)}catch(e){b(e instanceof Error?e.message:String(e))}finally{h(void 0)}};return(0,R.jsxs)(`div`,{className:`text-muted-foreground mb-2 flex flex-wrap items-center gap-2 text-xs`,children:[(0,R.jsx)(`span`,{children:`Export`}),(0,R.jsx)(`select`,{"aria-label":`Export format`,value:i,onChange:e=>c(e.target.value),className:Z,children:Object.entries(K).map(([e,{label:t}])=>(0,R.jsx)(`option`,{value:e,children:t},e))}),(0,R.jsxs)(`select`,{"aria-label":`Rows to export`,value:l?`all`:`page`,onChange:e=>u(e.target.value===`all`),className:Z,children:[(0,R.jsx)(`option`,{value:`page`,children:`this page`}),(0,R.jsx)(`option`,{value:`all`,children:`all rows`})]}),i===`sql`&&(0,R.jsx)(`input`,{"aria-label":`Table to insert into`,value:d,onChange:e=>f(e.target.value),className:`${Z} w-40`}),(0,R.jsxs)(a,{variant:`outline`,size:`sm`,disabled:m!==void 0,onClick:()=>x(`copy`),children:[_===`copy`?(0,R.jsx)(o,{}):(0,R.jsx)(s,{}),` `,_===`copy`?`Copied`:`Copy`]}),(0,R.jsxs)(a,{variant:`outline`,size:`sm`,disabled:m!==void 0,onClick:()=>x(`download`),children:[_===`download`?(0,R.jsx)(o,{}):(0,R.jsx)(p,{}),` `,m===`download`?`Reading...`:`Download`]}),y&&(0,R.jsx)(`span`,{role:`status`,children:y})]})}function be(e,t){let n=t?e+2:e,r=Math.max(0,e-2),i=[];r>0&&i.push(0),r>1&&i.push(`gap`);for(let e=r;e<=n;e++)i.push(e);return t&&i.push(`gap`),i}function xe({page:e,hasMore:t,disabled:n=!1,onPage:r}){let[i,a]=(0,g.useState)(``),o=`enabled:hover:text-foreground disabled:opacity-40`,s=()=>{let t=Number.parseInt(i,10);a(``),Number.isFinite(t)&&t>=1&&t-1!==e&&r(t-1)};return(0,R.jsxs)(`nav`,{"aria-label":`Pages`,className:`flex items-center gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:e===0||n,onClick:()=>r(e-1),className:o,children:`< previous`}),be(e,t).map((t,i)=>t===`gap`?(0,R.jsx)(`span`,{"aria-hidden":!0,children:`…`},`gap${i}`):(0,R.jsx)(`button`,{type:`button`,disabled:n,"aria-current":t===e?`page`:void 0,onClick:()=>t!==e&&r(t),className:`${o} min-w-6 px-1 ${t===e?`text-foreground font-semibold underline underline-offset-4`:``}`,children:t+1},t)),(0,R.jsx)(`button`,{type:`button`,disabled:!t||n,onClick:()=>r(e+1),className:o,children:`next >`}),(0,R.jsxs)(`form`,{className:`flex items-center gap-1`,onSubmit:e=>{e.preventDefault(),s()},children:[(0,R.jsx)(`label`,{htmlFor:`pager-jump`,children:`go to`}),(0,R.jsx)(`input`,{id:`pager-jump`,type:`number`,min:1,inputMode:`numeric`,value:i,disabled:n,onChange:e=>a(e.target.value),placeholder:`page`,className:`border-input bg-background text-foreground h-6 w-16 border px-1`})]})]})}var Q=`psql-explorer:zone`;function $(){try{return window.localStorage.getItem(Q)??`UTC`}catch{return`UTC`}}function Se(e){try{window.localStorage.setItem(Q,e)}catch{}}var Ce=()=>(0,g.useState)($)[0];export{ye as a,h as c,l as d,xe as i,p as l,Se as n,ce as o,Ce as r,T as s,$ as t,d as u};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en" class="dark">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<script>
|
|
8
|
+
try {
|
|
9
|
+
document.documentElement.dataset.theme = localStorage.getItem('psql-explorer-theme') || 'neon-sunset'
|
|
10
|
+
} catch {}
|
|
11
|
+
</script>
|
|
12
|
+
<title>psql-explorer</title>
|
|
13
|
+
<script type="module" crossorigin src="/assets/index-CDcnUacl.js"></script>
|
|
14
|
+
<link rel="modulepreload" crossorigin href="/assets/route-DO6IZ7of.js">
|
|
15
|
+
<link rel="modulepreload" crossorigin href="/assets/code-xml-CXkpHeU9.js">
|
|
16
|
+
<link rel="modulepreload" crossorigin href="/assets/button-ClA70PLR.js">
|
|
17
|
+
<link rel="modulepreload" crossorigin href="/assets/copy-CCXzeW-s.js">
|
|
18
|
+
<link rel="modulepreload" crossorigin href="/assets/zone-D9dXk8tn.js">
|
|
19
|
+
<link rel="modulepreload" crossorigin href="/assets/table-DfMz2f8M.js">
|
|
20
|
+
<link rel="modulepreload" crossorigin href="/assets/graph-link-OCo_s0zO.js">
|
|
21
|
+
<link rel="stylesheet" crossorigin href="/assets/index-OzJqnJWG.css">
|
|
22
|
+
</head>
|
|
23
|
+
<body>
|
|
24
|
+
<div id="root"></div>
|
|
25
|
+
</body>
|
|
26
|
+
</html>
|