@lunora/studio 1.0.0-alpha.83 → 1.0.0-alpha.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/standalone/{chunk-PXYWCZ7T.js → chunk-22LOWEEC.js} +1 -1
  2. package/dist/standalone/{chunk-6VAKZALJ.js → chunk-232MBXB2.js} +1 -1
  3. package/dist/standalone/{chunk-GB6LP6UJ.js → chunk-2EJADIPC.js} +1 -1
  4. package/dist/standalone/{chunk-D2RKH6JK.js → chunk-2SC3EG5Y.js} +1 -1
  5. package/dist/standalone/{chunk-UDVB4URN.js → chunk-347H2BQO.js} +1 -1
  6. package/dist/standalone/{chunk-A3KUNMU6.js → chunk-4I2TBTZS.js} +1 -1
  7. package/dist/standalone/{chunk-B2H5DK55.js → chunk-52OYJHM7.js} +1 -1
  8. package/dist/standalone/{chunk-YTA2HGRD.js → chunk-5YADKLAQ.js} +1 -1
  9. package/dist/standalone/{chunk-C7EOC2WS.js → chunk-6IEBRNDW.js} +1 -1
  10. package/dist/standalone/{chunk-HEB6GQQ6.js → chunk-7AG3T4DK.js} +2 -2
  11. package/dist/standalone/{chunk-53WEPGUD.js → chunk-AHVDZWB3.js} +1 -1
  12. package/dist/standalone/{chunk-CU55Y5TV.js → chunk-AQKXMWNF.js} +1 -1
  13. package/dist/standalone/{chunk-LLF5KWDZ.js → chunk-BAAU4OTI.js} +1 -1
  14. package/dist/standalone/{chunk-Y7A5NCXT.js → chunk-D3FRQZ4X.js} +1 -1
  15. package/dist/standalone/{chunk-T242WITF.js → chunk-D67BVBQW.js} +1 -1
  16. package/dist/standalone/{chunk-WQVVA5NB.js → chunk-EDOMDMVI.js} +1 -1
  17. package/dist/standalone/{chunk-GM67EQJU.js → chunk-ENBTOX7N.js} +1 -1
  18. package/dist/standalone/{chunk-DOZAODYC.js → chunk-ESKVOZLC.js} +1 -1
  19. package/dist/standalone/{chunk-KAPSM6AI.js → chunk-ETZYJL7Z.js} +1 -1
  20. package/dist/standalone/{chunk-PD4LANXJ.js → chunk-FUBR2PAD.js} +1 -1
  21. package/dist/standalone/{chunk-GWQIPIYA.js → chunk-HJR42BJY.js} +1 -1
  22. package/dist/standalone/{chunk-SV52HB7D.js → chunk-JAT5ZBQK.js} +1 -1
  23. package/dist/standalone/{chunk-CGLS2ILT.js → chunk-JE3WK77V.js} +1 -1
  24. package/dist/standalone/{chunk-6QP5N57V.js → chunk-KNHWIHC7.js} +1 -1
  25. package/dist/standalone/{chunk-OE465DVY.js → chunk-LVJ5IHEU.js} +1 -1
  26. package/dist/standalone/{chunk-TQXZ7LG4.js → chunk-MBVSXVTV.js} +1 -1
  27. package/dist/standalone/{chunk-7YKWP4QK.js → chunk-MDHUWMFD.js} +1 -1
  28. package/dist/standalone/{chunk-WZ3B3MEV.js → chunk-MLULN4R2.js} +1 -1
  29. package/dist/standalone/{chunk-Y5Y7DHFW.js → chunk-MN64D74P.js} +1 -1
  30. package/dist/standalone/{chunk-ZHBIKP5G.js → chunk-MUGKOGZG.js} +1 -1
  31. package/dist/standalone/{chunk-HOR3JLUY.js → chunk-NPKNFZUW.js} +1 -1
  32. package/dist/standalone/{chunk-KXSSTTEY.js → chunk-OLM62NLS.js} +1 -1
  33. package/dist/standalone/{chunk-Q7O6B7WC.js → chunk-OOL3FV6A.js} +1 -1
  34. package/dist/standalone/{chunk-DGBJE7YF.js → chunk-OV63HVE4.js} +1 -1
  35. package/dist/standalone/{chunk-SDQBPFLO.js → chunk-PWTURL56.js} +1 -1
  36. package/dist/standalone/{chunk-GN567L2T.js → chunk-QFJRZR4U.js} +1 -1
  37. package/dist/standalone/{chunk-WJGOI3FZ.js → chunk-QI25LTPH.js} +1 -1
  38. package/dist/standalone/{chunk-TBRZQICB.js → chunk-QNRAMF4X.js} +1 -1
  39. package/dist/standalone/{chunk-AADILRJW.js → chunk-QNUWWC3N.js} +12 -12
  40. package/dist/standalone/{chunk-UETNCBWU.js → chunk-QS4IFAFJ.js} +1 -1
  41. package/dist/standalone/{chunk-ZK3XKFCI.js → chunk-QSFKPGK4.js} +1 -1
  42. package/dist/standalone/{chunk-GWHM4C4N.js → chunk-QZ6TCNWR.js} +1 -1
  43. package/dist/standalone/{chunk-VTLYN3CX.js → chunk-RC3H4OP3.js} +1 -1
  44. package/dist/standalone/{chunk-7ZUQE3KU.js → chunk-RFBU5RZI.js} +1 -1
  45. package/dist/standalone/{chunk-7L7FXGJU.js → chunk-S67SBGB3.js} +1 -1
  46. package/dist/standalone/{chunk-VC5SSRUP.js → chunk-SHD2IWQI.js} +1 -1
  47. package/dist/standalone/{chunk-NRCXRCJX.js → chunk-SKFZXESP.js} +1 -1
  48. package/dist/standalone/{chunk-KSRP7GZV.js → chunk-SPT3KPV7.js} +1 -1
  49. package/dist/standalone/{chunk-74DN6HIE.js → chunk-TIR6CWHO.js} +1 -1
  50. package/dist/standalone/{chunk-Q7QTRX2E.js → chunk-TO45V3L6.js} +1 -1
  51. package/dist/standalone/{chunk-HJD2YUQS.js → chunk-U44CWN7H.js} +1 -1
  52. package/dist/standalone/{chunk-VCXH5V3Z.js → chunk-U5IIRHZ6.js} +1 -1
  53. package/dist/standalone/{chunk-EN2QAEO4.js → chunk-UBR4KB6K.js} +1 -1
  54. package/dist/standalone/{chunk-ZI5ZVNIN.js → chunk-UOQ24BAY.js} +1 -1
  55. package/dist/standalone/{chunk-BDJCCVB6.js → chunk-VKEJTZY7.js} +1 -1
  56. package/dist/standalone/{chunk-RNL6BSFM.js → chunk-VORDESEQ.js} +1 -1
  57. package/dist/standalone/{chunk-XDAT7LHC.js → chunk-YGKR536O.js} +1 -1
  58. package/dist/standalone/{chunk-CU6SCYQ7.js → chunk-YNBIW2GN.js} +1 -1
  59. package/dist/standalone/{chunk-WDG4WFUV.js → chunk-YSMJN36P.js} +1 -1
  60. package/dist/standalone/{chunk-5SQRE3VR.js → chunk-ZOX6X2DL.js} +1 -1
  61. package/dist/standalone/studio.js +1 -1
  62. package/package.json +6 -6
