@lunora/studio 1.0.0-alpha.350 → 1.0.0-alpha.352

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 (125) hide show
  1. package/dist/index.d.mts +4 -1
  2. package/dist/index.d.ts +4 -1
  3. package/dist/index.mjs +1 -1
  4. package/dist/mount.mjs +1 -1
  5. package/dist/packem_chunks/AdvisorHealthPanel.mjs +1 -1
  6. package/dist/packem_chunks/ApiTab.mjs +1 -1
  7. package/dist/packem_chunks/AuditPanel.mjs +1 -1
  8. package/dist/packem_chunks/ExportImportPanel.mjs +8 -8
  9. package/dist/packem_chunks/FileBrowser.mjs +1 -1
  10. package/dist/packem_chunks/FunctionRunner.mjs +1 -1
  11. package/dist/packem_chunks/FunctionStatsPanel.mjs +1 -1
  12. package/dist/packem_chunks/HealthPanel.mjs +1 -1
  13. package/dist/packem_chunks/InsightsPanel.mjs +1 -1
  14. package/dist/packem_chunks/LogsPanel.mjs +1 -1
  15. package/dist/packem_chunks/MailPanel.mjs +1 -1
  16. package/dist/packem_chunks/MetricsPanel.mjs +1 -1
  17. package/dist/packem_chunks/NotificationsPanel.mjs +1 -1
  18. package/dist/packem_chunks/PitrPanel.mjs +1 -1
  19. package/dist/packem_chunks/SchemaViewer.mjs +1 -1
  20. package/dist/packem_chunks/SecurityAdvisorPanel.mjs +1 -1
  21. package/dist/packem_chunks/SettingsPanel.mjs +1 -1
  22. package/dist/packem_chunks/SqlEditorPanel.mjs +1 -1
  23. package/dist/packem_chunks/TableEditor.mjs +1 -1
  24. package/dist/packem_chunks/agents-panel.mjs +1 -1
  25. package/dist/packem_chunks/ai-usage-panel.mjs +1 -1
  26. package/dist/packem_chunks/auth-audit-panel.mjs +1 -1
  27. package/dist/packem_chunks/containers-panel.mjs +1 -1
  28. package/dist/packem_chunks/dashboards-panel.mjs +1 -1
  29. package/dist/packem_chunks/evals-panel.mjs +1 -1
  30. package/dist/packem_chunks/fanout-panel.mjs +1 -1
  31. package/dist/packem_chunks/flags-panel.mjs +1 -1
  32. package/dist/packem_chunks/issues-panel.mjs +1 -1
  33. package/dist/packem_chunks/kv-browser.mjs +1 -1
  34. package/dist/packem_chunks/migrations-route.mjs +1 -1
  35. package/dist/packem_chunks/payments-panel.mjs +1 -1
  36. package/dist/packem_chunks/permissions-panel.mjs +1 -1
  37. package/dist/packem_chunks/queues-panel.mjs +1 -1
  38. package/dist/packem_chunks/reactors-panel.mjs +1 -1
  39. package/dist/packem_chunks/rls-panel.mjs +1 -1
  40. package/dist/packem_chunks/storage-rules-panel.mjs +1 -1
  41. package/dist/packem_chunks/subscriptions-panel.mjs +1 -1
  42. package/dist/packem_chunks/traces-panel.mjs +1 -1
  43. package/dist/packem_chunks/workflows-panel.mjs +1 -1
  44. package/dist/packem_shared/{ADMIN_FUNCTIONS-B8yyk5BX.mjs → ADMIN_FUNCTIONS-4aGsMs95.mjs} +1 -1
  45. package/dist/packem_shared/{ApiDocsPanel-B_RaW7Br.mjs → ApiDocsPanel-E4Vr-8zW.mjs} +1 -1
  46. package/dist/packem_shared/{DataBrowser-Cc1qZX-4.mjs → DataBrowser-C5HbI4TH.mjs} +1 -1
  47. package/dist/packem_shared/{GlobalDataBrowser-Hq6gTlkb.mjs → GlobalDataBrowser-D0H2yJSl.mjs} +1 -1
  48. package/dist/packem_shared/{HomePanel-DeyYLVxc.mjs → HomePanel-CcYkDlR-.mjs} +1 -1
  49. package/dist/packem_shared/{MigrationsPanel-CMZYYcQ5.mjs → MigrationsPanel-YyCO_T-3.mjs} +1 -1
  50. package/dist/packem_shared/{Studio-BhTqTeGb.mjs → Studio-4vJzwwNa.mjs} +1 -1
  51. package/dist/packem_shared/{StudioApp-B1d0beD4.mjs → StudioApp-px2FMPDS.mjs} +1 -1
  52. package/dist/packem_shared/{home-panel-0XMGe1hP.mjs → home-panel-DPiMVQZ2.mjs} +1 -1
  53. package/dist/packem_shared/{studio-CA3ZKwVK.mjs → studio-DIUgH7k0.mjs} +1 -1
  54. package/dist/packem_shared/{table-list-sidebar-nA7g7uSk.mjs → table-list-sidebar-CCRB_iYz.mjs} +1 -1
  55. package/dist/packem_shared/{use-sql-assistant-DXnqbBs-.mjs → use-sql-assistant-BMVlguKF.mjs} +1 -1
  56. package/dist/standalone/{chunk-WQGT24W6.js → chunk-22O2JDWR.js} +1 -1
  57. package/dist/standalone/{chunk-RXVXXRYD.js → chunk-2DV455PX.js} +1 -1
  58. package/dist/standalone/{chunk-B7MHW3A5.js → chunk-2EMNPL3B.js} +1 -1
  59. package/dist/standalone/{chunk-LOV52GLG.js → chunk-35BGGOWV.js} +1 -1
  60. package/dist/standalone/{chunk-BTRYFPZH.js → chunk-3MQ477EE.js} +1 -1
  61. package/dist/standalone/{chunk-XWEDIIIT.js → chunk-453GHHZ4.js} +1 -1
  62. package/dist/standalone/{chunk-QAQVT4FS.js → chunk-4CITH2NU.js} +1 -1
  63. package/dist/standalone/{chunk-E32FS6PE.js → chunk-4EDOPHLM.js} +1 -1
  64. package/dist/standalone/{chunk-EDGOSJXL.js → chunk-4QRVJDM4.js} +1 -1
  65. package/dist/standalone/{chunk-B3AXFXAD.js → chunk-4UWYDYM5.js} +1 -1
  66. package/dist/standalone/{chunk-SXD6JQXF.js → chunk-57ZNR6IA.js} +1 -1
  67. package/dist/standalone/{chunk-R3KLR5EP.js → chunk-6DYXTEU7.js} +1 -1
  68. package/dist/standalone/chunk-6GPEHYCG.js +1 -0
  69. package/dist/standalone/{chunk-E3VSRIQU.js → chunk-6GRI2HXU.js} +1 -1
  70. package/dist/standalone/{chunk-7F3S5OQT.js → chunk-6QBK3Z7A.js} +1 -1
  71. package/dist/standalone/{chunk-4ZEL6BYL.js → chunk-6UTZXEW3.js} +1 -1
  72. package/dist/standalone/{chunk-CGZVMM3P.js → chunk-7EAHHRJR.js} +1 -1
  73. package/dist/standalone/{chunk-HOPAJ5F6.js → chunk-ACNWZIAH.js} +1 -1
  74. package/dist/standalone/{chunk-5J32EGHF.js → chunk-ANACHJRU.js} +1 -1
  75. package/dist/standalone/chunk-BAGJYLSU.js +8 -0
  76. package/dist/standalone/{chunk-HLAAOW33.js → chunk-BCOOULSO.js} +1 -1
  77. package/dist/standalone/{chunk-ZMQ6PKLN.js → chunk-BKH2NALB.js} +1 -1
  78. package/dist/standalone/{chunk-ZBFWT34B.js → chunk-BTOOJXUL.js} +1 -1
  79. package/dist/standalone/{chunk-2EL4EMYZ.js → chunk-C6FNBKCO.js} +1 -1
  80. package/dist/standalone/{chunk-OECMBE6Q.js → chunk-DSTNWB4N.js} +1 -1
  81. package/dist/standalone/{chunk-WIET27J3.js → chunk-DTW4E5AB.js} +1 -1
  82. package/dist/standalone/{chunk-VB6YJKPA.js → chunk-FNWRS4VQ.js} +1 -1
  83. package/dist/standalone/{chunk-UTX6IBA3.js → chunk-FST24UXA.js} +1 -1
  84. package/dist/standalone/{chunk-ZTOXQK4V.js → chunk-FXGYX2V6.js} +1 -1
  85. package/dist/standalone/{chunk-MFNO5BFR.js → chunk-HWTX54JM.js} +1 -1
  86. package/dist/standalone/{chunk-26OKWFLO.js → chunk-HZCLLEWP.js} +1 -1
  87. package/dist/standalone/{chunk-7AZYREIY.js → chunk-IRCUXARN.js} +1 -1
  88. package/dist/standalone/{chunk-W7Z35E2E.js → chunk-IVQKQBKK.js} +1 -1
  89. package/dist/standalone/{chunk-W2XSKODB.js → chunk-K7FZTYAY.js} +1 -1
  90. package/dist/standalone/{chunk-5NZWQEEJ.js → chunk-KNX3KB7E.js} +1 -1
  91. package/dist/standalone/{chunk-MMJTKSHL.js → chunk-LYHEBMM6.js} +1 -1
  92. package/dist/standalone/{chunk-BVKQA5OL.js → chunk-M2RIGPGL.js} +1 -1
  93. package/dist/standalone/{chunk-EOR73TZZ.js → chunk-MKVZXGJQ.js} +1 -1
  94. package/dist/standalone/chunk-OIDFWEJX.js +21 -0
  95. package/dist/standalone/{chunk-CLINNLLE.js → chunk-OJG65AG4.js} +1 -1
  96. package/dist/standalone/{chunk-XMEVNOCA.js → chunk-Q4N3TJPV.js} +1 -1
  97. package/dist/standalone/{chunk-NVHHB5EV.js → chunk-QEVFVWGC.js} +1 -1
  98. package/dist/standalone/{chunk-JAHK7RRJ.js → chunk-RHOQJNDW.js} +1 -1
  99. package/dist/standalone/{chunk-7MN724WR.js → chunk-RQDSPVVH.js} +1 -1
  100. package/dist/standalone/{chunk-P5GAJKDW.js → chunk-S5S2YICJ.js} +1 -1
  101. package/dist/standalone/{chunk-ZZAJHNZ6.js → chunk-S6JFSLBK.js} +1 -1
  102. package/dist/standalone/{chunk-GMW2DYFU.js → chunk-SDTHCM5H.js} +1 -1
  103. package/dist/standalone/{chunk-JG2C7SS2.js → chunk-SM2IQWCJ.js} +1 -1
  104. package/dist/standalone/{chunk-GPOSJNMV.js → chunk-T2QAOXUO.js} +1 -1
  105. package/dist/standalone/{chunk-2WNL74MI.js → chunk-T4VAXHRL.js} +1 -1
  106. package/dist/standalone/{chunk-FPIUVV7Q.js → chunk-TBDJVYCB.js} +1 -1
  107. package/dist/standalone/{chunk-HFYFYNSX.js → chunk-TTD7BKB6.js} +1 -1
  108. package/dist/standalone/{chunk-KFNDET5D.js → chunk-UCK6ITED.js} +1 -1
  109. package/dist/standalone/{chunk-UZIBQZ2F.js → chunk-UKKZJRJT.js} +1 -1
  110. package/dist/standalone/{chunk-F5LTDUMB.js → chunk-V74BXQXC.js} +1 -1
  111. package/dist/standalone/{chunk-2ZO7XY3Z.js → chunk-VHMA6YPT.js} +1 -1
  112. package/dist/standalone/{chunk-SOO2HXV6.js → chunk-W4X4J7BU.js} +1 -1
  113. package/dist/standalone/{chunk-S7XAAH7U.js → chunk-W6ZKEW5M.js} +1 -1
  114. package/dist/standalone/{chunk-D7JK65OK.js → chunk-WIYDA4XT.js} +1 -1
  115. package/dist/standalone/{chunk-2X6O33OX.js → chunk-X7GSROPX.js} +1 -1
  116. package/dist/standalone/{chunk-O3FDK56W.js → chunk-Y7SN6CTX.js} +1 -1
  117. package/dist/standalone/{chunk-JGMQQ3S7.js → chunk-YRQHFMEY.js} +1 -1
  118. package/dist/standalone/{chunk-YJ2WHOGO.js → chunk-ZKPRORLI.js} +1 -1
  119. package/dist/standalone/{chunk-TWMS2TMF.js → chunk-ZLSNET6H.js} +1 -1
  120. package/dist/standalone/{chunk-CIVMATZK.js → chunk-ZM4K2ETZ.js} +1 -1
  121. package/dist/standalone/studio.js +1 -1
  122. package/package.json +5 -5
  123. package/dist/standalone/chunk-BHOLL76W.js +0 -8
  124. package/dist/standalone/chunk-GQYA5W5T.js +0 -1
  125. package/dist/standalone/chunk-U76DVXTR.js +0 -21
