@lunora/studio 1.0.0-alpha.224 → 1.0.0-alpha.226

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/index.d.mts +7 -0
  2. package/dist/index.d.ts +7 -0
  3. package/dist/index.mjs +1 -1
  4. package/dist/packem_chunks/FileBrowser.mjs +4 -4
  5. package/dist/packem_chunks/SchemaViewer.mjs +1 -1
  6. package/dist/packem_chunks/TableEditor.mjs +1 -1
  7. package/dist/packem_chunks/permissions-panel.mjs +1 -1
  8. package/dist/packem_chunks/vector-browser.mjs +1 -1
  9. package/dist/packem_chunks/workflows-panel.mjs +1 -1
  10. package/dist/packem_shared/DataBrowser-B5Sl4vMa.mjs +4 -0
  11. package/dist/packem_shared/DataFilters-CYZFt2EK.mjs +1 -0
  12. package/dist/packem_shared/{GlobalDataBrowser-CR138dEZ.mjs → GlobalDataBrowser-BzhSVDvF.mjs} +1 -1
  13. package/dist/packem_shared/table-list-sidebar-CYRSPLIv.mjs +1 -0
  14. package/dist/standalone/{chunk-GFB3DJBT.js → chunk-224DF7HD.js} +1 -1
  15. package/dist/standalone/{chunk-WM5HSIP3.js → chunk-2AGQJ3RT.js} +1 -1
  16. package/dist/standalone/{chunk-QOQ56UE7.js → chunk-2ZMIQJFC.js} +1 -1
  17. package/dist/standalone/{chunk-NHLLFFXW.js → chunk-37TUKSUI.js} +1 -1
  18. package/dist/standalone/{chunk-FZAGSACU.js → chunk-3KA25M2D.js} +1 -1
  19. package/dist/standalone/{chunk-I7GBAQ72.js → chunk-3WDNFRIY.js} +1 -1
  20. package/dist/standalone/{chunk-VVQBWSND.js → chunk-56GQC4TY.js} +1 -1
  21. package/dist/standalone/{chunk-KJOMRSX7.js → chunk-5DXMAKEG.js} +1 -1
  22. package/dist/standalone/{chunk-G6JWVIBX.js → chunk-5TBTVXMF.js} +1 -1
  23. package/dist/standalone/{chunk-IL34SD2J.js → chunk-6CP4FGVV.js} +1 -1
  24. package/dist/standalone/{chunk-FMEXQNO7.js → chunk-6I6SDCXD.js} +1 -1
  25. package/dist/standalone/{chunk-Q5H5UZCT.js → chunk-6OQCFS5H.js} +1 -1
  26. package/dist/standalone/{chunk-E6YTK54J.js → chunk-6QBEY5L3.js} +1 -1
  27. package/dist/standalone/{chunk-27ILKCWI.js → chunk-6R3CL5GW.js} +1 -1
  28. package/dist/standalone/{chunk-SB535MB2.js → chunk-AM3Q2SY4.js} +1 -1
  29. package/dist/standalone/{chunk-CFYXGSV3.js → chunk-AOSUYLNV.js} +1 -1
  30. package/dist/standalone/{chunk-JL7WQ35Y.js → chunk-BDNFSPL2.js} +1 -1
  31. package/dist/standalone/{chunk-UWHH6R7J.js → chunk-IKFXSK5G.js} +1 -1
  32. package/dist/standalone/{chunk-OMTRTMGC.js → chunk-INWZFRAK.js} +1 -1
  33. package/dist/standalone/{chunk-PCYB6Q5V.js → chunk-IU6UCL3Z.js} +1 -1
  34. package/dist/standalone/{chunk-EVGASJNW.js → chunk-JH4ISCW2.js} +1 -1
  35. package/dist/standalone/chunk-JJGVOQY3.js +5 -0
  36. package/dist/standalone/{chunk-WQ6OGGRQ.js → chunk-JPQR4RYQ.js} +1 -1
  37. package/dist/standalone/{chunk-WXDKJUXF.js → chunk-JSVP2IDG.js} +1 -1
  38. package/dist/standalone/{chunk-QWBMBXUI.js → chunk-JYEDDOSG.js} +1 -1
  39. package/dist/standalone/{chunk-RFNTIPZM.js → chunk-JYP5EIUU.js} +1 -1
  40. package/dist/standalone/{chunk-FQEKYLWQ.js → chunk-KCQSTV6F.js} +1 -1
  41. package/dist/standalone/{chunk-WRSH2CJD.js → chunk-KDBCB6FG.js} +1 -1
  42. package/dist/standalone/chunk-KZW3DDZ5.js +1 -0
  43. package/dist/standalone/{chunk-3UW7JOCC.js → chunk-LZZWCAZX.js} +1 -1
  44. package/dist/standalone/chunk-MZP4J6RB.js +1 -0
  45. package/dist/standalone/{chunk-4YXKODH3.js → chunk-NXN6ZECT.js} +1 -1
  46. package/dist/standalone/{chunk-WLLOZ3HS.js → chunk-OQWQT3II.js} +1 -1
  47. package/dist/standalone/{chunk-KTBJ5SQO.js → chunk-OT2A56S3.js} +1 -1
  48. package/dist/standalone/chunk-P5RFX2G3.js +1 -0
  49. package/dist/standalone/{chunk-74CQY3AB.js → chunk-P6ONKKHY.js} +1 -1
  50. package/dist/standalone/{chunk-OBUY7UZO.js → chunk-PITC2AP5.js} +1 -1
  51. package/dist/standalone/{chunk-2LJKZSU4.js → chunk-Q4WSPRIT.js} +1 -1
  52. package/dist/standalone/{chunk-GQWFRBCJ.js → chunk-QDAW2ZP3.js} +1 -1
  53. package/dist/standalone/chunk-RATPWNIM.js +9 -0
  54. package/dist/standalone/chunk-RT6BD4RL.js +1 -0
  55. package/dist/standalone/{chunk-INHSAPFB.js → chunk-RTCWTRPH.js} +1 -1
  56. package/dist/standalone/{chunk-S6ZFBF3S.js → chunk-S54AMHYS.js} +1 -1
  57. package/dist/standalone/{chunk-3G3KM5QW.js → chunk-SERBKIWI.js} +1 -1
  58. package/dist/standalone/{chunk-D6Z2ZUU7.js → chunk-TL5ZV6DR.js} +1 -1
  59. package/dist/standalone/{chunk-KME5TGGZ.js → chunk-TP7KHFWY.js} +1 -1
  60. package/dist/standalone/{chunk-UTIAX6IO.js → chunk-VNWWQQJR.js} +1 -1
  61. package/dist/standalone/{chunk-RK5UUSYK.js → chunk-W3A4SIKT.js} +1 -1
  62. package/dist/standalone/{chunk-SL2WTTEZ.js → chunk-WGN2KDQO.js} +1 -1
  63. package/dist/standalone/{chunk-SWS6R7OJ.js → chunk-WTBOHRI6.js} +1 -1
  64. package/dist/standalone/chunk-WWH4SBK2.js +4 -0
  65. package/dist/standalone/{chunk-TSNKMJKC.js → chunk-XBVXA2OK.js} +1 -1
  66. package/dist/standalone/{chunk-7FTSNUL7.js → chunk-XD7F5ZP5.js} +1 -1
  67. package/dist/standalone/{chunk-7UHE2RRI.js → chunk-XNWVQHXW.js} +1 -1
  68. package/dist/standalone/{chunk-2OW5U2BZ.js → chunk-YD77YQGV.js} +1 -1
  69. package/dist/standalone/{chunk-KDY4VSAF.js → chunk-ZA3NKULE.js} +1 -1
  70. package/dist/standalone/studio.js +1 -1
  71. package/dist/styles.css +1 -1
  72. package/package.json +3 -3
  73. package/dist/packem_shared/DataBrowser-DWSaSSRj.mjs +0 -4
  74. package/dist/packem_shared/DataFilters-Cocu-WWE.mjs +0 -1
  75. package/dist/packem_shared/table-list-sidebar-DxvakjpR.mjs +0 -1
  76. package/dist/standalone/chunk-2ZFFWSLG.js +0 -1
  77. package/dist/standalone/chunk-3EDFZHY5.js +0 -5
  78. package/dist/standalone/chunk-DG5KSS6E.js +0 -1
  79. package/dist/standalone/chunk-EBNWZ33C.js +0 -1
  80. package/dist/standalone/chunk-FS4K5TEX.js +0 -1
  81. package/dist/standalone/chunk-NZKXQEZ5.js +0 -9
  82. package/dist/standalone/chunk-OIHA5CMU.js +0 -4
