@lunora/studio 1.0.0-alpha.336 → 1.0.0-alpha.338

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 (82) hide show
  1. package/dist/index.d.mts +4 -2
  2. package/dist/index.d.ts +4 -2
  3. package/dist/index.mjs +1 -1
  4. package/dist/packem_chunks/ApiTab.mjs +1 -1
  5. package/dist/packem_chunks/SchemaViewer.mjs +1 -1
  6. package/dist/packem_chunks/SqlEditorPanel.mjs +8 -8
  7. package/dist/packem_chunks/migrations-route.mjs +1 -1
  8. package/dist/packem_shared/OpenRpcReferencePanel-nYyfjjse.mjs +1 -0
  9. package/dist/packem_shared/schema-diagram-ghsOCED7.mjs +2 -0
  10. package/dist/standalone/{chunk-VQH2F33R.js → chunk-2JD6VLW7.js} +1 -1
  11. package/dist/standalone/{chunk-6K7ZB6M6.js → chunk-2OOWQRI5.js} +1 -1
  12. package/dist/standalone/{chunk-3EFAEGID.js → chunk-3DNOCE5K.js} +1 -1
  13. package/dist/standalone/{chunk-7XBIOLIW.js → chunk-3FRBAQI7.js} +1 -1
  14. package/dist/standalone/chunk-3JVXNEBO.js +7 -0
  15. package/dist/standalone/{chunk-KT4UNIZB.js → chunk-4KMJQGIN.js} +1 -1
  16. package/dist/standalone/{chunk-EA2RNGEE.js → chunk-4ZISAQ2B.js} +1 -1
  17. package/dist/standalone/{chunk-JNW2ARJO.js → chunk-5B4SQYIP.js} +1 -1
  18. package/dist/standalone/{chunk-AWGYECJN.js → chunk-5NCDYUAL.js} +1 -1
  19. package/dist/standalone/chunk-6LNSHLOB.js +15 -0
  20. package/dist/standalone/{chunk-IIIYLX6U.js → chunk-7LPVTOAF.js} +1 -1
  21. package/dist/standalone/{chunk-TKMI2XAK.js → chunk-7VF6QXGR.js} +1 -1
  22. package/dist/standalone/{chunk-3APWNQJ3.js → chunk-7WWDCRLQ.js} +1 -1
  23. package/dist/standalone/{chunk-SL7YMFRX.js → chunk-AHQIBM3C.js} +1 -1
  24. package/dist/standalone/{chunk-NRAAYZ4C.js → chunk-BAWEGZ7T.js} +3 -3
  25. package/dist/standalone/{chunk-EOCVVABQ.js → chunk-BCGCD4CO.js} +1 -1
  26. package/dist/standalone/{chunk-2OSBOZSF.js → chunk-CG7AWLQB.js} +1 -1
  27. package/dist/standalone/{chunk-35LRTD6L.js → chunk-CHYVUB6Y.js} +1 -1
  28. package/dist/standalone/{chunk-ZFW3QEVE.js → chunk-CMVOO3MU.js} +1 -1
  29. package/dist/standalone/{chunk-HFR5DYKT.js → chunk-DW67E5WI.js} +1 -1
  30. package/dist/standalone/{chunk-T4Y5DPRN.js → chunk-DXC6YGNT.js} +1 -1
  31. package/dist/standalone/{chunk-FKS6EUNJ.js → chunk-EFT6JH6H.js} +1 -1
  32. package/dist/standalone/{chunk-T6J6Q5Q2.js → chunk-EJ7YAEPM.js} +1 -1
  33. package/dist/standalone/{chunk-FYW6TV4Q.js → chunk-G2YF7RNG.js} +1 -1
  34. package/dist/standalone/{chunk-CS7K5PAU.js → chunk-G5DO7HSE.js} +1 -1
  35. package/dist/standalone/{chunk-HD2IF5L4.js → chunk-GABRCO5N.js} +1 -1
  36. package/dist/standalone/{chunk-R36PEHB2.js → chunk-GDD7FNZA.js} +1 -1
  37. package/dist/standalone/{chunk-SHCUZSRI.js → chunk-GNX7VKQY.js} +1 -1
  38. package/dist/standalone/{chunk-KVEG7CIS.js → chunk-H4BEW5RF.js} +1 -1
  39. package/dist/standalone/{chunk-Z643LPA5.js → chunk-H6MI6GGH.js} +1 -1
  40. package/dist/standalone/{chunk-3VI2EZN2.js → chunk-HC6E6BIJ.js} +1 -1
  41. package/dist/standalone/{chunk-VOLGQ2EF.js → chunk-JIWDKEGI.js} +1 -1
  42. package/dist/standalone/chunk-KRSOII6O.js +1 -0
  43. package/dist/standalone/{chunk-BOUF5HG7.js → chunk-LQM7KUEA.js} +1 -1
  44. package/dist/standalone/{chunk-AX2GEOKC.js → chunk-LVNRJL4S.js} +1 -1
  45. package/dist/standalone/{chunk-5AXRIRHW.js → chunk-LXQGF74P.js} +1 -1
  46. package/dist/standalone/{chunk-XC2LTW44.js → chunk-M27YVZWM.js} +1 -1
  47. package/dist/standalone/{chunk-JT3XCMAO.js → chunk-MFUYHLXW.js} +1 -1
  48. package/dist/standalone/{chunk-MC44447W.js → chunk-NQZ5IJWF.js} +1 -1
  49. package/dist/standalone/{chunk-YSPQIRER.js → chunk-NWWMHMGA.js} +1 -1
  50. package/dist/standalone/{chunk-3DRBFZ2R.js → chunk-O75FH2VA.js} +1 -1
  51. package/dist/standalone/{chunk-7COKTU5I.js → chunk-OPXOPRI2.js} +1 -1
  52. package/dist/standalone/{chunk-ZRFRFHRU.js → chunk-OYDOFRRB.js} +1 -1
  53. package/dist/standalone/{chunk-5UDEPHRK.js → chunk-Q5CSRWLU.js} +1 -1
  54. package/dist/standalone/{chunk-7FTJLXZH.js → chunk-QYLNHUWI.js} +1 -1
  55. package/dist/standalone/{chunk-ZPYEW5ZL.js → chunk-QZFWP5PG.js} +1 -1
  56. package/dist/standalone/{chunk-AUUB5SEX.js → chunk-ROX3SLF7.js} +1 -1
  57. package/dist/standalone/{chunk-LVKT5NQQ.js → chunk-RZAWVHB7.js} +1 -1
  58. package/dist/standalone/{chunk-VHL2HNC5.js → chunk-SKTCA3PL.js} +1 -1
  59. package/dist/standalone/{chunk-XN2YDTTH.js → chunk-STF2OPKL.js} +1 -1
  60. package/dist/standalone/{chunk-BPDWF4EX.js → chunk-TNXRQCSI.js} +1 -1
  61. package/dist/standalone/{chunk-3SSDUHUE.js → chunk-UEHILSMN.js} +1 -1
  62. package/dist/standalone/{chunk-L5UNLRGK.js → chunk-UQJRKAQX.js} +1 -1
  63. package/dist/standalone/{chunk-SBDEC37M.js → chunk-V65TMRRH.js} +1 -1
  64. package/dist/standalone/{chunk-P7I3HBJN.js → chunk-VTLEHQAN.js} +1 -1
  65. package/dist/standalone/{chunk-YHTANVUO.js → chunk-VVB3GENM.js} +2 -2
  66. package/dist/standalone/{chunk-BUH67LRI.js → chunk-VVGQZR53.js} +1 -1
  67. package/dist/standalone/{chunk-L3NY3CEL.js → chunk-VVRT5OAX.js} +1 -1
  68. package/dist/standalone/{chunk-5OGXAO7S.js → chunk-W77PDXGW.js} +1 -1
  69. package/dist/standalone/{chunk-Q5KTZWZ2.js → chunk-WYP2Z35M.js} +6 -6
  70. package/dist/standalone/{chunk-W4CQMJH3.js → chunk-XSW4R2MI.js} +1 -1
  71. package/dist/standalone/{chunk-3LD7PBIC.js → chunk-YGV4V7VT.js} +1 -1
  72. package/dist/standalone/{chunk-6XRGQ3ND.js → chunk-YI7WVSMX.js} +1 -1
  73. package/dist/standalone/{chunk-XBTCFWYG.js → chunk-YJ5SU2PD.js} +1 -1
  74. package/dist/standalone/{chunk-6RYVH5BG.js → chunk-YXW7GATV.js} +1 -1
  75. package/dist/standalone/{chunk-MW6W7DGV.js → chunk-Z277L2BQ.js} +1 -1
  76. package/dist/standalone/studio.js +1 -1
  77. package/package.json +5 -5
  78. package/dist/packem_shared/OpenRpcReferencePanel-CPIr-u-J.mjs +0 -1
  79. package/dist/packem_shared/schema-diagram-LRfchcoA.mjs +0 -2
  80. package/dist/standalone/chunk-EQRZJZD4.js +0 -7
  81. package/dist/standalone/chunk-GW4GGPRY.js +0 -15
  82. package/dist/standalone/chunk-IKT6EYHN.js +0 -1