@@ -1 +1 @@
1
- import{c as X}from"react/compiler-runtime";import{useNavigate as se}from"@tanstack/react-router";import{useState as L,useRef as ae,useEffectEvent as Q,useEffect as z,useCallback as re,useMemo as N}from"react";import{ShardInput as oe}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{B as ie}from"../packem_shared/button-q0UYSmrn.mjs";import{u as B}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{u as ce}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{u as le}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as K}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as w}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{f as k,d as E,c as M,n as de}from"../packem_shared/internal-BXEjuLPN.mjs";import{r as ue}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{a as G,A as fe}from"../packem_shared/advisor-view-fNcNYW2Q.mjs";import{ConfirmButton as me}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{jsx as v,jsxs as he}from"react/jsx-runtime";import{deriveInsights as pe}from"../packem_shared/DEFAULT_INSIGHT_THRESHOLDS-D5YMT0gM.mjs";import{runAdvisor as be,RUNTIME_LINTS as xe}from"@lunora/advisor";const ye=t=>{const{suggestedIndex:e,table:a}=t;if(typeof a!="string"||a.length===0||typeof e!="object"||e===null)return!1;const{fields:n,name:s}=e;return!Array.isArray(n)||n.length===0||n.some(i=>typeof i!="string"||i.length===0)?!1:typeof s=="string"&&s.length>0},ge=(t,e)=>`.index(${JSON.stringify(t)}, [${e.map(a=>JSON.stringify(a)).join(", ")}])`,ve=t=>{const e=X(19),{fields:a,indexName:n,table:s,testId:i}=t,l=K(),[f,d]=L(null);let m;e[0]!==a||e[1]!==n?(m=()=>{const b=ge(n,a),I="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if(I===void 0){d({copied:!1,declaration:b});return}k(I.writeText(b).then(()=>(d({copied:!0,declaration:b}),!0)),()=>{d({copied:!1,declaration:b})})},e[0]=a,e[1]=n,e[2]=m):m=e[2];const S=m;if(f!==null){let b;return e[3]!==f.copied||e[4]!==f.declaration||e[5]!==l||e[6]!==s||e[7]!==i?(b=f.copied?v("span",{className:"text-xs text-muted-foreground","data-testid":`${i}-applied`,children:l("Index declaration copied — add it to {table} in lunora/schema.ts.",{table:s})}):he("span",{className:"flex flex-col gap-1 text-xs text-muted-foreground","data-testid":`${i}-manual`,children:[l("Could not reach the clipboard — add this to {table} in lunora/schema.ts:",{table:s}),v("code",{className:"font-mono break-all select-all",children:f.declaration})]}),e[3]=f.copied,e[4]=f.declaration,e[5]=l,e[6]=s,e[7]=i,e[8]=b):b=e[8],b}let u;e[9]!==l?(u=l("Copy?"),e[9]=l,e[10]=u):u=e[10];let h;e[11]!==l||e[12]!==s?(h=l("Copy index declaration for {table}",{table:s}),e[11]=l,e[12]=s,e[13]=h):h=e[13];let y;return e[14]!==S||e[15]!==u||e[16]!==h||e[17]!==i?(y=v(me,{confirmLabel:u,onConfirm:S,testId:i,children:h}),e[14]=S,e[15]=u,e[16]=h,e[17]=i,e[18]=y):y=e[18],y},Se=(t,e)=>{const a=new Map;for(const n of e){const s=`${n.table} ${n.index}`;a.set(s,(a.get(s)??0)+n.reads)}return t.map(n=>({index:n.index,reads:a.get(`${n.table} ${n.index}`)??0,table:n.table}))},Te=t=>{const e=new Map;for(const a of t)for(const n of a.scannedTables??[])e.set(n.table,(e.get(n.table)??0)+n.scans);return[...e].map(([a,n])=>({scans:n,table:a}))},P=(t,e)=>e.map(a=>({index:a.name,table:t})),we=t=>{const e=Se(t.declaredIndexes??[],t.indexHits??[]),a=Te(t.functions??[]),n=t.shardTraffic??[],s=t.analyticsMetrics,i=s&&s.indexHits.length>0?s.indexHits:e,l=s&&s.tableScans.length>0?s.tableScans:a,f=s&&s.shardTraffic.length>0?s.shardTraffic:n,d=be({indexHits:i,schema:{tables:[]},shardTraffic:f,tableScans:l},{lints:xe,source:"runtime"}),m=t.suppressHotScanTables;return(m===void 0?d:d.filter(u=>!(u.metadata.kind==="hot_scan"&&typeof u.metadata.table=="string"&&m.has(u.metadata.table)))).map(u=>G(u))},Ie=M(w.listTables),$e=M(w.listTableIndexes),Ae=M(w.listTablesIndexes),H=t=>`${(t*100).toFixed(1)}%`,V=t=>`${(t/1e3).toFixed(2)}s`,Ne=t=>{if(t.length<=1)return t[0]??"";const e=t[t.length-1]??"";return`${t.slice(0,-1).join(", ")} and ${e}`},ke=(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],U=(t,e)=>({"high-error-rate":t("{rate} of calls failed.",{rate:H(e.value)}),"high-evictions":t("{count} entries evicted recently.",{count:e.value}),"high-write-contention":t("{rate} of calls hit a write conflict — consider sharding to cut contention.",{rate:H(e.value)}),"low-cache-hit-rate":t("{rate} hit rate over recent traffic.",{rate:H(e.value)}),"missing-index":t("Slowest call took {duration} — it full-scanned {tables} with no index.",{duration:V(e.value),tables:Ne(e.tables??[])}),"slow-function":t("Slowest call took {duration}.",{duration:V(e.value)}),"storage-headroom":t("{size} of the 10 GiB per-shard ceiling — plan a .shardBy() migration while it still has runway.",{size:de(e.value)})})[e.kind],Be=t=>{const e=X(10),{onJump:a,table:n}=t,s=K();let i;e[0]!==a||e[1]!==n?(i=()=>{a(n)},e[0]=a,e[1]=n,e[2]=i):i=e[2];const l=i,f=`in-add-index-${n}`;let d;e[3]!==s||e[4]!==n?(d=s("Add index on {table}",{table:n}),e[3]=s,e[4]=n,e[5]=d):d=e[5];let m;return e[6]!==l||e[7]!==f||e[8]!==d?(m=v(ie,{"data-testid":f,onClick:l,size:"sm",type:"button",variant:"outline",children:d}),e[6]=l,e[7]=f,e[8]=d,e[9]=m):m=e[9],m},Ue=({initialShardKey:t,loadShardTraffic:e})=>{const a=le(),n=se(),s=K(),{queryShardKey:i,setShardKey:l,shardKey:f}=ce(t),[d,m]=L(null),[S,u]=L(null),h=ae(""),y=B(w.getMetrics,{},{live:!0,shardKey:i}),b=B(w.getFunctionStats,{},{live:!0,shardKey:i}),I=B(w.getAdvisories,{},{live:!0,shardKey:i}),C=y.data??null,$=b.data?.functions??null,D=I.data?.advisories??null,R=y.data?.indexHits??null,j=y.error!==null&&b.error!==null?y.error:null,W=e??(r=>a.shardTraffic(r)),Y=async(r,x)=>{const g=r[0];if(g===void 0||g===""){h.current===x&&u(null);return}try{const o=await W(g);if(h.current!==x)return;const c=new Map;for(const p of o.shards)c.has(p.shardKey)||c.set(p.shardKey,{requests:p.requests,shardKey:p.shardKey});u([...c.values()])}catch{h.current===x&&u(null)}},Z=async(r,x)=>{const g=await Promise.allSettled(r.map(async c=>[c,await a.query($e,{table:c},E(x))])),o=[];for(const c of g)if(c.status==="fulfilled"){const[p,T]=c.value;o.push(...P(p,T.indexes))}return o},F=Q(async r=>{h.current=r;let x=[];try{const g=await a.query(Ie,{},E(r));if(h.current!==r)return;ue(r),x=g.map(c=>c.name);let o=[];if(x.length>0)try{const c=await a.query(Ae,{tables:x},E(r));if(h.current!==r)return;for(const[p,T]of Object.entries(c.indexesByTable))o.push(...P(p,T))}catch{if(o=await Z(x,r),h.current!==r)return}m(o)}catch{h.current===r&&m(null)}await Y(x,r)});z(()=>{k(F(i))},[i]);const _=Q(()=>{y.refetch(),b.refetch(),I.refetch(),k(F(i))});z(()=>{const r=()=>{document.visibilityState==="visible"&&_()};return document.addEventListener("visibilitychange",r),()=>{document.removeEventListener("visibilitychange",r)}},[]);const O=re(r=>{k(n({search:{table:r},to:"/schema"}))},[n]),A=N(()=>pe(C,$),[$,C]),q=N(()=>new Set(A.filter(r=>r.kind==="missing-index").flatMap(r=>r.tables??[])),[A]),J=N(()=>we({declaredIndexes:d??[],functions:$,indexHits:R,shardTraffic:S,suppressHotScanTables:q}),[d,$,R,q,S]),ee=N(()=>{const r=A.map(o=>{const c=o.kind==="missing-index"?o.tables??[]:[];return{action:c.length>0?c.map(p=>v(Be,{onJump:O,table:p},p)):void 0,description:o.message===void 0?U(s,o):`${U(s,o)} — ${o.message}`,entity:o.fn,issueType:ke(s,o),key:`${o.kind}:${o.fn??""}`,level:o.severity}}),x=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(D??[]).map(o=>{const c=G(o);if(x.has(o.name)&&ye(o.metadata)){const{table:p,suggestedIndex:T}=o.metadata,ne=`in-apply-index-${p}-${T.name}`;return{...c,action:v(ve,{fields:T.fields,indexName:T.name,table:p,testId:ne})}}return c}),...J,...r]},[D,A,O,J,s]),te=v(oe,{onChange:l,testId:"in-shard-input",value:f});return v(fe,{error:j,errorSource:j===null?void 0:y.errorSource,rows:ee,testId:"lunora-insights",toolbar:te})};export{Ue as InsightsPanel};
1
+ import{c as X}from"react/compiler-runtime";import{useNavigate as se}from"@tanstack/react-router";import{useState as L,useRef as ae,useEffectEvent as Q,useEffect as z,useCallback as re,useMemo as N}from"react";import{ShardInput as oe}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{B as ie}from"../packem_shared/button-q0UYSmrn.mjs";import{u as B}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{u as ce}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{u as le}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as K}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as w}from"../packem_shared/ADMIN_FUNCTIONS-4aGsMs95.mjs";import{f as k,d as E,c as M,n as de}from"../packem_shared/internal-BXEjuLPN.mjs";import{r as ue}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{a as G,A as fe}from"../packem_shared/advisor-view-fNcNYW2Q.mjs";import{ConfirmButton as me}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{jsx as v,jsxs as he}from"react/jsx-runtime";import{deriveInsights as pe}from"../packem_shared/DEFAULT_INSIGHT_THRESHOLDS-D5YMT0gM.mjs";import{runAdvisor as be,RUNTIME_LINTS as xe}from"@lunora/advisor";const ye=t=>{const{suggestedIndex:e,table:a}=t;if(typeof a!="string"||a.length===0||typeof e!="object"||e===null)return!1;const{fields:n,name:s}=e;return!Array.isArray(n)||n.length===0||n.some(i=>typeof i!="string"||i.length===0)?!1:typeof s=="string"&&s.length>0},ge=(t,e)=>`.index(${JSON.stringify(t)}, [${e.map(a=>JSON.stringify(a)).join(", ")}])`,ve=t=>{const e=X(19),{fields:a,indexName:n,table:s,testId:i}=t,l=K(),[f,d]=L(null);let m;e[0]!==a||e[1]!==n?(m=()=>{const b=ge(n,a),I="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if(I===void 0){d({copied:!1,declaration:b});return}k(I.writeText(b).then(()=>(d({copied:!0,declaration:b}),!0)),()=>{d({copied:!1,declaration:b})})},e[0]=a,e[1]=n,e[2]=m):m=e[2];const S=m;if(f!==null){let b;return e[3]!==f.copied||e[4]!==f.declaration||e[5]!==l||e[6]!==s||e[7]!==i?(b=f.copied?v("span",{className:"text-xs text-muted-foreground","data-testid":`${i}-applied`,children:l("Index declaration copied — add it to {table} in lunora/schema.ts.",{table:s})}):he("span",{className:"flex flex-col gap-1 text-xs text-muted-foreground","data-testid":`${i}-manual`,children:[l("Could not reach the clipboard — add this to {table} in lunora/schema.ts:",{table:s}),v("code",{className:"font-mono break-all select-all",children:f.declaration})]}),e[3]=f.copied,e[4]=f.declaration,e[5]=l,e[6]=s,e[7]=i,e[8]=b):b=e[8],b}let u;e[9]!==l?(u=l("Copy?"),e[9]=l,e[10]=u):u=e[10];let h;e[11]!==l||e[12]!==s?(h=l("Copy index declaration for {table}",{table:s}),e[11]=l,e[12]=s,e[13]=h):h=e[13];let y;return e[14]!==S||e[15]!==u||e[16]!==h||e[17]!==i?(y=v(me,{confirmLabel:u,onConfirm:S,testId:i,children:h}),e[14]=S,e[15]=u,e[16]=h,e[17]=i,e[18]=y):y=e[18],y},Se=(t,e)=>{const a=new Map;for(const n of e){const s=`${n.table} ${n.index}`;a.set(s,(a.get(s)??0)+n.reads)}return t.map(n=>({index:n.index,reads:a.get(`${n.table} ${n.index}`)??0,table:n.table}))},Te=t=>{const e=new Map;for(const a of t)for(const n of a.scannedTables??[])e.set(n.table,(e.get(n.table)??0)+n.scans);return[...e].map(([a,n])=>({scans:n,table:a}))},P=(t,e)=>e.map(a=>({index:a.name,table:t})),we=t=>{const e=Se(t.declaredIndexes??[],t.indexHits??[]),a=Te(t.functions??[]),n=t.shardTraffic??[],s=t.analyticsMetrics,i=s&&s.indexHits.length>0?s.indexHits:e,l=s&&s.tableScans.length>0?s.tableScans:a,f=s&&s.shardTraffic.length>0?s.shardTraffic:n,d=be({indexHits:i,schema:{tables:[]},shardTraffic:f,tableScans:l},{lints:xe,source:"runtime"}),m=t.suppressHotScanTables;return(m===void 0?d:d.filter(u=>!(u.metadata.kind==="hot_scan"&&typeof u.metadata.table=="string"&&m.has(u.metadata.table)))).map(u=>G(u))},Ie=M(w.listTables),$e=M(w.listTableIndexes),Ae=M(w.listTablesIndexes),H=t=>`${(t*100).toFixed(1)}%`,V=t=>`${(t/1e3).toFixed(2)}s`,Ne=t=>{if(t.length<=1)return t[0]??"";const e=t[t.length-1]??"";return`${t.slice(0,-1).join(", ")} and ${e}`},ke=(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],U=(t,e)=>({"high-error-rate":t("{rate} of calls failed.",{rate:H(e.value)}),"high-evictions":t("{count} entries evicted recently.",{count:e.value}),"high-write-contention":t("{rate} of calls hit a write conflict — consider sharding to cut contention.",{rate:H(e.value)}),"low-cache-hit-rate":t("{rate} hit rate over recent traffic.",{rate:H(e.value)}),"missing-index":t("Slowest call took {duration} — it full-scanned {tables} with no index.",{duration:V(e.value),tables:Ne(e.tables??[])}),"slow-function":t("Slowest call took {duration}.",{duration:V(e.value)}),"storage-headroom":t("{size} of the 10 GiB per-shard ceiling — plan a .shardBy() migration while it still has runway.",{size:de(e.value)})})[e.kind],Be=t=>{const e=X(10),{onJump:a,table:n}=t,s=K();let i;e[0]!==a||e[1]!==n?(i=()=>{a(n)},e[0]=a,e[1]=n,e[2]=i):i=e[2];const l=i,f=`in-add-index-${n}`;let d;e[3]!==s||e[4]!==n?(d=s("Add index on {table}",{table:n}),e[3]=s,e[4]=n,e[5]=d):d=e[5];let m;return e[6]!==l||e[7]!==f||e[8]!==d?(m=v(ie,{"data-testid":f,onClick:l,size:"sm",type:"button",variant:"outline",children:d}),e[6]=l,e[7]=f,e[8]=d,e[9]=m):m=e[9],m},Ue=({initialShardKey:t,loadShardTraffic:e})=>{const a=le(),n=se(),s=K(),{queryShardKey:i,setShardKey:l,shardKey:f}=ce(t),[d,m]=L(null),[S,u]=L(null),h=ae(""),y=B(w.getMetrics,{},{live:!0,shardKey:i}),b=B(w.getFunctionStats,{},{live:!0,shardKey:i}),I=B(w.getAdvisories,{},{live:!0,shardKey:i}),C=y.data??null,$=b.data?.functions??null,D=I.data?.advisories??null,R=y.data?.indexHits??null,j=y.error!==null&&b.error!==null?y.error:null,W=e??(r=>a.shardTraffic(r)),Y=async(r,x)=>{const g=r[0];if(g===void 0||g===""){h.current===x&&u(null);return}try{const o=await W(g);if(h.current!==x)return;const c=new Map;for(const p of o.shards)c.has(p.shardKey)||c.set(p.shardKey,{requests:p.requests,shardKey:p.shardKey});u([...c.values()])}catch{h.current===x&&u(null)}},Z=async(r,x)=>{const g=await Promise.allSettled(r.map(async c=>[c,await a.query($e,{table:c},E(x))])),o=[];for(const c of g)if(c.status==="fulfilled"){const[p,T]=c.value;o.push(...P(p,T.indexes))}return o},F=Q(async r=>{h.current=r;let x=[];try{const g=await a.query(Ie,{},E(r));if(h.current!==r)return;ue(r),x=g.map(c=>c.name);let o=[];if(x.length>0)try{const c=await a.query(Ae,{tables:x},E(r));if(h.current!==r)return;for(const[p,T]of Object.entries(c.indexesByTable))o.push(...P(p,T))}catch{if(o=await Z(x,r),h.current!==r)return}m(o)}catch{h.current===r&&m(null)}await Y(x,r)});z(()=>{k(F(i))},[i]);const _=Q(()=>{y.refetch(),b.refetch(),I.refetch(),k(F(i))});z(()=>{const r=()=>{document.visibilityState==="visible"&&_()};return document.addEventListener("visibilitychange",r),()=>{document.removeEventListener("visibilitychange",r)}},[]);const O=re(r=>{k(n({search:{table:r},to:"/schema"}))},[n]),A=N(()=>pe(C,$),[$,C]),q=N(()=>new Set(A.filter(r=>r.kind==="missing-index").flatMap(r=>r.tables??[])),[A]),J=N(()=>we({declaredIndexes:d??[],functions:$,indexHits:R,shardTraffic:S,suppressHotScanTables:q}),[d,$,R,q,S]),ee=N(()=>{const r=A.map(o=>{const c=o.kind==="missing-index"?o.tables??[]:[];return{action:c.length>0?c.map(p=>v(Be,{onJump:O,table:p},p)):void 0,description:o.message===void 0?U(s,o):`${U(s,o)} — ${o.message}`,entity:o.fn,issueType:ke(s,o),key:`${o.kind}:${o.fn??""}`,level:o.severity}}),x=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(D??[]).map(o=>{const c=G(o);if(x.has(o.name)&&ye(o.metadata)){const{table:p,suggestedIndex:T}=o.metadata,ne=`in-apply-index-${p}-${T.name}`;return{...c,action:v(ve,{fields:T.fields,indexName:T.name,table:p,testId:ne})}}return c}),...J,...r]},[D,A,O,J,s]),te=v(oe,{onChange:l,testId:"in-shard-input",value:f});return v(fe,{error:j,errorSource:j===null?void 0:y.errorSource,rows:ee,testId:"lunora-insights",toolbar:te})};export{Ue as InsightsPanel};
@@ -1 +1 @@
1
- import{c as q}from"react/compiler-runtime";import{useVirtualizer as Ce}from"@tanstack/react-virtual";import{useState as F,useReducer as Le,useRef as ue,useEffect as me,useMemo as Ne}from"react";import{f as fe}from"../packem_shared/log-fields-BolUoZ9g.mjs";import{E as Se}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{B as he}from"../packem_shared/badge-r_5B4LHP.mjs";import{E as ee}from"../packem_shared/empty-state-D7jEML_T.mjs";import{u as le}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{u as Te}from"../packem_shared/use-open-trace-B_0LbTD7.mjs";import{u as Ie}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as Q}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as oe}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{r as Re}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{f as ke}from"../packem_shared/virtual-rect-D_j7aLxX.mjs";import{B as Pe}from"../packem_shared/button-q0UYSmrn.mjs";import{I as D}from"../packem_shared/input-CXhxesPC.mjs";import{T as Ee,a as Oe,b as ge,c as B,d as _e,e as V}from"../packem_shared/table-D0SBiDu-.mjs";import ae from"../packem_shared/useDebounced-DVeQ5-oW.mjs";import{u as Fe}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{a as pe}from"../packem_shared/cf-links-CBJ5SywP.mjs";import{f as ne,j as qe,b as ie}from"../packem_shared/internal-BXEjuLPN.mjs";import{a as Ae,L as Me}from"../packem_shared/log-line-BWDt_F56.mjs";import{jsx as r,jsxs as E,Fragment as $e}from"react/jsx-runtime";import{c as H}from"../packem_shared/utils-bhneXptQ.mjs";import{L as Ue}from"../packem_shared/live-status-D1GasNsH.mjs";import{ShardInput as Ke}from"../packem_shared/ShardInput-CoySruKZ.mjs";const re=["trace","debug","log","info","warn","error","fatal"],Be="LOG_ARCHIVE_NOT_CONFIGURED",Ve={cursor:void 0,error:null,loading:!1,notConfigured:!1,rows:null},De=(i,e)=>{switch(e.type){case"append":return{...i,cursor:e.cursor,error:null,loading:!1,rows:[...i.rows??[],...e.rows]};case"failed":return{cursor:void 0,error:e.message,loading:!1,notConfigured:!1,rows:null};case"loaded":return{cursor:e.cursor,error:null,loading:!1,notConfigured:!1,rows:e.rows};case"loading":return{...i,error:null,loading:!0,notConfigured:!1};case"notConfigured":return{cursor:void 0,error:null,loading:!1,notConfigured:!0,rows:null};case"pageFailed":return{...i,error:e.message,loading:!1};default:return i}},Qe=i=>{const e=q(33),{row:t}=i;let a;e[0]!==t.fields?(a=fe(t.fields),e[0]=t.fields,e[1]=a):a=e[1];const n=a,o=`lg-archive-row-${String(t.ts)}`;let d;e[2]!==t.ts?(d=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=d):d=e[3];let p;e[4]!==d?(p=r(V,{className:"tabular-nums whitespace-nowrap text-xs text-muted-foreground",children:d}),e[4]=d,e[5]=p):p=e[5];const m=Ae[t.level];let c;e[6]!==t.level||e[7]!==m?(c=r(V,{children:r(he,{variant:m,children:t.level})}),e[6]=t.level,e[7]=m,e[8]=c):c=e[8];let s;e[9]!==t.functionPath?(s=r(V,{className:"font-mono text-xs",children:t.functionPath}),e[9]=t.functionPath,e[10]=s):s=e[10];let f;e[11]!==t.message?(f=r("div",{className:"truncate",title:t.message,children:t.message}),e[11]=t.message,e[12]=f):f=e[12];let l;e[13]!==n?(l=n!==""&&r("div",{className:"truncate font-mono text-[11px] text-muted-foreground",title:n,children:n}),e[13]=n,e[14]=l):l=e[14];let u;e[15]!==f||e[16]!==l?(u=E(V,{className:"max-w-md",children:[f,l]}),e[15]=f,e[16]=l,e[17]=u):u=e[17];const h=t.traceId??"—";let v;e[18]!==h?(v=r(V,{className:"font-mono text-[11px] text-muted-foreground",children:h}),e[18]=h,e[19]=v):v=e[19];const b=t.shardKey??"—";let y;e[20]!==b?(y=r(V,{className:"font-mono text-[11px] text-muted-foreground",children:b}),e[20]=b,e[21]=y):y=e[21];const w=t.userId??"—";let x;e[22]!==w?(x=r(V,{className:"font-mono text-[11px] text-muted-foreground",children:w}),e[22]=w,e[23]=x):x=e[23];let T;return e[24]!==u||e[25]!==v||e[26]!==y||e[27]!==x||e[28]!==o||e[29]!==p||e[30]!==c||e[31]!==s?(T=E(ge,{"data-testid":o,children:[p,c,s,u,v,y,x]}),e[24]=u,e[25]=v,e[26]=y,e[27]=x,e[28]=o,e[29]=p,e[30]=c,e[31]=s,e[32]=T):T=e[32],T},ze=({shardKey:i})=>{const e=Fe(),t=Q(),[a,n]=F(""),[o,d]=F(""),[p,m]=F(""),[{cursor:c,error:s,loading:f,notConfigured:l,rows:u},h]=Le(De,Ve),v=ae(a.trim(),400),b=ae(o.trim(),400),y={...v===""?{}:{functionPathPrefix:v},...p===""?{}:{minLevel:p},...i===""?{}:{shardKey:i},...b===""?{}:{userId:b}},w=JSON.stringify(y),x=ue(w);me(()=>{const g={cancelled:!1};return x.current=w,ne((async()=>{h({type:"loading"});try{const C=await e.queryLogArchive(y);g.cancelled||h({cursor:C.nextCursor,rows:C.rows,type:"loaded"})}catch(C){g.cancelled||h(qe(C)===Be?{type:"notConfigured"}:{message:ie(C),type:"failed"})}})()),()=>{g.cancelled=!0}},[e,w]);const T=async()=>{if(c===void 0)return;const g=w;h({type:"loading"});try{const C=await e.queryLogArchive({...y,cursor:c});x.current===g&&h({cursor:C.nextCursor,rows:C.rows,type:"append"})}catch(C){x.current===g&&h({message:ie(C),type:"pageFailed"})}},R=g=>{n(g.target.value)},N=g=>{d(g.target.value)},L=g=>{m(g.target.value)},S=()=>{ne(T())};return l?r(ee,{action:r("a",{className:"text-sm text-primary underline-offset-4 hover:underline",href:pe,rel:"noreferrer",target:"_blank",children:t("Open in Cloudflare")}),description:t("Wire pipelineLogSink to a Cloudflare Pipeline → 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")}):E("div",{className:"flex flex-col gap-4","data-testid":"lg-archive",children:[E("div",{className:"flex flex-wrap items-center gap-2",children:[r(D,{"aria-label":t("Function path prefix"),className:"h-8 w-48","data-testid":"lg-archive-path",onChange:R,placeholder:t("function path…"),value:a}),r(D,{"aria-label":t("User id"),className:"h-8 w-40","data-testid":"lg-archive-user",onChange:N,placeholder:t("user id…"),value:o}),E("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:L,value:p,children:[r("option",{value:"",children:t("min level")}),re.map(g=>r("option",{value:g,children:g},g))]})]}),s!==null&&r("p",{className:"text-sm text-destructive","data-testid":"lg-archive-error",role:"alert",children:s}),f&&u===null&&s===null&&r("p",{className:"text-sm text-muted-foreground","data-testid":"lg-archive-loading",children:t("Loading…")}),u!==null&&u.length===0&&r(ee,{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&&r("div",{className:"overflow-hidden rounded-xl border border-border shadow-xs",children:E(Ee,{"data-testid":"lg-archive-table",children:[r(Oe,{children:E(ge,{children:[r(B,{children:t("Time")}),r(B,{children:t("Level")}),r(B,{children:t("Function")}),r(B,{children:t("Message")}),r(B,{children:t("Trace")}),r(B,{children:t("Shard")}),r(B,{children:t("User")})]})}),r(_e,{children:u.map((g,C)=>r(Qe,{row:g},`${String(g.ts)}-${String(C)}`))})]})}),c!==void 0&&r("div",{children:r(Pe,{"data-testid":"lg-archive-more",disabled:f,onClick:S,size:"sm",variant:"outline",children:t(f?"Loading…":"Load more")})})]})},Ge=i=>{const e=q(11),{level:t,onToggle:a,selected:n}=i;let o;e[0]!==t||e[1]!==a?(o=()=>{a(t)},e[0]=t,e[1]=a,e[2]=o):o=e[2];const d=o,p=n?"border-border bg-muted font-medium":"border-input text-muted-foreground";let m;e[3]!==p?(m=H("rounded-md border px-2 py-1 text-xs",p),e[3]=p,e[4]=m):m=e[4];const c=`logs-level-${t}`;let s;return e[5]!==t||e[6]!==d||e[7]!==n||e[8]!==m||e[9]!==c?(s=r("button",{"aria-pressed":n,className:m,"data-testid":c,onClick:d,type:"button",children:t}),e[5]=t,e[6]=d,e[7]=n,e[8]=m,e[9]=c,e[10]=s):s=e[10],s},He=i=>{const e=q(68),{levelFilter:t,onLogPathChange:a,onSearchChange:n,onTimeRangeChange:o,onToggleLevel:d,onToggleSummary:p,pathFilter:m,search:c,showSummary:s,timeRange:f}=i,l=Q();let u;e[0]!==l?(u=l("Search messages"),e[0]=l,e[1]=u):u=e[1];let h;e[2]!==l?(h=l("search message"),e[2]=l,e[3]=h):h=e[3];let v;e[4]!==n||e[5]!==c||e[6]!==u||e[7]!==h?(v=r(D,{"aria-label":u,className:"h-8 w-48","data-testid":"lg-search",onChange:n,placeholder:h,value:c}),e[4]=n,e[5]=c,e[6]=u,e[7]=h,e[8]=v):v=e[8];let b;e[9]!==l?(b=l("Function path"),e[9]=l,e[10]=b):b=e[10];let y;e[11]!==l?(y=l("filter path"),e[11]=l,e[12]=y):y=e[12];let w;e[13]!==a||e[14]!==m||e[15]!==b||e[16]!==y?(w=r(D,{"aria-label":b,className:"h-8 w-40","data-testid":"logs-path-filter",onChange:a,placeholder:y,value:m}),e[13]=a,e[14]=m,e[15]=b,e[16]=y,e[17]=w):w=e[17];let x;e[18]!==l?(x=l("Level filter"),e[18]=l,e[19]=x):x=e[19];let T;e[20]!==t||e[21]!==d?(T=re.map(G=>r(Ge,{level:G,onToggle:d,selected:t.has(G)},G)),e[20]=t,e[21]=d,e[22]=T):T=e[22];let R;e[23]!==x||e[24]!==T?(R=r("div",{"aria-label":x,className:"inline-flex items-center gap-1","data-testid":"logs-level-filter",role:"group",children:T}),e[23]=x,e[24]=T,e[25]=R):R=e[25];let N;e[26]!==l?(N=l("Time range"),e[26]=l,e[27]=N):N=e[27];let L;e[28]!==l?(L=l("All time"),e[28]=l,e[29]=L):L=e[29];let S;e[30]!==L?(S=r("option",{value:"all",children:L}),e[30]=L,e[31]=S):S=e[31];let g;e[32]!==l?(g=l("Last 5m"),e[32]=l,e[33]=g):g=e[33];let C;e[34]!==g?(C=r("option",{value:"5m",children:g}),e[34]=g,e[35]=C):C=e[35];let k;e[36]!==l?(k=l("Last 15m"),e[36]=l,e[37]=k):k=e[37];let P;e[38]!==k?(P=r("option",{value:"15m",children:k}),e[38]=k,e[39]=P):P=e[39];let O;e[40]!==l?(O=l("Last hour"),e[40]=l,e[41]=O):O=e[41];let _;e[42]!==O?(_=r("option",{value:"1h",children:O}),e[42]=O,e[43]=_):_=e[43];let A;e[44]!==o||e[45]!==N||e[46]!==S||e[47]!==C||e[48]!==P||e[49]!==_||e[50]!==f?(A=E("select",{"aria-label":N,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:f,children:[S,C,P,_]}),e[44]=o,e[45]=N,e[46]=S,e[47]=C,e[48]=P,e[49]=_,e[50]=f,e[51]=A):A=e[51];const z=s?"border-border bg-muted font-medium":"border-input text-muted-foreground";let M;e[52]!==z?(M=H("h-8 rounded-md border px-3 text-sm",z),e[52]=z,e[53]=M):M=e[53];let U;e[54]!==s||e[55]!==l?(U=l(s?"List":"Summary"),e[54]=s,e[55]=l,e[56]=U):U=e[56];let $;e[57]!==p||e[58]!==s||e[59]!==M||e[60]!==U?($=r("button",{"aria-pressed":s,className:M,"data-testid":"logs-summary-toggle",onClick:p,type:"button",children:U}),e[57]=p,e[58]=s,e[59]=M,e[60]=U,e[61]=$):$=e[61];let K;return e[62]!==A||e[63]!==$||e[64]!==v||e[65]!==w||e[66]!==R?(K=E("div",{className:"flex flex-wrap items-center gap-2",children:[v,w,R,A,$]}),e[62]=A,e[63]=$,e[64]=v,e[65]=w,e[66]=R,e[67]=K):K=e[67],K},We=i=>{const e=q(53),{onOutcomeChange:t,onPathChange:a,onTableChange:n,onUserChange:o,outcomeFilter:d,pathPrefix:p,tableFilter:m,userIdFilter:c}=i,s=Q();let f;e[0]!==s?(f=s("Function path"),e[0]=s,e[1]=f):f=e[1];let l;e[2]!==s?(l=s("file:function"),e[2]=s,e[3]=l):l=e[3];let u;e[4]!==a||e[5]!==p||e[6]!==f||e[7]!==l?(u=r(D,{"aria-label":f,className:"h-8 w-44","data-testid":"lg-req-path",onChange:a,placeholder:l,value:p}),e[4]=a,e[5]=p,e[6]=f,e[7]=l,e[8]=u):u=e[8];let h;e[9]!==s?(h=s("User id"),e[9]=s,e[10]=h):h=e[10];let v;e[11]!==s?(v=s("userId"),e[11]=s,e[12]=v):v=e[12];let b;e[13]!==o||e[14]!==h||e[15]!==v||e[16]!==c?(b=r(D,{"aria-label":h,className:"h-8 w-32","data-testid":"lg-req-user",onChange:o,placeholder:v,value:c}),e[13]=o,e[14]=h,e[15]=v,e[16]=c,e[17]=b):b=e[17];let y;e[18]!==s?(y=s("Table touched"),e[18]=s,e[19]=y):y=e[19];let w;e[20]!==s?(w=s("table"),e[20]=s,e[21]=w):w=e[21];let x;e[22]!==n||e[23]!==y||e[24]!==w||e[25]!==m?(x=r(D,{"aria-label":y,className:"h-8 w-32","data-testid":"lg-req-table",onChange:n,placeholder:w,value:m}),e[22]=n,e[23]=y,e[24]=w,e[25]=m,e[26]=x):x=e[26];let T;e[27]!==s?(T=s("Outcome filter"),e[27]=s,e[28]=T):T=e[28];let R;e[29]!==s?(R=s("all"),e[29]=s,e[30]=R):R=e[30];let N;e[31]!==R?(N=r("option",{value:"all",children:R}),e[31]=R,e[32]=N):N=e[32];let L;e[33]!==s?(L=s("ok"),e[33]=s,e[34]=L):L=e[34];let S;e[35]!==L?(S=r("option",{value:"ok",children:L}),e[35]=L,e[36]=S):S=e[36];let g;e[37]!==s?(g=s("error"),e[37]=s,e[38]=g):g=e[38];let C;e[39]!==g?(C=r("option",{value:"error",children:g}),e[39]=g,e[40]=C):C=e[40];let k;e[41]!==t||e[42]!==d||e[43]!==T||e[44]!==N||e[45]!==S||e[46]!==C?(k=E("select",{"aria-label":T,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:d,children:[N,S,C]}),e[41]=t,e[42]=d,e[43]=T,e[44]=N,e[45]=S,e[46]=C,e[47]=k):k=e[47];let P;return e[48]!==k||e[49]!==u||e[50]!==b||e[51]!==x?(P=E("div",{className:"flex flex-wrap items-center gap-2",children:[u,b,x,k]}),e[48]=k,e[49]=u,e[50]=b,e[51]=x,e[52]=P):P=e[52],P},ve=i=>{const e=q(7),{bucket:t}=i;let a;e[0]!==t.key?(a=r("span",{className:"truncate text-muted-foreground",role:"gridcell",children:t.key}),e[0]=t.key,e[1]=a):a=e[1];let n;e[2]!==t.count?(n=r("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]!==a||e[5]!==n?(o=E("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:[a,n]}),e[4]=a,e[5]=n,e[6]=o):o=e[6],o},Ye=i=>{const e=q(31),{summary:t}=i,a=Q();let n;e[0]!==t.total||e[1]!==a?(n=a("{count} entries",{count:t.total}),e[0]=t.total,e[1]=a,e[2]=n):n=e[2];let o;e[3]!==n?(o=r("p",{className:"text-xs text-muted-foreground","data-testid":"logs-summary-total",children:n}),e[3]=n,e[4]=o):o=e[4];let d;e[5]!==a?(d=a("By level"),e[5]=a,e[6]=d):d=e[6];let p;e[7]!==d?(p=r("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:d}),e[7]=d,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 c;e[11]!==m?(c=r("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-levels",role:"grid",children:m}),e[11]=m,e[12]=c):c=e[12];let s;e[13]!==p||e[14]!==c?(s=E("div",{children:[p,c]}),e[13]=p,e[14]=c,e[15]=s):s=e[15];let f;e[16]!==a?(f=a("By function"),e[16]=a,e[17]=f):f=e[17];let l;e[18]!==f?(l=r("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:f}),e[18]=f,e[19]=l):l=e[19];let u;e[20]!==t.byPath?(u=t.byPath.map(Je),e[20]=t.byPath,e[21]=u):u=e[21];let h;e[22]!==u?(h=r("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-paths",role:"grid",children:u}),e[22]=u,e[23]=h):h=e[23];let v;e[24]!==h||e[25]!==l?(v=E("div",{children:[l,h]}),e[24]=h,e[25]=l,e[26]=v):v=e[26];let b;return e[27]!==v||e[28]!==o||e[29]!==s?(b=E("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"logs-summary",children:[o,s,v]}),e[27]=v,e[28]=o,e[29]=s,e[30]=b):b=e[30],b};function je(i){return r(ve,{bucket:i},i.key)}function Je(i){return r(ve,{bucket:i},i.key)}const Xe=i=>{const e=q(46),{liveError:t,onShardKeyChange:a,onShowArchive:n,onShowErrors:o,onShowRequests:d,shardKey:p,view:m}=i,c=Q(),s=m==="requests",f=m==="requests"?"bg-muted font-medium":"text-muted-foreground";let l;e[0]!==f?(l=H("px-3 py-1 text-sm",f),e[0]=f,e[1]=l):l=e[1];let u;e[2]!==c?(u=c("Requests"),e[2]=c,e[3]=u):u=e[3];let h;e[4]!==d||e[5]!==s||e[6]!==l||e[7]!==u?(h=r("button",{"aria-selected":s,className:l,"data-testid":"lg-view-requests",onClick:d,role:"tab",type:"button",children:u}),e[4]=d,e[5]=s,e[6]=l,e[7]=u,e[8]=h):h=e[8];const v=m==="errors",b=m==="errors"?"bg-muted font-medium":"text-muted-foreground";let y;e[9]!==b?(y=H("px-3 py-1 text-sm",b),e[9]=b,e[10]=y):y=e[10];let w;e[11]!==c?(w=c("Errors"),e[11]=c,e[12]=w):w=e[12];let x;e[13]!==o||e[14]!==v||e[15]!==y||e[16]!==w?(x=r("button",{"aria-selected":v,className:y,"data-testid":"lg-view-errors",onClick:o,role:"tab",type:"button",children:w}),e[13]=o,e[14]=v,e[15]=y,e[16]=w,e[17]=x):x=e[17];const T=m==="archive",R=m==="archive"?"bg-muted font-medium":"text-muted-foreground";let N;e[18]!==R?(N=H("px-3 py-1 text-sm",R),e[18]=R,e[19]=N):N=e[19];let L;e[20]!==c?(L=c("Archive"),e[20]=c,e[21]=L):L=e[21];let S;e[22]!==n||e[23]!==T||e[24]!==N||e[25]!==L?(S=r("button",{"aria-selected":T,className:N,"data-testid":"lg-view-archive",onClick:n,role:"tab",type:"button",children:L}),e[22]=n,e[23]=T,e[24]=N,e[25]=L,e[26]=S):S=e[26];let g;e[27]!==x||e[28]!==S||e[29]!==h?(g=E("div",{className:"inline-flex overflow-hidden rounded-lg border border-border",role:"tablist",children:[h,x,S]}),e[27]=x,e[28]=S,e[29]=h,e[30]=g):g=e[30];let C;e[31]!==a||e[32]!==p?(C=r(Ke,{onChange:a,testId:"lg-shard-input",value:p}),e[31]=a,e[32]=p,e[33]=C):C=e[33];let k;e[34]!==t||e[35]!==m?(k=m!=="archive"&&r(Ue,{message:t,prefix:"lg"}),e[34]=t,e[35]=m,e[36]=k):k=e[36];let P;e[37]!==c?(P=c("Open in Cloudflare"),e[37]=c,e[38]=P):P=e[38];let O;e[39]!==P?(O=r("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"lg-cf-link",href:pe,rel:"noreferrer",target:"_blank",children:P}),e[39]=P,e[40]=O):O=e[40];let _;return e[41]!==g||e[42]!==C||e[43]!==k||e[44]!==O?(_=E("div",{className:"flex flex-wrap items-center gap-2",children:[g,C,k,O]}),e[41]=g,e[42]=C,e[43]=k,e[44]=O,e[45]=_):_=e[45],_},te=400,Ze=36,et={height:te,overflow:"auto"},be={left:0,position:"absolute",top:0,width:"100%"},tt={error:"destructive",ok:"secondary"},xe=i=>{const e=q(6),{onOpenTrace:t,traceId:a}=i,n=Q();let o;e[0]!==t||e[1]!==n||e[2]!==a?(o=a===void 0?null:r("button",{className:"text-primary underline-offset-2 hover:underline","data-testid":"lg-trace-link",onClick:()=>{t(a)},type:"button",children:n("Trace")}),e[0]=t,e[1]=n,e[2]=a,e[3]=o):o=e[3];let d;return e[4]!==o?(d=r("span",{className:"w-16 shrink-0 text-right",role:"gridcell",children:o}),e[4]=o,e[5]=d):d=e[5],d},rt=i=>{const e=q(13),{entry:t,index:a,measureRef:n,onOpenTrace:o,start:d}=i,p=`translateY(${String(d)}px)`;let m;e[0]!==p?(m={...be,transform:p},e[0]=p,e[1]=m):m=e[1];const c=m;let s;e[2]!==t?(s=r(Me,{entry:t}),e[2]=t,e[3]=s):s=e[3];let f;e[4]!==t.traceId||e[5]!==o?(f=r(xe,{onOpenTrace:o,traceId:t.traceId}),e[4]=t.traceId,e[5]=o,e[6]=f):f=e[6];let l;return e[7]!==a||e[8]!==n||e[9]!==c||e[10]!==s||e[11]!==f?(l=E("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":a,"data-testid":"lg-row",ref:n,role:"row",style:c,children:[s,f]}),e[7]=a,e[8]=n,e[9]=c,e[10]=s,e[11]=f,e[12]=l):l=e[12],l},ce=i=>i.length===0?"—":i.join(", "),st=i=>{const e=q(41),{entry:t,index:a,measureRef:n,onOpenTrace:o,start:d}=i,p=`translateY(${String(d)}px)`;let m;e[0]!==p?(m={...be,transform:p},e[0]=p,e[1]=m):m=e[1];const c=m;let s;e[2]!==t.ts?(s=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=s):s=e[3];let f;e[4]!==s?(f=r("span",{className:"w-40 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:s}),e[4]=s,e[5]=f):f=e[5];const l=tt[t.outcome];let u;e[6]!==t.outcome||e[7]!==l?(u=r("span",{className:"w-16 shrink-0",role:"gridcell",children:r(he,{variant:l,children:t.outcome})}),e[6]=t.outcome,e[7]=l,e[8]=u):u=e[8];let h;e[9]!==t.functionPath?(h=r("span",{className:"w-44 shrink-0 truncate",role:"gridcell",title:t.functionPath,children:t.functionPath}),e[9]=t.functionPath,e[10]=h):h=e[10];const v=t.shardKey??"—";let b;e[11]!==v?(b=r("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:v}),e[11]=v,e[12]=b):b=e[12];const y=t.userId??"—";let w;e[13]!==y?(w=r("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:y}),e[13]=y,e[14]=w):w=e[14];let x;e[15]!==t.durationMs?(x=Math.round(t.durationMs),e[15]=t.durationMs,e[16]=x):x=e[16];const T=`${String(x)}ms`;let R;e[17]!==T?(R=r("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:T}),e[17]=T,e[18]=R):R=e[18];let N;e[19]!==t.errorMessage||e[20]!==t.outcome||e[21]!==t.tablesRead||e[22]!==t.tablesWritten?(N=t.outcome==="error"&&t.errorMessage!==void 0?t.errorMessage:`r:${ce(t.tablesRead)} · w:${ce(t.tablesWritten)}`,e[19]=t.errorMessage,e[20]=t.outcome,e[21]=t.tablesRead,e[22]=t.tablesWritten,e[23]=N):N=e[23];let L;e[24]!==N?(L=r("span",{className:"flex-1 truncate text-muted-foreground",role:"gridcell",children:N}),e[24]=N,e[25]=L):L=e[25];let S;e[26]!==t.traceId||e[27]!==o?(S=r(xe,{onOpenTrace:o,traceId:t.traceId}),e[26]=t.traceId,e[27]=o,e[28]=S):S=e[28];let g;return e[29]!==a||e[30]!==n||e[31]!==c||e[32]!==w||e[33]!==R||e[34]!==L||e[35]!==S||e[36]!==f||e[37]!==u||e[38]!==h||e[39]!==b?(g=E("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":a,"data-testid":"lg-req-row",ref:n,role:"row",style:c,children:[f,u,h,b,w,R,L,S]}),e[29]=a,e[30]=n,e[31]=c,e[32]=w,e[33]=R,e[34]=L,e[35]=S,e[36]=f,e[37]=u,e[38]=h,e[39]=b,e[40]=g):g=e[40],g},de=i=>{const{entries:e}=i??{};return Array.isArray(e)?e:[]},lt=i=>{const 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},ot={"5m":300*1e3,"15m":900*1e3,"1h":3600*1e3},at=(i,e)=>{const t=e.search.trim().toLowerCase(),a=e.path.trim().toLowerCase(),n=e.range==="all"?Number.NEGATIVE_INFINITY:e.now-ot[e.range];return i.filter(o=>e.levels.size>0&&!e.levels.has(o.level)||o.timestamp<n||a!==""&&!(o.functionPath??"").toLowerCase().includes(a)?!1:t===""||o.message.toLowerCase().includes(t)||fe(o.fields).toLowerCase().includes(t))},nt="—",it=i=>{const e=new Map,t=new Map;for(const o of i){e.set(o.level,(e.get(o.level)??0)+1);const d=o.functionPath??nt;t.set(d,(t.get(d)??0)+1)}const a=re.filter(o=>e.has(o)).map(o=>({count:e.get(o)??0,key:o})),n=[...t.entries()].map(([o,d])=>({count:d,key:o})).toSorted((o,d)=>d.count===o.count?o.key.localeCompare(d.key):d.count-o.count);return{byLevel:a,byPath:n,total:i.length}},Wt=({initialShardKey:i})=>{const e=Q(),[t,a]=F("requests"),{queryShardKey:n,setShardKey:o,shardKey:d}=Ie(i),[p,m]=F(""),[c,s]=F(()=>new Set),[f,l]=F(""),[u,h]=F("all"),[v,b]=F(!1),[y,w]=F(""),[x,T]=F(""),[R,N]=F(""),[L,S]=F("all"),g=lt({functionPathPrefix:y,outcome:L,tableTouched:R,userId:x}),C=le(oe.getRequestLog,g,{enabled:t==="requests",live:!0,shardKey:n}),k=le(oe.getLogs,{},{enabled:t==="errors",live:!0,shardKey:n}),P=t==="requests"?C:k,{error:O,errorSource:_,isLoading:A,liveError:z}=P,M=Te(n),U=de(k.data),$=de(C.data);me(()=>{P.data!==void 0&&Re(n)},[P.data,n]);const K=at(U,{levels:c,now:Date.now(),path:f,range:u,search:p}),G=it(K),J=t==="requests"?$.length:K.length,X=t==="errors"&&v,W=Ne(()=>O!==null?"error":J===0?A?X?"summary":"list":"empty":X?"summary":"list",[J,A,O,X]),se=ue(null),Y=Ce({count:J,estimateSize:()=>Ze,getScrollElement:()=>se.current,initialRect:{height:te,width:800},observeElementRect:(I,Z)=>ke(I,Z,te),overscan:8}),ye=Y.getVirtualItems(),we={height:Y.getTotalSize(),position:"relative",width:"100%"};return E("div",{className:"flex flex-col gap-4","data-testid":"lunora-logs",children:[r(Xe,{liveError:z,onShardKeyChange:o,onShowArchive:()=>{a("archive"),b(!1)},onShowErrors:()=>{a("errors"),b(!1)},onShowRequests:()=>{a("requests"),b(!1)},shardKey:d,view:t}),t==="errors"&&r(He,{levelFilter:c,onLogPathChange:I=>{l(I.target.value)},onSearchChange:I=>{m(I.target.value)},onTimeRangeChange:I=>{h(I.target.value)},onToggleLevel:I=>{s(Z=>{const j=new Set(Z);return j.has(I)?j.delete(I):j.add(I),j})},onToggleSummary:()=>{b(I=>!I)},pathFilter:f,search:p,showSummary:v,timeRange:u}),t==="requests"&&r(We,{onOutcomeChange:I=>{S(I.target.value)},onPathChange:I=>{w(I.target.value)},onTableChange:I=>{N(I.target.value)},onUserChange:I=>{T(I.target.value)},outcomeFilter:L,pathPrefix:y,tableFilter:R,userIdFilter:x}),t==="archive"?r(ze,{shardKey:n}):E($e,{children:[W==="error"&&r(Se,{error:_,testId:"lg-error"}),W==="empty"&&r(ee,{description:e("Function and request logs for this shard show up here as your app handles traffic."),icon:r("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:r("path",{d:"M4 5h16M4 12h16M4 19h10"})}),testId:"lg-empty",title:e("No logs.")}),W==="summary"&&r(Ye,{summary:G}),W==="list"&&r("div",{className:"rounded-xl border border-border shadow-xs","data-testid":"lg-scroll",ref:se,style:et,children:r("div",{"aria-label":e("Recent logs"),"data-testid":"lg-table",role:"grid",style:we,children:ye.map(I=>t==="requests"?r(st,{entry:$[I.index],index:I.index,measureRef:Y.measureElement,onOpenTrace:M,start:I.start},I.key):r(rt,{entry:K[I.index],index:I.index,measureRef:Y.measureElement,onOpenTrace:M,start:I.start},I.key))})})]})]})};export{Wt as LogsPanel,at as filterLogs,it as summarizeLogs};
1
+ import{c as q}from"react/compiler-runtime";import{useVirtualizer as Ce}from"@tanstack/react-virtual";import{useState as F,useReducer as Le,useRef as ue,useEffect as me,useMemo as Ne}from"react";import{f as fe}from"../packem_shared/log-fields-BolUoZ9g.mjs";import{E as Se}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{B as he}from"../packem_shared/badge-r_5B4LHP.mjs";import{E as ee}from"../packem_shared/empty-state-D7jEML_T.mjs";import{u as le}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{u as Te}from"../packem_shared/use-open-trace-B_0LbTD7.mjs";import{u as Ie}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as Q}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as oe}from"../packem_shared/ADMIN_FUNCTIONS-4aGsMs95.mjs";import{r as Re}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{f as ke}from"../packem_shared/virtual-rect-D_j7aLxX.mjs";import{B as Pe}from"../packem_shared/button-q0UYSmrn.mjs";import{I as D}from"../packem_shared/input-CXhxesPC.mjs";import{T as Ee,a as Oe,b as ge,c as B,d as _e,e as V}from"../packem_shared/table-D0SBiDu-.mjs";import ae from"../packem_shared/useDebounced-DVeQ5-oW.mjs";import{u as Fe}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{a as pe}from"../packem_shared/cf-links-CBJ5SywP.mjs";import{f as ne,j as qe,b as ie}from"../packem_shared/internal-BXEjuLPN.mjs";import{a as Ae,L as Me}from"../packem_shared/log-line-BWDt_F56.mjs";import{jsx as r,jsxs as E,Fragment as $e}from"react/jsx-runtime";import{c as H}from"../packem_shared/utils-bhneXptQ.mjs";import{L as Ue}from"../packem_shared/live-status-D1GasNsH.mjs";import{ShardInput as Ke}from"../packem_shared/ShardInput-CoySruKZ.mjs";const re=["trace","debug","log","info","warn","error","fatal"],Be="LOG_ARCHIVE_NOT_CONFIGURED",Ve={cursor:void 0,error:null,loading:!1,notConfigured:!1,rows:null},De=(i,e)=>{switch(e.type){case"append":return{...i,cursor:e.cursor,error:null,loading:!1,rows:[...i.rows??[],...e.rows]};case"failed":return{cursor:void 0,error:e.message,loading:!1,notConfigured:!1,rows:null};case"loaded":return{cursor:e.cursor,error:null,loading:!1,notConfigured:!1,rows:e.rows};case"loading":return{...i,error:null,loading:!0,notConfigured:!1};case"notConfigured":return{cursor:void 0,error:null,loading:!1,notConfigured:!0,rows:null};case"pageFailed":return{...i,error:e.message,loading:!1};default:return i}},Qe=i=>{const e=q(33),{row:t}=i;let a;e[0]!==t.fields?(a=fe(t.fields),e[0]=t.fields,e[1]=a):a=e[1];const n=a,o=`lg-archive-row-${String(t.ts)}`;let d;e[2]!==t.ts?(d=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=d):d=e[3];let p;e[4]!==d?(p=r(V,{className:"tabular-nums whitespace-nowrap text-xs text-muted-foreground",children:d}),e[4]=d,e[5]=p):p=e[5];const m=Ae[t.level];let c;e[6]!==t.level||e[7]!==m?(c=r(V,{children:r(he,{variant:m,children:t.level})}),e[6]=t.level,e[7]=m,e[8]=c):c=e[8];let s;e[9]!==t.functionPath?(s=r(V,{className:"font-mono text-xs",children:t.functionPath}),e[9]=t.functionPath,e[10]=s):s=e[10];let f;e[11]!==t.message?(f=r("div",{className:"truncate",title:t.message,children:t.message}),e[11]=t.message,e[12]=f):f=e[12];let l;e[13]!==n?(l=n!==""&&r("div",{className:"truncate font-mono text-[11px] text-muted-foreground",title:n,children:n}),e[13]=n,e[14]=l):l=e[14];let u;e[15]!==f||e[16]!==l?(u=E(V,{className:"max-w-md",children:[f,l]}),e[15]=f,e[16]=l,e[17]=u):u=e[17];const h=t.traceId??"—";let v;e[18]!==h?(v=r(V,{className:"font-mono text-[11px] text-muted-foreground",children:h}),e[18]=h,e[19]=v):v=e[19];const b=t.shardKey??"—";let y;e[20]!==b?(y=r(V,{className:"font-mono text-[11px] text-muted-foreground",children:b}),e[20]=b,e[21]=y):y=e[21];const w=t.userId??"—";let x;e[22]!==w?(x=r(V,{className:"font-mono text-[11px] text-muted-foreground",children:w}),e[22]=w,e[23]=x):x=e[23];let T;return e[24]!==u||e[25]!==v||e[26]!==y||e[27]!==x||e[28]!==o||e[29]!==p||e[30]!==c||e[31]!==s?(T=E(ge,{"data-testid":o,children:[p,c,s,u,v,y,x]}),e[24]=u,e[25]=v,e[26]=y,e[27]=x,e[28]=o,e[29]=p,e[30]=c,e[31]=s,e[32]=T):T=e[32],T},ze=({shardKey:i})=>{const e=Fe(),t=Q(),[a,n]=F(""),[o,d]=F(""),[p,m]=F(""),[{cursor:c,error:s,loading:f,notConfigured:l,rows:u},h]=Le(De,Ve),v=ae(a.trim(),400),b=ae(o.trim(),400),y={...v===""?{}:{functionPathPrefix:v},...p===""?{}:{minLevel:p},...i===""?{}:{shardKey:i},...b===""?{}:{userId:b}},w=JSON.stringify(y),x=ue(w);me(()=>{const g={cancelled:!1};return x.current=w,ne((async()=>{h({type:"loading"});try{const C=await e.queryLogArchive(y);g.cancelled||h({cursor:C.nextCursor,rows:C.rows,type:"loaded"})}catch(C){g.cancelled||h(qe(C)===Be?{type:"notConfigured"}:{message:ie(C),type:"failed"})}})()),()=>{g.cancelled=!0}},[e,w]);const T=async()=>{if(c===void 0)return;const g=w;h({type:"loading"});try{const C=await e.queryLogArchive({...y,cursor:c});x.current===g&&h({cursor:C.nextCursor,rows:C.rows,type:"append"})}catch(C){x.current===g&&h({message:ie(C),type:"pageFailed"})}},R=g=>{n(g.target.value)},N=g=>{d(g.target.value)},L=g=>{m(g.target.value)},S=()=>{ne(T())};return l?r(ee,{action:r("a",{className:"text-sm text-primary underline-offset-4 hover:underline",href:pe,rel:"noreferrer",target:"_blank",children:t("Open in Cloudflare")}),description:t("Wire pipelineLogSink to a Cloudflare Pipeline → 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")}):E("div",{className:"flex flex-col gap-4","data-testid":"lg-archive",children:[E("div",{className:"flex flex-wrap items-center gap-2",children:[r(D,{"aria-label":t("Function path prefix"),className:"h-8 w-48","data-testid":"lg-archive-path",onChange:R,placeholder:t("function path…"),value:a}),r(D,{"aria-label":t("User id"),className:"h-8 w-40","data-testid":"lg-archive-user",onChange:N,placeholder:t("user id…"),value:o}),E("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:L,value:p,children:[r("option",{value:"",children:t("min level")}),re.map(g=>r("option",{value:g,children:g},g))]})]}),s!==null&&r("p",{className:"text-sm text-destructive","data-testid":"lg-archive-error",role:"alert",children:s}),f&&u===null&&s===null&&r("p",{className:"text-sm text-muted-foreground","data-testid":"lg-archive-loading",children:t("Loading…")}),u!==null&&u.length===0&&r(ee,{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&&r("div",{className:"overflow-hidden rounded-xl border border-border shadow-xs",children:E(Ee,{"data-testid":"lg-archive-table",children:[r(Oe,{children:E(ge,{children:[r(B,{children:t("Time")}),r(B,{children:t("Level")}),r(B,{children:t("Function")}),r(B,{children:t("Message")}),r(B,{children:t("Trace")}),r(B,{children:t("Shard")}),r(B,{children:t("User")})]})}),r(_e,{children:u.map((g,C)=>r(Qe,{row:g},`${String(g.ts)}-${String(C)}`))})]})}),c!==void 0&&r("div",{children:r(Pe,{"data-testid":"lg-archive-more",disabled:f,onClick:S,size:"sm",variant:"outline",children:t(f?"Loading…":"Load more")})})]})},Ge=i=>{const e=q(11),{level:t,onToggle:a,selected:n}=i;let o;e[0]!==t||e[1]!==a?(o=()=>{a(t)},e[0]=t,e[1]=a,e[2]=o):o=e[2];const d=o,p=n?"border-border bg-muted font-medium":"border-input text-muted-foreground";let m;e[3]!==p?(m=H("rounded-md border px-2 py-1 text-xs",p),e[3]=p,e[4]=m):m=e[4];const c=`logs-level-${t}`;let s;return e[5]!==t||e[6]!==d||e[7]!==n||e[8]!==m||e[9]!==c?(s=r("button",{"aria-pressed":n,className:m,"data-testid":c,onClick:d,type:"button",children:t}),e[5]=t,e[6]=d,e[7]=n,e[8]=m,e[9]=c,e[10]=s):s=e[10],s},He=i=>{const e=q(68),{levelFilter:t,onLogPathChange:a,onSearchChange:n,onTimeRangeChange:o,onToggleLevel:d,onToggleSummary:p,pathFilter:m,search:c,showSummary:s,timeRange:f}=i,l=Q();let u;e[0]!==l?(u=l("Search messages"),e[0]=l,e[1]=u):u=e[1];let h;e[2]!==l?(h=l("search message"),e[2]=l,e[3]=h):h=e[3];let v;e[4]!==n||e[5]!==c||e[6]!==u||e[7]!==h?(v=r(D,{"aria-label":u,className:"h-8 w-48","data-testid":"lg-search",onChange:n,placeholder:h,value:c}),e[4]=n,e[5]=c,e[6]=u,e[7]=h,e[8]=v):v=e[8];let b;e[9]!==l?(b=l("Function path"),e[9]=l,e[10]=b):b=e[10];let y;e[11]!==l?(y=l("filter path"),e[11]=l,e[12]=y):y=e[12];let w;e[13]!==a||e[14]!==m||e[15]!==b||e[16]!==y?(w=r(D,{"aria-label":b,className:"h-8 w-40","data-testid":"logs-path-filter",onChange:a,placeholder:y,value:m}),e[13]=a,e[14]=m,e[15]=b,e[16]=y,e[17]=w):w=e[17];let x;e[18]!==l?(x=l("Level filter"),e[18]=l,e[19]=x):x=e[19];let T;e[20]!==t||e[21]!==d?(T=re.map(G=>r(Ge,{level:G,onToggle:d,selected:t.has(G)},G)),e[20]=t,e[21]=d,e[22]=T):T=e[22];let R;e[23]!==x||e[24]!==T?(R=r("div",{"aria-label":x,className:"inline-flex items-center gap-1","data-testid":"logs-level-filter",role:"group",children:T}),e[23]=x,e[24]=T,e[25]=R):R=e[25];let N;e[26]!==l?(N=l("Time range"),e[26]=l,e[27]=N):N=e[27];let L;e[28]!==l?(L=l("All time"),e[28]=l,e[29]=L):L=e[29];let S;e[30]!==L?(S=r("option",{value:"all",children:L}),e[30]=L,e[31]=S):S=e[31];let g;e[32]!==l?(g=l("Last 5m"),e[32]=l,e[33]=g):g=e[33];let C;e[34]!==g?(C=r("option",{value:"5m",children:g}),e[34]=g,e[35]=C):C=e[35];let k;e[36]!==l?(k=l("Last 15m"),e[36]=l,e[37]=k):k=e[37];let P;e[38]!==k?(P=r("option",{value:"15m",children:k}),e[38]=k,e[39]=P):P=e[39];let O;e[40]!==l?(O=l("Last hour"),e[40]=l,e[41]=O):O=e[41];let _;e[42]!==O?(_=r("option",{value:"1h",children:O}),e[42]=O,e[43]=_):_=e[43];let A;e[44]!==o||e[45]!==N||e[46]!==S||e[47]!==C||e[48]!==P||e[49]!==_||e[50]!==f?(A=E("select",{"aria-label":N,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:f,children:[S,C,P,_]}),e[44]=o,e[45]=N,e[46]=S,e[47]=C,e[48]=P,e[49]=_,e[50]=f,e[51]=A):A=e[51];const z=s?"border-border bg-muted font-medium":"border-input text-muted-foreground";let M;e[52]!==z?(M=H("h-8 rounded-md border px-3 text-sm",z),e[52]=z,e[53]=M):M=e[53];let U;e[54]!==s||e[55]!==l?(U=l(s?"List":"Summary"),e[54]=s,e[55]=l,e[56]=U):U=e[56];let $;e[57]!==p||e[58]!==s||e[59]!==M||e[60]!==U?($=r("button",{"aria-pressed":s,className:M,"data-testid":"logs-summary-toggle",onClick:p,type:"button",children:U}),e[57]=p,e[58]=s,e[59]=M,e[60]=U,e[61]=$):$=e[61];let K;return e[62]!==A||e[63]!==$||e[64]!==v||e[65]!==w||e[66]!==R?(K=E("div",{className:"flex flex-wrap items-center gap-2",children:[v,w,R,A,$]}),e[62]=A,e[63]=$,e[64]=v,e[65]=w,e[66]=R,e[67]=K):K=e[67],K},We=i=>{const e=q(53),{onOutcomeChange:t,onPathChange:a,onTableChange:n,onUserChange:o,outcomeFilter:d,pathPrefix:p,tableFilter:m,userIdFilter:c}=i,s=Q();let f;e[0]!==s?(f=s("Function path"),e[0]=s,e[1]=f):f=e[1];let l;e[2]!==s?(l=s("file:function"),e[2]=s,e[3]=l):l=e[3];let u;e[4]!==a||e[5]!==p||e[6]!==f||e[7]!==l?(u=r(D,{"aria-label":f,className:"h-8 w-44","data-testid":"lg-req-path",onChange:a,placeholder:l,value:p}),e[4]=a,e[5]=p,e[6]=f,e[7]=l,e[8]=u):u=e[8];let h;e[9]!==s?(h=s("User id"),e[9]=s,e[10]=h):h=e[10];let v;e[11]!==s?(v=s("userId"),e[11]=s,e[12]=v):v=e[12];let b;e[13]!==o||e[14]!==h||e[15]!==v||e[16]!==c?(b=r(D,{"aria-label":h,className:"h-8 w-32","data-testid":"lg-req-user",onChange:o,placeholder:v,value:c}),e[13]=o,e[14]=h,e[15]=v,e[16]=c,e[17]=b):b=e[17];let y;e[18]!==s?(y=s("Table touched"),e[18]=s,e[19]=y):y=e[19];let w;e[20]!==s?(w=s("table"),e[20]=s,e[21]=w):w=e[21];let x;e[22]!==n||e[23]!==y||e[24]!==w||e[25]!==m?(x=r(D,{"aria-label":y,className:"h-8 w-32","data-testid":"lg-req-table",onChange:n,placeholder:w,value:m}),e[22]=n,e[23]=y,e[24]=w,e[25]=m,e[26]=x):x=e[26];let T;e[27]!==s?(T=s("Outcome filter"),e[27]=s,e[28]=T):T=e[28];let R;e[29]!==s?(R=s("all"),e[29]=s,e[30]=R):R=e[30];let N;e[31]!==R?(N=r("option",{value:"all",children:R}),e[31]=R,e[32]=N):N=e[32];let L;e[33]!==s?(L=s("ok"),e[33]=s,e[34]=L):L=e[34];let S;e[35]!==L?(S=r("option",{value:"ok",children:L}),e[35]=L,e[36]=S):S=e[36];let g;e[37]!==s?(g=s("error"),e[37]=s,e[38]=g):g=e[38];let C;e[39]!==g?(C=r("option",{value:"error",children:g}),e[39]=g,e[40]=C):C=e[40];let k;e[41]!==t||e[42]!==d||e[43]!==T||e[44]!==N||e[45]!==S||e[46]!==C?(k=E("select",{"aria-label":T,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:d,children:[N,S,C]}),e[41]=t,e[42]=d,e[43]=T,e[44]=N,e[45]=S,e[46]=C,e[47]=k):k=e[47];let P;return e[48]!==k||e[49]!==u||e[50]!==b||e[51]!==x?(P=E("div",{className:"flex flex-wrap items-center gap-2",children:[u,b,x,k]}),e[48]=k,e[49]=u,e[50]=b,e[51]=x,e[52]=P):P=e[52],P},ve=i=>{const e=q(7),{bucket:t}=i;let a;e[0]!==t.key?(a=r("span",{className:"truncate text-muted-foreground",role:"gridcell",children:t.key}),e[0]=t.key,e[1]=a):a=e[1];let n;e[2]!==t.count?(n=r("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]!==a||e[5]!==n?(o=E("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:[a,n]}),e[4]=a,e[5]=n,e[6]=o):o=e[6],o},Ye=i=>{const e=q(31),{summary:t}=i,a=Q();let n;e[0]!==t.total||e[1]!==a?(n=a("{count} entries",{count:t.total}),e[0]=t.total,e[1]=a,e[2]=n):n=e[2];let o;e[3]!==n?(o=r("p",{className:"text-xs text-muted-foreground","data-testid":"logs-summary-total",children:n}),e[3]=n,e[4]=o):o=e[4];let d;e[5]!==a?(d=a("By level"),e[5]=a,e[6]=d):d=e[6];let p;e[7]!==d?(p=r("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:d}),e[7]=d,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 c;e[11]!==m?(c=r("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-levels",role:"grid",children:m}),e[11]=m,e[12]=c):c=e[12];let s;e[13]!==p||e[14]!==c?(s=E("div",{children:[p,c]}),e[13]=p,e[14]=c,e[15]=s):s=e[15];let f;e[16]!==a?(f=a("By function"),e[16]=a,e[17]=f):f=e[17];let l;e[18]!==f?(l=r("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:f}),e[18]=f,e[19]=l):l=e[19];let u;e[20]!==t.byPath?(u=t.byPath.map(Je),e[20]=t.byPath,e[21]=u):u=e[21];let h;e[22]!==u?(h=r("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-paths",role:"grid",children:u}),e[22]=u,e[23]=h):h=e[23];let v;e[24]!==h||e[25]!==l?(v=E("div",{children:[l,h]}),e[24]=h,e[25]=l,e[26]=v):v=e[26];let b;return e[27]!==v||e[28]!==o||e[29]!==s?(b=E("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"logs-summary",children:[o,s,v]}),e[27]=v,e[28]=o,e[29]=s,e[30]=b):b=e[30],b};function je(i){return r(ve,{bucket:i},i.key)}function Je(i){return r(ve,{bucket:i},i.key)}const Xe=i=>{const e=q(46),{liveError:t,onShardKeyChange:a,onShowArchive:n,onShowErrors:o,onShowRequests:d,shardKey:p,view:m}=i,c=Q(),s=m==="requests",f=m==="requests"?"bg-muted font-medium":"text-muted-foreground";let l;e[0]!==f?(l=H("px-3 py-1 text-sm",f),e[0]=f,e[1]=l):l=e[1];let u;e[2]!==c?(u=c("Requests"),e[2]=c,e[3]=u):u=e[3];let h;e[4]!==d||e[5]!==s||e[6]!==l||e[7]!==u?(h=r("button",{"aria-selected":s,className:l,"data-testid":"lg-view-requests",onClick:d,role:"tab",type:"button",children:u}),e[4]=d,e[5]=s,e[6]=l,e[7]=u,e[8]=h):h=e[8];const v=m==="errors",b=m==="errors"?"bg-muted font-medium":"text-muted-foreground";let y;e[9]!==b?(y=H("px-3 py-1 text-sm",b),e[9]=b,e[10]=y):y=e[10];let w;e[11]!==c?(w=c("Errors"),e[11]=c,e[12]=w):w=e[12];let x;e[13]!==o||e[14]!==v||e[15]!==y||e[16]!==w?(x=r("button",{"aria-selected":v,className:y,"data-testid":"lg-view-errors",onClick:o,role:"tab",type:"button",children:w}),e[13]=o,e[14]=v,e[15]=y,e[16]=w,e[17]=x):x=e[17];const T=m==="archive",R=m==="archive"?"bg-muted font-medium":"text-muted-foreground";let N;e[18]!==R?(N=H("px-3 py-1 text-sm",R),e[18]=R,e[19]=N):N=e[19];let L;e[20]!==c?(L=c("Archive"),e[20]=c,e[21]=L):L=e[21];let S;e[22]!==n||e[23]!==T||e[24]!==N||e[25]!==L?(S=r("button",{"aria-selected":T,className:N,"data-testid":"lg-view-archive",onClick:n,role:"tab",type:"button",children:L}),e[22]=n,e[23]=T,e[24]=N,e[25]=L,e[26]=S):S=e[26];let g;e[27]!==x||e[28]!==S||e[29]!==h?(g=E("div",{className:"inline-flex overflow-hidden rounded-lg border border-border",role:"tablist",children:[h,x,S]}),e[27]=x,e[28]=S,e[29]=h,e[30]=g):g=e[30];let C;e[31]!==a||e[32]!==p?(C=r(Ke,{onChange:a,testId:"lg-shard-input",value:p}),e[31]=a,e[32]=p,e[33]=C):C=e[33];let k;e[34]!==t||e[35]!==m?(k=m!=="archive"&&r(Ue,{message:t,prefix:"lg"}),e[34]=t,e[35]=m,e[36]=k):k=e[36];let P;e[37]!==c?(P=c("Open in Cloudflare"),e[37]=c,e[38]=P):P=e[38];let O;e[39]!==P?(O=r("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"lg-cf-link",href:pe,rel:"noreferrer",target:"_blank",children:P}),e[39]=P,e[40]=O):O=e[40];let _;return e[41]!==g||e[42]!==C||e[43]!==k||e[44]!==O?(_=E("div",{className:"flex flex-wrap items-center gap-2",children:[g,C,k,O]}),e[41]=g,e[42]=C,e[43]=k,e[44]=O,e[45]=_):_=e[45],_},te=400,Ze=36,et={height:te,overflow:"auto"},be={left:0,position:"absolute",top:0,width:"100%"},tt={error:"destructive",ok:"secondary"},xe=i=>{const e=q(6),{onOpenTrace:t,traceId:a}=i,n=Q();let o;e[0]!==t||e[1]!==n||e[2]!==a?(o=a===void 0?null:r("button",{className:"text-primary underline-offset-2 hover:underline","data-testid":"lg-trace-link",onClick:()=>{t(a)},type:"button",children:n("Trace")}),e[0]=t,e[1]=n,e[2]=a,e[3]=o):o=e[3];let d;return e[4]!==o?(d=r("span",{className:"w-16 shrink-0 text-right",role:"gridcell",children:o}),e[4]=o,e[5]=d):d=e[5],d},rt=i=>{const e=q(13),{entry:t,index:a,measureRef:n,onOpenTrace:o,start:d}=i,p=`translateY(${String(d)}px)`;let m;e[0]!==p?(m={...be,transform:p},e[0]=p,e[1]=m):m=e[1];const c=m;let s;e[2]!==t?(s=r(Me,{entry:t}),e[2]=t,e[3]=s):s=e[3];let f;e[4]!==t.traceId||e[5]!==o?(f=r(xe,{onOpenTrace:o,traceId:t.traceId}),e[4]=t.traceId,e[5]=o,e[6]=f):f=e[6];let l;return e[7]!==a||e[8]!==n||e[9]!==c||e[10]!==s||e[11]!==f?(l=E("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":a,"data-testid":"lg-row",ref:n,role:"row",style:c,children:[s,f]}),e[7]=a,e[8]=n,e[9]=c,e[10]=s,e[11]=f,e[12]=l):l=e[12],l},ce=i=>i.length===0?"—":i.join(", "),st=i=>{const e=q(41),{entry:t,index:a,measureRef:n,onOpenTrace:o,start:d}=i,p=`translateY(${String(d)}px)`;let m;e[0]!==p?(m={...be,transform:p},e[0]=p,e[1]=m):m=e[1];const c=m;let s;e[2]!==t.ts?(s=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=s):s=e[3];let f;e[4]!==s?(f=r("span",{className:"w-40 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:s}),e[4]=s,e[5]=f):f=e[5];const l=tt[t.outcome];let u;e[6]!==t.outcome||e[7]!==l?(u=r("span",{className:"w-16 shrink-0",role:"gridcell",children:r(he,{variant:l,children:t.outcome})}),e[6]=t.outcome,e[7]=l,e[8]=u):u=e[8];let h;e[9]!==t.functionPath?(h=r("span",{className:"w-44 shrink-0 truncate",role:"gridcell",title:t.functionPath,children:t.functionPath}),e[9]=t.functionPath,e[10]=h):h=e[10];const v=t.shardKey??"—";let b;e[11]!==v?(b=r("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:v}),e[11]=v,e[12]=b):b=e[12];const y=t.userId??"—";let w;e[13]!==y?(w=r("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:y}),e[13]=y,e[14]=w):w=e[14];let x;e[15]!==t.durationMs?(x=Math.round(t.durationMs),e[15]=t.durationMs,e[16]=x):x=e[16];const T=`${String(x)}ms`;let R;e[17]!==T?(R=r("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:T}),e[17]=T,e[18]=R):R=e[18];let N;e[19]!==t.errorMessage||e[20]!==t.outcome||e[21]!==t.tablesRead||e[22]!==t.tablesWritten?(N=t.outcome==="error"&&t.errorMessage!==void 0?t.errorMessage:`r:${ce(t.tablesRead)} · w:${ce(t.tablesWritten)}`,e[19]=t.errorMessage,e[20]=t.outcome,e[21]=t.tablesRead,e[22]=t.tablesWritten,e[23]=N):N=e[23];let L;e[24]!==N?(L=r("span",{className:"flex-1 truncate text-muted-foreground",role:"gridcell",children:N}),e[24]=N,e[25]=L):L=e[25];let S;e[26]!==t.traceId||e[27]!==o?(S=r(xe,{onOpenTrace:o,traceId:t.traceId}),e[26]=t.traceId,e[27]=o,e[28]=S):S=e[28];let g;return e[29]!==a||e[30]!==n||e[31]!==c||e[32]!==w||e[33]!==R||e[34]!==L||e[35]!==S||e[36]!==f||e[37]!==u||e[38]!==h||e[39]!==b?(g=E("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":a,"data-testid":"lg-req-row",ref:n,role:"row",style:c,children:[f,u,h,b,w,R,L,S]}),e[29]=a,e[30]=n,e[31]=c,e[32]=w,e[33]=R,e[34]=L,e[35]=S,e[36]=f,e[37]=u,e[38]=h,e[39]=b,e[40]=g):g=e[40],g},de=i=>{const{entries:e}=i??{};return Array.isArray(e)?e:[]},lt=i=>{const 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},ot={"5m":300*1e3,"15m":900*1e3,"1h":3600*1e3},at=(i,e)=>{const t=e.search.trim().toLowerCase(),a=e.path.trim().toLowerCase(),n=e.range==="all"?Number.NEGATIVE_INFINITY:e.now-ot[e.range];return i.filter(o=>e.levels.size>0&&!e.levels.has(o.level)||o.timestamp<n||a!==""&&!(o.functionPath??"").toLowerCase().includes(a)?!1:t===""||o.message.toLowerCase().includes(t)||fe(o.fields).toLowerCase().includes(t))},nt="—",it=i=>{const e=new Map,t=new Map;for(const o of i){e.set(o.level,(e.get(o.level)??0)+1);const d=o.functionPath??nt;t.set(d,(t.get(d)??0)+1)}const a=re.filter(o=>e.has(o)).map(o=>({count:e.get(o)??0,key:o})),n=[...t.entries()].map(([o,d])=>({count:d,key:o})).toSorted((o,d)=>d.count===o.count?o.key.localeCompare(d.key):d.count-o.count);return{byLevel:a,byPath:n,total:i.length}},Wt=({initialShardKey:i})=>{const e=Q(),[t,a]=F("requests"),{queryShardKey:n,setShardKey:o,shardKey:d}=Ie(i),[p,m]=F(""),[c,s]=F(()=>new Set),[f,l]=F(""),[u,h]=F("all"),[v,b]=F(!1),[y,w]=F(""),[x,T]=F(""),[R,N]=F(""),[L,S]=F("all"),g=lt({functionPathPrefix:y,outcome:L,tableTouched:R,userId:x}),C=le(oe.getRequestLog,g,{enabled:t==="requests",live:!0,shardKey:n}),k=le(oe.getLogs,{},{enabled:t==="errors",live:!0,shardKey:n}),P=t==="requests"?C:k,{error:O,errorSource:_,isLoading:A,liveError:z}=P,M=Te(n),U=de(k.data),$=de(C.data);me(()=>{P.data!==void 0&&Re(n)},[P.data,n]);const K=at(U,{levels:c,now:Date.now(),path:f,range:u,search:p}),G=it(K),J=t==="requests"?$.length:K.length,X=t==="errors"&&v,W=Ne(()=>O!==null?"error":J===0?A?X?"summary":"list":"empty":X?"summary":"list",[J,A,O,X]),se=ue(null),Y=Ce({count:J,estimateSize:()=>Ze,getScrollElement:()=>se.current,initialRect:{height:te,width:800},observeElementRect:(I,Z)=>ke(I,Z,te),overscan:8}),ye=Y.getVirtualItems(),we={height:Y.getTotalSize(),position:"relative",width:"100%"};return E("div",{className:"flex flex-col gap-4","data-testid":"lunora-logs",children:[r(Xe,{liveError:z,onShardKeyChange:o,onShowArchive:()=>{a("archive"),b(!1)},onShowErrors:()=>{a("errors"),b(!1)},onShowRequests:()=>{a("requests"),b(!1)},shardKey:d,view:t}),t==="errors"&&r(He,{levelFilter:c,onLogPathChange:I=>{l(I.target.value)},onSearchChange:I=>{m(I.target.value)},onTimeRangeChange:I=>{h(I.target.value)},onToggleLevel:I=>{s(Z=>{const j=new Set(Z);return j.has(I)?j.delete(I):j.add(I),j})},onToggleSummary:()=>{b(I=>!I)},pathFilter:f,search:p,showSummary:v,timeRange:u}),t==="requests"&&r(We,{onOutcomeChange:I=>{S(I.target.value)},onPathChange:I=>{w(I.target.value)},onTableChange:I=>{N(I.target.value)},onUserChange:I=>{T(I.target.value)},outcomeFilter:L,pathPrefix:y,tableFilter:R,userIdFilter:x}),t==="archive"?r(ze,{shardKey:n}):E($e,{children:[W==="error"&&r(Se,{error:_,testId:"lg-error"}),W==="empty"&&r(ee,{description:e("Function and request logs for this shard show up here as your app handles traffic."),icon:r("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:r("path",{d:"M4 5h16M4 12h16M4 19h10"})}),testId:"lg-empty",title:e("No logs.")}),W==="summary"&&r(Ye,{summary:G}),W==="list"&&r("div",{className:"rounded-xl border border-border shadow-xs","data-testid":"lg-scroll",ref:se,style:et,children:r("div",{"aria-label":e("Recent logs"),"data-testid":"lg-table",role:"grid",style:we,children:ye.map(I=>t==="requests"?r(st,{entry:$[I.index],index:I.index,measureRef:Y.measureElement,onOpenTrace:M,start:I.start},I.key):r(rt,{entry:K[I.index],index:I.index,measureRef:Y.measureElement,onOpenTrace:M,start:I.start},I.key))})})]})]})};export{Wt as LogsPanel,at as filterLogs,it as summarizeLogs};
@@ -1,2 +1,2 @@
1
- import{E as se}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{B as ie}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as g}from"../packem_shared/button-q0UYSmrn.mjs";import{E as oe}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ne}from"../packem_shared/input-CXhxesPC.mjs";import{S as le}from"../packem_shared/scroll-area-CXCQH7VT.mjs";import{Separator as de}from"@base-ui/react/separator";import{c as ce}from"../packem_shared/utils-bhneXptQ.mjs";import{jsx as t,jsxs as n,Fragment as me}from"react/jsx-runtime";import{useT as ue}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{c as ae,d as X,b as Z,f as ee,g as he,h as te}from"../packem_shared/internal-BXEjuLPN.mjs";import{c as pe}from"react/compiler-runtime";import{useState as F}from"react";import{u as fe}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{useAutoRefresh as xe}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-CG7Q45ZS.mjs";import{u as be}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{ADMIN_FUNCTIONS as J}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";function ge({className:r,orientation:e="horizontal",...i}){return t(de,{"data-slot":"separator",orientation:e,className:ce("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",r),...i})}const ve=/https?:\/\/[^\s"'<>)]+/i,re=r=>r===void 0?void 0:ve.exec(r)?.[0],v=r=>r===void 0?"":Array.isArray(r)?r.join(", "):r,Ne=/<a\s(?:[^>]*?\s)?href\s*=\s*["'](https?:\/\/[^"'\s]+)["']/iu,we=/&(?:amp|#0*38|#x0*26);/giu,ye=r=>r===void 0?void 0:((r.html===void 0?void 0:Ne.exec(r.html)?.[1])??re(r.text)??re(r.html))?.replaceAll(we,"&"),Ce=(r,e)=>{const i=e.trim().toLowerCase();return i===""?r:r.filter(o=>`${o.subject} ${v(o.to)} ${v(o.cc)}`.toLowerCase().includes(i))},Se=(r,e)=>{if(r.length!==0)return r.find(i=>i.id===e)??r[0]},Te=ae(J.clearCapturedMail),ke=ae(J.sendTestMail),Ae=r=>{const e=pe(36),{limit:i}=r,o=be();let p;e[0]!==i?(p={limit:i},e[0]=i,e[1]=p):p=e[1];const{data:P,error:N,errorSource:w,isLoading:b,poll:R,refetch:m}=fe(J.getCapturedMail,p),[y,f]=F(null),[O,C]=F(null),[s,h]=F("html"),[x,H]=F(""),a=P?.entries??[],u=N??y,B=N===null?y:w;let S;e[2]!==o||e[3]!==m?(S=async()=>{f(null);try{await o.query(Te,{},X("")),C(null),m()}catch(d){f(Z(d))}},e[2]=o,e[3]=m,e[4]=S):S=e[4];const D=S;let T;e[5]!==o||e[6]!==m?(T=async()=>{f(null);try{await o.query(ke,{},X("")),m()}catch(d){f(Z(d))}},e[5]=o,e[6]=m,e[7]=T):T=e[7];const q=T;xe(R,!0);let k;e[8]!==D?(k=()=>{ee(D())},e[8]=D,e[9]=k):k=e[9];const U=k;let A;e[10]!==q?(A=()=>{ee(q())},e[10]=q,e[11]=A):A=e[11];const W=A;let E;e[12]===Symbol.for("react.memo_cache_sentinel")?(E=d=>{H(d.currentTarget.value)},e[12]=E):E=e[12];const K=E;let _;e[13]===Symbol.for("react.memo_cache_sentinel")?(_=d=>{const{id:c}=d.currentTarget.dataset;c!==void 0&&C(c)},e[13]=_):_=e[13];const Q=_;let L;e[14]===Symbol.for("react.memo_cache_sentinel")?(L=d=>{const c=d.currentTarget.dataset.tab;(c==="headers"||c==="html"||c==="text")&&h(c)},e[14]=L):L=e[14];const V=L,M=Ce(a,x),I=Se(M,O),l=ye(I);let j;e[15]!==l?(j=()=>{l!==void 0&&he(l)},e[15]=l,e[16]=j):j=e[16];const Y=j;let $;e[17]!==l?($=()=>{l!==void 0&&"window"in globalThis&&globalThis.window.open(l,"_blank","noopener")},e[17]=l,e[18]=$):$=e[18];const G=$;let z;return e[19]!==a||e[20]!==u||e[21]!==B||e[22]!==x||e[23]!==b||e[24]!==l||e[25]!==U||e[26]!==Y||e[27]!==K||e[28]!==G||e[29]!==Q||e[30]!==V||e[31]!==W||e[32]!==I||e[33]!==s||e[34]!==M?(z={entries:a,error:u,errorSource:B,filter:x,isLoading:b,link:l,onClear:U,onCopyLink:Y,onFilterChange:K,onOpenLink:G,onSelectMessage:Q,onSelectTab:V,onSendTest:W,selected:I,tab:s,visible:M},e[19]=a,e[20]=u,e[21]=B,e[22]=x,e[23]=b,e[24]=l,e[25]=U,e[26]=Y,e[27]=K,e[28]=G,e[29]=Q,e[30]=V,e[31]=W,e[32]=I,e[33]=s,e[34]=M,e[35]=z):z=e[35],z},Ee=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">`,_e=r=>`${Ee}${r}`,Qe=({limit:r=100})=>{const e=ue(),{entries:i,error:o,errorSource:p,filter:P,isLoading:N,link:w,onClear:b,onCopyLink:R,onFilterChange:m,onOpenLink:y,onSelectMessage:f,onSelectTab:O,onSendTest:C,selected:s,tab:h,visible:x}=Ae({limit:r}),H=a=>e(a==="html"?"HTML":a==="text"?"Plain text":"Headers");return n("div",{className:"flex flex-col gap-4","data-testid":"mail-panel",children:[n("div",{className:"flex flex-wrap items-center gap-2",children:[t(g,{"data-testid":"mail-send-test",onClick:C,size:"sm",type:"button",variant:"outline",children:e("Send test")}),t(g,{"data-testid":"mail-clear",disabled:i.length===0,onClick:b,size:"sm",type:"button",variant:"outline",children:e("Clear inbox")}),i.length>0&&t(ie,{className:"ml-auto","data-testid":"mail-count",variant:"secondary",children:e("{count} messages",{count:i.length})})]}),o!==null&&t(se,{error:p,testId:"mail-error"}),o===null&&!N&&i.length===0&&t(oe,{description:e("Email your app sends in dev is captured here — nothing is delivered."),icon:n("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[t("path",{d:"M4 5h16v14H4z"}),t("path",{d:"m4 6 8 6 8-6"})]}),testId:"mail-empty",title:e("No captured email.")}),i.length>0&&n("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-[minmax(0,22rem)_1fr]","data-testid":"mail-reader",children:[n("div",{className:"flex flex-col gap-2",children:[t(ne,{"aria-label":e("Search messages"),"data-testid":"mail-search",onChange:m,placeholder:e("Filter messages"),type:"search",value:P}),t(le,{className:"max-h-[32rem] rounded-xl border border-border bg-card shadow-xs","data-testid":"mail-list",children:t("ul",{className:"divide-y",children:x.map(a=>{const u=a.id===s?.id;return t("li",{children:n("button",{className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-sm hover:bg-muted/60 ${u?"bg-muted":""}`,"data-active":u,"data-id":a.id,"data-testid":"mail-list-item",onClick:f,type:"button",children:[t("span",{className:"w-full truncate font-medium",children:a.subject||e("(no subject)")}),t("span",{className:"w-full truncate text-xs text-muted-foreground",children:v(a.to)}),t("span",{className:"text-xs text-muted-foreground tabular-nums",children:te(a.capturedAt,"—")})]})},a.id)})})})]}),s!==void 0&&n("div",{className:"flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"mail-detail",children:[n("div",{className:"flex flex-col gap-1",children:[t("h2",{className:"truncate text-base font-semibold","data-testid":"mail-subject",children:s.subject||e("(no subject)")}),n("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs text-muted-foreground",children:[t("dt",{children:e("From")}),t("dd",{className:"truncate font-mono",children:s.from??"—"}),t("dt",{children:e("To")}),t("dd",{className:"truncate font-mono",children:v(s.to)}),s.cc!==void 0&&s.cc.length>0&&n(me,{children:[t("dt",{children:e("Cc")}),t("dd",{className:"truncate font-mono",children:v(s.cc)})]}),t("dt",{children:e("Sent")}),t("dd",{className:"tabular-nums",children:te(s.capturedAt,"—")})]})]}),n("div",{className:"flex flex-wrap items-center gap-2","data-testid":"mail-actions",children:[t(g,{"data-testid":"mail-copy-link",disabled:w===void 0,onClick:R,size:"sm",type:"button",variant:"outline",children:e("Copy link")}),t(g,{"data-testid":"mail-open-link",disabled:w===void 0,onClick:y,size:"sm",type:"button",variant:"outline",children:e("Open in new tab")})]}),t(ge,{}),t("div",{className:"flex items-center gap-1","data-testid":"mail-tabs",role:"tablist",children:["html","text","headers"].map(a=>t(g,{"aria-selected":h===a,"data-tab":a,"data-testid":`mail-tab-${a}`,onClick:O,role:"tab",size:"sm",type:"button",variant:h===a?"secondary":"ghost",children:H(a)},a))}),n("div",{className:"min-h-[12rem]",children:[h==="html"&&(s.html===void 0?t("p",{className:"text-sm text-muted-foreground",children:e("No HTML body.")}):t("iframe",{className:"h-[24rem] w-full rounded-md border bg-white","data-testid":"mail-preview-html",sandbox:"",srcDoc:_e(s.html),title:e("Email preview")})),h==="text"&&(s.text===void 0?t("p",{className:"text-sm text-muted-foreground",children:e("No text body.")}):t("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-text",children:s.text})),h==="headers"&&(s.headers===void 0||Object.keys(s.headers).length===0?t("p",{className:"text-sm text-muted-foreground",children:e("No headers.")}):t("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-headers",children:Object.entries(s.headers).map(([a,u])=>`${a}: ${u}`).join(`
1
+ import{E as se}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{B as ie}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as g}from"../packem_shared/button-q0UYSmrn.mjs";import{E as oe}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ne}from"../packem_shared/input-CXhxesPC.mjs";import{S as le}from"../packem_shared/scroll-area-CXCQH7VT.mjs";import{Separator as de}from"@base-ui/react/separator";import{c as ce}from"../packem_shared/utils-bhneXptQ.mjs";import{jsx as t,jsxs as n,Fragment as me}from"react/jsx-runtime";import{useT as ue}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{c as ae,d as X,b as Z,f as ee,g as he,h as te}from"../packem_shared/internal-BXEjuLPN.mjs";import{c as pe}from"react/compiler-runtime";import{useState as F}from"react";import{u as fe}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{useAutoRefresh as xe}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-CG7Q45ZS.mjs";import{u as be}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{ADMIN_FUNCTIONS as J}from"../packem_shared/ADMIN_FUNCTIONS-4aGsMs95.mjs";function ge({className:r,orientation:e="horizontal",...i}){return t(de,{"data-slot":"separator",orientation:e,className:ce("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",r),...i})}const ve=/https?:\/\/[^\s"'<>)]+/i,re=r=>r===void 0?void 0:ve.exec(r)?.[0],v=r=>r===void 0?"":Array.isArray(r)?r.join(", "):r,Ne=/<a\s(?:[^>]*?\s)?href\s*=\s*["'](https?:\/\/[^"'\s]+)["']/iu,we=/&(?:amp|#0*38|#x0*26);/giu,ye=r=>r===void 0?void 0:((r.html===void 0?void 0:Ne.exec(r.html)?.[1])??re(r.text)??re(r.html))?.replaceAll(we,"&"),Ce=(r,e)=>{const i=e.trim().toLowerCase();return i===""?r:r.filter(o=>`${o.subject} ${v(o.to)} ${v(o.cc)}`.toLowerCase().includes(i))},Se=(r,e)=>{if(r.length!==0)return r.find(i=>i.id===e)??r[0]},Te=ae(J.clearCapturedMail),ke=ae(J.sendTestMail),Ae=r=>{const e=pe(36),{limit:i}=r,o=be();let p;e[0]!==i?(p={limit:i},e[0]=i,e[1]=p):p=e[1];const{data:P,error:N,errorSource:w,isLoading:b,poll:R,refetch:m}=fe(J.getCapturedMail,p),[y,f]=F(null),[O,C]=F(null),[s,h]=F("html"),[x,H]=F(""),a=P?.entries??[],u=N??y,B=N===null?y:w;let S;e[2]!==o||e[3]!==m?(S=async()=>{f(null);try{await o.query(Te,{},X("")),C(null),m()}catch(d){f(Z(d))}},e[2]=o,e[3]=m,e[4]=S):S=e[4];const D=S;let T;e[5]!==o||e[6]!==m?(T=async()=>{f(null);try{await o.query(ke,{},X("")),m()}catch(d){f(Z(d))}},e[5]=o,e[6]=m,e[7]=T):T=e[7];const q=T;xe(R,!0);let k;e[8]!==D?(k=()=>{ee(D())},e[8]=D,e[9]=k):k=e[9];const U=k;let A;e[10]!==q?(A=()=>{ee(q())},e[10]=q,e[11]=A):A=e[11];const W=A;let E;e[12]===Symbol.for("react.memo_cache_sentinel")?(E=d=>{H(d.currentTarget.value)},e[12]=E):E=e[12];const K=E;let _;e[13]===Symbol.for("react.memo_cache_sentinel")?(_=d=>{const{id:c}=d.currentTarget.dataset;c!==void 0&&C(c)},e[13]=_):_=e[13];const Q=_;let L;e[14]===Symbol.for("react.memo_cache_sentinel")?(L=d=>{const c=d.currentTarget.dataset.tab;(c==="headers"||c==="html"||c==="text")&&h(c)},e[14]=L):L=e[14];const V=L,M=Ce(a,x),I=Se(M,O),l=ye(I);let j;e[15]!==l?(j=()=>{l!==void 0&&he(l)},e[15]=l,e[16]=j):j=e[16];const Y=j;let $;e[17]!==l?($=()=>{l!==void 0&&"window"in globalThis&&globalThis.window.open(l,"_blank","noopener")},e[17]=l,e[18]=$):$=e[18];const G=$;let z;return e[19]!==a||e[20]!==u||e[21]!==B||e[22]!==x||e[23]!==b||e[24]!==l||e[25]!==U||e[26]!==Y||e[27]!==K||e[28]!==G||e[29]!==Q||e[30]!==V||e[31]!==W||e[32]!==I||e[33]!==s||e[34]!==M?(z={entries:a,error:u,errorSource:B,filter:x,isLoading:b,link:l,onClear:U,onCopyLink:Y,onFilterChange:K,onOpenLink:G,onSelectMessage:Q,onSelectTab:V,onSendTest:W,selected:I,tab:s,visible:M},e[19]=a,e[20]=u,e[21]=B,e[22]=x,e[23]=b,e[24]=l,e[25]=U,e[26]=Y,e[27]=K,e[28]=G,e[29]=Q,e[30]=V,e[31]=W,e[32]=I,e[33]=s,e[34]=M,e[35]=z):z=e[35],z},Ee=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">`,_e=r=>`${Ee}${r}`,Qe=({limit:r=100})=>{const e=ue(),{entries:i,error:o,errorSource:p,filter:P,isLoading:N,link:w,onClear:b,onCopyLink:R,onFilterChange:m,onOpenLink:y,onSelectMessage:f,onSelectTab:O,onSendTest:C,selected:s,tab:h,visible:x}=Ae({limit:r}),H=a=>e(a==="html"?"HTML":a==="text"?"Plain text":"Headers");return n("div",{className:"flex flex-col gap-4","data-testid":"mail-panel",children:[n("div",{className:"flex flex-wrap items-center gap-2",children:[t(g,{"data-testid":"mail-send-test",onClick:C,size:"sm",type:"button",variant:"outline",children:e("Send test")}),t(g,{"data-testid":"mail-clear",disabled:i.length===0,onClick:b,size:"sm",type:"button",variant:"outline",children:e("Clear inbox")}),i.length>0&&t(ie,{className:"ml-auto","data-testid":"mail-count",variant:"secondary",children:e("{count} messages",{count:i.length})})]}),o!==null&&t(se,{error:p,testId:"mail-error"}),o===null&&!N&&i.length===0&&t(oe,{description:e("Email your app sends in dev is captured here — nothing is delivered."),icon:n("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[t("path",{d:"M4 5h16v14H4z"}),t("path",{d:"m4 6 8 6 8-6"})]}),testId:"mail-empty",title:e("No captured email.")}),i.length>0&&n("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-[minmax(0,22rem)_1fr]","data-testid":"mail-reader",children:[n("div",{className:"flex flex-col gap-2",children:[t(ne,{"aria-label":e("Search messages"),"data-testid":"mail-search",onChange:m,placeholder:e("Filter messages"),type:"search",value:P}),t(le,{className:"max-h-[32rem] rounded-xl border border-border bg-card shadow-xs","data-testid":"mail-list",children:t("ul",{className:"divide-y",children:x.map(a=>{const u=a.id===s?.id;return t("li",{children:n("button",{className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-sm hover:bg-muted/60 ${u?"bg-muted":""}`,"data-active":u,"data-id":a.id,"data-testid":"mail-list-item",onClick:f,type:"button",children:[t("span",{className:"w-full truncate font-medium",children:a.subject||e("(no subject)")}),t("span",{className:"w-full truncate text-xs text-muted-foreground",children:v(a.to)}),t("span",{className:"text-xs text-muted-foreground tabular-nums",children:te(a.capturedAt,"—")})]})},a.id)})})})]}),s!==void 0&&n("div",{className:"flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"mail-detail",children:[n("div",{className:"flex flex-col gap-1",children:[t("h2",{className:"truncate text-base font-semibold","data-testid":"mail-subject",children:s.subject||e("(no subject)")}),n("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs text-muted-foreground",children:[t("dt",{children:e("From")}),t("dd",{className:"truncate font-mono",children:s.from??"—"}),t("dt",{children:e("To")}),t("dd",{className:"truncate font-mono",children:v(s.to)}),s.cc!==void 0&&s.cc.length>0&&n(me,{children:[t("dt",{children:e("Cc")}),t("dd",{className:"truncate font-mono",children:v(s.cc)})]}),t("dt",{children:e("Sent")}),t("dd",{className:"tabular-nums",children:te(s.capturedAt,"—")})]})]}),n("div",{className:"flex flex-wrap items-center gap-2","data-testid":"mail-actions",children:[t(g,{"data-testid":"mail-copy-link",disabled:w===void 0,onClick:R,size:"sm",type:"button",variant:"outline",children:e("Copy link")}),t(g,{"data-testid":"mail-open-link",disabled:w===void 0,onClick:y,size:"sm",type:"button",variant:"outline",children:e("Open in new tab")})]}),t(ge,{}),t("div",{className:"flex items-center gap-1","data-testid":"mail-tabs",role:"tablist",children:["html","text","headers"].map(a=>t(g,{"aria-selected":h===a,"data-tab":a,"data-testid":`mail-tab-${a}`,onClick:O,role:"tab",size:"sm",type:"button",variant:h===a?"secondary":"ghost",children:H(a)},a))}),n("div",{className:"min-h-[12rem]",children:[h==="html"&&(s.html===void 0?t("p",{className:"text-sm text-muted-foreground",children:e("No HTML body.")}):t("iframe",{className:"h-[24rem] w-full rounded-md border bg-white","data-testid":"mail-preview-html",sandbox:"",srcDoc:_e(s.html),title:e("Email preview")})),h==="text"&&(s.text===void 0?t("p",{className:"text-sm text-muted-foreground",children:e("No text body.")}):t("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-text",children:s.text})),h==="headers"&&(s.headers===void 0||Object.keys(s.headers).length===0?t("p",{className:"text-sm text-muted-foreground",children:e("No headers.")}):t("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-headers",children:Object.entries(s.headers).map(([a,u])=>`${a}: ${u}`).join(`
2
2
  `)}))]})]})]})]})};export{Qe as MailPanel};
@@ -1 +1 @@
1
- import{c as me}from"react/compiler-runtime";import{useState as be,useRef as Je,useEffect as We}from"react";import{L as gt}from"../packem_shared/live-status-D1GasNsH.mjs";import{ShardInput as pt}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{B as tt}from"../packem_shared/button-q0UYSmrn.mjs";import{u as je}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{u as xt}from"../packem_shared/use-open-trace-B_0LbTD7.mjs";import{u as bt}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{u as vt}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as ge}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as Fe}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{c as yt}from"../packem_shared/cf-links-CBJ5SywP.mjs";import{j as Nt,n as Xe,f as St,d as wt,b as Tt,c as qt}from"../packem_shared/internal-BXEjuLPN.mjs";import{l as _t,r as Ct}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{f as Rt}from"../packem_shared/log-fields-BolUoZ9g.mjs";import{B as et}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as pe,a as xe,b as Be,d as Mt,c as Qe}from"../packem_shared/card-By2O8ULa.mjs";import{b as Ve,e as ie,T as ct,c as oe,a as dt,d as mt}from"../packem_shared/table-D0SBiDu-.mjs";import{stableStringify as kt}from"@lunora/wire";import{S as ft}from"../packem_shared/sparkline-B_sPPO_8.mjs";import{jsxs as f,jsx as s,Fragment as Ze}from"react/jsx-runtime";import{aggregateMetrics as At,enrichQueryStats as It,shardsToAggregate as $t,computeLatencyPercentiles as Dt}from"../packem_shared/aggregateMetrics-DKFJc-o5.mjs";import{S as ce}from"../packem_shared/stat-card-BAv73QtB.mjs";import{b as st,c as Et,h as Lt}from"../packem_shared/metrics-format-1sNGG47R.mjs";import{ResponsiveContainer as rt,AreaChart as Ft,CartesianGrid as lt,XAxis as at,YAxis as it,Tooltip as nt,Area as Ot,LineChart as zt,Line as Kt}from"recharts";import{E as Pt}from"../packem_shared/empty-state-D7jEML_T.mjs";import{c as Bt}from"../packem_shared/utils-bhneXptQ.mjs";import{S as Qt,a as Ht,c as He,b as Ut,d as jt}from"../packem_shared/select-DPyS18Vy.mjs";const ut=(i,e,l)=>`${i}:${e}:${kt(l??{})}`,ht=(i,e)=>i==="gauge"?e.last:i==="histogram"?e.sum/Math.max(1,e.count):e.sum,Vt=(i,e)=>ht(i,e),Gt=i=>ht(i.kind,i),Ye=i=>Number.isInteger(i)?i.toLocaleString():i.toLocaleString(void 0,{maximumFractionDigits:2}),Yt=i=>Array.isArray(i?.series)?i.series:[],Jt="FUNCTION_NOT_FOUND",Wt=i=>{const e=new Map;if(!Array.isArray(i?.series))return e;for(const l of i.series)e.set(ut(l.kind,l.name,l.attributes),l.points);return e},Xt={counter:"secondary",gauge:"default",histogram:"outline"},Zt=i=>{const e=me(18),{name:l,onOpenTrace:r,traceId:t}=i,o=ge();if(t===void 0){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=s("span",{className:"text-muted-foreground",children:"—"}),e[0]=d):d=e[0],d}let n;e[1]!==t?(n=t.slice(0,8),e[1]=t,e[2]=n):n=e[2];const a=n;if(r===void 0){const d=`mt-instrument-trace-${l}`;let c;return e[3]!==a||e[4]!==d||e[5]!==t?(c=s("span",{className:"text-muted-foreground","data-testid":d,title:t,children:a}),e[3]=a,e[4]=d,e[5]=t,e[6]=c):c=e[6],c}const m=`mt-instrument-trace-${l}`;let p;e[7]!==r||e[8]!==t?(p=()=>{r(t)},e[7]=r,e[8]=t,e[9]=p):p=e[9];let h;e[10]!==o||e[11]!==t?(h=o("Open the exemplar trace {trace}",{trace:t}),e[10]=o,e[11]=t,e[12]=h):h=e[12];let u;return e[13]!==a||e[14]!==m||e[15]!==p||e[16]!==h?(u=s("button",{className:"text-primary underline-offset-4 hover:underline","data-testid":m,onClick:p,title:h,type:"button",children:a}),e[13]=a,e[14]=m,e[15]=p,e[16]=h,e[17]=u):u=e[17],u},es=i=>{const e=me(105),{onOpenTrace:l,shardKey:r}=i,t=ge();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={},e[0]=o):o=e[0];let n;e[1]!==r?(n={live:!0,shardKey:r},e[1]=r,e[2]=n):n=e[2];const{data:a,error:m,errorSource:p}=je(Fe.getMetricSeries,o,n);let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h={},e[3]=h):h=e[3];let u;e[4]!==r?(u={live:!0,shardKey:r},e[4]=r,e[5]=u):u=e[5];const{data:d}=je(Fe.getMetricHistory,h,u);let c,x,g,v,b,S,y,w,M,_,N,$,q;if(e[6]!==a||e[7]!==m||e[8]!==p||e[9]!==d||e[10]!==l||e[11]!==t){w=Symbol.for("react.early_return_sentinel");e:{const E=Yt(a),L=Nt(p)===Jt;if(m!==null&&!L){let T;e[25]!==t?(T=t("Instruments"),e[25]=t,e[26]=T):T=e[26];let O;e[27]!==T?(O=s("h3",{className:"text-sm font-semibold text-foreground",children:T}),e[27]=T,e[28]=O):O=e[28];let z;e[29]!==m||e[30]!==t?(z=t("Instruments unavailable: {error}",{error:m}),e[29]=m,e[30]=t,e[31]=z):z=e[31];let K;e[32]!==z?(K=s("span",{className:"text-xs text-muted-foreground","data-testid":"mt-instruments-error",role:"status",children:z}),e[32]=z,e[33]=K):K=e[33];let P;e[34]!==O||e[35]!==K?(P=f("section",{className:"flex flex-col gap-2","data-testid":"mt-instruments",children:[O,K]}),e[34]=O,e[35]=K,e[36]=P):P=e[36],w=P;break e}if(E.length===0){w=null;break e}const F=Wt(d);let de;e[37]!==t?(de=T=>t(T==="counter"?"Counter":T==="gauge"?"Gauge":"Histogram"),e[37]=t,e[38]=de):de=e[38];const fe=de;b="flex flex-col gap-2",S="mt-instruments";let Q;e[39]!==t?(Q=t("Instruments"),e[39]=t,e[40]=Q):Q=e[40],e[41]!==Q?(y=s("h3",{className:"text-sm font-semibold text-foreground",children:Q}),e[41]=Q,e[42]=y):y=e[42],v=pe,q="overflow-hidden py-0",g=xe,$="px-0",x=ct,_="mt-instruments-table";let H;e[43]!==t?(H=t("name"),e[43]=t,e[44]=H):H=e[44];let U;e[45]!==H?(U=s(oe,{children:H}),e[45]=H,e[46]=U):U=e[46];let j;e[47]!==t?(j=t("kind"),e[47]=t,e[48]=j):j=e[48];let V;e[49]!==j?(V=s(oe,{children:j}),e[49]=j,e[50]=V):V=e[50];let G;e[51]!==t?(G=t("value"),e[51]=t,e[52]=G):G=e[52];let Y;e[53]!==G?(Y=s(oe,{className:"text-right",children:G}),e[53]=G,e[54]=Y):Y=e[54];let J;e[55]!==t?(J=t("count"),e[55]=t,e[56]=J):J=e[56];let W;e[57]!==J?(W=s(oe,{className:"text-right",children:J}),e[57]=J,e[58]=W):W=e[58];let X;e[59]!==t?(X=t("range"),e[59]=t,e[60]=X):X=e[60];let Z;e[61]!==X?(Z=s(oe,{className:"text-right",children:X}),e[61]=X,e[62]=Z):Z=e[62];let ee;e[63]!==t?(ee=t("trend"),e[63]=t,e[64]=ee):ee=e[64];let te;e[65]!==ee?(te=s(oe,{children:ee}),e[65]=ee,e[66]=te):te=e[66];let se;e[67]!==t?(se=t("trace"),e[67]=t,e[68]=se):se=e[68];let re;e[69]!==se?(re=s(oe,{children:se}),e[69]=se,e[70]=re):re=e[70];let le;e[71]!==t?(le=t("dimensions"),e[71]=t,e[72]=le):le=e[72];let ae;e[73]!==le?(ae=s(oe,{children:le}),e[73]=le,e[74]=ae):ae=e[74],e[75]!==U||e[76]!==V||e[77]!==Y||e[78]!==W||e[79]!==Z||e[80]!==te||e[81]!==re||e[82]!==ae?(N=s(dt,{children:f(Ve,{children:[U,V,Y,W,Z,te,re,ae]})}),e[75]=U,e[76]=V,e[77]=Y,e[78]=W,e[79]=Z,e[80]=te,e[81]=re,e[82]=ae,e[83]=N):N=e[83],c=mt,M=E.map(T=>{const O=Rt(T.attributes),z=ut(T.kind,T.name,T.attributes),P=(F.get(z)??[]).map(ue=>Vt(T.kind,ue));return f(Ve,{"data-testid":`mt-instrument-${T.name}`,children:[s(ie,{className:"font-mono text-xs",title:T.functionPath,children:T.name}),s(ie,{children:s(et,{variant:Xt[T.kind],children:fe(T.kind)})}),s(ie,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${T.name}`,children:Ye(Gt(T))}),s(ie,{className:"text-right tabular-nums text-muted-foreground",children:T.count.toLocaleString()}),s(ie,{className:"text-right font-mono text-xs tabular-nums text-muted-foreground",children:T.min===T.max?"—":`${Ye(T.min)}–${Ye(T.max)}`}),s(ie,{children:P.length>=2?s(ft,{ariaLabel:t("{name} trend",{name:T.name}),className:"h-6 w-24 text-foreground",series:P,testId:`mt-instrument-trend-${T.name}`}):s("span",{className:"text-xs text-muted-foreground",children:"—"})}),s(ie,{className:"font-mono text-xs",children:s(Zt,{name:T.name,onOpenTrace:l,traceId:T.exemplarTraceId})}),s(ie,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:O,children:O===""?"—":O})]},z)})}e[6]=a,e[7]=m,e[8]=p,e[9]=d,e[10]=l,e[11]=t,e[12]=c,e[13]=x,e[14]=g,e[15]=v,e[16]=b,e[17]=S,e[18]=y,e[19]=w,e[20]=M,e[21]=_,e[22]=N,e[23]=$,e[24]=q}else c=e[12],x=e[13],g=e[14],v=e[15],b=e[16],S=e[17],y=e[18],w=e[19],M=e[20],_=e[21],N=e[22],$=e[23],q=e[24];if(w!==Symbol.for("react.early_return_sentinel"))return w;let C;e[84]!==c||e[85]!==M?(C=s(c,{children:M}),e[84]=c,e[85]=M,e[86]=C):C=e[86];let k;e[87]!==x||e[88]!==C||e[89]!==_||e[90]!==N?(k=f(x,{"data-testid":_,children:[N,C]}),e[87]=x,e[88]=C,e[89]=_,e[90]=N,e[91]=k):k=e[91];let R;e[92]!==g||e[93]!==k||e[94]!==$?(R=s(g,{className:$,children:k}),e[92]=g,e[93]=k,e[94]=$,e[95]=R):R=e[95];let A;e[96]!==v||e[97]!==R||e[98]!==q?(A=s(v,{className:q,children:R}),e[96]=v,e[97]=R,e[98]=q,e[99]=A):A=e[99];let I;return e[100]!==b||e[101]!==S||e[102]!==y||e[103]!==A?(I=f("section",{className:b,"data-testid":S,children:[y,A]}),e[100]=b,e[101]=S,e[102]=y,e[103]=A,e[104]=I):I=e[104],I},ts=i=>{const e=me(74),{aggregate:l,shardResults:r}=i,t=ge();let o;e[0]!==t?(o=t("Shards"),e[0]=t,e[1]=o):o=e[1];let n;e[2]!==l.failed||e[3]!==l.reachable||e[4]!==t?(n=l.failed>0?t("{reachable} reachable, {failed} unreachable",{failed:l.failed,reachable:l.reachable}):t("{reachable} reachable",{reachable:l.reachable}),e[2]=l.failed,e[3]=l.reachable,e[4]=t,e[5]=n):n=e[5];let a;e[6]!==o||e[7]!==n?(a=s(ce,{label:o,testId:"mt-agg-shards",value:n}),e[6]=o,e[7]=n,e[8]=a):a=e[8];let m;e[9]!==t?(m=t("Total requests"),e[9]=t,e[10]=m):m=e[10];let p;e[11]!==l.totalRequests||e[12]!==m?(p=s(ce,{label:m,testId:"mt-agg-requests",value:l.totalRequests}),e[11]=l.totalRequests,e[12]=m,e[13]=p):p=e[13];let h;e[14]!==t?(h=t("Total errors"),e[14]=t,e[15]=h):h=e[15];let u;e[16]!==l.totalErrors||e[17]!==h?(u=s(ce,{label:h,testId:"mt-agg-errors",value:l.totalErrors}),e[16]=l.totalErrors,e[17]=h,e[18]=u):u=e[18];let d;e[19]!==t?(d=t("Total database size"),e[19]=t,e[20]=d):d=e[20];let c;e[21]!==l.totalDatabaseSize?(c=Xe(l.totalDatabaseSize),e[21]=l.totalDatabaseSize,e[22]=c):c=e[22];let x;e[23]!==d||e[24]!==c?(x=s(ce,{label:d,testId:"mt-agg-db-size",value:c}),e[23]=d,e[24]=c,e[25]=x):x=e[25];let g;e[26]!==t?(g=t("Combined cache hit rate"),e[26]=t,e[27]=g):g=e[27];let v;e[28]!==l.hitRate||e[29]!==t?(v=l.hitRate===null?t("no cache configured"):`${(l.hitRate*100).toFixed(1)}%`,e[28]=l.hitRate,e[29]=t,e[30]=v):v=e[30];let b;e[31]!==g||e[32]!==v?(b=s(ce,{label:g,testId:"mt-agg-cache",value:v}),e[31]=g,e[32]=v,e[33]=b):b=e[33];let S;e[34]!==x||e[35]!==b||e[36]!==a||e[37]!==p||e[38]!==u?(S=f("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[a,p,u,x,b]}),e[34]=x,e[35]=b,e[36]=a,e[37]=p,e[38]=u,e[39]=S):S=e[39];let y;e[40]!==t?(y=t("shard"),e[40]=t,e[41]=y):y=e[41];let w;e[42]!==y?(w=s(oe,{children:y}),e[42]=y,e[43]=w):w=e[43];let M;e[44]!==t?(M=t("requests"),e[44]=t,e[45]=M):M=e[45];let _;e[46]!==M?(_=s(oe,{children:M}),e[46]=M,e[47]=_):_=e[47];let N;e[48]!==t?(N=t("errors"),e[48]=t,e[49]=N):N=e[49];let $;e[50]!==N?($=s(oe,{children:N}),e[50]=N,e[51]=$):$=e[51];let q;e[52]!==t?(q=t("db size"),e[52]=t,e[53]=q):q=e[53];let C;e[54]!==q?(C=s(oe,{children:q}),e[54]=q,e[55]=C):C=e[55];let k;e[56]!==w||e[57]!==_||e[58]!==$||e[59]!==C?(k=s(dt,{children:f(Ve,{children:[w,_,$,C]})}),e[56]=w,e[57]=_,e[58]=$,e[59]=C,e[60]=k):k=e[60];let R;if(e[61]!==r||e[62]!==t){let L;e[64]!==t?(L=F=>f(Ve,{"data-testid":`mt-agg-row-${F.shard}`,children:[s(ie,{children:F.shard}),F.metrics===null?s(ie,{className:"text-destructive",colSpan:3,children:F.error??t("unreachable")}):f(Ze,{children:[s(ie,{className:"tabular-nums",children:F.metrics.requests}),s(ie,{className:"tabular-nums",children:F.metrics.errors}),s(ie,{className:"tabular-nums",children:Xe(F.metrics.databaseSize)})]})]},F.shard),e[64]=t,e[65]=L):L=e[65],R=r.map(L),e[61]=r,e[62]=t,e[63]=R}else R=e[63];let A;e[66]!==R?(A=s(mt,{children:R}),e[66]=R,e[67]=A):A=e[67];let I;e[68]!==k||e[69]!==A?(I=s(pe,{className:"overflow-hidden py-0",children:s(xe,{className:"px-0",children:f(ct,{"data-testid":"mt-agg-table",children:[k,A]})})}),e[68]=k,e[69]=A,e[70]=I):I=e[70];let E;return e[71]!==S||e[72]!==I?(E=f("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[S,I]}),e[71]=S,e[72]=I,e[73]=E):E=e[73],E},ss=i=>{const e=me(75),{currentDelta:l,errorRate:r,history:t,latencyPercentiles:o,metrics:n}=i,a=ge(),{cache:m}=n;let p;e[0]!==t||e[1]!==a?(p=t.length>=2?s(ft,{ariaLabel:a("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:t,testId:"mt-sparkline"}):void 0,e[0]=t,e[1]=a,e[2]=p):p=e[2];let h;e[3]!==l||e[4]!==t.length||e[5]!==a?(h=t.length>=2?f(Ze,{children:[s("span",{className:"font-semibold text-foreground",children:`+${l.toLocaleString()}`})," ",a("last interval")]}):s("span",{"data-testid":"mt-sparkline-empty",children:a("collecting samples…")}),e[3]=l,e[4]=t.length,e[5]=a,e[6]=h):h=e[6];let u;e[7]!==a?(u=a("Requests"),e[7]=a,e[8]=u):u=e[8];let d;e[9]!==n.requests||e[10]!==p||e[11]!==h||e[12]!==u?(d=s(ce,{chart:p,footer:h,label:u,testId:"mt-requests",value:n.requests}),e[9]=n.requests,e[10]=p,e[11]=h,e[12]=u,e[13]=d):d=e[13];let c;e[14]!==r||e[15]!==a?(c=a("{rate} error rate",{rate:r}),e[14]=r,e[15]=a,e[16]=c):c=e[16];let x;e[17]!==a?(x=a("Errors"),e[17]=a,e[18]=x):x=e[18];let g;e[19]!==r||e[20]!==n.errors?(g=f(Ze,{children:[n.errors," (",r,")"]}),e[19]=r,e[20]=n.errors,e[21]=g):g=e[21];let v;e[22]!==c||e[23]!==x||e[24]!==g?(v=s(ce,{footer:c,label:x,testId:"mt-errors",value:g}),e[22]=c,e[23]=x,e[24]=g,e[25]=v):v=e[25];let b;e[26]!==o.p90?(b=o.p90>0?`P90 ${st(o.p90)}`:void 0,e[26]=o.p90,e[27]=b):b=e[27];let S;e[28]!==a?(S=a("P95 latency"),e[28]=a,e[29]=S):S=e[29];let y;e[30]!==o.p95?(y=o.p95>0?st(o.p95):"—",e[30]=o.p95,e[31]=y):y=e[31];let w;e[32]!==S||e[33]!==y||e[34]!==b?(w=s(ce,{footer:b,label:S,testId:"mt-p95",value:y}),e[32]=S,e[33]=y,e[34]=b,e[35]=w):w=e[35];let M;e[36]!==m||e[37]!==a?(M=m?`${m.entries.toLocaleString()} ${a("cache entries")}`:void 0,e[36]=m,e[37]=a,e[38]=M):M=e[38];let _;e[39]!==a?(_=a("Database size"),e[39]=a,e[40]=_):_=e[40];let N;e[41]!==n.databaseSize?(N=Xe(n.databaseSize),e[41]=n.databaseSize,e[42]=N):N=e[42];let $;e[43]!==M||e[44]!==_||e[45]!==N?($=s(ce,{footer:M,label:_,testId:"mt-db-size",value:N}),e[43]=M,e[44]=_,e[45]=N,e[46]=$):$=e[46];let q;e[47]!==a?(q=a("Shard"),e[47]=a,e[48]=q):q=e[48];let C;e[49]!==n.shard||e[50]!==q?(C=s(ce,{label:q,testId:"mt-shard",value:n.shard}),e[49]=n.shard,e[50]=q,e[51]=C):C=e[51];let k;e[52]!==a?(k=a("Uptime"),e[52]=a,e[53]=k):k=e[53];let R;e[54]!==n.uptimeMs?(R=Et(n.uptimeMs),e[54]=n.uptimeMs,e[55]=R):R=e[55];let A;e[56]!==k||e[57]!==R?(A=s(ce,{label:k,testId:"mt-uptime",value:R}),e[56]=k,e[57]=R,e[58]=A):A=e[58];let I;e[59]!==a?(I=a("Cache hit rate"),e[59]=a,e[60]=I):I=e[60];let E;e[61]!==m||e[62]!==a?(E=m?a("{rate} ({count} entries)",{count:m.entries,rate:Lt(m.hits,m.misses)}):a("no cache configured"),e[61]=m,e[62]=a,e[63]=E):E=e[63];let L;e[64]!==I||e[65]!==E?(L=s(ce,{label:I,testId:"mt-cache",value:E}),e[64]=I,e[65]=E,e[66]=L):L=e[66];let F;return e[67]!==w||e[68]!==$||e[69]!==C||e[70]!==A||e[71]!==L||e[72]!==d||e[73]!==v?(F=f("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[d,v,w,$,C,A,L]}),e[67]=w,e[68]=$,e[69]=C,e[70]=A,e[71]=L,e[72]=d,e[73]=v,e[74]=F):F=e[74],F},Ge=i=>i>=100?"critical":i>=50?"warning":"good",Le=i=>i<1?`${(i*1e3).toFixed(0)}μs`:i<1e3?`${i.toFixed(1)}ms`:`${(i/1e3).toFixed(2)}s`,Ue=i=>i>=1e9?`${(i/1e9).toFixed(1)}B`:i>=1e6?`${(i/1e6).toFixed(1)}M`:i>=1e3?`${(i/1e3).toFixed(1)}K`:i.toLocaleString(),rs=i=>{const e=me(3),{level:l}=i;if(l==="critical"){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=s(et,{variant:"destructive",children:"Slow"}),e[0]=t):t=e[0],t}if(l==="warning"){let t;return e[1]===Symbol.for("react.memo_cache_sentinel")?(t=s("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning",children:"Moderate"}),e[1]=t):t=e[1],t}let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=s("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-success/10 px-2 py-0.5 text-xs font-medium text-success",children:"Fast"}),e[2]=r):r=e[2],r},ls=(i,e)=>{const l=[...i];return l.sort((r,t)=>{switch(e){case"avgTime":return t.avgDurationMs-r.avgDurationMs;case"execCount":return t.execCount-r.execCount;case"rowsRead":return t.rowsRead-r.rowsRead;default:return t.totalDurationMs-r.totalDurationMs}}),l},as=i=>{const e=me(161),{queryStats:l}=i,r=ge(),[t,o]=be("totalTime");let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=new Set,e[0]=n):n=e[0];const[a,m]=be(n);let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=q=>{q!==null&&o(q)},e[1]=p):p=e[1];const h=p;let u,d,c,x,g,v,b,S,y,w;if(e[2]!==a||e[3]!==l||e[4]!==t||e[5]!==r){c=Symbol.for("react.early_return_sentinel");e:{const q=ls(l,t);let C;e[16]!==l?(C=l.filter(is),e[16]=l,e[17]=C):C=e[17];const k=C.length;let R;e[18]!==l?(R=l.filter(ns),e[18]=l,e[19]=R):R=e[19];const A=R.length;let I;e[20]!==l?(I=l.filter(os),e[20]=l,e[21]=I):I=e[21];const E=I.length;let L;e[22]===Symbol.for("react.memo_cache_sentinel")?(L=D=>{m(ne=>{const B=new Set(ne);return B.has(D)?B.delete(D):B.add(D),B})},e[22]=L):L=e[22];const F=L;if(l.length===0){let D;e[23]!==r?(D=r("No query insights yet"),e[23]=r,e[24]=D):D=e[24];let ne;e[25]!==D?(ne=s("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:D}),e[25]=D,e[26]=ne):ne=e[26];let B;e[27]!==r?(B=r("Query insights appear once statements are executed against this shard."),e[27]=r,e[28]=B):B=e[28];let he;e[29]!==B?(he=s("p",{className:"mt-1 text-sm",children:B}),e[29]=B,e[30]=he):he=e[30];let Pe;e[31]!==ne||e[32]!==he?(Pe=s(pe,{children:s(xe,{className:"py-12",children:f("div",{className:"text-center text-muted-foreground",children:[ne,he]})})}),e[31]=ne,e[32]=he,e[33]=Pe):Pe=e[33],c=Pe;break e}b="space-y-4",S="qi-root";let de;e[34]!==r?(de=r("Critical queries"),e[34]=r,e[35]=de):de=e[35];let fe;e[36]!==de?(fe=s(Be,{className:"pb-2",children:s(Qe,{className:"text-sm font-medium",children:de})}),e[36]=de,e[37]=fe):fe=e[37];let Q;e[38]!==k?(Q=s("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:k}),e[38]=k,e[39]=Q):Q=e[39];let H;e[40]!==r?(H=r(">100ms avg execution"),e[40]=r,e[41]=H):H=e[41];let U;e[42]!==H?(U=s("p",{className:"text-xs text-muted-foreground",children:H}),e[42]=H,e[43]=U):U=e[43];let j;e[44]!==Q||e[45]!==U?(j=f(xe,{children:[Q,U]}),e[44]=Q,e[45]=U,e[46]=j):j=e[46];let V;e[47]!==fe||e[48]!==j?(V=f(pe,{children:[fe,j]}),e[47]=fe,e[48]=j,e[49]=V):V=e[49];let G;e[50]!==r?(G=r("Moderate queries"),e[50]=r,e[51]=G):G=e[51];let Y;e[52]!==G?(Y=s(Be,{className:"pb-2",children:s(Qe,{className:"text-sm font-medium",children:G})}),e[52]=G,e[53]=Y):Y=e[53];let J;e[54]!==A?(J=s("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:A}),e[54]=A,e[55]=J):J=e[55];let W;e[56]!==r?(W=r("50–100ms avg execution"),e[56]=r,e[57]=W):W=e[57];let X;e[58]!==W?(X=s("p",{className:"text-xs text-muted-foreground",children:W}),e[58]=W,e[59]=X):X=e[59];let Z;e[60]!==J||e[61]!==X?(Z=f(xe,{children:[J,X]}),e[60]=J,e[61]=X,e[62]=Z):Z=e[62];let ee;e[63]!==Y||e[64]!==Z?(ee=f(pe,{children:[Y,Z]}),e[63]=Y,e[64]=Z,e[65]=ee):ee=e[65];let te;e[66]!==r?(te=r("Fast queries"),e[66]=r,e[67]=te):te=e[67];let se;e[68]!==te?(se=s(Be,{className:"pb-2",children:s(Qe,{className:"text-sm font-medium",children:te})}),e[68]=te,e[69]=se):se=e[69];let re;e[70]!==E?(re=s("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:E}),e[70]=E,e[71]=re):re=e[71];let le;e[72]!==r?(le=r("<50ms avg execution"),e[72]=r,e[73]=le):le=e[73];let ae;e[74]!==le?(ae=s("p",{className:"text-xs text-muted-foreground",children:le}),e[74]=le,e[75]=ae):ae=e[75];let T;e[76]!==re||e[77]!==ae?(T=f(xe,{children:[re,ae]}),e[76]=re,e[77]=ae,e[78]=T):T=e[78];let O;e[79]!==se||e[80]!==T?(O=f(pe,{children:[se,T]}),e[79]=se,e[80]=T,e[81]=O):O=e[81],e[82]!==V||e[83]!==ee||e[84]!==O?(y=f("div",{className:"grid gap-4 md:grid-cols-3",children:[V,ee,O]}),e[82]=V,e[83]=ee,e[84]=O,e[85]=y):y=e[85];let z;e[86]!==r?(z=r("Query leaderboard"),e[86]=r,e[87]=z):z=e[87];let K;e[88]!==z?(K=s("h3",{className:"text-lg font-semibold",children:z}),e[88]=z,e[89]=K):K=e[89];let P;e[90]!==t||e[91]!==r?(P=r("Slow queries sorted by {sortField}",{sortField:r(t)}),e[90]=t,e[91]=r,e[92]=P):P=e[92];let ue;e[93]!==P?(ue=s("p",{className:"text-sm text-muted-foreground",children:P}),e[93]=P,e[94]=ue):ue=e[94];let ve;e[95]!==K||e[96]!==ue?(ve=f("div",{children:[K,ue]}),e[95]=K,e[96]=ue,e[97]=ve):ve=e[97];let ye;e[98]!==r?(ye=r("Sort by"),e[98]=r,e[99]=ye):ye=e[99];let Ne;e[100]!==ye?(Ne=s("span",{className:"text-sm text-muted-foreground",children:ye}),e[100]=ye,e[101]=Ne):Ne=e[101];let Se;e[102]!==r?(Se=r("Sort queries by"),e[102]=r,e[103]=Se):Se=e[103];let Oe;e[104]===Symbol.for("react.memo_cache_sentinel")?(Oe=s(Qt,{}),e[104]=Oe):Oe=e[104];let we;e[105]!==Se?(we=s(Ht,{"aria-label":Se,className:"w-[140px]","data-testid":"qi-sort",children:Oe}),e[105]=Se,e[106]=we):we=e[106];let Te;e[107]!==r?(Te=r("Total time"),e[107]=r,e[108]=Te):Te=e[108];let qe;e[109]!==Te?(qe=s(He,{value:"totalTime",children:Te}),e[109]=Te,e[110]=qe):qe=e[110];let _e;e[111]!==r?(_e=r("Avg time"),e[111]=r,e[112]=_e):_e=e[112];let Ce;e[113]!==_e?(Ce=s(He,{value:"avgTime",children:_e}),e[113]=_e,e[114]=Ce):Ce=e[114];let Re;e[115]!==r?(Re=r("Execution count"),e[115]=r,e[116]=Re):Re=e[116];let Me;e[117]!==Re?(Me=s(He,{value:"execCount",children:Re}),e[117]=Re,e[118]=Me):Me=e[118];let ke;e[119]!==r?(ke=r("Rows read"),e[119]=r,e[120]=ke):ke=e[120];let Ae;e[121]!==ke?(Ae=s(He,{value:"rowsRead",children:ke}),e[121]=ke,e[122]=Ae):Ae=e[122];let Ie;e[123]!==qe||e[124]!==Ce||e[125]!==Me||e[126]!==Ae?(Ie=f(Ut,{children:[qe,Ce,Me,Ae]}),e[123]=qe,e[124]=Ce,e[125]=Me,e[126]=Ae,e[127]=Ie):Ie=e[127];let $e;e[128]!==t||e[129]!==we||e[130]!==Ie?($e=f(jt,{onValueChange:h,value:t,children:[we,Ie]}),e[128]=t,e[129]=we,e[130]=Ie,e[131]=$e):$e=e[131];let De;e[132]!==Ne||e[133]!==$e?(De=f("div",{className:"flex items-center gap-2",children:[Ne,$e]}),e[132]=Ne,e[133]=$e,e[134]=De):De=e[134],e[135]!==ve||e[136]!==De?(w=f("div",{className:"flex items-center justify-between",children:[ve,De]}),e[135]=ve,e[136]=De,e[137]=w):w=e[137],d=pe;let Ee;e[138]!==r?(Ee=r("Statements"),e[138]=r,e[139]=Ee):Ee=e[139];let ze;e[140]!==Ee?(ze=s(Qe,{children:Ee}),e[140]=Ee,e[141]=ze):ze=e[141],v=f(Be,{children:[ze,s(Mt,{children:r("{count} tracked statements",{count:q.length})})]}),u=xe,x="space-y-2";let Ke;e[142]!==a||e[143]!==r?(Ke=D=>{const ne=D.normalizedSql,B=a.has(ne),he=Ge(D.avgDurationMs);return f("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[f("button",{"aria-expanded":B,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:()=>{F(ne)},type:"button",children:[f("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[s(rs,{level:he}),s("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:D.normalizedSql})]}),f("div",{className:"flex shrink-0 items-center gap-4",children:[f("div",{className:"text-right",children:[s("div",{className:"text-sm font-medium",children:Le(D.totalDurationMs)}),s("div",{className:"text-xs text-muted-foreground",children:r("total")})]}),f("div",{className:"text-right",children:[s("div",{className:"text-sm font-medium",children:Le(D.avgDurationMs)}),s("div",{className:"text-xs text-muted-foreground",children:r("avg")})]}),D.p95DurationMs!==void 0&&f("div",{className:"text-right",children:[s("div",{className:"text-sm font-medium",children:Le(D.p95DurationMs)}),s("div",{className:"text-xs text-muted-foreground",children:r("p95")})]}),f("div",{className:"text-right",children:[s("div",{className:"text-sm font-medium",children:Ue(D.execCount)}),s("div",{className:"text-xs text-muted-foreground",children:r("calls")})]})]})]}),B&&f("div",{className:"space-y-3 border-t bg-muted/30 p-4",children:[f("div",{children:[s("p",{className:"mb-2 text-sm font-medium",children:r("Full statement")}),s("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:D.normalizedSql})]}),f("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[D.p50DurationMs!==void 0&&f("div",{children:[s("span",{className:"text-muted-foreground",children:r("p50")}),s("span",{className:"block font-medium tabular-nums",children:Le(D.p50DurationMs)})]}),f("div",{children:[s("span",{className:"text-muted-foreground",children:r("Exec count")}),s("span",{className:"block font-medium tabular-nums",children:Ue(D.execCount)})]}),f("div",{children:[s("span",{className:"text-muted-foreground",children:r("Total time")}),s("span",{className:"block font-medium tabular-nums",children:Le(D.totalDurationMs)})]}),f("div",{children:[s("span",{className:"text-muted-foreground",children:r("Rows read")}),s("span",{className:"block font-medium tabular-nums",children:Ue(D.rowsRead)})]}),f("div",{children:[s("span",{className:"text-muted-foreground",children:r("Rows written")}),s("span",{className:"block font-medium tabular-nums",children:Ue(D.rowsWritten)})]})]})]})]},ne)},e[142]=a,e[143]=r,e[144]=Ke):Ke=e[144],g=q.map(Ke)}e[2]=a,e[3]=l,e[4]=t,e[5]=r,e[6]=u,e[7]=d,e[8]=c,e[9]=x,e[10]=g,e[11]=v,e[12]=b,e[13]=S,e[14]=y,e[15]=w}else u=e[6],d=e[7],c=e[8],x=e[9],g=e[10],v=e[11],b=e[12],S=e[13],y=e[14],w=e[15];if(c!==Symbol.for("react.early_return_sentinel"))return c;let M;e[145]!==x||e[146]!==g?(M=s("div",{className:x,children:g}),e[145]=x,e[146]=g,e[147]=M):M=e[147];let _;e[148]!==u||e[149]!==M?(_=s(u,{children:M}),e[148]=u,e[149]=M,e[150]=_):_=e[150];let N;e[151]!==d||e[152]!==_||e[153]!==v?(N=f(d,{children:[v,_]}),e[151]=d,e[152]=_,e[153]=v,e[154]=N):N=e[154];let $;return e[155]!==N||e[156]!==b||e[157]!==S||e[158]!==y||e[159]!==w?($=f("div",{className:b,"data-testid":S,children:[y,w,N]}),e[155]=N,e[156]=b,e[157]=S,e[158]=y,e[159]=w,e[160]=$):$=e[160],$};function is(i){return Ge(i.avgDurationMs)==="critical"}function ns(i){return Ge(i.avgDurationMs)==="warning"}function os(i){return Ge(i.avgDurationMs)==="good"}const cs=["1m","5m","15m","1h"],ds=i=>new Date(i).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),ms=i=>i.map(e=>({avg:Math.round(e.avgDurationMs*100)/100,execs:e.execCount,label:ds(e.bucketMs)})),fs=({shardKey:i=""})=>{const e=ge(),[l,r]=be("15m"),o=je(Fe.getQueryInsights,{range:l},{live:!0,shardKey:i}).data,n=ms(o?.buckets??[]);return f("div",{className:"flex flex-col gap-4","data-testid":"qi-range",children:[f("div",{className:"flex flex-wrap items-center gap-2",children:[s("div",{className:"flex gap-1 rounded-lg border border-border p-0.5","data-testid":"qi-ranges",role:"group",children:cs.map(a=>s("button",{"aria-pressed":a===l,className:Bt("rounded px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",a===l&&"bg-accent font-medium text-foreground"),"data-testid":`qi-range-${a}`,onClick:()=>{r(a)},type:"button",children:a},a))}),o?.capped===!0&&s(et,{"data-testid":"qi-capped",variant:"secondary",children:e("showing a capped set")})]}),n.length===0?s(Pt,{description:e("Statements executed in the selected window appear here, with throughput and latency over time."),testId:"qi-empty",title:e("No queries in this window.")}):f("div",{className:"grid gap-4 lg:grid-cols-2",children:[f("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-throughput",children:[s("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Throughput")}),s(rt,{height:140,width:"100%",children:f(Ft,{data:n,children:[s(lt,{strokeDasharray:"3 3",vertical:!1}),s(at,{dataKey:"label",fontSize:10,tickLine:!1}),s(it,{allowDecimals:!1,fontSize:10,tickLine:!1,width:32}),s(nt,{}),s(Ot,{dataKey:"execs",fill:"var(--color-primary)",fillOpacity:.15,stroke:"var(--color-primary)",type:"monotone"})]})})]}),f("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-latency",children:[s("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Mean latency (ms)")}),s(rt,{height:140,width:"100%",children:f(zt,{data:n,children:[s(lt,{strokeDasharray:"3 3",vertical:!1}),s(at,{dataKey:"label",fontSize:10,tickLine:!1}),s(it,{fontSize:10,tickLine:!1,width:32}),s(nt,{}),s(Kt,{dataKey:"avg",dot:!1,stroke:"var(--color-destructive)",type:"monotone"})]})})]})]}),s(as,{queryStats:o?.entries??[]})]})},us=qt(Fe.getMetrics),hs=[],gs=(i,e)=>i?e:"overview",ps=i=>{const e=me(14);let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={},e[0]=l):l=e[0];let r;e[1]!==i?(r={live:!0,shardKey:i},e[1]=i,e[2]=r):r=e[2];const t=je(Fe.getMetrics,l,r),{data:o}=t;let n;e[3]===Symbol.for("react.memo_cache_sentinel")?(n={points:[],shard:null},e[3]=n):n=e[3];const[a,m]=be(n),p=Je(null),h=Je(null);let u,d;e[4]!==o||e[5]!==i?(u=()=>{o!==void 0&&Ct(i)},d=[o,i],e[4]=o,e[5]=i,e[6]=u,e[7]=d):(u=e[6],d=e[7]),We(u,d);let c,x;e[8]!==o?(c=()=>{if(o===void 0)return;const b=o,S=h.current!==null&&h.current!==b.shard,y=h.current===b.shard?p.current:null;if(h.current=b.shard,p.current=b.requests,S){m({points:[],shard:b.shard});return}y!==null&&b.requests>=y&&m(w=>({points:[...w.shard===b.shard?w.points:[],b.requests-y].slice(-30),shard:b.shard}))},x=[o],e[8]=o,e[9]=c,e[10]=x):(c=e[9],x=e[10]),We(c,x);const g=a.shard!==null&&a.shard===o?.shard?a.points:hs;let v;return e[11]!==t||e[12]!==g?(v={...t,history:g},e[11]=t,e[12]=g,e[13]=v):v=e[13],v},xs=i=>{const e=vt(),l=Je(!0);We(()=>(l.current=!0,()=>{l.current=!1}),[]);const[r,t]=be(null),[o,n]=be(!1),a=async()=>{n(!0);const p=i,h=$t(p,_t());try{const u=await Promise.all(h.map(async d=>{try{const c=await e.query(us,{},wt(d));return{error:null,metrics:c,shard:d===""?c.shard:d}}catch(c){return{error:Tt(c),metrics:null,shard:d===""?"__root__":d}}}));l.current&&t({results:u,shard:p})}finally{l.current&&n(!1)}},m=r?.shard===i?r.results:null;return{aggregate:m===null?null:At(m),aggregating:o,clearAggregate:()=>{t(null)},runAggregate:()=>{St(a())},shardResults:m}},bs=i=>{if(!i||!("queryStats"in i))return;const e=i.queryStats;if(!(!e||!Array.isArray(e)))return It(e)},ot=i=>`pb-2 text-sm font-medium transition-colors ${i?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,vs=i=>{const e=me(26),{activeTab:l,onSelect:r,queryCount:t}=i,o=ge();let n;e[0]!==r?(n=()=>{r("overview")},e[0]=r,e[1]=n):n=e[1];const a=n;let m;e[2]!==r?(m=()=>{r("query-insights")},e[2]=r,e[3]=m):m=e[3];const p=m,h=l==="overview";let u;e[4]!==h?(u=ot(h),e[4]=h,e[5]=u):u=e[5];let d;e[6]!==o?(d=o("Overview"),e[6]=o,e[7]=d):d=e[7];let c;e[8]!==a||e[9]!==u||e[10]!==d?(c=s("button",{className:u,"data-testid":"mt-tab-overview",onClick:a,type:"button",children:d}),e[8]=a,e[9]=u,e[10]=d,e[11]=c):c=e[11];const x=l==="query-insights";let g;e[12]!==x?(g=ot(x),e[12]=x,e[13]=g):g=e[13];let v;e[14]!==o?(v=o("Query insights"),e[14]=o,e[15]=v):v=e[15];let b;e[16]!==t?(b=t>0&&s("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:t}),e[16]=t,e[17]=b):b=e[17];let S;e[18]!==p||e[19]!==b||e[20]!==g||e[21]!==v?(S=f("button",{className:g,"data-testid":"mt-tab-query-insights",onClick:p,type:"button",children:[v,b]}),e[18]=p,e[19]=b,e[20]=g,e[21]=v,e[22]=S):S=e[22];let y;return e[23]!==S||e[24]!==c?(y=f("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[c,S]}),e[23]=S,e[24]=c,e[25]=y):y=e[25],y},ys=i=>{const e=me(13),{history:l,metrics:r}=i;let t;e[0]!==l?(t=l.at(-1)??0,e[0]=l,e[1]=t):t=e[1];let o;e[2]!==r.errors||e[3]!==r.requests?(o=r.requests===0?"—":`${(r.errors/r.requests*100).toFixed(1)}%`,e[2]=r.errors,e[3]=r.requests,e[4]=o):o=e[4];let n;e[5]!==r?(n=Dt(r),e[5]=r,e[6]=n):n=e[6];let a;return e[7]!==l||e[8]!==r||e[9]!==t||e[10]!==o||e[11]!==n?(a=s(ss,{currentDelta:t,errorRate:o,history:l,latencyPercentiles:n,metrics:r}),e[7]=l,e[8]=r,e[9]=t,e[10]=o,e[11]=n,e[12]=a):a=e[12],a},Ns=i=>{const e=me(25),{aggregating:l,liveError:r,onAggregate:t,onClearAggregate:o,onShardKeyChange:n,shardKey:a}=i,m=ge();let p;e[0]!==n||e[1]!==a?(p=s(pt,{onChange:n,testId:"mt-shard-input",value:a}),e[0]=n,e[1]=a,e[2]=p):p=e[2];let h;e[3]!==r?(h=s(gt,{message:r,prefix:"mt"}),e[3]=r,e[4]=h):h=e[4];let u;e[5]!==l||e[6]!==m?(u=m(l?"Aggregating…":"All shards"),e[5]=l,e[6]=m,e[7]=u):u=e[7];let d;e[8]!==l||e[9]!==t||e[10]!==u?(d=s(tt,{"data-testid":"mt-aggregate",disabled:l,onClick:t,size:"sm",type:"button",variant:"secondary",children:u}),e[8]=l,e[9]=t,e[10]=u,e[11]=d):d=e[11];let c;e[12]!==o||e[13]!==m?(c=o!==void 0&&s(tt,{"data-testid":"mt-aggregate-clear",onClick:o,size:"sm",type:"button",variant:"ghost",children:m("Hide")}),e[12]=o,e[13]=m,e[14]=c):c=e[14];let x;e[15]!==m?(x=m("Open in Cloudflare"),e[15]=m,e[16]=x):x=e[16];let g;e[17]!==x?(g=s("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:yt,rel:"noreferrer",target:"_blank",children:x}),e[17]=x,e[18]=g):g=e[18];let v;return e[19]!==p||e[20]!==h||e[21]!==d||e[22]!==c||e[23]!==g?(v=f("div",{className:"flex flex-wrap items-center gap-2",children:[p,h,d,c,g]}),e[19]=p,e[20]=h,e[21]=d,e[22]=c,e[23]=g,e[24]=v):v=e[24],v},Js=i=>{const e=me(41),{initialShardKey:l}=i,{queryShardKey:r,setShardKey:t,shardKey:o}=bt(l),[n,a]=be("overview"),m=xt(r),{data:p,error:h,history:u,liveError:d}=ps(r),c=p??null,{aggregate:x,aggregating:g,clearAggregate:v,runAggregate:b,shardResults:S}=xs(o);let y;e[0]!==c?(y=bs(c),e[0]=c,e[1]=y):y=e[1];const w=y,M=w!==void 0;let _;e[2]!==n||e[3]!==M?(_=gs(M,n),e[2]=n,e[3]=M,e[4]=_):_=e[4];const N=_,$=S===null?void 0:v;let q;e[5]!==g||e[6]!==d||e[7]!==b||e[8]!==t||e[9]!==o||e[10]!==$?(q=s(Ns,{aggregating:g,liveError:d,onAggregate:b,onClearAggregate:$,onShardKeyChange:t,shardKey:o}),e[5]=g,e[6]=d,e[7]=b,e[8]=t,e[9]=o,e[10]=$,e[11]=q):q=e[11];let C;e[12]!==h?(C=h!==null&&s("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:h}),e[12]=h,e[13]=C):C=e[13];let k;e[14]!==N||e[15]!==w?(k=w!==void 0&&s(vs,{activeTab:N,onSelect:a,queryCount:w.length}),e[14]=N,e[15]=w,e[16]=k):k=e[16];let R;e[17]!==N||e[18]!==r||e[19]!==w?(R=N==="query-insights"&&w!==void 0&&s(fs,{shardKey:r}),e[17]=N,e[18]=r,e[19]=w,e[20]=R):R=e[20];let A;e[21]!==N||e[22]!==u||e[23]!==c?(A=N==="overview"&&c!==null&&s(ys,{history:u,metrics:c}),e[21]=N,e[22]=u,e[23]=c,e[24]=A):A=e[24];let I;e[25]!==N||e[26]!==m||e[27]!==r?(I=N==="overview"&&s(es,{onOpenTrace:m,shardKey:r}),e[25]=N,e[26]=m,e[27]=r,e[28]=I):I=e[28];let E;e[29]!==x||e[30]!==N||e[31]!==S?(E=N==="overview"&&x!==null&&S!==null&&s(ts,{aggregate:x,shardResults:S}),e[29]=x,e[30]=N,e[31]=S,e[32]=E):E=e[32];let L;return e[33]!==I||e[34]!==E||e[35]!==q||e[36]!==C||e[37]!==k||e[38]!==R||e[39]!==A?(L=f("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[q,C,k,R,A,I,E]}),e[33]=I,e[34]=E,e[35]=q,e[36]=C,e[37]=k,e[38]=R,e[39]=A,e[40]=L):L=e[40],L};export{Js as MetricsPanel};
1
+ import{c as me}from"react/compiler-runtime";import{useState as be,useRef as Je,useEffect as We}from"react";import{L as gt}from"../packem_shared/live-status-D1GasNsH.mjs";import{ShardInput as pt}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{B as tt}from"../packem_shared/button-q0UYSmrn.mjs";import{u as je}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{u as xt}from"../packem_shared/use-open-trace-B_0LbTD7.mjs";import{u as bt}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{u as vt}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as ge}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as Fe}from"../packem_shared/ADMIN_FUNCTIONS-4aGsMs95.mjs";import{c as yt}from"../packem_shared/cf-links-CBJ5SywP.mjs";import{j as Nt,n as Xe,f as St,d as wt,b as Tt,c as qt}from"../packem_shared/internal-BXEjuLPN.mjs";import{l as _t,r as Ct}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{f as Rt}from"../packem_shared/log-fields-BolUoZ9g.mjs";import{B as et}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as pe,a as xe,b as Be,d as Mt,c as Qe}from"../packem_shared/card-By2O8ULa.mjs";import{b as Ve,e as ie,T as ct,c as oe,a as dt,d as mt}from"../packem_shared/table-D0SBiDu-.mjs";import{stableStringify as kt}from"@lunora/wire";import{S as ft}from"../packem_shared/sparkline-B_sPPO_8.mjs";import{jsxs as f,jsx as s,Fragment as Ze}from"react/jsx-runtime";import{aggregateMetrics as At,enrichQueryStats as It,shardsToAggregate as $t,computeLatencyPercentiles as Dt}from"../packem_shared/aggregateMetrics-DKFJc-o5.mjs";import{S as ce}from"../packem_shared/stat-card-BAv73QtB.mjs";import{b as st,c as Et,h as Lt}from"../packem_shared/metrics-format-1sNGG47R.mjs";import{ResponsiveContainer as rt,AreaChart as Ft,CartesianGrid as lt,XAxis as at,YAxis as it,Tooltip as nt,Area as Ot,LineChart as zt,Line as Kt}from"recharts";import{E as Pt}from"../packem_shared/empty-state-D7jEML_T.mjs";import{c as Bt}from"../packem_shared/utils-bhneXptQ.mjs";import{S as Qt,a as Ht,c as He,b as Ut,d as jt}from"../packem_shared/select-DPyS18Vy.mjs";const ut=(i,e,l)=>`${i}:${e}:${kt(l??{})}`,ht=(i,e)=>i==="gauge"?e.last:i==="histogram"?e.sum/Math.max(1,e.count):e.sum,Vt=(i,e)=>ht(i,e),Gt=i=>ht(i.kind,i),Ye=i=>Number.isInteger(i)?i.toLocaleString():i.toLocaleString(void 0,{maximumFractionDigits:2}),Yt=i=>Array.isArray(i?.series)?i.series:[],Jt="FUNCTION_NOT_FOUND",Wt=i=>{const e=new Map;if(!Array.isArray(i?.series))return e;for(const l of i.series)e.set(ut(l.kind,l.name,l.attributes),l.points);return e},Xt={counter:"secondary",gauge:"default",histogram:"outline"},Zt=i=>{const e=me(18),{name:l,onOpenTrace:r,traceId:t}=i,o=ge();if(t===void 0){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=s("span",{className:"text-muted-foreground",children:"—"}),e[0]=d):d=e[0],d}let n;e[1]!==t?(n=t.slice(0,8),e[1]=t,e[2]=n):n=e[2];const a=n;if(r===void 0){const d=`mt-instrument-trace-${l}`;let c;return e[3]!==a||e[4]!==d||e[5]!==t?(c=s("span",{className:"text-muted-foreground","data-testid":d,title:t,children:a}),e[3]=a,e[4]=d,e[5]=t,e[6]=c):c=e[6],c}const m=`mt-instrument-trace-${l}`;let p;e[7]!==r||e[8]!==t?(p=()=>{r(t)},e[7]=r,e[8]=t,e[9]=p):p=e[9];let h;e[10]!==o||e[11]!==t?(h=o("Open the exemplar trace {trace}",{trace:t}),e[10]=o,e[11]=t,e[12]=h):h=e[12];let u;return e[13]!==a||e[14]!==m||e[15]!==p||e[16]!==h?(u=s("button",{className:"text-primary underline-offset-4 hover:underline","data-testid":m,onClick:p,title:h,type:"button",children:a}),e[13]=a,e[14]=m,e[15]=p,e[16]=h,e[17]=u):u=e[17],u},es=i=>{const e=me(105),{onOpenTrace:l,shardKey:r}=i,t=ge();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={},e[0]=o):o=e[0];let n;e[1]!==r?(n={live:!0,shardKey:r},e[1]=r,e[2]=n):n=e[2];const{data:a,error:m,errorSource:p}=je(Fe.getMetricSeries,o,n);let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h={},e[3]=h):h=e[3];let u;e[4]!==r?(u={live:!0,shardKey:r},e[4]=r,e[5]=u):u=e[5];const{data:d}=je(Fe.getMetricHistory,h,u);let c,x,g,v,b,S,y,w,M,_,N,$,q;if(e[6]!==a||e[7]!==m||e[8]!==p||e[9]!==d||e[10]!==l||e[11]!==t){w=Symbol.for("react.early_return_sentinel");e:{const E=Yt(a),L=Nt(p)===Jt;if(m!==null&&!L){let T;e[25]!==t?(T=t("Instruments"),e[25]=t,e[26]=T):T=e[26];let O;e[27]!==T?(O=s("h3",{className:"text-sm font-semibold text-foreground",children:T}),e[27]=T,e[28]=O):O=e[28];let z;e[29]!==m||e[30]!==t?(z=t("Instruments unavailable: {error}",{error:m}),e[29]=m,e[30]=t,e[31]=z):z=e[31];let K;e[32]!==z?(K=s("span",{className:"text-xs text-muted-foreground","data-testid":"mt-instruments-error",role:"status",children:z}),e[32]=z,e[33]=K):K=e[33];let P;e[34]!==O||e[35]!==K?(P=f("section",{className:"flex flex-col gap-2","data-testid":"mt-instruments",children:[O,K]}),e[34]=O,e[35]=K,e[36]=P):P=e[36],w=P;break e}if(E.length===0){w=null;break e}const F=Wt(d);let de;e[37]!==t?(de=T=>t(T==="counter"?"Counter":T==="gauge"?"Gauge":"Histogram"),e[37]=t,e[38]=de):de=e[38];const fe=de;b="flex flex-col gap-2",S="mt-instruments";let Q;e[39]!==t?(Q=t("Instruments"),e[39]=t,e[40]=Q):Q=e[40],e[41]!==Q?(y=s("h3",{className:"text-sm font-semibold text-foreground",children:Q}),e[41]=Q,e[42]=y):y=e[42],v=pe,q="overflow-hidden py-0",g=xe,$="px-0",x=ct,_="mt-instruments-table";let H;e[43]!==t?(H=t("name"),e[43]=t,e[44]=H):H=e[44];let U;e[45]!==H?(U=s(oe,{children:H}),e[45]=H,e[46]=U):U=e[46];let j;e[47]!==t?(j=t("kind"),e[47]=t,e[48]=j):j=e[48];let V;e[49]!==j?(V=s(oe,{children:j}),e[49]=j,e[50]=V):V=e[50];let G;e[51]!==t?(G=t("value"),e[51]=t,e[52]=G):G=e[52];let Y;e[53]!==G?(Y=s(oe,{className:"text-right",children:G}),e[53]=G,e[54]=Y):Y=e[54];let J;e[55]!==t?(J=t("count"),e[55]=t,e[56]=J):J=e[56];let W;e[57]!==J?(W=s(oe,{className:"text-right",children:J}),e[57]=J,e[58]=W):W=e[58];let X;e[59]!==t?(X=t("range"),e[59]=t,e[60]=X):X=e[60];let Z;e[61]!==X?(Z=s(oe,{className:"text-right",children:X}),e[61]=X,e[62]=Z):Z=e[62];let ee;e[63]!==t?(ee=t("trend"),e[63]=t,e[64]=ee):ee=e[64];let te;e[65]!==ee?(te=s(oe,{children:ee}),e[65]=ee,e[66]=te):te=e[66];let se;e[67]!==t?(se=t("trace"),e[67]=t,e[68]=se):se=e[68];let re;e[69]!==se?(re=s(oe,{children:se}),e[69]=se,e[70]=re):re=e[70];let le;e[71]!==t?(le=t("dimensions"),e[71]=t,e[72]=le):le=e[72];let ae;e[73]!==le?(ae=s(oe,{children:le}),e[73]=le,e[74]=ae):ae=e[74],e[75]!==U||e[76]!==V||e[77]!==Y||e[78]!==W||e[79]!==Z||e[80]!==te||e[81]!==re||e[82]!==ae?(N=s(dt,{children:f(Ve,{children:[U,V,Y,W,Z,te,re,ae]})}),e[75]=U,e[76]=V,e[77]=Y,e[78]=W,e[79]=Z,e[80]=te,e[81]=re,e[82]=ae,e[83]=N):N=e[83],c=mt,M=E.map(T=>{const O=Rt(T.attributes),z=ut(T.kind,T.name,T.attributes),P=(F.get(z)??[]).map(ue=>Vt(T.kind,ue));return f(Ve,{"data-testid":`mt-instrument-${T.name}`,children:[s(ie,{className:"font-mono text-xs",title:T.functionPath,children:T.name}),s(ie,{children:s(et,{variant:Xt[T.kind],children:fe(T.kind)})}),s(ie,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${T.name}`,children:Ye(Gt(T))}),s(ie,{className:"text-right tabular-nums text-muted-foreground",children:T.count.toLocaleString()}),s(ie,{className:"text-right font-mono text-xs tabular-nums text-muted-foreground",children:T.min===T.max?"—":`${Ye(T.min)}–${Ye(T.max)}`}),s(ie,{children:P.length>=2?s(ft,{ariaLabel:t("{name} trend",{name:T.name}),className:"h-6 w-24 text-foreground",series:P,testId:`mt-instrument-trend-${T.name}`}):s("span",{className:"text-xs text-muted-foreground",children:"—"})}),s(ie,{className:"font-mono text-xs",children:s(Zt,{name:T.name,onOpenTrace:l,traceId:T.exemplarTraceId})}),s(ie,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:O,children:O===""?"—":O})]},z)})}e[6]=a,e[7]=m,e[8]=p,e[9]=d,e[10]=l,e[11]=t,e[12]=c,e[13]=x,e[14]=g,e[15]=v,e[16]=b,e[17]=S,e[18]=y,e[19]=w,e[20]=M,e[21]=_,e[22]=N,e[23]=$,e[24]=q}else c=e[12],x=e[13],g=e[14],v=e[15],b=e[16],S=e[17],y=e[18],w=e[19],M=e[20],_=e[21],N=e[22],$=e[23],q=e[24];if(w!==Symbol.for("react.early_return_sentinel"))return w;let C;e[84]!==c||e[85]!==M?(C=s(c,{children:M}),e[84]=c,e[85]=M,e[86]=C):C=e[86];let k;e[87]!==x||e[88]!==C||e[89]!==_||e[90]!==N?(k=f(x,{"data-testid":_,children:[N,C]}),e[87]=x,e[88]=C,e[89]=_,e[90]=N,e[91]=k):k=e[91];let R;e[92]!==g||e[93]!==k||e[94]!==$?(R=s(g,{className:$,children:k}),e[92]=g,e[93]=k,e[94]=$,e[95]=R):R=e[95];let A;e[96]!==v||e[97]!==R||e[98]!==q?(A=s(v,{className:q,children:R}),e[96]=v,e[97]=R,e[98]=q,e[99]=A):A=e[99];let I;return e[100]!==b||e[101]!==S||e[102]!==y||e[103]!==A?(I=f("section",{className:b,"data-testid":S,children:[y,A]}),e[100]=b,e[101]=S,e[102]=y,e[103]=A,e[104]=I):I=e[104],I},ts=i=>{const e=me(74),{aggregate:l,shardResults:r}=i,t=ge();let o;e[0]!==t?(o=t("Shards"),e[0]=t,e[1]=o):o=e[1];let n;e[2]!==l.failed||e[3]!==l.reachable||e[4]!==t?(n=l.failed>0?t("{reachable} reachable, {failed} unreachable",{failed:l.failed,reachable:l.reachable}):t("{reachable} reachable",{reachable:l.reachable}),e[2]=l.failed,e[3]=l.reachable,e[4]=t,e[5]=n):n=e[5];let a;e[6]!==o||e[7]!==n?(a=s(ce,{label:o,testId:"mt-agg-shards",value:n}),e[6]=o,e[7]=n,e[8]=a):a=e[8];let m;e[9]!==t?(m=t("Total requests"),e[9]=t,e[10]=m):m=e[10];let p;e[11]!==l.totalRequests||e[12]!==m?(p=s(ce,{label:m,testId:"mt-agg-requests",value:l.totalRequests}),e[11]=l.totalRequests,e[12]=m,e[13]=p):p=e[13];let h;e[14]!==t?(h=t("Total errors"),e[14]=t,e[15]=h):h=e[15];let u;e[16]!==l.totalErrors||e[17]!==h?(u=s(ce,{label:h,testId:"mt-agg-errors",value:l.totalErrors}),e[16]=l.totalErrors,e[17]=h,e[18]=u):u=e[18];let d;e[19]!==t?(d=t("Total database size"),e[19]=t,e[20]=d):d=e[20];let c;e[21]!==l.totalDatabaseSize?(c=Xe(l.totalDatabaseSize),e[21]=l.totalDatabaseSize,e[22]=c):c=e[22];let x;e[23]!==d||e[24]!==c?(x=s(ce,{label:d,testId:"mt-agg-db-size",value:c}),e[23]=d,e[24]=c,e[25]=x):x=e[25];let g;e[26]!==t?(g=t("Combined cache hit rate"),e[26]=t,e[27]=g):g=e[27];let v;e[28]!==l.hitRate||e[29]!==t?(v=l.hitRate===null?t("no cache configured"):`${(l.hitRate*100).toFixed(1)}%`,e[28]=l.hitRate,e[29]=t,e[30]=v):v=e[30];let b;e[31]!==g||e[32]!==v?(b=s(ce,{label:g,testId:"mt-agg-cache",value:v}),e[31]=g,e[32]=v,e[33]=b):b=e[33];let S;e[34]!==x||e[35]!==b||e[36]!==a||e[37]!==p||e[38]!==u?(S=f("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[a,p,u,x,b]}),e[34]=x,e[35]=b,e[36]=a,e[37]=p,e[38]=u,e[39]=S):S=e[39];let y;e[40]!==t?(y=t("shard"),e[40]=t,e[41]=y):y=e[41];let w;e[42]!==y?(w=s(oe,{children:y}),e[42]=y,e[43]=w):w=e[43];let M;e[44]!==t?(M=t("requests"),e[44]=t,e[45]=M):M=e[45];let _;e[46]!==M?(_=s(oe,{children:M}),e[46]=M,e[47]=_):_=e[47];let N;e[48]!==t?(N=t("errors"),e[48]=t,e[49]=N):N=e[49];let $;e[50]!==N?($=s(oe,{children:N}),e[50]=N,e[51]=$):$=e[51];let q;e[52]!==t?(q=t("db size"),e[52]=t,e[53]=q):q=e[53];let C;e[54]!==q?(C=s(oe,{children:q}),e[54]=q,e[55]=C):C=e[55];let k;e[56]!==w||e[57]!==_||e[58]!==$||e[59]!==C?(k=s(dt,{children:f(Ve,{children:[w,_,$,C]})}),e[56]=w,e[57]=_,e[58]=$,e[59]=C,e[60]=k):k=e[60];let R;if(e[61]!==r||e[62]!==t){let L;e[64]!==t?(L=F=>f(Ve,{"data-testid":`mt-agg-row-${F.shard}`,children:[s(ie,{children:F.shard}),F.metrics===null?s(ie,{className:"text-destructive",colSpan:3,children:F.error??t("unreachable")}):f(Ze,{children:[s(ie,{className:"tabular-nums",children:F.metrics.requests}),s(ie,{className:"tabular-nums",children:F.metrics.errors}),s(ie,{className:"tabular-nums",children:Xe(F.metrics.databaseSize)})]})]},F.shard),e[64]=t,e[65]=L):L=e[65],R=r.map(L),e[61]=r,e[62]=t,e[63]=R}else R=e[63];let A;e[66]!==R?(A=s(mt,{children:R}),e[66]=R,e[67]=A):A=e[67];let I;e[68]!==k||e[69]!==A?(I=s(pe,{className:"overflow-hidden py-0",children:s(xe,{className:"px-0",children:f(ct,{"data-testid":"mt-agg-table",children:[k,A]})})}),e[68]=k,e[69]=A,e[70]=I):I=e[70];let E;return e[71]!==S||e[72]!==I?(E=f("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[S,I]}),e[71]=S,e[72]=I,e[73]=E):E=e[73],E},ss=i=>{const e=me(75),{currentDelta:l,errorRate:r,history:t,latencyPercentiles:o,metrics:n}=i,a=ge(),{cache:m}=n;let p;e[0]!==t||e[1]!==a?(p=t.length>=2?s(ft,{ariaLabel:a("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:t,testId:"mt-sparkline"}):void 0,e[0]=t,e[1]=a,e[2]=p):p=e[2];let h;e[3]!==l||e[4]!==t.length||e[5]!==a?(h=t.length>=2?f(Ze,{children:[s("span",{className:"font-semibold text-foreground",children:`+${l.toLocaleString()}`})," ",a("last interval")]}):s("span",{"data-testid":"mt-sparkline-empty",children:a("collecting samples…")}),e[3]=l,e[4]=t.length,e[5]=a,e[6]=h):h=e[6];let u;e[7]!==a?(u=a("Requests"),e[7]=a,e[8]=u):u=e[8];let d;e[9]!==n.requests||e[10]!==p||e[11]!==h||e[12]!==u?(d=s(ce,{chart:p,footer:h,label:u,testId:"mt-requests",value:n.requests}),e[9]=n.requests,e[10]=p,e[11]=h,e[12]=u,e[13]=d):d=e[13];let c;e[14]!==r||e[15]!==a?(c=a("{rate} error rate",{rate:r}),e[14]=r,e[15]=a,e[16]=c):c=e[16];let x;e[17]!==a?(x=a("Errors"),e[17]=a,e[18]=x):x=e[18];let g;e[19]!==r||e[20]!==n.errors?(g=f(Ze,{children:[n.errors," (",r,")"]}),e[19]=r,e[20]=n.errors,e[21]=g):g=e[21];let v;e[22]!==c||e[23]!==x||e[24]!==g?(v=s(ce,{footer:c,label:x,testId:"mt-errors",value:g}),e[22]=c,e[23]=x,e[24]=g,e[25]=v):v=e[25];let b;e[26]!==o.p90?(b=o.p90>0?`P90 ${st(o.p90)}`:void 0,e[26]=o.p90,e[27]=b):b=e[27];let S;e[28]!==a?(S=a("P95 latency"),e[28]=a,e[29]=S):S=e[29];let y;e[30]!==o.p95?(y=o.p95>0?st(o.p95):"—",e[30]=o.p95,e[31]=y):y=e[31];let w;e[32]!==S||e[33]!==y||e[34]!==b?(w=s(ce,{footer:b,label:S,testId:"mt-p95",value:y}),e[32]=S,e[33]=y,e[34]=b,e[35]=w):w=e[35];let M;e[36]!==m||e[37]!==a?(M=m?`${m.entries.toLocaleString()} ${a("cache entries")}`:void 0,e[36]=m,e[37]=a,e[38]=M):M=e[38];let _;e[39]!==a?(_=a("Database size"),e[39]=a,e[40]=_):_=e[40];let N;e[41]!==n.databaseSize?(N=Xe(n.databaseSize),e[41]=n.databaseSize,e[42]=N):N=e[42];let $;e[43]!==M||e[44]!==_||e[45]!==N?($=s(ce,{footer:M,label:_,testId:"mt-db-size",value:N}),e[43]=M,e[44]=_,e[45]=N,e[46]=$):$=e[46];let q;e[47]!==a?(q=a("Shard"),e[47]=a,e[48]=q):q=e[48];let C;e[49]!==n.shard||e[50]!==q?(C=s(ce,{label:q,testId:"mt-shard",value:n.shard}),e[49]=n.shard,e[50]=q,e[51]=C):C=e[51];let k;e[52]!==a?(k=a("Uptime"),e[52]=a,e[53]=k):k=e[53];let R;e[54]!==n.uptimeMs?(R=Et(n.uptimeMs),e[54]=n.uptimeMs,e[55]=R):R=e[55];let A;e[56]!==k||e[57]!==R?(A=s(ce,{label:k,testId:"mt-uptime",value:R}),e[56]=k,e[57]=R,e[58]=A):A=e[58];let I;e[59]!==a?(I=a("Cache hit rate"),e[59]=a,e[60]=I):I=e[60];let E;e[61]!==m||e[62]!==a?(E=m?a("{rate} ({count} entries)",{count:m.entries,rate:Lt(m.hits,m.misses)}):a("no cache configured"),e[61]=m,e[62]=a,e[63]=E):E=e[63];let L;e[64]!==I||e[65]!==E?(L=s(ce,{label:I,testId:"mt-cache",value:E}),e[64]=I,e[65]=E,e[66]=L):L=e[66];let F;return e[67]!==w||e[68]!==$||e[69]!==C||e[70]!==A||e[71]!==L||e[72]!==d||e[73]!==v?(F=f("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[d,v,w,$,C,A,L]}),e[67]=w,e[68]=$,e[69]=C,e[70]=A,e[71]=L,e[72]=d,e[73]=v,e[74]=F):F=e[74],F},Ge=i=>i>=100?"critical":i>=50?"warning":"good",Le=i=>i<1?`${(i*1e3).toFixed(0)}μs`:i<1e3?`${i.toFixed(1)}ms`:`${(i/1e3).toFixed(2)}s`,Ue=i=>i>=1e9?`${(i/1e9).toFixed(1)}B`:i>=1e6?`${(i/1e6).toFixed(1)}M`:i>=1e3?`${(i/1e3).toFixed(1)}K`:i.toLocaleString(),rs=i=>{const e=me(3),{level:l}=i;if(l==="critical"){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=s(et,{variant:"destructive",children:"Slow"}),e[0]=t):t=e[0],t}if(l==="warning"){let t;return e[1]===Symbol.for("react.memo_cache_sentinel")?(t=s("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning",children:"Moderate"}),e[1]=t):t=e[1],t}let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=s("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-success/10 px-2 py-0.5 text-xs font-medium text-success",children:"Fast"}),e[2]=r):r=e[2],r},ls=(i,e)=>{const l=[...i];return l.sort((r,t)=>{switch(e){case"avgTime":return t.avgDurationMs-r.avgDurationMs;case"execCount":return t.execCount-r.execCount;case"rowsRead":return t.rowsRead-r.rowsRead;default:return t.totalDurationMs-r.totalDurationMs}}),l},as=i=>{const e=me(161),{queryStats:l}=i,r=ge(),[t,o]=be("totalTime");let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=new Set,e[0]=n):n=e[0];const[a,m]=be(n);let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=q=>{q!==null&&o(q)},e[1]=p):p=e[1];const h=p;let u,d,c,x,g,v,b,S,y,w;if(e[2]!==a||e[3]!==l||e[4]!==t||e[5]!==r){c=Symbol.for("react.early_return_sentinel");e:{const q=ls(l,t);let C;e[16]!==l?(C=l.filter(is),e[16]=l,e[17]=C):C=e[17];const k=C.length;let R;e[18]!==l?(R=l.filter(ns),e[18]=l,e[19]=R):R=e[19];const A=R.length;let I;e[20]!==l?(I=l.filter(os),e[20]=l,e[21]=I):I=e[21];const E=I.length;let L;e[22]===Symbol.for("react.memo_cache_sentinel")?(L=D=>{m(ne=>{const B=new Set(ne);return B.has(D)?B.delete(D):B.add(D),B})},e[22]=L):L=e[22];const F=L;if(l.length===0){let D;e[23]!==r?(D=r("No query insights yet"),e[23]=r,e[24]=D):D=e[24];let ne;e[25]!==D?(ne=s("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:D}),e[25]=D,e[26]=ne):ne=e[26];let B;e[27]!==r?(B=r("Query insights appear once statements are executed against this shard."),e[27]=r,e[28]=B):B=e[28];let he;e[29]!==B?(he=s("p",{className:"mt-1 text-sm",children:B}),e[29]=B,e[30]=he):he=e[30];let Pe;e[31]!==ne||e[32]!==he?(Pe=s(pe,{children:s(xe,{className:"py-12",children:f("div",{className:"text-center text-muted-foreground",children:[ne,he]})})}),e[31]=ne,e[32]=he,e[33]=Pe):Pe=e[33],c=Pe;break e}b="space-y-4",S="qi-root";let de;e[34]!==r?(de=r("Critical queries"),e[34]=r,e[35]=de):de=e[35];let fe;e[36]!==de?(fe=s(Be,{className:"pb-2",children:s(Qe,{className:"text-sm font-medium",children:de})}),e[36]=de,e[37]=fe):fe=e[37];let Q;e[38]!==k?(Q=s("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:k}),e[38]=k,e[39]=Q):Q=e[39];let H;e[40]!==r?(H=r(">100ms avg execution"),e[40]=r,e[41]=H):H=e[41];let U;e[42]!==H?(U=s("p",{className:"text-xs text-muted-foreground",children:H}),e[42]=H,e[43]=U):U=e[43];let j;e[44]!==Q||e[45]!==U?(j=f(xe,{children:[Q,U]}),e[44]=Q,e[45]=U,e[46]=j):j=e[46];let V;e[47]!==fe||e[48]!==j?(V=f(pe,{children:[fe,j]}),e[47]=fe,e[48]=j,e[49]=V):V=e[49];let G;e[50]!==r?(G=r("Moderate queries"),e[50]=r,e[51]=G):G=e[51];let Y;e[52]!==G?(Y=s(Be,{className:"pb-2",children:s(Qe,{className:"text-sm font-medium",children:G})}),e[52]=G,e[53]=Y):Y=e[53];let J;e[54]!==A?(J=s("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:A}),e[54]=A,e[55]=J):J=e[55];let W;e[56]!==r?(W=r("50–100ms avg execution"),e[56]=r,e[57]=W):W=e[57];let X;e[58]!==W?(X=s("p",{className:"text-xs text-muted-foreground",children:W}),e[58]=W,e[59]=X):X=e[59];let Z;e[60]!==J||e[61]!==X?(Z=f(xe,{children:[J,X]}),e[60]=J,e[61]=X,e[62]=Z):Z=e[62];let ee;e[63]!==Y||e[64]!==Z?(ee=f(pe,{children:[Y,Z]}),e[63]=Y,e[64]=Z,e[65]=ee):ee=e[65];let te;e[66]!==r?(te=r("Fast queries"),e[66]=r,e[67]=te):te=e[67];let se;e[68]!==te?(se=s(Be,{className:"pb-2",children:s(Qe,{className:"text-sm font-medium",children:te})}),e[68]=te,e[69]=se):se=e[69];let re;e[70]!==E?(re=s("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:E}),e[70]=E,e[71]=re):re=e[71];let le;e[72]!==r?(le=r("<50ms avg execution"),e[72]=r,e[73]=le):le=e[73];let ae;e[74]!==le?(ae=s("p",{className:"text-xs text-muted-foreground",children:le}),e[74]=le,e[75]=ae):ae=e[75];let T;e[76]!==re||e[77]!==ae?(T=f(xe,{children:[re,ae]}),e[76]=re,e[77]=ae,e[78]=T):T=e[78];let O;e[79]!==se||e[80]!==T?(O=f(pe,{children:[se,T]}),e[79]=se,e[80]=T,e[81]=O):O=e[81],e[82]!==V||e[83]!==ee||e[84]!==O?(y=f("div",{className:"grid gap-4 md:grid-cols-3",children:[V,ee,O]}),e[82]=V,e[83]=ee,e[84]=O,e[85]=y):y=e[85];let z;e[86]!==r?(z=r("Query leaderboard"),e[86]=r,e[87]=z):z=e[87];let K;e[88]!==z?(K=s("h3",{className:"text-lg font-semibold",children:z}),e[88]=z,e[89]=K):K=e[89];let P;e[90]!==t||e[91]!==r?(P=r("Slow queries sorted by {sortField}",{sortField:r(t)}),e[90]=t,e[91]=r,e[92]=P):P=e[92];let ue;e[93]!==P?(ue=s("p",{className:"text-sm text-muted-foreground",children:P}),e[93]=P,e[94]=ue):ue=e[94];let ve;e[95]!==K||e[96]!==ue?(ve=f("div",{children:[K,ue]}),e[95]=K,e[96]=ue,e[97]=ve):ve=e[97];let ye;e[98]!==r?(ye=r("Sort by"),e[98]=r,e[99]=ye):ye=e[99];let Ne;e[100]!==ye?(Ne=s("span",{className:"text-sm text-muted-foreground",children:ye}),e[100]=ye,e[101]=Ne):Ne=e[101];let Se;e[102]!==r?(Se=r("Sort queries by"),e[102]=r,e[103]=Se):Se=e[103];let Oe;e[104]===Symbol.for("react.memo_cache_sentinel")?(Oe=s(Qt,{}),e[104]=Oe):Oe=e[104];let we;e[105]!==Se?(we=s(Ht,{"aria-label":Se,className:"w-[140px]","data-testid":"qi-sort",children:Oe}),e[105]=Se,e[106]=we):we=e[106];let Te;e[107]!==r?(Te=r("Total time"),e[107]=r,e[108]=Te):Te=e[108];let qe;e[109]!==Te?(qe=s(He,{value:"totalTime",children:Te}),e[109]=Te,e[110]=qe):qe=e[110];let _e;e[111]!==r?(_e=r("Avg time"),e[111]=r,e[112]=_e):_e=e[112];let Ce;e[113]!==_e?(Ce=s(He,{value:"avgTime",children:_e}),e[113]=_e,e[114]=Ce):Ce=e[114];let Re;e[115]!==r?(Re=r("Execution count"),e[115]=r,e[116]=Re):Re=e[116];let Me;e[117]!==Re?(Me=s(He,{value:"execCount",children:Re}),e[117]=Re,e[118]=Me):Me=e[118];let ke;e[119]!==r?(ke=r("Rows read"),e[119]=r,e[120]=ke):ke=e[120];let Ae;e[121]!==ke?(Ae=s(He,{value:"rowsRead",children:ke}),e[121]=ke,e[122]=Ae):Ae=e[122];let Ie;e[123]!==qe||e[124]!==Ce||e[125]!==Me||e[126]!==Ae?(Ie=f(Ut,{children:[qe,Ce,Me,Ae]}),e[123]=qe,e[124]=Ce,e[125]=Me,e[126]=Ae,e[127]=Ie):Ie=e[127];let $e;e[128]!==t||e[129]!==we||e[130]!==Ie?($e=f(jt,{onValueChange:h,value:t,children:[we,Ie]}),e[128]=t,e[129]=we,e[130]=Ie,e[131]=$e):$e=e[131];let De;e[132]!==Ne||e[133]!==$e?(De=f("div",{className:"flex items-center gap-2",children:[Ne,$e]}),e[132]=Ne,e[133]=$e,e[134]=De):De=e[134],e[135]!==ve||e[136]!==De?(w=f("div",{className:"flex items-center justify-between",children:[ve,De]}),e[135]=ve,e[136]=De,e[137]=w):w=e[137],d=pe;let Ee;e[138]!==r?(Ee=r("Statements"),e[138]=r,e[139]=Ee):Ee=e[139];let ze;e[140]!==Ee?(ze=s(Qe,{children:Ee}),e[140]=Ee,e[141]=ze):ze=e[141],v=f(Be,{children:[ze,s(Mt,{children:r("{count} tracked statements",{count:q.length})})]}),u=xe,x="space-y-2";let Ke;e[142]!==a||e[143]!==r?(Ke=D=>{const ne=D.normalizedSql,B=a.has(ne),he=Ge(D.avgDurationMs);return f("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[f("button",{"aria-expanded":B,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:()=>{F(ne)},type:"button",children:[f("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[s(rs,{level:he}),s("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:D.normalizedSql})]}),f("div",{className:"flex shrink-0 items-center gap-4",children:[f("div",{className:"text-right",children:[s("div",{className:"text-sm font-medium",children:Le(D.totalDurationMs)}),s("div",{className:"text-xs text-muted-foreground",children:r("total")})]}),f("div",{className:"text-right",children:[s("div",{className:"text-sm font-medium",children:Le(D.avgDurationMs)}),s("div",{className:"text-xs text-muted-foreground",children:r("avg")})]}),D.p95DurationMs!==void 0&&f("div",{className:"text-right",children:[s("div",{className:"text-sm font-medium",children:Le(D.p95DurationMs)}),s("div",{className:"text-xs text-muted-foreground",children:r("p95")})]}),f("div",{className:"text-right",children:[s("div",{className:"text-sm font-medium",children:Ue(D.execCount)}),s("div",{className:"text-xs text-muted-foreground",children:r("calls")})]})]})]}),B&&f("div",{className:"space-y-3 border-t bg-muted/30 p-4",children:[f("div",{children:[s("p",{className:"mb-2 text-sm font-medium",children:r("Full statement")}),s("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:D.normalizedSql})]}),f("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[D.p50DurationMs!==void 0&&f("div",{children:[s("span",{className:"text-muted-foreground",children:r("p50")}),s("span",{className:"block font-medium tabular-nums",children:Le(D.p50DurationMs)})]}),f("div",{children:[s("span",{className:"text-muted-foreground",children:r("Exec count")}),s("span",{className:"block font-medium tabular-nums",children:Ue(D.execCount)})]}),f("div",{children:[s("span",{className:"text-muted-foreground",children:r("Total time")}),s("span",{className:"block font-medium tabular-nums",children:Le(D.totalDurationMs)})]}),f("div",{children:[s("span",{className:"text-muted-foreground",children:r("Rows read")}),s("span",{className:"block font-medium tabular-nums",children:Ue(D.rowsRead)})]}),f("div",{children:[s("span",{className:"text-muted-foreground",children:r("Rows written")}),s("span",{className:"block font-medium tabular-nums",children:Ue(D.rowsWritten)})]})]})]})]},ne)},e[142]=a,e[143]=r,e[144]=Ke):Ke=e[144],g=q.map(Ke)}e[2]=a,e[3]=l,e[4]=t,e[5]=r,e[6]=u,e[7]=d,e[8]=c,e[9]=x,e[10]=g,e[11]=v,e[12]=b,e[13]=S,e[14]=y,e[15]=w}else u=e[6],d=e[7],c=e[8],x=e[9],g=e[10],v=e[11],b=e[12],S=e[13],y=e[14],w=e[15];if(c!==Symbol.for("react.early_return_sentinel"))return c;let M;e[145]!==x||e[146]!==g?(M=s("div",{className:x,children:g}),e[145]=x,e[146]=g,e[147]=M):M=e[147];let _;e[148]!==u||e[149]!==M?(_=s(u,{children:M}),e[148]=u,e[149]=M,e[150]=_):_=e[150];let N;e[151]!==d||e[152]!==_||e[153]!==v?(N=f(d,{children:[v,_]}),e[151]=d,e[152]=_,e[153]=v,e[154]=N):N=e[154];let $;return e[155]!==N||e[156]!==b||e[157]!==S||e[158]!==y||e[159]!==w?($=f("div",{className:b,"data-testid":S,children:[y,w,N]}),e[155]=N,e[156]=b,e[157]=S,e[158]=y,e[159]=w,e[160]=$):$=e[160],$};function is(i){return Ge(i.avgDurationMs)==="critical"}function ns(i){return Ge(i.avgDurationMs)==="warning"}function os(i){return Ge(i.avgDurationMs)==="good"}const cs=["1m","5m","15m","1h"],ds=i=>new Date(i).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),ms=i=>i.map(e=>({avg:Math.round(e.avgDurationMs*100)/100,execs:e.execCount,label:ds(e.bucketMs)})),fs=({shardKey:i=""})=>{const e=ge(),[l,r]=be("15m"),o=je(Fe.getQueryInsights,{range:l},{live:!0,shardKey:i}).data,n=ms(o?.buckets??[]);return f("div",{className:"flex flex-col gap-4","data-testid":"qi-range",children:[f("div",{className:"flex flex-wrap items-center gap-2",children:[s("div",{className:"flex gap-1 rounded-lg border border-border p-0.5","data-testid":"qi-ranges",role:"group",children:cs.map(a=>s("button",{"aria-pressed":a===l,className:Bt("rounded px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",a===l&&"bg-accent font-medium text-foreground"),"data-testid":`qi-range-${a}`,onClick:()=>{r(a)},type:"button",children:a},a))}),o?.capped===!0&&s(et,{"data-testid":"qi-capped",variant:"secondary",children:e("showing a capped set")})]}),n.length===0?s(Pt,{description:e("Statements executed in the selected window appear here, with throughput and latency over time."),testId:"qi-empty",title:e("No queries in this window.")}):f("div",{className:"grid gap-4 lg:grid-cols-2",children:[f("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-throughput",children:[s("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Throughput")}),s(rt,{height:140,width:"100%",children:f(Ft,{data:n,children:[s(lt,{strokeDasharray:"3 3",vertical:!1}),s(at,{dataKey:"label",fontSize:10,tickLine:!1}),s(it,{allowDecimals:!1,fontSize:10,tickLine:!1,width:32}),s(nt,{}),s(Ot,{dataKey:"execs",fill:"var(--color-primary)",fillOpacity:.15,stroke:"var(--color-primary)",type:"monotone"})]})})]}),f("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-latency",children:[s("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Mean latency (ms)")}),s(rt,{height:140,width:"100%",children:f(zt,{data:n,children:[s(lt,{strokeDasharray:"3 3",vertical:!1}),s(at,{dataKey:"label",fontSize:10,tickLine:!1}),s(it,{fontSize:10,tickLine:!1,width:32}),s(nt,{}),s(Kt,{dataKey:"avg",dot:!1,stroke:"var(--color-destructive)",type:"monotone"})]})})]})]}),s(as,{queryStats:o?.entries??[]})]})},us=qt(Fe.getMetrics),hs=[],gs=(i,e)=>i?e:"overview",ps=i=>{const e=me(14);let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={},e[0]=l):l=e[0];let r;e[1]!==i?(r={live:!0,shardKey:i},e[1]=i,e[2]=r):r=e[2];const t=je(Fe.getMetrics,l,r),{data:o}=t;let n;e[3]===Symbol.for("react.memo_cache_sentinel")?(n={points:[],shard:null},e[3]=n):n=e[3];const[a,m]=be(n),p=Je(null),h=Je(null);let u,d;e[4]!==o||e[5]!==i?(u=()=>{o!==void 0&&Ct(i)},d=[o,i],e[4]=o,e[5]=i,e[6]=u,e[7]=d):(u=e[6],d=e[7]),We(u,d);let c,x;e[8]!==o?(c=()=>{if(o===void 0)return;const b=o,S=h.current!==null&&h.current!==b.shard,y=h.current===b.shard?p.current:null;if(h.current=b.shard,p.current=b.requests,S){m({points:[],shard:b.shard});return}y!==null&&b.requests>=y&&m(w=>({points:[...w.shard===b.shard?w.points:[],b.requests-y].slice(-30),shard:b.shard}))},x=[o],e[8]=o,e[9]=c,e[10]=x):(c=e[9],x=e[10]),We(c,x);const g=a.shard!==null&&a.shard===o?.shard?a.points:hs;let v;return e[11]!==t||e[12]!==g?(v={...t,history:g},e[11]=t,e[12]=g,e[13]=v):v=e[13],v},xs=i=>{const e=vt(),l=Je(!0);We(()=>(l.current=!0,()=>{l.current=!1}),[]);const[r,t]=be(null),[o,n]=be(!1),a=async()=>{n(!0);const p=i,h=$t(p,_t());try{const u=await Promise.all(h.map(async d=>{try{const c=await e.query(us,{},wt(d));return{error:null,metrics:c,shard:d===""?c.shard:d}}catch(c){return{error:Tt(c),metrics:null,shard:d===""?"__root__":d}}}));l.current&&t({results:u,shard:p})}finally{l.current&&n(!1)}},m=r?.shard===i?r.results:null;return{aggregate:m===null?null:At(m),aggregating:o,clearAggregate:()=>{t(null)},runAggregate:()=>{St(a())},shardResults:m}},bs=i=>{if(!i||!("queryStats"in i))return;const e=i.queryStats;if(!(!e||!Array.isArray(e)))return It(e)},ot=i=>`pb-2 text-sm font-medium transition-colors ${i?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,vs=i=>{const e=me(26),{activeTab:l,onSelect:r,queryCount:t}=i,o=ge();let n;e[0]!==r?(n=()=>{r("overview")},e[0]=r,e[1]=n):n=e[1];const a=n;let m;e[2]!==r?(m=()=>{r("query-insights")},e[2]=r,e[3]=m):m=e[3];const p=m,h=l==="overview";let u;e[4]!==h?(u=ot(h),e[4]=h,e[5]=u):u=e[5];let d;e[6]!==o?(d=o("Overview"),e[6]=o,e[7]=d):d=e[7];let c;e[8]!==a||e[9]!==u||e[10]!==d?(c=s("button",{className:u,"data-testid":"mt-tab-overview",onClick:a,type:"button",children:d}),e[8]=a,e[9]=u,e[10]=d,e[11]=c):c=e[11];const x=l==="query-insights";let g;e[12]!==x?(g=ot(x),e[12]=x,e[13]=g):g=e[13];let v;e[14]!==o?(v=o("Query insights"),e[14]=o,e[15]=v):v=e[15];let b;e[16]!==t?(b=t>0&&s("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:t}),e[16]=t,e[17]=b):b=e[17];let S;e[18]!==p||e[19]!==b||e[20]!==g||e[21]!==v?(S=f("button",{className:g,"data-testid":"mt-tab-query-insights",onClick:p,type:"button",children:[v,b]}),e[18]=p,e[19]=b,e[20]=g,e[21]=v,e[22]=S):S=e[22];let y;return e[23]!==S||e[24]!==c?(y=f("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[c,S]}),e[23]=S,e[24]=c,e[25]=y):y=e[25],y},ys=i=>{const e=me(13),{history:l,metrics:r}=i;let t;e[0]!==l?(t=l.at(-1)??0,e[0]=l,e[1]=t):t=e[1];let o;e[2]!==r.errors||e[3]!==r.requests?(o=r.requests===0?"—":`${(r.errors/r.requests*100).toFixed(1)}%`,e[2]=r.errors,e[3]=r.requests,e[4]=o):o=e[4];let n;e[5]!==r?(n=Dt(r),e[5]=r,e[6]=n):n=e[6];let a;return e[7]!==l||e[8]!==r||e[9]!==t||e[10]!==o||e[11]!==n?(a=s(ss,{currentDelta:t,errorRate:o,history:l,latencyPercentiles:n,metrics:r}),e[7]=l,e[8]=r,e[9]=t,e[10]=o,e[11]=n,e[12]=a):a=e[12],a},Ns=i=>{const e=me(25),{aggregating:l,liveError:r,onAggregate:t,onClearAggregate:o,onShardKeyChange:n,shardKey:a}=i,m=ge();let p;e[0]!==n||e[1]!==a?(p=s(pt,{onChange:n,testId:"mt-shard-input",value:a}),e[0]=n,e[1]=a,e[2]=p):p=e[2];let h;e[3]!==r?(h=s(gt,{message:r,prefix:"mt"}),e[3]=r,e[4]=h):h=e[4];let u;e[5]!==l||e[6]!==m?(u=m(l?"Aggregating…":"All shards"),e[5]=l,e[6]=m,e[7]=u):u=e[7];let d;e[8]!==l||e[9]!==t||e[10]!==u?(d=s(tt,{"data-testid":"mt-aggregate",disabled:l,onClick:t,size:"sm",type:"button",variant:"secondary",children:u}),e[8]=l,e[9]=t,e[10]=u,e[11]=d):d=e[11];let c;e[12]!==o||e[13]!==m?(c=o!==void 0&&s(tt,{"data-testid":"mt-aggregate-clear",onClick:o,size:"sm",type:"button",variant:"ghost",children:m("Hide")}),e[12]=o,e[13]=m,e[14]=c):c=e[14];let x;e[15]!==m?(x=m("Open in Cloudflare"),e[15]=m,e[16]=x):x=e[16];let g;e[17]!==x?(g=s("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:yt,rel:"noreferrer",target:"_blank",children:x}),e[17]=x,e[18]=g):g=e[18];let v;return e[19]!==p||e[20]!==h||e[21]!==d||e[22]!==c||e[23]!==g?(v=f("div",{className:"flex flex-wrap items-center gap-2",children:[p,h,d,c,g]}),e[19]=p,e[20]=h,e[21]=d,e[22]=c,e[23]=g,e[24]=v):v=e[24],v},Js=i=>{const e=me(41),{initialShardKey:l}=i,{queryShardKey:r,setShardKey:t,shardKey:o}=bt(l),[n,a]=be("overview"),m=xt(r),{data:p,error:h,history:u,liveError:d}=ps(r),c=p??null,{aggregate:x,aggregating:g,clearAggregate:v,runAggregate:b,shardResults:S}=xs(o);let y;e[0]!==c?(y=bs(c),e[0]=c,e[1]=y):y=e[1];const w=y,M=w!==void 0;let _;e[2]!==n||e[3]!==M?(_=gs(M,n),e[2]=n,e[3]=M,e[4]=_):_=e[4];const N=_,$=S===null?void 0:v;let q;e[5]!==g||e[6]!==d||e[7]!==b||e[8]!==t||e[9]!==o||e[10]!==$?(q=s(Ns,{aggregating:g,liveError:d,onAggregate:b,onClearAggregate:$,onShardKeyChange:t,shardKey:o}),e[5]=g,e[6]=d,e[7]=b,e[8]=t,e[9]=o,e[10]=$,e[11]=q):q=e[11];let C;e[12]!==h?(C=h!==null&&s("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:h}),e[12]=h,e[13]=C):C=e[13];let k;e[14]!==N||e[15]!==w?(k=w!==void 0&&s(vs,{activeTab:N,onSelect:a,queryCount:w.length}),e[14]=N,e[15]=w,e[16]=k):k=e[16];let R;e[17]!==N||e[18]!==r||e[19]!==w?(R=N==="query-insights"&&w!==void 0&&s(fs,{shardKey:r}),e[17]=N,e[18]=r,e[19]=w,e[20]=R):R=e[20];let A;e[21]!==N||e[22]!==u||e[23]!==c?(A=N==="overview"&&c!==null&&s(ys,{history:u,metrics:c}),e[21]=N,e[22]=u,e[23]=c,e[24]=A):A=e[24];let I;e[25]!==N||e[26]!==m||e[27]!==r?(I=N==="overview"&&s(es,{onOpenTrace:m,shardKey:r}),e[25]=N,e[26]=m,e[27]=r,e[28]=I):I=e[28];let E;e[29]!==x||e[30]!==N||e[31]!==S?(E=N==="overview"&&x!==null&&S!==null&&s(ts,{aggregate:x,shardResults:S}),e[29]=x,e[30]=N,e[31]=S,e[32]=E):E=e[32];let L;return e[33]!==I||e[34]!==E||e[35]!==q||e[36]!==C||e[37]!==k||e[38]!==R||e[39]!==A?(L=f("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[q,C,k,R,A,I,E]}),e[33]=I,e[34]=E,e[35]=q,e[36]=C,e[37]=k,e[38]=R,e[39]=A,e[40]=L):L=e[40],L};export{Js as MetricsPanel};
@@ -1 +1 @@
1
- import{c as D}from"react/compiler-runtime";import{useState as j}from"react";import{E as K}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{B as L}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as F}from"../packem_shared/button-q0UYSmrn.mjs";import{C as O,a as Q}from"../packem_shared/card-By2O8ULa.mjs";import{E as U}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as q}from"../packem_shared/input-CXhxesPC.mjs";import{T as G,a as J,b as H,c as h,d as X,e as u}from"../packem_shared/table-D0SBiDu-.mjs";import{u as Y}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{useT as Z}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as _}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{h as ee}from"../packem_shared/internal-BXEjuLPN.mjs";import{jsx as t,jsxs as x}from"react/jsx-runtime";const te=e=>e==="ok"?"success":e==="failed"?"destructive":e==="expired"?"warning":"secondary",M=e=>e.endpoint??e.id,ge=()=>{const e=D(38),r=Z(),[a,P]=j("all"),[n,V]=j("");let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const{data:T,error:i,errorSource:p,isLoading:v,refetch:g}=Y(_.listPushSubscriptions,b);let N;if(e[1]!==T?.subscriptions||e[2]!==i||e[3]!==p||e[4]!==v||e[5]!==a||e[6]!==g||e[7]!==n||e[8]!==r){const I=T?.subscriptions??[],$=n.trim().toLowerCase(),A=I.filter(s=>a!=="all"&&s.kind!==a?!1:$===""?!0:`${M(s)} ${s.userId??""}`.toLowerCase().includes($));let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w=s=>{V(s.target.value)},e[10]=w):w=e[10];const z=w;let y;e[11]!==g?(y=()=>{g()},e[11]=g,e[12]=y):y=e[12];const B=y;let C;e[13]===Symbol.for("react.memo_cache_sentinel")?(C=["all","web-push","fcm"],e[13]=C):C=e[13];const W=C;let o;e[14]!==a||e[15]!==r?(o=t("div",{className:"flex items-center gap-1","data-testid":"nt-kind-filter",role:"tablist",children:W.map(s=>t(F,{"aria-selected":a===s,"data-testid":`nt-kind-${s}`,onClick:()=>{P(s)},role:"tab",size:"sm",type:"button",variant:a===s?"secondary":"ghost",children:s==="all"?r("All"):s},s))}),e[14]=a,e[15]=r,e[16]=o):o=e[16];let l;e[17]!==r?(l=r("Filter devices"),e[17]=r,e[18]=l):l=e[18];let d;e[19]!==r?(d=r("filter endpoint, user"),e[19]=r,e[20]=d):d=e[20];let c;e[21]!==n||e[22]!==l||e[23]!==d?(c=t(q,{"aria-label":l,className:"h-8 w-56","data-testid":"nt-search",onChange:z,placeholder:d,value:n}),e[21]=n,e[22]=l,e[23]=d,e[24]=c):c=e[24];let m;e[25]!==r?(m=r("Refresh"),e[25]=r,e[26]=m):m=e[26];let f;e[27]!==B||e[28]!==m?(f=t(F,{className:"ml-auto","data-testid":"nt-refresh",onClick:B,size:"sm",type:"button",variant:"outline",children:m}),e[27]=B,e[28]=m,e[29]=f):f=e[29];const E=I.length>0&&t(L,{"data-testid":"nt-count",variant:"secondary",children:r("{count} devices",{count:I.length})});let k;e[30]!==f||e[31]!==E||e[32]!==o||e[33]!==c?(k=x("div",{className:"flex flex-wrap items-center gap-2",children:[o,c,f,E]}),e[30]=f,e[31]=E,e[32]=o,e[33]=c,e[34]=k):k=e[34];let S;e[35]!==i||e[36]!==p?(S=i!==null&&t(K,{error:p,testId:"nt-error"}),e[35]=i,e[36]=p,e[37]=S):S=e[37],N=x("div",{className:"flex flex-col gap-4","data-testid":"lunora-notifications",children:[k,S,i===null&&!v&&A.length===0&&t(U,{description:r("Registered Web Push / FCM devices appear here. Configure lunora/notify.ts with defineNotify({ store }) and register a device with ctx.push.register(...)."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M15 17h5l-1.4-1.4A2 2 0 0 1 18 14.2V11a6 6 0 0 0-4-5.7V5a2 2 0 1 0-4 0v.3A6 6 0 0 0 6 11v3.2a2 2 0 0 1-.6 1.4L4 17h5m6 0v1a3 3 0 1 1-6 0v-1m6 0H9"})}),testId:"nt-empty",title:r("No registered devices.")}),A.length>0&&t(O,{className:"overflow-hidden py-0",children:t(Q,{className:"max-h-[30rem] overflow-auto px-0",children:x(G,{"data-testid":"nt-table",children:[t(J,{children:x(H,{children:[t(h,{children:r("kind")}),t(h,{children:r("endpoint")}),t(h,{children:r("user")}),t(h,{children:r("last seen")}),t(h,{children:r("status")}),t(h,{children:r("error")})]})}),t(X,{children:A.map(s=>{const R=M(s);return x(H,{"data-testid":"nt-row",children:[t(u,{children:t(L,{variant:"outline",children:s.kind})}),t(u,{className:"max-w-[28ch] truncate font-mono text-xs",title:R,children:R}),t(u,{className:"max-w-[16ch] truncate font-mono text-xs",children:s.userId??t("span",{className:"text-muted-foreground",children:"—"})}),t(u,{className:"text-muted-foreground tabular-nums",children:ee(s.lastSeenAt,"—")}),t(u,{children:t(L,{"data-testid":`nt-status-${s.id}`,variant:te(s.lastStatus),children:s.lastStatus??r("n/a")})}),t(u,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",title:s.lastError??void 0,children:s.lastError??t("span",{className:"text-muted-foreground",children:"—"})})]},s.id)})})]})})})]}),e[1]=T?.subscriptions,e[2]=i,e[3]=p,e[4]=v,e[5]=a,e[6]=g,e[7]=n,e[8]=r,e[9]=N}else N=e[9];return N};export{ge as default};
1
+ import{c as D}from"react/compiler-runtime";import{useState as j}from"react";import{E as K}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{B as L}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as F}from"../packem_shared/button-q0UYSmrn.mjs";import{C as O,a as Q}from"../packem_shared/card-By2O8ULa.mjs";import{E as U}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as q}from"../packem_shared/input-CXhxesPC.mjs";import{T as G,a as J,b as H,c as h,d as X,e as u}from"../packem_shared/table-D0SBiDu-.mjs";import{u as Y}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{useT as Z}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as _}from"../packem_shared/ADMIN_FUNCTIONS-4aGsMs95.mjs";import{h as ee}from"../packem_shared/internal-BXEjuLPN.mjs";import{jsx as t,jsxs as x}from"react/jsx-runtime";const te=e=>e==="ok"?"success":e==="failed"?"destructive":e==="expired"?"warning":"secondary",M=e=>e.endpoint??e.id,ge=()=>{const e=D(38),r=Z(),[a,P]=j("all"),[n,V]=j("");let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const{data:T,error:i,errorSource:p,isLoading:v,refetch:g}=Y(_.listPushSubscriptions,b);let N;if(e[1]!==T?.subscriptions||e[2]!==i||e[3]!==p||e[4]!==v||e[5]!==a||e[6]!==g||e[7]!==n||e[8]!==r){const I=T?.subscriptions??[],$=n.trim().toLowerCase(),A=I.filter(s=>a!=="all"&&s.kind!==a?!1:$===""?!0:`${M(s)} ${s.userId??""}`.toLowerCase().includes($));let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w=s=>{V(s.target.value)},e[10]=w):w=e[10];const z=w;let y;e[11]!==g?(y=()=>{g()},e[11]=g,e[12]=y):y=e[12];const B=y;let C;e[13]===Symbol.for("react.memo_cache_sentinel")?(C=["all","web-push","fcm"],e[13]=C):C=e[13];const W=C;let o;e[14]!==a||e[15]!==r?(o=t("div",{className:"flex items-center gap-1","data-testid":"nt-kind-filter",role:"tablist",children:W.map(s=>t(F,{"aria-selected":a===s,"data-testid":`nt-kind-${s}`,onClick:()=>{P(s)},role:"tab",size:"sm",type:"button",variant:a===s?"secondary":"ghost",children:s==="all"?r("All"):s},s))}),e[14]=a,e[15]=r,e[16]=o):o=e[16];let l;e[17]!==r?(l=r("Filter devices"),e[17]=r,e[18]=l):l=e[18];let d;e[19]!==r?(d=r("filter endpoint, user"),e[19]=r,e[20]=d):d=e[20];let c;e[21]!==n||e[22]!==l||e[23]!==d?(c=t(q,{"aria-label":l,className:"h-8 w-56","data-testid":"nt-search",onChange:z,placeholder:d,value:n}),e[21]=n,e[22]=l,e[23]=d,e[24]=c):c=e[24];let m;e[25]!==r?(m=r("Refresh"),e[25]=r,e[26]=m):m=e[26];let f;e[27]!==B||e[28]!==m?(f=t(F,{className:"ml-auto","data-testid":"nt-refresh",onClick:B,size:"sm",type:"button",variant:"outline",children:m}),e[27]=B,e[28]=m,e[29]=f):f=e[29];const E=I.length>0&&t(L,{"data-testid":"nt-count",variant:"secondary",children:r("{count} devices",{count:I.length})});let k;e[30]!==f||e[31]!==E||e[32]!==o||e[33]!==c?(k=x("div",{className:"flex flex-wrap items-center gap-2",children:[o,c,f,E]}),e[30]=f,e[31]=E,e[32]=o,e[33]=c,e[34]=k):k=e[34];let S;e[35]!==i||e[36]!==p?(S=i!==null&&t(K,{error:p,testId:"nt-error"}),e[35]=i,e[36]=p,e[37]=S):S=e[37],N=x("div",{className:"flex flex-col gap-4","data-testid":"lunora-notifications",children:[k,S,i===null&&!v&&A.length===0&&t(U,{description:r("Registered Web Push / FCM devices appear here. Configure lunora/notify.ts with defineNotify({ store }) and register a device with ctx.push.register(...)."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M15 17h5l-1.4-1.4A2 2 0 0 1 18 14.2V11a6 6 0 0 0-4-5.7V5a2 2 0 1 0-4 0v.3A6 6 0 0 0 6 11v3.2a2 2 0 0 1-.6 1.4L4 17h5m6 0v1a3 3 0 1 1-6 0v-1m6 0H9"})}),testId:"nt-empty",title:r("No registered devices.")}),A.length>0&&t(O,{className:"overflow-hidden py-0",children:t(Q,{className:"max-h-[30rem] overflow-auto px-0",children:x(G,{"data-testid":"nt-table",children:[t(J,{children:x(H,{children:[t(h,{children:r("kind")}),t(h,{children:r("endpoint")}),t(h,{children:r("user")}),t(h,{children:r("last seen")}),t(h,{children:r("status")}),t(h,{children:r("error")})]})}),t(X,{children:A.map(s=>{const R=M(s);return x(H,{"data-testid":"nt-row",children:[t(u,{children:t(L,{variant:"outline",children:s.kind})}),t(u,{className:"max-w-[28ch] truncate font-mono text-xs",title:R,children:R}),t(u,{className:"max-w-[16ch] truncate font-mono text-xs",children:s.userId??t("span",{className:"text-muted-foreground",children:"—"})}),t(u,{className:"text-muted-foreground tabular-nums",children:ee(s.lastSeenAt,"—")}),t(u,{children:t(L,{"data-testid":`nt-status-${s.id}`,variant:te(s.lastStatus),children:s.lastStatus??r("n/a")})}),t(u,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",title:s.lastError??void 0,children:s.lastError??t("span",{className:"text-muted-foreground",children:"—"})})]},s.id)})})]})})})]}),e[1]=T?.subscriptions,e[2]=i,e[3]=p,e[4]=v,e[5]=a,e[6]=g,e[7]=n,e[8]=r,e[9]=N}else N=e[9];return N};export{ge as default};
@@ -1 +1 @@
1
- import{c as Ke}from"react/compiler-runtime";import{useState as k,useEffect as We}from"react";import{ConfirmButton as Le}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{B as Xe}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as Ye}from"../packem_shared/button-q0UYSmrn.mjs";import{I as Ue}from"../packem_shared/input-CXhxesPC.mjs";import{L as Se}from"../packem_shared/label-DKFzyHq6.mjs";import{useAutoRefresh as et}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-CG7Q45ZS.mjs";import{u as tt}from"../packem_shared/use-mirrored-ref-CVDf2z1M.mjs";import{u as rt}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as je}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as qe}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{c as ze,d as _e,j as Fe,b as Pe,f as Ae}from"../packem_shared/internal-BXEjuLPN.mjs";import{jsxs as i,jsx as s}from"react/jsx-runtime";const Me=ze(qe.getPitrBookmark),st=ze(qe.pitrRestore),ot=/^\d+$/u,De=ne=>{const e=ne.trim(),u=ot.test(e)?Number(e):Date.parse(e),l=new Date(u);return Number.isNaN(l.getTime())?void 0:{epochMs:u,iso:l.toISOString()}},lt=ne=>{const e=Ke(9),{text:u}=ne,l=je();if(u.trim()==="")return null;let t,r,f;if(e[0]!==l||e[1]!==u){const y=De(u);t="font-mono text-xs text-muted-foreground",r="pitr-time-resolved",f=y===void 0?l("Not a time — use epoch-ms or ISO 8601."):l("Resolves to {instant} (a date-time without an offset is read in this browser's time zone; a bare date is UTC)",{instant:y.iso}),e[0]=l,e[1]=u,e[2]=t,e[3]=r,e[4]=f}else t=e[2],r=e[3],f=e[4];let v;return e[5]!==t||e[6]!==r||e[7]!==f?(v=s("p",{className:t,"data-testid":r,children:f}),e[5]=t,e[6]=r,e[7]=f,e[8]=v):v=e[8],v},Nt=ne=>{const e=Ke(140),{initialShardKey:u}=ne,l=rt(),t=je(),r=u??"",f=tt(r),[v,y]=k(null),[p,$e]=k(""),[de,Oe]=k(null),[d,He]=k(""),[h,Ve]=k(!1),[n,Ge]=k(null),[me,R]=k(null),[ce,_]=k(!1),[w,Ee]=k(!1);let fe;e[0]!==l||e[1]!==r?(fe=async o=>{_(!0),R(null);let c;try{c={current:(await l.query(Me,{},_e(r))).current,error:null,unavailable:!1}}catch(a){const N=a;c={current:null,error:Pe(N),unavailable:Fe(N)==="PITR_UNAVAILABLE"}}o?.aborted!==!0&&(c.error===null?y(c.current):R(c.error),Ee(c.unavailable),_(!1))},e[0]=l,e[1]=r,e[2]=fe):fe=e[2];const b=fe;let ue,pe;e[3]!==b?(ue=()=>{const o=new AbortController;return Ae(b(o.signal)),()=>{o.abort()}},pe=[b],e[3]=b,e[4]=ue,e[5]=pe):(ue=e[4],pe=e[5]),We(ue,pe);let he;e[6]!==l||e[7]!==r?(he=async()=>{const o=await l.query(Me,{},_e(r));y(o.current)},e[6]=l,e[7]=r,e[8]=he):he=e[8],et(he,!w);let be;e[9]===Symbol.for("react.memo_cache_sentinel")?(be=o=>{$e(o.target.value)},e[9]=be):be=e[9];const Ze=be;let xe;e[10]===Symbol.for("react.memo_cache_sentinel")?(xe=o=>{He(o.target.value)},e[10]=xe):xe=e[10];const Je=xe;let ke;e[11]===Symbol.for("react.memo_cache_sentinel")?(ke=o=>{Ve(o.target.checked)},e[11]=ke):ke=e[11];const Qe=ke;let ve,C,m,x,g,ge;if(e[12]!==d||e[13]!==l||e[14]!==de||e[15]!==b||e[16]!==r||e[17]!==f||e[18]!==t||e[19]!==p){m=De(p),C=()=>{if(m===void 0)return;const c=r;Ae((async()=>{_(!0),R(null);let a;try{a={result:await l.query(Me,{time:m.epochMs},_e(c))}}catch(N){a={error:Pe(N)}}f.current===c&&("result"in a?(Oe(a.result.forTime===void 0?null:{bookmark:a.result.forTime,shard:c}),y(a.result.current)):(Oe(null),R(a.error)),_(!1))})())},g=de?.shard===r?de.bookmark:null;let o;e[26]!==l||e[27]!==b||e[28]!==r?(o=c=>{Ae((async()=>{_(!0),R(null);try{const a=await l.mutation(st,c,_e(r));Ge(a),await b()}catch(a){const N=a;R(Pe(N)),Fe(N)==="PITR_UNAVAILABLE"&&Ee(!0)}_(!1)})())},e[26]=l,e[27]=b,e[28]=r,e[29]=o):o=e[29],x=o,ve=d.trim()!==""||m!==void 0,ge=t("Restore {shard} to {target}?",{shard:r===""?t("root"):r,target:d.trim()===""?m?.iso??"":t("the given bookmark")}),e[12]=d,e[13]=l,e[14]=de,e[15]=b,e[16]=r,e[17]=f,e[18]=t,e[19]=p,e[20]=ve,e[21]=C,e[22]=m,e[23]=x,e[24]=g,e[25]=ge}else ve=e[20],C=e[21],m=e[22],x=e[23],g=e[24],ge=e[25];const we=ge;let Ne;e[30]!==d||e[31]!==m?.epochMs||e[32]!==h||e[33]!==x?(Ne=()=>{const o=h?{restart:!0}:{};d.trim()===""?o.time=m?.epochMs:o.bookmark=d.trim(),x(o)},e[30]=d,e[31]=m?.epochMs,e[32]=h,e[33]=x,e[34]=Ne):Ne=e[34];const Ce=Ne;let ye;e[35]!==h||e[36]!==n||e[37]!==x?(ye=()=>{n!==null&&x(h?{bookmark:n.undoBookmark,restart:!0}:{bookmark:n.undoBookmark})},e[35]=h,e[36]=n,e[37]=x,e[38]=ye):ye=e[38];const Te=ye;let T;e[39]!==t?(T=t("Shard"),e[39]=t,e[40]=T):T=e[40];let B;e[41]!==r||e[42]!==t?(B=r===""?t("root"):r,e[41]=r,e[42]=t,e[43]=B):B=e[43];let I;e[44]!==B?(I=s("span",{className:"font-mono",children:B}),e[44]=B,e[45]=I):I=e[45];let S;e[46]!==T||e[47]!==I?(S=s("div",{className:"flex flex-wrap items-center gap-3",children:i("span",{className:"text-xs text-muted-foreground",children:[T,": ",I]})}),e[46]=T,e[47]=I,e[48]=S):S=e[48];let P;e[49]!==t?(P=t("In-place recovery to any moment in the last 30 days. For older or portable recovery, use the snapshot backup tier."),e[49]=t,e[50]=P):P=e[50];let A;e[51]!==P?(A=s("p",{className:"text-sm text-muted-foreground","data-testid":"pitr-note",children:P}),e[51]=P,e[52]=A):A=e[52];let M;e[53]!==me?(M=me!==null&&s("p",{className:"text-sm text-destructive","data-testid":"pitr-error",role:"alert",children:me}),e[53]=me,e[54]=M):M=e[54];let O;e[55]!==t?(O=t("Current bookmark"),e[55]=t,e[56]=O):O=e[56];let E;e[57]!==O?(E=s("h3",{className:"mb-2 text-sm font-semibold",children:O}),e[57]=O,e[58]=E):E=e[58];let L;e[59]!==v?(L=v??s("span",{className:"text-muted-foreground",children:"—"}),e[59]=v,e[60]=L):L=e[60];let U;e[61]!==L?(U=s("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-current",children:L}),e[61]=L,e[62]=U):U=e[62];let F;e[63]!==E||e[64]!==U?(F=i("section",{className:"rounded-xl border border-border bg-card p-3 shadow-xs",children:[E,U]}),e[63]=E,e[64]=U,e[65]=F):F=e[65];let K;e[66]!==t?(K=t("Restore"),e[66]=t,e[67]=K):K=e[67];let j;e[68]!==K?(j=s("h3",{className:"text-sm font-semibold",children:K}),e[68]=K,e[69]=j):j=e[69];let q;e[70]!==t?(q=t("Time (ISO or epoch-ms, last 30 days)"),e[70]=t,e[71]=q):q=e[71];let z;e[72]!==q?(z=s(Se,{htmlFor:"pitr-time",children:q}),e[72]=q,e[73]=z):z=e[73];let D;e[74]!==p?(D=s(Ue,{"data-testid":"pitr-time",id:"pitr-time",onChange:Ze,placeholder:"2026-06-01T00:00:00.000Z",value:p}),e[74]=p,e[75]=D):D=e[75];const Be=ce||w||m===void 0;let $;e[76]!==t?($=t("Preview"),e[76]=t,e[77]=$):$=e[77];let H;e[78]!==C||e[79]!==Be||e[80]!==$?(H=s(Ye,{"data-testid":"pitr-preview",disabled:Be,onClick:C,size:"sm",type:"button",variant:"outline",children:$}),e[78]=C,e[79]=Be,e[80]=$,e[81]=H):H=e[81];let V;e[82]!==D||e[83]!==H?(V=i("div",{className:"flex items-center gap-2",children:[D,H]}),e[82]=D,e[83]=H,e[84]=V):V=e[84];let G;e[85]!==p?(G=s(lt,{text:p}),e[85]=p,e[86]=G):G=e[86];let Z;e[87]!==g||e[88]!==t?(Z=g!==null&&i("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-preview-bookmark",children:[t("Bookmark for that time"),": ",g]}),e[87]=g,e[88]=t,e[89]=Z):Z=e[89];let J;e[90]!==z||e[91]!==V||e[92]!==G||e[93]!==Z?(J=i("div",{className:"flex flex-col gap-1",children:[z,V,G,Z]}),e[90]=z,e[91]=V,e[92]=G,e[93]=Z,e[94]=J):J=e[94];let Q;e[95]!==t?(Q=t("Or an explicit bookmark (wins over time)"),e[95]=t,e[96]=Q):Q=e[96];let W;e[97]!==Q?(W=s(Se,{htmlFor:"pitr-bookmark",children:Q}),e[97]=Q,e[98]=W):W=e[98];let X;e[99]!==t?(X=t("bookmark string"),e[99]=t,e[100]=X):X=e[100];let Y;e[101]!==d||e[102]!==X?(Y=s(Ue,{"data-testid":"pitr-bookmark",id:"pitr-bookmark",onChange:Je,placeholder:X,value:d}),e[101]=d,e[102]=X,e[103]=Y):Y=e[103];let ee;e[104]!==W||e[105]!==Y?(ee=i("div",{className:"flex flex-col gap-1",children:[W,Y]}),e[104]=W,e[105]=Y,e[106]=ee):ee=e[106];let te;e[107]!==h?(te=s("input",{checked:h,className:"size-4 accent-primary","data-testid":"pitr-restart",id:"pitr-restart",onChange:Qe,type:"checkbox"}),e[107]=h,e[108]=te):te=e[108];let re;e[109]!==t?(re=t("Restart the shard now so recovery applies immediately"),e[109]=t,e[110]=re):re=e[110];let se;e[111]!==te||e[112]!==re?(se=i(Se,{className:"flex items-center gap-2 text-xs font-normal text-muted-foreground",htmlFor:"pitr-restart",children:[te,re]}),e[111]=te,e[112]=re,e[113]=se):se=e[113];const Ie=ce||w||!ve;let oe;e[114]!==t?(oe=t("Restore"),e[114]=t,e[115]=oe):oe=e[115];let le;e[116]!==we||e[117]!==Ce||e[118]!==Ie||e[119]!==oe?(le=s("div",{children:s(Le,{confirmLabel:we,disabled:Ie,onConfirm:Ce,testId:"pitr-restore",children:oe})}),e[116]=we,e[117]=Ce,e[118]=Ie,e[119]=oe,e[120]=le):le=e[120];let ae;e[121]!==j||e[122]!==J||e[123]!==ee||e[124]!==se||e[125]!==le?(ae=i("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-3 shadow-xs",children:[j,J,ee,se,le]}),e[121]=j,e[122]=J,e[123]=ee,e[124]=se,e[125]=le,e[126]=ae):ae=e[126];let ie;e[127]!==ce||e[128]!==Te||e[129]!==n||e[130]!==t||e[131]!==w?(ie=n!==null&&i("section",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs","data-testid":"pitr-result",children:[i("div",{className:"flex items-center gap-2",children:[s("h3",{className:"text-sm font-semibold",children:t("Restore armed")}),s(Xe,{variant:n.restarted?"destructive":"secondary",children:n.restarted?t("restarted now"):t("on next restart")})]}),i("p",{className:"font-mono text-xs break-all text-muted-foreground",children:[t("Restored to"),": ",n.restoredTo]}),i("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-undo-bookmark",children:[t("Undo bookmark"),": ",n.undoBookmark]}),s("div",{children:s(Le,{confirmLabel:t("Confirm undo"),disabled:ce||w,onConfirm:Te,testId:"pitr-undo",children:t("Undo restore")})})]}),e[127]=ce,e[128]=Te,e[129]=n,e[130]=t,e[131]=w,e[132]=ie):ie=e[132];let Re;return e[133]!==S||e[134]!==A||e[135]!==M||e[136]!==F||e[137]!==ae||e[138]!==ie?(Re=i("div",{className:"flex flex-col gap-4","data-testid":"lunora-pitr",children:[S,A,M,F,ae,ie]}),e[133]=S,e[134]=A,e[135]=M,e[136]=F,e[137]=ae,e[138]=ie,e[139]=Re):Re=e[139],Re};export{Nt as PitrPanel};
1
+ import{c as Ke}from"react/compiler-runtime";import{useState as k,useEffect as We}from"react";import{ConfirmButton as Le}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{B as Xe}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as Ye}from"../packem_shared/button-q0UYSmrn.mjs";import{I as Ue}from"../packem_shared/input-CXhxesPC.mjs";import{L as Se}from"../packem_shared/label-DKFzyHq6.mjs";import{useAutoRefresh as et}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-CG7Q45ZS.mjs";import{u as tt}from"../packem_shared/use-mirrored-ref-CVDf2z1M.mjs";import{u as rt}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as je}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as qe}from"../packem_shared/ADMIN_FUNCTIONS-4aGsMs95.mjs";import{c as ze,d as _e,j as Fe,b as Pe,f as Ae}from"../packem_shared/internal-BXEjuLPN.mjs";import{jsxs as i,jsx as s}from"react/jsx-runtime";const Me=ze(qe.getPitrBookmark),st=ze(qe.pitrRestore),ot=/^\d+$/u,De=ne=>{const e=ne.trim(),u=ot.test(e)?Number(e):Date.parse(e),l=new Date(u);return Number.isNaN(l.getTime())?void 0:{epochMs:u,iso:l.toISOString()}},lt=ne=>{const e=Ke(9),{text:u}=ne,l=je();if(u.trim()==="")return null;let t,r,f;if(e[0]!==l||e[1]!==u){const y=De(u);t="font-mono text-xs text-muted-foreground",r="pitr-time-resolved",f=y===void 0?l("Not a time — use epoch-ms or ISO 8601."):l("Resolves to {instant} (a date-time without an offset is read in this browser's time zone; a bare date is UTC)",{instant:y.iso}),e[0]=l,e[1]=u,e[2]=t,e[3]=r,e[4]=f}else t=e[2],r=e[3],f=e[4];let v;return e[5]!==t||e[6]!==r||e[7]!==f?(v=s("p",{className:t,"data-testid":r,children:f}),e[5]=t,e[6]=r,e[7]=f,e[8]=v):v=e[8],v},Nt=ne=>{const e=Ke(140),{initialShardKey:u}=ne,l=rt(),t=je(),r=u??"",f=tt(r),[v,y]=k(null),[p,$e]=k(""),[de,Oe]=k(null),[d,He]=k(""),[h,Ve]=k(!1),[n,Ge]=k(null),[me,R]=k(null),[ce,_]=k(!1),[w,Ee]=k(!1);let fe;e[0]!==l||e[1]!==r?(fe=async o=>{_(!0),R(null);let c;try{c={current:(await l.query(Me,{},_e(r))).current,error:null,unavailable:!1}}catch(a){const N=a;c={current:null,error:Pe(N),unavailable:Fe(N)==="PITR_UNAVAILABLE"}}o?.aborted!==!0&&(c.error===null?y(c.current):R(c.error),Ee(c.unavailable),_(!1))},e[0]=l,e[1]=r,e[2]=fe):fe=e[2];const b=fe;let ue,pe;e[3]!==b?(ue=()=>{const o=new AbortController;return Ae(b(o.signal)),()=>{o.abort()}},pe=[b],e[3]=b,e[4]=ue,e[5]=pe):(ue=e[4],pe=e[5]),We(ue,pe);let he;e[6]!==l||e[7]!==r?(he=async()=>{const o=await l.query(Me,{},_e(r));y(o.current)},e[6]=l,e[7]=r,e[8]=he):he=e[8],et(he,!w);let be;e[9]===Symbol.for("react.memo_cache_sentinel")?(be=o=>{$e(o.target.value)},e[9]=be):be=e[9];const Ze=be;let xe;e[10]===Symbol.for("react.memo_cache_sentinel")?(xe=o=>{He(o.target.value)},e[10]=xe):xe=e[10];const Je=xe;let ke;e[11]===Symbol.for("react.memo_cache_sentinel")?(ke=o=>{Ve(o.target.checked)},e[11]=ke):ke=e[11];const Qe=ke;let ve,C,m,x,g,ge;if(e[12]!==d||e[13]!==l||e[14]!==de||e[15]!==b||e[16]!==r||e[17]!==f||e[18]!==t||e[19]!==p){m=De(p),C=()=>{if(m===void 0)return;const c=r;Ae((async()=>{_(!0),R(null);let a;try{a={result:await l.query(Me,{time:m.epochMs},_e(c))}}catch(N){a={error:Pe(N)}}f.current===c&&("result"in a?(Oe(a.result.forTime===void 0?null:{bookmark:a.result.forTime,shard:c}),y(a.result.current)):(Oe(null),R(a.error)),_(!1))})())},g=de?.shard===r?de.bookmark:null;let o;e[26]!==l||e[27]!==b||e[28]!==r?(o=c=>{Ae((async()=>{_(!0),R(null);try{const a=await l.mutation(st,c,_e(r));Ge(a),await b()}catch(a){const N=a;R(Pe(N)),Fe(N)==="PITR_UNAVAILABLE"&&Ee(!0)}_(!1)})())},e[26]=l,e[27]=b,e[28]=r,e[29]=o):o=e[29],x=o,ve=d.trim()!==""||m!==void 0,ge=t("Restore {shard} to {target}?",{shard:r===""?t("root"):r,target:d.trim()===""?m?.iso??"":t("the given bookmark")}),e[12]=d,e[13]=l,e[14]=de,e[15]=b,e[16]=r,e[17]=f,e[18]=t,e[19]=p,e[20]=ve,e[21]=C,e[22]=m,e[23]=x,e[24]=g,e[25]=ge}else ve=e[20],C=e[21],m=e[22],x=e[23],g=e[24],ge=e[25];const we=ge;let Ne;e[30]!==d||e[31]!==m?.epochMs||e[32]!==h||e[33]!==x?(Ne=()=>{const o=h?{restart:!0}:{};d.trim()===""?o.time=m?.epochMs:o.bookmark=d.trim(),x(o)},e[30]=d,e[31]=m?.epochMs,e[32]=h,e[33]=x,e[34]=Ne):Ne=e[34];const Ce=Ne;let ye;e[35]!==h||e[36]!==n||e[37]!==x?(ye=()=>{n!==null&&x(h?{bookmark:n.undoBookmark,restart:!0}:{bookmark:n.undoBookmark})},e[35]=h,e[36]=n,e[37]=x,e[38]=ye):ye=e[38];const Te=ye;let T;e[39]!==t?(T=t("Shard"),e[39]=t,e[40]=T):T=e[40];let B;e[41]!==r||e[42]!==t?(B=r===""?t("root"):r,e[41]=r,e[42]=t,e[43]=B):B=e[43];let I;e[44]!==B?(I=s("span",{className:"font-mono",children:B}),e[44]=B,e[45]=I):I=e[45];let S;e[46]!==T||e[47]!==I?(S=s("div",{className:"flex flex-wrap items-center gap-3",children:i("span",{className:"text-xs text-muted-foreground",children:[T,": ",I]})}),e[46]=T,e[47]=I,e[48]=S):S=e[48];let P;e[49]!==t?(P=t("In-place recovery to any moment in the last 30 days. For older or portable recovery, use the snapshot backup tier."),e[49]=t,e[50]=P):P=e[50];let A;e[51]!==P?(A=s("p",{className:"text-sm text-muted-foreground","data-testid":"pitr-note",children:P}),e[51]=P,e[52]=A):A=e[52];let M;e[53]!==me?(M=me!==null&&s("p",{className:"text-sm text-destructive","data-testid":"pitr-error",role:"alert",children:me}),e[53]=me,e[54]=M):M=e[54];let O;e[55]!==t?(O=t("Current bookmark"),e[55]=t,e[56]=O):O=e[56];let E;e[57]!==O?(E=s("h3",{className:"mb-2 text-sm font-semibold",children:O}),e[57]=O,e[58]=E):E=e[58];let L;e[59]!==v?(L=v??s("span",{className:"text-muted-foreground",children:"—"}),e[59]=v,e[60]=L):L=e[60];let U;e[61]!==L?(U=s("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-current",children:L}),e[61]=L,e[62]=U):U=e[62];let F;e[63]!==E||e[64]!==U?(F=i("section",{className:"rounded-xl border border-border bg-card p-3 shadow-xs",children:[E,U]}),e[63]=E,e[64]=U,e[65]=F):F=e[65];let K;e[66]!==t?(K=t("Restore"),e[66]=t,e[67]=K):K=e[67];let j;e[68]!==K?(j=s("h3",{className:"text-sm font-semibold",children:K}),e[68]=K,e[69]=j):j=e[69];let q;e[70]!==t?(q=t("Time (ISO or epoch-ms, last 30 days)"),e[70]=t,e[71]=q):q=e[71];let z;e[72]!==q?(z=s(Se,{htmlFor:"pitr-time",children:q}),e[72]=q,e[73]=z):z=e[73];let D;e[74]!==p?(D=s(Ue,{"data-testid":"pitr-time",id:"pitr-time",onChange:Ze,placeholder:"2026-06-01T00:00:00.000Z",value:p}),e[74]=p,e[75]=D):D=e[75];const Be=ce||w||m===void 0;let $;e[76]!==t?($=t("Preview"),e[76]=t,e[77]=$):$=e[77];let H;e[78]!==C||e[79]!==Be||e[80]!==$?(H=s(Ye,{"data-testid":"pitr-preview",disabled:Be,onClick:C,size:"sm",type:"button",variant:"outline",children:$}),e[78]=C,e[79]=Be,e[80]=$,e[81]=H):H=e[81];let V;e[82]!==D||e[83]!==H?(V=i("div",{className:"flex items-center gap-2",children:[D,H]}),e[82]=D,e[83]=H,e[84]=V):V=e[84];let G;e[85]!==p?(G=s(lt,{text:p}),e[85]=p,e[86]=G):G=e[86];let Z;e[87]!==g||e[88]!==t?(Z=g!==null&&i("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-preview-bookmark",children:[t("Bookmark for that time"),": ",g]}),e[87]=g,e[88]=t,e[89]=Z):Z=e[89];let J;e[90]!==z||e[91]!==V||e[92]!==G||e[93]!==Z?(J=i("div",{className:"flex flex-col gap-1",children:[z,V,G,Z]}),e[90]=z,e[91]=V,e[92]=G,e[93]=Z,e[94]=J):J=e[94];let Q;e[95]!==t?(Q=t("Or an explicit bookmark (wins over time)"),e[95]=t,e[96]=Q):Q=e[96];let W;e[97]!==Q?(W=s(Se,{htmlFor:"pitr-bookmark",children:Q}),e[97]=Q,e[98]=W):W=e[98];let X;e[99]!==t?(X=t("bookmark string"),e[99]=t,e[100]=X):X=e[100];let Y;e[101]!==d||e[102]!==X?(Y=s(Ue,{"data-testid":"pitr-bookmark",id:"pitr-bookmark",onChange:Je,placeholder:X,value:d}),e[101]=d,e[102]=X,e[103]=Y):Y=e[103];let ee;e[104]!==W||e[105]!==Y?(ee=i("div",{className:"flex flex-col gap-1",children:[W,Y]}),e[104]=W,e[105]=Y,e[106]=ee):ee=e[106];let te;e[107]!==h?(te=s("input",{checked:h,className:"size-4 accent-primary","data-testid":"pitr-restart",id:"pitr-restart",onChange:Qe,type:"checkbox"}),e[107]=h,e[108]=te):te=e[108];let re;e[109]!==t?(re=t("Restart the shard now so recovery applies immediately"),e[109]=t,e[110]=re):re=e[110];let se;e[111]!==te||e[112]!==re?(se=i(Se,{className:"flex items-center gap-2 text-xs font-normal text-muted-foreground",htmlFor:"pitr-restart",children:[te,re]}),e[111]=te,e[112]=re,e[113]=se):se=e[113];const Ie=ce||w||!ve;let oe;e[114]!==t?(oe=t("Restore"),e[114]=t,e[115]=oe):oe=e[115];let le;e[116]!==we||e[117]!==Ce||e[118]!==Ie||e[119]!==oe?(le=s("div",{children:s(Le,{confirmLabel:we,disabled:Ie,onConfirm:Ce,testId:"pitr-restore",children:oe})}),e[116]=we,e[117]=Ce,e[118]=Ie,e[119]=oe,e[120]=le):le=e[120];let ae;e[121]!==j||e[122]!==J||e[123]!==ee||e[124]!==se||e[125]!==le?(ae=i("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-3 shadow-xs",children:[j,J,ee,se,le]}),e[121]=j,e[122]=J,e[123]=ee,e[124]=se,e[125]=le,e[126]=ae):ae=e[126];let ie;e[127]!==ce||e[128]!==Te||e[129]!==n||e[130]!==t||e[131]!==w?(ie=n!==null&&i("section",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs","data-testid":"pitr-result",children:[i("div",{className:"flex items-center gap-2",children:[s("h3",{className:"text-sm font-semibold",children:t("Restore armed")}),s(Xe,{variant:n.restarted?"destructive":"secondary",children:n.restarted?t("restarted now"):t("on next restart")})]}),i("p",{className:"font-mono text-xs break-all text-muted-foreground",children:[t("Restored to"),": ",n.restoredTo]}),i("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-undo-bookmark",children:[t("Undo bookmark"),": ",n.undoBookmark]}),s("div",{children:s(Le,{confirmLabel:t("Confirm undo"),disabled:ce||w,onConfirm:Te,testId:"pitr-undo",children:t("Undo restore")})})]}),e[127]=ce,e[128]=Te,e[129]=n,e[130]=t,e[131]=w,e[132]=ie):ie=e[132];let Re;return e[133]!==S||e[134]!==A||e[135]!==M||e[136]!==F||e[137]!==ae||e[138]!==ie?(Re=i("div",{className:"flex flex-col gap-4","data-testid":"lunora-pitr",children:[S,A,M,F,ae,ie]}),e[133]=S,e[134]=A,e[135]=M,e[136]=F,e[137]=ae,e[138]=ie,e[139]=Re):Re=e[139],Re};export{Nt as PitrPanel};