@lunora/studio 1.0.0-alpha.356 → 1.0.0-alpha.358
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-Q5GY7D5H.js → chunk-2CPBNLFU.js} +1 -1
- package/dist/standalone/{chunk-YHK5UBXI.js → chunk-3HX723U6.js} +1 -1
- package/dist/standalone/{chunk-GNVWTK4S.js → chunk-4FZYH76L.js} +1 -1
- package/dist/standalone/{chunk-FIJVZCBO.js → chunk-5IGDDSST.js} +1 -1
- package/dist/standalone/{chunk-SL7LF2SO.js → chunk-5SYMAYUA.js} +1 -1
- package/dist/standalone/{chunk-SPPJFTWE.js → chunk-7KPRMBD6.js} +1 -1
- package/dist/standalone/{chunk-SOVH524I.js → chunk-AKGGWCWW.js} +1 -1
- package/dist/standalone/{chunk-Z3NZJ4C2.js → chunk-AN2L3XHC.js} +1 -1
- package/dist/standalone/{chunk-MQ3FFFP4.js → chunk-B4BK5Q5O.js} +1 -1
- package/dist/standalone/{chunk-TIQ3NI77.js → chunk-B6OTKSMY.js} +1 -1
- package/dist/standalone/{chunk-DN3HPAOA.js → chunk-BCP3MEB3.js} +1 -1
- package/dist/standalone/{chunk-F7GMBSJP.js → chunk-CVUNFP54.js} +1 -1
- package/dist/standalone/{chunk-S6OBDEAQ.js → chunk-CZACJYDC.js} +1 -1
- package/dist/standalone/{chunk-VO6GV6F2.js → chunk-DPESH5MT.js} +1 -1
- package/dist/standalone/{chunk-N5FOHLIG.js → chunk-EAZXULX6.js} +1 -1
- package/dist/standalone/{chunk-CDV6T5KM.js → chunk-F4VO76XV.js} +1 -1
- package/dist/standalone/{chunk-ILLDX6LU.js → chunk-FACE2CFY.js} +1 -1
- package/dist/standalone/{chunk-64S3IDR2.js → chunk-FCRSF54M.js} +1 -1
- package/dist/standalone/{chunk-XFTWGZKD.js → chunk-FHGTI6PR.js} +1 -1
- package/dist/standalone/{chunk-CHGMDVEQ.js → chunk-FMQ72AKG.js} +1 -1
- package/dist/standalone/{chunk-NQX6SAC6.js → chunk-FNUPPZKJ.js} +1 -1
- package/dist/standalone/{chunk-ESUUPILO.js → chunk-FRN6D6MP.js} +1 -1
- package/dist/standalone/{chunk-D5LY65EX.js → chunk-FSWWDMW2.js} +1 -1
- package/dist/standalone/{chunk-VPG46PCA.js → chunk-FYWZRJCT.js} +1 -1
- package/dist/standalone/{chunk-IMF6DJKL.js → chunk-GMO7IUXO.js} +1 -1
- package/dist/standalone/{chunk-OGKRWT6I.js → chunk-HGT4YHTI.js} +1 -1
- package/dist/standalone/{chunk-EEPCLLGE.js → chunk-HONLEKH5.js} +1 -1
- package/dist/standalone/{chunk-SV34MAIK.js → chunk-HSLO46OW.js} +1 -1
- package/dist/standalone/{chunk-UWAVY3IF.js → chunk-IIJXS3KP.js} +1 -1
- package/dist/standalone/{chunk-UHGLZ5RV.js → chunk-IWG2D7QS.js} +1 -1
- package/dist/standalone/{chunk-R66XCM3J.js → chunk-JYCRY3LM.js} +1 -1
- package/dist/standalone/{chunk-7DMOBHYC.js → chunk-KRDWV6YM.js} +1 -1
- package/dist/standalone/{chunk-RNHTOEL7.js → chunk-KRH6UDVU.js} +1 -1
- package/dist/standalone/{chunk-M3KSCNKR.js → chunk-LVNPLZDL.js} +1 -1
- package/dist/standalone/{chunk-ZXUEBA56.js → chunk-MC577GI5.js} +1 -1
- package/dist/standalone/{chunk-U2YFL6EA.js → chunk-MHJNM7VT.js} +1 -1
- package/dist/standalone/{chunk-3QGR4DC7.js → chunk-MI7DM536.js} +1 -1
- package/dist/standalone/{chunk-I2PP6Q6F.js → chunk-MY7ZGJOD.js} +1 -1
- package/dist/standalone/{chunk-E423VRTC.js → chunk-N4AWDORA.js} +1 -1
- package/dist/standalone/{chunk-O6XMGPGY.js → chunk-NEZRBBPI.js} +1 -1
- package/dist/standalone/{chunk-YJYXN3WQ.js → chunk-NSUOMZWM.js} +1 -1
- package/dist/standalone/{chunk-NXNUGQHB.js → chunk-OIBN6KMM.js} +1 -1
- package/dist/standalone/{chunk-R5ACA3OC.js → chunk-OSQYIZAV.js} +1 -1
- package/dist/standalone/{chunk-AZRUSOAH.js → chunk-OX7I5YHU.js} +1 -1
- package/dist/standalone/{chunk-QSNQXPIX.js → chunk-PBKTGB7B.js} +1 -1
- package/dist/standalone/{chunk-GZX5XABE.js → chunk-PCMV6S7K.js} +1 -1
- package/dist/standalone/{chunk-OT4KZ6Y6.js → chunk-PMGNJZYE.js} +1 -1
- package/dist/standalone/{chunk-BCIFRJ3Q.js → chunk-PTCC45P7.js} +1 -1
- package/dist/standalone/{chunk-AMLIZFTD.js → chunk-QXHMVPS3.js} +1 -1
- package/dist/standalone/{chunk-TNII7Q2L.js → chunk-SUOVLXY6.js} +1 -1
- package/dist/standalone/{chunk-DUQ7KXNS.js → chunk-TA3DCQUA.js} +1 -1
- package/dist/standalone/{chunk-5KD75VXP.js → chunk-UFPN44MP.js} +1 -1
- package/dist/standalone/{chunk-7W6WESSS.js → chunk-V6SVNLUM.js} +1 -1
- package/dist/standalone/{chunk-4SJDWMH3.js → chunk-W37HRJGQ.js} +1 -1
- package/dist/standalone/{chunk-ZZ5564FZ.js → chunk-WC5QFZYZ.js} +1 -1
- package/dist/standalone/{chunk-FXTT2XP3.js → chunk-WCWSMX3N.js} +1 -1
- package/dist/standalone/{chunk-OKSZWLJX.js → chunk-WOGVVXGF.js} +1 -1
- package/dist/standalone/{chunk-4BNWYVLP.js → chunk-XIVWJUD3.js} +1 -1
- package/dist/standalone/{chunk-2CWGRQ5L.js → chunk-XZ6B5XNN.js} +1 -1
- package/dist/standalone/{chunk-AQJXOPBW.js → chunk-XZKWGTLI.js} +1 -1
- package/dist/standalone/{chunk-TAGWTOFD.js → chunk-ZD53YB3L.js} +1 -1
- package/dist/standalone/{chunk-5IIX2STA.js → chunk-ZFFZWSDJ.js} +1 -1
- package/dist/standalone/{chunk-2PHY5V5E.js → chunk-ZQOPXQIT.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +5 -5
- /package/dist/standalone/{chunk-FKM35PXF.js → chunk-SDSQIQJG.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as dt}from"./chunk-U2YFL6EA.js";import"./chunk-7RGYCU6F.js";import"./chunk-CDV6T5KM.js";import"./chunk-SYGCASPT.js";import"./chunk-CTE6RPXC.js";import"./chunk-LIGOLZND.js";import"./chunk-3GXPALXG.js";import{a as De}from"./chunk-OUFWXYEF.js";import{a as st}from"./chunk-XBZUJDHD.js";import"./chunk-AP4PC2M4.js";import"./chunk-KRPXOSBL.js";import"./chunk-W2BCSK5S.js";import"./chunk-NGVP66OH.js";import"./chunk-XYR5NST4.js";import{a as at}from"./chunk-5DNGK3NT.js";import{a as ot}from"./chunk-ZWDORIZY.js";import{a as tt}from"./chunk-KYONGQQ4.js";import{b as et}from"./chunk-SLIDAWNX.js";import"./chunk-6M7FLLMT.js";import{h as Be,i as We}from"./chunk-LUHXNZI4.js";import"./chunk-ZTOREMGH.js";import{i as ze}from"./chunk-SDQH4HR6.js";import"./chunk-W7MRISE3.js";import"./chunk-IBJVVHV5.js";import{a as He}from"./chunk-2O6KKVH2.js";import"./chunk-JTGGWF7R.js";import"./chunk-ZBON5T5A.js";import{b as Ue}from"./chunk-6I42AM75.js";import"./chunk-4C4THJUD.js";import{a as Te}from"./chunk-IMF6DJKL.js";import"./chunk-OSJ7HV7B.js";import"./chunk-SL7LF2SO.js";import"./chunk-E26OT26O.js";import{a as F}from"./chunk-6UTZXEW3.js";import{c as ce}from"./chunk-4SJDWMH3.js";import{p as Ye}from"./chunk-FKM35PXF.js";import"./chunk-WZTY3ZYI.js";import{a as Oe}from"./chunk-3Y5K3IQO.js";import{a as rt,b as it,c as nt,d as _e,e as q,f as T}from"./chunk-CW57Q264.js";import{a as Qe,e as Ve}from"./chunk-MD67S53Z.js";import{b as de,f as le,h as Ge,i as Ze,j as Xe,s as je,w as qe}from"./chunk-LPINY2IJ.js";import{a as s,d as se,e as Je,f as Ae,g as Pe}from"./chunk-OXFKZ4BM.js";var be=se(Ae(),1),he=se(Je(),1);var lt=se(Ae(),1),S=se(Je(),1);var m=se(Pe(),1);var qt=Ge(F.runMigration),ct=s(t=>{let e=(0,lt.c)(98),{initialShardKey:r}=t,i=Ye(),a=le(),{queryShardKey:o,setShardKey:n,shardKey:d}=at(r),[l,f]=(0,S.useState)(""),[h,g]=(0,S.useState)("up"),[p,b]=(0,S.useState)(!0),[y,x]=(0,S.useState)(!1),[v,u]=(0,S.useState)(null),[w,k]=(0,S.useState)(null),L;e[0]!==d?(L=d.trim(),e[0]=d,e[1]=L):L=e[1];let C=L===o,j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j={},e[2]=j):j=e[2];let M;e[3]!==o?(M={live:!0,shardKey:o},e[3]=o,e[4]=M):M=e[4];let $=ce(F.migrationStatus,j,M),N=$.data?.migrations??null,Ie=$.error,{errorSource:Fe,liveError:Re}=$,ye,ve;e[5]!==o||e[6]!==$.data?(ye=s(()=>{$.data!==void 0&&et(o)},"W"),ve=[$.data,o],e[5]=o,e[6]=$.data,e[7]=ye,e[8]=ve):(ye=e[7],ve=e[8]),(0,S.useEffect)(ye,ve);let xe;if(e[9]!==i||e[10]!==h||e[11]!==p||e[12]!==l||e[13]!==d||e[14]!==$||e[15]!==a){let I=s(async()=>{let Ee=l.trim();if(Ee===""){k(a("Enter a migration id")),u(null);return}x(!0),k(null);try{let Le=await i.query(qt,{direction:h,dryRun:p,id:Ee},Ze(d));u(Le),$.refetch()}catch(Le){let jt=Le;u(null),k(Xe(jt))}x(!1)},"u");xe=s(()=>{je(I())},"V"),e[9]=i,e[10]=h,e[11]=p,e[12]=l,e[13]=d,e[14]=$,e[15]=a,e[16]=xe}else xe=e[16];let ke=xe,we;e[17]===Symbol.for("react.memo_cache_sentinel")?(we=s(I=>{f(I.target.value)},"Y"),e[17]=we):we=e[17];let Nt=we,$e;e[18]===Symbol.for("react.memo_cache_sentinel")?($e=s(I=>{g(I.target.value==="down"?"down":"up")},"Z"),e[18]=$e):$e=e[18];let St=$e,Ne;e[19]===Symbol.for("react.memo_cache_sentinel")?(Ne=s(I=>{b(I.target.checked)},"ee"),e[19]=Ne):Ne=e[19];let Ot=Ne,_;e[20]!==n||e[21]!==d?(_=(0,m.jsx)(tt,{onChange:n,testId:"mg-shard-input",value:d}),e[20]=n,e[21]=d,e[22]=_):_=e[22];let D;e[23]!==Re?(D=(0,m.jsx)(st,{message:Re,prefix:"mg"}),e[23]=Re,e[24]=D):D=e[24];let K;e[25]!==_||e[26]!==D?(K=(0,m.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[_,D]}),e[25]=_,e[26]=D,e[27]=K):K=e[27];let E;e[28]!==Ie||e[29]!==Fe?(E=Ie!==null&&(0,m.jsx)(Te,{error:Fe,testId:"mg-status-error"}),e[28]=Ie,e[29]=Fe,e[30]=E):E=e[30];let J;e[31]!==N||e[32]!==a?(J=N!==null&&N.length===0&&(0,m.jsx)(Oe,{description:a("Data migrations you run against this shard will be tracked here."),icon:(0,m.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,m.jsx)("path",{d:"M4 12a8 8 0 0 1 13.7-5.6L20 8M20 4v4h-4M20 12a8 8 0 0 1-13.7 5.6L4 16m0 4v-4h4"})}),testId:"mg-empty",title:a("No migrations have run on this shard.")}),e[31]=N,e[32]=a,e[33]=J):J=e[33];let A;e[34]!==N||e[35]!==a?(A=N!==null&&N.length>0&&(0,m.jsx)(Qe,{className:"overflow-hidden py-0",children:(0,m.jsx)(Ve,{className:"px-0",children:(0,m.jsxs)(rt,{"data-testid":"mg-table",children:[(0,m.jsx)(it,{children:(0,m.jsxs)(_e,{children:[(0,m.jsx)(q,{children:a("id")}),(0,m.jsx)(q,{children:a("direction")}),(0,m.jsx)(q,{children:a("status")}),(0,m.jsx)(q,{children:a("processed")}),(0,m.jsx)(q,{children:a("changed")}),(0,m.jsx)(q,{children:a("updated")}),(0,m.jsx)(q,{children:a("error")})]})}),(0,m.jsx)(nt,{children:N.map(Tt)})]})})}),e[34]=N,e[35]=a,e[36]=A):A=e[36];let P;e[37]!==a?(P=a("Run migration"),e[37]=a,e[38]=P):P=e[38];let B;e[39]!==P?(B=(0,m.jsx)(De,{children:P}),e[39]=P,e[40]=B):B=e[40];let W;e[41]!==a?(W=a("Migration id"),e[41]=a,e[42]=W):W=e[42];let U;e[43]!==a?(U=a("migration id"),e[43]=a,e[44]=U):U=e[44];let z;e[45]!==l||e[46]!==W||e[47]!==U?(z=(0,m.jsx)(ze,{"aria-label":W,className:"w-auto","data-testid":"mg-id-input",onChange:Nt,placeholder:U,value:l}),e[45]=l,e[46]=W,e[47]=U,e[48]=z):z=e[48];let H;e[49]!==a?(H=a("Direction"),e[49]=a,e[50]=H):H=e[50];let Q;e[51]!==a?(Q=a("up"),e[51]=a,e[52]=Q):Q=e[52];let V;e[53]!==Q?(V=(0,m.jsx)("option",{value:"up",children:Q}),e[53]=Q,e[54]=V):V=e[54];let G;e[55]!==a?(G=a("down"),e[55]=a,e[56]=G):G=e[56];let Z;e[57]!==G?(Z=(0,m.jsx)("option",{value:"down",children:G}),e[57]=G,e[58]=Z):Z=e[58];let X;e[59]!==h||e[60]!==H||e[61]!==V||e[62]!==Z?(X=(0,m.jsxs)("select",{"aria-label":H,className:"flex h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs transition-colors outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 dark:bg-input/30","data-testid":"mg-direction",onChange:St,value:h,children:[V,Z]}),e[59]=h,e[60]=H,e[61]=V,e[62]=Z,e[63]=X):X=e[63];let Y;e[64]!==p?(Y=(0,m.jsx)("input",{checked:p,className:"size-4 accent-primary","data-testid":"mg-dry-run",id:"mg-dry-run",onChange:Ot,type:"checkbox"}),e[64]=p,e[65]=Y):Y=e[65];let ee;e[66]!==a?(ee=a("Dry run"),e[66]=a,e[67]=ee):ee=e[67];let te;e[68]!==Y||e[69]!==ee?(te=(0,m.jsxs)(De,{className:"flex items-center gap-1.5",htmlFor:"mg-dry-run",children:[Y,ee]}),e[68]=Y,e[69]=ee,e[70]=te):te=e[70];let ae;e[71]!==p||e[72]!==ke||e[73]!==y||e[74]!==C||e[75]!==a?(ae=p?(0,m.jsx)(He,{"data-testid":"mg-run",disabled:y||!C,onClick:ke,type:"button",children:a(y?"Running\u2026":"Run")}):(0,m.jsx)(ot,{confirmLabel:a(y?"Running\u2026":"Run migration?"),disabled:y||!C,onConfirm:ke,testId:"mg-run",children:a("Run")}),e[71]=p,e[72]=ke,e[73]=y,e[74]=C,e[75]=a,e[76]=ae):ae=e[76];let re;e[77]!==z||e[78]!==X||e[79]!==te||e[80]!==ae?(re=(0,m.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[z,X,te,ae]}),e[77]=z,e[78]=X,e[79]=te,e[80]=ae,e[81]=re):re=e[81];let ie;e[82]!==B||e[83]!==re?(ie=(0,m.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs",children:[B,re]}),e[82]=B,e[83]=re,e[84]=ie):ie=e[84];let ne;e[85]!==w?(ne=w!==null&&(0,m.jsx)("pre",{className:"text-sm text-destructive whitespace-pre-wrap","data-testid":"mg-run-error",role:"alert",children:w}),e[85]=w,e[86]=ne):ne=e[86];let oe;e[87]!==v||e[88]!==a?(oe=v!==null&&(0,m.jsxs)("p",{className:"text-sm text-muted-foreground","data-testid":"mg-run-result",children:[v.dryRun?a("Dry run: "):"",a("{status} \u2014 processed",{status:v.status}),v.processed,a(", changed"),v.changed]}),e[87]=v,e[88]=a,e[89]=oe):oe=e[89];let Se;return e[90]!==K||e[91]!==E||e[92]!==J||e[93]!==A||e[94]!==ie||e[95]!==ne||e[96]!==oe?(Se=(0,m.jsxs)("div",{className:"flex flex-col gap-3 pt-4","data-testid":"lunora-migrations",children:[K,E,J,A,ie,ne,oe]}),e[90]=K,e[91]=E,e[92]=J,e[93]=A,e[94]=ie,e[95]=ne,e[96]=oe,e[97]=Se):Se=e[97],Se},"yt");function Tt(t){return(0,m.jsxs)(_e,{"data-testid":`mg-row-${t.id}`,children:[(0,m.jsx)(T,{children:t.id}),(0,m.jsx)(T,{children:t.direction}),(0,m.jsx)(T,{children:(0,m.jsx)(Ue,{variant:"secondary",children:t.status})}),(0,m.jsx)(T,{children:t.processed}),(0,m.jsx)(T,{children:t.changed}),(0,m.jsx)(T,{children:qe(t.updatedAt)}),(0,m.jsx)(T,{children:t.error??""})]},t.id)}s(Tt,"Je");var c=se(Pe(),1);var Ke=1;function Ct(t){let e={},r=Object.keys(t);r.sort();for(let i of r)e[i]=t[i];return e}s(Ct,"me");var me=s(t=>typeof t=="object"&&t!==null,"O"),Mt=s(t=>me(t)&&me(t.fields)&&me(t.indexes)&&me(t.relations)&&typeof t.shardMode=="string","ue"),It=s(t=>{if(t===void 0||t.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(t)}catch(r){return{error:`baseline is not valid JSON: ${r instanceof Error?r.message:String(r)}`,status:"invalid"}}if(!me(e)||e.version!==Ke||!me(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(Ke)})`,status:"invalid"};for(let[r,i]of Object.entries(e.tables))if(!Mt(i))return{error:`baseline table "${r}" has an invalid structure`,status:"invalid"};return{snapshot:{jurisdiction:typeof e.jurisdiction=="string"?e.jurisdiction:void 0,migrationIds:Array.isArray(e.migrationIds)?e.migrationIds:[],tables:e.tables,version:Ke},status:"ok"}},"fe"),Ft=s((t,e)=>t.unique===e.unique&&t.fields.length===e.fields.length&&t.fields.every((r,i)=>r===e.fields[i]),"he"),mt=s(t=>t.unique!==void 0,"V"),ge=s(({nullable:t,optional:e,refined:r,unique:i,...a})=>JSON.stringify(Ct(a)),"q"),ut=s(t=>({form:JSON.stringify([ge(t),t.optional===!0,t.nullable===!0]),refined:t.refined===!0}),"G"),ht=s(t=>t.kind==="union"&&t.members?t.members.map(e=>ut(e)):[ut({...t,nullable:!1,optional:!1})],"Q"),Rt=s((t,e)=>{if(e.kind!=="union")return!1;let r=ht(e);return ht(t).every(i=>r.some(a=>a.form===i.form&&(i.refined||!a.refined)))},"pe"),O=s(t=>{switch(t.kind){case"array":return`array(${t.of?O(t.of):"?"})`;case"from":return t.output===void 0?"from":`from(${t.output})`;case"id":return`id(${t.ref??"?"})`;case"literal":return`literal(${t.literal??"?"})`;case"object":return`object({ ${Object.keys(t.fields??{}).join(", ")} })`;case"record":return`record(${t.key?O(t.key):"?"}, ${t.of?O(t.of):"?"})`;case"union":return(t.members??[]).map(e=>O(e)).join(" | ");default:return t.kind}},"x"),fe=s((t,e,r)=>({remediation:"backfill",scope:"table",severity:"breaking",summary:r,table:t,type:e}),"F"),pe=s((t,e,r)=>({remediation:"none",scope:"table",severity:"safe",summary:r,table:t,type:e}),"T"),kt=s((t,e)=>{let r=JSON.stringify(t),i=JSON.stringify(e);return r===i?0:r<i?-1:1},"Z"),ue=s(t=>({...t,...t.kind==="from"?{output:void 0}:{},...t.fields?{fields:Object.fromEntries(Object.entries(t.fields).map(([e,r])=>[e,ue(r)]))}:{},...t.key?{key:ue(t.key)}:{},...t.of?{of:ue(t.of)}:{},...t.members?{members:t.members.map(e=>ue(e)).toSorted(kt)}:{}}),"S"),ft=s(t=>t.kind==="union"?t.members??[]:[t],"U"),Lt=s((t,e)=>{let r=[...t],i=[...e],a=new Set,o=new Set,n=s((d,l)=>{for(let[f,h]of r.entries()){if(o.has(f))continue;let g=i.findIndex((p,b)=>!a.has(b)&&d(h,p));g!==-1&&(a.add(g),o.add(f),l&&([r[f],i[g]]=Me(h,i[g])))}},"s");return n((d,l)=>JSON.stringify(d)===JSON.stringify(l),!1),n((d,l)=>ge(ue(d))===ge(ue(l)),!0),[r,i]},"ge"),Me=s((t,e)=>{if(t.kind==="union"||e.kind==="union"){let[a,o]=Lt(ft(t),ft(e)),n=s((d,l)=>d.kind==="union"?{...d,members:l.toSorted(kt)}:l[0],"s");return[n(t,a),n(e,o)]}if(t.kind!==e.kind)return[t,e];if(t.kind==="from")return t.output===void 0||e.output===void 0?[{...t,output:void 0},{...e,output:void 0}]:[t,e];let r={...t.fields?{fields:{...t.fields}}:{}},i={...e.fields?{fields:{...e.fields}}:{}};for(let a of["key","of"])t[a]&&e[a]&&([r[a],i[a]]=Me(t[a],e[a]));for(let a of Object.keys(t.fields??{})){let o=t.fields?.[a],n=e.fields?.[a];o&&n&&r.fields&&i.fields&&([r.fields[a],i.fields[a]]=Me(o,n))}return[{...t,...r},{...e,...i}]},"I"),_t=s((t,e,r,i,a)=>{let[o,n]=Me(r,i);if(o.kind===n.kind&&(!a||ge(o)===ge(n)))return;if(a&&Rt(o,n))return pe(t,"widenedFieldShape",`field ${t}.${e} widened: ${O(o)} \u2192 ${O(n)} \u2014 every stored value stays valid`);if(o.kind!==n.kind)return fe(t,"changedFieldKind",`field ${t}.${e} changed type: ${o.kind} \u2192 ${n.kind} \u2014 add a data migration to convert existing values`);let d=Object.values(n.fields??{});return a&&o.kind==="object"&&Object.keys(o.fields??{}).length===0&&d.length>0&&d.every(l=>l.optional)?pe(t,"widenedFieldShape",`field ${t}.${e} now records its optional object shape \u2014 stored values stay valid`):fe(t,"changedFieldShape",`field ${t}.${e} changed shape: ${O(o)} \u2192 ${O(n)} \u2014 stored values were written against the old shape; add a data migration to convert them`)},"be"),Dt=s((t,e,r,i)=>{let a=[];return r.unique!==i.unique&&a.push(i.unique===!0?fe(t,"addedFieldConstraint",`field ${t}.${e} became unique \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`):pe(t,"relaxedFieldConstraint",`field ${t}.${e} is no longer unique`)),r.nullable!==i.nullable&&a.push(i.nullable===!0?pe(t,"relaxedFieldConstraint",`field ${t}.${e} became nullable`):fe(t,"addedFieldConstraint",`field ${t}.${e} is no longer nullable \u2014 rows holding NULL would be invalid; add a data migration to backfill them`)),r.refined!==i.refined&&a.push(i.refined===!0?fe(t,"addedFieldConstraint",`field ${t}.${e} gained a validation refinement \u2014 stored values were never checked against it; add a data migration if any could fail`):pe(t,"relaxedFieldConstraint",`field ${t}.${e} dropped its validation refinement`)),a},"ye"),wt=s((t,e,r,i)=>{let a=[],o=mt(r)&&mt(i),n=_t(t,e,r,i,o);return n&&a.push(n),o&&a.push(...Dt(t,e,r,i)),r.optional&&!i.optional?a.push({remediation:"backfill",severity:"breaking",summary:`field ${t}.${e} became required \u2014 rows missing it would be invalid; add a data migration to backfill it`,table:t,scope:"table",type:"fieldOptionalToRequired"}):!r.optional&&i.optional&&a.push({remediation:"none",scope:"table",severity:"safe",summary:`field ${t}.${e} became optional`,table:t,type:"fieldRequiredToOptional"}),a},"N"),Kt=s((t,e,r)=>r.optional?{remediation:"none",scope:"table",severity:"safe",summary:`added optional field ${t}.${e}`,table:t,type:"addedOptionalField"}:{remediation:"backfill",severity:"breaking",summary:`added required field ${t}.${e} \u2014 existing rows have no value; add a data migration to backfill it`,table:t,scope:"table",type:"addedRequiredField"},"ve"),Et=s((t,e,r,i)=>{for(let[a,o]of Object.entries(r.fields)){let n=e.fields[a];n===void 0?i.push(Kt(t,a,o)):i.push(...wt(t,a,n,o))}for(let a of Object.keys(e.fields))r.fields[a]===void 0&&i.push({remediation:"backfill",severity:"breaking",summary:`removed field ${t}.${a} \u2014 add a data migration if stored data must be cleaned up`,table:t,scope:"table",type:"removedField"})},"xe"),Jt=s((t,e,r,i)=>{for(let[a,o]of Object.entries(r.indexes)){let n=e.indexes[a];if(n===void 0){i.push(o.unique?{remediation:"backfill",scope:"table",severity:"breaking",summary:`added unique index ${a} on ${t} \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`,table:t,type:"addedIndex"}:{remediation:"none",scope:"table",severity:"safe",summary:`added index ${a} on ${t}`,table:t,type:"addedIndex"});continue}Ft(n,o)||i.push({remediation:"code",severity:"breaking",summary:`index ${a} on ${t} changed shape \u2014 a query may have relied on the old index`,table:t,scope:"table",type:"changedIndex"})}for(let a of Object.keys(e.indexes))r.indexes[a]===void 0&&i.push({remediation:"code",severity:"breaking",summary:`removed index ${a} on ${t} \u2014 a query that used \`.withIndex("${a}")\` would break`,table:t,scope:"table",type:"removedIndex"})},"ke"),At=s((t,e,r,i)=>{for(let a of Object.keys(r.relations))e.relations[a]===void 0&&i.push({remediation:"none",scope:"schema",severity:"safe",summary:`added relation ${t}.${a}`,table:t,type:"addedRelation"});for(let a of Object.keys(e.relations))r.relations[a]===void 0&&i.push({remediation:"code",scope:"schema",severity:"breaking",summary:`removed relation ${t}.${a}`,table:t,type:"removedRelation"})},"$e"),pt="shardBy:_unknown_",Ce="global",Pt=s((t,e)=>t===Ce&&e.startsWith(`${Ce}:`)||e===Ce&&t.startsWith(`${Ce}:`),"we"),Bt=s((t,e,r)=>{if(e===r)return r!==pt?void 0:{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} declares a non-literal .shardBy(...) key, so codegen cannot read which column partitions it \u2014 every such key records as "${pt}" and two DIFFERENT keys would compare equal. Pass the shard key as a string literal; until then this is reported on every run, because the alternative is a silent pass on a re-home that strands every row (export/import is the only way back).`,table:t,type:"changedShardMode"};if(!Pt(e,r))return{remediation:"rehome",severity:"breaking",summary:`table ${t} changed shard mode: ${e} \u2192 ${r} \u2014 its physical storage moves, and existing rows do NOT follow the schema; re-home them with an export/import round trip (https://lunora.sh/docs/concepts/sharding#migrating-a-populated-table)`,table:t,scope:"table",type:"changedShardMode"}},"Oe"),gt=s(t=>t.memory!==void 0,"B"),bt=s(t=>t.after??0,"K"),R=s(t=>t.after===void 0?`.ttl("${t.field}")`:`.ttl("${t.field}", { after: ${String(t.after)} })`,"w"),Wt=s((t,e,r)=>{if(e===void 0&&r===void 0)return;let i=s(d=>({remediation:"backfill",scope:"table",severity:"breaking",summary:d,table:t,type:"changedTtlPolicy"}),"i"),a=s(d=>({remediation:"none",scope:"table",severity:"safe",summary:d,table:t,type:"changedTtlPolicy"}),"o");if(r===void 0)return a(`table ${t} dropped its TTL policy \u2014 its rows are no longer swept`);if(e===void 0)return i(`table ${t} gained a TTL policy ${R(r)} \u2014 every row already past the cutoff is deleted on the next alarm sweep; add a data migration to refresh or clear "${r.field}" on the rows written before it`);if(e.field!==r.field)return i(`table ${t} moved its TTL to a different column: ${R(e)} \u2192 ${R(r)} \u2014 rows are now expired by a column they were never written against; add a data migration to populate "${r.field}"`);let o=bt(e),n=bt(r);return n<o?i(`table ${t} shortened its TTL: ${R(e)} \u2192 ${R(r)} \u2014 rows that were not expired under the old offset are deleted on the next alarm sweep; add a data migration to refresh "${r.field}" on the rows that must survive`):n>o?a(`table ${t} lengthened its TTL: ${R(e)} \u2192 ${R(r)}`):void 0},"Se"),Ut=s((t,e,r)=>{let i=[];return e.memory!==r.memory&&i.push(r.memory===!0?{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} became a .memory() table \u2014 every row is deleted in every shard on the next Durable Object cold start, and no data migration survives that; export the rows first if they must be kept, or revert`,table:t,type:"changedMemoryMode"}:{remediation:"none",scope:"table",severity:"safe",summary:`table ${t} is no longer a .memory() table \u2014 its rows now survive a cold start`,table:t,type:"changedMemoryMode"}),e.commitOrdered!==r.commitOrdered&&i.push(r.commitOrdered===!0?{remediation:"backfill",scope:"table",severity:"breaking",summary:`table ${t} became .commitOrdered() \u2014 rows written before it carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed never offers them; add a data migration over the table to stamp them (the rewrite allocates a sequence)`,table:t,type:"changedCommitOrdering"}:{remediation:"code",scope:"table",severity:"breaking",summary:`table ${t} is no longer .commitOrdered() \u2014 new rows carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed stops advancing without erroring; update the consumers before deploying`,table:t,type:"changedCommitOrdering"}),i},"je"),zt=s((t,e,r,i)=>{let a=Bt(t,e.shardMode,r.shardMode);if(a&&i.push(a),gt(e)&>(r)){i.push(...Ut(t,e,r));let o=Wt(t,e.ttl,r.ttl);o&&i.push(o)}Et(t,e,r,i),Jt(t,e,r,i),At(t,e,r,i)},"Fe"),Ht=s((t,e)=>{let r=[],i=t?.tables??{};for(let[a,o]of Object.entries(e.tables)){let n=i[a];if(n===void 0){r.push({remediation:"none",scope:"table",severity:"safe",summary:`added table ${a}`,table:a,type:"addedTable"});continue}zt(a,n,o,r)}for(let a of Object.keys(i))e.tables[a]===void 0&&r.push({remediation:"rehome",scope:"table",severity:"breaking",summary:`removed table ${a} \u2014 its rows stay in each shard's SQLite, unreachable through the schema; export the shard first if the data must be kept`,table:a,type:"removedTable"});if(t!==void 0&&t.jurisdiction!==e.jurisdiction){let a=t.jurisdiction??"(none)",o=e.jurisdiction??"(none)";r.push({remediation:"rehome",scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${a} to ${o} \u2014 this re-homes every DO and strands all existing shard, scheduler, and session-DO data in the old region (no in-place migration; export then import to move it). Revert the change, or override the gate to proceed intentionally.`,type:"changedJurisdiction"})}return{changes:r}},"Te"),yt=s(t=>Object.entries(t.fields).map(([e,r])=>({name:e,optional:r.optional,ref:Object.values(t.relations).find(i=>i.field===e&&i.kind==="one")?.table,type:O(r)})),"Y"),vt=s((t,e,r)=>{let i={},a=e?.fields??{},o=r?.fields??{};for(let[n,d]of Object.entries(o)){let l=a[n];l===void 0?i[n]=e===void 0?"unchanged":"added":i[n]=wt(t,n,l,d).length===0?"unchanged":"changed"}for(let n of Object.keys(a))o[n]===void 0&&(i[n]="removed");return i},"z"),Qt=s((t,e)=>{let{changes:r}=Ht(t,e),i=new Set(r.filter(n=>n.scope==="table"&&n.table!==void 0).map(n=>n.table)),a=[],o=s((n,d)=>n?"added":i.has(d)?"changed":"context","r");for(let[n,d]of Object.entries(e.tables)){let l=t?.tables[n],f=o(l===void 0,n);a.push({columns:yt(d),fieldStatus:vt(n,l,d),name:n,shardMode:d.shardMode,status:f})}for(let[n,d]of Object.entries(t?.tables??{}))e.tables[n]===void 0&&a.push({columns:yt(d),fieldStatus:vt(n,d,void 0),name:n,shardMode:d.shardMode,status:"removed"});return a.sort((n,d)=>n.name.localeCompare(d.name)),{breakingCount:r.filter(n=>n.severity==="breaking").length,changes:r,tables:a}},"Me"),xt=s(t=>{let e=It(t);return e.status==="ok"?e.snapshot:void 0},"X"),Vt={added:"ring-2 ring-emerald-500/60",changed:"ring-2 ring-amber-500/70",context:"opacity-55",removed:"opacity-70 ring-2 ring-destructive/60"},Gt=s(t=>t==="global"||t.startsWith("global:")?"global":"shard","Ce"),Zt=s(t=>{let e=(0,be.c)(24),{appliedAt:r,hash:i,onSelect:a,selected:o,seq:n}=t,d=o?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground",l;e[0]!==d?(l=de("flex w-full flex-col items-start gap-1 border-s-2 px-4 py-3 text-start outline-none transition-colors",d),e[0]=d,e[1]=l):l=e[1];let f=`sh-version-${i}`,h;e[2]!==i||e[3]!==a?(h=s(()=>{a(i)},"f"),e[2]=i,e[3]=a,e[4]=h):h=e[4];let g;e[5]!==n?(g=(0,c.jsxs)("span",{className:"font-mono text-[13px] tabular-nums",children:["v",n]}),e[5]=n,e[6]=g):g=e[6];let p;e[7]!==i?(p=i.slice(0,7),e[7]=i,e[8]=p):p=e[8];let b;e[9]!==p?(b=(0,c.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:p}),e[9]=p,e[10]=b):b=e[10];let y;e[11]!==g||e[12]!==b?(y=(0,c.jsxs)("span",{className:"flex w-full items-baseline gap-2",children:[g,b]}),e[11]=g,e[12]=b,e[13]=y):y=e[13];let x;e[14]!==r?(x=qe(r),e[14]=r,e[15]=x):x=e[15];let v;e[16]!==x?(v=(0,c.jsx)("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:x}),e[16]=x,e[17]=v):v=e[17];let u;return e[18]!==v||e[19]!==l||e[20]!==f||e[21]!==h||e[22]!==y?(u=(0,c.jsx)("li",{children:(0,c.jsxs)("button",{className:l,"data-testid":f,onClick:h,type:"button",children:[y,v]})}),e[18]=v,e[19]=l,e[20]=f,e[21]=h,e[22]=y,e[23]=u):u=e[23],u},"Ie"),Xt=s(t=>{let e=(0,be.c)(26),{breaking:r,count:i,first:a}=t,o=le();if(a){let b;e[0]!==i?(b=(0,c.jsx)("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:i}),e[0]=i,e[1]=b):b=e[1];let y;e[2]!==o?(y=o("tables"),e[2]=o,e[3]=y):y=e[3];let x;e[4]!==y?(x=(0,c.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:y}),e[4]=y,e[5]=x):x=e[5];let v;return e[6]!==b||e[7]!==x?(v=(0,c.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[b,x]}),e[6]=b,e[7]=x,e[8]=v):v=e[8],v}let n=r>0&&"text-destructive",d;e[9]!==n?(d=de("text-3xl leading-none font-light tracking-tight tabular-nums",n),e[9]=n,e[10]=d):d=e[10];let l;e[11]!==i||e[12]!==d?(l=(0,c.jsx)("span",{className:d,children:i}),e[11]=i,e[12]=d,e[13]=l):l=e[13];let f;e[14]!==i||e[15]!==o?(f=o(i===1?"change":"changes"),e[14]=i,e[15]=o,e[16]=f):f=e[16];let h;e[17]!==f?(h=(0,c.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:f}),e[17]=f,e[18]=h):h=e[18];let g;e[19]!==r||e[20]!==o?(g=r>0&&(0,c.jsxs)("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["\xB7 ",o("{count} breaking",{count:r})]}),e[19]=r,e[20]=o,e[21]=g):g=e[21];let p;return e[22]!==l||e[23]!==h||e[24]!==g?(p=(0,c.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[l,h,g]}),e[22]=l,e[23]=h,e[24]=g,e[25]=p):p=e[25],p},"Re"),$t={addedFieldConstraint:{action:"added",kind:"constraint"},addedIndex:{action:"added",kind:"index"},addedOptionalField:{action:"added",kind:"field?"},addedRelation:{action:"added",kind:"relation"},addedRequiredField:{action:"added",kind:"field"},addedTable:{action:"added",kind:"table"},changedCommitOrdering:{action:"changed",kind:"commit ordering"},changedFieldKind:{action:"changed",kind:"field kind"},changedFieldShape:{action:"changed",kind:"field shape"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedMemoryMode:{action:"changed",kind:"memory mode"},changedShardMode:{action:"changed",kind:"shard mode"},changedTtlPolicy:{action:"changed",kind:"TTL policy"},fieldOptionalToRequired:{action:"changed",kind:"field \u2192 required"},fieldRequiredToOptional:{action:"changed",kind:"field \u2192 optional"},relaxedFieldConstraint:{action:"removed",kind:"constraint"},removedField:{action:"removed",kind:"field"},removedIndex:{action:"removed",kind:"index"},removedRelation:{action:"removed",kind:"relation"},removedTable:{action:"removed",kind:"table"},widenedFieldShape:{action:"changed",kind:"field \u2192 wider"}},Yt=s((t,e)=>{let r=`${$t[t.type].action} ${e} `;return t.summary.startsWith(r)?t.summary.slice(r.length):t.summary},"Ee"),ea=s(t=>{let e=new Map;for(let i of t){let a=i.table??"",o=e.get(a);o===void 0?e.set(a,[i]):o.push(i)}let r=[...e].map(([i,a])=>({changes:a,table:i}));return[...r.filter(i=>i.table!==""),...r.filter(i=>i.table==="")]},"Ae"),ta=s(t=>{let e=(0,be.c)(2),{children:r}=t,i;return e[0]!==r?(i=(0,c.jsx)("div",{className:"px-4 pt-4 pb-2 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:r}),e[0]=r,e[1]=i):i=e[1],i},"De"),aa=s(({pane:t,shardKey:e=""})=>{let r=le(),i=We(),a=Be({strict:!1}).version,o=s(u=>{je(i({search:{version:u},to:"/migrations"}))},"s"),n=ce(F.schemaHistory,{},{shardKey:e}),d=n.data?.versions??[],l=a!==void 0&&d.some(u=>u.hash===a)?a:d[0]?.hash,f=d.findIndex(u=>u.hash===l),h=f===-1?void 0:d[f+1]?.hash,g=ce(F.schemaVersion,{hash:l??""},{enabled:l!==void 0,shardKey:e}),p=ce(F.schemaVersion,{hash:h??""},{enabled:h!==void 0,shardKey:e}),b=(0,he.useMemo)(()=>{let u=xt(g.data?.version?.snapshotJson);if(u!==void 0)return Qt(xt(p.data?.version?.snapshotJson),u)},[g.data,p.data]),y=(0,he.useMemo)(()=>(b?.tables??[]).map(u=>({columns:u.columns,name:u.name,tier:Gt(u.shardMode)})),[b]),x=(0,he.useMemo)(()=>{let u={};for(let w of b?.tables??[])u[w.name]=Vt[w.status];return u},[b]);if(n.error!==null)return(0,c.jsx)(Te,{error:n.errorSource,testId:"sh-error"});if(d.length===0)return(0,c.jsx)(Oe,{description:r("Each distinct schema shape this shard runs is recorded here, so you can see what changed and when."),testId:"sh-empty",title:r("No schema versions recorded yet.")});let v=b?.changes??[];return(0,c.jsxs)("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[(0,c.jsxs)("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[(0,c.jsx)(ta,{children:r("Schema versions")}),(0,c.jsx)("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:d.map(u=>(0,c.jsx)(Zt,{appliedAt:u.appliedAt,hash:u.hash,onSelect:o,selected:u.hash===l,seq:u.seq},u.hash))})]}),(0,c.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[(0,c.jsx)(Xt,{breaking:b?.breakingCount??0,count:h===void 0?y.length:v.length,first:h===void 0}),t==="diagram"?(0,c.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,c.jsx)(dt,{fill:!0,nodeClasses:x,tables:y,testIdPrefix:"sh"})}):(0,c.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:ea(v).map(u=>{let w=(b?.tables??[]).find(k=>k.name===u.table);return(0,c.jsxs)("section",{className:"mb-6",children:[(0,c.jsxs)("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[(0,c.jsx)("span",{className:"font-mono text-[13px] text-foreground",children:u.table===""?r("schema"):u.table}),w!==void 0&&(0,c.jsx)("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:r("{count} columns",{count:w.columns.length})}),u.changes.length>1&&(0,c.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:u.changes.length})]}),(0,c.jsx)("ul",{children:u.changes.map(k=>{let{action:L,kind:C}=$t[k.type],j=k.severity==="breaking",M=Yt(k,C);return(0,c.jsxs)("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[(0,c.jsx)("span",{"aria-hidden":"true",className:de("-ms-3 h-3 w-0.5 shrink-0 self-center",j?"bg-destructive":"bg-transparent")}),(0,c.jsxs)("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[r(L)," ",C]}),M!==u.table&&(0,c.jsx)("span",{className:de("min-w-0 font-mono text-[13px]",j?"text-destructive":"text-foreground"),children:M}),j&&(0,c.jsx)("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:r("breaking")})]},`${k.type}-${k.summary}`)})})]},u.table)})})]})]})},"Le"),ra=s(t=>de("-mb-px border-b-2 px-3 py-2.5 font-mono text-[11px] tracking-wider uppercase transition-colors outline-none","hover:bg-accent/40 focus-visible:bg-accent/40",t?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"Je"),Ra=s(t=>{let e=(0,be.c)(11),{initialShardKey:r}=t,i=le(),[a,o]=(0,he.useState)("diagram"),n;e[0]!==a?(n=s((g,p,b,y)=>(0,c.jsxs)("button",{"aria-selected":a===g,className:ra(a===g),"data-testid":b,onClick:s(()=>{o(g)},"onClick"),role:"tab",type:"button",children:[p,y!==void 0&&(0,c.jsx)("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:y})]}),"s"),e[0]=a,e[1]=n):n=e[1];let d=n,l;e[2]!==i||e[3]!==d?(l=(0,c.jsxs)("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-3","data-testid":"mg-panes",role:"tablist",children:[d("diagram",i("Diagram"),"mg-pane-diagram"),d("changes",i("Changes"),"mg-pane-changes"),d("data",i("Data migrations"),"mg-pane-data")]}),e[2]=i,e[3]=d,e[4]=l):l=e[4];let f;e[5]!==r||e[6]!==a?(f=(0,c.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:a==="data"?(0,c.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:(0,c.jsx)(ct,{initialShardKey:r})}):(0,c.jsx)(aa,{pane:a,shardKey:r})}),e[5]=r,e[6]=a,e[7]=f):f=e[7];let h;return e[8]!==l||e[9]!==f?(h=(0,c.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[l,f]}),e[8]=l,e[9]=f,e[10]=h):h=e[10],h},"Ze");export{Ra as default};
|
|
1
|
+
import{a as dt}from"./chunk-MHJNM7VT.js";import"./chunk-7RGYCU6F.js";import"./chunk-F4VO76XV.js";import"./chunk-SYGCASPT.js";import"./chunk-CTE6RPXC.js";import"./chunk-LIGOLZND.js";import"./chunk-3GXPALXG.js";import{a as De}from"./chunk-OUFWXYEF.js";import{a as st}from"./chunk-XBZUJDHD.js";import"./chunk-AP4PC2M4.js";import"./chunk-KRPXOSBL.js";import"./chunk-W2BCSK5S.js";import"./chunk-NGVP66OH.js";import"./chunk-XYR5NST4.js";import{a as at}from"./chunk-5DNGK3NT.js";import{a as ot}from"./chunk-ZWDORIZY.js";import{a as tt}from"./chunk-KYONGQQ4.js";import{b as et}from"./chunk-SLIDAWNX.js";import"./chunk-6M7FLLMT.js";import{h as Be,i as We}from"./chunk-LUHXNZI4.js";import"./chunk-ZTOREMGH.js";import{i as ze}from"./chunk-SDQH4HR6.js";import"./chunk-W7MRISE3.js";import"./chunk-IBJVVHV5.js";import{a as He}from"./chunk-2O6KKVH2.js";import"./chunk-JTGGWF7R.js";import"./chunk-ZBON5T5A.js";import{b as Ue}from"./chunk-6I42AM75.js";import"./chunk-4C4THJUD.js";import{a as Te}from"./chunk-GMO7IUXO.js";import"./chunk-OSJ7HV7B.js";import"./chunk-5SYMAYUA.js";import"./chunk-E26OT26O.js";import{a as F}from"./chunk-6UTZXEW3.js";import{c as ce}from"./chunk-W37HRJGQ.js";import{p as Ye}from"./chunk-SDSQIQJG.js";import"./chunk-WZTY3ZYI.js";import{a as Oe}from"./chunk-3Y5K3IQO.js";import{a as rt,b as it,c as nt,d as _e,e as q,f as T}from"./chunk-CW57Q264.js";import{a as Qe,e as Ve}from"./chunk-MD67S53Z.js";import{b as de,f as le,h as Ge,i as Ze,j as Xe,s as je,w as qe}from"./chunk-LPINY2IJ.js";import{a as s,d as se,e as Je,f as Ae,g as Pe}from"./chunk-OXFKZ4BM.js";var be=se(Ae(),1),he=se(Je(),1);var lt=se(Ae(),1),S=se(Je(),1);var m=se(Pe(),1);var qt=Ge(F.runMigration),ct=s(t=>{let e=(0,lt.c)(98),{initialShardKey:r}=t,i=Ye(),a=le(),{queryShardKey:o,setShardKey:n,shardKey:d}=at(r),[l,f]=(0,S.useState)(""),[h,g]=(0,S.useState)("up"),[p,b]=(0,S.useState)(!0),[y,x]=(0,S.useState)(!1),[v,u]=(0,S.useState)(null),[w,k]=(0,S.useState)(null),L;e[0]!==d?(L=d.trim(),e[0]=d,e[1]=L):L=e[1];let C=L===o,j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j={},e[2]=j):j=e[2];let M;e[3]!==o?(M={live:!0,shardKey:o},e[3]=o,e[4]=M):M=e[4];let $=ce(F.migrationStatus,j,M),N=$.data?.migrations??null,Ie=$.error,{errorSource:Fe,liveError:Re}=$,ye,ve;e[5]!==o||e[6]!==$.data?(ye=s(()=>{$.data!==void 0&&et(o)},"W"),ve=[$.data,o],e[5]=o,e[6]=$.data,e[7]=ye,e[8]=ve):(ye=e[7],ve=e[8]),(0,S.useEffect)(ye,ve);let xe;if(e[9]!==i||e[10]!==h||e[11]!==p||e[12]!==l||e[13]!==d||e[14]!==$||e[15]!==a){let I=s(async()=>{let Ee=l.trim();if(Ee===""){k(a("Enter a migration id")),u(null);return}x(!0),k(null);try{let Le=await i.query(qt,{direction:h,dryRun:p,id:Ee},Ze(d));u(Le),$.refetch()}catch(Le){let jt=Le;u(null),k(Xe(jt))}x(!1)},"u");xe=s(()=>{je(I())},"V"),e[9]=i,e[10]=h,e[11]=p,e[12]=l,e[13]=d,e[14]=$,e[15]=a,e[16]=xe}else xe=e[16];let ke=xe,we;e[17]===Symbol.for("react.memo_cache_sentinel")?(we=s(I=>{f(I.target.value)},"Y"),e[17]=we):we=e[17];let Nt=we,$e;e[18]===Symbol.for("react.memo_cache_sentinel")?($e=s(I=>{g(I.target.value==="down"?"down":"up")},"Z"),e[18]=$e):$e=e[18];let St=$e,Ne;e[19]===Symbol.for("react.memo_cache_sentinel")?(Ne=s(I=>{b(I.target.checked)},"ee"),e[19]=Ne):Ne=e[19];let Ot=Ne,_;e[20]!==n||e[21]!==d?(_=(0,m.jsx)(tt,{onChange:n,testId:"mg-shard-input",value:d}),e[20]=n,e[21]=d,e[22]=_):_=e[22];let D;e[23]!==Re?(D=(0,m.jsx)(st,{message:Re,prefix:"mg"}),e[23]=Re,e[24]=D):D=e[24];let K;e[25]!==_||e[26]!==D?(K=(0,m.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[_,D]}),e[25]=_,e[26]=D,e[27]=K):K=e[27];let E;e[28]!==Ie||e[29]!==Fe?(E=Ie!==null&&(0,m.jsx)(Te,{error:Fe,testId:"mg-status-error"}),e[28]=Ie,e[29]=Fe,e[30]=E):E=e[30];let J;e[31]!==N||e[32]!==a?(J=N!==null&&N.length===0&&(0,m.jsx)(Oe,{description:a("Data migrations you run against this shard will be tracked here."),icon:(0,m.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,m.jsx)("path",{d:"M4 12a8 8 0 0 1 13.7-5.6L20 8M20 4v4h-4M20 12a8 8 0 0 1-13.7 5.6L4 16m0 4v-4h4"})}),testId:"mg-empty",title:a("No migrations have run on this shard.")}),e[31]=N,e[32]=a,e[33]=J):J=e[33];let A;e[34]!==N||e[35]!==a?(A=N!==null&&N.length>0&&(0,m.jsx)(Qe,{className:"overflow-hidden py-0",children:(0,m.jsx)(Ve,{className:"px-0",children:(0,m.jsxs)(rt,{"data-testid":"mg-table",children:[(0,m.jsx)(it,{children:(0,m.jsxs)(_e,{children:[(0,m.jsx)(q,{children:a("id")}),(0,m.jsx)(q,{children:a("direction")}),(0,m.jsx)(q,{children:a("status")}),(0,m.jsx)(q,{children:a("processed")}),(0,m.jsx)(q,{children:a("changed")}),(0,m.jsx)(q,{children:a("updated")}),(0,m.jsx)(q,{children:a("error")})]})}),(0,m.jsx)(nt,{children:N.map(Tt)})]})})}),e[34]=N,e[35]=a,e[36]=A):A=e[36];let P;e[37]!==a?(P=a("Run migration"),e[37]=a,e[38]=P):P=e[38];let B;e[39]!==P?(B=(0,m.jsx)(De,{children:P}),e[39]=P,e[40]=B):B=e[40];let W;e[41]!==a?(W=a("Migration id"),e[41]=a,e[42]=W):W=e[42];let U;e[43]!==a?(U=a("migration id"),e[43]=a,e[44]=U):U=e[44];let z;e[45]!==l||e[46]!==W||e[47]!==U?(z=(0,m.jsx)(ze,{"aria-label":W,className:"w-auto","data-testid":"mg-id-input",onChange:Nt,placeholder:U,value:l}),e[45]=l,e[46]=W,e[47]=U,e[48]=z):z=e[48];let H;e[49]!==a?(H=a("Direction"),e[49]=a,e[50]=H):H=e[50];let Q;e[51]!==a?(Q=a("up"),e[51]=a,e[52]=Q):Q=e[52];let V;e[53]!==Q?(V=(0,m.jsx)("option",{value:"up",children:Q}),e[53]=Q,e[54]=V):V=e[54];let G;e[55]!==a?(G=a("down"),e[55]=a,e[56]=G):G=e[56];let Z;e[57]!==G?(Z=(0,m.jsx)("option",{value:"down",children:G}),e[57]=G,e[58]=Z):Z=e[58];let X;e[59]!==h||e[60]!==H||e[61]!==V||e[62]!==Z?(X=(0,m.jsxs)("select",{"aria-label":H,className:"flex h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs transition-colors outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 dark:bg-input/30","data-testid":"mg-direction",onChange:St,value:h,children:[V,Z]}),e[59]=h,e[60]=H,e[61]=V,e[62]=Z,e[63]=X):X=e[63];let Y;e[64]!==p?(Y=(0,m.jsx)("input",{checked:p,className:"size-4 accent-primary","data-testid":"mg-dry-run",id:"mg-dry-run",onChange:Ot,type:"checkbox"}),e[64]=p,e[65]=Y):Y=e[65];let ee;e[66]!==a?(ee=a("Dry run"),e[66]=a,e[67]=ee):ee=e[67];let te;e[68]!==Y||e[69]!==ee?(te=(0,m.jsxs)(De,{className:"flex items-center gap-1.5",htmlFor:"mg-dry-run",children:[Y,ee]}),e[68]=Y,e[69]=ee,e[70]=te):te=e[70];let ae;e[71]!==p||e[72]!==ke||e[73]!==y||e[74]!==C||e[75]!==a?(ae=p?(0,m.jsx)(He,{"data-testid":"mg-run",disabled:y||!C,onClick:ke,type:"button",children:a(y?"Running\u2026":"Run")}):(0,m.jsx)(ot,{confirmLabel:a(y?"Running\u2026":"Run migration?"),disabled:y||!C,onConfirm:ke,testId:"mg-run",children:a("Run")}),e[71]=p,e[72]=ke,e[73]=y,e[74]=C,e[75]=a,e[76]=ae):ae=e[76];let re;e[77]!==z||e[78]!==X||e[79]!==te||e[80]!==ae?(re=(0,m.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[z,X,te,ae]}),e[77]=z,e[78]=X,e[79]=te,e[80]=ae,e[81]=re):re=e[81];let ie;e[82]!==B||e[83]!==re?(ie=(0,m.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs",children:[B,re]}),e[82]=B,e[83]=re,e[84]=ie):ie=e[84];let ne;e[85]!==w?(ne=w!==null&&(0,m.jsx)("pre",{className:"text-sm text-destructive whitespace-pre-wrap","data-testid":"mg-run-error",role:"alert",children:w}),e[85]=w,e[86]=ne):ne=e[86];let oe;e[87]!==v||e[88]!==a?(oe=v!==null&&(0,m.jsxs)("p",{className:"text-sm text-muted-foreground","data-testid":"mg-run-result",children:[v.dryRun?a("Dry run: "):"",a("{status} \u2014 processed",{status:v.status}),v.processed,a(", changed"),v.changed]}),e[87]=v,e[88]=a,e[89]=oe):oe=e[89];let Se;return e[90]!==K||e[91]!==E||e[92]!==J||e[93]!==A||e[94]!==ie||e[95]!==ne||e[96]!==oe?(Se=(0,m.jsxs)("div",{className:"flex flex-col gap-3 pt-4","data-testid":"lunora-migrations",children:[K,E,J,A,ie,ne,oe]}),e[90]=K,e[91]=E,e[92]=J,e[93]=A,e[94]=ie,e[95]=ne,e[96]=oe,e[97]=Se):Se=e[97],Se},"yt");function Tt(t){return(0,m.jsxs)(_e,{"data-testid":`mg-row-${t.id}`,children:[(0,m.jsx)(T,{children:t.id}),(0,m.jsx)(T,{children:t.direction}),(0,m.jsx)(T,{children:(0,m.jsx)(Ue,{variant:"secondary",children:t.status})}),(0,m.jsx)(T,{children:t.processed}),(0,m.jsx)(T,{children:t.changed}),(0,m.jsx)(T,{children:qe(t.updatedAt)}),(0,m.jsx)(T,{children:t.error??""})]},t.id)}s(Tt,"Je");var c=se(Pe(),1);var Ke=1;function Ct(t){let e={},r=Object.keys(t);r.sort();for(let i of r)e[i]=t[i];return e}s(Ct,"me");var me=s(t=>typeof t=="object"&&t!==null,"O"),Mt=s(t=>me(t)&&me(t.fields)&&me(t.indexes)&&me(t.relations)&&typeof t.shardMode=="string","ue"),It=s(t=>{if(t===void 0||t.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(t)}catch(r){return{error:`baseline is not valid JSON: ${r instanceof Error?r.message:String(r)}`,status:"invalid"}}if(!me(e)||e.version!==Ke||!me(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(Ke)})`,status:"invalid"};for(let[r,i]of Object.entries(e.tables))if(!Mt(i))return{error:`baseline table "${r}" has an invalid structure`,status:"invalid"};return{snapshot:{jurisdiction:typeof e.jurisdiction=="string"?e.jurisdiction:void 0,migrationIds:Array.isArray(e.migrationIds)?e.migrationIds:[],tables:e.tables,version:Ke},status:"ok"}},"fe"),Ft=s((t,e)=>t.unique===e.unique&&t.fields.length===e.fields.length&&t.fields.every((r,i)=>r===e.fields[i]),"he"),mt=s(t=>t.unique!==void 0,"V"),ge=s(({nullable:t,optional:e,refined:r,unique:i,...a})=>JSON.stringify(Ct(a)),"q"),ut=s(t=>({form:JSON.stringify([ge(t),t.optional===!0,t.nullable===!0]),refined:t.refined===!0}),"G"),ht=s(t=>t.kind==="union"&&t.members?t.members.map(e=>ut(e)):[ut({...t,nullable:!1,optional:!1})],"Q"),Rt=s((t,e)=>{if(e.kind!=="union")return!1;let r=ht(e);return ht(t).every(i=>r.some(a=>a.form===i.form&&(i.refined||!a.refined)))},"pe"),O=s(t=>{switch(t.kind){case"array":return`array(${t.of?O(t.of):"?"})`;case"from":return t.output===void 0?"from":`from(${t.output})`;case"id":return`id(${t.ref??"?"})`;case"literal":return`literal(${t.literal??"?"})`;case"object":return`object({ ${Object.keys(t.fields??{}).join(", ")} })`;case"record":return`record(${t.key?O(t.key):"?"}, ${t.of?O(t.of):"?"})`;case"union":return(t.members??[]).map(e=>O(e)).join(" | ");default:return t.kind}},"x"),fe=s((t,e,r)=>({remediation:"backfill",scope:"table",severity:"breaking",summary:r,table:t,type:e}),"F"),pe=s((t,e,r)=>({remediation:"none",scope:"table",severity:"safe",summary:r,table:t,type:e}),"T"),kt=s((t,e)=>{let r=JSON.stringify(t),i=JSON.stringify(e);return r===i?0:r<i?-1:1},"Z"),ue=s(t=>({...t,...t.kind==="from"?{output:void 0}:{},...t.fields?{fields:Object.fromEntries(Object.entries(t.fields).map(([e,r])=>[e,ue(r)]))}:{},...t.key?{key:ue(t.key)}:{},...t.of?{of:ue(t.of)}:{},...t.members?{members:t.members.map(e=>ue(e)).toSorted(kt)}:{}}),"S"),ft=s(t=>t.kind==="union"?t.members??[]:[t],"U"),Lt=s((t,e)=>{let r=[...t],i=[...e],a=new Set,o=new Set,n=s((d,l)=>{for(let[f,h]of r.entries()){if(o.has(f))continue;let g=i.findIndex((p,b)=>!a.has(b)&&d(h,p));g!==-1&&(a.add(g),o.add(f),l&&([r[f],i[g]]=Me(h,i[g])))}},"s");return n((d,l)=>JSON.stringify(d)===JSON.stringify(l),!1),n((d,l)=>ge(ue(d))===ge(ue(l)),!0),[r,i]},"ge"),Me=s((t,e)=>{if(t.kind==="union"||e.kind==="union"){let[a,o]=Lt(ft(t),ft(e)),n=s((d,l)=>d.kind==="union"?{...d,members:l.toSorted(kt)}:l[0],"s");return[n(t,a),n(e,o)]}if(t.kind!==e.kind)return[t,e];if(t.kind==="from")return t.output===void 0||e.output===void 0?[{...t,output:void 0},{...e,output:void 0}]:[t,e];let r={...t.fields?{fields:{...t.fields}}:{}},i={...e.fields?{fields:{...e.fields}}:{}};for(let a of["key","of"])t[a]&&e[a]&&([r[a],i[a]]=Me(t[a],e[a]));for(let a of Object.keys(t.fields??{})){let o=t.fields?.[a],n=e.fields?.[a];o&&n&&r.fields&&i.fields&&([r.fields[a],i.fields[a]]=Me(o,n))}return[{...t,...r},{...e,...i}]},"I"),_t=s((t,e,r,i,a)=>{let[o,n]=Me(r,i);if(o.kind===n.kind&&(!a||ge(o)===ge(n)))return;if(a&&Rt(o,n))return pe(t,"widenedFieldShape",`field ${t}.${e} widened: ${O(o)} \u2192 ${O(n)} \u2014 every stored value stays valid`);if(o.kind!==n.kind)return fe(t,"changedFieldKind",`field ${t}.${e} changed type: ${o.kind} \u2192 ${n.kind} \u2014 add a data migration to convert existing values`);let d=Object.values(n.fields??{});return a&&o.kind==="object"&&Object.keys(o.fields??{}).length===0&&d.length>0&&d.every(l=>l.optional)?pe(t,"widenedFieldShape",`field ${t}.${e} now records its optional object shape \u2014 stored values stay valid`):fe(t,"changedFieldShape",`field ${t}.${e} changed shape: ${O(o)} \u2192 ${O(n)} \u2014 stored values were written against the old shape; add a data migration to convert them`)},"be"),Dt=s((t,e,r,i)=>{let a=[];return r.unique!==i.unique&&a.push(i.unique===!0?fe(t,"addedFieldConstraint",`field ${t}.${e} became unique \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`):pe(t,"relaxedFieldConstraint",`field ${t}.${e} is no longer unique`)),r.nullable!==i.nullable&&a.push(i.nullable===!0?pe(t,"relaxedFieldConstraint",`field ${t}.${e} became nullable`):fe(t,"addedFieldConstraint",`field ${t}.${e} is no longer nullable \u2014 rows holding NULL would be invalid; add a data migration to backfill them`)),r.refined!==i.refined&&a.push(i.refined===!0?fe(t,"addedFieldConstraint",`field ${t}.${e} gained a validation refinement \u2014 stored values were never checked against it; add a data migration if any could fail`):pe(t,"relaxedFieldConstraint",`field ${t}.${e} dropped its validation refinement`)),a},"ye"),wt=s((t,e,r,i)=>{let a=[],o=mt(r)&&mt(i),n=_t(t,e,r,i,o);return n&&a.push(n),o&&a.push(...Dt(t,e,r,i)),r.optional&&!i.optional?a.push({remediation:"backfill",severity:"breaking",summary:`field ${t}.${e} became required \u2014 rows missing it would be invalid; add a data migration to backfill it`,table:t,scope:"table",type:"fieldOptionalToRequired"}):!r.optional&&i.optional&&a.push({remediation:"none",scope:"table",severity:"safe",summary:`field ${t}.${e} became optional`,table:t,type:"fieldRequiredToOptional"}),a},"N"),Kt=s((t,e,r)=>r.optional?{remediation:"none",scope:"table",severity:"safe",summary:`added optional field ${t}.${e}`,table:t,type:"addedOptionalField"}:{remediation:"backfill",severity:"breaking",summary:`added required field ${t}.${e} \u2014 existing rows have no value; add a data migration to backfill it`,table:t,scope:"table",type:"addedRequiredField"},"ve"),Et=s((t,e,r,i)=>{for(let[a,o]of Object.entries(r.fields)){let n=e.fields[a];n===void 0?i.push(Kt(t,a,o)):i.push(...wt(t,a,n,o))}for(let a of Object.keys(e.fields))r.fields[a]===void 0&&i.push({remediation:"backfill",severity:"breaking",summary:`removed field ${t}.${a} \u2014 add a data migration if stored data must be cleaned up`,table:t,scope:"table",type:"removedField"})},"xe"),Jt=s((t,e,r,i)=>{for(let[a,o]of Object.entries(r.indexes)){let n=e.indexes[a];if(n===void 0){i.push(o.unique?{remediation:"backfill",scope:"table",severity:"breaking",summary:`added unique index ${a} on ${t} \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`,table:t,type:"addedIndex"}:{remediation:"none",scope:"table",severity:"safe",summary:`added index ${a} on ${t}`,table:t,type:"addedIndex"});continue}Ft(n,o)||i.push({remediation:"code",severity:"breaking",summary:`index ${a} on ${t} changed shape \u2014 a query may have relied on the old index`,table:t,scope:"table",type:"changedIndex"})}for(let a of Object.keys(e.indexes))r.indexes[a]===void 0&&i.push({remediation:"code",severity:"breaking",summary:`removed index ${a} on ${t} \u2014 a query that used \`.withIndex("${a}")\` would break`,table:t,scope:"table",type:"removedIndex"})},"ke"),At=s((t,e,r,i)=>{for(let a of Object.keys(r.relations))e.relations[a]===void 0&&i.push({remediation:"none",scope:"schema",severity:"safe",summary:`added relation ${t}.${a}`,table:t,type:"addedRelation"});for(let a of Object.keys(e.relations))r.relations[a]===void 0&&i.push({remediation:"code",scope:"schema",severity:"breaking",summary:`removed relation ${t}.${a}`,table:t,type:"removedRelation"})},"$e"),pt="shardBy:_unknown_",Ce="global",Pt=s((t,e)=>t===Ce&&e.startsWith(`${Ce}:`)||e===Ce&&t.startsWith(`${Ce}:`),"we"),Bt=s((t,e,r)=>{if(e===r)return r!==pt?void 0:{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} declares a non-literal .shardBy(...) key, so codegen cannot read which column partitions it \u2014 every such key records as "${pt}" and two DIFFERENT keys would compare equal. Pass the shard key as a string literal; until then this is reported on every run, because the alternative is a silent pass on a re-home that strands every row (export/import is the only way back).`,table:t,type:"changedShardMode"};if(!Pt(e,r))return{remediation:"rehome",severity:"breaking",summary:`table ${t} changed shard mode: ${e} \u2192 ${r} \u2014 its physical storage moves, and existing rows do NOT follow the schema; re-home them with an export/import round trip (https://lunora.sh/docs/concepts/sharding#migrating-a-populated-table)`,table:t,scope:"table",type:"changedShardMode"}},"Oe"),gt=s(t=>t.memory!==void 0,"B"),bt=s(t=>t.after??0,"K"),R=s(t=>t.after===void 0?`.ttl("${t.field}")`:`.ttl("${t.field}", { after: ${String(t.after)} })`,"w"),Wt=s((t,e,r)=>{if(e===void 0&&r===void 0)return;let i=s(d=>({remediation:"backfill",scope:"table",severity:"breaking",summary:d,table:t,type:"changedTtlPolicy"}),"i"),a=s(d=>({remediation:"none",scope:"table",severity:"safe",summary:d,table:t,type:"changedTtlPolicy"}),"o");if(r===void 0)return a(`table ${t} dropped its TTL policy \u2014 its rows are no longer swept`);if(e===void 0)return i(`table ${t} gained a TTL policy ${R(r)} \u2014 every row already past the cutoff is deleted on the next alarm sweep; add a data migration to refresh or clear "${r.field}" on the rows written before it`);if(e.field!==r.field)return i(`table ${t} moved its TTL to a different column: ${R(e)} \u2192 ${R(r)} \u2014 rows are now expired by a column they were never written against; add a data migration to populate "${r.field}"`);let o=bt(e),n=bt(r);return n<o?i(`table ${t} shortened its TTL: ${R(e)} \u2192 ${R(r)} \u2014 rows that were not expired under the old offset are deleted on the next alarm sweep; add a data migration to refresh "${r.field}" on the rows that must survive`):n>o?a(`table ${t} lengthened its TTL: ${R(e)} \u2192 ${R(r)}`):void 0},"Se"),Ut=s((t,e,r)=>{let i=[];return e.memory!==r.memory&&i.push(r.memory===!0?{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} became a .memory() table \u2014 every row is deleted in every shard on the next Durable Object cold start, and no data migration survives that; export the rows first if they must be kept, or revert`,table:t,type:"changedMemoryMode"}:{remediation:"none",scope:"table",severity:"safe",summary:`table ${t} is no longer a .memory() table \u2014 its rows now survive a cold start`,table:t,type:"changedMemoryMode"}),e.commitOrdered!==r.commitOrdered&&i.push(r.commitOrdered===!0?{remediation:"backfill",scope:"table",severity:"breaking",summary:`table ${t} became .commitOrdered() \u2014 rows written before it carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed never offers them; add a data migration over the table to stamp them (the rewrite allocates a sequence)`,table:t,type:"changedCommitOrdering"}:{remediation:"code",scope:"table",severity:"breaking",summary:`table ${t} is no longer .commitOrdered() \u2014 new rows carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed stops advancing without erroring; update the consumers before deploying`,table:t,type:"changedCommitOrdering"}),i},"je"),zt=s((t,e,r,i)=>{let a=Bt(t,e.shardMode,r.shardMode);if(a&&i.push(a),gt(e)&>(r)){i.push(...Ut(t,e,r));let o=Wt(t,e.ttl,r.ttl);o&&i.push(o)}Et(t,e,r,i),Jt(t,e,r,i),At(t,e,r,i)},"Fe"),Ht=s((t,e)=>{let r=[],i=t?.tables??{};for(let[a,o]of Object.entries(e.tables)){let n=i[a];if(n===void 0){r.push({remediation:"none",scope:"table",severity:"safe",summary:`added table ${a}`,table:a,type:"addedTable"});continue}zt(a,n,o,r)}for(let a of Object.keys(i))e.tables[a]===void 0&&r.push({remediation:"rehome",scope:"table",severity:"breaking",summary:`removed table ${a} \u2014 its rows stay in each shard's SQLite, unreachable through the schema; export the shard first if the data must be kept`,table:a,type:"removedTable"});if(t!==void 0&&t.jurisdiction!==e.jurisdiction){let a=t.jurisdiction??"(none)",o=e.jurisdiction??"(none)";r.push({remediation:"rehome",scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${a} to ${o} \u2014 this re-homes every DO and strands all existing shard, scheduler, and session-DO data in the old region (no in-place migration; export then import to move it). Revert the change, or override the gate to proceed intentionally.`,type:"changedJurisdiction"})}return{changes:r}},"Te"),yt=s(t=>Object.entries(t.fields).map(([e,r])=>({name:e,optional:r.optional,ref:Object.values(t.relations).find(i=>i.field===e&&i.kind==="one")?.table,type:O(r)})),"Y"),vt=s((t,e,r)=>{let i={},a=e?.fields??{},o=r?.fields??{};for(let[n,d]of Object.entries(o)){let l=a[n];l===void 0?i[n]=e===void 0?"unchanged":"added":i[n]=wt(t,n,l,d).length===0?"unchanged":"changed"}for(let n of Object.keys(a))o[n]===void 0&&(i[n]="removed");return i},"z"),Qt=s((t,e)=>{let{changes:r}=Ht(t,e),i=new Set(r.filter(n=>n.scope==="table"&&n.table!==void 0).map(n=>n.table)),a=[],o=s((n,d)=>n?"added":i.has(d)?"changed":"context","r");for(let[n,d]of Object.entries(e.tables)){let l=t?.tables[n],f=o(l===void 0,n);a.push({columns:yt(d),fieldStatus:vt(n,l,d),name:n,shardMode:d.shardMode,status:f})}for(let[n,d]of Object.entries(t?.tables??{}))e.tables[n]===void 0&&a.push({columns:yt(d),fieldStatus:vt(n,d,void 0),name:n,shardMode:d.shardMode,status:"removed"});return a.sort((n,d)=>n.name.localeCompare(d.name)),{breakingCount:r.filter(n=>n.severity==="breaking").length,changes:r,tables:a}},"Me"),xt=s(t=>{let e=It(t);return e.status==="ok"?e.snapshot:void 0},"X"),Vt={added:"ring-2 ring-emerald-500/60",changed:"ring-2 ring-amber-500/70",context:"opacity-55",removed:"opacity-70 ring-2 ring-destructive/60"},Gt=s(t=>t==="global"||t.startsWith("global:")?"global":"shard","Ce"),Zt=s(t=>{let e=(0,be.c)(24),{appliedAt:r,hash:i,onSelect:a,selected:o,seq:n}=t,d=o?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground",l;e[0]!==d?(l=de("flex w-full flex-col items-start gap-1 border-s-2 px-4 py-3 text-start outline-none transition-colors",d),e[0]=d,e[1]=l):l=e[1];let f=`sh-version-${i}`,h;e[2]!==i||e[3]!==a?(h=s(()=>{a(i)},"f"),e[2]=i,e[3]=a,e[4]=h):h=e[4];let g;e[5]!==n?(g=(0,c.jsxs)("span",{className:"font-mono text-[13px] tabular-nums",children:["v",n]}),e[5]=n,e[6]=g):g=e[6];let p;e[7]!==i?(p=i.slice(0,7),e[7]=i,e[8]=p):p=e[8];let b;e[9]!==p?(b=(0,c.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:p}),e[9]=p,e[10]=b):b=e[10];let y;e[11]!==g||e[12]!==b?(y=(0,c.jsxs)("span",{className:"flex w-full items-baseline gap-2",children:[g,b]}),e[11]=g,e[12]=b,e[13]=y):y=e[13];let x;e[14]!==r?(x=qe(r),e[14]=r,e[15]=x):x=e[15];let v;e[16]!==x?(v=(0,c.jsx)("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:x}),e[16]=x,e[17]=v):v=e[17];let u;return e[18]!==v||e[19]!==l||e[20]!==f||e[21]!==h||e[22]!==y?(u=(0,c.jsx)("li",{children:(0,c.jsxs)("button",{className:l,"data-testid":f,onClick:h,type:"button",children:[y,v]})}),e[18]=v,e[19]=l,e[20]=f,e[21]=h,e[22]=y,e[23]=u):u=e[23],u},"Ie"),Xt=s(t=>{let e=(0,be.c)(26),{breaking:r,count:i,first:a}=t,o=le();if(a){let b;e[0]!==i?(b=(0,c.jsx)("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:i}),e[0]=i,e[1]=b):b=e[1];let y;e[2]!==o?(y=o("tables"),e[2]=o,e[3]=y):y=e[3];let x;e[4]!==y?(x=(0,c.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:y}),e[4]=y,e[5]=x):x=e[5];let v;return e[6]!==b||e[7]!==x?(v=(0,c.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[b,x]}),e[6]=b,e[7]=x,e[8]=v):v=e[8],v}let n=r>0&&"text-destructive",d;e[9]!==n?(d=de("text-3xl leading-none font-light tracking-tight tabular-nums",n),e[9]=n,e[10]=d):d=e[10];let l;e[11]!==i||e[12]!==d?(l=(0,c.jsx)("span",{className:d,children:i}),e[11]=i,e[12]=d,e[13]=l):l=e[13];let f;e[14]!==i||e[15]!==o?(f=o(i===1?"change":"changes"),e[14]=i,e[15]=o,e[16]=f):f=e[16];let h;e[17]!==f?(h=(0,c.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:f}),e[17]=f,e[18]=h):h=e[18];let g;e[19]!==r||e[20]!==o?(g=r>0&&(0,c.jsxs)("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["\xB7 ",o("{count} breaking",{count:r})]}),e[19]=r,e[20]=o,e[21]=g):g=e[21];let p;return e[22]!==l||e[23]!==h||e[24]!==g?(p=(0,c.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[l,h,g]}),e[22]=l,e[23]=h,e[24]=g,e[25]=p):p=e[25],p},"Re"),$t={addedFieldConstraint:{action:"added",kind:"constraint"},addedIndex:{action:"added",kind:"index"},addedOptionalField:{action:"added",kind:"field?"},addedRelation:{action:"added",kind:"relation"},addedRequiredField:{action:"added",kind:"field"},addedTable:{action:"added",kind:"table"},changedCommitOrdering:{action:"changed",kind:"commit ordering"},changedFieldKind:{action:"changed",kind:"field kind"},changedFieldShape:{action:"changed",kind:"field shape"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedMemoryMode:{action:"changed",kind:"memory mode"},changedShardMode:{action:"changed",kind:"shard mode"},changedTtlPolicy:{action:"changed",kind:"TTL policy"},fieldOptionalToRequired:{action:"changed",kind:"field \u2192 required"},fieldRequiredToOptional:{action:"changed",kind:"field \u2192 optional"},relaxedFieldConstraint:{action:"removed",kind:"constraint"},removedField:{action:"removed",kind:"field"},removedIndex:{action:"removed",kind:"index"},removedRelation:{action:"removed",kind:"relation"},removedTable:{action:"removed",kind:"table"},widenedFieldShape:{action:"changed",kind:"field \u2192 wider"}},Yt=s((t,e)=>{let r=`${$t[t.type].action} ${e} `;return t.summary.startsWith(r)?t.summary.slice(r.length):t.summary},"Ee"),ea=s(t=>{let e=new Map;for(let i of t){let a=i.table??"",o=e.get(a);o===void 0?e.set(a,[i]):o.push(i)}let r=[...e].map(([i,a])=>({changes:a,table:i}));return[...r.filter(i=>i.table!==""),...r.filter(i=>i.table==="")]},"Ae"),ta=s(t=>{let e=(0,be.c)(2),{children:r}=t,i;return e[0]!==r?(i=(0,c.jsx)("div",{className:"px-4 pt-4 pb-2 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:r}),e[0]=r,e[1]=i):i=e[1],i},"De"),aa=s(({pane:t,shardKey:e=""})=>{let r=le(),i=We(),a=Be({strict:!1}).version,o=s(u=>{je(i({search:{version:u},to:"/migrations"}))},"s"),n=ce(F.schemaHistory,{},{shardKey:e}),d=n.data?.versions??[],l=a!==void 0&&d.some(u=>u.hash===a)?a:d[0]?.hash,f=d.findIndex(u=>u.hash===l),h=f===-1?void 0:d[f+1]?.hash,g=ce(F.schemaVersion,{hash:l??""},{enabled:l!==void 0,shardKey:e}),p=ce(F.schemaVersion,{hash:h??""},{enabled:h!==void 0,shardKey:e}),b=(0,he.useMemo)(()=>{let u=xt(g.data?.version?.snapshotJson);if(u!==void 0)return Qt(xt(p.data?.version?.snapshotJson),u)},[g.data,p.data]),y=(0,he.useMemo)(()=>(b?.tables??[]).map(u=>({columns:u.columns,name:u.name,tier:Gt(u.shardMode)})),[b]),x=(0,he.useMemo)(()=>{let u={};for(let w of b?.tables??[])u[w.name]=Vt[w.status];return u},[b]);if(n.error!==null)return(0,c.jsx)(Te,{error:n.errorSource,testId:"sh-error"});if(d.length===0)return(0,c.jsx)(Oe,{description:r("Each distinct schema shape this shard runs is recorded here, so you can see what changed and when."),testId:"sh-empty",title:r("No schema versions recorded yet.")});let v=b?.changes??[];return(0,c.jsxs)("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[(0,c.jsxs)("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[(0,c.jsx)(ta,{children:r("Schema versions")}),(0,c.jsx)("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:d.map(u=>(0,c.jsx)(Zt,{appliedAt:u.appliedAt,hash:u.hash,onSelect:o,selected:u.hash===l,seq:u.seq},u.hash))})]}),(0,c.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[(0,c.jsx)(Xt,{breaking:b?.breakingCount??0,count:h===void 0?y.length:v.length,first:h===void 0}),t==="diagram"?(0,c.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,c.jsx)(dt,{fill:!0,nodeClasses:x,tables:y,testIdPrefix:"sh"})}):(0,c.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:ea(v).map(u=>{let w=(b?.tables??[]).find(k=>k.name===u.table);return(0,c.jsxs)("section",{className:"mb-6",children:[(0,c.jsxs)("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[(0,c.jsx)("span",{className:"font-mono text-[13px] text-foreground",children:u.table===""?r("schema"):u.table}),w!==void 0&&(0,c.jsx)("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:r("{count} columns",{count:w.columns.length})}),u.changes.length>1&&(0,c.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:u.changes.length})]}),(0,c.jsx)("ul",{children:u.changes.map(k=>{let{action:L,kind:C}=$t[k.type],j=k.severity==="breaking",M=Yt(k,C);return(0,c.jsxs)("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[(0,c.jsx)("span",{"aria-hidden":"true",className:de("-ms-3 h-3 w-0.5 shrink-0 self-center",j?"bg-destructive":"bg-transparent")}),(0,c.jsxs)("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[r(L)," ",C]}),M!==u.table&&(0,c.jsx)("span",{className:de("min-w-0 font-mono text-[13px]",j?"text-destructive":"text-foreground"),children:M}),j&&(0,c.jsx)("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:r("breaking")})]},`${k.type}-${k.summary}`)})})]},u.table)})})]})]})},"Le"),ra=s(t=>de("-mb-px border-b-2 px-3 py-2.5 font-mono text-[11px] tracking-wider uppercase transition-colors outline-none","hover:bg-accent/40 focus-visible:bg-accent/40",t?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"Je"),Ra=s(t=>{let e=(0,be.c)(11),{initialShardKey:r}=t,i=le(),[a,o]=(0,he.useState)("diagram"),n;e[0]!==a?(n=s((g,p,b,y)=>(0,c.jsxs)("button",{"aria-selected":a===g,className:ra(a===g),"data-testid":b,onClick:s(()=>{o(g)},"onClick"),role:"tab",type:"button",children:[p,y!==void 0&&(0,c.jsx)("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:y})]}),"s"),e[0]=a,e[1]=n):n=e[1];let d=n,l;e[2]!==i||e[3]!==d?(l=(0,c.jsxs)("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-3","data-testid":"mg-panes",role:"tablist",children:[d("diagram",i("Diagram"),"mg-pane-diagram"),d("changes",i("Changes"),"mg-pane-changes"),d("data",i("Data migrations"),"mg-pane-data")]}),e[2]=i,e[3]=d,e[4]=l):l=e[4];let f;e[5]!==r||e[6]!==a?(f=(0,c.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:a==="data"?(0,c.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:(0,c.jsx)(ct,{initialShardKey:r})}):(0,c.jsx)(aa,{pane:a,shardKey:r})}),e[5]=r,e[6]=a,e[7]=f):f=e[7];let h;return e[8]!==l||e[9]!==f?(h=(0,c.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[l,f]}),e[8]=l,e[9]=f,e[10]=h):h=e[10],h},"Ze");export{Ra as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as c}from"./chunk-
|
|
1
|
+
import{b as c}from"./chunk-W37HRJGQ.js";import{p as l}from"./chunk-SDSQIQJG.js";import{a as r,d as f,f as g}from"./chunk-OXFKZ4BM.js";var m=f(g(),1);var p={capabilities:{accounts:!0,admin:!0,inviteOnly:!1,organization:!1,passkey:!1,twoFactor:!1},emailAndPassword:!1,organization:{enabled:!1,roles:!1,teams:!1},plugins:[],rateLimit:{enabled:!1},session:{},socialProviders:[],userFields:[]},h=r(()=>{let o=(0,m.c)(6),t=l(),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(),"t"),o[1]=t,o[2]=e):e=o[2];let{data:d,isLoading:u}=c(a,e),n=d??p,s=!u,i;return o[3]!==n||o[4]!==s?(i={config:n,ready:s},o[3]=n,o[4]=s,o[5]=i):i=o[5],i},"y");export{h as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as L}from"./chunk-LKCO3E2B.js";import"./chunk-HKPDPKXD.js";import{a as H}from"./chunk-
|
|
1
|
+
import{a as L}from"./chunk-LKCO3E2B.js";import"./chunk-HKPDPKXD.js";import{a as H}from"./chunk-FACE2CFY.js";import{a as C}from"./chunk-2O6KKVH2.js";import"./chunk-JTGGWF7R.js";import"./chunk-ZBON5T5A.js";import"./chunk-4C4THJUD.js";import{b as $}from"./chunk-W37HRJGQ.js";import{p as T}from"./chunk-SDSQIQJG.js";import"./chunk-WZTY3ZYI.js";import{a as z}from"./chunk-3Y5K3IQO.js";import{a as E,b as O,c as F,d as k,e as r,f as n}from"./chunk-CW57Q264.js";import{a as I,e as j}from"./chunk-MD67S53Z.js";import{f as S,s as B,w as R}from"./chunk-LPINY2IJ.js";import{a as f,d as y,e as D,f as G,g as J}from"./chunk-OXFKZ4BM.js";var P=y(G(),1),Q=y(D(),1);var s=y(J(),1);var w=200,se=f(()=>{let e=(0,P.c)(28),d=T(),a=S(),[l,q]=(0,Q.useState)(0),p;e[0]!==l?(p=["lunora-auth-sessions",w,l],e[0]=l,e[1]=p):p=e[1];let x;e[2]!==d||e[3]!==l?(x=f(()=>d.listAuthSessions({limit:w,offset:l}),"p"),e[2]=d,e[3]=l,e[4]=x):x=e[4];let o=$(p,x),{error:g}=o,t=o.data?.rows??null,N;e[5]!==o?(N=f(()=>o.poll(),"b"),e[5]=o,e[6]=N):N=e[6],H(N,!0);let v;e[7]!==d||e[8]!==o?(v=f(i=>{B((async()=>{await d.revokeAuthSession({sessionId:i}),o.refetch()})())},"g"),e[7]=d,e[8]=o,e[9]=v):v=e[9];let b=v,m;e[10]!==g?(m=g!==null&&(0,s.jsx)("p",{className:"text-sm text-destructive","data-testid":"auth-sessions-error",role:"alert",children:g}),e[10]=g,e[11]=m):m=e[11];let c;e[12]!==t||e[13]!==a?(c=t!==null&&t.length===0&&(0,s.jsx)(z,{testId:"auth-sessions-empty",title:a("No active sessions.")}),e[12]=t,e[13]=a,e[14]=c):c=e[14];let h;e[15]!==b||e[16]!==t||e[17]!==a?(h=t!==null&&t.length>0&&(0,s.jsx)(I,{className:"overflow-hidden py-0",children:(0,s.jsx)(j,{className:"px-0",children:(0,s.jsxs)(E,{"data-testid":"auth-sessions-table",children:[(0,s.jsx)(O,{children:(0,s.jsxs)(k,{children:[(0,s.jsx)(r,{children:a("user")}),(0,s.jsx)(r,{children:a("expires")}),(0,s.jsx)(r,{children:a("ip")}),(0,s.jsx)(r,{children:a("user agent")}),(0,s.jsx)(r,{children:a("impersonated by")}),(0,s.jsx)(r,{"aria-label":a("Actions")})]})}),(0,s.jsx)(F,{children:t.map(i=>(0,s.jsxs)(k,{"data-testid":`auth-session-${i.id}`,children:[(0,s.jsx)(n,{className:"font-mono text-xs",children:i.userId}),(0,s.jsx)(n,{className:"text-muted-foreground tabular-nums",children:R(i.expiresAt)}),(0,s.jsx)(n,{children:i.ipAddress??""}),(0,s.jsx)(n,{className:"max-w-40 truncate",children:i.userAgent??""}),(0,s.jsx)(n,{className:"font-mono text-xs",children:i.impersonatedBy??""}),(0,s.jsx)(n,{children:(0,s.jsx)(C,{"data-testid":`auth-session-revoke-${i.id}`,onClick:f(()=>{b(i.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Revoke")})})]},i.id))})]})})}),e[15]=b,e[16]=t,e[17]=a,e[18]=h):h=e[18];let u;e[19]!==l||e[20]!==t||e[21]!==o.data?.total?(u=t!==null&&(0,s.jsx)(L,{count:t.length,offset:l,onOffsetChange:q,pageSize:w,prefix:"auth-sessions",total:o.data?.total}),e[19]=l,e[20]=t,e[21]=o.data?.total,e[22]=u):u=e[22];let A;return e[23]!==m||e[24]!==c||e[25]!==h||e[26]!==u?(A=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"auth-sessions",children:[m,c,h,u]}),e[23]=m,e[24]=c,e[25]=h,e[26]=u,e[27]=A):A=e[27],A},"ee");export{se as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as k}from"./chunk-SDQH4HR6.js";import"./chunk-W7MRISE3.js";import"./chunk-IBJVVHV5.js";import{a as q}from"./chunk-2O6KKVH2.js";import"./chunk-JTGGWF7R.js";import"./chunk-ZBON5T5A.js";import{b as j}from"./chunk-6I42AM75.js";import"./chunk-4C4THJUD.js";import{a as U}from"./chunk-
|
|
1
|
+
import{i as k}from"./chunk-SDQH4HR6.js";import"./chunk-W7MRISE3.js";import"./chunk-IBJVVHV5.js";import{a as q}from"./chunk-2O6KKVH2.js";import"./chunk-JTGGWF7R.js";import"./chunk-ZBON5T5A.js";import{b as j}from"./chunk-6I42AM75.js";import"./chunk-4C4THJUD.js";import{a as U}from"./chunk-GMO7IUXO.js";import"./chunk-OSJ7HV7B.js";import"./chunk-5SYMAYUA.js";import"./chunk-E26OT26O.js";import{a as R}from"./chunk-6UTZXEW3.js";import{c as P}from"./chunk-W37HRJGQ.js";import"./chunk-SDSQIQJG.js";import"./chunk-WZTY3ZYI.js";import{a as M}from"./chunk-3Y5K3IQO.js";import{a as G,b as H,c as J,d as B,e as x,f as N}from"./chunk-CW57Q264.js";import{a as z,e as D}from"./chunk-MD67S53Z.js";import{f as F,w as O}from"./chunk-LPINY2IJ.js";import{a as A,d as T,e as $,f as X,g as Y}from"./chunk-OXFKZ4BM.js";var K=T(X(),1),Q=T($(),1);var t=T(Y(),1);var de=A(()=>{let e=(0,K.c)(39),a=F(),[s,V]=(0,Q.useState)(""),y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={},e[0]=y):y=e[0];let{data:C,error:l,errorSource:S,isLoading:E,refetch:_}=P(R.getAuthAuditLog,y),I;if(e[1]!==C?.entries||e[2]!==s){let r=C?.entries??[],v=s.trim().toLowerCase();I=v===""?r:r.filter(w=>w.event.toLowerCase().includes(v)||(w.actorId??"").toLowerCase().includes(v)||(w.actorEmail??"").toLowerCase().includes(v)||(w.ip??"").toLowerCase().includes(v)||w.outcome.toLowerCase().includes(v)),e[1]=C?.entries,e[2]=s,e[3]=I}else I=e[3];let o=I,L;e[4]===Symbol.for("react.memo_cache_sentinel")?(L=A(r=>{V(r.target.value)},"I"),e[4]=L):L=e[4];let W=L,i;e[5]!==a?(i=a("Filter security events"),e[5]=a,e[6]=i):i=e[6];let n;e[7]!==a?(n=a("filter event, actor, IP"),e[7]=a,e[8]=n):n=e[8];let c;e[9]!==s||e[10]!==i||e[11]!==n?(c=(0,t.jsx)(k,{"aria-label":i,className:"h-8 w-56","data-testid":"aa-search",onChange:W,placeholder:n,value:s}),e[9]=s,e[10]=i,e[11]=n,e[12]=c):c=e[12];let d;e[13]!==_?(d=A(()=>{_()},"m"),e[13]=_,e[14]=d):d=e[14];let m;e[15]!==a?(m=a("Refresh"),e[15]=a,e[16]=m):m=e[16];let u;e[17]!==d||e[18]!==m?(u=(0,t.jsx)(q,{"data-testid":"aa-refresh",onClick:d,size:"xs",type:"button",variant:"ghost",children:m}),e[17]=d,e[18]=m,e[19]=u):u=e[19];let h;e[20]!==c||e[21]!==u?(h=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,u]}),e[20]=c,e[21]=u,e[22]=h):h=e[22];let f;e[23]!==l||e[24]!==S?(f=l!==null&&(0,t.jsx)(U,{error:S,testId:"aa-error"}),e[23]=l,e[24]=S,e[25]=f):f=e[25];let p;e[26]!==l||e[27]!==o.length||e[28]!==E||e[29]!==a?(p=l===null&&!E&&o.length===0&&(0,t.jsx)(M,{description:a("Authentication and security events are recorded here."),testId:"aa-empty",title:a("No security events.")}),e[26]=l,e[27]=o.length,e[28]=E,e[29]=a,e[30]=p):p=e[30];let g;e[31]!==o||e[32]!==a?(g=o.length>0&&(0,t.jsx)(z,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"max-h-[30rem] overflow-auto px-0",children:(0,t.jsxs)(G,{"data-testid":"aa-table",children:[(0,t.jsx)(H,{children:(0,t.jsxs)(B,{children:[(0,t.jsx)(x,{children:a("time")}),(0,t.jsx)(x,{children:a("event")}),(0,t.jsx)(x,{children:a("actor")}),(0,t.jsx)(x,{children:a("ip / user agent")}),(0,t.jsx)(x,{children:a("outcome")})]})}),(0,t.jsx)(J,{children:o.map(r=>(0,t.jsxs)(B,{"data-testid":"aa-row",children:[(0,t.jsx)(N,{className:"text-muted-foreground tabular-nums",children:O(r.ts,"\u2014")}),(0,t.jsx)(N,{children:(0,t.jsx)(j,{variant:"secondary",children:r.event})}),(0,t.jsx)(N,{className:"max-w-[24ch] truncate font-mono text-xs",title:r.actorId??void 0,children:r.actorEmail??r.actorId??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,t.jsxs)(N,{className:"max-w-[28ch] truncate text-xs text-muted-foreground",title:r.userAgent??void 0,children:[r.ip??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),r.userAgent!==void 0&&(0,t.jsxs)("span",{className:"ml-1 opacity-70",children:["\xB7 ",r.userAgent]})]}),(0,t.jsx)(N,{children:(0,t.jsx)(j,{variant:r.outcome==="failure"?"destructive":"outline",children:a(r.outcome)})})]},r.seq))})]})})}),e[31]=o,e[32]=a,e[33]=g):g=e[33];let b;return e[34]!==f||e[35]!==p||e[36]!==g||e[37]!==h?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-auth-audit",children:[h,f,p,g]}),e[34]=f,e[35]=p,e[36]=g,e[37]=h,e[38]=b):b=e[38],b},"ne");export{de as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j,k as v,l as D,p as q}from"./chunk-
|
|
1
|
+
import{j,k as v,l as D,p as q}from"./chunk-SDSQIQJG.js";import{h as g,i as S,j as P,s as w}from"./chunk-LPINY2IJ.js";import{a as i,d as A,e as L,f as M}from"./chunk-OXFKZ4BM.js";var E=A(M(),1);var p=A(L(),1);var I=300,l=i(t=>typeof t=="string"?t===""?void 0:t:typeof t=="number"||typeof t=="boolean"?String(t):void 0,"c"),u=i(t=>t.filter(r=>r!==void 0).join(" "),"u"),T=i(t=>{let r=Array.isArray(t.filters)?t.filters.length:0,e=typeof t.search=="string"&&t.search!=="";return r===0&&!e?"no predicate":u([r===0?void 0:`${String(r)} filters`,e?"search":void 0])},"q"),N={clearTable:i(t=>u([l(t.table),"whole table"]),"clearTable"),deleteRows:i(t=>u([l(t.table),T(t)]),"deleteRows"),facetColumn:i(t=>u([l(t.table),l(t.column)]),"facetColumn"),importShard:i(t=>{if(!Array.isArray(t.rows))return"";let r=[...new Set(t.rows.filter(e=>typeof e=="object"&&e!==null).map(e=>e.table).filter(e=>typeof e=="string"))].toSorted((e,s)=>e.localeCompare(s));return u([`${String(t.rows.length)} rows`,r.length===0?void 0:`into ${r.join(", ")}`])},"importShard"),lintSql:i(()=>"sql","lintSql"),patchRows:i(t=>u([l(t.table),typeof t.doc=="object"&&t.doc!==null?`set ${Object.keys(t.doc).join(", ")}`:void 0,T(t)]),"patchRows"),pitrRestore:i(t=>u([l(t.time)===void 0?void 0:`to ${String(t.time)}`,typeof t.bookmark=="string"&&t.bookmark!==""?"from bookmark":void 0,t.restart===!0?"restart now":void 0]),"pitrRestore"),readTablePage:i(t=>u([l(t.table),Array.isArray(t.filters)&&t.filters.length>0?`${String(t.filters.length)} filters`:void 0,typeof t.search=="string"&&t.search!==""?"search":void 0,typeof t.limit=="number"?`limit ${String(t.limit)}`:void 0]),"readTablePage"),runMigration:i(t=>u([l(t.id),l(t.direction),t.dryRun===!0?"dry-run":void 0]),"runMigration"),runSql:i(t=>typeof t.sql=="string"?`${String(t.sql.length)} chars`:"","runSql"),schemaVersion:i(t=>typeof t.hash=="string"?t.hash.slice(0,8):"","schemaVersion"),writeRow:i(t=>u([l(t.table),"1 row"]),"writeRow")},$="__lunora_admin__:",F=i((t,r)=>{let e=t.startsWith($)?t.slice($.length):t,s=N[e];if(s!==void 0)return s(r);let n=Object.keys(r);return n.length===0?"":n.join(", ")},"M"),V=i(t=>{if(Array.isArray(t))return t.length;if(!(typeof t!="object"||t===null)){for(let r of Object.values(t))if(Array.isArray(r))return r.length}},"K"),k=class{static{i(this,"x")}entries=[];listeners=new Set;nextSeq=1;getSnapshot=i(()=>this.entries,"getSnapshot");subscribe=i(r=>(this.listeners.add(r),()=>{this.listeners.delete(r)}),"subscribe");start(r,e,s){return this.append(r,e,s,"call","pending")}startSubscription(r,e,s){return this.append(r,e,s,"subscription","live")}recordPush(r){if(this.listeners.size===0){let e=this.entries.find(s=>s.seq===r);e!==void 0&&(e.pushes=(e.pushes??0)+1);return}this.patch(r,e=>({...e,pushes:(e.pushes??0)+1}))}failSubscription(r,e){this.patch(r,s=>({...s,error:e,status:"error"}))}endSubscription(r){this.patch(r,e=>e.status==="error"?e:{...e,durationMs:Date.now()-e.startedAt,status:"closed"})}lastErrorSeq(){return this.entries.findLast(r=>r.status==="error")?.seq}settle(r,e){this.patch(r,s=>({...s,durationMs:Date.now()-s.startedAt,...e.error===void 0?{resultCount:V(e.result),status:"ok"}:{error:e.error,status:"error"}}))}clear(){this.entries=[],this.emit()}append(r,e,s,n,a){let c=this.nextSeq;this.nextSeq+=1;let d={functionPath:r,kind:n,seq:c,shardKey:s,startedAt:Date.now(),status:a,summary:F(r,e),...n==="subscription"?{pushes:0}:{}},o=[...this.entries,d];return this.entries=o.length>I?o.slice(o.length-I):o,this.emit(),c}patch(r,e){let s=this.entries.findIndex(n=>n.seq===r);s!==-1&&(this.entries=this.entries.with(s,e(this.entries[s])),this.emit())}emit(){for(let r of this.listeners)r()}},f=new k,O=i((t,r,e)=>["lunora-admin",t,r,e.trim()],"E"),_=i((t,r)=>[...t,r],"j");function W(t,r,e={}){let s=q(),{enabled:n=!0,keepPreviousData:a=!1,staleTime:c=0}=e,d=_(t,s.clientIdentifier()),o=D({enabled:n,queryFn:r,placeholderData:a?j:void 0,queryKey:d,staleTime:c});return{data:o.data,error:o.error?P(o.error):o.error,errorSource:o.error??void 0,isLoading:o.isLoading,liveError:void 0,refetch:i(()=>{w(o.refetch())},"refetch"),poll:i(async()=>{await o.refetch({throwOnError:!0})},"poll")}}i(W,"F");function Y(t,r,e={}){let s=q(),n=v(),{enabled:a=!0,keepPreviousData:c=!1,live:d=!1,shardKey:o="",staleTime:R}=e,m=O(t,r,o),C=W(m,()=>s.query(g(t),r,S(o)),{enabled:a,keepPreviousData:c,staleTime:R??(d?Number.POSITIVE_INFINITY:0)}),[K,b]=(0,p.useState)(void 0),Q=JSON.stringify(m);return(0,p.useEffect)(()=>{if(!a||!d)return;b(void 0);let y=f.startSubscription(t,r,o),x=s.subscribe(g(t),r,h=>{f.recordPush(y),b(void 0),n.setQueryData(_(m,s.clientIdentifier()),h)},{...S(o),onError:i(h=>{f.failSubscription(y,h.message),b(h.message)},"onError")});return()=>{f.endSubscription(y),x()}},[s,Q,a,d]),{...C,liveError:a&&d?K:void 0}}i(Y,"U");var B=i(()=>{let t=(0,E.c)(2),r=v(),e;return t[0]!==r?(e=i((s,n,a)=>{let c=n===void 0?["lunora-admin",s]:O(s,n,a??"");w(r.invalidateQueries({queryKey:c}))},"r"),t[0]=r,t[1]=e):e=t[1],e},"W");export{f as a,W as b,Y as c,B as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Pt,b as jt,c as ot}from"./chunk-VEWQWS3J.js";import{a as de}from"./chunk-AOHKAKKL.js";import{a as Et,b as Ot,c as Dt,d as Ft}from"./chunk-TDVDZ7XQ.js";import{a as it}from"./chunk-EEPCLLGE.js";import{a as rt,b as at,c as st,d as At,e as zt,f as lt,g as nt,h as Kt,i as Lt}from"./chunk-5IIX2STA.js";import{a as Rt}from"./chunk-R36QXQZX.js";import{a as $t}from"./chunk-TRZTGE4R.js";import"./chunk-IH2CJZF2.js";import{e as _t}from"./chunk-UYEZR3BI.js";import{a as kt,b as Ct,c as Mt,d as It,e as je}from"./chunk-FLVDICZL.js";import"./chunk-A566HCBX.js";import"./chunk-SYGCASPT.js";import"./chunk-LIGOLZND.js";import{a as qt}from"./chunk-XBZUJDHD.js";import"./chunk-KRPXOSBL.js";import"./chunk-W2BCSK5S.js";import"./chunk-NGVP66OH.js";import"./chunk-XYR5NST4.js";import"./chunk-ZGSL4DPP.js";import{a as wt}from"./chunk-5DNGK3NT.js";import{a as St}from"./chunk-KYONGQQ4.js";import{a as yt,b as Nt}from"./chunk-SLIDAWNX.js";import"./chunk-6M7FLLMT.js";import"./chunk-LUHXNZI4.js";import"./chunk-ZTOREMGH.js";import"./chunk-SDQH4HR6.js";import"./chunk-W7MRISE3.js";import"./chunk-IBJVVHV5.js";import{a as Ye}from"./chunk-2O6KKVH2.js";import"./chunk-JTGGWF7R.js";import"./chunk-ZBON5T5A.js";import{b as Ge}from"./chunk-6I42AM75.js";import"./chunk-4C4THJUD.js";import"./chunk-E26OT26O.js";import{a as Ee}from"./chunk-6UTZXEW3.js";import{c as Fe}from"./chunk-4SJDWMH3.js";import{d as ct,p as vt}from"./chunk-FKM35PXF.js";import"./chunk-WZTY3ZYI.js";import{a as ht}from"./chunk-3Y5K3IQO.js";import{a as Ze,b as et,c as tt,d as Pe,e as oe,f as B}from"./chunk-CW57Q264.js";import{a as fe,b as Oe,c as De,d as ut,e as xe}from"./chunk-MD67S53Z.js";import{b as mt,f as he,h as gt,i as pt,j as ft,k as xt,o as Je,s as bt}from"./chunk-LPINY2IJ.js";import{a as b,d as Xe,e as Ut,f as Ht,g as Gt}from"./chunk-OXFKZ4BM.js";var me=Xe(Ht(),1),j=Xe(Ut(),1);var t=Xe(Gt(),1);var Bt=b((l,e,s)=>`${l}:${e}:${ct(s??{})}`,"ut"),Tt=b((l,e)=>l==="gauge"?e.last:l==="histogram"?e.sum/Math.max(1,e.count):e.sum,"ht"),Jt=b((l,e)=>Tt(l,e),"Vt"),Vt=b(l=>Tt(l.kind,l),"Gt"),dt=b(l=>Number.isInteger(l)?l.toLocaleString():l.toLocaleString(void 0,{maximumFractionDigits:2}),"Ye"),Wt=b(l=>Array.isArray(l?.series)?l.series:[],"Yt"),Xt="FUNCTION_NOT_FOUND",Yt=b(l=>{let e=new Map;if(!Array.isArray(l?.series))return e;for(let s of l.series)e.set(Bt(s.kind,s.name,s.attributes),s.points);return e},"Wt"),Zt={counter:"secondary",gauge:"default",histogram:"outline"},er=b(l=>{let e=(0,me.c)(18),{name:s,onOpenTrace:a,traceId:r}=l,o=he();if(r===void 0){let c;return e[0]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),e[0]=c):c=e[0],c}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 c=`mt-instrument-trace-${s}`,d;return e[3]!==n||e[4]!==c||e[5]!==r?(d=(0,t.jsx)("span",{className:"text-muted-foreground","data-testid":c,title:r,children:n}),e[3]=n,e[4]=c,e[5]=r,e[6]=d):d=e[6],d}let m=`mt-instrument-trace-${s}`,p;e[7]!==a||e[8]!==r?(p=b(()=>{a(r)},"p"),e[7]=a,e[8]=r,e[9]=p):p=e[9];let h;e[10]!==o||e[11]!==r?(h=o("Open the exemplar trace {trace}",{trace:r}),e[10]=o,e[11]=r,e[12]=h):h=e[12];let u;return e[13]!==n||e[14]!==m||e[15]!==p||e[16]!==h?(u=(0,t.jsx)("button",{className:"text-primary underline-offset-4 hover:underline","data-testid":m,onClick:p,title:h,type:"button",children:n}),e[13]=n,e[14]=m,e[15]=p,e[16]=h,e[17]=u):u=e[17],u},"Zt"),tr=b(l=>{let e=(0,me.c)(105),{onOpenTrace:s,shardKey:a}=l,r=he(),o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={},e[0]=o):o=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:m,errorSource:p}=Fe(Ee.getMetricSeries,o,i),h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h={},e[3]=h):h=e[3];let u;e[4]!==a?(u={live:!0,shardKey:a},e[4]=a,e[5]=u):u=e[5];let{data:c}=Fe(Ee.getMetricHistory,h,u),d,f,g,v,x,S,y,w,I,k,N,z,_;if(e[6]!==n||e[7]!==m||e[8]!==p||e[9]!==c||e[10]!==s||e[11]!==r){w=Symbol.for("react.early_return_sentinel");e:{let L=Wt(n),E=xt(p)===Xt;if(m!==null&&!E){let q;e[25]!==r?(q=r("Instruments"),e[25]=r,e[26]=q):q=e[26];let D;e[27]!==q?(D=(0,t.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:q}),e[27]=q,e[28]=D):D=e[28];let F;e[29]!==m||e[30]!==r?(F=r("Instruments unavailable: {error}",{error:m}),e[29]=m,e[30]=r,e[31]=F):F=e[31];let P;e[32]!==F?(P=(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":"mt-instruments-error",role:"status",children:F}),e[32]=F,e[33]=P):P=e[33];let ie;e[34]!==D||e[35]!==P?(ie=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"mt-instruments",children:[D,P]}),e[34]=D,e[35]=P,e[36]=ie):ie=e[36],w=ie;break e}if(L.length===0){w=null;break e}let O=Yt(c),ue;e[37]!==r?(ue=b(q=>r(q==="counter"?"Counter":q==="gauge"?"Gauge":"Histogram"),"de"),e[37]=r,e[38]=ue):ue=e[38];let ge=ue;x="flex flex-col gap-2",S="mt-instruments";let T;e[39]!==r?(T=r("Instruments"),e[39]=r,e[40]=T):T=e[40],e[41]!==T?(y=(0,t.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:T}),e[41]=T,e[42]=y):y=e[42],v=fe,_="overflow-hidden py-0",g=xe,z="px-0",f=Ze,k="mt-instruments-table";let U;e[43]!==r?(U=r("name"),e[43]=r,e[44]=U):U=e[44];let H;e[45]!==U?(H=(0,t.jsx)(oe,{children:U}),e[45]=U,e[46]=H):H=e[46];let G;e[47]!==r?(G=r("kind"),e[47]=r,e[48]=G):G=e[48];let J;e[49]!==G?(J=(0,t.jsx)(oe,{children:G}),e[49]=G,e[50]=J):J=e[50];let V;e[51]!==r?(V=r("value"),e[51]=r,e[52]=V):V=e[52];let W;e[53]!==V?(W=(0,t.jsx)(oe,{className:"text-right",children:V}),e[53]=V,e[54]=W):W=e[54];let X;e[55]!==r?(X=r("count"),e[55]=r,e[56]=X):X=e[56];let Y;e[57]!==X?(Y=(0,t.jsx)(oe,{className:"text-right",children:X}),e[57]=X,e[58]=Y):Y=e[58];let Z;e[59]!==r?(Z=r("range"),e[59]=r,e[60]=Z):Z=e[60];let ee;e[61]!==Z?(ee=(0,t.jsx)(oe,{className:"text-right",children:Z}),e[61]=Z,e[62]=ee):ee=e[62];let te;e[63]!==r?(te=r("trend"),e[63]=r,e[64]=te):te=e[64];let re;e[65]!==te?(re=(0,t.jsx)(oe,{children:te}),e[65]=te,e[66]=re):re=e[66];let ae;e[67]!==r?(ae=r("trace"),e[67]=r,e[68]=ae):ae=e[68];let se;e[69]!==ae?(se=(0,t.jsx)(oe,{children:ae}),e[69]=ae,e[70]=se):se=e[70];let le;e[71]!==r?(le=r("dimensions"),e[71]=r,e[72]=le):le=e[72];let ne;e[73]!==le?(ne=(0,t.jsx)(oe,{children:le}),e[73]=le,e[74]=ne):ne=e[74],e[75]!==H||e[76]!==J||e[77]!==W||e[78]!==Y||e[79]!==ee||e[80]!==re||e[81]!==se||e[82]!==ne?(N=(0,t.jsx)(et,{children:(0,t.jsxs)(Pe,{children:[H,J,W,Y,ee,re,se,ne]})}),e[75]=H,e[76]=J,e[77]=W,e[78]=Y,e[79]=ee,e[80]=re,e[81]=se,e[82]=ne,e[83]=N):N=e[83],d=tt,I=L.map(q=>{let D=Rt(q.attributes),F=Bt(q.kind,q.name,q.attributes),P=(O.get(F)??[]).map(ie=>Jt(q.kind,ie));return(0,t.jsxs)(Pe,{"data-testid":`mt-instrument-${q.name}`,children:[(0,t.jsx)(B,{className:"font-mono text-xs",title:q.functionPath,children:q.name}),(0,t.jsx)(B,{children:(0,t.jsx)(Ge,{variant:Zt[q.kind],children:ge(q.kind)})}),(0,t.jsx)(B,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${q.name}`,children:dt(Vt(q))}),(0,t.jsx)(B,{className:"text-right tabular-nums text-muted-foreground",children:q.count.toLocaleString()}),(0,t.jsx)(B,{className:"text-right font-mono text-xs tabular-nums text-muted-foreground",children:q.min===q.max?"\u2014":`${dt(q.min)}\u2013${dt(q.max)}`}),(0,t.jsx)(B,{children:P.length>=2?(0,t.jsx)(it,{ariaLabel:r("{name} trend",{name:q.name}),className:"h-6 w-24 text-foreground",series:P,testId:`mt-instrument-trend-${q.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)(er,{name:q.name,onOpenTrace:s,traceId:q.exemplarTraceId})}),(0,t.jsx)(B,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:D,children:D===""?"\u2014":D})]},F)})}e[6]=n,e[7]=m,e[8]=p,e[9]=c,e[10]=s,e[11]=r,e[12]=d,e[13]=f,e[14]=g,e[15]=v,e[16]=x,e[17]=S,e[18]=y,e[19]=w,e[20]=I,e[21]=k,e[22]=N,e[23]=z,e[24]=_}else d=e[12],f=e[13],g=e[14],v=e[15],x=e[16],S=e[17],y=e[18],w=e[19],I=e[20],k=e[21],N=e[22],z=e[23],_=e[24];if(w!==Symbol.for("react.early_return_sentinel"))return w;let C;e[84]!==d||e[85]!==I?(C=(0,t.jsx)(d,{children:I}),e[84]=d,e[85]=I,e[86]=C):C=e[86];let R;e[87]!==f||e[88]!==C||e[89]!==k||e[90]!==N?(R=(0,t.jsxs)(f,{"data-testid":k,children:[N,C]}),e[87]=f,e[88]=C,e[89]=k,e[90]=N,e[91]=R):R=e[91];let M;e[92]!==g||e[93]!==R||e[94]!==z?(M=(0,t.jsx)(g,{className:z,children:R}),e[92]=g,e[93]=R,e[94]=z,e[95]=M):M=e[95];let $;e[96]!==v||e[97]!==M||e[98]!==_?($=(0,t.jsx)(v,{className:_,children:M}),e[96]=v,e[97]=M,e[98]=_,e[99]=$):$=e[99];let A;return e[100]!==x||e[101]!==S||e[102]!==y||e[103]!==$?(A=(0,t.jsxs)("section",{className:x,"data-testid":S,children:[y,$]}),e[100]=x,e[101]=S,e[102]=y,e[103]=$,e[104]=A):A=e[104],A},"es"),rr=b(l=>{let e=(0,me.c)(74),{aggregate:s,shardResults:a}=l,r=he(),o;e[0]!==r?(o=r("Shards"),e[0]=r,e[1]=o):o=e[1];let i;e[2]!==s.failed||e[3]!==s.reachable||e[4]!==r?(i=s.failed>0?r("{reachable} reachable, {failed} unreachable",{failed:s.failed,reachable:s.reachable}):r("{reachable} reachable",{reachable:s.reachable}),e[2]=s.failed,e[3]=s.reachable,e[4]=r,e[5]=i):i=e[5];let n;e[6]!==o||e[7]!==i?(n=(0,t.jsx)(de,{label:o,testId:"mt-agg-shards",value:i}),e[6]=o,e[7]=i,e[8]=n):n=e[8];let m;e[9]!==r?(m=r("Total requests"),e[9]=r,e[10]=m):m=e[10];let p;e[11]!==s.totalRequests||e[12]!==m?(p=(0,t.jsx)(de,{label:m,testId:"mt-agg-requests",value:s.totalRequests}),e[11]=s.totalRequests,e[12]=m,e[13]=p):p=e[13];let h;e[14]!==r?(h=r("Total errors"),e[14]=r,e[15]=h):h=e[15];let u;e[16]!==s.totalErrors||e[17]!==h?(u=(0,t.jsx)(de,{label:h,testId:"mt-agg-errors",value:s.totalErrors}),e[16]=s.totalErrors,e[17]=h,e[18]=u):u=e[18];let c;e[19]!==r?(c=r("Total database size"),e[19]=r,e[20]=c):c=e[20];let d;e[21]!==s.totalDatabaseSize?(d=Je(s.totalDatabaseSize),e[21]=s.totalDatabaseSize,e[22]=d):d=e[22];let f;e[23]!==c||e[24]!==d?(f=(0,t.jsx)(de,{label:c,testId:"mt-agg-db-size",value:d}),e[23]=c,e[24]=d,e[25]=f):f=e[25];let g;e[26]!==r?(g=r("Combined cache hit rate"),e[26]=r,e[27]=g):g=e[27];let v;e[28]!==s.hitRate||e[29]!==r?(v=s.hitRate===null?r("no cache configured"):`${(s.hitRate*100).toFixed(1)}%`,e[28]=s.hitRate,e[29]=r,e[30]=v):v=e[30];let x;e[31]!==g||e[32]!==v?(x=(0,t.jsx)(de,{label:g,testId:"mt-agg-cache",value:v}),e[31]=g,e[32]=v,e[33]=x):x=e[33];let S;e[34]!==f||e[35]!==x||e[36]!==n||e[37]!==p||e[38]!==u?(S=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[n,p,u,f,x]}),e[34]=f,e[35]=x,e[36]=n,e[37]=p,e[38]=u,e[39]=S):S=e[39];let y;e[40]!==r?(y=r("shard"),e[40]=r,e[41]=y):y=e[41];let w;e[42]!==y?(w=(0,t.jsx)(oe,{children:y}),e[42]=y,e[43]=w):w=e[43];let I;e[44]!==r?(I=r("requests"),e[44]=r,e[45]=I):I=e[45];let k;e[46]!==I?(k=(0,t.jsx)(oe,{children:I}),e[46]=I,e[47]=k):k=e[47];let N;e[48]!==r?(N=r("errors"),e[48]=r,e[49]=N):N=e[49];let z;e[50]!==N?(z=(0,t.jsx)(oe,{children:N}),e[50]=N,e[51]=z):z=e[51];let _;e[52]!==r?(_=r("db size"),e[52]=r,e[53]=_):_=e[53];let C;e[54]!==_?(C=(0,t.jsx)(oe,{children:_}),e[54]=_,e[55]=C):C=e[55];let R;e[56]!==w||e[57]!==k||e[58]!==z||e[59]!==C?(R=(0,t.jsx)(et,{children:(0,t.jsxs)(Pe,{children:[w,k,z,C]})}),e[56]=w,e[57]=k,e[58]=z,e[59]=C,e[60]=R):R=e[60];let M;if(e[61]!==a||e[62]!==r){let E;e[64]!==r?(E=b(O=>(0,t.jsxs)(Pe,{"data-testid":`mt-agg-row-${O.shard}`,children:[(0,t.jsx)(B,{children:O.shard}),O.metrics===null?(0,t.jsx)(B,{className:"text-destructive",colSpan:3,children:O.error??r("unreachable")}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(B,{className:"tabular-nums",children:O.metrics.requests}),(0,t.jsx)(B,{className:"tabular-nums",children:O.metrics.errors}),(0,t.jsx)(B,{className:"tabular-nums",children:Je(O.metrics.databaseSize)})]})]},O.shard),"L"),e[64]=r,e[65]=E):E=e[65],M=a.map(E),e[61]=a,e[62]=r,e[63]=M}else M=e[63];let $;e[66]!==M?($=(0,t.jsx)(tt,{children:M}),e[66]=M,e[67]=$):$=e[67];let A;e[68]!==R||e[69]!==$?(A=(0,t.jsx)(fe,{className:"overflow-hidden py-0",children:(0,t.jsx)(xe,{className:"px-0",children:(0,t.jsxs)(Ze,{"data-testid":"mt-agg-table",children:[R,$]})})}),e[68]=R,e[69]=$,e[70]=A):A=e[70];let L;return e[71]!==S||e[72]!==A?(L=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[S,A]}),e[71]=S,e[72]=A,e[73]=L):L=e[73],L},"ts"),ar=b(l=>{let e=(0,me.c)(75),{currentDelta:s,errorRate:a,history:r,latencyPercentiles:o,metrics:i}=l,n=he(),{cache:m}=i,p;e[0]!==r||e[1]!==n?(p=r.length>=2?(0,t.jsx)(it,{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]=p):p=e[2];let h;e[3]!==s||e[4]!==r.length||e[5]!==n?(h=r.length>=2?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"font-semibold text-foreground",children:`+${s.toLocaleString()}`})," ",n("last interval")]}):(0,t.jsx)("span",{"data-testid":"mt-sparkline-empty",children:n("collecting samples\u2026")}),e[3]=s,e[4]=r.length,e[5]=n,e[6]=h):h=e[6];let u;e[7]!==n?(u=n("Requests"),e[7]=n,e[8]=u):u=e[8];let c;e[9]!==i.requests||e[10]!==p||e[11]!==h||e[12]!==u?(c=(0,t.jsx)(de,{chart:p,footer:h,label:u,testId:"mt-requests",value:i.requests}),e[9]=i.requests,e[10]=p,e[11]=h,e[12]=u,e[13]=c):c=e[13];let d;e[14]!==a||e[15]!==n?(d=n("{rate} error rate",{rate:a}),e[14]=a,e[15]=n,e[16]=d):d=e[16];let f;e[17]!==n?(f=n("Errors"),e[17]=n,e[18]=f):f=e[18];let g;e[19]!==a||e[20]!==i.errors?(g=(0,t.jsxs)(t.Fragment,{children:[i.errors," (",a,")"]}),e[19]=a,e[20]=i.errors,e[21]=g):g=e[21];let v;e[22]!==d||e[23]!==f||e[24]!==g?(v=(0,t.jsx)(de,{footer:d,label:f,testId:"mt-errors",value:g}),e[22]=d,e[23]=f,e[24]=g,e[25]=v):v=e[25];let x;e[26]!==o.p90?(x=o.p90>0?`P90 ${ot(o.p90)}`:void 0,e[26]=o.p90,e[27]=x):x=e[27];let S;e[28]!==n?(S=n("P95 latency"),e[28]=n,e[29]=S):S=e[29];let y;e[30]!==o.p95?(y=o.p95>0?ot(o.p95):"\u2014",e[30]=o.p95,e[31]=y):y=e[31];let w;e[32]!==S||e[33]!==y||e[34]!==x?(w=(0,t.jsx)(de,{footer:x,label:S,testId:"mt-p95",value:y}),e[32]=S,e[33]=y,e[34]=x,e[35]=w):w=e[35];let I;e[36]!==m||e[37]!==n?(I=m?`${m.entries.toLocaleString()} ${n("cache entries")}`:void 0,e[36]=m,e[37]=n,e[38]=I):I=e[38];let k;e[39]!==n?(k=n("Database size"),e[39]=n,e[40]=k):k=e[40];let N;e[41]!==i.databaseSize?(N=Je(i.databaseSize),e[41]=i.databaseSize,e[42]=N):N=e[42];let z;e[43]!==I||e[44]!==k||e[45]!==N?(z=(0,t.jsx)(de,{footer:I,label:k,testId:"mt-db-size",value:N}),e[43]=I,e[44]=k,e[45]=N,e[46]=z):z=e[46];let _;e[47]!==n?(_=n("Shard"),e[47]=n,e[48]=_):_=e[48];let C;e[49]!==i.shard||e[50]!==_?(C=(0,t.jsx)(de,{label:_,testId:"mt-shard",value:i.shard}),e[49]=i.shard,e[50]=_,e[51]=C):C=e[51];let R;e[52]!==n?(R=n("Uptime"),e[52]=n,e[53]=R):R=e[53];let M;e[54]!==i.uptimeMs?(M=Pt(i.uptimeMs),e[54]=i.uptimeMs,e[55]=M):M=e[55];let $;e[56]!==R||e[57]!==M?($=(0,t.jsx)(de,{label:R,testId:"mt-uptime",value:M}),e[56]=R,e[57]=M,e[58]=$):$=e[58];let A;e[59]!==n?(A=n("Cache hit rate"),e[59]=n,e[60]=A):A=e[60];let L;e[61]!==m||e[62]!==n?(L=m?n("{rate} ({count} entries)",{count:m.entries,rate:jt(m.hits,m.misses)}):n("no cache configured"),e[61]=m,e[62]=n,e[63]=L):L=e[63];let E;e[64]!==A||e[65]!==L?(E=(0,t.jsx)(de,{label:A,testId:"mt-cache",value:L}),e[64]=A,e[65]=L,e[66]=E):E=e[66];let O;return e[67]!==w||e[68]!==z||e[69]!==C||e[70]!==$||e[71]!==E||e[72]!==c||e[73]!==v?(O=(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:[c,v,w,z,C,$,E]}),e[67]=w,e[68]=z,e[69]=C,e[70]=$,e[71]=E,e[72]=c,e[73]=v,e[74]=O):O=e[74],O},"ss"),We=b(l=>l>=100?"critical":l>=50?"warning":"good","Ge"),Qe=b(l=>l<1?`${(l*1e3).toFixed(0)}\u03BCs`:l<1e3?`${l.toFixed(1)}ms`:`${(l/1e3).toFixed(2)}s`,"Le"),Ve=b(l=>l>=1e9?`${(l/1e9).toFixed(1)}B`:l>=1e6?`${(l/1e6).toFixed(1)}M`:l>=1e3?`${(l/1e3).toFixed(1)}K`:l.toLocaleString(),"Ue"),sr=b(l=>{let e=(0,me.c)(3),{level:s}=l;if(s==="critical"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(Ge,{variant:"destructive",children:"Slow"}),e[0]=r):r=e[0],r}if(s==="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},"rs"),lr=b((l,e)=>{let s=[...l];return s.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}}),s},"ls"),nr=b(l=>{let e=(0,me.c)(161),{queryStats:s}=l,a=he(),[r,o]=(0,j.useState)("totalTime"),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=new Set,e[0]=i):i=e[0];let[n,m]=(0,j.useState)(i),p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=b(_=>{_!==null&&o(_)},"p"),e[1]=p):p=e[1];let h=p,u,c,d,f,g,v,x,S,y,w;if(e[2]!==n||e[3]!==s||e[4]!==r||e[5]!==a){d=Symbol.for("react.early_return_sentinel");e:{let _=lr(s,r),C;e[16]!==s?(C=s.filter(ir),e[16]=s,e[17]=C):C=e[17];let R=C.length,M;e[18]!==s?(M=s.filter(or),e[18]=s,e[19]=M):M=e[19];let $=M.length,A;e[20]!==s?(A=s.filter(dr),e[20]=s,e[21]=A):A=e[21];let L=A.length,E;e[22]===Symbol.for("react.memo_cache_sentinel")?(E=b(K=>{m(ce=>{let Q=new Set(ce);return Q.has(K)?Q.delete(K):Q.add(K),Q})},"L"),e[22]=E):E=e[22];let O=E;if(s.length===0){let K;e[23]!==a?(K=a("No query insights yet"),e[23]=a,e[24]=K):K=e[24];let ce;e[25]!==K?(ce=(0,t.jsx)("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:K}),e[25]=K,e[26]=ce):ce=e[26];let Q;e[27]!==a?(Q=a("Query insights appear once statements are executed against this shard."),e[27]=a,e[28]=Q):Q=e[28];let pe;e[29]!==Q?(pe=(0,t.jsx)("p",{className:"mt-1 text-sm",children:Q}),e[29]=Q,e[30]=pe):pe=e[30];let He;e[31]!==ce||e[32]!==pe?(He=(0,t.jsx)(fe,{children:(0,t.jsx)(xe,{className:"py-12",children:(0,t.jsxs)("div",{className:"text-center text-muted-foreground",children:[ce,pe]})})}),e[31]=ce,e[32]=pe,e[33]=He):He=e[33],d=He;break e}x="space-y-4",S="qi-root";let ue;e[34]!==a?(ue=a("Critical queries"),e[34]=a,e[35]=ue):ue=e[35];let ge;e[36]!==ue?(ge=(0,t.jsx)(Oe,{className:"pb-2",children:(0,t.jsx)(De,{className:"text-sm font-medium",children:ue})}),e[36]=ue,e[37]=ge):ge=e[37];let T;e[38]!==R?(T=(0,t.jsx)("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:R}),e[38]=R,e[39]=T):T=e[39];let U;e[40]!==a?(U=a(">100ms avg execution"),e[40]=a,e[41]=U):U=e[41];let H;e[42]!==U?(H=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:U}),e[42]=U,e[43]=H):H=e[43];let G;e[44]!==T||e[45]!==H?(G=(0,t.jsxs)(xe,{children:[T,H]}),e[44]=T,e[45]=H,e[46]=G):G=e[46];let J;e[47]!==ge||e[48]!==G?(J=(0,t.jsxs)(fe,{children:[ge,G]}),e[47]=ge,e[48]=G,e[49]=J):J=e[49];let V;e[50]!==a?(V=a("Moderate queries"),e[50]=a,e[51]=V):V=e[51];let W;e[52]!==V?(W=(0,t.jsx)(Oe,{className:"pb-2",children:(0,t.jsx)(De,{className:"text-sm font-medium",children:V})}),e[52]=V,e[53]=W):W=e[53];let X;e[54]!==$?(X=(0,t.jsx)("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:$}),e[54]=$,e[55]=X):X=e[55];let Y;e[56]!==a?(Y=a("50\u2013100ms avg execution"),e[56]=a,e[57]=Y):Y=e[57];let Z;e[58]!==Y?(Z=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:Y}),e[58]=Y,e[59]=Z):Z=e[59];let ee;e[60]!==X||e[61]!==Z?(ee=(0,t.jsxs)(xe,{children:[X,Z]}),e[60]=X,e[61]=Z,e[62]=ee):ee=e[62];let te;e[63]!==W||e[64]!==ee?(te=(0,t.jsxs)(fe,{children:[W,ee]}),e[63]=W,e[64]=ee,e[65]=te):te=e[65];let re;e[66]!==a?(re=a("Fast queries"),e[66]=a,e[67]=re):re=e[67];let ae;e[68]!==re?(ae=(0,t.jsx)(Oe,{className:"pb-2",children:(0,t.jsx)(De,{className:"text-sm font-medium",children:re})}),e[68]=re,e[69]=ae):ae=e[69];let se;e[70]!==L?(se=(0,t.jsx)("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:L}),e[70]=L,e[71]=se):se=e[71];let le;e[72]!==a?(le=a("<50ms avg execution"),e[72]=a,e[73]=le):le=e[73];let ne;e[74]!==le?(ne=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:le}),e[74]=le,e[75]=ne):ne=e[75];let q;e[76]!==se||e[77]!==ne?(q=(0,t.jsxs)(xe,{children:[se,ne]}),e[76]=se,e[77]=ne,e[78]=q):q=e[78];let D;e[79]!==ae||e[80]!==q?(D=(0,t.jsxs)(fe,{children:[ae,q]}),e[79]=ae,e[80]=q,e[81]=D):D=e[81],e[82]!==J||e[83]!==te||e[84]!==D?(y=(0,t.jsxs)("div",{className:"grid gap-4 md:grid-cols-3",children:[J,te,D]}),e[82]=J,e[83]=te,e[84]=D,e[85]=y):y=e[85];let F;e[86]!==a?(F=a("Query leaderboard"),e[86]=a,e[87]=F):F=e[87];let P;e[88]!==F?(P=(0,t.jsx)("h3",{className:"text-lg font-semibold",children:F}),e[88]=F,e[89]=P):P=e[89];let ie;e[90]!==r||e[91]!==a?(ie=a("Slow queries sorted by {sortField}",{sortField:a(r)}),e[90]=r,e[91]=a,e[92]=ie):ie=e[92];let be;e[93]!==ie?(be=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:ie}),e[93]=ie,e[94]=be):be=e[94];let ve;e[95]!==P||e[96]!==be?(ve=(0,t.jsxs)("div",{children:[P,be]}),e[95]=P,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 Be;e[104]===Symbol.for("react.memo_cache_sentinel")?(Be=(0,t.jsx)(Ct,{}),e[104]=Be):Be=e[104];let we;e[105]!==Se?(we=(0,t.jsx)(Mt,{"aria-label":Se,className:"w-[140px]","data-testid":"qi-sort",children:Be}),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 _e;e[109]!==qe?(_e=(0,t.jsx)(je,{value:"totalTime",children:qe}),e[109]=qe,e[110]=_e):_e=e[110];let ke;e[111]!==a?(ke=a("Avg time"),e[111]=a,e[112]=ke):ke=e[112];let Ce;e[113]!==ke?(Ce=(0,t.jsx)(je,{value:"avgTime",children:ke}),e[113]=ke,e[114]=Ce):Ce=e[114];let Me;e[115]!==a?(Me=a("Execution count"),e[115]=a,e[116]=Me):Me=e[116];let Ie;e[117]!==Me?(Ie=(0,t.jsx)(je,{value:"execCount",children:Me}),e[117]=Me,e[118]=Ie):Ie=e[118];let Re;e[119]!==a?(Re=a("Rows read"),e[119]=a,e[120]=Re):Re=e[120];let $e;e[121]!==Re?($e=(0,t.jsx)(je,{value:"rowsRead",children:Re}),e[121]=Re,e[122]=$e):$e=e[122];let Ae;e[123]!==_e||e[124]!==Ce||e[125]!==Ie||e[126]!==$e?(Ae=(0,t.jsxs)(It,{children:[_e,Ce,Ie,$e]}),e[123]=_e,e[124]=Ce,e[125]=Ie,e[126]=$e,e[127]=Ae):Ae=e[127];let ze;e[128]!==r||e[129]!==we||e[130]!==Ae?(ze=(0,t.jsxs)(kt,{onValueChange:h,value:r,children:[we,Ae]}),e[128]=r,e[129]=we,e[130]=Ae,e[131]=ze):ze=e[131];let Ke;e[132]!==Ne||e[133]!==ze?(Ke=(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[Ne,ze]}),e[132]=Ne,e[133]=ze,e[134]=Ke):Ke=e[134],e[135]!==ve||e[136]!==Ke?(w=(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[ve,Ke]}),e[135]=ve,e[136]=Ke,e[137]=w):w=e[137],c=fe;let Le;e[138]!==a?(Le=a("Statements"),e[138]=a,e[139]=Le):Le=e[139];let Te;e[140]!==Le?(Te=(0,t.jsx)(De,{children:Le}),e[140]=Le,e[141]=Te):Te=e[141],v=(0,t.jsxs)(Oe,{children:[Te,(0,t.jsx)(ut,{children:a("{count} tracked statements",{count:_.length})})]}),u=xe,f="space-y-2";let Ue;e[142]!==n||e[143]!==a?(Ue=b(K=>{let ce=K.normalizedSql,Q=n.has(ce),pe=We(K.avgDurationMs);return(0,t.jsxs)("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[(0,t.jsxs)("button",{"aria-expanded":Q,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:b(()=>{O(ce)},"onClick"),type:"button",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[(0,t.jsx)(sr,{level:pe}),(0,t.jsx)("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:K.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(K.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(K.avgDurationMs)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("avg")})]}),K.p95DurationMs!==void 0&&(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:Qe(K.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(K.execCount)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("calls")})]})]})]}),Q&&(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:K.normalizedSql})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[K.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(K.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(K.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(K.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(K.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(K.rowsWritten)})]})]})]})]},ce)},"Ke"),e[142]=n,e[143]=a,e[144]=Ue):Ue=e[144],g=_.map(Ue)}e[2]=n,e[3]=s,e[4]=r,e[5]=a,e[6]=u,e[7]=c,e[8]=d,e[9]=f,e[10]=g,e[11]=v,e[12]=x,e[13]=S,e[14]=y,e[15]=w}else u=e[6],c=e[7],d=e[8],f=e[9],g=e[10],v=e[11],x=e[12],S=e[13],y=e[14],w=e[15];if(d!==Symbol.for("react.early_return_sentinel"))return d;let I;e[145]!==f||e[146]!==g?(I=(0,t.jsx)("div",{className:f,children:g}),e[145]=f,e[146]=g,e[147]=I):I=e[147];let k;e[148]!==u||e[149]!==I?(k=(0,t.jsx)(u,{children:I}),e[148]=u,e[149]=I,e[150]=k):k=e[150];let N;e[151]!==c||e[152]!==k||e[153]!==v?(N=(0,t.jsxs)(c,{children:[v,k]}),e[151]=c,e[152]=k,e[153]=v,e[154]=N):N=e[154];let z;return e[155]!==N||e[156]!==x||e[157]!==S||e[158]!==y||e[159]!==w?(z=(0,t.jsxs)("div",{className:x,"data-testid":S,children:[y,w,N]}),e[155]=N,e[156]=x,e[157]=S,e[158]=y,e[159]=w,e[160]=z):z=e[160],z},"as");function ir(l){return We(l.avgDurationMs)==="critical"}b(ir,"is");function or(l){return We(l.avgDurationMs)==="warning"}b(or,"ns");function dr(l){return We(l.avgDurationMs)==="good"}b(dr,"os");var cr=["1m","5m","15m","1h"],mr=b(l=>new Date(l).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),"ds"),ur=b(l=>l.map(e=>({avg:Math.round(e.avgDurationMs*100)/100,execs:e.execCount,label:mr(e.bucketMs)})),"ms"),hr=b(({shardKey:l=""})=>{let e=he(),[s,a]=(0,j.useState)("15m"),r=Fe(Ee.getQueryInsights,{range:s},{live:!0,shardKey:l}).data,o=ur(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:cr.map(i=>(0,t.jsx)("button",{"aria-pressed":i===s,className:mt("rounded px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",i===s&&"bg-accent font-medium text-foreground"),"data-testid":`qi-range-${i}`,onClick:b(()=>{a(i)},"onClick"),type:"button",children:i},i))}),r?.capped===!0&&(0,t.jsx)(Ge,{"data-testid":"qi-capped",variant:"secondary",children:e("showing a capped set")})]}),o.length===0?(0,t.jsx)(ht,{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)(rt,{height:140,width:"100%",children:(0,t.jsxs)(Lt,{data:o,children:[(0,t.jsx)(st,{strokeDasharray:"3 3",vertical:!1}),(0,t.jsx)(lt,{dataKey:"label",fontSize:10,tickLine:!1}),(0,t.jsx)(nt,{allowDecimals:!1,fontSize:10,tickLine:!1,width:32}),(0,t.jsx)(at,{}),(0,t.jsx)(zt,{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)(rt,{height:140,width:"100%",children:(0,t.jsxs)(Kt,{data:o,children:[(0,t.jsx)(st,{strokeDasharray:"3 3",vertical:!1}),(0,t.jsx)(lt,{dataKey:"label",fontSize:10,tickLine:!1}),(0,t.jsx)(nt,{fontSize:10,tickLine:!1,width:32}),(0,t.jsx)(at,{}),(0,t.jsx)(At,{dataKey:"avg",dot:!1,stroke:"var(--color-destructive)",type:"monotone"})]})})]})]}),(0,t.jsx)(nr,{queryStats:r?.entries??[]})]})},"fs"),gr=gt(Ee.getMetrics),pr=[],fr=b((l,e)=>l?e:"overview","gs"),xr=b(l=>{let e=(0,me.c)(14),s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},e[0]=s):s=e[0];let a;e[1]!==l?(a={live:!0,shardKey:l},e[1]=l,e[2]=a):a=e[2];let r=Fe(Ee.getMetrics,s,a),{data:o}=r,i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i={points:[],shard:null},e[3]=i):i=e[3];let[n,m]=(0,j.useState)(i),p=(0,j.useRef)(null),h=(0,j.useRef)(null),u,c;e[4]!==o||e[5]!==l?(u=b(()=>{o!==void 0&&Nt(l)},"u"),c=[o,l],e[4]=o,e[5]=l,e[6]=u,e[7]=c):(u=e[6],c=e[7]),(0,j.useEffect)(u,c);let d,f;e[8]!==o?(d=b(()=>{if(o===void 0)return;let x=o,S=h.current!==null&&h.current!==x.shard,y=h.current===x.shard?p.current:null;if(h.current=x.shard,p.current=x.requests,S){m({points:[],shard:x.shard});return}y!==null&&x.requests>=y&&m(w=>({points:[...w.shard===x.shard?w.points:[],x.requests-y].slice(-30),shard:x.shard}))},"c"),f=[o],e[8]=o,e[9]=d,e[10]=f):(d=e[9],f=e[10]),(0,j.useEffect)(d,f);let g=n.shard!==null&&n.shard===o?.shard?n.points:pr,v;return e[11]!==r||e[12]!==g?(v={...r,history:g},e[11]=r,e[12]=g,e[13]=v):v=e[13],v},"ps"),br=b(l=>{let e=vt(),s=(0,j.useRef)(!0);(0,j.useEffect)(()=>(s.current=!0,()=>{s.current=!1}),[]);let[a,r]=(0,j.useState)(null),[o,i]=(0,j.useState)(!1),n=b(async()=>{i(!0);let p=l,h=Ot(p,yt());try{let u=await Promise.all(h.map(async c=>{try{let d=await e.query(gr,{},pt(c));return{error:null,metrics:d,shard:c===""?d.shard:c}}catch(d){return{error:ft(d),metrics:null,shard:c===""?"__root__":c}}}));s.current&&r({results:u,shard:p})}finally{s.current&&i(!1)}},"a"),m=a?.shard===l?a.results:null;return{aggregate:m===null?null:Et(m),aggregating:o,clearAggregate:b(()=>{r(null)},"clearAggregate"),runAggregate:b(()=>{bt(n())},"runAggregate"),shardResults:m}},"xs"),vr=b(l=>{if(!l||!("queryStats"in l))return;let e=l.queryStats;if(!(!e||!Array.isArray(e)))return Ft(e)},"bs"),Qt=b(l=>`pb-2 text-sm font-medium transition-colors ${l?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"ot"),yr=b(l=>{let e=(0,me.c)(26),{activeTab:s,onSelect:a,queryCount:r}=l,o=he(),i;e[0]!==a?(i=b(()=>{a("overview")},"n"),e[0]=a,e[1]=i):i=e[1];let n=i,m;e[2]!==a?(m=b(()=>{a("query-insights")},"m"),e[2]=a,e[3]=m):m=e[3];let p=m,h=s==="overview",u;e[4]!==h?(u=Qt(h),e[4]=h,e[5]=u):u=e[5];let c;e[6]!==o?(c=o("Overview"),e[6]=o,e[7]=c):c=e[7];let d;e[8]!==n||e[9]!==u||e[10]!==c?(d=(0,t.jsx)("button",{className:u,"data-testid":"mt-tab-overview",onClick:n,type:"button",children:c}),e[8]=n,e[9]=u,e[10]=c,e[11]=d):d=e[11];let f=s==="query-insights",g;e[12]!==f?(g=Qt(f),e[12]=f,e[13]=g):g=e[13];let v;e[14]!==o?(v=o("Query insights"),e[14]=o,e[15]=v):v=e[15];let x;e[16]!==r?(x=r>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:r}),e[16]=r,e[17]=x):x=e[17];let S;e[18]!==p||e[19]!==x||e[20]!==g||e[21]!==v?(S=(0,t.jsxs)("button",{className:g,"data-testid":"mt-tab-query-insights",onClick:p,type:"button",children:[v,x]}),e[18]=p,e[19]=x,e[20]=g,e[21]=v,e[22]=S):S=e[22];let y;return e[23]!==S||e[24]!==d?(y=(0,t.jsxs)("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[d,S]}),e[23]=S,e[24]=d,e[25]=y):y=e[25],y},"vs"),Nr=b(l=>{let e=(0,me.c)(13),{history:s,metrics:a}=l,r;e[0]!==s?(r=s.at(-1)??0,e[0]=s,e[1]=r):r=e[1];let o;e[2]!==a.errors||e[3]!==a.requests?(o=a.requests===0?"\u2014":`${(a.errors/a.requests*100).toFixed(1)}%`,e[2]=a.errors,e[3]=a.requests,e[4]=o):o=e[4];let i;e[5]!==a?(i=Dt(a),e[5]=a,e[6]=i):i=e[6];let n;return e[7]!==s||e[8]!==a||e[9]!==r||e[10]!==o||e[11]!==i?(n=(0,t.jsx)(ar,{currentDelta:r,errorRate:o,history:s,latencyPercentiles:i,metrics:a}),e[7]=s,e[8]=a,e[9]=r,e[10]=o,e[11]=i,e[12]=n):n=e[12],n},"ys"),Sr=b(l=>{let e=(0,me.c)(25),{aggregating:s,liveError:a,onAggregate:r,onClearAggregate:o,onShardKeyChange:i,shardKey:n}=l,m=he(),p;e[0]!==i||e[1]!==n?(p=(0,t.jsx)(St,{onChange:i,testId:"mt-shard-input",value:n}),e[0]=i,e[1]=n,e[2]=p):p=e[2];let h;e[3]!==a?(h=(0,t.jsx)(qt,{message:a,prefix:"mt"}),e[3]=a,e[4]=h):h=e[4];let u;e[5]!==s||e[6]!==m?(u=m(s?"Aggregating\u2026":"All shards"),e[5]=s,e[6]=m,e[7]=u):u=e[7];let c;e[8]!==s||e[9]!==r||e[10]!==u?(c=(0,t.jsx)(Ye,{"data-testid":"mt-aggregate",disabled:s,onClick:r,size:"sm",type:"button",variant:"secondary",children:u}),e[8]=s,e[9]=r,e[10]=u,e[11]=c):c=e[11];let d;e[12]!==o||e[13]!==m?(d=o!==void 0&&(0,t.jsx)(Ye,{"data-testid":"mt-aggregate-clear",onClick:o,size:"sm",type:"button",variant:"ghost",children:m("Hide")}),e[12]=o,e[13]=m,e[14]=d):d=e[14];let f;e[15]!==m?(f=m("Open in Cloudflare"),e[15]=m,e[16]=f):f=e[16];let g;e[17]!==f?(g=(0,t.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:_t,rel:"noreferrer",target:"_blank",children:f}),e[17]=f,e[18]=g):g=e[18];let v;return e[19]!==p||e[20]!==h||e[21]!==c||e[22]!==d||e[23]!==g?(v=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[p,h,c,d,g]}),e[19]=p,e[20]=h,e[21]=c,e[22]=d,e[23]=g,e[24]=v):v=e[24],v},"Ns"),Jr=b(l=>{let e=(0,me.c)(41),{initialShardKey:s}=l,{queryShardKey:a,setShardKey:r,shardKey:o}=wt(s),[i,n]=(0,j.useState)("overview"),m=$t(a),{data:p,error:h,history:u,liveError:c}=xr(a),d=p??null,{aggregate:f,aggregating:g,clearAggregate:v,runAggregate:x,shardResults:S}=br(o),y;e[0]!==d?(y=vr(d),e[0]=d,e[1]=y):y=e[1];let w=y,I=w!==void 0,k;e[2]!==i||e[3]!==I?(k=fr(I,i),e[2]=i,e[3]=I,e[4]=k):k=e[4];let N=k,z=S===null?void 0:v,_;e[5]!==g||e[6]!==c||e[7]!==x||e[8]!==r||e[9]!==o||e[10]!==z?(_=(0,t.jsx)(Sr,{aggregating:g,liveError:c,onAggregate:x,onClearAggregate:z,onShardKeyChange:r,shardKey:o}),e[5]=g,e[6]=c,e[7]=x,e[8]=r,e[9]=o,e[10]=z,e[11]=_):_=e[11];let C;e[12]!==h?(C=h!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:h}),e[12]=h,e[13]=C):C=e[13];let R;e[14]!==N||e[15]!==w?(R=w!==void 0&&(0,t.jsx)(yr,{activeTab:N,onSelect:n,queryCount:w.length}),e[14]=N,e[15]=w,e[16]=R):R=e[16];let M;e[17]!==N||e[18]!==a||e[19]!==w?(M=N==="query-insights"&&w!==void 0&&(0,t.jsx)(hr,{shardKey:a}),e[17]=N,e[18]=a,e[19]=w,e[20]=M):M=e[20];let $;e[21]!==N||e[22]!==u||e[23]!==d?($=N==="overview"&&d!==null&&(0,t.jsx)(Nr,{history:u,metrics:d}),e[21]=N,e[22]=u,e[23]=d,e[24]=$):$=e[24];let A;e[25]!==N||e[26]!==m||e[27]!==a?(A=N==="overview"&&(0,t.jsx)(tr,{onOpenTrace:m,shardKey:a}),e[25]=N,e[26]=m,e[27]=a,e[28]=A):A=e[28];let L;e[29]!==f||e[30]!==N||e[31]!==S?(L=N==="overview"&&f!==null&&S!==null&&(0,t.jsx)(rr,{aggregate:f,shardResults:S}),e[29]=f,e[30]=N,e[31]=S,e[32]=L):L=e[32];let E;return e[33]!==A||e[34]!==L||e[35]!==_||e[36]!==C||e[37]!==R||e[38]!==M||e[39]!==$?(E=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[_,C,R,M,$,A,L]}),e[33]=A,e[34]=L,e[35]=_,e[36]=C,e[37]=R,e[38]=M,e[39]=$,e[40]=E):E=e[40],E},"Js");export{Jr as MetricsPanel};
|
|
1
|
+
import{a as Pt,b as jt,c as ot}from"./chunk-VEWQWS3J.js";import{a as de}from"./chunk-AOHKAKKL.js";import{a as Et,b as Ot,c as Dt,d as Ft}from"./chunk-TDVDZ7XQ.js";import{a as it}from"./chunk-HONLEKH5.js";import{a as rt,b as at,c as st,d as At,e as zt,f as lt,g as nt,h as Kt,i as Lt}from"./chunk-ZFFZWSDJ.js";import{a as Rt}from"./chunk-R36QXQZX.js";import{a as $t}from"./chunk-TRZTGE4R.js";import"./chunk-IH2CJZF2.js";import{e as _t}from"./chunk-UYEZR3BI.js";import{a as kt,b as Ct,c as Mt,d as It,e as je}from"./chunk-FLVDICZL.js";import"./chunk-A566HCBX.js";import"./chunk-SYGCASPT.js";import"./chunk-LIGOLZND.js";import{a as qt}from"./chunk-XBZUJDHD.js";import"./chunk-KRPXOSBL.js";import"./chunk-W2BCSK5S.js";import"./chunk-NGVP66OH.js";import"./chunk-XYR5NST4.js";import"./chunk-ZGSL4DPP.js";import{a as wt}from"./chunk-5DNGK3NT.js";import{a as St}from"./chunk-KYONGQQ4.js";import{a as yt,b as Nt}from"./chunk-SLIDAWNX.js";import"./chunk-6M7FLLMT.js";import"./chunk-LUHXNZI4.js";import"./chunk-ZTOREMGH.js";import"./chunk-SDQH4HR6.js";import"./chunk-W7MRISE3.js";import"./chunk-IBJVVHV5.js";import{a as Ye}from"./chunk-2O6KKVH2.js";import"./chunk-JTGGWF7R.js";import"./chunk-ZBON5T5A.js";import{b as Ge}from"./chunk-6I42AM75.js";import"./chunk-4C4THJUD.js";import"./chunk-E26OT26O.js";import{a as Ee}from"./chunk-6UTZXEW3.js";import{c as Fe}from"./chunk-W37HRJGQ.js";import{d as ct,p as vt}from"./chunk-SDSQIQJG.js";import"./chunk-WZTY3ZYI.js";import{a as ht}from"./chunk-3Y5K3IQO.js";import{a as Ze,b as et,c as tt,d as Pe,e as oe,f as B}from"./chunk-CW57Q264.js";import{a as fe,b as Oe,c as De,d as ut,e as xe}from"./chunk-MD67S53Z.js";import{b as mt,f as he,h as gt,i as pt,j as ft,k as xt,o as Je,s as bt}from"./chunk-LPINY2IJ.js";import{a as b,d as Xe,e as Ut,f as Ht,g as Gt}from"./chunk-OXFKZ4BM.js";var me=Xe(Ht(),1),j=Xe(Ut(),1);var t=Xe(Gt(),1);var Bt=b((l,e,s)=>`${l}:${e}:${ct(s??{})}`,"ut"),Tt=b((l,e)=>l==="gauge"?e.last:l==="histogram"?e.sum/Math.max(1,e.count):e.sum,"ht"),Jt=b((l,e)=>Tt(l,e),"Vt"),Vt=b(l=>Tt(l.kind,l),"Gt"),dt=b(l=>Number.isInteger(l)?l.toLocaleString():l.toLocaleString(void 0,{maximumFractionDigits:2}),"Ye"),Wt=b(l=>Array.isArray(l?.series)?l.series:[],"Yt"),Xt="FUNCTION_NOT_FOUND",Yt=b(l=>{let e=new Map;if(!Array.isArray(l?.series))return e;for(let s of l.series)e.set(Bt(s.kind,s.name,s.attributes),s.points);return e},"Wt"),Zt={counter:"secondary",gauge:"default",histogram:"outline"},er=b(l=>{let e=(0,me.c)(18),{name:s,onOpenTrace:a,traceId:r}=l,o=he();if(r===void 0){let c;return e[0]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),e[0]=c):c=e[0],c}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 c=`mt-instrument-trace-${s}`,d;return e[3]!==n||e[4]!==c||e[5]!==r?(d=(0,t.jsx)("span",{className:"text-muted-foreground","data-testid":c,title:r,children:n}),e[3]=n,e[4]=c,e[5]=r,e[6]=d):d=e[6],d}let m=`mt-instrument-trace-${s}`,p;e[7]!==a||e[8]!==r?(p=b(()=>{a(r)},"p"),e[7]=a,e[8]=r,e[9]=p):p=e[9];let h;e[10]!==o||e[11]!==r?(h=o("Open the exemplar trace {trace}",{trace:r}),e[10]=o,e[11]=r,e[12]=h):h=e[12];let u;return e[13]!==n||e[14]!==m||e[15]!==p||e[16]!==h?(u=(0,t.jsx)("button",{className:"text-primary underline-offset-4 hover:underline","data-testid":m,onClick:p,title:h,type:"button",children:n}),e[13]=n,e[14]=m,e[15]=p,e[16]=h,e[17]=u):u=e[17],u},"Zt"),tr=b(l=>{let e=(0,me.c)(105),{onOpenTrace:s,shardKey:a}=l,r=he(),o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={},e[0]=o):o=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:m,errorSource:p}=Fe(Ee.getMetricSeries,o,i),h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h={},e[3]=h):h=e[3];let u;e[4]!==a?(u={live:!0,shardKey:a},e[4]=a,e[5]=u):u=e[5];let{data:c}=Fe(Ee.getMetricHistory,h,u),d,f,g,v,x,S,y,w,I,k,N,z,_;if(e[6]!==n||e[7]!==m||e[8]!==p||e[9]!==c||e[10]!==s||e[11]!==r){w=Symbol.for("react.early_return_sentinel");e:{let L=Wt(n),E=xt(p)===Xt;if(m!==null&&!E){let q;e[25]!==r?(q=r("Instruments"),e[25]=r,e[26]=q):q=e[26];let D;e[27]!==q?(D=(0,t.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:q}),e[27]=q,e[28]=D):D=e[28];let F;e[29]!==m||e[30]!==r?(F=r("Instruments unavailable: {error}",{error:m}),e[29]=m,e[30]=r,e[31]=F):F=e[31];let P;e[32]!==F?(P=(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":"mt-instruments-error",role:"status",children:F}),e[32]=F,e[33]=P):P=e[33];let ie;e[34]!==D||e[35]!==P?(ie=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"mt-instruments",children:[D,P]}),e[34]=D,e[35]=P,e[36]=ie):ie=e[36],w=ie;break e}if(L.length===0){w=null;break e}let O=Yt(c),ue;e[37]!==r?(ue=b(q=>r(q==="counter"?"Counter":q==="gauge"?"Gauge":"Histogram"),"de"),e[37]=r,e[38]=ue):ue=e[38];let ge=ue;x="flex flex-col gap-2",S="mt-instruments";let T;e[39]!==r?(T=r("Instruments"),e[39]=r,e[40]=T):T=e[40],e[41]!==T?(y=(0,t.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:T}),e[41]=T,e[42]=y):y=e[42],v=fe,_="overflow-hidden py-0",g=xe,z="px-0",f=Ze,k="mt-instruments-table";let U;e[43]!==r?(U=r("name"),e[43]=r,e[44]=U):U=e[44];let H;e[45]!==U?(H=(0,t.jsx)(oe,{children:U}),e[45]=U,e[46]=H):H=e[46];let G;e[47]!==r?(G=r("kind"),e[47]=r,e[48]=G):G=e[48];let J;e[49]!==G?(J=(0,t.jsx)(oe,{children:G}),e[49]=G,e[50]=J):J=e[50];let V;e[51]!==r?(V=r("value"),e[51]=r,e[52]=V):V=e[52];let W;e[53]!==V?(W=(0,t.jsx)(oe,{className:"text-right",children:V}),e[53]=V,e[54]=W):W=e[54];let X;e[55]!==r?(X=r("count"),e[55]=r,e[56]=X):X=e[56];let Y;e[57]!==X?(Y=(0,t.jsx)(oe,{className:"text-right",children:X}),e[57]=X,e[58]=Y):Y=e[58];let Z;e[59]!==r?(Z=r("range"),e[59]=r,e[60]=Z):Z=e[60];let ee;e[61]!==Z?(ee=(0,t.jsx)(oe,{className:"text-right",children:Z}),e[61]=Z,e[62]=ee):ee=e[62];let te;e[63]!==r?(te=r("trend"),e[63]=r,e[64]=te):te=e[64];let re;e[65]!==te?(re=(0,t.jsx)(oe,{children:te}),e[65]=te,e[66]=re):re=e[66];let ae;e[67]!==r?(ae=r("trace"),e[67]=r,e[68]=ae):ae=e[68];let se;e[69]!==ae?(se=(0,t.jsx)(oe,{children:ae}),e[69]=ae,e[70]=se):se=e[70];let le;e[71]!==r?(le=r("dimensions"),e[71]=r,e[72]=le):le=e[72];let ne;e[73]!==le?(ne=(0,t.jsx)(oe,{children:le}),e[73]=le,e[74]=ne):ne=e[74],e[75]!==H||e[76]!==J||e[77]!==W||e[78]!==Y||e[79]!==ee||e[80]!==re||e[81]!==se||e[82]!==ne?(N=(0,t.jsx)(et,{children:(0,t.jsxs)(Pe,{children:[H,J,W,Y,ee,re,se,ne]})}),e[75]=H,e[76]=J,e[77]=W,e[78]=Y,e[79]=ee,e[80]=re,e[81]=se,e[82]=ne,e[83]=N):N=e[83],d=tt,I=L.map(q=>{let D=Rt(q.attributes),F=Bt(q.kind,q.name,q.attributes),P=(O.get(F)??[]).map(ie=>Jt(q.kind,ie));return(0,t.jsxs)(Pe,{"data-testid":`mt-instrument-${q.name}`,children:[(0,t.jsx)(B,{className:"font-mono text-xs",title:q.functionPath,children:q.name}),(0,t.jsx)(B,{children:(0,t.jsx)(Ge,{variant:Zt[q.kind],children:ge(q.kind)})}),(0,t.jsx)(B,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${q.name}`,children:dt(Vt(q))}),(0,t.jsx)(B,{className:"text-right tabular-nums text-muted-foreground",children:q.count.toLocaleString()}),(0,t.jsx)(B,{className:"text-right font-mono text-xs tabular-nums text-muted-foreground",children:q.min===q.max?"\u2014":`${dt(q.min)}\u2013${dt(q.max)}`}),(0,t.jsx)(B,{children:P.length>=2?(0,t.jsx)(it,{ariaLabel:r("{name} trend",{name:q.name}),className:"h-6 w-24 text-foreground",series:P,testId:`mt-instrument-trend-${q.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)(er,{name:q.name,onOpenTrace:s,traceId:q.exemplarTraceId})}),(0,t.jsx)(B,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:D,children:D===""?"\u2014":D})]},F)})}e[6]=n,e[7]=m,e[8]=p,e[9]=c,e[10]=s,e[11]=r,e[12]=d,e[13]=f,e[14]=g,e[15]=v,e[16]=x,e[17]=S,e[18]=y,e[19]=w,e[20]=I,e[21]=k,e[22]=N,e[23]=z,e[24]=_}else d=e[12],f=e[13],g=e[14],v=e[15],x=e[16],S=e[17],y=e[18],w=e[19],I=e[20],k=e[21],N=e[22],z=e[23],_=e[24];if(w!==Symbol.for("react.early_return_sentinel"))return w;let C;e[84]!==d||e[85]!==I?(C=(0,t.jsx)(d,{children:I}),e[84]=d,e[85]=I,e[86]=C):C=e[86];let R;e[87]!==f||e[88]!==C||e[89]!==k||e[90]!==N?(R=(0,t.jsxs)(f,{"data-testid":k,children:[N,C]}),e[87]=f,e[88]=C,e[89]=k,e[90]=N,e[91]=R):R=e[91];let M;e[92]!==g||e[93]!==R||e[94]!==z?(M=(0,t.jsx)(g,{className:z,children:R}),e[92]=g,e[93]=R,e[94]=z,e[95]=M):M=e[95];let $;e[96]!==v||e[97]!==M||e[98]!==_?($=(0,t.jsx)(v,{className:_,children:M}),e[96]=v,e[97]=M,e[98]=_,e[99]=$):$=e[99];let A;return e[100]!==x||e[101]!==S||e[102]!==y||e[103]!==$?(A=(0,t.jsxs)("section",{className:x,"data-testid":S,children:[y,$]}),e[100]=x,e[101]=S,e[102]=y,e[103]=$,e[104]=A):A=e[104],A},"es"),rr=b(l=>{let e=(0,me.c)(74),{aggregate:s,shardResults:a}=l,r=he(),o;e[0]!==r?(o=r("Shards"),e[0]=r,e[1]=o):o=e[1];let i;e[2]!==s.failed||e[3]!==s.reachable||e[4]!==r?(i=s.failed>0?r("{reachable} reachable, {failed} unreachable",{failed:s.failed,reachable:s.reachable}):r("{reachable} reachable",{reachable:s.reachable}),e[2]=s.failed,e[3]=s.reachable,e[4]=r,e[5]=i):i=e[5];let n;e[6]!==o||e[7]!==i?(n=(0,t.jsx)(de,{label:o,testId:"mt-agg-shards",value:i}),e[6]=o,e[7]=i,e[8]=n):n=e[8];let m;e[9]!==r?(m=r("Total requests"),e[9]=r,e[10]=m):m=e[10];let p;e[11]!==s.totalRequests||e[12]!==m?(p=(0,t.jsx)(de,{label:m,testId:"mt-agg-requests",value:s.totalRequests}),e[11]=s.totalRequests,e[12]=m,e[13]=p):p=e[13];let h;e[14]!==r?(h=r("Total errors"),e[14]=r,e[15]=h):h=e[15];let u;e[16]!==s.totalErrors||e[17]!==h?(u=(0,t.jsx)(de,{label:h,testId:"mt-agg-errors",value:s.totalErrors}),e[16]=s.totalErrors,e[17]=h,e[18]=u):u=e[18];let c;e[19]!==r?(c=r("Total database size"),e[19]=r,e[20]=c):c=e[20];let d;e[21]!==s.totalDatabaseSize?(d=Je(s.totalDatabaseSize),e[21]=s.totalDatabaseSize,e[22]=d):d=e[22];let f;e[23]!==c||e[24]!==d?(f=(0,t.jsx)(de,{label:c,testId:"mt-agg-db-size",value:d}),e[23]=c,e[24]=d,e[25]=f):f=e[25];let g;e[26]!==r?(g=r("Combined cache hit rate"),e[26]=r,e[27]=g):g=e[27];let v;e[28]!==s.hitRate||e[29]!==r?(v=s.hitRate===null?r("no cache configured"):`${(s.hitRate*100).toFixed(1)}%`,e[28]=s.hitRate,e[29]=r,e[30]=v):v=e[30];let x;e[31]!==g||e[32]!==v?(x=(0,t.jsx)(de,{label:g,testId:"mt-agg-cache",value:v}),e[31]=g,e[32]=v,e[33]=x):x=e[33];let S;e[34]!==f||e[35]!==x||e[36]!==n||e[37]!==p||e[38]!==u?(S=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[n,p,u,f,x]}),e[34]=f,e[35]=x,e[36]=n,e[37]=p,e[38]=u,e[39]=S):S=e[39];let y;e[40]!==r?(y=r("shard"),e[40]=r,e[41]=y):y=e[41];let w;e[42]!==y?(w=(0,t.jsx)(oe,{children:y}),e[42]=y,e[43]=w):w=e[43];let I;e[44]!==r?(I=r("requests"),e[44]=r,e[45]=I):I=e[45];let k;e[46]!==I?(k=(0,t.jsx)(oe,{children:I}),e[46]=I,e[47]=k):k=e[47];let N;e[48]!==r?(N=r("errors"),e[48]=r,e[49]=N):N=e[49];let z;e[50]!==N?(z=(0,t.jsx)(oe,{children:N}),e[50]=N,e[51]=z):z=e[51];let _;e[52]!==r?(_=r("db size"),e[52]=r,e[53]=_):_=e[53];let C;e[54]!==_?(C=(0,t.jsx)(oe,{children:_}),e[54]=_,e[55]=C):C=e[55];let R;e[56]!==w||e[57]!==k||e[58]!==z||e[59]!==C?(R=(0,t.jsx)(et,{children:(0,t.jsxs)(Pe,{children:[w,k,z,C]})}),e[56]=w,e[57]=k,e[58]=z,e[59]=C,e[60]=R):R=e[60];let M;if(e[61]!==a||e[62]!==r){let E;e[64]!==r?(E=b(O=>(0,t.jsxs)(Pe,{"data-testid":`mt-agg-row-${O.shard}`,children:[(0,t.jsx)(B,{children:O.shard}),O.metrics===null?(0,t.jsx)(B,{className:"text-destructive",colSpan:3,children:O.error??r("unreachable")}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(B,{className:"tabular-nums",children:O.metrics.requests}),(0,t.jsx)(B,{className:"tabular-nums",children:O.metrics.errors}),(0,t.jsx)(B,{className:"tabular-nums",children:Je(O.metrics.databaseSize)})]})]},O.shard),"L"),e[64]=r,e[65]=E):E=e[65],M=a.map(E),e[61]=a,e[62]=r,e[63]=M}else M=e[63];let $;e[66]!==M?($=(0,t.jsx)(tt,{children:M}),e[66]=M,e[67]=$):$=e[67];let A;e[68]!==R||e[69]!==$?(A=(0,t.jsx)(fe,{className:"overflow-hidden py-0",children:(0,t.jsx)(xe,{className:"px-0",children:(0,t.jsxs)(Ze,{"data-testid":"mt-agg-table",children:[R,$]})})}),e[68]=R,e[69]=$,e[70]=A):A=e[70];let L;return e[71]!==S||e[72]!==A?(L=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[S,A]}),e[71]=S,e[72]=A,e[73]=L):L=e[73],L},"ts"),ar=b(l=>{let e=(0,me.c)(75),{currentDelta:s,errorRate:a,history:r,latencyPercentiles:o,metrics:i}=l,n=he(),{cache:m}=i,p;e[0]!==r||e[1]!==n?(p=r.length>=2?(0,t.jsx)(it,{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]=p):p=e[2];let h;e[3]!==s||e[4]!==r.length||e[5]!==n?(h=r.length>=2?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"font-semibold text-foreground",children:`+${s.toLocaleString()}`})," ",n("last interval")]}):(0,t.jsx)("span",{"data-testid":"mt-sparkline-empty",children:n("collecting samples\u2026")}),e[3]=s,e[4]=r.length,e[5]=n,e[6]=h):h=e[6];let u;e[7]!==n?(u=n("Requests"),e[7]=n,e[8]=u):u=e[8];let c;e[9]!==i.requests||e[10]!==p||e[11]!==h||e[12]!==u?(c=(0,t.jsx)(de,{chart:p,footer:h,label:u,testId:"mt-requests",value:i.requests}),e[9]=i.requests,e[10]=p,e[11]=h,e[12]=u,e[13]=c):c=e[13];let d;e[14]!==a||e[15]!==n?(d=n("{rate} error rate",{rate:a}),e[14]=a,e[15]=n,e[16]=d):d=e[16];let f;e[17]!==n?(f=n("Errors"),e[17]=n,e[18]=f):f=e[18];let g;e[19]!==a||e[20]!==i.errors?(g=(0,t.jsxs)(t.Fragment,{children:[i.errors," (",a,")"]}),e[19]=a,e[20]=i.errors,e[21]=g):g=e[21];let v;e[22]!==d||e[23]!==f||e[24]!==g?(v=(0,t.jsx)(de,{footer:d,label:f,testId:"mt-errors",value:g}),e[22]=d,e[23]=f,e[24]=g,e[25]=v):v=e[25];let x;e[26]!==o.p90?(x=o.p90>0?`P90 ${ot(o.p90)}`:void 0,e[26]=o.p90,e[27]=x):x=e[27];let S;e[28]!==n?(S=n("P95 latency"),e[28]=n,e[29]=S):S=e[29];let y;e[30]!==o.p95?(y=o.p95>0?ot(o.p95):"\u2014",e[30]=o.p95,e[31]=y):y=e[31];let w;e[32]!==S||e[33]!==y||e[34]!==x?(w=(0,t.jsx)(de,{footer:x,label:S,testId:"mt-p95",value:y}),e[32]=S,e[33]=y,e[34]=x,e[35]=w):w=e[35];let I;e[36]!==m||e[37]!==n?(I=m?`${m.entries.toLocaleString()} ${n("cache entries")}`:void 0,e[36]=m,e[37]=n,e[38]=I):I=e[38];let k;e[39]!==n?(k=n("Database size"),e[39]=n,e[40]=k):k=e[40];let N;e[41]!==i.databaseSize?(N=Je(i.databaseSize),e[41]=i.databaseSize,e[42]=N):N=e[42];let z;e[43]!==I||e[44]!==k||e[45]!==N?(z=(0,t.jsx)(de,{footer:I,label:k,testId:"mt-db-size",value:N}),e[43]=I,e[44]=k,e[45]=N,e[46]=z):z=e[46];let _;e[47]!==n?(_=n("Shard"),e[47]=n,e[48]=_):_=e[48];let C;e[49]!==i.shard||e[50]!==_?(C=(0,t.jsx)(de,{label:_,testId:"mt-shard",value:i.shard}),e[49]=i.shard,e[50]=_,e[51]=C):C=e[51];let R;e[52]!==n?(R=n("Uptime"),e[52]=n,e[53]=R):R=e[53];let M;e[54]!==i.uptimeMs?(M=Pt(i.uptimeMs),e[54]=i.uptimeMs,e[55]=M):M=e[55];let $;e[56]!==R||e[57]!==M?($=(0,t.jsx)(de,{label:R,testId:"mt-uptime",value:M}),e[56]=R,e[57]=M,e[58]=$):$=e[58];let A;e[59]!==n?(A=n("Cache hit rate"),e[59]=n,e[60]=A):A=e[60];let L;e[61]!==m||e[62]!==n?(L=m?n("{rate} ({count} entries)",{count:m.entries,rate:jt(m.hits,m.misses)}):n("no cache configured"),e[61]=m,e[62]=n,e[63]=L):L=e[63];let E;e[64]!==A||e[65]!==L?(E=(0,t.jsx)(de,{label:A,testId:"mt-cache",value:L}),e[64]=A,e[65]=L,e[66]=E):E=e[66];let O;return e[67]!==w||e[68]!==z||e[69]!==C||e[70]!==$||e[71]!==E||e[72]!==c||e[73]!==v?(O=(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:[c,v,w,z,C,$,E]}),e[67]=w,e[68]=z,e[69]=C,e[70]=$,e[71]=E,e[72]=c,e[73]=v,e[74]=O):O=e[74],O},"ss"),We=b(l=>l>=100?"critical":l>=50?"warning":"good","Ge"),Qe=b(l=>l<1?`${(l*1e3).toFixed(0)}\u03BCs`:l<1e3?`${l.toFixed(1)}ms`:`${(l/1e3).toFixed(2)}s`,"Le"),Ve=b(l=>l>=1e9?`${(l/1e9).toFixed(1)}B`:l>=1e6?`${(l/1e6).toFixed(1)}M`:l>=1e3?`${(l/1e3).toFixed(1)}K`:l.toLocaleString(),"Ue"),sr=b(l=>{let e=(0,me.c)(3),{level:s}=l;if(s==="critical"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(Ge,{variant:"destructive",children:"Slow"}),e[0]=r):r=e[0],r}if(s==="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},"rs"),lr=b((l,e)=>{let s=[...l];return s.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}}),s},"ls"),nr=b(l=>{let e=(0,me.c)(161),{queryStats:s}=l,a=he(),[r,o]=(0,j.useState)("totalTime"),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=new Set,e[0]=i):i=e[0];let[n,m]=(0,j.useState)(i),p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=b(_=>{_!==null&&o(_)},"p"),e[1]=p):p=e[1];let h=p,u,c,d,f,g,v,x,S,y,w;if(e[2]!==n||e[3]!==s||e[4]!==r||e[5]!==a){d=Symbol.for("react.early_return_sentinel");e:{let _=lr(s,r),C;e[16]!==s?(C=s.filter(ir),e[16]=s,e[17]=C):C=e[17];let R=C.length,M;e[18]!==s?(M=s.filter(or),e[18]=s,e[19]=M):M=e[19];let $=M.length,A;e[20]!==s?(A=s.filter(dr),e[20]=s,e[21]=A):A=e[21];let L=A.length,E;e[22]===Symbol.for("react.memo_cache_sentinel")?(E=b(K=>{m(ce=>{let Q=new Set(ce);return Q.has(K)?Q.delete(K):Q.add(K),Q})},"L"),e[22]=E):E=e[22];let O=E;if(s.length===0){let K;e[23]!==a?(K=a("No query insights yet"),e[23]=a,e[24]=K):K=e[24];let ce;e[25]!==K?(ce=(0,t.jsx)("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:K}),e[25]=K,e[26]=ce):ce=e[26];let Q;e[27]!==a?(Q=a("Query insights appear once statements are executed against this shard."),e[27]=a,e[28]=Q):Q=e[28];let pe;e[29]!==Q?(pe=(0,t.jsx)("p",{className:"mt-1 text-sm",children:Q}),e[29]=Q,e[30]=pe):pe=e[30];let He;e[31]!==ce||e[32]!==pe?(He=(0,t.jsx)(fe,{children:(0,t.jsx)(xe,{className:"py-12",children:(0,t.jsxs)("div",{className:"text-center text-muted-foreground",children:[ce,pe]})})}),e[31]=ce,e[32]=pe,e[33]=He):He=e[33],d=He;break e}x="space-y-4",S="qi-root";let ue;e[34]!==a?(ue=a("Critical queries"),e[34]=a,e[35]=ue):ue=e[35];let ge;e[36]!==ue?(ge=(0,t.jsx)(Oe,{className:"pb-2",children:(0,t.jsx)(De,{className:"text-sm font-medium",children:ue})}),e[36]=ue,e[37]=ge):ge=e[37];let T;e[38]!==R?(T=(0,t.jsx)("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:R}),e[38]=R,e[39]=T):T=e[39];let U;e[40]!==a?(U=a(">100ms avg execution"),e[40]=a,e[41]=U):U=e[41];let H;e[42]!==U?(H=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:U}),e[42]=U,e[43]=H):H=e[43];let G;e[44]!==T||e[45]!==H?(G=(0,t.jsxs)(xe,{children:[T,H]}),e[44]=T,e[45]=H,e[46]=G):G=e[46];let J;e[47]!==ge||e[48]!==G?(J=(0,t.jsxs)(fe,{children:[ge,G]}),e[47]=ge,e[48]=G,e[49]=J):J=e[49];let V;e[50]!==a?(V=a("Moderate queries"),e[50]=a,e[51]=V):V=e[51];let W;e[52]!==V?(W=(0,t.jsx)(Oe,{className:"pb-2",children:(0,t.jsx)(De,{className:"text-sm font-medium",children:V})}),e[52]=V,e[53]=W):W=e[53];let X;e[54]!==$?(X=(0,t.jsx)("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:$}),e[54]=$,e[55]=X):X=e[55];let Y;e[56]!==a?(Y=a("50\u2013100ms avg execution"),e[56]=a,e[57]=Y):Y=e[57];let Z;e[58]!==Y?(Z=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:Y}),e[58]=Y,e[59]=Z):Z=e[59];let ee;e[60]!==X||e[61]!==Z?(ee=(0,t.jsxs)(xe,{children:[X,Z]}),e[60]=X,e[61]=Z,e[62]=ee):ee=e[62];let te;e[63]!==W||e[64]!==ee?(te=(0,t.jsxs)(fe,{children:[W,ee]}),e[63]=W,e[64]=ee,e[65]=te):te=e[65];let re;e[66]!==a?(re=a("Fast queries"),e[66]=a,e[67]=re):re=e[67];let ae;e[68]!==re?(ae=(0,t.jsx)(Oe,{className:"pb-2",children:(0,t.jsx)(De,{className:"text-sm font-medium",children:re})}),e[68]=re,e[69]=ae):ae=e[69];let se;e[70]!==L?(se=(0,t.jsx)("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:L}),e[70]=L,e[71]=se):se=e[71];let le;e[72]!==a?(le=a("<50ms avg execution"),e[72]=a,e[73]=le):le=e[73];let ne;e[74]!==le?(ne=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:le}),e[74]=le,e[75]=ne):ne=e[75];let q;e[76]!==se||e[77]!==ne?(q=(0,t.jsxs)(xe,{children:[se,ne]}),e[76]=se,e[77]=ne,e[78]=q):q=e[78];let D;e[79]!==ae||e[80]!==q?(D=(0,t.jsxs)(fe,{children:[ae,q]}),e[79]=ae,e[80]=q,e[81]=D):D=e[81],e[82]!==J||e[83]!==te||e[84]!==D?(y=(0,t.jsxs)("div",{className:"grid gap-4 md:grid-cols-3",children:[J,te,D]}),e[82]=J,e[83]=te,e[84]=D,e[85]=y):y=e[85];let F;e[86]!==a?(F=a("Query leaderboard"),e[86]=a,e[87]=F):F=e[87];let P;e[88]!==F?(P=(0,t.jsx)("h3",{className:"text-lg font-semibold",children:F}),e[88]=F,e[89]=P):P=e[89];let ie;e[90]!==r||e[91]!==a?(ie=a("Slow queries sorted by {sortField}",{sortField:a(r)}),e[90]=r,e[91]=a,e[92]=ie):ie=e[92];let be;e[93]!==ie?(be=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:ie}),e[93]=ie,e[94]=be):be=e[94];let ve;e[95]!==P||e[96]!==be?(ve=(0,t.jsxs)("div",{children:[P,be]}),e[95]=P,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 Be;e[104]===Symbol.for("react.memo_cache_sentinel")?(Be=(0,t.jsx)(Ct,{}),e[104]=Be):Be=e[104];let we;e[105]!==Se?(we=(0,t.jsx)(Mt,{"aria-label":Se,className:"w-[140px]","data-testid":"qi-sort",children:Be}),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 _e;e[109]!==qe?(_e=(0,t.jsx)(je,{value:"totalTime",children:qe}),e[109]=qe,e[110]=_e):_e=e[110];let ke;e[111]!==a?(ke=a("Avg time"),e[111]=a,e[112]=ke):ke=e[112];let Ce;e[113]!==ke?(Ce=(0,t.jsx)(je,{value:"avgTime",children:ke}),e[113]=ke,e[114]=Ce):Ce=e[114];let Me;e[115]!==a?(Me=a("Execution count"),e[115]=a,e[116]=Me):Me=e[116];let Ie;e[117]!==Me?(Ie=(0,t.jsx)(je,{value:"execCount",children:Me}),e[117]=Me,e[118]=Ie):Ie=e[118];let Re;e[119]!==a?(Re=a("Rows read"),e[119]=a,e[120]=Re):Re=e[120];let $e;e[121]!==Re?($e=(0,t.jsx)(je,{value:"rowsRead",children:Re}),e[121]=Re,e[122]=$e):$e=e[122];let Ae;e[123]!==_e||e[124]!==Ce||e[125]!==Ie||e[126]!==$e?(Ae=(0,t.jsxs)(It,{children:[_e,Ce,Ie,$e]}),e[123]=_e,e[124]=Ce,e[125]=Ie,e[126]=$e,e[127]=Ae):Ae=e[127];let ze;e[128]!==r||e[129]!==we||e[130]!==Ae?(ze=(0,t.jsxs)(kt,{onValueChange:h,value:r,children:[we,Ae]}),e[128]=r,e[129]=we,e[130]=Ae,e[131]=ze):ze=e[131];let Ke;e[132]!==Ne||e[133]!==ze?(Ke=(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[Ne,ze]}),e[132]=Ne,e[133]=ze,e[134]=Ke):Ke=e[134],e[135]!==ve||e[136]!==Ke?(w=(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[ve,Ke]}),e[135]=ve,e[136]=Ke,e[137]=w):w=e[137],c=fe;let Le;e[138]!==a?(Le=a("Statements"),e[138]=a,e[139]=Le):Le=e[139];let Te;e[140]!==Le?(Te=(0,t.jsx)(De,{children:Le}),e[140]=Le,e[141]=Te):Te=e[141],v=(0,t.jsxs)(Oe,{children:[Te,(0,t.jsx)(ut,{children:a("{count} tracked statements",{count:_.length})})]}),u=xe,f="space-y-2";let Ue;e[142]!==n||e[143]!==a?(Ue=b(K=>{let ce=K.normalizedSql,Q=n.has(ce),pe=We(K.avgDurationMs);return(0,t.jsxs)("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[(0,t.jsxs)("button",{"aria-expanded":Q,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:b(()=>{O(ce)},"onClick"),type:"button",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[(0,t.jsx)(sr,{level:pe}),(0,t.jsx)("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:K.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(K.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(K.avgDurationMs)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("avg")})]}),K.p95DurationMs!==void 0&&(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:Qe(K.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(K.execCount)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("calls")})]})]})]}),Q&&(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:K.normalizedSql})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[K.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(K.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(K.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(K.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(K.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(K.rowsWritten)})]})]})]})]},ce)},"Ke"),e[142]=n,e[143]=a,e[144]=Ue):Ue=e[144],g=_.map(Ue)}e[2]=n,e[3]=s,e[4]=r,e[5]=a,e[6]=u,e[7]=c,e[8]=d,e[9]=f,e[10]=g,e[11]=v,e[12]=x,e[13]=S,e[14]=y,e[15]=w}else u=e[6],c=e[7],d=e[8],f=e[9],g=e[10],v=e[11],x=e[12],S=e[13],y=e[14],w=e[15];if(d!==Symbol.for("react.early_return_sentinel"))return d;let I;e[145]!==f||e[146]!==g?(I=(0,t.jsx)("div",{className:f,children:g}),e[145]=f,e[146]=g,e[147]=I):I=e[147];let k;e[148]!==u||e[149]!==I?(k=(0,t.jsx)(u,{children:I}),e[148]=u,e[149]=I,e[150]=k):k=e[150];let N;e[151]!==c||e[152]!==k||e[153]!==v?(N=(0,t.jsxs)(c,{children:[v,k]}),e[151]=c,e[152]=k,e[153]=v,e[154]=N):N=e[154];let z;return e[155]!==N||e[156]!==x||e[157]!==S||e[158]!==y||e[159]!==w?(z=(0,t.jsxs)("div",{className:x,"data-testid":S,children:[y,w,N]}),e[155]=N,e[156]=x,e[157]=S,e[158]=y,e[159]=w,e[160]=z):z=e[160],z},"as");function ir(l){return We(l.avgDurationMs)==="critical"}b(ir,"is");function or(l){return We(l.avgDurationMs)==="warning"}b(or,"ns");function dr(l){return We(l.avgDurationMs)==="good"}b(dr,"os");var cr=["1m","5m","15m","1h"],mr=b(l=>new Date(l).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),"ds"),ur=b(l=>l.map(e=>({avg:Math.round(e.avgDurationMs*100)/100,execs:e.execCount,label:mr(e.bucketMs)})),"ms"),hr=b(({shardKey:l=""})=>{let e=he(),[s,a]=(0,j.useState)("15m"),r=Fe(Ee.getQueryInsights,{range:s},{live:!0,shardKey:l}).data,o=ur(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:cr.map(i=>(0,t.jsx)("button",{"aria-pressed":i===s,className:mt("rounded px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",i===s&&"bg-accent font-medium text-foreground"),"data-testid":`qi-range-${i}`,onClick:b(()=>{a(i)},"onClick"),type:"button",children:i},i))}),r?.capped===!0&&(0,t.jsx)(Ge,{"data-testid":"qi-capped",variant:"secondary",children:e("showing a capped set")})]}),o.length===0?(0,t.jsx)(ht,{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)(rt,{height:140,width:"100%",children:(0,t.jsxs)(Lt,{data:o,children:[(0,t.jsx)(st,{strokeDasharray:"3 3",vertical:!1}),(0,t.jsx)(lt,{dataKey:"label",fontSize:10,tickLine:!1}),(0,t.jsx)(nt,{allowDecimals:!1,fontSize:10,tickLine:!1,width:32}),(0,t.jsx)(at,{}),(0,t.jsx)(zt,{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)(rt,{height:140,width:"100%",children:(0,t.jsxs)(Kt,{data:o,children:[(0,t.jsx)(st,{strokeDasharray:"3 3",vertical:!1}),(0,t.jsx)(lt,{dataKey:"label",fontSize:10,tickLine:!1}),(0,t.jsx)(nt,{fontSize:10,tickLine:!1,width:32}),(0,t.jsx)(at,{}),(0,t.jsx)(At,{dataKey:"avg",dot:!1,stroke:"var(--color-destructive)",type:"monotone"})]})})]})]}),(0,t.jsx)(nr,{queryStats:r?.entries??[]})]})},"fs"),gr=gt(Ee.getMetrics),pr=[],fr=b((l,e)=>l?e:"overview","gs"),xr=b(l=>{let e=(0,me.c)(14),s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},e[0]=s):s=e[0];let a;e[1]!==l?(a={live:!0,shardKey:l},e[1]=l,e[2]=a):a=e[2];let r=Fe(Ee.getMetrics,s,a),{data:o}=r,i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i={points:[],shard:null},e[3]=i):i=e[3];let[n,m]=(0,j.useState)(i),p=(0,j.useRef)(null),h=(0,j.useRef)(null),u,c;e[4]!==o||e[5]!==l?(u=b(()=>{o!==void 0&&Nt(l)},"u"),c=[o,l],e[4]=o,e[5]=l,e[6]=u,e[7]=c):(u=e[6],c=e[7]),(0,j.useEffect)(u,c);let d,f;e[8]!==o?(d=b(()=>{if(o===void 0)return;let x=o,S=h.current!==null&&h.current!==x.shard,y=h.current===x.shard?p.current:null;if(h.current=x.shard,p.current=x.requests,S){m({points:[],shard:x.shard});return}y!==null&&x.requests>=y&&m(w=>({points:[...w.shard===x.shard?w.points:[],x.requests-y].slice(-30),shard:x.shard}))},"c"),f=[o],e[8]=o,e[9]=d,e[10]=f):(d=e[9],f=e[10]),(0,j.useEffect)(d,f);let g=n.shard!==null&&n.shard===o?.shard?n.points:pr,v;return e[11]!==r||e[12]!==g?(v={...r,history:g},e[11]=r,e[12]=g,e[13]=v):v=e[13],v},"ps"),br=b(l=>{let e=vt(),s=(0,j.useRef)(!0);(0,j.useEffect)(()=>(s.current=!0,()=>{s.current=!1}),[]);let[a,r]=(0,j.useState)(null),[o,i]=(0,j.useState)(!1),n=b(async()=>{i(!0);let p=l,h=Ot(p,yt());try{let u=await Promise.all(h.map(async c=>{try{let d=await e.query(gr,{},pt(c));return{error:null,metrics:d,shard:c===""?d.shard:c}}catch(d){return{error:ft(d),metrics:null,shard:c===""?"__root__":c}}}));s.current&&r({results:u,shard:p})}finally{s.current&&i(!1)}},"a"),m=a?.shard===l?a.results:null;return{aggregate:m===null?null:Et(m),aggregating:o,clearAggregate:b(()=>{r(null)},"clearAggregate"),runAggregate:b(()=>{bt(n())},"runAggregate"),shardResults:m}},"xs"),vr=b(l=>{if(!l||!("queryStats"in l))return;let e=l.queryStats;if(!(!e||!Array.isArray(e)))return Ft(e)},"bs"),Qt=b(l=>`pb-2 text-sm font-medium transition-colors ${l?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"ot"),yr=b(l=>{let e=(0,me.c)(26),{activeTab:s,onSelect:a,queryCount:r}=l,o=he(),i;e[0]!==a?(i=b(()=>{a("overview")},"n"),e[0]=a,e[1]=i):i=e[1];let n=i,m;e[2]!==a?(m=b(()=>{a("query-insights")},"m"),e[2]=a,e[3]=m):m=e[3];let p=m,h=s==="overview",u;e[4]!==h?(u=Qt(h),e[4]=h,e[5]=u):u=e[5];let c;e[6]!==o?(c=o("Overview"),e[6]=o,e[7]=c):c=e[7];let d;e[8]!==n||e[9]!==u||e[10]!==c?(d=(0,t.jsx)("button",{className:u,"data-testid":"mt-tab-overview",onClick:n,type:"button",children:c}),e[8]=n,e[9]=u,e[10]=c,e[11]=d):d=e[11];let f=s==="query-insights",g;e[12]!==f?(g=Qt(f),e[12]=f,e[13]=g):g=e[13];let v;e[14]!==o?(v=o("Query insights"),e[14]=o,e[15]=v):v=e[15];let x;e[16]!==r?(x=r>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:r}),e[16]=r,e[17]=x):x=e[17];let S;e[18]!==p||e[19]!==x||e[20]!==g||e[21]!==v?(S=(0,t.jsxs)("button",{className:g,"data-testid":"mt-tab-query-insights",onClick:p,type:"button",children:[v,x]}),e[18]=p,e[19]=x,e[20]=g,e[21]=v,e[22]=S):S=e[22];let y;return e[23]!==S||e[24]!==d?(y=(0,t.jsxs)("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[d,S]}),e[23]=S,e[24]=d,e[25]=y):y=e[25],y},"vs"),Nr=b(l=>{let e=(0,me.c)(13),{history:s,metrics:a}=l,r;e[0]!==s?(r=s.at(-1)??0,e[0]=s,e[1]=r):r=e[1];let o;e[2]!==a.errors||e[3]!==a.requests?(o=a.requests===0?"\u2014":`${(a.errors/a.requests*100).toFixed(1)}%`,e[2]=a.errors,e[3]=a.requests,e[4]=o):o=e[4];let i;e[5]!==a?(i=Dt(a),e[5]=a,e[6]=i):i=e[6];let n;return e[7]!==s||e[8]!==a||e[9]!==r||e[10]!==o||e[11]!==i?(n=(0,t.jsx)(ar,{currentDelta:r,errorRate:o,history:s,latencyPercentiles:i,metrics:a}),e[7]=s,e[8]=a,e[9]=r,e[10]=o,e[11]=i,e[12]=n):n=e[12],n},"ys"),Sr=b(l=>{let e=(0,me.c)(25),{aggregating:s,liveError:a,onAggregate:r,onClearAggregate:o,onShardKeyChange:i,shardKey:n}=l,m=he(),p;e[0]!==i||e[1]!==n?(p=(0,t.jsx)(St,{onChange:i,testId:"mt-shard-input",value:n}),e[0]=i,e[1]=n,e[2]=p):p=e[2];let h;e[3]!==a?(h=(0,t.jsx)(qt,{message:a,prefix:"mt"}),e[3]=a,e[4]=h):h=e[4];let u;e[5]!==s||e[6]!==m?(u=m(s?"Aggregating\u2026":"All shards"),e[5]=s,e[6]=m,e[7]=u):u=e[7];let c;e[8]!==s||e[9]!==r||e[10]!==u?(c=(0,t.jsx)(Ye,{"data-testid":"mt-aggregate",disabled:s,onClick:r,size:"sm",type:"button",variant:"secondary",children:u}),e[8]=s,e[9]=r,e[10]=u,e[11]=c):c=e[11];let d;e[12]!==o||e[13]!==m?(d=o!==void 0&&(0,t.jsx)(Ye,{"data-testid":"mt-aggregate-clear",onClick:o,size:"sm",type:"button",variant:"ghost",children:m("Hide")}),e[12]=o,e[13]=m,e[14]=d):d=e[14];let f;e[15]!==m?(f=m("Open in Cloudflare"),e[15]=m,e[16]=f):f=e[16];let g;e[17]!==f?(g=(0,t.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:_t,rel:"noreferrer",target:"_blank",children:f}),e[17]=f,e[18]=g):g=e[18];let v;return e[19]!==p||e[20]!==h||e[21]!==c||e[22]!==d||e[23]!==g?(v=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[p,h,c,d,g]}),e[19]=p,e[20]=h,e[21]=c,e[22]=d,e[23]=g,e[24]=v):v=e[24],v},"Ns"),Jr=b(l=>{let e=(0,me.c)(41),{initialShardKey:s}=l,{queryShardKey:a,setShardKey:r,shardKey:o}=wt(s),[i,n]=(0,j.useState)("overview"),m=$t(a),{data:p,error:h,history:u,liveError:c}=xr(a),d=p??null,{aggregate:f,aggregating:g,clearAggregate:v,runAggregate:x,shardResults:S}=br(o),y;e[0]!==d?(y=vr(d),e[0]=d,e[1]=y):y=e[1];let w=y,I=w!==void 0,k;e[2]!==i||e[3]!==I?(k=fr(I,i),e[2]=i,e[3]=I,e[4]=k):k=e[4];let N=k,z=S===null?void 0:v,_;e[5]!==g||e[6]!==c||e[7]!==x||e[8]!==r||e[9]!==o||e[10]!==z?(_=(0,t.jsx)(Sr,{aggregating:g,liveError:c,onAggregate:x,onClearAggregate:z,onShardKeyChange:r,shardKey:o}),e[5]=g,e[6]=c,e[7]=x,e[8]=r,e[9]=o,e[10]=z,e[11]=_):_=e[11];let C;e[12]!==h?(C=h!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:h}),e[12]=h,e[13]=C):C=e[13];let R;e[14]!==N||e[15]!==w?(R=w!==void 0&&(0,t.jsx)(yr,{activeTab:N,onSelect:n,queryCount:w.length}),e[14]=N,e[15]=w,e[16]=R):R=e[16];let M;e[17]!==N||e[18]!==a||e[19]!==w?(M=N==="query-insights"&&w!==void 0&&(0,t.jsx)(hr,{shardKey:a}),e[17]=N,e[18]=a,e[19]=w,e[20]=M):M=e[20];let $;e[21]!==N||e[22]!==u||e[23]!==d?($=N==="overview"&&d!==null&&(0,t.jsx)(Nr,{history:u,metrics:d}),e[21]=N,e[22]=u,e[23]=d,e[24]=$):$=e[24];let A;e[25]!==N||e[26]!==m||e[27]!==a?(A=N==="overview"&&(0,t.jsx)(tr,{onOpenTrace:m,shardKey:a}),e[25]=N,e[26]=m,e[27]=a,e[28]=A):A=e[28];let L;e[29]!==f||e[30]!==N||e[31]!==S?(L=N==="overview"&&f!==null&&S!==null&&(0,t.jsx)(rr,{aggregate:f,shardResults:S}),e[29]=f,e[30]=N,e[31]=S,e[32]=L):L=e[32];let E;return e[33]!==A||e[34]!==L||e[35]!==_||e[36]!==C||e[37]!==R||e[38]!==M||e[39]!==$?(E=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[_,C,R,M,$,A,L]}),e[33]=A,e[34]=L,e[35]=_,e[36]=C,e[37]=R,e[38]=M,e[39]=$,e[40]=E):E=e[40],E},"Js");export{Jr as MetricsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as O}from"./chunk-ILLDX6LU.js";import{a as H}from"./chunk-ZWDORIZY.js";import{a as ee}from"./chunk-2O6KKVH2.js";import"./chunk-JTGGWF7R.js";import"./chunk-ZBON5T5A.js";import{b as Z}from"./chunk-6I42AM75.js";import"./chunk-4C4THJUD.js";import{b as E}from"./chunk-4SJDWMH3.js";import{p as W}from"./chunk-FKM35PXF.js";import"./chunk-WZTY3ZYI.js";import{a as R}from"./chunk-3Y5K3IQO.js";import{a as K,b as V,c as z,d as F,e as u,f as p}from"./chunk-CW57Q264.js";import{a as A,e as T}from"./chunk-MD67S53Z.js";import{f as M,j as G,s as _,w as X}from"./chunk-LPINY2IJ.js";import{a as c,d as P,e as oe,f as re,g as ae}from"./chunk-OXFKZ4BM.js";var U=P(re(),1),Y=P(oe(),1);var t=P(ae(),1);var se=P(re(),1),Q=P(oe(),1);var h=P(ae(),1);var ie=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","X"),le=c(a=>a.toSorted((e,i)=>e.scheduledFor-i.scheduledFor),"F"),ce=c((a,e,i)=>e!==void 0?e:i===void 0?d=>a.cancelScheduledJob(d):void 0,"Y"),de=c(a=>{let e=(0,se.c)(16),{cancelJob:i,loadJobs:d}=a===void 0?{}:a,f=W(),r=M(),l=d===void 0,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-scheduled-jobs"],e[0]=o):o=e[0];let N=E(o,async()=>{let v=await(d??(()=>f.listScheduledJobs()))();return le(v)}),[x,n]=(0,Q.useState)(void 0),[s,m]=(0,Q.useState)(void 0),y,k;e[1]!==f||e[2]!==l?(y=c(()=>{if(l)return f.subscribeScheduledJobs(v=>{m(void 0),n(le(v))})},"v"),k=[l,f],e[1]=f,e[2]=l,e[3]=y,e[4]=k):(y=e[3],k=e[4]),(0,Q.useEffect)(y,k);let g;e[5]!==N?(g=c(()=>N.poll(),"y"),e[5]=N,e[6]=g):g=e[6],O(g,!l);let J=ce(f,i,d),b=x??N.data,j=s??N.error,L=c(async v=>{if(J!==void 0){m(void 0);try{await J(v),l||N.refetch()}catch(D){m(G(D))}}},"E"),q="flex flex-col gap-3",B="lunora-scheduled-jobs",S;e[7]!==j?(S=j!==null&&(0,h.jsx)("p",{className:"text-sm text-destructive","data-testid":"sj-error",role:"alert",children:j}),e[7]=j,e[8]=S):S=e[8];let $;e[9]!==b?.length||e[10]!==r?($=b?.length===0&&(0,h.jsx)(R,{description:r("Jobs queued with runAfter / runAt will appear here."),icon:(0,h.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,h.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,h.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"sj-empty",title:r("No scheduled jobs.")}),e[9]=b?.length,e[10]=r,e[11]=$):$=e[11];let I=b!==void 0&&b.length>0&&(0,h.jsx)(A,{className:"overflow-hidden py-0",children:(0,h.jsx)(T,{className:"px-0",children:(0,h.jsxs)(K,{"data-testid":"sj-table",children:[(0,h.jsx)(V,{children:(0,h.jsxs)(F,{children:[(0,h.jsx)(u,{children:r("function")}),(0,h.jsx)(u,{children:r("scheduled for")}),(0,h.jsx)(u,{children:r("pool")}),(0,h.jsx)(u,{children:r("attempts")}),(0,h.jsx)(u,{children:r("shard")}),(0,h.jsx)(u,{children:r("id")}),J!==void 0&&(0,h.jsx)(u,{"aria-label":r("Actions")})]})}),(0,h.jsx)(z,{children:b.map(v=>(0,h.jsxs)(F,{"data-testid":`sj-row-${v.id}`,children:[(0,h.jsx)(p,{className:"font-mono text-xs",children:v.workflow??v.functionPath}),(0,h.jsx)(p,{className:"text-muted-foreground tabular-nums",children:ie(v.scheduledFor)}),(0,h.jsx)(p,{className:"font-mono text-xs",children:v.pool??""}),(0,h.jsx)(p,{className:"tabular-nums",children:v.attempts??0}),(0,h.jsx)(p,{children:v.shardKey??""}),(0,h.jsx)(p,{className:"font-mono text-xs",children:v.id}),J!==void 0&&(0,h.jsx)(p,{className:"text-right",children:(0,h.jsx)(H,{confirmLabel:r("Cancel job?"),onConfirm:c(()=>{_(L(v.id))},"onConfirm"),testId:`sj-cancel-${v.id}`,children:r("Cancel")})})]},v.id))})]})})}),w;return e[12]!==I||e[13]!==S||e[14]!==$?(w=(0,h.jsxs)("div",{className:q,"data-testid":B,children:[S,$,I]}),e[12]=I,e[13]=S,e[14]=$,e[15]=w):w=e[15],w},"he");var he={kind:"idle"},me=c((a,e,i)=>i!==void 0?i:e===void 0?d=>a.runCronJob(d):void 0,"re"),ue=c(({loadCronJobs:a,runCronJob:e}={})=>{let i=W(),d=M(),[f,r]=(0,Y.useState)({}),l=E(["lunora-cron-jobs",a?"custom":"default"],()=>(a??(()=>i.getCronJobs()))()),{data:o,error:N}=l,x=me(i,a,e),n=c(async s=>{if(x!==void 0){r(m=>({...m,[s]:{kind:"running"}}));try{await x(s),r(m=>({...m,[s]:{kind:"ok"}})),l.refetch()}catch(m){r(y=>({...y,[s]:{kind:"error",message:G(m)}}))}}},"i");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[N!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:N}),o?.length===0&&(0,t.jsx)(R,{description:d("Triggers declared with the cronJobs() builder appear here."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,t.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:d("No cron triggers.")}),o!==void 0&&o.length>0&&(0,t.jsx)(A,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"cron-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(u,{children:d("name")}),(0,t.jsx)(u,{children:d("schedule")}),(0,t.jsx)(u,{children:d("target")}),(0,t.jsx)(u,{children:d("shard")}),x!==void 0&&(0,t.jsx)(u,{"aria-label":d("Actions")})]})}),(0,t.jsx)(z,{children:o.map(s=>{let m=f[s.name]??he;return(0,t.jsxs)(F,{"data-testid":`cron-row-${s.name}`,children:[(0,t.jsx)(p,{children:s.name}),(0,t.jsx)(p,{className:"font-mono text-xs tabular-nums",children:s.cron}),(0,t.jsx)(p,{children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[s.workflow===void 0?(0,t.jsx)(Z,{variant:"outline",children:d("function")}):(0,t.jsx)(Z,{variant:"secondary",children:d("workflow")}),(0,t.jsx)("span",{className:"font-mono text-xs",children:s.workflow??s.functionPath})]})}),(0,t.jsx)(p,{children:s.shardKey??""}),x!==void 0&&(0,t.jsx)(p,{className:"text-right",children:(0,t.jsxs)("span",{className:"flex items-center justify-end gap-2",children:[m.kind==="ok"&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${s.name}`,children:d("ran")}),m.kind==="error"&&(0,t.jsx)("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${s.name}`,role:"alert",children:m.message}),(0,t.jsx)(H,{confirmLabel:d("Run now?"),disabled:m.kind==="running",onConfirm:c(()=>{_(n(s.name))},"onConfirm"),testId:`cron-run-${s.name}`,children:m.kind==="running"?d("Running\u2026"):d("Run now")})]})})]},`${s.cron}:${s.name}`)})})]})})})]})},"le"),pe=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","se"),fe=c(a=>{let e=(0,U.c)(34),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadJobs:d,removeJob:f,retryJob:r}=i,l=W(),o=M(),N;e[2]===Symbol.for("react.memo_cache_sentinel")?(N=["lunora-dead-jobs"],e[2]=N):N=e[2];let x;e[3]!==l||e[4]!==d?(x=c(async()=>(await(d??(()=>l.listDeadJobs()))()).toSorted(be),"h"),e[3]=l,e[4]=d,e[5]=x):x=e[5];let n=E(N,x),s=n.data,[m,y]=(0,Y.useState)(void 0),k=n.error??m,g=d===void 0,J;e[6]!==l||e[7]!==g||e[8]!==r?(J=r??(g?C=>l.retryDeadJob(C):void 0),e[6]=l,e[7]=g,e[8]=r,e[9]=J):J=e[9];let b=J,j;e[10]!==l||e[11]!==g||e[12]!==f?(j=f??(g?C=>l.removeDeadJob(C):void 0),e[10]=l,e[11]=g,e[12]=f,e[13]=j):j=e[13];let L=j,q;e[14]!==n?(q=c(()=>n.poll(),"$"),e[14]=n,e[15]=q):q=e[15],O(q,!0);let B;e[16]!==n?(B=c(async C=>{y(void 0);try{await C,n.refetch()}catch(ne){y(G(ne))}},"I"),e[16]=n,e[17]=B):B=e[17];let S=B,$=b!==void 0||L!==void 0,I;e[18]!==k?(I=k!==void 0&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:k}),e[18]=k,e[19]=I):I=e[19];let w;e[20]!==s?.length||e[21]!==o?(w=s?.length===0&&(0,t.jsx)(R,{description:o("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:o("No dead-letter jobs.")}),e[20]=s?.length,e[21]=o,e[22]=w):w=e[22];let v;e[23]!==S||e[24]!==$||e[25]!==s||e[26]!==L||e[27]!==b||e[28]!==o?(v=s!==void 0&&s.length>0&&(0,t.jsx)(A,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"dlq-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(u,{children:o("function")}),(0,t.jsx)(u,{children:o("attempts")}),(0,t.jsx)(u,{children:o("last tried")}),(0,t.jsx)(u,{children:o("pool")}),(0,t.jsx)(u,{children:o("shard")}),(0,t.jsx)(u,{children:o("id")}),$&&(0,t.jsx)(u,{"aria-label":o("Actions")})]})}),(0,t.jsx)(z,{children:s.map(C=>(0,t.jsxs)(F,{"data-testid":`dlq-row-${C.id}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:C.workflow??C.functionPath}),(0,t.jsx)(p,{className:"tabular-nums",children:C.attempts??0}),(0,t.jsx)(p,{className:"text-muted-foreground tabular-nums",children:pe(C.scheduledFor)}),(0,t.jsx)(p,{className:"font-mono text-xs",children:C.pool??""}),(0,t.jsx)(p,{children:C.shardKey??""}),(0,t.jsx)(p,{className:"font-mono text-xs",children:C.id}),$&&(0,t.jsx)(p,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1.5",children:[b!==void 0&&(0,t.jsx)(ee,{"data-testid":`dlq-retry-${C.id}`,onClick:c(()=>{_(S(b(C.id)))},"onClick"),size:"sm",type:"button",variant:"outline",children:o("Retry")}),L!==void 0&&(0,t.jsx)(H,{confirmLabel:o("Drop job?"),onConfirm:c(()=>{_(S(L(C.id)))},"onConfirm"),testId:`dlq-remove-${C.id}`,children:o("Drop")})]})})]},C.id))})]})})}),e[23]=S,e[24]=$,e[25]=s,e[26]=L,e[27]=b,e[28]=o,e[29]=v):v=e[29];let D;return e[30]!==v||e[31]!==I||e[32]!==w?(D=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[I,w,v]}),e[30]=v,e[31]=I,e[32]=w,e[33]=D):D=e[33],D},"ne");function be(a,e){return(e.attempts??0)-(a.attempts??0)}c(be,"oe");var te=c(a=>{let e=(0,U.c)(8),{label:i,testId:d,value:f}=a,r;e[0]!==i?(r=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:i}),e[0]=i,e[1]=r):r=e[1];let l;e[2]!==d||e[3]!==f?(l=(0,t.jsx)("span",{className:"text-2xl font-semibold tabular-nums","data-testid":d,children:f}),e[2]=d,e[3]=f,e[4]=l):l=e[4];let o;return e[5]!==r||e[6]!==l?(o=(0,t.jsx)(A,{className:"flex-1 py-0",children:(0,t.jsxs)(T,{className:"flex flex-col gap-1 p-4",children:[r,l]})}),e[5]=r,e[6]=l,e[7]=o):o=e[7],o},"E"),ve=c(a=>{let e=(0,U.c)(25),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadStatus:d}=i,f=W(),r=M(),l=d===void 0,o;e[2]!==l?(o=["lunora-scheduler-status",l],e[2]=l,e[3]=o):o=e[3];let N;e[4]!==f||e[5]!==d?(N=c(async()=>{let j=await(d??(()=>f.schedulerStatus()))();return{...j,pools:j.pools.toSorted(xe)}},"y"),e[4]=f,e[5]=d,e[6]=N):N=e[6];let x=E(o,N),{data:n,error:s}=x,m;e[7]!==x?(m=c(()=>x.poll(),"d"),e[7]=x,e[8]=m):m=e[8],O(m,!0);let y;e[9]!==s?(y=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:s}),e[9]=s,e[10]=y):y=e[10];let k;e[11]!==n||e[12]!==r?(k=n!==void 0&&(0,t.jsxs)("div",{className:"flex gap-3","data-testid":"pools-totals",children:[(0,t.jsx)(te,{label:r("backlog"),testId:"pools-backlog",value:n.backlog}),(0,t.jsx)(te,{label:r("in flight"),testId:"pools-inflight",value:n.inFlight}),(0,t.jsx)(te,{label:r("pools"),testId:"pools-count",value:n.pools.length})]}),e[11]=n,e[12]=r,e[13]=k):k=e[13];let g;e[14]!==n?.pools.length||e[15]!==r?(g=n?.pools.length===0&&(0,t.jsx)(R,{description:r("Pools created with createWorkpool appear here once they have activity."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:r("No workpools.")}),e[14]=n?.pools.length,e[15]=r,e[16]=g):g=e[16];let J;e[17]!==n||e[18]!==r?(J=n!==void 0&&n.pools.length>0&&(0,t.jsx)(A,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"pools-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(u,{children:r("pool")}),(0,t.jsx)(u,{children:r("queued")}),(0,t.jsx)(u,{children:r("in flight")}),(0,t.jsx)(u,{children:r("max concurrency")})]})}),(0,t.jsx)(z,{children:n.pools.map(ge)})]})})}),e[17]=n,e[18]=r,e[19]=J):J=e[19];let b;return e[20]!==y||e[21]!==k||e[22]!==g||e[23]!==J?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[y,k,g,J]}),e[20]=y,e[21]=k,e[22]=g,e[23]=J,e[24]=b):b=e[24],b},"ae");function xe(a,e){return e.queued-a.queued}c(xe,"ie");function ge(a){return(0,t.jsxs)(F,{"data-testid":`pools-row-${a.name}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:a.name}),(0,t.jsx)(p,{className:"tabular-nums",children:a.queued}),(0,t.jsxs)(p,{className:"tabular-nums",children:[a.inFlight," / ",a.maxConcurrency]}),(0,t.jsx)(p,{className:"tabular-nums",children:a.maxConcurrency})]},a.name)}c(ge,"de");var Ne=["jobs","dead","pools","cron"],Ve=c(a=>{let e=(0,U.c)(41),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadCronJobs:d,scheduledCancel:f,scheduledLoad:r}=i,l=M(),[o,N]=(0,Y.useState)("jobs"),x;e[2]!==l?(x=l("Cron triggers"),e[2]=l,e[3]=x):x=e[3];let n;e[4]!==l?(n=l("Dead letter"),e[4]=l,e[5]=n):n=e[5];let s;e[6]!==l?(s=l("Scheduled jobs"),e[6]=l,e[7]=s):s=e[7];let m;e[8]!==l?(m=l("Pools"),e[8]=l,e[9]=m):m=e[9];let y;e[10]!==x||e[11]!==n||e[12]!==s||e[13]!==m?(y={cron:x,dead:n,jobs:s,pools:m},e[10]=x,e[11]=n,e[12]=s,e[13]=m,e[14]=y):y=e[14];let k=y,g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=c(w=>{N(w.currentTarget.dataset.view)},"f"),e[15]=g):g=e[15];let J=g,b;e[16]!==l?(b=l("Schedule view"),e[16]=l,e[17]=b):b=e[17];let j;e[18]!==o||e[19]!==k?(j=Ne.map(w=>(0,t.jsx)(ee,{"aria-selected":o===w,"data-testid":`schedule-view-${w}`,"data-view":w,onClick:J,role:"tab",size:"sm",type:"button",variant:o===w?"default":"outline",children:k[w]},w)),e[18]=o,e[19]=k,e[20]=j):j=e[20];let L;e[21]!==b||e[22]!==j?(L=(0,t.jsx)("div",{"aria-label":b,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:j}),e[21]=b,e[22]=j,e[23]=L):L=e[23];let q;e[24]!==f||e[25]!==r||e[26]!==o?(q=o==="jobs"&&(0,t.jsx)(de,{cancelJob:f,loadJobs:r}),e[24]=f,e[25]=r,e[26]=o,e[27]=q):q=e[27];let B;e[28]!==o?(B=o==="dead"&&(0,t.jsx)(fe,{}),e[28]=o,e[29]=B):B=e[29];let S;e[30]!==o?(S=o==="pools"&&(0,t.jsx)(ve,{}),e[30]=o,e[31]=S):S=e[31];let $;e[32]!==d||e[33]!==o?($=o==="cron"&&(0,t.jsx)(ue,{loadCronJobs:d}),e[32]=d,e[33]=o,e[34]=$):$=e[34];let I;return e[35]!==L||e[36]!==q||e[37]!==B||e[38]!==S||e[39]!==$?(I=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[L,q,B,S,$]}),e[35]=L,e[36]=q,e[37]=B,e[38]=S,e[39]=$,e[40]=I):I=e[40],I},"Ie");export{Ve as SchedulePanel};
|
|
1
|
+
import{a as O}from"./chunk-FACE2CFY.js";import{a as H}from"./chunk-ZWDORIZY.js";import{a as ee}from"./chunk-2O6KKVH2.js";import"./chunk-JTGGWF7R.js";import"./chunk-ZBON5T5A.js";import{b as Z}from"./chunk-6I42AM75.js";import"./chunk-4C4THJUD.js";import{b as E}from"./chunk-W37HRJGQ.js";import{p as W}from"./chunk-SDSQIQJG.js";import"./chunk-WZTY3ZYI.js";import{a as R}from"./chunk-3Y5K3IQO.js";import{a as K,b as V,c as z,d as F,e as u,f as p}from"./chunk-CW57Q264.js";import{a as A,e as T}from"./chunk-MD67S53Z.js";import{f as M,j as G,s as _,w as X}from"./chunk-LPINY2IJ.js";import{a as c,d as P,e as oe,f as re,g as ae}from"./chunk-OXFKZ4BM.js";var U=P(re(),1),Y=P(oe(),1);var t=P(ae(),1);var se=P(re(),1),Q=P(oe(),1);var h=P(ae(),1);var ie=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","X"),le=c(a=>a.toSorted((e,i)=>e.scheduledFor-i.scheduledFor),"F"),ce=c((a,e,i)=>e!==void 0?e:i===void 0?d=>a.cancelScheduledJob(d):void 0,"Y"),de=c(a=>{let e=(0,se.c)(16),{cancelJob:i,loadJobs:d}=a===void 0?{}:a,f=W(),r=M(),l=d===void 0,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-scheduled-jobs"],e[0]=o):o=e[0];let N=E(o,async()=>{let v=await(d??(()=>f.listScheduledJobs()))();return le(v)}),[x,n]=(0,Q.useState)(void 0),[s,m]=(0,Q.useState)(void 0),y,k;e[1]!==f||e[2]!==l?(y=c(()=>{if(l)return f.subscribeScheduledJobs(v=>{m(void 0),n(le(v))})},"v"),k=[l,f],e[1]=f,e[2]=l,e[3]=y,e[4]=k):(y=e[3],k=e[4]),(0,Q.useEffect)(y,k);let g;e[5]!==N?(g=c(()=>N.poll(),"y"),e[5]=N,e[6]=g):g=e[6],O(g,!l);let J=ce(f,i,d),b=x??N.data,j=s??N.error,L=c(async v=>{if(J!==void 0){m(void 0);try{await J(v),l||N.refetch()}catch(D){m(G(D))}}},"E"),q="flex flex-col gap-3",B="lunora-scheduled-jobs",S;e[7]!==j?(S=j!==null&&(0,h.jsx)("p",{className:"text-sm text-destructive","data-testid":"sj-error",role:"alert",children:j}),e[7]=j,e[8]=S):S=e[8];let $;e[9]!==b?.length||e[10]!==r?($=b?.length===0&&(0,h.jsx)(R,{description:r("Jobs queued with runAfter / runAt will appear here."),icon:(0,h.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,h.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,h.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"sj-empty",title:r("No scheduled jobs.")}),e[9]=b?.length,e[10]=r,e[11]=$):$=e[11];let I=b!==void 0&&b.length>0&&(0,h.jsx)(A,{className:"overflow-hidden py-0",children:(0,h.jsx)(T,{className:"px-0",children:(0,h.jsxs)(K,{"data-testid":"sj-table",children:[(0,h.jsx)(V,{children:(0,h.jsxs)(F,{children:[(0,h.jsx)(u,{children:r("function")}),(0,h.jsx)(u,{children:r("scheduled for")}),(0,h.jsx)(u,{children:r("pool")}),(0,h.jsx)(u,{children:r("attempts")}),(0,h.jsx)(u,{children:r("shard")}),(0,h.jsx)(u,{children:r("id")}),J!==void 0&&(0,h.jsx)(u,{"aria-label":r("Actions")})]})}),(0,h.jsx)(z,{children:b.map(v=>(0,h.jsxs)(F,{"data-testid":`sj-row-${v.id}`,children:[(0,h.jsx)(p,{className:"font-mono text-xs",children:v.workflow??v.functionPath}),(0,h.jsx)(p,{className:"text-muted-foreground tabular-nums",children:ie(v.scheduledFor)}),(0,h.jsx)(p,{className:"font-mono text-xs",children:v.pool??""}),(0,h.jsx)(p,{className:"tabular-nums",children:v.attempts??0}),(0,h.jsx)(p,{children:v.shardKey??""}),(0,h.jsx)(p,{className:"font-mono text-xs",children:v.id}),J!==void 0&&(0,h.jsx)(p,{className:"text-right",children:(0,h.jsx)(H,{confirmLabel:r("Cancel job?"),onConfirm:c(()=>{_(L(v.id))},"onConfirm"),testId:`sj-cancel-${v.id}`,children:r("Cancel")})})]},v.id))})]})})}),w;return e[12]!==I||e[13]!==S||e[14]!==$?(w=(0,h.jsxs)("div",{className:q,"data-testid":B,children:[S,$,I]}),e[12]=I,e[13]=S,e[14]=$,e[15]=w):w=e[15],w},"he");var he={kind:"idle"},me=c((a,e,i)=>i!==void 0?i:e===void 0?d=>a.runCronJob(d):void 0,"re"),ue=c(({loadCronJobs:a,runCronJob:e}={})=>{let i=W(),d=M(),[f,r]=(0,Y.useState)({}),l=E(["lunora-cron-jobs",a?"custom":"default"],()=>(a??(()=>i.getCronJobs()))()),{data:o,error:N}=l,x=me(i,a,e),n=c(async s=>{if(x!==void 0){r(m=>({...m,[s]:{kind:"running"}}));try{await x(s),r(m=>({...m,[s]:{kind:"ok"}})),l.refetch()}catch(m){r(y=>({...y,[s]:{kind:"error",message:G(m)}}))}}},"i");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[N!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:N}),o?.length===0&&(0,t.jsx)(R,{description:d("Triggers declared with the cronJobs() builder appear here."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,t.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:d("No cron triggers.")}),o!==void 0&&o.length>0&&(0,t.jsx)(A,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"cron-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(u,{children:d("name")}),(0,t.jsx)(u,{children:d("schedule")}),(0,t.jsx)(u,{children:d("target")}),(0,t.jsx)(u,{children:d("shard")}),x!==void 0&&(0,t.jsx)(u,{"aria-label":d("Actions")})]})}),(0,t.jsx)(z,{children:o.map(s=>{let m=f[s.name]??he;return(0,t.jsxs)(F,{"data-testid":`cron-row-${s.name}`,children:[(0,t.jsx)(p,{children:s.name}),(0,t.jsx)(p,{className:"font-mono text-xs tabular-nums",children:s.cron}),(0,t.jsx)(p,{children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[s.workflow===void 0?(0,t.jsx)(Z,{variant:"outline",children:d("function")}):(0,t.jsx)(Z,{variant:"secondary",children:d("workflow")}),(0,t.jsx)("span",{className:"font-mono text-xs",children:s.workflow??s.functionPath})]})}),(0,t.jsx)(p,{children:s.shardKey??""}),x!==void 0&&(0,t.jsx)(p,{className:"text-right",children:(0,t.jsxs)("span",{className:"flex items-center justify-end gap-2",children:[m.kind==="ok"&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${s.name}`,children:d("ran")}),m.kind==="error"&&(0,t.jsx)("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${s.name}`,role:"alert",children:m.message}),(0,t.jsx)(H,{confirmLabel:d("Run now?"),disabled:m.kind==="running",onConfirm:c(()=>{_(n(s.name))},"onConfirm"),testId:`cron-run-${s.name}`,children:m.kind==="running"?d("Running\u2026"):d("Run now")})]})})]},`${s.cron}:${s.name}`)})})]})})})]})},"le"),pe=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","se"),fe=c(a=>{let e=(0,U.c)(34),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadJobs:d,removeJob:f,retryJob:r}=i,l=W(),o=M(),N;e[2]===Symbol.for("react.memo_cache_sentinel")?(N=["lunora-dead-jobs"],e[2]=N):N=e[2];let x;e[3]!==l||e[4]!==d?(x=c(async()=>(await(d??(()=>l.listDeadJobs()))()).toSorted(be),"h"),e[3]=l,e[4]=d,e[5]=x):x=e[5];let n=E(N,x),s=n.data,[m,y]=(0,Y.useState)(void 0),k=n.error??m,g=d===void 0,J;e[6]!==l||e[7]!==g||e[8]!==r?(J=r??(g?C=>l.retryDeadJob(C):void 0),e[6]=l,e[7]=g,e[8]=r,e[9]=J):J=e[9];let b=J,j;e[10]!==l||e[11]!==g||e[12]!==f?(j=f??(g?C=>l.removeDeadJob(C):void 0),e[10]=l,e[11]=g,e[12]=f,e[13]=j):j=e[13];let L=j,q;e[14]!==n?(q=c(()=>n.poll(),"$"),e[14]=n,e[15]=q):q=e[15],O(q,!0);let B;e[16]!==n?(B=c(async C=>{y(void 0);try{await C,n.refetch()}catch(ne){y(G(ne))}},"I"),e[16]=n,e[17]=B):B=e[17];let S=B,$=b!==void 0||L!==void 0,I;e[18]!==k?(I=k!==void 0&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:k}),e[18]=k,e[19]=I):I=e[19];let w;e[20]!==s?.length||e[21]!==o?(w=s?.length===0&&(0,t.jsx)(R,{description:o("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:o("No dead-letter jobs.")}),e[20]=s?.length,e[21]=o,e[22]=w):w=e[22];let v;e[23]!==S||e[24]!==$||e[25]!==s||e[26]!==L||e[27]!==b||e[28]!==o?(v=s!==void 0&&s.length>0&&(0,t.jsx)(A,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"dlq-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(u,{children:o("function")}),(0,t.jsx)(u,{children:o("attempts")}),(0,t.jsx)(u,{children:o("last tried")}),(0,t.jsx)(u,{children:o("pool")}),(0,t.jsx)(u,{children:o("shard")}),(0,t.jsx)(u,{children:o("id")}),$&&(0,t.jsx)(u,{"aria-label":o("Actions")})]})}),(0,t.jsx)(z,{children:s.map(C=>(0,t.jsxs)(F,{"data-testid":`dlq-row-${C.id}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:C.workflow??C.functionPath}),(0,t.jsx)(p,{className:"tabular-nums",children:C.attempts??0}),(0,t.jsx)(p,{className:"text-muted-foreground tabular-nums",children:pe(C.scheduledFor)}),(0,t.jsx)(p,{className:"font-mono text-xs",children:C.pool??""}),(0,t.jsx)(p,{children:C.shardKey??""}),(0,t.jsx)(p,{className:"font-mono text-xs",children:C.id}),$&&(0,t.jsx)(p,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1.5",children:[b!==void 0&&(0,t.jsx)(ee,{"data-testid":`dlq-retry-${C.id}`,onClick:c(()=>{_(S(b(C.id)))},"onClick"),size:"sm",type:"button",variant:"outline",children:o("Retry")}),L!==void 0&&(0,t.jsx)(H,{confirmLabel:o("Drop job?"),onConfirm:c(()=>{_(S(L(C.id)))},"onConfirm"),testId:`dlq-remove-${C.id}`,children:o("Drop")})]})})]},C.id))})]})})}),e[23]=S,e[24]=$,e[25]=s,e[26]=L,e[27]=b,e[28]=o,e[29]=v):v=e[29];let D;return e[30]!==v||e[31]!==I||e[32]!==w?(D=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[I,w,v]}),e[30]=v,e[31]=I,e[32]=w,e[33]=D):D=e[33],D},"ne");function be(a,e){return(e.attempts??0)-(a.attempts??0)}c(be,"oe");var te=c(a=>{let e=(0,U.c)(8),{label:i,testId:d,value:f}=a,r;e[0]!==i?(r=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:i}),e[0]=i,e[1]=r):r=e[1];let l;e[2]!==d||e[3]!==f?(l=(0,t.jsx)("span",{className:"text-2xl font-semibold tabular-nums","data-testid":d,children:f}),e[2]=d,e[3]=f,e[4]=l):l=e[4];let o;return e[5]!==r||e[6]!==l?(o=(0,t.jsx)(A,{className:"flex-1 py-0",children:(0,t.jsxs)(T,{className:"flex flex-col gap-1 p-4",children:[r,l]})}),e[5]=r,e[6]=l,e[7]=o):o=e[7],o},"E"),ve=c(a=>{let e=(0,U.c)(25),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadStatus:d}=i,f=W(),r=M(),l=d===void 0,o;e[2]!==l?(o=["lunora-scheduler-status",l],e[2]=l,e[3]=o):o=e[3];let N;e[4]!==f||e[5]!==d?(N=c(async()=>{let j=await(d??(()=>f.schedulerStatus()))();return{...j,pools:j.pools.toSorted(xe)}},"y"),e[4]=f,e[5]=d,e[6]=N):N=e[6];let x=E(o,N),{data:n,error:s}=x,m;e[7]!==x?(m=c(()=>x.poll(),"d"),e[7]=x,e[8]=m):m=e[8],O(m,!0);let y;e[9]!==s?(y=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:s}),e[9]=s,e[10]=y):y=e[10];let k;e[11]!==n||e[12]!==r?(k=n!==void 0&&(0,t.jsxs)("div",{className:"flex gap-3","data-testid":"pools-totals",children:[(0,t.jsx)(te,{label:r("backlog"),testId:"pools-backlog",value:n.backlog}),(0,t.jsx)(te,{label:r("in flight"),testId:"pools-inflight",value:n.inFlight}),(0,t.jsx)(te,{label:r("pools"),testId:"pools-count",value:n.pools.length})]}),e[11]=n,e[12]=r,e[13]=k):k=e[13];let g;e[14]!==n?.pools.length||e[15]!==r?(g=n?.pools.length===0&&(0,t.jsx)(R,{description:r("Pools created with createWorkpool appear here once they have activity."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:r("No workpools.")}),e[14]=n?.pools.length,e[15]=r,e[16]=g):g=e[16];let J;e[17]!==n||e[18]!==r?(J=n!==void 0&&n.pools.length>0&&(0,t.jsx)(A,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"pools-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(u,{children:r("pool")}),(0,t.jsx)(u,{children:r("queued")}),(0,t.jsx)(u,{children:r("in flight")}),(0,t.jsx)(u,{children:r("max concurrency")})]})}),(0,t.jsx)(z,{children:n.pools.map(ge)})]})})}),e[17]=n,e[18]=r,e[19]=J):J=e[19];let b;return e[20]!==y||e[21]!==k||e[22]!==g||e[23]!==J?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[y,k,g,J]}),e[20]=y,e[21]=k,e[22]=g,e[23]=J,e[24]=b):b=e[24],b},"ae");function xe(a,e){return e.queued-a.queued}c(xe,"ie");function ge(a){return(0,t.jsxs)(F,{"data-testid":`pools-row-${a.name}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:a.name}),(0,t.jsx)(p,{className:"tabular-nums",children:a.queued}),(0,t.jsxs)(p,{className:"tabular-nums",children:[a.inFlight," / ",a.maxConcurrency]}),(0,t.jsx)(p,{className:"tabular-nums",children:a.maxConcurrency})]},a.name)}c(ge,"de");var Ne=["jobs","dead","pools","cron"],Ve=c(a=>{let e=(0,U.c)(41),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadCronJobs:d,scheduledCancel:f,scheduledLoad:r}=i,l=M(),[o,N]=(0,Y.useState)("jobs"),x;e[2]!==l?(x=l("Cron triggers"),e[2]=l,e[3]=x):x=e[3];let n;e[4]!==l?(n=l("Dead letter"),e[4]=l,e[5]=n):n=e[5];let s;e[6]!==l?(s=l("Scheduled jobs"),e[6]=l,e[7]=s):s=e[7];let m;e[8]!==l?(m=l("Pools"),e[8]=l,e[9]=m):m=e[9];let y;e[10]!==x||e[11]!==n||e[12]!==s||e[13]!==m?(y={cron:x,dead:n,jobs:s,pools:m},e[10]=x,e[11]=n,e[12]=s,e[13]=m,e[14]=y):y=e[14];let k=y,g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=c(w=>{N(w.currentTarget.dataset.view)},"f"),e[15]=g):g=e[15];let J=g,b;e[16]!==l?(b=l("Schedule view"),e[16]=l,e[17]=b):b=e[17];let j;e[18]!==o||e[19]!==k?(j=Ne.map(w=>(0,t.jsx)(ee,{"aria-selected":o===w,"data-testid":`schedule-view-${w}`,"data-view":w,onClick:J,role:"tab",size:"sm",type:"button",variant:o===w?"default":"outline",children:k[w]},w)),e[18]=o,e[19]=k,e[20]=j):j=e[20];let L;e[21]!==b||e[22]!==j?(L=(0,t.jsx)("div",{"aria-label":b,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:j}),e[21]=b,e[22]=j,e[23]=L):L=e[23];let q;e[24]!==f||e[25]!==r||e[26]!==o?(q=o==="jobs"&&(0,t.jsx)(de,{cancelJob:f,loadJobs:r}),e[24]=f,e[25]=r,e[26]=o,e[27]=q):q=e[27];let B;e[28]!==o?(B=o==="dead"&&(0,t.jsx)(fe,{}),e[28]=o,e[29]=B):B=e[29];let S;e[30]!==o?(S=o==="pools"&&(0,t.jsx)(ve,{}),e[30]=o,e[31]=S):S=e[31];let $;e[32]!==d||e[33]!==o?($=o==="cron"&&(0,t.jsx)(ue,{loadCronJobs:d}),e[32]=d,e[33]=o,e[34]=$):$=e[34];let I;return e[35]!==L||e[36]!==q||e[37]!==B||e[38]!==S||e[39]!==$?(I=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[L,q,B,S,$]}),e[35]=L,e[36]=q,e[37]=B,e[38]=S,e[39]=$,e[40]=I):I=e[40],I},"Ie");export{Ve as SchedulePanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as u}from"./chunk-6I42AM75.js";import"./chunk-4C4THJUD.js";import{a as y}from"./chunk-
|
|
1
|
+
import{b as u}from"./chunk-6I42AM75.js";import"./chunk-4C4THJUD.js";import{a as y}from"./chunk-GMO7IUXO.js";import"./chunk-OSJ7HV7B.js";import"./chunk-5SYMAYUA.js";import"./chunk-E26OT26O.js";import{a as N}from"./chunk-6UTZXEW3.js";import{c as v}from"./chunk-W37HRJGQ.js";import"./chunk-SDSQIQJG.js";import"./chunk-WZTY3ZYI.js";import{a as g}from"./chunk-3Y5K3IQO.js";import{a as w,b,c as S,d as c,e as s,f as o}from"./chunk-CW57Q264.js";import{a as f,e as x}from"./chunk-MD67S53Z.js";import{f as p}from"./chunk-LPINY2IJ.js";import{a as n,d as R,g as T}from"./chunk-OXFKZ4BM.js";var e=R(T(),1);var $={active:"default",failing:"destructive",idle:"secondary"},j=n(a=>a===void 0?"\u2014":`${new Date(a).toISOString().slice(0,19).replace("T"," ")} UTC`,"I"),U=n(a=>{let t=a.runs+a.suppressed;return t===0?void 0:Math.round(a.suppressed/t*100)},"$"),F=n(({initialShardKey:a=""})=>{let t=p(),{data:l,error:E,errorSource:A,liveError:I}=v(N.listReactors,{},{live:!0,shardKey:a}),C=l!==void 0,i=Array.isArray(l?.reactors)?l.reactors:[],d;C&&i.length===0?d=(0,e.jsx)(g,{description:t("No reactor is declared in this deployment. Export an onQueryChange(select, handler) from lunora/ to run server-side logic when a query's result changes."),testId:"reactors-empty",title:t("No reactors declared")}):d=(0,e.jsx)(f,{className:"overflow-hidden py-0",children:(0,e.jsx)(x,{className:"px-0",children:(0,e.jsxs)(w,{"data-testid":"reactors-table",children:[(0,e.jsx)(b,{children:(0,e.jsxs)(c,{children:[(0,e.jsx)(s,{children:t("Reactor")}),(0,e.jsx)(s,{children:t("State")}),(0,e.jsx)(s,{children:t("Ran")}),(0,e.jsx)(s,{children:t("Suppressed")}),(0,e.jsx)(s,{children:t("Errors")}),(0,e.jsx)(s,{children:t("Watches")}),(0,e.jsx)(s,{children:t("Last dispatch")})]})}),(0,e.jsx)(S,{children:i.map(r=>{let m=U(r);return(0,e.jsxs)(c,{"data-testid":`reactors-row-${r.path}`,children:[(0,e.jsx)(o,{className:"font-mono text-xs",children:r.path}),(0,e.jsx)(o,{children:(0,e.jsx)(u,{"data-testid":`reactors-state-${r.path}`,variant:$[r.state],children:r.state})}),(0,e.jsx)(o,{className:"font-mono text-xs",children:r.runs}),(0,e.jsxs)(o,{className:"font-mono text-xs text-muted-foreground",children:[r.suppressed,m===void 0?"":` (${String(m)}%)`]}),(0,e.jsx)(o,{className:"font-mono text-xs",children:r.errors===0?(0,e.jsx)("span",{className:"text-muted-foreground",children:"0"}):(0,e.jsx)("span",{className:"text-destructive",children:r.errors})}),(0,e.jsx)(o,{className:"font-mono text-xs text-muted-foreground",children:r.tables===void 0||r.tables.length===0?"\u2014":r.tables.join(", ")}),(0,e.jsx)(o,{className:"font-mono text-xs text-muted-foreground",children:j(r.lastRanAt)})]},r.path)})})]})})});let h=i.filter(r=>r.state==="failing");return(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-reactors-panel",children:[E!==null&&(0,e.jsx)(y,{error:A,testId:"reactors-error"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t("A reactor runs after a write flush, but only when the result of the query it watches actually changed \u2014 a trigger fires on a row write, a reactor fires on a result changing. Suppressed dispatches are the ones where the read re-ran and nothing had moved.")}),h.length>0&&(0,e.jsx)("div",{className:"flex flex-col gap-2","data-testid":"reactors-failing",children:h.map(r=>(0,e.jsxs)("p",{className:"text-xs text-destructive",role:"alert",children:[(0,e.jsx)("span",{className:"font-mono",children:r.path}),": ",r.lastError??t("last dispatch failed")]},r.path))}),I!==void 0&&(0,e.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"reactors-live-error",role:"alert",children:t("Live updates unavailable; showing the last reading.")}),d]})},"U");export{F as default};
|