@lunora/studio 1.0.0-alpha.97 → 1.0.0-alpha.99

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 (56) hide show
  1. package/dist/standalone/{chunk-ON2FIVI2.js → chunk-2TFGS62O.js} +1 -1
  2. package/dist/standalone/{chunk-NDO6YSEG.js → chunk-3J6AAVUL.js} +1 -1
  3. package/dist/standalone/{chunk-DDO5EGID.js → chunk-4D56O2UT.js} +1 -1
  4. package/dist/standalone/{chunk-VH2IO643.js → chunk-5GMRSN6L.js} +1 -1
  5. package/dist/standalone/chunk-6FQJRXVI.js +11 -0
  6. package/dist/standalone/{chunk-STESBRLN.js → chunk-6IKXBSNY.js} +1 -1
  7. package/dist/standalone/{chunk-YZIR7PL5.js → chunk-7HWEPGII.js} +1 -1
  8. package/dist/standalone/{chunk-SZXVX6PY.js → chunk-7IIICQZ7.js} +1 -1
  9. package/dist/standalone/{chunk-OKZP3YY3.js → chunk-AIB3GCQI.js} +1 -1
  10. package/dist/standalone/{chunk-J4UYSDWF.js → chunk-AS4WSCMT.js} +1 -1
  11. package/dist/standalone/{chunk-5A7NIX77.js → chunk-BAZ2VU7R.js} +1 -1
  12. package/dist/standalone/{chunk-3IF75YS7.js → chunk-BG54FBTO.js} +1 -1
  13. package/dist/standalone/{chunk-KP6VHTO4.js → chunk-BMZPRRSX.js} +1 -1
  14. package/dist/standalone/{chunk-2KRXOCZ2.js → chunk-D34YXUQY.js} +1 -1
  15. package/dist/standalone/{chunk-I7V54EDS.js → chunk-DK4J7ZBH.js} +1 -1
  16. package/dist/standalone/{chunk-NJRW66LJ.js → chunk-DSU54IAT.js} +1 -1
  17. package/dist/standalone/{chunk-5L63KFHD.js → chunk-FKBHX7BD.js} +1 -1
  18. package/dist/standalone/{chunk-6F7KP54M.js → chunk-HRRFUAP6.js} +1 -1
  19. package/dist/standalone/{chunk-IZFPJXB3.js → chunk-II5ZTRTW.js} +1 -1
  20. package/dist/standalone/{chunk-S7ZOM3NK.js → chunk-IMME7XEE.js} +1 -1
  21. package/dist/standalone/{chunk-QEVFPILV.js → chunk-IXAMI2KV.js} +1 -1
  22. package/dist/standalone/{chunk-FHZ5WDTU.js → chunk-J3Q3ESBP.js} +1 -1
  23. package/dist/standalone/{chunk-SPE3AB54.js → chunk-J6PMARYI.js} +1 -1
  24. package/dist/standalone/{chunk-FXBBFE7Y.js → chunk-JR4LDDRW.js} +1 -1
  25. package/dist/standalone/{chunk-QC4T2L6I.js → chunk-JZUM7FBJ.js} +1 -1
  26. package/dist/standalone/{chunk-NCKRVNF2.js → chunk-KBBOZRRX.js} +1 -1
  27. package/dist/standalone/{chunk-XPOUF2XH.js → chunk-KVYAMWYX.js} +1 -1
  28. package/dist/standalone/{chunk-H5ZYPSLB.js → chunk-MCPDCNPO.js} +1 -1
  29. package/dist/standalone/{chunk-NBANYYGB.js → chunk-N6N6MMWG.js} +1 -1
  30. package/dist/standalone/{chunk-PMGTIUU2.js → chunk-NTAN75BV.js} +1 -1
  31. package/dist/standalone/{chunk-4EHNOASW.js → chunk-O36FXWMR.js} +1 -1
  32. package/dist/standalone/{chunk-QQYX5WN4.js → chunk-O3BG6T4B.js} +1 -1
  33. package/dist/standalone/{chunk-73B3T2SA.js → chunk-QVK5DESS.js} +1 -1
  34. package/dist/standalone/{chunk-D264UAKY.js → chunk-RE7VLJ6H.js} +1 -1
  35. package/dist/standalone/{chunk-EZKBI7SZ.js → chunk-T2NCAYLT.js} +1 -1
  36. package/dist/standalone/{chunk-UYPXC3OO.js → chunk-T7AVSVIA.js} +1 -1
  37. package/dist/standalone/{chunk-M3Z2YAHD.js → chunk-T7YW6OMG.js} +1 -1
  38. package/dist/standalone/{chunk-G2O3XP7Y.js → chunk-TLVSMHK2.js} +1 -1
  39. package/dist/standalone/{chunk-E3Z4QXAD.js → chunk-TMZQNRFA.js} +1 -1
  40. package/dist/standalone/{chunk-CXBXUT5A.js → chunk-U3Y2BI4W.js} +1 -1
  41. package/dist/standalone/{chunk-3626PHEZ.js → chunk-UE2NC2ZZ.js} +1 -1
  42. package/dist/standalone/{chunk-3SGYSFRC.js → chunk-URCRLZN7.js} +1 -1
  43. package/dist/standalone/{chunk-OZA2RA45.js → chunk-UYOSHHOV.js} +1 -1
  44. package/dist/standalone/{chunk-WLXH4ECM.js → chunk-V3EN6YQV.js} +1 -1
  45. package/dist/standalone/{chunk-LHAHIDNT.js → chunk-V4R4HI3U.js} +1 -1
  46. package/dist/standalone/{chunk-LAEO6D34.js → chunk-VKK7A4VH.js} +1 -1
  47. package/dist/standalone/{chunk-PKWJ7UOG.js → chunk-VOYG35OH.js} +1 -1
  48. package/dist/standalone/{chunk-II64XEZV.js → chunk-W2GXYXCQ.js} +1 -1
  49. package/dist/standalone/{chunk-MW5YIENZ.js → chunk-WG3WC2F2.js} +1 -1
  50. package/dist/standalone/{chunk-5L2VKBAJ.js → chunk-WZXZ6YN5.js} +1 -1
  51. package/dist/standalone/{chunk-YP7WZ6YM.js → chunk-XGL7QCYN.js} +1 -1
  52. package/dist/standalone/{chunk-HH5CZ6KD.js → chunk-XUQEE25M.js} +1 -1
  53. package/dist/standalone/{chunk-A6NAMYVS.js → chunk-XYENOWOR.js} +1 -1
  54. package/dist/standalone/studio.js +1 -1
  55. package/package.json +5 -5
  56. package/dist/standalone/chunk-C2ZFQARQ.js +0 -11
