@lunora/studio 1.0.0-alpha.183 → 1.0.0-alpha.184

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 (63) hide show
  1. package/dist/standalone/{chunk-KX3YZ3TC.js → chunk-26L63KFY.js} +1 -1
  2. package/dist/standalone/{chunk-3PZNTIBM.js → chunk-2KM4MU7U.js} +1 -1
  3. package/dist/standalone/{chunk-IP7YCJUN.js → chunk-37CLUREK.js} +1 -1
  4. package/dist/standalone/{chunk-XKP3TSCE.js → chunk-3GJKDNXE.js} +1 -1
  5. package/dist/standalone/{chunk-FI6N7XWP.js → chunk-4P4DE3XL.js} +1 -1
  6. package/dist/standalone/{chunk-H43JNQM6.js → chunk-4PLYQWKJ.js} +1 -1
  7. package/dist/standalone/{chunk-TIIEZS24.js → chunk-4X5HAX5N.js} +1 -1
  8. package/dist/standalone/{chunk-QQ3CS3FX.js → chunk-55K64SUB.js} +1 -1
  9. package/dist/standalone/{chunk-5XRNQ732.js → chunk-56XCNBO4.js} +1 -1
  10. package/dist/standalone/{chunk-DAD33Q2T.js → chunk-5AQVGRDR.js} +1 -1
  11. package/dist/standalone/{chunk-I6FR5UAK.js → chunk-5TV5EBCO.js} +1 -1
  12. package/dist/standalone/{chunk-JYT34NQM.js → chunk-6VNVVY4F.js} +1 -1
  13. package/dist/standalone/{chunk-VWXJAY7R.js → chunk-724ZBLVZ.js} +1 -1
  14. package/dist/standalone/{chunk-AULH6SZB.js → chunk-75OWNJEY.js} +2 -2
  15. package/dist/standalone/{chunk-TTIBDOV6.js → chunk-7E4PCEOO.js} +1 -1
  16. package/dist/standalone/{chunk-KIW73EIK.js → chunk-7MF5C3Z6.js} +1 -1
  17. package/dist/standalone/{chunk-SDHFSBNM.js → chunk-7TRN7FQ4.js} +1 -1
  18. package/dist/standalone/{chunk-BAAPQWFF.js → chunk-AO5ROTB4.js} +1 -1
  19. package/dist/standalone/{chunk-A6S4TULR.js → chunk-BMVSHGFK.js} +1 -1
  20. package/dist/standalone/{chunk-B3JY36UV.js → chunk-CLELTQYS.js} +1 -1
  21. package/dist/standalone/{chunk-AX24JD2G.js → chunk-CZIPGHIR.js} +1 -1
  22. package/dist/standalone/{chunk-5LZJ5JBB.js → chunk-DVXDMRWA.js} +1 -1
  23. package/dist/standalone/{chunk-B6RRRJP5.js → chunk-EAQZEXBX.js} +1 -1
  24. package/dist/standalone/{chunk-IXNOQYEE.js → chunk-ETHN2RZR.js} +1 -1
  25. package/dist/standalone/{chunk-CBNGOAD4.js → chunk-FAFNOIJX.js} +1 -1
  26. package/dist/standalone/{chunk-ITMXIPQ7.js → chunk-FDB7QVEC.js} +1 -1
  27. package/dist/standalone/{chunk-GZAXFXZE.js → chunk-FGMA2GGM.js} +1 -1
  28. package/dist/standalone/{chunk-GAPFZFIL.js → chunk-FRMJ5VVM.js} +1 -1
  29. package/dist/standalone/{chunk-5MKG6RW3.js → chunk-FZ45WJQK.js} +1 -1
  30. package/dist/standalone/{chunk-2Y6PXGIS.js → chunk-GETL6R4M.js} +14 -14
  31. package/dist/standalone/{chunk-3TXB4AKZ.js → chunk-GKUDJ3RC.js} +1 -1
  32. package/dist/standalone/{chunk-AODYDAXY.js → chunk-HATH336U.js} +1 -1
  33. package/dist/standalone/{chunk-D4ZGY3II.js → chunk-IYUIJLIW.js} +1 -1
  34. package/dist/standalone/{chunk-66Z7ZIZZ.js → chunk-J6JOGFVB.js} +1 -1
  35. package/dist/standalone/{chunk-Y2I6GYEG.js → chunk-JM6U3CQE.js} +1 -1
  36. package/dist/standalone/{chunk-QWJQUQY3.js → chunk-JP6RVFCJ.js} +1 -1
  37. package/dist/standalone/{chunk-PGMASM2T.js → chunk-JYVJ2OWH.js} +1 -1
  38. package/dist/standalone/{chunk-DI34YDBW.js → chunk-LP7ELDUL.js} +1 -1
  39. package/dist/standalone/{chunk-L2CWAQUO.js → chunk-M3ANC2JI.js} +1 -1
  40. package/dist/standalone/{chunk-PZVVEPIN.js → chunk-MKRJGSYF.js} +1 -1
  41. package/dist/standalone/{chunk-URBHAYYZ.js → chunk-MWSNVNHE.js} +1 -1
  42. package/dist/standalone/{chunk-E2X625P3.js → chunk-N6LSV246.js} +1 -1
  43. package/dist/standalone/{chunk-RM4TNBYG.js → chunk-NRZ5MBPS.js} +1 -1
  44. package/dist/standalone/{chunk-4PRXEO3C.js → chunk-O337Z6XI.js} +1 -1
  45. package/dist/standalone/{chunk-WRZTTZFV.js → chunk-PVAE535J.js} +1 -1
  46. package/dist/standalone/{chunk-AFSPF2R4.js → chunk-PVV6LALL.js} +1 -1
  47. package/dist/standalone/{chunk-GZ6GAFM2.js → chunk-QZHPUFML.js} +1 -1
  48. package/dist/standalone/{chunk-MH2NGGUC.js → chunk-SDBOAPOT.js} +1 -1
  49. package/dist/standalone/{chunk-HGT5U6GD.js → chunk-SGL3ZV4P.js} +1 -1
  50. package/dist/standalone/{chunk-INXSZE5I.js → chunk-T57JAZCX.js} +1 -1
  51. package/dist/standalone/{chunk-WIXX2VWE.js → chunk-UZHJM2CX.js} +1 -1
  52. package/dist/standalone/{chunk-GP2GJRJ3.js → chunk-VCOPIBKL.js} +1 -1
  53. package/dist/standalone/{chunk-V7G6YTQ5.js → chunk-VG34EBBT.js} +1 -1
  54. package/dist/standalone/{chunk-QDHXQ56K.js → chunk-VICAUTXQ.js} +1 -1
  55. package/dist/standalone/{chunk-WD4WHTAV.js → chunk-WDJ4CHIO.js} +1 -1
  56. package/dist/standalone/{chunk-EBU3TTYR.js → chunk-XBKABVCJ.js} +1 -1
  57. package/dist/standalone/{chunk-NVKY4CIW.js → chunk-Y6SKU4M7.js} +1 -1
  58. package/dist/standalone/{chunk-5B6TTEP6.js → chunk-YBZYUPAG.js} +1 -1
  59. package/dist/standalone/{chunk-Z2XS4ZOO.js → chunk-Z2CLSELV.js} +1 -1
  60. package/dist/standalone/{chunk-J3LCGEBD.js → chunk-ZGMGMEFM.js} +1 -1
  61. package/dist/standalone/{chunk-TXHTSFLO.js → chunk-ZWJGQACG.js} +1 -1
  62. package/dist/standalone/studio.js +1 -1
  63. package/package.json +6 -6