@@ -1 +1 @@
1
- import{b as de,c as ce}from"./chunk-KUVMORDQ.js";import{a as ie}from"./chunk-QWGT25SE.js";import{a as le}from"./chunk-CTNB2KIA.js";import{a as se}from"./chunk-X665E2HU.js";import{b as ae}from"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{a as ne}from"./chunk-LFKCLLPT.js";import{R as Z}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as Y}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as oe}from"./chunk-53WEPGUD.js";import"./chunk-XXQUMVWH.js";import"./chunk-RNL6BSFM.js";import"./chunk-QLQADHFE.js";import{a as re}from"./chunk-ERMTJYQF.js";import{c as te}from"./chunk-XDAT7LHC.js";import"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{a as X}from"./chunk-XQCVZAGU.js";import{d as z,q as ee}from"./chunk-OG4N2XHD.js";import"./chunk-AADILRJW.js";import{a as M,e as Q,f as he,g as fe,h as pe,j as V}from"./chunk-3XIESWL4.js";var H=Q(fe(),1),K=Q(he(),1);var a=Q(pe(),1);var me=M(o=>Math.min(100,Math.max(0,o)),"V"),ge=M((o,e)=>{if(!Number.isFinite(e)||e<=0)return{leftPercent:0,widthPercent:100};let t=me(o.offsetMs/e*100),s=o.durationMs/e*100,r=Math.max(.5,Math.min(me(s),100-t));return{leftPercent:t,widthPercent:r}},"he"),xe=M((o,e)=>{let t=e.trim().toLowerCase();return t===""?[...o]:o.filter(s=>s.rootName.toLowerCase().includes(t)||s.functionPath.toLowerCase().includes(t)||s.traceId.toLowerCase().includes(t))},"fe"),G=M(o=>Number.isFinite(o)?o>0&&o<1?`${o.toFixed(2)}ms`:`${String(Math.round(o))}ms`:"\u2014","U"),be=14,we=M(o=>Array.isArray(o?.traces)?o.traces:[],"ge"),Ne=M(o=>{let e=(0,H.c)(50),{span:t,traceDurationMs:s}=o,r=z(),n;e[0]!==t||e[1]!==s?(n=ge(t,s),e[0]=t,e[1]=s,e[2]=n):n=e[2];let{leftPercent:P,widthPercent:x}=n,L;e[3]!==t.attributes?(L=ie(t.attributes),e[3]=t.attributes,e[4]=L):L=e[4];let k=L,C=t.depth*be,y;e[5]!==C?(y={paddingLeft:C},e[5]=C,e[6]=y):y=e[6];let b=y,c=`${String(P)}%`,w=`${String(x)}%`,p;e[7]!==c||e[8]!==w?(p={left:c,width:w},e[7]=c,e[8]=w,e[9]=p):p=e[9];let l=p,f=t.depth,i;e[10]!==t.ok||e[11]!==r?(i=t.ok?null:(0,a.jsx)("span",{"aria-label":r("Errored span"),className:"mr-1 text-destructive","data-testid":"tr-span-error",role:"img",children:"\u25CF"}),e[10]=t.ok,e[11]=r,e[12]=i):i=e[12];let v;e[13]!==b||e[14]!==t.name||e[15]!==i?(v=(0,a.jsxs)("span",{className:"w-56 shrink-0 truncate",role:"gridcell",style:b,title:t.name,children:[i,t.name]}),e[13]=b,e[14]=t.name,e[15]=i,e[16]=v):v=e[16];let d;e[17]!==t.durationMs||e[18]!==t.offsetMs||e[19]!==r?(d=r("starts {offset} in, runs {duration}",{duration:G(t.durationMs),offset:G(t.offsetMs)}),e[17]=t.durationMs,e[18]=t.offsetMs,e[19]=r,e[20]=d):d=e[20];let N=t.ok?"bg-primary/70":"bg-destructive",m;e[21]!==N?(m=V("absolute inset-y-0 rounded-sm",N),e[21]=N,e[22]=m):m=e[22];let u;e[23]!==l||e[24]!==P||e[25]!==m||e[26]!==x?(u=(0,a.jsx)("span",{className:m,"data-left":P,"data-testid":"tr-span-bar","data-width":x,style:l}),e[23]=l,e[24]=P,e[25]=m,e[26]=x,e[27]=u):u=e[27];let h;e[28]!==d||e[29]!==u?(h=(0,a.jsx)("span",{"aria-label":d,className:"relative h-3 flex-1 overflow-hidden rounded-sm bg-muted",role:"gridcell",children:u}),e[28]=d,e[29]=u,e[30]=h):h=e[30];let g;e[31]!==t.durationMs?(g=G(t.durationMs),e[31]=t.durationMs,e[32]=g):g=e[32];let I;e[33]!==g?(I=(0,a.jsx)("span",{className:"w-16 shrink-0 text-right tabular-nums text-muted-foreground",role:"gridcell",children:g}),e[33]=g,e[34]=I):I=e[34];let S;e[35]!==t.error?(S=t.error===void 0?null:(0,a.jsx)("span",{className:"text-destructive","data-testid":"tr-span-error-message",title:t.error.message,children:`${t.error.type}: ${t.error.message}`}),e[35]=t.error,e[36]=S):S=e[36];let T;e[37]!==S?(T=(0,a.jsx)("span",{className:"w-64 shrink-0 truncate text-muted-foreground",role:"gridcell",children:S}),e[37]=S,e[38]=T):T=e[38];let F;e[39]!==k?(F=k===""?null:(0,a.jsx)("span",{"data-testid":"tr-span-attributes",title:k,children:k}),e[39]=k,e[40]=F):F=e[40];let $;e[41]!==F?($=(0,a.jsx)("span",{className:"w-64 shrink-0 truncate text-muted-foreground",role:"gridcell",children:F}),e[41]=F,e[42]=$):$=e[42];let _;return e[43]!==t.depth||e[44]!==v||e[45]!==h||e[46]!==I||e[47]!==T||e[48]!==$?(_=(0,a.jsxs)("div",{className:"flex items-center gap-2 border-b border-border px-3 py-1.5 font-mono text-xs last:border-b-0 hover:bg-muted/50","data-depth":f,"data-testid":"tr-span-row",role:"row",children:[v,h,I,T,$]}),e[43]=t.depth,e[44]=v,e[45]=h,e[46]=I,e[47]=T,e[48]=$,e[49]=_):_=e[49],_},"xe"),Me=M(o=>{let e=(0,H.c)(50),{expanded:t,onToggle:s,trace:r}=o,n=z(),P;e[0]!==s||e[1]!==r.traceId?(P=M(()=>{s(r.traceId)},"S"),e[0]=s,e[1]=r.traceId,e[2]=P):P=e[2];let x=P,L=`tr-row-${r.traceId}`,k=`tr-waterfall-${r.traceId}`,C=`tr-toggle-${r.traceId}`,y=t?"\u25BE":"\u25B8",b;e[3]!==y?(b=(0,a.jsx)("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-xs text-muted-foreground",children:y}),e[3]=y,e[4]=b):b=e[4];let c;e[5]!==r.rootName?(c=(0,a.jsx)("span",{className:"w-56 shrink-0 truncate text-sm font-medium",title:r.rootName,children:r.rootName}),e[5]=r.rootName,e[6]=c):c=e[6];let w;e[7]!==r.functionPath?(w=(0,a.jsx)("span",{className:"w-48 shrink-0 truncate font-mono text-xs text-muted-foreground",title:r.functionPath,children:r.functionPath}),e[7]=r.functionPath,e[8]=w):w=e[8];let p;e[9]!==r.durationMs?(p=G(r.durationMs),e[9]=r.durationMs,e[10]=p):p=e[10];let l;e[11]!==p?(l=(0,a.jsx)("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:p}),e[11]=p,e[12]=l):l=e[12];let f;e[13]!==n||e[14]!==r.spans.length?(f=n("{count} spans",{count:r.spans.length}),e[13]=n,e[14]=r.spans.length,e[15]=f):f=e[15];let i;e[16]!==f?(i=(0,a.jsx)("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:f}),e[16]=f,e[17]=i):i=e[17];let v=r.ok?"secondary":"destructive",d;e[18]!==n||e[19]!==r.ok?(d=r.ok?n("ok"):n("error"),e[18]=n,e[19]=r.ok,e[20]=d):d=e[20];let N;e[21]!==v||e[22]!==d?(N=(0,a.jsx)("span",{className:"shrink-0",children:(0,a.jsx)(Y,{variant:v,children:d})}),e[21]=v,e[22]=d,e[23]=N):N=e[23];let m;e[24]!==r.startTs?(m=ee(r.startTs),e[24]=r.startTs,e[25]=m):m=e[25];let u;e[26]!==m?(u=(0,a.jsx)("span",{className:"flex-1 truncate text-right font-mono text-xs tabular-nums text-muted-foreground",children:m}),e[26]=m,e[27]=u):u=e[27];let h;e[28]!==t||e[29]!==x||e[30]!==l||e[31]!==i||e[32]!==N||e[33]!==u||e[34]!==k||e[35]!==C||e[36]!==b||e[37]!==c||e[38]!==w?(h=(0,a.jsxs)("button",{"aria-controls":k,"aria-expanded":t,className:"flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-muted/50","data-testid":C,onClick:x,type:"button",children:[b,c,w,l,i,N,u]}),e[28]=t,e[29]=x,e[30]=l,e[31]=i,e[32]=N,e[33]=u,e[34]=k,e[35]=C,e[36]=b,e[37]=c,e[38]=w,e[39]=h):h=e[39];let g;e[40]!==t||e[41]!==n||e[42]!==r.durationMs||e[43]!==r.spans||e[44]!==r.traceId?(g=t&&(0,a.jsx)("div",{"aria-label":n("Trace waterfall"),className:"bg-muted/20","data-testid":`tr-waterfall-${r.traceId}`,id:`tr-waterfall-${r.traceId}`,role:"grid",children:r.spans.map(S=>(0,a.jsx)(Ne,{span:S,traceDurationMs:r.durationMs},S.spanId))}),e[40]=t,e[41]=n,e[42]=r.durationMs,e[43]=r.spans,e[44]=r.traceId,e[45]=g):g=e[45];let I;return e[46]!==h||e[47]!==g||e[48]!==L?(I=(0,a.jsxs)("div",{className:"border-b border-border last:border-b-0","data-testid":L,children:[h,g]}),e[46]=h,e[47]=g,e[48]=L,e[49]=I):I=e[49],I},"be"),Be=M(o=>{let e=(0,H.c)(44),{initialShardKey:t}=o,s=z(),[r]=(0,K.useState)(de),[n,P]=(0,K.useState)(r?.shardKey!==void 0&&r.shardKey!==""?r.shardKey:t??""),[x,L]=(0,K.useState)(r?.traceId??""),[k,C]=(0,K.useState)(ve),y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y=[],e[0]=y):y=e[0],(0,K.useEffect)(ke,y);let b;e[1]!==n?(b=n.trim(),e[1]=n,e[2]=b):b=e[2];let c=ne(b,400),w;e[3]===Symbol.for("react.memo_cache_sentinel")?(w={},e[3]=w):w=e[3];let p;e[4]!==c?(p={live:!0,shardKey:c},e[4]=c,e[5]=p):p=e[5];let{data:l,error:f,errorSource:i,isLoading:v,liveError:d}=te(re.getTraces,w,p),N,m;e[6]!==l||e[7]!==c?(N=M(()=>{l!==void 0&&ae(c)},"N"),m=[l,c],e[6]=l,e[7]=c,e[8]=N,e[9]=m):(N=e[8],m=e[9]),(0,K.useEffect)(N,m);let u;if(e[10]!==l||e[11]!==f||e[12]!==i||e[13]!==k||e[14]!==v||e[15]!==d||e[16]!==x||e[17]!==n||e[18]!==s){let h=we(l),g=l?.total??h.length,I=g>h.length,S=xe(h,x),T;e[20]===Symbol.for("react.memo_cache_sentinel")?(T=M(E=>{L(E.target.value)},"$"),e[20]=T):T=e[20];let F=T,$;e[21]===Symbol.for("react.memo_cache_sentinel")?($=M(E=>{C(ue=>{let q=new Set(ue);return q.has(E)?q.delete(E):q.add(E),q})},"T"),e[21]=$):$=e[21];let _=$,J=f===null&&S.length===0&&!v,j;e[22]!==n?(j=(0,a.jsx)(se,{onChange:P,testId:"tr-shard-input",value:n}),e[22]=n,e[23]=j):j=e[23];let A;e[24]!==s?(A=s("Search traces"),e[24]=s,e[25]=A):A=e[25];let D;e[26]!==s?(D=s("search trace or function"),e[26]=s,e[27]=D):D=e[27];let B;e[28]!==x||e[29]!==A||e[30]!==D?(B=(0,a.jsx)(Z,{"aria-label":A,className:"h-8 w-56","data-testid":"tr-search",onChange:F,placeholder:D,value:x}),e[28]=x,e[29]=A,e[30]=D,e[31]=B):B=e[31];let O;e[32]!==d?(O=(0,a.jsx)(le,{message:d,prefix:"tr"}),e[32]=d,e[33]=O):O=e[33];let R;e[34]!==j||e[35]!==B||e[36]!==O?(R=(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[j,B,O]}),e[34]=j,e[35]=B,e[36]=O,e[37]=R):R=e[37];let U;e[38]!==f||e[39]!==i?(U=f!==null&&(0,a.jsx)(oe,{error:i,testId:"tr-error"}),e[38]=f,e[39]=i,e[40]=U):U=e[40];let W;e[41]!==J||e[42]!==s?(W=J&&(0,a.jsx)(X,{description:s("Traces recorded with ctx.trace show up here as your app handles traffic. The span buffer resets when the shard hibernates."),icon:(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M4 6h10M7 12h13M10 18h7"})}),testId:"tr-empty",title:s("No traces")}),e[41]=J,e[42]=s,e[43]=W):W=e[43],u=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[R,U,W,f===null&&I&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"tr-truncated",children:s("Showing the {shown} most recent of {total} traces in the buffer.",{shown:h.length,total:g})}),f===null&&S.length>0&&(0,a.jsx)("div",{"aria-label":s("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:S.map(E=>(0,a.jsx)(Me,{expanded:k.has(E.traceId),onToggle:_,trace:E},E.traceId))})]}),e[10]=l,e[11]=f,e[12]=i,e[13]=k,e[14]=v,e[15]=d,e[16]=x,e[17]=n,e[18]=s,e[19]=u}else u=e[19];return u},"Be");function ve(){return new Set}M(ve,"we");function ke(){ce()}M(ke,"Ne");export{Be as TracesPanel};
1
+ import{b as de,c as ce}from"./chunk-KUVMORDQ.js";import{a as ie}from"./chunk-QWGT25SE.js";import{a as le}from"./chunk-CTNB2KIA.js";import{a as se}from"./chunk-X665E2HU.js";import{b as ae}from"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{a as ne}from"./chunk-LFKCLLPT.js";import{R as Z}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as Y}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as oe}from"./chunk-AHVDZWB3.js";import"./chunk-XXQUMVWH.js";import"./chunk-VORDESEQ.js";import"./chunk-QLQADHFE.js";import{a as re}from"./chunk-ERMTJYQF.js";import{c as te}from"./chunk-YGKR536O.js";import"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as X}from"./chunk-XQCVZAGU.js";import{d as z,q as ee}from"./chunk-OG4N2XHD.js";import"./chunk-QNUWWC3N.js";import{a as M,e as Q,f as he,g as fe,h as pe,j as V}from"./chunk-3XIESWL4.js";var H=Q(fe(),1),K=Q(he(),1);var a=Q(pe(),1);var me=M(o=>Math.min(100,Math.max(0,o)),"V"),ge=M((o,e)=>{if(!Number.isFinite(e)||e<=0)return{leftPercent:0,widthPercent:100};let t=me(o.offsetMs/e*100),s=o.durationMs/e*100,r=Math.max(.5,Math.min(me(s),100-t));return{leftPercent:t,widthPercent:r}},"he"),xe=M((o,e)=>{let t=e.trim().toLowerCase();return t===""?[...o]:o.filter(s=>s.rootName.toLowerCase().includes(t)||s.functionPath.toLowerCase().includes(t)||s.traceId.toLowerCase().includes(t))},"fe"),G=M(o=>Number.isFinite(o)?o>0&&o<1?`${o.toFixed(2)}ms`:`${String(Math.round(o))}ms`:"\u2014","U"),be=14,we=M(o=>Array.isArray(o?.traces)?o.traces:[],"ge"),Ne=M(o=>{let e=(0,H.c)(50),{span:t,traceDurationMs:s}=o,r=z(),n;e[0]!==t||e[1]!==s?(n=ge(t,s),e[0]=t,e[1]=s,e[2]=n):n=e[2];let{leftPercent:P,widthPercent:x}=n,L;e[3]!==t.attributes?(L=ie(t.attributes),e[3]=t.attributes,e[4]=L):L=e[4];let k=L,C=t.depth*be,y;e[5]!==C?(y={paddingLeft:C},e[5]=C,e[6]=y):y=e[6];let b=y,c=`${String(P)}%`,w=`${String(x)}%`,p;e[7]!==c||e[8]!==w?(p={left:c,width:w},e[7]=c,e[8]=w,e[9]=p):p=e[9];let l=p,f=t.depth,i;e[10]!==t.ok||e[11]!==r?(i=t.ok?null:(0,a.jsx)("span",{"aria-label":r("Errored span"),className:"mr-1 text-destructive","data-testid":"tr-span-error",role:"img",children:"\u25CF"}),e[10]=t.ok,e[11]=r,e[12]=i):i=e[12];let v;e[13]!==b||e[14]!==t.name||e[15]!==i?(v=(0,a.jsxs)("span",{className:"w-56 shrink-0 truncate",role:"gridcell",style:b,title:t.name,children:[i,t.name]}),e[13]=b,e[14]=t.name,e[15]=i,e[16]=v):v=e[16];let d;e[17]!==t.durationMs||e[18]!==t.offsetMs||e[19]!==r?(d=r("starts {offset} in, runs {duration}",{duration:G(t.durationMs),offset:G(t.offsetMs)}),e[17]=t.durationMs,e[18]=t.offsetMs,e[19]=r,e[20]=d):d=e[20];let N=t.ok?"bg-primary/70":"bg-destructive",m;e[21]!==N?(m=V("absolute inset-y-0 rounded-sm",N),e[21]=N,e[22]=m):m=e[22];let u;e[23]!==l||e[24]!==P||e[25]!==m||e[26]!==x?(u=(0,a.jsx)("span",{className:m,"data-left":P,"data-testid":"tr-span-bar","data-width":x,style:l}),e[23]=l,e[24]=P,e[25]=m,e[26]=x,e[27]=u):u=e[27];let h;e[28]!==d||e[29]!==u?(h=(0,a.jsx)("span",{"aria-label":d,className:"relative h-3 flex-1 overflow-hidden rounded-sm bg-muted",role:"gridcell",children:u}),e[28]=d,e[29]=u,e[30]=h):h=e[30];let g;e[31]!==t.durationMs?(g=G(t.durationMs),e[31]=t.durationMs,e[32]=g):g=e[32];let I;e[33]!==g?(I=(0,a.jsx)("span",{className:"w-16 shrink-0 text-right tabular-nums text-muted-foreground",role:"gridcell",children:g}),e[33]=g,e[34]=I):I=e[34];let S;e[35]!==t.error?(S=t.error===void 0?null:(0,a.jsx)("span",{className:"text-destructive","data-testid":"tr-span-error-message",title:t.error.message,children:`${t.error.type}: ${t.error.message}`}),e[35]=t.error,e[36]=S):S=e[36];let T;e[37]!==S?(T=(0,a.jsx)("span",{className:"w-64 shrink-0 truncate text-muted-foreground",role:"gridcell",children:S}),e[37]=S,e[38]=T):T=e[38];let F;e[39]!==k?(F=k===""?null:(0,a.jsx)("span",{"data-testid":"tr-span-attributes",title:k,children:k}),e[39]=k,e[40]=F):F=e[40];let $;e[41]!==F?($=(0,a.jsx)("span",{className:"w-64 shrink-0 truncate text-muted-foreground",role:"gridcell",children:F}),e[41]=F,e[42]=$):$=e[42];let _;return e[43]!==t.depth||e[44]!==v||e[45]!==h||e[46]!==I||e[47]!==T||e[48]!==$?(_=(0,a.jsxs)("div",{className:"flex items-center gap-2 border-b border-border px-3 py-1.5 font-mono text-xs last:border-b-0 hover:bg-muted/50","data-depth":f,"data-testid":"tr-span-row",role:"row",children:[v,h,I,T,$]}),e[43]=t.depth,e[44]=v,e[45]=h,e[46]=I,e[47]=T,e[48]=$,e[49]=_):_=e[49],_},"xe"),Me=M(o=>{let e=(0,H.c)(50),{expanded:t,onToggle:s,trace:r}=o,n=z(),P;e[0]!==s||e[1]!==r.traceId?(P=M(()=>{s(r.traceId)},"S"),e[0]=s,e[1]=r.traceId,e[2]=P):P=e[2];let x=P,L=`tr-row-${r.traceId}`,k=`tr-waterfall-${r.traceId}`,C=`tr-toggle-${r.traceId}`,y=t?"\u25BE":"\u25B8",b;e[3]!==y?(b=(0,a.jsx)("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-xs text-muted-foreground",children:y}),e[3]=y,e[4]=b):b=e[4];let c;e[5]!==r.rootName?(c=(0,a.jsx)("span",{className:"w-56 shrink-0 truncate text-sm font-medium",title:r.rootName,children:r.rootName}),e[5]=r.rootName,e[6]=c):c=e[6];let w;e[7]!==r.functionPath?(w=(0,a.jsx)("span",{className:"w-48 shrink-0 truncate font-mono text-xs text-muted-foreground",title:r.functionPath,children:r.functionPath}),e[7]=r.functionPath,e[8]=w):w=e[8];let p;e[9]!==r.durationMs?(p=G(r.durationMs),e[9]=r.durationMs,e[10]=p):p=e[10];let l;e[11]!==p?(l=(0,a.jsx)("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:p}),e[11]=p,e[12]=l):l=e[12];let f;e[13]!==n||e[14]!==r.spans.length?(f=n("{count} spans",{count:r.spans.length}),e[13]=n,e[14]=r.spans.length,e[15]=f):f=e[15];let i;e[16]!==f?(i=(0,a.jsx)("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:f}),e[16]=f,e[17]=i):i=e[17];let v=r.ok?"secondary":"destructive",d;e[18]!==n||e[19]!==r.ok?(d=r.ok?n("ok"):n("error"),e[18]=n,e[19]=r.ok,e[20]=d):d=e[20];let N;e[21]!==v||e[22]!==d?(N=(0,a.jsx)("span",{className:"shrink-0",children:(0,a.jsx)(Y,{variant:v,children:d})}),e[21]=v,e[22]=d,e[23]=N):N=e[23];let m;e[24]!==r.startTs?(m=ee(r.startTs),e[24]=r.startTs,e[25]=m):m=e[25];let u;e[26]!==m?(u=(0,a.jsx)("span",{className:"flex-1 truncate text-right font-mono text-xs tabular-nums text-muted-foreground",children:m}),e[26]=m,e[27]=u):u=e[27];let h;e[28]!==t||e[29]!==x||e[30]!==l||e[31]!==i||e[32]!==N||e[33]!==u||e[34]!==k||e[35]!==C||e[36]!==b||e[37]!==c||e[38]!==w?(h=(0,a.jsxs)("button",{"aria-controls":k,"aria-expanded":t,className:"flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-muted/50","data-testid":C,onClick:x,type:"button",children:[b,c,w,l,i,N,u]}),e[28]=t,e[29]=x,e[30]=l,e[31]=i,e[32]=N,e[33]=u,e[34]=k,e[35]=C,e[36]=b,e[37]=c,e[38]=w,e[39]=h):h=e[39];let g;e[40]!==t||e[41]!==n||e[42]!==r.durationMs||e[43]!==r.spans||e[44]!==r.traceId?(g=t&&(0,a.jsx)("div",{"aria-label":n("Trace waterfall"),className:"bg-muted/20","data-testid":`tr-waterfall-${r.traceId}`,id:`tr-waterfall-${r.traceId}`,role:"grid",children:r.spans.map(S=>(0,a.jsx)(Ne,{span:S,traceDurationMs:r.durationMs},S.spanId))}),e[40]=t,e[41]=n,e[42]=r.durationMs,e[43]=r.spans,e[44]=r.traceId,e[45]=g):g=e[45];let I;return e[46]!==h||e[47]!==g||e[48]!==L?(I=(0,a.jsxs)("div",{className:"border-b border-border last:border-b-0","data-testid":L,children:[h,g]}),e[46]=h,e[47]=g,e[48]=L,e[49]=I):I=e[49],I},"be"),Be=M(o=>{let e=(0,H.c)(44),{initialShardKey:t}=o,s=z(),[r]=(0,K.useState)(de),[n,P]=(0,K.useState)(r?.shardKey!==void 0&&r.shardKey!==""?r.shardKey:t??""),[x,L]=(0,K.useState)(r?.traceId??""),[k,C]=(0,K.useState)(ve),y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y=[],e[0]=y):y=e[0],(0,K.useEffect)(ke,y);let b;e[1]!==n?(b=n.trim(),e[1]=n,e[2]=b):b=e[2];let c=ne(b,400),w;e[3]===Symbol.for("react.memo_cache_sentinel")?(w={},e[3]=w):w=e[3];let p;e[4]!==c?(p={live:!0,shardKey:c},e[4]=c,e[5]=p):p=e[5];let{data:l,error:f,errorSource:i,isLoading:v,liveError:d}=te(re.getTraces,w,p),N,m;e[6]!==l||e[7]!==c?(N=M(()=>{l!==void 0&&ae(c)},"N"),m=[l,c],e[6]=l,e[7]=c,e[8]=N,e[9]=m):(N=e[8],m=e[9]),(0,K.useEffect)(N,m);let u;if(e[10]!==l||e[11]!==f||e[12]!==i||e[13]!==k||e[14]!==v||e[15]!==d||e[16]!==x||e[17]!==n||e[18]!==s){let h=we(l),g=l?.total??h.length,I=g>h.length,S=xe(h,x),T;e[20]===Symbol.for("react.memo_cache_sentinel")?(T=M(E=>{L(E.target.value)},"$"),e[20]=T):T=e[20];let F=T,$;e[21]===Symbol.for("react.memo_cache_sentinel")?($=M(E=>{C(ue=>{let q=new Set(ue);return q.has(E)?q.delete(E):q.add(E),q})},"T"),e[21]=$):$=e[21];let _=$,J=f===null&&S.length===0&&!v,j;e[22]!==n?(j=(0,a.jsx)(se,{onChange:P,testId:"tr-shard-input",value:n}),e[22]=n,e[23]=j):j=e[23];let A;e[24]!==s?(A=s("Search traces"),e[24]=s,e[25]=A):A=e[25];let D;e[26]!==s?(D=s("search trace or function"),e[26]=s,e[27]=D):D=e[27];let B;e[28]!==x||e[29]!==A||e[30]!==D?(B=(0,a.jsx)(Z,{"aria-label":A,className:"h-8 w-56","data-testid":"tr-search",onChange:F,placeholder:D,value:x}),e[28]=x,e[29]=A,e[30]=D,e[31]=B):B=e[31];let O;e[32]!==d?(O=(0,a.jsx)(le,{message:d,prefix:"tr"}),e[32]=d,e[33]=O):O=e[33];let R;e[34]!==j||e[35]!==B||e[36]!==O?(R=(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[j,B,O]}),e[34]=j,e[35]=B,e[36]=O,e[37]=R):R=e[37];let U;e[38]!==f||e[39]!==i?(U=f!==null&&(0,a.jsx)(oe,{error:i,testId:"tr-error"}),e[38]=f,e[39]=i,e[40]=U):U=e[40];let W;e[41]!==J||e[42]!==s?(W=J&&(0,a.jsx)(X,{description:s("Traces recorded with ctx.trace show up here as your app handles traffic. The span buffer resets when the shard hibernates."),icon:(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M4 6h10M7 12h13M10 18h7"})}),testId:"tr-empty",title:s("No traces")}),e[41]=J,e[42]=s,e[43]=W):W=e[43],u=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[R,U,W,f===null&&I&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"tr-truncated",children:s("Showing the {shown} most recent of {total} traces in the buffer.",{shown:h.length,total:g})}),f===null&&S.length>0&&(0,a.jsx)("div",{"aria-label":s("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:S.map(E=>(0,a.jsx)(Me,{expanded:k.has(E.traceId),onToggle:_,trace:E},E.traceId))})]}),e[10]=l,e[11]=f,e[12]=i,e[13]=k,e[14]=v,e[15]=d,e[16]=x,e[17]=n,e[18]=s,e[19]=u}else u=e[19];return u},"Be");function ve(){return new Set}M(ve,"we");function ke(){ce()}M(ke,"Ne");export{Be as TracesPanel};
@@ -1 +1 @@
1
- import{b as l}from"./chunk-XDAT7LHC.js";import{f as c}from"./chunk-EN2QAEO4.js";import{a as r,e as f,g}from"./chunk-3XIESWL4.js";var m=f(g(),1);var p={capabilities:{accounts:!0,admin:!0,organization:!1,passkey:!1,twoFactor:!1},emailAndPassword:!1,organization:{enabled:!1,roles:!1,teams:!1},plugins:[],rateLimit:{enabled:!1},session:{},socialProviders:[],userFields:[]},y=r(()=>{let o=(0,m.c)(6),t=c(),a;o[0]===Symbol.for("react.memo_cache_sentinel")?(a=["lunora-auth-config"],o[0]=a):a=o[0];let e;o[1]!==t?(e=r(()=>t.getAuthConfig(),"o"),o[1]=t,o[2]=e):e=o[2];let{data:u,isLoading:d}=l(a,e),i=u??p,n=!d,s;return o[3]!==i||o[4]!==n?(s={config:i,ready:n},o[3]=i,o[4]=n,o[5]=s):s=o[5],s},"A");export{y as a};
1
+ import{b as l}from"./chunk-YGKR536O.js";import{f as c}from"./chunk-UBR4KB6K.js";import{a as r,e as f,g}from"./chunk-3XIESWL4.js";var m=f(g(),1);var p={capabilities:{accounts:!0,admin:!0,organization:!1,passkey:!1,twoFactor:!1},emailAndPassword:!1,organization:{enabled:!1,roles:!1,teams:!1},plugins:[],rateLimit:{enabled:!1},session:{},socialProviders:[],userFields:[]},y=r(()=>{let o=(0,m.c)(6),t=c(),a;o[0]===Symbol.for("react.memo_cache_sentinel")?(a=["lunora-auth-config"],o[0]=a):a=o[0];let e;o[1]!==t?(e=r(()=>t.getAuthConfig(),"o"),o[1]=t,o[2]=e):e=o[2];let{data:u,isLoading:d}=l(a,e),i=u??p,n=!d,s;return o[3]!==i||o[4]!==n?(s={config:i,ready:n},o[3]=i,o[4]=n,o[5]=s):s=o[5],s},"A");export{y as a};
@@ -1 +1 @@
1
- import{a as et}from"./chunk-YTA2HGRD.js";import"./chunk-GMR677FL.js";import"./chunk-7H7LZRLP.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import{a as Re}from"./chunk-5Y3QLNWX.js";import{a as Ze}from"./chunk-CTNB2KIA.js";import"./chunk-I6A5C46N.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import"./chunk-4UOFSGUS.js";import{a as Ye}from"./chunk-QXXIJAD5.js";import{a as ze}from"./chunk-X665E2HU.js";import{b as We}from"./chunk-GRL5MG3Z.js";import{d as Ke,e as _e}from"./chunk-SMIESS7P.js";import"./chunk-7T7UOTYK.js";import{a as He}from"./chunk-LFKCLLPT.js";import{R as Ae}from"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{c as Le}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as Ee}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as $e}from"./chunk-53WEPGUD.js";import"./chunk-XXQUMVWH.js";import"./chunk-RNL6BSFM.js";import"./chunk-QLQADHFE.js";import{a as T}from"./chunk-ERMTJYQF.js";import{c as de}from"./chunk-XDAT7LHC.js";import{f as Fe}from"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{a as ke}from"./chunk-XQCVZAGU.js";import{a as Ge,b as Qe,c as Xe,d as Ie,e as M,f as I}from"./chunk-MIQTKZAR.js";import{a as Je,e as Pe}from"./chunk-UZERI5YC.js";import{d as oe,f as Be,g as Ue,h as Ve,m as Ne,q as we}from"./chunk-OG4N2XHD.js";import"./chunk-AADILRJW.js";import{a as m,e as ie,f as Ce,g as Te,h as De,j as se}from"./chunk-3XIESWL4.js";var me=ie(Te(),1),ce=ie(Ce(),1);var tt=ie(Te(),1);var $=ie(Ce(),1);var l=ie(De(),1);var mt=Be(T.runMigration),at=m(a=>{let e=(0,tt.c)(99),{initialShardKey:r}=a,n=Fe(),t=oe(),[i,s]=(0,$.useState)(r??""),[d,u]=(0,$.useState)(""),[f,g]=(0,$.useState)("up"),[h,x]=(0,$.useState)(!0),[p,v]=(0,$.useState)(!1),[b,y]=(0,$.useState)(null),[c,j]=(0,$.useState)(null),k;e[0]!==i?(k=i.trim(),e[0]=i,e[1]=k):k=e[1];let N=He(k,400),R;e[2]!==i?(R=i.trim(),e[2]=i,e[3]=R):R=e[3];let O=R===N,q;e[4]===Symbol.for("react.memo_cache_sentinel")?(q={},e[4]=q):q=e[4];let ue;e[5]!==N?(ue={live:!0,shardKey:N},e[5]=N,e[6]=ue):ue=e[6];let w=de(T.migrationStatus,q,ue),S=w.data?.migrations??null,je=w.error,{errorSource:Se,liveError:Oe}=w,he,pe;e[7]!==N||e[8]!==w.data?(he=m(()=>{w.data!==void 0&&We(N)},"H"),pe=[w.data,N],e[7]=N,e[8]=w.data,e[9]=he,e[10]=pe):(he=e[9],pe=e[10]),(0,$.useEffect)(he,pe);let fe;if(e[11]!==n||e[12]!==f||e[13]!==h||e[14]!==d||e[15]!==i||e[16]!==w||e[17]!==t){let C=m(async()=>{let qe=d.trim();if(qe===""){j(t("Enter a migration id")),y(null);return}v(!0),j(null);try{let Me=await n.query(mt,{direction:f,dryRun:h,id:qe},Ue(i));y(Me),w.refetch()}catch(Me){let ct=Me;y(null),j(Ve(ct))}v(!1)},"m");fe=m(()=>{Ne(C())},"X"),e[11]=n,e[12]=f,e[13]=h,e[14]=d,e[15]=i,e[16]=w,e[17]=t,e[18]=fe}else fe=e[18];let ge=fe,be;e[19]===Symbol.for("react.memo_cache_sentinel")?(be=m(C=>{u(C.target.value)},"Z"),e[19]=be):be=e[19];let ot=be,ve;e[20]===Symbol.for("react.memo_cache_sentinel")?(ve=m(C=>{g(C.target.value==="down"?"down":"up")},"ee"),e[20]=ve):ve=e[20];let dt=ve,xe;e[21]===Symbol.for("react.memo_cache_sentinel")?(xe=m(C=>{x(C.target.checked)},"re"),e[21]=xe):xe=e[21];let lt=xe,D;e[22]!==i?(D=(0,l.jsx)(ze,{onChange:s,testId:"mg-shard-input",value:i}),e[22]=i,e[23]=D):D=e[23];let F;e[24]!==Oe?(F=(0,l.jsx)(Ze,{message:Oe,prefix:"mg"}),e[24]=Oe,e[25]=F):F=e[25];let K;e[26]!==D||e[27]!==F?(K=(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[D,F]}),e[26]=D,e[27]=F,e[28]=K):K=e[28];let _;e[29]!==je||e[30]!==Se?(_=je!==null&&(0,l.jsx)($e,{error:Se,testId:"mg-status-error"}),e[29]=je,e[30]=Se,e[31]=_):_=e[31];let E;e[32]!==S||e[33]!==t?(E=S!==null&&S.length===0&&(0,l.jsx)(ke,{description:t("Data migrations you run against this shard will be tracked here."),icon:(0,l.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,l.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:t("No migrations have run on this shard.")}),e[32]=S,e[33]=t,e[34]=E):E=e[34];let A;e[35]!==S||e[36]!==t?(A=S!==null&&S.length>0&&(0,l.jsx)(Je,{className:"overflow-hidden py-0",children:(0,l.jsx)(Pe,{className:"px-0",children:(0,l.jsxs)(Ge,{"data-testid":"mg-table",children:[(0,l.jsx)(Qe,{children:(0,l.jsxs)(Ie,{children:[(0,l.jsx)(M,{children:t("id")}),(0,l.jsx)(M,{children:t("direction")}),(0,l.jsx)(M,{children:t("status")}),(0,l.jsx)(M,{children:t("processed")}),(0,l.jsx)(M,{children:t("changed")}),(0,l.jsx)(M,{children:t("updated")}),(0,l.jsx)(M,{children:t("error")})]})}),(0,l.jsx)(Xe,{children:S.map(ut)})]})})}),e[35]=S,e[36]=t,e[37]=A):A=e[37];let L;e[38]!==t?(L=t("Run migration"),e[38]=t,e[39]=L):L=e[39];let J;e[40]!==L?(J=(0,l.jsx)(Re,{children:L}),e[40]=L,e[41]=J):J=e[41];let P;e[42]!==t?(P=t("Migration id"),e[42]=t,e[43]=P):P=e[43];let B;e[44]!==t?(B=t("migration id"),e[44]=t,e[45]=B):B=e[45];let U;e[46]!==d||e[47]!==P||e[48]!==B?(U=(0,l.jsx)(Ae,{"aria-label":P,className:"w-auto","data-testid":"mg-id-input",onChange:ot,placeholder:B,value:d}),e[46]=d,e[47]=P,e[48]=B,e[49]=U):U=e[49];let V;e[50]!==t?(V=t("Direction"),e[50]=t,e[51]=V):V=e[51];let W;e[52]!==t?(W=t("up"),e[52]=t,e[53]=W):W=e[53];let z;e[54]!==W?(z=(0,l.jsx)("option",{value:"up",children:W}),e[54]=W,e[55]=z):z=e[55];let H;e[56]!==t?(H=t("down"),e[56]=t,e[57]=H):H=e[57];let G;e[58]!==H?(G=(0,l.jsx)("option",{value:"down",children:H}),e[58]=H,e[59]=G):G=e[59];let Q;e[60]!==f||e[61]!==V||e[62]!==z||e[63]!==G?(Q=(0,l.jsxs)("select",{"aria-label":V,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:dt,value:f,children:[z,G]}),e[60]=f,e[61]=V,e[62]=z,e[63]=G,e[64]=Q):Q=e[64];let X;e[65]!==h?(X=(0,l.jsx)("input",{checked:h,className:"size-4 accent-primary","data-testid":"mg-dry-run",id:"mg-dry-run",onChange:lt,type:"checkbox"}),e[65]=h,e[66]=X):X=e[66];let Y;e[67]!==t?(Y=t("Dry run"),e[67]=t,e[68]=Y):Y=e[68];let Z;e[69]!==X||e[70]!==Y?(Z=(0,l.jsxs)(Re,{className:"flex items-center gap-1.5",htmlFor:"mg-dry-run",children:[X,Y]}),e[69]=X,e[70]=Y,e[71]=Z):Z=e[71];let ee;e[72]!==h||e[73]!==ge||e[74]!==p||e[75]!==O||e[76]!==t?(ee=h?(0,l.jsx)(Le,{"data-testid":"mg-run",disabled:p||!O,onClick:ge,type:"button",children:t(p?"Running\u2026":"Run")}):(0,l.jsx)(Ye,{confirmLabel:t(p?"Running\u2026":"Run migration?"),disabled:p||!O,onConfirm:ge,testId:"mg-run",children:t("Run")}),e[72]=h,e[73]=ge,e[74]=p,e[75]=O,e[76]=t,e[77]=ee):ee=e[77];let te;e[78]!==U||e[79]!==Q||e[80]!==Z||e[81]!==ee?(te=(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[U,Q,Z,ee]}),e[78]=U,e[79]=Q,e[80]=Z,e[81]=ee,e[82]=te):te=e[82];let ae;e[83]!==J||e[84]!==te?(ae=(0,l.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs",children:[J,te]}),e[83]=J,e[84]=te,e[85]=ae):ae=e[85];let re;e[86]!==c?(re=c!==null&&(0,l.jsx)("pre",{className:"text-sm text-destructive whitespace-pre-wrap","data-testid":"mg-run-error",role:"alert",children:c}),e[86]=c,e[87]=re):re=e[87];let ne;e[88]!==b||e[89]!==t?(ne=b!==null&&(0,l.jsxs)("p",{className:"text-sm text-muted-foreground","data-testid":"mg-run-result",children:[b.dryRun?t("Dry run: "):"",t("{status} \u2014 processed",{status:b.status}),b.processed,t(", changed"),b.changed]}),e[88]=b,e[89]=t,e[90]=ne):ne=e[90];let ye;return e[91]!==K||e[92]!==_||e[93]!==E||e[94]!==A||e[95]!==ae||e[96]!==re||e[97]!==ne?(ye=(0,l.jsxs)("div",{className:"flex flex-col gap-3 pt-4","data-testid":"lunora-migrations",children:[K,_,E,A,ae,re,ne]}),e[91]=K,e[92]=_,e[93]=E,e[94]=A,e[95]=ae,e[96]=re,e[97]=ne,e[98]=ye):ye=e[98],ye},"vr");function ut(a){return(0,l.jsxs)(Ie,{"data-testid":`mg-row-${a.id}`,children:[(0,l.jsx)(I,{children:a.id}),(0,l.jsx)(I,{children:a.direction}),(0,l.jsx)(I,{children:(0,l.jsx)(Ee,{variant:"secondary",children:a.status})}),(0,l.jsx)(I,{children:a.processed}),(0,l.jsx)(I,{children:a.changed}),(0,l.jsx)(I,{children:we(a.updatedAt)}),(0,l.jsx)(I,{children:a.error??""})]},a.id)}m(ut,"Qe");var o=ie(De(),1);var le=m(a=>typeof a=="object"&&a!==null,"k"),ht=m(a=>le(a)&&le(a.fields)&&le(a.indexes)&&le(a.relations)&&typeof a.shardMode=="string","z"),pt=m(a=>{if(a===void 0||a.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(a)}catch(r){return{error:`baseline is not valid JSON: ${r instanceof Error?r.message:String(r)}`,status:"invalid"}}if(!le(e)||e.version!==1||!le(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(1)})`,status:"invalid"};for(let[r,n]of Object.entries(e.tables))if(!ht(n))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:1},status:"ok"}},"B"),ft=m((a,e)=>a.unique===e.unique&&a.fields.length===e.fields.length&&a.fields.every((r,n)=>r===e.fields[n]),"L"),gt=m((a,e,r,n)=>{let t=[];return r.kind!==n.kind&&t.push({severity:"breaking",summary:`field ${a}.${e} changed type: ${r.kind} \u2192 ${n.kind} \u2014 add a data migration to convert existing values`,table:a,scope:"table",type:"changedFieldKind"}),r.optional&&!n.optional?t.push({severity:"breaking",summary:`field ${a}.${e} became required \u2014 rows missing it would be invalid; add a data migration to backfill it`,table:a,scope:"table",type:"fieldOptionalToRequired"}):!r.optional&&n.optional&&t.push({scope:"table",severity:"safe",summary:`field ${a}.${e} became optional`,table:a,type:"fieldRequiredToOptional"}),t},"Q"),bt=m((a,e,r)=>r.optional?{scope:"table",severity:"safe",summary:`added optional field ${a}.${e}`,table:a,type:"addedOptionalField"}:{severity:"breaking",summary:`added required field ${a}.${e} \u2014 existing rows have no value; add a data migration to backfill it`,table:a,scope:"table",type:"addedRequiredField"},"G"),vt=m((a,e,r,n)=>{for(let[t,i]of Object.entries(r.fields)){let s=e.fields[t];s===void 0?n.push(bt(a,t,i)):n.push(...gt(a,t,s,i))}for(let t of Object.keys(e.fields))r.fields[t]===void 0&&n.push({severity:"breaking",summary:`removed field ${a}.${t} \u2014 add a data migration if stored data must be cleaned up`,table:a,scope:"table",type:"removedField"})},"X"),xt=m((a,e,r,n)=>{for(let[t,i]of Object.entries(r.indexes)){let s=e.indexes[t];if(s===void 0){n.push({scope:"table",severity:"safe",summary:`added index ${t} on ${a}`,table:a,type:"addedIndex"});continue}ft(s,i)||n.push({severity:"breaking",summary:`index ${t} on ${a} changed shape \u2014 a query may have relied on the old index`,table:a,scope:"table",type:"changedIndex"})}for(let t of Object.keys(e.indexes))r.indexes[t]===void 0&&n.push({severity:"breaking",summary:`removed index ${t} on ${a} \u2014 a query that used \`.withIndex("${t}")\` would break`,table:a,scope:"table",type:"removedIndex"})},"Y"),yt=m((a,e,r,n)=>{for(let t of Object.keys(r.relations))e.relations[t]===void 0&&n.push({scope:"schema",severity:"safe",summary:`added relation ${a}.${t}`,table:a,type:"addedRelation"});for(let t of Object.keys(e.relations))r.relations[t]===void 0&&n.push({scope:"schema",severity:"breaking",summary:`removed relation ${a}.${t}`,table:a,type:"removedRelation"})},"Z"),kt=m((a,e,r,n)=>{e.shardMode!==r.shardMode&&n.push({severity:"breaking",summary:`table ${a} changed shard mode: ${e.shardMode} \u2192 ${r.shardMode} \u2014 its physical storage moves; add a data migration / re-shard plan`,table:a,scope:"table",type:"changedShardMode"}),vt(a,e,r,n),xt(a,e,r,n),yt(a,e,r,n)},"ee"),Nt=m((a,e)=>{let r=[],n=a?.tables??{};for(let[t,i]of Object.entries(e.tables)){let s=n[t];if(s===void 0){r.push({scope:"table",severity:"safe",summary:`added table ${t}`,table:t,type:"addedTable"});continue}kt(t,s,i,r)}for(let t of Object.keys(n))e.tables[t]===void 0&&r.push({scope:"table",severity:"breaking",summary:`removed table ${t} \u2014 add a data migration if its data must be archived/cleaned up`,table:t,type:"removedTable"});if(a!==void 0&&a.jurisdiction!==e.jurisdiction){let t=a.jurisdiction??"(none)",i=e.jurisdiction??"(none)";r.push({scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${t} to ${i} \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"),rt=m(a=>Object.entries(a.fields).map(([e,r])=>({name:e,optional:r.optional,ref:Object.values(a.relations).find(n=>n.field===e&&n.kind==="one")?.table,type:r.kind})),"T"),nt=m((a,e)=>{let r={},n=a?.fields??{},t=e?.fields??{};for(let[i,s]of Object.entries(t)){let d=n[i];d===void 0?r[i]=a===void 0?"unchanged":"added":r[i]=d.kind===s.kind&&d.optional===s.optional?"unchanged":"changed"}for(let i of Object.keys(n))t[i]===void 0&&(r[i]="removed");return r},"F"),wt=m((a,e)=>{let{changes:r}=Nt(a,e),n=new Set(r.filter(s=>s.scope==="table"&&s.table!==void 0).map(s=>s.table)),t=[],i=m((s,d)=>s?"added":n.has(d)?"changed":"context","o");for(let[s,d]of Object.entries(e.tables)){let u=a?.tables[s],f=i(u===void 0,s);t.push({columns:rt(d),fieldStatus:nt(u,d),name:s,shardMode:d.shardMode,status:f})}for(let[s,d]of Object.entries(a?.tables??{}))e.tables[s]===void 0&&t.push({columns:rt(d),fieldStatus:nt(d,void 0),name:s,shardMode:d.shardMode,status:"removed"});return t.sort((s,d)=>s.name.localeCompare(d.name)),{breakingCount:r.filter(s=>s.severity==="breaking").length,changes:r,tables:t}},"ae"),it=m(a=>{let e=pt(a);return e.status==="ok"?e.snapshot:void 0},"A"),$t={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"},jt=m(a=>a==="global"?"global":"shard","se"),St=m(a=>{let e=(0,me.c)(24),{appliedAt:r,hash:n,onSelect:t,selected:i,seq:s}=a,d=i?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground",u;e[0]!==d?(u=se("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]=u):u=e[1];let f=`sh-version-${n}`,g;e[2]!==n||e[3]!==t?(g=m(()=>{t(n)},"m"),e[2]=n,e[3]=t,e[4]=g):g=e[4];let h;e[5]!==s?(h=(0,o.jsxs)("span",{className:"font-mono text-[13px] tabular-nums",children:["v",s]}),e[5]=s,e[6]=h):h=e[6];let x;e[7]!==n?(x=n.slice(0,7),e[7]=n,e[8]=x):x=e[8];let p;e[9]!==x?(p=(0,o.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:x}),e[9]=x,e[10]=p):p=e[10];let v;e[11]!==h||e[12]!==p?(v=(0,o.jsxs)("span",{className:"flex w-full items-baseline gap-2",children:[h,p]}),e[11]=h,e[12]=p,e[13]=v):v=e[13];let b;e[14]!==r?(b=we(r),e[14]=r,e[15]=b):b=e[15];let y;e[16]!==b?(y=(0,o.jsx)("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:b}),e[16]=b,e[17]=y):y=e[17];let c;return e[18]!==y||e[19]!==u||e[20]!==f||e[21]!==g||e[22]!==v?(c=(0,o.jsx)("li",{children:(0,o.jsxs)("button",{className:u,"data-testid":f,onClick:g,type:"button",children:[v,y]})}),e[18]=y,e[19]=u,e[20]=f,e[21]=g,e[22]=v,e[23]=c):c=e[23],c},"ie"),Ot=m(a=>{let e=(0,me.c)(26),{breaking:r,count:n,first:t}=a,i=oe();if(t){let p;e[0]!==n?(p=(0,o.jsx)("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:n}),e[0]=n,e[1]=p):p=e[1];let v;e[2]!==i?(v=i("tables"),e[2]=i,e[3]=v):v=e[3];let b;e[4]!==v?(b=(0,o.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:v}),e[4]=v,e[5]=b):b=e[5];let y;return e[6]!==p||e[7]!==b?(y=(0,o.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[p,b]}),e[6]=p,e[7]=b,e[8]=y):y=e[8],y}let s=r>0&&"text-destructive",d;e[9]!==s?(d=se("text-3xl leading-none font-light tracking-tight tabular-nums",s),e[9]=s,e[10]=d):d=e[10];let u;e[11]!==n||e[12]!==d?(u=(0,o.jsx)("span",{className:d,children:n}),e[11]=n,e[12]=d,e[13]=u):u=e[13];let f;e[14]!==n||e[15]!==i?(f=i(n===1?"change":"changes"),e[14]=n,e[15]=i,e[16]=f):f=e[16];let g;e[17]!==f?(g=(0,o.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:f}),e[17]=f,e[18]=g):g=e[18];let h;e[19]!==r||e[20]!==i?(h=r>0&&(0,o.jsxs)("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["\xB7 ",i("{count} breaking",{count:r})]}),e[19]=r,e[20]=i,e[21]=h):h=e[21];let x;return e[22]!==u||e[23]!==g||e[24]!==h?(x=(0,o.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[u,g,h]}),e[22]=u,e[23]=g,e[24]=h,e[25]=x):x=e[25],x},"re"),st={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"},changedFieldKind:{action:"changed",kind:"field kind"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedShardMode:{action:"changed",kind:"shard mode"},fieldOptionalToRequired:{action:"changed",kind:"field \u2192 required"},fieldRequiredToOptional:{action:"changed",kind:"field \u2192 optional"},removedField:{action:"removed",kind:"field"},removedIndex:{action:"removed",kind:"index"},removedRelation:{action:"removed",kind:"relation"},removedTable:{action:"removed",kind:"table"}},Mt=m((a,e)=>{let r=`${st[a.type].action} ${e} `;return a.summary.startsWith(r)?a.summary.slice(r.length):a.summary},"oe"),It=m(a=>{let e=new Map;for(let n of a){let t=n.table??"",i=e.get(t);i===void 0?e.set(t,[n]):i.push(n)}let r=[...e].map(([n,t])=>({changes:t,table:n}));return[...r.filter(n=>n.table!==""),...r.filter(n=>n.table==="")]},"de"),Rt=m(a=>{let e=(0,me.c)(2),{children:r}=a,n;return e[0]!==r?(n=(0,o.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]=n):n=e[1],n},"le"),qt=m(({pane:a,shardKey:e=""})=>{let r=oe(),n=_e(),t=Ke({strict:!1}).version,i=m(c=>{Ne(n({search:{version:c},to:"/migrations"}))},"o"),s=de(T.schemaHistory,{},{shardKey:e}),d=s.data?.versions??[],u=t!==void 0&&d.some(c=>c.hash===t)?t:d[0]?.hash,f=d.findIndex(c=>c.hash===u),g=f===-1?void 0:d[f+1]?.hash,h=de(T.schemaVersion,{hash:u??""},{enabled:u!==void 0,shardKey:e}),x=de(T.schemaVersion,{hash:g??""},{enabled:g!==void 0,shardKey:e}),p=(0,ce.useMemo)(()=>{let c=it(h.data?.version?.snapshotJson);if(c!==void 0)return wt(it(x.data?.version?.snapshotJson),c)},[h.data,x.data]),v=(0,ce.useMemo)(()=>(p?.tables??[]).map(c=>({columns:c.columns,name:c.name,tier:jt(c.shardMode)})),[p]),b=(0,ce.useMemo)(()=>{let c={};for(let j of p?.tables??[])c[j.name]=$t[j.status];return c},[p]);if(s.error!==null)return(0,o.jsx)($e,{error:s.errorSource,testId:"sh-error"});if(d.length===0)return(0,o.jsx)(ke,{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 y=p?.changes??[];return(0,o.jsxs)("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[(0,o.jsxs)("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[(0,o.jsx)(Rt,{children:r("Schema versions")}),(0,o.jsx)("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:d.map(c=>(0,o.jsx)(St,{appliedAt:c.appliedAt,hash:c.hash,onSelect:i,selected:c.hash===u,seq:c.seq},c.hash))})]}),(0,o.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[(0,o.jsx)(Ot,{breaking:p?.breakingCount??0,count:g===void 0?v.length:y.length,first:g===void 0}),a==="diagram"?(0,o.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,o.jsx)(et,{fill:!0,nodeClasses:b,tables:v,testIdPrefix:"sh"})}):(0,o.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:It(y).map(c=>{let j=(p?.tables??[]).find(k=>k.name===c.table);return(0,o.jsxs)("section",{className:"mb-6",children:[(0,o.jsxs)("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[(0,o.jsx)("span",{className:"font-mono text-[13px] text-foreground",children:c.table===""?r("schema"):c.table}),j!==void 0&&(0,o.jsx)("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:r("{count} columns",{count:j.columns.length})}),c.changes.length>1&&(0,o.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:c.changes.length})]}),(0,o.jsx)("ul",{children:c.changes.map(k=>{let{action:N,kind:R}=st[k.type],O=k.severity==="breaking",q=Mt(k,R);return(0,o.jsxs)("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[(0,o.jsx)("span",{"aria-hidden":"true",className:se("-ms-3 h-3 w-0.5 shrink-0 self-center",O?"bg-destructive":"bg-transparent")}),(0,o.jsxs)("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[r(N)," ",R]}),q!==c.table&&(0,o.jsx)("span",{className:se("min-w-0 font-mono text-[13px]",O?"text-destructive":"text-foreground"),children:q}),O&&(0,o.jsx)("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:r("breaking")})]},`${k.type}-${k.summary}`)})})]},c.table)})})]})]})},"ce"),Ct=m(a=>se("-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",a?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"me"),la=m(a=>{let e=(0,me.c)(11),{initialShardKey:r}=a,n=oe(),[t,i]=(0,ce.useState)("diagram"),s;e[0]!==t?(s=m((h,x,p,v)=>(0,o.jsxs)("button",{"aria-selected":t===h,className:Ct(t===h),"data-testid":p,onClick:m(()=>{i(h)},"onClick"),role:"tab",type:"button",children:[x,v!==void 0&&(0,o.jsx)("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:v})]}),"i"),e[0]=t,e[1]=s):s=e[1];let d=s,u;e[2]!==n||e[3]!==d?(u=(0,o.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",n("Diagram"),"mg-pane-diagram"),d("changes",n("Changes"),"mg-pane-changes"),d("data",n("Data migrations"),"mg-pane-data")]}),e[2]=n,e[3]=d,e[4]=u):u=e[4];let f;e[5]!==r||e[6]!==t?(f=(0,o.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:t==="data"?(0,o.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:(0,o.jsx)(at,{initialShardKey:r})}):(0,o.jsx)(qt,{pane:t,shardKey:r})}),e[5]=r,e[6]=t,e[7]=f):f=e[7];let g;return e[8]!==u||e[9]!==f?(g=(0,o.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[u,f]}),e[8]=u,e[9]=f,e[10]=g):g=e[10],g},"je");export{la as MigrationsRoutePanel};
1
+ import{a as et}from"./chunk-5YADKLAQ.js";import"./chunk-GMR677FL.js";import"./chunk-7H7LZRLP.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import{a as Re}from"./chunk-5Y3QLNWX.js";import{a as Ze}from"./chunk-CTNB2KIA.js";import"./chunk-I6A5C46N.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import"./chunk-4UOFSGUS.js";import{a as Ye}from"./chunk-QXXIJAD5.js";import{a as ze}from"./chunk-X665E2HU.js";import{b as We}from"./chunk-GRL5MG3Z.js";import{d as Ke,e as _e}from"./chunk-SMIESS7P.js";import"./chunk-7T7UOTYK.js";import{a as He}from"./chunk-LFKCLLPT.js";import{R as Ae}from"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{c as Le}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as Ee}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as $e}from"./chunk-AHVDZWB3.js";import"./chunk-XXQUMVWH.js";import"./chunk-VORDESEQ.js";import"./chunk-QLQADHFE.js";import{a as T}from"./chunk-ERMTJYQF.js";import{c as de}from"./chunk-YGKR536O.js";import{f as Fe}from"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as ke}from"./chunk-XQCVZAGU.js";import{a as Ge,b as Qe,c as Xe,d as Ie,e as M,f as I}from"./chunk-MIQTKZAR.js";import{a as Je,e as Pe}from"./chunk-UZERI5YC.js";import{d as oe,f as Be,g as Ue,h as Ve,m as Ne,q as we}from"./chunk-OG4N2XHD.js";import"./chunk-QNUWWC3N.js";import{a as m,e as ie,f as Ce,g as Te,h as De,j as se}from"./chunk-3XIESWL4.js";var me=ie(Te(),1),ce=ie(Ce(),1);var tt=ie(Te(),1);var $=ie(Ce(),1);var l=ie(De(),1);var mt=Be(T.runMigration),at=m(a=>{let e=(0,tt.c)(99),{initialShardKey:r}=a,n=Fe(),t=oe(),[i,s]=(0,$.useState)(r??""),[d,u]=(0,$.useState)(""),[f,g]=(0,$.useState)("up"),[h,x]=(0,$.useState)(!0),[p,v]=(0,$.useState)(!1),[b,y]=(0,$.useState)(null),[c,j]=(0,$.useState)(null),k;e[0]!==i?(k=i.trim(),e[0]=i,e[1]=k):k=e[1];let N=He(k,400),R;e[2]!==i?(R=i.trim(),e[2]=i,e[3]=R):R=e[3];let O=R===N,q;e[4]===Symbol.for("react.memo_cache_sentinel")?(q={},e[4]=q):q=e[4];let ue;e[5]!==N?(ue={live:!0,shardKey:N},e[5]=N,e[6]=ue):ue=e[6];let w=de(T.migrationStatus,q,ue),S=w.data?.migrations??null,je=w.error,{errorSource:Se,liveError:Oe}=w,he,pe;e[7]!==N||e[8]!==w.data?(he=m(()=>{w.data!==void 0&&We(N)},"H"),pe=[w.data,N],e[7]=N,e[8]=w.data,e[9]=he,e[10]=pe):(he=e[9],pe=e[10]),(0,$.useEffect)(he,pe);let fe;if(e[11]!==n||e[12]!==f||e[13]!==h||e[14]!==d||e[15]!==i||e[16]!==w||e[17]!==t){let C=m(async()=>{let qe=d.trim();if(qe===""){j(t("Enter a migration id")),y(null);return}v(!0),j(null);try{let Me=await n.query(mt,{direction:f,dryRun:h,id:qe},Ue(i));y(Me),w.refetch()}catch(Me){let ct=Me;y(null),j(Ve(ct))}v(!1)},"m");fe=m(()=>{Ne(C())},"X"),e[11]=n,e[12]=f,e[13]=h,e[14]=d,e[15]=i,e[16]=w,e[17]=t,e[18]=fe}else fe=e[18];let ge=fe,be;e[19]===Symbol.for("react.memo_cache_sentinel")?(be=m(C=>{u(C.target.value)},"Z"),e[19]=be):be=e[19];let ot=be,ve;e[20]===Symbol.for("react.memo_cache_sentinel")?(ve=m(C=>{g(C.target.value==="down"?"down":"up")},"ee"),e[20]=ve):ve=e[20];let dt=ve,xe;e[21]===Symbol.for("react.memo_cache_sentinel")?(xe=m(C=>{x(C.target.checked)},"re"),e[21]=xe):xe=e[21];let lt=xe,D;e[22]!==i?(D=(0,l.jsx)(ze,{onChange:s,testId:"mg-shard-input",value:i}),e[22]=i,e[23]=D):D=e[23];let F;e[24]!==Oe?(F=(0,l.jsx)(Ze,{message:Oe,prefix:"mg"}),e[24]=Oe,e[25]=F):F=e[25];let K;e[26]!==D||e[27]!==F?(K=(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[D,F]}),e[26]=D,e[27]=F,e[28]=K):K=e[28];let _;e[29]!==je||e[30]!==Se?(_=je!==null&&(0,l.jsx)($e,{error:Se,testId:"mg-status-error"}),e[29]=je,e[30]=Se,e[31]=_):_=e[31];let E;e[32]!==S||e[33]!==t?(E=S!==null&&S.length===0&&(0,l.jsx)(ke,{description:t("Data migrations you run against this shard will be tracked here."),icon:(0,l.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,l.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:t("No migrations have run on this shard.")}),e[32]=S,e[33]=t,e[34]=E):E=e[34];let A;e[35]!==S||e[36]!==t?(A=S!==null&&S.length>0&&(0,l.jsx)(Je,{className:"overflow-hidden py-0",children:(0,l.jsx)(Pe,{className:"px-0",children:(0,l.jsxs)(Ge,{"data-testid":"mg-table",children:[(0,l.jsx)(Qe,{children:(0,l.jsxs)(Ie,{children:[(0,l.jsx)(M,{children:t("id")}),(0,l.jsx)(M,{children:t("direction")}),(0,l.jsx)(M,{children:t("status")}),(0,l.jsx)(M,{children:t("processed")}),(0,l.jsx)(M,{children:t("changed")}),(0,l.jsx)(M,{children:t("updated")}),(0,l.jsx)(M,{children:t("error")})]})}),(0,l.jsx)(Xe,{children:S.map(ut)})]})})}),e[35]=S,e[36]=t,e[37]=A):A=e[37];let L;e[38]!==t?(L=t("Run migration"),e[38]=t,e[39]=L):L=e[39];let J;e[40]!==L?(J=(0,l.jsx)(Re,{children:L}),e[40]=L,e[41]=J):J=e[41];let P;e[42]!==t?(P=t("Migration id"),e[42]=t,e[43]=P):P=e[43];let B;e[44]!==t?(B=t("migration id"),e[44]=t,e[45]=B):B=e[45];let U;e[46]!==d||e[47]!==P||e[48]!==B?(U=(0,l.jsx)(Ae,{"aria-label":P,className:"w-auto","data-testid":"mg-id-input",onChange:ot,placeholder:B,value:d}),e[46]=d,e[47]=P,e[48]=B,e[49]=U):U=e[49];let V;e[50]!==t?(V=t("Direction"),e[50]=t,e[51]=V):V=e[51];let W;e[52]!==t?(W=t("up"),e[52]=t,e[53]=W):W=e[53];let z;e[54]!==W?(z=(0,l.jsx)("option",{value:"up",children:W}),e[54]=W,e[55]=z):z=e[55];let H;e[56]!==t?(H=t("down"),e[56]=t,e[57]=H):H=e[57];let G;e[58]!==H?(G=(0,l.jsx)("option",{value:"down",children:H}),e[58]=H,e[59]=G):G=e[59];let Q;e[60]!==f||e[61]!==V||e[62]!==z||e[63]!==G?(Q=(0,l.jsxs)("select",{"aria-label":V,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:dt,value:f,children:[z,G]}),e[60]=f,e[61]=V,e[62]=z,e[63]=G,e[64]=Q):Q=e[64];let X;e[65]!==h?(X=(0,l.jsx)("input",{checked:h,className:"size-4 accent-primary","data-testid":"mg-dry-run",id:"mg-dry-run",onChange:lt,type:"checkbox"}),e[65]=h,e[66]=X):X=e[66];let Y;e[67]!==t?(Y=t("Dry run"),e[67]=t,e[68]=Y):Y=e[68];let Z;e[69]!==X||e[70]!==Y?(Z=(0,l.jsxs)(Re,{className:"flex items-center gap-1.5",htmlFor:"mg-dry-run",children:[X,Y]}),e[69]=X,e[70]=Y,e[71]=Z):Z=e[71];let ee;e[72]!==h||e[73]!==ge||e[74]!==p||e[75]!==O||e[76]!==t?(ee=h?(0,l.jsx)(Le,{"data-testid":"mg-run",disabled:p||!O,onClick:ge,type:"button",children:t(p?"Running\u2026":"Run")}):(0,l.jsx)(Ye,{confirmLabel:t(p?"Running\u2026":"Run migration?"),disabled:p||!O,onConfirm:ge,testId:"mg-run",children:t("Run")}),e[72]=h,e[73]=ge,e[74]=p,e[75]=O,e[76]=t,e[77]=ee):ee=e[77];let te;e[78]!==U||e[79]!==Q||e[80]!==Z||e[81]!==ee?(te=(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[U,Q,Z,ee]}),e[78]=U,e[79]=Q,e[80]=Z,e[81]=ee,e[82]=te):te=e[82];let ae;e[83]!==J||e[84]!==te?(ae=(0,l.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs",children:[J,te]}),e[83]=J,e[84]=te,e[85]=ae):ae=e[85];let re;e[86]!==c?(re=c!==null&&(0,l.jsx)("pre",{className:"text-sm text-destructive whitespace-pre-wrap","data-testid":"mg-run-error",role:"alert",children:c}),e[86]=c,e[87]=re):re=e[87];let ne;e[88]!==b||e[89]!==t?(ne=b!==null&&(0,l.jsxs)("p",{className:"text-sm text-muted-foreground","data-testid":"mg-run-result",children:[b.dryRun?t("Dry run: "):"",t("{status} \u2014 processed",{status:b.status}),b.processed,t(", changed"),b.changed]}),e[88]=b,e[89]=t,e[90]=ne):ne=e[90];let ye;return e[91]!==K||e[92]!==_||e[93]!==E||e[94]!==A||e[95]!==ae||e[96]!==re||e[97]!==ne?(ye=(0,l.jsxs)("div",{className:"flex flex-col gap-3 pt-4","data-testid":"lunora-migrations",children:[K,_,E,A,ae,re,ne]}),e[91]=K,e[92]=_,e[93]=E,e[94]=A,e[95]=ae,e[96]=re,e[97]=ne,e[98]=ye):ye=e[98],ye},"vr");function ut(a){return(0,l.jsxs)(Ie,{"data-testid":`mg-row-${a.id}`,children:[(0,l.jsx)(I,{children:a.id}),(0,l.jsx)(I,{children:a.direction}),(0,l.jsx)(I,{children:(0,l.jsx)(Ee,{variant:"secondary",children:a.status})}),(0,l.jsx)(I,{children:a.processed}),(0,l.jsx)(I,{children:a.changed}),(0,l.jsx)(I,{children:we(a.updatedAt)}),(0,l.jsx)(I,{children:a.error??""})]},a.id)}m(ut,"Qe");var o=ie(De(),1);var le=m(a=>typeof a=="object"&&a!==null,"k"),ht=m(a=>le(a)&&le(a.fields)&&le(a.indexes)&&le(a.relations)&&typeof a.shardMode=="string","z"),pt=m(a=>{if(a===void 0||a.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(a)}catch(r){return{error:`baseline is not valid JSON: ${r instanceof Error?r.message:String(r)}`,status:"invalid"}}if(!le(e)||e.version!==1||!le(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(1)})`,status:"invalid"};for(let[r,n]of Object.entries(e.tables))if(!ht(n))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:1},status:"ok"}},"B"),ft=m((a,e)=>a.unique===e.unique&&a.fields.length===e.fields.length&&a.fields.every((r,n)=>r===e.fields[n]),"L"),gt=m((a,e,r,n)=>{let t=[];return r.kind!==n.kind&&t.push({severity:"breaking",summary:`field ${a}.${e} changed type: ${r.kind} \u2192 ${n.kind} \u2014 add a data migration to convert existing values`,table:a,scope:"table",type:"changedFieldKind"}),r.optional&&!n.optional?t.push({severity:"breaking",summary:`field ${a}.${e} became required \u2014 rows missing it would be invalid; add a data migration to backfill it`,table:a,scope:"table",type:"fieldOptionalToRequired"}):!r.optional&&n.optional&&t.push({scope:"table",severity:"safe",summary:`field ${a}.${e} became optional`,table:a,type:"fieldRequiredToOptional"}),t},"Q"),bt=m((a,e,r)=>r.optional?{scope:"table",severity:"safe",summary:`added optional field ${a}.${e}`,table:a,type:"addedOptionalField"}:{severity:"breaking",summary:`added required field ${a}.${e} \u2014 existing rows have no value; add a data migration to backfill it`,table:a,scope:"table",type:"addedRequiredField"},"G"),vt=m((a,e,r,n)=>{for(let[t,i]of Object.entries(r.fields)){let s=e.fields[t];s===void 0?n.push(bt(a,t,i)):n.push(...gt(a,t,s,i))}for(let t of Object.keys(e.fields))r.fields[t]===void 0&&n.push({severity:"breaking",summary:`removed field ${a}.${t} \u2014 add a data migration if stored data must be cleaned up`,table:a,scope:"table",type:"removedField"})},"X"),xt=m((a,e,r,n)=>{for(let[t,i]of Object.entries(r.indexes)){let s=e.indexes[t];if(s===void 0){n.push({scope:"table",severity:"safe",summary:`added index ${t} on ${a}`,table:a,type:"addedIndex"});continue}ft(s,i)||n.push({severity:"breaking",summary:`index ${t} on ${a} changed shape \u2014 a query may have relied on the old index`,table:a,scope:"table",type:"changedIndex"})}for(let t of Object.keys(e.indexes))r.indexes[t]===void 0&&n.push({severity:"breaking",summary:`removed index ${t} on ${a} \u2014 a query that used \`.withIndex("${t}")\` would break`,table:a,scope:"table",type:"removedIndex"})},"Y"),yt=m((a,e,r,n)=>{for(let t of Object.keys(r.relations))e.relations[t]===void 0&&n.push({scope:"schema",severity:"safe",summary:`added relation ${a}.${t}`,table:a,type:"addedRelation"});for(let t of Object.keys(e.relations))r.relations[t]===void 0&&n.push({scope:"schema",severity:"breaking",summary:`removed relation ${a}.${t}`,table:a,type:"removedRelation"})},"Z"),kt=m((a,e,r,n)=>{e.shardMode!==r.shardMode&&n.push({severity:"breaking",summary:`table ${a} changed shard mode: ${e.shardMode} \u2192 ${r.shardMode} \u2014 its physical storage moves; add a data migration / re-shard plan`,table:a,scope:"table",type:"changedShardMode"}),vt(a,e,r,n),xt(a,e,r,n),yt(a,e,r,n)},"ee"),Nt=m((a,e)=>{let r=[],n=a?.tables??{};for(let[t,i]of Object.entries(e.tables)){let s=n[t];if(s===void 0){r.push({scope:"table",severity:"safe",summary:`added table ${t}`,table:t,type:"addedTable"});continue}kt(t,s,i,r)}for(let t of Object.keys(n))e.tables[t]===void 0&&r.push({scope:"table",severity:"breaking",summary:`removed table ${t} \u2014 add a data migration if its data must be archived/cleaned up`,table:t,type:"removedTable"});if(a!==void 0&&a.jurisdiction!==e.jurisdiction){let t=a.jurisdiction??"(none)",i=e.jurisdiction??"(none)";r.push({scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${t} to ${i} \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"),rt=m(a=>Object.entries(a.fields).map(([e,r])=>({name:e,optional:r.optional,ref:Object.values(a.relations).find(n=>n.field===e&&n.kind==="one")?.table,type:r.kind})),"T"),nt=m((a,e)=>{let r={},n=a?.fields??{},t=e?.fields??{};for(let[i,s]of Object.entries(t)){let d=n[i];d===void 0?r[i]=a===void 0?"unchanged":"added":r[i]=d.kind===s.kind&&d.optional===s.optional?"unchanged":"changed"}for(let i of Object.keys(n))t[i]===void 0&&(r[i]="removed");return r},"F"),wt=m((a,e)=>{let{changes:r}=Nt(a,e),n=new Set(r.filter(s=>s.scope==="table"&&s.table!==void 0).map(s=>s.table)),t=[],i=m((s,d)=>s?"added":n.has(d)?"changed":"context","o");for(let[s,d]of Object.entries(e.tables)){let u=a?.tables[s],f=i(u===void 0,s);t.push({columns:rt(d),fieldStatus:nt(u,d),name:s,shardMode:d.shardMode,status:f})}for(let[s,d]of Object.entries(a?.tables??{}))e.tables[s]===void 0&&t.push({columns:rt(d),fieldStatus:nt(d,void 0),name:s,shardMode:d.shardMode,status:"removed"});return t.sort((s,d)=>s.name.localeCompare(d.name)),{breakingCount:r.filter(s=>s.severity==="breaking").length,changes:r,tables:t}},"ae"),it=m(a=>{let e=pt(a);return e.status==="ok"?e.snapshot:void 0},"A"),$t={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"},jt=m(a=>a==="global"?"global":"shard","se"),St=m(a=>{let e=(0,me.c)(24),{appliedAt:r,hash:n,onSelect:t,selected:i,seq:s}=a,d=i?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground",u;e[0]!==d?(u=se("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]=u):u=e[1];let f=`sh-version-${n}`,g;e[2]!==n||e[3]!==t?(g=m(()=>{t(n)},"m"),e[2]=n,e[3]=t,e[4]=g):g=e[4];let h;e[5]!==s?(h=(0,o.jsxs)("span",{className:"font-mono text-[13px] tabular-nums",children:["v",s]}),e[5]=s,e[6]=h):h=e[6];let x;e[7]!==n?(x=n.slice(0,7),e[7]=n,e[8]=x):x=e[8];let p;e[9]!==x?(p=(0,o.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:x}),e[9]=x,e[10]=p):p=e[10];let v;e[11]!==h||e[12]!==p?(v=(0,o.jsxs)("span",{className:"flex w-full items-baseline gap-2",children:[h,p]}),e[11]=h,e[12]=p,e[13]=v):v=e[13];let b;e[14]!==r?(b=we(r),e[14]=r,e[15]=b):b=e[15];let y;e[16]!==b?(y=(0,o.jsx)("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:b}),e[16]=b,e[17]=y):y=e[17];let c;return e[18]!==y||e[19]!==u||e[20]!==f||e[21]!==g||e[22]!==v?(c=(0,o.jsx)("li",{children:(0,o.jsxs)("button",{className:u,"data-testid":f,onClick:g,type:"button",children:[v,y]})}),e[18]=y,e[19]=u,e[20]=f,e[21]=g,e[22]=v,e[23]=c):c=e[23],c},"ie"),Ot=m(a=>{let e=(0,me.c)(26),{breaking:r,count:n,first:t}=a,i=oe();if(t){let p;e[0]!==n?(p=(0,o.jsx)("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:n}),e[0]=n,e[1]=p):p=e[1];let v;e[2]!==i?(v=i("tables"),e[2]=i,e[3]=v):v=e[3];let b;e[4]!==v?(b=(0,o.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:v}),e[4]=v,e[5]=b):b=e[5];let y;return e[6]!==p||e[7]!==b?(y=(0,o.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[p,b]}),e[6]=p,e[7]=b,e[8]=y):y=e[8],y}let s=r>0&&"text-destructive",d;e[9]!==s?(d=se("text-3xl leading-none font-light tracking-tight tabular-nums",s),e[9]=s,e[10]=d):d=e[10];let u;e[11]!==n||e[12]!==d?(u=(0,o.jsx)("span",{className:d,children:n}),e[11]=n,e[12]=d,e[13]=u):u=e[13];let f;e[14]!==n||e[15]!==i?(f=i(n===1?"change":"changes"),e[14]=n,e[15]=i,e[16]=f):f=e[16];let g;e[17]!==f?(g=(0,o.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:f}),e[17]=f,e[18]=g):g=e[18];let h;e[19]!==r||e[20]!==i?(h=r>0&&(0,o.jsxs)("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["\xB7 ",i("{count} breaking",{count:r})]}),e[19]=r,e[20]=i,e[21]=h):h=e[21];let x;return e[22]!==u||e[23]!==g||e[24]!==h?(x=(0,o.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[u,g,h]}),e[22]=u,e[23]=g,e[24]=h,e[25]=x):x=e[25],x},"re"),st={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"},changedFieldKind:{action:"changed",kind:"field kind"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedShardMode:{action:"changed",kind:"shard mode"},fieldOptionalToRequired:{action:"changed",kind:"field \u2192 required"},fieldRequiredToOptional:{action:"changed",kind:"field \u2192 optional"},removedField:{action:"removed",kind:"field"},removedIndex:{action:"removed",kind:"index"},removedRelation:{action:"removed",kind:"relation"},removedTable:{action:"removed",kind:"table"}},Mt=m((a,e)=>{let r=`${st[a.type].action} ${e} `;return a.summary.startsWith(r)?a.summary.slice(r.length):a.summary},"oe"),It=m(a=>{let e=new Map;for(let n of a){let t=n.table??"",i=e.get(t);i===void 0?e.set(t,[n]):i.push(n)}let r=[...e].map(([n,t])=>({changes:t,table:n}));return[...r.filter(n=>n.table!==""),...r.filter(n=>n.table==="")]},"de"),Rt=m(a=>{let e=(0,me.c)(2),{children:r}=a,n;return e[0]!==r?(n=(0,o.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]=n):n=e[1],n},"le"),qt=m(({pane:a,shardKey:e=""})=>{let r=oe(),n=_e(),t=Ke({strict:!1}).version,i=m(c=>{Ne(n({search:{version:c},to:"/migrations"}))},"o"),s=de(T.schemaHistory,{},{shardKey:e}),d=s.data?.versions??[],u=t!==void 0&&d.some(c=>c.hash===t)?t:d[0]?.hash,f=d.findIndex(c=>c.hash===u),g=f===-1?void 0:d[f+1]?.hash,h=de(T.schemaVersion,{hash:u??""},{enabled:u!==void 0,shardKey:e}),x=de(T.schemaVersion,{hash:g??""},{enabled:g!==void 0,shardKey:e}),p=(0,ce.useMemo)(()=>{let c=it(h.data?.version?.snapshotJson);if(c!==void 0)return wt(it(x.data?.version?.snapshotJson),c)},[h.data,x.data]),v=(0,ce.useMemo)(()=>(p?.tables??[]).map(c=>({columns:c.columns,name:c.name,tier:jt(c.shardMode)})),[p]),b=(0,ce.useMemo)(()=>{let c={};for(let j of p?.tables??[])c[j.name]=$t[j.status];return c},[p]);if(s.error!==null)return(0,o.jsx)($e,{error:s.errorSource,testId:"sh-error"});if(d.length===0)return(0,o.jsx)(ke,{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 y=p?.changes??[];return(0,o.jsxs)("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[(0,o.jsxs)("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[(0,o.jsx)(Rt,{children:r("Schema versions")}),(0,o.jsx)("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:d.map(c=>(0,o.jsx)(St,{appliedAt:c.appliedAt,hash:c.hash,onSelect:i,selected:c.hash===u,seq:c.seq},c.hash))})]}),(0,o.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[(0,o.jsx)(Ot,{breaking:p?.breakingCount??0,count:g===void 0?v.length:y.length,first:g===void 0}),a==="diagram"?(0,o.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,o.jsx)(et,{fill:!0,nodeClasses:b,tables:v,testIdPrefix:"sh"})}):(0,o.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:It(y).map(c=>{let j=(p?.tables??[]).find(k=>k.name===c.table);return(0,o.jsxs)("section",{className:"mb-6",children:[(0,o.jsxs)("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[(0,o.jsx)("span",{className:"font-mono text-[13px] text-foreground",children:c.table===""?r("schema"):c.table}),j!==void 0&&(0,o.jsx)("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:r("{count} columns",{count:j.columns.length})}),c.changes.length>1&&(0,o.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:c.changes.length})]}),(0,o.jsx)("ul",{children:c.changes.map(k=>{let{action:N,kind:R}=st[k.type],O=k.severity==="breaking",q=Mt(k,R);return(0,o.jsxs)("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[(0,o.jsx)("span",{"aria-hidden":"true",className:se("-ms-3 h-3 w-0.5 shrink-0 self-center",O?"bg-destructive":"bg-transparent")}),(0,o.jsxs)("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[r(N)," ",R]}),q!==c.table&&(0,o.jsx)("span",{className:se("min-w-0 font-mono text-[13px]",O?"text-destructive":"text-foreground"),children:q}),O&&(0,o.jsx)("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:r("breaking")})]},`${k.type}-${k.summary}`)})})]},c.table)})})]})]})},"ce"),Ct=m(a=>se("-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",a?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"me"),la=m(a=>{let e=(0,me.c)(11),{initialShardKey:r}=a,n=oe(),[t,i]=(0,ce.useState)("diagram"),s;e[0]!==t?(s=m((h,x,p,v)=>(0,o.jsxs)("button",{"aria-selected":t===h,className:Ct(t===h),"data-testid":p,onClick:m(()=>{i(h)},"onClick"),role:"tab",type:"button",children:[x,v!==void 0&&(0,o.jsx)("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:v})]}),"i"),e[0]=t,e[1]=s):s=e[1];let d=s,u;e[2]!==n||e[3]!==d?(u=(0,o.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",n("Diagram"),"mg-pane-diagram"),d("changes",n("Changes"),"mg-pane-changes"),d("data",n("Data migrations"),"mg-pane-data")]}),e[2]=n,e[3]=d,e[4]=u):u=e[4];let f;e[5]!==r||e[6]!==t?(f=(0,o.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:t==="data"?(0,o.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:(0,o.jsx)(at,{initialShardKey:r})}):(0,o.jsx)(qt,{pane:t,shardKey:r})}),e[5]=r,e[6]=t,e[7]=f):f=e[7];let g;return e[8]!==u||e[9]!==f?(g=(0,o.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[u,f]}),e[8]=u,e[9]=f,e[10]=g):g=e[10],g},"je");export{la as MigrationsRoutePanel};
@@ -1 +1 @@
1
- import{c as k,d as S,e as T,f as w,h as X,i as B,j as E,k as L,l as g,m as G,n as I,o as O,p as W}from"./chunk-CU55Y5TV.js";import{d as j,l as q}from"./chunk-OG4N2XHD.js";import{a as x,e as C,g as F,h as H}from"./chunk-3XIESWL4.js";var K=C(F(),1);var e=C(H(),1);var R=50,$={value:{colors:{dark:["var(--chart-1)"],light:["var(--chart-1)"]},label:"value"}},z=x(o=>{let a=o.columns.find(t=>o.rows.length>0&&o.rows.every(l=>typeof l[t]=="number"))??null;return{label:o.columns.find(t=>t!==a)??null,value:a}},"I"),D=x(o=>{let a=(0,K.c)(3),{data:t,kind:l}=o,s;return a[0]!==t||a[1]!==l?(s=(0,e.jsx)(E,{className:"h-full w-full",config:$,children:l==="area"?(0,e.jsxs)(B,{data:t,children:[(0,e.jsx)(k,{vertical:!1}),(0,e.jsx)(w,{axisLine:!1,dataKey:"label",tickLine:!1}),(0,e.jsx)(g,{content:(0,e.jsx)(L,{})}),(0,e.jsx)(T,{dataKey:"value",fill:"var(--color-value-0)",fillOpacity:.2,stroke:"var(--color-value-0)",type:"monotone"})]}):(0,e.jsxs)(X,{data:t,children:[(0,e.jsx)(k,{vertical:!1}),(0,e.jsx)(w,{axisLine:!1,dataKey:"label",tickLine:!1}),(0,e.jsx)(g,{content:(0,e.jsx)(L,{})}),(0,e.jsx)(S,{dataKey:"value",dot:!1,stroke:"var(--color-value-0)",strokeWidth:2,type:"monotone"})]})}),a[0]=t,a[1]=l,a[2]=s):s=a[2],s},"W"),U=x(o=>{let a=(0,K.c)(21),{axes:t,result:l}=o,s=j(),u;a[0]!==l?(u=z(l),a[0]=l,a[1]=u):u=a[1];let N=u,m;a[2]!==l.columns?(m=new Set(l.columns),a[2]=l.columns,a[3]=m):m=a[3];let h=m,v=t!==void 0&&h.has(t.x)?t.x:N.label,f;a[4]!==t?.y||a[5]!==h?(f=t?.y.find(r=>h.has(r)),a[4]=t?.y,a[5]=h,a[6]=f):f=a[6];let A=f,d=A??N.value,p;a[7]!==v||a[8]!==l.rows||a[9]!==d?(p=d===null?[]:l.rows.slice(0,R).map((r,c)=>({label:v===null?`#${(c+1).toString()}`:q(r[v]),value:Number(r[d])||0})),a[7]=v,a[8]=l.rows,a[9]=d,a[10]=p):p=a[10];let y=p;if(d===null){let r;a[11]!==s?(r=s("No numeric column to chart."),a[11]=s,a[12]=r):r=a[12];let c;return a[13]!==r?(c=(0,e.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-chart-empty",children:r}),a[13]=r,a[14]=c):c=a[14],c}let n=t!==void 0&&A!==void 0?t.kind:"bar",i;a[15]!==y||a[16]!==n?(i=n==="bar"?(0,e.jsxs)(G,{className:"h-full w-full",config:$,data:y,children:[(0,e.jsx)(O,{dataKey:"label"}),(0,e.jsx)(I,{dataKey:"value"}),(0,e.jsx)(W,{})]}):(0,e.jsx)(D,{data:y,kind:n}),a[15]=y,a[16]=n,a[17]=i):i=a[17];let b;return a[18]!==n||a[19]!==i?(b=(0,e.jsx)("div",{className:"h-80 w-full p-3","data-chart-kind":n,"data-testid":"sql-chart",children:i}),a[18]=n,a[19]=i,a[20]=b):b=a[20],b},"R");export{U as a};
1
+ import{c as k,d as S,e as T,f as w,h as X,i as B,j as E,k as L,l as g,m as G,n as I,o as O,p as W}from"./chunk-AQKXMWNF.js";import{d as j,l as q}from"./chunk-OG4N2XHD.js";import{a as x,e as C,g as F,h as H}from"./chunk-3XIESWL4.js";var K=C(F(),1);var e=C(H(),1);var R=50,$={value:{colors:{dark:["var(--chart-1)"],light:["var(--chart-1)"]},label:"value"}},z=x(o=>{let a=o.columns.find(t=>o.rows.length>0&&o.rows.every(l=>typeof l[t]=="number"))??null;return{label:o.columns.find(t=>t!==a)??null,value:a}},"I"),D=x(o=>{let a=(0,K.c)(3),{data:t,kind:l}=o,s;return a[0]!==t||a[1]!==l?(s=(0,e.jsx)(E,{className:"h-full w-full",config:$,children:l==="area"?(0,e.jsxs)(B,{data:t,children:[(0,e.jsx)(k,{vertical:!1}),(0,e.jsx)(w,{axisLine:!1,dataKey:"label",tickLine:!1}),(0,e.jsx)(g,{content:(0,e.jsx)(L,{})}),(0,e.jsx)(T,{dataKey:"value",fill:"var(--color-value-0)",fillOpacity:.2,stroke:"var(--color-value-0)",type:"monotone"})]}):(0,e.jsxs)(X,{data:t,children:[(0,e.jsx)(k,{vertical:!1}),(0,e.jsx)(w,{axisLine:!1,dataKey:"label",tickLine:!1}),(0,e.jsx)(g,{content:(0,e.jsx)(L,{})}),(0,e.jsx)(S,{dataKey:"value",dot:!1,stroke:"var(--color-value-0)",strokeWidth:2,type:"monotone"})]})}),a[0]=t,a[1]=l,a[2]=s):s=a[2],s},"W"),U=x(o=>{let a=(0,K.c)(21),{axes:t,result:l}=o,s=j(),u;a[0]!==l?(u=z(l),a[0]=l,a[1]=u):u=a[1];let N=u,m;a[2]!==l.columns?(m=new Set(l.columns),a[2]=l.columns,a[3]=m):m=a[3];let h=m,v=t!==void 0&&h.has(t.x)?t.x:N.label,f;a[4]!==t?.y||a[5]!==h?(f=t?.y.find(r=>h.has(r)),a[4]=t?.y,a[5]=h,a[6]=f):f=a[6];let A=f,d=A??N.value,p;a[7]!==v||a[8]!==l.rows||a[9]!==d?(p=d===null?[]:l.rows.slice(0,R).map((r,c)=>({label:v===null?`#${(c+1).toString()}`:q(r[v]),value:Number(r[d])||0})),a[7]=v,a[8]=l.rows,a[9]=d,a[10]=p):p=a[10];let y=p;if(d===null){let r;a[11]!==s?(r=s("No numeric column to chart."),a[11]=s,a[12]=r):r=a[12];let c;return a[13]!==r?(c=(0,e.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-chart-empty",children:r}),a[13]=r,a[14]=c):c=a[14],c}let n=t!==void 0&&A!==void 0?t.kind:"bar",i;a[15]!==y||a[16]!==n?(i=n==="bar"?(0,e.jsxs)(G,{className:"h-full w-full",config:$,data:y,children:[(0,e.jsx)(O,{dataKey:"label"}),(0,e.jsx)(I,{dataKey:"value"}),(0,e.jsx)(W,{})]}):(0,e.jsx)(D,{data:y,kind:n}),a[15]=y,a[16]=n,a[17]=i):i=a[17];let b;return a[18]!==n||a[19]!==i?(b=(0,e.jsx)("div",{className:"h-80 w-full p-3","data-chart-kind":n,"data-testid":"sql-chart",children:i}),a[18]=n,a[19]=i,a[20]=b):b=a[20],b},"R");export{U as a};
@@ -1 +1 @@
1
- import{a as E}from"./chunk-54MMVNPT.js";import{c as w}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{b as $}from"./chunk-XDAT7LHC.js";import{f as b}from"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{a as j}from"./chunk-XQCVZAGU.js";import{a as z,b as B,c as C,d as g,e as n,f as i}from"./chunk-MIQTKZAR.js";import{a as S,e as I}from"./chunk-UZERI5YC.js";import{d as k,m as R,q as _}from"./chunk-OG4N2XHD.js";import"./chunk-AADILRJW.js";import{a as h,e as y,g as O,h as P}from"./chunk-3XIESWL4.js";var L=y(O(),1);var s=y(P(),1);var T=200,U=h(()=>{let e=(0,L.c)(21),l=b(),t=k(),u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=["lunora-auth-sessions",T],e[0]=u):u=e[0];let p;e[1]!==l?(p=h(()=>l.listAuthSessions({limit:T}),"u"),e[1]=l,e[2]=p):p=e[2];let o=$(u,p),{error:f}=o,a=o.data?.rows??null,x;e[3]!==o?(x=h(()=>{o.refetch()},"f"),e[3]=o,e[4]=x):x=e[4],E(x,!0);let N;e[5]!==l||e[6]!==o?(N=h(r=>{R((async()=>{await l.revokeAuthSession({sessionId:r}),o.refetch()})())},"x"),e[5]=l,e[6]=o,e[7]=N):N=e[7];let A=N,d;e[8]!==f?(d=f!==null&&(0,s.jsx)("p",{className:"text-sm text-destructive","data-testid":"auth-sessions-error",role:"alert",children:f}),e[8]=f,e[9]=d):d=e[9];let c;e[10]!==a||e[11]!==t?(c=a!==null&&a.length===0&&(0,s.jsx)(j,{testId:"auth-sessions-empty",title:t("No active sessions.")}),e[10]=a,e[11]=t,e[12]=c):c=e[12];let m;e[13]!==A||e[14]!==a||e[15]!==t?(m=a!==null&&a.length>0&&(0,s.jsx)(S,{className:"overflow-hidden py-0",children:(0,s.jsx)(I,{className:"px-0",children:(0,s.jsxs)(z,{"data-testid":"auth-sessions-table",children:[(0,s.jsx)(B,{children:(0,s.jsxs)(g,{children:[(0,s.jsx)(n,{children:t("user")}),(0,s.jsx)(n,{children:t("expires")}),(0,s.jsx)(n,{children:t("ip")}),(0,s.jsx)(n,{children:t("user agent")}),(0,s.jsx)(n,{children:t("impersonated by")}),(0,s.jsx)(n,{"aria-label":t("Actions")})]})}),(0,s.jsx)(C,{children:a.map(r=>(0,s.jsxs)(g,{"data-testid":`auth-session-${r.id}`,children:[(0,s.jsx)(i,{className:"font-mono text-xs",children:r.userId}),(0,s.jsx)(i,{className:"text-muted-foreground tabular-nums",children:_(r.expiresAt)}),(0,s.jsx)(i,{children:r.ipAddress??""}),(0,s.jsx)(i,{className:"max-w-40 truncate",children:r.userAgent??""}),(0,s.jsx)(i,{className:"font-mono text-xs",children:r.impersonatedBy??""}),(0,s.jsx)(i,{children:(0,s.jsx)(w,{"data-testid":`auth-session-revoke-${r.id}`,onClick:h(()=>{A(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:t("Revoke")})})]},r.id))})]})})}),e[13]=A,e[14]=a,e[15]=t,e[16]=m):m=e[16];let v;return e[17]!==d||e[18]!==c||e[19]!==m?(v=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"auth-sessions",children:[d,c,m]}),e[17]=d,e[18]=c,e[19]=m,e[20]=v):v=e[20],v},"Q");export{U as AuthSessionsPanel};
1
+ import{a as E}from"./chunk-54MMVNPT.js";import{c as w}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{b as $}from"./chunk-YGKR536O.js";import{f as b}from"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as j}from"./chunk-XQCVZAGU.js";import{a as z,b as B,c as C,d as g,e as n,f as i}from"./chunk-MIQTKZAR.js";import{a as S,e as I}from"./chunk-UZERI5YC.js";import{d as k,m as R,q as _}from"./chunk-OG4N2XHD.js";import"./chunk-QNUWWC3N.js";import{a as h,e as y,g as O,h as P}from"./chunk-3XIESWL4.js";var L=y(O(),1);var s=y(P(),1);var T=200,U=h(()=>{let e=(0,L.c)(21),l=b(),t=k(),u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=["lunora-auth-sessions",T],e[0]=u):u=e[0];let p;e[1]!==l?(p=h(()=>l.listAuthSessions({limit:T}),"u"),e[1]=l,e[2]=p):p=e[2];let o=$(u,p),{error:f}=o,a=o.data?.rows??null,x;e[3]!==o?(x=h(()=>{o.refetch()},"f"),e[3]=o,e[4]=x):x=e[4],E(x,!0);let N;e[5]!==l||e[6]!==o?(N=h(r=>{R((async()=>{await l.revokeAuthSession({sessionId:r}),o.refetch()})())},"x"),e[5]=l,e[6]=o,e[7]=N):N=e[7];let A=N,d;e[8]!==f?(d=f!==null&&(0,s.jsx)("p",{className:"text-sm text-destructive","data-testid":"auth-sessions-error",role:"alert",children:f}),e[8]=f,e[9]=d):d=e[9];let c;e[10]!==a||e[11]!==t?(c=a!==null&&a.length===0&&(0,s.jsx)(j,{testId:"auth-sessions-empty",title:t("No active sessions.")}),e[10]=a,e[11]=t,e[12]=c):c=e[12];let m;e[13]!==A||e[14]!==a||e[15]!==t?(m=a!==null&&a.length>0&&(0,s.jsx)(S,{className:"overflow-hidden py-0",children:(0,s.jsx)(I,{className:"px-0",children:(0,s.jsxs)(z,{"data-testid":"auth-sessions-table",children:[(0,s.jsx)(B,{children:(0,s.jsxs)(g,{children:[(0,s.jsx)(n,{children:t("user")}),(0,s.jsx)(n,{children:t("expires")}),(0,s.jsx)(n,{children:t("ip")}),(0,s.jsx)(n,{children:t("user agent")}),(0,s.jsx)(n,{children:t("impersonated by")}),(0,s.jsx)(n,{"aria-label":t("Actions")})]})}),(0,s.jsx)(C,{children:a.map(r=>(0,s.jsxs)(g,{"data-testid":`auth-session-${r.id}`,children:[(0,s.jsx)(i,{className:"font-mono text-xs",children:r.userId}),(0,s.jsx)(i,{className:"text-muted-foreground tabular-nums",children:_(r.expiresAt)}),(0,s.jsx)(i,{children:r.ipAddress??""}),(0,s.jsx)(i,{className:"max-w-40 truncate",children:r.userAgent??""}),(0,s.jsx)(i,{className:"font-mono text-xs",children:r.impersonatedBy??""}),(0,s.jsx)(i,{children:(0,s.jsx)(w,{"data-testid":`auth-session-revoke-${r.id}`,onClick:h(()=>{A(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:t("Revoke")})})]},r.id))})]})})}),e[13]=A,e[14]=a,e[15]=t,e[16]=m):m=e[16];let v;return e[17]!==d||e[18]!==c||e[19]!==m?(v=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"auth-sessions",children:[d,c,m]}),e[17]=d,e[18]=c,e[19]=m,e[20]=v):v=e[20],v},"Q");export{U as AuthSessionsPanel};
@@ -1 +1 @@
1
- import{a as st}from"./chunk-CTNB2KIA.js";import{a as X}from"./chunk-X665E2HU.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{a as Y}from"./chunk-LFKCLLPT.js";import"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as U}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as R}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as Z}from"./chunk-53WEPGUD.js";import"./chunk-XXQUMVWH.js";import"./chunk-RNL6BSFM.js";import"./chunk-QLQADHFE.js";import{a as V}from"./chunk-ERMTJYQF.js";import{c as Q}from"./chunk-XDAT7LHC.js";import"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{a as H}from"./chunk-XQCVZAGU.js";import{a as tt,b as et,c as rt,d as z,e as n,f as o}from"./chunk-MIQTKZAR.js";import{a as W,e as G}from"./chunk-UZERI5YC.js";import{d as O,q as J}from"./chunk-OG4N2XHD.js";import"./chunk-AADILRJW.js";import{a,e as K,f as mt,g as ht,h as ut,j as P}from"./chunk-3XIESWL4.js";var at=K(ht(),1),B=K(mt(),1);var e=K(ut(),1);var ft={action:"outline",mutation:"default",query:"secondary"},lt=a(r=>r<1e3?`${r<10?r.toFixed(1):Math.round(r).toString()}ms`:`${(r/1e3).toFixed(2)}s`,"O"),pt=a(r=>r.calls===0?"\u2014":r.errors===0?"0":`${r.errors.toString()} (${(r.errors/r.calls*100).toFixed(1)}%)`,"mt"),xt=a(r=>{let t=r.conflicts??0;return r.calls===0?"\u2014":t===0?"0":`${t.toString()} (${(t/r.calls*100).toFixed(1)}%)`},"ut"),gt={calls:a((r,t)=>t.calls-r.calls,"calls"),recent:a((r,t)=>t.lastCalledAt-r.lastCalledAt,"recent"),slowest:a((r,t)=>t.maxDurationMs-r.maxDurationMs,"slowest")},At=a(r=>{let t=(0,at.c)(47),{functions:A,initialShardKey:nt}=r,l=O(),[i,ot]=(0,B.useState)(nt??""),[c,it]=(0,B.useState)("recent"),M;t[0]!==i?(M=i.trim(),t[0]=i,t[1]=M):M=t[1];let j=Y(M,400),w;t[2]===Symbol.for("react.memo_cache_sentinel")?(w={},t[2]=w):w=t[2];let $;t[3]!==j?($={live:!0,shardKey:j},t[3]=j,t[4]=$):$=t[4];let{data:ct,error:d,errorSource:v,liveError:k}=Q(V.getFunctionStats,w,$),S=ct?.functions??null,C;t[5]!==A?(C=new Map((A??[]).map(Nt)),t[5]=A,t[6]=C):C=t[6];let L=C,F;t[7]===Symbol.for("react.memo_cache_sentinel")?(F=a(b=>{it(b.currentTarget.dataset.sort)},"C"),t[7]=F):F=t[7];let dt=F,D;if(t[8]!==d||t[9]!==v||t[10]!==L||t[11]!==k||t[12]!==i||t[13]!==c||t[14]!==S||t[15]!==l){let b=S===null?[]:S.toSorted(gt[c]),m;t[17]!==l?(m=l("Recent"),t[17]=l,t[18]=m):m=t[18];let h;t[19]!==m?(h={key:"recent",label:m},t[19]=m,t[20]=h):h=t[20];let u;t[21]!==l?(u=l("Most called"),t[21]=l,t[22]=u):u=t[22];let f;t[23]!==u?(f={key:"calls",label:u},t[23]=u,t[24]=f):f=t[24];let p;t[25]!==l?(p=l("Slowest"),t[25]=l,t[26]=p):p=t[26];let x;t[27]!==p?(x={key:"slowest",label:p},t[27]=p,t[28]=x):x=t[28];let I;t[29]!==f||t[30]!==x||t[31]!==h?(I=[h,f,x],t[29]=f,t[30]=x,t[31]=h,t[32]=I):I=t[32];let T=I,g;t[33]!==i?(g=(0,e.jsx)(X,{onChange:ot,testId:"fs-shard-input",value:i}),t[33]=i,t[34]=g):g=t[34];let N;t[35]!==k?(N=(0,e.jsx)(st,{message:k,prefix:"fs"}),t[35]=k,t[36]=N):N=t[36];let y;t[37]!==T||t[38]!==c?(y=(0,e.jsx)("div",{className:"ml-auto flex items-center gap-1",role:"group",children:T.map(s=>(0,e.jsx)(U,{"data-sort":s.key,"data-testid":`fs-sort-${s.key}`,onClick:dt,size:"sm",type:"button",variant:c===s.key?"secondary":"ghost",children:s.label},s.key))}),t[37]=T,t[38]=c,t[39]=y):y=t[39];let E;t[40]!==g||t[41]!==N||t[42]!==y?(E=(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[g,N,y]}),t[40]=g,t[41]=N,t[42]=y,t[43]=E):E=t[43];let _;t[44]!==d||t[45]!==v?(_=d!==null&&(0,e.jsx)(Z,{error:v,testId:"fs-error"}),t[44]=d,t[45]=v,t[46]=_):_=t[46],D=(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-stats",children:[E,_,S!==null&&b.length===0&&d===null&&(0,e.jsx)(H,{description:l("Per-function call counts, error rates, and latency land here after your first request."),icon:(0,e.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,e.jsx)("path",{d:"M3 3v18h18"}),(0,e.jsx)("path",{d:"M7 14l4-4 3 3 5-6"})]}),testId:"fs-empty",title:l("No functions have run on this shard yet.")}),b.length>0&&(0,e.jsx)(W,{className:"overflow-hidden py-0",children:(0,e.jsx)(G,{className:"px-0",children:(0,e.jsxs)(tt,{"data-testid":"fs-table",children:[(0,e.jsx)(et,{children:(0,e.jsxs)(z,{children:[(0,e.jsx)(n,{children:l("function")}),(0,e.jsx)(n,{children:l("kind")}),(0,e.jsx)(n,{className:"text-right",children:l("calls")}),(0,e.jsx)(n,{className:"text-right",children:l("errors")}),(0,e.jsx)(n,{className:"text-right",children:l("conflicts")}),(0,e.jsx)(n,{className:"text-right",children:l("avg")}),(0,e.jsx)(n,{className:"text-right",children:l("max")}),(0,e.jsx)(n,{children:l("last run")}),(0,e.jsx)(n,{children:l("last error")})]})}),(0,e.jsx)(rt,{children:b.map(s=>{let q=L.get(s.path);return(0,e.jsxs)(z,{"data-testid":`fs-row-${s.path}`,children:[(0,e.jsx)(o,{className:"font-medium",children:s.path}),(0,e.jsx)(o,{children:q===void 0?(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}):(0,e.jsx)(R,{variant:ft[q],children:q})}),(0,e.jsx)(o,{className:"text-right tabular-nums",children:s.calls}),(0,e.jsx)(o,{className:P("text-right tabular-nums",s.errors>0&&"text-destructive"),children:pt(s)}),(0,e.jsx)(o,{className:P("text-right tabular-nums",(s.conflicts??0)>0&&"text-warning"),children:xt(s)}),(0,e.jsx)(o,{className:"text-right tabular-nums",children:s.calls===0?"\u2014":lt(s.totalDurationMs/s.calls)}),(0,e.jsx)(o,{className:"text-right tabular-nums",children:s.calls===0?"\u2014":lt(s.maxDurationMs)}),(0,e.jsx)(o,{className:"text-muted-foreground",children:J(s.lastCalledAt,"\u2014")}),(0,e.jsx)(o,{className:"max-w-[24ch] truncate text-destructive",title:s.lastErrorMessage??void 0,children:s.lastErrorMessage??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},s.path)})})]})})})]}),t[8]=d,t[9]=v,t[10]=L,t[11]=k,t[12]=i,t[13]=c,t[14]=S,t[15]=l,t[16]=D}else D=t[16];return D},"Dt");function Nt(r){return[r.path,r.kind]}a(Nt,"ft");export{At as FunctionStatsPanel};
1
+ import{a as st}from"./chunk-CTNB2KIA.js";import{a as X}from"./chunk-X665E2HU.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{a as Y}from"./chunk-LFKCLLPT.js";import"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as U}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as R}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as Z}from"./chunk-AHVDZWB3.js";import"./chunk-XXQUMVWH.js";import"./chunk-VORDESEQ.js";import"./chunk-QLQADHFE.js";import{a as V}from"./chunk-ERMTJYQF.js";import{c as Q}from"./chunk-YGKR536O.js";import"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as H}from"./chunk-XQCVZAGU.js";import{a as tt,b as et,c as rt,d as z,e as n,f as o}from"./chunk-MIQTKZAR.js";import{a as W,e as G}from"./chunk-UZERI5YC.js";import{d as O,q as J}from"./chunk-OG4N2XHD.js";import"./chunk-QNUWWC3N.js";import{a,e as K,f as mt,g as ht,h as ut,j as P}from"./chunk-3XIESWL4.js";var at=K(ht(),1),B=K(mt(),1);var e=K(ut(),1);var ft={action:"outline",mutation:"default",query:"secondary"},lt=a(r=>r<1e3?`${r<10?r.toFixed(1):Math.round(r).toString()}ms`:`${(r/1e3).toFixed(2)}s`,"O"),pt=a(r=>r.calls===0?"\u2014":r.errors===0?"0":`${r.errors.toString()} (${(r.errors/r.calls*100).toFixed(1)}%)`,"mt"),xt=a(r=>{let t=r.conflicts??0;return r.calls===0?"\u2014":t===0?"0":`${t.toString()} (${(t/r.calls*100).toFixed(1)}%)`},"ut"),gt={calls:a((r,t)=>t.calls-r.calls,"calls"),recent:a((r,t)=>t.lastCalledAt-r.lastCalledAt,"recent"),slowest:a((r,t)=>t.maxDurationMs-r.maxDurationMs,"slowest")},At=a(r=>{let t=(0,at.c)(47),{functions:A,initialShardKey:nt}=r,l=O(),[i,ot]=(0,B.useState)(nt??""),[c,it]=(0,B.useState)("recent"),M;t[0]!==i?(M=i.trim(),t[0]=i,t[1]=M):M=t[1];let j=Y(M,400),w;t[2]===Symbol.for("react.memo_cache_sentinel")?(w={},t[2]=w):w=t[2];let $;t[3]!==j?($={live:!0,shardKey:j},t[3]=j,t[4]=$):$=t[4];let{data:ct,error:d,errorSource:v,liveError:k}=Q(V.getFunctionStats,w,$),S=ct?.functions??null,C;t[5]!==A?(C=new Map((A??[]).map(Nt)),t[5]=A,t[6]=C):C=t[6];let L=C,F;t[7]===Symbol.for("react.memo_cache_sentinel")?(F=a(b=>{it(b.currentTarget.dataset.sort)},"C"),t[7]=F):F=t[7];let dt=F,D;if(t[8]!==d||t[9]!==v||t[10]!==L||t[11]!==k||t[12]!==i||t[13]!==c||t[14]!==S||t[15]!==l){let b=S===null?[]:S.toSorted(gt[c]),m;t[17]!==l?(m=l("Recent"),t[17]=l,t[18]=m):m=t[18];let h;t[19]!==m?(h={key:"recent",label:m},t[19]=m,t[20]=h):h=t[20];let u;t[21]!==l?(u=l("Most called"),t[21]=l,t[22]=u):u=t[22];let f;t[23]!==u?(f={key:"calls",label:u},t[23]=u,t[24]=f):f=t[24];let p;t[25]!==l?(p=l("Slowest"),t[25]=l,t[26]=p):p=t[26];let x;t[27]!==p?(x={key:"slowest",label:p},t[27]=p,t[28]=x):x=t[28];let I;t[29]!==f||t[30]!==x||t[31]!==h?(I=[h,f,x],t[29]=f,t[30]=x,t[31]=h,t[32]=I):I=t[32];let T=I,g;t[33]!==i?(g=(0,e.jsx)(X,{onChange:ot,testId:"fs-shard-input",value:i}),t[33]=i,t[34]=g):g=t[34];let N;t[35]!==k?(N=(0,e.jsx)(st,{message:k,prefix:"fs"}),t[35]=k,t[36]=N):N=t[36];let y;t[37]!==T||t[38]!==c?(y=(0,e.jsx)("div",{className:"ml-auto flex items-center gap-1",role:"group",children:T.map(s=>(0,e.jsx)(U,{"data-sort":s.key,"data-testid":`fs-sort-${s.key}`,onClick:dt,size:"sm",type:"button",variant:c===s.key?"secondary":"ghost",children:s.label},s.key))}),t[37]=T,t[38]=c,t[39]=y):y=t[39];let E;t[40]!==g||t[41]!==N||t[42]!==y?(E=(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[g,N,y]}),t[40]=g,t[41]=N,t[42]=y,t[43]=E):E=t[43];let _;t[44]!==d||t[45]!==v?(_=d!==null&&(0,e.jsx)(Z,{error:v,testId:"fs-error"}),t[44]=d,t[45]=v,t[46]=_):_=t[46],D=(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-stats",children:[E,_,S!==null&&b.length===0&&d===null&&(0,e.jsx)(H,{description:l("Per-function call counts, error rates, and latency land here after your first request."),icon:(0,e.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,e.jsx)("path",{d:"M3 3v18h18"}),(0,e.jsx)("path",{d:"M7 14l4-4 3 3 5-6"})]}),testId:"fs-empty",title:l("No functions have run on this shard yet.")}),b.length>0&&(0,e.jsx)(W,{className:"overflow-hidden py-0",children:(0,e.jsx)(G,{className:"px-0",children:(0,e.jsxs)(tt,{"data-testid":"fs-table",children:[(0,e.jsx)(et,{children:(0,e.jsxs)(z,{children:[(0,e.jsx)(n,{children:l("function")}),(0,e.jsx)(n,{children:l("kind")}),(0,e.jsx)(n,{className:"text-right",children:l("calls")}),(0,e.jsx)(n,{className:"text-right",children:l("errors")}),(0,e.jsx)(n,{className:"text-right",children:l("conflicts")}),(0,e.jsx)(n,{className:"text-right",children:l("avg")}),(0,e.jsx)(n,{className:"text-right",children:l("max")}),(0,e.jsx)(n,{children:l("last run")}),(0,e.jsx)(n,{children:l("last error")})]})}),(0,e.jsx)(rt,{children:b.map(s=>{let q=L.get(s.path);return(0,e.jsxs)(z,{"data-testid":`fs-row-${s.path}`,children:[(0,e.jsx)(o,{className:"font-medium",children:s.path}),(0,e.jsx)(o,{children:q===void 0?(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}):(0,e.jsx)(R,{variant:ft[q],children:q})}),(0,e.jsx)(o,{className:"text-right tabular-nums",children:s.calls}),(0,e.jsx)(o,{className:P("text-right tabular-nums",s.errors>0&&"text-destructive"),children:pt(s)}),(0,e.jsx)(o,{className:P("text-right tabular-nums",(s.conflicts??0)>0&&"text-warning"),children:xt(s)}),(0,e.jsx)(o,{className:"text-right tabular-nums",children:s.calls===0?"\u2014":lt(s.totalDurationMs/s.calls)}),(0,e.jsx)(o,{className:"text-right tabular-nums",children:s.calls===0?"\u2014":lt(s.maxDurationMs)}),(0,e.jsx)(o,{className:"text-muted-foreground",children:J(s.lastCalledAt,"\u2014")}),(0,e.jsx)(o,{className:"max-w-[24ch] truncate text-destructive",title:s.lastErrorMessage??void 0,children:s.lastErrorMessage??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},s.path)})})]})})})]}),t[8]=d,t[9]=v,t[10]=L,t[11]=k,t[12]=i,t[13]=c,t[14]=S,t[15]=l,t[16]=D}else D=t[16];return D},"Dt");function Nt(r){return[r.path,r.kind]}a(Nt,"ft");export{At as FunctionStatsPanel};
@@ -1 +1 @@
1
- import{a as f}from"./chunk-5Y3QLNWX.js";import{a as U}from"./chunk-54MMVNPT.js";import{a as C}from"./chunk-QXXIJAD5.js";import{R as v}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as O}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as L}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as w}from"./chunk-ERMTJYQF.js";import{f as P}from"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{d as q,f as y,g as c,h,m as p}from"./chunk-OG4N2XHD.js";import"./chunk-AADILRJW.js";import{a as o,e as T,f as W,h as $}from"./chunk-3XIESWL4.js";var a=T(W(),1);var e=T($(),1);var R=y(w.getPitrBookmark),V=y(w.pitrRestore),ne=o(({initialShardKey:j})=>{let m=P(),r=q(),i=j??"",[z,x]=(0,a.useState)(null),[l,A]=(0,a.useState)(""),[B,I]=(0,a.useState)(null),[u,D]=(0,a.useState)(""),[k,E]=(0,a.useState)(!1),[s,K]=(0,a.useState)(null),[F,n]=(0,a.useState)(null),[b,d]=(0,a.useState)(!1),g=(0,a.useCallback)(async()=>{d(!0),n(null);try{let t=await m.query(R,{},c(i));x(t.current)}catch(t){n(h(t))}d(!1)},[m,i]);(0,a.useEffect)(()=>{p(g())},[g]),U(()=>{p((async()=>{try{let t=await m.query(R,{},c(i));x(t.current)}catch{}})())},!0);let M=o(t=>{A(t.target.value)},"U"),Z=o(t=>{D(t.target.value)},"j"),_=o(t=>{E(t.target.checked)},"M"),G=o(()=>{l.trim()!==""&&p((async()=>{d(!0),n(null);try{let t=await m.query(R,{time:l.trim()},c(i));I(t.forTime??null),x(t.current)}catch(t){I(null),n(h(t))}d(!1)})())},"z"),S=o(t=>{p((async()=>{d(!0),n(null);try{let N=await m.mutation(V,t,c(i));K(N),await g()}catch(N){n(h(N))}d(!1)})())},"R"),H=u.trim()!==""||l.trim()!=="",J=o(()=>{let t=k?{restart:!0}:{};u.trim()===""?t.time=l.trim():t.bookmark=u.trim(),S(t)},"$"),Q=o(()=>{s!==null&&S(k?{bookmark:s.undoBookmark,restart:!0}:{bookmark:s.undoBookmark})},"D");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-pitr",children:[(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[r("Shard"),": ",(0,e.jsx)("span",{className:"font-mono",children:i===""?r("root"):i})]})}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"pitr-note",children:r("In-place recovery to any moment in the last 30 days. For older or portable recovery, use the snapshot backup tier.")}),F!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"pitr-error",role:"alert",children:F}),(0,e.jsxs)("section",{className:"rounded-xl border border-border bg-card p-3 shadow-xs",children:[(0,e.jsx)("h3",{className:"mb-2 text-sm font-semibold",children:r("Current bookmark")}),(0,e.jsx)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-current",children:z??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]}),(0,e.jsxs)("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-3 shadow-xs",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold",children:r("Restore")}),(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)(f,{htmlFor:"pitr-time",children:r("Time (ISO or epoch-ms, last 30 days)")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(v,{"data-testid":"pitr-time",id:"pitr-time",onChange:M,placeholder:"2026-06-01T00:00:00.000Z",value:l}),(0,e.jsx)(O,{"data-testid":"pitr-preview",disabled:b||l.trim()==="",onClick:G,size:"sm",type:"button",variant:"outline",children:r("Preview")})]}),B!==null&&(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-preview-bookmark",children:[r("Bookmark for that time"),": ",B]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)(f,{htmlFor:"pitr-bookmark",children:r("Or an explicit bookmark (wins over time)")}),(0,e.jsx)(v,{"data-testid":"pitr-bookmark",id:"pitr-bookmark",onChange:Z,placeholder:r("bookmark string"),value:u})]}),(0,e.jsxs)(f,{className:"flex items-center gap-2 text-xs font-normal text-muted-foreground",htmlFor:"pitr-restart",children:[(0,e.jsx)("input",{checked:k,className:"size-4 accent-primary","data-testid":"pitr-restart",id:"pitr-restart",onChange:_,type:"checkbox"}),r("Restart the shard now so recovery applies immediately")]}),(0,e.jsx)("div",{children:(0,e.jsx)(C,{confirmLabel:r("Confirm restore"),disabled:b||!H,onConfirm:J,testId:"pitr-restore",children:r("Restore")})})]}),s!==null&&(0,e.jsxs)("section",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs","data-testid":"pitr-result",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold",children:r("Restore armed")}),(0,e.jsx)(L,{variant:s.restarted?"destructive":"secondary",children:s.restarted?r("restarted now"):r("on next restart")})]}),(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground",children:[r("Restored to"),": ",s.restoredTo]}),(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-undo-bookmark",children:[r("Undo bookmark"),": ",s.undoBookmark]}),(0,e.jsx)("div",{children:(0,e.jsx)(C,{confirmLabel:r("Confirm undo"),disabled:b,onConfirm:Q,testId:"pitr-undo",children:r("Undo restore")})})]})]})},"de");export{ne as PitrPanel};
1
+ import{a as f}from"./chunk-5Y3QLNWX.js";import{a as U}from"./chunk-54MMVNPT.js";import{a as C}from"./chunk-QXXIJAD5.js";import{R as v}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as O}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as L}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as w}from"./chunk-ERMTJYQF.js";import{f as P}from"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{d as q,f as y,g as c,h,m as p}from"./chunk-OG4N2XHD.js";import"./chunk-QNUWWC3N.js";import{a as o,e as T,f as W,h as $}from"./chunk-3XIESWL4.js";var a=T(W(),1);var e=T($(),1);var R=y(w.getPitrBookmark),V=y(w.pitrRestore),ne=o(({initialShardKey:j})=>{let m=P(),r=q(),i=j??"",[z,x]=(0,a.useState)(null),[l,A]=(0,a.useState)(""),[B,I]=(0,a.useState)(null),[u,D]=(0,a.useState)(""),[k,E]=(0,a.useState)(!1),[s,K]=(0,a.useState)(null),[F,n]=(0,a.useState)(null),[b,d]=(0,a.useState)(!1),g=(0,a.useCallback)(async()=>{d(!0),n(null);try{let t=await m.query(R,{},c(i));x(t.current)}catch(t){n(h(t))}d(!1)},[m,i]);(0,a.useEffect)(()=>{p(g())},[g]),U(()=>{p((async()=>{try{let t=await m.query(R,{},c(i));x(t.current)}catch{}})())},!0);let M=o(t=>{A(t.target.value)},"U"),Z=o(t=>{D(t.target.value)},"j"),_=o(t=>{E(t.target.checked)},"M"),G=o(()=>{l.trim()!==""&&p((async()=>{d(!0),n(null);try{let t=await m.query(R,{time:l.trim()},c(i));I(t.forTime??null),x(t.current)}catch(t){I(null),n(h(t))}d(!1)})())},"z"),S=o(t=>{p((async()=>{d(!0),n(null);try{let N=await m.mutation(V,t,c(i));K(N),await g()}catch(N){n(h(N))}d(!1)})())},"R"),H=u.trim()!==""||l.trim()!=="",J=o(()=>{let t=k?{restart:!0}:{};u.trim()===""?t.time=l.trim():t.bookmark=u.trim(),S(t)},"$"),Q=o(()=>{s!==null&&S(k?{bookmark:s.undoBookmark,restart:!0}:{bookmark:s.undoBookmark})},"D");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-pitr",children:[(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[r("Shard"),": ",(0,e.jsx)("span",{className:"font-mono",children:i===""?r("root"):i})]})}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"pitr-note",children:r("In-place recovery to any moment in the last 30 days. For older or portable recovery, use the snapshot backup tier.")}),F!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"pitr-error",role:"alert",children:F}),(0,e.jsxs)("section",{className:"rounded-xl border border-border bg-card p-3 shadow-xs",children:[(0,e.jsx)("h3",{className:"mb-2 text-sm font-semibold",children:r("Current bookmark")}),(0,e.jsx)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-current",children:z??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]}),(0,e.jsxs)("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-3 shadow-xs",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold",children:r("Restore")}),(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)(f,{htmlFor:"pitr-time",children:r("Time (ISO or epoch-ms, last 30 days)")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(v,{"data-testid":"pitr-time",id:"pitr-time",onChange:M,placeholder:"2026-06-01T00:00:00.000Z",value:l}),(0,e.jsx)(O,{"data-testid":"pitr-preview",disabled:b||l.trim()==="",onClick:G,size:"sm",type:"button",variant:"outline",children:r("Preview")})]}),B!==null&&(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-preview-bookmark",children:[r("Bookmark for that time"),": ",B]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)(f,{htmlFor:"pitr-bookmark",children:r("Or an explicit bookmark (wins over time)")}),(0,e.jsx)(v,{"data-testid":"pitr-bookmark",id:"pitr-bookmark",onChange:Z,placeholder:r("bookmark string"),value:u})]}),(0,e.jsxs)(f,{className:"flex items-center gap-2 text-xs font-normal text-muted-foreground",htmlFor:"pitr-restart",children:[(0,e.jsx)("input",{checked:k,className:"size-4 accent-primary","data-testid":"pitr-restart",id:"pitr-restart",onChange:_,type:"checkbox"}),r("Restart the shard now so recovery applies immediately")]}),(0,e.jsx)("div",{children:(0,e.jsx)(C,{confirmLabel:r("Confirm restore"),disabled:b||!H,onConfirm:J,testId:"pitr-restore",children:r("Restore")})})]}),s!==null&&(0,e.jsxs)("section",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs","data-testid":"pitr-result",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold",children:r("Restore armed")}),(0,e.jsx)(L,{variant:s.restarted?"destructive":"secondary",children:s.restarted?r("restarted now"):r("on next restart")})]}),(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground",children:[r("Restored to"),": ",s.restoredTo]}),(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-undo-bookmark",children:[r("Undo bookmark"),": ",s.undoBookmark]}),(0,e.jsx)("div",{children:(0,e.jsx)(C,{confirmLabel:r("Confirm undo"),disabled:b,onConfirm:Q,testId:"pitr-undo",children:r("Undo restore")})})]})]})},"de");export{ne as PitrPanel};