@@ -1,2 +1,2 @@
1
- import{a as fe}from"./chunk-LEDWUPXM.js";import"./chunk-2PJNAWB3.js";import{a as ie}from"./chunk-IC4L6G56.js";import{a as pe}from"./chunk-54MMVNPT.js";import"./chunk-BGBLQ563.js";import{R as de}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as x}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as ne}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as he}from"./chunk-NCKRVNF2.js";import"./chunk-XXQUMVWH.js";import"./chunk-NJRW66LJ.js";import"./chunk-QLQADHFE.js";import{a as P}from"./chunk-VDW32UET.js";import{c as ue}from"./chunk-6F7KP54M.js";import{f as le}from"./chunk-C2ZFQARQ.js";import"./chunk-XBDKZZ67.js";import{a as ce}from"./chunk-XQCVZAGU.js";import{d as oe,f as Z,g as ee,h as te,o as ae,q as me,r as re}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as i,e as Y,f as ge,g as ve,h as Ne,j as se}from"./chunk-3XIESWL4.js";var t=Y(Ne(),1);var xe=Y(ve(),1);var N=Y(ge(),1);function ye({className:a,orientation:e="horizontal",...s}){return(0,t.jsx)(ie,{"data-slot":"separator",orientation:e,className:se("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",a),...s})}i(ye,"xe");var we=/https?:\/\/[^\s"'<>)]+/i,be=i(a=>a===void 0?void 0:we.exec(a)?.[0],"ae"),y=i(a=>a===void 0?"":Array.isArray(a)?a.join(", "):a,"N"),Ce=i(a=>{if(a!==void 0)return be(a.html)??be(a.text)},"Ne"),ke=i((a,e)=>{let s=e.trim().toLowerCase();return s===""?a:a.filter(o=>`${o.subject} ${y(o.to)} ${y(o.cc)}`.toLowerCase().includes(s))},"ye"),Se=i((a,e)=>{if(a.length!==0)return a.find(s=>s.id===e)??a[0]},"we"),Te=Z(P.clearCapturedMail),Le=Z(P.sendTestMail),je=i(a=>{let e=(0,xe.c)(38),{limit:s}=a,o=le(),p;e[0]!==s?(p={limit:s},e[0]=s,e[1]=p):p=e[1];let{data:D,error:w,errorSource:C,isLoading:g,refetch:n}=ue(P.getCapturedMail,p),[k,f]=(0,N.useState)(null),[E,S]=(0,N.useState)(null),[v,l]=(0,N.useState)("html"),[c,U]=(0,N.useState)(""),b=D?.entries??[],r=w??k,u=w===null?k:C,T;e[2]!==o||e[3]!==n?(T=i(async()=>{f(null);try{await o.query(Te,{},ee("")),S(null),n()}catch(m){f(te(m))}},"S"),e[2]=o,e[3]=n,e[4]=T):T=e[4];let W=T,L;e[5]!==o||e[6]!==n?(L=i(async()=>{f(null);try{await o.query(Le,{},ee("")),n()}catch(m){f(te(m))}},"$"),e[5]=o,e[6]=n,e[7]=L):L=e[7];let B=L,j;e[8]!==n?(j=i(()=>{n()},"T"),e[8]=n,e[9]=j):j=e[9],pe(j,!0);let M;e[10]!==W?(M=i(()=>{ae(W())},"L"),e[10]=W,e[11]=M):M=e[11];let R=M,_;e[12]!==B?(_=i(()=>{ae(B())},"j"),e[12]=B,e[13]=_):_=e[13];let G=_,$;e[14]===Symbol.for("react.memo_cache_sentinel")?($=i(m=>{U(m.currentTarget.value)},"M"),e[14]=$):$=e[14];let J=$,z;e[15]===Symbol.for("react.memo_cache_sentinel")?(z=i(m=>{let{id:h}=m.currentTarget.dataset;h!==void 0&&S(h)},"_"),e[15]=z):z=e[15];let K=z,A;e[16]===Symbol.for("react.memo_cache_sentinel")?(A=i(m=>{let h=m.currentTarget.dataset.tab;(h==="headers"||h==="html"||h==="text")&&l(h)},"z"),e[16]=A):A=e[16];let Q=A,F=ke(b,c),O=Se(F,E),d=Ce(O),q;e[17]!==d?(q=i(()=>{d!==void 0&&me(d)},"O"),e[17]=d,e[18]=q):q=e[18];let V=q,H;e[19]!==d?(H=i(()=>{d!==void 0&&"window"in globalThis&&globalThis.window.open(d,"_blank","noopener")},"I"),e[19]=d,e[20]=H):H=e[20];let X=H,I;return e[21]!==b||e[22]!==r||e[23]!==u||e[24]!==c||e[25]!==g||e[26]!==d||e[27]!==R||e[28]!==V||e[29]!==J||e[30]!==X||e[31]!==K||e[32]!==Q||e[33]!==G||e[34]!==O||e[35]!==v||e[36]!==F?(I={entries:b,error:r,errorSource:u,filter:c,isLoading:g,link:d,onClear:R,onCopyLink:V,onFilterChange:J,onOpenLink:X,onSelectMessage:K,onSelectTab:Q,onSendTest:G,selected:O,tab:v,visible:F},e[21]=b,e[22]=r,e[23]=u,e[24]=c,e[25]=g,e[26]=d,e[27]=R,e[28]=V,e[29]=J,e[30]=X,e[31]=K,e[32]=Q,e[33]=G,e[34]=O,e[35]=v,e[36]=F,e[37]=I):I=e[37],I},"Se"),Me=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">`,_e=i(a=>`${Me}${a}`,"Te"),Je=i(({limit:a=100})=>{let e=oe(),{entries:s,error:o,errorSource:p,filter:D,isLoading:w,link:C,onClear:g,onCopyLink:n,onFilterChange:k,onOpenLink:f,onSelectMessage:E,onSelectTab:S,onSendTest:v,selected:l,tab:c,visible:U}=je({limit:a}),b=i(r=>e(r==="html"?"HTML":r==="text"?"Plain text":"Headers"),"b");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"mail-panel",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(x,{"data-testid":"mail-send-test",onClick:v,size:"sm",type:"button",variant:"outline",children:e("Send test")}),(0,t.jsx)(x,{"data-testid":"mail-clear",disabled:s.length===0,onClick:g,size:"sm",type:"button",variant:"outline",children:e("Clear inbox")}),s.length>0&&(0,t.jsx)(ne,{className:"ml-auto","data-testid":"mail-count",variant:"secondary",children:e("{count} messages",{count:s.length})})]}),o!==null&&(0,t.jsx)(he,{error:p,testId:"mail-error"}),o===null&&!w&&s.length===0&&(0,t.jsx)(ce,{description:e("Email your app sends in dev is captured here \u2014 nothing is delivered."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("path",{d:"M4 5h16v14H4z"}),(0,t.jsx)("path",{d:"m4 6 8 6 8-6"})]}),testId:"mail-empty",title:e("No captured email.")}),s.length>0&&(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-[minmax(0,22rem)_1fr]","data-testid":"mail-reader",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)(de,{"aria-label":e("Search messages"),"data-testid":"mail-search",onChange:k,placeholder:e("Filter messages"),type:"search",value:D}),(0,t.jsx)(fe,{className:"max-h-[32rem] rounded-xl border border-border bg-card shadow-xs","data-testid":"mail-list",children:(0,t.jsx)("ul",{className:"divide-y",children:U.map(r=>{let u=r.id===l?.id;return(0,t.jsx)("li",{children:(0,t.jsxs)("button",{className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-sm hover:bg-muted/60 ${u?"bg-muted":""}`,"data-active":u,"data-id":r.id,"data-testid":"mail-list-item",onClick:E,type:"button",children:[(0,t.jsx)("span",{className:"w-full truncate font-medium",children:r.subject||e("(no subject)")}),(0,t.jsx)("span",{className:"w-full truncate text-xs text-muted-foreground",children:y(r.to)}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground tabular-nums",children:re(r.capturedAt,"\u2014")})]})},r.id)})})})]}),l!==void 0&&(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"mail-detail",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"truncate text-base font-semibold","data-testid":"mail-subject",children:l.subject||e("(no subject)")}),(0,t.jsxs)("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs text-muted-foreground",children:[(0,t.jsx)("dt",{children:e("From")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:l.from??"\u2014"}),(0,t.jsx)("dt",{children:e("To")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:y(l.to)}),l.cc!==void 0&&l.cc.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("dt",{children:e("Cc")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:y(l.cc)})]}),(0,t.jsx)("dt",{children:e("Sent")}),(0,t.jsx)("dd",{className:"tabular-nums",children:re(l.capturedAt,"\u2014")})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2","data-testid":"mail-actions",children:[(0,t.jsx)(x,{"data-testid":"mail-copy-link",disabled:C===void 0,onClick:n,size:"sm",type:"button",variant:"outline",children:e("Copy link")}),(0,t.jsx)(x,{"data-testid":"mail-open-link",disabled:C===void 0,onClick:f,size:"sm",type:"button",variant:"outline",children:e("Open in new tab")})]}),(0,t.jsx)(ye,{}),(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"mail-tabs",role:"tablist",children:["html","text","headers"].map(r=>(0,t.jsx)(x,{"aria-selected":c===r,"data-tab":r,"data-testid":`mail-tab-${r}`,onClick:S,role:"tab",size:"sm",type:"button",variant:c===r?"secondary":"ghost",children:b(r)},r))}),(0,t.jsxs)("div",{className:"min-h-[12rem]",children:[c==="html"&&(l.html===void 0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No HTML body.")}):(0,t.jsx)("iframe",{className:"h-[24rem] w-full rounded-md border bg-white","data-testid":"mail-preview-html",sandbox:"",srcDoc:_e(l.html),title:e("Email preview")})),c==="text"&&(l.text===void 0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No text body.")}):(0,t.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-text",children:l.text})),c==="headers"&&(l.headers===void 0||Object.keys(l.headers).length===0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No headers.")}):(0,t.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-headers",children:Object.entries(l.headers).map(([r,u])=>`${r}: ${u}`).join(`
1
+ import{a as fe}from"./chunk-LEDWUPXM.js";import"./chunk-2PJNAWB3.js";import{a as ie}from"./chunk-IC4L6G56.js";import{a as pe}from"./chunk-54MMVNPT.js";import"./chunk-BGBLQ563.js";import{R as de}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as x}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as ne}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as he}from"./chunk-KBBOZRRX.js";import"./chunk-XXQUMVWH.js";import"./chunk-DSU54IAT.js";import"./chunk-QLQADHFE.js";import{a as P}from"./chunk-VDW32UET.js";import{c as ue}from"./chunk-HRRFUAP6.js";import{f as le}from"./chunk-6FQJRXVI.js";import"./chunk-XBDKZZ67.js";import{a as ce}from"./chunk-XQCVZAGU.js";import{d as oe,f as Z,g as ee,h as te,o as ae,q as me,r as re}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as i,e as Y,f as ge,g as ve,h as Ne,j as se}from"./chunk-3XIESWL4.js";var t=Y(Ne(),1);var xe=Y(ve(),1);var N=Y(ge(),1);function ye({className:a,orientation:e="horizontal",...s}){return(0,t.jsx)(ie,{"data-slot":"separator",orientation:e,className:se("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",a),...s})}i(ye,"xe");var we=/https?:\/\/[^\s"'<>)]+/i,be=i(a=>a===void 0?void 0:we.exec(a)?.[0],"ae"),y=i(a=>a===void 0?"":Array.isArray(a)?a.join(", "):a,"N"),Ce=i(a=>{if(a!==void 0)return be(a.html)??be(a.text)},"Ne"),ke=i((a,e)=>{let s=e.trim().toLowerCase();return s===""?a:a.filter(o=>`${o.subject} ${y(o.to)} ${y(o.cc)}`.toLowerCase().includes(s))},"ye"),Se=i((a,e)=>{if(a.length!==0)return a.find(s=>s.id===e)??a[0]},"we"),Te=Z(P.clearCapturedMail),Le=Z(P.sendTestMail),je=i(a=>{let e=(0,xe.c)(38),{limit:s}=a,o=le(),p;e[0]!==s?(p={limit:s},e[0]=s,e[1]=p):p=e[1];let{data:D,error:w,errorSource:C,isLoading:g,refetch:n}=ue(P.getCapturedMail,p),[k,f]=(0,N.useState)(null),[E,S]=(0,N.useState)(null),[v,l]=(0,N.useState)("html"),[c,U]=(0,N.useState)(""),b=D?.entries??[],r=w??k,u=w===null?k:C,T;e[2]!==o||e[3]!==n?(T=i(async()=>{f(null);try{await o.query(Te,{},ee("")),S(null),n()}catch(m){f(te(m))}},"S"),e[2]=o,e[3]=n,e[4]=T):T=e[4];let W=T,L;e[5]!==o||e[6]!==n?(L=i(async()=>{f(null);try{await o.query(Le,{},ee("")),n()}catch(m){f(te(m))}},"$"),e[5]=o,e[6]=n,e[7]=L):L=e[7];let B=L,j;e[8]!==n?(j=i(()=>{n()},"T"),e[8]=n,e[9]=j):j=e[9],pe(j,!0);let M;e[10]!==W?(M=i(()=>{ae(W())},"L"),e[10]=W,e[11]=M):M=e[11];let R=M,_;e[12]!==B?(_=i(()=>{ae(B())},"j"),e[12]=B,e[13]=_):_=e[13];let G=_,$;e[14]===Symbol.for("react.memo_cache_sentinel")?($=i(m=>{U(m.currentTarget.value)},"M"),e[14]=$):$=e[14];let J=$,z;e[15]===Symbol.for("react.memo_cache_sentinel")?(z=i(m=>{let{id:h}=m.currentTarget.dataset;h!==void 0&&S(h)},"_"),e[15]=z):z=e[15];let K=z,A;e[16]===Symbol.for("react.memo_cache_sentinel")?(A=i(m=>{let h=m.currentTarget.dataset.tab;(h==="headers"||h==="html"||h==="text")&&l(h)},"z"),e[16]=A):A=e[16];let Q=A,F=ke(b,c),O=Se(F,E),d=Ce(O),q;e[17]!==d?(q=i(()=>{d!==void 0&&me(d)},"O"),e[17]=d,e[18]=q):q=e[18];let V=q,H;e[19]!==d?(H=i(()=>{d!==void 0&&"window"in globalThis&&globalThis.window.open(d,"_blank","noopener")},"I"),e[19]=d,e[20]=H):H=e[20];let X=H,I;return e[21]!==b||e[22]!==r||e[23]!==u||e[24]!==c||e[25]!==g||e[26]!==d||e[27]!==R||e[28]!==V||e[29]!==J||e[30]!==X||e[31]!==K||e[32]!==Q||e[33]!==G||e[34]!==O||e[35]!==v||e[36]!==F?(I={entries:b,error:r,errorSource:u,filter:c,isLoading:g,link:d,onClear:R,onCopyLink:V,onFilterChange:J,onOpenLink:X,onSelectMessage:K,onSelectTab:Q,onSendTest:G,selected:O,tab:v,visible:F},e[21]=b,e[22]=r,e[23]=u,e[24]=c,e[25]=g,e[26]=d,e[27]=R,e[28]=V,e[29]=J,e[30]=X,e[31]=K,e[32]=Q,e[33]=G,e[34]=O,e[35]=v,e[36]=F,e[37]=I):I=e[37],I},"Se"),Me=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">`,_e=i(a=>`${Me}${a}`,"Te"),Je=i(({limit:a=100})=>{let e=oe(),{entries:s,error:o,errorSource:p,filter:D,isLoading:w,link:C,onClear:g,onCopyLink:n,onFilterChange:k,onOpenLink:f,onSelectMessage:E,onSelectTab:S,onSendTest:v,selected:l,tab:c,visible:U}=je({limit:a}),b=i(r=>e(r==="html"?"HTML":r==="text"?"Plain text":"Headers"),"b");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"mail-panel",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(x,{"data-testid":"mail-send-test",onClick:v,size:"sm",type:"button",variant:"outline",children:e("Send test")}),(0,t.jsx)(x,{"data-testid":"mail-clear",disabled:s.length===0,onClick:g,size:"sm",type:"button",variant:"outline",children:e("Clear inbox")}),s.length>0&&(0,t.jsx)(ne,{className:"ml-auto","data-testid":"mail-count",variant:"secondary",children:e("{count} messages",{count:s.length})})]}),o!==null&&(0,t.jsx)(he,{error:p,testId:"mail-error"}),o===null&&!w&&s.length===0&&(0,t.jsx)(ce,{description:e("Email your app sends in dev is captured here \u2014 nothing is delivered."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("path",{d:"M4 5h16v14H4z"}),(0,t.jsx)("path",{d:"m4 6 8 6 8-6"})]}),testId:"mail-empty",title:e("No captured email.")}),s.length>0&&(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-[minmax(0,22rem)_1fr]","data-testid":"mail-reader",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)(de,{"aria-label":e("Search messages"),"data-testid":"mail-search",onChange:k,placeholder:e("Filter messages"),type:"search",value:D}),(0,t.jsx)(fe,{className:"max-h-[32rem] rounded-xl border border-border bg-card shadow-xs","data-testid":"mail-list",children:(0,t.jsx)("ul",{className:"divide-y",children:U.map(r=>{let u=r.id===l?.id;return(0,t.jsx)("li",{children:(0,t.jsxs)("button",{className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-sm hover:bg-muted/60 ${u?"bg-muted":""}`,"data-active":u,"data-id":r.id,"data-testid":"mail-list-item",onClick:E,type:"button",children:[(0,t.jsx)("span",{className:"w-full truncate font-medium",children:r.subject||e("(no subject)")}),(0,t.jsx)("span",{className:"w-full truncate text-xs text-muted-foreground",children:y(r.to)}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground tabular-nums",children:re(r.capturedAt,"\u2014")})]})},r.id)})})})]}),l!==void 0&&(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"mail-detail",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"truncate text-base font-semibold","data-testid":"mail-subject",children:l.subject||e("(no subject)")}),(0,t.jsxs)("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs text-muted-foreground",children:[(0,t.jsx)("dt",{children:e("From")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:l.from??"\u2014"}),(0,t.jsx)("dt",{children:e("To")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:y(l.to)}),l.cc!==void 0&&l.cc.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("dt",{children:e("Cc")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:y(l.cc)})]}),(0,t.jsx)("dt",{children:e("Sent")}),(0,t.jsx)("dd",{className:"tabular-nums",children:re(l.capturedAt,"\u2014")})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2","data-testid":"mail-actions",children:[(0,t.jsx)(x,{"data-testid":"mail-copy-link",disabled:C===void 0,onClick:n,size:"sm",type:"button",variant:"outline",children:e("Copy link")}),(0,t.jsx)(x,{"data-testid":"mail-open-link",disabled:C===void 0,onClick:f,size:"sm",type:"button",variant:"outline",children:e("Open in new tab")})]}),(0,t.jsx)(ye,{}),(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"mail-tabs",role:"tablist",children:["html","text","headers"].map(r=>(0,t.jsx)(x,{"aria-selected":c===r,"data-tab":r,"data-testid":`mail-tab-${r}`,onClick:S,role:"tab",size:"sm",type:"button",variant:c===r?"secondary":"ghost",children:b(r)},r))}),(0,t.jsxs)("div",{className:"min-h-[12rem]",children:[c==="html"&&(l.html===void 0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No HTML body.")}):(0,t.jsx)("iframe",{className:"h-[24rem] w-full rounded-md border bg-white","data-testid":"mail-preview-html",sandbox:"",srcDoc:_e(l.html),title:e("Email preview")})),c==="text"&&(l.text===void 0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No text body.")}):(0,t.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-text",children:l.text})),c==="headers"&&(l.headers===void 0||Object.keys(l.headers).length===0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No headers.")}):(0,t.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-headers",children:Object.entries(l.headers).map(([r,u])=>`${r}: ${u}`).join(`
2
2
  `)}))]})]})]})]})},"We");export{Je as MailPanel};
@@ -1 +1 @@
1
- import{a as Y}from"./chunk-AREBQI6D.js";import{a as V}from"./chunk-3CWGJYBB.js";import{a as G}from"./chunk-RMN2JN4S.js";import{b as Q}from"./chunk-GRL5MG3Z.js";import{a as z}from"./chunk-SFDOII3B.js";import{e as P}from"./chunk-SMIESS7P.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{b as Z,c as ee}from"./chunk-PLFTCTMX.js";import{a as _,b as W}from"./chunk-2KRXOCZ2.js";import{c as U}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import"./chunk-NCKRVNF2.js";import"./chunk-XXQUMVWH.js";import"./chunk-NJRW66LJ.js";import"./chunk-QLQADHFE.js";import{a as I}from"./chunk-VDW32UET.js";import{c as M}from"./chunk-6F7KP54M.js";import{f as B}from"./chunk-C2ZFQARQ.js";import"./chunk-XBDKZZ67.js";import"./chunk-WJQLNYGX.js";import"./chunk-WQH3LT2P.js";import{d as A,f as H,g as K,o as k}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as l,e as L,f as fe,g as he,h as me}from"./chunk-3XIESWL4.js";var j=L(he(),1);var u=L(fe(),1);var $=L(me(),1);var pe=l(t=>{let{suggestedIndex:e,table:r}=t;return!(typeof r!="string"||r.length===0||typeof e!="object"||e===null||!Array.isArray(e.fields)||e.fields.length===0)},"pe"),be=l((t,e,r)=>{let a=`"${t}"`,n=`"${e}"`,o=r.map(c=>`"${c}"`).join(", ");return`CREATE INDEX IF NOT EXISTS ${n} ON ${a} (${o});`},"ge"),ge=l(t=>{let e=(0,j.c)(19),{fields:r,indexName:a,table:n,testId:o}=t,c=A(),[T,p]=(0,u.useState)(!1),f;e[0]!==r||e[1]!==a||e[2]!==n?(f=l(()=>{let S="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if(S===void 0)return;let y=be(n,a,r);k(S.writeText(y)),p(!0)},"d"),e[0]=r,e[1]=a,e[2]=n,e[3]=f):f=e[3];let v=f;if(T){let S=`${o}-applied`,y;e[4]!==c?(y=c("CREATE INDEX SQL copied to clipboard."),e[4]=c,e[5]=y):y=e[5];let E;return e[6]!==S||e[7]!==y?(E=(0,$.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":S,children:y}),e[6]=S,e[7]=y,e[8]=E):E=e[8],E}let w;e[9]!==c?(w=c("Apply?"),e[9]=c,e[10]=w):w=e[10];let h;e[11]!==c||e[12]!==n?(h=c("Apply index on {table}",{table:n}),e[11]=c,e[12]=n,e[13]=h):h=e[13];let x;return e[14]!==v||e[15]!==w||e[16]!==h||e[17]!==o?(x=(0,$.jsx)(Y,{confirmLabel:w,onConfirm:v,testId:o,children:h}),e[14]=v,e[15]=w,e[16]=h,e[17]=o,e[18]=x):x=e[18],x},"be"),ve=l((t,e)=>{let r=new Map;for(let a of e){let n=`${a.table} ${a.index}`;r.set(n,(r.get(n)??0)+a.reads)}return t.map(a=>({index:a.index,reads:r.get(`${a.table} ${a.index}`)??0,table:a.table}))},"xe"),xe=l(t=>{let e=new Map;for(let r of t)for(let a of r.scannedTables??[])e.set(a.table,(e.get(a.table)??0)+a.scans);return[...e].map(([r,a])=>({scans:a,table:r}))},"ye"),te=l((t,e)=>e.map(r=>({index:r.name,table:t})),"X"),ye=l(t=>{let e=ve(t.declaredIndexes??[],t.indexHits??[]),r=xe(t.functions??[]),a=t.shardTraffic??[],n=t.analyticsMetrics,o=n&&n.indexHits.length>0?n.indexHits:e,c=n&&n.tableScans.length>0?n.tableScans:r,T=n&&n.shardTraffic.length>0?n.shardTraffic:a,p=ee({indexHits:o,schema:{tables:[]},shardTraffic:T,tableScans:c},{lints:Z,source:"runtime"}),f=t.suppressHotScanTables;return(f===void 0?p:p.filter(v=>!(v.metadata.kind==="hot_scan"&&typeof v.metadata.table=="string"&&f.has(v.metadata.table)))).map(v=>_(v))},"ve"),we=H(I.listTables),Se=H(I.listTableIndexes),Te=H(I.listTablesIndexes),q=l(t=>`${(t*100).toFixed(1)}%`,"K"),ae=l(t=>`${(t/1e3).toFixed(2)}s`,"B"),$e=l(t=>{if(t.length<=1)return t[0]??"";let e=t[t.length-1]??"";return`${t.slice(0,-1).join(", ")} and ${e}`},"Te"),Ie=l((t,e)=>({"high-error-rate":t("High error rate"),"high-evictions":t("High cache eviction rate"),"high-write-contention":t("High write contention"),"low-cache-hit-rate":t("Low cache hit rate"),"missing-index":t("Missing index"),"slow-function":t("Slow function")})[e.kind],"Ie"),ne=l((t,e)=>({"high-error-rate":t("{rate} of calls failed.",{rate:q(e.value)}),"high-evictions":t("{count} entries evicted recently.",{count:e.value}),"high-write-contention":t("{rate} of calls hit a write conflict \u2014 consider sharding to cut contention.",{rate:q(e.value)}),"low-cache-hit-rate":t("{rate} hit rate over recent traffic.",{rate:q(e.value)}),"missing-index":t("Slowest call took {duration} \u2014 it full-scanned {tables} with no index.",{duration:ae(e.value),tables:$e(e.tables??[])}),"slow-function":t("Slowest call took {duration}.",{duration:ae(e.value)})})[e.kind],"J"),Ee=l(t=>{let e=(0,j.c)(10),{onJump:r,table:a}=t,n=A(),o;e[0]!==r||e[1]!==a?(o=l(()=>{r(a)},"o"),e[0]=r,e[1]=a,e[2]=o):o=e[2];let c=o,T=`in-add-index-${a}`,p;e[3]!==n||e[4]!==a?(p=n("Add index on {table}",{table:a}),e[3]=n,e[4]=a,e[5]=p):p=e[5];let f;return e[6]!==c||e[7]!==T||e[8]!==p?(f=(0,$.jsx)(U,{"data-testid":T,onClick:c,size:"sm",type:"button",variant:"outline",children:p}),e[6]=c,e[7]=T,e[8]=p,e[9]=f):f=e[9],f},"Ee"),De=l(({initialShardKey:t,loadShardTraffic:e})=>{let r=B(),a=P(),n=A(),{queryShardKey:o,setShardKey:c,shardKey:T}=V(t),[p,f]=(0,u.useState)(null),[v,w]=(0,u.useState)(null),h=(0,u.useRef)(""),x=M(I.getMetrics,{},{live:!0,shardKey:o}),S=M(I.getFunctionStats,{},{live:!0,shardKey:o}),y=M(I.getAdvisories,{},{live:!0,shardKey:o}),E=x.data??null,F=S.data?.functions??null,O=y.data?.advisories??null,re=x.data?.indexHits??null,R=x.error!==null&&S.error!==null?x.error:null,se=e??(s=>r.shardTraffic(s)),ie=l(async(s,b)=>{let i=s[0];if(i===void 0||i===""){h.current===b&&w(null);return}try{let m=await se(i);if(h.current!==b)return;let d=new Map;for(let g of m.shards)d.has(g.shardKey)||d.set(g.shardKey,{requests:g.requests,shardKey:g.shardKey});w([...d.values()])}catch{h.current===b&&w(null)}},"V"),oe=l(async(s,b)=>{let i=await Promise.allSettled(s.map(async d=>[d,await r.query(Se,{table:d},K(b))])),m=[];for(let d of i)if(d.status==="fulfilled"){let[g,N]=d.value;m.push(...te(g,N.indexes))}return m},"G"),D=(0,u.useEffectEvent)(async s=>{h.current=s;let b=[];try{let i=await r.query(we,{},K(s));if(h.current!==s)return;Q(s),b=i.map(d=>d.name);let m=[];if(b.length>0)try{let d=await r.query(Te,{tables:b},K(s));if(h.current!==s)return;for(let[g,N]of Object.entries(d.indexesByTable))m.push(...te(g,N))}catch{if(m=await oe(b,s),h.current!==s)return}f(m)}catch{h.current===s&&f(null)}await ie(b,s)});(0,u.useEffect)(()=>{k(D(o))},[o]);let le=(0,u.useEffectEvent)(()=>{x.refetch(),S.refetch(),y.refetch(),k(D(o))});(0,u.useEffect)(()=>{let s=l(()=>{document.visibilityState==="visible"&&le()},"i");return document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s)}},[]);let J=(0,u.useCallback)(s=>{k(a({search:{table:s},to:"/schema"}))},[a]),C=z(E,F),ce=new Set(C.filter(s=>s.kind==="missing-index").flatMap(s=>s.tables??[])),X=ye({declaredIndexes:p??[],functions:F,indexHits:re,shardTraffic:v,suppressHotScanTables:ce}),de=(0,u.useMemo)(()=>{let s=C.map(i=>{let m=i.kind==="missing-index"?i.tables??[]:[];return{action:m.length>0?m.map(d=>(0,$.jsx)(Ee,{onJump:J,table:d},d)):void 0,description:i.message===void 0?ne(n,i):`${ne(n,i)} \u2014 ${i.message}`,entity:i.fn,issueType:Ie(n,i),key:`${i.kind}:${i.fn??""}`,level:i.severity}}),b=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(O??[]).map(i=>{let m=_(i);if(b.has(i.name)&&pe(i.metadata)){let{table:d,suggestedIndex:g}=i.metadata,N=`in-apply-index-${d}-${g.name}`;return{...m,action:(0,$.jsx)(ge,{fields:g.fields,indexName:g.name,table:d,testId:N})}}return m}),...X,...s]},[O,C,J,X,n]),ue=(0,$.jsx)(G,{onChange:c,testId:"in-shard-input",value:T});return(0,$.jsx)(W,{error:R,errorSource:R===null?void 0:x.errorSource,rows:de,testId:"lunora-insights",toolbar:ue})},"Je");export{De as InsightsPanel};
1
+ import{a as Y}from"./chunk-AREBQI6D.js";import{a as V}from"./chunk-3CWGJYBB.js";import{a as G}from"./chunk-RMN2JN4S.js";import{b as Q}from"./chunk-GRL5MG3Z.js";import{a as z}from"./chunk-SFDOII3B.js";import{e as P}from"./chunk-SMIESS7P.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{b as Z,c as ee}from"./chunk-PLFTCTMX.js";import{a as _,b as W}from"./chunk-D34YXUQY.js";import{c as U}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import"./chunk-KBBOZRRX.js";import"./chunk-XXQUMVWH.js";import"./chunk-DSU54IAT.js";import"./chunk-QLQADHFE.js";import{a as I}from"./chunk-VDW32UET.js";import{c as M}from"./chunk-HRRFUAP6.js";import{f as B}from"./chunk-6FQJRXVI.js";import"./chunk-XBDKZZ67.js";import"./chunk-WJQLNYGX.js";import"./chunk-WQH3LT2P.js";import{d as A,f as H,g as K,o as k}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as l,e as L,f as fe,g as he,h as me}from"./chunk-3XIESWL4.js";var j=L(he(),1);var u=L(fe(),1);var $=L(me(),1);var pe=l(t=>{let{suggestedIndex:e,table:r}=t;return!(typeof r!="string"||r.length===0||typeof e!="object"||e===null||!Array.isArray(e.fields)||e.fields.length===0)},"pe"),be=l((t,e,r)=>{let a=`"${t}"`,n=`"${e}"`,o=r.map(c=>`"${c}"`).join(", ");return`CREATE INDEX IF NOT EXISTS ${n} ON ${a} (${o});`},"ge"),ge=l(t=>{let e=(0,j.c)(19),{fields:r,indexName:a,table:n,testId:o}=t,c=A(),[T,p]=(0,u.useState)(!1),f;e[0]!==r||e[1]!==a||e[2]!==n?(f=l(()=>{let S="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if(S===void 0)return;let y=be(n,a,r);k(S.writeText(y)),p(!0)},"d"),e[0]=r,e[1]=a,e[2]=n,e[3]=f):f=e[3];let v=f;if(T){let S=`${o}-applied`,y;e[4]!==c?(y=c("CREATE INDEX SQL copied to clipboard."),e[4]=c,e[5]=y):y=e[5];let E;return e[6]!==S||e[7]!==y?(E=(0,$.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":S,children:y}),e[6]=S,e[7]=y,e[8]=E):E=e[8],E}let w;e[9]!==c?(w=c("Apply?"),e[9]=c,e[10]=w):w=e[10];let h;e[11]!==c||e[12]!==n?(h=c("Apply index on {table}",{table:n}),e[11]=c,e[12]=n,e[13]=h):h=e[13];let x;return e[14]!==v||e[15]!==w||e[16]!==h||e[17]!==o?(x=(0,$.jsx)(Y,{confirmLabel:w,onConfirm:v,testId:o,children:h}),e[14]=v,e[15]=w,e[16]=h,e[17]=o,e[18]=x):x=e[18],x},"be"),ve=l((t,e)=>{let r=new Map;for(let a of e){let n=`${a.table} ${a.index}`;r.set(n,(r.get(n)??0)+a.reads)}return t.map(a=>({index:a.index,reads:r.get(`${a.table} ${a.index}`)??0,table:a.table}))},"xe"),xe=l(t=>{let e=new Map;for(let r of t)for(let a of r.scannedTables??[])e.set(a.table,(e.get(a.table)??0)+a.scans);return[...e].map(([r,a])=>({scans:a,table:r}))},"ye"),te=l((t,e)=>e.map(r=>({index:r.name,table:t})),"X"),ye=l(t=>{let e=ve(t.declaredIndexes??[],t.indexHits??[]),r=xe(t.functions??[]),a=t.shardTraffic??[],n=t.analyticsMetrics,o=n&&n.indexHits.length>0?n.indexHits:e,c=n&&n.tableScans.length>0?n.tableScans:r,T=n&&n.shardTraffic.length>0?n.shardTraffic:a,p=ee({indexHits:o,schema:{tables:[]},shardTraffic:T,tableScans:c},{lints:Z,source:"runtime"}),f=t.suppressHotScanTables;return(f===void 0?p:p.filter(v=>!(v.metadata.kind==="hot_scan"&&typeof v.metadata.table=="string"&&f.has(v.metadata.table)))).map(v=>_(v))},"ve"),we=H(I.listTables),Se=H(I.listTableIndexes),Te=H(I.listTablesIndexes),q=l(t=>`${(t*100).toFixed(1)}%`,"K"),ae=l(t=>`${(t/1e3).toFixed(2)}s`,"B"),$e=l(t=>{if(t.length<=1)return t[0]??"";let e=t[t.length-1]??"";return`${t.slice(0,-1).join(", ")} and ${e}`},"Te"),Ie=l((t,e)=>({"high-error-rate":t("High error rate"),"high-evictions":t("High cache eviction rate"),"high-write-contention":t("High write contention"),"low-cache-hit-rate":t("Low cache hit rate"),"missing-index":t("Missing index"),"slow-function":t("Slow function")})[e.kind],"Ie"),ne=l((t,e)=>({"high-error-rate":t("{rate} of calls failed.",{rate:q(e.value)}),"high-evictions":t("{count} entries evicted recently.",{count:e.value}),"high-write-contention":t("{rate} of calls hit a write conflict \u2014 consider sharding to cut contention.",{rate:q(e.value)}),"low-cache-hit-rate":t("{rate} hit rate over recent traffic.",{rate:q(e.value)}),"missing-index":t("Slowest call took {duration} \u2014 it full-scanned {tables} with no index.",{duration:ae(e.value),tables:$e(e.tables??[])}),"slow-function":t("Slowest call took {duration}.",{duration:ae(e.value)})})[e.kind],"J"),Ee=l(t=>{let e=(0,j.c)(10),{onJump:r,table:a}=t,n=A(),o;e[0]!==r||e[1]!==a?(o=l(()=>{r(a)},"o"),e[0]=r,e[1]=a,e[2]=o):o=e[2];let c=o,T=`in-add-index-${a}`,p;e[3]!==n||e[4]!==a?(p=n("Add index on {table}",{table:a}),e[3]=n,e[4]=a,e[5]=p):p=e[5];let f;return e[6]!==c||e[7]!==T||e[8]!==p?(f=(0,$.jsx)(U,{"data-testid":T,onClick:c,size:"sm",type:"button",variant:"outline",children:p}),e[6]=c,e[7]=T,e[8]=p,e[9]=f):f=e[9],f},"Ee"),De=l(({initialShardKey:t,loadShardTraffic:e})=>{let r=B(),a=P(),n=A(),{queryShardKey:o,setShardKey:c,shardKey:T}=V(t),[p,f]=(0,u.useState)(null),[v,w]=(0,u.useState)(null),h=(0,u.useRef)(""),x=M(I.getMetrics,{},{live:!0,shardKey:o}),S=M(I.getFunctionStats,{},{live:!0,shardKey:o}),y=M(I.getAdvisories,{},{live:!0,shardKey:o}),E=x.data??null,F=S.data?.functions??null,O=y.data?.advisories??null,re=x.data?.indexHits??null,R=x.error!==null&&S.error!==null?x.error:null,se=e??(s=>r.shardTraffic(s)),ie=l(async(s,b)=>{let i=s[0];if(i===void 0||i===""){h.current===b&&w(null);return}try{let m=await se(i);if(h.current!==b)return;let d=new Map;for(let g of m.shards)d.has(g.shardKey)||d.set(g.shardKey,{requests:g.requests,shardKey:g.shardKey});w([...d.values()])}catch{h.current===b&&w(null)}},"V"),oe=l(async(s,b)=>{let i=await Promise.allSettled(s.map(async d=>[d,await r.query(Se,{table:d},K(b))])),m=[];for(let d of i)if(d.status==="fulfilled"){let[g,N]=d.value;m.push(...te(g,N.indexes))}return m},"G"),D=(0,u.useEffectEvent)(async s=>{h.current=s;let b=[];try{let i=await r.query(we,{},K(s));if(h.current!==s)return;Q(s),b=i.map(d=>d.name);let m=[];if(b.length>0)try{let d=await r.query(Te,{tables:b},K(s));if(h.current!==s)return;for(let[g,N]of Object.entries(d.indexesByTable))m.push(...te(g,N))}catch{if(m=await oe(b,s),h.current!==s)return}f(m)}catch{h.current===s&&f(null)}await ie(b,s)});(0,u.useEffect)(()=>{k(D(o))},[o]);let le=(0,u.useEffectEvent)(()=>{x.refetch(),S.refetch(),y.refetch(),k(D(o))});(0,u.useEffect)(()=>{let s=l(()=>{document.visibilityState==="visible"&&le()},"i");return document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s)}},[]);let J=(0,u.useCallback)(s=>{k(a({search:{table:s},to:"/schema"}))},[a]),C=z(E,F),ce=new Set(C.filter(s=>s.kind==="missing-index").flatMap(s=>s.tables??[])),X=ye({declaredIndexes:p??[],functions:F,indexHits:re,shardTraffic:v,suppressHotScanTables:ce}),de=(0,u.useMemo)(()=>{let s=C.map(i=>{let m=i.kind==="missing-index"?i.tables??[]:[];return{action:m.length>0?m.map(d=>(0,$.jsx)(Ee,{onJump:J,table:d},d)):void 0,description:i.message===void 0?ne(n,i):`${ne(n,i)} \u2014 ${i.message}`,entity:i.fn,issueType:Ie(n,i),key:`${i.kind}:${i.fn??""}`,level:i.severity}}),b=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(O??[]).map(i=>{let m=_(i);if(b.has(i.name)&&pe(i.metadata)){let{table:d,suggestedIndex:g}=i.metadata,N=`in-apply-index-${d}-${g.name}`;return{...m,action:(0,$.jsx)(ge,{fields:g.fields,indexName:g.name,table:d,testId:N})}}return m}),...X,...s]},[O,C,J,X,n]),ue=(0,$.jsx)(G,{onChange:c,testId:"in-shard-input",value:T});return(0,$.jsx)(W,{error:R,errorSource:R===null?void 0:x.errorSource,rows:de,testId:"lunora-insights",toolbar:ue})},"Je");export{De as InsightsPanel};
@@ -1 +1 @@
1
- import{a as te}from"./chunk-V53KNYRN.js";import{R as Z}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as I}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{a as K}from"./chunk-VDW32UET.js";import{c as ee}from"./chunk-6F7KP54M.js";import{f as M}from"./chunk-C2ZFQARQ.js";import"./chunk-XBDKZZ67.js";import{a as q}from"./chunk-XQCVZAGU.js";import{a as z,b as D,c as F,d as h,e as o,f as i}from"./chunk-WJQLNYGX.js";import{a as T,e as j}from"./chunk-WQH3LT2P.js";import{d as H,f as Q,g as V,h as W,o as $}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as n,e as Y,f as ne,h as le}from"./chunk-3XIESWL4.js";var c=Y(ne(),1);var e=Y(le(),1);var oe=["queued","running","paused","waiting","complete","errored","terminated"],ie=["pause","resume","terminate"],de="WORKFLOWS_NOT_CONFIGURED",ce=n(l=>typeof l=="object"&&l!==null&&l.code===de,"ie"),me=n(l=>{let r=l.error??l.output;if(r===void 0)return"\u2014";try{return JSON.stringify(r)}catch{return"(unserializable)"}},"de"),ue=n(({loadDetail:l,loadInstances:r,readOnly:N,runAction:R,workflowName:g})=>{let A=M(),s=H(),[p,k]=(0,c.useState)(null),[S,O]=(0,c.useState)(null),[v,_]=(0,c.useState)(""),[b,f]=(0,c.useState)(null),[J,C]=(0,c.useState)(!1),[L,P]=(0,c.useState)(null),w=l??(a=>A.getWorkflowInstance(a)),x=N?void 0:R??(r===void 0?a=>A.setWorkflowInstanceStatus(a):void 0),E=n(async()=>{f(null),C(!1);let a=v===""?void 0:v;try{if(r===void 0){let d=await A.listWorkflowInstances({name:g,status:a});if(d.configured===!1){k(null),C(!0);return}k(d.instances);return}k(await r({name:g,status:a}))}catch(d){k(null),ce(d)?C(!0):f(W(d))}},"O");(0,c.useEffect)(()=>{O(null),$(E())},[g,v]);let U=n(async a=>{f(null);try{O(await w({id:a,name:g}))}catch(d){f(W(d))}},"D"),B=n(async(a,d)=>{if(x!==void 0){P(a),f(null);try{await x({action:d,id:a,name:g}),await E()}catch(G){f(W(G))}P(null)}},"K");return(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:s("Instance history")}),(0,e.jsxs)("select",{"aria-label":s("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:n(a=>{_(a.target.value)},"onChange"),value:v,children:[(0,e.jsx)("option",{value:"",children:s("All statuses")}),oe.map(a=>(0,e.jsx)("option",{value:a,children:a},a))]})]}),b!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:b}),J&&(0,e.jsx)(q,{description:s("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:s("Workflow inspection not configured")}),!J&&p!==null&&p.length===0&&(0,e.jsx)(q,{description:s("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:s("No instances")}),p!==null&&p.length>0&&(0,e.jsx)(T,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(z,{"data-testid":"workflow-instances-table",children:[(0,e.jsx)(D,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:s("Instance id")}),(0,e.jsx)(o,{children:s("Status")}),(0,e.jsx)(o,{children:s("Created")}),(0,e.jsx)(o,{children:s("Ended")}),(0,e.jsx)(o,{"aria-label":s("Actions")})]})}),(0,e.jsx)(F,{children:p.map(a=>(0,e.jsxs)(h,{"data-testid":`workflow-instance-${a.id}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:a.id}),(0,e.jsx)(i,{className:"font-mono text-xs",children:a.status}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.createdOn??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.endedOn??"\u2014"}),(0,e.jsx)(i,{className:"text-right",children:(0,e.jsxs)("div",{className:"flex justify-end gap-1.5",children:[(0,e.jsx)(I,{"data-testid":`workflow-instance-steps-${a.id}`,onClick:n(()=>{$(U(a.id))},"onClick"),size:"sm",type:"button",variant:"outline",children:s("Steps")}),x!==void 0&&ie.map(d=>(0,e.jsx)(I,{"data-testid":`workflow-instance-${d}-${a.id}`,disabled:L===a.id,onClick:n(()=>{$(B(a.id,d))},"onClick"),size:"sm",type:"button",variant:"ghost",children:s(d)},d))]})})]},a.id))})]})})}),S!==null&&(0,e.jsx)(T,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:(0,e.jsxs)(j,{className:"flex flex-col gap-2 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[s("Steps")," \xB7 ",S.id]}),(0,e.jsx)(I,{"data-testid":"workflow-instance-detail-close",onClick:n(()=>{O(null)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Close")})]}),S.steps.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:s("This instance has no recorded steps yet.")}):(0,e.jsxs)(z,{"data-testid":"workflow-instance-steps",children:[(0,e.jsx)(D,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:s("Step")}),(0,e.jsx)(o,{children:s("Type")}),(0,e.jsx)(o,{children:s("Attempts")}),(0,e.jsx)(o,{children:s("Started")}),(0,e.jsx)(o,{children:s("Output")})]})}),(0,e.jsx)(F,{children:S.steps.map((a,d)=>(0,e.jsxs)(h,{"data-testid":`workflow-step-${String(d)}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:a.name}),(0,e.jsx)(i,{className:"text-xs text-muted-foreground",children:a.type??"\u2014"}),(0,e.jsx)(i,{className:"tabular-nums",children:a.attempts??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.start??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:me(a)})]},`${a.name}:${String(d)}`))})]})]})})]})},"ce"),fe=Q(K.createWorkflowInstance),he=Q(K.getWorkflowInstanceStatus),pe=n(l=>{if(l.error)return`${l.error.name}: ${l.error.message}`;if(l.output===void 0)return"\u2014";try{return JSON.stringify(l.output)}catch{return"(unserializable)"}},"fe"),we=n((l,r)=>l.some(N=>N.exportName===r)?r:l[0]?.exportName??"","he"),We=n(()=>{let l=M(),r=H(),{data:N,error:R}=ee(K.listWorkflows,{}),[g,A]=(0,c.useState)(""),[s,p]=(0,c.useState)(""),[k,S]=(0,c.useState)(""),[O,v]=(0,c.useState)(!1),[_,b]=(0,c.useState)(null),[f,J]=(0,c.useState)([]),[C,L]=(0,c.useState)(null),P=N!==void 0,w=Array.isArray(N?.workflows)?[...N.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],x=we(w,g),E=w.find(t=>t.exportName===x),U=n(t=>{J(u=>{let m=u.filter(y=>!(y.exportName===t.exportName&&y.id===t.id));return[t,...m]})},"D"),B=n(async()=>{let t=x;if(t==="")return;let u,m=k.trim();if(m!=="")try{u=JSON.parse(m)}catch{b(r("Params must be valid JSON"));return}v(!0),b(null);try{let y=s.trim(),X=await l.query(fe,{exportName:t,id:y===""?void 0:y,params:u},V(""));U({exportName:t,id:X.id,status:X.status}),p("")}catch(y){b(W(y))}v(!1)},"K"),a=n(()=>{$(B())},"a"),d=n(async(t,u)=>{L(u);try{let m=await l.query(he,{exportName:t,id:u},V(""));U({error:m.error,exportName:t,id:m.id,output:m.output,status:m.status})}catch(m){b(W(m))}L(null)},"l"),G=n(t=>{A(t.target.value)},"P"),ae=n(t=>{p(t.target.value)},"Y"),re=n(t=>{S(t.target.value)},"Z"),se=n(t=>{let{export:u,id:m}=t.currentTarget.dataset;u!==void 0&&m!==void 0&&$(d(u,m))},"ee");return(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[R!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:R}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:r("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),P&&w.length===0?(0,e.jsx)(q,{description:r("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:r("No workflows defined")}):(0,e.jsx)(T,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(z,{"data-testid":"workflows-table",children:[(0,e.jsx)(D,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:r("Export")}),(0,e.jsx)(o,{children:r("Name")}),(0,e.jsx)(o,{children:r("Class")}),(0,e.jsx)(o,{children:r("Binding")})]})}),(0,e.jsx)(F,{children:w.map(t=>(0,e.jsxs)(h,{"data-testid":`workflows-row-${t.exportName}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.name}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.className}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.binding})]},t.exportName))})]})})}),w.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:r("Start instance")}),_!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:_}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("select",{"aria-label":r("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:G,value:x,children:w.map(t=>(0,e.jsx)("option",{value:t.exportName,children:t.exportName},t.exportName))}),(0,e.jsx)(Z,{"aria-label":r("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:ae,placeholder:r("Instance id (optional)"),value:s}),(0,e.jsx)(I,{"data-testid":"workflows-start-button",disabled:O||x==="",onClick:a,children:r(O?"Starting\u2026":"Start instance")})]}),(0,e.jsx)(te,{"aria-label":r("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:re,placeholder:r("Params (JSON, optional)"),value:k})]}),f.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:r("Instances")}),(0,e.jsx)(T,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(z,{"data-testid":"workflows-instances-table",children:[(0,e.jsx)(D,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:r("Workflow")}),(0,e.jsx)(o,{children:r("Instance id")}),(0,e.jsx)(o,{children:r("Status")}),(0,e.jsx)(o,{children:r("Output")}),(0,e.jsx)(o,{})]})}),(0,e.jsx)(F,{children:f.map(t=>(0,e.jsxs)(h,{"data-testid":`workflows-instance-${t.id}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.id}),(0,e.jsx)(i,{className:"font-mono text-xs",children:t.status}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:pe(t)}),(0,e.jsx)(i,{children:(0,e.jsx)(I,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:C===t.id,onClick:se,size:"xs",variant:"outline",children:C===t.id?r("Refreshing\u2026"):r("Refresh")})})]},`${t.exportName}:${t.id}`))})]})})})]}),E!==void 0&&(0,e.jsx)(ue,{workflowName:E.name})]})},"Oe");export{We as default};
1
+ import{a as te}from"./chunk-V53KNYRN.js";import{R as Z}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as I}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{a as K}from"./chunk-VDW32UET.js";import{c as ee}from"./chunk-HRRFUAP6.js";import{f as M}from"./chunk-6FQJRXVI.js";import"./chunk-XBDKZZ67.js";import{a as q}from"./chunk-XQCVZAGU.js";import{a as z,b as D,c as F,d as h,e as o,f as i}from"./chunk-WJQLNYGX.js";import{a as T,e as j}from"./chunk-WQH3LT2P.js";import{d as H,f as Q,g as V,h as W,o as $}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as n,e as Y,f as ne,h as le}from"./chunk-3XIESWL4.js";var c=Y(ne(),1);var e=Y(le(),1);var oe=["queued","running","paused","waiting","complete","errored","terminated"],ie=["pause","resume","terminate"],de="WORKFLOWS_NOT_CONFIGURED",ce=n(l=>typeof l=="object"&&l!==null&&l.code===de,"ie"),me=n(l=>{let r=l.error??l.output;if(r===void 0)return"\u2014";try{return JSON.stringify(r)}catch{return"(unserializable)"}},"de"),ue=n(({loadDetail:l,loadInstances:r,readOnly:N,runAction:R,workflowName:g})=>{let A=M(),s=H(),[p,k]=(0,c.useState)(null),[S,O]=(0,c.useState)(null),[v,_]=(0,c.useState)(""),[b,f]=(0,c.useState)(null),[J,C]=(0,c.useState)(!1),[L,P]=(0,c.useState)(null),w=l??(a=>A.getWorkflowInstance(a)),x=N?void 0:R??(r===void 0?a=>A.setWorkflowInstanceStatus(a):void 0),E=n(async()=>{f(null),C(!1);let a=v===""?void 0:v;try{if(r===void 0){let d=await A.listWorkflowInstances({name:g,status:a});if(d.configured===!1){k(null),C(!0);return}k(d.instances);return}k(await r({name:g,status:a}))}catch(d){k(null),ce(d)?C(!0):f(W(d))}},"O");(0,c.useEffect)(()=>{O(null),$(E())},[g,v]);let U=n(async a=>{f(null);try{O(await w({id:a,name:g}))}catch(d){f(W(d))}},"D"),B=n(async(a,d)=>{if(x!==void 0){P(a),f(null);try{await x({action:d,id:a,name:g}),await E()}catch(G){f(W(G))}P(null)}},"K");return(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:s("Instance history")}),(0,e.jsxs)("select",{"aria-label":s("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:n(a=>{_(a.target.value)},"onChange"),value:v,children:[(0,e.jsx)("option",{value:"",children:s("All statuses")}),oe.map(a=>(0,e.jsx)("option",{value:a,children:a},a))]})]}),b!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:b}),J&&(0,e.jsx)(q,{description:s("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:s("Workflow inspection not configured")}),!J&&p!==null&&p.length===0&&(0,e.jsx)(q,{description:s("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:s("No instances")}),p!==null&&p.length>0&&(0,e.jsx)(T,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(z,{"data-testid":"workflow-instances-table",children:[(0,e.jsx)(D,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:s("Instance id")}),(0,e.jsx)(o,{children:s("Status")}),(0,e.jsx)(o,{children:s("Created")}),(0,e.jsx)(o,{children:s("Ended")}),(0,e.jsx)(o,{"aria-label":s("Actions")})]})}),(0,e.jsx)(F,{children:p.map(a=>(0,e.jsxs)(h,{"data-testid":`workflow-instance-${a.id}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:a.id}),(0,e.jsx)(i,{className:"font-mono text-xs",children:a.status}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.createdOn??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.endedOn??"\u2014"}),(0,e.jsx)(i,{className:"text-right",children:(0,e.jsxs)("div",{className:"flex justify-end gap-1.5",children:[(0,e.jsx)(I,{"data-testid":`workflow-instance-steps-${a.id}`,onClick:n(()=>{$(U(a.id))},"onClick"),size:"sm",type:"button",variant:"outline",children:s("Steps")}),x!==void 0&&ie.map(d=>(0,e.jsx)(I,{"data-testid":`workflow-instance-${d}-${a.id}`,disabled:L===a.id,onClick:n(()=>{$(B(a.id,d))},"onClick"),size:"sm",type:"button",variant:"ghost",children:s(d)},d))]})})]},a.id))})]})})}),S!==null&&(0,e.jsx)(T,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:(0,e.jsxs)(j,{className:"flex flex-col gap-2 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[s("Steps")," \xB7 ",S.id]}),(0,e.jsx)(I,{"data-testid":"workflow-instance-detail-close",onClick:n(()=>{O(null)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Close")})]}),S.steps.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:s("This instance has no recorded steps yet.")}):(0,e.jsxs)(z,{"data-testid":"workflow-instance-steps",children:[(0,e.jsx)(D,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:s("Step")}),(0,e.jsx)(o,{children:s("Type")}),(0,e.jsx)(o,{children:s("Attempts")}),(0,e.jsx)(o,{children:s("Started")}),(0,e.jsx)(o,{children:s("Output")})]})}),(0,e.jsx)(F,{children:S.steps.map((a,d)=>(0,e.jsxs)(h,{"data-testid":`workflow-step-${String(d)}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:a.name}),(0,e.jsx)(i,{className:"text-xs text-muted-foreground",children:a.type??"\u2014"}),(0,e.jsx)(i,{className:"tabular-nums",children:a.attempts??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.start??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:me(a)})]},`${a.name}:${String(d)}`))})]})]})})]})},"ce"),fe=Q(K.createWorkflowInstance),he=Q(K.getWorkflowInstanceStatus),pe=n(l=>{if(l.error)return`${l.error.name}: ${l.error.message}`;if(l.output===void 0)return"\u2014";try{return JSON.stringify(l.output)}catch{return"(unserializable)"}},"fe"),we=n((l,r)=>l.some(N=>N.exportName===r)?r:l[0]?.exportName??"","he"),We=n(()=>{let l=M(),r=H(),{data:N,error:R}=ee(K.listWorkflows,{}),[g,A]=(0,c.useState)(""),[s,p]=(0,c.useState)(""),[k,S]=(0,c.useState)(""),[O,v]=(0,c.useState)(!1),[_,b]=(0,c.useState)(null),[f,J]=(0,c.useState)([]),[C,L]=(0,c.useState)(null),P=N!==void 0,w=Array.isArray(N?.workflows)?[...N.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],x=we(w,g),E=w.find(t=>t.exportName===x),U=n(t=>{J(u=>{let m=u.filter(y=>!(y.exportName===t.exportName&&y.id===t.id));return[t,...m]})},"D"),B=n(async()=>{let t=x;if(t==="")return;let u,m=k.trim();if(m!=="")try{u=JSON.parse(m)}catch{b(r("Params must be valid JSON"));return}v(!0),b(null);try{let y=s.trim(),X=await l.query(fe,{exportName:t,id:y===""?void 0:y,params:u},V(""));U({exportName:t,id:X.id,status:X.status}),p("")}catch(y){b(W(y))}v(!1)},"K"),a=n(()=>{$(B())},"a"),d=n(async(t,u)=>{L(u);try{let m=await l.query(he,{exportName:t,id:u},V(""));U({error:m.error,exportName:t,id:m.id,output:m.output,status:m.status})}catch(m){b(W(m))}L(null)},"l"),G=n(t=>{A(t.target.value)},"P"),ae=n(t=>{p(t.target.value)},"Y"),re=n(t=>{S(t.target.value)},"Z"),se=n(t=>{let{export:u,id:m}=t.currentTarget.dataset;u!==void 0&&m!==void 0&&$(d(u,m))},"ee");return(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[R!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:R}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:r("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),P&&w.length===0?(0,e.jsx)(q,{description:r("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:r("No workflows defined")}):(0,e.jsx)(T,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(z,{"data-testid":"workflows-table",children:[(0,e.jsx)(D,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:r("Export")}),(0,e.jsx)(o,{children:r("Name")}),(0,e.jsx)(o,{children:r("Class")}),(0,e.jsx)(o,{children:r("Binding")})]})}),(0,e.jsx)(F,{children:w.map(t=>(0,e.jsxs)(h,{"data-testid":`workflows-row-${t.exportName}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.name}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.className}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.binding})]},t.exportName))})]})})}),w.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:r("Start instance")}),_!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:_}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("select",{"aria-label":r("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:G,value:x,children:w.map(t=>(0,e.jsx)("option",{value:t.exportName,children:t.exportName},t.exportName))}),(0,e.jsx)(Z,{"aria-label":r("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:ae,placeholder:r("Instance id (optional)"),value:s}),(0,e.jsx)(I,{"data-testid":"workflows-start-button",disabled:O||x==="",onClick:a,children:r(O?"Starting\u2026":"Start instance")})]}),(0,e.jsx)(te,{"aria-label":r("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:re,placeholder:r("Params (JSON, optional)"),value:k})]}),f.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:r("Instances")}),(0,e.jsx)(T,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(z,{"data-testid":"workflows-instances-table",children:[(0,e.jsx)(D,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:r("Workflow")}),(0,e.jsx)(o,{children:r("Instance id")}),(0,e.jsx)(o,{children:r("Status")}),(0,e.jsx)(o,{children:r("Output")}),(0,e.jsx)(o,{})]})}),(0,e.jsx)(F,{children:f.map(t=>(0,e.jsxs)(h,{"data-testid":`workflows-instance-${t.id}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.id}),(0,e.jsx)(i,{className:"font-mono text-xs",children:t.status}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:pe(t)}),(0,e.jsx)(i,{children:(0,e.jsx)(I,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:C===t.id,onClick:se,size:"xs",variant:"outline",children:C===t.id?r("Refreshing\u2026"):r("Refresh")})})]},`${t.exportName}:${t.id}`))})]})})})]}),E!==void 0&&(0,e.jsx)(ue,{workflowName:E.name})]})},"Oe");export{We as default};
@@ -1 +1 @@
1
- import{b as de,c as ie}from"./chunk-PKSAWP56.js";import{a as le}from"./chunk-QWGT25SE.js";import{a as oe}from"./chunk-IGCNMZSB.js";import{a as se}from"./chunk-3CWGJYBB.js";import{a as ae}from"./chunk-RMN2JN4S.js";import{b as re}from"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as Y}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as X}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as ne}from"./chunk-NCKRVNF2.js";import"./chunk-XXQUMVWH.js";import"./chunk-NJRW66LJ.js";import"./chunk-QLQADHFE.js";import{a as te}from"./chunk-VDW32UET.js";import{c as ee}from"./chunk-6F7KP54M.js";import"./chunk-C2ZFQARQ.js";import"./chunk-XBDKZZ67.js";import{a as Z}from"./chunk-XQCVZAGU.js";import{d as z,r as V}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as y,e as J,f as ue,g as he,h as fe,j as Q}from"./chunk-3XIESWL4.js";var H=J(he(),1),E=J(ue(),1);var a=J(fe(),1);var ce=y(o=>Math.min(100,Math.max(0,o)),"Q"),pe=y((o,e)=>{if(!Number.isFinite(e)||e<=0)return{leftPercent:0,widthPercent:100};let t=ce(o.offsetMs/e*100),s=o.durationMs/e*100,r=Math.max(.5,Math.min(ce(s),100-t));return{leftPercent:t,widthPercent:r}},"ue"),ge=y((o,e)=>{let t=e.trim().toLowerCase();return t===""?[...o]:o.filter(s=>s.rootName.toLowerCase().includes(t)||s.functionPath.toLowerCase().includes(t)||s.traceId.toLowerCase().includes(t))},"he"),G=y(o=>Number.isFinite(o)?o>0&&o<1?`${o.toFixed(2)}ms`:`${String(Math.round(o))}ms`:"\u2014","H"),xe=14,be=y(o=>Array.isArray(o?.traces)?o.traces:[],"pe"),we=y(o=>{let e=(0,H.c)(50),{span:t,traceDurationMs:s}=o,r=z(),n;e[0]!==t||e[1]!==s?(n=pe(t,s),e[0]=t,e[1]=s,e[2]=n):n=e[2];let{leftPercent:p,widthPercent:k}=n,g;e[3]!==t.attributes?(g=le(t.attributes),e[3]=t.attributes,e[4]=g):g=e[4];let P=g,$=t.depth*xe,C;e[5]!==$?(C={paddingLeft:$},e[5]=$,e[6]=C):C=e[6];let x=C,b=`${String(p)}%`,w=`${String(k)}%`,l;e[7]!==b||e[8]!==w?(l={left:b,width:w},e[7]=b,e[8]=w,e[9]=l):l=e[9];let d=l,I=t.depth,u;e[10]!==t.ok||e[11]!==r?(u=t.ok?null:(0,a.jsx)("span",{"aria-label":r("Errored span"),className:"mr-1 text-destructive","data-testid":"tr-span-error",role:"img",children:"\u25CF"}),e[10]=t.ok,e[11]=r,e[12]=u):u=e[12];let h;e[13]!==x||e[14]!==t.name||e[15]!==u?(h=(0,a.jsxs)("span",{className:"w-56 shrink-0 truncate",role:"gridcell",style:x,title:t.name,children:[u,t.name]}),e[13]=x,e[14]=t.name,e[15]=u,e[16]=h):h=e[16];let i;e[17]!==t.durationMs||e[18]!==t.offsetMs||e[19]!==r?(i=r("starts {offset} in, runs {duration}",{duration:G(t.durationMs),offset:G(t.offsetMs)}),e[17]=t.durationMs,e[18]=t.offsetMs,e[19]=r,e[20]=i):i=e[20];let N=t.ok?"bg-primary/70":"bg-destructive",c;e[21]!==N?(c=Q("absolute inset-y-0 rounded-sm",N),e[21]=N,e[22]=c):c=e[22];let m;e[23]!==d||e[24]!==p||e[25]!==c||e[26]!==k?(m=(0,a.jsx)("span",{className:c,"data-left":p,"data-testid":"tr-span-bar","data-width":k,style:d}),e[23]=d,e[24]=p,e[25]=c,e[26]=k,e[27]=m):m=e[27];let f;e[28]!==i||e[29]!==m?(f=(0,a.jsx)("span",{"aria-label":i,className:"relative h-3 flex-1 overflow-hidden rounded-sm bg-muted",role:"gridcell",children:m}),e[28]=i,e[29]=m,e[30]=f):f=e[30];let M;e[31]!==t.durationMs?(M=G(t.durationMs),e[31]=t.durationMs,e[32]=M):M=e[32];let v;e[33]!==M?(v=(0,a.jsx)("span",{className:"w-16 shrink-0 text-right tabular-nums text-muted-foreground",role:"gridcell",children:M}),e[33]=M,e[34]=v):v=e[34];let S;e[35]!==t.error?(S=t.error===void 0?null:(0,a.jsx)("span",{className:"text-destructive","data-testid":"tr-span-error-message",title:t.error.message,children:`${t.error.type}: ${t.error.message}`}),e[35]=t.error,e[36]=S):S=e[36];let _;e[37]!==S?(_=(0,a.jsx)("span",{className:"w-64 shrink-0 truncate text-muted-foreground",role:"gridcell",children:S}),e[37]=S,e[38]=_):_=e[38];let T;e[39]!==P?(T=P===""?null:(0,a.jsx)("span",{"data-testid":"tr-span-attributes",title:P,children:P}),e[39]=P,e[40]=T):T=e[40];let F;e[41]!==T?(F=(0,a.jsx)("span",{className:"w-64 shrink-0 truncate text-muted-foreground",role:"gridcell",children:T}),e[41]=T,e[42]=F):F=e[42];let A;return e[43]!==t.depth||e[44]!==h||e[45]!==f||e[46]!==v||e[47]!==_||e[48]!==F?(A=(0,a.jsxs)("div",{className:"flex items-center gap-2 border-b border-border px-3 py-1.5 font-mono text-xs last:border-b-0 hover:bg-muted/50","data-depth":I,"data-testid":"tr-span-row",role:"row",children:[h,f,v,_,F]}),e[43]=t.depth,e[44]=h,e[45]=f,e[46]=v,e[47]=_,e[48]=F,e[49]=A):A=e[49],A},"ge"),Ne=y(o=>{let e=(0,H.c)(50),{expanded:t,onToggle:s,trace:r}=o,n=z(),p;e[0]!==s||e[1]!==r.traceId?(p=y(()=>{s(r.traceId)},"p"),e[0]=s,e[1]=r.traceId,e[2]=p):p=e[2];let k=p,g=`tr-row-${r.traceId}`,P=`tr-waterfall-${r.traceId}`,$=`tr-toggle-${r.traceId}`,C=t?"\u25BE":"\u25B8",x;e[3]!==C?(x=(0,a.jsx)("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-xs text-muted-foreground",children:C}),e[3]=C,e[4]=x):x=e[4];let b;e[5]!==r.rootName?(b=(0,a.jsx)("span",{className:"w-56 shrink-0 truncate text-sm font-medium",title:r.rootName,children:r.rootName}),e[5]=r.rootName,e[6]=b):b=e[6];let w;e[7]!==r.functionPath?(w=(0,a.jsx)("span",{className:"w-48 shrink-0 truncate font-mono text-xs text-muted-foreground",title:r.functionPath,children:r.functionPath}),e[7]=r.functionPath,e[8]=w):w=e[8];let l;e[9]!==r.durationMs?(l=G(r.durationMs),e[9]=r.durationMs,e[10]=l):l=e[10];let d;e[11]!==l?(d=(0,a.jsx)("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:l}),e[11]=l,e[12]=d):d=e[12];let I;e[13]!==n||e[14]!==r.spans.length?(I=n("{count} spans",{count:r.spans.length}),e[13]=n,e[14]=r.spans.length,e[15]=I):I=e[15];let u;e[16]!==I?(u=(0,a.jsx)("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:I}),e[16]=I,e[17]=u):u=e[17];let h=r.ok?"secondary":"destructive",i;e[18]!==n||e[19]!==r.ok?(i=r.ok?n("ok"):n("error"),e[18]=n,e[19]=r.ok,e[20]=i):i=e[20];let N;e[21]!==h||e[22]!==i?(N=(0,a.jsx)("span",{className:"shrink-0",children:(0,a.jsx)(X,{variant:h,children:i})}),e[21]=h,e[22]=i,e[23]=N):N=e[23];let c;e[24]!==r.startTs?(c=V(r.startTs),e[24]=r.startTs,e[25]=c):c=e[25];let m;e[26]!==c?(m=(0,a.jsx)("span",{className:"flex-1 truncate text-right font-mono text-xs tabular-nums text-muted-foreground",children:c}),e[26]=c,e[27]=m):m=e[27];let f;e[28]!==t||e[29]!==k||e[30]!==d||e[31]!==u||e[32]!==N||e[33]!==m||e[34]!==P||e[35]!==$||e[36]!==x||e[37]!==b||e[38]!==w?(f=(0,a.jsxs)("button",{"aria-controls":P,"aria-expanded":t,className:"flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-muted/50","data-testid":$,onClick:k,type:"button",children:[x,b,w,d,u,N,m]}),e[28]=t,e[29]=k,e[30]=d,e[31]=u,e[32]=N,e[33]=m,e[34]=P,e[35]=$,e[36]=x,e[37]=b,e[38]=w,e[39]=f):f=e[39];let M;e[40]!==t||e[41]!==n||e[42]!==r.durationMs||e[43]!==r.spans||e[44]!==r.traceId?(M=t&&(0,a.jsx)("div",{"aria-label":n("Trace waterfall"),className:"bg-muted/20","data-testid":`tr-waterfall-${r.traceId}`,id:`tr-waterfall-${r.traceId}`,role:"grid",children:r.spans.map(S=>(0,a.jsx)(we,{span:S,traceDurationMs:r.durationMs},S.spanId))}),e[40]=t,e[41]=n,e[42]=r.durationMs,e[43]=r.spans,e[44]=r.traceId,e[45]=M):M=e[45];let v;return e[46]!==f||e[47]!==M||e[48]!==g?(v=(0,a.jsxs)("div",{className:"border-b border-border last:border-b-0","data-testid":g,children:[f,M]}),e[46]=f,e[47]=M,e[48]=g,e[49]=v):v=e[49],v},"xe"),De=y(o=>{let e=(0,H.c)(44),{initialShardKey:t}=o,s=z(),[r]=(0,E.useState)(de),{queryShardKey:n,setShardKey:p,shardKey:k}=se(r?.shardKey!==void 0&&r.shardKey!==""?r.shardKey:t??""),[g,P]=(0,E.useState)(r?.traceId??""),[$,C]=(0,E.useState)(Me),x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=[],e[0]=x):x=e[0],(0,E.useEffect)(ve,x);let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b={},e[1]=b):b=e[1];let w;e[2]!==n?(w={live:!0,shardKey:n},e[2]=n,e[3]=w):w=e[3];let{data:l,error:d,errorSource:I,isLoading:u,liveError:h}=ee(te.getTraces,b,w),i,N;e[4]!==l||e[5]!==n?(i=y(()=>{l!==void 0&&re(n)},"d"),N=[l,n],e[4]=l,e[5]=n,e[6]=i,e[7]=N):(i=e[6],N=e[7]),(0,E.useEffect)(i,N);let c;if(e[8]!==l||e[9]!==d||e[10]!==I||e[11]!==$||e[12]!==u||e[13]!==h||e[14]!==g||e[15]!==p||e[16]!==k||e[17]!==s){let m=be(l),f=l?.total??m.length,M=f>m.length,v=ge(m,g),S;e[19]===Symbol.for("react.memo_cache_sentinel")?(S=y(K=>{P(K.target.value)},"S"),e[19]=S):S=e[19];let _=S,T;e[20]===Symbol.for("react.memo_cache_sentinel")?(T=y(K=>{C(me=>{let W=new Set(me);return W.has(K)?W.delete(K):W.add(K),W})},"T"),e[20]=T):T=e[20];let F=T,A=d===null&&v.length===0&&!u,L;e[21]!==p||e[22]!==k?(L=(0,a.jsx)(ae,{onChange:p,testId:"tr-shard-input",value:k}),e[21]=p,e[22]=k,e[23]=L):L=e[23];let j;e[24]!==s?(j=s("Search traces"),e[24]=s,e[25]=j):j=e[25];let D;e[26]!==s?(D=s("search trace or function"),e[26]=s,e[27]=D):D=e[27];let U;e[28]!==g||e[29]!==j||e[30]!==D?(U=(0,a.jsx)(Y,{"aria-label":j,className:"h-8 w-56","data-testid":"tr-search",onChange:_,placeholder:D,value:g}),e[28]=g,e[29]=j,e[30]=D,e[31]=U):U=e[31];let q;e[32]!==h?(q=(0,a.jsx)(oe,{message:h,prefix:"tr"}),e[32]=h,e[33]=q):q=e[33];let B;e[34]!==U||e[35]!==q||e[36]!==L?(B=(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[L,U,q]}),e[34]=U,e[35]=q,e[36]=L,e[37]=B):B=e[37];let O;e[38]!==d||e[39]!==I?(O=d!==null&&(0,a.jsx)(ne,{error:I,testId:"tr-error"}),e[38]=d,e[39]=I,e[40]=O):O=e[40];let R;e[41]!==A||e[42]!==s?(R=A&&(0,a.jsx)(Z,{description:s("Traces recorded with ctx.trace show up here as your app handles traffic. The span buffer resets when the shard hibernates."),icon:(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M4 6h10M7 12h13M10 18h7"})}),testId:"tr-empty",title:s("No traces")}),e[41]=A,e[42]=s,e[43]=R):R=e[43],c=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[B,O,R,d===null&&M&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"tr-truncated",children:s("Showing the {shown} most recent of {total} traces in the buffer.",{shown:m.length,total:f})}),d===null&&v.length>0&&(0,a.jsx)("div",{"aria-label":s("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:v.map(K=>(0,a.jsx)(Ne,{expanded:$.has(K.traceId),onToggle:F,trace:K},K.traceId))})]}),e[8]=l,e[9]=d,e[10]=I,e[11]=$,e[12]=u,e[13]=h,e[14]=g,e[15]=p,e[16]=k,e[17]=s,e[18]=c}else c=e[18];return c},"Ae");function Me(){return new Set}y(Me,"be");function ve(){ie()}y(ve,"we");export{De as default};
1
+ import{b as de,c as ie}from"./chunk-PKSAWP56.js";import{a as le}from"./chunk-QWGT25SE.js";import{a as oe}from"./chunk-IGCNMZSB.js";import{a as se}from"./chunk-3CWGJYBB.js";import{a as ae}from"./chunk-RMN2JN4S.js";import{b as re}from"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as Y}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as X}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as ne}from"./chunk-KBBOZRRX.js";import"./chunk-XXQUMVWH.js";import"./chunk-DSU54IAT.js";import"./chunk-QLQADHFE.js";import{a as te}from"./chunk-VDW32UET.js";import{c as ee}from"./chunk-HRRFUAP6.js";import"./chunk-6FQJRXVI.js";import"./chunk-XBDKZZ67.js";import{a as Z}from"./chunk-XQCVZAGU.js";import{d as z,r as V}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as y,e as J,f as ue,g as he,h as fe,j as Q}from"./chunk-3XIESWL4.js";var H=J(he(),1),E=J(ue(),1);var a=J(fe(),1);var ce=y(o=>Math.min(100,Math.max(0,o)),"Q"),pe=y((o,e)=>{if(!Number.isFinite(e)||e<=0)return{leftPercent:0,widthPercent:100};let t=ce(o.offsetMs/e*100),s=o.durationMs/e*100,r=Math.max(.5,Math.min(ce(s),100-t));return{leftPercent:t,widthPercent:r}},"ue"),ge=y((o,e)=>{let t=e.trim().toLowerCase();return t===""?[...o]:o.filter(s=>s.rootName.toLowerCase().includes(t)||s.functionPath.toLowerCase().includes(t)||s.traceId.toLowerCase().includes(t))},"he"),G=y(o=>Number.isFinite(o)?o>0&&o<1?`${o.toFixed(2)}ms`:`${String(Math.round(o))}ms`:"\u2014","H"),xe=14,be=y(o=>Array.isArray(o?.traces)?o.traces:[],"pe"),we=y(o=>{let e=(0,H.c)(50),{span:t,traceDurationMs:s}=o,r=z(),n;e[0]!==t||e[1]!==s?(n=pe(t,s),e[0]=t,e[1]=s,e[2]=n):n=e[2];let{leftPercent:p,widthPercent:k}=n,g;e[3]!==t.attributes?(g=le(t.attributes),e[3]=t.attributes,e[4]=g):g=e[4];let P=g,$=t.depth*xe,C;e[5]!==$?(C={paddingLeft:$},e[5]=$,e[6]=C):C=e[6];let x=C,b=`${String(p)}%`,w=`${String(k)}%`,l;e[7]!==b||e[8]!==w?(l={left:b,width:w},e[7]=b,e[8]=w,e[9]=l):l=e[9];let d=l,I=t.depth,u;e[10]!==t.ok||e[11]!==r?(u=t.ok?null:(0,a.jsx)("span",{"aria-label":r("Errored span"),className:"mr-1 text-destructive","data-testid":"tr-span-error",role:"img",children:"\u25CF"}),e[10]=t.ok,e[11]=r,e[12]=u):u=e[12];let h;e[13]!==x||e[14]!==t.name||e[15]!==u?(h=(0,a.jsxs)("span",{className:"w-56 shrink-0 truncate",role:"gridcell",style:x,title:t.name,children:[u,t.name]}),e[13]=x,e[14]=t.name,e[15]=u,e[16]=h):h=e[16];let i;e[17]!==t.durationMs||e[18]!==t.offsetMs||e[19]!==r?(i=r("starts {offset} in, runs {duration}",{duration:G(t.durationMs),offset:G(t.offsetMs)}),e[17]=t.durationMs,e[18]=t.offsetMs,e[19]=r,e[20]=i):i=e[20];let N=t.ok?"bg-primary/70":"bg-destructive",c;e[21]!==N?(c=Q("absolute inset-y-0 rounded-sm",N),e[21]=N,e[22]=c):c=e[22];let m;e[23]!==d||e[24]!==p||e[25]!==c||e[26]!==k?(m=(0,a.jsx)("span",{className:c,"data-left":p,"data-testid":"tr-span-bar","data-width":k,style:d}),e[23]=d,e[24]=p,e[25]=c,e[26]=k,e[27]=m):m=e[27];let f;e[28]!==i||e[29]!==m?(f=(0,a.jsx)("span",{"aria-label":i,className:"relative h-3 flex-1 overflow-hidden rounded-sm bg-muted",role:"gridcell",children:m}),e[28]=i,e[29]=m,e[30]=f):f=e[30];let M;e[31]!==t.durationMs?(M=G(t.durationMs),e[31]=t.durationMs,e[32]=M):M=e[32];let v;e[33]!==M?(v=(0,a.jsx)("span",{className:"w-16 shrink-0 text-right tabular-nums text-muted-foreground",role:"gridcell",children:M}),e[33]=M,e[34]=v):v=e[34];let S;e[35]!==t.error?(S=t.error===void 0?null:(0,a.jsx)("span",{className:"text-destructive","data-testid":"tr-span-error-message",title:t.error.message,children:`${t.error.type}: ${t.error.message}`}),e[35]=t.error,e[36]=S):S=e[36];let _;e[37]!==S?(_=(0,a.jsx)("span",{className:"w-64 shrink-0 truncate text-muted-foreground",role:"gridcell",children:S}),e[37]=S,e[38]=_):_=e[38];let T;e[39]!==P?(T=P===""?null:(0,a.jsx)("span",{"data-testid":"tr-span-attributes",title:P,children:P}),e[39]=P,e[40]=T):T=e[40];let F;e[41]!==T?(F=(0,a.jsx)("span",{className:"w-64 shrink-0 truncate text-muted-foreground",role:"gridcell",children:T}),e[41]=T,e[42]=F):F=e[42];let A;return e[43]!==t.depth||e[44]!==h||e[45]!==f||e[46]!==v||e[47]!==_||e[48]!==F?(A=(0,a.jsxs)("div",{className:"flex items-center gap-2 border-b border-border px-3 py-1.5 font-mono text-xs last:border-b-0 hover:bg-muted/50","data-depth":I,"data-testid":"tr-span-row",role:"row",children:[h,f,v,_,F]}),e[43]=t.depth,e[44]=h,e[45]=f,e[46]=v,e[47]=_,e[48]=F,e[49]=A):A=e[49],A},"ge"),Ne=y(o=>{let e=(0,H.c)(50),{expanded:t,onToggle:s,trace:r}=o,n=z(),p;e[0]!==s||e[1]!==r.traceId?(p=y(()=>{s(r.traceId)},"p"),e[0]=s,e[1]=r.traceId,e[2]=p):p=e[2];let k=p,g=`tr-row-${r.traceId}`,P=`tr-waterfall-${r.traceId}`,$=`tr-toggle-${r.traceId}`,C=t?"\u25BE":"\u25B8",x;e[3]!==C?(x=(0,a.jsx)("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-xs text-muted-foreground",children:C}),e[3]=C,e[4]=x):x=e[4];let b;e[5]!==r.rootName?(b=(0,a.jsx)("span",{className:"w-56 shrink-0 truncate text-sm font-medium",title:r.rootName,children:r.rootName}),e[5]=r.rootName,e[6]=b):b=e[6];let w;e[7]!==r.functionPath?(w=(0,a.jsx)("span",{className:"w-48 shrink-0 truncate font-mono text-xs text-muted-foreground",title:r.functionPath,children:r.functionPath}),e[7]=r.functionPath,e[8]=w):w=e[8];let l;e[9]!==r.durationMs?(l=G(r.durationMs),e[9]=r.durationMs,e[10]=l):l=e[10];let d;e[11]!==l?(d=(0,a.jsx)("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:l}),e[11]=l,e[12]=d):d=e[12];let I;e[13]!==n||e[14]!==r.spans.length?(I=n("{count} spans",{count:r.spans.length}),e[13]=n,e[14]=r.spans.length,e[15]=I):I=e[15];let u;e[16]!==I?(u=(0,a.jsx)("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:I}),e[16]=I,e[17]=u):u=e[17];let h=r.ok?"secondary":"destructive",i;e[18]!==n||e[19]!==r.ok?(i=r.ok?n("ok"):n("error"),e[18]=n,e[19]=r.ok,e[20]=i):i=e[20];let N;e[21]!==h||e[22]!==i?(N=(0,a.jsx)("span",{className:"shrink-0",children:(0,a.jsx)(X,{variant:h,children:i})}),e[21]=h,e[22]=i,e[23]=N):N=e[23];let c;e[24]!==r.startTs?(c=V(r.startTs),e[24]=r.startTs,e[25]=c):c=e[25];let m;e[26]!==c?(m=(0,a.jsx)("span",{className:"flex-1 truncate text-right font-mono text-xs tabular-nums text-muted-foreground",children:c}),e[26]=c,e[27]=m):m=e[27];let f;e[28]!==t||e[29]!==k||e[30]!==d||e[31]!==u||e[32]!==N||e[33]!==m||e[34]!==P||e[35]!==$||e[36]!==x||e[37]!==b||e[38]!==w?(f=(0,a.jsxs)("button",{"aria-controls":P,"aria-expanded":t,className:"flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-muted/50","data-testid":$,onClick:k,type:"button",children:[x,b,w,d,u,N,m]}),e[28]=t,e[29]=k,e[30]=d,e[31]=u,e[32]=N,e[33]=m,e[34]=P,e[35]=$,e[36]=x,e[37]=b,e[38]=w,e[39]=f):f=e[39];let M;e[40]!==t||e[41]!==n||e[42]!==r.durationMs||e[43]!==r.spans||e[44]!==r.traceId?(M=t&&(0,a.jsx)("div",{"aria-label":n("Trace waterfall"),className:"bg-muted/20","data-testid":`tr-waterfall-${r.traceId}`,id:`tr-waterfall-${r.traceId}`,role:"grid",children:r.spans.map(S=>(0,a.jsx)(we,{span:S,traceDurationMs:r.durationMs},S.spanId))}),e[40]=t,e[41]=n,e[42]=r.durationMs,e[43]=r.spans,e[44]=r.traceId,e[45]=M):M=e[45];let v;return e[46]!==f||e[47]!==M||e[48]!==g?(v=(0,a.jsxs)("div",{className:"border-b border-border last:border-b-0","data-testid":g,children:[f,M]}),e[46]=f,e[47]=M,e[48]=g,e[49]=v):v=e[49],v},"xe"),De=y(o=>{let e=(0,H.c)(44),{initialShardKey:t}=o,s=z(),[r]=(0,E.useState)(de),{queryShardKey:n,setShardKey:p,shardKey:k}=se(r?.shardKey!==void 0&&r.shardKey!==""?r.shardKey:t??""),[g,P]=(0,E.useState)(r?.traceId??""),[$,C]=(0,E.useState)(Me),x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=[],e[0]=x):x=e[0],(0,E.useEffect)(ve,x);let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b={},e[1]=b):b=e[1];let w;e[2]!==n?(w={live:!0,shardKey:n},e[2]=n,e[3]=w):w=e[3];let{data:l,error:d,errorSource:I,isLoading:u,liveError:h}=ee(te.getTraces,b,w),i,N;e[4]!==l||e[5]!==n?(i=y(()=>{l!==void 0&&re(n)},"d"),N=[l,n],e[4]=l,e[5]=n,e[6]=i,e[7]=N):(i=e[6],N=e[7]),(0,E.useEffect)(i,N);let c;if(e[8]!==l||e[9]!==d||e[10]!==I||e[11]!==$||e[12]!==u||e[13]!==h||e[14]!==g||e[15]!==p||e[16]!==k||e[17]!==s){let m=be(l),f=l?.total??m.length,M=f>m.length,v=ge(m,g),S;e[19]===Symbol.for("react.memo_cache_sentinel")?(S=y(K=>{P(K.target.value)},"S"),e[19]=S):S=e[19];let _=S,T;e[20]===Symbol.for("react.memo_cache_sentinel")?(T=y(K=>{C(me=>{let W=new Set(me);return W.has(K)?W.delete(K):W.add(K),W})},"T"),e[20]=T):T=e[20];let F=T,A=d===null&&v.length===0&&!u,L;e[21]!==p||e[22]!==k?(L=(0,a.jsx)(ae,{onChange:p,testId:"tr-shard-input",value:k}),e[21]=p,e[22]=k,e[23]=L):L=e[23];let j;e[24]!==s?(j=s("Search traces"),e[24]=s,e[25]=j):j=e[25];let D;e[26]!==s?(D=s("search trace or function"),e[26]=s,e[27]=D):D=e[27];let U;e[28]!==g||e[29]!==j||e[30]!==D?(U=(0,a.jsx)(Y,{"aria-label":j,className:"h-8 w-56","data-testid":"tr-search",onChange:_,placeholder:D,value:g}),e[28]=g,e[29]=j,e[30]=D,e[31]=U):U=e[31];let q;e[32]!==h?(q=(0,a.jsx)(oe,{message:h,prefix:"tr"}),e[32]=h,e[33]=q):q=e[33];let B;e[34]!==U||e[35]!==q||e[36]!==L?(B=(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[L,U,q]}),e[34]=U,e[35]=q,e[36]=L,e[37]=B):B=e[37];let O;e[38]!==d||e[39]!==I?(O=d!==null&&(0,a.jsx)(ne,{error:I,testId:"tr-error"}),e[38]=d,e[39]=I,e[40]=O):O=e[40];let R;e[41]!==A||e[42]!==s?(R=A&&(0,a.jsx)(Z,{description:s("Traces recorded with ctx.trace show up here as your app handles traffic. The span buffer resets when the shard hibernates."),icon:(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M4 6h10M7 12h13M10 18h7"})}),testId:"tr-empty",title:s("No traces")}),e[41]=A,e[42]=s,e[43]=R):R=e[43],c=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[B,O,R,d===null&&M&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"tr-truncated",children:s("Showing the {shown} most recent of {total} traces in the buffer.",{shown:m.length,total:f})}),d===null&&v.length>0&&(0,a.jsx)("div",{"aria-label":s("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:v.map(K=>(0,a.jsx)(Ne,{expanded:$.has(K.traceId),onToggle:F,trace:K},K.traceId))})]}),e[8]=l,e[9]=d,e[10]=I,e[11]=$,e[12]=u,e[13]=h,e[14]=g,e[15]=p,e[16]=k,e[17]=s,e[18]=c}else c=e[18];return c},"Ae");function Me(){return new Set}y(Me,"be");function ve(){ie()}y(ve,"we");export{De as default};
@@ -1 +1 @@
1
- import{a as N}from"./chunk-TMGHRD6W.js";import{a as z}from"./chunk-54MMVNPT.js";import{a as q}from"./chunk-3CWGJYBB.js";import{a as W}from"./chunk-RMN2JN4S.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as R}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as B}from"./chunk-NCKRVNF2.js";import"./chunk-XXQUMVWH.js";import"./chunk-NJRW66LJ.js";import"./chunk-QLQADHFE.js";import{a as U}from"./chunk-VDW32UET.js";import{c as L}from"./chunk-6F7KP54M.js";import"./chunk-C2ZFQARQ.js";import"./chunk-XBDKZZ67.js";import{a as A}from"./chunk-XQCVZAGU.js";import{a as E,b as H,c as O,d as K,e as T,f as D}from"./chunk-WJQLNYGX.js";import{a as _}from"./chunk-WQH3LT2P.js";import{d as j}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as M,e as F,g as V,h as X}from"./chunk-3XIESWL4.js";var P=F(V(),1);var t=F(X(),1);var G=M(n=>`${n.toString()} ms`,"D"),Q=M(n=>n.totalConnections===0&&n.shapePoke.passes===0&&n.whisper.passes===0,"z"),J=M(n=>{let e=(0,P.c)(48),{counters:r,includeTiming:s,prefix:l,t:o,title:b}=n,k=`${l}-section`,p;e[0]!==b?(p=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:b}),e[0]=b,e[1]=p):p=e[1];let a=`${l}-stats`,i;e[2]!==o?(i=o("Passes"),e[2]=o,e[3]=i):i=e[3];let I=`${l}-passes`,v;e[4]!==r.passes||e[5]!==i||e[6]!==I?(v=(0,t.jsx)(N,{label:i,testId:I,value:r.passes}),e[4]=r.passes,e[5]=i,e[6]=I,e[7]=v):v=e[7];let h;e[8]!==o?(h=o("Sockets iterated"),e[8]=o,e[9]=h):h=e[9];let x=`${l}-iterated`,c;e[10]!==r.socketsIterated||e[11]!==h||e[12]!==x?(c=(0,t.jsx)(N,{label:h,testId:x,value:r.socketsIterated}),e[10]=r.socketsIterated,e[11]=h,e[12]=x,e[13]=c):c=e[13];let d;e[14]!==o?(d=o("Delivered"),e[14]=o,e[15]=d):d=e[15];let y=`${l}-delivered`,m;e[16]!==r.socketsDelivered||e[17]!==d||e[18]!==y?(m=(0,t.jsx)(N,{label:d,testId:y,value:r.socketsDelivered}),e[16]=r.socketsDelivered,e[17]=d,e[18]=y,e[19]=m):m=e[19];let u;e[20]!==o?(u=o("Peak width"),e[20]=o,e[21]=u):u=e[21];let g=`${l}-peak`,f;e[22]!==r.peakSocketsIterated||e[23]!==u||e[24]!==g?(f=(0,t.jsx)(N,{label:u,testId:g,value:r.peakSocketsIterated}),e[22]=r.peakSocketsIterated,e[23]=u,e[24]=g,e[25]=f):f=e[25];let S;e[26]!==r.totalMs||e[27]!==s||e[28]!==l||e[29]!==o?(S=s&&(0,t.jsx)(N,{label:o("Total time"),testId:`${l}-total-ms`,value:G(r.totalMs)}),e[26]=r.totalMs,e[27]=s,e[28]=l,e[29]=o,e[30]=S):S=e[30];let C;e[31]!==r.maxMs||e[32]!==s||e[33]!==l||e[34]!==o?(C=s&&(0,t.jsx)(N,{label:o("Max time"),testId:`${l}-max-ms`,value:G(r.maxMs)}),e[31]=r.maxMs,e[32]=s,e[33]=l,e[34]=o,e[35]=C):C=e[35];let $;e[36]!==m||e[37]!==f||e[38]!==S||e[39]!==C||e[40]!==a||e[41]!==v||e[42]!==c?($=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":a,children:[v,c,m,f,S,C]}),e[36]=m,e[37]=f,e[38]=S,e[39]=C,e[40]=a,e[41]=v,e[42]=c,e[43]=$):$=e[43];let w;return e[44]!==k||e[45]!==$||e[46]!==p?(w=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":k,children:[p,$]}),e[44]=k,e[45]=$,e[46]=p,e[47]=w):w=e[47],w},"F"),me=M(n=>{let e=(0,P.c)(31),{initialShardKey:r}=n,s=j(),{queryShardKey:l,setShardKey:o,shardKey:b}=q(r),k;e[0]===Symbol.for("react.memo_cache_sentinel")?(k={},e[0]=k):k=e[0];let p;e[1]!==l?(p={keepPreviousData:!0,shardKey:l},e[1]=l,e[2]=p):p=e[2];let{data:a,error:i,errorSource:I,refetch:v}=L(U.getFanoutMetrics,k,p);z(v,!0);let h;e[3]!==a?(h=a!==void 0&&Q(a),e[3]=a,e[4]=h):h=e[4];let x=h,c;e[5]!==o||e[6]!==b?(c=(0,t.jsx)(W,{onChange:o,testId:"fanout-shard-input",value:b}),e[5]=o,e[6]=b,e[7]=c):c=e[7];let d;e[8]!==a||e[9]!==s?(d=a!==void 0&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"fanout-count",children:[a.promoted&&(0,t.jsx)(R,{"data-testid":"fanout-promoted",variant:a.relayCount>=a.maxRelays?"destructive":"default",children:a.relayCount>=a.maxRelays?s("auto-scaled: {relayCount}/{maxRelays} relays (at ceiling)",{maxRelays:a.maxRelays,relayCount:a.relayCount}):s("auto-scaled: {relayCount}/{maxRelays} relays",{maxRelays:a.maxRelays,relayCount:a.relayCount})}),(0,t.jsx)(R,{variant:"secondary",children:s("{count} connections",{count:a.totalConnections})}),(0,t.jsx)(R,{variant:"secondary",children:s("peak {count} subscribers",{count:a.peakSubscribers})})]}),e[8]=a,e[9]=s,e[10]=d):d=e[10];let y;e[11]!==c||e[12]!==d?(y=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,d]}),e[11]=c,e[12]=d,e[13]=y):y=e[13];let m;e[14]!==i||e[15]!==I?(m=i!==null&&(0,t.jsx)(B,{error:I,testId:"fanout-error"}),e[14]=i,e[15]=I,e[16]=m):m=e[16];let u;e[17]!==i||e[18]!==x||e[19]!==s?(u=i===null&&x&&(0,t.jsx)(A,{description:s("Realtime fan-out cost and per-topic subscriber counts for this shard."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M4 12h4l3 7 4-14 3 7h2"})}),testId:"fanout-empty",title:s("No fan-out activity yet.")}),e[17]=i,e[18]=x,e[19]=s,e[20]=u):u=e[20];let g;e[21]!==i||e[22]!==x||e[23]!==a||e[24]!==s?(g=i===null&&a!==void 0&&!x&&(0,t.jsxs)(t.Fragment,{children:[a.topics.length>0&&(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-topics-section",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:s("Hot topics")}),(0,t.jsx)(_,{className:"overflow-hidden py-0",children:(0,t.jsxs)(E,{"data-testid":"fanout-topics-table",children:[(0,t.jsx)(H,{children:(0,t.jsxs)(K,{children:[(0,t.jsx)(T,{children:s("Topic")}),(0,t.jsx)(T,{children:s("Kind")}),(0,t.jsx)(T,{className:"text-right",children:s("Subscribers")})]})}),(0,t.jsx)(O,{children:a.topics.map(Y)})]})})]}),(0,t.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"fanout-cost",children:[(0,t.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:s("Fan-out cost since this instance woke")}),(0,t.jsx)(J,{counters:a.shapePoke,includeTiming:!0,prefix:"fanout-poke",t:s,title:s("Shape pokes")}),(0,t.jsx)(J,{counters:a.whisper,includeTiming:!1,prefix:"fanout-whisper",t:s,title:s("Whisper broadcasts")})]})]}),e[21]=i,e[22]=x,e[23]=a,e[24]=s,e[25]=g):g=e[25];let f;return e[26]!==y||e[27]!==m||e[28]!==u||e[29]!==g?(f=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"fanout-panel",children:[y,m,u,g]}),e[26]=y,e[27]=m,e[28]=u,e[29]=g,e[30]=f):f=e[30],f},"me");function Y(n){return(0,t.jsxs)(K,{"data-testid":"fanout-topic-row",children:[(0,t.jsx)(D,{className:"font-mono text-xs",children:n.topic}),(0,t.jsx)(D,{children:(0,t.jsx)(R,{variant:"outline",children:n.kind})}),(0,t.jsx)(D,{className:"text-right font-medium tabular-nums",children:n.subscribers})]},`${n.kind}:${n.topic}`)}M(Y,"G");export{me as default};
1
+ import{a as N}from"./chunk-TMGHRD6W.js";import{a as z}from"./chunk-54MMVNPT.js";import{a as q}from"./chunk-3CWGJYBB.js";import{a as W}from"./chunk-RMN2JN4S.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as R}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as B}from"./chunk-KBBOZRRX.js";import"./chunk-XXQUMVWH.js";import"./chunk-DSU54IAT.js";import"./chunk-QLQADHFE.js";import{a as U}from"./chunk-VDW32UET.js";import{c as L}from"./chunk-HRRFUAP6.js";import"./chunk-6FQJRXVI.js";import"./chunk-XBDKZZ67.js";import{a as A}from"./chunk-XQCVZAGU.js";import{a as E,b as H,c as O,d as K,e as T,f as D}from"./chunk-WJQLNYGX.js";import{a as _}from"./chunk-WQH3LT2P.js";import{d as j}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as M,e as F,g as V,h as X}from"./chunk-3XIESWL4.js";var P=F(V(),1);var t=F(X(),1);var G=M(n=>`${n.toString()} ms`,"D"),Q=M(n=>n.totalConnections===0&&n.shapePoke.passes===0&&n.whisper.passes===0,"z"),J=M(n=>{let e=(0,P.c)(48),{counters:r,includeTiming:s,prefix:l,t:o,title:b}=n,k=`${l}-section`,p;e[0]!==b?(p=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:b}),e[0]=b,e[1]=p):p=e[1];let a=`${l}-stats`,i;e[2]!==o?(i=o("Passes"),e[2]=o,e[3]=i):i=e[3];let I=`${l}-passes`,v;e[4]!==r.passes||e[5]!==i||e[6]!==I?(v=(0,t.jsx)(N,{label:i,testId:I,value:r.passes}),e[4]=r.passes,e[5]=i,e[6]=I,e[7]=v):v=e[7];let h;e[8]!==o?(h=o("Sockets iterated"),e[8]=o,e[9]=h):h=e[9];let x=`${l}-iterated`,c;e[10]!==r.socketsIterated||e[11]!==h||e[12]!==x?(c=(0,t.jsx)(N,{label:h,testId:x,value:r.socketsIterated}),e[10]=r.socketsIterated,e[11]=h,e[12]=x,e[13]=c):c=e[13];let d;e[14]!==o?(d=o("Delivered"),e[14]=o,e[15]=d):d=e[15];let y=`${l}-delivered`,m;e[16]!==r.socketsDelivered||e[17]!==d||e[18]!==y?(m=(0,t.jsx)(N,{label:d,testId:y,value:r.socketsDelivered}),e[16]=r.socketsDelivered,e[17]=d,e[18]=y,e[19]=m):m=e[19];let u;e[20]!==o?(u=o("Peak width"),e[20]=o,e[21]=u):u=e[21];let g=`${l}-peak`,f;e[22]!==r.peakSocketsIterated||e[23]!==u||e[24]!==g?(f=(0,t.jsx)(N,{label:u,testId:g,value:r.peakSocketsIterated}),e[22]=r.peakSocketsIterated,e[23]=u,e[24]=g,e[25]=f):f=e[25];let S;e[26]!==r.totalMs||e[27]!==s||e[28]!==l||e[29]!==o?(S=s&&(0,t.jsx)(N,{label:o("Total time"),testId:`${l}-total-ms`,value:G(r.totalMs)}),e[26]=r.totalMs,e[27]=s,e[28]=l,e[29]=o,e[30]=S):S=e[30];let C;e[31]!==r.maxMs||e[32]!==s||e[33]!==l||e[34]!==o?(C=s&&(0,t.jsx)(N,{label:o("Max time"),testId:`${l}-max-ms`,value:G(r.maxMs)}),e[31]=r.maxMs,e[32]=s,e[33]=l,e[34]=o,e[35]=C):C=e[35];let $;e[36]!==m||e[37]!==f||e[38]!==S||e[39]!==C||e[40]!==a||e[41]!==v||e[42]!==c?($=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":a,children:[v,c,m,f,S,C]}),e[36]=m,e[37]=f,e[38]=S,e[39]=C,e[40]=a,e[41]=v,e[42]=c,e[43]=$):$=e[43];let w;return e[44]!==k||e[45]!==$||e[46]!==p?(w=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":k,children:[p,$]}),e[44]=k,e[45]=$,e[46]=p,e[47]=w):w=e[47],w},"F"),me=M(n=>{let e=(0,P.c)(31),{initialShardKey:r}=n,s=j(),{queryShardKey:l,setShardKey:o,shardKey:b}=q(r),k;e[0]===Symbol.for("react.memo_cache_sentinel")?(k={},e[0]=k):k=e[0];let p;e[1]!==l?(p={keepPreviousData:!0,shardKey:l},e[1]=l,e[2]=p):p=e[2];let{data:a,error:i,errorSource:I,refetch:v}=L(U.getFanoutMetrics,k,p);z(v,!0);let h;e[3]!==a?(h=a!==void 0&&Q(a),e[3]=a,e[4]=h):h=e[4];let x=h,c;e[5]!==o||e[6]!==b?(c=(0,t.jsx)(W,{onChange:o,testId:"fanout-shard-input",value:b}),e[5]=o,e[6]=b,e[7]=c):c=e[7];let d;e[8]!==a||e[9]!==s?(d=a!==void 0&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"fanout-count",children:[a.promoted&&(0,t.jsx)(R,{"data-testid":"fanout-promoted",variant:a.relayCount>=a.maxRelays?"destructive":"default",children:a.relayCount>=a.maxRelays?s("auto-scaled: {relayCount}/{maxRelays} relays (at ceiling)",{maxRelays:a.maxRelays,relayCount:a.relayCount}):s("auto-scaled: {relayCount}/{maxRelays} relays",{maxRelays:a.maxRelays,relayCount:a.relayCount})}),(0,t.jsx)(R,{variant:"secondary",children:s("{count} connections",{count:a.totalConnections})}),(0,t.jsx)(R,{variant:"secondary",children:s("peak {count} subscribers",{count:a.peakSubscribers})})]}),e[8]=a,e[9]=s,e[10]=d):d=e[10];let y;e[11]!==c||e[12]!==d?(y=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,d]}),e[11]=c,e[12]=d,e[13]=y):y=e[13];let m;e[14]!==i||e[15]!==I?(m=i!==null&&(0,t.jsx)(B,{error:I,testId:"fanout-error"}),e[14]=i,e[15]=I,e[16]=m):m=e[16];let u;e[17]!==i||e[18]!==x||e[19]!==s?(u=i===null&&x&&(0,t.jsx)(A,{description:s("Realtime fan-out cost and per-topic subscriber counts for this shard."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M4 12h4l3 7 4-14 3 7h2"})}),testId:"fanout-empty",title:s("No fan-out activity yet.")}),e[17]=i,e[18]=x,e[19]=s,e[20]=u):u=e[20];let g;e[21]!==i||e[22]!==x||e[23]!==a||e[24]!==s?(g=i===null&&a!==void 0&&!x&&(0,t.jsxs)(t.Fragment,{children:[a.topics.length>0&&(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-topics-section",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:s("Hot topics")}),(0,t.jsx)(_,{className:"overflow-hidden py-0",children:(0,t.jsxs)(E,{"data-testid":"fanout-topics-table",children:[(0,t.jsx)(H,{children:(0,t.jsxs)(K,{children:[(0,t.jsx)(T,{children:s("Topic")}),(0,t.jsx)(T,{children:s("Kind")}),(0,t.jsx)(T,{className:"text-right",children:s("Subscribers")})]})}),(0,t.jsx)(O,{children:a.topics.map(Y)})]})})]}),(0,t.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"fanout-cost",children:[(0,t.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:s("Fan-out cost since this instance woke")}),(0,t.jsx)(J,{counters:a.shapePoke,includeTiming:!0,prefix:"fanout-poke",t:s,title:s("Shape pokes")}),(0,t.jsx)(J,{counters:a.whisper,includeTiming:!1,prefix:"fanout-whisper",t:s,title:s("Whisper broadcasts")})]})]}),e[21]=i,e[22]=x,e[23]=a,e[24]=s,e[25]=g):g=e[25];let f;return e[26]!==y||e[27]!==m||e[28]!==u||e[29]!==g?(f=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"fanout-panel",children:[y,m,u,g]}),e[26]=y,e[27]=m,e[28]=u,e[29]=g,e[30]=f):f=e[30],f},"me");function Y(n){return(0,t.jsxs)(K,{"data-testid":"fanout-topic-row",children:[(0,t.jsx)(D,{className:"font-mono text-xs",children:n.topic}),(0,t.jsx)(D,{children:(0,t.jsx)(R,{variant:"outline",children:n.kind})}),(0,t.jsx)(D,{className:"text-right font-medium tabular-nums",children:n.subscribers})]},`${n.kind}:${n.topic}`)}M(Y,"G");export{me as default};
@@ -1,4 +1,4 @@
1
- import{a as Ze}from"./chunk-ATLV7KWK.js";import{a as Je,b as Ve}from"./chunk-KP6VHTO4.js";import{a as Xe}from"./chunk-6V27P65N.js";import"./chunk-4KIQ5RLS.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import"./chunk-ESVP44Y3.js";import"./chunk-I6A5C46N.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import{a as Ge}from"./chunk-FURI47Z2.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import"./chunk-OQIGV6FX.js";import"./chunk-4UOFSGUS.js";import"./chunk-CZZWYUTR.js";import"./chunk-AREBQI6D.js";import{a as Qe}from"./chunk-RMN2JN4S.js";import{b as Pe}from"./chunk-GRL5MG3Z.js";import{d as Ce,e as Oe,f as Me}from"./chunk-7T7UOTYK.js";import{R as Fe}from"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{a as We}from"./chunk-XXQUMVWH.js";import{a as we}from"./chunk-VDW32UET.js";import"./chunk-6F7KP54M.js";import{f as ke}from"./chunk-C2ZFQARQ.js";import"./chunk-XBDKZZ67.js";import{a as He,b as je,c as Ke,d as De,e as Ye,f as Ue}from"./chunk-WJQLNYGX.js";import{d as oe,f as ve,g as ye,h as _e,o as ie}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as i,e as Ee,f as dt,g as ut,h as mt,j as ue}from"./chunk-3XIESWL4.js";var K=Ee(ut(),1);var P=Ee(dt(),1);var c=Ee(mt(),1);var ht=["ORDER BY","GROUP BY","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN","EXPLAIN QUERY PLAN","SELECT","DISTINCT","FROM","WHERE","HAVING","LIMIT","OFFSET","JOIN","ON","AND","OR","AS","ASC","DESC","WITH","UNION","EXPLAIN"],ft=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],Ie=String.fromCodePoint(0),pt=new RegExp(`${Ie}${String.raw`(\d+)`}${Ie}`,"gu"),bt=ht.map(l=>({pattern:new RegExp(String.raw`\b${l.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:l})),gt=ft.map(l=>({pattern:new RegExp(String.raw`\s+${l.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
1
+ import{a as Ze}from"./chunk-ATLV7KWK.js";import{a as Je,b as Ve}from"./chunk-BMZPRRSX.js";import{a as Xe}from"./chunk-6V27P65N.js";import"./chunk-4KIQ5RLS.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import"./chunk-ESVP44Y3.js";import"./chunk-I6A5C46N.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import{a as Ge}from"./chunk-FURI47Z2.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import"./chunk-OQIGV6FX.js";import"./chunk-4UOFSGUS.js";import"./chunk-CZZWYUTR.js";import"./chunk-AREBQI6D.js";import{a as Qe}from"./chunk-RMN2JN4S.js";import{b as Pe}from"./chunk-GRL5MG3Z.js";import{d as Ce,e as Oe,f as Me}from"./chunk-7T7UOTYK.js";import{R as Fe}from"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{a as We}from"./chunk-XXQUMVWH.js";import{a as we}from"./chunk-VDW32UET.js";import"./chunk-HRRFUAP6.js";import{f as ke}from"./chunk-6FQJRXVI.js";import"./chunk-XBDKZZ67.js";import{a as He,b as je,c as Ke,d as De,e as Ye,f as Ue}from"./chunk-WJQLNYGX.js";import{d as oe,f as ve,g as ye,h as _e,o as ie}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as i,e as Ee,f as dt,g as ut,h as mt,j as ue}from"./chunk-3XIESWL4.js";var K=Ee(ut(),1);var P=Ee(dt(),1);var c=Ee(mt(),1);var ht=["ORDER BY","GROUP BY","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN","EXPLAIN QUERY PLAN","SELECT","DISTINCT","FROM","WHERE","HAVING","LIMIT","OFFSET","JOIN","ON","AND","OR","AS","ASC","DESC","WITH","UNION","EXPLAIN"],ft=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],Ie=String.fromCodePoint(0),pt=new RegExp(`${Ie}${String.raw`(\d+)`}${Ie}`,"gu"),bt=ht.map(l=>({pattern:new RegExp(String.raw`\b${l.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:l})),gt=ft.map(l=>({pattern:new RegExp(String.raw`\s+${l.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
2
2
  ${l}`})),xt=i(l=>{let e=[],t=l.replaceAll(/'(?:[^']|'')*'/gu,n=>(e.push(n),`${Ie}${(e.length-1).toString()}${Ie}`)).replaceAll(/\s+/gu," ").trim();for(let{pattern:n,replacement:r}of bt)t=t.replaceAll(n,r);for(let{pattern:n,replacement:r}of gt)t=t.replaceAll(n,r);return t=t.replaceAll(pt,(n,r)=>e[Number(r)]??""),t},"yt"),vt=/^(?:explain\s+(?:query\s+plan\s+)?)?(?:select|with)\b/iu,yt=/\b(?:alter|attach|create|delete|detach|drop|insert|pragma|reindex|replace|truncate|update|vacuum)\b/iu,wt=/^\w+/u,St=/;\s*$/u,Nt=/\s/u,kt=i((l,e)=>{let t=e+2;for(;t<l.length&&l[t]!==`
3
3
  `;)t+=1;return t},"$t"),Ct=i((l,e)=>{let t=l.indexOf("*/",e+2);return t===-1?-1:t+2},"qt"),qt=i(l=>{let e=0;for(;e<l.length;){let t=l[e];if(t!==void 0&&Nt.test(t))e+=1;else if(t==="-"&&l[e+1]==="-")e=kt(l,e);else if(t==="/"&&l[e+1]==="*"){let n=Ct(l,e);if(n===-1)break;e=n}else break}return e},"Tt"),Tt=i(l=>{let e=qt(l),t=l.slice(e).trimEnd();if(t==="")return{code:"SQL_EMPTY",message:"the query is empty"};let n=t.replace(St,""),r=n.indexOf(";");if(r!==-1)return{code:"SQL_MULTIPLE_STATEMENTS",length:1,message:"only a single statement may be run",offset:e+r};let o="the SQL editor is read-only \u2014 only SELECT / WITH / EXPLAIN queries are allowed";if(!vt.test(n))return{code:"SQL_NOT_READONLY",length:wt.exec(n)?.[0].length??1,message:o,offset:e};let s=yt.exec(n);if(s!==null)return{code:"SQL_NOT_READONLY",length:s[0].length,message:`${o} (\`${s[0].toUpperCase()}\` is not allowed)`,offset:e+s.index}},"Rt"),It=/\b(?:from|join)\s+([a-z_][\w$]*)(?:\s+(?:as\s+)?([a-z_][\w$]*))?/giu,Rt=/(?:\bwith\s+(?:recursive\s+)?|,\s*)([a-z_][\w$]*)\s+as\s*\(/giu,Lt=new Set(["cross","full","group","having","inner","join","left","limit","offset","on","order","right","union","using","where","window"]),Et=/[^\n]/gu,_t=i((l,e)=>{let t=l[e];if(t==="'"){let n=e+1;for(;n<l.length&&l[n]!=="'";)n+=1;return Math.min(n+1,l.length)}if(t==="-"&&l[e+1]==="-"){let n=l.indexOf(`
4
4
  `,e);return n===-1?l.length:n}if(t==="/"&&l[e+1]==="*"){let n=l.indexOf("*/",e+2);return n===-1?l.length:n+2}return-1},"Ot"),Ot=i(l=>{let e="",t=0;for(;t<l.length;){let n=_t(l,t);n===-1?(e+=l.slice(t,t+1),t+=1):(e+=l.slice(t,n).replaceAll(Et," "),t=n)}return e},"Mt"),Mt=i(l=>{let e=new Set;for(let t of l.matchAll(Rt))e.add((t[1]??"").toLowerCase());return e},"Dt"),Dt=i((l,e)=>{let t=new Map;for(let n of l.matchAll(It)){let r=(n[1]??"").toLowerCase(),o=(n[2]??"").toLowerCase();e.has(r)&&(t.set(r,r),o!==""&&!Lt.has(o)&&t.set(o,r))}return t},"At"),ot=i((l,e)=>{let t=Ot(l),n=new Set(e.map(r=>r.toLowerCase()));return{ctes:Mt(t),masked:t,targets:Dt(t,n)}},"Ke"),At=/^(?:__lunora|sqlite_)/iu,$t=/\b(?:from|join)\s+([a-z_][\w$]*)/giu,Bt=/\b([a-z_][\w$]*)\.([a-z_][\w$]*)/giu,zt=new Set(["cross","full","group","having","inner","join","lateral","left","limit","offset","order","right","select","union","where","window"]),Ft=i((l,e,t)=>{let n=[];for(let r of l.matchAll($t)){let o=r[1]??"",s=o.toLowerCase();!e.has(s)&&!t.has(s)&&!zt.has(s)&&!At.test(o)&&n.push({length:o.length,message:`unknown table \`${o}\``,offset:r.index+r[0].length-o.length,severity:"error",source:"schema"})}return n},"Ft"),Pt=i((l,e,t)=>{let n=[],r=new Map;for(let[o,s]of Object.entries(e.columns))r.set(o.toLowerCase(),new Set(s.map(m=>m.toLowerCase())));for(let o of l.matchAll(Bt)){let s=(o[1]??"").toLowerCase(),m=o[2]??"",a=t.get(s),d=a===void 0?void 0:r.get(a);d!==void 0&&!d.has(m.toLowerCase())&&n.push({length:m.length,message:`\`${a??""}\` has no column \`${m}\``,offset:o.index+o[0].length-m.length,severity:"error",source:"schema"})}return n},"Qt"),Qt=i((l,e)=>{if(l.trim()==="")return[];let t=Tt(l);if(t!==void 0)return t.code==="SQL_EMPTY"?[]:[{length:t.length,message:t.message,offset:t.offset,severity:"error",source:"gate"}];let{ctes:n,masked:r,targets:o}=ot(l,e.tables),s=new Set(e.tables.map(m=>m.toLowerCase()));return[...Ft(r,s,n),...Pt(r,e,o)]},"jt"),Wt=ve(we.lintSql),Ht=600,jt=i((l,e,t)=>{let n=ke(),[r,o]=(0,P.useState)([]),s=(0,P.useMemo)(()=>Qt(l,e),[l,e]),m=Ge(l,Ht),a=s.some(p=>p.source==="gate")||m.trim()==="",d=(0,P.useCallback)(async p=>{try{let b=await n.query(Wt,{sql:m},ye(t));p.cancelled||o(b.diagnostics??[])}catch{p.cancelled||o([])}},[n,m,t]);(0,P.useEffect)(()=>{if(a){o([]);return}let p={cancelled:!1};return ie(d(p)),()=>{p.cancelled=!0}},[d,a]);let f=m===l;return(0,P.useMemo)(()=>f?[...s,...r]:s,[s,r,f])},"Ut"),qe=8,Kt=["AND","ASC","AS","BY","COUNT","DESC","DISTINCT","EXPLAIN","FROM","GROUP","HAVING","INNER","JOIN","LEFT","LIKE","LIMIT","NOT","NULL","OFFSET","ON","ORDER","OR","QUERY","SELECT","WHERE","WITH"],Yt=new Set(["AND","BY","HAVING","ON","OR","SELECT","WHERE"]),Ut=/[\w$]/,rt=i(l=>l!==void 0&&Ut.test(l),"Ue"),lt=i(l=>{let e=l.length;for(;e>0&&rt(l[e-1]);)e-=1;return l.slice(e)},"Ye"),st=i((l,e)=>{let t=e;for(;t>0&&rt(l[t-1]);)t-=1;return{end:e,start:t,text:l.slice(t,e)}},"Je"),et=i((l,e)=>{let t=l.slice(0,e).trimEnd();return t.endsWith(".")||Yt.has(lt(t).toUpperCase())},"Pe"),Gt=i((l,e,t)=>{let n=l.slice(0,e);if(!n.endsWith("."))return;let r=lt(n.slice(0,-1));if(r!=="")return ot(l,t).targets.get(r.toLowerCase())??r},"Vt"),$e=i((l,e)=>l.toLowerCase().startsWith(e.toLowerCase()),"Me"),tt=i((l,e,t,n)=>{let r=[];for(let o of l)if($e(o,e)&&(r.push(n(o)),r.length>=t))break;return r},"Fe"),Jt=i((l,e,t)=>{let n=new Map;for(let[r,o]of Object.entries(l.columns))for(let s of o)if($e(s,e)&&!n.has(s)&&(n.set(s,r),n.size>=t))return[...n].map(([m,a])=>({detail:a,kind:"column",label:m}));return[...n].map(([r,o])=>({detail:o,kind:"column",label:r}))},"Xt"),Vt=i((l,e,t)=>{let n=st(l,e),r=Gt(l,n.start,t.tables);if(r!==void 0){let a=t.columns[r]??t.columns[r.toLowerCase()]??[];return tt(a,n.text,qe,d=>({detail:r,kind:"column",label:d}))}if(n.text===""&&!et(l,n.start))return[];let o=tt(t.tables,n.text,qe,a=>({kind:"table",label:a})),s=Jt(t,n.text,qe),m=Kt.flatMap(a=>n.text!==""&&$e(a,n.text)&&a.toLowerCase()!==n.text.toLowerCase()?[{kind:"keyword",label:a}]:[]);return(et(l,n.start)?[...s,...o,...m]:[...o,...s,...m]).slice(0,qe)},"Zt"),Xt=i((l,e,t)=>{let n=st(l,e),r=l.slice(0,n.start)+t.label+l.slice(n.end);return{caret:n.start+t.label.length,value:r}},"en"),Zt=["boxSizing","borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textTransform","width","wordSpacing"],en=i((l,e)=>{let t=globalThis.getComputedStyle(l),n=globalThis.document.createElement("div"),{style:r}=n;r.position="absolute",r.visibility="hidden",r.whiteSpace="pre-wrap",r.overflowWrap="break-word";for(let a of Zt)r[a]=t[a];n.textContent=l.value.slice(0,Math.max(0,e));let o=globalThis.document.createElement("span");o.textContent=l.value.slice(Math.max(0,e))||".",n.append(o),globalThis.document.body.append(n);let s=o.offsetLeft-l.scrollLeft,m=o.offsetTop-l.scrollTop;return n.remove(),{left:s,top:m}},"nn"),tn=i((l,e,t)=>{let n=(0,K.c)(16),[r,o]=(0,P.useState)(null),s;n[0]!==l||n[1]!==e?(s=i((w,g)=>{let h=Vt(w,g,l);if(h.length===0){o(null);return}let S=e.current,{left:k,top:N}=S===null?{left:0,top:0}:en(S,g);o(C=>C!==null&&C.active===0&&C.left===k&&C.top===N&&C.suggestions.length===h.length&&C.suggestions.every((L,R)=>{let E=h.at(R);return L.kind===E?.kind&&L.label===E.label&&L.detail===E.detail})?C:{active:0,left:k,suggestions:h,top:N})},"s"),n[0]=l,n[1]=e,n[2]=s):s=n[2];let m=s,a;n[3]===Symbol.for("react.memo_cache_sentinel")?(a=i(()=>{o(null)},"a"),n[3]=a):a=n[3];let d=a,f;n[4]===Symbol.for("react.memo_cache_sentinel")?(f=i(w=>{o(g=>{if(g===null)return g;let h=g.suggestions.length,S=(g.active+w+h)%h;return{...g,active:S}})},"f"),n[4]=f):f=n[4];let p=f,b;n[5]!==t||n[6]!==r||n[7]!==e?(b=i(w=>{let g=e.current;if(r===null||g===null)return!1;let h=r.suggestions[w??r.active];if(h===void 0)return!1;let S=Xt(g.value,g.selectionStart,h);return t(S.value),o(null),requestAnimationFrame(()=>{let k=e.current;k!==null&&(k.focus(),k.setSelectionRange(S.caret,S.caret))}),!0},"p"),n[5]=t,n[6]=r,n[7]=e,n[8]=b):b=n[8];let v=b,u;n[9]!==v?(u=i(()=>v(),"c"),n[9]=v,n[10]=u):u=n[10];let x=u,y;return n[11]!==x||n[12]!==v||n[13]!==m||n[14]!==r?(y={close:d,commit:x,commitAt:v,move:p,refresh:m,state:r},n[11]=x,n[12]=v,n[13]=m,n[14]=r,n[15]=y):y=n[15],y},"on"),nn={column:"column",keyword:"keyword",table:"table"},on=20,rn=i(l=>{let e=(0,K.c)(17),{listboxId:t,onPick:n,state:r}=l,o=oe(),s;e[0]!==r?(s=r===null?void 0:{left:r.left,top:r.top+on},e[0]=r,e[1]=s):s=e[1];let m=s;if(r===null)return null;let a;if(e[2]!==t||e[3]!==n||e[4]!==r.active||e[5]!==r.suggestions||e[6]!==o){let f;e[8]!==t||e[9]!==n||e[10]!==r.active||e[11]!==o?(f=i((p,b)=>(0,c.jsxs)("li",{"aria-selected":b===r.active,className:ue("flex cursor-pointer items-center gap-2 px-2 py-1 text-[13px]",b===r.active?"bg-accent text-accent-foreground":"text-foreground"),"data-testid":"sql-autocomplete-item",id:`${t}-opt-${b.toString()}`,onMouseDown:i(v=>{v.preventDefault(),n(b)},"onMouseDown"),role:"option",children:[(0,c.jsx)("span",{className:"truncate font-mono",children:p.label}),p.detail!==void 0&&(0,c.jsx)("span",{className:"ms-auto truncate text-xs text-muted-foreground",children:p.detail}),(0,c.jsx)("span",{className:"shrink-0 font-mono text-[10px] tracking-wide text-muted-foreground/70 uppercase",children:o(nn[p.kind])})]},`${p.kind}:${p.label}`),"f"),e[8]=t,e[9]=n,e[10]=r.active,e[11]=o,e[12]=f):f=e[12],a=r.suggestions.map(f),e[2]=t,e[3]=n,e[4]=r.active,e[5]=r.suggestions,e[6]=o,e[7]=a}else a=e[7];let d;return e[13]!==t||e[14]!==m||e[15]!==a?(d=(0,c.jsx)("ul",{className:"absolute z-30 max-h-56 w-72 overflow-auto rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-autocomplete",id:t,role:"listbox",style:m,children:a}),e[13]=t,e[14]=m,e[15]=a,e[16]=d):d=e[16],d},"sn"),ln=ve(we.listTables),sn=ve(we.readTablePage),an=i(l=>{let e=(0,K.c)(16),t=ke(),n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],e[0]=n):n=e[0];let[r,o]=(0,P.useState)(n),s;e[1]===Symbol.for("react.memo_cache_sentinel")?(s={},e[1]=s):s=e[1];let[m,a]=(0,P.useState)(s),d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=new Set,e[2]=d):d=e[2];let f=(0,P.useRef)(d),p,b;e[3]!==t||e[4]!==l?(p=i(()=>{let g={cancelled:!1};return ie((async()=>{try{let h=await t.query(ln,{},ye(l));g.cancelled||(o(h.map(dn)),a({}),f.current=new Set)}catch{g.cancelled||(o([]),a({}),f.current=new Set)}})()),()=>{g.cancelled=!0}},"h"),b=[t,l],e[3]=t,e[4]=l,e[5]=p,e[6]=b):(p=e[5],b=e[6]),(0,P.useEffect)(p,b);let v;e[7]!==t||e[8]!==l?(v=i(g=>{f.current.has(g)||(f.current.add(g),ie((async()=>{try{let h=await t.query(sn,{limit:1,offset:0,table:g},ye(l));a(S=>({...S,[g]:h.columns}))}catch{f.current.delete(g)}})()))},"x"),e[7]=t,e[8]=l,e[9]=v):v=e[9];let u=v,x;e[10]!==m||e[11]!==r?(x={columns:m,tables:r},e[10]=m,e[11]=r,e[12]=x):x=e[12];let y=x,w;return e[13]!==u||e[14]!==y?(w={probe:u,schema:y},e[13]=u,e[14]=y,e[15]=w):w=e[15],w},"dn"),Ae=/\b(?:from|join|update|into)\s+([a-z_][\w$]*)|\b([a-z_][\w$]*)\s*\./gi,cn=i(l=>{let e=new Set;Ae.lastIndex=0;let t=Ae.exec(l);for(;t!==null;)e.add(t[1]??t[2]),t=Ae.exec(l);return[...e]},"un");function dn(l){return l.name}i(dn,"mn");var un=i(l=>{let e=(0,K.c)(34),{onSubmit:t,probe:n,schema:r,setDraft:o}=l,s=(0,P.useId)(),m=(0,P.useRef)(null),a=(0,P.useRef)(null),d=(0,P.useRef)(null),f=tn(r,d,o),{close:p,commit:b,commitAt:v,move:u,refresh:x,state:y}=f,w;e[0]!==v?(w=i(I=>{v(I)},"y"),e[0]=v,e[1]=w):w=e[1];let g=w,h;e[2]!==x?(h=i(()=>{let I=d.current;I!==null&&I===document.activeElement&&x(I.value,I.selectionStart)},"m"),e[2]=x,e[3]=h):h=e[3];let S;e[4]!==x||e[5]!==r?(S=[x,r],e[4]=x,e[5]=r,e[6]=S):S=e[6],(0,P.useEffect)(h,S);let k;e[7]!==n||e[8]!==x||e[9]!==o?(k=i(I=>{let{selectionStart:B,value:W}=I.target;o(W);for(let Q of cn(W))n(Q);x(W,B)},"N"),e[7]=n,e[8]=x,e[9]=o,e[10]=k):k=e[10];let N=k,C;e[11]!==x?(C=i(I=>{let B=I.currentTarget;x(B.value,B.selectionStart)},"k"),e[11]=x,e[12]=C):C=e[12];let L=C,R;e[13]!==y||e[14]!==p||e[15]!==b||e[16]!==u||e[17]!==t?(R=i(I=>{if(y!==null){if(I.key==="ArrowDown"){I.preventDefault(),u(1);return}if(I.key==="ArrowUp"){I.preventDefault(),u(-1);return}if(I.key==="Escape"){I.preventDefault(),p();return}if((I.key==="Enter"||I.key==="Tab")&&!I.metaKey&&!I.ctrlKey&&b()){I.preventDefault();return}}(I.metaKey||I.ctrlKey)&&I.key==="Enter"&&(I.preventDefault(),t())},"T"),e[13]=y,e[14]=p,e[15]=b,e[16]=u,e[17]=t,e[18]=R):R=e[18];let E=R,q;e[19]!==p?(q=i(()=>{requestAnimationFrame(()=>{p()})},"C"),e[19]=p,e[20]=q):q=e[20];let O=q,M;e[21]===Symbol.for("react.memo_cache_sentinel")?(M=i(I=>{let{scrollLeft:B,scrollTop:W}=I.currentTarget;m.current!==null&&(m.current.scrollTop=W),a.current!==null&&(a.current.scrollTop=W,a.current.scrollLeft=B)},"_"),e[21]=M):M=e[21];let D=M,T;e[22]===Symbol.for("react.memo_cache_sentinel")?(T=i(I=>{let B=d.current;B===null||I.offset===void 0||(B.focus(),B.setSelectionRange(I.offset,I.offset+(I.length??0)))},"$"),e[22]=T):T=e[22];let _=T,A;e[23]!==N||e[24]!==O||e[25]!==E||e[26]!==L?(A={onBlur:O,onChange:N,onKeyDown:E,onScroll:D,onSelect:L},e[23]=N,e[24]=O,e[25]=E,e[26]=L,e[27]=A):A=e[27];let $;return e[28]!==y||e[29]!==p||e[30]!==s||e[31]!==g||e[32]!==A?($={autocompleteState:y,closeAutocomplete:p,handlers:A,listboxId:s,onPickSuggestion:g,editorRef:d,gutterRef:m,overlayRef:a,revealDiagnostic:_},e[28]=y,e[29]=p,e[30]=s,e[31]=g,e[32]=A,e[33]=$):$=e[33],$},"fn"),mn="lunora-studio-sql-tabs",hn="lunora-studio-sql-active-tab",Be=12,Se=i((l="",e="")=>({activeId:null,id:Me("tab"),name:e,sql:l}),"ve"),fn=i(()=>Oe(hn,""),"bn"),pn=i(l=>{let e=(0,K.c)(16),[t,n]=Ce(mn),[r,o]=fn(),[s]=(0,P.useState)(l),m,a;e[0]!==s||e[1]!==n||e[2]!==t.length?(m=i(()=>{t.length===0&&n([s])},"d"),a=[s,n,t.length],e[0]=s,e[1]=n,e[2]=t.length,e[3]=m,e[4]=a):(m=e[3],a=e[4]),(0,P.useEffect)(m,a);let d;e[5]!==s||e[6]!==t?(d=t.length===0?[s]:t,e[5]=s,e[6]=t,e[7]=d):d=e[7];let f=d,p;e[8]!==r||e[9]!==f?(p=f.some(u=>u.id===r)?r:f[0]?.id??"",e[8]=r,e[9]=f,e[10]=p):p=e[10];let b=p,v;return e[11]!==b||e[12]!==o||e[13]!==n||e[14]!==f?(v={activeId:b,setActiveId:o,setTabs:n,tabs:f},e[11]=b,e[12]=o,e[13]=n,e[14]=f,e[15]=v):v=e[15],v},"gn"),at=i(l=>l.activeId===null&&l.sql.trim()!=="","Ge"),bn=i((l,e)=>[...l,e].slice(-Be),"xn"),gn=i((l,e,t)=>{let n=l.findIndex(o=>o.id===e);if(n===-1)return{activeId:l[0]?.id??"",tabs:[...l]};let r=l.filter(o=>o.id!==e);if(r.length===0){let o=t();return{activeId:o.id,tabs:[o]}}return{activeId:r[Math.min(n,r.length-1)].id,tabs:r}},"vn"),xn=i((l,e)=>{let t=l.filter(n=>n.id===e);return t.length===0?{activeId:l[0]?.id??"",tabs:[...l]}:{activeId:e,tabs:t}},"yn"),vn=i((l,e,t)=>{let n=l.findIndex(o=>o.id===e);if(n===-1)return{activeId:t,tabs:[...l]};let r=l.slice(0,n+1);return{activeId:r.some(o=>o.id===t)?t:e,tabs:r}},"wn"),yn=i(l=>{let e=l();return{activeId:e.id,tabs:[e]}},"Sn"),wn=i((l,e,t)=>{if(l==="others")return e.filter(n=>n.id!==t);if(l==="right"){let n=e.findIndex(r=>r.id===t);return n===-1?[]:e.slice(n+1)}return[...e]},"Nn"),nt={error:null,pane:"results",result:null,running:!1},Sn=i(l=>{let e=(0,K.c)(66),{activeId:t,setActiveId:n,setTabs:r,tabs:o}=pn(l),s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},e[0]=s):s=e[0];let[m,a]=(0,P.useState)(s),[d,f]=(0,P.useState)(null),[p,b]=(0,P.useState)(null),v;e[1]!==t||e[2]!==o?(v=o.find(F=>F.id===t)??o[0]??Se(),e[1]=t,e[2]=o,e[3]=v):v=e[3];let u=v,x=m[u.id]??nt,y;e[4]!==u.id||e[5]!==r?(y=i(F=>{r(j=>j.map(U=>U.id===u.id?{...U,...F}:U))},"v"),e[4]=u.id,e[5]=r,e[6]=y):y=e[6];let w=y,g;e[7]!==u.id?(g=i(F=>{a(j=>{let U=j[u.id]??nt;return{...j,[u.id]:{...U,...F}}})},"b"),e[7]=u.id,e[8]=g):g=e[8];let h=g,S;e[9]!==n||e[10]!==r||e[11]!==o.length?(S=i(()=>{if(o.length>=Be)return;let F=Se();r(j=>bn(j,F)),n(F.id)},"w"),e[9]=n,e[10]=r,e[11]=o.length,e[12]=S):S=e[12];let k=S,N;e[13]!==n||e[14]!==r?(N=i(F=>{f(null),b(null),r(F.tabs),n(F.activeId);let j=new Set(F.tabs.map(Nn));a(U=>Object.fromEntries(Object.entries(U).filter(ae=>{let[xe]=ae;return j.has(xe)})))},"S"),e[13]=n,e[14]=r,e[15]=N):N=e[15];let C=N,L;e[16]!==C||e[17]!==o?(L=i(F=>{C(gn(o,F,Se))},"R"),e[16]=C,e[17]=o,e[18]=L):L=e[18];let R=L,E;e[19]!==t||e[20]!==C||e[21]!==o?(E=i((F,j)=>{C(F==="others"?xn(o,j):F==="right"?vn(o,j,t):yn(Se))},"I"),e[19]=t,e[20]=C,e[21]=o,e[22]=E):E=e[22];let q=E,O;e[23]!==q||e[24]!==d||e[25]!==o?(O=i(F=>{d!==null&&(wn(F,o,d.id).some(kn)?b(F):q(F,d.id))},"L"),e[23]=q,e[24]=d,e[25]=o,e[26]=O):O=e[26];let M=O,D;e[27]===Symbol.for("react.memo_cache_sentinel")?(D=i((F,j)=>{j.preventDefault(),b(null),f({id:F,x:j.clientX,y:j.clientY})},"O"),e[27]=D):D=e[27];let T=D,_;e[28]===Symbol.for("react.memo_cache_sentinel")?(_=i(()=>{f(null),b(null)},"E"),e[28]=_):_=e[28];let A=_,$;e[29]===Symbol.for("react.memo_cache_sentinel")?($=i(F=>{F.preventDefault(),f(null),b(null)},"D"),e[29]=$):$=e[29];let I=$,B;e[30]!==M?(B=i(()=>{M("others")},"B"),e[30]=M,e[31]=B):B=e[31];let W=B,Q;e[32]!==M?(Q=i(()=>{M("right")},"P"),e[32]=M,e[33]=Q):Q=e[33];let Y=Q,H;e[34]!==M?(H=i(()=>{M("all")},"Q"),e[34]=M,e[35]=H):H=e[35];let G=H,J;e[36]!==q||e[37]!==p||e[38]!==d?(J=i(()=>{d!==null&&p!==null&&q(p,d.id),b(null)},"J"),e[36]=q,e[37]=p,e[38]=d,e[39]=J):J=e[39];let z=J,V;e[40]===Symbol.for("react.memo_cache_sentinel")?(V=i(()=>{b(null)},"G"),e[40]=V):V=e[40];let re=V,X;e[41]!==d?(X=d===null?void 0:{left:d.x,top:d.y},e[41]=d,e[42]=X):X=e[42];let Z=X,ee;e[43]!==r?(ee=i(F=>{r(j=>j.map(U=>U.activeId===F?{...U,activeId:null}:U))},"Z"),e[43]=r,e[44]=ee):ee=e[44];let te=ee,ne;e[45]!==r?(ne=i((F,j)=>{r(U=>U.map(ae=>ae.id===F?{...ae,name:j}:ae))},"te"),e[45]=r,e[46]=ne):ne=e[46];let le=ne,ce;return e[47]!==u||e[48]!==t||e[49]!==k||e[50]!==R||e[51]!==z||e[52]!==G||e[53]!==W||e[54]!==Y||e[55]!==x||e[56]!==h||e[57]!==w||e[58]!==p||e[59]!==le||e[60]!==n||e[61]!==d||e[62]!==Z||e[63]!==o||e[64]!==te?(ce={activeTab:u,activeTabId:t,addEditorTab:k,cancelBulk:re,closeEditorTab:R,closeTabMenu:A,confirmBulk:z,menuStyle:Z,onBackdropContextMenu:I,onCloseAll:G,onCloseOthers:W,onCloseToRight:Y,openTabMenu:T,output:x,patchActiveOutput:h,patchActiveTab:w,pendingBulk:p,renameTab:le,setActiveTabId:n,tabMenu:d,tabs:o,unlinkQuery:te},e[47]=u,e[48]=t,e[49]=k,e[50]=R,e[51]=z,e[52]=G,e[53]=W,e[54]=Y,e[55]=x,e[56]=h,e[57]=w,e[58]=p,e[59]=le,e[60]=n,e[61]=d,e[62]=Z,e[63]=o,e[64]=te,e[65]=ce):ce=e[65],ce},"kn");function Nn(l){return l.id}i(Nn,"Cn");function kn(l){return at(l)}i(kn,"$n");var Cn="lunora-studio-sql-queries",qn="lunora-studio-sql-history",Tn=25,In=i(l=>{let e=(0,K.c)(33),{loadIntoActiveTab:t,unlinkQuery:n}=l,r=oe(),[o,s]=Ce(Cn),[m,a]=Ce(qn),[d,f]=(0,P.useState)(""),p=(0,P.useRef)(null),b;e[0]!==a?(b=i(T=>{a(_=>_[0]?.sql===T?_:[{at:Date.now(),sql:T},..._.filter(A=>A.sql!==T)].slice(0,Tn))},"p"),e[0]=a,e[1]=b):b=e[1];let v=b,u;e[2]!==t||e[3]!==s||e[4]!==r?(u=i(()=>{let T={id:Me("q"),name:r("Untitled query"),sql:""};s(_=>[T,..._]),t("",T.id)},"c"),e[2]=t,e[3]=s,e[4]=r,e[5]=u):u=e[5];let x=u,y;e[6]!==t||e[7]!==o?(y=i(T=>{let _=o.find(A=>A.id===T);_!==void 0&&(t(_.sql,T),p.current?.querySelector(`[data-testid="sql-query-${T}"]`)?.scrollIntoView({block:"nearest"}))},"v"),e[6]=t,e[7]=o,e[8]=y):y=e[8];let w=y,g;e[9]!==s||e[10]!==n?(g=i(T=>{s(_=>_.filter(A=>A.id!==T)),n(T)},"b"),e[9]=s,e[10]=n,e[11]=g):g=e[11];let h=g,S;e[12]!==t?(S=i(T=>{t(T.currentTarget.dataset.sql??"",null)},"w"),e[12]=t,e[13]=S):S=e[13];let k=S,N;e[14]!==t?(N=i(T=>{t(T.currentTarget.dataset.sql??"",null)},"S"),e[14]=t,e[15]=N):N=e[15];let C=N,L;e[16]!==a?(L=i(()=>{a([])},"R"),e[16]=a,e[17]=L):L=e[17];let R=L,E;e[18]===Symbol.for("react.memo_cache_sentinel")?(E=i(T=>{f(T.target.value)},"I"),e[18]=E):E=e[18];let q=E,O;e[19]!==s?(O=i((T,_)=>{s(A=>A.map($=>$.id===T?{...$,sql:_}:$))},"L"),e[19]=s,e[20]=O):O=e[20];let M=O,D;return e[21]!==R||e[22]!==h||e[23]!==m||e[24]!==C||e[25]!==k||e[26]!==x||e[27]!==o||e[28]!==v||e[29]!==d||e[30]!==w||e[31]!==M?(D={clearHistory:R,deleteQuery:h,history:m,listRef:p,loadFromHistory:C,loadTemplate:k,newQuery:x,onSearchChange:q,queries:o,recordHistory:v,search:d,selectQuery:w,updateQuerySql:M},e[21]=R,e[22]=h,e[23]=m,e[24]=C,e[25]=k,e[26]=x,e[27]=o,e[28]=v,e[29]=d,e[30]=w,e[31]=M,e[32]=D):D=e[32],D},"In"),it="p-3 font-mono text-xs leading-5 whitespace-pre-wrap break-words",Rn=i((l,e)=>{let t=[];for(let r of l){if(r.offset===void 0||r.length===void 0||r.length<=0)continue;let o=Math.max(0,Math.min(r.offset,e)),s=Math.max(o,Math.min(r.offset+r.length,e));o!==s&&t.push({end:s,severity:r.severity,start:o})}t.sort((r,o)=>r.start-o.start);let n=[];for(let r of t)r.start>=(n.at(-1)?.end??0)&&n.push(r);return n},"En"),Ln=i(l=>l==="unsafe-response"?"The model returned a statement that is not read-only, so it was discarded.":l==="empty-response"?"The model returned nothing usable.":"The model could not be reached.","Ln"),En=i(l=>{let e=(0,K.c)(51),{assistant:t,failed:n,onGenerated:r}=l,o=oe(),[s,m]=(0,P.useState)("");if(t.unavailable)return null;let a;e[0]!==t?(a=t.pending("sql"),e[0]=t,e[1]=a):a=e[1];let d=a,f;if(e[2]!==t||e[3]!==n||e[4]!==r||e[5]!==d||e[6]!==s||e[7]!==o){let p=t.reason("sql"),b;e[9]!==t||e[10]!==n||e[11]!==r||e[12]!==s?(b=i(q=>{let O=s.trim();O===""&&!q||ie((async()=>{let M=await t.generate(O===""?"fix the failing statement":O,q?n:void 0);M!==void 0&&r(M)})())},"p"),e[9]=t,e[10]=n,e[11]=r,e[12]=s,e[13]=b):b=e[13];let v=b,u;e[14]!==o?(u=o("Describe the query you want"),e[14]=o,e[15]=u):u=e[15];let x;e[16]===Symbol.for("react.memo_cache_sentinel")?(x=i(q=>{m(q.target.value)},"g"),e[16]=x):x=e[16];let y;e[17]!==v?(y=i(q=>{q.key==="Enter"&&(q.preventDefault(),v(!1))},"v"),e[17]=v,e[18]=y):y=e[18];let w;e[19]!==o?(w=o("Describe the query you want"),e[19]=o,e[20]=w):w=e[20];let g;e[21]!==d||e[22]!==s||e[23]!==u||e[24]!==y||e[25]!==w?(g=(0,c.jsx)(Fe,{"aria-label":u,className:"h-7 flex-1 text-xs","data-testid":"sql-assistant-prompt",disabled:d,onChange:x,onKeyDown:y,placeholder:w,value:s}),e[21]=d,e[22]=s,e[23]=u,e[24]=y,e[25]=w,e[26]=g):g=e[26];let h=d&&"opacity-60",S;e[27]!==h?(S=ue("rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",h),e[27]=h,e[28]=S):S=e[28];let k;e[29]!==d||e[30]!==s?(k=d||s.trim()==="",e[29]=d,e[30]=s,e[31]=k):k=e[31];let N;e[32]!==v?(N=i(()=>{v(!1)},"S"),e[32]=v,e[33]=N):N=e[33];let C;e[34]!==d||e[35]!==o?(C=o(d?"Thinking\u2026":"Draft SQL"),e[34]=d,e[35]=o,e[36]=C):C=e[36];let L;e[37]!==S||e[38]!==k||e[39]!==N||e[40]!==C?(L=(0,c.jsx)("button",{className:S,"data-testid":"sql-assistant-generate",disabled:k,onClick:N,type:"button",children:C}),e[37]=S,e[38]=k,e[39]=N,e[40]=C,e[41]=L):L=e[41];let R;e[42]!==n||e[43]!==d||e[44]!==v||e[45]!==o?(R=n!==void 0&&(0,c.jsx)("button",{className:"rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-assistant-fix",disabled:d,onClick:i(()=>{v(!0)},"onClick"),type:"button",children:o("Fix this")}),e[42]=n,e[43]=d,e[44]=v,e[45]=o,e[46]=R):R=e[46];let E;e[47]!==L||e[48]!==R||e[49]!==g?(E=(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[g,L,R]}),e[47]=L,e[48]=R,e[49]=g,e[50]=E):E=e[50],f=(0,c.jsxs)("div",{className:"flex flex-col gap-1 border-b border-border px-3 py-2","data-testid":"sql-assistant",children:[E,p!==void 0&&(0,c.jsx)("p",{className:"text-[11px] text-muted-foreground","data-testid":"sql-assistant-reason",role:"status",children:Ln(p)})]}),e[2]=t,e[3]=n,e[4]=r,e[5]=d,e[6]=s,e[7]=o,e[8]=f}else f=e[8];return f},"_n"),_n=i(l=>{let e=(0,K.c)(8),{diagnostics:t,draft:n,scrollRef:r}=l,o,s;if(e[0]!==t||e[1]!==n){s=Symbol.for("react.early_return_sentinel");e:{let d=Rn(t,n.length);if(d.length===0){s=null;break e}o=[];let f=0;for(let[p,b]of d.entries())b.start>f&&o.push(n.slice(f,b.start)),o.push((0,c.jsx)("span",{className:ue("decoration-wavy underline underline-offset-4",b.severity==="error"?"decoration-destructive":"decoration-amber-500"),children:n.slice(b.start,b.end)},`${b.start.toString()}-${p.toString()}`)),f=b.end;o.push(n.slice(f))}e[0]=t,e[1]=n,e[2]=o,e[3]=s}else o=e[2],s=e[3];if(s!==Symbol.for("react.early_return_sentinel"))return s;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=ue("pointer-events-none absolute inset-0 overflow-hidden text-transparent",it),e[4]=m):m=e[4];let a;return e[5]!==o||e[6]!==r?(a=(0,c.jsx)("div",{"aria-hidden":"true",className:m,"data-testid":"sql-diagnostics-overlay",ref:r,children:o}),e[5]=o,e[6]=r,e[7]=a):a=e[7],a},"On"),On={gate:"read-only",plan:"plan",schema:"schema",syntax:"syntax"},Mn=i(l=>{let e=(0,K.c)(10),{diagnostics:t,onSelect:n}=l,r=oe();if(t.length===0)return null;let o;e[0]!==r?(o=r("SQL problems"),e[0]=r,e[1]=o):o=e[1];let s;if(e[2]!==t||e[3]!==n){let a;e[5]!==n?(a=i((d,f)=>(0,c.jsx)("li",{children:(0,c.jsxs)("button",{className:"flex w-full items-start gap-2 px-3 py-1 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-problem",onClick:i(()=>{n(d)},"onClick"),type:"button",children:[(0,c.jsx)("span",{className:ue("mt-px shrink-0 rounded px-1 font-mono text-[10px] uppercase",d.severity==="error"?"bg-destructive/15 text-destructive":"bg-amber-500/15 text-amber-600"),children:On[d.source]}),(0,c.jsx)("span",{className:"min-w-0 text-muted-foreground",children:d.message})]})},`${d.source}-${(d.offset??f).toString()}-${f.toString()}`),"a"),e[5]=n,e[6]=a):a=e[6],s=t.map(a),e[2]=t,e[3]=n,e[4]=s}else s=e[4];let m;return e[7]!==o||e[8]!==s?(m=(0,c.jsx)("ul",{"aria-label":o,className:"max-h-24 shrink-0 overflow-y-auto border-t border-border bg-muted/30","data-testid":"sql-problems",children:s}),e[7]=o,e[8]=s,e[9]=m):m=e[9],m},"Dn"),Dn={minWidth:"2.75rem",paddingInline:"0.5rem"},An=i(l=>{let e=(0,K.c)(64),{assistant:t,autocomplete:n,diagnostics:r,draft:o,failed:s,handlers:m,editorRef:a,gutterRef:d,listboxId:f,onGenerated:p,onPickSuggestion:b,onRevealDiagnostic:v,overlayRef:u}=l,x=oe(),y,w,g,h,S,k,N,C;if(e[0]!==t||e[1]!==o||e[2]!==s||e[3]!==d||e[4]!==p){let B=o.split(`
@@ -1 +1 @@
1
- import{a as de}from"./chunk-ATLV7KWK.js";import"./chunk-OQIGV6FX.js";import"./chunk-4UOFSGUS.js";import"./chunk-CZZWYUTR.js";import{d as Y,f as ee}from"./chunk-7T7UOTYK.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{c as T}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{a as te}from"./chunk-XXQUMVWH.js";import{a as X}from"./chunk-VDW32UET.js";import{f as F}from"./chunk-C2ZFQARQ.js";import"./chunk-XBDKZZ67.js";import{a as H}from"./chunk-XQCVZAGU.js";import{a as Q,b as U,c as D,e as V}from"./chunk-WQH3LT2P.js";import{d as A,f as Z,g as G,h as J,o as P}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as k,e as O,f as ae,g as le,h as se}from"./chunk-3XIESWL4.js";var W=O(le(),1),I=O(ae(),1);var s=O(se(),1);var re=Z(X.runSql),ie=k((_,e)=>{let t=(0,W.c)(11),m=F(),[d,a]=(0,I.useState)(void 0),[r,l]=(0,I.useState)(void 0),[o,E]=(0,I.useState)(!0),c;t[0]!==m||t[1]!==e||t[2]!==_?(c=k(async u=>{E(!0);try{let N=await m.query(re,{sql:_},G(e));u.cancelled||(a(N),l(void 0))}catch(N){let $=N;u.cancelled||(a(void 0),l(J($)))}u.cancelled||E(!1)},"n"),t[0]=m,t[1]=e,t[2]=_,t[3]=c):c=t[3];let C=c,y,K;t[4]!==C?(y=k(()=>{let u={cancelled:!1};return P(C(u)),()=>{u.cancelled=!0}},"y"),K=[C],t[4]=C,t[5]=y,t[6]=K):(y=t[5],K=t[6]),(0,I.useEffect)(y,K);let h;return t[7]!==r||t[8]!==o||t[9]!==d?(h={error:r,loading:o,result:d},t[7]=r,t[8]=o,t[9]=d,t[10]=h):h=t[10],h},"re"),oe="lunora-studio-dashboards",B={shardKey:"",sql:"",title:""},ne=k(_=>{let e=(0,W.c)(54),{onEdit:t,onRemove:m,widget:d}=_,a=A(),{error:r,loading:l,result:o}=ie(d.sql,d.shardKey??""),E;e[0]!==t||e[1]!==d.id?(E=k(()=>{t(d.id)},"$"),e[0]=t,e[1]=d.id,e[2]=E):E=e[2];let c=E,C;e[3]!==m||e[4]!==d.id?(C=k(()=>{m(d.id)},"k"),e[3]=m,e[4]=d.id,e[5]=C):C=e[5];let y=C,K=`dashboards-widget-${d.id}`,h;e[6]!==d.title?(h=(0,s.jsx)(D,{className:"min-w-0 truncate",title:d.title,children:d.title}),e[6]=d.title,e[7]=h):h=e[7];let u;e[8]!==a?(u=a("Edit widget"),e[8]=a,e[9]=u):u=e[9];let N=`dashboards-widget-edit-${d.id}`,$;e[10]!==a?($=a("Edit widget"),e[10]=a,e[11]=$):$=e[11];let L;e[12]===Symbol.for("react.memo_cache_sentinel")?(L=(0,s.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,s.jsx)("path",{d:"M4 20h4L18 10l-4-4L4 16v4ZM14 6l4 4"})}),e[12]=L):L=e[12];let S;e[13]!==c||e[14]!==u||e[15]!==N||e[16]!==$?(S=(0,s.jsx)(T,{"aria-label":u,"data-testid":N,onClick:c,size:"icon-xs",title:$,type:"button",variant:"ghost",children:L}),e[13]=c,e[14]=u,e[15]=N,e[16]=$,e[17]=S):S=e[17];let x;e[18]!==a?(x=a("Remove widget"),e[18]=a,e[19]=x):x=e[19];let j=`dashboards-widget-remove-${d.id}`,g;e[20]!==a?(g=a("Remove widget"),e[20]=a,e[21]=g):g=e[21];let w;e[22]===Symbol.for("react.memo_cache_sentinel")?(w=(0,s.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,s.jsx)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[22]=w):w=e[22];let b;e[23]!==y||e[24]!==x||e[25]!==j||e[26]!==g?(b=(0,s.jsx)(T,{"aria-label":x,"data-testid":j,onClick:y,size:"icon-xs",title:g,type:"button",variant:"ghost",children:w}),e[23]=y,e[24]=x,e[25]=j,e[26]=g,e[27]=b):b=e[27];let f;e[28]!==b||e[29]!==S?(f=(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[S,b]}),e[28]=b,e[29]=S,e[30]=f):f=e[30];let p;e[31]!==f||e[32]!==h?(p=(0,s.jsxs)(U,{className:"flex flex-row items-start justify-between gap-2 border-b pb-3",children:[h,f]}),e[31]=f,e[32]=h,e[33]=p):p=e[33];let v;e[34]!==r||e[35]!==d.id?(v=r!==void 0&&(0,s.jsx)(te,{className:"font-mono text-xs",testId:`dashboards-widget-error-${d.id}`,variant:"destructive",children:r}),e[34]=r,e[35]=d.id,e[36]=v):v=e[36];let R;e[37]!==r||e[38]!==l||e[39]!==o||e[40]!==a||e[41]!==d.id?(R=r===void 0&&l&&o===void 0&&(0,s.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":`dashboards-widget-loading-${d.id}`,children:a("Running\u2026")}),e[37]=r,e[38]=l,e[39]=o,e[40]=a,e[41]=d.id,e[42]=R):R=e[42];let i;e[43]!==r||e[44]!==o?(i=r===void 0&&o!==void 0&&(0,s.jsx)(de,{result:o}),e[43]=r,e[44]=o,e[45]=i):i=e[45];let n;e[46]!==v||e[47]!==R||e[48]!==i?(n=(0,s.jsxs)(V,{className:"min-h-32 py-2",children:[v,R,i]}),e[46]=v,e[47]=R,e[48]=i,e[49]=n):n=e[49];let q;return e[50]!==p||e[51]!==n||e[52]!==K?(q=(0,s.jsxs)(Q,{"data-testid":K,children:[p,n]}),e[50]=p,e[51]=n,e[52]=K,e[53]=q):q=e[53],q},"ie"),ce=k(_=>{let e=(0,W.c)(58),{draft:t,editing:m,onCancel:d,onChange:a,onSubmit:r}=_,l=A(),o;e[0]!==t||e[1]!==a?(o=k(z=>{a({...t,title:z.target.value})},"a"),e[0]=t,e[1]=a,e[2]=o):o=e[2];let E=o,c;e[3]!==t||e[4]!==a?(c=k(z=>{a({...t,sql:z.target.value})},"n"),e[3]=t,e[4]=a,e[5]=c):c=e[5];let C=c,y;e[6]!==t||e[7]!==a?(y=k(z=>{a({...t,shardKey:z.target.value})},"y"),e[6]=t,e[7]=a,e[8]=y):y=e[8];let K=y,h;e[9]!==r?(h=k(()=>{r()},"h"),e[9]=r,e[10]=h):h=e[10];let u=h,N;e[11]!==t.sql||e[12]!==t.title?(N=t.title.trim()!==""&&t.sql.trim()!=="",e[11]=t.sql,e[12]=t.title,e[13]=N):N=e[13];let $=N,L;e[14]!==l?(L=l("Widget title"),e[14]=l,e[15]=L):L=e[15];let S;e[16]!==l?(S=l("Widget title"),e[16]=l,e[17]=S):S=e[17];let x;e[18]!==t.title||e[19]!==E||e[20]!==L||e[21]!==S?(x=(0,s.jsx)("input",{"aria-label":L,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:E,placeholder:S,type:"text",value:t.title}),e[18]=t.title,e[19]=E,e[20]=L,e[21]=S,e[22]=x):x=e[22];let j;e[23]!==l?(j=l("SQL query"),e[23]=l,e[24]=j):j=e[24];let g;e[25]!==t.sql||e[26]!==C||e[27]!==j?(g=(0,s.jsx)("textarea",{"aria-label":j,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:C,placeholder:"SELECT author, COUNT(*) AS messages FROM \u2026",spellCheck:!1,value:t.sql}),e[25]=t.sql,e[26]=C,e[27]=j,e[28]=g):g=e[28];let w;e[29]!==l?(w=l("Shard key (optional)"),e[29]=l,e[30]=w):w=e[30];let b;e[31]!==l?(b=l("Shard key (optional)"),e[31]=l,e[32]=b):b=e[32];let f;e[33]!==t.shardKey||e[34]!==K||e[35]!==w||e[36]!==b?(f=(0,s.jsx)("input",{"aria-label":w,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:K,placeholder:b,type:"text",value:t.shardKey}),e[33]=t.shardKey,e[34]=K,e[35]=w,e[36]=b,e[37]=f):f=e[37];let p;e[38]!==l?(p=l("Cancel"),e[38]=l,e[39]=p):p=e[39];let v;e[40]!==d||e[41]!==p?(v=(0,s.jsx)(T,{"data-testid":"dashboards-form-cancel",onClick:d,size:"sm",type:"button",variant:"outline",children:p}),e[40]=d,e[41]=p,e[42]=v):v=e[42];let R=!$,i;e[43]!==m||e[44]!==l?(i=l(m?"Save widget":"Add widget"),e[43]=m,e[44]=l,e[45]=i):i=e[45];let n;e[46]!==u||e[47]!==R||e[48]!==i?(n=(0,s.jsx)(T,{"data-testid":"dashboards-form-save",disabled:R,onClick:u,size:"sm",type:"button",children:i}),e[46]=u,e[47]=R,e[48]=i,e[49]=n):n=e[49];let q;e[50]!==v||e[51]!==n?(q=(0,s.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[v,n]}),e[50]=v,e[51]=n,e[52]=q):q=e[52];let M;return e[53]!==g||e[54]!==f||e[55]!==q||e[56]!==x?(M=(0,s.jsx)(Q,{"data-testid":"dashboards-form",children:(0,s.jsxs)(V,{className:"flex flex-col gap-3 py-4",children:[x,g,f,q]})}),e[53]=g,e[54]=f,e[55]=q,e[56]=x,e[57]=M):M=e[57],M},"ae"),we=k(_=>{let e=(0,W.c)(39),{initialShardKey:t}=_,m=A(),[d,a]=Y(oe),[r,l]=(0,I.useState)(B),[o,E]=(0,I.useState)(null),[c,C]=(0,I.useState)(!1),y;e[0]!==t?(y=k(()=>{E(null),l({...B,shardKey:t??""}),C(!0)},"y"),e[0]=t,e[1]=y):y=e[1];let K=y,h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=k(()=>{C(!1),E(null),l(B)},"h"),e[2]=h):h=e[2];let u=h,N;e[3]!==d?(N=k(i=>{let n=d.find(q=>q.id===i);n!==void 0&&(E(i),l({shardKey:n.shardKey??"",sql:n.sql,title:n.title}),C(!0))},"C"),e[3]=d,e[4]=N):N=e[4];let $=N,L;e[5]!==a?(L=k(i=>{a(n=>n.filter(q=>q.id!==i))},"K"),e[5]=a,e[6]=L):L=e[6];let S=L,x;e[7]!==r.shardKey||e[8]!==r.sql||e[9]!==r.title||e[10]!==o||e[11]!==a?(x=k(()=>{let i=r.title.trim(),n=r.sql.trim();if(i===""||n==="")return;let q=r.shardKey.trim();a(o===null?M=>[...M,{id:ee("w"),shardKey:q,sql:n,title:i}]:M=>M.map(z=>z.id===o?{...z,shardKey:q,sql:n,title:i}:z)),u()},"x"),e[7]=r.shardKey,e[8]=r.sql,e[9]=r.title,e[10]=o,e[11]=a,e[12]=x):x=e[12];let j=x,g;e[13]!==m?(g=m("Chart widgets backed by saved read-only SQL queries."),e[13]=m,e[14]=g):g=e[14];let w;e[15]!==g?(w=(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:g}),e[15]=g,e[16]=w):w=e[16];let b;e[17]!==c||e[18]!==K||e[19]!==m?(b=!c&&(0,s.jsx)(T,{"data-testid":"dashboards-add",onClick:K,size:"sm",type:"button",children:m("Add widget")}),e[17]=c,e[18]=K,e[19]=m,e[20]=b):b=e[20];let f;e[21]!==w||e[22]!==b?(f=(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[w,b]}),e[21]=w,e[22]=b,e[23]=f):f=e[23];let p;e[24]!==r||e[25]!==o||e[26]!==c||e[27]!==j?(p=c&&(0,s.jsx)(ce,{draft:r,editing:o!==null,onCancel:u,onChange:l,onSubmit:j}),e[24]=r,e[25]=o,e[26]=c,e[27]=j,e[28]=p):p=e[28];let v;e[29]!==c||e[30]!==$||e[31]!==S||e[32]!==m||e[33]!==d?(v=d.length===0&&!c?(0,s.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,s.jsx)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3","data-testid":"dashboards-grid",children:d.map(i=>(0,s.jsx)(ne,{onEdit:$,onRemove:S,widget:i},i.id))}),e[29]=c,e[30]=$,e[31]=S,e[32]=m,e[33]=d,e[34]=v):v=e[34];let R;return e[35]!==p||e[36]!==v||e[37]!==f?(R=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-dashboards",children:[f,p,v]}),e[35]=p,e[36]=v,e[37]=f,e[38]=R):R=e[38],R},"we");export{we as default};
1
+ import{a as de}from"./chunk-ATLV7KWK.js";import"./chunk-OQIGV6FX.js";import"./chunk-4UOFSGUS.js";import"./chunk-CZZWYUTR.js";import{d as Y,f as ee}from"./chunk-7T7UOTYK.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{c as T}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{a as te}from"./chunk-XXQUMVWH.js";import{a as X}from"./chunk-VDW32UET.js";import{f as F}from"./chunk-6FQJRXVI.js";import"./chunk-XBDKZZ67.js";import{a as H}from"./chunk-XQCVZAGU.js";import{a as Q,b as U,c as D,e as V}from"./chunk-WQH3LT2P.js";import{d as A,f as Z,g as G,h as J,o as P}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as k,e as O,f as ae,g as le,h as se}from"./chunk-3XIESWL4.js";var W=O(le(),1),I=O(ae(),1);var s=O(se(),1);var re=Z(X.runSql),ie=k((_,e)=>{let t=(0,W.c)(11),m=F(),[d,a]=(0,I.useState)(void 0),[r,l]=(0,I.useState)(void 0),[o,E]=(0,I.useState)(!0),c;t[0]!==m||t[1]!==e||t[2]!==_?(c=k(async u=>{E(!0);try{let N=await m.query(re,{sql:_},G(e));u.cancelled||(a(N),l(void 0))}catch(N){let $=N;u.cancelled||(a(void 0),l(J($)))}u.cancelled||E(!1)},"n"),t[0]=m,t[1]=e,t[2]=_,t[3]=c):c=t[3];let C=c,y,K;t[4]!==C?(y=k(()=>{let u={cancelled:!1};return P(C(u)),()=>{u.cancelled=!0}},"y"),K=[C],t[4]=C,t[5]=y,t[6]=K):(y=t[5],K=t[6]),(0,I.useEffect)(y,K);let h;return t[7]!==r||t[8]!==o||t[9]!==d?(h={error:r,loading:o,result:d},t[7]=r,t[8]=o,t[9]=d,t[10]=h):h=t[10],h},"re"),oe="lunora-studio-dashboards",B={shardKey:"",sql:"",title:""},ne=k(_=>{let e=(0,W.c)(54),{onEdit:t,onRemove:m,widget:d}=_,a=A(),{error:r,loading:l,result:o}=ie(d.sql,d.shardKey??""),E;e[0]!==t||e[1]!==d.id?(E=k(()=>{t(d.id)},"$"),e[0]=t,e[1]=d.id,e[2]=E):E=e[2];let c=E,C;e[3]!==m||e[4]!==d.id?(C=k(()=>{m(d.id)},"k"),e[3]=m,e[4]=d.id,e[5]=C):C=e[5];let y=C,K=`dashboards-widget-${d.id}`,h;e[6]!==d.title?(h=(0,s.jsx)(D,{className:"min-w-0 truncate",title:d.title,children:d.title}),e[6]=d.title,e[7]=h):h=e[7];let u;e[8]!==a?(u=a("Edit widget"),e[8]=a,e[9]=u):u=e[9];let N=`dashboards-widget-edit-${d.id}`,$;e[10]!==a?($=a("Edit widget"),e[10]=a,e[11]=$):$=e[11];let L;e[12]===Symbol.for("react.memo_cache_sentinel")?(L=(0,s.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,s.jsx)("path",{d:"M4 20h4L18 10l-4-4L4 16v4ZM14 6l4 4"})}),e[12]=L):L=e[12];let S;e[13]!==c||e[14]!==u||e[15]!==N||e[16]!==$?(S=(0,s.jsx)(T,{"aria-label":u,"data-testid":N,onClick:c,size:"icon-xs",title:$,type:"button",variant:"ghost",children:L}),e[13]=c,e[14]=u,e[15]=N,e[16]=$,e[17]=S):S=e[17];let x;e[18]!==a?(x=a("Remove widget"),e[18]=a,e[19]=x):x=e[19];let j=`dashboards-widget-remove-${d.id}`,g;e[20]!==a?(g=a("Remove widget"),e[20]=a,e[21]=g):g=e[21];let w;e[22]===Symbol.for("react.memo_cache_sentinel")?(w=(0,s.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,s.jsx)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[22]=w):w=e[22];let b;e[23]!==y||e[24]!==x||e[25]!==j||e[26]!==g?(b=(0,s.jsx)(T,{"aria-label":x,"data-testid":j,onClick:y,size:"icon-xs",title:g,type:"button",variant:"ghost",children:w}),e[23]=y,e[24]=x,e[25]=j,e[26]=g,e[27]=b):b=e[27];let f;e[28]!==b||e[29]!==S?(f=(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[S,b]}),e[28]=b,e[29]=S,e[30]=f):f=e[30];let p;e[31]!==f||e[32]!==h?(p=(0,s.jsxs)(U,{className:"flex flex-row items-start justify-between gap-2 border-b pb-3",children:[h,f]}),e[31]=f,e[32]=h,e[33]=p):p=e[33];let v;e[34]!==r||e[35]!==d.id?(v=r!==void 0&&(0,s.jsx)(te,{className:"font-mono text-xs",testId:`dashboards-widget-error-${d.id}`,variant:"destructive",children:r}),e[34]=r,e[35]=d.id,e[36]=v):v=e[36];let R;e[37]!==r||e[38]!==l||e[39]!==o||e[40]!==a||e[41]!==d.id?(R=r===void 0&&l&&o===void 0&&(0,s.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":`dashboards-widget-loading-${d.id}`,children:a("Running\u2026")}),e[37]=r,e[38]=l,e[39]=o,e[40]=a,e[41]=d.id,e[42]=R):R=e[42];let i;e[43]!==r||e[44]!==o?(i=r===void 0&&o!==void 0&&(0,s.jsx)(de,{result:o}),e[43]=r,e[44]=o,e[45]=i):i=e[45];let n;e[46]!==v||e[47]!==R||e[48]!==i?(n=(0,s.jsxs)(V,{className:"min-h-32 py-2",children:[v,R,i]}),e[46]=v,e[47]=R,e[48]=i,e[49]=n):n=e[49];let q;return e[50]!==p||e[51]!==n||e[52]!==K?(q=(0,s.jsxs)(Q,{"data-testid":K,children:[p,n]}),e[50]=p,e[51]=n,e[52]=K,e[53]=q):q=e[53],q},"ie"),ce=k(_=>{let e=(0,W.c)(58),{draft:t,editing:m,onCancel:d,onChange:a,onSubmit:r}=_,l=A(),o;e[0]!==t||e[1]!==a?(o=k(z=>{a({...t,title:z.target.value})},"a"),e[0]=t,e[1]=a,e[2]=o):o=e[2];let E=o,c;e[3]!==t||e[4]!==a?(c=k(z=>{a({...t,sql:z.target.value})},"n"),e[3]=t,e[4]=a,e[5]=c):c=e[5];let C=c,y;e[6]!==t||e[7]!==a?(y=k(z=>{a({...t,shardKey:z.target.value})},"y"),e[6]=t,e[7]=a,e[8]=y):y=e[8];let K=y,h;e[9]!==r?(h=k(()=>{r()},"h"),e[9]=r,e[10]=h):h=e[10];let u=h,N;e[11]!==t.sql||e[12]!==t.title?(N=t.title.trim()!==""&&t.sql.trim()!=="",e[11]=t.sql,e[12]=t.title,e[13]=N):N=e[13];let $=N,L;e[14]!==l?(L=l("Widget title"),e[14]=l,e[15]=L):L=e[15];let S;e[16]!==l?(S=l("Widget title"),e[16]=l,e[17]=S):S=e[17];let x;e[18]!==t.title||e[19]!==E||e[20]!==L||e[21]!==S?(x=(0,s.jsx)("input",{"aria-label":L,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:E,placeholder:S,type:"text",value:t.title}),e[18]=t.title,e[19]=E,e[20]=L,e[21]=S,e[22]=x):x=e[22];let j;e[23]!==l?(j=l("SQL query"),e[23]=l,e[24]=j):j=e[24];let g;e[25]!==t.sql||e[26]!==C||e[27]!==j?(g=(0,s.jsx)("textarea",{"aria-label":j,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:C,placeholder:"SELECT author, COUNT(*) AS messages FROM \u2026",spellCheck:!1,value:t.sql}),e[25]=t.sql,e[26]=C,e[27]=j,e[28]=g):g=e[28];let w;e[29]!==l?(w=l("Shard key (optional)"),e[29]=l,e[30]=w):w=e[30];let b;e[31]!==l?(b=l("Shard key (optional)"),e[31]=l,e[32]=b):b=e[32];let f;e[33]!==t.shardKey||e[34]!==K||e[35]!==w||e[36]!==b?(f=(0,s.jsx)("input",{"aria-label":w,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:K,placeholder:b,type:"text",value:t.shardKey}),e[33]=t.shardKey,e[34]=K,e[35]=w,e[36]=b,e[37]=f):f=e[37];let p;e[38]!==l?(p=l("Cancel"),e[38]=l,e[39]=p):p=e[39];let v;e[40]!==d||e[41]!==p?(v=(0,s.jsx)(T,{"data-testid":"dashboards-form-cancel",onClick:d,size:"sm",type:"button",variant:"outline",children:p}),e[40]=d,e[41]=p,e[42]=v):v=e[42];let R=!$,i;e[43]!==m||e[44]!==l?(i=l(m?"Save widget":"Add widget"),e[43]=m,e[44]=l,e[45]=i):i=e[45];let n;e[46]!==u||e[47]!==R||e[48]!==i?(n=(0,s.jsx)(T,{"data-testid":"dashboards-form-save",disabled:R,onClick:u,size:"sm",type:"button",children:i}),e[46]=u,e[47]=R,e[48]=i,e[49]=n):n=e[49];let q;e[50]!==v||e[51]!==n?(q=(0,s.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[v,n]}),e[50]=v,e[51]=n,e[52]=q):q=e[52];let M;return e[53]!==g||e[54]!==f||e[55]!==q||e[56]!==x?(M=(0,s.jsx)(Q,{"data-testid":"dashboards-form",children:(0,s.jsxs)(V,{className:"flex flex-col gap-3 py-4",children:[x,g,f,q]})}),e[53]=g,e[54]=f,e[55]=q,e[56]=x,e[57]=M):M=e[57],M},"ae"),we=k(_=>{let e=(0,W.c)(39),{initialShardKey:t}=_,m=A(),[d,a]=Y(oe),[r,l]=(0,I.useState)(B),[o,E]=(0,I.useState)(null),[c,C]=(0,I.useState)(!1),y;e[0]!==t?(y=k(()=>{E(null),l({...B,shardKey:t??""}),C(!0)},"y"),e[0]=t,e[1]=y):y=e[1];let K=y,h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=k(()=>{C(!1),E(null),l(B)},"h"),e[2]=h):h=e[2];let u=h,N;e[3]!==d?(N=k(i=>{let n=d.find(q=>q.id===i);n!==void 0&&(E(i),l({shardKey:n.shardKey??"",sql:n.sql,title:n.title}),C(!0))},"C"),e[3]=d,e[4]=N):N=e[4];let $=N,L;e[5]!==a?(L=k(i=>{a(n=>n.filter(q=>q.id!==i))},"K"),e[5]=a,e[6]=L):L=e[6];let S=L,x;e[7]!==r.shardKey||e[8]!==r.sql||e[9]!==r.title||e[10]!==o||e[11]!==a?(x=k(()=>{let i=r.title.trim(),n=r.sql.trim();if(i===""||n==="")return;let q=r.shardKey.trim();a(o===null?M=>[...M,{id:ee("w"),shardKey:q,sql:n,title:i}]:M=>M.map(z=>z.id===o?{...z,shardKey:q,sql:n,title:i}:z)),u()},"x"),e[7]=r.shardKey,e[8]=r.sql,e[9]=r.title,e[10]=o,e[11]=a,e[12]=x):x=e[12];let j=x,g;e[13]!==m?(g=m("Chart widgets backed by saved read-only SQL queries."),e[13]=m,e[14]=g):g=e[14];let w;e[15]!==g?(w=(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:g}),e[15]=g,e[16]=w):w=e[16];let b;e[17]!==c||e[18]!==K||e[19]!==m?(b=!c&&(0,s.jsx)(T,{"data-testid":"dashboards-add",onClick:K,size:"sm",type:"button",children:m("Add widget")}),e[17]=c,e[18]=K,e[19]=m,e[20]=b):b=e[20];let f;e[21]!==w||e[22]!==b?(f=(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[w,b]}),e[21]=w,e[22]=b,e[23]=f):f=e[23];let p;e[24]!==r||e[25]!==o||e[26]!==c||e[27]!==j?(p=c&&(0,s.jsx)(ce,{draft:r,editing:o!==null,onCancel:u,onChange:l,onSubmit:j}),e[24]=r,e[25]=o,e[26]=c,e[27]=j,e[28]=p):p=e[28];let v;e[29]!==c||e[30]!==$||e[31]!==S||e[32]!==m||e[33]!==d?(v=d.length===0&&!c?(0,s.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,s.jsx)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3","data-testid":"dashboards-grid",children:d.map(i=>(0,s.jsx)(ne,{onEdit:$,onRemove:S,widget:i},i.id))}),e[29]=c,e[30]=$,e[31]=S,e[32]=m,e[33]=d,e[34]=v):v=e[34];let R;return e[35]!==p||e[36]!==v||e[37]!==f?(R=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-dashboards",children:[f,p,v]}),e[35]=p,e[36]=v,e[37]=f,e[38]=R):R=e[38],R},"we");export{we as default};
@@ -1,3 +1,3 @@
1
- import{a as nt}from"./chunk-SFDOII3B.js";import{e as Ee}from"./chunk-SMIESS7P.js";import{c as Ue}from"./chunk-FXCBF4XT.js";import{b as Fe}from"./chunk-THIXMMZD.js";import{a as D}from"./chunk-VDW32UET.js";import{c as ke}from"./chunk-6F7KP54M.js";import{f as We}from"./chunk-C2ZFQARQ.js";import{a as Ye}from"./chunk-XQCVZAGU.js";import{a as T,e as He}from"./chunk-WQH3LT2P.js";import{d as $,f as Qe,g as Xe,l as et,o as Se,p as tt,q as at}from"./chunk-IUYFXK4X.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,notifications:!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"),notifications:s("notifications"),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(`
1
+ import{a as nt}from"./chunk-SFDOII3B.js";import{e as Ee}from"./chunk-SMIESS7P.js";import{c as Ue}from"./chunk-FXCBF4XT.js";import{b as Fe}from"./chunk-THIXMMZD.js";import{a as D}from"./chunk-VDW32UET.js";import{c as ke}from"./chunk-HRRFUAP6.js";import{f as We}from"./chunk-6FQJRXVI.js";import{a as Ye}from"./chunk-XQCVZAGU.js";import{a as T,e as He}from"./chunk-WQH3LT2P.js";import{d as $,f as Qe,g as Xe,l as et,o as Se,p as tt,q as at}from"./chunk-IUYFXK4X.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,notifications:!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"),notifications:s("notifications"),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
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
3
  `)},"kt"),Mt=1500,It=m(()=>{let t=(0,S.c)(35),e=$(),s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=tt(),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)=>{at(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-7CWPU3LW.js")),Ze=m(t=>{if(t<1e3)return`${String(Math.round(t))}ms`;let e=t>=1e4?0:1;return`${(t/1e3).toFixed(e)}s`},"Ee"),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"),qe=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(qt).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},"Tt"),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},"jt"),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,q,V,W,E,R,K,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(Kt)),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 Ke=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]!==Ke||e[54]!==ye||e[55]!==ve?(R=(0,n.jsx)(qe,{delta:Ke,label:ye,trend:$e,value:ve}),e[52]=$e,e[53]=Ke,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?(K=(0,n.jsx)(qe,{delta:De,label:Ne,trend:je,value:_e}),e[61]=je,e[62]=De,e[63]=Ne,e[64]=_e,e[65]=K):K=e[65],M=qe,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?(q=a("Avg latency"),e[69]=a,e[70]=q):q=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]=q,e[31]=V,e[32]=W,e[33]=E,e[34]=R,e[35]=K,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],q=e[30],V=e[31],W=e[32],E=e[33],R=e[34],K=e[35],B=e[36],F=e[37],U=e[38],H=e[39];let J;e[71]!==M||e[72]!==O||e[73]!==q||e[74]!==V?(J=(0,n.jsx)(M,{footer:O,label:q,value:V}),e[71]=M,e[72]=O,e[73]=q,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=et(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)(qe,{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]!==K||e[91]!==J||e[92]!==Q?(X=(0,n.jsxs)("div",{className:W,"data-testid":E,children:[R,K,J,Q]}),e[87]=W,e[88]=E,e[89]=R,e[90]=K,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 qt(t,e){return e.calls-t.calls}m(qt,"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,"Rt");function Kt(t){return t.maxDurationMs}m(Kt,"qt");export{ft as a,Gt as b};