@lunora/studio 1.0.0-alpha.49 → 1.0.0-alpha.50

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 (85) hide show
  1. package/dist/index.d.ts +10 -5
  2. package/dist/index.js +6 -6
  3. package/dist/mount.d.ts +1 -1
  4. package/dist/mount.js +1 -1
  5. package/dist/packem_chunks/ApiTab.js +1 -1
  6. package/dist/packem_chunks/AuditPanel.js +1 -1
  7. package/dist/packem_chunks/ExportImportPanel.js +1 -1
  8. package/dist/packem_chunks/FileBrowser.js +1 -1
  9. package/dist/packem_chunks/FunctionRunner.js +1 -1
  10. package/dist/packem_chunks/FunctionStatsPanel.js +1 -1
  11. package/dist/packem_chunks/HealthPanel.js +1 -1
  12. package/dist/packem_chunks/InsightsPanel.js +1 -1
  13. package/dist/packem_chunks/LogsPanel.js +1 -1
  14. package/dist/packem_chunks/MailPanel.js +1 -1
  15. package/dist/packem_chunks/MetricsPanel.js +1 -1
  16. package/dist/packem_chunks/MigrationsPanel.js +1 -1
  17. package/dist/packem_chunks/PitrPanel.js +1 -1
  18. package/dist/packem_chunks/SchemaViewer.js +1 -1
  19. package/dist/packem_chunks/SecurityAdvisorPanel.js +1 -1
  20. package/dist/packem_chunks/SettingsPanel.js +1 -1
  21. package/dist/packem_chunks/SqlEditorPanel.js +1 -1
  22. package/dist/packem_chunks/TableEditor.js +1 -1
  23. package/dist/packem_chunks/agents-panel.js +1 -1
  24. package/dist/packem_chunks/containers-panel.js +21 -7
  25. package/dist/packem_chunks/dashboards-panel.js +1 -1
  26. package/dist/packem_chunks/fanout-panel.js +1 -1
  27. package/dist/packem_chunks/flags-panel.js +1 -1
  28. package/dist/packem_chunks/issues-panel.js +188 -0
  29. package/dist/packem_chunks/kv-browser.js +1 -1
  30. package/dist/packem_chunks/payments-panel.js +1 -1
  31. package/dist/packem_chunks/permissions-panel.js +1 -1
  32. package/dist/packem_chunks/queues-panel.js +1 -1
  33. package/dist/packem_chunks/rls-panel.js +1 -1
  34. package/dist/packem_chunks/storage-rules-panel.js +1 -1
  35. package/dist/packem_chunks/subscriptions-panel.js +1 -1
  36. package/dist/packem_chunks/workflows-panel.js +1 -1
  37. package/dist/packem_shared/{ADMIN_FUNCTIONS-BHHJi3Gb.js → ADMIN_FUNCTIONS-DNeyYtUN.js} +1 -0
  38. package/dist/packem_shared/{ApiDocsPanel-B2Rc7nOF.js → ApiDocsPanel-_aEZxAMX.js} +1 -1
  39. package/dist/packem_shared/{DataBrowser-Cc197zke.js → DataBrowser-C8hejnub.js} +1 -1
  40. package/dist/packem_shared/{HomePanel-CjDlJzzs.js → HomePanel-Ye8PaqQL.js} +2 -2
  41. package/dist/packem_shared/{Studio-MB2VTLwI.js → Studio-xJLTlLpf.js} +2 -2
  42. package/dist/packem_shared/{StudioApp-Ds6u0iY5.js → StudioApp-oCQholCL.js} +1 -1
  43. package/dist/packem_shared/{app.d-Bly6zmWK.d.ts → app.d-CGdOmLTm.d.ts} +1 -1
  44. package/dist/packem_shared/{home-panel-BohxdqDb.js → home-panel-D62G8108.js} +1 -1
  45. package/dist/packem_shared/{studio-Bv27fj7n.js → studio-WZUOecDv.js} +578 -551
  46. package/dist/standalone/{chunk-2JUOJEKE.js → chunk-2JTPX3CV.js} +1 -1
  47. package/dist/standalone/{chunk-2O4BHAHA.js → chunk-3CPQ5IQU.js} +1 -1
  48. package/dist/standalone/{chunk-BTODL6SI.js → chunk-4AXW2ECS.js} +1 -1
  49. package/dist/standalone/chunk-4BVRLBEW.js +1 -0
  50. package/dist/standalone/{chunk-QCW4BAH5.js → chunk-6RREMPQX.js} +1 -1
  51. package/dist/standalone/{chunk-AHDVD4KF.js → chunk-6ZBU3JWR.js} +1 -1
  52. package/dist/standalone/chunk-A2DBMISD.js +1 -0
  53. package/dist/standalone/{chunk-Q7HPS6TW.js → chunk-A66LI6OV.js} +1 -1
  54. package/dist/standalone/{chunk-CDHEMVIY.js → chunk-CJXJIRSN.js} +1 -1
  55. package/dist/standalone/{chunk-R6H6DUPU.js → chunk-DR6LGPXE.js} +1 -1
  56. package/dist/standalone/{chunk-CTOOUWO4.js → chunk-FAUN4Z72.js} +1 -1
  57. package/dist/standalone/chunk-G7ZBM54M.js +1 -0
  58. package/dist/standalone/{chunk-5YPIP3G7.js → chunk-HAJSYWFT.js} +1 -1
  59. package/dist/standalone/{chunk-6U45TJXA.js → chunk-HQM6MBPS.js} +1 -1
  60. package/dist/standalone/{chunk-ECJPFPHR.js → chunk-HTQNZXDT.js} +1 -1
  61. package/dist/standalone/{chunk-W5BAQMIE.js → chunk-IO2XEI6T.js} +1 -1
  62. package/dist/standalone/{chunk-WK7VHQTQ.js → chunk-K4S652EQ.js} +1 -1
  63. package/dist/standalone/{chunk-L4UCG6XZ.js → chunk-KJFFID72.js} +1 -1
  64. package/dist/standalone/{chunk-R2HA2NVX.js → chunk-LJAAZNQ6.js} +1 -1
  65. package/dist/standalone/{chunk-UWSLX56Q.js → chunk-LX7KONE3.js} +1 -1
  66. package/dist/standalone/{chunk-XGPFWZPJ.js → chunk-NW6SZZ5O.js} +1 -1
  67. package/dist/standalone/{chunk-NH4FSHFO.js → chunk-P2ERTKMB.js} +1 -1
  68. package/dist/standalone/{chunk-N4TGVH2R.js → chunk-PS3XCCZD.js} +1 -1
  69. package/dist/standalone/{chunk-ALTQC4S5.js → chunk-RS7S7XVP.js} +1 -1
  70. package/dist/standalone/{chunk-GA6K5WS5.js → chunk-S7AB7Y75.js} +1 -1
  71. package/dist/standalone/{chunk-FFCUV3TZ.js → chunk-SHJUAHC6.js} +1 -1
  72. package/dist/standalone/{chunk-RE4LLVPN.js → chunk-TYN6SQ73.js} +1 -1
  73. package/dist/standalone/{chunk-XPLUSBKA.js → chunk-U26QNHMO.js} +1 -1
  74. package/dist/standalone/{chunk-Q6356GAQ.js → chunk-VL6HOZHF.js} +1 -1
  75. package/dist/standalone/{chunk-RYF5EUQA.js → chunk-X2TQRMQV.js} +1 -1
  76. package/dist/standalone/{chunk-ZANX3V5B.js → chunk-X4676IX6.js} +1 -1
  77. package/dist/standalone/{chunk-3JXKA6BH.js → chunk-XJU5SRNL.js} +1 -1
  78. package/dist/standalone/chunk-XWPZBZSZ.js +3 -0
  79. package/dist/standalone/{chunk-CCRVGYTN.js → chunk-YLHDKM2P.js} +1 -1
  80. package/dist/standalone/studio.js +1 -1
  81. package/dist/styles.css +1 -1
  82. package/package.json +1 -1
  83. package/dist/standalone/chunk-4TV6S6AO.js +0 -3
  84. package/dist/standalone/chunk-BOXSWNXZ.js +0 -1
  85. package/dist/standalone/chunk-ZVLQVBTM.js +0 -1
