@lunora/studio 1.0.0-alpha.63 → 1.0.0-alpha.64

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 (60) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/packem_chunks/MetricsPanel.js +1 -1
  3. package/dist/packem_chunks/issues-panel.js +1 -1
  4. package/dist/packem_chunks/payments-panel.js +1 -1
  5. package/dist/standalone/{chunk-SM67QXQI.js → chunk-2F7G7IWQ.js} +1 -1
  6. package/dist/standalone/chunk-34UVAASH.js +1 -0
  7. package/dist/standalone/chunk-35II7U25.js +11 -0
  8. package/dist/standalone/{chunk-UVDPQU7J.js → chunk-3FUFEZ65.js} +1 -1
  9. package/dist/standalone/{chunk-VSS7NFZJ.js → chunk-3QRTYSSX.js} +1 -1
  10. package/dist/standalone/{chunk-PZPFWABF.js → chunk-4WLYA3XE.js} +1 -1
  11. package/dist/standalone/{chunk-TDE4AR5O.js → chunk-5OWIOACV.js} +1 -1
  12. package/dist/standalone/{chunk-ZSWWTXVW.js → chunk-5U2THBI7.js} +1 -1
  13. package/dist/standalone/{chunk-DY7CLL2H.js → chunk-65OTWFS3.js} +1 -1
  14. package/dist/standalone/chunk-6DWCIIHE.js +1 -0
  15. package/dist/standalone/{chunk-IJFCOWEQ.js → chunk-7J5N6DGQ.js} +1 -1
  16. package/dist/standalone/{chunk-M7QCL3ZP.js → chunk-B43FTQJ7.js} +1 -1
  17. package/dist/standalone/{chunk-TCQEDMAQ.js → chunk-BNUJ7QMG.js} +1 -1
  18. package/dist/standalone/{chunk-RLEENOIX.js → chunk-C43X4M5U.js} +1 -1
  19. package/dist/standalone/{chunk-JGY4NGFW.js → chunk-D7XXWV4E.js} +1 -1
  20. package/dist/standalone/{chunk-4MSKCWUL.js → chunk-DVOBKIUX.js} +1 -1
  21. package/dist/standalone/{chunk-K7M4SMQ7.js → chunk-EKRN4ZQM.js} +1 -1
  22. package/dist/standalone/{chunk-IGBEXNXY.js → chunk-EVN46TVV.js} +1 -1
  23. package/dist/standalone/{chunk-NPIULIRO.js → chunk-EXFBIISG.js} +1 -1
  24. package/dist/standalone/{chunk-OZGWNJXD.js → chunk-F5QWLENA.js} +1 -1
  25. package/dist/standalone/chunk-F6GOKFMU.js +3 -0
  26. package/dist/standalone/{chunk-PYXZLNG2.js → chunk-FGTK44LR.js} +1 -1
  27. package/dist/standalone/{chunk-XBGJVK32.js → chunk-GSPTEMYN.js} +1 -1
  28. package/dist/standalone/{chunk-XITDHIVL.js → chunk-HP2UCWND.js} +1 -1
  29. package/dist/standalone/{chunk-WQTUQZUM.js → chunk-IDNNI63H.js} +1 -1
  30. package/dist/standalone/{chunk-ZKEVSU66.js → chunk-KDOC2DP5.js} +1 -1
  31. package/dist/standalone/{chunk-P4J3Z3SA.js → chunk-L7N7F3DA.js} +1 -1
  32. package/dist/standalone/{chunk-IPHXIGYP.js → chunk-LJDP7NRB.js} +1 -1
  33. package/dist/standalone/{chunk-GBQHGYGH.js → chunk-OHKRN65U.js} +1 -1
  34. package/dist/standalone/{chunk-LA3HEESS.js → chunk-P24JBHEZ.js} +1 -1
  35. package/dist/standalone/chunk-PWWHP76O.js +1 -0
  36. package/dist/standalone/{chunk-IUW24D4X.js → chunk-QGKAJTQQ.js} +1 -1
  37. package/dist/standalone/{chunk-AX4PAEGP.js → chunk-QVEHPYA5.js} +1 -1
  38. package/dist/standalone/{chunk-7YAUSG6S.js → chunk-QWJ3NPE3.js} +1 -1
  39. package/dist/standalone/{chunk-H3V2QQ4K.js → chunk-RAA2RGG6.js} +1 -1
  40. package/dist/standalone/chunk-RBU52M5T.js +1 -0
  41. package/dist/standalone/{chunk-RWZKO2P6.js → chunk-SA3MDZC3.js} +1 -1
  42. package/dist/standalone/{chunk-66TS6K5F.js → chunk-T2JIUFOD.js} +1 -1
  43. package/dist/standalone/chunk-TJ2WZ5OP.js +1 -0
  44. package/dist/standalone/{chunk-37RIZFJ4.js → chunk-TLHJRWNK.js} +1 -1
  45. package/dist/standalone/{chunk-YQP2EYOC.js → chunk-UIS34ZPB.js} +1 -1
  46. package/dist/standalone/{chunk-P4DHFWH7.js → chunk-VPAXCQ2Y.js} +1 -1
  47. package/dist/standalone/{chunk-V4RWA7QI.js → chunk-XEDU5FO4.js} +1 -1
  48. package/dist/standalone/{chunk-M2B3MDFJ.js → chunk-XQBTNJUQ.js} +1 -1
  49. package/dist/standalone/{chunk-OWADN6BI.js → chunk-XSD4Y6SQ.js} +1 -1
  50. package/dist/standalone/{chunk-BY4QROKU.js → chunk-YD5NF6UT.js} +1 -1
  51. package/dist/standalone/{chunk-DCJKCERP.js → chunk-YI3WYUXK.js} +1 -1
  52. package/dist/standalone/{chunk-26TQSVUV.js → chunk-ZNNAGR6N.js} +1 -1
  53. package/dist/standalone/studio.js +1 -1
  54. package/package.json +4 -4
  55. package/dist/standalone/chunk-3NHORZCK.js +0 -1
  56. package/dist/standalone/chunk-B5E7GQHG.js +0 -1
  57. package/dist/standalone/chunk-F6LUZVVI.js +0 -1
  58. package/dist/standalone/chunk-GHUPW2Y5.js +0 -1
  59. package/dist/standalone/chunk-LWECXQWP.js +0 -11
  60. package/dist/standalone/chunk-TRHTFGFW.js +0 -3