@@ -1,4 +0,0 @@
1
- import{c as B}from"react/compiler-runtime";import{useLunora as ct}from"@lunora/react";import{useState as P,useEffect as Be,useMemo as Et,useRef as We,useCallback as at}from"react";import{ShardInput as Bn}from"./ShardInput-C6mjgAh4.mjs";import{u as Ye}from"./use-admin-query-tlBof8Yg.mjs";import{ADMIN_FUNCTIONS as xe}from"./ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{b as Zt}from"./browser-storage-BH1MxLZs.mjs";import{f as Ce,k as Fe,j as en,b as Vt,c as Ee,d as Te,n as jn,h as zn}from"./internal-Df43vQI0.mjs";import{m as qn,c as tn,d as wt,a as Kn,u as yt,b as Gn,T as Jn,D as Wn}from"./table-list-sidebar-DxvakjpR.mjs";import{u as Hn}from"./use-sql-assistant-pjfGp-Ol.mjs";import{d as $t,i as nn,e as on,a as Un}from"./wire-codec-Bk4XZGE4.mjs";import{B as Ct}from"./button-q0UYSmrn.mjs";import{I as Qn}from"./input-CXhxesPC.mjs";import{L as Bt}from"./label-DKFzyHq6.mjs";import{M as dt}from"./modal-shell-CDztwLnv.mjs";import{useT as we}from"./DEFAULT_LOCALE-A1Yg5ORA.mjs";import{jsx as d,jsxs as E,Fragment as Xe}from"react/jsx-runtime";import{ConfirmButton as jt}from"./ConfirmButton-DU4p72Er.mjs";import{E as Yn}from"./empty-state-D7jEML_T.mjs";import{C as _t,a as De}from"./control-button-BOZ5K-FC.mjs";import{tableFeatures as Xn,sortFn_text as Zn,sortFn_datetime as eo,sortFn_basic as to,sortFn_alphanumeric as no,rowSortingFeature as oo,rowSelectionFeature as so,columnVisibilityFeature as lo,columnSizingFeature as ro,columnResizingFeature as ao,columnOrderingFeature as io,createSortedRowModel as co,useTable as uo,flexRender as fo}from"@tanstack/react-table";import{useVirtualizer as mo}from"@tanstack/react-virtual";import{C as Dt}from"./checkbox-CnS9cyCz.mjs";import{c as it}from"./utils-bhneXptQ.mjs";import{f as go}from"./virtual-rect-D_j7aLxX.mjs";import{C as Nt,G as po,T as bo}from"./data-grid-DIiNmDR9.mjs";import{DataFilters as ho,toFilterClauses as Oe}from"./DataFilters-Cocu-WWE.mjs";import{G as xo,C as vo}from"./grid-features-OVIMIQan.mjs";import{G as wo}from"./grid-pagination-DgzyzfBh.mjs";import zt from"./useDebounced-DVeQ5-oW.mjs";import{r as yo,l as Co}from"./shard-history-CaO3C4KQ.mjs";const No=s=>({tables:Object.entries(s).map(([e,n])=>({fields:n.map(o=>o.name),indexes:[],name:e,relations:n.filter(o=>o.ref!==void 0).map(o=>({field:o.name,kind:"one",name:o.name,onDelete:o.onDelete,references:o.ref,table:e}))}))}),So=s=>{const e=new Map,n=new Set;for(const o of s.tables)for(const t of o.relations){if(t.kind!=="one"||t.onDelete==="set null")continue;const c=t.references,l=`${c}\0${o.name}\0${t.field}`;if(n.has(l))continue;n.add(l);const r=e.get(c)??[];r.push({...t,table:o.name}),e.set(c,r)}return e},ko=(s,e)=>{const n=[],o=[s];for(;o.length>0;){const t=o.shift();if(t===void 0)break;e(t)&&n.push(t);for(const c of t.children)o.push(c)}return n},qt=(s,e)=>{const n=[];for(const[o,t]of Object.entries(e))for(const c of t)c.ref===s&&n.push({column:c.name,table:o});return n.sort((o,t)=>o.table.localeCompare(t.table)||o.column.localeCompare(t.column)),n},Pt=s=>`${s.table}.${s.column}`,To=s=>{const e=B(111),{columns:n,onApply:o,onClose:t,shardKey:c,table:l,total:r,uniqueColumns:a}=s,i=we(),[f,m]=P(n[0]??""),[p,b]=P("");let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=ie=>{m(ie.target.value)},e[0]=u):u=e[0];const g=u;let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=ie=>{b(ie.target.value)},e[1]=h):h=e[1];const x=h;let v;e[2]!==p?(v=p.trim(),e[2]=p,e[3]=v):v=e[3];const y=v==="";let N,C;if(e[4]!==y||e[5]!==i||e[6]!==p){if(!y)try{C=$t(JSON.parse(p))}catch(ie){N=i("Invalid JSON: {message}",{message:ie.message})}e[4]=y,e[5]=i,e[6]=p,e[7]=N,e[8]=C}else N=e[7],C=e[8];let k;e[9]!==f||e[10]!==r||e[11]!==a?(k=a.has(f)&&r>1,e[9]=f,e[10]=r,e[11]=a,e[12]=k):k=e[12];const S=k,w=f!==""&&!y&&N===void 0&&!S;let T;e[13]!==w||e[14]!==f||e[15]!==o||e[16]!==t||e[17]!==C?(T=()=>{w&&(o({[f]:C}),t())},e[13]=w,e[14]=f,e[15]=o,e[16]=t,e[17]=C,e[18]=T):T=e[18];const F=T;let R;e[19]!==i?(R=i("Set a column on matching rows"),e[19]=i,e[20]=R):R=e[20];let _;e[21]!==i?(_=i("Set a column on matching rows"),e[21]=i,e[22]=_):_=e[22];let $;e[23]!==_?($=d("h3",{className:"text-base text-foreground","data-testid":"bulk-patch-title",children:_}),e[23]=_,e[24]=$):$=e[24];let I;e[25]!==i||e[26]!==l||e[27]!==r?(I=i("Writes {total} rows of {table} through the schema-aware writer — validators and indexes apply, exactly like a mutation.",{table:l,total:r.toString()}),e[25]=i,e[26]=l,e[27]=r,e[28]=I):I=e[28];let L;e[29]!==I?(L=d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-desc",children:I}),e[29]=I,e[30]=L):L=e[30];let D;e[31]!==c||e[32]!==i?(D=c===""?i("Shard: root"):i("Shard: {shardKey} — rows in other shards are not touched.",{shardKey:c}),e[31]=c,e[32]=i,e[33]=D):D=e[33];let V;e[34]!==D?(V=d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-shard",children:D}),e[34]=D,e[35]=V):V=e[35];let G;e[36]!==L||e[37]!==V||e[38]!==$?(G=E("div",{className:"flex flex-col gap-0.5",children:[$,L,V]}),e[36]=L,e[37]=V,e[38]=$,e[39]=G):G=e[39];let q;e[40]!==i?(q=i("Close"),e[40]=i,e[41]=q):q=e[41];let O;e[42]!==t||e[43]!==q?(O=d(Ct,{"data-testid":"bulk-patch-close",onClick:t,size:"xs",variant:"ghost",children:q}),e[42]=t,e[43]=q,e[44]=O):O=e[44];let J;e[45]!==G||e[46]!==O?(J=E("div",{className:"flex items-start justify-between",children:[G,O]}),e[45]=G,e[46]=O,e[47]=J):J=e[47];let K;e[48]!==i?(K=i("Column"),e[48]=i,e[49]=K):K=e[49];let U;e[50]!==K?(U=d(Bt,{htmlFor:"bulk-patch-column",children:K}),e[50]=K,e[51]=U):U=e[51];let X;e[52]!==i?(X=i("Column"),e[52]=i,e[53]=X):X=e[53];let Q;e[54]!==n?(Q=n.map(Eo),e[54]=n,e[55]=Q):Q=e[55];let ee;e[56]!==f||e[57]!==X||e[58]!==Q?(ee=d("select",{"aria-label":X,className:"h-8 rounded-md border border-input bg-transparent px-2 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 dark:bg-input/30","data-testid":"bulk-patch-column",id:"bulk-patch-column",onChange:g,value:f,children:Q}),e[56]=f,e[57]=X,e[58]=Q,e[59]=ee):ee=e[59];let ne;e[60]!==i?(ne=i("Value"),e[60]=i,e[61]=ne):ne=e[61];let le;e[62]!==ne?(le=d(Bt,{htmlFor:"bulk-patch-value",children:ne}),e[62]=ne,e[63]=le):le=e[63];let be;e[64]!==p?(be=d(Qn,{className:"flex-1 font-mono","data-testid":"bulk-patch-value",id:"bulk-patch-value",onChange:x,placeholder:"true",value:p}),e[64]=p,e[65]=be):be=e[65];let ce;e[66]!==U||e[67]!==ee||e[68]!==le||e[69]!==be?(ce=E("div",{className:"flex items-center gap-2",children:[U,ee,le,be]}),e[66]=U,e[67]=ee,e[68]=le,e[69]=be,e[70]=ce):ce=e[70];let de;e[71]!==N?(de=N!==void 0&&d("p",{className:"text-xs text-destructive","data-testid":"bulk-patch-error",role:"alert",children:N}),e[71]=N,e[72]=de):de=e[72];let ue;e[73]!==f||e[74]!==i||e[75]!==r||e[76]!==S?(ue=S&&d("p",{className:"text-xs text-destructive","data-testid":"bulk-patch-unique",role:"alert",children:i("{column} has a unique index — the same value cannot be set on {total} rows.",{column:f,total:r.toString()})}),e[73]=f,e[74]=i,e[75]=r,e[76]=S,e[77]=ue):ue=e[77];let re;e[78]!==y||e[79]!==i||e[80]!==S?(re=y&&!S&&d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-hint",children:i('Enter a JSON value — for example true, 0, null, or "done".')}),e[78]=y,e[79]=i,e[80]=S,e[81]=re):re=e[81];let Y;e[82]!==w||e[83]!==f||e[84]!==p?(Y=w&&d("p",{className:"font-mono text-xs text-muted-foreground","data-testid":"bulk-patch-preview",children:`${f} = ${p.trim()}`}),e[82]=w,e[83]=f,e[84]=p,e[85]=Y):Y=e[85];let ve;e[86]!==i?(ve=i("Cancel"),e[86]=i,e[87]=ve):ve=e[87];let ae;e[88]!==t||e[89]!==ve?(ae=d(Ct,{"data-testid":"bulk-patch-cancel",onClick:t,size:"xs",variant:"outline",children:ve}),e[88]=t,e[89]=ve,e[90]=ae):ae=e[90];const fe=!w;let me;e[91]!==i||e[92]!==r?(me=i("Set on {total} rows",{total:r.toString()}),e[91]=i,e[92]=r,e[93]=me):me=e[93];let oe;e[94]!==F||e[95]!==fe||e[96]!==me?(oe=d(Ct,{"data-testid":"bulk-patch-apply",disabled:fe,onClick:F,size:"xs",children:me}),e[94]=F,e[95]=fe,e[96]=me,e[97]=oe):oe=e[97];let W;e[98]!==ae||e[99]!==oe?(W=E("div",{className:"flex justify-end gap-2",children:[ae,oe]}),e[98]=ae,e[99]=oe,e[100]=W):W=e[100];let z;return e[101]!==t||e[102]!==J||e[103]!==ce||e[104]!==de||e[105]!==ue||e[106]!==re||e[107]!==Y||e[108]!==W||e[109]!==R?(z=E(dt,{label:R,onClose:t,panelTestId:"bulk-patch-panel",testId:"bulk-patch-overlay",variant:"dialog",children:[J,ce,de,ue,re,Y,W]}),e[101]=t,e[102]=J,e[103]=ce,e[104]=de,e[105]=ue,e[106]=re,e[107]=Y,e[108]=W,e[109]=R,e[110]=z):z=e[110],z};function Eo(s){return d("option",{value:s,children:s},s)}const Kt=6,lt=100,_o=s=>({paddingLeft:s*16}),Ro=s=>{const e=B(2),{table:n}=s,o=`cascade-restrict-${n}`;let t;return e[0]!==o?(t=d("span",{className:"rounded bg-destructive/10 px-1 text-destructive","data-testid":o,children:"restrict — will block delete"}),e[0]=o,e[1]=t):t=e[1],t},$o=s=>{const e=B(2),{table:n}=s,o=`cascade-cascade-${n}`;let t;return e[0]!==o?(t=d("span",{className:"rounded bg-warning/10 px-1 text-warning","data-testid":o,children:"cascade"}),e[0]=o,e[1]=t):t=e[1],t},Do=s=>{const e=B(2),{table:n}=s,o=`cascade-undeclared-${n}`;let t;return e[0]!==o?(t=d("span",{className:"rounded bg-muted px-1 text-muted-foreground","data-testid":o,children:"references — no delete action declared"}),e[0]=o,e[1]=t):t=e[1],t},Po=s=>s.relation===void 0||s.relation.onDelete==="cascade"?d($o,{table:s.table}):s.isRestrict?d(Ro,{table:s.table}):d(Do,{table:s.table}),sn=s=>{const e=B(35),{depth:n,node:o}=s,t=`cascade-row-${o.table}`;let c;e[0]!==n?(c=_o(n),e[0]=n,e[1]=c):c=e[1];let l;e[2]!==n?(l=n>0&&d("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"└"}),e[2]=n,e[3]=l):l=e[3];let r;e[4]!==o.table?(r=d("span",{className:"font-medium text-foreground",children:o.table}),e[4]=o.table,e[5]=r):r=e[5];let a;e[6]!==o.relation||e[7]!==o.table?(a=o.relation!==void 0&&E("span",{className:"text-muted-foreground","data-testid":`cascade-col-${o.table}-${o.relation.field}`,children:["via ",o.relation.field]}),e[6]=o.relation,e[7]=o.table,e[8]=a):a=e[8];let i;e[9]!==o.rowCount?(i=o.rowCount.toString(),e[9]=o.rowCount,e[10]=i):i=e[10];let f;e[11]!==i?(f=E("span",{className:"text-muted-foreground",children:["(",i," rows)"]}),e[11]=i,e[12]=f):f=e[12];let m;e[13]!==o?(m=Po(o),e[13]=o,e[14]=m):m=e[14];let p;e[15]!==o.capNote||e[16]!==o.table?(p=o.capNote!==void 0&&E("span",{className:"italic text-muted-foreground","data-testid":`cascade-cap-${o.table}`,children:["(",o.capNote,")"]}),e[15]=o.capNote,e[16]=o.table,e[17]=p):p=e[17];let b;e[18]!==t||e[19]!==c||e[20]!==l||e[21]!==r||e[22]!==a||e[23]!==f||e[24]!==m||e[25]!==p?(b=E("li",{className:"flex flex-wrap items-center gap-1.5 py-1 font-mono text-xs","data-testid":t,style:c,children:[l,r,a,f,m,p]}),e[18]=t,e[19]=c,e[20]=l,e[21]=r,e[22]=a,e[23]=f,e[24]=m,e[25]=p,e[26]=b):b=e[26];let u;if(e[27]!==n||e[28]!==o.children){let h;e[30]!==n?(h=(x,v)=>d(sn,{depth:n+1,node:x},`${x.table}-${x.relation?.field??"root"}-${v.toString()}`),e[30]=n,e[31]=h):h=e[31],u=o.children.map(h),e[27]=n,e[28]=o.children,e[29]=u}else u=e[29];let g;return e[32]!==b||e[33]!==u?(g=E(Xe,{children:[b,u]}),e[32]=b,e[33]=u,e[34]=g):g=e[34],g},Ao=s=>{const e=s._id??s.id??s.__id__??"";return typeof e=="string"?e:typeof e=="number"?e.toString():""},Io=async(s,e,n,o)=>{try{const t=await o(s,e,n),c=t.rows.flatMap(a=>Ao(a)||[]).slice(0,lt),l=t.total??0;return{capNote:l>lt?`showing first ${lt.toString()} of ${l.toString()}`:void 0,rowCount:l,rowIds:c}}catch{return{capNote:"count unavailable",rowCount:0,rowIds:[]}}},ln=async(s,e,n,o,t,c,l)=>{const{capNote:r,rowCount:a,rowIds:i}=n===void 0?{capNote:void 0,rowCount:1,rowIds:[e]}:await Io(s,n.field,e,l),f=n?.onDelete==="restrict",m=[],p=`${s}:${e}`,b=c>=Kt;if(!t.has(p)&&!b){t.add(p);const g=o.get(s)??[];for(const h of g)for(const x of i.slice(0,10)){const v=await ln(h.table,x,h,o,t,c+1,l);(v.rowCount>0||c===0)&&m.push(v)}t.delete(p)}let u=r;if(b){const g=`depth capped at ${Kt.toString()}`;u=r===void 0?g:`${r}; ${g}`}return{capNote:u,children:m,isRestrict:f,relation:n,rowCount:a,rowIds:i,table:s}},Oo=({onClose:s,onConfirm:e,readPage:n,rowId:o,schema:t,table:c})=>{const l=we(),[r,a]=P(!0),[i,f]=P(null),[m,p]=P(null);Be(()=>{let g=!1;return Ce((async()=>{try{a(!0),p(null);const x=So(t);if(!((x.get(c)??[]).length>0)){g||(f({capNote:void 0,children:[],isRestrict:!1,relation:void 0,rowCount:1,rowIds:[o],table:c}),a(!1));return}const y=await ln(c,o,void 0,x,new Set,0,n);g||(f(y),a(!1))}catch(x){g||(p(x.message),a(!1))}})()),()=>{g=!0}},[o,c]);const b=i!==null&&ko(i,g=>g.isRestrict).length>0,u=()=>{e(),s()};return E(dt,{label:"Cascade impact preview",onClose:s,panelTestId:"cascade-panel",testId:"cascade-overlay",variant:"dialog",children:[E("div",{className:"flex items-start justify-between",children:[E("div",{className:"flex flex-col gap-0.5",children:[d("h3",{className:"text-base text-foreground","data-testid":"cascade-title",children:l("Cascade impact")}),d("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-desc",children:l("Delete preview — rows that would cascade or be blocked")})]}),d("button",{className:"text-xs text-muted-foreground hover:text-foreground","data-testid":"cascade-close",onClick:s,type:"button",children:l("Close")})]}),r&&d("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-loading",children:l("Loading…")}),m!==null&&d("p",{className:"text-xs text-destructive","data-testid":"cascade-error",role:"alert",children:m}),!r&&i!==null&&d("ul",{className:"flex flex-col","data-testid":"cascade-tree",children:d(sn,{depth:0,node:i})}),!r&&i!==null&&i.children.length===0&&d("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-no-impact",children:l("No related rows found.")}),b&&d("p",{className:"text-sm font-medium text-destructive","data-testid":"cascade-blocker-warning",role:"alert",children:l("Restrict relations will block this delete.")}),E("div",{className:"flex justify-end gap-2",children:[d("button",{className:"rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"cascade-cancel",onClick:s,type:"button",children:l("Cancel")}),d("button",{className:"rounded-md bg-destructive px-3 py-1.5 text-xs font-medium text-destructive-foreground outline-none transition-colors hover:bg-destructive/90 focus-visible:bg-destructive/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"cascade-confirm",disabled:r,onClick:u,type:"button",children:l("Delete")})]})]})},Fo=(s,e,n,o,t=300)=>{if(o<=0)return{ids:new Set(s.map(m=>m.id)),leadPx:0,tailPx:0};const c=n-t,l=n+o+t,r=new Set;let a=0,i=0,f=0;for(const m of s){const p=m.getSize(),b=e.has(m.id),u=a+p>c&&a<l;b||u?r.add(m.id):a<c?i+=p:f+=p,a+=p}return{ids:r,leadPx:i,tailPx:f}},Mo=(s,e)=>{const n=new Map;let o=0;for(const t of s)e.has(t.id)&&(n.set(t.id,o),o+=t.getSize());return n},Lo=Xn({columnOrderingFeature:io,columnResizingFeature:ao,columnSizingFeature:ro,columnVisibilityFeature:lo,rowSelectionFeature:so,rowSortingFeature:oo,sortedRowModel:co(),sortFns:{alphanumeric:no,basic:to,datetime:eo,text:Zn}}),Vo=()=>{const s=B(12);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e={},s[0]=e):e=s[0];const[n,o]=P(e);let t;s[1]===Symbol.for("react.memo_cache_sentinel")?(t=(g,h,x)=>{o(v=>({...v,[g]:{...v[g],[h]:x}}))},s[1]=t):t=s[1];const c=t;let l;s[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{o({})},s[2]=l):l=s[2];const r=l;let a;s[3]===Symbol.for("react.memo_cache_sentinel")?(a=(g,h)=>{o(x=>{const v=x[g];if(v===void 0)return x;const y=Object.fromEntries(Object.entries(v).filter(N=>{const[C,k]=N;return!(C in h)||!Object.is(k,h[C])}));return Object.keys(y).length===0?Object.fromEntries(Object.entries(x).filter(N=>{const[C]=N;return C!==g})):{...x,[g]:y}})},s[3]=a):a=s[3];const i=a;let f;s[4]!==n?(f=(g,h)=>{const x=n[g];return x!==void 0&&h in x?{value:x[h]}:void 0},s[4]=n,s[5]=f):f=s[5];const m=f;let p;s[6]!==n?(p=Object.values(n).reduce(jo,0),s[6]=n,s[7]=p):p=s[7];const b=p;let u;return s[8]!==b||s[9]!==n||s[10]!==m?(u={clear:r,count:b,drop:i,stage:c,staged:n,stagedValue:m},s[8]=b,s[9]=n,s[10]=m,s[11]=u):u=s[11],u},rn=(s,e)=>{if(typeof e=="number"){const n=Number(s);return s.trim()===""||Number.isNaN(n)?s:n}if(typeof e=="boolean"){if(s==="true")return!0;if(s==="false")return!1}return s},Bo=s=>{const e=B(29),{changes:n,committing:o,onCommit:t,onDiscard:c}=s,l=we();let r;e[0]!==n.length||e[1]!==l?(r=l("{count} pending changes",{count:n.length}),e[0]=n.length,e[1]=l,e[2]=r):r=e[2];let a;e[3]!==r?(a=d("span",{className:"font-mono text-[11px] tracking-wide uppercase text-warning","data-testid":"db-staged-count",children:r}),e[3]=r,e[4]=a):a=e[4];let i;e[5]!==o||e[6]!==l?(i=l(o?"Committing…":"Commit"),e[5]=o,e[6]=l,e[7]=i):i=e[7];let f;e[8]!==o||e[9]!==t||e[10]!==i?(f=d("button",{className:"ms-auto rounded-md bg-primary px-2.5 py-1 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"db-staged-commit",disabled:o,onClick:t,type:"button",children:i}),e[8]=o,e[9]=t,e[10]=i,e[11]=f):f=e[11];let m;e[12]!==l?(m=l("Discard"),e[12]=l,e[13]=m):m=e[13];let p;e[14]!==o||e[15]!==c||e[16]!==m?(p=d("button",{className:"rounded-md border border-border px-2.5 py-1 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50","data-testid":"db-staged-discard",disabled:o,onClick:c,type:"button",children:m}),e[14]=o,e[15]=c,e[16]=m,e[17]=p):p=e[17];let b;e[18]!==a||e[19]!==f||e[20]!==p?(b=E("div",{className:"flex flex-wrap items-center gap-2",children:[a,f,p]}),e[18]=a,e[19]=f,e[20]=p,e[21]=b):b=e[21];let u;e[22]!==n?(u=n.map(zo),e[22]=n,e[23]=u):u=e[23];let g;e[24]!==u?(g=d("ul",{className:"flex flex-col gap-1","data-testid":"db-staged-list",children:u}),e[24]=u,e[25]=g):g=e[25];let h;return e[26]!==b||e[27]!==g?(h=E("div",{className:"flex flex-col gap-2 border border-warning/40 bg-warning/5 p-3","data-testid":"db-staged",children:[b,g]}),e[26]=b,e[27]=g,e[28]=h):h=e[28],h};function jo(s,e){return s+Object.keys(e).length}function zo(s){return E("li",{className:"flex flex-wrap items-center gap-2 font-mono text-xs",children:[E("span",{className:"text-muted-foreground",children:[s.rowId,".",s.column]}),d("span",{className:"text-destructive line-through",children:Fe(s.oldValue)}),d("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"→"}),d("span",{className:"text-foreground",children:Fe(s.newValue)})]},`${s.rowId}:${s.column}`)}const Gt=400,qo=36,Ko={flex:"1 1 0%",minHeight:0,overflow:"auto",position:"relative"},Go={width:"100%"},Jo=/\n$/u,Wo={alignItems:"center",display:"flex",left:0,position:"absolute",top:0,width:"100%"},Ho={display:"flex",width:"100%"},Jt={flex:"0 0 8.5rem",padding:"0.375rem 0.75rem"},Uo="2.5rem",an={alignItems:"center",display:"flex",flex:"0 0 2.5rem",justifyContent:"center",left:0,padding:"0.375rem 0",position:"sticky",zIndex:2},At=s=>({flex:"0 0 auto",overflow:"hidden",padding:"0.375rem 0.75rem",position:"relative",textOverflow:"ellipsis",whiteSpace:"nowrap",width:`${s.toString()}px`}),cn=(s,e)=>({...At(s),left:`calc(${Uo} + ${e.toString()}px)`,position:"sticky",zIndex:2}),St="rounded-md px-2 py-0.5 text-xs font-medium text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50",Qo=(s,e,n)=>e.enabled&&e.columns.has(n)?void 0:s,Rt="__back__:",Yo=s=>`${Rt}${s.table}.${s.column}`,Xo=s=>{const e=B(3),{counts:n,rowId:o}=s;if(n===void 0){let l;return e[0]===Symbol.for("react.memo_cache_sentinel")?(l=d("span",{className:"text-muted-foreground/50",children:"—"}),e[0]=l):l=e[0],l}const t=n[o]??0;let c;return e[1]!==t?(c=d("span",{className:"tabular-nums",children:t}),e[1]=t,e[2]=c):c=e[2],c},Pe=s=>{for(const e of["id","__id__","_id"]){const n=s[e];if(typeof n=="string"||typeof n=="number")return String(n)}return null},Zo=(s,e)=>{if(e.enumValues!==void 0&&e.enumValues.length>0)return e.enumValues.includes(s)||s===""&&e.nullable===!0?{value:s===""?null:s}:void 0;if(e.type==="boolean")return s==="true"||s==="false"?{value:s==="true"}:void 0;if(e.type==="number"){const n=Number(s);return s.trim()===""||!Number.isFinite(n)?void 0:{value:n}}return{value:s}},es=(s,e,n)=>{if(n!==void 0&&n.type!=="any")return Zo(s,n);const o=rn(s,e);return typeof e=="number"&&typeof o!="number"?void 0:{value:o}},ts=({anchor:s,columnIds:e,columnMeta:n,editableColumn:o,rows:t,text:c})=>{const l=c.replaceAll(`\r
2
- `,`
3
- `).replace(Jo,"").split(`
4
- `),r=[];let a=0;for(const[i,f]of l.entries()){const m=t[s.row+i],p=m===void 0?null:Pe(m),b=f.split(" ");if(m===void 0||p===null){a+=b.length;continue}for(const[u,g]of b.entries()){const h=e[s.col+u],x=h===void 0||!o(h)?void 0:es(g,m[h],n?.[h]);h===void 0||x===void 0?a+=1:r.push({column:h,rowId:p,value:x.value})}}return{edits:r,skipped:a}},dn=(s,e)=>Pe(s)??`row-${e.toString()}`,ns=8,os=s=>{const e=B(17),{anchor:n,mask:o,state:t}=s,c=we();let l;e[0]!==n.left||e[1]!==n.top?(l={left:n.left,position:"fixed",top:n.top,zIndex:50},e[0]=n.left,e[1]=n.top,e[2]=l):l=e[2];const r=l;let a;if(t==="loading"){let f;e[3]!==c?(f=c("Loading…"),e[3]=c,e[4]=f):f=e[4];let m;e[5]!==f?(m=d("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:f}),e[5]=f,e[6]=m):m=e[6],a=m}else if(t.row===null){let f;e[7]!==c?(f=c("No matching row."),e[7]=c,e[8]=f):f=e[8];let m;e[9]!==f?(m=d("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:f}),e[9]=f,e[10]=m):m=e[10],a=m}else{let f;if(e[11]!==o||e[12]!==t.row){const m=Object.entries(tn(t.row,o)).slice(0,ns);f=d("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 px-3 py-2",children:m.map(ps)}),e[11]=o,e[12]=t.row,e[13]=f}else f=e[13];a=f}let i;return e[14]!==a||e[15]!==r?(i=d("div",{className:"pointer-events-none w-72 overflow-hidden rounded-md border border-border bg-popover text-popover-foreground","data-testid":"db-ref-preview",role:"tooltip",style:r,children:a}),e[14]=a,e[15]=r,e[16]=i):i=e[16],i},ss=s=>{const e=B(24),{column:n,id:o,maskViewFor:t,onNavigate:c,onPreview:l,target:r}=s,[a,i]=P(null),[f,m]=P("idle");let p;e[0]!==o||e[1]!==c||e[2]!==r?(p=()=>{c(r,o)},e[0]=o,e[1]=c,e[2]=r,e[3]=p):p=e[3];const b=p;let u;e[4]!==o||e[5]!==l||e[6]!==f||e[7]!==r?(u=S=>{const w=S.currentTarget.getBoundingClientRect();if(i({left:w.left,top:w.bottom+4}),f!=="idle")return;m("loading"),Ce((async()=>{try{m({row:await l(r,o)})}catch{m({row:null})}})())},e[4]=o,e[5]=l,e[6]=f,e[7]=r,e[8]=u):u=e[8];const g=u;let h;e[9]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{i(null)},e[9]=h):h=e[9];const x=h,v=`db-ref-${n}`,y=`Open ${r} ${o}`;let N;e[10]!==o||e[11]!==b||e[12]!==g||e[13]!==v||e[14]!==y?(N=E("button",{"data-testid":v,onBlur:x,onClick:b,onFocus:g,onMouseEnter:g,onMouseLeave:x,title:y,type:"button",children:[o," ↗"]}),e[10]=o,e[11]=b,e[12]=g,e[13]=v,e[14]=y,e[15]=N):N=e[15];let C;e[16]!==a||e[17]!==t||e[18]!==f||e[19]!==r?(C=a!==null&&f!=="idle"&&d(os,{anchor:a,mask:t(r,f==="loading"||f.row===null?[]:Object.keys(f.row)),state:f}),e[16]=a,e[17]=t,e[18]=f,e[19]=r,e[20]=C):C=e[20];let k;return e[21]!==N||e[22]!==C?(k=E(Xe,{children:[N,C]}),e[21]=N,e[22]=C,e[23]=k):k=e[23],k},ls=s=>s==="asc"?" ▲":s==="desc"?" ▼":"",rs="absolute end-1 top-1/2 hidden -translate-y-1/2 items-center justify-center rounded text-muted-foreground outline-none group-hover/cell:flex hover:text-foreground focus-visible:flex",Wt=s=>{const e=B(8),{column:n,onExpand:o,value:t}=s;let c;e[0]!==n||e[1]!==o||e[2]!==t?(c=()=>{o(n,t)},e[0]=n,e[1]=o,e[2]=t,e[3]=c):c=e[3];const l=c,r=`db-expand-${n}`;let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=d("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:d("path",{d:"M9 21H5a2 2 0 0 1-2-2v-4m18 0v4a2 2 0 0 1-2 2h-4M3 9V5a2 2 0 0 1 2-2h4m6 0h4a2 2 0 0 1 2 2v4"})}),e[4]=a):a=e[4];let i;return e[5]!==l||e[6]!==r?(i=d("button",{"aria-label":"Expand cell",className:rs,"data-testid":r,onClick:l,type:"button",children:a}),e[5]=l,e[6]=r,e[7]=i):i=e[7],i},as=s=>{const e=B(15),{column:n,initial:o,onCancel:t,onCommit:c,recordId:l}=s,r=We(null);let a,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{r.current?.select()},i=[],e[0]=a,e[1]=i):(a=e[0],i=e[1]),Be(a,i);let f;e[2]!==t||e[3]!==c?(f=x=>{x.key==="Enter"?(x.preventDefault(),c(x.currentTarget.value)):x.key==="Escape"&&(x.preventDefault(),t())},e[2]=t,e[3]=c,e[4]=f):f=e[4];const m=f;let p;e[5]!==c?(p=x=>{c(x.currentTarget.value)},e[5]=c,e[6]=p):p=e[6];const b=p,u=`db-cell-input-${l}-${n}`;let g;e[7]!==o?(g=Fe(o),e[7]=o,e[8]=g):g=e[8];let h;return e[9]!==n||e[10]!==b||e[11]!==m||e[12]!==u||e[13]!==g?(h=d("input",{"aria-label":n,className:"w-full rounded border border-ring bg-background px-1 py-0.5 font-mono text-xs outline-none","data-testid":u,defaultValue:g,onBlur:b,onKeyDown:m,ref:r}),e[9]=n,e[10]=b,e[11]=m,e[12]=u,e[13]=g,e[14]=h):h=e[14],h},is=s=>{const e=B(70),{cell:n,edit:o,highlight:t,mask:c,refs:l}=s,r=n.column.id;let a,i,f,m;if(e[0]!==n||e[1]!==r||e[2]!==o||e[3]!==c||e[4]!==l.columns||e[5]!==l.maskViewFor||e[6]!==l.onNavigate||e[7]!==l.onPreview){m=Symbol.for("react.early_return_sentinel");e:{i=n.getValue(),a=Pe(n.row.original);const R=l.columns?.[r];if(c.enabled&&c.columns.has(r)){const _=`db-masked-${r}`,$=d(Nt,{value:qn(i,r,c)});let I;e[12]!==_||e[13]!==$?(I=d("span",{className:"text-muted-foreground italic","data-testid":_,title:"Masked (preview)",children:$}),e[12]=_,e[13]=$,e[14]=I):I=e[14],m=I;break e}if(R!==void 0&&(typeof i=="string"||typeof i=="number")&&String(i)!==""){const _=String(i),$=`${R}:${String(i)}`;let I;e[15]!==r||e[16]!==l.maskViewFor||e[17]!==l.onNavigate||e[18]!==l.onPreview||e[19]!==_||e[20]!==$||e[21]!==R?(I=d(ss,{column:r,id:_,maskViewFor:l.maskViewFor,onNavigate:l.onNavigate,onPreview:l.onPreview,target:R},$),e[15]=r,e[16]=l.maskViewFor,e[17]=l.onNavigate,e[18]=l.onPreview,e[19]=_,e[20]=$,e[21]=R,e[22]=I):I=e[22],m=I;break e}if(a===null){let _;e[23]!==i?(_=d(Nt,{value:i}),e[23]=i,e[24]=_):_=e[24];let $;e[25]!==r||e[26]!==o.onExpandCell||e[27]!==i?($=d(Wt,{column:r,onExpand:o.onExpandCell,value:i}),e[25]=r,e[26]=o.onExpandCell,e[27]=i,e[28]=$):$=e[28];let I;e[29]!==_||e[30]!==$?(I=E(Xe,{children:[_,$]}),e[29]=_,e[30]=$,e[31]=I):I=e[31],m=I;break e}f=o.stagedValue(a,r)}e[0]=n,e[1]=r,e[2]=o,e[3]=c,e[4]=l.columns,e[5]=l.maskViewFor,e[6]=l.onNavigate,e[7]=l.onPreview,e[8]=a,e[9]=i,e[10]=f,e[11]=m}else a=e[8],i=e[9],f=e[10],m=e[11];if(m!==Symbol.for("react.early_return_sentinel"))return m;const p=f,b=p===void 0?i:p.value;let u;e[32]!==r||e[33]!==o?(u=o.editable&&o.editableColumn(r),e[32]=r,e[33]=o,e[34]=u):u=e[34];const g=u;if(o.editingCell!==null&&o.editingCell.rowId===a&&o.editingCell.column===r){let R;e[35]!==r||e[36]!==o||e[37]!==a||e[38]!==i?(R=$=>{o.stage(a,r,rn($,i)),o.cancelEdit()},e[35]=r,e[36]=o,e[37]=a,e[38]=i,e[39]=R):R=e[39];let _;return e[40]!==r||e[41]!==b||e[42]!==o.cancelEdit||e[43]!==a||e[44]!==R?(_=d(as,{column:r,initial:b,onCancel:o.cancelEdit,onCommit:R,recordId:a}),e[40]=r,e[41]=b,e[42]=o.cancelEdit,e[43]=a,e[44]=R,e[45]=_):_=e[45],_}let x;p!==void 0?x="rounded bg-warning/15 px-1":g&&(x="cursor-text");let v;e[46]!==g||e[47]!==r||e[48]!==o||e[49]!==a?(v=g?()=>{o.startEdit(a,r)}:void 0,e[46]=g,e[47]=r,e[48]=o,e[49]=a,e[50]=v):v=e[50];const y=v,N=x,C=`db-cell-${a}-${r}`;let k;e[51]!==r||e[52]!==t||e[53]!==c?(k=Qo(t,c,r),e[51]=r,e[52]=t,e[53]=c,e[54]=k):k=e[54];let S;e[55]!==b||e[56]!==k?(S=d(Nt,{highlight:k,value:b}),e[55]=b,e[56]=k,e[57]=S):S=e[57];let w;e[58]!==x||e[59]!==y||e[60]!==C||e[61]!==S?(w=d("span",{className:N,"data-testid":C,onDoubleClick:y,children:S}),e[58]=x,e[59]=y,e[60]=C,e[61]=S,e[62]=w):w=e[62];let T;e[63]!==r||e[64]!==b||e[65]!==o.onExpandCell?(T=d(Wt,{column:r,onExpand:o.onExpandCell,value:b}),e[63]=r,e[64]=b,e[65]=o.onExpandCell,e[66]=T):T=e[66];let F;return e[67]!==T||e[68]!==w?(F=E(Xe,{children:[w,T]}),e[67]=T,e[68]=w,e[69]=F):F=e[69],F},cs=s=>{s.preventDefault()},Ht={any:"?",array:"[]",bigint:"#",boolean:"01",bytes:"0x",id:"→",number:"#",object:"{}",storage:"◫",string:"T",union:"|"},ds=({declaredType:s,draggedRef:e,header:n,masked:o=!1,onTogglePin:t,pinnedOffset:c,table:l})=>{const r=()=>{e.current=n.column.id},a=()=>{const i=e.current,f=n.column.id;if(e.current=null,i===null||i===f)return;const m=l.atoms.columnOrder.get(),b=(m.length>0?m:l.getAllLeafColumns().map(g=>g.id)).filter(g=>g!==i),u=b.indexOf(f);b.splice(u===-1?b.length:u,0,i),l.setColumnOrder(b)};return E("th",{className:it("group/head text-start text-xs font-medium text-muted-foreground",c!==void 0&&"border-e border-border bg-muted"),"data-testid":`db-head-${n.column.id}`,draggable:!0,onDragOver:cs,onDragStart:r,onDrop:a,style:c===void 0?At(n.getSize()):cn(n.getSize(),c),children:[E("button",{className:"inline-flex max-w-full cursor-grab items-center gap-1 truncate outline-none hover:text-foreground","data-testid":`db-sort-${n.column.id}`,onClick:n.column.getToggleSortingHandler(),type:"button",children:[fo(n.column.columnDef.header,n.getContext()),ls(n.column.getIsSorted())]}),s!==void 0&&Ht[s]!==void 0&&d("span",{className:"ms-1 font-mono text-[0.625rem] text-muted-foreground/70","data-testid":`db-type-${n.column.id}`,title:s,children:Ht[s]}),o&&d("span",{className:"ms-1 inline-flex items-center rounded-sm bg-warning/15 px-1 text-[0.625rem] font-medium uppercase text-warning","data-testid":`db-mask-chip-${n.column.id}`,title:"This column is masked by a mask() policy",children:"masked"}),d("button",{"aria-label":c===void 0?`Pin ${n.column.id}`:`Unpin ${n.column.id}`,"aria-pressed":c!==void 0,className:it("ms-1 rounded-sm px-1 text-[0.625rem] outline-none transition-opacity hover:bg-accent focus-visible:bg-accent",c===void 0?"opacity-0 group-hover/head:opacity-100 focus-visible:opacity-100":"opacity-100 text-foreground"),"data-testid":`db-pin-${n.column.id}`,onClick:()=>{t(n.column.id)},type:"button",children:"📌"}),d("span",{"aria-hidden":"true",className:"absolute inset-y-0 end-0 w-1 cursor-col-resize touch-none select-none hover:bg-ring/60 data-[resizing=true]:bg-ring","data-resizing":n.column.getIsResizing(),"data-testid":`db-resize-${n.column.id}`,onMouseDown:n.getResizeHandler(),onTouchStart:n.getResizeHandler()})]})},us=s=>{const e=B(13),{table:n}=s,o=we();let t;e[0]!==n?(t=f=>{n.toggleAllRowsSelected(f)},e[0]=n,e[1]=t):t=e[1];const c=t;let l;e[2]!==o?(l=o("Select all rows"),e[2]=o,e[3]=l):l=e[3];let r;e[4]!==n?(r=n.getIsAllRowsSelected(),e[4]=n,e[5]=r):r=e[5];let a;e[6]!==n?(a=n.getIsSomeRowsSelected()&&!n.getIsAllRowsSelected(),e[6]=n,e[7]=a):a=e[7];let i;return e[8]!==c||e[9]!==l||e[10]!==r||e[11]!==a?(i=d("th",{className:"bg-muted",style:an,children:d(Dt,{"aria-label":l,checked:r,"data-testid":"db-select-all",indeterminate:a,onCheckedChange:c})}),e[8]=c,e[9]=l,e[10]=r,e[11]=a,e[12]=i):i=e[12],i},fs=s=>{const e=B(17),{row:n}=s,o=we();let t;e[0]!==n.original?(t=Pe(n.original),e[0]=n.original,e[1]=t):t=e[1];const c=t;let l;e[2]!==n?(l=u=>{n.toggleSelected(u)},e[2]=n,e[3]=l):l=e[3];const r=l;let a;e[4]!==o?(a=o("Select row"),e[4]=o,e[5]=a):a=e[5];let i;e[6]!==n?(i=n.getIsSelected(),e[6]=n,e[7]=i):i=e[7];let f;e[8]!==n.index||e[9]!==n.original?(f=dn(n.original,n.index),e[8]=n.index,e[9]=n.original,e[10]=f):f=e[10];const m=`db-select-${f}`,p=c===null;let b;return e[11]!==r||e[12]!==a||e[13]!==i||e[14]!==m||e[15]!==p?(b=d("td",{className:"bg-background",style:an,children:d(Dt,{"aria-label":a,checked:i,"data-testid":m,disabled:p,onCheckedChange:r})}),e[11]=r,e[12]=a,e[13]=i,e[14]=m,e[15]=p,e[16]=b):b=e[16],b},ms=s=>{const e=B(91),{columnMeta:n,edit:o,editable:t,mask:c,onDelete:l,onEdit:r,onInspect:a,highlight:i,backRelationCounts:f,onTogglePin:m,pinnedColumns:p,refs:b,tableModel:u}=s,g=we(),{attachScroll:h,scrollLeft:x,scrollToIndex:v,table:y,tableRows:N,tbodyStyle:C,viewportWidth:k,virtualRows:S}=u,w=We(null),[T,F]=P(null);let R;e[0]===Symbol.for("react.memo_cache_sentinel")?(R={columns:"",count:0},e[0]=R):R=e[0];const[_,$]=P(R);let I;e[1]!==y?(I=y.getVisibleLeafColumns(),e[1]=y,e[2]=I):I=e[2];const L=I.length;let D;e[3]!==T||e[4]!==L||e[5]!==o||e[6]!==y||e[7]!==N?(D=ie=>{if(!["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","Enter"].includes(ie.key))return;ie.preventDefault();const H=T??{col:0,row:0};if(ie.key==="Enter"){const pe=N[H.row],Se=y.getVisibleLeafColumns()[H.col];if(pe!==void 0&&Se!==void 0){const Z=Pe(pe.original);Z!==null&&o.editableColumn(Se.id)&&o.startEdit(Z,Se.id)}F(H);return}let{col:he,row:ge}=H;e:switch(ie.key){case"ArrowDown":{ge=Math.min(ge+1,N.length-1);break e}case"ArrowRight":{he=Math.min(he+1,L-1);break e}case"ArrowUp":{ge=Math.max(ge-1,0);break e}default:he=Math.max(he-1,0)}F({col:he,row:ge})},e[3]=T,e[4]=L,e[5]=o,e[6]=y,e[7]=N,e[8]=D):D=e[8];const V=D;let G;e[9]!==T||e[10]!==n||e[11]!==o||e[12]!==y||e[13]!==N?(G=ie=>{const H=o.editable?ie.clipboardData.getData("text/plain"):"";if(H==="")return;ie.preventDefault();const he=y.getVisibleLeafColumns().map(bs),ge=ts({anchor:T??{col:0,row:0},columnIds:he,columnMeta:n,editableColumn:o.editableColumn,rows:N.map(hs),text:H});for(const pe of ge.edits)o.stage(pe.rowId,pe.column,pe.value);$({columns:he.join("\0"),count:ge.skipped})},e[9]=T,e[10]=n,e[11]=o,e[12]=y,e[13]=N,e[14]=G):G=e[14];const q=G;let O,J;e[15]!==T||e[16]!==v?(O=()=>{T!==null&&v(T.row)},J=[T,v],e[15]=T,e[16]=v,e[17]=O,e[18]=J):(O=e[17],J=e[18]),Be(O,J);let K,U,X,Q,ee,ne,le,be,ce,de,ue,re,Y,ve,ae,fe;if(e[19]!==T||e[20]!==h||e[21]!==f||e[22]!==n||e[23]!==o||e[24]!==t||e[25]!==i||e[26]!==c||e[27]!==l||e[28]!==r||e[29]!==V||e[30]!==q||e[31]!==a||e[32]!==m||e[33]!==_.columns||e[34]!==_.count||e[35]!==p||e[36]!==b||e[37]!==x||e[38]!==g||e[39]!==y||e[40]!==N||e[41]!==C||e[42]!==k||e[43]!==S){const ie=y.getVisibleLeafColumns().map(xs),H=Fo(ie,p,x,k),he=Mo(y.getVisibleLeafColumns().map(vs),p),ge=Z=>{const Me=N[Z.index],{original:ye}=Me,te=Pe(ye),Ae=dn(ye,Z.index),ze={...Wo,height:`${Z.size.toString()}px`,transform:`translateY(${Z.start.toString()}px)`};return E("tr",{className:"border-b border-border text-xs transition-colors hover:bg-muted/50","data-testid":"db-row",style:ze,children:[d(fs,{row:Me}),H.leadPx>0&&d("td",{"aria-hidden":"true",style:{flex:`0 0 ${H.leadPx.toString()}px`}}),Me.getVisibleCells().map((ke,qe)=>{if(!H.ids.has(ke.column.id))return null;const je=he.get(ke.column.id),Ue=T!==null&&T.row===Z.index&&T.col===qe?" ring-1 ring-ring ring-inset":"";return d("td",{className:it("group/cell truncate font-mono text-muted-foreground",je!==void 0&&"border-e border-border bg-background",Ue),onPointerDown:()=>{F({col:qe,row:Z.index})},style:je===void 0?At(ke.column.getSize()):cn(ke.column.getSize(),je),children:ke.column.id.startsWith(Rt)?d(Xo,{counts:f[ke.column.id.slice(Rt.length)],rowId:Ae}):d(is,{cell:ke,edit:o,highlight:i,mask:c,refs:b})},ke.id)}),H.tailPx>0&&d("td",{"aria-hidden":"true",style:{flex:`0 0 ${H.tailPx.toString()}px`}}),E("td",{className:"flex items-center gap-1",style:Jt,children:[d("button",{className:St,"data-testid":`db-inspect-${Ae}`,onClick:()=>{a(ye)},type:"button",children:"Details"}),t&&E(Xe,{children:[d("button",{className:St,"data-testid":`db-edit-${Ae}`,disabled:te===null,onClick:()=>{r(te,ye)},type:"button",children:"Edit"}),d("button",{className:St,"data-testid":`db-delete-${Ae}`,disabled:te===null,onClick:()=>{l(te)},type:"button",children:"Delete"})]})]})]},Me.id)};K=po,re="fill",e[60]!==_.columns||e[61]!==_.count||e[62]!==g||e[63]!==y?(Y=_.count>0&&_.columns===y.getVisibleLeafColumns().map(ws).join("\0")&&d("p",{className:"border-b border-warning/40 bg-warning/5 px-3 py-1.5 text-xs text-warning","data-testid":"db-paste-skipped",children:g("{count} pasted cells were skipped",{count:_.count})}),e[60]=_.columns,e[61]=_.count,e[62]=g,e[63]=y,e[64]=Y):Y=e[64],ee="db-scroll",ne=V,le=q,be=h,ce="grid",de=Ko,ue=0,fe="w-full text-xs",U="db-rows",X=Go;let pe;e[65]!==y?(pe=d(us,{table:y}),e[65]=y,e[66]=pe):pe=e[66];let Se;e[67]===Symbol.for("react.memo_cache_sentinel")?(Se=d("th",{"aria-label":"Row actions",style:Jt}),e[67]=Se):Se=e[67],Q=d("thead",{className:"bg-muted/50",children:E("tr",{className:"border-b border-border",style:Ho,children:[pe,H.leadPx>0&&d("th",{"aria-hidden":"true",style:{flex:`0 0 ${H.leadPx.toString()}px`}}),y.getFlatHeaders().map(Z=>H.ids.has(Z.column.id)?d(ds,{declaredType:n?.[Z.column.id]?.type,draggedRef:w,header:Z,masked:c.columns.has(Z.column.id),onTogglePin:m,pinnedOffset:he.get(Z.column.id),table:y},Z.id):null),H.tailPx>0&&d("th",{"aria-hidden":"true",style:{flex:`0 0 ${H.tailPx.toString()}px`}}),Se]})}),ve=C,ae=S.map(Z=>ge(Z)),e[19]=T,e[20]=h,e[21]=f,e[22]=n,e[23]=o,e[24]=t,e[25]=i,e[26]=c,e[27]=l,e[28]=r,e[29]=V,e[30]=q,e[31]=a,e[32]=m,e[33]=_.columns,e[34]=_.count,e[35]=p,e[36]=b,e[37]=x,e[38]=g,e[39]=y,e[40]=N,e[41]=C,e[42]=k,e[43]=S,e[44]=K,e[45]=U,e[46]=X,e[47]=Q,e[48]=ee,e[49]=ne,e[50]=le,e[51]=be,e[52]=ce,e[53]=de,e[54]=ue,e[55]=re,e[56]=Y,e[57]=ve,e[58]=ae,e[59]=fe}else K=e[44],U=e[45],X=e[46],Q=e[47],ee=e[48],ne=e[49],le=e[50],be=e[51],ce=e[52],de=e[53],ue=e[54],re=e[55],Y=e[56],ve=e[57],ae=e[58],fe=e[59];let me;e[68]!==ve||e[69]!==ae?(me=d("tbody",{style:ve,children:ae}),e[68]=ve,e[69]=ae,e[70]=me):me=e[70];let oe;e[71]!==U||e[72]!==X||e[73]!==Q||e[74]!==me||e[75]!==fe?(oe=E("table",{className:fe,"data-testid":U,style:X,children:[Q,me]}),e[71]=U,e[72]=X,e[73]=Q,e[74]=me,e[75]=fe,e[76]=oe):oe=e[76];let W;e[77]!==ee||e[78]!==ne||e[79]!==le||e[80]!==be||e[81]!==ce||e[82]!==de||e[83]!==ue||e[84]!==oe?(W=d("div",{"data-testid":ee,onKeyDown:ne,onPaste:le,ref:be,role:ce,style:de,tabIndex:ue,children:oe}),e[77]=ee,e[78]=ne,e[79]=le,e[80]=be,e[81]=ce,e[82]=de,e[83]=ue,e[84]=oe,e[85]=W):W=e[85];let z;return e[86]!==K||e[87]!==re||e[88]!==Y||e[89]!==W?(z=E(K,{layout:re,children:[Y,W]}),e[86]=K,e[87]=re,e[88]=Y,e[89]=W,e[90]=z):z=e[90],z},gs=(s,e,n,o=[])=>{const t=s?.columns,c=s?.rows,l=s?.refs,r=Et(()=>{if(t===void 0)return[];const w=t.map(T=>({accessorFn:F=>F[T],header:l?.[T]===void 0?T:`${T} →`,id:T}));for(const T of o)w.push({accessorFn:()=>{},enableSorting:!1,header:`← ${T.table}`,id:Yo(T)});return w},[o,t,l]),a=Et(()=>c??[],[c]),[i,f]=P({}),[m,p]=P({}),b=uo({columnResizeMode:"onChange",columns:r,data:a,defaultColumn:{minSize:80,size:200},enableColumnResizing:!0,enableRowSelection:w=>Pe(w.original)!==null,features:Lo,getRowId:(w,T)=>Pe(w)??`row-${T.toString()}`,manualSorting:!0,onColumnVisibilityChange:p,onRowSelectionChange:f,onSortingChange:n,state:{columnVisibility:m,rowSelection:i,sorting:e}}),u=b.getRowModel().rows,g=We(null),h=mo({count:u.length,estimateSize:()=>qo,getScrollElement:()=>g.current,initialRect:{height:Gt,width:0},observeElementRect:(w,T)=>go(w,T,Gt),overscan:8}),x=at(w=>{h.scrollToIndex(w)},[h]),[v,y]=P({left:0,width:0}),N=at(w=>{if(g.current=w,w===null)return;const T=()=>{y(R=>R.left===w.scrollLeft&&R.width===w.clientWidth?R:{left:w.scrollLeft,width:w.clientWidth})};w.addEventListener("scroll",T,{passive:!0});const F=new ResizeObserver(T);return F.observe(w),()=>{w.removeEventListener("scroll",T),F.disconnect(),g.current=null}},[]),C=h.getVirtualItems(),S={display:"block",height:`${h.getTotalSize().toString()}px`,position:"relative"};return{attachScroll:N,scrollLeft:v.left,scrollToIndex:x,table:b,tableRows:u,tbodyStyle:S,viewportWidth:v.width,virtualRows:C}};function ps(s){const[e,n]=s;return E("div",{className:"contents",children:[d("dt",{className:"truncate font-mono text-[11px] text-muted-foreground",children:e}),d("dd",{className:"truncate font-mono text-[11px] text-foreground",title:Fe(n),children:Fe(n)})]},e)}function bs(s){return s.id}function hs(s){return s.original}function xs(s){return{getSize:()=>s.getSize(),id:s.id}}function vs(s){return{getSize:()=>s.getSize(),id:s.id}}function ws(s){return s.id}const ys=s=>{const e=B(22),{onCommit:n}=s,o=we(),[t,c]=P(""),l=We(null);let r,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{l.current?.focus()},a=[],e[0]=r,e[1]=a):(r=e[0],a=e[1]),Be(r,a);let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=y=>{c(y.target.value)},e[2]=i):i=e[2];const f=i;let m;e[3]!==t||e[4]!==n?(m=()=>{const y=t.trim();y!==""&&n(y)},e[3]=t,e[4]=n,e[5]=m):m=e[5];const p=m;let b;e[6]!==o?(b=o("Query name"),e[6]=o,e[7]=b):b=e[7];let u;e[8]!==o?(u=o("Query name"),e[8]=o,e[9]=u):u=e[9];let g;e[10]!==t||e[11]!==b||e[12]!==u?(g=d("input",{"aria-label":b,className:"h-7 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"db-save-query-name",onChange:f,placeholder:u,ref:l,value:t}),e[10]=t,e[11]=b,e[12]=u,e[13]=g):g=e[13];let h;e[14]!==o?(h=o("Save"),e[14]=o,e[15]=h):h=e[15];let x;e[16]!==p||e[17]!==h?(x=d("button",{className:_t,"data-testid":"db-save-query-confirm",onClick:p,type:"button",children:h}),e[16]=p,e[17]=h,e[18]=x):x=e[18];let v;return e[19]!==g||e[20]!==x?(v=E("span",{className:"inline-flex items-center gap-1",children:[g,x]}),e[19]=g,e[20]=x,e[21]=v):v=e[21],v},Cs=s=>{const e=B(27),{onApply:n,onCopyLink:o,onDelete:t,onSave:c,saved:l}=s,r=we(),[a,i]=P(!1);let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{i(!0)},e[0]=f):f=e[0];const m=f;let p;e[1]!==c?(p=S=>{c(S),i(!1)},e[1]=c,e[2]=p):p=e[2];const b=p;let u;e[3]!==n||e[4]!==l?(u=S=>{const w=l[Number(S.currentTarget.dataset.index)];w!==void 0&&n(w)},e[3]=n,e[4]=l,e[5]=u):u=e[5];const g=u;let h;e[6]!==t||e[7]!==l?(h=S=>{const w=l[Number(S.currentTarget.dataset.index)];w!==void 0&&t(w.name)},e[6]=t,e[7]=l,e[8]=h):h=e[8];const x=h;let v;e[9]!==r?(v=r("Copy link"),e[9]=r,e[10]=v):v=e[10];let y;e[11]!==o||e[12]!==v?(y=d("button",{className:_t,"data-testid":"db-copy-link",onClick:o,type:"button",children:v}),e[11]=o,e[12]=v,e[13]=y):y=e[13];let N;e[14]!==b||e[15]!==a||e[16]!==r?(N=a?d(ys,{onCommit:b}):d("button",{className:_t,"data-testid":"db-save-query",onClick:m,type:"button",children:r("Save query")}),e[14]=b,e[15]=a,e[16]=r,e[17]=N):N=e[17];let C;e[18]!==g||e[19]!==x||e[20]!==l||e[21]!==r?(C=l.length>0&&E("div",{className:"flex flex-wrap items-center gap-1","data-testid":"db-saved-queries",children:[d("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:r("Saved")}),l.map((S,w)=>E("span",{className:"inline-flex items-center overflow-hidden rounded-md border border-border",children:[d("button",{className:"px-2 py-0.5 text-xs text-foreground transition-colors hover:bg-accent","data-index":w,"data-testid":`db-saved-query-${S.name}`,onClick:g,type:"button",children:S.name}),d("button",{"aria-label":r("Delete saved query {name}",{name:S.name}),className:"border-l border-border px-1 py-0.5 text-xs text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive","data-index":w,"data-testid":`db-saved-query-delete-${S.name}`,onClick:x,type:"button",children:"✕"})]},S.name))]}),e[18]=g,e[19]=x,e[20]=l,e[21]=r,e[22]=C):C=e[22];let k;return e[23]!==y||e[24]!==N||e[25]!==C?(k=E("div",{className:"flex flex-wrap items-center gap-1.5","data-testid":"db-query-bar",children:[y,N,C]}),e[23]=y,e[24]=N,e[25]=C,e[26]=k):k=e[26],k},He="w-full rounded-md border border-border bg-background px-2 py-1 font-mono text-xs outline-none focus-visible:border-ring",un=/(?:_creationtime|(?:^|[a-z])(?:time|at))$/iu,Ut=(s,e)=>typeof e=="boolean"?"boolean":typeof e=="number"?un.test(s)?"date":"number":e!==null&&typeof e=="object"?"json":"text",Ns=(s,e,n)=>n===void 0?Ut(s,e):n.enumValues!==void 0&&n.enumValues.length>0?"enum":n.type==="boolean"?"boolean":n.type==="number"?un.test(s)?"date":"number":Ut(s,e),Ss=s=>{try{const e=JSON.parse(s);return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}catch{return null}},ks=s=>{const e=new Date(s),n=o=>String(o).padStart(2,"0");return`${e.getFullYear().toString()}-${n(e.getMonth()+1)}-${n(e.getDate())}T${n(e.getHours())}:${n(e.getMinutes())}`},Je="\0clear",Ts=s=>{const e=B(23),{column:n,nullable:o,onChange:t,value:c}=s,l=we();let r;e[0]!==n||e[1]!==t?(r=v=>{t(n,v)},e[0]=n,e[1]=t,e[2]=r):r=e[2];const a=r;let i;e[3]!==n||e[4]!==t?(i=v=>{t(n,v.target.value===Je?null:v.target.value==="true")},e[3]=n,e[4]=t,e[5]=i):i=e[5];const f=i;if(!o&&c!==null){const v=c===!0,y=`db-field-${n}`;let N;return e[6]!==n||e[7]!==a||e[8]!==v||e[9]!==y?(N=d(Dt,{"aria-label":n,checked:v,"data-testid":y,onCheckedChange:a}),e[6]=n,e[7]=a,e[8]=v,e[9]=y,e[10]=N):N=e[10],N}const m=`db-field-${n}`,p=c===!0||c===!1?String(c):Je;let b;e[11]!==l?(b=l("(none)"),e[11]=l,e[12]=b):b=e[12];let u;e[13]!==b?(u=d("option",{value:Je,children:b}),e[13]=b,e[14]=u):u=e[14];let g,h;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=d("option",{value:"true",children:"true"}),h=d("option",{value:"false",children:"false"}),e[15]=g,e[16]=h):(g=e[15],h=e[16]);let x;return e[17]!==n||e[18]!==f||e[19]!==m||e[20]!==p||e[21]!==u?(x=E("select",{"aria-label":n,className:He,"data-testid":m,onChange:f,value:p,children:[u,g,h]}),e[17]=n,e[18]=f,e[19]=m,e[20]=p,e[21]=u,e[22]=x):x=e[22],x},Es=s=>{const e=B(23),{column:n,nullable:o,onChange:t,options:c,value:l}=s,r=we(),a=typeof l=="string"?l:null;let i;e[0]!==c||e[1]!==a?(i=a!==null&&!c.includes(a),e[0]=c,e[1]=a,e[2]=i):i=e[2];const f=i;let m;e[3]!==n||e[4]!==t?(m=y=>{t(n,y.target.value===Je?null:y.target.value)},e[3]=n,e[4]=t,e[5]=m):m=e[5];const p=m,b=`db-field-${n}`,u=a??Je;let g;e[6]!==o||e[7]!==a||e[8]!==r?(g=(o||a===null)&&d("option",{value:Je,children:r("(none)")}),e[6]=o,e[7]=a,e[8]=r,e[9]=g):g=e[9];let h;e[10]!==a||e[11]!==f?(h=f&&d("option",{value:a,children:a}),e[10]=a,e[11]=f,e[12]=h):h=e[12];let x;e[13]!==c?(x=c.map(Is),e[13]=c,e[14]=x):x=e[14];let v;return e[15]!==n||e[16]!==p||e[17]!==b||e[18]!==u||e[19]!==g||e[20]!==h||e[21]!==x?(v=E("select",{"aria-label":n,className:He,"data-testid":b,onChange:p,value:u,children:[g,h,x]}),e[15]=n,e[16]=p,e[17]=b,e[18]=u,e[19]=g,e[20]=h,e[21]=x,e[22]=v):v=e[22],v},_s=s=>{const e=B(8),{column:n,onChange:o,value:t}=s;let c;e[0]!==n||e[1]!==o?(c=f=>{const m=Number(f.target.value);f.target.value!==""&&!Number.isNaN(m)&&o(n,m)},e[0]=n,e[1]=o,e[2]=c):c=e[2];const l=c,r=`db-field-${n}`,a=typeof t=="number"?t:"";let i;return e[3]!==n||e[4]!==l||e[5]!==r||e[6]!==a?(i=d("input",{"aria-label":n,className:He,"data-testid":r,onChange:l,type:"number",value:a}),e[3]=n,e[4]=l,e[5]=r,e[6]=a,e[7]=i):i=e[7],i},Rs=s=>{const e=B(10),{column:n,onChange:o,value:t}=s;let c;e[0]!==n||e[1]!==o?(c=f=>{const m=new Date(f.target.value).getTime();Number.isNaN(m)||o(n,m)},e[0]=n,e[1]=o,e[2]=c):c=e[2];const l=c,r=`db-field-${n}`;let a;e[3]!==t?(a=typeof t=="number"?ks(t):"",e[3]=t,e[4]=a):a=e[4];let i;return e[5]!==n||e[6]!==l||e[7]!==r||e[8]!==a?(i=d("input",{"aria-label":n,className:He,"data-testid":r,onChange:l,type:"datetime-local",value:a}),e[5]=n,e[6]=l,e[7]=r,e[8]=a,e[9]=i):i=e[9],i},$s=s=>{const e=B(8),{column:n,onChange:o,value:t}=s;let c;e[0]!==n||e[1]!==o?(c=f=>{o(n,f.target.value)},e[0]=n,e[1]=o,e[2]=c):c=e[2];const l=c,r=`db-field-${n}`,a=typeof t=="string"?t:"";let i;return e[3]!==n||e[4]!==l||e[5]!==r||e[6]!==a?(i=d("input",{"aria-label":n,className:He,"data-testid":r,onChange:l,type:"text",value:a}),e[3]=n,e[4]=l,e[5]=r,e[6]=a,e[7]=i):i=e[7],i},Ds=s=>{const e=B(20),{column:n,onChange:o,value:t}=s,c=we();let l;e[0]!==t?(l=()=>JSON.stringify(t,null,2),e[0]=t,e[1]=l):l=e[1];const[r,a]=P(l),[i,f]=P(!1);let m;e[2]!==n||e[3]!==o?(m=y=>{const N=y.target.value;a(N);try{o(n,JSON.parse(N)),f(!1)}catch{f(!0)}},e[2]=n,e[3]=o,e[4]=m):m=e[4];const p=m,b=i&&"border-destructive";let u;e[5]!==b?(u=it(He,"min-h-16",b),e[5]=b,e[6]=u):u=e[6];const g=`db-field-${n}`;let h;e[7]!==n||e[8]!==p||e[9]!==u||e[10]!==g||e[11]!==r?(h=d("textarea",{"aria-label":n,className:u,"data-testid":g,onChange:p,value:r}),e[7]=n,e[8]=p,e[9]=u,e[10]=g,e[11]=r,e[12]=h):h=e[12];let x;e[13]!==n||e[14]!==i||e[15]!==c?(x=i&&d("span",{className:"text-xs text-destructive","data-testid":`db-field-error-${n}`,children:c("Invalid JSON")}),e[13]=n,e[14]=i,e[15]=c,e[16]=x):x=e[16];let v;return e[17]!==h||e[18]!==x?(v=E("div",{className:"flex flex-col gap-1",children:[h,x]}),e[17]=h,e[18]=x,e[19]=v):v=e[19],v},Ps=s=>{const e=B(56),{column:n,meta:o,onChange:t,target:c,value:l}=s;let r;e[0]!==n||e[1]!==o||e[2]!==l?(r=Ns(n,l,o),e[0]=n,e[1]=o,e[2]=l,e[3]=r):r=e[3];const a=r,i=`db-field-${n}`;let f;e[4]!==n?(f=d("span",{className:"font-mono",children:n}),e[4]=n,e[5]=f):f=e[5];let m;e[6]!==n||e[7]!==o?(m=o!==void 0&&d("span",{className:"rounded bg-muted px-1 font-mono text-[10px] tracking-wide","data-testid":`db-field-type-${n}`,children:o.type}),e[6]=n,e[7]=o,e[8]=m):m=e[8];let p;e[9]!==c?(p=c!==void 0&&E("span",{className:"rounded bg-muted px-1 font-mono text-[10px] tracking-wide uppercase",children:["→ ",c]}),e[9]=c,e[10]=p):p=e[10];let b;e[11]!==f||e[12]!==m||e[13]!==p?(b=E("span",{className:"flex items-center gap-1.5 font-medium text-muted-foreground",children:[f,m,p]}),e[11]=f,e[12]=m,e[13]=p,e[14]=b):b=e[14];let u;e[15]!==n||e[16]!==a||e[17]!==o?.nullable||e[18]!==t||e[19]!==l?(u=a==="boolean"&&d(Ts,{column:n,nullable:o?.nullable===!0,onChange:t,value:l}),e[15]=n,e[16]=a,e[17]=o?.nullable,e[18]=t,e[19]=l,e[20]=u):u=e[20];let g;e[21]!==n||e[22]!==a||e[23]!==o||e[24]!==t||e[25]!==l?(g=a==="enum"&&o?.enumValues!==void 0&&d(Es,{column:n,nullable:o.nullable===!0,onChange:t,options:o.enumValues,value:l}),e[21]=n,e[22]=a,e[23]=o,e[24]=t,e[25]=l,e[26]=g):g=e[26];let h;e[27]!==n||e[28]!==a||e[29]!==t||e[30]!==l?(h=a==="number"&&d(_s,{column:n,onChange:t,value:l}),e[27]=n,e[28]=a,e[29]=t,e[30]=l,e[31]=h):h=e[31];let x;e[32]!==n||e[33]!==a||e[34]!==t||e[35]!==l?(x=a==="date"&&d(Rs,{column:n,onChange:t,value:l}),e[32]=n,e[33]=a,e[34]=t,e[35]=l,e[36]=x):x=e[36];let v;e[37]!==n||e[38]!==a||e[39]!==t||e[40]!==l?(v=a==="json"&&d(Ds,{column:n,onChange:t,value:l}),e[37]=n,e[38]=a,e[39]=t,e[40]=l,e[41]=v):v=e[41];let y;e[42]!==n||e[43]!==a||e[44]!==t||e[45]!==l?(y=a==="text"&&d($s,{column:n,onChange:t,value:l}),e[42]=n,e[43]=a,e[44]=t,e[45]=l,e[46]=y):y=e[46];let N;return e[47]!==x||e[48]!==v||e[49]!==y||e[50]!==i||e[51]!==b||e[52]!==u||e[53]!==g||e[54]!==h?(N=E("label",{className:"flex flex-col gap-1 text-xs",htmlFor:i,children:[b,u,g,h,x,v,y]}),e[47]=x,e[48]=v,e[49]=y,e[50]=i,e[51]=b,e[52]=u,e[53]=g,e[54]=h,e[55]=N):N=e[55],N},As=s=>{const e=B(49),{columnMeta:n,documentText:o,onCancel:t,onDocumentTextChange:c,onSave:l,refs:r}=s,a=we();let i;e[0]!==o?(i=Ss(o),e[0]=o,e[1]=i):i=e[1];const f=i,[m,p]=P(!1),b=!m&&f!==null;let u;e[2]!==f||e[3]!==c?(u=(O,J)=>{c(JSON.stringify({...f,[O]:J},null,2))},e[2]=f,e[3]=c,e[4]=u):u=e[4];const g=u;let h;e[5]!==c?(h=O=>{c(O.target.value)},e[5]=c,e[6]=h):h=e[6];const x=h;let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{p(!1)},e[7]=v):v=e[7];const y=v;let N;e[8]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{p(!0)},e[8]=N):N=e[8];const C=N,k=f===null;let S;e[9]!==a?(S=a("Form"),e[9]=a,e[10]=S):S=e[10];let w;e[11]!==b||e[12]!==k||e[13]!==S?(w=d("button",{"aria-pressed":b,className:De,"data-testid":"db-editor-form",disabled:k,onClick:y,type:"button",children:S}),e[11]=b,e[12]=k,e[13]=S,e[14]=w):w=e[14];const T=!b;let F;e[15]!==a?(F=a("JSON"),e[15]=a,e[16]=F):F=e[16];let R;e[17]!==F||e[18]!==T?(R=d("button",{"aria-pressed":T,className:De,"data-testid":"db-editor-json",onClick:C,type:"button",children:F}),e[17]=F,e[18]=T,e[19]=R):R=e[19];let _;e[20]!==R||e[21]!==w?(_=E("div",{className:"flex items-center gap-1.5",children:[w,R]}),e[20]=R,e[21]=w,e[22]=_):_=e[22];let $;e[23]!==n||e[24]!==o||e[25]!==f||e[26]!==g||e[27]!==x||e[28]!==r||e[29]!==b||e[30]!==a?($=b?d("div",{className:"flex flex-col gap-3","data-testid":"db-editor-fields",children:Object.entries(f).map(O=>{const[J,K]=O;return d(Ps,{column:J,meta:n?.[J],onChange:g,target:r?.[J],value:K},J)})}):d("textarea",{"aria-label":a("Row document JSON"),className:"min-h-28 w-full rounded-md border border-border bg-background px-2 py-1.5 font-mono text-xs outline-none focus-visible:border-ring","data-testid":"db-editor-doc",onChange:x,value:o}),e[23]=n,e[24]=o,e[25]=f,e[26]=g,e[27]=x,e[28]=r,e[29]=b,e[30]=a,e[31]=$):$=e[31];let I;e[32]!==a?(I=a("Save"),e[32]=a,e[33]=I):I=e[33];let L;e[34]!==l||e[35]!==I?(L=d("button",{className:De,"data-testid":"db-editor-save",onClick:l,type:"button",children:I}),e[34]=l,e[35]=I,e[36]=L):L=e[36];let D;e[37]!==a?(D=a("Cancel"),e[37]=a,e[38]=D):D=e[38];let V;e[39]!==t||e[40]!==D?(V=d("button",{className:De,"data-testid":"db-editor-cancel",onClick:t,type:"button",children:D}),e[39]=t,e[40]=D,e[41]=V):V=e[41];let G;e[42]!==L||e[43]!==V?(G=E("div",{className:"flex items-center gap-1.5",children:[L,V]}),e[42]=L,e[43]=V,e[44]=G):G=e[44];let q;return e[45]!==_||e[46]!==$||e[47]!==G?(q=E("div",{className:"flex flex-col gap-2 border border-border bg-card p-3","data-testid":"db-editor",children:[_,$,G]}),e[45]=_,e[46]=$,e[47]=G,e[48]=q):q=e[48],q};function Is(s){return d("option",{value:s,children:s},s)}const Os=s=>{const e=B(71),{columns:n,editable:o,filter:t,filters:c,hasMaskedColumns:l,hasPredicate:r,liveError:a,maskOn:i,onAddRow:f,onBulkDelete:m,onBulkPatch:p,onAskAiFilter:b,onClearTable:u,onFilterChange:g,onFiltersChange:h,onGenerateRows:x,onShowJson:v,onShowTable:y,onToggleMask:N,total:C,totalKnown:k,viewMode:S}=s,w=we(),T=S==="table";let F;e[0]!==y||e[1]!==T?(F=d("button",{"aria-pressed":T,className:De,"data-testid":"db-view-table",onClick:y,type:"button",children:"Table"}),e[0]=y,e[1]=T,e[2]=F):F=e[2];const R=S==="json";let _;e[3]!==v||e[4]!==R?(_=d("button",{"aria-pressed":R,className:De,"data-testid":"db-view-json",onClick:v,type:"button",children:"JSON"}),e[3]=v,e[4]=R,e[5]=_):_=e[5];let $;e[6]!==a||e[7]!==w?($=a===void 0?w("Live — changes stream in automatically"):w("Live unavailable: {liveError}",{liveError:a}),e[6]=a,e[7]=w,e[8]=$):$=e[8];const I=`size-1.5 rounded-full ${a===void 0?"bg-success":"bg-muted-foreground/50"}`;let L;e[9]!==I?(L=d("span",{"aria-hidden":"true",className:I}),e[9]=I,e[10]=L):L=e[10];let D;e[11]!==a||e[12]!==w?(D=w(a===void 0?"Live":"Live unavailable"),e[11]=a,e[12]=w,e[13]=D):D=e[13];let V;e[14]!==$||e[15]!==L||e[16]!==D?(V=E("span",{className:"inline-flex items-center gap-1.5 px-1 text-xs font-medium text-muted-foreground","data-testid":"db-live-indicator",role:"status",title:$,children:[L,D]}),e[14]=$,e[15]=L,e[16]=D,e[17]=V):V=e[17];let G;e[18]!==l||e[19]!==i||e[20]!==N||e[21]!==w?(G=l&&d("button",{"aria-pressed":i,className:De,"data-testid":"db-mask-toggle",onClick:N,type:"button",children:w("Mask sensitive columns")}),e[18]=l,e[19]=i,e[20]=N,e[21]=w,e[22]=G):G=e[22];let q;e[23]!==o||e[24]!==f?(q=o&&d("button",{className:De,"data-testid":"db-add-row",onClick:f,type:"button",children:"Add row"}),e[23]=o,e[24]=f,e[25]=q):q=e[25];let O;e[26]!==o||e[27]!==x||e[28]!==w?(O=o&&x!==void 0&&d("button",{className:De,"data-testid":"db-generate-rows",onClick:x,type:"button",children:w("Generate rows")}),e[26]=o,e[27]=x,e[28]=w,e[29]=O):O=e[29];let J;e[30]!==o||e[31]!==r||e[32]!==m||e[33]!==w||e[34]!==C||e[35]!==k?(J=o&&C>0&&r&&d(jt,{confirmLabel:k?w("Permanently delete {total} matching rows and everything that cascades?",{total:C.toString()}):w("Permanently delete all matching rows and everything that cascades?"),onConfirm:m,testId:"db-bulk-delete",children:k?w("Delete {total} matching",{total:C.toString()}):w("Delete matching")}),e[30]=o,e[31]=r,e[32]=m,e[33]=w,e[34]=C,e[35]=k,e[36]=J):J=e[36];let K;e[37]!==o||e[38]!==r||e[39]!==p||e[40]!==w||e[41]!==C||e[42]!==k?(K=o&&k&&C>0&&r&&d("button",{className:De,"data-testid":"db-bulk-patch",onClick:p,type:"button",children:w("Set column on {total} matching",{total:C.toString()})}),e[37]=o,e[38]=r,e[39]=p,e[40]=w,e[41]=C,e[42]=k,e[43]=K):K=e[43];let U;e[44]!==o||e[45]!==r||e[46]!==u||e[47]!==w||e[48]!==C||e[49]!==k?(U=o&&C>0&&!r&&d(jt,{confirmLabel:k?w("Permanently clear all {total} rows and everything that cascades?",{total:C.toString()}):w("Permanently clear every row and everything that cascades?"),onConfirm:u,testId:"db-clear-table",children:k?w("Clear table ({total})",{total:C.toString()}):w("Clear table")}),e[44]=o,e[45]=r,e[46]=u,e[47]=w,e[48]=C,e[49]=k,e[50]=U):U=e[50];let X;e[51]!==G||e[52]!==q||e[53]!==O||e[54]!==J||e[55]!==K||e[56]!==U||e[57]!==F||e[58]!==_||e[59]!==V?(X=E("div",{className:"flex flex-wrap items-center gap-1.5",children:[F,_,V,G,q,O,J,K,U]}),e[51]=G,e[52]=q,e[53]=O,e[54]=J,e[55]=K,e[56]=U,e[57]=F,e[58]=_,e[59]=V,e[60]=X):X=e[60];let Q;e[61]!==n||e[62]!==t||e[63]!==c||e[64]!==b||e[65]!==g||e[66]!==h?(Q=d(ho,{columns:n,filters:c,onAskAi:b,onFiltersChange:h,onSearchChange:g,search:t}),e[61]=n,e[62]=t,e[63]=c,e[64]=b,e[65]=g,e[66]=h,e[67]=Q):Q=e[67];let ee;return e[68]!==X||e[69]!==Q?(ee=E("div",{className:"flex flex-col gap-2","data-testid":"db-view-toggle",children:[X,Q]}),e[68]=X,e[69]=Q,e[70]=ee):ee=e[70],ee},Fs=s=>{const e=B(110),{assistant:n,backRelations:o,browser:t,columnMeta:c,edit:l,editable:r,onAskAiFilter:a,onInspect:i,onOpenBulkPatch:f,onOpenGenerateRows:m,onRowDelete:p,onSaveQuery:b,page:u,preferences:g,queryBar:h,references:x}=s,v=g.maskColumns.size>0,y=n.unavailable?void 0:a;let N;e[0]!==t.addRow||e[1]!==t.bulkDelete||e[2]!==t.clearTable||e[3]!==t.columns||e[4]!==t.filter||e[5]!==t.filters||e[6]!==t.hasPredicate||e[7]!==t.liveError||e[8]!==t.onFilterChange||e[9]!==t.onFiltersChange||e[10]!==t.showJson||e[11]!==t.showTable||e[12]!==t.total||e[13]!==t.totalKnown||e[14]!==t.viewMode||e[15]!==r||e[16]!==f||e[17]!==m||e[18]!==g.maskOn||e[19]!==g.onToggleMask||e[20]!==v||e[21]!==y?(N=d(Os,{columns:t.columns,editable:r,filter:t.filter,filters:t.filters,hasMaskedColumns:v,hasPredicate:t.hasPredicate,liveError:t.liveError,maskOn:g.maskOn,onAddRow:t.addRow,onAskAiFilter:y,onBulkDelete:t.bulkDelete,onBulkPatch:f,onClearTable:t.clearTable,onFilterChange:t.onFilterChange,onFiltersChange:t.onFiltersChange,onGenerateRows:m,onShowJson:t.showJson,onShowTable:t.showTable,onToggleMask:g.onToggleMask,total:t.total,totalKnown:t.totalKnown,viewMode:t.viewMode}),e[0]=t.addRow,e[1]=t.bulkDelete,e[2]=t.clearTable,e[3]=t.columns,e[4]=t.filter,e[5]=t.filters,e[6]=t.hasPredicate,e[7]=t.liveError,e[8]=t.onFilterChange,e[9]=t.onFiltersChange,e[10]=t.showJson,e[11]=t.showTable,e[12]=t.total,e[13]=t.totalKnown,e[14]=t.viewMode,e[15]=r,e[16]=f,e[17]=m,e[18]=g.maskOn,e[19]=g.onToggleMask,e[20]=v,e[21]=y,e[22]=N):N=e[22];let C;e[23]!==b||e[24]!==h?(C=h!==void 0&&d(Cs,{onApply:h.onApplyQuery,onCopyLink:h.onCopyLink,onDelete:h.onDeleteQuery,onSave:b,saved:h.saved}),e[23]=b,e[24]=h,e[25]=C):C=e[25];let k;e[26]!==o||e[27]!==t.onBulkDeleteSelected||e[28]!==t.selectedTable||e[29]!==t.table||e[30]!==t.viewMode||e[31]!==r||e[32]!==u||e[33]!==g.maskView||e[34]!==g.onToggleTranspose||e[35]!==g.transposed?(k=t.viewMode==="table"&&u.rows.length>0&&d(xo,{backRelations:o.available,columns:u.columns,editable:r,enabledBackRelations:o.enabled,name:t.selectedTable??"export",onBulkDelete:t.onBulkDeleteSelected,onToggleBackRelation:o.onToggle,onToggleTranspose:g.onToggleTranspose,rows:wt(u.rows,g.maskView),sqlColumns:u.sqlColumns,table:t.table.table,transposed:g.transposed}),e[26]=o,e[27]=t.onBulkDeleteSelected,e[28]=t.selectedTable,e[29]=t.table,e[30]=t.viewMode,e[31]=r,e[32]=u,e[33]=g.maskView,e[34]=g.onToggleTranspose,e[35]=g.transposed,e[36]=k):k=e[36];let S;e[37]!==t.cancelEdit||e[38]!==t.editing||e[39]!==t.saveEdit||e[40]!==t.setEditorDocumentText||e[41]!==c||e[42]!==r||e[43]!==u?(S=r&&t.editing!==null&&d(As,{columnMeta:c,documentText:t.editing.docText,onCancel:t.cancelEdit,onDocumentTextChange:t.setEditorDocumentText,onSave:t.saveEdit,refs:u.refs}),e[37]=t.cancelEdit,e[38]=t.editing,e[39]=t.saveEdit,e[40]=t.setEditorDocumentText,e[41]=c,e[42]=r,e[43]=u,e[44]=S):S=e[44];let w;e[45]!==t.committing||e[46]!==t.discardStaged||e[47]!==t.onCommitStaged||e[48]!==t.stagedChanges||e[49]!==r?(w=r&&t.stagedChanges.length>0&&d(Bo,{changes:t.stagedChanges,committing:t.committing,onCommit:t.onCommitStaged,onDiscard:t.discardStaged}),e[45]=t.committing,e[46]=t.discardStaged,e[47]=t.onCommitStaged,e[48]=t.stagedChanges,e[49]=r,e[50]=w):w=e[50];let T;e[51]!==t.writeError?(T=t.writeError!==null&&d("p",{className:"text-sm text-destructive","data-testid":"db-write-error",role:"alert",children:t.writeError}),e[51]=t.writeError,e[52]=T):T=e[52];let F;e[53]!==t.writeNotice?(F=t.writeNotice!==null&&d("p",{className:"text-sm text-muted-foreground","data-testid":"db-write-notice",role:"status",children:t.writeNotice}),e[53]=t.writeNotice,e[54]=F):F=e[54];let R;e[55]!==N||e[56]!==C||e[57]!==k||e[58]!==S||e[59]!==w||e[60]!==T||e[61]!==F?(R=E("div",{className:"flex shrink-0 flex-col gap-2 border-b border-border px-4 py-3",children:[N,C,k,S,w,T,F]}),e[55]=N,e[56]=C,e[57]=k,e[58]=S,e[59]=w,e[60]=T,e[61]=F,e[62]=R):R=e[62];let _;e[63]!==t.viewMode||e[64]!==u?(_=t.viewMode==="table"&&u.rows.length===0&&d("div",{className:"flex flex-1 items-center justify-center p-6",children:d(Yn,{description:"Rows you insert into this table will show up here.",icon:d("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:d("path",{d:"M4 5h16v14H4V5Zm0 5h16M10 10v9M4 14.5h16"})}),testId:"db-empty-rows",title:"This table is empty."})}),e[63]=t.viewMode,e[64]=u,e[65]=_):_=e[65];let $;e[66]!==t.viewMode||e[67]!==u||e[68]!==g.maskView||e[69]!==g.transposed?($=t.viewMode==="table"&&u.rows.length>0&&g.transposed&&d(bo,{columns:u.columns,rows:wt(u.rows,g.maskView)}),e[66]=t.viewMode,e[67]=u,e[68]=g.maskView,e[69]=g.transposed,e[70]=$):$=e[70];let I;e[71]!==o||e[72]!==t.filter||e[73]!==t.onRowEdit||e[74]!==t.table||e[75]!==t.viewMode||e[76]!==c||e[77]!==l||e[78]!==r||e[79]!==i||e[80]!==p||e[81]!==u||e[82]!==g.maskView||e[83]!==g.onTogglePin||e[84]!==g.pinnedColumns||e[85]!==g.transposed||e[86]!==x?(I=t.viewMode==="table"&&u.rows.length>0&&!g.transposed&&d(ms,{backRelationCounts:o.counts,columnMeta:c,edit:l,editable:r,highlight:t.filter,mask:g.maskView,onDelete:p,onEdit:t.onRowEdit,onInspect:i,onTogglePin:g.onTogglePin,pinnedColumns:g.pinnedColumns,refs:x,tableModel:t.table}),e[71]=o,e[72]=t.filter,e[73]=t.onRowEdit,e[74]=t.table,e[75]=t.viewMode,e[76]=c,e[77]=l,e[78]=r,e[79]=i,e[80]=p,e[81]=u,e[82]=g.maskView,e[83]=g.onTogglePin,e[84]=g.pinnedColumns,e[85]=g.transposed,e[86]=x,e[87]=I):I=e[87];let L;e[88]!==t.viewMode||e[89]!==u||e[90]!==g.maskView?(L=t.viewMode==="json"&&d("pre",{className:"min-h-0 flex-1 overflow-auto border-t border-border bg-muted/30 p-3 text-xs","data-testid":"db-json",children:JSON.stringify(wt(u.rows,g.maskView),en,2)}),e[88]=t.viewMode,e[89]=u,e[90]=g.maskView,e[91]=L):L=e[91];let D;e[92]!==t.changePageSize||e[93]!==t.goNext||e[94]!==t.goPrevious||e[95]!==t.hasNext||e[96]!==t.hasPrevious||e[97]!==t.jumpToPage||e[98]!==t.pageSize||e[99]!==t.rangeEnd||e[100]!==t.rangeStart||e[101]!==t.total?(D=d("div",{className:"flex shrink-0 items-center border-t border-border px-4 py-2",children:d(wo,{hasNext:t.hasNext,hasPrevious:t.hasPrevious,onJumpToPage:t.jumpToPage,onNext:t.goNext,onPageSizeChange:t.changePageSize,onPrevious:t.goPrevious,pageSize:t.pageSize,prefix:"db",rangeEnd:t.rangeEnd,rangeStart:t.rangeStart,total:t.total})}),e[92]=t.changePageSize,e[93]=t.goNext,e[94]=t.goPrevious,e[95]=t.hasNext,e[96]=t.hasPrevious,e[97]=t.jumpToPage,e[98]=t.pageSize,e[99]=t.rangeEnd,e[100]=t.rangeStart,e[101]=t.total,e[102]=D):D=e[102];let V;return e[103]!==R||e[104]!==_||e[105]!==$||e[106]!==I||e[107]!==L||e[108]!==D?(V=E("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"db-page",children:[R,_,$,I,L,D]}),e[103]=R,e[104]=_,e[105]=$,e[106]=I,e[107]=L,e[108]=D,e[109]=V):V=e[109],V},Ms="/__lunora/seed",kt=200,Ls=50,Vs=(s,e)=>{const n=[];for(const o of s)o.pk!==!0&&o.ref!==void 0&&o.type==="id"&&(e[o.ref]??[]).length===0&&n.push(o.name);return n},Bs=s=>Array.isArray(s)&&s.every(e=>nn(e)),js=async s=>{let e;try{e=await fetch(Ms,{body:JSON.stringify(s),headers:{"Content-Type":"application/json"},method:"POST"})}catch(o){return{kind:"error",message:`seed request failed: ${Vt(o)}`}}let n;try{n=await e.json()??{}}catch{return{kind:"error",message:`seed request failed (${String(e.status)})`}}if(e.ok&&n.rows!==void 0){let o;try{o=$t(n.rows)}catch(t){return{kind:"error",message:`seed response could not be decoded: ${Vt(t)}`}}return Bs(o)?{kind:"ok",rows:o}:{kind:"error",message:"seed response did not carry a list of row documents"}}return n.error==="fk-parents-empty"?{kind:"error",message:`no rows to reference in ${(Array.isArray(n.tables)?n.tables.filter(t=>typeof t=="string"):[]).join(", ")} — seed those tables first`}:{kind:"error",message:typeof n.error=="string"?n.error:`seed request failed (${String(e.status)})`}},zs="rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50",qs="rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50",Ks=({columns:s,fkPools:e,onClose:n,onInsertRows:o,table:t})=>{const c=we(),[l,r]=P(10),[a,i]=P(!1),[f,m]=P(void 0),[p,b]=P(void 0),[u,g]=P(0),h=C=>{const k=Number(C.target.value);!Number.isNaN(k)&&k>=1&&r(Math.min(k,kt))},x=async()=>{m(void 0),b(void 0),g(0),i(!0);try{const C=await js({count:l,existingIds:e,seed:Date.now(),table:t});if(C.kind==="error"){m(C.message);return}const{rows:k}=C;if(k.length===0){m(c("No rows generated — all columns were skipped."));return}const S=await o(k);if(S.error!==void 0){m(S.error);return}b(S.inserted),g(S.conflicts)}finally{i(!1)}},v=()=>{Ce(x())},y=s.filter(C=>C.pk!==!0),N=Vs(s,e);return E(dt,{label:c("Generate dummy rows"),onClose:n,panelTestId:"gen-rows-panel",testId:"gen-rows-overlay",variant:"dialog",children:[E("div",{className:"flex items-start justify-between",children:[E("div",{className:"flex flex-col gap-0.5",children:[d("h3",{className:"text-base text-foreground","data-testid":"gen-rows-title",children:c("Generate dummy rows")}),d("p",{className:"text-xs text-muted-foreground","data-testid":"gen-rows-desc",children:c("Seed {table} with Faker-generated rows. Existing rows are not affected.",{table:t})})]}),d("button",{className:"text-xs text-muted-foreground hover:text-foreground","data-testid":"gen-rows-close",onClick:n,type:"button",children:c("Close")})]}),E("div",{className:"flex items-center gap-2",children:[d("label",{className:"text-xs font-medium text-foreground",htmlFor:"gen-rows-count",children:c("Row count")}),d("input",{className:"w-20 rounded-md border border-border bg-background px-2 py-1 text-xs outline-none focus-visible:border-ring","data-testid":"gen-rows-count",id:"gen-rows-count",max:kt,min:1,onChange:h,type:"number",value:l}),d("span",{className:"text-xs text-muted-foreground",children:c("(max {max})",{max:kt.toString()})})]}),y.length>0&&E("div",{className:"flex flex-col gap-1",children:[d("p",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:c("Columns to seed")}),d("ul",{className:"flex flex-col gap-0.5","data-testid":"gen-rows-columns",children:y.map(C=>{const k=C.ref!==void 0&&C.type==="id",S=k&&(e[C.ref??""]??[]).length===0,w=S?"rounded bg-destructive/10 px-1 text-destructive":"rounded bg-muted px-1 text-muted-foreground",T=S?`gen-rows-fk-empty-${C.name}`:`gen-rows-fk-ok-${C.name}`,F=S?c("FK: no rows in {ref} — seed it first",{ref:C.ref??""}):c("→ {ref}",{ref:C.ref??""});return E("li",{className:"flex items-center gap-1.5 font-mono text-xs",children:[d("span",{className:"text-foreground",children:C.name}),E("span",{className:"text-muted-foreground",children:["(",C.type,")"]}),C.optional&&d("span",{className:"rounded bg-muted px-1 font-mono text-[10px] tracking-wide uppercase",children:"optional"}),k&&d("span",{className:w,"data-testid":T,children:F})]},C.name)})})]}),N.length>0&&d("p",{className:"text-xs text-destructive","data-testid":"gen-rows-blocked",role:"alert",children:c("Cannot generate rows: these columns reference tables with no rows: {cols}. Seed those tables first.",{cols:N.join(", ")})}),f!==void 0&&d("p",{className:"text-xs text-destructive","data-testid":"gen-rows-error",role:"alert",children:f}),p!==void 0&&f===void 0&&d("p",{className:"text-xs text-success","data-testid":"gen-rows-success",children:u>0?c("Inserted {inserted} of {total} rows — {conflicts} skipped as id conflicts.",{conflicts:u.toString(),inserted:p.toString(),total:(p+u).toString()}):c("Inserted {count} rows successfully.",{count:p.toString()})}),E("div",{className:"flex justify-end gap-2",children:[d("button",{className:zs,"data-testid":"gen-rows-cancel",onClick:n,type:"button",children:c("Cancel")}),d("button",{className:qs,"data-testid":"gen-rows-generate",disabled:a||N.length>0,onClick:v,type:"button",children:c(a?"Inserting…":"Generate & insert")})]})]})},Gs=Ee(xe.backRelationCounts),Js=(s,e,n,o)=>{const t=B(16),c=ct();let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l={},t[0]=l):l=t[0];const[r,a]=P(l);let i;if(t[1]!==s||t[2]!==e){let x;t[4]!==s?(x=v=>s.has(Pt(v)),t[4]=s,t[5]=x):x=t[5],i=e.filter(x),t[1]=s,t[2]=e,t[3]=i}else i=t[3];const f=i;let m;t[6]!==n||t[7]!==f?(m=JSON.stringify([f,n]),t[6]=n,t[7]=f,t[8]=m):m=t[8];const p=m;let b;t[9]!==c||t[10]!==o||t[11]!==p?(b=async x=>{const[v,y]=JSON.parse(p);if(v.length===0||y.length===0){x.cancelled||a({});return}try{const N=await c.query(Gs,{ids:y,relations:v},Te(o));x.cancelled||a(Object.fromEntries(N.relations.map(Ws)))}catch{}},t[9]=c,t[10]=o,t[11]=p,t[12]=b):b=t[12];const u=b;let g,h;return t[13]!==u?(g=()=>{const x={cancelled:!1};return Ce(u(x)),()=>{x.cancelled=!0}},h=[u],t[13]=u,t[14]=g,t[15]=h):(g=t[14],h=t[15]),Be(g,h),r};function Ws(s){return[Pt(s),s.counts]}const Hs=async s=>{const{args:e,maxBatches:n,openCursor:o,query:t}=s;let c=o,l=0,r="cap-hit";for(let a=0;a<n;a+=1){const i=await t({...e,after:c});if(l+=i.count,c=i.cursor,!i.hasMore){r="completed";break}}return{cursor:r==="cap-hit"?c:void 0,outcome:r,written:l}},rt=s=>{const e=s[0];return e===void 0?void 0:{column:e.id,direction:e.desc?"desc":"asc"}},fn=s=>Fe(s),Qt=s=>s.map(e=>({column:e.column,...e.value===void 0?{}:{literal:[e.value]},operator:e.operator,value:e.value===void 0?"":fn(e.value)})),Yt=s=>s===void 0?[]:[{desc:s.direction==="desc",id:s.column}],Us=s=>[s.column,s.operator,s.value],st=(s,e,n,o)=>JSON.stringify([s??"",e??"",(n??[]).map(t=>Us(t)),o===void 0?null:[o.column,o.direction]]),It=200,Qs=20,Ys=Ee(xe.readTablePage),Xs=Ee(xe.facetColumn),Tt=Ee(xe.writeRow),Zs=Ee(xe.deleteRows),el=Ee(xe.clearTable),tl=Ee(xe.patchRows),nl={},Ot=new Set(["__doc__","__id__","_creationTime","_id","id"]),ol=s=>{const e=s.__doc__;if(typeof e=="string"){const o=Un(e);if(o!==void 0)return o}const n={};for(const[o,t]of Object.entries(s))Ot.has(o)||(n[o]=t);return n},sl=(s,e,n)=>JSON.stringify([s.__lunoraRef,n,on(e)]),ll=({filters:s,offset:e,pageSize:n,search:o,sorting:t,table:c})=>({filters:Oe(s),limit:n,offset:e,orderBy:rt(t),search:o,skipCount:!0,table:c}),rl=({filters:s,search:e,table:n})=>({filters:Oe(s),limit:1,search:e,table:n}),al=(s,e)=>{const n=new Map;for(const t of s?.rows??[]){const c=Pe(t);c!==null&&n.set(c,t)}const o=[];for(const[t,c]of Object.entries(e))for(const[l,r]of Object.entries(c))o.push({column:l,newValue:r,oldValue:n.get(t)?.[l],rowId:t});return o},il=s=>!Ot.has(s),cl=`Stopped after ${It.toString()} batches — rows still match. Run it again to remove the rest.`,dl=`Stopped after ${It.toString()} batches — rows still match. Run it again to set the rest.`,Xt={resumable:!1,truncated:cl,verb:"deleted"},ul={resumable:!0,truncated:dl,verb:"written"},fl=({initialFilters:s,initialOrderBy:e,initialSearch:n,initialShardKey:o,onSelectTable:t,onViewChange:c,pageSize:l,resolveBackRelations:r,tableParam:a})=>{const i=ct(),[f,m]=P(l),[p,b]=P(o??""),u=a===void 0||a===""?null:a,[g,h]=P(0),[x,v]=P("table"),[y,N]=P(()=>Yt(e)),[C,k]=P(n??""),[S,w]=P(()=>Qt(s??[])),{clearFacets:T,facets:F,refetchFacets:R,toggleFacet:_}=Kn(),[$,I]=P(null),[L,D]=P(null),[V,G]=P(null),q=We(null),O=Vo(),[J,K]=P(null),[U,X]=P(!1),[Q,ee]=P(a),[ne,le]=P(()=>st(o,n,s,e)),[be,ce]=P(0),[de,ue]=P(()=>st(o,n,s,e)),re=a!==Q,Y=st(o,n,s,e),ae=re||!re&&Y!==ne&&Y!==de;if(ae){ee(a),le(Y),ce(j=>j+1),N(Yt(e)),k(n??"");const A=Qt(s??[]);w(A),b(o??""),T(),O.clear(),K(null),I(null),h(0),D(null),G(null),q.current=null}else Y!==ne&&le(Y);const fe=ae?n??"":C,me=ae?o??"":p,oe=`${a??""}:${be.toString()}`,W=zt(fe.trim(),300,oe),z=zt(me.trim(),400,oe),[ie,H]=P(z);ie!==z&&(H(z),O.clear(),K(null),I(null));const he=st(z,W,Oe(S),rt(y));he!==de&&ue(he);const ge=Ye(xe.listTables,nl,{live:!0,shardKey:z}),pe=ge.data??null,Se=ge.error,Z=ll({filters:S,offset:g,pageSize:f,search:W,sorting:y,table:u??""}),Me=rl({filters:S,search:W,table:u??""}),ye=Ye(xe.readTablePage,Z,{enabled:u!==null,keepPreviousData:!1,live:!0,shardKey:z}),te=ye.data??null,Ae=ye.error,{liveError:ze}=ye,ke=Ye(xe.readTablePage,Me,{enabled:u!==null,live:!0,shardKey:z});Be(()=>{ge.data!==void 0&&yo(z)},[ge.data,z]);const qe=A=>{t?.(A)},je=(A,j)=>{t?.(A,{search:j})},Ue=async(A,j)=>{try{return(await i.query(Ys,{filters:[],limit:Qs,offset:0,search:j,table:A},Te(z))).rows.find(Re=>Pe(Re)===j)??null}catch{return null}},Ze=(A,j,Ne,Re)=>$e=>i.query(Xs,{column:$e,filters:Oe(Ne),search:Re,table:j},Te(A)),ut=A=>{_(A,u===null?null:Ze(z,u,S,W))},ft=(A,j)=>{const Ne={column:A,literal:[jn(j)],operator:"eq",value:fn(j)};w(Re=>[...Re.filter($e=>$e.column!==A),Ne]),h(0)},et=yt(Ze),mt=yt(R),tt=yt(c);Be(()=>{u!==null&&mt.current(et.current(z,u,S,W))},[z,u,S,W]),Be(()=>{u===null||tt.current===void 0||Q!==a||ne!==Y||tt.current({filters:Oe(S),orderBy:rt(y),search:W,shard:z})},[u,a,Q,ne,Y,S,y,W,z]);const Ke=A=>{u!==null&&h(Math.max(0,A))},gt=(A,j)=>{K({column:j,rowId:A})},pt=()=>{K(null)},bt=async()=>{if(u!==null){D(null),X(!0);try{for(const[A,j]of Object.entries(O.staged))await i.query(Tt,{doc:j,id:A,op:"patch",table:u},Te(z)),O.drop(A,j)}catch(A){D(A.message)}K(null),ye.refetch(),X(!1)}},ht=()=>{O.clear(),K(null)},xt=A=>{b(A),O.clear(),K(null),I(null),h(0),q.current=null},vt=al(te,O.staged),nt=async(A,j,Ne)=>{if(u===null)return;D(null);let Re;if(A!=="delete"){let $e;try{$e=Ne===void 0||Ne.trim()===""?{}:JSON.parse(Ne)}catch(Ve){D(`Invalid JSON: ${Ve.message}`);return}try{const Ve=$t($e);if(!nn(Ve)){D("The document must be a JSON object.");return}Re=Ve}catch(Ve){D(`Invalid document: ${Ve.message}`);return}}try{await i.query(Tt,{doc:Re,id:j??void 0,op:A,table:u},Te(z)),I(null),ye.refetch()}catch($e){D($e.message)}},M=async(A,j,Ne)=>{if(u===null)return 0;D(null),G(null);const Re=sl(A,j,z),$e=q.current?.key===Re?q.current.after:void 0,Ve=Ne.resumable?$e??"":void 0;let Ge=0;try{const Qe=await Hs({args:j,maxBatches:It,openCursor:Ve,query:async Vn=>{const Lt=await i.query(A,Vn,Te(z));return Ge+=Lt.count,Lt}});return q.current=Qe.cursor===void 0?null:{after:Qe.cursor,key:Re},Qe.outcome==="cap-hit"&&D(Ne.truncated),G(`${Ge.toString()} ${Ge===1?"row":"rows"} ${Ne.verb}.`),Ge}catch(Qe){return D(`${Qe.message} (at least ${Ge.toString()} rows were already ${Ne.verb})`),q.current=null,Ge}finally{h(0),ye.refetch()}},se=A=>{N(A),h(0)},_e=Et(()=>u===null?[]:r?.(u)??[],[r,u]),Ie=gs(te,y,se,_e),Le={filters:Oe(S),orderBy:rt(y),search:W,shard:p,table:u??void 0},ot=ke.data?.total,Ft=ot!==void 0,Mt=ot??(te===null?0:g+te.rows.length),mn=g>0,gn=W!==""||Oe(S).length>0,pn=te!==null&&(Ft?g+te.rows.length<Mt:te.rows.length===f),bn=te===null||te.rows.length===0?0:g+1,hn=te===null?0:g+te.rows.length,xn=()=>{ge.refetch()},vn=()=>{v("table")},wn=()=>{v("json")},yn=()=>{Ce(M(Zs,{filters:Oe(S),search:W,table:u},Xt))},Cn=()=>{Ce(M(el,{table:u},Xt))},Nn=A=>{Ce(M(tl,{doc:A,filters:Oe(S),search:W,table:u},ul))},Sn=A=>{k(A.target.value),h(0)},kn=A=>{w(A),h(0)},Tn=()=>{D(null);const A={};for(const j of te?.columns??[])Ot.has(j)||(A[j]="");I({docText:JSON.stringify(A,null,2),id:""})},En=A=>{I(j=>j===null?j:{docText:A,id:j.id})},_n=()=>{$!==null&&Ce(nt($.id===""?"insert":"patch",$.id===""?null:$.id,$.docText))},Rn=()=>{I(null),D(null)},$n=()=>{Ke(g-f)},Dn=()=>{Ke(g+f)},Pn=A=>{Ke(Math.max(0,(A-1)*f))},An=A=>{m(A),h(0)},In=(A,j)=>{D(null),I({docText:JSON.stringify(on(ol(j)),null,2),id:A})},On=A=>{Ce(nt("delete",A))},Fn=async A=>{if(!(u===null||A.length===0)){D(null);try{for(const j of A)await i.query(Tt,{id:j,op:"delete",table:u},Te(z));ye.refetch()}catch(j){D(j.message)}}},Mn=A=>{Ce(Fn(A))},Ln=()=>{Ce(bt())};return{addRow:Tn,bulkDelete:yn,bulkPatch:Nn,cancelCellEdit:pt,cancelEdit:Rn,changePageSize:An,clearTable:Cn,columns:te?.columns??[],committing:U,currentView:Le,discardStaged:ht,editableColumn:il,editing:$,editingCell:J,facetFilter:ft,facets:F,filter:C,filters:S,goNext:Dn,goPrevious:$n,hasNext:pn,hasPredicate:gn,hasPrevious:mn,jumpToPage:Pn,liveError:ze,loadTables:xn,navigateToRef:je,onBulkDeleteSelected:Mn,onCommitStaged:Ln,onFilterChange:Sn,onFiltersChange:kn,onRowDelete:On,onRowEdit:In,page:te,previewRef:Ue,pageError:Ae,pageSize:f,rangeEnd:hn,rangeStart:bn,queryShardKey:z,saveEdit:_n,selectedTable:u,selectTable:qe,setEditorDocumentText:En,setShardKey:xt,shardKey:p,showJson:wn,showTable:vn,stage:O.stage,stagedChanges:vt,stagedValue:O.stagedValue,startCellEdit:gt,table:Ie,tables:pe,tablesError:Se,toggleFacet:ut,total:Mt,totalKnown:Ft,viewMode:x,writeError:L,writeNotice:V}},ml="lunora-studio-pinned-columns",gl=s=>{const e=B(21),{columns:n,initialPins:o,selectedTable:t}=s;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={},e[0]=c):c=e[0];const[l,r]=Zt(ml,c),a=t??"",i=l[a];let f;e[1]!==o||e[2]!==i?(f=i===void 0?new Set((o??"").split(",").filter(pl)):new Set(i),e[1]=o,e[2]=i,e[3]=f):f=e[3];const m=f;let p;e[4]!==a||e[5]!==m||e[6]!==r?(p=T=>{r(F=>{const R=F[a]??[...m],_=R.includes(T)?R.filter($=>$!==T):[...R,T];return{...F,[a]:_}})},e[4]=a,e[5]=m,e[6]=r,e[7]=p):p=e[7];const b=p,[u,g]=P(!1);let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{g(bl)},e[8]=h):h=e[8];const x=h;let v;e[9]!==n||e[10]!==t?(v={columns:n,selectedTable:t},e[9]=n,e[10]=t,e[11]=v):v=e[11];const{maskColumns:y,maskOn:N,maskView:C,maskViewFor:k,onToggleMask:S}=Gn(v);let w;return e[12]!==y||e[13]!==N||e[14]!==C||e[15]!==k||e[16]!==S||e[17]!==b||e[18]!==m||e[19]!==u?(w={maskColumns:y,maskOn:N,maskView:C,maskViewFor:k,onToggleMask:S,onTogglePin:b,onToggleTranspose:x,pinnedColumns:m,transposed:u},e[12]=y,e[13]=N,e[14]=C,e[15]=k,e[16]=S,e[17]=b,e[18]=m,e[19]=u,e[20]=w):w=e[20],w};function pl(s){return s!==""}function bl(s){return!s}const hl=Ee(xe.describeTable),xl=Ee(xe.readTablePage),vl=Ee(xe.importShard),wl=s=>{const e=s._id??s.id??s.__id__??"";return typeof e=="string"?e:typeof e=="number"?String(e):""},yl=s=>{const e=Object.values(s.inserted).reduce((a,i)=>a+i,0),[n]=s.errors;if(n===void 0)return{conflicts:s.conflicts,error:void 0,inserted:e};const o=s.errors.length-1,t=e+s.conflicts+s.errors.length,c=o===1?"error":"errors",l=o>0?` (+${o.toString()} more ${c})`:"",r=`Inserted ${e.toString()} of ${t.toString()} rows — row ${n.line.toString()} (${n.table}): ${n.message}${l}`;return{conflicts:s.conflicts,error:r,inserted:e}},Cl=s=>{const e=ct(),[n,o]=P(!1),[t,c]=P(void 0),[l,r]=P(void 0),[a,i]=P(void 0),[f,m]=P({}),[p,b]=P(!1),[u,g]=P(void 0),h=async(N,C)=>{o(!0),c(N),r(C),i(void 0),m({}),g(void 0),b(!0);try{const k=await e.query(hl,{table:N},Te(C)),{columns:S}=k;i(S);const w={},T=S.filter(F=>F.ref!==void 0&&F.type==="id"&&F.pk!==!0);for(const F of T){if(F.ref===void 0)continue;const{ref:R}=F;if(w[R]===void 0)try{const _=await e.query(xl,{filters:[],limit:Ls,offset:0,search:"",table:R},Te(C));w[R]=_.rows.flatMap($=>wl($)||[])}catch{w[R]=[]}}m(w)}catch(k){g(k.message)}b(!1)};return{closeDialog:()=>{o(!1),c(void 0),r(void 0),i(void 0),m({}),g(void 0)},columnMeta:a,error:u,fkPools:f,insertBatch:async(N,C)=>{if(t===void 0||l===void 0)return{conflicts:0,error:"No table selected.",inserted:0};try{const k=await e.query(vl,{rows:N.map(w=>({doc:w,table:t}))},Te(l)),S=yl(k);return S.error!==void 0||(C(),s()),S}catch(k){return{conflicts:0,error:k.message,inserted:0}}},loading:p,open:n,openDialog:(N,C)=>{Ce(h(N,C))},shardKey:l,table:t}},Nl=()=>{const s=B(6),[e,n]=P(null);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>{n(null)},s[0]=o):o=s[0];const t=o,[c,l]=P(null);let r;s[1]===Symbol.for("react.memo_cache_sentinel")?(r=(p,b)=>{l({column:p,value:b})},s[1]=r):r=s[1];const a=r;let i;s[2]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{l(null)},s[2]=i):i=s[2];const f=i;let m;return s[3]!==c||s[4]!==e?(m={closeExpandedCell:f,closeInspect:t,expandedCell:c,inspecting:e,onExpandCell:a,onInspect:n},s[3]=c,s[4]=e,s[5]=m):m=s[5],m},Sl=/(?:_creationtime|(?:^|[a-z])(?:time|at))$/iu,kl=(s,e)=>typeof e=="number"&&Sl.test(s),Tl=s=>{const e=B(36),{column:n,masked:o,onNavigate:t,target:c,value:l}=s;let r;e[0]!==t||e[1]!==c||e[2]!==l?(r=()=>{c!==void 0&&t(c,String(l))},e[0]=t,e[1]=c,e[2]=l,e[3]=r):r=e[3];const a=r;if(l==null){let m;return e[4]===Symbol.for("react.memo_cache_sentinel")?(m=d("span",{className:"italic text-muted-foreground",children:"null"}),e[4]=m):m=e[4],m}if(o){const m=`rd-masked-${n}`;let p;e[5]!==l?(p=Fe(l),e[5]=l,e[6]=p):p=e[6];let b;return e[7]!==m||e[8]!==p?(b=d("span",{className:"italic text-muted-foreground","data-testid":m,title:"Masked (preview)",children:p}),e[7]=m,e[8]=p,e[9]=b):b=e[9],b}if(c!==void 0&&(typeof l=="string"||typeof l=="number")&&String(l)!==""){const m=`rd-ref-${n}`,p=`Open ${c} ${String(l)}`,b=String(l);let u;return e[10]!==a||e[11]!==m||e[12]!==p||e[13]!==b?(u=E("button",{"data-testid":m,onClick:a,title:p,type:"button",children:[b," ↗"]}),e[10]=a,e[11]=m,e[12]=p,e[13]=b,e[14]=u):u=e[14],u}if(kl(n,l)){const m=`rd-ts-${n}`;let p;e[15]!==l?(p=l.toString(),e[15]=l,e[16]=p):p=e[16];let b;e[17]!==l?(b=zn(l),e[17]=l,e[18]=b):b=e[18];let u;return e[19]!==m||e[20]!==p||e[21]!==b?(u=d("span",{"data-testid":m,title:p,children:b}),e[19]=m,e[20]=p,e[21]=b,e[22]=u):u=e[22],u}if(l instanceof ArrayBuffer||ArrayBuffer.isView(l)){const m=`rd-bytes-${n}`;let p;e[23]!==l?(p=Fe(l),e[23]=l,e[24]=p):p=e[24];let b;return e[25]!==m||e[26]!==p?(b=d("span",{"data-testid":m,children:p}),e[25]=m,e[26]=p,e[27]=b):b=e[27],b}if(typeof l=="object"){let m;e[28]!==l?(m=JSON.stringify(l,en,2),e[28]=l,e[29]=m):m=e[29];let p;return e[30]!==m?(p=d("pre",{className:"m-0 overflow-auto rounded-md bg-muted/50 p-2 text-xs",children:m}),e[30]=m,e[31]=p):p=e[31],p}let i;e[32]!==l?(i=Fe(l),e[32]=l,e[33]=i):i=e[33];let f;return e[34]!==i?(f=d("span",{children:i}),e[34]=i,e[35]=f):f=e[35],f},El=s=>{const e=B(23),{columns:n,mask:o,onClose:t,onNavigate:c,refs:l,row:r}=s;let a;e[0]!==t||e[1]!==c?(a=(g,h)=>{c(g,h),t()},e[0]=t,e[1]=c,e[2]=a):a=e[2];const i=a;let f;e[3]===Symbol.for("react.memo_cache_sentinel")?(f=d("h3",{className:"m-0 text-base text-foreground",children:"Row detail"}),e[3]=f):f=e[3];let m;e[4]!==t?(m=E("div",{className:"mb-3 flex items-center justify-between",children:[f,d("button",{"data-testid":"rd-close",onClick:t,type:"button",children:"Close"})]}),e[4]=t,e[5]=m):m=e[5];let p;if(e[6]!==n||e[7]!==o||e[8]!==i||e[9]!==l||e[10]!==r){let g;e[12]!==o||e[13]!==i||e[14]!==l||e[15]!==r?(g=h=>E("div",{className:"border-t border-border py-2 first:border-t-0","data-testid":`rd-field-${h}`,children:[d("dt",{className:"mb-0.5 text-xs font-semibold text-muted-foreground",children:h}),d("dd",{className:"m-0",children:d(Tl,{column:h,masked:o.enabled&&o.columns.has(h),onNavigate:i,target:l?.[h],value:r[h]})})]},h),e[12]=o,e[13]=i,e[14]=l,e[15]=r,e[16]=g):g=e[16],p=n.map(g),e[6]=n,e[7]=o,e[8]=i,e[9]=l,e[10]=r,e[11]=p}else p=e[11];let b;e[17]!==p?(b=d("dl",{"data-testid":"rd-fields",children:p}),e[17]=p,e[18]=b):b=e[18];let u;return e[19]!==t||e[20]!==m||e[21]!==b?(u=E(dt,{label:"Row detail",onClose:t,panelTestId:"rd-panel",testId:"rd-overlay",variant:"drawer",children:[m,b]}),e[19]=t,e[20]=m,e[21]=b,e[22]=u):u=e[22],u},_l=50,Rl=s=>{const e=B(8),{active:n,onPick:o,shard:t}=s;let c;e[0]!==o||e[1]!==t?(c=()=>{o(t)},e[0]=o,e[1]=t,e[2]=c):c=e[2];const l=c,r=`w-full rounded px-2 py-0.5 text-left text-xs transition-colors hover:bg-accent ${n?"bg-accent font-medium":""}`,a=`shard-explorer-item-${t}`;let i;return e[3]!==l||e[4]!==t||e[5]!==r||e[6]!==a?(i=d("button",{className:r,"data-testid":a,onClick:l,type:"button",children:t}),e[3]=l,e[4]=t,e[5]=r,e[6]=a,e[7]=i):i=e[7],i},$l=({onFetchTables:s,onSelect:e})=>{const n=we(),[o]=P(()=>Co()),[t,c]=P(!1),[l,r]=P(void 0),[a,i]=P(void 0),[f,m]=P(!1),[p,b]=P(void 0),u=We(0),g=()=>{c(v=>!v)},h=async v=>{e(v),r(v),i(void 0),b(void 0),m(!0),u.current+=1;const y=u.current;try{const N=await s(v);u.current===y&&i(N?.slice(0,_l))}catch(N){u.current===y&&b(N.message)}u.current===y&&m(!1)},x=v=>{Ce(h(v))};return o.length===0?null:E("div",{"data-testid":"shard-explorer",children:[E("button",{"aria-controls":"shard-explorer-panel","aria-expanded":t,className:"inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"shard-explorer-toggle",onClick:g,type:"button",children:[n("Shards seen"),d("span",{"aria-hidden":"true",className:`ml-0.5 transition-transform ${t?"rotate-180":""}`,children:"▾"})]}),t&&E("div",{className:"mt-1 flex flex-col gap-1 rounded-md border border-border bg-popover p-2","data-testid":"shard-explorer-panel",id:"shard-explorer-panel",children:[d("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-hint",children:n("Recently visited shards — click to switch")}),d("ul",{className:"flex flex-col gap-0.5","data-testid":"shard-explorer-list",children:o.map(v=>d("li",{children:d(Rl,{active:l===v,onPick:x,shard:v})},v))}),l!==void 0&&E("div",{className:"mt-1 border-t border-border pt-1","data-testid":"shard-explorer-summary",children:[d("p",{className:"mb-1 text-xs font-medium text-foreground","data-testid":"shard-explorer-summary-title",children:n("{shard} tables",{shard:l})}),f&&d("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-loading",children:n("Loading…")}),p!==void 0&&d("p",{className:"text-xs text-destructive","data-testid":"shard-explorer-error",role:"alert",children:p}),!f&&p===void 0&&a?.length===0&&d("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-empty",children:n("No tables in this shard.")}),!f&&p===void 0&&a!==void 0&&a.length>0&&d("ul",{className:"flex flex-col gap-0.5","data-testid":"shard-explorer-tables",children:a.map(v=>E("li",{className:"flex items-center justify-between text-xs",children:[d("span",{"data-testid":`shard-explorer-table-${v.name}`,children:v.name}),d("span",{className:"text-muted-foreground","data-testid":`shard-explorer-rowcount-${v.name}`,children:v.rowCount})]},v.name))})]})]})]})},Dl="lunora-studio-back-relations",Pl=s=>new Set((s??[]).filter(e=>e.unique===!0&&e.fields.length===1).map(e=>e.fields[0]??"")),Al={},Il=50,Ol=[],Fl=Ee(xe.listTables),Ml=Ee(xe.readTablePage),Ll=s=>{const e=B(10),{onFetchShardTables:n,onShardChange:o,schemaSwitch:t,shardKey:c}=s;let l;e[0]!==o||e[1]!==c?(l=d(Bn,{onChange:o,testId:"db-shard-input",value:c}),e[0]=o,e[1]=c,e[2]=l):l=e[2];let r;e[3]!==n||e[4]!==o?(r=d($l,{onFetchTables:n,onSelect:o}),e[3]=n,e[4]=o,e[5]=r):r=e[5];let a;return e[6]!==t||e[7]!==l||e[8]!==r?(a=E("div",{className:"flex shrink-0 flex-col items-stretch gap-2 border-b border-border p-3",children:[t,l,r]}),e[6]=t,e[7]=l,e[8]=r,e[9]=a):a=e[9],a},br=({canGenerateRows:s=!1,editable:e=!1,globalTableNames:n,initialFilters:o,initialOrderBy:t,initialPins:c,initialSearch:l,initialShardKey:r,onNavigateToGlobal:a,onSelectTable:i,onViewChange:f,pageSize:m=Il,queryBar:p,schemaSwitch:b,tableParam:u})=>{const g=Ye(xe.describeTables,{},{shardKey:r??""}),h=Ye(xe.listTablesIndexes,{},{shardKey:r??""}),x=g.data?.columnsByTable??Al,[v,y]=Zt(Dl,{}),N=at(M=>{const se=new Set(v[M]);return qt(M,x).filter(_e=>se.has(Pt(_e)))},[v,x]),C=fl({initialFilters:o,initialOrderBy:t,initialSearch:l,initialShardKey:r,onSelectTable:i,onViewChange:f,pageSize:m,resolveBackRelations:N,tableParam:u}),{cancelCellEdit:k,columns:S,currentView:w,editableColumn:T,editingCell:F,facetFilter:R,facets:_,loadTables:$,navigateToRef:I,onFiltersChange:L,page:D,pageError:V,previewRef:G,queryShardKey:q,selectedTable:O,selectTable:J,setShardKey:K,shardKey:U,stage:X,stagedValue:Q,startCellEdit:ee,tables:ne,tablesError:le,toggleFacet:be}=C,ce=Hn(U),de=M=>{Ce((async()=>{const _e=await ce.suggestFilter(M,O??"");_e!==void 0&&L(_e.map(Ie=>{const Le=Ie.value,ot=typeof Le=="string"||typeof Le=="number"||typeof Le=="boolean"?String(Le):"";return{column:Ie.column,operator:Ie.operator,value:ot}}))})())},ue=O===null?[]:qt(O,x),re=new Set(v[O??""]),Y=[];for(const M of D?.rows??[]){const se=M._id??M.id;typeof se=="string"&&se!==""&&Y.push(se)}const ve=Js(re,ue,Y,q),ae=M=>{y(se=>{const _e=O??"",Ie=se[_e]??[];return{...se,[_e]:Ie.includes(M)?Ie.filter(Le=>Le!==M):[...Ie,M]}})},fe=gl({columns:S,initialPins:c,selectedTable:O}),me=Nl(),[oe,W]=P(null),{closeExpandedCell:z,closeInspect:ie,expandedCell:H,inspecting:he,onExpandCell:ge}=me,pe=ct(),Se=Object.fromEntries((x[O??""]??[]).map(M=>[M.name,M])),Z=new Map;for(const M of x[O??""]??[])M.isStorage===!0&&Z.set(M.name,M.bucket);const Me=at(async(M,se)=>pe.signedStorageUrl(M,se===void 0?{}:{bucket:se}),[pe]),ye=async M=>await pe.query(Fl,{},Te(M)),te=()=>{O!==null&&J(O)},{closeDialog:Ae,columnMeta:ze,fkPools:ke,insertBatch:qe,open:je,openDialog:Ue}=Cl(te),Ze=()=>{O!==null&&Ue(O,U)},ut=M=>qe(M,Ae),[ft,et]=P(!1),mt=()=>{et(!0)},tt=()=>{et(!1)},Ke=(M,se)=>{if(a!==void 0&&n?.has(M)===!0){a(M,se);return}I(M,se)},gt=p?.onSaveQuery,pt=M=>{gt?.(M,w)},bt={cancelEdit:k,editable:e,editableColumn:T,editingCell:F,onExpandCell:ge,stage:X,stagedValue:Q,startEdit:ee},ht=M=>{M!==null&&W(M)},xt=()=>{C.onRowDelete(oe)},vt=async(M,se,_e)=>await pe.query(Ml,{filters:[{column:se,operator:"eq",value:_e}],limit:lt,offset:0,orderBy:[],table:M},Te(q)),nt={columns:D?.refs,maskViewFor:fe.maskViewFor,onNavigate:Ke,onPreview:G};return E("div",{className:"flex h-full min-w-0","data-testid":"lunora-data-browser",children:[d(Jn,{header:d(Ll,{onFetchShardTables:ye,onShardChange:K,schemaSwitch:b,shardKey:U}),onReload:$,onSelect:J,prefix:"db",selected:O,tables:ne??Ol}),E("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[le!==null&&d("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"db-tables-error",role:"alert",children:le}),D===null&&V===null&&d("div",{className:"flex flex-1 items-center justify-center p-6",children:d("p",{className:"text-sm text-muted-foreground",children:"Select a table to browse its rows."})}),V!==null&&d("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"db-page-error",role:"alert",children:V}),D!==null&&d(Fs,{assistant:ce,backRelations:{available:ue,counts:ve,enabled:re,onToggle:ae},browser:C,columnMeta:Se,edit:bt,editable:e,onAskAiFilter:de,onInspect:me.onInspect,onOpenBulkPatch:mt,onOpenGenerateRows:s?Ze:void 0,onRowDelete:ht,onSaveQuery:pt,page:D,preferences:fe,queryBar:p,references:nt})]}),D!==null&&d(Wn,{columns:S,facets:_,mask:fe.maskView,onFacetFilter:R,onToggleFacet:be}),he!==null&&D!==null&&d(El,{columns:D.columns,mask:fe.maskView,onClose:ie,onNavigate:Ke,refs:D.refs,row:tn(he,fe.maskView)}),oe!==null&&O!==null&&d(Oo,{onClose:()=>{W(null)},onConfirm:xt,readPage:vt,rowId:oe,schema:No(x),table:O}),H!==null&&d(vo,{bucket:Z.get(H.column),column:H.column,onClose:z,resolveUrl:Z.has(H.column)?Me:void 0,value:H.value}),ft&&O!==null&&d(To,{columns:C.columns.filter(M=>C.editableColumn(M)),onApply:C.bulkPatch,onClose:tt,shardKey:C.queryShardKey,table:O,total:C.total,uniqueColumns:Pl(h.data?.indexesByTable[O])}),je&&O!==null&&ze!==void 0&&d(Ks,{columns:ze,fkPools:ke,onClose:Ae,onInsertRows:ut,table:O})]})};export{br as DataBrowser};
@@ -1 +0,0 @@
1
- import{c as q}from"react/compiler-runtime";import{useState as E}from"react";import{jsxs as A,Fragment as V,jsx as c}from"react/jsx-runtime";const K=[{label:"=",value:"eq"},{label:"≠",value:"ne"},{label:"<",value:"lt"},{label:"≤",value:"lte"},{label:">",value:"gt"},{label:"≥",value:"gte"},{label:"contains",value:"contains"}],$=a=>{const e=a.trim(),n=Number(e);return e!==""&&Number.isFinite(n)&&String(n)===e?n:a},J=a=>a.filter(e=>e.column!=="").map(e=>e.operator==="contains"?{column:e.column,operator:e.operator,value:e.value}:{column:e.column,operator:e.operator,value:e.literal===void 0?$(e.value):e.literal[0]}),R=(a,e)=>({column:a.column,operator:a.operator,value:a.value,...e}),L=a=>{const e=q(44),{columns:n,filters:l,onAskAi:h,onFiltersChange:r,onSearchChange:D,search:O}=a,[u,j]=E("");let N;e[0]!==n[0]||e[1]!==l||e[2]!==r?(N=()=>{r([...l,{column:n[0]??"",operator:"eq",value:""}])},e[0]=n[0],e[1]=l,e[2]=r,e[3]=N):N=e[3];const P=N;let T;e[4]!==l||e[5]!==r?(T=t=>{const i=Number(t.currentTarget.dataset.index);r(l.filter((o,s)=>s!==i))},e[4]=l,e[5]=r,e[6]=T):T=e[6];const f=T;let y;e[7]!==l||e[8]!==r?(y=t=>{const i=Number(t.currentTarget.dataset.index),o=t.currentTarget.value;r(l.map((s,F)=>F===i?R(s,{column:o}):s))},e[7]=l,e[8]=r,e[9]=y):y=e[9];const g=y;let S;e[10]!==l||e[11]!==r?(S=t=>{const i=Number(t.currentTarget.dataset.index),o=t.currentTarget.value;r(l.map((s,F)=>F===i?{...s,operator:o}:s))},e[10]=l,e[11]=r,e[12]=S):S=e[12];const x=S;let k;e[13]!==l||e[14]!==r?(k=t=>{const i=Number(t.currentTarget.dataset.index),o=t.currentTarget.value;r(l.map((s,F)=>F===i?R(s,{value:o}):s))},e[13]=l,e[14]=r,e[15]=k):k=e[15];const C=k;let d;e[16]!==D||e[17]!==O?(d=c("input",{"aria-label":"Search rows","data-testid":"db-filter",onChange:D,placeholder:"search table…",value:O}),e[16]=D,e[17]=O,e[18]=d):d=e[18];let m;e[19]!==P?(m=c("button",{"data-testid":"db-add-filter",onClick:P,type:"button",children:"Add filter"}),e[19]=P,e[20]=m):m=e[20];let p;e[21]!==u||e[22]!==h?(p=h!==void 0&&A(V,{children:[c("input",{"aria-label":"Describe a filter","data-testid":"db-ai-prompt",onChange:t=>{j(t.target.value)},onKeyDown:t=>{t.key==="Enter"&&u.trim()!==""&&(t.preventDefault(),h(u.trim()))},placeholder:"describe a filter…",value:u}),c("button",{"data-testid":"db-ai-filter",disabled:u.trim()==="",onClick:()=>{h(u.trim())},type:"button",children:"Suggest"})]}),e[21]=u,e[22]=h,e[23]=p):p=e[23];let b;e[24]!==d||e[25]!==m||e[26]!==p?(b=A("div",{className:"flex flex-wrap items-center gap-1.5",children:[d,m,p]}),e[24]=d,e[25]=m,e[26]=p,e[27]=b):b=e[27];let v;if(e[28]!==g||e[29]!==x||e[30]!==C||e[31]!==n||e[32]!==l||e[33]!==f){let t;e[35]!==g||e[36]!==x||e[37]!==C||e[38]!==n||e[39]!==f?(t=(i,o)=>A("div",{className:"flex flex-wrap items-center gap-1.5","data-testid":"db-filter-row",children:[c("select",{"aria-label":"Filter column","data-index":o,"data-testid":"db-filter-column",onChange:g,value:i.column,children:n.map(z)}),c("select",{"aria-label":"Filter operator","data-index":o,"data-testid":"db-filter-operator",onChange:x,value:i.operator,children:K.map(B)}),c("input",{"aria-label":"Filter value","data-index":o,"data-testid":"db-filter-value",onChange:C,placeholder:"value",value:i.value}),c("button",{"aria-label":"Remove filter","data-index":o,"data-testid":"db-filter-remove",onClick:f,type:"button",children:"✕"})]},o),e[35]=g,e[36]=x,e[37]=C,e[38]=n,e[39]=f,e[40]=t):t=e[40],v=l.map(t),e[28]=g,e[29]=x,e[30]=C,e[31]=n,e[32]=l,e[33]=f,e[34]=v}else v=e[34];let w;return e[41]!==v||e[42]!==b?(w=A("div",{className:"flex flex-col gap-1.5","data-testid":"db-filters",children:[b,v]}),e[41]=v,e[42]=b,e[43]=w):w=e[43],w};function z(a){return c("option",{value:a,children:a},a)}function B(a){return c("option",{value:a.value,children:a.label},a.value)}export{L as DataFilters,J as toFilterClauses};
@@ -1 +0,0 @@
1
- import{c as T}from"react/compiler-runtime";import{useT as E}from"./DEFAULT_LOCALE-A1Yg5ORA.mjs";import{k as H,f as I,b as Q}from"./internal-Df43vQI0.mjs";import{jsx as p,jsxs as S}from"react/jsx-runtime";import{useRef as O,useEffect as Y,useState as L,useMemo as G}from"react";import{u as J}from"./use-admin-query-tlBof8Yg.mjs";import{ADMIN_FUNCTIONS as K}from"./ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{useVirtualizer as Z}from"@tanstack/react-virtual";import{c as X}from"./utils-bhneXptQ.mjs";import{f as ee}from"./virtual-rect-D_j7aLxX.mjs";const te=2166136261,re=16777619,V=(s,e=te)=>{let t=e;for(let r=0;r<s.length;r+=1)t^=s.charCodeAt(r),t=Math.imul(t,re);return(t>>>0).toString(16).padStart(8,"0")},se=/([a-z\d])([A-Z])/gu,ne=/[\s_-]+/u,oe=new Set(["access_token","api_key","apikey","card_number","client_secret","credit_card","cvv","passwd","password","private_key","pwd","refresh_token","secret","ssn","token"]),le=s=>{const e=s.replaceAll(se,"$1 $2").split(ne).map(r=>r.toLowerCase()).filter(r=>r.length>0),t=new Set(e);for(let r=0;r<e.length-1;r+=1){const n=e[r],u=e[r+1];n===void 0||u===void 0||(t.add(`${n}${u}`),t.add(`${n}_${u}`))}return[...t]},j="•••",W=(s,e)=>{try{return e==="redact"?null:e==="hash"?s==null?s:V(typeof s=="bigint"?s.toString():typeof s=="string"?s:JSON.stringify(s)):j}catch{return j}},z=(s,e)=>{const t=new Map;for(const r of s)r.table===e&&t.set(r.column,r.strategy);return t},ae=s=>{for(const e of le(s))if(oe.has(e))return!0;return!1},B=(s,e)=>{const t=e.filter(n=>!s.has(n)&&ae(n));if(t.length===0)return s;const r=new Map(s);for(const n of t)r.set(n,"redact");return r},Ce=(s,e,t)=>{if(!t.enabled)return s;const r=t.columns.get(e);return r===void 0?s:W(s,r)},ce=(s,e)=>{if(!e.enabled||e.columns.size===0)return s;const t={...s};for(const[r,n]of e.columns)r in t&&(t[r]=W(t[r],n));return t},Fe=(s,e)=>!e.enabled||e.columns.size===0?s:s.map(t=>ce(t,e)),P=s=>s==null?"∅":s===""?"(empty)":H(s),ie=s=>{const e=T(32),{column:t,onFacetFilter:r,state:n}=s,u=E();let x;e[0]!==t||e[1]!==r||e[2]!==n.result?.values?(x=c=>{const m=Number(c.currentTarget.dataset.index),k=n.result?.values[m];k!==void 0&&r(t,k.value)},e[0]=t,e[1]=r,e[2]=n.result?.values,e[3]=x):x=e[3];const g=x,o=`db-facet-${t}`;let d;e[4]!==t?(d=p("span",{className:"font-medium text-foreground",children:t}),e[4]=t,e[5]=d):d=e[5];let a;e[6]!==n.loading||e[7]!==n.result||e[8]!==u?(a=n.loading&&n.result===null&&p("span",{className:"text-muted-foreground",children:u("Loading…")}),e[6]=n.loading,e[7]=n.result,e[8]=u,e[9]=a):a=e[9];let l;e[10]!==n.error?(l=n.error!==null&&p("span",{className:"text-destructive",role:"alert",children:n.error}),e[10]=n.error,e[11]=l):l=e[11];let i;e[12]!==n.result?.values?(i=n.result?.values??[],e[12]=n.result?.values,e[13]=i):i=e[13];let f;if(e[14]!==t||e[15]!==g||e[16]!==i){let c;e[18]!==t||e[19]!==g?(c=(m,k)=>S("button",{className:"flex items-center justify-between gap-2 rounded px-1 py-0.5 text-left text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground","data-index":k,"data-testid":`db-facet-value-${t}`,onClick:g,type:"button",children:[p("span",{className:"truncate",children:P(m.value)}),p("span",{className:"shrink-0 tabular-nums text-foreground/70",children:m.count})]},P(m.value)),e[18]=t,e[19]=g,e[20]=c):c=e[20],f=i.map(c),e[14]=t,e[15]=g,e[16]=i,e[17]=f}else f=e[17];let b;e[21]!==t||e[22]!==n.result||e[23]!==u?(b=n.result?.truncated===!0&&p("span",{className:"text-muted-foreground","data-testid":`db-facet-truncated-${t}`,children:u("Showing the {n} most common values.",{n:n.result.values.length})}),e[21]=t,e[22]=n.result,e[23]=u,e[24]=b):b=e[24];let h;return e[25]!==o||e[26]!==d||e[27]!==a||e[28]!==l||e[29]!==f||e[30]!==b?(h=S("section",{className:"flex flex-col gap-1","data-testid":o,children:[d,a,l,f,b]}),e[25]=o,e[26]=d,e[27]=a,e[28]=l,e[29]=f,e[30]=b,e[31]=h):h=e[31],h},_e=s=>{const e=T(44),{columns:t,facets:r,mask:n,onFacetFilter:u,onToggleFacet:x}=s,g=E();let o;e[0]!==x?(o=y=>{const{column:v}=y.currentTarget.dataset;v!==void 0&&x(v)},e[0]=x,e[1]=o):o=e[1];const d=o;let a;e[2]!==n?(a=y=>n.enabled&&n.columns.has(y),e[2]=n,e[3]=a):a=e[3];const l=a;let i,f,b,h,c,m,k,w;if(e[4]!==t||e[5]!==r||e[6]!==l||e[7]!==g||e[8]!==d){w=Symbol.for("react.early_return_sentinel");e:{let y;e[17]!==l?(y=N=>!l(N),e[17]=l,e[18]=y):y=e[18];const v=t.filter(y);let M;if(e[19]!==r||e[20]!==l?(M=Object.entries(r).filter(N=>{const[q]=N;return!l(q)}),e[19]=r,e[20]=l,e[21]=M):M=e[21],i=M,v.length===0){w=null;break e}m="flex w-56 shrink-0 flex-col gap-3 overflow-auto border-l border-border p-3 text-xs",k="db-facets",h="flex flex-col gap-1.5";let $;e[22]!==g?($=g("Facets"),e[22]=g,e[23]=$):$=e[23],e[24]!==$?(c=p("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:$}),e[24]=$,e[25]=c):c=e[25],f="flex flex-wrap gap-1";let A;e[26]!==r||e[27]!==d?(A=N=>p("button",{"aria-pressed":N in r,className:"rounded border border-border px-1.5 py-0.5 text-muted-foreground transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:text-accent-foreground","data-column":N,"data-testid":`db-facet-toggle-${N}`,onClick:d,type:"button",children:N},N),e[26]=r,e[27]=d,e[28]=A):A=e[28],b=v.map(A)}e[4]=t,e[5]=r,e[6]=l,e[7]=g,e[8]=d,e[9]=i,e[10]=f,e[11]=b,e[12]=h,e[13]=c,e[14]=m,e[15]=k,e[16]=w}else i=e[9],f=e[10],b=e[11],h=e[12],c=e[13],m=e[14],k=e[15],w=e[16];if(w!==Symbol.for("react.early_return_sentinel"))return w;let C;e[29]!==f||e[30]!==b?(C=p("div",{className:f,children:b}),e[29]=f,e[30]=b,e[31]=C):C=e[31];let F;e[32]!==C||e[33]!==h||e[34]!==c?(F=S("div",{className:h,children:[c,C]}),e[32]=C,e[33]=h,e[34]=c,e[35]=F):F=e[35];let _;e[36]!==u||e[37]!==i?(_=i.map(y=>{const[v,M]=y;return p(ie,{column:v,onFacetFilter:u,state:M},v)}),e[36]=u,e[37]=i,e[38]=_):_=e[38];let R;return e[39]!==F||e[40]!==_||e[41]!==m||e[42]!==k?(R=S("aside",{className:m,"data-testid":k,children:[F,_]}),e[39]=F,e[40]=_,e[41]=m,e[42]=k,e[43]=R):R=e[43],R};function ue(s){const e=T(2),t=O(s);let r;return e[0]!==s?(r=()=>{t.current=s},e[0]=s,e[1]=r):r=e[1],Y(r),t}const Me=()=>{const[s,e]=L({}),t=ue(s),r=O({}),n=async(o,d)=>{const a=(r.current[o]??0)+1;r.current[o]=a,e(l=>o in l?{...l,[o]:{error:null,loading:!0,result:l[o]?.result??null}}:l);try{const l=await d(o);if(r.current[o]!==a)return;e(i=>o in i?{...i,[o]:{error:null,loading:!1,result:l}}:i)}catch(l){if(r.current[o]!==a)return;e(i=>o in i?{...i,[o]:{error:Q(l),loading:!1,result:null}}:i)}};return{clearFacets:()=>{e({})},facets:s,facetsRef:t,refetchFacets:o=>{for(const d of Object.keys(t.current))I(n(d,o))},toggleFacet:(o,d)=>{if(o in t.current){e(a=>Object.fromEntries(Object.entries(a).filter(([l])=>l!==o)));return}e(a=>({...a,[o]:{error:null,loading:!0,result:null}})),d!==null&&I(n(o,d))}}},de=[],fe=()=>{const s=T(1);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e={},s[0]=e):e=s[0];const{data:t}=J(K.maskPolicies,e);return Array.isArray(t?.columns)?t.columns:de},$e=s=>{const e=T(16),{columns:t,selectedTable:r}=s,n=fe(),[u,x]=L(!0);let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{x(me)},e[0]=g):g=e[0];const o=g;let d;if(e[1]!==t||e[2]!==n||e[3]!==r){const h=z(n,r??"");d=B(h,t),e[1]=t,e[2]=n,e[3]=r,e[4]=d}else d=e[4];const a=d;let l;e[5]!==u||e[6]!==n?(l=(h,c)=>({columns:B(z(n,h),c),enabled:u}),e[5]=u,e[6]=n,e[7]=l):l=e[7];const i=l;let f;e[8]!==a||e[9]!==u?(f={columns:a,enabled:u},e[8]=a,e[9]=u,e[10]=f):f=e[10];let b;return e[11]!==a||e[12]!==u||e[13]!==i||e[14]!==f?(b={maskColumns:a,maskOn:u,maskView:f,maskViewFor:i,onToggleMask:o},e[11]=a,e[12]=u,e[13]=i,e[14]=f,e[15]=b):b=e[15],b};function me(s){return!s}const D=34,U=600,ge=s=>{const e=T(21),{item:t,onSelect:r,prefix:n,selected:u,start:x}=s;let g;e[0]!==t.name||e[1]!==r?(g=()=>{r(t.name)},e[0]=t.name,e[1]=r,e[2]=g):g=e[2];const o=g,d=`translateY(${String(x)}px)`;let a;e[3]!==d?(a={insetInline:0,position:"absolute",top:0,transform:d},e[3]=d,e[4]=a):a=e[4];const l=a,i=u?"bg-accent font-medium text-accent-foreground":"text-foreground";let f;e[5]!==i?(f=X("flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-start text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:bg-accent",i),e[5]=i,e[6]=f):f=e[6];const b=`${n}-table-${t.name}`;let h;e[7]!==t.name?(h=p("span",{className:"truncate",children:t.name}),e[7]=t.name,e[8]=h):h=e[8];let c;e[9]!==t.rowCount?(c=p("span",{className:"shrink-0 rounded bg-muted px-1.5 text-xs tabular-nums text-muted-foreground",children:t.rowCount}),e[9]=t.rowCount,e[10]=c):c=e[10];let m;e[11]!==o||e[12]!==u||e[13]!==f||e[14]!==b||e[15]!==h||e[16]!==c?(m=S("button",{"aria-pressed":u,className:f,"data-testid":b,onClick:o,type:"button",children:[h,c]}),e[11]=o,e[12]=u,e[13]=f,e[14]=b,e[15]=h,e[16]=c,e[17]=m):m=e[17];let k;return e[18]!==l||e[19]!==m?(k=p("li",{style:l,children:m}),e[18]=l,e[19]=m,e[20]=k):k=e[20],k},Te=({header:s,onReload:e,onSelect:t,prefix:r,reloadLabel:n,selected:u,tables:x})=>{const g=E(),[o,d]=L(""),a=O(null),l=c=>{d(c.target.value)},i=G(()=>{const c=o.trim().toLowerCase();return c===""?x:x.filter(m=>m.name.toLowerCase().includes(c))},[o,x]),b=Z({count:i.length,estimateSize:()=>D,getScrollElement:()=>a.current,initialRect:{height:U,width:240},observeElementRect:(c,m)=>ee(c,m,U),overscan:12}).getVirtualItems(),h={height:i.length*D};return S("aside",{className:"flex h-full w-60 shrink-0 flex-col border-e border-border bg-sidebar","data-testid":`${r}-table-list`,children:[s,S("div",{className:"flex h-9 shrink-0 items-center justify-between gap-2 border-b border-border px-3",children:[p("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:g("Tables")}),e!==void 0&&p("button",{"aria-label":n??g("Refresh"),className:"flex size-6 items-center justify-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent","data-testid":`${r}-load-tables`,onClick:e,title:n??g("Refresh"),type:"button",children:p("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:p("path",{d:"M4 12a8 8 0 0 1 13.7-5.6L20 8M20 4v4h-4M20 12a8 8 0 0 1-13.7 5.6L4 16m0 4v-4h4"})})})]}),p("div",{className:"shrink-0 border-b border-border p-2",children:p("input",{className:"h-7 w-full rounded-md border border-border bg-background px-2 text-xs outline-none placeholder:text-muted-foreground focus-visible:border-ring","data-testid":`${r}-table-search`,onChange:l,placeholder:g("search table…"),type:"search",value:o})}),S("ul",{className:"relative flex-1 overflow-y-auto p-1.5","data-testid":`${r}-table-list-rows`,ref:a,children:[p("li",{"aria-hidden":"true",style:h}),b.map(c=>{const m=i[c.index];return m===void 0?null:p(ge,{item:m,onSelect:t,prefix:r,selected:u===m.name,start:c.start},m.name)})]})]})};export{_e as D,Te as T,Me as a,$e as b,ce as c,Fe as d,Ce as m,ue as u};
@@ -1 +0,0 @@
1
- import{a as Qe}from"./chunk-IVHSLEDF.js";import{a as Me,b as Re}from"./chunk-CSUROWL2.js";import"./chunk-RFNGDE33.js";import"./chunk-V3CZW3JB.js";import"./chunk-MU3P2FI7.js";import{a as we}from"./chunk-IMOHEGMV.js";import"./chunk-YPRQLCKF.js";import"./chunk-GMS77BZD.js";import"./chunk-3Q2P62UR.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import"./chunk-5JDWLCSH.js";import{a as He}from"./chunk-S3CRZLGS.js";import{a as Xe}from"./chunk-EJSI4PMU.js";import{b as We}from"./chunk-OGUKYRFM.js";import{e as Ue}from"./chunk-6D6Z2KXU.js";import"./chunk-OKG3HWSJ.js";import{W as Ae}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as me}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as ze}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as je}from"./chunk-4ZEL6BYL.js";import{f as Ve}from"./chunk-NZKXQEZ5.js";import"./chunk-FSRSK4LY.js";import"./chunk-5ICUJ4IA.js";import{a as Je}from"./chunk-FKVZRPV5.js";import{a as qe,b as Pe,c as Ge,d as Ke,e as Le}from"./chunk-WUWBZPUK.js";import{d as Fe,f as Ee,g as $e,h as Oe,p as ue}from"./chunk-PTZD7RUZ.js";import{a as r,d as Be,e as at,f as nt,g as st,i as De}from"./chunk-YKXDMIHQ.js";var Ce=Be(nt(),1);var x=Be(at(),1);var t=Be(st(),1);var rt=Ee(je.listTables),ot=Ee(je.listTableIndexes),it=Ee(je.readTablePage),dt=Ee(je.describeTables),ct={},Ye=[],mt=r(s=>{let e=(0,Ce.c)(74),{initialShardKey:u,initialTable:n}=s,l=Ve(),[a,m]=(0,x.useState)("graph"),{queryShardKey:c,setShardKey:d,shardKey:g}=He(u),[o,b]=(0,x.useState)(""),[i,v]=(0,x.useState)(null),[p,P]=(0,x.useState)(null),_;e[0]===Symbol.for("react.memo_cache_sentinel")?(_={},e[0]=_):_=e[0];let[L,y]=(0,x.useState)(_),G;e[1]===Symbol.for("react.memo_cache_sentinel")?(G={},e[1]=G):G=e[1];let[E,M]=(0,x.useState)(G),[S,C]=(0,x.useState)(null),F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F={},e[2]=F):F=e[2];let[$,he]=(0,x.useState)(F),Q;e[3]===Symbol.for("react.memo_cache_sentinel")?(Q={},e[3]=Q):Q=e[3];let[I,K]=(0,x.useState)(Q),[k,be]=(0,x.useState)(null),[B,oe]=(0,x.useState)(null),Y;e[4]===Symbol.for("react.memo_cache_sentinel")?(Y={},e[4]=Y):Y=e[4];let[J,xe]=(0,x.useState)(Y),[W,ie]=(0,x.useState)(null),ve;e[5]!==l?(ve=r(async h=>{P(null);try{let w=await l.query(rt,{},$e(h));We(h),v(w),y({}),M({}),C(null),he(N=>Object.fromEntries(Object.entries(N).filter(q=>{let[A]=q;return A!==h}))),K(N=>Object.fromEntries(Object.entries(N).filter(q=>{let[A]=q;return A!==h})))}catch(w){let N=w;v(null),P(Oe(N))}},"ve"),e[5]=l,e[6]=ve):ve=e[6];let O=ve,Z;e[7]!==l?(Z=r(async()=>{oe(null);try{be(await l.listGlobalTables())}catch(h){let w=h;be(null),oe(Oe(w))}},"Z"),e[7]=l,e[8]=Z):Z=e[8];let ee=Z,de,D;e[9]!==c||e[10]!==O||e[11]!==ee?(de=r(()=>{ue(O(c)),ue(ee())},"de"),D=[O,ee,c],e[9]=c,e[10]=O,e[11]=ee,e[12]=de,e[13]=D):(de=e[12],D=e[13]),(0,x.useEffect)(de,D);let te;e[14]!==l||e[15]!==L||e[16]!==S||e[17]!==c?(te=r(async h=>{if(S===h){C(null);return}C(h);let w=`${c}:${h}`;if(L[w]!==void 0)return;let[N,q]=await Promise.allSettled([l.query(it,{limit:1,offset:0,table:h},$e(c)),l.query(ot,{table:h},$e(c))]);N.status==="fulfilled"?y(A=>({...A,[w]:N.value.columns})):P(Oe(N.reason)),q.status==="fulfilled"&&M(A=>({...A,[w]:q.value.indexes}))},"te"),e[14]=l,e[15]=L,e[16]=S,e[17]=c,e[18]=te):te=e[18];let j=te,ye;e[19]!==l||e[20]!==J||e[21]!==W?(ye=r(async h=>{if(W===h){ie(null);return}if(ie(h),J[h]===void 0)try{let w=await l.readGlobalTablePage({limit:1,offset:0,table:h});xe(N=>({...N,[h]:w.columns}))}catch(w){oe(Oe(w))}},"ye"),e[19]=l,e[20]=J,e[21]=W,e[22]=ye):ye=e[22];let ce=ye,pe=(0,x.useRef)(void 0),R,X;e[23]!==n||e[24]!==i||e[25]!==j?(R=r(()=>{n===void 0||i===null||pe.current===n||i.some(h=>h.name===n)&&(pe.current=n,ue(j(n)))},"K"),X=[n,i,j],e[23]=n,e[24]=i,e[25]=j,e[26]=R,e[27]=X):(R=e[26],X=e[27]),(0,x.useEffect)(R,X);let V;e[28]!==l?(V=r(async(h,w,N)=>{let[q,A]=await Promise.all([Promise.allSettled([l.query(dt,{tables:[...w,...N]},$e(h))]),Promise.all(N.map(async T=>{let ge=await Promise.allSettled([l.readGlobalTablePage({limit:1,offset:0,table:T})]),Ie=ge[0].status==="fulfilled"?ge[0].value:void 0;return{columns:Ie?.columns??[],refs:Ie?.refs??{},table:T}}))]),Te=q[0].status==="fulfilled"?q[0].value?.columnsByTable??{}:{},Se=q[0].status==="rejected",_e=new Map(A.map(ut)),ke=[...w,...N].map(T=>{let ge=Te[T]??[];return[T,ge.length>0?ge:_e.get(T)??[]]});he(T=>({...T,[h]:Object.fromEntries(ke)})),K(T=>({...T,[h]:Se}))},"U"),e[28]=l,e[29]=V):V=e[29];let le=V,U,ae;e[30]!==B||e[31]!==k||e[32]!==le||e[33]!==c||e[34]!==$||e[35]!==i||e[36]!==a?(U=r(()=>{a!=="graph"||i===null||k===null&&B===null||$[c]!==void 0||ue(le(c,i.map(ht),(k??[]).map(bt)))},"V"),ae=[a,i,k,B,c,$,le],e[30]=B,e[31]=k,e[32]=le,e[33]=c,e[34]=$,e[35]=i,e[36]=a,e[37]=U,e[38]=ae):(U=e[37],ae=e[38]),(0,x.useEffect)(U,ae);let z=$[c]??ct,ne;if(e[39]!==z||e[40]!==k||e[41]!==i){let h;e[43]!==z?(h=r(A=>({columns:z[A.name]??Ye,name:A.name,tier:"shard"}),"u"),e[43]=z,e[44]=h):h=e[44];let w=(i??[]).map(h),N;e[45]!==z?(N=r(A=>({columns:z[A.name]??Ye,name:A.name,tier:"global"}),"x"),e[45]=z,e[46]=N):N=e[46];let q=(k??[]).map(N);ne=[...w,...q],e[39]=z,e[40]=k,e[41]=i,e[42]=ne}else ne=e[42];let se=ne,f;if(e[47]!==o||e[48]!==i){let h=o.trim().toLowerCase();f=(i??[]).filter(w=>w.name.toLowerCase().includes(h)),e[47]=o,e[48]=i,e[49]=f}else f=e[49];let re=f,H;if(e[50]!==k||e[51]!==o){let h=o.trim().toLowerCase();H=(k??[]).filter(w=>w.name.toLowerCase().includes(h)),e[50]=k,e[51]=o,e[52]=H}else H=e[52];let Ne=H,fe;return e[53]!==L||e[54]!==se||e[55]!==p||e[56]!==S||e[57]!==Ne||e[58]!==re||e[59]!==J||e[60]!==B||e[61]!==W||e[62]!==k||e[63]!==E||e[64]!==O||e[65]!==d||e[66]!==I||e[67]!==g||e[68]!==o||e[69]!==i||e[70]!==j||e[71]!==ce||e[72]!==a?(fe={columns:L,diagramTables:se,error:p,expanded:S,filteredGlobalTables:Ne,filteredTables:re,globalColumns:J,globalError:B,globalExpanded:W,globalTables:k,indexes:E,refresh:O,setShardKey:d,setTableFilter:b,setView:m,shardColumnsError:I,shardKey:g,tableFilter:o,tables:i,toggle:j,toggleGlobal:ce,view:a},e[53]=L,e[54]=se,e[55]=p,e[56]=S,e[57]=Ne,e[58]=re,e[59]=J,e[60]=B,e[61]=W,e[62]=k,e[63]=E,e[64]=O,e[65]=d,e[66]=I,e[67]=g,e[68]=o,e[69]=i,e[70]=j,e[71]=ce,e[72]=a,e[73]=fe):fe=e[73],fe},"ct");function ut(s){let{columns:e,refs:u,table:n}=s;return[n,e.map(l=>{let a=u[l];return a===void 0?{name:l,optional:!1,type:""}:{name:l,optional:!1,ref:a,type:"id"}})]}r(ut,"mt");function ht(s){return s.name}r(ht,"ut");function bt(s){return s.name}r(bt,"ft");var pt="/__lunora/schema-edit",ft=r(async s=>{let e=await fetch(pt,{body:JSON.stringify(s),headers:{"Content-Type":"application/json"},method:"POST"}),u=await e.json();return u.needsMigration===!0?{kind:"needs-migration",message:u.message??"This edit needs a migration."}:e.ok&&u.tables!==void 0?{diagnostics:u.diagnostics??[],kind:"ok",tables:u.tables}:{kind:"error",message:u.error??`schema edit failed (${String(e.status)})`}},"pt"),gt=r(s=>{let e=(0,Ce.c)(32),{hasTables:u,mode:n,onAddColumn:l,onAddIndex:a,onAddTable:m,onDestructive:c}=s,d=Fe(),g=n==="addTable"?"default":"outline",o;e[0]!==d?(o=d("Add table"),e[0]=d,e[1]=o):o=e[1];let b;e[2]!==m||e[3]!==g||e[4]!==o?(b=(0,t.jsx)(me,{"data-testid":"sc-editor-add-table",onClick:m,size:"xs",type:"button",variant:g,children:o}),e[2]=m,e[3]=g,e[4]=o,e[5]=b):b=e[5];let i=!u,v=n==="addColumn"?"default":"outline",p;e[6]!==d?(p=d("Add column"),e[6]=d,e[7]=p):p=e[7];let P;e[8]!==l||e[9]!==i||e[10]!==v||e[11]!==p?(P=(0,t.jsx)(me,{"data-testid":"sc-editor-add-column",disabled:i,onClick:l,size:"xs",type:"button",variant:v,children:p}),e[8]=l,e[9]=i,e[10]=v,e[11]=p,e[12]=P):P=e[12];let _=!u,L=n==="addIndex"?"default":"outline",y;e[13]!==d?(y=d("Add index"),e[13]=d,e[14]=y):y=e[14];let G;e[15]!==a||e[16]!==y||e[17]!==_||e[18]!==L?(G=(0,t.jsx)(me,{"data-testid":"sc-editor-add-index",disabled:_,onClick:a,size:"xs",type:"button",variant:L,children:y}),e[15]=a,e[16]=y,e[17]=_,e[18]=L,e[19]=G):G=e[19];let E=!u,M=n==="destructive"?"default":"ghost",S;e[20]!==d?(S=d("Rename / drop / change type\u2026"),e[20]=d,e[21]=S):S=e[21];let C;e[22]!==c||e[23]!==E||e[24]!==M||e[25]!==S?(C=(0,t.jsx)(me,{"data-testid":"sc-editor-destructive",disabled:E,onClick:c,size:"xs",type:"button",variant:M,children:S}),e[22]=c,e[23]=E,e[24]=M,e[25]=S,e[26]=C):C=e[26];let F;return e[27]!==G||e[28]!==C||e[29]!==b||e[30]!==P?(F=(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[b,P,G,C]}),e[27]=G,e[28]=C,e[29]=b,e[30]=P,e[31]=F):F=e[31],F},"gt"),xt=r(s=>{let e=(0,Ce.c)(28),{onOpenMigrations:u,result:n}=s,l=Fe();if(n===null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[0]=o):o=e[0],o}if(n.kind==="error"){let o;return e[1]!==n.message?(o=(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:n.message}),e[1]=n.message,e[2]=o):o=e[2],o}if(n.kind==="needs-migration"){let o;e[3]!==n.message||e[4]!==l?(o=n.message===""?l("This edit changes stored data and must go through a migration. Review the migration before applying."):n.message,e[3]=n.message,e[4]=l,e[5]=o):o=e[5];let b;e[6]!==o?(b=(0,t.jsx)("p",{className:"text-sm text-warning",role:"alert",children:o}),e[6]=o,e[7]=b):b=e[7];let i;e[8]!==l?(i=l("Open Migrations"),e[8]=l,e[9]=i):i=e[9];let v;e[10]!==u||e[11]!==i?(v=(0,t.jsx)(me,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:u,size:"xs",type:"button",variant:"outline",children:i}),e[10]=u,e[11]=i,e[12]=v):v=e[12];let p;return e[13]!==b||e[14]!==v?(p=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[b,v]}),e[13]=b,e[14]=v,e[15]=p):p=e[15],p}if(n.diagnostics.length===0){let o;return e[16]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[16]=o):o=e[16],o}let a;e[17]!==l?(a=l("Codegen reported diagnostics:"),e[17]=l,e[18]=a):a=e[18];let m;e[19]!==a?(m=(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:a}),e[19]=a,e[20]=m):m=e[20];let c;e[21]!==n.diagnostics?(c=n.diagnostics.map(vt),e[21]=n.diagnostics,e[22]=c):c=e[22];let d;e[23]!==c?(d=(0,t.jsx)("ul",{className:"flex flex-col gap-0.5",children:c}),e[23]=c,e[24]=d):d=e[24];let g;return e[25]!==m||e[26]!==d?(g=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[m,d]}),e[25]=m,e[26]=d,e[27]=g):g=e[27],g},"bt");function vt(s){return(0,t.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:s},s)}r(vt,"xt");var yt=[{label:"string",validator:"v.string()"},{label:"number",validator:"v.number()"},{label:"boolean",validator:"v.boolean()"},{label:"bigint",validator:"v.bigint()"},{label:"bytes",validator:"v.bytes()"},{label:"any",validator:"v.any()"}],Nt="v.string()",Ct=r(s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),"Ct"),wt=r(s=>{let e=(0,Ce.c)(83),{onApplied:u,tableNames:n}=s,l=Fe(),a=Ue(),[m,c]=(0,x.useState)(null),[d,g]=(0,x.useState)(!1),[o,b]=(0,x.useState)(null),[i,v]=(0,x.useState)(""),[p,P]=(0,x.useState)(""),[_,L]=(0,x.useState)(Nt),[y,G]=(0,x.useState)(n[0]??""),[E,M]=(0,x.useState)(""),[S,C]=(0,x.useState)(""),[F,$]=(0,x.useState)(!1),he;e[0]===Symbol.for("react.memo_cache_sentinel")?(he=r(()=>{c(null),v(""),P(""),M(""),C(""),$(!1)},"me"),e[0]=he):he=e[0];let Q=he,I;e[1]!==u?(I=r(async T=>{g(!0),b(null);try{let ge=await ft(T);b(ge),ge.kind==="ok"&&(u(ge.tables),Q())}catch(ge){let Ie=ge;b({kind:"error",message:Ie instanceof Error?Ie.message:String(Ie)})}g(!1)},"I"),e[1]=u,e[2]=I):I=e[2];let K=I,k;e[3]!==K||e[4]!==i?(k=r(()=>{ue(K({kind:"addTable",table:i.trim()}))},"_"),e[3]=K,e[4]=i,e[5]=k):k=e[5];let be=k,B;e[6]!==p||e[7]!==K||e[8]!==y||e[9]!==_?(B=r(()=>{ue(K({column:p.trim(),kind:"addOptionalColumn",table:y,validator:_}))},"j"),e[6]=p,e[7]=K,e[8]=y,e[9]=_,e[10]=B):B=e[10];let oe=B,Y;e[11]!==S||e[12]!==E||e[13]!==K||e[14]!==y||e[15]!==F?(Y=r(()=>{ue(K({fields:Ct(S),kind:"addIndex",name:E.trim(),table:y,unique:F}))},"Q"),e[11]=S,e[12]=E,e[13]=K,e[14]=y,e[15]=F,e[16]=Y):Y=e[16];let J=Y,xe;e[17]===Symbol.for("react.memo_cache_sentinel")?(xe=r(()=>{b(null),c("addTable")},"xe"),e[17]=xe):xe=e[17];let W=xe,ie;e[18]===Symbol.for("react.memo_cache_sentinel")?(ie=r(()=>{b(null),c("addColumn")},"re"),e[18]=ie):ie=e[18];let ve=ie,O;e[19]===Symbol.for("react.memo_cache_sentinel")?(O=r(()=>{b(null),c("addIndex")},"O"),e[19]=O):O=e[19];let Z=O,ee;e[20]!==l?(ee=r(()=>{c("destructive"),b({kind:"needs-migration",message:l("This edit changes stored data and must go through a migration. Review the migration before applying.")})},"ee"),e[20]=l,e[21]=ee):ee=e[21];let de=ee,D;e[22]===Symbol.for("react.memo_cache_sentinel")?(D=r(T=>{v(T.target.value)},"R"),e[22]=D):D=e[22];let te=D,j;e[23]===Symbol.for("react.memo_cache_sentinel")?(j=r(T=>{P(T.target.value)},"M"),e[23]=j):j=e[23];let ye=j,ce;e[24]===Symbol.for("react.memo_cache_sentinel")?(ce=r(T=>{L(T.target.value)},"ce"),e[24]=ce):ce=e[24];let pe=ce,R;e[25]===Symbol.for("react.memo_cache_sentinel")?(R=r(T=>{G(T.target.value)},"K"),e[25]=R):R=e[25];let X=R,V;e[26]===Symbol.for("react.memo_cache_sentinel")?(V=r(T=>{M(T.target.value)},"U"),e[26]=V):V=e[26];let le=V,U;e[27]===Symbol.for("react.memo_cache_sentinel")?(U=r(T=>{C(T.target.value)},"V"),e[27]=U):U=e[27];let ae=U,z;e[28]===Symbol.for("react.memo_cache_sentinel")?(z=r(T=>{$(T.target.checked)},"$"),e[28]=z):z=e[28];let ne=z,se;e[29]!==a?(se=r(()=>{ue(a({to:"/migrations"}))},"ne"),e[29]=a,e[30]=se):se=e[30];let f=se,re;e[31]!==l?(re=l("Edit schema"),e[31]=l,e[32]=re):re=e[32];let H;e[33]!==re?(H=(0,t.jsx)(Ge,{children:re}),e[33]=re,e[34]=H):H=e[34];let Ne;e[35]!==l?(Ne=l("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=l,e[36]=Ne):Ne=e[36];let fe;e[37]!==Ne?(fe=(0,t.jsx)(Ke,{children:Ne}),e[37]=Ne,e[38]=fe):fe=e[38];let h;e[39]!==H||e[40]!==fe?(h=(0,t.jsxs)(Pe,{children:[H,fe]}),e[39]=H,e[40]=fe,e[41]=h):h=e[41];let w=n.length>0,N;e[42]!==m||e[43]!==de||e[44]!==w?(N=(0,t.jsx)(gt,{hasTables:w,mode:m,onAddColumn:ve,onAddIndex:Z,onAddTable:W,onDestructive:de}),e[42]=m,e[43]=de,e[44]=w,e[45]=N):N=e[45];let q;e[46]!==d||e[47]!==m||e[48]!==be||e[49]!==l||e[50]!==i?(q=m==="addTable"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-table-name",children:l("Table name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:te,value:i})]}),(0,t.jsx)(me,{"data-testid":"sc-editor-table-apply",disabled:d||i.trim()==="",onClick:be,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[46]=d,e[47]=m,e[48]=be,e[49]=l,e[50]=i,e[51]=q):q=e[51];let A;e[52]!==d||e[53]!==p||e[54]!==m||e[55]!==oe||e[56]!==l||e[57]!==n||e[58]!==y||e[59]!==_?(A=m==="addColumn"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-table",id:"sc-editor-column-table",onChange:X,value:y,children:n.map(Tt)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-name",children:l("Column name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:ye,value:p})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-type",children:l("Column type")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-type",id:"sc-editor-column-type",onChange:pe,value:_,children:yt.map(St)})]}),(0,t.jsx)("span",{className:"text-[11px] text-muted-foreground",children:l("Optional")}),(0,t.jsx)(me,{"data-testid":"sc-editor-column-apply",disabled:d||p.trim()===""||y==="",onClick:oe,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[52]=d,e[53]=p,e[54]=m,e[55]=oe,e[56]=l,e[57]=n,e[58]=y,e[59]=_,e[60]=A):A=e[60];let Te;e[61]!==d||e[62]!==S||e[63]!==E||e[64]!==m||e[65]!==J||e[66]!==l||e[67]!==n||e[68]!==y||e[69]!==F?(Te=m==="addIndex"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-index-table",id:"sc-editor-index-table",onChange:X,value:y,children:n.map(_t)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-name",children:l("Index name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:le,value:E})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-fields",children:l("Index fields (comma-separated)")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:ae,value:S})]}),(0,t.jsxs)(we,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[(0,t.jsx)("input",{checked:F,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:ne,type:"checkbox"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:l("Unique")})]}),(0,t.jsx)(me,{"data-testid":"sc-editor-index-apply",disabled:d||E.trim()===""||S.trim()==="",onClick:J,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[61]=d,e[62]=S,e[63]=E,e[64]=m,e[65]=J,e[66]=l,e[67]=n,e[68]=y,e[69]=F,e[70]=Te):Te=e[70];let Se;e[71]!==f||e[72]!==o?(Se=(0,t.jsx)(xt,{onOpenMigrations:f,result:o}),e[71]=f,e[72]=o,e[73]=Se):Se=e[73];let _e;e[74]!==N||e[75]!==q||e[76]!==A||e[77]!==Te||e[78]!==Se?(_e=(0,t.jsxs)(Le,{children:[N,q,A,Te,Se]}),e[74]=N,e[75]=q,e[76]=A,e[77]=Te,e[78]=Se,e[79]=_e):_e=e[79];let ke;return e[80]!==h||e[81]!==_e?(ke=(0,t.jsxs)(qe,{"data-testid":"sc-editor",size:"sm",children:[h,_e]}),e[80]=h,e[81]=_e,e[82]=ke):ke=e[82],ke},"Nt");function Tt(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(Tt,"Tt");function St(s){return(0,t.jsx)("option",{value:s.validator,children:s.label},s.validator)}r(St,"St");function _t(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(_t,"wt");var Ze=[],kt=r(s=>{let e=(0,Ce.c)(5),{open:u}=s,n=u&&"rotate-90",l;e[0]!==n?(l=De("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",n),e[0]=n,e[1]=l):l=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[2]=a):a=e[2];let m;return e[3]!==l?(m=(0,t.jsx)("svg",{"aria-hidden":"true",className:l,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:a}),e[3]=l,e[4]=m):m=e[4],m},"_t"),et=r(s=>{let e=(0,Ce.c)(20),{children:u,expanded:n,name:l,onToggle:a,rowCount:m,rowTestId:c,toggleTestId:d}=s,g;e[0]!==n?(g=(0,t.jsx)(kt,{open:n}),e[0]=n,e[1]=g):g=e[1];let o;e[2]!==l?(o=(0,t.jsx)("span",{className:"truncate font-mono text-xs text-foreground",title:l,children:l}),e[2]=l,e[3]=o):o=e[3];let b;e[4]!==m?(b=(0,t.jsxs)("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",m,")"]}),e[4]=m,e[5]=b):b=e[5];let i;e[6]!==n||e[7]!==a||e[8]!==g||e[9]!==o||e[10]!==b||e[11]!==d?(i=(0,t.jsxs)("button",{"aria-expanded":n,className:"flex w-full items-center gap-2 px-3 py-2 text-start transition-colors hover:bg-muted/50 aria-expanded:bg-muted/40","data-testid":d,onClick:a,type:"button",children:[g,o," ",b]}),e[6]=n,e[7]=a,e[8]=g,e[9]=o,e[10]=b,e[11]=d,e[12]=i):i=e[12];let v;e[13]!==u||e[14]!==n?(v=n&&(0,t.jsx)("div",{className:"px-3 pb-3 ps-8",children:u}),e[13]=u,e[14]=n,e[15]=v):v=e[15];let p;return e[16]!==c||e[17]!==i||e[18]!==v?(p=(0,t.jsxs)("li",{className:"border-t border-border/60 first:border-t-0","data-testid":c,children:[i,v]}),e[16]=c,e[17]=i,e[18]=v,e[19]=p):p=e[19],p},"Ye"),tt=r(s=>{let e=(0,Ce.c)(5),{columns:u,testId:n}=s,l;e[0]!==u?(l=u.map(At),e[0]=u,e[1]=l):l=e[1];let a;return e[2]!==l||e[3]!==n?(a=(0,t.jsx)("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":n,children:l}),e[2]=l,e[3]=n,e[4]=a):a=e[4],a},"He"),It=r(s=>{let e=(0,Ce.c)(10),{heading:u,indexes:n,testId:l}=s,a;e[0]!==u?(a=(0,t.jsx)("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:u}),e[0]=u,e[1]=a):a=e[1];let m;e[2]!==n?(m=n.map(Ft),e[2]=n,e[3]=m):m=e[3];let c;e[4]!==m||e[5]!==l?(c=(0,t.jsx)("ul",{className:"flex flex-col gap-1","data-testid":l,children:m}),e[4]=m,e[5]=l,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=(0,t.jsxs)("div",{className:"pt-3",children:[a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d},"Et"),lt=r(s=>De("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",s?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"Je"),Xt=r(s=>{let e=(0,Ce.c)(85),{initialShardKey:u,initialTable:n,schemaEditable:l}=s,a=Fe(),m;e[0]!==u||e[1]!==n?(m={initialShardKey:u,initialTable:n},e[0]=u,e[1]=n,e[2]=m):m=e[2];let{columns:c,diagramTables:d,error:g,expanded:o,filteredGlobalTables:b,filteredTables:i,globalColumns:v,globalError:p,globalExpanded:P,globalTables:_,indexes:L,refresh:y,setShardKey:G,setTableFilter:E,setView:M,shardColumnsError:S,shardKey:C,tableFilter:F,tables:$,toggle:he,toggleGlobal:Q,view:I}=mt(m),K;e[3]!==M?(K=r(()=>{M("list")},"q"),e[3]=M,e[4]=K):K=e[4];let k=K,be;e[5]!==M?(be=r(()=>{M("graph")},"ue"),e[5]=M,e[6]=be):be=e[6];let B=be,oe;e[7]!==E?(oe=r(f=>{E(f.target.value)},"ie"),e[7]=E,e[8]=oe):oe=e[8];let Y=oe,J;e[9]!==y||e[10]!==C?(J=r(f=>{ue(y(C))},"Y"),e[9]=y,e[10]=C,e[11]=J):J=e[11];let xe=J,W;e[12]!==$?(W=$??[],e[12]=$,e[13]=W):W=e[13];let ie;e[14]!==W?(ie=W.map(zt),e[14]=W,e[15]=ie):ie=e[15];let ve=ie,O;e[16]!==G||e[17]!==C?(O=(0,t.jsx)(Xe,{onChange:G,testId:"sc-shard-input",value:C}),e[16]=G,e[17]=C,e[18]=O):O=e[18];let Z;e[19]!==a?(Z=a("Schema view"),e[19]=a,e[20]=Z):Z=e[20];let ee=I==="graph",de=I==="graph",D;e[21]!==de?(D=lt(de),e[21]=de,e[22]=D):D=e[22];let te;e[23]!==a?(te=a("Graph"),e[23]=a,e[24]=te):te=e[24];let j;e[25]!==B||e[26]!==ee||e[27]!==D||e[28]!==te?(j=(0,t.jsx)("button",{"aria-selected":ee,className:D,"data-testid":"sc-view-graph",onClick:B,role:"tab",type:"button",children:te}),e[25]=B,e[26]=ee,e[27]=D,e[28]=te,e[29]=j):j=e[29];let ye=I==="list",ce=I==="list",pe;e[30]!==ce?(pe=lt(ce),e[30]=ce,e[31]=pe):pe=e[31];let R;e[32]!==a?(R=a("Table list"),e[32]=a,e[33]=R):R=e[33];let X;e[34]!==k||e[35]!==ye||e[36]!==pe||e[37]!==R?(X=(0,t.jsx)("button",{"aria-selected":ye,className:pe,"data-testid":"sc-view-list",onClick:k,role:"tab",type:"button",children:R}),e[34]=k,e[35]=ye,e[36]=pe,e[37]=R,e[38]=X):X=e[38];let V;e[39]!==j||e[40]!==X||e[41]!==Z?(V=(0,t.jsxs)("div",{"aria-label":Z,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[j,X]}),e[39]=j,e[40]=X,e[41]=Z,e[42]=V):V=e[42];let le;e[43]!==V||e[44]!==O?(le=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[O,V]}),e[43]=V,e[44]=O,e[45]=le):le=e[45];let U;e[46]!==xe||e[47]!==l||e[48]!==ve?(U=l===!0&&(0,t.jsx)(wt,{onApplied:xe,tableNames:ve}),e[46]=xe,e[47]=l,e[48]=ve,e[49]=U):U=e[49];let ae;e[50]!==Y||e[51]!==a||e[52]!==F||e[53]!==I?(ae=I==="list"&&(0,t.jsx)(Ae,{"aria-label":a("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:Y,placeholder:a("Filter tables"),value:F}),e[50]=Y,e[51]=a,e[52]=F,e[53]=I,e[54]=ae):ae=e[54];let z;e[55]!==d||e[56]!==g||e[57]!==p||e[58]!==S||e[59]!==C||e[60]!==I?(z=I==="graph"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),p!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:p}),(0,t.jsx)(Qe,{columnsError:S[C]===!0,tables:d,testIdPrefix:"sc-graph"})]}),e[55]=d,e[56]=g,e[57]=p,e[58]=S,e[59]=C,e[60]=I,e[61]=z):z=e[61];let ne;e[62]!==c||e[63]!==g||e[64]!==o||e[65]!==b||e[66]!==i||e[67]!==v||e[68]!==p||e[69]!==P||e[70]!==_||e[71]!==L||e[72]!==C||e[73]!==a||e[74]!==$||e[75]!==he||e[76]!==Q||e[77]!==I?(ne=I==="list"&&(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)(qe,{"data-testid":"sc-shard-section",size:"sm",children:[(0,t.jsxs)(Pe,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Re,{tier:"shard"}),(0,t.jsx)(Ge,{children:a("Shard tables")}),$!==null&&(0,t.jsx)(ze,{className:"ms-auto tabular-nums",variant:"outline",children:i.length})]}),(0,t.jsx)(Ke,{children:Me.shard.hint})]}),(0,t.jsxs)(Le,{children:[g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),$!==null&&$.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:a("No tables in this shard.")}),$!==null&&$.length>0&&i.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:a("No tables match your filter.")}),i.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:i.map(f=>{let re=`${C}:${f.name}`,H=L[re]??[];return(0,t.jsxs)(et,{expanded:o===f.name,name:f.name,onToggle:r(()=>{ue(he(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-table-${f.name}`,toggleTestId:`sc-toggle-${f.name}`,children:[(0,t.jsx)(tt,{columns:c[re]??Ze,testId:`sc-columns-${f.name}`}),H.length>0&&(0,t.jsx)(It,{heading:a("Indexes"),indexes:H,testId:`sc-indexes-${f.name}`})]},f.name)})})]})]}),(0,t.jsxs)(qe,{"data-testid":"sc-global-section",size:"sm",children:[(0,t.jsxs)(Pe,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Re,{tier:"global"}),(0,t.jsx)(Ge,{children:a("Global tables (D1)")}),_!==null&&(0,t.jsx)(ze,{className:"ms-auto tabular-nums",variant:"outline",children:b.length})]}),(0,t.jsx)(Ke,{children:Me.global.hint})]}),(0,t.jsxs)(Le,{children:[p!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:p}),_!==null&&_.length===0&&(0,t.jsx)(Je,{description:Me.global.hint,testId:"sc-global-empty",title:a("No global tables.")}),_!==null&&_.length>0&&b.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:a("No tables match your filter.")}),b.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:b.map(f=>(0,t.jsx)(et,{expanded:P===f.name,name:f.name,onToggle:r(()=>{ue(Q(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-global-table-${f.name}`,toggleTestId:`sc-global-toggle-${f.name}`,children:(0,t.jsx)(tt,{columns:v[f.name]??Ze,testId:`sc-global-columns-${f.name}`})},f.name))})]})]})]}),e[62]=c,e[63]=g,e[64]=o,e[65]=b,e[66]=i,e[67]=v,e[68]=p,e[69]=P,e[70]=_,e[71]=L,e[72]=C,e[73]=a,e[74]=$,e[75]=he,e[76]=Q,e[77]=I,e[78]=ne):ne=e[78];let se;return e[79]!==le||e[80]!==U||e[81]!==ae||e[82]!==z||e[83]!==ne?(se=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[le,U,ae,z,ne]}),e[79]=le,e[80]=U,e[81]=ae,e[82]=z,e[83]=ne,e[84]=se):se=e[84],se},"Xt");function At(s){return(0,t.jsx)("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:s},s)}r(At,"It");function Ft(s){return(0,t.jsxs)("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[(0,t.jsx)("span",{className:"font-mono",children:s.name}),(0,t.jsx)(ze,{variant:"outline",children:s.type}),s.unique===!0&&(0,t.jsx)(ze,{variant:"secondary",children:"unique"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:s.fields.join(", ")})]},`${s.type}:${s.name}`)}r(Ft,"kt");function zt(s){return s.name}r(zt,"At");export{Xt as SchemaViewer};