@lunora/studio 1.0.0-alpha.178 → 1.0.0-alpha.180

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 (78) hide show
  1. package/dist/index.d.mts +40 -1
  2. package/dist/index.d.ts +40 -1
  3. package/dist/index.mjs +1 -1
  4. package/dist/packem_chunks/FileBrowser.mjs +1 -1
  5. package/dist/packem_chunks/SqlEditorPanel.mjs +6 -6
  6. package/dist/packem_chunks/TableEditor.mjs +1 -1
  7. package/dist/packem_chunks/permissions-panel.mjs +1 -1
  8. package/dist/packem_chunks/queues-panel.mjs +1 -1
  9. package/dist/packem_shared/DataBrowser-BUFMFvNX.mjs +4 -0
  10. package/dist/packem_shared/DataFilters-Cocu-WWE.mjs +1 -0
  11. package/dist/packem_shared/grid-features-CE8kcqsK.mjs +6 -0
  12. package/dist/standalone/{chunk-2W365SXI.js → chunk-3PZNTIBM.js} +1 -1
  13. package/dist/standalone/{chunk-TXLWUHAU.js → chunk-3TXB4AKZ.js} +1 -1
  14. package/dist/standalone/{chunk-U7A2W7UG.js → chunk-4PRXEO3C.js} +1 -1
  15. package/dist/standalone/{chunk-P4V5VRUR.js → chunk-5B6TTEP6.js} +1 -1
  16. package/dist/standalone/{chunk-QCFJKKLX.js → chunk-5LZJ5JBB.js} +1 -1
  17. package/dist/standalone/{chunk-E366YQXO.js → chunk-5MKG6RW3.js} +1 -1
  18. package/dist/standalone/{chunk-PHYKYBCE.js → chunk-66Z7ZIZZ.js} +1 -1
  19. package/dist/standalone/{chunk-MOYNBJNW.js → chunk-A6S4TULR.js} +1 -1
  20. package/dist/standalone/{chunk-KIEUFC6E.js → chunk-A7EWHGFT.js} +1 -1
  21. package/dist/standalone/{chunk-ANXXWNJG.js → chunk-AFSPF2R4.js} +1 -1
  22. package/dist/standalone/{chunk-AKG3SL2Z.js → chunk-AODYDAXY.js} +1 -1
  23. package/dist/standalone/{chunk-NLHKRU3D.js → chunk-AULH6SZB.js} +1 -1
  24. package/dist/standalone/{chunk-YRZFU7OM.js → chunk-AX24JD2G.js} +1 -1
  25. package/dist/standalone/chunk-B3JY36UV.js +5 -0
  26. package/dist/standalone/chunk-B6RRRJP5.js +11 -0
  27. package/dist/standalone/{chunk-VR3OL4A6.js → chunk-BAAPQWFF.js} +1 -1
  28. package/dist/standalone/{chunk-I3OOVU3O.js → chunk-D4ZGY3II.js} +1 -1
  29. package/dist/standalone/{chunk-D7PVLNBP.js → chunk-DAD33Q2T.js} +1 -1
  30. package/dist/standalone/{chunk-ZTA7WN4R.js → chunk-DI34YDBW.js} +1 -1
  31. package/dist/standalone/{chunk-BR64TOG4.js → chunk-E2X625P3.js} +1 -1
  32. package/dist/standalone/{chunk-5PBVNSPQ.js → chunk-EBU3TTYR.js} +1 -1
  33. package/dist/standalone/{chunk-MWUR2KP6.js → chunk-FI6N7XWP.js} +1 -1
  34. package/dist/standalone/{chunk-IUKHT5XV.js → chunk-GAPFZFIL.js} +1 -1
  35. package/dist/standalone/{chunk-D2SSRZG5.js → chunk-GP2GJRJ3.js} +1 -1
  36. package/dist/standalone/{chunk-MNQSYFV6.js → chunk-GZ6GAFM2.js} +1 -1
  37. package/dist/standalone/chunk-GZAXFXZE.js +1 -0
  38. package/dist/standalone/{chunk-WV2AW6IT.js → chunk-H43JNQM6.js} +1 -1
  39. package/dist/standalone/{chunk-V5FOHTRB.js → chunk-HGT5U6GD.js} +1 -1
  40. package/dist/standalone/{chunk-P6F4CNT5.js → chunk-I6FR5UAK.js} +1 -1
  41. package/dist/standalone/{chunk-7HFDITXH.js → chunk-INXSZE5I.js} +1 -1
  42. package/dist/standalone/{chunk-FTR6JAWG.js → chunk-IP7YCJUN.js} +1 -1
  43. package/dist/standalone/{chunk-KZDIKRZ3.js → chunk-ITMXIPQ7.js} +1 -1
  44. package/dist/standalone/{chunk-M7QQYXU4.js → chunk-IXNOQYEE.js} +1 -1
  45. package/dist/standalone/{chunk-LKKZMIZK.js → chunk-JYT34NQM.js} +1 -1
  46. package/dist/standalone/{chunk-2NYASBOP.js → chunk-L2CWAQUO.js} +1 -1
  47. package/dist/standalone/{chunk-QY4V5UOY.js → chunk-M4POCI2J.js} +1 -1
  48. package/dist/standalone/{chunk-RSULZ5QU.js → chunk-MH2NGGUC.js} +1 -1
  49. package/dist/standalone/{chunk-WHPKXZN2.js → chunk-PGMASM2T.js} +1 -1
  50. package/dist/standalone/{chunk-2ADU5FA5.js → chunk-PZVVEPIN.js} +1 -1
  51. package/dist/standalone/{chunk-GDYRC6T6.js → chunk-QDHXQ56K.js} +1 -1
  52. package/dist/standalone/{chunk-KQMWK6QZ.js → chunk-QQ3CS3FX.js} +1 -1
  53. package/dist/standalone/chunk-QWJQUQY3.js +8 -0
  54. package/dist/standalone/{chunk-YK7JO7NP.js → chunk-RM4TNBYG.js} +1 -1
  55. package/dist/standalone/{chunk-MBP4SZYB.js → chunk-SDHFSBNM.js} +1 -1
  56. package/dist/standalone/{chunk-N2VWHDGA.js → chunk-SLI7DPVW.js} +1 -1
  57. package/dist/standalone/{chunk-CXGPKEDJ.js → chunk-TIIEZS24.js} +1 -1
  58. package/dist/standalone/{chunk-MOMBFDIA.js → chunk-TK6AEV4N.js} +1 -1
  59. package/dist/standalone/{chunk-U2YJ64UT.js → chunk-TTIBDOV6.js} +1 -1
  60. package/dist/standalone/{chunk-WX6MJS7P.js → chunk-V56XORNF.js} +1 -1
  61. package/dist/standalone/{chunk-IBM6X4XI.js → chunk-V7G6YTQ5.js} +1 -1
  62. package/dist/standalone/{chunk-U3T6FYYZ.js → chunk-VWXJAY7R.js} +1 -1
  63. package/dist/standalone/{chunk-6HVFOKP5.js → chunk-WD4WHTAV.js} +1 -1
  64. package/dist/standalone/{chunk-G22LSAIH.js → chunk-WIXX2VWE.js} +1 -1
  65. package/dist/standalone/{chunk-3JDH25N2.js → chunk-WRZTTZFV.js} +1 -1
  66. package/dist/standalone/{chunk-Y5IE2W4U.js → chunk-Y2I6GYEG.js} +1 -1
  67. package/dist/standalone/{chunk-I5V3IHPF.js → chunk-YONJDNSM.js} +1 -1
  68. package/dist/standalone/chunk-Z2XS4ZOO.js +1 -0
  69. package/dist/standalone/studio.js +1 -1
  70. package/package.json +5 -5
  71. package/dist/packem_shared/DataBrowser-B_zcf3a_.mjs +0 -4
  72. package/dist/packem_shared/DataFilters-3nbW0uax.mjs +0 -1
  73. package/dist/packem_shared/grid-features-Dl7bCGRN.mjs +0 -6
  74. package/dist/standalone/chunk-KYMUE3MZ.js +0 -5
  75. package/dist/standalone/chunk-RY66ZJJQ.js +0 -1
  76. package/dist/standalone/chunk-SA5SGD3V.js +0 -8
  77. package/dist/standalone/chunk-YAAM5IKA.js +0 -1
  78. package/dist/standalone/chunk-Z7WCKAUJ.js +0 -11