@@ -1 +1 @@
1
- import{a as U}from"./chunk-54MMVNPT.js";import{a as Q}from"./chunk-7LQWFOEU.js";import{a as E}from"./chunk-OWADN6BI.js";import{a as K,b as V,c as z,d as F,e as v,f as b}from"./chunk-MIQTKZAR.js";import{a as D,e as P}from"./chunk-UZERI5YC.js";import{c as te}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as ee}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{f as T}from"./chunk-LWECXQWP.js";import"./chunk-XBDKZZ67.js";import{a as _}from"./chunk-XQCVZAGU.js";import{d as B,h as O,m as W,q as Z}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as m,e as R,f as oe,g as ae,h as le}from"./chunk-3XIESWL4.js";var Y=R(ae(),1),G=R(oe(),1);var t=R(le(),1);var ne=R(ae(),1);var X=R(oe(),1);var c=R(le(),1);var ie=m(a=>Number.isFinite(a)?Z(a,"\u2014"):"\u2014","Y"),se=m(a=>a.toSorted((e,h)=>e.scheduledFor-h.scheduledFor),"T"),de=m(a=>{let e=(0,ne.c)(33),h;e[0]!==a?(h=a===void 0?{}:a,e[0]=a,e[1]=h):h=e[1];let{cancelJob:i,loadJobs:p}=h,l=T(),o=B(),r=p===void 0,y;e[2]===Symbol.for("react.memo_cache_sentinel")?(y=["lunora-scheduled-jobs"],e[2]=y):y=e[2];let f;e[3]!==l||e[4]!==p?(f=m(async()=>{let d=await(p??(()=>l.listScheduledJobs()))();return se(d)},"j"),e[3]=l,e[4]=p,e[5]=f):f=e[5];let n=E(y,f),[s,u]=(0,X.useState)(void 0),[J,j]=(0,X.useState)(void 0),x,C;e[6]!==l||e[7]!==r?(x=m(()=>{if(r)return l.subscribeScheduledJobs(d=>{j(void 0),u(se(d))})},"N"),C=[r,l],e[6]=l,e[7]=r,e[8]=x,e[9]=C):(x=e[8],C=e[9]),(0,X.useEffect)(x,C);let g;e[10]!==n?(g=m(()=>{n.refetch()},"$"),e[10]=n,e[11]=g):g=e[11],U(g,!r);let S;e:{if(i!==void 0){S=i;break e}let d;e[12]!==l||e[13]!==p?(d=p===void 0?H=>l.cancelScheduledJob(H):void 0,e[12]=l,e[13]=p,e[14]=d):d=e[14],S=d}let k=S,w=s??n.data,$=J??n.error,q;e[15]!==k||e[16]!==n||e[17]!==r?(q=m(async d=>{if(k!==void 0){j(void 0);try{await k(d),r||n.refetch()}catch(H){j(O(H))}}},"S"),e[15]=k,e[16]=n,e[17]=r,e[18]=q):q=e[18];let I=q,L;e[19]!==$?(L=$!==null&&(0,c.jsx)("p",{className:"text-sm text-destructive","data-testid":"sj-error",role:"alert",children:$}),e[19]=$,e[20]=L):L=e[20];let N;e[21]!==w?.length||e[22]!==o?(N=w?.length===0&&(0,c.jsx)(_,{description:o("Jobs queued with runAfter / runAt will appear here."),icon:(0,c.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,c.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,c.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"sj-empty",title:o("No scheduled jobs.")}),e[21]=w?.length,e[22]=o,e[23]=N):N=e[23];let M;e[24]!==I||e[25]!==k||e[26]!==w||e[27]!==o?(M=w!==void 0&&w.length>0&&(0,c.jsx)(D,{className:"overflow-hidden py-0",children:(0,c.jsx)(P,{className:"px-0",children:(0,c.jsxs)(K,{"data-testid":"sj-table",children:[(0,c.jsx)(V,{children:(0,c.jsxs)(F,{children:[(0,c.jsx)(v,{children:o("function")}),(0,c.jsx)(v,{children:o("scheduled for")}),(0,c.jsx)(v,{children:o("pool")}),(0,c.jsx)(v,{children:o("attempts")}),(0,c.jsx)(v,{children:o("shard")}),(0,c.jsx)(v,{children:o("id")}),k!==void 0&&(0,c.jsx)(v,{"aria-label":o("Actions")})]})}),(0,c.jsx)(z,{children:w.map(d=>(0,c.jsxs)(F,{"data-testid":`sj-row-${d.id}`,children:[(0,c.jsx)(b,{className:"font-mono text-xs",children:d.functionPath}),(0,c.jsx)(b,{className:"text-muted-foreground tabular-nums",children:ie(d.scheduledFor)}),(0,c.jsx)(b,{className:"font-mono text-xs",children:d.pool??""}),(0,c.jsx)(b,{className:"tabular-nums",children:d.attempts??0}),(0,c.jsx)(b,{children:d.shardKey??""}),(0,c.jsx)(b,{className:"font-mono text-xs",children:d.id}),k!==void 0&&(0,c.jsx)(b,{className:"text-right",children:(0,c.jsx)(Q,{confirmLabel:o("Cancel job?"),onConfirm:m(()=>{W(I(d.id))},"onConfirm"),testId:`sj-cancel-${d.id}`,children:o("Cancel")})})]},d.id))})]})})}),e[24]=I,e[25]=k,e[26]=w,e[27]=o,e[28]=M):M=e[28];let A;return e[29]!==N||e[30]!==M||e[31]!==L?(A=(0,c.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduled-jobs",children:[L,N,M]}),e[29]=N,e[30]=M,e[31]=L,e[32]=A):A=e[32],A},"he");var ce={kind:"idle"},he=m(({loadCronJobs:a,runCronJob:e}={})=>{let h=T(),i=B(),[p,l]=(0,G.useState)({}),o=E(["lunora-cron-jobs",a?"custom":"default"],()=>(a??(()=>h.getCronJobs()))()),{data:r,error:y}=o,f=(0,G.useMemo)(()=>e!==void 0?e:a===void 0?s=>h.runCronJob(s):void 0,[h,a,e]),n=m(async s=>{if(f!==void 0){l(u=>({...u,[s]:{kind:"running"}}));try{await f(s),l(u=>({...u,[s]:{kind:"ok"}})),o.refetch()}catch(u){l(J=>({...J,[s]:{kind:"error",message:O(u)}}))}}},"d");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:y}),r?.length===0&&(0,t.jsx)(_,{description:i("Triggers declared with the cronJobs() builder appear here."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,t.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:i("No cron triggers.")}),r!==void 0&&r.length>0&&(0,t.jsx)(D,{className:"overflow-hidden py-0",children:(0,t.jsx)(P,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"cron-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(v,{children:i("name")}),(0,t.jsx)(v,{children:i("schedule")}),(0,t.jsx)(v,{children:i("target")}),(0,t.jsx)(v,{children:i("shard")}),f!==void 0&&(0,t.jsx)(v,{"aria-label":i("Actions")})]})}),(0,t.jsx)(z,{children:r.map(s=>{let u=p[s.name]??ce;return(0,t.jsxs)(F,{"data-testid":`cron-row-${s.name}`,children:[(0,t.jsx)(b,{children:s.name}),(0,t.jsx)(b,{className:"font-mono text-xs tabular-nums",children:s.cron}),(0,t.jsx)(b,{children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[s.workflow===void 0?(0,t.jsx)(ee,{variant:"outline",children:i("function")}):(0,t.jsx)(ee,{variant:"secondary",children:i("workflow")}),(0,t.jsx)("span",{className:"font-mono text-xs",children:s.workflow??s.functionPath})]})}),(0,t.jsx)(b,{children:s.shardKey??""}),f!==void 0&&(0,t.jsx)(b,{className:"text-right",children:(0,t.jsxs)("span",{className:"flex items-center justify-end gap-2",children:[u.kind==="ok"&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${s.name}`,children:i("ran")}),u.kind==="error"&&(0,t.jsx)("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${s.name}`,role:"alert",children:u.message}),(0,t.jsx)(Q,{confirmLabel:i("Run now?"),disabled:u.kind==="running",onConfirm:m(()=>{W(n(s.name))},"onConfirm"),testId:`cron-run-${s.name}`,children:u.kind==="running"?i("Running\u2026"):i("Run now")})]})})]},`${s.cron}:${s.name}`)})})]})})})]})},"le"),me=m(a=>Number.isFinite(a)?Z(a,"\u2014"):"\u2014","re"),ue=m(a=>{let e=(0,Y.c)(34),h;e[0]!==a?(h=a===void 0?{}:a,e[0]=a,e[1]=h):h=e[1];let{loadJobs:i,removeJob:p,retryJob:l}=h,o=T(),r=B(),y;e[2]===Symbol.for("react.memo_cache_sentinel")?(y=["lunora-dead-jobs"],e[2]=y):y=e[2];let f;e[3]!==o||e[4]!==i?(f=m(async()=>(await(i??(()=>o.listDeadJobs()))()).toSorted(fe),"h"),e[3]=o,e[4]=i,e[5]=f):f=e[5];let n=E(y,f),s=n.data,[u,J]=(0,G.useState)(void 0),j=n.error??u,x=i===void 0,C;e[6]!==o||e[7]!==x||e[8]!==l?(C=l??(x?d=>o.retryDeadJob(d):void 0),e[6]=o,e[7]=x,e[8]=l,e[9]=C):C=e[9];let g=C,S;e[10]!==o||e[11]!==x||e[12]!==p?(S=p??(x?d=>o.removeDeadJob(d):void 0),e[10]=o,e[11]=x,e[12]=p,e[13]=S):S=e[13];let k=S,w;e[14]!==n?(w=m(()=>{n.refetch()},"J"),e[14]=n,e[15]=w):w=e[15],U(w,!0);let $;e[16]!==n?($=m(async d=>{J(void 0);try{await d,n.refetch()}catch(H){J(O(H))}},"j"),e[16]=n,e[17]=$):$=e[17];let q=$,I=g!==void 0||k!==void 0,L;e[18]!==j?(L=j!==void 0&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:j}),e[18]=j,e[19]=L):L=e[19];let N;e[20]!==s?.length||e[21]!==r?(N=s?.length===0&&(0,t.jsx)(_,{description:r("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:r("No dead-letter jobs.")}),e[20]=s?.length,e[21]=r,e[22]=N):N=e[22];let M;e[23]!==q||e[24]!==I||e[25]!==s||e[26]!==k||e[27]!==g||e[28]!==r?(M=s!==void 0&&s.length>0&&(0,t.jsx)(D,{className:"overflow-hidden py-0",children:(0,t.jsx)(P,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"dlq-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(v,{children:r("function")}),(0,t.jsx)(v,{children:r("attempts")}),(0,t.jsx)(v,{children:r("last tried")}),(0,t.jsx)(v,{children:r("pool")}),(0,t.jsx)(v,{children:r("shard")}),(0,t.jsx)(v,{children:r("id")}),I&&(0,t.jsx)(v,{"aria-label":r("Actions")})]})}),(0,t.jsx)(z,{children:s.map(d=>(0,t.jsxs)(F,{"data-testid":`dlq-row-${d.id}`,children:[(0,t.jsx)(b,{className:"font-mono text-xs",children:d.functionPath}),(0,t.jsx)(b,{className:"tabular-nums",children:d.attempts??0}),(0,t.jsx)(b,{className:"text-muted-foreground tabular-nums",children:me(d.scheduledFor)}),(0,t.jsx)(b,{className:"font-mono text-xs",children:d.pool??""}),(0,t.jsx)(b,{children:d.shardKey??""}),(0,t.jsx)(b,{className:"font-mono text-xs",children:d.id}),I&&(0,t.jsx)(b,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1.5",children:[g!==void 0&&(0,t.jsx)(te,{"data-testid":`dlq-retry-${d.id}`,onClick:m(()=>{W(q(g(d.id)))},"onClick"),size:"sm",type:"button",variant:"outline",children:r("Retry")}),k!==void 0&&(0,t.jsx)(Q,{confirmLabel:r("Drop job?"),onConfirm:m(()=>{W(q(k(d.id)))},"onConfirm"),testId:`dlq-remove-${d.id}`,children:r("Drop")})]})})]},d.id))})]})})}),e[23]=q,e[24]=I,e[25]=s,e[26]=k,e[27]=g,e[28]=r,e[29]=M):M=e[29];let A;return e[30]!==M||e[31]!==L||e[32]!==N?(A=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[L,N,M]}),e[30]=M,e[31]=L,e[32]=N,e[33]=A):A=e[33],A},"ne");function fe(a,e){return(e.attempts??0)-(a.attempts??0)}m(fe,"ae");var re=m(a=>{let e=(0,Y.c)(8),{label:h,testId:i,value:p}=a,l;e[0]!==h?(l=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:h}),e[0]=h,e[1]=l):l=e[1];let o;e[2]!==i||e[3]!==p?(o=(0,t.jsx)("span",{className:"text-2xl font-semibold tabular-nums","data-testid":i,children:p}),e[2]=i,e[3]=p,e[4]=o):o=e[4];let r;return e[5]!==l||e[6]!==o?(r=(0,t.jsx)(D,{className:"flex-1 py-0",children:(0,t.jsxs)(P,{className:"flex flex-col gap-1 p-4",children:[l,o]})}),e[5]=l,e[6]=o,e[7]=r):r=e[7],r},"F"),pe=m(a=>{let e=(0,Y.c)(25),h;e[0]!==a?(h=a===void 0?{}:a,e[0]=a,e[1]=h):h=e[1];let{loadStatus:i}=h,p=T(),l=B(),o=i===void 0,r;e[2]!==o?(r=["lunora-scheduler-status",o],e[2]=o,e[3]=r):r=e[3];let y;e[4]!==p||e[5]!==i?(y=m(async()=>{let S=await(i??(()=>p.schedulerStatus()))();return{...S,pools:S.pools.toSorted(ve)}},"k"),e[4]=p,e[5]=i,e[6]=y):y=e[6];let f=E(r,y),{data:n,error:s}=f,u;e[7]!==f?(u=m(()=>{f.refetch()},"s"),e[7]=f,e[8]=u):u=e[8],U(u,!0);let J;e[9]!==s?(J=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:s}),e[9]=s,e[10]=J):J=e[10];let j;e[11]!==n||e[12]!==l?(j=n!==void 0&&(0,t.jsxs)("div",{className:"flex gap-3","data-testid":"pools-totals",children:[(0,t.jsx)(re,{label:l("backlog"),testId:"pools-backlog",value:n.backlog}),(0,t.jsx)(re,{label:l("in flight"),testId:"pools-inflight",value:n.inFlight}),(0,t.jsx)(re,{label:l("pools"),testId:"pools-count",value:n.pools.length})]}),e[11]=n,e[12]=l,e[13]=j):j=e[13];let x;e[14]!==n?.pools.length||e[15]!==l?(x=n?.pools.length===0&&(0,t.jsx)(_,{description:l("Pools created with createWorkpool appear here once they have activity."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:l("No workpools.")}),e[14]=n?.pools.length,e[15]=l,e[16]=x):x=e[16];let C;e[17]!==n||e[18]!==l?(C=n!==void 0&&n.pools.length>0&&(0,t.jsx)(D,{className:"overflow-hidden py-0",children:(0,t.jsx)(P,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"pools-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(v,{children:l("pool")}),(0,t.jsx)(v,{children:l("queued")}),(0,t.jsx)(v,{children:l("in flight")}),(0,t.jsx)(v,{children:l("max concurrency")})]})}),(0,t.jsx)(z,{children:n.pools.map(be)})]})})}),e[17]=n,e[18]=l,e[19]=C):C=e[19];let g;return e[20]!==J||e[21]!==j||e[22]!==x||e[23]!==C?(g=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[J,j,x,C]}),e[20]=J,e[21]=j,e[22]=x,e[23]=C,e[24]=g):g=e[24],g},"de");function ve(a,e){return e.queued-a.queued}m(ve,"ie");function be(a){return(0,t.jsxs)(F,{"data-testid":`pools-row-${a.name}`,children:[(0,t.jsx)(b,{className:"font-mono text-xs",children:a.name}),(0,t.jsx)(b,{className:"tabular-nums",children:a.queued}),(0,t.jsxs)(b,{className:"tabular-nums",children:[a.inFlight," / ",a.maxConcurrency]}),(0,t.jsx)(b,{className:"tabular-nums",children:a.maxConcurrency})]},a.name)}m(be,"se");var xe=["jobs","dead","pools","cron"],Ee=m(a=>{let e=(0,Y.c)(41),h;e[0]!==a?(h=a===void 0?{}:a,e[0]=a,e[1]=h):h=e[1];let{loadCronJobs:i,scheduledCancel:p,scheduledLoad:l}=h,o=B(),[r,y]=(0,G.useState)("jobs"),f;e[2]!==o?(f=o("Cron triggers"),e[2]=o,e[3]=f):f=e[3];let n;e[4]!==o?(n=o("Dead letter"),e[4]=o,e[5]=n):n=e[5];let s;e[6]!==o?(s=o("Scheduled jobs"),e[6]=o,e[7]=s):s=e[7];let u;e[8]!==o?(u=o("Pools"),e[8]=o,e[9]=u):u=e[9];let J;e[10]!==f||e[11]!==n||e[12]!==s||e[13]!==u?(J={cron:f,dead:n,jobs:s,pools:u},e[10]=f,e[11]=n,e[12]=s,e[13]=u,e[14]=J):J=e[14];let j=J,x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=m(N=>{y(N.currentTarget.dataset.view)},"u"),e[15]=x):x=e[15];let C=x,g;e[16]!==o?(g=o("Schedule view"),e[16]=o,e[17]=g):g=e[17];let S;e[18]!==r||e[19]!==j?(S=xe.map(N=>(0,t.jsx)(te,{"aria-selected":r===N,"data-testid":`schedule-view-${N}`,"data-view":N,onClick:C,role:"tab",size:"sm",type:"button",variant:r===N?"default":"outline",children:j[N]},N)),e[18]=r,e[19]=j,e[20]=S):S=e[20];let k;e[21]!==g||e[22]!==S?(k=(0,t.jsx)("div",{"aria-label":g,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:S}),e[21]=g,e[22]=S,e[23]=k):k=e[23];let w;e[24]!==p||e[25]!==l||e[26]!==r?(w=r==="jobs"&&(0,t.jsx)(de,{cancelJob:p,loadJobs:l}),e[24]=p,e[25]=l,e[26]=r,e[27]=w):w=e[27];let $;e[28]!==r?($=r==="dead"&&(0,t.jsx)(ue,{}),e[28]=r,e[29]=$):$=e[29];let q;e[30]!==r?(q=r==="pools"&&(0,t.jsx)(pe,{}),e[30]=r,e[31]=q):q=e[31];let I;e[32]!==i||e[33]!==r?(I=r==="cron"&&(0,t.jsx)(he,{loadCronJobs:i}),e[32]=i,e[33]=r,e[34]=I):I=e[34];let L;return e[35]!==k||e[36]!==w||e[37]!==$||e[38]!==q||e[39]!==I?(L=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[k,w,$,q,I]}),e[35]=k,e[36]=w,e[37]=$,e[38]=q,e[39]=I,e[40]=L):L=e[40],L},"Je");export{Ee as SchedulePanel};
1
+ import{a as U}from"./chunk-54MMVNPT.js";import{a as Q}from"./chunk-7LQWFOEU.js";import{a as E}from"./chunk-XSD4Y6SQ.js";import{a as K,b as V,c as z,d as F,e as v,f as b}from"./chunk-MIQTKZAR.js";import{a as D,e as P}from"./chunk-UZERI5YC.js";import{c as te}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as ee}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{f as T}from"./chunk-35II7U25.js";import"./chunk-XBDKZZ67.js";import{a as _}from"./chunk-XQCVZAGU.js";import{d as B,h as O,m as W,q as Z}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as m,e as R,f as oe,g as ae,h as le}from"./chunk-3XIESWL4.js";var Y=R(ae(),1),G=R(oe(),1);var t=R(le(),1);var ne=R(ae(),1);var X=R(oe(),1);var c=R(le(),1);var ie=m(a=>Number.isFinite(a)?Z(a,"\u2014"):"\u2014","Y"),se=m(a=>a.toSorted((e,h)=>e.scheduledFor-h.scheduledFor),"T"),de=m(a=>{let e=(0,ne.c)(33),h;e[0]!==a?(h=a===void 0?{}:a,e[0]=a,e[1]=h):h=e[1];let{cancelJob:i,loadJobs:p}=h,l=T(),o=B(),r=p===void 0,y;e[2]===Symbol.for("react.memo_cache_sentinel")?(y=["lunora-scheduled-jobs"],e[2]=y):y=e[2];let f;e[3]!==l||e[4]!==p?(f=m(async()=>{let d=await(p??(()=>l.listScheduledJobs()))();return se(d)},"j"),e[3]=l,e[4]=p,e[5]=f):f=e[5];let n=E(y,f),[s,u]=(0,X.useState)(void 0),[J,j]=(0,X.useState)(void 0),x,C;e[6]!==l||e[7]!==r?(x=m(()=>{if(r)return l.subscribeScheduledJobs(d=>{j(void 0),u(se(d))})},"N"),C=[r,l],e[6]=l,e[7]=r,e[8]=x,e[9]=C):(x=e[8],C=e[9]),(0,X.useEffect)(x,C);let g;e[10]!==n?(g=m(()=>{n.refetch()},"$"),e[10]=n,e[11]=g):g=e[11],U(g,!r);let S;e:{if(i!==void 0){S=i;break e}let d;e[12]!==l||e[13]!==p?(d=p===void 0?H=>l.cancelScheduledJob(H):void 0,e[12]=l,e[13]=p,e[14]=d):d=e[14],S=d}let k=S,w=s??n.data,$=J??n.error,q;e[15]!==k||e[16]!==n||e[17]!==r?(q=m(async d=>{if(k!==void 0){j(void 0);try{await k(d),r||n.refetch()}catch(H){j(O(H))}}},"S"),e[15]=k,e[16]=n,e[17]=r,e[18]=q):q=e[18];let I=q,L;e[19]!==$?(L=$!==null&&(0,c.jsx)("p",{className:"text-sm text-destructive","data-testid":"sj-error",role:"alert",children:$}),e[19]=$,e[20]=L):L=e[20];let N;e[21]!==w?.length||e[22]!==o?(N=w?.length===0&&(0,c.jsx)(_,{description:o("Jobs queued with runAfter / runAt will appear here."),icon:(0,c.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,c.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,c.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"sj-empty",title:o("No scheduled jobs.")}),e[21]=w?.length,e[22]=o,e[23]=N):N=e[23];let M;e[24]!==I||e[25]!==k||e[26]!==w||e[27]!==o?(M=w!==void 0&&w.length>0&&(0,c.jsx)(D,{className:"overflow-hidden py-0",children:(0,c.jsx)(P,{className:"px-0",children:(0,c.jsxs)(K,{"data-testid":"sj-table",children:[(0,c.jsx)(V,{children:(0,c.jsxs)(F,{children:[(0,c.jsx)(v,{children:o("function")}),(0,c.jsx)(v,{children:o("scheduled for")}),(0,c.jsx)(v,{children:o("pool")}),(0,c.jsx)(v,{children:o("attempts")}),(0,c.jsx)(v,{children:o("shard")}),(0,c.jsx)(v,{children:o("id")}),k!==void 0&&(0,c.jsx)(v,{"aria-label":o("Actions")})]})}),(0,c.jsx)(z,{children:w.map(d=>(0,c.jsxs)(F,{"data-testid":`sj-row-${d.id}`,children:[(0,c.jsx)(b,{className:"font-mono text-xs",children:d.functionPath}),(0,c.jsx)(b,{className:"text-muted-foreground tabular-nums",children:ie(d.scheduledFor)}),(0,c.jsx)(b,{className:"font-mono text-xs",children:d.pool??""}),(0,c.jsx)(b,{className:"tabular-nums",children:d.attempts??0}),(0,c.jsx)(b,{children:d.shardKey??""}),(0,c.jsx)(b,{className:"font-mono text-xs",children:d.id}),k!==void 0&&(0,c.jsx)(b,{className:"text-right",children:(0,c.jsx)(Q,{confirmLabel:o("Cancel job?"),onConfirm:m(()=>{W(I(d.id))},"onConfirm"),testId:`sj-cancel-${d.id}`,children:o("Cancel")})})]},d.id))})]})})}),e[24]=I,e[25]=k,e[26]=w,e[27]=o,e[28]=M):M=e[28];let A;return e[29]!==N||e[30]!==M||e[31]!==L?(A=(0,c.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduled-jobs",children:[L,N,M]}),e[29]=N,e[30]=M,e[31]=L,e[32]=A):A=e[32],A},"he");var ce={kind:"idle"},he=m(({loadCronJobs:a,runCronJob:e}={})=>{let h=T(),i=B(),[p,l]=(0,G.useState)({}),o=E(["lunora-cron-jobs",a?"custom":"default"],()=>(a??(()=>h.getCronJobs()))()),{data:r,error:y}=o,f=(0,G.useMemo)(()=>e!==void 0?e:a===void 0?s=>h.runCronJob(s):void 0,[h,a,e]),n=m(async s=>{if(f!==void 0){l(u=>({...u,[s]:{kind:"running"}}));try{await f(s),l(u=>({...u,[s]:{kind:"ok"}})),o.refetch()}catch(u){l(J=>({...J,[s]:{kind:"error",message:O(u)}}))}}},"d");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:y}),r?.length===0&&(0,t.jsx)(_,{description:i("Triggers declared with the cronJobs() builder appear here."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,t.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:i("No cron triggers.")}),r!==void 0&&r.length>0&&(0,t.jsx)(D,{className:"overflow-hidden py-0",children:(0,t.jsx)(P,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"cron-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(v,{children:i("name")}),(0,t.jsx)(v,{children:i("schedule")}),(0,t.jsx)(v,{children:i("target")}),(0,t.jsx)(v,{children:i("shard")}),f!==void 0&&(0,t.jsx)(v,{"aria-label":i("Actions")})]})}),(0,t.jsx)(z,{children:r.map(s=>{let u=p[s.name]??ce;return(0,t.jsxs)(F,{"data-testid":`cron-row-${s.name}`,children:[(0,t.jsx)(b,{children:s.name}),(0,t.jsx)(b,{className:"font-mono text-xs tabular-nums",children:s.cron}),(0,t.jsx)(b,{children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[s.workflow===void 0?(0,t.jsx)(ee,{variant:"outline",children:i("function")}):(0,t.jsx)(ee,{variant:"secondary",children:i("workflow")}),(0,t.jsx)("span",{className:"font-mono text-xs",children:s.workflow??s.functionPath})]})}),(0,t.jsx)(b,{children:s.shardKey??""}),f!==void 0&&(0,t.jsx)(b,{className:"text-right",children:(0,t.jsxs)("span",{className:"flex items-center justify-end gap-2",children:[u.kind==="ok"&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${s.name}`,children:i("ran")}),u.kind==="error"&&(0,t.jsx)("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${s.name}`,role:"alert",children:u.message}),(0,t.jsx)(Q,{confirmLabel:i("Run now?"),disabled:u.kind==="running",onConfirm:m(()=>{W(n(s.name))},"onConfirm"),testId:`cron-run-${s.name}`,children:u.kind==="running"?i("Running\u2026"):i("Run now")})]})})]},`${s.cron}:${s.name}`)})})]})})})]})},"le"),me=m(a=>Number.isFinite(a)?Z(a,"\u2014"):"\u2014","re"),ue=m(a=>{let e=(0,Y.c)(34),h;e[0]!==a?(h=a===void 0?{}:a,e[0]=a,e[1]=h):h=e[1];let{loadJobs:i,removeJob:p,retryJob:l}=h,o=T(),r=B(),y;e[2]===Symbol.for("react.memo_cache_sentinel")?(y=["lunora-dead-jobs"],e[2]=y):y=e[2];let f;e[3]!==o||e[4]!==i?(f=m(async()=>(await(i??(()=>o.listDeadJobs()))()).toSorted(fe),"h"),e[3]=o,e[4]=i,e[5]=f):f=e[5];let n=E(y,f),s=n.data,[u,J]=(0,G.useState)(void 0),j=n.error??u,x=i===void 0,C;e[6]!==o||e[7]!==x||e[8]!==l?(C=l??(x?d=>o.retryDeadJob(d):void 0),e[6]=o,e[7]=x,e[8]=l,e[9]=C):C=e[9];let g=C,S;e[10]!==o||e[11]!==x||e[12]!==p?(S=p??(x?d=>o.removeDeadJob(d):void 0),e[10]=o,e[11]=x,e[12]=p,e[13]=S):S=e[13];let k=S,w;e[14]!==n?(w=m(()=>{n.refetch()},"J"),e[14]=n,e[15]=w):w=e[15],U(w,!0);let $;e[16]!==n?($=m(async d=>{J(void 0);try{await d,n.refetch()}catch(H){J(O(H))}},"j"),e[16]=n,e[17]=$):$=e[17];let q=$,I=g!==void 0||k!==void 0,L;e[18]!==j?(L=j!==void 0&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:j}),e[18]=j,e[19]=L):L=e[19];let N;e[20]!==s?.length||e[21]!==r?(N=s?.length===0&&(0,t.jsx)(_,{description:r("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:r("No dead-letter jobs.")}),e[20]=s?.length,e[21]=r,e[22]=N):N=e[22];let M;e[23]!==q||e[24]!==I||e[25]!==s||e[26]!==k||e[27]!==g||e[28]!==r?(M=s!==void 0&&s.length>0&&(0,t.jsx)(D,{className:"overflow-hidden py-0",children:(0,t.jsx)(P,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"dlq-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(v,{children:r("function")}),(0,t.jsx)(v,{children:r("attempts")}),(0,t.jsx)(v,{children:r("last tried")}),(0,t.jsx)(v,{children:r("pool")}),(0,t.jsx)(v,{children:r("shard")}),(0,t.jsx)(v,{children:r("id")}),I&&(0,t.jsx)(v,{"aria-label":r("Actions")})]})}),(0,t.jsx)(z,{children:s.map(d=>(0,t.jsxs)(F,{"data-testid":`dlq-row-${d.id}`,children:[(0,t.jsx)(b,{className:"font-mono text-xs",children:d.functionPath}),(0,t.jsx)(b,{className:"tabular-nums",children:d.attempts??0}),(0,t.jsx)(b,{className:"text-muted-foreground tabular-nums",children:me(d.scheduledFor)}),(0,t.jsx)(b,{className:"font-mono text-xs",children:d.pool??""}),(0,t.jsx)(b,{children:d.shardKey??""}),(0,t.jsx)(b,{className:"font-mono text-xs",children:d.id}),I&&(0,t.jsx)(b,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1.5",children:[g!==void 0&&(0,t.jsx)(te,{"data-testid":`dlq-retry-${d.id}`,onClick:m(()=>{W(q(g(d.id)))},"onClick"),size:"sm",type:"button",variant:"outline",children:r("Retry")}),k!==void 0&&(0,t.jsx)(Q,{confirmLabel:r("Drop job?"),onConfirm:m(()=>{W(q(k(d.id)))},"onConfirm"),testId:`dlq-remove-${d.id}`,children:r("Drop")})]})})]},d.id))})]})})}),e[23]=q,e[24]=I,e[25]=s,e[26]=k,e[27]=g,e[28]=r,e[29]=M):M=e[29];let A;return e[30]!==M||e[31]!==L||e[32]!==N?(A=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[L,N,M]}),e[30]=M,e[31]=L,e[32]=N,e[33]=A):A=e[33],A},"ne");function fe(a,e){return(e.attempts??0)-(a.attempts??0)}m(fe,"ae");var re=m(a=>{let e=(0,Y.c)(8),{label:h,testId:i,value:p}=a,l;e[0]!==h?(l=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:h}),e[0]=h,e[1]=l):l=e[1];let o;e[2]!==i||e[3]!==p?(o=(0,t.jsx)("span",{className:"text-2xl font-semibold tabular-nums","data-testid":i,children:p}),e[2]=i,e[3]=p,e[4]=o):o=e[4];let r;return e[5]!==l||e[6]!==o?(r=(0,t.jsx)(D,{className:"flex-1 py-0",children:(0,t.jsxs)(P,{className:"flex flex-col gap-1 p-4",children:[l,o]})}),e[5]=l,e[6]=o,e[7]=r):r=e[7],r},"F"),pe=m(a=>{let e=(0,Y.c)(25),h;e[0]!==a?(h=a===void 0?{}:a,e[0]=a,e[1]=h):h=e[1];let{loadStatus:i}=h,p=T(),l=B(),o=i===void 0,r;e[2]!==o?(r=["lunora-scheduler-status",o],e[2]=o,e[3]=r):r=e[3];let y;e[4]!==p||e[5]!==i?(y=m(async()=>{let S=await(i??(()=>p.schedulerStatus()))();return{...S,pools:S.pools.toSorted(ve)}},"k"),e[4]=p,e[5]=i,e[6]=y):y=e[6];let f=E(r,y),{data:n,error:s}=f,u;e[7]!==f?(u=m(()=>{f.refetch()},"s"),e[7]=f,e[8]=u):u=e[8],U(u,!0);let J;e[9]!==s?(J=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:s}),e[9]=s,e[10]=J):J=e[10];let j;e[11]!==n||e[12]!==l?(j=n!==void 0&&(0,t.jsxs)("div",{className:"flex gap-3","data-testid":"pools-totals",children:[(0,t.jsx)(re,{label:l("backlog"),testId:"pools-backlog",value:n.backlog}),(0,t.jsx)(re,{label:l("in flight"),testId:"pools-inflight",value:n.inFlight}),(0,t.jsx)(re,{label:l("pools"),testId:"pools-count",value:n.pools.length})]}),e[11]=n,e[12]=l,e[13]=j):j=e[13];let x;e[14]!==n?.pools.length||e[15]!==l?(x=n?.pools.length===0&&(0,t.jsx)(_,{description:l("Pools created with createWorkpool appear here once they have activity."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:l("No workpools.")}),e[14]=n?.pools.length,e[15]=l,e[16]=x):x=e[16];let C;e[17]!==n||e[18]!==l?(C=n!==void 0&&n.pools.length>0&&(0,t.jsx)(D,{className:"overflow-hidden py-0",children:(0,t.jsx)(P,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"pools-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(v,{children:l("pool")}),(0,t.jsx)(v,{children:l("queued")}),(0,t.jsx)(v,{children:l("in flight")}),(0,t.jsx)(v,{children:l("max concurrency")})]})}),(0,t.jsx)(z,{children:n.pools.map(be)})]})})}),e[17]=n,e[18]=l,e[19]=C):C=e[19];let g;return e[20]!==J||e[21]!==j||e[22]!==x||e[23]!==C?(g=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[J,j,x,C]}),e[20]=J,e[21]=j,e[22]=x,e[23]=C,e[24]=g):g=e[24],g},"de");function ve(a,e){return e.queued-a.queued}m(ve,"ie");function be(a){return(0,t.jsxs)(F,{"data-testid":`pools-row-${a.name}`,children:[(0,t.jsx)(b,{className:"font-mono text-xs",children:a.name}),(0,t.jsx)(b,{className:"tabular-nums",children:a.queued}),(0,t.jsxs)(b,{className:"tabular-nums",children:[a.inFlight," / ",a.maxConcurrency]}),(0,t.jsx)(b,{className:"tabular-nums",children:a.maxConcurrency})]},a.name)}m(be,"se");var xe=["jobs","dead","pools","cron"],Ee=m(a=>{let e=(0,Y.c)(41),h;e[0]!==a?(h=a===void 0?{}:a,e[0]=a,e[1]=h):h=e[1];let{loadCronJobs:i,scheduledCancel:p,scheduledLoad:l}=h,o=B(),[r,y]=(0,G.useState)("jobs"),f;e[2]!==o?(f=o("Cron triggers"),e[2]=o,e[3]=f):f=e[3];let n;e[4]!==o?(n=o("Dead letter"),e[4]=o,e[5]=n):n=e[5];let s;e[6]!==o?(s=o("Scheduled jobs"),e[6]=o,e[7]=s):s=e[7];let u;e[8]!==o?(u=o("Pools"),e[8]=o,e[9]=u):u=e[9];let J;e[10]!==f||e[11]!==n||e[12]!==s||e[13]!==u?(J={cron:f,dead:n,jobs:s,pools:u},e[10]=f,e[11]=n,e[12]=s,e[13]=u,e[14]=J):J=e[14];let j=J,x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=m(N=>{y(N.currentTarget.dataset.view)},"u"),e[15]=x):x=e[15];let C=x,g;e[16]!==o?(g=o("Schedule view"),e[16]=o,e[17]=g):g=e[17];let S;e[18]!==r||e[19]!==j?(S=xe.map(N=>(0,t.jsx)(te,{"aria-selected":r===N,"data-testid":`schedule-view-${N}`,"data-view":N,onClick:C,role:"tab",size:"sm",type:"button",variant:r===N?"default":"outline",children:j[N]},N)),e[18]=r,e[19]=j,e[20]=S):S=e[20];let k;e[21]!==g||e[22]!==S?(k=(0,t.jsx)("div",{"aria-label":g,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:S}),e[21]=g,e[22]=S,e[23]=k):k=e[23];let w;e[24]!==p||e[25]!==l||e[26]!==r?(w=r==="jobs"&&(0,t.jsx)(de,{cancelJob:p,loadJobs:l}),e[24]=p,e[25]=l,e[26]=r,e[27]=w):w=e[27];let $;e[28]!==r?($=r==="dead"&&(0,t.jsx)(ue,{}),e[28]=r,e[29]=$):$=e[29];let q;e[30]!==r?(q=r==="pools"&&(0,t.jsx)(pe,{}),e[30]=r,e[31]=q):q=e[31];let I;e[32]!==i||e[33]!==r?(I=r==="cron"&&(0,t.jsx)(he,{loadCronJobs:i}),e[32]=i,e[33]=r,e[34]=I):I=e[34];let L;return e[35]!==k||e[36]!==w||e[37]!==$||e[38]!==q||e[39]!==I?(L=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[k,w,$,q,I]}),e[35]=k,e[36]=w,e[37]=$,e[38]=q,e[39]=I,e[40]=L):L=e[40],L},"Je");export{Ee as SchedulePanel};
@@ -1 +1 @@
1
- import{b as de,e as F}from"./chunk-5L2MD6F6.js";import{a as ce}from"./chunk-X2FQ6B5V.js";import"./chunk-PF7V3G2Z.js";import"./chunk-4UOFSGUS.js";import"./chunk-ILNELDFC.js";import"./chunk-T6VMSOBB.js";import{b as ie}from"./chunk-OWADN6BI.js";import{a as k}from"./chunk-UZERI5YC.js";import{a as oe}from"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import"./chunk-7QIFDWQV.js";import{b as A}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as y}from"./chunk-GXZAXNZI.js";import{f as ae,g as le}from"./chunk-LWECXQWP.js";import"./chunk-XBDKZZ67.js";import{d as R,f as S,g as Q,h as V,m as z,q as ne}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as p,e as q,f as qe,g as re,h as se,j as w}from"./chunk-3XIESWL4.js";var xe=q(re(),1);var c=q(qe(),1);var ue=q(re(),1);var K=q(se(),1);var Ae={connected:"bg-success",connecting:"bg-warning",idle:"bg-muted-foreground",offline:"bg-destructive"},me=p(()=>{let t=(0,ue.c)(16),e=R(),a=le(),s;e:switch(a){case"connected":{let i;t[0]!==e?(i=e("Connected"),t[0]=e,t[1]=i):i=t[1],s=i;break e}case"connecting":{let i;t[2]!==e?(i=e("Connecting\u2026"),t[2]=e,t[3]=i):i=t[3],s=i;break e}case"idle":{let i;t[4]!==e?(i=e("Idle"),t[4]=e,t[5]=i):i=t[5],s=i;break e}case"offline":{let i;t[6]!==e?(i=e("Offline"),t[6]=e,t[7]=i):i=t[7],s=i;break e}default:s=a}let l=Ae[a],d;t[8]!==l?(d=w("size-2 rounded-full",l),t[8]=l,t[9]=d):d=t[9];let u;t[10]!==d?(u=(0,K.jsx)("span",{"aria-hidden":"true",className:d}),t[10]=d,t[11]=u):u=t[11];let o;return t[12]!==a||t[13]!==u||t[14]!==s?(o=(0,K.jsxs)("span",{"aria-live":"polite",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground","data-status":a,"data-testid":"dash-connection",role:"status",children:[u,s]}),t[12]=a,t[13]=u,t[14]=s,t[15]=o):o=t[15],o},"j");var r=q(se(),1);var fe={completed:0,failed:2,in_progress:1},Ee=p(t=>{let e=0,a=0,s=0,l=0,d=[];for(let{metrics:u}of t){if(u===null){l+=1;continue}s+=1,e+=u.requests,a+=u.errors,d.push(...u.history??[])}return{errors:a,failed:l,history:d,reachable:s,requests:e}},"Se"),je=p(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.path);if(l===void 0){e.set(s.path,{...s});continue}l.calls+=s.calls,l.errors+=s.errors,l.totalDurationMs+=s.totalDurationMs,l.scans=(l.scans??0)+(s.scans??0),l.maxDurationMs=Math.max(l.maxDurationMs,s.maxDurationMs),l.lastCalledAt=Math.max(l.lastCalledAt,s.lastCalledAt),(s.lastErrorAt??0)>(l.lastErrorAt??0)&&(l.lastErrorAt=s.lastErrorAt,l.lastErrorMessage=s.lastErrorMessage)}return[...e.values()]},"Me"),Ie=p(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.id);if(l===void 0){e.set(s.id,s);continue}let d=fe[s.status]-fe[l.status];(d>0||d===0&&(s.updatedAt??0)>(l.updatedAt??0))&&e.set(s.id,s)}return[...e.values()]},"qe"),De=S(y.getAuthMetrics),Ce=S(y.getFunctionStats),Pe=S(y.getLogs),Le=S(y.getMetrics),Te=S(y.migrationStatus),Re=5,pe=2e3,ze=5,he=.01,ge=.05,Fe=.1,Ke=.3,Oe=1,_e=50,W=p((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","V"),$e=p((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","Re"),He={crit:"destructive",ok:"secondary",warn:"default"},O=p((t,e)=>e===0?"\u2014":`${(t/e*100).toFixed(1)}%`,"F"),Ue=p(t=>{let e=new Map;for(let s of t??[]){let l=e.get(s.bucketMs)??{calls:0,errors:0};l.calls+=s.calls,l.errors+=s.errors,e.set(s.bucketMs,l)}let a=[...e.entries()].toSorted((s,l)=>s[0]-l[0]);return{errors:a.map(([,s])=>s.errors),requests:a.map(([,s])=>s.calls)}},"_e"),Be=p(t=>{let e=0,a=0;for(let l of t)l.status==="failed"?e+=1:l.status==="in_progress"&&(a+=1);let s="ok";return e>0?s="crit":a>0&&(s="warn"),{failed:e,level:s,running:a}},"ze"),Ge=p((t,e)=>t.failed>0?e("{count} failed",{count:t.failed.toString()}):t.running>0?e("{count} running",{count:t.running.toString()}):e("OK"),"Ke"),ve={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},be={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},Je={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},Qe=p(t=>t.includes("crit")?"crit":t.includes("warn")?"warn":"ok","Ue"),_=p(t=>{let e=(0,xe.c)(19),{chart:a,label:s,level:l,testId:d,value:u}=t,o=ve[l],i;e[0]!==o?(i=w("size-1.5 shrink-0 rounded-full",o),e[0]=o,e[1]=i):i=e[1];let h;e[2]!==i?(h=(0,r.jsx)("span",{"aria-hidden":"true",className:i}),e[2]=i,e[3]=h):h=e[3];let g;e[4]!==s||e[5]!==h?(g=(0,r.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[h,s]}),e[4]=s,e[5]=h,e[6]=g):g=e[6];let N=be[l],f;e[7]!==N?(f=w("truncate text-2xl font-semibold tabular-nums",N),e[7]=N,e[8]=f):f=e[8];let m;e[9]!==f||e[10]!==d||e[11]!==u?(m=(0,r.jsx)("span",{className:f,"data-testid":d,children:u}),e[9]=f,e[10]=d,e[11]=u,e[12]=m):m=e[12];let x;e[13]!==a||e[14]!==m?(x=(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[m,a]}),e[13]=a,e[14]=m,e[15]=x):x=e[15];let v;return e[16]!==g||e[17]!==x?(v=(0,r.jsx)(k,{className:"gap-0 py-0",children:(0,r.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[g,x]})}),e[16]=g,e[17]=x,e[18]=v):v=e[18],v},"R"),Ve=p(async(t,e,a)=>{let s=await Promise.all(a.map(f=>{let m=Q(f);return Promise.allSettled([t.query(Le,{},m),t.query(Ce,{},m),t.query(Te,{},m)])})),l=Q(e),d=typeof t.schedulerStatus=="function"?t.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[u,o,i]=await Promise.allSettled([t.query(Pe,{},l),t.query(De,{},l),d]),h=s.map(([f,m,x])=>({functions:m.status==="fulfilled"?m.value.functions:[],metrics:f.status==="fulfilled"?f.value:null,migrations:x.status==="fulfilled"?x.value.migrations:[]})),g=Ee(h),N=s[0]?.[0];return{auth:o.status==="fulfilled"?o.value:null,entries:u.status==="fulfilled"?u.value.entries:[],functions:je(h.map(f=>f.functions)),logsError:u.status==="rejected"?V(u.reason):null,metricsError:g.reachable===0&&N?.status==="rejected"?V(N.reason):null,migrations:Ie(h.map(f=>f.migrations)),scheduler:i.status==="fulfilled"?i.value:null,totals:g}},"Be"),pt=p(({initialShardKey:t})=>{let e=ae(),a=R(),[s,l]=(0,c.useState)([]),[d,u]=(0,c.useState)(null),[o,i]=(0,c.useState)(null),[h,g]=(0,c.useState)(null),[N,f]=(0,c.useState)([]),[m,x]=(0,c.useState)(null),[v,Ne]=(0,c.useState)(null),[we,ye]=(0,c.useState)([]),[M]=(0,c.useState)(oe),E=(0,c.useRef)(!1),$=(0,c.useRef)(!0);(0,c.useEffect)(()=>($.current=!0,()=>{$.current=!1}),[]);let j=t??"",I=(0,c.useCallback)(async()=>{if(E.current)return;E.current=!0;let n=await Ve(e,j,de(j,M));if(!$.current){E.current=!1;return}i(n.totals),g(n.metricsError),f(n.functions),ye(n.migrations),l(n.entries),u(n.logsError),x(n.auth),Ne(n.scheduler),E.current=!1},[e,M,j]);(0,c.useEffect)(()=>{z(I())},[I]);let H=(0,c.useRef)(0),D=(0,c.useRef)(null),ke=p(()=>{let n=Date.now()-H.current;if(n>=pe){H.current=Date.now(),z(I());return}D.current??=setTimeout(()=>{D.current=null,H.current=Date.now(),z(I())},pe-n)},"de");(0,c.useEffect)(()=>()=>{D.current!==null&&clearTimeout(D.current)},[]);let{data:X,liveError:Se}=ie(y.getMetrics,{},{live:!0,shardKey:j});(0,c.useEffect)(()=>{X!==void 0&&ke()},[X]);let U=s.filter(n=>n.level==="error"),B=U.slice(0,Re),C=Ue(o?.history),Y=(0,c.useMemo)(()=>{let n=m?.history??[];return{attempts:n.map(b=>b.attempts),failures:n.map(b=>b.failures)}},[m?.history]),Z=N.filter(n=>n.calls>0).toSorted((n,b)=>b.errors/b.calls-n.errors/n.calls||b.calls-n.calls).slice(0,ze),G=Be(we),Me=o===null||o.requests===0?0:o.errors/o.requests,J=W(Me,he,ge),ee=m===null?"ok":W(m.failureRate,Fe,Ke),te=v===null?"ok":$e(v.backlog,Oe,_e),P=Qe([J,ee,te,G.level]),L,T;return P==="crit"?(L=a("Critical"),T=a("One or more service levels are breached.")):P==="warn"?(L=a("Degraded"),T=a("Some service levels need attention.")):(L=a("All systems healthy"),T=a("All service levels are within target.")),(0,r.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[(0,r.jsxs)(k,{className:"gap-0 py-0",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:w("flex size-10 shrink-0 items-center justify-center rounded-full",Je[P]),children:(0,r.jsx)("span",{className:w("size-3 rounded-full",ve[P])})}),(0,r.jsxs)("div",{className:"grid leading-tight",children:[(0,r.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:L}),(0,r.jsx)("span",{className:"text-[13px] text-muted-foreground",children:T})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Requests")}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[C.requests.length>=2&&(0,r.jsx)(F,{ariaLabel:a("Requests over time"),className:"h-6 w-20 text-foreground",series:C.requests,testId:"hl-spark-requests"}),(0,r.jsx)("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:(o?.requests??0).toString()})]})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Error rate")}),(0,r.jsx)("div",{className:w("text-lg font-semibold tabular-nums",be[J]),"data-testid":"hl-error-rate",children:o===null?"\u2014":O(o.errors,o.requests)})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(me,{}),(0,r.jsx)(ce,{message:Se,prefix:"hl"})]})]})]}),h!==null&&(0,r.jsx)("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-sm text-destructive","data-testid":"hl-metrics-error",role:"alert",children:h})]}),(0,r.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[(0,r.jsx)(_,{chart:C.errors.length>=2?(0,r.jsx)(F,{ariaLabel:a("Errors over time"),className:"h-7 w-20 text-destructive",series:C.errors,testId:"hl-spark-errors"}):void 0,label:a("Error rate"),level:J,testId:"hl-slo-errorrate",value:o===null?"\u2014":O(o.errors,o.requests)}),(0,r.jsx)(_,{chart:Y.failures.length>=2?(0,r.jsx)(F,{ariaLabel:a("Auth failures over time"),className:"h-7 w-20 text-destructive",series:Y.failures,testId:"hl-spark-auth"}):void 0,label:a("Auth failures"),level:ee,testId:"hl-slo-auth",value:m===null?"\u2014":O(m.failures,m.attempts)}),(0,r.jsx)(_,{label:a("Scheduler backlog"),level:te,testId:"hl-slo-backlog",value:v===null?"\u2014":v.backlog.toString()}),(0,r.jsx)(_,{label:a("Migrations"),level:G.level,testId:"hl-slo-migrations",value:Ge(G,a)})]}),(0,r.jsxs)("div",{className:"grid gap-3 lg:grid-cols-2",children:[(0,r.jsxs)(k,{className:"gap-0 py-0","data-testid":"hl-functions",children:[(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Functions by error rate")})}),Z.length===0?(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-functions-empty",children:a("No function activity yet.")}):(0,r.jsx)("ul",{className:"divide-y divide-border",children:Z.map(n=>(0,r.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-xs","data-testid":"hl-fn-row",children:[(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:n.path}),(0,r.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[(0,r.jsx)("span",{className:"tabular-nums text-muted-foreground",children:a("{count} calls",{count:n.calls.toString()})}),(0,r.jsx)(A,{variant:He[W(n.errors/n.calls,he,ge)],children:O(n.errors,n.calls)})]})]},n.path))})]}),(0,r.jsxs)(k,{className:"gap-0 py-0",children:[(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Recent errors")}),(0,r.jsx)(A,{"data-testid":"hl-error-count",variant:U.length>0?"destructive":"outline",children:U.length})]}),d!==null&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:d}),d===null&&B.length===0&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-errors-empty",children:a("No recent errors.")}),B.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:B.map((n,b)=>(0,r.jsxs)("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)("time",{className:"shrink-0 text-muted-foreground",children:ne(n.timestamp)}),n.functionPath!==void 0&&(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:n.functionPath})]}),(0,r.jsx)("span",{className:"text-destructive",children:n.message})]},`${n.timestamp.toString()}-${b.toString()}`))})]})]}),(0,r.jsxs)(k,{className:"gap-0 py-0",children:[(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Shards seen")}),(0,r.jsx)(A,{"data-testid":"hl-shard-count",variant:"outline",children:M.length})]}),M.length>0&&(0,r.jsx)("ul",{className:"flex flex-wrap gap-1.5 p-4",children:M.map(n=>(0,r.jsx)("li",{"data-testid":"hl-shard",children:(0,r.jsx)(A,{variant:"secondary",children:n})},n))})]})]})},"ot");export{pt as HealthPanel};
1
+ import{b as de,e as F}from"./chunk-5L2MD6F6.js";import{a as ce}from"./chunk-X2FQ6B5V.js";import"./chunk-PF7V3G2Z.js";import"./chunk-4UOFSGUS.js";import"./chunk-ILNELDFC.js";import"./chunk-T6VMSOBB.js";import{b as ie}from"./chunk-XSD4Y6SQ.js";import{a as k}from"./chunk-UZERI5YC.js";import{a as oe}from"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import"./chunk-7QIFDWQV.js";import{b as A}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as y}from"./chunk-GXZAXNZI.js";import{f as ae,g as le}from"./chunk-35II7U25.js";import"./chunk-XBDKZZ67.js";import{d as R,f as S,g as Q,h as V,m as z,q as ne}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as p,e as q,f as qe,g as re,h as se,j as w}from"./chunk-3XIESWL4.js";var xe=q(re(),1);var c=q(qe(),1);var ue=q(re(),1);var K=q(se(),1);var Ae={connected:"bg-success",connecting:"bg-warning",idle:"bg-muted-foreground",offline:"bg-destructive"},me=p(()=>{let t=(0,ue.c)(16),e=R(),a=le(),s;e:switch(a){case"connected":{let i;t[0]!==e?(i=e("Connected"),t[0]=e,t[1]=i):i=t[1],s=i;break e}case"connecting":{let i;t[2]!==e?(i=e("Connecting\u2026"),t[2]=e,t[3]=i):i=t[3],s=i;break e}case"idle":{let i;t[4]!==e?(i=e("Idle"),t[4]=e,t[5]=i):i=t[5],s=i;break e}case"offline":{let i;t[6]!==e?(i=e("Offline"),t[6]=e,t[7]=i):i=t[7],s=i;break e}default:s=a}let l=Ae[a],d;t[8]!==l?(d=w("size-2 rounded-full",l),t[8]=l,t[9]=d):d=t[9];let u;t[10]!==d?(u=(0,K.jsx)("span",{"aria-hidden":"true",className:d}),t[10]=d,t[11]=u):u=t[11];let o;return t[12]!==a||t[13]!==u||t[14]!==s?(o=(0,K.jsxs)("span",{"aria-live":"polite",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground","data-status":a,"data-testid":"dash-connection",role:"status",children:[u,s]}),t[12]=a,t[13]=u,t[14]=s,t[15]=o):o=t[15],o},"j");var r=q(se(),1);var fe={completed:0,failed:2,in_progress:1},Ee=p(t=>{let e=0,a=0,s=0,l=0,d=[];for(let{metrics:u}of t){if(u===null){l+=1;continue}s+=1,e+=u.requests,a+=u.errors,d.push(...u.history??[])}return{errors:a,failed:l,history:d,reachable:s,requests:e}},"Se"),je=p(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.path);if(l===void 0){e.set(s.path,{...s});continue}l.calls+=s.calls,l.errors+=s.errors,l.totalDurationMs+=s.totalDurationMs,l.scans=(l.scans??0)+(s.scans??0),l.maxDurationMs=Math.max(l.maxDurationMs,s.maxDurationMs),l.lastCalledAt=Math.max(l.lastCalledAt,s.lastCalledAt),(s.lastErrorAt??0)>(l.lastErrorAt??0)&&(l.lastErrorAt=s.lastErrorAt,l.lastErrorMessage=s.lastErrorMessage)}return[...e.values()]},"Me"),Ie=p(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.id);if(l===void 0){e.set(s.id,s);continue}let d=fe[s.status]-fe[l.status];(d>0||d===0&&(s.updatedAt??0)>(l.updatedAt??0))&&e.set(s.id,s)}return[...e.values()]},"qe"),De=S(y.getAuthMetrics),Ce=S(y.getFunctionStats),Pe=S(y.getLogs),Le=S(y.getMetrics),Te=S(y.migrationStatus),Re=5,pe=2e3,ze=5,he=.01,ge=.05,Fe=.1,Ke=.3,Oe=1,_e=50,W=p((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","V"),$e=p((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","Re"),He={crit:"destructive",ok:"secondary",warn:"default"},O=p((t,e)=>e===0?"\u2014":`${(t/e*100).toFixed(1)}%`,"F"),Ue=p(t=>{let e=new Map;for(let s of t??[]){let l=e.get(s.bucketMs)??{calls:0,errors:0};l.calls+=s.calls,l.errors+=s.errors,e.set(s.bucketMs,l)}let a=[...e.entries()].toSorted((s,l)=>s[0]-l[0]);return{errors:a.map(([,s])=>s.errors),requests:a.map(([,s])=>s.calls)}},"_e"),Be=p(t=>{let e=0,a=0;for(let l of t)l.status==="failed"?e+=1:l.status==="in_progress"&&(a+=1);let s="ok";return e>0?s="crit":a>0&&(s="warn"),{failed:e,level:s,running:a}},"ze"),Ge=p((t,e)=>t.failed>0?e("{count} failed",{count:t.failed.toString()}):t.running>0?e("{count} running",{count:t.running.toString()}):e("OK"),"Ke"),ve={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},be={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},Je={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},Qe=p(t=>t.includes("crit")?"crit":t.includes("warn")?"warn":"ok","Ue"),_=p(t=>{let e=(0,xe.c)(19),{chart:a,label:s,level:l,testId:d,value:u}=t,o=ve[l],i;e[0]!==o?(i=w("size-1.5 shrink-0 rounded-full",o),e[0]=o,e[1]=i):i=e[1];let h;e[2]!==i?(h=(0,r.jsx)("span",{"aria-hidden":"true",className:i}),e[2]=i,e[3]=h):h=e[3];let g;e[4]!==s||e[5]!==h?(g=(0,r.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[h,s]}),e[4]=s,e[5]=h,e[6]=g):g=e[6];let N=be[l],f;e[7]!==N?(f=w("truncate text-2xl font-semibold tabular-nums",N),e[7]=N,e[8]=f):f=e[8];let m;e[9]!==f||e[10]!==d||e[11]!==u?(m=(0,r.jsx)("span",{className:f,"data-testid":d,children:u}),e[9]=f,e[10]=d,e[11]=u,e[12]=m):m=e[12];let x;e[13]!==a||e[14]!==m?(x=(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[m,a]}),e[13]=a,e[14]=m,e[15]=x):x=e[15];let v;return e[16]!==g||e[17]!==x?(v=(0,r.jsx)(k,{className:"gap-0 py-0",children:(0,r.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[g,x]})}),e[16]=g,e[17]=x,e[18]=v):v=e[18],v},"R"),Ve=p(async(t,e,a)=>{let s=await Promise.all(a.map(f=>{let m=Q(f);return Promise.allSettled([t.query(Le,{},m),t.query(Ce,{},m),t.query(Te,{},m)])})),l=Q(e),d=typeof t.schedulerStatus=="function"?t.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[u,o,i]=await Promise.allSettled([t.query(Pe,{},l),t.query(De,{},l),d]),h=s.map(([f,m,x])=>({functions:m.status==="fulfilled"?m.value.functions:[],metrics:f.status==="fulfilled"?f.value:null,migrations:x.status==="fulfilled"?x.value.migrations:[]})),g=Ee(h),N=s[0]?.[0];return{auth:o.status==="fulfilled"?o.value:null,entries:u.status==="fulfilled"?u.value.entries:[],functions:je(h.map(f=>f.functions)),logsError:u.status==="rejected"?V(u.reason):null,metricsError:g.reachable===0&&N?.status==="rejected"?V(N.reason):null,migrations:Ie(h.map(f=>f.migrations)),scheduler:i.status==="fulfilled"?i.value:null,totals:g}},"Be"),pt=p(({initialShardKey:t})=>{let e=ae(),a=R(),[s,l]=(0,c.useState)([]),[d,u]=(0,c.useState)(null),[o,i]=(0,c.useState)(null),[h,g]=(0,c.useState)(null),[N,f]=(0,c.useState)([]),[m,x]=(0,c.useState)(null),[v,Ne]=(0,c.useState)(null),[we,ye]=(0,c.useState)([]),[M]=(0,c.useState)(oe),E=(0,c.useRef)(!1),$=(0,c.useRef)(!0);(0,c.useEffect)(()=>($.current=!0,()=>{$.current=!1}),[]);let j=t??"",I=(0,c.useCallback)(async()=>{if(E.current)return;E.current=!0;let n=await Ve(e,j,de(j,M));if(!$.current){E.current=!1;return}i(n.totals),g(n.metricsError),f(n.functions),ye(n.migrations),l(n.entries),u(n.logsError),x(n.auth),Ne(n.scheduler),E.current=!1},[e,M,j]);(0,c.useEffect)(()=>{z(I())},[I]);let H=(0,c.useRef)(0),D=(0,c.useRef)(null),ke=p(()=>{let n=Date.now()-H.current;if(n>=pe){H.current=Date.now(),z(I());return}D.current??=setTimeout(()=>{D.current=null,H.current=Date.now(),z(I())},pe-n)},"de");(0,c.useEffect)(()=>()=>{D.current!==null&&clearTimeout(D.current)},[]);let{data:X,liveError:Se}=ie(y.getMetrics,{},{live:!0,shardKey:j});(0,c.useEffect)(()=>{X!==void 0&&ke()},[X]);let U=s.filter(n=>n.level==="error"),B=U.slice(0,Re),C=Ue(o?.history),Y=(0,c.useMemo)(()=>{let n=m?.history??[];return{attempts:n.map(b=>b.attempts),failures:n.map(b=>b.failures)}},[m?.history]),Z=N.filter(n=>n.calls>0).toSorted((n,b)=>b.errors/b.calls-n.errors/n.calls||b.calls-n.calls).slice(0,ze),G=Be(we),Me=o===null||o.requests===0?0:o.errors/o.requests,J=W(Me,he,ge),ee=m===null?"ok":W(m.failureRate,Fe,Ke),te=v===null?"ok":$e(v.backlog,Oe,_e),P=Qe([J,ee,te,G.level]),L,T;return P==="crit"?(L=a("Critical"),T=a("One or more service levels are breached.")):P==="warn"?(L=a("Degraded"),T=a("Some service levels need attention.")):(L=a("All systems healthy"),T=a("All service levels are within target.")),(0,r.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[(0,r.jsxs)(k,{className:"gap-0 py-0",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:w("flex size-10 shrink-0 items-center justify-center rounded-full",Je[P]),children:(0,r.jsx)("span",{className:w("size-3 rounded-full",ve[P])})}),(0,r.jsxs)("div",{className:"grid leading-tight",children:[(0,r.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:L}),(0,r.jsx)("span",{className:"text-[13px] text-muted-foreground",children:T})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Requests")}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[C.requests.length>=2&&(0,r.jsx)(F,{ariaLabel:a("Requests over time"),className:"h-6 w-20 text-foreground",series:C.requests,testId:"hl-spark-requests"}),(0,r.jsx)("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:(o?.requests??0).toString()})]})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Error rate")}),(0,r.jsx)("div",{className:w("text-lg font-semibold tabular-nums",be[J]),"data-testid":"hl-error-rate",children:o===null?"\u2014":O(o.errors,o.requests)})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(me,{}),(0,r.jsx)(ce,{message:Se,prefix:"hl"})]})]})]}),h!==null&&(0,r.jsx)("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-sm text-destructive","data-testid":"hl-metrics-error",role:"alert",children:h})]}),(0,r.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[(0,r.jsx)(_,{chart:C.errors.length>=2?(0,r.jsx)(F,{ariaLabel:a("Errors over time"),className:"h-7 w-20 text-destructive",series:C.errors,testId:"hl-spark-errors"}):void 0,label:a("Error rate"),level:J,testId:"hl-slo-errorrate",value:o===null?"\u2014":O(o.errors,o.requests)}),(0,r.jsx)(_,{chart:Y.failures.length>=2?(0,r.jsx)(F,{ariaLabel:a("Auth failures over time"),className:"h-7 w-20 text-destructive",series:Y.failures,testId:"hl-spark-auth"}):void 0,label:a("Auth failures"),level:ee,testId:"hl-slo-auth",value:m===null?"\u2014":O(m.failures,m.attempts)}),(0,r.jsx)(_,{label:a("Scheduler backlog"),level:te,testId:"hl-slo-backlog",value:v===null?"\u2014":v.backlog.toString()}),(0,r.jsx)(_,{label:a("Migrations"),level:G.level,testId:"hl-slo-migrations",value:Ge(G,a)})]}),(0,r.jsxs)("div",{className:"grid gap-3 lg:grid-cols-2",children:[(0,r.jsxs)(k,{className:"gap-0 py-0","data-testid":"hl-functions",children:[(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Functions by error rate")})}),Z.length===0?(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-functions-empty",children:a("No function activity yet.")}):(0,r.jsx)("ul",{className:"divide-y divide-border",children:Z.map(n=>(0,r.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-xs","data-testid":"hl-fn-row",children:[(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:n.path}),(0,r.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[(0,r.jsx)("span",{className:"tabular-nums text-muted-foreground",children:a("{count} calls",{count:n.calls.toString()})}),(0,r.jsx)(A,{variant:He[W(n.errors/n.calls,he,ge)],children:O(n.errors,n.calls)})]})]},n.path))})]}),(0,r.jsxs)(k,{className:"gap-0 py-0",children:[(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Recent errors")}),(0,r.jsx)(A,{"data-testid":"hl-error-count",variant:U.length>0?"destructive":"outline",children:U.length})]}),d!==null&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:d}),d===null&&B.length===0&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-errors-empty",children:a("No recent errors.")}),B.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:B.map((n,b)=>(0,r.jsxs)("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)("time",{className:"shrink-0 text-muted-foreground",children:ne(n.timestamp)}),n.functionPath!==void 0&&(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:n.functionPath})]}),(0,r.jsx)("span",{className:"text-destructive",children:n.message})]},`${n.timestamp.toString()}-${b.toString()}`))})]})]}),(0,r.jsxs)(k,{className:"gap-0 py-0",children:[(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Shards seen")}),(0,r.jsx)(A,{"data-testid":"hl-shard-count",variant:"outline",children:M.length})]}),M.length>0&&(0,r.jsx)("ul",{className:"flex flex-wrap gap-1.5 p-4",children:M.map(n=>(0,r.jsx)("li",{"data-testid":"hl-shard",children:(0,r.jsx)(A,{variant:"secondary",children:n})},n))})]})]})},"ot");export{pt as HealthPanel};
@@ -1 +1 @@
1
- import{a as ae}from"./chunk-7RXOPYR5.js";import"./chunk-PF7V3G2Z.js";import"./chunk-4UOFSGUS.js";import"./chunk-ILNELDFC.js";import"./chunk-T6VMSOBB.js";import{a as te}from"./chunk-XXQUMVWH.js";import{a as Q,b as U,c as D,e as V}from"./chunk-UZERI5YC.js";import{d as Y,f as ee}from"./chunk-7T7UOTYK.js";import"./chunk-7QIFDWQV.js";import{c as T}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{a as X}from"./chunk-GXZAXNZI.js";import{f as F}from"./chunk-LWECXQWP.js";import"./chunk-XBDKZZ67.js";import{a as H}from"./chunk-XQCVZAGU.js";import{d as W,f as Z,g as G,h as J,m as P}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as C,e as O,f as de,g as le,h as ie}from"./chunk-3XIESWL4.js";var A=O(le(),1),$=O(de(),1);var i=O(ie(),1);var se=Z(X.runSql),re=C((M,e)=>{let a=F(),[m,t]=(0,$.useState)(void 0),[d,s]=(0,$.useState)(void 0),[l,c]=(0,$.useState)(!0),N=(0,$.useCallback)(async r=>{c(!0);try{let w=await a.query(se,{sql:M},G(e));r.cancelled||(t(w),s(void 0))}catch(w){r.cancelled||(t(void 0),s(J(w)))}finally{r.cancelled||c(!1)}},[a,M,e]);return(0,$.useEffect)(()=>{let r={cancelled:!1};return P(N(r)),()=>{r.cancelled=!0}},[N]),{error:d,loading:l,result:m}},"ie"),oe="lunora-studio-dashboards",B={shardKey:"",sql:"",title:""},ne=C(M=>{let e=(0,A.c)(54),{onEdit:a,onRemove:m,widget:t}=M,d=W(),{error:s,loading:l,result:c}=re(t.sql,t.shardKey??""),N;e[0]!==a||e[1]!==t.id?(N=C(()=>{a(t.id)},"C"),e[0]=a,e[1]=t.id,e[2]=N):N=e[2];let r=N,w;e[3]!==m||e[4]!==t.id?(w=C(()=>{m(t.id)},"w"),e[3]=m,e[4]=t.id,e[5]=w):w=e[5];let L=w,_=`dashboards-widget-${t.id}`,q;e[6]!==t.title?(q=(0,i.jsx)(D,{className:"min-w-0 truncate",title:t.title,children:t.title}),e[6]=t.title,e[7]=q):q=e[7];let E;e[8]!==d?(E=d("Edit widget"),e[8]=d,e[9]=E):E=e[9];let j=`dashboards-widget-edit-${t.id}`,R;e[10]!==d?(R=d("Edit widget"),e[10]=d,e[11]=R):R=e[11];let k;e[12]===Symbol.for("react.memo_cache_sentinel")?(k=(0,i.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,i.jsx)("path",{d:"M4 20h4L18 10l-4-4L4 16v4ZM14 6l4 4"})}),e[12]=k):k=e[12];let x;e[13]!==r||e[14]!==E||e[15]!==j||e[16]!==R?(x=(0,i.jsx)(T,{"aria-label":E,"data-testid":j,onClick:r,size:"icon-xs",title:R,type:"button",variant:"ghost",children:k}),e[13]=r,e[14]=E,e[15]=j,e[16]=R,e[17]=x):x=e[17];let p;e[18]!==d?(p=d("Remove widget"),e[18]=d,e[19]=p):p=e[19];let K=`dashboards-widget-remove-${t.id}`,h;e[20]!==d?(h=d("Remove widget"),e[20]=d,e[21]=h):h=e[21];let v;e[22]===Symbol.for("react.memo_cache_sentinel")?(v=(0,i.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,i.jsx)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[22]=v):v=e[22];let u;e[23]!==L||e[24]!==p||e[25]!==K||e[26]!==h?(u=(0,i.jsx)(T,{"aria-label":p,"data-testid":K,onClick:L,size:"icon-xs",title:h,type:"button",variant:"ghost",children:v}),e[23]=L,e[24]=p,e[25]=K,e[26]=h,e[27]=u):u=e[27];let b;e[28]!==u||e[29]!==x?(b=(0,i.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[x,u]}),e[28]=u,e[29]=x,e[30]=b):b=e[30];let g;e[31]!==b||e[32]!==q?(g=(0,i.jsxs)(U,{className:"flex flex-row items-start justify-between gap-2 border-b pb-3",children:[q,b]}),e[31]=b,e[32]=q,e[33]=g):g=e[33];let f;e[34]!==s||e[35]!==t.id?(f=s!==void 0&&(0,i.jsx)(te,{className:"font-mono text-xs",testId:`dashboards-widget-error-${t.id}`,variant:"destructive",children:s}),e[34]=s,e[35]=t.id,e[36]=f):f=e[36];let S;e[37]!==s||e[38]!==l||e[39]!==c||e[40]!==d||e[41]!==t.id?(S=s===void 0&&l&&c===void 0&&(0,i.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":`dashboards-widget-loading-${t.id}`,children:d("Running\u2026")}),e[37]=s,e[38]=l,e[39]=c,e[40]=d,e[41]=t.id,e[42]=S):S=e[42];let o;e[43]!==s||e[44]!==c?(o=s===void 0&&c!==void 0&&(0,i.jsx)(ae,{result:c}),e[43]=s,e[44]=c,e[45]=o):o=e[45];let n;e[46]!==f||e[47]!==S||e[48]!==o?(n=(0,i.jsxs)(V,{className:"min-h-32 py-2",children:[f,S,o]}),e[46]=f,e[47]=S,e[48]=o,e[49]=n):n=e[49];let y;return e[50]!==g||e[51]!==n||e[52]!==_?(y=(0,i.jsxs)(Q,{"data-testid":_,children:[g,n]}),e[50]=g,e[51]=n,e[52]=_,e[53]=y):y=e[53],y},"ae"),ce=C(M=>{let e=(0,A.c)(58),{draft:a,editing:m,onCancel:t,onChange:d,onSubmit:s}=M,l=W(),c;e[0]!==a||e[1]!==d?(c=C(z=>{d({...a,title:z.target.value})},"n"),e[0]=a,e[1]=d,e[2]=c):c=e[2];let N=c,r;e[3]!==a||e[4]!==d?(r=C(z=>{d({...a,sql:z.target.value})},"s"),e[3]=a,e[4]=d,e[5]=r):r=e[5];let w=r,L;e[6]!==a||e[7]!==d?(L=C(z=>{d({...a,shardKey:z.target.value})},"$"),e[6]=a,e[7]=d,e[8]=L):L=e[8];let _=L,q;e[9]!==s?(q=C(()=>{s()},"q"),e[9]=s,e[10]=q):q=e[10];let E=q,j;e[11]!==a.sql||e[12]!==a.title?(j=a.title.trim()!==""&&a.sql.trim()!=="",e[11]=a.sql,e[12]=a.title,e[13]=j):j=e[13];let R=j,k;e[14]!==l?(k=l("Widget title"),e[14]=l,e[15]=k):k=e[15];let x;e[16]!==l?(x=l("Widget title"),e[16]=l,e[17]=x):x=e[17];let p;e[18]!==a.title||e[19]!==N||e[20]!==k||e[21]!==x?(p=(0,i.jsx)("input",{"aria-label":k,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:N,placeholder:x,type:"text",value:a.title}),e[18]=a.title,e[19]=N,e[20]=k,e[21]=x,e[22]=p):p=e[22];let K;e[23]!==l?(K=l("SQL query"),e[23]=l,e[24]=K):K=e[24];let h;e[25]!==a.sql||e[26]!==w||e[27]!==K?(h=(0,i.jsx)("textarea",{"aria-label":K,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:w,placeholder:"SELECT author, COUNT(*) AS messages FROM \u2026",spellCheck:!1,value:a.sql}),e[25]=a.sql,e[26]=w,e[27]=K,e[28]=h):h=e[28];let v;e[29]!==l?(v=l("Shard key (optional)"),e[29]=l,e[30]=v):v=e[30];let u;e[31]!==l?(u=l("Shard key (optional)"),e[31]=l,e[32]=u):u=e[32];let b;e[33]!==a.shardKey||e[34]!==_||e[35]!==v||e[36]!==u?(b=(0,i.jsx)("input",{"aria-label":v,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:_,placeholder:u,type:"text",value:a.shardKey}),e[33]=a.shardKey,e[34]=_,e[35]=v,e[36]=u,e[37]=b):b=e[37];let g;e[38]!==l?(g=l("Cancel"),e[38]=l,e[39]=g):g=e[39];let f;e[40]!==t||e[41]!==g?(f=(0,i.jsx)(T,{"data-testid":"dashboards-form-cancel",onClick:t,size:"sm",type:"button",variant:"outline",children:g}),e[40]=t,e[41]=g,e[42]=f):f=e[42];let S=!R,o;e[43]!==m||e[44]!==l?(o=l(m?"Save widget":"Add widget"),e[43]=m,e[44]=l,e[45]=o):o=e[45];let n;e[46]!==E||e[47]!==S||e[48]!==o?(n=(0,i.jsx)(T,{"data-testid":"dashboards-form-save",disabled:S,onClick:E,size:"sm",type:"button",children:o}),e[46]=E,e[47]=S,e[48]=o,e[49]=n):n=e[49];let y;e[50]!==f||e[51]!==n?(y=(0,i.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[f,n]}),e[50]=f,e[51]=n,e[52]=y):y=e[52];let I;return e[53]!==h||e[54]!==b||e[55]!==y||e[56]!==p?(I=(0,i.jsx)(Q,{"data-testid":"dashboards-form",children:(0,i.jsxs)(V,{className:"flex flex-col gap-3 py-4",children:[p,h,b,y]})}),e[53]=h,e[54]=b,e[55]=y,e[56]=p,e[57]=I):I=e[57],I},"oe"),we=C(M=>{let e=(0,A.c)(39),{initialShardKey:a}=M,m=W(),[t,d]=Y(oe),[s,l]=(0,$.useState)(B),[c,N]=(0,$.useState)(null),[r,w]=(0,$.useState)(!1),L;e[0]!==a?(L=C(()=>{N(null),l({...B,shardKey:a??""}),w(!0)},"$"),e[0]=a,e[1]=L):L=e[1];let _=L,q;e[2]===Symbol.for("react.memo_cache_sentinel")?(q=C(()=>{w(!1),N(null),l(B)},"q"),e[2]=q):q=e[2];let E=q,j;e[3]!==t?(j=C(o=>{let n=t.find(y=>y.id===o);n!==void 0&&(N(o),l({shardKey:n.shardKey??"",sql:n.sql,title:n.title}),w(!0))},"L"),e[3]=t,e[4]=j):j=e[4];let R=j,k;e[5]!==d?(k=C(o=>{d(n=>n.filter(y=>y.id!==o))},"k"),e[5]=d,e[6]=k):k=e[6];let x=k,p;e[7]!==s.shardKey||e[8]!==s.sql||e[9]!==s.title||e[10]!==c||e[11]!==d?(p=C(()=>{let o=s.title.trim(),n=s.sql.trim();if(o===""||n==="")return;let y=s.shardKey.trim();d(c===null?I=>[...I,{id:ee("w"),shardKey:y,sql:n,title:o}]:I=>I.map(z=>z.id===c?{...z,shardKey:y,sql:n,title:o}:z)),E()},"p"),e[7]=s.shardKey,e[8]=s.sql,e[9]=s.title,e[10]=c,e[11]=d,e[12]=p):p=e[12];let K=p,h;e[13]!==m?(h=m("Chart widgets backed by saved read-only SQL queries."),e[13]=m,e[14]=h):h=e[14];let v;e[15]!==h?(v=(0,i.jsx)("p",{className:"text-sm text-muted-foreground",children:h}),e[15]=h,e[16]=v):v=e[16];let u;e[17]!==r||e[18]!==_||e[19]!==m?(u=!r&&(0,i.jsx)(T,{"data-testid":"dashboards-add",onClick:_,size:"sm",type:"button",children:m("Add widget")}),e[17]=r,e[18]=_,e[19]=m,e[20]=u):u=e[20];let b;e[21]!==v||e[22]!==u?(b=(0,i.jsxs)("div",{className:"flex items-center justify-between",children:[v,u]}),e[21]=v,e[22]=u,e[23]=b):b=e[23];let g;e[24]!==s||e[25]!==c||e[26]!==r||e[27]!==K?(g=r&&(0,i.jsx)(ce,{draft:s,editing:c!==null,onCancel:E,onChange:l,onSubmit:K}),e[24]=s,e[25]=c,e[26]=r,e[27]=K,e[28]=g):g=e[28];let f;e[29]!==r||e[30]!==R||e[31]!==x||e[32]!==m||e[33]!==t?(f=t.length===0&&!r?(0,i.jsx)(H,{description:m("Add a widget to chart a saved SQL query on this browser."),testId:"dashboards-empty",title:m("No widgets yet")}):(0,i.jsx)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3","data-testid":"dashboards-grid",children:t.map(o=>(0,i.jsx)(ne,{onEdit:R,onRemove:x,widget:o},o.id))}),e[29]=r,e[30]=R,e[31]=x,e[32]=m,e[33]=t,e[34]=f):f=e[34];let S;return e[35]!==g||e[36]!==f||e[37]!==b?(S=(0,i.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-dashboards",children:[b,g,f]}),e[35]=g,e[36]=f,e[37]=b,e[38]=S):S=e[38],S},"qe");export{we as default};
1
+ import{a as ae}from"./chunk-7RXOPYR5.js";import"./chunk-PF7V3G2Z.js";import"./chunk-4UOFSGUS.js";import"./chunk-ILNELDFC.js";import"./chunk-T6VMSOBB.js";import{a as te}from"./chunk-XXQUMVWH.js";import{a as Q,b as U,c as D,e as V}from"./chunk-UZERI5YC.js";import{d as Y,f as ee}from"./chunk-7T7UOTYK.js";import"./chunk-7QIFDWQV.js";import{c as T}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{a as X}from"./chunk-GXZAXNZI.js";import{f as F}from"./chunk-35II7U25.js";import"./chunk-XBDKZZ67.js";import{a as H}from"./chunk-XQCVZAGU.js";import{d as W,f as Z,g as G,h as J,m as P}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as C,e as O,f as de,g as le,h as ie}from"./chunk-3XIESWL4.js";var A=O(le(),1),$=O(de(),1);var i=O(ie(),1);var se=Z(X.runSql),re=C((M,e)=>{let a=F(),[m,t]=(0,$.useState)(void 0),[d,s]=(0,$.useState)(void 0),[l,c]=(0,$.useState)(!0),N=(0,$.useCallback)(async r=>{c(!0);try{let w=await a.query(se,{sql:M},G(e));r.cancelled||(t(w),s(void 0))}catch(w){r.cancelled||(t(void 0),s(J(w)))}finally{r.cancelled||c(!1)}},[a,M,e]);return(0,$.useEffect)(()=>{let r={cancelled:!1};return P(N(r)),()=>{r.cancelled=!0}},[N]),{error:d,loading:l,result:m}},"ie"),oe="lunora-studio-dashboards",B={shardKey:"",sql:"",title:""},ne=C(M=>{let e=(0,A.c)(54),{onEdit:a,onRemove:m,widget:t}=M,d=W(),{error:s,loading:l,result:c}=re(t.sql,t.shardKey??""),N;e[0]!==a||e[1]!==t.id?(N=C(()=>{a(t.id)},"C"),e[0]=a,e[1]=t.id,e[2]=N):N=e[2];let r=N,w;e[3]!==m||e[4]!==t.id?(w=C(()=>{m(t.id)},"w"),e[3]=m,e[4]=t.id,e[5]=w):w=e[5];let L=w,_=`dashboards-widget-${t.id}`,q;e[6]!==t.title?(q=(0,i.jsx)(D,{className:"min-w-0 truncate",title:t.title,children:t.title}),e[6]=t.title,e[7]=q):q=e[7];let E;e[8]!==d?(E=d("Edit widget"),e[8]=d,e[9]=E):E=e[9];let j=`dashboards-widget-edit-${t.id}`,R;e[10]!==d?(R=d("Edit widget"),e[10]=d,e[11]=R):R=e[11];let k;e[12]===Symbol.for("react.memo_cache_sentinel")?(k=(0,i.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,i.jsx)("path",{d:"M4 20h4L18 10l-4-4L4 16v4ZM14 6l4 4"})}),e[12]=k):k=e[12];let x;e[13]!==r||e[14]!==E||e[15]!==j||e[16]!==R?(x=(0,i.jsx)(T,{"aria-label":E,"data-testid":j,onClick:r,size:"icon-xs",title:R,type:"button",variant:"ghost",children:k}),e[13]=r,e[14]=E,e[15]=j,e[16]=R,e[17]=x):x=e[17];let p;e[18]!==d?(p=d("Remove widget"),e[18]=d,e[19]=p):p=e[19];let K=`dashboards-widget-remove-${t.id}`,h;e[20]!==d?(h=d("Remove widget"),e[20]=d,e[21]=h):h=e[21];let v;e[22]===Symbol.for("react.memo_cache_sentinel")?(v=(0,i.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,i.jsx)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[22]=v):v=e[22];let u;e[23]!==L||e[24]!==p||e[25]!==K||e[26]!==h?(u=(0,i.jsx)(T,{"aria-label":p,"data-testid":K,onClick:L,size:"icon-xs",title:h,type:"button",variant:"ghost",children:v}),e[23]=L,e[24]=p,e[25]=K,e[26]=h,e[27]=u):u=e[27];let b;e[28]!==u||e[29]!==x?(b=(0,i.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[x,u]}),e[28]=u,e[29]=x,e[30]=b):b=e[30];let g;e[31]!==b||e[32]!==q?(g=(0,i.jsxs)(U,{className:"flex flex-row items-start justify-between gap-2 border-b pb-3",children:[q,b]}),e[31]=b,e[32]=q,e[33]=g):g=e[33];let f;e[34]!==s||e[35]!==t.id?(f=s!==void 0&&(0,i.jsx)(te,{className:"font-mono text-xs",testId:`dashboards-widget-error-${t.id}`,variant:"destructive",children:s}),e[34]=s,e[35]=t.id,e[36]=f):f=e[36];let S;e[37]!==s||e[38]!==l||e[39]!==c||e[40]!==d||e[41]!==t.id?(S=s===void 0&&l&&c===void 0&&(0,i.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":`dashboards-widget-loading-${t.id}`,children:d("Running\u2026")}),e[37]=s,e[38]=l,e[39]=c,e[40]=d,e[41]=t.id,e[42]=S):S=e[42];let o;e[43]!==s||e[44]!==c?(o=s===void 0&&c!==void 0&&(0,i.jsx)(ae,{result:c}),e[43]=s,e[44]=c,e[45]=o):o=e[45];let n;e[46]!==f||e[47]!==S||e[48]!==o?(n=(0,i.jsxs)(V,{className:"min-h-32 py-2",children:[f,S,o]}),e[46]=f,e[47]=S,e[48]=o,e[49]=n):n=e[49];let y;return e[50]!==g||e[51]!==n||e[52]!==_?(y=(0,i.jsxs)(Q,{"data-testid":_,children:[g,n]}),e[50]=g,e[51]=n,e[52]=_,e[53]=y):y=e[53],y},"ae"),ce=C(M=>{let e=(0,A.c)(58),{draft:a,editing:m,onCancel:t,onChange:d,onSubmit:s}=M,l=W(),c;e[0]!==a||e[1]!==d?(c=C(z=>{d({...a,title:z.target.value})},"n"),e[0]=a,e[1]=d,e[2]=c):c=e[2];let N=c,r;e[3]!==a||e[4]!==d?(r=C(z=>{d({...a,sql:z.target.value})},"s"),e[3]=a,e[4]=d,e[5]=r):r=e[5];let w=r,L;e[6]!==a||e[7]!==d?(L=C(z=>{d({...a,shardKey:z.target.value})},"$"),e[6]=a,e[7]=d,e[8]=L):L=e[8];let _=L,q;e[9]!==s?(q=C(()=>{s()},"q"),e[9]=s,e[10]=q):q=e[10];let E=q,j;e[11]!==a.sql||e[12]!==a.title?(j=a.title.trim()!==""&&a.sql.trim()!=="",e[11]=a.sql,e[12]=a.title,e[13]=j):j=e[13];let R=j,k;e[14]!==l?(k=l("Widget title"),e[14]=l,e[15]=k):k=e[15];let x;e[16]!==l?(x=l("Widget title"),e[16]=l,e[17]=x):x=e[17];let p;e[18]!==a.title||e[19]!==N||e[20]!==k||e[21]!==x?(p=(0,i.jsx)("input",{"aria-label":k,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:N,placeholder:x,type:"text",value:a.title}),e[18]=a.title,e[19]=N,e[20]=k,e[21]=x,e[22]=p):p=e[22];let K;e[23]!==l?(K=l("SQL query"),e[23]=l,e[24]=K):K=e[24];let h;e[25]!==a.sql||e[26]!==w||e[27]!==K?(h=(0,i.jsx)("textarea",{"aria-label":K,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:w,placeholder:"SELECT author, COUNT(*) AS messages FROM \u2026",spellCheck:!1,value:a.sql}),e[25]=a.sql,e[26]=w,e[27]=K,e[28]=h):h=e[28];let v;e[29]!==l?(v=l("Shard key (optional)"),e[29]=l,e[30]=v):v=e[30];let u;e[31]!==l?(u=l("Shard key (optional)"),e[31]=l,e[32]=u):u=e[32];let b;e[33]!==a.shardKey||e[34]!==_||e[35]!==v||e[36]!==u?(b=(0,i.jsx)("input",{"aria-label":v,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:_,placeholder:u,type:"text",value:a.shardKey}),e[33]=a.shardKey,e[34]=_,e[35]=v,e[36]=u,e[37]=b):b=e[37];let g;e[38]!==l?(g=l("Cancel"),e[38]=l,e[39]=g):g=e[39];let f;e[40]!==t||e[41]!==g?(f=(0,i.jsx)(T,{"data-testid":"dashboards-form-cancel",onClick:t,size:"sm",type:"button",variant:"outline",children:g}),e[40]=t,e[41]=g,e[42]=f):f=e[42];let S=!R,o;e[43]!==m||e[44]!==l?(o=l(m?"Save widget":"Add widget"),e[43]=m,e[44]=l,e[45]=o):o=e[45];let n;e[46]!==E||e[47]!==S||e[48]!==o?(n=(0,i.jsx)(T,{"data-testid":"dashboards-form-save",disabled:S,onClick:E,size:"sm",type:"button",children:o}),e[46]=E,e[47]=S,e[48]=o,e[49]=n):n=e[49];let y;e[50]!==f||e[51]!==n?(y=(0,i.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[f,n]}),e[50]=f,e[51]=n,e[52]=y):y=e[52];let I;return e[53]!==h||e[54]!==b||e[55]!==y||e[56]!==p?(I=(0,i.jsx)(Q,{"data-testid":"dashboards-form",children:(0,i.jsxs)(V,{className:"flex flex-col gap-3 py-4",children:[p,h,b,y]})}),e[53]=h,e[54]=b,e[55]=y,e[56]=p,e[57]=I):I=e[57],I},"oe"),we=C(M=>{let e=(0,A.c)(39),{initialShardKey:a}=M,m=W(),[t,d]=Y(oe),[s,l]=(0,$.useState)(B),[c,N]=(0,$.useState)(null),[r,w]=(0,$.useState)(!1),L;e[0]!==a?(L=C(()=>{N(null),l({...B,shardKey:a??""}),w(!0)},"$"),e[0]=a,e[1]=L):L=e[1];let _=L,q;e[2]===Symbol.for("react.memo_cache_sentinel")?(q=C(()=>{w(!1),N(null),l(B)},"q"),e[2]=q):q=e[2];let E=q,j;e[3]!==t?(j=C(o=>{let n=t.find(y=>y.id===o);n!==void 0&&(N(o),l({shardKey:n.shardKey??"",sql:n.sql,title:n.title}),w(!0))},"L"),e[3]=t,e[4]=j):j=e[4];let R=j,k;e[5]!==d?(k=C(o=>{d(n=>n.filter(y=>y.id!==o))},"k"),e[5]=d,e[6]=k):k=e[6];let x=k,p;e[7]!==s.shardKey||e[8]!==s.sql||e[9]!==s.title||e[10]!==c||e[11]!==d?(p=C(()=>{let o=s.title.trim(),n=s.sql.trim();if(o===""||n==="")return;let y=s.shardKey.trim();d(c===null?I=>[...I,{id:ee("w"),shardKey:y,sql:n,title:o}]:I=>I.map(z=>z.id===c?{...z,shardKey:y,sql:n,title:o}:z)),E()},"p"),e[7]=s.shardKey,e[8]=s.sql,e[9]=s.title,e[10]=c,e[11]=d,e[12]=p):p=e[12];let K=p,h;e[13]!==m?(h=m("Chart widgets backed by saved read-only SQL queries."),e[13]=m,e[14]=h):h=e[14];let v;e[15]!==h?(v=(0,i.jsx)("p",{className:"text-sm text-muted-foreground",children:h}),e[15]=h,e[16]=v):v=e[16];let u;e[17]!==r||e[18]!==_||e[19]!==m?(u=!r&&(0,i.jsx)(T,{"data-testid":"dashboards-add",onClick:_,size:"sm",type:"button",children:m("Add widget")}),e[17]=r,e[18]=_,e[19]=m,e[20]=u):u=e[20];let b;e[21]!==v||e[22]!==u?(b=(0,i.jsxs)("div",{className:"flex items-center justify-between",children:[v,u]}),e[21]=v,e[22]=u,e[23]=b):b=e[23];let g;e[24]!==s||e[25]!==c||e[26]!==r||e[27]!==K?(g=r&&(0,i.jsx)(ce,{draft:s,editing:c!==null,onCancel:E,onChange:l,onSubmit:K}),e[24]=s,e[25]=c,e[26]=r,e[27]=K,e[28]=g):g=e[28];let f;e[29]!==r||e[30]!==R||e[31]!==x||e[32]!==m||e[33]!==t?(f=t.length===0&&!r?(0,i.jsx)(H,{description:m("Add a widget to chart a saved SQL query on this browser."),testId:"dashboards-empty",title:m("No widgets yet")}):(0,i.jsx)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3","data-testid":"dashboards-grid",children:t.map(o=>(0,i.jsx)(ne,{onEdit:R,onRemove:x,widget:o},o.id))}),e[29]=r,e[30]=R,e[31]=x,e[32]=m,e[33]=t,e[34]=f):f=e[34];let S;return e[35]!==g||e[36]!==f||e[37]!==b?(S=(0,i.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-dashboards",children:[b,g,f]}),e[35]=g,e[36]=f,e[37]=b,e[38]=S):S=e[38],S},"qe");export{we as default};
@@ -1,2 +1,2 @@
1
- import{a as B}from"./chunk-LEDWUPXM.js";import"./chunk-2PJNAWB3.js";import{a as k}from"./chunk-IC4L6G56.js";import{a as D}from"./chunk-54MMVNPT.js";import"./chunk-BGBLQ563.js";import{a as P}from"./chunk-UNUU7CJJ.js";import"./chunk-XXQUMVWH.js";import{b as q}from"./chunk-OWADN6BI.js";import{R as I}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as H}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as f}from"./chunk-GXZAXNZI.js";import{f as A}from"./chunk-LWECXQWP.js";import"./chunk-XBDKZZ67.js";import{a as O}from"./chunk-XQCVZAGU.js";import{d as F,f as v,g as N,h as w,m as y,o as _,q as C}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as s,e as $,f as se,h as de,j as E}from"./chunk-3XIESWL4.js";var l=$(se(),1);var e=$(de(),1);function le({className:r,orientation:h="horizontal",...a}){return(0,e.jsx)(k,{"data-slot":"separator",orientation:h,className:E("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",r),...a})}s(le,"de");var oe=v(f.clearCapturedMail),ne=v(f.sendTestMail),ce=/https?:\/\/[^\s"'<>)]+/i,K=s(r=>r===void 0?void 0:ce.exec(r)?.[0],"S"),me=s(r=>{if(r!==void 0)return K(r.html)??K(r.text)},"ce"),ue=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">`,he=s(r=>`${ue}${r}`,"ue"),x=s(r=>r===void 0?"":Array.isArray(r)?r.join(", "):r,"f"),Le=s(({limit:r=100})=>{let h=A(),a=F(),{data:j,error:T,errorSource:R,isLoading:U,refetch:g}=q(f.getCapturedMail,{limit:r}),[z,p]=(0,l.useState)(null),[M,S]=(0,l.useState)(null),[m,W]=(0,l.useState)("html"),[b,G]=(0,l.useState)(""),o=(0,l.useMemo)(()=>j?.entries??[],[j]),L=T??z,J=T===null?z:R,Q=s(async()=>{p(null);try{await h.query(oe,{},N("")),S(null),g()}catch(t){p(w(t))}},"I"),V=s(async()=>{p(null);try{await h.query(ne,{},N("")),g()}catch(t){p(w(t))}},"_");D(()=>{g()},!0);let X=s(()=>{y(Q())},"q"),Y=s(()=>{y(V())},"P"),Z=s(t=>{G(t.currentTarget.value)},"D"),ee=s(t=>{let{id:d}=t.currentTarget.dataset;d!==void 0&&S(d)},"R"),te=s(t=>{let d=t.currentTarget.dataset.tab;(d==="headers"||d==="html"||d==="text")&&W(d)},"B"),ae=s(t=>a(t==="html"?"HTML":t==="text"?"Plain text":"Headers"),"K"),u=(0,l.useMemo)(()=>{let t=b.trim().toLowerCase();return t===""?o:o.filter(d=>`${d.subject} ${x(d.to)}`.toLowerCase().includes(t))},[o,b]),i=(0,l.useMemo)(()=>{if(u.length!==0)return u.find(t=>t.id===M)??u[0]},[u,M]),n=me(i),re=s(()=>{n!==void 0&&_(n)},"U"),ie=s(()=>{n!==void 0&&"window"in globalThis&&globalThis.window.open(n,"_blank","noopener")},"W");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"mail-panel",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(c,{"data-testid":"mail-send-test",onClick:Y,size:"sm",type:"button",variant:"outline",children:a("Send test")}),(0,e.jsx)(c,{"data-testid":"mail-clear",disabled:o.length===0,onClick:X,size:"sm",type:"button",variant:"outline",children:a("Clear inbox")}),o.length>0&&(0,e.jsx)(H,{className:"ml-auto","data-testid":"mail-count",variant:"secondary",children:a("{count} messages",{count:o.length})})]}),L!==null&&(0,e.jsx)(P,{error:J,testId:"mail-error"}),L===null&&!U&&o.length===0&&(0,e.jsx)(O,{description:a("Email your app sends in dev is captured here \u2014 nothing is delivered."),icon:(0,e.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,e.jsx)("path",{d:"M4 5h16v14H4z"}),(0,e.jsx)("path",{d:"m4 6 8 6 8-6"})]}),testId:"mail-empty",title:a("No captured email.")}),o.length>0&&(0,e.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-[minmax(0,22rem)_1fr]","data-testid":"mail-reader",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,e.jsx)(I,{"aria-label":a("Search messages"),"data-testid":"mail-search",onChange:Z,placeholder:a("Filter messages"),type:"search",value:b}),(0,e.jsx)(B,{className:"max-h-[32rem] rounded-xl border border-border bg-card shadow-xs","data-testid":"mail-list",children:(0,e.jsx)("ul",{className:"divide-y",children:u.map(t=>{let d=t.id===i?.id;return(0,e.jsx)("li",{children:(0,e.jsxs)("button",{className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-sm hover:bg-muted/60 ${d?"bg-muted":""}`,"data-active":d,"data-id":t.id,"data-testid":"mail-list-item",onClick:ee,type:"button",children:[(0,e.jsx)("span",{className:"w-full truncate font-medium",children:t.subject||a("(no subject)")}),(0,e.jsx)("span",{className:"w-full truncate text-xs text-muted-foreground",children:x(t.to)}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground tabular-nums",children:C(t.capturedAt,"\u2014")})]})},t.id)})})})]}),i!==void 0&&(0,e.jsxs)("div",{className:"flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"mail-detail",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)("h2",{className:"truncate text-base font-semibold","data-testid":"mail-subject",children:i.subject||a("(no subject)")}),(0,e.jsxs)("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs text-muted-foreground",children:[(0,e.jsx)("dt",{children:a("From")}),(0,e.jsx)("dd",{className:"truncate font-mono",children:i.from??"\u2014"}),(0,e.jsx)("dt",{children:a("To")}),(0,e.jsx)("dd",{className:"truncate font-mono",children:x(i.to)}),i.cc!==void 0&&i.cc.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("dt",{children:a("Cc")}),(0,e.jsx)("dd",{className:"truncate font-mono",children:x(i.cc)})]}),(0,e.jsx)("dt",{children:a("Sent")}),(0,e.jsx)("dd",{className:"tabular-nums",children:C(i.capturedAt,"\u2014")})]})]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2","data-testid":"mail-actions",children:[(0,e.jsx)(c,{"data-testid":"mail-copy-link",disabled:n===void 0,onClick:re,size:"sm",type:"button",variant:"outline",children:a("Copy link")}),(0,e.jsx)(c,{"data-testid":"mail-open-link",disabled:n===void 0,onClick:ie,size:"sm",type:"button",variant:"outline",children:a("Open in new tab")})]}),(0,e.jsx)(le,{}),(0,e.jsx)("div",{className:"flex items-center gap-1","data-testid":"mail-tabs",role:"tablist",children:["html","text","headers"].map(t=>(0,e.jsx)(c,{"aria-selected":m===t,"data-tab":t,"data-testid":`mail-tab-${t}`,onClick:te,role:"tab",size:"sm",type:"button",variant:m===t?"secondary":"ghost",children:ae(t)},t))}),(0,e.jsxs)("div",{className:"min-h-[12rem]",children:[m==="html"&&(i.html===void 0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:a("No HTML body.")}):(0,e.jsx)("iframe",{className:"h-[24rem] w-full rounded-md border bg-white","data-testid":"mail-preview-html",sandbox:"",srcDoc:he(i.html),title:a("Email preview")})),m==="text"&&(i.text===void 0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:a("No text body.")}):(0,e.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-text",children:i.text})),m==="headers"&&(i.headers===void 0||Object.keys(i.headers).length===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:a("No headers.")}):(0,e.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-headers",children:Object.entries(i.headers).map(([t,d])=>`${t}: ${d}`).join(`
1
+ import{a as B}from"./chunk-LEDWUPXM.js";import"./chunk-2PJNAWB3.js";import{a as k}from"./chunk-IC4L6G56.js";import{a as D}from"./chunk-54MMVNPT.js";import"./chunk-BGBLQ563.js";import{a as P}from"./chunk-UNUU7CJJ.js";import"./chunk-XXQUMVWH.js";import{b as q}from"./chunk-XSD4Y6SQ.js";import{R as I}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as H}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as f}from"./chunk-GXZAXNZI.js";import{f as A}from"./chunk-35II7U25.js";import"./chunk-XBDKZZ67.js";import{a as O}from"./chunk-XQCVZAGU.js";import{d as F,f as v,g as N,h as w,m as y,o as _,q as C}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as s,e as $,f as se,h as de,j as E}from"./chunk-3XIESWL4.js";var l=$(se(),1);var e=$(de(),1);function le({className:r,orientation:h="horizontal",...a}){return(0,e.jsx)(k,{"data-slot":"separator",orientation:h,className:E("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",r),...a})}s(le,"de");var oe=v(f.clearCapturedMail),ne=v(f.sendTestMail),ce=/https?:\/\/[^\s"'<>)]+/i,K=s(r=>r===void 0?void 0:ce.exec(r)?.[0],"S"),me=s(r=>{if(r!==void 0)return K(r.html)??K(r.text)},"ce"),ue=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">`,he=s(r=>`${ue}${r}`,"ue"),x=s(r=>r===void 0?"":Array.isArray(r)?r.join(", "):r,"f"),Le=s(({limit:r=100})=>{let h=A(),a=F(),{data:j,error:T,errorSource:R,isLoading:U,refetch:g}=q(f.getCapturedMail,{limit:r}),[z,p]=(0,l.useState)(null),[M,S]=(0,l.useState)(null),[m,W]=(0,l.useState)("html"),[b,G]=(0,l.useState)(""),o=(0,l.useMemo)(()=>j?.entries??[],[j]),L=T??z,J=T===null?z:R,Q=s(async()=>{p(null);try{await h.query(oe,{},N("")),S(null),g()}catch(t){p(w(t))}},"I"),V=s(async()=>{p(null);try{await h.query(ne,{},N("")),g()}catch(t){p(w(t))}},"_");D(()=>{g()},!0);let X=s(()=>{y(Q())},"q"),Y=s(()=>{y(V())},"P"),Z=s(t=>{G(t.currentTarget.value)},"D"),ee=s(t=>{let{id:d}=t.currentTarget.dataset;d!==void 0&&S(d)},"R"),te=s(t=>{let d=t.currentTarget.dataset.tab;(d==="headers"||d==="html"||d==="text")&&W(d)},"B"),ae=s(t=>a(t==="html"?"HTML":t==="text"?"Plain text":"Headers"),"K"),u=(0,l.useMemo)(()=>{let t=b.trim().toLowerCase();return t===""?o:o.filter(d=>`${d.subject} ${x(d.to)}`.toLowerCase().includes(t))},[o,b]),i=(0,l.useMemo)(()=>{if(u.length!==0)return u.find(t=>t.id===M)??u[0]},[u,M]),n=me(i),re=s(()=>{n!==void 0&&_(n)},"U"),ie=s(()=>{n!==void 0&&"window"in globalThis&&globalThis.window.open(n,"_blank","noopener")},"W");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"mail-panel",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(c,{"data-testid":"mail-send-test",onClick:Y,size:"sm",type:"button",variant:"outline",children:a("Send test")}),(0,e.jsx)(c,{"data-testid":"mail-clear",disabled:o.length===0,onClick:X,size:"sm",type:"button",variant:"outline",children:a("Clear inbox")}),o.length>0&&(0,e.jsx)(H,{className:"ml-auto","data-testid":"mail-count",variant:"secondary",children:a("{count} messages",{count:o.length})})]}),L!==null&&(0,e.jsx)(P,{error:J,testId:"mail-error"}),L===null&&!U&&o.length===0&&(0,e.jsx)(O,{description:a("Email your app sends in dev is captured here \u2014 nothing is delivered."),icon:(0,e.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,e.jsx)("path",{d:"M4 5h16v14H4z"}),(0,e.jsx)("path",{d:"m4 6 8 6 8-6"})]}),testId:"mail-empty",title:a("No captured email.")}),o.length>0&&(0,e.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-[minmax(0,22rem)_1fr]","data-testid":"mail-reader",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,e.jsx)(I,{"aria-label":a("Search messages"),"data-testid":"mail-search",onChange:Z,placeholder:a("Filter messages"),type:"search",value:b}),(0,e.jsx)(B,{className:"max-h-[32rem] rounded-xl border border-border bg-card shadow-xs","data-testid":"mail-list",children:(0,e.jsx)("ul",{className:"divide-y",children:u.map(t=>{let d=t.id===i?.id;return(0,e.jsx)("li",{children:(0,e.jsxs)("button",{className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-sm hover:bg-muted/60 ${d?"bg-muted":""}`,"data-active":d,"data-id":t.id,"data-testid":"mail-list-item",onClick:ee,type:"button",children:[(0,e.jsx)("span",{className:"w-full truncate font-medium",children:t.subject||a("(no subject)")}),(0,e.jsx)("span",{className:"w-full truncate text-xs text-muted-foreground",children:x(t.to)}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground tabular-nums",children:C(t.capturedAt,"\u2014")})]})},t.id)})})})]}),i!==void 0&&(0,e.jsxs)("div",{className:"flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"mail-detail",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)("h2",{className:"truncate text-base font-semibold","data-testid":"mail-subject",children:i.subject||a("(no subject)")}),(0,e.jsxs)("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs text-muted-foreground",children:[(0,e.jsx)("dt",{children:a("From")}),(0,e.jsx)("dd",{className:"truncate font-mono",children:i.from??"\u2014"}),(0,e.jsx)("dt",{children:a("To")}),(0,e.jsx)("dd",{className:"truncate font-mono",children:x(i.to)}),i.cc!==void 0&&i.cc.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("dt",{children:a("Cc")}),(0,e.jsx)("dd",{className:"truncate font-mono",children:x(i.cc)})]}),(0,e.jsx)("dt",{children:a("Sent")}),(0,e.jsx)("dd",{className:"tabular-nums",children:C(i.capturedAt,"\u2014")})]})]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2","data-testid":"mail-actions",children:[(0,e.jsx)(c,{"data-testid":"mail-copy-link",disabled:n===void 0,onClick:re,size:"sm",type:"button",variant:"outline",children:a("Copy link")}),(0,e.jsx)(c,{"data-testid":"mail-open-link",disabled:n===void 0,onClick:ie,size:"sm",type:"button",variant:"outline",children:a("Open in new tab")})]}),(0,e.jsx)(le,{}),(0,e.jsx)("div",{className:"flex items-center gap-1","data-testid":"mail-tabs",role:"tablist",children:["html","text","headers"].map(t=>(0,e.jsx)(c,{"aria-selected":m===t,"data-tab":t,"data-testid":`mail-tab-${t}`,onClick:te,role:"tab",size:"sm",type:"button",variant:m===t?"secondary":"ghost",children:ae(t)},t))}),(0,e.jsxs)("div",{className:"min-h-[12rem]",children:[m==="html"&&(i.html===void 0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:a("No HTML body.")}):(0,e.jsx)("iframe",{className:"h-[24rem] w-full rounded-md border bg-white","data-testid":"mail-preview-html",sandbox:"",srcDoc:he(i.html),title:a("Email preview")})),m==="text"&&(i.text===void 0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:a("No text body.")}):(0,e.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-text",children:i.text})),m==="headers"&&(i.headers===void 0||Object.keys(i.headers).length===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:a("No headers.")}):(0,e.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-headers",children:Object.entries(i.headers).map(([t,d])=>`${t}: ${d}`).join(`
2
2
  `)}))]})]})]})]})},"ze");export{Le as MailPanel};
@@ -1 +1 @@
1
- import{a as D}from"./chunk-54MMVNPT.js";import{a as B}from"./chunk-OWADN6BI.js";import{a as q,b as E,c as M,d as S,e as r,f as s}from"./chunk-MIQTKZAR.js";import{a as A,e as L}from"./chunk-UZERI5YC.js";import{b as x}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{f as W}from"./chunk-LWECXQWP.js";import"./chunk-XBDKZZ67.js";import{a as _}from"./chunk-XQCVZAGU.js";import{d as z}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as R,e as O,g as $,h as I}from"./chunk-3XIESWL4.js";var F=O($(),1);var n=O(I(),1);var J=2e3,Q=new Set(["open"]),re=R(G=>{let e=(0,F.c)(41),{read:y}=G,t=z(),j=W(),v;e[0]!==j||e[1]!==y?(v=R(()=>Promise.resolve(y?y():j.debug()),"S"),e[0]=j,e[1]=y,e[2]=v):v=e[2];let H=v,K=y?"injected":"live",b;e[3]!==K?(b=["lunora-studio","sync-client-debug",K],e[3]=K,e[4]=b):b=e[4];let{data:c,refetch:Y}=B(b,H);if(D(Y,!0,J),!c){let i;e[5]!==t?(i=t("Reading the sync client's state\u2026"),e[5]=t,e[6]=i):i=e[6];let g;e[7]!==t?(g=t("Sync client"),e[7]=t,e[8]=g):g=e[8];let T;return e[9]!==i||e[10]!==g?(T=(0,n.jsx)(A,{children:(0,n.jsx)(L,{children:(0,n.jsx)(_,{description:i,title:g})})}),e[9]=i,e[10]=g,e[11]=T):T=e[11],T}let{pendingWrites:k,shards:N,subscriptions:w}=c,l;e[12]!==t?(l=t("This Studio session's sync client"),e[12]=t,e[13]=l):l=e[13];let a;e[14]!==l?(a=(0,n.jsx)("span",{className:"text-sm font-medium",children:l}),e[14]=l,e[15]=a):a=e[15];let P=c.connectionStatus==="connected"?"default":"secondary",o;e[16]!==c.connectionStatus||e[17]!==P?(o=(0,n.jsx)(x,{variant:P,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=P,e[18]=o):o=e[18];let d;e[19]!==k||e[20]!==t?(d=k>0?(0,n.jsx)(x,{variant:"secondary",children:t("{count} pending writes",{count:k})}):null,e[19]=k,e[20]=t,e[21]=d):d=e[21];let h;e[22]!==a||e[23]!==o||e[24]!==d?(h=(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[a,o,d]}),e[22]=a,e[23]=o,e[24]=d,e[25]=h):h=e[25];let u;e[26]!==t?(u=t("Reads client.debug() for the client running in this page \u2014 not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=t,e[27]=u):u=e[27];let m;e[28]!==u?(m=(0,n.jsx)("p",{className:"text-muted-foreground text-xs",children:u}),e[28]=u,e[29]=m):m=e[29];let p;e[30]!==N||e[31]!==t?(p=N.length===0?(0,n.jsx)(_,{description:t("No shard connection has been opened yet."),title:t("No shards")}):(0,n.jsxs)(q,{children:[(0,n.jsx)(E,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(r,{children:t("Shard")}),(0,n.jsx)(r,{children:t("Socket")}),(0,n.jsx)(r,{children:t("Confirmed watermark")})]})}),(0,n.jsx)(M,{children:N.map(i=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{children:i.shardKey??t("(default)")}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:Q.has(i.wsState)?"default":"secondary",children:i.wsState})}),(0,n.jsx)(s,{children:i.confirmedMutationWatermark})]},i.shardKey??"__default__"))})]}),e[30]=N,e[31]=t,e[32]=p):p=e[32];let f;e[33]!==w||e[34]!==t?(f=w.length===0?(0,n.jsx)(_,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):(0,n.jsxs)(q,{children:[(0,n.jsx)(E,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(r,{children:t("Subscription")}),(0,n.jsx)(r,{children:t("Kind")}),(0,n.jsx)(r,{children:t("Acked")}),(0,n.jsx)(r,{children:t("Cursor")}),(0,n.jsx)(r,{children:t("Pending overlays")})]})}),(0,n.jsx)(M,{children:w.map(i=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{className:"font-mono text-xs",children:i.functionPath}),(0,n.jsx)(s,{children:i.kind}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:i.acked?"default":"secondary",children:i.acked?t("yes"):t("no")})}),(0,n.jsx)(s,{children:i.serverCursor??"\u2014"}),(0,n.jsx)(s,{children:i.pendingOptimisticLayers})]},i.id))})]}),e[33]=w,e[34]=t,e[35]=f):f=e[35];let C;return e[36]!==m||e[37]!==p||e[38]!==f||e[39]!==h?(C=(0,n.jsx)(A,{children:(0,n.jsxs)(L,{className:"flex flex-col gap-4",children:[h,m,p,f]})}),e[36]=m,e[37]=p,e[38]=f,e[39]=h,e[40]=C):C=e[40],C},"re");export{re as default};
1
+ import{a as D}from"./chunk-54MMVNPT.js";import{a as B}from"./chunk-XSD4Y6SQ.js";import{a as q,b as E,c as M,d as S,e as r,f as s}from"./chunk-MIQTKZAR.js";import{a as A,e as L}from"./chunk-UZERI5YC.js";import{b as x}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{f as W}from"./chunk-35II7U25.js";import"./chunk-XBDKZZ67.js";import{a as _}from"./chunk-XQCVZAGU.js";import{d as z}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as R,e as O,g as $,h as I}from"./chunk-3XIESWL4.js";var F=O($(),1);var n=O(I(),1);var J=2e3,Q=new Set(["open"]),re=R(G=>{let e=(0,F.c)(41),{read:y}=G,t=z(),j=W(),v;e[0]!==j||e[1]!==y?(v=R(()=>Promise.resolve(y?y():j.debug()),"S"),e[0]=j,e[1]=y,e[2]=v):v=e[2];let H=v,K=y?"injected":"live",b;e[3]!==K?(b=["lunora-studio","sync-client-debug",K],e[3]=K,e[4]=b):b=e[4];let{data:c,refetch:Y}=B(b,H);if(D(Y,!0,J),!c){let i;e[5]!==t?(i=t("Reading the sync client's state\u2026"),e[5]=t,e[6]=i):i=e[6];let g;e[7]!==t?(g=t("Sync client"),e[7]=t,e[8]=g):g=e[8];let T;return e[9]!==i||e[10]!==g?(T=(0,n.jsx)(A,{children:(0,n.jsx)(L,{children:(0,n.jsx)(_,{description:i,title:g})})}),e[9]=i,e[10]=g,e[11]=T):T=e[11],T}let{pendingWrites:k,shards:N,subscriptions:w}=c,l;e[12]!==t?(l=t("This Studio session's sync client"),e[12]=t,e[13]=l):l=e[13];let a;e[14]!==l?(a=(0,n.jsx)("span",{className:"text-sm font-medium",children:l}),e[14]=l,e[15]=a):a=e[15];let P=c.connectionStatus==="connected"?"default":"secondary",o;e[16]!==c.connectionStatus||e[17]!==P?(o=(0,n.jsx)(x,{variant:P,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=P,e[18]=o):o=e[18];let d;e[19]!==k||e[20]!==t?(d=k>0?(0,n.jsx)(x,{variant:"secondary",children:t("{count} pending writes",{count:k})}):null,e[19]=k,e[20]=t,e[21]=d):d=e[21];let h;e[22]!==a||e[23]!==o||e[24]!==d?(h=(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[a,o,d]}),e[22]=a,e[23]=o,e[24]=d,e[25]=h):h=e[25];let u;e[26]!==t?(u=t("Reads client.debug() for the client running in this page \u2014 not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=t,e[27]=u):u=e[27];let m;e[28]!==u?(m=(0,n.jsx)("p",{className:"text-muted-foreground text-xs",children:u}),e[28]=u,e[29]=m):m=e[29];let p;e[30]!==N||e[31]!==t?(p=N.length===0?(0,n.jsx)(_,{description:t("No shard connection has been opened yet."),title:t("No shards")}):(0,n.jsxs)(q,{children:[(0,n.jsx)(E,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(r,{children:t("Shard")}),(0,n.jsx)(r,{children:t("Socket")}),(0,n.jsx)(r,{children:t("Confirmed watermark")})]})}),(0,n.jsx)(M,{children:N.map(i=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{children:i.shardKey??t("(default)")}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:Q.has(i.wsState)?"default":"secondary",children:i.wsState})}),(0,n.jsx)(s,{children:i.confirmedMutationWatermark})]},i.shardKey??"__default__"))})]}),e[30]=N,e[31]=t,e[32]=p):p=e[32];let f;e[33]!==w||e[34]!==t?(f=w.length===0?(0,n.jsx)(_,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):(0,n.jsxs)(q,{children:[(0,n.jsx)(E,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(r,{children:t("Subscription")}),(0,n.jsx)(r,{children:t("Kind")}),(0,n.jsx)(r,{children:t("Acked")}),(0,n.jsx)(r,{children:t("Cursor")}),(0,n.jsx)(r,{children:t("Pending overlays")})]})}),(0,n.jsx)(M,{children:w.map(i=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{className:"font-mono text-xs",children:i.functionPath}),(0,n.jsx)(s,{children:i.kind}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:i.acked?"default":"secondary",children:i.acked?t("yes"):t("no")})}),(0,n.jsx)(s,{children:i.serverCursor??"\u2014"}),(0,n.jsx)(s,{children:i.pendingOptimisticLayers})]},i.id))})]}),e[33]=w,e[34]=t,e[35]=f):f=e[35];let C;return e[36]!==m||e[37]!==p||e[38]!==f||e[39]!==h?(C=(0,n.jsx)(A,{children:(0,n.jsxs)(L,{className:"flex flex-col gap-4",children:[h,m,p,f]})}),e[36]=m,e[37]=p,e[38]=f,e[39]=h,e[40]=C):C=e[40],C},"re");export{re as default};
@@ -0,0 +1,3 @@
1
+ import{a as nt}from"./chunk-SFDOII3B.js";import{e as Ee}from"./chunk-SMIESS7P.js";import{b as ke}from"./chunk-XSD4Y6SQ.js";import{a as T,e as He}from"./chunk-UZERI5YC.js";import{c as Ue}from"./chunk-FXCBF4XT.js";import{b as Fe}from"./chunk-THIXMMZD.js";import{a as D}from"./chunk-GXZAXNZI.js";import{f as We}from"./chunk-35II7U25.js";import{a as Ye}from"./chunk-XQCVZAGU.js";import{d as $,f as Qe,g as Xe,m as Se,n as et,o as tt,p as at}from"./chunk-4CGALXS3.js";import{a as m,e as Ve,f as ct,g as dt,h as mt,j as Be}from"./chunk-3XIESWL4.js";var S=Ve(dt(),1);var L=Ve(ct(),1);var n=Ve(mt(),1);var ut=Qe(D.studioFeatures),it={analytics:!0,auth:!0,containers:!0,flags:!0,kv:!0,mail:!0,payments:!0,queues:!0,scheduler:!0,storage:!0,vectors:!0,workflows:!0},pt=m(t=>{if(t===null||typeof t!="object")return it;let e=t,s=m(a=>typeof e[a]=="boolean"?e[a]:!0,"a");return{analytics:s("analytics"),auth:s("auth"),containers:s("containers"),flags:s("flags"),kv:s("kv"),mail:s("mail"),payments:s("payments"),queues:s("queues"),scheduler:s("scheduler"),storage:s("storage"),vectors:s("vectors"),workflows:s("workflows")}},"ut"),ft=m(()=>{let t=(0,S.c)(3),e=We(),[s,a]=(0,L.useState)(it),r,l;return t[0]!==e?(r=m(()=>{Se((async()=>{try{a(pt(await e.query(ut,{},Xe(""))))}catch{}})())},"s"),l=[e],t[0]=e,t[1]=r,t[2]=l):(r=t[1],l=t[2]),(0,L.useEffect)(r,l),s},"pt"),ht=m(()=>{let t=(0,S.c)(1),e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("svg",{"aria-hidden":"true",className:"size-4 text-muted-foreground",fill:"none",stroke:"currentColor",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,n.jsx)("path",{d:"m9 6 6 6-6 6",strokeLinecap:"round",strokeLinejoin:"round"})}),t[0]=e):e=t[0],e},"ft"),gt=m(t=>{let e=(0,S.c)(24),{group:s}=t,a=$(),r=Ee(),l;e[0]!==s.tab||e[1]!==r?(l=m(()=>{Se(r({to:`/${s.tab}`}))},"o"),e[0]=s.tab,e[1]=r,e[2]=l):l=e[2];let o=l,i=s.bindings.length,c;e[3]!==s.label?(c=(0,n.jsx)("span",{className:"text-sm font-medium text-foreground",children:s.label}),e[3]=s.label,e[4]=c):c=e[4];let p;e[5]===Symbol.for("react.memo_cache_sentinel")?(p=(0,n.jsx)(ht,{}),e[5]=p):p=e[5];let d;e[6]!==c?(d=(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[c,p]}),e[6]=c,e[7]=d):d=e[7];let f;e[8]!==i||e[9]!==a?(f=i===1?a("1 binding"):a("{count} bindings",{count:i}),e[8]=i,e[9]=a,e[10]=f):f=e[10];let u;e[11]!==f?(u=(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:f}),e[11]=f,e[12]=u):u=e[12];let h;e[13]!==i||e[14]!==s.bindings?(h=i>0&&(0,n.jsx)("div",{className:"flex flex-wrap gap-1.5",children:s.bindings.map(yt)}),e[13]=i,e[14]=s.bindings,e[15]=h):h=e[15];let g;e[16]!==d||e[17]!==u||e[18]!==h?(g=(0,n.jsxs)(He,{className:"flex flex-col gap-2 py-4",children:[d,u,h]}),e[16]=d,e[17]=u,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==s.testId||e[21]!==o||e[22]!==g?(x=(0,n.jsx)(T,{className:"cursor-pointer gap-0 py-0 transition-colors hover:bg-muted/40","data-testid":s.testId,onClick:o,children:g}),e[20]=s.testId,e[21]=o,e[22]=g,e[23]=x):x=e[23],x},"ht"),st=["kv","files","vectors"],xt=m((t,e)=>[...t.filter(s=>s.tab!==e.tab),e].toSorted((s,a)=>st.indexOf(s.tab)-st.indexOf(a.tab)),"gt"),bt=m(()=>{let t=(0,S.c)(19),e=We(),s=ft(),a=$(),r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=[],t[0]=r):r=t[0];let[l,o]=(0,L.useState)(r),i,c;if(t[1]!==e||t[2]!==s.kv||t[3]!==s.storage||t[4]!==s.vectors||t[5]!==a?(i=m(()=>{let g={cancelled:!1},x=[{enabled:s.kv,label:a("KV Namespaces"),load:m(async()=>(await e.listKvNamespaces()).map(vt),"load"),tab:"kv",testId:"home-binding-kv"},{enabled:s.storage,label:a("R2 Buckets"),load:m(()=>e.listStorageBuckets(),"load"),tab:"files",testId:"home-binding-r2"},{enabled:s.vectors,label:a("Vectorize Indexes"),load:m(async()=>(await e.listVectorIndexes()).map(Nt),"load"),tab:"vectors",testId:"home-binding-vectors"}];for(let b of x)b.enabled&&Se((async()=>{try{let y=await b.load();if(!g.cancelled){let k={bindings:y,label:b.label,tab:b.tab,testId:b.testId};o(A=>xt(A,k))}}catch{}})());return()=>{g.cancelled=!0}},"i"),c=[e,s.kv,s.storage,s.vectors,a],t[1]=e,t[2]=s.kv,t[3]=s.storage,t[4]=s.vectors,t[5]=a,t[6]=i,t[7]=c):(i=t[6],c=t[7]),(0,L.useEffect)(i,c),l.length===0)return null;let p;t[8]!==a?(p=a("Bindings"),t[8]=a,t[9]=p):p=t[9];let d;t[10]!==p?(d=(0,n.jsx)("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:p}),t[10]=p,t[11]=d):d=t[11];let f;t[12]!==l?(f=l.map(_t),t[12]=l,t[13]=f):f=t[13];let u;t[14]!==f?(u=(0,n.jsx)("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:f}),t[14]=f,t[15]=u):u=t[15];let h;return t[16]!==d||t[17]!==u?(h=(0,n.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"home-bindings",children:[d,u]}),t[16]=d,t[17]=u,t[18]=h):h=t[18],h},"xt");function yt(t){return(0,n.jsx)(Fe,{variant:"secondary",children:t},t)}m(yt,"bt");function vt(t){return t.binding}m(vt,"yt");function Nt(t){return t.name}m(Nt,"vt");function _t(t){return(0,n.jsx)(gt,{group:t},t.tab)}m(_t,"Nt");var St=[{name:"lunora_list_functions",summary:"list every query, mutation, and action with its path"},{name:"lunora_list_tables",summary:"list the schema's tables"},{name:"lunora_get_function_schema",summary:"read a function's argument JSON Schema before calling it"},{name:"lunora_run_query",summary:"run a read-only query"},{name:"lunora_run_mutation",summary:"run a mutation \u2014 writes; only when LUNORA_MCP_ALLOW_WRITES is set"},{name:"lunora_run_action",summary:"run an action \u2014 writes/effects; only when LUNORA_MCP_ALLOW_WRITES is set"}],kt=m(t=>JSON.stringify({mcpServers:{lunora:{args:["-y","@lunora/mcp"],command:"npx",env:{LUNORA_ADMIN_TOKEN:"<your-admin-token>",LUNORA_URL:t}}}},null,2),"St"),wt=m(t=>{let e=St.map(s=>`- ${s.name} \u2014 ${s.summary}`).join(`
2
+ `);return[`You have a Lunora MCP server connected to the deployment at ${t}.`,"It exposes this backend's functions and schema so you can inspect and operate it:",e,"",`Start by calling lunora_list_functions and lunora_list_tables to learn what exists, then lunora_get_function_schema before any run call. The full HTTP API is also documented at ${t}/_lunora/admin/openapi (that endpoint needs the same admin token the MCP server is configured with).`].join(`
3
+ `)},"kt"),Mt=1500,It=m(()=>{let t=(0,S.c)(35),e=$(),s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=et(),t[0]=s):s=t[0];let a=s,[r,l]=(0,L.useState)(null),o,i;t[1]!==r?(o=m(()=>{if(r===null)return;let C=globalThis.setTimeout(()=>{l(null)},Mt);return()=>{globalThis.clearTimeout(C)}},"l"),i=[r],t[1]=r,t[2]=o,t[3]=i):(o=t[2],i=t[3]),(0,L.useEffect)(o,i);let c;t[4]===Symbol.for("react.memo_cache_sentinel")?(c=m((C,j)=>{tt(j)&&l(C)},"c"),t[4]=c):c=t[4];let p=c,d;t[5]===Symbol.for("react.memo_cache_sentinel")?(d=m(()=>{p("config",kt(a))},"d"),t[5]=d):d=t[5];let f=d,u;t[6]===Symbol.for("react.memo_cache_sentinel")?(u=m(()=>{p("prompt",wt(a))},"m"),t[6]=u):u=t[6];let h=u,g;t[7]!==e?(g=e("Connect an AI agent"),t[7]=e,t[8]=g):g=t[8];let x;t[9]!==g?(x=(0,n.jsx)("span",{className:"text-sm font-medium text-foreground",children:g}),t[9]=g,t[10]=x):x=t[10];let b;t[11]!==e?(b=e("Drive this deployment from an AI agent over the Model Context Protocol \u2014 it can list functions and tables, read schemas, and run read-only queries. Writes stay off unless you opt in."),t[11]=e,t[12]=b):b=t[12];let y;t[13]!==b?(y=(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:b}),t[13]=b,t[14]=y):y=t[14];let k;t[15]!==x||t[16]!==y?(k=(0,n.jsxs)("div",{className:"flex flex-col gap-1.5 p-4",children:[x,y]}),t[15]=x,t[16]=y,t[17]=k):k=t[17];let A;t[18]===Symbol.for("react.memo_cache_sentinel")?(A=(0,n.jsx)("code",{className:"font-mono text-xs text-muted-foreground","data-testid":"home-connect-agent-command",children:"npx -y @lunora/mcp"}),t[18]=A):A=t[18];let w;t[19]!==r||t[20]!==e?(w=e(r==="config"?"Copied":"Copy MCP config"),t[19]=r,t[20]=e,t[21]=w):w=t[21];let v;t[22]!==w?(v=(0,n.jsx)(Ue,{"data-testid":"home-connect-agent-copy-config",onClick:f,size:"xs",variant:"outline",children:w}),t[22]=w,t[23]=v):v=t[23];let M;t[24]!==r||t[25]!==e?(M=e(r==="prompt"?"Copied":"Copy agent prompt"),t[24]=r,t[25]=e,t[26]=M):M=t[26];let I;t[27]!==M?(I=(0,n.jsx)(Ue,{"data-testid":"home-connect-agent-copy-prompt",onClick:h,size:"xs",variant:"outline",children:M}),t[27]=M,t[28]=I):I=t[28];let N;t[29]!==v||t[30]!==I?(N=(0,n.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border bg-muted/50 px-4 py-3",children:[A,(0,n.jsxs)("div",{className:"flex flex-wrap gap-2",children:[v,I]})]}),t[29]=v,t[30]=I,t[31]=N):N=t[31];let _;return t[32]!==k||t[33]!==N?(_=(0,n.jsxs)(T,{className:"gap-0 py-0","data-testid":"home-connect-agent",children:[k,N]}),t[32]=k,t[33]=N,t[34]=_):_=t[34],_},"$t"),Lt=(0,L.lazy)(()=>import("./chunk-QLJJ5YYZ.js").then(t=>({default:t.Sparkline}))),Ze=m(t=>{if(t<1e3)return`${String(Math.round(t))}ms`;let e=t>=1e4?0:1;return`${(t/1e3).toFixed(e)}s`},"Be"),At=m((t,e)=>{let s=Math.max(0,Math.round((e-t)/1e3));if(s<60)return`${String(s)}s ago`;let a=Math.round(s/60);if(a<60)return`${String(a)}m ago`;let r=Math.round(a/60);return r<24?`${String(r)}h ago`:`${String(Math.round(r/24))}d ago`},"Mt"),rt=m((t,e)=>{if(t===void 0||t.length===0)return[];let s=new Map;for(let a of t)s.set(a.bucketMs,(s.get(a.bucketMs)??0)+a[e]);return[...s.entries()].toSorted(([a],[r])=>a-r).map(([,a])=>a)},"He"),lt=m((t,e=!0)=>{if(t.length<4)return null;let s=Math.floor(t.length/2),a=t.slice(0,s).reduce((o,i)=>o+i,0),r=t.slice(s).reduce((o,i)=>o+i,0);if(a===0)return null;let l=(r-a)/a*100;return{positive:e?l>=0:l<=0,text:`${l>=0?"+":""}${l.toFixed(1)}%`}},"Je"),Ke=m(t=>{let e=(0,S.c)(24),{delta:s,footer:a,label:r,trend:l,unit:o,value:i}=t,c=$(),p;e[0]!==r?(p=(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r}),e[0]=r,e[1]=p):p=e[1];let d;e[2]!==i?(d=(0,n.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:i}),e[2]=i,e[3]=d):d=e[3];let f;e[4]!==o?(f=o!==void 0&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:o}),e[4]=o,e[5]=f):f=e[5];let u;e[6]!==d||e[7]!==f?(u=(0,n.jsxs)("span",{className:"flex items-baseline gap-1.5",children:[d,f]}),e[6]=d,e[7]=f,e[8]=u):u=e[8];let h;e[9]!==l?(h=l!==void 0&&(0,n.jsx)(L.Suspense,{fallback:(0,n.jsx)("div",{"aria-hidden":"true",className:"h-8 w-28"}),children:(0,n.jsx)(Lt,{data:l})}),e[9]=l,e[10]=h):h=e[10];let g;e[11]!==u||e[12]!==h?(g=(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[u,h]}),e[11]=u,e[12]=h,e[13]=g):g=e[13];let x;e[14]!==p||e[15]!==g?(x=(0,n.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[p,g]}),e[14]=p,e[15]=g,e[16]=x):x=e[16];let b;e[17]!==s||e[18]!==a||e[19]!==c?(b=s==null?a!=null&&(0,n.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:a}):(0,n.jsxs)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px]",children:[(0,n.jsx)("span",{className:Be("font-semibold",s.positive?"text-success":"text-destructive"),children:s.text})," ",(0,n.jsx)("span",{className:"text-muted-foreground",children:c("vs. prev.")})]}),e[17]=s,e[18]=a,e[19]=c,e[20]=b):b=e[20];let y;return e[21]!==x||e[22]!==b?(y=(0,n.jsxs)(T,{className:"justify-between gap-0 py-0",children:[x,b]}),e[21]=x,e[22]=b,e[23]=y):y=e[23],y},"Oe"),Ct=m(()=>{let t=(0,S.c)(1),e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:(0,n.jsx)("path",{d:"m9 6 6 6-6 6"})}),t[0]=e):e=t[0],e},"At"),Je=m(t=>{let e=(0,S.c)(7),{command:s,label:a}=t,r;e[0]!==a?(r=(0,n.jsx)("div",{className:"p-4",children:(0,n.jsx)("span",{className:"text-sm font-medium text-foreground",children:a})}),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==s?(l=(0,n.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5",children:(0,n.jsx)("code",{className:"font-mono text-xs text-muted-foreground",children:s})}),e[2]=s,e[3]=l):l=e[3];let o;return e[4]!==r||e[5]!==l?(o=(0,n.jsxs)(T,{className:"justify-between gap-0 py-0",children:[r,l]}),e[4]=r,e[5]=l,e[6]=o):o=e[6],o},"De"),ot=m(t=>{let e=(0,S.c)(18),{count:s,onView:a,testId:r,title:l}=t,o=$(),i;e[0]!==l?(i=(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l}),e[0]=l,e[1]=i):i=e[1];let c;e[2]!==s||e[3]!==o?(c=s===null?(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:o("No data yet")}):(0,n.jsx)(Fe,{variant:s>0?"destructive":"success",children:s>0?s:o("All clear")}),e[2]=s,e[3]=o,e[4]=c):c=e[4];let p;e[5]!==i||e[6]!==c?(p=(0,n.jsxs)("div",{className:"flex items-start justify-between gap-2 p-4",children:[i,c]}),e[5]=i,e[6]=c,e[7]=p):p=e[7];let d;e[8]!==o?(d=o("View"),e[8]=o,e[9]=d):d=e[9];let f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=(0,n.jsx)(Ct,{}),e[10]=f):f=e[10];let u;e[11]!==a||e[12]!==d?(u=(0,n.jsxs)("button",{className:"flex items-center gap-1 border-t border-border bg-muted/50 px-4 py-2.5 text-[12px] font-medium text-foreground outline-none transition-colors hover:bg-muted focus-visible:bg-muted",onClick:a,type:"button",children:[d,f]}),e[11]=a,e[12]=d,e[13]=u):u=e[13];let h;return e[14]!==p||e[15]!==u||e[16]!==r?(h=(0,n.jsxs)(T,{className:"justify-between gap-0 py-0","data-testid":r,children:[p,u]}),e[14]=p,e[15]=u,e[16]=r,e[17]=h):h=e[17],h},"Ge"),$t=m(t=>{let e=(0,S.c)(7),{functions:s}=t,a=$(),r;if(e[0]!==s||e[1]!==a){let l=[...s].toSorted(Kt).slice(0,5),o;e[3]!==a?(o=a("Top functions"),e[3]=a,e[4]=o):o=e[4];let i;e[5]!==o?(i=(0,n.jsx)("div",{className:"border-b border-border px-4 py-3",children:(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o})}),e[5]=o,e[6]=i):i=e[6],r=(0,n.jsxs)(T,{className:"gap-0 py-0","data-testid":"home-top-functions",children:[i,l.length===0?(0,n.jsx)("p",{className:"px-4 py-8 text-center text-xs text-muted-foreground",children:a("No functions called yet.")}):(0,n.jsxs)("div",{className:"divide-y divide-border",children:[(0,n.jsxs)("div",{className:"grid grid-cols-[1fr_auto_auto_auto] gap-4 px-4 py-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:[(0,n.jsx)("span",{children:a("Function")}),(0,n.jsx)("span",{className:"text-end",children:a("Calls")}),(0,n.jsx)("span",{className:"w-12 text-end",children:a("Avg")}),(0,n.jsx)("span",{className:"w-8 text-end",children:a("Err")})]}),l.map(Rt)]})]}),e[0]=s,e[1]=a,e[2]=r}else r=e[2];return r},"Ct"),jt=m(t=>{let e=(0,S.c)(26),{subs:s}=t,a=$(),r;e[0]!==a?(r=a("Live connections"),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==r?(l=(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r}),e[2]=r,e[3]=l):l=e[3];let o=s?.totalConnections??0,i;e[4]!==o?(i=o.toLocaleString(),e[4]=o,e[5]=i):i=e[5];let c;e[6]!==i?(c=(0,n.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:i}),e[6]=i,e[7]=c):c=e[7];let p;e[8]!==a?(p=a("sockets"),e[8]=a,e[9]=p):p=e[9];let d;e[10]!==p?(d=(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:p}),e[10]=p,e[11]=d):d=e[11];let f;e[12]!==c||e[13]!==d?(f=(0,n.jsxs)("span",{className:"flex items-baseline gap-1.5",children:[c,d]}),e[12]=c,e[13]=d,e[14]=f):f=e[14];let u=s?.totalSubscriptions??0,h;e[15]!==u?(h=u.toLocaleString(),e[15]=u,e[16]=h):h=e[16];let g;e[17]!==a?(g=a("active subscriptions"),e[17]=a,e[18]=g):g=e[18];let x;e[19]!==h||e[20]!==g?(x=(0,n.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:[h," ",g]}),e[19]=h,e[20]=g,e[21]=x):x=e[21];let b;return e[22]!==x||e[23]!==l||e[24]!==f?(b=(0,n.jsx)(T,{"data-testid":"home-live-connections",children:(0,n.jsxs)(He,{className:"flex flex-col gap-2.5 py-4",children:[l,f,x]})}),e[22]=x,e[23]=l,e[24]=f,e[25]=b):b=e[25],b},"It"),Tt=m(t=>{let e=(0,S.c)(7),{entries:s}=t,a=$(),r;if(e[0]!==s||e[1]!==a){let l=Date.now(),o;e[3]!==a?(o=a("Recent activity"),e[3]=a,e[4]=o):o=e[4];let i;e[5]!==o?(i=(0,n.jsx)("div",{className:"border-b border-border px-4 py-3",children:(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o})}),e[5]=o,e[6]=i):i=e[6],r=(0,n.jsxs)(T,{className:"gap-0 py-0","data-testid":"home-recent-activity",children:[i,s.length===0?(0,n.jsx)("p",{className:"px-4 py-8 text-center text-xs text-muted-foreground",children:a("No recent activity.")}):(0,n.jsx)("ul",{className:"divide-y divide-border",children:s.slice(0,5).map(c=>(0,n.jsxs)("li",{className:"flex items-center justify-between gap-3 px-4 py-2 text-[13px]",children:[(0,n.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,n.jsx)("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full bg-muted-foreground/40"}),(0,n.jsxs)("span",{className:"truncate text-foreground",children:[c.op,c.table!==void 0&&(0,n.jsxs)("span",{className:"text-muted-foreground",children:[" \xB7 ",c.table,c.id===void 0?"":`#${c.id}`]})]})]}),(0,n.jsx)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:At(c.ts,l)})]},c.seq))})]}),e[0]=s,e[1]=a,e[2]=r}else r=e[2];return r},"jt"),Ot=m(t=>{let e=t.reduce((s,a)=>s+a.calls,0);return e===0?null:t.reduce((s,a)=>s+a.totalDurationMs,0)/e},"Tt"),Gt=m(t=>{let e=(0,S.c)(151),{initialShardKey:s}=t,a=$(),r=Ee(),l=s??"",o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={},e[0]=o):o=e[0];let i;e[1]!==l?(i={shardKey:l},e[1]=l,e[2]=i):i=e[2];let c=ke(D.getMetrics,o,i),p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p={},e[3]=p):p=e[3];let d;e[4]!==l?(d={shardKey:l},e[4]=l,e[5]=d):d=e[5];let f=ke(D.getFunctionStats,p,d),u,h;e[6]===Symbol.for("react.memo_cache_sentinel")?(u={},h={shardKey:""},e[6]=u,e[7]=h):(u=e[6],h=e[7]);let g=ke(D.getSecurityAudit,u,h),x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x={},e[8]=x):x=e[8];let b;e[9]!==l?(b={shardKey:l},e[9]=l,e[10]=b):b=e[10];let y=ke(D.listSubscriptions,x,b),k;e[11]===Symbol.for("react.memo_cache_sentinel")?(k={},e[11]=k):k=e[11];let A;e[12]!==l?(A={shardKey:l},e[12]=l,e[13]=A):A=e[13];let w=ke(D.getAuditLog,k,A),v=c.data??null,M,I,N,_,C,j,P,O,K,V,W,E,R,q,B,F,U,H;if(e[14]!==w.data||e[15]!==g.data||e[16]!==v||e[17]!==c.data||e[18]!==r||e[19]!==f.data||e[20]!==y.data||e[21]!==a){_=Array.isArray(f.data?.functions)?f.data.functions:[],P=y.data??null;let Le;e[40]!==w.data?(Le=Array.isArray(w.data?.entries)?w.data.entries:[],e[40]=w.data,e[41]=Le):Le=e[41],I=Le,C=c.data===void 0||f.data===void 0?null:nt(v,_).length,j=Array.isArray(g.data?.findings)?g.data.findings.length:null;let Ae;e[42]!==r?(Ae=m(()=>{Se(r({to:"/security"}))},"Me"),e[42]=r,e[43]=Ae):Ae=e[43],H=Ae;let Ce;e[44]!==r?(Ce=m(()=>{Se(r({to:"/insights"}))},"Ae"),e[44]=r,e[45]=Ce):Ce=e[45],U=Ce;let $e=rt(v?.history,"calls"),je=rt(v?.history,"errors"),Ge=Ot(_),Te=Math.max(0,..._.map(qt)),z=v?.cache,Oe;e[46]!==z?(Oe=z!=null&&z.hits+z.misses>0?Math.round(z.hits/(z.hits+z.misses)*100):null,e[46]=z,e[47]=Oe):Oe=e[47],N=Oe,B="flex flex-col gap-6",F="lunora-home",W="grid gap-3 sm:grid-cols-2 xl:grid-cols-4",E="home-health";let qe=lt($e),ye;e[48]!==a?(ye=a("Requests"),e[48]=a,e[49]=ye):ye=e[49];let ze=v?.requests??0,ve;e[50]!==ze?(ve=ze.toLocaleString(),e[50]=ze,e[51]=ve):ve=e[51],e[52]!==$e||e[53]!==qe||e[54]!==ye||e[55]!==ve?(R=(0,n.jsx)(Ke,{delta:qe,label:ye,trend:$e,value:ve}),e[52]=$e,e[53]=qe,e[54]=ye,e[55]=ve,e[56]=R):R=e[56];let De=lt(je,!1),Ne;e[57]!==a?(Ne=a("Errors"),e[57]=a,e[58]=Ne):Ne=e[58];let Pe=v?.errors??0,_e;e[59]!==Pe?(_e=Pe.toLocaleString(),e[59]=Pe,e[60]=_e):_e=e[60],e[61]!==je||e[62]!==De||e[63]!==Ne||e[64]!==_e?(q=(0,n.jsx)(Ke,{delta:De,label:Ne,trend:je,value:_e}),e[61]=je,e[62]=De,e[63]=Ne,e[64]=_e,e[65]=q):q=e[65],M=Ke,e[66]!==Te||e[67]!==a?(O=Te>0?`${a("max")} ${Ze(Te)}`:void 0,e[66]=Te,e[67]=a,e[68]=O):O=e[68],e[69]!==a?(K=a("Avg latency"),e[69]=a,e[70]=K):K=e[70],V=Ge===null?"\u2014":Ze(Ge),e[14]=w.data,e[15]=g.data,e[16]=v,e[17]=c.data,e[18]=r,e[19]=f.data,e[20]=y.data,e[21]=a,e[22]=M,e[23]=I,e[24]=N,e[25]=_,e[26]=C,e[27]=j,e[28]=P,e[29]=O,e[30]=K,e[31]=V,e[32]=W,e[33]=E,e[34]=R,e[35]=q,e[36]=B,e[37]=F,e[38]=U,e[39]=H}else M=e[22],I=e[23],N=e[24],_=e[25],C=e[26],j=e[27],P=e[28],O=e[29],K=e[30],V=e[31],W=e[32],E=e[33],R=e[34],q=e[35],B=e[36],F=e[37],U=e[38],H=e[39];let J;e[71]!==M||e[72]!==O||e[73]!==K||e[74]!==V?(J=(0,n.jsx)(M,{footer:O,label:K,value:V}),e[71]=M,e[72]=O,e[73]=K,e[74]=V,e[75]=J):J=e[75];let Z;e[76]!==N||e[77]!==a?(Z=N===null?void 0:`${String(N)}% ${a("cache hit")}`,e[76]=N,e[77]=a,e[78]=Z):Z=e[78];let G;e[79]!==a?(G=a("Database size"),e[79]=a,e[80]=G):G=e[80];let Re=v?.databaseSize??null,Y;e[81]!==Re?(Y=at(Re),e[81]=Re,e[82]=Y):Y=e[82];let Q;e[83]!==Z||e[84]!==G||e[85]!==Y?(Q=(0,n.jsx)(Ke,{footer:Z,label:G,value:Y}),e[83]=Z,e[84]=G,e[85]=Y,e[86]=Q):Q=e[86];let X;e[87]!==W||e[88]!==E||e[89]!==R||e[90]!==q||e[91]!==J||e[92]!==Q?(X=(0,n.jsxs)("div",{className:W,"data-testid":E,children:[R,q,J,Q]}),e[87]=W,e[88]=E,e[89]=R,e[90]=q,e[91]=J,e[92]=Q,e[93]=X):X=e[93];let we;e[94]===Symbol.for("react.memo_cache_sentinel")?(we=(0,n.jsx)(bt,{}),e[94]=we):we=e[94];let ee;e[95]!==_?(ee=(0,n.jsx)("div",{className:"lg:col-span-2",children:(0,n.jsx)($t,{functions:_})}),e[95]=_,e[96]=ee):ee=e[96];let te;e[97]!==P?(te=(0,n.jsx)(jt,{subs:P}),e[97]=P,e[98]=te):te=e[98];let ae;e[99]!==I?(ae=(0,n.jsx)(Tt,{entries:I}),e[99]=I,e[100]=ae):ae=e[100];let ne;e[101]!==te||e[102]!==ae?(ne=(0,n.jsxs)("div",{className:"flex flex-col gap-3",children:[te,ae]}),e[101]=te,e[102]=ae,e[103]=ne):ne=e[103];let se;e[104]!==ee||e[105]!==ne?(se=(0,n.jsxs)("div",{className:"grid gap-3 lg:grid-cols-3",children:[ee,ne]}),e[104]=ee,e[105]=ne,e[106]=se):se=e[106];let re;e[107]!==a?(re=a("Advisors"),e[107]=a,e[108]=re):re=e[108];let le;e[109]!==re?(le=(0,n.jsx)("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:re}),e[109]=re,e[110]=le):le=e[110];let oe;e[111]!==C||e[112]!==j||e[113]!==a||e[114]!==U||e[115]!==H?(oe=j===0&&C===0?(0,n.jsx)(Ye,{description:a("No security or performance issues detected."),icon:(0,n.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,n.jsx)("path",{d:"M12 3 4 6v5c0 5 3.4 8.5 8 10 4.6-1.5 8-5 8-10V6l-8-3Z"}),(0,n.jsx)("path",{d:"m9 12 2 2 4-4"})]}),testId:"home-advisors-clear",title:a("No issues found")}):(0,n.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,n.jsx)(ot,{count:j,onView:H,testId:"home-security",title:a("Security findings")}),(0,n.jsx)(ot,{count:C,onView:U,testId:"home-performance",title:a("Performance issues")})]}),e[111]=C,e[112]=j,e[113]=a,e[114]=U,e[115]=H,e[116]=oe):oe=e[116];let ie;e[117]!==le||e[118]!==oe?(ie=(0,n.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"home-advisors",children:[le,oe]}),e[117]=le,e[118]=oe,e[119]=ie):ie=e[119];let ce;e[120]!==a?(ce=a("Get connected"),e[120]=a,e[121]=ce):ce=e[121];let de;e[122]!==ce?(de=(0,n.jsx)("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:ce}),e[122]=ce,e[123]=de):de=e[123];let me;e[124]!==a?(me=a("Client SDK"),e[124]=a,e[125]=me):me=e[125];let ue;e[126]!==me?(ue=(0,n.jsx)(Je,{command:"npm i @lunora/client",label:me}),e[126]=me,e[127]=ue):ue=e[127];let pe;e[128]!==a?(pe=a("React"),e[128]=a,e[129]=pe):pe=e[129];let fe;e[130]!==pe?(fe=(0,n.jsx)(Je,{command:"npm i @lunora/react",label:pe}),e[130]=pe,e[131]=fe):fe=e[131];let he;e[132]!==a?(he=a("CLI"),e[132]=a,e[133]=he):he=e[133];let ge;e[134]!==he?(ge=(0,n.jsx)(Je,{command:"lunora dev",label:he}),e[134]=he,e[135]=ge):ge=e[135];let xe;e[136]!==ue||e[137]!==fe||e[138]!==ge?(xe=(0,n.jsxs)("div",{className:"grid gap-3 sm:grid-cols-3",children:[ue,fe,ge]}),e[136]=ue,e[137]=fe,e[138]=ge,e[139]=xe):xe=e[139];let Me;e[140]===Symbol.for("react.memo_cache_sentinel")?(Me=(0,n.jsx)(It,{}),e[140]=Me):Me=e[140];let be;e[141]!==de||e[142]!==xe?(be=(0,n.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"home-get-connected",children:[de,xe,Me]}),e[141]=de,e[142]=xe,e[143]=be):be=e[143];let Ie;return e[144]!==B||e[145]!==F||e[146]!==X||e[147]!==se||e[148]!==ie||e[149]!==be?(Ie=(0,n.jsxs)("div",{className:B,"data-testid":F,children:[X,we,se,ie,be]}),e[144]=B,e[145]=F,e[146]=X,e[147]=se,e[148]=ie,e[149]=be,e[150]=Ie):Ie=e[150],Ie},"Zt");function Kt(t,e){return e.calls-t.calls}m(Kt,"Ot");function Rt(t){return(0,n.jsxs)("div",{className:"grid grid-cols-[1fr_auto_auto_auto] items-center gap-4 px-4 py-2 text-[13px]",children:[(0,n.jsx)("span",{className:"truncate font-mono text-xs text-foreground",children:t.path}),(0,n.jsx)("span",{className:"text-end tabular-nums",children:t.calls.toLocaleString()}),(0,n.jsx)("span",{className:"w-12 text-end tabular-nums text-muted-foreground",children:Ze(t.calls>0?t.totalDurationMs/t.calls:0)}),(0,n.jsx)("span",{className:Be("w-8 text-end tabular-nums",t.errors>0?"text-destructive":"text-muted-foreground"),children:t.errors})]},t.path)}m(Rt,"Kt");function qt(t){return t.maxDurationMs}m(qt,"Rt");export{ft as a,Gt as b};
@@ -1 +1 @@
1
- import{a as C}from"./chunk-54MMVNPT.js";import{a as _}from"./chunk-OWADN6BI.js";import{a as $,b as z,c as B,d as g,e as n,f as i}from"./chunk-MIQTKZAR.js";import{a as S,e as I}from"./chunk-UZERI5YC.js";import{c as w}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{f as b}from"./chunk-LWECXQWP.js";import"./chunk-XBDKZZ67.js";import{a as j}from"./chunk-XQCVZAGU.js";import{d as k,m as R,q as T}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as h,e as y,g as P,h as Q}from"./chunk-3XIESWL4.js";var L=y(P(),1);var s=y(Q(),1);var E=200,U=h(()=>{let e=(0,L.c)(21),l=b(),t=k(),u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=["lunora-auth-sessions",E],e[0]=u):u=e[0];let p;e[1]!==l?(p=h(()=>l.listAuthSessions({limit:E}),"u"),e[1]=l,e[2]=p):p=e[2];let o=_(u,p),{error:f}=o,a=o.data?.rows??null,x;e[3]!==o?(x=h(()=>{o.refetch()},"f"),e[3]=o,e[4]=x):x=e[4],C(x,!0);let N;e[5]!==l||e[6]!==o?(N=h(r=>{R((async()=>{await l.revokeAuthSession({sessionId:r}),o.refetch()})())},"x"),e[5]=l,e[6]=o,e[7]=N):N=e[7];let A=N,d;e[8]!==f?(d=f!==null&&(0,s.jsx)("p",{className:"text-sm text-destructive","data-testid":"auth-sessions-error",role:"alert",children:f}),e[8]=f,e[9]=d):d=e[9];let c;e[10]!==a||e[11]!==t?(c=a!==null&&a.length===0&&(0,s.jsx)(j,{testId:"auth-sessions-empty",title:t("No active sessions.")}),e[10]=a,e[11]=t,e[12]=c):c=e[12];let m;e[13]!==A||e[14]!==a||e[15]!==t?(m=a!==null&&a.length>0&&(0,s.jsx)(S,{className:"overflow-hidden py-0",children:(0,s.jsx)(I,{className:"px-0",children:(0,s.jsxs)($,{"data-testid":"auth-sessions-table",children:[(0,s.jsx)(z,{children:(0,s.jsxs)(g,{children:[(0,s.jsx)(n,{children:t("user")}),(0,s.jsx)(n,{children:t("expires")}),(0,s.jsx)(n,{children:t("ip")}),(0,s.jsx)(n,{children:t("user agent")}),(0,s.jsx)(n,{children:t("impersonated by")}),(0,s.jsx)(n,{"aria-label":t("Actions")})]})}),(0,s.jsx)(B,{children:a.map(r=>(0,s.jsxs)(g,{"data-testid":`auth-session-${r.id}`,children:[(0,s.jsx)(i,{className:"font-mono text-xs",children:r.userId}),(0,s.jsx)(i,{className:"text-muted-foreground tabular-nums",children:T(r.expiresAt)}),(0,s.jsx)(i,{children:r.ipAddress??""}),(0,s.jsx)(i,{className:"max-w-40 truncate",children:r.userAgent??""}),(0,s.jsx)(i,{className:"font-mono text-xs",children:r.impersonatedBy??""}),(0,s.jsx)(i,{children:(0,s.jsx)(w,{"data-testid":`auth-session-revoke-${r.id}`,onClick:h(()=>{A(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:t("Revoke")})})]},r.id))})]})})}),e[13]=A,e[14]=a,e[15]=t,e[16]=m):m=e[16];let v;return e[17]!==d||e[18]!==c||e[19]!==m?(v=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"auth-sessions",children:[d,c,m]}),e[17]=d,e[18]=c,e[19]=m,e[20]=v):v=e[20],v},"Q");export{U as AuthSessionsPanel};
1
+ import{a as C}from"./chunk-54MMVNPT.js";import{a as _}from"./chunk-XSD4Y6SQ.js";import{a as $,b as z,c as B,d as g,e as n,f as i}from"./chunk-MIQTKZAR.js";import{a as S,e as I}from"./chunk-UZERI5YC.js";import{c as w}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{f as b}from"./chunk-35II7U25.js";import"./chunk-XBDKZZ67.js";import{a as j}from"./chunk-XQCVZAGU.js";import{d as k,m as R,q as T}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as h,e as y,g as P,h as Q}from"./chunk-3XIESWL4.js";var L=y(P(),1);var s=y(Q(),1);var E=200,U=h(()=>{let e=(0,L.c)(21),l=b(),t=k(),u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=["lunora-auth-sessions",E],e[0]=u):u=e[0];let p;e[1]!==l?(p=h(()=>l.listAuthSessions({limit:E}),"u"),e[1]=l,e[2]=p):p=e[2];let o=_(u,p),{error:f}=o,a=o.data?.rows??null,x;e[3]!==o?(x=h(()=>{o.refetch()},"f"),e[3]=o,e[4]=x):x=e[4],C(x,!0);let N;e[5]!==l||e[6]!==o?(N=h(r=>{R((async()=>{await l.revokeAuthSession({sessionId:r}),o.refetch()})())},"x"),e[5]=l,e[6]=o,e[7]=N):N=e[7];let A=N,d;e[8]!==f?(d=f!==null&&(0,s.jsx)("p",{className:"text-sm text-destructive","data-testid":"auth-sessions-error",role:"alert",children:f}),e[8]=f,e[9]=d):d=e[9];let c;e[10]!==a||e[11]!==t?(c=a!==null&&a.length===0&&(0,s.jsx)(j,{testId:"auth-sessions-empty",title:t("No active sessions.")}),e[10]=a,e[11]=t,e[12]=c):c=e[12];let m;e[13]!==A||e[14]!==a||e[15]!==t?(m=a!==null&&a.length>0&&(0,s.jsx)(S,{className:"overflow-hidden py-0",children:(0,s.jsx)(I,{className:"px-0",children:(0,s.jsxs)($,{"data-testid":"auth-sessions-table",children:[(0,s.jsx)(z,{children:(0,s.jsxs)(g,{children:[(0,s.jsx)(n,{children:t("user")}),(0,s.jsx)(n,{children:t("expires")}),(0,s.jsx)(n,{children:t("ip")}),(0,s.jsx)(n,{children:t("user agent")}),(0,s.jsx)(n,{children:t("impersonated by")}),(0,s.jsx)(n,{"aria-label":t("Actions")})]})}),(0,s.jsx)(B,{children:a.map(r=>(0,s.jsxs)(g,{"data-testid":`auth-session-${r.id}`,children:[(0,s.jsx)(i,{className:"font-mono text-xs",children:r.userId}),(0,s.jsx)(i,{className:"text-muted-foreground tabular-nums",children:T(r.expiresAt)}),(0,s.jsx)(i,{children:r.ipAddress??""}),(0,s.jsx)(i,{className:"max-w-40 truncate",children:r.userAgent??""}),(0,s.jsx)(i,{className:"font-mono text-xs",children:r.impersonatedBy??""}),(0,s.jsx)(i,{children:(0,s.jsx)(w,{"data-testid":`auth-session-revoke-${r.id}`,onClick:h(()=>{A(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:t("Revoke")})})]},r.id))})]})})}),e[13]=A,e[14]=a,e[15]=t,e[16]=m):m=e[16];let v;return e[17]!==d||e[18]!==c||e[19]!==m?(v=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"auth-sessions",children:[d,c,m]}),e[17]=d,e[18]=c,e[19]=m,e[20]=v):v=e[20],v},"Q");export{U as AuthSessionsPanel};
@@ -1 +1 @@
1
- import{a as S}from"./chunk-UNUU7CJJ.js";import"./chunk-XXQUMVWH.js";import{b as p}from"./chunk-OWADN6BI.js";import{a as C,b as K,c as j,d as m,e as n,f as o}from"./chunk-MIQTKZAR.js";import{a as A,e as k}from"./chunk-UZERI5YC.js";import{c as w}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as f}from"./chunk-GXZAXNZI.js";import"./chunk-LWECXQWP.js";import"./chunk-XBDKZZ67.js";import{a as T}from"./chunk-XQCVZAGU.js";import{d as z,q as B}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as i,e as U,f as W,h as X}from"./chunk-3XIESWL4.js";var D=U(W(),1);var e=U(X(),1);var F="agent_threads",Y="agent_messages",Z=100,ee=250,te={},ae={filters:[],limit:Z,offset:0,orderBy:{column:"updatedAt",direction:"desc"},skipCount:!0,table:F},l=i((s,t)=>{let a=s[t];return typeof a=="string"?a:void 0},"d"),I=i((s,t)=>{let a=s[t];return typeof a=="number"?a:void 0},"b"),M=i(s=>{let{usage:t}=s;if(t===null||typeof t!="object")return;let{totalTokens:a}=t;return typeof a=="number"?a:void 0},"z"),re=i(s=>{let{toolCalls:t}=s;return Array.isArray(t)?t.map(a=>a!==null&&typeof a=="object"?a.name:void 0).filter(a=>typeof a=="string"):[]},"ee"),se=i(s=>{switch(s){case"awaiting_input":return"warning";case"cancelled":return"warning";case"error":return"destructive";case"running":return"info";default:return"outline"}},"te"),ne=i(s=>{switch(s){case"approved":return"success";case"rejected":return"destructive";default:return"warning"}},"ae"),fe=i(({initialShardKey:s=""})=>{let t=z(),[a,$]=(0,D.useState)(void 0),{data:x}=p(f.listTables,te,{live:!0,shardKey:s}),L=x!==void 0,u=Array.isArray(x)&&x.some(r=>r.name===F),{data:_,error:O,errorSource:R,liveError:G}=p(f.readTablePage,ae,{enabled:u,live:!0,shardKey:s}),H={filters:[{column:"threadKey",operator:"eq",value:a??""}],limit:ee,offset:0,orderBy:{column:"seq",direction:"asc"},skipCount:!0,table:Y},{data:q,error:J,errorSource:Q}=p(f.readTablePage,H,{enabled:u&&a!==void 0,live:!0,shardKey:s}),v=Array.isArray(_?.rows)?_.rows:[],E=Array.isArray(q?.rows)?q.rows:[],P=v.find(r=>l(r,"key")===a),h;return L&&!u?h=(0,e.jsx)(T,{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")}):u&&v.length===0?h=(0,e.jsx)(T,{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")}):h=(0,e.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,e.jsx)(A,{className:"overflow-hidden py-0",children:(0,e.jsx)(k,{className:"px-0",children:(0,e.jsxs)(C,{"data-testid":"agents-threads-table",children:[(0,e.jsx)(K,{children:(0,e.jsxs)(m,{children:[(0,e.jsx)(n,{children:t("Agent")}),(0,e.jsx)(n,{children:t("Key")}),(0,e.jsx)(n,{children:t("Status")}),(0,e.jsx)(n,{children:t("Messages")}),(0,e.jsx)(n,{children:t("Tokens")}),(0,e.jsx)(n,{children:t("Updated")}),(0,e.jsx)(n,{"aria-label":t("Actions")})]})}),(0,e.jsx)(j,{children:v.map(r=>{let d=l(r,"key")??"",c=l(r,"status"),g=M(r);return(0,e.jsxs)(m,{"data-active":d===a?"":void 0,"data-testid":`agents-thread-${d}`,children:[(0,e.jsx)(o,{className:"font-mono text-xs",children:l(r,"agent")??"\u2014"}),(0,e.jsx)(o,{className:"font-mono text-xs text-muted-foreground",children:d}),(0,e.jsx)(o,{children:(0,e.jsx)(b,{"data-testid":`agents-thread-status-${d}`,variant:se(c),children:c??"\u2014"})}),(0,e.jsx)(o,{className:"tabular-nums",children:I(r,"messageCount")??"\u2014"}),(0,e.jsx)(o,{className:"tabular-nums text-muted-foreground",children:g??"\u2014"}),(0,e.jsx)(o,{className:"text-muted-foreground tabular-nums",children:B(I(r,"updatedAt"),"\u2014")}),(0,e.jsx)(o,{className:"text-right",children:(0,e.jsx)(w,{"data-testid":`agents-thread-open-${d}`,onClick:i(()=>{$(d)},"onClick"),size:"sm",type:"button",variant:"outline",children:t("Timeline")})})]},d)})})]})})}),J!==null&&(0,e.jsx)(S,{error:Q,testId:"agents-messages-error"}),a!==void 0&&(0,e.jsx)(A,{className:"overflow-hidden py-0","data-testid":"agents-thread-detail",children:(0,e.jsxs)(k,{className:"flex flex-col gap-3 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[t("Timeline")," \xB7 ",a,P!==void 0&&(0,e.jsxs)("span",{className:"text-muted-foreground",children:[" \xB7 ",t("Usage"),": ",M(P)??0," ",t("Tokens")]})]}),(0,e.jsx)(w,{"data-testid":"agents-thread-detail-close",onClick:i(()=>{$(void 0)},"onClick"),size:"xs",type:"button",variant:"ghost",children:t("Close")})]}),E.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:t("This thread has no messages yet.")}):(0,e.jsxs)(C,{"data-testid":"agents-messages-table",children:[(0,e.jsx)(K,{children:(0,e.jsxs)(m,{children:[(0,e.jsx)(n,{children:t("Role")}),(0,e.jsx)(n,{children:t("Content")}),(0,e.jsx)(n,{children:t("Tool")}),(0,e.jsx)(n,{children:t("Approval")})]})}),(0,e.jsx)(j,{children:E.map((r,d)=>{let c=l(r,"role")??"\u2014",g=re(r),V=l(r,"toolName"),y=l(r,"status"),N=I(r,"seq")??d;return(0,e.jsxs)(m,{"data-testid":`agents-message-${String(N)}`,children:[(0,e.jsx)(o,{className:"font-mono text-xs align-top text-muted-foreground",children:c}),(0,e.jsx)(o,{className:"max-w-md font-mono text-xs whitespace-pre-wrap break-words",children:l(r,"content")??"\u2014"}),(0,e.jsx)(o,{className:"font-mono text-xs align-top text-muted-foreground",children:V??(g.length>0?g.join(", "):"\u2014")}),(0,e.jsx)(o,{className:"align-top",children:y===void 0?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"\u2014"}):(0,e.jsx)(b,{"data-testid":`agents-message-approval-${String(N)}`,variant:ne(y),children:y})})]},l(r,"messageKey")??`${c}:${String(N)}`)})})]})]})})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-agents-panel",children:[O!==null&&(0,e.jsx)(S,{error:R,testId:"agents-error"}),(0,e.jsx)("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.")}),G!==void 0&&(0,e.jsx)("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.")}),h]})},"pe");export{fe as AgentsPanel};
1
+ import{a as S}from"./chunk-UNUU7CJJ.js";import"./chunk-XXQUMVWH.js";import{b as p}from"./chunk-XSD4Y6SQ.js";import{a as C,b as K,c as j,d as m,e as n,f as o}from"./chunk-MIQTKZAR.js";import{a as A,e as k}from"./chunk-UZERI5YC.js";import{c as w}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as f}from"./chunk-GXZAXNZI.js";import"./chunk-35II7U25.js";import"./chunk-XBDKZZ67.js";import{a as T}from"./chunk-XQCVZAGU.js";import{d as z,q as B}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as i,e as U,f as W,h as X}from"./chunk-3XIESWL4.js";var D=U(W(),1);var e=U(X(),1);var F="agent_threads",Y="agent_messages",Z=100,ee=250,te={},ae={filters:[],limit:Z,offset:0,orderBy:{column:"updatedAt",direction:"desc"},skipCount:!0,table:F},l=i((s,t)=>{let a=s[t];return typeof a=="string"?a:void 0},"d"),I=i((s,t)=>{let a=s[t];return typeof a=="number"?a:void 0},"b"),M=i(s=>{let{usage:t}=s;if(t===null||typeof t!="object")return;let{totalTokens:a}=t;return typeof a=="number"?a:void 0},"z"),re=i(s=>{let{toolCalls:t}=s;return Array.isArray(t)?t.map(a=>a!==null&&typeof a=="object"?a.name:void 0).filter(a=>typeof a=="string"):[]},"ee"),se=i(s=>{switch(s){case"awaiting_input":return"warning";case"cancelled":return"warning";case"error":return"destructive";case"running":return"info";default:return"outline"}},"te"),ne=i(s=>{switch(s){case"approved":return"success";case"rejected":return"destructive";default:return"warning"}},"ae"),fe=i(({initialShardKey:s=""})=>{let t=z(),[a,$]=(0,D.useState)(void 0),{data:x}=p(f.listTables,te,{live:!0,shardKey:s}),L=x!==void 0,u=Array.isArray(x)&&x.some(r=>r.name===F),{data:_,error:O,errorSource:R,liveError:G}=p(f.readTablePage,ae,{enabled:u,live:!0,shardKey:s}),H={filters:[{column:"threadKey",operator:"eq",value:a??""}],limit:ee,offset:0,orderBy:{column:"seq",direction:"asc"},skipCount:!0,table:Y},{data:q,error:J,errorSource:Q}=p(f.readTablePage,H,{enabled:u&&a!==void 0,live:!0,shardKey:s}),v=Array.isArray(_?.rows)?_.rows:[],E=Array.isArray(q?.rows)?q.rows:[],P=v.find(r=>l(r,"key")===a),h;return L&&!u?h=(0,e.jsx)(T,{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")}):u&&v.length===0?h=(0,e.jsx)(T,{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")}):h=(0,e.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,e.jsx)(A,{className:"overflow-hidden py-0",children:(0,e.jsx)(k,{className:"px-0",children:(0,e.jsxs)(C,{"data-testid":"agents-threads-table",children:[(0,e.jsx)(K,{children:(0,e.jsxs)(m,{children:[(0,e.jsx)(n,{children:t("Agent")}),(0,e.jsx)(n,{children:t("Key")}),(0,e.jsx)(n,{children:t("Status")}),(0,e.jsx)(n,{children:t("Messages")}),(0,e.jsx)(n,{children:t("Tokens")}),(0,e.jsx)(n,{children:t("Updated")}),(0,e.jsx)(n,{"aria-label":t("Actions")})]})}),(0,e.jsx)(j,{children:v.map(r=>{let d=l(r,"key")??"",c=l(r,"status"),g=M(r);return(0,e.jsxs)(m,{"data-active":d===a?"":void 0,"data-testid":`agents-thread-${d}`,children:[(0,e.jsx)(o,{className:"font-mono text-xs",children:l(r,"agent")??"\u2014"}),(0,e.jsx)(o,{className:"font-mono text-xs text-muted-foreground",children:d}),(0,e.jsx)(o,{children:(0,e.jsx)(b,{"data-testid":`agents-thread-status-${d}`,variant:se(c),children:c??"\u2014"})}),(0,e.jsx)(o,{className:"tabular-nums",children:I(r,"messageCount")??"\u2014"}),(0,e.jsx)(o,{className:"tabular-nums text-muted-foreground",children:g??"\u2014"}),(0,e.jsx)(o,{className:"text-muted-foreground tabular-nums",children:B(I(r,"updatedAt"),"\u2014")}),(0,e.jsx)(o,{className:"text-right",children:(0,e.jsx)(w,{"data-testid":`agents-thread-open-${d}`,onClick:i(()=>{$(d)},"onClick"),size:"sm",type:"button",variant:"outline",children:t("Timeline")})})]},d)})})]})})}),J!==null&&(0,e.jsx)(S,{error:Q,testId:"agents-messages-error"}),a!==void 0&&(0,e.jsx)(A,{className:"overflow-hidden py-0","data-testid":"agents-thread-detail",children:(0,e.jsxs)(k,{className:"flex flex-col gap-3 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[t("Timeline")," \xB7 ",a,P!==void 0&&(0,e.jsxs)("span",{className:"text-muted-foreground",children:[" \xB7 ",t("Usage"),": ",M(P)??0," ",t("Tokens")]})]}),(0,e.jsx)(w,{"data-testid":"agents-thread-detail-close",onClick:i(()=>{$(void 0)},"onClick"),size:"xs",type:"button",variant:"ghost",children:t("Close")})]}),E.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:t("This thread has no messages yet.")}):(0,e.jsxs)(C,{"data-testid":"agents-messages-table",children:[(0,e.jsx)(K,{children:(0,e.jsxs)(m,{children:[(0,e.jsx)(n,{children:t("Role")}),(0,e.jsx)(n,{children:t("Content")}),(0,e.jsx)(n,{children:t("Tool")}),(0,e.jsx)(n,{children:t("Approval")})]})}),(0,e.jsx)(j,{children:E.map((r,d)=>{let c=l(r,"role")??"\u2014",g=re(r),V=l(r,"toolName"),y=l(r,"status"),N=I(r,"seq")??d;return(0,e.jsxs)(m,{"data-testid":`agents-message-${String(N)}`,children:[(0,e.jsx)(o,{className:"font-mono text-xs align-top text-muted-foreground",children:c}),(0,e.jsx)(o,{className:"max-w-md font-mono text-xs whitespace-pre-wrap break-words",children:l(r,"content")??"\u2014"}),(0,e.jsx)(o,{className:"font-mono text-xs align-top text-muted-foreground",children:V??(g.length>0?g.join(", "):"\u2014")}),(0,e.jsx)(o,{className:"align-top",children:y===void 0?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"\u2014"}):(0,e.jsx)(b,{"data-testid":`agents-message-approval-${String(N)}`,variant:ne(y),children:y})})]},l(r,"messageKey")??`${c}:${String(N)}`)})})]})]})})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-agents-panel",children:[O!==null&&(0,e.jsx)(S,{error:R,testId:"agents-error"}),(0,e.jsx)("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.")}),G!==void 0&&(0,e.jsx)("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.")}),h]})},"pe");export{fe as AgentsPanel};
@@ -1 +1 @@
1
- import{a as U}from"./chunk-UNUU7CJJ.js";import"./chunk-XXQUMVWH.js";import{b as O}from"./chunk-OWADN6BI.js";import{a as B,b as G,c as H,d as P,e as x,f as w}from"./chunk-MIQTKZAR.js";import{a as z,e as D}from"./chunk-UZERI5YC.js";import{R as k}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as q}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as F}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as R}from"./chunk-GXZAXNZI.js";import"./chunk-LWECXQWP.js";import"./chunk-XBDKZZ67.js";import{a as K}from"./chunk-XQCVZAGU.js";import{d as T,q as M}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as L,e as j,f as V,g as X,h as Y}from"./chunk-3XIESWL4.js";var J=j(X(),1),W=j(V(),1);var t=j(Y(),1);var de=L(()=>{let e=(0,J.c)(39),r=T(),[s,$]=(0,W.useState)(""),N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N={},e[0]=N):N=e[0];let{data:b,error:i,errorSource:S,isLoading:_,refetch:E}=O(R.getAuthAuditLog,N),A;if(e[1]!==b?.entries||e[2]!==s){let a=b?.entries??[],v=s.trim().toLowerCase();A=v===""?a:a.filter(y=>y.event.toLowerCase().includes(v)||(y.actorId??"").toLowerCase().includes(v)||(y.actorEmail??"").toLowerCase().includes(v)||(y.ip??"").toLowerCase().includes(v)||y.outcome.toLowerCase().includes(v)),e[1]=b?.entries,e[2]=s,e[3]=A}else A=e[3];let o=A,C;e[4]===Symbol.for("react.memo_cache_sentinel")?(C=L(a=>{$(a.target.value)},"I"),e[4]=C):C=e[4];let Q=C,l;e[5]!==r?(l=r("Filter security events"),e[5]=r,e[6]=l):l=e[6];let n;e[7]!==r?(n=r("filter event, actor, IP"),e[7]=r,e[8]=n):n=e[8];let c;e[9]!==s||e[10]!==l||e[11]!==n?(c=(0,t.jsx)(k,{"aria-label":l,className:"h-8 w-56","data-testid":"aa-search",onChange:Q,placeholder:n,value:s}),e[9]=s,e[10]=l,e[11]=n,e[12]=c):c=e[12];let d;e[13]!==E?(d=L(()=>{E()},"m"),e[13]=E,e[14]=d):d=e[14];let m;e[15]!==r?(m=r("Refresh"),e[15]=r,e[16]=m):m=e[16];let u;e[17]!==d||e[18]!==m?(u=(0,t.jsx)(q,{"data-testid":"aa-refresh",onClick:d,size:"xs",type:"button",variant:"ghost",children:m}),e[17]=d,e[18]=m,e[19]=u):u=e[19];let h;e[20]!==c||e[21]!==u?(h=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,u]}),e[20]=c,e[21]=u,e[22]=h):h=e[22];let f;e[23]!==i||e[24]!==S?(f=i!==null&&(0,t.jsx)(U,{error:S,testId:"aa-error"}),e[23]=i,e[24]=S,e[25]=f):f=e[25];let p;e[26]!==i||e[27]!==o.length||e[28]!==_||e[29]!==r?(p=i===null&&!_&&o.length===0&&(0,t.jsx)(K,{description:r("Authentication and security events are recorded here."),testId:"aa-empty",title:r("No security events.")}),e[26]=i,e[27]=o.length,e[28]=_,e[29]=r,e[30]=p):p=e[30];let g;e[31]!==o||e[32]!==r?(g=o.length>0&&(0,t.jsx)(z,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"max-h-[30rem] overflow-auto px-0",children:(0,t.jsxs)(B,{"data-testid":"aa-table",children:[(0,t.jsx)(G,{children:(0,t.jsxs)(P,{children:[(0,t.jsx)(x,{children:r("time")}),(0,t.jsx)(x,{children:r("event")}),(0,t.jsx)(x,{children:r("actor")}),(0,t.jsx)(x,{children:r("ip / user agent")}),(0,t.jsx)(x,{children:r("outcome")})]})}),(0,t.jsx)(H,{children:o.map(a=>(0,t.jsxs)(P,{"data-testid":"aa-row",children:[(0,t.jsx)(w,{className:"text-muted-foreground tabular-nums",children:M(a.ts,"\u2014")}),(0,t.jsx)(w,{children:(0,t.jsx)(F,{variant:"secondary",children:a.event})}),(0,t.jsx)(w,{className:"max-w-[24ch] truncate font-mono text-xs",title:a.actorId??void 0,children:a.actorEmail??a.actorId??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,t.jsxs)(w,{className:"max-w-[28ch] truncate text-xs text-muted-foreground",title:a.userAgent??void 0,children:[a.ip??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),a.userAgent!==void 0&&(0,t.jsxs)("span",{className:"ml-1 opacity-70",children:["\xB7 ",a.userAgent]})]}),(0,t.jsx)(w,{children:(0,t.jsx)(F,{variant:a.outcome==="failure"?"destructive":"outline",children:r(a.outcome)})})]},a.seq))})]})})}),e[31]=o,e[32]=r,e[33]=g):g=e[33];let I;return e[34]!==f||e[35]!==p||e[36]!==g||e[37]!==h?(I=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-auth-audit",children:[h,f,p,g]}),e[34]=f,e[35]=p,e[36]=g,e[37]=h,e[38]=I):I=e[38],I},"ce");export{de as AuthAuditPanel};
1
+ import{a as U}from"./chunk-UNUU7CJJ.js";import"./chunk-XXQUMVWH.js";import{b as O}from"./chunk-XSD4Y6SQ.js";import{a as B,b as G,c as H,d as P,e as x,f as w}from"./chunk-MIQTKZAR.js";import{a as z,e as D}from"./chunk-UZERI5YC.js";import{R as k}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as q}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as F}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as R}from"./chunk-GXZAXNZI.js";import"./chunk-35II7U25.js";import"./chunk-XBDKZZ67.js";import{a as K}from"./chunk-XQCVZAGU.js";import{d as T,q as M}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as L,e as j,f as V,g as X,h as Y}from"./chunk-3XIESWL4.js";var J=j(X(),1),W=j(V(),1);var t=j(Y(),1);var de=L(()=>{let e=(0,J.c)(39),r=T(),[s,$]=(0,W.useState)(""),N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N={},e[0]=N):N=e[0];let{data:b,error:i,errorSource:S,isLoading:_,refetch:E}=O(R.getAuthAuditLog,N),A;if(e[1]!==b?.entries||e[2]!==s){let a=b?.entries??[],v=s.trim().toLowerCase();A=v===""?a:a.filter(y=>y.event.toLowerCase().includes(v)||(y.actorId??"").toLowerCase().includes(v)||(y.actorEmail??"").toLowerCase().includes(v)||(y.ip??"").toLowerCase().includes(v)||y.outcome.toLowerCase().includes(v)),e[1]=b?.entries,e[2]=s,e[3]=A}else A=e[3];let o=A,C;e[4]===Symbol.for("react.memo_cache_sentinel")?(C=L(a=>{$(a.target.value)},"I"),e[4]=C):C=e[4];let Q=C,l;e[5]!==r?(l=r("Filter security events"),e[5]=r,e[6]=l):l=e[6];let n;e[7]!==r?(n=r("filter event, actor, IP"),e[7]=r,e[8]=n):n=e[8];let c;e[9]!==s||e[10]!==l||e[11]!==n?(c=(0,t.jsx)(k,{"aria-label":l,className:"h-8 w-56","data-testid":"aa-search",onChange:Q,placeholder:n,value:s}),e[9]=s,e[10]=l,e[11]=n,e[12]=c):c=e[12];let d;e[13]!==E?(d=L(()=>{E()},"m"),e[13]=E,e[14]=d):d=e[14];let m;e[15]!==r?(m=r("Refresh"),e[15]=r,e[16]=m):m=e[16];let u;e[17]!==d||e[18]!==m?(u=(0,t.jsx)(q,{"data-testid":"aa-refresh",onClick:d,size:"xs",type:"button",variant:"ghost",children:m}),e[17]=d,e[18]=m,e[19]=u):u=e[19];let h;e[20]!==c||e[21]!==u?(h=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,u]}),e[20]=c,e[21]=u,e[22]=h):h=e[22];let f;e[23]!==i||e[24]!==S?(f=i!==null&&(0,t.jsx)(U,{error:S,testId:"aa-error"}),e[23]=i,e[24]=S,e[25]=f):f=e[25];let p;e[26]!==i||e[27]!==o.length||e[28]!==_||e[29]!==r?(p=i===null&&!_&&o.length===0&&(0,t.jsx)(K,{description:r("Authentication and security events are recorded here."),testId:"aa-empty",title:r("No security events.")}),e[26]=i,e[27]=o.length,e[28]=_,e[29]=r,e[30]=p):p=e[30];let g;e[31]!==o||e[32]!==r?(g=o.length>0&&(0,t.jsx)(z,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"max-h-[30rem] overflow-auto px-0",children:(0,t.jsxs)(B,{"data-testid":"aa-table",children:[(0,t.jsx)(G,{children:(0,t.jsxs)(P,{children:[(0,t.jsx)(x,{children:r("time")}),(0,t.jsx)(x,{children:r("event")}),(0,t.jsx)(x,{children:r("actor")}),(0,t.jsx)(x,{children:r("ip / user agent")}),(0,t.jsx)(x,{children:r("outcome")})]})}),(0,t.jsx)(H,{children:o.map(a=>(0,t.jsxs)(P,{"data-testid":"aa-row",children:[(0,t.jsx)(w,{className:"text-muted-foreground tabular-nums",children:M(a.ts,"\u2014")}),(0,t.jsx)(w,{children:(0,t.jsx)(F,{variant:"secondary",children:a.event})}),(0,t.jsx)(w,{className:"max-w-[24ch] truncate font-mono text-xs",title:a.actorId??void 0,children:a.actorEmail??a.actorId??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,t.jsxs)(w,{className:"max-w-[28ch] truncate text-xs text-muted-foreground",title:a.userAgent??void 0,children:[a.ip??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),a.userAgent!==void 0&&(0,t.jsxs)("span",{className:"ml-1 opacity-70",children:["\xB7 ",a.userAgent]})]}),(0,t.jsx)(w,{children:(0,t.jsx)(F,{variant:a.outcome==="failure"?"destructive":"outline",children:r(a.outcome)})})]},a.seq))})]})})}),e[31]=o,e[32]=r,e[33]=g):g=e[33];let I;return e[34]!==f||e[35]!==p||e[36]!==g||e[37]!==h?(I=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-auth-audit",children:[h,f,p,g]}),e[34]=f,e[35]=p,e[36]=g,e[37]=h,e[38]=I):I=e[38],I},"ce");export{de as AuthAuditPanel};
@@ -1 +1 @@
1
- import{a as ae}from"./chunk-UZERI5YC.js";import{a as le}from"./chunk-HPFLBYRI.js";import{b as re}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{d as de,f as oe}from"./chunk-LWECXQWP.js";import"./chunk-XBDKZZ67.js";import{a as me}from"./chunk-XQCVZAGU.js";import{d as ce,q as pe}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as k,e as ie,g as xe,h as ge,j as Z}from"./chunk-3XIESWL4.js";var ne=ie(xe(),1);var a=ie(ge(),1);var ye="/_lunora/health",Ne="/_lunora/health/ready",ve=k((n,e)=>(n.endsWith("/")?n.slice(0,-1):n)+e,"xe"),be=k(()=>{let n=oe();return async e=>{let w=e==="ready"?Ne:ye,t=n.getAuthToken(),_=ve(n.url,w);try{let l=await fetch(_,{headers:t===null?{}:{authorization:`Bearer ${t}`}}),d=null;try{d=await l.json()}catch{d=null}return{body:d,ok:l.ok,status:l.status}}catch(l){return{body:null,error:l instanceof Error?l.message:String(l),ok:!1,status:0}}}},"Ne"),he={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},ke={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},we=k(n=>n==="unhealthy"?"crit":n==="degraded"?"warn":"ok","ye"),ue=k(n=>{let e=(0,ne.c)(13),{label:w,level:t,testId:_,value:l}=n,d=he[t],o;e[0]!==d?(o=Z("size-1.5 shrink-0 rounded-full",d),e[0]=d,e[1]=o):o=e[1];let c;e[2]!==o?(c=(0,a.jsx)("span",{"aria-hidden":"true",className:o}),e[2]=o,e[3]=c):c=e[3];let x;e[4]!==w||e[5]!==c?(x=(0,a.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[c,w]}),e[4]=w,e[5]=c,e[6]=x):x=e[6];let g;e[7]!==_||e[8]!==l?(g=(0,a.jsx)("span",{className:"text-lg font-semibold text-foreground","data-testid":_,children:l}),e[7]=_,e[8]=l,e[9]=g):g=e[9];let u;return e[10]!==x||e[11]!==g?(u=(0,a.jsx)(ae,{className:"gap-0 py-0",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[x,g]})}),e[10]=x,e[11]=g,e[12]=u):u=e[12],u},"ne"),De=k(n=>{let e=(0,ne.c)(115),{probe:w}=n,t=ce(),_=be(),l=w??_,d;e[0]!==l?(d=k(async()=>{let[s,i]=await Promise.all([l("live"),l("ready")]);return{live:s,ready:i}},"d"),e[0]=l,e[1]=d):d=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=["deployment-health"],e[2]=o):o=e[2];let c;e[3]!==d?(c={queryFn:d,queryKey:o},e[3]=d,e[4]=c):c=e[4];let{data:x,isPending:g}=de(c),u=x?.live??null,fe=x?.ready??null;if(g){let s;return e[5]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"deployment-health-loading",children:[(0,a.jsx)(le,{className:"h-16 w-full"}),(0,a.jsx)(le,{className:"h-40 w-full"})]}),e[5]=s):s=e[5],s}let r=u?.body??null;if(r===null){let s=u?.status===403,i;e[6]!==s||e[7]!==u?.error||e[8]!==t?(i=s?t("The health endpoint is in the admin posture. Paste a valid admin token in the connect popover, or set its auth to public."):t("Couldn't reach the health endpoint: {message}",{message:u?.error??t("no response")}),e[6]=s,e[7]=u?.error,e[8]=t,e[9]=i):i=e[9];let h;e[10]!==t?(h=t("Health endpoint unavailable"),e[10]=t,e[11]=h):h=e[11];let p;return e[12]!==i||e[13]!==h?(p=(0,a.jsx)(me,{description:i,testId:"deployment-health-error",title:h}),e[12]=i,e[13]=h,e[14]=p):p=e[14],p}let ee;e[15]!==r.status?(ee=we(r.status),e[15]=r.status,e[16]=ee):ee=e[16];let j=ee,m;if(r.status==="unhealthy"){let s;e[17]!==t?(s=t("Unhealthy"),e[17]=t,e[18]=s):s=e[18],m=s}else if(r.status==="degraded"){let s;e[19]!==t?(s=t("Degraded"),e[19]=t,e[20]=s):s=e[20],m=s}else{let s;e[21]!==t?(s=t("Healthy"),e[21]=t,e[22]=s):s=e[22],m=s}let C=fe?.ok??!1,Y=C?"ok":"crit",z,I,y,N,v,S,V,b,$,H;if(e[23]!==r.appName||e[24]!==r.appVersion||e[25]!==r.checks||e[26]!==r.timestamp||e[27]!==j||e[28]!==Y||e[29]!==C||e[30]!==m||e[31]!==t){let s=[...r.checks].toSorted(_e);H="flex flex-col gap-6",I="deployment-health";let i;e[42]!==t?(i=t("Live liveness, readiness, and per-binding health from the deployment's /_lunora/health endpoint \u2014 wire an uptime monitor or a Cloudflare Health Check at it."),e[42]=t,e[43]=i):i=e[43],e[44]!==i?(y=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:i}),e[44]=i,e[45]=y):y=e[45];let h=ke[j],p;e[46]!==h?(p=Z("flex size-10 shrink-0 items-center justify-center rounded-full",h),e[46]=h,e[47]=p):p=e[47];let se=he[j],D;e[48]!==se?(D=Z("size-3 rounded-full",se),e[48]=se,e[49]=D):D=e[49];let L;e[50]!==D?(L=(0,a.jsx)("span",{className:D}),e[50]=D,e[51]=L):L=e[51];let T;e[52]!==p||e[53]!==L?(T=(0,a.jsx)("span",{"aria-hidden":"true",className:p,children:L}),e[52]=p,e[53]=L,e[54]=T):T=e[54];let q;e[55]!==m?(q=(0,a.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"dh-status",children:m}),e[55]=m,e[56]=q):q=e[56];let E;e[57]!==r.appName||e[58]!==r.appVersion?(E=(0,a.jsxs)("span",{className:"font-mono text-[13px] text-muted-foreground","data-testid":"dh-app",children:[r.appName," \xB7 ",r.appVersion]}),e[57]=r.appName,e[58]=r.appVersion,e[59]=E):E=e[59];let R;e[60]!==q||e[61]!==E?(R=(0,a.jsxs)("div",{className:"grid leading-tight",children:[q,E]}),e[60]=q,e[61]=E,e[62]=R):R=e[62];let U;e[63]!==T||e[64]!==R?(U=(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[T,R]}),e[63]=T,e[64]=R,e[65]=U):U=e[65];let A;e[66]!==t?(A=t("Checked"),e[66]=t,e[67]=A):A=e[67];let B;e[68]!==A?(B=(0,a.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:A}),e[68]=A,e[69]=B):B=e[69];let F;e[70]!==r.timestamp?(F=pe(r.timestamp),e[70]=r.timestamp,e[71]=F):F=e[71];let K;e[72]!==F?(K=(0,a.jsx)("time",{className:"text-[13px] text-muted-foreground","data-testid":"dh-timestamp",children:F}),e[72]=F,e[73]=K):K=e[73];let Q;e[74]!==B||e[75]!==K?(Q=(0,a.jsxs)("div",{className:"text-end",children:[B,K]}),e[74]=B,e[75]=K,e[76]=Q):Q=e[76],e[77]!==U||e[78]!==Q?(N=(0,a.jsx)(ae,{className:"gap-0 py-0",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[U,Q]})}),e[77]=U,e[78]=Q,e[79]=N):N=e[79];let W;e[80]!==t?(W=t("Liveness"),e[80]=t,e[81]=W):W=e[81];let G;e[82]!==j||e[83]!==m||e[84]!==W?(G=(0,a.jsx)(ue,{label:W,level:j,testId:"dh-liveness",value:m}),e[82]=j,e[83]=m,e[84]=W,e[85]=G):G=e[85];let J;e[86]!==t?(J=t("Readiness"),e[86]=t,e[87]=J):J=e[87];let M;e[88]!==C||e[89]!==t?(M=t(C?"Ready":"Not ready"),e[88]=C,e[89]=t,e[90]=M):M=e[90];let O;e[91]!==Y||e[92]!==J||e[93]!==M?(O=(0,a.jsx)(ue,{label:J,level:Y,testId:"dh-readiness",value:M}),e[91]=Y,e[92]=J,e[93]=M,e[94]=O):O=e[94],e[95]!==G||e[96]!==O?(v=(0,a.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2","data-testid":"dh-probes",children:[G,O]}),e[95]=G,e[96]=O,e[97]=v):v=e[97],z=ae,S="gap-0 py-0",V="dh-checks";let X;e[98]!==t?(X=t("Subsystem checks"),e[98]=t,e[99]=X):X=e[99],e[100]!==X?(b=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:X})}),e[100]=X,e[101]=b):b=e[101],$=s.length===0?(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"dh-checks-empty",children:t("No checks reported.")}):(0,a.jsx)("ul",{className:"divide-y divide-border",children:s.map(f=>(0,a.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2.5 text-xs","data-testid":`dh-check-${f.name}`,children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":"true",className:Z("size-1.5 shrink-0 rounded-full",f.status==="up"?"bg-success":"bg-destructive")}),(0,a.jsx)("span",{className:"font-mono text-foreground",children:f.name}),f.critical&&(0,a.jsx)(re,{variant:"outline",children:t("Critical")})]}),(0,a.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[f.message!==void 0&&(0,a.jsx)("span",{className:"text-muted-foreground",children:f.message}),(0,a.jsx)(re,{"data-testid":`dh-check-status-${f.name}`,variant:f.status==="up"?"secondary":"destructive",children:f.status==="up"?t("Up"):t("Down")})]})]},f.name))}),e[23]=r.appName,e[24]=r.appVersion,e[25]=r.checks,e[26]=r.timestamp,e[27]=j,e[28]=Y,e[29]=C,e[30]=m,e[31]=t,e[32]=z,e[33]=I,e[34]=y,e[35]=N,e[36]=v,e[37]=S,e[38]=V,e[39]=b,e[40]=$,e[41]=H}else z=e[32],I=e[33],y=e[34],N=e[35],v=e[36],S=e[37],V=e[38],b=e[39],$=e[40],H=e[41];let P;e[102]!==z||e[103]!==S||e[104]!==V||e[105]!==b||e[106]!==$?(P=(0,a.jsxs)(z,{className:S,"data-testid":V,children:[b,$]}),e[102]=z,e[103]=S,e[104]=V,e[105]=b,e[106]=$,e[107]=P):P=e[107];let te;return e[108]!==I||e[109]!==y||e[110]!==N||e[111]!==v||e[112]!==P||e[113]!==H?(te=(0,a.jsxs)("div",{className:H,"data-testid":I,children:[y,N,v,P]}),e[108]=I,e[109]=y,e[110]=N,e[111]=v,e[112]=P,e[113]=H,e[114]=te):te=e[114],te},"Ie");function _e(n,e){return n.name.localeCompare(e.name)}k(_e,"be");export{De as DeploymentHealthPanel};
1
+ import{a as ae}from"./chunk-UZERI5YC.js";import{a as le}from"./chunk-HPFLBYRI.js";import{b as re}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{d as de,f as oe}from"./chunk-35II7U25.js";import"./chunk-XBDKZZ67.js";import{a as me}from"./chunk-XQCVZAGU.js";import{d as ce,q as pe}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as k,e as ie,g as xe,h as ge,j as Z}from"./chunk-3XIESWL4.js";var ne=ie(xe(),1);var a=ie(ge(),1);var ye="/_lunora/health",Ne="/_lunora/health/ready",ve=k((n,e)=>(n.endsWith("/")?n.slice(0,-1):n)+e,"xe"),be=k(()=>{let n=oe();return async e=>{let w=e==="ready"?Ne:ye,t=n.getAuthToken(),_=ve(n.url,w);try{let l=await fetch(_,{headers:t===null?{}:{authorization:`Bearer ${t}`}}),d=null;try{d=await l.json()}catch{d=null}return{body:d,ok:l.ok,status:l.status}}catch(l){return{body:null,error:l instanceof Error?l.message:String(l),ok:!1,status:0}}}},"Ne"),he={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},ke={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},we=k(n=>n==="unhealthy"?"crit":n==="degraded"?"warn":"ok","ye"),ue=k(n=>{let e=(0,ne.c)(13),{label:w,level:t,testId:_,value:l}=n,d=he[t],o;e[0]!==d?(o=Z("size-1.5 shrink-0 rounded-full",d),e[0]=d,e[1]=o):o=e[1];let c;e[2]!==o?(c=(0,a.jsx)("span",{"aria-hidden":"true",className:o}),e[2]=o,e[3]=c):c=e[3];let x;e[4]!==w||e[5]!==c?(x=(0,a.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[c,w]}),e[4]=w,e[5]=c,e[6]=x):x=e[6];let g;e[7]!==_||e[8]!==l?(g=(0,a.jsx)("span",{className:"text-lg font-semibold text-foreground","data-testid":_,children:l}),e[7]=_,e[8]=l,e[9]=g):g=e[9];let u;return e[10]!==x||e[11]!==g?(u=(0,a.jsx)(ae,{className:"gap-0 py-0",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[x,g]})}),e[10]=x,e[11]=g,e[12]=u):u=e[12],u},"ne"),De=k(n=>{let e=(0,ne.c)(115),{probe:w}=n,t=ce(),_=be(),l=w??_,d;e[0]!==l?(d=k(async()=>{let[s,i]=await Promise.all([l("live"),l("ready")]);return{live:s,ready:i}},"d"),e[0]=l,e[1]=d):d=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=["deployment-health"],e[2]=o):o=e[2];let c;e[3]!==d?(c={queryFn:d,queryKey:o},e[3]=d,e[4]=c):c=e[4];let{data:x,isPending:g}=de(c),u=x?.live??null,fe=x?.ready??null;if(g){let s;return e[5]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"deployment-health-loading",children:[(0,a.jsx)(le,{className:"h-16 w-full"}),(0,a.jsx)(le,{className:"h-40 w-full"})]}),e[5]=s):s=e[5],s}let r=u?.body??null;if(r===null){let s=u?.status===403,i;e[6]!==s||e[7]!==u?.error||e[8]!==t?(i=s?t("The health endpoint is in the admin posture. Paste a valid admin token in the connect popover, or set its auth to public."):t("Couldn't reach the health endpoint: {message}",{message:u?.error??t("no response")}),e[6]=s,e[7]=u?.error,e[8]=t,e[9]=i):i=e[9];let h;e[10]!==t?(h=t("Health endpoint unavailable"),e[10]=t,e[11]=h):h=e[11];let p;return e[12]!==i||e[13]!==h?(p=(0,a.jsx)(me,{description:i,testId:"deployment-health-error",title:h}),e[12]=i,e[13]=h,e[14]=p):p=e[14],p}let ee;e[15]!==r.status?(ee=we(r.status),e[15]=r.status,e[16]=ee):ee=e[16];let j=ee,m;if(r.status==="unhealthy"){let s;e[17]!==t?(s=t("Unhealthy"),e[17]=t,e[18]=s):s=e[18],m=s}else if(r.status==="degraded"){let s;e[19]!==t?(s=t("Degraded"),e[19]=t,e[20]=s):s=e[20],m=s}else{let s;e[21]!==t?(s=t("Healthy"),e[21]=t,e[22]=s):s=e[22],m=s}let C=fe?.ok??!1,Y=C?"ok":"crit",z,I,y,N,v,S,V,b,$,H;if(e[23]!==r.appName||e[24]!==r.appVersion||e[25]!==r.checks||e[26]!==r.timestamp||e[27]!==j||e[28]!==Y||e[29]!==C||e[30]!==m||e[31]!==t){let s=[...r.checks].toSorted(_e);H="flex flex-col gap-6",I="deployment-health";let i;e[42]!==t?(i=t("Live liveness, readiness, and per-binding health from the deployment's /_lunora/health endpoint \u2014 wire an uptime monitor or a Cloudflare Health Check at it."),e[42]=t,e[43]=i):i=e[43],e[44]!==i?(y=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:i}),e[44]=i,e[45]=y):y=e[45];let h=ke[j],p;e[46]!==h?(p=Z("flex size-10 shrink-0 items-center justify-center rounded-full",h),e[46]=h,e[47]=p):p=e[47];let se=he[j],D;e[48]!==se?(D=Z("size-3 rounded-full",se),e[48]=se,e[49]=D):D=e[49];let L;e[50]!==D?(L=(0,a.jsx)("span",{className:D}),e[50]=D,e[51]=L):L=e[51];let T;e[52]!==p||e[53]!==L?(T=(0,a.jsx)("span",{"aria-hidden":"true",className:p,children:L}),e[52]=p,e[53]=L,e[54]=T):T=e[54];let q;e[55]!==m?(q=(0,a.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"dh-status",children:m}),e[55]=m,e[56]=q):q=e[56];let E;e[57]!==r.appName||e[58]!==r.appVersion?(E=(0,a.jsxs)("span",{className:"font-mono text-[13px] text-muted-foreground","data-testid":"dh-app",children:[r.appName," \xB7 ",r.appVersion]}),e[57]=r.appName,e[58]=r.appVersion,e[59]=E):E=e[59];let R;e[60]!==q||e[61]!==E?(R=(0,a.jsxs)("div",{className:"grid leading-tight",children:[q,E]}),e[60]=q,e[61]=E,e[62]=R):R=e[62];let U;e[63]!==T||e[64]!==R?(U=(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[T,R]}),e[63]=T,e[64]=R,e[65]=U):U=e[65];let A;e[66]!==t?(A=t("Checked"),e[66]=t,e[67]=A):A=e[67];let B;e[68]!==A?(B=(0,a.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:A}),e[68]=A,e[69]=B):B=e[69];let F;e[70]!==r.timestamp?(F=pe(r.timestamp),e[70]=r.timestamp,e[71]=F):F=e[71];let K;e[72]!==F?(K=(0,a.jsx)("time",{className:"text-[13px] text-muted-foreground","data-testid":"dh-timestamp",children:F}),e[72]=F,e[73]=K):K=e[73];let Q;e[74]!==B||e[75]!==K?(Q=(0,a.jsxs)("div",{className:"text-end",children:[B,K]}),e[74]=B,e[75]=K,e[76]=Q):Q=e[76],e[77]!==U||e[78]!==Q?(N=(0,a.jsx)(ae,{className:"gap-0 py-0",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[U,Q]})}),e[77]=U,e[78]=Q,e[79]=N):N=e[79];let W;e[80]!==t?(W=t("Liveness"),e[80]=t,e[81]=W):W=e[81];let G;e[82]!==j||e[83]!==m||e[84]!==W?(G=(0,a.jsx)(ue,{label:W,level:j,testId:"dh-liveness",value:m}),e[82]=j,e[83]=m,e[84]=W,e[85]=G):G=e[85];let J;e[86]!==t?(J=t("Readiness"),e[86]=t,e[87]=J):J=e[87];let M;e[88]!==C||e[89]!==t?(M=t(C?"Ready":"Not ready"),e[88]=C,e[89]=t,e[90]=M):M=e[90];let O;e[91]!==Y||e[92]!==J||e[93]!==M?(O=(0,a.jsx)(ue,{label:J,level:Y,testId:"dh-readiness",value:M}),e[91]=Y,e[92]=J,e[93]=M,e[94]=O):O=e[94],e[95]!==G||e[96]!==O?(v=(0,a.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2","data-testid":"dh-probes",children:[G,O]}),e[95]=G,e[96]=O,e[97]=v):v=e[97],z=ae,S="gap-0 py-0",V="dh-checks";let X;e[98]!==t?(X=t("Subsystem checks"),e[98]=t,e[99]=X):X=e[99],e[100]!==X?(b=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:X})}),e[100]=X,e[101]=b):b=e[101],$=s.length===0?(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"dh-checks-empty",children:t("No checks reported.")}):(0,a.jsx)("ul",{className:"divide-y divide-border",children:s.map(f=>(0,a.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2.5 text-xs","data-testid":`dh-check-${f.name}`,children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":"true",className:Z("size-1.5 shrink-0 rounded-full",f.status==="up"?"bg-success":"bg-destructive")}),(0,a.jsx)("span",{className:"font-mono text-foreground",children:f.name}),f.critical&&(0,a.jsx)(re,{variant:"outline",children:t("Critical")})]}),(0,a.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[f.message!==void 0&&(0,a.jsx)("span",{className:"text-muted-foreground",children:f.message}),(0,a.jsx)(re,{"data-testid":`dh-check-status-${f.name}`,variant:f.status==="up"?"secondary":"destructive",children:f.status==="up"?t("Up"):t("Down")})]})]},f.name))}),e[23]=r.appName,e[24]=r.appVersion,e[25]=r.checks,e[26]=r.timestamp,e[27]=j,e[28]=Y,e[29]=C,e[30]=m,e[31]=t,e[32]=z,e[33]=I,e[34]=y,e[35]=N,e[36]=v,e[37]=S,e[38]=V,e[39]=b,e[40]=$,e[41]=H}else z=e[32],I=e[33],y=e[34],N=e[35],v=e[36],S=e[37],V=e[38],b=e[39],$=e[40],H=e[41];let P;e[102]!==z||e[103]!==S||e[104]!==V||e[105]!==b||e[106]!==$?(P=(0,a.jsxs)(z,{className:S,"data-testid":V,children:[b,$]}),e[102]=z,e[103]=S,e[104]=V,e[105]=b,e[106]=$,e[107]=P):P=e[107];let te;return e[108]!==I||e[109]!==y||e[110]!==N||e[111]!==v||e[112]!==P||e[113]!==H?(te=(0,a.jsxs)("div",{className:H,"data-testid":I,children:[y,N,v,P]}),e[108]=I,e[109]=y,e[110]=N,e[111]=v,e[112]=P,e[113]=H,e[114]=te):te=e[114],te},"Ie");function _e(n,e){return n.name.localeCompare(e.name)}k(_e,"be");export{De as DeploymentHealthPanel};
@@ -1 +1 @@
1
- import{a as U}from"./chunk-UNUU7CJJ.js";import"./chunk-XXQUMVWH.js";import{b as K}from"./chunk-OWADN6BI.js";import{a as q,b as G,c as J,d as M,e as a,f as o}from"./chunk-MIQTKZAR.js";import{a as W,e as B}from"./chunk-UZERI5YC.js";import{R as V}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as F}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as C}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as O}from"./chunk-GXZAXNZI.js";import"./chunk-LWECXQWP.js";import"./chunk-XBDKZZ67.js";import{a as D}from"./chunk-XQCVZAGU.js";import{d as T,q as H}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as n,e as j,f as re,g as se,h as ie}from"./chunk-3XIESWL4.js";var X=j(se(),1),P=j(re(),1);var t=j(ie(),1);var ne=n(e=>e==="ok"?"success":e==="failed"?"destructive":e==="expired"?"warning":"secondary","te"),Q=n(e=>e.endpoint??e.id,"P"),xe=n(()=>{let e=(0,X.c)(38),r=T(),[i,Y]=(0,P.useState)("all"),[l,Z]=(0,P.useState)(""),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={},e[0]=g):g=e[0];let{data:_,error:c,errorSource:v,isLoading:I,refetch:x}=K(O.listPushSubscriptions,g),N;if(e[1]!==_?.subscriptions||e[2]!==c||e[3]!==v||e[4]!==I||e[5]!==i||e[6]!==x||e[7]!==l||e[8]!==r){let L=_?.subscriptions??[],z=l.trim().toLowerCase(),A=L.filter(s=>i!=="all"&&s.kind!==i?!1:z===""?!0:`${Q(s)} ${s.userId??""}`.toLowerCase().includes(z)),b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=n(s=>{Z(s.target.value)},"b"),e[10]=b):b=e[10];let ee=b,w;e[11]!==x?(w=n(()=>{x()},"w"),e[11]=x,e[12]=w):w=e[12];let E=w,k;e[13]===Symbol.for("react.memo_cache_sentinel")?(k=["all","web-push","fcm"],e[13]=k):k=e[13];let te=k,d;e[14]!==i||e[15]!==r?(d=(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"nt-kind-filter",role:"tablist",children:te.map(s=>(0,t.jsx)(F,{"aria-selected":i===s,"data-testid":`nt-kind-${s}`,onClick:n(()=>{Y(s)},"onClick"),role:"tab",size:"sm",type:"button",variant:i===s?"secondary":"ghost",children:s==="all"?r("All"):s},s))}),e[14]=i,e[15]=r,e[16]=d):d=e[16];let m;e[17]!==r?(m=r("Filter devices"),e[17]=r,e[18]=m):m=e[18];let h;e[19]!==r?(h=r("filter endpoint, user"),e[19]=r,e[20]=h):h=e[20];let u;e[21]!==l||e[22]!==m||e[23]!==h?(u=(0,t.jsx)(V,{"aria-label":m,className:"h-8 w-56","data-testid":"nt-search",onChange:ee,placeholder:h,value:l}),e[21]=l,e[22]=m,e[23]=h,e[24]=u):u=e[24];let f;e[25]!==r?(f=r("Refresh"),e[25]=r,e[26]=f):f=e[26];let p;e[27]!==E||e[28]!==f?(p=(0,t.jsx)(F,{className:"ml-auto","data-testid":"nt-refresh",onClick:E,size:"sm",type:"button",variant:"outline",children:f}),e[27]=E,e[28]=f,e[29]=p):p=e[29];let $=L.length>0&&(0,t.jsx)(C,{"data-testid":"nt-count",variant:"secondary",children:r("{count} devices",{count:L.length})}),y;e[30]!==p||e[31]!==$||e[32]!==d||e[33]!==u?(y=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[d,u,p,$]}),e[30]=p,e[31]=$,e[32]=d,e[33]=u,e[34]=y):y=e[34];let S;e[35]!==c||e[36]!==v?(S=c!==null&&(0,t.jsx)(U,{error:v,testId:"nt-error"}),e[35]=c,e[36]=v,e[37]=S):S=e[37],N=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-notifications",children:[y,S,c===null&&!I&&A.length===0&&(0,t.jsx)(D,{description:r("Registered Web Push / FCM devices appear here. Configure lunora/notify.ts with defineNotify({ store }) and register a device with ctx.push.register(...)."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M15 17h5l-1.4-1.4A2 2 0 0 1 18 14.2V11a6 6 0 0 0-4-5.7V5a2 2 0 1 0-4 0v.3A6 6 0 0 0 6 11v3.2a2 2 0 0 1-.6 1.4L4 17h5m6 0v1a3 3 0 1 1-6 0v-1m6 0H9"})}),testId:"nt-empty",title:r("No registered devices.")}),A.length>0&&(0,t.jsx)(W,{className:"overflow-hidden py-0",children:(0,t.jsx)(B,{className:"max-h-[30rem] overflow-auto px-0",children:(0,t.jsxs)(q,{"data-testid":"nt-table",children:[(0,t.jsx)(G,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(a,{children:r("kind")}),(0,t.jsx)(a,{children:r("endpoint")}),(0,t.jsx)(a,{children:r("user")}),(0,t.jsx)(a,{children:r("last seen")}),(0,t.jsx)(a,{children:r("status")}),(0,t.jsx)(a,{children:r("error")})]})}),(0,t.jsx)(J,{children:A.map(s=>{let R=Q(s);return(0,t.jsxs)(M,{"data-testid":"nt-row",children:[(0,t.jsx)(o,{children:(0,t.jsx)(C,{variant:"outline",children:s.kind})}),(0,t.jsx)(o,{className:"max-w-[28ch] truncate font-mono text-xs",title:R,children:R}),(0,t.jsx)(o,{className:"max-w-[16ch] truncate font-mono text-xs",children:s.userId??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,t.jsx)(o,{className:"text-muted-foreground tabular-nums",children:H(s.lastSeenAt,"\u2014")}),(0,t.jsx)(o,{children:(0,t.jsx)(C,{"data-testid":`nt-status-${s.id}`,variant:ne(s.lastStatus),children:s.lastStatus??r("n/a")})}),(0,t.jsx)(o,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",title:s.lastError??void 0,children:s.lastError??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},s.id)})})]})})})]}),e[1]=_?.subscriptions,e[2]=c,e[3]=v,e[4]=I,e[5]=i,e[6]=x,e[7]=l,e[8]=r,e[9]=N}else N=e[9];return N},"ve");export{xe as NotificationsPanel};
1
+ import{a as U}from"./chunk-UNUU7CJJ.js";import"./chunk-XXQUMVWH.js";import{b as K}from"./chunk-XSD4Y6SQ.js";import{a as q,b as G,c as J,d as M,e as a,f as o}from"./chunk-MIQTKZAR.js";import{a as W,e as B}from"./chunk-UZERI5YC.js";import{R as V}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as F}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as C}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as O}from"./chunk-GXZAXNZI.js";import"./chunk-35II7U25.js";import"./chunk-XBDKZZ67.js";import{a as D}from"./chunk-XQCVZAGU.js";import{d as T,q as H}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as n,e as j,f as re,g as se,h as ie}from"./chunk-3XIESWL4.js";var X=j(se(),1),P=j(re(),1);var t=j(ie(),1);var ne=n(e=>e==="ok"?"success":e==="failed"?"destructive":e==="expired"?"warning":"secondary","te"),Q=n(e=>e.endpoint??e.id,"P"),xe=n(()=>{let e=(0,X.c)(38),r=T(),[i,Y]=(0,P.useState)("all"),[l,Z]=(0,P.useState)(""),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={},e[0]=g):g=e[0];let{data:_,error:c,errorSource:v,isLoading:I,refetch:x}=K(O.listPushSubscriptions,g),N;if(e[1]!==_?.subscriptions||e[2]!==c||e[3]!==v||e[4]!==I||e[5]!==i||e[6]!==x||e[7]!==l||e[8]!==r){let L=_?.subscriptions??[],z=l.trim().toLowerCase(),A=L.filter(s=>i!=="all"&&s.kind!==i?!1:z===""?!0:`${Q(s)} ${s.userId??""}`.toLowerCase().includes(z)),b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=n(s=>{Z(s.target.value)},"b"),e[10]=b):b=e[10];let ee=b,w;e[11]!==x?(w=n(()=>{x()},"w"),e[11]=x,e[12]=w):w=e[12];let E=w,k;e[13]===Symbol.for("react.memo_cache_sentinel")?(k=["all","web-push","fcm"],e[13]=k):k=e[13];let te=k,d;e[14]!==i||e[15]!==r?(d=(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"nt-kind-filter",role:"tablist",children:te.map(s=>(0,t.jsx)(F,{"aria-selected":i===s,"data-testid":`nt-kind-${s}`,onClick:n(()=>{Y(s)},"onClick"),role:"tab",size:"sm",type:"button",variant:i===s?"secondary":"ghost",children:s==="all"?r("All"):s},s))}),e[14]=i,e[15]=r,e[16]=d):d=e[16];let m;e[17]!==r?(m=r("Filter devices"),e[17]=r,e[18]=m):m=e[18];let h;e[19]!==r?(h=r("filter endpoint, user"),e[19]=r,e[20]=h):h=e[20];let u;e[21]!==l||e[22]!==m||e[23]!==h?(u=(0,t.jsx)(V,{"aria-label":m,className:"h-8 w-56","data-testid":"nt-search",onChange:ee,placeholder:h,value:l}),e[21]=l,e[22]=m,e[23]=h,e[24]=u):u=e[24];let f;e[25]!==r?(f=r("Refresh"),e[25]=r,e[26]=f):f=e[26];let p;e[27]!==E||e[28]!==f?(p=(0,t.jsx)(F,{className:"ml-auto","data-testid":"nt-refresh",onClick:E,size:"sm",type:"button",variant:"outline",children:f}),e[27]=E,e[28]=f,e[29]=p):p=e[29];let $=L.length>0&&(0,t.jsx)(C,{"data-testid":"nt-count",variant:"secondary",children:r("{count} devices",{count:L.length})}),y;e[30]!==p||e[31]!==$||e[32]!==d||e[33]!==u?(y=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[d,u,p,$]}),e[30]=p,e[31]=$,e[32]=d,e[33]=u,e[34]=y):y=e[34];let S;e[35]!==c||e[36]!==v?(S=c!==null&&(0,t.jsx)(U,{error:v,testId:"nt-error"}),e[35]=c,e[36]=v,e[37]=S):S=e[37],N=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-notifications",children:[y,S,c===null&&!I&&A.length===0&&(0,t.jsx)(D,{description:r("Registered Web Push / FCM devices appear here. Configure lunora/notify.ts with defineNotify({ store }) and register a device with ctx.push.register(...)."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M15 17h5l-1.4-1.4A2 2 0 0 1 18 14.2V11a6 6 0 0 0-4-5.7V5a2 2 0 1 0-4 0v.3A6 6 0 0 0 6 11v3.2a2 2 0 0 1-.6 1.4L4 17h5m6 0v1a3 3 0 1 1-6 0v-1m6 0H9"})}),testId:"nt-empty",title:r("No registered devices.")}),A.length>0&&(0,t.jsx)(W,{className:"overflow-hidden py-0",children:(0,t.jsx)(B,{className:"max-h-[30rem] overflow-auto px-0",children:(0,t.jsxs)(q,{"data-testid":"nt-table",children:[(0,t.jsx)(G,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(a,{children:r("kind")}),(0,t.jsx)(a,{children:r("endpoint")}),(0,t.jsx)(a,{children:r("user")}),(0,t.jsx)(a,{children:r("last seen")}),(0,t.jsx)(a,{children:r("status")}),(0,t.jsx)(a,{children:r("error")})]})}),(0,t.jsx)(J,{children:A.map(s=>{let R=Q(s);return(0,t.jsxs)(M,{"data-testid":"nt-row",children:[(0,t.jsx)(o,{children:(0,t.jsx)(C,{variant:"outline",children:s.kind})}),(0,t.jsx)(o,{className:"max-w-[28ch] truncate font-mono text-xs",title:R,children:R}),(0,t.jsx)(o,{className:"max-w-[16ch] truncate font-mono text-xs",children:s.userId??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,t.jsx)(o,{className:"text-muted-foreground tabular-nums",children:H(s.lastSeenAt,"\u2014")}),(0,t.jsx)(o,{children:(0,t.jsx)(C,{"data-testid":`nt-status-${s.id}`,variant:ne(s.lastStatus),children:s.lastStatus??r("n/a")})}),(0,t.jsx)(o,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",title:s.lastError??void 0,children:s.lastError??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},s.id)})})]})})})]}),e[1]=_?.subscriptions,e[2]=c,e[3]=v,e[4]=I,e[5]=i,e[6]=x,e[7]=l,e[8]=r,e[9]=N}else N=e[9];return N},"ve");export{xe as NotificationsPanel};
@@ -1 +1 @@
1
- import{a as U}from"./chunk-54MMVNPT.js";import{a as C}from"./chunk-7LQWFOEU.js";import{a as f}from"./chunk-5Y3QLNWX.js";import{R as N}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as O}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as L}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as w}from"./chunk-GXZAXNZI.js";import{f as P}from"./chunk-LWECXQWP.js";import"./chunk-XBDKZZ67.js";import{d as q,f as v,g as c,h,m as p}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as o,e as T,f as W,h as $}from"./chunk-3XIESWL4.js";var a=T(W(),1);var e=T($(),1);var R=v(w.getPitrBookmark),V=v(w.pitrRestore),ne=o(({initialShardKey:j})=>{let m=P(),r=q(),i=j??"",[z,x]=(0,a.useState)(null),[l,A]=(0,a.useState)(""),[B,I]=(0,a.useState)(null),[u,D]=(0,a.useState)(""),[k,E]=(0,a.useState)(!1),[s,K]=(0,a.useState)(null),[F,n]=(0,a.useState)(null),[b,d]=(0,a.useState)(!1),g=(0,a.useCallback)(async()=>{d(!0),n(null);try{let t=await m.query(R,{},c(i));x(t.current)}catch(t){n(h(t))}finally{d(!1)}},[m,i]);(0,a.useEffect)(()=>{p(g())},[g]),U(()=>{p((async()=>{try{let t=await m.query(R,{},c(i));x(t.current)}catch{}})())},!0);let M=o(t=>{A(t.target.value)},"U"),Z=o(t=>{D(t.target.value)},"j"),_=o(t=>{E(t.target.checked)},"M"),G=o(()=>{l.trim()!==""&&p((async()=>{d(!0),n(null);try{let t=await m.query(R,{time:l.trim()},c(i));I(t.forTime??null),x(t.current)}catch(t){I(null),n(h(t))}finally{d(!1)}})())},"z"),S=o(t=>{p((async()=>{d(!0),n(null);try{let y=await m.mutation(V,t,c(i));K(y),await g()}catch(y){n(h(y))}finally{d(!1)}})())},"R"),H=u.trim()!==""||l.trim()!=="",J=o(()=>{let t=k?{restart:!0}:{};u.trim()===""?t.time=l.trim():t.bookmark=u.trim(),S(t)},"$"),Q=o(()=>{s!==null&&S(k?{bookmark:s.undoBookmark,restart:!0}:{bookmark:s.undoBookmark})},"D");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-pitr",children:[(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[r("Shard"),": ",(0,e.jsx)("span",{className:"font-mono",children:i===""?r("root"):i})]})}),(0,e.jsx)("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.")}),F!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"pitr-error",role:"alert",children:F}),(0,e.jsxs)("section",{className:"rounded-xl border border-border bg-card p-3 shadow-xs",children:[(0,e.jsx)("h3",{className:"mb-2 text-sm font-semibold",children:r("Current bookmark")}),(0,e.jsx)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-current",children:z??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]}),(0,e.jsxs)("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-3 shadow-xs",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold",children:r("Restore")}),(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)(f,{htmlFor:"pitr-time",children:r("Time (ISO or epoch-ms, last 30 days)")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(N,{"data-testid":"pitr-time",id:"pitr-time",onChange:M,placeholder:"2026-06-01T00:00:00.000Z",value:l}),(0,e.jsx)(O,{"data-testid":"pitr-preview",disabled:b||l.trim()==="",onClick:G,size:"sm",type:"button",variant:"outline",children:r("Preview")})]}),B!==null&&(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-preview-bookmark",children:[r("Bookmark for that time"),": ",B]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)(f,{htmlFor:"pitr-bookmark",children:r("Or an explicit bookmark (wins over time)")}),(0,e.jsx)(N,{"data-testid":"pitr-bookmark",id:"pitr-bookmark",onChange:Z,placeholder:r("bookmark string"),value:u})]}),(0,e.jsxs)(f,{className:"flex items-center gap-2 text-xs font-normal text-muted-foreground",htmlFor:"pitr-restart",children:[(0,e.jsx)("input",{checked:k,className:"size-4 accent-primary","data-testid":"pitr-restart",id:"pitr-restart",onChange:_,type:"checkbox"}),r("Restart the shard now so recovery applies immediately")]}),(0,e.jsx)("div",{children:(0,e.jsx)(C,{confirmLabel:r("Confirm restore"),disabled:b||!H,onConfirm:J,testId:"pitr-restore",children:r("Restore")})})]}),s!==null&&(0,e.jsxs)("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.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold",children:r("Restore armed")}),(0,e.jsx)(L,{variant:s.restarted?"destructive":"secondary",children:s.restarted?r("restarted now"):r("on next restart")})]}),(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground",children:[r("Restored to"),": ",s.restoredTo]}),(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-undo-bookmark",children:[r("Undo bookmark"),": ",s.undoBookmark]}),(0,e.jsx)("div",{children:(0,e.jsx)(C,{confirmLabel:r("Confirm undo"),disabled:b,onConfirm:Q,testId:"pitr-undo",children:r("Undo restore")})})]})]})},"de");export{ne as PitrPanel};
1
+ import{a as U}from"./chunk-54MMVNPT.js";import{a as C}from"./chunk-7LQWFOEU.js";import{a as f}from"./chunk-5Y3QLNWX.js";import{R as N}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as O}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as L}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as w}from"./chunk-GXZAXNZI.js";import{f as P}from"./chunk-35II7U25.js";import"./chunk-XBDKZZ67.js";import{d as q,f as v,g as c,h,m as p}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as o,e as T,f as W,h as $}from"./chunk-3XIESWL4.js";var a=T(W(),1);var e=T($(),1);var R=v(w.getPitrBookmark),V=v(w.pitrRestore),ne=o(({initialShardKey:j})=>{let m=P(),r=q(),i=j??"",[z,x]=(0,a.useState)(null),[l,A]=(0,a.useState)(""),[B,I]=(0,a.useState)(null),[u,D]=(0,a.useState)(""),[k,E]=(0,a.useState)(!1),[s,K]=(0,a.useState)(null),[F,n]=(0,a.useState)(null),[b,d]=(0,a.useState)(!1),g=(0,a.useCallback)(async()=>{d(!0),n(null);try{let t=await m.query(R,{},c(i));x(t.current)}catch(t){n(h(t))}finally{d(!1)}},[m,i]);(0,a.useEffect)(()=>{p(g())},[g]),U(()=>{p((async()=>{try{let t=await m.query(R,{},c(i));x(t.current)}catch{}})())},!0);let M=o(t=>{A(t.target.value)},"U"),Z=o(t=>{D(t.target.value)},"j"),_=o(t=>{E(t.target.checked)},"M"),G=o(()=>{l.trim()!==""&&p((async()=>{d(!0),n(null);try{let t=await m.query(R,{time:l.trim()},c(i));I(t.forTime??null),x(t.current)}catch(t){I(null),n(h(t))}finally{d(!1)}})())},"z"),S=o(t=>{p((async()=>{d(!0),n(null);try{let y=await m.mutation(V,t,c(i));K(y),await g()}catch(y){n(h(y))}finally{d(!1)}})())},"R"),H=u.trim()!==""||l.trim()!=="",J=o(()=>{let t=k?{restart:!0}:{};u.trim()===""?t.time=l.trim():t.bookmark=u.trim(),S(t)},"$"),Q=o(()=>{s!==null&&S(k?{bookmark:s.undoBookmark,restart:!0}:{bookmark:s.undoBookmark})},"D");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-pitr",children:[(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[r("Shard"),": ",(0,e.jsx)("span",{className:"font-mono",children:i===""?r("root"):i})]})}),(0,e.jsx)("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.")}),F!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"pitr-error",role:"alert",children:F}),(0,e.jsxs)("section",{className:"rounded-xl border border-border bg-card p-3 shadow-xs",children:[(0,e.jsx)("h3",{className:"mb-2 text-sm font-semibold",children:r("Current bookmark")}),(0,e.jsx)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-current",children:z??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]}),(0,e.jsxs)("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-3 shadow-xs",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold",children:r("Restore")}),(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)(f,{htmlFor:"pitr-time",children:r("Time (ISO or epoch-ms, last 30 days)")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(N,{"data-testid":"pitr-time",id:"pitr-time",onChange:M,placeholder:"2026-06-01T00:00:00.000Z",value:l}),(0,e.jsx)(O,{"data-testid":"pitr-preview",disabled:b||l.trim()==="",onClick:G,size:"sm",type:"button",variant:"outline",children:r("Preview")})]}),B!==null&&(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-preview-bookmark",children:[r("Bookmark for that time"),": ",B]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)(f,{htmlFor:"pitr-bookmark",children:r("Or an explicit bookmark (wins over time)")}),(0,e.jsx)(N,{"data-testid":"pitr-bookmark",id:"pitr-bookmark",onChange:Z,placeholder:r("bookmark string"),value:u})]}),(0,e.jsxs)(f,{className:"flex items-center gap-2 text-xs font-normal text-muted-foreground",htmlFor:"pitr-restart",children:[(0,e.jsx)("input",{checked:k,className:"size-4 accent-primary","data-testid":"pitr-restart",id:"pitr-restart",onChange:_,type:"checkbox"}),r("Restart the shard now so recovery applies immediately")]}),(0,e.jsx)("div",{children:(0,e.jsx)(C,{confirmLabel:r("Confirm restore"),disabled:b||!H,onConfirm:J,testId:"pitr-restore",children:r("Restore")})})]}),s!==null&&(0,e.jsxs)("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.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold",children:r("Restore armed")}),(0,e.jsx)(L,{variant:s.restarted?"destructive":"secondary",children:s.restarted?r("restarted now"):r("on next restart")})]}),(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground",children:[r("Restored to"),": ",s.restoredTo]}),(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-undo-bookmark",children:[r("Undo bookmark"),": ",s.undoBookmark]}),(0,e.jsx)("div",{children:(0,e.jsx)(C,{confirmLabel:r("Confirm undo"),disabled:b,onConfirm:Q,testId:"pitr-undo",children:r("Undo restore")})})]})]})},"de");export{ne as PitrPanel};