@@ -1 +1 @@
1
- import{a as ge,b as fe,c as xe,d as Ne,e as Ce}from"./chunk-IHMGCHAA.js";import"./chunk-4JLGLPWV.js";import"./chunk-V3CZW3JB.js";import{a as ce}from"./chunk-EA2JKR5D.js";import{a as ue}from"./chunk-3FBLWUXD.js";import{a as q}from"./chunk-IMOHEGMV.js";import{g as me,h as ve,i as pe,j as ye}from"./chunk-NVKY4CIW.js";import"./chunk-Q4CAKBWN.js";import"./chunk-AULH6SZB.js";import"./chunk-RLLKECZT.js";import"./chunk-YPRQLCKF.js";import"./chunk-GMS77BZD.js";import"./chunk-3Q2P62UR.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import"./chunk-5WJXVZMZ.js";import"./chunk-EVTM6Q43.js";import"./chunk-K7AJEMKE.js";import"./chunk-6D6Z2KXU.js";import"./chunk-OKG3HWSJ.js";import{W as ae}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as $}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as he}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import"./chunk-35DM4JJG.js";import"./chunk-4ZEL6BYL.js";import"./chunk-SDHFSBNM.js";import{f as G}from"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as ke}from"./chunk-FKVZRPV5.js";import{a as ie,b as se,c as oe,d as Q,e as X,f as Y}from"./chunk-HEAQVSNS.js";import{a as re,e as ne}from"./chunk-WUWBZPUK.js";import{d as R,h as Z,l as be,o as z,q as de}from"./chunk-FODLDLE2.js";import{a as s,d as le,e as Oe,f as _e,g as De}from"./chunk-YKXDMIHQ.js";var P=le(Oe(),1);var ee=le(_e(),1);var a=le(De(),1);var Be=s(l=>{let e=l.trim();if(e==="")return;let d=Number(e);return Number.isFinite(d)&&d>0?Math.floor(d):void 0},"Be"),Le=s(l=>l===void 0?"\u2014":new Date(l*1e3).toISOString(),"Oe"),Je=s(l=>new TextEncoder().encode(l).length,"Ae"),Fe=s(l=>{if(l.trim()!=="")try{return JSON.stringify(JSON.parse(l),void 0,2)}catch{return}},"ge"),Ke=s(l=>{if(l.trim()==="")return!0;try{return JSON.parse(l),!0}catch{return!1}},"xe"),Ee=[{key:"seconds",seconds:1},{key:"minutes",seconds:60},{key:"hours",seconds:3600},{key:"days",seconds:86400}],we=s((l,e)=>{let d=l.trim();if(d==="")return"";let u=Number(d),i=Ee.find(v=>v.key===e)?.seconds??1;return Number.isFinite(u)&&u>0?String(Math.round(u*i)):d},"ue"),Ve=s(l=>{let e=l.trim();if(e==="")return!0;let d=Number(e);return Number.isInteger(d)&&d>=60},"Ce"),Te=s((l,e,d,u)=>{let i=Be(l.ttl);return{expiration:i===void 0?u:void 0,expirationTtl:i,key:e,metadata:l.metadata.trim()===""?void 0:JSON.parse(l.metadata),namespace:d,value:l.value}},"Se"),Me=s(l=>{let e=(0,ee.c)(60),{helper:d,id:u,invalid:i,onChange:v,testId:o}=l,t=R(),[r,p]=(0,P.useState)(""),[c,x]=(0,P.useState)("seconds"),g;e[0]!==v||e[1]!==c?(g=s(f=>{p(f.target.value),v(we(f.target.value,c))},"k"),e[0]=v,e[1]=c,e[2]=g):g=e[2];let O=g,V;e[3]!==r||e[4]!==v?(V=s(f=>{f!==null&&(x(f),v(we(r,f)))},"K"),e[3]=r,e[4]=v,e[5]=V):V=e[5];let _=V,y;e[6]!==t?(y=t("days"),e[6]=t,e[7]=y):y=e[7];let m;e[8]!==t?(m=t("hours"),e[8]=t,e[9]=m):m=e[9];let h;e[10]!==t?(h=t("minutes"),e[10]=t,e[11]=h):h=e[11];let N;e[12]!==t?(N=t("seconds"),e[12]=t,e[13]=N):N=e[13];let C;e[14]!==y||e[15]!==m||e[16]!==h||e[17]!==N?(C={days:y,hours:m,minutes:h,seconds:N},e[14]=y,e[15]=m,e[16]=h,e[17]=N,e[18]=C):C=e[18];let w=C,b;e[19]!==t?(b=t("Expires after"),e[19]=t,e[20]=b):b=e[20];let S;e[21]!==u||e[22]!==b?(S=(0,a.jsx)(q,{className:"text-xs",htmlFor:u,children:b}),e[21]=u,e[22]=b,e[23]=S):S=e[23];let E;e[24]!==t?(E=t("No expiration"),e[24]=t,e[25]=E):E=e[25];let B;e[26]!==r||e[27]!==u||e[28]!==i||e[29]!==O||e[30]!==E||e[31]!==o?(B=(0,a.jsx)(ae,{"aria-invalid":i,className:"flex-1","data-testid":o,id:u,inputMode:"numeric",onChange:O,placeholder:E,value:r}),e[26]=r,e[27]=u,e[28]=i,e[29]=O,e[30]=E,e[31]=o,e[32]=B):B=e[32];let T;e[33]!==t?(T=t("TTL unit"),e[33]=t,e[34]=T):T=e[34];let J=`${o}-unit`,L;e[35]===Symbol.for("react.memo_cache_sentinel")?(L=(0,a.jsx)(fe,{}),e[35]=L):L=e[35];let M;e[36]!==T||e[37]!==J?(M=(0,a.jsx)(xe,{"aria-label":T,className:"w-[7.5rem]","data-testid":J,children:L}),e[36]=T,e[37]=J,e[38]=M):M=e[38];let n;e[39]!==w?(n=Ee.map(f=>(0,a.jsx)(Ce,{value:f.key,children:w[f.key]},f.key)),e[39]=w,e[40]=n):n=e[40];let k;e[41]!==n?(k=(0,a.jsx)(Ne,{children:n}),e[41]=n,e[42]=k):k=e[42];let F;e[43]!==_||e[44]!==M||e[45]!==k||e[46]!==c?(F=(0,a.jsxs)(ge,{onValueChange:_,value:c,children:[M,k]}),e[43]=_,e[44]=M,e[45]=k,e[46]=c,e[47]=F):F=e[47];let I;e[48]!==B||e[49]!==F?(I=(0,a.jsxs)("div",{className:"flex gap-2",children:[B,F]}),e[48]=B,e[49]=F,e[50]=I):I=e[50];let K;e[51]!==d||e[52]!==i||e[53]!==t||e[54]!==o?(K=i?(0,a.jsx)("p",{className:"text-xs text-destructive","data-testid":`${o}-invalid`,children:t("TTL must be at least 60 seconds.")}):d!==void 0&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:d}),e[51]=d,e[52]=i,e[53]=t,e[54]=o,e[55]=K):K=e[55];let D;return e[56]!==I||e[57]!==K||e[58]!==S?(D=(0,a.jsxs)("div",{className:"mb-3 grid gap-1",children:[S,I,K]}),e[56]=I,e[57]=K,e[58]=S,e[59]=D):D=e[59],D},"we"),Ie=s(l=>{let e=(0,ee.c)(36),{id:d,invalidTestId:u,onChange:i,testId:v,valid:o,value:t}=l,r=R(),p;e[0]!==t?(p=Fe(t),e[0]=t,e[1]=p):p=e[1];let c=p,x;e[2]!==r?(x=r("Metadata (JSON)"),e[2]=r,e[3]=x):x=e[3];let g;e[4]!==d||e[5]!==x?(g=(0,a.jsx)(q,{className:"text-xs",htmlFor:d,children:x}),e[4]=d,e[5]=x,e[6]=g):g=e[6];let O=`${v}-format`,V=c===void 0,_;e[7]!==c||e[8]!==i?(_=s(()=>{c!==void 0&&i(c)},"L"),e[7]=c,e[8]=i,e[9]=_):_=e[9];let y;e[10]!==r?(y=r("Format JSON"),e[10]=r,e[11]=y):y=e[11];let m;e[12]!==O||e[13]!==V||e[14]!==_||e[15]!==y?(m=(0,a.jsx)($,{"data-testid":O,disabled:V,onClick:_,size:"sm",variant:"outline",children:y}),e[12]=O,e[13]=V,e[14]=_,e[15]=y,e[16]=m):m=e[16];let h;e[17]!==g||e[18]!==m?(h=(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[g,m]}),e[17]=g,e[18]=m,e[19]=h):h=e[19];let N=!o,C;e[20]!==i?(C=s(E=>{i(E.target.value)},"N"),e[20]=i,e[21]=C):C=e[21];let w;e[22]!==d||e[23]!==N||e[24]!==C||e[25]!==v||e[26]!==t?(w=(0,a.jsx)(ce,{"aria-invalid":N,className:"min-h-[4rem] font-mono text-xs","data-testid":v,id:d,onChange:C,value:t}),e[22]=d,e[23]=N,e[24]=C,e[25]=v,e[26]=t,e[27]=w):w=e[27];let b;e[28]!==u||e[29]!==r||e[30]!==o?(b=!o&&(0,a.jsx)("p",{className:"text-xs text-destructive","data-testid":u,children:r("Metadata must be valid JSON.")}),e[28]=u,e[29]=r,e[30]=o,e[31]=b):b=e[31];let S;return e[32]!==w||e[33]!==b||e[34]!==h?(S=(0,a.jsxs)("div",{className:"mb-3 grid gap-1",children:[h,w,b]}),e[32]=w,e[33]=b,e[34]=h,e[35]=S):S=e[35],S},"Te"),Pe={busy:!1,error:null,metadata:"",name:"",ttl:"",value:""},$e=s((l,e)=>{switch(e.type){case"setField":return{...l,[e.field]:e.value};case"submitFailed":return{...l,busy:!1,error:e.error};case"submitStart":return{...l,busy:!0,error:null};default:return l}},"Je"),je=s(l=>{let e=(0,ee.c)(73),{namespace:d,onCancel:u,onCreated:i}=l,v=G(),o=R(),[t,r]=(0,P.useReducer)($e,Pe),p;e[0]!==t.metadata?(p=Ke(t.metadata),e[0]=t.metadata,e[1]=p):p=e[1];let c=p,x;e[2]!==t.ttl?(x=Ve(t.ttl),e[2]=t.ttl,e[3]=x):x=e[3];let g=x,O;e[4]!==c||e[5]!==t.busy||e[6]!==t.name||e[7]!==g?(O=t.name.trim()!==""&&c&&g&&!t.busy,e[4]=c,e[5]=t.busy,e[6]=t.name,e[7]=g,e[8]=O):O=e[8];let V=O,_;e[9]!==V||e[10]!==v||e[11]!==d||e[12]!==i||e[13]!==t.metadata||e[14]!==t.name||e[15]!==t.ttl||e[16]!==t.value?(_=s(()=>{V&&(r({type:"submitStart"}),z((async()=>{try{await v.putKvValue(Te({metadata:t.metadata,ttl:t.ttl,value:t.value},t.name,d)),i()}catch(A){r({error:Z(A),type:"submitFailed"})}})()))},"L"),e[9]=V,e[10]=v,e[11]=d,e[12]=i,e[13]=t.metadata,e[14]=t.name,e[15]=t.ttl,e[16]=t.value,e[17]=_):_=e[17];let y=_,m;e[18]!==o?(m=o("Key name"),e[18]=o,e[19]=m):m=e[19];let h;e[20]!==m?(h=(0,a.jsx)(q,{className:"text-xs",htmlFor:"kv-create-name",children:m}),e[20]=m,e[21]=h):h=e[21];let N;e[22]===Symbol.for("react.memo_cache_sentinel")?(N=s(A=>{r({field:"name",type:"setField",value:A.target.value})},"x"),e[22]=N):N=e[22];let C;e[23]!==o?(C=o("Key name"),e[23]=o,e[24]=C):C=e[24];let w;e[25]!==t.name||e[26]!==C?(w=(0,a.jsx)(ae,{autoFocus:!0,"data-testid":"kv-create-name",id:"kv-create-name",onChange:N,placeholder:C,value:t.name}),e[25]=t.name,e[26]=C,e[27]=w):w=e[27];let b;e[28]!==h||e[29]!==w?(b=(0,a.jsxs)("div",{className:"grid gap-1",children:[h,w]}),e[28]=h,e[29]=w,e[30]=b):b=e[30];let S;e[31]!==o?(S=o("Value"),e[31]=o,e[32]=S):S=e[32];let E;e[33]!==S?(E=(0,a.jsx)(q,{className:"text-xs",htmlFor:"kv-create-value",children:S}),e[33]=S,e[34]=E):E=e[34];let B;e[35]===Symbol.for("react.memo_cache_sentinel")?(B=s(A=>{r({field:"value",type:"setField",value:A.target.value})},"O"),e[35]=B):B=e[35];let T;e[36]!==t.value?(T=(0,a.jsx)(ce,{className:"min-h-[6rem] font-mono text-xs","data-testid":"kv-create-value",id:"kv-create-value",onChange:B,value:t.value}),e[36]=t.value,e[37]=T):T=e[37];let J;e[38]!==E||e[39]!==T?(J=(0,a.jsxs)("div",{className:"grid gap-1",children:[E,T]}),e[38]=E,e[39]=T,e[40]=J):J=e[40];let L=!g,M;e[41]===Symbol.for("react.memo_cache_sentinel")?(M=s(A=>{r({field:"ttl",type:"setField",value:A})},"I"),e[41]=M):M=e[41];let n;e[42]!==L?(n=(0,a.jsx)(Me,{id:"kv-create-ttl",invalid:L,onChange:M,testId:"kv-create-ttl"}),e[42]=L,e[43]=n):n=e[43];let k;e[44]===Symbol.for("react.memo_cache_sentinel")?(k=s(A=>{r({field:"metadata",type:"setField",value:A})},"h"),e[44]=k):k=e[44];let F;e[45]!==c||e[46]!==t.metadata?(F=(0,a.jsx)(Ie,{id:"kv-create-metadata",invalidTestId:"kv-create-metadata-invalid",onChange:k,testId:"kv-create-metadata",valid:c,value:t.metadata}),e[45]=c,e[46]=t.metadata,e[47]=F):F=e[47];let I=!V,K;e[48]!==t.busy||e[49]!==o?(K=t.busy?o("Creating\u2026"):o("Create key"),e[48]=t.busy,e[49]=o,e[50]=K):K=e[50];let D;e[51]!==y||e[52]!==I||e[53]!==K?(D=(0,a.jsx)($,{"data-testid":"kv-create-submit",disabled:I,onClick:y,children:K}),e[51]=y,e[52]=I,e[53]=K,e[54]=D):D=e[54];let f=t.busy,j;e[55]!==o?(j=o("Cancel"),e[55]=o,e[56]=j):j=e[56];let H;e[57]!==u||e[58]!==t.busy||e[59]!==j?(H=(0,a.jsx)($,{"data-testid":"kv-create-cancel",disabled:f,onClick:u,variant:"outline",children:j}),e[57]=u,e[58]=t.busy,e[59]=j,e[60]=H):H=e[60];let U;e[61]!==D||e[62]!==H?(U=(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[D,H]}),e[61]=D,e[62]=H,e[63]=U):U=e[63];let W;e[64]!==t.error?(W=t.error!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"kv-create-error",role:"alert",children:t.error}),e[64]=t.error,e[65]=W):W=e[65];let te;return e[66]!==b||e[67]!==J||e[68]!==n||e[69]!==F||e[70]!==U||e[71]!==W?(te=(0,a.jsxs)("div",{className:"grid gap-3 px-4 pb-4","data-testid":"kv-create-form",children:[b,J,n,F,U,W]}),e[66]=b,e[67]=J,e[68]=n,e[69]=F,e[70]=U,e[71]=W,e[72]=te):te=e[72],te},"Pe"),Ae={busy:"",editedMetadata:"",editedTtl:"",editedValue:"",loadError:null,loading:!0,value:null,writeError:null},ze=s((l,e)=>{switch(e.type){case"deleteStart":return{...l,busy:"deleting",writeError:null};case"editMetadata":return{...l,editedMetadata:e.value};case"editTtl":return{...l,editedTtl:e.value};case"editValue":return{...l,editedValue:e.value};case"loaded":return{...l,editedMetadata:e.metadata===null||e.metadata===void 0?"":JSON.stringify(e.metadata,null,2),editedValue:e.value??"",loading:!1,value:e.value};case"loadFailed":return{...l,loadError:e.error,loading:!1};case"saveOk":return{...l,busy:"",value:l.editedValue};case"saveStart":return{...l,busy:"saving",writeError:null};case"writeFailed":return{...l,busy:"",writeError:e.error};default:return l}},"je"),He=s(l=>{let e=(0,ee.c)(67),{expiration:d,keyName:u,namespace:i,onDeleted:v}=l,o=G(),t=R(),[r,p]=(0,P.useReducer)(ze,Ae),c,x;e[0]!==o||e[1]!==u||e[2]!==i?(c=s(()=>{let f={cancelled:!1};return z((async()=>{try{let j=await o.getKvValue({key:u,namespace:i});f.cancelled||p({metadata:j.metadata,type:"loaded",value:j.value})}catch(j){let H=j;f.cancelled||p({error:Z(H),type:"loadFailed"})}})()),()=>{f.cancelled=!0}},"o"),x=[o,i,u],e[0]=o,e[1]=u,e[2]=i,e[3]=c,e[4]=x):(c=e[3],x=e[4]),(0,P.useEffect)(c,x);let g;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=s(f=>{p({type:"editValue",value:f.target.value})},"k"),e[5]=g):g=e[5];let O=g,V;e[6]===Symbol.for("react.memo_cache_sentinel")?(V=s(f=>{p({type:"editMetadata",value:f})},"K"),e[6]=V):V=e[6];let _=V,y;e[7]!==r.editedValue?(y=Fe(r.editedValue),e[7]=r.editedValue,e[8]=y):y=e[8];let m=y,h;e[9]!==r.editedMetadata?(h=Ke(r.editedMetadata),e[9]=r.editedMetadata,e[10]=h):h=e[10];let N=h,C;e[11]!==r.editedTtl?(C=Ve(r.editedTtl),e[11]=r.editedTtl,e[12]=C):C=e[12];let w=C,b;e[13]!==m?(b=s(()=>{m!==void 0&&p({type:"editValue",value:m})},"y"),e[13]=m,e[14]=b):b=e[14];let S=b,E;e[15]!==o||e[16]!==d||e[17]!==u||e[18]!==N||e[19]!==i||e[20]!==r.editedMetadata||e[21]!==r.editedTtl||e[22]!==r.editedValue||e[23]!==t?(E=s(()=>{if(!N){p({error:t("Metadata must be valid JSON."),type:"writeFailed"});return}p({type:"saveStart"}),z((async()=>{try{await o.putKvValue(Te({metadata:r.editedMetadata,ttl:r.editedTtl,value:r.editedValue},u,i,d)),p({type:"saveOk"})}catch(f){p({error:Z(f),type:"writeFailed"})}})())},"F"),e[15]=o,e[16]=d,e[17]=u,e[18]=N,e[19]=i,e[20]=r.editedMetadata,e[21]=r.editedTtl,e[22]=r.editedValue,e[23]=t,e[24]=E):E=e[24];let B=E,T;e[25]!==o||e[26]!==u||e[27]!==i||e[28]!==v?(T=s(()=>{p({type:"deleteStart"}),z((async()=>{try{await o.deleteKvKey({key:u,namespace:i}),v(u)}catch(f){p({error:Z(f),type:"writeFailed"})}})())},"V"),e[25]=o,e[26]=u,e[27]=i,e[28]=v,e[29]=T):T=e[29];let J=T,L;e[30]!==u?(L=s(()=>{de(u)},"A"),e[30]=u,e[31]=L):L=e[31];let M;e[32]!==t?(M=t("Copy key"),e[32]=t,e[33]=M):M=e[33];let n;e[34]!==L||e[35]!==M?(n=(0,a.jsx)("div",{className:"mb-2 flex justify-end",children:(0,a.jsx)($,{"data-testid":"kv-copy-key-btn",onClick:L,size:"sm",variant:"outline",children:M})}),e[34]=L,e[35]=M,e[36]=n):n=e[36];let k;e[37]!==r.loadError?(k=r.loadError!==null&&(0,a.jsx)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-value-error",role:"alert",children:r.loadError}),e[37]=r.loadError,e[38]=k):k=e[38];let F;e[39]!==r.loading||e[40]!==t?(F=r.loading&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-value-loading",children:t("Loading\u2026")}),e[39]=r.loading,e[40]=t,e[41]=F):F=e[41];let I;e[42]!==m||e[43]!==N||e[44]!==J||e[45]!==S||e[46]!==B||e[47]!==r.busy||e[48]!==r.editedMetadata||e[49]!==r.editedValue||e[50]!==r.loading||e[51]!==r.value||e[52]!==r.writeError||e[53]!==t||e[54]!==w?(I=!r.loading&&r.value!==null&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[(0,a.jsx)(q,{className:"text-xs",htmlFor:"kv-value-editor",children:t("Value")}),m!==void 0&&(0,a.jsx)(he,{variant:"secondary",children:t("JSON")}),(0,a.jsx)("span",{className:"ml-auto text-xs tabular-nums text-muted-foreground","data-testid":"kv-value-size",children:be(Je(r.editedValue))})]}),(0,a.jsx)("textarea",{"aria-label":t("KV value"),className:"mb-2 min-h-[8rem] w-full rounded border border-border bg-muted/30 p-2 font-mono text-xs","data-testid":"kv-value-editor",id:"kv-value-editor",onChange:O,value:r.editedValue}),(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap gap-2",children:[(0,a.jsx)($,{"data-testid":"kv-format-btn",disabled:m===void 0,onClick:S,size:"sm",variant:"outline",children:t("Format JSON")}),(0,a.jsx)($,{"data-testid":"kv-copy-value-btn",onClick:s(()=>{de(r.editedValue)},"onClick"),size:"sm",variant:"outline",children:t("Copy value")})]}),(0,a.jsx)(Me,{helper:t("Leave blank to keep the current expiration."),id:"kv-ttl-input",invalid:!w,onChange:s(f=>{p({type:"editTtl",value:f})},"onChange"),testId:"kv-ttl-input"}),(0,a.jsx)(Ie,{id:"kv-metadata-editor",invalidTestId:"kv-metadata-invalid",onChange:_,testId:"kv-metadata-editor",valid:N,value:r.editedMetadata}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)($,{"data-testid":"kv-save-btn",disabled:r.busy!==""||!N||!w,onClick:B,children:r.busy==="saving"?t("Saving\u2026"):t("Save")}),(0,a.jsx)($,{"data-testid":"kv-delete-btn",disabled:r.busy!=="",onClick:J,variant:"destructive",children:r.busy==="deleting"?t("Deleting\u2026"):t("Delete")})]}),r.writeError!==null&&(0,a.jsx)("p",{className:"mt-2 text-sm text-destructive","data-testid":"kv-save-error",role:"alert",children:r.writeError})]}),e[42]=m,e[43]=N,e[44]=J,e[45]=S,e[46]=B,e[47]=r.busy,e[48]=r.editedMetadata,e[49]=r.editedValue,e[50]=r.loading,e[51]=r.value,e[52]=r.writeError,e[53]=t,e[54]=w,e[55]=I):I=e[55];let K;e[56]!==r.loadError||e[57]!==r.loading||e[58]!==r.value||e[59]!==t?(K=!r.loading&&r.value===null&&r.loadError===null&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-absent",children:t("Key is absent or has no value.")}),e[56]=r.loadError,e[57]=r.loading,e[58]=r.value,e[59]=t,e[60]=K):K=e[60];let D;return e[61]!==n||e[62]!==k||e[63]!==F||e[64]!==I||e[65]!==K?(D=(0,a.jsxs)("div",{className:"px-4 pb-4","data-testid":"kv-value-section",children:[n,k,F,I,K]}),e[61]=n,e[62]=k,e[63]=F,e[64]=I,e[65]=K,e[66]=D):D=e[66],D},"He"),Se=100,Ze={appliedPrefix:"",bulk:[],bulkBusy:!1,bulkError:null,cursor:null,keys:null,listComplete:!1,loadError:null,loading:!1,prefixInput:"",reloadNonce:0,selectedKey:null},Re=s((l,e)=>{switch(e.type){case"appendPage":return{...l,cursor:e.cursor,keys:[...l.keys??[],...e.keys],listComplete:e.listComplete,loading:!1};case"applyFilter":return{...l,appliedPrefix:l.prefixInput,bulk:[],bulkError:null,cursor:null,keys:null,listComplete:!1,reloadNonce:l.reloadNonce+1,selectedKey:null};case"bulkDeleted":{let d=new Set(e.deleted);return{...l,bulk:l.bulk.filter(u=>!d.has(u)),bulkBusy:!1,bulkError:e.error,keys:l.keys===null?null:l.keys.filter(u=>!d.has(u.name)),selectedKey:l.selectedKey!==null&&d.has(l.selectedKey)?null:l.selectedKey}}case"bulkDeleteStart":return{...l,bulkBusy:!0,bulkError:null};case"firstPage":return{...l,cursor:e.cursor,keys:e.keys,listComplete:e.listComplete,loading:!1};case"keyDeleted":return{...l,bulk:l.bulk.filter(d=>d!==e.name),keys:l.keys===null?null:l.keys.filter(d=>d.name!==e.name),selectedKey:null};case"loadFailed":return{...l,loadError:e.error,loading:!1};case"loadStart":return{...l,loadError:null,loading:!0};case"prefixInput":return{...l,prefixInput:e.value};case"reload":return{...l,bulk:[],bulkError:null,reloadNonce:l.reloadNonce+1,selectedKey:null};case"selectKey":return{...l,selectedKey:e.name};case"toggleAllBulk":return{...l,bulk:e.names};case"toggleBulk":return{...l,bulk:l.bulk.includes(e.name)?l.bulk.filter(d=>d!==e.name):[...l.bulk,e.name]};default:return l}},"ze"),Ue=s(({namespace:l})=>{let e=G(),d=R(),[u,i]=(0,P.useReducer)(Re,Ze),{appliedPrefix:v,bulk:o,bulkBusy:t,bulkError:r,cursor:p,keys:c,listComplete:x,loadError:g,loading:O,prefixInput:V,reloadNonce:_,selectedKey:y}=u,[m,h]=(0,P.useState)(!1);(0,P.useEffect)(()=>{let n={cancelled:!1};return z((async()=>{i({type:"loadStart"});try{let k=await e.listKvKeys({limit:Se,namespace:l,prefix:v===""?void 0:v});n.cancelled||i({cursor:k.cursor??null,keys:k.keys,listComplete:k.listComplete,type:"firstPage"})}catch(k){n.cancelled||i({error:Z(k),type:"loadFailed"})}})()),()=>{n.cancelled=!0}},[e,l,v,_]);let N=s(n=>{i({type:"prefixInput",value:n.target.value})},"x"),C=s(()=>{i({type:"applyFilter"})},"N"),w=s(n=>{i({name:n.currentTarget.dataset.key??null,type:"selectKey"})},"C"),b=s(()=>{p!==null&&(i({type:"loadStart"}),z((async()=>{try{let n=await e.listKvKeys({cursor:p,limit:Se,namespace:l,prefix:v===""?void 0:v});i({cursor:n.cursor??null,keys:n.keys,listComplete:n.listComplete,type:"appendPage"})}catch(n){i({error:Z(n),type:"loadFailed"})}})()))},"y"),S=s(n=>{i({name:n,type:"keyDeleted"})},"S"),E=s(n=>{i({name:n,type:"toggleBulk"})},"F"),B=s(n=>{i({names:n&&c!==null?c.map(k=>k.name):[],type:"toggleAllBulk"})},"O"),T=s(()=>{if(o.length===0)return;let n=[...o];i({type:"bulkDeleteStart"}),z((async()=>{let k=await Promise.allSettled(n.map(K=>e.deleteKvKey({key:K,namespace:l}))),F=n.filter((K,D)=>k[D]?.status==="fulfilled"),I=n.length-F.length;i({deleted:F,error:I>0?d("Failed to delete {count} keys.",{count:I}):null,type:"bulkDeleted"})})())},"V"),J=s(()=>{h(!1),i({type:"reload"})},"D"),L=c!==null&&c.length>0&&o.length===c.length,M=new Set(o);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("section",{className:"border border-border bg-card p-3","data-testid":"kv-keys-section",children:[(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[(0,a.jsx)(ae,{"aria-label":d("Filter keys by prefix"),className:"min-w-[16rem] flex-1","data-testid":"kv-prefix-input",onChange:N,placeholder:d("Filter by prefix\u2026"),value:V}),(0,a.jsx)($,{"data-testid":"kv-filter-btn",disabled:O,onClick:C,children:d("Filter")}),(0,a.jsx)($,{"data-testid":"kv-new-key-btn",onClick:s(()=>{h(n=>!n)},"onClick"),variant:"outline",children:d("New key")}),o.length>0&&(0,a.jsx)($,{"data-testid":"kv-bulk-delete-btn",disabled:t,onClick:T,variant:"destructive",children:t?d("Deleting\u2026"):d("Delete {count}",{count:o.length})})]}),r!==null&&(0,a.jsx)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-bulk-error",role:"alert",children:r}),g!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"kv-keys-error",role:"alert",children:g}),c!==null&&c.length===0&&!O&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-no-keys",children:d("No keys.")}),c!==null&&c.length>0&&(0,a.jsx)(re,{className:"overflow-hidden py-0",children:(0,a.jsx)(ne,{className:"px-0",children:(0,a.jsxs)(ie,{"data-testid":"kv-key-table",children:[(0,a.jsx)(se,{children:(0,a.jsxs)(Q,{children:[(0,a.jsx)(X,{className:"w-10",children:(0,a.jsx)(ue,{"aria-label":d("Select all"),checked:L,"data-testid":"kv-select-all",onCheckedChange:B})}),(0,a.jsx)(X,{children:d("Key")}),(0,a.jsx)(X,{children:d("Expiration")})]})}),(0,a.jsx)(oe,{children:c.map(n=>(0,a.jsxs)(Q,{className:n.name===y?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-key":n.name,"data-testid":`kv-key-row-${n.name}`,onClick:w,children:[(0,a.jsx)(Y,{onClick:s(k=>{k.stopPropagation()},"onClick"),children:(0,a.jsx)(ue,{"aria-label":d("Select {name}",{name:n.name}),checked:M.has(n.name),"data-testid":`kv-select-${n.name}`,onCheckedChange:s(()=>{E(n.name)},"onCheckedChange")})}),(0,a.jsx)(Y,{className:"font-mono text-xs",children:n.name}),(0,a.jsx)(Y,{className:"tabular-nums text-xs",children:Le(n.expiration)})]},n.name))})]})})}),!x&&p!==null&&(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)($,{"data-testid":"kv-load-more",disabled:O,onClick:b,variant:"outline",children:d(O?"Loading\u2026":"Load more")})})]}),(0,a.jsx)(me,{onOpenChange:s(n=>{n||h(!1)},"onOpenChange"),open:m,children:(0,a.jsxs)(ve,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-create-sheet",side:"right",children:[(0,a.jsx)(pe,{children:(0,a.jsx)(ye,{children:d("New key")})}),(0,a.jsx)(je,{namespace:l,onCancel:s(()=>{h(!1)},"onCancel"),onCreated:J})]})}),(0,a.jsx)(me,{onOpenChange:s(n=>{n||i({name:null,type:"selectKey"})},"onOpenChange"),open:y!==null,children:(0,a.jsxs)(ve,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-editor-sheet",side:"right",children:[(0,a.jsx)(pe,{children:(0,a.jsx)(ye,{className:"truncate font-mono text-xs",children:y})}),y!==null&&(0,a.jsx)(He,{expiration:c?.find(n=>n.name===y)?.expiration,keyName:y,namespace:l,onDeleted:S},`${l}:${y}`)]})})]})},"Ue"),st=s(({loadNamespaces:l}={})=>{let e=G(),d=R(),[u,i]=(0,P.useState)(null),[v,o]=(0,P.useState)(null),[t,r]=(0,P.useState)(null);(0,P.useEffect)(()=>{let c={cancelled:!1};return z((async()=>{try{let x=await(l??(()=>e.listKvNamespaces()))();c.cancelled||(i(x),o(null),r(g=>g??x[0]?.binding??null))}catch(x){c.cancelled||(i(null),o(Z(x)))}})()),()=>{c.cancelled=!0}},[e,l]);let p=s(c=>{r(c.currentTarget.dataset.ns??null)},"v");return(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-kv-browser",children:[v!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"kv-ns-error",role:"alert",children:v}),u!==null&&u.length===0&&(0,a.jsx)(ke,{description:d("Add a kv_namespaces binding to wrangler.jsonc \u2014 it appears here automatically, no wiring needed."),icon:(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M5 5h14v4H5V5Zm0 5h14v4H5v-4Zm0 5h14v4H5v-4Z"})}),testId:"kv-empty",title:d("No KV namespaces.")}),u!==null&&u.length>0&&(0,a.jsx)(re,{className:"overflow-hidden py-0",children:(0,a.jsx)(ne,{className:"px-0",children:(0,a.jsxs)(ie,{"data-testid":"kv-namespace-table",children:[(0,a.jsx)(se,{children:(0,a.jsx)(Q,{children:(0,a.jsx)(X,{children:d("Namespace")})})}),(0,a.jsx)(oe,{children:u.map(c=>(0,a.jsx)(Q,{className:c.binding===t?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-ns":c.binding,"data-testid":`kv-ns-row-${c.binding}`,onClick:p,children:(0,a.jsx)(Y,{className:"font-mono text-xs",children:c.binding})},c.binding))})]})})}),t!==null&&(0,a.jsx)(Ue,{namespace:t},t)]})},"ut");export{st as KvBrowser};
1
+ import{a as ge,b as fe,c as xe,d as Ne,e as Ce}from"./chunk-IHMGCHAA.js";import"./chunk-4JLGLPWV.js";import"./chunk-V3CZW3JB.js";import{a as ce}from"./chunk-EA2JKR5D.js";import{a as ue}from"./chunk-3FBLWUXD.js";import{a as q}from"./chunk-IMOHEGMV.js";import{g as me,h as ve,i as pe,j as ye}from"./chunk-Y6SKU4M7.js";import"./chunk-Q4CAKBWN.js";import"./chunk-75OWNJEY.js";import"./chunk-RLLKECZT.js";import"./chunk-YPRQLCKF.js";import"./chunk-GMS77BZD.js";import"./chunk-3Q2P62UR.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import"./chunk-5WJXVZMZ.js";import"./chunk-EVTM6Q43.js";import"./chunk-K7AJEMKE.js";import"./chunk-6D6Z2KXU.js";import"./chunk-OKG3HWSJ.js";import{W as ae}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as $}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as he}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import"./chunk-35DM4JJG.js";import"./chunk-4ZEL6BYL.js";import"./chunk-7TRN7FQ4.js";import{f as G}from"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import"./chunk-GETL6R4M.js";import{a as ke}from"./chunk-FKVZRPV5.js";import{a as ie,b as se,c as oe,d as Q,e as X,f as Y}from"./chunk-HEAQVSNS.js";import{a as re,e as ne}from"./chunk-WUWBZPUK.js";import{d as R,h as Z,l as be,o as z,q as de}from"./chunk-FODLDLE2.js";import{a as s,d as le,e as Oe,f as _e,g as De}from"./chunk-YKXDMIHQ.js";var P=le(Oe(),1);var ee=le(_e(),1);var a=le(De(),1);var Be=s(l=>{let e=l.trim();if(e==="")return;let d=Number(e);return Number.isFinite(d)&&d>0?Math.floor(d):void 0},"Be"),Le=s(l=>l===void 0?"\u2014":new Date(l*1e3).toISOString(),"Oe"),Je=s(l=>new TextEncoder().encode(l).length,"Ae"),Fe=s(l=>{if(l.trim()!=="")try{return JSON.stringify(JSON.parse(l),void 0,2)}catch{return}},"ge"),Ke=s(l=>{if(l.trim()==="")return!0;try{return JSON.parse(l),!0}catch{return!1}},"xe"),Ee=[{key:"seconds",seconds:1},{key:"minutes",seconds:60},{key:"hours",seconds:3600},{key:"days",seconds:86400}],we=s((l,e)=>{let d=l.trim();if(d==="")return"";let u=Number(d),i=Ee.find(v=>v.key===e)?.seconds??1;return Number.isFinite(u)&&u>0?String(Math.round(u*i)):d},"ue"),Ve=s(l=>{let e=l.trim();if(e==="")return!0;let d=Number(e);return Number.isInteger(d)&&d>=60},"Ce"),Te=s((l,e,d,u)=>{let i=Be(l.ttl);return{expiration:i===void 0?u:void 0,expirationTtl:i,key:e,metadata:l.metadata.trim()===""?void 0:JSON.parse(l.metadata),namespace:d,value:l.value}},"Se"),Me=s(l=>{let e=(0,ee.c)(60),{helper:d,id:u,invalid:i,onChange:v,testId:o}=l,t=R(),[r,p]=(0,P.useState)(""),[c,x]=(0,P.useState)("seconds"),g;e[0]!==v||e[1]!==c?(g=s(f=>{p(f.target.value),v(we(f.target.value,c))},"k"),e[0]=v,e[1]=c,e[2]=g):g=e[2];let O=g,V;e[3]!==r||e[4]!==v?(V=s(f=>{f!==null&&(x(f),v(we(r,f)))},"K"),e[3]=r,e[4]=v,e[5]=V):V=e[5];let _=V,y;e[6]!==t?(y=t("days"),e[6]=t,e[7]=y):y=e[7];let m;e[8]!==t?(m=t("hours"),e[8]=t,e[9]=m):m=e[9];let h;e[10]!==t?(h=t("minutes"),e[10]=t,e[11]=h):h=e[11];let N;e[12]!==t?(N=t("seconds"),e[12]=t,e[13]=N):N=e[13];let C;e[14]!==y||e[15]!==m||e[16]!==h||e[17]!==N?(C={days:y,hours:m,minutes:h,seconds:N},e[14]=y,e[15]=m,e[16]=h,e[17]=N,e[18]=C):C=e[18];let w=C,b;e[19]!==t?(b=t("Expires after"),e[19]=t,e[20]=b):b=e[20];let S;e[21]!==u||e[22]!==b?(S=(0,a.jsx)(q,{className:"text-xs",htmlFor:u,children:b}),e[21]=u,e[22]=b,e[23]=S):S=e[23];let E;e[24]!==t?(E=t("No expiration"),e[24]=t,e[25]=E):E=e[25];let B;e[26]!==r||e[27]!==u||e[28]!==i||e[29]!==O||e[30]!==E||e[31]!==o?(B=(0,a.jsx)(ae,{"aria-invalid":i,className:"flex-1","data-testid":o,id:u,inputMode:"numeric",onChange:O,placeholder:E,value:r}),e[26]=r,e[27]=u,e[28]=i,e[29]=O,e[30]=E,e[31]=o,e[32]=B):B=e[32];let T;e[33]!==t?(T=t("TTL unit"),e[33]=t,e[34]=T):T=e[34];let J=`${o}-unit`,L;e[35]===Symbol.for("react.memo_cache_sentinel")?(L=(0,a.jsx)(fe,{}),e[35]=L):L=e[35];let M;e[36]!==T||e[37]!==J?(M=(0,a.jsx)(xe,{"aria-label":T,className:"w-[7.5rem]","data-testid":J,children:L}),e[36]=T,e[37]=J,e[38]=M):M=e[38];let n;e[39]!==w?(n=Ee.map(f=>(0,a.jsx)(Ce,{value:f.key,children:w[f.key]},f.key)),e[39]=w,e[40]=n):n=e[40];let k;e[41]!==n?(k=(0,a.jsx)(Ne,{children:n}),e[41]=n,e[42]=k):k=e[42];let F;e[43]!==_||e[44]!==M||e[45]!==k||e[46]!==c?(F=(0,a.jsxs)(ge,{onValueChange:_,value:c,children:[M,k]}),e[43]=_,e[44]=M,e[45]=k,e[46]=c,e[47]=F):F=e[47];let I;e[48]!==B||e[49]!==F?(I=(0,a.jsxs)("div",{className:"flex gap-2",children:[B,F]}),e[48]=B,e[49]=F,e[50]=I):I=e[50];let K;e[51]!==d||e[52]!==i||e[53]!==t||e[54]!==o?(K=i?(0,a.jsx)("p",{className:"text-xs text-destructive","data-testid":`${o}-invalid`,children:t("TTL must be at least 60 seconds.")}):d!==void 0&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:d}),e[51]=d,e[52]=i,e[53]=t,e[54]=o,e[55]=K):K=e[55];let D;return e[56]!==I||e[57]!==K||e[58]!==S?(D=(0,a.jsxs)("div",{className:"mb-3 grid gap-1",children:[S,I,K]}),e[56]=I,e[57]=K,e[58]=S,e[59]=D):D=e[59],D},"we"),Ie=s(l=>{let e=(0,ee.c)(36),{id:d,invalidTestId:u,onChange:i,testId:v,valid:o,value:t}=l,r=R(),p;e[0]!==t?(p=Fe(t),e[0]=t,e[1]=p):p=e[1];let c=p,x;e[2]!==r?(x=r("Metadata (JSON)"),e[2]=r,e[3]=x):x=e[3];let g;e[4]!==d||e[5]!==x?(g=(0,a.jsx)(q,{className:"text-xs",htmlFor:d,children:x}),e[4]=d,e[5]=x,e[6]=g):g=e[6];let O=`${v}-format`,V=c===void 0,_;e[7]!==c||e[8]!==i?(_=s(()=>{c!==void 0&&i(c)},"L"),e[7]=c,e[8]=i,e[9]=_):_=e[9];let y;e[10]!==r?(y=r("Format JSON"),e[10]=r,e[11]=y):y=e[11];let m;e[12]!==O||e[13]!==V||e[14]!==_||e[15]!==y?(m=(0,a.jsx)($,{"data-testid":O,disabled:V,onClick:_,size:"sm",variant:"outline",children:y}),e[12]=O,e[13]=V,e[14]=_,e[15]=y,e[16]=m):m=e[16];let h;e[17]!==g||e[18]!==m?(h=(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[g,m]}),e[17]=g,e[18]=m,e[19]=h):h=e[19];let N=!o,C;e[20]!==i?(C=s(E=>{i(E.target.value)},"N"),e[20]=i,e[21]=C):C=e[21];let w;e[22]!==d||e[23]!==N||e[24]!==C||e[25]!==v||e[26]!==t?(w=(0,a.jsx)(ce,{"aria-invalid":N,className:"min-h-[4rem] font-mono text-xs","data-testid":v,id:d,onChange:C,value:t}),e[22]=d,e[23]=N,e[24]=C,e[25]=v,e[26]=t,e[27]=w):w=e[27];let b;e[28]!==u||e[29]!==r||e[30]!==o?(b=!o&&(0,a.jsx)("p",{className:"text-xs text-destructive","data-testid":u,children:r("Metadata must be valid JSON.")}),e[28]=u,e[29]=r,e[30]=o,e[31]=b):b=e[31];let S;return e[32]!==w||e[33]!==b||e[34]!==h?(S=(0,a.jsxs)("div",{className:"mb-3 grid gap-1",children:[h,w,b]}),e[32]=w,e[33]=b,e[34]=h,e[35]=S):S=e[35],S},"Te"),Pe={busy:!1,error:null,metadata:"",name:"",ttl:"",value:""},$e=s((l,e)=>{switch(e.type){case"setField":return{...l,[e.field]:e.value};case"submitFailed":return{...l,busy:!1,error:e.error};case"submitStart":return{...l,busy:!0,error:null};default:return l}},"Je"),je=s(l=>{let e=(0,ee.c)(73),{namespace:d,onCancel:u,onCreated:i}=l,v=G(),o=R(),[t,r]=(0,P.useReducer)($e,Pe),p;e[0]!==t.metadata?(p=Ke(t.metadata),e[0]=t.metadata,e[1]=p):p=e[1];let c=p,x;e[2]!==t.ttl?(x=Ve(t.ttl),e[2]=t.ttl,e[3]=x):x=e[3];let g=x,O;e[4]!==c||e[5]!==t.busy||e[6]!==t.name||e[7]!==g?(O=t.name.trim()!==""&&c&&g&&!t.busy,e[4]=c,e[5]=t.busy,e[6]=t.name,e[7]=g,e[8]=O):O=e[8];let V=O,_;e[9]!==V||e[10]!==v||e[11]!==d||e[12]!==i||e[13]!==t.metadata||e[14]!==t.name||e[15]!==t.ttl||e[16]!==t.value?(_=s(()=>{V&&(r({type:"submitStart"}),z((async()=>{try{await v.putKvValue(Te({metadata:t.metadata,ttl:t.ttl,value:t.value},t.name,d)),i()}catch(A){r({error:Z(A),type:"submitFailed"})}})()))},"L"),e[9]=V,e[10]=v,e[11]=d,e[12]=i,e[13]=t.metadata,e[14]=t.name,e[15]=t.ttl,e[16]=t.value,e[17]=_):_=e[17];let y=_,m;e[18]!==o?(m=o("Key name"),e[18]=o,e[19]=m):m=e[19];let h;e[20]!==m?(h=(0,a.jsx)(q,{className:"text-xs",htmlFor:"kv-create-name",children:m}),e[20]=m,e[21]=h):h=e[21];let N;e[22]===Symbol.for("react.memo_cache_sentinel")?(N=s(A=>{r({field:"name",type:"setField",value:A.target.value})},"x"),e[22]=N):N=e[22];let C;e[23]!==o?(C=o("Key name"),e[23]=o,e[24]=C):C=e[24];let w;e[25]!==t.name||e[26]!==C?(w=(0,a.jsx)(ae,{autoFocus:!0,"data-testid":"kv-create-name",id:"kv-create-name",onChange:N,placeholder:C,value:t.name}),e[25]=t.name,e[26]=C,e[27]=w):w=e[27];let b;e[28]!==h||e[29]!==w?(b=(0,a.jsxs)("div",{className:"grid gap-1",children:[h,w]}),e[28]=h,e[29]=w,e[30]=b):b=e[30];let S;e[31]!==o?(S=o("Value"),e[31]=o,e[32]=S):S=e[32];let E;e[33]!==S?(E=(0,a.jsx)(q,{className:"text-xs",htmlFor:"kv-create-value",children:S}),e[33]=S,e[34]=E):E=e[34];let B;e[35]===Symbol.for("react.memo_cache_sentinel")?(B=s(A=>{r({field:"value",type:"setField",value:A.target.value})},"O"),e[35]=B):B=e[35];let T;e[36]!==t.value?(T=(0,a.jsx)(ce,{className:"min-h-[6rem] font-mono text-xs","data-testid":"kv-create-value",id:"kv-create-value",onChange:B,value:t.value}),e[36]=t.value,e[37]=T):T=e[37];let J;e[38]!==E||e[39]!==T?(J=(0,a.jsxs)("div",{className:"grid gap-1",children:[E,T]}),e[38]=E,e[39]=T,e[40]=J):J=e[40];let L=!g,M;e[41]===Symbol.for("react.memo_cache_sentinel")?(M=s(A=>{r({field:"ttl",type:"setField",value:A})},"I"),e[41]=M):M=e[41];let n;e[42]!==L?(n=(0,a.jsx)(Me,{id:"kv-create-ttl",invalid:L,onChange:M,testId:"kv-create-ttl"}),e[42]=L,e[43]=n):n=e[43];let k;e[44]===Symbol.for("react.memo_cache_sentinel")?(k=s(A=>{r({field:"metadata",type:"setField",value:A})},"h"),e[44]=k):k=e[44];let F;e[45]!==c||e[46]!==t.metadata?(F=(0,a.jsx)(Ie,{id:"kv-create-metadata",invalidTestId:"kv-create-metadata-invalid",onChange:k,testId:"kv-create-metadata",valid:c,value:t.metadata}),e[45]=c,e[46]=t.metadata,e[47]=F):F=e[47];let I=!V,K;e[48]!==t.busy||e[49]!==o?(K=t.busy?o("Creating\u2026"):o("Create key"),e[48]=t.busy,e[49]=o,e[50]=K):K=e[50];let D;e[51]!==y||e[52]!==I||e[53]!==K?(D=(0,a.jsx)($,{"data-testid":"kv-create-submit",disabled:I,onClick:y,children:K}),e[51]=y,e[52]=I,e[53]=K,e[54]=D):D=e[54];let f=t.busy,j;e[55]!==o?(j=o("Cancel"),e[55]=o,e[56]=j):j=e[56];let H;e[57]!==u||e[58]!==t.busy||e[59]!==j?(H=(0,a.jsx)($,{"data-testid":"kv-create-cancel",disabled:f,onClick:u,variant:"outline",children:j}),e[57]=u,e[58]=t.busy,e[59]=j,e[60]=H):H=e[60];let U;e[61]!==D||e[62]!==H?(U=(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[D,H]}),e[61]=D,e[62]=H,e[63]=U):U=e[63];let W;e[64]!==t.error?(W=t.error!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"kv-create-error",role:"alert",children:t.error}),e[64]=t.error,e[65]=W):W=e[65];let te;return e[66]!==b||e[67]!==J||e[68]!==n||e[69]!==F||e[70]!==U||e[71]!==W?(te=(0,a.jsxs)("div",{className:"grid gap-3 px-4 pb-4","data-testid":"kv-create-form",children:[b,J,n,F,U,W]}),e[66]=b,e[67]=J,e[68]=n,e[69]=F,e[70]=U,e[71]=W,e[72]=te):te=e[72],te},"Pe"),Ae={busy:"",editedMetadata:"",editedTtl:"",editedValue:"",loadError:null,loading:!0,value:null,writeError:null},ze=s((l,e)=>{switch(e.type){case"deleteStart":return{...l,busy:"deleting",writeError:null};case"editMetadata":return{...l,editedMetadata:e.value};case"editTtl":return{...l,editedTtl:e.value};case"editValue":return{...l,editedValue:e.value};case"loaded":return{...l,editedMetadata:e.metadata===null||e.metadata===void 0?"":JSON.stringify(e.metadata,null,2),editedValue:e.value??"",loading:!1,value:e.value};case"loadFailed":return{...l,loadError:e.error,loading:!1};case"saveOk":return{...l,busy:"",value:l.editedValue};case"saveStart":return{...l,busy:"saving",writeError:null};case"writeFailed":return{...l,busy:"",writeError:e.error};default:return l}},"je"),He=s(l=>{let e=(0,ee.c)(67),{expiration:d,keyName:u,namespace:i,onDeleted:v}=l,o=G(),t=R(),[r,p]=(0,P.useReducer)(ze,Ae),c,x;e[0]!==o||e[1]!==u||e[2]!==i?(c=s(()=>{let f={cancelled:!1};return z((async()=>{try{let j=await o.getKvValue({key:u,namespace:i});f.cancelled||p({metadata:j.metadata,type:"loaded",value:j.value})}catch(j){let H=j;f.cancelled||p({error:Z(H),type:"loadFailed"})}})()),()=>{f.cancelled=!0}},"o"),x=[o,i,u],e[0]=o,e[1]=u,e[2]=i,e[3]=c,e[4]=x):(c=e[3],x=e[4]),(0,P.useEffect)(c,x);let g;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=s(f=>{p({type:"editValue",value:f.target.value})},"k"),e[5]=g):g=e[5];let O=g,V;e[6]===Symbol.for("react.memo_cache_sentinel")?(V=s(f=>{p({type:"editMetadata",value:f})},"K"),e[6]=V):V=e[6];let _=V,y;e[7]!==r.editedValue?(y=Fe(r.editedValue),e[7]=r.editedValue,e[8]=y):y=e[8];let m=y,h;e[9]!==r.editedMetadata?(h=Ke(r.editedMetadata),e[9]=r.editedMetadata,e[10]=h):h=e[10];let N=h,C;e[11]!==r.editedTtl?(C=Ve(r.editedTtl),e[11]=r.editedTtl,e[12]=C):C=e[12];let w=C,b;e[13]!==m?(b=s(()=>{m!==void 0&&p({type:"editValue",value:m})},"y"),e[13]=m,e[14]=b):b=e[14];let S=b,E;e[15]!==o||e[16]!==d||e[17]!==u||e[18]!==N||e[19]!==i||e[20]!==r.editedMetadata||e[21]!==r.editedTtl||e[22]!==r.editedValue||e[23]!==t?(E=s(()=>{if(!N){p({error:t("Metadata must be valid JSON."),type:"writeFailed"});return}p({type:"saveStart"}),z((async()=>{try{await o.putKvValue(Te({metadata:r.editedMetadata,ttl:r.editedTtl,value:r.editedValue},u,i,d)),p({type:"saveOk"})}catch(f){p({error:Z(f),type:"writeFailed"})}})())},"F"),e[15]=o,e[16]=d,e[17]=u,e[18]=N,e[19]=i,e[20]=r.editedMetadata,e[21]=r.editedTtl,e[22]=r.editedValue,e[23]=t,e[24]=E):E=e[24];let B=E,T;e[25]!==o||e[26]!==u||e[27]!==i||e[28]!==v?(T=s(()=>{p({type:"deleteStart"}),z((async()=>{try{await o.deleteKvKey({key:u,namespace:i}),v(u)}catch(f){p({error:Z(f),type:"writeFailed"})}})())},"V"),e[25]=o,e[26]=u,e[27]=i,e[28]=v,e[29]=T):T=e[29];let J=T,L;e[30]!==u?(L=s(()=>{de(u)},"A"),e[30]=u,e[31]=L):L=e[31];let M;e[32]!==t?(M=t("Copy key"),e[32]=t,e[33]=M):M=e[33];let n;e[34]!==L||e[35]!==M?(n=(0,a.jsx)("div",{className:"mb-2 flex justify-end",children:(0,a.jsx)($,{"data-testid":"kv-copy-key-btn",onClick:L,size:"sm",variant:"outline",children:M})}),e[34]=L,e[35]=M,e[36]=n):n=e[36];let k;e[37]!==r.loadError?(k=r.loadError!==null&&(0,a.jsx)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-value-error",role:"alert",children:r.loadError}),e[37]=r.loadError,e[38]=k):k=e[38];let F;e[39]!==r.loading||e[40]!==t?(F=r.loading&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-value-loading",children:t("Loading\u2026")}),e[39]=r.loading,e[40]=t,e[41]=F):F=e[41];let I;e[42]!==m||e[43]!==N||e[44]!==J||e[45]!==S||e[46]!==B||e[47]!==r.busy||e[48]!==r.editedMetadata||e[49]!==r.editedValue||e[50]!==r.loading||e[51]!==r.value||e[52]!==r.writeError||e[53]!==t||e[54]!==w?(I=!r.loading&&r.value!==null&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[(0,a.jsx)(q,{className:"text-xs",htmlFor:"kv-value-editor",children:t("Value")}),m!==void 0&&(0,a.jsx)(he,{variant:"secondary",children:t("JSON")}),(0,a.jsx)("span",{className:"ml-auto text-xs tabular-nums text-muted-foreground","data-testid":"kv-value-size",children:be(Je(r.editedValue))})]}),(0,a.jsx)("textarea",{"aria-label":t("KV value"),className:"mb-2 min-h-[8rem] w-full rounded border border-border bg-muted/30 p-2 font-mono text-xs","data-testid":"kv-value-editor",id:"kv-value-editor",onChange:O,value:r.editedValue}),(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap gap-2",children:[(0,a.jsx)($,{"data-testid":"kv-format-btn",disabled:m===void 0,onClick:S,size:"sm",variant:"outline",children:t("Format JSON")}),(0,a.jsx)($,{"data-testid":"kv-copy-value-btn",onClick:s(()=>{de(r.editedValue)},"onClick"),size:"sm",variant:"outline",children:t("Copy value")})]}),(0,a.jsx)(Me,{helper:t("Leave blank to keep the current expiration."),id:"kv-ttl-input",invalid:!w,onChange:s(f=>{p({type:"editTtl",value:f})},"onChange"),testId:"kv-ttl-input"}),(0,a.jsx)(Ie,{id:"kv-metadata-editor",invalidTestId:"kv-metadata-invalid",onChange:_,testId:"kv-metadata-editor",valid:N,value:r.editedMetadata}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)($,{"data-testid":"kv-save-btn",disabled:r.busy!==""||!N||!w,onClick:B,children:r.busy==="saving"?t("Saving\u2026"):t("Save")}),(0,a.jsx)($,{"data-testid":"kv-delete-btn",disabled:r.busy!=="",onClick:J,variant:"destructive",children:r.busy==="deleting"?t("Deleting\u2026"):t("Delete")})]}),r.writeError!==null&&(0,a.jsx)("p",{className:"mt-2 text-sm text-destructive","data-testid":"kv-save-error",role:"alert",children:r.writeError})]}),e[42]=m,e[43]=N,e[44]=J,e[45]=S,e[46]=B,e[47]=r.busy,e[48]=r.editedMetadata,e[49]=r.editedValue,e[50]=r.loading,e[51]=r.value,e[52]=r.writeError,e[53]=t,e[54]=w,e[55]=I):I=e[55];let K;e[56]!==r.loadError||e[57]!==r.loading||e[58]!==r.value||e[59]!==t?(K=!r.loading&&r.value===null&&r.loadError===null&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-absent",children:t("Key is absent or has no value.")}),e[56]=r.loadError,e[57]=r.loading,e[58]=r.value,e[59]=t,e[60]=K):K=e[60];let D;return e[61]!==n||e[62]!==k||e[63]!==F||e[64]!==I||e[65]!==K?(D=(0,a.jsxs)("div",{className:"px-4 pb-4","data-testid":"kv-value-section",children:[n,k,F,I,K]}),e[61]=n,e[62]=k,e[63]=F,e[64]=I,e[65]=K,e[66]=D):D=e[66],D},"He"),Se=100,Ze={appliedPrefix:"",bulk:[],bulkBusy:!1,bulkError:null,cursor:null,keys:null,listComplete:!1,loadError:null,loading:!1,prefixInput:"",reloadNonce:0,selectedKey:null},Re=s((l,e)=>{switch(e.type){case"appendPage":return{...l,cursor:e.cursor,keys:[...l.keys??[],...e.keys],listComplete:e.listComplete,loading:!1};case"applyFilter":return{...l,appliedPrefix:l.prefixInput,bulk:[],bulkError:null,cursor:null,keys:null,listComplete:!1,reloadNonce:l.reloadNonce+1,selectedKey:null};case"bulkDeleted":{let d=new Set(e.deleted);return{...l,bulk:l.bulk.filter(u=>!d.has(u)),bulkBusy:!1,bulkError:e.error,keys:l.keys===null?null:l.keys.filter(u=>!d.has(u.name)),selectedKey:l.selectedKey!==null&&d.has(l.selectedKey)?null:l.selectedKey}}case"bulkDeleteStart":return{...l,bulkBusy:!0,bulkError:null};case"firstPage":return{...l,cursor:e.cursor,keys:e.keys,listComplete:e.listComplete,loading:!1};case"keyDeleted":return{...l,bulk:l.bulk.filter(d=>d!==e.name),keys:l.keys===null?null:l.keys.filter(d=>d.name!==e.name),selectedKey:null};case"loadFailed":return{...l,loadError:e.error,loading:!1};case"loadStart":return{...l,loadError:null,loading:!0};case"prefixInput":return{...l,prefixInput:e.value};case"reload":return{...l,bulk:[],bulkError:null,reloadNonce:l.reloadNonce+1,selectedKey:null};case"selectKey":return{...l,selectedKey:e.name};case"toggleAllBulk":return{...l,bulk:e.names};case"toggleBulk":return{...l,bulk:l.bulk.includes(e.name)?l.bulk.filter(d=>d!==e.name):[...l.bulk,e.name]};default:return l}},"ze"),Ue=s(({namespace:l})=>{let e=G(),d=R(),[u,i]=(0,P.useReducer)(Re,Ze),{appliedPrefix:v,bulk:o,bulkBusy:t,bulkError:r,cursor:p,keys:c,listComplete:x,loadError:g,loading:O,prefixInput:V,reloadNonce:_,selectedKey:y}=u,[m,h]=(0,P.useState)(!1);(0,P.useEffect)(()=>{let n={cancelled:!1};return z((async()=>{i({type:"loadStart"});try{let k=await e.listKvKeys({limit:Se,namespace:l,prefix:v===""?void 0:v});n.cancelled||i({cursor:k.cursor??null,keys:k.keys,listComplete:k.listComplete,type:"firstPage"})}catch(k){n.cancelled||i({error:Z(k),type:"loadFailed"})}})()),()=>{n.cancelled=!0}},[e,l,v,_]);let N=s(n=>{i({type:"prefixInput",value:n.target.value})},"x"),C=s(()=>{i({type:"applyFilter"})},"N"),w=s(n=>{i({name:n.currentTarget.dataset.key??null,type:"selectKey"})},"C"),b=s(()=>{p!==null&&(i({type:"loadStart"}),z((async()=>{try{let n=await e.listKvKeys({cursor:p,limit:Se,namespace:l,prefix:v===""?void 0:v});i({cursor:n.cursor??null,keys:n.keys,listComplete:n.listComplete,type:"appendPage"})}catch(n){i({error:Z(n),type:"loadFailed"})}})()))},"y"),S=s(n=>{i({name:n,type:"keyDeleted"})},"S"),E=s(n=>{i({name:n,type:"toggleBulk"})},"F"),B=s(n=>{i({names:n&&c!==null?c.map(k=>k.name):[],type:"toggleAllBulk"})},"O"),T=s(()=>{if(o.length===0)return;let n=[...o];i({type:"bulkDeleteStart"}),z((async()=>{let k=await Promise.allSettled(n.map(K=>e.deleteKvKey({key:K,namespace:l}))),F=n.filter((K,D)=>k[D]?.status==="fulfilled"),I=n.length-F.length;i({deleted:F,error:I>0?d("Failed to delete {count} keys.",{count:I}):null,type:"bulkDeleted"})})())},"V"),J=s(()=>{h(!1),i({type:"reload"})},"D"),L=c!==null&&c.length>0&&o.length===c.length,M=new Set(o);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("section",{className:"border border-border bg-card p-3","data-testid":"kv-keys-section",children:[(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[(0,a.jsx)(ae,{"aria-label":d("Filter keys by prefix"),className:"min-w-[16rem] flex-1","data-testid":"kv-prefix-input",onChange:N,placeholder:d("Filter by prefix\u2026"),value:V}),(0,a.jsx)($,{"data-testid":"kv-filter-btn",disabled:O,onClick:C,children:d("Filter")}),(0,a.jsx)($,{"data-testid":"kv-new-key-btn",onClick:s(()=>{h(n=>!n)},"onClick"),variant:"outline",children:d("New key")}),o.length>0&&(0,a.jsx)($,{"data-testid":"kv-bulk-delete-btn",disabled:t,onClick:T,variant:"destructive",children:t?d("Deleting\u2026"):d("Delete {count}",{count:o.length})})]}),r!==null&&(0,a.jsx)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-bulk-error",role:"alert",children:r}),g!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"kv-keys-error",role:"alert",children:g}),c!==null&&c.length===0&&!O&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-no-keys",children:d("No keys.")}),c!==null&&c.length>0&&(0,a.jsx)(re,{className:"overflow-hidden py-0",children:(0,a.jsx)(ne,{className:"px-0",children:(0,a.jsxs)(ie,{"data-testid":"kv-key-table",children:[(0,a.jsx)(se,{children:(0,a.jsxs)(Q,{children:[(0,a.jsx)(X,{className:"w-10",children:(0,a.jsx)(ue,{"aria-label":d("Select all"),checked:L,"data-testid":"kv-select-all",onCheckedChange:B})}),(0,a.jsx)(X,{children:d("Key")}),(0,a.jsx)(X,{children:d("Expiration")})]})}),(0,a.jsx)(oe,{children:c.map(n=>(0,a.jsxs)(Q,{className:n.name===y?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-key":n.name,"data-testid":`kv-key-row-${n.name}`,onClick:w,children:[(0,a.jsx)(Y,{onClick:s(k=>{k.stopPropagation()},"onClick"),children:(0,a.jsx)(ue,{"aria-label":d("Select {name}",{name:n.name}),checked:M.has(n.name),"data-testid":`kv-select-${n.name}`,onCheckedChange:s(()=>{E(n.name)},"onCheckedChange")})}),(0,a.jsx)(Y,{className:"font-mono text-xs",children:n.name}),(0,a.jsx)(Y,{className:"tabular-nums text-xs",children:Le(n.expiration)})]},n.name))})]})})}),!x&&p!==null&&(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)($,{"data-testid":"kv-load-more",disabled:O,onClick:b,variant:"outline",children:d(O?"Loading\u2026":"Load more")})})]}),(0,a.jsx)(me,{onOpenChange:s(n=>{n||h(!1)},"onOpenChange"),open:m,children:(0,a.jsxs)(ve,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-create-sheet",side:"right",children:[(0,a.jsx)(pe,{children:(0,a.jsx)(ye,{children:d("New key")})}),(0,a.jsx)(je,{namespace:l,onCancel:s(()=>{h(!1)},"onCancel"),onCreated:J})]})}),(0,a.jsx)(me,{onOpenChange:s(n=>{n||i({name:null,type:"selectKey"})},"onOpenChange"),open:y!==null,children:(0,a.jsxs)(ve,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-editor-sheet",side:"right",children:[(0,a.jsx)(pe,{children:(0,a.jsx)(ye,{className:"truncate font-mono text-xs",children:y})}),y!==null&&(0,a.jsx)(He,{expiration:c?.find(n=>n.name===y)?.expiration,keyName:y,namespace:l,onDeleted:S},`${l}:${y}`)]})})]})},"Ue"),st=s(({loadNamespaces:l}={})=>{let e=G(),d=R(),[u,i]=(0,P.useState)(null),[v,o]=(0,P.useState)(null),[t,r]=(0,P.useState)(null);(0,P.useEffect)(()=>{let c={cancelled:!1};return z((async()=>{try{let x=await(l??(()=>e.listKvNamespaces()))();c.cancelled||(i(x),o(null),r(g=>g??x[0]?.binding??null))}catch(x){c.cancelled||(i(null),o(Z(x)))}})()),()=>{c.cancelled=!0}},[e,l]);let p=s(c=>{r(c.currentTarget.dataset.ns??null)},"v");return(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-kv-browser",children:[v!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"kv-ns-error",role:"alert",children:v}),u!==null&&u.length===0&&(0,a.jsx)(ke,{description:d("Add a kv_namespaces binding to wrangler.jsonc \u2014 it appears here automatically, no wiring needed."),icon:(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M5 5h14v4H5V5Zm0 5h14v4H5v-4Zm0 5h14v4H5v-4Z"})}),testId:"kv-empty",title:d("No KV namespaces.")}),u!==null&&u.length>0&&(0,a.jsx)(re,{className:"overflow-hidden py-0",children:(0,a.jsx)(ne,{className:"px-0",children:(0,a.jsxs)(ie,{"data-testid":"kv-namespace-table",children:[(0,a.jsx)(se,{children:(0,a.jsx)(Q,{children:(0,a.jsx)(X,{children:d("Namespace")})})}),(0,a.jsx)(oe,{children:u.map(c=>(0,a.jsx)(Q,{className:c.binding===t?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-ns":c.binding,"data-testid":`kv-ns-row-${c.binding}`,onClick:p,children:(0,a.jsx)(Y,{className:"font-mono text-xs",children:c.binding})},c.binding))})]})})}),t!==null&&(0,a.jsx)(Ue,{namespace:t},t)]})},"ut");export{st as KvBrowser};
@@ -1 +1 @@
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
+ import{a as s}from"./chunk-7TRN7FQ4.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{a as D}from"./chunk-BOTGXX4H.js";import{b as C}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import"./chunk-35DM4JJG.js";import{a as L}from"./chunk-4ZEL6BYL.js";import{c as $}from"./chunk-SDHFSBNM.js";import"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as I}from"./chunk-FKVZRPV5.js";import{a as T,b as k,c as A,d as g,e as c,f as l}from"./chunk-HEAQVSNS.js";import{a as b,e as S}from"./chunk-WUWBZPUK.js";import{d as w}from"./chunk-FODLDLE2.js";import{a as f,d as y,f as _,g as j}from"./chunk-YKXDMIHQ.js";var O=y(_(),1);var t=y(j(),1);var E="container:",M={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},B=f(e=>{let n=e.indexOf(":");if(n===-1)return{event:e.trim()};let r=e.slice(n+1).trim(),a=e.slice(0,n).trim();return r===""?{event:a}:{detail:r,event:a}},"B"),P=f(e=>{let n=new Map;for(let r of e){let a=r.functionPath??"";if(!a.startsWith(E))continue;let i=a.slice(E.length);if(i==="")continue;let s=JSON.stringify([i,r.instance??""]),o=n.get(s);if(o!==void 0&&o.timestamp>=r.timestamp)continue;let{detail:p,event:d}=B(r.message);n.set(s,{detail:p,event:d,exitCode:r.exitCode,instance:r.instance,level:r.level,name:i,state:M[d]??"unknown",timestamp:r.timestamp})}return[...n.values()].toSorted((r,a)=>r.name.localeCompare(a.name)||(r.instance??"").localeCompare(a.instance??""))},"D"),W={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},q=f(e=>{let{entries:n}=e??{};return Array.isArray(n)?n:[]},"P"),V=f(()=>{let e=(0,O.c)(19),n=w(),r,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},a={live:!0,shardKey:""},e[0]=r,e[1]=a):(r=e[0],a=e[1]);let{data:i,error:s,liveError:o}=$(L.getLogs,r,a),p=i!==void 0,d;if(e[2]!==i||e[3]!==s||e[4]!==o||e[5]!==p||e[6]!==n){let N=P(q(i)),x;e[8]!==s?(x=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:s}),e[8]=s,e[9]=x):x=e[9];let m;e[10]!==n?(m=n("Cloudflare Containers are observed from their lifecycle log stream. This shows the current state per instance \u2014 ports and health checks aren't carried in that stream."),e[10]=n,e[11]=m):m=e[11];let u;e[12]!==m?(u=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:m}),e[12]=m,e[13]=u):u=e[13];let h;e[14]!==o?(h=(0,t.jsx)(D,{message:o,prefix:"containers"}),e[14]=o,e[15]=h):h=e[15];let v;e[16]!==u||e[17]!==h?(v=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[u,h]}),e[16]=u,e[17]=h,e[18]=v):v=e[18],d=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[x,v,p&&N.length===0?(0,t.jsx)(I,{description:n("No container lifecycle activity yet. Instances declared with defineContainer show up here once they start, sleep, stop, or error."),testId:"containers-empty",title:n("No container activity")}):(0,t.jsx)(b,{className:"overflow-hidden py-0",children:(0,t.jsx)(S,{className:"px-0",children:(0,t.jsxs)(T,{"data-testid":"containers-table",children:[(0,t.jsx)(k,{children:(0,t.jsxs)(g,{children:[(0,t.jsx)(c,{children:n("Container")}),(0,t.jsx)(c,{children:n("Instance")}),(0,t.jsx)(c,{children:n("State")}),(0,t.jsx)(c,{children:n("Last event")}),(0,t.jsx)(c,{children:n("Detail")}),(0,t.jsx)(c,{children:n("Exit")}),(0,t.jsx)(c,{children:n("When")})]})}),(0,t.jsx)(A,{children:N.map(F)})]})})})]}),e[2]=i,e[3]=s,e[4]=o,e[5]=p,e[6]=n,e[7]=d}else d=e[7];return d},"q");function F(e){return(0,t.jsxs)(g,{"data-testid":`containers-row-${e.name}${e.instance===void 0?"":`-${e.instance}`}`,children:[(0,t.jsx)(l,{className:"font-mono text-xs",children:e.name}),(0,t.jsx)(l,{className:"max-w-40 truncate font-mono text-xs text-muted-foreground",title:e.instance,children:e.instance??"\u2014"}),(0,t.jsx)(l,{children:(0,t.jsx)(C,{variant:W[e.state],children:e.state})}),(0,t.jsx)(l,{className:"font-mono text-xs text-muted-foreground",children:e.event}),(0,t.jsx)(l,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"\u2014"}),(0,t.jsx)(l,{className:"font-mono text-xs tabular-nums text-muted-foreground",children:e.exitCode??"\u2014"}),(0,t.jsx)(l,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]},`${e.name}/${e.instance??""}`)}f(F,"j");export{V as default};
1
+ import{a as D}from"./chunk-BOTGXX4H.js";import{b as C}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import"./chunk-35DM4JJG.js";import{a as L}from"./chunk-4ZEL6BYL.js";import{c as $}from"./chunk-7TRN7FQ4.js";import"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import"./chunk-GETL6R4M.js";import{a as I}from"./chunk-FKVZRPV5.js";import{a as T,b as k,c as A,d as g,e as c,f as l}from"./chunk-HEAQVSNS.js";import{a as b,e as S}from"./chunk-WUWBZPUK.js";import{d as w}from"./chunk-FODLDLE2.js";import{a as f,d as y,f as _,g as j}from"./chunk-YKXDMIHQ.js";var O=y(_(),1);var t=y(j(),1);var E="container:",M={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},B=f(e=>{let n=e.indexOf(":");if(n===-1)return{event:e.trim()};let r=e.slice(n+1).trim(),a=e.slice(0,n).trim();return r===""?{event:a}:{detail:r,event:a}},"B"),P=f(e=>{let n=new Map;for(let r of e){let a=r.functionPath??"";if(!a.startsWith(E))continue;let i=a.slice(E.length);if(i==="")continue;let s=JSON.stringify([i,r.instance??""]),o=n.get(s);if(o!==void 0&&o.timestamp>=r.timestamp)continue;let{detail:p,event:d}=B(r.message);n.set(s,{detail:p,event:d,exitCode:r.exitCode,instance:r.instance,level:r.level,name:i,state:M[d]??"unknown",timestamp:r.timestamp})}return[...n.values()].toSorted((r,a)=>r.name.localeCompare(a.name)||(r.instance??"").localeCompare(a.instance??""))},"D"),W={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},q=f(e=>{let{entries:n}=e??{};return Array.isArray(n)?n:[]},"P"),V=f(()=>{let e=(0,O.c)(19),n=w(),r,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},a={live:!0,shardKey:""},e[0]=r,e[1]=a):(r=e[0],a=e[1]);let{data:i,error:s,liveError:o}=$(L.getLogs,r,a),p=i!==void 0,d;if(e[2]!==i||e[3]!==s||e[4]!==o||e[5]!==p||e[6]!==n){let N=P(q(i)),x;e[8]!==s?(x=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:s}),e[8]=s,e[9]=x):x=e[9];let m;e[10]!==n?(m=n("Cloudflare Containers are observed from their lifecycle log stream. This shows the current state per instance \u2014 ports and health checks aren't carried in that stream."),e[10]=n,e[11]=m):m=e[11];let u;e[12]!==m?(u=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:m}),e[12]=m,e[13]=u):u=e[13];let h;e[14]!==o?(h=(0,t.jsx)(D,{message:o,prefix:"containers"}),e[14]=o,e[15]=h):h=e[15];let v;e[16]!==u||e[17]!==h?(v=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[u,h]}),e[16]=u,e[17]=h,e[18]=v):v=e[18],d=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[x,v,p&&N.length===0?(0,t.jsx)(I,{description:n("No container lifecycle activity yet. Instances declared with defineContainer show up here once they start, sleep, stop, or error."),testId:"containers-empty",title:n("No container activity")}):(0,t.jsx)(b,{className:"overflow-hidden py-0",children:(0,t.jsx)(S,{className:"px-0",children:(0,t.jsxs)(T,{"data-testid":"containers-table",children:[(0,t.jsx)(k,{children:(0,t.jsxs)(g,{children:[(0,t.jsx)(c,{children:n("Container")}),(0,t.jsx)(c,{children:n("Instance")}),(0,t.jsx)(c,{children:n("State")}),(0,t.jsx)(c,{children:n("Last event")}),(0,t.jsx)(c,{children:n("Detail")}),(0,t.jsx)(c,{children:n("Exit")}),(0,t.jsx)(c,{children:n("When")})]})}),(0,t.jsx)(A,{children:N.map(F)})]})})})]}),e[2]=i,e[3]=s,e[4]=o,e[5]=p,e[6]=n,e[7]=d}else d=e[7];return d},"q");function F(e){return(0,t.jsxs)(g,{"data-testid":`containers-row-${e.name}${e.instance===void 0?"":`-${e.instance}`}`,children:[(0,t.jsx)(l,{className:"font-mono text-xs",children:e.name}),(0,t.jsx)(l,{className:"max-w-40 truncate font-mono text-xs text-muted-foreground",title:e.instance,children:e.instance??"\u2014"}),(0,t.jsx)(l,{children:(0,t.jsx)(C,{variant:W[e.state],children:e.state})}),(0,t.jsx)(l,{className:"font-mono text-xs text-muted-foreground",children:e.event}),(0,t.jsx)(l,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"\u2014"}),(0,t.jsx)(l,{className:"font-mono text-xs tabular-nums text-muted-foreground",children:e.exitCode??"\u2014"}),(0,t.jsx)(l,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]},`${e.name}/${e.instance??""}`)}f(F,"j");export{V as default};
@@ -1 +1 @@
1
- import{a as te}from"./chunk-PD6WIDY6.js";import{a as Z}from"./chunk-S3CRZLGS.js";import{a as Y}from"./chunk-2DX5MROH.js";import{b as X}from"./chunk-OGUKYRFM.js";import{a as W}from"./chunk-K7AJEMKE.js";import{e as G}from"./chunk-6D6Z2KXU.js";import"./chunk-OKG3HWSJ.js";import"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{b as ae,c as ne}from"./chunk-EY7RT4YO.js";import{a as q,b as ee}from"./chunk-AX24JD2G.js";import{a as Q}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import"./chunk-ITMXIPQ7.js";import"./chunk-ULIQFBZU.js";import"./chunk-3PZNTIBM.js";import"./chunk-35DM4JJG.js";import{a as I}from"./chunk-4ZEL6BYL.js";import{c as _}from"./chunk-SDHFSBNM.js";import{f as D}from"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import"./chunk-HEAQVSNS.js";import"./chunk-WUWBZPUK.js";import{d as M,f as C,g as A,l as V,o as N}from"./chunk-FODLDLE2.js";import{a as l,d as j,e as he,f as me,g as pe}from"./chunk-YKXDMIHQ.js";var E=j(me(),1);var c=j(he(),1);var S=j(pe(),1);var ge=l(t=>{let{suggestedIndex:e,table:i}=t;if(typeof i!="string"||i.length===0||typeof e!="object"||e===null)return!1;let{fields:a,name:n}=e;return!Array.isArray(a)||a.length===0||a.some(s=>typeof s!="string"||s.length===0)?!1:typeof n=="string"&&n.length>0},"ye"),be=l((t,e)=>`.index(${JSON.stringify(t)}, [${e.map(i=>JSON.stringify(i)).join(", ")}])`,"ge"),ye=l(t=>{let e=(0,E.c)(19),{fields:i,indexName:a,table:n,testId:s}=t,u=M(),[h,f]=(0,c.useState)(null),m;e[0]!==i||e[1]!==a?(m=l(()=>{let b=be(a,i),$="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if($===void 0){f({copied:!1,declaration:b});return}N($.writeText(b).then(()=>(f({copied:!0,declaration:b}),!0)),()=>{f({copied:!1,declaration:b})})},"m"),e[0]=i,e[1]=a,e[2]=m):m=e[2];let x=m;if(h!==null){let b;return e[3]!==h.copied||e[4]!==h.declaration||e[5]!==u||e[6]!==n||e[7]!==s?(b=h.copied?(0,S.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`${s}-applied`,children:u("Index declaration copied \u2014 add it to {table} in lunora/schema.ts.",{table:n})}):(0,S.jsxs)("span",{className:"flex flex-col gap-1 text-xs text-muted-foreground","data-testid":`${s}-manual`,children:[u("Could not reach the clipboard \u2014 add this to {table} in lunora/schema.ts:",{table:n}),(0,S.jsx)("code",{className:"font-mono break-all select-all",children:h.declaration})]}),e[3]=h.copied,e[4]=h.declaration,e[5]=u,e[6]=n,e[7]=s,e[8]=b):b=e[8],b}let T;e[9]!==u?(T=u("Copy?"),e[9]=u,e[10]=T):T=e[10];let p;e[11]!==u||e[12]!==n?(p=u("Copy index declaration for {table}",{table:n}),e[11]=u,e[12]=n,e[13]=p):p=e[13];let w;return e[14]!==x||e[15]!==T||e[16]!==p||e[17]!==s?(w=(0,S.jsx)(te,{confirmLabel:T,onConfirm:x,testId:s,children:p}),e[14]=x,e[15]=T,e[16]=p,e[17]=s,e[18]=w):w=e[18],w},"ve"),xe=l((t,e)=>{let i=new Map;for(let a of e){let n=`${a.table} ${a.index}`;i.set(n,(i.get(n)??0)+a.reads)}return t.map(a=>({index:a.index,reads:i.get(`${a.table} ${a.index}`)??0,table:a.table}))},"Se"),ve=l(t=>{let e=new Map;for(let i of t)for(let a of i.scannedTables??[])e.set(a.table,(e.get(a.table)??0)+a.scans);return[...e].map(([i,a])=>({scans:a,table:i}))},"Te"),ie=l((t,e)=>e.map(i=>({index:i.name,table:t})),"P"),we=l(t=>{let e=xe(t.declaredIndexes??[],t.indexHits??[]),i=ve(t.functions??[]),a=t.shardTraffic??[],n=t.analyticsMetrics,s=n&&n.indexHits.length>0?n.indexHits:e,u=n&&n.tableScans.length>0?n.tableScans:i,h=n&&n.shardTraffic.length>0?n.shardTraffic:a,f=ne({indexHits:s,schema:{tables:[]},shardTraffic:h,tableScans:u},{lints:ae,source:"runtime"}),m=t.suppressHotScanTables;return(m===void 0?f:f.filter(x=>!(x.metadata.kind==="hot_scan"&&typeof x.metadata.table=="string"&&m.has(x.metadata.table)))).map(x=>q(x))},"we"),Se=C(I.listTables),Te=C(I.listTableIndexes),Ie=C(I.listTablesIndexes),B=l(t=>`${(t*100).toFixed(1)}%`,"L"),re=l(t=>`${(t/1e3).toFixed(2)}s`,"V"),$e=l(t=>{if(t.length<=1)return t[0]??"";let e=t[t.length-1]??"";return`${t.slice(0,-1).join(", ")} and ${e}`},"Ne"),ke=l((t,e)=>({"high-error-rate":t("High error rate"),"high-evictions":t("High cache eviction rate"),"high-write-contention":t("High write contention"),"low-cache-hit-rate":t("Low cache hit rate"),"missing-index":t("Missing index"),"slow-function":t("Slow function"),"storage-headroom":t("Storage headroom")})[e.kind],"ke"),se=l((t,e)=>({"high-error-rate":t("{rate} of calls failed.",{rate:B(e.value)}),"high-evictions":t("{count} entries evicted recently.",{count:e.value}),"high-write-contention":t("{rate} of calls hit a write conflict \u2014 consider sharding to cut contention.",{rate:B(e.value)}),"low-cache-hit-rate":t("{rate} hit rate over recent traffic.",{rate:B(e.value)}),"missing-index":t("Slowest call took {duration} \u2014 it full-scanned {tables} with no index.",{duration:re(e.value),tables:$e(e.tables??[])}),"slow-function":t("Slowest call took {duration}.",{duration:re(e.value)}),"storage-headroom":t("{size} of the 10 GiB per-shard ceiling \u2014 plan a .shardBy() migration while it still has runway.",{size:V(e.value)})})[e.kind],"U"),Ne=l(t=>{let e=(0,E.c)(10),{onJump:i,table:a}=t,n=M(),s;e[0]!==i||e[1]!==a?(s=l(()=>{i(a)},"i"),e[0]=i,e[1]=a,e[2]=s):s=e[2];let u=s,h=`in-add-index-${a}`,f;e[3]!==n||e[4]!==a?(f=n("Add index on {table}",{table:a}),e[3]=n,e[4]=a,e[5]=f):f=e[5];let m;return e[6]!==u||e[7]!==h||e[8]!==f?(m=(0,S.jsx)(Q,{"data-testid":h,onClick:u,size:"sm",type:"button",variant:"outline",children:f}),e[6]=u,e[7]=h,e[8]=f,e[9]=m):m=e[9],m},"Be"),ze=l(({initialShardKey:t,loadShardTraffic:e})=>{let i=D(),a=G(),n=M(),{queryShardKey:s,setShardKey:u,shardKey:h}=Z(t),[f,m]=(0,c.useState)(null),[x,T]=(0,c.useState)(null),p=(0,c.useRef)(""),w=_(I.getMetrics,{},{live:!0,shardKey:s}),b=_(I.getFunctionStats,{},{live:!0,shardKey:s}),$=_(I.getAdvisories,{},{live:!0,shardKey:s}),L=w.data??null,H=b.data?.functions??null,F=$.data?.advisories??null,J=w.data?.indexHits??null,O=w.error!==null&&b.error!==null?w.error:null,oe=e??(r=>i.shardTraffic(r)),le=l(async(r,y)=>{let o=r[0];if(o===void 0||o===""){p.current===y&&T(null);return}try{let g=await oe(o);if(p.current!==y)return;let d=new Map;for(let v of g.shards)d.has(v.shardKey)||d.set(v.shardKey,{requests:v.requests,shardKey:v.shardKey});T([...d.values()])}catch{p.current===y&&T(null)}},"Y"),de=l(async(r,y)=>{let o=await Promise.allSettled(r.map(async d=>[d,await i.query(Te,{table:d},A(y))])),g=[];for(let d of o)if(d.status==="fulfilled"){let[v,k]=d.value;g.push(...ie(v,k.indexes))}return g},"Z"),z=(0,c.useEffectEvent)(async r=>{p.current=r;let y=[];try{let o=await i.query(Se,{},A(r));if(p.current!==r)return;X(r),y=o.map(d=>d.name);let g=[];if(y.length>0)try{let d=await i.query(Ie,{tables:y},A(r));if(p.current!==r)return;for(let[v,k]of Object.entries(d.indexesByTable))g.push(...ie(v,k))}catch{if(g=await de(y,r),p.current!==r)return}m(g)}catch{p.current===r&&m(null)}await le(y,r)});(0,c.useEffect)(()=>{N(z(s))},[s]);let ce=(0,c.useEffectEvent)(()=>{w.refetch(),b.refetch(),$.refetch(),N(z(s))});(0,c.useEffect)(()=>{let r=l(()=>{document.visibilityState==="visible"&&ce()},"r");return document.addEventListener("visibilitychange",r),()=>{document.removeEventListener("visibilitychange",r)}},[]);let U=(0,c.useCallback)(r=>{N(a({search:{table:r},to:"/schema"}))},[a]),K=(0,c.useMemo)(()=>W(L,H),[H,L]),P=(0,c.useMemo)(()=>new Set(K.filter(r=>r.kind==="missing-index").flatMap(r=>r.tables??[])),[K]),R=(0,c.useMemo)(()=>we({declaredIndexes:f??[],functions:H,indexHits:J,shardTraffic:x,suppressHotScanTables:P}),[f,H,J,P,x]),ue=(0,c.useMemo)(()=>{let r=K.map(o=>{let g=o.kind==="missing-index"?o.tables??[]:[];return{action:g.length>0?g.map(d=>(0,S.jsx)(Ne,{onJump:U,table:d},d)):void 0,description:o.message===void 0?se(n,o):`${se(n,o)} \u2014 ${o.message}`,entity:o.fn,issueType:ke(n,o),key:`${o.kind}:${o.fn??""}`,level:o.severity}}),y=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(F??[]).map(o=>{let g=q(o);if(y.has(o.name)&&ge(o.metadata)){let{table:d,suggestedIndex:v}=o.metadata,k=`in-apply-index-${d}-${v.name}`;return{...g,action:(0,S.jsx)(ye,{fields:v.fields,indexName:v.name,table:d,testId:k})}}return g}),...R,...r]},[F,K,U,R,n]),fe=(0,S.jsx)(Y,{onChange:u,testId:"in-shard-input",value:h});return(0,S.jsx)(ee,{error:O,errorSource:O===null?void 0:w.errorSource,rows:ue,testId:"lunora-insights",toolbar:fe})},"Ue");export{ze as InsightsPanel};
1
+ import{a as te}from"./chunk-PD6WIDY6.js";import{a as Z}from"./chunk-S3CRZLGS.js";import{a as Y}from"./chunk-2DX5MROH.js";import{b as X}from"./chunk-OGUKYRFM.js";import{a as W}from"./chunk-K7AJEMKE.js";import{e as G}from"./chunk-6D6Z2KXU.js";import"./chunk-OKG3HWSJ.js";import"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{b as ae,c as ne}from"./chunk-EY7RT4YO.js";import{a as q,b as ee}from"./chunk-CZIPGHIR.js";import{a as Q}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import"./chunk-FDB7QVEC.js";import"./chunk-ULIQFBZU.js";import"./chunk-2KM4MU7U.js";import"./chunk-35DM4JJG.js";import{a as I}from"./chunk-4ZEL6BYL.js";import{c as _}from"./chunk-7TRN7FQ4.js";import{f as D}from"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import"./chunk-GETL6R4M.js";import"./chunk-HEAQVSNS.js";import"./chunk-WUWBZPUK.js";import{d as M,f as C,g as A,l as V,o as N}from"./chunk-FODLDLE2.js";import{a as l,d as j,e as he,f as me,g as pe}from"./chunk-YKXDMIHQ.js";var E=j(me(),1);var c=j(he(),1);var S=j(pe(),1);var ge=l(t=>{let{suggestedIndex:e,table:i}=t;if(typeof i!="string"||i.length===0||typeof e!="object"||e===null)return!1;let{fields:a,name:n}=e;return!Array.isArray(a)||a.length===0||a.some(s=>typeof s!="string"||s.length===0)?!1:typeof n=="string"&&n.length>0},"ye"),be=l((t,e)=>`.index(${JSON.stringify(t)}, [${e.map(i=>JSON.stringify(i)).join(", ")}])`,"ge"),ye=l(t=>{let e=(0,E.c)(19),{fields:i,indexName:a,table:n,testId:s}=t,u=M(),[h,f]=(0,c.useState)(null),m;e[0]!==i||e[1]!==a?(m=l(()=>{let b=be(a,i),$="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if($===void 0){f({copied:!1,declaration:b});return}N($.writeText(b).then(()=>(f({copied:!0,declaration:b}),!0)),()=>{f({copied:!1,declaration:b})})},"m"),e[0]=i,e[1]=a,e[2]=m):m=e[2];let x=m;if(h!==null){let b;return e[3]!==h.copied||e[4]!==h.declaration||e[5]!==u||e[6]!==n||e[7]!==s?(b=h.copied?(0,S.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`${s}-applied`,children:u("Index declaration copied \u2014 add it to {table} in lunora/schema.ts.",{table:n})}):(0,S.jsxs)("span",{className:"flex flex-col gap-1 text-xs text-muted-foreground","data-testid":`${s}-manual`,children:[u("Could not reach the clipboard \u2014 add this to {table} in lunora/schema.ts:",{table:n}),(0,S.jsx)("code",{className:"font-mono break-all select-all",children:h.declaration})]}),e[3]=h.copied,e[4]=h.declaration,e[5]=u,e[6]=n,e[7]=s,e[8]=b):b=e[8],b}let T;e[9]!==u?(T=u("Copy?"),e[9]=u,e[10]=T):T=e[10];let p;e[11]!==u||e[12]!==n?(p=u("Copy index declaration for {table}",{table:n}),e[11]=u,e[12]=n,e[13]=p):p=e[13];let w;return e[14]!==x||e[15]!==T||e[16]!==p||e[17]!==s?(w=(0,S.jsx)(te,{confirmLabel:T,onConfirm:x,testId:s,children:p}),e[14]=x,e[15]=T,e[16]=p,e[17]=s,e[18]=w):w=e[18],w},"ve"),xe=l((t,e)=>{let i=new Map;for(let a of e){let n=`${a.table} ${a.index}`;i.set(n,(i.get(n)??0)+a.reads)}return t.map(a=>({index:a.index,reads:i.get(`${a.table} ${a.index}`)??0,table:a.table}))},"Se"),ve=l(t=>{let e=new Map;for(let i of t)for(let a of i.scannedTables??[])e.set(a.table,(e.get(a.table)??0)+a.scans);return[...e].map(([i,a])=>({scans:a,table:i}))},"Te"),ie=l((t,e)=>e.map(i=>({index:i.name,table:t})),"P"),we=l(t=>{let e=xe(t.declaredIndexes??[],t.indexHits??[]),i=ve(t.functions??[]),a=t.shardTraffic??[],n=t.analyticsMetrics,s=n&&n.indexHits.length>0?n.indexHits:e,u=n&&n.tableScans.length>0?n.tableScans:i,h=n&&n.shardTraffic.length>0?n.shardTraffic:a,f=ne({indexHits:s,schema:{tables:[]},shardTraffic:h,tableScans:u},{lints:ae,source:"runtime"}),m=t.suppressHotScanTables;return(m===void 0?f:f.filter(x=>!(x.metadata.kind==="hot_scan"&&typeof x.metadata.table=="string"&&m.has(x.metadata.table)))).map(x=>q(x))},"we"),Se=C(I.listTables),Te=C(I.listTableIndexes),Ie=C(I.listTablesIndexes),B=l(t=>`${(t*100).toFixed(1)}%`,"L"),re=l(t=>`${(t/1e3).toFixed(2)}s`,"V"),$e=l(t=>{if(t.length<=1)return t[0]??"";let e=t[t.length-1]??"";return`${t.slice(0,-1).join(", ")} and ${e}`},"Ne"),ke=l((t,e)=>({"high-error-rate":t("High error rate"),"high-evictions":t("High cache eviction rate"),"high-write-contention":t("High write contention"),"low-cache-hit-rate":t("Low cache hit rate"),"missing-index":t("Missing index"),"slow-function":t("Slow function"),"storage-headroom":t("Storage headroom")})[e.kind],"ke"),se=l((t,e)=>({"high-error-rate":t("{rate} of calls failed.",{rate:B(e.value)}),"high-evictions":t("{count} entries evicted recently.",{count:e.value}),"high-write-contention":t("{rate} of calls hit a write conflict \u2014 consider sharding to cut contention.",{rate:B(e.value)}),"low-cache-hit-rate":t("{rate} hit rate over recent traffic.",{rate:B(e.value)}),"missing-index":t("Slowest call took {duration} \u2014 it full-scanned {tables} with no index.",{duration:re(e.value),tables:$e(e.tables??[])}),"slow-function":t("Slowest call took {duration}.",{duration:re(e.value)}),"storage-headroom":t("{size} of the 10 GiB per-shard ceiling \u2014 plan a .shardBy() migration while it still has runway.",{size:V(e.value)})})[e.kind],"U"),Ne=l(t=>{let e=(0,E.c)(10),{onJump:i,table:a}=t,n=M(),s;e[0]!==i||e[1]!==a?(s=l(()=>{i(a)},"i"),e[0]=i,e[1]=a,e[2]=s):s=e[2];let u=s,h=`in-add-index-${a}`,f;e[3]!==n||e[4]!==a?(f=n("Add index on {table}",{table:a}),e[3]=n,e[4]=a,e[5]=f):f=e[5];let m;return e[6]!==u||e[7]!==h||e[8]!==f?(m=(0,S.jsx)(Q,{"data-testid":h,onClick:u,size:"sm",type:"button",variant:"outline",children:f}),e[6]=u,e[7]=h,e[8]=f,e[9]=m):m=e[9],m},"Be"),ze=l(({initialShardKey:t,loadShardTraffic:e})=>{let i=D(),a=G(),n=M(),{queryShardKey:s,setShardKey:u,shardKey:h}=Z(t),[f,m]=(0,c.useState)(null),[x,T]=(0,c.useState)(null),p=(0,c.useRef)(""),w=_(I.getMetrics,{},{live:!0,shardKey:s}),b=_(I.getFunctionStats,{},{live:!0,shardKey:s}),$=_(I.getAdvisories,{},{live:!0,shardKey:s}),L=w.data??null,H=b.data?.functions??null,F=$.data?.advisories??null,J=w.data?.indexHits??null,O=w.error!==null&&b.error!==null?w.error:null,oe=e??(r=>i.shardTraffic(r)),le=l(async(r,y)=>{let o=r[0];if(o===void 0||o===""){p.current===y&&T(null);return}try{let g=await oe(o);if(p.current!==y)return;let d=new Map;for(let v of g.shards)d.has(v.shardKey)||d.set(v.shardKey,{requests:v.requests,shardKey:v.shardKey});T([...d.values()])}catch{p.current===y&&T(null)}},"Y"),de=l(async(r,y)=>{let o=await Promise.allSettled(r.map(async d=>[d,await i.query(Te,{table:d},A(y))])),g=[];for(let d of o)if(d.status==="fulfilled"){let[v,k]=d.value;g.push(...ie(v,k.indexes))}return g},"Z"),z=(0,c.useEffectEvent)(async r=>{p.current=r;let y=[];try{let o=await i.query(Se,{},A(r));if(p.current!==r)return;X(r),y=o.map(d=>d.name);let g=[];if(y.length>0)try{let d=await i.query(Ie,{tables:y},A(r));if(p.current!==r)return;for(let[v,k]of Object.entries(d.indexesByTable))g.push(...ie(v,k))}catch{if(g=await de(y,r),p.current!==r)return}m(g)}catch{p.current===r&&m(null)}await le(y,r)});(0,c.useEffect)(()=>{N(z(s))},[s]);let ce=(0,c.useEffectEvent)(()=>{w.refetch(),b.refetch(),$.refetch(),N(z(s))});(0,c.useEffect)(()=>{let r=l(()=>{document.visibilityState==="visible"&&ce()},"r");return document.addEventListener("visibilitychange",r),()=>{document.removeEventListener("visibilitychange",r)}},[]);let U=(0,c.useCallback)(r=>{N(a({search:{table:r},to:"/schema"}))},[a]),K=(0,c.useMemo)(()=>W(L,H),[H,L]),P=(0,c.useMemo)(()=>new Set(K.filter(r=>r.kind==="missing-index").flatMap(r=>r.tables??[])),[K]),R=(0,c.useMemo)(()=>we({declaredIndexes:f??[],functions:H,indexHits:J,shardTraffic:x,suppressHotScanTables:P}),[f,H,J,P,x]),ue=(0,c.useMemo)(()=>{let r=K.map(o=>{let g=o.kind==="missing-index"?o.tables??[]:[];return{action:g.length>0?g.map(d=>(0,S.jsx)(Ne,{onJump:U,table:d},d)):void 0,description:o.message===void 0?se(n,o):`${se(n,o)} \u2014 ${o.message}`,entity:o.fn,issueType:ke(n,o),key:`${o.kind}:${o.fn??""}`,level:o.severity}}),y=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(F??[]).map(o=>{let g=q(o);if(y.has(o.name)&&ge(o.metadata)){let{table:d,suggestedIndex:v}=o.metadata,k=`in-apply-index-${d}-${v.name}`;return{...g,action:(0,S.jsx)(ye,{fields:v.fields,indexName:v.name,table:d,testId:k})}}return g}),...R,...r]},[F,K,U,R,n]),fe=(0,S.jsx)(Y,{onChange:u,testId:"in-shard-input",value:h});return(0,S.jsx)(ee,{error:O,errorSource:O===null?void 0:w.errorSource,rows:ue,testId:"lunora-insights",toolbar:fe})},"Ue");export{ze as InsightsPanel};
@@ -1 +1 @@
1
- import{d as k}from"./chunk-YOB2X3FZ.js";import{a as j}from"./chunk-66UGPQVC.js";import{a as _}from"./chunk-AULH6SZB.js";import"./chunk-K7AJEMKE.js";import"./chunk-6D6Z2KXU.js";import"./chunk-Y6CXU7T4.js";import"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as g}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as E}from"./chunk-ITMXIPQ7.js";import"./chunk-ULIQFBZU.js";import"./chunk-3PZNTIBM.js";import"./chunk-35DM4JJG.js";import{a as y}from"./chunk-4ZEL6BYL.js";import{c as b}from"./chunk-SDHFSBNM.js";import"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as w}from"./chunk-FKVZRPV5.js";import{a as I,b as R,c as A,d as v,e as l,f as n}from"./chunk-HEAQVSNS.js";import{a as f,e as N}from"./chunk-WUWBZPUK.js";import{d as T,r as S}from"./chunk-FODLDLE2.js";import{a as c,d as G,g as H}from"./chunk-YKXDMIHQ.js";var e=G(H(),1);var Q=["subscriptions","events"],U={},B=new Set(["active","trialing"]),V=new Set(["past_due","unpaid"]),s=c((a,t)=>{if(a[t]!==void 0)return a[t];let m=a.__doc__;return typeof m=="string"?k(m)?.[t]:void 0},"n"),i=c(a=>typeof a=="string"?a:typeof a=="number"||typeof a=="bigint"||typeof a=="boolean"?String(a):"","a"),q=c(a=>B.has(a)?"default":V.has(a)?"destructive":"outline","G"),se=c(({limit:a=100})=>{let t=T(),m=_(),{data:x}=b(y.listTables,U,{live:!0}),D=x!==void 0,C=Array.isArray(x)&&Q.every(r=>x.some(d=>d.name===r)),p=m.payments&&C,o=b(y.readTablePage,{filters:[],limit:a,offset:0,orderBy:[],search:"",table:"subscriptions"},{enabled:p}),h=b(y.readTablePage,{filters:[],limit:25,offset:0,orderBy:[],search:"",table:"events"},{enabled:p});j(()=>{p&&(o.refetch(),h.refetch())},!0);let u=o.data?.rows??[],O=h.data?.rows??[],F=o.error??h.error,L=o.error===null?h.errorSource:o.errorSource,P=u.filter(r=>B.has(i(s(r,"state")))).length,M=O.toSorted((r,d)=>Number(s(d,"processedAt")??0)-Number(s(r,"processedAt")??0));return D&&!p?(0,e.jsx)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:(0,e.jsx)(w,{description:t("No @lunora/payment tables found in this deployment. Declare the store tables (subscriptions, events, \u2026) in lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions."),testId:"payments-unconfigured",title:t("No payments configured")})}):(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[(0,e.jsx)("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:(0,e.jsxs)(f,{className:"justify-between gap-0 py-0",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Subscriptions")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:P}),(0,e.jsx)(g,{variant:"default",children:t("{count} active",{count:P})})]})]}),(0,e.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:t("{total} total",{total:u.length})})]})}),F===null?void 0:(0,e.jsx)(E,{error:L}),u.length===0&&!o.isLoading?(0,e.jsx)(w,{testId:"payments-empty",title:t("No subscriptions yet")}):(0,e.jsx)(f,{className:"overflow-hidden py-0",children:(0,e.jsx)(N,{className:"px-0",children:(0,e.jsxs)(I,{children:[(0,e.jsx)(R,{children:(0,e.jsxs)(v,{children:[(0,e.jsx)(l,{children:t("Provider")}),(0,e.jsx)(l,{children:t("Reference")}),(0,e.jsx)(l,{children:t("Plan")}),(0,e.jsx)(l,{children:t("State")}),(0,e.jsx)(l,{children:t("Renews")})]})}),(0,e.jsx)(A,{children:u.map(r=>{let d=i(s(r,"state"));return(0,e.jsxs)(v,{"data-testid":"payment-subscription-row",children:[(0,e.jsx)(n,{children:i(s(r,"provider"))}),(0,e.jsx)(n,{children:i(s(r,"referenceId"))}),(0,e.jsx)(n,{children:i(s(r,"priceId"))}),(0,e.jsx)(n,{children:(0,e.jsx)(g,{variant:q(d),children:d})}),(0,e.jsx)(n,{children:S(s(r,"currentPeriodEnd"))})]},i(s(r,"providerSubscriptionId")))})})]})})}),(0,e.jsxs)(f,{className:"overflow-hidden py-0",children:[(0,e.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Recent webhook events")})}),(0,e.jsx)(N,{className:"px-0",children:(0,e.jsx)(I,{children:(0,e.jsx)(A,{children:M.map(r=>(0,e.jsxs)(v,{"data-testid":"payment-event-row",children:[(0,e.jsx)(n,{children:i(s(r,"provider"))}),(0,e.jsx)(n,{className:"font-medium",children:i(s(r,"type"))}),(0,e.jsx)(n,{className:"text-muted-foreground",children:i(s(r,"providerEventId"))}),(0,e.jsx)(n,{children:S(s(r,"processedAt"))})]},i(s(r,"providerEventId"))))})})})]})]})},"se");export{se as PaymentsPanel};
1
+ import{d as k}from"./chunk-YOB2X3FZ.js";import{a as j}from"./chunk-66UGPQVC.js";import{a as _}from"./chunk-75OWNJEY.js";import"./chunk-K7AJEMKE.js";import"./chunk-6D6Z2KXU.js";import"./chunk-Y6CXU7T4.js";import"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as g}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as E}from"./chunk-FDB7QVEC.js";import"./chunk-ULIQFBZU.js";import"./chunk-2KM4MU7U.js";import"./chunk-35DM4JJG.js";import{a as y}from"./chunk-4ZEL6BYL.js";import{c as b}from"./chunk-7TRN7FQ4.js";import"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import"./chunk-GETL6R4M.js";import{a as w}from"./chunk-FKVZRPV5.js";import{a as I,b as R,c as A,d as v,e as l,f as n}from"./chunk-HEAQVSNS.js";import{a as f,e as N}from"./chunk-WUWBZPUK.js";import{d as T,r as S}from"./chunk-FODLDLE2.js";import{a as c,d as G,g as H}from"./chunk-YKXDMIHQ.js";var e=G(H(),1);var Q=["subscriptions","events"],U={},B=new Set(["active","trialing"]),V=new Set(["past_due","unpaid"]),s=c((a,t)=>{if(a[t]!==void 0)return a[t];let m=a.__doc__;return typeof m=="string"?k(m)?.[t]:void 0},"n"),i=c(a=>typeof a=="string"?a:typeof a=="number"||typeof a=="bigint"||typeof a=="boolean"?String(a):"","a"),q=c(a=>B.has(a)?"default":V.has(a)?"destructive":"outline","G"),se=c(({limit:a=100})=>{let t=T(),m=_(),{data:x}=b(y.listTables,U,{live:!0}),D=x!==void 0,C=Array.isArray(x)&&Q.every(r=>x.some(d=>d.name===r)),p=m.payments&&C,o=b(y.readTablePage,{filters:[],limit:a,offset:0,orderBy:[],search:"",table:"subscriptions"},{enabled:p}),h=b(y.readTablePage,{filters:[],limit:25,offset:0,orderBy:[],search:"",table:"events"},{enabled:p});j(()=>{p&&(o.refetch(),h.refetch())},!0);let u=o.data?.rows??[],O=h.data?.rows??[],F=o.error??h.error,L=o.error===null?h.errorSource:o.errorSource,P=u.filter(r=>B.has(i(s(r,"state")))).length,M=O.toSorted((r,d)=>Number(s(d,"processedAt")??0)-Number(s(r,"processedAt")??0));return D&&!p?(0,e.jsx)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:(0,e.jsx)(w,{description:t("No @lunora/payment tables found in this deployment. Declare the store tables (subscriptions, events, \u2026) in lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions."),testId:"payments-unconfigured",title:t("No payments configured")})}):(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[(0,e.jsx)("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:(0,e.jsxs)(f,{className:"justify-between gap-0 py-0",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Subscriptions")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:P}),(0,e.jsx)(g,{variant:"default",children:t("{count} active",{count:P})})]})]}),(0,e.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:t("{total} total",{total:u.length})})]})}),F===null?void 0:(0,e.jsx)(E,{error:L}),u.length===0&&!o.isLoading?(0,e.jsx)(w,{testId:"payments-empty",title:t("No subscriptions yet")}):(0,e.jsx)(f,{className:"overflow-hidden py-0",children:(0,e.jsx)(N,{className:"px-0",children:(0,e.jsxs)(I,{children:[(0,e.jsx)(R,{children:(0,e.jsxs)(v,{children:[(0,e.jsx)(l,{children:t("Provider")}),(0,e.jsx)(l,{children:t("Reference")}),(0,e.jsx)(l,{children:t("Plan")}),(0,e.jsx)(l,{children:t("State")}),(0,e.jsx)(l,{children:t("Renews")})]})}),(0,e.jsx)(A,{children:u.map(r=>{let d=i(s(r,"state"));return(0,e.jsxs)(v,{"data-testid":"payment-subscription-row",children:[(0,e.jsx)(n,{children:i(s(r,"provider"))}),(0,e.jsx)(n,{children:i(s(r,"referenceId"))}),(0,e.jsx)(n,{children:i(s(r,"priceId"))}),(0,e.jsx)(n,{children:(0,e.jsx)(g,{variant:q(d),children:d})}),(0,e.jsx)(n,{children:S(s(r,"currentPeriodEnd"))})]},i(s(r,"providerSubscriptionId")))})})]})})}),(0,e.jsxs)(f,{className:"overflow-hidden py-0",children:[(0,e.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Recent webhook events")})}),(0,e.jsx)(N,{className:"px-0",children:(0,e.jsx)(I,{children:(0,e.jsx)(A,{children:M.map(r=>(0,e.jsxs)(v,{"data-testid":"payment-event-row",children:[(0,e.jsx)(n,{children:i(s(r,"provider"))}),(0,e.jsx)(n,{className:"font-medium",children:i(s(r,"type"))}),(0,e.jsx)(n,{className:"text-muted-foreground",children:i(s(r,"providerEventId"))}),(0,e.jsx)(n,{children:S(s(r,"processedAt"))})]},i(s(r,"providerEventId"))))})})})]})]})},"se");export{se as PaymentsPanel};
@@ -1 +1 @@
1
- import{a as v}from"./chunk-F7UC63UN.js";import{a as Q}from"./chunk-66UGPQVC.js";import{a as L}from"./chunk-S3CRZLGS.js";import{a as G}from"./chunk-2DX5MROH.js";import"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import"./chunk-AAVLPU5Q.js";import{b as $}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as W}from"./chunk-ITMXIPQ7.js";import"./chunk-ULIQFBZU.js";import"./chunk-3PZNTIBM.js";import"./chunk-35DM4JJG.js";import{a as E}from"./chunk-4ZEL6BYL.js";import{c as B}from"./chunk-SDHFSBNM.js";import"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as A}from"./chunk-FKVZRPV5.js";import{a as q,b as H,c as O,d as K,e as T,f as D}from"./chunk-HEAQVSNS.js";import{a as _}from"./chunk-WUWBZPUK.js";import{d as j}from"./chunk-FODLDLE2.js";import{a as S,d as F,f as J,g as V}from"./chunk-YKXDMIHQ.js";var R=F(J(),1);var t=F(V(),1);var U=S(c=>`${c.toString()} ms`,"D"),X=S(c=>c.totalConnections===0&&c.shapePoke.passes===0&&c.whisper.passes===0&&c.shapeProbe.run===0&&c.shapeProbe.served===0&&c.globalPoll.drains===0&&c.globalPoll.pairsSkipped===0,"J"),z=S(c=>{let e=(0,R.c)(48),{counters:o,includeTiming:a,prefix:r,t:l,title:u}=c,d=`${r}-section`,n;e[0]!==u?(n=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:u}),e[0]=u,e[1]=n):n=e[1];let s=`${r}-stats`,i;e[2]!==l?(i=l("Passes"),e[2]=l,e[3]=i):i=e[3];let m=`${r}-passes`,I;e[4]!==o.passes||e[5]!==i||e[6]!==m?(I=(0,t.jsx)(v,{label:i,testId:m,value:o.passes}),e[4]=o.passes,e[5]=i,e[6]=m,e[7]=I):I=e[7];let g;e[8]!==l?(g=l("Sockets iterated"),e[8]=l,e[9]=g):g=e[9];let k=`${r}-iterated`,p;e[10]!==o.socketsIterated||e[11]!==g||e[12]!==k?(p=(0,t.jsx)(v,{label:g,testId:k,value:o.socketsIterated}),e[10]=o.socketsIterated,e[11]=g,e[12]=k,e[13]=p):p=e[13];let f;e[14]!==l?(f=l("Delivered"),e[14]=l,e[15]=f):f=e[15];let y=`${r}-delivered`,h;e[16]!==o.socketsDelivered||e[17]!==f||e[18]!==y?(h=(0,t.jsx)(v,{label:f,testId:y,value:o.socketsDelivered}),e[16]=o.socketsDelivered,e[17]=f,e[18]=y,e[19]=h):h=e[19];let x;e[20]!==l?(x=l("Peak width"),e[20]=l,e[21]=x):x=e[21];let N=`${r}-peak`,b;e[22]!==o.peakSocketsIterated||e[23]!==x||e[24]!==N?(b=(0,t.jsx)(v,{label:x,testId:N,value:o.peakSocketsIterated}),e[22]=o.peakSocketsIterated,e[23]=x,e[24]=N,e[25]=b):b=e[25];let C;e[26]!==o.totalMs||e[27]!==a||e[28]!==r||e[29]!==l?(C=a&&(0,t.jsx)(v,{label:l("Total time"),testId:`${r}-total-ms`,value:U(o.totalMs)}),e[26]=o.totalMs,e[27]=a,e[28]=r,e[29]=l,e[30]=C):C=e[30];let P;e[31]!==o.maxMs||e[32]!==a||e[33]!==r||e[34]!==l?(P=a&&(0,t.jsx)(v,{label:l("Max time"),testId:`${r}-max-ms`,value:U(o.maxMs)}),e[31]=o.maxMs,e[32]=a,e[33]=r,e[34]=l,e[35]=P):P=e[35];let M;e[36]!==h||e[37]!==b||e[38]!==C||e[39]!==P||e[40]!==s||e[41]!==I||e[42]!==p?(M=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":s,children:[I,p,h,b,C,P]}),e[36]=h,e[37]=b,e[38]=C,e[39]=P,e[40]=s,e[41]=I,e[42]=p,e[43]=M):M=e[43];let w;return e[44]!==d||e[45]!==M||e[46]!==n?(w=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":d,children:[n,M]}),e[44]=d,e[45]=M,e[46]=n,e[47]=w):w=e[47],w},"F"),Y=S(c=>{let e=(0,R.c)(20),{counters:o,t:a}=c,r;e[0]!==a?(r=a("Membership probes"),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==r?(l=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:r}),e[2]=r,e[3]=l):l=e[3];let u;e[4]!==a?(u=a("Queries run"),e[4]=a,e[5]=u):u=e[5];let d;e[6]!==o.run||e[7]!==u?(d=(0,t.jsx)(v,{label:u,testId:"fanout-probe-run",value:o.run}),e[6]=o.run,e[7]=u,e[8]=d):d=e[8];let n;e[9]!==a?(n=a("Shared from cache"),e[9]=a,e[10]=n):n=e[10];let s;e[11]!==o.served||e[12]!==n?(s=(0,t.jsx)(v,{label:n,testId:"fanout-probe-served",value:o.served}),e[11]=o.served,e[12]=n,e[13]=s):s=e[13];let i;e[14]!==d||e[15]!==s?(i=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"fanout-probe-stats",children:[d,s]}),e[14]=d,e[15]=s,e[16]=i):i=e[16];let m;return e[17]!==l||e[18]!==i?(m=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-probe-section",children:[l,i]}),e[17]=l,e[18]=i,e[19]=m):m=e[19],m},"V"),Z=S(c=>{let e=(0,R.c)(20),{counters:o,t:a}=c,r;e[0]!==a?(r=a("Global shape polls"),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==r?(l=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:r}),e[2]=r,e[3]=l):l=e[3];let u;e[4]!==a?(u=a("Global reads"),e[4]=a,e[5]=u):u=e[5];let d;e[6]!==o.drains||e[7]!==u?(d=(0,t.jsx)(v,{label:u,testId:"fanout-global-poll-drains",value:o.drains}),e[6]=o.drains,e[7]=u,e[8]=d):d=e[8];let n;e[9]!==a?(n=a("Pairs skipped"),e[9]=a,e[10]=n):n=e[10];let s;e[11]!==o.pairsSkipped||e[12]!==n?(s=(0,t.jsx)(v,{label:n,testId:"fanout-global-poll-pairs-skipped",value:o.pairsSkipped}),e[11]=o.pairsSkipped,e[12]=n,e[13]=s):s=e[13];let i;e[14]!==d||e[15]!==s?(i=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"fanout-global-poll-stats",children:[d,s]}),e[14]=d,e[15]=s,e[16]=i):i=e[16];let m;return e[17]!==l||e[18]!==i?(m=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-global-poll-section",children:[l,i]}),e[17]=l,e[18]=i,e[19]=m):m=e[19],m},"X"),pe=S(c=>{let e=(0,R.c)(31),{initialShardKey:o}=c,a=j(),{queryShardKey:r,setShardKey:l,shardKey:u}=L(o),d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={},e[0]=d):d=e[0];let n;e[1]!==r?(n={keepPreviousData:!0,shardKey:r},e[1]=r,e[2]=n):n=e[2];let{data:s,error:i,errorSource:m,refetch:I}=B(E.getFanoutMetrics,d,n);Q(I,!0);let g;e[3]!==s?(g=s!==void 0&&X(s),e[3]=s,e[4]=g):g=e[4];let k=g,p;e[5]!==l||e[6]!==u?(p=(0,t.jsx)(G,{onChange:l,testId:"fanout-shard-input",value:u}),e[5]=l,e[6]=u,e[7]=p):p=e[7];let f;e[8]!==s||e[9]!==a?(f=s!==void 0&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"fanout-count",children:[s.promoted&&(0,t.jsx)($,{"data-testid":"fanout-promoted",variant:s.relayCount>=s.maxRelays?"destructive":"default",children:s.relayCount>=s.maxRelays?a("auto-scaled: {relayCount}/{maxRelays} relays (at ceiling)",{maxRelays:s.maxRelays,relayCount:s.relayCount}):a("auto-scaled: {relayCount}/{maxRelays} relays",{maxRelays:s.maxRelays,relayCount:s.relayCount})}),(0,t.jsx)($,{variant:"secondary",children:a("{count} connections",{count:s.totalConnections})}),(0,t.jsx)($,{variant:"secondary",children:a("peak {count} subscribers",{count:s.peakSubscribers})})]}),e[8]=s,e[9]=a,e[10]=f):f=e[10];let y;e[11]!==p||e[12]!==f?(y=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[p,f]}),e[11]=p,e[12]=f,e[13]=y):y=e[13];let h;e[14]!==i||e[15]!==m?(h=i!==null&&(0,t.jsx)(W,{error:m,testId:"fanout-error"}),e[14]=i,e[15]=m,e[16]=h):h=e[16];let x;e[17]!==i||e[18]!==k||e[19]!==a?(x=i===null&&k&&(0,t.jsx)(A,{description:a("Realtime fan-out cost and per-topic subscriber counts for this shard."),icon:(0,t.jsx)("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 12h4l3 7 4-14 3 7h2"})}),testId:"fanout-empty",title:a("No fan-out activity yet.")}),e[17]=i,e[18]=k,e[19]=a,e[20]=x):x=e[20];let N;e[21]!==i||e[22]!==k||e[23]!==s||e[24]!==a?(N=i===null&&s!==void 0&&!k&&(0,t.jsxs)(t.Fragment,{children:[s.topics.length>0&&(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-topics-section",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:a("Hot topics")}),(0,t.jsx)(_,{className:"overflow-hidden py-0",children:(0,t.jsxs)(q,{"data-testid":"fanout-topics-table",children:[(0,t.jsx)(H,{children:(0,t.jsxs)(K,{children:[(0,t.jsx)(T,{children:a("Topic")}),(0,t.jsx)(T,{children:a("Kind")}),(0,t.jsx)(T,{className:"text-right",children:a("Subscribers")})]})}),(0,t.jsx)(O,{children:s.topics.map(ee)})]})})]}),(0,t.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"fanout-cost",children:[(0,t.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:a("Fan-out cost since this instance woke")}),(0,t.jsx)(z,{counters:s.shapePoke,includeTiming:!0,prefix:"fanout-poke",t:a,title:a("Shape pokes")}),(0,t.jsx)(z,{counters:s.whisper,includeTiming:!1,prefix:"fanout-whisper",t:a,title:a("Whisper broadcasts")}),(0,t.jsx)(Y,{counters:s.shapeProbe,t:a}),(0,t.jsx)(Z,{counters:s.globalPoll,t:a})]})]}),e[21]=i,e[22]=k,e[23]=s,e[24]=a,e[25]=N):N=e[25];let b;return e[26]!==y||e[27]!==h||e[28]!==x||e[29]!==N?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"fanout-panel",children:[y,h,x,N]}),e[26]=y,e[27]=h,e[28]=x,e[29]=N,e[30]=b):b=e[30],b},"me");function ee(c){return(0,t.jsxs)(K,{"data-testid":"fanout-topic-row",children:[(0,t.jsx)(D,{className:"font-mono text-xs",children:c.topic}),(0,t.jsx)(D,{children:(0,t.jsx)($,{variant:"outline",children:c.kind})}),(0,t.jsx)(D,{className:"text-right font-medium tabular-nums",children:c.subscribers})]},`${c.kind}:${c.topic}`)}S(ee,"Y");export{pe as default};
1
+ import{a as v}from"./chunk-F7UC63UN.js";import{a as Q}from"./chunk-66UGPQVC.js";import{a as L}from"./chunk-S3CRZLGS.js";import{a as G}from"./chunk-2DX5MROH.js";import"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import"./chunk-AAVLPU5Q.js";import{b as $}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as W}from"./chunk-FDB7QVEC.js";import"./chunk-ULIQFBZU.js";import"./chunk-2KM4MU7U.js";import"./chunk-35DM4JJG.js";import{a as E}from"./chunk-4ZEL6BYL.js";import{c as B}from"./chunk-7TRN7FQ4.js";import"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import"./chunk-GETL6R4M.js";import{a as A}from"./chunk-FKVZRPV5.js";import{a as q,b as H,c as O,d as K,e as T,f as D}from"./chunk-HEAQVSNS.js";import{a as _}from"./chunk-WUWBZPUK.js";import{d as j}from"./chunk-FODLDLE2.js";import{a as S,d as F,f as J,g as V}from"./chunk-YKXDMIHQ.js";var R=F(J(),1);var t=F(V(),1);var U=S(c=>`${c.toString()} ms`,"D"),X=S(c=>c.totalConnections===0&&c.shapePoke.passes===0&&c.whisper.passes===0&&c.shapeProbe.run===0&&c.shapeProbe.served===0&&c.globalPoll.drains===0&&c.globalPoll.pairsSkipped===0,"J"),z=S(c=>{let e=(0,R.c)(48),{counters:o,includeTiming:a,prefix:r,t:l,title:u}=c,d=`${r}-section`,n;e[0]!==u?(n=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:u}),e[0]=u,e[1]=n):n=e[1];let s=`${r}-stats`,i;e[2]!==l?(i=l("Passes"),e[2]=l,e[3]=i):i=e[3];let m=`${r}-passes`,I;e[4]!==o.passes||e[5]!==i||e[6]!==m?(I=(0,t.jsx)(v,{label:i,testId:m,value:o.passes}),e[4]=o.passes,e[5]=i,e[6]=m,e[7]=I):I=e[7];let g;e[8]!==l?(g=l("Sockets iterated"),e[8]=l,e[9]=g):g=e[9];let k=`${r}-iterated`,p;e[10]!==o.socketsIterated||e[11]!==g||e[12]!==k?(p=(0,t.jsx)(v,{label:g,testId:k,value:o.socketsIterated}),e[10]=o.socketsIterated,e[11]=g,e[12]=k,e[13]=p):p=e[13];let f;e[14]!==l?(f=l("Delivered"),e[14]=l,e[15]=f):f=e[15];let y=`${r}-delivered`,h;e[16]!==o.socketsDelivered||e[17]!==f||e[18]!==y?(h=(0,t.jsx)(v,{label:f,testId:y,value:o.socketsDelivered}),e[16]=o.socketsDelivered,e[17]=f,e[18]=y,e[19]=h):h=e[19];let x;e[20]!==l?(x=l("Peak width"),e[20]=l,e[21]=x):x=e[21];let N=`${r}-peak`,b;e[22]!==o.peakSocketsIterated||e[23]!==x||e[24]!==N?(b=(0,t.jsx)(v,{label:x,testId:N,value:o.peakSocketsIterated}),e[22]=o.peakSocketsIterated,e[23]=x,e[24]=N,e[25]=b):b=e[25];let C;e[26]!==o.totalMs||e[27]!==a||e[28]!==r||e[29]!==l?(C=a&&(0,t.jsx)(v,{label:l("Total time"),testId:`${r}-total-ms`,value:U(o.totalMs)}),e[26]=o.totalMs,e[27]=a,e[28]=r,e[29]=l,e[30]=C):C=e[30];let P;e[31]!==o.maxMs||e[32]!==a||e[33]!==r||e[34]!==l?(P=a&&(0,t.jsx)(v,{label:l("Max time"),testId:`${r}-max-ms`,value:U(o.maxMs)}),e[31]=o.maxMs,e[32]=a,e[33]=r,e[34]=l,e[35]=P):P=e[35];let M;e[36]!==h||e[37]!==b||e[38]!==C||e[39]!==P||e[40]!==s||e[41]!==I||e[42]!==p?(M=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":s,children:[I,p,h,b,C,P]}),e[36]=h,e[37]=b,e[38]=C,e[39]=P,e[40]=s,e[41]=I,e[42]=p,e[43]=M):M=e[43];let w;return e[44]!==d||e[45]!==M||e[46]!==n?(w=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":d,children:[n,M]}),e[44]=d,e[45]=M,e[46]=n,e[47]=w):w=e[47],w},"F"),Y=S(c=>{let e=(0,R.c)(20),{counters:o,t:a}=c,r;e[0]!==a?(r=a("Membership probes"),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==r?(l=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:r}),e[2]=r,e[3]=l):l=e[3];let u;e[4]!==a?(u=a("Queries run"),e[4]=a,e[5]=u):u=e[5];let d;e[6]!==o.run||e[7]!==u?(d=(0,t.jsx)(v,{label:u,testId:"fanout-probe-run",value:o.run}),e[6]=o.run,e[7]=u,e[8]=d):d=e[8];let n;e[9]!==a?(n=a("Shared from cache"),e[9]=a,e[10]=n):n=e[10];let s;e[11]!==o.served||e[12]!==n?(s=(0,t.jsx)(v,{label:n,testId:"fanout-probe-served",value:o.served}),e[11]=o.served,e[12]=n,e[13]=s):s=e[13];let i;e[14]!==d||e[15]!==s?(i=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"fanout-probe-stats",children:[d,s]}),e[14]=d,e[15]=s,e[16]=i):i=e[16];let m;return e[17]!==l||e[18]!==i?(m=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-probe-section",children:[l,i]}),e[17]=l,e[18]=i,e[19]=m):m=e[19],m},"V"),Z=S(c=>{let e=(0,R.c)(20),{counters:o,t:a}=c,r;e[0]!==a?(r=a("Global shape polls"),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==r?(l=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:r}),e[2]=r,e[3]=l):l=e[3];let u;e[4]!==a?(u=a("Global reads"),e[4]=a,e[5]=u):u=e[5];let d;e[6]!==o.drains||e[7]!==u?(d=(0,t.jsx)(v,{label:u,testId:"fanout-global-poll-drains",value:o.drains}),e[6]=o.drains,e[7]=u,e[8]=d):d=e[8];let n;e[9]!==a?(n=a("Pairs skipped"),e[9]=a,e[10]=n):n=e[10];let s;e[11]!==o.pairsSkipped||e[12]!==n?(s=(0,t.jsx)(v,{label:n,testId:"fanout-global-poll-pairs-skipped",value:o.pairsSkipped}),e[11]=o.pairsSkipped,e[12]=n,e[13]=s):s=e[13];let i;e[14]!==d||e[15]!==s?(i=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"fanout-global-poll-stats",children:[d,s]}),e[14]=d,e[15]=s,e[16]=i):i=e[16];let m;return e[17]!==l||e[18]!==i?(m=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-global-poll-section",children:[l,i]}),e[17]=l,e[18]=i,e[19]=m):m=e[19],m},"X"),pe=S(c=>{let e=(0,R.c)(31),{initialShardKey:o}=c,a=j(),{queryShardKey:r,setShardKey:l,shardKey:u}=L(o),d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={},e[0]=d):d=e[0];let n;e[1]!==r?(n={keepPreviousData:!0,shardKey:r},e[1]=r,e[2]=n):n=e[2];let{data:s,error:i,errorSource:m,refetch:I}=B(E.getFanoutMetrics,d,n);Q(I,!0);let g;e[3]!==s?(g=s!==void 0&&X(s),e[3]=s,e[4]=g):g=e[4];let k=g,p;e[5]!==l||e[6]!==u?(p=(0,t.jsx)(G,{onChange:l,testId:"fanout-shard-input",value:u}),e[5]=l,e[6]=u,e[7]=p):p=e[7];let f;e[8]!==s||e[9]!==a?(f=s!==void 0&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"fanout-count",children:[s.promoted&&(0,t.jsx)($,{"data-testid":"fanout-promoted",variant:s.relayCount>=s.maxRelays?"destructive":"default",children:s.relayCount>=s.maxRelays?a("auto-scaled: {relayCount}/{maxRelays} relays (at ceiling)",{maxRelays:s.maxRelays,relayCount:s.relayCount}):a("auto-scaled: {relayCount}/{maxRelays} relays",{maxRelays:s.maxRelays,relayCount:s.relayCount})}),(0,t.jsx)($,{variant:"secondary",children:a("{count} connections",{count:s.totalConnections})}),(0,t.jsx)($,{variant:"secondary",children:a("peak {count} subscribers",{count:s.peakSubscribers})})]}),e[8]=s,e[9]=a,e[10]=f):f=e[10];let y;e[11]!==p||e[12]!==f?(y=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[p,f]}),e[11]=p,e[12]=f,e[13]=y):y=e[13];let h;e[14]!==i||e[15]!==m?(h=i!==null&&(0,t.jsx)(W,{error:m,testId:"fanout-error"}),e[14]=i,e[15]=m,e[16]=h):h=e[16];let x;e[17]!==i||e[18]!==k||e[19]!==a?(x=i===null&&k&&(0,t.jsx)(A,{description:a("Realtime fan-out cost and per-topic subscriber counts for this shard."),icon:(0,t.jsx)("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 12h4l3 7 4-14 3 7h2"})}),testId:"fanout-empty",title:a("No fan-out activity yet.")}),e[17]=i,e[18]=k,e[19]=a,e[20]=x):x=e[20];let N;e[21]!==i||e[22]!==k||e[23]!==s||e[24]!==a?(N=i===null&&s!==void 0&&!k&&(0,t.jsxs)(t.Fragment,{children:[s.topics.length>0&&(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-topics-section",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:a("Hot topics")}),(0,t.jsx)(_,{className:"overflow-hidden py-0",children:(0,t.jsxs)(q,{"data-testid":"fanout-topics-table",children:[(0,t.jsx)(H,{children:(0,t.jsxs)(K,{children:[(0,t.jsx)(T,{children:a("Topic")}),(0,t.jsx)(T,{children:a("Kind")}),(0,t.jsx)(T,{className:"text-right",children:a("Subscribers")})]})}),(0,t.jsx)(O,{children:s.topics.map(ee)})]})})]}),(0,t.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"fanout-cost",children:[(0,t.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:a("Fan-out cost since this instance woke")}),(0,t.jsx)(z,{counters:s.shapePoke,includeTiming:!0,prefix:"fanout-poke",t:a,title:a("Shape pokes")}),(0,t.jsx)(z,{counters:s.whisper,includeTiming:!1,prefix:"fanout-whisper",t:a,title:a("Whisper broadcasts")}),(0,t.jsx)(Y,{counters:s.shapeProbe,t:a}),(0,t.jsx)(Z,{counters:s.globalPoll,t:a})]})]}),e[21]=i,e[22]=k,e[23]=s,e[24]=a,e[25]=N):N=e[25];let b;return e[26]!==y||e[27]!==h||e[28]!==x||e[29]!==N?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"fanout-panel",children:[y,h,x,N]}),e[26]=y,e[27]=h,e[28]=x,e[29]=N,e[30]=b):b=e[30],b},"me");function ee(c){return(0,t.jsxs)(K,{"data-testid":"fanout-topic-row",children:[(0,t.jsx)(D,{className:"font-mono text-xs",children:c.topic}),(0,t.jsx)(D,{children:(0,t.jsx)($,{variant:"outline",children:c.kind})}),(0,t.jsx)(D,{className:"text-right font-medium tabular-nums",children:c.subscribers})]},`${c.kind}:${c.topic}`)}S(ee,"Y");export{pe as default};
@@ -1 +1 @@
1
- import{b as C}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as J}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 z}from"./chunk-SDHFSBNM.js";import"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as E}from"./chunk-FKVZRPV5.js";import{a as G,b as M,c as U,d as P,e as d,f as c}from"./chunk-HEAQVSNS.js";import{a as D,e as _}from"./chunk-WUWBZPUK.js";import{d as q}from"./chunk-FODLDLE2.js";import{a as S,d as O,f as Q,g as V}from"./chunk-YKXDMIHQ.js";var L=O(Q(),1);var r=O(V(),1);var K=["read","insert","update","delete"],B=S((e,s)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[s],"z"),W=S(e=>{let s=new Map;for(let a of e){let t=s.get(a.table)??{operations:new Set,procedures:new Set,table:a.table};t.operations.add(a.on),t.procedures.add(a.procedure),s.set(a.table,t)}return[...s.values()].toSorted((a,t)=>a.table.localeCompare(t.table))},"J"),ie=S(()=>{let e=(0,L.c)(49),s=q(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let{data:t,error:R,errorSource:k}=z(H.rlsPolicies,a),p=t!==void 0,m,n,h,l,f,u,x,b,o;if(e[1]!==t||e[2]!==R||e[3]!==k||e[4]!==p||e[5]!==s){let $=W(Array.isArray(t?.policies)?t.policies:[]),j;e[15]!==t?(j=Array.isArray(t?.roles)?t.roles:[],e[15]=t,e[16]=j):j=e[16],n=j,x="flex flex-col gap-6",b="lunora-rls-panel",e[17]!==R||e[18]!==k?(o=R!==null&&(0,r.jsx)(J,{error:k,testId:"rls-error"}),e[17]=R,e[18]=k,e[19]=o):o=e[19],u="flex flex-col gap-2",m=D,h="overflow-hidden py-0";let I;e[20]!==s?(I=s("Policies"),e[20]=s,e[21]=I):I=e[21],e[22]!==I?(l=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:I})}),e[22]=I,e[23]=l):l=e[23],f=p&&$.length===0?(0,r.jsx)(E,{description:s("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:s("No policies defined")}):(0,r.jsx)(_,{className:"px-0",children:(0,r.jsxs)(G,{"data-testid":"rls-policies-table",children:[(0,r.jsx)(M,{children:(0,r.jsxs)(P,{children:[(0,r.jsx)(d,{children:s("Table")}),K.map(i=>(0,r.jsx)(d,{children:B(s,i)},i)),(0,r.jsx)(d,{children:s("Guarded by")})]})}),(0,r.jsx)(U,{children:$.map(i=>(0,r.jsxs)(P,{"data-testid":`rls-table-${i.table}`,children:[(0,r.jsx)(c,{className:"font-mono text-xs",children:i.table}),K.map(F=>(0,r.jsx)(c,{children:i.operations.has(F)?(0,r.jsx)(C,{variant:"secondary",children:s("Guarded")}):(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"})},F)),(0,r.jsx)(c,{className:"font-mono text-xs text-muted-foreground",children:[...i.procedures].join(", ")})]},i.table))})]})}),e[1]=t,e[2]=R,e[3]=k,e[4]=p,e[5]=s,e[6]=m,e[7]=n,e[8]=h,e[9]=l,e[10]=f,e[11]=u,e[12]=x,e[13]=b,e[14]=o}else m=e[6],n=e[7],h=e[8],l=e[9],f=e[10],u=e[11],x=e[12],b=e[13],o=e[14];let N;e[24]!==m||e[25]!==h||e[26]!==l||e[27]!==f?(N=(0,r.jsxs)(m,{className:h,children:[l,f]}),e[24]=m,e[25]=h,e[26]=l,e[27]=f,e[28]=N):N=e[28];let g;e[29]!==u||e[30]!==N?(g=(0,r.jsx)("section",{className:u,children:N}),e[29]=u,e[30]=N,e[31]=g):g=e[31];let y;e[32]!==s?(y=s("Roles"),e[32]=s,e[33]=y):y=e[33];let w;e[34]!==y?(w=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y})}),e[34]=y,e[35]=w):w=e[35];let v;e[36]!==p||e[37]!==n||e[38]!==s?(v=p&&n.length===0?(0,r.jsx)(E,{description:s("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:s("No roles defined")}):(0,r.jsx)(_,{className:"px-0",children:(0,r.jsxs)(G,{"data-testid":"rls-roles-table",children:[(0,r.jsx)(M,{children:(0,r.jsxs)(P,{children:[(0,r.jsx)(d,{children:s("Role")}),(0,r.jsx)(d,{children:s("Description")}),(0,r.jsx)(d,{children:s("Permissions")})]})}),(0,r.jsx)(U,{children:n.map(Y)})]})}),e[36]=p,e[37]=n,e[38]=s,e[39]=v):v=e[39];let A;e[40]!==w||e[41]!==v?(A=(0,r.jsx)("section",{className:"flex flex-col gap-2",children:(0,r.jsxs)(D,{className:"overflow-hidden py-0",children:[w,v]})}),e[40]=w,e[41]=v,e[42]=A):A=e[42];let T;return e[43]!==A||e[44]!==x||e[45]!==b||e[46]!==o||e[47]!==g?(T=(0,r.jsxs)("div",{className:x,"data-testid":b,children:[o,g,A]}),e[43]=A,e[44]=x,e[45]=b,e[46]=o,e[47]=g,e[48]=T):T=e[48],T},"oe");function X(e){return(0,r.jsx)(C,{variant:"outline",children:e},e)}S(X,"K");function Y(e){return(0,r.jsxs)(P,{"data-testid":`rls-role-${e.name}`,children:[(0,r.jsx)(c,{className:"font-mono text-xs",children:e.name}),(0,r.jsx)(c,{className:"text-muted-foreground",children:e.description??""}),(0,r.jsx)(c,{children:e.permissions.length===0?(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,r.jsx)("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(X)})})]},e.name)}S(Y,"V");export{ie as default};
1
+ import{b as C}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as J}from"./chunk-FDB7QVEC.js";import"./chunk-ULIQFBZU.js";import"./chunk-2KM4MU7U.js";import"./chunk-35DM4JJG.js";import{a as H}from"./chunk-4ZEL6BYL.js";import{c as z}from"./chunk-7TRN7FQ4.js";import"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import"./chunk-GETL6R4M.js";import{a as E}from"./chunk-FKVZRPV5.js";import{a as G,b as M,c as U,d as P,e as d,f as c}from"./chunk-HEAQVSNS.js";import{a as D,e as _}from"./chunk-WUWBZPUK.js";import{d as q}from"./chunk-FODLDLE2.js";import{a as S,d as O,f as Q,g as V}from"./chunk-YKXDMIHQ.js";var L=O(Q(),1);var r=O(V(),1);var K=["read","insert","update","delete"],B=S((e,s)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[s],"z"),W=S(e=>{let s=new Map;for(let a of e){let t=s.get(a.table)??{operations:new Set,procedures:new Set,table:a.table};t.operations.add(a.on),t.procedures.add(a.procedure),s.set(a.table,t)}return[...s.values()].toSorted((a,t)=>a.table.localeCompare(t.table))},"J"),ie=S(()=>{let e=(0,L.c)(49),s=q(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let{data:t,error:R,errorSource:k}=z(H.rlsPolicies,a),p=t!==void 0,m,n,h,l,f,u,x,b,o;if(e[1]!==t||e[2]!==R||e[3]!==k||e[4]!==p||e[5]!==s){let $=W(Array.isArray(t?.policies)?t.policies:[]),j;e[15]!==t?(j=Array.isArray(t?.roles)?t.roles:[],e[15]=t,e[16]=j):j=e[16],n=j,x="flex flex-col gap-6",b="lunora-rls-panel",e[17]!==R||e[18]!==k?(o=R!==null&&(0,r.jsx)(J,{error:k,testId:"rls-error"}),e[17]=R,e[18]=k,e[19]=o):o=e[19],u="flex flex-col gap-2",m=D,h="overflow-hidden py-0";let I;e[20]!==s?(I=s("Policies"),e[20]=s,e[21]=I):I=e[21],e[22]!==I?(l=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:I})}),e[22]=I,e[23]=l):l=e[23],f=p&&$.length===0?(0,r.jsx)(E,{description:s("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:s("No policies defined")}):(0,r.jsx)(_,{className:"px-0",children:(0,r.jsxs)(G,{"data-testid":"rls-policies-table",children:[(0,r.jsx)(M,{children:(0,r.jsxs)(P,{children:[(0,r.jsx)(d,{children:s("Table")}),K.map(i=>(0,r.jsx)(d,{children:B(s,i)},i)),(0,r.jsx)(d,{children:s("Guarded by")})]})}),(0,r.jsx)(U,{children:$.map(i=>(0,r.jsxs)(P,{"data-testid":`rls-table-${i.table}`,children:[(0,r.jsx)(c,{className:"font-mono text-xs",children:i.table}),K.map(F=>(0,r.jsx)(c,{children:i.operations.has(F)?(0,r.jsx)(C,{variant:"secondary",children:s("Guarded")}):(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"})},F)),(0,r.jsx)(c,{className:"font-mono text-xs text-muted-foreground",children:[...i.procedures].join(", ")})]},i.table))})]})}),e[1]=t,e[2]=R,e[3]=k,e[4]=p,e[5]=s,e[6]=m,e[7]=n,e[8]=h,e[9]=l,e[10]=f,e[11]=u,e[12]=x,e[13]=b,e[14]=o}else m=e[6],n=e[7],h=e[8],l=e[9],f=e[10],u=e[11],x=e[12],b=e[13],o=e[14];let N;e[24]!==m||e[25]!==h||e[26]!==l||e[27]!==f?(N=(0,r.jsxs)(m,{className:h,children:[l,f]}),e[24]=m,e[25]=h,e[26]=l,e[27]=f,e[28]=N):N=e[28];let g;e[29]!==u||e[30]!==N?(g=(0,r.jsx)("section",{className:u,children:N}),e[29]=u,e[30]=N,e[31]=g):g=e[31];let y;e[32]!==s?(y=s("Roles"),e[32]=s,e[33]=y):y=e[33];let w;e[34]!==y?(w=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y})}),e[34]=y,e[35]=w):w=e[35];let v;e[36]!==p||e[37]!==n||e[38]!==s?(v=p&&n.length===0?(0,r.jsx)(E,{description:s("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:s("No roles defined")}):(0,r.jsx)(_,{className:"px-0",children:(0,r.jsxs)(G,{"data-testid":"rls-roles-table",children:[(0,r.jsx)(M,{children:(0,r.jsxs)(P,{children:[(0,r.jsx)(d,{children:s("Role")}),(0,r.jsx)(d,{children:s("Description")}),(0,r.jsx)(d,{children:s("Permissions")})]})}),(0,r.jsx)(U,{children:n.map(Y)})]})}),e[36]=p,e[37]=n,e[38]=s,e[39]=v):v=e[39];let A;e[40]!==w||e[41]!==v?(A=(0,r.jsx)("section",{className:"flex flex-col gap-2",children:(0,r.jsxs)(D,{className:"overflow-hidden py-0",children:[w,v]})}),e[40]=w,e[41]=v,e[42]=A):A=e[42];let T;return e[43]!==A||e[44]!==x||e[45]!==b||e[46]!==o||e[47]!==g?(T=(0,r.jsxs)("div",{className:x,"data-testid":b,children:[o,g,A]}),e[43]=A,e[44]=x,e[45]=b,e[46]=o,e[47]=g,e[48]=T):T=e[48],T},"oe");function X(e){return(0,r.jsx)(C,{variant:"outline",children:e},e)}S(X,"K");function Y(e){return(0,r.jsxs)(P,{"data-testid":`rls-role-${e.name}`,children:[(0,r.jsx)(c,{className:"font-mono text-xs",children:e.name}),(0,r.jsx)(c,{className:"text-muted-foreground",children:e.description??""}),(0,r.jsx)(c,{children:e.permissions.length===0?(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,r.jsx)("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(X)})})]},e.name)}S(Y,"V");export{ie as default};
@@ -1 +1 @@
1
- import{a as Qe}from"./chunk-5XRNQ732.js";import{a as Me,b as Re}from"./chunk-CSUROWL2.js";import"./chunk-RFNGDE33.js";import"./chunk-V3CZW3JB.js";import"./chunk-MU3P2FI7.js";import{a as we}from"./chunk-IMOHEGMV.js";import"./chunk-YPRQLCKF.js";import"./chunk-GMS77BZD.js";import"./chunk-3Q2P62UR.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import"./chunk-5JDWLCSH.js";import{a as He}from"./chunk-S3CRZLGS.js";import{a as Xe}from"./chunk-2DX5MROH.js";import{b as We}from"./chunk-OGUKYRFM.js";import{e as Ue}from"./chunk-6D6Z2KXU.js";import"./chunk-OKG3HWSJ.js";import{W as Ae}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as me}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as ze}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as je}from"./chunk-4ZEL6BYL.js";import{f as Ve}from"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as Je}from"./chunk-FKVZRPV5.js";import{a as qe,b as Pe,c as Ge,d as Ke,e as Le}from"./chunk-WUWBZPUK.js";import{d as Fe,f as Ee,g as $e,h as Oe,o as ue}from"./chunk-FODLDLE2.js";import{a as r,d as Be,e as at,f as nt,g as st,i as De}from"./chunk-YKXDMIHQ.js";var Ce=Be(nt(),1);var x=Be(at(),1);var t=Be(st(),1);var rt=Ee(je.listTables),ot=Ee(je.listTableIndexes),it=Ee(je.readTablePage),dt=Ee(je.describeTables),ct={},Ye=[],mt=r(s=>{let e=(0,Ce.c)(74),{initialShardKey:u,initialTable:n}=s,l=Ve(),[a,m]=(0,x.useState)("graph"),{queryShardKey:c,setShardKey:d,shardKey:g}=He(u),[o,b]=(0,x.useState)(""),[i,v]=(0,x.useState)(null),[p,P]=(0,x.useState)(null),_;e[0]===Symbol.for("react.memo_cache_sentinel")?(_={},e[0]=_):_=e[0];let[L,y]=(0,x.useState)(_),G;e[1]===Symbol.for("react.memo_cache_sentinel")?(G={},e[1]=G):G=e[1];let[E,M]=(0,x.useState)(G),[S,C]=(0,x.useState)(null),F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F={},e[2]=F):F=e[2];let[$,he]=(0,x.useState)(F),Q;e[3]===Symbol.for("react.memo_cache_sentinel")?(Q={},e[3]=Q):Q=e[3];let[I,K]=(0,x.useState)(Q),[k,be]=(0,x.useState)(null),[B,oe]=(0,x.useState)(null),Y;e[4]===Symbol.for("react.memo_cache_sentinel")?(Y={},e[4]=Y):Y=e[4];let[J,xe]=(0,x.useState)(Y),[W,ie]=(0,x.useState)(null),ve;e[5]!==l?(ve=r(async h=>{P(null);try{let w=await l.query(rt,{},$e(h));We(h),v(w),y({}),M({}),C(null),he(N=>Object.fromEntries(Object.entries(N).filter(q=>{let[A]=q;return A!==h}))),K(N=>Object.fromEntries(Object.entries(N).filter(q=>{let[A]=q;return A!==h})))}catch(w){let N=w;v(null),P(Oe(N))}},"ve"),e[5]=l,e[6]=ve):ve=e[6];let O=ve,Z;e[7]!==l?(Z=r(async()=>{oe(null);try{be(await l.listGlobalTables())}catch(h){let w=h;be(null),oe(Oe(w))}},"Z"),e[7]=l,e[8]=Z):Z=e[8];let ee=Z,de,D;e[9]!==c||e[10]!==O||e[11]!==ee?(de=r(()=>{ue(O(c)),ue(ee())},"de"),D=[O,ee,c],e[9]=c,e[10]=O,e[11]=ee,e[12]=de,e[13]=D):(de=e[12],D=e[13]),(0,x.useEffect)(de,D);let te;e[14]!==l||e[15]!==L||e[16]!==S||e[17]!==c?(te=r(async h=>{if(S===h){C(null);return}C(h);let w=`${c}:${h}`;if(L[w]!==void 0)return;let[N,q]=await Promise.allSettled([l.query(it,{limit:1,offset:0,table:h},$e(c)),l.query(ot,{table:h},$e(c))]);N.status==="fulfilled"?y(A=>({...A,[w]:N.value.columns})):P(Oe(N.reason)),q.status==="fulfilled"&&M(A=>({...A,[w]:q.value.indexes}))},"te"),e[14]=l,e[15]=L,e[16]=S,e[17]=c,e[18]=te):te=e[18];let j=te,ye;e[19]!==l||e[20]!==J||e[21]!==W?(ye=r(async h=>{if(W===h){ie(null);return}if(ie(h),J[h]===void 0)try{let w=await l.readGlobalTablePage({limit:1,offset:0,table:h});xe(N=>({...N,[h]:w.columns}))}catch(w){oe(Oe(w))}},"ye"),e[19]=l,e[20]=J,e[21]=W,e[22]=ye):ye=e[22];let ce=ye,pe=(0,x.useRef)(void 0),R,X;e[23]!==n||e[24]!==i||e[25]!==j?(R=r(()=>{n===void 0||i===null||pe.current===n||i.some(h=>h.name===n)&&(pe.current=n,ue(j(n)))},"K"),X=[n,i,j],e[23]=n,e[24]=i,e[25]=j,e[26]=R,e[27]=X):(R=e[26],X=e[27]),(0,x.useEffect)(R,X);let V;e[28]!==l?(V=r(async(h,w,N)=>{let[q,A]=await Promise.all([Promise.allSettled([l.query(dt,{tables:[...w,...N]},$e(h))]),Promise.all(N.map(async T=>{let ge=await Promise.allSettled([l.readGlobalTablePage({limit:1,offset:0,table:T})]),Ie=ge[0].status==="fulfilled"?ge[0].value:void 0;return{columns:Ie?.columns??[],refs:Ie?.refs??{},table:T}}))]),Te=q[0].status==="fulfilled"?q[0].value?.columnsByTable??{}:{},Se=q[0].status==="rejected",_e=new Map(A.map(ut)),ke=[...w,...N].map(T=>{let ge=Te[T]??[];return[T,ge.length>0?ge:_e.get(T)??[]]});he(T=>({...T,[h]:Object.fromEntries(ke)})),K(T=>({...T,[h]:Se}))},"U"),e[28]=l,e[29]=V):V=e[29];let le=V,U,ae;e[30]!==B||e[31]!==k||e[32]!==le||e[33]!==c||e[34]!==$||e[35]!==i||e[36]!==a?(U=r(()=>{a!=="graph"||i===null||k===null&&B===null||$[c]!==void 0||ue(le(c,i.map(ht),(k??[]).map(bt)))},"V"),ae=[a,i,k,B,c,$,le],e[30]=B,e[31]=k,e[32]=le,e[33]=c,e[34]=$,e[35]=i,e[36]=a,e[37]=U,e[38]=ae):(U=e[37],ae=e[38]),(0,x.useEffect)(U,ae);let z=$[c]??ct,ne;if(e[39]!==z||e[40]!==k||e[41]!==i){let h;e[43]!==z?(h=r(A=>({columns:z[A.name]??Ye,name:A.name,tier:"shard"}),"u"),e[43]=z,e[44]=h):h=e[44];let w=(i??[]).map(h),N;e[45]!==z?(N=r(A=>({columns:z[A.name]??Ye,name:A.name,tier:"global"}),"x"),e[45]=z,e[46]=N):N=e[46];let q=(k??[]).map(N);ne=[...w,...q],e[39]=z,e[40]=k,e[41]=i,e[42]=ne}else ne=e[42];let se=ne,f;if(e[47]!==o||e[48]!==i){let h=o.trim().toLowerCase();f=(i??[]).filter(w=>w.name.toLowerCase().includes(h)),e[47]=o,e[48]=i,e[49]=f}else f=e[49];let re=f,H;if(e[50]!==k||e[51]!==o){let h=o.trim().toLowerCase();H=(k??[]).filter(w=>w.name.toLowerCase().includes(h)),e[50]=k,e[51]=o,e[52]=H}else H=e[52];let Ne=H,fe;return e[53]!==L||e[54]!==se||e[55]!==p||e[56]!==S||e[57]!==Ne||e[58]!==re||e[59]!==J||e[60]!==B||e[61]!==W||e[62]!==k||e[63]!==E||e[64]!==O||e[65]!==d||e[66]!==I||e[67]!==g||e[68]!==o||e[69]!==i||e[70]!==j||e[71]!==ce||e[72]!==a?(fe={columns:L,diagramTables:se,error:p,expanded:S,filteredGlobalTables:Ne,filteredTables:re,globalColumns:J,globalError:B,globalExpanded:W,globalTables:k,indexes:E,refresh:O,setShardKey:d,setTableFilter:b,setView:m,shardColumnsError:I,shardKey:g,tableFilter:o,tables:i,toggle:j,toggleGlobal:ce,view:a},e[53]=L,e[54]=se,e[55]=p,e[56]=S,e[57]=Ne,e[58]=re,e[59]=J,e[60]=B,e[61]=W,e[62]=k,e[63]=E,e[64]=O,e[65]=d,e[66]=I,e[67]=g,e[68]=o,e[69]=i,e[70]=j,e[71]=ce,e[72]=a,e[73]=fe):fe=e[73],fe},"ct");function ut(s){let{columns:e,refs:u,table:n}=s;return[n,e.map(l=>{let a=u[l];return a===void 0?{name:l,optional:!1,type:""}:{name:l,optional:!1,ref:a,type:"id"}})]}r(ut,"mt");function ht(s){return s.name}r(ht,"ut");function bt(s){return s.name}r(bt,"ft");var pt="/__lunora/schema-edit",ft=r(async s=>{let e=await fetch(pt,{body:JSON.stringify(s),headers:{"Content-Type":"application/json"},method:"POST"}),u=await e.json();return u.needsMigration===!0?{kind:"needs-migration",message:u.message??"This edit needs a migration."}:e.ok&&u.tables!==void 0?{diagnostics:u.diagnostics??[],kind:"ok",tables:u.tables}:{kind:"error",message:u.error??`schema edit failed (${String(e.status)})`}},"pt"),gt=r(s=>{let e=(0,Ce.c)(32),{hasTables:u,mode:n,onAddColumn:l,onAddIndex:a,onAddTable:m,onDestructive:c}=s,d=Fe(),g=n==="addTable"?"default":"outline",o;e[0]!==d?(o=d("Add table"),e[0]=d,e[1]=o):o=e[1];let b;e[2]!==m||e[3]!==g||e[4]!==o?(b=(0,t.jsx)(me,{"data-testid":"sc-editor-add-table",onClick:m,size:"xs",type:"button",variant:g,children:o}),e[2]=m,e[3]=g,e[4]=o,e[5]=b):b=e[5];let i=!u,v=n==="addColumn"?"default":"outline",p;e[6]!==d?(p=d("Add column"),e[6]=d,e[7]=p):p=e[7];let P;e[8]!==l||e[9]!==i||e[10]!==v||e[11]!==p?(P=(0,t.jsx)(me,{"data-testid":"sc-editor-add-column",disabled:i,onClick:l,size:"xs",type:"button",variant:v,children:p}),e[8]=l,e[9]=i,e[10]=v,e[11]=p,e[12]=P):P=e[12];let _=!u,L=n==="addIndex"?"default":"outline",y;e[13]!==d?(y=d("Add index"),e[13]=d,e[14]=y):y=e[14];let G;e[15]!==a||e[16]!==y||e[17]!==_||e[18]!==L?(G=(0,t.jsx)(me,{"data-testid":"sc-editor-add-index",disabled:_,onClick:a,size:"xs",type:"button",variant:L,children:y}),e[15]=a,e[16]=y,e[17]=_,e[18]=L,e[19]=G):G=e[19];let E=!u,M=n==="destructive"?"default":"ghost",S;e[20]!==d?(S=d("Rename / drop / change type\u2026"),e[20]=d,e[21]=S):S=e[21];let C;e[22]!==c||e[23]!==E||e[24]!==M||e[25]!==S?(C=(0,t.jsx)(me,{"data-testid":"sc-editor-destructive",disabled:E,onClick:c,size:"xs",type:"button",variant:M,children:S}),e[22]=c,e[23]=E,e[24]=M,e[25]=S,e[26]=C):C=e[26];let F;return e[27]!==G||e[28]!==C||e[29]!==b||e[30]!==P?(F=(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[b,P,G,C]}),e[27]=G,e[28]=C,e[29]=b,e[30]=P,e[31]=F):F=e[31],F},"gt"),xt=r(s=>{let e=(0,Ce.c)(28),{onOpenMigrations:u,result:n}=s,l=Fe();if(n===null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[0]=o):o=e[0],o}if(n.kind==="error"){let o;return e[1]!==n.message?(o=(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:n.message}),e[1]=n.message,e[2]=o):o=e[2],o}if(n.kind==="needs-migration"){let o;e[3]!==n.message||e[4]!==l?(o=n.message===""?l("This edit changes stored data and must go through a migration. Review the migration before applying."):n.message,e[3]=n.message,e[4]=l,e[5]=o):o=e[5];let b;e[6]!==o?(b=(0,t.jsx)("p",{className:"text-sm text-warning",role:"alert",children:o}),e[6]=o,e[7]=b):b=e[7];let i;e[8]!==l?(i=l("Open Migrations"),e[8]=l,e[9]=i):i=e[9];let v;e[10]!==u||e[11]!==i?(v=(0,t.jsx)(me,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:u,size:"xs",type:"button",variant:"outline",children:i}),e[10]=u,e[11]=i,e[12]=v):v=e[12];let p;return e[13]!==b||e[14]!==v?(p=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[b,v]}),e[13]=b,e[14]=v,e[15]=p):p=e[15],p}if(n.diagnostics.length===0){let o;return e[16]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[16]=o):o=e[16],o}let a;e[17]!==l?(a=l("Codegen reported diagnostics:"),e[17]=l,e[18]=a):a=e[18];let m;e[19]!==a?(m=(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:a}),e[19]=a,e[20]=m):m=e[20];let c;e[21]!==n.diagnostics?(c=n.diagnostics.map(vt),e[21]=n.diagnostics,e[22]=c):c=e[22];let d;e[23]!==c?(d=(0,t.jsx)("ul",{className:"flex flex-col gap-0.5",children:c}),e[23]=c,e[24]=d):d=e[24];let g;return e[25]!==m||e[26]!==d?(g=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[m,d]}),e[25]=m,e[26]=d,e[27]=g):g=e[27],g},"bt");function vt(s){return(0,t.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:s},s)}r(vt,"xt");var yt=[{label:"string",validator:"v.string()"},{label:"number",validator:"v.number()"},{label:"boolean",validator:"v.boolean()"},{label:"bigint",validator:"v.bigint()"},{label:"bytes",validator:"v.bytes()"},{label:"any",validator:"v.any()"}],Nt="v.string()",Ct=r(s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),"Ct"),wt=r(s=>{let e=(0,Ce.c)(83),{onApplied:u,tableNames:n}=s,l=Fe(),a=Ue(),[m,c]=(0,x.useState)(null),[d,g]=(0,x.useState)(!1),[o,b]=(0,x.useState)(null),[i,v]=(0,x.useState)(""),[p,P]=(0,x.useState)(""),[_,L]=(0,x.useState)(Nt),[y,G]=(0,x.useState)(n[0]??""),[E,M]=(0,x.useState)(""),[S,C]=(0,x.useState)(""),[F,$]=(0,x.useState)(!1),he;e[0]===Symbol.for("react.memo_cache_sentinel")?(he=r(()=>{c(null),v(""),P(""),M(""),C(""),$(!1)},"me"),e[0]=he):he=e[0];let Q=he,I;e[1]!==u?(I=r(async T=>{g(!0),b(null);try{let ge=await ft(T);b(ge),ge.kind==="ok"&&(u(ge.tables),Q())}catch(ge){let Ie=ge;b({kind:"error",message:Ie instanceof Error?Ie.message:String(Ie)})}g(!1)},"I"),e[1]=u,e[2]=I):I=e[2];let K=I,k;e[3]!==K||e[4]!==i?(k=r(()=>{ue(K({kind:"addTable",table:i.trim()}))},"_"),e[3]=K,e[4]=i,e[5]=k):k=e[5];let be=k,B;e[6]!==p||e[7]!==K||e[8]!==y||e[9]!==_?(B=r(()=>{ue(K({column:p.trim(),kind:"addOptionalColumn",table:y,validator:_}))},"j"),e[6]=p,e[7]=K,e[8]=y,e[9]=_,e[10]=B):B=e[10];let oe=B,Y;e[11]!==S||e[12]!==E||e[13]!==K||e[14]!==y||e[15]!==F?(Y=r(()=>{ue(K({fields:Ct(S),kind:"addIndex",name:E.trim(),table:y,unique:F}))},"Q"),e[11]=S,e[12]=E,e[13]=K,e[14]=y,e[15]=F,e[16]=Y):Y=e[16];let J=Y,xe;e[17]===Symbol.for("react.memo_cache_sentinel")?(xe=r(()=>{b(null),c("addTable")},"xe"),e[17]=xe):xe=e[17];let W=xe,ie;e[18]===Symbol.for("react.memo_cache_sentinel")?(ie=r(()=>{b(null),c("addColumn")},"re"),e[18]=ie):ie=e[18];let ve=ie,O;e[19]===Symbol.for("react.memo_cache_sentinel")?(O=r(()=>{b(null),c("addIndex")},"O"),e[19]=O):O=e[19];let Z=O,ee;e[20]!==l?(ee=r(()=>{c("destructive"),b({kind:"needs-migration",message:l("This edit changes stored data and must go through a migration. Review the migration before applying.")})},"ee"),e[20]=l,e[21]=ee):ee=e[21];let de=ee,D;e[22]===Symbol.for("react.memo_cache_sentinel")?(D=r(T=>{v(T.target.value)},"R"),e[22]=D):D=e[22];let te=D,j;e[23]===Symbol.for("react.memo_cache_sentinel")?(j=r(T=>{P(T.target.value)},"M"),e[23]=j):j=e[23];let ye=j,ce;e[24]===Symbol.for("react.memo_cache_sentinel")?(ce=r(T=>{L(T.target.value)},"ce"),e[24]=ce):ce=e[24];let pe=ce,R;e[25]===Symbol.for("react.memo_cache_sentinel")?(R=r(T=>{G(T.target.value)},"K"),e[25]=R):R=e[25];let X=R,V;e[26]===Symbol.for("react.memo_cache_sentinel")?(V=r(T=>{M(T.target.value)},"U"),e[26]=V):V=e[26];let le=V,U;e[27]===Symbol.for("react.memo_cache_sentinel")?(U=r(T=>{C(T.target.value)},"V"),e[27]=U):U=e[27];let ae=U,z;e[28]===Symbol.for("react.memo_cache_sentinel")?(z=r(T=>{$(T.target.checked)},"$"),e[28]=z):z=e[28];let ne=z,se;e[29]!==a?(se=r(()=>{ue(a({to:"/migrations"}))},"ne"),e[29]=a,e[30]=se):se=e[30];let f=se,re;e[31]!==l?(re=l("Edit schema"),e[31]=l,e[32]=re):re=e[32];let H;e[33]!==re?(H=(0,t.jsx)(Ge,{children:re}),e[33]=re,e[34]=H):H=e[34];let Ne;e[35]!==l?(Ne=l("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=l,e[36]=Ne):Ne=e[36];let fe;e[37]!==Ne?(fe=(0,t.jsx)(Ke,{children:Ne}),e[37]=Ne,e[38]=fe):fe=e[38];let h;e[39]!==H||e[40]!==fe?(h=(0,t.jsxs)(Pe,{children:[H,fe]}),e[39]=H,e[40]=fe,e[41]=h):h=e[41];let w=n.length>0,N;e[42]!==m||e[43]!==de||e[44]!==w?(N=(0,t.jsx)(gt,{hasTables:w,mode:m,onAddColumn:ve,onAddIndex:Z,onAddTable:W,onDestructive:de}),e[42]=m,e[43]=de,e[44]=w,e[45]=N):N=e[45];let q;e[46]!==d||e[47]!==m||e[48]!==be||e[49]!==l||e[50]!==i?(q=m==="addTable"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-table-name",children:l("Table name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:te,value:i})]}),(0,t.jsx)(me,{"data-testid":"sc-editor-table-apply",disabled:d||i.trim()==="",onClick:be,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[46]=d,e[47]=m,e[48]=be,e[49]=l,e[50]=i,e[51]=q):q=e[51];let A;e[52]!==d||e[53]!==p||e[54]!==m||e[55]!==oe||e[56]!==l||e[57]!==n||e[58]!==y||e[59]!==_?(A=m==="addColumn"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-table",id:"sc-editor-column-table",onChange:X,value:y,children:n.map(Tt)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-name",children:l("Column name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:ye,value:p})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-type",children:l("Column type")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-type",id:"sc-editor-column-type",onChange:pe,value:_,children:yt.map(St)})]}),(0,t.jsx)("span",{className:"text-[11px] text-muted-foreground",children:l("Optional")}),(0,t.jsx)(me,{"data-testid":"sc-editor-column-apply",disabled:d||p.trim()===""||y==="",onClick:oe,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[52]=d,e[53]=p,e[54]=m,e[55]=oe,e[56]=l,e[57]=n,e[58]=y,e[59]=_,e[60]=A):A=e[60];let Te;e[61]!==d||e[62]!==S||e[63]!==E||e[64]!==m||e[65]!==J||e[66]!==l||e[67]!==n||e[68]!==y||e[69]!==F?(Te=m==="addIndex"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-index-table",id:"sc-editor-index-table",onChange:X,value:y,children:n.map(_t)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-name",children:l("Index name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:le,value:E})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-fields",children:l("Index fields (comma-separated)")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:ae,value:S})]}),(0,t.jsxs)(we,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[(0,t.jsx)("input",{checked:F,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:ne,type:"checkbox"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:l("Unique")})]}),(0,t.jsx)(me,{"data-testid":"sc-editor-index-apply",disabled:d||E.trim()===""||S.trim()==="",onClick:J,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[61]=d,e[62]=S,e[63]=E,e[64]=m,e[65]=J,e[66]=l,e[67]=n,e[68]=y,e[69]=F,e[70]=Te):Te=e[70];let Se;e[71]!==f||e[72]!==o?(Se=(0,t.jsx)(xt,{onOpenMigrations:f,result:o}),e[71]=f,e[72]=o,e[73]=Se):Se=e[73];let _e;e[74]!==N||e[75]!==q||e[76]!==A||e[77]!==Te||e[78]!==Se?(_e=(0,t.jsxs)(Le,{children:[N,q,A,Te,Se]}),e[74]=N,e[75]=q,e[76]=A,e[77]=Te,e[78]=Se,e[79]=_e):_e=e[79];let ke;return e[80]!==h||e[81]!==_e?(ke=(0,t.jsxs)(qe,{"data-testid":"sc-editor",size:"sm",children:[h,_e]}),e[80]=h,e[81]=_e,e[82]=ke):ke=e[82],ke},"Nt");function Tt(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(Tt,"Tt");function St(s){return(0,t.jsx)("option",{value:s.validator,children:s.label},s.validator)}r(St,"St");function _t(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(_t,"wt");var Ze=[],kt=r(s=>{let e=(0,Ce.c)(5),{open:u}=s,n=u&&"rotate-90",l;e[0]!==n?(l=De("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",n),e[0]=n,e[1]=l):l=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[2]=a):a=e[2];let m;return e[3]!==l?(m=(0,t.jsx)("svg",{"aria-hidden":"true",className:l,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:a}),e[3]=l,e[4]=m):m=e[4],m},"_t"),et=r(s=>{let e=(0,Ce.c)(20),{children:u,expanded:n,name:l,onToggle:a,rowCount:m,rowTestId:c,toggleTestId:d}=s,g;e[0]!==n?(g=(0,t.jsx)(kt,{open:n}),e[0]=n,e[1]=g):g=e[1];let o;e[2]!==l?(o=(0,t.jsx)("span",{className:"truncate font-mono text-xs text-foreground",title:l,children:l}),e[2]=l,e[3]=o):o=e[3];let b;e[4]!==m?(b=(0,t.jsxs)("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",m,")"]}),e[4]=m,e[5]=b):b=e[5];let i;e[6]!==n||e[7]!==a||e[8]!==g||e[9]!==o||e[10]!==b||e[11]!==d?(i=(0,t.jsxs)("button",{"aria-expanded":n,className:"flex w-full items-center gap-2 px-3 py-2 text-start transition-colors hover:bg-muted/50 aria-expanded:bg-muted/40","data-testid":d,onClick:a,type:"button",children:[g,o," ",b]}),e[6]=n,e[7]=a,e[8]=g,e[9]=o,e[10]=b,e[11]=d,e[12]=i):i=e[12];let v;e[13]!==u||e[14]!==n?(v=n&&(0,t.jsx)("div",{className:"px-3 pb-3 ps-8",children:u}),e[13]=u,e[14]=n,e[15]=v):v=e[15];let p;return e[16]!==c||e[17]!==i||e[18]!==v?(p=(0,t.jsxs)("li",{className:"border-t border-border/60 first:border-t-0","data-testid":c,children:[i,v]}),e[16]=c,e[17]=i,e[18]=v,e[19]=p):p=e[19],p},"Ye"),tt=r(s=>{let e=(0,Ce.c)(5),{columns:u,testId:n}=s,l;e[0]!==u?(l=u.map(At),e[0]=u,e[1]=l):l=e[1];let a;return e[2]!==l||e[3]!==n?(a=(0,t.jsx)("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":n,children:l}),e[2]=l,e[3]=n,e[4]=a):a=e[4],a},"He"),It=r(s=>{let e=(0,Ce.c)(10),{heading:u,indexes:n,testId:l}=s,a;e[0]!==u?(a=(0,t.jsx)("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:u}),e[0]=u,e[1]=a):a=e[1];let m;e[2]!==n?(m=n.map(Ft),e[2]=n,e[3]=m):m=e[3];let c;e[4]!==m||e[5]!==l?(c=(0,t.jsx)("ul",{className:"flex flex-col gap-1","data-testid":l,children:m}),e[4]=m,e[5]=l,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=(0,t.jsxs)("div",{className:"pt-3",children:[a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d},"Et"),lt=r(s=>De("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",s?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"Je"),Xt=r(s=>{let e=(0,Ce.c)(85),{initialShardKey:u,initialTable:n,schemaEditable:l}=s,a=Fe(),m;e[0]!==u||e[1]!==n?(m={initialShardKey:u,initialTable:n},e[0]=u,e[1]=n,e[2]=m):m=e[2];let{columns:c,diagramTables:d,error:g,expanded:o,filteredGlobalTables:b,filteredTables:i,globalColumns:v,globalError:p,globalExpanded:P,globalTables:_,indexes:L,refresh:y,setShardKey:G,setTableFilter:E,setView:M,shardColumnsError:S,shardKey:C,tableFilter:F,tables:$,toggle:he,toggleGlobal:Q,view:I}=mt(m),K;e[3]!==M?(K=r(()=>{M("list")},"q"),e[3]=M,e[4]=K):K=e[4];let k=K,be;e[5]!==M?(be=r(()=>{M("graph")},"ue"),e[5]=M,e[6]=be):be=e[6];let B=be,oe;e[7]!==E?(oe=r(f=>{E(f.target.value)},"ie"),e[7]=E,e[8]=oe):oe=e[8];let Y=oe,J;e[9]!==y||e[10]!==C?(J=r(f=>{ue(y(C))},"Y"),e[9]=y,e[10]=C,e[11]=J):J=e[11];let xe=J,W;e[12]!==$?(W=$??[],e[12]=$,e[13]=W):W=e[13];let ie;e[14]!==W?(ie=W.map(zt),e[14]=W,e[15]=ie):ie=e[15];let ve=ie,O;e[16]!==G||e[17]!==C?(O=(0,t.jsx)(Xe,{onChange:G,testId:"sc-shard-input",value:C}),e[16]=G,e[17]=C,e[18]=O):O=e[18];let Z;e[19]!==a?(Z=a("Schema view"),e[19]=a,e[20]=Z):Z=e[20];let ee=I==="graph",de=I==="graph",D;e[21]!==de?(D=lt(de),e[21]=de,e[22]=D):D=e[22];let te;e[23]!==a?(te=a("Graph"),e[23]=a,e[24]=te):te=e[24];let j;e[25]!==B||e[26]!==ee||e[27]!==D||e[28]!==te?(j=(0,t.jsx)("button",{"aria-selected":ee,className:D,"data-testid":"sc-view-graph",onClick:B,role:"tab",type:"button",children:te}),e[25]=B,e[26]=ee,e[27]=D,e[28]=te,e[29]=j):j=e[29];let ye=I==="list",ce=I==="list",pe;e[30]!==ce?(pe=lt(ce),e[30]=ce,e[31]=pe):pe=e[31];let R;e[32]!==a?(R=a("Table list"),e[32]=a,e[33]=R):R=e[33];let X;e[34]!==k||e[35]!==ye||e[36]!==pe||e[37]!==R?(X=(0,t.jsx)("button",{"aria-selected":ye,className:pe,"data-testid":"sc-view-list",onClick:k,role:"tab",type:"button",children:R}),e[34]=k,e[35]=ye,e[36]=pe,e[37]=R,e[38]=X):X=e[38];let V;e[39]!==j||e[40]!==X||e[41]!==Z?(V=(0,t.jsxs)("div",{"aria-label":Z,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[j,X]}),e[39]=j,e[40]=X,e[41]=Z,e[42]=V):V=e[42];let le;e[43]!==V||e[44]!==O?(le=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[O,V]}),e[43]=V,e[44]=O,e[45]=le):le=e[45];let U;e[46]!==xe||e[47]!==l||e[48]!==ve?(U=l===!0&&(0,t.jsx)(wt,{onApplied:xe,tableNames:ve}),e[46]=xe,e[47]=l,e[48]=ve,e[49]=U):U=e[49];let ae;e[50]!==Y||e[51]!==a||e[52]!==F||e[53]!==I?(ae=I==="list"&&(0,t.jsx)(Ae,{"aria-label":a("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:Y,placeholder:a("Filter tables"),value:F}),e[50]=Y,e[51]=a,e[52]=F,e[53]=I,e[54]=ae):ae=e[54];let z;e[55]!==d||e[56]!==g||e[57]!==p||e[58]!==S||e[59]!==C||e[60]!==I?(z=I==="graph"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),p!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:p}),(0,t.jsx)(Qe,{columnsError:S[C]===!0,tables:d,testIdPrefix:"sc-graph"})]}),e[55]=d,e[56]=g,e[57]=p,e[58]=S,e[59]=C,e[60]=I,e[61]=z):z=e[61];let ne;e[62]!==c||e[63]!==g||e[64]!==o||e[65]!==b||e[66]!==i||e[67]!==v||e[68]!==p||e[69]!==P||e[70]!==_||e[71]!==L||e[72]!==C||e[73]!==a||e[74]!==$||e[75]!==he||e[76]!==Q||e[77]!==I?(ne=I==="list"&&(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)(qe,{"data-testid":"sc-shard-section",size:"sm",children:[(0,t.jsxs)(Pe,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Re,{tier:"shard"}),(0,t.jsx)(Ge,{children:a("Shard tables")}),$!==null&&(0,t.jsx)(ze,{className:"ms-auto tabular-nums",variant:"outline",children:i.length})]}),(0,t.jsx)(Ke,{children:Me.shard.hint})]}),(0,t.jsxs)(Le,{children:[g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),$!==null&&$.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:a("No tables in this shard.")}),$!==null&&$.length>0&&i.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:a("No tables match your filter.")}),i.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:i.map(f=>{let re=`${C}:${f.name}`,H=L[re]??[];return(0,t.jsxs)(et,{expanded:o===f.name,name:f.name,onToggle:r(()=>{ue(he(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-table-${f.name}`,toggleTestId:`sc-toggle-${f.name}`,children:[(0,t.jsx)(tt,{columns:c[re]??Ze,testId:`sc-columns-${f.name}`}),H.length>0&&(0,t.jsx)(It,{heading:a("Indexes"),indexes:H,testId:`sc-indexes-${f.name}`})]},f.name)})})]})]}),(0,t.jsxs)(qe,{"data-testid":"sc-global-section",size:"sm",children:[(0,t.jsxs)(Pe,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Re,{tier:"global"}),(0,t.jsx)(Ge,{children:a("Global tables (D1)")}),_!==null&&(0,t.jsx)(ze,{className:"ms-auto tabular-nums",variant:"outline",children:b.length})]}),(0,t.jsx)(Ke,{children:Me.global.hint})]}),(0,t.jsxs)(Le,{children:[p!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:p}),_!==null&&_.length===0&&(0,t.jsx)(Je,{description:Me.global.hint,testId:"sc-global-empty",title:a("No global tables.")}),_!==null&&_.length>0&&b.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:a("No tables match your filter.")}),b.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:b.map(f=>(0,t.jsx)(et,{expanded:P===f.name,name:f.name,onToggle:r(()=>{ue(Q(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-global-table-${f.name}`,toggleTestId:`sc-global-toggle-${f.name}`,children:(0,t.jsx)(tt,{columns:v[f.name]??Ze,testId:`sc-global-columns-${f.name}`})},f.name))})]})]})]}),e[62]=c,e[63]=g,e[64]=o,e[65]=b,e[66]=i,e[67]=v,e[68]=p,e[69]=P,e[70]=_,e[71]=L,e[72]=C,e[73]=a,e[74]=$,e[75]=he,e[76]=Q,e[77]=I,e[78]=ne):ne=e[78];let se;return e[79]!==le||e[80]!==U||e[81]!==ae||e[82]!==z||e[83]!==ne?(se=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[le,U,ae,z,ne]}),e[79]=le,e[80]=U,e[81]=ae,e[82]=z,e[83]=ne,e[84]=se):se=e[84],se},"Xt");function At(s){return(0,t.jsx)("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:s},s)}r(At,"It");function Ft(s){return(0,t.jsxs)("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[(0,t.jsx)("span",{className:"font-mono",children:s.name}),(0,t.jsx)(ze,{variant:"outline",children:s.type}),s.unique===!0&&(0,t.jsx)(ze,{variant:"secondary",children:"unique"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:s.fields.join(", ")})]},`${s.type}:${s.name}`)}r(Ft,"kt");function zt(s){return s.name}r(zt,"At");export{Xt as SchemaViewer};
1
+ import{a as Qe}from"./chunk-56XCNBO4.js";import{a as Me,b as Re}from"./chunk-CSUROWL2.js";import"./chunk-RFNGDE33.js";import"./chunk-V3CZW3JB.js";import"./chunk-MU3P2FI7.js";import{a as we}from"./chunk-IMOHEGMV.js";import"./chunk-YPRQLCKF.js";import"./chunk-GMS77BZD.js";import"./chunk-3Q2P62UR.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import"./chunk-5JDWLCSH.js";import{a as He}from"./chunk-S3CRZLGS.js";import{a as Xe}from"./chunk-2DX5MROH.js";import{b as We}from"./chunk-OGUKYRFM.js";import{e as Ue}from"./chunk-6D6Z2KXU.js";import"./chunk-OKG3HWSJ.js";import{W as Ae}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as me}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as ze}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as je}from"./chunk-4ZEL6BYL.js";import{f as Ve}from"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import"./chunk-GETL6R4M.js";import{a as Je}from"./chunk-FKVZRPV5.js";import{a as qe,b as Pe,c as Ge,d as Ke,e as Le}from"./chunk-WUWBZPUK.js";import{d as Fe,f as Ee,g as $e,h as Oe,o as ue}from"./chunk-FODLDLE2.js";import{a as r,d as Be,e as at,f as nt,g as st,i as De}from"./chunk-YKXDMIHQ.js";var Ce=Be(nt(),1);var x=Be(at(),1);var t=Be(st(),1);var rt=Ee(je.listTables),ot=Ee(je.listTableIndexes),it=Ee(je.readTablePage),dt=Ee(je.describeTables),ct={},Ye=[],mt=r(s=>{let e=(0,Ce.c)(74),{initialShardKey:u,initialTable:n}=s,l=Ve(),[a,m]=(0,x.useState)("graph"),{queryShardKey:c,setShardKey:d,shardKey:g}=He(u),[o,b]=(0,x.useState)(""),[i,v]=(0,x.useState)(null),[p,P]=(0,x.useState)(null),_;e[0]===Symbol.for("react.memo_cache_sentinel")?(_={},e[0]=_):_=e[0];let[L,y]=(0,x.useState)(_),G;e[1]===Symbol.for("react.memo_cache_sentinel")?(G={},e[1]=G):G=e[1];let[E,M]=(0,x.useState)(G),[S,C]=(0,x.useState)(null),F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F={},e[2]=F):F=e[2];let[$,he]=(0,x.useState)(F),Q;e[3]===Symbol.for("react.memo_cache_sentinel")?(Q={},e[3]=Q):Q=e[3];let[I,K]=(0,x.useState)(Q),[k,be]=(0,x.useState)(null),[B,oe]=(0,x.useState)(null),Y;e[4]===Symbol.for("react.memo_cache_sentinel")?(Y={},e[4]=Y):Y=e[4];let[J,xe]=(0,x.useState)(Y),[W,ie]=(0,x.useState)(null),ve;e[5]!==l?(ve=r(async h=>{P(null);try{let w=await l.query(rt,{},$e(h));We(h),v(w),y({}),M({}),C(null),he(N=>Object.fromEntries(Object.entries(N).filter(q=>{let[A]=q;return A!==h}))),K(N=>Object.fromEntries(Object.entries(N).filter(q=>{let[A]=q;return A!==h})))}catch(w){let N=w;v(null),P(Oe(N))}},"ve"),e[5]=l,e[6]=ve):ve=e[6];let O=ve,Z;e[7]!==l?(Z=r(async()=>{oe(null);try{be(await l.listGlobalTables())}catch(h){let w=h;be(null),oe(Oe(w))}},"Z"),e[7]=l,e[8]=Z):Z=e[8];let ee=Z,de,D;e[9]!==c||e[10]!==O||e[11]!==ee?(de=r(()=>{ue(O(c)),ue(ee())},"de"),D=[O,ee,c],e[9]=c,e[10]=O,e[11]=ee,e[12]=de,e[13]=D):(de=e[12],D=e[13]),(0,x.useEffect)(de,D);let te;e[14]!==l||e[15]!==L||e[16]!==S||e[17]!==c?(te=r(async h=>{if(S===h){C(null);return}C(h);let w=`${c}:${h}`;if(L[w]!==void 0)return;let[N,q]=await Promise.allSettled([l.query(it,{limit:1,offset:0,table:h},$e(c)),l.query(ot,{table:h},$e(c))]);N.status==="fulfilled"?y(A=>({...A,[w]:N.value.columns})):P(Oe(N.reason)),q.status==="fulfilled"&&M(A=>({...A,[w]:q.value.indexes}))},"te"),e[14]=l,e[15]=L,e[16]=S,e[17]=c,e[18]=te):te=e[18];let j=te,ye;e[19]!==l||e[20]!==J||e[21]!==W?(ye=r(async h=>{if(W===h){ie(null);return}if(ie(h),J[h]===void 0)try{let w=await l.readGlobalTablePage({limit:1,offset:0,table:h});xe(N=>({...N,[h]:w.columns}))}catch(w){oe(Oe(w))}},"ye"),e[19]=l,e[20]=J,e[21]=W,e[22]=ye):ye=e[22];let ce=ye,pe=(0,x.useRef)(void 0),R,X;e[23]!==n||e[24]!==i||e[25]!==j?(R=r(()=>{n===void 0||i===null||pe.current===n||i.some(h=>h.name===n)&&(pe.current=n,ue(j(n)))},"K"),X=[n,i,j],e[23]=n,e[24]=i,e[25]=j,e[26]=R,e[27]=X):(R=e[26],X=e[27]),(0,x.useEffect)(R,X);let V;e[28]!==l?(V=r(async(h,w,N)=>{let[q,A]=await Promise.all([Promise.allSettled([l.query(dt,{tables:[...w,...N]},$e(h))]),Promise.all(N.map(async T=>{let ge=await Promise.allSettled([l.readGlobalTablePage({limit:1,offset:0,table:T})]),Ie=ge[0].status==="fulfilled"?ge[0].value:void 0;return{columns:Ie?.columns??[],refs:Ie?.refs??{},table:T}}))]),Te=q[0].status==="fulfilled"?q[0].value?.columnsByTable??{}:{},Se=q[0].status==="rejected",_e=new Map(A.map(ut)),ke=[...w,...N].map(T=>{let ge=Te[T]??[];return[T,ge.length>0?ge:_e.get(T)??[]]});he(T=>({...T,[h]:Object.fromEntries(ke)})),K(T=>({...T,[h]:Se}))},"U"),e[28]=l,e[29]=V):V=e[29];let le=V,U,ae;e[30]!==B||e[31]!==k||e[32]!==le||e[33]!==c||e[34]!==$||e[35]!==i||e[36]!==a?(U=r(()=>{a!=="graph"||i===null||k===null&&B===null||$[c]!==void 0||ue(le(c,i.map(ht),(k??[]).map(bt)))},"V"),ae=[a,i,k,B,c,$,le],e[30]=B,e[31]=k,e[32]=le,e[33]=c,e[34]=$,e[35]=i,e[36]=a,e[37]=U,e[38]=ae):(U=e[37],ae=e[38]),(0,x.useEffect)(U,ae);let z=$[c]??ct,ne;if(e[39]!==z||e[40]!==k||e[41]!==i){let h;e[43]!==z?(h=r(A=>({columns:z[A.name]??Ye,name:A.name,tier:"shard"}),"u"),e[43]=z,e[44]=h):h=e[44];let w=(i??[]).map(h),N;e[45]!==z?(N=r(A=>({columns:z[A.name]??Ye,name:A.name,tier:"global"}),"x"),e[45]=z,e[46]=N):N=e[46];let q=(k??[]).map(N);ne=[...w,...q],e[39]=z,e[40]=k,e[41]=i,e[42]=ne}else ne=e[42];let se=ne,f;if(e[47]!==o||e[48]!==i){let h=o.trim().toLowerCase();f=(i??[]).filter(w=>w.name.toLowerCase().includes(h)),e[47]=o,e[48]=i,e[49]=f}else f=e[49];let re=f,H;if(e[50]!==k||e[51]!==o){let h=o.trim().toLowerCase();H=(k??[]).filter(w=>w.name.toLowerCase().includes(h)),e[50]=k,e[51]=o,e[52]=H}else H=e[52];let Ne=H,fe;return e[53]!==L||e[54]!==se||e[55]!==p||e[56]!==S||e[57]!==Ne||e[58]!==re||e[59]!==J||e[60]!==B||e[61]!==W||e[62]!==k||e[63]!==E||e[64]!==O||e[65]!==d||e[66]!==I||e[67]!==g||e[68]!==o||e[69]!==i||e[70]!==j||e[71]!==ce||e[72]!==a?(fe={columns:L,diagramTables:se,error:p,expanded:S,filteredGlobalTables:Ne,filteredTables:re,globalColumns:J,globalError:B,globalExpanded:W,globalTables:k,indexes:E,refresh:O,setShardKey:d,setTableFilter:b,setView:m,shardColumnsError:I,shardKey:g,tableFilter:o,tables:i,toggle:j,toggleGlobal:ce,view:a},e[53]=L,e[54]=se,e[55]=p,e[56]=S,e[57]=Ne,e[58]=re,e[59]=J,e[60]=B,e[61]=W,e[62]=k,e[63]=E,e[64]=O,e[65]=d,e[66]=I,e[67]=g,e[68]=o,e[69]=i,e[70]=j,e[71]=ce,e[72]=a,e[73]=fe):fe=e[73],fe},"ct");function ut(s){let{columns:e,refs:u,table:n}=s;return[n,e.map(l=>{let a=u[l];return a===void 0?{name:l,optional:!1,type:""}:{name:l,optional:!1,ref:a,type:"id"}})]}r(ut,"mt");function ht(s){return s.name}r(ht,"ut");function bt(s){return s.name}r(bt,"ft");var pt="/__lunora/schema-edit",ft=r(async s=>{let e=await fetch(pt,{body:JSON.stringify(s),headers:{"Content-Type":"application/json"},method:"POST"}),u=await e.json();return u.needsMigration===!0?{kind:"needs-migration",message:u.message??"This edit needs a migration."}:e.ok&&u.tables!==void 0?{diagnostics:u.diagnostics??[],kind:"ok",tables:u.tables}:{kind:"error",message:u.error??`schema edit failed (${String(e.status)})`}},"pt"),gt=r(s=>{let e=(0,Ce.c)(32),{hasTables:u,mode:n,onAddColumn:l,onAddIndex:a,onAddTable:m,onDestructive:c}=s,d=Fe(),g=n==="addTable"?"default":"outline",o;e[0]!==d?(o=d("Add table"),e[0]=d,e[1]=o):o=e[1];let b;e[2]!==m||e[3]!==g||e[4]!==o?(b=(0,t.jsx)(me,{"data-testid":"sc-editor-add-table",onClick:m,size:"xs",type:"button",variant:g,children:o}),e[2]=m,e[3]=g,e[4]=o,e[5]=b):b=e[5];let i=!u,v=n==="addColumn"?"default":"outline",p;e[6]!==d?(p=d("Add column"),e[6]=d,e[7]=p):p=e[7];let P;e[8]!==l||e[9]!==i||e[10]!==v||e[11]!==p?(P=(0,t.jsx)(me,{"data-testid":"sc-editor-add-column",disabled:i,onClick:l,size:"xs",type:"button",variant:v,children:p}),e[8]=l,e[9]=i,e[10]=v,e[11]=p,e[12]=P):P=e[12];let _=!u,L=n==="addIndex"?"default":"outline",y;e[13]!==d?(y=d("Add index"),e[13]=d,e[14]=y):y=e[14];let G;e[15]!==a||e[16]!==y||e[17]!==_||e[18]!==L?(G=(0,t.jsx)(me,{"data-testid":"sc-editor-add-index",disabled:_,onClick:a,size:"xs",type:"button",variant:L,children:y}),e[15]=a,e[16]=y,e[17]=_,e[18]=L,e[19]=G):G=e[19];let E=!u,M=n==="destructive"?"default":"ghost",S;e[20]!==d?(S=d("Rename / drop / change type\u2026"),e[20]=d,e[21]=S):S=e[21];let C;e[22]!==c||e[23]!==E||e[24]!==M||e[25]!==S?(C=(0,t.jsx)(me,{"data-testid":"sc-editor-destructive",disabled:E,onClick:c,size:"xs",type:"button",variant:M,children:S}),e[22]=c,e[23]=E,e[24]=M,e[25]=S,e[26]=C):C=e[26];let F;return e[27]!==G||e[28]!==C||e[29]!==b||e[30]!==P?(F=(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[b,P,G,C]}),e[27]=G,e[28]=C,e[29]=b,e[30]=P,e[31]=F):F=e[31],F},"gt"),xt=r(s=>{let e=(0,Ce.c)(28),{onOpenMigrations:u,result:n}=s,l=Fe();if(n===null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[0]=o):o=e[0],o}if(n.kind==="error"){let o;return e[1]!==n.message?(o=(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:n.message}),e[1]=n.message,e[2]=o):o=e[2],o}if(n.kind==="needs-migration"){let o;e[3]!==n.message||e[4]!==l?(o=n.message===""?l("This edit changes stored data and must go through a migration. Review the migration before applying."):n.message,e[3]=n.message,e[4]=l,e[5]=o):o=e[5];let b;e[6]!==o?(b=(0,t.jsx)("p",{className:"text-sm text-warning",role:"alert",children:o}),e[6]=o,e[7]=b):b=e[7];let i;e[8]!==l?(i=l("Open Migrations"),e[8]=l,e[9]=i):i=e[9];let v;e[10]!==u||e[11]!==i?(v=(0,t.jsx)(me,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:u,size:"xs",type:"button",variant:"outline",children:i}),e[10]=u,e[11]=i,e[12]=v):v=e[12];let p;return e[13]!==b||e[14]!==v?(p=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[b,v]}),e[13]=b,e[14]=v,e[15]=p):p=e[15],p}if(n.diagnostics.length===0){let o;return e[16]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[16]=o):o=e[16],o}let a;e[17]!==l?(a=l("Codegen reported diagnostics:"),e[17]=l,e[18]=a):a=e[18];let m;e[19]!==a?(m=(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:a}),e[19]=a,e[20]=m):m=e[20];let c;e[21]!==n.diagnostics?(c=n.diagnostics.map(vt),e[21]=n.diagnostics,e[22]=c):c=e[22];let d;e[23]!==c?(d=(0,t.jsx)("ul",{className:"flex flex-col gap-0.5",children:c}),e[23]=c,e[24]=d):d=e[24];let g;return e[25]!==m||e[26]!==d?(g=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[m,d]}),e[25]=m,e[26]=d,e[27]=g):g=e[27],g},"bt");function vt(s){return(0,t.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:s},s)}r(vt,"xt");var yt=[{label:"string",validator:"v.string()"},{label:"number",validator:"v.number()"},{label:"boolean",validator:"v.boolean()"},{label:"bigint",validator:"v.bigint()"},{label:"bytes",validator:"v.bytes()"},{label:"any",validator:"v.any()"}],Nt="v.string()",Ct=r(s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),"Ct"),wt=r(s=>{let e=(0,Ce.c)(83),{onApplied:u,tableNames:n}=s,l=Fe(),a=Ue(),[m,c]=(0,x.useState)(null),[d,g]=(0,x.useState)(!1),[o,b]=(0,x.useState)(null),[i,v]=(0,x.useState)(""),[p,P]=(0,x.useState)(""),[_,L]=(0,x.useState)(Nt),[y,G]=(0,x.useState)(n[0]??""),[E,M]=(0,x.useState)(""),[S,C]=(0,x.useState)(""),[F,$]=(0,x.useState)(!1),he;e[0]===Symbol.for("react.memo_cache_sentinel")?(he=r(()=>{c(null),v(""),P(""),M(""),C(""),$(!1)},"me"),e[0]=he):he=e[0];let Q=he,I;e[1]!==u?(I=r(async T=>{g(!0),b(null);try{let ge=await ft(T);b(ge),ge.kind==="ok"&&(u(ge.tables),Q())}catch(ge){let Ie=ge;b({kind:"error",message:Ie instanceof Error?Ie.message:String(Ie)})}g(!1)},"I"),e[1]=u,e[2]=I):I=e[2];let K=I,k;e[3]!==K||e[4]!==i?(k=r(()=>{ue(K({kind:"addTable",table:i.trim()}))},"_"),e[3]=K,e[4]=i,e[5]=k):k=e[5];let be=k,B;e[6]!==p||e[7]!==K||e[8]!==y||e[9]!==_?(B=r(()=>{ue(K({column:p.trim(),kind:"addOptionalColumn",table:y,validator:_}))},"j"),e[6]=p,e[7]=K,e[8]=y,e[9]=_,e[10]=B):B=e[10];let oe=B,Y;e[11]!==S||e[12]!==E||e[13]!==K||e[14]!==y||e[15]!==F?(Y=r(()=>{ue(K({fields:Ct(S),kind:"addIndex",name:E.trim(),table:y,unique:F}))},"Q"),e[11]=S,e[12]=E,e[13]=K,e[14]=y,e[15]=F,e[16]=Y):Y=e[16];let J=Y,xe;e[17]===Symbol.for("react.memo_cache_sentinel")?(xe=r(()=>{b(null),c("addTable")},"xe"),e[17]=xe):xe=e[17];let W=xe,ie;e[18]===Symbol.for("react.memo_cache_sentinel")?(ie=r(()=>{b(null),c("addColumn")},"re"),e[18]=ie):ie=e[18];let ve=ie,O;e[19]===Symbol.for("react.memo_cache_sentinel")?(O=r(()=>{b(null),c("addIndex")},"O"),e[19]=O):O=e[19];let Z=O,ee;e[20]!==l?(ee=r(()=>{c("destructive"),b({kind:"needs-migration",message:l("This edit changes stored data and must go through a migration. Review the migration before applying.")})},"ee"),e[20]=l,e[21]=ee):ee=e[21];let de=ee,D;e[22]===Symbol.for("react.memo_cache_sentinel")?(D=r(T=>{v(T.target.value)},"R"),e[22]=D):D=e[22];let te=D,j;e[23]===Symbol.for("react.memo_cache_sentinel")?(j=r(T=>{P(T.target.value)},"M"),e[23]=j):j=e[23];let ye=j,ce;e[24]===Symbol.for("react.memo_cache_sentinel")?(ce=r(T=>{L(T.target.value)},"ce"),e[24]=ce):ce=e[24];let pe=ce,R;e[25]===Symbol.for("react.memo_cache_sentinel")?(R=r(T=>{G(T.target.value)},"K"),e[25]=R):R=e[25];let X=R,V;e[26]===Symbol.for("react.memo_cache_sentinel")?(V=r(T=>{M(T.target.value)},"U"),e[26]=V):V=e[26];let le=V,U;e[27]===Symbol.for("react.memo_cache_sentinel")?(U=r(T=>{C(T.target.value)},"V"),e[27]=U):U=e[27];let ae=U,z;e[28]===Symbol.for("react.memo_cache_sentinel")?(z=r(T=>{$(T.target.checked)},"$"),e[28]=z):z=e[28];let ne=z,se;e[29]!==a?(se=r(()=>{ue(a({to:"/migrations"}))},"ne"),e[29]=a,e[30]=se):se=e[30];let f=se,re;e[31]!==l?(re=l("Edit schema"),e[31]=l,e[32]=re):re=e[32];let H;e[33]!==re?(H=(0,t.jsx)(Ge,{children:re}),e[33]=re,e[34]=H):H=e[34];let Ne;e[35]!==l?(Ne=l("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=l,e[36]=Ne):Ne=e[36];let fe;e[37]!==Ne?(fe=(0,t.jsx)(Ke,{children:Ne}),e[37]=Ne,e[38]=fe):fe=e[38];let h;e[39]!==H||e[40]!==fe?(h=(0,t.jsxs)(Pe,{children:[H,fe]}),e[39]=H,e[40]=fe,e[41]=h):h=e[41];let w=n.length>0,N;e[42]!==m||e[43]!==de||e[44]!==w?(N=(0,t.jsx)(gt,{hasTables:w,mode:m,onAddColumn:ve,onAddIndex:Z,onAddTable:W,onDestructive:de}),e[42]=m,e[43]=de,e[44]=w,e[45]=N):N=e[45];let q;e[46]!==d||e[47]!==m||e[48]!==be||e[49]!==l||e[50]!==i?(q=m==="addTable"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-table-name",children:l("Table name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:te,value:i})]}),(0,t.jsx)(me,{"data-testid":"sc-editor-table-apply",disabled:d||i.trim()==="",onClick:be,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[46]=d,e[47]=m,e[48]=be,e[49]=l,e[50]=i,e[51]=q):q=e[51];let A;e[52]!==d||e[53]!==p||e[54]!==m||e[55]!==oe||e[56]!==l||e[57]!==n||e[58]!==y||e[59]!==_?(A=m==="addColumn"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-table",id:"sc-editor-column-table",onChange:X,value:y,children:n.map(Tt)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-name",children:l("Column name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:ye,value:p})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-type",children:l("Column type")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-type",id:"sc-editor-column-type",onChange:pe,value:_,children:yt.map(St)})]}),(0,t.jsx)("span",{className:"text-[11px] text-muted-foreground",children:l("Optional")}),(0,t.jsx)(me,{"data-testid":"sc-editor-column-apply",disabled:d||p.trim()===""||y==="",onClick:oe,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[52]=d,e[53]=p,e[54]=m,e[55]=oe,e[56]=l,e[57]=n,e[58]=y,e[59]=_,e[60]=A):A=e[60];let Te;e[61]!==d||e[62]!==S||e[63]!==E||e[64]!==m||e[65]!==J||e[66]!==l||e[67]!==n||e[68]!==y||e[69]!==F?(Te=m==="addIndex"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-index-table",id:"sc-editor-index-table",onChange:X,value:y,children:n.map(_t)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-name",children:l("Index name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:le,value:E})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-fields",children:l("Index fields (comma-separated)")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:ae,value:S})]}),(0,t.jsxs)(we,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[(0,t.jsx)("input",{checked:F,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:ne,type:"checkbox"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:l("Unique")})]}),(0,t.jsx)(me,{"data-testid":"sc-editor-index-apply",disabled:d||E.trim()===""||S.trim()==="",onClick:J,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[61]=d,e[62]=S,e[63]=E,e[64]=m,e[65]=J,e[66]=l,e[67]=n,e[68]=y,e[69]=F,e[70]=Te):Te=e[70];let Se;e[71]!==f||e[72]!==o?(Se=(0,t.jsx)(xt,{onOpenMigrations:f,result:o}),e[71]=f,e[72]=o,e[73]=Se):Se=e[73];let _e;e[74]!==N||e[75]!==q||e[76]!==A||e[77]!==Te||e[78]!==Se?(_e=(0,t.jsxs)(Le,{children:[N,q,A,Te,Se]}),e[74]=N,e[75]=q,e[76]=A,e[77]=Te,e[78]=Se,e[79]=_e):_e=e[79];let ke;return e[80]!==h||e[81]!==_e?(ke=(0,t.jsxs)(qe,{"data-testid":"sc-editor",size:"sm",children:[h,_e]}),e[80]=h,e[81]=_e,e[82]=ke):ke=e[82],ke},"Nt");function Tt(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(Tt,"Tt");function St(s){return(0,t.jsx)("option",{value:s.validator,children:s.label},s.validator)}r(St,"St");function _t(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(_t,"wt");var Ze=[],kt=r(s=>{let e=(0,Ce.c)(5),{open:u}=s,n=u&&"rotate-90",l;e[0]!==n?(l=De("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",n),e[0]=n,e[1]=l):l=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[2]=a):a=e[2];let m;return e[3]!==l?(m=(0,t.jsx)("svg",{"aria-hidden":"true",className:l,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:a}),e[3]=l,e[4]=m):m=e[4],m},"_t"),et=r(s=>{let e=(0,Ce.c)(20),{children:u,expanded:n,name:l,onToggle:a,rowCount:m,rowTestId:c,toggleTestId:d}=s,g;e[0]!==n?(g=(0,t.jsx)(kt,{open:n}),e[0]=n,e[1]=g):g=e[1];let o;e[2]!==l?(o=(0,t.jsx)("span",{className:"truncate font-mono text-xs text-foreground",title:l,children:l}),e[2]=l,e[3]=o):o=e[3];let b;e[4]!==m?(b=(0,t.jsxs)("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",m,")"]}),e[4]=m,e[5]=b):b=e[5];let i;e[6]!==n||e[7]!==a||e[8]!==g||e[9]!==o||e[10]!==b||e[11]!==d?(i=(0,t.jsxs)("button",{"aria-expanded":n,className:"flex w-full items-center gap-2 px-3 py-2 text-start transition-colors hover:bg-muted/50 aria-expanded:bg-muted/40","data-testid":d,onClick:a,type:"button",children:[g,o," ",b]}),e[6]=n,e[7]=a,e[8]=g,e[9]=o,e[10]=b,e[11]=d,e[12]=i):i=e[12];let v;e[13]!==u||e[14]!==n?(v=n&&(0,t.jsx)("div",{className:"px-3 pb-3 ps-8",children:u}),e[13]=u,e[14]=n,e[15]=v):v=e[15];let p;return e[16]!==c||e[17]!==i||e[18]!==v?(p=(0,t.jsxs)("li",{className:"border-t border-border/60 first:border-t-0","data-testid":c,children:[i,v]}),e[16]=c,e[17]=i,e[18]=v,e[19]=p):p=e[19],p},"Ye"),tt=r(s=>{let e=(0,Ce.c)(5),{columns:u,testId:n}=s,l;e[0]!==u?(l=u.map(At),e[0]=u,e[1]=l):l=e[1];let a;return e[2]!==l||e[3]!==n?(a=(0,t.jsx)("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":n,children:l}),e[2]=l,e[3]=n,e[4]=a):a=e[4],a},"He"),It=r(s=>{let e=(0,Ce.c)(10),{heading:u,indexes:n,testId:l}=s,a;e[0]!==u?(a=(0,t.jsx)("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:u}),e[0]=u,e[1]=a):a=e[1];let m;e[2]!==n?(m=n.map(Ft),e[2]=n,e[3]=m):m=e[3];let c;e[4]!==m||e[5]!==l?(c=(0,t.jsx)("ul",{className:"flex flex-col gap-1","data-testid":l,children:m}),e[4]=m,e[5]=l,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=(0,t.jsxs)("div",{className:"pt-3",children:[a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d},"Et"),lt=r(s=>De("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",s?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"Je"),Xt=r(s=>{let e=(0,Ce.c)(85),{initialShardKey:u,initialTable:n,schemaEditable:l}=s,a=Fe(),m;e[0]!==u||e[1]!==n?(m={initialShardKey:u,initialTable:n},e[0]=u,e[1]=n,e[2]=m):m=e[2];let{columns:c,diagramTables:d,error:g,expanded:o,filteredGlobalTables:b,filteredTables:i,globalColumns:v,globalError:p,globalExpanded:P,globalTables:_,indexes:L,refresh:y,setShardKey:G,setTableFilter:E,setView:M,shardColumnsError:S,shardKey:C,tableFilter:F,tables:$,toggle:he,toggleGlobal:Q,view:I}=mt(m),K;e[3]!==M?(K=r(()=>{M("list")},"q"),e[3]=M,e[4]=K):K=e[4];let k=K,be;e[5]!==M?(be=r(()=>{M("graph")},"ue"),e[5]=M,e[6]=be):be=e[6];let B=be,oe;e[7]!==E?(oe=r(f=>{E(f.target.value)},"ie"),e[7]=E,e[8]=oe):oe=e[8];let Y=oe,J;e[9]!==y||e[10]!==C?(J=r(f=>{ue(y(C))},"Y"),e[9]=y,e[10]=C,e[11]=J):J=e[11];let xe=J,W;e[12]!==$?(W=$??[],e[12]=$,e[13]=W):W=e[13];let ie;e[14]!==W?(ie=W.map(zt),e[14]=W,e[15]=ie):ie=e[15];let ve=ie,O;e[16]!==G||e[17]!==C?(O=(0,t.jsx)(Xe,{onChange:G,testId:"sc-shard-input",value:C}),e[16]=G,e[17]=C,e[18]=O):O=e[18];let Z;e[19]!==a?(Z=a("Schema view"),e[19]=a,e[20]=Z):Z=e[20];let ee=I==="graph",de=I==="graph",D;e[21]!==de?(D=lt(de),e[21]=de,e[22]=D):D=e[22];let te;e[23]!==a?(te=a("Graph"),e[23]=a,e[24]=te):te=e[24];let j;e[25]!==B||e[26]!==ee||e[27]!==D||e[28]!==te?(j=(0,t.jsx)("button",{"aria-selected":ee,className:D,"data-testid":"sc-view-graph",onClick:B,role:"tab",type:"button",children:te}),e[25]=B,e[26]=ee,e[27]=D,e[28]=te,e[29]=j):j=e[29];let ye=I==="list",ce=I==="list",pe;e[30]!==ce?(pe=lt(ce),e[30]=ce,e[31]=pe):pe=e[31];let R;e[32]!==a?(R=a("Table list"),e[32]=a,e[33]=R):R=e[33];let X;e[34]!==k||e[35]!==ye||e[36]!==pe||e[37]!==R?(X=(0,t.jsx)("button",{"aria-selected":ye,className:pe,"data-testid":"sc-view-list",onClick:k,role:"tab",type:"button",children:R}),e[34]=k,e[35]=ye,e[36]=pe,e[37]=R,e[38]=X):X=e[38];let V;e[39]!==j||e[40]!==X||e[41]!==Z?(V=(0,t.jsxs)("div",{"aria-label":Z,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[j,X]}),e[39]=j,e[40]=X,e[41]=Z,e[42]=V):V=e[42];let le;e[43]!==V||e[44]!==O?(le=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[O,V]}),e[43]=V,e[44]=O,e[45]=le):le=e[45];let U;e[46]!==xe||e[47]!==l||e[48]!==ve?(U=l===!0&&(0,t.jsx)(wt,{onApplied:xe,tableNames:ve}),e[46]=xe,e[47]=l,e[48]=ve,e[49]=U):U=e[49];let ae;e[50]!==Y||e[51]!==a||e[52]!==F||e[53]!==I?(ae=I==="list"&&(0,t.jsx)(Ae,{"aria-label":a("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:Y,placeholder:a("Filter tables"),value:F}),e[50]=Y,e[51]=a,e[52]=F,e[53]=I,e[54]=ae):ae=e[54];let z;e[55]!==d||e[56]!==g||e[57]!==p||e[58]!==S||e[59]!==C||e[60]!==I?(z=I==="graph"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),p!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:p}),(0,t.jsx)(Qe,{columnsError:S[C]===!0,tables:d,testIdPrefix:"sc-graph"})]}),e[55]=d,e[56]=g,e[57]=p,e[58]=S,e[59]=C,e[60]=I,e[61]=z):z=e[61];let ne;e[62]!==c||e[63]!==g||e[64]!==o||e[65]!==b||e[66]!==i||e[67]!==v||e[68]!==p||e[69]!==P||e[70]!==_||e[71]!==L||e[72]!==C||e[73]!==a||e[74]!==$||e[75]!==he||e[76]!==Q||e[77]!==I?(ne=I==="list"&&(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)(qe,{"data-testid":"sc-shard-section",size:"sm",children:[(0,t.jsxs)(Pe,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Re,{tier:"shard"}),(0,t.jsx)(Ge,{children:a("Shard tables")}),$!==null&&(0,t.jsx)(ze,{className:"ms-auto tabular-nums",variant:"outline",children:i.length})]}),(0,t.jsx)(Ke,{children:Me.shard.hint})]}),(0,t.jsxs)(Le,{children:[g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),$!==null&&$.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:a("No tables in this shard.")}),$!==null&&$.length>0&&i.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:a("No tables match your filter.")}),i.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:i.map(f=>{let re=`${C}:${f.name}`,H=L[re]??[];return(0,t.jsxs)(et,{expanded:o===f.name,name:f.name,onToggle:r(()=>{ue(he(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-table-${f.name}`,toggleTestId:`sc-toggle-${f.name}`,children:[(0,t.jsx)(tt,{columns:c[re]??Ze,testId:`sc-columns-${f.name}`}),H.length>0&&(0,t.jsx)(It,{heading:a("Indexes"),indexes:H,testId:`sc-indexes-${f.name}`})]},f.name)})})]})]}),(0,t.jsxs)(qe,{"data-testid":"sc-global-section",size:"sm",children:[(0,t.jsxs)(Pe,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Re,{tier:"global"}),(0,t.jsx)(Ge,{children:a("Global tables (D1)")}),_!==null&&(0,t.jsx)(ze,{className:"ms-auto tabular-nums",variant:"outline",children:b.length})]}),(0,t.jsx)(Ke,{children:Me.global.hint})]}),(0,t.jsxs)(Le,{children:[p!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:p}),_!==null&&_.length===0&&(0,t.jsx)(Je,{description:Me.global.hint,testId:"sc-global-empty",title:a("No global tables.")}),_!==null&&_.length>0&&b.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:a("No tables match your filter.")}),b.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:b.map(f=>(0,t.jsx)(et,{expanded:P===f.name,name:f.name,onToggle:r(()=>{ue(Q(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-global-table-${f.name}`,toggleTestId:`sc-global-toggle-${f.name}`,children:(0,t.jsx)(tt,{columns:v[f.name]??Ze,testId:`sc-global-columns-${f.name}`})},f.name))})]})]})]}),e[62]=c,e[63]=g,e[64]=o,e[65]=b,e[66]=i,e[67]=v,e[68]=p,e[69]=P,e[70]=_,e[71]=L,e[72]=C,e[73]=a,e[74]=$,e[75]=he,e[76]=Q,e[77]=I,e[78]=ne):ne=e[78];let se;return e[79]!==le||e[80]!==U||e[81]!==ae||e[82]!==z||e[83]!==ne?(se=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[le,U,ae,z,ne]}),e[79]=le,e[80]=U,e[81]=ae,e[82]=z,e[83]=ne,e[84]=se):se=e[84],se},"Xt");function At(s){return(0,t.jsx)("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:s},s)}r(At,"It");function Ft(s){return(0,t.jsxs)("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[(0,t.jsx)("span",{className:"font-mono",children:s.name}),(0,t.jsx)(ze,{variant:"outline",children:s.type}),s.unique===!0&&(0,t.jsx)(ze,{variant:"secondary",children:"unique"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:s.fields.join(", ")})]},`${s.type}:${s.name}`)}r(Ft,"kt");function zt(s){return s.name}r(zt,"At");export{Xt as SchemaViewer};