@@ -0,0 +1,4 @@
1
+ import{c as B}from"react/compiler-runtime";import{useLunora as dt}from"@lunora/react";import{useState as D,useEffect as Be,useMemo as Tt,useRef as Ge,useCallback as it}from"react";import{ShardInput as Mn}from"./ShardInput-C6mjgAh4.mjs";import{u as Xe}from"./use-admin-query-BKXiqLci.mjs";import{ADMIN_FUNCTIONS as pe}from"./ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{b as Qt}from"./browser-storage-BH1MxLZs.mjs";import{f as Ce,i as je,j as Yt,b as Ft,c as Te,d as ke,h as Ln}from"./internal-B6haJbiP.mjs";import{m as Vn,c as Xt,d as vt,G as Bn,a as jn,u as wt,b as zn,T as qn,D as Kn}from"./table-list-sidebar-DHG1UJC4.mjs";import{u as Gn}from"./use-sql-assistant-BhIMDQHV.mjs";import{d as Rt,i as Zt,e as en,a as Jn}from"./wire-codec-Bk4XZGE4.mjs";import{B as yt}from"./button-q0UYSmrn.mjs";import{I as Wn}from"./input-CXhxesPC.mjs";import{L as Mt}from"./label-DKFzyHq6.mjs";import{M as ut}from"./modal-shell-CDztwLnv.mjs";import{useT as he}from"./DEFAULT_LOCALE-A1Yg5ORA.mjs";import{jsx as d,jsxs as E,Fragment as Ze}from"react/jsx-runtime";import{ConfirmButton as Lt}from"./ConfirmButton-DU4p72Er.mjs";import{E as Hn}from"./empty-state-D7jEML_T.mjs";import{C as Et,a as De}from"./control-button-BOZ5K-FC.mjs";import{tableFeatures as Un,sortFn_text as Qn,sortFn_datetime as Yn,sortFn_basic as Xn,sortFn_alphanumeric as Zn,rowSortingFeature as eo,rowSelectionFeature as to,columnVisibilityFeature as no,columnSizingFeature as oo,columnResizingFeature as so,columnOrderingFeature as lo,createSortedRowModel as ro,useTable as ao,flexRender as io}from"@tanstack/react-table";import{useVirtualizer as co}from"@tanstack/react-virtual";import{C as $t}from"./checkbox-CnS9cyCz.mjs";import{c as ct}from"./utils-bhneXptQ.mjs";import{f as uo}from"./virtual-rect-D_j7aLxX.mjs";import{C as Ct,G as fo,T as mo}from"./data-grid-DTBAKZlm.mjs";import{DataFilters as go,toFilterClauses as Fe}from"./DataFilters-Cocu-WWE.mjs";import{G as po,C as bo}from"./grid-features-CE8kcqsK.mjs";import Vt from"./useDebounced-DVeQ5-oW.mjs";import{r as ho,l as xo}from"./shard-history-CaO3C4KQ.mjs";const vo=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}))}))}),wo=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},yo=(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},Bt=(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},Dt=s=>`${s.table}.${s.column}`,Co=s=>{const e=B(111),{columns:n,onApply:o,onClose:t,shardKey:c,table:l,total:r,uniqueColumns:a}=s,i=he(),[m,u]=D(n[0]??""),[p,b]=D("");let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=ee=>{u(ee.target.value)},e[0]=f):f=e[0];const g=f;let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=ee=>{b(ee.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 C,N;if(e[4]!==y||e[5]!==i||e[6]!==p){if(!y)try{N=Rt(JSON.parse(p))}catch(ee){C=i("Invalid JSON: {message}",{message:ee.message})}e[4]=y,e[5]=i,e[6]=p,e[7]=C,e[8]=N}else C=e[7],N=e[8];let k;e[9]!==m||e[10]!==r||e[11]!==a?(k=a.has(m)&&r>1,e[9]=m,e[10]=r,e[11]=a,e[12]=k):k=e[12];const S=k,w=m!==""&&!y&&C===void 0&&!S;let T;e[13]!==w||e[14]!==m||e[15]!==o||e[16]!==t||e[17]!==N?(T=()=>{w&&(o({[m]:N}),t())},e[13]=w,e[14]=m,e[15]=o,e[16]=t,e[17]=N,e[18]=T):T=e[18];const I=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 O;e[25]!==i||e[26]!==l||e[27]!==r?(O=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]=O):O=e[28];let M;e[29]!==O?(M=d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-desc",children:O}),e[29]=O,e[30]=M):M=e[30];let P;e[31]!==c||e[32]!==i?(P=c===""?i("Shard: root"):i("Shard: {shardKey} — rows in other shards are not touched.",{shardKey:c}),e[31]=c,e[32]=i,e[33]=P):P=e[33];let z;e[34]!==P?(z=d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-shard",children:P}),e[34]=P,e[35]=z):z=e[35];let q;e[36]!==M||e[37]!==z||e[38]!==$?(q=E("div",{className:"flex flex-col gap-0.5",children:[$,M,z]}),e[36]=M,e[37]=z,e[38]=$,e[39]=q):q=e[39];let F;e[40]!==i?(F=i("Close"),e[40]=i,e[41]=F):F=e[41];let V;e[42]!==t||e[43]!==F?(V=d(yt,{"data-testid":"bulk-patch-close",onClick:t,size:"xs",variant:"ghost",children:F}),e[42]=t,e[43]=F,e[44]=V):V=e[44];let J;e[45]!==q||e[46]!==V?(J=E("div",{className:"flex items-start justify-between",children:[q,V]}),e[45]=q,e[46]=V,e[47]=J):J=e[47];let K;e[48]!==i?(K=i("Column"),e[48]=i,e[49]=K):K=e[49];let Z;e[50]!==K?(Z=d(Mt,{htmlFor:"bulk-patch-column",children:K}),e[50]=K,e[51]=Z):Z=e[51];let Y;e[52]!==i?(Y=i("Column"),e[52]=i,e[53]=Y):Y=e[53];let Q;e[54]!==n?(Q=n.map(No),e[54]=n,e[55]=Q):Q=e[55];let ne;e[56]!==m||e[57]!==Y||e[58]!==Q?(ne=d("select",{"aria-label":Y,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:m,children:Q}),e[56]=m,e[57]=Y,e[58]=Q,e[59]=ne):ne=e[59];let oe;e[60]!==i?(oe=i("Value"),e[60]=i,e[61]=oe):oe=e[61];let de;e[62]!==oe?(de=d(Mt,{htmlFor:"bulk-patch-value",children:oe}),e[62]=oe,e[63]=de):de=e[63];let ue;e[64]!==p?(ue=d(Wn,{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]=ue):ue=e[65];let me;e[66]!==Z||e[67]!==ne||e[68]!==de||e[69]!==ue?(me=E("div",{className:"flex items-center gap-2",children:[Z,ne,de,ue]}),e[66]=Z,e[67]=ne,e[68]=de,e[69]=ue,e[70]=me):me=e[70];let re;e[71]!==C?(re=C!==void 0&&d("p",{className:"text-xs text-destructive","data-testid":"bulk-patch-error",role:"alert",children:C}),e[71]=C,e[72]=re):re=e[72];let fe;e[73]!==m||e[74]!==i||e[75]!==r||e[76]!==S?(fe=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:m,total:r.toString()})}),e[73]=m,e[74]=i,e[75]=r,e[76]=S,e[77]=fe):fe=e[77];let ae;e[78]!==y||e[79]!==i||e[80]!==S?(ae=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]=ae):ae=e[81];let X;e[82]!==w||e[83]!==m||e[84]!==p?(X=w&&d("p",{className:"font-mono text-xs text-muted-foreground","data-testid":"bulk-patch-preview",children:`${m} = ${p.trim()}`}),e[82]=w,e[83]=m,e[84]=p,e[85]=X):X=e[85];let be;e[86]!==i?(be=i("Cancel"),e[86]=i,e[87]=be):be=e[87];let te;e[88]!==t||e[89]!==be?(te=d(yt,{"data-testid":"bulk-patch-cancel",onClick:t,size:"xs",variant:"outline",children:be}),e[88]=t,e[89]=be,e[90]=te):te=e[90];const xe=!w;let ie;e[91]!==i||e[92]!==r?(ie=i("Set on {total} rows",{total:r.toString()}),e[91]=i,e[92]=r,e[93]=ie):ie=e[93];let ce;e[94]!==I||e[95]!==xe||e[96]!==ie?(ce=d(yt,{"data-testid":"bulk-patch-apply",disabled:xe,onClick:I,size:"xs",children:ie}),e[94]=I,e[95]=xe,e[96]=ie,e[97]=ce):ce=e[97];let W;e[98]!==te||e[99]!==ce?(W=E("div",{className:"flex justify-end gap-2",children:[te,ce]}),e[98]=te,e[99]=ce,e[100]=W):W=e[100];let G;return e[101]!==t||e[102]!==J||e[103]!==me||e[104]!==re||e[105]!==fe||e[106]!==ae||e[107]!==X||e[108]!==W||e[109]!==R?(G=E(ut,{label:R,onClose:t,panelTestId:"bulk-patch-panel",testId:"bulk-patch-overlay",variant:"dialog",children:[J,me,re,fe,ae,X,W]}),e[101]=t,e[102]=J,e[103]=me,e[104]=re,e[105]=fe,e[106]=ae,e[107]=X,e[108]=W,e[109]=R,e[110]=G):G=e[110],G};function No(s){return d("option",{value:s,children:s},s)}const jt=6,rt=100,So=s=>({paddingLeft:s*16}),ko=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},To=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},Eo=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},_o=s=>s.relation===void 0||s.relation.onDelete==="cascade"?d(To,{table:s.table}):s.isRestrict?d(ko,{table:s.table}):d(Eo,{table:s.table}),tn=s=>{const e=B(35),{depth:n,node:o}=s,t=`cascade-row-${o.table}`;let c;e[0]!==n?(c=So(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 m;e[11]!==i?(m=E("span",{className:"text-muted-foreground",children:["(",i," rows)"]}),e[11]=i,e[12]=m):m=e[12];let u;e[13]!==o?(u=_o(o),e[13]=o,e[14]=u):u=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]!==m||e[24]!==u||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,m,u,p]}),e[18]=t,e[19]=c,e[20]=l,e[21]=r,e[22]=a,e[23]=m,e[24]=u,e[25]=p,e[26]=b):b=e[26];let f;if(e[27]!==n||e[28]!==o.children){let h;e[30]!==n?(h=(x,v)=>d(tn,{depth:n+1,node:x},`${x.table}-${x.relation?.field??"root"}-${v.toString()}`),e[30]=n,e[31]=h):h=e[31],f=o.children.map(h),e[27]=n,e[28]=o.children,e[29]=f}else f=e[29];let g;return e[32]!==b||e[33]!==f?(g=E(Ze,{children:[b,f]}),e[32]=b,e[33]=f,e[34]=g):g=e[34],g},Ro=s=>{const e=s._id??s.id??s.__id__??"";return typeof e=="string"?e:typeof e=="number"?e.toString():""},$o=async(s,e,n,o)=>{try{const t=await o(s,e,n),c=t.rows.flatMap(a=>Ro(a)||[]).slice(0,rt),l=t.total??0;return{capNote:l>rt?`showing first ${rt.toString()} of ${l.toString()}`:void 0,rowCount:l,rowIds:c}}catch{return{capNote:"count unavailable",rowCount:0,rowIds:[]}}},nn=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 $o(s,n.field,e,l),m=n?.onDelete==="restrict",u=[],p=`${s}:${e}`,b=c>=jt;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 nn(h.table,x,h,o,t,c+1,l);(v.rowCount>0||c===0)&&u.push(v)}t.delete(p)}let f=r;if(b){const g=`depth capped at ${jt.toString()}`;f=r===void 0?g:`${r}; ${g}`}return{capNote:f,children:u,isRestrict:m,relation:n,rowCount:a,rowIds:i,table:s}},Do=({onClose:s,onConfirm:e,readPage:n,rowId:o,schema:t,table:c})=>{const l=he(),[r,a]=D(!0),[i,m]=D(null),[u,p]=D(null);Be(()=>{let g=!1;return Ce((async()=>{try{a(!0),p(null);const x=wo(t);if(!((x.get(c)??[]).length>0)){g||(m({capNote:void 0,children:[],isRestrict:!1,relation:void 0,rowCount:1,rowIds:[o],table:c}),a(!1));return}const y=await nn(c,o,void 0,x,new Set,0,n);g||(m(y),a(!1))}catch(x){g||(p(x.message),a(!1))}})()),()=>{g=!0}},[o,c]);const b=i!==null&&yo(i,g=>g.isRestrict).length>0,f=()=>{e(),s()};return E(ut,{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…")}),u!==null&&d("p",{className:"text-xs text-destructive","data-testid":"cascade-error",role:"alert",children:u}),!r&&i!==null&&d("ul",{className:"flex flex-col","data-testid":"cascade-tree",children:d(tn,{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:f,type:"button",children:l("Delete")})]})]})},Ao=(s,e,n,o,t=300)=>{if(o<=0)return{ids:new Set(s.map(u=>u.id)),leadPx:0,tailPx:0};const c=n-t,l=n+o+t,r=new Set;let a=0,i=0,m=0;for(const u of s){const p=u.getSize(),b=e.has(u.id),f=a+p>c&&a<l;b||f?r.add(u.id):a<c?i+=p:m+=p,a+=p}return{ids:r,leadPx:i,tailPx:m}},Io=(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},Po=Un({columnOrderingFeature:lo,columnResizingFeature:so,columnSizingFeature:oo,columnVisibilityFeature:no,rowSelectionFeature:to,rowSortingFeature:eo,sortedRowModel:ro(),sortFns:{alphanumeric:Zn,basic:Xn,datetime:Yn,text:Qn}}),Oo=()=>{const s=B(12);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e={},s[0]=e):e=s[0];const[n,o]=D(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(C=>{const[N,k]=C;return!(N in h)||!Object.is(k,h[N])}));return Object.keys(y).length===0?Object.fromEntries(Object.entries(x).filter(C=>{const[N]=C;return N!==g})):{...x,[g]:y}})},s[3]=a):a=s[3];const i=a;let m;s[4]!==n?(m=(g,h)=>{const x=n[g];return x!==void 0&&h in x?{value:x[h]}:void 0},s[4]=n,s[5]=m):m=s[5];const u=m;let p;s[6]!==n?(p=Object.values(n).reduce(Mo,0),s[6]=n,s[7]=p):p=s[7];const b=p;let f;return s[8]!==b||s[9]!==n||s[10]!==u?(f={clear:r,count:b,drop:i,stage:c,staged:n,stagedValue:u},s[8]=b,s[9]=n,s[10]=u,s[11]=f):f=s[11],f},on=(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},Fo=s=>{const e=B(29),{changes:n,committing:o,onCommit:t,onDiscard:c}=s,l=he();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 m;e[8]!==o||e[9]!==t||e[10]!==i?(m=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]=m):m=e[11];let u;e[12]!==l?(u=l("Discard"),e[12]=l,e[13]=u):u=e[13];let p;e[14]!==o||e[15]!==c||e[16]!==u?(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:u}),e[14]=o,e[15]=c,e[16]=u,e[17]=p):p=e[17];let b;e[18]!==a||e[19]!==m||e[20]!==p?(b=E("div",{className:"flex flex-wrap items-center gap-2",children:[a,m,p]}),e[18]=a,e[19]=m,e[20]=p,e[21]=b):b=e[21];let f;e[22]!==n?(f=n.map(Lo),e[22]=n,e[23]=f):f=e[23];let g;e[24]!==f?(g=d("ul",{className:"flex flex-col gap-1","data-testid":"db-staged-list",children:f}),e[24]=f,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 Mo(s,e){return s+Object.keys(e).length}function Lo(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:je(s.oldValue)}),d("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"→"}),d("span",{className:"text-foreground",children:je(s.newValue)})]},`${s.rowId}:${s.column}`)}const zt=400,Vo=36,Bo={flex:"1 1 0%",minHeight:0,overflow:"auto",position:"relative"},jo={width:"100%"},zo=/\n$/u,qo={alignItems:"center",display:"flex",left:0,position:"absolute",top:0,width:"100%"},Ko={display:"flex",width:"100%"},qt={flex:"0 0 8.5rem",padding:"0.375rem 0.75rem"},Go="2.5rem",sn={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`}),ln=(s,e)=>({...At(s),left:`calc(${Go} + ${e.toString()}px)`,position:"sticky",zIndex:2}),Nt="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",Jo=(s,e,n)=>e.enabled&&e.columns.has(n)?void 0:s,_t="__back__:",Wo=s=>`${_t}${s.table}.${s.column}`,Ho=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},Ae=s=>{for(const e of["id","__id__","_id"]){const n=s[e];if(typeof n=="string"||typeof n=="number")return String(n)}return null},Uo=(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}},Qo=(s,e,n)=>{if(n!==void 0&&n.type!=="any")return Uo(s,n);const o=on(s,e);return typeof e=="number"&&typeof o!="number"?void 0:{value:o}},Yo=({anchor:s,columnIds:e,columnMeta:n,editableColumn:o,rows:t,text:c})=>{const l=c.replaceAll(`\r
2
+ `,`
3
+ `).replace(zo,"").split(`
4
+ `),r=[];let a=0;for(const[i,m]of l.entries()){const u=t[s.row+i],p=u===void 0?null:Ae(u),b=m.split(" ");if(u===void 0||p===null){a+=b.length;continue}for(const[f,g]of b.entries()){const h=e[s.col+f],x=h===void 0||!o(h)?void 0:Qo(g,u[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}},rn=(s,e)=>Ae(s)??`row-${e.toString()}`,Xo=8,Zo=s=>{const e=B(17),{anchor:n,mask:o,state:t}=s,c=he();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 m;e[3]!==c?(m=c("Loading…"),e[3]=c,e[4]=m):m=e[4];let u;e[5]!==m?(u=d("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:m}),e[5]=m,e[6]=u):u=e[6],a=u}else if(t.row===null){let m;e[7]!==c?(m=c("No matching row."),e[7]=c,e[8]=m):m=e[8];let u;e[9]!==m?(u=d("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:m}),e[9]=m,e[10]=u):u=e[10],a=u}else{let m;if(e[11]!==o||e[12]!==t.row){const u=Object.entries(Xt(t.row,o)).slice(0,Xo);m=d("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 px-3 py-2",children:u.map(us)}),e[11]=o,e[12]=t.row,e[13]=m}else m=e[13];a=m}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},es=s=>{const e=B(24),{column:n,id:o,maskViewFor:t,onNavigate:c,onPreview:l,target:r}=s,[a,i]=D(null),[m,u]=D("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 f;e[4]!==o||e[5]!==l||e[6]!==m||e[7]!==r?(f=S=>{const w=S.currentTarget.getBoundingClientRect();if(i({left:w.left,top:w.bottom+4}),m!=="idle")return;u("loading"),Ce((async()=>{try{u({row:await l(r,o)})}catch{u({row:null})}})())},e[4]=o,e[5]=l,e[6]=m,e[7]=r,e[8]=f):f=e[8];const g=f;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 C;e[10]!==o||e[11]!==b||e[12]!==g||e[13]!==v||e[14]!==y?(C=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]=C):C=e[15];let N;e[16]!==a||e[17]!==t||e[18]!==m||e[19]!==r?(N=a!==null&&m!=="idle"&&d(Zo,{anchor:a,mask:t(r,m==="loading"||m.row===null?[]:Object.keys(m.row)),state:m}),e[16]=a,e[17]=t,e[18]=m,e[19]=r,e[20]=N):N=e[20];let k;return e[21]!==C||e[22]!==N?(k=E(Ze,{children:[C,N]}),e[21]=C,e[22]=N,e[23]=k):k=e[23],k},ts=s=>s==="asc"?" ▲":s==="desc"?" ▼":"",ns="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",Kt=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:ns,"data-testid":r,onClick:l,type:"button",children:a}),e[5]=l,e[6]=r,e[7]=i):i=e[7],i},os=s=>{const e=B(15),{column:n,initial:o,onCancel:t,onCommit:c,recordId:l}=s,r=Ge(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 m;e[2]!==t||e[3]!==c?(m=x=>{x.key==="Enter"?(x.preventDefault(),c(x.currentTarget.value)):x.key==="Escape"&&(x.preventDefault(),t())},e[2]=t,e[3]=c,e[4]=m):m=e[4];const u=m;let p;e[5]!==c?(p=x=>{c(x.currentTarget.value)},e[5]=c,e[6]=p):p=e[6];const b=p,f=`db-cell-input-${l}-${n}`;let g;e[7]!==o?(g=je(o),e[7]=o,e[8]=g):g=e[8];let h;return e[9]!==n||e[10]!==b||e[11]!==u||e[12]!==f||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":f,defaultValue:g,onBlur:b,onKeyDown:u,ref:r}),e[9]=n,e[10]=b,e[11]=u,e[12]=f,e[13]=g,e[14]=h):h=e[14],h},ss=s=>{const e=B(70),{cell:n,edit:o,highlight:t,mask:c,refs:l}=s,r=n.column.id;let a,i,m,u;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){u=Symbol.for("react.early_return_sentinel");e:{i=n.getValue(),a=Ae(n.row.original);const R=l.columns?.[r];if(c.enabled&&c.columns.has(r)){const _=`db-masked-${r}`,$=d(Ct,{value:Vn(i,r,c)});let O;e[12]!==_||e[13]!==$?(O=d("span",{className:"text-muted-foreground italic","data-testid":_,title:"Masked (preview)",children:$}),e[12]=_,e[13]=$,e[14]=O):O=e[14],u=O;break e}if(R!==void 0&&(typeof i=="string"||typeof i=="number")&&String(i)!==""){const _=String(i),$=`${R}:${String(i)}`;let O;e[15]!==r||e[16]!==l.maskViewFor||e[17]!==l.onNavigate||e[18]!==l.onPreview||e[19]!==_||e[20]!==$||e[21]!==R?(O=d(es,{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]=O):O=e[22],u=O;break e}if(a===null){let _;e[23]!==i?(_=d(Ct,{value:i}),e[23]=i,e[24]=_):_=e[24];let $;e[25]!==r||e[26]!==o.onExpandCell||e[27]!==i?($=d(Kt,{column:r,onExpand:o.onExpandCell,value:i}),e[25]=r,e[26]=o.onExpandCell,e[27]=i,e[28]=$):$=e[28];let O;e[29]!==_||e[30]!==$?(O=E(Ze,{children:[_,$]}),e[29]=_,e[30]=$,e[31]=O):O=e[31],u=O;break e}m=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]=m,e[11]=u}else a=e[8],i=e[9],m=e[10],u=e[11];if(u!==Symbol.for("react.early_return_sentinel"))return u;const p=m,b=p===void 0?i:p.value;let f;e[32]!==r||e[33]!==o?(f=o.editable&&o.editableColumn(r),e[32]=r,e[33]=o,e[34]=f):f=e[34];const g=f;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,on($,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(os,{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,C=x,N=`db-cell-${a}-${r}`;let k;e[51]!==r||e[52]!==t||e[53]!==c?(k=Jo(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(Ct,{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]!==N||e[61]!==S?(w=d("span",{className:C,"data-testid":N,onDoubleClick:y,children:S}),e[58]=x,e[59]=y,e[60]=N,e[61]=S,e[62]=w):w=e[62];let T;e[63]!==r||e[64]!==b||e[65]!==o.onExpandCell?(T=d(Kt,{column:r,onExpand:o.onExpandCell,value:b}),e[63]=r,e[64]=b,e[65]=o.onExpandCell,e[66]=T):T=e[66];let I;return e[67]!==T||e[68]!==w?(I=E(Ze,{children:[w,T]}),e[67]=T,e[68]=w,e[69]=I):I=e[69],I},ls=s=>{s.preventDefault()},Gt={any:"?",array:"[]",bigint:"#",boolean:"01",bytes:"0x",id:"→",number:"#",object:"{}",storage:"◫",string:"T",union:"|"},rs=({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,m=n.column.id;if(e.current=null,i===null||i===m)return;const u=l.atoms.columnOrder.get(),b=(u.length>0?u:l.getAllLeafColumns().map(g=>g.id)).filter(g=>g!==i),f=b.indexOf(m);b.splice(f===-1?b.length:f,0,i),l.setColumnOrder(b)};return E("th",{className:ct("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:ls,onDragStart:r,onDrop:a,style:c===void 0?At(n.getSize()):ln(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:[io(n.column.columnDef.header,n.getContext()),ts(n.column.getIsSorted())]}),s!==void 0&&Gt[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:Gt[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:ct("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()})]})},as=s=>{const e=B(13),{table:n}=s,o=he();let t;e[0]!==n?(t=m=>{n.toggleAllRowsSelected(m)},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:sn,children:d($t,{"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},is=s=>{const e=B(17),{row:n}=s,o=he();let t;e[0]!==n.original?(t=Ae(n.original),e[0]=n.original,e[1]=t):t=e[1];const c=t;let l;e[2]!==n?(l=f=>{n.toggleSelected(f)},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 m;e[8]!==n.index||e[9]!==n.original?(m=rn(n.original,n.index),e[8]=n.index,e[9]=n.original,e[10]=m):m=e[10];const u=`db-select-${m}`,p=c===null;let b;return e[11]!==r||e[12]!==a||e[13]!==i||e[14]!==u||e[15]!==p?(b=d("td",{className:"bg-background",style:sn,children:d($t,{"aria-label":a,checked:i,"data-testid":u,disabled:p,onCheckedChange:r})}),e[11]=r,e[12]=a,e[13]=i,e[14]=u,e[15]=p,e[16]=b):b=e[16],b},cs=s=>{const e=B(91),{columnMeta:n,edit:o,editable:t,mask:c,onDelete:l,onEdit:r,onInspect:a,highlight:i,backRelationCounts:m,onTogglePin:u,pinnedColumns:p,refs:b,tableModel:f}=s,g=he(),{attachScroll:h,scrollLeft:x,scrollToIndex:v,table:y,tableRows:C,tbodyStyle:N,viewportWidth:k,virtualRows:S}=f,w=Ge(null),[T,I]=D(null);let R;e[0]===Symbol.for("react.memo_cache_sentinel")?(R={columns:"",count:0},e[0]=R):R=e[0];const[_,$]=D(R);let O;e[1]!==y?(O=y.getVisibleLeafColumns(),e[1]=y,e[2]=O):O=e[2];const M=O.length;let P;e[3]!==T||e[4]!==M||e[5]!==o||e[6]!==y||e[7]!==C?(P=ee=>{if(!["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","Enter"].includes(ee.key))return;ee.preventDefault();const H=T??{col:0,row:0};if(ee.key==="Enter"){const we=C[H.row],ye=y.getVisibleLeafColumns()[H.col];if(we!==void 0&&ye!==void 0){const U=Ae(we.original);U!==null&&o.editableColumn(ye.id)&&o.startEdit(U,ye.id)}I(H);return}let{col:ve,row:ge}=H;e:switch(ee.key){case"ArrowDown":{ge=Math.min(ge+1,C.length-1);break e}case"ArrowRight":{ve=Math.min(ve+1,M-1);break e}case"ArrowUp":{ge=Math.max(ge-1,0);break e}default:ve=Math.max(ve-1,0)}I({col:ve,row:ge})},e[3]=T,e[4]=M,e[5]=o,e[6]=y,e[7]=C,e[8]=P):P=e[8];const z=P;let q;e[9]!==T||e[10]!==n||e[11]!==o||e[12]!==y||e[13]!==C?(q=ee=>{const H=o.editable?ee.clipboardData.getData("text/plain"):"";if(H==="")return;ee.preventDefault();const ve=y.getVisibleLeafColumns().map(fs),ge=Yo({anchor:T??{col:0,row:0},columnIds:ve,columnMeta:n,editableColumn:o.editableColumn,rows:C.map(ms),text:H});for(const we of ge.edits)o.stage(we.rowId,we.column,we.value);$({columns:ve.join("\0"),count:ge.skipped})},e[9]=T,e[10]=n,e[11]=o,e[12]=y,e[13]=C,e[14]=q):q=e[14];const F=q;let V,J;e[15]!==T||e[16]!==v?(V=()=>{T!==null&&v(T.row)},J=[T,v],e[15]=T,e[16]=v,e[17]=V,e[18]=J):(V=e[17],J=e[18]),Be(V,J);let K,Z,Y,Q,ne,oe,de,ue,me,re,fe,ae,X,be,te,xe;if(e[19]!==T||e[20]!==h||e[21]!==m||e[22]!==n||e[23]!==o||e[24]!==t||e[25]!==i||e[26]!==c||e[27]!==l||e[28]!==r||e[29]!==z||e[30]!==F||e[31]!==a||e[32]!==u||e[33]!==_.columns||e[34]!==_.count||e[35]!==p||e[36]!==b||e[37]!==x||e[38]!==g||e[39]!==y||e[40]!==C||e[41]!==N||e[42]!==k||e[43]!==S){const ee=y.getVisibleLeafColumns().map(gs),H=Ao(ee,p,x,k),ve=Io(y.getVisibleLeafColumns().map(ps),p),ge=U=>{const se=C[U.index],{original:Me}=se,Ie=Ae(Me),Pe=rn(Me,U.index),We={...qo,height:`${U.size.toString()}px`,transform:`translateY(${U.start.toString()}px)`};return E("tr",{className:"border-b border-border text-xs transition-colors hover:bg-muted/50","data-testid":"db-row",style:We,children:[d(is,{row:se}),H.leadPx>0&&d("td",{"aria-hidden":"true",style:{flex:`0 0 ${H.leadPx.toString()}px`}}),se.getVisibleCells().map((Se,ze)=>{if(!H.ids.has(Se.column.id))return null;const Le=ve.get(Se.column.id),He=T!==null&&T.row===U.index&&T.col===ze?" ring-1 ring-ring ring-inset":"";return d("td",{className:ct("group/cell truncate font-mono text-muted-foreground",Le!==void 0&&"border-e border-border bg-background",He),onPointerDown:()=>{I({col:ze,row:U.index})},style:Le===void 0?At(Se.column.getSize()):ln(Se.column.getSize(),Le),children:Se.column.id.startsWith(_t)?d(Ho,{counts:m[Se.column.id.slice(_t.length)],rowId:Pe}):d(ss,{cell:Se,edit:o,highlight:i,mask:c,refs:b})},Se.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:qt,children:[d("button",{className:Nt,"data-testid":`db-inspect-${Pe}`,onClick:()=>{a(Me)},type:"button",children:"Details"}),t&&E(Ze,{children:[d("button",{className:Nt,"data-testid":`db-edit-${Pe}`,disabled:Ie===null,onClick:()=>{r(Ie,Me)},type:"button",children:"Edit"}),d("button",{className:Nt,"data-testid":`db-delete-${Pe}`,disabled:Ie===null,onClick:()=>{l(Ie)},type:"button",children:"Delete"})]})]})]},se.id)};K=fo,ae="fill",e[60]!==_.columns||e[61]!==_.count||e[62]!==g||e[63]!==y?(X=_.count>0&&_.columns===y.getVisibleLeafColumns().map(bs).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]=X):X=e[64],ne="db-scroll",oe=z,de=F,ue=h,me="grid",re=Bo,fe=0,xe="w-full text-xs",Z="db-rows",Y=jo;let we;e[65]!==y?(we=d(as,{table:y}),e[65]=y,e[66]=we):we=e[66];let ye;e[67]===Symbol.for("react.memo_cache_sentinel")?(ye=d("th",{"aria-label":"Row actions",style:qt}),e[67]=ye):ye=e[67],Q=d("thead",{className:"bg-muted/50",children:E("tr",{className:"border-b border-border",style:Ko,children:[we,H.leadPx>0&&d("th",{"aria-hidden":"true",style:{flex:`0 0 ${H.leadPx.toString()}px`}}),y.getFlatHeaders().map(U=>H.ids.has(U.column.id)?d(rs,{declaredType:n?.[U.column.id]?.type,draggedRef:w,header:U,masked:c.columns.has(U.column.id),onTogglePin:u,pinnedOffset:ve.get(U.column.id),table:y},U.id):null),H.tailPx>0&&d("th",{"aria-hidden":"true",style:{flex:`0 0 ${H.tailPx.toString()}px`}}),ye]})}),be=N,te=S.map(U=>ge(U)),e[19]=T,e[20]=h,e[21]=m,e[22]=n,e[23]=o,e[24]=t,e[25]=i,e[26]=c,e[27]=l,e[28]=r,e[29]=z,e[30]=F,e[31]=a,e[32]=u,e[33]=_.columns,e[34]=_.count,e[35]=p,e[36]=b,e[37]=x,e[38]=g,e[39]=y,e[40]=C,e[41]=N,e[42]=k,e[43]=S,e[44]=K,e[45]=Z,e[46]=Y,e[47]=Q,e[48]=ne,e[49]=oe,e[50]=de,e[51]=ue,e[52]=me,e[53]=re,e[54]=fe,e[55]=ae,e[56]=X,e[57]=be,e[58]=te,e[59]=xe}else K=e[44],Z=e[45],Y=e[46],Q=e[47],ne=e[48],oe=e[49],de=e[50],ue=e[51],me=e[52],re=e[53],fe=e[54],ae=e[55],X=e[56],be=e[57],te=e[58],xe=e[59];let ie;e[68]!==be||e[69]!==te?(ie=d("tbody",{style:be,children:te}),e[68]=be,e[69]=te,e[70]=ie):ie=e[70];let ce;e[71]!==Z||e[72]!==Y||e[73]!==Q||e[74]!==ie||e[75]!==xe?(ce=E("table",{className:xe,"data-testid":Z,style:Y,children:[Q,ie]}),e[71]=Z,e[72]=Y,e[73]=Q,e[74]=ie,e[75]=xe,e[76]=ce):ce=e[76];let W;e[77]!==ne||e[78]!==oe||e[79]!==de||e[80]!==ue||e[81]!==me||e[82]!==re||e[83]!==fe||e[84]!==ce?(W=d("div",{"data-testid":ne,onKeyDown:oe,onPaste:de,ref:ue,role:me,style:re,tabIndex:fe,children:ce}),e[77]=ne,e[78]=oe,e[79]=de,e[80]=ue,e[81]=me,e[82]=re,e[83]=fe,e[84]=ce,e[85]=W):W=e[85];let G;return e[86]!==K||e[87]!==ae||e[88]!==X||e[89]!==W?(G=E(K,{layout:ae,children:[X,W]}),e[86]=K,e[87]=ae,e[88]=X,e[89]=W,e[90]=G):G=e[90],G},ds=(s,e,n,o=[])=>{const t=s?.columns,c=s?.rows,l=s?.refs,r=Tt(()=>{if(t===void 0)return[];const w=t.map(T=>({accessorFn:I=>I[T],header:l?.[T]===void 0?T:`${T} →`,id:T}));for(const T of o)w.push({accessorFn:()=>{},enableSorting:!1,header:`← ${T.table}`,id:Wo(T)});return w},[o,t,l]),a=Tt(()=>c??[],[c]),[i,m]=D({}),[u,p]=D({}),b=ao({columnResizeMode:"onChange",columns:r,data:a,defaultColumn:{minSize:80,size:200},enableColumnResizing:!0,enableRowSelection:w=>Ae(w.original)!==null,features:Po,getRowId:(w,T)=>Ae(w)??`row-${T.toString()}`,manualSorting:!0,onColumnVisibilityChange:p,onRowSelectionChange:m,onSortingChange:n,state:{columnVisibility:u,rowSelection:i,sorting:e}}),f=b.getRowModel().rows,g=Ge(null),h=co({count:f.length,estimateSize:()=>Vo,getScrollElement:()=>g.current,initialRect:{height:zt,width:0},observeElementRect:(w,T)=>uo(w,T,zt),overscan:8}),x=it(w=>{h.scrollToIndex(w)},[h]),[v,y]=D({left:0,width:0}),C=it(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 I=new ResizeObserver(T);return I.observe(w),()=>{w.removeEventListener("scroll",T),I.disconnect(),g.current=null}},[]),N=h.getVirtualItems(),S={display:"block",height:`${h.getTotalSize().toString()}px`,position:"relative"};return{attachScroll:C,scrollLeft:v.left,scrollToIndex:x,table:b,tableRows:f,tbodyStyle:S,viewportWidth:v.width,virtualRows:N}};function us(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:je(n),children:je(n)})]},e)}function fs(s){return s.id}function ms(s){return s.original}function gs(s){return{getSize:()=>s.getSize(),id:s.id}}function ps(s){return{getSize:()=>s.getSize(),id:s.id}}function bs(s){return s.id}const hs=s=>{const e=B(22),{onCommit:n}=s,o=he(),[t,c]=D(""),l=Ge(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 m=i;let u;e[3]!==t||e[4]!==n?(u=()=>{const y=t.trim();y!==""&&n(y)},e[3]=t,e[4]=n,e[5]=u):u=e[5];const p=u;let b;e[6]!==o?(b=o("Query name"),e[6]=o,e[7]=b):b=e[7];let f;e[8]!==o?(f=o("Query name"),e[8]=o,e[9]=f):f=e[9];let g;e[10]!==t||e[11]!==b||e[12]!==f?(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:m,placeholder:f,ref:l,value:t}),e[10]=t,e[11]=b,e[12]=f,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:Et,"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},xs=s=>{const e=B(27),{onApply:n,onCopyLink:o,onDelete:t,onSave:c,saved:l}=s,r=he(),[a,i]=D(!1);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{i(!0)},e[0]=m):m=e[0];const u=m;let p;e[1]!==c?(p=S=>{c(S),i(!1)},e[1]=c,e[2]=p):p=e[2];const b=p;let f;e[3]!==n||e[4]!==l?(f=S=>{const w=l[Number(S.currentTarget.dataset.index)];w!==void 0&&n(w)},e[3]=n,e[4]=l,e[5]=f):f=e[5];const g=f;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:Et,"data-testid":"db-copy-link",onClick:o,type:"button",children:v}),e[11]=o,e[12]=v,e[13]=y):y=e[13];let C;e[14]!==b||e[15]!==a||e[16]!==r?(C=a?d(hs,{onCommit:b}):d("button",{className:Et,"data-testid":"db-save-query",onClick:u,type:"button",children:r("Save query")}),e[14]=b,e[15]=a,e[16]=r,e[17]=C):C=e[17];let N;e[18]!==g||e[19]!==x||e[20]!==l||e[21]!==r?(N=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]=N):N=e[22];let k;return e[23]!==y||e[24]!==C||e[25]!==N?(k=E("div",{className:"flex flex-wrap items-center gap-1.5","data-testid":"db-query-bar",children:[y,C,N]}),e[23]=y,e[24]=C,e[25]=N,e[26]=k):k=e[26],k},Je="w-full rounded-md border border-border bg-background px-2 py-1 font-mono text-xs outline-none focus-visible:border-ring",an=/(?:_creationtime|(?:^|[a-z])(?:time|at))$/iu,Jt=(s,e)=>typeof e=="boolean"?"boolean":typeof e=="number"?an.test(s)?"date":"number":e!==null&&typeof e=="object"?"json":"text",vs=(s,e,n)=>n===void 0?Jt(s,e):n.enumValues!==void 0&&n.enumValues.length>0?"enum":n.type==="boolean"?"boolean":n.type==="number"?an.test(s)?"date":"number":Jt(s,e),ws=s=>{try{const e=JSON.parse(s);return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}catch{return null}},ys=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())}`},Ke="\0clear",Cs=s=>{const e=B(23),{column:n,nullable:o,onChange:t,value:c}=s,l=he();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===Ke?null:v.target.value==="true")},e[3]=n,e[4]=t,e[5]=i):i=e[5];const m=i;if(!o&&c!==null){const v=c===!0,y=`db-field-${n}`;let C;return e[6]!==n||e[7]!==a||e[8]!==v||e[9]!==y?(C=d($t,{"aria-label":n,checked:v,"data-testid":y,onCheckedChange:a}),e[6]=n,e[7]=a,e[8]=v,e[9]=y,e[10]=C):C=e[10],C}const u=`db-field-${n}`,p=c===!0||c===!1?String(c):Ke;let b;e[11]!==l?(b=l("(none)"),e[11]=l,e[12]=b):b=e[12];let f;e[13]!==b?(f=d("option",{value:Ke,children:b}),e[13]=b,e[14]=f):f=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]!==m||e[19]!==u||e[20]!==p||e[21]!==f?(x=E("select",{"aria-label":n,className:Je,"data-testid":u,onChange:m,value:p,children:[f,g,h]}),e[17]=n,e[18]=m,e[19]=u,e[20]=p,e[21]=f,e[22]=x):x=e[22],x},Ns=s=>{const e=B(23),{column:n,nullable:o,onChange:t,options:c,value:l}=s,r=he(),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 m=i;let u;e[3]!==n||e[4]!==t?(u=y=>{t(n,y.target.value===Ke?null:y.target.value)},e[3]=n,e[4]=t,e[5]=u):u=e[5];const p=u,b=`db-field-${n}`,f=a??Ke;let g;e[6]!==o||e[7]!==a||e[8]!==r?(g=(o||a===null)&&d("option",{value:Ke,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]!==m?(h=m&&d("option",{value:a,children:a}),e[10]=a,e[11]=m,e[12]=h):h=e[12];let x;e[13]!==c?(x=c.map($s),e[13]=c,e[14]=x):x=e[14];let v;return e[15]!==n||e[16]!==p||e[17]!==b||e[18]!==f||e[19]!==g||e[20]!==h||e[21]!==x?(v=E("select",{"aria-label":n,className:Je,"data-testid":b,onChange:p,value:f,children:[g,h,x]}),e[15]=n,e[16]=p,e[17]=b,e[18]=f,e[19]=g,e[20]=h,e[21]=x,e[22]=v):v=e[22],v},Ss=s=>{const e=B(8),{column:n,onChange:o,value:t}=s;let c;e[0]!==n||e[1]!==o?(c=m=>{const u=Number(m.target.value);m.target.value!==""&&!Number.isNaN(u)&&o(n,u)},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:Je,"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},ks=s=>{const e=B(10),{column:n,onChange:o,value:t}=s;let c;e[0]!==n||e[1]!==o?(c=m=>{const u=new Date(m.target.value).getTime();Number.isNaN(u)||o(n,u)},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"?ys(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:Je,"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},Ts=s=>{const e=B(8),{column:n,onChange:o,value:t}=s;let c;e[0]!==n||e[1]!==o?(c=m=>{o(n,m.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:Je,"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},Es=s=>{const e=B(20),{column:n,onChange:o,value:t}=s,c=he();let l;e[0]!==t?(l=()=>JSON.stringify(t,null,2),e[0]=t,e[1]=l):l=e[1];const[r,a]=D(l),[i,m]=D(!1);let u;e[2]!==n||e[3]!==o?(u=y=>{const C=y.target.value;a(C);try{o(n,JSON.parse(C)),m(!1)}catch{m(!0)}},e[2]=n,e[3]=o,e[4]=u):u=e[4];const p=u,b=i&&"border-destructive";let f;e[5]!==b?(f=ct(Je,"min-h-16",b),e[5]=b,e[6]=f):f=e[6];const g=`db-field-${n}`;let h;e[7]!==n||e[8]!==p||e[9]!==f||e[10]!==g||e[11]!==r?(h=d("textarea",{"aria-label":n,className:f,"data-testid":g,onChange:p,value:r}),e[7]=n,e[8]=p,e[9]=f,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},_s=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=vs(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 m;e[4]!==n?(m=d("span",{className:"font-mono",children:n}),e[4]=n,e[5]=m):m=e[5];let u;e[6]!==n||e[7]!==o?(u=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]=u):u=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]!==m||e[12]!==u||e[13]!==p?(b=E("span",{className:"flex items-center gap-1.5 font-medium text-muted-foreground",children:[m,u,p]}),e[11]=m,e[12]=u,e[13]=p,e[14]=b):b=e[14];let f;e[15]!==n||e[16]!==a||e[17]!==o?.nullable||e[18]!==t||e[19]!==l?(f=a==="boolean"&&d(Cs,{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]=f):f=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(Ns,{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(Ss,{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(ks,{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(Es,{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(Ts,{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 C;return e[47]!==x||e[48]!==v||e[49]!==y||e[50]!==i||e[51]!==b||e[52]!==f||e[53]!==g||e[54]!==h?(C=E("label",{className:"flex flex-col gap-1 text-xs",htmlFor:i,children:[b,f,g,h,x,v,y]}),e[47]=x,e[48]=v,e[49]=y,e[50]=i,e[51]=b,e[52]=f,e[53]=g,e[54]=h,e[55]=C):C=e[55],C},Rs=s=>{const e=B(49),{columnMeta:n,documentText:o,onCancel:t,onDocumentTextChange:c,onSave:l,refs:r}=s,a=he();let i;e[0]!==o?(i=ws(o),e[0]=o,e[1]=i):i=e[1];const m=i,[u,p]=D(!1),b=!u&&m!==null;let f;e[2]!==m||e[3]!==c?(f=(V,J)=>{c(JSON.stringify({...m,[V]:J},null,2))},e[2]=m,e[3]=c,e[4]=f):f=e[4];const g=f;let h;e[5]!==c?(h=V=>{c(V.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 C;e[8]===Symbol.for("react.memo_cache_sentinel")?(C=()=>{p(!0)},e[8]=C):C=e[8];const N=C,k=m===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 I;e[15]!==a?(I=a("JSON"),e[15]=a,e[16]=I):I=e[16];let R;e[17]!==I||e[18]!==T?(R=d("button",{"aria-pressed":T,className:De,"data-testid":"db-editor-json",onClick:N,type:"button",children:I}),e[17]=I,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]!==m||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(m).map(V=>{const[J,K]=V;return d(_s,{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]=m,e[26]=g,e[27]=x,e[28]=r,e[29]=b,e[30]=a,e[31]=$):$=e[31];let O;e[32]!==a?(O=a("Save"),e[32]=a,e[33]=O):O=e[33];let M;e[34]!==l||e[35]!==O?(M=d("button",{className:De,"data-testid":"db-editor-save",onClick:l,type:"button",children:O}),e[34]=l,e[35]=O,e[36]=M):M=e[36];let P;e[37]!==a?(P=a("Cancel"),e[37]=a,e[38]=P):P=e[38];let z;e[39]!==t||e[40]!==P?(z=d("button",{className:De,"data-testid":"db-editor-cancel",onClick:t,type:"button",children:P}),e[39]=t,e[40]=P,e[41]=z):z=e[41];let q;e[42]!==M||e[43]!==z?(q=E("div",{className:"flex items-center gap-1.5",children:[M,z]}),e[42]=M,e[43]=z,e[44]=q):q=e[44];let F;return e[45]!==_||e[46]!==$||e[47]!==q?(F=E("div",{className:"flex flex-col gap-2 border border-border bg-card p-3","data-testid":"db-editor",children:[_,$,q]}),e[45]=_,e[46]=$,e[47]=q,e[48]=F):F=e[48],F};function $s(s){return d("option",{value:s,children:s},s)}const Ds=s=>{const e=B(71),{columns:n,editable:o,filter:t,filters:c,hasMaskedColumns:l,hasPredicate:r,liveError:a,maskOn:i,onAddRow:m,onBulkDelete:u,onBulkPatch:p,onAskAiFilter:b,onClearTable:f,onFilterChange:g,onFiltersChange:h,onGenerateRows:x,onShowJson:v,onShowTable:y,onToggleMask:C,total:N,totalKnown:k,viewMode:S}=s,w=he(),T=S==="table";let I;e[0]!==y||e[1]!==T?(I=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]=I):I=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 O=`size-1.5 rounded-full ${a===void 0?"bg-success":"bg-muted-foreground/50"}`;let M;e[9]!==O?(M=d("span",{"aria-hidden":"true",className:O}),e[9]=O,e[10]=M):M=e[10];let P;e[11]!==a||e[12]!==w?(P=w(a===void 0?"Live":"Live unavailable"),e[11]=a,e[12]=w,e[13]=P):P=e[13];let z;e[14]!==$||e[15]!==M||e[16]!==P?(z=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:[M,P]}),e[14]=$,e[15]=M,e[16]=P,e[17]=z):z=e[17];let q;e[18]!==l||e[19]!==i||e[20]!==C||e[21]!==w?(q=l&&d("button",{"aria-pressed":i,className:De,"data-testid":"db-mask-toggle",onClick:C,type:"button",children:w("Mask sensitive columns")}),e[18]=l,e[19]=i,e[20]=C,e[21]=w,e[22]=q):q=e[22];let F;e[23]!==o||e[24]!==m?(F=o&&d("button",{className:De,"data-testid":"db-add-row",onClick:m,type:"button",children:"Add row"}),e[23]=o,e[24]=m,e[25]=F):F=e[25];let V;e[26]!==o||e[27]!==x||e[28]!==w?(V=o&&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]=V):V=e[29];let J;e[30]!==o||e[31]!==r||e[32]!==u||e[33]!==w||e[34]!==N||e[35]!==k?(J=o&&N>0&&r&&d(Lt,{confirmLabel:k?w("Delete {total} matching rows and everything that cascades?",{total:N.toString()}):w("Delete all matching rows and everything that cascades?"),onConfirm:u,testId:"db-bulk-delete",children:k?w("Delete {total} matching",{total:N.toString()}):w("Delete matching")}),e[30]=o,e[31]=r,e[32]=u,e[33]=w,e[34]=N,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]!==N||e[42]!==k?(K=o&&k&&N>0&&r&&d("button",{className:De,"data-testid":"db-bulk-patch",onClick:p,type:"button",children:w("Set column on {total} matching",{total:N.toString()})}),e[37]=o,e[38]=r,e[39]=p,e[40]=w,e[41]=N,e[42]=k,e[43]=K):K=e[43];let Z;e[44]!==o||e[45]!==r||e[46]!==f||e[47]!==w||e[48]!==N||e[49]!==k?(Z=o&&N>0&&!r&&d(Lt,{confirmLabel:k?w("Clear all {total} rows and everything that cascades?",{total:N.toString()}):w("Clear every row and everything that cascades?"),onConfirm:f,testId:"db-clear-table",children:k?w("Clear table ({total})",{total:N.toString()}):w("Clear table")}),e[44]=o,e[45]=r,e[46]=f,e[47]=w,e[48]=N,e[49]=k,e[50]=Z):Z=e[50];let Y;e[51]!==q||e[52]!==F||e[53]!==V||e[54]!==J||e[55]!==K||e[56]!==Z||e[57]!==I||e[58]!==_||e[59]!==z?(Y=E("div",{className:"flex flex-wrap items-center gap-1.5",children:[I,_,z,q,F,V,J,K,Z]}),e[51]=q,e[52]=F,e[53]=V,e[54]=J,e[55]=K,e[56]=Z,e[57]=I,e[58]=_,e[59]=z,e[60]=Y):Y=e[60];let Q;e[61]!==n||e[62]!==t||e[63]!==c||e[64]!==b||e[65]!==g||e[66]!==h?(Q=d(go,{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 ne;return e[68]!==Y||e[69]!==Q?(ne=E("div",{className:"flex flex-col gap-2","data-testid":"db-view-toggle",children:[Y,Q]}),e[68]=Y,e[69]=Q,e[70]=ne):ne=e[70],ne},As=s=>{const e=B(110),{assistant:n,backRelations:o,browser:t,columnMeta:c,edit:l,editable:r,onAskAiFilter:a,onInspect:i,onOpenBulkPatch:m,onOpenGenerateRows:u,onRowDelete:p,onSaveQuery:b,page:f,preferences:g,queryBar:h,references:x}=s,v=g.maskColumns.size>0,y=n.unavailable?void 0:a;let C;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]!==m||e[17]!==u||e[18]!==g.maskOn||e[19]!==g.onToggleMask||e[20]!==v||e[21]!==y?(C=d(Ds,{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:m,onClearTable:t.clearTable,onFilterChange:t.onFilterChange,onFiltersChange:t.onFiltersChange,onGenerateRows:u,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]=m,e[17]=u,e[18]=g.maskOn,e[19]=g.onToggleMask,e[20]=v,e[21]=y,e[22]=C):C=e[22];let N;e[23]!==b||e[24]!==h?(N=h!==void 0&&d(xs,{onApply:h.onApplyQuery,onCopyLink:h.onCopyLink,onDelete:h.onDeleteQuery,onSave:b,saved:h.saved}),e[23]=b,e[24]=h,e[25]=N):N=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]!==f||e[33]!==g.maskView||e[34]!==g.onToggleTranspose||e[35]!==g.transposed?(k=t.viewMode==="table"&&f.rows.length>0&&d(po,{backRelations:o.available,columns:f.columns,editable:r,enabledBackRelations:o.enabled,name:t.selectedTable??"export",onBulkDelete:t.onBulkDeleteSelected,onToggleBackRelation:o.onToggle,onToggleTranspose:g.onToggleTranspose,rows:vt(f.rows,g.maskView),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]=f,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]!==f?(S=r&&t.editing!==null&&d(Rs,{columnMeta:c,documentText:t.editing.docText,onCancel:t.cancelEdit,onDocumentTextChange:t.setEditorDocumentText,onSave:t.saveEdit,refs:f.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]=f,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(Fo,{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 I;e[53]!==t.writeNotice?(I=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]=I):I=e[54];let R;e[55]!==C||e[56]!==N||e[57]!==k||e[58]!==S||e[59]!==w||e[60]!==T||e[61]!==I?(R=E("div",{className:"flex shrink-0 flex-col gap-2 border-b border-border px-4 py-3",children:[C,N,k,S,w,T,I]}),e[55]=C,e[56]=N,e[57]=k,e[58]=S,e[59]=w,e[60]=T,e[61]=I,e[62]=R):R=e[62];let _;e[63]!==t.viewMode||e[64]!==f?(_=t.viewMode==="table"&&f.rows.length===0&&d("div",{className:"flex flex-1 items-center justify-center p-6",children:d(Hn,{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]=f,e[65]=_):_=e[65];let $;e[66]!==t.viewMode||e[67]!==f||e[68]!==g.maskView||e[69]!==g.transposed?($=t.viewMode==="table"&&f.rows.length>0&&g.transposed&&d(mo,{columns:f.columns,rows:vt(f.rows,g.maskView)}),e[66]=t.viewMode,e[67]=f,e[68]=g.maskView,e[69]=g.transposed,e[70]=$):$=e[70];let O;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]!==f||e[82]!==g.maskView||e[83]!==g.onTogglePin||e[84]!==g.pinnedColumns||e[85]!==g.transposed||e[86]!==x?(O=t.viewMode==="table"&&f.rows.length>0&&!g.transposed&&d(cs,{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]=f,e[82]=g.maskView,e[83]=g.onTogglePin,e[84]=g.pinnedColumns,e[85]=g.transposed,e[86]=x,e[87]=O):O=e[87];let M;e[88]!==t.viewMode||e[89]!==f||e[90]!==g.maskView?(M=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(vt(f.rows,g.maskView),Yt,2)}),e[88]=t.viewMode,e[89]=f,e[90]=g.maskView,e[91]=M):M=e[91];let P;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?(P=d("div",{className:"flex shrink-0 items-center border-t border-border px-4 py-2",children:d(Bn,{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]=P):P=e[102];let z;return e[103]!==R||e[104]!==_||e[105]!==$||e[106]!==O||e[107]!==M||e[108]!==P?(z=E("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"db-page",children:[R,_,$,O,M,P]}),e[103]=R,e[104]=_,e[105]=$,e[106]=O,e[107]=M,e[108]=P,e[109]=z):z=e[109],z},Is="/__lunora/seed",St=200,Ps=50,Os=(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},Fs=s=>Array.isArray(s)&&s.every(e=>Zt(e)),Ms=async s=>{let e;try{e=await fetch(Is,{body:JSON.stringify(s),headers:{"Content-Type":"application/json"},method:"POST"})}catch(o){return{kind:"error",message:`seed request failed: ${Ft(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=Rt(n.rows)}catch(t){return{kind:"error",message:`seed response could not be decoded: ${Ft(t)}`}}return Fs(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)})`}},Ls="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",Vs="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",Bs=({columns:s,fkPools:e,onClose:n,onInsertRows:o,table:t})=>{const c=he(),[l,r]=D(10),[a,i]=D(!1),[m,u]=D(void 0),[p,b]=D(void 0),[f,g]=D(0),h=N=>{const k=Number(N.target.value);!Number.isNaN(k)&&k>=1&&r(Math.min(k,St))},x=async()=>{u(void 0),b(void 0),g(0),i(!0);try{const N=await Ms({count:l,existingIds:e,seed:Date.now(),table:t});if(N.kind==="error"){u(N.message);return}const{rows:k}=N;if(k.length===0){u(c("No rows generated — all columns were skipped."));return}const S=await o(k);if(S.error!==void 0){u(S.error);return}b(S.inserted),g(S.conflicts)}finally{i(!1)}},v=()=>{Ce(x())},y=s.filter(N=>N.pk!==!0),C=Os(s,e);return E(ut,{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:St,min:1,onChange:h,type:"number",value:l}),d("span",{className:"text-xs text-muted-foreground",children:c("(max {max})",{max:St.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(N=>{const k=N.ref!==void 0&&N.type==="id",S=k&&(e[N.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-${N.name}`:`gen-rows-fk-ok-${N.name}`,I=S?c("FK: no rows in {ref} — seed it first",{ref:N.ref??""}):c("→ {ref}",{ref:N.ref??""});return E("li",{className:"flex items-center gap-1.5 font-mono text-xs",children:[d("span",{className:"text-foreground",children:N.name}),E("span",{className:"text-muted-foreground",children:["(",N.type,")"]}),N.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:I})]},N.name)})})]}),C.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:C.join(", ")})}),m!==void 0&&d("p",{className:"text-xs text-destructive","data-testid":"gen-rows-error",role:"alert",children:m}),p!==void 0&&m===void 0&&d("p",{className:"text-xs text-success","data-testid":"gen-rows-success",children:f>0?c("Inserted {inserted} of {total} rows — {conflicts} skipped as id conflicts.",{conflicts:f.toString(),inserted:p.toString(),total:(p+f).toString()}):c("Inserted {count} rows successfully.",{count:p.toString()})}),E("div",{className:"flex justify-end gap-2",children:[d("button",{className:Ls,"data-testid":"gen-rows-cancel",onClick:n,type:"button",children:c("Cancel")}),d("button",{className:Vs,"data-testid":"gen-rows-generate",disabled:a||C.length>0,onClick:v,type:"button",children:c(a?"Inserting…":"Generate & insert")})]})]})},js=Te(pe.backRelationCounts),zs=(s,e,n,o)=>{const t=B(16),c=dt();let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l={},t[0]=l):l=t[0];const[r,a]=D(l);let i;if(t[1]!==s||t[2]!==e){let x;t[4]!==s?(x=v=>s.has(Dt(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 m=i;let u;t[6]!==n||t[7]!==m?(u=JSON.stringify([m,n]),t[6]=n,t[7]=m,t[8]=u):u=t[8];const p=u;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 C=await c.query(js,{ids:y,relations:v},ke(o));x.cancelled||a(Object.fromEntries(C.relations.map(qs)))}catch{}},t[9]=c,t[10]=o,t[11]=p,t[12]=b):b=t[12];const f=b;let g,h;return t[13]!==f?(g=()=>{const x={cancelled:!1};return Ce(f(x)),()=>{x.cancelled=!0}},h=[f],t[13]=f,t[14]=g,t[15]=h):(g=t[14],h=t[15]),Be(g,h),r};function qs(s){return[Dt(s),s.counts]}const Ks=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}},at=s=>{const e=s[0];return e===void 0?void 0:{column:e.id,direction:e.desc?"desc":"asc"}},cn=s=>s==null?"":typeof s=="object"?JSON.stringify(s):String(s),Wt=s=>s.map(e=>({column:e.column,...e.value===void 0?{}:{literal:[e.value]},operator:e.operator,value:e.value===void 0?"":cn(e.value)})),Ht=s=>s===void 0?[]:[{desc:s.direction==="desc",id:s.column}],Gs=s=>[s.column,s.operator,s.value],lt=(s,e,n,o)=>JSON.stringify([s??"",e??"",(n??[]).map(t=>Gs(t)),o===void 0?null:[o.column,o.direction]]),It=200,Js=20,Ws=Te(pe.readTablePage),Hs=Te(pe.facetColumn),kt=Te(pe.writeRow),Us=Te(pe.deleteRows),Qs=Te(pe.clearTable),Ys=Te(pe.patchRows),Xs={},Pt=new Set(["__doc__","__id__","_creationTime","_id","id"]),Zs=s=>{const e=s.__doc__;if(typeof e=="string"){const o=Jn(e);if(o!==void 0)return o}const n={};for(const[o,t]of Object.entries(s))Pt.has(o)||(n[o]=t);return n},el=(s,e,n)=>JSON.stringify([s.__lunoraRef,n,en(e)]),tl=({filters:s,offset:e,pageSize:n,search:o,sorting:t,table:c})=>({filters:Fe(s),limit:n,offset:e,orderBy:at(t),search:o,skipCount:!0,table:c}),nl=({filters:s,search:e,table:n})=>({filters:Fe(s),limit:1,search:e,table:n}),ol=(s,e)=>{const n=new Map;for(const t of s?.rows??[]){const c=Ae(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},sl=s=>!Pt.has(s),ll=`Stopped after ${It.toString()} batches — rows still match. Run it again to remove the rest.`,rl=`Stopped after ${It.toString()} batches — rows still match. Run it again to set the rest.`,Ut={resumable:!1,truncated:ll,verb:"deleted"},al={resumable:!0,truncated:rl,verb:"written"},il=({initialFilters:s,initialOrderBy:e,initialSearch:n,initialShardKey:o,onSelectTable:t,onViewChange:c,pageSize:l,resolveBackRelations:r,tableParam:a})=>{const i=dt(),[m,u]=D(l),[p,b]=D(o??""),f=a===void 0||a===""?null:a,[g,h]=D(0),[x,v]=D("table"),[y,C]=D(()=>Ht(e)),[N,k]=D(n??""),[S,w]=D(()=>Wt(s??[])),{clearFacets:T,facets:I,refetchFacets:R,toggleFacet:_}=jn(),[$,O]=D(null),[M,P]=D(null),[z,q]=D(null),F=Ge(null),V=Oo(),[J,K]=D(null),[Z,Y]=D(!1),[Q,ne]=D(a),[oe,de]=D(()=>lt(o,n,s,e)),[ue,me]=D(0),[re,fe]=D(()=>lt(o,n,s,e)),ae=a!==Q,X=lt(o,n,s,e),te=ae||!ae&&X!==oe&&X!==re;if(te){ne(a),de(X),me(j=>j+1),C(Ht(e)),k(n??"");const A=Wt(s??[]);w(A),b(o??""),T(),V.clear(),K(null),h(0),P(null),q(null),F.current=null}else X!==oe&&de(X);const xe=te?n??"":N,ie=te?o??"":p,ce=`${a??""}:${ue.toString()}`,W=Vt(xe.trim(),300,ce),G=Vt(ie.trim(),400,ce),ee=lt(G,W,Fe(S),at(y));ee!==re&&fe(ee);const H=Xe(pe.listTables,Xs,{live:!0,shardKey:G}),ve=H.data??null,ge=H.error,we=tl({filters:S,offset:g,pageSize:m,search:W,sorting:y,table:f??""}),ye=nl({filters:S,search:W,table:f??""}),U=Xe(pe.readTablePage,we,{enabled:f!==null,keepPreviousData:!1,live:!0,shardKey:G}),se=U.data??null,Me=U.error,{liveError:Ie}=U,Pe=Xe(pe.readTablePage,ye,{enabled:f!==null,live:!0,shardKey:G});Be(()=>{H.data!==void 0&&ho(G)},[H.data,G]);const We=A=>{t?.(A)},Se=(A,j)=>{t?.(A,{search:j})},ze=async(A,j)=>{try{return(await i.query(Ws,{filters:[],limit:Js,offset:0,search:j,table:A},ke(G))).rows.find(_e=>Ae(_e)===j)??null}catch{return null}},Le=(A,j,Ne,_e)=>$e=>i.query(Hs,{column:$e,filters:Fe(Ne),search:_e,table:j},ke(A)),He=A=>{_(A,f===null?null:Le(G,f,S,W))},ft=(A,j)=>{const Ne={column:A,literal:[j],operator:"eq",value:cn(j)};w(_e=>[..._e.filter($e=>$e.column!==A),Ne]),h(0)},mt=wt(Le),et=wt(R),tt=wt(c);Be(()=>{f!==null&&et.current(mt.current(G,f,S,W))},[G,f,S,W]),Be(()=>{f===null||tt.current===void 0||Q!==a||oe!==X||tt.current({filters:Fe(S),orderBy:at(y),search:W,shard:G})},[f,a,Q,oe,X,S,y,W,G]);const Ue=A=>{f!==null&&h(Math.max(0,A))},nt=(A,j)=>{K({column:j,rowId:A})},gt=()=>{K(null)},pt=async()=>{if(f!==null){P(null),Y(!0);try{for(const[A,j]of Object.entries(V.staged))await i.query(kt,{doc:j,id:A,op:"patch",table:f},ke(G)),V.drop(A,j)}catch(A){P(A.message)}K(null),U.refetch(),Y(!1)}},bt=()=>{V.clear(),K(null)},ht=ol(se,V.staged),ot=async(A,j,Ne)=>{if(f===null)return;P(null);let _e;if(A!=="delete"){let $e;try{$e=Ne===void 0||Ne.trim()===""?{}:JSON.parse(Ne)}catch(Ve){P(`Invalid JSON: ${Ve.message}`);return}try{const Ve=Rt($e);if(!Zt(Ve)){P("The document must be a JSON object.");return}_e=Ve}catch(Ve){P(`Invalid document: ${Ve.message}`);return}}try{await i.query(kt,{doc:_e,id:j??void 0,op:A,table:f},ke(G)),O(null),U.refetch()}catch($e){P($e.message)}},Qe=async(A,j,Ne)=>{if(f===null)return 0;P(null),q(null);const _e=el(A,j,G),$e=F.current?.key===_e?F.current.after:void 0,Ve=Ne.resumable?$e??"":void 0;let qe=0;try{const Ye=await Ks({args:j,maxBatches:It,openCursor:Ve,query:async Fn=>{const Ot=await i.query(A,Fn,ke(G));return qe+=Ot.count,Ot}});return F.current=Ye.cursor===void 0?null:{after:Ye.cursor,key:_e},Ye.outcome==="cap-hit"&&P(Ne.truncated),q(`${qe.toString()} ${qe===1?"row":"rows"} ${Ne.verb}.`),qe}catch(Ye){return P(`${Ye.message} (at least ${qe.toString()} rows were already ${Ne.verb})`),F.current=null,qe}finally{h(0),U.refetch()}},xt=A=>{C(A),h(0)},L=Tt(()=>f===null?[]:r?.(f)??[],[r,f]),le=ds(se,y,xt,L),Ee={filters:Fe(S),orderBy:at(y),search:W,shard:p,table:f??void 0},Re=Pe.data?.total,Oe=Re!==void 0,st=Re??(se===null?0:g+se.rows.length),dn=g>0,un=W!==""||Fe(S).length>0,fn=se!==null&&(Oe?g+se.rows.length<st:se.rows.length===m),mn=se===null||se.rows.length===0?0:g+1,gn=se===null?0:g+se.rows.length,pn=()=>{H.refetch()},bn=()=>{v("table")},hn=()=>{v("json")},xn=()=>{Ce(Qe(Us,{filters:Fe(S),search:W,table:f},Ut))},vn=()=>{Ce(Qe(Qs,{table:f},Ut))},wn=A=>{Ce(Qe(Ys,{doc:A,filters:Fe(S),search:W,table:f},al))},yn=A=>{k(A.target.value),h(0)},Cn=A=>{w(A),h(0)},Nn=()=>{P(null);const A={};for(const j of se?.columns??[])Pt.has(j)||(A[j]="");O({docText:JSON.stringify(A,null,2),id:""})},Sn=A=>{O(j=>j===null?j:{docText:A,id:j.id})},kn=()=>{$!==null&&Ce(ot($.id===""?"insert":"patch",$.id===""?null:$.id,$.docText))},Tn=()=>{O(null),P(null)},En=()=>{Ue(g-m)},_n=()=>{Ue(g+m)},Rn=A=>{Ue(Math.max(0,(A-1)*m))},$n=A=>{u(A),h(0)},Dn=(A,j)=>{P(null),O({docText:JSON.stringify(en(Zs(j)),null,2),id:A})},An=A=>{Ce(ot("delete",A))},In=async A=>{if(!(f===null||A.length===0)){P(null);try{for(const j of A)await i.query(kt,{id:j,op:"delete",table:f},ke(G));U.refetch()}catch(j){P(j.message)}}},Pn=A=>{Ce(In(A))},On=()=>{Ce(pt())};return{addRow:Nn,bulkDelete:xn,bulkPatch:wn,cancelCellEdit:gt,cancelEdit:Tn,changePageSize:$n,clearTable:vn,columns:se?.columns??[],committing:Z,currentView:Ee,discardStaged:bt,editableColumn:sl,editing:$,editingCell:J,facetFilter:ft,facets:I,filter:N,filters:S,goNext:_n,goPrevious:En,hasNext:fn,hasPredicate:un,hasPrevious:dn,jumpToPage:Rn,liveError:Ie,loadTables:pn,navigateToRef:Se,onBulkDeleteSelected:Pn,onCommitStaged:On,onFilterChange:yn,onFiltersChange:Cn,onRowDelete:An,onRowEdit:Dn,page:se,previewRef:ze,pageError:Me,pageSize:m,rangeEnd:gn,rangeStart:mn,queryShardKey:G,saveEdit:kn,selectedTable:f,selectTable:We,setEditorDocumentText:Sn,setShardKey:b,shardKey:p,showJson:hn,showTable:bn,stage:V.stage,stagedChanges:ht,stagedValue:V.stagedValue,startCellEdit:nt,table:le,tables:ve,tablesError:ge,toggleFacet:He,total:st,totalKnown:Oe,viewMode:x,writeError:M,writeNotice:z}},cl="lunora-studio-pinned-columns",dl=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]=Qt(cl,c),a=t??"",i=l[a];let m;e[1]!==o||e[2]!==i?(m=i===void 0?new Set((o??"").split(",").filter(ul)):new Set(i),e[1]=o,e[2]=i,e[3]=m):m=e[3];const u=m;let p;e[4]!==a||e[5]!==u||e[6]!==r?(p=T=>{r(I=>{const R=I[a]??[...u],_=R.includes(T)?R.filter($=>$!==T):[...R,T];return{...I,[a]:_}})},e[4]=a,e[5]=u,e[6]=r,e[7]=p):p=e[7];const b=p,[f,g]=D(!1);let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{g(fl)},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:C,maskView:N,maskViewFor:k,onToggleMask:S}=zn(v);let w;return e[12]!==y||e[13]!==C||e[14]!==N||e[15]!==k||e[16]!==S||e[17]!==b||e[18]!==u||e[19]!==f?(w={maskColumns:y,maskOn:C,maskView:N,maskViewFor:k,onToggleMask:S,onTogglePin:b,onToggleTranspose:x,pinnedColumns:u,transposed:f},e[12]=y,e[13]=C,e[14]=N,e[15]=k,e[16]=S,e[17]=b,e[18]=u,e[19]=f,e[20]=w):w=e[20],w};function ul(s){return s!==""}function fl(s){return!s}const ml=Te(pe.describeTable),gl=Te(pe.readTablePage),pl=Te(pe.importShard),bl=s=>{const e=s._id??s.id??s.__id__??"";return typeof e=="string"?e:typeof e=="number"?String(e):""},hl=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}},xl=s=>{const e=dt(),[n,o]=D(!1),[t,c]=D(void 0),[l,r]=D(void 0),[a,i]=D(void 0),[m,u]=D({}),[p,b]=D(!1),[f,g]=D(void 0),h=async(C,N)=>{o(!0),c(C),r(N),i(void 0),u({}),g(void 0),b(!0);try{const k=await e.query(ml,{table:C},ke(N)),{columns:S}=k;i(S);const w={},T=S.filter(I=>I.ref!==void 0&&I.type==="id"&&I.pk!==!0);for(const I of T){if(I.ref===void 0)continue;const{ref:R}=I;if(w[R]===void 0)try{const _=await e.query(gl,{filters:[],limit:Ps,offset:0,search:"",table:R},ke(N));w[R]=_.rows.flatMap($=>bl($)||[])}catch{w[R]=[]}}u(w)}catch(k){g(k.message)}b(!1)};return{closeDialog:()=>{o(!1),c(void 0),r(void 0),i(void 0),u({}),g(void 0)},columnMeta:a,error:f,fkPools:m,insertBatch:async(C,N)=>{if(t===void 0||l===void 0)return{conflicts:0,error:"No table selected.",inserted:0};try{const k=await e.query(pl,{rows:C.map(w=>({doc:w,table:t}))},ke(l)),S=hl(k);return S.error!==void 0||(N(),s()),S}catch(k){return{conflicts:0,error:k.message,inserted:0}}},loading:p,open:n,openDialog:(C,N)=>{Ce(h(C,N))},shardKey:l,table:t}},vl=()=>{const s=B(6),[e,n]=D(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]=D(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 m=i;let u;return s[3]!==c||s[4]!==e?(u={closeExpandedCell:m,closeInspect:t,expandedCell:c,inspecting:e,onExpandCell:a,onInspect:n},s[3]=c,s[4]=e,s[5]=u):u=s[5],u},wl=/(?:_creationtime|(?:^|[a-z])(?:time|at))$/iu,yl=(s,e)=>typeof e=="number"&&wl.test(s),Cl=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 u;return e[4]===Symbol.for("react.memo_cache_sentinel")?(u=d("span",{className:"italic text-muted-foreground",children:"null"}),e[4]=u):u=e[4],u}if(o){const u=`rd-masked-${n}`;let p;e[5]!==l?(p=je(l),e[5]=l,e[6]=p):p=e[6];let b;return e[7]!==u||e[8]!==p?(b=d("span",{className:"italic text-muted-foreground","data-testid":u,title:"Masked (preview)",children:p}),e[7]=u,e[8]=p,e[9]=b):b=e[9],b}if(c!==void 0&&(typeof l=="string"||typeof l=="number")&&String(l)!==""){const u=`rd-ref-${n}`,p=`Open ${c} ${String(l)}`,b=String(l);let f;return e[10]!==a||e[11]!==u||e[12]!==p||e[13]!==b?(f=E("button",{"data-testid":u,onClick:a,title:p,type:"button",children:[b," ↗"]}),e[10]=a,e[11]=u,e[12]=p,e[13]=b,e[14]=f):f=e[14],f}if(yl(n,l)){const u=`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=Ln(l),e[17]=l,e[18]=b):b=e[18];let f;return e[19]!==u||e[20]!==p||e[21]!==b?(f=d("span",{"data-testid":u,title:p,children:b}),e[19]=u,e[20]=p,e[21]=b,e[22]=f):f=e[22],f}if(l instanceof ArrayBuffer||ArrayBuffer.isView(l)){const u=`rd-bytes-${n}`;let p;e[23]!==l?(p=je(l),e[23]=l,e[24]=p):p=e[24];let b;return e[25]!==u||e[26]!==p?(b=d("span",{"data-testid":u,children:p}),e[25]=u,e[26]=p,e[27]=b):b=e[27],b}if(typeof l=="object"){let u;e[28]!==l?(u=JSON.stringify(l,Yt,2),e[28]=l,e[29]=u):u=e[29];let p;return e[30]!==u?(p=d("pre",{className:"m-0 overflow-auto rounded-md bg-muted/50 p-2 text-xs",children:u}),e[30]=u,e[31]=p):p=e[31],p}let i;e[32]!==l?(i=je(l),e[32]=l,e[33]=i):i=e[33];let m;return e[34]!==i?(m=d("span",{children:i}),e[34]=i,e[35]=m):m=e[35],m},Nl=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 m;e[3]===Symbol.for("react.memo_cache_sentinel")?(m=d("h3",{className:"m-0 text-base text-foreground",children:"Row detail"}),e[3]=m):m=e[3];let u;e[4]!==t?(u=E("div",{className:"mb-3 flex items-center justify-between",children:[m,d("button",{"data-testid":"rd-close",onClick:t,type:"button",children:"Close"})]}),e[4]=t,e[5]=u):u=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(Cl,{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 f;return e[19]!==t||e[20]!==u||e[21]!==b?(f=E(ut,{label:"Row detail",onClose:t,panelTestId:"rd-panel",testId:"rd-overlay",variant:"drawer",children:[u,b]}),e[19]=t,e[20]=u,e[21]=b,e[22]=f):f=e[22],f},Sl=50,kl=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},Tl=({onFetchTables:s,onSelect:e})=>{const n=he(),[o]=D(()=>xo()),[t,c]=D(!1),[l,r]=D(void 0),[a,i]=D(void 0),[m,u]=D(!1),[p,b]=D(void 0),f=Ge(0),g=()=>{c(v=>!v)},h=async v=>{e(v),r(v),i(void 0),b(void 0),u(!0),f.current+=1;const y=f.current;try{const C=await s(v);f.current===y&&i(C?.slice(0,Sl))}catch(C){f.current===y&&b(C.message)}f.current===y&&u(!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(kl,{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})}),m&&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}),!m&&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.")}),!m&&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))})]})]})]})},El="lunora-studio-back-relations",_l=s=>new Set((s??[]).filter(e=>e.unique===!0&&e.fields.length===1).map(e=>e.fields[0]??"")),Rl={},$l=50,Dl=[],Al=Te(pe.listTables),Il=Te(pe.readTablePage),Pl=s=>{const e=B(10),{onFetchShardTables:n,onShardChange:o,schemaSwitch:t,shardKey:c}=s;let l;e[0]!==o||e[1]!==c?(l=d(Mn,{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(Tl,{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},ur=({editable:s=!1,globalTableNames:e,initialFilters:n,initialOrderBy:o,initialPins:t,initialSearch:c,initialShardKey:l,onNavigateToGlobal:r,onSelectTable:a,onViewChange:i,pageSize:m=$l,queryBar:u,schemaSwitch:p,tableParam:b})=>{const f=Xe(pe.describeTables,{},{shardKey:l??""}),g=Xe(pe.listTablesIndexes,{},{shardKey:l??""}),h=f.data?.columnsByTable??Rl,[x,v]=Qt(El,{}),y=it(L=>{const le=new Set(x[L]);return Bt(L,h).filter(Ee=>le.has(Dt(Ee)))},[x,h]),C=il({initialFilters:n,initialOrderBy:o,initialSearch:c,initialShardKey:l,onSelectTable:a,onViewChange:i,pageSize:m,resolveBackRelations:y,tableParam:b}),{cancelCellEdit:N,columns:k,currentView:S,editableColumn:w,editingCell:T,facetFilter:I,facets:R,loadTables:_,navigateToRef:$,onFiltersChange:O,page:M,pageError:P,previewRef:z,queryShardKey:q,selectedTable:F,selectTable:V,setShardKey:J,shardKey:K,stage:Z,stagedValue:Y,startCellEdit:Q,tables:ne,tablesError:oe,toggleFacet:de}=C,ue=Gn(K),me=L=>{Ce((async()=>{const Ee=await ue.suggestFilter(L,F??"");Ee!==void 0&&O(Ee.map(Re=>{const Oe=Re.value,st=typeof Oe=="string"||typeof Oe=="number"||typeof Oe=="boolean"?String(Oe):"";return{column:Re.column,operator:Re.operator,value:st}}))})())},re=F===null?[]:Bt(F,h),fe=new Set(x[F??""]),ae=[];for(const L of M?.rows??[]){const le=L._id??L.id;typeof le=="string"&&le!==""&&ae.push(le)}const X=zs(fe,re,ae,q),be=L=>{v(le=>{const Ee=F??"",Re=le[Ee]??[];return{...le,[Ee]:Re.includes(L)?Re.filter(Oe=>Oe!==L):[...Re,L]}})},te=dl({columns:k,initialPins:t,selectedTable:F}),xe=vl(),[ie,ce]=D(null),{closeExpandedCell:W,closeInspect:G,expandedCell:ee,inspecting:H,onExpandCell:ve}=xe,ge=dt(),we=Object.fromEntries((h[F??""]??[]).map(L=>[L.name,L])),ye=new Map;for(const L of h[F??""]??[])L.isStorage===!0&&ye.set(L.name,L.bucket);const U=it(async(L,le)=>ge.signedStorageUrl(L,le===void 0?{}:{bucket:le}),[ge]),se=async L=>await ge.query(Al,{},ke(L)),Me=()=>{F!==null&&V(F)},{closeDialog:Ie,columnMeta:Pe,fkPools:We,insertBatch:Se,open:ze,openDialog:Le}=xl(Me),He=()=>{F!==null&&Le(F,K)},ft=L=>Se(L,Ie),[mt,et]=D(!1),tt=()=>{et(!0)},Ue=()=>{et(!1)},nt=(L,le)=>{if(r!==void 0&&e?.has(L)===!0){r(L,le);return}$(L,le)},gt=u?.onSaveQuery,pt=L=>{gt?.(L,S)},bt={cancelEdit:N,editable:s,editableColumn:w,editingCell:T,onExpandCell:ve,stage:Z,stagedValue:Y,startEdit:Q},ht=L=>{L!==null&&ce(L)},ot=()=>{C.onRowDelete(ie)},Qe=async(L,le,Ee)=>await ge.query(Il,{filters:[{column:le,operator:"eq",value:Ee}],limit:rt,offset:0,orderBy:[],table:L},ke(q)),xt={columns:M?.refs,maskViewFor:te.maskViewFor,onNavigate:nt,onPreview:z};return E("div",{className:"flex h-full min-w-0","data-testid":"lunora-data-browser",children:[d(qn,{header:d(Pl,{onFetchShardTables:se,onShardChange:J,schemaSwitch:p,shardKey:K}),onReload:_,onSelect:V,prefix:"db",selected:F,tables:ne??Dl}),E("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[oe!==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:oe}),M===null&&P===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."})}),P!==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:P}),M!==null&&d(As,{assistant:ue,backRelations:{available:re,counts:X,enabled:fe,onToggle:be},browser:C,columnMeta:we,edit:bt,editable:s,onAskAiFilter:me,onInspect:xe.onInspect,onOpenBulkPatch:tt,onOpenGenerateRows:He,onRowDelete:ht,onSaveQuery:pt,page:M,preferences:te,queryBar:u,references:xt})]}),M!==null&&d(Kn,{columns:k,facets:R,mask:te.maskView,onFacetFilter:I,onToggleFacet:de}),H!==null&&M!==null&&d(Nl,{columns:M.columns,mask:te.maskView,onClose:G,onNavigate:nt,refs:M.refs,row:Xt(H,te.maskView)}),ie!==null&&F!==null&&d(Do,{onClose:()=>{ce(null)},onConfirm:ot,readPage:Qe,rowId:ie,schema:vo(h),table:F}),ee!==null&&d(bo,{bucket:ye.get(ee.column),column:ee.column,onClose:W,resolveUrl:ye.has(ee.column)?U:void 0,value:ee.value}),mt&&F!==null&&d(Co,{columns:C.columns.filter(L=>C.editableColumn(L)),onApply:C.bulkPatch,onClose:Ue,shardKey:C.queryShardKey,table:F,total:C.total,uniqueColumns:_l(g.data?.indexesByTable[F])}),ze&&F!==null&&Pe!==void 0&&d(Bs,{columns:Pe,fkPools:We,onClose:Ie,onInsertRows:ft,table:F})]})};export{ur as DataBrowser};
@@ -0,0 +1 @@
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};
@@ -0,0 +1,6 @@
1
+ import{c as R}from"react/compiler-runtime";import{useState as M,useEffect as Q}from"react";import{ConfirmButton as H}from"./ConfirmButton-DU4p72Er.mjs";import{D as G,a as v,b as D,c as J,d as K,e as U,f as O,g as B}from"./dropdown-menu-jLZenfWH.mjs";import{M as P}from"./modal-shell-CDztwLnv.mjs";import{useT as _}from"./DEFAULT_LOCALE-A1Yg5ORA.mjs";import{i as I,g as W,j as Y,f as z}from"./internal-B6haJbiP.mjs";import{C as L}from"./control-button-BOZ5K-FC.mjs";import{jsx as d,jsxs as T}from"react/jsx-runtime";const V=l=>`"${l.replaceAll('"','""')}"`,X=/["\n,]/u,Z=/^[=+\-@\t\r]/u,q=l=>{if(l==null)return"";let e;return typeof l=="string"?e=Z.test(l)?` ${l}`:l:typeof l=="number"||typeof l=="boolean"||typeof l=="bigint"?e=String(l):e=I(l),X.test(e)?`"${e.replaceAll('"','""')}"`:e},ee=(l,e)=>{const o=l.map(t=>q(t)).join(","),s=e.map(t=>l.map(n=>q(t[n])).join(","));return[o,...s].join(`
2
+ `)},te=l=>JSON.stringify(l,Y,2),F=500,le=l=>l==null?"NULL":typeof l=="number"?Number.isFinite(l)?String(l):"NULL":typeof l=="bigint"?String(l):typeof l=="boolean"?l?"1":"0":`'${(typeof l=="string"?l:I(l)).replaceAll("'","''")}'`,oe=(l,e,o)=>{if(e.length===0||o.length===0)return"";const s=e.map(n=>V(n)).join(", "),t=[];for(let n=0;n<o.length;n+=F){const r=o.slice(n,n+F).map(i=>` (${e.map(a=>le(i[a])).join(", ")})`).join(`,
3
+ `);t.push(`INSERT INTO ${V(l)} (${s}) VALUES
4
+ ${r};`)}return t.join(`
5
+
6
+ `)},A=(l,e,o)=>{if(!("document"in globalThis))return;const s=globalThis.URL.createObjectURL(new globalThis.Blob([e],{type:o})),t=globalThis.document.createElement("a");t.href=s,t.download=l,globalThis.document.body.append(t),t.click(),t.remove(),globalThis.URL.revokeObjectURL(s)},ne=l=>{const e=R(36),{columns:o,name:s,rows:t}=l,n=_();let r;e[0]!==o||e[1]!==s||e[2]!==t?(r=()=>{A(`${s}.csv`,ee(o,t),"text/csv;charset=utf-8")},e[0]=o,e[1]=s,e[2]=t,e[3]=r):r=e[3];const i=r;let a;e[4]!==s||e[5]!==t?(a=()=>{A(`${s}.json`,te(t),"application/json")},e[4]=s,e[5]=t,e[6]=a):a=e[6];const u=a;let f;e[7]!==o||e[8]!==s||e[9]!==t?(f=()=>{A(`${s}.sql`,oe(s,o,t),"application/sql;charset=utf-8")},e[7]=o,e[8]=s,e[9]=t,e[10]=f):f=e[10];const c=f,C=t.length===0;let p;e[11]!==C?(p=d(G,{className:L,"data-testid":"grid-export",disabled:C,title:"Exports only the rows loaded on the current page, not the whole table",children:"Export page"}),e[11]=C,e[12]=p):p=e[12];let g;e[13]===Symbol.for("react.memo_cache_sentinel")?(g=d(v,{children:"Export loaded rows"}),e[13]=g):g=e[13];let m;e[14]!==n?(m=n("CSV"),e[14]=n,e[15]=m):m=e[15];let y;e[16]!==i||e[17]!==m?(y=d(D,{"data-testid":"grid-export-csv",onClick:i,children:m}),e[16]=i,e[17]=m,e[18]=y):y=e[18];let N;e[19]!==n?(N=n("JSON"),e[19]=n,e[20]=N):N=e[20];let w;e[21]!==u||e[22]!==N?(w=d(D,{"data-testid":"grid-export-json",onClick:u,children:N}),e[21]=u,e[22]=N,e[23]=w):w=e[23];let S;e[24]!==n?(S=n("SQL"),e[24]=n,e[25]=S):S=e[25];let h;e[26]!==c||e[27]!==S?(h=d(D,{"data-testid":"grid-export-sql",onClick:c,children:S}),e[26]=c,e[27]=S,e[28]=h):h=e[28];let b;e[29]!==w||e[30]!==h||e[31]!==y?(b=T(J,{align:"end",children:[g,y,w,h]}),e[29]=w,e[30]=h,e[31]=y,e[32]=b):b=e[32];let x;return e[33]!==b||e[34]!==p?(x=T(K,{children:[p,b]}),e[33]=b,e[34]=p,e[35]=x):x=e[35],x},se=l=>{const e=R(9),{column:o}=l;let s;e[0]!==o?(s=()=>{o.toggleVisibility()},e[0]=o,e[1]=s):s=e[1];const t=s;let n;e[2]!==o?(n=o.getIsVisible(),e[2]=o,e[3]=n):n=e[3];const r=`grid-column-${o.id}`;let i;return e[4]!==o.id||e[5]!==t||e[6]!==n||e[7]!==r?(i=d(O,{checked:n,closeOnClick:!1,"data-testid":r,onCheckedChange:t,children:o.id}),e[4]=o.id,e[5]=t,e[6]=n,e[7]=r,e[8]=i):i=e[8],i},ie=[],re=({backRelations:l=ie,enabledBackRelations:e,onToggleBackRelation:o,table:s})=>{const t=_(),n=s.getIsAllColumnsVisible(),r=()=>{s.toggleAllColumnsVisible(!n)};return T(K,{children:[d(G,{className:L,"data-testid":"grid-columns",children:t("Columns")}),T(J,{align:"end",className:"max-h-80 overflow-y-auto",children:[T(U,{children:[d(v,{children:t("Columns")}),d(O,{checked:n,closeOnClick:!1,"data-testid":"grid-columns-all",onCheckedChange:r,children:t(n?"Hide all":"Show all")}),d(B,{}),s.getAllLeafColumns().filter(i=>!i.id.startsWith("__back__:")).map(i=>d(se,{column:i},i.id))]}),l.length>0&&o!==void 0&&T(U,{children:[d(B,{}),d(v,{children:t("Related")}),l.map(i=>{const a=`${i.table}.${i.column}`;return d(O,{checked:e?.has(a)===!0,closeOnClick:!1,"data-testid":`grid-back-relation-${a}`,onCheckedChange:()=>{o(a)},children:`← ${i.table}.${i.column}`},a)})]})]})]})},ce=l=>{const e=R(19),{count:o,editable:s,onClear:t,onDelete:n}=l,r=_();let i;e[0]!==o||e[1]!==r?(i=r("{count} selected",{count:o}),e[0]=o,e[1]=r,e[2]=i):i=e[2];let a;e[3]!==i?(a=d("span",{className:"font-medium tabular-nums","data-testid":"grid-selection-count",children:i}),e[3]=i,e[4]=a):a=e[4];let u;e[5]!==r?(u=r("Clear"),e[5]=r,e[6]=u):u=e[6];let f;e[7]!==t||e[8]!==u?(f=d("button",{className:L,"data-testid":"grid-selection-clear",onClick:t,type:"button",children:u}),e[7]=t,e[8]=u,e[9]=f):f=e[9];let c;e[10]!==o||e[11]!==s||e[12]!==n||e[13]!==r?(c=s&&d(H,{confirmLabel:r("Delete {count} rows and everything that cascades?",{count:o}),onConfirm:n,testId:"grid-selection-delete",children:r("Delete {count}",{count:o})}),e[10]=o,e[11]=s,e[12]=n,e[13]=r,e[14]=c):c=e[14];let C;return e[15]!==a||e[16]!==f||e[17]!==c?(C=T("div",{className:"flex items-center gap-2 rounded-md border border-border bg-accent/40 px-3 py-1.5 text-xs","data-testid":"grid-selection-bar",children:[a,f,c]}),e[15]=a,e[16]=f,e[17]=c,e[18]=C):C=e[18],C},ae=/\.(?:avif|bmp|gif|ico|jpe?g|png|svg|webp)$/iu,de=l=>{const e=R(9),{bucket:o,objectKey:s,resolveUrl:t}=l,[n,r]=M(null),[i,a]=M(!1);let u,f;e[0]!==o||e[1]!==s||e[2]!==t?(u=()=>{const g={cancelled:!1};return z((async()=>{try{const m=await t(s,o);g.cancelled||r(m)}catch{g.cancelled||a(!0)}})()),()=>{g.cancelled=!0}},f=[o,s,t],e[0]=o,e[1]=s,e[2]=t,e[3]=u,e[4]=f):(u=e[3],f=e[4]),Q(u,f);let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{a(!0)},e[5]=c):c=e[5];const C=c;if(n===null||i)return null;let p;return e[6]!==s||e[7]!==n?(p=d("div",{className:"flex max-h-64 shrink-0 items-center justify-center overflow-hidden rounded-md border border-border bg-muted/30",children:d("img",{alt:s,className:"max-h-64 object-contain","data-testid":"grid-cell-image",onError:C,src:n})}),e[6]=s,e[7]=n,e[8]=p):p=e[8],p},xe=l=>{const e=R(37),{bucket:o,column:s,onClose:t,resolveUrl:n,value:r}=l,i=_(),[a,u]=M(!1);let f;e[0]!==r?(f=I(r),e[0]=r,e[1]=f):f=e[1];const c=f;let C;e[2]!==c?(C=()=>{W(c)&&u(!0)},e[2]=c,e[3]=C):C=e[3];const p=C;let g;e[4]!==i?(g=i("Cell value"),e[4]=i,e[5]=g):g=e[5];let m;e[6]!==s?(m=d("h2",{className:"truncate font-mono text-sm font-semibold text-foreground",children:s}),e[6]=s,e[7]=m):m=e[7];let y;e[8]!==a||e[9]!==i?(y=i(a?"Copied":"Copy"),e[8]=a,e[9]=i,e[10]=y):y=e[10];let N;e[11]!==p||e[12]!==y?(N=d("button",{className:L,"data-testid":"grid-cell-copy",onClick:p,type:"button",children:y}),e[11]=p,e[12]=y,e[13]=N):N=e[13];let w;e[14]!==i?(w=i("Close"),e[14]=i,e[15]=w):w=e[15];let S;e[16]!==t||e[17]!==w?(S=d("button",{className:L,"data-testid":"grid-cell-close",onClick:t,type:"button",children:w}),e[16]=t,e[17]=w,e[18]=S):S=e[18];let h;e[19]!==N||e[20]!==S?(h=T("div",{className:"flex items-center gap-1.5",children:[N,S]}),e[19]=N,e[20]=S,e[21]=h):h=e[21];let b;e[22]!==m||e[23]!==h?(b=T("div",{className:"flex items-center justify-between",children:[m,h]}),e[22]=m,e[23]=h,e[24]=b):b=e[24];let x;e[25]!==o||e[26]!==n||e[27]!==r?(x=n!==void 0&&typeof r=="string"&&ae.test(r)&&d(de,{bucket:o,objectKey:r,resolveUrl:n}),e[25]=o,e[26]=n,e[27]=r,e[28]=x):x=e[28];let k;e[29]!==c?(k=d("pre",{className:"min-h-0 flex-1 overflow-auto rounded-md border border-border bg-muted/30 p-3 font-mono text-xs whitespace-pre-wrap","data-testid":"grid-cell-value",children:c}),e[29]=c,e[30]=k):k=e[30];let $;return e[31]!==t||e[32]!==b||e[33]!==x||e[34]!==k||e[35]!==g?($=T(P,{className:"max-h-[70vh] w-[min(40rem,90vw)]",label:g,onClose:t,panelTestId:"grid-cell-dialog",testId:"grid-cell-dialog-overlay",variant:"dialog",children:[b,x,k]}),e[31]=t,e[32]=b,e[33]=x,e[34]=k,e[35]=g,e[36]=$):$=e[36],$},Ne=l=>{const e=R(36),{backRelations:o,enabledBackRelations:s,onToggleBackRelation:t,columns:n,editable:r,name:i,onBulkDelete:a,onToggleTranspose:u,rows:f,table:c,transposed:C}=l,p=_();let g;e[0]!==c?(g=c.getSelectedRowModel(),e[0]=c,e[1]=g):g=e[1];const m=g.rows;let y;e[2]!==c?(y=()=>{c.resetRowSelection()},e[2]=c,e[3]=y):y=e[3];const N=y;let w;e[4]!==a||e[5]!==m||e[6]!==c?(w=()=>{a(m.map(fe)),c.resetRowSelection()},e[4]=a,e[5]=m,e[6]=c,e[7]=w):w=e[7];const S=w;let h;e[8]!==n||e[9]!==i||e[10]!==f?(h=d(ne,{columns:n,name:i,rows:f}),e[8]=n,e[9]=i,e[10]=f,e[11]=h):h=e[11];let b;e[12]!==o||e[13]!==s||e[14]!==t||e[15]!==c?(b=d(re,{backRelations:o,enabledBackRelations:s,onToggleBackRelation:t,table:c}),e[12]=o,e[13]=s,e[14]=t,e[15]=c,e[16]=b):b=e[16];let x;e[17]!==p?(x=p("Swap rows and columns"),e[17]=p,e[18]=x):x=e[18];let k;e[19]!==p?(k=p("Transpose"),e[19]=p,e[20]=k):k=e[20];let $;e[21]!==u||e[22]!==x||e[23]!==k||e[24]!==C?($=d("button",{"aria-pressed":C,className:L,"data-testid":"grid-transpose",onClick:u,title:x,type:"button",children:k}),e[21]=u,e[22]=x,e[23]=k,e[24]=C,e[25]=$):$=e[25];let j;e[26]!==r||e[27]!==N||e[28]!==S||e[29]!==m.length?(j=m.length>0&&d(ce,{count:m.length,editable:r,onClear:N,onDelete:S}),e[26]=r,e[27]=N,e[28]=S,e[29]=m.length,e[30]=j):j=e[30];let E;return e[31]!==h||e[32]!==b||e[33]!==$||e[34]!==j?(E=T("div",{className:"flex flex-wrap items-center gap-1.5","data-testid":"grid-actions",children:[h,b,$,j]}),e[31]=h,e[32]=b,e[33]=$,e[34]=j,e[35]=E):E=e[35],E};function fe(l){return l.id}export{xe as C,ne as E,Ne as G,ce as S};
@@ -1 +1 @@
1
- import{a as s}from"./chunk-MBP4SZYB.js";import{a as n}from"./chunk-YKXDMIHQ.js";var b="__lunora_admin__:",g=new Set(["action","mutation","query"]),c=Symbol("lunora.operationSeq"),_=n(t=>{if(typeof t!="object"||t===null)return;let e=t[c];return typeof e=="number"?e:void 0},"g"),d=n((t,e)=>{if(!(typeof t!="object"||t===null||!Object.isExtensible(t)))try{Object.defineProperty(t,c,{configurable:!0,enumerable:!1,value:e,writable:!0})}catch{}},"h"),m=n(t=>{if(typeof t!="object"||t===null)return;let e=t.__lunoraRef;return typeof e=="string"&&e.startsWith(b)?e:void 0},"p"),h=n(t=>{if(typeof t!="object"||t===null)return"";let{shardKey:e}=t;return typeof e=="string"?e:""},"O"),w=n(t=>new Proxy(t,{get(e,u,y){let i=Reflect.get(e,u,y);if(typeof i!="function"||typeof u!="string"||!g.has(u))return typeof i=="function"?i.bind(e):i;let f=i;return async(...o)=>{let l=m(o[0]);if(l===void 0)return f.apply(e,o);let p=typeof o[1]=="object"&&o[1]!==null?o[1]:{},a=s.start(l,p,h(o[2]));try{let r=await f.apply(e,o);return s.settle(a,{result:r}),r}catch(r){throw s.settle(a,{error:r instanceof Error?r.message:String(r)}),d(r,a),r}}}}),"E");export{_ as a,w as b};
1
+ import{a as s}from"./chunk-SDHFSBNM.js";import{a as n}from"./chunk-YKXDMIHQ.js";var b="__lunora_admin__:",g=new Set(["action","mutation","query"]),c=Symbol("lunora.operationSeq"),_=n(t=>{if(typeof t!="object"||t===null)return;let e=t[c];return typeof e=="number"?e:void 0},"g"),d=n((t,e)=>{if(!(typeof t!="object"||t===null||!Object.isExtensible(t)))try{Object.defineProperty(t,c,{configurable:!0,enumerable:!1,value:e,writable:!0})}catch{}},"h"),m=n(t=>{if(typeof t!="object"||t===null)return;let e=t.__lunoraRef;return typeof e=="string"&&e.startsWith(b)?e:void 0},"p"),h=n(t=>{if(typeof t!="object"||t===null)return"";let{shardKey:e}=t;return typeof e=="string"?e:""},"O"),w=n(t=>new Proxy(t,{get(e,u,y){let i=Reflect.get(e,u,y);if(typeof i!="function"||typeof u!="string"||!g.has(u))return typeof i=="function"?i.bind(e):i;let f=i;return async(...o)=>{let l=m(o[0]);if(l===void 0)return f.apply(e,o);let p=typeof o[1]=="object"&&o[1]!==null?o[1]:{},a=s.start(l,p,h(o[2]));try{let r=await f.apply(e,o);return s.settle(a,{result:r}),r}catch(r){throw s.settle(a,{error:r instanceof Error?r.message:String(r)}),d(r,a),r}}}}),"E");export{_ as a,w as b};
@@ -1 +1 @@
1
- import{b as de}from"./chunk-UYEZR3BI.js";import{a as te,b as re,c as ne}from"./chunk-Q4CAKBWN.js";import"./chunk-OKG3HWSJ.js";import{b as Y}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as ae}from"./chunk-KZDIKRZ3.js";import"./chunk-ULIQFBZU.js";import"./chunk-2W365SXI.js";import"./chunk-35DM4JJG.js";import{a as ee}from"./chunk-4ZEL6BYL.js";import{c as Z}from"./chunk-MBP4SZYB.js";import"./chunk-Z7WCKAUJ.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as le,b as oe,c as se,d as H,e as z,f as G}from"./chunk-HEAQVSNS.js";import{a as P,e as q}from"./chunk-WUWBZPUK.js";import{d as X}from"./chunk-FODLDLE2.js";import{a as g,d as W,f as ce,g as me}from"./chunk-YKXDMIHQ.js";var J=W(ce(),1);var t=W(me(),1);var ue={binding:"outline",secret:"destructive",var:"secondary"},pe=g((n,e)=>{if(n===void 0)return[];let u=[];return n.workerUrl!==void 0&&u.push({label:e("URL"),value:n.workerUrl}),n.environment!==void 0&&u.push({label:e("Environment"),value:n.environment}),n.deploymentId!==void 0&&u.push({label:e("Deployment"),value:n.deploymentId}),n.versionTag!==void 0&&u.push({label:e("Version"),value:n.versionTag}),u},"ce"),ie=g(n=>{let e=(0,J.c)(18),{modifier:u,name:r,label:p}=n,A=te(),x;e[0]!==r?(x=g(o=>{if(!["Escape","Tab"].includes(o.key)){if(o.shiftKey){o.preventDefault();return}o.preventDefault(),re(r,o.key)}},"b"),e[0]=r,e[1]=x):x=e[1];let i=x,c=`set-shortcut-${r}`,m;e[2]!==p?(m=(0,t.jsx)("dt",{className:"text-muted-foreground",children:p}),e[2]=p,e[3]=m):m=e[3];let h;e[4]!==u?(h=(0,t.jsx)("kbd",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:u}),e[4]=u,e[5]=h):h=e[5];let l=`set-shortcut-input-${r}`,f=A[r],s;e[6]!==p||e[7]!==i||e[8]!==l||e[9]!==f?(s=(0,t.jsx)("input",{"aria-label":p,className:"h-7 w-12 rounded-md border border-border bg-background text-center font-mono text-xs uppercase outline-none focus-visible:border-ring","data-testid":l,onKeyDown:i,readOnly:!0,value:f}),e[6]=p,e[7]=i,e[8]=l,e[9]=f,e[10]=s):s=e[10];let a;e[11]!==h||e[12]!==s?(a=(0,t.jsxs)("dd",{className:"flex items-center gap-1.5",children:[h,s]}),e[11]=h,e[12]=s,e[13]=a):a=e[13];let d;return e[14]!==c||e[15]!==m||e[16]!==a?(d=(0,t.jsxs)("div",{className:"contents","data-testid":c,children:[m,a]}),e[14]=c,e[15]=m,e[16]=a,e[17]=d):d=e[17],d},"z"),Se=g(n=>{let e=(0,J.c)(85),{initialShardKey:u}=n,r=X(),p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let A=u??"",x;e[1]!==A?(x={shardKey:A},e[1]=A,e[2]=x):x=e[2];let{data:i,error:c,errorSource:m,isLoading:h}=Z(ee.getSettings,p,x),l,f,s,a,d,o,b;if(e[3]!==c||e[4]!==m||e[5]!==i?.deploy||e[6]!==i?.settings||e[7]!==r){let Q=pe(i?.deploy,r),M;e[15]!==i?.settings?(M=i?.settings??[],e[15]=i?.settings,e[16]=M):M=e[16],l=M,f="flex flex-col gap-4",s="lunora-settings";let V;e[17]!==r?(V=r("Open in Cloudflare"),e[17]=r,e[18]=V):V=e[18],e[19]!==V?(a=(0,t.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,t.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:de,rel:"noreferrer",target:"_blank",children:V})}),e[19]=V,e[20]=a):a=e[20];let $;e[21]!==r?($=r("View-only \u2014 values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=r,e[22]=$):$=e[22],e[23]!==$?(d=(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:$}),e[23]=$,e[24]=d):d=e[24],e[25]!==c||e[26]!==m?(o=c!==null&&(0,t.jsx)(ae,{error:m,testId:"set-error"}),e[25]=c,e[26]=m,e[27]=o):o=e[27],b=Q.length>0&&(0,t.jsxs)(P,{className:"py-0","data-testid":"set-deploy",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Deployment")})}),(0,t.jsx)(q,{className:"py-3",children:(0,t.jsx)("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:Q.map(he)})})]}),e[3]=c,e[4]=m,e[5]=i?.deploy,e[6]=i?.settings,e[7]=r,e[8]=l,e[9]=f,e[10]=s,e[11]=a,e[12]=d,e[13]=o,e[14]=b}else l=e[8],f=e[9],s=e[10],a=e[11],d=e[12],o=e[13],b=e[14];let y;e[28]!==r?(y=r("Keyboard shortcuts"),e[28]=r,e[29]=y):y=e[29];let v;e[30]!==y?(v=(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y}),e[30]=y,e[31]=v):v=e[31];let N;e[32]!==r?(N=r("Reset"),e[32]=r,e[33]=N):N=e[33];let k;e[34]!==N?(k=(0,t.jsx)("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"set-shortcut-reset",onClick:ne,type:"button",children:N}),e[34]=N,e[35]=k):k=e[35];let w;e[36]!==v||e[37]!==k?(w=(0,t.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[v,k]}),e[36]=v,e[37]=k,e[38]=w):w=e[38];let C;e[39]!==r?(C=r("Command palette"),e[39]=r,e[40]=C):C=e[40];let S;e[41]!==C?(S=(0,t.jsx)(ie,{label:C,modifier:"\u2318/Ctrl",name:"palette"}),e[41]=C,e[42]=S):S=e[42];let T;e[43]!==r?(T=r("Operation console"),e[43]=r,e[44]=T):T=e[44];let D;e[45]!==T?(D=(0,t.jsx)(ie,{label:T,modifier:"Ctrl",name:"console"}),e[45]=T,e[46]=D):D=e[46];let _;e[47]!==S||e[48]!==D?(_=(0,t.jsxs)("dl",{className:"grid grid-cols-[10rem_minmax(0,1fr)] items-center gap-x-4 gap-y-2 text-sm",children:[S,D]}),e[47]=S,e[48]=D,e[49]=_):_=e[49];let E;e[50]!==r?(E=r("Stored in this browser. Focus a box and press a key to rebind it."),e[50]=r,e[51]=E):E=e[51];let I;e[52]!==E?(I=(0,t.jsx)("p",{className:"pt-3 text-xs text-muted-foreground",children:E}),e[52]=E,e[53]=I):I=e[53];let K;e[54]!==_||e[55]!==I?(K=(0,t.jsxs)(q,{className:"py-3",children:[_,I]}),e[54]=_,e[55]=I,e[56]=K):K=e[56];let O;e[57]!==w||e[58]!==K?(O=(0,t.jsxs)(P,{className:"py-0","data-testid":"set-preferences",children:[w,K]}),e[57]=w,e[58]=K,e[59]=O):O=e[59];let U;e[60]!==r?(U=r("Environment & bindings"),e[60]=r,e[61]=U):U=e[61];let j;e[62]!==U?(j=(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:U})}),e[62]=U,e[63]=j):j=e[63];let F;e[64]!==c||e[65]!==h||e[66]!==l.length||e[67]!==r?(F=c===null&&!h&&l.length===0&&(0,t.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:r("No environment variables or bindings.")}),e[64]=c,e[65]=h,e[66]=l.length,e[67]=r,e[68]=F):F=e[68];let L;e[69]!==l||e[70]!==r?(L=l.length>0&&(0,t.jsx)(q,{className:"px-0 py-0",children:(0,t.jsxs)(le,{"data-testid":"set-table",children:[(0,t.jsx)(oe,{children:(0,t.jsxs)(H,{children:[(0,t.jsx)(z,{children:r("name")}),(0,t.jsx)(z,{children:r("kind")}),(0,t.jsx)(z,{children:r("value")})]})}),(0,t.jsx)(se,{children:l.map(fe)})]})}),e[69]=l,e[70]=r,e[71]=L):L=e[71];let R;e[72]!==j||e[73]!==F||e[74]!==L?(R=(0,t.jsxs)(P,{className:"py-0",children:[j,F,L]}),e[72]=j,e[73]=F,e[74]=L,e[75]=R):R=e[75];let B;return e[76]!==O||e[77]!==R||e[78]!==f||e[79]!==s||e[80]!==a||e[81]!==d||e[82]!==o||e[83]!==b?(B=(0,t.jsxs)("div",{className:f,"data-testid":s,children:[a,d,o,b,O,R]}),e[76]=O,e[77]=R,e[78]=f,e[79]=s,e[80]=a,e[81]=d,e[82]=o,e[83]=b,e[84]=B):B=e[84],B},"Ce");function he(n){return(0,t.jsxs)("div",{className:"contents","data-testid":"set-deploy-row",children:[(0,t.jsx)("dt",{className:"text-muted-foreground",children:n.label}),(0,t.jsx)("dd",{className:"truncate font-mono text-xs",title:n.value,children:n.value})]},n.label)}g(he,"me");function fe(n){return(0,t.jsxs)(H,{"data-testid":"set-row",children:[(0,t.jsx)(G,{className:"font-mono text-xs font-medium",children:n.name}),(0,t.jsx)(G,{children:(0,t.jsx)(Y,{variant:ue[n.kind],children:n.bindingType??n.kind})}),(0,t.jsx)(G,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:n.value??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},n.name)}g(fe,"fe");export{Se as SettingsPanel};
1
+ import{b as de}from"./chunk-UYEZR3BI.js";import{a as te,b as re,c as ne}from"./chunk-Q4CAKBWN.js";import"./chunk-OKG3HWSJ.js";import{b as Y}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as ae}from"./chunk-ITMXIPQ7.js";import"./chunk-ULIQFBZU.js";import"./chunk-3PZNTIBM.js";import"./chunk-35DM4JJG.js";import{a as ee}from"./chunk-4ZEL6BYL.js";import{c as Z}from"./chunk-SDHFSBNM.js";import"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as le,b as oe,c as se,d as H,e as z,f as G}from"./chunk-HEAQVSNS.js";import{a as P,e as q}from"./chunk-WUWBZPUK.js";import{d as X}from"./chunk-FODLDLE2.js";import{a as g,d as W,f as ce,g as me}from"./chunk-YKXDMIHQ.js";var J=W(ce(),1);var t=W(me(),1);var ue={binding:"outline",secret:"destructive",var:"secondary"},pe=g((n,e)=>{if(n===void 0)return[];let u=[];return n.workerUrl!==void 0&&u.push({label:e("URL"),value:n.workerUrl}),n.environment!==void 0&&u.push({label:e("Environment"),value:n.environment}),n.deploymentId!==void 0&&u.push({label:e("Deployment"),value:n.deploymentId}),n.versionTag!==void 0&&u.push({label:e("Version"),value:n.versionTag}),u},"ce"),ie=g(n=>{let e=(0,J.c)(18),{modifier:u,name:r,label:p}=n,A=te(),x;e[0]!==r?(x=g(o=>{if(!["Escape","Tab"].includes(o.key)){if(o.shiftKey){o.preventDefault();return}o.preventDefault(),re(r,o.key)}},"b"),e[0]=r,e[1]=x):x=e[1];let i=x,c=`set-shortcut-${r}`,m;e[2]!==p?(m=(0,t.jsx)("dt",{className:"text-muted-foreground",children:p}),e[2]=p,e[3]=m):m=e[3];let h;e[4]!==u?(h=(0,t.jsx)("kbd",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:u}),e[4]=u,e[5]=h):h=e[5];let l=`set-shortcut-input-${r}`,f=A[r],s;e[6]!==p||e[7]!==i||e[8]!==l||e[9]!==f?(s=(0,t.jsx)("input",{"aria-label":p,className:"h-7 w-12 rounded-md border border-border bg-background text-center font-mono text-xs uppercase outline-none focus-visible:border-ring","data-testid":l,onKeyDown:i,readOnly:!0,value:f}),e[6]=p,e[7]=i,e[8]=l,e[9]=f,e[10]=s):s=e[10];let a;e[11]!==h||e[12]!==s?(a=(0,t.jsxs)("dd",{className:"flex items-center gap-1.5",children:[h,s]}),e[11]=h,e[12]=s,e[13]=a):a=e[13];let d;return e[14]!==c||e[15]!==m||e[16]!==a?(d=(0,t.jsxs)("div",{className:"contents","data-testid":c,children:[m,a]}),e[14]=c,e[15]=m,e[16]=a,e[17]=d):d=e[17],d},"z"),Se=g(n=>{let e=(0,J.c)(85),{initialShardKey:u}=n,r=X(),p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let A=u??"",x;e[1]!==A?(x={shardKey:A},e[1]=A,e[2]=x):x=e[2];let{data:i,error:c,errorSource:m,isLoading:h}=Z(ee.getSettings,p,x),l,f,s,a,d,o,b;if(e[3]!==c||e[4]!==m||e[5]!==i?.deploy||e[6]!==i?.settings||e[7]!==r){let Q=pe(i?.deploy,r),M;e[15]!==i?.settings?(M=i?.settings??[],e[15]=i?.settings,e[16]=M):M=e[16],l=M,f="flex flex-col gap-4",s="lunora-settings";let V;e[17]!==r?(V=r("Open in Cloudflare"),e[17]=r,e[18]=V):V=e[18],e[19]!==V?(a=(0,t.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,t.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:de,rel:"noreferrer",target:"_blank",children:V})}),e[19]=V,e[20]=a):a=e[20];let $;e[21]!==r?($=r("View-only \u2014 values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=r,e[22]=$):$=e[22],e[23]!==$?(d=(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:$}),e[23]=$,e[24]=d):d=e[24],e[25]!==c||e[26]!==m?(o=c!==null&&(0,t.jsx)(ae,{error:m,testId:"set-error"}),e[25]=c,e[26]=m,e[27]=o):o=e[27],b=Q.length>0&&(0,t.jsxs)(P,{className:"py-0","data-testid":"set-deploy",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Deployment")})}),(0,t.jsx)(q,{className:"py-3",children:(0,t.jsx)("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:Q.map(he)})})]}),e[3]=c,e[4]=m,e[5]=i?.deploy,e[6]=i?.settings,e[7]=r,e[8]=l,e[9]=f,e[10]=s,e[11]=a,e[12]=d,e[13]=o,e[14]=b}else l=e[8],f=e[9],s=e[10],a=e[11],d=e[12],o=e[13],b=e[14];let y;e[28]!==r?(y=r("Keyboard shortcuts"),e[28]=r,e[29]=y):y=e[29];let v;e[30]!==y?(v=(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y}),e[30]=y,e[31]=v):v=e[31];let N;e[32]!==r?(N=r("Reset"),e[32]=r,e[33]=N):N=e[33];let k;e[34]!==N?(k=(0,t.jsx)("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"set-shortcut-reset",onClick:ne,type:"button",children:N}),e[34]=N,e[35]=k):k=e[35];let w;e[36]!==v||e[37]!==k?(w=(0,t.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[v,k]}),e[36]=v,e[37]=k,e[38]=w):w=e[38];let C;e[39]!==r?(C=r("Command palette"),e[39]=r,e[40]=C):C=e[40];let S;e[41]!==C?(S=(0,t.jsx)(ie,{label:C,modifier:"\u2318/Ctrl",name:"palette"}),e[41]=C,e[42]=S):S=e[42];let T;e[43]!==r?(T=r("Operation console"),e[43]=r,e[44]=T):T=e[44];let D;e[45]!==T?(D=(0,t.jsx)(ie,{label:T,modifier:"Ctrl",name:"console"}),e[45]=T,e[46]=D):D=e[46];let _;e[47]!==S||e[48]!==D?(_=(0,t.jsxs)("dl",{className:"grid grid-cols-[10rem_minmax(0,1fr)] items-center gap-x-4 gap-y-2 text-sm",children:[S,D]}),e[47]=S,e[48]=D,e[49]=_):_=e[49];let E;e[50]!==r?(E=r("Stored in this browser. Focus a box and press a key to rebind it."),e[50]=r,e[51]=E):E=e[51];let I;e[52]!==E?(I=(0,t.jsx)("p",{className:"pt-3 text-xs text-muted-foreground",children:E}),e[52]=E,e[53]=I):I=e[53];let K;e[54]!==_||e[55]!==I?(K=(0,t.jsxs)(q,{className:"py-3",children:[_,I]}),e[54]=_,e[55]=I,e[56]=K):K=e[56];let O;e[57]!==w||e[58]!==K?(O=(0,t.jsxs)(P,{className:"py-0","data-testid":"set-preferences",children:[w,K]}),e[57]=w,e[58]=K,e[59]=O):O=e[59];let U;e[60]!==r?(U=r("Environment & bindings"),e[60]=r,e[61]=U):U=e[61];let j;e[62]!==U?(j=(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:U})}),e[62]=U,e[63]=j):j=e[63];let F;e[64]!==c||e[65]!==h||e[66]!==l.length||e[67]!==r?(F=c===null&&!h&&l.length===0&&(0,t.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:r("No environment variables or bindings.")}),e[64]=c,e[65]=h,e[66]=l.length,e[67]=r,e[68]=F):F=e[68];let L;e[69]!==l||e[70]!==r?(L=l.length>0&&(0,t.jsx)(q,{className:"px-0 py-0",children:(0,t.jsxs)(le,{"data-testid":"set-table",children:[(0,t.jsx)(oe,{children:(0,t.jsxs)(H,{children:[(0,t.jsx)(z,{children:r("name")}),(0,t.jsx)(z,{children:r("kind")}),(0,t.jsx)(z,{children:r("value")})]})}),(0,t.jsx)(se,{children:l.map(fe)})]})}),e[69]=l,e[70]=r,e[71]=L):L=e[71];let R;e[72]!==j||e[73]!==F||e[74]!==L?(R=(0,t.jsxs)(P,{className:"py-0",children:[j,F,L]}),e[72]=j,e[73]=F,e[74]=L,e[75]=R):R=e[75];let B;return e[76]!==O||e[77]!==R||e[78]!==f||e[79]!==s||e[80]!==a||e[81]!==d||e[82]!==o||e[83]!==b?(B=(0,t.jsxs)("div",{className:f,"data-testid":s,children:[a,d,o,b,O,R]}),e[76]=O,e[77]=R,e[78]=f,e[79]=s,e[80]=a,e[81]=d,e[82]=o,e[83]=b,e[84]=B):B=e[84],B},"Ce");function he(n){return(0,t.jsxs)("div",{className:"contents","data-testid":"set-deploy-row",children:[(0,t.jsx)("dt",{className:"text-muted-foreground",children:n.label}),(0,t.jsx)("dd",{className:"truncate font-mono text-xs",title:n.value,children:n.value})]},n.label)}g(he,"me");function fe(n){return(0,t.jsxs)(H,{"data-testid":"set-row",children:[(0,t.jsx)(G,{className:"font-mono text-xs font-medium",children:n.name}),(0,t.jsx)(G,{children:(0,t.jsx)(Y,{variant:ue[n.kind],children:n.bindingType??n.kind})}),(0,t.jsx)(G,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:n.value??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},n.name)}g(fe,"fe");export{Se as SettingsPanel};
@@ -1,4 +1,4 @@
1
- import{a as Pe}from"./chunk-EA2JKR5D.js";import{a as he}from"./chunk-IMOHEGMV.js";import{d as Ne,f as ke,g as we,k as oe}from"./chunk-V3VJAA4D.js";import{a as V}from"./chunk-5WJXVZMZ.js";import{a as $e}from"./chunk-2DX5MROH.js";import"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import{W as ye}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as B}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as ve}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as Oe}from"./chunk-4ZEL6BYL.js";import{f as F}from"./chunk-Z7WCKAUJ.js";import"./chunk-FSRSK4LY.js";import{d as be}from"./chunk-2Y6PXGIS.js";import{a as U}from"./chunk-FKVZRPV5.js";import{d as M,e as Se,f as se,g as ie,h as le,o as Ie,q as ae}from"./chunk-FODLDLE2.js";import{a as u,d as z,e as ue,f as te,g as re,i as fe}from"./chunk-YKXDMIHQ.js";var He=z(te(),1),xe=z(ue(),1);var Y=z(te(),1);var X=z(ue(),1);var C=z(re(),1);var Qe=se(Oe.listTables),Ve=["react","client","cli"],Xe={action:"action",mutation:"mutation",query:"query"},_e=u(t=>{let e=t.indexOf(":");return e===-1?{file:"",fn:t}:{file:t.slice(0,e),fn:t.slice(e+1)}},"Q"),Ye=u(({file:t,fn:e,kind:a})=>`await client.${Xe[a]}(api.${t}.${e}, { /* args */ });`,"ie"),Ze=u(t=>{let e=`api.${t.file}.${t.fn}`;switch(t.kind){case"action":return`const { call: ${t.fn} } = useAction(${e});`;case"mutation":return`const ${t.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},"se"),et=u(({file:t,fn:e})=>`lunora run ${t}:${e} --args '{ }'`,"oe"),tt=u(t=>["// Read rows",`const rows = await ctx.db.query("${t}").collect();`,"","// Insert a row",`const id = await ctx.db.insert("${t}", { /* fields */ });`,"","// Generated types",`type Row = Doc<"${t}">;`,`type RowId = Id<"${t}">;`].join(`
1
+ import{a as Pe}from"./chunk-EA2JKR5D.js";import{a as he}from"./chunk-IMOHEGMV.js";import{d as Ne,f as ke,g as we,k as oe}from"./chunk-V3VJAA4D.js";import{a as V}from"./chunk-5WJXVZMZ.js";import{a as $e}from"./chunk-2DX5MROH.js";import"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import{W as ye}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as B}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as ve}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as Oe}from"./chunk-4ZEL6BYL.js";import{f as F}from"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import{d as be}from"./chunk-2Y6PXGIS.js";import{a as U}from"./chunk-FKVZRPV5.js";import{d as M,e as Se,f as se,g as ie,h as le,o as Ie,q as ae}from"./chunk-FODLDLE2.js";import{a as u,d as z,e as ue,f as te,g as re,i as fe}from"./chunk-YKXDMIHQ.js";var He=z(te(),1),xe=z(ue(),1);var Y=z(te(),1);var X=z(ue(),1);var C=z(re(),1);var Qe=se(Oe.listTables),Ve=["react","client","cli"],Xe={action:"action",mutation:"mutation",query:"query"},_e=u(t=>{let e=t.indexOf(":");return e===-1?{file:"",fn:t}:{file:t.slice(0,e),fn:t.slice(e+1)}},"Q"),Ye=u(({file:t,fn:e,kind:a})=>`await client.${Xe[a]}(api.${t}.${e}, { /* args */ });`,"ie"),Ze=u(t=>{let e=`api.${t.file}.${t.fn}`;switch(t.kind){case"action":return`const { call: ${t.fn} } = useAction(${e});`;case"mutation":return`const ${t.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},"se"),et=u(({file:t,fn:e})=>`lunora run ${t}:${e} --args '{ }'`,"oe"),tt=u(t=>["// Read rows",`const rows = await ctx.db.query("${t}").collect();`,"","// Insert a row",`const id = await ctx.db.insert("${t}", { /* fields */ });`,"","// Generated types",`type Row = Doc<"${t}">;`,`type RowId = Id<"${t}">;`].join(`
2
2
  `),"ce"),rt=u((t,e)=>{switch(t){case"cli":return et(e);case"client":return Ye(e);default:return Ze(e)}},"re"),Te=u(t=>{let e=(0,Y.c)(19),{code:a,label:r,testId:n}=t,s=M(),o;e[0]!==a?(o=u(()=>{ae(a)},"c"),e[0]=a,e[1]=o):o=e[1];let i=o,d;e[2]!==r?(d=(0,C.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:r}),e[2]=r,e[3]=d):d=e[3];let m=`${n}-copy`,l;e[4]!==s?(l=s("Copy"),e[4]=s,e[5]=l):l=e[5];let c;e[6]!==i||e[7]!==m||e[8]!==l?(c=(0,C.jsx)(B,{"data-testid":m,onClick:i,size:"xs",type:"button",variant:"ghost",children:l}),e[6]=i,e[7]=m,e[8]=l,e[9]=c):c=e[9];let f;e[10]!==d||e[11]!==c?(f=(0,C.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[d,c]}),e[10]=d,e[11]=c,e[12]=f):f=e[12];let h;e[13]!==a||e[14]!==n?(h=(0,C.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":n,children:a}),e[13]=a,e[14]=n,e[15]=h):h=e[15];let g;return e[16]!==f||e[17]!==h?(g=(0,C.jsxs)("div",{className:"flex flex-col gap-1.5",children:[f,h]}),e[16]=f,e[17]=h,e[18]=g):g=e[18],g},"U"),at=u(t=>{let e=(0,Y.c)(46),{file:a,fn:r,kind:n}=t,s=M(),[o,i]=(0,X.useState)("react"),d,m,l;if(e[0]!==a||e[1]!==r||e[2]!==n||e[3]!==s||e[4]!==o){let w={file:a,fn:r,kind:n},j;e[8]!==s?(j=s("CLI"),e[8]=s,e[9]=j):j=e[9];let O;e[10]!==s?(O=s("Client"),e[10]=s,e[11]=O):O=e[11];let S;e[12]!==s?(S=s("React"),e[12]=s,e[13]=S):S=e[13];let T;e[14]!==j||e[15]!==O||e[16]!==S?(T={cli:j,client:O,react:S},e[14]=j,e[15]=O,e[16]=S,e[17]=T):T=e[17],l=T;let A;e[18]===Symbol.for("react.memo_cache_sentinel")?(A=u(R=>{i(R.currentTarget.dataset.tab)},"B"),e[18]=A):A=e[18],d=A,m=rt(o,w),e[0]=a,e[1]=r,e[2]=n,e[3]=s,e[4]=o,e[5]=d,e[6]=m,e[7]=l}else d=e[5],m=e[6],l=e[7];let c=m,f=`api.${a}.${r}`,h;e[19]!==f?(h=(0,C.jsx)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-fn-title",children:f}),e[19]=f,e[20]=h):h=e[20];let g;e[21]!==n||e[22]!==s?(g=s("Call this {kind} from your app.",{kind:n}),e[21]=n,e[22]=s,e[23]=g):g=e[23];let x;e[24]!==g?(x=(0,C.jsx)("p",{className:"text-xs text-muted-foreground",children:g}),e[24]=g,e[25]=x):x=e[25];let y;e[26]!==h||e[27]!==x?(y=(0,C.jsxs)("div",{children:[h,x]}),e[26]=h,e[27]=x,e[28]=y):y=e[28];let N;e[29]!==s?(N=s("Snippet flavour"),e[29]=s,e[30]=N):N=e[30];let v;e[31]!==d||e[32]!==o||e[33]!==l?(v=Ve.map(w=>(0,C.jsx)(B,{"aria-selected":o===w,"data-tab":w,"data-testid":`api-tab-${w}`,onClick:d,role:"tab",size:"xs",type:"button",variant:o===w?"default":"outline",children:l[w]},w)),e[31]=d,e[32]=o,e[33]=l,e[34]=v):v=e[34];let b;e[35]!==N||e[36]!==v?(b=(0,C.jsx)("div",{"aria-label":N,className:"flex gap-1.5","data-testid":"api-tabs",role:"tablist",children:v}),e[35]=N,e[36]=v,e[37]=b):b=e[37];let I=l[o],P=`api-snippet-${o}`,$;e[38]!==c||e[39]!==I||e[40]!==P?($=(0,C.jsx)(Te,{code:c,label:I,testId:P}),e[38]=c,e[39]=I,e[40]=P,e[41]=$):$=e[41];let k;return e[42]!==$||e[43]!==y||e[44]!==b?(k=(0,C.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"api-fn-doc",children:[y,b,$]}),e[42]=$,e[43]=y,e[44]=b,e[45]=k):k=e[45],k},"de"),nt=u(t=>{let e=(0,Y.c)(19),{name:a}=t,r=M(),n;e[0]!==a?(n=tt(a),e[0]=a,e[1]=n):n=e[1];let s=n,o;e[2]!==a?(o=(0,C.jsx)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-table-title",children:a}),e[2]=a,e[3]=o):o=e[3];let i;e[4]!==r?(i=r("Read and write this table through the typed data model."),e[4]=r,e[5]=i):i=e[5];let d;e[6]!==i?(d=(0,C.jsx)("p",{className:"text-xs text-muted-foreground",children:i}),e[6]=i,e[7]=d):d=e[7];let m;e[8]!==o||e[9]!==d?(m=(0,C.jsxs)("div",{children:[o,d]}),e[8]=o,e[9]=d,e[10]=m):m=e[10];let l;e[11]!==r?(l=r("Data model"),e[11]=r,e[12]=l):l=e[12];let c;e[13]!==s||e[14]!==l?(c=(0,C.jsx)(Te,{code:s,label:l,testId:"api-snippet-table"}),e[13]=s,e[14]=l,e[15]=c):c=e[15];let f;return e[16]!==m||e[17]!==c?(f=(0,C.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"api-table-doc",children:[m,c]}),e[16]=m,e[17]=c,e[18]=f):f=e[18],f},"fe"),je=u(t=>{let e=(0,Y.c)(8),{active:a,label:r,onSelect:n,testId:s,value:o}=t,i;e[0]!==n||e[1]!==o?(i=u(()=>{n(o)},"m"),e[0]=n,e[1]=o,e[2]=i):i=e[2];let d=i,m=a?"page":void 0,l;return e[3]!==r||e[4]!==d||e[5]!==m||e[6]!==s?(l=(0,C.jsx)("button",{"aria-current":m,className:"w-full truncate rounded-md px-2 py-1 text-start font-mono text-xs text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-foreground","data-testid":s,onClick:d,type:"button",children:r}),e[3]=r,e[4]=d,e[5]=m,e[6]=s,e[7]=l):l=e[7],l},"G"),ot=u(t=>{let e=new Map;for(let a of t){let{file:r,fn:n}=_e(a.path),s=e.get(r)??[];s.push({fn:n,kind:a.kind,path:a.path}),e.set(r,s)}return[...e.entries()].map(([a,r])=>({file:a,items:r.toSorted((n,s)=>n.fn.localeCompare(s.fn))})).toSorted((a,r)=>a.file.localeCompare(r.file))},"pe"),Ce=u(t=>{let e=(0,Y.c)(58),{functions:a,initialShardKey:r}=t,n=M(),s=F(),[o,i]=(0,X.useState)(null),[d,m]=(0,X.useState)(null),l,c;e[0]!==s||e[1]!==r?(l=u(()=>{let R=!1;return s.query(Qe,{},ie(r??"")).then(_=>(R||i(_),_)).catch(()=>{R||i([])}),()=>{R=!0}},"o"),c=[s,r],e[0]=s,e[1]=r,e[2]=l,e[3]=c):(l=e[2],c=e[3]),(0,X.useEffect)(l,c);let f,h,g,x,y,N,v,b,I,P;if(e[4]!==a||e[5]!==d||e[6]!==n||e[7]!==o){let R=a??[],_=ot(R),L=(o??[]).map(st).toSorted(it),E;e[18]===Symbol.for("react.memo_cache_sentinel")?(E=u(q=>{m({kind:"fn",path:q})},"P"),e[18]=E):E=e[18];let W=E,Q;e[19]===Symbol.for("react.memo_cache_sentinel")?(Q=u(q=>{m({kind:"table",name:q})},"j"),e[19]=Q):Q=e[19];let Ge=Q;h=d?.kind==="fn"?R.find(q=>q.path===d.path):void 0,f=R.length>0||L.length>0,g=h===void 0?void 0:_e(h.path),I="grid min-h-0 gap-6 md:grid-cols-[16rem_minmax(0,1fr)]",P="lunora-api-docs",e[20]!==n?(x=n("API resources"),e[20]=n,e[21]=x):x=e[21],y="flex flex-col gap-4 overflow-y-auto",N="api-rail";let ne;e[22]!==d||e[23]!==n?(ne=u(q=>(0,C.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,C.jsx)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:q.file||n("(root)")}),q.items.map(ee=>(0,C.jsx)(je,{active:d?.kind==="fn"&&d.path===ee.path,label:ee.fn,onSelect:W,testId:`api-rail-fn-${ee.path}`,value:ee.path},ee.path))]},q.file),"q"),e[22]=d,e[23]=n,e[24]=ne):ne=e[24],v=_.map(ne),b=L.length>0&&(0,C.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,C.jsx)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Tables")}),L.map(q=>(0,C.jsx)(je,{active:d?.kind==="table"&&d.name===q,label:q,onSelect:Ge,testId:`api-rail-table-${q}`,value:q},q))]}),e[4]=a,e[5]=d,e[6]=n,e[7]=o,e[8]=f,e[9]=h,e[10]=g,e[11]=x,e[12]=y,e[13]=N,e[14]=v,e[15]=b,e[16]=I,e[17]=P}else f=e[8],h=e[9],g=e[10],x=e[11],y=e[12],N=e[13],v=e[14],b=e[15],I=e[16],P=e[17];let $;e[25]!==f||e[26]!==n?($=!f&&(0,C.jsx)("p",{className:"px-2 text-xs text-muted-foreground","data-testid":"api-rail-empty",children:n("No functions or tables to document yet.")}),e[25]=f,e[26]=n,e[27]=$):$=e[27];let k;e[28]!==$||e[29]!==x||e[30]!==y||e[31]!==N||e[32]!==v||e[33]!==b?(k=(0,C.jsxs)("nav",{"aria-label":x,className:y,"data-testid":N,children:[v,b,$]}),e[28]=$,e[29]=x,e[30]=y,e[31]=N,e[32]=v,e[33]=b,e[34]=k):k=e[34];let w;e[35]!==d||e[36]!==n?(w=d===null&&(0,C.jsx)(U,{description:n("Select a function or table to see how to call it from your app."),testId:"api-empty",title:n("API usage snippets")}),e[35]=d,e[36]=n,e[37]=w):w=e[37];let j;e[38]!==d?.kind||e[39]!==h||e[40]!==g?(j=d?.kind==="fn"&&h!==void 0&&g!==void 0&&(0,C.jsx)(at,{file:g.file,fn:g.fn,kind:h.kind},h.path),e[38]=d?.kind,e[39]=h,e[40]=g,e[41]=j):j=e[41];let O;e[42]!==d?.kind||e[43]!==h||e[44]!==n?(O=d?.kind==="fn"&&h===void 0&&(0,C.jsx)(U,{testId:"api-empty",title:n("API usage snippets")}),e[42]=d?.kind,e[43]=h,e[44]=n,e[45]=O):O=e[45];let S;e[46]!==d?(S=d?.kind==="table"&&(0,C.jsx)(nt,{name:d.name}),e[46]=d,e[47]=S):S=e[47];let T;e[48]!==w||e[49]!==j||e[50]!==O||e[51]!==S?(T=(0,C.jsxs)("div",{className:"min-w-0",children:[w,j,O,S]}),e[48]=w,e[49]=j,e[50]=O,e[51]=S,e[52]=T):T=e[52];let A;return e[53]!==k||e[54]!==T||e[55]!==I||e[56]!==P?(A=(0,C.jsxs)("div",{className:I,"data-testid":P,children:[k,T]}),e[53]=k,e[54]=T,e[55]=I,e[56]=P,e[57]=A):A=e[57],A},"ke");function st(t){return t.name}u(st,"ue");function it(t,e){return t.localeCompare(e)}u(it,"me");var De=z(te(),1);var K=z(te(),1),J=z(ue(),1);var p=z(re(),1);var pe=u(function(t,e,a){let r=(0,K.c)(15),n;r[0]===Symbol.for("react.memo_cache_sentinel")?(n={kind:"loading"},r[0]=n):n=r[0];let[s,o]=(0,J.useState)(n),i;r[1]!==e?(i=u(async()=>e(),"a"),r[1]=e,r[2]=i):i=r[2];let d=(0,J.useEffectEvent)(i),m;r[3]!==a?(m=u(g=>a(g),"d"),r[3]=a,r[4]=m):m=r[4];let l=(0,J.useEffectEvent)(m),c;r[5]!==l||r[6]!==d||r[7]!==t?(c=u(()=>{if(t!==void 0)return;let g=!1;return d().then(x=>(g||o(l(x)),x)).catch(x=>{g||o({kind:"error",message:le(x)})}),()=>{g=!0}},"u"),r[5]=l,r[6]=d,r[7]=t,r[8]=c):c=r[8];let f;r[9]!==t?(f=[t],r[9]=t,r[10]=f):f=r[10],(0,J.useEffect)(c,f);let h;return r[11]!==a||r[12]!==s||r[13]!==t?(h=t===void 0?s:a(t),r[11]=a,r[12]=s,r[13]=t,r[14]=h):h=r[14],h},"wt"),lt=u(t=>typeof t=="number"?"number":typeof t=="boolean"?"boolean":"string","we"),Ee=u(t=>{if(t.enum!==void 0&&t.enum.length>0)return t.enum;if(t.anyOf!==void 0&&t.anyOf.length>0&&t.anyOf.every(e=>e.const!==void 0))return t.anyOf.map(e=>e.const)},"Z"),ce=u(t=>t===void 0?"any":t.const!==void 0?JSON.stringify(t.const):t.enum!==void 0&&t.enum.length>0?t.enum.map(e=>JSON.stringify(e)).join(" | "):t.anyOf!==void 0&&t.anyOf.length>0?t.anyOf.map(e=>ce(e)).join(" | "):t.type==="array"?`array<${ce(t.items)}>`:t.type??"any","F"),dt=u(t=>{let e=Ee(t);return e!==void 0?t.type??lt(e[0]):ce(t)},"Oe"),ct=u(t=>{let e=Ee(t);return e===void 0?void 0:e.map(a=>JSON.stringify(a)).join(" | ")},"$e"),pt=u(t=>{let e=[];t.minimum!==void 0?e.push(`${String(t.minimum)} \u2264`):t.exclusiveMinimum!==void 0&&e.push(`${String(t.exclusiveMinimum)} <`);let a=e.length>0;e.push("value"),t.maximum!==void 0?e.push(`\u2264 ${String(t.maximum)}`):t.exclusiveMaximum!==void 0&&e.push(`< ${String(t.exclusiveMaximum)}`);let r=e.length>(a?2:1);return a||r?e.join(" "):void 0},"Te"),mt=u(t=>{if(t.type==="object"&&t.properties!==void 0)return t;if(t.type==="array"&&t.items?.type==="object"&&t.items.properties!==void 0)return t.items},"Ee"),Z=u(t=>{if(t===void 0)return null;if(t.const!==void 0)return t.const;if(t.enum!==void 0&&t.enum.length>0)return t.enum[0];if(t.anyOf!==void 0&&t.anyOf.length>0)return Z(t.anyOf[0]);switch(t.type){case"array":return[];case"boolean":return!1;case"number":return 0;case"object":{let e={};for(let[a,r]of Object.entries(t.properties??{}))e[a]=Z(r);return e}case"string":return"";default:return null}},"D"),de=u(t=>{let e=(0,K.c)(7),{label:a,value:r}=t,n;e[0]!==a?(n=(0,p.jsx)("span",{className:"text-muted-foreground",children:a}),e[0]=a,e[1]=n):n=e[1];let s;e[2]!==r?(s=(0,p.jsx)("span",{className:"text-foreground",children:r}),e[2]=r,e[3]=s):s=e[3];let o;return e[4]!==n||e[5]!==s?(o=(0,p.jsxs)("span",{className:"inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 font-mono text-[10px]",children:[n,s]}),e[4]=n,e[5]=s,e[6]=o):o=e[6],o},"K"),ut=u(t=>{let e=(0,K.c)(40),{name:a,required:r,schema:n}=t,s=M(),o;e[0]!==n?(o=pt(n),e[0]=n,e[1]=o):o=e[1];let i=o,d;e[2]!==n?(d=ct(n),e[2]=n,e[3]=d):d=e[3];let m=d,l=n["x-lunora-table"],c=n.format!==void 0||i!==void 0||m!==void 0||l!==void 0,f;e[4]!==n?(f=mt(n),e[4]=n,e[5]=f):f=e[5];let h=f,g=r?"*":"?",x;e[6]!==g?(x=(0,p.jsx)("span",{className:"text-muted-foreground",children:g}),e[6]=g,e[7]=x):x=e[7];let y;e[8]!==a||e[9]!==x?(y=(0,p.jsxs)("span",{className:"font-mono text-foreground",children:[a,x]}),e[8]=a,e[9]=x,e[10]=y):y=e[10];let N;e[11]!==n?(N=dt(n),e[11]=n,e[12]=N):N=e[12];let v;e[13]!==N?(v=(0,p.jsx)("span",{className:"font-mono text-muted-foreground",children:N}),e[13]=N,e[14]=v):v=e[14];let b;e[15]!==y||e[16]!==v?(b=(0,p.jsxs)("div",{className:"flex items-baseline gap-2",children:[y,v]}),e[15]=y,e[16]=v,e[17]=b):b=e[17];let I;e[18]!==n.description?(I=n.description!==void 0&&(0,p.jsx)("p",{className:"max-w-prose text-muted-foreground",children:n.description}),e[18]=n.description,e[19]=I):I=e[19];let P;e[20]!==c||e[21]!==i||e[22]!==l||e[23]!==n.format||e[24]!==s||e[25]!==m?(P=c&&(0,p.jsxs)("div",{className:"flex flex-wrap gap-1",children:[n.format!==void 0&&(0,p.jsx)(de,{label:s("Format"),value:n.format}),i!==void 0&&(0,p.jsx)(de,{label:s("Range"),value:i}),m!==void 0&&(0,p.jsx)(de,{label:s("Value in"),value:m}),l!==void 0&&(0,p.jsx)(de,{label:s("relation"),value:l})]}),e[20]=c,e[21]=i,e[22]=l,e[23]=n.format,e[24]=s,e[25]=m,e[26]=P):P=e[26];let $;e[27]!==I||e[28]!==P||e[29]!==b?($=(0,p.jsxs)("div",{className:"flex flex-col gap-1 py-2",children:[b,I,P]}),e[27]=I,e[28]=P,e[29]=b,e[30]=$):$=e[30];let k=$;if(h===void 0){let S;return e[31]!==k?(S=(0,p.jsx)("div",{className:"border-b border-border/50 last:border-b-0",children:k}),e[31]=k,e[32]=S):S=e[32],S}let w;e[33]!==k?(w=(0,p.jsx)("summary",{className:"cursor-pointer marker:text-muted-foreground",children:k}),e[33]=k,e[34]=w):w=e[34];let j;e[35]!==h?(j=(0,p.jsx)("div",{className:"mb-2 ml-2 border-l border-border pl-3",children:(0,p.jsx)(Je,{schema:h})}),e[35]=h,e[36]=j):j=e[36];let O;return e[37]!==w||e[38]!==j?(O=(0,p.jsxs)("details",{className:"border-b border-border/50 last:border-b-0",children:[w,j]}),e[37]=w,e[38]=j,e[39]=O):O=e[39],O},"Ce"),Je=u(t=>{let e=(0,K.c)(7),{schema:a}=t,r;e[0]!==a.required?(r=new Set(a.required),e[0]=a.required,e[1]=r):r=e[1];let n=r,s;e[2]!==a.properties?(s=Object.entries(a.properties??{}),e[2]=a.properties,e[3]=s):s=e[3];let o=s,i;return e[4]!==n||e[5]!==o?(i=(0,p.jsx)("div",{className:"flex flex-col",children:o.map(d=>{let[m,l]=d;return(0,p.jsx)(ut,{name:m,required:n.has(m),schema:l},m)})}),e[4]=n,e[5]=o,e[6]=i):i=e[6],i},"ee"),Ae=u(t=>{let e=(0,K.c)(10),{schema:a,testId:r}=t;if(a?.type!=="object"||Object.keys(a.properties??{}).length===0){let o;e[0]!==a?(o=ce(a),e[0]=a,e[1]=o):o=e[1];let i;return e[2]!==o||e[3]!==r?(i=(0,p.jsx)("p",{className:"font-mono text-xs text-muted-foreground","data-testid":r,children:o}),e[2]=o,e[3]=r,e[4]=i):i=e[4],i}let n;e[5]!==a?(n=(0,p.jsx)(Je,{schema:a}),e[5]=a,e[6]=n):n=e[6];let s;return e[7]!==n||e[8]!==r?(s=(0,p.jsx)("div",{className:"text-xs","data-testid":r,children:n}),e[7]=n,e[8]=r,e[9]=s):s=e[9],s},"G"),ft=["curl","javascript","lunora"],ht={lunora:"Lunora",curl:"cURL",javascript:"JavaScript"},gt=u(t=>`api.${t.replaceAll(/[/:]/g,".")}`,"Re"),xt=u(t=>{let e=Z(t.argsSchema)??{};return t.functionPath===void 0?e:{args:e,functionPath:t.functionPath}},"je"),bt=u((t,e,a)=>{let r=`${a}${e.httpPath}`,n=JSON.stringify(xt(e),void 0,2),s=JSON.stringify(Z(e.argsSchema)??{},void 0,2);switch(t){case"curl":{let o=e.method!=="GET"&&e.method!=="HEAD",i=[`curl -X ${e.method} ${JSON.stringify(r)}`];return o&&i.push(' -H "Content-Type: application/json"',` -d '${n}'`),i.join(` \\
3
3
  `)}case"lunora":return e.functionPath===void 0?`await fetch(${JSON.stringify(e.httpPath)}, { method: ${JSON.stringify(e.method)} });`:`import { useLunora } from "@lunora/react";
4
4
  import { api } from "./_generated/api";
@@ -1 +1 @@
1
- import{b as P}from"./chunk-2ADU5FA5.js";import{c as K,d as X,e as z,f as L,h as B,i as E,j as G,k as q,l as A,m as O,n as W,o as $,p as D}from"./chunk-URBHAYYZ.js";import{a as F,b as H,c as I,d as S,e as J,f as M}from"./chunk-HEAQVSNS.js";import{d as C,n as j}from"./chunk-FODLDLE2.js";import{a as f,d as T,f as U,g as V}from"./chunk-YKXDMIHQ.js";var N=T(U(),1);var t=T(V(),1);var _=50,R={value:{colors:{dark:["var(--chart-1)"],light:["var(--chart-1)"]},label:"value"}},Q=f(r=>{let a=r.columns.find(e=>r.rows.length>0&&r.rows.every(n=>typeof n[e]=="number"))??null;return{label:r.columns.find(e=>e!==a)??null,value:a}},"D"),Y=f(r=>{let a=(0,N.c)(3),{data:e,kind:n}=r,l;return a[0]!==e||a[1]!==n?(l=(0,t.jsx)(G,{className:"h-full w-full",config:R,children:n==="area"?(0,t.jsxs)(E,{data:e,children:[(0,t.jsx)(K,{vertical:!1}),(0,t.jsx)(L,{axisLine:!1,dataKey:"label",tickLine:!1}),(0,t.jsx)(A,{content:(0,t.jsx)(q,{})}),(0,t.jsx)(z,{dataKey:"value",fill:"var(--color-value-0)",fillOpacity:.2,stroke:"var(--color-value-0)",type:"monotone"})]}):(0,t.jsxs)(B,{data:e,children:[(0,t.jsx)(K,{vertical:!1}),(0,t.jsx)(L,{axisLine:!1,dataKey:"label",tickLine:!1}),(0,t.jsx)(A,{content:(0,t.jsx)(q,{})}),(0,t.jsx)(X,{dataKey:"value",dot:!1,stroke:"var(--color-value-0)",strokeWidth:2,type:"monotone"})]})}),a[0]=e,a[1]=n,a[2]=l):l=a[2],l},"J"),na=f(r=>{let a=(0,N.c)(21),{axes:e,kind:n,result:l}=r,u=C(),o;a[0]!==l?(o=Q(l),a[0]=l,a[1]=o):o=a[1];let d=o,m;a[2]!==l.columns?(m=new Set(l.columns),a[2]=l.columns,a[3]=m):m=a[3];let s=m,c=e!==void 0&&s.has(e.x)?e.x:d.label,p;a[4]!==e?.y||a[5]!==s?(p=e?.y.find(i=>s.has(i)),a[4]=e?.y,a[5]=s,a[6]=p):p=a[6];let x=p,y=x??d.value,b;a[7]!==c||a[8]!==l.rows||a[9]!==y?(b=y===null?[]:l.rows.slice(0,_).map((i,w)=>({label:c===null?`#${(w+1).toString()}`:j(i[c]),value:Number(i[y])||0})),a[7]=c,a[8]=l.rows,a[9]=y,a[10]=b):b=a[10];let k=b;if(y===null){let i;a[11]!==u?(i=u("No numeric column to chart."),a[11]=u,a[12]=i):i=a[12];let w;return a[13]!==i?(w=(0,t.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-chart-empty",children:i}),a[13]=i,a[14]=w):w=a[14],w}let h=n??(e!==void 0&&x!==void 0?e.kind:"bar"),v;a[15]!==k||a[16]!==h?(v=h==="bar"?(0,t.jsxs)(O,{className:"h-full w-full",config:R,data:k,children:[(0,t.jsx)($,{dataKey:"label"}),(0,t.jsx)(W,{dataKey:"value"}),(0,t.jsx)(D,{})]}):(0,t.jsx)(Y,{data:k,kind:h}),a[15]=k,a[16]=h,a[17]=v):v=a[17];let g;return a[18]!==h||a[19]!==v?(g=(0,t.jsx)("div",{className:"h-80 w-full p-3","data-chart-kind":h,"data-testid":"sql-chart",children:v}),a[18]=h,a[19]=v,a[20]=g):g=a[20],g},"oe"),oa=f(r=>{let a=(0,N.c)(19),{result:e}=r,n=C();if(e.columns.length===0){let s;a[0]!==e.rowCount||a[1]!==n?(s=n("{count} rows",{count:e.rowCount}),a[0]=e.rowCount,a[1]=n,a[2]=s):s=a[2];let c;return a[3]!==s?(c=(0,t.jsx)("p",{className:"p-4 text-sm text-muted-foreground",children:s}),a[3]=s,a[4]=c):c=a[4],c}let l;a[5]!==e.columns?(l=e.columns.map(Z),a[5]=e.columns,a[6]=l):l=a[6];let u;a[7]!==l?(u=(0,t.jsx)(H,{className:"sticky top-0 z-10 bg-muted",children:(0,t.jsx)(S,{children:l})}),a[7]=l,a[8]=u):u=a[8];let o;if(a[9]!==e.columns||a[10]!==e.rows){let s;a[12]!==e.columns?(s=f((c,p)=>(0,t.jsx)(S,{"data-testid":"sql-row",children:e.columns.map(x=>(0,t.jsx)(M,{className:"max-w-md truncate font-mono text-xs",children:(0,t.jsx)(P,{value:c[x]})},x))},p),"s"),a[12]=e.columns,a[13]=s):s=a[13],o=e.rows.map(s),a[9]=e.columns,a[10]=e.rows,a[11]=o}else o=a[11];let d;a[14]!==o?(d=(0,t.jsx)(I,{children:o}),a[14]=o,a[15]=d):d=a[15];let m;return a[16]!==u||a[17]!==d?(m=(0,t.jsxs)(F,{"data-testid":"sql-rows",children:[u,d]}),a[16]=u,a[17]=d,a[18]=m):m=a[18],m},"ne");function Z(r){return(0,t.jsx)(J,{children:r},r)}f(Z,"P");export{na as a,oa as b};
1
+ import{b as P}from"./chunk-PZVVEPIN.js";import{c as K,d as X,e as z,f as L,h as B,i as E,j as G,k as q,l as A,m as O,n as W,o as $,p as D}from"./chunk-URBHAYYZ.js";import{a as F,b as H,c as I,d as S,e as J,f as M}from"./chunk-HEAQVSNS.js";import{d as C,n as j}from"./chunk-FODLDLE2.js";import{a as f,d as T,f as U,g as V}from"./chunk-YKXDMIHQ.js";var N=T(U(),1);var t=T(V(),1);var _=50,R={value:{colors:{dark:["var(--chart-1)"],light:["var(--chart-1)"]},label:"value"}},Q=f(r=>{let a=r.columns.find(e=>r.rows.length>0&&r.rows.every(n=>typeof n[e]=="number"))??null;return{label:r.columns.find(e=>e!==a)??null,value:a}},"D"),Y=f(r=>{let a=(0,N.c)(3),{data:e,kind:n}=r,l;return a[0]!==e||a[1]!==n?(l=(0,t.jsx)(G,{className:"h-full w-full",config:R,children:n==="area"?(0,t.jsxs)(E,{data:e,children:[(0,t.jsx)(K,{vertical:!1}),(0,t.jsx)(L,{axisLine:!1,dataKey:"label",tickLine:!1}),(0,t.jsx)(A,{content:(0,t.jsx)(q,{})}),(0,t.jsx)(z,{dataKey:"value",fill:"var(--color-value-0)",fillOpacity:.2,stroke:"var(--color-value-0)",type:"monotone"})]}):(0,t.jsxs)(B,{data:e,children:[(0,t.jsx)(K,{vertical:!1}),(0,t.jsx)(L,{axisLine:!1,dataKey:"label",tickLine:!1}),(0,t.jsx)(A,{content:(0,t.jsx)(q,{})}),(0,t.jsx)(X,{dataKey:"value",dot:!1,stroke:"var(--color-value-0)",strokeWidth:2,type:"monotone"})]})}),a[0]=e,a[1]=n,a[2]=l):l=a[2],l},"J"),na=f(r=>{let a=(0,N.c)(21),{axes:e,kind:n,result:l}=r,u=C(),o;a[0]!==l?(o=Q(l),a[0]=l,a[1]=o):o=a[1];let d=o,m;a[2]!==l.columns?(m=new Set(l.columns),a[2]=l.columns,a[3]=m):m=a[3];let s=m,c=e!==void 0&&s.has(e.x)?e.x:d.label,p;a[4]!==e?.y||a[5]!==s?(p=e?.y.find(i=>s.has(i)),a[4]=e?.y,a[5]=s,a[6]=p):p=a[6];let x=p,y=x??d.value,b;a[7]!==c||a[8]!==l.rows||a[9]!==y?(b=y===null?[]:l.rows.slice(0,_).map((i,w)=>({label:c===null?`#${(w+1).toString()}`:j(i[c]),value:Number(i[y])||0})),a[7]=c,a[8]=l.rows,a[9]=y,a[10]=b):b=a[10];let k=b;if(y===null){let i;a[11]!==u?(i=u("No numeric column to chart."),a[11]=u,a[12]=i):i=a[12];let w;return a[13]!==i?(w=(0,t.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-chart-empty",children:i}),a[13]=i,a[14]=w):w=a[14],w}let h=n??(e!==void 0&&x!==void 0?e.kind:"bar"),v;a[15]!==k||a[16]!==h?(v=h==="bar"?(0,t.jsxs)(O,{className:"h-full w-full",config:R,data:k,children:[(0,t.jsx)($,{dataKey:"label"}),(0,t.jsx)(W,{dataKey:"value"}),(0,t.jsx)(D,{})]}):(0,t.jsx)(Y,{data:k,kind:h}),a[15]=k,a[16]=h,a[17]=v):v=a[17];let g;return a[18]!==h||a[19]!==v?(g=(0,t.jsx)("div",{className:"h-80 w-full p-3","data-chart-kind":h,"data-testid":"sql-chart",children:v}),a[18]=h,a[19]=v,a[20]=g):g=a[20],g},"oe"),oa=f(r=>{let a=(0,N.c)(19),{result:e}=r,n=C();if(e.columns.length===0){let s;a[0]!==e.rowCount||a[1]!==n?(s=n("{count} rows",{count:e.rowCount}),a[0]=e.rowCount,a[1]=n,a[2]=s):s=a[2];let c;return a[3]!==s?(c=(0,t.jsx)("p",{className:"p-4 text-sm text-muted-foreground",children:s}),a[3]=s,a[4]=c):c=a[4],c}let l;a[5]!==e.columns?(l=e.columns.map(Z),a[5]=e.columns,a[6]=l):l=a[6];let u;a[7]!==l?(u=(0,t.jsx)(H,{className:"sticky top-0 z-10 bg-muted",children:(0,t.jsx)(S,{children:l})}),a[7]=l,a[8]=u):u=a[8];let o;if(a[9]!==e.columns||a[10]!==e.rows){let s;a[12]!==e.columns?(s=f((c,p)=>(0,t.jsx)(S,{"data-testid":"sql-row",children:e.columns.map(x=>(0,t.jsx)(M,{className:"max-w-md truncate font-mono text-xs",children:(0,t.jsx)(P,{value:c[x]})},x))},p),"s"),a[12]=e.columns,a[13]=s):s=a[13],o=e.rows.map(s),a[9]=e.columns,a[10]=e.rows,a[11]=o}else o=a[11];let d;a[14]!==o?(d=(0,t.jsx)(I,{children:o}),a[14]=o,a[15]=d):d=a[15];let m;return a[16]!==u||a[17]!==d?(m=(0,t.jsxs)(F,{"data-testid":"sql-rows",children:[u,d]}),a[16]=u,a[17]=d,a[18]=m):m=a[18],m},"ne");function Z(r){return(0,t.jsx)(J,{children:r},r)}f(Z,"P");export{na as a,oa as b};
@@ -1 +1 @@
1
- import{a as H}from"./chunk-66UGPQVC.js";import{b as x}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{b as z}from"./chunk-MBP4SZYB.js";import{f as O}from"./chunk-Z7WCKAUJ.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as _}from"./chunk-FKVZRPV5.js";import{a as q,b as B,c as E,d as S,e as i,f as s}from"./chunk-HEAQVSNS.js";import{a as A,e as L}from"./chunk-WUWBZPUK.js";import{d as W}from"./chunk-FODLDLE2.js";import{a as R,d as M,f as $,g as D}from"./chunk-YKXDMIHQ.js";var I=M($(),1);var n=M(D(),1);var F=2e3,G=new Set(["open"]),ie=R(Q=>{let e=(0,I.c)(41),{read:y}=Q,t=W(),j=O(),v;e[0]!==j||e[1]!==y?(v=R(()=>Promise.resolve(y?y():j.debug()),"T"),e[0]=j,e[1]=y,e[2]=v):v=e[2];let V=v,K=y?"injected":"live",b;e[3]!==K?(b=["lunora-studio","sync-client-debug",K],e[3]=K,e[4]=b):b=e[4];let{data:c,refetch:Y}=z(b,V);if(H(Y,!0,F),!c){let r;e[5]!==t?(r=t("Reading the sync client's state\u2026"),e[5]=t,e[6]=r):r=e[6];let g;e[7]!==t?(g=t("Sync client"),e[7]=t,e[8]=g):g=e[8];let T;return e[9]!==r||e[10]!==g?(T=(0,n.jsx)(A,{children:(0,n.jsx)(L,{children:(0,n.jsx)(_,{description:r,title:g})})}),e[9]=r,e[10]=g,e[11]=T):T=e[11],T}let{pendingWrites:k,shards:N,subscriptions:w}=c,a;e[12]!==t?(a=t("This Studio session's sync client"),e[12]=t,e[13]=a):a=e[13];let l;e[14]!==a?(l=(0,n.jsx)("span",{className:"text-sm font-medium",children:a}),e[14]=a,e[15]=l):l=e[15];let P=c.connectionStatus==="connected"?"default":"secondary",o;e[16]!==c.connectionStatus||e[17]!==P?(o=(0,n.jsx)(x,{variant:P,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=P,e[18]=o):o=e[18];let d;e[19]!==k||e[20]!==t?(d=k>0?(0,n.jsx)(x,{variant:"secondary",children:t("{count} pending writes",{count:k})}):null,e[19]=k,e[20]=t,e[21]=d):d=e[21];let h;e[22]!==l||e[23]!==o||e[24]!==d?(h=(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[l,o,d]}),e[22]=l,e[23]=o,e[24]=d,e[25]=h):h=e[25];let u;e[26]!==t?(u=t("Reads client.debug() for the client running in this page \u2014 not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=t,e[27]=u):u=e[27];let m;e[28]!==u?(m=(0,n.jsx)("p",{className:"text-muted-foreground text-xs",children:u}),e[28]=u,e[29]=m):m=e[29];let p;e[30]!==N||e[31]!==t?(p=N.length===0?(0,n.jsx)(_,{description:t("No shard connection has been opened yet."),title:t("No shards")}):(0,n.jsxs)(q,{children:[(0,n.jsx)(B,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(i,{children:t("Shard")}),(0,n.jsx)(i,{children:t("Socket")}),(0,n.jsx)(i,{children:t("Confirmed watermark")})]})}),(0,n.jsx)(E,{children:N.map(r=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{children:r.shardKey??t("(default)")}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:G.has(r.wsState)?"default":"secondary",children:r.wsState})}),(0,n.jsx)(s,{children:r.confirmedMutationWatermark})]},r.shardKey??"__default__"))})]}),e[30]=N,e[31]=t,e[32]=p):p=e[32];let f;e[33]!==w||e[34]!==t?(f=w.length===0?(0,n.jsx)(_,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):(0,n.jsxs)(q,{children:[(0,n.jsx)(B,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(i,{children:t("Subscription")}),(0,n.jsx)(i,{children:t("Kind")}),(0,n.jsx)(i,{children:t("Acked")}),(0,n.jsx)(i,{children:t("Cursor")}),(0,n.jsx)(i,{children:t("Pending overlays")})]})}),(0,n.jsx)(E,{children:w.map(r=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{className:"font-mono text-xs",children:r.functionPath}),(0,n.jsx)(s,{children:r.kind}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:r.acked?"default":"secondary",children:r.acked?t("yes"):t("no")})}),(0,n.jsx)(s,{children:r.serverCursor??"\u2014"}),(0,n.jsx)(s,{children:r.pendingOptimisticLayers})]},r.id))})]}),e[33]=w,e[34]=t,e[35]=f):f=e[35];let C;return e[36]!==m||e[37]!==p||e[38]!==f||e[39]!==h?(C=(0,n.jsx)(A,{children:(0,n.jsxs)(L,{className:"flex flex-col gap-4",children:[h,m,p,f]})}),e[36]=m,e[37]=p,e[38]=f,e[39]=h,e[40]=C):C=e[40],C},"ie");export{ie as default};
1
+ import{a as H}from"./chunk-66UGPQVC.js";import{b as x}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{b as z}from"./chunk-SDHFSBNM.js";import{f as O}from"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as _}from"./chunk-FKVZRPV5.js";import{a as q,b as B,c as E,d as S,e as i,f as s}from"./chunk-HEAQVSNS.js";import{a as A,e as L}from"./chunk-WUWBZPUK.js";import{d as W}from"./chunk-FODLDLE2.js";import{a as R,d as M,f as $,g as D}from"./chunk-YKXDMIHQ.js";var I=M($(),1);var n=M(D(),1);var F=2e3,G=new Set(["open"]),ie=R(Q=>{let e=(0,I.c)(41),{read:y}=Q,t=W(),j=O(),v;e[0]!==j||e[1]!==y?(v=R(()=>Promise.resolve(y?y():j.debug()),"T"),e[0]=j,e[1]=y,e[2]=v):v=e[2];let V=v,K=y?"injected":"live",b;e[3]!==K?(b=["lunora-studio","sync-client-debug",K],e[3]=K,e[4]=b):b=e[4];let{data:c,refetch:Y}=z(b,V);if(H(Y,!0,F),!c){let r;e[5]!==t?(r=t("Reading the sync client's state\u2026"),e[5]=t,e[6]=r):r=e[6];let g;e[7]!==t?(g=t("Sync client"),e[7]=t,e[8]=g):g=e[8];let T;return e[9]!==r||e[10]!==g?(T=(0,n.jsx)(A,{children:(0,n.jsx)(L,{children:(0,n.jsx)(_,{description:r,title:g})})}),e[9]=r,e[10]=g,e[11]=T):T=e[11],T}let{pendingWrites:k,shards:N,subscriptions:w}=c,a;e[12]!==t?(a=t("This Studio session's sync client"),e[12]=t,e[13]=a):a=e[13];let l;e[14]!==a?(l=(0,n.jsx)("span",{className:"text-sm font-medium",children:a}),e[14]=a,e[15]=l):l=e[15];let P=c.connectionStatus==="connected"?"default":"secondary",o;e[16]!==c.connectionStatus||e[17]!==P?(o=(0,n.jsx)(x,{variant:P,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=P,e[18]=o):o=e[18];let d;e[19]!==k||e[20]!==t?(d=k>0?(0,n.jsx)(x,{variant:"secondary",children:t("{count} pending writes",{count:k})}):null,e[19]=k,e[20]=t,e[21]=d):d=e[21];let h;e[22]!==l||e[23]!==o||e[24]!==d?(h=(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[l,o,d]}),e[22]=l,e[23]=o,e[24]=d,e[25]=h):h=e[25];let u;e[26]!==t?(u=t("Reads client.debug() for the client running in this page \u2014 not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=t,e[27]=u):u=e[27];let m;e[28]!==u?(m=(0,n.jsx)("p",{className:"text-muted-foreground text-xs",children:u}),e[28]=u,e[29]=m):m=e[29];let p;e[30]!==N||e[31]!==t?(p=N.length===0?(0,n.jsx)(_,{description:t("No shard connection has been opened yet."),title:t("No shards")}):(0,n.jsxs)(q,{children:[(0,n.jsx)(B,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(i,{children:t("Shard")}),(0,n.jsx)(i,{children:t("Socket")}),(0,n.jsx)(i,{children:t("Confirmed watermark")})]})}),(0,n.jsx)(E,{children:N.map(r=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{children:r.shardKey??t("(default)")}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:G.has(r.wsState)?"default":"secondary",children:r.wsState})}),(0,n.jsx)(s,{children:r.confirmedMutationWatermark})]},r.shardKey??"__default__"))})]}),e[30]=N,e[31]=t,e[32]=p):p=e[32];let f;e[33]!==w||e[34]!==t?(f=w.length===0?(0,n.jsx)(_,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):(0,n.jsxs)(q,{children:[(0,n.jsx)(B,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(i,{children:t("Subscription")}),(0,n.jsx)(i,{children:t("Kind")}),(0,n.jsx)(i,{children:t("Acked")}),(0,n.jsx)(i,{children:t("Cursor")}),(0,n.jsx)(i,{children:t("Pending overlays")})]})}),(0,n.jsx)(E,{children:w.map(r=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{className:"font-mono text-xs",children:r.functionPath}),(0,n.jsx)(s,{children:r.kind}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:r.acked?"default":"secondary",children:r.acked?t("yes"):t("no")})}),(0,n.jsx)(s,{children:r.serverCursor??"\u2014"}),(0,n.jsx)(s,{children:r.pendingOptimisticLayers})]},r.id))})]}),e[33]=w,e[34]=t,e[35]=f):f=e[35];let C;return e[36]!==m||e[37]!==p||e[38]!==f||e[39]!==h?(C=(0,n.jsx)(A,{children:(0,n.jsxs)(L,{className:"flex flex-col gap-4",children:[h,m,p,f]})}),e[36]=m,e[37]=p,e[38]=f,e[39]=h,e[40]=C):C=e[40],C},"ie");export{ie as default};
@@ -1 +1 @@
1
- import{b as c}from"./chunk-MBP4SZYB.js";import{f as l}from"./chunk-Z7WCKAUJ.js";import{a as r,d as f,f as g}from"./chunk-YKXDMIHQ.js";var m=f(g(),1);var p={capabilities:{accounts:!0,admin:!0,inviteOnly:!1,organization:!1,passkey:!1,twoFactor:!1},emailAndPassword:!1,organization:{enabled:!1,roles:!1,teams:!1},plugins:[],rateLimit:{enabled:!1},session:{},socialProviders:[],userFields:[]},h=r(()=>{let a=(0,m.c)(6),s=l(),o;a[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-auth-config"],a[0]=o):o=a[0];let e;a[1]!==s?(e=r(()=>s.getAuthConfig(),"t"),a[1]=s,a[2]=e):e=a[2];let{data:u,isLoading:d}=c(o,e),t=u??p,n=!d,i;return a[3]!==t||a[4]!==n?(i={config:t,ready:n},a[3]=t,a[4]=n,a[5]=i):i=a[5],i},"b");export{p as a,h as b};
1
+ import{b as c}from"./chunk-SDHFSBNM.js";import{f as l}from"./chunk-B6RRRJP5.js";import{a as r,d as f,f as g}from"./chunk-YKXDMIHQ.js";var m=f(g(),1);var p={capabilities:{accounts:!0,admin:!0,inviteOnly:!1,organization:!1,passkey:!1,twoFactor:!1},emailAndPassword:!1,organization:{enabled:!1,roles:!1,teams:!1},plugins:[],rateLimit:{enabled:!1},session:{},socialProviders:[],userFields:[]},h=r(()=>{let a=(0,m.c)(6),s=l(),o;a[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-auth-config"],a[0]=o):o=a[0];let e;a[1]!==s?(e=r(()=>s.getAuthConfig(),"t"),a[1]=s,a[2]=e):e=a[2];let{data:u,isLoading:d}=c(o,e),t=u??p,n=!d,i;return a[3]!==t||a[4]!==n?(i={config:t,ready:n},a[3]=t,a[4]=n,a[5]=i):i=a[5],i},"b");export{p as a,h as b};
@@ -1 +1 @@
1
- import{b as g}from"./chunk-YRZFU7OM.js";import"./chunk-KZDIKRZ3.js";import"./chunk-ULIQFBZU.js";import"./chunk-2W365SXI.js";import"./chunk-35DM4JJG.js";import{a as f}from"./chunk-4ZEL6BYL.js";import{c as m}from"./chunk-MBP4SZYB.js";import"./chunk-Z7WCKAUJ.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import"./chunk-HEAQVSNS.js";import"./chunk-WUWBZPUK.js";import{d as p}from"./chunk-FODLDLE2.js";import{a as r,d as h,f as S,g as A}from"./chunk-YKXDMIHQ.js";var R=h(S(),1);var k=h(A(),1);var _=r((e,s)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("User subscriptions are ungated")})[s.kind],"k"),w=r(e=>Array.isArray(e.findings)?e.findings:[],"g"),b=r(e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],"S"),E=r((e,s)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters \u2014 use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:s.detail?.length,min:s.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed \u2014 browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: anyone who can reach the worker can open a socket and run ordinary user subscriptions. Admin subscriptions are unaffected \u2014 they need the admin token. Set it if subscribers should present a shared credential.")})[s.kind],"A"),O=r(()=>{let e=(0,R.c)(8),s=p(),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];let{data:a,error:d,errorSource:c}=m(f.getSecurityAudit,i),n;if(e[1]!==a||e[2]!==s){let u=a===void 0?null:w(a);n=u===null?null:u.map(t=>({description:E(s,t),entity:b(t),issueType:_(s,t),key:t.kind,level:t.level})),e[1]=a,e[2]=s,e[3]=n}else n=e[3];let l=n,o;return e[4]!==d||e[5]!==c||e[6]!==l?(o=(0,k.jsx)(g,{error:d,errorSource:c,rows:l,testId:"lunora-security-advisor"}),e[4]=d,e[5]=c,e[6]=l,e[7]=o):o=e[7],o},"T");export{O as default};
1
+ import{b as g}from"./chunk-AX24JD2G.js";import"./chunk-ITMXIPQ7.js";import"./chunk-ULIQFBZU.js";import"./chunk-3PZNTIBM.js";import"./chunk-35DM4JJG.js";import{a as f}from"./chunk-4ZEL6BYL.js";import{c as m}from"./chunk-SDHFSBNM.js";import"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import"./chunk-HEAQVSNS.js";import"./chunk-WUWBZPUK.js";import{d as p}from"./chunk-FODLDLE2.js";import{a as r,d as h,f as S,g as A}from"./chunk-YKXDMIHQ.js";var R=h(S(),1);var k=h(A(),1);var _=r((e,s)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("User subscriptions are ungated")})[s.kind],"k"),w=r(e=>Array.isArray(e.findings)?e.findings:[],"g"),b=r(e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],"S"),E=r((e,s)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters \u2014 use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:s.detail?.length,min:s.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed \u2014 browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: anyone who can reach the worker can open a socket and run ordinary user subscriptions. Admin subscriptions are unaffected \u2014 they need the admin token. Set it if subscribers should present a shared credential.")})[s.kind],"A"),O=r(()=>{let e=(0,R.c)(8),s=p(),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];let{data:a,error:d,errorSource:c}=m(f.getSecurityAudit,i),n;if(e[1]!==a||e[2]!==s){let u=a===void 0?null:w(a);n=u===null?null:u.map(t=>({description:E(s,t),entity:b(t),issueType:_(s,t),key:t.kind,level:t.level})),e[1]=a,e[2]=s,e[3]=n}else n=e[3];let l=n,o;return e[4]!==d||e[5]!==c||e[6]!==l?(o=(0,k.jsx)(g,{error:d,errorSource:c,rows:l,testId:"lunora-security-advisor"}),e[4]=d,e[5]=c,e[6]=l,e[7]=o):o=e[7],o},"T");export{O as default};
@@ -1,2 +1,2 @@
1
- import{a as fe}from"./chunk-2URQKGWU.js";import"./chunk-4JLGLPWV.js";import{a as ie}from"./chunk-MU3P2FI7.js";import{a as pe}from"./chunk-66UGPQVC.js";import"./chunk-3Q2P62UR.js";import{W as de}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as x}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as ne}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as he}from"./chunk-KZDIKRZ3.js";import"./chunk-ULIQFBZU.js";import"./chunk-2W365SXI.js";import"./chunk-35DM4JJG.js";import{a as H}from"./chunk-4ZEL6BYL.js";import{c as ue}from"./chunk-MBP4SZYB.js";import{f as le}from"./chunk-Z7WCKAUJ.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as ce}from"./chunk-FKVZRPV5.js";import{d as oe,f as Z,g as ee,h as te,o as ae,q as me,r as re}from"./chunk-FODLDLE2.js";import{a as i,d as Y,e as ge,f as ve,g as Ne,i as se}from"./chunk-YKXDMIHQ.js";var t=Y(Ne(),1);var xe=Y(ve(),1);var N=Y(ge(),1);function ye({className:a,orientation:e="horizontal",...s}){return(0,t.jsx)(ie,{"data-slot":"separator",orientation:e,className:se("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",a),...s})}i(ye,"ge");var we=/https?:\/\/[^\s"'<>)]+/i,be=i(a=>a===void 0?void 0:we.exec(a)?.[0],"re"),y=i(a=>a===void 0?"":Array.isArray(a)?a.join(", "):a,"N"),Ce=i(a=>{if(a!==void 0)return be(a.html)??be(a.text)},"Ne"),ke=i((a,e)=>{let s=e.trim().toLowerCase();return s===""?a:a.filter(o=>`${o.subject} ${y(o.to)} ${y(o.cc)}`.toLowerCase().includes(s))},"we"),Se=i((a,e)=>{if(a.length!==0)return a.find(s=>s.id===e)??a[0]},"ye"),Te=Z(H.clearCapturedMail),Le=Z(H.sendTestMail),je=i(a=>{let e=(0,xe.c)(38),{limit:s}=a,o=le(),p;e[0]!==s?(p={limit:s},e[0]=s,e[1]=p):p=e[1];let{data:q,error:w,errorSource:C,isLoading:g,refetch:n}=ue(H.getCapturedMail,p),[k,f]=(0,N.useState)(null),[D,S]=(0,N.useState)(null),[v,l]=(0,N.useState)("html"),[c,P]=(0,N.useState)(""),b=q?.entries??[],r=w??k,u=w===null?k:C,T;e[2]!==o||e[3]!==n?(T=i(async()=>{f(null);try{await o.query(Te,{},ee("")),S(null),n()}catch(m){f(te(m))}},"T"),e[2]=o,e[3]=n,e[4]=T):T=e[4];let R=T,L;e[5]!==o||e[6]!==n?(L=i(async()=>{f(null);try{await o.query(Le,{},ee("")),n()}catch(m){f(te(m))}},"k"),e[5]=o,e[6]=n,e[7]=L):L=e[7];let W=L,j;e[8]!==n?(j=i(()=>{n()},"L"),e[8]=n,e[9]=j):j=e[9],pe(j,!0);let M;e[10]!==R?(M=i(()=>{ae(R())},"A"),e[10]=R,e[11]=M):M=e[11];let U=M,_;e[12]!==W?(_=i(()=>{ae(W())},"E"),e[12]=W,e[13]=_):_=e[13];let G=_,z;e[14]===Symbol.for("react.memo_cache_sentinel")?(z=i(m=>{P(m.currentTarget.value)},"_"),e[14]=z):z=e[14];let J=z,$;e[15]===Symbol.for("react.memo_cache_sentinel")?($=i(m=>{let{id:h}=m.currentTarget.dataset;h!==void 0&&S(h)},"M"),e[15]=$):$=e[15];let K=$,A;e[16]===Symbol.for("react.memo_cache_sentinel")?(A=i(m=>{let h=m.currentTarget.dataset.tab;(h==="headers"||h==="html"||h==="text")&&l(h)},"j"),e[16]=A):A=e[16];let Q=A,F=ke(b,c),O=Se(F,D),d=Ce(O),I;e[17]!==d?(I=i(()=>{d!==void 0&&me(d)},"z"),e[17]=d,e[18]=I):I=e[18];let V=I,B;e[19]!==d?(B=i(()=>{d!==void 0&&"window"in globalThis&&globalThis.window.open(d,"_blank","noopener")},"F"),e[19]=d,e[20]=B):B=e[20];let X=B,E;return e[21]!==b||e[22]!==r||e[23]!==u||e[24]!==c||e[25]!==g||e[26]!==d||e[27]!==U||e[28]!==V||e[29]!==J||e[30]!==X||e[31]!==K||e[32]!==Q||e[33]!==G||e[34]!==O||e[35]!==v||e[36]!==F?(E={entries:b,error:r,errorSource:u,filter:c,isLoading:g,link:d,onClear:U,onCopyLink:V,onFilterChange:J,onOpenLink:X,onSelectMessage:K,onSelectTab:Q,onSendTest:G,selected:O,tab:v,visible:F},e[21]=b,e[22]=r,e[23]=u,e[24]=c,e[25]=g,e[26]=d,e[27]=U,e[28]=V,e[29]=J,e[30]=X,e[31]=K,e[32]=Q,e[33]=G,e[34]=O,e[35]=v,e[36]=F,e[37]=E):E=e[37],E},"Te"),Me=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">`,_e=i(a=>`${Me}${a}`,"Le"),Je=i(({limit:a=100})=>{let e=oe(),{entries:s,error:o,errorSource:p,filter:q,isLoading:w,link:C,onClear:g,onCopyLink:n,onFilterChange:k,onOpenLink:f,onSelectMessage:D,onSelectTab:S,onSendTest:v,selected:l,tab:c,visible:P}=je({limit:a}),b=i(r=>e(r==="html"?"HTML":r==="text"?"Plain text":"Headers"),"b");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"mail-panel",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(x,{"data-testid":"mail-send-test",onClick:v,size:"sm",type:"button",variant:"outline",children:e("Send test")}),(0,t.jsx)(x,{"data-testid":"mail-clear",disabled:s.length===0,onClick:g,size:"sm",type:"button",variant:"outline",children:e("Clear inbox")}),s.length>0&&(0,t.jsx)(ne,{className:"ml-auto","data-testid":"mail-count",variant:"secondary",children:e("{count} messages",{count:s.length})})]}),o!==null&&(0,t.jsx)(he,{error:p,testId:"mail-error"}),o===null&&!w&&s.length===0&&(0,t.jsx)(ce,{description:e("Email your app sends in dev is captured here \u2014 nothing is delivered."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("path",{d:"M4 5h16v14H4z"}),(0,t.jsx)("path",{d:"m4 6 8 6 8-6"})]}),testId:"mail-empty",title:e("No captured email.")}),s.length>0&&(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-[minmax(0,22rem)_1fr]","data-testid":"mail-reader",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)(de,{"aria-label":e("Search messages"),"data-testid":"mail-search",onChange:k,placeholder:e("Filter messages"),type:"search",value:q}),(0,t.jsx)(fe,{className:"max-h-[32rem] rounded-xl border border-border bg-card shadow-xs","data-testid":"mail-list",children:(0,t.jsx)("ul",{className:"divide-y",children:P.map(r=>{let u=r.id===l?.id;return(0,t.jsx)("li",{children:(0,t.jsxs)("button",{className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-sm hover:bg-muted/60 ${u?"bg-muted":""}`,"data-active":u,"data-id":r.id,"data-testid":"mail-list-item",onClick:D,type:"button",children:[(0,t.jsx)("span",{className:"w-full truncate font-medium",children:r.subject||e("(no subject)")}),(0,t.jsx)("span",{className:"w-full truncate text-xs text-muted-foreground",children:y(r.to)}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground tabular-nums",children:re(r.capturedAt,"\u2014")})]})},r.id)})})})]}),l!==void 0&&(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"mail-detail",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"truncate text-base font-semibold","data-testid":"mail-subject",children:l.subject||e("(no subject)")}),(0,t.jsxs)("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs text-muted-foreground",children:[(0,t.jsx)("dt",{children:e("From")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:l.from??"\u2014"}),(0,t.jsx)("dt",{children:e("To")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:y(l.to)}),l.cc!==void 0&&l.cc.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("dt",{children:e("Cc")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:y(l.cc)})]}),(0,t.jsx)("dt",{children:e("Sent")}),(0,t.jsx)("dd",{className:"tabular-nums",children:re(l.capturedAt,"\u2014")})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2","data-testid":"mail-actions",children:[(0,t.jsx)(x,{"data-testid":"mail-copy-link",disabled:C===void 0,onClick:n,size:"sm",type:"button",variant:"outline",children:e("Copy link")}),(0,t.jsx)(x,{"data-testid":"mail-open-link",disabled:C===void 0,onClick:f,size:"sm",type:"button",variant:"outline",children:e("Open in new tab")})]}),(0,t.jsx)(ye,{}),(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"mail-tabs",role:"tablist",children:["html","text","headers"].map(r=>(0,t.jsx)(x,{"aria-selected":c===r,"data-tab":r,"data-testid":`mail-tab-${r}`,onClick:S,role:"tab",size:"sm",type:"button",variant:c===r?"secondary":"ghost",children:b(r)},r))}),(0,t.jsxs)("div",{className:"min-h-[12rem]",children:[c==="html"&&(l.html===void 0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No HTML body.")}):(0,t.jsx)("iframe",{className:"h-[24rem] w-full rounded-md border bg-white","data-testid":"mail-preview-html",sandbox:"",srcDoc:_e(l.html),title:e("Email preview")})),c==="text"&&(l.text===void 0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No text body.")}):(0,t.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-text",children:l.text})),c==="headers"&&(l.headers===void 0||Object.keys(l.headers).length===0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No headers.")}):(0,t.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-headers",children:Object.entries(l.headers).map(([r,u])=>`${r}: ${u}`).join(`
1
+ import{a as fe}from"./chunk-2URQKGWU.js";import"./chunk-4JLGLPWV.js";import{a as ie}from"./chunk-MU3P2FI7.js";import{a as pe}from"./chunk-66UGPQVC.js";import"./chunk-3Q2P62UR.js";import{W as de}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as x}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as ne}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as he}from"./chunk-ITMXIPQ7.js";import"./chunk-ULIQFBZU.js";import"./chunk-3PZNTIBM.js";import"./chunk-35DM4JJG.js";import{a as H}from"./chunk-4ZEL6BYL.js";import{c as ue}from"./chunk-SDHFSBNM.js";import{f as le}from"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as ce}from"./chunk-FKVZRPV5.js";import{d as oe,f as Z,g as ee,h as te,o as ae,q as me,r as re}from"./chunk-FODLDLE2.js";import{a as i,d as Y,e as ge,f as ve,g as Ne,i as se}from"./chunk-YKXDMIHQ.js";var t=Y(Ne(),1);var xe=Y(ve(),1);var N=Y(ge(),1);function ye({className:a,orientation:e="horizontal",...s}){return(0,t.jsx)(ie,{"data-slot":"separator",orientation:e,className:se("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",a),...s})}i(ye,"ge");var we=/https?:\/\/[^\s"'<>)]+/i,be=i(a=>a===void 0?void 0:we.exec(a)?.[0],"re"),y=i(a=>a===void 0?"":Array.isArray(a)?a.join(", "):a,"N"),Ce=i(a=>{if(a!==void 0)return be(a.html)??be(a.text)},"Ne"),ke=i((a,e)=>{let s=e.trim().toLowerCase();return s===""?a:a.filter(o=>`${o.subject} ${y(o.to)} ${y(o.cc)}`.toLowerCase().includes(s))},"we"),Se=i((a,e)=>{if(a.length!==0)return a.find(s=>s.id===e)??a[0]},"ye"),Te=Z(H.clearCapturedMail),Le=Z(H.sendTestMail),je=i(a=>{let e=(0,xe.c)(38),{limit:s}=a,o=le(),p;e[0]!==s?(p={limit:s},e[0]=s,e[1]=p):p=e[1];let{data:q,error:w,errorSource:C,isLoading:g,refetch:n}=ue(H.getCapturedMail,p),[k,f]=(0,N.useState)(null),[D,S]=(0,N.useState)(null),[v,l]=(0,N.useState)("html"),[c,P]=(0,N.useState)(""),b=q?.entries??[],r=w??k,u=w===null?k:C,T;e[2]!==o||e[3]!==n?(T=i(async()=>{f(null);try{await o.query(Te,{},ee("")),S(null),n()}catch(m){f(te(m))}},"T"),e[2]=o,e[3]=n,e[4]=T):T=e[4];let R=T,L;e[5]!==o||e[6]!==n?(L=i(async()=>{f(null);try{await o.query(Le,{},ee("")),n()}catch(m){f(te(m))}},"k"),e[5]=o,e[6]=n,e[7]=L):L=e[7];let W=L,j;e[8]!==n?(j=i(()=>{n()},"L"),e[8]=n,e[9]=j):j=e[9],pe(j,!0);let M;e[10]!==R?(M=i(()=>{ae(R())},"A"),e[10]=R,e[11]=M):M=e[11];let U=M,_;e[12]!==W?(_=i(()=>{ae(W())},"E"),e[12]=W,e[13]=_):_=e[13];let G=_,z;e[14]===Symbol.for("react.memo_cache_sentinel")?(z=i(m=>{P(m.currentTarget.value)},"_"),e[14]=z):z=e[14];let J=z,$;e[15]===Symbol.for("react.memo_cache_sentinel")?($=i(m=>{let{id:h}=m.currentTarget.dataset;h!==void 0&&S(h)},"M"),e[15]=$):$=e[15];let K=$,A;e[16]===Symbol.for("react.memo_cache_sentinel")?(A=i(m=>{let h=m.currentTarget.dataset.tab;(h==="headers"||h==="html"||h==="text")&&l(h)},"j"),e[16]=A):A=e[16];let Q=A,F=ke(b,c),O=Se(F,D),d=Ce(O),I;e[17]!==d?(I=i(()=>{d!==void 0&&me(d)},"z"),e[17]=d,e[18]=I):I=e[18];let V=I,B;e[19]!==d?(B=i(()=>{d!==void 0&&"window"in globalThis&&globalThis.window.open(d,"_blank","noopener")},"F"),e[19]=d,e[20]=B):B=e[20];let X=B,E;return e[21]!==b||e[22]!==r||e[23]!==u||e[24]!==c||e[25]!==g||e[26]!==d||e[27]!==U||e[28]!==V||e[29]!==J||e[30]!==X||e[31]!==K||e[32]!==Q||e[33]!==G||e[34]!==O||e[35]!==v||e[36]!==F?(E={entries:b,error:r,errorSource:u,filter:c,isLoading:g,link:d,onClear:U,onCopyLink:V,onFilterChange:J,onOpenLink:X,onSelectMessage:K,onSelectTab:Q,onSendTest:G,selected:O,tab:v,visible:F},e[21]=b,e[22]=r,e[23]=u,e[24]=c,e[25]=g,e[26]=d,e[27]=U,e[28]=V,e[29]=J,e[30]=X,e[31]=K,e[32]=Q,e[33]=G,e[34]=O,e[35]=v,e[36]=F,e[37]=E):E=e[37],E},"Te"),Me=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">`,_e=i(a=>`${Me}${a}`,"Le"),Je=i(({limit:a=100})=>{let e=oe(),{entries:s,error:o,errorSource:p,filter:q,isLoading:w,link:C,onClear:g,onCopyLink:n,onFilterChange:k,onOpenLink:f,onSelectMessage:D,onSelectTab:S,onSendTest:v,selected:l,tab:c,visible:P}=je({limit:a}),b=i(r=>e(r==="html"?"HTML":r==="text"?"Plain text":"Headers"),"b");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"mail-panel",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(x,{"data-testid":"mail-send-test",onClick:v,size:"sm",type:"button",variant:"outline",children:e("Send test")}),(0,t.jsx)(x,{"data-testid":"mail-clear",disabled:s.length===0,onClick:g,size:"sm",type:"button",variant:"outline",children:e("Clear inbox")}),s.length>0&&(0,t.jsx)(ne,{className:"ml-auto","data-testid":"mail-count",variant:"secondary",children:e("{count} messages",{count:s.length})})]}),o!==null&&(0,t.jsx)(he,{error:p,testId:"mail-error"}),o===null&&!w&&s.length===0&&(0,t.jsx)(ce,{description:e("Email your app sends in dev is captured here \u2014 nothing is delivered."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("path",{d:"M4 5h16v14H4z"}),(0,t.jsx)("path",{d:"m4 6 8 6 8-6"})]}),testId:"mail-empty",title:e("No captured email.")}),s.length>0&&(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-[minmax(0,22rem)_1fr]","data-testid":"mail-reader",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)(de,{"aria-label":e("Search messages"),"data-testid":"mail-search",onChange:k,placeholder:e("Filter messages"),type:"search",value:q}),(0,t.jsx)(fe,{className:"max-h-[32rem] rounded-xl border border-border bg-card shadow-xs","data-testid":"mail-list",children:(0,t.jsx)("ul",{className:"divide-y",children:P.map(r=>{let u=r.id===l?.id;return(0,t.jsx)("li",{children:(0,t.jsxs)("button",{className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-sm hover:bg-muted/60 ${u?"bg-muted":""}`,"data-active":u,"data-id":r.id,"data-testid":"mail-list-item",onClick:D,type:"button",children:[(0,t.jsx)("span",{className:"w-full truncate font-medium",children:r.subject||e("(no subject)")}),(0,t.jsx)("span",{className:"w-full truncate text-xs text-muted-foreground",children:y(r.to)}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground tabular-nums",children:re(r.capturedAt,"\u2014")})]})},r.id)})})})]}),l!==void 0&&(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"mail-detail",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"truncate text-base font-semibold","data-testid":"mail-subject",children:l.subject||e("(no subject)")}),(0,t.jsxs)("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs text-muted-foreground",children:[(0,t.jsx)("dt",{children:e("From")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:l.from??"\u2014"}),(0,t.jsx)("dt",{children:e("To")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:y(l.to)}),l.cc!==void 0&&l.cc.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("dt",{children:e("Cc")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:y(l.cc)})]}),(0,t.jsx)("dt",{children:e("Sent")}),(0,t.jsx)("dd",{className:"tabular-nums",children:re(l.capturedAt,"\u2014")})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2","data-testid":"mail-actions",children:[(0,t.jsx)(x,{"data-testid":"mail-copy-link",disabled:C===void 0,onClick:n,size:"sm",type:"button",variant:"outline",children:e("Copy link")}),(0,t.jsx)(x,{"data-testid":"mail-open-link",disabled:C===void 0,onClick:f,size:"sm",type:"button",variant:"outline",children:e("Open in new tab")})]}),(0,t.jsx)(ye,{}),(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"mail-tabs",role:"tablist",children:["html","text","headers"].map(r=>(0,t.jsx)(x,{"aria-selected":c===r,"data-tab":r,"data-testid":`mail-tab-${r}`,onClick:S,role:"tab",size:"sm",type:"button",variant:c===r?"secondary":"ghost",children:b(r)},r))}),(0,t.jsxs)("div",{className:"min-h-[12rem]",children:[c==="html"&&(l.html===void 0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No HTML body.")}):(0,t.jsx)("iframe",{className:"h-[24rem] w-full rounded-md border bg-white","data-testid":"mail-preview-html",sandbox:"",srcDoc:_e(l.html),title:e("Email preview")})),c==="text"&&(l.text===void 0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No text body.")}):(0,t.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-text",children:l.text})),c==="headers"&&(l.headers===void 0||Object.keys(l.headers).length===0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No headers.")}):(0,t.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-headers",children:Object.entries(l.headers).map(([r,u])=>`${r}: ${u}`).join(`
2
2
  `)}))]})]})]})]})},"We");export{Je as MailPanel};