@@ -1 +1 @@
1
- import{a as He}from"./chunk-CGQMJYCW.js";import{a as Se}from"./chunk-37WYCOQ2.js";import{a as Ge}from"./chunk-ZRFRFHRU.js";import{a as qe}from"./chunk-LXCVA5SP.js";import{i as Ue}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as $e}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as Ze}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as je}from"./chunk-4ZEL6BYL.js";import{l as Ke}from"./chunk-EQRZJZD4.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{d as Pe,f as Fe,g as me,h as Ce,i as Oe,q as Re}from"./chunk-74IYYDDI.js";import{a as s,d as Me,e as ot,f as at,g as lt}from"./chunk-I26MS5PJ.js";var De=Me(at(),1);var m=Me(ot(),1);var r=Me(lt(),1);var ze=Fe(je.getPitrBookmark),st=Fe(je.pitrRestore),nt=/^\d+$/u,Je=s(ie=>{let e=ie.trim(),h=nt.test(e)?Number(e):Date.parse(e),l=new Date(h);return Number.isNaN(l.getTime())?void 0:{epochMs:h,iso:l.toISOString()}},"De"),it=s(ie=>{let e=(0,De.c)(9),{text:h}=ie,l=Pe();if(h.trim()==="")return null;let t,o,p;if(e[0]!==l||e[1]!==h){let y=Je(h);t="font-mono text-xs text-muted-foreground",o="pitr-time-resolved",p=y===void 0?l("Not a time \u2014 use epoch-ms or ISO 8601."):l("Resolves to {instant} (a date-time without an offset is read in this browser's time zone; a bare date is UTC)",{instant:y.iso}),e[0]=l,e[1]=h,e[2]=t,e[3]=o,e[4]=p}else t=e[2],o=e[3],p=e[4];let N;return e[5]!==t||e[6]!==o||e[7]!==p?(N=(0,r.jsx)("p",{className:t,"data-testid":o,children:p}),e[5]=t,e[6]=o,e[7]=p,e[8]=N):N=e[8],N},"lt"),vt=s(ie=>{let e=(0,De.c)(140),{initialShardKey:h}=ie,l=Ke(),t=Pe(),o=h??"",p=He(o),[N,y]=(0,m.useState)(null),[f,Qe]=(0,m.useState)(""),[ce,Ee]=(0,m.useState)(null),[c,We]=(0,m.useState)(""),[b,Xe]=(0,m.useState)(!1),[i,Ye]=(0,m.useState)(null),[ue,w]=(0,m.useState)(null),[de,I]=(0,m.useState)(!1),[C,Ve]=(0,m.useState)(!1),pe;e[0]!==l||e[1]!==o?(pe=s(async a=>{I(!0),w(null);let d;try{d={current:(await l.query(ze,{},me(o))).current,error:null,unavailable:!1}}catch(n){let g=n;d={current:null,error:Ce(g),unavailable:Oe(g)==="PITR_UNAVAILABLE"}}a?.aborted!==!0&&(d.error===null?y(d.current):w(d.error),Ve(d.unavailable),I(!1))},"fe"),e[0]=l,e[1]=o,e[2]=pe):pe=e[2];let x=pe,he,fe;e[3]!==x?(he=s(()=>{let a=new AbortController;return Re(x(a.signal)),()=>{a.abort()}},"ue"),fe=[x],e[3]=x,e[4]=he,e[5]=fe):(he=e[4],fe=e[5]),(0,m.useEffect)(he,fe);let be;e[6]!==l||e[7]!==o?(be=s(async()=>{let a=await l.query(ze,{},me(o));y(a.current)},"he"),e[6]=l,e[7]=o,e[8]=be):be=e[8],Ge(be,!C);let xe;e[9]===Symbol.for("react.memo_cache_sentinel")?(xe=s(a=>{Qe(a.target.value)},"be"),e[9]=xe):xe=e[9];let et=xe,ke;e[10]===Symbol.for("react.memo_cache_sentinel")?(ke=s(a=>{We(a.target.value)},"xe"),e[10]=ke):ke=e[10];let tt=ke,Ne;e[11]===Symbol.for("react.memo_cache_sentinel")?(Ne=s(a=>{Xe(a.target.checked)},"ke"),e[11]=Ne):Ne=e[11];let rt=Ne,ve,R,u,k,v,ge;if(e[12]!==c||e[13]!==l||e[14]!==ce||e[15]!==x||e[16]!==o||e[17]!==p||e[18]!==t||e[19]!==f){u=Je(f),R=s(()=>{if(u===void 0)return;let d=o;Re((async()=>{I(!0),w(null);let n;try{n={result:await l.query(ze,{time:u.epochMs},me(d))}}catch(g){n={error:Ce(g)}}p.current===d&&("result"in n?(Ee(n.result.forTime===void 0?null:{bookmark:n.result.forTime,shard:d}),y(n.result.current)):(Ee(null),w(n.error)),I(!1))})())},"C"),v=ce?.shard===o?ce.bookmark:null;let a;e[26]!==l||e[27]!==x||e[28]!==o?(a=s(d=>{Re((async()=>{I(!0),w(null);try{let n=await l.mutation(st,d,me(o));Ye(n),await x()}catch(n){let g=n;w(Ce(g)),Oe(g)==="PITR_UNAVAILABLE"&&Ve(!0)}I(!1)})())},"o"),e[26]=l,e[27]=x,e[28]=o,e[29]=a):a=e[29],k=a,ve=c.trim()!==""||u!==void 0,ge=t("Restore {shard} to {target}?",{shard:o===""?t("root"):o,target:c.trim()===""?u?.iso??"":t("the given bookmark")}),e[12]=c,e[13]=l,e[14]=ce,e[15]=x,e[16]=o,e[17]=p,e[18]=t,e[19]=f,e[20]=ve,e[21]=R,e[22]=u,e[23]=k,e[24]=v,e[25]=ge}else ve=e[20],R=e[21],u=e[22],k=e[23],v=e[24],ge=e[25];let Te=ge,ye;e[30]!==c||e[31]!==u?.epochMs||e[32]!==b||e[33]!==k?(ye=s(()=>{let a=b?{restart:!0}:{};c.trim()===""?a.time=u?.epochMs:a.bookmark=c.trim(),k(a)},"Ne"),e[30]=c,e[31]=u?.epochMs,e[32]=b,e[33]=k,e[34]=ye):ye=e[34];let Be=ye,we;e[35]!==b||e[36]!==i||e[37]!==k?(we=s(()=>{i!==null&&k(b?{bookmark:i.undoBookmark,restart:!0}:{bookmark:i.undoBookmark})},"ye"),e[35]=b,e[36]=i,e[37]=k,e[38]=we):we=e[38];let Ae=we,S;e[39]!==t?(S=t("Shard"),e[39]=t,e[40]=S):S=e[40];let T;e[41]!==o||e[42]!==t?(T=o===""?t("root"):o,e[41]=o,e[42]=t,e[43]=T):T=e[43];let B;e[44]!==T?(B=(0,r.jsx)("span",{className:"font-mono",children:T}),e[44]=T,e[45]=B):B=e[45];let A;e[46]!==S||e[47]!==B?(A=(0,r.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[S,": ",B]})}),e[46]=S,e[47]=B,e[48]=A):A=e[48];let _;e[49]!==t?(_=t("In-place recovery to any moment in the last 30 days. For older or portable recovery, use the snapshot backup tier."),e[49]=t,e[50]=_):_=e[50];let L;e[51]!==_?(L=(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"pitr-note",children:_}),e[51]=_,e[52]=L):L=e[52];let M;e[53]!==ue?(M=ue!==null&&(0,r.jsx)("p",{className:"text-sm text-destructive","data-testid":"pitr-error",role:"alert",children:ue}),e[53]=ue,e[54]=M):M=e[54];let P;e[55]!==t?(P=t("Current bookmark"),e[55]=t,e[56]=P):P=e[56];let U;e[57]!==P?(U=(0,r.jsx)("h3",{className:"mb-2 text-sm font-semibold",children:P}),e[57]=P,e[58]=U):U=e[58];let F;e[59]!==N?(F=N??(0,r.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),e[59]=N,e[60]=F):F=e[60];let O;e[61]!==F?(O=(0,r.jsx)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-current",children:F}),e[61]=F,e[62]=O):O=e[62];let j;e[63]!==U||e[64]!==O?(j=(0,r.jsxs)("section",{className:"rounded-xl border border-border bg-card p-3 shadow-xs",children:[U,O]}),e[63]=U,e[64]=O,e[65]=j):j=e[65];let q;e[66]!==t?(q=t("Restore"),e[66]=t,e[67]=q):q=e[67];let z;e[68]!==q?(z=(0,r.jsx)("h3",{className:"text-sm font-semibold",children:q}),e[68]=q,e[69]=z):z=e[69];let D;e[70]!==t?(D=t("Time (ISO or epoch-ms, last 30 days)"),e[70]=t,e[71]=D):D=e[71];let E;e[72]!==D?(E=(0,r.jsx)(Se,{htmlFor:"pitr-time",children:D}),e[72]=D,e[73]=E):E=e[73];let V;e[74]!==f?(V=(0,r.jsx)(Ue,{"data-testid":"pitr-time",id:"pitr-time",onChange:et,placeholder:"2026-06-01T00:00:00.000Z",value:f}),e[74]=f,e[75]=V):V=e[75];let _e=de||C||u===void 0,K;e[76]!==t?(K=t("Preview"),e[76]=t,e[77]=K):K=e[77];let Z;e[78]!==R||e[79]!==_e||e[80]!==K?(Z=(0,r.jsx)($e,{"data-testid":"pitr-preview",disabled:_e,onClick:R,size:"sm",type:"button",variant:"outline",children:K}),e[78]=R,e[79]=_e,e[80]=K,e[81]=Z):Z=e[81];let $;e[82]!==V||e[83]!==Z?($=(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[V,Z]}),e[82]=V,e[83]=Z,e[84]=$):$=e[84];let G;e[85]!==f?(G=(0,r.jsx)(it,{text:f}),e[85]=f,e[86]=G):G=e[86];let H;e[87]!==v||e[88]!==t?(H=v!==null&&(0,r.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-preview-bookmark",children:[t("Bookmark for that time"),": ",v]}),e[87]=v,e[88]=t,e[89]=H):H=e[89];let J;e[90]!==E||e[91]!==$||e[92]!==G||e[93]!==H?(J=(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[E,$,G,H]}),e[90]=E,e[91]=$,e[92]=G,e[93]=H,e[94]=J):J=e[94];let Q;e[95]!==t?(Q=t("Or an explicit bookmark (wins over time)"),e[95]=t,e[96]=Q):Q=e[96];let W;e[97]!==Q?(W=(0,r.jsx)(Se,{htmlFor:"pitr-bookmark",children:Q}),e[97]=Q,e[98]=W):W=e[98];let X;e[99]!==t?(X=t("bookmark string"),e[99]=t,e[100]=X):X=e[100];let Y;e[101]!==c||e[102]!==X?(Y=(0,r.jsx)(Ue,{"data-testid":"pitr-bookmark",id:"pitr-bookmark",onChange:tt,placeholder:X,value:c}),e[101]=c,e[102]=X,e[103]=Y):Y=e[103];let ee;e[104]!==W||e[105]!==Y?(ee=(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[W,Y]}),e[104]=W,e[105]=Y,e[106]=ee):ee=e[106];let te;e[107]!==b?(te=(0,r.jsx)("input",{checked:b,className:"size-4 accent-primary","data-testid":"pitr-restart",id:"pitr-restart",onChange:rt,type:"checkbox"}),e[107]=b,e[108]=te):te=e[108];let re;e[109]!==t?(re=t("Restart the shard now so recovery applies immediately"),e[109]=t,e[110]=re):re=e[110];let oe;e[111]!==te||e[112]!==re?(oe=(0,r.jsxs)(Se,{className:"flex items-center gap-2 text-xs font-normal text-muted-foreground",htmlFor:"pitr-restart",children:[te,re]}),e[111]=te,e[112]=re,e[113]=oe):oe=e[113];let Le=de||C||!ve,ae;e[114]!==t?(ae=t("Restore"),e[114]=t,e[115]=ae):ae=e[115];let le;e[116]!==Te||e[117]!==Be||e[118]!==Le||e[119]!==ae?(le=(0,r.jsx)("div",{children:(0,r.jsx)(qe,{confirmLabel:Te,disabled:Le,onConfirm:Be,testId:"pitr-restore",children:ae})}),e[116]=Te,e[117]=Be,e[118]=Le,e[119]=ae,e[120]=le):le=e[120];let se;e[121]!==z||e[122]!==J||e[123]!==ee||e[124]!==oe||e[125]!==le?(se=(0,r.jsxs)("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-3 shadow-xs",children:[z,J,ee,oe,le]}),e[121]=z,e[122]=J,e[123]=ee,e[124]=oe,e[125]=le,e[126]=se):se=e[126];let ne;e[127]!==de||e[128]!==Ae||e[129]!==i||e[130]!==t||e[131]!==C?(ne=i!==null&&(0,r.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,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold",children:t("Restore armed")}),(0,r.jsx)(Ze,{variant:i.restarted?"destructive":"secondary",children:i.restarted?t("restarted now"):t("on next restart")})]}),(0,r.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground",children:[t("Restored to"),": ",i.restoredTo]}),(0,r.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-undo-bookmark",children:[t("Undo bookmark"),": ",i.undoBookmark]}),(0,r.jsx)("div",{children:(0,r.jsx)(qe,{confirmLabel:t("Confirm undo"),disabled:de||C,onConfirm:Ae,testId:"pitr-undo",children:t("Undo restore")})})]}),e[127]=de,e[128]=Ae,e[129]=i,e[130]=t,e[131]=C,e[132]=ne):ne=e[132];let Ie;return e[133]!==A||e[134]!==L||e[135]!==M||e[136]!==j||e[137]!==se||e[138]!==ne?(Ie=(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-pitr",children:[A,L,M,j,se,ne]}),e[133]=A,e[134]=L,e[135]=M,e[136]=j,e[137]=se,e[138]=ne,e[139]=Ie):Ie=e[139],Ie},"Nt");export{vt as PitrPanel};
1
+ import{a as He}from"./chunk-CGQMJYCW.js";import{a as Se}from"./chunk-37WYCOQ2.js";import{a as Ge}from"./chunk-OYDOFRRB.js";import{a as qe}from"./chunk-LXCVA5SP.js";import{i as Ue}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as $e}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as Ze}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as je}from"./chunk-4ZEL6BYL.js";import{l as Ke}from"./chunk-3JVXNEBO.js";import"./chunk-QAQDMS6R.js";import"./chunk-BAWEGZ7T.js";import{d as Pe,f as Fe,g as me,h as Ce,i as Oe,q as Re}from"./chunk-74IYYDDI.js";import{a as s,d as Me,e as ot,f as at,g as lt}from"./chunk-I26MS5PJ.js";var De=Me(at(),1);var m=Me(ot(),1);var r=Me(lt(),1);var ze=Fe(je.getPitrBookmark),st=Fe(je.pitrRestore),nt=/^\d+$/u,Je=s(ie=>{let e=ie.trim(),h=nt.test(e)?Number(e):Date.parse(e),l=new Date(h);return Number.isNaN(l.getTime())?void 0:{epochMs:h,iso:l.toISOString()}},"De"),it=s(ie=>{let e=(0,De.c)(9),{text:h}=ie,l=Pe();if(h.trim()==="")return null;let t,o,p;if(e[0]!==l||e[1]!==h){let y=Je(h);t="font-mono text-xs text-muted-foreground",o="pitr-time-resolved",p=y===void 0?l("Not a time \u2014 use epoch-ms or ISO 8601."):l("Resolves to {instant} (a date-time without an offset is read in this browser's time zone; a bare date is UTC)",{instant:y.iso}),e[0]=l,e[1]=h,e[2]=t,e[3]=o,e[4]=p}else t=e[2],o=e[3],p=e[4];let N;return e[5]!==t||e[6]!==o||e[7]!==p?(N=(0,r.jsx)("p",{className:t,"data-testid":o,children:p}),e[5]=t,e[6]=o,e[7]=p,e[8]=N):N=e[8],N},"lt"),vt=s(ie=>{let e=(0,De.c)(140),{initialShardKey:h}=ie,l=Ke(),t=Pe(),o=h??"",p=He(o),[N,y]=(0,m.useState)(null),[f,Qe]=(0,m.useState)(""),[ce,Ee]=(0,m.useState)(null),[c,We]=(0,m.useState)(""),[b,Xe]=(0,m.useState)(!1),[i,Ye]=(0,m.useState)(null),[ue,w]=(0,m.useState)(null),[de,I]=(0,m.useState)(!1),[C,Ve]=(0,m.useState)(!1),pe;e[0]!==l||e[1]!==o?(pe=s(async a=>{I(!0),w(null);let d;try{d={current:(await l.query(ze,{},me(o))).current,error:null,unavailable:!1}}catch(n){let g=n;d={current:null,error:Ce(g),unavailable:Oe(g)==="PITR_UNAVAILABLE"}}a?.aborted!==!0&&(d.error===null?y(d.current):w(d.error),Ve(d.unavailable),I(!1))},"fe"),e[0]=l,e[1]=o,e[2]=pe):pe=e[2];let x=pe,he,fe;e[3]!==x?(he=s(()=>{let a=new AbortController;return Re(x(a.signal)),()=>{a.abort()}},"ue"),fe=[x],e[3]=x,e[4]=he,e[5]=fe):(he=e[4],fe=e[5]),(0,m.useEffect)(he,fe);let be;e[6]!==l||e[7]!==o?(be=s(async()=>{let a=await l.query(ze,{},me(o));y(a.current)},"he"),e[6]=l,e[7]=o,e[8]=be):be=e[8],Ge(be,!C);let xe;e[9]===Symbol.for("react.memo_cache_sentinel")?(xe=s(a=>{Qe(a.target.value)},"be"),e[9]=xe):xe=e[9];let et=xe,ke;e[10]===Symbol.for("react.memo_cache_sentinel")?(ke=s(a=>{We(a.target.value)},"xe"),e[10]=ke):ke=e[10];let tt=ke,Ne;e[11]===Symbol.for("react.memo_cache_sentinel")?(Ne=s(a=>{Xe(a.target.checked)},"ke"),e[11]=Ne):Ne=e[11];let rt=Ne,ve,R,u,k,v,ge;if(e[12]!==c||e[13]!==l||e[14]!==ce||e[15]!==x||e[16]!==o||e[17]!==p||e[18]!==t||e[19]!==f){u=Je(f),R=s(()=>{if(u===void 0)return;let d=o;Re((async()=>{I(!0),w(null);let n;try{n={result:await l.query(ze,{time:u.epochMs},me(d))}}catch(g){n={error:Ce(g)}}p.current===d&&("result"in n?(Ee(n.result.forTime===void 0?null:{bookmark:n.result.forTime,shard:d}),y(n.result.current)):(Ee(null),w(n.error)),I(!1))})())},"C"),v=ce?.shard===o?ce.bookmark:null;let a;e[26]!==l||e[27]!==x||e[28]!==o?(a=s(d=>{Re((async()=>{I(!0),w(null);try{let n=await l.mutation(st,d,me(o));Ye(n),await x()}catch(n){let g=n;w(Ce(g)),Oe(g)==="PITR_UNAVAILABLE"&&Ve(!0)}I(!1)})())},"o"),e[26]=l,e[27]=x,e[28]=o,e[29]=a):a=e[29],k=a,ve=c.trim()!==""||u!==void 0,ge=t("Restore {shard} to {target}?",{shard:o===""?t("root"):o,target:c.trim()===""?u?.iso??"":t("the given bookmark")}),e[12]=c,e[13]=l,e[14]=ce,e[15]=x,e[16]=o,e[17]=p,e[18]=t,e[19]=f,e[20]=ve,e[21]=R,e[22]=u,e[23]=k,e[24]=v,e[25]=ge}else ve=e[20],R=e[21],u=e[22],k=e[23],v=e[24],ge=e[25];let Te=ge,ye;e[30]!==c||e[31]!==u?.epochMs||e[32]!==b||e[33]!==k?(ye=s(()=>{let a=b?{restart:!0}:{};c.trim()===""?a.time=u?.epochMs:a.bookmark=c.trim(),k(a)},"Ne"),e[30]=c,e[31]=u?.epochMs,e[32]=b,e[33]=k,e[34]=ye):ye=e[34];let Be=ye,we;e[35]!==b||e[36]!==i||e[37]!==k?(we=s(()=>{i!==null&&k(b?{bookmark:i.undoBookmark,restart:!0}:{bookmark:i.undoBookmark})},"ye"),e[35]=b,e[36]=i,e[37]=k,e[38]=we):we=e[38];let Ae=we,S;e[39]!==t?(S=t("Shard"),e[39]=t,e[40]=S):S=e[40];let T;e[41]!==o||e[42]!==t?(T=o===""?t("root"):o,e[41]=o,e[42]=t,e[43]=T):T=e[43];let B;e[44]!==T?(B=(0,r.jsx)("span",{className:"font-mono",children:T}),e[44]=T,e[45]=B):B=e[45];let A;e[46]!==S||e[47]!==B?(A=(0,r.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[S,": ",B]})}),e[46]=S,e[47]=B,e[48]=A):A=e[48];let _;e[49]!==t?(_=t("In-place recovery to any moment in the last 30 days. For older or portable recovery, use the snapshot backup tier."),e[49]=t,e[50]=_):_=e[50];let L;e[51]!==_?(L=(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"pitr-note",children:_}),e[51]=_,e[52]=L):L=e[52];let M;e[53]!==ue?(M=ue!==null&&(0,r.jsx)("p",{className:"text-sm text-destructive","data-testid":"pitr-error",role:"alert",children:ue}),e[53]=ue,e[54]=M):M=e[54];let P;e[55]!==t?(P=t("Current bookmark"),e[55]=t,e[56]=P):P=e[56];let U;e[57]!==P?(U=(0,r.jsx)("h3",{className:"mb-2 text-sm font-semibold",children:P}),e[57]=P,e[58]=U):U=e[58];let F;e[59]!==N?(F=N??(0,r.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),e[59]=N,e[60]=F):F=e[60];let O;e[61]!==F?(O=(0,r.jsx)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-current",children:F}),e[61]=F,e[62]=O):O=e[62];let j;e[63]!==U||e[64]!==O?(j=(0,r.jsxs)("section",{className:"rounded-xl border border-border bg-card p-3 shadow-xs",children:[U,O]}),e[63]=U,e[64]=O,e[65]=j):j=e[65];let q;e[66]!==t?(q=t("Restore"),e[66]=t,e[67]=q):q=e[67];let z;e[68]!==q?(z=(0,r.jsx)("h3",{className:"text-sm font-semibold",children:q}),e[68]=q,e[69]=z):z=e[69];let D;e[70]!==t?(D=t("Time (ISO or epoch-ms, last 30 days)"),e[70]=t,e[71]=D):D=e[71];let E;e[72]!==D?(E=(0,r.jsx)(Se,{htmlFor:"pitr-time",children:D}),e[72]=D,e[73]=E):E=e[73];let V;e[74]!==f?(V=(0,r.jsx)(Ue,{"data-testid":"pitr-time",id:"pitr-time",onChange:et,placeholder:"2026-06-01T00:00:00.000Z",value:f}),e[74]=f,e[75]=V):V=e[75];let _e=de||C||u===void 0,K;e[76]!==t?(K=t("Preview"),e[76]=t,e[77]=K):K=e[77];let Z;e[78]!==R||e[79]!==_e||e[80]!==K?(Z=(0,r.jsx)($e,{"data-testid":"pitr-preview",disabled:_e,onClick:R,size:"sm",type:"button",variant:"outline",children:K}),e[78]=R,e[79]=_e,e[80]=K,e[81]=Z):Z=e[81];let $;e[82]!==V||e[83]!==Z?($=(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[V,Z]}),e[82]=V,e[83]=Z,e[84]=$):$=e[84];let G;e[85]!==f?(G=(0,r.jsx)(it,{text:f}),e[85]=f,e[86]=G):G=e[86];let H;e[87]!==v||e[88]!==t?(H=v!==null&&(0,r.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-preview-bookmark",children:[t("Bookmark for that time"),": ",v]}),e[87]=v,e[88]=t,e[89]=H):H=e[89];let J;e[90]!==E||e[91]!==$||e[92]!==G||e[93]!==H?(J=(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[E,$,G,H]}),e[90]=E,e[91]=$,e[92]=G,e[93]=H,e[94]=J):J=e[94];let Q;e[95]!==t?(Q=t("Or an explicit bookmark (wins over time)"),e[95]=t,e[96]=Q):Q=e[96];let W;e[97]!==Q?(W=(0,r.jsx)(Se,{htmlFor:"pitr-bookmark",children:Q}),e[97]=Q,e[98]=W):W=e[98];let X;e[99]!==t?(X=t("bookmark string"),e[99]=t,e[100]=X):X=e[100];let Y;e[101]!==c||e[102]!==X?(Y=(0,r.jsx)(Ue,{"data-testid":"pitr-bookmark",id:"pitr-bookmark",onChange:tt,placeholder:X,value:c}),e[101]=c,e[102]=X,e[103]=Y):Y=e[103];let ee;e[104]!==W||e[105]!==Y?(ee=(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[W,Y]}),e[104]=W,e[105]=Y,e[106]=ee):ee=e[106];let te;e[107]!==b?(te=(0,r.jsx)("input",{checked:b,className:"size-4 accent-primary","data-testid":"pitr-restart",id:"pitr-restart",onChange:rt,type:"checkbox"}),e[107]=b,e[108]=te):te=e[108];let re;e[109]!==t?(re=t("Restart the shard now so recovery applies immediately"),e[109]=t,e[110]=re):re=e[110];let oe;e[111]!==te||e[112]!==re?(oe=(0,r.jsxs)(Se,{className:"flex items-center gap-2 text-xs font-normal text-muted-foreground",htmlFor:"pitr-restart",children:[te,re]}),e[111]=te,e[112]=re,e[113]=oe):oe=e[113];let Le=de||C||!ve,ae;e[114]!==t?(ae=t("Restore"),e[114]=t,e[115]=ae):ae=e[115];let le;e[116]!==Te||e[117]!==Be||e[118]!==Le||e[119]!==ae?(le=(0,r.jsx)("div",{children:(0,r.jsx)(qe,{confirmLabel:Te,disabled:Le,onConfirm:Be,testId:"pitr-restore",children:ae})}),e[116]=Te,e[117]=Be,e[118]=Le,e[119]=ae,e[120]=le):le=e[120];let se;e[121]!==z||e[122]!==J||e[123]!==ee||e[124]!==oe||e[125]!==le?(se=(0,r.jsxs)("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-3 shadow-xs",children:[z,J,ee,oe,le]}),e[121]=z,e[122]=J,e[123]=ee,e[124]=oe,e[125]=le,e[126]=se):se=e[126];let ne;e[127]!==de||e[128]!==Ae||e[129]!==i||e[130]!==t||e[131]!==C?(ne=i!==null&&(0,r.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,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold",children:t("Restore armed")}),(0,r.jsx)(Ze,{variant:i.restarted?"destructive":"secondary",children:i.restarted?t("restarted now"):t("on next restart")})]}),(0,r.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground",children:[t("Restored to"),": ",i.restoredTo]}),(0,r.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-undo-bookmark",children:[t("Undo bookmark"),": ",i.undoBookmark]}),(0,r.jsx)("div",{children:(0,r.jsx)(qe,{confirmLabel:t("Confirm undo"),disabled:de||C,onConfirm:Ae,testId:"pitr-undo",children:t("Undo restore")})})]}),e[127]=de,e[128]=Ae,e[129]=i,e[130]=t,e[131]=C,e[132]=ne):ne=e[132];let Ie;return e[133]!==A||e[134]!==L||e[135]!==M||e[136]!==j||e[137]!==se||e[138]!==ne?(Ie=(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-pitr",children:[A,L,M,j,se,ne]}),e[133]=A,e[134]=L,e[135]=M,e[136]=j,e[137]=se,e[138]=ne,e[139]=Ie):Ie=e[139],Ie},"Nt");export{vt as PitrPanel};
@@ -1 +1 @@
1
- import{a as q}from"./chunk-ZRFRFHRU.js";import{a as F}from"./chunk-R6U22RSY.js";import{a as D}from"./chunk-7Q256NLI.js";import"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import"./chunk-AUAECCXB.js";import{b as S}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as L}from"./chunk-XC2LTW44.js";import"./chunk-NCPW7WHO.js";import"./chunk-5AXRIRHW.js";import"./chunk-55UGUCQ6.js";import{a as B}from"./chunk-4ZEL6BYL.js";import{c as _}from"./chunk-YSPQIRER.js";import"./chunk-EQRZJZD4.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as j}from"./chunk-RWVIV3U7.js";import{a as O,b as P,c as W,d as C,e as h,f as p}from"./chunk-HCTJKP5J.js";import{a as T,e as $}from"./chunk-2IKDEUCX.js";import{d as M,n as E}from"./chunk-74IYYDDI.js";import{a as N,d as A,f as H,g as U}from"./chunk-I26MS5PJ.js";var R=A(H(),1);var t=A(U(),1);var J=80,Z=N(a=>{if(a===void 0)return"";let e=JSON.stringify(a,E);return e.length>J?`${e.slice(0,J)}\u2026`:e},"G"),z=N(a=>{let e=[];for(let r of a){let n=r.id.toString();if(r.subscriptions.length===0){e.push({admin:r.admin,connectionId:r.id,key:`c${n}`,subscription:null});continue}r.subscriptions.forEach((d,o)=>{e.push({admin:r.admin,connectionId:r.id,key:`c${n}-s${o.toString()}`,subscription:d})})}return e},"J"),w=(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),ce=N(a=>{let e=(0,R.c)(22),{initialShardKey:r}=a,n=M(),{queryShardKey:d,setShardKey:o,shardKey:m}=F(r),f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f={},e[0]=f):f=e[0];let b;e[1]!==d?(b={keepPreviousData:!0,shardKey:d},e[1]=d,e[2]=b):b=e[2];let{data:s,error:i,errorSource:u,poll:G}=_(B.listSubscriptions,f,b);q(G,!0);let x;if(e[3]!==i||e[4]!==u||e[5]!==s||e[6]!==o||e[7]!==m||e[8]!==n){let k=s===void 0?[]:z(s.connections),c;e[10]!==o||e[11]!==m?(c=(0,t.jsx)(D,{onChange:o,testId:"subs-shard-input",value:m}),e[10]=o,e[11]=m,e[12]=c):c=e[12];let l;e[13]!==s||e[14]!==n?(l=s!==void 0&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[(0,t.jsx)(S,{variant:"secondary",children:n("{count} connections",{count:s.totalConnections})}),(0,t.jsx)(S,{variant:"secondary",children:n("{count} subscriptions",{count:s.totalSubscriptions})})]}),e[13]=s,e[14]=n,e[15]=l):l=e[15];let g;e[16]!==c||e[17]!==l?(g=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,l]}),e[16]=c,e[17]=l,e[18]=g):g=e[18];let v;e[19]!==i||e[20]!==u?(v=i!==null&&(0,t.jsx)(L,{error:u,testId:"subs-error"}),e[19]=i,e[20]=u,e[21]=v):v=e[21],x=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[g,v,i===null&&s!==void 0&&k.length===0&&(0,t.jsx)(j,{description:n("Active WebSocket subscriptions on this shard."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"})}),testId:"subs-empty",title:n("No active subscriptions.")}),i===null&&k.length>0&&(0,t.jsx)(T,{className:"overflow-hidden py-0",children:(0,t.jsx)($,{className:"px-0",children:(0,t.jsxs)(O,{"data-testid":"subs-table",children:[(0,t.jsx)(P,{children:(0,t.jsxs)(C,{children:[(0,t.jsx)(h,{children:n("Connection")}),(0,t.jsx)(h,{children:n("Function path")}),(0,t.jsx)(h,{children:n("Table")}),(0,t.jsx)(h,{children:n("Arguments")})]})}),(0,t.jsx)(W,{children:k.map(y=>{let{subscription:I}=y,K=Z(I?.args);return(0,t.jsxs)(C,{"data-testid":"subs-row",children:[(0,t.jsx)(p,{className:"font-medium tabular-nums",children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:["#",y.connectionId,y.admin&&(0,t.jsx)(S,{variant:"outline",children:n("admin")})]})}),(0,t.jsx)(p,{className:"font-mono text-xs",children:I?.functionPath??w}),(0,t.jsx)(p,{children:I?.table??w}),(0,t.jsx)(p,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:K||void 0,children:K||w})]},y.key)})})]})})})]}),e[3]=i,e[4]=u,e[5]=s,e[6]=o,e[7]=m,e[8]=n,e[9]=x}else x=e[9];return x},"ae");export{ce as default};
1
+ import{a as q}from"./chunk-OYDOFRRB.js";import{a as F}from"./chunk-R6U22RSY.js";import{a as D}from"./chunk-7Q256NLI.js";import"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import"./chunk-AUAECCXB.js";import{b as S}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as L}from"./chunk-M27YVZWM.js";import"./chunk-NCPW7WHO.js";import"./chunk-LXQGF74P.js";import"./chunk-55UGUCQ6.js";import{a as B}from"./chunk-4ZEL6BYL.js";import{c as _}from"./chunk-NWWMHMGA.js";import"./chunk-3JVXNEBO.js";import"./chunk-QAQDMS6R.js";import"./chunk-BAWEGZ7T.js";import{a as j}from"./chunk-RWVIV3U7.js";import{a as O,b as P,c as W,d as C,e as h,f as p}from"./chunk-HCTJKP5J.js";import{a as T,e as $}from"./chunk-2IKDEUCX.js";import{d as M,n as E}from"./chunk-74IYYDDI.js";import{a as N,d as A,f as H,g as U}from"./chunk-I26MS5PJ.js";var R=A(H(),1);var t=A(U(),1);var J=80,Z=N(a=>{if(a===void 0)return"";let e=JSON.stringify(a,E);return e.length>J?`${e.slice(0,J)}\u2026`:e},"G"),z=N(a=>{let e=[];for(let r of a){let n=r.id.toString();if(r.subscriptions.length===0){e.push({admin:r.admin,connectionId:r.id,key:`c${n}`,subscription:null});continue}r.subscriptions.forEach((d,o)=>{e.push({admin:r.admin,connectionId:r.id,key:`c${n}-s${o.toString()}`,subscription:d})})}return e},"J"),w=(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),ce=N(a=>{let e=(0,R.c)(22),{initialShardKey:r}=a,n=M(),{queryShardKey:d,setShardKey:o,shardKey:m}=F(r),f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f={},e[0]=f):f=e[0];let b;e[1]!==d?(b={keepPreviousData:!0,shardKey:d},e[1]=d,e[2]=b):b=e[2];let{data:s,error:i,errorSource:u,poll:G}=_(B.listSubscriptions,f,b);q(G,!0);let x;if(e[3]!==i||e[4]!==u||e[5]!==s||e[6]!==o||e[7]!==m||e[8]!==n){let k=s===void 0?[]:z(s.connections),c;e[10]!==o||e[11]!==m?(c=(0,t.jsx)(D,{onChange:o,testId:"subs-shard-input",value:m}),e[10]=o,e[11]=m,e[12]=c):c=e[12];let l;e[13]!==s||e[14]!==n?(l=s!==void 0&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[(0,t.jsx)(S,{variant:"secondary",children:n("{count} connections",{count:s.totalConnections})}),(0,t.jsx)(S,{variant:"secondary",children:n("{count} subscriptions",{count:s.totalSubscriptions})})]}),e[13]=s,e[14]=n,e[15]=l):l=e[15];let g;e[16]!==c||e[17]!==l?(g=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,l]}),e[16]=c,e[17]=l,e[18]=g):g=e[18];let v;e[19]!==i||e[20]!==u?(v=i!==null&&(0,t.jsx)(L,{error:u,testId:"subs-error"}),e[19]=i,e[20]=u,e[21]=v):v=e[21],x=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[g,v,i===null&&s!==void 0&&k.length===0&&(0,t.jsx)(j,{description:n("Active WebSocket subscriptions on this shard."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"})}),testId:"subs-empty",title:n("No active subscriptions.")}),i===null&&k.length>0&&(0,t.jsx)(T,{className:"overflow-hidden py-0",children:(0,t.jsx)($,{className:"px-0",children:(0,t.jsxs)(O,{"data-testid":"subs-table",children:[(0,t.jsx)(P,{children:(0,t.jsxs)(C,{children:[(0,t.jsx)(h,{children:n("Connection")}),(0,t.jsx)(h,{children:n("Function path")}),(0,t.jsx)(h,{children:n("Table")}),(0,t.jsx)(h,{children:n("Arguments")})]})}),(0,t.jsx)(W,{children:k.map(y=>{let{subscription:I}=y,K=Z(I?.args);return(0,t.jsxs)(C,{"data-testid":"subs-row",children:[(0,t.jsx)(p,{className:"font-medium tabular-nums",children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:["#",y.connectionId,y.admin&&(0,t.jsx)(S,{variant:"outline",children:n("admin")})]})}),(0,t.jsx)(p,{className:"font-mono text-xs",children:I?.functionPath??w}),(0,t.jsx)(p,{children:I?.table??w}),(0,t.jsx)(p,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:K||void 0,children:K||w})]},y.key)})})]})})})]}),e[3]=i,e[4]=u,e[5]=s,e[6]=o,e[7]=m,e[8]=n,e[9]=x}else x=e[9];return x},"ae");export{ce as default};
@@ -1,4 +1,4 @@
1
- import{c as _e}from"./chunk-UYEZR3BI.js";import{e as Re}from"./chunk-4CGBMYO3.js";import"./chunk-NQZALRU3.js";import"./chunk-OPM7ESDV.js";import"./chunk-Y3AYVFTK.js";import{a as ke}from"./chunk-7RKB5KS7.js";import"./chunk-QJLHH3ET.js";import{a as Ie}from"./chunk-ZRFRFHRU.js";import"./chunk-OYCUPD3Q.js";import"./chunk-NXQW5E6W.js";import"./chunk-UC7MNI2F.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import{a as Be}from"./chunk-LXCVA5SP.js";import{a as Fe}from"./chunk-7Q256NLI.js";import"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import{i as De}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{a as ee}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as ae}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as ve}from"./chunk-4ZEL6BYL.js";import{l as je}from"./chunk-EQRZJZD4.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as pe}from"./chunk-RWVIV3U7.js";import{a as Oe,b as Ee,c as Le,d as de,e as te,f as X}from"./chunk-HCTJKP5J.js";import{a as Te,e as $e}from"./chunk-2IKDEUCX.js";import{d as ze,f as be,g as ye,h as le,m as xe,q as Z,t as Ke}from"./chunk-74IYYDDI.js";import{a as h,d as ge,e as bt,f as yt,g as xt}from"./chunk-I26MS5PJ.js";var M=ge(yt(),1),z=ge(bt(),1);var o=ge(xt(),1);var Ae=h((d,e,t)=>{let{onCopy:r,onDelete:l,onDownload:n,onToggleSelect:c}=t,i=h(()=>{r(d.key)},"c"),s=h(()=>{n(d.key)},"o"),u=h(()=>{l(d.key)},"f"),m=h(()=>{c(d.key)},"h");return{copy:i,download:s,name:d.key.slice(e.length),remove:u,toggle:m}},"Re"),We=h(d=>{let e=(0,M.c)(31),{busy:t,buttonClassName:r,copied:l,objectKey:n,onCopy:c,onDelete:i,onDownload:s,t:u}=d,m=`storage-copy-${n}`,f;e[0]!==l||e[1]!==u?(f=u(l?"Copied":"Copy URL"),e[0]=l,e[1]=u,e[2]=f):f=e[2];let g;e[3]!==t||e[4]!==r||e[5]!==c||e[6]!==m||e[7]!==f?(g=(0,o.jsx)(ee,{className:r,"data-testid":m,disabled:t,onClick:c,size:"sm",type:"button",variant:"ghost",children:f}),e[3]=t,e[4]=r,e[5]=c,e[6]=m,e[7]=f,e[8]=g):g=e[8];let w=`storage-download-${n}`,a;e[9]!==u?(a=u("Download"),e[9]=u,e[10]=a):a=e[10];let k;e[11]!==t||e[12]!==r||e[13]!==s||e[14]!==w||e[15]!==a?(k=(0,o.jsx)(ee,{className:r,"data-testid":w,disabled:t,onClick:s,size:"sm",type:"button",variant:"ghost",children:a}),e[11]=t,e[12]=r,e[13]=s,e[14]=w,e[15]=a,e[16]=k):k=e[16];let S;e[17]!==u?(S=u("Delete object?"),e[17]=u,e[18]=S):S=e[18];let x=`storage-delete-${n}`,b;e[19]!==u?(b=u("Delete"),e[19]=u,e[20]=b):b=e[20];let y;e[21]!==t||e[22]!==i||e[23]!==S||e[24]!==x||e[25]!==b?(y=(0,o.jsx)(Be,{confirmLabel:S,disabled:t,onConfirm:i,testId:x,children:b}),e[21]=t,e[22]=i,e[23]=S,e[24]=x,e[25]=b,e[26]=y):y=e[26];let v;return e[27]!==y||e[28]!==g||e[29]!==k?(v=(0,o.jsxs)(o.Fragment,{children:[g,k,y]}),e[27]=y,e[28]=g,e[29]=k,e[30]=v):v=e[30],v},"ze"),He=h(d=>{let e=(0,M.c)(14),{objectKey:t,references:r,t:l}=d;if(r===void 0)return null;if(r.length===0){let m=`storage-orphan-${t}`,f;e[0]!==l?(f=l("Orphan"),e[0]=l,e[1]=f):f=e[1];let g;return e[2]!==m||e[3]!==f?(g=(0,o.jsx)(ae,{"data-testid":m,variant:"warning",children:f}),e[2]=m,e[3]=f,e[4]=g):g=e[4],g}let n;e[5]!==r?(n=r.map(vt).join(`
1
+ import{c as _e}from"./chunk-UYEZR3BI.js";import{e as Re}from"./chunk-4CGBMYO3.js";import"./chunk-NQZALRU3.js";import"./chunk-OPM7ESDV.js";import"./chunk-Y3AYVFTK.js";import{a as ke}from"./chunk-7RKB5KS7.js";import"./chunk-QJLHH3ET.js";import{a as Ie}from"./chunk-OYDOFRRB.js";import"./chunk-OYCUPD3Q.js";import"./chunk-NXQW5E6W.js";import"./chunk-UC7MNI2F.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import{a as Be}from"./chunk-LXCVA5SP.js";import{a as Fe}from"./chunk-7Q256NLI.js";import"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import{i as De}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{a as ee}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as ae}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as ve}from"./chunk-4ZEL6BYL.js";import{l as je}from"./chunk-3JVXNEBO.js";import"./chunk-QAQDMS6R.js";import"./chunk-BAWEGZ7T.js";import{a as pe}from"./chunk-RWVIV3U7.js";import{a as Oe,b as Ee,c as Le,d as de,e as te,f as X}from"./chunk-HCTJKP5J.js";import{a as Te,e as $e}from"./chunk-2IKDEUCX.js";import{d as ze,f as be,g as ye,h as le,m as xe,q as Z,t as Ke}from"./chunk-74IYYDDI.js";import{a as h,d as ge,e as bt,f as yt,g as xt}from"./chunk-I26MS5PJ.js";var M=ge(yt(),1),z=ge(bt(),1);var o=ge(xt(),1);var Ae=h((d,e,t)=>{let{onCopy:r,onDelete:l,onDownload:n,onToggleSelect:c}=t,i=h(()=>{r(d.key)},"c"),s=h(()=>{n(d.key)},"o"),u=h(()=>{l(d.key)},"f"),m=h(()=>{c(d.key)},"h");return{copy:i,download:s,name:d.key.slice(e.length),remove:u,toggle:m}},"Re"),We=h(d=>{let e=(0,M.c)(31),{busy:t,buttonClassName:r,copied:l,objectKey:n,onCopy:c,onDelete:i,onDownload:s,t:u}=d,m=`storage-copy-${n}`,f;e[0]!==l||e[1]!==u?(f=u(l?"Copied":"Copy URL"),e[0]=l,e[1]=u,e[2]=f):f=e[2];let g;e[3]!==t||e[4]!==r||e[5]!==c||e[6]!==m||e[7]!==f?(g=(0,o.jsx)(ee,{className:r,"data-testid":m,disabled:t,onClick:c,size:"sm",type:"button",variant:"ghost",children:f}),e[3]=t,e[4]=r,e[5]=c,e[6]=m,e[7]=f,e[8]=g):g=e[8];let w=`storage-download-${n}`,a;e[9]!==u?(a=u("Download"),e[9]=u,e[10]=a):a=e[10];let k;e[11]!==t||e[12]!==r||e[13]!==s||e[14]!==w||e[15]!==a?(k=(0,o.jsx)(ee,{className:r,"data-testid":w,disabled:t,onClick:s,size:"sm",type:"button",variant:"ghost",children:a}),e[11]=t,e[12]=r,e[13]=s,e[14]=w,e[15]=a,e[16]=k):k=e[16];let S;e[17]!==u?(S=u("Delete object?"),e[17]=u,e[18]=S):S=e[18];let x=`storage-delete-${n}`,b;e[19]!==u?(b=u("Delete"),e[19]=u,e[20]=b):b=e[20];let y;e[21]!==t||e[22]!==i||e[23]!==S||e[24]!==x||e[25]!==b?(y=(0,o.jsx)(Be,{confirmLabel:S,disabled:t,onConfirm:i,testId:x,children:b}),e[21]=t,e[22]=i,e[23]=S,e[24]=x,e[25]=b,e[26]=y):y=e[26];let v;return e[27]!==y||e[28]!==g||e[29]!==k?(v=(0,o.jsxs)(o.Fragment,{children:[g,k,y]}),e[27]=y,e[28]=g,e[29]=k,e[30]=v):v=e[30],v},"ze"),He=h(d=>{let e=(0,M.c)(14),{objectKey:t,references:r,t:l}=d;if(r===void 0)return null;if(r.length===0){let m=`storage-orphan-${t}`,f;e[0]!==l?(f=l("Orphan"),e[0]=l,e[1]=f):f=e[1];let g;return e[2]!==m||e[3]!==f?(g=(0,o.jsx)(ae,{"data-testid":m,variant:"warning",children:f}),e[2]=m,e[3]=f,e[4]=g):g=e[4],g}let n;e[5]!==r?(n=r.map(vt).join(`
2
2
  `),e[5]=r,e[6]=n):n=e[6];let c=n,i=`storage-refs-${t}`,s;e[7]!==r.length||e[8]!==l?(s=r.length===1?l("1 record"):l("{count} records",{count:r.length}),e[7]=r.length,e[8]=l,e[9]=s):s=e[9];let u;return e[10]!==c||e[11]!==i||e[12]!==s?(u=(0,o.jsx)(ae,{"data-testid":i,title:c,variant:"secondary",children:s}),e[10]=c,e[11]=i,e[12]=s,e[13]=u):u=e[13],u},"De"),Ze=h(d=>{let e=(0,M.c)(7),{objectKey:t,onToggle:r,selected:l,t:n}=d,c;e[0]!==n?(c=n("Select row"),e[0]=n,e[1]=c):c=e[1];let i=`storage-select-${t}`,s;return e[2]!==r||e[3]!==l||e[4]!==c||e[5]!==i?(s=(0,o.jsx)(ke,{"aria-label":c,checked:l,"data-testid":i,onCheckedChange:r}),e[2]=r,e[3]=l,e[4]=c,e[5]=i,e[6]=s):s=e[6],s},"je");function vt(d){return`${d.table}\xB7${d.id}`}h(vt,"kt");var kt=h(d=>{let e=(0,M.c)(10),{colSpan:t,name:r,onEnter:l}=d,n;e[0]!==r||e[1]!==l?(n=h(()=>{l(r)},"l"),e[0]=r,e[1]=l,e[2]=n):n=e[2];let c=n,i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=(0,o.jsx)("svg",{"aria-hidden":"true",className:"size-4 text-muted-foreground",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,o.jsx)("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"})}),e[3]=i):i=e[3];let s;e[4]!==c||e[5]!==r?(s=(0,o.jsxs)("button",{className:"inline-flex items-center gap-2 font-mono text-xs outline-none hover:text-foreground focus-visible:text-foreground","data-testid":"fb-folder",onClick:c,type:"button",children:[i,r]}),e[4]=c,e[5]=r,e[6]=s):s=e[6];let u;return e[7]!==t||e[8]!==s?(u=(0,o.jsx)(de,{children:(0,o.jsx)(X,{colSpan:t,children:s})}),e[7]=t,e[8]=s,e[9]=u):u=e[9],u},"St"),wt=h(d=>{let e=(0,M.c)(37),{busy:t,copiedKey:r,handlers:l,object:n,prefix:c,references:i,selected:s,showReferences:u,t:m}=d,f;e[0]!==l||e[1]!==n||e[2]!==c?(f=Ae(n,c,l),e[0]=l,e[1]=n,e[2]=c,e[3]=f):f=e[3];let{copy:g,download:w,name:a,remove:k,toggle:S}=f,x;e[4]!==n.key||e[5]!==s||e[6]!==m||e[7]!==S?(x=(0,o.jsx)(X,{className:"w-8",children:(0,o.jsx)(Ze,{objectKey:n.key,onToggle:S,selected:s,t:m})}),e[4]=n.key,e[5]=s,e[6]=m,e[7]=S,e[8]=x):x=e[8];let b;e[9]!==a?(b=(0,o.jsx)(X,{className:"font-mono text-xs",children:a}),e[9]=a,e[10]=b):b=e[10];let y;e[11]!==n.size?(y=xe(n.size),e[11]=n.size,e[12]=y):y=e[12];let v;e[13]!==y?(v=(0,o.jsx)(X,{className:"tabular-nums text-muted-foreground",children:y}),e[13]=y,e[14]=v):v=e[14];let j=n.httpMetadata?.contentType??"",N;e[15]!==j?(N=(0,o.jsx)(X,{children:j}),e[15]=j,e[16]=N):N=e[16];let C;e[17]!==n.key||e[18]!==i||e[19]!==u||e[20]!==m?(C=u&&(0,o.jsx)(X,{children:(0,o.jsx)(He,{objectKey:n.key,references:i,t:m})}),e[17]=n.key,e[18]=i,e[19]=u,e[20]=m,e[21]=C):C=e[21];let T=r===n.key,D;e[22]!==t||e[23]!==g||e[24]!==w||e[25]!==n.key||e[26]!==k||e[27]!==m||e[28]!==T?(D=(0,o.jsx)(X,{className:"text-right",children:(0,o.jsx)("span",{className:"inline-flex items-center gap-1",children:(0,o.jsx)(We,{busy:t,copied:T,objectKey:n.key,onCopy:g,onDelete:k,onDownload:w,t:m})})}),e[22]=t,e[23]=g,e[24]=w,e[25]=n.key,e[26]=k,e[27]=m,e[28]=T,e[29]=D):D=e[29];let F;return e[30]!==D||e[31]!==x||e[32]!==b||e[33]!==v||e[34]!==N||e[35]!==C?(F=(0,o.jsxs)(de,{"data-testid":"fb-row",children:[x,b,v,N,C,D]}),e[30]=D,e[31]=x,e[32]=b,e[33]=v,e[34]=N,e[35]=C,e[36]=F):F=e[36],F},"wt"),St=h(d=>{let e=(0,M.c)(65),{allSelected:t,busy:r,copiedKey:l,files:n,folders:c,handlers:i,onEnterFolder:s,prefix:u,references:m,selected:f,showReferences:g,someSelected:w,t:a,toggleSelectAll:k}=d,S;e[0]!==a?(S=a("Select all rows"),e[0]=a,e[1]=S):S=e[1];let x;e[2]!==t||e[3]!==w||e[4]!==S||e[5]!==k?(x=(0,o.jsx)(te,{className:"w-8",children:(0,o.jsx)(ke,{"aria-label":S,checked:t,"data-testid":"storage-select-all",indeterminate:w,onCheckedChange:k})}),e[2]=t,e[3]=w,e[4]=S,e[5]=k,e[6]=x):x=e[6];let b;e[7]!==a?(b=a("key"),e[7]=a,e[8]=b):b=e[8];let y;e[9]!==b?(y=(0,o.jsx)(te,{children:b}),e[9]=b,e[10]=y):y=e[10];let v;e[11]!==a?(v=a("size"),e[11]=a,e[12]=v):v=e[12];let j;e[13]!==v?(j=(0,o.jsx)(te,{children:v}),e[13]=v,e[14]=j):j=e[14];let N;e[15]!==a?(N=a("content-type"),e[15]=a,e[16]=N):N=e[16];let C;e[17]!==N?(C=(0,o.jsx)(te,{children:N}),e[17]=N,e[18]=C):C=e[18];let T;e[19]!==g||e[20]!==a?(T=g&&(0,o.jsx)(te,{children:a("used by")}),e[19]=g,e[20]=a,e[21]=T):T=e[21];let D;e[22]!==a?(D=a("Actions"),e[22]=a,e[23]=D):D=e[23];let F;e[24]!==D?(F=(0,o.jsx)(te,{"aria-label":D}),e[24]=D,e[25]=F):F=e[25];let $;e[26]!==F||e[27]!==x||e[28]!==y||e[29]!==j||e[30]!==C||e[31]!==T?($=(0,o.jsx)(Ee,{children:(0,o.jsxs)(de,{children:[x,y,j,C,T,F]})}),e[26]=F,e[27]=x,e[28]=y,e[29]=j,e[30]=C,e[31]=T,e[32]=$):$=e[32];let O;if(e[33]!==c||e[34]!==s||e[35]!==g){let E;e[37]!==s||e[38]!==g?(E=h(B=>(0,o.jsx)(kt,{colSpan:g?6:5,name:B,onEnter:s},B),"D"),e[37]=s,e[38]=g,e[39]=E):E=e[39],O=c.map(E),e[33]=c,e[34]=s,e[35]=g,e[36]=O}else O=e[36];let I;if(e[40]!==r||e[41]!==l||e[42]!==n||e[43]!==i||e[44]!==u||e[45]!==m||e[46]!==f||e[47]!==g||e[48]!==a){let E;e[50]!==r||e[51]!==l||e[52]!==i||e[53]!==u||e[54]!==m||e[55]!==f||e[56]!==g||e[57]!==a?(E=h(B=>(0,o.jsx)(wt,{busy:r,copiedKey:l,handlers:i,object:B,prefix:u,references:m[B.key],selected:f.has(B.key),showReferences:g,t:a},B.key),"D"),e[50]=r,e[51]=l,e[52]=i,e[53]=u,e[54]=m,e[55]=f,e[56]=g,e[57]=a,e[58]=E):E=e[58],I=n.map(E),e[40]=r,e[41]=l,e[42]=n,e[43]=i,e[44]=u,e[45]=m,e[46]=f,e[47]=g,e[48]=a,e[49]=I}else I=e[49];let L;e[59]!==O||e[60]!==I?(L=(0,o.jsxs)(Le,{children:[O,I]}),e[59]=O,e[60]=I,e[61]=L):L=e[61];let R;return e[62]!==$||e[63]!==L?(R=(0,o.jsx)(Te,{className:"overflow-hidden py-0",children:(0,o.jsx)($e,{className:"px-0",children:(0,o.jsxs)(Oe,{"data-testid":"fb-table",children:[$,L]})})}),e[62]=$,e[63]=L,e[64]=R):R=e[64],R},"Ct"),Nt=[{label:"15m",seconds:900},{label:"1h",seconds:3600},{label:"24h",seconds:86400},{label:"7d",seconds:604800}],Ct=3600,Ue=h((d,e)=>{if(e==="size")return d.size;if(e==="type")return d.httpMetadata?.contentType??"";if(e==="date"){if(d.uploaded===void 0)return 0;let t=new Date(d.uploaded).getTime();return Number.isNaN(t)?0:t}return e.startsWith("tag:")?d.customMetadata?.[e.slice(4)]??"":d.key},"we"),jt=h((d,e,t)=>{let r=t==="desc"?-1:1;return d.toSorted((l,n)=>{let c=Ue(l,e),i=Ue(n,e);return(typeof c=="number"&&typeof i=="number"?c-i:String(c).localeCompare(String(i)))*r})},"Et"),zt=h((d,e)=>{let t=new Set,r=[];for(let l of d){let n=l.key.slice(e.length),c=n.indexOf("/");c===-1?r.push(l):t.add(n.slice(0,c+1))}return{files:r,folders:[...t].toSorted((l,n)=>l.localeCompare(n))}},"_t"),Dt=h(d=>{let e=(0,M.c)(59),{bucket:t,buckets:r,busy:l,draftPrefix:n,expiry:c,fileInputRef:i,onBucketChange:s,onExpiryChange:u,onFileChange:m,onList:f,onPrefixChange:g,onUploadClick:w,t:a}=d,k;e[0]!==g?(k=h(A=>{g(A.target.value)},"v"),e[0]=g,e[1]=k):k=e[1];let S=k,x;e[2]!==s?(x=h(A=>{s(A.target.value)},"y"),e[2]=s,e[3]=x):x=e[3];let b=x,y;e[4]!==u?(y=h(A=>{u(Number.parseInt(A.target.value,10))},"b"),e[4]=u,e[5]=y):y=e[5];let v=y,j;e[6]!==t||e[7]!==r||e[8]!==b||e[9]!==a?(j=r.length>0&&(0,o.jsx)("select",{"aria-label":a("Bucket"),className:"h-8 rounded-md border border-border bg-background px-1 outline-none focus-visible:border-ring","data-testid":"fb-bucket",onChange:b,value:t,children:r.map($t)}),e[6]=t,e[7]=r,e[8]=b,e[9]=a,e[10]=j):j=e[10];let N;e[11]!==a?(N=a("Key prefix"),e[11]=a,e[12]=N):N=e[12];let C;e[13]!==a?(C=a("key prefix (optional)"),e[13]=a,e[14]=C):C=e[14];let T;e[15]!==n||e[16]!==S||e[17]!==N||e[18]!==C?(T=(0,o.jsx)(De,{"aria-label":N,className:"h-8 w-64 max-w-full","data-testid":"fb-prefix-input",onChange:S,placeholder:C,value:n}),e[15]=n,e[16]=S,e[17]=N,e[18]=C,e[19]=T):T=e[19];let D;e[20]!==a?(D=a("List"),e[20]=a,e[21]=D):D=e[21];let F;e[22]!==l||e[23]!==f||e[24]!==D?(F=(0,o.jsx)(ee,{"data-testid":"fb-list",disabled:l,onClick:f,size:"sm",type:"button",children:D}),e[22]=l,e[23]=f,e[24]=D,e[25]=F):F=e[25];let $;e[26]!==l||e[27]!==a?($=a(l?"Uploading\u2026":"Upload"),e[26]=l,e[27]=a,e[28]=$):$=e[28];let O;e[29]!==l||e[30]!==w||e[31]!==$?(O=(0,o.jsx)(ee,{"data-testid":"storage-upload",disabled:l,onClick:w,size:"sm",type:"button",variant:"outline",children:$}),e[29]=l,e[30]=w,e[31]=$,e[32]=O):O=e[32];let I;e[33]!==i||e[34]!==m?(I=(0,o.jsx)("input",{className:"hidden","data-testid":"storage-file-input",onChange:m,ref:i,type:"file"}),e[33]=i,e[34]=m,e[35]=I):I=e[35];let L;e[36]!==a?(L=a("Link expiry"),e[36]=a,e[37]=L):L=e[37];let R;e[38]!==a?(R=Nt.map(A=>(0,o.jsx)("option",{value:A.seconds,children:a(A.label)},A.seconds)),e[38]=a,e[39]=R):R=e[39];let E;e[40]!==c||e[41]!==v||e[42]!==R?(E=(0,o.jsx)("select",{className:"h-8 rounded-md border border-border bg-background px-1 tabular-nums outline-none focus-visible:border-ring","data-testid":"storage-expiry",id:"storage-expiry",onChange:v,value:c,children:R}),e[40]=c,e[41]=v,e[42]=R,e[43]=E):E=e[43];let B;e[44]!==L||e[45]!==E?(B=(0,o.jsxs)("label",{className:"ml-auto flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"storage-expiry",children:[L,E]}),e[44]=L,e[45]=E,e[46]=B):B=e[46];let U;e[47]!==a?(U=a("Open in Cloudflare"),e[47]=a,e[48]=U):U=e[48];let P;e[49]!==U?(P=(0,o.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"fb-cf-link",href:_e,rel:"noreferrer",target:"_blank",children:U}),e[49]=U,e[50]=P):P=e[50];let W;return e[51]!==O||e[52]!==I||e[53]!==B||e[54]!==P||e[55]!==j||e[56]!==T||e[57]!==F?(W=(0,o.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[j,T,F,O,I,B,P]}),e[51]=O,e[52]=I,e[53]=B,e[54]=P,e[55]=j,e[56]=T,e[57]=F,e[58]=W):W=e[58],W},"$t"),Tt=h(d=>{let e=(0,M.c)(66),{onSortKeyChange:t,onThumbSizeChange:r,showGrid:l,showList:n,sortDirection:c,sortKey:i,t:s,tagKeys:u,thumbSize:m,toggleSortDirection:f,view:g}=d,w;e[0]!==t?(w=h(q=>{t(q.target.value)},"k"),e[0]=t,e[1]=w):w=e[1];let a=w,k;e[2]!==r?(k=h(q=>{r(Number.parseInt(q.target.value,10))},"v"),e[2]=r,e[3]=k):k=e[3];let S=k,x=g==="list",b;e[4]!==s?(b=s("List"),e[4]=s,e[5]=b):b=e[5];let y;e[6]!==n||e[7]!==x||e[8]!==b?(y=(0,o.jsx)("button",{"aria-pressed":x,className:"px-2 py-1 outline-none transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:text-accent-foreground","data-testid":"fb-view-list",onClick:n,type:"button",children:b}),e[6]=n,e[7]=x,e[8]=b,e[9]=y):y=e[9];let v=g==="grid",j;e[10]!==s?(j=s("Grid"),e[10]=s,e[11]=j):j=e[11];let N;e[12]!==l||e[13]!==v||e[14]!==j?(N=(0,o.jsx)("button",{"aria-pressed":v,className:"border-s border-border px-2 py-1 outline-none transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:text-accent-foreground","data-testid":"fb-view-grid",onClick:l,type:"button",children:j}),e[12]=l,e[13]=v,e[14]=j,e[15]=N):N=e[15];let C;e[16]!==y||e[17]!==N?(C=(0,o.jsxs)("div",{className:"inline-flex overflow-hidden rounded-md border border-border",children:[y,N]}),e[16]=y,e[17]=N,e[18]=C):C=e[18];let T;e[19]!==s?(T=s("Sort"),e[19]=s,e[20]=T):T=e[20];let D;e[21]!==s?(D=s("Name"),e[21]=s,e[22]=D):D=e[22];let F;e[23]!==D?(F=(0,o.jsx)("option",{value:"name",children:D}),e[23]=D,e[24]=F):F=e[24];let $;e[25]!==s?($=s("size"),e[25]=s,e[26]=$):$=e[26];let O;e[27]!==$?(O=(0,o.jsx)("option",{value:"size",children:$}),e[27]=$,e[28]=O):O=e[28];let I;e[29]!==s?(I=s("Type"),e[29]=s,e[30]=I):I=e[30];let L;e[31]!==I?(L=(0,o.jsx)("option",{value:"type",children:I}),e[31]=I,e[32]=L):L=e[32];let R;e[33]!==s?(R=s("Modified"),e[33]=s,e[34]=R):R=e[34];let E;e[35]!==R?(E=(0,o.jsx)("option",{value:"date",children:R}),e[35]=R,e[36]=E):E=e[36];let B;e[37]!==u?(B=u.map(Kt),e[37]=u,e[38]=B):B=e[38];let U;e[39]!==a||e[40]!==i||e[41]!==F||e[42]!==O||e[43]!==L||e[44]!==E||e[45]!==B?(U=(0,o.jsxs)("select",{className:"h-8 rounded-md border border-border bg-background px-1 outline-none focus-visible:border-ring","data-testid":"fb-sort",id:"fb-sort",onChange:a,value:i,children:[F,O,L,E,B]}),e[39]=a,e[40]=i,e[41]=F,e[42]=O,e[43]=L,e[44]=E,e[45]=B,e[46]=U):U=e[46];let P;e[47]!==T||e[48]!==U?(P=(0,o.jsxs)("label",{className:"flex items-center gap-1.5 text-muted-foreground",htmlFor:"fb-sort",children:[T,U]}),e[47]=T,e[48]=U,e[49]=P):P=e[49];let W;e[50]!==s?(W=s("Toggle sort direction"),e[50]=s,e[51]=W):W=e[51];let A=c==="asc"?"\u2191":"\u2193",H;e[52]!==W||e[53]!==A||e[54]!==f?(H=(0,o.jsx)("button",{"aria-label":W,className:"flex size-8 items-center justify-center rounded-md border border-border tabular-nums outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"fb-sort-dir",onClick:f,type:"button",children:A}),e[52]=W,e[53]=A,e[54]=f,e[55]=H):H=e[55];let V;e[56]!==S||e[57]!==s||e[58]!==m||e[59]!==g?(V=g==="grid"&&(0,o.jsxs)("label",{className:"ml-auto flex items-center gap-1.5 text-muted-foreground",htmlFor:"fb-thumb-size",children:[s("Thumbnail size"),(0,o.jsx)("input",{className:"accent-primary","data-testid":"fb-thumb-size",id:"fb-thumb-size",max:240,min:80,onChange:S,step:8,type:"range",value:m})]}),e[56]=S,e[57]=s,e[58]=m,e[59]=g,e[60]=V):V=e[60];let re;return e[61]!==P||e[62]!==H||e[63]!==V||e[64]!==C?(re=(0,o.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs","data-testid":"fb-controls",children:[C,P,H,V]}),e[61]=P,e[62]=H,e[63]=V,e[64]=C,e[65]=re):re=e[65],re},"Ft");function $t(d){return(0,o.jsx)("option",{value:d,children:d},d)}h($t,"Rt");function Kt(d){return(0,o.jsx)("option",{value:`tag:${d}`,children:d},d)}h(Kt,"zt");var Ft=/\.(?:avif|bmp|gif|ico|jpe?g|png|svg|webp)$/iu,Ot=h(d=>(d.httpMetadata?.contentType??"").startsWith("image/")||Ft.test(d.key),"jt"),Et=h(()=>{let d=(0,M.c)(1),e;return d[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,o.jsx)("svg",{"aria-hidden":"true",className:"size-8 text-muted-foreground/60",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.4,viewBox:"0 0 24 24",children:(0,o.jsx)("path",{d:"M7 3h7l5 5v13a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Zm7 0v5h5"})}),d[0]=e):e=d[0],e},"Kt"),Lt=h(d=>{let e=(0,M.c)(13),{object:t,resolveUrl:r}=d,[l,n]=(0,z.useState)(null),[c,i]=(0,z.useState)(!1),s;e[0]!==t?(s=Ot(t),e[0]=t,e[1]=s):s=e[1];let u=s,m,f;e[2]!==u||e[3]!==t.key||e[4]!==r?(m=h(()=>{if(!u)return;let k={cancelled:!1};return Z((async()=>{try{let S=await r(t.key);k.cancelled||n(S)}catch{k.cancelled||i(!0)}})()),()=>{k.cancelled=!0}},"h"),f=[u,t.key,r],e[2]=u,e[3]=t.key,e[4]=r,e[5]=m,e[6]=f):(m=e[5],f=e[6]),(0,z.useEffect)(m,f);let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g=h(()=>{i(!0)},"m"),e[7]=g):g=e[7];let w=g,a;return e[8]!==c||e[9]!==u||e[10]!==t.key||e[11]!==l?(a=(0,o.jsx)("div",{className:"flex aspect-square w-full items-center justify-center overflow-hidden rounded-md border border-border bg-muted/30",children:u&&l!==null&&!c?(0,o.jsx)("img",{alt:t.key,className:"size-full object-cover",loading:"lazy",onError:w,src:l}):(0,o.jsx)(Et,{})}),e[8]=c,e[9]=u,e[10]=t.key,e[11]=l,e[12]=a):a=e[12],a},"Lt"),Bt=h(d=>{let e=(0,M.c)(42),{busy:t,copiedKey:r,handlers:l,object:n,prefix:c,references:i,resolveUrl:s,selected:u,showReferences:m,t:f}=d,g;e[0]!==l||e[1]!==n||e[2]!==c?(g=Ae(n,c,l),e[0]=l,e[1]=n,e[2]=c,e[3]=g):g=e[3];let{copy:w,download:a,name:k,remove:S,toggle:x}=g,b;e[4]!==n||e[5]!==s?(b=(0,o.jsx)(Lt,{object:n,resolveUrl:s}),e[4]=n,e[5]=s,e[6]=b):b=e[6];let y;e[7]!==n.key||e[8]!==u||e[9]!==f||e[10]!==x?(y=(0,o.jsx)("span",{className:"absolute left-1.5 top-1.5 rounded bg-background/80 p-0.5",children:(0,o.jsx)(Ze,{objectKey:n.key,onToggle:x,selected:u,t:f})}),e[7]=n.key,e[8]=u,e[9]=f,e[10]=x,e[11]=y):y=e[11];let v;e[12]!==b||e[13]!==y?(v=(0,o.jsxs)("div",{className:"relative",children:[b,y]}),e[12]=b,e[13]=y,e[14]=v):v=e[14];let j;e[15]!==k?(j=(0,o.jsx)("p",{className:"truncate font-mono text-xs",title:k,children:k}),e[15]=k,e[16]=j):j=e[16];let N;e[17]!==n.size?(N=xe(n.size),e[17]=n.size,e[18]=N):N=e[18];let C;e[19]!==N?(C=(0,o.jsx)("p",{className:"text-[11px] tabular-nums text-muted-foreground",children:N}),e[19]=N,e[20]=C):C=e[20];let T;e[21]!==n.key||e[22]!==i||e[23]!==m||e[24]!==f?(T=m&&(0,o.jsx)("div",{className:"mt-1",children:(0,o.jsx)(He,{objectKey:n.key,references:i,t:f})}),e[21]=n.key,e[22]=i,e[23]=m,e[24]=f,e[25]=T):T=e[25];let D;e[26]!==j||e[27]!==C||e[28]!==T?(D=(0,o.jsxs)("div",{className:"min-w-0",children:[j,C,T]}),e[26]=j,e[27]=C,e[28]=T,e[29]=D):D=e[29];let F=r===n.key,$;e[30]!==t||e[31]!==w||e[32]!==a||e[33]!==n.key||e[34]!==S||e[35]!==f||e[36]!==F?($=(0,o.jsx)("div",{className:"flex items-center gap-1",children:(0,o.jsx)(We,{busy:t,buttonClassName:"h-7 px-2 text-xs",copied:F,objectKey:n.key,onCopy:w,onDelete:S,onDownload:a,t:f})}),e[30]=t,e[31]=w,e[32]=a,e[33]=n.key,e[34]=S,e[35]=f,e[36]=F,e[37]=$):$=e[37];let O;return e[38]!==$||e[39]!==v||e[40]!==D?(O=(0,o.jsxs)("div",{className:"flex flex-col gap-1.5","data-testid":"fb-tile",children:[v,D,$]}),e[38]=$,e[39]=v,e[40]=D,e[41]=O):O=e[41],O},"Bt"),It=h(d=>{let e=(0,M.c)(9),{name:t,onEnter:r}=d,l;e[0]!==t||e[1]!==r?(l=h(()=>{r(t)},"n"),e[0]=t,e[1]=r,e[2]=l):l=e[2];let n=l,c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=(0,o.jsx)("span",{className:"flex aspect-square w-full items-center justify-center rounded-md border border-border bg-muted/30 transition-colors hover:bg-accent",children:(0,o.jsx)("svg",{"aria-hidden":"true",className:"size-10 text-muted-foreground",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.4,viewBox:"0 0 24 24",children:(0,o.jsx)("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"})})}),e[3]=c):c=e[3];let i;e[4]!==t?(i=(0,o.jsx)("span",{className:"truncate font-mono text-xs",title:t,children:t}),e[4]=t,e[5]=i):i=e[5];let s;return e[6]!==n||e[7]!==i?(s=(0,o.jsxs)("button",{className:"flex flex-col gap-1.5 text-left outline-none","data-testid":"fb-folder",onClick:n,type:"button",children:[c,i]}),e[6]=n,e[7]=i,e[8]=s):s=e[8],s},"It"),Rt=h(d=>{let e=(0,M.c)(34),{busy:t,copiedKey:r,files:l,folders:n,handlers:c,onEnterFolder:i,prefix:s,references:u,resolveUrl:m,selected:f,showReferences:g,size:w,t:a}=d,k;e[0]!==w?(k=w.toString(),e[0]=w,e[1]=k):k=e[1];let S=`repeat(auto-fill, minmax(${k}px, 1fr))`,x;e[2]!==S?(x={gridTemplateColumns:S},e[2]=S,e[3]=x):x=e[3];let b=x,y;if(e[4]!==n||e[5]!==i){let N;e[7]!==i?(N=h(C=>(0,o.jsx)(It,{name:C,onEnter:i},C),"w"),e[7]=i,e[8]=N):N=e[8],y=n.map(N),e[4]=n,e[5]=i,e[6]=y}else y=e[6];let v;if(e[9]!==t||e[10]!==r||e[11]!==l||e[12]!==c||e[13]!==s||e[14]!==u||e[15]!==m||e[16]!==f||e[17]!==g||e[18]!==a){let N;e[20]!==t||e[21]!==r||e[22]!==c||e[23]!==s||e[24]!==u||e[25]!==m||e[26]!==f||e[27]!==g||e[28]!==a?(N=h(C=>(0,o.jsx)(Bt,{busy:t,copiedKey:r,handlers:c,object:C,prefix:s,references:u[C.key],resolveUrl:m,selected:f.has(C.key),showReferences:g,t:a},C.key),"w"),e[20]=t,e[21]=r,e[22]=c,e[23]=s,e[24]=u,e[25]=m,e[26]=f,e[27]=g,e[28]=a,e[29]=N):N=e[29],v=l.map(N),e[9]=t,e[10]=r,e[11]=l,e[12]=c,e[13]=s,e[14]=u,e[15]=m,e[16]=f,e[17]=g,e[18]=a,e[19]=v}else v=e[19];let j;return e[30]!==b||e[31]!==y||e[32]!==v?(j=(0,o.jsxs)("div",{className:"grid gap-4","data-testid":"fb-gallery",style:b,children:[y,v]}),e[30]=b,e[31]=y,e[32]=v,e[33]=j):j=e[33],j},"Ot"),_t=h(d=>{let e=(0,M.c)(23),{reference:t,t:r}=d,l=`fb-dangling-${t.table}-${t.id}-${t.column}`,n=`${t.table}\xB7${t.id}`,c;e[0]!==n?(c=(0,o.jsx)(ae,{variant:"secondary",children:n}),e[0]=n,e[1]=c):c=e[1];let i;e[2]!==t.column?(i=(0,o.jsx)("span",{className:"text-muted-foreground",children:t.column}),e[2]=t.column,e[3]=i):i=e[3];let s;e[4]!==r?(s=r("\u2192"),e[4]=r,e[5]=s):s=e[5];let u;e[6]!==s?(u=(0,o.jsx)("span",{className:"text-muted-foreground/60",children:s}),e[6]=s,e[7]=u):u=e[7];let m;e[8]!==t.key?(m=(0,o.jsx)("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-foreground",children:t.key}),e[8]=t.key,e[9]=m):m=e[9];let f;e[10]!==c||e[11]!==i||e[12]!==u||e[13]!==m?(f=(0,o.jsxs)("span",{className:"flex flex-wrap items-center gap-1.5",children:[c,i,u,m]}),e[10]=c,e[11]=i,e[12]=u,e[13]=m,e[14]=f):f=e[14];let g;e[15]!==r?(g=r("Missing object"),e[15]=r,e[16]=g):g=e[16];let w;e[17]!==g?(w=(0,o.jsx)(ae,{className:"border-destructive/40 text-destructive",variant:"outline",children:g}),e[17]=g,e[18]=w):w=e[18];let a;return e[19]!==l||e[20]!==w||e[21]!==f?(a=(0,o.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-border/60 px-3 py-2 text-xs","data-testid":l,children:[f,w]}),e[19]=l,e[20]=w,e[21]=f,e[22]=a):a=e[22],a},"At"),Ut=h(d=>{let e=(0,M.c)(42),{busy:t,onCheck:r,references:l,t:n,truncated:c}=d,i;e[0]!==n?(i=n("Integrity"),e[0]=n,e[1]=i):i=e[1];let s;e[2]!==i?(s=(0,o.jsx)("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:i}),e[2]=i,e[3]=s):s=e[3];let u;e[4]!==n?(u=n("Orphaned objects"),e[4]=n,e[5]=u):u=e[5];let m;e[6]!==u?(m=(0,o.jsx)("span",{className:"text-sm font-medium text-foreground",children:u}),e[6]=u,e[7]=m):m=e[7];let f;e[8]!==n?(f=n("Find records whose file reference points at an object the bucket no longer has."),e[8]=n,e[9]=f):f=e[9];let g;e[10]!==f?(g=(0,o.jsx)("span",{className:"text-xs text-muted-foreground",children:f}),e[10]=f,e[11]=g):g=e[11];let w;e[12]!==s||e[13]!==m||e[14]!==g?(w=(0,o.jsxs)("div",{className:"flex flex-col gap-1",children:[s,m,g]}),e[12]=s,e[13]=m,e[14]=g,e[15]=w):w=e[15];let a;e[16]!==t||e[17]!==n?(a=n(t?"Checking\u2026":"Check for orphans"),e[16]=t,e[17]=n,e[18]=a):a=e[18];let k;e[19]!==t||e[20]!==r||e[21]!==a?(k=(0,o.jsx)(ee,{"data-testid":"fb-orphans-check",disabled:t,onClick:r,size:"sm",type:"button",variant:"outline",children:a}),e[19]=t,e[20]=r,e[21]=a,e[22]=k):k=e[22];let S;e[23]!==w||e[24]!==k?(S=(0,o.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[w,k]}),e[23]=w,e[24]=k,e[25]=S):S=e[25];let x;e[26]!==l||e[27]!==n||e[28]!==c?(x=c&&(0,o.jsx)("p",{className:"text-xs text-warning","data-testid":"fb-orphans-truncated",children:l===void 0||l.length===0?n("The bucket is larger than the scan's key limit, so dangling references could not be checked."):n("Showing the first {count} dangling references \u2014 the scan was truncated.",{count:l.length})}),e[26]=l,e[27]=n,e[28]=c,e[29]=x):x=e[29];let b;e[30]!==l?.length||e[31]!==n||e[32]!==c?(b=l?.length===0&&!c&&(0,o.jsx)(pe,{description:n("Every record's file reference points at an object that exists in the bucket."),testId:"fb-orphans-empty",title:n("No dangling references.")}),e[30]=l?.length,e[31]=n,e[32]=c,e[33]=b):b=e[33];let y;e[34]!==l||e[35]!==n?(y=l!==void 0&&l.length>0&&(0,o.jsx)("ul",{className:"flex flex-col gap-1.5","data-testid":"fb-orphans-list",children:l.map(j=>(0,o.jsx)(_t,{reference:j,t:n},`${j.table}\xB7${j.id}\xB7${j.column}`))}),e[34]=l,e[35]=n,e[36]=y):y=e[36];let v;return e[37]!==S||e[38]!==x||e[39]!==b||e[40]!==y?(v=(0,o.jsxs)("section",{className:"flex flex-col gap-2 rounded-lg border border-border/60 p-3","data-testid":"fb-orphans",children:[S,x,b,y]}),e[37]=S,e[38]=x,e[39]=b,e[40]=y,e[41]=v):v=e[41],v},"Ut"),Mt=h(function(d,e){let t=(0,M.c)(18),r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=new Set,t[0]=r):r=t[0];let[l,n]=(0,z.useState)(r),c;t[1]===Symbol.for("react.memo_cache_sentinel")?(c=h(x=>{n(b=>{let y=new Set(b);return y.has(x)?y.delete(x):y.add(x),y})},"a"),t[1]=c):c=t[1];let i=c,s;t[2]===Symbol.for("react.memo_cache_sentinel")?(s=h(()=>{n(new Set)},"o"),t[2]=s):s=t[2];let u=s,m,f,g;if(t[3]!==d||t[4]!==e||t[5]!==l){let x;t[9]!==e?(x=h(b=>e(b),"y"),t[9]=e,t[10]=x):x=t[10],f=d.map(x),m=f.length>0&&f.every(b=>l.has(b)),g=!m&&f.some(b=>l.has(b)),t[3]=d,t[4]=e,t[5]=l,t[6]=m,t[7]=f,t[8]=g}else m=t[6],f=t[7],g=t[8];let w=g,a;t[11]!==f?(a=h(()=>{n(x=>f.every(b=>x.has(b))?new Set:new Set(f))},"i"),t[11]=f,t[12]=a):a=t[12];let k=a,S;return t[13]!==m||t[14]!==l||t[15]!==w||t[16]!==k?(S={allSelected:m,clear:u,selected:l,someSelected:w,toggle:i,toggleAll:k},t[13]=m,t[14]=l,t[15]=w,t[16]=k,t[17]=S):S=t[17],S},"Mt"),Pt=be(ve.storageReferences),At=be(ve.storageOrphans),Me=1e4,Wt=1e3,Ht=h(async d=>{let e=[],t,r=!0,l=!1;for(;r&&e.length<Me;){let n=await d.list({cursor:t,limit:Wt}),c=Me-e.length;for(let i of n.objects.slice(0,c))e.push(i.key);l||=n.objects.length>c,t=n.cursor,r=t!==void 0}return{liveKeys:e,truncated:l||r}},"qt"),Zt=3600,qt=h((d,e)=>{if(!("document"in globalThis))return;let t=globalThis.document.createElement("a");t.href=d,t.download=e,t.rel="noopener",globalThis.document.body.append(t),t.click(),t.remove()},"Vt"),Gt=h(d=>d.key,"Zt"),Vt=h(({initialPrefix:d,pageSize:e})=>{let t=je(),[r,l]=(0,z.useState)(d??""),[n,c]=(0,z.useState)(d??""),[i,s]=(0,z.useState)(Ct),[u,m]=(0,z.useState)("list"),[f,g]=(0,z.useState)(128),[w,a]=(0,z.useState)("name"),[k,S]=(0,z.useState)("asc"),[x,b]=(0,z.useState)(void 0),[y,v]=(0,z.useState)(void 0),[j,N]=(0,z.useState)(!1),[C,T]=(0,z.useState)(void 0),[D,F]=(0,z.useState)(void 0),[$,O]=(0,z.useState)(""),[I,L]=(0,z.useState)({}),[R,E]=(0,z.useState)(!1),[B,U]=(0,z.useState)(void 0),[P,W]=(0,z.useState)(!1),[A,H]=(0,z.useState)(!1),[V,re]=(0,z.useState)([]),[q,we]=(0,z.useState)(""),ne=(0,z.useRef)(0),Q=(0,z.useRef)(0),ce=(0,z.useRef)(0);(0,z.useEffect)(()=>{let p={cancelled:!1};return Z((async()=>{try{let K=await t.listStorageBuckets();if(!p.cancelled){re(K);let[_]=K;_!==void 0&&we(J=>J===""?_:J)}}catch{}})()),()=>{p.cancelled=!0}},[t]);let G=(0,z.useMemo)(()=>({list:h(p=>t.listStorageObjects({...p,bucket:q}),"list"),remove:h(p=>t.deleteStorageObject(p,{bucket:q}),"remove"),signedUrl:h((p,K)=>t.signedStorageUrl(p,{...K,bucket:q}),"signedUrl"),upload:h(p=>t.uploadStorageObject({...p,bucket:q}),"upload")}),[q,t]),Y=(0,z.useCallback)(async(p,K,_,J=!1)=>{ne.current+=1;let me=ne.current;v(void 0),N(!0);try{let oe=await G.list({cursor:K,limit:e,prefix:p});if(me!==ne.current)return;b(Ce=>_&&Ce!==void 0?[...Ce,...oe.objects]:oe.objects),F(oe.cursor)}catch(oe){if(me!==ne.current)return;if(_||b(void 0),v(le(oe)),J)throw oe}finally{me===ne.current&&N(!1)}},[e,G]);(0,z.useEffect)(()=>{Z(Y(d??"",void 0,!1))},[Y,d]);let qe=(x?.length??0)<=e;Ie(()=>Y(r,void 0,!1,!0),qe);let{files:ue,folders:Ge}=zt(x??[],r),Ve=(0,z.useMemo)(()=>{let p=new Set;for(let K of ue)for(let _ of Object.keys(K.customMetadata??{}))p.add(_);return[...p].toSorted((K,_)=>K.localeCompare(_))},[ue]),ie=jt(ue,w,k),fe=(0,z.useMemo)(()=>[...new Set(ie.map(p=>p.key))].toSorted((p,K)=>p.localeCompare(K)).join(`
3
3
  `),[ie]);(0,z.useEffect)(()=>{let p=fe===""?[]:fe.split(`
4
4
  `);if(p.length===0){L({});return}let K={current:!0};return Z((async()=>{try{let _=await t.query(Pt,{keys:p},ye($));K.current&&(L(_.references??{}),E(Object.keys(_.storageColumns??{}).length>0))}catch{K.current&&(L({}),E(!1))}})()),()=>{K.current=!1}},[t,fe,$]);let{allSelected:Qe,clear:se,selected:Se,someSelected:Xe,toggle:Ye,toggleAll:Je}=Mt(ie,Gt),et=h(()=>{l(n),se(),Z(Y(n,void 0,!1))},"Me"),tt=h(()=>{Z(Y(r,D,!0))},"Ge"),Ne=h(p=>{l(p),c(p),se(),Z(Y(p,void 0,!1))},"ve"),rt=h(p=>{Ne(`${r}${p}`)},"He"),nt=h(p=>G.signedUrl(p,{expiresInSeconds:Zt}),"Pe"),ot=h(()=>{m("list")},"qe"),lt=h(()=>{m("grid")},"We"),st=h(p=>{a(p)},"Ve"),at=h(()=>{S(p=>p==="asc"?"desc":"asc")},"Ze"),ct=h(p=>{g(p)},"Xe"),it=h(p=>{s(p)},"Ye"),he=h(p=>{let K=ce.current;v(void 0),N(!0),Z((async()=>{try{await p(),K===ce.current&&await Y(r,void 0,!1)}catch(_){v(le(_))}K===ce.current&&N(!1)})())},"me"),dt=h(()=>{he(async()=>{for(let p of Se)await G.remove(p);se()})},"Je"),ut=h(p=>{v(void 0),Z((async()=>{try{let K=await G.signedUrl(p,{expiresInSeconds:i});Ke(K)&&T(p)}catch(K){v(le(K))}})())},"Qe"),ft=h(p=>{v(void 0),Z((async()=>{try{let K=await G.signedUrl(p,{expiresInSeconds:i}),_=p.slice(p.lastIndexOf("/")+1)||p;qt(K,_)}catch(K){v(le(K))}})())},"et");(0,z.useEffect)(()=>{if(C===void 0)return;let p=globalThis.setTimeout(()=>{T(void 0)},2e3);return()=>{globalThis.clearTimeout(p)}},[C]);let ht=h(p=>{he(async()=>{await G.remove(p)})},"tt"),mt=h(p=>{let K=`${r}${p.name}`;he(async()=>{let _=await p.arrayBuffer();await G.upload({body:_,contentType:p.type===""?void 0:p.type,key:K})})},"st");(0,z.useEffect)(()=>{Q.current+=1,U(void 0),H(!1)},[$]);let gt=h(()=>{Q.current+=1;let p=Q.current;v(void 0),W(!0),Z((async()=>{try{let{liveKeys:K,truncated:_}=await Ht(G);if(_)p===Q.current&&(U(void 0),H(!0));else{let J=await t.query(At,{liveKeys:K},ye($));p===Q.current&&(U(J.references??[]),H(J.truncated===!0))}}catch(K){p===Q.current&&(U(void 0),H(!1),v(le(K)))}p===Q.current&&W(!1)})())},"lt"),pt=h(p=>{ne.current+=1,Q.current+=1,ce.current+=1,we(p),l(d??""),c(d??""),b(void 0),U(void 0),H(!1),se()},"nt");return{allSelected:Qe,bucket:q,buckets:V,bulkDelete:dt,busy:j,checkOrphans:gt,clearSelection:se,copiedKey:C,danglingBusy:P,danglingReferences:B,danglingTruncated:A,draftPrefix:n,enterFolder:rt,error:y,expiry:i,files:ie,folders:Ge,hasObjects:x!==void 0&&x.length>0,hasStorageColumns:R,listFirst:et,loaded:x!==void 0,loadMore:tt,navigate:Ne,nextCursor:D,onCopy:ut,onDelete:ht,onDownload:ft,onExpiryChange:it,onFile:mt,onSortKeyChange:st,onThumbSizeChange:ct,prefix:r,referenceShard:$,references:I,resolveUrl:nt,selectBucket:pt,selected:Se,setDraftPrefix:c,setReferenceShard:O,showGrid:lt,showList:ot,someSelected:Xe,sortDirection:k,sortKey:w,tagKeys:Ve,thumbSize:f,toggleSelect:Ye,toggleSelectAll:Je,toggleSortDirection:at,view:u}},"Xt"),Qt=100,Pe=h(d=>{let e=(0,M.c)(6),{label:t,onNavigate:r,target:l}=d,n;e[0]!==r||e[1]!==l?(n=h(()=>{r(l)},"l"),e[0]=r,e[1]=l,e[2]=n):n=e[2];let c=n,i;return e[3]!==c||e[4]!==t?(i=(0,o.jsx)("button",{className:"rounded px-1 text-muted-foreground outline-none hover:text-foreground focus-visible:text-foreground",onClick:c,type:"button",children:t}),e[3]=c,e[4]=t,e[5]=i):i=e[5],i},"Ne"),Xt=h(d=>{let e=(0,M.c)(11),{onNavigate:t,prefix:r,t:l}=d,n;if(e[0]!==t||e[1]!==r||e[2]!==l){let c=r.split("/").filter(Yt),i;e[4]!==l?(i=l("Folder path"),e[4]=l,e[5]=i):i=e[5];let s;e[6]!==l?(s=l("root"),e[6]=l,e[7]=s):s=e[7];let u;e[8]!==t||e[9]!==s?(u=(0,o.jsx)(Pe,{label:s,onNavigate:t,target:""}),e[8]=t,e[9]=s,e[10]=u):u=e[10],n=(0,o.jsxs)("nav",{"aria-label":i,className:"flex flex-wrap items-center gap-0.5 text-xs","data-testid":"fb-breadcrumbs",children:[u,c.map((m,f)=>(0,o.jsxs)("span",{className:"flex items-center gap-0.5",children:[(0,o.jsx)("span",{className:"text-muted-foreground/50",children:"/"}),(0,o.jsx)(Pe,{label:m,onNavigate:t,target:`${c.slice(0,f+1).join("/")}/`})]},`${m}-${f.toString()}`))]}),e[0]=t,e[1]=r,e[2]=l,e[3]=n}else n=e[3];return n},"Jt"),gr=h(({initialPrefix:d,pageSize:e=Qt})=>{let t=ze(),r=Vt({initialPrefix:d,pageSize:e}),l=(0,z.useRef)(null),{onCopy:n,onDelete:c,onDownload:i,onFile:s,toggleSelect:u}=r,m={onCopy:n,onDelete:c,onDownload:i,onToggleSelect:u},f=h(()=>{l.current?.click()},"u"),g=h(a=>{let k=a.target,S=k.files?.[0];k.value="",S&&s(S)},"m"),w=r.loaded&&!r.hasObjects;return(0,o.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-file-browser",children:[(0,o.jsx)(Dt,{bucket:r.bucket,buckets:r.buckets,busy:r.busy,draftPrefix:r.draftPrefix,expiry:r.expiry,fileInputRef:l,onBucketChange:r.selectBucket,onExpiryChange:r.onExpiryChange,onFileChange:g,onList:r.listFirst,onPrefixChange:r.setDraftPrefix,onUploadClick:f,t}),r.loaded&&(0,o.jsx)(Xt,{onNavigate:r.navigate,prefix:r.prefix,t}),r.hasObjects&&(0,o.jsx)(Tt,{onSortKeyChange:r.onSortKeyChange,onThumbSizeChange:r.onThumbSizeChange,showGrid:r.showGrid,showList:r.showList,sortDirection:r.sortDirection,sortKey:r.sortKey,t,tagKeys:r.tagKeys,thumbSize:r.thumbSize,toggleSortDirection:r.toggleSortDirection,view:r.view}),r.hasStorageColumns&&(0,o.jsxs)("div",{className:"flex flex-wrap items-center gap-2","data-testid":"fb-references-shard",children:[(0,o.jsx)("label",{className:"text-xs text-muted-foreground",htmlFor:"fb-reference-shard-input",children:t("References shard")}),(0,o.jsx)(Fe,{id:"fb-reference-shard-input",onChange:r.setReferenceShard,testId:"fb-reference-shard-input",value:r.referenceShard}),(0,o.jsx)("span",{className:"text-xs text-muted-foreground",children:t("Which shard's records are checked for references to these files. Empty = root shard.")})]}),r.hasStorageColumns&&(0,o.jsx)(Ut,{busy:r.danglingBusy,onCheck:r.checkOrphans,references:r.danglingReferences,t,truncated:r.danglingTruncated}),r.selected.size>0&&(0,o.jsx)(Re,{count:r.selected.size,editable:!0,onClear:r.clearSelection,onDelete:r.bulkDelete}),r.error!==void 0&&(0,o.jsx)("p",{className:"text-sm text-destructive","data-testid":"storage-error",role:"alert",children:r.error}),w&&(0,o.jsx)(pe,{description:t("Objects you upload to your R2 buckets will appear here."),icon:(0,o.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,o.jsx)("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"}),(0,o.jsx)("path",{d:"M12 11v5m-2.5-2.5h5"})]}),testId:"fb-empty",title:t("No objects.")}),r.hasObjects&&r.view==="list"&&(0,o.jsx)(St,{allSelected:r.allSelected,busy:r.busy,copiedKey:r.copiedKey,files:r.files,folders:r.folders,handlers:m,onEnterFolder:r.enterFolder,prefix:r.prefix,references:r.references,selected:r.selected,showReferences:r.hasStorageColumns,someSelected:r.someSelected,t,toggleSelectAll:r.toggleSelectAll}),r.hasObjects&&r.view==="grid"&&(0,o.jsx)(Rt,{busy:r.busy,copiedKey:r.copiedKey,files:r.files,folders:r.folders,handlers:m,onEnterFolder:r.enterFolder,prefix:r.prefix,references:r.references,resolveUrl:r.resolveUrl,selected:r.selected,showReferences:r.hasStorageColumns,size:r.thumbSize,t}),r.nextCursor!==void 0&&(0,o.jsx)("div",{children:(0,o.jsx)(ee,{"data-testid":"fb-next",disabled:r.busy,onClick:r.loadMore,size:"sm",type:"button",variant:"outline",children:t("Load more")})})]})},"xs");function Yt(d){return d!==""}h(Yt,"Qt");export{gr as FileBrowser};
@@ -0,0 +1,15 @@
1
+ import{a as Fe,b as Ke}from"./chunk-G2YF7RNG.js";import{a as We}from"./chunk-O75FH2VA.js";import{d as He}from"./chunk-4CGBMYO3.js";import"./chunk-NQZALRU3.js";import"./chunk-OPM7ESDV.js";import"./chunk-Y3AYVFTK.js";import"./chunk-QJLHH3ET.js";import"./chunk-OYCUPD3Q.js";import"./chunk-NXQW5E6W.js";import"./chunk-UC7MNI2F.js";import{a as ze}from"./chunk-IWZ7GVQO.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import"./chunk-XSW4R2MI.js";import"./chunk-AUGKHAMQ.js";import"./chunk-WJRYEML4.js";import"./chunk-LXCVA5SP.js";import{a as Pe}from"./chunk-7Q256NLI.js";import{b as Oe}from"./chunk-ZKJS6EBE.js";import{c as $e,d as pe,e as ve,f as ye,g as Ee}from"./chunk-RGMVGZV4.js";import{i as qe}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import"./chunk-BOMPSVRC.js";import{a as je}from"./chunk-NCPW7WHO.js";import{a as he}from"./chunk-4ZEL6BYL.js";import"./chunk-NWWMHMGA.js";import{l as xe}from"./chunk-3JVXNEBO.js";import"./chunk-QAQDMS6R.js";import"./chunk-BAWEGZ7T.js";import"./chunk-HCTJKP5J.js";import{d as se,f as me,g as fe,h as Ae,q as ae}from"./chunk-74IYYDDI.js";import{a as i,d as ke,e as ct,f as dt,g as ut,i as ie}from"./chunk-I26MS5PJ.js";var X=ke(dt(),1);var j=ke(ct(),1);var u=ke(ut(),1);var be=class{static{i(this,"Diff")}diff(e,n,t={}){let o;typeof t=="function"?(o=t,t={}):"callback"in t&&(o=t.callback);let r=this.castInput(e,t),l=this.castInput(n,t),d=this.removeEmpty(this.tokenize(r,t)),a=this.removeEmpty(this.tokenize(l,t));return this.diffWithOptionsObj(d,a,t,o)}diffWithOptionsObj(e,n,t,o){var r;let l=i(h=>{if(h=this.postProcess(h,t),o){setTimeout(function(){o(h)},0);return}else return h},"done"),d=n.length,a=e.length,c=1,m=d+a;t.maxEditLength!=null&&(m=Math.min(m,t.maxEditLength));let p=(r=t.timeout)!==null&&r!==void 0?r:1/0,f=Date.now()+p,v=[{oldPos:-1,lastComponent:void 0}],g=this.extractCommon(v[0],n,e,0,t);if(v[0].oldPos+1>=a&&g+1>=d)return l(this.buildValues(v[0].lastComponent,n,e));let E=-1/0,x=1/0,y=i(()=>{for(let h=Math.max(E,-c);h<=Math.min(x,c);h+=2){let S,w=v[h-1],C=v[h+1];w&&(v[h-1]=void 0);let b=!1;if(C){let N=C.oldPos-h;b=C&&0<=N&&N<d}let k=w&&w.oldPos+1<a;if(!b&&!k){v[h]=void 0;continue}if(!k||b&&w.oldPos<C.oldPos?S=this.addToPath(C,!0,!1,0,t):S=this.addToPath(w,!1,!0,1,t),g=this.extractCommon(S,n,e,h,t),S.oldPos+1>=a&&g+1>=d)return l(this.buildValues(S.lastComponent,n,e))||!0;v[h]=S,S.oldPos+1>=a&&(x=Math.min(x,h-1)),g+1>=d&&(E=Math.max(E,h+1))}c++},"execEditLength");if(o)i(function h(){setTimeout(function(){if(c>m||Date.now()>f)return o(void 0);y()||h()},0)},"exec")();else for(;c<=m&&Date.now()<=f;){let h=y();if(h)return h}}addToPath(e,n,t,o,r){let l=e.lastComponent;return l&&!r.oneChangePerToken&&l.added===n&&l.removed===t?{oldPos:e.oldPos+o,lastComponent:{count:l.count+1,added:n,removed:t,previousComponent:l.previousComponent}}:{oldPos:e.oldPos+o,lastComponent:{count:1,added:n,removed:t,previousComponent:l}}}extractCommon(e,n,t,o,r){let l=n.length,d=t.length,a=e.oldPos,c=a-o,m=0;for(;c+1<l&&a+1<d&&this.equals(t[a+1],n[c+1],r);)c++,a++,m++,r.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return m&&!r.oneChangePerToken&&(e.lastComponent={count:m,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=a,c}equals(e,n,t){return t.comparator?t.comparator(e,n):e===n||!!t.ignoreCase&&e.toLowerCase()===n.toLowerCase()}removeEmpty(e){let n=[];for(let t=0;t<e.length;t++)e[t]&&n.push(e[t]);return n}castInput(e,n){return e}tokenize(e,n){return Array.from(e)}join(e){return e.join("")}postProcess(e,n){return e}get useLongestToken(){return!1}buildValues(e,n,t){let o=[],r;for(;e;)o.push(e),r=e.previousComponent,delete e.previousComponent,e=r;o.reverse();let l=o.length,d=0,a=0,c=0;for(;d<l;d++){let m=o[d];if(m.removed)m.value=this.join(t.slice(c,c+m.count)),c+=m.count;else{if(!m.added&&this.useLongestToken){let p=n.slice(a,a+m.count);p=p.map(function(f,v){let g=t[c+v];return g.length>f.length?g:f}),m.value=this.join(p)}else m.value=this.join(n.slice(a,a+m.count));a+=m.count,m.added||(c+=m.count)}}return o}};var Te=class extends be{static{i(this,"LineDiff")}constructor(){super(...arguments),this.tokenize=mt}equals(e,n,t){return t.ignoreWhitespace?((!t.newlineIsToken||!e.includes(`
2
+ `))&&(e=e.trim()),(!t.newlineIsToken||!n.includes(`
3
+ `))&&(n=n.trim())):t.ignoreNewlineAtEof&&!t.newlineIsToken&&(e.endsWith(`
4
+ `)&&(e=e.slice(0,-1)),n.endsWith(`
5
+ `)&&(n=n.slice(0,-1))),super.equals(e,n,t)}},Be=new Te;function Ie(s,e,n){return Be.diff(s,e,n)}i(Ie,"diffLines");function mt(s,e){e.stripTrailingCr&&(s=s.replace(/\r\n/g,`
6
+ `));let n=[],t=s.split(/(\n|\r\n)/);t[t.length-1]||t.pop();for(let o=0;o<t.length;o++){let r=t[o];o%2&&!e.newlineIsToken?n[n.length-1]+=r:n.push(r)}return n}i(mt,"tokenize");var ft="x",Qe=" ",ht={'"':'"',"'":"'","[":"]","`":"`"},Ue=i((s,e)=>{let n=e+2;for(;n<s.length&&s[n]!==`
7
+ `;)n+=1;return n},"He"),Xe=i((s,e)=>{let n=s.indexOf("*/",e+2);return n===-1?-1:n+2},"Fe"),Ze=i(s=>{let e=s.split(""),n=0;for(;n<s.length;){let t=s[n]??"",o=ht[t];if(t==="-"&&s[n+1]==="-"){let r=Ue(s,n);e.fill(Qe,n,r),n=r}else if(t==="/"&&s[n+1]==="*"){let r=Xe(s,n);if(r===-1)return;e.fill(Qe,n,r),n=r}else if(o!==void 0){let r=n+1;for(;r<s.length;)if(s[r]!==o)r+=1;else if(o!=="]"&&s[r+1]===o)r+=2;else break;if(r>=s.length)return;e.fill(ft,n,r+1),n=r+1}else n+=1}for(let t=0;t<s.length;t+=1)s[t]===`
8
+ `&&(e[t]=`
9
+ `);return e.join("")},"We"),pt=/^(?:explain\s+(?:query\s+plan\s+)?)?(?:select|with)\b/iu,bt=/\b(?:alter|attach|create|delete|detach|drop|insert|pragma|reindex|truncate|update|vacuum)\b|\breplace\b(?!\s*\()/iu,gt=/^\w+/u,xt=/;\s*$/u,vt=/\s/u,et=i(s=>{let e=0;for(;e<s.length;){let n=s[e];if(n!==void 0&&vt.test(n))e+=1;else if(n==="-"&&s[e+1]==="-")e=Ue(s,e);else if(n==="/"&&s[e+1]==="*"){let t=Xe(s,e);if(t===-1)break;e=t}else break}return e},"Ke"),yt=i(s=>{let e=et(s),n=s.slice(e).trimEnd();if(n==="")return{code:"SQL_EMPTY",message:"the query is empty"};let t=(Ze(n)??n).replace(xt,""),o=n.slice(0,t.length),r=t.indexOf(";");if(r!==-1)return{code:"SQL_MULTIPLE_STATEMENTS",length:1,message:"only a single statement may be run",offset:e+r};let l="the SQL editor is read-only \u2014 only SELECT / WITH / EXPLAIN queries are allowed";if(!pt.test(o))return{code:"SQL_NOT_READONLY",length:gt.exec(o)?.[0].length??1,message:l,offset:e};let d=bt.exec(o);if(d!==null)return{code:"SQL_NOT_READONLY",length:d[0].length,message:`${l} (\`${d[0].toUpperCase()}\` is not allowed)`,offset:e+d.index}},"xt"),wt=/^explain\b/iu,St=i(s=>wt.test(s.slice(et(s)))?s:`EXPLAIN QUERY PLAN ${s}`,"yt"),_e=i((s,e)=>{let n=s.trim();if(n==="")return[];let t=e+s.indexOf(n),o=yt(n);return o?.code==="SQL_EMPTY"?[]:[o===void 0?{offset:t,sql:n}:{offset:t,rejection:o,sql:n}]},"ke"),tt=i(s=>{let e=Ze(s);if(e===void 0)return _e(s,0);let n=[],t=0;for(let o=0;o<=e.length;o+=1)o!==e.length&&e[o]!==";"||(n.push(..._e(s.slice(t,o),t)),t=o+1);return n},"ze"),Ct=["ORDER BY","GROUP BY","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN","EXPLAIN QUERY PLAN","SELECT","DISTINCT","FROM","WHERE","HAVING","LIMIT","OFFSET","JOIN","ON","AND","OR","AS","ASC","DESC","WITH","UNION","EXPLAIN"],Nt=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],Ne=String.fromCodePoint(0),kt=new RegExp(`${Ne}${String.raw`(\d+)`}${Ne}`,"gu"),qt=Ct.map(s=>({pattern:new RegExp(String.raw`\b${s.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:s})),Et=Nt.map(s=>({pattern:new RegExp(String.raw`\s+${s.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
10
+ ${s}`})),Tt=i(s=>{let e=[],n=s.replaceAll(/'(?:[^']|'')*'/gu,t=>(e.push(t),`${Ne}${(e.length-1).toString()}${Ne}`)).replaceAll(/\s+/gu," ").trim();for(let{pattern:t,replacement:o}of qt)n=n.replaceAll(t,o);for(let{pattern:t,replacement:o}of Et)n=n.replaceAll(t,o);return n=n.replaceAll(kt,(t,o)=>e[Number(o)]??""),n},"kt"),It=/\b(?:from|join)\s+([a-z_][\w$]*)(?:\s+(?:as\s+)?([a-z_][\w$]*))?/giu,Lt=/(?:\bwith\s+(?:recursive\s+)?|,\s*)([a-z_][\w$]*)\s+as\s*\(/giu,_t=new Set(["cross","full","group","having","inner","join","left","limit","offset","on","order","right","union","using","where","window"]),Rt=/[^\n]/gu,Dt=i((s,e)=>{let n=s[e];if(n==="'"){let t=e+1;for(;t<s.length&&s[t]!=="'";)t+=1;return Math.min(t+1,s.length)}if(n==="-"&&s[e+1]==="-"){let t=s.indexOf(`
11
+ `,e);return t===-1?s.length:t}if(n==="/"&&s[e+1]==="*"){let t=s.indexOf("*/",e+2);return t===-1?s.length:t+2}return-1},"_t"),Mt=i(s=>{let e="",n=0;for(;n<s.length;){let t=Dt(s,n);t===-1?(e+=s.slice(n,n+1),n+=1):(e+=s.slice(n,t).replaceAll(Rt," "),n=t)}return e},"At"),At=i(s=>{let e=new Set;for(let n of s.matchAll(Lt))e.add((n[1]??"").toLowerCase());return e},"qt"),$t=i((s,e)=>{let n=new Map;for(let t of s.matchAll(It)){let o=(t[1]??"").toLowerCase(),r=(t[2]??"").toLowerCase();e.has(o)&&(n.set(o,o),r!==""&&!_t.has(r)&&n.set(r,o))}return n},"Dt"),nt=i((s,e)=>{let n=Mt(s),t=new Set(e.map(o=>o.toLowerCase()));return{ctes:At(n),masked:n,targets:$t(n,t)}},"Ue"),Ot=/^(?:__lunora|sqlite_)/iu,Pt=/\b(?:from|join)\s+([a-z_][\w$]*)/giu,jt=/\b([a-z_][\w$]*)\.([a-z_][\w$]*)/giu,zt=new Set(["cross","full","group","having","inner","join","lateral","left","limit","offset","order","right","select","union","where","window"]),Wt=i((s,e,n)=>{let t=[];for(let o of s.matchAll(Pt)){let r=o[1]??"",l=r.toLowerCase();!e.has(l)&&!n.has(l)&&!zt.has(l)&&!Ot.test(r)&&t.push({length:r.length,message:`unknown table \`${r}\``,offset:o.index+o[0].length-r.length,severity:"error",source:"schema"})}return t},"Pt"),Ht=i((s,e,n)=>{let t=[],o=new Map;for(let[r,l]of Object.entries(e.columns))o.set(r.toLowerCase(),new Set(l.map(d=>d.toLowerCase())));for(let r of s.matchAll(jt)){let l=(r[1]??"").toLowerCase(),d=r[2]??"",a=n.get(l),c=a===void 0?void 0:o.get(a);c!==void 0&&!c.has(d.toLowerCase())&&t.push({length:d.length,message:`\`${a??""}\` has no column \`${d}\``,offset:r.index+r[0].length-d.length,severity:"error",source:"schema"})}return t},"Ht"),Ft=/(?<![\w$."])(?:"([a-z_][\w$]*)"|([a-z_][\w$]*))(?![.(])/giu,Kt=/\bas\s+"?([a-z_][\w$]*)"?/giu,Bt=i((s,e,n,t)=>{let o=[...new Set(n.values())],r=new Map,l=new Set;for(let c of o){for(let m of e.columns[c]??[])l.add(m.toLowerCase());for(let m of e.docFields?.[c]??[])r.set(m.toLowerCase(),m)}if(r.size===0)return[];let d=new Set([...s.matchAll(Kt)].map(c=>(c[1]??"").toLowerCase())),a=[];for(let c of s.matchAll(Ft)){let m=c[1],p=m??c[2]??"",f=p.toLowerCase(),v=r.get(f);v===void 0||l.has(f)||d.has(f)||t.has(f)||n.has(f)||a.push({length:p.length,message:`\`${v}\` is a \`__doc__\` field, not a column \u2014 use \`json_extract(__doc__, '$.${v}')\``,offset:c.index+(m===void 0?0:1),severity:"error",source:"schema"})}return a},"Kt"),Qt=i((s,e)=>{if(s.trim()==="")return[];let n=tt(s),t=new Set(e.tables.map(r=>r.toLowerCase())),o=[];for(let r of n){let{offset:l,rejection:d}=r;if(d!==void 0){o.push({length:d.length,message:d.message,offset:d.offset===void 0?l:l+d.offset,severity:"error",source:"gate"});continue}let{ctes:a,masked:c,targets:m}=nt(r.sql,e.tables);o.push(...[...Wt(c,t,a),...Ht(c,e,m),...Bt(c,e,m,a)].map(p=>({...p,offset:p.offset===void 0?l:l+p.offset})))}return o},"zt"),Yt=me(he.lintSql),Jt=600,Vt=i((s,e,n)=>{let t=xe(),[o,r]=(0,j.useState)([]),l=(0,j.useMemo)(()=>Qt(s,e),[s,e]),d=ze(s,Jt),a=l.some(p=>p.source==="gate")||d.trim()==="",c=(0,j.useCallback)(async p=>{try{let f=await t.query(Yt,{sql:d},fe(n));p.cancelled||r(f.diagnostics??[])}catch{p.cancelled||r([])}},[t,d,n]);(0,j.useEffect)(()=>{if(a){r([]);return}let p={cancelled:!1};return ae(c(p)),()=>{p.cancelled=!0}},[c,a]);let m=d===s;return(0,j.useMemo)(()=>m?[...l,...o]:l,[l,o,m])},"Qt"),we=8,Gt=["AND","ASC","AS","BY","COUNT","DESC","DISTINCT","EXPLAIN","FROM","GROUP","HAVING","INNER","JOIN","LEFT","LIKE","LIMIT","NOT","NULL","OFFSET","ON","ORDER","OR","QUERY","SELECT","WHERE","WITH"],Ut=new Set(["AND","BY","HAVING","ON","OR","SELECT","WHERE"]),Xt=/[\w$]/,ot=i(s=>s!==void 0&&Xt.test(s),"je"),rt=i(s=>{let e=s.length;for(;e>0&&ot(s[e-1]);)e-=1;return s.slice(e)},"Qe"),st=i((s,e)=>{let n=e;for(;n>0&&ot(s[n-1]);)n-=1;return{end:e,start:n,text:s.slice(n,e)}},"Ye"),Ye=i((s,e)=>{let n=s.slice(0,e).trimEnd();return n.endsWith(".")||Ut.has(rt(n).toUpperCase())},"De"),Zt=i((s,e,n)=>{let t=s.slice(0,e);if(!t.endsWith("."))return;let o=rt(t.slice(0,-1));if(o!=="")return nt(s,n).targets.get(o.toLowerCase())??o},"Vt"),Re=i((s,e)=>s.toLowerCase().startsWith(e.toLowerCase()),"Ie"),Je=i((s,e,n,t)=>{let o=[];for(let r of s)if(Re(r,e)&&(o.push(t(r)),o.length>=n))break;return o},"Oe"),en=i((s,e,n)=>{let t=new Map;for(let[o,r]of Object.entries(s.columns))for(let l of r)if(Re(l,e)&&!t.has(l)&&(t.set(l,o),t.size>=n))return[...t].map(([d,a])=>({detail:a,kind:"column",label:d}));return[...t].map(([o,r])=>({detail:r,kind:"column",label:o}))},"Xt"),tn=i((s,e,n)=>{let t=st(s,e),o=Zt(s,t.start,n.tables);if(o!==void 0){let a=n.columns[o]??n.columns[o.toLowerCase()]??[];return Je(a,t.text,we,c=>({detail:o,kind:"column",label:c}))}if(t.text===""&&!Ye(s,t.start))return[];let r=Je(n.tables,t.text,we,a=>({kind:"table",label:a})),l=en(n,t.text,we),d=Gt.flatMap(a=>t.text!==""&&Re(a,t.text)&&a.toLowerCase()!==t.text.toLowerCase()?[{kind:"keyword",label:a}]:[]);return(Ye(s,t.start)?[...l,...r,...d]:[...r,...l,...d]).slice(0,we)},"Zt"),nn=i((s,e,n)=>{let t=st(s,e),o=s.slice(0,t.start)+n.label+s.slice(t.end);return{caret:t.start+n.label.length,value:o}},"en"),on=["boxSizing","borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textTransform","width","wordSpacing"],rn=i((s,e)=>{let n=globalThis.getComputedStyle(s),t=globalThis.document.createElement("div"),{style:o}=t;o.position="absolute",o.visibility="hidden",o.whiteSpace="pre-wrap",o.overflowWrap="break-word";for(let a of on)o[a]=n[a];t.textContent=s.value.slice(0,Math.max(0,e));let r=globalThis.document.createElement("span");r.textContent=s.value.slice(Math.max(0,e))||".",t.append(r),globalThis.document.body.append(t);let l=r.offsetLeft-s.scrollLeft,d=r.offsetTop-s.scrollTop;return t.remove(),{left:l,top:d}},"nn"),sn=i((s,e,n)=>{let t=(0,X.c)(16),[o,r]=(0,j.useState)(null),l;t[0]!==s||t[1]!==e?(l=i((y,h)=>{let S=tn(y,h,s);if(S.length===0){r(null);return}let w=e.current,{left:C,top:b}=w===null?{left:0,top:0}:rn(w,h);r(k=>k!==null&&k.active===0&&k.left===C&&k.top===b&&k.suggestions.length===S.length&&k.suggestions.every((N,R)=>{let q=S.at(R);return N.kind===q?.kind&&N.label===q.label&&N.detail===q.detail})?k:{active:0,left:C,suggestions:S,top:b})},"r"),t[0]=s,t[1]=e,t[2]=l):l=t[2];let d=l,a;t[3]===Symbol.for("react.memo_cache_sentinel")?(a=i(()=>{r(null)},"a"),t[3]=a):a=t[3];let c=a,m;t[4]===Symbol.for("react.memo_cache_sentinel")?(m=i(y=>{r(h=>{if(h===null)return h;let S=h.suggestions.length,w=(h.active+y+S)%S;return{...h,active:w}})},"u"),t[4]=m):m=t[4];let p=m,f;t[5]!==n||t[6]!==o||t[7]!==e?(f=i(y=>{let h=e.current;if(o===null||h===null)return!1;let S=o.suggestions[y??o.active];if(S===void 0)return!1;let w=nn(h.value,h.selectionStart,S);return n(w.value),r(null),requestAnimationFrame(()=>{let C=e.current;C!==null&&(C.focus(),C.setSelectionRange(w.caret,w.caret))}),!0},"d"),t[5]=n,t[6]=o,t[7]=e,t[8]=f):f=t[8];let v=f,g;t[9]!==v?(g=i(()=>v(),"b"),t[9]=v,t[10]=g):g=t[10];let E=g,x;return t[11]!==E||t[12]!==v||t[13]!==d||t[14]!==o?(x={close:c,commit:E,commitAt:v,move:p,refresh:d,state:o},t[11]=E,t[12]=v,t[13]=d,t[14]=o,t[15]=x):x=t[15],x},"sn"),ln={column:"column",keyword:"keyword",table:"table"},an=20,cn=i(s=>{let e=(0,X.c)(17),{listboxId:n,onPick:t,state:o}=s,r=se(),l;e[0]!==o?(l=o===null?void 0:{left:o.left,top:o.top+an},e[0]=o,e[1]=l):l=e[1];let d=l;if(o===null)return null;let a;if(e[2]!==n||e[3]!==t||e[4]!==o.active||e[5]!==o.suggestions||e[6]!==r){let m;e[8]!==n||e[9]!==t||e[10]!==o.active||e[11]!==r?(m=i((p,f)=>(0,u.jsxs)("li",{"aria-selected":f===o.active,className:ie("flex cursor-pointer items-center gap-2 px-2 py-1 text-[13px]",f===o.active?"bg-accent text-accent-foreground":"text-foreground"),"data-testid":"sql-autocomplete-item",id:`${n}-opt-${f.toString()}`,onMouseDown:i(v=>{v.preventDefault(),t(f)},"onMouseDown"),role:"option",children:[(0,u.jsx)("span",{className:"truncate font-mono",children:p.label}),p.detail!==void 0&&(0,u.jsx)("span",{className:"ms-auto truncate text-xs text-muted-foreground",children:p.detail}),(0,u.jsx)("span",{className:"shrink-0 font-mono text-[10px] tracking-wide text-muted-foreground/70 uppercase",children:r(ln[p.kind])})]},`${p.kind}:${p.label}`),"u"),e[8]=n,e[9]=t,e[10]=o.active,e[11]=r,e[12]=m):m=e[12],a=o.suggestions.map(m),e[2]=n,e[3]=t,e[4]=o.active,e[5]=o.suggestions,e[6]=r,e[7]=a}else a=e[7];let c;return e[13]!==n||e[14]!==d||e[15]!==a?(c=(0,u.jsx)("ul",{className:"absolute z-30 max-h-56 w-72 overflow-auto rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-autocomplete",id:n,role:"listbox",style:d,children:a}),e[13]=n,e[14]=d,e[15]=a,e[16]=c):c=e[16],c},"rn"),dn=me(he.listTables),un=me(he.readTablePage),mn=i(s=>{let e=(0,X.c)(18),n=xe(),t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];let[o,r]=(0,j.useState)(t),l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l={},e[1]=l):l=e[1];let[d,a]=(0,j.useState)(l),c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c={},e[2]=c):c=e[2];let[m,p]=(0,j.useState)(c),f;e[3]===Symbol.for("react.memo_cache_sentinel")?(f=new Set,e[3]=f):f=e[3];let v=(0,j.useRef)(f),g,E;e[4]!==n||e[5]!==s?(g=i(()=>{let C={cancelled:!1};return ae((async()=>{try{let b=await n.query(dn,{},fe(s));C.cancelled||(r(b.map(hn)),a({}),p({}),v.current=new Set)}catch{C.cancelled||(r([]),a({}),p({}),v.current=new Set)}})()),()=>{C.cancelled=!0}},"b"),E=[n,s],e[4]=n,e[5]=s,e[6]=g,e[7]=E):(g=e[6],E=e[7]),(0,j.useEffect)(g,E);let x;e[8]!==n||e[9]!==s?(x=i(C=>{v.current.has(C)||(v.current.add(C),ae((async()=>{try{let b=await n.query(un,{limit:1,offset:0,table:C},fe(s)),{sqlColumns:k}=b;if(k===void 0){v.current.delete(C);return}let N=new Set(k),R=b.columns.filter(q=>!N.has(q));a(q=>({...q,[C]:k})),p(q=>({...q,[C]:R}))}catch{v.current.delete(C)}})()))},"m"),e[8]=n,e[9]=s,e[10]=x):x=e[10];let y=x,h;e[11]!==d||e[12]!==m||e[13]!==o?(h={columns:d,docFields:m,tables:o},e[11]=d,e[12]=m,e[13]=o,e[14]=h):h=e[14];let S=h,w;return e[15]!==y||e[16]!==S?(w={probe:y,schema:S},e[15]=y,e[16]=S,e[17]=w):w=e[17],w},"dn"),Le=/\b(?:from|join|update|into)\s+([a-z_][\w$]*)|\b([a-z_][\w$]*)\s*\./gi,fn=i(s=>{let e=new Set;Le.lastIndex=0;let n=Le.exec(s);for(;n!==null;)e.add(n[1]??n[2]),n=Le.exec(s);return[...e]},"un");function hn(s){return s.name}i(hn,"fn");var pn=i(s=>(s.metaKey||s.ctrlKey)&&!s.shiftKey&&!s.altKey&&s.key.toLowerCase()==="i","mn"),bn=i(s=>{let e=(0,X.c)(44),{inlineEditEnabled:n,onSubmit:t,probe:o,schema:r,setDraft:l}=s,d=(0,j.useId)(),[a,c]=(0,j.useState)(null),m=(0,j.useRef)(null),p=(0,j.useRef)(null),f=(0,j.useRef)(null),v=sn(r,f,l),{close:g,commit:E,commitAt:x,move:y,refresh:h,state:S}=v,w;e[0]!==x?(w=i(M=>{x(M)},"v"),e[0]=x,e[1]=w):w=e[1];let C=w,b;e[2]!==h?(b=i(()=>{let M=f.current;M!==null&&M===document.activeElement&&h(M.value,M.selectionStart)},"h"),e[2]=h,e[3]=b):b=e[3];let k;e[4]!==h||e[5]!==r?(k=[h,r],e[4]=h,e[5]=r,e[6]=k):k=e[6],(0,j.useEffect)(b,k);let N;e[7]!==o||e[8]!==h||e[9]!==l?(N=i(M=>{let{selectionStart:Y,value:U}=M.target;l(U),c(null);for(let W of fn(U))o(W);h(U,Y)},"T"),e[7]=o,e[8]=h,e[9]=l,e[10]=N):N=e[10];let R=N,q;e[11]!==h?(q=i(M=>{let Y=M.currentTarget;h(Y.value,Y.selectionStart)},"R"),e[11]=h,e[12]=q):q=e[12];let T=q,L;e[13]!==g||e[14]!==E||e[15]!==y?(L=i(M=>M.key==="ArrowDown"?(M.preventDefault(),y(1),!0):M.key==="ArrowUp"?(M.preventDefault(),y(-1),!0):M.key==="Escape"?(M.preventDefault(),g(),!0):(M.key==="Enter"||M.key==="Tab")&&!M.metaKey&&!M.ctrlKey&&E()?(M.preventDefault(),!0):!1,"_"),e[13]=g,e[14]=E,e[15]=y,e[16]=L):L=e[16];let _=L,I;e[17]!==S||e[18]!==g||e[19]!==n||e[20]!==_||e[21]!==t?(I=i(M=>{if(!(S!==null&&_(M))){if((M.metaKey||M.ctrlKey)&&M.key==="Enter"){M.preventDefault(),t();return}if(n&&pn(M)){M.preventDefault(),g();let{selectionEnd:Y,selectionStart:U,value:W}=M.currentTarget,[J,G]=U===Y?[0,W.length]:[U,Y];c({end:G,start:J,text:W.slice(J,G)})}}},"A"),e[17]=S,e[18]=g,e[19]=n,e[20]=_,e[21]=t,e[22]=I):I=e[22];let H=I,B;e[23]!==g?(B=i(()=>{requestAnimationFrame(()=>{g()})},"W"),e[23]=g,e[24]=B):B=e[24];let F=B,O;e[25]===Symbol.for("react.memo_cache_sentinel")?(O=i(M=>{let{scrollLeft:Y,scrollTop:U}=M.currentTarget;m.current!==null&&(m.current.scrollTop=U),p.current!==null&&(p.current.scrollTop=U,p.current.scrollLeft=Y)},"$"),e[25]=O):O=e[25];let K=O,$;e[26]===Symbol.for("react.memo_cache_sentinel")?($=i(M=>{let Y=f.current;Y===null||M.offset===void 0||(Y.focus(),Y.setSelectionRange(M.offset,M.offset+(M.length??0)))},"H"),e[26]=$):$=e[26];let D=$,A;e[27]===Symbol.for("react.memo_cache_sentinel")?(A=i(()=>{c(null),f.current?.focus()},"D"),e[27]=A):A=e[27];let Q=A,z;e[28]!==a||e[29]!==l?(z=i(M=>{let Y=f.current;if(a===null||Y===null)return;let{end:U,start:W,text:J}=a;if(Y.value.slice(W,U)!==J){Q();return}l(Y.value.slice(0,W)+M+Y.value.slice(U)),c(null),Y.focus(),requestAnimationFrame(()=>{Y.setSelectionRange(W,W+M.length)})},"P"),e[28]=a,e[29]=l,e[30]=z):z=e[30];let re=z,Z;e[31]!==R||e[32]!==F||e[33]!==H||e[34]!==T?(Z={onBlur:F,onChange:R,onKeyDown:H,onScroll:K,onSelect:T},e[31]=R,e[32]=F,e[33]=H,e[34]=T,e[35]=Z):Z=e[35];let oe;return e[36]!==re||e[37]!==S||e[38]!==g||e[39]!==a||e[40]!==d||e[41]!==C||e[42]!==Z?(oe={acceptInlineEdit:re,autocompleteState:S,closeAutocomplete:g,closeInlineEdit:Q,inlineEdit:a,handlers:Z,listboxId:d,onPickSuggestion:C,editorRef:f,gutterRef:m,overlayRef:p,revealDiagnostic:D},e[36]=re,e[37]=S,e[38]=g,e[39]=a,e[40]=d,e[41]=C,e[42]=Z,e[43]=oe):oe=e[43],oe},"pn"),gn="lunora-studio-sql-tabs",xn="lunora-studio-sql-active-tab",De=12,ge=i((s="",e="")=>({activeId:null,id:Ee("tab"),name:e,sql:s}),"pe"),vn=i(()=>ye(xn,""),"gn"),yn=i(s=>{let e=(0,X.c)(16),[n,t]=ve(gn),[o,r]=vn(),[l]=(0,j.useState)(s),d,a;e[0]!==l||e[1]!==t||e[2]!==n.length?(d=i(()=>{n.length===0&&t([l])},"c"),a=[l,t,n.length],e[0]=l,e[1]=t,e[2]=n.length,e[3]=d,e[4]=a):(d=e[3],a=e[4]),(0,j.useEffect)(d,a);let c;e[5]!==l||e[6]!==n?(c=n.length===0?[l]:n,e[5]=l,e[6]=n,e[7]=c):c=e[7];let m=c,p;e[8]!==o||e[9]!==m?(p=m.some(g=>g.id===o)?o:m[0]?.id??"",e[8]=o,e[9]=m,e[10]=p):p=e[10];let f=p,v;return e[11]!==f||e[12]!==r||e[13]!==t||e[14]!==m?(v={activeId:f,setActiveId:r,setTabs:t,tabs:m},e[11]=f,e[12]=r,e[13]=t,e[14]=m,e[15]=v):v=e[15],v},"xn"),lt=i(s=>s.activeId===null&&s.sql.trim()!=="","Ge"),wn=i((s,e)=>[...s,e].slice(-De),"vn"),Sn=i((s,e,n)=>{let t=s.findIndex(r=>r.id===e);if(t===-1)return{activeId:s[0]?.id??"",tabs:[...s]};let o=s.filter(r=>r.id!==e);if(o.length===0){let r=n();return{activeId:r.id,tabs:[r]}}return{activeId:o[Math.min(t,o.length-1)].id,tabs:o}},"yn"),Cn=i((s,e)=>{let n=s.filter(t=>t.id===e);return n.length===0?{activeId:s[0]?.id??"",tabs:[...s]}:{activeId:e,tabs:n}},"Sn"),Nn=i((s,e,n)=>{let t=s.findIndex(r=>r.id===e);if(t===-1)return{activeId:n,tabs:[...s]};let o=s.slice(0,t+1);return{activeId:o.some(r=>r.id===n)?n:e,tabs:o}},"wn"),kn=i(s=>{let e=s();return{activeId:e.id,tabs:[e]}},"Nn"),qn=i((s,e,n)=>{if(s==="others")return e.filter(t=>t.id!==n);if(s==="right"){let t=e.findIndex(o=>o.id===n);return t===-1?[]:e.slice(t+1)}return[...e]},"Cn"),Ve={error:null,pane:"results",result:null,running:!1},En=i(s=>{let e=(0,X.c)(66),{activeId:n,setActiveId:t,setTabs:o,tabs:r}=yn(s),l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={},e[0]=l):l=e[0];let[d,a]=(0,j.useState)(l),[c,m]=(0,j.useState)(null),[p,f]=(0,j.useState)(null),v;e[1]!==n||e[2]!==r?(v=r.find(P=>P.id===n)??r[0]??ge(),e[1]=n,e[2]=r,e[3]=v):v=e[3];let g=v,E=d[g.id]??Ve,x;e[4]!==g.id||e[5]!==o?(x=i(P=>{o(V=>V.map(ne=>ne.id===g.id?{...ne,...P}:ne))},"m"),e[4]=g.id,e[5]=o,e[6]=x):x=e[6];let y=x,h;e[7]!==g.id?(h=i(P=>{a(V=>{let ne=V[g.id]??Ve;return{...V,[g.id]:{...ne,...P}}})},"p"),e[7]=g.id,e[8]=h):h=e[8];let S=h,w;e[9]!==t||e[10]!==o||e[11]!==r.length?(w=i(()=>{if(r.length>=De)return;let P=ge();o(V=>wn(V,P)),t(P.id)},"v"),e[9]=t,e[10]=o,e[11]=r.length,e[12]=w):w=e[12];let C=w,b;e[13]!==t||e[14]!==o?(b=i(P=>{m(null),f(null),o(P.tabs),t(P.activeId);let V=new Set(P.tabs.map(Tn));a(ne=>Object.fromEntries(Object.entries(ne).filter(ce=>{let[de]=ce;return V.has(de)})))},"h"),e[13]=t,e[14]=o,e[15]=b):b=e[15];let k=b,N;e[16]!==k||e[17]!==r?(N=i(P=>{k(Sn(r,P,ge))},"T"),e[16]=k,e[17]=r,e[18]=N):N=e[18];let R=N,q;e[19]!==n||e[20]!==k||e[21]!==r?(q=i((P,V)=>{k(P==="others"?Cn(r,V):P==="right"?Nn(r,V,n):kn(ge))},"R"),e[19]=n,e[20]=k,e[21]=r,e[22]=q):q=e[22];let T=q,L;e[23]!==T||e[24]!==c||e[25]!==r?(L=i(P=>{c!==null&&(qn(P,r,c.id).some(In)?f(P):T(P,c.id))},"_"),e[23]=T,e[24]=c,e[25]=r,e[26]=L):L=e[26];let _=L,I;e[27]===Symbol.for("react.memo_cache_sentinel")?(I=i((P,V)=>{V.preventDefault(),f(null),m({id:P,x:V.clientX,y:V.clientY})},"A"),e[27]=I):I=e[27];let H=I,B;e[28]===Symbol.for("react.memo_cache_sentinel")?(B=i(()=>{m(null),f(null)},"W"),e[28]=B):B=e[28];let F=B,O;e[29]===Symbol.for("react.memo_cache_sentinel")?(O=i(P=>{P.preventDefault(),m(null),f(null)},"$"),e[29]=O):O=e[29];let K=O,$;e[30]!==_?($=i(()=>{_("others")},"H"),e[30]=_,e[31]=$):$=e[31];let D=$,A;e[32]!==_?(A=i(()=>{_("right")},"D"),e[32]=_,e[33]=A):A=e[33];let Q=A,z;e[34]!==_?(z=i(()=>{_("all")},"P"),e[34]=_,e[35]=z):z=e[35];let re=z,Z;e[36]!==T||e[37]!==p||e[38]!==c?(Z=i(()=>{c!==null&&p!==null&&T(p,c.id),f(null)},"Z"),e[36]=T,e[37]=p,e[38]=c,e[39]=Z):Z=e[39];let oe=Z,M;e[40]===Symbol.for("react.memo_cache_sentinel")?(M=i(()=>{f(null)},"q"),e[40]=M):M=e[40];let Y=M,U;e[41]!==c?(U=c===null?void 0:{left:c.x,top:c.y},e[41]=c,e[42]=U):U=e[42];let W=U,J;e[43]!==o?(J=i(P=>{o(V=>V.map(ne=>ne.activeId===P?{...ne,activeId:null}:ne))},"U"),e[43]=o,e[44]=J):J=e[44];let G=J,ee;e[45]!==o?(ee=i((P,V)=>{o(ne=>ne.map(ce=>ce.id===P?{...ce,name:V}:ce))},"Y"),e[45]=o,e[46]=ee):ee=e[46];let le=ee,te;return e[47]!==g||e[48]!==n||e[49]!==C||e[50]!==R||e[51]!==oe||e[52]!==re||e[53]!==D||e[54]!==Q||e[55]!==E||e[56]!==S||e[57]!==y||e[58]!==p||e[59]!==le||e[60]!==t||e[61]!==c||e[62]!==W||e[63]!==r||e[64]!==G?(te={activeTab:g,activeTabId:n,addEditorTab:C,cancelBulk:Y,closeEditorTab:R,closeTabMenu:F,confirmBulk:oe,menuStyle:W,onBackdropContextMenu:K,onCloseAll:re,onCloseOthers:D,onCloseToRight:Q,openTabMenu:H,output:E,patchActiveOutput:S,patchActiveTab:y,pendingBulk:p,renameTab:le,setActiveTabId:t,tabMenu:c,tabs:r,unlinkQuery:G},e[47]=g,e[48]=n,e[49]=C,e[50]=R,e[51]=oe,e[52]=re,e[53]=D,e[54]=Q,e[55]=E,e[56]=S,e[57]=y,e[58]=p,e[59]=le,e[60]=t,e[61]=c,e[62]=W,e[63]=r,e[64]=G,e[65]=te):te=e[65],te},"En");function Tn(s){return s.id}i(Tn,"kn");function In(s){return lt(s)}i(In,"Tn");var Ln="lunora-studio-sql-queries",ue="lunora-studio-sql-history",_n="lunora-studio-sql-remember-history",Rn=25,Dn=i(s=>{let e=(0,X.c)(41),{loadIntoActiveTab:n,unlinkQuery:t}=s,o=se(),[r,l]=ve(Ln),[d,a]=ye(_n,!1),[c,m]=ve(ue,d?"local":"session"),p,f;e[0]!==d?(p=i(()=>{d||pe(ue,"local")},"g"),f=[d],e[0]=d,e[1]=p,e[2]=f):(p=e[1],f=e[2]),(0,j.useEffect)(p,f);let[v,g]=(0,j.useState)(""),E=(0,j.useRef)(null),x;e[3]!==m?(x=i(D=>{m(A=>A[0]?.sql===D?A:[{at:Date.now(),sql:D},...A.filter(Q=>Q.sql!==D)].slice(0,Rn))},"m"),e[3]=m,e[4]=x):x=e[4];let y=x,h;e[5]!==n||e[6]!==l||e[7]!==o?(h=i(()=>{let D={id:Ee("q"),name:o("Untitled query"),sql:""};l(A=>[D,...A]),n("",D.id)},"p"),e[5]=n,e[6]=l,e[7]=o,e[8]=h):h=e[8];let S=h,w;e[9]!==n||e[10]!==r?(w=i(D=>{let A=r.find(Q=>Q.id===D);A!==void 0&&(n(A.sql,D),E.current?.querySelector(`[data-testid="sql-query-${D}"]`)?.scrollIntoView({block:"nearest"}))},"v"),e[9]=n,e[10]=r,e[11]=w):w=e[11];let C=w,b;e[12]!==l||e[13]!==t?(b=i(D=>{l(A=>A.filter(Q=>Q.id!==D)),t(D)},"h"),e[12]=l,e[13]=t,e[14]=b):b=e[14];let k=b,N;e[15]!==n?(N=i(D=>{n(D.currentTarget.dataset.sql??"",null)},"T"),e[15]=n,e[16]=N):N=e[16];let R=N,q;e[17]!==n?(q=i(D=>{n(D.currentTarget.dataset.sql??"",null)},"R"),e[17]=n,e[18]=q):q=e[18];let T=q,L;e[19]!==m?(L=i(()=>{m([]),pe(ue,"local"),pe(ue,"session")},"_"),e[19]=m,e[20]=L):L=e[20];let _=L,I;e[21]!==c||e[22]!==a?(I=i(D=>{$e(ue,c,D?"local":"session"),D||pe(ue,"local"),a(D)},"A"),e[21]=c,e[22]=a,e[23]=I):I=e[23];let H=I,B;e[24]===Symbol.for("react.memo_cache_sentinel")?(B=i(D=>{g(D.target.value)},"W"),e[24]=B):B=e[24];let F=B,O;e[25]!==l?(O=i((D,A)=>{l(Q=>Q.map(z=>z.id===D?{...z,sql:A}:z))},"$"),e[25]=l,e[26]=O):O=e[26];let K=O,$;return e[27]!==_||e[28]!==k||e[29]!==c||e[30]!==T||e[31]!==R||e[32]!==S||e[33]!==r||e[34]!==y||e[35]!==d||e[36]!==v||e[37]!==C||e[38]!==H||e[39]!==K?($={clearHistory:_,deleteQuery:k,history:c,listRef:E,loadFromHistory:T,loadTemplate:R,newQuery:S,onSearchChange:F,queries:r,recordHistory:y,rememberHistory:d,search:v,selectQuery:C,setRememberHistory:H,updateQuerySql:K},e[27]=_,e[28]=k,e[29]=c,e[30]=T,e[31]=R,e[32]=S,e[33]=r,e[34]=y,e[35]=d,e[36]=v,e[37]=C,e[38]=H,e[39]=K,e[40]=$):$=e[40],$},"_n"),Me="p-3 font-mono text-xs leading-5 whitespace-pre-wrap break-words",Mn=i((s,e)=>{let n=[];for(let o of s){if(o.offset===void 0||o.length===void 0||o.length<=0)continue;let r=Math.max(0,Math.min(o.offset,e)),l=Math.max(r,Math.min(o.offset+o.length,e));r!==l&&n.push({end:l,severity:o.severity,start:r})}n.sort((o,r)=>o.start-r.start);let t=[];for(let o of n)o.start>=(t.at(-1)?.end??0)&&t.push(o);return t},"An"),it=i((s,e)=>e(s==="unsafe-response"?"The model returned a statement that is not read-only, so it was discarded.":s==="too-long"?"The statement is too long to rewrite. Select a shorter part of it.":s==="empty-response"?"The model returned nothing usable.":"The model could not be reached."),"Je"),An=i(s=>{let e=(0,X.c)(51),{assistant:n,failed:t,onGenerated:o}=s,r=se(),[l,d]=(0,j.useState)("");if(n.unavailable)return null;let a;e[0]!==n?(a=n.pending("sql"),e[0]=n,e[1]=a):a=e[1];let c=a,m;if(e[2]!==n||e[3]!==t||e[4]!==o||e[5]!==c||e[6]!==l||e[7]!==r){let p=n.reason("sql"),f;e[9]!==n||e[10]!==t||e[11]!==o||e[12]!==l?(f=i(T=>{let L=l.trim();L===""&&!T||ae((async()=>{let _=await n.generate(L===""?"fix the failing statement":L,T?t:void 0);_!==void 0&&o(_)})())},"d"),e[9]=n,e[10]=t,e[11]=o,e[12]=l,e[13]=f):f=e[13];let v=f,g;e[14]!==r?(g=r("Describe the query you want"),e[14]=r,e[15]=g):g=e[15];let E;e[16]===Symbol.for("react.memo_cache_sentinel")?(E=i(T=>{d(T.target.value)},"C"),e[16]=E):E=e[16];let x;e[17]!==v?(x=i(T=>{T.key==="Enter"&&(T.preventDefault(),v(!1))},"m"),e[17]=v,e[18]=x):x=e[18];let y;e[19]!==r?(y=r("Describe the query you want"),e[19]=r,e[20]=y):y=e[20];let h;e[21]!==c||e[22]!==l||e[23]!==g||e[24]!==x||e[25]!==y?(h=(0,u.jsx)(qe,{"aria-label":g,className:"h-7 flex-1 text-xs","data-testid":"sql-assistant-prompt",disabled:c,onChange:E,onKeyDown:x,placeholder:y,value:l}),e[21]=c,e[22]=l,e[23]=g,e[24]=x,e[25]=y,e[26]=h):h=e[26];let S=c&&"opacity-60",w;e[27]!==S?(w=ie("rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",S),e[27]=S,e[28]=w):w=e[28];let C;e[29]!==c||e[30]!==l?(C=c||l.trim()==="",e[29]=c,e[30]=l,e[31]=C):C=e[31];let b;e[32]!==v?(b=i(()=>{v(!1)},"h"),e[32]=v,e[33]=b):b=e[33];let k;e[34]!==c||e[35]!==r?(k=r(c?"Thinking\u2026":"Draft SQL"),e[34]=c,e[35]=r,e[36]=k):k=e[36];let N;e[37]!==w||e[38]!==C||e[39]!==b||e[40]!==k?(N=(0,u.jsx)("button",{className:w,"data-testid":"sql-assistant-generate",disabled:C,onClick:b,type:"button",children:k}),e[37]=w,e[38]=C,e[39]=b,e[40]=k,e[41]=N):N=e[41];let R;e[42]!==t||e[43]!==c||e[44]!==v||e[45]!==r?(R=t!==void 0&&(0,u.jsx)("button",{className:"rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-assistant-fix",disabled:c,onClick:i(()=>{v(!0)},"onClick"),type:"button",children:r("Fix this")}),e[42]=t,e[43]=c,e[44]=v,e[45]=r,e[46]=R):R=e[46];let q;e[47]!==N||e[48]!==R||e[49]!==h?(q=(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[h,N,R]}),e[47]=N,e[48]=R,e[49]=h,e[50]=q):q=e[50],m=(0,u.jsxs)("div",{className:"flex flex-col gap-1 border-b border-border px-3 py-2","data-testid":"sql-assistant",children:[q,p!==void 0&&(0,u.jsx)("p",{className:"text-[11px] text-muted-foreground","data-testid":"sql-assistant-reason",role:"status",children:it(p,r)})]}),e[2]=n,e[3]=t,e[4]=o,e[5]=c,e[6]=l,e[7]=r,e[8]=m}else m=e[8];return m},"qn"),$n=i(s=>{let e=(0,X.c)(8),{diagnostics:n,draft:t,scrollRef:o}=s,r,l;if(e[0]!==n||e[1]!==t){l=Symbol.for("react.early_return_sentinel");e:{let c=Mn(n,t.length);if(c.length===0){l=null;break e}r=[];let m=0;for(let[p,f]of c.entries())f.start>m&&r.push(t.slice(m,f.start)),r.push((0,u.jsx)("span",{className:ie("decoration-wavy underline underline-offset-4",f.severity==="error"?"decoration-destructive":"decoration-amber-500"),children:t.slice(f.start,f.end)},`${f.start.toString()}-${p.toString()}`)),m=f.end;r.push(t.slice(m))}e[0]=n,e[1]=t,e[2]=r,e[3]=l}else r=e[2],l=e[3];if(l!==Symbol.for("react.early_return_sentinel"))return l;let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=ie("pointer-events-none absolute inset-0 overflow-hidden text-transparent",Me),e[4]=d):d=e[4];let a;return e[5]!==r||e[6]!==o?(a=(0,u.jsx)("div",{"aria-hidden":"true",className:d,"data-testid":"sql-diagnostics-overlay",ref:o,children:r}),e[5]=r,e[6]=o,e[7]=a):a=e[7],a},"Dn"),On={gate:"read-only",plan:"plan",schema:"schema",syntax:"syntax"},Pn=i(s=>{let e=(0,X.c)(10),{diagnostics:n,onSelect:t}=s,o=se();if(n.length===0)return null;let r;e[0]!==o?(r=o("SQL problems"),e[0]=o,e[1]=r):r=e[1];let l;if(e[2]!==n||e[3]!==t){let a;e[5]!==t?(a=i((c,m)=>(0,u.jsx)("li",{children:(0,u.jsxs)("button",{className:"flex w-full items-start gap-2 px-3 py-1 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-problem",onClick:i(()=>{t(c)},"onClick"),type:"button",children:[(0,u.jsx)("span",{className:ie("mt-px shrink-0 rounded px-1 font-mono text-[10px] uppercase",c.severity==="error"?"bg-destructive/15 text-destructive":"bg-amber-500/15 text-amber-600"),children:On[c.source]}),(0,u.jsx)("span",{className:"min-w-0 text-muted-foreground",children:c.message})]})},`${c.source}-${(c.offset??m).toString()}-${m.toString()}`),"a"),e[5]=t,e[6]=a):a=e[6],l=n.map(a),e[2]=n,e[3]=t,e[4]=l}else l=e[4];let d;return e[7]!==r||e[8]!==l?(d=(0,u.jsx)("ul",{"aria-label":r,className:"max-h-24 shrink-0 overflow-y-auto border-t border-border bg-muted/30","data-testid":"sql-problems",children:l}),e[7]=r,e[8]=l,e[9]=d):d=e[9],d},"Mn"),jn=i(s=>(s.endsWith(`
12
+ `)?s.slice(0,-1):s).split(`
13
+ `),"$n"),zn=i((s,e)=>{let n=[],t=1,o=1;for(let r of Ie(s,e,{ignoreNewlineAtEof:!0}))for(let l of jn(r.value))r.added?(n.push({after:o,kind:"added",text:l}),o+=1):r.removed?(n.push({before:t,kind:"removed",text:l}),t+=1):(n.push({after:o,before:t,kind:"context",text:l}),t+=1,o+=1);return n},"Bn"),Wn={added:"bg-emerald-500/10 text-emerald-700 dark:text-emerald-400",context:"text-muted-foreground",removed:"bg-destructive/10 text-destructive"},Hn={added:"+",context:" ",removed:"-"},Fn=i(s=>{let e=(0,X.c)(11),{lines:n}=s,t=se(),o;e[0]!==t?(o=t("Proposed edit"),e[0]=t,e[1]=o):o=e[1];let r;e[2]===Symbol.for("react.memo_cache_sentinel")?(r=ie("max-h-48 overflow-auto rounded-md border border-border bg-background",Me),e[2]=r):r=e[2];let l;if(e[3]!==n||e[4]!==t){let a;e[6]!==t?(a=i(c=>(0,u.jsxs)("li",{className:ie("flex gap-2",Wn[c.kind]),"data-kind":c.kind,children:[(0,u.jsx)("span",{"aria-hidden":"true",className:"shrink-0 select-none opacity-60",children:Hn[c.kind]}),c.kind!=="context"&&(0,u.jsx)("span",{className:"sr-only",children:c.kind==="added"?t("Added"):t("Removed")}),(0,u.jsx)("span",{className:"min-w-0",children:c.text===""?"\xA0":c.text})]},`${String(c.before)}:${String(c.after)}`),"a"),e[6]=t,e[7]=a):a=e[7],l=n.map(a),e[3]=n,e[4]=t,e[5]=l}else l=e[5];let d;return e[8]!==o||e[9]!==l?(d=(0,u.jsx)("ul",{"aria-label":o,className:r,"data-testid":"sql-inline-diff",children:l}),e[8]=o,e[9]=l,e[10]=d):d=e[10],d},"Fn"),Se="rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",Kn=i(s=>{let e=(0,X.c)(41),{onAccept:n,onCancel:t,rpc:o,source:r,whole:l}=s,d=se(),a=(0,j.useRef)(null),c=(0,j.useRef)(null),[m,p]=(0,j.useState)(""),[f,v]=(0,j.useState)(null),g,E;if(e[0]!==f?(g=i(()=>{f===null?a.current?.focus():c.current?.focus()},"b"),E=[f],e[0]=f,e[1]=g,e[2]=E):(g=e[1],E=e[2]),(0,j.useEffect)(g,E),o.unavailable)return null;let x;e[3]!==o?(x=o.pending("sql"),e[3]=o,e[4]=x):x=e[4];let y=x,h;if(e[5]!==m||e[6]!==n||e[7]!==t||e[8]!==y||e[9]!==f||e[10]!==o||e[11]!==r||e[12]!==d||e[13]!==l){let S=o.reason("sql"),w;e[15]!==m||e[16]!==o||e[17]!==r?(w=i(()=>{let _=m.trim();_===""||r.trim()===""||ae((async()=>{let I=await o.rewrite(_,r);I!==void 0&&v(I)})())},"v"),e[15]=m,e[16]=o,e[17]=r,e[18]=w):w=e[18];let C=w,b;e[19]!==t?(b=i(_=>{_.key==="Escape"&&(_.preventDefault(),t())},"h"),e[19]=t,e[20]=b):b=e[20];let k=b,N;e[21]!==d||e[22]!==l?(N=d(l?"Whole query":"Selection"),e[21]=d,e[22]=l,e[23]=N):N=e[23];let R;e[24]!==N?(R=(0,u.jsx)("span",{className:"shrink-0 rounded bg-muted px-1 font-mono text-[10px] uppercase text-muted-foreground","data-testid":"sql-inline-edit-scope",children:N}),e[24]=N,e[25]=R):R=e[25];let q;e[26]!==m||e[27]!==n||e[28]!==t||e[29]!==k||e[30]!==y||e[31]!==f||e[32]!==C||e[33]!==d?(q=f===null?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(qe,{"aria-label":d("Tell the model what to change"),className:"h-7 flex-1 text-xs","data-testid":"sql-inline-edit-prompt",disabled:y,onChange:i(_=>{p(_.target.value)},"onChange"),onKeyDown:i(_=>{if(_.key==="Enter"){_.preventDefault(),C();return}k(_)},"onKeyDown"),placeholder:d("Tell the model what to change"),ref:a,value:m}),(0,u.jsx)("button",{className:ie(Se,y&&"opacity-60"),"data-testid":"sql-inline-edit-submit",disabled:y||m.trim()==="",onClick:C,onKeyDown:k,type:"button",children:d(y?"Thinking\u2026":"Rewrite")}),(0,u.jsx)("button",{className:Se,"data-testid":"sql-inline-edit-cancel",onClick:t,onKeyDown:k,type:"button",children:d("Cancel")})]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("span",{className:"flex-1 text-xs text-muted-foreground",children:d("Proposed edit")}),(0,u.jsx)("button",{className:Se,"data-testid":"sql-inline-edit-accept",onClick:i(()=>{n(f)},"onClick"),onKeyDown:k,ref:c,type:"button",children:d("Accept")}),(0,u.jsx)("button",{className:Se,"data-testid":"sql-inline-edit-reject",onClick:i(()=>{v(null)},"onClick"),onKeyDown:k,type:"button",children:d("Reject")})]}),e[26]=m,e[27]=n,e[28]=t,e[29]=k,e[30]=y,e[31]=f,e[32]=C,e[33]=d,e[34]=q):q=e[34];let T;e[35]!==R||e[36]!==q?(T=(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[R,q]}),e[35]=R,e[36]=q,e[37]=T):T=e[37];let L;e[38]!==f||e[39]!==r?(L=f!==null&&(0,u.jsx)(Fn,{lines:zn(r,f)}),e[38]=f,e[39]=r,e[40]=L):L=e[40],h=(0,u.jsxs)("div",{className:"flex flex-col gap-1 border-b border-border bg-muted/20 px-3 py-2","data-testid":"sql-inline-edit",children:[T,L,S!==void 0&&(0,u.jsx)("p",{className:"text-[11px] text-muted-foreground","data-testid":"sql-inline-edit-reason",role:"status",children:it(S,d)})]}),e[5]=m,e[6]=n,e[7]=t,e[8]=y,e[9]=f,e[10]=o,e[11]=r,e[12]=d,e[13]=l,e[14]=h}else h=e[14];return h},"Wn"),Bn={minWidth:"2.75rem",paddingInline:"0.5rem"},Qn=i(s=>{let e=(0,X.c)(75),{assistant:n,autocomplete:t,diagnostics:o,draft:r,failed:l,handlers:d,editorRef:a,gutterRef:c,inlineEdit:m,listboxId:p,onAcceptInlineEdit:f,onCancelInlineEdit:v,onGenerated:g,onPickSuggestion:E,onRevealDiagnostic:x,overlayRef:y}=s,h=se(),S,w,C,b,k,N,R,q,T;if(e[0]!==n||e[1]!==r||e[2]!==l||e[3]!==c||e[4]!==m||e[5]!==f||e[6]!==v||e[7]!==g){let z=r.split(`
14
+ `).length;R="flex min-h-0 min-w-0 flex-1 flex-col",e[17]!==n||e[18]!==l||e[19]!==g?(q=(0,u.jsx)(An,{assistant:n,failed:l,onGenerated:g}),e[17]=n,e[18]=l,e[19]=g,e[20]=q):q=e[20],e[21]!==n||e[22]!==r.length||e[23]!==m||e[24]!==f||e[25]!==v?(T=m!==null&&(0,u.jsx)(Kn,{onAccept:f,onCancel:v,rpc:n,source:m.text,whole:m.start===0&&m.end===r.length},`${m.start.toString()}-${m.end.toString()}`),e[21]=n,e[22]=r.length,e[23]=m,e[24]=f,e[25]=v,e[26]=T):T=e[26],N="flex min-h-0 min-w-0 flex-1",S="true",w="shrink-0 select-none overflow-hidden border-e border-border bg-muted/30 py-3 text-end font-mono text-xs leading-5 text-muted-foreground/60",C=c,b=Bn,k=Array.from({length:z},Yn),e[0]=n,e[1]=r,e[2]=l,e[3]=c,e[4]=m,e[5]=f,e[6]=v,e[7]=g,e[8]=S,e[9]=w,e[10]=C,e[11]=b,e[12]=k,e[13]=N,e[14]=R,e[15]=q,e[16]=T}else S=e[8],w=e[9],C=e[10],b=e[11],k=e[12],N=e[13],R=e[14],q=e[15],T=e[16];let L;e[27]!==S||e[28]!==w||e[29]!==C||e[30]!==b||e[31]!==k?(L=(0,u.jsx)("div",{"aria-hidden":S,className:w,ref:C,style:b,children:k}),e[27]=S,e[28]=w,e[29]=C,e[30]=b,e[31]=k,e[32]=L):L=e[32];let _;e[33]!==o||e[34]!==r||e[35]!==y?(_=(0,u.jsx)($n,{diagnostics:o,draft:r,scrollRef:y}),e[33]=o,e[34]=r,e[35]=y,e[36]=_):_=e[36];let I;e[37]!==t||e[38]!==p?(I=t===null?void 0:`${p}-opt-${t.active.toString()}`,e[37]=t,e[38]=p,e[39]=I):I=e[39];let H=t===null?void 0:p,B=t!==null,F;e[40]!==h?(F=h("SQL query"),e[40]=h,e[41]=F):F=e[41];let O;e[42]!==r||e[43]!==a||e[44]!==d.onBlur||e[45]!==d.onChange||e[46]!==d.onKeyDown||e[47]!==d.onScroll||e[48]!==d.onSelect||e[49]!==I||e[50]!==H||e[51]!==B||e[52]!==F?(O=(0,u.jsx)("textarea",{"aria-activedescendant":I,"aria-autocomplete":"list","aria-controls":H,"aria-expanded":B,"aria-label":F,className:`relative size-full resize-none bg-transparent outline-none ${Me}`,"data-testid":"sql-input",onBlur:d.onBlur,onChange:d.onChange,onKeyDown:d.onKeyDown,onScroll:d.onScroll,onSelect:d.onSelect,placeholder:"SELECT * FROM \u2026",ref:a,role:"combobox",spellCheck:!1,value:r}),e[42]=r,e[43]=a,e[44]=d.onBlur,e[45]=d.onChange,e[46]=d.onKeyDown,e[47]=d.onScroll,e[48]=d.onSelect,e[49]=I,e[50]=H,e[51]=B,e[52]=F,e[53]=O):O=e[53];let K;e[54]!==t||e[55]!==p||e[56]!==E?(K=(0,u.jsx)(cn,{listboxId:p,onPick:E,state:t}),e[54]=t,e[55]=p,e[56]=E,e[57]=K):K=e[57];let $;e[58]!==_||e[59]!==O||e[60]!==K?($=(0,u.jsxs)("div",{className:"relative min-w-0 flex-1 bg-background",children:[_,O,K]}),e[58]=_,e[59]=O,e[60]=K,e[61]=$):$=e[61];let D;e[62]!==L||e[63]!==$||e[64]!==N?(D=(0,u.jsxs)("div",{className:N,children:[L,$]}),e[62]=L,e[63]=$,e[64]=N,e[65]=D):D=e[65];let A;e[66]!==o||e[67]!==x?(A=(0,u.jsx)(Pn,{diagnostics:o,onSelect:x}),e[66]=o,e[67]=x,e[68]=A):A=e[68];let Q;return e[69]!==D||e[70]!==A||e[71]!==R||e[72]!==q||e[73]!==T?(Q=(0,u.jsxs)("div",{className:R,children:[q,T,D,A]}),e[69]=D,e[70]=A,e[71]=R,e[72]=q,e[73]=T,e[74]=Q):Q=e[74],Q},"zn");function Yn(s,e){return(0,u.jsx)("div",{children:e+1},e)}i(Yn,"Un");var at=[{label:"List tables",sql:"SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name;"},{label:"Table row count",sql:"SELECT COUNT(*) AS rows FROM messages;"},{label:"Recent rows",sql:"SELECT id, _creationTime, __doc__ FROM messages ORDER BY _creationTime DESC LIMIT 50;"},{label:"Index list",sql:"SELECT name, tbl_name FROM sqlite_master WHERE type = 'index' ORDER BY tbl_name;"}],Jn=i(s=>{let e=(0,X.c)(29),{active:n,onDelete:t,onSelect:o,query:r}=s,l=se(),d;e[0]!==o||e[1]!==r.id?(d=i(()=>{o(r.id)},"c"),e[0]=o,e[1]=r.id,e[2]=d):d=e[2];let a=d,c;e[3]!==t||e[4]!==r.id?(c=i(b=>{b.stopPropagation(),t(r.id)},"i"),e[3]=t,e[4]=r.id,e[5]=c):c=e[5];let m=c,p=n?"bg-sidebar-accent font-medium text-foreground":"text-muted-foreground",f;e[6]!==p?(f=ie("flex min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] outline-none transition-colors hover:bg-sidebar-accent focus-visible:bg-sidebar-accent",p),e[6]=p,e[7]=f):f=e[7];let v=`sql-query-${r.id}`,g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g=(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M4 6h16M4 12h10M4 18h7"})}),e[8]=g):g=e[8];let E;e[9]!==r.name?(E=(0,u.jsx)("span",{className:"truncate",children:r.name}),e[9]=r.name,e[10]=E):E=e[10];let x;e[11]!==n||e[12]!==a||e[13]!==f||e[14]!==v||e[15]!==E?(x=(0,u.jsxs)("button",{"aria-pressed":n,className:f,"data-testid":v,onClick:a,type:"button",children:[g,E]}),e[11]=n,e[12]=a,e[13]=f,e[14]=v,e[15]=E,e[16]=x):x=e[16];let y;e[17]!==l?(y=l("Delete query"),e[17]=l,e[18]=y):y=e[18];let h;e[19]!==l?(h=l("Delete query"),e[19]=l,e[20]=h):h=e[20];let S;e[21]===Symbol.for("react.memo_cache_sentinel")?(S=(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[21]=S):S=e[21];let w;e[22]!==m||e[23]!==h||e[24]!==y?(w=(0,u.jsx)("button",{"aria-label":y,className:"me-1 hidden size-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive group-hover/q:flex",onClick:m,title:h,type:"button",children:S}),e[22]=m,e[23]=h,e[24]=y,e[25]=w):w=e[25];let C;return e[26]!==w||e[27]!==x?(C=(0,u.jsxs)("li",{className:"group/q flex items-center",children:[x,w]}),e[26]=w,e[27]=x,e[28]=C):C=e[28],C},"jn"),Ge="sql-history-remember",Vn=i((s,e)=>{let n=e.trim().toLowerCase();return n===""?[...s]:s.filter(t=>t.name.toLowerCase().includes(n))},"Qn"),Gn=i(s=>{let e=(0,X.c)(66),{activeId:n,history:t,listRef:o,onClearHistory:r,onDelete:l,onLoadHistory:d,onLoadTemplate:a,onNew:c,onSearchChange:m,onSelect:p,onToggleRememberHistory:f,queries:v,rememberHistory:g,search:E}=s,x=se(),y,h,S,w,C;if(e[0]!==n||e[1]!==o||e[2]!==l||e[3]!==c||e[4]!==m||e[5]!==p||e[6]!==f||e[7]!==v||e[8]!==E||e[9]!==x){let I=Vn(v,E),H;e[15]!==f?(H=i(z=>{f(z.target.checked)},"M"),e[15]=f,e[16]=H):H=e[16],y=H,S="flex h-full w-64 shrink-0 flex-col border-e border-border bg-sidebar";let B;e[17]!==x?(B=x("Search queries\u2026"),e[17]=x,e[18]=B):B=e[18];let F;e[19]!==m||e[20]!==E||e[21]!==B?(F=(0,u.jsx)("input",{className:"h-8 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"sql-search",onChange:m,placeholder:B,type:"text",value:E}),e[19]=m,e[20]=E,e[21]=B,e[22]=F):F=e[22];let O;e[23]!==x?(O=x("New query"),e[23]=x,e[24]=O):O=e[24];let K;e[25]!==x?(K=x("New query"),e[25]=x,e[26]=K):K=e[26];let $;e[27]===Symbol.for("react.memo_cache_sentinel")?($=(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M12 5v14M5 12h14"})}),e[27]=$):$=e[27];let D;e[28]!==c||e[29]!==O||e[30]!==K?(D=(0,u.jsx)("button",{"aria-label":O,className:"flex size-8 shrink-0 items-center justify-center rounded-md border border-border text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-new",onClick:c,title:K,type:"button",children:$}),e[28]=c,e[29]=O,e[30]=K,e[31]=D):D=e[31],e[32]!==D||e[33]!==F?(w=(0,u.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border p-2",children:[F,D]}),e[32]=D,e[33]=F,e[34]=w):w=e[34],h="flex flex-1 flex-col gap-4 overflow-y-auto p-2";let A;e[35]!==x?(A=x("Private"),e[35]=x,e[36]=A):A=e[36];let Q;e[37]!==A?(Q=(0,u.jsx)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:A}),e[37]=A,e[38]=Q):Q=e[38],C=(0,u.jsxs)("div",{children:[Q,I.length===0?(0,u.jsx)("p",{className:"px-1 py-2 text-xs text-muted-foreground","data-testid":"sql-private-empty",children:x("No saved queries yet \u2014 they save to this browser as you type.")}):(0,u.jsx)("ul",{className:"flex flex-col gap-px","data-testid":"sql-private",ref:o,children:I.map(z=>(0,u.jsx)(Jn,{active:n===z.id,onDelete:l,onSelect:p,query:z},z.id))})]}),e[0]=n,e[1]=o,e[2]=l,e[3]=c,e[4]=m,e[5]=p,e[6]=f,e[7]=v,e[8]=E,e[9]=x,e[10]=y,e[11]=h,e[12]=S,e[13]=w,e[14]=C}else y=e[10],h=e[11],S=e[12],w=e[13],C=e[14];let b;e[39]!==x?(b=x("Reference"),e[39]=x,e[40]=b):b=e[40];let k;e[41]!==b?(k=(0,u.jsx)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:b}),e[41]=b,e[42]=k):k=e[42];let N;e[43]!==a?(N=at.map(I=>(0,u.jsx)("li",{children:(0,u.jsxs)("button",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-foreground focus-visible:bg-sidebar-accent","data-sql":I.sql,onClick:a,type:"button",children:[(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M7 4h7l4 4v12H7zM14 4v4h4"})}),I.label]})},I.label)),e[43]=a,e[44]=N):N=e[44];let R;e[45]!==N?(R=(0,u.jsx)("ul",{className:"flex flex-col gap-px",children:N}),e[45]=N,e[46]=R):R=e[46];let q;e[47]!==k||e[48]!==R?(q=(0,u.jsxs)("div",{children:[k,R]}),e[47]=k,e[48]=R,e[49]=q):q=e[49];let T;e[50]!==t||e[51]!==r||e[52]!==d||e[53]!==y||e[54]!==g||e[55]!==x?(T=t.length>0&&(0,u.jsxs)("div",{children:[(0,u.jsxs)("div",{className:"flex items-center justify-between px-1 pb-1",children:[(0,u.jsx)("p",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:x("History")}),(0,u.jsx)("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"sql-history-clear",onClick:r,type:"button",children:x("Clear history")})]}),(0,u.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 px-1 pb-1.5 text-[11px] text-muted-foreground",htmlFor:Ge,children:[(0,u.jsx)("input",{checked:g,"data-testid":"sql-history-remember",id:Ge,onChange:y,type:"checkbox"}),x("Keep history on this browser")]}),(0,u.jsx)("ul",{className:"flex flex-col gap-px","data-testid":"sql-history",children:t.map(I=>(0,u.jsx)("li",{children:(0,u.jsxs)("button",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-foreground focus-visible:bg-sidebar-accent","data-sql":I.sql,"data-testid":"sql-history-item",onClick:d,title:I.sql,type:"button",children:[(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M12 8v4l3 2M12 21a9 9 0 1 1 0-18 9 9 0 0 1 0 18Z"})}),(0,u.jsx)("span",{className:"truncate font-mono",children:I.sql})]})},`${I.at.toString()}:${I.sql}`))})]}),e[50]=t,e[51]=r,e[52]=d,e[53]=y,e[54]=g,e[55]=x,e[56]=T):T=e[56];let L;e[57]!==h||e[58]!==T||e[59]!==C||e[60]!==q?(L=(0,u.jsxs)("div",{className:h,children:[C,q,T]}),e[57]=h,e[58]=T,e[59]=C,e[60]=q,e[61]=L):L=e[61];let _;return e[62]!==L||e[63]!==S||e[64]!==w?(_=(0,u.jsxs)("aside",{className:S,children:[w,L]}),e[62]=L,e[63]=S,e[64]=w,e[65]=_):_=e[65],_},"Yn"),Ce=i(s=>`border-b-2 px-3 py-2 text-sm outline-none transition-colors ${s?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,"ve"),Un=i(s=>{let e=(0,X.c)(97),{assistant:n,chart:t,className:o,durationMs:r,error:l,onFormat:d,onInferChart:a,onRun:c,onSelectStatement:m,onShardKeyChange:p,onShowChart:f,onShowExplain:v,onShowResults:g,onToggleSplit:E,pane:x,result:y,running:h,script:S,shardKey:w,splitView:C}=s,b=se(),k=x==="results",N;e[0]!==k?(N=Ce(k),e[0]=k,e[1]=N):N=e[1];let R;e[2]!==b?(R=b("Results"),e[2]=b,e[3]=R):R=e[3];let q;e[4]!==g||e[5]!==N||e[6]!==R?(q=(0,u.jsx)("button",{className:N,"data-testid":"sql-tab-results",onClick:g,type:"button",children:R}),e[4]=g,e[5]=N,e[6]=R,e[7]=q):q=e[7];let T=x==="chart",L;e[8]!==T?(L=Ce(T),e[8]=T,e[9]=L):L=e[9];let _;e[10]!==b?(_=b("Chart"),e[10]=b,e[11]=_):_=e[11];let I;e[12]!==f||e[13]!==L||e[14]!==_?(I=(0,u.jsx)("button",{className:L,"data-testid":"sql-tab-chart",onClick:f,type:"button",children:_}),e[12]=f,e[13]=L,e[14]=_,e[15]=I):I=e[15];let H;e[16]!==n||e[17]!==a||e[18]!==x||e[19]!==y||e[20]!==b?(H=!n.unavailable&&x==="chart"&&y!==null&&(0,u.jsx)("button",{className:Ce(!1),"data-testid":"sql-infer-chart",disabled:n.pending("chart"),onClick:a,type:"button",children:n.pending("chart")?b("Thinking\u2026"):b("Suggest chart")}),e[16]=n,e[17]=a,e[18]=x,e[19]=y,e[20]=b,e[21]=H):H=e[21];let B=x==="explain",F;e[22]!==B?(F=Ce(B),e[22]=B,e[23]=F):F=e[23];let O;e[24]!==b?(O=b("Explain"),e[24]=b,e[25]=O):O=e[25];let K;e[26]!==v||e[27]!==F||e[28]!==O?(K=(0,u.jsx)("button",{className:F,"data-testid":"sql-tab-explain",onClick:v,type:"button",children:O}),e[26]=v,e[27]=F,e[28]=O,e[29]=K):K=e[29];let $;e[30]!==b?($=b("Split editor and results"),e[30]=b,e[31]=$):$=e[31];let D=`inline-flex items-center rounded-md border border-border px-2 py-1.5 outline-none transition-colors hover:bg-accent focus-visible:bg-accent ${C?"bg-accent text-foreground":"text-muted-foreground"}`,A;e[32]!==b?(A=b("Split editor and results"),e[32]=b,e[33]=A):A=e[33];let Q;e[34]===Symbol.for("react.memo_cache_sentinel")?(Q=(0,u.jsxs)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:[(0,u.jsx)("rect",{height:"16",rx:"2",width:"18",x:"3",y:"4"}),(0,u.jsx)("path",{d:"M12 4v16"})]}),e[34]=Q):Q=e[34];let z;e[35]!==E||e[36]!==C||e[37]!==$||e[38]!==D||e[39]!==A?(z=(0,u.jsx)("button",{"aria-label":$,"aria-pressed":C,className:D,"data-testid":"sql-split-toggle",onClick:E,title:A,type:"button",children:Q}),e[35]=E,e[36]=C,e[37]=$,e[38]=D,e[39]=A,e[40]=z):z=e[40];let re;e[41]!==y?(re=y!==null&&y.columns.length>0&&(0,u.jsx)(He,{columns:y.columns,name:"query-result",rows:y.rows}),e[41]=y,e[42]=re):re=e[42];let Z;e[43]!==b?(Z=b("Format"),e[43]=b,e[44]=Z):Z=e[44];let oe;e[45]!==d||e[46]!==h||e[47]!==Z?(oe=(0,u.jsx)("button",{className:"inline-flex items-center rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-format",disabled:h,onClick:d,type:"button",children:Z}),e[45]=d,e[46]=h,e[47]=Z,e[48]=oe):oe=e[48];let M;e[49]!==p||e[50]!==w?(M=(0,u.jsx)(Pe,{onChange:p,testId:"sql-shard-input",value:w}),e[49]=p,e[50]=w,e[51]=M):M=e[51];let Y;e[52]!==h||e[53]!==b?(Y=b(h?"Running\u2026":"Run"),e[52]=h,e[53]=b,e[54]=Y):Y=e[54];let U;e[55]===Symbol.for("react.memo_cache_sentinel")?(U=(0,u.jsx)("kbd",{className:"rounded border border-primary-foreground/30 px-1 font-sans text-[10px]",children:"\u2318\u21B5"}),e[55]=U):U=e[55];let W;e[56]!==c||e[57]!==h||e[58]!==Y?(W=(0,u.jsxs)("button",{className:"inline-flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-run",disabled:h,onClick:c,type:"button",children:[Y,U]}),e[56]=c,e[57]=h,e[58]=Y,e[59]=W):W=e[59];let J;e[60]!==z||e[61]!==re||e[62]!==oe||e[63]!==M||e[64]!==W?(J=(0,u.jsxs)("div",{className:"ms-auto flex items-center gap-2",children:[z,re,oe,M,W]}),e[60]=z,e[61]=re,e[62]=oe,e[63]=M,e[64]=W,e[65]=J):J=e[65];let G;e[66]!==K||e[67]!==J||e[68]!==q||e[69]!==I||e[70]!==H?(G=(0,u.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border pe-2",children:[q,I,H,K,J]}),e[66]=K,e[67]=J,e[68]=q,e[69]=I,e[70]=H,e[71]=G):G=e[71];let ee;e[72]!==m||e[73]!==S?(ee=S!==void 0&&(0,u.jsx)("div",{className:"flex shrink-0 flex-wrap items-center gap-1 border-b border-border px-3 py-1.5","data-testid":"sql-statements",children:S.runs.map((ce,de)=>(0,u.jsx)("button",{"aria-pressed":de===S.selected,className:`rounded-md border px-2 py-0.5 font-mono text-[11px] outline-none transition-colors ${de===S.selected?"border-foreground text-foreground":"border-border text-muted-foreground hover:text-foreground"} ${ce.error===null?"":"border-destructive/50 text-destructive"}`,"data-testid":`sql-statement-${de.toString()}`,onClick:i(()=>{m(de)},"onClick"),title:ce.sql,type:"button",children:de+1},`${de.toString()}:${ce.sql}`))}),e[72]=m,e[73]=S,e[74]=ee):ee=e[74];let le;e[75]!==l?(le=l!==null&&(0,u.jsx)(je,{className:"m-3 font-mono text-xs",testId:"sql-error",variant:"destructive",children:l}),e[75]=l,e[76]=le):le=e[76];let te;e[77]!==l||e[78]!==y||e[79]!==b?(te=l===null&&y===null&&(0,u.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-empty",children:b("Click Run to execute your query.")}),e[77]=l,e[78]=y,e[79]=b,e[80]=te):te=e[80];let P;e[81]!==t||e[82]!==r||e[83]!==l||e[84]!==x||e[85]!==y||e[86]!==b?(P=l===null&&y!==null&&(0,u.jsxs)("div",{"data-testid":"sql-result",children:[x==="chart"?(0,u.jsx)(Fe,{axes:t,result:y}):(0,u.jsx)(Ke,{result:y}),(0,u.jsxs)("p",{className:"border-t border-border px-3 py-1.5 text-xs text-muted-foreground","data-testid":"sql-count",children:[y.truncated?b("Showing the first {max} rows.",{max:y.rows.length}):b("{count} rows",{count:y.rowCount}),r!==void 0&&` \xB7 ${b("{ms} ms",{ms:Math.round(r)})}`]})]}),e[81]=t,e[82]=r,e[83]=l,e[84]=x,e[85]=y,e[86]=b,e[87]=P):P=e[87];let V;e[88]!==le||e[89]!==te||e[90]!==P?(V=(0,u.jsxs)("div",{className:"min-h-0 flex-1 overflow-auto",children:[le,te,P]}),e[88]=le,e[89]=te,e[90]=P,e[91]=V):V=e[91];let ne;return e[92]!==o||e[93]!==G||e[94]!==ee||e[95]!==V?(ne=(0,u.jsxs)("div",{className:o,children:[G,ee,V]}),e[92]=o,e[93]=G,e[94]=ee,e[95]=V,e[96]=ne):ne=e[96],ne},"Gn"),Xn=i((s,e)=>s.trim()===""?e:(s.split(`
15
+ `)[0]??s).slice(0,24),"Jn"),Zn=i(s=>{s?.focus(),s?.select()},"Vn"),eo=i(s=>{let e=(0,X.c)(14),{initial:n,onCancel:t,onCommit:o,placeholder:r,testId:l}=s,d=se(),a;e[0]!==o?(a=i(g=>{o(g.currentTarget.value.trim())},"a"),e[0]=o,e[1]=a):a=e[1];let c=a,m;e[2]!==t||e[3]!==o?(m=i(g=>{g.key==="Enter"?o(g.currentTarget.value.trim()):g.key==="Escape"&&t()},"u"),e[2]=t,e[3]=o,e[4]=m):m=e[4];let p=m,f;e[5]!==d?(f=d("Tab title"),e[5]=d,e[6]=f):f=e[6];let v;return e[7]!==n||e[8]!==c||e[9]!==p||e[10]!==r||e[11]!==f||e[12]!==l?(v=(0,u.jsx)("input",{"aria-label":f,className:"w-40 rounded border border-ring bg-background px-1 py-0.5 text-xs outline-none","data-testid":l,defaultValue:n,onBlur:c,onKeyDown:p,placeholder:r,ref:Zn,type:"text"}),e[7]=n,e[8]=c,e[9]=p,e[10]=r,e[11]=f,e[12]=l,e[13]=v):v=e[13],v},"Xn"),to=i(s=>{let e=(0,X.c)(29),{idBase:n,onDiscard:t,onKeep:o}=s,r=se(),l=`sql-tab-close-prompt-${n}`,d;e[0]!==r?(d=r("Discard?"),e[0]=r,e[1]=d):d=e[1];let a;e[2]!==d?(a=(0,u.jsx)("span",{className:"text-[11px] text-muted-foreground",children:d}),e[2]=d,e[3]=a):a=e[3];let c;e[4]!==r?(c=r("Discard changes"),e[4]=r,e[5]=c):c=e[5];let m=`sql-tab-close-confirm-${n}`,p;e[6]!==r?(p=r("Discard changes"),e[6]=r,e[7]=p):p=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M5 13l4 4L19 7"})}),e[8]=f):f=e[8];let v;e[9]!==t||e[10]!==c||e[11]!==m||e[12]!==p?(v=(0,u.jsx)("button",{"aria-label":c,className:"flex size-5 items-center justify-center rounded text-destructive hover:bg-destructive/10","data-testid":m,onClick:t,title:p,type:"button",children:f}),e[9]=t,e[10]=c,e[11]=m,e[12]=p,e[13]=v):v=e[13];let g;e[14]!==r?(g=r("Keep editing"),e[14]=r,e[15]=g):g=e[15];let E=`sql-tab-close-cancel-${n}`,x;e[16]!==r?(x=r("Keep editing"),e[16]=r,e[17]=x):x=e[17];let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y=(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M6 6l12 12M18 6 6 18"})}),e[18]=y):y=e[18];let h;e[19]!==o||e[20]!==E||e[21]!==x||e[22]!==g?(h=(0,u.jsx)("button",{"aria-label":g,className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-accent","data-testid":E,onClick:o,title:x,type:"button",children:y}),e[19]=o,e[20]=E,e[21]=x,e[22]=g,e[23]=h):h=e[23];let S;return e[24]!==l||e[25]!==h||e[26]!==a||e[27]!==v?(S=(0,u.jsxs)("span",{className:"flex shrink-0 items-center gap-1","data-testid":l,role:"group",children:[a,v,h]}),e[24]=l,e[25]=h,e[26]=a,e[27]=v,e[28]=S):S=e[28],S},"Zn"),no=i(s=>{let e=(0,X.c)(47),{active:n,canClose:t,onClose:o,onMenu:r,onRename:l,onSelect:d,tab:a}=s,c=se(),[m,p]=(0,j.useState)(!1),[f,v]=(0,j.useState)(!1),g;e[0]!==r||e[1]!==a.id?(g=i(z=>{r(a.id,z)},"b"),e[0]=r,e[1]=a.id,e[2]=g):g=e[2];let E=g,x;e[3]!==d||e[4]!==a.id?(x=i(()=>{d(a.id)},"m"),e[3]=d,e[4]=a.id,e[5]=x):x=e[5];let y=x,h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=i(()=>{p(!0)},"p"),e[6]=h):h=e[6];let S=h,w;e[7]!==o||e[8]!==a?(w=i(z=>{z.stopPropagation(),lt(a)?v(!0):o(a.id)},"v"),e[7]=o,e[8]=a,e[9]=w):w=e[9];let C=w,b;e[10]!==o||e[11]!==a.id?(b=i(z=>{z.stopPropagation(),v(!1),o(a.id)},"h"),e[10]=o,e[11]=a.id,e[12]=b):b=e[12];let k=b,N;e[13]===Symbol.for("react.memo_cache_sentinel")?(N=i(z=>{z.stopPropagation(),v(!1)},"T"),e[13]=N):N=e[13];let R=N,q;e[14]!==l||e[15]!==a.id?(q=i(z=>{l(a.id,z),p(!1)},"R"),e[14]=l,e[15]=a.id,e[16]=q):q=e[16];let T=q,L;e[17]===Symbol.for("react.memo_cache_sentinel")?(L=i(()=>{p(!1)},"_"),e[17]=L):L=e[17];let _=L,I;e[18]!==a.name?(I=a.name.trim(),e[18]=a.name,e[19]=I):I=e[19];let H=I,B;e[20]!==c||e[21]!==a.sql?(B=Xn(a.sql,c("Untitled")),e[20]=c,e[21]=a.sql,e[22]=B):B=e[22];let F=B,O=n?"bg-background text-foreground":"bg-muted/40 text-muted-foreground hover:text-foreground",K;e[23]!==O?(K=ie("group/tab flex shrink-0 items-center gap-1 border-e border-border ps-3 pe-1.5 text-xs",O),e[23]=O,e[24]=K):K=e[24];let $=`sql-tab-${a.id}`,D;e[25]!==n||e[26]!==T||e[27]!==H||e[28]!==F||e[29]!==m||e[30]!==y||e[31]!==c||e[32]!==a.id?(D=m?(0,u.jsx)(eo,{initial:H,onCancel:_,onCommit:T,placeholder:F,testId:`sql-tab-rename-${a.id}`}):(0,u.jsx)("button",{"aria-pressed":n,className:"max-w-40 truncate py-1.5 outline-none","data-testid":`sql-tab-select-${a.id}`,onClick:y,onDoubleClick:S,title:c("Double-click to rename"),type:"button",children:H===""?F:H}),e[25]=n,e[26]=T,e[27]=H,e[28]=F,e[29]=m,e[30]=y,e[31]=c,e[32]=a.id,e[33]=D):D=e[33];let A;e[34]!==t||e[35]!==k||e[36]!==f||e[37]!==C||e[38]!==c||e[39]!==a.id?(A=t&&(f?(0,u.jsx)(to,{idBase:a.id,onDiscard:k,onKeep:R}):(0,u.jsx)("button",{"aria-label":c("Close tab"),className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive","data-testid":`sql-tab-close-${a.id}`,onClick:C,title:c("Close tab"),type:"button",children:(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M6 6l12 12M18 6 6 18"})})})),e[34]=t,e[35]=k,e[36]=f,e[37]=C,e[38]=c,e[39]=a.id,e[40]=A):A=e[40];let Q;return e[41]!==E||e[42]!==K||e[43]!==$||e[44]!==D||e[45]!==A?(Q=(0,u.jsxs)("div",{className:K,"data-testid":$,onContextMenu:E,children:[D,A]}),e[41]=E,e[42]=K,e[43]=$,e[44]=D,e[45]=A,e[46]=Q):Q=e[46],Q},"es"),oo=i(s=>{let e=(0,X.c)(43),{model:n,onSelect:t}=s,o=se(),{activeTab:r,addEditorTab:l,cancelBulk:d,closeEditorTab:a,closeTabMenu:c,confirmBulk:m,menuStyle:p,onBackdropContextMenu:f,onCloseAll:v,onCloseOthers:g,onCloseToRight:E,openTabMenu:x,pendingBulk:y,renameTab:h,tabMenu:S,tabs:w}=n,C;if(e[0]!==r||e[1]!==a||e[2]!==t||e[3]!==x||e[4]!==h||e[5]!==w){let I;e[7]!==r||e[8]!==a||e[9]!==t||e[10]!==x||e[11]!==h||e[12]!==w.length?(I=i(H=>(0,u.jsx)(no,{active:H.id===r.id,canClose:w.length>1,onClose:a,onMenu:x,onRename:h,onSelect:t,tab:H},H.id),"A"),e[7]=r,e[8]=a,e[9]=t,e[10]=x,e[11]=h,e[12]=w.length,e[13]=I):I=e[13],C=w.map(I),e[0]=r,e[1]=a,e[2]=t,e[3]=x,e[4]=h,e[5]=w,e[6]=C}else C=e[6];let b;e[14]!==o?(b=o("New tab"),e[14]=o,e[15]=b):b=e[15];let k=w.length>=De,N;e[16]!==o?(N=o("New tab"),e[16]=o,e[17]=N):N=e[17];let R;e[18]===Symbol.for("react.memo_cache_sentinel")?(R=(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M12 5v14M5 12h14"})}),e[18]=R):R=e[18];let q;e[19]!==l||e[20]!==b||e[21]!==k||e[22]!==N?(q=(0,u.jsx)("button",{"aria-label":b,className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-add",disabled:k,onClick:l,title:N,type:"button",children:R}),e[19]=l,e[20]=b,e[21]=k,e[22]=N,e[23]=q):q=e[23];let T;e[24]!==C||e[25]!==q?(T=(0,u.jsxs)("div",{className:"flex shrink-0 items-stretch overflow-x-auto border-b border-border bg-muted/30","data-testid":"sql-tab-strip",role:"tablist",children:[C,q]}),e[24]=C,e[25]=q,e[26]=T):T=e[26];let L;e[27]!==d||e[28]!==c||e[29]!==m||e[30]!==p||e[31]!==f||e[32]!==v||e[33]!==g||e[34]!==E||e[35]!==y||e[36]!==o||e[37]!==S||e[38]!==w?(L=S!==null&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"fixed inset-0 z-40","data-testid":"sql-tab-menu-backdrop",onClick:c,onContextMenu:f,role:"presentation"}),(0,u.jsx)("div",{className:"fixed z-50 min-w-44 rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-tab-menu",role:"menu",style:p,children:y===null?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-menu-close-others",disabled:w.length<=1,onClick:g,role:"menuitem",type:"button",children:o("Close other tabs")}),(0,u.jsx)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-menu-close-right",disabled:w.findIndex(I=>I.id===S.id)>=w.length-1,onClick:E,role:"menuitem",type:"button",children:o("Close tabs to the right")}),(0,u.jsx)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-tab-menu-close-all",onClick:v,role:"menuitem",type:"button",children:o("Close all tabs")})]}):(0,u.jsxs)("div",{className:"px-3 py-1.5","data-testid":"sql-tab-menu-confirm",children:[(0,u.jsx)("p",{className:"pb-1.5 text-xs text-muted-foreground",children:o("Discard unsaved tabs?")}),(0,u.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,u.jsx)("button",{className:"rounded px-2 py-1 text-xs font-medium text-destructive outline-none hover:bg-destructive/10 focus-visible:bg-destructive/10","data-testid":"sql-tab-menu-confirm-discard",onClick:m,type:"button",children:o("Discard")}),(0,u.jsx)("button",{className:"rounded px-2 py-1 text-xs text-muted-foreground outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-tab-menu-confirm-cancel",onClick:d,type:"button",children:o("Cancel")})]})]})})]}),e[27]=d,e[28]=c,e[29]=m,e[30]=p,e[31]=f,e[32]=v,e[33]=g,e[34]=E,e[35]=y,e[36]=o,e[37]=S,e[38]=w,e[39]=L):L=e[39];let _;return e[40]!==T||e[41]!==L?(_=(0,u.jsxs)(u.Fragment,{children:[T,L]}),e[40]=T,e[41]=L,e[42]=_):_=e[42],_},"ts"),ro=me(he.runSql),so="lunora-studio-sql-split-view",lo=i(()=>ge(at[0]?.sql??""),"os"),io=i(()=>performance.now(),"ls"),ao=i(()=>{let s=(0,X.c)(2),e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=new Map,s[0]=e):e=s[0];let n=(0,j.useRef)(e),t;return s[1]===Symbol.for("react.memo_cache_sentinel")?(t={advance:i(o=>{n.current.set(o,(n.current.get(o)??0)+1)},"advance"),begin:i(o=>{let r=n.current.get(o)??0;return()=>(n.current.get(o)??0)===r},"begin")},s[1]=t):t=s[1],t},"rs"),Do=i(({initialShardKey:s,now:e=io})=>{let n=xe(),t=En(lo),{activeTab:o,output:r,patchActiveOutput:l,patchActiveTab:d,setActiveTabId:a,unlinkQuery:c}=t,m=ao(),p=Dn({loadIntoActiveTab:i((W,J)=>{m.advance(o.id),d({activeId:J,sql:W}),l({chart:void 0,durationMs:void 0,error:null,failed:void 0,result:null,running:!1,script:void 0})},"loadIntoActiveTab"),unlinkQuery:c}),{recordHistory:f,updateQuerySql:v}=p,g=o.sql,{activeId:E}=o,{chart:x,error:y,failed:h,result:S,running:w}=r,C=r.pane,[b,k]=(0,j.useState)(s??""),[N,R]=ye(so,!1),{probe:q,schema:T}=mn(b),L=i(W=>{d({sql:W}),E!==null&&v(E,W)},"L"),_=Vt(g,T,b),I=We(b),H=i(()=>{S!==null&&ae((async()=>{let W=await I.inferChart({columns:S.columns,rowCount:S.rowCount,types:Object.fromEntries(S.columns.map(J=>[J,typeof(S.rows[0]?.[J]??"")]))});l({chart:W})})())},"W"),B=i(async W=>{let J=e();try{let G=await n.query(ro,{sql:W},fe(b)),ee=e()-J;return f(W),{durationMs:ee,error:null,result:G,sql:W}}catch(G){return{error:Ae(G),result:null,sql:W}}},"K"),F=i(async W=>{if(g.trim()==="")return;let J=m.begin(o.id);l({running:!0});let G=W==="explain"?_e(St(g),0):tt(g),ee=[];for(let P of G){let V={error:P.rejection?.message??"",result:null,sql:P.sql};ee.push(P.rejection===void 0?await B(P.sql):V)}if(Oe(b),!J())return;let le=Math.max(ee.length-1,0),te=ee[le];l({chart:void 0,durationMs:te?.durationMs,error:te?.error??null,failed:te?.error===null||te===void 0?void 0:{error:te.error,sql:te.sql},pane:W,result:te?.result??null,running:!1,script:ee.length>1?{runs:ee,selected:le}:void 0})},"$"),O=i(W=>{let J=r.script?.runs,G=J?.[W];J===void 0||G===void 0||l({chart:void 0,durationMs:G.durationMs,error:G.error,failed:G.error===null?void 0:{error:G.error,sql:G.sql},result:G.result,script:{runs:J,selected:W}})},"F"),K=i(()=>{ae(F("results"))},"H"),$=bn({inlineEditEnabled:!I.unavailable,onSubmit:i(()=>{ae(F(r.pane))},"onSubmit"),probe:q,schema:T,setDraft:L}),{closeAutocomplete:D,closeInlineEdit:A}=$,Q=i(()=>{L(Tt(g))},"P"),z=i(W=>{D(),A(),a(W)},"oe"),re=i(()=>{l({pane:"results"})},"Z"),Z=i(()=>{ae(F("explain"))},"ne"),oe=i(()=>{l({pane:"chart"})},"q"),M=i(()=>{R(!N)},"j"),Y=N?"flex min-h-0 flex-1 flex-row":"flex min-h-0 flex-1 flex-col",U=N?"flex w-2/5 min-h-0 min-w-0 shrink-0 flex-col border-s border-border":"flex h-2/5 min-h-0 shrink-0 flex-col border-t border-border";return(0,u.jsxs)("div",{className:"flex h-full min-w-0","data-testid":"lunora-sql-editor",children:[(0,u.jsx)(Gn,{activeId:E,history:p.history,listRef:p.listRef,onClearHistory:p.clearHistory,onDelete:p.deleteQuery,onLoadHistory:p.loadFromHistory,onLoadTemplate:p.loadTemplate,onNew:p.newQuery,onSearchChange:p.onSearchChange,onSelect:p.selectQuery,onToggleRememberHistory:p.setRememberHistory,queries:p.queries,rememberHistory:p.rememberHistory,search:p.search}),(0,u.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col",children:[(0,u.jsx)(oo,{model:t,onSelect:z}),(0,u.jsxs)("div",{className:Y,children:[(0,u.jsx)(Qn,{assistant:I,autocomplete:$.autocompleteState,diagnostics:_,draft:g,editorRef:$.editorRef,failed:h,gutterRef:$.gutterRef,handlers:$.handlers,inlineEdit:$.inlineEdit,listboxId:$.listboxId,onAcceptInlineEdit:$.acceptInlineEdit,onCancelInlineEdit:$.closeInlineEdit,onGenerated:L,onPickSuggestion:$.onPickSuggestion,onRevealDiagnostic:$.revealDiagnostic,overlayRef:$.overlayRef}),(0,u.jsx)(Un,{assistant:I,chart:x,className:U,durationMs:r.durationMs,error:y,onFormat:Q,onInferChart:H,onRun:K,onSelectStatement:O,onShardKeyChange:k,onShowChart:oe,onShowExplain:Z,onShowResults:re,onToggleSplit:M,pane:C,result:S,running:w,script:r.script,shardKey:b,splitView:N})]})]})]})},"Es");export{Do as SqlEditorPanel};
@@ -1 +1 @@
1
- import{a as O,b as D}from"./chunk-5B2RTXBS.js";import{a as F}from"./chunk-EWMBX5N2.js";import{a as j}from"./chunk-R6U22RSY.js";import{a as V}from"./chunk-7Q256NLI.js";import"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import{i as L}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import"./chunk-AUAECCXB.js";import{b as C}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as z}from"./chunk-XC2LTW44.js";import"./chunk-NCPW7WHO.js";import"./chunk-5AXRIRHW.js";import"./chunk-55UGUCQ6.js";import{a as T}from"./chunk-4ZEL6BYL.js";import{c as R}from"./chunk-YSPQIRER.js";import"./chunk-EQRZJZD4.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as k}from"./chunk-RWVIV3U7.js";import{a as A,b as q,c as B,d as p,e as d,f as n}from"./chunk-HCTJKP5J.js";import{a as I,e as E}from"./chunk-2IKDEUCX.js";import{d as b,n as K,u as M}from"./chunk-74IYYDDI.js";import{a as i,d as y,e as ee,g as te}from"./chunk-I26MS5PJ.js";var s=y(ee(),1);var e=y(te(),1);var re=i(o=>o===void 0?"":JSON.stringify(o,K),"te"),ae=41,J=480,H=5,ie=i((o,t)=>O(o,l=>{t(l.height>0?l:{height:J,width:l.width})}),"ae"),Ne=i(({initialShardKey:o})=>{let t=b(),{queryShardKey:l,setShardKey:P,shardKey:U}=j(o),[h,W]=(0,s.useState)(""),{data:f,error:g,errorSource:Z,isLoading:_,liveError:G}=R(T.getAuditLog,{},{live:!0,shardKey:l}),c=(0,s.useMemo)(()=>f?.entries??[],[f]),m=(0,s.useMemo)(()=>{let a=h.trim().toLowerCase();return a===""?c:c.filter(r=>r.op.toLowerCase().includes(a)||(r.table??"").toLowerCase().includes(a)||(r.id??"").toLowerCase().includes(a))},[c,h]),x=(0,s.useRef)(null),v=D({count:m.length,estimateSize:i(()=>ae,"estimateSize"),getScrollElement:i(()=>x.current,"getScrollElement"),initialRect:{height:J,width:800},observeElementRect:ie,overscan:8}),u=v.getVirtualItems(),Q=v.getTotalSize(),N=u[0]?.start??0,w=Q-(u.at(-1)?.end??0),X={height:N},Y={height:w},$=i(a=>{W(a.target.value)},"z");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-audit",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(V,{onChange:P,testId:"au-shard-input",value:U}),(0,e.jsx)(F,{message:G,prefix:"au"}),(0,e.jsx)(L,{"aria-label":t("Filter audit log"),className:"h-8 w-48","data-testid":"au-search",onChange:$,placeholder:t("filter op, table, id"),value:h})]}),g!==null&&(0,e.jsx)(z,{error:Z,testId:"au-error"}),g===null&&!_&&m.length===0&&(0,e.jsx)(k,{description:t("State-changing admin operations are recorded here."),icon:(0,e.jsx)("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:"M8 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2h-2M9 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V3Zm-1 9h8m-8 4h5"})}),testId:"au-empty",title:t("No audit entries.")}),m.length>0&&(0,e.jsx)(I,{className:"overflow-hidden py-0",children:(0,e.jsx)(E,{className:"max-h-[30rem] overflow-auto px-0",ref:x,children:(0,e.jsxs)(A,{"data-testid":"au-table",children:[(0,e.jsx)(q,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(d,{children:t("time")}),(0,e.jsx)(d,{children:t("op")}),(0,e.jsx)(d,{children:t("table")}),(0,e.jsx)(d,{children:t("id")}),(0,e.jsx)(d,{children:t("detail")})]})}),(0,e.jsxs)(B,{children:[N>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:H,style:X})}),u.map(a=>{let r=m[a.index],S=re(r.detail);return(0,e.jsxs)(p,{"data-testid":"au-row",children:[(0,e.jsx)(n,{className:"text-muted-foreground tabular-nums",children:M(r.ts,"\u2014")}),(0,e.jsx)(n,{children:(0,e.jsx)(C,{variant:"secondary",children:r.op})}),(0,e.jsx)(n,{className:"font-medium",children:r.table??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(n,{className:"max-w-[20ch] truncate font-mono text-xs",children:r.id??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(n,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:S||void 0,children:S||(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},r.seq)}),w>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:H,style:Y})})]})]})})})]})},"we");export{Ne as AuditPanel};
1
+ import{a as O,b as D}from"./chunk-5B2RTXBS.js";import{a as F}from"./chunk-EWMBX5N2.js";import{a as j}from"./chunk-R6U22RSY.js";import{a as V}from"./chunk-7Q256NLI.js";import"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import{i as L}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import"./chunk-AUAECCXB.js";import{b as C}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as z}from"./chunk-M27YVZWM.js";import"./chunk-NCPW7WHO.js";import"./chunk-LXQGF74P.js";import"./chunk-55UGUCQ6.js";import{a as T}from"./chunk-4ZEL6BYL.js";import{c as R}from"./chunk-NWWMHMGA.js";import"./chunk-3JVXNEBO.js";import"./chunk-QAQDMS6R.js";import"./chunk-BAWEGZ7T.js";import{a as k}from"./chunk-RWVIV3U7.js";import{a as A,b as q,c as B,d as p,e as d,f as n}from"./chunk-HCTJKP5J.js";import{a as I,e as E}from"./chunk-2IKDEUCX.js";import{d as b,n as K,u as M}from"./chunk-74IYYDDI.js";import{a as i,d as y,e as ee,g as te}from"./chunk-I26MS5PJ.js";var s=y(ee(),1);var e=y(te(),1);var re=i(o=>o===void 0?"":JSON.stringify(o,K),"te"),ae=41,J=480,H=5,ie=i((o,t)=>O(o,l=>{t(l.height>0?l:{height:J,width:l.width})}),"ae"),Ne=i(({initialShardKey:o})=>{let t=b(),{queryShardKey:l,setShardKey:P,shardKey:U}=j(o),[h,W]=(0,s.useState)(""),{data:f,error:g,errorSource:Z,isLoading:_,liveError:G}=R(T.getAuditLog,{},{live:!0,shardKey:l}),c=(0,s.useMemo)(()=>f?.entries??[],[f]),m=(0,s.useMemo)(()=>{let a=h.trim().toLowerCase();return a===""?c:c.filter(r=>r.op.toLowerCase().includes(a)||(r.table??"").toLowerCase().includes(a)||(r.id??"").toLowerCase().includes(a))},[c,h]),x=(0,s.useRef)(null),v=D({count:m.length,estimateSize:i(()=>ae,"estimateSize"),getScrollElement:i(()=>x.current,"getScrollElement"),initialRect:{height:J,width:800},observeElementRect:ie,overscan:8}),u=v.getVirtualItems(),Q=v.getTotalSize(),N=u[0]?.start??0,w=Q-(u.at(-1)?.end??0),X={height:N},Y={height:w},$=i(a=>{W(a.target.value)},"z");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-audit",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(V,{onChange:P,testId:"au-shard-input",value:U}),(0,e.jsx)(F,{message:G,prefix:"au"}),(0,e.jsx)(L,{"aria-label":t("Filter audit log"),className:"h-8 w-48","data-testid":"au-search",onChange:$,placeholder:t("filter op, table, id"),value:h})]}),g!==null&&(0,e.jsx)(z,{error:Z,testId:"au-error"}),g===null&&!_&&m.length===0&&(0,e.jsx)(k,{description:t("State-changing admin operations are recorded here."),icon:(0,e.jsx)("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:"M8 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2h-2M9 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V3Zm-1 9h8m-8 4h5"})}),testId:"au-empty",title:t("No audit entries.")}),m.length>0&&(0,e.jsx)(I,{className:"overflow-hidden py-0",children:(0,e.jsx)(E,{className:"max-h-[30rem] overflow-auto px-0",ref:x,children:(0,e.jsxs)(A,{"data-testid":"au-table",children:[(0,e.jsx)(q,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(d,{children:t("time")}),(0,e.jsx)(d,{children:t("op")}),(0,e.jsx)(d,{children:t("table")}),(0,e.jsx)(d,{children:t("id")}),(0,e.jsx)(d,{children:t("detail")})]})}),(0,e.jsxs)(B,{children:[N>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:H,style:X})}),u.map(a=>{let r=m[a.index],S=re(r.detail);return(0,e.jsxs)(p,{"data-testid":"au-row",children:[(0,e.jsx)(n,{className:"text-muted-foreground tabular-nums",children:M(r.ts,"\u2014")}),(0,e.jsx)(n,{children:(0,e.jsx)(C,{variant:"secondary",children:r.op})}),(0,e.jsx)(n,{className:"font-medium",children:r.table??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(n,{className:"max-w-[20ch] truncate font-mono text-xs",children:r.id??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(n,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:S||void 0,children:S||(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},r.seq)}),w>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:H,style:Y})})]})]})})})]})},"we");export{Ne as AuditPanel};
@@ -1,4 +1,4 @@
1
- import{c as V}from"./chunk-4CGBMYO3.js";import"./chunk-NQZALRU3.js";import"./chunk-OPM7ESDV.js";import"./chunk-Y3AYVFTK.js";import"./chunk-QJLHH3ET.js";import"./chunk-OYCUPD3Q.js";import"./chunk-NXQW5E6W.js";import"./chunk-UC7MNI2F.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import{a as Q}from"./chunk-LXCVA5SP.js";import{a as H}from"./chunk-7Q256NLI.js";import{b as K}from"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{a as A}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import"./chunk-BOMPSVRC.js";import{a as v}from"./chunk-4ZEL6BYL.js";import{d as G}from"./chunk-YSPQIRER.js";import{c as k,d as M,l as U}from"./chunk-EQRZJZD4.js";import"./chunk-QAQDMS6R.js";import{d as $}from"./chunk-NRAAYZ4C.js";import{a as B,e as D}from"./chunk-2IKDEUCX.js";import{d as _,f as E,g as L,h as C,q as J}from"./chunk-74IYYDDI.js";import{a as n,d as F,e as me,g as pe}from"./chunk-I26MS5PJ.js";var h=F(me(),1);var e=F(pe(),1);var ue=E(v.exportShard),fe=E(v.importShard),he=E(v.listTables),xe=n(i=>i.map(l=>JSON.stringify(k(l))).join(`
1
+ import{c as V}from"./chunk-4CGBMYO3.js";import"./chunk-NQZALRU3.js";import"./chunk-OPM7ESDV.js";import"./chunk-Y3AYVFTK.js";import"./chunk-QJLHH3ET.js";import"./chunk-OYCUPD3Q.js";import"./chunk-NXQW5E6W.js";import"./chunk-UC7MNI2F.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import{a as Q}from"./chunk-LXCVA5SP.js";import{a as H}from"./chunk-7Q256NLI.js";import{b as K}from"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{a as A}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import"./chunk-BOMPSVRC.js";import{a as v}from"./chunk-4ZEL6BYL.js";import{d as G}from"./chunk-NWWMHMGA.js";import{c as k,d as M,l as U}from"./chunk-3JVXNEBO.js";import"./chunk-QAQDMS6R.js";import{d as $}from"./chunk-BAWEGZ7T.js";import{a as B,e as D}from"./chunk-2IKDEUCX.js";import{d as _,f as E,g as L,h as C,q as J}from"./chunk-74IYYDDI.js";import{a as n,d as F,e as me,g as pe}from"./chunk-I26MS5PJ.js";var h=F(me(),1);var e=F(pe(),1);var ue=E(v.exportShard),fe=E(v.importShard),he=E(v.listTables),xe=n(i=>i.map(l=>JSON.stringify(k(l))).join(`
2
2
  `),"ue"),Z=n((i,l)=>{let r=i.trim();if(r==="")return;let t=M(JSON.parse(r));if(typeof t!="object"||t===null)throw new $("INTERNAL",`line ${l.toString()}: expected a { table, doc } object`);let o=t;if(typeof o.table!="string"||typeof o.doc!="object"||o.doc===null||Array.isArray(o.doc))throw new $("INTERNAL",`line ${l.toString()}: expected a { table, doc } object`);return o},"q"),X=1024*1024,ee=n(async function*(i){let l=new TextDecoder("utf-8",{fatal:!0}),r="",t=0;for(let c=0;c<i.size;c+=X){let x=await i.slice(c,c+X).arrayBuffer(),d=`${r}${l.decode(x,{stream:!0})}`.split(`
3
3
  `);r=d.pop()??"";for(let u of d)t+=1,yield{line:u,lineNumber:t}}let o=r+l.decode();o!==""&&(yield{line:o,lineNumber:t+1})},"U"),Y=50,ge=500,R=9e5,te=n(i=>new TextEncoder().encode(JSON.stringify(k(i))).byteLength,"z"),q="application/x-ndjson",be=n(async i=>{let l=0;for await(let{line:r,lineNumber:t}of ee(i)){let o=Z(r,t);if(o!==void 0){if(te(o)>R)throw new $("INTERNAL",`line ${t.toString()}: a single row is over the ${R.toString()}-byte import limit`);l+=1}}return l},"he"),we=n(async(i,l)=>{let r=[],t=0,o=0,c=0;for await(let{line:x,lineNumber:d}of ee(i)){let u=Z(x,d);if(u===void 0)continue;let g=te(u),S=d!==c+1;r.length>0&&(S||r.length===ge||t+g>R)&&(await l(r,o),r=[],t=0),r.length===0&&(o=d),r.push(u),t+=g,c=d}r.length>0&&await l(r,o)},"xe"),Ae=n(({initialShardKey:i})=>{let l=U(),r=G(),t=_(),[o,c]=(0,h.useState)(i??""),[x,d]=(0,h.useState)(null),[u,g]=(0,h.useState)(!1),[S,j]=(0,h.useState)(null),[b,T]=(0,h.useState)(null),[z,P]=(0,h.useState)(null),[f,O]=(0,h.useState)(null),re=n(async()=>{let s=o;g(!0),j(null),T(null),O(null);try{let a=await l.query(he,{},L(s)),m=new Blob([],{type:q}),w=0,y=[];for(let{name:p}of a){let{rows:I}=await l.query(ue,{tables:[p]},L(s));if(I.length===0)continue;let N=xe(I);m=new Blob([m,`${N}
4
4
  `],{type:q}),w+=I.length,y.length<Y&&y.push(...N.split(`