okengine 0.16.0 → 0.17.1
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/manifest.v1.schema.json +21 -2
- package/package.json +1 -1
- package/site/content/docs/ai/llms-txt.mdx +9 -3
- package/site/content/docs/elements/clock.mdx +7 -0
- package/site/content/docs/elements/flow.mdx +14 -12
- package/site/content/docs/elements/gate.mdx +58 -8
- package/site/content/docs/elements/signal.mdx +46 -17
- package/site/content/docs/elements/store.mdx +23 -17
- package/site/content/docs/elements/vault.mdx +23 -0
- package/site/content/docs/get-started/project-structure.mdx +4 -4
- package/site/content/docs/reference/cli.md +1 -1
- package/site/content/docs/reference/client.mdx +72 -17
- package/site/content/docs/reference/configuration.mdx +7 -4
- package/site/content/docs/reference/errors.mdx +24 -17
- package/site/content/docs/reference/fx.mdx +15 -9
- package/src/auth/api-key-sql.ts +11 -4
- package/src/auth/api-keys.ts +3 -0
- package/src/auth/config.ts +19 -0
- package/src/auth/index.ts +37 -0
- package/src/auth/plugin.ts +6 -1
- package/src/auth/sessions.ts +18 -0
- package/src/auth/tables.ts +32 -0
- package/src/auth/tenant-config.ts +74 -0
- package/src/auth/tenant-tables.ts +11 -0
- package/src/auth/tenants.test.ts +63 -0
- package/src/auth/tenants.ts +360 -0
- package/src/cli/build.ts +2 -2
- package/src/client/budget.test.ts +1 -1
- package/src/client/create.ts +75 -5
- package/src/client/index.ts +13 -0
- package/src/client/live.test.ts +422 -0
- package/src/client/live.ts +389 -0
- package/src/client/notes-contract.test.ts +41 -0
- package/src/client/types.ts +85 -6
- package/src/client-react/index.ts +85 -1
- package/src/client-react/use-live.test.ts +129 -0
- package/src/compiler/effects-infer.ts +22 -2
- package/src/compiler/extract.test.ts +143 -11
- package/src/compiler/extract.ts +210 -30
- package/src/compiler/fixtures/skyport/src/flows/bookings/index.ts +1 -2
- package/src/compiler/fixtures/skyport.expected.json +2 -3
- package/src/compiler/response.ts +41 -11
- package/src/console/server/app.ts +44 -11
- package/src/console/server/console.test.ts +6 -8
- package/src/console/server/gates.ts +2 -9
- package/src/console/server/store.test.ts +17 -0
- package/src/console/server/store.ts +43 -1
- package/src/console/ui-next/dist/assets/{access-page-CAGHrA9H.js → access-page-9Wwx1g4Q.js} +1 -1
- package/src/console/ui-next/dist/assets/{flows-page-B-OUtiAu.js → flows-page-DydRDi70.js} +1 -1
- package/src/console/ui-next/dist/assets/{index-CGoZkILK.js → index-Cg9nxd6m.js} +3 -3
- package/src/console/ui-next/dist/assets/{observability-page-BDyXalNR.js → observability-page-D-OzmFOI.js} +1 -1
- package/src/console/ui-next/dist/assets/{store-page-Xh8Kn3rx.js → store-page-CS5-aETQ.js} +1 -1
- package/src/console/ui-next/dist/assets/{tree-expand-toggle-DkOXA12R.js → tree-expand-toggle-BtyhmWb4.js} +2 -1
- package/src/console/ui-next/dist/assets/{units-page-Dpk40kOQ.js → units-page-B_zeux2Y.js} +1 -1
- package/src/console/ui-next/dist/assets/{vault-page-B1dB9Ft0.js → vault-page-CsMg7XDW.js} +1 -1
- package/src/console/ui-next/dist/index.html +1 -1
- package/src/console/ui-next/src/features/flows/fixture.ts +0 -1
- package/src/console/ui-next/src/features/units/detail/flow-contract-panel.tsx +5 -1
- package/src/console/ui-next/src/features/units/lib/unit-tree.test.ts +15 -4
- package/src/console/ui-next/ui-next-seed-manifest-surface.ts +2 -9
- package/src/console/ui-next/ui-next-seed-manifest.ts +0 -1
- package/src/drivers/index.ts +2 -0
- package/src/drivers/journal-postgres.ts +12 -3
- package/src/drivers/pg-rls.ts +26 -2
- package/src/drivers/pg-vault-rls.ts +68 -0
- package/src/drivers/signal-engine.ts +69 -15
- package/src/drivers/signal-live-iter.ts +65 -0
- package/src/drivers/signal-nats.ts +2 -1
- package/src/drivers/signal-postgres.ts +95 -12
- package/src/drivers/signal-redis.ts +2 -1
- package/src/drivers/signal-retention.ts +64 -0
- package/src/drivers/signal-types.ts +35 -5
- package/src/elements/clock/declare.ts +64 -2
- package/src/elements/clock/reconcile.ts +98 -25
- package/src/elements/clock/runtime.ts +13 -2
- package/src/elements/clock.test.ts +28 -0
- package/src/elements/clock.ts +9 -1
- package/src/elements/gate/permissions.ts +12 -0
- package/src/elements/gate.ts +6 -1
- package/src/elements/signal/declare.ts +44 -10
- package/src/elements/signal/delivery-modes.test.ts +90 -4
- package/src/elements/signal/order-lifecycle.test.ts +20 -4
- package/src/elements/signal/runtime.ts +42 -0
- package/src/elements/signal.test.ts +21 -8
- package/src/elements/signal.ts +1 -1
- package/src/elements/store/declare.ts +7 -0
- package/src/elements/store/rls-identity.test.ts +29 -0
- package/src/elements/store/rls-identity.ts +3 -0
- package/src/elements/store/schema-decl.ts +63 -3
- package/src/elements/store/schema-tenant.ts +41 -0
- package/src/elements/store/sql-rls-isolation.test.ts +39 -0
- package/src/elements/store.ts +2 -0
- package/src/elements/vault/builtin-adapter.ts +15 -2
- package/src/elements/vault/declare.ts +8 -0
- package/src/elements/vault/runtime.ts +7 -0
- package/src/elements/vault/sql-rls-isolation.test.ts +145 -0
- package/src/elements/vault/storage.ts +9 -0
- package/src/elements/vault/test-helpers.ts +2 -1
- package/src/i18n/catalogs/ar.ts +19 -0
- package/src/i18n/catalogs/en.ts +19 -0
- package/src/index.ts +1 -0
- package/src/kernel/adopt-routes.ts +56 -8
- package/src/kernel/app-tenant.ts +122 -0
- package/src/kernel/app.ts +183 -56
- package/src/kernel/auth-resolve.ts +3 -0
- package/src/kernel/boot-bind/clock.ts +9 -3
- package/src/kernel/boot.ts +2 -0
- package/src/kernel/budget.test.ts +1 -1
- package/src/kernel/clock-durable.ts +8 -0
- package/src/kernel/clock-per-tenant-name.ts +5 -0
- package/src/kernel/clock-reconcile.ts +8 -0
- package/src/kernel/errors-live-resume.ts +15 -0
- package/src/kernel/errors-tenant.ts +29 -0
- package/src/kernel/errors.registry.test.ts +31 -3
- package/src/kernel/errors.ts +43 -3
- package/src/kernel/flow.ts +26 -5
- package/src/kernel/fx-auth-keys.ts +6 -1
- package/src/kernel/fx-auth-tenants.test.ts +87 -0
- package/src/kernel/fx-auth-tenants.ts +286 -0
- package/src/kernel/fx-live-stream.ts +149 -0
- package/src/kernel/fx-live.test.ts +157 -0
- package/src/kernel/fx-runtime.ts +15 -0
- package/src/kernel/fx-tenant-store.ts +213 -0
- package/src/kernel/fx.test.ts +91 -0
- package/src/kernel/fx.ts +173 -13
- package/src/kernel/hooks.ts +2 -2
- package/src/kernel/http-resource.ts +9 -18
- package/src/kernel/index.ts +2 -0
- package/src/kernel/journal.ts +12 -0
- package/src/kernel/live-http.test.ts +78 -0
- package/src/kernel/live-http.ts +114 -0
- package/src/kernel/live-resume.test.ts +125 -0
- package/src/kernel/on.ts +51 -0
- package/src/kernel/pipeline-tenant.ts +49 -0
- package/src/kernel/pipeline.test.ts +1 -1
- package/src/kernel/pipeline.ts +37 -2
- package/src/kernel/resource-mount.test.ts +10 -27
- package/src/kernel/tenant-resolve.test.ts +101 -0
- package/src/kernel/tenant-resolve.ts +124 -0
- package/src/kernel/tenant-roles.test.ts +87 -0
- package/src/kernel/triggers.ts +59 -21
- package/src/manifest/diff.test.ts +11 -2
- package/src/manifest/diff.ts +53 -11
- package/src/manifest/fixtures/skyport.excerpt.json +1 -1
- package/src/manifest/fixtures/skyport.manifest.json +0 -1
- package/src/manifest/types.ts +52 -6
- package/src/release/build-lib.ts +13 -1
- package/src/release/limits.ts +2 -2
- package/src/release/measure.ts +55 -1
- package/src/client/live-gap.test.ts +0 -35
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$a as t,$n as n,$r as r,Bi as i,Br as a,Cr as o,E as s,Ei as c,Er as l,F as u,Fi as d,Fo as f,Fr as p,Gr as m,Hi as h,Hr as g,Ii as _,Ir as v,Ja as y,Ji as b,Jr as x,Ka as S,L as C,Li as w,Lr as T,Mr as E,Mt as D,No as O,Oi as k,P as A,Pr as j,Qa as M,Qi as N,Qn as P,Ri as F,Sr as I,Ui as ee,Vi as L,Wi as te,Wr as R,Ya as z,Yi as B,Za as ne,Zn as V,_i as re,_r as H,a as ie,aa as ae,ar as oe,br as se,c as ce,ca as le,ci as ue,cr as de,da as fe,dr as pe,ea as me,ei as U,eo as he,er as ge,ga as _e,ha as ve,hi as ye,hr as be,i as W,ii as xe,ir as Se,ji as Ce,kr as we,l as Te,li as Ee,lr as De,ma as Oe,mr as ke,na as Ae,no as je,nr as Me,o as G,oi as Ne,or as K,pa as Pe,pi as Fe,qa as Ie,ra as Le,rr as Re,s as ze,sa as Be,si as Ve,sr as He,t as Ue,ti as We,to as Ge,tr as Ke,u as qe,ua as Je,ur as Ye,vi as Xe,vr as Ze,wi as Qe,wr as q,x as J,xi as $e,xr as et,yi as tt,zi as nt,zr as rt}from"./shortcut-keys-DKxNTe_m.js";import{t as it}from"./useMutation-B8EO02Ej.js";import{n as at,r as ot}from"./react-dom-Bph1y7z7.js";import{A as st,a as ct,c as lt,d as ut,f as dt,i as ft,l as pt,m as mt,n as ht,o as gt,p as _t,r as vt,s as yt,t as bt,u as xt}from"./xyflow-D7n4g6go.js";import{t as St}from"./link-BX6Vqztd.js";import{n as Ct,t as wt}from"./skeleton-D-czQJT6.js";import{B as Tt,G as Et,H as Dt,R as Ot,U as kt,V as At,W as jt,_ as Mt,i as Nt,k as Pt,n as Ft,t as It,z as Lt}from"./react-D8E3mtu1.js";import{a as Rt,i as zt,n as Bt,r as Vt}from"./duration-tone-sC3lGABz.js";import{r as Ht}from"./preload-helper-oH4irX4C.js";import{a as Ut,c as Wt,d as Gt,i as Kt,l as qt,n as Jt,o as Yt,r as Xt,s as Zt,t as Qt,u as $t,y as en}from"./dropdown-menu-_NjTEo5_.js";import{$ as tn,A as nn,B as rn,C as an,D as on,E as sn,F as cn,G as ln,H as un,I as dn,J as fn,K as pn,L as mn,M as hn,N as gn,O as _n,P as vn,Q as yn,R as bn,S as xn,T as Sn,U as Cn,V as wn,W as Tn,X as En,Y as Dn,Z as On,_ as kn,a as An,at as jn,b as Mn,c as Nn,ct as Pn,et as Fn,f as In,g as Ln,h as Rn,i as zn,it as Bn,j as Vn,k as Hn,l as Un,m as Wn,n as Gn,nt as Kn,o as qn,ot as Jn,q as Yn,r as Xn,rt as Zn,s as Qn,st as $n,t as er,tt as tr,u as nr,v as rr,w as ir,x as ar,y as or,z as sr}from"./tree-expand-toggle-DkOXA12R.js";import{t as cr}from"./useRender-BE2A9BWC.js";import{a as lr,i as ur}from"./shortcut-JQIZlWfm.js";import{a as dr,c as fr,d as pr,f as mr,i as hr,l as gr,n as _r,o as vr,p as yr,r as br,s as xr,t as Sr,u as Cr}from"./element-icons-BVXtRyd3.js";import{t as wr}from"./explorer-empty-2uIhBu0_.js";import{a as Tr,c as Y,d as Er,f as Dr,i as Or,l as kr,n as X,o as Ar,p as jr,r as Mr,s as Nr,t as Pr}from"./detail-header-DhHM1iaZ.js";import{n as Fr,t as Ir}from"./copy-inline-button-DBHhgHKP.js";import{a as Lr,c as Rr,i as zr,n as Br,r as Vr,s as Hr,t as Ur}from"./highlighted-json-Awq7gYdu.js";import{t as Wr}from"./agent-disclosure-BP0Y0Sux.js";import{i as Gr,n as Kr,r as qr,t as Jr}from"./collapsible-DGnOM2ph.js";import{A as Yr,B as Xr,C as Zr,D as Qr,E as $r,F as ei,H as ti,I as ni,L as ri,M as ii,N as ai,O as oi,P as si,R as ci,S as li,T as ui,V as di,_ as fi,a as pi,b as mi,c as hi,d as gi,f as _i,g as vi,h as yi,i as bi,j as xi,k as Si,l as Ci,m as wi,n as Ti,o as Ei,p as Di,r as Oi,s as ki,t as Ai,u as ji,v as Mi,w as Ni,x as Pi,y as Fi,z as Ii}from"./replica-lag-DKRrbvdo.js";import{a as Li,i as Ri,o as zi,s as Bi,t as Vi}from"./call-pii-button-ChAUiLo9.js";var Hi=e=>!e.isLayoutDirty&&e.willUpdate(!1);function Ui(){let e=new Set,t=new WeakMap,n=()=>e.forEach(Hi);return{add:r=>{e.add(r),t.set(r,r.addEventListener(`willUpdate`,n))},remove:r=>{e.delete(r);let i=t.get(r);i&&(i(),t.delete(r)),n()},dirty:n}}var Z=e(ot(),1),Wi=(0,Z.createContext)(null);function Gi(){let e=(0,Z.useRef)(!1);return Ot(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function Ki(){let e=Gi(),[t,n]=(0,Z.useState)(0),r=(0,Z.useCallback)(()=>{e.current&&n(t+1)},[t]);return[(0,Z.useCallback)(()=>Pt.postRender(r),[r]),t]}var Q=st(),qi=e=>e===!0,Ji=e=>qi(e===!0)||e===`id`,Yi=({children:e,id:t,inherit:n=!0})=>{let r=(0,Z.useContext)(Tt),i=(0,Z.useContext)(Wi),[a,o]=Ki(),s=(0,Z.useRef)(null),c=r.id||i;s.current===null&&(Ji(n)&&c&&(t=t?c+`-`+t:c),s.current={id:t,group:qi(n)&&r.group||Ui()});let l=(0,Z.useMemo)(()=>({...s.current,forceRender:a}),[o]);return(0,Q.jsx)(Tt.Provider,{value:l,children:e})};function Xi({children:e,...t}){let n=(0,Z.useContext)(Nt);t={...n,...t},t.transition=Mt(t.transition,n.transition),t.isStatic=Lt(()=>t.isStatic);let r=(0,Z.useMemo)(()=>t,[JSON.stringify(t.transition),t.transformPagePoint,t.reducedMotion,t.skipAnimations,t.isValidProp]);return(0,Q.jsx)(Nt.Provider,{value:r,children:e})}var Zi=e(at(),1);function Qi({className:e,orientation:t=`horizontal`,...n}){return(0,Q.jsx)(en,{"data-slot":`separator`,orientation:t,className:o(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,e),...n})}function $i(e){if(e.facet!==`files`)return!1;let t=e.children[0];return e.children.length===1&&t!==void 0&&t.name===e.name}function ea(e){return e===`memory`||e===`fs`||e===`s3`?e:`files`}function ta(e){switch(e){case`memory`:return`This process`;case`fs`:return`Local disk`;case`s3`:return`Object store`;default:return`Files driver`}}var na=[`sql`,`kv`,`files`,`index`];function ra(e){return na.includes(e)}var ia={sql:`SQL`,kv:`KV`,files:`Files`,index:`Index`},aa={sql:{icon:U,label:ia.sql,wellClass:`border-emerald-500/35 bg-emerald-500/10 text-emerald-700 dark:text-emerald-400`},kv:{icon:$e,label:ia.kv,wellClass:`border-amber-500/35 bg-amber-500/10 text-amber-700 dark:text-amber-400`},files:{icon:xe,label:ia.files,wellClass:`border-sky-500/35 bg-sky-500/10 text-sky-600 dark:text-sky-400`},index:{icon:ee,label:ia.index,wellClass:`border-violet-500/35 bg-violet-500/10 text-violet-700 dark:text-violet-400`}};function oa(e){return na.map(t=>({facet:t,label:ia[t],stores:e.filter(e=>e.facet===t).map(e=>({store:e,children:e.children}))})).filter(e=>e.stores.length>0)}function sa(e,t){let n=t.trim().toLowerCase();if(!n)return[...e];let r=[];for(let t of e){let e=t.name.toLowerCase().includes(n)||t.ref.toLowerCase().includes(n)||(t.description?.toLowerCase().includes(n)??!1),i=t.children.filter(t=>e||t.name.toLowerCase().includes(n)||Jn(t).toLowerCase().includes(n)||t.effectRef.toLowerCase().includes(n));(e||i.length>0)&&r.push({...t,children:e?t.children:i})}return r}function ca(e,t){for(let n of e)for(let e of n.children)if(e.effectRef===t)return{store:n,child:e};return null}function la(e){if(e.facet===`sql`)return!1;let t=e.children[0];return e.children.length===1&&t!==void 0&&t.name===e.name}function ua(e,t){return e===t?null:t}function da(e){return`facet:${e}`}function fa(e){return`${e}/tables`}function pa(e,t){let n=t[e];return n===void 0?e.startsWith(`facet:`):n}function ma(e){let t=[];for(let n of e){t.push(da(n.facet));for(let e of n.stores)la(e.store)||(t.push(e.store.ref),e.store.facet===`sql`&&t.push(fa(e.store.ref)))}return t}function ha(e,t){let n=ca(e,t);if(!n)return[];let r=[da(n.store.facet)];return la(n.store)?r:(r.push(n.store.ref),n.store.facet===`sql`&&!jn(n.child)&&r.push(fa(n.store.ref)),r)}function ga(e){for(let t of na)for(let n of e){if(n.facet!==t)continue;let e=n.children.find(e=>!jn(e));if(e)return e.effectRef}return null}var _a=`oke_store_hidden_facets`;function va(e){return Array.isArray(e)?new Set(e.filter(e=>typeof e==`string`&&ra(e))):new Set}function ya(){try{if(typeof localStorage>`u`)return new Set;let e=localStorage.getItem(_a);return e?va(JSON.parse(e)):new Set}catch{return new Set}}function ba(e){try{if(typeof localStorage>`u`)return;localStorage.setItem(_a,JSON.stringify([...e]))}catch{}}function xa(e,t){return e.filter(e=>!t.has(e.facet))}var Sa={duration:0},Ca={type:`spring`,duration:.4,bounce:.3},wa={hidden:{},show:{transition:{staggerChildren:.035,delayChildren:.05}}},Ta={hidden:{opacity:0,y:-6,filter:`blur(3px)`},show:{opacity:1,y:0,filter:`blur(0px)`}},Ea=(0,Z.createContext)(null);function Da(e){let t=(0,Z.useContext)(Ea);if(!t)throw Error(`${e} must be used within <Select>`);return t}function Oa({value:e,defaultValue:t,onValueChange:n,disabled:r=!1,className:i,children:a}){let s=Ft()??!1,c=(0,Z.useId)(),l=(0,Z.useRef)(null),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(t),[m,h]=(0,Z.useState)(()=>new Map),[g,_]=(0,Z.useState)(`bottom`),v=e!==void 0,y=v?e:f,b=(0,Z.useCallback)(e=>{v||p(e),n?.(e),d(!1)},[v,n]),x=(0,Z.useCallback)((e,t)=>{h(n=>n.get(e)===t?n:new Map(n).set(e,t))},[]),S=(0,Z.useCallback)(e=>{h(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]);(0,Z.useEffect)(()=>{if(!u)return;let e=e=>{e.key===`Escape`&&d(!1)},t=e=>{l.current&&!l.current.contains(e.target)&&d(!1)};return window.addEventListener(`keydown`,e),window.addEventListener(`pointerdown`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`pointerdown`,t)}},[u]);let C=(0,Z.useMemo)(()=>({value:y,open:u,setOpen:d,select:b,register:x,unregister:S,labelFor:e=>e===void 0?void 0:m.get(e),reduce:s,triggerId:`${c}-trigger`,listId:`${c}-list`,disabled:r,placement:g,setPlacement:_}),[y,u,b,x,S,m,s,c,r,g]);return(0,Q.jsx)(Ea.Provider,{value:C,children:(0,Q.jsx)(`div`,{ref:l,className:o(`relative`,i),"data-slot":`motion-select`,children:a})})}function ka({className:e,children:t,"aria-label":n,flat:r=!1}){let i=Da(`SelectTrigger`),a=i.placement===`top`,s=i.open?[0,0,12]:[12,0,12],c=i.reduce?{duration:0}:i.open?{duration:.6,times:[0,.4,1],ease:At}:{duration:.42,times:[0,.5,1],ease:At};return(0,Q.jsxs)(It.button,{type:`button`,id:i.triggerId,disabled:i.disabled,"aria-label":n,"aria-haspopup":`listbox`,"aria-expanded":i.open,"aria-controls":i.listId,onClick:()=>i.setOpen(!i.open),initial:!1,animate:r?{borderTopLeftRadius:0,borderTopRightRadius:0,borderBottomLeftRadius:0,borderBottomRightRadius:0}:{borderTopLeftRadius:a?s:12,borderTopRightRadius:a?s:12,borderBottomLeftRadius:a?12:s,borderBottomRightRadius:a?12:s},transition:{borderTopLeftRadius:a?c:Sa,borderTopRightRadius:a?c:Sa,borderBottomLeftRadius:a?Sa:c,borderBottomRightRadius:a?Sa:c},className:o(`relative z-10 flex w-full items-center justify-between gap-2 text-sm text-foreground outline-none transition-colors`,`disabled:pointer-events-none disabled:opacity-50`,r?`rounded-none border-0 bg-transparent px-4 py-0 shadow-none hover:bg-transparent focus-visible:ring-0`:`rounded-xl border border-border bg-background px-3 py-2 hover:border-border focus-visible:ring-2 focus-visible:ring-ring/50`,e),children:[t,(0,Q.jsx)(It.span,{"aria-hidden":!0,animate:{rotate:i.open?180:0},transition:i.reduce?{duration:0}:Ca,className:`text-muted-foreground`,children:(0,Q.jsx)(q,{icon:E,className:`size-3.5`})})]})}function Aa({placeholder:e,className:t}){let n=Da(`SelectValue`),r=n.labelFor(n.value);return(0,Q.jsx)(`span`,{className:o(r?`text-foreground`:`text-muted-foreground`,t),children:r??e??`Select`})}function ja({className:e,children:t}){let n=Da(`SelectContent`),r=(0,Z.useRef)(null),[i,a]=(0,Z.useState)(0),s=n.open,{setPlacement:c}=n;(0,Z.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=()=>a(e.offsetHeight);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()}),(0,Z.useLayoutEffect)(()=>{if(!s)return;let e=document.getElementById(n.triggerId),t=r.current;if(!e||!t)return;let i=e.getBoundingClientRect(),a=t.offsetHeight,o=window.innerHeight-i.bottom,l=i.top;c(o<a+16&&l>o?`top`:`bottom`)},[s,n.triggerId,c]);let l=n.placement===`top`,u=s?8:0,d=s?12:0,f=s?{type:`spring`,duration:.6,bounce:.5,delay:.12}:{type:`spring`,duration:.3,bounce:.1},p=s?{duration:.3,ease:At,delay:.14}:{duration:.16,ease:At};return(0,Q.jsx)(It.div,{id:n.listId,role:`listbox`,"aria-labelledby":n.triggerId,"aria-hidden":!s,inert:!s,initial:!1,animate:n.reduce?{opacity:+!!s,height:s?i:0}:{opacity:+!!s,height:s?i:0,marginTop:l?0:u,marginBottom:l?u:0,borderTopLeftRadius:l?12:d,borderTopRightRadius:l?12:d,borderBottomLeftRadius:l?d:12,borderBottomRightRadius:l?d:12},transition:n.reduce?{duration:.12}:{opacity:s?{duration:.18}:{duration:.16,delay:.12},height:s?{type:`spring`,duration:.42,bounce:.14}:{duration:.26,ease:At,delay:.14},marginTop:l?Sa:f,marginBottom:l?f:Sa,borderTopLeftRadius:l?Sa:p,borderTopRightRadius:l?Sa:p,borderBottomLeftRadius:l?p:Sa,borderBottomRightRadius:l?p:Sa},style:{transformOrigin:l?`bottom`:`top`,overflow:`hidden`,pointerEvents:s?`auto`:`none`},className:o(`absolute right-0 left-0 z-20 rounded-xl border border-border bg-background shadow-lg`,l?`bottom-full`:`top-full`,e),children:(0,Q.jsx)(It.div,{ref:r,variants:n.reduce?void 0:wa,initial:!1,animate:s?`show`:`hidden`,className:`p-1`,children:t})})}function Ma({value:e,disabled:t=!1,className:n,children:r}){let i=Da(`SelectItem`),a=i.value===e,s=typeof r==`string`?r:e,c=i.register,l=i.unregister;return(0,Z.useLayoutEffect)(()=>(c(e,s),()=>l(e)),[c,l,e,s]),(0,Q.jsx)(It.li,{variants:i.reduce?void 0:Ta,children:(0,Q.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":a,disabled:t,onClick:()=>i.select(e),className:o(`flex w-full items-center justify-between gap-2 rounded-lg px-2.5 py-1.5 text-left text-sm outline-none transition-colors`,a?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:bg-muted`,`disabled:pointer-events-none disabled:opacity-50`,n),children:[r,a?(0,Q.jsx)(q,{icon:Ae,className:`size-3.5 shrink-0`,"aria-hidden":!0}):null]})})}function Na(e){if(!e.error)return null;let t=Error(e.error.message??e.error.code);return t.code=e.error.code,t.data=e.error.data,t}function Pa(){let e=f();return it({mutationFn:async e=>{let t=await Ie(e),n=Na(t);if(n)throw n;if(!t.data)throw Error(`Empty store edit`);return t.data},onSuccess:async(t,n)=>{n.commit&&await Promise.all([e.invalidateQueries({queryKey:tr}),e.invalidateQueries({queryKey:di})])}})}function Fa(){let e=f();return it({mutationFn:async e=>{let t=await S(e),n=Na(t);if(n)throw n;if(!t.data)throw Error(`Empty store delete`);return t.data},onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:tr}),e.invalidateQueries({queryKey:di})])}})}var Ia={type:`spring`,stiffness:800,damping:80,mass:4};function La({checked:e,onCheckedChange:t,disabled:n,label:r,ariaLabel:i,className:a,size:s=`default`}){let c=(0,Z.useId)(),l=(0,Z.useRef)(null),u=Ft(),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1),h=s===`sm`;(0,Z.useEffect)(()=>{!l.current||u||n&&d&&zt(l.current,{x:[0,-2,2,-1,0]},{delay:.2,duration:.6})},[n,d,u]);let g=!n&&p&&d&&!u;return(0,Q.jsx)(Xi,{transition:u?{duration:0}:Ia,children:(0,Q.jsxs)(`span`,{className:o(`inline-flex items-center gap-2`,a),children:[(0,Q.jsx)(It.button,{id:c,type:`button`,role:`switch`,"aria-checked":e,"aria-label":i,disabled:n,onClick:()=>{n||t(!e)},onPointerDown:()=>{f(!0),m(!0)},onPointerUp:()=>f(!1),onPointerLeave:()=>f(!1),initial:!1,"data-state":e?`checked`:`unchecked`,className:o(`group peer inline-flex shrink-0 cursor-pointer items-center rounded-full outline-none transition-colors duration-200`,`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`,`disabled:cursor-not-allowed disabled:opacity-60`,h?`h-4 w-7 px-0.5`:`h-7 w-12 px-1`,e?`justify-end bg-primary`:`justify-start bg-muted-foreground/60`),children:(0,Q.jsx)(It.div,{ref:l,layout:!0,animate:{scale:g?.9:1},className:o(`pointer-events-none block rounded-full bg-background shadow-md`,h?`h-3 w-3`:`h-5 w-5`),children:(0,Q.jsx)(`div`,{className:o(h?`size-3`:`size-5`,g&&(e?`ml-1`:`mr-1`)),"aria-hidden":!0})})}),r?(0,Q.jsx)(`label`,{htmlFor:c,className:`text-sm`,children:r}):null]})})}function Ra({open:e,extraCount:t=0,onOpenChange:n,controls:r}){return(0,Q.jsxs)(jr,{active:e||t>0,extraCount:t,"aria-expanded":e,"aria-controls":r,onClick:()=>n(!e),children:[(0,Q.jsx)(q,{icon:Ee,className:`size-3`,"aria-hidden":!0}),`Advanced`]})}function za({templates:e,selectedId:t,onSelect:n}){let r=e.find(e=>e.id===t)??null;return(0,Q.jsx)(Ar,{label:`Templates`,hint:r?.detail??`Pick a starter, or fill the fields.`,children:e.map(e=>(0,Q.jsx)(Tr,{active:e.id===t,onClick:()=>n(e),children:e.title},e.id))})}var Ba=[{name:`plpgsql`,version:`1.0`,comment:`PL/pgSQL procedural language`,source:`builtin`,category:`language`},{name:`pgcrypto`,version:`1.3`,comment:`Cryptographic functions`,source:`builtin`,category:`contrib`},{name:`uuid-ossp`,version:`1.1`,comment:`UUID generation (OSSP)`,source:`builtin`,category:`contrib`},{name:`citext`,version:`1.6`,comment:`Case-insensitive text`,source:`builtin`,category:`contrib`},{name:`hstore`,version:`1.8`,comment:`Key-value store in a column`,source:`builtin`,category:`contrib`},{name:`pg_trgm`,version:`1.6`,comment:`Trigram text similarity`,source:`builtin`,category:`contrib`},{name:`btree_gin`,version:`1.3`,comment:`GIN support for common types`,source:`builtin`,category:`contrib`},{name:`btree_gist`,version:`1.7`,comment:`GiST support for common types`,source:`builtin`,category:`contrib`},{name:`unaccent`,version:`1.1`,comment:`Text search dictionary that removes accents`,source:`builtin`,category:`contrib`},{name:`ltree`,version:`1.3`,comment:`Hierarchical tree-like data type`,source:`builtin`,category:`contrib`},{name:`cube`,version:`1.5`,comment:`Multidimensional cubes`,source:`builtin`,category:`contrib`},{name:`earthdistance`,version:`1.2`,comment:`Great-circle distances on Earth`,source:`builtin`,category:`contrib`},{name:`fuzzystrmatch`,version:`1.2`,comment:`Fuzzy string matching`,source:`builtin`,category:`contrib`},{name:`intarray`,version:`1.5`,comment:`Functions for 1-D arrays of integers`,source:`builtin`,category:`contrib`},{name:`isn`,version:`1.2`,comment:`International product numbering types`,source:`builtin`,category:`contrib`},{name:`lo`,version:`1.1`,comment:`Large Object maintenance`,source:`builtin`,category:`contrib`},{name:`tablefunc`,version:`1.0`,comment:`Crosstab and table functions`,source:`builtin`,category:`contrib`},{name:`tcn`,version:`1.0`,comment:`Triggered change notifications`,source:`builtin`,category:`contrib`},{name:`tsm_system_rows`,version:`1.0`,comment:`TABLESAMPLE method SYSTEM_ROWS`,source:`builtin`,category:`contrib`},{name:`tsm_system_time`,version:`1.0`,comment:`TABLESAMPLE method SYSTEM_TIME`,source:`builtin`,category:`contrib`},{name:`xml2`,version:`1.1`,comment:`XPath querying and XSLT`,source:`builtin`,category:`contrib`},{name:`postgres_fdw`,version:`1.1`,comment:`Foreign-data wrapper for PostgreSQL`,source:`builtin`,category:`contrib`},{name:`file_fdw`,version:`1.0`,comment:`Foreign-data wrapper for files`,source:`builtin`,category:`contrib`},{name:`dblink`,version:`1.2`,comment:`Connect to other PostgreSQL databases`,source:`builtin`,category:`contrib`},{name:`amcheck`,version:`1.4`,comment:`Verify relation integrity`,source:`builtin`,category:`contrib`},{name:`bloom`,version:`1.0`,comment:`Bloom-filter index access method`,source:`builtin`,category:`contrib`},{name:`dict_int`,version:`1.0`,comment:`Text search dictionary for integers`,source:`builtin`,category:`contrib`},{name:`dict_xsyn`,version:`1.0`,comment:`Text search dictionary for extended synonym`,source:`builtin`,category:`contrib`},{name:`pageinspect`,version:`1.12`,comment:`Inspect contents of database pages`,source:`builtin`,category:`contrib`},{name:`pg_buffercache`,version:`1.5`,comment:`Examine shared buffer cache`,source:`builtin`,category:`contrib`},{name:`pg_freespacemap`,version:`1.2`,comment:`Examine the free space map`,source:`builtin`,category:`contrib`},{name:`pg_prewarm`,version:`1.2`,comment:`Prewarm relation data`,source:`builtin`,category:`contrib`},{name:`pg_stat_statements`,version:`1.11`,comment:`Track planning and execution statistics`,source:`builtin`,category:`contrib`},{name:`pg_surgery`,version:`1.0`,comment:`Low-level heap surgery`,source:`builtin`,category:`contrib`},{name:`pg_visibility`,version:`1.2`,comment:`Examine visibility map`,source:`builtin`,category:`contrib`},{name:`pgrowlocks`,version:`1.2`,comment:`Show row-level locking information`,source:`builtin`,category:`contrib`},{name:`pgstattuple`,version:`1.5`,comment:`Tuple-level statistics`,source:`builtin`,category:`contrib`},{name:`sslinfo`,version:`1.2`,comment:`Information about SSL certificates`,source:`builtin`,category:`contrib`},{name:`vector`,version:`0.8.6`,comment:`Vector similarity search (pgvector)`,source:`builtin`,category:`search`}];function $(e,t,n,r,i,a){return{name:e,version:t,comment:n,source:`library`,category:r,tags:i,...a&&a.length>0?{requires:a}:{}}}var Va=[$(`timescaledb`,`2.17.0`,`Time-series hypertables, compression, and continuous aggregates`,`time`,[`timescale`,`hypertable`,`iot`,`metrics`]),$(`timescaledb_toolkit`,`1.19.0`,`Timescale hyperfunctions — locf, gapfill, stats`,`time`,[`timescale`,`hyperfunctions`,`analytics`],[`timescaledb`]),$(`pg_partman`,`5.2.0`,`Partition maintenance for time- and serial-based tables`,`time`,[`partition`,`retention`]),$(`pg_ivm`,`1.9`,`Incremental view maintenance for materialized views`,`time`,[`materialized`,`ivm`,`refresh`]),$(`temporal_tables`,`1.2.2`,`System-period temporal tables (SQL:2011 style)`,`time`,[`history`,`versioning`,`audit`]),$(`pg_cron`,`1.6`,`Cron-based job scheduler inside the database`,`jobs`,[`cron`,`schedule`,`jobs`]),$(`pg_later`,`0.3.0`,`Fire-and-forget SQL jobs after the current transaction`,`jobs`,[`async`,`queue`,`later`]),$(`pg_background`,`1.2`,`Run commands in a background worker`,`jobs`,[`worker`,`background`]),$(`postgis`,`3.5.0`,`Geographic objects and spatial indexes`,`geo`,[`gis`,`geo`,`geometry`,`geography`,`spatial`]),$(`postgis_topology`,`3.5.0`,`PostGIS topology types and functions`,`geo`,[`gis`,`topology`],[`postgis`]),$(`postgis_raster`,`3.5.0`,`PostGIS raster types and functions`,`geo`,[`gis`,`raster`,`coverage`],[`postgis`]),$(`postgis_sfcgal`,`3.5.0`,`3D / solid geometry via SFCGAL`,`geo`,[`gis`,`3d`,`sfcgal`],[`postgis`]),$(`address_standardizer`,`3.5.0`,`Parse and normalize street addresses`,`geo`,[`gis`,`geocode`,`address`]),$(`postgis_tiger_geocoder`,`3.5.0`,`TIGER geocoder for US addresses`,`geo`,[`gis`,`geocode`,`tiger`],[`postgis`,`address_standardizer`]),$(`pgrouting`,`3.7.0`,`Routing algorithms on PostGIS networks`,`geo`,[`gis`,`routing`,`shortest-path`],[`postgis`]),$(`h3`,`4.1.0`,`Uber H3 hexagonal hierarchical spatial index`,`geo`,[`gis`,`hex`,`uber`]),$(`mobilitydb`,`1.2.0`,`Temporal and spatiotemporal types for moving objects`,`geo`,[`gis`,`trajectory`,`temporal`],[`postgis`]),$(`pointcloud`,`1.2.5`,`LIDAR / point-cloud storage (PDAL)`,`geo`,[`gis`,`lidar`,`pdal`]),$(`rum`,`1.3`,`GIN-like access method for faster full-text search`,`search`,[`fts`,`full-text`,`gin`]),$(`pg_search`,`0.15.0`,`ParadeDB BM25 full-text search`,`search`,[`paradedb`,`bm25`,`fts`]),$(`pgroonga`,`3.2.5`,`Groonga full-text search (CJK-friendly)`,`search`,[`fts`,`cjk`,`japanese`]),$(`pg_bigm`,`1.2`,`Bigram full-text search (LIKE acceleration)`,`search`,[`fts`,`bigram`,`like`]),$(`zhparser`,`2.2`,`Chinese text search parser`,`search`,[`fts`,`chinese`,`cjk`]),$(`zombodb`,`3000.2.7`,`Elasticsearch-backed indexes from Postgres`,`search`,[`elasticsearch`,`fts`]),$(`vchord`,`0.4.3`,`VectorChord — disk-based vector index`,`search`,[`vector`,`embedding`,`ann`]),$(`vectorscale`,`0.7.1`,`Timescale vector index (StreamingDiskANN)`,`search`,[`vector`,`timescale`,`ann`]),$(`age`,`1.5.0`,`Apache AGE graph queries (openCypher)`,`graph`,[`graph`,`cypher`,`opencypher`]),$(`citus`,`12.1`,`Distributed Postgres — shard and scale out`,`scale`,[`shard`,`distributed`,`microsoft`]),$(`citus_columnar`,`12.1`,`Citus columnar storage for analytics`,`scale`,[`columnar`,`olap`,`citus`],[`citus`]),$(`pg_repack`,`1.5.1`,`Online table bloat cleanup without exclusive locks`,`scale`,[`bloat`,`vacuum`,`reindex`]),$(`pg_squeeze`,`1.8`,`Automatic bloat cleanup as a background worker`,`scale`,[`bloat`,`vacuum`]),$(`hypopg`,`1.4.1`,`Hypothetical indexes for EXPLAIN without creating them`,`scale`,[`explain`,`index`,`what-if`]),$(`index_advisor`,`0.2.0`,`Suggest indexes from a query via hypothetical indexes`,`scale`,[`index`,`advisor`,`hypopg`],[`hypopg`]),$(`pg_hint_plan`,`1.7.0`,`Planner hints in SQL comments`,`scale`,[`planner`,`hint`,`explain`]),$(`pg_stat_kcache`,`2.3.0`,`Filesystem and CPU stats per query`,`scale`,[`stats`,`observability`]),$(`pg_qualstats`,`2.1.1`,`Predicate statistics for missing-index hints`,`scale`,[`stats`,`index`]),$(`pg_wait_sampling`,`1.1.6`,`Sample wait events for lock analysis`,`scale`,[`waits`,`locks`,`observability`]),$(`pg_stat_monitor`,`2.1.0`,`Percona query-performance monitor`,`scale`,[`stats`,`percona`,`observability`]),$(`pgaudit`,`17.0`,`Session and object audit logging`,`security`,[`audit`,`compliance`,`logging`]),$(`pgsodium`,`3.1.9`,`Libsodium cryptography helpers`,`security`,[`crypto`,`encryption`,`libsodium`]),$(`pgjwt`,`0.2.0`,`Create and verify JSON Web Tokens in SQL`,`security`,[`jwt`,`auth`,`token`]),$(`anon`,`2.1.0`,`PostgreSQL Anonymizer — masking and dumping`,`security`,[`pii`,`mask`,`gdpr`,`anonymizer`]),$(`credcheck`,`2.8`,`Password complexity and reuse checks`,`security`,[`password`,`auth`]),$(`set_user`,`4.1.0`,`Privilege bridging with audit trail`,`security`,[`sudo`,`privilege`,`audit`]),$(`pg_tle`,`1.5.0`,`Trusted Language Extensions (AWS)`,`security`,[`tle`,`aws`,`sandbox`]),$(`pg_net`,`0.14.0`,`Async HTTP from SQL (Supabase)`,`http`,[`http`,`webhook`,`supabase`]),$(`http`,`1.6`,`Synchronous HTTP client from SQL`,`http`,[`http`,`rest`,`curl`]),$(`wrappers`,`0.4.5`,`Supabase FDW framework (Stripe, Firebase, S3…)`,`http`,[`fdw`,`supabase`,`stripe`]),$(`pg_graphql`,`1.5.11`,`GraphQL API generated from the schema`,`http`,[`graphql`,`api`,`supabase`]),$(`pgmq`,`1.5.1`,`Lightweight message queue in Postgres`,`http`,[`queue`,`mq`,`jobs`]),$(`pg_jsonschema`,`0.3.3`,`Validate JSON against JSON Schema`,`http`,[`json`,`schema`,`validate`]),$(`mysql_fdw`,`1.2`,`Foreign-data wrapper for MySQL / MariaDB`,`fdw`,[`mysql`,`mariadb`,`fdw`]),$(`mongo_fdw`,`5.5.2`,`Foreign-data wrapper for MongoDB`,`fdw`,[`mongodb`,`fdw`]),$(`tds_fdw`,`2.0.4`,`Foreign-data wrapper for SQL Server / Sybase`,`fdw`,[`mssql`,`sqlserver`,`fdw`]),$(`oracle_fdw`,`2.7.0`,`Foreign-data wrapper for Oracle`,`fdw`,[`oracle`,`fdw`]),$(`sqlite_fdw`,`2.5.0`,`Foreign-data wrapper for SQLite`,`fdw`,[`sqlite`,`fdw`]),$(`redis_fdw`,`1.0`,`Foreign-data wrapper for Redis`,`fdw`,[`redis`,`fdw`]),$(`duckdb_fdw`,`1.1.0`,`Foreign-data wrapper for DuckDB`,`fdw`,[`duckdb`,`olap`,`fdw`]),$(`pg_duckdb`,`0.3.0`,`DuckDB engine inside Postgres`,`fdw`,[`duckdb`,`olap`,`analytics`]),$(`ogr_fdw`,`1.1.5`,`GDAL/OGR spatial foreign tables`,`fdw`,[`gis`,`gdal`,`shapefile`,`fdw`]),$(`plpython3u`,`1.0`,`Untrusted Python 3 procedural language`,`lang`,[`python`,`pl`]),$(`plperl`,`1.0`,`Perl procedural language`,`lang`,[`perl`,`pl`]),$(`pltcl`,`1.0`,`Tcl procedural language`,`lang`,[`tcl`,`pl`]),$(`plv8`,`3.2.3`,`JavaScript (V8) procedural language`,`lang`,[`javascript`,`v8`,`pl`]),$(`plrust`,`1.2.8`,`Trusted Rust procedural language`,`lang`,[`rust`,`pl`]),$(`plpgsql_check`,`2.7.15`,`Static analysis for PL/pgSQL functions`,`lang`,[`lint`,`plpgsql`]),$(`hll`,`2.18`,`HyperLogLog distinct-count sketches`,`analytics`,[`cardinality`,`sketch`,`approx`]),$(`tdigest`,`1.4.2`,`t-digest quantiles and percentiles`,`analytics`,[`quantile`,`percentile`,`sketch`]),$(`topn`,`2.7.0`,`Approximate most-frequent values`,`analytics`,[`topk`,`sketch`,`timescale`]),$(`datasketches`,`1.7.0`,`Apache DataSketches — HLL, Theta, KLL`,`analytics`,[`sketch`,`apache`,`approx`]),$(`pg_uuidv7`,`1.6.0`,`UUIDv7 generators (time-ordered)`,`analytics`,[`uuid`,`id`]),$(`pg_idkit`,`0.2.4`,`UUID, ULID, KSUID, TypeID generators`,`analytics`,[`uuid`,`ulid`,`ksuid`]),$(`pg_hashids`,`1.3.0`,`YouTube-style hashids from integers`,`analytics`,[`hashid`,`shortid`])];[...Ba,...Va];function Ha(e){return/^[0-9]+(\.[0-9]+)*$/.test(e)}var Ua={plpgsql:`PL/pgSQL`,pgcrypto:`Crypto`,"uuid-ossp":`UUID OSSP`,citext:`CIText`,hstore:`Hstore`,pg_trgm:`Trigram`,btree_gin:`B-tree GIN`,btree_gist:`B-tree GiST`,unaccent:`Unaccent`,ltree:`Ltree`,cube:`Cube`,earthdistance:`Earth Distance`,fuzzystrmatch:`Fuzzy Match`,intarray:`Intarray`,isn:`ISN`,lo:`Large Objects`,tablefunc:`Tablefunc`,tcn:`TCN`,tsm_system_rows:`System Rows`,tsm_system_time:`System Time`,xml2:`XML2`,postgres_fdw:`Postgres FDW`,file_fdw:`File FDW`,dblink:`DB Link`,amcheck:`AM Check`,bloom:`Bloom`,dict_int:`Dict Int`,dict_xsyn:`Dict Xsyn`,pageinspect:`Page Inspect`,pg_buffercache:`Buffer Cache`,pg_freespacemap:`Free Space Map`,pg_prewarm:`Prewarm`,pg_stat_statements:`Stat Statements`,pg_surgery:`Surgery`,pg_visibility:`Visibility`,pgrowlocks:`Row Locks`,pgstattuple:`Stat Tuple`,sslinfo:`SSL Info`,vector:`pgvector`,timescaledb:`Timescale`,timescaledb_toolkit:`Timescale Toolkit`,pg_partman:`Partman`,pg_ivm:`IVM`,temporal_tables:`Temporal Tables`,pg_cron:`Cron`,pg_later:`Later`,pg_background:`Background`,postgis:`PostGIS`,postgis_topology:`PostGIS Topology`,postgis_raster:`PostGIS Raster`,postgis_sfcgal:`PostGIS SFCGAL`,address_standardizer:`Address Standardizer`,postgis_tiger_geocoder:`PostGIS Tiger Geocoder`,pgrouting:`pgRouting`,h3:`H3`,mobilitydb:`MobilityDB`,pointcloud:`Pointcloud`,rum:`RUM`,pg_search:`ParadeDB Search`,pgroonga:`PGroonga`,pg_bigm:`Bigm`,zhparser:`Zhparser`,zombodb:`ZomboDB`,vchord:`VectorChord`,vectorscale:`Vectorscale`,age:`Apache AGE`,citus:`Citus`,citus_columnar:`Citus Columnar`,pg_repack:`Repack`,pg_squeeze:`Squeeze`,hypopg:`HypoPG`,index_advisor:`Index Advisor`,pg_hint_plan:`Hint Plan`,pg_stat_kcache:`Stat Kcache`,pg_qualstats:`Qualstats`,pg_wait_sampling:`Wait Sampling`,pg_stat_monitor:`Stat Monitor`,pgaudit:`pgAudit`,pgsodium:`Sodium`,pgjwt:`JWT`,anon:`Anonymizer`,credcheck:`Credcheck`,set_user:`Set User`,pg_tle:`TLE`,pg_net:`Net`,http:`HTTP`,wrappers:`Wrappers`,pg_graphql:`GraphQL`,pgmq:`Queues`,pg_jsonschema:`JSON Schema`,mysql_fdw:`MySQL FDW`,mongo_fdw:`MongoDB FDW`,tds_fdw:`TDS FDW`,oracle_fdw:`Oracle FDW`,sqlite_fdw:`SQLite FDW`,redis_fdw:`Redis FDW`,duckdb_fdw:`DuckDB FDW`,pg_duckdb:`DuckDB`,ogr_fdw:`OGR FDW`,plpython3u:`PL/Python 3`,plperl:`PL/Perl`,pltcl:`PL/Tcl`,plv8:`PL/V8`,plrust:`PL/Rust`,plpgsql_check:`PL/pgSQL Check`,hll:`HyperLogLog`,tdigest:`t-digest`,topn:`TopN`,datasketches:`DataSketches`,pg_uuidv7:`UUIDv7`,pg_idkit:`IDkit`,pg_hashids:`Hashids`},Wa={fdw:`FDW`,jwt:`JWT`,http:`HTTP`,ivm:`IVM`,tle:`TLE`,hll:`HLL`,age:`AGE`,rum:`RUM`,h3:`H3`,postgis:`PostGIS`,duckdb:`DuckDB`,gin:`GIN`,gist:`GiST`};function Ga(e){return Ua[e]||e.replace(/^pg_/,``).split(/[_-]+/).filter(e=>e.length>0).map(e=>Wa[e]??e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var Ka=`https://www.postgresql.org/docs/current`,qa={plpgsql:`plpgsql`,pgcrypto:`pgcrypto`,"uuid-ossp":`uuid-ossp`,citext:`citext`,hstore:`hstore`,pg_trgm:`pgtrgm`,btree_gin:`btree-gin`,btree_gist:`btree-gist`,unaccent:`unaccent`,ltree:`ltree`,cube:`cube`,earthdistance:`earthdistance`,fuzzystrmatch:`fuzzystrmatch`,intarray:`intarray`,isn:`isn`,lo:`lo`,tablefunc:`tablefunc`,tcn:`tcn`,tsm_system_rows:`tsm-system-rows`,tsm_system_time:`tsm-system-time`,xml2:`xml2`,postgres_fdw:`postgres-fdw`,file_fdw:`file-fdw`,dblink:`dblink`,amcheck:`amcheck`,bloom:`bloom`,dict_int:`dict-int`,dict_xsyn:`dict-xsyn`,pageinspect:`pageinspect`,pg_buffercache:`pgbuffercache`,pg_freespacemap:`pgfreespacemap`,pg_prewarm:`pgprewarm`,pg_stat_statements:`pgstatstatements`,pg_surgery:`pgsurgery`,pg_visibility:`pgvisibility`,pgrowlocks:`pgrowlocks`,pgstattuple:`pgstattuple`,sslinfo:`sslinfo`,plpython3u:`plpython`,plperl:`plperl`,pltcl:`pltcl`},Ja={vector:`https://github.com/pgvector/pgvector`,timescaledb:`https://github.com/timescale/timescaledb`,timescaledb_toolkit:`https://github.com/timescale/timescaledb-toolkit`,pg_partman:`https://github.com/pgpartman/pg_partman`,pg_ivm:`https://github.com/sraoss/pg_ivm`,temporal_tables:`https://github.com/arkhipov/temporal_tables`,pg_cron:`https://github.com/citusdata/pg_cron`,pg_later:`https://github.com/supabase/pg_later`,pg_background:`https://github.com/vibhorkum/pg_background`,postgis:`https://postgis.net`,postgis_topology:`https://postgis.net/docs/Topology.html`,postgis_raster:`https://postgis.net/docs/RT_reference.html`,postgis_sfcgal:`https://postgis.net/docs/reference.html#reference_sfcgal`,address_standardizer:`https://postgis.net/docs/manual-dev/Address_Standardizer.html`,postgis_tiger_geocoder:`https://postgis.net/docs/Extras.html#Tiger_Geocoder`,pgrouting:`https://pgrouting.org`,h3:`https://github.com/zachasme/h3-pg`,mobilitydb:`https://github.com/MobilityDB/MobilityDB`,pointcloud:`https://github.com/pgpointcloud/pointcloud`,rum:`https://github.com/postgrespro/rum`,pg_search:`https://github.com/paradedb/paradedb`,pgroonga:`https://pgroonga.github.io`,pg_bigm:`https://github.com/pgbigm/pg_bigm`,zhparser:`https://github.com/amutu/zhparser`,zombodb:`https://github.com/zombodb/zombodb`,vchord:`https://github.com/tensorchord/VectorChord`,vectorscale:`https://github.com/timescale/pgvectorscale`,age:`https://age.apache.org`,citus:`https://github.com/citusdata/citus`,citus_columnar:`https://github.com/citusdata/citus`,pg_repack:`https://github.com/reorg/pg_repack`,pg_squeeze:`https://github.com/cybertec-postgresql/pg_squeeze`,hypopg:`https://github.com/HypoPG/hypopg`,index_advisor:`https://github.com/supabase/index_advisor`,pg_hint_plan:`https://github.com/ossc-db/pg_hint_plan`,pg_stat_kcache:`https://github.com/powa-team/pg_stat_kcache`,pg_qualstats:`https://github.com/powa-team/pg_qualstats`,pg_wait_sampling:`https://github.com/postgrespro/pg_wait_sampling`,pg_stat_monitor:`https://github.com/percona/pg_stat_monitor`,pgaudit:`https://github.com/pgaudit/pgaudit`,pgsodium:`https://github.com/michelp/pgsodium`,pgjwt:`https://github.com/michelp/pgjwt`,anon:`https://postgresql-anonymizer.readthedocs.io`,credcheck:`https://github.com/HexaCluster/credcheck`,set_user:`https://github.com/pgaudit/set_user`,pg_tle:`https://github.com/aws/pg_tle`,pg_net:`https://github.com/supabase/pg_net`,http:`https://github.com/pramsey/pgsql-http`,wrappers:`https://github.com/supabase/wrappers`,pg_graphql:`https://github.com/supabase/pg_graphql`,pgmq:`https://github.com/pgmq/pgmq`,pg_jsonschema:`https://github.com/supabase/pg_jsonschema`,mysql_fdw:`https://github.com/enterprisedb/mysql_fdw`,mongo_fdw:`https://github.com/enterprisedb/mongo_fdw`,tds_fdw:`https://github.com/tds-fdw/tds_fdw`,oracle_fdw:`https://github.com/laurenz/oracle_fdw`,sqlite_fdw:`https://github.com/pgspider/sqlite_fdw`,redis_fdw:`https://github.com/pg-redis-fdw/redis_fdw`,duckdb_fdw:`https://github.com/alitrack/duckdb_fdw`,pg_duckdb:`https://github.com/duckdb/pg_duckdb`,ogr_fdw:`https://github.com/pramsey/pgsql-ogr-fdw`,plv8:`https://github.com/plv8/plv8`,plrust:`https://github.com/tcdi/plrust`,plpgsql_check:`https://github.com/okbob/plpgsql_check`,hll:`https://github.com/citusdata/postgresql-hll`,tdigest:`https://github.com/tvondra/tdigest`,topn:`https://github.com/timescale/pg_topn`,datasketches:`https://github.com/apache/datasketches-postgresql`,pg_uuidv7:`https://github.com/fboulnois/pg_uuidv7`,pg_idkit:`https://github.com/gaeljw/pg_idkit`,pg_hashids:`https://github.com/iCyberon/pg_hashids`};function Ya(e){let t=Ja[e];if(t)return t;let n=qa[e];return n?`${Ka}/${n}.html`:null}var Xa={language:`Language`,contrib:`Contrib`,time:`Time series`,geo:`Geospatial`,jobs:`Jobs`,search:`Search`,graph:`Graph`,scale:`Scale`,security:`Security`,http:`HTTP`,fdw:`Foreign data`,lang:`Languages`,analytics:`Analytics`};function Za(e){return`"${e.replaceAll(`"`,``)}"`}var Qa=Ga,$a=[`timescaledb`,`pg_cron`,`postgis`],eo={timescaledb:`Timescale`,timescaledb_toolkit:`Timescale`,vectorscale:`Timescale`,topn:`Timescale`,pg_cron:`Citus Data`,citus:`Microsoft`,citus_columnar:`Microsoft`,postgis:`PostGIS Project`,postgis_topology:`PostGIS Project`,postgis_raster:`PostGIS Project`,postgis_sfcgal:`PostGIS Project`,postgis_tiger_geocoder:`PostGIS Project`,pgrouting:`pgRouting`,pg_search:`ParadeDB`,pgmq:`pgmq`,pg_net:`Supabase`,index_advisor:`Supabase`,wrappers:`Supabase`,pg_graphql:`Supabase`,age:`Apache`,datasketches:`Apache`,pg_duckdb:`DuckDB`,duckdb_fdw:`DuckDB`,anon:`PostgreSQL Anonymizer`,pg_stat_monitor:`Percona`};function to(e){return eo[e]}function no(e){let t=new Map(e.map(e=>[e.name,e]));return $a.flatMap(e=>{let n=t.get(e);return n?[n]:[]})}var ro=[`time`,`jobs`,`geo`,`search`,`graph`,`scale`,`security`,`http`,`fdw`,`lang`,`analytics`];function io(e){return[e.name,Qa(e.name),e.comment,e.category,Xa[e.category],...e.tags??[],...e.requires??[]].join(` `).toLowerCase()}function ao(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(e=>e.length>0);return n.length===0?e:e.filter(e=>{let t=io(e);return n.every(e=>t.includes(e))})}function oo(e){return ro.flatMap(t=>{let n=e.filter(e=>e.category===t);return n.length===0?[]:[{category:t,label:Xa[t],items:n}]})}var so={pg_cron:`After install, schedule jobs with cron.schedule(). HTTP job types need pg_net.`,timescaledb:`After install, convert time-series tables with create_hypertable().`,timescaledb_toolkit:`Hyperfunctions on top of Timescale — needs timescaledb first.`,postgis:`Adds geometry / geography types and spatial indexes.`,pg_net:`Lets SQL send async HTTP. Required for webhook-style cron jobs.`,pgmq:`Lightweight queue tables in Postgres. Pair with pg_cron to drain jobs.`,pg_graphql:`Exposes a GraphQL schema from your tables.`};function co(e,t){let n=[`CREATE EXTENSION IF NOT EXISTS ${Za(e)}`],r=[],i=t?.schema?.trim()??``;i!==``&&lo(i)&&r.push(`SCHEMA ${fn(i)}`);let a=t?.version?.trim()??``;return a!==``&&Ha(a)&&r.push(`VERSION '${a}'`),t?.cascade===!0&&r.push(`CASCADE`),r.length>0&&n.push(`WITH ${r.join(` `)}`),`${n.join(` `)};`}function lo(e){let t=e.trim();return pn(t)&&t.toLowerCase()!==`pg_catalog`}function uo(e){return+!!e.schema?.trim()+ +!!e.version?.trim()+ +(e.cascade===!0)}function fo(e,t,n){let r=[...e.requires??[],e.name].map(e=>({name:e,title:Qa(e),already:t.has(e)})),i=r.filter(e=>!e.already),a=i.length>0?i.map(t=>co(t.name,t.name===e.name?n:void 0)).join(`
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$a as t,$n as n,$r as r,Bi as i,Br as a,Cr as o,E as s,Ei as c,Er as l,F as u,Fi as d,Fo as f,Fr as p,Gr as m,Hi as h,Hr as g,Ii as _,Ir as v,Ja as y,Ji as b,Jr as x,Ka as S,L as C,Li as w,Lr as T,Mr as E,Mt as D,No as O,Oi as k,P as A,Pr as j,Qa as M,Qi as N,Qn as P,Ri as F,Sr as I,Ui as ee,Vi as L,Wi as te,Wr as R,Ya as z,Yi as B,Za as ne,Zn as V,_i as re,_r as H,a as ie,aa as ae,ar as oe,br as se,c as ce,ca as le,ci as ue,cr as de,da as fe,dr as pe,ea as me,ei as U,eo as he,er as ge,ga as _e,ha as ve,hi as ye,hr as be,i as W,ii as xe,ir as Se,ji as Ce,kr as we,l as Te,li as Ee,lr as De,ma as Oe,mr as ke,na as Ae,no as je,nr as Me,o as G,oi as Ne,or as K,pa as Pe,pi as Fe,qa as Ie,ra as Le,rr as Re,s as ze,sa as Be,si as Ve,sr as He,t as Ue,ti as We,to as Ge,tr as Ke,u as qe,ua as Je,ur as Ye,vi as Xe,vr as Ze,wi as Qe,wr as q,x as J,xi as $e,xr as et,yi as tt,zi as nt,zr as rt}from"./shortcut-keys-DKxNTe_m.js";import{t as it}from"./useMutation-B8EO02Ej.js";import{n as at,r as ot}from"./react-dom-Bph1y7z7.js";import{A as st,a as ct,c as lt,d as ut,f as dt,i as ft,l as pt,m as mt,n as ht,o as gt,p as _t,r as vt,s as yt,t as bt,u as xt}from"./xyflow-D7n4g6go.js";import{t as St}from"./link-BX6Vqztd.js";import{n as Ct,t as wt}from"./skeleton-D-czQJT6.js";import{B as Tt,G as Et,H as Dt,R as Ot,U as kt,V as At,W as jt,_ as Mt,i as Nt,k as Pt,n as Ft,t as It,z as Lt}from"./react-D8E3mtu1.js";import{a as Rt,i as zt,n as Bt,r as Vt}from"./duration-tone-sC3lGABz.js";import{r as Ht}from"./preload-helper-oH4irX4C.js";import{a as Ut,c as Wt,d as Gt,i as Kt,l as qt,n as Jt,o as Yt,r as Xt,s as Zt,t as Qt,u as $t,y as en}from"./dropdown-menu-_NjTEo5_.js";import{$ as tn,A as nn,B as rn,C as an,D as on,E as sn,F as cn,G as ln,H as un,I as dn,J as fn,K as pn,L as mn,M as hn,N as gn,O as _n,P as vn,Q as yn,R as bn,S as xn,T as Sn,U as Cn,V as wn,W as Tn,X as En,Y as Dn,Z as On,_ as kn,a as An,at as jn,b as Mn,c as Nn,ct as Pn,et as Fn,f as In,g as Ln,h as Rn,i as zn,it as Bn,j as Vn,k as Hn,l as Un,m as Wn,n as Gn,nt as Kn,o as qn,ot as Jn,q as Yn,r as Xn,rt as Zn,s as Qn,st as $n,t as er,tt as tr,u as nr,v as rr,w as ir,x as ar,y as or,z as sr}from"./tree-expand-toggle-BtyhmWb4.js";import{t as cr}from"./useRender-BE2A9BWC.js";import{a as lr,i as ur}from"./shortcut-JQIZlWfm.js";import{a as dr,c as fr,d as pr,f as mr,i as hr,l as gr,n as _r,o as vr,p as yr,r as br,s as xr,t as Sr,u as Cr}from"./element-icons-BVXtRyd3.js";import{t as wr}from"./explorer-empty-2uIhBu0_.js";import{a as Tr,c as Y,d as Er,f as Dr,i as Or,l as kr,n as X,o as Ar,p as jr,r as Mr,s as Nr,t as Pr}from"./detail-header-DhHM1iaZ.js";import{n as Fr,t as Ir}from"./copy-inline-button-DBHhgHKP.js";import{a as Lr,c as Rr,i as zr,n as Br,r as Vr,s as Hr,t as Ur}from"./highlighted-json-Awq7gYdu.js";import{t as Wr}from"./agent-disclosure-BP0Y0Sux.js";import{i as Gr,n as Kr,r as qr,t as Jr}from"./collapsible-DGnOM2ph.js";import{A as Yr,B as Xr,C as Zr,D as Qr,E as $r,F as ei,H as ti,I as ni,L as ri,M as ii,N as ai,O as oi,P as si,R as ci,S as li,T as ui,V as di,_ as fi,a as pi,b as mi,c as hi,d as gi,f as _i,g as vi,h as yi,i as bi,j as xi,k as Si,l as Ci,m as wi,n as Ti,o as Ei,p as Di,r as Oi,s as ki,t as Ai,u as ji,v as Mi,w as Ni,x as Pi,y as Fi,z as Ii}from"./replica-lag-DKRrbvdo.js";import{a as Li,i as Ri,o as zi,s as Bi,t as Vi}from"./call-pii-button-ChAUiLo9.js";var Hi=e=>!e.isLayoutDirty&&e.willUpdate(!1);function Ui(){let e=new Set,t=new WeakMap,n=()=>e.forEach(Hi);return{add:r=>{e.add(r),t.set(r,r.addEventListener(`willUpdate`,n))},remove:r=>{e.delete(r);let i=t.get(r);i&&(i(),t.delete(r)),n()},dirty:n}}var Z=e(ot(),1),Wi=(0,Z.createContext)(null);function Gi(){let e=(0,Z.useRef)(!1);return Ot(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function Ki(){let e=Gi(),[t,n]=(0,Z.useState)(0),r=(0,Z.useCallback)(()=>{e.current&&n(t+1)},[t]);return[(0,Z.useCallback)(()=>Pt.postRender(r),[r]),t]}var Q=st(),qi=e=>e===!0,Ji=e=>qi(e===!0)||e===`id`,Yi=({children:e,id:t,inherit:n=!0})=>{let r=(0,Z.useContext)(Tt),i=(0,Z.useContext)(Wi),[a,o]=Ki(),s=(0,Z.useRef)(null),c=r.id||i;s.current===null&&(Ji(n)&&c&&(t=t?c+`-`+t:c),s.current={id:t,group:qi(n)&&r.group||Ui()});let l=(0,Z.useMemo)(()=>({...s.current,forceRender:a}),[o]);return(0,Q.jsx)(Tt.Provider,{value:l,children:e})};function Xi({children:e,...t}){let n=(0,Z.useContext)(Nt);t={...n,...t},t.transition=Mt(t.transition,n.transition),t.isStatic=Lt(()=>t.isStatic);let r=(0,Z.useMemo)(()=>t,[JSON.stringify(t.transition),t.transformPagePoint,t.reducedMotion,t.skipAnimations,t.isValidProp]);return(0,Q.jsx)(Nt.Provider,{value:r,children:e})}var Zi=e(at(),1);function Qi({className:e,orientation:t=`horizontal`,...n}){return(0,Q.jsx)(en,{"data-slot":`separator`,orientation:t,className:o(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,e),...n})}function $i(e){if(e.facet!==`files`)return!1;let t=e.children[0];return e.children.length===1&&t!==void 0&&t.name===e.name}function ea(e){return e===`memory`||e===`fs`||e===`s3`?e:`files`}function ta(e){switch(e){case`memory`:return`This process`;case`fs`:return`Local disk`;case`s3`:return`Object store`;default:return`Files driver`}}var na=[`sql`,`kv`,`files`,`index`];function ra(e){return na.includes(e)}var ia={sql:`SQL`,kv:`KV`,files:`Files`,index:`Index`},aa={sql:{icon:U,label:ia.sql,wellClass:`border-emerald-500/35 bg-emerald-500/10 text-emerald-700 dark:text-emerald-400`},kv:{icon:$e,label:ia.kv,wellClass:`border-amber-500/35 bg-amber-500/10 text-amber-700 dark:text-amber-400`},files:{icon:xe,label:ia.files,wellClass:`border-sky-500/35 bg-sky-500/10 text-sky-600 dark:text-sky-400`},index:{icon:ee,label:ia.index,wellClass:`border-violet-500/35 bg-violet-500/10 text-violet-700 dark:text-violet-400`}};function oa(e){return na.map(t=>({facet:t,label:ia[t],stores:e.filter(e=>e.facet===t).map(e=>({store:e,children:e.children}))})).filter(e=>e.stores.length>0)}function sa(e,t){let n=t.trim().toLowerCase();if(!n)return[...e];let r=[];for(let t of e){let e=t.name.toLowerCase().includes(n)||t.ref.toLowerCase().includes(n)||(t.description?.toLowerCase().includes(n)??!1),i=t.children.filter(t=>e||t.name.toLowerCase().includes(n)||Jn(t).toLowerCase().includes(n)||t.effectRef.toLowerCase().includes(n));(e||i.length>0)&&r.push({...t,children:e?t.children:i})}return r}function ca(e,t){for(let n of e)for(let e of n.children)if(e.effectRef===t)return{store:n,child:e};return null}function la(e){if(e.facet===`sql`)return!1;let t=e.children[0];return e.children.length===1&&t!==void 0&&t.name===e.name}function ua(e,t){return e===t?null:t}function da(e){return`facet:${e}`}function fa(e){return`${e}/tables`}function pa(e,t){let n=t[e];return n===void 0?e.startsWith(`facet:`):n}function ma(e){let t=[];for(let n of e){t.push(da(n.facet));for(let e of n.stores)la(e.store)||(t.push(e.store.ref),e.store.facet===`sql`&&t.push(fa(e.store.ref)))}return t}function ha(e,t){let n=ca(e,t);if(!n)return[];let r=[da(n.store.facet)];return la(n.store)?r:(r.push(n.store.ref),n.store.facet===`sql`&&!jn(n.child)&&r.push(fa(n.store.ref)),r)}function ga(e){for(let t of na)for(let n of e){if(n.facet!==t)continue;let e=n.children.find(e=>!jn(e));if(e)return e.effectRef}return null}var _a=`oke_store_hidden_facets`;function va(e){return Array.isArray(e)?new Set(e.filter(e=>typeof e==`string`&&ra(e))):new Set}function ya(){try{if(typeof localStorage>`u`)return new Set;let e=localStorage.getItem(_a);return e?va(JSON.parse(e)):new Set}catch{return new Set}}function ba(e){try{if(typeof localStorage>`u`)return;localStorage.setItem(_a,JSON.stringify([...e]))}catch{}}function xa(e,t){return e.filter(e=>!t.has(e.facet))}var Sa={duration:0},Ca={type:`spring`,duration:.4,bounce:.3},wa={hidden:{},show:{transition:{staggerChildren:.035,delayChildren:.05}}},Ta={hidden:{opacity:0,y:-6,filter:`blur(3px)`},show:{opacity:1,y:0,filter:`blur(0px)`}},Ea=(0,Z.createContext)(null);function Da(e){let t=(0,Z.useContext)(Ea);if(!t)throw Error(`${e} must be used within <Select>`);return t}function Oa({value:e,defaultValue:t,onValueChange:n,disabled:r=!1,className:i,children:a}){let s=Ft()??!1,c=(0,Z.useId)(),l=(0,Z.useRef)(null),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(t),[m,h]=(0,Z.useState)(()=>new Map),[g,_]=(0,Z.useState)(`bottom`),v=e!==void 0,y=v?e:f,b=(0,Z.useCallback)(e=>{v||p(e),n?.(e),d(!1)},[v,n]),x=(0,Z.useCallback)((e,t)=>{h(n=>n.get(e)===t?n:new Map(n).set(e,t))},[]),S=(0,Z.useCallback)(e=>{h(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]);(0,Z.useEffect)(()=>{if(!u)return;let e=e=>{e.key===`Escape`&&d(!1)},t=e=>{l.current&&!l.current.contains(e.target)&&d(!1)};return window.addEventListener(`keydown`,e),window.addEventListener(`pointerdown`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`pointerdown`,t)}},[u]);let C=(0,Z.useMemo)(()=>({value:y,open:u,setOpen:d,select:b,register:x,unregister:S,labelFor:e=>e===void 0?void 0:m.get(e),reduce:s,triggerId:`${c}-trigger`,listId:`${c}-list`,disabled:r,placement:g,setPlacement:_}),[y,u,b,x,S,m,s,c,r,g]);return(0,Q.jsx)(Ea.Provider,{value:C,children:(0,Q.jsx)(`div`,{ref:l,className:o(`relative`,i),"data-slot":`motion-select`,children:a})})}function ka({className:e,children:t,"aria-label":n,flat:r=!1}){let i=Da(`SelectTrigger`),a=i.placement===`top`,s=i.open?[0,0,12]:[12,0,12],c=i.reduce?{duration:0}:i.open?{duration:.6,times:[0,.4,1],ease:At}:{duration:.42,times:[0,.5,1],ease:At};return(0,Q.jsxs)(It.button,{type:`button`,id:i.triggerId,disabled:i.disabled,"aria-label":n,"aria-haspopup":`listbox`,"aria-expanded":i.open,"aria-controls":i.listId,onClick:()=>i.setOpen(!i.open),initial:!1,animate:r?{borderTopLeftRadius:0,borderTopRightRadius:0,borderBottomLeftRadius:0,borderBottomRightRadius:0}:{borderTopLeftRadius:a?s:12,borderTopRightRadius:a?s:12,borderBottomLeftRadius:a?12:s,borderBottomRightRadius:a?12:s},transition:{borderTopLeftRadius:a?c:Sa,borderTopRightRadius:a?c:Sa,borderBottomLeftRadius:a?Sa:c,borderBottomRightRadius:a?Sa:c},className:o(`relative z-10 flex w-full items-center justify-between gap-2 text-sm text-foreground outline-none transition-colors`,`disabled:pointer-events-none disabled:opacity-50`,r?`rounded-none border-0 bg-transparent px-4 py-0 shadow-none hover:bg-transparent focus-visible:ring-0`:`rounded-xl border border-border bg-background px-3 py-2 hover:border-border focus-visible:ring-2 focus-visible:ring-ring/50`,e),children:[t,(0,Q.jsx)(It.span,{"aria-hidden":!0,animate:{rotate:i.open?180:0},transition:i.reduce?{duration:0}:Ca,className:`text-muted-foreground`,children:(0,Q.jsx)(q,{icon:E,className:`size-3.5`})})]})}function Aa({placeholder:e,className:t}){let n=Da(`SelectValue`),r=n.labelFor(n.value);return(0,Q.jsx)(`span`,{className:o(r?`text-foreground`:`text-muted-foreground`,t),children:r??e??`Select`})}function ja({className:e,children:t}){let n=Da(`SelectContent`),r=(0,Z.useRef)(null),[i,a]=(0,Z.useState)(0),s=n.open,{setPlacement:c}=n;(0,Z.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=()=>a(e.offsetHeight);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()}),(0,Z.useLayoutEffect)(()=>{if(!s)return;let e=document.getElementById(n.triggerId),t=r.current;if(!e||!t)return;let i=e.getBoundingClientRect(),a=t.offsetHeight,o=window.innerHeight-i.bottom,l=i.top;c(o<a+16&&l>o?`top`:`bottom`)},[s,n.triggerId,c]);let l=n.placement===`top`,u=s?8:0,d=s?12:0,f=s?{type:`spring`,duration:.6,bounce:.5,delay:.12}:{type:`spring`,duration:.3,bounce:.1},p=s?{duration:.3,ease:At,delay:.14}:{duration:.16,ease:At};return(0,Q.jsx)(It.div,{id:n.listId,role:`listbox`,"aria-labelledby":n.triggerId,"aria-hidden":!s,inert:!s,initial:!1,animate:n.reduce?{opacity:+!!s,height:s?i:0}:{opacity:+!!s,height:s?i:0,marginTop:l?0:u,marginBottom:l?u:0,borderTopLeftRadius:l?12:d,borderTopRightRadius:l?12:d,borderBottomLeftRadius:l?d:12,borderBottomRightRadius:l?d:12},transition:n.reduce?{duration:.12}:{opacity:s?{duration:.18}:{duration:.16,delay:.12},height:s?{type:`spring`,duration:.42,bounce:.14}:{duration:.26,ease:At,delay:.14},marginTop:l?Sa:f,marginBottom:l?f:Sa,borderTopLeftRadius:l?Sa:p,borderTopRightRadius:l?Sa:p,borderBottomLeftRadius:l?p:Sa,borderBottomRightRadius:l?p:Sa},style:{transformOrigin:l?`bottom`:`top`,overflow:`hidden`,pointerEvents:s?`auto`:`none`},className:o(`absolute right-0 left-0 z-20 rounded-xl border border-border bg-background shadow-lg`,l?`bottom-full`:`top-full`,e),children:(0,Q.jsx)(It.div,{ref:r,variants:n.reduce?void 0:wa,initial:!1,animate:s?`show`:`hidden`,className:`p-1`,children:t})})}function Ma({value:e,disabled:t=!1,className:n,children:r}){let i=Da(`SelectItem`),a=i.value===e,s=typeof r==`string`?r:e,c=i.register,l=i.unregister;return(0,Z.useLayoutEffect)(()=>(c(e,s),()=>l(e)),[c,l,e,s]),(0,Q.jsx)(It.li,{variants:i.reduce?void 0:Ta,children:(0,Q.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":a,disabled:t,onClick:()=>i.select(e),className:o(`flex w-full items-center justify-between gap-2 rounded-lg px-2.5 py-1.5 text-left text-sm outline-none transition-colors`,a?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:bg-muted`,`disabled:pointer-events-none disabled:opacity-50`,n),children:[r,a?(0,Q.jsx)(q,{icon:Ae,className:`size-3.5 shrink-0`,"aria-hidden":!0}):null]})})}function Na(e){if(!e.error)return null;let t=Error(e.error.message??e.error.code);return t.code=e.error.code,t.data=e.error.data,t}function Pa(){let e=f();return it({mutationFn:async e=>{let t=await Ie(e),n=Na(t);if(n)throw n;if(!t.data)throw Error(`Empty store edit`);return t.data},onSuccess:async(t,n)=>{n.commit&&await Promise.all([e.invalidateQueries({queryKey:tr}),e.invalidateQueries({queryKey:di})])}})}function Fa(){let e=f();return it({mutationFn:async e=>{let t=await S(e),n=Na(t);if(n)throw n;if(!t.data)throw Error(`Empty store delete`);return t.data},onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:tr}),e.invalidateQueries({queryKey:di})])}})}var Ia={type:`spring`,stiffness:800,damping:80,mass:4};function La({checked:e,onCheckedChange:t,disabled:n,label:r,ariaLabel:i,className:a,size:s=`default`}){let c=(0,Z.useId)(),l=(0,Z.useRef)(null),u=Ft(),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1),h=s===`sm`;(0,Z.useEffect)(()=>{!l.current||u||n&&d&&zt(l.current,{x:[0,-2,2,-1,0]},{delay:.2,duration:.6})},[n,d,u]);let g=!n&&p&&d&&!u;return(0,Q.jsx)(Xi,{transition:u?{duration:0}:Ia,children:(0,Q.jsxs)(`span`,{className:o(`inline-flex items-center gap-2`,a),children:[(0,Q.jsx)(It.button,{id:c,type:`button`,role:`switch`,"aria-checked":e,"aria-label":i,disabled:n,onClick:()=>{n||t(!e)},onPointerDown:()=>{f(!0),m(!0)},onPointerUp:()=>f(!1),onPointerLeave:()=>f(!1),initial:!1,"data-state":e?`checked`:`unchecked`,className:o(`group peer inline-flex shrink-0 cursor-pointer items-center rounded-full outline-none transition-colors duration-200`,`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`,`disabled:cursor-not-allowed disabled:opacity-60`,h?`h-4 w-7 px-0.5`:`h-7 w-12 px-1`,e?`justify-end bg-primary`:`justify-start bg-muted-foreground/60`),children:(0,Q.jsx)(It.div,{ref:l,layout:!0,animate:{scale:g?.9:1},className:o(`pointer-events-none block rounded-full bg-background shadow-md`,h?`h-3 w-3`:`h-5 w-5`),children:(0,Q.jsx)(`div`,{className:o(h?`size-3`:`size-5`,g&&(e?`ml-1`:`mr-1`)),"aria-hidden":!0})})}),r?(0,Q.jsx)(`label`,{htmlFor:c,className:`text-sm`,children:r}):null]})})}function Ra({open:e,extraCount:t=0,onOpenChange:n,controls:r}){return(0,Q.jsxs)(jr,{active:e||t>0,extraCount:t,"aria-expanded":e,"aria-controls":r,onClick:()=>n(!e),children:[(0,Q.jsx)(q,{icon:Ee,className:`size-3`,"aria-hidden":!0}),`Advanced`]})}function za({templates:e,selectedId:t,onSelect:n}){let r=e.find(e=>e.id===t)??null;return(0,Q.jsx)(Ar,{label:`Templates`,hint:r?.detail??`Pick a starter, or fill the fields.`,children:e.map(e=>(0,Q.jsx)(Tr,{active:e.id===t,onClick:()=>n(e),children:e.title},e.id))})}var Ba=[{name:`plpgsql`,version:`1.0`,comment:`PL/pgSQL procedural language`,source:`builtin`,category:`language`},{name:`pgcrypto`,version:`1.3`,comment:`Cryptographic functions`,source:`builtin`,category:`contrib`},{name:`uuid-ossp`,version:`1.1`,comment:`UUID generation (OSSP)`,source:`builtin`,category:`contrib`},{name:`citext`,version:`1.6`,comment:`Case-insensitive text`,source:`builtin`,category:`contrib`},{name:`hstore`,version:`1.8`,comment:`Key-value store in a column`,source:`builtin`,category:`contrib`},{name:`pg_trgm`,version:`1.6`,comment:`Trigram text similarity`,source:`builtin`,category:`contrib`},{name:`btree_gin`,version:`1.3`,comment:`GIN support for common types`,source:`builtin`,category:`contrib`},{name:`btree_gist`,version:`1.7`,comment:`GiST support for common types`,source:`builtin`,category:`contrib`},{name:`unaccent`,version:`1.1`,comment:`Text search dictionary that removes accents`,source:`builtin`,category:`contrib`},{name:`ltree`,version:`1.3`,comment:`Hierarchical tree-like data type`,source:`builtin`,category:`contrib`},{name:`cube`,version:`1.5`,comment:`Multidimensional cubes`,source:`builtin`,category:`contrib`},{name:`earthdistance`,version:`1.2`,comment:`Great-circle distances on Earth`,source:`builtin`,category:`contrib`},{name:`fuzzystrmatch`,version:`1.2`,comment:`Fuzzy string matching`,source:`builtin`,category:`contrib`},{name:`intarray`,version:`1.5`,comment:`Functions for 1-D arrays of integers`,source:`builtin`,category:`contrib`},{name:`isn`,version:`1.2`,comment:`International product numbering types`,source:`builtin`,category:`contrib`},{name:`lo`,version:`1.1`,comment:`Large Object maintenance`,source:`builtin`,category:`contrib`},{name:`tablefunc`,version:`1.0`,comment:`Crosstab and table functions`,source:`builtin`,category:`contrib`},{name:`tcn`,version:`1.0`,comment:`Triggered change notifications`,source:`builtin`,category:`contrib`},{name:`tsm_system_rows`,version:`1.0`,comment:`TABLESAMPLE method SYSTEM_ROWS`,source:`builtin`,category:`contrib`},{name:`tsm_system_time`,version:`1.0`,comment:`TABLESAMPLE method SYSTEM_TIME`,source:`builtin`,category:`contrib`},{name:`xml2`,version:`1.1`,comment:`XPath querying and XSLT`,source:`builtin`,category:`contrib`},{name:`postgres_fdw`,version:`1.1`,comment:`Foreign-data wrapper for PostgreSQL`,source:`builtin`,category:`contrib`},{name:`file_fdw`,version:`1.0`,comment:`Foreign-data wrapper for files`,source:`builtin`,category:`contrib`},{name:`dblink`,version:`1.2`,comment:`Connect to other PostgreSQL databases`,source:`builtin`,category:`contrib`},{name:`amcheck`,version:`1.4`,comment:`Verify relation integrity`,source:`builtin`,category:`contrib`},{name:`bloom`,version:`1.0`,comment:`Bloom-filter index access method`,source:`builtin`,category:`contrib`},{name:`dict_int`,version:`1.0`,comment:`Text search dictionary for integers`,source:`builtin`,category:`contrib`},{name:`dict_xsyn`,version:`1.0`,comment:`Text search dictionary for extended synonym`,source:`builtin`,category:`contrib`},{name:`pageinspect`,version:`1.12`,comment:`Inspect contents of database pages`,source:`builtin`,category:`contrib`},{name:`pg_buffercache`,version:`1.5`,comment:`Examine shared buffer cache`,source:`builtin`,category:`contrib`},{name:`pg_freespacemap`,version:`1.2`,comment:`Examine the free space map`,source:`builtin`,category:`contrib`},{name:`pg_prewarm`,version:`1.2`,comment:`Prewarm relation data`,source:`builtin`,category:`contrib`},{name:`pg_stat_statements`,version:`1.11`,comment:`Track planning and execution statistics`,source:`builtin`,category:`contrib`},{name:`pg_surgery`,version:`1.0`,comment:`Low-level heap surgery`,source:`builtin`,category:`contrib`},{name:`pg_visibility`,version:`1.2`,comment:`Examine visibility map`,source:`builtin`,category:`contrib`},{name:`pgrowlocks`,version:`1.2`,comment:`Show row-level locking information`,source:`builtin`,category:`contrib`},{name:`pgstattuple`,version:`1.5`,comment:`Tuple-level statistics`,source:`builtin`,category:`contrib`},{name:`sslinfo`,version:`1.2`,comment:`Information about SSL certificates`,source:`builtin`,category:`contrib`},{name:`vector`,version:`0.8.6`,comment:`Vector similarity search (pgvector)`,source:`builtin`,category:`search`}];function $(e,t,n,r,i,a){return{name:e,version:t,comment:n,source:`library`,category:r,tags:i,...a&&a.length>0?{requires:a}:{}}}var Va=[$(`timescaledb`,`2.17.0`,`Time-series hypertables, compression, and continuous aggregates`,`time`,[`timescale`,`hypertable`,`iot`,`metrics`]),$(`timescaledb_toolkit`,`1.19.0`,`Timescale hyperfunctions — locf, gapfill, stats`,`time`,[`timescale`,`hyperfunctions`,`analytics`],[`timescaledb`]),$(`pg_partman`,`5.2.0`,`Partition maintenance for time- and serial-based tables`,`time`,[`partition`,`retention`]),$(`pg_ivm`,`1.9`,`Incremental view maintenance for materialized views`,`time`,[`materialized`,`ivm`,`refresh`]),$(`temporal_tables`,`1.2.2`,`System-period temporal tables (SQL:2011 style)`,`time`,[`history`,`versioning`,`audit`]),$(`pg_cron`,`1.6`,`Cron-based job scheduler inside the database`,`jobs`,[`cron`,`schedule`,`jobs`]),$(`pg_later`,`0.3.0`,`Fire-and-forget SQL jobs after the current transaction`,`jobs`,[`async`,`queue`,`later`]),$(`pg_background`,`1.2`,`Run commands in a background worker`,`jobs`,[`worker`,`background`]),$(`postgis`,`3.5.0`,`Geographic objects and spatial indexes`,`geo`,[`gis`,`geo`,`geometry`,`geography`,`spatial`]),$(`postgis_topology`,`3.5.0`,`PostGIS topology types and functions`,`geo`,[`gis`,`topology`],[`postgis`]),$(`postgis_raster`,`3.5.0`,`PostGIS raster types and functions`,`geo`,[`gis`,`raster`,`coverage`],[`postgis`]),$(`postgis_sfcgal`,`3.5.0`,`3D / solid geometry via SFCGAL`,`geo`,[`gis`,`3d`,`sfcgal`],[`postgis`]),$(`address_standardizer`,`3.5.0`,`Parse and normalize street addresses`,`geo`,[`gis`,`geocode`,`address`]),$(`postgis_tiger_geocoder`,`3.5.0`,`TIGER geocoder for US addresses`,`geo`,[`gis`,`geocode`,`tiger`],[`postgis`,`address_standardizer`]),$(`pgrouting`,`3.7.0`,`Routing algorithms on PostGIS networks`,`geo`,[`gis`,`routing`,`shortest-path`],[`postgis`]),$(`h3`,`4.1.0`,`Uber H3 hexagonal hierarchical spatial index`,`geo`,[`gis`,`hex`,`uber`]),$(`mobilitydb`,`1.2.0`,`Temporal and spatiotemporal types for moving objects`,`geo`,[`gis`,`trajectory`,`temporal`],[`postgis`]),$(`pointcloud`,`1.2.5`,`LIDAR / point-cloud storage (PDAL)`,`geo`,[`gis`,`lidar`,`pdal`]),$(`rum`,`1.3`,`GIN-like access method for faster full-text search`,`search`,[`fts`,`full-text`,`gin`]),$(`pg_search`,`0.15.0`,`ParadeDB BM25 full-text search`,`search`,[`paradedb`,`bm25`,`fts`]),$(`pgroonga`,`3.2.5`,`Groonga full-text search (CJK-friendly)`,`search`,[`fts`,`cjk`,`japanese`]),$(`pg_bigm`,`1.2`,`Bigram full-text search (LIKE acceleration)`,`search`,[`fts`,`bigram`,`like`]),$(`zhparser`,`2.2`,`Chinese text search parser`,`search`,[`fts`,`chinese`,`cjk`]),$(`zombodb`,`3000.2.7`,`Elasticsearch-backed indexes from Postgres`,`search`,[`elasticsearch`,`fts`]),$(`vchord`,`0.4.3`,`VectorChord — disk-based vector index`,`search`,[`vector`,`embedding`,`ann`]),$(`vectorscale`,`0.7.1`,`Timescale vector index (StreamingDiskANN)`,`search`,[`vector`,`timescale`,`ann`]),$(`age`,`1.5.0`,`Apache AGE graph queries (openCypher)`,`graph`,[`graph`,`cypher`,`opencypher`]),$(`citus`,`12.1`,`Distributed Postgres — shard and scale out`,`scale`,[`shard`,`distributed`,`microsoft`]),$(`citus_columnar`,`12.1`,`Citus columnar storage for analytics`,`scale`,[`columnar`,`olap`,`citus`],[`citus`]),$(`pg_repack`,`1.5.1`,`Online table bloat cleanup without exclusive locks`,`scale`,[`bloat`,`vacuum`,`reindex`]),$(`pg_squeeze`,`1.8`,`Automatic bloat cleanup as a background worker`,`scale`,[`bloat`,`vacuum`]),$(`hypopg`,`1.4.1`,`Hypothetical indexes for EXPLAIN without creating them`,`scale`,[`explain`,`index`,`what-if`]),$(`index_advisor`,`0.2.0`,`Suggest indexes from a query via hypothetical indexes`,`scale`,[`index`,`advisor`,`hypopg`],[`hypopg`]),$(`pg_hint_plan`,`1.7.0`,`Planner hints in SQL comments`,`scale`,[`planner`,`hint`,`explain`]),$(`pg_stat_kcache`,`2.3.0`,`Filesystem and CPU stats per query`,`scale`,[`stats`,`observability`]),$(`pg_qualstats`,`2.1.1`,`Predicate statistics for missing-index hints`,`scale`,[`stats`,`index`]),$(`pg_wait_sampling`,`1.1.6`,`Sample wait events for lock analysis`,`scale`,[`waits`,`locks`,`observability`]),$(`pg_stat_monitor`,`2.1.0`,`Percona query-performance monitor`,`scale`,[`stats`,`percona`,`observability`]),$(`pgaudit`,`17.0`,`Session and object audit logging`,`security`,[`audit`,`compliance`,`logging`]),$(`pgsodium`,`3.1.9`,`Libsodium cryptography helpers`,`security`,[`crypto`,`encryption`,`libsodium`]),$(`pgjwt`,`0.2.0`,`Create and verify JSON Web Tokens in SQL`,`security`,[`jwt`,`auth`,`token`]),$(`anon`,`2.1.0`,`PostgreSQL Anonymizer — masking and dumping`,`security`,[`pii`,`mask`,`gdpr`,`anonymizer`]),$(`credcheck`,`2.8`,`Password complexity and reuse checks`,`security`,[`password`,`auth`]),$(`set_user`,`4.1.0`,`Privilege bridging with audit trail`,`security`,[`sudo`,`privilege`,`audit`]),$(`pg_tle`,`1.5.0`,`Trusted Language Extensions (AWS)`,`security`,[`tle`,`aws`,`sandbox`]),$(`pg_net`,`0.14.0`,`Async HTTP from SQL (Supabase)`,`http`,[`http`,`webhook`,`supabase`]),$(`http`,`1.6`,`Synchronous HTTP client from SQL`,`http`,[`http`,`rest`,`curl`]),$(`wrappers`,`0.4.5`,`Supabase FDW framework (Stripe, Firebase, S3…)`,`http`,[`fdw`,`supabase`,`stripe`]),$(`pg_graphql`,`1.5.11`,`GraphQL API generated from the schema`,`http`,[`graphql`,`api`,`supabase`]),$(`pgmq`,`1.5.1`,`Lightweight message queue in Postgres`,`http`,[`queue`,`mq`,`jobs`]),$(`pg_jsonschema`,`0.3.3`,`Validate JSON against JSON Schema`,`http`,[`json`,`schema`,`validate`]),$(`mysql_fdw`,`1.2`,`Foreign-data wrapper for MySQL / MariaDB`,`fdw`,[`mysql`,`mariadb`,`fdw`]),$(`mongo_fdw`,`5.5.2`,`Foreign-data wrapper for MongoDB`,`fdw`,[`mongodb`,`fdw`]),$(`tds_fdw`,`2.0.4`,`Foreign-data wrapper for SQL Server / Sybase`,`fdw`,[`mssql`,`sqlserver`,`fdw`]),$(`oracle_fdw`,`2.7.0`,`Foreign-data wrapper for Oracle`,`fdw`,[`oracle`,`fdw`]),$(`sqlite_fdw`,`2.5.0`,`Foreign-data wrapper for SQLite`,`fdw`,[`sqlite`,`fdw`]),$(`redis_fdw`,`1.0`,`Foreign-data wrapper for Redis`,`fdw`,[`redis`,`fdw`]),$(`duckdb_fdw`,`1.1.0`,`Foreign-data wrapper for DuckDB`,`fdw`,[`duckdb`,`olap`,`fdw`]),$(`pg_duckdb`,`0.3.0`,`DuckDB engine inside Postgres`,`fdw`,[`duckdb`,`olap`,`analytics`]),$(`ogr_fdw`,`1.1.5`,`GDAL/OGR spatial foreign tables`,`fdw`,[`gis`,`gdal`,`shapefile`,`fdw`]),$(`plpython3u`,`1.0`,`Untrusted Python 3 procedural language`,`lang`,[`python`,`pl`]),$(`plperl`,`1.0`,`Perl procedural language`,`lang`,[`perl`,`pl`]),$(`pltcl`,`1.0`,`Tcl procedural language`,`lang`,[`tcl`,`pl`]),$(`plv8`,`3.2.3`,`JavaScript (V8) procedural language`,`lang`,[`javascript`,`v8`,`pl`]),$(`plrust`,`1.2.8`,`Trusted Rust procedural language`,`lang`,[`rust`,`pl`]),$(`plpgsql_check`,`2.7.15`,`Static analysis for PL/pgSQL functions`,`lang`,[`lint`,`plpgsql`]),$(`hll`,`2.18`,`HyperLogLog distinct-count sketches`,`analytics`,[`cardinality`,`sketch`,`approx`]),$(`tdigest`,`1.4.2`,`t-digest quantiles and percentiles`,`analytics`,[`quantile`,`percentile`,`sketch`]),$(`topn`,`2.7.0`,`Approximate most-frequent values`,`analytics`,[`topk`,`sketch`,`timescale`]),$(`datasketches`,`1.7.0`,`Apache DataSketches — HLL, Theta, KLL`,`analytics`,[`sketch`,`apache`,`approx`]),$(`pg_uuidv7`,`1.6.0`,`UUIDv7 generators (time-ordered)`,`analytics`,[`uuid`,`id`]),$(`pg_idkit`,`0.2.4`,`UUID, ULID, KSUID, TypeID generators`,`analytics`,[`uuid`,`ulid`,`ksuid`]),$(`pg_hashids`,`1.3.0`,`YouTube-style hashids from integers`,`analytics`,[`hashid`,`shortid`])];[...Ba,...Va];function Ha(e){return/^[0-9]+(\.[0-9]+)*$/.test(e)}var Ua={plpgsql:`PL/pgSQL`,pgcrypto:`Crypto`,"uuid-ossp":`UUID OSSP`,citext:`CIText`,hstore:`Hstore`,pg_trgm:`Trigram`,btree_gin:`B-tree GIN`,btree_gist:`B-tree GiST`,unaccent:`Unaccent`,ltree:`Ltree`,cube:`Cube`,earthdistance:`Earth Distance`,fuzzystrmatch:`Fuzzy Match`,intarray:`Intarray`,isn:`ISN`,lo:`Large Objects`,tablefunc:`Tablefunc`,tcn:`TCN`,tsm_system_rows:`System Rows`,tsm_system_time:`System Time`,xml2:`XML2`,postgres_fdw:`Postgres FDW`,file_fdw:`File FDW`,dblink:`DB Link`,amcheck:`AM Check`,bloom:`Bloom`,dict_int:`Dict Int`,dict_xsyn:`Dict Xsyn`,pageinspect:`Page Inspect`,pg_buffercache:`Buffer Cache`,pg_freespacemap:`Free Space Map`,pg_prewarm:`Prewarm`,pg_stat_statements:`Stat Statements`,pg_surgery:`Surgery`,pg_visibility:`Visibility`,pgrowlocks:`Row Locks`,pgstattuple:`Stat Tuple`,sslinfo:`SSL Info`,vector:`pgvector`,timescaledb:`Timescale`,timescaledb_toolkit:`Timescale Toolkit`,pg_partman:`Partman`,pg_ivm:`IVM`,temporal_tables:`Temporal Tables`,pg_cron:`Cron`,pg_later:`Later`,pg_background:`Background`,postgis:`PostGIS`,postgis_topology:`PostGIS Topology`,postgis_raster:`PostGIS Raster`,postgis_sfcgal:`PostGIS SFCGAL`,address_standardizer:`Address Standardizer`,postgis_tiger_geocoder:`PostGIS Tiger Geocoder`,pgrouting:`pgRouting`,h3:`H3`,mobilitydb:`MobilityDB`,pointcloud:`Pointcloud`,rum:`RUM`,pg_search:`ParadeDB Search`,pgroonga:`PGroonga`,pg_bigm:`Bigm`,zhparser:`Zhparser`,zombodb:`ZomboDB`,vchord:`VectorChord`,vectorscale:`Vectorscale`,age:`Apache AGE`,citus:`Citus`,citus_columnar:`Citus Columnar`,pg_repack:`Repack`,pg_squeeze:`Squeeze`,hypopg:`HypoPG`,index_advisor:`Index Advisor`,pg_hint_plan:`Hint Plan`,pg_stat_kcache:`Stat Kcache`,pg_qualstats:`Qualstats`,pg_wait_sampling:`Wait Sampling`,pg_stat_monitor:`Stat Monitor`,pgaudit:`pgAudit`,pgsodium:`Sodium`,pgjwt:`JWT`,anon:`Anonymizer`,credcheck:`Credcheck`,set_user:`Set User`,pg_tle:`TLE`,pg_net:`Net`,http:`HTTP`,wrappers:`Wrappers`,pg_graphql:`GraphQL`,pgmq:`Queues`,pg_jsonschema:`JSON Schema`,mysql_fdw:`MySQL FDW`,mongo_fdw:`MongoDB FDW`,tds_fdw:`TDS FDW`,oracle_fdw:`Oracle FDW`,sqlite_fdw:`SQLite FDW`,redis_fdw:`Redis FDW`,duckdb_fdw:`DuckDB FDW`,pg_duckdb:`DuckDB`,ogr_fdw:`OGR FDW`,plpython3u:`PL/Python 3`,plperl:`PL/Perl`,pltcl:`PL/Tcl`,plv8:`PL/V8`,plrust:`PL/Rust`,plpgsql_check:`PL/pgSQL Check`,hll:`HyperLogLog`,tdigest:`t-digest`,topn:`TopN`,datasketches:`DataSketches`,pg_uuidv7:`UUIDv7`,pg_idkit:`IDkit`,pg_hashids:`Hashids`},Wa={fdw:`FDW`,jwt:`JWT`,http:`HTTP`,ivm:`IVM`,tle:`TLE`,hll:`HLL`,age:`AGE`,rum:`RUM`,h3:`H3`,postgis:`PostGIS`,duckdb:`DuckDB`,gin:`GIN`,gist:`GiST`};function Ga(e){return Ua[e]||e.replace(/^pg_/,``).split(/[_-]+/).filter(e=>e.length>0).map(e=>Wa[e]??e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var Ka=`https://www.postgresql.org/docs/current`,qa={plpgsql:`plpgsql`,pgcrypto:`pgcrypto`,"uuid-ossp":`uuid-ossp`,citext:`citext`,hstore:`hstore`,pg_trgm:`pgtrgm`,btree_gin:`btree-gin`,btree_gist:`btree-gist`,unaccent:`unaccent`,ltree:`ltree`,cube:`cube`,earthdistance:`earthdistance`,fuzzystrmatch:`fuzzystrmatch`,intarray:`intarray`,isn:`isn`,lo:`lo`,tablefunc:`tablefunc`,tcn:`tcn`,tsm_system_rows:`tsm-system-rows`,tsm_system_time:`tsm-system-time`,xml2:`xml2`,postgres_fdw:`postgres-fdw`,file_fdw:`file-fdw`,dblink:`dblink`,amcheck:`amcheck`,bloom:`bloom`,dict_int:`dict-int`,dict_xsyn:`dict-xsyn`,pageinspect:`pageinspect`,pg_buffercache:`pgbuffercache`,pg_freespacemap:`pgfreespacemap`,pg_prewarm:`pgprewarm`,pg_stat_statements:`pgstatstatements`,pg_surgery:`pgsurgery`,pg_visibility:`pgvisibility`,pgrowlocks:`pgrowlocks`,pgstattuple:`pgstattuple`,sslinfo:`sslinfo`,plpython3u:`plpython`,plperl:`plperl`,pltcl:`pltcl`},Ja={vector:`https://github.com/pgvector/pgvector`,timescaledb:`https://github.com/timescale/timescaledb`,timescaledb_toolkit:`https://github.com/timescale/timescaledb-toolkit`,pg_partman:`https://github.com/pgpartman/pg_partman`,pg_ivm:`https://github.com/sraoss/pg_ivm`,temporal_tables:`https://github.com/arkhipov/temporal_tables`,pg_cron:`https://github.com/citusdata/pg_cron`,pg_later:`https://github.com/supabase/pg_later`,pg_background:`https://github.com/vibhorkum/pg_background`,postgis:`https://postgis.net`,postgis_topology:`https://postgis.net/docs/Topology.html`,postgis_raster:`https://postgis.net/docs/RT_reference.html`,postgis_sfcgal:`https://postgis.net/docs/reference.html#reference_sfcgal`,address_standardizer:`https://postgis.net/docs/manual-dev/Address_Standardizer.html`,postgis_tiger_geocoder:`https://postgis.net/docs/Extras.html#Tiger_Geocoder`,pgrouting:`https://pgrouting.org`,h3:`https://github.com/zachasme/h3-pg`,mobilitydb:`https://github.com/MobilityDB/MobilityDB`,pointcloud:`https://github.com/pgpointcloud/pointcloud`,rum:`https://github.com/postgrespro/rum`,pg_search:`https://github.com/paradedb/paradedb`,pgroonga:`https://pgroonga.github.io`,pg_bigm:`https://github.com/pgbigm/pg_bigm`,zhparser:`https://github.com/amutu/zhparser`,zombodb:`https://github.com/zombodb/zombodb`,vchord:`https://github.com/tensorchord/VectorChord`,vectorscale:`https://github.com/timescale/pgvectorscale`,age:`https://age.apache.org`,citus:`https://github.com/citusdata/citus`,citus_columnar:`https://github.com/citusdata/citus`,pg_repack:`https://github.com/reorg/pg_repack`,pg_squeeze:`https://github.com/cybertec-postgresql/pg_squeeze`,hypopg:`https://github.com/HypoPG/hypopg`,index_advisor:`https://github.com/supabase/index_advisor`,pg_hint_plan:`https://github.com/ossc-db/pg_hint_plan`,pg_stat_kcache:`https://github.com/powa-team/pg_stat_kcache`,pg_qualstats:`https://github.com/powa-team/pg_qualstats`,pg_wait_sampling:`https://github.com/postgrespro/pg_wait_sampling`,pg_stat_monitor:`https://github.com/percona/pg_stat_monitor`,pgaudit:`https://github.com/pgaudit/pgaudit`,pgsodium:`https://github.com/michelp/pgsodium`,pgjwt:`https://github.com/michelp/pgjwt`,anon:`https://postgresql-anonymizer.readthedocs.io`,credcheck:`https://github.com/HexaCluster/credcheck`,set_user:`https://github.com/pgaudit/set_user`,pg_tle:`https://github.com/aws/pg_tle`,pg_net:`https://github.com/supabase/pg_net`,http:`https://github.com/pramsey/pgsql-http`,wrappers:`https://github.com/supabase/wrappers`,pg_graphql:`https://github.com/supabase/pg_graphql`,pgmq:`https://github.com/pgmq/pgmq`,pg_jsonschema:`https://github.com/supabase/pg_jsonschema`,mysql_fdw:`https://github.com/enterprisedb/mysql_fdw`,mongo_fdw:`https://github.com/enterprisedb/mongo_fdw`,tds_fdw:`https://github.com/tds-fdw/tds_fdw`,oracle_fdw:`https://github.com/laurenz/oracle_fdw`,sqlite_fdw:`https://github.com/pgspider/sqlite_fdw`,redis_fdw:`https://github.com/pg-redis-fdw/redis_fdw`,duckdb_fdw:`https://github.com/alitrack/duckdb_fdw`,pg_duckdb:`https://github.com/duckdb/pg_duckdb`,ogr_fdw:`https://github.com/pramsey/pgsql-ogr-fdw`,plv8:`https://github.com/plv8/plv8`,plrust:`https://github.com/tcdi/plrust`,plpgsql_check:`https://github.com/okbob/plpgsql_check`,hll:`https://github.com/citusdata/postgresql-hll`,tdigest:`https://github.com/tvondra/tdigest`,topn:`https://github.com/timescale/pg_topn`,datasketches:`https://github.com/apache/datasketches-postgresql`,pg_uuidv7:`https://github.com/fboulnois/pg_uuidv7`,pg_idkit:`https://github.com/gaeljw/pg_idkit`,pg_hashids:`https://github.com/iCyberon/pg_hashids`};function Ya(e){let t=Ja[e];if(t)return t;let n=qa[e];return n?`${Ka}/${n}.html`:null}var Xa={language:`Language`,contrib:`Contrib`,time:`Time series`,geo:`Geospatial`,jobs:`Jobs`,search:`Search`,graph:`Graph`,scale:`Scale`,security:`Security`,http:`HTTP`,fdw:`Foreign data`,lang:`Languages`,analytics:`Analytics`};function Za(e){return`"${e.replaceAll(`"`,``)}"`}var Qa=Ga,$a=[`timescaledb`,`pg_cron`,`postgis`],eo={timescaledb:`Timescale`,timescaledb_toolkit:`Timescale`,vectorscale:`Timescale`,topn:`Timescale`,pg_cron:`Citus Data`,citus:`Microsoft`,citus_columnar:`Microsoft`,postgis:`PostGIS Project`,postgis_topology:`PostGIS Project`,postgis_raster:`PostGIS Project`,postgis_sfcgal:`PostGIS Project`,postgis_tiger_geocoder:`PostGIS Project`,pgrouting:`pgRouting`,pg_search:`ParadeDB`,pgmq:`pgmq`,pg_net:`Supabase`,index_advisor:`Supabase`,wrappers:`Supabase`,pg_graphql:`Supabase`,age:`Apache`,datasketches:`Apache`,pg_duckdb:`DuckDB`,duckdb_fdw:`DuckDB`,anon:`PostgreSQL Anonymizer`,pg_stat_monitor:`Percona`};function to(e){return eo[e]}function no(e){let t=new Map(e.map(e=>[e.name,e]));return $a.flatMap(e=>{let n=t.get(e);return n?[n]:[]})}var ro=[`time`,`jobs`,`geo`,`search`,`graph`,`scale`,`security`,`http`,`fdw`,`lang`,`analytics`];function io(e){return[e.name,Qa(e.name),e.comment,e.category,Xa[e.category],...e.tags??[],...e.requires??[]].join(` `).toLowerCase()}function ao(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(e=>e.length>0);return n.length===0?e:e.filter(e=>{let t=io(e);return n.every(e=>t.includes(e))})}function oo(e){return ro.flatMap(t=>{let n=e.filter(e=>e.category===t);return n.length===0?[]:[{category:t,label:Xa[t],items:n}]})}var so={pg_cron:`After install, schedule jobs with cron.schedule(). HTTP job types need pg_net.`,timescaledb:`After install, convert time-series tables with create_hypertable().`,timescaledb_toolkit:`Hyperfunctions on top of Timescale — needs timescaledb first.`,postgis:`Adds geometry / geography types and spatial indexes.`,pg_net:`Lets SQL send async HTTP. Required for webhook-style cron jobs.`,pgmq:`Lightweight queue tables in Postgres. Pair with pg_cron to drain jobs.`,pg_graphql:`Exposes a GraphQL schema from your tables.`};function co(e,t){let n=[`CREATE EXTENSION IF NOT EXISTS ${Za(e)}`],r=[],i=t?.schema?.trim()??``;i!==``&&lo(i)&&r.push(`SCHEMA ${fn(i)}`);let a=t?.version?.trim()??``;return a!==``&&Ha(a)&&r.push(`VERSION '${a}'`),t?.cascade===!0&&r.push(`CASCADE`),r.length>0&&n.push(`WITH ${r.join(` `)}`),`${n.join(` `)};`}function lo(e){let t=e.trim();return pn(t)&&t.toLowerCase()!==`pg_catalog`}function uo(e){return+!!e.schema?.trim()+ +!!e.version?.trim()+ +(e.cascade===!0)}function fo(e,t,n){let r=[...e.requires??[],e.name].map(e=>({name:e,title:Qa(e),already:t.has(e)})),i=r.filter(e=>!e.already),a=i.length>0?i.map(t=>co(t.name,t.name===e.name?n:void 0)).join(`
|
|
2
2
|
`):`-- ${e.name} is already installed`,o=so[e.name];return{items:r,sql:a,...o?{note:o}:{}}}var po={timescaledb:R,pg_cron:rt,postgis:Ce},mo=[{value:`all`,label:`All`},...ro.map(e=>({value:e,label:Xa[e]}))];function ho({open:e,onOpenChange:t,storeRef:n,presentNames:r}){let i=Pa(),[a,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(`all`),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(`extensions`),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(``),[T,E]=(0,Z.useState)(!1),D=(0,Z.useMemo)(()=>new Set(r),[r]),O=(0,Z.useMemo)(()=>{let e=ao(Va,a);return l===`all`?e:e.filter(e=>e.category===l)},[a,l]),k=l===`all`&&a.trim()===``,A=(0,Z.useMemo)(()=>k?no(Va):[],[k]),j=(0,Z.useMemo)(()=>{if(!k)return O;let e=new Set(A.map(e=>e.name));return O.filter(t=>!e.has(t.name))},[k,A,O]),M=(0,Z.useMemo)(()=>oo(j),[j]),N=(0,Z.useMemo)(()=>({...x.trim()===``?{}:{schema:x.trim()},...C.trim()===``?{}:{version:C.trim()},...T?{cascade:!0}:{}}),[x,C,T]),P=(0,Z.useMemo)(()=>h?fo(h,D,N):null,[h,D,N]),F=e=>{D.has(e.name)||(f(null),v(`extensions`),b(!1),S(``),w(``),E(!1),g(e))},I=async()=>{if(!h||!P)return;let e=P.items.filter(e=>!e.already).map(e=>e.name);if(e.length===0){g(null);return}f(null),m(h.name);try{for(let t of e)await i.mutateAsync({ref:n,child:`extensions`,id:t,patch:{enabled:!0,...t===h.name?N:{}},commit:!0});g(null)}catch(e){f(e instanceof Error?e.message:String(e))}finally{m(null)}};return(0,Q.jsx)(W,{open:e,onOpenChange:e=>{e||(c(``),u(`all`),f(null),m(null),g(null),v(`extensions`),b(!1),S(``),w(``),E(!1)),t(e)},children:(0,Q.jsx)(G,{side:`right`,showOverlay:!1,className:`gap-0 p-0 data-[side=right]:sm:max-w-3xl`,"data-slot":`extension-library-sheet`,children:h&&P?(0,Q.jsx)(go,{ext:h,plan:P,tab:_,advancedOpen:y,extraCount:uo(N),schema:x,version:C,cascade:T,error:d,pending:p!==null,onTab:v,onAdvanced:b,onSchema:S,onVersion:w,onCascade:E,onBack:()=>{g(null),f(null)},onConfirm:()=>void I()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(Te,{className:`gap-1 border-b border-border/50`,children:[(0,Q.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 pr-8`,children:[(0,Q.jsx)(qe,{className:`text-sm`,children:`Extend this store`}),(0,Q.jsxs)(`p`,{className:`text-[10px] tabular-nums text-muted-foreground`,children:[O.length,` pack`,O.length===1?``:`s`,a.trim()?` matching “${a.trim()}”`:``]})]}),(0,Q.jsxs)(ze,{className:`text-[11px]`,children:[`External packs — Timescale, PostGIS, cron, FDWs. Install reviews`,` `,(0,Q.jsx)(`span`,{className:`font-mono`,children:`CREATE EXTENSION`}),` first.`]})]}),(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center border-b border-border/50`,children:[(0,Q.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,Q.jsx)(q,{icon:ee,className:`pointer-events-none absolute top-1/2 left-3 size-3.5 -translate-y-1/2 text-muted-foreground`,"aria-hidden":!0}),(0,Q.jsx)(s,{value:a,onChange:e=>c(e.target.value),placeholder:`Search packs…`,"aria-label":`Search library`,flat:!0,className:o(Mr,`font-mono`),autoFocus:!0})]}),(0,Q.jsxs)(Dn,{items:mo,value:l,onValueChange:e=>{e==null||Array.isArray(e)||u(e===`all`?`all`:e)},children:[(0,Q.jsx)(tn,{"aria-label":`Category`,size:`sm`,className:`h-8 shrink-0 gap-1 border-0 bg-transparent px-1.5 shadow-none ring-0 text-[11px] dark:bg-transparent dark:hover:bg-transparent [&_svg:not([class*='size-'])]:size-3.5`,children:(0,Q.jsx)(Fn,{children:e=>{let t=String(e??`all`),n=t===`all`?`All`:Xa[t];return(0,Q.jsxs)(`span`,{children:[`Category · `,n]})}})}),(0,Q.jsx)(En,{align:`end`,alignItemWithTrigger:!1,className:`min-w-44`,children:(0,Q.jsx)(On,{children:mo.map(e=>(0,Q.jsx)(yn,{value:e.value,className:`text-[11px]`,children:e.label},e.value))})})]})]}),d?(0,Q.jsx)(`p`,{className:`border-b border-border/50 px-4 py-2 text-[11px] text-destructive`,role:`alert`,children:d}):null,(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:O.length===0?(0,Q.jsx)(`p`,{className:`px-4 py-8 text-center text-[11px] text-muted-foreground`,children:`No matching packs.`}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5 px-4 py-4`,children:[A.length>0?(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(yo,{children:`Popular`}),(0,Q.jsx)(`ul`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-3`,children:A.map(e=>(0,Q.jsx)(bo,{ext:e,installed:D.has(e.name),pending:p===e.name,disabled:p!==null,onAdd:()=>F(e)},e.name))})]}):null,M.map(e=>(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(yo,{children:e.label}),(0,Q.jsx)(`ul`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:e.items.map(e=>(0,Q.jsx)(xo,{ext:e,installed:D.has(e.name),pending:p===e.name,disabled:p!==null,onAdd:()=>F(e)},e.name))})]},e.category))]})})]})]})})})}function go({ext:e,plan:t,tab:n,advancedOpen:r,extraCount:i,schema:a,version:o,cascade:c,error:l,pending:u,onTab:d,onAdvanced:f,onSchema:p,onVersion:m,onCascade:h,onBack:g,onConfirm:_}){let v=Qa(e.name),y=e.name===`timescaledb`||e.name===`pg_cron`||e.name===`postgis`?po[e.name]:L;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(Te,{className:`gap-2 border-b border-border/50`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:g,className:`flex w-fit items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground`,children:[(0,Q.jsx)(q,{icon:j,className:`size-3.5`}),`Library`]}),(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`div`,{className:`flex size-9 items-center justify-center rounded-full border border-border/50 bg-muted/20`,children:(0,Q.jsx)(q,{icon:y,className:`size-4`,"aria-hidden":!0})}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(qe,{className:`text-sm`,children:[`Install `,v]}),(0,Q.jsx)(ze,{className:`text-[11px]`,children:`Review and configure this pack`})]})]})]}),(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-4 py-4`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] font-medium text-foreground`,children:`Installs`}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:`What this pack will run on the store`}),(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center gap-4`,role:`tablist`,"aria-label":`Install preview`,children:[(0,Q.jsx)(_o,{active:n===`extensions`,onClick:()=>d(`extensions`),children:`Extensions`}),(0,Q.jsx)(_o,{active:n===`sql`,onClick:()=>d(`sql`),children:`SQL`})]}),n===`extensions`?(0,Q.jsx)(`ul`,{className:`mt-3 divide-y divide-border/50 rounded-lg border border-border/50`,children:t.items.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-center justify-between gap-2 px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`font-mono text-[12px] text-foreground`,children:e.name}),e.already?(0,Q.jsx)(Co,{}):(0,Q.jsx)(Gr,{variant:`outline`,className:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[9px] font-semibold tracking-wide text-amber-800 uppercase dark:text-amber-400`,children:`Required`})]},e.name))}):(0,Q.jsx)(`pre`,{className:`mt-3 overflow-x-auto rounded-lg border border-border/50 bg-muted/15 px-3 py-2.5 font-mono text-[11px] leading-relaxed text-foreground`,children:t.sql}),t.note?(0,Q.jsx)(`p`,{className:`mt-3 text-[11px] leading-snug text-muted-foreground`,children:t.note}):null,(0,Q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-semibold tracking-[0.12em] text-muted-foreground uppercase`,children:`Options`}),(0,Q.jsx)(Ra,{open:r,extraCount:i,onOpenChange:f,controls:`sql-extension-advanced`})]}),r?(0,Q.jsxs)(`div`,{id:`sql-extension-advanced`,className:`mt-3 flex flex-col gap-3`,children:[(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1.5 block text-[10px] font-semibold tracking-[0.12em] text-muted-foreground uppercase`,children:`Schema`}),(0,Q.jsx)(s,{value:a,onChange:e=>p(e.target.value),placeholder:`engine default`,className:`h-8 font-mono text-[12px]`})]}),(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1.5 block text-[10px] font-semibold tracking-[0.12em] text-muted-foreground uppercase`,children:`Version`}),(0,Q.jsx)(s,{value:o,onChange:e=>m(e.target.value),placeholder:`packaged default`,className:`h-8 font-mono text-[12px]`})]}),(0,Q.jsxs)(`label`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-[12px] text-foreground`,children:`CASCADE`}),(0,Q.jsx)(La,{size:`sm`,checked:c,onCheckedChange:h,ariaLabel:`CASCADE required extensions`})]}),(0,Q.jsx)(`p`,{className:`text-[11px] leading-snug text-muted-foreground`,children:"`pg_catalog` is refused. Schema and version apply to this pack only."})]}):null,l?(0,Q.jsx)(`p`,{className:`mt-3 text-[11px] text-destructive`,role:`alert`,children:l}):null]}),(0,Q.jsxs)(ce,{children:[(0,Q.jsx)(kr,{split:!0,onClick:g,children:`Cancel`}),(0,Q.jsx)(kr,{variant:`default`,disabled:u,"data-slot":`extension-library-install`,"data-name":e.name,onClick:_,children:u?`Installing…`:`Install pack`})]})]})}function _o({active:e,onClick:t,children:n}){return(0,Q.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e,onClick:t,className:o(`px-2 py-1.5 text-[10px] font-semibold tracking-[0.08em] uppercase transition-colors hover:bg-muted/50`,e?`text-foreground`:`text-muted-foreground hover:text-foreground`),children:n})}function vo({name:e,title:t,className:n}){let r=Ya(e);return r?(0,Q.jsxs)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,className:o(`group/ext-link inline-flex max-w-full items-center gap-1 font-medium tracking-tight text-foreground underline-offset-2 hover:underline`,n),children:[(0,Q.jsx)(`span`,{className:`truncate`,children:t}),(0,Q.jsx)(q,{icon:c,className:`size-3 shrink-0 text-muted-foreground/50 group-hover/ext-link:text-muted-foreground`,"aria-hidden":!0})]}):(0,Q.jsx)(`p`,{className:o(`font-medium tracking-tight text-foreground`,n),children:t})}function yo({children:e}){return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-[10px] font-semibold tracking-[0.12em] text-muted-foreground uppercase`,children:e}),(0,Q.jsx)(`div`,{className:`h-px min-w-0 flex-1 bg-border/50`,"aria-hidden":!0})]})}function bo({ext:e,installed:t,pending:n,disabled:r,onAdd:i}){let a=e.name,o=Qa(e.name),s=to(e.name);return(0,Q.jsxs)(`li`,{className:`flex flex-col gap-3 rounded-xl border border-border/50 bg-muted/10 p-3`,children:[(0,Q.jsx)(`div`,{className:`flex size-8 items-center justify-center rounded-lg border border-border/40 bg-background`,children:(0,Q.jsx)(q,{icon:po[a],className:`size-4 text-foreground`,"aria-hidden":!0})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(vo,{name:e.name,title:o,className:`text-[13px]`}),(0,Q.jsx)(`p`,{className:`font-mono text-[11px] text-muted-foreground`,children:e.name}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-[11px] leading-snug text-muted-foreground`,children:e.comment}),(0,Q.jsx)(So,{tags:e.tags})]}),(0,Q.jsxs)(`div`,{className:`mt-auto flex items-end justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`text-[9px] font-semibold tracking-[0.12em] text-muted-foreground uppercase`,children:Xa[e.category]}),s?(0,Q.jsxs)(`p`,{className:`truncate text-[10px] text-muted-foreground/80`,children:[`Built by `,s]}):null]}),(0,Q.jsx)(wo,{installed:t,pending:n,disabled:r,name:e.name,onAdd:i})]})]})}function xo({ext:e,installed:t,pending:n,disabled:r,onAdd:i}){let a=to(e.name);return(0,Q.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-xl border border-border/50 px-3 py-2.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(vo,{name:e.name,title:Qa(e.name),className:`text-[13px]`}),(0,Q.jsx)(`p`,{className:`font-mono text-[11px] text-muted-foreground`,children:e.name}),(0,Q.jsx)(So,{tags:e.tags})]}),t?(0,Q.jsx)(Co,{}):null]}),(0,Q.jsx)(`p`,{className:`text-[11px] leading-snug text-muted-foreground`,children:e.comment}),e.requires&&e.requires.length>0?(0,Q.jsxs)(`p`,{className:`font-mono text-[10px] text-muted-foreground/80`,children:[`needs `,e.requires.join(` + `)]}):null,(0,Q.jsxs)(`div`,{className:`mt-auto flex items-end justify-between gap-2 pt-1`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`text-[9px] font-semibold tracking-[0.12em] text-muted-foreground uppercase`,children:Xa[e.category]}),a?(0,Q.jsxs)(`p`,{className:`truncate text-[10px] text-muted-foreground/80`,children:[`Built by `,a]}):null]}),t?null:(0,Q.jsx)(wo,{installed:!1,pending:n,disabled:r,name:e.name,onAdd:i})]})]})}function So({tags:e}){return!e||e.length===0?null:(0,Q.jsx)(`p`,{className:`mt-1 flex flex-wrap gap-1`,children:e.slice(0,4).map(e=>(0,Q.jsx)(`span`,{className:`rounded border border-border/40 px-1 py-px font-mono text-[9px] text-muted-foreground/80`,children:e},e))})}function Co(){return(0,Q.jsx)(Gr,{variant:`outline`,className:`h-5 rounded-md border-emerald-500/30 bg-emerald-500/10 px-1.5 text-[9px] font-semibold tracking-wide text-emerald-700 uppercase dark:text-emerald-400`,children:`Installed`})}function wo({installed:e,pending:t,disabled:n,name:r,onAdd:i}){return e?(0,Q.jsx)(Co,{}):(0,Q.jsx)(J,{type:`button`,size:`sm`,variant:`outline`,className:`h-7 shrink-0 px-2 text-[11px]`,disabled:n,"data-slot":`extension-library-add`,"data-name":r,onClick:i,children:t?`Installing…`:`Install`})}var To=`github-light`,Eo=`github-dark`;function Do(e){return Br.includes(e)}var Oo=new Map;function ko(e,t){return`${t}\u0000${e}`}function Ao(){let{theme:e}=Ht(),[t,n]=(0,Z.useState)(()=>e===`dark`);return(0,Z.useEffect)(()=>{let t=document.documentElement,r=()=>{if(e===`dark`){n(!0);return}if(e===`light`){n(!1);return}n(t.classList.contains(`dark`))};if(r(),e!==`system`)return;let i=window.matchMedia(`(prefers-color-scheme: dark)`);return i.addEventListener(`change`,r),()=>i.removeEventListener(`change`,r)},[e]),t}function jo(e,t){let n=ko(e,t),r=Oo.get(n),[i,a]=(0,Z.useState)(r?{key:n,code:e,language:t,lines:r}:null);return(0,Z.useEffect)(()=>{if(t===`text`||t===`diff`||!Do(t)){a({key:n,code:e,language:t,lines:[]});return}let r=Oo.get(n);if(r){a({key:n,code:e,language:t,lines:r});return}let i=!1;return Vr().then(n=>n.codeToTokensWithThemes(e,{lang:t,themes:{light:To,dark:Eo}})).then(r=>{if(i)return;let o=r.map(e=>e.map(e=>({content:e.content,offset:e.offset,light:e.variants.light?.color,dark:e.variants.dark?.color})));Oo.set(n,o),a({key:n,code:e,language:t,lines:o})}).catch(()=>{i||a({key:n,code:e,language:t,lines:[]})}),()=>{i=!0}},[e,n,t]),i?.key===n||i?.language===t&&e.startsWith(i.code)?i.lines.length===0?null:i.lines:null}function Mo({code:e,tokens:t,className:n}){let r=Ao();return(0,Q.jsx)(`code`,{className:o(`font-mono text-[inherit]`,n),children:t?t.map(e=>(0,Q.jsx)(`span`,{style:{color:(r?e.dark:e.light)??e.light??e.dark},children:e.content},`${e.offset}-${e.content}`)):e})}function No({code:e,language:t=`bash`,className:n}){let r=jo(e,t),i=0,a=e.split(`
|
|
3
3
|
`).map(e=>{let t={content:e,offset:i};return i+=e.length+1,t});return(0,Q.jsx)(`pre`,{className:o(`m-0 overflow-x-auto whitespace-pre font-mono text-xs leading-5 text-foreground/85`,n),children:a.map((e,t)=>(0,Q.jsxs)(Z.Fragment,{children:[(0,Q.jsx)(Mo,{code:e.content,tokens:r?.[t]}),t<a.length-1?`
|
|
4
4
|
`:null]},`${e.offset}-${e.content}`))})}var Po=[`INSERT`,`UPDATE`,`DELETE`],Fo=[{id:`read`,label:`Read`,icon:Je},{id:`write`,label:`Write`,icon:F},{id:`both`,label:`Both`,icon:te}];function Io({open:e,onOpenChange:t,storeRef:n,tables:r,manifest:i=null}){let c=Pa(),l=ln(e),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(`sql`),[m,h]=(0,Z.useState)(r[0]??``),[g,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(`SELECT`),[b,x]=(0,Z.useState)(`PERMISSIVE`),[S,C]=(0,Z.useState)(`true`),[w,T]=(0,Z.useState)(`true`),[E,D]=(0,Z.useState)(!0),[O,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(``),[P,F]=(0,Z.useState)(null),[I,ee]=(0,Z.useState)(!1),[L,R]=(0,Z.useState)(``),[z,B]=(0,Z.useState)([]),[ne,V]=(0,Z.useState)(()=>_n(`read`)),re=Hn(v),H=gn(v),ae=(0,Z.useMemo)(()=>dn(i,n,m),[i,n,m]),se=(0,Z.useMemo)(()=>ae.map(e=>e.sqlName),[ae]),le=Vn(se),ue=g!==``&&se.includes(g)?g:le??``,de=P!==null&&bn(xn.find(e=>e.id===P)??{})||H.using&&on(S)||H.withCheck&&on(w),fe=se.length>0&&de,pe=(H.using&&sn(S)||H.withCheck&&sn(w))&&ue===``,me=(0,Z.useMemo)(()=>Rn(rr(i),l.data??null),[i,l.data]),U=(0,Z.useMemo)(()=>({gates:z,actions:ne,roles:[]}),[z,ne]),he=(0,Z.useMemo)(()=>{try{let e=Yn({name:u||`policy_name`,table:m||`table`,command:v,behavior:b,roles:`public`,using:H.using?S:``,withCheck:H.withCheck?w:``});return{sql:vn(e,E),code:hn(e)}}catch{return null}},[u,m,v,b,H,S,w,E]),ge=(e,t)=>t===``?e:ir(e,t),_e=e=>{let t=bn(e)?ue:``;F(e.id),d(e.name),y(e.command),x(e.behavior??`PERMISSIVE`),V(t=>Mn(t,e.command)),C(ge(e.using??`true`,t)),T(ge(e.withCheck??`true`,t)),t!==``&&_(t)},ve=e=>{let t=mn(i,n,e),r=(g!==``&&t.includes(g)?g:null)??Vn(t)??``;h(e),_(r);let a=ue||`owner`;C(e=>cn(e,a,r)),T(e=>cn(e,a,r))},ye=e=>{let t=ue||`owner`;_(e),C(n=>cn(n,t,e)),T(n=>cn(n,t,e))},be=e=>{let t=Sn(e,v);y(t),V(_n(e)),B([])},xe=e=>{y(e),V(t=>Mn(t,e))},Se=e=>{B(t=>{let n=t.includes(e)?t.filter(t=>t!==e):[...t,e],r=nn(n);return C(r),T(r),n})},Ce=async()=>{if(k(null),pe){k(`Pick a column on ${m} that stores the user id.`);return}try{let e=Yn({name:u,table:m,command:v,behavior:b,roles:`public`,using:H.using?S:``,withCheck:H.withCheck?w:``});await c.mutateAsync({ref:n,child:`policies`,id:`${e.table}:${e.name}`,patch:{create:!0,name:e.name,table:e.table,command:e.command,behavior:e.behavior,roles:e.roles.join(`, `),...e.using===void 0?{}:{using:e.using},...e.withCheck===void 0?{}:{withCheck:e.withCheck},enableRls:E},commit:!0}),t(!1)}catch(e){k(e instanceof Error?e.message:String(e))}};return(0,Q.jsx)(W,{open:e,onOpenChange:e=>{e||ee(!1),t(e)},children:(0,Q.jsxs)(G,{side:`right`,showCloseButton:!1,className:`flex-col gap-0 overflow-hidden rounded-none bg-popover p-0 shadow-lg sm:flex-row sm:items-stretch data-[side=right]:w-auto data-[side=right]:max-w-[calc(100vw-1.5rem)] data-[side=right]:sm:max-w-none`,"data-slot":`rls-policy-sheet`,children:[(0,Q.jsxs)(`div`,{className:`relative flex min-h-0 w-full flex-1 flex-col sm:w-[28rem] sm:flex-none`,"data-slot":`rls-policy-form-sheet`,children:[(0,Q.jsxs)(Te,{className:`flex-row items-stretch gap-0 border-b border-border/60 p-0`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3 p-4`,children:[(0,Q.jsx)(`div`,{className:`flex size-9 items-center justify-center rounded-full border border-border/50 bg-muted/20`,children:(0,Q.jsx)(q,{icon:te,className:`size-4`,"aria-hidden":!0})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(qe,{className:`text-sm`,children:`Create policy`}),(0,Q.jsx)(ze,{className:`text-[11px]`,children:"Review the `CREATE POLICY` SQL before it runs"})]})]}),(0,Q.jsx)(`span`,{className:`w-px shrink-0 self-stretch bg-border/60`,"aria-hidden":!0}),(0,Q.jsxs)(ie,{className:o(oe,`min-w-11`),"data-slot":`rls-policy-form-close`,"aria-label":`Close`,children:[(0,Q.jsx)(q,{icon:a,className:`size-4`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]}),(0,Q.jsxs)(dr,{orientation:`vertical`,className:`min-h-0 flex-1`,children:[(0,Q.jsx)(hr,{defaultSize:`68%`,minSize:`28%`,className:`min-h-0`,children:(0,Q.jsxs)(`div`,{className:`h-full min-h-0 overflow-y-auto`,"data-slot":`rls-policy-form-scroll`,children:[(0,Q.jsxs)(`div`,{className:`border-b border-border/50`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-4 pt-2.5`,children:[(0,Q.jsx)(`p`,{className:`text-[10px] font-semibold tracking-[0.12em] text-muted-foreground uppercase`,children:`Policy name`}),(0,Q.jsxs)(jr,{active:I,"aria-expanded":I,"aria-controls":I?`rls-policy-templates-sheet`:void 0,onClick:()=>ee(e=>!e),children:[(0,Q.jsx)(q,{icon:Qe,className:`size-3`,"aria-hidden":!0}),`Templates`]})]}),(0,Q.jsx)(s,{value:u,onChange:e=>d(e.target.value),placeholder:`read_all`,"aria-label":`Policy name`,flat:!0,className:o(X,`font-mono`)})]}),(0,Q.jsxs)(Er,{children:[(0,Q.jsx)(Y,{label:`Table`,split:`start`,children:(0,Q.jsxs)(Oa,{value:m,onValueChange:ve,children:[(0,Q.jsx)(ka,{flat:!0,className:o(X,`font-mono`),children:(0,Q.jsx)(Aa,{placeholder:`Select a table`})}),(0,Q.jsx)(ja,{children:r.map(e=>(0,Q.jsx)(Ma,{value:e,className:`font-mono text-[12px]`,children:e},e))})]})}),(0,Q.jsx)(Y,{label:`Behavior`,split:`end`,children:(0,Q.jsxs)(Oa,{value:b,onValueChange:e=>x(e),children:[(0,Q.jsx)(ka,{flat:!0,className:X,children:(0,Q.jsx)(Aa,{})}),(0,Q.jsxs)(ja,{children:[(0,Q.jsx)(Ma,{value:`PERMISSIVE`,children:`Permissive`}),(0,Q.jsx)(Ma,{value:`RESTRICTIVE`,children:`Restrictive`})]})]})})]}),(0,Q.jsx)(Or,{label:`Gate`,hint:`Who this policy pairs with`}),(0,Q.jsx)(zo,{advanced:A,onAdvancedChange:j,mode:re,onModeChange:be,catalog:me,query:L,onQueryChange:R,selection:U,onToggleGate:Se}),A||re===`write`?(0,Q.jsx)(Yo,{commands:A?ar:Po,value:v,onChange:xe}):null,(0,Q.jsx)(Or,{label:`Rows`,hint:H.using&&H.withCheck?`Existing rows and new rows`:H.withCheck?`New rows`:`Existing rows`}),fe?(0,Q.jsx)(Y,{label:`Column`,hint:`compared to oke.user()`,children:(0,Q.jsxs)(Oa,{value:ue,onValueChange:ye,children:[(0,Q.jsx)(ka,{flat:!0,className:o(X,`font-mono`),"data-slot":`rls-identity-column`,children:(0,Q.jsx)(Aa,{placeholder:`Select a column`})}),(0,Q.jsx)(ja,{children:ae.map(e=>(0,Q.jsx)(Ma,{value:e.sqlName,children:(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(zi,{primaryKey:e.primaryKey,foreignKey:e.foreignKey,unique:e.unique,inferred:e.inferred}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[12px]`,children:e.sqlName})]})},e.sqlName))})]})}):null,H.using?(0,Q.jsx)(Y,{label:`USING`,children:(0,Q.jsx)(s,{value:S,onChange:e=>C(e.target.value),placeholder:`true`,flat:!0,className:o(X,`font-mono`)})}):null,H.withCheck?(0,Q.jsx)(Y,{label:`WITH CHECK`,children:(0,Q.jsx)(s,{value:w,onChange:e=>T(e.target.value),placeholder:`true`,flat:!0,className:o(X,`font-mono`)})}):null]})}),(0,Q.jsx)(br,{withHandle:!0,"data-slot":`rls-policy-sql-handle`}),(0,Q.jsx)(hr,{defaultSize:`32%`,minSize:`16%`,className:`min-h-0`,children:(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-muted/15`,"data-slot":`rls-policy-sql-dock`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-4 py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,className:o(`text-[10px] font-semibold tracking-[0.12em] uppercase`,f===`sql`?`text-foreground`:`text-muted-foreground`),onClick:()=>p(`sql`),children:`SQL`}),(0,Q.jsx)(`button`,{type:`button`,className:o(`text-[10px] font-semibold tracking-[0.12em] uppercase`,f===`code`?`text-foreground`:`text-muted-foreground`),onClick:()=>p(`code`),children:`Code`})]}),(0,Q.jsxs)(`label`,{className:`inline-flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Enable RLS`}),(0,Q.jsx)(La,{size:`sm`,checked:E,onCheckedChange:D,ariaLabel:`Enable RLS on this table`})]})]}),he?(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 pb-3`,children:(0,Q.jsx)(No,{code:f===`sql`?he.sql:he.code,language:f===`sql`?`sql`:`typescript`,className:`overflow-visible whitespace-pre-wrap break-words text-[11px] leading-relaxed`})}):(0,Q.jsx)(`p`,{className:`min-h-0 flex-1 px-4 pb-3 text-[11px] text-muted-foreground`,children:`Fill name, table, and an expression.`}),pe?(0,Q.jsxs)(Nr,{slot:`rls-owner-missing`,children:[`Pick a column on `,m,` — this table has no owner / owner_email / creator_email guess.`]}):null,O?(0,Q.jsx)(Nr,{children:O}):null]})})]}),(0,Q.jsxs)(ce,{children:[(0,Q.jsx)(kr,{split:!0,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsx)(kr,{variant:`default`,disabled:c.isPending||!he||pe,onClick:()=>void Ce(),children:c.isPending?`Creating…`:`Create policy`})]})]}),I?(0,Q.jsx)(`aside`,{id:`rls-policy-templates-sheet`,className:`flex h-80 w-full shrink-0 flex-col border-t border-border/50 sm:h-auto sm:w-80 sm:border-t-0 sm:border-l`,"data-slot":`rls-policy-templates-sheet`,children:(0,Q.jsx)(Ro,{query:M,onQueryChange:N,selectedId:P,onSelect:_e,onClose:()=>ee(!1)})}):null]})})}var Lo={SELECT:`bg-emerald-500/15 text-emerald-800 dark:text-emerald-300`,INSERT:`bg-amber-500/15 text-amber-800 dark:text-amber-300`,UPDATE:`bg-sky-500/15 text-sky-800 dark:text-sky-300`,DELETE:`bg-rose-500/15 text-rose-800 dark:text-rose-300`,ALL:`bg-muted text-muted-foreground`};function Ro({query:e,onQueryChange:t,selectedId:n,onSelect:r,onClose:i}){let c=an(xn,e);return(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-slot":`rls-policy-templates`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-stretch border-b border-border/60`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`px-3 pt-2.5 text-[10px] font-semibold tracking-[0.12em] text-muted-foreground uppercase`,children:`Templates`}),(0,Q.jsxs)(`label`,{className:`relative block`,children:[(0,Q.jsx)(q,{icon:ee,className:`pointer-events-none absolute top-1/2 left-3 size-3.5 -translate-y-1/2 text-muted-foreground`,"aria-hidden":!0}),(0,Q.jsx)(s,{value:e,onChange:e=>t(e.target.value),placeholder:`Search templates`,"aria-label":`Search templates`,flat:!0,className:o(Mr,`font-mono`)})]})]}),(0,Q.jsx)(`span`,{className:`w-px shrink-0 self-stretch bg-border/60`,"aria-hidden":!0}),(0,Q.jsx)(`button`,{type:`button`,className:o(oe,`min-w-11`),onClick:i,"aria-label":`Close templates`,"data-slot":`rls-policy-templates-close`,children:(0,Q.jsx)(q,{icon:a,className:`size-4`,"aria-hidden":!0})})]}),(0,Q.jsx)(`ul`,{className:`min-h-0 flex-1 overflow-y-auto p-2`,children:c.length===0?(0,Q.jsx)(`li`,{className:`px-2 py-3 text-[10px] text-muted-foreground`,children:`No matching templates.`}):c.map(e=>{let t=e.id===n;return(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>r(e),className:o(`flex w-full flex-col gap-1.5 rounded-lg px-2.5 py-2 text-left`,t?`bg-muted ring-1 ring-foreground`:`hover:bg-muted/50`),children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:o(`rounded px-1.5 py-px font-mono text-[9px] font-semibold tracking-wide`,Lo[e.command]),children:e.command}),e.behavior===`RESTRICTIVE`?(0,Q.jsx)(`span`,{className:`rounded border border-border/60 px-1 py-px text-[9px] font-semibold tracking-[0.08em] text-muted-foreground uppercase`,children:`Restrictive`}):null,t?(0,Q.jsx)(q,{icon:Ae,className:`ml-auto size-3.5 shrink-0`}):null]}),(0,Q.jsx)(`span`,{className:`text-[12px] font-medium text-foreground`,children:e.title}),(0,Q.jsx)(`span`,{className:`text-[10px] leading-snug text-muted-foreground`,children:e.detail})]})},e.id)})})]})}function zo({advanced:e,onAdvancedChange:t,mode:n,onModeChange:r,catalog:i,query:a,onQueryChange:s,selection:c,onToggleGate:l}){let u=or(c);return(0,Q.jsxs)(`div`,{className:o(!e&&`border-b border-border/50`),children:[(0,Q.jsx)(Bo,{mode:n,onChange:r,advanced:e,extraCount:u,onAdvancedChange:t}),e?(0,Q.jsx)(Uo,{catalog:i,query:a,onQueryChange:s,selection:c,onToggleGate:l}):null]})}function Bo({mode:e,onChange:t,advanced:n,extraCount:r,onAdvancedChange:i}){let a=(0,Z.useId)(),s=Ft();return(0,Q.jsx)(Yi,{id:a,children:(0,Q.jsxs)(`div`,{role:`group`,"aria-label":`Gate`,className:o(`flex w-full items-center`,n&&`border-b border-border/50`),children:[Fo.map(r=>{let a=!n&&e===r.id;return(0,Q.jsxs)(Vo,{active:a,reduceMotion:s,onClick:()=>{i(!1),t(r.id)},children:[(0,Q.jsx)(q,{icon:r.icon,className:`size-3.5`,"aria-hidden":!0}),r.label]},r.id)}),(0,Q.jsxs)(Vo,{active:n,reduceMotion:s,"aria-expanded":n,"aria-controls":`rls-gate-advanced`,onClick:()=>i(!n),children:[(0,Q.jsx)(q,{icon:Ee,className:`size-3.5`,"aria-hidden":!0}),`Advanced`,r>0?(0,Q.jsx)(`span`,{className:`flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-foreground/10 px-1 text-[9px] font-semibold tabular-nums`,children:r}):null]})]})})}function Vo({active:e,reduceMotion:t,onClick:n,children:r,...i}){return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":e,onClick:n,className:o(`relative inline-flex h-8 min-w-0 flex-1 items-center justify-center gap-1.5 overflow-hidden rounded-none px-2 text-[11px] font-medium outline-none select-none`,`focus-visible:ring-2 focus-visible:ring-ring/50`,e?`text-foreground`:`text-muted-foreground hover:bg-muted/50 hover:text-foreground`),...i,children:[e?(0,Q.jsx)(It.span,{layoutId:`rls-gate-pill`,className:`absolute inset-0 z-0 bg-muted`,style:{borderRadius:0},transition:t?{duration:0}:Dt}):null,(0,Q.jsx)(`span`,{className:`relative z-10 inline-flex items-center gap-1.5`,children:r})]})}var Ho={SELECT:`USING on existing rows`,INSERT:`WITH CHECK on new rows`,UPDATE:`USING and WITH CHECK`,DELETE:`USING on existing rows`,ALL:`Every command`};function Uo({catalog:e,query:t,onQueryChange:n,selection:r,onToggleGate:i}){let c=Wn(e,t),l=Ln(c),u=kn(c),d=t.trim()!==``;return(0,Q.jsxs)(`div`,{id:`rls-gate-advanced`,className:`flex flex-col`,children:[(0,Q.jsxs)(`label`,{className:`relative block border-b border-border/50`,children:[(0,Q.jsx)(q,{icon:ee,className:`pointer-events-none absolute top-1/2 left-4 size-3.5 -translate-y-1/2 text-muted-foreground`,"aria-hidden":!0}),(0,Q.jsx)(s,{value:t,onChange:e=>n(e.target.value),placeholder:`Search policy or scope`,"aria-label":`Search policy or scope`,flat:!0,className:o(Mr,`font-mono`)})]}),r.gates.length>0?(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1 border-b border-border/50 px-4 py-1.5`,children:r.gates.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>i(e),className:`inline-flex items-center gap-1 rounded-md bg-muted px-1.5 py-0.5 font-mono text-[10px] text-foreground hover:bg-muted/70`,"aria-label":`Remove ${e}`,children:[e,(0,Q.jsx)(q,{icon:a,className:`size-2.5`,"aria-hidden":!0})]},e))}):null,(0,Q.jsxs)(Wo,{empty:d?`No matches.`:`No policy or scope gates declared.`,hasRows:l.length+u.length>0,children:[l.length>0?(0,Q.jsx)(Go,{label:`Policy`,hint:`gate.policy`}):null,l.map(e=>(0,Q.jsx)(Ko,{icon:qo(e.variant),label:e.name,detail:Jo(e),selected:r.gates.includes(e.name),onSelect:()=>i(e.name),pressed:!0},e.name)),u.length>0?(0,Q.jsx)(Go,{label:`Scope`,hint:`gate.scope`}):null,u.map(e=>(0,Q.jsx)(Ko,{icon:qo(e.variant),label:e.name,detail:Jo(e),selected:r.gates.includes(e.name),onSelect:()=>i(e.name),pressed:!0},e.name))]})]})}function Wo({empty:e,hasRows:t,children:n}){return t?(0,Q.jsx)(`ul`,{className:`max-h-40 overflow-y-auto border-b border-border/50`,children:n}):(0,Q.jsx)(`p`,{className:`border-b border-border/50 px-4 py-3 text-[10px] text-muted-foreground`,children:e})}function Go({label:e,hint:t}){return(0,Q.jsx)(`li`,{className:`sticky top-0 z-10 border-b border-border/50 bg-muted/80 px-4 py-1 backdrop-blur-sm`,children:(0,Q.jsxs)(`p`,{className:`flex items-baseline gap-2 text-[10px] font-semibold tracking-[0.08em] text-muted-foreground uppercase`,children:[e,(0,Q.jsx)(`span`,{className:`font-mono font-normal tracking-normal text-muted-foreground/70 lowercase`,children:t})]})})}function Ko({icon:e,label:t,detail:n,selected:r,onSelect:i,pressed:a=!1}){return(0,Q.jsx)(`li`,{className:`border-b border-border/50 last:border-b-0`,children:(0,Q.jsxs)(`button`,{type:`button`,role:a?`checkbox`:`radio`,"aria-checked":r,"aria-pressed":a?r:void 0,onClick:i,className:o(`flex w-full items-start gap-2 px-4 py-1.5 text-left`,r?`bg-muted`:`hover:bg-muted/40`),children:[(0,Q.jsx)(`span`,{className:o(`mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-sm`,r?`bg-foreground text-background`:`bg-muted text-muted-foreground`),"aria-hidden":!0,children:(0,Q.jsx)(q,{icon:e,className:`size-3`})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block truncate font-mono text-[12px] font-medium text-foreground`,children:t}),(0,Q.jsx)(`span`,{className:`mt-0.5 block text-[10px] leading-snug text-muted-foreground`,children:n})]}),r?(0,Q.jsx)(q,{icon:Ae,className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":!0}):null]})})}function qo(e){return e===`public`?le:e===`scope`?$e:te}function Jo(e){return e.description?e.description:e.variant===`public`?`Intentionally unauthenticated`:e.variant===`scope`?`auth.scopes.has("${e.name}")`:`ABAC policy`}function Yo({commands:e,value:t,onChange:n}){return(0,Q.jsx)(Ar,{label:`FOR`,hint:Ho[t],children:e.map(e=>(0,Q.jsx)(Tr,{active:t===e,onClick:()=>n(e),children:e},e))})}function Xo(e){if(!e.error)return null;let t=e.error.data,n=t&&typeof t==`object`&&`ref`in t&&typeof t.ref==`string`?t.ref:null,r=Error(n??e.error.message??e.error.code);return r.code=e.error.code,r.data=e.error.data,r}function Zo(){return it({mutationFn:async e=>{let n=await t(e),r=Xo(n);if(r)throw r;if(!n.data)throw Error(`Empty SQL result`);return n.data}})}function Qo({value:e,onChange:t,label:n,className:r,onSubmit:i}){let a=(0,Z.useRef)(null),s=(0,Z.useRef)(null),c=e.endsWith(`
|
|
@@ -31,7 +31,8 @@ LANGUAGE sql STABLE AS $$
|
|
|
31
31
|
WHEN current_setting('oke.scopes', true) IN ('') THEN false
|
|
32
32
|
ELSE jsonb_exists(current_setting('oke.scopes', true)::jsonb, p_scope)
|
|
33
33
|
END
|
|
34
|
-
$$`,`
|
|
34
|
+
$$`,`CREATE OR REPLACE FUNCTION oke.tenant() RETURNS text
|
|
35
|
+
LANGUAGE sql STABLE AS $$ SELECT current_setting('oke.tenant', true) $$`,`DO $oke_rls_role$
|
|
35
36
|
BEGIN
|
|
36
37
|
CREATE ROLE ${wn} NOSUPERUSER NOBYPASSRLS NOLOGIN;
|
|
37
38
|
EXCEPTION
|