@@ -1 +1 @@
1
- import{a as ft,b as mt,c as vt,d as ht,e as gt}from"./chunk-JPILGFXT.js";import{a as dt,b as nt,c as ct,d as ut,e as Me}from"./chunk-S5NTGHCG.js";import"./chunk-DWDILV2E.js";import"./chunk-APSSZB6Z.js";import{e as ot}from"./chunk-TQ36RWOP.js";import"./chunk-QAFAJBAW.js";import{a as it}from"./chunk-AITOCPML.js";import"./chunk-SHERR7ZP.js";import"./chunk-5OIBXYZM.js";import"./chunk-L7SK4ZZD.js";import"./chunk-X4QFAAZ5.js";import"./chunk-BJGBHGK3.js";import"./chunk-ZIGWVHCS.js";import{a as rt}from"./chunk-2K47A3P6.js";import"./chunk-KEGAWN6Y.js";import{b as Ye}from"./chunk-W666BB6V.js";import{a as st,b as lt,c as at,d as je,e as $e,f as Te}from"./chunk-GTM65MVX.js";import{a as B,b as Re,c as _e,d as Ve,e as P}from"./chunk-SEU5V7I6.js";import"./chunk-4QHKBC77.js";import{a as tt}from"./chunk-LUP4YTBS.js";import{a as Ze,b as et}from"./chunk-4PC7IXNY.js";import"./chunk-2MLA6WFH.js";import"./chunk-VL23Y44O.js";import"./chunk-HV7G6DFP.js";import{c as Oe}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{b as Ke}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as Pe}from"./chunk-BOXSWNXZ.js";import{f as Ue}from"./chunk-SDMZKBTD.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as Qe,f as Ge,g as Je,h as We,l as Xe,o as Ae}from"./chunk-ITQKVEP7.js";import"./chunk-22C6COGE.js";import{a as n,e as Be,f as pt,g as xt,h as bt}from"./chunk-RRCPZMC2.js";var Le=Be(xt(),1);var v=Be(pt(),1);var t=Be(bt(),1);var ze=n(l=>l>=100?"critical":l>=50?"warning":"good","performanceLevel"),He=n(l=>l<1?`${(l*1e3).toFixed(0)}\u03BCs`:l<1e3?`${l.toFixed(1)}ms`:`${(l/1e3).toFixed(2)}s`,"formatLatency"),Ee=n(l=>l>=1e9?`${(l/1e9).toFixed(1)}B`:l>=1e6?`${(l/1e6).toFixed(1)}M`:l>=1e3?`${(l/1e3).toFixed(1)}K`:l.toLocaleString(),"formatCount"),Nt=n(l=>{let e=(0,Le.c)(3),{level:s}=l;if(s==="critical"){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsxDEV)(Ke,{variant:"destructive",children:"Slow"},void 0,!1),e[0]=i):i=e[0],i}if(s==="warning"){let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsxDEV)("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning",children:"Moderate"},void 0,!1),e[1]=i):i=e[1],i}let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsxDEV)("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-success/10 px-2 py-0.5 text-xs font-medium text-success",children:"Fast"},void 0,!1),e[2]=r):r=e[2],r},"PerformanceBadge"),yt=n(l=>{let e=(0,Le.c)(152),{queryStats:s}=l,r=Qe(),[i,Q]=(0,v.useState)("totalTime"),C;e[0]===Symbol.for("react.memo_cache_sentinel")?(C=new Set,e[0]=C):C=e[0];let[h,T]=(0,v.useState)(C),p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=n(o=>{o!==null&&Q(o)},"t2"),e[1]=p):p=e[1];let S=p,u;if(e[2]!==s||e[3]!==i){u=[...s];let o;e[5]!==i?(o=n((m,c)=>{switch(i){case"avgTime":return c.avgDurationMs-m.avgDurationMs;case"execCount":return c.execCount-m.execCount;case"rowsRead":return c.rowsRead-m.rowsRead;default:return c.totalDurationMs-m.totalDurationMs}},"t310"),e[5]=i,e[6]=o):o=e[6],u.sort(o),e[2]=s,e[3]=i,e[4]=u}else u=e[4];let g=u,$;e[7]!==s?($=s.filter(St),e[7]=s,e[8]=$):$=e[8];let j=$.length,H;e[9]!==s?(H=s.filter(wt),e[9]=s,e[10]=H):H=e[10];let d=H.length,_;e[11]!==s?(_=s.filter(qt),e[11]=s,e[12]=_):_=e[12];let U=_.length,O;e[13]===Symbol.for("react.memo_cache_sentinel")?(O=n(o=>{T(m=>{let c=new Set(m);return c.has(o)?c.delete(o):c.add(o),c})},"t6"),e[13]=O):O=e[13];let Fe=O;if(s.length===0){let o;e[14]!==r?(o=r("No query insights yet"),e[14]=r,e[15]=o):o=e[15];let m;e[16]!==o?(m=(0,t.jsxDEV)("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:o},void 0,!1),e[16]=o,e[17]=m):m=e[17];let c;e[18]!==r?(c=r("Query insights appear once statements are executed against this shard."),e[18]=r,e[19]=c):c=e[19];let z;e[20]!==c?(z=(0,t.jsxDEV)("p",{className:"mt-1 text-sm",children:c},void 0,!1),e[20]=c,e[21]=z):z=e[21];let ke;return e[22]!==z||e[23]!==m?(ke=(0,t.jsxDEV)(B,{children:(0,t.jsxDEV)(P,{className:"py-12",children:(0,t.jsxDEV)("div",{className:"text-center text-muted-foreground",children:[m,z]},void 0,!0)},void 0,!1)},void 0,!1),e[22]=z,e[23]=m,e[24]=ke):ke=e[24],ke}let I;e[25]!==r?(I=r("Critical queries"),e[25]=r,e[26]=I):I=e[26];let f;e[27]!==I?(f=(0,t.jsxDEV)(Re,{className:"pb-2",children:(0,t.jsxDEV)(_e,{className:"text-sm font-medium",children:I},void 0,!1)},void 0,!1),e[27]=I,e[28]=f):f=e[28];let M;e[29]!==j?(M=(0,t.jsxDEV)("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:j},void 0,!1),e[29]=j,e[30]=M):M=e[30];let D;e[31]!==r?(D=r(">100ms avg execution"),e[31]=r,e[32]=D):D=e[32];let R;e[33]!==D?(R=(0,t.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:D},void 0,!1),e[33]=D,e[34]=R):R=e[34];let F;e[35]!==R||e[36]!==M?(F=(0,t.jsxDEV)(P,{children:[M,R]},void 0,!0),e[35]=R,e[36]=M,e[37]=F):F=e[37];let b;e[38]!==F||e[39]!==f?(b=(0,t.jsxDEV)(B,{children:[f,F]},void 0,!0),e[38]=F,e[39]=f,e[40]=b):b=e[40];let N;e[41]!==r?(N=r("Moderate queries"),e[41]=r,e[42]=N):N=e[42];let k;e[43]!==N?(k=(0,t.jsxDEV)(Re,{className:"pb-2",children:(0,t.jsxDEV)(_e,{className:"text-sm font-medium",children:N},void 0,!1)},void 0,!1),e[43]=N,e[44]=k):k=e[44];let A;e[45]!==d?(A=(0,t.jsxDEV)("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:d},void 0,!1),e[45]=d,e[46]=A):A=e[46];let E;e[47]!==r?(E=r("50\u2013100ms avg execution"),e[47]=r,e[48]=E):E=e[48];let L;e[49]!==E?(L=(0,t.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:E},void 0,!1),e[49]=E,e[50]=L):L=e[50];let a;e[51]!==A||e[52]!==L?(a=(0,t.jsxDEV)(P,{children:[A,L]},void 0,!0),e[51]=A,e[52]=L,e[53]=a):a=e[53];let w;e[54]!==k||e[55]!==a?(w=(0,t.jsxDEV)(B,{children:[k,a]},void 0,!0),e[54]=k,e[55]=a,e[56]=w):w=e[56];let x;e[57]!==r?(x=r("Fast queries"),e[57]=r,e[58]=x):x=e[58];let y;e[59]!==x?(y=(0,t.jsxDEV)(Re,{className:"pb-2",children:(0,t.jsxDEV)(_e,{className:"text-sm font-medium",children:x},void 0,!1)},void 0,!1),e[59]=x,e[60]=y):y=e[60];let K;e[61]!==U?(K=(0,t.jsxDEV)("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:U},void 0,!1),e[61]=U,e[62]=K):K=e[62];let V;e[63]!==r?(V=r("<50ms avg execution"),e[63]=r,e[64]=V):V=e[64];let G;e[65]!==V?(G=(0,t.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:V},void 0,!1),e[65]=V,e[66]=G):G=e[66];let J;e[67]!==K||e[68]!==G?(J=(0,t.jsxDEV)(P,{children:[K,G]},void 0,!0),e[67]=K,e[68]=G,e[69]=J):J=e[69];let W;e[70]!==y||e[71]!==J?(W=(0,t.jsxDEV)(B,{children:[y,J]},void 0,!0),e[70]=y,e[71]=J,e[72]=W):W=e[72];let X;e[73]!==b||e[74]!==w||e[75]!==W?(X=(0,t.jsxDEV)("div",{className:"grid gap-4 md:grid-cols-3",children:[b,w,W]},void 0,!0),e[73]=b,e[74]=w,e[75]=W,e[76]=X):X=e[76];let Y;e[77]!==r?(Y=r("Query leaderboard"),e[77]=r,e[78]=Y):Y=e[78];let Z;e[79]!==Y?(Z=(0,t.jsxDEV)("h3",{className:"text-lg font-semibold",children:Y},void 0,!1),e[79]=Y,e[80]=Z):Z=e[80];let ee;e[81]!==i||e[82]!==r?(ee=r("Slow queries sorted by {sortField}",{sortField:r(i)}),e[81]=i,e[82]=r,e[83]=ee):ee=e[83];let te;e[84]!==ee?(te=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:ee},void 0,!1),e[84]=ee,e[85]=te):te=e[85];let re;e[86]!==Z||e[87]!==te?(re=(0,t.jsxDEV)("div",{children:[Z,te]},void 0,!0),e[86]=Z,e[87]=te,e[88]=re):re=e[88];let se;e[89]!==r?(se=r("Sort by"),e[89]=r,e[90]=se):se=e[90];let le;e[91]!==se?(le=(0,t.jsxDEV)("span",{className:"text-sm text-muted-foreground",children:se},void 0,!1),e[91]=se,e[92]=le):le=e[92];let ae;e[93]!==r?(ae=r("Sort queries by"),e[93]=r,e[94]=ae):ae=e[94];let Ie;e[95]===Symbol.for("react.memo_cache_sentinel")?(Ie=(0,t.jsxDEV)(nt,{},void 0,!1),e[95]=Ie):Ie=e[95];let ie;e[96]!==ae?(ie=(0,t.jsxDEV)(ct,{"aria-label":ae,className:"w-[140px]","data-testid":"qi-sort",children:Ie},void 0,!1),e[96]=ae,e[97]=ie):ie=e[97];let oe;e[98]!==r?(oe=r("Total time"),e[98]=r,e[99]=oe):oe=e[99];let de;e[100]!==oe?(de=(0,t.jsxDEV)(Me,{value:"totalTime",children:oe},void 0,!1),e[100]=oe,e[101]=de):de=e[101];let ne;e[102]!==r?(ne=r("Avg time"),e[102]=r,e[103]=ne):ne=e[103];let ce;e[104]!==ne?(ce=(0,t.jsxDEV)(Me,{value:"avgTime",children:ne},void 0,!1),e[104]=ne,e[105]=ce):ce=e[105];let ue;e[106]!==r?(ue=r("Execution count"),e[106]=r,e[107]=ue):ue=e[107];let fe;e[108]!==ue?(fe=(0,t.jsxDEV)(Me,{value:"execCount",children:ue},void 0,!1),e[108]=ue,e[109]=fe):fe=e[109];let me;e[110]!==r?(me=r("Rows read"),e[110]=r,e[111]=me):me=e[111];let ve;e[112]!==me?(ve=(0,t.jsxDEV)(Me,{value:"rowsRead",children:me},void 0,!1),e[112]=me,e[113]=ve):ve=e[113];let he;e[114]!==de||e[115]!==ce||e[116]!==fe||e[117]!==ve?(he=(0,t.jsxDEV)(ut,{children:[de,ce,fe,ve]},void 0,!0),e[114]=de,e[115]=ce,e[116]=fe,e[117]=ve,e[118]=he):he=e[118];let ge;e[119]!==i||e[120]!==ie||e[121]!==he?(ge=(0,t.jsxDEV)(dt,{onValueChange:S,value:i,children:[ie,he]},void 0,!0),e[119]=i,e[120]=ie,e[121]=he,e[122]=ge):ge=e[122];let pe;e[123]!==le||e[124]!==ge?(pe=(0,t.jsxDEV)("div",{className:"flex items-center gap-2",children:[le,ge]},void 0,!0),e[123]=le,e[124]=ge,e[125]=pe):pe=e[125];let xe;e[126]!==re||e[127]!==pe?(xe=(0,t.jsxDEV)("div",{className:"flex items-center justify-between",children:[re,pe]},void 0,!0),e[126]=re,e[127]=pe,e[128]=xe):xe=e[128];let be;e[129]!==r?(be=r("Statements"),e[129]=r,e[130]=be):be=e[130];let Ne;e[131]!==be?(Ne=(0,t.jsxDEV)(_e,{children:be},void 0,!1),e[131]=be,e[132]=Ne):Ne=e[132];let ye;e[133]!==g.length||e[134]!==r?(ye=r("{count} tracked statements",{count:g.length}),e[133]=g.length,e[134]=r,e[135]=ye):ye=e[135];let Se;e[136]!==ye?(Se=(0,t.jsxDEV)(Ve,{children:ye},void 0,!1),e[136]=ye,e[137]=Se):Se=e[137];let we;e[138]!==Ne||e[139]!==Se?(we=(0,t.jsxDEV)(Re,{children:[Ne,Se]},void 0,!0),e[138]=Ne,e[139]=Se,e[140]=we):we=e[140];let qe;e[141]!==h||e[142]!==g||e[143]!==r?(qe=(0,t.jsxDEV)(P,{children:(0,t.jsxDEV)("div",{className:"space-y-2",children:g.map(o=>{let m=o.normalizedSql,c=h.has(m),z=ze(o.avgDurationMs);return(0,t.jsxDEV)("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[(0,t.jsxDEV)("button",{"aria-expanded":c,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:n(()=>{Fe(m)},"onClick"),type:"button",children:[(0,t.jsxDEV)("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[(0,t.jsxDEV)(Nt,{level:z},void 0,!1),(0,t.jsxDEV)("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:o.normalizedSql},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex shrink-0 items-center gap-4",children:[(0,t.jsxDEV)("div",{className:"text-right",children:[(0,t.jsxDEV)("div",{className:"text-sm font-medium",children:He(o.totalDurationMs)},void 0,!1),(0,t.jsxDEV)("div",{className:"text-xs text-muted-foreground",children:r("total")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"text-right",children:[(0,t.jsxDEV)("div",{className:"text-sm font-medium",children:He(o.avgDurationMs)},void 0,!1),(0,t.jsxDEV)("div",{className:"text-xs text-muted-foreground",children:r("avg")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"text-right",children:[(0,t.jsxDEV)("div",{className:"text-sm font-medium",children:Ee(o.execCount)},void 0,!1),(0,t.jsxDEV)("div",{className:"text-xs text-muted-foreground",children:r("calls")},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0),c&&(0,t.jsxDEV)("div",{className:"space-y-3 border-t bg-muted/30 p-4",children:[(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("p",{className:"mb-2 text-sm font-medium",children:r("Full statement")},void 0,!1),(0,t.jsxDEV)("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:o.normalizedSql},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:r("Exec count")},void 0,!1),(0,t.jsxDEV)("span",{className:"block font-medium tabular-nums",children:Ee(o.execCount)},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:r("Total time")},void 0,!1),(0,t.jsxDEV)("span",{className:"block font-medium tabular-nums",children:He(o.totalDurationMs)},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:r("Rows read")},void 0,!1),(0,t.jsxDEV)("span",{className:"block font-medium tabular-nums",children:Ee(o.rowsRead)},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:r("Rows written")},void 0,!1),(0,t.jsxDEV)("span",{className:"block font-medium tabular-nums",children:Ee(o.rowsWritten)},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0)]},m,!0)})},void 0,!1)},void 0,!1),e[141]=h,e[142]=g,e[143]=r,e[144]=qe):qe=e[144];let Ce;e[145]!==we||e[146]!==qe?(Ce=(0,t.jsxDEV)(B,{children:[we,qe]},void 0,!0),e[145]=we,e[146]=qe,e[147]=Ce):Ce=e[147];let De;return e[148]!==X||e[149]!==xe||e[150]!==Ce?(De=(0,t.jsxDEV)("div",{className:"space-y-4","data-testid":"qi-root",children:[X,xe,Ce]},void 0,!0),e[148]=X,e[149]=xe,e[150]=Ce,e[151]=De):De=e[151],De},"QueryInsights");function St(l){return ze(l.avgDurationMs)==="critical"}n(St,"_temp");function wt(l){return ze(l.avgDurationMs)==="warning"}n(wt,"_temp2");function qt(l){return ze(l.avgDurationMs)==="good"}n(qt,"_temp3");var Ct=Ge(Pe.getMetrics),Tt=n(l=>{let e=Math.floor(l/1e3),s=Math.floor(e/3600),r=Math.floor(e%3600/60),i=e%60;return s>0?`${s.toString()}h ${r.toString()}m`:r>0?`${r.toString()}m ${i.toString()}s`:`${i.toString()}s`},"formatDuration"),Rt=n((l,e)=>l?e:"overview","resolveTab"),_t=n((l,e)=>{let s=l+e;return s===0?"\u2014":`${(l/s*100).toFixed(1)}%`},"hitRate"),q=n(l=>{let e=(0,Le.c)(16),{chart:s,footer:r,label:i,testId:Q,value:C}=l,h;e[0]!==i?(h=(0,t.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i},void 0,!1),e[0]=i,e[1]=h):h=e[1];let T;e[2]!==Q||e[3]!==C?(T=(0,t.jsxDEV)("span",{className:"truncate text-2xl font-semibold tabular-nums text-foreground","data-testid":Q,children:C},void 0,!1),e[2]=Q,e[3]=C,e[4]=T):T=e[4];let p;e[5]!==s||e[6]!==T?(p=(0,t.jsxDEV)("div",{className:"flex items-center justify-between gap-3",children:[T,s]},void 0,!0),e[5]=s,e[6]=T,e[7]=p):p=e[7];let S;e[8]!==h||e[9]!==p?(S=(0,t.jsxDEV)("div",{className:"flex flex-col gap-2.5 p-4",children:[h,p]},void 0,!0),e[8]=h,e[9]=p,e[10]=S):S=e[10];let u;e[11]!==r?(u=r!=null&&(0,t.jsxDEV)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:r},void 0,!1),e[11]=r,e[12]=u):u=e[12];let g;return e[13]!==S||e[14]!==u?(g=(0,t.jsxDEV)(B,{className:"justify-between gap-0 py-0",children:[S,u]},void 0,!0),e[13]=S,e[14]=u,e[15]=g):g=e[15],g},"StatCard"),Kt=n(({initialShardKey:l})=>{let e=Ue(),s=Qe(),[r,i]=(0,v.useState)(l??""),[Q,C]=(0,v.useState)("overview"),[h,T]=(0,v.useState)([]),p=(0,v.useRef)(null),S=(0,v.useRef)(null),u=(0,v.useRef)(!0);(0,v.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]);let g=rt(r.trim(),400),{data:$,error:j,liveError:H}=Ye(Pe.getMetrics,{},{live:!0,shardKey:g}),d=$??null;(0,v.useEffect)(()=>{if($===void 0)return;et(g);let a=$,w=p.current,x=S.current!==null&&S.current!==a.shard;if(S.current=a.shard,p.current=a.requests,x){T([]);return}w!==null&&a.requests>=w&&T(y=>[...y,a.requests-w].slice(-30))},[$,g]);let[_,U]=(0,v.useState)(null),[O,Fe]=(0,v.useState)(!1),I=n(async()=>{Fe(!0);let a=mt(r,Ze());try{let w=await Promise.all(a.map(async x=>{try{let y=await e.query(Ct,{},Je(x));return{error:null,metrics:y,shard:x===""?y.shard:x}}catch(y){return{error:We(y),metrics:null,shard:x===""?"__root__":x}}}));u.current&&U(w)}finally{u.current&&Fe(!1)}},"aggregateAll"),f=_===null?null:ft(_),M=d===null||d.requests===0?"\u2014":`${(d.errors/d.requests*100).toFixed(1)}%`,D=h.length>0?h.at(-1):0,R=d?vt(d):{p90:0,p95:0},F=n(a=>a<=0?"\u2014":a<1?`${(a*1e3).toFixed(0)}\u03BCs`:a<1e3?`${a.toFixed(1)}ms`:`${(a/1e3).toFixed(2)}s`,"formatMs"),b=(0,v.useMemo)(()=>{if(!d||!("queryStats"in d))return;let a=d.queryStats;if(!(!a||!Array.isArray(a)))return ht(a)},[d]),N=Rt(b!==void 0,Q),k=n(()=>{Xe(I())},"runAggregate"),A=n(()=>{U(null)},"clearAggregate"),E=n(()=>{C("overview")},"switchToOverview"),L=n(()=>{C("query-insights")},"switchToQueryInsights");return(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxDEV)(tt,{onChange:i,testId:"mt-shard-input",value:r},void 0,!1),(0,t.jsxDEV)(it,{message:H,prefix:"mt"},void 0,!1),(0,t.jsxDEV)(Oe,{"data-testid":"mt-aggregate",disabled:O,onClick:k,size:"sm",type:"button",variant:"secondary",children:s(O?"Aggregating\u2026":"All shards")},void 0,!1),_!==null&&(0,t.jsxDEV)(Oe,{"data-testid":"mt-aggregate-clear",onClick:A,size:"sm",type:"button",variant:"ghost",children:s("Hide")},void 0,!1),(0,t.jsxDEV)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:ot,rel:"noreferrer",target:"_blank",children:s("Open in Cloudflare")},void 0,!1)]},void 0,!0),j!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:j},void 0,!1),b!==void 0&&(0,t.jsxDEV)("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[(0,t.jsxDEV)("button",{className:`pb-2 text-sm font-medium transition-colors ${N==="overview"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-overview",onClick:E,type:"button",children:s("Overview")},void 0,!1),(0,t.jsxDEV)("button",{className:`pb-2 text-sm font-medium transition-colors ${N==="query-insights"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-query-insights",onClick:L,type:"button",children:[s("Query insights"),b.length>0&&(0,t.jsxDEV)("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:b.length},void 0,!1)]},void 0,!0)]},void 0,!0),N==="query-insights"&&b!==void 0&&(0,t.jsxDEV)(yt,{queryStats:b},void 0,!1),N==="overview"&&d!==null&&(0,t.jsxDEV)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[(0,t.jsxDEV)(q,{chart:h.length>=2?(0,t.jsxDEV)(gt,{ariaLabel:s("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:h,testId:"mt-sparkline"},void 0,!1):void 0,footer:h.length>=2?(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)("span",{className:"font-semibold text-foreground",children:`+${D.toLocaleString()}`},void 0,!1)," ",s("last interval")]},void 0,!0):(0,t.jsxDEV)("span",{"data-testid":"mt-sparkline-empty",children:s("collecting samples\u2026")},void 0,!1),label:s("Requests"),testId:"mt-requests",value:d.requests},void 0,!1),(0,t.jsxDEV)(q,{footer:s("{rate} error rate",{rate:M}),label:s("Errors"),testId:"mt-errors",value:(0,t.jsxDEV)(t.Fragment,{children:[d.errors," (",M,")"]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(q,{footer:R.p90>0?`P90 ${F(R.p90)}`:void 0,label:s("P95 latency"),testId:"mt-p95",value:R.p95>0?F(R.p95):"\u2014"},void 0,!1),(0,t.jsxDEV)(q,{footer:d.cache===null?void 0:`${d.cache.entries.toLocaleString()} ${s("cache entries")}`,label:s("Database size"),testId:"mt-db-size",value:Ae(d.databaseSize)},void 0,!1),(0,t.jsxDEV)(q,{label:s("Shard"),testId:"mt-shard",value:d.shard},void 0,!1),(0,t.jsxDEV)(q,{label:s("Uptime"),testId:"mt-uptime",value:Tt(d.uptimeMs)},void 0,!1),(0,t.jsxDEV)(q,{label:s("Cache hit rate"),testId:"mt-cache",value:d.cache===null?s("no cache configured"):s("{rate} ({count} entries)",{count:d.cache.entries,rate:_t(d.cache.hits,d.cache.misses)})},void 0,!1)]},void 0,!0),N==="overview"&&d===null&&null,N==="overview"&&f!==null&&_!==null&&(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[(0,t.jsxDEV)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[(0,t.jsxDEV)(q,{label:s("Shards"),testId:"mt-agg-shards",value:f.failed>0?s("{reachable} reachable, {failed} unreachable",{failed:f.failed,reachable:f.reachable}):s("{reachable} reachable",{reachable:f.reachable})},void 0,!1),(0,t.jsxDEV)(q,{label:s("Total requests"),testId:"mt-agg-requests",value:f.totalRequests},void 0,!1),(0,t.jsxDEV)(q,{label:s("Total errors"),testId:"mt-agg-errors",value:f.totalErrors},void 0,!1),(0,t.jsxDEV)(q,{label:s("Total database size"),testId:"mt-agg-db-size",value:Ae(f.totalDatabaseSize)},void 0,!1),(0,t.jsxDEV)(q,{label:s("Combined cache hit rate"),testId:"mt-agg-cache",value:f.hitRate===null?s("no cache configured"):`${(f.hitRate*100).toFixed(1)}%`},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(B,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(P,{className:"px-0",children:(0,t.jsxDEV)(st,{"data-testid":"mt-agg-table",children:[(0,t.jsxDEV)(lt,{children:(0,t.jsxDEV)(je,{children:[(0,t.jsxDEV)($e,{children:s("shard")},void 0,!1),(0,t.jsxDEV)($e,{children:s("requests")},void 0,!1),(0,t.jsxDEV)($e,{children:s("errors")},void 0,!1),(0,t.jsxDEV)($e,{children:s("db size")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(at,{children:_.map(a=>(0,t.jsxDEV)(je,{"data-testid":`mt-agg-row-${a.shard}`,children:[(0,t.jsxDEV)(Te,{children:a.shard},void 0,!1),a.metrics===null?(0,t.jsxDEV)(Te,{className:"text-destructive",colSpan:3,children:a.error??s("unreachable")},void 0,!1):(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)(Te,{className:"tabular-nums",children:a.metrics.requests},void 0,!1),(0,t.jsxDEV)(Te,{className:"tabular-nums",children:a.metrics.errors},void 0,!1),(0,t.jsxDEV)(Te,{className:"tabular-nums",children:Ae(a.metrics.databaseSize)},void 0,!1)]},void 0,!0)]},a.shard,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0)]},void 0,!0)},"MetricsPanel");export{Kt as MetricsPanel};
1
+ import{a as ft,b as mt,c as vt,d as ht,e as gt}from"./chunk-JPILGFXT.js";import{a as dt,b as nt,c as ct,d as ut,e as Me}from"./chunk-S5NTGHCG.js";import"./chunk-DWDILV2E.js";import"./chunk-APSSZB6Z.js";import"./chunk-QAFAJBAW.js";import{e as ot}from"./chunk-TQ36RWOP.js";import{a as it}from"./chunk-AITOCPML.js";import"./chunk-SHERR7ZP.js";import"./chunk-5OIBXYZM.js";import"./chunk-L7SK4ZZD.js";import"./chunk-X4QFAAZ5.js";import"./chunk-BJGBHGK3.js";import"./chunk-ZIGWVHCS.js";import{a as rt}from"./chunk-2K47A3P6.js";import"./chunk-KEGAWN6Y.js";import{b as Ye}from"./chunk-W666BB6V.js";import{a as st,b as lt,c as at,d as je,e as $e,f as Te}from"./chunk-GTM65MVX.js";import{a as B,b as Re,c as _e,d as Ve,e as P}from"./chunk-SEU5V7I6.js";import"./chunk-4QHKBC77.js";import{a as tt}from"./chunk-LUP4YTBS.js";import{a as Ze,b as et}from"./chunk-4PC7IXNY.js";import"./chunk-2MLA6WFH.js";import"./chunk-VL23Y44O.js";import"./chunk-HV7G6DFP.js";import{c as Oe}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{b as Ke}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as Pe}from"./chunk-G7ZBM54M.js";import{f as Ue}from"./chunk-SDMZKBTD.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as Qe,f as Ge,g as Je,h as We,l as Xe,o as Ae}from"./chunk-ITQKVEP7.js";import"./chunk-22C6COGE.js";import{a as n,e as Be,f as pt,g as xt,h as bt}from"./chunk-RRCPZMC2.js";var Le=Be(xt(),1);var v=Be(pt(),1);var t=Be(bt(),1);var ze=n(l=>l>=100?"critical":l>=50?"warning":"good","performanceLevel"),He=n(l=>l<1?`${(l*1e3).toFixed(0)}\u03BCs`:l<1e3?`${l.toFixed(1)}ms`:`${(l/1e3).toFixed(2)}s`,"formatLatency"),Ee=n(l=>l>=1e9?`${(l/1e9).toFixed(1)}B`:l>=1e6?`${(l/1e6).toFixed(1)}M`:l>=1e3?`${(l/1e3).toFixed(1)}K`:l.toLocaleString(),"formatCount"),Nt=n(l=>{let e=(0,Le.c)(3),{level:s}=l;if(s==="critical"){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsxDEV)(Ke,{variant:"destructive",children:"Slow"},void 0,!1),e[0]=i):i=e[0],i}if(s==="warning"){let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsxDEV)("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning",children:"Moderate"},void 0,!1),e[1]=i):i=e[1],i}let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsxDEV)("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-success/10 px-2 py-0.5 text-xs font-medium text-success",children:"Fast"},void 0,!1),e[2]=r):r=e[2],r},"PerformanceBadge"),yt=n(l=>{let e=(0,Le.c)(152),{queryStats:s}=l,r=Qe(),[i,Q]=(0,v.useState)("totalTime"),C;e[0]===Symbol.for("react.memo_cache_sentinel")?(C=new Set,e[0]=C):C=e[0];let[h,T]=(0,v.useState)(C),p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=n(o=>{o!==null&&Q(o)},"t2"),e[1]=p):p=e[1];let S=p,u;if(e[2]!==s||e[3]!==i){u=[...s];let o;e[5]!==i?(o=n((m,c)=>{switch(i){case"avgTime":return c.avgDurationMs-m.avgDurationMs;case"execCount":return c.execCount-m.execCount;case"rowsRead":return c.rowsRead-m.rowsRead;default:return c.totalDurationMs-m.totalDurationMs}},"t310"),e[5]=i,e[6]=o):o=e[6],u.sort(o),e[2]=s,e[3]=i,e[4]=u}else u=e[4];let g=u,$;e[7]!==s?($=s.filter(St),e[7]=s,e[8]=$):$=e[8];let j=$.length,H;e[9]!==s?(H=s.filter(wt),e[9]=s,e[10]=H):H=e[10];let d=H.length,_;e[11]!==s?(_=s.filter(qt),e[11]=s,e[12]=_):_=e[12];let U=_.length,O;e[13]===Symbol.for("react.memo_cache_sentinel")?(O=n(o=>{T(m=>{let c=new Set(m);return c.has(o)?c.delete(o):c.add(o),c})},"t6"),e[13]=O):O=e[13];let Fe=O;if(s.length===0){let o;e[14]!==r?(o=r("No query insights yet"),e[14]=r,e[15]=o):o=e[15];let m;e[16]!==o?(m=(0,t.jsxDEV)("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:o},void 0,!1),e[16]=o,e[17]=m):m=e[17];let c;e[18]!==r?(c=r("Query insights appear once statements are executed against this shard."),e[18]=r,e[19]=c):c=e[19];let z;e[20]!==c?(z=(0,t.jsxDEV)("p",{className:"mt-1 text-sm",children:c},void 0,!1),e[20]=c,e[21]=z):z=e[21];let ke;return e[22]!==z||e[23]!==m?(ke=(0,t.jsxDEV)(B,{children:(0,t.jsxDEV)(P,{className:"py-12",children:(0,t.jsxDEV)("div",{className:"text-center text-muted-foreground",children:[m,z]},void 0,!0)},void 0,!1)},void 0,!1),e[22]=z,e[23]=m,e[24]=ke):ke=e[24],ke}let I;e[25]!==r?(I=r("Critical queries"),e[25]=r,e[26]=I):I=e[26];let f;e[27]!==I?(f=(0,t.jsxDEV)(Re,{className:"pb-2",children:(0,t.jsxDEV)(_e,{className:"text-sm font-medium",children:I},void 0,!1)},void 0,!1),e[27]=I,e[28]=f):f=e[28];let M;e[29]!==j?(M=(0,t.jsxDEV)("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:j},void 0,!1),e[29]=j,e[30]=M):M=e[30];let D;e[31]!==r?(D=r(">100ms avg execution"),e[31]=r,e[32]=D):D=e[32];let R;e[33]!==D?(R=(0,t.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:D},void 0,!1),e[33]=D,e[34]=R):R=e[34];let F;e[35]!==R||e[36]!==M?(F=(0,t.jsxDEV)(P,{children:[M,R]},void 0,!0),e[35]=R,e[36]=M,e[37]=F):F=e[37];let b;e[38]!==F||e[39]!==f?(b=(0,t.jsxDEV)(B,{children:[f,F]},void 0,!0),e[38]=F,e[39]=f,e[40]=b):b=e[40];let N;e[41]!==r?(N=r("Moderate queries"),e[41]=r,e[42]=N):N=e[42];let k;e[43]!==N?(k=(0,t.jsxDEV)(Re,{className:"pb-2",children:(0,t.jsxDEV)(_e,{className:"text-sm font-medium",children:N},void 0,!1)},void 0,!1),e[43]=N,e[44]=k):k=e[44];let A;e[45]!==d?(A=(0,t.jsxDEV)("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:d},void 0,!1),e[45]=d,e[46]=A):A=e[46];let E;e[47]!==r?(E=r("50\u2013100ms avg execution"),e[47]=r,e[48]=E):E=e[48];let L;e[49]!==E?(L=(0,t.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:E},void 0,!1),e[49]=E,e[50]=L):L=e[50];let a;e[51]!==A||e[52]!==L?(a=(0,t.jsxDEV)(P,{children:[A,L]},void 0,!0),e[51]=A,e[52]=L,e[53]=a):a=e[53];let w;e[54]!==k||e[55]!==a?(w=(0,t.jsxDEV)(B,{children:[k,a]},void 0,!0),e[54]=k,e[55]=a,e[56]=w):w=e[56];let x;e[57]!==r?(x=r("Fast queries"),e[57]=r,e[58]=x):x=e[58];let y;e[59]!==x?(y=(0,t.jsxDEV)(Re,{className:"pb-2",children:(0,t.jsxDEV)(_e,{className:"text-sm font-medium",children:x},void 0,!1)},void 0,!1),e[59]=x,e[60]=y):y=e[60];let K;e[61]!==U?(K=(0,t.jsxDEV)("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:U},void 0,!1),e[61]=U,e[62]=K):K=e[62];let V;e[63]!==r?(V=r("<50ms avg execution"),e[63]=r,e[64]=V):V=e[64];let G;e[65]!==V?(G=(0,t.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:V},void 0,!1),e[65]=V,e[66]=G):G=e[66];let J;e[67]!==K||e[68]!==G?(J=(0,t.jsxDEV)(P,{children:[K,G]},void 0,!0),e[67]=K,e[68]=G,e[69]=J):J=e[69];let W;e[70]!==y||e[71]!==J?(W=(0,t.jsxDEV)(B,{children:[y,J]},void 0,!0),e[70]=y,e[71]=J,e[72]=W):W=e[72];let X;e[73]!==b||e[74]!==w||e[75]!==W?(X=(0,t.jsxDEV)("div",{className:"grid gap-4 md:grid-cols-3",children:[b,w,W]},void 0,!0),e[73]=b,e[74]=w,e[75]=W,e[76]=X):X=e[76];let Y;e[77]!==r?(Y=r("Query leaderboard"),e[77]=r,e[78]=Y):Y=e[78];let Z;e[79]!==Y?(Z=(0,t.jsxDEV)("h3",{className:"text-lg font-semibold",children:Y},void 0,!1),e[79]=Y,e[80]=Z):Z=e[80];let ee;e[81]!==i||e[82]!==r?(ee=r("Slow queries sorted by {sortField}",{sortField:r(i)}),e[81]=i,e[82]=r,e[83]=ee):ee=e[83];let te;e[84]!==ee?(te=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:ee},void 0,!1),e[84]=ee,e[85]=te):te=e[85];let re;e[86]!==Z||e[87]!==te?(re=(0,t.jsxDEV)("div",{children:[Z,te]},void 0,!0),e[86]=Z,e[87]=te,e[88]=re):re=e[88];let se;e[89]!==r?(se=r("Sort by"),e[89]=r,e[90]=se):se=e[90];let le;e[91]!==se?(le=(0,t.jsxDEV)("span",{className:"text-sm text-muted-foreground",children:se},void 0,!1),e[91]=se,e[92]=le):le=e[92];let ae;e[93]!==r?(ae=r("Sort queries by"),e[93]=r,e[94]=ae):ae=e[94];let Ie;e[95]===Symbol.for("react.memo_cache_sentinel")?(Ie=(0,t.jsxDEV)(nt,{},void 0,!1),e[95]=Ie):Ie=e[95];let ie;e[96]!==ae?(ie=(0,t.jsxDEV)(ct,{"aria-label":ae,className:"w-[140px]","data-testid":"qi-sort",children:Ie},void 0,!1),e[96]=ae,e[97]=ie):ie=e[97];let oe;e[98]!==r?(oe=r("Total time"),e[98]=r,e[99]=oe):oe=e[99];let de;e[100]!==oe?(de=(0,t.jsxDEV)(Me,{value:"totalTime",children:oe},void 0,!1),e[100]=oe,e[101]=de):de=e[101];let ne;e[102]!==r?(ne=r("Avg time"),e[102]=r,e[103]=ne):ne=e[103];let ce;e[104]!==ne?(ce=(0,t.jsxDEV)(Me,{value:"avgTime",children:ne},void 0,!1),e[104]=ne,e[105]=ce):ce=e[105];let ue;e[106]!==r?(ue=r("Execution count"),e[106]=r,e[107]=ue):ue=e[107];let fe;e[108]!==ue?(fe=(0,t.jsxDEV)(Me,{value:"execCount",children:ue},void 0,!1),e[108]=ue,e[109]=fe):fe=e[109];let me;e[110]!==r?(me=r("Rows read"),e[110]=r,e[111]=me):me=e[111];let ve;e[112]!==me?(ve=(0,t.jsxDEV)(Me,{value:"rowsRead",children:me},void 0,!1),e[112]=me,e[113]=ve):ve=e[113];let he;e[114]!==de||e[115]!==ce||e[116]!==fe||e[117]!==ve?(he=(0,t.jsxDEV)(ut,{children:[de,ce,fe,ve]},void 0,!0),e[114]=de,e[115]=ce,e[116]=fe,e[117]=ve,e[118]=he):he=e[118];let ge;e[119]!==i||e[120]!==ie||e[121]!==he?(ge=(0,t.jsxDEV)(dt,{onValueChange:S,value:i,children:[ie,he]},void 0,!0),e[119]=i,e[120]=ie,e[121]=he,e[122]=ge):ge=e[122];let pe;e[123]!==le||e[124]!==ge?(pe=(0,t.jsxDEV)("div",{className:"flex items-center gap-2",children:[le,ge]},void 0,!0),e[123]=le,e[124]=ge,e[125]=pe):pe=e[125];let xe;e[126]!==re||e[127]!==pe?(xe=(0,t.jsxDEV)("div",{className:"flex items-center justify-between",children:[re,pe]},void 0,!0),e[126]=re,e[127]=pe,e[128]=xe):xe=e[128];let be;e[129]!==r?(be=r("Statements"),e[129]=r,e[130]=be):be=e[130];let Ne;e[131]!==be?(Ne=(0,t.jsxDEV)(_e,{children:be},void 0,!1),e[131]=be,e[132]=Ne):Ne=e[132];let ye;e[133]!==g.length||e[134]!==r?(ye=r("{count} tracked statements",{count:g.length}),e[133]=g.length,e[134]=r,e[135]=ye):ye=e[135];let Se;e[136]!==ye?(Se=(0,t.jsxDEV)(Ve,{children:ye},void 0,!1),e[136]=ye,e[137]=Se):Se=e[137];let we;e[138]!==Ne||e[139]!==Se?(we=(0,t.jsxDEV)(Re,{children:[Ne,Se]},void 0,!0),e[138]=Ne,e[139]=Se,e[140]=we):we=e[140];let qe;e[141]!==h||e[142]!==g||e[143]!==r?(qe=(0,t.jsxDEV)(P,{children:(0,t.jsxDEV)("div",{className:"space-y-2",children:g.map(o=>{let m=o.normalizedSql,c=h.has(m),z=ze(o.avgDurationMs);return(0,t.jsxDEV)("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[(0,t.jsxDEV)("button",{"aria-expanded":c,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:n(()=>{Fe(m)},"onClick"),type:"button",children:[(0,t.jsxDEV)("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[(0,t.jsxDEV)(Nt,{level:z},void 0,!1),(0,t.jsxDEV)("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:o.normalizedSql},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex shrink-0 items-center gap-4",children:[(0,t.jsxDEV)("div",{className:"text-right",children:[(0,t.jsxDEV)("div",{className:"text-sm font-medium",children:He(o.totalDurationMs)},void 0,!1),(0,t.jsxDEV)("div",{className:"text-xs text-muted-foreground",children:r("total")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"text-right",children:[(0,t.jsxDEV)("div",{className:"text-sm font-medium",children:He(o.avgDurationMs)},void 0,!1),(0,t.jsxDEV)("div",{className:"text-xs text-muted-foreground",children:r("avg")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"text-right",children:[(0,t.jsxDEV)("div",{className:"text-sm font-medium",children:Ee(o.execCount)},void 0,!1),(0,t.jsxDEV)("div",{className:"text-xs text-muted-foreground",children:r("calls")},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0),c&&(0,t.jsxDEV)("div",{className:"space-y-3 border-t bg-muted/30 p-4",children:[(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("p",{className:"mb-2 text-sm font-medium",children:r("Full statement")},void 0,!1),(0,t.jsxDEV)("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:o.normalizedSql},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:r("Exec count")},void 0,!1),(0,t.jsxDEV)("span",{className:"block font-medium tabular-nums",children:Ee(o.execCount)},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:r("Total time")},void 0,!1),(0,t.jsxDEV)("span",{className:"block font-medium tabular-nums",children:He(o.totalDurationMs)},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:r("Rows read")},void 0,!1),(0,t.jsxDEV)("span",{className:"block font-medium tabular-nums",children:Ee(o.rowsRead)},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:r("Rows written")},void 0,!1),(0,t.jsxDEV)("span",{className:"block font-medium tabular-nums",children:Ee(o.rowsWritten)},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0)]},m,!0)})},void 0,!1)},void 0,!1),e[141]=h,e[142]=g,e[143]=r,e[144]=qe):qe=e[144];let Ce;e[145]!==we||e[146]!==qe?(Ce=(0,t.jsxDEV)(B,{children:[we,qe]},void 0,!0),e[145]=we,e[146]=qe,e[147]=Ce):Ce=e[147];let De;return e[148]!==X||e[149]!==xe||e[150]!==Ce?(De=(0,t.jsxDEV)("div",{className:"space-y-4","data-testid":"qi-root",children:[X,xe,Ce]},void 0,!0),e[148]=X,e[149]=xe,e[150]=Ce,e[151]=De):De=e[151],De},"QueryInsights");function St(l){return ze(l.avgDurationMs)==="critical"}n(St,"_temp");function wt(l){return ze(l.avgDurationMs)==="warning"}n(wt,"_temp2");function qt(l){return ze(l.avgDurationMs)==="good"}n(qt,"_temp3");var Ct=Ge(Pe.getMetrics),Tt=n(l=>{let e=Math.floor(l/1e3),s=Math.floor(e/3600),r=Math.floor(e%3600/60),i=e%60;return s>0?`${s.toString()}h ${r.toString()}m`:r>0?`${r.toString()}m ${i.toString()}s`:`${i.toString()}s`},"formatDuration"),Rt=n((l,e)=>l?e:"overview","resolveTab"),_t=n((l,e)=>{let s=l+e;return s===0?"\u2014":`${(l/s*100).toFixed(1)}%`},"hitRate"),q=n(l=>{let e=(0,Le.c)(16),{chart:s,footer:r,label:i,testId:Q,value:C}=l,h;e[0]!==i?(h=(0,t.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i},void 0,!1),e[0]=i,e[1]=h):h=e[1];let T;e[2]!==Q||e[3]!==C?(T=(0,t.jsxDEV)("span",{className:"truncate text-2xl font-semibold tabular-nums text-foreground","data-testid":Q,children:C},void 0,!1),e[2]=Q,e[3]=C,e[4]=T):T=e[4];let p;e[5]!==s||e[6]!==T?(p=(0,t.jsxDEV)("div",{className:"flex items-center justify-between gap-3",children:[T,s]},void 0,!0),e[5]=s,e[6]=T,e[7]=p):p=e[7];let S;e[8]!==h||e[9]!==p?(S=(0,t.jsxDEV)("div",{className:"flex flex-col gap-2.5 p-4",children:[h,p]},void 0,!0),e[8]=h,e[9]=p,e[10]=S):S=e[10];let u;e[11]!==r?(u=r!=null&&(0,t.jsxDEV)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:r},void 0,!1),e[11]=r,e[12]=u):u=e[12];let g;return e[13]!==S||e[14]!==u?(g=(0,t.jsxDEV)(B,{className:"justify-between gap-0 py-0",children:[S,u]},void 0,!0),e[13]=S,e[14]=u,e[15]=g):g=e[15],g},"StatCard"),Kt=n(({initialShardKey:l})=>{let e=Ue(),s=Qe(),[r,i]=(0,v.useState)(l??""),[Q,C]=(0,v.useState)("overview"),[h,T]=(0,v.useState)([]),p=(0,v.useRef)(null),S=(0,v.useRef)(null),u=(0,v.useRef)(!0);(0,v.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]);let g=rt(r.trim(),400),{data:$,error:j,liveError:H}=Ye(Pe.getMetrics,{},{live:!0,shardKey:g}),d=$??null;(0,v.useEffect)(()=>{if($===void 0)return;et(g);let a=$,w=p.current,x=S.current!==null&&S.current!==a.shard;if(S.current=a.shard,p.current=a.requests,x){T([]);return}w!==null&&a.requests>=w&&T(y=>[...y,a.requests-w].slice(-30))},[$,g]);let[_,U]=(0,v.useState)(null),[O,Fe]=(0,v.useState)(!1),I=n(async()=>{Fe(!0);let a=mt(r,Ze());try{let w=await Promise.all(a.map(async x=>{try{let y=await e.query(Ct,{},Je(x));return{error:null,metrics:y,shard:x===""?y.shard:x}}catch(y){return{error:We(y),metrics:null,shard:x===""?"__root__":x}}}));u.current&&U(w)}finally{u.current&&Fe(!1)}},"aggregateAll"),f=_===null?null:ft(_),M=d===null||d.requests===0?"\u2014":`${(d.errors/d.requests*100).toFixed(1)}%`,D=h.length>0?h.at(-1):0,R=d?vt(d):{p90:0,p95:0},F=n(a=>a<=0?"\u2014":a<1?`${(a*1e3).toFixed(0)}\u03BCs`:a<1e3?`${a.toFixed(1)}ms`:`${(a/1e3).toFixed(2)}s`,"formatMs"),b=(0,v.useMemo)(()=>{if(!d||!("queryStats"in d))return;let a=d.queryStats;if(!(!a||!Array.isArray(a)))return ht(a)},[d]),N=Rt(b!==void 0,Q),k=n(()=>{Xe(I())},"runAggregate"),A=n(()=>{U(null)},"clearAggregate"),E=n(()=>{C("overview")},"switchToOverview"),L=n(()=>{C("query-insights")},"switchToQueryInsights");return(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxDEV)(tt,{onChange:i,testId:"mt-shard-input",value:r},void 0,!1),(0,t.jsxDEV)(it,{message:H,prefix:"mt"},void 0,!1),(0,t.jsxDEV)(Oe,{"data-testid":"mt-aggregate",disabled:O,onClick:k,size:"sm",type:"button",variant:"secondary",children:s(O?"Aggregating\u2026":"All shards")},void 0,!1),_!==null&&(0,t.jsxDEV)(Oe,{"data-testid":"mt-aggregate-clear",onClick:A,size:"sm",type:"button",variant:"ghost",children:s("Hide")},void 0,!1),(0,t.jsxDEV)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:ot,rel:"noreferrer",target:"_blank",children:s("Open in Cloudflare")},void 0,!1)]},void 0,!0),j!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:j},void 0,!1),b!==void 0&&(0,t.jsxDEV)("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[(0,t.jsxDEV)("button",{className:`pb-2 text-sm font-medium transition-colors ${N==="overview"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-overview",onClick:E,type:"button",children:s("Overview")},void 0,!1),(0,t.jsxDEV)("button",{className:`pb-2 text-sm font-medium transition-colors ${N==="query-insights"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-query-insights",onClick:L,type:"button",children:[s("Query insights"),b.length>0&&(0,t.jsxDEV)("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:b.length},void 0,!1)]},void 0,!0)]},void 0,!0),N==="query-insights"&&b!==void 0&&(0,t.jsxDEV)(yt,{queryStats:b},void 0,!1),N==="overview"&&d!==null&&(0,t.jsxDEV)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[(0,t.jsxDEV)(q,{chart:h.length>=2?(0,t.jsxDEV)(gt,{ariaLabel:s("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:h,testId:"mt-sparkline"},void 0,!1):void 0,footer:h.length>=2?(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)("span",{className:"font-semibold text-foreground",children:`+${D.toLocaleString()}`},void 0,!1)," ",s("last interval")]},void 0,!0):(0,t.jsxDEV)("span",{"data-testid":"mt-sparkline-empty",children:s("collecting samples\u2026")},void 0,!1),label:s("Requests"),testId:"mt-requests",value:d.requests},void 0,!1),(0,t.jsxDEV)(q,{footer:s("{rate} error rate",{rate:M}),label:s("Errors"),testId:"mt-errors",value:(0,t.jsxDEV)(t.Fragment,{children:[d.errors," (",M,")"]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(q,{footer:R.p90>0?`P90 ${F(R.p90)}`:void 0,label:s("P95 latency"),testId:"mt-p95",value:R.p95>0?F(R.p95):"\u2014"},void 0,!1),(0,t.jsxDEV)(q,{footer:d.cache===null?void 0:`${d.cache.entries.toLocaleString()} ${s("cache entries")}`,label:s("Database size"),testId:"mt-db-size",value:Ae(d.databaseSize)},void 0,!1),(0,t.jsxDEV)(q,{label:s("Shard"),testId:"mt-shard",value:d.shard},void 0,!1),(0,t.jsxDEV)(q,{label:s("Uptime"),testId:"mt-uptime",value:Tt(d.uptimeMs)},void 0,!1),(0,t.jsxDEV)(q,{label:s("Cache hit rate"),testId:"mt-cache",value:d.cache===null?s("no cache configured"):s("{rate} ({count} entries)",{count:d.cache.entries,rate:_t(d.cache.hits,d.cache.misses)})},void 0,!1)]},void 0,!0),N==="overview"&&d===null&&null,N==="overview"&&f!==null&&_!==null&&(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[(0,t.jsxDEV)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[(0,t.jsxDEV)(q,{label:s("Shards"),testId:"mt-agg-shards",value:f.failed>0?s("{reachable} reachable, {failed} unreachable",{failed:f.failed,reachable:f.reachable}):s("{reachable} reachable",{reachable:f.reachable})},void 0,!1),(0,t.jsxDEV)(q,{label:s("Total requests"),testId:"mt-agg-requests",value:f.totalRequests},void 0,!1),(0,t.jsxDEV)(q,{label:s("Total errors"),testId:"mt-agg-errors",value:f.totalErrors},void 0,!1),(0,t.jsxDEV)(q,{label:s("Total database size"),testId:"mt-agg-db-size",value:Ae(f.totalDatabaseSize)},void 0,!1),(0,t.jsxDEV)(q,{label:s("Combined cache hit rate"),testId:"mt-agg-cache",value:f.hitRate===null?s("no cache configured"):`${(f.hitRate*100).toFixed(1)}%`},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(B,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(P,{className:"px-0",children:(0,t.jsxDEV)(st,{"data-testid":"mt-agg-table",children:[(0,t.jsxDEV)(lt,{children:(0,t.jsxDEV)(je,{children:[(0,t.jsxDEV)($e,{children:s("shard")},void 0,!1),(0,t.jsxDEV)($e,{children:s("requests")},void 0,!1),(0,t.jsxDEV)($e,{children:s("errors")},void 0,!1),(0,t.jsxDEV)($e,{children:s("db size")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(at,{children:_.map(a=>(0,t.jsxDEV)(je,{"data-testid":`mt-agg-row-${a.shard}`,children:[(0,t.jsxDEV)(Te,{children:a.shard},void 0,!1),a.metrics===null?(0,t.jsxDEV)(Te,{className:"text-destructive",colSpan:3,children:a.error??s("unreachable")},void 0,!1):(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)(Te,{className:"tabular-nums",children:a.metrics.requests},void 0,!1),(0,t.jsxDEV)(Te,{className:"tabular-nums",children:a.metrics.errors},void 0,!1),(0,t.jsxDEV)(Te,{className:"tabular-nums",children:Ae(a.metrics.databaseSize)},void 0,!1)]},void 0,!0)]},a.shard,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0)]},void 0,!0)},"MetricsPanel");export{Kt as MetricsPanel};
@@ -1 +1 @@
1
- import{a as se}from"./chunk-SDQE2IUJ.js";import"./chunk-X4QFAAZ5.js";import"./chunk-BJGBHGK3.js";import"./chunk-ZIGWVHCS.js";import"./chunk-KEGAWN6Y.js";import{a as te}from"./chunk-XNJNSCLM.js";import{a as z,b as V,c as P,e as D}from"./chunk-SEU5V7I6.js";import{d as X,f as ee}from"./chunk-2MLA6WFH.js";import"./chunk-HV7G6DFP.js";import{c as I}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-CKSHCYGC.js";import{a as J}from"./chunk-BOXSWNXZ.js";import{f as Q}from"./chunk-SDMZKBTD.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as U}from"./chunk-TAD43CG5.js";import{d as O,f as H,g as Y,h as G,l as Z}from"./chunk-ITQKVEP7.js";import"./chunk-22C6COGE.js";import{a as k,e as j,f as ie,g as le,h as oe}from"./chunk-RRCPZMC2.js";var W=j(le(),1),T=j(ie(),1);var o=j(oe(),1);var de=H(J.runSql),ae=k(($,e)=>{let s=Q(),[f,t]=(0,T.useState)(void 0),[i,d]=(0,T.useState)(void 0),[l,c]=(0,T.useState)(!0),q=(0,T.useCallback)(async a=>{c(!0);try{let x=await s.query(de,{sql:$},Y(e));a.cancelled||(t(x),d(void 0))}catch(x){a.cancelled||(t(void 0),d(G(x)))}finally{a.cancelled||c(!1)}},[s,$,e]);return(0,T.useEffect)(()=>{let a={cancelled:!1};return Z(q(a)),()=>{a.cancelled=!0}},[q]),{error:i,loading:l,result:f}},"useRunSql"),re="lunora-studio-dashboards",B={shardKey:"",sql:"",title:""},ne=k($=>{let e=(0,W.c)(54),{onEdit:s,onRemove:f,widget:t}=$,i=O(),{error:d,loading:l,result:c}=ae(t.sql,t.shardKey??""),q;e[0]!==s||e[1]!==t.id?(q=k(()=>{s(t.id)},"t1"),e[0]=s,e[1]=t.id,e[2]=q):q=e[2];let a=q,x;e[3]!==f||e[4]!==t.id?(x=k(()=>{f(t.id)},"t2"),e[3]=f,e[4]=t.id,e[5]=x):x=e[5];let K=x,M=`dashboards-widget-${t.id}`,S;e[6]!==t.title?(S=(0,o.jsxDEV)(P,{className:"min-w-0 truncate",title:t.title,children:t.title},void 0,!1),e[6]=t.title,e[7]=S):S=e[7];let L;e[8]!==i?(L=i("Edit widget"),e[8]=i,e[9]=L):L=e[9];let R=`dashboards-widget-edit-${t.id}`,A;e[10]!==i?(A=i("Edit widget"),e[10]=i,e[11]=A):A=e[11];let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=(0,o.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,o.jsxDEV)("path",{d:"M4 20h4L18 10l-4-4L4 16v4ZM14 6l4 4"},void 0,!1)},void 0,!1),e[12]=w):w=e[12];let C;e[13]!==a||e[14]!==L||e[15]!==R||e[16]!==A?(C=(0,o.jsxDEV)(I,{"aria-label":L,"data-testid":R,onClick:a,size:"icon-xs",title:A,type:"button",variant:"ghost",children:w},void 0,!1),e[13]=a,e[14]=L,e[15]=R,e[16]=A,e[17]=C):C=e[17];let b;e[18]!==i?(b=i("Remove widget"),e[18]=i,e[19]=b):b=e[19];let E=`dashboards-widget-remove-${t.id}`,m;e[20]!==i?(m=i("Remove widget"),e[20]=i,e[21]=m):m=e[21];let p;e[22]===Symbol.for("react.memo_cache_sentinel")?(p=(0,o.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,o.jsxDEV)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"},void 0,!1)},void 0,!1),e[22]=p):p=e[22];let u;e[23]!==K||e[24]!==b||e[25]!==E||e[26]!==m?(u=(0,o.jsxDEV)(I,{"aria-label":b,"data-testid":E,onClick:K,size:"icon-xs",title:m,type:"button",variant:"ghost",children:p},void 0,!1),e[23]=K,e[24]=b,e[25]=E,e[26]=m,e[27]=u):u=e[27];let h;e[28]!==u||e[29]!==C?(h=(0,o.jsxDEV)("div",{className:"flex shrink-0 items-center gap-1",children:[C,u]},void 0,!0),e[28]=u,e[29]=C,e[30]=h):h=e[30];let v;e[31]!==h||e[32]!==S?(v=(0,o.jsxDEV)(V,{className:"flex flex-row items-start justify-between gap-2 border-b pb-3",children:[S,h]},void 0,!0),e[31]=h,e[32]=S,e[33]=v):v=e[33];let g;e[34]!==d||e[35]!==t.id?(g=d!==void 0&&(0,o.jsxDEV)(te,{className:"font-mono text-xs",testId:`dashboards-widget-error-${t.id}`,variant:"destructive",children:d},void 0,!1),e[34]=d,e[35]=t.id,e[36]=g):g=e[36];let N;e[37]!==d||e[38]!==l||e[39]!==c||e[40]!==i||e[41]!==t.id?(N=d===void 0&&l&&c===void 0&&(0,o.jsxDEV)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":`dashboards-widget-loading-${t.id}`,children:i("Running\u2026")},void 0,!1),e[37]=d,e[38]=l,e[39]=c,e[40]=i,e[41]=t.id,e[42]=N):N=e[42];let r;e[43]!==d||e[44]!==c?(r=d===void 0&&c!==void 0&&(0,o.jsxDEV)(se,{result:c},void 0,!1),e[43]=d,e[44]=c,e[45]=r):r=e[45];let n;e[46]!==g||e[47]!==N||e[48]!==r?(n=(0,o.jsxDEV)(D,{className:"min-h-32 py-2",children:[g,N,r]},void 0,!0),e[46]=g,e[47]=N,e[48]=r,e[49]=n):n=e[49];let y;return e[50]!==v||e[51]!==n||e[52]!==M?(y=(0,o.jsxDEV)(z,{"data-testid":M,children:[v,n]},void 0,!0),e[50]=v,e[51]=n,e[52]=M,e[53]=y):y=e[53],y},"WidgetCard"),ce=k($=>{let e=(0,W.c)(58),{draft:s,editing:f,onCancel:t,onChange:i,onSubmit:d}=$,l=O(),c;e[0]!==s||e[1]!==i?(c=k(_=>{i({...s,title:_.target.value})},"t1"),e[0]=s,e[1]=i,e[2]=c):c=e[2];let q=c,a;e[3]!==s||e[4]!==i?(a=k(_=>{i({...s,sql:_.target.value})},"t2"),e[3]=s,e[4]=i,e[5]=a):a=e[5];let x=a,K;e[6]!==s||e[7]!==i?(K=k(_=>{i({...s,shardKey:_.target.value})},"t3"),e[6]=s,e[7]=i,e[8]=K):K=e[8];let M=K,S;e[9]!==d?(S=k(()=>{d()},"t4"),e[9]=d,e[10]=S):S=e[10];let L=S,R;e[11]!==s.sql||e[12]!==s.title?(R=s.title.trim()!==""&&s.sql.trim()!=="",e[11]=s.sql,e[12]=s.title,e[13]=R):R=e[13];let A=R,w;e[14]!==l?(w=l("Widget title"),e[14]=l,e[15]=w):w=e[15];let C;e[16]!==l?(C=l("Widget title"),e[16]=l,e[17]=C):C=e[17];let b;e[18]!==s.title||e[19]!==q||e[20]!==w||e[21]!==C?(b=(0,o.jsxDEV)("input",{"aria-label":w,className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-title",onChange:q,placeholder:C,type:"text",value:s.title},void 0,!1),e[18]=s.title,e[19]=q,e[20]=w,e[21]=C,e[22]=b):b=e[22];let E;e[23]!==l?(E=l("SQL query"),e[23]=l,e[24]=E):E=e[24];let m;e[25]!==s.sql||e[26]!==x||e[27]!==E?(m=(0,o.jsxDEV)("textarea",{"aria-label":E,className:"min-h-24 resize-y rounded-md border border-border bg-background p-2 font-mono text-xs leading-5 outline-none focus-visible:border-ring","data-testid":"dashboards-form-sql",onChange:x,placeholder:"SELECT author, COUNT(*) AS messages FROM \u2026",spellCheck:!1,value:s.sql},void 0,!1),e[25]=s.sql,e[26]=x,e[27]=E,e[28]=m):m=e[28];let p;e[29]!==l?(p=l("Shard key (optional)"),e[29]=l,e[30]=p):p=e[30];let u;e[31]!==l?(u=l("Shard key (optional)"),e[31]=l,e[32]=u):u=e[32];let h;e[33]!==s.shardKey||e[34]!==M||e[35]!==p||e[36]!==u?(h=(0,o.jsxDEV)("input",{"aria-label":p,className:"h-8 rounded-md border border-border bg-background px-2 font-mono text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-shard",onChange:M,placeholder:u,type:"text",value:s.shardKey},void 0,!1),e[33]=s.shardKey,e[34]=M,e[35]=p,e[36]=u,e[37]=h):h=e[37];let v;e[38]!==l?(v=l("Cancel"),e[38]=l,e[39]=v):v=e[39];let g;e[40]!==t||e[41]!==v?(g=(0,o.jsxDEV)(I,{"data-testid":"dashboards-form-cancel",onClick:t,size:"sm",type:"button",variant:"outline",children:v},void 0,!1),e[40]=t,e[41]=v,e[42]=g):g=e[42];let N=!A,r;e[43]!==f||e[44]!==l?(r=l(f?"Save widget":"Add widget"),e[43]=f,e[44]=l,e[45]=r):r=e[45];let n;e[46]!==L||e[47]!==N||e[48]!==r?(n=(0,o.jsxDEV)(I,{"data-testid":"dashboards-form-save",disabled:N,onClick:L,size:"sm",type:"button",children:r},void 0,!1),e[46]=L,e[47]=N,e[48]=r,e[49]=n):n=e[49];let y;e[50]!==g||e[51]!==n?(y=(0,o.jsxDEV)("div",{className:"flex items-center justify-end gap-2",children:[g,n]},void 0,!0),e[50]=g,e[51]=n,e[52]=y):y=e[52];let F;return e[53]!==m||e[54]!==h||e[55]!==y||e[56]!==b?(F=(0,o.jsxDEV)(z,{"data-testid":"dashboards-form",children:(0,o.jsxDEV)(D,{className:"flex flex-col gap-3 py-4",children:[b,m,h,y]},void 0,!0)},void 0,!1),e[53]=m,e[54]=h,e[55]=y,e[56]=b,e[57]=F):F=e[57],F},"WidgetForm"),xe=k($=>{let e=(0,W.c)(39),{initialShardKey:s}=$,f=O(),[t,i]=X(re),[d,l]=(0,T.useState)(B),[c,q]=(0,T.useState)(null),[a,x]=(0,T.useState)(!1),K;e[0]!==s?(K=k(()=>{q(null),l({...B,shardKey:s??""}),x(!0)},"t1"),e[0]=s,e[1]=K):K=e[1];let M=K,S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=k(()=>{x(!1),q(null),l(B)},"t2"),e[2]=S):S=e[2];let L=S,R;e[3]!==t?(R=k(r=>{let n=t.find(y=>y.id===r);n!==void 0&&(q(r),l({shardKey:n.shardKey??"",sql:n.sql,title:n.title}),x(!0))},"t3"),e[3]=t,e[4]=R):R=e[4];let A=R,w;e[5]!==i?(w=k(r=>{i(n=>n.filter(y=>y.id!==r))},"t4"),e[5]=i,e[6]=w):w=e[6];let C=w,b;e[7]!==d.shardKey||e[8]!==d.sql||e[9]!==d.title||e[10]!==c||e[11]!==i?(b=k(()=>{let r=d.title.trim(),n=d.sql.trim();if(r===""||n==="")return;let y=d.shardKey.trim();i(c===null?F=>[...F,{id:ee("w"),shardKey:y,sql:n,title:r}]:F=>F.map(_=>_.id===c?{..._,shardKey:y,sql:n,title:r}:_)),L()},"t5"),e[7]=d.shardKey,e[8]=d.sql,e[9]=d.title,e[10]=c,e[11]=i,e[12]=b):b=e[12];let E=b,m;e[13]!==f?(m=f("Chart widgets backed by saved read-only SQL queries."),e[13]=f,e[14]=m):m=e[14];let p;e[15]!==m?(p=(0,o.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:m},void 0,!1),e[15]=m,e[16]=p):p=e[16];let u;e[17]!==a||e[18]!==M||e[19]!==f?(u=!a&&(0,o.jsxDEV)(I,{"data-testid":"dashboards-add",onClick:M,size:"sm",type:"button",children:f("Add widget")},void 0,!1),e[17]=a,e[18]=M,e[19]=f,e[20]=u):u=e[20];let h;e[21]!==p||e[22]!==u?(h=(0,o.jsxDEV)("div",{className:"flex items-center justify-between",children:[p,u]},void 0,!0),e[21]=p,e[22]=u,e[23]=h):h=e[23];let v;e[24]!==d||e[25]!==c||e[26]!==a||e[27]!==E?(v=a&&(0,o.jsxDEV)(ce,{draft:d,editing:c!==null,onCancel:L,onChange:l,onSubmit:E},void 0,!1),e[24]=d,e[25]=c,e[26]=a,e[27]=E,e[28]=v):v=e[28];let g;e[29]!==a||e[30]!==A||e[31]!==C||e[32]!==f||e[33]!==t?(g=t.length===0&&!a?(0,o.jsxDEV)(U,{description:f("Add a widget to chart a saved SQL query on this browser."),testId:"dashboards-empty",title:f("No widgets yet")},void 0,!1):(0,o.jsxDEV)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3","data-testid":"dashboards-grid",children:t.map(r=>(0,o.jsxDEV)(ne,{onEdit:A,onRemove:C,widget:r},r.id,!1))},void 0,!1),e[29]=a,e[30]=A,e[31]=C,e[32]=f,e[33]=t,e[34]=g):g=e[34];let N;return e[35]!==v||e[36]!==g||e[37]!==h?(N=(0,o.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-dashboards",children:[h,v,g]},void 0,!0),e[35]=v,e[36]=g,e[37]=h,e[38]=N):N=e[38],N},"DashboardsPanel");export{xe as default};
1
+ import{a as se}from"./chunk-SDQE2IUJ.js";import"./chunk-X4QFAAZ5.js";import"./chunk-BJGBHGK3.js";import"./chunk-ZIGWVHCS.js";import"./chunk-KEGAWN6Y.js";import{a as te}from"./chunk-XNJNSCLM.js";import{a as z,b as V,c as P,e as D}from"./chunk-SEU5V7I6.js";import{d as X,f as ee}from"./chunk-2MLA6WFH.js";import"./chunk-HV7G6DFP.js";import{c as I}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-CKSHCYGC.js";import{a as J}from"./chunk-G7ZBM54M.js";import{f as Q}from"./chunk-SDMZKBTD.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as U}from"./chunk-TAD43CG5.js";import{d as O,f as H,g as Y,h as G,l as Z}from"./chunk-ITQKVEP7.js";import"./chunk-22C6COGE.js";import{a as k,e as j,f as ie,g as le,h as oe}from"./chunk-RRCPZMC2.js";var W=j(le(),1),T=j(ie(),1);var o=j(oe(),1);var de=H(J.runSql),ae=k(($,e)=>{let s=Q(),[f,t]=(0,T.useState)(void 0),[i,d]=(0,T.useState)(void 0),[l,c]=(0,T.useState)(!0),q=(0,T.useCallback)(async a=>{c(!0);try{let x=await s.query(de,{sql:$},Y(e));a.cancelled||(t(x),d(void 0))}catch(x){a.cancelled||(t(void 0),d(G(x)))}finally{a.cancelled||c(!1)}},[s,$,e]);return(0,T.useEffect)(()=>{let a={cancelled:!1};return Z(q(a)),()=>{a.cancelled=!0}},[q]),{error:i,loading:l,result:f}},"useRunSql"),re="lunora-studio-dashboards",B={shardKey:"",sql:"",title:""},ne=k($=>{let e=(0,W.c)(54),{onEdit:s,onRemove:f,widget:t}=$,i=O(),{error:d,loading:l,result:c}=ae(t.sql,t.shardKey??""),q;e[0]!==s||e[1]!==t.id?(q=k(()=>{s(t.id)},"t1"),e[0]=s,e[1]=t.id,e[2]=q):q=e[2];let a=q,x;e[3]!==f||e[4]!==t.id?(x=k(()=>{f(t.id)},"t2"),e[3]=f,e[4]=t.id,e[5]=x):x=e[5];let K=x,M=`dashboards-widget-${t.id}`,S;e[6]!==t.title?(S=(0,o.jsxDEV)(P,{className:"min-w-0 truncate",title:t.title,children:t.title},void 0,!1),e[6]=t.title,e[7]=S):S=e[7];let L;e[8]!==i?(L=i("Edit widget"),e[8]=i,e[9]=L):L=e[9];let R=`dashboards-widget-edit-${t.id}`,A;e[10]!==i?(A=i("Edit widget"),e[10]=i,e[11]=A):A=e[11];let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=(0,o.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,o.jsxDEV)("path",{d:"M4 20h4L18 10l-4-4L4 16v4ZM14 6l4 4"},void 0,!1)},void 0,!1),e[12]=w):w=e[12];let C;e[13]!==a||e[14]!==L||e[15]!==R||e[16]!==A?(C=(0,o.jsxDEV)(I,{"aria-label":L,"data-testid":R,onClick:a,size:"icon-xs",title:A,type:"button",variant:"ghost",children:w},void 0,!1),e[13]=a,e[14]=L,e[15]=R,e[16]=A,e[17]=C):C=e[17];let b;e[18]!==i?(b=i("Remove widget"),e[18]=i,e[19]=b):b=e[19];let E=`dashboards-widget-remove-${t.id}`,m;e[20]!==i?(m=i("Remove widget"),e[20]=i,e[21]=m):m=e[21];let p;e[22]===Symbol.for("react.memo_cache_sentinel")?(p=(0,o.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,o.jsxDEV)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"},void 0,!1)},void 0,!1),e[22]=p):p=e[22];let u;e[23]!==K||e[24]!==b||e[25]!==E||e[26]!==m?(u=(0,o.jsxDEV)(I,{"aria-label":b,"data-testid":E,onClick:K,size:"icon-xs",title:m,type:"button",variant:"ghost",children:p},void 0,!1),e[23]=K,e[24]=b,e[25]=E,e[26]=m,e[27]=u):u=e[27];let h;e[28]!==u||e[29]!==C?(h=(0,o.jsxDEV)("div",{className:"flex shrink-0 items-center gap-1",children:[C,u]},void 0,!0),e[28]=u,e[29]=C,e[30]=h):h=e[30];let v;e[31]!==h||e[32]!==S?(v=(0,o.jsxDEV)(V,{className:"flex flex-row items-start justify-between gap-2 border-b pb-3",children:[S,h]},void 0,!0),e[31]=h,e[32]=S,e[33]=v):v=e[33];let g;e[34]!==d||e[35]!==t.id?(g=d!==void 0&&(0,o.jsxDEV)(te,{className:"font-mono text-xs",testId:`dashboards-widget-error-${t.id}`,variant:"destructive",children:d},void 0,!1),e[34]=d,e[35]=t.id,e[36]=g):g=e[36];let N;e[37]!==d||e[38]!==l||e[39]!==c||e[40]!==i||e[41]!==t.id?(N=d===void 0&&l&&c===void 0&&(0,o.jsxDEV)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":`dashboards-widget-loading-${t.id}`,children:i("Running\u2026")},void 0,!1),e[37]=d,e[38]=l,e[39]=c,e[40]=i,e[41]=t.id,e[42]=N):N=e[42];let r;e[43]!==d||e[44]!==c?(r=d===void 0&&c!==void 0&&(0,o.jsxDEV)(se,{result:c},void 0,!1),e[43]=d,e[44]=c,e[45]=r):r=e[45];let n;e[46]!==g||e[47]!==N||e[48]!==r?(n=(0,o.jsxDEV)(D,{className:"min-h-32 py-2",children:[g,N,r]},void 0,!0),e[46]=g,e[47]=N,e[48]=r,e[49]=n):n=e[49];let y;return e[50]!==v||e[51]!==n||e[52]!==M?(y=(0,o.jsxDEV)(z,{"data-testid":M,children:[v,n]},void 0,!0),e[50]=v,e[51]=n,e[52]=M,e[53]=y):y=e[53],y},"WidgetCard"),ce=k($=>{let e=(0,W.c)(58),{draft:s,editing:f,onCancel:t,onChange:i,onSubmit:d}=$,l=O(),c;e[0]!==s||e[1]!==i?(c=k(_=>{i({...s,title:_.target.value})},"t1"),e[0]=s,e[1]=i,e[2]=c):c=e[2];let q=c,a;e[3]!==s||e[4]!==i?(a=k(_=>{i({...s,sql:_.target.value})},"t2"),e[3]=s,e[4]=i,e[5]=a):a=e[5];let x=a,K;e[6]!==s||e[7]!==i?(K=k(_=>{i({...s,shardKey:_.target.value})},"t3"),e[6]=s,e[7]=i,e[8]=K):K=e[8];let M=K,S;e[9]!==d?(S=k(()=>{d()},"t4"),e[9]=d,e[10]=S):S=e[10];let L=S,R;e[11]!==s.sql||e[12]!==s.title?(R=s.title.trim()!==""&&s.sql.trim()!=="",e[11]=s.sql,e[12]=s.title,e[13]=R):R=e[13];let A=R,w;e[14]!==l?(w=l("Widget title"),e[14]=l,e[15]=w):w=e[15];let C;e[16]!==l?(C=l("Widget title"),e[16]=l,e[17]=C):C=e[17];let b;e[18]!==s.title||e[19]!==q||e[20]!==w||e[21]!==C?(b=(0,o.jsxDEV)("input",{"aria-label":w,className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-title",onChange:q,placeholder:C,type:"text",value:s.title},void 0,!1),e[18]=s.title,e[19]=q,e[20]=w,e[21]=C,e[22]=b):b=e[22];let E;e[23]!==l?(E=l("SQL query"),e[23]=l,e[24]=E):E=e[24];let m;e[25]!==s.sql||e[26]!==x||e[27]!==E?(m=(0,o.jsxDEV)("textarea",{"aria-label":E,className:"min-h-24 resize-y rounded-md border border-border bg-background p-2 font-mono text-xs leading-5 outline-none focus-visible:border-ring","data-testid":"dashboards-form-sql",onChange:x,placeholder:"SELECT author, COUNT(*) AS messages FROM \u2026",spellCheck:!1,value:s.sql},void 0,!1),e[25]=s.sql,e[26]=x,e[27]=E,e[28]=m):m=e[28];let p;e[29]!==l?(p=l("Shard key (optional)"),e[29]=l,e[30]=p):p=e[30];let u;e[31]!==l?(u=l("Shard key (optional)"),e[31]=l,e[32]=u):u=e[32];let h;e[33]!==s.shardKey||e[34]!==M||e[35]!==p||e[36]!==u?(h=(0,o.jsxDEV)("input",{"aria-label":p,className:"h-8 rounded-md border border-border bg-background px-2 font-mono text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-shard",onChange:M,placeholder:u,type:"text",value:s.shardKey},void 0,!1),e[33]=s.shardKey,e[34]=M,e[35]=p,e[36]=u,e[37]=h):h=e[37];let v;e[38]!==l?(v=l("Cancel"),e[38]=l,e[39]=v):v=e[39];let g;e[40]!==t||e[41]!==v?(g=(0,o.jsxDEV)(I,{"data-testid":"dashboards-form-cancel",onClick:t,size:"sm",type:"button",variant:"outline",children:v},void 0,!1),e[40]=t,e[41]=v,e[42]=g):g=e[42];let N=!A,r;e[43]!==f||e[44]!==l?(r=l(f?"Save widget":"Add widget"),e[43]=f,e[44]=l,e[45]=r):r=e[45];let n;e[46]!==L||e[47]!==N||e[48]!==r?(n=(0,o.jsxDEV)(I,{"data-testid":"dashboards-form-save",disabled:N,onClick:L,size:"sm",type:"button",children:r},void 0,!1),e[46]=L,e[47]=N,e[48]=r,e[49]=n):n=e[49];let y;e[50]!==g||e[51]!==n?(y=(0,o.jsxDEV)("div",{className:"flex items-center justify-end gap-2",children:[g,n]},void 0,!0),e[50]=g,e[51]=n,e[52]=y):y=e[52];let F;return e[53]!==m||e[54]!==h||e[55]!==y||e[56]!==b?(F=(0,o.jsxDEV)(z,{"data-testid":"dashboards-form",children:(0,o.jsxDEV)(D,{className:"flex flex-col gap-3 py-4",children:[b,m,h,y]},void 0,!0)},void 0,!1),e[53]=m,e[54]=h,e[55]=y,e[56]=b,e[57]=F):F=e[57],F},"WidgetForm"),xe=k($=>{let e=(0,W.c)(39),{initialShardKey:s}=$,f=O(),[t,i]=X(re),[d,l]=(0,T.useState)(B),[c,q]=(0,T.useState)(null),[a,x]=(0,T.useState)(!1),K;e[0]!==s?(K=k(()=>{q(null),l({...B,shardKey:s??""}),x(!0)},"t1"),e[0]=s,e[1]=K):K=e[1];let M=K,S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=k(()=>{x(!1),q(null),l(B)},"t2"),e[2]=S):S=e[2];let L=S,R;e[3]!==t?(R=k(r=>{let n=t.find(y=>y.id===r);n!==void 0&&(q(r),l({shardKey:n.shardKey??"",sql:n.sql,title:n.title}),x(!0))},"t3"),e[3]=t,e[4]=R):R=e[4];let A=R,w;e[5]!==i?(w=k(r=>{i(n=>n.filter(y=>y.id!==r))},"t4"),e[5]=i,e[6]=w):w=e[6];let C=w,b;e[7]!==d.shardKey||e[8]!==d.sql||e[9]!==d.title||e[10]!==c||e[11]!==i?(b=k(()=>{let r=d.title.trim(),n=d.sql.trim();if(r===""||n==="")return;let y=d.shardKey.trim();i(c===null?F=>[...F,{id:ee("w"),shardKey:y,sql:n,title:r}]:F=>F.map(_=>_.id===c?{..._,shardKey:y,sql:n,title:r}:_)),L()},"t5"),e[7]=d.shardKey,e[8]=d.sql,e[9]=d.title,e[10]=c,e[11]=i,e[12]=b):b=e[12];let E=b,m;e[13]!==f?(m=f("Chart widgets backed by saved read-only SQL queries."),e[13]=f,e[14]=m):m=e[14];let p;e[15]!==m?(p=(0,o.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:m},void 0,!1),e[15]=m,e[16]=p):p=e[16];let u;e[17]!==a||e[18]!==M||e[19]!==f?(u=!a&&(0,o.jsxDEV)(I,{"data-testid":"dashboards-add",onClick:M,size:"sm",type:"button",children:f("Add widget")},void 0,!1),e[17]=a,e[18]=M,e[19]=f,e[20]=u):u=e[20];let h;e[21]!==p||e[22]!==u?(h=(0,o.jsxDEV)("div",{className:"flex items-center justify-between",children:[p,u]},void 0,!0),e[21]=p,e[22]=u,e[23]=h):h=e[23];let v;e[24]!==d||e[25]!==c||e[26]!==a||e[27]!==E?(v=a&&(0,o.jsxDEV)(ce,{draft:d,editing:c!==null,onCancel:L,onChange:l,onSubmit:E},void 0,!1),e[24]=d,e[25]=c,e[26]=a,e[27]=E,e[28]=v):v=e[28];let g;e[29]!==a||e[30]!==A||e[31]!==C||e[32]!==f||e[33]!==t?(g=t.length===0&&!a?(0,o.jsxDEV)(U,{description:f("Add a widget to chart a saved SQL query on this browser."),testId:"dashboards-empty",title:f("No widgets yet")},void 0,!1):(0,o.jsxDEV)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3","data-testid":"dashboards-grid",children:t.map(r=>(0,o.jsxDEV)(ne,{onEdit:A,onRemove:C,widget:r},r.id,!1))},void 0,!1),e[29]=a,e[30]=A,e[31]=C,e[32]=f,e[33]=t,e[34]=g):g=e[34];let N;return e[35]!==v||e[36]!==g||e[37]!==h?(N=(0,o.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-dashboards",children:[h,v,g]},void 0,!0),e[35]=v,e[36]=g,e[37]=h,e[38]=N):N=e[38],N},"DashboardsPanel");export{xe as default};
@@ -1 +1 @@
1
- import{a as Q}from"./chunk-WUFVFVHJ.js";import"./chunk-XNJNSCLM.js";import{b as F}from"./chunk-W666BB6V.js";import{a as O,b as $,c as j,d as S,e as n,f as c}from"./chunk-GTM65MVX.js";import{a as B,e as D}from"./chunk-SEU5V7I6.js";import{b as k}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as L}from"./chunk-BOXSWNXZ.js";import"./chunk-SDMZKBTD.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as _}from"./chunk-TAD43CG5.js";import{d as U}from"./chunk-ITQKVEP7.js";import"./chunk-22C6COGE.js";import{a as R,e as M,g as z,h as J}from"./chunk-RRCPZMC2.js";var q=M(z(),1);var l=M(J(),1);var V=["read","insert","update","delete"],K=R((e,s)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[s],"operationLabel"),W=R(e=>{let s=new Map;for(let t of e){let r=s.get(t.table)??{operations:new Set,procedures:[],table:t.table};r.operations.add(t.on),r.procedures.includes(t.procedure)||r.procedures.push(t.procedure),s.set(t.table,r)}return[...s.values()].toSorted((t,r)=>t.table.localeCompare(r.table))},"groupByTable"),ie=R(()=>{let e=(0,q.c)(49),s=U(),t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={},e[0]=t):t=e[0];let{data:r,error:C,errorSource:I}=F(L.rlsPolicies,t),f=r!==void 0,p,d,m,a,u,h,v,b,o;if(e[1]!==r||e[2]!==C||e[3]!==I||e[4]!==f||e[5]!==s){let G=W(Array.isArray(r?.policies)?r.policies:[]),P;e[15]!==r?(P=Array.isArray(r?.roles)?r.roles:[],e[15]=r,e[16]=P):P=e[16],d=P,v="flex flex-col gap-6",b="lunora-rls-panel",e[17]!==C||e[18]!==I?(o=C!==null&&(0,l.jsxDEV)(Q,{error:I,testId:"rls-error"},void 0,!1),e[17]=C,e[18]=I,e[19]=o):o=e[19],h="flex flex-col gap-2",p=B,m="overflow-hidden py-0";let A;e[20]!==s?(A=s("Policies"),e[20]=s,e[21]=A):A=e[21],e[22]!==A?(a=(0,l.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,l.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:A},void 0,!1)},void 0,!1),e[22]=A,e[23]=a):a=e[23],u=f&&G.length===0?(0,l.jsxDEV)(_,{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")},void 0,!1):(0,l.jsxDEV)(D,{className:"px-0",children:(0,l.jsxDEV)(O,{"data-testid":"rls-policies-table",children:[(0,l.jsxDEV)($,{children:(0,l.jsxDEV)(S,{children:[(0,l.jsxDEV)(n,{children:s("Table")},void 0,!1),V.map(i=>(0,l.jsxDEV)(n,{children:K(s,i)},i,!1)),(0,l.jsxDEV)(n,{children:s("Guarded by")},void 0,!1)]},void 0,!0)},void 0,!1),(0,l.jsxDEV)(j,{children:G.map(i=>(0,l.jsxDEV)(S,{"data-testid":`rls-table-${i.table}`,children:[(0,l.jsxDEV)(c,{className:"font-mono text-xs",children:i.table},void 0,!1),V.map(H=>(0,l.jsxDEV)(c,{children:i.operations.has(H)?(0,l.jsxDEV)(k,{variant:"secondary",children:s("Guarded")},void 0,!1):(0,l.jsxDEV)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"},void 0,!1)},H,!1)),(0,l.jsxDEV)(c,{className:"font-mono text-xs text-muted-foreground",children:i.procedures.join(", ")},void 0,!1)]},i.table,!0))},void 0,!1)]},void 0,!0)},void 0,!1),e[1]=r,e[2]=C,e[3]=I,e[4]=f,e[5]=s,e[6]=p,e[7]=d,e[8]=m,e[9]=a,e[10]=u,e[11]=h,e[12]=v,e[13]=b,e[14]=o}else p=e[6],d=e[7],m=e[8],a=e[9],u=e[10],h=e[11],v=e[12],b=e[13],o=e[14];let x;e[24]!==p||e[25]!==m||e[26]!==a||e[27]!==u?(x=(0,l.jsxDEV)(p,{className:m,children:[a,u]},void 0,!0),e[24]=p,e[25]=m,e[26]=a,e[27]=u,e[28]=x):x=e[28];let N;e[29]!==h||e[30]!==x?(N=(0,l.jsxDEV)("section",{className:h,children:x},void 0,!1),e[29]=h,e[30]=x,e[31]=N):N=e[31];let y;e[32]!==s?(y=s("Roles"),e[32]=s,e[33]=y):y=e[33];let g;e[34]!==y?(g=(0,l.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,l.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y},void 0,!1)},void 0,!1),e[34]=y,e[35]=g):g=e[35];let T;e[36]!==f||e[37]!==d||e[38]!==s?(T=f&&d.length===0?(0,l.jsxDEV)(_,{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")},void 0,!1):(0,l.jsxDEV)(D,{className:"px-0",children:(0,l.jsxDEV)(O,{"data-testid":"rls-roles-table",children:[(0,l.jsxDEV)($,{children:(0,l.jsxDEV)(S,{children:[(0,l.jsxDEV)(n,{children:s("Role")},void 0,!1),(0,l.jsxDEV)(n,{children:s("Description")},void 0,!1),(0,l.jsxDEV)(n,{children:s("Permissions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,l.jsxDEV)(j,{children:d.map(Y)},void 0,!1)]},void 0,!0)},void 0,!1),e[36]=f,e[37]=d,e[38]=s,e[39]=T):T=e[39];let w;e[40]!==g||e[41]!==T?(w=(0,l.jsxDEV)("section",{className:"flex flex-col gap-2",children:(0,l.jsxDEV)(B,{className:"overflow-hidden py-0",children:[g,T]},void 0,!0)},void 0,!1),e[40]=g,e[41]=T,e[42]=w):w=e[42];let E;return e[43]!==w||e[44]!==v||e[45]!==b||e[46]!==o||e[47]!==N?(E=(0,l.jsxDEV)("div",{className:v,"data-testid":b,children:[o,N,w]},void 0,!0),e[43]=w,e[44]=v,e[45]=b,e[46]=o,e[47]=N,e[48]=E):E=e[48],E},"RlsPanel");function X(e){return(0,l.jsxDEV)(k,{variant:"outline",children:e},e,!1)}R(X,"_temp");function Y(e){return(0,l.jsxDEV)(S,{"data-testid":`rls-role-${e.name}`,children:[(0,l.jsxDEV)(c,{className:"font-mono text-xs",children:e.name},void 0,!1),(0,l.jsxDEV)(c,{className:"text-muted-foreground",children:e.description??""},void 0,!1),(0,l.jsxDEV)(c,{children:e.permissions.length===0?(0,l.jsxDEV)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"},void 0,!1):(0,l.jsxDEV)("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(X)},void 0,!1)},void 0,!1)]},e.name,!0)}R(Y,"_temp2");export{ie as default};
1
+ import{a as Q}from"./chunk-WUFVFVHJ.js";import"./chunk-XNJNSCLM.js";import{b as F}from"./chunk-W666BB6V.js";import{a as O,b as $,c as j,d as S,e as n,f as c}from"./chunk-GTM65MVX.js";import{a as B,e as D}from"./chunk-SEU5V7I6.js";import{b as k}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as L}from"./chunk-G7ZBM54M.js";import"./chunk-SDMZKBTD.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as _}from"./chunk-TAD43CG5.js";import{d as U}from"./chunk-ITQKVEP7.js";import"./chunk-22C6COGE.js";import{a as R,e as M,g as z,h as J}from"./chunk-RRCPZMC2.js";var q=M(z(),1);var l=M(J(),1);var V=["read","insert","update","delete"],K=R((e,s)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[s],"operationLabel"),W=R(e=>{let s=new Map;for(let t of e){let r=s.get(t.table)??{operations:new Set,procedures:[],table:t.table};r.operations.add(t.on),r.procedures.includes(t.procedure)||r.procedures.push(t.procedure),s.set(t.table,r)}return[...s.values()].toSorted((t,r)=>t.table.localeCompare(r.table))},"groupByTable"),ie=R(()=>{let e=(0,q.c)(49),s=U(),t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={},e[0]=t):t=e[0];let{data:r,error:C,errorSource:I}=F(L.rlsPolicies,t),f=r!==void 0,p,d,m,a,u,h,v,b,o;if(e[1]!==r||e[2]!==C||e[3]!==I||e[4]!==f||e[5]!==s){let G=W(Array.isArray(r?.policies)?r.policies:[]),P;e[15]!==r?(P=Array.isArray(r?.roles)?r.roles:[],e[15]=r,e[16]=P):P=e[16],d=P,v="flex flex-col gap-6",b="lunora-rls-panel",e[17]!==C||e[18]!==I?(o=C!==null&&(0,l.jsxDEV)(Q,{error:I,testId:"rls-error"},void 0,!1),e[17]=C,e[18]=I,e[19]=o):o=e[19],h="flex flex-col gap-2",p=B,m="overflow-hidden py-0";let A;e[20]!==s?(A=s("Policies"),e[20]=s,e[21]=A):A=e[21],e[22]!==A?(a=(0,l.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,l.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:A},void 0,!1)},void 0,!1),e[22]=A,e[23]=a):a=e[23],u=f&&G.length===0?(0,l.jsxDEV)(_,{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")},void 0,!1):(0,l.jsxDEV)(D,{className:"px-0",children:(0,l.jsxDEV)(O,{"data-testid":"rls-policies-table",children:[(0,l.jsxDEV)($,{children:(0,l.jsxDEV)(S,{children:[(0,l.jsxDEV)(n,{children:s("Table")},void 0,!1),V.map(i=>(0,l.jsxDEV)(n,{children:K(s,i)},i,!1)),(0,l.jsxDEV)(n,{children:s("Guarded by")},void 0,!1)]},void 0,!0)},void 0,!1),(0,l.jsxDEV)(j,{children:G.map(i=>(0,l.jsxDEV)(S,{"data-testid":`rls-table-${i.table}`,children:[(0,l.jsxDEV)(c,{className:"font-mono text-xs",children:i.table},void 0,!1),V.map(H=>(0,l.jsxDEV)(c,{children:i.operations.has(H)?(0,l.jsxDEV)(k,{variant:"secondary",children:s("Guarded")},void 0,!1):(0,l.jsxDEV)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"},void 0,!1)},H,!1)),(0,l.jsxDEV)(c,{className:"font-mono text-xs text-muted-foreground",children:i.procedures.join(", ")},void 0,!1)]},i.table,!0))},void 0,!1)]},void 0,!0)},void 0,!1),e[1]=r,e[2]=C,e[3]=I,e[4]=f,e[5]=s,e[6]=p,e[7]=d,e[8]=m,e[9]=a,e[10]=u,e[11]=h,e[12]=v,e[13]=b,e[14]=o}else p=e[6],d=e[7],m=e[8],a=e[9],u=e[10],h=e[11],v=e[12],b=e[13],o=e[14];let x;e[24]!==p||e[25]!==m||e[26]!==a||e[27]!==u?(x=(0,l.jsxDEV)(p,{className:m,children:[a,u]},void 0,!0),e[24]=p,e[25]=m,e[26]=a,e[27]=u,e[28]=x):x=e[28];let N;e[29]!==h||e[30]!==x?(N=(0,l.jsxDEV)("section",{className:h,children:x},void 0,!1),e[29]=h,e[30]=x,e[31]=N):N=e[31];let y;e[32]!==s?(y=s("Roles"),e[32]=s,e[33]=y):y=e[33];let g;e[34]!==y?(g=(0,l.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,l.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y},void 0,!1)},void 0,!1),e[34]=y,e[35]=g):g=e[35];let T;e[36]!==f||e[37]!==d||e[38]!==s?(T=f&&d.length===0?(0,l.jsxDEV)(_,{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")},void 0,!1):(0,l.jsxDEV)(D,{className:"px-0",children:(0,l.jsxDEV)(O,{"data-testid":"rls-roles-table",children:[(0,l.jsxDEV)($,{children:(0,l.jsxDEV)(S,{children:[(0,l.jsxDEV)(n,{children:s("Role")},void 0,!1),(0,l.jsxDEV)(n,{children:s("Description")},void 0,!1),(0,l.jsxDEV)(n,{children:s("Permissions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,l.jsxDEV)(j,{children:d.map(Y)},void 0,!1)]},void 0,!0)},void 0,!1),e[36]=f,e[37]=d,e[38]=s,e[39]=T):T=e[39];let w;e[40]!==g||e[41]!==T?(w=(0,l.jsxDEV)("section",{className:"flex flex-col gap-2",children:(0,l.jsxDEV)(B,{className:"overflow-hidden py-0",children:[g,T]},void 0,!0)},void 0,!1),e[40]=g,e[41]=T,e[42]=w):w=e[42];let E;return e[43]!==w||e[44]!==v||e[45]!==b||e[46]!==o||e[47]!==N?(E=(0,l.jsxDEV)("div",{className:v,"data-testid":b,children:[o,N,w]},void 0,!0),e[43]=w,e[44]=v,e[45]=b,e[46]=o,e[47]=N,e[48]=E):E=e[48],E},"RlsPanel");function X(e){return(0,l.jsxDEV)(k,{variant:"outline",children:e},e,!1)}R(X,"_temp");function Y(e){return(0,l.jsxDEV)(S,{"data-testid":`rls-role-${e.name}`,children:[(0,l.jsxDEV)(c,{className:"font-mono text-xs",children:e.name},void 0,!1),(0,l.jsxDEV)(c,{className:"text-muted-foreground",children:e.description??""},void 0,!1),(0,l.jsxDEV)(c,{children:e.permissions.length===0?(0,l.jsxDEV)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"},void 0,!1):(0,l.jsxDEV)("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(X)},void 0,!1)},void 0,!1)]},e.name,!0)}R(Y,"_temp2");export{ie as default};
@@ -1 +1 @@
1
- import{a as S}from"./chunk-J6J54MBP.js";import{a as R}from"./chunk-EEWKIQUE.js";import{a as h}from"./chunk-JSEXCW5Q.js";import{R as y}from"./chunk-VL23Y44O.js";import"./chunk-HV7G6DFP.js";import{c as L}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{b as F}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as w}from"./chunk-BOXSWNXZ.js";import{f as P}from"./chunk-SDMZKBTD.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as E,f as N,g as m,h as p,l as u}from"./chunk-ITQKVEP7.js";import"./chunk-22C6COGE.js";import{a,e as O,f as Q,h as W}from"./chunk-RRCPZMC2.js";var o=O(Q(),1);var e=O(W(),1);var C=N(w.getPitrBookmark),X=N(w.pitrRestore),le=a(({initialShardKey:A})=>{let c=P(),r=E(),i=A??"",[U,v]=(0,o.useState)(null),[n,q]=(0,o.useState)(""),[B,_]=(0,o.useState)(null),[f,K]=(0,o.useState)(""),[x,M]=(0,o.useState)(!1),[s,z]=(0,o.useState)(null),[T,l]=(0,o.useState)(null),[k,d]=(0,o.useState)(!1),b=(0,o.useCallback)(async()=>{d(!0),l(null);try{let t=await c.query(C,{},m(i));v(t.current)}catch(t){l(p(t))}finally{d(!1)}},[c,i]);(0,o.useEffect)(()=>{u(b())},[b]),S(()=>{u((async()=>{try{let t=await c.query(C,{},m(i));v(t.current)}catch{}})())},!0);let D=a(t=>{q(t.target.value)},"onTimeChange"),j=a(t=>{K(t.target.value)},"onBookmarkChange"),G=a(t=>{M(t.target.checked)},"onRestartChange"),V=a(()=>{n.trim()!==""&&u((async()=>{d(!0),l(null);try{let t=await c.query(C,{time:n.trim()},m(i));_(t.forTime??null),v(t.current)}catch(t){_(null),l(p(t))}finally{d(!1)}})())},"onPreview"),I=a(t=>{u((async()=>{d(!0),l(null);try{let g=await c.mutation(X,t,m(i));z(g),await b()}catch(g){l(p(g))}finally{d(!1)}})())},"runRestore"),Z=f.trim()!==""||n.trim()!=="",H=a(()=>{let t=x?{restart:!0}:{};f.trim()===""?t.time=n.trim():t.bookmark=f.trim(),I(t)},"onConfirmRestore"),J=a(()=>{s!==null&&I(x?{bookmark:s.undoBookmark,restart:!0}:{bookmark:s.undoBookmark})},"onUndo");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-pitr",children:[(0,e.jsxDEV)("div",{className:"flex flex-wrap items-center gap-3",children:(0,e.jsxDEV)("span",{className:"text-xs text-muted-foreground",children:[r("Shard"),": ",(0,e.jsxDEV)("span",{className:"font-mono",children:i===""?r("root"):i},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)("p",{className:"text-sm text-muted-foreground","data-testid":"pitr-note",children:r("In-place recovery to any moment in the last 30 days. For older or portable recovery, use the snapshot backup tier.")},void 0,!1),T!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"pitr-error",role:"alert",children:T},void 0,!1),(0,e.jsxDEV)("section",{className:"rounded-xl border border-border bg-card p-3 shadow-xs",children:[(0,e.jsxDEV)("h3",{className:"mb-2 text-sm font-semibold",children:r("Current bookmark")},void 0,!1),(0,e.jsxDEV)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-current",children:U??(0,e.jsxDEV)("span",{className:"text-muted-foreground",children:"\u2014"},void 0,!1)},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-3 shadow-xs",children:[(0,e.jsxDEV)("h3",{className:"text-sm font-semibold",children:r("Restore")},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,e.jsxDEV)(h,{htmlFor:"pitr-time",children:r("Time (ISO or epoch-ms, last 30 days)")},void 0,!1),(0,e.jsxDEV)("div",{className:"flex items-center gap-2",children:[(0,e.jsxDEV)(y,{"data-testid":"pitr-time",id:"pitr-time",onChange:D,placeholder:"2026-06-01T00:00:00.000Z",value:n},void 0,!1),(0,e.jsxDEV)(L,{"data-testid":"pitr-preview",disabled:k||n.trim()==="",onClick:V,size:"sm",type:"button",variant:"outline",children:r("Preview")},void 0,!1)]},void 0,!0),B!==null&&(0,e.jsxDEV)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-preview-bookmark",children:[r("Bookmark for that time"),": ",B]},void 0,!0)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,e.jsxDEV)(h,{htmlFor:"pitr-bookmark",children:r("Or an explicit bookmark (wins over time)")},void 0,!1),(0,e.jsxDEV)(y,{"data-testid":"pitr-bookmark",id:"pitr-bookmark",onChange:j,placeholder:r("bookmark string"),value:f},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(h,{className:"flex items-center gap-2 text-xs font-normal text-muted-foreground",htmlFor:"pitr-restart",children:[(0,e.jsxDEV)("input",{checked:x,className:"size-4 accent-primary","data-testid":"pitr-restart",id:"pitr-restart",onChange:G,type:"checkbox"},void 0,!1),r("Restart the shard now so recovery applies immediately")]},void 0,!0),(0,e.jsxDEV)("div",{children:(0,e.jsxDEV)(R,{confirmLabel:r("Confirm restore"),disabled:k||!Z,onConfirm:H,testId:"pitr-restore",children:r("Restore")},void 0,!1)},void 0,!1)]},void 0,!0),s!==null&&(0,e.jsxDEV)("section",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs","data-testid":"pitr-result",children:[(0,e.jsxDEV)("div",{className:"flex items-center gap-2",children:[(0,e.jsxDEV)("h3",{className:"text-sm font-semibold",children:r("Restore armed")},void 0,!1),(0,e.jsxDEV)(F,{variant:s.restarted?"destructive":"secondary",children:s.restarted?r("restarted now"):r("on next restart")},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("p",{className:"font-mono text-xs break-all text-muted-foreground",children:[r("Restored to"),": ",s.restoredTo]},void 0,!0),(0,e.jsxDEV)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-undo-bookmark",children:[r("Undo bookmark"),": ",s.undoBookmark]},void 0,!0),(0,e.jsxDEV)("div",{children:(0,e.jsxDEV)(R,{confirmLabel:r("Confirm undo"),disabled:k,onConfirm:J,testId:"pitr-undo",children:r("Undo restore")},void 0,!1)},void 0,!1)]},void 0,!0)]},void 0,!0)},"PitrPanel");export{le as PitrPanel};
1
+ import{a as S}from"./chunk-J6J54MBP.js";import{a as R}from"./chunk-EEWKIQUE.js";import{a as h}from"./chunk-JSEXCW5Q.js";import{R as y}from"./chunk-VL23Y44O.js";import"./chunk-HV7G6DFP.js";import{c as L}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{b as F}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as w}from"./chunk-G7ZBM54M.js";import{f as P}from"./chunk-SDMZKBTD.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as E,f as N,g as m,h as p,l as u}from"./chunk-ITQKVEP7.js";import"./chunk-22C6COGE.js";import{a,e as O,f as Q,h as W}from"./chunk-RRCPZMC2.js";var o=O(Q(),1);var e=O(W(),1);var C=N(w.getPitrBookmark),X=N(w.pitrRestore),le=a(({initialShardKey:A})=>{let c=P(),r=E(),i=A??"",[U,v]=(0,o.useState)(null),[n,q]=(0,o.useState)(""),[B,_]=(0,o.useState)(null),[f,K]=(0,o.useState)(""),[x,M]=(0,o.useState)(!1),[s,z]=(0,o.useState)(null),[T,l]=(0,o.useState)(null),[k,d]=(0,o.useState)(!1),b=(0,o.useCallback)(async()=>{d(!0),l(null);try{let t=await c.query(C,{},m(i));v(t.current)}catch(t){l(p(t))}finally{d(!1)}},[c,i]);(0,o.useEffect)(()=>{u(b())},[b]),S(()=>{u((async()=>{try{let t=await c.query(C,{},m(i));v(t.current)}catch{}})())},!0);let D=a(t=>{q(t.target.value)},"onTimeChange"),j=a(t=>{K(t.target.value)},"onBookmarkChange"),G=a(t=>{M(t.target.checked)},"onRestartChange"),V=a(()=>{n.trim()!==""&&u((async()=>{d(!0),l(null);try{let t=await c.query(C,{time:n.trim()},m(i));_(t.forTime??null),v(t.current)}catch(t){_(null),l(p(t))}finally{d(!1)}})())},"onPreview"),I=a(t=>{u((async()=>{d(!0),l(null);try{let g=await c.mutation(X,t,m(i));z(g),await b()}catch(g){l(p(g))}finally{d(!1)}})())},"runRestore"),Z=f.trim()!==""||n.trim()!=="",H=a(()=>{let t=x?{restart:!0}:{};f.trim()===""?t.time=n.trim():t.bookmark=f.trim(),I(t)},"onConfirmRestore"),J=a(()=>{s!==null&&I(x?{bookmark:s.undoBookmark,restart:!0}:{bookmark:s.undoBookmark})},"onUndo");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-pitr",children:[(0,e.jsxDEV)("div",{className:"flex flex-wrap items-center gap-3",children:(0,e.jsxDEV)("span",{className:"text-xs text-muted-foreground",children:[r("Shard"),": ",(0,e.jsxDEV)("span",{className:"font-mono",children:i===""?r("root"):i},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)("p",{className:"text-sm text-muted-foreground","data-testid":"pitr-note",children:r("In-place recovery to any moment in the last 30 days. For older or portable recovery, use the snapshot backup tier.")},void 0,!1),T!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"pitr-error",role:"alert",children:T},void 0,!1),(0,e.jsxDEV)("section",{className:"rounded-xl border border-border bg-card p-3 shadow-xs",children:[(0,e.jsxDEV)("h3",{className:"mb-2 text-sm font-semibold",children:r("Current bookmark")},void 0,!1),(0,e.jsxDEV)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-current",children:U??(0,e.jsxDEV)("span",{className:"text-muted-foreground",children:"\u2014"},void 0,!1)},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-3 shadow-xs",children:[(0,e.jsxDEV)("h3",{className:"text-sm font-semibold",children:r("Restore")},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,e.jsxDEV)(h,{htmlFor:"pitr-time",children:r("Time (ISO or epoch-ms, last 30 days)")},void 0,!1),(0,e.jsxDEV)("div",{className:"flex items-center gap-2",children:[(0,e.jsxDEV)(y,{"data-testid":"pitr-time",id:"pitr-time",onChange:D,placeholder:"2026-06-01T00:00:00.000Z",value:n},void 0,!1),(0,e.jsxDEV)(L,{"data-testid":"pitr-preview",disabled:k||n.trim()==="",onClick:V,size:"sm",type:"button",variant:"outline",children:r("Preview")},void 0,!1)]},void 0,!0),B!==null&&(0,e.jsxDEV)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-preview-bookmark",children:[r("Bookmark for that time"),": ",B]},void 0,!0)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,e.jsxDEV)(h,{htmlFor:"pitr-bookmark",children:r("Or an explicit bookmark (wins over time)")},void 0,!1),(0,e.jsxDEV)(y,{"data-testid":"pitr-bookmark",id:"pitr-bookmark",onChange:j,placeholder:r("bookmark string"),value:f},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(h,{className:"flex items-center gap-2 text-xs font-normal text-muted-foreground",htmlFor:"pitr-restart",children:[(0,e.jsxDEV)("input",{checked:x,className:"size-4 accent-primary","data-testid":"pitr-restart",id:"pitr-restart",onChange:G,type:"checkbox"},void 0,!1),r("Restart the shard now so recovery applies immediately")]},void 0,!0),(0,e.jsxDEV)("div",{children:(0,e.jsxDEV)(R,{confirmLabel:r("Confirm restore"),disabled:k||!Z,onConfirm:H,testId:"pitr-restore",children:r("Restore")},void 0,!1)},void 0,!1)]},void 0,!0),s!==null&&(0,e.jsxDEV)("section",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs","data-testid":"pitr-result",children:[(0,e.jsxDEV)("div",{className:"flex items-center gap-2",children:[(0,e.jsxDEV)("h3",{className:"text-sm font-semibold",children:r("Restore armed")},void 0,!1),(0,e.jsxDEV)(F,{variant:s.restarted?"destructive":"secondary",children:s.restarted?r("restarted now"):r("on next restart")},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("p",{className:"font-mono text-xs break-all text-muted-foreground",children:[r("Restored to"),": ",s.restoredTo]},void 0,!0),(0,e.jsxDEV)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-undo-bookmark",children:[r("Undo bookmark"),": ",s.undoBookmark]},void 0,!0),(0,e.jsxDEV)("div",{children:(0,e.jsxDEV)(R,{confirmLabel:r("Confirm undo"),disabled:k,onConfirm:J,testId:"pitr-undo",children:r("Undo restore")},void 0,!1)},void 0,!1)]},void 0,!0)]},void 0,!0)},"PitrPanel");export{le as PitrPanel};
@@ -1 +1 @@
1
- import{b as ae}from"./chunk-W666BB6V.js";import{a as $,b as F,c as D,d as p,e as l,f as i}from"./chunk-GTM65MVX.js";import{a as R,e as _}from"./chunk-SEU5V7I6.js";import{a as se}from"./chunk-VLXV72QE.js";import{R as te}from"./chunk-VL23Y44O.js";import"./chunk-HV7G6DFP.js";import{c as T}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-CKSHCYGC.js";import{a as K}from"./chunk-BOXSWNXZ.js";import{f as Q}from"./chunk-SDMZKBTD.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as B}from"./chunk-TAD43CG5.js";import{d as V,f as X,g as Y,h as E,l as W}from"./chunk-ITQKVEP7.js";import"./chunk-22C6COGE.js";import{a as r,e as ee,f as re,h as le}from"./chunk-RRCPZMC2.js";var n=ee(re(),1);var e=ee(le(),1);var ie=["queued","running","paused","waiting","complete","errored","terminated"],ne=["pause","resume","terminate"],de="WORKFLOWS_NOT_CONFIGURED",ce=r(c=>typeof c=="object"&&c!==null&&c.code===de,"isNotConfigured"),fe=r(c=>{let s=c.error??c.output;if(s===void 0)return"\u2014";try{return JSON.stringify(s)}catch{return"(unserializable)"}},"formatStepPayload"),ue=r(({loadDetail:c,loadInstances:s,readOnly:y,runAction:L,workflowName:v})=>{let A=Q(),o=V(),[x,N]=(0,n.useState)(null),[k,I]=(0,n.useState)(null),[w,P]=(0,n.useState)(""),[g,h]=(0,n.useState)(null),[U,S]=(0,n.useState)(!1),[z,J]=(0,n.useState)(null),m=c??(a=>A.getWorkflowInstance(a)),O=y?void 0:L??(s===void 0?a=>A.setWorkflowInstanceStatus(a):void 0),j=r(async()=>{h(null),S(!1);let a=w===""?void 0:w;try{if(s===void 0){let d=await A.listWorkflowInstances({name:v,status:a});if(d.configured===!1){N(null),S(!0);return}N(d.instances);return}N(await s({name:v,status:a}))}catch(d){N(null),ce(d)?S(!0):h(E(d))}},"load");(0,n.useEffect)(()=>{I(null),W(j())},[v,w]);let G=r(async a=>{h(null);try{I(await m({id:a,name:v}))}catch(d){h(E(d))}},"openDetail"),H=r(async(a,d)=>{if(O!==void 0){J(a),h(null);try{await O({action:d,id:a,name:v}),await j()}catch(M){h(E(M))}finally{J(null)}}},"act");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[(0,e.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxDEV)("h3",{className:"text-sm font-medium",children:o("Instance history")},void 0,!1),(0,e.jsxDEV)("select",{"aria-label":o("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:r(a=>{P(a.target.value)},"onChange"),value:w,children:[(0,e.jsxDEV)("option",{value:"",children:o("All statuses")},void 0,!1),ie.map(a=>(0,e.jsxDEV)("option",{value:a,children:a},a,!1))]},void 0,!0)]},void 0,!0),g!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:g},void 0,!1),U&&(0,e.jsxDEV)(B,{description:o("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:o("Workflow inspection not configured")},void 0,!1),!U&&x!==null&&x.length===0&&(0,e.jsxDEV)(B,{description:o("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:o("No instances")},void 0,!1),x!==null&&x.length>0&&(0,e.jsxDEV)(R,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(_,{className:"px-0",children:(0,e.jsxDEV)($,{"data-testid":"workflow-instances-table",children:[(0,e.jsxDEV)(F,{children:(0,e.jsxDEV)(p,{children:[(0,e.jsxDEV)(l,{children:o("Instance id")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Status")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Created")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Ended")},void 0,!1),(0,e.jsxDEV)(l,{"aria-label":o("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(D,{children:x.map(a=>(0,e.jsxDEV)(p,{"data-testid":`workflow-instance-${a.id}`,children:[(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:a.id},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:a.status},void 0,!1),(0,e.jsxDEV)(i,{className:"text-muted-foreground tabular-nums",children:a.createdOn??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"text-muted-foreground tabular-nums",children:a.endedOn??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"text-right",children:(0,e.jsxDEV)("div",{className:"flex justify-end gap-1.5",children:[(0,e.jsxDEV)(T,{"data-testid":`workflow-instance-steps-${a.id}`,onClick:r(()=>{W(G(a.id))},"onClick"),size:"sm",type:"button",variant:"outline",children:o("Steps")},void 0,!1),O!==void 0&&ne.map(d=>(0,e.jsxDEV)(T,{"data-testid":`workflow-instance-${d}-${a.id}`,disabled:z===a.id,onClick:r(()=>{W(H(a.id,d))},"onClick"),size:"sm",type:"button",variant:"ghost",children:o(d)},d,!1))]},void 0,!0)},void 0,!1)]},a.id,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),k!==null&&(0,e.jsxDEV)(R,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:(0,e.jsxDEV)(_,{className:"flex flex-col gap-2 px-4 py-3",children:[(0,e.jsxDEV)("div",{className:"flex items-center justify-between",children:[(0,e.jsxDEV)("span",{className:"font-mono text-xs",children:[o("Steps")," \xB7 ",k.id]},void 0,!0),(0,e.jsxDEV)(T,{"data-testid":"workflow-instance-detail-close",onClick:r(()=>{I(null)},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Close")},void 0,!1)]},void 0,!0),k.steps.length===0?(0,e.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:o("This instance has no recorded steps yet.")},void 0,!1):(0,e.jsxDEV)($,{"data-testid":"workflow-instance-steps",children:[(0,e.jsxDEV)(F,{children:(0,e.jsxDEV)(p,{children:[(0,e.jsxDEV)(l,{children:o("Step")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Type")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Attempts")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Started")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Output")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(D,{children:k.steps.map((a,d)=>(0,e.jsxDEV)(p,{"data-testid":`workflow-step-${String(d)}`,children:[(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:a.name},void 0,!1),(0,e.jsxDEV)(i,{className:"text-xs text-muted-foreground",children:a.type??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"tabular-nums",children:a.attempts??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"text-muted-foreground tabular-nums",children:a.start??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:fe(a)},void 0,!1)]},`${a.name}:${String(d)}`,!0))},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1)]},void 0,!0)},"WorkflowInstanceHistory"),me=X(K.createWorkflowInstance),ve=X(K.getWorkflowInstanceStatus),he=r(c=>{if(c.error)return`${c.error.name}: ${c.error.message}`;if(c.output===void 0)return"\u2014";try{return JSON.stringify(c.output)}catch{return"(unserializable)"}},"formatPayload"),Oe=r(()=>{let c=Q(),s=V(),{data:y,error:L}=ae(K.listWorkflows,{}),[v,A]=(0,n.useState)(""),[o,x]=(0,n.useState)(""),[N,k]=(0,n.useState)(""),[I,w]=(0,n.useState)(!1),[P,g]=(0,n.useState)(null),[h,U]=(0,n.useState)([]),[S,z]=(0,n.useState)(null),J=y!==void 0,m=(0,n.useMemo)(()=>Array.isArray(y?.workflows)?[...y.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],[y]),C=(0,n.useMemo)(()=>m.some(t=>t.exportName===v)?v:m[0]?.exportName??"",[m,v]),q=(0,n.useMemo)(()=>m.find(t=>t.exportName===C),[m,C]),O=r(t=>{U(u=>{let f=u.filter(b=>!(b.exportName===t.exportName&&b.id===t.id));return[t,...f]})},"upsertInstance"),j=r(async()=>{let t=C;if(t==="")return;let u,f=N.trim();if(f!=="")try{u=JSON.parse(f)}catch{g(s("Params must be valid JSON"));return}w(!0),g(null);try{let b=o.trim(),Z=await c.query(me,{exportName:t,id:b===""?void 0:b,params:u},Y(""));O({exportName:t,id:Z.id,status:Z.status}),x("")}catch(b){g(E(b))}finally{w(!1)}},"start"),G=r(()=>{W(j())},"startInstance"),H=r(async(t,u)=>{z(u);try{let f=await c.query(ve,{exportName:t,id:u},Y(""));O({error:f.error,exportName:t,id:f.id,output:f.output,status:f.status})}catch(f){g(E(f))}finally{z(null)}},"refreshInstance"),a=r(t=>{A(t.target.value)},"onSelectedExportChange"),d=r(t=>{x(t.target.value)},"onInstanceIdChange"),M=r(t=>{k(t.target.value)},"onParamsChange"),oe=r(t=>{let{export:u,id:f}=t.currentTarget.dataset;u!==void 0&&f!==void 0&&W(H(u,f))},"onRefreshClick");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[L!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:L},void 0,!1),(0,e.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:s("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")},void 0,!1),J&&m.length===0?(0,e.jsxDEV)(B,{description:s("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:s("No workflows defined")},void 0,!1):(0,e.jsxDEV)(R,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(_,{className:"px-0",children:(0,e.jsxDEV)($,{"data-testid":"workflows-table",children:[(0,e.jsxDEV)(F,{children:(0,e.jsxDEV)(p,{children:[(0,e.jsxDEV)(l,{children:s("Export")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Name")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Class")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Binding")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(D,{children:m.map(t=>(0,e.jsxDEV)(p,{"data-testid":`workflows-row-${t.exportName}`,children:[(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:t.exportName},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:t.name},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:t.className},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:t.binding},void 0,!1)]},t.exportName,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),m.length>0&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[(0,e.jsxDEV)("h3",{className:"text-sm font-medium",children:s("Start instance")},void 0,!1),P!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:P},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxDEV)("select",{"aria-label":s("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:a,value:C,children:m.map(t=>(0,e.jsxDEV)("option",{value:t.exportName,children:t.exportName},t.exportName,!1))},void 0,!1),(0,e.jsxDEV)(te,{"aria-label":s("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:d,placeholder:s("Instance id (optional)"),value:o},void 0,!1),(0,e.jsxDEV)(T,{"data-testid":"workflows-start-button",disabled:I||C==="",onClick:G,children:s(I?"Starting\u2026":"Start instance")},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(se,{"aria-label":s("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:M,placeholder:s("Params (JSON, optional)"),value:N},void 0,!1)]},void 0,!0),h.length>0&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[(0,e.jsxDEV)("h3",{className:"text-sm font-medium",children:s("Instances")},void 0,!1),(0,e.jsxDEV)(R,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(_,{className:"px-0",children:(0,e.jsxDEV)($,{"data-testid":"workflows-instances-table",children:[(0,e.jsxDEV)(F,{children:(0,e.jsxDEV)(p,{children:[(0,e.jsxDEV)(l,{children:s("Workflow")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Instance id")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Status")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Output")},void 0,!1),(0,e.jsxDEV)(l,{},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(D,{children:h.map(t=>(0,e.jsxDEV)(p,{"data-testid":`workflows-instance-${t.id}`,children:[(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:t.exportName},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:t.id},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:t.status},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:he(t)},void 0,!1),(0,e.jsxDEV)(i,{children:(0,e.jsxDEV)(T,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:S===t.id,onClick:oe,size:"xs",variant:"outline",children:S===t.id?s("Refreshing\u2026"):s("Refresh")},void 0,!1)},void 0,!1)]},`${t.exportName}:${t.id}`,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0),q!==void 0&&(0,e.jsxDEV)(ue,{workflowName:q.name},void 0,!1)]},void 0,!0)},"WorkflowsPanel");export{Oe as default};
1
+ import{b as ae}from"./chunk-W666BB6V.js";import{a as $,b as F,c as D,d as p,e as l,f as i}from"./chunk-GTM65MVX.js";import{a as R,e as _}from"./chunk-SEU5V7I6.js";import{a as se}from"./chunk-VLXV72QE.js";import{R as te}from"./chunk-VL23Y44O.js";import"./chunk-HV7G6DFP.js";import{c as T}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-CKSHCYGC.js";import{a as K}from"./chunk-G7ZBM54M.js";import{f as Q}from"./chunk-SDMZKBTD.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as B}from"./chunk-TAD43CG5.js";import{d as V,f as X,g as Y,h as E,l as W}from"./chunk-ITQKVEP7.js";import"./chunk-22C6COGE.js";import{a as r,e as ee,f as re,h as le}from"./chunk-RRCPZMC2.js";var n=ee(re(),1);var e=ee(le(),1);var ie=["queued","running","paused","waiting","complete","errored","terminated"],ne=["pause","resume","terminate"],de="WORKFLOWS_NOT_CONFIGURED",ce=r(c=>typeof c=="object"&&c!==null&&c.code===de,"isNotConfigured"),fe=r(c=>{let s=c.error??c.output;if(s===void 0)return"\u2014";try{return JSON.stringify(s)}catch{return"(unserializable)"}},"formatStepPayload"),ue=r(({loadDetail:c,loadInstances:s,readOnly:y,runAction:L,workflowName:v})=>{let A=Q(),o=V(),[x,N]=(0,n.useState)(null),[k,I]=(0,n.useState)(null),[w,P]=(0,n.useState)(""),[g,h]=(0,n.useState)(null),[U,S]=(0,n.useState)(!1),[z,J]=(0,n.useState)(null),m=c??(a=>A.getWorkflowInstance(a)),O=y?void 0:L??(s===void 0?a=>A.setWorkflowInstanceStatus(a):void 0),j=r(async()=>{h(null),S(!1);let a=w===""?void 0:w;try{if(s===void 0){let d=await A.listWorkflowInstances({name:v,status:a});if(d.configured===!1){N(null),S(!0);return}N(d.instances);return}N(await s({name:v,status:a}))}catch(d){N(null),ce(d)?S(!0):h(E(d))}},"load");(0,n.useEffect)(()=>{I(null),W(j())},[v,w]);let G=r(async a=>{h(null);try{I(await m({id:a,name:v}))}catch(d){h(E(d))}},"openDetail"),H=r(async(a,d)=>{if(O!==void 0){J(a),h(null);try{await O({action:d,id:a,name:v}),await j()}catch(M){h(E(M))}finally{J(null)}}},"act");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[(0,e.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxDEV)("h3",{className:"text-sm font-medium",children:o("Instance history")},void 0,!1),(0,e.jsxDEV)("select",{"aria-label":o("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:r(a=>{P(a.target.value)},"onChange"),value:w,children:[(0,e.jsxDEV)("option",{value:"",children:o("All statuses")},void 0,!1),ie.map(a=>(0,e.jsxDEV)("option",{value:a,children:a},a,!1))]},void 0,!0)]},void 0,!0),g!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:g},void 0,!1),U&&(0,e.jsxDEV)(B,{description:o("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:o("Workflow inspection not configured")},void 0,!1),!U&&x!==null&&x.length===0&&(0,e.jsxDEV)(B,{description:o("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:o("No instances")},void 0,!1),x!==null&&x.length>0&&(0,e.jsxDEV)(R,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(_,{className:"px-0",children:(0,e.jsxDEV)($,{"data-testid":"workflow-instances-table",children:[(0,e.jsxDEV)(F,{children:(0,e.jsxDEV)(p,{children:[(0,e.jsxDEV)(l,{children:o("Instance id")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Status")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Created")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Ended")},void 0,!1),(0,e.jsxDEV)(l,{"aria-label":o("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(D,{children:x.map(a=>(0,e.jsxDEV)(p,{"data-testid":`workflow-instance-${a.id}`,children:[(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:a.id},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:a.status},void 0,!1),(0,e.jsxDEV)(i,{className:"text-muted-foreground tabular-nums",children:a.createdOn??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"text-muted-foreground tabular-nums",children:a.endedOn??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"text-right",children:(0,e.jsxDEV)("div",{className:"flex justify-end gap-1.5",children:[(0,e.jsxDEV)(T,{"data-testid":`workflow-instance-steps-${a.id}`,onClick:r(()=>{W(G(a.id))},"onClick"),size:"sm",type:"button",variant:"outline",children:o("Steps")},void 0,!1),O!==void 0&&ne.map(d=>(0,e.jsxDEV)(T,{"data-testid":`workflow-instance-${d}-${a.id}`,disabled:z===a.id,onClick:r(()=>{W(H(a.id,d))},"onClick"),size:"sm",type:"button",variant:"ghost",children:o(d)},d,!1))]},void 0,!0)},void 0,!1)]},a.id,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),k!==null&&(0,e.jsxDEV)(R,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:(0,e.jsxDEV)(_,{className:"flex flex-col gap-2 px-4 py-3",children:[(0,e.jsxDEV)("div",{className:"flex items-center justify-between",children:[(0,e.jsxDEV)("span",{className:"font-mono text-xs",children:[o("Steps")," \xB7 ",k.id]},void 0,!0),(0,e.jsxDEV)(T,{"data-testid":"workflow-instance-detail-close",onClick:r(()=>{I(null)},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Close")},void 0,!1)]},void 0,!0),k.steps.length===0?(0,e.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:o("This instance has no recorded steps yet.")},void 0,!1):(0,e.jsxDEV)($,{"data-testid":"workflow-instance-steps",children:[(0,e.jsxDEV)(F,{children:(0,e.jsxDEV)(p,{children:[(0,e.jsxDEV)(l,{children:o("Step")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Type")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Attempts")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Started")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Output")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(D,{children:k.steps.map((a,d)=>(0,e.jsxDEV)(p,{"data-testid":`workflow-step-${String(d)}`,children:[(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:a.name},void 0,!1),(0,e.jsxDEV)(i,{className:"text-xs text-muted-foreground",children:a.type??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"tabular-nums",children:a.attempts??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"text-muted-foreground tabular-nums",children:a.start??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:fe(a)},void 0,!1)]},`${a.name}:${String(d)}`,!0))},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1)]},void 0,!0)},"WorkflowInstanceHistory"),me=X(K.createWorkflowInstance),ve=X(K.getWorkflowInstanceStatus),he=r(c=>{if(c.error)return`${c.error.name}: ${c.error.message}`;if(c.output===void 0)return"\u2014";try{return JSON.stringify(c.output)}catch{return"(unserializable)"}},"formatPayload"),Oe=r(()=>{let c=Q(),s=V(),{data:y,error:L}=ae(K.listWorkflows,{}),[v,A]=(0,n.useState)(""),[o,x]=(0,n.useState)(""),[N,k]=(0,n.useState)(""),[I,w]=(0,n.useState)(!1),[P,g]=(0,n.useState)(null),[h,U]=(0,n.useState)([]),[S,z]=(0,n.useState)(null),J=y!==void 0,m=(0,n.useMemo)(()=>Array.isArray(y?.workflows)?[...y.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],[y]),C=(0,n.useMemo)(()=>m.some(t=>t.exportName===v)?v:m[0]?.exportName??"",[m,v]),q=(0,n.useMemo)(()=>m.find(t=>t.exportName===C),[m,C]),O=r(t=>{U(u=>{let f=u.filter(b=>!(b.exportName===t.exportName&&b.id===t.id));return[t,...f]})},"upsertInstance"),j=r(async()=>{let t=C;if(t==="")return;let u,f=N.trim();if(f!=="")try{u=JSON.parse(f)}catch{g(s("Params must be valid JSON"));return}w(!0),g(null);try{let b=o.trim(),Z=await c.query(me,{exportName:t,id:b===""?void 0:b,params:u},Y(""));O({exportName:t,id:Z.id,status:Z.status}),x("")}catch(b){g(E(b))}finally{w(!1)}},"start"),G=r(()=>{W(j())},"startInstance"),H=r(async(t,u)=>{z(u);try{let f=await c.query(ve,{exportName:t,id:u},Y(""));O({error:f.error,exportName:t,id:f.id,output:f.output,status:f.status})}catch(f){g(E(f))}finally{z(null)}},"refreshInstance"),a=r(t=>{A(t.target.value)},"onSelectedExportChange"),d=r(t=>{x(t.target.value)},"onInstanceIdChange"),M=r(t=>{k(t.target.value)},"onParamsChange"),oe=r(t=>{let{export:u,id:f}=t.currentTarget.dataset;u!==void 0&&f!==void 0&&W(H(u,f))},"onRefreshClick");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[L!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:L},void 0,!1),(0,e.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:s("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")},void 0,!1),J&&m.length===0?(0,e.jsxDEV)(B,{description:s("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:s("No workflows defined")},void 0,!1):(0,e.jsxDEV)(R,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(_,{className:"px-0",children:(0,e.jsxDEV)($,{"data-testid":"workflows-table",children:[(0,e.jsxDEV)(F,{children:(0,e.jsxDEV)(p,{children:[(0,e.jsxDEV)(l,{children:s("Export")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Name")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Class")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Binding")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(D,{children:m.map(t=>(0,e.jsxDEV)(p,{"data-testid":`workflows-row-${t.exportName}`,children:[(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:t.exportName},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:t.name},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:t.className},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:t.binding},void 0,!1)]},t.exportName,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),m.length>0&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[(0,e.jsxDEV)("h3",{className:"text-sm font-medium",children:s("Start instance")},void 0,!1),P!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:P},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxDEV)("select",{"aria-label":s("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:a,value:C,children:m.map(t=>(0,e.jsxDEV)("option",{value:t.exportName,children:t.exportName},t.exportName,!1))},void 0,!1),(0,e.jsxDEV)(te,{"aria-label":s("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:d,placeholder:s("Instance id (optional)"),value:o},void 0,!1),(0,e.jsxDEV)(T,{"data-testid":"workflows-start-button",disabled:I||C==="",onClick:G,children:s(I?"Starting\u2026":"Start instance")},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(se,{"aria-label":s("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:M,placeholder:s("Params (JSON, optional)"),value:N},void 0,!1)]},void 0,!0),h.length>0&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[(0,e.jsxDEV)("h3",{className:"text-sm font-medium",children:s("Instances")},void 0,!1),(0,e.jsxDEV)(R,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(_,{className:"px-0",children:(0,e.jsxDEV)($,{"data-testid":"workflows-instances-table",children:[(0,e.jsxDEV)(F,{children:(0,e.jsxDEV)(p,{children:[(0,e.jsxDEV)(l,{children:s("Workflow")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Instance id")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Status")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Output")},void 0,!1),(0,e.jsxDEV)(l,{},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(D,{children:h.map(t=>(0,e.jsxDEV)(p,{"data-testid":`workflows-instance-${t.id}`,children:[(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:t.exportName},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:t.id},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:t.status},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:he(t)},void 0,!1),(0,e.jsxDEV)(i,{children:(0,e.jsxDEV)(T,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:S===t.id,onClick:oe,size:"xs",variant:"outline",children:S===t.id?s("Refreshing\u2026"):s("Refresh")},void 0,!1)},void 0,!1)]},`${t.exportName}:${t.id}`,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0),q!==void 0&&(0,e.jsxDEV)(ue,{workflowName:q.name},void 0,!1)]},void 0,!0)},"WorkflowsPanel");export{Oe as default};
@@ -1 +1 @@
1
- import{a as He}from"./chunk-EOE5NDMK.js";import"./chunk-DWDILV2E.js";import{a as je}from"./chunk-J6J54MBP.js";import"./chunk-5OIBXYZM.js";import{a as Pe}from"./chunk-WUFVFVHJ.js";import{a as Ge}from"./chunk-XNJNSCLM.js";import{b as De}from"./chunk-W666BB6V.js";import{a as Be,b as Re,c as $e,d as j,e as E,f as _}from"./chunk-GTM65MVX.js";import{a as Le,e as Me}from"./chunk-SEU5V7I6.js";import{a as Ve}from"./chunk-VLXV72QE.js";import{R as We}from"./chunk-VL23Y44O.js";import"./chunk-HV7G6DFP.js";import{c as V}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{b as de}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as J}from"./chunk-BOXSWNXZ.js";import{f as Fe}from"./chunk-SDMZKBTD.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as ie}from"./chunk-TAD43CG5.js";import{d as U,f as ce,g as ue,h as me,l as fe,p as ze}from"./chunk-ITQKVEP7.js";import"./chunk-22C6COGE.js";import{a as f,e as Ie,f as at,g as ot,h as rt}from"./chunk-RRCPZMC2.js";var F=Ie(ot(),1);var w=Ie(at(),1);var t=Ie(rt(),1);var lt=f((o,e)=>{let s=new Set(o.map(a=>a.deadLetterQueue).filter(a=>typeof a=="string"&&a!=="")),i=o.filter(a=>(a.deadLetterQueue===void 0||a.deadLetterQueue==="")&&!s.has(a.name)),n=e.filter(a=>a.deadLettered).length;return{deadLetteredCount:n,queuesWithoutDlq:i,showReliabilityWarning:i.length>0||n>0}},"computeQueueReliability"),nt=200,dt=ce(J.sendQueueMessage),it=ce(J.replayQueueMessage),ct=ce(J.clearQueueMessages),Ye=96,ut=f(o=>{if(o===void 0)return"\u2014";try{return JSON.stringify(o)}catch{return"[unserializable]"}},"formatBody"),mt=f(o=>o.length>Ye?`${o.slice(0,Ye)}\u2026`:o,"truncate"),ft=f(o=>o==="error"?"destructive":o==="retry"?"outline":"secondary","outcomeVariant"),ht=f((o,e)=>e(o==="messages"?"Messages":o==="send"?"Send":"Declared"),"tabLabel"),pt=f(o=>{let e=(0,F.c)(11),{loaded:s,queues:i}=o,n=U(),a;e[0]!==n?(a=n("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[0]=n,e[1]=a):a=e[1];let l;e[2]!==a?(l=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:a},void 0,!1),e[2]=a,e[3]=l):l=e[3];let r;e[4]!==s||e[5]!==i||e[6]!==n?(r=s&&i.length===0?(0,t.jsxDEV)(ie,{description:n("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:n("No queues defined")},void 0,!1):(0,t.jsxDEV)(Le,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Me,{className:"px-0",children:(0,t.jsxDEV)(Be,{"data-testid":"queues-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(E,{children:n("Export")},void 0,!1),(0,t.jsxDEV)(E,{children:n("Queue")},void 0,!1),(0,t.jsxDEV)(E,{children:n("Mode")},void 0,!1),(0,t.jsxDEV)(E,{children:n("Binding")},void 0,!1),(0,t.jsxDEV)(E,{children:n("Dead-letter")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)($e,{children:i.map(yt)},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[4]=s,e[5]=i,e[6]=n,e[7]=r):r=e[7];let h;return e[8]!==l||e[9]!==r?(h=(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[l,r]},void 0,!0),e[8]=l,e[9]=r,e[10]=h):h=e[10],h},"QueuesDeclaredTab"),gt=f(o=>{let e=(0,F.c)(67),{message:s,onReplay:i,replayingId:n}=o,a=U(),l,r,h,u,y,p,x,d,m,g;if(e[0]!==s.attempts||e[1]!==s.body||e[2]!==s.deadLettered||e[3]!==s.exportName||e[4]!==s.id||e[5]!==s.messageId||e[6]!==s.outcome||e[7]!==s.queue||e[8]!==a){let W=ut(s.body);r=j,p=`queues-message-${s.id}`;let z=s.exportName??s.queue;e[19]!==z?(x=(0,t.jsxDEV)(_,{className:"font-mono text-xs",children:z},void 0,!1),e[19]=z,e[20]=x):x=e[20],e[21]!==s.messageId?(d=(0,t.jsxDEV)(_,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:s.messageId,children:s.messageId},void 0,!1),e[21]=s.messageId,e[22]=d):d=e[22],e[23]!==s.attempts?(m=(0,t.jsxDEV)(_,{className:"font-mono text-xs tabular-nums",children:s.attempts},void 0,!1),e[23]=s.attempts,e[24]=m):m=e[24];let I=`queues-outcome-${s.id}`,L;e[25]!==s.outcome?(L=ft(s.outcome),e[25]=s.outcome,e[26]=L):L=e[26];let T;e[27]!==s.outcome||e[28]!==I||e[29]!==L?(T=(0,t.jsxDEV)(de,{"data-testid":I,variant:L,children:s.outcome},void 0,!1),e[27]=s.outcome,e[28]=I,e[29]=L,e[30]=T):T=e[30];let M;e[31]!==s.deadLettered||e[32]!==s.id||e[33]!==a?(M=s.deadLettered&&(0,t.jsxDEV)(de,{"data-testid":`queues-dlq-${s.id}`,variant:"destructive",children:a("DLQ")},void 0,!1),e[31]=s.deadLettered,e[32]=s.id,e[33]=a,e[34]=M):M=e[34],e[35]!==T||e[36]!==M?(g=(0,t.jsxDEV)(_,{children:(0,t.jsxDEV)("span",{className:"inline-flex items-center gap-1",children:[T,M]},void 0,!0)},void 0,!1),e[35]=T,e[36]=M,e[37]=g):g=e[37],l=_,h="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",u=W,y=mt(W),e[0]=s.attempts,e[1]=s.body,e[2]=s.deadLettered,e[3]=s.exportName,e[4]=s.id,e[5]=s.messageId,e[6]=s.outcome,e[7]=s.queue,e[8]=a,e[9]=l,e[10]=r,e[11]=h,e[12]=u,e[13]=y,e[14]=p,e[15]=x,e[16]=d,e[17]=m,e[18]=g}else l=e[9],r=e[10],h=e[11],u=e[12],y=e[13],p=e[14],x=e[15],d=e[16],m=e[17],g=e[18];let v;e[38]!==l||e[39]!==h||e[40]!==u||e[41]!==y?(v=(0,t.jsxDEV)(l,{className:h,title:u,children:y},void 0,!1),e[38]=l,e[39]=h,e[40]=u,e[41]=y,e[42]=v):v=e[42];let N;e[43]!==s.capturedAt?(N=ze(s.capturedAt,"\u2014"),e[43]=s.capturedAt,e[44]=N):N=e[44];let b;e[45]!==N?(b=(0,t.jsxDEV)(_,{className:"text-xs text-muted-foreground tabular-nums",children:N},void 0,!1),e[45]=N,e[46]=b):b=e[46];let S=`queues-replay-${s.id}`,A=n!==null,C;e[47]!==s.id||e[48]!==n||e[49]!==a?(C=n===s.id?a("Replaying\u2026"):a("Replay"),e[47]=s.id,e[48]=n,e[49]=a,e[50]=C):C=e[50];let Q;e[51]!==s.id||e[52]!==i||e[53]!==S||e[54]!==A||e[55]!==C?(Q=(0,t.jsxDEV)(_,{children:(0,t.jsxDEV)(V,{"data-id":s.id,"data-testid":S,disabled:A,onClick:i,size:"xs",type:"button",variant:"outline",children:C},void 0,!1)},void 0,!1),e[51]=s.id,e[52]=i,e[53]=S,e[54]=A,e[55]=C,e[56]=Q):Q=e[56];let D;return e[57]!==r||e[58]!==b||e[59]!==Q||e[60]!==p||e[61]!==x||e[62]!==d||e[63]!==m||e[64]!==g||e[65]!==v?(D=(0,t.jsxDEV)(r,{"data-testid":p,children:[x,d,m,g,v,b,Q]},void 0,!0),e[57]=r,e[58]=b,e[59]=Q,e[60]=p,e[61]=x,e[62]=d,e[63]=m,e[64]=g,e[65]=v,e[66]=D):D=e[66],D},"QueueLogRow"),vt=f(o=>{let e=(0,F.c)(26),{hasError:s,messages:i,onClear:n,onReplay:a,replayingId:l}=o,r=U(),h;e[0]!==r?(h=r("Cloudflare Queues have no peek API, so this is what push consumers actually processed \u2014 not pending depth."),e[0]=r,e[1]=h):h=e[1];let u;e[2]!==h?(u=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:h},void 0,!1),e[2]=h,e[3]=u):u=e[3];let y=i.length===0,p;e[4]!==r?(p=r("Clear log"),e[4]=r,e[5]=p):p=e[5];let x;e[6]!==n||e[7]!==y||e[8]!==p?(x=(0,t.jsxDEV)(V,{className:"ml-auto","data-testid":"queues-clear",disabled:y,onClick:n,size:"sm",type:"button",variant:"outline",children:p},void 0,!1),e[6]=n,e[7]=y,e[8]=p,e[9]=x):x=e[9];let d;e[10]!==i.length||e[11]!==r?(d=i.length>0&&(0,t.jsxDEV)(de,{"data-testid":"queues-count",variant:"secondary",children:r("{count} messages",{count:i.length})},void 0,!1),e[10]=i.length,e[11]=r,e[12]=d):d=e[12];let m;e[13]!==u||e[14]!==x||e[15]!==d?(m=(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[u,x,d]},void 0,!0),e[13]=u,e[14]=x,e[15]=d,e[16]=m):m=e[16];let g;e[17]!==s||e[18]!==i||e[19]!==a||e[20]!==l||e[21]!==r?(g=!s&&i.length===0?(0,t.jsxDEV)(ie,{description:r("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:r("No consumed messages yet.")},void 0,!1):(0,t.jsxDEV)(Le,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Me,{className:"px-0",children:(0,t.jsxDEV)(He,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:(0,t.jsxDEV)(Be,{"data-testid":"queues-messages-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(E,{children:r("Export")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Message")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Attempts")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Outcome")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Body")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Captured")},void 0,!1),(0,t.jsxDEV)(E,{},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)($e,{children:i.map(N=>(0,t.jsxDEV)(gt,{message:N,onReplay:a,replayingId:l},N.id,!1))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)},void 0,!1),e[17]=s,e[18]=i,e[19]=a,e[20]=l,e[21]=r,e[22]=g):g=e[22];let v;return e[23]!==m||e[24]!==g?(v=(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[m,g]},void 0,!0),e[23]=m,e[24]=g,e[25]=v):v=e[25],v},"QueuesMessagesTab"),xt=f(o=>{let e=(0,F.c)(20),{batchMode:s,bodyText:i,delayText:n,onBatchModeChange:a,onBodyChange:l,onDelayChange:r,onSelectExport:h,onSend:u,queues:y,selectedExportName:p,sending:x}=o,d=U(),m;e[0]!==d?(m=d("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=d,e[1]=m):m=e[1];let g;e[2]!==m?(g=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:m},void 0,!1),e[2]=m,e[3]=g):g=e[3];let v;e[4]!==s||e[5]!==i||e[6]!==n||e[7]!==a||e[8]!==l||e[9]!==r||e[10]!==h||e[11]!==u||e[12]!==y||e[13]!==p||e[14]!==x||e[15]!==d?(v=y.length===0?(0,t.jsxDEV)(ie,{description:d("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:d("No queues to send to")},void 0,!1):(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxDEV)("select",{"aria-label":d("Queue"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"queues-send-select",onChange:h,value:p,children:y.map(bt)},void 0,!1),(0,t.jsxDEV)(We,{"aria-label":d("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:r,placeholder:d("Delay (s)"),type:"number",value:n},void 0,!1),(0,t.jsxDEV)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[(0,t.jsxDEV)("input",{checked:s,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:a,type:"checkbox"},void 0,!1),d("Send as batch (JSON array)")]},void 0,!0),(0,t.jsxDEV)(V,{className:"ml-auto","data-testid":"queues-send-button",disabled:x||p==="",onClick:u,type:"button",children:d(x?"Sending\u2026":"Send message")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(Ve,{"aria-label":d("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:l,placeholder:s?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:i},void 0,!1)]},void 0,!0),e[4]=s,e[5]=i,e[6]=n,e[7]=a,e[8]=l,e[9]=r,e[10]=h,e[11]=u,e[12]=y,e[13]=p,e[14]=x,e[15]=d,e[16]=v):v=e[16];let N;return e[17]!==g||e[18]!==v?(N=(0,t.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[g,v]},void 0,!0),e[17]=g,e[18]=v,e[19]=N):N=e[19],N},"QueuesSendTab"),Ut=f(o=>{let e=(0,F.c)(59),{limit:s}=o,i=s??nt,n=Fe(),a=U(),[l,r]=(0,w.useState)("declared"),[h,u]=(0,w.useState)(null),y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={},e[0]=y):y=e[0];let{data:p,error:x,errorSource:d}=De(J.listQueues,y),m;e[1]!==i?(m={limit:i},e[1]=i,e[2]=m):m=e[2];let{data:g,error:v,errorSource:N,refetch:b}=De(J.getQueueMessages,m),S=Array.isArray(p?.queues)?[...p.queues].toSorted(Nt):[],A=g?.entries??[],{deadLetteredCount:C,queuesWithoutDlq:Q,showReliabilityWarning:D}=lt(S,A),[W,z]=(0,w.useState)(""),[I,L]=(0,w.useState)(""),[T,M]=(0,w.useState)(""),[G,Xe]=(0,w.useState)(!1),[he,Oe]=(0,w.useState)(!1),[pe,ke]=(0,w.useState)(null),H=S.some(c=>c.exportName===W)?W:S[0]?.exportName??"",Ue=l==="messages"?v:x,Ke=l==="messages"?N:d,ge=Ue??h,ve=Ue===null?h:Ke,Y;e[3]!==b?(Y=f(()=>{b()},"t3"),e[3]=b,e[4]=Y):Y=e[4],je(Y,l==="messages");let xe=f(async()=>{u(null);let c=H;if(c==="")return;let q=null,we=I.trim();if(we!=="")try{q=JSON.parse(we)}catch{u(a("Body must be valid JSON."));return}let Ae,Je=T.trim();if(Je!==""){let P=Number(Je);if(!Number.isFinite(P)||P<0){u(a("Delay must be a non-negative number of seconds."));return}Ae=P}if(G&&!Array.isArray(q)){u(a("Batch mode needs a JSON array body \u2014 each element is enqueued as one message."));return}Oe(!0);let st=G?{batch:q,delaySeconds:Ae,exportName:c}:{body:q,delaySeconds:Ae,exportName:c};try{await n.query(dt,st,ue("")),b()}catch(P){u(me(P))}Oe(!1)},"send"),X;e[5]!==n||e[6]!==b?(X=f(async c=>{u(null),ke(c);try{await n.query(it,{id:c},ue("")),b()}catch(q){u(me(q))}ke(null)},"t5"),e[5]=n,e[6]=b,e[7]=X):X=e[7];let ye=X,K;e[8]!==n||e[9]!==b?(K=f(async()=>{u(null);try{await n.query(ct,{},ue("")),b()}catch(c){u(me(c))}},"t6"),e[8]=n,e[9]=b,e[10]=K):K=e[10];let be=K,Z;e[11]===Symbol.for("react.memo_cache_sentinel")?(Z=f(c=>{let q=c.currentTarget.dataset.tab;(q==="declared"||q==="messages"||q==="send")&&r(q)},"t7"),e[11]=Z):Z=e[11];let Ze=Z,ee;e[12]===Symbol.for("react.memo_cache_sentinel")?(ee=f(c=>{z(c.currentTarget.value)},"t8"),e[12]=ee):ee=e[12];let Ne=ee,te;e[13]===Symbol.for("react.memo_cache_sentinel")?(te=f(c=>{L(c.currentTarget.value)},"t9"),e[13]=te):te=e[13];let qe=te,se;e[14]===Symbol.for("react.memo_cache_sentinel")?(se=f(c=>{M(c.currentTarget.value)},"t10"),e[14]=se):se=e[14];let Se=se,ae;e[15]===Symbol.for("react.memo_cache_sentinel")?(ae=f(c=>{Xe(c.currentTarget.checked)},"t11"),e[15]=ae):ae=e[15];let Ee=ae,oe;e[16]!==xe?(oe=f(()=>{fe(xe())},"t12"),e[16]=xe,e[17]=oe):oe=e[17];let _e=oe,re;e[18]!==ye?(re=f(c=>{let{id:q}=c.currentTarget.dataset;q!==void 0&&fe(ye(q))},"t13"),e[18]=ye,e[19]=re):re=e[19];let Te=re,le;e[20]!==be?(le=f(()=>{fe(be())},"t14"),e[20]=be,e[21]=le):le=e[21];let Ce=le,et="flex flex-col gap-6",tt="lunora-queues-panel",B;e[22]!==a||e[23]!==l?(B=(0,t.jsxDEV)("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(c=>(0,t.jsxDEV)(V,{"aria-selected":l===c,"data-tab":c,"data-testid":`queues-tab-${c}`,onClick:Ze,role:"tab",size:"sm",type:"button",variant:l===c?"secondary":"ghost",children:ht(c,a)},c,!1))},void 0,!1),e[22]=a,e[23]=l,e[24]=B):B=e[24];let R;e[25]!==ge||e[26]!==ve?(R=ge!==null&&(0,t.jsxDEV)(Pe,{error:ve,testId:"queues-error"},void 0,!1),e[25]=ge,e[26]=ve,e[27]=R):R=e[27];let Qe=D&&(0,t.jsxDEV)(Ge,{icon:(0,t.jsxDEV)("span",{"aria-hidden":"true",className:"text-base leading-none",children:"\u26A0"},void 0,!1),testId:"queues-dlq-warning",variant:"warning",children:(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[Q.length>0&&(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)("p",{className:"font-medium",children:a("No dead-letter queue on {queues}.",{queues:Q.map(qt).join(", ")})},void 0,!1),(0,t.jsxDEV)("p",{className:"text-muted-foreground",children:a("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")},void 0,!1)]},void 0,!0),C>0&&(0,t.jsxDEV)("p",{className:Q.length>0?"text-muted-foreground":"font-medium",children:C===1?a("1 message was recently dead-lettered."):a("{count} messages were recently dead-lettered.",{count:C})},void 0,!1)]},void 0,!0)},void 0,!1),$;e[28]!==S||e[29]!==p||e[30]!==l?($=l==="declared"&&(0,t.jsxDEV)(pt,{loaded:p!==void 0,queues:S},void 0,!1),e[28]=S,e[29]=p,e[30]=l,e[31]=$):$=e[31];let O;e[32]!==A||e[33]!==v||e[34]!==Ce||e[35]!==Te||e[36]!==pe||e[37]!==l?(O=l==="messages"&&(0,t.jsxDEV)(vt,{hasError:v!==null,messages:A,onClear:Ce,onReplay:Te,replayingId:pe},void 0,!1),e[32]=A,e[33]=v,e[34]=Ce,e[35]=Te,e[36]=pe,e[37]=l,e[38]=O):O=e[38];let k;e[39]!==G||e[40]!==I||e[41]!==T||e[42]!==Ee||e[43]!==qe||e[44]!==Se||e[45]!==Ne||e[46]!==_e||e[47]!==S||e[48]!==H||e[49]!==he||e[50]!==l?(k=l==="send"&&(0,t.jsxDEV)(xt,{batchMode:G,bodyText:I,delayText:T,onBatchModeChange:Ee,onBodyChange:qe,onDelayChange:Se,onSelectExport:Ne,onSend:_e,queues:S,selectedExportName:H,sending:he},void 0,!1),e[39]=G,e[40]=I,e[41]=T,e[42]=Ee,e[43]=qe,e[44]=Se,e[45]=Ne,e[46]=_e,e[47]=S,e[48]=H,e[49]=he,e[50]=l,e[51]=k):k=e[51];let ne;return e[52]!==B||e[53]!==R||e[54]!==Qe||e[55]!==$||e[56]!==O||e[57]!==k?(ne=(0,t.jsxDEV)("div",{className:et,"data-testid":tt,children:[B,R,Qe,$,O,k]},void 0,!0),e[52]=B,e[53]=R,e[54]=Qe,e[55]=$,e[56]=O,e[57]=k,e[58]=ne):ne=e[58],ne},"QueuesPanel");function yt(o){return(0,t.jsxDEV)(j,{"data-testid":`queues-row-${o.exportName}`,children:[(0,t.jsxDEV)(_,{className:"font-mono text-xs",children:o.exportName},void 0,!1),(0,t.jsxDEV)(_,{className:"font-mono text-xs text-muted-foreground",children:o.name},void 0,!1),(0,t.jsxDEV)(_,{className:"font-mono text-xs text-muted-foreground",children:o.mode},void 0,!1),(0,t.jsxDEV)(_,{className:"font-mono text-xs text-muted-foreground",children:o.binding},void 0,!1),(0,t.jsxDEV)(_,{className:"font-mono text-xs text-muted-foreground",children:o.deadLetterQueue??"\u2014"},void 0,!1)]},o.exportName,!0)}f(yt,"_temp");function bt(o){return(0,t.jsxDEV)("option",{value:o.exportName,children:o.exportName},o.exportName,!1)}f(bt,"_temp2");function Nt(o,e){return o.exportName.localeCompare(e.exportName)}f(Nt,"_temp3");function qt(o){return o.name}f(qt,"_temp4");export{Ut as default};
1
+ import{a as He}from"./chunk-EOE5NDMK.js";import"./chunk-DWDILV2E.js";import{a as je}from"./chunk-J6J54MBP.js";import"./chunk-5OIBXYZM.js";import{a as Pe}from"./chunk-WUFVFVHJ.js";import{a as Ge}from"./chunk-XNJNSCLM.js";import{b as De}from"./chunk-W666BB6V.js";import{a as Be,b as Re,c as $e,d as j,e as E,f as _}from"./chunk-GTM65MVX.js";import{a as Le,e as Me}from"./chunk-SEU5V7I6.js";import{a as Ve}from"./chunk-VLXV72QE.js";import{R as We}from"./chunk-VL23Y44O.js";import"./chunk-HV7G6DFP.js";import{c as V}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{b as de}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as J}from"./chunk-G7ZBM54M.js";import{f as Fe}from"./chunk-SDMZKBTD.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as ie}from"./chunk-TAD43CG5.js";import{d as U,f as ce,g as ue,h as me,l as fe,p as ze}from"./chunk-ITQKVEP7.js";import"./chunk-22C6COGE.js";import{a as f,e as Ie,f as at,g as ot,h as rt}from"./chunk-RRCPZMC2.js";var F=Ie(ot(),1);var w=Ie(at(),1);var t=Ie(rt(),1);var lt=f((o,e)=>{let s=new Set(o.map(a=>a.deadLetterQueue).filter(a=>typeof a=="string"&&a!=="")),i=o.filter(a=>(a.deadLetterQueue===void 0||a.deadLetterQueue==="")&&!s.has(a.name)),n=e.filter(a=>a.deadLettered).length;return{deadLetteredCount:n,queuesWithoutDlq:i,showReliabilityWarning:i.length>0||n>0}},"computeQueueReliability"),nt=200,dt=ce(J.sendQueueMessage),it=ce(J.replayQueueMessage),ct=ce(J.clearQueueMessages),Ye=96,ut=f(o=>{if(o===void 0)return"\u2014";try{return JSON.stringify(o)}catch{return"[unserializable]"}},"formatBody"),mt=f(o=>o.length>Ye?`${o.slice(0,Ye)}\u2026`:o,"truncate"),ft=f(o=>o==="error"?"destructive":o==="retry"?"outline":"secondary","outcomeVariant"),ht=f((o,e)=>e(o==="messages"?"Messages":o==="send"?"Send":"Declared"),"tabLabel"),pt=f(o=>{let e=(0,F.c)(11),{loaded:s,queues:i}=o,n=U(),a;e[0]!==n?(a=n("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[0]=n,e[1]=a):a=e[1];let l;e[2]!==a?(l=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:a},void 0,!1),e[2]=a,e[3]=l):l=e[3];let r;e[4]!==s||e[5]!==i||e[6]!==n?(r=s&&i.length===0?(0,t.jsxDEV)(ie,{description:n("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:n("No queues defined")},void 0,!1):(0,t.jsxDEV)(Le,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Me,{className:"px-0",children:(0,t.jsxDEV)(Be,{"data-testid":"queues-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(E,{children:n("Export")},void 0,!1),(0,t.jsxDEV)(E,{children:n("Queue")},void 0,!1),(0,t.jsxDEV)(E,{children:n("Mode")},void 0,!1),(0,t.jsxDEV)(E,{children:n("Binding")},void 0,!1),(0,t.jsxDEV)(E,{children:n("Dead-letter")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)($e,{children:i.map(yt)},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[4]=s,e[5]=i,e[6]=n,e[7]=r):r=e[7];let h;return e[8]!==l||e[9]!==r?(h=(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[l,r]},void 0,!0),e[8]=l,e[9]=r,e[10]=h):h=e[10],h},"QueuesDeclaredTab"),gt=f(o=>{let e=(0,F.c)(67),{message:s,onReplay:i,replayingId:n}=o,a=U(),l,r,h,u,y,p,x,d,m,g;if(e[0]!==s.attempts||e[1]!==s.body||e[2]!==s.deadLettered||e[3]!==s.exportName||e[4]!==s.id||e[5]!==s.messageId||e[6]!==s.outcome||e[7]!==s.queue||e[8]!==a){let W=ut(s.body);r=j,p=`queues-message-${s.id}`;let z=s.exportName??s.queue;e[19]!==z?(x=(0,t.jsxDEV)(_,{className:"font-mono text-xs",children:z},void 0,!1),e[19]=z,e[20]=x):x=e[20],e[21]!==s.messageId?(d=(0,t.jsxDEV)(_,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:s.messageId,children:s.messageId},void 0,!1),e[21]=s.messageId,e[22]=d):d=e[22],e[23]!==s.attempts?(m=(0,t.jsxDEV)(_,{className:"font-mono text-xs tabular-nums",children:s.attempts},void 0,!1),e[23]=s.attempts,e[24]=m):m=e[24];let I=`queues-outcome-${s.id}`,L;e[25]!==s.outcome?(L=ft(s.outcome),e[25]=s.outcome,e[26]=L):L=e[26];let T;e[27]!==s.outcome||e[28]!==I||e[29]!==L?(T=(0,t.jsxDEV)(de,{"data-testid":I,variant:L,children:s.outcome},void 0,!1),e[27]=s.outcome,e[28]=I,e[29]=L,e[30]=T):T=e[30];let M;e[31]!==s.deadLettered||e[32]!==s.id||e[33]!==a?(M=s.deadLettered&&(0,t.jsxDEV)(de,{"data-testid":`queues-dlq-${s.id}`,variant:"destructive",children:a("DLQ")},void 0,!1),e[31]=s.deadLettered,e[32]=s.id,e[33]=a,e[34]=M):M=e[34],e[35]!==T||e[36]!==M?(g=(0,t.jsxDEV)(_,{children:(0,t.jsxDEV)("span",{className:"inline-flex items-center gap-1",children:[T,M]},void 0,!0)},void 0,!1),e[35]=T,e[36]=M,e[37]=g):g=e[37],l=_,h="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",u=W,y=mt(W),e[0]=s.attempts,e[1]=s.body,e[2]=s.deadLettered,e[3]=s.exportName,e[4]=s.id,e[5]=s.messageId,e[6]=s.outcome,e[7]=s.queue,e[8]=a,e[9]=l,e[10]=r,e[11]=h,e[12]=u,e[13]=y,e[14]=p,e[15]=x,e[16]=d,e[17]=m,e[18]=g}else l=e[9],r=e[10],h=e[11],u=e[12],y=e[13],p=e[14],x=e[15],d=e[16],m=e[17],g=e[18];let v;e[38]!==l||e[39]!==h||e[40]!==u||e[41]!==y?(v=(0,t.jsxDEV)(l,{className:h,title:u,children:y},void 0,!1),e[38]=l,e[39]=h,e[40]=u,e[41]=y,e[42]=v):v=e[42];let N;e[43]!==s.capturedAt?(N=ze(s.capturedAt,"\u2014"),e[43]=s.capturedAt,e[44]=N):N=e[44];let b;e[45]!==N?(b=(0,t.jsxDEV)(_,{className:"text-xs text-muted-foreground tabular-nums",children:N},void 0,!1),e[45]=N,e[46]=b):b=e[46];let S=`queues-replay-${s.id}`,A=n!==null,C;e[47]!==s.id||e[48]!==n||e[49]!==a?(C=n===s.id?a("Replaying\u2026"):a("Replay"),e[47]=s.id,e[48]=n,e[49]=a,e[50]=C):C=e[50];let Q;e[51]!==s.id||e[52]!==i||e[53]!==S||e[54]!==A||e[55]!==C?(Q=(0,t.jsxDEV)(_,{children:(0,t.jsxDEV)(V,{"data-id":s.id,"data-testid":S,disabled:A,onClick:i,size:"xs",type:"button",variant:"outline",children:C},void 0,!1)},void 0,!1),e[51]=s.id,e[52]=i,e[53]=S,e[54]=A,e[55]=C,e[56]=Q):Q=e[56];let D;return e[57]!==r||e[58]!==b||e[59]!==Q||e[60]!==p||e[61]!==x||e[62]!==d||e[63]!==m||e[64]!==g||e[65]!==v?(D=(0,t.jsxDEV)(r,{"data-testid":p,children:[x,d,m,g,v,b,Q]},void 0,!0),e[57]=r,e[58]=b,e[59]=Q,e[60]=p,e[61]=x,e[62]=d,e[63]=m,e[64]=g,e[65]=v,e[66]=D):D=e[66],D},"QueueLogRow"),vt=f(o=>{let e=(0,F.c)(26),{hasError:s,messages:i,onClear:n,onReplay:a,replayingId:l}=o,r=U(),h;e[0]!==r?(h=r("Cloudflare Queues have no peek API, so this is what push consumers actually processed \u2014 not pending depth."),e[0]=r,e[1]=h):h=e[1];let u;e[2]!==h?(u=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:h},void 0,!1),e[2]=h,e[3]=u):u=e[3];let y=i.length===0,p;e[4]!==r?(p=r("Clear log"),e[4]=r,e[5]=p):p=e[5];let x;e[6]!==n||e[7]!==y||e[8]!==p?(x=(0,t.jsxDEV)(V,{className:"ml-auto","data-testid":"queues-clear",disabled:y,onClick:n,size:"sm",type:"button",variant:"outline",children:p},void 0,!1),e[6]=n,e[7]=y,e[8]=p,e[9]=x):x=e[9];let d;e[10]!==i.length||e[11]!==r?(d=i.length>0&&(0,t.jsxDEV)(de,{"data-testid":"queues-count",variant:"secondary",children:r("{count} messages",{count:i.length})},void 0,!1),e[10]=i.length,e[11]=r,e[12]=d):d=e[12];let m;e[13]!==u||e[14]!==x||e[15]!==d?(m=(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[u,x,d]},void 0,!0),e[13]=u,e[14]=x,e[15]=d,e[16]=m):m=e[16];let g;e[17]!==s||e[18]!==i||e[19]!==a||e[20]!==l||e[21]!==r?(g=!s&&i.length===0?(0,t.jsxDEV)(ie,{description:r("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:r("No consumed messages yet.")},void 0,!1):(0,t.jsxDEV)(Le,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Me,{className:"px-0",children:(0,t.jsxDEV)(He,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:(0,t.jsxDEV)(Be,{"data-testid":"queues-messages-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(E,{children:r("Export")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Message")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Attempts")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Outcome")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Body")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Captured")},void 0,!1),(0,t.jsxDEV)(E,{},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)($e,{children:i.map(N=>(0,t.jsxDEV)(gt,{message:N,onReplay:a,replayingId:l},N.id,!1))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)},void 0,!1),e[17]=s,e[18]=i,e[19]=a,e[20]=l,e[21]=r,e[22]=g):g=e[22];let v;return e[23]!==m||e[24]!==g?(v=(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[m,g]},void 0,!0),e[23]=m,e[24]=g,e[25]=v):v=e[25],v},"QueuesMessagesTab"),xt=f(o=>{let e=(0,F.c)(20),{batchMode:s,bodyText:i,delayText:n,onBatchModeChange:a,onBodyChange:l,onDelayChange:r,onSelectExport:h,onSend:u,queues:y,selectedExportName:p,sending:x}=o,d=U(),m;e[0]!==d?(m=d("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=d,e[1]=m):m=e[1];let g;e[2]!==m?(g=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:m},void 0,!1),e[2]=m,e[3]=g):g=e[3];let v;e[4]!==s||e[5]!==i||e[6]!==n||e[7]!==a||e[8]!==l||e[9]!==r||e[10]!==h||e[11]!==u||e[12]!==y||e[13]!==p||e[14]!==x||e[15]!==d?(v=y.length===0?(0,t.jsxDEV)(ie,{description:d("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:d("No queues to send to")},void 0,!1):(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxDEV)("select",{"aria-label":d("Queue"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"queues-send-select",onChange:h,value:p,children:y.map(bt)},void 0,!1),(0,t.jsxDEV)(We,{"aria-label":d("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:r,placeholder:d("Delay (s)"),type:"number",value:n},void 0,!1),(0,t.jsxDEV)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[(0,t.jsxDEV)("input",{checked:s,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:a,type:"checkbox"},void 0,!1),d("Send as batch (JSON array)")]},void 0,!0),(0,t.jsxDEV)(V,{className:"ml-auto","data-testid":"queues-send-button",disabled:x||p==="",onClick:u,type:"button",children:d(x?"Sending\u2026":"Send message")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(Ve,{"aria-label":d("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:l,placeholder:s?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:i},void 0,!1)]},void 0,!0),e[4]=s,e[5]=i,e[6]=n,e[7]=a,e[8]=l,e[9]=r,e[10]=h,e[11]=u,e[12]=y,e[13]=p,e[14]=x,e[15]=d,e[16]=v):v=e[16];let N;return e[17]!==g||e[18]!==v?(N=(0,t.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[g,v]},void 0,!0),e[17]=g,e[18]=v,e[19]=N):N=e[19],N},"QueuesSendTab"),Ut=f(o=>{let e=(0,F.c)(59),{limit:s}=o,i=s??nt,n=Fe(),a=U(),[l,r]=(0,w.useState)("declared"),[h,u]=(0,w.useState)(null),y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={},e[0]=y):y=e[0];let{data:p,error:x,errorSource:d}=De(J.listQueues,y),m;e[1]!==i?(m={limit:i},e[1]=i,e[2]=m):m=e[2];let{data:g,error:v,errorSource:N,refetch:b}=De(J.getQueueMessages,m),S=Array.isArray(p?.queues)?[...p.queues].toSorted(Nt):[],A=g?.entries??[],{deadLetteredCount:C,queuesWithoutDlq:Q,showReliabilityWarning:D}=lt(S,A),[W,z]=(0,w.useState)(""),[I,L]=(0,w.useState)(""),[T,M]=(0,w.useState)(""),[G,Xe]=(0,w.useState)(!1),[he,Oe]=(0,w.useState)(!1),[pe,ke]=(0,w.useState)(null),H=S.some(c=>c.exportName===W)?W:S[0]?.exportName??"",Ue=l==="messages"?v:x,Ke=l==="messages"?N:d,ge=Ue??h,ve=Ue===null?h:Ke,Y;e[3]!==b?(Y=f(()=>{b()},"t3"),e[3]=b,e[4]=Y):Y=e[4],je(Y,l==="messages");let xe=f(async()=>{u(null);let c=H;if(c==="")return;let q=null,we=I.trim();if(we!=="")try{q=JSON.parse(we)}catch{u(a("Body must be valid JSON."));return}let Ae,Je=T.trim();if(Je!==""){let P=Number(Je);if(!Number.isFinite(P)||P<0){u(a("Delay must be a non-negative number of seconds."));return}Ae=P}if(G&&!Array.isArray(q)){u(a("Batch mode needs a JSON array body \u2014 each element is enqueued as one message."));return}Oe(!0);let st=G?{batch:q,delaySeconds:Ae,exportName:c}:{body:q,delaySeconds:Ae,exportName:c};try{await n.query(dt,st,ue("")),b()}catch(P){u(me(P))}Oe(!1)},"send"),X;e[5]!==n||e[6]!==b?(X=f(async c=>{u(null),ke(c);try{await n.query(it,{id:c},ue("")),b()}catch(q){u(me(q))}ke(null)},"t5"),e[5]=n,e[6]=b,e[7]=X):X=e[7];let ye=X,K;e[8]!==n||e[9]!==b?(K=f(async()=>{u(null);try{await n.query(ct,{},ue("")),b()}catch(c){u(me(c))}},"t6"),e[8]=n,e[9]=b,e[10]=K):K=e[10];let be=K,Z;e[11]===Symbol.for("react.memo_cache_sentinel")?(Z=f(c=>{let q=c.currentTarget.dataset.tab;(q==="declared"||q==="messages"||q==="send")&&r(q)},"t7"),e[11]=Z):Z=e[11];let Ze=Z,ee;e[12]===Symbol.for("react.memo_cache_sentinel")?(ee=f(c=>{z(c.currentTarget.value)},"t8"),e[12]=ee):ee=e[12];let Ne=ee,te;e[13]===Symbol.for("react.memo_cache_sentinel")?(te=f(c=>{L(c.currentTarget.value)},"t9"),e[13]=te):te=e[13];let qe=te,se;e[14]===Symbol.for("react.memo_cache_sentinel")?(se=f(c=>{M(c.currentTarget.value)},"t10"),e[14]=se):se=e[14];let Se=se,ae;e[15]===Symbol.for("react.memo_cache_sentinel")?(ae=f(c=>{Xe(c.currentTarget.checked)},"t11"),e[15]=ae):ae=e[15];let Ee=ae,oe;e[16]!==xe?(oe=f(()=>{fe(xe())},"t12"),e[16]=xe,e[17]=oe):oe=e[17];let _e=oe,re;e[18]!==ye?(re=f(c=>{let{id:q}=c.currentTarget.dataset;q!==void 0&&fe(ye(q))},"t13"),e[18]=ye,e[19]=re):re=e[19];let Te=re,le;e[20]!==be?(le=f(()=>{fe(be())},"t14"),e[20]=be,e[21]=le):le=e[21];let Ce=le,et="flex flex-col gap-6",tt="lunora-queues-panel",B;e[22]!==a||e[23]!==l?(B=(0,t.jsxDEV)("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(c=>(0,t.jsxDEV)(V,{"aria-selected":l===c,"data-tab":c,"data-testid":`queues-tab-${c}`,onClick:Ze,role:"tab",size:"sm",type:"button",variant:l===c?"secondary":"ghost",children:ht(c,a)},c,!1))},void 0,!1),e[22]=a,e[23]=l,e[24]=B):B=e[24];let R;e[25]!==ge||e[26]!==ve?(R=ge!==null&&(0,t.jsxDEV)(Pe,{error:ve,testId:"queues-error"},void 0,!1),e[25]=ge,e[26]=ve,e[27]=R):R=e[27];let Qe=D&&(0,t.jsxDEV)(Ge,{icon:(0,t.jsxDEV)("span",{"aria-hidden":"true",className:"text-base leading-none",children:"\u26A0"},void 0,!1),testId:"queues-dlq-warning",variant:"warning",children:(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[Q.length>0&&(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)("p",{className:"font-medium",children:a("No dead-letter queue on {queues}.",{queues:Q.map(qt).join(", ")})},void 0,!1),(0,t.jsxDEV)("p",{className:"text-muted-foreground",children:a("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")},void 0,!1)]},void 0,!0),C>0&&(0,t.jsxDEV)("p",{className:Q.length>0?"text-muted-foreground":"font-medium",children:C===1?a("1 message was recently dead-lettered."):a("{count} messages were recently dead-lettered.",{count:C})},void 0,!1)]},void 0,!0)},void 0,!1),$;e[28]!==S||e[29]!==p||e[30]!==l?($=l==="declared"&&(0,t.jsxDEV)(pt,{loaded:p!==void 0,queues:S},void 0,!1),e[28]=S,e[29]=p,e[30]=l,e[31]=$):$=e[31];let O;e[32]!==A||e[33]!==v||e[34]!==Ce||e[35]!==Te||e[36]!==pe||e[37]!==l?(O=l==="messages"&&(0,t.jsxDEV)(vt,{hasError:v!==null,messages:A,onClear:Ce,onReplay:Te,replayingId:pe},void 0,!1),e[32]=A,e[33]=v,e[34]=Ce,e[35]=Te,e[36]=pe,e[37]=l,e[38]=O):O=e[38];let k;e[39]!==G||e[40]!==I||e[41]!==T||e[42]!==Ee||e[43]!==qe||e[44]!==Se||e[45]!==Ne||e[46]!==_e||e[47]!==S||e[48]!==H||e[49]!==he||e[50]!==l?(k=l==="send"&&(0,t.jsxDEV)(xt,{batchMode:G,bodyText:I,delayText:T,onBatchModeChange:Ee,onBodyChange:qe,onDelayChange:Se,onSelectExport:Ne,onSend:_e,queues:S,selectedExportName:H,sending:he},void 0,!1),e[39]=G,e[40]=I,e[41]=T,e[42]=Ee,e[43]=qe,e[44]=Se,e[45]=Ne,e[46]=_e,e[47]=S,e[48]=H,e[49]=he,e[50]=l,e[51]=k):k=e[51];let ne;return e[52]!==B||e[53]!==R||e[54]!==Qe||e[55]!==$||e[56]!==O||e[57]!==k?(ne=(0,t.jsxDEV)("div",{className:et,"data-testid":tt,children:[B,R,Qe,$,O,k]},void 0,!0),e[52]=B,e[53]=R,e[54]=Qe,e[55]=$,e[56]=O,e[57]=k,e[58]=ne):ne=e[58],ne},"QueuesPanel");function yt(o){return(0,t.jsxDEV)(j,{"data-testid":`queues-row-${o.exportName}`,children:[(0,t.jsxDEV)(_,{className:"font-mono text-xs",children:o.exportName},void 0,!1),(0,t.jsxDEV)(_,{className:"font-mono text-xs text-muted-foreground",children:o.name},void 0,!1),(0,t.jsxDEV)(_,{className:"font-mono text-xs text-muted-foreground",children:o.mode},void 0,!1),(0,t.jsxDEV)(_,{className:"font-mono text-xs text-muted-foreground",children:o.binding},void 0,!1),(0,t.jsxDEV)(_,{className:"font-mono text-xs text-muted-foreground",children:o.deadLetterQueue??"\u2014"},void 0,!1)]},o.exportName,!0)}f(yt,"_temp");function bt(o){return(0,t.jsxDEV)("option",{value:o.exportName,children:o.exportName},o.exportName,!1)}f(bt,"_temp2");function Nt(o,e){return o.exportName.localeCompare(e.exportName)}f(Nt,"_temp3");function qt(o){return o.name}f(qt,"_temp4");export{Ut as default};
@@ -1 +1 @@
1
- import{a as k}from"./chunk-WUFVFVHJ.js";import"./chunk-XNJNSCLM.js";import{b as h}from"./chunk-W666BB6V.js";import{a as C,b as w,c as I,d as u,e as o,f as n}from"./chunk-GTM65MVX.js";import{a as A,e as S}from"./chunk-SEU5V7I6.js";import{c as T}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{b as N}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as g}from"./chunk-BOXSWNXZ.js";import"./chunk-SDMZKBTD.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as E}from"./chunk-TAD43CG5.js";import{d as D,p as H}from"./chunk-ITQKVEP7.js";import"./chunk-22C6COGE.js";import{a as d,e as M,f as X,h as Y}from"./chunk-RRCPZMC2.js";var q=M(X(),1);var e=M(Y(),1);var G="agent_threads",Z="agent_messages",_=100,ee=250,te={},ae={filters:[],limit:_,offset:0,orderBy:{column:"updatedAt",direction:"desc"},skipCount:!0,table:G},l=d((r,t)=>{let a=r[t];return typeof a=="string"?a:void 0},"readString"),B=d((r,t)=>{let a=r[t];return typeof a=="number"?a:void 0},"readNumber"),P=d(r=>{let{usage:t}=r;if(t===null||typeof t!="object")return;let{totalTokens:a}=t;return typeof a=="number"?a:void 0},"readTotalTokens"),se=d(r=>{let{toolCalls:t}=r;return Array.isArray(t)?t.map(a=>a!==null&&typeof a=="object"?a.name:void 0).filter(a=>typeof a=="string"):[]},"readToolNames"),re=d(r=>{switch(r){case"awaiting_input":return"warning";case"cancelled":return"warning";case"error":return"destructive";case"running":return"info";default:return"outline"}},"threadStatusVariant"),oe=d(r=>{switch(r){case"approved":return"success";case"rejected":return"destructive";default:return"warning"}},"approvalVariant"),ge=d(({initialShardKey:r=""})=>{let t=D(),[a,R]=(0,q.useState)(void 0),{data:p}=h(g.listTables,te,{live:!0,shardKey:r}),U=p!==void 0,m=Array.isArray(p)&&p.some(s=>s.name===G),{data:$,error:V,errorSource:z,liveError:O}=h(g.readTablePage,ae,{enabled:m,live:!0,shardKey:r}),F={filters:[{column:"threadKey",operator:"eq",value:a??""}],limit:ee,offset:0,orderBy:{column:"seq",direction:"asc"},skipCount:!0,table:Z},{data:j,error:Q,errorSource:J}=h(g.readTablePage,F,{enabled:m&&a!==void 0,live:!0,shardKey:r}),x=Array.isArray($?.rows)?$.rows:[],K=Array.isArray(j?.rows)?j.rows:[],L=x.find(s=>l(s,"key")===a),f;return U&&!m?f=(0,e.jsxDEV)(E,{description:t("No @lunora/agent tables found in this deployment. Add lunora/agents.ts with defineAgent(...) and merge the agent schema extension to run durable AI agents."),testId:"agents-unconfigured",title:t("No agents configured")},void 0,!1):m&&x.length===0?f=(0,e.jsxDEV)(E,{description:t("No agent has run yet. Start a run with ctx.agents.<name>.run(...) and its thread appears here."),testId:"agents-empty",title:t("No agent threads yet")},void 0,!1):f=(0,e.jsxDEV)("div",{className:"flex flex-col gap-6",children:[(0,e.jsxDEV)(A,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(S,{className:"px-0",children:(0,e.jsxDEV)(C,{"data-testid":"agents-threads-table",children:[(0,e.jsxDEV)(w,{children:(0,e.jsxDEV)(u,{children:[(0,e.jsxDEV)(o,{children:t("Agent")},void 0,!1),(0,e.jsxDEV)(o,{children:t("Key")},void 0,!1),(0,e.jsxDEV)(o,{children:t("Status")},void 0,!1),(0,e.jsxDEV)(o,{children:t("Messages")},void 0,!1),(0,e.jsxDEV)(o,{children:t("Tokens")},void 0,!1),(0,e.jsxDEV)(o,{children:t("Updated")},void 0,!1),(0,e.jsxDEV)(o,{"aria-label":t("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(I,{children:x.map(s=>{let i=l(s,"key")??"",c=l(s,"status"),v=P(s);return(0,e.jsxDEV)(u,{"data-active":i===a?"":void 0,"data-testid":`agents-thread-${i}`,children:[(0,e.jsxDEV)(n,{className:"font-mono text-xs",children:l(s,"agent")??"\u2014"},void 0,!1),(0,e.jsxDEV)(n,{className:"font-mono text-xs text-muted-foreground",children:i},void 0,!1),(0,e.jsxDEV)(n,{children:(0,e.jsxDEV)(N,{"data-testid":`agents-thread-status-${i}`,variant:re(c),children:c??"\u2014"},void 0,!1)},void 0,!1),(0,e.jsxDEV)(n,{className:"tabular-nums",children:B(s,"messageCount")??"\u2014"},void 0,!1),(0,e.jsxDEV)(n,{className:"tabular-nums text-muted-foreground",children:v??"\u2014"},void 0,!1),(0,e.jsxDEV)(n,{className:"text-muted-foreground tabular-nums",children:H(B(s,"updatedAt"),"\u2014")},void 0,!1),(0,e.jsxDEV)(n,{className:"text-right",children:(0,e.jsxDEV)(T,{"data-testid":`agents-thread-open-${i}`,onClick:d(()=>{R(i)},"onClick"),size:"sm",type:"button",variant:"outline",children:t("Timeline")},void 0,!1)},void 0,!1)]},i,!0)})},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),Q!==null&&(0,e.jsxDEV)(k,{error:J,testId:"agents-messages-error"},void 0,!1),a!==void 0&&(0,e.jsxDEV)(A,{className:"overflow-hidden py-0","data-testid":"agents-thread-detail",children:(0,e.jsxDEV)(S,{className:"flex flex-col gap-3 px-4 py-3",children:[(0,e.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxDEV)("span",{className:"font-mono text-xs",children:[t("Timeline")," \xB7 ",a,L!==void 0&&(0,e.jsxDEV)("span",{className:"text-muted-foreground",children:[" \xB7 ",t("Usage"),": ",P(L)??0," ",t("Tokens")]},void 0,!0)]},void 0,!0),(0,e.jsxDEV)(T,{"data-testid":"agents-thread-detail-close",onClick:d(()=>{R(void 0)},"onClick"),size:"xs",type:"button",variant:"ghost",children:t("Close")},void 0,!1)]},void 0,!0),K.length===0?(0,e.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:t("This thread has no messages yet.")},void 0,!1):(0,e.jsxDEV)(C,{"data-testid":"agents-messages-table",children:[(0,e.jsxDEV)(w,{children:(0,e.jsxDEV)(u,{children:[(0,e.jsxDEV)(o,{children:t("Role")},void 0,!1),(0,e.jsxDEV)(o,{children:t("Content")},void 0,!1),(0,e.jsxDEV)(o,{children:t("Tool")},void 0,!1),(0,e.jsxDEV)(o,{children:t("Approval")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(I,{children:K.map((s,i)=>{let c=l(s,"role")??"\u2014",v=se(s),W=l(s,"toolName"),y=l(s,"status"),b=B(s,"seq")??i;return(0,e.jsxDEV)(u,{"data-testid":`agents-message-${String(b)}`,children:[(0,e.jsxDEV)(n,{className:"font-mono text-xs align-top text-muted-foreground",children:c},void 0,!1),(0,e.jsxDEV)(n,{className:"max-w-md font-mono text-xs whitespace-pre-wrap break-words",children:l(s,"content")??"\u2014"},void 0,!1),(0,e.jsxDEV)(n,{className:"font-mono text-xs align-top text-muted-foreground",children:W??(v.length>0?v.join(", "):"\u2014")},void 0,!1),(0,e.jsxDEV)(n,{className:"align-top",children:y===void 0?(0,e.jsxDEV)("span",{className:"text-xs text-muted-foreground",children:"\u2014"},void 0,!1):(0,e.jsxDEV)(N,{"data-testid":`agents-message-approval-${String(b)}`,variant:oe(y),children:y},void 0,!1)},void 0,!1)]},l(s,"messageKey")??`${c}:${String(b)}`,!0)})},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-6","data-testid":"lunora-agents-panel",children:[V!==null&&(0,e.jsxDEV)(k,{error:z,testId:"agents-error"},void 0,!1),(0,e.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:t("Agents run as durable workflows. Each run persists a thread of assistant and tool messages; select a thread to inspect its timeline, tool calls, approvals, and token usage.")},void 0,!1),O!==void 0&&(0,e.jsxDEV)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"agents-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")},void 0,!1),f]},void 0,!0)},"AgentsPanel");export{ge as AgentsPanel};
1
+ import{a as k}from"./chunk-WUFVFVHJ.js";import"./chunk-XNJNSCLM.js";import{b as h}from"./chunk-W666BB6V.js";import{a as C,b as w,c as I,d as u,e as o,f as n}from"./chunk-GTM65MVX.js";import{a as A,e as S}from"./chunk-SEU5V7I6.js";import{c as T}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{b as N}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as g}from"./chunk-G7ZBM54M.js";import"./chunk-SDMZKBTD.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as E}from"./chunk-TAD43CG5.js";import{d as D,p as H}from"./chunk-ITQKVEP7.js";import"./chunk-22C6COGE.js";import{a as d,e as M,f as X,h as Y}from"./chunk-RRCPZMC2.js";var q=M(X(),1);var e=M(Y(),1);var G="agent_threads",Z="agent_messages",_=100,ee=250,te={},ae={filters:[],limit:_,offset:0,orderBy:{column:"updatedAt",direction:"desc"},skipCount:!0,table:G},l=d((r,t)=>{let a=r[t];return typeof a=="string"?a:void 0},"readString"),B=d((r,t)=>{let a=r[t];return typeof a=="number"?a:void 0},"readNumber"),P=d(r=>{let{usage:t}=r;if(t===null||typeof t!="object")return;let{totalTokens:a}=t;return typeof a=="number"?a:void 0},"readTotalTokens"),se=d(r=>{let{toolCalls:t}=r;return Array.isArray(t)?t.map(a=>a!==null&&typeof a=="object"?a.name:void 0).filter(a=>typeof a=="string"):[]},"readToolNames"),re=d(r=>{switch(r){case"awaiting_input":return"warning";case"cancelled":return"warning";case"error":return"destructive";case"running":return"info";default:return"outline"}},"threadStatusVariant"),oe=d(r=>{switch(r){case"approved":return"success";case"rejected":return"destructive";default:return"warning"}},"approvalVariant"),ge=d(({initialShardKey:r=""})=>{let t=D(),[a,R]=(0,q.useState)(void 0),{data:p}=h(g.listTables,te,{live:!0,shardKey:r}),U=p!==void 0,m=Array.isArray(p)&&p.some(s=>s.name===G),{data:$,error:V,errorSource:z,liveError:O}=h(g.readTablePage,ae,{enabled:m,live:!0,shardKey:r}),F={filters:[{column:"threadKey",operator:"eq",value:a??""}],limit:ee,offset:0,orderBy:{column:"seq",direction:"asc"},skipCount:!0,table:Z},{data:j,error:Q,errorSource:J}=h(g.readTablePage,F,{enabled:m&&a!==void 0,live:!0,shardKey:r}),x=Array.isArray($?.rows)?$.rows:[],K=Array.isArray(j?.rows)?j.rows:[],L=x.find(s=>l(s,"key")===a),f;return U&&!m?f=(0,e.jsxDEV)(E,{description:t("No @lunora/agent tables found in this deployment. Add lunora/agents.ts with defineAgent(...) and merge the agent schema extension to run durable AI agents."),testId:"agents-unconfigured",title:t("No agents configured")},void 0,!1):m&&x.length===0?f=(0,e.jsxDEV)(E,{description:t("No agent has run yet. Start a run with ctx.agents.<name>.run(...) and its thread appears here."),testId:"agents-empty",title:t("No agent threads yet")},void 0,!1):f=(0,e.jsxDEV)("div",{className:"flex flex-col gap-6",children:[(0,e.jsxDEV)(A,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(S,{className:"px-0",children:(0,e.jsxDEV)(C,{"data-testid":"agents-threads-table",children:[(0,e.jsxDEV)(w,{children:(0,e.jsxDEV)(u,{children:[(0,e.jsxDEV)(o,{children:t("Agent")},void 0,!1),(0,e.jsxDEV)(o,{children:t("Key")},void 0,!1),(0,e.jsxDEV)(o,{children:t("Status")},void 0,!1),(0,e.jsxDEV)(o,{children:t("Messages")},void 0,!1),(0,e.jsxDEV)(o,{children:t("Tokens")},void 0,!1),(0,e.jsxDEV)(o,{children:t("Updated")},void 0,!1),(0,e.jsxDEV)(o,{"aria-label":t("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(I,{children:x.map(s=>{let i=l(s,"key")??"",c=l(s,"status"),v=P(s);return(0,e.jsxDEV)(u,{"data-active":i===a?"":void 0,"data-testid":`agents-thread-${i}`,children:[(0,e.jsxDEV)(n,{className:"font-mono text-xs",children:l(s,"agent")??"\u2014"},void 0,!1),(0,e.jsxDEV)(n,{className:"font-mono text-xs text-muted-foreground",children:i},void 0,!1),(0,e.jsxDEV)(n,{children:(0,e.jsxDEV)(N,{"data-testid":`agents-thread-status-${i}`,variant:re(c),children:c??"\u2014"},void 0,!1)},void 0,!1),(0,e.jsxDEV)(n,{className:"tabular-nums",children:B(s,"messageCount")??"\u2014"},void 0,!1),(0,e.jsxDEV)(n,{className:"tabular-nums text-muted-foreground",children:v??"\u2014"},void 0,!1),(0,e.jsxDEV)(n,{className:"text-muted-foreground tabular-nums",children:H(B(s,"updatedAt"),"\u2014")},void 0,!1),(0,e.jsxDEV)(n,{className:"text-right",children:(0,e.jsxDEV)(T,{"data-testid":`agents-thread-open-${i}`,onClick:d(()=>{R(i)},"onClick"),size:"sm",type:"button",variant:"outline",children:t("Timeline")},void 0,!1)},void 0,!1)]},i,!0)})},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),Q!==null&&(0,e.jsxDEV)(k,{error:J,testId:"agents-messages-error"},void 0,!1),a!==void 0&&(0,e.jsxDEV)(A,{className:"overflow-hidden py-0","data-testid":"agents-thread-detail",children:(0,e.jsxDEV)(S,{className:"flex flex-col gap-3 px-4 py-3",children:[(0,e.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxDEV)("span",{className:"font-mono text-xs",children:[t("Timeline")," \xB7 ",a,L!==void 0&&(0,e.jsxDEV)("span",{className:"text-muted-foreground",children:[" \xB7 ",t("Usage"),": ",P(L)??0," ",t("Tokens")]},void 0,!0)]},void 0,!0),(0,e.jsxDEV)(T,{"data-testid":"agents-thread-detail-close",onClick:d(()=>{R(void 0)},"onClick"),size:"xs",type:"button",variant:"ghost",children:t("Close")},void 0,!1)]},void 0,!0),K.length===0?(0,e.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:t("This thread has no messages yet.")},void 0,!1):(0,e.jsxDEV)(C,{"data-testid":"agents-messages-table",children:[(0,e.jsxDEV)(w,{children:(0,e.jsxDEV)(u,{children:[(0,e.jsxDEV)(o,{children:t("Role")},void 0,!1),(0,e.jsxDEV)(o,{children:t("Content")},void 0,!1),(0,e.jsxDEV)(o,{children:t("Tool")},void 0,!1),(0,e.jsxDEV)(o,{children:t("Approval")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(I,{children:K.map((s,i)=>{let c=l(s,"role")??"\u2014",v=se(s),W=l(s,"toolName"),y=l(s,"status"),b=B(s,"seq")??i;return(0,e.jsxDEV)(u,{"data-testid":`agents-message-${String(b)}`,children:[(0,e.jsxDEV)(n,{className:"font-mono text-xs align-top text-muted-foreground",children:c},void 0,!1),(0,e.jsxDEV)(n,{className:"max-w-md font-mono text-xs whitespace-pre-wrap break-words",children:l(s,"content")??"\u2014"},void 0,!1),(0,e.jsxDEV)(n,{className:"font-mono text-xs align-top text-muted-foreground",children:W??(v.length>0?v.join(", "):"\u2014")},void 0,!1),(0,e.jsxDEV)(n,{className:"align-top",children:y===void 0?(0,e.jsxDEV)("span",{className:"text-xs text-muted-foreground",children:"\u2014"},void 0,!1):(0,e.jsxDEV)(N,{"data-testid":`agents-message-approval-${String(b)}`,variant:oe(y),children:y},void 0,!1)},void 0,!1)]},l(s,"messageKey")??`${c}:${String(b)}`,!0)})},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-6","data-testid":"lunora-agents-panel",children:[V!==null&&(0,e.jsxDEV)(k,{error:z,testId:"agents-error"},void 0,!1),(0,e.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:t("Agents run as durable workflows. Each run persists a thread of assistant and tool messages; select a thread to inspect its timeline, tool calls, approvals, and token usage.")},void 0,!1),O!==void 0&&(0,e.jsxDEV)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"agents-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")},void 0,!1),f]},void 0,!0)},"AgentsPanel");export{ge as AgentsPanel};
@@ -1 +1 @@
1
- import{b as f}from"./chunk-MDTNVR3G.js";import"./chunk-WUFVFVHJ.js";import"./chunk-XNJNSCLM.js";import{b as p}from"./chunk-W666BB6V.js";import"./chunk-GTM65MVX.js";import"./chunk-SEU5V7I6.js";import{a as R}from"./chunk-BOXSWNXZ.js";import"./chunk-SDMZKBTD.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as h}from"./chunk-ITQKVEP7.js";import"./chunk-22C6COGE.js";import{a as i,e as m,g as S,h as A}from"./chunk-RRCPZMC2.js";var g=m(S(),1);var k=m(A(),1);var _=i((e,s)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("Live admin subscriptions are ungated")})[s.kind],"findingTitle"),E=i(e=>Array.isArray(e.findings)?e.findings:[],"toFindings"),w=i(e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],"findingEntity"),T=i((e,s)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters \u2014 use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:s.detail?.length,min:s.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed \u2014 browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: live admin subscriptions need no credential. Set it to gate them like the HTTP admin RPCs.")})[s.kind],"findingDetail"),v=i(()=>{let e=(0,g.c)(8),s=h(),r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},e[0]=r):r=e[0];let{data:a,error:d,errorSource:c}=p(R.getSecurityAudit,r),o;if(e[1]!==a||e[2]!==s){let u=a===void 0?null:E(a);o=u===null?null:u.map(t=>({description:T(s,t),entity:w(t),issueType:_(s,t),key:t.kind,level:t.level})),e[1]=a,e[2]=s,e[3]=o}else o=e[3];let l=o,n;return e[4]!==d||e[5]!==c||e[6]!==l?(n=(0,k.jsxDEV)(f,{error:d,errorSource:c,rows:l,testId:"lunora-security-advisor"},void 0,!1),e[4]=d,e[5]=c,e[6]=l,e[7]=n):n=e[7],n},"SecurityAdvisorPanel");export{v as default};
1
+ import{b as f}from"./chunk-MDTNVR3G.js";import"./chunk-WUFVFVHJ.js";import"./chunk-XNJNSCLM.js";import{b as p}from"./chunk-W666BB6V.js";import"./chunk-GTM65MVX.js";import"./chunk-SEU5V7I6.js";import{a as R}from"./chunk-G7ZBM54M.js";import"./chunk-SDMZKBTD.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as h}from"./chunk-ITQKVEP7.js";import"./chunk-22C6COGE.js";import{a as i,e as m,g as S,h as A}from"./chunk-RRCPZMC2.js";var g=m(S(),1);var k=m(A(),1);var _=i((e,s)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("Live admin subscriptions are ungated")})[s.kind],"findingTitle"),E=i(e=>Array.isArray(e.findings)?e.findings:[],"toFindings"),w=i(e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],"findingEntity"),T=i((e,s)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters \u2014 use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:s.detail?.length,min:s.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed \u2014 browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: live admin subscriptions need no credential. Set it to gate them like the HTTP admin RPCs.")})[s.kind],"findingDetail"),v=i(()=>{let e=(0,g.c)(8),s=h(),r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},e[0]=r):r=e[0];let{data:a,error:d,errorSource:c}=p(R.getSecurityAudit,r),o;if(e[1]!==a||e[2]!==s){let u=a===void 0?null:E(a);o=u===null?null:u.map(t=>({description:T(s,t),entity:w(t),issueType:_(s,t),key:t.kind,level:t.level})),e[1]=a,e[2]=s,e[3]=o}else o=e[3];let l=o,n;return e[4]!==d||e[5]!==c||e[6]!==l?(n=(0,k.jsxDEV)(f,{error:d,errorSource:c,rows:l,testId:"lunora-security-advisor"},void 0,!1),e[4]=d,e[5]=c,e[6]=l,e[7]=n):n=e[7],n},"SecurityAdvisorPanel");export{v as default};