@lunora/studio 1.0.0-alpha.96 → 1.0.0-alpha.98
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.
- package/dist/standalone/{chunk-NQ4FA65F.js → chunk-2TFGS62O.js} +1 -1
- package/dist/standalone/{chunk-JRAUQ4L2.js → chunk-3J6AAVUL.js} +1 -1
- package/dist/standalone/{chunk-AUXEGD24.js → chunk-4D56O2UT.js} +1 -1
- package/dist/standalone/{chunk-3PXUIMP2.js → chunk-5GMRSN6L.js} +1 -1
- package/dist/standalone/chunk-6FQJRXVI.js +11 -0
- package/dist/standalone/{chunk-7KU3LR7G.js → chunk-6IKXBSNY.js} +1 -1
- package/dist/standalone/{chunk-VWKQ6X2S.js → chunk-7CWPU3LW.js} +1 -1
- package/dist/standalone/{chunk-FA6AR5QU.js → chunk-7HWEPGII.js} +1 -1
- package/dist/standalone/{chunk-ZURV2PEP.js → chunk-7IIICQZ7.js} +1 -1
- package/dist/standalone/{chunk-LV5UVTHL.js → chunk-AIB3GCQI.js} +1 -1
- package/dist/standalone/{chunk-D7B2KFWM.js → chunk-AS4WSCMT.js} +1 -1
- package/dist/standalone/{chunk-57BUSXRD.js → chunk-ATLV7KWK.js} +1 -1
- package/dist/standalone/{chunk-ZCPQGIQW.js → chunk-BAZ2VU7R.js} +1 -1
- package/dist/standalone/{chunk-2FRLB5SB.js → chunk-BG54FBTO.js} +1 -1
- package/dist/standalone/{chunk-NSUBZT43.js → chunk-BLHSTFG3.js} +1 -1
- package/dist/standalone/{chunk-TAWXVVAZ.js → chunk-BMZPRRSX.js} +1 -1
- package/dist/standalone/{chunk-ESIEIGR3.js → chunk-D34YXUQY.js} +1 -1
- package/dist/standalone/{chunk-UE6A3CRB.js → chunk-DK4J7ZBH.js} +1 -1
- package/dist/standalone/{chunk-DGO2XJOT.js → chunk-DSU54IAT.js} +1 -1
- package/dist/standalone/{chunk-YOKL7XDT.js → chunk-FKBHX7BD.js} +1 -1
- package/dist/standalone/{chunk-LZGOETI3.js → chunk-HRRFUAP6.js} +1 -1
- package/dist/standalone/{chunk-TKFI6XYV.js → chunk-II5ZTRTW.js} +1 -1
- package/dist/standalone/{chunk-7URLLMST.js → chunk-IMME7XEE.js} +1 -1
- package/dist/standalone/{chunk-U5MIBWJD.js → chunk-IXAMI2KV.js} +1 -1
- package/dist/standalone/{chunk-UZHRBXA7.js → chunk-J3Q3ESBP.js} +1 -1
- package/dist/standalone/{chunk-AQZMKZMP.js → chunk-J6PMARYI.js} +1 -1
- package/dist/standalone/{chunk-TVRCPIAV.js → chunk-JNY7CFF4.js} +1 -1
- package/dist/standalone/{chunk-WOBRLIBX.js → chunk-JR4LDDRW.js} +1 -1
- package/dist/standalone/{chunk-SFQX7RUJ.js → chunk-JZUM7FBJ.js} +1 -1
- package/dist/standalone/{chunk-3WISGFZ7.js → chunk-KBBOZRRX.js} +1 -1
- package/dist/standalone/{chunk-2NO45MRI.js → chunk-KVYAMWYX.js} +1 -1
- package/dist/standalone/{chunk-LT236J7E.js → chunk-M2M3RYJU.js} +1 -1
- package/dist/standalone/{chunk-BLJANR7J.js → chunk-MCPDCNPO.js} +1 -1
- package/dist/standalone/{chunk-2IFGRS6R.js → chunk-N6N6MMWG.js} +1 -1
- package/dist/standalone/{chunk-Q2QILUP4.js → chunk-NTAN75BV.js} +1 -1
- package/dist/standalone/{chunk-WPERYUTG.js → chunk-O36FXWMR.js} +1 -1
- package/dist/standalone/{chunk-ECF57FQF.js → chunk-O3BG6T4B.js} +1 -1
- package/dist/standalone/{chunk-U7ILDM43.js → chunk-OQIGV6FX.js} +1 -1
- package/dist/standalone/{chunk-YEGFNH56.js → chunk-P33WK7YI.js} +1 -1
- package/dist/standalone/{chunk-GL7YL3VF.js → chunk-PLFTCTMX.js} +1 -1
- package/dist/standalone/{chunk-DXJWFZFI.js → chunk-QVK5DESS.js} +1 -1
- package/dist/standalone/{chunk-HJC67CE4.js → chunk-RE7VLJ6H.js} +1 -1
- package/dist/standalone/{chunk-I7FF5IIJ.js → chunk-T2NCAYLT.js} +1 -1
- package/dist/standalone/{chunk-OZK52CH2.js → chunk-T7AVSVIA.js} +1 -1
- package/dist/standalone/{chunk-KGPNIBOV.js → chunk-T7YW6OMG.js} +1 -1
- package/dist/standalone/{chunk-BAJXBWFJ.js → chunk-TLVSMHK2.js} +1 -1
- package/dist/standalone/{chunk-QNQTMABQ.js → chunk-TMZQNRFA.js} +1 -1
- package/dist/standalone/{chunk-WQJOV6L5.js → chunk-U3Y2BI4W.js} +2 -2
- package/dist/standalone/{chunk-2YGNOZPZ.js → chunk-UE2NC2ZZ.js} +1 -1
- package/dist/standalone/{chunk-44T6NSYY.js → chunk-URCRLZN7.js} +1 -1
- package/dist/standalone/{chunk-E2C6CK7F.js → chunk-UYOSHHOV.js} +1 -1
- package/dist/standalone/{chunk-BMYWOK5Q.js → chunk-V3EN6YQV.js} +1 -1
- package/dist/standalone/{chunk-QVPKPH2T.js → chunk-V4R4HI3U.js} +1 -1
- package/dist/standalone/{chunk-CFXL7MQK.js → chunk-VKK7A4VH.js} +1 -1
- package/dist/standalone/{chunk-LZ2RREQV.js → chunk-VOYG35OH.js} +1 -1
- package/dist/standalone/{chunk-EYIEO5QZ.js → chunk-W2GXYXCQ.js} +1 -1
- package/dist/standalone/{chunk-TGQH54CS.js → chunk-WG3WC2F2.js} +1 -1
- package/dist/standalone/{chunk-34WN3PEC.js → chunk-WZXZ6YN5.js} +1 -1
- package/dist/standalone/{chunk-MVJMAEP4.js → chunk-XGL7QCYN.js} +1 -1
- package/dist/standalone/{chunk-J4POSI6T.js → chunk-XUQEE25M.js} +1 -1
- package/dist/standalone/{chunk-IGBUUFPN.js → chunk-XYENOWOR.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +6 -6
- package/dist/standalone/chunk-ETU7KIO4.js +0 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as y}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as R}from"./chunk-
|
|
1
|
+
import{b as y}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as R}from"./chunk-KBBOZRRX.js";import"./chunk-XXQUMVWH.js";import"./chunk-DSU54IAT.js";import"./chunk-QLQADHFE.js";import{a as v}from"./chunk-VDW32UET.js";import{c as $}from"./chunk-HRRFUAP6.js";import"./chunk-6FQJRXVI.js";import"./chunk-XBDKZZ67.js";import{a as S}from"./chunk-XQCVZAGU.js";import{a as A,b as I,c as j,d as x,e as n,f as c}from"./chunk-WJQLNYGX.js";import{a as k,e as w}from"./chunk-WQH3LT2P.js";import{d as b}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as f,e as N,g as _,h as D}from"./chunk-3XIESWL4.js";var T=N(_(),1);var r=N(D(),1);var E=f((e,t)=>({delete:e("Delete"),list:e("List"),read:e("Read"),write:e("Write")})[t],"E"),C={delete:2,list:3,read:0,write:1},O=f(e=>[...e].toSorted((t,a)=>t.bucket.localeCompare(a.bucket)||C[t.on]-C[a.on]||(t.prefix??"").localeCompare(a.prefix??"")),"T"),q=f(()=>{let e=(0,T.c)(14),t=b(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let{data:l,error:i,errorSource:d}=$(v.storageRules,a),h=l!==void 0,m;if(e[1]!==l||e[2]!==i||e[3]!==d||e[4]!==h||e[5]!==t){let g=O(Array.isArray(l?.rules)?l.rules:[]),u;e[7]!==i||e[8]!==d?(u=i!==null&&(0,r.jsx)(R,{error:d,testId:"storage-rules-error"}),e[7]=i,e[8]=d,e[9]=u):u=e[9];let o;e[10]!==t?(o=t("Storage rules are declared in code with defineStorageRule and gate ctx.storage access per bucket. This view is read-only."),e[10]=t,e[11]=o):o=e[11];let p;e[12]!==o?(p=(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"storage-rules-note",children:o}),e[12]=o,e[13]=p):p=e[13],m=(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-storage-rules-panel",children:[u,p,h&&g.length===0?(0,r.jsx)(S,{description:t("No defineStorageRule is wired through .use(storageRules(...)) in this deployment. Add one to gate object access by key prefix."),testId:"storage-rules-empty",title:t("No storage rules defined")}):(0,r.jsx)(k,{className:"overflow-hidden py-0",children:(0,r.jsx)(w,{className:"px-0",children:(0,r.jsxs)(A,{"data-testid":"storage-rules-table",children:[(0,r.jsx)(I,{children:(0,r.jsxs)(x,{children:[(0,r.jsx)(n,{children:t("Bucket")}),(0,r.jsx)(n,{children:t("Operation")}),(0,r.jsx)(n,{children:t("Key prefix")}),(0,r.jsx)(n,{children:t("Guarded by")})]})}),(0,r.jsx)(j,{children:g.map(s=>(0,r.jsxs)(x,{"data-testid":`storage-rule-${s.bucket}-${s.on}-${s.prefix??""}`,children:[(0,r.jsx)(c,{className:"font-mono text-xs",children:s.bucket}),(0,r.jsx)(c,{children:(0,r.jsx)(y,{variant:"secondary",children:E(t,s.on)})}),(0,r.jsx)(c,{className:"font-mono text-xs",children:s.prefix??(0,r.jsx)("span",{className:"text-muted-foreground",children:t("(whole bucket)")})}),(0,r.jsx)(c,{className:"font-mono text-xs text-muted-foreground",children:s.procedure})]},`${s.bucket}:${s.on}:${s.prefix??""}:${s.procedure}`))})]})})})]}),e[1]=l,e[2]=i,e[3]=d,e[4]=h,e[5]=t,e[6]=m}else m=e[6];return m},"W");export{q as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s}from"./chunk-
|
|
1
|
+
import{a as s}from"./chunk-HRRFUAP6.js";import{a as o}from"./chunk-3XIESWL4.js";var b="__lunora_admin__:",g=new Set(["action","mutation","query"]),u=Symbol("lunora.operationSeq"),h=o(t=>{if(typeof t!="object"||t===null)return;let e=t[u];return typeof e=="number"?e:void 0},"j"),m=o((t,e)=>{if(!(typeof t!="object"||t===null||!Object.isExtensible(t)))try{Object.defineProperty(t,u,{configurable:!0,enumerable:!1,value:e,writable:!0})}catch{}},"g"),d=o(t=>{if(typeof t!="object"||t===null)return;let e=t.__lunoraRef;return typeof e=="string"&&e.startsWith(b)?e:void 0},"d"),j=o(t=>{if(typeof t!="object"||t===null)return"";let{shardKey:e}=t;return typeof e=="string"?e:""},"m"),w=o(t=>new Proxy(t,{get(e,a,y){let i=Reflect.get(e,a,y);if(typeof i!="function"||typeof a!="string"||!g.has(a))return typeof i=="function"?i.bind(e):i;let f=i;return async(...n)=>{let l=d(n[0]);if(l===void 0)return f.apply(e,n);let p=typeof n[1]=="object"&&n[1]!==null?n[1]:{},c=s.start(l,p,j(n[2]));try{let r=await f.apply(e,n);return s.settle(c,{result:r}),r}catch(r){throw s.settle(c,{error:r instanceof Error?r.message:String(r)}),m(r,c),r}}}}),"_");export{h as a,w as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as k}from"./chunk-MLT5MMMY.js";import{a as j}from"./chunk-54MMVNPT.js";import{a as T}from"./chunk-
|
|
1
|
+
import{d as k}from"./chunk-MLT5MMMY.js";import{a as j}from"./chunk-54MMVNPT.js";import{a as T}from"./chunk-U3Y2BI4W.js";import"./chunk-SFDOII3B.js";import"./chunk-SMIESS7P.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as x}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as E}from"./chunk-KBBOZRRX.js";import"./chunk-XXQUMVWH.js";import"./chunk-DSU54IAT.js";import"./chunk-QLQADHFE.js";import{a as y}from"./chunk-VDW32UET.js";import{c as b}from"./chunk-HRRFUAP6.js";import"./chunk-6FQJRXVI.js";import"./chunk-XBDKZZ67.js";import{a as w}from"./chunk-XQCVZAGU.js";import{a as I,b as R,c as A,d as v,e as l,f as n}from"./chunk-WJQLNYGX.js";import{a as u,e as N}from"./chunk-WQH3LT2P.js";import{d as _,r as S}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as c,e as M,h as G}from"./chunk-3XIESWL4.js";var e=M(G(),1);var H=["subscriptions","events"],$={},D=new Set(["active","trialing"]),q=new Set(["past_due","unpaid"]),a=c((s,t)=>{if(s[t]!==void 0)return s[t];let m=s.__doc__;return typeof m=="string"?k(m)?.[t]:void 0},"i"),i=c(s=>typeof s=="string"?s:typeof s=="number"||typeof s=="bigint"||typeof s=="boolean"?String(s):"","s"),z=c(s=>D.has(s)?"default":q.has(s)?"destructive":"outline","L"),ae=c(({limit:s=100})=>{let t=_(),m=T(),{data:g}=b(y.listTables,$,{live:!0}),O=g!==void 0,B=Array.isArray(g)&&H.every(r=>g.some(d=>d.name===r)),p=m.payments&&B,o=b(y.readTablePage,{filters:[],limit:s,offset:0,orderBy:[],search:"",table:"subscriptions"},{enabled:p}),f=b(y.readTablePage,{filters:[],limit:25,offset:0,orderBy:[],search:"",table:"events"},{enabled:p});j(()=>{p&&(o.refetch(),f.refetch())},!0);let h=o.data?.rows??[],U=f.data?.rows??[],C=o.error??f.error,F=o.error===null?f.errorSource:o.errorSource,P=h.filter(r=>D.has(i(a(r,"state")))).length,L=U.toSorted((r,d)=>Number(a(d,"processedAt")??0)-Number(a(r,"processedAt")??0));return O&&!p?(0,e.jsx)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:(0,e.jsx)(w,{description:t("No @lunora/payment tables found in this deployment. Declare the store tables (subscriptions, events, \u2026) in lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions."),testId:"payments-unconfigured",title:t("No payments configured")})}):(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[(0,e.jsx)("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:(0,e.jsxs)(u,{className:"justify-between gap-0 py-0",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Subscriptions")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:P}),(0,e.jsx)(x,{variant:"default",children:t("{count} active",{count:P})})]})]}),(0,e.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:t("{total} total",{total:h.length})})]})}),C===null?void 0:(0,e.jsx)(E,{error:F}),h.length===0&&!o.isLoading?(0,e.jsx)(w,{testId:"payments-empty",title:t("No subscriptions yet")}):(0,e.jsx)(u,{className:"overflow-hidden py-0",children:(0,e.jsx)(N,{className:"px-0",children:(0,e.jsxs)(I,{children:[(0,e.jsx)(R,{children:(0,e.jsxs)(v,{children:[(0,e.jsx)(l,{children:t("Provider")}),(0,e.jsx)(l,{children:t("Reference")}),(0,e.jsx)(l,{children:t("Plan")}),(0,e.jsx)(l,{children:t("State")}),(0,e.jsx)(l,{children:t("Renews")})]})}),(0,e.jsx)(A,{children:h.map(r=>{let d=i(a(r,"state"));return(0,e.jsxs)(v,{"data-testid":"payment-subscription-row",children:[(0,e.jsx)(n,{children:i(a(r,"provider"))}),(0,e.jsx)(n,{children:i(a(r,"referenceId"))}),(0,e.jsx)(n,{children:i(a(r,"priceId"))}),(0,e.jsx)(n,{children:(0,e.jsx)(x,{variant:z(d),children:d})}),(0,e.jsx)(n,{children:S(a(r,"currentPeriodEnd"))})]},i(a(r,"providerSubscriptionId")))})})]})})}),(0,e.jsxs)(u,{className:"overflow-hidden py-0",children:[(0,e.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Recent webhook events")})}),(0,e.jsx)(N,{className:"px-0",children:(0,e.jsx)(I,{children:(0,e.jsx)(A,{children:L.map(r=>(0,e.jsxs)(v,{"data-testid":"payment-event-row",children:[(0,e.jsx)(n,{children:i(a(r,"provider"))}),(0,e.jsx)(n,{className:"font-medium",children:i(a(r,"type"))}),(0,e.jsx)(n,{className:"text-muted-foreground",children:i(a(r,"providerEventId"))}),(0,e.jsx)(n,{children:S(a(r,"processedAt"))})]},i(a(r,"providerEventId"))))})})})]})]})},"ae");export{ae as PaymentsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as D,c as g,d as P,f as k}from"./chunk-
|
|
1
|
+
import{b as D,c as g,d as P,f as k}from"./chunk-6FQJRXVI.js";import{f as v,g as S,h as T,o as q}from"./chunk-IUYFXK4X.js";import{a as i,e as A,f as $,g as M}from"./chunk-3XIESWL4.js";var I=A(M(),1);var f=A($(),1);var l=i(e=>typeof e=="string"?e===""?void 0:e:typeof e=="number"||typeof e=="boolean"?String(e):void 0,"u"),h=i(e=>e.filter(r=>r!==void 0).join(" "),"d"),Q={deleteRows:i(e=>h([l(e.table),Array.isArray(e.ids)?`${String(e.ids.length)} rows`:void 0]),"deleteRows"),facetColumn:i(e=>h([l(e.table),l(e.column)]),"facetColumn"),lintSql:i(()=>"sql","lintSql"),readTablePage:i(e=>h([l(e.table),Array.isArray(e.filters)&&e.filters.length>0?`${String(e.filters.length)} filters`:void 0,typeof e.search=="string"&&e.search!==""?"search":void 0,typeof e.limit=="number"?`limit ${String(e.limit)}`:void 0]),"readTablePage"),runMigration:i(e=>h([l(e.id),l(e.direction),e.dryRun===!0?"dry-run":void 0]),"runMigration"),runSql:i(e=>typeof e.sql=="string"?`${String(e.sql.length)} chars`:"","runSql"),schemaVersion:i(e=>typeof e.hash=="string"?e.hash.slice(0,8):"","schemaVersion"),writeRow:i(e=>h([l(e.table),"1 row"]),"writeRow")},E="__lunora_admin__:",C=i((e,r)=>{let s=e.startsWith(E)?e.slice(E.length):e,t=Q[s];if(t!==void 0)return t(r);let n=Object.keys(r);return n.length===0?"":n.join(", ")},"N"),L=i(e=>{if(Array.isArray(e))return e.length;if(!(typeof e!="object"||e===null)){for(let r of Object.values(e))if(Array.isArray(r))return r.length}},"K"),w=class{static{i(this,"L")}entries=[];listeners=new Set;nextSeq=1;getSnapshot=i(()=>this.entries,"getSnapshot");subscribe=i(r=>(this.listeners.add(r),()=>{this.listeners.delete(r)}),"subscribe");start(r,s,t){return this.append(r,s,t,"call","pending")}startSubscription(r,s,t){return this.append(r,s,t,"subscription","live")}recordPush(r){if(this.listeners.size===0){let s=this.entries.find(t=>t.seq===r);s!==void 0&&(s.pushes=(s.pushes??0)+1);return}this.patch(r,s=>({...s,pushes:(s.pushes??0)+1}))}failSubscription(r,s){this.patch(r,t=>({...t,error:s,status:"error"}))}endSubscription(r){this.patch(r,s=>s.status==="error"?s:{...s,durationMs:Date.now()-s.startedAt,status:"closed"})}lastErrorSeq(){return this.entries.findLast(r=>r.status==="error")?.seq}settle(r,s){this.patch(r,t=>({...t,durationMs:Date.now()-t.startedAt,...s.error===void 0?{resultCount:L(s.result),status:"ok"}:{error:s.error,status:"error"}}))}clear(){this.entries=[],this.emit()}append(r,s,t,n,a){let o=this.nextSeq;this.nextSeq+=1;let d={functionPath:r,kind:n,seq:o,shardKey:t,startedAt:Date.now(),status:a,summary:C(r,s),...n==="subscription"?{pushes:0}:{}},u=[...this.entries,d];return this.entries=u.length>300?u.slice(u.length-300):u,this.emit(),o}patch(r,s){let t=this.entries.findIndex(n=>n.seq===r);t!==-1&&(this.entries=this.entries.with(t,s(this.entries[t])),this.emit())}emit(){for(let r of this.listeners)r()}},p=new w,_=i((e,r,s)=>["lunora-admin",e,r,s.trim()],"q");function R(e,r,s={}){let{enabled:t=!0,keepPreviousData:n=!1,staleTime:a=0}=s,o=P({enabled:t,queryFn:r,placeholderData:n?D:void 0,queryKey:e,staleTime:a});return{data:o.data,error:o.error?T(o.error):o.error,errorSource:o.error??void 0,isLoading:o.isLoading,liveError:void 0,refetch:i(()=>{q(o.refetch())},"refetch")}}i(R,"M");function V(e,r,s={}){let t=k(),n=g(),{enabled:a=!0,keepPreviousData:o=!1,live:d=!1,shardKey:u="",staleTime:j}=s,m=_(e,r,u),x=R(m,()=>t.query(v(e),r,S(u)),{enabled:a,keepPreviousData:o,staleTime:j??(d?Number.POSITIVE_INFINITY:0)}),[N,y]=(0,f.useState)(void 0),O=JSON.stringify(m);return(0,f.useEffect)(()=>{if(!a||!d)return;y(void 0);let b=p.startSubscription(e,r,u),K=t.subscribe(v(e),r,c=>{p.recordPush(b),y(void 0),n.setQueryData(m,c)},{...S(u),onError:i(c=>{p.failSubscription(b,c.message),y(c.message)},"onError")});return()=>{p.endSubscription(b),K()}},[O,a,d]),{...x,liveError:a&&d?N:void 0}}i(V,"z");var U=i(()=>{let e=(0,I.c)(2),r=g(),s;return e[0]!==r?(s=i((t,n,a)=>{let o=n===void 0?["lunora-admin",t]:_(t,n,a??"");q(r.invalidateQueries({queryKey:o}))},"e"),e[0]=r,e[1]=s):s=e[1],s},"J");export{p as a,R as b,V as c,U as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as jt}from"./chunk-PKSAWP56.js";import{a as me}from"./chunk-TMGHRD6W.js";import{a as Kt,b as Lt,c as At,d as Ot,e as ot}from"./chunk-LT236J7E.js";import{a as zt}from"./chunk-QWGT25SE.js";import{e as Dt}from"./chunk-XF2B7P5A.js";import{a as It,b as Ct,c as Tt,d as Rt,e as Pe}from"./chunk-MKYEFQCA.js";import"./chunk-2PJNAWB3.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import{a as _t}from"./chunk-IGCNMZSB.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import{a as et,b as tt,c as rt,d as yt,e as Nt,f as at,g as st,h as St,i as wt}from"./chunk-U7ILDM43.js";import"./chunk-4UOFSGUS.js";import"./chunk-CZZWYUTR.js";import{a as Mt}from"./chunk-3CWGJYBB.js";import{a as $t}from"./chunk-RMN2JN4S.js";import{a as qt,b as kt}from"./chunk-GRL5MG3Z.js";import{e as ut}from"./chunk-SMIESS7P.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{c as Ze}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as Be}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import"./chunk-QLQADHFE.js";import{a as Le}from"./chunk-VDW32UET.js";import{c as je}from"./chunk-LZGOETI3.js";import{f as mt}from"./chunk-ETU7KIO4.js";import"./chunk-XBDKZZ67.js";import{a as ft}from"./chunk-XQCVZAGU.js";import{a as lt,b as nt,c as it,d as Ee,e as ce,f as B}from"./chunk-WJQLNYGX.js";import{a as fe,b as Ae,c as Oe,d as gt,e as pe}from"./chunk-WQH3LT2P.js";import{d as ge,f as pt,g as xt,h as bt,i as vt,l as Ge,o as Ue}from"./chunk-IUYFXK4X.js";import"./chunk-YEGFNH56.js";import{a as o,e as Ye,f as Ft,g as Jt,h as Ht,j as ht}from"./chunk-3XIESWL4.js";var P=Ye(Ft(),1);var xe=Ye(Jt(),1);var t=Ye(Ht(),1);var Wt=o((s,e)=>s<e?-1:s>e?1:0,"Jt"),ct=o(s=>{if(s===void 0)return"null";if(typeof s=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key \u2014 pass it as a string, or use stableWireKey");if(s===null||typeof s!="object")return JSON.stringify(s);if(Array.isArray(s))return`[${s.map(c=>ct(c)).join(",")}]`;let e=Object.getPrototypeOf(s);if(e!==null&&e!==Object.prototype){let c=s.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${c} in a stable JSON cache key \u2014 only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}let l=s,a=Object.keys(l).toSorted(Wt),r=[];for(let c of a){let i=l[c];i!==void 0&&r.push(`${JSON.stringify(c)}:${ct(i)}`)}return`{${r.join(",")}}`},"Ze"),Pt=o((s,e,l)=>`${s}:${e}:${ct(l??{})}`,"gt"),Qt=o((s,e)=>s==="gauge"?e.last:s==="histogram"?e.sum/Math.max(1,e.count):e.sum,"ft"),Bt=o((s,e)=>Qt(s,e),"Ht"),Gt=o(s=>Qt(s.kind,s),"Gt"),dt=o(s=>Number.isInteger(s)?s.toLocaleString():s.toLocaleString(void 0,{maximumFractionDigits:2}),"Xe"),Vt=o(s=>Array.isArray(s?.series)?s.series:[],"Wt"),Xt="FUNCTION_NOT_FOUND",Yt=o(s=>{let e=new Map;if(!Array.isArray(s?.series))return e;for(let l of s.series)e.set(Pt(l.kind,l.name,l.attributes),l.points);return e},"Yt"),Zt={counter:"secondary",gauge:"default",histogram:"outline"},Ut=o(s=>{let e=(0,xe.c)(18),{name:l,onOpenTrace:a,traceId:r}=s,c=ge();if(r===void 0){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),e[0]=u):u=e[0],u}let i;e[1]!==r?(i=r.slice(0,8),e[1]=r,e[2]=i):i=e[2];let n=i;if(a===void 0){let u=`mt-instrument-trace-${l}`,h;return e[3]!==n||e[4]!==u||e[5]!==r?(h=(0,t.jsx)("span",{className:"text-muted-foreground","data-testid":u,title:r,children:n}),e[3]=n,e[4]=u,e[5]=r,e[6]=h):h=e[6],h}let $=`mt-instrument-trace-${l}`,f;e[7]!==a||e[8]!==r?(f=o(()=>{a(r)},"f"),e[7]=a,e[8]=r,e[9]=f):f=e[9];let S;e[10]!==c||e[11]!==r?(S=c("Open the exemplar trace {trace}",{trace:r}),e[10]=c,e[11]=r,e[12]=S):S=e[12];let p;return e[13]!==n||e[14]!==$||e[15]!==f||e[16]!==S?(p=(0,t.jsx)("button",{className:"text-primary underline-offset-4 hover:underline","data-testid":$,onClick:f,title:S,type:"button",children:n}),e[13]=n,e[14]=$,e[15]=f,e[16]=S,e[17]=p):p=e[17],p},"Zt"),er=o(s=>{let e=(0,xe.c)(105),{onOpenTrace:l,shardKey:a}=s,r=ge(),c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={},e[0]=c):c=e[0];let i;e[1]!==a?(i={live:!0,shardKey:a},e[1]=a,e[2]=i):i=e[2];let{data:n,error:$,errorSource:f}=je(Le.getMetricSeries,c,i),S;e[3]===Symbol.for("react.memo_cache_sentinel")?(S={},e[3]=S):S=e[3];let p;e[4]!==a?(p={live:!0,shardKey:a},e[4]=a,e[5]=p):p=e[5];let{data:u}=je(Le.getMetricHistory,S,p),h,M,b,w,_,d,g,x,q,k,y,D,I;if(e[6]!==n||e[7]!==$||e[8]!==f||e[9]!==u||e[10]!==l||e[11]!==r){x=Symbol.for("react.early_return_sentinel");e:{let A=Vt(n),j=vt(f)===Xt;if($!==null&&!j){let m;e[25]!==r?(m=r("Instruments"),e[25]=r,e[26]=m):m=e[26];let E;e[27]!==m?(E=(0,t.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:m}),e[27]=m,e[28]=E):E=e[28];let Q;e[29]!==$||e[30]!==r?(Q=r("Instruments unavailable: {error}",{error:$}),e[29]=$,e[30]=r,e[31]=Q):Q=e[31];let F;e[32]!==Q?(F=(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":"mt-instruments-error",role:"status",children:Q}),e[32]=Q,e[33]=F):F=e[33];let de;e[34]!==E||e[35]!==F?(de=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"mt-instruments",children:[E,F]}),e[34]=E,e[35]=F,e[36]=de):de=e[36],x=de;break e}if(A.length===0){x=null;break e}let J=Yt(u),K;e[37]!==r?(K=o(m=>r(m==="counter"?"Counter":m==="gauge"?"Gauge":"Histogram"),"L"),e[37]=r,e[38]=K):K=e[38];let H=K;_="flex flex-col gap-2",d="mt-instruments";let L;e[39]!==r?(L=r("Instruments"),e[39]=r,e[40]=L):L=e[40],e[41]!==L?(g=(0,t.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:L}),e[41]=L,e[42]=g):g=e[42],w=fe,I="overflow-hidden py-0",b=pe,D="px-0",M=lt,k="mt-instruments-table";let O;e[43]!==r?(O=r("name"),e[43]=r,e[44]=O):O=e[44];let G;e[45]!==O?(G=(0,t.jsx)(ce,{children:O}),e[45]=O,e[46]=G):G=e[46];let V;e[47]!==r?(V=r("kind"),e[47]=r,e[48]=V):V=e[48];let X;e[49]!==V?(X=(0,t.jsx)(ce,{children:V}),e[49]=V,e[50]=X):X=e[50];let Y;e[51]!==r?(Y=r("value"),e[51]=r,e[52]=Y):Y=e[52];let Z;e[53]!==Y?(Z=(0,t.jsx)(ce,{className:"text-right",children:Y}),e[53]=Y,e[54]=Z):Z=e[54];let U;e[55]!==r?(U=r("count"),e[55]=r,e[56]=U):U=e[56];let ee;e[57]!==U?(ee=(0,t.jsx)(ce,{className:"text-right",children:U}),e[57]=U,e[58]=ee):ee=e[58];let te;e[59]!==r?(te=r("range"),e[59]=r,e[60]=te):te=e[60];let re;e[61]!==te?(re=(0,t.jsx)(ce,{className:"text-right",children:te}),e[61]=te,e[62]=re):re=e[62];let ae;e[63]!==r?(ae=r("trend"),e[63]=r,e[64]=ae):ae=e[64];let se;e[65]!==ae?(se=(0,t.jsx)(ce,{children:ae}),e[65]=ae,e[66]=se):se=e[66];let le;e[67]!==r?(le=r("trace"),e[67]=r,e[68]=le):le=e[68];let ne;e[69]!==le?(ne=(0,t.jsx)(ce,{children:le}),e[69]=le,e[70]=ne):ne=e[70];let ie;e[71]!==r?(ie=r("dimensions"),e[71]=r,e[72]=ie):ie=e[72];let oe;e[73]!==ie?(oe=(0,t.jsx)(ce,{children:ie}),e[73]=ie,e[74]=oe):oe=e[74],e[75]!==G||e[76]!==X||e[77]!==Z||e[78]!==ee||e[79]!==re||e[80]!==se||e[81]!==ne||e[82]!==oe?(y=(0,t.jsx)(nt,{children:(0,t.jsxs)(Ee,{children:[G,X,Z,ee,re,se,ne,oe]})}),e[75]=G,e[76]=X,e[77]=Z,e[78]=ee,e[79]=re,e[80]=se,e[81]=ne,e[82]=oe,e[83]=y):y=e[83],h=it,q=A.map(m=>{let E=zt(m.attributes),Q=Pt(m.kind,m.name,m.attributes),F=(J.get(Q)??[]).map(de=>Bt(m.kind,de));return(0,t.jsxs)(Ee,{"data-testid":`mt-instrument-${m.name}`,children:[(0,t.jsx)(B,{className:"font-mono text-xs",title:m.functionPath,children:m.name}),(0,t.jsx)(B,{children:(0,t.jsx)(Be,{variant:Zt[m.kind],children:H(m.kind)})}),(0,t.jsx)(B,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${m.name}`,children:dt(Gt(m))}),(0,t.jsx)(B,{className:"text-right tabular-nums text-muted-foreground",children:m.count.toLocaleString()}),(0,t.jsx)(B,{className:"text-right font-mono text-xs tabular-nums text-muted-foreground",children:m.min===m.max?"\u2014":`${dt(m.min)}\u2013${dt(m.max)}`}),(0,t.jsx)(B,{children:F.length>=2?(0,t.jsx)(ot,{ariaLabel:r("{name} trend",{name:m.name}),className:"h-6 w-24 text-foreground",series:F,testId:`mt-instrument-trend-${m.name}`}):(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"\u2014"})}),(0,t.jsx)(B,{className:"font-mono text-xs",children:(0,t.jsx)(Ut,{name:m.name,onOpenTrace:l,traceId:m.exemplarTraceId})}),(0,t.jsx)(B,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:E,children:E===""?"\u2014":E})]},Q)})}e[6]=n,e[7]=$,e[8]=f,e[9]=u,e[10]=l,e[11]=r,e[12]=h,e[13]=M,e[14]=b,e[15]=w,e[16]=_,e[17]=d,e[18]=g,e[19]=x,e[20]=q,e[21]=k,e[22]=y,e[23]=D,e[24]=I}else h=e[12],M=e[13],b=e[14],w=e[15],_=e[16],d=e[17],g=e[18],x=e[19],q=e[20],k=e[21],y=e[22],D=e[23],I=e[24];if(x!==Symbol.for("react.early_return_sentinel"))return x;let C;e[84]!==h||e[85]!==q?(C=(0,t.jsx)(h,{children:q}),e[84]=h,e[85]=q,e[86]=C):C=e[86];let T;e[87]!==M||e[88]!==C||e[89]!==k||e[90]!==y?(T=(0,t.jsxs)(M,{"data-testid":k,children:[y,C]}),e[87]=M,e[88]=C,e[89]=k,e[90]=y,e[91]=T):T=e[91];let N;e[92]!==b||e[93]!==T||e[94]!==D?(N=(0,t.jsx)(b,{className:D,children:T}),e[92]=b,e[93]=T,e[94]=D,e[95]=N):N=e[95];let v;e[96]!==w||e[97]!==N||e[98]!==I?(v=(0,t.jsx)(w,{className:I,children:N}),e[96]=w,e[97]=N,e[98]=I,e[99]=v):v=e[99];let z;return e[100]!==_||e[101]!==d||e[102]!==g||e[103]!==v?(z=(0,t.jsxs)("section",{className:_,"data-testid":d,children:[g,v]}),e[100]=_,e[101]=d,e[102]=g,e[103]=v,e[104]=z):z=e[104],z},"er"),tr=o(s=>{let e=(0,xe.c)(74),{aggregate:l,shardResults:a}=s,r=ge(),c;e[0]!==r?(c=r("Shards"),e[0]=r,e[1]=c):c=e[1];let i;e[2]!==l.failed||e[3]!==l.reachable||e[4]!==r?(i=l.failed>0?r("{reachable} reachable, {failed} unreachable",{failed:l.failed,reachable:l.reachable}):r("{reachable} reachable",{reachable:l.reachable}),e[2]=l.failed,e[3]=l.reachable,e[4]=r,e[5]=i):i=e[5];let n;e[6]!==c||e[7]!==i?(n=(0,t.jsx)(me,{label:c,testId:"mt-agg-shards",value:i}),e[6]=c,e[7]=i,e[8]=n):n=e[8];let $;e[9]!==r?($=r("Total requests"),e[9]=r,e[10]=$):$=e[10];let f;e[11]!==l.totalRequests||e[12]!==$?(f=(0,t.jsx)(me,{label:$,testId:"mt-agg-requests",value:l.totalRequests}),e[11]=l.totalRequests,e[12]=$,e[13]=f):f=e[13];let S;e[14]!==r?(S=r("Total errors"),e[14]=r,e[15]=S):S=e[15];let p;e[16]!==l.totalErrors||e[17]!==S?(p=(0,t.jsx)(me,{label:S,testId:"mt-agg-errors",value:l.totalErrors}),e[16]=l.totalErrors,e[17]=S,e[18]=p):p=e[18];let u;e[19]!==r?(u=r("Total database size"),e[19]=r,e[20]=u):u=e[20];let h;e[21]!==l.totalDatabaseSize?(h=Ge(l.totalDatabaseSize),e[21]=l.totalDatabaseSize,e[22]=h):h=e[22];let M;e[23]!==u||e[24]!==h?(M=(0,t.jsx)(me,{label:u,testId:"mt-agg-db-size",value:h}),e[23]=u,e[24]=h,e[25]=M):M=e[25];let b;e[26]!==r?(b=r("Combined cache hit rate"),e[26]=r,e[27]=b):b=e[27];let w;e[28]!==l.hitRate||e[29]!==r?(w=l.hitRate===null?r("no cache configured"):`${(l.hitRate*100).toFixed(1)}%`,e[28]=l.hitRate,e[29]=r,e[30]=w):w=e[30];let _;e[31]!==b||e[32]!==w?(_=(0,t.jsx)(me,{label:b,testId:"mt-agg-cache",value:w}),e[31]=b,e[32]=w,e[33]=_):_=e[33];let d;e[34]!==M||e[35]!==_||e[36]!==n||e[37]!==f||e[38]!==p?(d=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[n,f,p,M,_]}),e[34]=M,e[35]=_,e[36]=n,e[37]=f,e[38]=p,e[39]=d):d=e[39];let g;e[40]!==r?(g=r("shard"),e[40]=r,e[41]=g):g=e[41];let x;e[42]!==g?(x=(0,t.jsx)(ce,{children:g}),e[42]=g,e[43]=x):x=e[43];let q;e[44]!==r?(q=r("requests"),e[44]=r,e[45]=q):q=e[45];let k;e[46]!==q?(k=(0,t.jsx)(ce,{children:q}),e[46]=q,e[47]=k):k=e[47];let y;e[48]!==r?(y=r("errors"),e[48]=r,e[49]=y):y=e[49];let D;e[50]!==y?(D=(0,t.jsx)(ce,{children:y}),e[50]=y,e[51]=D):D=e[51];let I;e[52]!==r?(I=r("db size"),e[52]=r,e[53]=I):I=e[53];let C;e[54]!==I?(C=(0,t.jsx)(ce,{children:I}),e[54]=I,e[55]=C):C=e[55];let T;e[56]!==x||e[57]!==k||e[58]!==D||e[59]!==C?(T=(0,t.jsx)(nt,{children:(0,t.jsxs)(Ee,{children:[x,k,D,C]})}),e[56]=x,e[57]=k,e[58]=D,e[59]=C,e[60]=T):T=e[60];let N;if(e[61]!==a||e[62]!==r){let j;e[64]!==r?(j=o(J=>(0,t.jsxs)(Ee,{"data-testid":`mt-agg-row-${J.shard}`,children:[(0,t.jsx)(B,{children:J.shard}),J.metrics===null?(0,t.jsx)(B,{className:"text-destructive",colSpan:3,children:J.error??r("unreachable")}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(B,{className:"tabular-nums",children:J.metrics.requests}),(0,t.jsx)(B,{className:"tabular-nums",children:J.metrics.errors}),(0,t.jsx)(B,{className:"tabular-nums",children:Ge(J.metrics.databaseSize)})]})]},J.shard),"K"),e[64]=r,e[65]=j):j=e[65],N=a.map(j),e[61]=a,e[62]=r,e[63]=N}else N=e[63];let v;e[66]!==N?(v=(0,t.jsx)(it,{children:N}),e[66]=N,e[67]=v):v=e[67];let z;e[68]!==T||e[69]!==v?(z=(0,t.jsx)(fe,{className:"overflow-hidden py-0",children:(0,t.jsx)(pe,{className:"px-0",children:(0,t.jsxs)(lt,{"data-testid":"mt-agg-table",children:[T,v]})})}),e[68]=T,e[69]=v,e[70]=z):z=e[70];let A;return e[71]!==d||e[72]!==z?(A=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[d,z]}),e[71]=d,e[72]=z,e[73]=A):A=e[73],A},"tr"),rr=o(s=>{let e=Math.floor(s/1e3),l=Math.floor(e/3600),a=Math.floor(e%3600/60),r=e%60;return l>0?`${l.toString()}h ${a.toString()}m`:a>0?`${a.toString()}m ${r.toString()}s`:`${r.toString()}s`},"rr"),ar=o((s,e)=>{let l=s+e;return l===0?"\u2014":`${(s/l*100).toFixed(1)}%`},"ar"),Et=o(s=>s<=0?"\u2014":s<1?`${(s*1e3).toFixed(0)}\u03BCs`:s<1e3?`${s.toFixed(1)}ms`:`${(s/1e3).toFixed(2)}s`,"ct"),sr=o(s=>{let e=(0,xe.c)(75),{currentDelta:l,errorRate:a,history:r,latencyPercentiles:c,metrics:i}=s,n=ge(),$;e[0]!==r||e[1]!==n?($=r.length>=2?(0,t.jsx)(ot,{ariaLabel:n("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:r,testId:"mt-sparkline"}):void 0,e[0]=r,e[1]=n,e[2]=$):$=e[2];let f;e[3]!==l||e[4]!==r.length||e[5]!==n?(f=r.length>=2?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"font-semibold text-foreground",children:`+${l.toLocaleString()}`})," ",n("last interval")]}):(0,t.jsx)("span",{"data-testid":"mt-sparkline-empty",children:n("collecting samples\u2026")}),e[3]=l,e[4]=r.length,e[5]=n,e[6]=f):f=e[6];let S;e[7]!==n?(S=n("Requests"),e[7]=n,e[8]=S):S=e[8];let p;e[9]!==i.requests||e[10]!==$||e[11]!==f||e[12]!==S?(p=(0,t.jsx)(me,{chart:$,footer:f,label:S,testId:"mt-requests",value:i.requests}),e[9]=i.requests,e[10]=$,e[11]=f,e[12]=S,e[13]=p):p=e[13];let u;e[14]!==a||e[15]!==n?(u=n("{rate} error rate",{rate:a}),e[14]=a,e[15]=n,e[16]=u):u=e[16];let h;e[17]!==n?(h=n("Errors"),e[17]=n,e[18]=h):h=e[18];let M;e[19]!==a||e[20]!==i.errors?(M=(0,t.jsxs)(t.Fragment,{children:[i.errors," (",a,")"]}),e[19]=a,e[20]=i.errors,e[21]=M):M=e[21];let b;e[22]!==u||e[23]!==h||e[24]!==M?(b=(0,t.jsx)(me,{footer:u,label:h,testId:"mt-errors",value:M}),e[22]=u,e[23]=h,e[24]=M,e[25]=b):b=e[25];let w;e[26]!==c.p90?(w=c.p90>0?`P90 ${Et(c.p90)}`:void 0,e[26]=c.p90,e[27]=w):w=e[27];let _;e[28]!==n?(_=n("P95 latency"),e[28]=n,e[29]=_):_=e[29];let d;e[30]!==c.p95?(d=c.p95>0?Et(c.p95):"\u2014",e[30]=c.p95,e[31]=d):d=e[31];let g;e[32]!==_||e[33]!==d||e[34]!==w?(g=(0,t.jsx)(me,{footer:w,label:_,testId:"mt-p95",value:d}),e[32]=_,e[33]=d,e[34]=w,e[35]=g):g=e[35];let x;e[36]!==i.cache||e[37]!==n?(x=i.cache===null?void 0:`${i.cache.entries.toLocaleString()} ${n("cache entries")}`,e[36]=i.cache,e[37]=n,e[38]=x):x=e[38];let q;e[39]!==n?(q=n("Database size"),e[39]=n,e[40]=q):q=e[40];let k;e[41]!==i.databaseSize?(k=Ge(i.databaseSize),e[41]=i.databaseSize,e[42]=k):k=e[42];let y;e[43]!==x||e[44]!==q||e[45]!==k?(y=(0,t.jsx)(me,{footer:x,label:q,testId:"mt-db-size",value:k}),e[43]=x,e[44]=q,e[45]=k,e[46]=y):y=e[46];let D;e[47]!==n?(D=n("Shard"),e[47]=n,e[48]=D):D=e[48];let I;e[49]!==i.shard||e[50]!==D?(I=(0,t.jsx)(me,{label:D,testId:"mt-shard",value:i.shard}),e[49]=i.shard,e[50]=D,e[51]=I):I=e[51];let C;e[52]!==n?(C=n("Uptime"),e[52]=n,e[53]=C):C=e[53];let T;e[54]!==i.uptimeMs?(T=rr(i.uptimeMs),e[54]=i.uptimeMs,e[55]=T):T=e[55];let N;e[56]!==C||e[57]!==T?(N=(0,t.jsx)(me,{label:C,testId:"mt-uptime",value:T}),e[56]=C,e[57]=T,e[58]=N):N=e[58];let v;e[59]!==n?(v=n("Cache hit rate"),e[59]=n,e[60]=v):v=e[60];let z;e[61]!==i.cache||e[62]!==n?(z=i.cache===null?n("no cache configured"):n("{rate} ({count} entries)",{count:i.cache.entries,rate:ar(i.cache.hits,i.cache.misses)}),e[61]=i.cache,e[62]=n,e[63]=z):z=e[63];let A;e[64]!==v||e[65]!==z?(A=(0,t.jsx)(me,{label:v,testId:"mt-cache",value:z}),e[64]=v,e[65]=z,e[66]=A):A=e[66];let j;return e[67]!==g||e[68]!==y||e[69]!==I||e[70]!==N||e[71]!==A||e[72]!==p||e[73]!==b?(j=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[p,b,g,y,I,N,A]}),e[67]=g,e[68]=y,e[69]=I,e[70]=N,e[71]=A,e[72]=p,e[73]=b,e[74]=j):j=e[74],j},"lr"),Xe=o(s=>s>=100?"critical":s>=50?"warning":"good","Ge"),Qe=o(s=>s<1?`${(s*1e3).toFixed(0)}\u03BCs`:s<1e3?`${s.toFixed(1)}ms`:`${(s/1e3).toFixed(2)}s`,"Oe"),Ve=o(s=>s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString(),"Be"),lr=o(s=>{let e=(0,xe.c)(3),{level:l}=s;if(l==="critical"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(Be,{variant:"destructive",children:"Slow"}),e[0]=r):r=e[0],r}if(l==="warning"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)("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]=r):r=e[1],r}let a;return e[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)("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]=a):a=e[2],a},"sr"),nr=o((s,e)=>{let l=[...s];return l.sort((a,r)=>{switch(e){case"avgTime":return r.avgDurationMs-a.avgDurationMs;case"execCount":return r.execCount-a.execCount;case"rowsRead":return r.rowsRead-a.rowsRead;default:return r.totalDurationMs-a.totalDurationMs}}),l},"nr"),ir=o(s=>{let e=(0,xe.c)(161),{queryStats:l}=s,a=ge(),[r,c]=(0,P.useState)("totalTime"),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=new Set,e[0]=i):i=e[0];let[n,$]=(0,P.useState)(i),f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=o(I=>{I!==null&&c(I)},"f"),e[1]=f):f=e[1];let S=f,p,u,h,M,b,w,_,d,g,x;if(e[2]!==n||e[3]!==l||e[4]!==r||e[5]!==a){h=Symbol.for("react.early_return_sentinel");e:{let I=nr(l,r),C;e[16]!==l?(C=l.filter(or),e[16]=l,e[17]=C):C=e[17];let T=C.length,N;e[18]!==l?(N=l.filter(dr),e[18]=l,e[19]=N):N=e[19];let v=N.length,z;e[20]!==l?(z=l.filter(cr),e[20]=l,e[21]=z):z=e[21];let A=z.length,j;e[22]===Symbol.for("react.memo_cache_sentinel")?(j=o(R=>{$(ue=>{let W=new Set(ue);return W.has(R)?W.delete(R):W.add(R),W})},"K"),e[22]=j):j=e[22];let J=j;if(l.length===0){let R;e[23]!==a?(R=a("No query insights yet"),e[23]=a,e[24]=R):R=e[24];let ue;e[25]!==R?(ue=(0,t.jsx)("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:R}),e[25]=R,e[26]=ue):ue=e[26];let W;e[27]!==a?(W=a("Query insights appear once statements are executed against this shard."),e[27]=a,e[28]=W):W=e[28];let he;e[29]!==W?(he=(0,t.jsx)("p",{className:"mt-1 text-sm",children:W}),e[29]=W,e[30]=he):he=e[30];let We;e[31]!==ue||e[32]!==he?(We=(0,t.jsx)(fe,{children:(0,t.jsx)(pe,{className:"py-12",children:(0,t.jsxs)("div",{className:"text-center text-muted-foreground",children:[ue,he]})})}),e[31]=ue,e[32]=he,e[33]=We):We=e[33],h=We;break e}_="space-y-4",d="qi-root";let K;e[34]!==a?(K=a("Critical queries"),e[34]=a,e[35]=K):K=e[35];let H;e[36]!==K?(H=(0,t.jsx)(Ae,{className:"pb-2",children:(0,t.jsx)(Oe,{className:"text-sm font-medium",children:K})}),e[36]=K,e[37]=H):H=e[37];let L;e[38]!==T?(L=(0,t.jsx)("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:T}),e[38]=T,e[39]=L):L=e[39];let O;e[40]!==a?(O=a(">100ms avg execution"),e[40]=a,e[41]=O):O=e[41];let G;e[42]!==O?(G=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:O}),e[42]=O,e[43]=G):G=e[43];let V;e[44]!==L||e[45]!==G?(V=(0,t.jsxs)(pe,{children:[L,G]}),e[44]=L,e[45]=G,e[46]=V):V=e[46];let X;e[47]!==H||e[48]!==V?(X=(0,t.jsxs)(fe,{children:[H,V]}),e[47]=H,e[48]=V,e[49]=X):X=e[49];let Y;e[50]!==a?(Y=a("Moderate queries"),e[50]=a,e[51]=Y):Y=e[51];let Z;e[52]!==Y?(Z=(0,t.jsx)(Ae,{className:"pb-2",children:(0,t.jsx)(Oe,{className:"text-sm font-medium",children:Y})}),e[52]=Y,e[53]=Z):Z=e[53];let U;e[54]!==v?(U=(0,t.jsx)("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:v}),e[54]=v,e[55]=U):U=e[55];let ee;e[56]!==a?(ee=a("50\u2013100ms avg execution"),e[56]=a,e[57]=ee):ee=e[57];let te;e[58]!==ee?(te=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:ee}),e[58]=ee,e[59]=te):te=e[59];let re;e[60]!==U||e[61]!==te?(re=(0,t.jsxs)(pe,{children:[U,te]}),e[60]=U,e[61]=te,e[62]=re):re=e[62];let ae;e[63]!==Z||e[64]!==re?(ae=(0,t.jsxs)(fe,{children:[Z,re]}),e[63]=Z,e[64]=re,e[65]=ae):ae=e[65];let se;e[66]!==a?(se=a("Fast queries"),e[66]=a,e[67]=se):se=e[67];let le;e[68]!==se?(le=(0,t.jsx)(Ae,{className:"pb-2",children:(0,t.jsx)(Oe,{className:"text-sm font-medium",children:se})}),e[68]=se,e[69]=le):le=e[69];let ne;e[70]!==A?(ne=(0,t.jsx)("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:A}),e[70]=A,e[71]=ne):ne=e[71];let ie;e[72]!==a?(ie=a("<50ms avg execution"),e[72]=a,e[73]=ie):ie=e[73];let oe;e[74]!==ie?(oe=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:ie}),e[74]=ie,e[75]=oe):oe=e[75];let m;e[76]!==ne||e[77]!==oe?(m=(0,t.jsxs)(pe,{children:[ne,oe]}),e[76]=ne,e[77]=oe,e[78]=m):m=e[78];let E;e[79]!==le||e[80]!==m?(E=(0,t.jsxs)(fe,{children:[le,m]}),e[79]=le,e[80]=m,e[81]=E):E=e[81],e[82]!==X||e[83]!==ae||e[84]!==E?(g=(0,t.jsxs)("div",{className:"grid gap-4 md:grid-cols-3",children:[X,ae,E]}),e[82]=X,e[83]=ae,e[84]=E,e[85]=g):g=e[85];let Q;e[86]!==a?(Q=a("Query leaderboard"),e[86]=a,e[87]=Q):Q=e[87];let F;e[88]!==Q?(F=(0,t.jsx)("h3",{className:"text-lg font-semibold",children:Q}),e[88]=Q,e[89]=F):F=e[89];let de;e[90]!==r||e[91]!==a?(de=a("Slow queries sorted by {sortField}",{sortField:a(r)}),e[90]=r,e[91]=a,e[92]=de):de=e[92];let be;e[93]!==de?(be=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:de}),e[93]=de,e[94]=be):be=e[94];let ve;e[95]!==F||e[96]!==be?(ve=(0,t.jsxs)("div",{children:[F,be]}),e[95]=F,e[96]=be,e[97]=ve):ve=e[97];let ye;e[98]!==a?(ye=a("Sort by"),e[98]=a,e[99]=ye):ye=e[99];let Ne;e[100]!==ye?(Ne=(0,t.jsx)("span",{className:"text-sm text-muted-foreground",children:ye}),e[100]=ye,e[101]=Ne):Ne=e[101];let Se;e[102]!==a?(Se=a("Sort queries by"),e[102]=a,e[103]=Se):Se=e[103];let Fe;e[104]===Symbol.for("react.memo_cache_sentinel")?(Fe=(0,t.jsx)(Ct,{}),e[104]=Fe):Fe=e[104];let we;e[105]!==Se?(we=(0,t.jsx)(Tt,{"aria-label":Se,className:"w-[140px]","data-testid":"qi-sort",children:Fe}),e[105]=Se,e[106]=we):we=e[106];let qe;e[107]!==a?(qe=a("Total time"),e[107]=a,e[108]=qe):qe=e[108];let ke;e[109]!==qe?(ke=(0,t.jsx)(Pe,{value:"totalTime",children:qe}),e[109]=qe,e[110]=ke):ke=e[110];let $e;e[111]!==a?($e=a("Avg time"),e[111]=a,e[112]=$e):$e=e[112];let Me;e[113]!==$e?(Me=(0,t.jsx)(Pe,{value:"avgTime",children:$e}),e[113]=$e,e[114]=Me):Me=e[114];let _e;e[115]!==a?(_e=a("Execution count"),e[115]=a,e[116]=_e):_e=e[116];let De;e[117]!==_e?(De=(0,t.jsx)(Pe,{value:"execCount",children:_e}),e[117]=_e,e[118]=De):De=e[118];let Ie;e[119]!==a?(Ie=a("Rows read"),e[119]=a,e[120]=Ie):Ie=e[120];let Ce;e[121]!==Ie?(Ce=(0,t.jsx)(Pe,{value:"rowsRead",children:Ie}),e[121]=Ie,e[122]=Ce):Ce=e[122];let Te;e[123]!==ke||e[124]!==Me||e[125]!==De||e[126]!==Ce?(Te=(0,t.jsxs)(Rt,{children:[ke,Me,De,Ce]}),e[123]=ke,e[124]=Me,e[125]=De,e[126]=Ce,e[127]=Te):Te=e[127];let Re;e[128]!==r||e[129]!==we||e[130]!==Te?(Re=(0,t.jsxs)(It,{onValueChange:S,value:r,children:[we,Te]}),e[128]=r,e[129]=we,e[130]=Te,e[131]=Re):Re=e[131];let ze;e[132]!==Ne||e[133]!==Re?(ze=(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[Ne,Re]}),e[132]=Ne,e[133]=Re,e[134]=ze):ze=e[134],e[135]!==ve||e[136]!==ze?(x=(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[ve,ze]}),e[135]=ve,e[136]=ze,e[137]=x):x=e[137],u=fe;let Ke;e[138]!==a?(Ke=a("Statements"),e[138]=a,e[139]=Ke):Ke=e[139];let Je;e[140]!==Ke?(Je=(0,t.jsx)(Oe,{children:Ke}),e[140]=Ke,e[141]=Je):Je=e[141],w=(0,t.jsxs)(Ae,{children:[Je,(0,t.jsx)(gt,{children:a("{count} tracked statements",{count:I.length})})]}),p=pe,M="space-y-2";let He;e[142]!==n||e[143]!==a?(He=o(R=>{let ue=R.normalizedSql,W=n.has(ue),he=Xe(R.avgDurationMs);return(0,t.jsxs)("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[(0,t.jsxs)("button",{"aria-expanded":W,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:o(()=>{J(ue)},"onClick"),type:"button",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[(0,t.jsx)(lr,{level:he}),(0,t.jsx)("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:R.normalizedSql})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-4",children:[(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:Qe(R.totalDurationMs)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("total")})]}),(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:Qe(R.avgDurationMs)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("avg")})]}),R.p95DurationMs!==void 0&&(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:Qe(R.p95DurationMs)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("p95")})]}),(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:Ve(R.execCount)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("calls")})]})]})]}),W&&(0,t.jsxs)("div",{className:"space-y-3 border-t bg-muted/30 p-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-2 text-sm font-medium",children:a("Full statement")}),(0,t.jsx)("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:R.normalizedSql})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[R.p50DurationMs!==void 0&&(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("p50")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:Qe(R.p50DurationMs)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Exec count")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:Ve(R.execCount)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Total time")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:Qe(R.totalDurationMs)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Rows read")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:Ve(R.rowsRead)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Rows written")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:Ve(R.rowsWritten)})]})]})]})]},ue)},"Ee"),e[142]=n,e[143]=a,e[144]=He):He=e[144],b=I.map(He)}e[2]=n,e[3]=l,e[4]=r,e[5]=a,e[6]=p,e[7]=u,e[8]=h,e[9]=M,e[10]=b,e[11]=w,e[12]=_,e[13]=d,e[14]=g,e[15]=x}else p=e[6],u=e[7],h=e[8],M=e[9],b=e[10],w=e[11],_=e[12],d=e[13],g=e[14],x=e[15];if(h!==Symbol.for("react.early_return_sentinel"))return h;let q;e[145]!==M||e[146]!==b?(q=(0,t.jsx)("div",{className:M,children:b}),e[145]=M,e[146]=b,e[147]=q):q=e[147];let k;e[148]!==p||e[149]!==q?(k=(0,t.jsx)(p,{children:q}),e[148]=p,e[149]=q,e[150]=k):k=e[150];let y;e[151]!==u||e[152]!==k||e[153]!==w?(y=(0,t.jsxs)(u,{children:[w,k]}),e[151]=u,e[152]=k,e[153]=w,e[154]=y):y=e[154];let D;return e[155]!==y||e[156]!==_||e[157]!==d||e[158]!==g||e[159]!==x?(D=(0,t.jsxs)("div",{className:_,"data-testid":d,children:[g,x,y]}),e[155]=y,e[156]=_,e[157]=d,e[158]=g,e[159]=x,e[160]=D):D=e[160],D},"ir");function or(s){return Xe(s.avgDurationMs)==="critical"}o(or,"or");function dr(s){return Xe(s.avgDurationMs)==="warning"}o(dr,"cr");function cr(s){return Xe(s.avgDurationMs)==="good"}o(cr,"dr");var mr=["1m","5m","15m","1h"],ur=o(s=>new Date(s).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),"ur"),hr=o(s=>s.map(e=>({avg:Math.round(e.avgDurationMs*100)/100,execs:e.execCount,label:ur(e.bucketMs)})),"hr"),gr=o(({shardKey:s=""})=>{let e=ge(),[l,a]=(0,P.useState)("15m"),r=je(Le.getQueryInsights,{range:l},{live:!0,shardKey:s}).data,c=hr(r?.buckets??[]);return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"qi-range",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("div",{className:"flex gap-1 rounded-lg border border-border p-0.5","data-testid":"qi-ranges",role:"group",children:mr.map(i=>(0,t.jsx)("button",{"aria-pressed":i===l,className:ht("rounded px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",i===l&&"bg-accent font-medium text-foreground"),"data-testid":`qi-range-${i}`,onClick:o(()=>{a(i)},"onClick"),type:"button",children:i},i))}),r?.capped===!0&&(0,t.jsx)(Be,{"data-testid":"qi-capped",variant:"secondary",children:e("showing a capped set")})]}),c.length===0?(0,t.jsx)(ft,{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.")}):(0,t.jsxs)("div",{className:"grid gap-4 lg:grid-cols-2",children:[(0,t.jsxs)("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-throughput",children:[(0,t.jsx)("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Throughput")}),(0,t.jsx)(et,{height:140,width:"100%",children:(0,t.jsxs)(wt,{data:c,children:[(0,t.jsx)(rt,{strokeDasharray:"3 3",vertical:!1}),(0,t.jsx)(at,{dataKey:"label",fontSize:10,tickLine:!1}),(0,t.jsx)(st,{allowDecimals:!1,fontSize:10,tickLine:!1,width:32}),(0,t.jsx)(tt,{}),(0,t.jsx)(Nt,{dataKey:"execs",fill:"var(--color-primary)",fillOpacity:.15,stroke:"var(--color-primary)",type:"monotone"})]})})]}),(0,t.jsxs)("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-latency",children:[(0,t.jsx)("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Mean latency (ms)")}),(0,t.jsx)(et,{height:140,width:"100%",children:(0,t.jsxs)(St,{data:c,children:[(0,t.jsx)(rt,{strokeDasharray:"3 3",vertical:!1}),(0,t.jsx)(at,{dataKey:"label",fontSize:10,tickLine:!1}),(0,t.jsx)(st,{fontSize:10,tickLine:!1,width:32}),(0,t.jsx)(tt,{}),(0,t.jsx)(yt,{dataKey:"avg",dot:!1,stroke:"var(--color-destructive)",type:"monotone"})]})})]})]}),(0,t.jsx)(ir,{queryStats:r?.entries??[]})]})},"gr"),fr=pt(Le.getMetrics),pr=o((s,e)=>s?e:"overview","pr"),Pr=o(({initialShardKey:s})=>{let e=mt(),l=ge(),a=ut(),{queryShardKey:r,setShardKey:c,shardKey:i}=Mt(s),[n,$]=(0,P.useState)("overview"),[f,S]=(0,P.useState)([]),p=(0,P.useRef)(null),u=(0,P.useRef)(null),h=(0,P.useRef)(!0);(0,P.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]);let M=o(K=>{jt({shardKey:r,traceId:K}),Ue(a({to:"/traces"}))},"M"),{data:b,error:w,liveError:_}=je(Le.getMetrics,{},{live:!0,shardKey:r}),d=b??null;(0,P.useEffect)(()=>{if(b===void 0)return;kt(r);let K=b,H=p.current,L=u.current!==null&&u.current!==K.shard;if(u.current=K.shard,p.current=K.requests,L){S([]);return}H!==null&&K.requests>=H&&S(O=>[...O,K.requests-H].slice(-30))},[b,r]);let[g,x]=(0,P.useState)(null),[q,k]=(0,P.useState)(!1),y=o(async()=>{k(!0);let K=Lt(i,qt());try{let H=await Promise.all(K.map(async L=>{try{let O=await e.query(fr,{},xt(L));return{error:null,metrics:O,shard:L===""?O.shard:L}}catch(O){return{error:bt(O),metrics:null,shard:L===""?"__root__":L}}}));h.current&&x(H)}finally{h.current&&k(!1)}},"y"),D=g===null?null:Kt(g),I=d===null||d.requests===0?"\u2014":`${(d.errors/d.requests*100).toFixed(1)}%`,C=f.length>0?f.at(-1):0,T=d?At(d):{p90:0,p95:0},N=(0,P.useMemo)(()=>{if(!d||!("queryStats"in d))return;let K=d.queryStats;if(!(!K||!Array.isArray(K)))return Ot(K)},[d]),v=pr(N!==void 0,n),z=o(()=>{Ue(y())},"T"),A=o(()=>{x(null)},"z"),j=o(()=>{$("overview")},"K"),J=o(()=>{$("query-insights")},"U");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)($t,{onChange:c,testId:"mt-shard-input",value:i}),(0,t.jsx)(_t,{message:_,prefix:"mt"}),(0,t.jsx)(Ze,{"data-testid":"mt-aggregate",disabled:q,onClick:z,size:"sm",type:"button",variant:"secondary",children:l(q?"Aggregating\u2026":"All shards")}),g!==null&&(0,t.jsx)(Ze,{"data-testid":"mt-aggregate-clear",onClick:A,size:"sm",type:"button",variant:"ghost",children:l("Hide")}),(0,t.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:Dt,rel:"noreferrer",target:"_blank",children:l("Open in Cloudflare")})]}),w!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:w}),N!==void 0&&(0,t.jsxs)("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[(0,t.jsx)("button",{className:`pb-2 text-sm font-medium transition-colors ${v==="overview"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-overview",onClick:j,type:"button",children:l("Overview")}),(0,t.jsxs)("button",{className:`pb-2 text-sm font-medium transition-colors ${v==="query-insights"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-query-insights",onClick:J,type:"button",children:[l("Query insights"),N.length>0&&(0,t.jsx)("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:N.length})]})]}),v==="query-insights"&&N!==void 0&&(0,t.jsx)(gr,{shardKey:r}),v==="overview"&&d!==null&&(0,t.jsx)(sr,{currentDelta:C,errorRate:I,history:f,latencyPercentiles:T,metrics:d}),v==="overview"&&d===null&&null,v==="overview"&&(0,t.jsx)(er,{onOpenTrace:M,shardKey:r}),v==="overview"&&D!==null&&g!==null&&(0,t.jsx)(tr,{aggregate:D,shardResults:g})]})},"Qr");export{Pr as MetricsPanel};
|
|
1
|
+
import{a as jt}from"./chunk-PKSAWP56.js";import{a as me}from"./chunk-TMGHRD6W.js";import{a as Kt,b as Lt,c as At,d as Ot,e as ot}from"./chunk-M2M3RYJU.js";import{a as zt}from"./chunk-QWGT25SE.js";import{e as Dt}from"./chunk-XF2B7P5A.js";import{a as It,b as Ct,c as Tt,d as Rt,e as Pe}from"./chunk-MKYEFQCA.js";import"./chunk-2PJNAWB3.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import{a as _t}from"./chunk-IGCNMZSB.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import{a as et,b as tt,c as rt,d as yt,e as Nt,f as at,g as st,h as St,i as wt}from"./chunk-OQIGV6FX.js";import"./chunk-4UOFSGUS.js";import"./chunk-CZZWYUTR.js";import{a as Mt}from"./chunk-3CWGJYBB.js";import{a as $t}from"./chunk-RMN2JN4S.js";import{a as qt,b as kt}from"./chunk-GRL5MG3Z.js";import{e as ut}from"./chunk-SMIESS7P.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{c as Ze}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as Be}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import"./chunk-QLQADHFE.js";import{a as Le}from"./chunk-VDW32UET.js";import{c as je}from"./chunk-HRRFUAP6.js";import{f as mt}from"./chunk-6FQJRXVI.js";import"./chunk-XBDKZZ67.js";import{a as ft}from"./chunk-XQCVZAGU.js";import{a as lt,b as nt,c as it,d as Ee,e as ce,f as B}from"./chunk-WJQLNYGX.js";import{a as fe,b as Ae,c as Oe,d as gt,e as pe}from"./chunk-WQH3LT2P.js";import{d as ge,f as pt,g as xt,h as bt,i as vt,l as Ge,o as Ue}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as o,e as Ye,f as Ft,g as Jt,h as Ht,j as ht}from"./chunk-3XIESWL4.js";var P=Ye(Ft(),1);var xe=Ye(Jt(),1);var t=Ye(Ht(),1);var Wt=o((s,e)=>s<e?-1:s>e?1:0,"Jt"),ct=o(s=>{if(s===void 0)return"null";if(typeof s=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key \u2014 pass it as a string, or use stableWireKey");if(s===null||typeof s!="object")return JSON.stringify(s);if(Array.isArray(s))return`[${s.map(c=>ct(c)).join(",")}]`;let e=Object.getPrototypeOf(s);if(e!==null&&e!==Object.prototype){let c=s.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${c} in a stable JSON cache key \u2014 only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}let l=s,a=Object.keys(l).toSorted(Wt),r=[];for(let c of a){let i=l[c];i!==void 0&&r.push(`${JSON.stringify(c)}:${ct(i)}`)}return`{${r.join(",")}}`},"Ze"),Pt=o((s,e,l)=>`${s}:${e}:${ct(l??{})}`,"gt"),Qt=o((s,e)=>s==="gauge"?e.last:s==="histogram"?e.sum/Math.max(1,e.count):e.sum,"ft"),Bt=o((s,e)=>Qt(s,e),"Ht"),Gt=o(s=>Qt(s.kind,s),"Gt"),dt=o(s=>Number.isInteger(s)?s.toLocaleString():s.toLocaleString(void 0,{maximumFractionDigits:2}),"Xe"),Vt=o(s=>Array.isArray(s?.series)?s.series:[],"Wt"),Xt="FUNCTION_NOT_FOUND",Yt=o(s=>{let e=new Map;if(!Array.isArray(s?.series))return e;for(let l of s.series)e.set(Pt(l.kind,l.name,l.attributes),l.points);return e},"Yt"),Zt={counter:"secondary",gauge:"default",histogram:"outline"},Ut=o(s=>{let e=(0,xe.c)(18),{name:l,onOpenTrace:a,traceId:r}=s,c=ge();if(r===void 0){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),e[0]=u):u=e[0],u}let i;e[1]!==r?(i=r.slice(0,8),e[1]=r,e[2]=i):i=e[2];let n=i;if(a===void 0){let u=`mt-instrument-trace-${l}`,h;return e[3]!==n||e[4]!==u||e[5]!==r?(h=(0,t.jsx)("span",{className:"text-muted-foreground","data-testid":u,title:r,children:n}),e[3]=n,e[4]=u,e[5]=r,e[6]=h):h=e[6],h}let $=`mt-instrument-trace-${l}`,f;e[7]!==a||e[8]!==r?(f=o(()=>{a(r)},"f"),e[7]=a,e[8]=r,e[9]=f):f=e[9];let S;e[10]!==c||e[11]!==r?(S=c("Open the exemplar trace {trace}",{trace:r}),e[10]=c,e[11]=r,e[12]=S):S=e[12];let p;return e[13]!==n||e[14]!==$||e[15]!==f||e[16]!==S?(p=(0,t.jsx)("button",{className:"text-primary underline-offset-4 hover:underline","data-testid":$,onClick:f,title:S,type:"button",children:n}),e[13]=n,e[14]=$,e[15]=f,e[16]=S,e[17]=p):p=e[17],p},"Zt"),er=o(s=>{let e=(0,xe.c)(105),{onOpenTrace:l,shardKey:a}=s,r=ge(),c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={},e[0]=c):c=e[0];let i;e[1]!==a?(i={live:!0,shardKey:a},e[1]=a,e[2]=i):i=e[2];let{data:n,error:$,errorSource:f}=je(Le.getMetricSeries,c,i),S;e[3]===Symbol.for("react.memo_cache_sentinel")?(S={},e[3]=S):S=e[3];let p;e[4]!==a?(p={live:!0,shardKey:a},e[4]=a,e[5]=p):p=e[5];let{data:u}=je(Le.getMetricHistory,S,p),h,M,b,w,_,d,g,x,q,k,y,D,I;if(e[6]!==n||e[7]!==$||e[8]!==f||e[9]!==u||e[10]!==l||e[11]!==r){x=Symbol.for("react.early_return_sentinel");e:{let A=Vt(n),j=vt(f)===Xt;if($!==null&&!j){let m;e[25]!==r?(m=r("Instruments"),e[25]=r,e[26]=m):m=e[26];let E;e[27]!==m?(E=(0,t.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:m}),e[27]=m,e[28]=E):E=e[28];let Q;e[29]!==$||e[30]!==r?(Q=r("Instruments unavailable: {error}",{error:$}),e[29]=$,e[30]=r,e[31]=Q):Q=e[31];let F;e[32]!==Q?(F=(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":"mt-instruments-error",role:"status",children:Q}),e[32]=Q,e[33]=F):F=e[33];let de;e[34]!==E||e[35]!==F?(de=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"mt-instruments",children:[E,F]}),e[34]=E,e[35]=F,e[36]=de):de=e[36],x=de;break e}if(A.length===0){x=null;break e}let J=Yt(u),K;e[37]!==r?(K=o(m=>r(m==="counter"?"Counter":m==="gauge"?"Gauge":"Histogram"),"L"),e[37]=r,e[38]=K):K=e[38];let H=K;_="flex flex-col gap-2",d="mt-instruments";let L;e[39]!==r?(L=r("Instruments"),e[39]=r,e[40]=L):L=e[40],e[41]!==L?(g=(0,t.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:L}),e[41]=L,e[42]=g):g=e[42],w=fe,I="overflow-hidden py-0",b=pe,D="px-0",M=lt,k="mt-instruments-table";let O;e[43]!==r?(O=r("name"),e[43]=r,e[44]=O):O=e[44];let G;e[45]!==O?(G=(0,t.jsx)(ce,{children:O}),e[45]=O,e[46]=G):G=e[46];let V;e[47]!==r?(V=r("kind"),e[47]=r,e[48]=V):V=e[48];let X;e[49]!==V?(X=(0,t.jsx)(ce,{children:V}),e[49]=V,e[50]=X):X=e[50];let Y;e[51]!==r?(Y=r("value"),e[51]=r,e[52]=Y):Y=e[52];let Z;e[53]!==Y?(Z=(0,t.jsx)(ce,{className:"text-right",children:Y}),e[53]=Y,e[54]=Z):Z=e[54];let U;e[55]!==r?(U=r("count"),e[55]=r,e[56]=U):U=e[56];let ee;e[57]!==U?(ee=(0,t.jsx)(ce,{className:"text-right",children:U}),e[57]=U,e[58]=ee):ee=e[58];let te;e[59]!==r?(te=r("range"),e[59]=r,e[60]=te):te=e[60];let re;e[61]!==te?(re=(0,t.jsx)(ce,{className:"text-right",children:te}),e[61]=te,e[62]=re):re=e[62];let ae;e[63]!==r?(ae=r("trend"),e[63]=r,e[64]=ae):ae=e[64];let se;e[65]!==ae?(se=(0,t.jsx)(ce,{children:ae}),e[65]=ae,e[66]=se):se=e[66];let le;e[67]!==r?(le=r("trace"),e[67]=r,e[68]=le):le=e[68];let ne;e[69]!==le?(ne=(0,t.jsx)(ce,{children:le}),e[69]=le,e[70]=ne):ne=e[70];let ie;e[71]!==r?(ie=r("dimensions"),e[71]=r,e[72]=ie):ie=e[72];let oe;e[73]!==ie?(oe=(0,t.jsx)(ce,{children:ie}),e[73]=ie,e[74]=oe):oe=e[74],e[75]!==G||e[76]!==X||e[77]!==Z||e[78]!==ee||e[79]!==re||e[80]!==se||e[81]!==ne||e[82]!==oe?(y=(0,t.jsx)(nt,{children:(0,t.jsxs)(Ee,{children:[G,X,Z,ee,re,se,ne,oe]})}),e[75]=G,e[76]=X,e[77]=Z,e[78]=ee,e[79]=re,e[80]=se,e[81]=ne,e[82]=oe,e[83]=y):y=e[83],h=it,q=A.map(m=>{let E=zt(m.attributes),Q=Pt(m.kind,m.name,m.attributes),F=(J.get(Q)??[]).map(de=>Bt(m.kind,de));return(0,t.jsxs)(Ee,{"data-testid":`mt-instrument-${m.name}`,children:[(0,t.jsx)(B,{className:"font-mono text-xs",title:m.functionPath,children:m.name}),(0,t.jsx)(B,{children:(0,t.jsx)(Be,{variant:Zt[m.kind],children:H(m.kind)})}),(0,t.jsx)(B,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${m.name}`,children:dt(Gt(m))}),(0,t.jsx)(B,{className:"text-right tabular-nums text-muted-foreground",children:m.count.toLocaleString()}),(0,t.jsx)(B,{className:"text-right font-mono text-xs tabular-nums text-muted-foreground",children:m.min===m.max?"\u2014":`${dt(m.min)}\u2013${dt(m.max)}`}),(0,t.jsx)(B,{children:F.length>=2?(0,t.jsx)(ot,{ariaLabel:r("{name} trend",{name:m.name}),className:"h-6 w-24 text-foreground",series:F,testId:`mt-instrument-trend-${m.name}`}):(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"\u2014"})}),(0,t.jsx)(B,{className:"font-mono text-xs",children:(0,t.jsx)(Ut,{name:m.name,onOpenTrace:l,traceId:m.exemplarTraceId})}),(0,t.jsx)(B,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:E,children:E===""?"\u2014":E})]},Q)})}e[6]=n,e[7]=$,e[8]=f,e[9]=u,e[10]=l,e[11]=r,e[12]=h,e[13]=M,e[14]=b,e[15]=w,e[16]=_,e[17]=d,e[18]=g,e[19]=x,e[20]=q,e[21]=k,e[22]=y,e[23]=D,e[24]=I}else h=e[12],M=e[13],b=e[14],w=e[15],_=e[16],d=e[17],g=e[18],x=e[19],q=e[20],k=e[21],y=e[22],D=e[23],I=e[24];if(x!==Symbol.for("react.early_return_sentinel"))return x;let C;e[84]!==h||e[85]!==q?(C=(0,t.jsx)(h,{children:q}),e[84]=h,e[85]=q,e[86]=C):C=e[86];let T;e[87]!==M||e[88]!==C||e[89]!==k||e[90]!==y?(T=(0,t.jsxs)(M,{"data-testid":k,children:[y,C]}),e[87]=M,e[88]=C,e[89]=k,e[90]=y,e[91]=T):T=e[91];let N;e[92]!==b||e[93]!==T||e[94]!==D?(N=(0,t.jsx)(b,{className:D,children:T}),e[92]=b,e[93]=T,e[94]=D,e[95]=N):N=e[95];let v;e[96]!==w||e[97]!==N||e[98]!==I?(v=(0,t.jsx)(w,{className:I,children:N}),e[96]=w,e[97]=N,e[98]=I,e[99]=v):v=e[99];let z;return e[100]!==_||e[101]!==d||e[102]!==g||e[103]!==v?(z=(0,t.jsxs)("section",{className:_,"data-testid":d,children:[g,v]}),e[100]=_,e[101]=d,e[102]=g,e[103]=v,e[104]=z):z=e[104],z},"er"),tr=o(s=>{let e=(0,xe.c)(74),{aggregate:l,shardResults:a}=s,r=ge(),c;e[0]!==r?(c=r("Shards"),e[0]=r,e[1]=c):c=e[1];let i;e[2]!==l.failed||e[3]!==l.reachable||e[4]!==r?(i=l.failed>0?r("{reachable} reachable, {failed} unreachable",{failed:l.failed,reachable:l.reachable}):r("{reachable} reachable",{reachable:l.reachable}),e[2]=l.failed,e[3]=l.reachable,e[4]=r,e[5]=i):i=e[5];let n;e[6]!==c||e[7]!==i?(n=(0,t.jsx)(me,{label:c,testId:"mt-agg-shards",value:i}),e[6]=c,e[7]=i,e[8]=n):n=e[8];let $;e[9]!==r?($=r("Total requests"),e[9]=r,e[10]=$):$=e[10];let f;e[11]!==l.totalRequests||e[12]!==$?(f=(0,t.jsx)(me,{label:$,testId:"mt-agg-requests",value:l.totalRequests}),e[11]=l.totalRequests,e[12]=$,e[13]=f):f=e[13];let S;e[14]!==r?(S=r("Total errors"),e[14]=r,e[15]=S):S=e[15];let p;e[16]!==l.totalErrors||e[17]!==S?(p=(0,t.jsx)(me,{label:S,testId:"mt-agg-errors",value:l.totalErrors}),e[16]=l.totalErrors,e[17]=S,e[18]=p):p=e[18];let u;e[19]!==r?(u=r("Total database size"),e[19]=r,e[20]=u):u=e[20];let h;e[21]!==l.totalDatabaseSize?(h=Ge(l.totalDatabaseSize),e[21]=l.totalDatabaseSize,e[22]=h):h=e[22];let M;e[23]!==u||e[24]!==h?(M=(0,t.jsx)(me,{label:u,testId:"mt-agg-db-size",value:h}),e[23]=u,e[24]=h,e[25]=M):M=e[25];let b;e[26]!==r?(b=r("Combined cache hit rate"),e[26]=r,e[27]=b):b=e[27];let w;e[28]!==l.hitRate||e[29]!==r?(w=l.hitRate===null?r("no cache configured"):`${(l.hitRate*100).toFixed(1)}%`,e[28]=l.hitRate,e[29]=r,e[30]=w):w=e[30];let _;e[31]!==b||e[32]!==w?(_=(0,t.jsx)(me,{label:b,testId:"mt-agg-cache",value:w}),e[31]=b,e[32]=w,e[33]=_):_=e[33];let d;e[34]!==M||e[35]!==_||e[36]!==n||e[37]!==f||e[38]!==p?(d=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[n,f,p,M,_]}),e[34]=M,e[35]=_,e[36]=n,e[37]=f,e[38]=p,e[39]=d):d=e[39];let g;e[40]!==r?(g=r("shard"),e[40]=r,e[41]=g):g=e[41];let x;e[42]!==g?(x=(0,t.jsx)(ce,{children:g}),e[42]=g,e[43]=x):x=e[43];let q;e[44]!==r?(q=r("requests"),e[44]=r,e[45]=q):q=e[45];let k;e[46]!==q?(k=(0,t.jsx)(ce,{children:q}),e[46]=q,e[47]=k):k=e[47];let y;e[48]!==r?(y=r("errors"),e[48]=r,e[49]=y):y=e[49];let D;e[50]!==y?(D=(0,t.jsx)(ce,{children:y}),e[50]=y,e[51]=D):D=e[51];let I;e[52]!==r?(I=r("db size"),e[52]=r,e[53]=I):I=e[53];let C;e[54]!==I?(C=(0,t.jsx)(ce,{children:I}),e[54]=I,e[55]=C):C=e[55];let T;e[56]!==x||e[57]!==k||e[58]!==D||e[59]!==C?(T=(0,t.jsx)(nt,{children:(0,t.jsxs)(Ee,{children:[x,k,D,C]})}),e[56]=x,e[57]=k,e[58]=D,e[59]=C,e[60]=T):T=e[60];let N;if(e[61]!==a||e[62]!==r){let j;e[64]!==r?(j=o(J=>(0,t.jsxs)(Ee,{"data-testid":`mt-agg-row-${J.shard}`,children:[(0,t.jsx)(B,{children:J.shard}),J.metrics===null?(0,t.jsx)(B,{className:"text-destructive",colSpan:3,children:J.error??r("unreachable")}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(B,{className:"tabular-nums",children:J.metrics.requests}),(0,t.jsx)(B,{className:"tabular-nums",children:J.metrics.errors}),(0,t.jsx)(B,{className:"tabular-nums",children:Ge(J.metrics.databaseSize)})]})]},J.shard),"K"),e[64]=r,e[65]=j):j=e[65],N=a.map(j),e[61]=a,e[62]=r,e[63]=N}else N=e[63];let v;e[66]!==N?(v=(0,t.jsx)(it,{children:N}),e[66]=N,e[67]=v):v=e[67];let z;e[68]!==T||e[69]!==v?(z=(0,t.jsx)(fe,{className:"overflow-hidden py-0",children:(0,t.jsx)(pe,{className:"px-0",children:(0,t.jsxs)(lt,{"data-testid":"mt-agg-table",children:[T,v]})})}),e[68]=T,e[69]=v,e[70]=z):z=e[70];let A;return e[71]!==d||e[72]!==z?(A=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[d,z]}),e[71]=d,e[72]=z,e[73]=A):A=e[73],A},"tr"),rr=o(s=>{let e=Math.floor(s/1e3),l=Math.floor(e/3600),a=Math.floor(e%3600/60),r=e%60;return l>0?`${l.toString()}h ${a.toString()}m`:a>0?`${a.toString()}m ${r.toString()}s`:`${r.toString()}s`},"rr"),ar=o((s,e)=>{let l=s+e;return l===0?"\u2014":`${(s/l*100).toFixed(1)}%`},"ar"),Et=o(s=>s<=0?"\u2014":s<1?`${(s*1e3).toFixed(0)}\u03BCs`:s<1e3?`${s.toFixed(1)}ms`:`${(s/1e3).toFixed(2)}s`,"ct"),sr=o(s=>{let e=(0,xe.c)(75),{currentDelta:l,errorRate:a,history:r,latencyPercentiles:c,metrics:i}=s,n=ge(),$;e[0]!==r||e[1]!==n?($=r.length>=2?(0,t.jsx)(ot,{ariaLabel:n("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:r,testId:"mt-sparkline"}):void 0,e[0]=r,e[1]=n,e[2]=$):$=e[2];let f;e[3]!==l||e[4]!==r.length||e[5]!==n?(f=r.length>=2?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"font-semibold text-foreground",children:`+${l.toLocaleString()}`})," ",n("last interval")]}):(0,t.jsx)("span",{"data-testid":"mt-sparkline-empty",children:n("collecting samples\u2026")}),e[3]=l,e[4]=r.length,e[5]=n,e[6]=f):f=e[6];let S;e[7]!==n?(S=n("Requests"),e[7]=n,e[8]=S):S=e[8];let p;e[9]!==i.requests||e[10]!==$||e[11]!==f||e[12]!==S?(p=(0,t.jsx)(me,{chart:$,footer:f,label:S,testId:"mt-requests",value:i.requests}),e[9]=i.requests,e[10]=$,e[11]=f,e[12]=S,e[13]=p):p=e[13];let u;e[14]!==a||e[15]!==n?(u=n("{rate} error rate",{rate:a}),e[14]=a,e[15]=n,e[16]=u):u=e[16];let h;e[17]!==n?(h=n("Errors"),e[17]=n,e[18]=h):h=e[18];let M;e[19]!==a||e[20]!==i.errors?(M=(0,t.jsxs)(t.Fragment,{children:[i.errors," (",a,")"]}),e[19]=a,e[20]=i.errors,e[21]=M):M=e[21];let b;e[22]!==u||e[23]!==h||e[24]!==M?(b=(0,t.jsx)(me,{footer:u,label:h,testId:"mt-errors",value:M}),e[22]=u,e[23]=h,e[24]=M,e[25]=b):b=e[25];let w;e[26]!==c.p90?(w=c.p90>0?`P90 ${Et(c.p90)}`:void 0,e[26]=c.p90,e[27]=w):w=e[27];let _;e[28]!==n?(_=n("P95 latency"),e[28]=n,e[29]=_):_=e[29];let d;e[30]!==c.p95?(d=c.p95>0?Et(c.p95):"\u2014",e[30]=c.p95,e[31]=d):d=e[31];let g;e[32]!==_||e[33]!==d||e[34]!==w?(g=(0,t.jsx)(me,{footer:w,label:_,testId:"mt-p95",value:d}),e[32]=_,e[33]=d,e[34]=w,e[35]=g):g=e[35];let x;e[36]!==i.cache||e[37]!==n?(x=i.cache===null?void 0:`${i.cache.entries.toLocaleString()} ${n("cache entries")}`,e[36]=i.cache,e[37]=n,e[38]=x):x=e[38];let q;e[39]!==n?(q=n("Database size"),e[39]=n,e[40]=q):q=e[40];let k;e[41]!==i.databaseSize?(k=Ge(i.databaseSize),e[41]=i.databaseSize,e[42]=k):k=e[42];let y;e[43]!==x||e[44]!==q||e[45]!==k?(y=(0,t.jsx)(me,{footer:x,label:q,testId:"mt-db-size",value:k}),e[43]=x,e[44]=q,e[45]=k,e[46]=y):y=e[46];let D;e[47]!==n?(D=n("Shard"),e[47]=n,e[48]=D):D=e[48];let I;e[49]!==i.shard||e[50]!==D?(I=(0,t.jsx)(me,{label:D,testId:"mt-shard",value:i.shard}),e[49]=i.shard,e[50]=D,e[51]=I):I=e[51];let C;e[52]!==n?(C=n("Uptime"),e[52]=n,e[53]=C):C=e[53];let T;e[54]!==i.uptimeMs?(T=rr(i.uptimeMs),e[54]=i.uptimeMs,e[55]=T):T=e[55];let N;e[56]!==C||e[57]!==T?(N=(0,t.jsx)(me,{label:C,testId:"mt-uptime",value:T}),e[56]=C,e[57]=T,e[58]=N):N=e[58];let v;e[59]!==n?(v=n("Cache hit rate"),e[59]=n,e[60]=v):v=e[60];let z;e[61]!==i.cache||e[62]!==n?(z=i.cache===null?n("no cache configured"):n("{rate} ({count} entries)",{count:i.cache.entries,rate:ar(i.cache.hits,i.cache.misses)}),e[61]=i.cache,e[62]=n,e[63]=z):z=e[63];let A;e[64]!==v||e[65]!==z?(A=(0,t.jsx)(me,{label:v,testId:"mt-cache",value:z}),e[64]=v,e[65]=z,e[66]=A):A=e[66];let j;return e[67]!==g||e[68]!==y||e[69]!==I||e[70]!==N||e[71]!==A||e[72]!==p||e[73]!==b?(j=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[p,b,g,y,I,N,A]}),e[67]=g,e[68]=y,e[69]=I,e[70]=N,e[71]=A,e[72]=p,e[73]=b,e[74]=j):j=e[74],j},"lr"),Xe=o(s=>s>=100?"critical":s>=50?"warning":"good","Ge"),Qe=o(s=>s<1?`${(s*1e3).toFixed(0)}\u03BCs`:s<1e3?`${s.toFixed(1)}ms`:`${(s/1e3).toFixed(2)}s`,"Oe"),Ve=o(s=>s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString(),"Be"),lr=o(s=>{let e=(0,xe.c)(3),{level:l}=s;if(l==="critical"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(Be,{variant:"destructive",children:"Slow"}),e[0]=r):r=e[0],r}if(l==="warning"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)("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]=r):r=e[1],r}let a;return e[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)("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]=a):a=e[2],a},"sr"),nr=o((s,e)=>{let l=[...s];return l.sort((a,r)=>{switch(e){case"avgTime":return r.avgDurationMs-a.avgDurationMs;case"execCount":return r.execCount-a.execCount;case"rowsRead":return r.rowsRead-a.rowsRead;default:return r.totalDurationMs-a.totalDurationMs}}),l},"nr"),ir=o(s=>{let e=(0,xe.c)(161),{queryStats:l}=s,a=ge(),[r,c]=(0,P.useState)("totalTime"),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=new Set,e[0]=i):i=e[0];let[n,$]=(0,P.useState)(i),f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=o(I=>{I!==null&&c(I)},"f"),e[1]=f):f=e[1];let S=f,p,u,h,M,b,w,_,d,g,x;if(e[2]!==n||e[3]!==l||e[4]!==r||e[5]!==a){h=Symbol.for("react.early_return_sentinel");e:{let I=nr(l,r),C;e[16]!==l?(C=l.filter(or),e[16]=l,e[17]=C):C=e[17];let T=C.length,N;e[18]!==l?(N=l.filter(dr),e[18]=l,e[19]=N):N=e[19];let v=N.length,z;e[20]!==l?(z=l.filter(cr),e[20]=l,e[21]=z):z=e[21];let A=z.length,j;e[22]===Symbol.for("react.memo_cache_sentinel")?(j=o(R=>{$(ue=>{let W=new Set(ue);return W.has(R)?W.delete(R):W.add(R),W})},"K"),e[22]=j):j=e[22];let J=j;if(l.length===0){let R;e[23]!==a?(R=a("No query insights yet"),e[23]=a,e[24]=R):R=e[24];let ue;e[25]!==R?(ue=(0,t.jsx)("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:R}),e[25]=R,e[26]=ue):ue=e[26];let W;e[27]!==a?(W=a("Query insights appear once statements are executed against this shard."),e[27]=a,e[28]=W):W=e[28];let he;e[29]!==W?(he=(0,t.jsx)("p",{className:"mt-1 text-sm",children:W}),e[29]=W,e[30]=he):he=e[30];let We;e[31]!==ue||e[32]!==he?(We=(0,t.jsx)(fe,{children:(0,t.jsx)(pe,{className:"py-12",children:(0,t.jsxs)("div",{className:"text-center text-muted-foreground",children:[ue,he]})})}),e[31]=ue,e[32]=he,e[33]=We):We=e[33],h=We;break e}_="space-y-4",d="qi-root";let K;e[34]!==a?(K=a("Critical queries"),e[34]=a,e[35]=K):K=e[35];let H;e[36]!==K?(H=(0,t.jsx)(Ae,{className:"pb-2",children:(0,t.jsx)(Oe,{className:"text-sm font-medium",children:K})}),e[36]=K,e[37]=H):H=e[37];let L;e[38]!==T?(L=(0,t.jsx)("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:T}),e[38]=T,e[39]=L):L=e[39];let O;e[40]!==a?(O=a(">100ms avg execution"),e[40]=a,e[41]=O):O=e[41];let G;e[42]!==O?(G=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:O}),e[42]=O,e[43]=G):G=e[43];let V;e[44]!==L||e[45]!==G?(V=(0,t.jsxs)(pe,{children:[L,G]}),e[44]=L,e[45]=G,e[46]=V):V=e[46];let X;e[47]!==H||e[48]!==V?(X=(0,t.jsxs)(fe,{children:[H,V]}),e[47]=H,e[48]=V,e[49]=X):X=e[49];let Y;e[50]!==a?(Y=a("Moderate queries"),e[50]=a,e[51]=Y):Y=e[51];let Z;e[52]!==Y?(Z=(0,t.jsx)(Ae,{className:"pb-2",children:(0,t.jsx)(Oe,{className:"text-sm font-medium",children:Y})}),e[52]=Y,e[53]=Z):Z=e[53];let U;e[54]!==v?(U=(0,t.jsx)("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:v}),e[54]=v,e[55]=U):U=e[55];let ee;e[56]!==a?(ee=a("50\u2013100ms avg execution"),e[56]=a,e[57]=ee):ee=e[57];let te;e[58]!==ee?(te=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:ee}),e[58]=ee,e[59]=te):te=e[59];let re;e[60]!==U||e[61]!==te?(re=(0,t.jsxs)(pe,{children:[U,te]}),e[60]=U,e[61]=te,e[62]=re):re=e[62];let ae;e[63]!==Z||e[64]!==re?(ae=(0,t.jsxs)(fe,{children:[Z,re]}),e[63]=Z,e[64]=re,e[65]=ae):ae=e[65];let se;e[66]!==a?(se=a("Fast queries"),e[66]=a,e[67]=se):se=e[67];let le;e[68]!==se?(le=(0,t.jsx)(Ae,{className:"pb-2",children:(0,t.jsx)(Oe,{className:"text-sm font-medium",children:se})}),e[68]=se,e[69]=le):le=e[69];let ne;e[70]!==A?(ne=(0,t.jsx)("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:A}),e[70]=A,e[71]=ne):ne=e[71];let ie;e[72]!==a?(ie=a("<50ms avg execution"),e[72]=a,e[73]=ie):ie=e[73];let oe;e[74]!==ie?(oe=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:ie}),e[74]=ie,e[75]=oe):oe=e[75];let m;e[76]!==ne||e[77]!==oe?(m=(0,t.jsxs)(pe,{children:[ne,oe]}),e[76]=ne,e[77]=oe,e[78]=m):m=e[78];let E;e[79]!==le||e[80]!==m?(E=(0,t.jsxs)(fe,{children:[le,m]}),e[79]=le,e[80]=m,e[81]=E):E=e[81],e[82]!==X||e[83]!==ae||e[84]!==E?(g=(0,t.jsxs)("div",{className:"grid gap-4 md:grid-cols-3",children:[X,ae,E]}),e[82]=X,e[83]=ae,e[84]=E,e[85]=g):g=e[85];let Q;e[86]!==a?(Q=a("Query leaderboard"),e[86]=a,e[87]=Q):Q=e[87];let F;e[88]!==Q?(F=(0,t.jsx)("h3",{className:"text-lg font-semibold",children:Q}),e[88]=Q,e[89]=F):F=e[89];let de;e[90]!==r||e[91]!==a?(de=a("Slow queries sorted by {sortField}",{sortField:a(r)}),e[90]=r,e[91]=a,e[92]=de):de=e[92];let be;e[93]!==de?(be=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:de}),e[93]=de,e[94]=be):be=e[94];let ve;e[95]!==F||e[96]!==be?(ve=(0,t.jsxs)("div",{children:[F,be]}),e[95]=F,e[96]=be,e[97]=ve):ve=e[97];let ye;e[98]!==a?(ye=a("Sort by"),e[98]=a,e[99]=ye):ye=e[99];let Ne;e[100]!==ye?(Ne=(0,t.jsx)("span",{className:"text-sm text-muted-foreground",children:ye}),e[100]=ye,e[101]=Ne):Ne=e[101];let Se;e[102]!==a?(Se=a("Sort queries by"),e[102]=a,e[103]=Se):Se=e[103];let Fe;e[104]===Symbol.for("react.memo_cache_sentinel")?(Fe=(0,t.jsx)(Ct,{}),e[104]=Fe):Fe=e[104];let we;e[105]!==Se?(we=(0,t.jsx)(Tt,{"aria-label":Se,className:"w-[140px]","data-testid":"qi-sort",children:Fe}),e[105]=Se,e[106]=we):we=e[106];let qe;e[107]!==a?(qe=a("Total time"),e[107]=a,e[108]=qe):qe=e[108];let ke;e[109]!==qe?(ke=(0,t.jsx)(Pe,{value:"totalTime",children:qe}),e[109]=qe,e[110]=ke):ke=e[110];let $e;e[111]!==a?($e=a("Avg time"),e[111]=a,e[112]=$e):$e=e[112];let Me;e[113]!==$e?(Me=(0,t.jsx)(Pe,{value:"avgTime",children:$e}),e[113]=$e,e[114]=Me):Me=e[114];let _e;e[115]!==a?(_e=a("Execution count"),e[115]=a,e[116]=_e):_e=e[116];let De;e[117]!==_e?(De=(0,t.jsx)(Pe,{value:"execCount",children:_e}),e[117]=_e,e[118]=De):De=e[118];let Ie;e[119]!==a?(Ie=a("Rows read"),e[119]=a,e[120]=Ie):Ie=e[120];let Ce;e[121]!==Ie?(Ce=(0,t.jsx)(Pe,{value:"rowsRead",children:Ie}),e[121]=Ie,e[122]=Ce):Ce=e[122];let Te;e[123]!==ke||e[124]!==Me||e[125]!==De||e[126]!==Ce?(Te=(0,t.jsxs)(Rt,{children:[ke,Me,De,Ce]}),e[123]=ke,e[124]=Me,e[125]=De,e[126]=Ce,e[127]=Te):Te=e[127];let Re;e[128]!==r||e[129]!==we||e[130]!==Te?(Re=(0,t.jsxs)(It,{onValueChange:S,value:r,children:[we,Te]}),e[128]=r,e[129]=we,e[130]=Te,e[131]=Re):Re=e[131];let ze;e[132]!==Ne||e[133]!==Re?(ze=(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[Ne,Re]}),e[132]=Ne,e[133]=Re,e[134]=ze):ze=e[134],e[135]!==ve||e[136]!==ze?(x=(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[ve,ze]}),e[135]=ve,e[136]=ze,e[137]=x):x=e[137],u=fe;let Ke;e[138]!==a?(Ke=a("Statements"),e[138]=a,e[139]=Ke):Ke=e[139];let Je;e[140]!==Ke?(Je=(0,t.jsx)(Oe,{children:Ke}),e[140]=Ke,e[141]=Je):Je=e[141],w=(0,t.jsxs)(Ae,{children:[Je,(0,t.jsx)(gt,{children:a("{count} tracked statements",{count:I.length})})]}),p=pe,M="space-y-2";let He;e[142]!==n||e[143]!==a?(He=o(R=>{let ue=R.normalizedSql,W=n.has(ue),he=Xe(R.avgDurationMs);return(0,t.jsxs)("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[(0,t.jsxs)("button",{"aria-expanded":W,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:o(()=>{J(ue)},"onClick"),type:"button",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[(0,t.jsx)(lr,{level:he}),(0,t.jsx)("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:R.normalizedSql})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-4",children:[(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:Qe(R.totalDurationMs)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("total")})]}),(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:Qe(R.avgDurationMs)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("avg")})]}),R.p95DurationMs!==void 0&&(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:Qe(R.p95DurationMs)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("p95")})]}),(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:Ve(R.execCount)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("calls")})]})]})]}),W&&(0,t.jsxs)("div",{className:"space-y-3 border-t bg-muted/30 p-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-2 text-sm font-medium",children:a("Full statement")}),(0,t.jsx)("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:R.normalizedSql})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[R.p50DurationMs!==void 0&&(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("p50")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:Qe(R.p50DurationMs)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Exec count")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:Ve(R.execCount)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Total time")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:Qe(R.totalDurationMs)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Rows read")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:Ve(R.rowsRead)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Rows written")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:Ve(R.rowsWritten)})]})]})]})]},ue)},"Ee"),e[142]=n,e[143]=a,e[144]=He):He=e[144],b=I.map(He)}e[2]=n,e[3]=l,e[4]=r,e[5]=a,e[6]=p,e[7]=u,e[8]=h,e[9]=M,e[10]=b,e[11]=w,e[12]=_,e[13]=d,e[14]=g,e[15]=x}else p=e[6],u=e[7],h=e[8],M=e[9],b=e[10],w=e[11],_=e[12],d=e[13],g=e[14],x=e[15];if(h!==Symbol.for("react.early_return_sentinel"))return h;let q;e[145]!==M||e[146]!==b?(q=(0,t.jsx)("div",{className:M,children:b}),e[145]=M,e[146]=b,e[147]=q):q=e[147];let k;e[148]!==p||e[149]!==q?(k=(0,t.jsx)(p,{children:q}),e[148]=p,e[149]=q,e[150]=k):k=e[150];let y;e[151]!==u||e[152]!==k||e[153]!==w?(y=(0,t.jsxs)(u,{children:[w,k]}),e[151]=u,e[152]=k,e[153]=w,e[154]=y):y=e[154];let D;return e[155]!==y||e[156]!==_||e[157]!==d||e[158]!==g||e[159]!==x?(D=(0,t.jsxs)("div",{className:_,"data-testid":d,children:[g,x,y]}),e[155]=y,e[156]=_,e[157]=d,e[158]=g,e[159]=x,e[160]=D):D=e[160],D},"ir");function or(s){return Xe(s.avgDurationMs)==="critical"}o(or,"or");function dr(s){return Xe(s.avgDurationMs)==="warning"}o(dr,"cr");function cr(s){return Xe(s.avgDurationMs)==="good"}o(cr,"dr");var mr=["1m","5m","15m","1h"],ur=o(s=>new Date(s).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),"ur"),hr=o(s=>s.map(e=>({avg:Math.round(e.avgDurationMs*100)/100,execs:e.execCount,label:ur(e.bucketMs)})),"hr"),gr=o(({shardKey:s=""})=>{let e=ge(),[l,a]=(0,P.useState)("15m"),r=je(Le.getQueryInsights,{range:l},{live:!0,shardKey:s}).data,c=hr(r?.buckets??[]);return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"qi-range",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("div",{className:"flex gap-1 rounded-lg border border-border p-0.5","data-testid":"qi-ranges",role:"group",children:mr.map(i=>(0,t.jsx)("button",{"aria-pressed":i===l,className:ht("rounded px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",i===l&&"bg-accent font-medium text-foreground"),"data-testid":`qi-range-${i}`,onClick:o(()=>{a(i)},"onClick"),type:"button",children:i},i))}),r?.capped===!0&&(0,t.jsx)(Be,{"data-testid":"qi-capped",variant:"secondary",children:e("showing a capped set")})]}),c.length===0?(0,t.jsx)(ft,{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.")}):(0,t.jsxs)("div",{className:"grid gap-4 lg:grid-cols-2",children:[(0,t.jsxs)("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-throughput",children:[(0,t.jsx)("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Throughput")}),(0,t.jsx)(et,{height:140,width:"100%",children:(0,t.jsxs)(wt,{data:c,children:[(0,t.jsx)(rt,{strokeDasharray:"3 3",vertical:!1}),(0,t.jsx)(at,{dataKey:"label",fontSize:10,tickLine:!1}),(0,t.jsx)(st,{allowDecimals:!1,fontSize:10,tickLine:!1,width:32}),(0,t.jsx)(tt,{}),(0,t.jsx)(Nt,{dataKey:"execs",fill:"var(--color-primary)",fillOpacity:.15,stroke:"var(--color-primary)",type:"monotone"})]})})]}),(0,t.jsxs)("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-latency",children:[(0,t.jsx)("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Mean latency (ms)")}),(0,t.jsx)(et,{height:140,width:"100%",children:(0,t.jsxs)(St,{data:c,children:[(0,t.jsx)(rt,{strokeDasharray:"3 3",vertical:!1}),(0,t.jsx)(at,{dataKey:"label",fontSize:10,tickLine:!1}),(0,t.jsx)(st,{fontSize:10,tickLine:!1,width:32}),(0,t.jsx)(tt,{}),(0,t.jsx)(yt,{dataKey:"avg",dot:!1,stroke:"var(--color-destructive)",type:"monotone"})]})})]})]}),(0,t.jsx)(ir,{queryStats:r?.entries??[]})]})},"gr"),fr=pt(Le.getMetrics),pr=o((s,e)=>s?e:"overview","pr"),Pr=o(({initialShardKey:s})=>{let e=mt(),l=ge(),a=ut(),{queryShardKey:r,setShardKey:c,shardKey:i}=Mt(s),[n,$]=(0,P.useState)("overview"),[f,S]=(0,P.useState)([]),p=(0,P.useRef)(null),u=(0,P.useRef)(null),h=(0,P.useRef)(!0);(0,P.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]);let M=o(K=>{jt({shardKey:r,traceId:K}),Ue(a({to:"/traces"}))},"M"),{data:b,error:w,liveError:_}=je(Le.getMetrics,{},{live:!0,shardKey:r}),d=b??null;(0,P.useEffect)(()=>{if(b===void 0)return;kt(r);let K=b,H=p.current,L=u.current!==null&&u.current!==K.shard;if(u.current=K.shard,p.current=K.requests,L){S([]);return}H!==null&&K.requests>=H&&S(O=>[...O,K.requests-H].slice(-30))},[b,r]);let[g,x]=(0,P.useState)(null),[q,k]=(0,P.useState)(!1),y=o(async()=>{k(!0);let K=Lt(i,qt());try{let H=await Promise.all(K.map(async L=>{try{let O=await e.query(fr,{},xt(L));return{error:null,metrics:O,shard:L===""?O.shard:L}}catch(O){return{error:bt(O),metrics:null,shard:L===""?"__root__":L}}}));h.current&&x(H)}finally{h.current&&k(!1)}},"y"),D=g===null?null:Kt(g),I=d===null||d.requests===0?"\u2014":`${(d.errors/d.requests*100).toFixed(1)}%`,C=f.length>0?f.at(-1):0,T=d?At(d):{p90:0,p95:0},N=(0,P.useMemo)(()=>{if(!d||!("queryStats"in d))return;let K=d.queryStats;if(!(!K||!Array.isArray(K)))return Ot(K)},[d]),v=pr(N!==void 0,n),z=o(()=>{Ue(y())},"T"),A=o(()=>{x(null)},"z"),j=o(()=>{$("overview")},"K"),J=o(()=>{$("query-insights")},"U");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)($t,{onChange:c,testId:"mt-shard-input",value:i}),(0,t.jsx)(_t,{message:_,prefix:"mt"}),(0,t.jsx)(Ze,{"data-testid":"mt-aggregate",disabled:q,onClick:z,size:"sm",type:"button",variant:"secondary",children:l(q?"Aggregating\u2026":"All shards")}),g!==null&&(0,t.jsx)(Ze,{"data-testid":"mt-aggregate-clear",onClick:A,size:"sm",type:"button",variant:"ghost",children:l("Hide")}),(0,t.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:Dt,rel:"noreferrer",target:"_blank",children:l("Open in Cloudflare")})]}),w!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:w}),N!==void 0&&(0,t.jsxs)("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[(0,t.jsx)("button",{className:`pb-2 text-sm font-medium transition-colors ${v==="overview"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-overview",onClick:j,type:"button",children:l("Overview")}),(0,t.jsxs)("button",{className:`pb-2 text-sm font-medium transition-colors ${v==="query-insights"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-query-insights",onClick:J,type:"button",children:[l("Query insights"),N.length>0&&(0,t.jsx)("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:N.length})]})]}),v==="query-insights"&&N!==void 0&&(0,t.jsx)(gr,{shardKey:r}),v==="overview"&&d!==null&&(0,t.jsx)(sr,{currentDelta:C,errorRate:I,history:f,latencyPercentiles:T,metrics:d}),v==="overview"&&d===null&&null,v==="overview"&&(0,t.jsx)(er,{onOpenTrace:M,shardKey:r}),v==="overview"&&D!==null&&g!==null&&(0,t.jsx)(tr,{aggregate:D,shardResults:g})]})},"Qr");export{Pr as MetricsPanel};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as Ue}from"./chunk-6V27P65N.js";import{c as _e}from"./chunk-XF2B7P5A.js";import"./chunk-4KIQ5RLS.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import{a as ye}from"./chunk-JN2Y24PY.js";import"./chunk-ESVP44Y3.js";import{a as Re}from"./chunk-54MMVNPT.js";import"./chunk-I6A5C46N.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import{a as Le}from"./chunk-AREBQI6D.js";import{a as De}from"./chunk-RMN2JN4S.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as Ne}from"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{c as re}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as ae}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as be}from"./chunk-VDW32UET.js";import{f as Se}from"./chunk-
|
|
1
|
+
import{b as Ue}from"./chunk-6V27P65N.js";import{c as _e}from"./chunk-XF2B7P5A.js";import"./chunk-4KIQ5RLS.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import{a as ye}from"./chunk-JN2Y24PY.js";import"./chunk-ESVP44Y3.js";import{a as Re}from"./chunk-54MMVNPT.js";import"./chunk-I6A5C46N.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import{a as Le}from"./chunk-AREBQI6D.js";import{a as De}from"./chunk-RMN2JN4S.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as Ne}from"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{c as re}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as ae}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as be}from"./chunk-VDW32UET.js";import{f as Se}from"./chunk-6FQJRXVI.js";import"./chunk-XBDKZZ67.js";import{a as he}from"./chunk-XQCVZAGU.js";import{a as $e,b as Te,c as Fe,d as ce,e as ne,f as ee}from"./chunk-WJQLNYGX.js";import{a as je,e as ze}from"./chunk-WQH3LT2P.js";import{d as Ce,f as me,g as ge,h as X,l as pe,o as W,q as Ke}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as g,e as fe,f as mt,g as gt,h as pt}from"./chunk-3XIESWL4.js";var M=fe(gt(),1),j=fe(mt(),1);var n=fe(pt(),1);var Oe=g((d,e,t)=>{let{onCopy:r,onDelete:s,onDownload:o,onToggleSelect:c}=t,i=g(()=>{r(d.key)},"i"),l=g(()=>{o(d.key)},"o"),u=g(()=>{s(d.key)},"u"),h=g(()=>{c(d.key)},"h");return{copy:i,download:l,name:d.key.slice(e.length),remove:u,toggle:h}},"Ke"),Me=g(d=>{let e=(0,M.c)(31),{busy:t,buttonClassName:r,copied:s,objectKey:o,onCopy:c,onDelete:i,onDownload:l,t:u}=d,h=`storage-copy-${o}`,f;e[0]!==s||e[1]!==u?(f=u(s?"Copied":"Copy URL"),e[0]=s,e[1]=u,e[2]=f):f=e[2];let m;e[3]!==t||e[4]!==r||e[5]!==c||e[6]!==h||e[7]!==f?(m=(0,n.jsx)(re,{className:r,"data-testid":h,disabled:t,onClick:c,size:"sm",type:"button",variant:"ghost",children:f}),e[3]=t,e[4]=r,e[5]=c,e[6]=h,e[7]=f,e[8]=m):m=e[8];let w=`storage-download-${o}`,a;e[9]!==u?(a=u("Download"),e[9]=u,e[10]=a):a=e[10];let k;e[11]!==t||e[12]!==r||e[13]!==l||e[14]!==w||e[15]!==a?(k=(0,n.jsx)(re,{className:r,"data-testid":w,disabled:t,onClick:l,size:"sm",type:"button",variant:"ghost",children:a}),e[11]=t,e[12]=r,e[13]=l,e[14]=w,e[15]=a,e[16]=k):k=e[16];let C;e[17]!==u?(C=u("Delete object?"),e[17]=u,e[18]=C):C=e[18];let x=`storage-delete-${o}`,b;e[19]!==u?(b=u("Delete"),e[19]=u,e[20]=b):b=e[20];let v;e[21]!==t||e[22]!==i||e[23]!==C||e[24]!==x||e[25]!==b?(v=(0,n.jsx)(Le,{confirmLabel:C,disabled:t,onConfirm:i,testId:x,children:b}),e[21]=t,e[22]=i,e[23]=C,e[24]=x,e[25]=b,e[26]=v):v=e[26];let y;return e[27]!==v||e[28]!==m||e[29]!==k?(y=(0,n.jsxs)(n.Fragment,{children:[m,k,v]}),e[27]=v,e[28]=m,e[29]=k,e[30]=y):y=e[30],y},"De"),Ae=g(d=>{let e=(0,M.c)(14),{objectKey:t,references:r,t:s}=d;if(r===void 0)return null;if(r.length===0){let h=`storage-orphan-${t}`,f;e[0]!==s?(f=s("Orphan"),e[0]=s,e[1]=f):f=e[1];let m;return e[2]!==h||e[3]!==f?(m=(0,n.jsx)(ae,{"data-testid":h,variant:"warning",children:f}),e[2]=h,e[3]=f,e[4]=m):m=e[4],m}let o;e[5]!==r?(o=r.map(bt).join(`
|
|
2
2
|
`),e[5]=r,e[6]=o):o=e[6];let c=o,i=`storage-refs-${t}`,l;e[7]!==r.length||e[8]!==s?(l=r.length===1?s("1 record"):s("{count} records",{count:r.length}),e[7]=r.length,e[8]=s,e[9]=l):l=e[9];let u;return e[10]!==c||e[11]!==i||e[12]!==l?(u=(0,n.jsx)(ae,{"data-testid":i,title:c,variant:"secondary",children:l}),e[10]=c,e[11]=i,e[12]=l,e[13]=u):u=e[13],u},"Te"),Pe=g(d=>{let e=(0,M.c)(7),{objectKey:t,onToggle:r,selected:s,t:o}=d,c;e[0]!==o?(c=o("Select row"),e[0]=o,e[1]=c):c=e[1];let i=`storage-select-${t}`,l;return e[2]!==r||e[3]!==s||e[4]!==c||e[5]!==i?(l=(0,n.jsx)(ye,{"aria-label":c,checked:s,"data-testid":i,onCheckedChange:r}),e[2]=r,e[3]=s,e[4]=c,e[5]=i,e[6]=l):l=e[6],l},"Fe");function bt(d){return`${d.table}\xB7${d.id}`}g(bt,"yt");var yt=g(d=>{let e=(0,M.c)(10),{colSpan:t,name:r,onEnter:s}=d,o;e[0]!==r||e[1]!==s?(o=g(()=>{s(r)},"n"),e[0]=r,e[1]=s,e[2]=o):o=e[2];let c=o,i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=(0,n.jsx)("svg",{"aria-hidden":"true",className:"size-4 text-muted-foreground",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,n.jsx)("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"})}),e[3]=i):i=e[3];let l;e[4]!==c||e[5]!==r?(l=(0,n.jsxs)("button",{className:"inline-flex items-center gap-2 font-mono text-xs outline-none hover:text-foreground focus-visible:text-foreground","data-testid":"fb-folder",onClick:c,type:"button",children:[i,r]}),e[4]=c,e[5]=r,e[6]=l):l=e[6];let u;return e[7]!==t||e[8]!==l?(u=(0,n.jsx)(ce,{children:(0,n.jsx)(ee,{colSpan:t,children:l})}),e[7]=t,e[8]=l,e[9]=u):u=e[9],u},"xt"),xt=g(d=>{let e=(0,M.c)(37),{busy:t,copiedKey:r,handlers:s,object:o,prefix:c,references:i,selected:l,showReferences:u,t:h}=d,f;e[0]!==s||e[1]!==o||e[2]!==c?(f=Oe(o,c,s),e[0]=s,e[1]=o,e[2]=c,e[3]=f):f=e[3];let{copy:m,download:w,name:a,remove:k,toggle:C}=f,x;e[4]!==o.key||e[5]!==l||e[6]!==h||e[7]!==C?(x=(0,n.jsx)(ee,{className:"w-8",children:(0,n.jsx)(Pe,{objectKey:o.key,onToggle:C,selected:l,t:h})}),e[4]=o.key,e[5]=l,e[6]=h,e[7]=C,e[8]=x):x=e[8];let b;e[9]!==a?(b=(0,n.jsx)(ee,{className:"font-mono text-xs",children:a}),e[9]=a,e[10]=b):b=e[10];let v;e[11]!==o.size?(v=pe(o.size),e[11]=o.size,e[12]=v):v=e[12];let y;e[13]!==v?(y=(0,n.jsx)(ee,{className:"tabular-nums text-muted-foreground",children:v}),e[13]=v,e[14]=y):y=e[14];let z=o.httpMetadata?.contentType??"",S;e[15]!==z?(S=(0,n.jsx)(ee,{children:z}),e[15]=z,e[16]=S):S=e[16];let N;e[17]!==o.key||e[18]!==i||e[19]!==u||e[20]!==h?(N=u&&(0,n.jsx)(ee,{children:(0,n.jsx)(Ae,{objectKey:o.key,references:i,t:h})}),e[17]=o.key,e[18]=i,e[19]=u,e[20]=h,e[21]=N):N=e[21];let $=r===o.key,K;e[22]!==t||e[23]!==m||e[24]!==w||e[25]!==o.key||e[26]!==k||e[27]!==h||e[28]!==$?(K=(0,n.jsx)(ee,{className:"text-right",children:(0,n.jsx)("span",{className:"inline-flex items-center gap-1",children:(0,n.jsx)(Me,{busy:t,copied:$,objectKey:o.key,onCopy:m,onDelete:k,onDownload:w,t:h})})}),e[22]=t,e[23]=m,e[24]=w,e[25]=o.key,e[26]=k,e[27]=h,e[28]=$,e[29]=K):K=e[29];let F;return e[30]!==K||e[31]!==x||e[32]!==b||e[33]!==y||e[34]!==S||e[35]!==N?(F=(0,n.jsxs)(ce,{"data-testid":"fb-row",children:[x,b,y,S,N,K]}),e[30]=K,e[31]=x,e[32]=b,e[33]=y,e[34]=S,e[35]=N,e[36]=F):F=e[36],F},"vt"),vt=g(d=>{let e=(0,M.c)(65),{allSelected:t,busy:r,copiedKey:s,files:o,folders:c,handlers:i,onEnterFolder:l,prefix:u,references:h,selected:f,showReferences:m,someSelected:w,t:a,toggleSelectAll:k}=d,C;e[0]!==a?(C=a("Select all rows"),e[0]=a,e[1]=C):C=e[1];let x;e[2]!==t||e[3]!==w||e[4]!==C||e[5]!==k?(x=(0,n.jsx)(ne,{className:"w-8",children:(0,n.jsx)(ye,{"aria-label":C,checked:t,"data-testid":"storage-select-all",indeterminate:w,onCheckedChange:k})}),e[2]=t,e[3]=w,e[4]=C,e[5]=k,e[6]=x):x=e[6];let b;e[7]!==a?(b=a("key"),e[7]=a,e[8]=b):b=e[8];let v;e[9]!==b?(v=(0,n.jsx)(ne,{children:b}),e[9]=b,e[10]=v):v=e[10];let y;e[11]!==a?(y=a("size"),e[11]=a,e[12]=y):y=e[12];let z;e[13]!==y?(z=(0,n.jsx)(ne,{children:y}),e[13]=y,e[14]=z):z=e[14];let S;e[15]!==a?(S=a("content-type"),e[15]=a,e[16]=S):S=e[16];let N;e[17]!==S?(N=(0,n.jsx)(ne,{children:S}),e[17]=S,e[18]=N):N=e[18];let $;e[19]!==m||e[20]!==a?($=m&&(0,n.jsx)(ne,{children:a("used by")}),e[19]=m,e[20]=a,e[21]=$):$=e[21];let K;e[22]!==a?(K=a("Actions"),e[22]=a,e[23]=K):K=e[23];let F;e[24]!==K?(F=(0,n.jsx)(ne,{"aria-label":K}),e[24]=K,e[25]=F):F=e[25];let T;e[26]!==F||e[27]!==x||e[28]!==v||e[29]!==z||e[30]!==N||e[31]!==$?(T=(0,n.jsx)(Te,{children:(0,n.jsxs)(ce,{children:[x,v,z,N,$,F]})}),e[26]=F,e[27]=x,e[28]=v,e[29]=z,e[30]=N,e[31]=$,e[32]=T):T=e[32];let L;if(e[33]!==c||e[34]!==l||e[35]!==m){let R;e[37]!==l||e[38]!==m?(R=g(_=>(0,n.jsx)(yt,{colSpan:m?6:5,name:_,onEnter:l},_),"R"),e[37]=l,e[38]=m,e[39]=R):R=e[39],L=c.map(R),e[33]=c,e[34]=l,e[35]=m,e[36]=L}else L=e[36];let B;if(e[40]!==r||e[41]!==s||e[42]!==o||e[43]!==i||e[44]!==u||e[45]!==h||e[46]!==f||e[47]!==m||e[48]!==a){let R;e[50]!==r||e[51]!==s||e[52]!==i||e[53]!==u||e[54]!==h||e[55]!==f||e[56]!==m||e[57]!==a?(R=g(_=>(0,n.jsx)(xt,{busy:r,copiedKey:s,handlers:i,object:_,prefix:u,references:h[_.key],selected:f.has(_.key),showReferences:m,t:a},_.key),"R"),e[50]=r,e[51]=s,e[52]=i,e[53]=u,e[54]=h,e[55]=f,e[56]=m,e[57]=a,e[58]=R):R=e[58],B=o.map(R),e[40]=r,e[41]=s,e[42]=o,e[43]=i,e[44]=u,e[45]=h,e[46]=f,e[47]=m,e[48]=a,e[49]=B}else B=e[49];let U;e[59]!==L||e[60]!==B?(U=(0,n.jsxs)(Fe,{children:[L,B]}),e[59]=L,e[60]=B,e[61]=U):U=e[61];let I;return e[62]!==T||e[63]!==U?(I=(0,n.jsx)(je,{className:"overflow-hidden py-0",children:(0,n.jsx)(ze,{className:"px-0",children:(0,n.jsxs)($e,{"data-testid":"fb-table",children:[T,U]})})}),e[62]=T,e[63]=U,e[64]=I):I=e[64],I},"kt"),kt=[{label:"15m",seconds:900},{label:"1h",seconds:3600},{label:"24h",seconds:86400},{label:"7d",seconds:604800}],wt=3600,Be=g((d,e)=>{if(e==="size")return d.size;if(e==="type")return d.httpMetadata?.contentType??"";if(e==="date"){if(d.uploaded===void 0)return 0;let t=new Date(d.uploaded).getTime();return Number.isNaN(t)?0:t}return e.startsWith("tag:")?d.customMetadata?.[e.slice(4)]??"":d.key},"ve"),St=g((d,e,t)=>{let r=t==="desc"?-1:1;return d.toSorted((s,o)=>{let c=Be(s,e),i=Be(o,e);return(typeof c=="number"&&typeof i=="number"?c-i:String(c).localeCompare(String(i)))*r})},"Nt"),Ct=g((d,e)=>{let t=new Set,r=[];for(let s of d){let o=s.key.slice(e.length),c=o.indexOf("/");c===-1?r.push(s):t.add(o.slice(0,c+1))}return{files:r,folders:[...t].toSorted((s,o)=>s.localeCompare(o))}},"Ct"),Nt=g(d=>{let e=(0,M.c)(59),{bucket:t,buckets:r,busy:s,draftPrefix:o,expiry:c,fileInputRef:i,onBucketChange:l,onExpiryChange:u,onFileChange:h,onList:f,onPrefixChange:m,onUploadClick:w,t:a}=d,k;e[0]!==m?(k=g(P=>{m(P.target.value)},"v"),e[0]=m,e[1]=k):k=e[1];let C=k,x;e[2]!==l?(x=g(P=>{l(P.target.value)},"y"),e[2]=l,e[3]=x):x=e[3];let b=x,v;e[4]!==u?(v=g(P=>{u(Number.parseInt(P.target.value,10))},"x"),e[4]=u,e[5]=v):v=e[5];let y=v,z;e[6]!==t||e[7]!==r||e[8]!==b||e[9]!==a?(z=r.length>0&&(0,n.jsx)("select",{"aria-label":a("Bucket"),className:"h-8 rounded-md border border-border bg-background px-1 outline-none focus-visible:border-ring","data-testid":"fb-bucket",onChange:b,value:t,children:r.map(zt)}),e[6]=t,e[7]=r,e[8]=b,e[9]=a,e[10]=z):z=e[10];let S;e[11]!==a?(S=a("Key prefix"),e[11]=a,e[12]=S):S=e[12];let N;e[13]!==a?(N=a("key prefix (optional)"),e[13]=a,e[14]=N):N=e[14];let $;e[15]!==o||e[16]!==C||e[17]!==S||e[18]!==N?($=(0,n.jsx)(Ne,{"aria-label":S,className:"h-8 w-64 max-w-full","data-testid":"fb-prefix-input",onChange:C,placeholder:N,value:o}),e[15]=o,e[16]=C,e[17]=S,e[18]=N,e[19]=$):$=e[19];let K;e[20]!==a?(K=a("List"),e[20]=a,e[21]=K):K=e[21];let F;e[22]!==s||e[23]!==f||e[24]!==K?(F=(0,n.jsx)(re,{"data-testid":"fb-list",disabled:s,onClick:f,size:"sm",type:"button",children:K}),e[22]=s,e[23]=f,e[24]=K,e[25]=F):F=e[25];let T;e[26]!==s||e[27]!==a?(T=a(s?"Uploading\u2026":"Upload"),e[26]=s,e[27]=a,e[28]=T):T=e[28];let L;e[29]!==s||e[30]!==w||e[31]!==T?(L=(0,n.jsx)(re,{"data-testid":"storage-upload",disabled:s,onClick:w,size:"sm",type:"button",variant:"outline",children:T}),e[29]=s,e[30]=w,e[31]=T,e[32]=L):L=e[32];let B;e[33]!==i||e[34]!==h?(B=(0,n.jsx)("input",{className:"hidden","data-testid":"storage-file-input",onChange:h,ref:i,type:"file"}),e[33]=i,e[34]=h,e[35]=B):B=e[35];let U;e[36]!==a?(U=a("Link expiry"),e[36]=a,e[37]=U):U=e[37];let I;e[38]!==a?(I=kt.map(P=>(0,n.jsx)("option",{value:P.seconds,children:a(P.label)},P.seconds)),e[38]=a,e[39]=I):I=e[39];let R;e[40]!==c||e[41]!==y||e[42]!==I?(R=(0,n.jsx)("select",{className:"h-8 rounded-md border border-border bg-background px-1 tabular-nums outline-none focus-visible:border-ring","data-testid":"storage-expiry",id:"storage-expiry",onChange:y,value:c,children:I}),e[40]=c,e[41]=y,e[42]=I,e[43]=R):R=e[43];let _;e[44]!==U||e[45]!==R?(_=(0,n.jsxs)("label",{className:"ml-auto flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"storage-expiry",children:[U,R]}),e[44]=U,e[45]=R,e[46]=_):_=e[46];let O;e[47]!==a?(O=a("Open in Cloudflare"),e[47]=a,e[48]=O):O=e[48];let A;e[49]!==O?(A=(0,n.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"fb-cf-link",href:_e,rel:"noreferrer",target:"_blank",children:O}),e[49]=O,e[50]=A):A=e[50];let G;return e[51]!==L||e[52]!==B||e[53]!==_||e[54]!==A||e[55]!==z||e[56]!==$||e[57]!==F?(G=(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[z,$,F,L,B,_,A]}),e[51]=L,e[52]=B,e[53]=_,e[54]=A,e[55]=z,e[56]=$,e[57]=F,e[58]=G):G=e[58],G},"$t"),jt=g(d=>{let e=(0,M.c)(66),{onSortKeyChange:t,onThumbSizeChange:r,showGrid:s,showList:o,sortDirection:c,sortKey:i,t:l,tagKeys:u,thumbSize:h,toggleSortDirection:f,view:m}=d,w;e[0]!==t?(w=g(V=>{t(V.target.value)},"k"),e[0]=t,e[1]=w):w=e[1];let a=w,k;e[2]!==r?(k=g(V=>{r(Number.parseInt(V.target.value,10))},"v"),e[2]=r,e[3]=k):k=e[3];let C=k,x=m==="list",b;e[4]!==l?(b=l("List"),e[4]=l,e[5]=b):b=e[5];let v;e[6]!==o||e[7]!==x||e[8]!==b?(v=(0,n.jsx)("button",{"aria-pressed":x,className:"px-2 py-1 outline-none transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:text-accent-foreground","data-testid":"fb-view-list",onClick:o,type:"button",children:b}),e[6]=o,e[7]=x,e[8]=b,e[9]=v):v=e[9];let y=m==="grid",z;e[10]!==l?(z=l("Grid"),e[10]=l,e[11]=z):z=e[11];let S;e[12]!==s||e[13]!==y||e[14]!==z?(S=(0,n.jsx)("button",{"aria-pressed":y,className:"border-s border-border px-2 py-1 outline-none transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:text-accent-foreground","data-testid":"fb-view-grid",onClick:s,type:"button",children:z}),e[12]=s,e[13]=y,e[14]=z,e[15]=S):S=e[15];let N;e[16]!==v||e[17]!==S?(N=(0,n.jsxs)("div",{className:"inline-flex overflow-hidden rounded-md border border-border",children:[v,S]}),e[16]=v,e[17]=S,e[18]=N):N=e[18];let $;e[19]!==l?($=l("Sort"),e[19]=l,e[20]=$):$=e[20];let K;e[21]!==l?(K=l("Name"),e[21]=l,e[22]=K):K=e[22];let F;e[23]!==K?(F=(0,n.jsx)("option",{value:"name",children:K}),e[23]=K,e[24]=F):F=e[24];let T;e[25]!==l?(T=l("size"),e[25]=l,e[26]=T):T=e[26];let L;e[27]!==T?(L=(0,n.jsx)("option",{value:"size",children:T}),e[27]=T,e[28]=L):L=e[28];let B;e[29]!==l?(B=l("Type"),e[29]=l,e[30]=B):B=e[30];let U;e[31]!==B?(U=(0,n.jsx)("option",{value:"type",children:B}),e[31]=B,e[32]=U):U=e[32];let I;e[33]!==l?(I=l("Modified"),e[33]=l,e[34]=I):I=e[34];let R;e[35]!==I?(R=(0,n.jsx)("option",{value:"date",children:I}),e[35]=I,e[36]=R):R=e[36];let _;e[37]!==u?(_=u.map(Kt),e[37]=u,e[38]=_):_=e[38];let O;e[39]!==a||e[40]!==i||e[41]!==F||e[42]!==L||e[43]!==U||e[44]!==R||e[45]!==_?(O=(0,n.jsxs)("select",{className:"h-8 rounded-md border border-border bg-background px-1 outline-none focus-visible:border-ring","data-testid":"fb-sort",id:"fb-sort",onChange:a,value:i,children:[F,L,U,R,_]}),e[39]=a,e[40]=i,e[41]=F,e[42]=L,e[43]=U,e[44]=R,e[45]=_,e[46]=O):O=e[46];let A;e[47]!==$||e[48]!==O?(A=(0,n.jsxs)("label",{className:"flex items-center gap-1.5 text-muted-foreground",htmlFor:"fb-sort",children:[$,O]}),e[47]=$,e[48]=O,e[49]=A):A=e[49];let G;e[50]!==l?(G=l("Toggle sort direction"),e[50]=l,e[51]=G):G=e[51];let P=c==="asc"?"\u2191":"\u2193",H;e[52]!==G||e[53]!==P||e[54]!==f?(H=(0,n.jsx)("button",{"aria-label":G,className:"flex size-8 items-center justify-center rounded-md border border-border tabular-nums outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"fb-sort-dir",onClick:f,type:"button",children:P}),e[52]=G,e[53]=P,e[54]=f,e[55]=H):H=e[55];let Y;e[56]!==C||e[57]!==l||e[58]!==h||e[59]!==m?(Y=m==="grid"&&(0,n.jsxs)("label",{className:"ml-auto flex items-center gap-1.5 text-muted-foreground",htmlFor:"fb-thumb-size",children:[l("Thumbnail size"),(0,n.jsx)("input",{className:"accent-primary","data-testid":"fb-thumb-size",id:"fb-thumb-size",max:240,min:80,onChange:C,step:8,type:"range",value:h})]}),e[56]=C,e[57]=l,e[58]=h,e[59]=m,e[60]=Y):Y=e[60];let oe;return e[61]!==A||e[62]!==H||e[63]!==Y||e[64]!==N?(oe=(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs","data-testid":"fb-controls",children:[N,A,H,Y]}),e[61]=A,e[62]=H,e[63]=Y,e[64]=N,e[65]=oe):oe=e[65],oe},"jt");function zt(d){return(0,n.jsx)("option",{value:d,children:d},d)}g(zt,"zt");function Kt(d){return(0,n.jsx)("option",{value:`tag:${d}`,children:d},d)}g(Kt,"Kt");var Dt=/\.(?:avif|bmp|gif|ico|jpe?g|png|svg|webp)$/iu,$t=g(d=>(d.httpMetadata?.contentType??"").startsWith("image/")||Dt.test(d.key),"Tt"),Tt=g(()=>{let d=(0,M.c)(1),e;return d[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("svg",{"aria-hidden":"true",className:"size-8 text-muted-foreground/60",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.4,viewBox:"0 0 24 24",children:(0,n.jsx)("path",{d:"M7 3h7l5 5v13a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Zm7 0v5h5"})}),d[0]=e):e=d[0],e},"Ft"),Ft=g(d=>{let e=(0,M.c)(13),{object:t,resolveUrl:r}=d,[s,o]=(0,j.useState)(null),[c,i]=(0,j.useState)(!1),l;e[0]!==t?(l=$t(t),e[0]=t,e[1]=l):l=e[1];let u=l,h,f;e[2]!==u||e[3]!==t.key||e[4]!==r?(h=g(()=>{if(!u)return;let k={cancelled:!1};return W((async()=>{try{let C=await r(t.key);k.cancelled||o(C)}catch{k.cancelled||i(!0)}})()),()=>{k.cancelled=!0}},"h"),f=[u,t.key,r],e[2]=u,e[3]=t.key,e[4]=r,e[5]=h,e[6]=f):(h=e[5],f=e[6]),(0,j.useEffect)(h,f);let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=g(()=>{i(!0)},"m"),e[7]=m):m=e[7];let w=m,a;return e[8]!==c||e[9]!==u||e[10]!==t.key||e[11]!==s?(a=(0,n.jsx)("div",{className:"flex aspect-square w-full items-center justify-center overflow-hidden rounded-md border border-border bg-muted/30",children:u&&s!==null&&!c?(0,n.jsx)("img",{alt:t.key,className:"size-full object-cover",loading:"lazy",onError:w,src:s}):(0,n.jsx)(Tt,{})}),e[8]=c,e[9]=u,e[10]=t.key,e[11]=s,e[12]=a):a=e[12],a},"Rt"),Lt=g(d=>{let e=(0,M.c)(42),{busy:t,copiedKey:r,handlers:s,object:o,prefix:c,references:i,resolveUrl:l,selected:u,showReferences:h,t:f}=d,m;e[0]!==s||e[1]!==o||e[2]!==c?(m=Oe(o,c,s),e[0]=s,e[1]=o,e[2]=c,e[3]=m):m=e[3];let{copy:w,download:a,name:k,remove:C,toggle:x}=m,b;e[4]!==o||e[5]!==l?(b=(0,n.jsx)(Ft,{object:o,resolveUrl:l}),e[4]=o,e[5]=l,e[6]=b):b=e[6];let v;e[7]!==o.key||e[8]!==u||e[9]!==f||e[10]!==x?(v=(0,n.jsx)("span",{className:"absolute left-1.5 top-1.5 rounded bg-background/80 p-0.5",children:(0,n.jsx)(Pe,{objectKey:o.key,onToggle:x,selected:u,t:f})}),e[7]=o.key,e[8]=u,e[9]=f,e[10]=x,e[11]=v):v=e[11];let y;e[12]!==b||e[13]!==v?(y=(0,n.jsxs)("div",{className:"relative",children:[b,v]}),e[12]=b,e[13]=v,e[14]=y):y=e[14];let z;e[15]!==k?(z=(0,n.jsx)("p",{className:"truncate font-mono text-xs",title:k,children:k}),e[15]=k,e[16]=z):z=e[16];let S;e[17]!==o.size?(S=pe(o.size),e[17]=o.size,e[18]=S):S=e[18];let N;e[19]!==S?(N=(0,n.jsx)("p",{className:"text-[11px] tabular-nums text-muted-foreground",children:S}),e[19]=S,e[20]=N):N=e[20];let $;e[21]!==o.key||e[22]!==i||e[23]!==h||e[24]!==f?($=h&&(0,n.jsx)("div",{className:"mt-1",children:(0,n.jsx)(Ae,{objectKey:o.key,references:i,t:f})}),e[21]=o.key,e[22]=i,e[23]=h,e[24]=f,e[25]=$):$=e[25];let K;e[26]!==z||e[27]!==N||e[28]!==$?(K=(0,n.jsxs)("div",{className:"min-w-0",children:[z,N,$]}),e[26]=z,e[27]=N,e[28]=$,e[29]=K):K=e[29];let F=r===o.key,T;e[30]!==t||e[31]!==w||e[32]!==a||e[33]!==o.key||e[34]!==C||e[35]!==f||e[36]!==F?(T=(0,n.jsx)("div",{className:"flex items-center gap-1",children:(0,n.jsx)(Me,{busy:t,buttonClassName:"h-7 px-2 text-xs",copied:F,objectKey:o.key,onCopy:w,onDelete:C,onDownload:a,t:f})}),e[30]=t,e[31]=w,e[32]=a,e[33]=o.key,e[34]=C,e[35]=f,e[36]=F,e[37]=T):T=e[37];let L;return e[38]!==T||e[39]!==y||e[40]!==K?(L=(0,n.jsxs)("div",{className:"flex flex-col gap-1.5","data-testid":"fb-tile",children:[y,K,T]}),e[38]=T,e[39]=y,e[40]=K,e[41]=L):L=e[41],L},"Lt"),Rt=g(d=>{let e=(0,M.c)(9),{name:t,onEnter:r}=d,s;e[0]!==t||e[1]!==r?(s=g(()=>{r(t)},"l"),e[0]=t,e[1]=r,e[2]=s):s=e[2];let o=s,c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=(0,n.jsx)("span",{className:"flex aspect-square w-full items-center justify-center rounded-md border border-border bg-muted/30 transition-colors hover:bg-accent",children:(0,n.jsx)("svg",{"aria-hidden":"true",className:"size-10 text-muted-foreground",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.4,viewBox:"0 0 24 24",children:(0,n.jsx)("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"})})}),e[3]=c):c=e[3];let i;e[4]!==t?(i=(0,n.jsx)("span",{className:"truncate font-mono text-xs",title:t,children:t}),e[4]=t,e[5]=i):i=e[5];let l;return e[6]!==o||e[7]!==i?(l=(0,n.jsxs)("button",{className:"flex flex-col gap-1.5 text-left outline-none","data-testid":"fb-folder",onClick:o,type:"button",children:[c,i]}),e[6]=o,e[7]=i,e[8]=l):l=e[8],l},"Ot"),Ut=g(d=>{let e=(0,M.c)(34),{busy:t,copiedKey:r,files:s,folders:o,handlers:c,onEnterFolder:i,prefix:l,references:u,resolveUrl:h,selected:f,showReferences:m,size:w,t:a}=d,k;e[0]!==w?(k=w.toString(),e[0]=w,e[1]=k):k=e[1];let C=`repeat(auto-fill, minmax(${k}px, 1fr))`,x;e[2]!==C?(x={gridTemplateColumns:C},e[2]=C,e[3]=x):x=e[3];let b=x,v;if(e[4]!==o||e[5]!==i){let S;e[7]!==i?(S=g(N=>(0,n.jsx)(Rt,{name:N,onEnter:i},N),"w"),e[7]=i,e[8]=S):S=e[8],v=o.map(S),e[4]=o,e[5]=i,e[6]=v}else v=e[6];let y;if(e[9]!==t||e[10]!==r||e[11]!==s||e[12]!==c||e[13]!==l||e[14]!==u||e[15]!==h||e[16]!==f||e[17]!==m||e[18]!==a){let S;e[20]!==t||e[21]!==r||e[22]!==c||e[23]!==l||e[24]!==u||e[25]!==h||e[26]!==f||e[27]!==m||e[28]!==a?(S=g(N=>(0,n.jsx)(Lt,{busy:t,copiedKey:r,handlers:c,object:N,prefix:l,references:u[N.key],resolveUrl:h,selected:f.has(N.key),showReferences:m,t:a},N.key),"w"),e[20]=t,e[21]=r,e[22]=c,e[23]=l,e[24]=u,e[25]=h,e[26]=f,e[27]=m,e[28]=a,e[29]=S):S=e[29],y=s.map(S),e[9]=t,e[10]=r,e[11]=s,e[12]=c,e[13]=l,e[14]=u,e[15]=h,e[16]=f,e[17]=m,e[18]=a,e[19]=y}else y=e[19];let z;return e[30]!==b||e[31]!==v||e[32]!==y?(z=(0,n.jsxs)("div",{className:"grid gap-4","data-testid":"fb-gallery",style:b,children:[v,y]}),e[30]=b,e[31]=v,e[32]=y,e[33]=z):z=e[33],z},"Et"),_t=g(d=>{let e=(0,M.c)(23),{reference:t,t:r}=d,s=`fb-dangling-${t.table}-${t.id}-${t.column}`,o=`${t.table}\xB7${t.id}`,c;e[0]!==o?(c=(0,n.jsx)(ae,{variant:"secondary",children:o}),e[0]=o,e[1]=c):c=e[1];let i;e[2]!==t.column?(i=(0,n.jsx)("span",{className:"text-muted-foreground",children:t.column}),e[2]=t.column,e[3]=i):i=e[3];let l;e[4]!==r?(l=r("\u2192"),e[4]=r,e[5]=l):l=e[5];let u;e[6]!==l?(u=(0,n.jsx)("span",{className:"text-muted-foreground/60",children:l}),e[6]=l,e[7]=u):u=e[7];let h;e[8]!==t.key?(h=(0,n.jsx)("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-foreground",children:t.key}),e[8]=t.key,e[9]=h):h=e[9];let f;e[10]!==c||e[11]!==i||e[12]!==u||e[13]!==h?(f=(0,n.jsxs)("span",{className:"flex flex-wrap items-center gap-1.5",children:[c,i,u,h]}),e[10]=c,e[11]=i,e[12]=u,e[13]=h,e[14]=f):f=e[14];let m;e[15]!==r?(m=r("Missing object"),e[15]=r,e[16]=m):m=e[16];let w;e[17]!==m?(w=(0,n.jsx)(ae,{className:"border-destructive/40 text-destructive",variant:"outline",children:m}),e[17]=m,e[18]=w):w=e[18];let a;return e[19]!==s||e[20]!==w||e[21]!==f?(a=(0,n.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-border/60 px-3 py-2 text-xs","data-testid":s,children:[f,w]}),e[19]=s,e[20]=w,e[21]=f,e[22]=a):a=e[22],a},"Ut"),Bt=g(d=>{let e=(0,M.c)(37),{busy:t,onCheck:r,references:s,t:o,truncated:c}=d,i;e[0]!==o?(i=o("Integrity"),e[0]=o,e[1]=i):i=e[1];let l;e[2]!==i?(l=(0,n.jsx)("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:i}),e[2]=i,e[3]=l):l=e[3];let u;e[4]!==o?(u=o("Orphaned objects"),e[4]=o,e[5]=u):u=e[5];let h;e[6]!==u?(h=(0,n.jsx)("span",{className:"text-sm font-medium text-foreground",children:u}),e[6]=u,e[7]=h):h=e[7];let f;e[8]!==o?(f=o("Find records whose file reference points at an object the bucket no longer has."),e[8]=o,e[9]=f):f=e[9];let m;e[10]!==f?(m=(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:f}),e[10]=f,e[11]=m):m=e[11];let w;e[12]!==l||e[13]!==h||e[14]!==m?(w=(0,n.jsxs)("div",{className:"flex flex-col gap-1",children:[l,h,m]}),e[12]=l,e[13]=h,e[14]=m,e[15]=w):w=e[15];let a;e[16]!==t||e[17]!==o?(a=o(t?"Checking\u2026":"Check for orphans"),e[16]=t,e[17]=o,e[18]=a):a=e[18];let k;e[19]!==t||e[20]!==r||e[21]!==a?(k=(0,n.jsx)(re,{"data-testid":"fb-orphans-check",disabled:t,onClick:r,size:"sm",type:"button",variant:"outline",children:a}),e[19]=t,e[20]=r,e[21]=a,e[22]=k):k=e[22];let C;e[23]!==w||e[24]!==k?(C=(0,n.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[w,k]}),e[23]=w,e[24]=k,e[25]=C):C=e[25];let x;e[26]!==s?.length||e[27]!==o?(x=s?.length===0&&(0,n.jsx)(he,{description:o("Every record's file reference points at an object that exists in the bucket."),testId:"fb-orphans-empty",title:o("No dangling references.")}),e[26]=s?.length,e[27]=o,e[28]=x):x=e[28];let b;e[29]!==s||e[30]!==o||e[31]!==c?(b=s!==void 0&&s.length>0&&(0,n.jsxs)(n.Fragment,{children:[c&&(0,n.jsx)("p",{className:"text-xs text-warning","data-testid":"fb-orphans-truncated",children:o("Showing the first {count} dangling references \u2014 the scan was truncated.",{count:s.length})}),(0,n.jsx)("ul",{className:"flex flex-col gap-1.5","data-testid":"fb-orphans-list",children:s.map(y=>(0,n.jsx)(_t,{reference:y,t:o},`${y.table}\xB7${y.id}\xB7${y.column}`))})]}),e[29]=s,e[30]=o,e[31]=c,e[32]=b):b=e[32];let v;return e[33]!==C||e[34]!==x||e[35]!==b?(v=(0,n.jsxs)("section",{className:"flex flex-col gap-2 rounded-lg border border-border/60 p-3","data-testid":"fb-orphans",children:[C,x,b]}),e[33]=C,e[34]=x,e[35]=b,e[36]=v):v=e[36],v},"_t"),Et=g(function(d,e){let t=(0,M.c)(18),r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=new Set,t[0]=r):r=t[0];let[s,o]=(0,j.useState)(r),c;t[1]===Symbol.for("react.memo_cache_sentinel")?(c=g(x=>{o(b=>{let v=new Set(b);return v.has(x)?v.delete(x):v.add(x),v})},"c"),t[1]=c):c=t[1];let i=c,l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l=g(()=>{o(new Set)},"o"),t[2]=l):l=t[2];let u=l,h,f,m;if(t[3]!==d||t[4]!==e||t[5]!==s){let x;t[9]!==e?(x=g(b=>e(b),"y"),t[9]=e,t[10]=x):x=t[10],f=d.map(x),h=f.length>0&&f.every(b=>s.has(b)),m=!h&&f.some(b=>s.has(b)),t[3]=d,t[4]=e,t[5]=s,t[6]=h,t[7]=f,t[8]=m}else h=t[6],f=t[7],m=t[8];let w=m,a;t[11]!==f?(a=g(()=>{o(x=>f.every(b=>x.has(b))?new Set:new Set(f))},"a"),t[11]=f,t[12]=a):a=t[12];let k=a,C;return t[13]!==h||t[14]!==s||t[15]!==w||t[16]!==k?(C={allSelected:h,clear:u,selected:s,someSelected:w,toggle:i,toggleAll:k},t[13]=h,t[14]=s,t[15]=w,t[16]=k,t[17]=C):C=t[17],C},"Bt"),It=me(be.storageReferences),Ot=me(be.storageOrphans),Ee=1e4,Mt=1e3,At=3600,Pt=g((d,e)=>{if(!("document"in globalThis))return;let t=globalThis.document.createElement("a");t.href=d,t.download=e,t.rel="noopener",globalThis.document.body.append(t),t.click(),t.remove()},"Wt"),Wt=g(d=>d.key,"qt"),Gt=g(({initialPrefix:d,pageSize:e})=>{let t=Se(),[r,s]=(0,j.useState)(d??""),[o,c]=(0,j.useState)(d??""),[i,l]=(0,j.useState)(wt),[u,h]=(0,j.useState)("list"),[f,m]=(0,j.useState)(128),[w,a]=(0,j.useState)("name"),[k,C]=(0,j.useState)("asc"),[x,b]=(0,j.useState)(void 0),[v,y]=(0,j.useState)(void 0),[z,S]=(0,j.useState)(!1),[N,$]=(0,j.useState)(void 0),[K,F]=(0,j.useState)(void 0),[T,L]=(0,j.useState)(""),[B,U]=(0,j.useState)({}),[I,R]=(0,j.useState)(!1),[_,O]=(0,j.useState)(void 0),[A,G]=(0,j.useState)(!1),[P,H]=(0,j.useState)(!1),[Y,oe]=(0,j.useState)([]),[V,xe]=(0,j.useState)(""),le=(0,j.useRef)(0),Q=(0,j.useRef)(0);(0,j.useEffect)(()=>{let p={cancelled:!1};return W((async()=>{try{let D=await t.listStorageBuckets();if(!p.cancelled){oe(D);let[E]=D;E!==void 0&&xe(q=>q===""?E:q)}}catch{}})()),()=>{p.cancelled=!0}},[t]);let Z=(0,j.useMemo)(()=>({list:g(p=>t.listStorageObjects({...p,bucket:V}),"list"),remove:g(p=>t.deleteStorageObject(p,{bucket:V}),"remove"),signedUrl:g((p,D)=>t.signedStorageUrl(p,{...D,bucket:V}),"signedUrl"),upload:g(p=>t.uploadStorageObject({...p,bucket:V}),"upload")}),[V,t]),J=(0,j.useCallback)(async(p,D,E)=>{le.current+=1;let q=le.current;y(void 0),S(!0);try{let te=await Z.list({cursor:D,limit:e,prefix:p});if(q!==le.current)return;b(we=>E&&we!==void 0?[...we,...te.objects]:te.objects),F(te.cursor)}catch(te){if(q!==le.current)return;E||b(void 0),y(X(te))}finally{q===le.current&&S(!1)}},[e,Z]);(0,j.useEffect)(()=>{W(J(d??"",void 0,!1))},[J,d]);let We=(x?.length??0)<=e;Re(()=>{W(J(r,void 0,!1))},We);let{files:de,folders:Ge}=Ct(x??[],r),He=(0,j.useMemo)(()=>{let p=new Set;for(let D of de)for(let E of Object.keys(D.customMetadata??{}))p.add(E);return[...p].toSorted((D,E)=>D.localeCompare(E))},[de]),ie=St(de,w,k),ue=(0,j.useMemo)(()=>[...new Set(ie.map(p=>p.key))].toSorted((p,D)=>p.localeCompare(D)).join(`
|
|
3
3
|
`),[ie]);(0,j.useEffect)(()=>{let p=ue===""?[]:ue.split(`
|
|
4
4
|
`);if(p.length===0){U({});return}let D={current:!0};return W((async()=>{try{let E=await t.query(It,{keys:p},ge(T));D.current&&(U(E.references??{}),R(Object.keys(E.storageColumns??{}).length>0))}catch{D.current&&(U({}),R(!1))}})()),()=>{D.current=!1}},[t,ue,T]);let{allSelected:qe,clear:se,selected:ve,someSelected:Ve,toggle:Ze,toggleAll:Je}=Et(ie,Wt),Ye=g(()=>{s(o),se(),W(J(o,void 0,!1))},"Ie"),Qe=g(()=>{W(J(r,K,!0))},"Me"),ke=g(p=>{s(p),c(p),se(),W(J(p,void 0,!1))},"be"),Xe=g(p=>{ke(`${r}${p}`)},"Ae"),et=g(p=>Z.signedUrl(p,{expiresInSeconds:At}),"Pe"),tt=g(()=>{h("list")},"We"),rt=g(()=>{h("grid")},"qe"),nt=g(p=>{a(p)},"Ge"),ot=g(()=>{C(p=>p==="asc"?"desc":"asc")},"He"),lt=g(p=>{m(p)},"Ze"),st=g(p=>{l(p)},"Ve"),at=g(()=>{y(void 0),S(!0),W((async()=>{try{for(let p of ve)await Z.remove(p);await J(r,void 0,!1),se()}catch(p){y(X(p))}S(!1)})())},"Xe"),it=g(p=>{y(void 0),W((async()=>{try{let D=await Z.signedUrl(p,{expiresInSeconds:i});Ke(D)&&$(p)}catch(D){y(X(D))}})())},"Ye"),ct=g(p=>{y(void 0),W((async()=>{try{let D=await Z.signedUrl(p,{expiresInSeconds:i}),E=p.slice(p.lastIndexOf("/")+1)||p;Pt(D,E)}catch(D){y(X(D))}})())},"Qe");(0,j.useEffect)(()=>{if(N===void 0)return;let p=globalThis.setTimeout(()=>{$(void 0)},2e3);return()=>{globalThis.clearTimeout(p)}},[N]);let dt=g(p=>{y(void 0),S(!0),W((async()=>{try{await Z.remove(p),await J(r,void 0,!1)}catch(D){y(X(D))}S(!1)})())},"Je"),ut=g(p=>{let D=`${r}${p.name}`;y(void 0),S(!0),W((async()=>{try{let E=await p.arrayBuffer();await Z.upload({body:E,contentType:p.type===""?void 0:p.type,key:D}),await J(r,void 0,!1)}catch(E){y(X(E))}S(!1)})())},"et");(0,j.useEffect)(()=>{Q.current+=1,O(void 0),H(!1)},[T]);let ft=g(()=>{Q.current+=1;let p=Q.current;y(void 0),G(!0),W((async()=>{try{let D=[],E;do{let q=await Z.list({cursor:E,limit:Mt});for(let te of q.objects)D.push(te.key);E=D.length>=Ee?void 0:q.cursor}while(E!==void 0);if(D.length>=Ee)p===Q.current&&(O([]),H(!0));else{let q=await t.query(Ot,{liveKeys:D},ge(T));p===Q.current&&(O(q.references??[]),H(q.truncated===!0))}}catch(D){p===Q.current&&(O([]),H(!1),y(X(D)))}p===Q.current&&G(!1)})())},"tt"),ht=g(p=>{le.current+=1,Q.current+=1,xe(p),s(d??""),c(d??""),b(void 0),O(void 0),H(!1),se()},"rt");return{allSelected:qe,bucket:V,buckets:Y,bulkDelete:at,busy:z,checkOrphans:ft,clearSelection:se,copiedKey:N,danglingBusy:A,danglingReferences:_,danglingTruncated:P,draftPrefix:o,enterFolder:Xe,error:v,expiry:i,files:ie,folders:Ge,hasObjects:x!==void 0&&x.length>0,hasStorageColumns:I,listFirst:Ye,loaded:x!==void 0,loadMore:Qe,navigate:ke,nextCursor:K,onCopy:it,onDelete:dt,onDownload:ct,onExpiryChange:st,onFile:ut,onSortKeyChange:nt,onThumbSizeChange:lt,prefix:r,referenceShard:T,references:B,resolveUrl:et,selectBucket:ht,selected:ve,setDraftPrefix:c,setReferenceShard:L,showGrid:rt,showList:tt,someSelected:Ve,sortDirection:k,sortKey:w,tagKeys:He,thumbSize:f,toggleSelect:Ze,toggleSelectAll:Je,toggleSortDirection:ot,view:u}},"Gt"),Ht=100,Ie=g(d=>{let e=(0,M.c)(6),{label:t,onNavigate:r,target:s}=d,o;e[0]!==r||e[1]!==s?(o=g(()=>{r(s)},"n"),e[0]=r,e[1]=s,e[2]=o):o=e[2];let c=o,i;return e[3]!==c||e[4]!==t?(i=(0,n.jsx)("button",{className:"rounded px-1 text-muted-foreground outline-none hover:text-foreground focus-visible:text-foreground",onClick:c,type:"button",children:t}),e[3]=c,e[4]=t,e[5]=i):i=e[5],i},"we"),qt=g(d=>{let e=(0,M.c)(11),{onNavigate:t,prefix:r,t:s}=d,o;if(e[0]!==t||e[1]!==r||e[2]!==s){let c=r.split("/").filter(Vt),i;e[4]!==s?(i=s("Folder path"),e[4]=s,e[5]=i):i=e[5];let l;e[6]!==s?(l=s("root"),e[6]=s,e[7]=l):l=e[7];let u;e[8]!==t||e[9]!==l?(u=(0,n.jsx)(Ie,{label:l,onNavigate:t,target:""}),e[8]=t,e[9]=l,e[10]=u):u=e[10],o=(0,n.jsxs)("nav",{"aria-label":i,className:"flex flex-wrap items-center gap-0.5 text-xs","data-testid":"fb-breadcrumbs",children:[u,c.map((h,f)=>(0,n.jsxs)("span",{className:"flex items-center gap-0.5",children:[(0,n.jsx)("span",{className:"text-muted-foreground/50",children:"/"}),(0,n.jsx)(Ie,{label:h,onNavigate:t,target:`${c.slice(0,f+1).join("/")}/`})]},`${h}-${f.toString()}`))]}),e[0]=t,e[1]=r,e[2]=s,e[3]=o}else o=e[3];return o},"Zt"),ur=g(({initialPrefix:d,pageSize:e=Ht})=>{let t=Ce(),r=Gt({initialPrefix:d,pageSize:e}),s=(0,j.useRef)(null),{onCopy:o,onDelete:c,onDownload:i,onFile:l,toggleSelect:u}=r,h={onCopy:o,onDelete:c,onDownload:i,onToggleSelect:u},f=g(()=>{s.current?.click()},"f"),m=g(a=>{let k=a.target,C=k.files?.[0];k.value="",C&&l(C)},"m"),w=r.loaded&&!r.hasObjects;return(0,n.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-file-browser",children:[(0,n.jsx)(Nt,{bucket:r.bucket,buckets:r.buckets,busy:r.busy,draftPrefix:r.draftPrefix,expiry:r.expiry,fileInputRef:s,onBucketChange:r.selectBucket,onExpiryChange:r.onExpiryChange,onFileChange:m,onList:r.listFirst,onPrefixChange:r.setDraftPrefix,onUploadClick:f,t}),r.loaded&&(0,n.jsx)(qt,{onNavigate:r.navigate,prefix:r.prefix,t}),r.hasObjects&&(0,n.jsx)(jt,{onSortKeyChange:r.onSortKeyChange,onThumbSizeChange:r.onThumbSizeChange,showGrid:r.showGrid,showList:r.showList,sortDirection:r.sortDirection,sortKey:r.sortKey,t,tagKeys:r.tagKeys,thumbSize:r.thumbSize,toggleSortDirection:r.toggleSortDirection,view:r.view}),r.hasStorageColumns&&(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2","data-testid":"fb-references-shard",children:[(0,n.jsx)("label",{className:"text-xs text-muted-foreground",htmlFor:"fb-reference-shard-input",children:t("References shard")}),(0,n.jsx)(De,{id:"fb-reference-shard-input",onChange:r.setReferenceShard,testId:"fb-reference-shard-input",value:r.referenceShard}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:t("Which shard's records are checked for references to these files. Empty = root shard.")})]}),r.hasStorageColumns&&(0,n.jsx)(Bt,{busy:r.danglingBusy,onCheck:r.checkOrphans,references:r.danglingReferences,t,truncated:r.danglingTruncated}),r.selected.size>0&&(0,n.jsx)(Ue,{count:r.selected.size,editable:!0,onClear:r.clearSelection,onDelete:r.bulkDelete}),r.error!==void 0&&(0,n.jsx)("p",{className:"text-sm text-destructive","data-testid":"storage-error",role:"alert",children:r.error}),w&&(0,n.jsx)(he,{description:t("Objects you upload to your R2 buckets will appear here."),icon:(0,n.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,n.jsx)("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"}),(0,n.jsx)("path",{d:"M12 11v5m-2.5-2.5h5"})]}),testId:"fb-empty",title:t("No objects.")}),r.hasObjects&&r.view==="list"&&(0,n.jsx)(vt,{allSelected:r.allSelected,busy:r.busy,copiedKey:r.copiedKey,files:r.files,folders:r.folders,handlers:h,onEnterFolder:r.enterFolder,prefix:r.prefix,references:r.references,selected:r.selected,showReferences:r.hasStorageColumns,someSelected:r.someSelected,t,toggleSelectAll:r.toggleSelectAll}),r.hasObjects&&r.view==="grid"&&(0,n.jsx)(Ut,{busy:r.busy,copiedKey:r.copiedKey,files:r.files,folders:r.folders,handlers:h,onEnterFolder:r.enterFolder,prefix:r.prefix,references:r.references,resolveUrl:r.resolveUrl,selected:r.selected,showReferences:r.hasStorageColumns,size:r.thumbSize,t}),r.nextCursor!==void 0&&(0,n.jsx)("div",{children:(0,n.jsx)(re,{"data-testid":"fb-next",disabled:r.busy,onClick:r.loadMore,size:"sm",type:"button",variant:"outline",children:t("Load more")})})]})},"pr");function Vt(d){return d!==""}g(Vt,"Vt");export{ur as FileBrowser};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as T}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as H}from"./chunk-
|
|
1
|
+
import{b as T}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as H}from"./chunk-KBBOZRRX.js";import"./chunk-XXQUMVWH.js";import"./chunk-DSU54IAT.js";import"./chunk-QLQADHFE.js";import{a as C}from"./chunk-VDW32UET.js";import{c as B}from"./chunk-HRRFUAP6.js";import"./chunk-6FQJRXVI.js";import"./chunk-XBDKZZ67.js";import{a as G}from"./chunk-XQCVZAGU.js";import{a as M,b as $,c as E,d as P,e as d,f as c}from"./chunk-WJQLNYGX.js";import{a as U,e as _}from"./chunk-WQH3LT2P.js";import{d as z}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as S,e as q,g as L,h as V}from"./chunk-3XIESWL4.js";var K=q(L(),1);var r=q(V(),1);var J=["read","insert","update","delete"],W=S((e,t)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[t],"q"),Q=S(e=>{let t=new Map;for(let a of e){let s=t.get(a.table)??{operations:new Set,procedures:new Set,table:a.table};s.operations.add(a.on),s.procedures.add(a.procedure),t.set(a.table,s)}return[...t.values()].toSorted((a,s)=>a.table.localeCompare(s.table))},"B"),ie=S(()=>{let e=(0,K.c)(49),t=z(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let{data:s,error:R,errorSource:k}=B(C.rlsPolicies,a),p=s!==void 0,m,n,h,l,f,u,x,b,o;if(e[1]!==s||e[2]!==R||e[3]!==k||e[4]!==p||e[5]!==t){let F=Q(Array.isArray(s?.policies)?s.policies:[]),D;e[15]!==s?(D=Array.isArray(s?.roles)?s.roles:[],e[15]=s,e[16]=D):D=e[16],n=D,x="flex flex-col gap-6",b="lunora-rls-panel",e[17]!==R||e[18]!==k?(o=R!==null&&(0,r.jsx)(H,{error:k,testId:"rls-error"}),e[17]=R,e[18]=k,e[19]=o):o=e[19],u="flex flex-col gap-2",m=U,h="overflow-hidden py-0";let I;e[20]!==t?(I=t("Policies"),e[20]=t,e[21]=I):I=e[21],e[22]!==I?(l=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:I})}),e[22]=I,e[23]=l):l=e[23],f=p&&F.length===0?(0,r.jsx)(G,{description:t("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:t("No policies defined")}):(0,r.jsx)(_,{className:"px-0",children:(0,r.jsxs)(M,{"data-testid":"rls-policies-table",children:[(0,r.jsx)($,{children:(0,r.jsxs)(P,{children:[(0,r.jsx)(d,{children:t("Table")}),J.map(i=>(0,r.jsx)(d,{children:W(t,i)},i)),(0,r.jsx)(d,{children:t("Guarded by")})]})}),(0,r.jsx)(E,{children:F.map(i=>(0,r.jsxs)(P,{"data-testid":`rls-table-${i.table}`,children:[(0,r.jsx)(c,{className:"font-mono text-xs",children:i.table}),J.map(O=>(0,r.jsx)(c,{children:i.operations.has(O)?(0,r.jsx)(T,{variant:"secondary",children:t("Guarded")}):(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"})},O)),(0,r.jsx)(c,{className:"font-mono text-xs text-muted-foreground",children:[...i.procedures].join(", ")})]},i.table))})]})}),e[1]=s,e[2]=R,e[3]=k,e[4]=p,e[5]=t,e[6]=m,e[7]=n,e[8]=h,e[9]=l,e[10]=f,e[11]=u,e[12]=x,e[13]=b,e[14]=o}else m=e[6],n=e[7],h=e[8],l=e[9],f=e[10],u=e[11],x=e[12],b=e[13],o=e[14];let N;e[24]!==m||e[25]!==h||e[26]!==l||e[27]!==f?(N=(0,r.jsxs)(m,{className:h,children:[l,f]}),e[24]=m,e[25]=h,e[26]=l,e[27]=f,e[28]=N):N=e[28];let g;e[29]!==u||e[30]!==N?(g=(0,r.jsx)("section",{className:u,children:N}),e[29]=u,e[30]=N,e[31]=g):g=e[31];let y;e[32]!==t?(y=t("Roles"),e[32]=t,e[33]=y):y=e[33];let w;e[34]!==y?(w=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y})}),e[34]=y,e[35]=w):w=e[35];let v;e[36]!==p||e[37]!==n||e[38]!==t?(v=p&&n.length===0?(0,r.jsx)(G,{description:t("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:t("No roles defined")}):(0,r.jsx)(_,{className:"px-0",children:(0,r.jsxs)(M,{"data-testid":"rls-roles-table",children:[(0,r.jsx)($,{children:(0,r.jsxs)(P,{children:[(0,r.jsx)(d,{children:t("Role")}),(0,r.jsx)(d,{children:t("Description")}),(0,r.jsx)(d,{children:t("Permissions")})]})}),(0,r.jsx)(E,{children:n.map(Y)})]})}),e[36]=p,e[37]=n,e[38]=t,e[39]=v):v=e[39];let A;e[40]!==w||e[41]!==v?(A=(0,r.jsx)("section",{className:"flex flex-col gap-2",children:(0,r.jsxs)(U,{className:"overflow-hidden py-0",children:[w,v]})}),e[40]=w,e[41]=v,e[42]=A):A=e[42];let j;return e[43]!==A||e[44]!==x||e[45]!==b||e[46]!==o||e[47]!==g?(j=(0,r.jsxs)("div",{className:x,"data-testid":b,children:[o,g,A]}),e[43]=A,e[44]=x,e[45]=b,e[46]=o,e[47]=g,e[48]=j):j=e[48],j},"ae");function X(e){return(0,r.jsx)(T,{variant:"outline",children:e},e)}S(X,"H");function Y(e){return(0,r.jsxs)(P,{"data-testid":`rls-role-${e.name}`,children:[(0,r.jsx)(c,{className:"font-mono text-xs",children:e.name}),(0,r.jsx)(c,{className:"text-muted-foreground",children:e.description??""}),(0,r.jsx)(c,{children:e.permissions.length===0?(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,r.jsx)("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(X)})})]},e.name)}S(Y,"L");export{ie as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as O}from"./chunk-IGCNMZSB.js";import{b as C}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import"./chunk-QLQADHFE.js";import{a as L}from"./chunk-VDW32UET.js";import{c as $}from"./chunk-
|
|
1
|
+
import{a as O}from"./chunk-IGCNMZSB.js";import{b as C}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import"./chunk-QLQADHFE.js";import{a as L}from"./chunk-VDW32UET.js";import{c as $}from"./chunk-HRRFUAP6.js";import"./chunk-6FQJRXVI.js";import"./chunk-XBDKZZ67.js";import{a as I}from"./chunk-XQCVZAGU.js";import{a as k,b as A,c as D,d as g,e as c,f as l}from"./chunk-WJQLNYGX.js";import{a as b,e as S}from"./chunk-WQH3LT2P.js";import{d as w}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as p,e as y,g as j,h as E}from"./chunk-3XIESWL4.js";var _=y(j(),1);var t=y(E(),1);var T="container:",M={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},W=p(e=>{let n=e.indexOf(":");if(n===-1)return{event:e.trim()};let r=e.slice(n+1).trim(),a=e.slice(0,n).trim();return r===""?{event:a}:{detail:r,event:a}},"_"),B=p(e=>{let n=new Map;for(let r of e){let a=r.functionPath??"";if(!a.startsWith(T))continue;let i=a.slice(T.length);if(i==="")continue;let s=JSON.stringify([i,r.instance??""]),o=n.get(s);if(o!==void 0&&o.timestamp>=r.timestamp)continue;let{detail:u,event:d}=W(r.message);n.set(s,{detail:u,event:d,exitCode:r.exitCode,instance:r.instance,level:r.level,name:i,state:M[d]??"unknown",timestamp:r.timestamp})}return[...n.values()].toSorted((r,a)=>r.name.localeCompare(a.name)||(r.instance??"").localeCompare(a.instance??""))},"j"),F={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},H=p(e=>{let{entries:n}=e??{};return Array.isArray(n)?n:[]},"W"),V=p(()=>{let e=(0,_.c)(19),n=w(),r,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},a={live:!0,shardKey:""},e[0]=r,e[1]=a):(r=e[0],a=e[1]);let{data:i,error:s,liveError:o}=$(L.getLogs,r,a),u=i!==void 0,d;if(e[2]!==i||e[3]!==s||e[4]!==o||e[5]!==u||e[6]!==n){let N=B(H(i)),x;e[8]!==s?(x=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:s}),e[8]=s,e[9]=x):x=e[9];let m;e[10]!==n?(m=n("Cloudflare Containers are observed from their lifecycle log stream. This shows the current state per instance \u2014 ports and health checks aren't carried in that stream."),e[10]=n,e[11]=m):m=e[11];let f;e[12]!==m?(f=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:m}),e[12]=m,e[13]=f):f=e[13];let h;e[14]!==o?(h=(0,t.jsx)(O,{message:o,prefix:"containers"}),e[14]=o,e[15]=h):h=e[15];let v;e[16]!==f||e[17]!==h?(v=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[f,h]}),e[16]=f,e[17]=h,e[18]=v):v=e[18],d=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[x,v,u&&N.length===0?(0,t.jsx)(I,{description:n("No container lifecycle activity yet. Instances declared with defineContainer show up here once they start, sleep, stop, or error."),testId:"containers-empty",title:n("No container activity")}):(0,t.jsx)(b,{className:"overflow-hidden py-0",children:(0,t.jsx)(S,{className:"px-0",children:(0,t.jsxs)(k,{"data-testid":"containers-table",children:[(0,t.jsx)(A,{children:(0,t.jsxs)(g,{children:[(0,t.jsx)(c,{children:n("Container")}),(0,t.jsx)(c,{children:n("Instance")}),(0,t.jsx)(c,{children:n("State")}),(0,t.jsx)(c,{children:n("Last event")}),(0,t.jsx)(c,{children:n("Detail")}),(0,t.jsx)(c,{children:n("Exit")}),(0,t.jsx)(c,{children:n("When")})]})}),(0,t.jsx)(D,{children:N.map(J)})]})})})]}),e[2]=i,e[3]=s,e[4]=o,e[5]=u,e[6]=n,e[7]=d}else d=e[7];return d},"H");function J(e){return(0,t.jsxs)(g,{"data-testid":`containers-row-${e.name}${e.instance===void 0?"":`-${e.instance}`}`,children:[(0,t.jsx)(l,{className:"font-mono text-xs",children:e.name}),(0,t.jsx)(l,{className:"max-w-40 truncate font-mono text-xs text-muted-foreground",title:e.instance,children:e.instance??"\u2014"}),(0,t.jsx)(l,{children:(0,t.jsx)(C,{variant:F[e.state],children:e.state})}),(0,t.jsx)(l,{className:"font-mono text-xs text-muted-foreground",children:e.event}),(0,t.jsx)(l,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"\u2014"}),(0,t.jsx)(l,{className:"font-mono text-xs tabular-nums text-muted-foreground",children:e.exitCode??"\u2014"}),(0,t.jsx)(l,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]},`${e.name}/${e.instance??""}`)}p(J,"B");export{V as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as D}from"./chunk-54MMVNPT.js";import{b as x}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{b as B}from"./chunk-
|
|
1
|
+
import{a as D}from"./chunk-54MMVNPT.js";import{b as x}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{b as B}from"./chunk-HRRFUAP6.js";import{f as O}from"./chunk-6FQJRXVI.js";import"./chunk-XBDKZZ67.js";import{a as j}from"./chunk-XQCVZAGU.js";import{a as W,b as q,c as E,d as S,e as r,f as s}from"./chunk-WJQLNYGX.js";import{a as A,e as L}from"./chunk-WQH3LT2P.js";import{d as z}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as T,e as M,g as $,h as I}from"./chunk-3XIESWL4.js";var F=M($(),1);var n=M(I(),1);var J=2e3,Q=new Set(["open"]),re=T(G=>{let e=(0,F.c)(41),{read:y}=G,t=z(),K=O(),v;e[0]!==K||e[1]!==y?(v=T(()=>Promise.resolve(y?y():K.debug()),"S"),e[0]=K,e[1]=y,e[2]=v):v=e[2];let H=v,P=y?"injected":"live",b;e[3]!==P?(b=["lunora-studio","sync-client-debug",P],e[3]=P,e[4]=b):b=e[4];let{data:c,refetch:Y}=B(b,H);if(D(Y,!0,J),!c){let i;e[5]!==t?(i=t("Reading the sync client's state\u2026"),e[5]=t,e[6]=i):i=e[6];let g;e[7]!==t?(g=t("Sync client"),e[7]=t,e[8]=g):g=e[8];let _;return e[9]!==i||e[10]!==g?(_=(0,n.jsx)(A,{children:(0,n.jsx)(L,{children:(0,n.jsx)(j,{description:i,title:g})})}),e[9]=i,e[10]=g,e[11]=_):_=e[11],_}let{pendingWrites:k,shards:N,subscriptions:w}=c,l;e[12]!==t?(l=t("This Studio session's sync client"),e[12]=t,e[13]=l):l=e[13];let a;e[14]!==l?(a=(0,n.jsx)("span",{className:"text-sm font-medium",children:l}),e[14]=l,e[15]=a):a=e[15];let R=c.connectionStatus==="connected"?"default":"secondary",o;e[16]!==c.connectionStatus||e[17]!==R?(o=(0,n.jsx)(x,{variant:R,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=R,e[18]=o):o=e[18];let d;e[19]!==k||e[20]!==t?(d=k>0?(0,n.jsx)(x,{variant:"secondary",children:t("{count} pending writes",{count:k})}):null,e[19]=k,e[20]=t,e[21]=d):d=e[21];let h;e[22]!==a||e[23]!==o||e[24]!==d?(h=(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[a,o,d]}),e[22]=a,e[23]=o,e[24]=d,e[25]=h):h=e[25];let u;e[26]!==t?(u=t("Reads client.debug() for the client running in this page \u2014 not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=t,e[27]=u):u=e[27];let m;e[28]!==u?(m=(0,n.jsx)("p",{className:"text-muted-foreground text-xs",children:u}),e[28]=u,e[29]=m):m=e[29];let p;e[30]!==N||e[31]!==t?(p=N.length===0?(0,n.jsx)(j,{description:t("No shard connection has been opened yet."),title:t("No shards")}):(0,n.jsxs)(W,{children:[(0,n.jsx)(q,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(r,{children:t("Shard")}),(0,n.jsx)(r,{children:t("Socket")}),(0,n.jsx)(r,{children:t("Confirmed watermark")})]})}),(0,n.jsx)(E,{children:N.map(i=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{children:i.shardKey??t("(default)")}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:Q.has(i.wsState)?"default":"secondary",children:i.wsState})}),(0,n.jsx)(s,{children:i.confirmedMutationWatermark})]},i.shardKey??"__default__"))})]}),e[30]=N,e[31]=t,e[32]=p):p=e[32];let f;e[33]!==w||e[34]!==t?(f=w.length===0?(0,n.jsx)(j,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):(0,n.jsxs)(W,{children:[(0,n.jsx)(q,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(r,{children:t("Subscription")}),(0,n.jsx)(r,{children:t("Kind")}),(0,n.jsx)(r,{children:t("Acked")}),(0,n.jsx)(r,{children:t("Cursor")}),(0,n.jsx)(r,{children:t("Pending overlays")})]})}),(0,n.jsx)(E,{children:w.map(i=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{className:"font-mono text-xs",children:i.functionPath}),(0,n.jsx)(s,{children:i.kind}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:i.acked?"default":"secondary",children:i.acked?t("yes"):t("no")})}),(0,n.jsx)(s,{children:i.serverCursor??"\u2014"}),(0,n.jsx)(s,{children:i.pendingOptimisticLayers})]},i.id))})]}),e[33]=w,e[34]=t,e[35]=f):f=e[35];let C;return e[36]!==m||e[37]!==p||e[38]!==f||e[39]!==h?(C=(0,n.jsx)(A,{children:(0,n.jsxs)(L,{className:"flex flex-col gap-4",children:[h,m,p,f]})}),e[36]=m,e[37]=p,e[38]=f,e[39]=h,e[40]=C):C=e[40],C},"re");export{re as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as q}from"./chunk-XQCVZAGU.js";import{a as O,b as v,c as N,d as b,e as _,f as M}from"./chunk-WJQLNYGX.js";import{a as k}from"./chunk-WQH3LT2P.js";import{d as g,h as w,m as I,o as T}from"./chunk-IUYFXK4X.js";import{c as L}from"./chunk-
|
|
1
|
+
import{a as q}from"./chunk-XQCVZAGU.js";import{a as O,b as v,c as N,d as b,e as _,f as M}from"./chunk-WJQLNYGX.js";import{a as k}from"./chunk-WQH3LT2P.js";import{d as g,h as w,m as I,o as T}from"./chunk-IUYFXK4X.js";import{c as L}from"./chunk-P33WK7YI.js";import{a as d,e as x,f as P,g as U,h as W}from"./chunk-3XIESWL4.js";var $=x(U(),1);var F="https://api.cloudflare.com/client/v4/accounts",E=class extends L{static{d(this,"c")}constructor(t,m){super("ANALYTICS_SQL_ERROR",`Analytics Engine SQL API returned ${String(t)}: ${m}`,{name:"AnalyticsSqlError",status:t})}},R=d(n=>{let t=n.fetch??globalThis.fetch,m=`${F}/${encodeURIComponent(n.accountId)}/analytics_engine/sql`;return{query:d(async p=>{let l=await t(m,{body:p,headers:{Authorization:`Bearer ${n.apiToken}`,"Content-Type":"text/plain"},method:"POST"});if(!l.ok)throw new E(l.status,await l.text());let r;try{r=await l.json()}catch{throw new E(l.status,"Analytics Engine SQL API returned a non-JSON body.")}let e=r,s=e.data??[];return{columns:e.meta??[],rowCount:e.rows??s.length,rows:s}},"query")}},"d");var y=x(P(),1);var a=x(W(),1);var H="ANALYTICS",D=[{key:"volume",sql:d(n=>`SELECT blob2 AS fn, count() AS calls FROM ${n} WHERE blob1 = 'function_call' GROUP BY fn ORDER BY calls DESC LIMIT 25`,"sql"),title:"Request volume per function"},{key:"latency",sql:d(n=>`SELECT blob2 AS fn, quantileWeighted(0.50)(double1, _sample_interval) AS p50, quantileWeighted(0.95)(double1, _sample_interval) AS p95 FROM ${n} WHERE blob1 = 'function_call' GROUP BY fn ORDER BY p95 DESC LIMIT 25`,"sql"),title:"Latency p50 / p95 per function"},{key:"hotShards",sql:d(n=>`SELECT blob3 AS shard, count() AS calls FROM ${n} WHERE blob1 = 'function_call' GROUP BY shard ORDER BY calls DESC LIMIT 25`,"sql"),title:"Hot shards"}],j={error:null,loading:!0,result:null},Q=d(n=>{let t=(0,$.c)(27),{state:m,title:p}=n,l=g(),{error:r,loading:e,result:s}=m,o=`analytics-panel-${p}`,c;t[0]!==l||t[1]!==p?(c=l(p),t[0]=l,t[1]=p,t[2]=c):c=t[2];let i;t[3]!==c?(i=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:c})}),t[3]=c,t[4]=i):i=t[4];let u;t[5]!==e||t[6]!==l?(u=e&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"analytics-loading",children:l("Loading\u2026")}),t[5]=e,t[6]=l,t[7]=u):u=t[7];let f;t[8]!==r||t[9]!==e?(f=!e&&r!==null&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"analytics-error",role:"alert",children:r}),t[8]=r,t[9]=e,t[10]=f):f=t[10];let h;t[11]!==r||t[12]!==e||t[13]!==s||t[14]!==l?(h=!e&&r===null&&s!==null&&s.rows.length===0&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"analytics-empty-rows",children:l("No data points yet.")}),t[11]=r,t[12]=e,t[13]=s,t[14]=l,t[15]=h):h=t[15];let A;t[16]!==r||t[17]!==e||t[18]!==s?(A=!e&&r===null&&s!==null&&s.rows.length>0&&(0,a.jsxs)(O,{children:[(0,a.jsx)(v,{children:(0,a.jsx)(b,{children:s.columns.map(G)})}),(0,a.jsx)(N,{children:s.rows.map((B,Y)=>(0,a.jsx)(b,{children:s.columns.map(C=>(0,a.jsx)(M,{className:"font-mono text-xs",children:I(B[C.name])},C.name))},Y))})]}),t[16]=r,t[17]=e,t[18]=s,t[19]=A):A=t[19];let S;return t[20]!==o||t[21]!==i||t[22]!==u||t[23]!==f||t[24]!==h||t[25]!==A?(S=(0,a.jsxs)(k,{className:"gap-0 py-0","data-testid":o,children:[i,u,f,h,A]}),t[20]=o,t[21]=i,t[22]=u,t[23]=f,t[24]=h,t[25]=A,t[26]=S):S=t[26],S},"U"),rt=d(({config:n,dataset:t=H,runQuery:m}={})=>{let p=g(),[l,r]=(0,y.useState)({}),e=(0,y.useMemo)(()=>{if(m!==void 0)return m;if(n===void 0)return null;let o=R({accountId:n.accountId,apiToken:n.apiToken});return c=>o.query(c)},[n,m]),s=(0,y.useCallback)(async o=>{if(e!==null)for(let c of D){if(o.cancelled)return;r(i=>({...i,[c.key]:{error:null,loading:!0,result:null}}));try{let i=await e(c.sql(t));o.cancelled||r(u=>({...u,[c.key]:{error:null,loading:!1,result:i}}))}catch(i){o.cancelled||r(u=>({...u,[c.key]:{error:w(i),loading:!1,result:null}}))}}},[e,t]);return(0,y.useEffect)(()=>{let o={cancelled:!1};return T(s(o)),()=>{o.cancelled=!0}},[s]),e===null?(0,a.jsx)(q,{description:p("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN (Analytics Read) in your .dev.vars to enable usage panels."),icon:(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M5 20V10m6.5 10V4M18 20v-7M3 20h18"})}),testId:"analytics-not-configured",title:p("Analytics is not configured.")}):(0,a.jsx)("div",{className:"flex flex-col gap-4","data-testid":"lunora-analytics-panel",children:D.map(o=>(0,a.jsx)(Q,{state:l[o.key]??j,title:o.title},o.key))})},"Z");function G(n){return(0,a.jsx)(_,{children:n.name},n.name)}d(G,"H");export{rt as AnalyticsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as l}from"./chunk-
|
|
1
|
+
import{b as l}from"./chunk-HRRFUAP6.js";import{f as c}from"./chunk-6FQJRXVI.js";import{a as r,e as f,g}from"./chunk-3XIESWL4.js";var m=f(g(),1);var p={capabilities:{accounts:!0,admin:!0,organization:!1,passkey:!1,twoFactor:!1},emailAndPassword:!1,organization:{enabled:!1,roles:!1,teams:!1},plugins:[],rateLimit:{enabled:!1},session:{},socialProviders:[],userFields:[]},y=r(()=>{let o=(0,m.c)(6),t=c(),a;o[0]===Symbol.for("react.memo_cache_sentinel")?(a=["lunora-auth-config"],o[0]=a):a=o[0];let e;o[1]!==t?(e=r(()=>t.getAuthConfig(),"o"),o[1]=t,o[2]=e):e=o[2];let{data:u,isLoading:d}=l(a,e),i=u??p,n=!d,s;return o[3]!==i||o[4]!==n?(s={config:i,ready:n},o[3]=i,o[4]=n,o[5]=s):s=o[5],s},"A");export{y as a};
|