@lunora/studio 1.0.0-alpha.387 → 1.0.0-alpha.388

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 (102) hide show
  1. package/dist/packem_chunks/ai-knowledge.mjs +1 -1
  2. package/dist/standalone/{chunk-B2QIV4WC.js → chunk-23MMGFHI.js} +1 -1
  3. package/dist/standalone/{chunk-457LPY43.js → chunk-2CDROYSG.js} +1 -1
  4. package/dist/standalone/{chunk-OKZINWBB.js → chunk-2D4WBSDO.js} +1 -1
  5. package/dist/standalone/{chunk-KFPV6FAK.js → chunk-2M37OAK3.js} +1 -1
  6. package/dist/standalone/{chunk-ZLELD7AD.js → chunk-2YDK4MZM.js} +1 -1
  7. package/dist/standalone/chunk-2ZJJH4YN.js +33 -0
  8. package/dist/standalone/{chunk-UVBNLJ2Q.js → chunk-375GZTYC.js} +1 -1
  9. package/dist/standalone/{chunk-3Y4QC5Y3.js → chunk-3OVQC66W.js} +1 -1
  10. package/dist/standalone/{chunk-HFPX37U7.js → chunk-3WYPRZY3.js} +1 -1
  11. package/dist/standalone/{chunk-KSEWJNEY.js → chunk-3YCWRKSW.js} +1 -1
  12. package/dist/standalone/{chunk-VEEFAOKX.js → chunk-4MFQ4XEJ.js} +1 -1
  13. package/dist/standalone/{chunk-PUYNCASR.js → chunk-4YVCKOYF.js} +1 -1
  14. package/dist/standalone/{chunk-GFOHMAH3.js → chunk-5EIGSLIK.js} +1 -1
  15. package/dist/standalone/{chunk-PROLM3J5.js → chunk-5ZWJVXDN.js} +1 -1
  16. package/dist/standalone/{chunk-ODV4EB3C.js → chunk-6K4F727K.js} +1 -1
  17. package/dist/standalone/{chunk-J4JDBEID.js → chunk-7ASIMMZY.js} +1 -1
  18. package/dist/standalone/{chunk-QK4NIT57.js → chunk-ADS4BJ7K.js} +1 -1
  19. package/dist/standalone/{chunk-RAJO2KOX.js → chunk-APCHI5CD.js} +1 -1
  20. package/dist/standalone/{chunk-HSL3R24X.js → chunk-AQG5OGO4.js} +1 -1
  21. package/dist/standalone/{chunk-MMRSSV2C.js → chunk-ATBPQT7F.js} +1 -1
  22. package/dist/standalone/{chunk-V7EUTFAA.js → chunk-AXB32N5O.js} +1 -1
  23. package/dist/standalone/{chunk-TQVX4KLJ.js → chunk-AXDXIMCN.js} +1 -1
  24. package/dist/standalone/{chunk-UV6GPH2E.js → chunk-BHUWAGFN.js} +1 -1
  25. package/dist/standalone/{chunk-DUNKBNMY.js → chunk-BRPLE2Z6.js} +1 -1
  26. package/dist/standalone/{chunk-56MOCXLS.js → chunk-BU5VWXRR.js} +1 -1
  27. package/dist/standalone/{chunk-DG5IPCQV.js → chunk-BWBECJFT.js} +1 -1
  28. package/dist/standalone/{chunk-FFECJKHB.js → chunk-BWHVY6L6.js} +1 -1
  29. package/dist/standalone/{chunk-NVMQPIRS.js → chunk-CBTPJPCZ.js} +1 -1
  30. package/dist/standalone/{chunk-ILPLYMU4.js → chunk-CFQQHZYU.js} +1 -1
  31. package/dist/standalone/{chunk-RUAE5VGJ.js → chunk-CO6R6GCX.js} +1 -1
  32. package/dist/standalone/{chunk-U5YP7MSK.js → chunk-CP3LCFFM.js} +1 -1
  33. package/dist/standalone/{chunk-QAETUNZX.js → chunk-CQDENTSP.js} +1 -1
  34. package/dist/standalone/{chunk-D34KO2UK.js → chunk-CVJDEN5L.js} +1 -1
  35. package/dist/standalone/{chunk-SALLT4EA.js → chunk-CXXCVBMK.js} +1 -1
  36. package/dist/standalone/{chunk-2IZDKUFI.js → chunk-CY45AO5T.js} +1 -1
  37. package/dist/standalone/{chunk-DUX2Q5UM.js → chunk-DZV6YFWZ.js} +1 -1
  38. package/dist/standalone/{chunk-5AVK4OU3.js → chunk-EKXAE4PS.js} +1 -1
  39. package/dist/standalone/{chunk-3R6W72RH.js → chunk-ELPLRD4S.js} +1 -1
  40. package/dist/standalone/{chunk-5LJYJ5SF.js → chunk-EMZ7RPR3.js} +1 -1
  41. package/dist/standalone/{chunk-XY5UOZMD.js → chunk-ERUKFS3I.js} +1 -1
  42. package/dist/standalone/{chunk-S7NFUY75.js → chunk-EYSF4DHD.js} +1 -1
  43. package/dist/standalone/{chunk-UDBPUH63.js → chunk-EZMAQE3T.js} +1 -1
  44. package/dist/standalone/{chunk-4KVCH3A4.js → chunk-FKAOFBS3.js} +1 -1
  45. package/dist/standalone/{chunk-J6NDZCBQ.js → chunk-HCK62XWB.js} +1 -1
  46. package/dist/standalone/{chunk-CD2LQVUA.js → chunk-HJOXP6C3.js} +1 -1
  47. package/dist/standalone/{chunk-QS2BPA4D.js → chunk-HLBZ7OAO.js} +1 -1
  48. package/dist/standalone/{chunk-S3TDGFRE.js → chunk-HMMALUXM.js} +1 -1
  49. package/dist/standalone/{chunk-TWNPQQS7.js → chunk-HUL247LG.js} +1 -1
  50. package/dist/standalone/{chunk-XUS65GNY.js → chunk-I6YVDNKQ.js} +1 -1
  51. package/dist/standalone/chunk-IL64HWFW.js +1 -0
  52. package/dist/standalone/{chunk-THB7DCWF.js → chunk-IXCSVK2Z.js} +1 -1
  53. package/dist/standalone/{chunk-54X7HWI6.js → chunk-JQBVRWFN.js} +1 -1
  54. package/dist/standalone/{chunk-VXMAQB2K.js → chunk-JZN3MNJX.js} +1 -1
  55. package/dist/standalone/{chunk-RDYGUTWW.js → chunk-K2LXQ3LS.js} +1 -1
  56. package/dist/standalone/{chunk-SB54Y4G6.js → chunk-KGQPMSNY.js} +1 -1
  57. package/dist/standalone/{chunk-E5GKOI3R.js → chunk-KIQ34774.js} +1 -1
  58. package/dist/standalone/{chunk-EK74664L.js → chunk-KZXSJF7K.js} +1 -1
  59. package/dist/standalone/{chunk-O5VYYMWA.js → chunk-L6VJTINV.js} +1 -1
  60. package/dist/standalone/{chunk-6AOWASDA.js → chunk-L7TFQUD7.js} +1 -1
  61. package/dist/standalone/{chunk-MVRBX7HB.js → chunk-LLSK6QBX.js} +1 -1
  62. package/dist/standalone/{chunk-BWS7JUQV.js → chunk-LOEVTOKP.js} +1 -1
  63. package/dist/standalone/{chunk-KDMDI7KA.js → chunk-LRUYEVHH.js} +1 -1
  64. package/dist/standalone/{chunk-57F7KSWY.js → chunk-LYWT6GTX.js} +1 -1
  65. package/dist/standalone/{chunk-CJ2V577P.js → chunk-MNN3YCKF.js} +1 -1
  66. package/dist/standalone/{chunk-2LKJSQKF.js → chunk-NAGIOR23.js} +1 -1
  67. package/dist/standalone/{chunk-2L3WHXJV.js → chunk-NFI2TNKU.js} +1 -1
  68. package/dist/standalone/{chunk-M4TYLAUX.js → chunk-NP6CBOPK.js} +1 -1
  69. package/dist/standalone/{chunk-VOQK6ERC.js → chunk-NPKGC4AM.js} +1 -1
  70. package/dist/standalone/{chunk-G7KYDZGL.js → chunk-O66HDCZT.js} +1 -1
  71. package/dist/standalone/{chunk-OGIWPH2B.js → chunk-OJR7BDKC.js} +1 -1
  72. package/dist/standalone/{chunk-KPX6GS6G.js → chunk-OQTMT64P.js} +1 -1
  73. package/dist/standalone/{chunk-C2AMUDOR.js → chunk-OWCTA7GY.js} +1 -1
  74. package/dist/standalone/{chunk-7KNQ44FF.js → chunk-P3ML7HGE.js} +1 -1
  75. package/dist/standalone/{chunk-6GIVSDLA.js → chunk-PBXRUYD3.js} +1 -1
  76. package/dist/standalone/{chunk-QB75Q7U4.js → chunk-QFN62JQJ.js} +1 -1
  77. package/dist/standalone/{chunk-PVNVHQS5.js → chunk-QTWNCDLK.js} +1 -1
  78. package/dist/standalone/{chunk-FFNYPIIW.js → chunk-SGIEXE5J.js} +1 -1
  79. package/dist/standalone/{chunk-KW5PNET5.js → chunk-U5UEDY4E.js} +1 -1
  80. package/dist/standalone/{chunk-KAWNPEUA.js → chunk-U7NVTULW.js} +1 -1
  81. package/dist/standalone/{chunk-Q3U7OEDK.js → chunk-UFS6UP4Z.js} +1 -1
  82. package/dist/standalone/{chunk-SNJ3ZOV2.js → chunk-UL5XVKGR.js} +1 -1
  83. package/dist/standalone/{chunk-SRNRWSMY.js → chunk-V3DOKU22.js} +1 -1
  84. package/dist/standalone/{chunk-I2C3K4SJ.js → chunk-V4B7ZPEG.js} +1 -1
  85. package/dist/standalone/{chunk-THRRRMIZ.js → chunk-V5TGDG6U.js} +1 -1
  86. package/dist/standalone/{chunk-DPSTEE4D.js → chunk-VM2V5UUW.js} +1 -1
  87. package/dist/standalone/{chunk-4AGOKKRZ.js → chunk-VQQEDEHH.js} +1 -1
  88. package/dist/standalone/{chunk-DWNWEMQK.js → chunk-W5BTAOHO.js} +1 -1
  89. package/dist/standalone/{chunk-RBTRTSXY.js → chunk-WEPANQGT.js} +1 -1
  90. package/dist/standalone/{chunk-CDDK3RFD.js → chunk-WLUWQ24M.js} +1 -1
  91. package/dist/standalone/{chunk-76CCNRPQ.js → chunk-WXZ334CL.js} +1 -1
  92. package/dist/standalone/{chunk-TN4Z3P6S.js → chunk-XV2XEUUB.js} +1 -1
  93. package/dist/standalone/{chunk-K55BSHNZ.js → chunk-Y2AKO63C.js} +1 -1
  94. package/dist/standalone/{chunk-HB2FLDDU.js → chunk-Y5QMX4YG.js} +1 -1
  95. package/dist/standalone/{chunk-PAFHBQFL.js → chunk-YLC2ZYCL.js} +1 -1
  96. package/dist/standalone/{chunk-H5XMXLKP.js → chunk-ZADOHFZB.js} +1 -1
  97. package/dist/standalone/{chunk-J3ZEO3PJ.js → chunk-ZJIYJZ6F.js} +1 -1
  98. package/dist/standalone/{chunk-BADXUCOT.js → chunk-ZP453BM4.js} +1 -1
  99. package/dist/standalone/studio.js +1 -1
  100. package/package.json +1 -1
  101. package/dist/standalone/chunk-PN7JHEYW.js +0 -33
  102. package/dist/standalone/chunk-WLQL3I62.js +0 -1
@@ -1 +1 @@
1
- import{a as Re,b as Pe,c as qe}from"./chunk-THRRRMIZ.js";import{b as Ie,c as Te}from"./chunk-LJLNIVUA.js";import{a as Se}from"./chunk-SRNRWSMY.js";import"./chunk-QLZGKBOW.js";import{a as de}from"./chunk-R6NJ4ER6.js";import{a as Le}from"./chunk-W7CLOQOU.js";import{c as ke}from"./chunk-MHZNDDGI.js";import{a as Ce}from"./chunk-2LKJSQKF.js";import{a as ie}from"./chunk-DRHZZ7IN.js";import{a as be}from"./chunk-2KTN53PK.js";import{a as ve}from"./chunk-PAFHBQFL.js";import{b as fe}from"./chunk-EDL46BPM.js";import"./chunk-4KPATTV6.js";import"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import{i as D}from"./chunk-OKZINWBB.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as pe}from"./chunk-NVMQPIRS.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as J}from"./chunk-S3TDGFRE.js";import{b as ne}from"./chunk-UV6GPH2E.js";import"./chunk-L27FKJTG.js";import{a as xe}from"./chunk-VXMAQB2K.js";import"./chunk-S7NFUY75.js";import{a as ye,b as we,c as Ne,d as se,e as j,f as B}from"./chunk-J3ZEO3PJ.js";import"./chunk-3R6W72RH.js";import"./chunk-2L3WHXJV.js";import"./chunk-EOFWXI3T.js";import{a as oe}from"./chunk-LYVYUTQY.js";import{c as le}from"./chunk-KDMDI7KA.js";import{n as ge}from"./chunk-QB75Q7U4.js";import"./chunk-ZPQBVYNN.js";import{B as z,j as re,k as he,s as ae,x as W}from"./chunk-PN7JHEYW.js";import"./chunk-PDBW6GTJ.js";import{a as Ue}from"./chunk-A6TVTNKO.js";import{a as $e,b as ze}from"./chunk-ADABTCDI.js";import{a as v,d as te}from"./chunk-5PEAXTYQ.js";var K=te(Ue(),1);var q=te($e(),1);var r=te(ze(),1);var ue=["trace","debug","log","info","warn","error","fatal"],De="LOG_ARCHIVE_NOT_CONFIGURED",je={cursor:void 0,error:null,generation:0,loading:!1,notConfigured:!1,rows:null},Be=v((i,e)=>{switch(e.type){case"append":return{...i,cursor:e.cursor,error:null,loading:!1,rows:[...i.rows??[],...e.rows]};case"failed":return{...i,cursor:void 0,error:e.message,loading:!1,notConfigured:!1,rows:null};case"loaded":return{cursor:e.cursor,error:null,generation:i.generation+1,loading:!1,notConfigured:!1,rows:e.rows};case"loading":return{...i,error:null,loading:!0,notConfigured:!1};case"notConfigured":return{...i,cursor:void 0,error:null,loading:!1,notConfigured:!0,rows:null};case"pageFailed":return{...i,error:e.message,loading:!1};default:return i}},"ze"),We=v(i=>{let e=(0,K.c)(36),{row:t}=i,s;e[0]!==t.fields?(s=Ie(t.fields),e[0]=t.fields,e[1]=s):s=e[1];let n=s,o=`lg-archive-row-${String(t.ts)}`,c;e[2]!==t.ts?(c=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=c):c=e[3];let p;e[4]!==c?(p=(0,r.jsx)(B,{className:"tabular-nums whitespace-nowrap text-xs text-muted-foreground",children:c}),e[4]=c,e[5]=p):p=e[5];let m=Re[t.level],d;e[6]!==t.level||e[7]!==m?(d=(0,r.jsx)(B,{children:(0,r.jsx)(ne,{variant:m,children:t.level})}),e[6]=t.level,e[7]=m,e[8]=d):d=e[8];let a;e[9]!==t.functionPath?(a=(0,r.jsx)(B,{className:"font-mono text-xs",children:t.functionPath}),e[9]=t.functionPath,e[10]=a):a=e[10];let h;e[11]!==t.message?(h=(0,r.jsx)("div",{className:"truncate",title:t.message,children:t.message}),e[11]=t.message,e[12]=h):h=e[12];let l;e[13]!==n.text?(l=n.text!==""&&(0,r.jsx)("div",{className:"truncate font-mono text-[11px] text-muted-foreground",title:n.text,children:n.text}),e[13]=n.text,e[14]=l):l=e[14];let g;e[15]!==n.errors?(g=n.errors.length>0&&(0,r.jsx)(Pe,{errors:n.errors}),e[15]=n.errors,e[16]=g):g=e[16];let u;e[17]!==g||e[18]!==h||e[19]!==l?(u=(0,r.jsxs)(B,{className:"max-w-md",children:[h,l,g]}),e[17]=g,e[18]=h,e[19]=l,e[20]=u):u=e[20];let x=t.traceId??"\u2014",f;e[21]!==x?(f=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:x}),e[21]=x,e[22]=f):f=e[22];let C=t.shardKey??"\u2014",y;e[23]!==C?(y=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:C}),e[23]=C,e[24]=y):y=e[24];let w=t.userId??"\u2014",k;e[25]!==w?(k=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:w}),e[25]=w,e[26]=k):k=e[26];let L;return e[27]!==u||e[28]!==f||e[29]!==y||e[30]!==k||e[31]!==o||e[32]!==p||e[33]!==d||e[34]!==a?(L=(0,r.jsxs)(se,{"data-testid":o,children:[p,d,a,u,f,y,k]}),e[27]=u,e[28]=f,e[29]=y,e[30]=k,e[31]=o,e[32]=p,e[33]=d,e[34]=a,e[35]=L):L=e[35],L},"Ge"),Ve=v(({shardKey:i})=>{let e=ge(),t=z(),[s,n]=(0,q.useState)(""),[o,c]=(0,q.useState)(""),[p,m]=(0,q.useState)(""),[{cursor:d,error:a,generation:h,loading:l,notConfigured:g,rows:u},x]=(0,q.useReducer)(Be,je),f=ie(s.trim(),400),C=ie(o.trim(),400),y={...f===""?{}:{functionPathPrefix:f},...p===""?{}:{minLevel:p},...i===""?{}:{shardKey:i},...C===""?{}:{userId:C}},w=JSON.stringify(y),k=(0,q.useRef)(w);(0,q.useEffect)(()=>{let b={cancelled:!1};return k.current=w,ae((async()=>{x({type:"loading"});try{let N=await e.queryLogArchive(y);b.cancelled||x({cursor:N.nextCursor,rows:N.rows,type:"loaded"})}catch(N){b.cancelled||x(he(N)===De?{type:"notConfigured"}:{message:re(N),type:"failed"})}})()),()=>{b.cancelled=!0}},[e,w]);let L=v(async()=>{if(d===void 0)return;let b=w;x({type:"loading"});try{let N=await e.queryLogArchive({...y,cursor:d});k.current===b&&x({cursor:N.nextCursor,rows:N.rows,type:"append"})}catch(N){k.current===b&&x({message:re(N),type:"pageFailed"})}},"N"),S=v(b=>{n(b.target.value)},"I"),T=v(b=>{c(b.target.value)},"T"),R=v(b=>{m(b.target.value)},"R"),P=v(()=>{ae(L())},"k");return g?(0,r.jsx)(J,{action:(0,r.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline",href:de,rel:"noreferrer",target:"_blank",children:t("Open in Cloudflare")}),description:t("Wire pipelineLogSink to a Cloudflare Pipeline \u2192 R2 Data Catalog table and set R2_SQL_ACCOUNT_ID, R2_SQL_TOKEN, R2_SQL_BUCKET to browse the durable log archive here."),testId:"lg-archive-not-configured",title:t("Log archive not configured")}):(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lg-archive",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(D,{"aria-label":t("Function path prefix"),className:"h-8 w-48","data-testid":"lg-archive-path",onChange:S,placeholder:t("function path\u2026"),value:s}),(0,r.jsx)(D,{"aria-label":t("User id"),className:"h-8 w-40","data-testid":"lg-archive-user",onChange:T,placeholder:t("user id\u2026"),value:o}),(0,r.jsxs)("select",{"aria-label":t("Minimum level"),className:"h-8 rounded-md border border-border bg-background px-2 text-sm","data-testid":"lg-archive-min-level",onChange:R,value:p,children:[(0,r.jsx)("option",{value:"",children:t("min level")}),ue.map(b=>(0,r.jsx)("option",{value:b,children:b},b))]})]}),a!==null&&(0,r.jsx)("p",{className:"text-sm text-destructive","data-testid":"lg-archive-error",role:"alert",children:a}),l&&u===null&&a===null&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"lg-archive-loading",children:t("Loading\u2026")}),u!==null&&u.length===0&&(0,r.jsx)(J,{description:t("No archived logs match these filters. The durable archive fills as pipelineLogSink flushes records to R2."),testId:"lg-archive-empty",title:t("No archived logs.")}),u!==null&&u.length>0&&(0,r.jsx)("div",{className:"overflow-hidden rounded-xl border border-border shadow-xs",children:(0,r.jsxs)(ye,{"data-testid":"lg-archive-table",children:[(0,r.jsx)(we,{children:(0,r.jsxs)(se,{children:[(0,r.jsx)(j,{children:t("Time")}),(0,r.jsx)(j,{children:t("Level")}),(0,r.jsx)(j,{children:t("Function")}),(0,r.jsx)(j,{children:t("Message")}),(0,r.jsx)(j,{children:t("Trace")}),(0,r.jsx)(j,{children:t("Shard")}),(0,r.jsx)(j,{children:t("User")})]})}),(0,r.jsx)(Ne,{children:u.map((b,N)=>(0,r.jsx)(We,{row:b},`${String(h)}:${String(b.ts)}-${String(N)}`))})]})}),d!==void 0&&(0,r.jsx)("div",{children:(0,r.jsx)(pe,{"data-testid":"lg-archive-more",disabled:l,onClick:P,size:"sm",variant:"outline",children:t(l?"Loading\u2026":"Load more")})})]})},"He"),Qe=v(i=>{let e=(0,K.c)(11),{level:t,onToggle:s,selected:n}=i,o;e[0]!==t||e[1]!==s?(o=v(()=>{s(t)},"o"),e[0]=t,e[1]=s,e[2]=o):o=e[2];let c=o,p=n?"border-border bg-muted font-medium":"border-input text-muted-foreground",m;e[3]!==p?(m=W("rounded-md border px-2 py-1 text-xs",p),e[3]=p,e[4]=m):m=e[4];let d=`logs-level-${t}`,a;return e[5]!==t||e[6]!==c||e[7]!==n||e[8]!==m||e[9]!==d?(a=(0,r.jsx)("button",{"aria-pressed":n,className:m,"data-testid":d,onClick:c,type:"button",children:t}),e[5]=t,e[6]=c,e[7]=n,e[8]=m,e[9]=d,e[10]=a):a=e[10],a},"We"),Ye=v(i=>{let e=(0,K.c)(68),{levelFilter:t,onLogPathChange:s,onSearchChange:n,onTimeRangeChange:o,onToggleLevel:c,onToggleSummary:p,pathFilter:m,search:d,showSummary:a,timeRange:h}=i,l=z(),g;e[0]!==l?(g=l("Search messages"),e[0]=l,e[1]=g):g=e[1];let u;e[2]!==l?(u=l("search message"),e[2]=l,e[3]=u):u=e[3];let x;e[4]!==n||e[5]!==d||e[6]!==g||e[7]!==u?(x=(0,r.jsx)(D,{"aria-label":g,className:"h-8 w-48","data-testid":"lg-search",onChange:n,placeholder:u,value:d}),e[4]=n,e[5]=d,e[6]=g,e[7]=u,e[8]=x):x=e[8];let f;e[9]!==l?(f=l("Function path"),e[9]=l,e[10]=f):f=e[10];let C;e[11]!==l?(C=l("filter path"),e[11]=l,e[12]=C):C=e[12];let y;e[13]!==s||e[14]!==m||e[15]!==f||e[16]!==C?(y=(0,r.jsx)(D,{"aria-label":f,className:"h-8 w-40","data-testid":"logs-path-filter",onChange:s,placeholder:C,value:m}),e[13]=s,e[14]=m,e[15]=f,e[16]=C,e[17]=y):y=e[17];let w;e[18]!==l?(w=l("Level filter"),e[18]=l,e[19]=w):w=e[19];let k;e[20]!==t||e[21]!==c?(k=ue.map(Q=>(0,r.jsx)(Qe,{level:Q,onToggle:c,selected:t.has(Q)},Q)),e[20]=t,e[21]=c,e[22]=k):k=e[22];let L;e[23]!==w||e[24]!==k?(L=(0,r.jsx)("div",{"aria-label":w,className:"inline-flex items-center gap-1","data-testid":"logs-level-filter",role:"group",children:k}),e[23]=w,e[24]=k,e[25]=L):L=e[25];let S;e[26]!==l?(S=l("Time range"),e[26]=l,e[27]=S):S=e[27];let T;e[28]!==l?(T=l("All time"),e[28]=l,e[29]=T):T=e[29];let R;e[30]!==T?(R=(0,r.jsx)("option",{value:"all",children:T}),e[30]=T,e[31]=R):R=e[31];let P;e[32]!==l?(P=l("Last 5m"),e[32]=l,e[33]=P):P=e[33];let b;e[34]!==P?(b=(0,r.jsx)("option",{value:"5m",children:P}),e[34]=P,e[35]=b):b=e[35];let N;e[36]!==l?(N=l("Last 15m"),e[36]=l,e[37]=N):N=e[37];let F;e[38]!==N?(F=(0,r.jsx)("option",{value:"15m",children:N}),e[38]=N,e[39]=F):F=e[39];let E;e[40]!==l?(E=l("Last hour"),e[40]=l,e[41]=E):E=e[41];let O;e[42]!==E?(O=(0,r.jsx)("option",{value:"1h",children:E}),e[42]=E,e[43]=O):O=e[43];let M;e[44]!==o||e[45]!==S||e[46]!==R||e[47]!==b||e[48]!==F||e[49]!==O||e[50]!==h?(M=(0,r.jsxs)("select",{"aria-label":S,className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"logs-time-range",onChange:o,value:h,children:[R,b,F,O]}),e[44]=o,e[45]=S,e[46]=R,e[47]=b,e[48]=F,e[49]=O,e[50]=h,e[51]=M):M=e[51];let V=a?"border-border bg-muted font-medium":"border-input text-muted-foreground",_;e[52]!==V?(_=W("h-8 rounded-md border px-3 text-sm",V),e[52]=V,e[53]=_):_=e[53];let U;e[54]!==a||e[55]!==l?(U=l(a?"List":"Summary"),e[54]=a,e[55]=l,e[56]=U):U=e[56];let A;e[57]!==p||e[58]!==a||e[59]!==_||e[60]!==U?(A=(0,r.jsx)("button",{"aria-pressed":a,className:_,"data-testid":"logs-summary-toggle",onClick:p,type:"button",children:U}),e[57]=p,e[58]=a,e[59]=_,e[60]=U,e[61]=A):A=e[61];let $;return e[62]!==M||e[63]!==A||e[64]!==x||e[65]!==y||e[66]!==L?($=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[x,y,L,M,A]}),e[62]=M,e[63]=A,e[64]=x,e[65]=y,e[66]=L,e[67]=$):$=e[67],$},"Ye"),Ge=v(i=>{let e=(0,K.c)(53),{onOutcomeChange:t,onPathChange:s,onTableChange:n,onUserChange:o,outcomeFilter:c,pathPrefix:p,tableFilter:m,userIdFilter:d}=i,a=z(),h;e[0]!==a?(h=a("Function path"),e[0]=a,e[1]=h):h=e[1];let l;e[2]!==a?(l=a("file:function"),e[2]=a,e[3]=l):l=e[3];let g;e[4]!==s||e[5]!==p||e[6]!==h||e[7]!==l?(g=(0,r.jsx)(D,{"aria-label":h,className:"h-8 w-44","data-testid":"lg-req-path",onChange:s,placeholder:l,value:p}),e[4]=s,e[5]=p,e[6]=h,e[7]=l,e[8]=g):g=e[8];let u;e[9]!==a?(u=a("User id"),e[9]=a,e[10]=u):u=e[10];let x;e[11]!==a?(x=a("userId"),e[11]=a,e[12]=x):x=e[12];let f;e[13]!==o||e[14]!==u||e[15]!==x||e[16]!==d?(f=(0,r.jsx)(D,{"aria-label":u,className:"h-8 w-32","data-testid":"lg-req-user",onChange:o,placeholder:x,value:d}),e[13]=o,e[14]=u,e[15]=x,e[16]=d,e[17]=f):f=e[17];let C;e[18]!==a?(C=a("Table touched"),e[18]=a,e[19]=C):C=e[19];let y;e[20]!==a?(y=a("table"),e[20]=a,e[21]=y):y=e[21];let w;e[22]!==n||e[23]!==C||e[24]!==y||e[25]!==m?(w=(0,r.jsx)(D,{"aria-label":C,className:"h-8 w-32","data-testid":"lg-req-table",onChange:n,placeholder:y,value:m}),e[22]=n,e[23]=C,e[24]=y,e[25]=m,e[26]=w):w=e[26];let k;e[27]!==a?(k=a("Outcome filter"),e[27]=a,e[28]=k):k=e[28];let L;e[29]!==a?(L=a("all"),e[29]=a,e[30]=L):L=e[30];let S;e[31]!==L?(S=(0,r.jsx)("option",{value:"all",children:L}),e[31]=L,e[32]=S):S=e[32];let T;e[33]!==a?(T=a("ok"),e[33]=a,e[34]=T):T=e[34];let R;e[35]!==T?(R=(0,r.jsx)("option",{value:"ok",children:T}),e[35]=T,e[36]=R):R=e[36];let P;e[37]!==a?(P=a("error"),e[37]=a,e[38]=P):P=e[38];let b;e[39]!==P?(b=(0,r.jsx)("option",{value:"error",children:P}),e[39]=P,e[40]=b):b=e[40];let N;e[41]!==t||e[42]!==c||e[43]!==k||e[44]!==S||e[45]!==R||e[46]!==b?(N=(0,r.jsxs)("select",{"aria-label":k,className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"lg-req-outcome",onChange:t,value:c,children:[S,R,b]}),e[41]=t,e[42]=c,e[43]=k,e[44]=S,e[45]=R,e[46]=b,e[47]=N):N=e[47];let F;return e[48]!==N||e[49]!==g||e[50]!==f||e[51]!==w?(F=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[g,f,w,N]}),e[48]=N,e[49]=g,e[50]=f,e[51]=w,e[52]=F):F=e[52],F},"je"),Oe=v(i=>{let e=(0,K.c)(7),{bucket:t}=i,s;e[0]!==t.key?(s=(0,r.jsx)("span",{className:"truncate text-muted-foreground",role:"gridcell",children:t.key}),e[0]=t.key,e[1]=s):s=e[1];let n;e[2]!==t.count?(n=(0,r.jsx)("span",{className:"shrink-0 tabular-nums",role:"gridcell",children:t.count}),e[2]=t.count,e[3]=n):n=e[3];let o;return e[4]!==s||e[5]!==n?(o=(0,r.jsxs)("div",{className:"flex items-center justify-between gap-4 px-3 py-1 font-mono text-xs","data-testid":"logs-summary-row",role:"row",children:[s,n]}),e[4]=s,e[5]=n,e[6]=o):o=e[6],o},"pe"),He=v(i=>{let e=(0,K.c)(31),{summary:t}=i,s=z(),n;e[0]!==t.total||e[1]!==s?(n=s("{count} entries",{count:t.total}),e[0]=t.total,e[1]=s,e[2]=n):n=e[2];let o;e[3]!==n?(o=(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"logs-summary-total",children:n}),e[3]=n,e[4]=o):o=e[4];let c;e[5]!==s?(c=s("By level"),e[5]=s,e[6]=c):c=e[6];let p;e[7]!==c?(p=(0,r.jsx)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:c}),e[7]=c,e[8]=p):p=e[8];let m;e[9]!==t.byLevel?(m=t.byLevel.map(Je),e[9]=t.byLevel,e[10]=m):m=e[10];let d;e[11]!==m?(d=(0,r.jsx)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-levels",role:"grid",children:m}),e[11]=m,e[12]=d):d=e[12];let a;e[13]!==p||e[14]!==d?(a=(0,r.jsxs)("div",{children:[p,d]}),e[13]=p,e[14]=d,e[15]=a):a=e[15];let h;e[16]!==s?(h=s("By function"),e[16]=s,e[17]=h):h=e[17];let l;e[18]!==h?(l=(0,r.jsx)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h}),e[18]=h,e[19]=l):l=e[19];let g;e[20]!==t.byPath?(g=t.byPath.map(Xe),e[20]=t.byPath,e[21]=g):g=e[21];let u;e[22]!==g?(u=(0,r.jsx)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-paths",role:"grid",children:g}),e[22]=g,e[23]=u):u=e[23];let x;e[24]!==u||e[25]!==l?(x=(0,r.jsxs)("div",{children:[l,u]}),e[24]=u,e[25]=l,e[26]=x):x=e[26];let f;return e[27]!==x||e[28]!==o||e[29]!==a?(f=(0,r.jsxs)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"logs-summary",children:[o,a,x]}),e[27]=x,e[28]=o,e[29]=a,e[30]=f):f=e[30],f},"Je");function Je(i){return(0,r.jsx)(Oe,{bucket:i},i.key)}v(Je,"Xe");function Xe(i){return(0,r.jsx)(Oe,{bucket:i},i.key)}v(Xe,"Ze");var Ze=v(i=>{let e=(0,K.c)(46),{liveError:t,onShardKeyChange:s,onShowArchive:n,onShowErrors:o,onShowRequests:c,shardKey:p,view:m}=i,d=z(),a=m==="requests",h=m==="requests"?"bg-muted font-medium":"text-muted-foreground",l;e[0]!==h?(l=W("px-3 py-1 text-sm",h),e[0]=h,e[1]=l):l=e[1];let g;e[2]!==d?(g=d("Requests"),e[2]=d,e[3]=g):g=e[3];let u;e[4]!==c||e[5]!==a||e[6]!==l||e[7]!==g?(u=(0,r.jsx)("button",{"aria-selected":a,className:l,"data-testid":"lg-view-requests",onClick:c,role:"tab",type:"button",children:g}),e[4]=c,e[5]=a,e[6]=l,e[7]=g,e[8]=u):u=e[8];let x=m==="errors",f=m==="errors"?"bg-muted font-medium":"text-muted-foreground",C;e[9]!==f?(C=W("px-3 py-1 text-sm",f),e[9]=f,e[10]=C):C=e[10];let y;e[11]!==d?(y=d("Errors"),e[11]=d,e[12]=y):y=e[12];let w;e[13]!==o||e[14]!==x||e[15]!==C||e[16]!==y?(w=(0,r.jsx)("button",{"aria-selected":x,className:C,"data-testid":"lg-view-errors",onClick:o,role:"tab",type:"button",children:y}),e[13]=o,e[14]=x,e[15]=C,e[16]=y,e[17]=w):w=e[17];let k=m==="archive",L=m==="archive"?"bg-muted font-medium":"text-muted-foreground",S;e[18]!==L?(S=W("px-3 py-1 text-sm",L),e[18]=L,e[19]=S):S=e[19];let T;e[20]!==d?(T=d("Archive"),e[20]=d,e[21]=T):T=e[21];let R;e[22]!==n||e[23]!==k||e[24]!==S||e[25]!==T?(R=(0,r.jsx)("button",{"aria-selected":k,className:S,"data-testid":"lg-view-archive",onClick:n,role:"tab",type:"button",children:T}),e[22]=n,e[23]=k,e[24]=S,e[25]=T,e[26]=R):R=e[26];let P;e[27]!==w||e[28]!==R||e[29]!==u?(P=(0,r.jsxs)("div",{className:"inline-flex overflow-hidden rounded-lg border border-border",role:"tablist",children:[u,w,R]}),e[27]=w,e[28]=R,e[29]=u,e[30]=P):P=e[30];let b;e[31]!==s||e[32]!==p?(b=(0,r.jsx)(ve,{onChange:s,testId:"lg-shard-input",value:p}),e[31]=s,e[32]=p,e[33]=b):b=e[33];let N;e[34]!==t||e[35]!==m?(N=m!=="archive"&&(0,r.jsx)(Ce,{message:t,prefix:"lg"}),e[34]=t,e[35]=m,e[36]=N):N=e[36];let F;e[37]!==d?(F=d("Open in Cloudflare"),e[37]=d,e[38]=F):F=e[38];let E;e[39]!==F?(E=(0,r.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"lg-cf-link",href:de,rel:"noreferrer",target:"_blank",children:F}),e[39]=F,e[40]=E):E=e[40];let O;return e[41]!==P||e[42]!==b||e[43]!==N||e[44]!==E?(O=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[P,b,N,E]}),e[41]=P,e[42]=b,e[43]=N,e[44]=E,e[45]=O):O=e[45],O},"et"),ce=400,et=36,tt={height:ce,overflow:"auto"},Ke={left:0,position:"absolute",top:0,width:"100%"},rt={error:"destructive",ok:"secondary"},Me=v(i=>{let e=(0,K.c)(6),{onOpenTrace:t,traceId:s}=i,n=z(),o;e[0]!==t||e[1]!==n||e[2]!==s?(o=s===void 0?null:(0,r.jsx)("button",{className:"text-primary underline-offset-2 hover:underline","data-testid":"lg-trace-link",onClick:v(()=>{t(s)},"onClick"),type:"button",children:n("Trace")}),e[0]=t,e[1]=n,e[2]=s,e[3]=o):o=e[3];let c;return e[4]!==o?(c=(0,r.jsx)("span",{className:"w-16 shrink-0 text-right",role:"gridcell",children:o}),e[4]=o,e[5]=c):c=e[5],c},"be"),at=v(i=>{let e=(0,K.c)(13),{entry:t,index:s,measureRef:n,onOpenTrace:o,start:c}=i,p=`translateY(${String(c)}px)`,m;e[0]!==p?(m={...Ke,transform:p},e[0]=p,e[1]=m):m=e[1];let d=m,a;e[2]!==t?(a=(0,r.jsx)(qe,{entry:t}),e[2]=t,e[3]=a):a=e[3];let h;e[4]!==t.traceId||e[5]!==o?(h=(0,r.jsx)(Me,{onOpenTrace:o,traceId:t.traceId}),e[4]=t.traceId,e[5]=o,e[6]=h):h=e[6];let l;return e[7]!==s||e[8]!==n||e[9]!==d||e[10]!==a||e[11]!==h?(l=(0,r.jsxs)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":s,"data-testid":"lg-row",ref:n,role:"row",style:d,children:[a,h]}),e[7]=s,e[8]=n,e[9]=d,e[10]=a,e[11]=h,e[12]=l):l=e[12],l},"lt"),Fe=v(i=>i.length===0?"\u2014":i.join(", "),"ce"),lt=v(i=>{let e=(0,K.c)(41),{entry:t,index:s,measureRef:n,onOpenTrace:o,start:c}=i,p=`translateY(${String(c)}px)`,m;e[0]!==p?(m={...Ke,transform:p},e[0]=p,e[1]=m):m=e[1];let d=m,a;e[2]!==t.ts?(a=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=a):a=e[3];let h;e[4]!==a?(h=(0,r.jsx)("span",{className:"w-40 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:a}),e[4]=a,e[5]=h):h=e[5];let l=rt[t.outcome],g;e[6]!==t.outcome||e[7]!==l?(g=(0,r.jsx)("span",{className:"w-16 shrink-0",role:"gridcell",children:(0,r.jsx)(ne,{variant:l,children:t.outcome})}),e[6]=t.outcome,e[7]=l,e[8]=g):g=e[8];let u;e[9]!==t.functionPath?(u=(0,r.jsx)("span",{className:"w-44 shrink-0 truncate",role:"gridcell",title:t.functionPath,children:t.functionPath}),e[9]=t.functionPath,e[10]=u):u=e[10];let x=t.shardKey??"\u2014",f;e[11]!==x?(f=(0,r.jsx)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:x}),e[11]=x,e[12]=f):f=e[12];let C=t.userId??"\u2014",y;e[13]!==C?(y=(0,r.jsx)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:C}),e[13]=C,e[14]=y):y=e[14];let w;e[15]!==t.durationMs?(w=Math.round(t.durationMs),e[15]=t.durationMs,e[16]=w):w=e[16];let k=`${String(w)}ms`,L;e[17]!==k?(L=(0,r.jsx)("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:k}),e[17]=k,e[18]=L):L=e[18];let S;e[19]!==t.errorMessage||e[20]!==t.outcome||e[21]!==t.tablesRead||e[22]!==t.tablesWritten?(S=t.outcome==="error"&&t.errorMessage!==void 0?t.errorMessage:`r:${Fe(t.tablesRead)} \xB7 w:${Fe(t.tablesWritten)}`,e[19]=t.errorMessage,e[20]=t.outcome,e[21]=t.tablesRead,e[22]=t.tablesWritten,e[23]=S):S=e[23];let T;e[24]!==S?(T=(0,r.jsx)("span",{className:"flex-1 truncate text-muted-foreground",role:"gridcell",children:S}),e[24]=S,e[25]=T):T=e[25];let R;e[26]!==t.traceId||e[27]!==o?(R=(0,r.jsx)(Me,{onOpenTrace:o,traceId:t.traceId}),e[26]=t.traceId,e[27]=o,e[28]=R):R=e[28];let P;return e[29]!==s||e[30]!==n||e[31]!==d||e[32]!==y||e[33]!==L||e[34]!==T||e[35]!==R||e[36]!==h||e[37]!==g||e[38]!==u||e[39]!==f?(P=(0,r.jsxs)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":s,"data-testid":"lg-req-row",ref:n,role:"row",style:d,children:[h,g,u,f,y,L,T,R]}),e[29]=s,e[30]=n,e[31]=d,e[32]=y,e[33]=L,e[34]=T,e[35]=R,e[36]=h,e[37]=g,e[38]=u,e[39]=f,e[40]=P):P=e[40],P},"ot"),Ee=v(i=>{let{entries:e}=i??{};return Array.isArray(e)?e:[]},"de"),ot=v(i=>{let e={};return i.functionPathPrefix.trim()!==""&&(e.functionPathPrefix=i.functionPathPrefix.trim()),i.userId.trim()!==""&&(e.userId=i.userId.trim()),i.tableTouched.trim()!==""&&(e.tableTouched=i.tableTouched.trim()),(i.outcome==="ok"||i.outcome==="error")&&(e.outcome=i.outcome),e},"nt"),nt={"5m":300*1e3,"15m":900*1e3,"1h":3600*1e3},st=v((i,e)=>{let t=e.search.trim().toLowerCase(),s=e.path.trim().toLowerCase(),n=e.range==="all"?Number.NEGATIVE_INFINITY:e.now-nt[e.range];return i.filter(o=>e.levels.size>0&&!e.levels.has(o.level)||o.timestamp<n||s!==""&&!(o.functionPath??"").toLowerCase().includes(s)?!1:t===""||o.message.toLowerCase().includes(t)||Te(o.fields).toLowerCase().includes(t))},"it"),it="\u2014",dt=v(i=>{let e=new Map,t=new Map;for(let o of i){e.set(o.level,(e.get(o.level)??0)+1);let c=o.functionPath??it;t.set(c,(t.get(c)??0)+1)}let s=ue.filter(o=>e.has(o)).map(o=>({count:e.get(o)??0,key:o})),n=[...t.entries()].map(([o,c])=>({count:c,key:o})).toSorted((o,c)=>c.count===o.count?o.key.localeCompare(c.key):c.count-o.count);return{byLevel:s,byPath:n,total:i.length}},"dt"),Et=v(({initialShardKey:i})=>{let e=z(),[t,s]=(0,q.useState)("requests"),{queryShardKey:n,setShardKey:o,shardKey:c}=be(i),[p,m]=(0,q.useState)(""),[d,a]=(0,q.useState)(()=>new Set),[h,l]=(0,q.useState)(""),[g,u]=(0,q.useState)("all"),[x,f]=(0,q.useState)(!1),[C,y]=(0,q.useState)(""),[w,k]=(0,q.useState)(""),[L,S]=(0,q.useState)(""),[T,R]=(0,q.useState)("all"),P=ot({functionPathPrefix:C,outcome:T,tableTouched:L,userId:w}),b=le(oe.getRequestLog,P,{enabled:t==="requests",live:!0,shardKey:n}),N=le(oe.getLogs,{},{enabled:t==="errors",live:!0,shardKey:n}),F=t==="requests"?b:N,{error:E,errorSource:O,isLoading:M,liveError:V}=F,_=Se(n),U=Ee(N.data),A=Ee(b.data);(0,q.useEffect)(()=>{F.data!==void 0&&fe(n)},[F.data,n]);let $=st(U,{levels:d,now:Date.now(),path:h,range:g,search:p}),Q=dt($),X=t==="requests"?A.length:$.length,Z=t==="errors"&&x,Y=(0,q.useMemo)(()=>E!==null?"error":X===0?M?Z?"summary":"list":"empty":Z?"summary":"list",[X,M,E,Z]),me=(0,q.useRef)(null),G=ke({count:X,estimateSize:v(()=>et,"estimateSize"),getItemKey:v(I=>t==="errors"?$[I]?.id??I:I,"getItemKey"),getScrollElement:v(()=>me.current,"getScrollElement"),initialRect:{height:ce,width:800},observeElementRect:v((I,ee)=>Le(I,ee,ce),"observeElementRect"),overscan:8}),_e=G.getVirtualItems(),Ae={height:G.getTotalSize(),position:"relative",width:"100%"};return(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-logs",children:[(0,r.jsx)(Ze,{liveError:V,onShardKeyChange:o,onShowArchive:v(()=>{s("archive"),f(!1)},"onShowArchive"),onShowErrors:v(()=>{s("errors"),f(!1)},"onShowErrors"),onShowRequests:v(()=>{s("requests"),f(!1)},"onShowRequests"),shardKey:c,view:t}),t==="errors"&&(0,r.jsx)(Ye,{levelFilter:d,onLogPathChange:v(I=>{l(I.target.value)},"onLogPathChange"),onSearchChange:v(I=>{m(I.target.value)},"onSearchChange"),onTimeRangeChange:v(I=>{u(I.target.value)},"onTimeRangeChange"),onToggleLevel:v(I=>{a(ee=>{let H=new Set(ee);return H.has(I)?H.delete(I):H.add(I),H})},"onToggleLevel"),onToggleSummary:v(()=>{f(I=>!I)},"onToggleSummary"),pathFilter:h,search:p,showSummary:x,timeRange:g}),t==="requests"&&(0,r.jsx)(Ge,{onOutcomeChange:v(I=>{R(I.target.value)},"onOutcomeChange"),onPathChange:v(I=>{y(I.target.value)},"onPathChange"),onTableChange:v(I=>{S(I.target.value)},"onTableChange"),onUserChange:v(I=>{k(I.target.value)},"onUserChange"),outcomeFilter:T,pathPrefix:C,tableFilter:L,userIdFilter:w}),t==="archive"?(0,r.jsx)(Ve,{shardKey:n}):(0,r.jsxs)(r.Fragment,{children:[Y==="error"&&(0,r.jsx)(xe,{error:O,shardKey:n,testId:"lg-error"}),Y==="empty"&&(0,r.jsx)(J,{description:e("Function and request logs for this shard show up here as your app handles traffic."),icon:(0,r.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M4 5h16M4 12h16M4 19h10"})}),testId:"lg-empty",title:e("No logs.")}),Y==="summary"&&(0,r.jsx)(He,{summary:Q}),Y==="list"&&(0,r.jsx)("div",{className:"rounded-xl border border-border shadow-xs","data-testid":"lg-scroll",ref:me,style:tt,children:(0,r.jsx)("div",{"aria-label":e("Recent logs"),"data-testid":"lg-table",role:"grid",style:Ae,children:_e.map(I=>t==="requests"?(0,r.jsx)(lt,{entry:A[I.index],index:I.index,measureRef:G.measureElement,onOpenTrace:_,start:I.start},I.key):(0,r.jsx)(at,{entry:$[I.index],index:I.index,measureRef:G.measureElement,onOpenTrace:_,start:I.start},I.key))})})]})]})},"jt");export{Et as LogsPanel,st as filterLogs,dt as summarizeLogs};
1
+ import{a as Re,b as Pe,c as qe}from"./chunk-V5TGDG6U.js";import{b as Ie,c as Te}from"./chunk-LJLNIVUA.js";import{a as Se}from"./chunk-V3DOKU22.js";import"./chunk-QLZGKBOW.js";import{a as de}from"./chunk-R6NJ4ER6.js";import{a as Le}from"./chunk-W7CLOQOU.js";import{c as ke}from"./chunk-MHZNDDGI.js";import{a as Ce}from"./chunk-NAGIOR23.js";import{a as ie}from"./chunk-DRHZZ7IN.js";import{a as be}from"./chunk-2KTN53PK.js";import{a as ve}from"./chunk-YLC2ZYCL.js";import{b as fe}from"./chunk-EDL46BPM.js";import"./chunk-4KPATTV6.js";import"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import{i as D}from"./chunk-2D4WBSDO.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as pe}from"./chunk-CBTPJPCZ.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as J}from"./chunk-HMMALUXM.js";import{b as ne}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{a as xe}from"./chunk-JZN3MNJX.js";import"./chunk-EYSF4DHD.js";import{a as ye,b as we,c as Ne,d as se,e as j,f as B}from"./chunk-ZJIYJZ6F.js";import"./chunk-ELPLRD4S.js";import"./chunk-NFI2TNKU.js";import"./chunk-EOFWXI3T.js";import{a as oe}from"./chunk-LYVYUTQY.js";import{c as le}from"./chunk-LRUYEVHH.js";import{n as ge}from"./chunk-QFN62JQJ.js";import"./chunk-ZPQBVYNN.js";import{B as z,j as re,k as he,s as ae,x as W}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as Ue}from"./chunk-A6TVTNKO.js";import{a as $e,b as ze}from"./chunk-ADABTCDI.js";import{a as v,d as te}from"./chunk-5PEAXTYQ.js";var K=te(Ue(),1);var q=te($e(),1);var r=te(ze(),1);var ue=["trace","debug","log","info","warn","error","fatal"],De="LOG_ARCHIVE_NOT_CONFIGURED",je={cursor:void 0,error:null,generation:0,loading:!1,notConfigured:!1,rows:null},Be=v((i,e)=>{switch(e.type){case"append":return{...i,cursor:e.cursor,error:null,loading:!1,rows:[...i.rows??[],...e.rows]};case"failed":return{...i,cursor:void 0,error:e.message,loading:!1,notConfigured:!1,rows:null};case"loaded":return{cursor:e.cursor,error:null,generation:i.generation+1,loading:!1,notConfigured:!1,rows:e.rows};case"loading":return{...i,error:null,loading:!0,notConfigured:!1};case"notConfigured":return{...i,cursor:void 0,error:null,loading:!1,notConfigured:!0,rows:null};case"pageFailed":return{...i,error:e.message,loading:!1};default:return i}},"ze"),We=v(i=>{let e=(0,K.c)(36),{row:t}=i,s;e[0]!==t.fields?(s=Ie(t.fields),e[0]=t.fields,e[1]=s):s=e[1];let n=s,o=`lg-archive-row-${String(t.ts)}`,c;e[2]!==t.ts?(c=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=c):c=e[3];let p;e[4]!==c?(p=(0,r.jsx)(B,{className:"tabular-nums whitespace-nowrap text-xs text-muted-foreground",children:c}),e[4]=c,e[5]=p):p=e[5];let m=Re[t.level],d;e[6]!==t.level||e[7]!==m?(d=(0,r.jsx)(B,{children:(0,r.jsx)(ne,{variant:m,children:t.level})}),e[6]=t.level,e[7]=m,e[8]=d):d=e[8];let a;e[9]!==t.functionPath?(a=(0,r.jsx)(B,{className:"font-mono text-xs",children:t.functionPath}),e[9]=t.functionPath,e[10]=a):a=e[10];let h;e[11]!==t.message?(h=(0,r.jsx)("div",{className:"truncate",title:t.message,children:t.message}),e[11]=t.message,e[12]=h):h=e[12];let l;e[13]!==n.text?(l=n.text!==""&&(0,r.jsx)("div",{className:"truncate font-mono text-[11px] text-muted-foreground",title:n.text,children:n.text}),e[13]=n.text,e[14]=l):l=e[14];let g;e[15]!==n.errors?(g=n.errors.length>0&&(0,r.jsx)(Pe,{errors:n.errors}),e[15]=n.errors,e[16]=g):g=e[16];let u;e[17]!==g||e[18]!==h||e[19]!==l?(u=(0,r.jsxs)(B,{className:"max-w-md",children:[h,l,g]}),e[17]=g,e[18]=h,e[19]=l,e[20]=u):u=e[20];let x=t.traceId??"\u2014",f;e[21]!==x?(f=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:x}),e[21]=x,e[22]=f):f=e[22];let C=t.shardKey??"\u2014",y;e[23]!==C?(y=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:C}),e[23]=C,e[24]=y):y=e[24];let w=t.userId??"\u2014",k;e[25]!==w?(k=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:w}),e[25]=w,e[26]=k):k=e[26];let L;return e[27]!==u||e[28]!==f||e[29]!==y||e[30]!==k||e[31]!==o||e[32]!==p||e[33]!==d||e[34]!==a?(L=(0,r.jsxs)(se,{"data-testid":o,children:[p,d,a,u,f,y,k]}),e[27]=u,e[28]=f,e[29]=y,e[30]=k,e[31]=o,e[32]=p,e[33]=d,e[34]=a,e[35]=L):L=e[35],L},"Ge"),Ve=v(({shardKey:i})=>{let e=ge(),t=z(),[s,n]=(0,q.useState)(""),[o,c]=(0,q.useState)(""),[p,m]=(0,q.useState)(""),[{cursor:d,error:a,generation:h,loading:l,notConfigured:g,rows:u},x]=(0,q.useReducer)(Be,je),f=ie(s.trim(),400),C=ie(o.trim(),400),y={...f===""?{}:{functionPathPrefix:f},...p===""?{}:{minLevel:p},...i===""?{}:{shardKey:i},...C===""?{}:{userId:C}},w=JSON.stringify(y),k=(0,q.useRef)(w);(0,q.useEffect)(()=>{let b={cancelled:!1};return k.current=w,ae((async()=>{x({type:"loading"});try{let N=await e.queryLogArchive(y);b.cancelled||x({cursor:N.nextCursor,rows:N.rows,type:"loaded"})}catch(N){b.cancelled||x(he(N)===De?{type:"notConfigured"}:{message:re(N),type:"failed"})}})()),()=>{b.cancelled=!0}},[e,w]);let L=v(async()=>{if(d===void 0)return;let b=w;x({type:"loading"});try{let N=await e.queryLogArchive({...y,cursor:d});k.current===b&&x({cursor:N.nextCursor,rows:N.rows,type:"append"})}catch(N){k.current===b&&x({message:re(N),type:"pageFailed"})}},"N"),S=v(b=>{n(b.target.value)},"I"),T=v(b=>{c(b.target.value)},"T"),R=v(b=>{m(b.target.value)},"R"),P=v(()=>{ae(L())},"k");return g?(0,r.jsx)(J,{action:(0,r.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline",href:de,rel:"noreferrer",target:"_blank",children:t("Open in Cloudflare")}),description:t("Wire pipelineLogSink to a Cloudflare Pipeline \u2192 R2 Data Catalog table and set R2_SQL_ACCOUNT_ID, R2_SQL_TOKEN, R2_SQL_BUCKET to browse the durable log archive here."),testId:"lg-archive-not-configured",title:t("Log archive not configured")}):(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lg-archive",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(D,{"aria-label":t("Function path prefix"),className:"h-8 w-48","data-testid":"lg-archive-path",onChange:S,placeholder:t("function path\u2026"),value:s}),(0,r.jsx)(D,{"aria-label":t("User id"),className:"h-8 w-40","data-testid":"lg-archive-user",onChange:T,placeholder:t("user id\u2026"),value:o}),(0,r.jsxs)("select",{"aria-label":t("Minimum level"),className:"h-8 rounded-md border border-border bg-background px-2 text-sm","data-testid":"lg-archive-min-level",onChange:R,value:p,children:[(0,r.jsx)("option",{value:"",children:t("min level")}),ue.map(b=>(0,r.jsx)("option",{value:b,children:b},b))]})]}),a!==null&&(0,r.jsx)("p",{className:"text-sm text-destructive","data-testid":"lg-archive-error",role:"alert",children:a}),l&&u===null&&a===null&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"lg-archive-loading",children:t("Loading\u2026")}),u!==null&&u.length===0&&(0,r.jsx)(J,{description:t("No archived logs match these filters. The durable archive fills as pipelineLogSink flushes records to R2."),testId:"lg-archive-empty",title:t("No archived logs.")}),u!==null&&u.length>0&&(0,r.jsx)("div",{className:"overflow-hidden rounded-xl border border-border shadow-xs",children:(0,r.jsxs)(ye,{"data-testid":"lg-archive-table",children:[(0,r.jsx)(we,{children:(0,r.jsxs)(se,{children:[(0,r.jsx)(j,{children:t("Time")}),(0,r.jsx)(j,{children:t("Level")}),(0,r.jsx)(j,{children:t("Function")}),(0,r.jsx)(j,{children:t("Message")}),(0,r.jsx)(j,{children:t("Trace")}),(0,r.jsx)(j,{children:t("Shard")}),(0,r.jsx)(j,{children:t("User")})]})}),(0,r.jsx)(Ne,{children:u.map((b,N)=>(0,r.jsx)(We,{row:b},`${String(h)}:${String(b.ts)}-${String(N)}`))})]})}),d!==void 0&&(0,r.jsx)("div",{children:(0,r.jsx)(pe,{"data-testid":"lg-archive-more",disabled:l,onClick:P,size:"sm",variant:"outline",children:t(l?"Loading\u2026":"Load more")})})]})},"He"),Qe=v(i=>{let e=(0,K.c)(11),{level:t,onToggle:s,selected:n}=i,o;e[0]!==t||e[1]!==s?(o=v(()=>{s(t)},"o"),e[0]=t,e[1]=s,e[2]=o):o=e[2];let c=o,p=n?"border-border bg-muted font-medium":"border-input text-muted-foreground",m;e[3]!==p?(m=W("rounded-md border px-2 py-1 text-xs",p),e[3]=p,e[4]=m):m=e[4];let d=`logs-level-${t}`,a;return e[5]!==t||e[6]!==c||e[7]!==n||e[8]!==m||e[9]!==d?(a=(0,r.jsx)("button",{"aria-pressed":n,className:m,"data-testid":d,onClick:c,type:"button",children:t}),e[5]=t,e[6]=c,e[7]=n,e[8]=m,e[9]=d,e[10]=a):a=e[10],a},"We"),Ye=v(i=>{let e=(0,K.c)(68),{levelFilter:t,onLogPathChange:s,onSearchChange:n,onTimeRangeChange:o,onToggleLevel:c,onToggleSummary:p,pathFilter:m,search:d,showSummary:a,timeRange:h}=i,l=z(),g;e[0]!==l?(g=l("Search messages"),e[0]=l,e[1]=g):g=e[1];let u;e[2]!==l?(u=l("search message"),e[2]=l,e[3]=u):u=e[3];let x;e[4]!==n||e[5]!==d||e[6]!==g||e[7]!==u?(x=(0,r.jsx)(D,{"aria-label":g,className:"h-8 w-48","data-testid":"lg-search",onChange:n,placeholder:u,value:d}),e[4]=n,e[5]=d,e[6]=g,e[7]=u,e[8]=x):x=e[8];let f;e[9]!==l?(f=l("Function path"),e[9]=l,e[10]=f):f=e[10];let C;e[11]!==l?(C=l("filter path"),e[11]=l,e[12]=C):C=e[12];let y;e[13]!==s||e[14]!==m||e[15]!==f||e[16]!==C?(y=(0,r.jsx)(D,{"aria-label":f,className:"h-8 w-40","data-testid":"logs-path-filter",onChange:s,placeholder:C,value:m}),e[13]=s,e[14]=m,e[15]=f,e[16]=C,e[17]=y):y=e[17];let w;e[18]!==l?(w=l("Level filter"),e[18]=l,e[19]=w):w=e[19];let k;e[20]!==t||e[21]!==c?(k=ue.map(Q=>(0,r.jsx)(Qe,{level:Q,onToggle:c,selected:t.has(Q)},Q)),e[20]=t,e[21]=c,e[22]=k):k=e[22];let L;e[23]!==w||e[24]!==k?(L=(0,r.jsx)("div",{"aria-label":w,className:"inline-flex items-center gap-1","data-testid":"logs-level-filter",role:"group",children:k}),e[23]=w,e[24]=k,e[25]=L):L=e[25];let S;e[26]!==l?(S=l("Time range"),e[26]=l,e[27]=S):S=e[27];let T;e[28]!==l?(T=l("All time"),e[28]=l,e[29]=T):T=e[29];let R;e[30]!==T?(R=(0,r.jsx)("option",{value:"all",children:T}),e[30]=T,e[31]=R):R=e[31];let P;e[32]!==l?(P=l("Last 5m"),e[32]=l,e[33]=P):P=e[33];let b;e[34]!==P?(b=(0,r.jsx)("option",{value:"5m",children:P}),e[34]=P,e[35]=b):b=e[35];let N;e[36]!==l?(N=l("Last 15m"),e[36]=l,e[37]=N):N=e[37];let F;e[38]!==N?(F=(0,r.jsx)("option",{value:"15m",children:N}),e[38]=N,e[39]=F):F=e[39];let E;e[40]!==l?(E=l("Last hour"),e[40]=l,e[41]=E):E=e[41];let O;e[42]!==E?(O=(0,r.jsx)("option",{value:"1h",children:E}),e[42]=E,e[43]=O):O=e[43];let M;e[44]!==o||e[45]!==S||e[46]!==R||e[47]!==b||e[48]!==F||e[49]!==O||e[50]!==h?(M=(0,r.jsxs)("select",{"aria-label":S,className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"logs-time-range",onChange:o,value:h,children:[R,b,F,O]}),e[44]=o,e[45]=S,e[46]=R,e[47]=b,e[48]=F,e[49]=O,e[50]=h,e[51]=M):M=e[51];let V=a?"border-border bg-muted font-medium":"border-input text-muted-foreground",_;e[52]!==V?(_=W("h-8 rounded-md border px-3 text-sm",V),e[52]=V,e[53]=_):_=e[53];let U;e[54]!==a||e[55]!==l?(U=l(a?"List":"Summary"),e[54]=a,e[55]=l,e[56]=U):U=e[56];let A;e[57]!==p||e[58]!==a||e[59]!==_||e[60]!==U?(A=(0,r.jsx)("button",{"aria-pressed":a,className:_,"data-testid":"logs-summary-toggle",onClick:p,type:"button",children:U}),e[57]=p,e[58]=a,e[59]=_,e[60]=U,e[61]=A):A=e[61];let $;return e[62]!==M||e[63]!==A||e[64]!==x||e[65]!==y||e[66]!==L?($=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[x,y,L,M,A]}),e[62]=M,e[63]=A,e[64]=x,e[65]=y,e[66]=L,e[67]=$):$=e[67],$},"Ye"),Ge=v(i=>{let e=(0,K.c)(53),{onOutcomeChange:t,onPathChange:s,onTableChange:n,onUserChange:o,outcomeFilter:c,pathPrefix:p,tableFilter:m,userIdFilter:d}=i,a=z(),h;e[0]!==a?(h=a("Function path"),e[0]=a,e[1]=h):h=e[1];let l;e[2]!==a?(l=a("file:function"),e[2]=a,e[3]=l):l=e[3];let g;e[4]!==s||e[5]!==p||e[6]!==h||e[7]!==l?(g=(0,r.jsx)(D,{"aria-label":h,className:"h-8 w-44","data-testid":"lg-req-path",onChange:s,placeholder:l,value:p}),e[4]=s,e[5]=p,e[6]=h,e[7]=l,e[8]=g):g=e[8];let u;e[9]!==a?(u=a("User id"),e[9]=a,e[10]=u):u=e[10];let x;e[11]!==a?(x=a("userId"),e[11]=a,e[12]=x):x=e[12];let f;e[13]!==o||e[14]!==u||e[15]!==x||e[16]!==d?(f=(0,r.jsx)(D,{"aria-label":u,className:"h-8 w-32","data-testid":"lg-req-user",onChange:o,placeholder:x,value:d}),e[13]=o,e[14]=u,e[15]=x,e[16]=d,e[17]=f):f=e[17];let C;e[18]!==a?(C=a("Table touched"),e[18]=a,e[19]=C):C=e[19];let y;e[20]!==a?(y=a("table"),e[20]=a,e[21]=y):y=e[21];let w;e[22]!==n||e[23]!==C||e[24]!==y||e[25]!==m?(w=(0,r.jsx)(D,{"aria-label":C,className:"h-8 w-32","data-testid":"lg-req-table",onChange:n,placeholder:y,value:m}),e[22]=n,e[23]=C,e[24]=y,e[25]=m,e[26]=w):w=e[26];let k;e[27]!==a?(k=a("Outcome filter"),e[27]=a,e[28]=k):k=e[28];let L;e[29]!==a?(L=a("all"),e[29]=a,e[30]=L):L=e[30];let S;e[31]!==L?(S=(0,r.jsx)("option",{value:"all",children:L}),e[31]=L,e[32]=S):S=e[32];let T;e[33]!==a?(T=a("ok"),e[33]=a,e[34]=T):T=e[34];let R;e[35]!==T?(R=(0,r.jsx)("option",{value:"ok",children:T}),e[35]=T,e[36]=R):R=e[36];let P;e[37]!==a?(P=a("error"),e[37]=a,e[38]=P):P=e[38];let b;e[39]!==P?(b=(0,r.jsx)("option",{value:"error",children:P}),e[39]=P,e[40]=b):b=e[40];let N;e[41]!==t||e[42]!==c||e[43]!==k||e[44]!==S||e[45]!==R||e[46]!==b?(N=(0,r.jsxs)("select",{"aria-label":k,className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"lg-req-outcome",onChange:t,value:c,children:[S,R,b]}),e[41]=t,e[42]=c,e[43]=k,e[44]=S,e[45]=R,e[46]=b,e[47]=N):N=e[47];let F;return e[48]!==N||e[49]!==g||e[50]!==f||e[51]!==w?(F=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[g,f,w,N]}),e[48]=N,e[49]=g,e[50]=f,e[51]=w,e[52]=F):F=e[52],F},"je"),Oe=v(i=>{let e=(0,K.c)(7),{bucket:t}=i,s;e[0]!==t.key?(s=(0,r.jsx)("span",{className:"truncate text-muted-foreground",role:"gridcell",children:t.key}),e[0]=t.key,e[1]=s):s=e[1];let n;e[2]!==t.count?(n=(0,r.jsx)("span",{className:"shrink-0 tabular-nums",role:"gridcell",children:t.count}),e[2]=t.count,e[3]=n):n=e[3];let o;return e[4]!==s||e[5]!==n?(o=(0,r.jsxs)("div",{className:"flex items-center justify-between gap-4 px-3 py-1 font-mono text-xs","data-testid":"logs-summary-row",role:"row",children:[s,n]}),e[4]=s,e[5]=n,e[6]=o):o=e[6],o},"pe"),He=v(i=>{let e=(0,K.c)(31),{summary:t}=i,s=z(),n;e[0]!==t.total||e[1]!==s?(n=s("{count} entries",{count:t.total}),e[0]=t.total,e[1]=s,e[2]=n):n=e[2];let o;e[3]!==n?(o=(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"logs-summary-total",children:n}),e[3]=n,e[4]=o):o=e[4];let c;e[5]!==s?(c=s("By level"),e[5]=s,e[6]=c):c=e[6];let p;e[7]!==c?(p=(0,r.jsx)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:c}),e[7]=c,e[8]=p):p=e[8];let m;e[9]!==t.byLevel?(m=t.byLevel.map(Je),e[9]=t.byLevel,e[10]=m):m=e[10];let d;e[11]!==m?(d=(0,r.jsx)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-levels",role:"grid",children:m}),e[11]=m,e[12]=d):d=e[12];let a;e[13]!==p||e[14]!==d?(a=(0,r.jsxs)("div",{children:[p,d]}),e[13]=p,e[14]=d,e[15]=a):a=e[15];let h;e[16]!==s?(h=s("By function"),e[16]=s,e[17]=h):h=e[17];let l;e[18]!==h?(l=(0,r.jsx)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h}),e[18]=h,e[19]=l):l=e[19];let g;e[20]!==t.byPath?(g=t.byPath.map(Xe),e[20]=t.byPath,e[21]=g):g=e[21];let u;e[22]!==g?(u=(0,r.jsx)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-paths",role:"grid",children:g}),e[22]=g,e[23]=u):u=e[23];let x;e[24]!==u||e[25]!==l?(x=(0,r.jsxs)("div",{children:[l,u]}),e[24]=u,e[25]=l,e[26]=x):x=e[26];let f;return e[27]!==x||e[28]!==o||e[29]!==a?(f=(0,r.jsxs)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"logs-summary",children:[o,a,x]}),e[27]=x,e[28]=o,e[29]=a,e[30]=f):f=e[30],f},"Je");function Je(i){return(0,r.jsx)(Oe,{bucket:i},i.key)}v(Je,"Xe");function Xe(i){return(0,r.jsx)(Oe,{bucket:i},i.key)}v(Xe,"Ze");var Ze=v(i=>{let e=(0,K.c)(46),{liveError:t,onShardKeyChange:s,onShowArchive:n,onShowErrors:o,onShowRequests:c,shardKey:p,view:m}=i,d=z(),a=m==="requests",h=m==="requests"?"bg-muted font-medium":"text-muted-foreground",l;e[0]!==h?(l=W("px-3 py-1 text-sm",h),e[0]=h,e[1]=l):l=e[1];let g;e[2]!==d?(g=d("Requests"),e[2]=d,e[3]=g):g=e[3];let u;e[4]!==c||e[5]!==a||e[6]!==l||e[7]!==g?(u=(0,r.jsx)("button",{"aria-selected":a,className:l,"data-testid":"lg-view-requests",onClick:c,role:"tab",type:"button",children:g}),e[4]=c,e[5]=a,e[6]=l,e[7]=g,e[8]=u):u=e[8];let x=m==="errors",f=m==="errors"?"bg-muted font-medium":"text-muted-foreground",C;e[9]!==f?(C=W("px-3 py-1 text-sm",f),e[9]=f,e[10]=C):C=e[10];let y;e[11]!==d?(y=d("Errors"),e[11]=d,e[12]=y):y=e[12];let w;e[13]!==o||e[14]!==x||e[15]!==C||e[16]!==y?(w=(0,r.jsx)("button",{"aria-selected":x,className:C,"data-testid":"lg-view-errors",onClick:o,role:"tab",type:"button",children:y}),e[13]=o,e[14]=x,e[15]=C,e[16]=y,e[17]=w):w=e[17];let k=m==="archive",L=m==="archive"?"bg-muted font-medium":"text-muted-foreground",S;e[18]!==L?(S=W("px-3 py-1 text-sm",L),e[18]=L,e[19]=S):S=e[19];let T;e[20]!==d?(T=d("Archive"),e[20]=d,e[21]=T):T=e[21];let R;e[22]!==n||e[23]!==k||e[24]!==S||e[25]!==T?(R=(0,r.jsx)("button",{"aria-selected":k,className:S,"data-testid":"lg-view-archive",onClick:n,role:"tab",type:"button",children:T}),e[22]=n,e[23]=k,e[24]=S,e[25]=T,e[26]=R):R=e[26];let P;e[27]!==w||e[28]!==R||e[29]!==u?(P=(0,r.jsxs)("div",{className:"inline-flex overflow-hidden rounded-lg border border-border",role:"tablist",children:[u,w,R]}),e[27]=w,e[28]=R,e[29]=u,e[30]=P):P=e[30];let b;e[31]!==s||e[32]!==p?(b=(0,r.jsx)(ve,{onChange:s,testId:"lg-shard-input",value:p}),e[31]=s,e[32]=p,e[33]=b):b=e[33];let N;e[34]!==t||e[35]!==m?(N=m!=="archive"&&(0,r.jsx)(Ce,{message:t,prefix:"lg"}),e[34]=t,e[35]=m,e[36]=N):N=e[36];let F;e[37]!==d?(F=d("Open in Cloudflare"),e[37]=d,e[38]=F):F=e[38];let E;e[39]!==F?(E=(0,r.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"lg-cf-link",href:de,rel:"noreferrer",target:"_blank",children:F}),e[39]=F,e[40]=E):E=e[40];let O;return e[41]!==P||e[42]!==b||e[43]!==N||e[44]!==E?(O=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[P,b,N,E]}),e[41]=P,e[42]=b,e[43]=N,e[44]=E,e[45]=O):O=e[45],O},"et"),ce=400,et=36,tt={height:ce,overflow:"auto"},Ke={left:0,position:"absolute",top:0,width:"100%"},rt={error:"destructive",ok:"secondary"},Me=v(i=>{let e=(0,K.c)(6),{onOpenTrace:t,traceId:s}=i,n=z(),o;e[0]!==t||e[1]!==n||e[2]!==s?(o=s===void 0?null:(0,r.jsx)("button",{className:"text-primary underline-offset-2 hover:underline","data-testid":"lg-trace-link",onClick:v(()=>{t(s)},"onClick"),type:"button",children:n("Trace")}),e[0]=t,e[1]=n,e[2]=s,e[3]=o):o=e[3];let c;return e[4]!==o?(c=(0,r.jsx)("span",{className:"w-16 shrink-0 text-right",role:"gridcell",children:o}),e[4]=o,e[5]=c):c=e[5],c},"be"),at=v(i=>{let e=(0,K.c)(13),{entry:t,index:s,measureRef:n,onOpenTrace:o,start:c}=i,p=`translateY(${String(c)}px)`,m;e[0]!==p?(m={...Ke,transform:p},e[0]=p,e[1]=m):m=e[1];let d=m,a;e[2]!==t?(a=(0,r.jsx)(qe,{entry:t}),e[2]=t,e[3]=a):a=e[3];let h;e[4]!==t.traceId||e[5]!==o?(h=(0,r.jsx)(Me,{onOpenTrace:o,traceId:t.traceId}),e[4]=t.traceId,e[5]=o,e[6]=h):h=e[6];let l;return e[7]!==s||e[8]!==n||e[9]!==d||e[10]!==a||e[11]!==h?(l=(0,r.jsxs)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":s,"data-testid":"lg-row",ref:n,role:"row",style:d,children:[a,h]}),e[7]=s,e[8]=n,e[9]=d,e[10]=a,e[11]=h,e[12]=l):l=e[12],l},"lt"),Fe=v(i=>i.length===0?"\u2014":i.join(", "),"ce"),lt=v(i=>{let e=(0,K.c)(41),{entry:t,index:s,measureRef:n,onOpenTrace:o,start:c}=i,p=`translateY(${String(c)}px)`,m;e[0]!==p?(m={...Ke,transform:p},e[0]=p,e[1]=m):m=e[1];let d=m,a;e[2]!==t.ts?(a=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=a):a=e[3];let h;e[4]!==a?(h=(0,r.jsx)("span",{className:"w-40 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:a}),e[4]=a,e[5]=h):h=e[5];let l=rt[t.outcome],g;e[6]!==t.outcome||e[7]!==l?(g=(0,r.jsx)("span",{className:"w-16 shrink-0",role:"gridcell",children:(0,r.jsx)(ne,{variant:l,children:t.outcome})}),e[6]=t.outcome,e[7]=l,e[8]=g):g=e[8];let u;e[9]!==t.functionPath?(u=(0,r.jsx)("span",{className:"w-44 shrink-0 truncate",role:"gridcell",title:t.functionPath,children:t.functionPath}),e[9]=t.functionPath,e[10]=u):u=e[10];let x=t.shardKey??"\u2014",f;e[11]!==x?(f=(0,r.jsx)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:x}),e[11]=x,e[12]=f):f=e[12];let C=t.userId??"\u2014",y;e[13]!==C?(y=(0,r.jsx)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:C}),e[13]=C,e[14]=y):y=e[14];let w;e[15]!==t.durationMs?(w=Math.round(t.durationMs),e[15]=t.durationMs,e[16]=w):w=e[16];let k=`${String(w)}ms`,L;e[17]!==k?(L=(0,r.jsx)("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:k}),e[17]=k,e[18]=L):L=e[18];let S;e[19]!==t.errorMessage||e[20]!==t.outcome||e[21]!==t.tablesRead||e[22]!==t.tablesWritten?(S=t.outcome==="error"&&t.errorMessage!==void 0?t.errorMessage:`r:${Fe(t.tablesRead)} \xB7 w:${Fe(t.tablesWritten)}`,e[19]=t.errorMessage,e[20]=t.outcome,e[21]=t.tablesRead,e[22]=t.tablesWritten,e[23]=S):S=e[23];let T;e[24]!==S?(T=(0,r.jsx)("span",{className:"flex-1 truncate text-muted-foreground",role:"gridcell",children:S}),e[24]=S,e[25]=T):T=e[25];let R;e[26]!==t.traceId||e[27]!==o?(R=(0,r.jsx)(Me,{onOpenTrace:o,traceId:t.traceId}),e[26]=t.traceId,e[27]=o,e[28]=R):R=e[28];let P;return e[29]!==s||e[30]!==n||e[31]!==d||e[32]!==y||e[33]!==L||e[34]!==T||e[35]!==R||e[36]!==h||e[37]!==g||e[38]!==u||e[39]!==f?(P=(0,r.jsxs)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":s,"data-testid":"lg-req-row",ref:n,role:"row",style:d,children:[h,g,u,f,y,L,T,R]}),e[29]=s,e[30]=n,e[31]=d,e[32]=y,e[33]=L,e[34]=T,e[35]=R,e[36]=h,e[37]=g,e[38]=u,e[39]=f,e[40]=P):P=e[40],P},"ot"),Ee=v(i=>{let{entries:e}=i??{};return Array.isArray(e)?e:[]},"de"),ot=v(i=>{let e={};return i.functionPathPrefix.trim()!==""&&(e.functionPathPrefix=i.functionPathPrefix.trim()),i.userId.trim()!==""&&(e.userId=i.userId.trim()),i.tableTouched.trim()!==""&&(e.tableTouched=i.tableTouched.trim()),(i.outcome==="ok"||i.outcome==="error")&&(e.outcome=i.outcome),e},"nt"),nt={"5m":300*1e3,"15m":900*1e3,"1h":3600*1e3},st=v((i,e)=>{let t=e.search.trim().toLowerCase(),s=e.path.trim().toLowerCase(),n=e.range==="all"?Number.NEGATIVE_INFINITY:e.now-nt[e.range];return i.filter(o=>e.levels.size>0&&!e.levels.has(o.level)||o.timestamp<n||s!==""&&!(o.functionPath??"").toLowerCase().includes(s)?!1:t===""||o.message.toLowerCase().includes(t)||Te(o.fields).toLowerCase().includes(t))},"it"),it="\u2014",dt=v(i=>{let e=new Map,t=new Map;for(let o of i){e.set(o.level,(e.get(o.level)??0)+1);let c=o.functionPath??it;t.set(c,(t.get(c)??0)+1)}let s=ue.filter(o=>e.has(o)).map(o=>({count:e.get(o)??0,key:o})),n=[...t.entries()].map(([o,c])=>({count:c,key:o})).toSorted((o,c)=>c.count===o.count?o.key.localeCompare(c.key):c.count-o.count);return{byLevel:s,byPath:n,total:i.length}},"dt"),Et=v(({initialShardKey:i})=>{let e=z(),[t,s]=(0,q.useState)("requests"),{queryShardKey:n,setShardKey:o,shardKey:c}=be(i),[p,m]=(0,q.useState)(""),[d,a]=(0,q.useState)(()=>new Set),[h,l]=(0,q.useState)(""),[g,u]=(0,q.useState)("all"),[x,f]=(0,q.useState)(!1),[C,y]=(0,q.useState)(""),[w,k]=(0,q.useState)(""),[L,S]=(0,q.useState)(""),[T,R]=(0,q.useState)("all"),P=ot({functionPathPrefix:C,outcome:T,tableTouched:L,userId:w}),b=le(oe.getRequestLog,P,{enabled:t==="requests",live:!0,shardKey:n}),N=le(oe.getLogs,{},{enabled:t==="errors",live:!0,shardKey:n}),F=t==="requests"?b:N,{error:E,errorSource:O,isLoading:M,liveError:V}=F,_=Se(n),U=Ee(N.data),A=Ee(b.data);(0,q.useEffect)(()=>{F.data!==void 0&&fe(n)},[F.data,n]);let $=st(U,{levels:d,now:Date.now(),path:h,range:g,search:p}),Q=dt($),X=t==="requests"?A.length:$.length,Z=t==="errors"&&x,Y=(0,q.useMemo)(()=>E!==null?"error":X===0?M?Z?"summary":"list":"empty":Z?"summary":"list",[X,M,E,Z]),me=(0,q.useRef)(null),G=ke({count:X,estimateSize:v(()=>et,"estimateSize"),getItemKey:v(I=>t==="errors"?$[I]?.id??I:I,"getItemKey"),getScrollElement:v(()=>me.current,"getScrollElement"),initialRect:{height:ce,width:800},observeElementRect:v((I,ee)=>Le(I,ee,ce),"observeElementRect"),overscan:8}),_e=G.getVirtualItems(),Ae={height:G.getTotalSize(),position:"relative",width:"100%"};return(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-logs",children:[(0,r.jsx)(Ze,{liveError:V,onShardKeyChange:o,onShowArchive:v(()=>{s("archive"),f(!1)},"onShowArchive"),onShowErrors:v(()=>{s("errors"),f(!1)},"onShowErrors"),onShowRequests:v(()=>{s("requests"),f(!1)},"onShowRequests"),shardKey:c,view:t}),t==="errors"&&(0,r.jsx)(Ye,{levelFilter:d,onLogPathChange:v(I=>{l(I.target.value)},"onLogPathChange"),onSearchChange:v(I=>{m(I.target.value)},"onSearchChange"),onTimeRangeChange:v(I=>{u(I.target.value)},"onTimeRangeChange"),onToggleLevel:v(I=>{a(ee=>{let H=new Set(ee);return H.has(I)?H.delete(I):H.add(I),H})},"onToggleLevel"),onToggleSummary:v(()=>{f(I=>!I)},"onToggleSummary"),pathFilter:h,search:p,showSummary:x,timeRange:g}),t==="requests"&&(0,r.jsx)(Ge,{onOutcomeChange:v(I=>{R(I.target.value)},"onOutcomeChange"),onPathChange:v(I=>{y(I.target.value)},"onPathChange"),onTableChange:v(I=>{S(I.target.value)},"onTableChange"),onUserChange:v(I=>{k(I.target.value)},"onUserChange"),outcomeFilter:T,pathPrefix:C,tableFilter:L,userIdFilter:w}),t==="archive"?(0,r.jsx)(Ve,{shardKey:n}):(0,r.jsxs)(r.Fragment,{children:[Y==="error"&&(0,r.jsx)(xe,{error:O,shardKey:n,testId:"lg-error"}),Y==="empty"&&(0,r.jsx)(J,{description:e("Function and request logs for this shard show up here as your app handles traffic."),icon:(0,r.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M4 5h16M4 12h16M4 19h10"})}),testId:"lg-empty",title:e("No logs.")}),Y==="summary"&&(0,r.jsx)(He,{summary:Q}),Y==="list"&&(0,r.jsx)("div",{className:"rounded-xl border border-border shadow-xs","data-testid":"lg-scroll",ref:me,style:tt,children:(0,r.jsx)("div",{"aria-label":e("Recent logs"),"data-testid":"lg-table",role:"grid",style:Ae,children:_e.map(I=>t==="requests"?(0,r.jsx)(lt,{entry:A[I.index],index:I.index,measureRef:G.measureElement,onOpenTrace:_,start:I.start},I.key):(0,r.jsx)(at,{entry:$[I.index],index:I.index,measureRef:G.measureElement,onOpenTrace:_,start:I.start},I.key))})})]})]})},"jt");export{Et as LogsPanel,st as filterLogs,dt as summarizeLogs};
@@ -1 +1 @@
1
- import{B as y,r as w}from"./chunk-PN7JHEYW.js";import{a as v}from"./chunk-A6TVTNKO.js";import{b as _}from"./chunk-ADABTCDI.js";import{a as m,d as g}from"./chunk-5PEAXTYQ.js";var x=g(v(),1);var a=g(_(),1);var k=m((s,e)=>{if(e==="")return[{match:!1,offset:0,text:s}];let n=[],l=s.toLowerCase(),o=e.toLowerCase(),t=0;for(let r=l.indexOf(o);r!==-1;r=l.indexOf(o,t))r>t&&n.push({match:!1,offset:t,text:s.slice(t,r)}),n.push({match:!0,offset:r,text:s.slice(r,r+e.length)}),t=r+e.length;return t<s.length&&n.push({match:!1,offset:t,text:s.slice(t)}),n},"N"),L=m(s=>{let e=(0,x.c)(9),{highlight:n,value:l}=s;if(l==null){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=(0,a.jsx)("span",{className:"text-muted-foreground/50 italic",children:"NULL"}),e[0]=d):d=e[0],d}let o,t,r;if(e[1]!==n||e[2]!==l){r=Symbol.for("react.early_return_sentinel");e:{let d=w(l);if(n===void 0||n===""){r=(0,a.jsx)("span",{title:d,children:d});break e}o=d,t=k(d,n).map(j)}e[1]=n,e[2]=l,e[3]=o,e[4]=t,e[5]=r}else o=e[3],t=e[4],r=e[5];if(r!==Symbol.for("react.early_return_sentinel"))return r;let c;return e[6]!==o||e[7]!==t?(c=(0,a.jsx)("span",{title:o,children:t}),e[6]=o,e[7]=t,e[8]=c):c=e[8],c},"v"),O=m(s=>{let e=(0,x.c)(22),{columns:n,rows:l}=s,o=y(),t;e[0]!==o?(t=o("Field"),e[0]=o,e[1]=t):t=e[1];let r;e[2]!==t?(r=(0,a.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:t}),e[2]=t,e[3]=r):r=e[3];let c;if(e[4]!==l||e[5]!==o){let i;e[7]!==o?(i=m((b,p)=>(0,a.jsx)("th",{className:"border-b border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase tabular-nums text-muted-foreground",children:o("Row {n}",{n:p+1})},p),"c"),e[7]=o,e[8]=i):i=e[8],c=l.map(i),e[4]=l,e[5]=o,e[6]=c}else c=e[6];let d;e[9]!==r||e[10]!==c?(d=(0,a.jsx)("thead",{className:"sticky top-0 z-10 bg-muted",children:(0,a.jsxs)("tr",{children:[r,c]})}),e[9]=r,e[10]=c,e[11]=d):d=e[11];let f;if(e[12]!==n||e[13]!==l){let i;e[15]!==l?(i=m(b=>(0,a.jsxs)("tr",{className:"hover:bg-muted/40",children:[(0,a.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono font-medium whitespace-nowrap",scope:"row",children:b}),l.map((p,N)=>(0,a.jsx)("td",{className:"max-w-md truncate border-b border-border px-3 py-1.5 font-mono",children:(0,a.jsx)(L,{value:p[b]})},N))]},b),"c"),e[15]=l,e[16]=i):i=e[16],f=n.map(i),e[12]=n,e[13]=l,e[14]=f}else f=e[14];let h;e[17]!==f?(h=(0,a.jsx)("tbody",{children:f}),e[17]=f,e[18]=h):h=e[18];let u;return e[19]!==d||e[20]!==h?(u=(0,a.jsx)("div",{className:"min-h-0 flex-1 overflow-auto","data-testid":"db-transposed",children:(0,a.jsxs)("table",{className:"border-collapse text-xs",children:[d,h]})}),e[19]=d,e[20]=h,e[21]=u):u=e[21],u},"T"),T=m(({children:s,layout:e="card",testId:n})=>(0,a.jsx)("div",{className:e==="fill"?"flex min-h-0 flex-1 flex-col overflow-hidden border-t border-border":"overflow-x-auto border border-border bg-card","data-testid":n,children:s}),"j");function j(s){return(0,a.jsx)("mark",{className:s.match?"rounded-sm bg-warning/40 text-foreground":"bg-transparent text-inherit",children:s.text},s.offset)}m(j,"_");export{L as a,O as b,T as c};
1
+ import{B as y,r as w}from"./chunk-2ZJJH4YN.js";import{a as v}from"./chunk-A6TVTNKO.js";import{b as _}from"./chunk-ADABTCDI.js";import{a as m,d as g}from"./chunk-5PEAXTYQ.js";var x=g(v(),1);var a=g(_(),1);var k=m((s,e)=>{if(e==="")return[{match:!1,offset:0,text:s}];let n=[],l=s.toLowerCase(),o=e.toLowerCase(),t=0;for(let r=l.indexOf(o);r!==-1;r=l.indexOf(o,t))r>t&&n.push({match:!1,offset:t,text:s.slice(t,r)}),n.push({match:!0,offset:r,text:s.slice(r,r+e.length)}),t=r+e.length;return t<s.length&&n.push({match:!1,offset:t,text:s.slice(t)}),n},"N"),L=m(s=>{let e=(0,x.c)(9),{highlight:n,value:l}=s;if(l==null){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=(0,a.jsx)("span",{className:"text-muted-foreground/50 italic",children:"NULL"}),e[0]=d):d=e[0],d}let o,t,r;if(e[1]!==n||e[2]!==l){r=Symbol.for("react.early_return_sentinel");e:{let d=w(l);if(n===void 0||n===""){r=(0,a.jsx)("span",{title:d,children:d});break e}o=d,t=k(d,n).map(j)}e[1]=n,e[2]=l,e[3]=o,e[4]=t,e[5]=r}else o=e[3],t=e[4],r=e[5];if(r!==Symbol.for("react.early_return_sentinel"))return r;let c;return e[6]!==o||e[7]!==t?(c=(0,a.jsx)("span",{title:o,children:t}),e[6]=o,e[7]=t,e[8]=c):c=e[8],c},"v"),O=m(s=>{let e=(0,x.c)(22),{columns:n,rows:l}=s,o=y(),t;e[0]!==o?(t=o("Field"),e[0]=o,e[1]=t):t=e[1];let r;e[2]!==t?(r=(0,a.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:t}),e[2]=t,e[3]=r):r=e[3];let c;if(e[4]!==l||e[5]!==o){let i;e[7]!==o?(i=m((b,p)=>(0,a.jsx)("th",{className:"border-b border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase tabular-nums text-muted-foreground",children:o("Row {n}",{n:p+1})},p),"c"),e[7]=o,e[8]=i):i=e[8],c=l.map(i),e[4]=l,e[5]=o,e[6]=c}else c=e[6];let d;e[9]!==r||e[10]!==c?(d=(0,a.jsx)("thead",{className:"sticky top-0 z-10 bg-muted",children:(0,a.jsxs)("tr",{children:[r,c]})}),e[9]=r,e[10]=c,e[11]=d):d=e[11];let f;if(e[12]!==n||e[13]!==l){let i;e[15]!==l?(i=m(b=>(0,a.jsxs)("tr",{className:"hover:bg-muted/40",children:[(0,a.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono font-medium whitespace-nowrap",scope:"row",children:b}),l.map((p,N)=>(0,a.jsx)("td",{className:"max-w-md truncate border-b border-border px-3 py-1.5 font-mono",children:(0,a.jsx)(L,{value:p[b]})},N))]},b),"c"),e[15]=l,e[16]=i):i=e[16],f=n.map(i),e[12]=n,e[13]=l,e[14]=f}else f=e[14];let h;e[17]!==f?(h=(0,a.jsx)("tbody",{children:f}),e[17]=f,e[18]=h):h=e[18];let u;return e[19]!==d||e[20]!==h?(u=(0,a.jsx)("div",{className:"min-h-0 flex-1 overflow-auto","data-testid":"db-transposed",children:(0,a.jsxs)("table",{className:"border-collapse text-xs",children:[d,h]})}),e[19]=d,e[20]=h,e[21]=u):u=e[21],u},"T"),T=m(({children:s,layout:e="card",testId:n})=>(0,a.jsx)("div",{className:e==="fill"?"flex min-h-0 flex-1 flex-col overflow-hidden border-t border-border":"overflow-x-auto border border-border bg-card","data-testid":n,children:s}),"j");function j(s){return(0,a.jsx)("mark",{className:s.match?"rounded-sm bg-warning/40 text-foreground":"bg-transparent text-inherit",children:s.text},s.offset)}m(j,"_");export{L as a,O as b,T as c};
@@ -1,4 +1,4 @@
1
- import{a as P}from"./chunk-SNJ3ZOV2.js";import{a as V,b as F,c as J,d as K,e as B,f as A,g as I,h as M}from"./chunk-QAETUNZX.js";import{a as z}from"./chunk-DWNWEMQK.js";import{B as L,p as D,r as U,s as Q,v as W}from"./chunk-PN7JHEYW.js";import{a as te}from"./chunk-A6TVTNKO.js";import{a as ee,b as le}from"./chunk-ADABTCDI.js";import{a as g,d as q}from"./chunk-5PEAXTYQ.js";var _=q(te(),1),E=q(ee(),1);var T="inline-flex items-center gap-1 rounded-md border border-border px-2.5 py-1 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50",fe=`${T} aria-pressed:bg-accent aria-pressed:text-accent-foreground`;var s=q(le(),1);var X=g(l=>`"${l.replaceAll('"','""')}"`,"q"),ne=/["\n\r,]/u,oe=/^[=+\-@\t\r]/u,Y=g(l=>{if(l==null)return"";let e;return typeof l=="string"?e=oe.test(l)?` ${l}`:l:typeof l=="number"||typeof l=="boolean"||typeof l=="bigint"?e=String(l):e=U(l),ne.test(e)?`"${e.replaceAll('"','""')}"`:e},"J"),ae=g((l,e)=>{let n=l.map(t=>Y(t)).join(","),o=e.map(t=>l.map(c=>Y(t[c])).join(","));return[n,...o].join(`
1
+ import{a as P}from"./chunk-UL5XVKGR.js";import{a as V,b as F,c as J,d as K,e as B,f as A,g as I,h as M}from"./chunk-CQDENTSP.js";import{a as z}from"./chunk-W5BTAOHO.js";import{B as L,p as D,r as U,s as Q,v as W}from"./chunk-2ZJJH4YN.js";import{a as te}from"./chunk-A6TVTNKO.js";import{a as ee,b as le}from"./chunk-ADABTCDI.js";import{a as g,d as q}from"./chunk-5PEAXTYQ.js";var _=q(te(),1),E=q(ee(),1);var T="inline-flex items-center gap-1 rounded-md border border-border px-2.5 py-1 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50",fe=`${T} aria-pressed:bg-accent aria-pressed:text-accent-foreground`;var s=q(le(),1);var X=g(l=>`"${l.replaceAll('"','""')}"`,"q"),ne=/["\n\r,]/u,oe=/^[=+\-@\t\r]/u,Y=g(l=>{if(l==null)return"";let e;return typeof l=="string"?e=oe.test(l)?` ${l}`:l:typeof l=="number"||typeof l=="boolean"||typeof l=="bigint"?e=String(l):e=U(l),ne.test(e)?`"${e.replaceAll('"','""')}"`:e},"J"),ae=g((l,e)=>{let n=l.map(t=>Y(t)).join(","),o=e.map(t=>l.map(c=>Y(t[c])).join(","));return[n,...o].join(`
2
2
  `)},"ne"),se=g(l=>JSON.stringify(l,D,2),"oe"),Z=500,re=g(l=>l==null?"NULL":typeof l=="number"?Number.isFinite(l)?String(l):"NULL":typeof l=="bigint"?String(l):typeof l=="boolean"?l?"1":"0":`'${(typeof l=="string"?l:U(l)).replaceAll("'","''")}'`,"K"),G="__doc__",ie=g((l,e,n,o)=>{if(e.length===0||n.length===0)return"";let t=o?.includes(G)===!0&&!e.includes(G)?e.filter(d=>!o.includes(d)):void 0,c=t===void 0?e:o,r=g((d,b)=>re(t===void 0||b!==G?d[b]:JSON.stringify(Object.fromEntries(t.map(u=>[u,d[u]])),D)),"i"),a=c.map(d=>X(d)).join(", "),i=[];for(let d=0;d<n.length;d+=Z){let b=n.slice(d,d+Z).map(u=>` (${c.map(m=>r(u,m)).join(", ")})`).join(`,
3
3
  `);i.push(`INSERT INTO ${X(l)} (${a}) VALUES
4
4
  ${b};`)}return i.join(`
@@ -1 +1 @@
1
- import{g as j,h as g,i as D,n as q}from"./chunk-QB75Q7U4.js";import{h as v,i as S,j as P,s as w}from"./chunk-PN7JHEYW.js";import{a as M}from"./chunk-A6TVTNKO.js";import{a as L}from"./chunk-ADABTCDI.js";import{a as i,d as A}from"./chunk-5PEAXTYQ.js";var E=A(M(),1);var p=A(L(),1);var I=300,l=i(t=>typeof t=="string"?t===""?void 0:t:typeof t=="number"||typeof t=="boolean"?String(t):void 0,"c"),u=i(t=>t.filter(r=>r!==void 0).join(" "),"u"),T=i(t=>{let r=Array.isArray(t.filters)?t.filters.length:0,e=typeof t.search=="string"&&t.search!=="";return r===0&&!e?"no predicate":u([r===0?void 0:`${String(r)} filters`,e?"search":void 0])},"q"),N={clearTable:i(t=>u([l(t.table),"whole table"]),"clearTable"),deleteRows:i(t=>u([l(t.table),T(t)]),"deleteRows"),facetColumn:i(t=>u([l(t.table),l(t.column)]),"facetColumn"),importShard:i(t=>{if(!Array.isArray(t.rows))return"";let r=[...new Set(t.rows.filter(e=>typeof e=="object"&&e!==null).map(e=>e.table).filter(e=>typeof e=="string"))].toSorted((e,s)=>e.localeCompare(s));return u([`${String(t.rows.length)} rows`,r.length===0?void 0:`into ${r.join(", ")}`])},"importShard"),lintSql:i(()=>"sql","lintSql"),patchRows:i(t=>u([l(t.table),typeof t.doc=="object"&&t.doc!==null?`set ${Object.keys(t.doc).join(", ")}`:void 0,T(t)]),"patchRows"),pitrRestore:i(t=>u([l(t.time)===void 0?void 0:`to ${String(t.time)}`,typeof t.bookmark=="string"&&t.bookmark!==""?"from bookmark":void 0,t.restart===!0?"restart now":void 0]),"pitrRestore"),readTablePage:i(t=>u([l(t.table),Array.isArray(t.filters)&&t.filters.length>0?`${String(t.filters.length)} filters`:void 0,typeof t.search=="string"&&t.search!==""?"search":void 0,typeof t.limit=="number"?`limit ${String(t.limit)}`:void 0]),"readTablePage"),runMigration:i(t=>u([l(t.id),l(t.direction),t.dryRun===!0?"dry-run":void 0]),"runMigration"),runSql:i(t=>typeof t.sql=="string"?`${String(t.sql.length)} chars`:"","runSql"),schemaVersion:i(t=>typeof t.hash=="string"?t.hash.slice(0,8):"","schemaVersion"),writeRow:i(t=>u([l(t.table),"1 row"]),"writeRow")},$="__lunora_admin__:",F=i((t,r)=>{let e=t.startsWith($)?t.slice($.length):t,s=N[e];if(s!==void 0)return s(r);let n=Object.keys(r);return n.length===0?"":n.join(", ")},"M"),V=i(t=>{if(Array.isArray(t))return t.length;if(!(typeof t!="object"||t===null)){for(let r of Object.values(t))if(Array.isArray(r))return r.length}},"K"),k=class{static{i(this,"x")}entries=[];listeners=new Set;nextSeq=1;getSnapshot=i(()=>this.entries,"getSnapshot");subscribe=i(r=>(this.listeners.add(r),()=>{this.listeners.delete(r)}),"subscribe");start(r,e,s){return this.append(r,e,s,"call","pending")}startSubscription(r,e,s){return this.append(r,e,s,"subscription","live")}recordPush(r){if(this.listeners.size===0){let e=this.entries.find(s=>s.seq===r);e!==void 0&&(e.pushes=(e.pushes??0)+1);return}this.patch(r,e=>({...e,pushes:(e.pushes??0)+1}))}failSubscription(r,e){this.patch(r,s=>({...s,error:e,status:"error"}))}endSubscription(r){this.patch(r,e=>e.status==="error"?e:{...e,durationMs:Date.now()-e.startedAt,status:"closed"})}lastErrorSeq(){return this.entries.findLast(r=>r.status==="error")?.seq}settle(r,e){this.patch(r,s=>({...s,durationMs:Date.now()-s.startedAt,...e.error===void 0?{resultCount:V(e.result),status:"ok"}:{error:e.error,status:"error"}}))}clear(){this.entries=[],this.emit()}append(r,e,s,n,a){let d=this.nextSeq;this.nextSeq+=1;let c={functionPath:r,kind:n,seq:d,shardKey:s,startedAt:Date.now(),status:a,summary:F(r,e),...n==="subscription"?{pushes:0}:{}},o=[...this.entries,c];return this.entries=o.length>I?o.slice(o.length-I):o,this.emit(),d}patch(r,e){let s=this.entries.findIndex(n=>n.seq===r);s!==-1&&(this.entries=this.entries.with(s,e(this.entries[s])),this.emit())}emit(){for(let r of this.listeners)r()}},f=new k,O=i((t,r,e)=>["lunora-admin",t,r,e.trim()],"E"),_=i((t,r)=>[...t,r],"g");function W(t,r,e={}){let s=q(),{enabled:n=!0,keepPreviousData:a=!1,staleTime:d=0}=e,c=_(t,s.clientIdentifier()),o=D({enabled:n,queryFn:r,placeholderData:a?j:void 0,queryKey:c,staleTime:d});return{data:o.data,error:o.error?P(o.error):o.error,errorSource:o.error??void 0,isLoading:o.isLoading,liveError:void 0,refetch:i(()=>{w(o.refetch())},"refetch"),poll:i(async()=>{await o.refetch({throwOnError:!0})},"poll")}}i(W,"F");function Y(t,r,e={}){let s=q(),n=g(),{enabled:a=!0,keepPreviousData:d=!1,live:c=!1,shardKey:o="",staleTime:R}=e,m=O(t,r,o),C=W(m,()=>s.query(v(t),r,S(o)),{enabled:a,keepPreviousData:d,staleTime:R??(c?Number.POSITIVE_INFINITY:0)}),[K,b]=(0,p.useState)(void 0),Q=JSON.stringify(m);return(0,p.useEffect)(()=>{if(!a||!c)return;b(void 0);let y=f.startSubscription(t,r,o),x=s.subscribe(v(t),r,h=>{f.recordPush(y),b(void 0),n.setQueryData(_(m,s.clientIdentifier()),h)},{...S(o),onError:i(h=>{f.failSubscription(y,h.message),b(h.message)},"onError")});return()=>{f.endSubscription(y),x()}},[s,Q,a,c]),{...C,liveError:a&&c?K:void 0}}i(Y,"U");var B=i(()=>{let t=(0,E.c)(2),r=g(),e;return t[0]!==r?(e=i((s,n,a)=>{let d=n===void 0?["lunora-admin",s]:O(s,n,a??"");w(r.invalidateQueries({queryKey:d}))},"r"),t[0]=r,t[1]=e):e=t[1],e},"W");export{f as a,W as b,Y as c,B as d};
1
+ import{g as j,h as g,i as D,n as q}from"./chunk-QFN62JQJ.js";import{h as v,i as S,j as P,s as w}from"./chunk-2ZJJH4YN.js";import{a as M}from"./chunk-A6TVTNKO.js";import{a as L}from"./chunk-ADABTCDI.js";import{a as i,d as A}from"./chunk-5PEAXTYQ.js";var E=A(M(),1);var p=A(L(),1);var I=300,l=i(t=>typeof t=="string"?t===""?void 0:t:typeof t=="number"||typeof t=="boolean"?String(t):void 0,"c"),u=i(t=>t.filter(r=>r!==void 0).join(" "),"u"),T=i(t=>{let r=Array.isArray(t.filters)?t.filters.length:0,e=typeof t.search=="string"&&t.search!=="";return r===0&&!e?"no predicate":u([r===0?void 0:`${String(r)} filters`,e?"search":void 0])},"q"),N={clearTable:i(t=>u([l(t.table),"whole table"]),"clearTable"),deleteRows:i(t=>u([l(t.table),T(t)]),"deleteRows"),facetColumn:i(t=>u([l(t.table),l(t.column)]),"facetColumn"),importShard:i(t=>{if(!Array.isArray(t.rows))return"";let r=[...new Set(t.rows.filter(e=>typeof e=="object"&&e!==null).map(e=>e.table).filter(e=>typeof e=="string"))].toSorted((e,s)=>e.localeCompare(s));return u([`${String(t.rows.length)} rows`,r.length===0?void 0:`into ${r.join(", ")}`])},"importShard"),lintSql:i(()=>"sql","lintSql"),patchRows:i(t=>u([l(t.table),typeof t.doc=="object"&&t.doc!==null?`set ${Object.keys(t.doc).join(", ")}`:void 0,T(t)]),"patchRows"),pitrRestore:i(t=>u([l(t.time)===void 0?void 0:`to ${String(t.time)}`,typeof t.bookmark=="string"&&t.bookmark!==""?"from bookmark":void 0,t.restart===!0?"restart now":void 0]),"pitrRestore"),readTablePage:i(t=>u([l(t.table),Array.isArray(t.filters)&&t.filters.length>0?`${String(t.filters.length)} filters`:void 0,typeof t.search=="string"&&t.search!==""?"search":void 0,typeof t.limit=="number"?`limit ${String(t.limit)}`:void 0]),"readTablePage"),runMigration:i(t=>u([l(t.id),l(t.direction),t.dryRun===!0?"dry-run":void 0]),"runMigration"),runSql:i(t=>typeof t.sql=="string"?`${String(t.sql.length)} chars`:"","runSql"),schemaVersion:i(t=>typeof t.hash=="string"?t.hash.slice(0,8):"","schemaVersion"),writeRow:i(t=>u([l(t.table),"1 row"]),"writeRow")},$="__lunora_admin__:",F=i((t,r)=>{let e=t.startsWith($)?t.slice($.length):t,s=N[e];if(s!==void 0)return s(r);let n=Object.keys(r);return n.length===0?"":n.join(", ")},"M"),V=i(t=>{if(Array.isArray(t))return t.length;if(!(typeof t!="object"||t===null)){for(let r of Object.values(t))if(Array.isArray(r))return r.length}},"K"),k=class{static{i(this,"x")}entries=[];listeners=new Set;nextSeq=1;getSnapshot=i(()=>this.entries,"getSnapshot");subscribe=i(r=>(this.listeners.add(r),()=>{this.listeners.delete(r)}),"subscribe");start(r,e,s){return this.append(r,e,s,"call","pending")}startSubscription(r,e,s){return this.append(r,e,s,"subscription","live")}recordPush(r){if(this.listeners.size===0){let e=this.entries.find(s=>s.seq===r);e!==void 0&&(e.pushes=(e.pushes??0)+1);return}this.patch(r,e=>({...e,pushes:(e.pushes??0)+1}))}failSubscription(r,e){this.patch(r,s=>({...s,error:e,status:"error"}))}endSubscription(r){this.patch(r,e=>e.status==="error"?e:{...e,durationMs:Date.now()-e.startedAt,status:"closed"})}lastErrorSeq(){return this.entries.findLast(r=>r.status==="error")?.seq}settle(r,e){this.patch(r,s=>({...s,durationMs:Date.now()-s.startedAt,...e.error===void 0?{resultCount:V(e.result),status:"ok"}:{error:e.error,status:"error"}}))}clear(){this.entries=[],this.emit()}append(r,e,s,n,a){let d=this.nextSeq;this.nextSeq+=1;let c={functionPath:r,kind:n,seq:d,shardKey:s,startedAt:Date.now(),status:a,summary:F(r,e),...n==="subscription"?{pushes:0}:{}},o=[...this.entries,c];return this.entries=o.length>I?o.slice(o.length-I):o,this.emit(),d}patch(r,e){let s=this.entries.findIndex(n=>n.seq===r);s!==-1&&(this.entries=this.entries.with(s,e(this.entries[s])),this.emit())}emit(){for(let r of this.listeners)r()}},f=new k,O=i((t,r,e)=>["lunora-admin",t,r,e.trim()],"E"),_=i((t,r)=>[...t,r],"g");function W(t,r,e={}){let s=q(),{enabled:n=!0,keepPreviousData:a=!1,staleTime:d=0}=e,c=_(t,s.clientIdentifier()),o=D({enabled:n,queryFn:r,placeholderData:a?j:void 0,queryKey:c,staleTime:d});return{data:o.data,error:o.error?P(o.error):o.error,errorSource:o.error??void 0,isLoading:o.isLoading,liveError:void 0,refetch:i(()=>{w(o.refetch())},"refetch"),poll:i(async()=>{await o.refetch({throwOnError:!0})},"poll")}}i(W,"F");function Y(t,r,e={}){let s=q(),n=g(),{enabled:a=!0,keepPreviousData:d=!1,live:c=!1,shardKey:o="",staleTime:R}=e,m=O(t,r,o),C=W(m,()=>s.query(v(t),r,S(o)),{enabled:a,keepPreviousData:d,staleTime:R??(c?Number.POSITIVE_INFINITY:0)}),[K,b]=(0,p.useState)(void 0),Q=JSON.stringify(m);return(0,p.useEffect)(()=>{if(!a||!c)return;b(void 0);let y=f.startSubscription(t,r,o),x=s.subscribe(v(t),r,h=>{f.recordPush(y),b(void 0),n.setQueryData(_(m,s.clientIdentifier()),h)},{...S(o),onError:i(h=>{f.failSubscription(y,h.message),b(h.message)},"onError")});return()=>{f.endSubscription(y),x()}},[s,Q,a,c]),{...C,liveError:a&&c?K:void 0}}i(Y,"U");var B=i(()=>{let t=(0,E.c)(2),r=g(),e;return t[0]!==r?(e=i((s,n,a)=>{let d=n===void 0?["lunora-admin",s]:O(s,n,a??"");w(r.invalidateQueries({queryKey:d}))},"r"),t[0]=r,t[1]=e):e=t[1],e},"W");export{f as a,W as b,Y as c,B as d};
@@ -1 +1 @@
1
- import{a as v}from"./chunk-HFPX37U7.js";import{a as A}from"./chunk-XY5UOZMD.js";import{a as W}from"./chunk-2KTN53PK.js";import{a as L}from"./chunk-PAFHBQFL.js";import"./chunk-EDL46BPM.js";import"./chunk-4KPATTV6.js";import"./chunk-OKZINWBB.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import"./chunk-OZID3UYF.js";import{a as G}from"./chunk-S3TDGFRE.js";import{b as $}from"./chunk-UV6GPH2E.js";import"./chunk-L27FKJTG.js";import{a as q}from"./chunk-VXMAQB2K.js";import"./chunk-S7NFUY75.js";import{a as H,b as O,c as Q,d as D,e as T,f as K}from"./chunk-J3ZEO3PJ.js";import"./chunk-3R6W72RH.js";import"./chunk-2L3WHXJV.js";import"./chunk-EOFWXI3T.js";import{a as _}from"./chunk-LYVYUTQY.js";import{c as j}from"./chunk-KDMDI7KA.js";import{a as E}from"./chunk-TN4Z3P6S.js";import"./chunk-QB75Q7U4.js";import"./chunk-ZPQBVYNN.js";import{B}from"./chunk-PN7JHEYW.js";import"./chunk-PDBW6GTJ.js";import{a as J}from"./chunk-A6TVTNKO.js";import{b as V}from"./chunk-ADABTCDI.js";import{a as S,d as F}from"./chunk-5PEAXTYQ.js";var R=F(J(),1);var t=F(V(),1);var U=S(c=>`${c.toString()} ms`,"D"),X=S(c=>c.totalConnections===0&&c.shapePoke.passes===0&&c.whisper.passes===0&&c.shapeProbe.run===0&&c.shapeProbe.served===0&&c.globalPoll.drains===0&&c.globalPoll.pairsSkipped===0,"J"),z=S(c=>{let e=(0,R.c)(48),{counters:o,includeTiming:a,prefix:r,t:l,title:u}=c,d=`${r}-section`,n;e[0]!==u?(n=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:u}),e[0]=u,e[1]=n):n=e[1];let s=`${r}-stats`,i;e[2]!==l?(i=l("Passes"),e[2]=l,e[3]=i):i=e[3];let m=`${r}-passes`,I;e[4]!==o.passes||e[5]!==i||e[6]!==m?(I=(0,t.jsx)(v,{label:i,testId:m,value:o.passes}),e[4]=o.passes,e[5]=i,e[6]=m,e[7]=I):I=e[7];let g;e[8]!==l?(g=l("Sockets iterated"),e[8]=l,e[9]=g):g=e[9];let k=`${r}-iterated`,p;e[10]!==o.socketsIterated||e[11]!==g||e[12]!==k?(p=(0,t.jsx)(v,{label:g,testId:k,value:o.socketsIterated}),e[10]=o.socketsIterated,e[11]=g,e[12]=k,e[13]=p):p=e[13];let f;e[14]!==l?(f=l("Delivered"),e[14]=l,e[15]=f):f=e[15];let y=`${r}-delivered`,h;e[16]!==o.socketsDelivered||e[17]!==f||e[18]!==y?(h=(0,t.jsx)(v,{label:f,testId:y,value:o.socketsDelivered}),e[16]=o.socketsDelivered,e[17]=f,e[18]=y,e[19]=h):h=e[19];let x;e[20]!==l?(x=l("Peak width"),e[20]=l,e[21]=x):x=e[21];let N=`${r}-peak`,b;e[22]!==o.peakSocketsIterated||e[23]!==x||e[24]!==N?(b=(0,t.jsx)(v,{label:x,testId:N,value:o.peakSocketsIterated}),e[22]=o.peakSocketsIterated,e[23]=x,e[24]=N,e[25]=b):b=e[25];let C;e[26]!==o.totalMs||e[27]!==a||e[28]!==r||e[29]!==l?(C=a&&(0,t.jsx)(v,{label:l("Total time"),testId:`${r}-total-ms`,value:U(o.totalMs)}),e[26]=o.totalMs,e[27]=a,e[28]=r,e[29]=l,e[30]=C):C=e[30];let P;e[31]!==o.maxMs||e[32]!==a||e[33]!==r||e[34]!==l?(P=a&&(0,t.jsx)(v,{label:l("Max time"),testId:`${r}-max-ms`,value:U(o.maxMs)}),e[31]=o.maxMs,e[32]=a,e[33]=r,e[34]=l,e[35]=P):P=e[35];let M;e[36]!==h||e[37]!==b||e[38]!==C||e[39]!==P||e[40]!==s||e[41]!==I||e[42]!==p?(M=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":s,children:[I,p,h,b,C,P]}),e[36]=h,e[37]=b,e[38]=C,e[39]=P,e[40]=s,e[41]=I,e[42]=p,e[43]=M):M=e[43];let w;return e[44]!==d||e[45]!==M||e[46]!==n?(w=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":d,children:[n,M]}),e[44]=d,e[45]=M,e[46]=n,e[47]=w):w=e[47],w},"F"),Y=S(c=>{let e=(0,R.c)(20),{counters:o,t:a}=c,r;e[0]!==a?(r=a("Membership probes"),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==r?(l=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:r}),e[2]=r,e[3]=l):l=e[3];let u;e[4]!==a?(u=a("Queries run"),e[4]=a,e[5]=u):u=e[5];let d;e[6]!==o.run||e[7]!==u?(d=(0,t.jsx)(v,{label:u,testId:"fanout-probe-run",value:o.run}),e[6]=o.run,e[7]=u,e[8]=d):d=e[8];let n;e[9]!==a?(n=a("Shared from cache"),e[9]=a,e[10]=n):n=e[10];let s;e[11]!==o.served||e[12]!==n?(s=(0,t.jsx)(v,{label:n,testId:"fanout-probe-served",value:o.served}),e[11]=o.served,e[12]=n,e[13]=s):s=e[13];let i;e[14]!==d||e[15]!==s?(i=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"fanout-probe-stats",children:[d,s]}),e[14]=d,e[15]=s,e[16]=i):i=e[16];let m;return e[17]!==l||e[18]!==i?(m=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-probe-section",children:[l,i]}),e[17]=l,e[18]=i,e[19]=m):m=e[19],m},"V"),Z=S(c=>{let e=(0,R.c)(20),{counters:o,t:a}=c,r;e[0]!==a?(r=a("Global shape polls"),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==r?(l=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:r}),e[2]=r,e[3]=l):l=e[3];let u;e[4]!==a?(u=a("Global reads"),e[4]=a,e[5]=u):u=e[5];let d;e[6]!==o.drains||e[7]!==u?(d=(0,t.jsx)(v,{label:u,testId:"fanout-global-poll-drains",value:o.drains}),e[6]=o.drains,e[7]=u,e[8]=d):d=e[8];let n;e[9]!==a?(n=a("Pairs skipped"),e[9]=a,e[10]=n):n=e[10];let s;e[11]!==o.pairsSkipped||e[12]!==n?(s=(0,t.jsx)(v,{label:n,testId:"fanout-global-poll-pairs-skipped",value:o.pairsSkipped}),e[11]=o.pairsSkipped,e[12]=n,e[13]=s):s=e[13];let i;e[14]!==d||e[15]!==s?(i=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"fanout-global-poll-stats",children:[d,s]}),e[14]=d,e[15]=s,e[16]=i):i=e[16];let m;return e[17]!==l||e[18]!==i?(m=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-global-poll-section",children:[l,i]}),e[17]=l,e[18]=i,e[19]=m):m=e[19],m},"X"),pe=S(c=>{let e=(0,R.c)(32),{initialShardKey:o}=c,a=B(),{queryShardKey:r,setShardKey:l,shardKey:u}=W(o),d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={},e[0]=d):d=e[0];let n;e[1]!==r?(n={keepPreviousData:!0,shardKey:r},e[1]=r,e[2]=n):n=e[2];let{data:s,error:i,errorSource:m,poll:I}=j(_.getFanoutMetrics,d,n);A(I,!0);let g;e[3]!==s?(g=s!==void 0&&X(s),e[3]=s,e[4]=g):g=e[4];let k=g,p;e[5]!==l||e[6]!==u?(p=(0,t.jsx)(L,{onChange:l,testId:"fanout-shard-input",value:u}),e[5]=l,e[6]=u,e[7]=p):p=e[7];let f;e[8]!==s||e[9]!==a?(f=s!==void 0&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"fanout-count",children:[s.promoted&&(0,t.jsx)($,{"data-testid":"fanout-promoted",variant:s.relayCount>=s.maxRelays?"destructive":"default",children:s.relayCount>=s.maxRelays?a("auto-scaled: {relayCount}/{maxRelays} relays (at ceiling)",{maxRelays:s.maxRelays,relayCount:s.relayCount}):a("auto-scaled: {relayCount}/{maxRelays} relays",{maxRelays:s.maxRelays,relayCount:s.relayCount})}),(0,t.jsx)($,{variant:"secondary",children:a("{count} connections",{count:s.totalConnections})}),(0,t.jsx)($,{variant:"secondary",children:a("peak {count} subscribers",{count:s.peakSubscribers})})]}),e[8]=s,e[9]=a,e[10]=f):f=e[10];let y;e[11]!==p||e[12]!==f?(y=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[p,f]}),e[11]=p,e[12]=f,e[13]=y):y=e[13];let h;e[14]!==i||e[15]!==m||e[16]!==r?(h=i!==null&&(0,t.jsx)(q,{error:m,shardKey:r,testId:"fanout-error"}),e[14]=i,e[15]=m,e[16]=r,e[17]=h):h=e[17];let x;e[18]!==i||e[19]!==k||e[20]!==a?(x=i===null&&k&&(0,t.jsx)(G,{description:a("Realtime fan-out cost and per-topic subscriber counts for this shard."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M4 12h4l3 7 4-14 3 7h2"})}),testId:"fanout-empty",title:a("No fan-out activity yet.")}),e[18]=i,e[19]=k,e[20]=a,e[21]=x):x=e[21];let N;e[22]!==i||e[23]!==k||e[24]!==s||e[25]!==a?(N=i===null&&s!==void 0&&!k&&(0,t.jsxs)(t.Fragment,{children:[s.topics.length>0&&(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-topics-section",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:a("Hot topics")}),(0,t.jsx)(E,{className:"overflow-hidden py-0",children:(0,t.jsxs)(H,{"data-testid":"fanout-topics-table",children:[(0,t.jsx)(O,{children:(0,t.jsxs)(D,{children:[(0,t.jsx)(T,{children:a("Topic")}),(0,t.jsx)(T,{children:a("Kind")}),(0,t.jsx)(T,{className:"text-right",children:a("Subscribers")})]})}),(0,t.jsx)(Q,{children:s.topics.map(ee)})]})})]}),(0,t.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"fanout-cost",children:[(0,t.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:a("Fan-out cost since this instance woke")}),(0,t.jsx)(z,{counters:s.shapePoke,includeTiming:!0,prefix:"fanout-poke",t:a,title:a("Shape pokes")}),(0,t.jsx)(z,{counters:s.whisper,includeTiming:!1,prefix:"fanout-whisper",t:a,title:a("Whisper broadcasts")}),(0,t.jsx)(Y,{counters:s.shapeProbe,t:a}),(0,t.jsx)(Z,{counters:s.globalPoll,t:a})]})]}),e[22]=i,e[23]=k,e[24]=s,e[25]=a,e[26]=N):N=e[26];let b;return e[27]!==y||e[28]!==h||e[29]!==x||e[30]!==N?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"fanout-panel",children:[y,h,x,N]}),e[27]=y,e[28]=h,e[29]=x,e[30]=N,e[31]=b):b=e[31],b},"me");function ee(c){return(0,t.jsxs)(D,{"data-testid":"fanout-topic-row",children:[(0,t.jsx)(K,{className:"font-mono text-xs",children:c.topic}),(0,t.jsx)(K,{children:(0,t.jsx)($,{variant:"outline",children:c.kind})}),(0,t.jsx)(K,{className:"text-right font-medium tabular-nums",children:c.subscribers})]},`${c.kind}:${c.topic}`)}S(ee,"Y");export{pe as default};
1
+ import{a as v}from"./chunk-3WYPRZY3.js";import{a as A}from"./chunk-ERUKFS3I.js";import{a as W}from"./chunk-2KTN53PK.js";import{a as L}from"./chunk-YLC2ZYCL.js";import"./chunk-EDL46BPM.js";import"./chunk-4KPATTV6.js";import"./chunk-2D4WBSDO.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import"./chunk-OZID3UYF.js";import{a as G}from"./chunk-HMMALUXM.js";import{b as $}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{a as q}from"./chunk-JZN3MNJX.js";import"./chunk-EYSF4DHD.js";import{a as H,b as O,c as Q,d as D,e as T,f as K}from"./chunk-ZJIYJZ6F.js";import"./chunk-ELPLRD4S.js";import"./chunk-NFI2TNKU.js";import"./chunk-EOFWXI3T.js";import{a as _}from"./chunk-LYVYUTQY.js";import{c as j}from"./chunk-LRUYEVHH.js";import{a as E}from"./chunk-XV2XEUUB.js";import"./chunk-QFN62JQJ.js";import"./chunk-ZPQBVYNN.js";import{B}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as J}from"./chunk-A6TVTNKO.js";import{b as V}from"./chunk-ADABTCDI.js";import{a as S,d as F}from"./chunk-5PEAXTYQ.js";var R=F(J(),1);var t=F(V(),1);var U=S(c=>`${c.toString()} ms`,"D"),X=S(c=>c.totalConnections===0&&c.shapePoke.passes===0&&c.whisper.passes===0&&c.shapeProbe.run===0&&c.shapeProbe.served===0&&c.globalPoll.drains===0&&c.globalPoll.pairsSkipped===0,"J"),z=S(c=>{let e=(0,R.c)(48),{counters:o,includeTiming:a,prefix:r,t:l,title:u}=c,d=`${r}-section`,n;e[0]!==u?(n=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:u}),e[0]=u,e[1]=n):n=e[1];let s=`${r}-stats`,i;e[2]!==l?(i=l("Passes"),e[2]=l,e[3]=i):i=e[3];let m=`${r}-passes`,I;e[4]!==o.passes||e[5]!==i||e[6]!==m?(I=(0,t.jsx)(v,{label:i,testId:m,value:o.passes}),e[4]=o.passes,e[5]=i,e[6]=m,e[7]=I):I=e[7];let g;e[8]!==l?(g=l("Sockets iterated"),e[8]=l,e[9]=g):g=e[9];let k=`${r}-iterated`,p;e[10]!==o.socketsIterated||e[11]!==g||e[12]!==k?(p=(0,t.jsx)(v,{label:g,testId:k,value:o.socketsIterated}),e[10]=o.socketsIterated,e[11]=g,e[12]=k,e[13]=p):p=e[13];let f;e[14]!==l?(f=l("Delivered"),e[14]=l,e[15]=f):f=e[15];let y=`${r}-delivered`,h;e[16]!==o.socketsDelivered||e[17]!==f||e[18]!==y?(h=(0,t.jsx)(v,{label:f,testId:y,value:o.socketsDelivered}),e[16]=o.socketsDelivered,e[17]=f,e[18]=y,e[19]=h):h=e[19];let x;e[20]!==l?(x=l("Peak width"),e[20]=l,e[21]=x):x=e[21];let N=`${r}-peak`,b;e[22]!==o.peakSocketsIterated||e[23]!==x||e[24]!==N?(b=(0,t.jsx)(v,{label:x,testId:N,value:o.peakSocketsIterated}),e[22]=o.peakSocketsIterated,e[23]=x,e[24]=N,e[25]=b):b=e[25];let C;e[26]!==o.totalMs||e[27]!==a||e[28]!==r||e[29]!==l?(C=a&&(0,t.jsx)(v,{label:l("Total time"),testId:`${r}-total-ms`,value:U(o.totalMs)}),e[26]=o.totalMs,e[27]=a,e[28]=r,e[29]=l,e[30]=C):C=e[30];let P;e[31]!==o.maxMs||e[32]!==a||e[33]!==r||e[34]!==l?(P=a&&(0,t.jsx)(v,{label:l("Max time"),testId:`${r}-max-ms`,value:U(o.maxMs)}),e[31]=o.maxMs,e[32]=a,e[33]=r,e[34]=l,e[35]=P):P=e[35];let M;e[36]!==h||e[37]!==b||e[38]!==C||e[39]!==P||e[40]!==s||e[41]!==I||e[42]!==p?(M=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":s,children:[I,p,h,b,C,P]}),e[36]=h,e[37]=b,e[38]=C,e[39]=P,e[40]=s,e[41]=I,e[42]=p,e[43]=M):M=e[43];let w;return e[44]!==d||e[45]!==M||e[46]!==n?(w=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":d,children:[n,M]}),e[44]=d,e[45]=M,e[46]=n,e[47]=w):w=e[47],w},"F"),Y=S(c=>{let e=(0,R.c)(20),{counters:o,t:a}=c,r;e[0]!==a?(r=a("Membership probes"),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==r?(l=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:r}),e[2]=r,e[3]=l):l=e[3];let u;e[4]!==a?(u=a("Queries run"),e[4]=a,e[5]=u):u=e[5];let d;e[6]!==o.run||e[7]!==u?(d=(0,t.jsx)(v,{label:u,testId:"fanout-probe-run",value:o.run}),e[6]=o.run,e[7]=u,e[8]=d):d=e[8];let n;e[9]!==a?(n=a("Shared from cache"),e[9]=a,e[10]=n):n=e[10];let s;e[11]!==o.served||e[12]!==n?(s=(0,t.jsx)(v,{label:n,testId:"fanout-probe-served",value:o.served}),e[11]=o.served,e[12]=n,e[13]=s):s=e[13];let i;e[14]!==d||e[15]!==s?(i=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"fanout-probe-stats",children:[d,s]}),e[14]=d,e[15]=s,e[16]=i):i=e[16];let m;return e[17]!==l||e[18]!==i?(m=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-probe-section",children:[l,i]}),e[17]=l,e[18]=i,e[19]=m):m=e[19],m},"V"),Z=S(c=>{let e=(0,R.c)(20),{counters:o,t:a}=c,r;e[0]!==a?(r=a("Global shape polls"),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==r?(l=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:r}),e[2]=r,e[3]=l):l=e[3];let u;e[4]!==a?(u=a("Global reads"),e[4]=a,e[5]=u):u=e[5];let d;e[6]!==o.drains||e[7]!==u?(d=(0,t.jsx)(v,{label:u,testId:"fanout-global-poll-drains",value:o.drains}),e[6]=o.drains,e[7]=u,e[8]=d):d=e[8];let n;e[9]!==a?(n=a("Pairs skipped"),e[9]=a,e[10]=n):n=e[10];let s;e[11]!==o.pairsSkipped||e[12]!==n?(s=(0,t.jsx)(v,{label:n,testId:"fanout-global-poll-pairs-skipped",value:o.pairsSkipped}),e[11]=o.pairsSkipped,e[12]=n,e[13]=s):s=e[13];let i;e[14]!==d||e[15]!==s?(i=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"fanout-global-poll-stats",children:[d,s]}),e[14]=d,e[15]=s,e[16]=i):i=e[16];let m;return e[17]!==l||e[18]!==i?(m=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-global-poll-section",children:[l,i]}),e[17]=l,e[18]=i,e[19]=m):m=e[19],m},"X"),pe=S(c=>{let e=(0,R.c)(32),{initialShardKey:o}=c,a=B(),{queryShardKey:r,setShardKey:l,shardKey:u}=W(o),d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={},e[0]=d):d=e[0];let n;e[1]!==r?(n={keepPreviousData:!0,shardKey:r},e[1]=r,e[2]=n):n=e[2];let{data:s,error:i,errorSource:m,poll:I}=j(_.getFanoutMetrics,d,n);A(I,!0);let g;e[3]!==s?(g=s!==void 0&&X(s),e[3]=s,e[4]=g):g=e[4];let k=g,p;e[5]!==l||e[6]!==u?(p=(0,t.jsx)(L,{onChange:l,testId:"fanout-shard-input",value:u}),e[5]=l,e[6]=u,e[7]=p):p=e[7];let f;e[8]!==s||e[9]!==a?(f=s!==void 0&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"fanout-count",children:[s.promoted&&(0,t.jsx)($,{"data-testid":"fanout-promoted",variant:s.relayCount>=s.maxRelays?"destructive":"default",children:s.relayCount>=s.maxRelays?a("auto-scaled: {relayCount}/{maxRelays} relays (at ceiling)",{maxRelays:s.maxRelays,relayCount:s.relayCount}):a("auto-scaled: {relayCount}/{maxRelays} relays",{maxRelays:s.maxRelays,relayCount:s.relayCount})}),(0,t.jsx)($,{variant:"secondary",children:a("{count} connections",{count:s.totalConnections})}),(0,t.jsx)($,{variant:"secondary",children:a("peak {count} subscribers",{count:s.peakSubscribers})})]}),e[8]=s,e[9]=a,e[10]=f):f=e[10];let y;e[11]!==p||e[12]!==f?(y=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[p,f]}),e[11]=p,e[12]=f,e[13]=y):y=e[13];let h;e[14]!==i||e[15]!==m||e[16]!==r?(h=i!==null&&(0,t.jsx)(q,{error:m,shardKey:r,testId:"fanout-error"}),e[14]=i,e[15]=m,e[16]=r,e[17]=h):h=e[17];let x;e[18]!==i||e[19]!==k||e[20]!==a?(x=i===null&&k&&(0,t.jsx)(G,{description:a("Realtime fan-out cost and per-topic subscriber counts for this shard."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M4 12h4l3 7 4-14 3 7h2"})}),testId:"fanout-empty",title:a("No fan-out activity yet.")}),e[18]=i,e[19]=k,e[20]=a,e[21]=x):x=e[21];let N;e[22]!==i||e[23]!==k||e[24]!==s||e[25]!==a?(N=i===null&&s!==void 0&&!k&&(0,t.jsxs)(t.Fragment,{children:[s.topics.length>0&&(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-topics-section",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:a("Hot topics")}),(0,t.jsx)(E,{className:"overflow-hidden py-0",children:(0,t.jsxs)(H,{"data-testid":"fanout-topics-table",children:[(0,t.jsx)(O,{children:(0,t.jsxs)(D,{children:[(0,t.jsx)(T,{children:a("Topic")}),(0,t.jsx)(T,{children:a("Kind")}),(0,t.jsx)(T,{className:"text-right",children:a("Subscribers")})]})}),(0,t.jsx)(Q,{children:s.topics.map(ee)})]})})]}),(0,t.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"fanout-cost",children:[(0,t.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:a("Fan-out cost since this instance woke")}),(0,t.jsx)(z,{counters:s.shapePoke,includeTiming:!0,prefix:"fanout-poke",t:a,title:a("Shape pokes")}),(0,t.jsx)(z,{counters:s.whisper,includeTiming:!1,prefix:"fanout-whisper",t:a,title:a("Whisper broadcasts")}),(0,t.jsx)(Y,{counters:s.shapeProbe,t:a}),(0,t.jsx)(Z,{counters:s.globalPoll,t:a})]})]}),e[22]=i,e[23]=k,e[24]=s,e[25]=a,e[26]=N):N=e[26];let b;return e[27]!==y||e[28]!==h||e[29]!==x||e[30]!==N?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"fanout-panel",children:[y,h,x,N]}),e[27]=y,e[28]=h,e[29]=x,e[30]=N,e[31]=b):b=e[31],b},"me");function ee(c){return(0,t.jsxs)(D,{"data-testid":"fanout-topic-row",children:[(0,t.jsx)(K,{className:"font-mono text-xs",children:c.topic}),(0,t.jsx)(K,{children:(0,t.jsx)($,{variant:"outline",children:c.kind})}),(0,t.jsx)(K,{className:"text-right font-medium tabular-nums",children:c.subscribers})]},`${c.kind}:${c.topic}`)}S(ee,"Y");export{pe as default};
@@ -1 +1 @@
1
- import{x as i}from"./chunk-PN7JHEYW.js";import{a as c}from"./chunk-A6TVTNKO.js";import{b as m}from"./chunk-ADABTCDI.js";import{a as s,d as n}from"./chunk-5PEAXTYQ.js";var d=n(c(),1);var p=n(m(),1);function b(r){let e=(0,d.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let o;e[3]!==t?(o=i("flex items-center gap-2 text-xs leading-none select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),e[3]=t,e[4]=o):o=e[4];let l;return e[5]!==a||e[6]!==o?(l=(0,p.jsx)("label",{"data-slot":"label",className:o,...a}),e[5]=a,e[6]=o,e[7]=l):l=e[7],l}s(b,"m");export{b as a};
1
+ import{x as i}from"./chunk-2ZJJH4YN.js";import{a as c}from"./chunk-A6TVTNKO.js";import{b as m}from"./chunk-ADABTCDI.js";import{a as s,d as n}from"./chunk-5PEAXTYQ.js";var d=n(c(),1);var p=n(m(),1);function b(r){let e=(0,d.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let o;e[3]!==t?(o=i("flex items-center gap-2 text-xs leading-none select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),e[3]=t,e[4]=o):o=e[4];let l;return e[5]!==a||e[6]!==o?(l=(0,p.jsx)("label",{"data-slot":"label",className:o,...a}),e[5]=a,e[6]=o,e[7]=l):l=e[7],l}s(b,"m");export{b as a};
@@ -1 +1 @@
1
- import{b as f}from"./chunk-EOFWXI3T.js";import{B as p}from"./chunk-PN7JHEYW.js";import{a as g}from"./chunk-A6TVTNKO.js";import{b as h}from"./chunk-ADABTCDI.js";import{a as v,d}from"./chunk-5PEAXTYQ.js";var x=d(g(),1);var c=d(h(),1);var y=v(b=>{let e=(0,x.c)(14),{message:i,prefix:n}=b,r=p(),t=f(),l;e[0]!==t?(l=v(()=>{t?.openConsole({errorsOnly:!0})},"l"),e[0]=t,e[1]=l):l=e[1];let u=l;if(i===void 0)return null;let m=`${n}-live-error`,o;e[2]!==i||e[3]!==r?(o=r("Live unavailable: {liveError}",{liveError:i}),e[2]=i,e[3]=r,e[4]=o):o=e[4];let s;e[5]!==t||e[6]!==n||e[7]!==u||e[8]!==r?(s=t===void 0?null:(0,c.jsx)("button",{className:"underline outline-none focus-visible:ring-1 focus-visible:ring-ring","data-testid":`${n}-live-error-console`,onClick:u,type:"button",children:r("Show in console")}),e[5]=t,e[6]=n,e[7]=u,e[8]=r,e[9]=s):s=e[9];let a;return e[10]!==m||e[11]!==o||e[12]!==s?(a=(0,c.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-destructive","data-testid":m,role:"status",children:[o,s]}),e[10]=m,e[11]=o,e[12]=s,e[13]=a):a=e[13],a},"E");export{y as a};
1
+ import{b as f}from"./chunk-EOFWXI3T.js";import{B as p}from"./chunk-2ZJJH4YN.js";import{a as g}from"./chunk-A6TVTNKO.js";import{b as h}from"./chunk-ADABTCDI.js";import{a as v,d}from"./chunk-5PEAXTYQ.js";var x=d(g(),1);var c=d(h(),1);var y=v(b=>{let e=(0,x.c)(14),{message:i,prefix:n}=b,r=p(),t=f(),l;e[0]!==t?(l=v(()=>{t?.openConsole({errorsOnly:!0})},"l"),e[0]=t,e[1]=l):l=e[1];let u=l;if(i===void 0)return null;let m=`${n}-live-error`,o;e[2]!==i||e[3]!==r?(o=r("Live unavailable: {liveError}",{liveError:i}),e[2]=i,e[3]=r,e[4]=o):o=e[4];let s;e[5]!==t||e[6]!==n||e[7]!==u||e[8]!==r?(s=t===void 0?null:(0,c.jsx)("button",{className:"underline outline-none focus-visible:ring-1 focus-visible:ring-ring","data-testid":`${n}-live-error-console`,onClick:u,type:"button",children:r("Show in console")}),e[5]=t,e[6]=n,e[7]=u,e[8]=r,e[9]=s):s=e[9];let a;return e[10]!==m||e[11]!==o||e[12]!==s?(a=(0,c.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-destructive","data-testid":m,role:"status",children:[o,s]}),e[10]=m,e[11]=o,e[12]=s,e[13]=a):a=e[13],a},"E");export{y as a};
@@ -1 +1 @@
1
- import{a as R}from"./chunk-LYVYUTQY.js";import{c as K}from"./chunk-KDMDI7KA.js";import{a as N}from"./chunk-A6TVTNKO.js";import{a as C,b as F}from"./chunk-ADABTCDI.js";import{a as o,d as A}from"./chunk-5PEAXTYQ.js";var b=A(N(),1),u=A(C(),1);var S=A(F(),1);var x=(0,u.createContext)(void 0),w={},T="New chat",j=o((n,s)=>({id:n,name:s?.title??T,schema:s?.schema??[],shardKey:s?.shardKey,suggestions:s?.suggestions??[],turns:[]}),"F"),D=o((n,s)=>[...n.sessions,s].slice(-10),"T"),m=o((n,s)=>{let a=`chat-${String(n.seq+1)}`;return{activeId:a,draft:s?.draft===void 0?void 0:{id:n.seq+1,text:s.draft},hasEditor:n.hasEditor,insertRequest:void 0,open:!0,pendingAsk:s?.ask===void 0?void 0:{id:n.seq+1,sessionId:a,text:s.ask},seq:n.seq+1,sessions:D(n,j(a,s))}},"f"),v=o((n,s)=>n.find(a=>a.id===s),"l"),O=o((n,s,a)=>n.map(c=>c.id===s?{...c,schema:a}:c),"D"),U=o((n,s,a)=>n.map(c=>c.id===s?{...c,schema:[],shardKey:a}:c),"O"),$=o((n,s)=>n.filter(a=>a.id!==s),"U"),E=o((n,s,a)=>n.map(c=>c.id===s?{...c,turns:a}:c),"y"),z=o(n=>{let s=(0,b.c)(16),{children:a}=n,c;s[0]===Symbol.for("react.memo_cache_sentinel")?(c={shardKey:""},s[0]=c):c=s[0];let _=K(R.aiAvailable,w,c),l;s[1]===Symbol.for("react.memo_cache_sentinel")?(l={activeId:void 0,draft:void 0,hasEditor:!1,insertRequest:void 0,open:!1,pendingAsk:void 0,seq:0,sessions:[]},s[1]=l):l=s[1];let[d,h]=(0,u.useState)(l),p;s[2]===Symbol.for("react.memo_cache_sentinel")?(p=o(()=>({close:o(()=>{h(H)},"close"),deleteChat:o(t=>{h(e=>{let i=$(e.sessions,t);return{...e,activeId:e.activeId===t?i.at(-1)?.id:e.activeId,open:i.length===0?!1:e.open,sessions:i}})},"deleteChat"),newChat:o(t=>{h(e=>m(e,t))},"newChat"),openAssistant:o(t=>{h(e=>{let i=e.activeId===void 0?void 0:v(e.sessions,e.activeId);return t?.ask!==void 0||i===void 0||(t?.shardKey??"")!==(i.shardKey??"")?m(e,t):{...e,draft:t?.draft===void 0?e.draft:{id:e.seq+1,text:t.draft},open:!0,sessions:t?.schema===void 0?e.sessions:O(e.sessions,i.id,t.schema),seq:e.seq+1}})},"openAssistant"),rebindShard:o((t,e)=>{h(i=>{let r=i.activeId===void 0?void 0:v(i.sessions,i.activeId);return!i.open||r===void 0||(r.shardKey??"")!==t||t===e?i:r.turns.length===0?{...i,sessions:U(i.sessions,r.id,e)}:m(i,{shardKey:e,title:r.name})})},"rebindShard"),requestInsert:o(t=>{h(e=>({...e,insertRequest:{id:e.seq+1,sql:t},seq:e.seq+1}))},"requestInsert"),setHasEditor:o(t=>{h(e=>e.hasEditor===t?e:{...e,hasEditor:t})},"setHasEditor"),takeInsert:o(t=>{h(e=>e.insertRequest?.id===t?{...e,insertRequest:void 0}:e)},"takeInsert"),selectChat:o(t=>{h(e=>({...e,activeId:t,open:!0}))},"selectChat"),branchFrom:o((t,e)=>{h(i=>{let r=v(i.sessions,t);if(r===void 0)return i;let y=m(i,{schema:r.schema,shardKey:r.shardKey,title:r.name});return{...y,sessions:E(y.sessions,y.activeId??"",r.turns.slice(0,e+1))}})},"branchFrom"),setTurns:o((t,e)=>{h(i=>{let r=v(i.sessions,t);return r===void 0?i:{...i,sessions:E(i.sessions,t,typeof e=="function"?e(r.turns):e)}})},"setTurns"),toggle:o(()=>{h(M)},"toggle"),truncateFrom:o((t,e)=>{h(i=>{let r=v(i.sessions,t);return r===void 0?i:{...i,sessions:E(i.sessions,t,r.turns.slice(0,e))}})},"truncateFrom"),takeAsk:o(t=>{h(e=>e.pendingAsk?.id===t?{...e,pendingAsk:void 0}:e)},"takeAsk")}),"c"),s[2]=p):p=s[2];let[I]=(0,u.useState)(p),g=_.data?.available!==!0,f;s[3]!==I||s[4]!==d.activeId||s[5]!==d.draft||s[6]!==d.hasEditor||s[7]!==d.insertRequest||s[8]!==d.open||s[9]!==d.pendingAsk||s[10]!==d.sessions||s[11]!==g?(f={...I,activeId:d.activeId,draft:d.draft,hasEditor:d.hasEditor,insertRequest:d.insertRequest,open:d.open,pendingAsk:d.pendingAsk,sessions:d.sessions,unavailable:g},s[3]=I,s[4]=d.activeId,s[5]=d.draft,s[6]=d.hasEditor,s[7]=d.insertRequest,s[8]=d.open,s[9]=d.pendingAsk,s[10]=d.sessions,s[11]=g,s[12]=f):f=s[12];let k=f,q;return s[13]!==a||s[14]!==k?(q=(0,S.jsx)(x,{value:k,children:a}),s[13]=a,s[14]=k,s[15]=q):q=s[15],q},"P"),B=o(()=>(0,u.use)(x),"Q");function H(n){return{...n,open:!1}}o(H,"$");function M(n){return!n.open&&n.activeId===void 0?m(n,void 0):{...n,open:!n.open}}o(M,"j");export{z as a,B as b};
1
+ import{a as R}from"./chunk-LYVYUTQY.js";import{c as K}from"./chunk-LRUYEVHH.js";import{a as N}from"./chunk-A6TVTNKO.js";import{a as C,b as F}from"./chunk-ADABTCDI.js";import{a as o,d as A}from"./chunk-5PEAXTYQ.js";var b=A(N(),1),u=A(C(),1);var S=A(F(),1);var x=(0,u.createContext)(void 0),w={},T="New chat",j=o((n,s)=>({id:n,name:s?.title??T,schema:s?.schema??[],shardKey:s?.shardKey,suggestions:s?.suggestions??[],turns:[]}),"F"),D=o((n,s)=>[...n.sessions,s].slice(-10),"T"),m=o((n,s)=>{let a=`chat-${String(n.seq+1)}`;return{activeId:a,draft:s?.draft===void 0?void 0:{id:n.seq+1,text:s.draft},hasEditor:n.hasEditor,insertRequest:void 0,open:!0,pendingAsk:s?.ask===void 0?void 0:{id:n.seq+1,sessionId:a,text:s.ask},seq:n.seq+1,sessions:D(n,j(a,s))}},"f"),v=o((n,s)=>n.find(a=>a.id===s),"l"),O=o((n,s,a)=>n.map(c=>c.id===s?{...c,schema:a}:c),"D"),U=o((n,s,a)=>n.map(c=>c.id===s?{...c,schema:[],shardKey:a}:c),"O"),$=o((n,s)=>n.filter(a=>a.id!==s),"U"),E=o((n,s,a)=>n.map(c=>c.id===s?{...c,turns:a}:c),"y"),z=o(n=>{let s=(0,b.c)(16),{children:a}=n,c;s[0]===Symbol.for("react.memo_cache_sentinel")?(c={shardKey:""},s[0]=c):c=s[0];let _=K(R.aiAvailable,w,c),l;s[1]===Symbol.for("react.memo_cache_sentinel")?(l={activeId:void 0,draft:void 0,hasEditor:!1,insertRequest:void 0,open:!1,pendingAsk:void 0,seq:0,sessions:[]},s[1]=l):l=s[1];let[d,h]=(0,u.useState)(l),p;s[2]===Symbol.for("react.memo_cache_sentinel")?(p=o(()=>({close:o(()=>{h(H)},"close"),deleteChat:o(t=>{h(e=>{let i=$(e.sessions,t);return{...e,activeId:e.activeId===t?i.at(-1)?.id:e.activeId,open:i.length===0?!1:e.open,sessions:i}})},"deleteChat"),newChat:o(t=>{h(e=>m(e,t))},"newChat"),openAssistant:o(t=>{h(e=>{let i=e.activeId===void 0?void 0:v(e.sessions,e.activeId);return t?.ask!==void 0||i===void 0||(t?.shardKey??"")!==(i.shardKey??"")?m(e,t):{...e,draft:t?.draft===void 0?e.draft:{id:e.seq+1,text:t.draft},open:!0,sessions:t?.schema===void 0?e.sessions:O(e.sessions,i.id,t.schema),seq:e.seq+1}})},"openAssistant"),rebindShard:o((t,e)=>{h(i=>{let r=i.activeId===void 0?void 0:v(i.sessions,i.activeId);return!i.open||r===void 0||(r.shardKey??"")!==t||t===e?i:r.turns.length===0?{...i,sessions:U(i.sessions,r.id,e)}:m(i,{shardKey:e,title:r.name})})},"rebindShard"),requestInsert:o(t=>{h(e=>({...e,insertRequest:{id:e.seq+1,sql:t},seq:e.seq+1}))},"requestInsert"),setHasEditor:o(t=>{h(e=>e.hasEditor===t?e:{...e,hasEditor:t})},"setHasEditor"),takeInsert:o(t=>{h(e=>e.insertRequest?.id===t?{...e,insertRequest:void 0}:e)},"takeInsert"),selectChat:o(t=>{h(e=>({...e,activeId:t,open:!0}))},"selectChat"),branchFrom:o((t,e)=>{h(i=>{let r=v(i.sessions,t);if(r===void 0)return i;let y=m(i,{schema:r.schema,shardKey:r.shardKey,title:r.name});return{...y,sessions:E(y.sessions,y.activeId??"",r.turns.slice(0,e+1))}})},"branchFrom"),setTurns:o((t,e)=>{h(i=>{let r=v(i.sessions,t);return r===void 0?i:{...i,sessions:E(i.sessions,t,typeof e=="function"?e(r.turns):e)}})},"setTurns"),toggle:o(()=>{h(M)},"toggle"),truncateFrom:o((t,e)=>{h(i=>{let r=v(i.sessions,t);return r===void 0?i:{...i,sessions:E(i.sessions,t,r.turns.slice(0,e))}})},"truncateFrom"),takeAsk:o(t=>{h(e=>e.pendingAsk?.id===t?{...e,pendingAsk:void 0}:e)},"takeAsk")}),"c"),s[2]=p):p=s[2];let[I]=(0,u.useState)(p),g=_.data?.available!==!0,f;s[3]!==I||s[4]!==d.activeId||s[5]!==d.draft||s[6]!==d.hasEditor||s[7]!==d.insertRequest||s[8]!==d.open||s[9]!==d.pendingAsk||s[10]!==d.sessions||s[11]!==g?(f={...I,activeId:d.activeId,draft:d.draft,hasEditor:d.hasEditor,insertRequest:d.insertRequest,open:d.open,pendingAsk:d.pendingAsk,sessions:d.sessions,unavailable:g},s[3]=I,s[4]=d.activeId,s[5]=d.draft,s[6]=d.hasEditor,s[7]=d.insertRequest,s[8]=d.open,s[9]=d.pendingAsk,s[10]=d.sessions,s[11]=g,s[12]=f):f=s[12];let k=f,q;return s[13]!==a||s[14]!==k?(q=(0,S.jsx)(x,{value:k,children:a}),s[13]=a,s[14]=k,s[15]=q):q=s[15],q},"P"),B=o(()=>(0,u.use)(x),"Q");function H(n){return{...n,open:!1}}o(H,"$");function M(n){return!n.open&&n.activeId===void 0?m(n,void 0):{...n,open:!n.open}}o(M,"j");export{z as a,B as b};
@@ -1 +1 @@
1
- import{i as G}from"./chunk-OKZINWBB.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as E}from"./chunk-NVMQPIRS.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as Q}from"./chunk-S3TDGFRE.js";import{b as $}from"./chunk-UV6GPH2E.js";import"./chunk-L27FKJTG.js";import{a as X}from"./chunk-VXMAQB2K.js";import"./chunk-S7NFUY75.js";import{a as Y,b as Z,c as ee,d as V,e as c,f as d}from"./chunk-J3ZEO3PJ.js";import"./chunk-3R6W72RH.js";import"./chunk-2L3WHXJV.js";import"./chunk-EOFWXI3T.js";import{a as U}from"./chunk-LYVYUTQY.js";import{c as O}from"./chunk-KDMDI7KA.js";import{a as J,e as K}from"./chunk-TN4Z3P6S.js";import"./chunk-QB75Q7U4.js";import"./chunk-ZPQBVYNN.js";import{B as q,w as H}from"./chunk-PN7JHEYW.js";import"./chunk-PDBW6GTJ.js";import{a as le}from"./chunk-A6TVTNKO.js";import{a as oe,b as ce}from"./chunk-ADABTCDI.js";import{a as s,d as R}from"./chunk-5PEAXTYQ.js";var te=R(le(),1),j=R(oe(),1);var t=R(ce(),1);var re=s(e=>e.endpoint??e.id,"V"),de=s((e,r,i,z)=>{let n=i.trim().toLowerCase(),y=[],o=[];for(let l of e){let m=r==="all"||l.kind===r,h=n===""||`${re(l)} ${l.userId??""}`.toLowerCase().includes(n);m&&h&&(y.push(l),l.lastStatus==="failed"&&o.push(l))}return{failing:o,filtered:z?o:y}},"ie"),me=s(e=>e==="ok"?"success":e==="failed"?"destructive":e==="expired"?"warning":"secondary","oe"),Ce=s(()=>{let e=(0,te.c)(40),r=q(),[i,z]=(0,j.useState)("all"),[n,y]=(0,j.useState)(""),[o,l]=(0,j.useState)(!1),m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={},e[0]=m):m=e[0];let{data:h,error:u,errorSource:k,isLoading:B,refetch:w}=O(U.listPushSubscriptions,m),C;if(e[1]!==h||e[2]!==u||e[3]!==k||e[4]!==o||e[5]!==B||e[6]!==i||e[7]!==w||e[8]!==n||e[9]!==r){let f=h?.subscriptions??[],ae=f.length>=1e3,{failing:se,filtered:F}=de(f,i,n,o),W=se.length,S;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=s(a=>{y(a.target.value)},"S"),e[11]=S):S=e[11];let ie=S,I;e[12]!==w?(I=s(()=>{w()},"T"),e[12]=w,e[13]=I):I=e[13];let M=I,_;e[14]===Symbol.for("react.memo_cache_sentinel")?(_=["all","web-push","fcm"],e[14]=_):_=e[14];let ne=_,p;e[15]!==i||e[16]!==r?(p=(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"nt-kind-filter",role:"tablist",children:ne.map(a=>(0,t.jsx)(E,{"aria-selected":i===a,"data-testid":`nt-kind-${a}`,onClick:s(()=>{z(a)},"onClick"),role:"tab",size:"sm",type:"button",variant:i===a?"secondary":"ghost",children:a==="all"?r("All"):a},a))}),e[15]=i,e[16]=r,e[17]=p):p=e[17];let T=h!==void 0&&(0,t.jsx)(E,{"aria-pressed":o,"data-testid":"nt-failing-filter",onClick:s(()=>{l(he)},"onClick"),size:"sm",type:"button",variant:o?"secondary":"ghost",children:ae?r("{count}+ failing",{count:W}):r("{count} failing",{count:W})}),g;e[18]!==r?(g=r("Filter devices"),e[18]=r,e[19]=g):g=e[19];let v;e[20]!==r?(v=r("filter endpoint, user"),e[20]=r,e[21]=v):v=e[21];let x;e[22]!==n||e[23]!==g||e[24]!==v?(x=(0,t.jsx)(G,{"aria-label":g,className:"h-8 w-56","data-testid":"nt-search",onChange:ie,placeholder:v,value:n}),e[22]=n,e[23]=g,e[24]=v,e[25]=x):x=e[25];let N;e[26]!==r?(N=r("Refresh"),e[26]=r,e[27]=N):N=e[27];let b;e[28]!==M||e[29]!==N?(b=(0,t.jsx)(E,{className:"ml-auto","data-testid":"nt-refresh",onClick:M,size:"sm",type:"button",variant:"outline",children:N}),e[28]=M,e[29]=N,e[30]=b):b=e[30];let P=f.length>0&&(0,t.jsx)($,{"data-testid":"nt-count",variant:"secondary",children:r("{count} devices",{count:f.length})}),L;e[31]!==b||e[32]!==P||e[33]!==p||e[34]!==T||e[35]!==x?(L=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[p,T,x,b,P]}),e[31]=b,e[32]=P,e[33]=p,e[34]=T,e[35]=x,e[36]=L):L=e[36];let A;e[37]!==u||e[38]!==k?(A=u!==null&&(0,t.jsx)(X,{error:k,testId:"nt-error"}),e[37]=u,e[38]=k,e[39]=A):A=e[39],C=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-notifications",children:[L,A,u===null&&!B&&F.length===0&&(0,t.jsx)(Q,{description:f.length>0?r("No device matches the current kind, search or failing filter."):r("Registered Web Push / FCM devices appear here. Configure lunora/notify.ts with defineNotify({ store }) and register a device with ctx.push.register(...)."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M15 17h5l-1.4-1.4A2 2 0 0 1 18 14.2V11a6 6 0 0 0-4-5.7V5a2 2 0 1 0-4 0v.3A6 6 0 0 0 6 11v3.2a2 2 0 0 1-.6 1.4L4 17h5m6 0v1a3 3 0 1 1-6 0v-1m6 0H9"})}),testId:"nt-empty",title:f.length>0?r("No matching devices."):r("No registered devices.")}),F.length>0&&(0,t.jsx)(J,{className:"overflow-hidden py-0",children:(0,t.jsx)(K,{className:"max-h-[30rem] overflow-auto px-0",children:(0,t.jsxs)(Y,{"data-testid":"nt-table",children:[(0,t.jsx)(Z,{children:(0,t.jsxs)(V,{children:[(0,t.jsx)(c,{children:r("kind")}),(0,t.jsx)(c,{children:r("endpoint")}),(0,t.jsx)(c,{children:r("user")}),(0,t.jsx)(c,{children:r("last seen")}),(0,t.jsx)(c,{children:r("status")}),(0,t.jsx)(c,{children:r("error")})]})}),(0,t.jsx)(ee,{children:F.map(a=>{let D=re(a);return(0,t.jsxs)(V,{"data-testid":"nt-row",children:[(0,t.jsx)(d,{children:(0,t.jsx)($,{variant:"outline",children:a.kind})}),(0,t.jsx)(d,{className:"max-w-[28ch] truncate font-mono text-xs",title:D,children:D}),(0,t.jsx)(d,{className:"max-w-[16ch] truncate font-mono text-xs",children:a.userId??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,t.jsx)(d,{className:"text-muted-foreground tabular-nums",children:H(a.lastSeenAt,"\u2014")}),(0,t.jsx)(d,{children:(0,t.jsx)($,{"data-testid":`nt-status-${a.id}`,variant:me(a.lastStatus),children:a.lastStatus??r("n/a")})}),(0,t.jsx)(d,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",title:a.lastError??void 0,children:a.lastError??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},a.id)})})]})})})]}),e[1]=h,e[2]=u,e[3]=k,e[4]=o,e[5]=B,e[6]=i,e[7]=w,e[8]=n,e[9]=r,e[10]=C}else C=e[10];return C},"ke");function he(e){return!e}s(he,"le");export{Ce as default};
1
+ import{i as G}from"./chunk-2D4WBSDO.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as E}from"./chunk-CBTPJPCZ.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as Q}from"./chunk-HMMALUXM.js";import{b as $}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{a as X}from"./chunk-JZN3MNJX.js";import"./chunk-EYSF4DHD.js";import{a as Y,b as Z,c as ee,d as V,e as c,f as d}from"./chunk-ZJIYJZ6F.js";import"./chunk-ELPLRD4S.js";import"./chunk-NFI2TNKU.js";import"./chunk-EOFWXI3T.js";import{a as U}from"./chunk-LYVYUTQY.js";import{c as O}from"./chunk-LRUYEVHH.js";import{a as J,e as K}from"./chunk-XV2XEUUB.js";import"./chunk-QFN62JQJ.js";import"./chunk-ZPQBVYNN.js";import{B as q,w as H}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as le}from"./chunk-A6TVTNKO.js";import{a as oe,b as ce}from"./chunk-ADABTCDI.js";import{a as s,d as R}from"./chunk-5PEAXTYQ.js";var te=R(le(),1),j=R(oe(),1);var t=R(ce(),1);var re=s(e=>e.endpoint??e.id,"V"),de=s((e,r,i,z)=>{let n=i.trim().toLowerCase(),y=[],o=[];for(let l of e){let m=r==="all"||l.kind===r,h=n===""||`${re(l)} ${l.userId??""}`.toLowerCase().includes(n);m&&h&&(y.push(l),l.lastStatus==="failed"&&o.push(l))}return{failing:o,filtered:z?o:y}},"ie"),me=s(e=>e==="ok"?"success":e==="failed"?"destructive":e==="expired"?"warning":"secondary","oe"),Ce=s(()=>{let e=(0,te.c)(40),r=q(),[i,z]=(0,j.useState)("all"),[n,y]=(0,j.useState)(""),[o,l]=(0,j.useState)(!1),m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={},e[0]=m):m=e[0];let{data:h,error:u,errorSource:k,isLoading:B,refetch:w}=O(U.listPushSubscriptions,m),C;if(e[1]!==h||e[2]!==u||e[3]!==k||e[4]!==o||e[5]!==B||e[6]!==i||e[7]!==w||e[8]!==n||e[9]!==r){let f=h?.subscriptions??[],ae=f.length>=1e3,{failing:se,filtered:F}=de(f,i,n,o),W=se.length,S;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=s(a=>{y(a.target.value)},"S"),e[11]=S):S=e[11];let ie=S,I;e[12]!==w?(I=s(()=>{w()},"T"),e[12]=w,e[13]=I):I=e[13];let M=I,_;e[14]===Symbol.for("react.memo_cache_sentinel")?(_=["all","web-push","fcm"],e[14]=_):_=e[14];let ne=_,p;e[15]!==i||e[16]!==r?(p=(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"nt-kind-filter",role:"tablist",children:ne.map(a=>(0,t.jsx)(E,{"aria-selected":i===a,"data-testid":`nt-kind-${a}`,onClick:s(()=>{z(a)},"onClick"),role:"tab",size:"sm",type:"button",variant:i===a?"secondary":"ghost",children:a==="all"?r("All"):a},a))}),e[15]=i,e[16]=r,e[17]=p):p=e[17];let T=h!==void 0&&(0,t.jsx)(E,{"aria-pressed":o,"data-testid":"nt-failing-filter",onClick:s(()=>{l(he)},"onClick"),size:"sm",type:"button",variant:o?"secondary":"ghost",children:ae?r("{count}+ failing",{count:W}):r("{count} failing",{count:W})}),g;e[18]!==r?(g=r("Filter devices"),e[18]=r,e[19]=g):g=e[19];let v;e[20]!==r?(v=r("filter endpoint, user"),e[20]=r,e[21]=v):v=e[21];let x;e[22]!==n||e[23]!==g||e[24]!==v?(x=(0,t.jsx)(G,{"aria-label":g,className:"h-8 w-56","data-testid":"nt-search",onChange:ie,placeholder:v,value:n}),e[22]=n,e[23]=g,e[24]=v,e[25]=x):x=e[25];let N;e[26]!==r?(N=r("Refresh"),e[26]=r,e[27]=N):N=e[27];let b;e[28]!==M||e[29]!==N?(b=(0,t.jsx)(E,{className:"ml-auto","data-testid":"nt-refresh",onClick:M,size:"sm",type:"button",variant:"outline",children:N}),e[28]=M,e[29]=N,e[30]=b):b=e[30];let P=f.length>0&&(0,t.jsx)($,{"data-testid":"nt-count",variant:"secondary",children:r("{count} devices",{count:f.length})}),L;e[31]!==b||e[32]!==P||e[33]!==p||e[34]!==T||e[35]!==x?(L=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[p,T,x,b,P]}),e[31]=b,e[32]=P,e[33]=p,e[34]=T,e[35]=x,e[36]=L):L=e[36];let A;e[37]!==u||e[38]!==k?(A=u!==null&&(0,t.jsx)(X,{error:k,testId:"nt-error"}),e[37]=u,e[38]=k,e[39]=A):A=e[39],C=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-notifications",children:[L,A,u===null&&!B&&F.length===0&&(0,t.jsx)(Q,{description:f.length>0?r("No device matches the current kind, search or failing filter."):r("Registered Web Push / FCM devices appear here. Configure lunora/notify.ts with defineNotify({ store }) and register a device with ctx.push.register(...)."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M15 17h5l-1.4-1.4A2 2 0 0 1 18 14.2V11a6 6 0 0 0-4-5.7V5a2 2 0 1 0-4 0v.3A6 6 0 0 0 6 11v3.2a2 2 0 0 1-.6 1.4L4 17h5m6 0v1a3 3 0 1 1-6 0v-1m6 0H9"})}),testId:"nt-empty",title:f.length>0?r("No matching devices."):r("No registered devices.")}),F.length>0&&(0,t.jsx)(J,{className:"overflow-hidden py-0",children:(0,t.jsx)(K,{className:"max-h-[30rem] overflow-auto px-0",children:(0,t.jsxs)(Y,{"data-testid":"nt-table",children:[(0,t.jsx)(Z,{children:(0,t.jsxs)(V,{children:[(0,t.jsx)(c,{children:r("kind")}),(0,t.jsx)(c,{children:r("endpoint")}),(0,t.jsx)(c,{children:r("user")}),(0,t.jsx)(c,{children:r("last seen")}),(0,t.jsx)(c,{children:r("status")}),(0,t.jsx)(c,{children:r("error")})]})}),(0,t.jsx)(ee,{children:F.map(a=>{let D=re(a);return(0,t.jsxs)(V,{"data-testid":"nt-row",children:[(0,t.jsx)(d,{children:(0,t.jsx)($,{variant:"outline",children:a.kind})}),(0,t.jsx)(d,{className:"max-w-[28ch] truncate font-mono text-xs",title:D,children:D}),(0,t.jsx)(d,{className:"max-w-[16ch] truncate font-mono text-xs",children:a.userId??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,t.jsx)(d,{className:"text-muted-foreground tabular-nums",children:H(a.lastSeenAt,"\u2014")}),(0,t.jsx)(d,{children:(0,t.jsx)($,{"data-testid":`nt-status-${a.id}`,variant:me(a.lastStatus),children:a.lastStatus??r("n/a")})}),(0,t.jsx)(d,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",title:a.lastError??void 0,children:a.lastError??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},a.id)})})]})})})]}),e[1]=h,e[2]=u,e[3]=k,e[4]=o,e[5]=B,e[6]=i,e[7]=w,e[8]=n,e[9]=r,e[10]=C}else C=e[10];return C},"ke");function he(e){return!e}s(he,"le");export{Ce as default};
@@ -1 +1 @@
1
- import{i as M}from"./chunk-OKZINWBB.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as D}from"./chunk-NVMQPIRS.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as R}from"./chunk-S3TDGFRE.js";import{b as j}from"./chunk-UV6GPH2E.js";import"./chunk-L27FKJTG.js";import{a as U}from"./chunk-VXMAQB2K.js";import"./chunk-S7NFUY75.js";import{a as G,b as H,c as J,d as B,e as x,f as N}from"./chunk-J3ZEO3PJ.js";import"./chunk-3R6W72RH.js";import"./chunk-2L3WHXJV.js";import"./chunk-EOFWXI3T.js";import{a as q}from"./chunk-LYVYUTQY.js";import{c as k}from"./chunk-KDMDI7KA.js";import{a as O,e as P}from"./chunk-TN4Z3P6S.js";import"./chunk-QB75Q7U4.js";import"./chunk-ZPQBVYNN.js";import{B as z,w as F}from"./chunk-PN7JHEYW.js";import"./chunk-PDBW6GTJ.js";import{a as X}from"./chunk-A6TVTNKO.js";import{a as $,b as Y}from"./chunk-ADABTCDI.js";import{a as A,d as T}from"./chunk-5PEAXTYQ.js";var K=T(X(),1),Q=T($(),1);var t=T(Y(),1);var de=A(()=>{let e=(0,K.c)(39),a=z(),[s,V]=(0,Q.useState)(""),y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={},e[0]=y):y=e[0];let{data:C,error:l,errorSource:S,isLoading:E,refetch:_}=k(q.getAuthAuditLog,y),I;if(e[1]!==C?.entries||e[2]!==s){let r=C?.entries??[],v=s.trim().toLowerCase();I=v===""?r:r.filter(w=>w.event.toLowerCase().includes(v)||(w.actorId??"").toLowerCase().includes(v)||(w.actorEmail??"").toLowerCase().includes(v)||(w.ip??"").toLowerCase().includes(v)||w.outcome.toLowerCase().includes(v)),e[1]=C?.entries,e[2]=s,e[3]=I}else I=e[3];let o=I,L;e[4]===Symbol.for("react.memo_cache_sentinel")?(L=A(r=>{V(r.target.value)},"I"),e[4]=L):L=e[4];let W=L,i;e[5]!==a?(i=a("Filter security events"),e[5]=a,e[6]=i):i=e[6];let n;e[7]!==a?(n=a("filter event, actor, IP"),e[7]=a,e[8]=n):n=e[8];let c;e[9]!==s||e[10]!==i||e[11]!==n?(c=(0,t.jsx)(M,{"aria-label":i,className:"h-8 w-56","data-testid":"aa-search",onChange:W,placeholder:n,value:s}),e[9]=s,e[10]=i,e[11]=n,e[12]=c):c=e[12];let d;e[13]!==_?(d=A(()=>{_()},"m"),e[13]=_,e[14]=d):d=e[14];let m;e[15]!==a?(m=a("Refresh"),e[15]=a,e[16]=m):m=e[16];let u;e[17]!==d||e[18]!==m?(u=(0,t.jsx)(D,{"data-testid":"aa-refresh",onClick:d,size:"xs",type:"button",variant:"ghost",children:m}),e[17]=d,e[18]=m,e[19]=u):u=e[19];let h;e[20]!==c||e[21]!==u?(h=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,u]}),e[20]=c,e[21]=u,e[22]=h):h=e[22];let f;e[23]!==l||e[24]!==S?(f=l!==null&&(0,t.jsx)(U,{error:S,testId:"aa-error"}),e[23]=l,e[24]=S,e[25]=f):f=e[25];let p;e[26]!==l||e[27]!==o.length||e[28]!==E||e[29]!==a?(p=l===null&&!E&&o.length===0&&(0,t.jsx)(R,{description:a("Authentication and security events are recorded here."),testId:"aa-empty",title:a("No security events.")}),e[26]=l,e[27]=o.length,e[28]=E,e[29]=a,e[30]=p):p=e[30];let g;e[31]!==o||e[32]!==a?(g=o.length>0&&(0,t.jsx)(O,{className:"overflow-hidden py-0",children:(0,t.jsx)(P,{className:"max-h-[30rem] overflow-auto px-0",children:(0,t.jsxs)(G,{"data-testid":"aa-table",children:[(0,t.jsx)(H,{children:(0,t.jsxs)(B,{children:[(0,t.jsx)(x,{children:a("time")}),(0,t.jsx)(x,{children:a("event")}),(0,t.jsx)(x,{children:a("actor")}),(0,t.jsx)(x,{children:a("ip / user agent")}),(0,t.jsx)(x,{children:a("outcome")})]})}),(0,t.jsx)(J,{children:o.map(r=>(0,t.jsxs)(B,{"data-testid":"aa-row",children:[(0,t.jsx)(N,{className:"text-muted-foreground tabular-nums",children:F(r.ts,"\u2014")}),(0,t.jsx)(N,{children:(0,t.jsx)(j,{variant:"secondary",children:r.event})}),(0,t.jsx)(N,{className:"max-w-[24ch] truncate font-mono text-xs",title:r.actorId??void 0,children:r.actorEmail??r.actorId??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,t.jsxs)(N,{className:"max-w-[28ch] truncate text-xs text-muted-foreground",title:r.userAgent??void 0,children:[r.ip??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),r.userAgent!==void 0&&(0,t.jsxs)("span",{className:"ml-1 opacity-70",children:["\xB7 ",r.userAgent]})]}),(0,t.jsx)(N,{children:(0,t.jsx)(j,{variant:r.outcome==="failure"?"destructive":"outline",children:a(r.outcome)})})]},r.seq))})]})})}),e[31]=o,e[32]=a,e[33]=g):g=e[33];let b;return e[34]!==f||e[35]!==p||e[36]!==g||e[37]!==h?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-auth-audit",children:[h,f,p,g]}),e[34]=f,e[35]=p,e[36]=g,e[37]=h,e[38]=b):b=e[38],b},"ne");export{de as default};
1
+ import{i as M}from"./chunk-2D4WBSDO.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as D}from"./chunk-CBTPJPCZ.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as R}from"./chunk-HMMALUXM.js";import{b as j}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{a as U}from"./chunk-JZN3MNJX.js";import"./chunk-EYSF4DHD.js";import{a as G,b as H,c as J,d as B,e as x,f as N}from"./chunk-ZJIYJZ6F.js";import"./chunk-ELPLRD4S.js";import"./chunk-NFI2TNKU.js";import"./chunk-EOFWXI3T.js";import{a as q}from"./chunk-LYVYUTQY.js";import{c as k}from"./chunk-LRUYEVHH.js";import{a as O,e as P}from"./chunk-XV2XEUUB.js";import"./chunk-QFN62JQJ.js";import"./chunk-ZPQBVYNN.js";import{B as z,w as F}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as X}from"./chunk-A6TVTNKO.js";import{a as $,b as Y}from"./chunk-ADABTCDI.js";import{a as A,d as T}from"./chunk-5PEAXTYQ.js";var K=T(X(),1),Q=T($(),1);var t=T(Y(),1);var de=A(()=>{let e=(0,K.c)(39),a=z(),[s,V]=(0,Q.useState)(""),y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={},e[0]=y):y=e[0];let{data:C,error:l,errorSource:S,isLoading:E,refetch:_}=k(q.getAuthAuditLog,y),I;if(e[1]!==C?.entries||e[2]!==s){let r=C?.entries??[],v=s.trim().toLowerCase();I=v===""?r:r.filter(w=>w.event.toLowerCase().includes(v)||(w.actorId??"").toLowerCase().includes(v)||(w.actorEmail??"").toLowerCase().includes(v)||(w.ip??"").toLowerCase().includes(v)||w.outcome.toLowerCase().includes(v)),e[1]=C?.entries,e[2]=s,e[3]=I}else I=e[3];let o=I,L;e[4]===Symbol.for("react.memo_cache_sentinel")?(L=A(r=>{V(r.target.value)},"I"),e[4]=L):L=e[4];let W=L,i;e[5]!==a?(i=a("Filter security events"),e[5]=a,e[6]=i):i=e[6];let n;e[7]!==a?(n=a("filter event, actor, IP"),e[7]=a,e[8]=n):n=e[8];let c;e[9]!==s||e[10]!==i||e[11]!==n?(c=(0,t.jsx)(M,{"aria-label":i,className:"h-8 w-56","data-testid":"aa-search",onChange:W,placeholder:n,value:s}),e[9]=s,e[10]=i,e[11]=n,e[12]=c):c=e[12];let d;e[13]!==_?(d=A(()=>{_()},"m"),e[13]=_,e[14]=d):d=e[14];let m;e[15]!==a?(m=a("Refresh"),e[15]=a,e[16]=m):m=e[16];let u;e[17]!==d||e[18]!==m?(u=(0,t.jsx)(D,{"data-testid":"aa-refresh",onClick:d,size:"xs",type:"button",variant:"ghost",children:m}),e[17]=d,e[18]=m,e[19]=u):u=e[19];let h;e[20]!==c||e[21]!==u?(h=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,u]}),e[20]=c,e[21]=u,e[22]=h):h=e[22];let f;e[23]!==l||e[24]!==S?(f=l!==null&&(0,t.jsx)(U,{error:S,testId:"aa-error"}),e[23]=l,e[24]=S,e[25]=f):f=e[25];let p;e[26]!==l||e[27]!==o.length||e[28]!==E||e[29]!==a?(p=l===null&&!E&&o.length===0&&(0,t.jsx)(R,{description:a("Authentication and security events are recorded here."),testId:"aa-empty",title:a("No security events.")}),e[26]=l,e[27]=o.length,e[28]=E,e[29]=a,e[30]=p):p=e[30];let g;e[31]!==o||e[32]!==a?(g=o.length>0&&(0,t.jsx)(O,{className:"overflow-hidden py-0",children:(0,t.jsx)(P,{className:"max-h-[30rem] overflow-auto px-0",children:(0,t.jsxs)(G,{"data-testid":"aa-table",children:[(0,t.jsx)(H,{children:(0,t.jsxs)(B,{children:[(0,t.jsx)(x,{children:a("time")}),(0,t.jsx)(x,{children:a("event")}),(0,t.jsx)(x,{children:a("actor")}),(0,t.jsx)(x,{children:a("ip / user agent")}),(0,t.jsx)(x,{children:a("outcome")})]})}),(0,t.jsx)(J,{children:o.map(r=>(0,t.jsxs)(B,{"data-testid":"aa-row",children:[(0,t.jsx)(N,{className:"text-muted-foreground tabular-nums",children:F(r.ts,"\u2014")}),(0,t.jsx)(N,{children:(0,t.jsx)(j,{variant:"secondary",children:r.event})}),(0,t.jsx)(N,{className:"max-w-[24ch] truncate font-mono text-xs",title:r.actorId??void 0,children:r.actorEmail??r.actorId??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,t.jsxs)(N,{className:"max-w-[28ch] truncate text-xs text-muted-foreground",title:r.userAgent??void 0,children:[r.ip??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),r.userAgent!==void 0&&(0,t.jsxs)("span",{className:"ml-1 opacity-70",children:["\xB7 ",r.userAgent]})]}),(0,t.jsx)(N,{children:(0,t.jsx)(j,{variant:r.outcome==="failure"?"destructive":"outline",children:a(r.outcome)})})]},r.seq))})]})})}),e[31]=o,e[32]=a,e[33]=g):g=e[33];let b;return e[34]!==f||e[35]!==p||e[36]!==g||e[37]!==h?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-auth-audit",children:[h,f,p,g]}),e[34]=f,e[35]=p,e[36]=g,e[37]=h,e[38]=b):b=e[38],b},"ne");export{de as default};
@@ -1 +1 @@
1
- import{j as u,s as f}from"./chunk-PN7JHEYW.js";import{a as S}from"./chunk-A6TVTNKO.js";import{a as h}from"./chunk-ADABTCDI.js";import{a as s,d as l}from"./chunk-5PEAXTYQ.js";var i=l(S(),1),c=l(h(),1);var g=s(()=>{let t=(0,i.c)(4),[a,n]=(0,c.useState)(!1),[e,m]=(0,c.useState)(null),r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=s(p=>{f((async()=>{n(!0),m(null);try{await p()}catch(b){m(u(b))}n(!1)})())},"e"),t[0]=r):r=t[0];let y=r,o;return t[1]!==a||t[2]!==e?(o={busy:a,error:e,run:y},t[1]=a,t[2]=e,t[3]=o):o=t[3],o},"g");export{g as a};
1
+ import{j as u,s as f}from"./chunk-2ZJJH4YN.js";import{a as S}from"./chunk-A6TVTNKO.js";import{a as h}from"./chunk-ADABTCDI.js";import{a as s,d as l}from"./chunk-5PEAXTYQ.js";var i=l(S(),1),c=l(h(),1);var g=s(()=>{let t=(0,i.c)(4),[a,n]=(0,c.useState)(!1),[e,m]=(0,c.useState)(null),r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=s(p=>{f((async()=>{n(!0),m(null);try{await p()}catch(b){m(u(b))}n(!1)})())},"e"),t[0]=r):r=t[0];let y=r,o;return t[1]!==a||t[2]!==e?(o={busy:a,error:e,run:y},t[1]=a,t[2]=e,t[3]=o):o=t[3],o},"g");export{g as a};
@@ -1 +1 @@
1
- import{a as ee}from"./chunk-2KTN53PK.js";import{a as Z}from"./chunk-PAFHBQFL.js";import{b as Y}from"./chunk-EDL46BPM.js";import{a as X}from"./chunk-DA2CAFXI.js";import{a as W}from"./chunk-DWNWEMQK.js";import"./chunk-4KPATTV6.js";import{i as D}from"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import"./chunk-OKZINWBB.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{b as ae,c as ne}from"./chunk-LLD7TMBV.js";import{a as j,b as te}from"./chunk-HSL3R24X.js";import{a as V}from"./chunk-NVMQPIRS.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import"./chunk-UV6GPH2E.js";import"./chunk-L27FKJTG.js";import"./chunk-VXMAQB2K.js";import"./chunk-S7NFUY75.js";import"./chunk-J3ZEO3PJ.js";import"./chunk-3R6W72RH.js";import"./chunk-2L3WHXJV.js";import"./chunk-EOFWXI3T.js";import{a as I}from"./chunk-LYVYUTQY.js";import{c as A}from"./chunk-KDMDI7KA.js";import"./chunk-TN4Z3P6S.js";import{n as Q}from"./chunk-QB75Q7U4.js";import"./chunk-ZPQBVYNN.js";import{B as q,h as M,i as C,o as G,s as N}from"./chunk-PN7JHEYW.js";import"./chunk-PDBW6GTJ.js";import{a as me}from"./chunk-A6TVTNKO.js";import{a as he,b as pe}from"./chunk-ADABTCDI.js";import{a as l,d as _}from"./chunk-5PEAXTYQ.js";var E=_(me(),1);var c=_(he(),1);var S=_(pe(),1);var ge=l(t=>{let{suggestedIndex:e,table:n}=t;if(typeof n!="string"||n.length===0||typeof e!="object"||e===null)return!1;let{fields:a,name:r}=e;return!Array.isArray(a)||a.length===0||a.some(i=>typeof i!="string"||i.length===0)?!1:typeof r=="string"&&r.length>0},"xe"),be=l((t,e)=>`.index(${JSON.stringify(t)}, [${e.map(n=>JSON.stringify(n)).join(", ")}])`,"ge"),xe=l(t=>{let e=(0,E.c)(19),{fields:n,indexName:a,table:r,testId:i}=t,u=q(),[h,f]=(0,c.useState)(null),m;e[0]!==n||e[1]!==a?(m=l(()=>{let b=be(a,n),$="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if($===void 0){f({copied:!1,declaration:b});return}N($.writeText(b).then(()=>(f({copied:!0,declaration:b}),!0)),()=>{f({copied:!1,declaration:b})})},"m"),e[0]=n,e[1]=a,e[2]=m):m=e[2];let y=m;if(h!==null){let b;return e[3]!==h.copied||e[4]!==h.declaration||e[5]!==u||e[6]!==r||e[7]!==i?(b=h.copied?(0,S.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`${i}-applied`,children:u("Index declaration copied \u2014 add it to {table} in lunora/schema.ts.",{table:r})}):(0,S.jsxs)("span",{className:"flex flex-col gap-1 text-xs text-muted-foreground","data-testid":`${i}-manual`,children:[u("Could not reach the clipboard \u2014 add this to {table} in lunora/schema.ts:",{table:r}),(0,S.jsx)("code",{className:"font-mono break-all select-all",children:h.declaration})]}),e[3]=h.copied,e[4]=h.declaration,e[5]=u,e[6]=r,e[7]=i,e[8]=b):b=e[8],b}let T;e[9]!==u?(T=u("Copy?"),e[9]=u,e[10]=T):T=e[10];let p;e[11]!==u||e[12]!==r?(p=u("Copy index declaration for {table}",{table:r}),e[11]=u,e[12]=r,e[13]=p):p=e[13];let w;return e[14]!==y||e[15]!==T||e[16]!==p||e[17]!==i?(w=(0,S.jsx)(W,{confirmLabel:T,onConfirm:y,testId:i,children:p}),e[14]=y,e[15]=T,e[16]=p,e[17]=i,e[18]=w):w=e[18],w},"ve"),ye=l((t,e)=>{let n=new Map;for(let a of e){let r=`${a.table} ${a.index}`;n.set(r,(n.get(r)??0)+a.reads)}return t.map(a=>({index:a.index,reads:n.get(`${a.table} ${a.index}`)??0,table:a.table}))},"Se"),ve=l(t=>{let e=new Map;for(let n of t)for(let a of n.scannedTables??[])e.set(a.table,(e.get(a.table)??0)+a.scans);return[...e].map(([n,a])=>({scans:a,table:n}))},"Te"),re=l((t,e)=>e.filter(n=>n.type!=="vector"&&n.unique!==!0).map(n=>({index:n.name,table:t})),"P"),we=l(t=>{let e=ye(t.declaredIndexes??[],t.indexHits??[]),n=ve(t.functions??[]),a=t.shardTraffic??[],r=t.analyticsMetrics,i=r&&r.indexHits.length>0?r.indexHits:e,u=r&&r.tableScans.length>0?r.tableScans:n,h=r&&r.shardTraffic.length>0?r.shardTraffic:a,f=ne({indexHits:i,schema:{tables:[]},shardTraffic:h,tableScans:u},{lints:ae,source:"runtime"}),m=t.suppressHotScanTables;return(m===void 0?f:f.filter(y=>!(y.metadata.kind==="hot_scan"&&typeof y.metadata.table=="string"&&m.has(y.metadata.table)))).map(y=>j(y))},"we"),Se=M(I.listTables),Te=M(I.listTableIndexes),Ie=M(I.listTablesIndexes),B=l(t=>`${(t*100).toFixed(1)}%`,"H"),se=l(t=>`${(t/1e3).toFixed(2)}s`,"V"),$e=l(t=>{if(t.length<=1)return t[0]??"";let e=t[t.length-1]??"";return`${t.slice(0,-1).join(", ")} and ${e}`},"Ne"),ke=l((t,e)=>({"high-error-rate":t("High error rate"),"high-evictions":t("High cache eviction rate"),"high-write-contention":t("High write contention"),"low-cache-hit-rate":t("Low cache hit rate"),"missing-index":t("Missing index"),"slow-function":t("Slow function"),"storage-headroom":t("Storage headroom")})[e.kind],"ke"),ie=l((t,e)=>({"high-error-rate":t("{rate} of calls failed.",{rate:B(e.value)}),"high-evictions":t("{count} entries evicted recently.",{count:e.value}),"high-write-contention":t("{rate} of calls hit a write conflict \u2014 consider sharding to cut contention.",{rate:B(e.value)}),"low-cache-hit-rate":t("{rate} hit rate over recent traffic.",{rate:B(e.value)}),"missing-index":t("Slowest call took {duration} \u2014 it full-scanned {tables} with no index.",{duration:se(e.value),tables:$e(e.tables??[])}),"slow-function":t("Slowest call took {duration}.",{duration:se(e.value)}),"storage-headroom":t("{size} of the 10 GiB per-shard ceiling \u2014 plan a .shardBy() migration while it still has runway.",{size:G(e.value)})})[e.kind],"U"),Ne=l(t=>{let e=(0,E.c)(10),{onJump:n,table:a}=t,r=q(),i;e[0]!==n||e[1]!==a?(i=l(()=>{n(a)},"o"),e[0]=n,e[1]=a,e[2]=i):i=e[2];let u=i,h=`in-add-index-${a}`,f;e[3]!==r||e[4]!==a?(f=r("Add index on {table}",{table:a}),e[3]=r,e[4]=a,e[5]=f):f=e[5];let m;return e[6]!==u||e[7]!==h||e[8]!==f?(m=(0,S.jsx)(V,{"data-testid":h,onClick:u,size:"sm",type:"button",variant:"outline",children:f}),e[6]=u,e[7]=h,e[8]=f,e[9]=m):m=e[9],m},"Be"),ze=l(({initialShardKey:t,loadShardTraffic:e})=>{let n=Q(),a=D(),r=q(),{queryShardKey:i,setShardKey:u,shardKey:h}=ee(t),[f,m]=(0,c.useState)(null),[y,T]=(0,c.useState)(null),p=(0,c.useRef)(""),w=A(I.getMetrics,{},{live:!0,shardKey:i}),b=A(I.getFunctionStats,{},{live:!0,shardKey:i}),$=A(I.getAdvisories,{},{live:!0,shardKey:i}),L=w.data??null,K=b.data?.functions??null,F=$.data?.advisories??null,J=w.data?.indexHits??null,O=w.error!==null&&b.error!==null?w.error:null,oe=e??(s=>n.shardTraffic(s)),le=l(async(s,x)=>{let o=s[0];if(o===void 0||o===""){p.current===x&&T(null);return}try{let g=await oe(o);if(p.current!==x)return;let d=new Map;for(let v of g.shards)d.has(v.shardKey)||d.set(v.shardKey,{requests:v.requests,shardKey:v.shardKey});T([...d.values()])}catch{p.current===x&&T(null)}},"Y"),de=l(async(s,x)=>{let o=await Promise.allSettled(s.map(async d=>[d,await n.query(Te,{table:d},C(x))])),g=[];for(let d of o)if(d.status==="fulfilled"){let[v,k]=d.value;g.push(...re(v,k.indexes))}return g},"Z"),z=(0,c.useEffectEvent)(async s=>{p.current=s;let x=[];try{let o=await n.query(Se,{},C(s));if(p.current!==s)return;Y(s),x=o.map(d=>d.name);let g=[];if(x.length>0)try{let d=await n.query(Ie,{tables:x},C(s));if(p.current!==s)return;for(let[v,k]of Object.entries(d.indexesByTable))g.push(...re(v,k))}catch{if(g=await de(x,s),p.current!==s)return}m(g)}catch{p.current===s&&m(null)}await le(x,s)});(0,c.useEffect)(()=>{N(z(i))},[i]);let ce=(0,c.useEffectEvent)(()=>{w.refetch(),b.refetch(),$.refetch(),N(z(i))});(0,c.useEffect)(()=>{let s=l(()=>{document.visibilityState==="visible"&&ce()},"r");return document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s)}},[]);let U=(0,c.useCallback)(s=>{N(a({search:{table:s},to:"/schema"}))},[a]),H=(0,c.useMemo)(()=>X(L,K),[K,L]),P=(0,c.useMemo)(()=>new Set(H.filter(s=>s.kind==="missing-index").flatMap(s=>s.tables??[])),[H]),R=(0,c.useMemo)(()=>we({declaredIndexes:f??[],functions:K,indexHits:J,shardTraffic:y,suppressHotScanTables:P}),[f,K,J,P,y]),ue=(0,c.useMemo)(()=>{let s=H.map(o=>{let g=o.kind==="missing-index"?o.tables??[]:[];return{action:g.length>0?g.map(d=>(0,S.jsx)(Ne,{onJump:U,table:d},d)):void 0,description:o.message===void 0?ie(r,o):`${ie(r,o)} \u2014 ${o.message}`,entity:o.fn,issueType:ke(r,o),key:`${o.kind}:${o.fn??""}`,level:o.severity}}),x=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(F??[]).map(o=>{let g=j(o);if(x.has(o.name)&&ge(o.metadata)){let{table:d,suggestedIndex:v}=o.metadata,k=`in-apply-index-${d}-${v.name}`;return{...g,action:(0,S.jsx)(xe,{fields:v.fields,indexName:v.name,table:d,testId:k})}}return g}),...R,...s]},[F,H,U,R,r]),fe=(0,S.jsx)(Z,{onChange:u,testId:"in-shard-input",value:h});return(0,S.jsx)(te,{error:O,errorSource:O===null?void 0:w.errorSource,rows:ue,shardKey:i,testId:"lunora-insights",toolbar:fe})},"Ue");export{ze as InsightsPanel};
1
+ import{a as ee}from"./chunk-2KTN53PK.js";import{a as Z}from"./chunk-YLC2ZYCL.js";import{b as Y}from"./chunk-EDL46BPM.js";import{a as X}from"./chunk-DA2CAFXI.js";import{a as W}from"./chunk-W5BTAOHO.js";import"./chunk-4KPATTV6.js";import{i as D}from"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import"./chunk-2D4WBSDO.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{b as ae,c as ne}from"./chunk-LLD7TMBV.js";import{a as j,b as te}from"./chunk-AQG5OGO4.js";import{a as V}from"./chunk-CBTPJPCZ.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import"./chunk-JZN3MNJX.js";import"./chunk-EYSF4DHD.js";import"./chunk-ZJIYJZ6F.js";import"./chunk-ELPLRD4S.js";import"./chunk-NFI2TNKU.js";import"./chunk-EOFWXI3T.js";import{a as I}from"./chunk-LYVYUTQY.js";import{c as A}from"./chunk-LRUYEVHH.js";import"./chunk-XV2XEUUB.js";import{n as Q}from"./chunk-QFN62JQJ.js";import"./chunk-ZPQBVYNN.js";import{B as q,h as M,i as C,o as G,s as N}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as me}from"./chunk-A6TVTNKO.js";import{a as he,b as pe}from"./chunk-ADABTCDI.js";import{a as l,d as _}from"./chunk-5PEAXTYQ.js";var E=_(me(),1);var c=_(he(),1);var S=_(pe(),1);var ge=l(t=>{let{suggestedIndex:e,table:n}=t;if(typeof n!="string"||n.length===0||typeof e!="object"||e===null)return!1;let{fields:a,name:r}=e;return!Array.isArray(a)||a.length===0||a.some(i=>typeof i!="string"||i.length===0)?!1:typeof r=="string"&&r.length>0},"xe"),be=l((t,e)=>`.index(${JSON.stringify(t)}, [${e.map(n=>JSON.stringify(n)).join(", ")}])`,"ge"),xe=l(t=>{let e=(0,E.c)(19),{fields:n,indexName:a,table:r,testId:i}=t,u=q(),[h,f]=(0,c.useState)(null),m;e[0]!==n||e[1]!==a?(m=l(()=>{let b=be(a,n),$="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if($===void 0){f({copied:!1,declaration:b});return}N($.writeText(b).then(()=>(f({copied:!0,declaration:b}),!0)),()=>{f({copied:!1,declaration:b})})},"m"),e[0]=n,e[1]=a,e[2]=m):m=e[2];let y=m;if(h!==null){let b;return e[3]!==h.copied||e[4]!==h.declaration||e[5]!==u||e[6]!==r||e[7]!==i?(b=h.copied?(0,S.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`${i}-applied`,children:u("Index declaration copied \u2014 add it to {table} in lunora/schema.ts.",{table:r})}):(0,S.jsxs)("span",{className:"flex flex-col gap-1 text-xs text-muted-foreground","data-testid":`${i}-manual`,children:[u("Could not reach the clipboard \u2014 add this to {table} in lunora/schema.ts:",{table:r}),(0,S.jsx)("code",{className:"font-mono break-all select-all",children:h.declaration})]}),e[3]=h.copied,e[4]=h.declaration,e[5]=u,e[6]=r,e[7]=i,e[8]=b):b=e[8],b}let T;e[9]!==u?(T=u("Copy?"),e[9]=u,e[10]=T):T=e[10];let p;e[11]!==u||e[12]!==r?(p=u("Copy index declaration for {table}",{table:r}),e[11]=u,e[12]=r,e[13]=p):p=e[13];let w;return e[14]!==y||e[15]!==T||e[16]!==p||e[17]!==i?(w=(0,S.jsx)(W,{confirmLabel:T,onConfirm:y,testId:i,children:p}),e[14]=y,e[15]=T,e[16]=p,e[17]=i,e[18]=w):w=e[18],w},"ve"),ye=l((t,e)=>{let n=new Map;for(let a of e){let r=`${a.table} ${a.index}`;n.set(r,(n.get(r)??0)+a.reads)}return t.map(a=>({index:a.index,reads:n.get(`${a.table} ${a.index}`)??0,table:a.table}))},"Se"),ve=l(t=>{let e=new Map;for(let n of t)for(let a of n.scannedTables??[])e.set(a.table,(e.get(a.table)??0)+a.scans);return[...e].map(([n,a])=>({scans:a,table:n}))},"Te"),re=l((t,e)=>e.filter(n=>n.type!=="vector"&&n.unique!==!0).map(n=>({index:n.name,table:t})),"P"),we=l(t=>{let e=ye(t.declaredIndexes??[],t.indexHits??[]),n=ve(t.functions??[]),a=t.shardTraffic??[],r=t.analyticsMetrics,i=r&&r.indexHits.length>0?r.indexHits:e,u=r&&r.tableScans.length>0?r.tableScans:n,h=r&&r.shardTraffic.length>0?r.shardTraffic:a,f=ne({indexHits:i,schema:{tables:[]},shardTraffic:h,tableScans:u},{lints:ae,source:"runtime"}),m=t.suppressHotScanTables;return(m===void 0?f:f.filter(y=>!(y.metadata.kind==="hot_scan"&&typeof y.metadata.table=="string"&&m.has(y.metadata.table)))).map(y=>j(y))},"we"),Se=M(I.listTables),Te=M(I.listTableIndexes),Ie=M(I.listTablesIndexes),B=l(t=>`${(t*100).toFixed(1)}%`,"H"),se=l(t=>`${(t/1e3).toFixed(2)}s`,"V"),$e=l(t=>{if(t.length<=1)return t[0]??"";let e=t[t.length-1]??"";return`${t.slice(0,-1).join(", ")} and ${e}`},"Ne"),ke=l((t,e)=>({"high-error-rate":t("High error rate"),"high-evictions":t("High cache eviction rate"),"high-write-contention":t("High write contention"),"low-cache-hit-rate":t("Low cache hit rate"),"missing-index":t("Missing index"),"slow-function":t("Slow function"),"storage-headroom":t("Storage headroom")})[e.kind],"ke"),ie=l((t,e)=>({"high-error-rate":t("{rate} of calls failed.",{rate:B(e.value)}),"high-evictions":t("{count} entries evicted recently.",{count:e.value}),"high-write-contention":t("{rate} of calls hit a write conflict \u2014 consider sharding to cut contention.",{rate:B(e.value)}),"low-cache-hit-rate":t("{rate} hit rate over recent traffic.",{rate:B(e.value)}),"missing-index":t("Slowest call took {duration} \u2014 it full-scanned {tables} with no index.",{duration:se(e.value),tables:$e(e.tables??[])}),"slow-function":t("Slowest call took {duration}.",{duration:se(e.value)}),"storage-headroom":t("{size} of the 10 GiB per-shard ceiling \u2014 plan a .shardBy() migration while it still has runway.",{size:G(e.value)})})[e.kind],"U"),Ne=l(t=>{let e=(0,E.c)(10),{onJump:n,table:a}=t,r=q(),i;e[0]!==n||e[1]!==a?(i=l(()=>{n(a)},"o"),e[0]=n,e[1]=a,e[2]=i):i=e[2];let u=i,h=`in-add-index-${a}`,f;e[3]!==r||e[4]!==a?(f=r("Add index on {table}",{table:a}),e[3]=r,e[4]=a,e[5]=f):f=e[5];let m;return e[6]!==u||e[7]!==h||e[8]!==f?(m=(0,S.jsx)(V,{"data-testid":h,onClick:u,size:"sm",type:"button",variant:"outline",children:f}),e[6]=u,e[7]=h,e[8]=f,e[9]=m):m=e[9],m},"Be"),ze=l(({initialShardKey:t,loadShardTraffic:e})=>{let n=Q(),a=D(),r=q(),{queryShardKey:i,setShardKey:u,shardKey:h}=ee(t),[f,m]=(0,c.useState)(null),[y,T]=(0,c.useState)(null),p=(0,c.useRef)(""),w=A(I.getMetrics,{},{live:!0,shardKey:i}),b=A(I.getFunctionStats,{},{live:!0,shardKey:i}),$=A(I.getAdvisories,{},{live:!0,shardKey:i}),L=w.data??null,K=b.data?.functions??null,F=$.data?.advisories??null,J=w.data?.indexHits??null,O=w.error!==null&&b.error!==null?w.error:null,oe=e??(s=>n.shardTraffic(s)),le=l(async(s,x)=>{let o=s[0];if(o===void 0||o===""){p.current===x&&T(null);return}try{let g=await oe(o);if(p.current!==x)return;let d=new Map;for(let v of g.shards)d.has(v.shardKey)||d.set(v.shardKey,{requests:v.requests,shardKey:v.shardKey});T([...d.values()])}catch{p.current===x&&T(null)}},"Y"),de=l(async(s,x)=>{let o=await Promise.allSettled(s.map(async d=>[d,await n.query(Te,{table:d},C(x))])),g=[];for(let d of o)if(d.status==="fulfilled"){let[v,k]=d.value;g.push(...re(v,k.indexes))}return g},"Z"),z=(0,c.useEffectEvent)(async s=>{p.current=s;let x=[];try{let o=await n.query(Se,{},C(s));if(p.current!==s)return;Y(s),x=o.map(d=>d.name);let g=[];if(x.length>0)try{let d=await n.query(Ie,{tables:x},C(s));if(p.current!==s)return;for(let[v,k]of Object.entries(d.indexesByTable))g.push(...re(v,k))}catch{if(g=await de(x,s),p.current!==s)return}m(g)}catch{p.current===s&&m(null)}await le(x,s)});(0,c.useEffect)(()=>{N(z(i))},[i]);let ce=(0,c.useEffectEvent)(()=>{w.refetch(),b.refetch(),$.refetch(),N(z(i))});(0,c.useEffect)(()=>{let s=l(()=>{document.visibilityState==="visible"&&ce()},"r");return document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s)}},[]);let U=(0,c.useCallback)(s=>{N(a({search:{table:s},to:"/schema"}))},[a]),H=(0,c.useMemo)(()=>X(L,K),[K,L]),P=(0,c.useMemo)(()=>new Set(H.filter(s=>s.kind==="missing-index").flatMap(s=>s.tables??[])),[H]),R=(0,c.useMemo)(()=>we({declaredIndexes:f??[],functions:K,indexHits:J,shardTraffic:y,suppressHotScanTables:P}),[f,K,J,P,y]),ue=(0,c.useMemo)(()=>{let s=H.map(o=>{let g=o.kind==="missing-index"?o.tables??[]:[];return{action:g.length>0?g.map(d=>(0,S.jsx)(Ne,{onJump:U,table:d},d)):void 0,description:o.message===void 0?ie(r,o):`${ie(r,o)} \u2014 ${o.message}`,entity:o.fn,issueType:ke(r,o),key:`${o.kind}:${o.fn??""}`,level:o.severity}}),x=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(F??[]).map(o=>{let g=j(o);if(x.has(o.name)&&ge(o.metadata)){let{table:d,suggestedIndex:v}=o.metadata,k=`in-apply-index-${d}-${v.name}`;return{...g,action:(0,S.jsx)(xe,{fields:v.fields,indexName:v.name,table:d,testId:k})}}return g}),...R,...s]},[F,H,U,R,r]),fe=(0,S.jsx)(Z,{onChange:u,testId:"in-shard-input",value:h});return(0,S.jsx)(te,{error:O,errorSource:O===null?void 0:w.errorSource,rows:ue,shardKey:i,testId:"lunora-insights",toolbar:fe})},"Ue");export{ze as InsightsPanel};