@lunora/studio 1.0.0-alpha.80 → 1.0.0-alpha.82

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 (134) hide show
  1. package/dist/index.d.ts +35 -6
  2. package/dist/index.js +1 -1
  3. package/dist/mount.js +1 -1
  4. package/dist/packem_chunks/AdvisorHealthPanel.js +1 -0
  5. package/dist/packem_chunks/ApiTab.js +1 -1
  6. package/dist/packem_chunks/AuditPanel.js +1 -1
  7. package/dist/packem_chunks/ExportImportPanel.js +1 -1
  8. package/dist/packem_chunks/FileBrowser.js +1 -1
  9. package/dist/packem_chunks/FunctionRunner.js +1 -1
  10. package/dist/packem_chunks/FunctionStatsPanel.js +1 -1
  11. package/dist/packem_chunks/HealthPanel.js +1 -1
  12. package/dist/packem_chunks/InsightsPanel.js +1 -1
  13. package/dist/packem_chunks/LogsPanel.js +1 -1
  14. package/dist/packem_chunks/MailPanel.js +2 -2
  15. package/dist/packem_chunks/MetricsPanel.js +1 -1
  16. package/dist/packem_chunks/NotificationsPanel.js +1 -1
  17. package/dist/packem_chunks/PitrPanel.js +1 -1
  18. package/dist/packem_chunks/SchemaViewer.js +1 -1
  19. package/dist/packem_chunks/SecurityAdvisorPanel.js +1 -1
  20. package/dist/packem_chunks/SettingsPanel.js +1 -1
  21. package/dist/packem_chunks/SqlEditorPanel.js +6 -6
  22. package/dist/packem_chunks/TableEditor.js +1 -1
  23. package/dist/packem_chunks/agents-panel.js +1 -1
  24. package/dist/packem_chunks/auth-audit-panel.js +1 -1
  25. package/dist/packem_chunks/containers-panel.js +1 -1
  26. package/dist/packem_chunks/dashboards-panel.js +1 -1
  27. package/dist/packem_chunks/fanout-panel.js +1 -1
  28. package/dist/packem_chunks/flags-panel.js +1 -1
  29. package/dist/packem_chunks/issues-panel.js +1 -1
  30. package/dist/packem_chunks/kv-browser.js +1 -1
  31. package/dist/packem_chunks/log-drains-panel.js +1 -1
  32. package/dist/packem_chunks/migrations-route.js +1 -1
  33. package/dist/packem_chunks/organizations-panel.js +1 -1
  34. package/dist/packem_chunks/payments-panel.js +1 -1
  35. package/dist/packem_chunks/permissions-panel.js +1 -1
  36. package/dist/packem_chunks/queues-panel.js +1 -1
  37. package/dist/packem_chunks/rls-panel.js +1 -1
  38. package/dist/packem_chunks/storage-rules-panel.js +1 -1
  39. package/dist/packem_chunks/subscriptions-panel.js +1 -1
  40. package/dist/packem_chunks/traces-panel.js +1 -1
  41. package/dist/packem_chunks/workflows-panel.js +1 -1
  42. package/dist/packem_shared/ADMIN_FUNCTIONS-CZESgd10.js +1 -0
  43. package/dist/packem_shared/{ApiDocsPanel-DfUQ1ZAF.js → ApiDocsPanel-fYS9NiLg.js} +1 -1
  44. package/dist/packem_shared/DataBrowser-C4J4gVUu.js +1 -0
  45. package/dist/packem_shared/GlobalDataBrowser-CSttudUx.js +1 -0
  46. package/dist/packem_shared/{HomePanel-Dcs4a3Ax.js → HomePanel-BYsfMhKh.js} +1 -1
  47. package/dist/packem_shared/{MigrationsPanel-C2OnsqRb.js → MigrationsPanel-2JbQ2HwG.js} +1 -1
  48. package/dist/packem_shared/{Studio-B26_pT8J.js → Studio-Ba9x0dG_.js} +1 -1
  49. package/dist/packem_shared/{StudioApp-bXhJeLlZ.js → StudioApp-B_PRdg4h.js} +1 -1
  50. package/dist/packem_shared/{cf-links-gbDy51nR.js → cf-links-Dmg86v1D.js} +1 -1
  51. package/dist/packem_shared/{home-panel-CU6MWLHG.js → home-panel-B60-5YfI.js} +1 -1
  52. package/dist/packem_shared/stat-card-fm_TF1mo.js +1 -0
  53. package/dist/packem_shared/studio-CPuoAmjh.js +2 -0
  54. package/dist/packem_shared/table-list-sidebar-BRv3hTLX.js +1 -0
  55. package/dist/packem_shared/{use-sql-assistant-CHEu2-Rk.js → use-sql-assistant-BLG9unQN.js} +1 -1
  56. package/dist/standalone/{chunk-RQ7AFLIV.js → chunk-2QSHLBCO.js} +1 -1
  57. package/dist/standalone/{chunk-33CL6OHR.js → chunk-5SQRE3VR.js} +1 -1
  58. package/dist/standalone/{chunk-5CVJS7ON.js → chunk-6QP5N57V.js} +1 -1
  59. package/dist/standalone/chunk-73GRNONE.js +1 -0
  60. package/dist/standalone/{chunk-JRMMYIAF.js → chunk-74DN6HIE.js} +1 -1
  61. package/dist/standalone/{chunk-KZ3ALMMP.js → chunk-7H7LZRLP.js} +1 -1
  62. package/dist/standalone/{chunk-FOBRNWBG.js → chunk-7YKWP4QK.js} +1 -1
  63. package/dist/standalone/{chunk-T7IUZIF4.js → chunk-7ZUQE3KU.js} +1 -1
  64. package/dist/standalone/{chunk-P4YLIBCN.js → chunk-A3KUNMU6.js} +1 -1
  65. package/dist/standalone/{chunk-S2VVR7HI.js → chunk-B2H5DK55.js} +1 -1
  66. package/dist/standalone/{chunk-FNPJ7GJZ.js → chunk-BDJCCVB6.js} +1 -1
  67. package/dist/standalone/{chunk-KJB7YAKB.js → chunk-C7EOC2WS.js} +1 -1
  68. package/dist/standalone/{chunk-KLQYC6CC.js → chunk-CGLS2ILT.js} +1 -1
  69. package/dist/standalone/chunk-CPSGJSHY.js +1 -0
  70. package/dist/standalone/{chunk-RJP3WBZ4.js → chunk-CU6SCYQ7.js} +1 -1
  71. package/dist/standalone/chunk-DGBJE7YF.js +4 -0
  72. package/dist/standalone/{chunk-G6PSMGLD.js → chunk-DOZAODYC.js} +1 -1
  73. package/dist/standalone/chunk-EQZTSISX.js +1 -0
  74. package/dist/standalone/chunk-ERMTJYQF.js +1 -0
  75. package/dist/standalone/{chunk-QZGTH6WH.js → chunk-GB6LP6UJ.js} +1 -1
  76. package/dist/standalone/{chunk-GYKVBKT5.js → chunk-GM67EQJU.js} +1 -1
  77. package/dist/standalone/chunk-GN567L2T.js +1 -0
  78. package/dist/standalone/{chunk-L7R74G63.js → chunk-GWHM4C4N.js} +1 -1
  79. package/dist/standalone/{chunk-JLOWAJRR.js → chunk-GWQIPIYA.js} +1 -1
  80. package/dist/standalone/{chunk-6YTSSIEJ.js → chunk-HEB6GQQ6.js} +1 -1
  81. package/dist/standalone/chunk-HOR3JLUY.js +6 -0
  82. package/dist/standalone/{chunk-7LWMHTJ3.js → chunk-I6A5C46N.js} +1 -1
  83. package/dist/standalone/{chunk-H6YOWRFB.js → chunk-KAPSM6AI.js} +1 -1
  84. package/dist/standalone/{chunk-6NY7SPDL.js → chunk-KSRP7GZV.js} +1 -1
  85. package/dist/standalone/chunk-LLF5KWDZ.js +2 -0
  86. package/dist/standalone/chunk-NRCXRCJX.js +1 -0
  87. package/dist/standalone/chunk-OE465DVY.js +1 -0
  88. package/dist/standalone/{chunk-HJ3E4YF5.js → chunk-PXYWCZ7T.js} +1 -1
  89. package/dist/standalone/{chunk-PZVU2QMX.js → chunk-Q7QTRX2E.js} +1 -1
  90. package/dist/standalone/{chunk-E3NMX2VU.js → chunk-S4ILMYP5.js} +1 -1
  91. package/dist/standalone/{chunk-KC44QCN6.js → chunk-SDQBPFLO.js} +1 -1
  92. package/dist/standalone/chunk-SV52HB7D.js +1 -0
  93. package/dist/standalone/{chunk-WBYSSCV2.js → chunk-T242WITF.js} +1 -1
  94. package/dist/standalone/{chunk-VHWOCPRK.js → chunk-TBRZQICB.js} +1 -1
  95. package/dist/standalone/{chunk-6LNCYDZO.js → chunk-TQXZ7LG4.js} +1 -1
  96. package/dist/standalone/chunk-U457LHCO.js +1 -0
  97. package/dist/standalone/chunk-UBPYN4DU.js +1 -0
  98. package/dist/standalone/{chunk-34D36UCW.js → chunk-UDVB4URN.js} +1 -1
  99. package/dist/standalone/{chunk-6IKEW5LG.js → chunk-UETNCBWU.js} +1 -1
  100. package/dist/standalone/{chunk-OY2RVUZL.js → chunk-UU2QJMGJ.js} +1 -1
  101. package/dist/standalone/chunk-VC5SSRUP.js +1 -0
  102. package/dist/standalone/{chunk-GXSZH7VJ.js → chunk-VCXH5V3Z.js} +1 -1
  103. package/dist/standalone/{chunk-RNRJKBY3.js → chunk-VTLYN3CX.js} +1 -1
  104. package/dist/standalone/{chunk-3O3HAXW7.js → chunk-WDG4WFUV.js} +1 -1
  105. package/dist/standalone/{chunk-3STOIE7Q.js → chunk-WJGOI3FZ.js} +1 -1
  106. package/dist/standalone/{chunk-W6SAOXGH.js → chunk-WLZ7YPBH.js} +1 -1
  107. package/dist/standalone/{chunk-2VDFV5TD.js → chunk-WQVVA5NB.js} +1 -1
  108. package/dist/standalone/{chunk-TTGOOYLF.js → chunk-WZ3B3MEV.js} +1 -1
  109. package/dist/standalone/{chunk-SKW6J4VW.js → chunk-Y7A5NCXT.js} +1 -1
  110. package/dist/standalone/{chunk-IHQC7J35.js → chunk-YSRW5RNU.js} +1 -1
  111. package/dist/standalone/{chunk-GAX5IZYG.js → chunk-YTA2HGRD.js} +1 -1
  112. package/dist/standalone/chunk-ZHBIKP5G.js +1 -0
  113. package/dist/standalone/{chunk-CCVXYYPJ.js → chunk-ZK3XKFCI.js} +1 -1
  114. package/dist/standalone/studio.js +1 -1
  115. package/dist/styles.css +1 -1
  116. package/package.json +5 -5
  117. package/dist/packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js +0 -1
  118. package/dist/packem_shared/DataBrowser-CuRlztBz.js +0 -1
  119. package/dist/packem_shared/GlobalDataBrowser-DB-vQ2_H.js +0 -1
  120. package/dist/packem_shared/studio-q-C-acL7.js +0 -2
  121. package/dist/packem_shared/table-list-sidebar-BFkSQwlB.js +0 -1
  122. package/dist/standalone/chunk-2GA4SHO7.js +0 -1
  123. package/dist/standalone/chunk-2WOIRKEI.js +0 -1
  124. package/dist/standalone/chunk-6PNPIW6I.js +0 -2
  125. package/dist/standalone/chunk-6YI4WJO4.js +0 -1
  126. package/dist/standalone/chunk-A74VSSA2.js +0 -4
  127. package/dist/standalone/chunk-CT5MMH4O.js +0 -1
  128. package/dist/standalone/chunk-GB6U2BPU.js +0 -1
  129. package/dist/standalone/chunk-GEDMLM4A.js +0 -6
  130. package/dist/standalone/chunk-S252DAFP.js +0 -1
  131. package/dist/standalone/chunk-XS5LDR52.js +0 -1
  132. package/dist/standalone/chunk-YJYTMQJI.js +0 -1
  133. package/dist/standalone/chunk-Z2V42P7J.js +0 -1
  134. /package/dist/standalone/{chunk-SKHEGARW.js → chunk-XF2B7P5A.js} +0 -0
@@ -1 +1 @@
1
- import{a as Me}from"./chunk-6VAKZALJ.js";import{a as Ke}from"./chunk-U6TNNM5U.js";import{a as Qe}from"./chunk-JN2Y24PY.js";import{a as Ve}from"./chunk-ESVP44Y3.js";import{a as Je}from"./chunk-54MMVNPT.js";import"./chunk-IVFHIQOT.js";import{a as He}from"./chunk-LFKCLLPT.js";import{b as Ge}from"./chunk-XDAT7LHC.js";import{a as Ue,b as _e,c as $e,d as L,e as U,f as _}from"./chunk-MIQTKZAR.js";import{a as we,e as Ce}from"./chunk-UZERI5YC.js";import{a as D}from"./chunk-5Y3QLNWX.js";import"./chunk-QBWRC5YX.js";import{R as P}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as z}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as T}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{f as E}from"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{a as Ze}from"./chunk-XQCVZAGU.js";import{d as W,h as Be,l as Ae,m as ze,q as Ie}from"./chunk-OG4N2XHD.js";import"./chunk-AADILRJW.js";import{a as r,e as Le,f as Ye,g as et,h as tt}from"./chunk-3XIESWL4.js";var k=Le(Ye(),1);var Z=Le(et(),1);var t=Le(tt(),1);var at=r(()=>{let u=(0,Z.c)(3),{config:e,ready:l}=Me(),s;return u[0]!==e.capabilities||u[1]!==l?(s={capabilities:e.capabilities,ready:l},u[0]=e.capabilities,u[1]=l,u[2]=s):s=u[2],s},"et"),st={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},lt=r((u,e)=>u.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:u.type!=="number"||!Number.isNaN(Number(e.trim())),"at"),rt=r((u,e)=>{if(u.type==="boolean")return e===!0?{value:!0}:u.required?{value:!1}:void 0;let l=typeof e=="string"?e.trim():"";if(l!==""){if(u.type==="number"){let s=Number(l);return Number.isNaN(s)?void 0:{value:s}}return{value:l}}},"lt"),it=r(u=>{let e=(0,Z.c)(105),{onClose:l,onCreated:s}=u,c=E(),a=W(),{config:o}=Me(),{busy:i,error:n,run:m}=Ke(),[w,S]=(0,k.useState)(""),[b,C]=(0,k.useState)(""),[y,I]=(0,k.useState)(""),[h,g]=(0,k.useState)(""),v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={},e[0]=v):v=e[0];let[f,d]=(0,k.useState)(v),A;e[1]===Symbol.for("react.memo_cache_sentinel")?(A=r(p=>{S(p.target.value)},"C"),e[1]=A):A=e[1];let x=A,F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F=r(p=>{C(p.target.value)},"F"),e[2]=F):F=e[2];let O=F,R;e[3]===Symbol.for("react.memo_cache_sentinel")?(R=r(p=>{I(p.target.value)},"_"),e[3]=R):R=e[3];let Pe=R,G;e[4]===Symbol.for("react.memo_cache_sentinel")?(G=r(p=>{g(p.target.value)},"O"),e[4]=G):G=e[4];let Te=G,H;e[5]===Symbol.for("react.memo_cache_sentinel")?(H=r((p,$)=>{d(V=>({...V,[p]:$}))},"G"),e[5]=H):H=e[5];let Re=H,J;e[6]!==f?(J=r(p=>f[p.name]??(p.type==="boolean"?!1:""),"H"),e[6]=f,e[7]=J):J=e[7];let j=J,K;if(e[8]!==o.userFields||e[9]!==j){let p;e[11]!==j?(p=r($=>!$.required||lt($,j($)),"p"),e[11]=j,e[12]=p):p=e[12],K=o.userFields.every(p),e[8]=o.userFields,e[9]=j,e[10]=K}else K=e[10];let Fe=K,Q;e[13]!==i||e[14]!==w||e[15]!==b||e[16]!==Fe?(Q=!i&&w.trim()!==""&&b.trim()!==""&&Fe,e[13]=i,e[14]=w,e[15]=b,e[16]=Fe,e[17]=Q):Q=e[17];let De=Q,X;e[18]!==o.userFields||e[19]!==j?(X=r(()=>{let p={};for(let $ of o.userFields){let V=rt($,j($));V!==void 0&&(p[$.name]=V.value)}return Object.keys(p).length===0?void 0:p},"W"),e[18]=o.userFields,e[19]=j,e[20]=X):X=e[20];let Se=X,Y;e[21]!==Se||e[22]!==c||e[23]!==w||e[24]!==b||e[25]!==l||e[26]!==s||e[27]!==y||e[28]!==h||e[29]!==m?(Y=r(()=>{m(async()=>{await c.createAuthUser({data:Se(),email:w.trim(),name:b.trim(),password:y===""?void 0:y,role:h.trim()===""?void 0:h.trim()}),s(),l()})},"Z"),e[21]=Se,e[22]=c,e[23]=w,e[24]=b,e[25]=l,e[26]=s,e[27]=y,e[28]=h,e[29]=m,e[30]=Y):Y=e[30];let N=Y,B;e[31]!==a?(B=a("Create user"),e[31]=a,e[32]=B):B=e[32];let q;e[33]!==a?(q=a("Create user"),e[33]=a,e[34]=q):q=e[34];let M;e[35]!==q?(M=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:q}),e[35]=q,e[36]=M):M=e[36];let ee;e[37]!==a?(ee=a("email"),e[37]=a,e[38]=ee):ee=e[38];let te;e[39]!==ee?(te=(0,t.jsx)(D,{htmlFor:"uc-email",children:ee}),e[39]=ee,e[40]=te):te=e[40];let ae;e[41]!==w?(ae=(0,t.jsx)(P,{"data-testid":"uc-email",id:"uc-email",onChange:x,type:"email",value:w}),e[41]=w,e[42]=ae):ae=e[42];let se;e[43]!==te||e[44]!==ae?(se=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[te,ae]}),e[43]=te,e[44]=ae,e[45]=se):se=e[45];let le;e[46]!==a?(le=a("name"),e[46]=a,e[47]=le):le=e[47];let re;e[48]!==le?(re=(0,t.jsx)(D,{htmlFor:"uc-name",children:le}),e[48]=le,e[49]=re):re=e[49];let ie;e[50]!==b?(ie=(0,t.jsx)(P,{"data-testid":"uc-name",id:"uc-name",onChange:O,value:b}),e[50]=b,e[51]=ie):ie=e[51];let ne;e[52]!==re||e[53]!==ie?(ne=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[re,ie]}),e[52]=re,e[53]=ie,e[54]=ne):ne=e[54];let de;e[55]!==a?(de=a("Password (optional)"),e[55]=a,e[56]=de):de=e[56];let oe;e[57]!==de?(oe=(0,t.jsx)(D,{htmlFor:"uc-password",children:de}),e[57]=de,e[58]=oe):oe=e[58];let ce;e[59]!==y?(ce=(0,t.jsx)(P,{"data-testid":"uc-password",id:"uc-password",onChange:Pe,type:"password",value:y}),e[59]=y,e[60]=ce):ce=e[60];let ue;e[61]!==oe||e[62]!==ce?(ue=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[oe,ce]}),e[61]=oe,e[62]=ce,e[63]=ue):ue=e[63];let me;e[64]!==a?(me=a("Role (optional)"),e[64]=a,e[65]=me):me=e[65];let he;e[66]!==me?(he=(0,t.jsx)(D,{htmlFor:"uc-role",children:me}),e[66]=me,e[67]=he):he=e[67];let pe;e[68]!==h?(pe=(0,t.jsx)(P,{"data-testid":"uc-role",id:"uc-role",onChange:Te,value:h}),e[68]=h,e[69]=pe):pe=e[69];let fe;e[70]!==he||e[71]!==pe?(fe=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[he,pe]}),e[70]=he,e[71]=pe,e[72]=fe):fe=e[72];let ve;e[73]!==o.userFields||e[74]!==j||e[75]!==a?(ve=o.userFields.length>0&&(0,t.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Plugin fields")}),o.userFields.map(p=>{let $=`uc-field-${p.name}`,V=p.required?"":` (${a("optional")})`;if(p.type==="boolean"){let qe=j(p)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:$,children:[(0,t.jsx)(Qe,{checked:qe,"data-testid":$,id:$,onCheckedChange:r(Xe=>{Re(p.name,Xe)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[p.name,V]})]},p.name)}let We=j(p);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(D,{htmlFor:$,children:[p.name,V]}),(0,t.jsx)(P,{"data-testid":$,id:$,onChange:r(qe=>{Re(p.name,qe.target.value)},"onChange"),type:st[p.type],value:typeof We=="string"?We:""})]},p.name)})]}),e[73]=o.userFields,e[74]=j,e[75]=a,e[76]=ve):ve=e[76];let xe;e[77]!==n?(xe=n!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:n}),e[77]=n,e[78]=xe):xe=e[78];let be;e[79]!==a?(be=a("Cancel"),e[79]=a,e[80]=be):be=e[80];let ye;e[81]!==l||e[82]!==be?(ye=(0,t.jsx)(z,{"data-testid":"uc-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:be}),e[81]=l,e[82]=be,e[83]=ye):ye=e[83];let Oe=!De,ge;e[84]!==i||e[85]!==a?(ge=a(i?"Creating\u2026":"Create"),e[84]=i,e[85]=a,e[86]=ge):ge=e[86];let Ne;e[87]!==N||e[88]!==Oe||e[89]!==ge?(Ne=(0,t.jsx)(z,{"data-testid":"uc-submit",disabled:Oe,onClick:N,size:"sm",type:"button",children:ge}),e[87]=N,e[88]=Oe,e[89]=ge,e[90]=Ne):Ne=e[90];let ke;e[91]!==ye||e[92]!==Ne?(ke=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[ye,Ne]}),e[91]=ye,e[92]=Ne,e[93]=ke):ke=e[93];let je;return e[94]!==l||e[95]!==B||e[96]!==M||e[97]!==se||e[98]!==ne||e[99]!==ue||e[100]!==fe||e[101]!==ve||e[102]!==xe||e[103]!==ke?(je=(0,t.jsxs)(Ve,{label:B,onClose:l,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[M,se,ne,ue,fe,ve,xe,ke]}),e[94]=l,e[95]=B,e[96]=M,e[97]=se,e[98]=ne,e[99]=ue,e[100]=fe,e[101]=ve,e[102]=xe,e[103]=ke,e[104]=je):je=e[104],je},"st"),Ee=r(u=>{let e=(0,Z.c)(2),{children:l}=u,s;return e[0]!==l?(s=(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l}),e[0]=l,e[1]=s):s=e[1],s},"Le"),nt=r(u=>{let e=(0,Z.c)(29),{busy:l,runAction:s,userId:c,version:a}=u,o=E(),i=W(),[n,m]=(0,k.useState)(null),[w,S]=(0,k.useState)(null),b;e[0]!==o||e[1]!==c?(b=r(()=>{ze((async()=>{S(null);try{let x=await o.listAuthSessions({limit:50,userId:c});m(x.rows)}catch(x){let F=x;m(null),S(Be(F))}})())},"x"),e[0]=o,e[1]=c,e[2]=b):b=e[2];let C;e[3]!==o||e[4]!==c||e[5]!==a?(C=[o,c,a],e[3]=o,e[4]=c,e[5]=a,e[6]=C):C=e[6],(0,k.useEffect)(b,C);let y;e[7]!==o||e[8]!==s?(y=r(x=>{s(()=>o.revokeAuthSession({sessionId:x}))},"y"),e[7]=o,e[8]=s,e[9]=y):y=e[9];let I=y,h;e[10]!==i?(h=i("Sessions"),e[10]=i,e[11]=h):h=e[11];let g;e[12]!==h?(g=(0,t.jsx)(Ee,{children:h}),e[12]=h,e[13]=g):g=e[13];let v;e[14]!==w?(v=w!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:w}),e[14]=w,e[15]=v):v=e[15];let f;e[16]!==n||e[17]!==i?(f=n!==null&&n.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:i("No active sessions.")}),e[16]=n,e[17]=i,e[18]=f):f=e[18];let d;e[19]!==l||e[20]!==I||e[21]!==n||e[22]!==i?(d=n!==null&&n.length>0&&(0,t.jsx)(we,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(Ue,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(L,{children:[(0,t.jsx)(U,{children:i("expires")}),(0,t.jsx)(U,{children:i("ip")}),(0,t.jsx)(U,{children:i("user agent")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)($e,{children:n.map(x=>(0,t.jsxs)(L,{"data-testid":`ud-session-${x.id}`,children:[(0,t.jsx)(_,{className:"text-muted-foreground tabular-nums",children:Ie(x.expiresAt)}),(0,t.jsx)(_,{children:x.ipAddress??""}),(0,t.jsx)(_,{className:"max-w-40 truncate",children:x.userAgent??""}),(0,t.jsx)(_,{children:(0,t.jsx)(z,{"data-testid":`ud-revoke-${x.id}`,disabled:l,onClick:r(()=>{I(x.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Revoke")})})]},x.id))})]})})}),e[19]=l,e[20]=I,e[21]=n,e[22]=i,e[23]=d):d=e[23];let A;return e[24]!==g||e[25]!==v||e[26]!==f||e[27]!==d?(A=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[g,v,f,d]}),e[24]=g,e[25]=v,e[26]=f,e[27]=d,e[28]=A):A=e[28],A},"rt"),dt=r(u=>{let e=(0,Z.c)(30),{busy:l,runAction:s,userId:c,version:a}=u,o=E(),i=W(),[n,m]=(0,k.useState)(null),[w,S]=(0,k.useState)(null),b;e[0]!==o||e[1]!==c?(b=r(()=>{ze((async()=>{S(null);try{m(await o.listAuthAccounts({userId:c}))}catch(x){let F=x;m(null),S(Be(F))}})())},"x"),e[0]=o,e[1]=c,e[2]=b):b=e[2];let C;e[3]!==o||e[4]!==c||e[5]!==a?(C=[o,c,a],e[3]=o,e[4]=c,e[5]=a,e[6]=C):C=e[6],(0,k.useEffect)(b,C);let y;e[7]!==o||e[8]!==s||e[9]!==c?(y=r(x=>{s(()=>o.unlinkAuthAccount({accountId:x,userId:c}))},"y"),e[7]=o,e[8]=s,e[9]=c,e[10]=y):y=e[10];let I=y,h;e[11]!==i?(h=i("Linked accounts"),e[11]=i,e[12]=h):h=e[12];let g;e[13]!==h?(g=(0,t.jsx)(Ee,{children:h}),e[13]=h,e[14]=g):g=e[14];let v;e[15]!==w?(v=w!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:w}),e[15]=w,e[16]=v):v=e[16];let f;e[17]!==n||e[18]!==i?(f=n!==null&&n.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:i("No linked accounts.")}),e[17]=n,e[18]=i,e[19]=f):f=e[19];let d;e[20]!==n||e[21]!==l||e[22]!==I||e[23]!==i?(d=n!==null&&n.length>0&&(0,t.jsx)(we,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(Ue,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(L,{children:[(0,t.jsx)(U,{children:i("provider")}),(0,t.jsx)(U,{children:i("created")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)($e,{children:n.map(x=>{let F=Ae(x.id);return(0,t.jsxs)(L,{"data-testid":`ud-account-${F}`,children:[(0,t.jsx)(_,{children:Ae(x.providerId)}),(0,t.jsx)(_,{className:"text-muted-foreground tabular-nums",children:Ie(x.createdAt)}),(0,t.jsx)(_,{children:(0,t.jsx)(z,{"data-testid":`ud-unlink-${F}`,disabled:l,onClick:r(()=>{I(F)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Unlink")})})]},F)})})]})})}),e[20]=n,e[21]=l,e[22]=I,e[23]=i,e[24]=d):d=e[24];let A;return e[25]!==g||e[26]!==v||e[27]!==f||e[28]!==d?(A=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[g,v,f,d]}),e[25]=g,e[26]=v,e[27]=f,e[28]=d,e[29]=A):A=e[29],A},"it"),ot=r(u=>{let e=(0,Z.c)(40),{busy:l,capabilities:s,runAction:c,userId:a,version:o}=u,i=E(),n=W(),[m,w]=(0,k.useState)(null),S;e[0]!==s.passkey||e[1]!==i||e[2]!==a?(S=r(()=>{s.passkey&&ze((async()=>{try{w(await i.listAuthPasskeys({userId:a}))}catch{w(null)}})())},"I"),e[0]=s.passkey,e[1]=i,e[2]=a,e[3]=S):S=e[3];let b;e[4]!==s.passkey||e[5]!==i||e[6]!==a||e[7]!==o?(b=[s.passkey,i,a,o],e[4]=s.passkey,e[5]=i,e[6]=a,e[7]=o,e[8]=b):b=e[8],(0,k.useEffect)(S,b);let C;e[9]!==i||e[10]!==c||e[11]!==a?(C=r(()=>{c(()=>i.disableAuthTwoFactor({userId:a}))},"w"),e[9]=i,e[10]=c,e[11]=a,e[12]=C):C=e[12];let y=C,I;e[13]!==i||e[14]!==c?(I=r(F=>{c(()=>i.deleteAuthPasskey({passkeyId:F}))},"A"),e[13]=i,e[14]=c,e[15]=I):I=e[15];let h=I,g;e[16]!==n?(g=n("Security"),e[16]=n,e[17]=g):g=e[17];let v;e[18]!==g?(v=(0,t.jsx)(Ee,{children:g}),e[18]=g,e[19]=v):v=e[19];let f;e[20]!==l||e[21]!==s.twoFactor||e[22]!==y||e[23]!==n?(f=s.twoFactor&&(0,t.jsx)(z,{"data-testid":"ud-disable-2fa",disabled:l,onClick:y,size:"sm",type:"button",variant:"outline",children:n("Disable two-factor")}),e[20]=l,e[21]=s.twoFactor,e[22]=y,e[23]=n,e[24]=f):f=e[24];let d;e[25]!==s.passkey||e[26]!==m||e[27]!==n?(d=s.passkey&&m!==null&&m.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:n("No passkeys.")}),e[25]=s.passkey,e[26]=m,e[27]=n,e[28]=d):d=e[28];let A;e[29]!==l||e[30]!==s.passkey||e[31]!==h||e[32]!==m||e[33]!==n?(A=s.passkey&&m!==null&&m.length>0&&(0,t.jsx)(we,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(Ue,{"data-testid":"ud-passkeys-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(L,{children:[(0,t.jsx)(U,{children:n("name")}),(0,t.jsx)(U,{children:n("created")}),(0,t.jsx)(U,{"aria-label":n("Actions")})]})}),(0,t.jsx)($e,{children:m.map(F=>{let O=Ae(F.id);return(0,t.jsxs)(L,{"data-testid":`ud-passkey-${O}`,children:[(0,t.jsx)(_,{children:Ae(F.name)||O}),(0,t.jsx)(_,{className:"text-muted-foreground tabular-nums",children:Ie(F.createdAt)}),(0,t.jsx)(_,{children:(0,t.jsx)(z,{"data-testid":`ud-delete-passkey-${O}`,disabled:l,onClick:r(()=>{h(O)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Delete")})})]},O)})})]})})}),e[29]=l,e[30]=s.passkey,e[31]=h,e[32]=m,e[33]=n,e[34]=A):A=e[34];let x;return e[35]!==v||e[36]!==f||e[37]!==d||e[38]!==A?(x=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[v,f,d,A]}),e[35]=v,e[36]=f,e[37]=d,e[38]=A,e[39]=x):x=e[39],x},"nt"),ct=/(?:at|expires)$/iu,ut=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),mt=r((u,e)=>typeof e=="number"&&ct.test(u)?Ie(e):Ae(e),"ct"),ht=r(({capabilities:u,onChanged:e,onClose:l,user:s})=>{let c=E(),a=W(),o=s.banned===!0,[i,n]=(0,k.useState)(null),[m,w]=(0,k.useState)(!1),[S,b]=(0,k.useState)(0),[C,y]=(0,k.useState)(typeof s.role=="string"?s.role:""),[I,h]=(0,k.useState)(""),[g,v]=(0,k.useState)(""),[f,d]=(0,k.useState)(""),[A,x]=(0,k.useState)(null),[F,O]=(0,k.useState)(!1),R=r((N,B)=>{ze((async()=>{w(!0),n(null);try{let q=await N();B?.refresh!==!1&&(b(M=>M+1),e()),B?.onResult?.(q)}catch(q){n(Be(q))}w(!1)})())},"_"),Pe=r(N=>{y(N.target.value)},"De"),G=r(N=>{h(N.target.value)},"O"),Te=r(N=>{v(N.target.value)},"je"),H=r(N=>{d(N.target.value)},"G"),Re=r(()=>{let N=C.trim();N!==""&&R(async()=>{await c.setAuthUserRole({role:N,userId:s.id})})},"Se"),J=r(()=>{let N=Number.parseInt(g,10),B=Number.isFinite(N)&&N>0?N*86400:void 0;R(async()=>{await c.banAuthUser({expiresInSeconds:B,reason:I.trim()===""?void 0:I.trim(),userId:s.id})})},"H"),j=r(()=>{R(async()=>{await c.unbanAuthUser({userId:s.id})})},"R"),K=r(()=>{R(async()=>{await c.setAuthUserPassword({newPassword:f,userId:s.id}),d("")})},"J"),Fe=r(()=>{R(()=>c.impersonateAuthUser({userId:s.id}),{onResult:r(N=>{x(N.token)},"onResult"),refresh:!1})},"we"),Q=r(()=>{R(async()=>{await c.revokeAuthUserSessions({userId:s.id})})},"K"),De=r(()=>{R(async()=>{await c.removeAuthUser({userId:s.id}),l()})},"Te"),X=r(()=>{O(!0)},"W"),Se=r(()=>{O(!1)},"Ce"),Y=Object.entries(s).filter(([N])=>!ut.has(N));return(0,t.jsxs)(Ve,{label:a("User details"),onClose:l,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:s.name??s.email??s.id}),(0,t.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:s.id}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof s.role=="string"&&s.role!==""&&(0,t.jsx)(T,{variant:"secondary",children:s.role}),o?(0,t.jsx)(T,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(T,{variant:"outline",children:a("Active")}),s.emailVerified===!0?(0,t.jsx)(T,{variant:"secondary",children:a("verified")}):(0,t.jsx)(T,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(z,{"data-testid":"ud-close",onClick:l,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),i!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:i}),u.admin&&(0,t.jsxs)(we,{className:"gap-0 py-0",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Actions")})}),(0,t.jsxs)(Ce,{className:"flex flex-col gap-3 p-3",children:[(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(D,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(P,{"data-testid":"ud-role-input",id:"ud-role",onChange:Pe,value:C})]}),(0,t.jsx)(z,{"data-testid":"ud-set-role",disabled:m||C.trim()==="",onClick:Re,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),o?(0,t.jsx)(z,{"data-testid":"ud-unban",disabled:m,onClick:j,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(D,{htmlFor:"ud-ban-reason",children:a("Ban reason (optional)")}),(0,t.jsx)(P,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:G,value:I})]}),(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[(0,t.jsx)(D,{htmlFor:"ud-ban-days",children:a("Days")}),(0,t.jsx)(P,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:Te,type:"number",value:g})]}),(0,t.jsx)(z,{"data-testid":"ud-ban",disabled:m,onClick:J,size:"sm",type:"button",variant:"destructive",children:a("Ban user")})]}),(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(D,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(P,{"data-testid":"ud-password",id:"ud-password",onChange:H,type:"password",value:f})]}),(0,t.jsx)(z,{"data-testid":"ud-set-password",disabled:m||f==="",onClick:K,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(z,{"data-testid":"ud-impersonate",disabled:m,onClick:Fe,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(z,{"data-testid":"ud-revoke-all",disabled:m,onClick:Q,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),F?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(z,{"data-testid":"ud-delete-confirm",disabled:m,onClick:De,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(z,{"data-testid":"ud-delete-cancel",onClick:Se,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(z,{"data-testid":"ud-delete",disabled:m,onClick:X,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),A!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(D,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(P,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:A})]})]})]}),(0,t.jsx)(nt,{busy:m,runAction:R,userId:s.id,version:S}),u.accounts&&(0,t.jsx)(dt,{busy:m,runAction:R,userId:s.id,version:S}),(u.twoFactor||u.passkey)&&(0,t.jsx)(ot,{busy:m,capabilities:u,runAction:R,userId:s.id,version:S}),(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Fields")}),(0,t.jsx)("dl",{className:"flex flex-col",children:Y.map(([N,B])=>(0,t.jsxs)("div",{className:"flex flex-col border-t border-border py-1.5",children:[(0,t.jsx)("dt",{className:"text-xs font-semibold text-muted-foreground",children:N}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:mt(N,B)})]},N))})]})]})},"ut"),pt=50,$t=r(({pageSize:u=pt}={})=>{let e=E(),l=W(),[s,c]=(0,k.useState)(""),[a,o]=(0,k.useState)(""),i=He(s),[n,m]=(0,k.useState)(null),[w,S]=(0,k.useState)(!1),{capabilities:b}=at(),C=i.trim(),y=a.trim(),I=Ge(["lunora-auth-users",C,y,u],()=>e.listAuthUsers({filterField:y===""?void 0:"role",filterValue:y===""?void 0:y,limit:u,search:C===""?void 0:C}),{keepPreviousData:!0}),h=I.data?.rows??null,g=I.error,v=r(()=>{I.refetch()},"v");Je(()=>{I.refetch()},!0);let f=n===null?null:h?.find(d=>d.id===n)??null;return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(P,{"aria-label":l("Search users"),className:"w-56","data-testid":"us-search",onChange:r(d=>{c(d.target.value)},"onChange"),placeholder:l("Search by email or name\u2026"),value:s}),(0,t.jsx)(P,{"aria-label":l("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:r(d=>{o(d.target.value)},"onChange"),placeholder:l("Filter by role"),value:a}),(0,t.jsx)(z,{"data-testid":"us-new",onClick:r(()=>{S(!0)},"onClick"),size:"sm",type:"button",children:l("New user")})]}),g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:g}),h!==null&&h.length===0&&(0,t.jsx)(Ze,{description:l("Users who sign up to your app will appear here."),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:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:l("No users.")}),h!==null&&h.length>0&&(0,t.jsx)(we,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(Ue,{"data-testid":"us-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(L,{children:[(0,t.jsx)(U,{children:l("id")}),(0,t.jsx)(U,{children:l("email")}),(0,t.jsx)(U,{children:l("name")}),(0,t.jsx)(U,{children:l("role")}),(0,t.jsx)(U,{children:l("status")}),(0,t.jsx)(U,{children:l("verified")}),(0,t.jsx)(U,{children:l("created")}),(0,t.jsx)(U,{"aria-label":l("Actions")})]})}),(0,t.jsx)($e,{children:h.map(d=>(0,t.jsxs)(L,{"data-testid":`us-row-${d.id}`,children:[(0,t.jsx)(_,{className:"font-mono text-xs",children:d.id}),(0,t.jsx)(_,{children:d.email??""}),(0,t.jsx)(_,{children:d.name??""}),(0,t.jsx)(_,{children:typeof d.role=="string"&&d.role!==""?(0,t.jsx)(T,{variant:"secondary",children:d.role}):""}),(0,t.jsx)(_,{children:d.banned===!0?(0,t.jsx)(T,{variant:"destructive",children:l("Banned")}):(0,t.jsx)(T,{variant:"success",children:l("Active")})}),(0,t.jsx)(_,{children:d.emailVerified===!0?(0,t.jsx)(T,{variant:"success",children:l("yes")}):(0,t.jsx)(T,{variant:"outline",children:l("no")})}),(0,t.jsx)(_,{className:"text-muted-foreground tabular-nums",children:Ie(d.createdAt)}),(0,t.jsx)(_,{children:(0,t.jsx)(z,{"data-testid":`us-manage-${d.id}`,onClick:r(()=>{m(d.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Manage")})})]},d.id))})]})})}),f!==null&&(0,t.jsx)(ht,{capabilities:b,onChanged:v,onClose:r(()=>{m(null)},"onClose"),user:f}),w&&(0,t.jsx)(it,{onClose:r(()=>{S(!1)},"onClose"),onCreated:v})]})},"_t");export{$t as UsersPanel};
1
+ import{a as Qe}from"./chunk-JN2Y24PY.js";import{a as Me}from"./chunk-6VAKZALJ.js";import{a as Ve}from"./chunk-ESVP44Y3.js";import{a as Ke}from"./chunk-U6TNNM5U.js";import{a as D}from"./chunk-5Y3QLNWX.js";import{a as Je}from"./chunk-54MMVNPT.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import{a as He}from"./chunk-LFKCLLPT.js";import{R as P}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as z}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as T}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{b as Ge}from"./chunk-XDAT7LHC.js";import{f as E}from"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{a as Ze}from"./chunk-XQCVZAGU.js";import{a as Ue,b as _e,c as $e,d as L,e as U,f as _}from"./chunk-MIQTKZAR.js";import{a as we,e as Ce}from"./chunk-UZERI5YC.js";import{d as W,h as Be,l as Ae,m as ze,q as Ie}from"./chunk-OG4N2XHD.js";import"./chunk-AADILRJW.js";import{a as r,e as Le,f as Ye,g as et,h as tt}from"./chunk-3XIESWL4.js";var k=Le(Ye(),1);var Z=Le(et(),1);var t=Le(tt(),1);var at=r(()=>{let u=(0,Z.c)(3),{config:e,ready:l}=Me(),s;return u[0]!==e.capabilities||u[1]!==l?(s={capabilities:e.capabilities,ready:l},u[0]=e.capabilities,u[1]=l,u[2]=s):s=u[2],s},"et"),st={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},lt=r((u,e)=>u.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:u.type!=="number"||!Number.isNaN(Number(e.trim())),"at"),rt=r((u,e)=>{if(u.type==="boolean")return e===!0?{value:!0}:u.required?{value:!1}:void 0;let l=typeof e=="string"?e.trim():"";if(l!==""){if(u.type==="number"){let s=Number(l);return Number.isNaN(s)?void 0:{value:s}}return{value:l}}},"lt"),it=r(u=>{let e=(0,Z.c)(105),{onClose:l,onCreated:s}=u,c=E(),a=W(),{config:o}=Me(),{busy:i,error:n,run:m}=Ke(),[w,S]=(0,k.useState)(""),[b,C]=(0,k.useState)(""),[y,I]=(0,k.useState)(""),[h,g]=(0,k.useState)(""),v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={},e[0]=v):v=e[0];let[f,d]=(0,k.useState)(v),A;e[1]===Symbol.for("react.memo_cache_sentinel")?(A=r(p=>{S(p.target.value)},"C"),e[1]=A):A=e[1];let x=A,F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F=r(p=>{C(p.target.value)},"F"),e[2]=F):F=e[2];let O=F,R;e[3]===Symbol.for("react.memo_cache_sentinel")?(R=r(p=>{I(p.target.value)},"_"),e[3]=R):R=e[3];let Pe=R,G;e[4]===Symbol.for("react.memo_cache_sentinel")?(G=r(p=>{g(p.target.value)},"O"),e[4]=G):G=e[4];let Te=G,H;e[5]===Symbol.for("react.memo_cache_sentinel")?(H=r((p,$)=>{d(V=>({...V,[p]:$}))},"G"),e[5]=H):H=e[5];let Re=H,J;e[6]!==f?(J=r(p=>f[p.name]??(p.type==="boolean"?!1:""),"H"),e[6]=f,e[7]=J):J=e[7];let j=J,K;if(e[8]!==o.userFields||e[9]!==j){let p;e[11]!==j?(p=r($=>!$.required||lt($,j($)),"p"),e[11]=j,e[12]=p):p=e[12],K=o.userFields.every(p),e[8]=o.userFields,e[9]=j,e[10]=K}else K=e[10];let Fe=K,Q;e[13]!==i||e[14]!==w||e[15]!==b||e[16]!==Fe?(Q=!i&&w.trim()!==""&&b.trim()!==""&&Fe,e[13]=i,e[14]=w,e[15]=b,e[16]=Fe,e[17]=Q):Q=e[17];let De=Q,X;e[18]!==o.userFields||e[19]!==j?(X=r(()=>{let p={};for(let $ of o.userFields){let V=rt($,j($));V!==void 0&&(p[$.name]=V.value)}return Object.keys(p).length===0?void 0:p},"W"),e[18]=o.userFields,e[19]=j,e[20]=X):X=e[20];let Se=X,Y;e[21]!==Se||e[22]!==c||e[23]!==w||e[24]!==b||e[25]!==l||e[26]!==s||e[27]!==y||e[28]!==h||e[29]!==m?(Y=r(()=>{m(async()=>{await c.createAuthUser({data:Se(),email:w.trim(),name:b.trim(),password:y===""?void 0:y,role:h.trim()===""?void 0:h.trim()}),s(),l()})},"Z"),e[21]=Se,e[22]=c,e[23]=w,e[24]=b,e[25]=l,e[26]=s,e[27]=y,e[28]=h,e[29]=m,e[30]=Y):Y=e[30];let N=Y,B;e[31]!==a?(B=a("Create user"),e[31]=a,e[32]=B):B=e[32];let q;e[33]!==a?(q=a("Create user"),e[33]=a,e[34]=q):q=e[34];let M;e[35]!==q?(M=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:q}),e[35]=q,e[36]=M):M=e[36];let ee;e[37]!==a?(ee=a("email"),e[37]=a,e[38]=ee):ee=e[38];let te;e[39]!==ee?(te=(0,t.jsx)(D,{htmlFor:"uc-email",children:ee}),e[39]=ee,e[40]=te):te=e[40];let ae;e[41]!==w?(ae=(0,t.jsx)(P,{"data-testid":"uc-email",id:"uc-email",onChange:x,type:"email",value:w}),e[41]=w,e[42]=ae):ae=e[42];let se;e[43]!==te||e[44]!==ae?(se=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[te,ae]}),e[43]=te,e[44]=ae,e[45]=se):se=e[45];let le;e[46]!==a?(le=a("name"),e[46]=a,e[47]=le):le=e[47];let re;e[48]!==le?(re=(0,t.jsx)(D,{htmlFor:"uc-name",children:le}),e[48]=le,e[49]=re):re=e[49];let ie;e[50]!==b?(ie=(0,t.jsx)(P,{"data-testid":"uc-name",id:"uc-name",onChange:O,value:b}),e[50]=b,e[51]=ie):ie=e[51];let ne;e[52]!==re||e[53]!==ie?(ne=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[re,ie]}),e[52]=re,e[53]=ie,e[54]=ne):ne=e[54];let de;e[55]!==a?(de=a("Password (optional)"),e[55]=a,e[56]=de):de=e[56];let oe;e[57]!==de?(oe=(0,t.jsx)(D,{htmlFor:"uc-password",children:de}),e[57]=de,e[58]=oe):oe=e[58];let ce;e[59]!==y?(ce=(0,t.jsx)(P,{"data-testid":"uc-password",id:"uc-password",onChange:Pe,type:"password",value:y}),e[59]=y,e[60]=ce):ce=e[60];let ue;e[61]!==oe||e[62]!==ce?(ue=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[oe,ce]}),e[61]=oe,e[62]=ce,e[63]=ue):ue=e[63];let me;e[64]!==a?(me=a("Role (optional)"),e[64]=a,e[65]=me):me=e[65];let he;e[66]!==me?(he=(0,t.jsx)(D,{htmlFor:"uc-role",children:me}),e[66]=me,e[67]=he):he=e[67];let pe;e[68]!==h?(pe=(0,t.jsx)(P,{"data-testid":"uc-role",id:"uc-role",onChange:Te,value:h}),e[68]=h,e[69]=pe):pe=e[69];let fe;e[70]!==he||e[71]!==pe?(fe=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[he,pe]}),e[70]=he,e[71]=pe,e[72]=fe):fe=e[72];let ve;e[73]!==o.userFields||e[74]!==j||e[75]!==a?(ve=o.userFields.length>0&&(0,t.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Plugin fields")}),o.userFields.map(p=>{let $=`uc-field-${p.name}`,V=p.required?"":` (${a("optional")})`;if(p.type==="boolean"){let qe=j(p)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:$,children:[(0,t.jsx)(Qe,{checked:qe,"data-testid":$,id:$,onCheckedChange:r(Xe=>{Re(p.name,Xe)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[p.name,V]})]},p.name)}let We=j(p);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(D,{htmlFor:$,children:[p.name,V]}),(0,t.jsx)(P,{"data-testid":$,id:$,onChange:r(qe=>{Re(p.name,qe.target.value)},"onChange"),type:st[p.type],value:typeof We=="string"?We:""})]},p.name)})]}),e[73]=o.userFields,e[74]=j,e[75]=a,e[76]=ve):ve=e[76];let xe;e[77]!==n?(xe=n!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:n}),e[77]=n,e[78]=xe):xe=e[78];let be;e[79]!==a?(be=a("Cancel"),e[79]=a,e[80]=be):be=e[80];let ye;e[81]!==l||e[82]!==be?(ye=(0,t.jsx)(z,{"data-testid":"uc-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:be}),e[81]=l,e[82]=be,e[83]=ye):ye=e[83];let Oe=!De,ge;e[84]!==i||e[85]!==a?(ge=a(i?"Creating\u2026":"Create"),e[84]=i,e[85]=a,e[86]=ge):ge=e[86];let Ne;e[87]!==N||e[88]!==Oe||e[89]!==ge?(Ne=(0,t.jsx)(z,{"data-testid":"uc-submit",disabled:Oe,onClick:N,size:"sm",type:"button",children:ge}),e[87]=N,e[88]=Oe,e[89]=ge,e[90]=Ne):Ne=e[90];let ke;e[91]!==ye||e[92]!==Ne?(ke=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[ye,Ne]}),e[91]=ye,e[92]=Ne,e[93]=ke):ke=e[93];let je;return e[94]!==l||e[95]!==B||e[96]!==M||e[97]!==se||e[98]!==ne||e[99]!==ue||e[100]!==fe||e[101]!==ve||e[102]!==xe||e[103]!==ke?(je=(0,t.jsxs)(Ve,{label:B,onClose:l,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[M,se,ne,ue,fe,ve,xe,ke]}),e[94]=l,e[95]=B,e[96]=M,e[97]=se,e[98]=ne,e[99]=ue,e[100]=fe,e[101]=ve,e[102]=xe,e[103]=ke,e[104]=je):je=e[104],je},"st"),Ee=r(u=>{let e=(0,Z.c)(2),{children:l}=u,s;return e[0]!==l?(s=(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l}),e[0]=l,e[1]=s):s=e[1],s},"Le"),nt=r(u=>{let e=(0,Z.c)(29),{busy:l,runAction:s,userId:c,version:a}=u,o=E(),i=W(),[n,m]=(0,k.useState)(null),[w,S]=(0,k.useState)(null),b;e[0]!==o||e[1]!==c?(b=r(()=>{ze((async()=>{S(null);try{let x=await o.listAuthSessions({limit:50,userId:c});m(x.rows)}catch(x){let F=x;m(null),S(Be(F))}})())},"x"),e[0]=o,e[1]=c,e[2]=b):b=e[2];let C;e[3]!==o||e[4]!==c||e[5]!==a?(C=[o,c,a],e[3]=o,e[4]=c,e[5]=a,e[6]=C):C=e[6],(0,k.useEffect)(b,C);let y;e[7]!==o||e[8]!==s?(y=r(x=>{s(()=>o.revokeAuthSession({sessionId:x}))},"y"),e[7]=o,e[8]=s,e[9]=y):y=e[9];let I=y,h;e[10]!==i?(h=i("Sessions"),e[10]=i,e[11]=h):h=e[11];let g;e[12]!==h?(g=(0,t.jsx)(Ee,{children:h}),e[12]=h,e[13]=g):g=e[13];let v;e[14]!==w?(v=w!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:w}),e[14]=w,e[15]=v):v=e[15];let f;e[16]!==n||e[17]!==i?(f=n!==null&&n.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:i("No active sessions.")}),e[16]=n,e[17]=i,e[18]=f):f=e[18];let d;e[19]!==l||e[20]!==I||e[21]!==n||e[22]!==i?(d=n!==null&&n.length>0&&(0,t.jsx)(we,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(Ue,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(L,{children:[(0,t.jsx)(U,{children:i("expires")}),(0,t.jsx)(U,{children:i("ip")}),(0,t.jsx)(U,{children:i("user agent")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)($e,{children:n.map(x=>(0,t.jsxs)(L,{"data-testid":`ud-session-${x.id}`,children:[(0,t.jsx)(_,{className:"text-muted-foreground tabular-nums",children:Ie(x.expiresAt)}),(0,t.jsx)(_,{children:x.ipAddress??""}),(0,t.jsx)(_,{className:"max-w-40 truncate",children:x.userAgent??""}),(0,t.jsx)(_,{children:(0,t.jsx)(z,{"data-testid":`ud-revoke-${x.id}`,disabled:l,onClick:r(()=>{I(x.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Revoke")})})]},x.id))})]})})}),e[19]=l,e[20]=I,e[21]=n,e[22]=i,e[23]=d):d=e[23];let A;return e[24]!==g||e[25]!==v||e[26]!==f||e[27]!==d?(A=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[g,v,f,d]}),e[24]=g,e[25]=v,e[26]=f,e[27]=d,e[28]=A):A=e[28],A},"rt"),dt=r(u=>{let e=(0,Z.c)(30),{busy:l,runAction:s,userId:c,version:a}=u,o=E(),i=W(),[n,m]=(0,k.useState)(null),[w,S]=(0,k.useState)(null),b;e[0]!==o||e[1]!==c?(b=r(()=>{ze((async()=>{S(null);try{m(await o.listAuthAccounts({userId:c}))}catch(x){let F=x;m(null),S(Be(F))}})())},"x"),e[0]=o,e[1]=c,e[2]=b):b=e[2];let C;e[3]!==o||e[4]!==c||e[5]!==a?(C=[o,c,a],e[3]=o,e[4]=c,e[5]=a,e[6]=C):C=e[6],(0,k.useEffect)(b,C);let y;e[7]!==o||e[8]!==s||e[9]!==c?(y=r(x=>{s(()=>o.unlinkAuthAccount({accountId:x,userId:c}))},"y"),e[7]=o,e[8]=s,e[9]=c,e[10]=y):y=e[10];let I=y,h;e[11]!==i?(h=i("Linked accounts"),e[11]=i,e[12]=h):h=e[12];let g;e[13]!==h?(g=(0,t.jsx)(Ee,{children:h}),e[13]=h,e[14]=g):g=e[14];let v;e[15]!==w?(v=w!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:w}),e[15]=w,e[16]=v):v=e[16];let f;e[17]!==n||e[18]!==i?(f=n!==null&&n.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:i("No linked accounts.")}),e[17]=n,e[18]=i,e[19]=f):f=e[19];let d;e[20]!==n||e[21]!==l||e[22]!==I||e[23]!==i?(d=n!==null&&n.length>0&&(0,t.jsx)(we,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(Ue,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(L,{children:[(0,t.jsx)(U,{children:i("provider")}),(0,t.jsx)(U,{children:i("created")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)($e,{children:n.map(x=>{let F=Ae(x.id);return(0,t.jsxs)(L,{"data-testid":`ud-account-${F}`,children:[(0,t.jsx)(_,{children:Ae(x.providerId)}),(0,t.jsx)(_,{className:"text-muted-foreground tabular-nums",children:Ie(x.createdAt)}),(0,t.jsx)(_,{children:(0,t.jsx)(z,{"data-testid":`ud-unlink-${F}`,disabled:l,onClick:r(()=>{I(F)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Unlink")})})]},F)})})]})})}),e[20]=n,e[21]=l,e[22]=I,e[23]=i,e[24]=d):d=e[24];let A;return e[25]!==g||e[26]!==v||e[27]!==f||e[28]!==d?(A=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[g,v,f,d]}),e[25]=g,e[26]=v,e[27]=f,e[28]=d,e[29]=A):A=e[29],A},"it"),ot=r(u=>{let e=(0,Z.c)(40),{busy:l,capabilities:s,runAction:c,userId:a,version:o}=u,i=E(),n=W(),[m,w]=(0,k.useState)(null),S;e[0]!==s.passkey||e[1]!==i||e[2]!==a?(S=r(()=>{s.passkey&&ze((async()=>{try{w(await i.listAuthPasskeys({userId:a}))}catch{w(null)}})())},"I"),e[0]=s.passkey,e[1]=i,e[2]=a,e[3]=S):S=e[3];let b;e[4]!==s.passkey||e[5]!==i||e[6]!==a||e[7]!==o?(b=[s.passkey,i,a,o],e[4]=s.passkey,e[5]=i,e[6]=a,e[7]=o,e[8]=b):b=e[8],(0,k.useEffect)(S,b);let C;e[9]!==i||e[10]!==c||e[11]!==a?(C=r(()=>{c(()=>i.disableAuthTwoFactor({userId:a}))},"w"),e[9]=i,e[10]=c,e[11]=a,e[12]=C):C=e[12];let y=C,I;e[13]!==i||e[14]!==c?(I=r(F=>{c(()=>i.deleteAuthPasskey({passkeyId:F}))},"A"),e[13]=i,e[14]=c,e[15]=I):I=e[15];let h=I,g;e[16]!==n?(g=n("Security"),e[16]=n,e[17]=g):g=e[17];let v;e[18]!==g?(v=(0,t.jsx)(Ee,{children:g}),e[18]=g,e[19]=v):v=e[19];let f;e[20]!==l||e[21]!==s.twoFactor||e[22]!==y||e[23]!==n?(f=s.twoFactor&&(0,t.jsx)(z,{"data-testid":"ud-disable-2fa",disabled:l,onClick:y,size:"sm",type:"button",variant:"outline",children:n("Disable two-factor")}),e[20]=l,e[21]=s.twoFactor,e[22]=y,e[23]=n,e[24]=f):f=e[24];let d;e[25]!==s.passkey||e[26]!==m||e[27]!==n?(d=s.passkey&&m!==null&&m.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:n("No passkeys.")}),e[25]=s.passkey,e[26]=m,e[27]=n,e[28]=d):d=e[28];let A;e[29]!==l||e[30]!==s.passkey||e[31]!==h||e[32]!==m||e[33]!==n?(A=s.passkey&&m!==null&&m.length>0&&(0,t.jsx)(we,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(Ue,{"data-testid":"ud-passkeys-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(L,{children:[(0,t.jsx)(U,{children:n("name")}),(0,t.jsx)(U,{children:n("created")}),(0,t.jsx)(U,{"aria-label":n("Actions")})]})}),(0,t.jsx)($e,{children:m.map(F=>{let O=Ae(F.id);return(0,t.jsxs)(L,{"data-testid":`ud-passkey-${O}`,children:[(0,t.jsx)(_,{children:Ae(F.name)||O}),(0,t.jsx)(_,{className:"text-muted-foreground tabular-nums",children:Ie(F.createdAt)}),(0,t.jsx)(_,{children:(0,t.jsx)(z,{"data-testid":`ud-delete-passkey-${O}`,disabled:l,onClick:r(()=>{h(O)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Delete")})})]},O)})})]})})}),e[29]=l,e[30]=s.passkey,e[31]=h,e[32]=m,e[33]=n,e[34]=A):A=e[34];let x;return e[35]!==v||e[36]!==f||e[37]!==d||e[38]!==A?(x=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[v,f,d,A]}),e[35]=v,e[36]=f,e[37]=d,e[38]=A,e[39]=x):x=e[39],x},"nt"),ct=/(?:at|expires)$/iu,ut=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),mt=r((u,e)=>typeof e=="number"&&ct.test(u)?Ie(e):Ae(e),"ct"),ht=r(({capabilities:u,onChanged:e,onClose:l,user:s})=>{let c=E(),a=W(),o=s.banned===!0,[i,n]=(0,k.useState)(null),[m,w]=(0,k.useState)(!1),[S,b]=(0,k.useState)(0),[C,y]=(0,k.useState)(typeof s.role=="string"?s.role:""),[I,h]=(0,k.useState)(""),[g,v]=(0,k.useState)(""),[f,d]=(0,k.useState)(""),[A,x]=(0,k.useState)(null),[F,O]=(0,k.useState)(!1),R=r((N,B)=>{ze((async()=>{w(!0),n(null);try{let q=await N();B?.refresh!==!1&&(b(M=>M+1),e()),B?.onResult?.(q)}catch(q){n(Be(q))}w(!1)})())},"_"),Pe=r(N=>{y(N.target.value)},"De"),G=r(N=>{h(N.target.value)},"O"),Te=r(N=>{v(N.target.value)},"je"),H=r(N=>{d(N.target.value)},"G"),Re=r(()=>{let N=C.trim();N!==""&&R(async()=>{await c.setAuthUserRole({role:N,userId:s.id})})},"Se"),J=r(()=>{let N=Number.parseInt(g,10),B=Number.isFinite(N)&&N>0?N*86400:void 0;R(async()=>{await c.banAuthUser({expiresInSeconds:B,reason:I.trim()===""?void 0:I.trim(),userId:s.id})})},"H"),j=r(()=>{R(async()=>{await c.unbanAuthUser({userId:s.id})})},"R"),K=r(()=>{R(async()=>{await c.setAuthUserPassword({newPassword:f,userId:s.id}),d("")})},"J"),Fe=r(()=>{R(()=>c.impersonateAuthUser({userId:s.id}),{onResult:r(N=>{x(N.token)},"onResult"),refresh:!1})},"we"),Q=r(()=>{R(async()=>{await c.revokeAuthUserSessions({userId:s.id})})},"K"),De=r(()=>{R(async()=>{await c.removeAuthUser({userId:s.id}),l()})},"Te"),X=r(()=>{O(!0)},"W"),Se=r(()=>{O(!1)},"Ce"),Y=Object.entries(s).filter(([N])=>!ut.has(N));return(0,t.jsxs)(Ve,{label:a("User details"),onClose:l,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:s.name??s.email??s.id}),(0,t.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:s.id}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof s.role=="string"&&s.role!==""&&(0,t.jsx)(T,{variant:"secondary",children:s.role}),o?(0,t.jsx)(T,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(T,{variant:"outline",children:a("Active")}),s.emailVerified===!0?(0,t.jsx)(T,{variant:"secondary",children:a("verified")}):(0,t.jsx)(T,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(z,{"data-testid":"ud-close",onClick:l,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),i!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:i}),u.admin&&(0,t.jsxs)(we,{className:"gap-0 py-0",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Actions")})}),(0,t.jsxs)(Ce,{className:"flex flex-col gap-3 p-3",children:[(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(D,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(P,{"data-testid":"ud-role-input",id:"ud-role",onChange:Pe,value:C})]}),(0,t.jsx)(z,{"data-testid":"ud-set-role",disabled:m||C.trim()==="",onClick:Re,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),o?(0,t.jsx)(z,{"data-testid":"ud-unban",disabled:m,onClick:j,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(D,{htmlFor:"ud-ban-reason",children:a("Ban reason (optional)")}),(0,t.jsx)(P,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:G,value:I})]}),(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[(0,t.jsx)(D,{htmlFor:"ud-ban-days",children:a("Days")}),(0,t.jsx)(P,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:Te,type:"number",value:g})]}),(0,t.jsx)(z,{"data-testid":"ud-ban",disabled:m,onClick:J,size:"sm",type:"button",variant:"destructive",children:a("Ban user")})]}),(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(D,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(P,{"data-testid":"ud-password",id:"ud-password",onChange:H,type:"password",value:f})]}),(0,t.jsx)(z,{"data-testid":"ud-set-password",disabled:m||f==="",onClick:K,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(z,{"data-testid":"ud-impersonate",disabled:m,onClick:Fe,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(z,{"data-testid":"ud-revoke-all",disabled:m,onClick:Q,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),F?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(z,{"data-testid":"ud-delete-confirm",disabled:m,onClick:De,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(z,{"data-testid":"ud-delete-cancel",onClick:Se,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(z,{"data-testid":"ud-delete",disabled:m,onClick:X,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),A!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(D,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(P,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:A})]})]})]}),(0,t.jsx)(nt,{busy:m,runAction:R,userId:s.id,version:S}),u.accounts&&(0,t.jsx)(dt,{busy:m,runAction:R,userId:s.id,version:S}),(u.twoFactor||u.passkey)&&(0,t.jsx)(ot,{busy:m,capabilities:u,runAction:R,userId:s.id,version:S}),(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Fields")}),(0,t.jsx)("dl",{className:"flex flex-col",children:Y.map(([N,B])=>(0,t.jsxs)("div",{className:"flex flex-col border-t border-border py-1.5",children:[(0,t.jsx)("dt",{className:"text-xs font-semibold text-muted-foreground",children:N}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:mt(N,B)})]},N))})]})]})},"ut"),pt=50,$t=r(({pageSize:u=pt}={})=>{let e=E(),l=W(),[s,c]=(0,k.useState)(""),[a,o]=(0,k.useState)(""),i=He(s),[n,m]=(0,k.useState)(null),[w,S]=(0,k.useState)(!1),{capabilities:b}=at(),C=i.trim(),y=a.trim(),I=Ge(["lunora-auth-users",C,y,u],()=>e.listAuthUsers({filterField:y===""?void 0:"role",filterValue:y===""?void 0:y,limit:u,search:C===""?void 0:C}),{keepPreviousData:!0}),h=I.data?.rows??null,g=I.error,v=r(()=>{I.refetch()},"v");Je(()=>{I.refetch()},!0);let f=n===null?null:h?.find(d=>d.id===n)??null;return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(P,{"aria-label":l("Search users"),className:"w-56","data-testid":"us-search",onChange:r(d=>{c(d.target.value)},"onChange"),placeholder:l("Search by email or name\u2026"),value:s}),(0,t.jsx)(P,{"aria-label":l("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:r(d=>{o(d.target.value)},"onChange"),placeholder:l("Filter by role"),value:a}),(0,t.jsx)(z,{"data-testid":"us-new",onClick:r(()=>{S(!0)},"onClick"),size:"sm",type:"button",children:l("New user")})]}),g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:g}),h!==null&&h.length===0&&(0,t.jsx)(Ze,{description:l("Users who sign up to your app will appear here."),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:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:l("No users.")}),h!==null&&h.length>0&&(0,t.jsx)(we,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(Ue,{"data-testid":"us-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(L,{children:[(0,t.jsx)(U,{children:l("id")}),(0,t.jsx)(U,{children:l("email")}),(0,t.jsx)(U,{children:l("name")}),(0,t.jsx)(U,{children:l("role")}),(0,t.jsx)(U,{children:l("status")}),(0,t.jsx)(U,{children:l("verified")}),(0,t.jsx)(U,{children:l("created")}),(0,t.jsx)(U,{"aria-label":l("Actions")})]})}),(0,t.jsx)($e,{children:h.map(d=>(0,t.jsxs)(L,{"data-testid":`us-row-${d.id}`,children:[(0,t.jsx)(_,{className:"font-mono text-xs",children:d.id}),(0,t.jsx)(_,{children:d.email??""}),(0,t.jsx)(_,{children:d.name??""}),(0,t.jsx)(_,{children:typeof d.role=="string"&&d.role!==""?(0,t.jsx)(T,{variant:"secondary",children:d.role}):""}),(0,t.jsx)(_,{children:d.banned===!0?(0,t.jsx)(T,{variant:"destructive",children:l("Banned")}):(0,t.jsx)(T,{variant:"success",children:l("Active")})}),(0,t.jsx)(_,{children:d.emailVerified===!0?(0,t.jsx)(T,{variant:"success",children:l("yes")}):(0,t.jsx)(T,{variant:"outline",children:l("no")})}),(0,t.jsx)(_,{className:"text-muted-foreground tabular-nums",children:Ie(d.createdAt)}),(0,t.jsx)(_,{children:(0,t.jsx)(z,{"data-testid":`us-manage-${d.id}`,onClick:r(()=>{m(d.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Manage")})})]},d.id))})]})})}),f!==null&&(0,t.jsx)(ht,{capabilities:b,onChanged:v,onClose:r(()=>{m(null)},"onClose"),user:f}),w&&(0,t.jsx)(it,{onClose:r(()=>{S(!1)},"onClose"),onCreated:v})]})},"_t");export{$t as UsersPanel};
@@ -1,4 +1,4 @@
1
- import{a as me}from"./chunk-SKHEGARW.js";import{a as te,e as se}from"./chunk-UZERI5YC.js";import{R as ne}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as ee}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import"./chunk-XBDKZZ67.js";import{d as Z,h as ie,m as de,o as ce}from"./chunk-OG4N2XHD.js";import{a as h,e as Y,f as ge,g as xe,h as ye}from"./chunk-3XIESWL4.js";var re=Y(xe(),1),K=Y(ge(),1);var s=Y(ye(),1);var be=h(e=>{let t=(0,re.c)(23),{destination:r}=e,f=Z(),g;t[0]!==r.snippet?(g=h(()=>{ce(r.snippet)},"g"),t[0]=r.snippet,t[1]=g):g=t[1];let m=g,a;t[2]!==r.title?(a=(0,s.jsx)("h4",{className:"text-sm font-semibold",children:r.title}),t[2]=r.title,t[3]=a):a=t[3];let o;t[4]!==r.description?(o=(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:r.description}),t[4]=r.description,t[5]=o):o=t[5];let d;t[6]!==a||t[7]!==o?(d=(0,s.jsxs)("div",{children:[a,o]}),t[6]=a,t[7]=o,t[8]=d):d=t[8];let H=`drain-copy-${r.id}`,l;t[9]!==f?(l=f("Copy"),t[9]=f,t[10]=l):l=t[10];let n;t[11]!==m||t[12]!==H||t[13]!==l?(n=(0,s.jsx)(ee,{"data-testid":H,onClick:m,size:"sm",variant:"outline",children:l}),t[11]=m,t[12]=H,t[13]=l,t[14]=n):n=t[14];let i;t[15]!==d||t[16]!==n?(i=(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[d,n]}),t[15]=d,t[16]=n,t[17]=i):i=t[17];let c;t[18]!==r.snippet?(c=(0,s.jsx)("pre",{className:"mt-2 overflow-x-auto rounded bg-muted p-2 font-mono text-xs",children:r.snippet}),t[18]=r.snippet,t[19]=c):c=t[19];let x;return t[20]!==i||t[21]!==c?(x=(0,s.jsx)(te,{className:"py-0","data-testid":"drain-card",children:(0,s.jsxs)(se,{className:"p-3",children:[i,c]})}),t[20]=i,t[21]=c,t[22]=x):x=t[22],x},"he"),je=h(()=>{let e=(0,re.c)(88),t=Z(),r;e[0]!==t?(r=t("Stream every request log to R2, a SIEM, or a third-party log service."),e[0]=t,e[1]=r):r=e[1];let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f=["{",' "logpush": true',"}"],e[2]=f):f=e[2];let g=f.join(`
1
+ import{a as me}from"./chunk-XF2B7P5A.js";import{R as ne}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as ee}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import"./chunk-XBDKZZ67.js";import{a as te,e as se}from"./chunk-UZERI5YC.js";import{d as Z,h as ie,m as de,o as ce}from"./chunk-OG4N2XHD.js";import{a as h,e as Y,f as ge,g as xe,h as ye}from"./chunk-3XIESWL4.js";var re=Y(xe(),1),K=Y(ge(),1);var s=Y(ye(),1);var be=h(e=>{let t=(0,re.c)(23),{destination:r}=e,f=Z(),g;t[0]!==r.snippet?(g=h(()=>{ce(r.snippet)},"g"),t[0]=r.snippet,t[1]=g):g=t[1];let m=g,a;t[2]!==r.title?(a=(0,s.jsx)("h4",{className:"text-sm font-semibold",children:r.title}),t[2]=r.title,t[3]=a):a=t[3];let o;t[4]!==r.description?(o=(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:r.description}),t[4]=r.description,t[5]=o):o=t[5];let d;t[6]!==a||t[7]!==o?(d=(0,s.jsxs)("div",{children:[a,o]}),t[6]=a,t[7]=o,t[8]=d):d=t[8];let H=`drain-copy-${r.id}`,l;t[9]!==f?(l=f("Copy"),t[9]=f,t[10]=l):l=t[10];let n;t[11]!==m||t[12]!==H||t[13]!==l?(n=(0,s.jsx)(ee,{"data-testid":H,onClick:m,size:"sm",variant:"outline",children:l}),t[11]=m,t[12]=H,t[13]=l,t[14]=n):n=t[14];let i;t[15]!==d||t[16]!==n?(i=(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[d,n]}),t[15]=d,t[16]=n,t[17]=i):i=t[17];let c;t[18]!==r.snippet?(c=(0,s.jsx)("pre",{className:"mt-2 overflow-x-auto rounded bg-muted p-2 font-mono text-xs",children:r.snippet}),t[18]=r.snippet,t[19]=c):c=t[19];let x;return t[20]!==i||t[21]!==c?(x=(0,s.jsx)(te,{className:"py-0","data-testid":"drain-card",children:(0,s.jsxs)(se,{className:"p-3",children:[i,c]})}),t[20]=i,t[21]=c,t[22]=x):x=t[22],x},"he"),je=h(()=>{let e=(0,re.c)(88),t=Z(),r;e[0]!==t?(r=t("Stream every request log to R2, a SIEM, or a third-party log service."),e[0]=t,e[1]=r):r=e[1];let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f=["{",' "logpush": true',"}"],e[2]=f):f=e[2];let g=f.join(`
2
2
  `),m;e[3]!==t?(m=t("Logpush"),e[3]=t,e[4]=m):m=e[4];let a;e[5]!==r||e[6]!==m?(a={description:r,id:"logpush",snippet:g,title:m},e[5]=r,e[6]=m,e[7]=a):a=e[7];let o;e[8]!==t?(o=t("Send logs programmatically to a Worker for custom capture and forwarding."),e[8]=t,e[9]=o):o=e[9];let d;e[10]===Symbol.for("react.memo_cache_sentinel")?(d=["{",' "tail_consumers": [{ "service": "my-log-forwarder" }]',"}"],e[10]=d):d=e[10];let H=d.join(`
3
3
  `),l;e[11]!==t?(l=t("Tail Workers"),e[11]=t,e[12]=l):l=e[12];let n;e[13]!==o||e[14]!==l?(n={description:o,id:"tail-worker",snippet:H,title:l},e[13]=o,e[14]=l,e[15]=n):n=e[15];let i;e[16]!==t?(i=t("Retain and query recent request logs directly in Cloudflare's dashboard."),e[16]=t,e[17]=i):i=e[17];let c;e[18]===Symbol.for("react.memo_cache_sentinel")?(c=["{",' "observability": { "enabled": true }',"}"],e[18]=c):c=e[18];let x=c.join(`
4
4
  `),y;e[19]!==t?(y=t("Workers Logs"),e[19]=t,e[20]=y):y=e[20];let b;e[21]!==i||e[22]!==y?(b={description:i,id:"workers-logs",snippet:x,title:y},e[21]=i,e[22]=y,e[23]=b):b=e[23];let J;e[24]!==b||e[25]!==a||e[26]!==n?(J=[a,n,b],e[24]=b,e[25]=a,e[26]=n,e[27]=J):J=e[27];let Q=J,[p,pe]=(0,K.useState)(""),[k,ae]=(0,K.useState)(!1),[u,$]=(0,K.useState)(null),A;if(e[28]!==t||e[29]!==p){let V=h(async()=>{let oe=p.trim();if(oe==="")return;let le="fetch"in globalThis?globalThis.fetch:void 0;if(le===void 0){$({kind:"error",message:t("fetch is unavailable in this environment.")});return}let fe={durationMs:12,function:"messages:list",outcome:"ok",shard:"root",source:"lunora",tablesRead:["messages"],tablesWritten:[],ts:new Date().toISOString(),type:"request"};ae(!0),$(null);let he=performance.now();try{let X=await le(oe,{body:JSON.stringify(fe),headers:{"Content-Type":"application/json"},method:"POST"});$({kind:"success",latencyMs:Math.round(performance.now()-he),status:X.status})}catch(X){$({kind:"error",message:ie(X)})}ae(!1)},"G");A=h(()=>{de(V())},"z"),e[28]=t,e[29]=p,e[30]=A}else A=e[30];let U=A,B;e[31]===Symbol.for("react.memo_cache_sentinel")?(B=h(V=>{pe(V.target.value)},"J"),e[31]=B):B=e[31];let ue=B,v;e[32]!==t?(v=t("Open in Cloudflare"),e[32]=t,e[33]=v):v=e[33];let w;e[34]!==v?(w=(0,s.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,s.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"drain-cf-link",href:me,rel:"noreferrer",target:"_blank",children:v})}),e[34]=v,e[35]=w):w=e[35];let N;e[36]!==t?(N=t("Lunora does not ship logs itself \u2014 forwarding is handled by Cloudflare. Configure a destination below, then test your collector."),e[36]=t,e[37]=N):N=e[37];let S;e[38]!==N?(S=(0,s.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"drain-readonly-note",children:N}),e[38]=N,e[39]=S):S=e[39];let _;e[40]!==t?(_=t("Cloudflare destinations"),e[40]=t,e[41]=_):_=e[41];let C;e[42]!==_?(C=(0,s.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:_}),e[42]=_,e[43]=C):C=e[43];let j;e[44]!==Q?(j=Q.map(ke),e[44]=Q,e[45]=j):j=e[45];let T;e[46]!==C||e[47]!==j?(T=(0,s.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"drain-destinations",children:[C,j]}),e[46]=C,e[47]=j,e[48]=T):T=e[48];let q;e[49]!==t?(q=t("Webhook test"),e[49]=t,e[50]=q):q=e[50];let L;e[51]!==q?(L=(0,s.jsx)("h3",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:q}),e[51]=q,e[52]=L):L=e[52];let M;e[53]!==t?(M=t("POST a sample Lunora request-log envelope to your collector to confirm it is reachable."),e[53]=t,e[54]=M):M=e[54];let O;e[55]!==M?(O=(0,s.jsx)("p",{className:"mb-2 text-sm text-muted-foreground",children:M}),e[55]=M,e[56]=O):O=e[56];let W;e[57]!==t?(W=t("https://example.com/logs"),e[57]=t,e[58]=W):W=e[58];let D;e[59]!==W||e[60]!==p?(D=(0,s.jsx)(ne,{className:"min-w-[20rem] flex-1","data-testid":"drain-webhook-url",onChange:ue,placeholder:W,type:"url",value:p}),e[59]=W,e[60]=p,e[61]=D):D=e[61];let P;e[62]!==k||e[63]!==p?(P=k||p.trim()==="",e[62]=k,e[63]=p,e[64]=P):P=e[64];let R;e[65]!==k||e[66]!==t?(R=t(k?"Sending\u2026":"Send test event"),e[65]=k,e[66]=t,e[67]=R):R=e[67];let F;e[68]!==U||e[69]!==P||e[70]!==R?(F=(0,s.jsx)(ee,{"data-testid":"drain-webhook-test",disabled:P,onClick:U,children:R}),e[68]=U,e[69]=P,e[70]=R,e[71]=F):F=e[71];let I;e[72]!==D||e[73]!==F?(I=(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[D,F]}),e[72]=D,e[73]=F,e[74]=I):I=e[74];let z;e[75]!==u||e[76]!==t?(z=u!==null&&(0,s.jsx)("p",{className:u.kind==="success"?"mt-2 text-sm text-muted-foreground":"mt-2 text-sm text-destructive","data-testid":"drain-webhook-result",role:u.kind==="error"?"alert":void 0,children:u.kind==="success"?t("Delivered \u2014 status {status} in {latency}ms",{latency:u.latencyMs,status:u.status}):t("Failed: {message}",{message:u.message})}),e[75]=u,e[76]=t,e[77]=z):z=e[77];let E;e[78]!==L||e[79]!==O||e[80]!==I||e[81]!==z?(E=(0,s.jsx)(te,{className:"py-0",children:(0,s.jsx)(se,{className:"p-3",children:(0,s.jsxs)("section",{"data-testid":"drain-webhook",children:[L,O,I,z]})})}),e[78]=L,e[79]=O,e[80]=I,e[81]=z,e[82]=E):E=e[82];let G;return e[83]!==w||e[84]!==S||e[85]!==T||e[86]!==E?(G=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"log-drains",children:[w,S,T,E]}),e[83]=w,e[84]=S,e[85]=T,e[86]=E,e[87]=G):G=e[87],G},"_e");function ke(e){return(0,s.jsx)(be,{destination:e},e.id)}h(ke,"ge");export{je as LogDrainsPanel};
@@ -1 +1 @@
1
- import{a as D}from"./chunk-54MMVNPT.js";import{b as B}from"./chunk-XDAT7LHC.js";import{a as W,b as q,c as E,d as S,e as r,f as s}from"./chunk-MIQTKZAR.js";import{a as A,e as L}from"./chunk-UZERI5YC.js";import{b as x}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{f as O}from"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{a as j}from"./chunk-XQCVZAGU.js";import{d as z}from"./chunk-OG4N2XHD.js";import"./chunk-AADILRJW.js";import{a as T,e as M,g as $,h as I}from"./chunk-3XIESWL4.js";var F=M($(),1);var n=M(I(),1);var J=2e3,Q=new Set(["open"]),re=T(G=>{let e=(0,F.c)(41),{read:y}=G,t=z(),K=O(),v;e[0]!==K||e[1]!==y?(v=T(()=>Promise.resolve(y?y():K.debug()),"S"),e[0]=K,e[1]=y,e[2]=v):v=e[2];let H=v,P=y?"injected":"live",b;e[3]!==P?(b=["lunora-studio","sync-client-debug",P],e[3]=P,e[4]=b):b=e[4];let{data:c,refetch:Y}=B(b,H);if(D(Y,!0,J),!c){let i;e[5]!==t?(i=t("Reading the sync client's state\u2026"),e[5]=t,e[6]=i):i=e[6];let g;e[7]!==t?(g=t("Sync client"),e[7]=t,e[8]=g):g=e[8];let _;return e[9]!==i||e[10]!==g?(_=(0,n.jsx)(A,{children:(0,n.jsx)(L,{children:(0,n.jsx)(j,{description:i,title:g})})}),e[9]=i,e[10]=g,e[11]=_):_=e[11],_}let{pendingWrites:k,shards:N,subscriptions:w}=c,l;e[12]!==t?(l=t("This Studio session's sync client"),e[12]=t,e[13]=l):l=e[13];let a;e[14]!==l?(a=(0,n.jsx)("span",{className:"text-sm font-medium",children:l}),e[14]=l,e[15]=a):a=e[15];let R=c.connectionStatus==="connected"?"default":"secondary",o;e[16]!==c.connectionStatus||e[17]!==R?(o=(0,n.jsx)(x,{variant:R,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=R,e[18]=o):o=e[18];let d;e[19]!==k||e[20]!==t?(d=k>0?(0,n.jsx)(x,{variant:"secondary",children:t("{count} pending writes",{count:k})}):null,e[19]=k,e[20]=t,e[21]=d):d=e[21];let h;e[22]!==a||e[23]!==o||e[24]!==d?(h=(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[a,o,d]}),e[22]=a,e[23]=o,e[24]=d,e[25]=h):h=e[25];let u;e[26]!==t?(u=t("Reads client.debug() for the client running in this page \u2014 not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=t,e[27]=u):u=e[27];let m;e[28]!==u?(m=(0,n.jsx)("p",{className:"text-muted-foreground text-xs",children:u}),e[28]=u,e[29]=m):m=e[29];let p;e[30]!==N||e[31]!==t?(p=N.length===0?(0,n.jsx)(j,{description:t("No shard connection has been opened yet."),title:t("No shards")}):(0,n.jsxs)(W,{children:[(0,n.jsx)(q,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(r,{children:t("Shard")}),(0,n.jsx)(r,{children:t("Socket")}),(0,n.jsx)(r,{children:t("Confirmed watermark")})]})}),(0,n.jsx)(E,{children:N.map(i=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{children:i.shardKey??t("(default)")}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:Q.has(i.wsState)?"default":"secondary",children:i.wsState})}),(0,n.jsx)(s,{children:i.confirmedMutationWatermark})]},i.shardKey??"__default__"))})]}),e[30]=N,e[31]=t,e[32]=p):p=e[32];let f;e[33]!==w||e[34]!==t?(f=w.length===0?(0,n.jsx)(j,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):(0,n.jsxs)(W,{children:[(0,n.jsx)(q,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(r,{children:t("Subscription")}),(0,n.jsx)(r,{children:t("Kind")}),(0,n.jsx)(r,{children:t("Acked")}),(0,n.jsx)(r,{children:t("Cursor")}),(0,n.jsx)(r,{children:t("Pending overlays")})]})}),(0,n.jsx)(E,{children:w.map(i=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{className:"font-mono text-xs",children:i.functionPath}),(0,n.jsx)(s,{children:i.kind}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:i.acked?"default":"secondary",children:i.acked?t("yes"):t("no")})}),(0,n.jsx)(s,{children:i.serverCursor??"\u2014"}),(0,n.jsx)(s,{children:i.pendingOptimisticLayers})]},i.id))})]}),e[33]=w,e[34]=t,e[35]=f):f=e[35];let C;return e[36]!==m||e[37]!==p||e[38]!==f||e[39]!==h?(C=(0,n.jsx)(A,{children:(0,n.jsxs)(L,{className:"flex flex-col gap-4",children:[h,m,p,f]})}),e[36]=m,e[37]=p,e[38]=f,e[39]=h,e[40]=C):C=e[40],C},"re");export{re as default};
1
+ import{a as D}from"./chunk-54MMVNPT.js";import{b as x}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{b as B}from"./chunk-XDAT7LHC.js";import{f as O}from"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{a as j}from"./chunk-XQCVZAGU.js";import{a as W,b as q,c as E,d as S,e as r,f as s}from"./chunk-MIQTKZAR.js";import{a as A,e as L}from"./chunk-UZERI5YC.js";import{d as z}from"./chunk-OG4N2XHD.js";import"./chunk-AADILRJW.js";import{a as T,e as M,g as $,h as I}from"./chunk-3XIESWL4.js";var F=M($(),1);var n=M(I(),1);var J=2e3,Q=new Set(["open"]),re=T(G=>{let e=(0,F.c)(41),{read:y}=G,t=z(),K=O(),v;e[0]!==K||e[1]!==y?(v=T(()=>Promise.resolve(y?y():K.debug()),"S"),e[0]=K,e[1]=y,e[2]=v):v=e[2];let H=v,P=y?"injected":"live",b;e[3]!==P?(b=["lunora-studio","sync-client-debug",P],e[3]=P,e[4]=b):b=e[4];let{data:c,refetch:Y}=B(b,H);if(D(Y,!0,J),!c){let i;e[5]!==t?(i=t("Reading the sync client's state\u2026"),e[5]=t,e[6]=i):i=e[6];let g;e[7]!==t?(g=t("Sync client"),e[7]=t,e[8]=g):g=e[8];let _;return e[9]!==i||e[10]!==g?(_=(0,n.jsx)(A,{children:(0,n.jsx)(L,{children:(0,n.jsx)(j,{description:i,title:g})})}),e[9]=i,e[10]=g,e[11]=_):_=e[11],_}let{pendingWrites:k,shards:N,subscriptions:w}=c,l;e[12]!==t?(l=t("This Studio session's sync client"),e[12]=t,e[13]=l):l=e[13];let a;e[14]!==l?(a=(0,n.jsx)("span",{className:"text-sm font-medium",children:l}),e[14]=l,e[15]=a):a=e[15];let R=c.connectionStatus==="connected"?"default":"secondary",o;e[16]!==c.connectionStatus||e[17]!==R?(o=(0,n.jsx)(x,{variant:R,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=R,e[18]=o):o=e[18];let d;e[19]!==k||e[20]!==t?(d=k>0?(0,n.jsx)(x,{variant:"secondary",children:t("{count} pending writes",{count:k})}):null,e[19]=k,e[20]=t,e[21]=d):d=e[21];let h;e[22]!==a||e[23]!==o||e[24]!==d?(h=(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[a,o,d]}),e[22]=a,e[23]=o,e[24]=d,e[25]=h):h=e[25];let u;e[26]!==t?(u=t("Reads client.debug() for the client running in this page \u2014 not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=t,e[27]=u):u=e[27];let m;e[28]!==u?(m=(0,n.jsx)("p",{className:"text-muted-foreground text-xs",children:u}),e[28]=u,e[29]=m):m=e[29];let p;e[30]!==N||e[31]!==t?(p=N.length===0?(0,n.jsx)(j,{description:t("No shard connection has been opened yet."),title:t("No shards")}):(0,n.jsxs)(W,{children:[(0,n.jsx)(q,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(r,{children:t("Shard")}),(0,n.jsx)(r,{children:t("Socket")}),(0,n.jsx)(r,{children:t("Confirmed watermark")})]})}),(0,n.jsx)(E,{children:N.map(i=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{children:i.shardKey??t("(default)")}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:Q.has(i.wsState)?"default":"secondary",children:i.wsState})}),(0,n.jsx)(s,{children:i.confirmedMutationWatermark})]},i.shardKey??"__default__"))})]}),e[30]=N,e[31]=t,e[32]=p):p=e[32];let f;e[33]!==w||e[34]!==t?(f=w.length===0?(0,n.jsx)(j,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):(0,n.jsxs)(W,{children:[(0,n.jsx)(q,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(r,{children:t("Subscription")}),(0,n.jsx)(r,{children:t("Kind")}),(0,n.jsx)(r,{children:t("Acked")}),(0,n.jsx)(r,{children:t("Cursor")}),(0,n.jsx)(r,{children:t("Pending overlays")})]})}),(0,n.jsx)(E,{children:w.map(i=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{className:"font-mono text-xs",children:i.functionPath}),(0,n.jsx)(s,{children:i.kind}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:i.acked?"default":"secondary",children:i.acked?t("yes"):t("no")})}),(0,n.jsx)(s,{children:i.serverCursor??"\u2014"}),(0,n.jsx)(s,{children:i.pendingOptimisticLayers})]},i.id))})]}),e[33]=w,e[34]=t,e[35]=f):f=e[35];let C;return e[36]!==m||e[37]!==p||e[38]!==f||e[39]!==h?(C=(0,n.jsx)(A,{children:(0,n.jsxs)(L,{className:"flex flex-col gap-4",children:[h,m,p,f]})}),e[36]=m,e[37]=p,e[38]=f,e[39]=h,e[40]=C):C=e[40],C},"re");export{re as default};
@@ -0,0 +1 @@
1
+ import{b as me,e as _}from"./chunk-Y5Y7DHFW.js";import{a as ue}from"./chunk-CTNB2KIA.js";import"./chunk-CU55Y5TV.js";import"./chunk-4UOFSGUS.js";import"./chunk-ILNELDFC.js";import{a as de}from"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{b as P}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import"./chunk-QLQADHFE.js";import{a as M}from"./chunk-ERMTJYQF.js";import{c as ce}from"./chunk-XDAT7LHC.js";import{f as ne,g as oe}from"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{a as A}from"./chunk-UZERI5YC.js";import{d as D,f as j,g as W,h as X,m as K,q as ie}from"./chunk-OG4N2XHD.js";import"./chunk-AADILRJW.js";import{a as h,e as I,f as qe,g as ae,h as le,j as q}from"./chunk-3XIESWL4.js";var Z=I(ae(),1);var f=I(qe(),1);var fe=I(ae(),1);var $=I(le(),1);var Me={connected:"bg-success",connecting:"bg-warning",idle:"bg-muted-foreground",offline:"bg-destructive"},pe=h(()=>{let t=(0,fe.c)(16),e=D(),a=oe(),s;e:switch(a){case"connected":{let n;t[0]!==e?(n=e("Connected"),t[0]=e,t[1]=n):n=t[1],s=n;break e}case"connecting":{let n;t[2]!==e?(n=e("Connecting\u2026"),t[2]=e,t[3]=n):n=t[3],s=n;break e}case"idle":{let n;t[4]!==e?(n=e("Idle"),t[4]=e,t[5]=n):n=t[5],s=n;break e}case"offline":{let n;t[6]!==e?(n=e("Offline"),t[6]=e,t[7]=n):n=t[7],s=n;break e}default:s=a}let l=Me[a],c;t[8]!==l?(c=q("size-2 rounded-full",l),t[8]=l,t[9]=c):c=t[9];let o;t[10]!==c?(o=(0,$.jsx)("span",{"aria-hidden":"true",className:c}),t[10]=c,t[11]=o):o=t[11];let i;return t[12]!==a||t[13]!==o||t[14]!==s?(i=(0,$.jsxs)("span",{"aria-live":"polite",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground","data-status":a,"data-testid":"dash-connection",role:"status",children:[o,s]}),t[12]=a,t[13]=o,t[14]=s,t[15]=i):i=t[15],i},"j");var r=I(le(),1);var Ae={crit:"destructive",ok:"secondary",warn:"default"},U=h((t,e)=>e===0?"\u2014":`${(t/e*100).toFixed(1)}%`,"_"),Y=h((t,e,a)=>Number.isNaN(t)?"ok":t>=a?"crit":t>=e?"warn":"ok","V"),xe=.01,ve=.05,je=h(t=>{let e=(0,Z.c)(36),{errorCount:a,logsError:s,topErrors:l,worstFunctions:c}=t,o=D(),i;e[0]!==o?(i=o("Functions by error rate"),e[0]=o,e[1]=i):i=e[1];let n;e[2]!==i?(n=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i})}),e[2]=i,e[3]=n):n=e[3];let p;e[4]!==o||e[5]!==c?(p=c.length===0?(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-functions-empty",children:o("No function activity yet.")}):(0,r.jsx)("ul",{className:"divide-y divide-border",children:c.map(w=>(0,r.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-xs","data-testid":"hl-fn-row",children:[(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:w.path}),(0,r.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[(0,r.jsx)("span",{className:"tabular-nums text-muted-foreground",children:o("{count} calls",{count:w.calls.toString()})}),(0,r.jsx)(P,{variant:Ae[Y(w.errors/w.calls,xe,ve)],children:U(w.errors,w.calls)})]})]},w.path))}),e[4]=o,e[5]=c,e[6]=p):p=e[6];let g;e[7]!==n||e[8]!==p?(g=(0,r.jsxs)(A,{className:"gap-0 py-0","data-testid":"hl-functions",children:[n,p]}),e[7]=n,e[8]=p,e[9]=g):g=e[9];let N;e[10]!==o?(N=o("Recent errors"),e[10]=o,e[11]=N):N=e[11];let d;e[12]!==N?(d=(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:N}),e[12]=N,e[13]=d):d=e[13];let u=a>0?"destructive":"outline",x;e[14]!==a||e[15]!==u?(x=(0,r.jsx)(P,{"data-testid":"hl-error-count",variant:u,children:a}),e[14]=a,e[15]=u,e[16]=x):x=e[16];let v;e[17]!==d||e[18]!==x?(v=(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[d,x]}),e[17]=d,e[18]=x,e[19]=v):v=e[19];let k;e[20]!==s?(k=s!==null&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:s}),e[20]=s,e[21]=k):k=e[21];let S;e[22]!==s||e[23]!==o||e[24]!==l.length?(S=s===null&&l.length===0&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-errors-empty",children:o("No recent errors.")}),e[22]=s,e[23]=o,e[24]=l.length,e[25]=S):S=e[25];let E;e[26]!==l?(E=l.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:l.map(Ce)}),e[26]=l,e[27]=E):E=e[27];let b;e[28]!==k||e[29]!==S||e[30]!==E||e[31]!==v?(b=(0,r.jsxs)(A,{className:"gap-0 py-0",children:[v,k,S,E]}),e[28]=k,e[29]=S,e[30]=E,e[31]=v,e[32]=b):b=e[32];let y;return e[33]!==b||e[34]!==g?(y=(0,r.jsxs)("div",{className:"grid gap-3 lg:grid-cols-2",children:[g,b]}),e[33]=b,e[34]=g,e[35]=y):y=e[35],y},"Se");function Ce(t,e){return(0,r.jsxs)("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)("time",{className:"shrink-0 text-muted-foreground",children:ie(t.timestamp)}),t.functionPath!==void 0&&(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:t.functionPath})]}),(0,r.jsx)("span",{className:"text-destructive",children:t.message})]},`${t.timestamp.toString()}-${e.toString()}`)}h(Ce,"Ee");var he={completed:0,failed:2,in_progress:1},Ie=h(t=>{let e=0,a=0,s=0,l=0,c=[];for(let{metrics:o}of t){if(o===null){l+=1;continue}s+=1,e+=o.requests,a+=o.errors,c.push(...o.history??[])}return{errors:a,failed:l,history:c,reachable:s,requests:e}},"Me"),De=h(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.path);if(l===void 0){e.set(s.path,{...s});continue}l.calls+=s.calls,l.errors+=s.errors,l.totalDurationMs+=s.totalDurationMs,l.scans=(l.scans??0)+(s.scans??0),l.maxDurationMs=Math.max(l.maxDurationMs,s.maxDurationMs),l.lastCalledAt=Math.max(l.lastCalledAt,s.lastCalledAt),(s.lastErrorAt??0)>(l.lastErrorAt??0)&&(l.lastErrorAt=s.lastErrorAt,l.lastErrorMessage=s.lastErrorMessage)}return[...e.values()]},"qe"),Pe=h(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.id);if(l===void 0){e.set(s.id,s);continue}let c=he[s.status]-he[l.status];(c>0||c===0&&(s.updatedAt??0)>(l.updatedAt??0))&&e.set(s.id,s)}return[...e.values()]},"$e"),Fe=j(M.getAuthMetrics),Le=j(M.getFunctionStats),Te=j(M.getLogs),Re=j(M.getMetrics),ze=j(M.migrationStatus),Oe=5,ge=2e3,Ke=5,_e=.1,$e=.3,He=1,Ue=50,Ge=h((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","_e"),Qe=h(t=>{let e=new Map;for(let s of t??[]){let l=e.get(s.bucketMs)??{calls:0,errors:0};l.calls+=s.calls,l.errors+=s.errors,e.set(s.bucketMs,l)}let a=[...e.entries()].toSorted((s,l)=>s[0]-l[0]);return{errors:a.map(([,s])=>s.errors),requests:a.map(([,s])=>s.calls)}},"ze"),Je=h(t=>{let e=0,a=0;for(let l of t)l.status==="failed"?e+=1:l.status==="in_progress"&&(a+=1);let s="ok";return e>0?s="crit":a>0&&(s="warn"),{failed:e,level:s,running:a}},"Ke"),Ve=h((t,e)=>t.failed>0?e("{count} failed",{count:t.failed.toString()}):t.running>0?e("{count} running",{count:t.running.toString()}):e("OK"),"He"),Ne={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},be={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},We={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},Xe=h(t=>t.includes("crit")?"crit":t.includes("warn")?"warn":"ok","Be"),H=h(t=>{let e=(0,Z.c)(19),{chart:a,label:s,level:l,testId:c,value:o}=t,i=Ne[l],n;e[0]!==i?(n=q("size-1.5 shrink-0 rounded-full",i),e[0]=i,e[1]=n):n=e[1];let p;e[2]!==n?(p=(0,r.jsx)("span",{"aria-hidden":"true",className:n}),e[2]=n,e[3]=p):p=e[3];let g;e[4]!==s||e[5]!==p?(g=(0,r.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[p,s]}),e[4]=s,e[5]=p,e[6]=g):g=e[6];let N=be[l],d;e[7]!==N?(d=q("truncate text-2xl font-semibold tabular-nums",N),e[7]=N,e[8]=d):d=e[8];let u;e[9]!==d||e[10]!==c||e[11]!==o?(u=(0,r.jsx)("span",{className:d,"data-testid":c,children:o}),e[9]=d,e[10]=c,e[11]=o,e[12]=u):u=e[12];let x;e[13]!==a||e[14]!==u?(x=(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[u,a]}),e[13]=a,e[14]=u,e[15]=x):x=e[15];let v;return e[16]!==g||e[17]!==x?(v=(0,r.jsx)(A,{className:"gap-0 py-0",children:(0,r.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[g,x]})}),e[16]=g,e[17]=x,e[18]=v):v=e[18],v},"T"),Ye=h(async(t,e,a)=>{let s=await Promise.all(a.map(d=>{let u=W(d);return Promise.allSettled([t.query(Re,{},u),t.query(Le,{},u),t.query(ze,{},u)])})),l=W(e),c=typeof t.schedulerStatus=="function"?t.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[o,i,n]=await Promise.allSettled([t.query(Te,{},l),t.query(Fe,{},l),c]),p=s.map(([d,u,x])=>({functions:u.status==="fulfilled"?u.value.functions:[],metrics:d.status==="fulfilled"?d.value:null,migrations:x.status==="fulfilled"?x.value.migrations:[]})),g=Ie(p),N=s[0]?.[0];return{auth:i.status==="fulfilled"?i.value:null,entries:o.status==="fulfilled"?o.value.entries:[],functions:De(p.map(d=>d.functions)),logsError:o.status==="rejected"?X(o.reason):null,metricsError:g.reachable===0&&N?.status==="rejected"?X(N.reason):null,migrations:Pe(p.map(d=>d.migrations)),scheduler:n.status==="fulfilled"?n.value:null,totals:g}},"Ge"),Ze=h(t=>{let e=t?.history??[];return{attempts:e.map(a=>a.attempts),failures:e.map(a=>a.failures)}},"Qe"),xt=h(({initialShardKey:t})=>{let e=ne(),a=D(),[s,l]=(0,f.useState)([]),[c,o]=(0,f.useState)(null),[i,n]=(0,f.useState)(null),[p,g]=(0,f.useState)(null),[N,d]=(0,f.useState)([]),[u,x]=(0,f.useState)(null),[v,k]=(0,f.useState)(null),[S,E]=(0,f.useState)([]),[b]=(0,f.useState)(de),y=(0,f.useRef)(!1),w=(0,f.useRef)(!0);(0,f.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]);let F=t??"",L=(0,f.useCallback)(async()=>{if(y.current)return;y.current=!0;let m=await Ye(e,F,me(F,b));if(!w.current){y.current=!1;return}n(m.totals),g(m.metricsError),d(m.functions),E(m.migrations),l(m.entries),o(m.logsError),x(m.auth),k(m.scheduler),y.current=!1},[e,b,F]);(0,f.useEffect)(()=>{K(L())},[L]);let G=(0,f.useRef)(0),C=(0,f.useRef)(null),we=h(()=>{let m=Date.now()-G.current;if(m>=ge){G.current=Date.now(),K(L());return}C.current===null&&(C.current=setTimeout(()=>{C.current=null,G.current=Date.now(),K(L())},ge-m))},"de");(0,f.useEffect)(()=>()=>{C.current!==null&&clearTimeout(C.current)},[]);let{data:B,liveError:ye}=ce(M.getMetrics,{},{live:!0,shardKey:F});(0,f.useEffect)(()=>{B!==void 0&&we()},[B]);let ee=s.filter(m=>m.level==="error"),ke=ee.slice(0,Oe),T=Qe(i?.history),te=Ze(u),Se=N.filter(m=>m.calls>0).toSorted((m,V)=>V.errors/V.calls-m.errors/m.calls||V.calls-m.calls).slice(0,Ke),Q=Je(S),Ee=i===null||i.requests===0?0:i.errors/i.requests,J=Y(Ee,xe,ve),re=u===null?"ok":Y(u.failureRate,_e,$e),se=v===null?"ok":Ge(v.backlog,He,Ue),R=Xe([J,re,se,Q.level]),z,O;return R==="crit"?(z=a("Critical"),O=a("One or more service levels are breached.")):R==="warn"?(z=a("Degraded"),O=a("Some service levels need attention.")):(z=a("All systems healthy"),O=a("All service levels are within target.")),(0,r.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[(0,r.jsxs)(A,{className:"gap-0 py-0",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:q("flex size-10 shrink-0 items-center justify-center rounded-full",We[R]),children:(0,r.jsx)("span",{className:q("size-3 rounded-full",Ne[R])})}),(0,r.jsxs)("div",{className:"grid leading-tight",children:[(0,r.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:z}),(0,r.jsx)("span",{className:"text-[13px] text-muted-foreground",children:O})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Requests")}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[T.requests.length>=2&&(0,r.jsx)(_,{ariaLabel:a("Requests over time"),className:"h-6 w-20 text-foreground",series:T.requests,testId:"hl-spark-requests"}),(0,r.jsx)("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:(i?.requests??0).toString()})]})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Error rate")}),(0,r.jsx)("div",{className:q("text-lg font-semibold tabular-nums",be[J]),"data-testid":"hl-error-rate",children:i===null?"\u2014":U(i.errors,i.requests)})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(pe,{}),(0,r.jsx)(ue,{message:ye,prefix:"hl"})]})]})]}),p!==null&&(0,r.jsx)("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-sm text-destructive","data-testid":"hl-metrics-error",role:"alert",children:p})]}),(0,r.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[(0,r.jsx)(H,{chart:T.errors.length>=2?(0,r.jsx)(_,{ariaLabel:a("Errors over time"),className:"h-7 w-20 text-destructive",series:T.errors,testId:"hl-spark-errors"}):void 0,label:a("Error rate"),level:J,testId:"hl-slo-errorrate",value:i===null?"\u2014":U(i.errors,i.requests)}),(0,r.jsx)(H,{chart:te.failures.length>=2?(0,r.jsx)(_,{ariaLabel:a("Auth failures over time"),className:"h-7 w-20 text-destructive",series:te.failures,testId:"hl-spark-auth"}):void 0,label:a("Auth failures"),level:re,testId:"hl-slo-auth",value:u===null?"\u2014":U(u.failures,u.attempts)}),(0,r.jsx)(H,{label:a("Scheduler backlog"),level:se,testId:"hl-slo-backlog",value:v===null?"\u2014":v.backlog.toString()}),(0,r.jsx)(H,{label:a("Migrations"),level:Q.level,testId:"hl-slo-migrations",value:Ve(Q,a)})]}),(0,r.jsx)(je,{errorCount:ee.length,logsError:c,topErrors:ke,worstFunctions:Se}),(0,r.jsxs)(A,{className:"gap-0 py-0",children:[(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Shards seen")}),(0,r.jsx)(P,{"data-testid":"hl-shard-count",variant:"outline",children:b.length})]}),b.length>0&&(0,r.jsx)("ul",{className:"flex flex-wrap gap-1.5 p-4",children:b.map(m=>(0,r.jsx)("li",{"data-testid":"hl-shard",children:(0,r.jsx)(P,{variant:"secondary",children:m})},m))})]})]})},"dt");export{xt as HealthPanel};
@@ -1 +1 @@
1
- import{b as S}from"./chunk-XDAT7LHC.js";import{a as y,e as A}from"./chunk-UZERI5YC.js";import{b as h}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{f as k}from"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{d as I}from"./chunk-OG4N2XHD.js";import"./chunk-AADILRJW.js";import{a as u,e as w,g as $,h as j}from"./chunk-3XIESWL4.js";var N=w($(),1);var a=w(j(),1);var z=[{key:"accounts",label:"Accounts"},{key:"admin",label:"Admin"},{key:"organization",label:"Organizations"},{key:"passkey",label:"Passkeys"},{key:"twoFactor",label:"Two-factor"}],v=u(e=>{if(e===void 0)return"\u2014";let i=[[86400,"d"],[3600,"h"],[60,"m"]];for(let[t,d]of i)if(e>=t&&e%t===0)return`${String(e/t)}${d}`;return`${String(e)}s`},"v"),g=u(e=>{let i=(0,N.c)(8),{children:t,heading:d,testId:r}=e,l;i[0]!==d?(l=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:d})}),i[0]=d,i[1]=l):l=i[1];let n;i[2]!==t?(n=(0,a.jsx)(A,{className:"p-3",children:t}),i[2]=t,i[3]=n):n=i[3];let c;return i[4]!==l||i[5]!==n||i[6]!==r?(c=(0,a.jsxs)(y,{className:"gap-0 py-0","data-testid":r,children:[l,n]}),i[4]=l,i[5]=n,i[6]=r,i[7]=c):c=i[7],c},"h"),o=u(e=>{let i=(0,N.c)(7),{label:t,value:d}=e,r;i[0]!==t?(r=(0,a.jsx)("span",{className:"text-sm",children:t}),i[0]=t,i[1]=r):r=i[1];let l;i[2]!==d?(l=(0,a.jsx)("span",{className:"text-sm text-muted-foreground tabular-nums",children:d}),i[2]=d,i[3]=l):l=i[3];let n;return i[4]!==r||i[5]!==l?(n=(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs",children:[r,l]}),i[4]=r,i[5]=l,i[6]=n):n=i[6],n},"c"),T=u(()=>{let e=(0,N.c)(20),i=k(),t=I(),d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=["lunora-auth-config"],e[0]=d):d=e[0];let r;e[1]!==i?(r=u(()=>i.getAuthConfig(),"s"),e[1]=i,e[2]=r):r=e[2];let{data:l,error:n}=S(d,r),c;e[3]!==t?(c=u(s=>(0,a.jsx)(h,{variant:s?"success":"outline",children:t(s?"Enabled":"Disabled")}),"u"),e[3]=t,e[4]=c):c=e[4];let m=c,p;e[5]!==n?(p=n!==null&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"auth-config-error",role:"alert",children:n}),e[5]=n,e[6]=p):p=e[6];let f;e[7]!==l||e[8]!==n||e[9]!==t?(f=n===null&&l===void 0&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"auth-config-loading",children:t("Loading auth configuration\u2026")}),e[7]=l,e[8]=n,e[9]=t,e[10]=f):f=e[10];let x;e[11]!==l||e[12]!==n||e[13]!==m||e[14]!==t?(x=n===null&&l!==void 0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(g,{heading:t("Enabled capabilities"),testId:"auth-config-capabilities",children:(0,a.jsx)("ul",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:z.map(s=>{let P=l.capabilities[s.key];return(0,a.jsxs)("li",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs","data-testid":`auth-config-cap-${s.key}`,children:[(0,a.jsx)("span",{className:"text-sm",children:t(s.label)}),m(P)]},s.key)})})}),(0,a.jsx)(g,{heading:t("Plugins"),testId:"auth-config-plugins",children:l.plugins.length===0?(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:t("No plugins enabled.")}):(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:l.plugins.map(L)})}),(0,a.jsx)(g,{heading:t("Sign-in methods"),testId:"auth-config-signin",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(o,{label:t("Email & password"),value:m(l.emailAndPassword)}),(0,a.jsx)(o,{label:t("Social providers"),value:l.socialProviders.length===0?t("None"):(0,a.jsx)("span",{className:"flex flex-wrap justify-end gap-1",children:l.socialProviders.map(q)})})]})}),l.organization.enabled&&(0,a.jsx)(g,{heading:t("Organizations"),testId:"auth-config-org",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(o,{label:t("Teams"),value:m(l.organization.teams)}),(0,a.jsx)(o,{label:t("Custom roles"),value:m(l.organization.roles)})]})}),(0,a.jsx)(g,{heading:t("Session policy"),testId:"auth-config-session",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(o,{label:t("Expires in"),value:v(l.session.expiresIn)}),(0,a.jsx)(o,{label:t("Refresh after"),value:v(l.session.updateAge)}),(0,a.jsx)(o,{label:t("Fresh window"),value:v(l.session.freshAge)}),(0,a.jsx)(o,{label:t("Cookie cache"),value:m(l.session.cookieCache===!0)})]})}),(0,a.jsx)(g,{heading:t("Rate limit"),testId:"auth-config-ratelimit",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(o,{label:t("Status"),value:m(l.rateLimit.enabled)}),l.rateLimit.enabled&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o,{label:t("Max requests"),value:l.rateLimit.max??"\u2014"}),(0,a.jsx)(o,{label:t("Window"),value:v(l.rateLimit.window)})]})]})}),l.userFields.length>0&&(0,a.jsx)(g,{heading:t("Plugin user fields"),testId:"auth-config-user-fields",children:(0,a.jsx)("ul",{className:"flex flex-col gap-2",children:l.userFields.map(s=>(0,a.jsxs)("li",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs","data-testid":`auth-config-user-field-${s.name}`,children:[(0,a.jsxs)("span",{className:"flex flex-col",children:[(0,a.jsx)("span",{className:"font-mono text-xs",children:s.name}),s.plugin!==void 0&&(0,a.jsx)("span",{className:"text-[11px] text-muted-foreground",children:s.plugin})]}),(0,a.jsxs)("span",{className:"flex items-center gap-1",children:[(0,a.jsx)(h,{variant:"outline",children:s.type}),s.required&&(0,a.jsx)(h,{variant:"secondary",children:t("required")}),s.unique&&(0,a.jsx)(h,{variant:"secondary",children:t("unique")})]})]},s.name))})}),(0,a.jsx)(y,{className:"gap-0 py-0",children:(0,a.jsx)("p",{className:"px-4 py-3 text-xs text-muted-foreground","data-testid":"auth-config-note",children:t("OAuth providers, email templates, and rate limits are configured at deploy time in the better-auth setup and aren't editable here. See the Mail tab for email output.")})})]}),e[11]=l,e[12]=n,e[13]=m,e[14]=t,e[15]=x):x=e[15];let b;return e[16]!==p||e[17]!==f||e[18]!==x?(b=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"auth-config",children:[p,f,x]}),e[16]=p,e[17]=f,e[18]=x,e[19]=b):b=e[19],b},"M");function L(e){return(0,a.jsx)(h,{"data-testid":`auth-config-plugin-${e}`,variant:"outline",children:e},e)}u(L,"P");function q(e){return(0,a.jsx)(h,{"data-testid":`auth-config-provider-${e}`,variant:"outline",children:e},e)}u(q,"z");export{T as AuthConfigPanel};
1
+ import{b as h}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{b as S}from"./chunk-XDAT7LHC.js";import{f as k}from"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{a as y,e as A}from"./chunk-UZERI5YC.js";import{d as I}from"./chunk-OG4N2XHD.js";import"./chunk-AADILRJW.js";import{a as u,e as w,g as $,h as j}from"./chunk-3XIESWL4.js";var N=w($(),1);var a=w(j(),1);var z=[{key:"accounts",label:"Accounts"},{key:"admin",label:"Admin"},{key:"organization",label:"Organizations"},{key:"passkey",label:"Passkeys"},{key:"twoFactor",label:"Two-factor"}],v=u(e=>{if(e===void 0)return"\u2014";let i=[[86400,"d"],[3600,"h"],[60,"m"]];for(let[t,d]of i)if(e>=t&&e%t===0)return`${String(e/t)}${d}`;return`${String(e)}s`},"v"),g=u(e=>{let i=(0,N.c)(8),{children:t,heading:d,testId:r}=e,l;i[0]!==d?(l=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:d})}),i[0]=d,i[1]=l):l=i[1];let n;i[2]!==t?(n=(0,a.jsx)(A,{className:"p-3",children:t}),i[2]=t,i[3]=n):n=i[3];let c;return i[4]!==l||i[5]!==n||i[6]!==r?(c=(0,a.jsxs)(y,{className:"gap-0 py-0","data-testid":r,children:[l,n]}),i[4]=l,i[5]=n,i[6]=r,i[7]=c):c=i[7],c},"h"),o=u(e=>{let i=(0,N.c)(7),{label:t,value:d}=e,r;i[0]!==t?(r=(0,a.jsx)("span",{className:"text-sm",children:t}),i[0]=t,i[1]=r):r=i[1];let l;i[2]!==d?(l=(0,a.jsx)("span",{className:"text-sm text-muted-foreground tabular-nums",children:d}),i[2]=d,i[3]=l):l=i[3];let n;return i[4]!==r||i[5]!==l?(n=(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs",children:[r,l]}),i[4]=r,i[5]=l,i[6]=n):n=i[6],n},"c"),T=u(()=>{let e=(0,N.c)(20),i=k(),t=I(),d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=["lunora-auth-config"],e[0]=d):d=e[0];let r;e[1]!==i?(r=u(()=>i.getAuthConfig(),"s"),e[1]=i,e[2]=r):r=e[2];let{data:l,error:n}=S(d,r),c;e[3]!==t?(c=u(s=>(0,a.jsx)(h,{variant:s?"success":"outline",children:t(s?"Enabled":"Disabled")}),"u"),e[3]=t,e[4]=c):c=e[4];let m=c,p;e[5]!==n?(p=n!==null&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"auth-config-error",role:"alert",children:n}),e[5]=n,e[6]=p):p=e[6];let f;e[7]!==l||e[8]!==n||e[9]!==t?(f=n===null&&l===void 0&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"auth-config-loading",children:t("Loading auth configuration\u2026")}),e[7]=l,e[8]=n,e[9]=t,e[10]=f):f=e[10];let x;e[11]!==l||e[12]!==n||e[13]!==m||e[14]!==t?(x=n===null&&l!==void 0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(g,{heading:t("Enabled capabilities"),testId:"auth-config-capabilities",children:(0,a.jsx)("ul",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:z.map(s=>{let P=l.capabilities[s.key];return(0,a.jsxs)("li",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs","data-testid":`auth-config-cap-${s.key}`,children:[(0,a.jsx)("span",{className:"text-sm",children:t(s.label)}),m(P)]},s.key)})})}),(0,a.jsx)(g,{heading:t("Plugins"),testId:"auth-config-plugins",children:l.plugins.length===0?(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:t("No plugins enabled.")}):(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:l.plugins.map(L)})}),(0,a.jsx)(g,{heading:t("Sign-in methods"),testId:"auth-config-signin",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(o,{label:t("Email & password"),value:m(l.emailAndPassword)}),(0,a.jsx)(o,{label:t("Social providers"),value:l.socialProviders.length===0?t("None"):(0,a.jsx)("span",{className:"flex flex-wrap justify-end gap-1",children:l.socialProviders.map(q)})})]})}),l.organization.enabled&&(0,a.jsx)(g,{heading:t("Organizations"),testId:"auth-config-org",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(o,{label:t("Teams"),value:m(l.organization.teams)}),(0,a.jsx)(o,{label:t("Custom roles"),value:m(l.organization.roles)})]})}),(0,a.jsx)(g,{heading:t("Session policy"),testId:"auth-config-session",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(o,{label:t("Expires in"),value:v(l.session.expiresIn)}),(0,a.jsx)(o,{label:t("Refresh after"),value:v(l.session.updateAge)}),(0,a.jsx)(o,{label:t("Fresh window"),value:v(l.session.freshAge)}),(0,a.jsx)(o,{label:t("Cookie cache"),value:m(l.session.cookieCache===!0)})]})}),(0,a.jsx)(g,{heading:t("Rate limit"),testId:"auth-config-ratelimit",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(o,{label:t("Status"),value:m(l.rateLimit.enabled)}),l.rateLimit.enabled&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o,{label:t("Max requests"),value:l.rateLimit.max??"\u2014"}),(0,a.jsx)(o,{label:t("Window"),value:v(l.rateLimit.window)})]})]})}),l.userFields.length>0&&(0,a.jsx)(g,{heading:t("Plugin user fields"),testId:"auth-config-user-fields",children:(0,a.jsx)("ul",{className:"flex flex-col gap-2",children:l.userFields.map(s=>(0,a.jsxs)("li",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs","data-testid":`auth-config-user-field-${s.name}`,children:[(0,a.jsxs)("span",{className:"flex flex-col",children:[(0,a.jsx)("span",{className:"font-mono text-xs",children:s.name}),s.plugin!==void 0&&(0,a.jsx)("span",{className:"text-[11px] text-muted-foreground",children:s.plugin})]}),(0,a.jsxs)("span",{className:"flex items-center gap-1",children:[(0,a.jsx)(h,{variant:"outline",children:s.type}),s.required&&(0,a.jsx)(h,{variant:"secondary",children:t("required")}),s.unique&&(0,a.jsx)(h,{variant:"secondary",children:t("unique")})]})]},s.name))})}),(0,a.jsx)(y,{className:"gap-0 py-0",children:(0,a.jsx)("p",{className:"px-4 py-3 text-xs text-muted-foreground","data-testid":"auth-config-note",children:t("OAuth providers, email templates, and rate limits are configured at deploy time in the better-auth setup and aren't editable here. See the Mail tab for email output.")})})]}),e[11]=l,e[12]=n,e[13]=m,e[14]=t,e[15]=x):x=e[15];let b;return e[16]!==p||e[17]!==f||e[18]!==x?(b=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"auth-config",children:[p,f,x]}),e[16]=p,e[17]=f,e[18]=x,e[19]=b):b=e[19],b},"M");function L(e){return(0,a.jsx)(h,{"data-testid":`auth-config-plugin-${e}`,variant:"outline",children:e},e)}u(L,"P");function q(e){return(0,a.jsx)(h,{"data-testid":`auth-config-provider-${e}`,variant:"outline",children:e},e)}u(q,"z");export{T as AuthConfigPanel};
@@ -1 +1 @@
1
- import{a as We,b as qe,c as De,d as Oe,e as be}from"./chunk-OY2RVUZL.js";import"./chunk-2PJNAWB3.js";import{a as Re}from"./chunk-U6TNNM5U.js";import{a as Ve}from"./chunk-CTNB2KIA.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import"./chunk-RQ7AFLIV.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import{a as ze}from"./chunk-LFKCLLPT.js";import"./chunk-T6VMSOBB.js";import"./chunk-QLQADHFE.js";import{c as _e}from"./chunk-XDAT7LHC.js";import{a as Le,b as je,c as Fe,d as pe,e as q,f as R}from"./chunk-MIQTKZAR.js";import{a as Me,e as Ae}from"./chunk-UZERI5YC.js";import"./chunk-QBWRC5YX.js";import{a as Ke}from"./chunk-X665E2HU.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as ke}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as ne}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as me}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as D}from"./chunk-2WOIRKEI.js";import{f as Ne}from"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{a as Ce}from"./chunk-XQCVZAGU.js";import{d as ue,f as oe,g as we,h as Ee,m as de,q as Te}from"./chunk-OG4N2XHD.js";import{a as Ie,b as $e}from"./chunk-AADILRJW.js";import{a as o,e as ye,f as Be,g as Ge,h as He}from"./chunk-3XIESWL4.js";var ge=ye(Ge(),1);var O=ye(Be(),1);var t=ye(He(),1);var Se="none",Pe=["all","open","resolved","ignored"],Je=["critical","high","medium","low"],Qe=oe(D.resolveIssue),Xe=oe(D.ignoreIssue),Ue=oe(D.assignIssue),Ye=oe(D.setIssueSeverity),Ze=oe(D.explainIssue),es=o(n=>Array.isArray(n?.issues)?n.issues:[],"Xe"),ss=o(n=>n==="resolved"?"success":n==="ignored"?"secondary":"warning","Ye"),ts=o(n=>n==="critical"?"destructive":n==="high"?"warning":n==="medium"?"info":"secondary","Ze"),as=o(n=>{let e=(0,ge.c)(44),{expanded:d,issue:s,shardKey:$}=n,i=Ne(),r=ue(),[a,C]=(0,O.useState)(void 0),{busy:E,error:T,run:F}=Re(),_;e[0]!==i||e[1]!==s||e[2]!==F||e[3]!==$?(_=o(()=>{C(void 0),F(async()=>{let f={culprit:s.culprit,sampleMessage:s.sampleMessage,title:s.title},I=await i.query(Ze,f,we($));C(I)})},"E"),e[0]=i,e[1]=s,e[2]=F,e[3]=$,e[4]=_):_=e[4];let K=_;if(!d)return null;let h;if(e[5]!==s.sampleMessage){let f=$e(s.sampleMessage);h=f===void 0?void 0:Ie(f.body),e[5]=s.sampleMessage,e[6]=h}else h=e[6];let M=h,z=`issues-detail-${s.hash}`,c;e[7]!==s.sampleMessage?(c=(0,t.jsx)("p",{className:"whitespace-pre-wrap font-mono text-xs text-muted-foreground",children:s.sampleMessage}),e[7]=s.sampleMessage,e[8]=c):c=e[8];let x;e[9]!==r?(x=r("Suggested fix"),e[9]=r,e[10]=x):x=e[10];let y;e[11]!==x?(y=(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:x}),e[11]=x,e[12]=y):y=e[12];let w;e[13]!==M||e[14]!==s.hash||e[15]!==r?(w=M===void 0?(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground","data-testid":`issues-hint-empty-${s.hash}`,children:r("No known fix for this error yet.")}):(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm","data-testid":`issues-hint-${s.hash}`,children:M}),e[13]=M,e[14]=s.hash,e[15]=r,e[16]=w):w=e[16];let u;e[17]!==y||e[18]!==w?(u=(0,t.jsxs)("div",{children:[y,w]}),e[17]=y,e[18]=w,e[19]=u):u=e[19];let A=`issues-explain-${s.hash}`,m;e[20]!==E||e[21]!==r?(m=r(E?"Explaining\u2026":"Explain in plain language"),e[20]=E,e[21]=r,e[22]=m):m=e[22];let b;e[23]!==E||e[24]!==K||e[25]!==m||e[26]!==A?(b=(0,t.jsx)("div",{children:(0,t.jsx)(ne,{"data-testid":A,disabled:E,onClick:K,size:"sm",type:"button",variant:"outline",children:m})}),e[23]=E,e[24]=K,e[25]=m,e[26]=A,e[27]=b):b=e[27];let p;e[28]!==T||e[29]!==s.hash?(p=T!==null&&(0,t.jsx)("p",{className:"text-xs text-destructive","data-testid":`issues-explain-error-${s.hash}`,role:"alert",children:T}),e[28]=T,e[29]=s.hash,e[30]=p):p=e[30];let v;e[31]!==a||e[32]!==s.hash||e[33]!==r?(v=a!==void 0&&(a.degraded?(0,t.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":`issues-degraded-${s.hash}`,children:a.reason==="no-ai-binding"?r("No AI binding is configured. Wire an AI binding to enable plain-language explanations \u2014 the suggested fix above is always available."):r("The AI model could not explain this error right now. The suggested fix above still applies.")}):(0,t.jsxs)("div",{"data-testid":`issues-explanation-${s.hash}`,children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:r("AI explanation")}),(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm",children:a.explanation}),a.groundedId===void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground","data-testid":`issues-ungrounded-${s.hash}`,children:r("No catalog fix matched this error, so this explanation is the model's own reading of the message. Verify before acting on it.")}),(0,t.jsx)("p",{className:"mt-1 text-[0.7rem] text-muted-foreground",children:r("Generated by {model}",{model:a.model})})]})),e[31]=a,e[32]=s.hash,e[33]=r,e[34]=v):v=e[34];let g;e[35]!==b||e[36]!==p||e[37]!==v||e[38]!==c||e[39]!==u?(g=(0,t.jsx)(R,{className:"bg-muted/30",colSpan:7,children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 py-1",children:[c,u,b,p,v]})}),e[35]=b,e[36]=p,e[37]=v,e[38]=c,e[39]=u,e[40]=g):g=e[40];let S;return e[41]!==g||e[42]!==z?(S=(0,t.jsx)(pe,{"data-testid":z,children:g}),e[41]=g,e[42]=z,e[43]=S):S=e[43],S},"et"),is=o(n=>{let e=(0,ge.c)(119),{busy:d,issue:s,rowError:$,runTriage:i,shardKey:r}=n,a=ue(),[C,E]=(0,O.useState)(!1),T;e[0]===Symbol.for("react.memo_cache_sentinel")?(T=o(()=>{E(ls)},"_"),e[0]=T):T=e[0];let F=T,_;e[1]!==s.hash||e[2]!==i?(_=o(re=>{let ce=re===null||re===Se?null:re;de(i(s.hash,Ye,{severity:ce}))},"E"),e[1]=s.hash,e[2]=i,e[3]=_):_=e[3];let K=_,h;e[4]!==s.hash||e[5]!==i?(h=o(re=>{if(re.key!=="Enter")return;let ce=re.currentTarget.value.trim();de(i(s.hash,Ue,{assignee:ce===""?null:ce}))},"d"),e[4]=s.hash,e[5]=i,e[6]=h):h=e[6];let M=h,z=`issues-row-${s.hash}`,c;e[7]!==a?(c=a("Toggle issue details"),e[7]=a,e[8]=c):c=e[8];let x=`issues-toggle-${s.hash}`,y=`mt-1 size-3 shrink-0 text-muted-foreground transition-transform ${C?"rotate-90":""}`,w;e[9]===Symbol.for("react.memo_cache_sentinel")?(w=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[9]=w):w=e[9];let u;e[10]!==y?(u=(0,t.jsx)("svg",{"aria-hidden":"true",className:y,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:w}),e[10]=y,e[11]=u):u=e[11];let A;e[12]!==s.title?(A=(0,t.jsx)("span",{className:"block truncate font-medium",title:s.title,children:s.title}),e[12]=s.title,e[13]=A):A=e[13];let m;e[14]!==s.culprit?(m=(0,t.jsx)("span",{className:"block truncate font-mono text-xs text-muted-foreground",title:s.culprit,children:s.culprit}),e[14]=s.culprit,e[15]=m):m=e[15];let b;e[16]!==A||e[17]!==m?(b=(0,t.jsxs)("span",{className:"min-w-0",children:[A,m]}),e[16]=A,e[17]=m,e[18]=b):b=e[18];let p;e[19]!==C||e[20]!==b||e[21]!==c||e[22]!==x||e[23]!==u?(p=(0,t.jsxs)("button",{"aria-expanded":C,"aria-label":c,className:"flex w-full items-start gap-2 text-left","data-testid":x,onClick:F,type:"button",children:[u,b]}),e[19]=C,e[20]=b,e[21]=c,e[22]=x,e[23]=u,e[24]=p):p=e[24];let v;e[25]!==s.hash||e[26]!==$?(v=$!==void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-destructive","data-testid":`issues-action-error-${s.hash}`,role:"alert",children:$}),e[25]=s.hash,e[26]=$,e[27]=v):v=e[27];let g;e[28]!==p||e[29]!==v?(g=(0,t.jsxs)(R,{className:"max-w-80",children:[p,v]}),e[28]=p,e[29]=v,e[30]=g):g=e[30];let S=`issues-status-${s.hash}`,f;e[31]!==s.status?(f=ss(s.status),e[31]=s.status,e[32]=f):f=e[32];let I;e[33]!==s.status||e[34]!==S||e[35]!==f?(I=(0,t.jsx)(R,{children:(0,t.jsx)(me,{"data-testid":S,variant:f,children:s.status})}),e[33]=s.status,e[34]=S,e[35]=f,e[36]=I):I=e[36];let j=s.severity??Se,L;e[37]!==a?(L=a("Set severity"),e[37]=a,e[38]=L):L=e[38];let l=`issues-severity-${s.hash}`,V;e[39]!==a?(V=a("\u2014"),e[39]=a,e[40]=V):V=e[40];let W;e[41]!==s.severity||e[42]!==a?(W=s.severity===void 0?(0,t.jsx)("span",{className:"text-muted-foreground",children:a("\u2014")}):(0,t.jsx)(me,{variant:ts(s.severity),children:s.severity}),e[41]=s.severity,e[42]=a,e[43]=W):W=e[43];let N;e[44]!==V||e[45]!==W?(N=(0,t.jsx)(qe,{placeholder:V,children:W}),e[44]=V,e[45]=W,e[46]=N):N=e[46];let k;e[47]!==L||e[48]!==l||e[49]!==N?(k=(0,t.jsx)(De,{"aria-label":L,className:"h-7 w-[110px]","data-testid":l,children:N}),e[47]=L,e[48]=l,e[49]=N,e[50]=k):k=e[50];let U;e[51]===Symbol.for("react.memo_cache_sentinel")?(U=Je.map(rs),e[51]=U):U=e[51];let B;e[52]!==a?(B=a("Clear"),e[52]=a,e[53]=B):B=e[53];let G;e[54]!==B?(G=(0,t.jsxs)(Oe,{children:[U,(0,t.jsx)(be,{value:Se,children:B})]}),e[54]=B,e[55]=G):G=e[55];let H;e[56]!==d||e[57]!==K||e[58]!==j||e[59]!==k||e[60]!==G?(H=(0,t.jsx)(R,{children:(0,t.jsxs)(We,{disabled:d,onValueChange:K,value:j,children:[k,G]})}),e[56]=d,e[57]=K,e[58]=j,e[59]=k,e[60]=G,e[61]=H):H=e[61];let P;e[62]!==a?(P=a("Assignee"),e[62]=a,e[63]=P):P=e[63];let fe=`issues-assignee-${s.hash}`,xe=s.assignee??"",ve=s.assignee??"",J;e[64]!==a?(J=a("Unassigned"),e[64]=a,e[65]=J):J=e[65];let Q;e[66]!==d||e[67]!==M||e[68]!==P||e[69]!==fe||e[70]!==xe||e[71]!==ve||e[72]!==J?(Q=(0,t.jsx)(R,{children:(0,t.jsx)(ke,{"aria-label":P,className:"h-7 w-32","data-testid":fe,defaultValue:xe,disabled:d,onKeyDown:M,placeholder:J},ve)}),e[66]=d,e[67]=M,e[68]=P,e[69]=fe,e[70]=xe,e[71]=ve,e[72]=J,e[73]=Q):Q=e[73];let X;e[74]!==s.count?(X=(0,t.jsx)(R,{className:"text-right",children:(0,t.jsx)(me,{variant:"secondary",children:s.count})}),e[74]=s.count,e[75]=X):X=e[75];let Y;e[76]!==s.lastSeen?(Y=Te(s.lastSeen),e[76]=s.lastSeen,e[77]=Y):Y=e[77];let Z;e[78]!==Y?(Z=(0,t.jsx)(R,{className:"text-xs tabular-nums text-muted-foreground",children:Y}),e[78]=Y,e[79]=Z):Z=e[79];let ee;e[80]!==d||e[81]!==s.hash||e[82]!==s.status||e[83]!==i||e[84]!==a?(ee=s.status!=="resolved"&&(0,t.jsx)(ne,{"data-testid":`issues-resolve-${s.hash}`,disabled:d,onClick:o(()=>{de(i(s.hash,Qe,{}))},"onClick"),size:"xs",variant:"outline",children:a("Resolve")}),e[80]=d,e[81]=s.hash,e[82]=s.status,e[83]=i,e[84]=a,e[85]=ee):ee=e[85];let se;e[86]!==d||e[87]!==s.hash||e[88]!==s.status||e[89]!==i||e[90]!==a?(se=s.status!=="ignored"&&(0,t.jsx)(ne,{"data-testid":`issues-ignore-${s.hash}`,disabled:d,onClick:o(()=>{de(i(s.hash,Xe,{}))},"onClick"),size:"xs",variant:"ghost",children:a("Ignore")}),e[86]=d,e[87]=s.hash,e[88]=s.status,e[89]=i,e[90]=a,e[91]=se):se=e[91];let te;e[92]!==d||e[93]!==s.assignee||e[94]!==s.hash||e[95]!==s.status||e[96]!==i||e[97]!==a?(te=s.status!=="open"&&(0,t.jsx)(ne,{"data-testid":`issues-reopen-${s.hash}`,disabled:d,onClick:o(()=>{de(i(s.hash,Ue,{assignee:s.assignee??null}))},"onClick"),size:"xs",variant:"ghost",children:a("Reopen")}),e[92]=d,e[93]=s.assignee,e[94]=s.hash,e[95]=s.status,e[96]=i,e[97]=a,e[98]=te):te=e[98];let ae;e[99]!==ee||e[100]!==se||e[101]!==te?(ae=(0,t.jsx)(R,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1",children:[ee,se,te]})}),e[99]=ee,e[100]=se,e[101]=te,e[102]=ae):ae=e[102];let ie;e[103]!==g||e[104]!==I||e[105]!==H||e[106]!==Q||e[107]!==X||e[108]!==Z||e[109]!==z||e[110]!==ae?(ie=(0,t.jsxs)(pe,{"data-testid":z,children:[g,I,H,Q,X,Z,ae]}),e[103]=g,e[104]=I,e[105]=H,e[106]=Q,e[107]=X,e[108]=Z,e[109]=z,e[110]=ae,e[111]=ie):ie=e[111];let le;e[112]!==C||e[113]!==s||e[114]!==r?(le=(0,t.jsx)(as,{expanded:C,issue:s,shardKey:r},s.sampleMessage),e[112]=C,e[113]=s,e[114]=r,e[115]=le):le=e[115];let he;return e[116]!==ie||e[117]!==le?(he=(0,t.jsxs)(t.Fragment,{children:[ie,le]}),e[116]=ie,e[117]=le,e[118]=he):he=e[118],he},"tt"),ks=o(n=>{let e=(0,ge.c)(38),{initialShardKey:d}=n,s=ue(),$=Ne(),[i,r]=(0,O.useState)(d??""),[a,C]=(0,O.useState)("all"),[E,T]=(0,O.useState)(ns),[F,_]=(0,O.useState)(os),K;e[0]!==i?(K=i.trim(),e[0]=i,e[1]=K):K=e[1];let h=ze(K,400),M;e[2]!==a?(M=a==="all"?{}:{status:a},e[2]=a,e[3]=M):M=e[3];let z;e[4]!==h?(z={live:!0,shardKey:h},e[4]=h,e[5]=z):z=e[5];let{data:c,error:x,liveError:y}=_e(D.getIssues,M,z),w=c!==void 0,u;if(e[6]!==F||e[7]!==E||e[8]!==$||e[9]!==c||e[10]!==h||e[11]!==x||e[12]!==y||e[13]!==w||e[14]!==i||e[15]!==a||e[16]!==s){let A=es(c),m;e[18]!==$||e[19]!==h?(m=o(async(l,V,W)=>{_(N=>{if(!N.has(l))return N;let k=new Map(N);return k.delete(l),k}),T(N=>new Set(N).add(l));try{await $.query(V,{...W,hash:l},we(h))}catch(N){let k=Ee(N);_(U=>new Map(U).set(l,k))}T(N=>{let k=new Set(N);return k.delete(l),k})},"u"),e[18]=$,e[19]=h,e[20]=m):m=e[20];let b=m,p;e[21]!==s?(p=o(l=>s(l==="all"?"All":l==="open"?"Open":l==="resolved"?"Resolved":"Ignored"),"m"),e[21]=s,e[22]=p):p=e[22];let v=p,g;e[23]!==x?(g=x!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"issues-error",role:"alert",children:x}),e[23]=x,e[24]=g):g=e[24];let S;e[25]!==i?(S=(0,t.jsx)(Ke,{onChange:r,testId:"issues-shard-input",value:i}),e[25]=i,e[26]=S):S=e[26];let f;e[27]!==y?(f=(0,t.jsx)(Ve,{message:y,prefix:"issues"}),e[27]=y,e[28]=f):f=e[28];let I;e[29]!==a||e[30]!==v?(I=Pe.map(l=>(0,t.jsx)(ne,{"data-active":a===l?"":void 0,"data-testid":`issues-filter-${l}`,onClick:o(()=>{C(l)},"onClick"),size:"xs",variant:a===l?"default":"outline",children:v(l)},l)),e[29]=a,e[30]=v,e[31]=I):I=e[31];let j;e[32]!==I?(j=(0,t.jsx)("div",{className:"ms-auto flex items-center gap-1","data-testid":"issues-status-filter",role:"group",children:I}),e[32]=I,e[33]=j):j=e[33];let L;e[34]!==j||e[35]!==S||e[36]!==f?(L=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[S,f,j]}),e[34]=j,e[35]=S,e[36]=f,e[37]=L):L=e[37],u=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-issues-panel",children:[g,L,w&&A.length===0?(0,t.jsx)(Ce,{description:s("No grouped errors yet. When a function throws or a container crashes, matching errors fold into a single issue here."),testId:"issues-empty",title:s("No issues")}):(0,t.jsx)(Me,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ae,{className:"px-0",children:(0,t.jsxs)(Le,{"data-testid":"issues-table",children:[(0,t.jsx)(je,{children:(0,t.jsxs)(pe,{children:[(0,t.jsx)(q,{children:s("Issue")}),(0,t.jsx)(q,{children:s("Status")}),(0,t.jsx)(q,{children:s("Severity")}),(0,t.jsx)(q,{children:s("Assignee")}),(0,t.jsx)(q,{className:"text-right",children:s("Events")}),(0,t.jsx)(q,{children:s("Last seen")}),(0,t.jsx)(q,{className:"text-right",children:s("Actions")})]})}),(0,t.jsx)(Fe,{children:A.map(l=>(0,t.jsx)(is,{busy:E.has(l.hash),issue:l,rowError:F.get(l.hash),runTriage:b,shardKey:h},l.hash))})]})})})]}),e[6]=F,e[7]=E,e[8]=$,e[9]=c,e[10]=h,e[11]=x,e[12]=y,e[13]=w,e[14]=i,e[15]=a,e[16]=s,e[17]=u}else u=e[17];return u},"kt");function ls(n){return!n}o(ls,"st");function rs(n){return(0,t.jsx)(be,{value:n,children:n},n)}o(rs,"at");function ns(){return new Set}o(ns,"it");function os(){return new Map}o(os,"rt");export{ks as IssuesPanel};
1
+ import{a as We,b as qe,c as De,d as Oe,e as be}from"./chunk-UU2QJMGJ.js";import"./chunk-2PJNAWB3.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import{a as Re}from"./chunk-U6TNNM5U.js";import{a as Ve}from"./chunk-CTNB2KIA.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import{a as Ke}from"./chunk-X665E2HU.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{a as ze}from"./chunk-LFKCLLPT.js";import{R as ke}from"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{c as ne}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as me}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import"./chunk-QLQADHFE.js";import{a as D}from"./chunk-ERMTJYQF.js";import{c as _e}from"./chunk-XDAT7LHC.js";import{f as Ne}from"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{a as Ce}from"./chunk-XQCVZAGU.js";import{a as Le,b as je,c as Fe,d as pe,e as q,f as R}from"./chunk-MIQTKZAR.js";import{a as Me,e as Ae}from"./chunk-UZERI5YC.js";import{d as ue,f as oe,g as we,h as Ee,m as de,q as Te}from"./chunk-OG4N2XHD.js";import{a as Ie,b as $e}from"./chunk-AADILRJW.js";import{a as o,e as ye,f as Be,g as Ge,h as He}from"./chunk-3XIESWL4.js";var ge=ye(Ge(),1);var O=ye(Be(),1);var t=ye(He(),1);var Se="none",Pe=["all","open","resolved","ignored"],Je=["critical","high","medium","low"],Qe=oe(D.resolveIssue),Xe=oe(D.ignoreIssue),Ue=oe(D.assignIssue),Ye=oe(D.setIssueSeverity),Ze=oe(D.explainIssue),es=o(n=>Array.isArray(n?.issues)?n.issues:[],"Xe"),ss=o(n=>n==="resolved"?"success":n==="ignored"?"secondary":"warning","Ye"),ts=o(n=>n==="critical"?"destructive":n==="high"?"warning":n==="medium"?"info":"secondary","Ze"),as=o(n=>{let e=(0,ge.c)(44),{expanded:d,issue:s,shardKey:$}=n,i=Ne(),r=ue(),[a,C]=(0,O.useState)(void 0),{busy:E,error:T,run:F}=Re(),_;e[0]!==i||e[1]!==s||e[2]!==F||e[3]!==$?(_=o(()=>{C(void 0),F(async()=>{let f={culprit:s.culprit,sampleMessage:s.sampleMessage,title:s.title},I=await i.query(Ze,f,we($));C(I)})},"E"),e[0]=i,e[1]=s,e[2]=F,e[3]=$,e[4]=_):_=e[4];let K=_;if(!d)return null;let h;if(e[5]!==s.sampleMessage){let f=$e(s.sampleMessage);h=f===void 0?void 0:Ie(f.body),e[5]=s.sampleMessage,e[6]=h}else h=e[6];let M=h,z=`issues-detail-${s.hash}`,c;e[7]!==s.sampleMessage?(c=(0,t.jsx)("p",{className:"whitespace-pre-wrap font-mono text-xs text-muted-foreground",children:s.sampleMessage}),e[7]=s.sampleMessage,e[8]=c):c=e[8];let x;e[9]!==r?(x=r("Suggested fix"),e[9]=r,e[10]=x):x=e[10];let y;e[11]!==x?(y=(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:x}),e[11]=x,e[12]=y):y=e[12];let w;e[13]!==M||e[14]!==s.hash||e[15]!==r?(w=M===void 0?(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground","data-testid":`issues-hint-empty-${s.hash}`,children:r("No known fix for this error yet.")}):(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm","data-testid":`issues-hint-${s.hash}`,children:M}),e[13]=M,e[14]=s.hash,e[15]=r,e[16]=w):w=e[16];let u;e[17]!==y||e[18]!==w?(u=(0,t.jsxs)("div",{children:[y,w]}),e[17]=y,e[18]=w,e[19]=u):u=e[19];let A=`issues-explain-${s.hash}`,m;e[20]!==E||e[21]!==r?(m=r(E?"Explaining\u2026":"Explain in plain language"),e[20]=E,e[21]=r,e[22]=m):m=e[22];let b;e[23]!==E||e[24]!==K||e[25]!==m||e[26]!==A?(b=(0,t.jsx)("div",{children:(0,t.jsx)(ne,{"data-testid":A,disabled:E,onClick:K,size:"sm",type:"button",variant:"outline",children:m})}),e[23]=E,e[24]=K,e[25]=m,e[26]=A,e[27]=b):b=e[27];let p;e[28]!==T||e[29]!==s.hash?(p=T!==null&&(0,t.jsx)("p",{className:"text-xs text-destructive","data-testid":`issues-explain-error-${s.hash}`,role:"alert",children:T}),e[28]=T,e[29]=s.hash,e[30]=p):p=e[30];let v;e[31]!==a||e[32]!==s.hash||e[33]!==r?(v=a!==void 0&&(a.degraded?(0,t.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":`issues-degraded-${s.hash}`,children:a.reason==="no-ai-binding"?r("No AI binding is configured. Wire an AI binding to enable plain-language explanations \u2014 the suggested fix above is always available."):r("The AI model could not explain this error right now. The suggested fix above still applies.")}):(0,t.jsxs)("div",{"data-testid":`issues-explanation-${s.hash}`,children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:r("AI explanation")}),(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm",children:a.explanation}),a.groundedId===void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground","data-testid":`issues-ungrounded-${s.hash}`,children:r("No catalog fix matched this error, so this explanation is the model's own reading of the message. Verify before acting on it.")}),(0,t.jsx)("p",{className:"mt-1 text-[0.7rem] text-muted-foreground",children:r("Generated by {model}",{model:a.model})})]})),e[31]=a,e[32]=s.hash,e[33]=r,e[34]=v):v=e[34];let g;e[35]!==b||e[36]!==p||e[37]!==v||e[38]!==c||e[39]!==u?(g=(0,t.jsx)(R,{className:"bg-muted/30",colSpan:7,children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 py-1",children:[c,u,b,p,v]})}),e[35]=b,e[36]=p,e[37]=v,e[38]=c,e[39]=u,e[40]=g):g=e[40];let S;return e[41]!==g||e[42]!==z?(S=(0,t.jsx)(pe,{"data-testid":z,children:g}),e[41]=g,e[42]=z,e[43]=S):S=e[43],S},"et"),is=o(n=>{let e=(0,ge.c)(119),{busy:d,issue:s,rowError:$,runTriage:i,shardKey:r}=n,a=ue(),[C,E]=(0,O.useState)(!1),T;e[0]===Symbol.for("react.memo_cache_sentinel")?(T=o(()=>{E(ls)},"_"),e[0]=T):T=e[0];let F=T,_;e[1]!==s.hash||e[2]!==i?(_=o(re=>{let ce=re===null||re===Se?null:re;de(i(s.hash,Ye,{severity:ce}))},"E"),e[1]=s.hash,e[2]=i,e[3]=_):_=e[3];let K=_,h;e[4]!==s.hash||e[5]!==i?(h=o(re=>{if(re.key!=="Enter")return;let ce=re.currentTarget.value.trim();de(i(s.hash,Ue,{assignee:ce===""?null:ce}))},"d"),e[4]=s.hash,e[5]=i,e[6]=h):h=e[6];let M=h,z=`issues-row-${s.hash}`,c;e[7]!==a?(c=a("Toggle issue details"),e[7]=a,e[8]=c):c=e[8];let x=`issues-toggle-${s.hash}`,y=`mt-1 size-3 shrink-0 text-muted-foreground transition-transform ${C?"rotate-90":""}`,w;e[9]===Symbol.for("react.memo_cache_sentinel")?(w=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[9]=w):w=e[9];let u;e[10]!==y?(u=(0,t.jsx)("svg",{"aria-hidden":"true",className:y,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:w}),e[10]=y,e[11]=u):u=e[11];let A;e[12]!==s.title?(A=(0,t.jsx)("span",{className:"block truncate font-medium",title:s.title,children:s.title}),e[12]=s.title,e[13]=A):A=e[13];let m;e[14]!==s.culprit?(m=(0,t.jsx)("span",{className:"block truncate font-mono text-xs text-muted-foreground",title:s.culprit,children:s.culprit}),e[14]=s.culprit,e[15]=m):m=e[15];let b;e[16]!==A||e[17]!==m?(b=(0,t.jsxs)("span",{className:"min-w-0",children:[A,m]}),e[16]=A,e[17]=m,e[18]=b):b=e[18];let p;e[19]!==C||e[20]!==b||e[21]!==c||e[22]!==x||e[23]!==u?(p=(0,t.jsxs)("button",{"aria-expanded":C,"aria-label":c,className:"flex w-full items-start gap-2 text-left","data-testid":x,onClick:F,type:"button",children:[u,b]}),e[19]=C,e[20]=b,e[21]=c,e[22]=x,e[23]=u,e[24]=p):p=e[24];let v;e[25]!==s.hash||e[26]!==$?(v=$!==void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-destructive","data-testid":`issues-action-error-${s.hash}`,role:"alert",children:$}),e[25]=s.hash,e[26]=$,e[27]=v):v=e[27];let g;e[28]!==p||e[29]!==v?(g=(0,t.jsxs)(R,{className:"max-w-80",children:[p,v]}),e[28]=p,e[29]=v,e[30]=g):g=e[30];let S=`issues-status-${s.hash}`,f;e[31]!==s.status?(f=ss(s.status),e[31]=s.status,e[32]=f):f=e[32];let I;e[33]!==s.status||e[34]!==S||e[35]!==f?(I=(0,t.jsx)(R,{children:(0,t.jsx)(me,{"data-testid":S,variant:f,children:s.status})}),e[33]=s.status,e[34]=S,e[35]=f,e[36]=I):I=e[36];let j=s.severity??Se,L;e[37]!==a?(L=a("Set severity"),e[37]=a,e[38]=L):L=e[38];let l=`issues-severity-${s.hash}`,V;e[39]!==a?(V=a("\u2014"),e[39]=a,e[40]=V):V=e[40];let W;e[41]!==s.severity||e[42]!==a?(W=s.severity===void 0?(0,t.jsx)("span",{className:"text-muted-foreground",children:a("\u2014")}):(0,t.jsx)(me,{variant:ts(s.severity),children:s.severity}),e[41]=s.severity,e[42]=a,e[43]=W):W=e[43];let N;e[44]!==V||e[45]!==W?(N=(0,t.jsx)(qe,{placeholder:V,children:W}),e[44]=V,e[45]=W,e[46]=N):N=e[46];let k;e[47]!==L||e[48]!==l||e[49]!==N?(k=(0,t.jsx)(De,{"aria-label":L,className:"h-7 w-[110px]","data-testid":l,children:N}),e[47]=L,e[48]=l,e[49]=N,e[50]=k):k=e[50];let U;e[51]===Symbol.for("react.memo_cache_sentinel")?(U=Je.map(rs),e[51]=U):U=e[51];let B;e[52]!==a?(B=a("Clear"),e[52]=a,e[53]=B):B=e[53];let G;e[54]!==B?(G=(0,t.jsxs)(Oe,{children:[U,(0,t.jsx)(be,{value:Se,children:B})]}),e[54]=B,e[55]=G):G=e[55];let H;e[56]!==d||e[57]!==K||e[58]!==j||e[59]!==k||e[60]!==G?(H=(0,t.jsx)(R,{children:(0,t.jsxs)(We,{disabled:d,onValueChange:K,value:j,children:[k,G]})}),e[56]=d,e[57]=K,e[58]=j,e[59]=k,e[60]=G,e[61]=H):H=e[61];let P;e[62]!==a?(P=a("Assignee"),e[62]=a,e[63]=P):P=e[63];let fe=`issues-assignee-${s.hash}`,xe=s.assignee??"",ve=s.assignee??"",J;e[64]!==a?(J=a("Unassigned"),e[64]=a,e[65]=J):J=e[65];let Q;e[66]!==d||e[67]!==M||e[68]!==P||e[69]!==fe||e[70]!==xe||e[71]!==ve||e[72]!==J?(Q=(0,t.jsx)(R,{children:(0,t.jsx)(ke,{"aria-label":P,className:"h-7 w-32","data-testid":fe,defaultValue:xe,disabled:d,onKeyDown:M,placeholder:J},ve)}),e[66]=d,e[67]=M,e[68]=P,e[69]=fe,e[70]=xe,e[71]=ve,e[72]=J,e[73]=Q):Q=e[73];let X;e[74]!==s.count?(X=(0,t.jsx)(R,{className:"text-right",children:(0,t.jsx)(me,{variant:"secondary",children:s.count})}),e[74]=s.count,e[75]=X):X=e[75];let Y;e[76]!==s.lastSeen?(Y=Te(s.lastSeen),e[76]=s.lastSeen,e[77]=Y):Y=e[77];let Z;e[78]!==Y?(Z=(0,t.jsx)(R,{className:"text-xs tabular-nums text-muted-foreground",children:Y}),e[78]=Y,e[79]=Z):Z=e[79];let ee;e[80]!==d||e[81]!==s.hash||e[82]!==s.status||e[83]!==i||e[84]!==a?(ee=s.status!=="resolved"&&(0,t.jsx)(ne,{"data-testid":`issues-resolve-${s.hash}`,disabled:d,onClick:o(()=>{de(i(s.hash,Qe,{}))},"onClick"),size:"xs",variant:"outline",children:a("Resolve")}),e[80]=d,e[81]=s.hash,e[82]=s.status,e[83]=i,e[84]=a,e[85]=ee):ee=e[85];let se;e[86]!==d||e[87]!==s.hash||e[88]!==s.status||e[89]!==i||e[90]!==a?(se=s.status!=="ignored"&&(0,t.jsx)(ne,{"data-testid":`issues-ignore-${s.hash}`,disabled:d,onClick:o(()=>{de(i(s.hash,Xe,{}))},"onClick"),size:"xs",variant:"ghost",children:a("Ignore")}),e[86]=d,e[87]=s.hash,e[88]=s.status,e[89]=i,e[90]=a,e[91]=se):se=e[91];let te;e[92]!==d||e[93]!==s.assignee||e[94]!==s.hash||e[95]!==s.status||e[96]!==i||e[97]!==a?(te=s.status!=="open"&&(0,t.jsx)(ne,{"data-testid":`issues-reopen-${s.hash}`,disabled:d,onClick:o(()=>{de(i(s.hash,Ue,{assignee:s.assignee??null}))},"onClick"),size:"xs",variant:"ghost",children:a("Reopen")}),e[92]=d,e[93]=s.assignee,e[94]=s.hash,e[95]=s.status,e[96]=i,e[97]=a,e[98]=te):te=e[98];let ae;e[99]!==ee||e[100]!==se||e[101]!==te?(ae=(0,t.jsx)(R,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1",children:[ee,se,te]})}),e[99]=ee,e[100]=se,e[101]=te,e[102]=ae):ae=e[102];let ie;e[103]!==g||e[104]!==I||e[105]!==H||e[106]!==Q||e[107]!==X||e[108]!==Z||e[109]!==z||e[110]!==ae?(ie=(0,t.jsxs)(pe,{"data-testid":z,children:[g,I,H,Q,X,Z,ae]}),e[103]=g,e[104]=I,e[105]=H,e[106]=Q,e[107]=X,e[108]=Z,e[109]=z,e[110]=ae,e[111]=ie):ie=e[111];let le;e[112]!==C||e[113]!==s||e[114]!==r?(le=(0,t.jsx)(as,{expanded:C,issue:s,shardKey:r},s.sampleMessage),e[112]=C,e[113]=s,e[114]=r,e[115]=le):le=e[115];let he;return e[116]!==ie||e[117]!==le?(he=(0,t.jsxs)(t.Fragment,{children:[ie,le]}),e[116]=ie,e[117]=le,e[118]=he):he=e[118],he},"tt"),ks=o(n=>{let e=(0,ge.c)(38),{initialShardKey:d}=n,s=ue(),$=Ne(),[i,r]=(0,O.useState)(d??""),[a,C]=(0,O.useState)("all"),[E,T]=(0,O.useState)(ns),[F,_]=(0,O.useState)(os),K;e[0]!==i?(K=i.trim(),e[0]=i,e[1]=K):K=e[1];let h=ze(K,400),M;e[2]!==a?(M=a==="all"?{}:{status:a},e[2]=a,e[3]=M):M=e[3];let z;e[4]!==h?(z={live:!0,shardKey:h},e[4]=h,e[5]=z):z=e[5];let{data:c,error:x,liveError:y}=_e(D.getIssues,M,z),w=c!==void 0,u;if(e[6]!==F||e[7]!==E||e[8]!==$||e[9]!==c||e[10]!==h||e[11]!==x||e[12]!==y||e[13]!==w||e[14]!==i||e[15]!==a||e[16]!==s){let A=es(c),m;e[18]!==$||e[19]!==h?(m=o(async(l,V,W)=>{_(N=>{if(!N.has(l))return N;let k=new Map(N);return k.delete(l),k}),T(N=>new Set(N).add(l));try{await $.query(V,{...W,hash:l},we(h))}catch(N){let k=Ee(N);_(U=>new Map(U).set(l,k))}T(N=>{let k=new Set(N);return k.delete(l),k})},"u"),e[18]=$,e[19]=h,e[20]=m):m=e[20];let b=m,p;e[21]!==s?(p=o(l=>s(l==="all"?"All":l==="open"?"Open":l==="resolved"?"Resolved":"Ignored"),"m"),e[21]=s,e[22]=p):p=e[22];let v=p,g;e[23]!==x?(g=x!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"issues-error",role:"alert",children:x}),e[23]=x,e[24]=g):g=e[24];let S;e[25]!==i?(S=(0,t.jsx)(Ke,{onChange:r,testId:"issues-shard-input",value:i}),e[25]=i,e[26]=S):S=e[26];let f;e[27]!==y?(f=(0,t.jsx)(Ve,{message:y,prefix:"issues"}),e[27]=y,e[28]=f):f=e[28];let I;e[29]!==a||e[30]!==v?(I=Pe.map(l=>(0,t.jsx)(ne,{"data-active":a===l?"":void 0,"data-testid":`issues-filter-${l}`,onClick:o(()=>{C(l)},"onClick"),size:"xs",variant:a===l?"default":"outline",children:v(l)},l)),e[29]=a,e[30]=v,e[31]=I):I=e[31];let j;e[32]!==I?(j=(0,t.jsx)("div",{className:"ms-auto flex items-center gap-1","data-testid":"issues-status-filter",role:"group",children:I}),e[32]=I,e[33]=j):j=e[33];let L;e[34]!==j||e[35]!==S||e[36]!==f?(L=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[S,f,j]}),e[34]=j,e[35]=S,e[36]=f,e[37]=L):L=e[37],u=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-issues-panel",children:[g,L,w&&A.length===0?(0,t.jsx)(Ce,{description:s("No grouped errors yet. When a function throws or a container crashes, matching errors fold into a single issue here."),testId:"issues-empty",title:s("No issues")}):(0,t.jsx)(Me,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ae,{className:"px-0",children:(0,t.jsxs)(Le,{"data-testid":"issues-table",children:[(0,t.jsx)(je,{children:(0,t.jsxs)(pe,{children:[(0,t.jsx)(q,{children:s("Issue")}),(0,t.jsx)(q,{children:s("Status")}),(0,t.jsx)(q,{children:s("Severity")}),(0,t.jsx)(q,{children:s("Assignee")}),(0,t.jsx)(q,{className:"text-right",children:s("Events")}),(0,t.jsx)(q,{children:s("Last seen")}),(0,t.jsx)(q,{className:"text-right",children:s("Actions")})]})}),(0,t.jsx)(Fe,{children:A.map(l=>(0,t.jsx)(is,{busy:E.has(l.hash),issue:l,rowError:F.get(l.hash),runTriage:b,shardKey:h},l.hash))})]})})})]}),e[6]=F,e[7]=E,e[8]=$,e[9]=c,e[10]=h,e[11]=x,e[12]=y,e[13]=w,e[14]=i,e[15]=a,e[16]=s,e[17]=u}else u=e[17];return u},"kt");function ls(n){return!n}o(ls,"st");function rs(n){return(0,t.jsx)(be,{value:n,children:n},n)}o(rs,"at");function ns(){return new Set}o(ns,"it");function os(){return new Map}o(os,"rt");export{ks as IssuesPanel};
@@ -1 +1 @@
1
- import{a as q,b as L,c as B,d as f,e as c,f as d}from"./chunk-MIQTKZAR.js";import{a as I,e as j}from"./chunk-UZERI5YC.js";import{R as Q}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as W}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{f as F}from"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{a as Z}from"./chunk-XQCVZAGU.js";import{d as K,h as S,l as $,m as V}from"./chunk-OG4N2XHD.js";import"./chunk-AADILRJW.js";import{a as h,e as C,f as R,g as P,h as U}from"./chunk-3XIESWL4.js";var A=C(P(),1);var n=C(R(),1);var e=C(U(),1);var X=10,g=h(v=>{let l=(0,A.c)(7),{label:m,value:a}=v,r;l[0]!==m?(r=(0,e.jsx)("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:m}),l[0]=m,l[1]=r):r=l[1];let p=a??"\u2014",s;l[2]!==p?(s=(0,e.jsx)("span",{className:"font-mono text-sm",children:p}),l[2]=p,l[3]=s):s=l[3];let u;return l[4]!==r||l[5]!==s?(u=(0,e.jsxs)("div",{className:"flex flex-col gap-0.5",children:[r,s]}),l[4]=r,l[5]=s,l[6]=u):u=l[6],u},"g"),se=h(({loadIndexes:v,runQuery:l}={})=>{let m=F(),a=K(),[r,p]=(0,n.useState)(null),[s,u]=(0,n.useState)(null),[N,E]=(0,n.useState)(null),[b,D]=(0,n.useState)(""),[x,y]=(0,n.useState)(null),[M,w]=(0,n.useState)(null),[T,z]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let t={cancelled:!1};return V((async()=>{try{let i=await(v??(()=>m.listVectorIndexes()))();t.cancelled||(p(i),u(null),E(k=>k??i[0]?.name??null))}catch(i){t.cancelled||(p(null),u(S(i)))}})()),()=>{t.cancelled=!0}},[m,v]);let o=r?.find(t=>t.name===N)??null,G=h(t=>{E(t.currentTarget.dataset.index??null),y(null),w(null)},"K"),H=h(t=>{D(t.target.value)},"T"),J=h(async()=>{let t=b.trim();if(!(N===null||t==="")){z(!0),w(null);try{let i=await(l??(k=>m.queryVectorIndex(k)))({name:N,text:t,topK:X});y(i)}catch(i){y(null),w(S(i))}z(!1)}},"Z"),O=h(()=>{V(J())},"z");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-vector-browser",children:[s!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"vector-error",role:"alert",children:s}),r!==null&&r.length===0&&(0,e.jsx)(Z,{description:a("Indexes declared with .vectorize() or defineVectorIndex() appear 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:"M4 7l8-4 8 4-8 4-8-4Zm0 5 8 4 8-4M4 17l8 4 8-4"})}),testId:"vector-empty",title:a("No vector indexes.")}),r!==null&&r.length>0&&(0,e.jsx)(I,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(q,{"data-testid":"vector-table",children:[(0,e.jsx)(L,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(c,{children:a("name")}),(0,e.jsx)(c,{children:a("table")}),(0,e.jsx)(c,{children:a("dimensions")}),(0,e.jsx)(c,{children:a("metric")}),(0,e.jsx)(c,{children:a("vectors")})]})}),(0,e.jsx)(B,{children:r.map(t=>(0,e.jsxs)(f,{className:t.name===N?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-index":t.name,"data-testid":`vector-row-${t.name}`,onClick:G,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:t.name}),(0,e.jsx)(d,{className:"font-mono text-xs",children:t.table}),(0,e.jsx)(d,{className:"tabular-nums",children:t.dimensions??"\u2014"}),(0,e.jsx)(d,{children:t.metric??"\u2014"}),(0,e.jsx)(d,{className:"tabular-nums",children:t.vectorsCount??"\u2014"})]},t.name))})]})})}),o!==null&&(0,e.jsxs)("section",{className:"border border-border bg-card p-3","data-testid":"vector-detail",children:[(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[(0,e.jsx)(g,{label:a("field"),value:o.field}),(0,e.jsx)(g,{label:a("dimensions"),value:o.dimensions}),(0,e.jsx)(g,{label:a("metric"),value:o.metric}),(0,e.jsx)(g,{label:a("vectors"),value:o.vectorsCount})]}),o.metadata!==void 0&&o.metadata.length>0&&(0,e.jsxs)("p",{className:"mt-3 text-xs text-muted-foreground","data-testid":"vector-metadata",children:[a("metadata"),": ",(0,e.jsx)("span",{className:"font-mono",children:o.metadata.join(", ")})]}),(0,e.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,e.jsx)(Q,{className:"min-w-[18rem] flex-1","data-testid":"vector-query-input",onChange:H,placeholder:a("Search by similarity\u2026"),value:b}),(0,e.jsx)(W,{"data-testid":"vector-search",disabled:T||b.trim()==="",onClick:O,children:a(T?"Searching\u2026":"Search")})]}),M!==null&&(0,e.jsx)("p",{className:"mt-2 text-sm text-destructive","data-testid":"vector-query-error",role:"alert",children:M}),x!==null&&x.length===0&&(0,e.jsx)("p",{className:"mt-2 text-sm text-muted-foreground","data-testid":"vector-no-matches",children:a("No matches.")}),x!==null&&x.length>0&&(0,e.jsx)(I,{className:"mt-3 overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(q,{"data-testid":"vector-matches",children:[(0,e.jsx)(L,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(c,{children:a("id")}),(0,e.jsx)(c,{children:a("score")}),(0,e.jsx)(c,{children:a("metadata")})]})}),(0,e.jsx)(B,{children:x.map(t=>(0,e.jsxs)(f,{"data-testid":`vector-match-${t.id}`,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:t.id}),(0,e.jsx)(d,{className:"tabular-nums",children:t.score.toFixed(4)}),(0,e.jsx)(d,{className:"max-w-md truncate font-mono text-xs",children:t.metadata===void 0?"\u2014":$(t.metadata)})]},t.id))})]})})})]})]})},"ce");export{se as VectorBrowser};
1
+ import{R as Q}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as W}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{f as F}from"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{a as Z}from"./chunk-XQCVZAGU.js";import{a as q,b as L,c as B,d as f,e as c,f as d}from"./chunk-MIQTKZAR.js";import{a as I,e as j}from"./chunk-UZERI5YC.js";import{d as K,h as S,l as $,m as V}from"./chunk-OG4N2XHD.js";import"./chunk-AADILRJW.js";import{a as h,e as C,f as R,g as P,h as U}from"./chunk-3XIESWL4.js";var A=C(P(),1);var n=C(R(),1);var e=C(U(),1);var X=10,g=h(v=>{let l=(0,A.c)(7),{label:m,value:a}=v,r;l[0]!==m?(r=(0,e.jsx)("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:m}),l[0]=m,l[1]=r):r=l[1];let p=a??"\u2014",s;l[2]!==p?(s=(0,e.jsx)("span",{className:"font-mono text-sm",children:p}),l[2]=p,l[3]=s):s=l[3];let u;return l[4]!==r||l[5]!==s?(u=(0,e.jsxs)("div",{className:"flex flex-col gap-0.5",children:[r,s]}),l[4]=r,l[5]=s,l[6]=u):u=l[6],u},"g"),se=h(({loadIndexes:v,runQuery:l}={})=>{let m=F(),a=K(),[r,p]=(0,n.useState)(null),[s,u]=(0,n.useState)(null),[N,E]=(0,n.useState)(null),[b,D]=(0,n.useState)(""),[x,y]=(0,n.useState)(null),[M,w]=(0,n.useState)(null),[T,z]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let t={cancelled:!1};return V((async()=>{try{let i=await(v??(()=>m.listVectorIndexes()))();t.cancelled||(p(i),u(null),E(k=>k??i[0]?.name??null))}catch(i){t.cancelled||(p(null),u(S(i)))}})()),()=>{t.cancelled=!0}},[m,v]);let o=r?.find(t=>t.name===N)??null,G=h(t=>{E(t.currentTarget.dataset.index??null),y(null),w(null)},"K"),H=h(t=>{D(t.target.value)},"T"),J=h(async()=>{let t=b.trim();if(!(N===null||t==="")){z(!0),w(null);try{let i=await(l??(k=>m.queryVectorIndex(k)))({name:N,text:t,topK:X});y(i)}catch(i){y(null),w(S(i))}z(!1)}},"Z"),O=h(()=>{V(J())},"z");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-vector-browser",children:[s!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"vector-error",role:"alert",children:s}),r!==null&&r.length===0&&(0,e.jsx)(Z,{description:a("Indexes declared with .vectorize() or defineVectorIndex() appear 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:"M4 7l8-4 8 4-8 4-8-4Zm0 5 8 4 8-4M4 17l8 4 8-4"})}),testId:"vector-empty",title:a("No vector indexes.")}),r!==null&&r.length>0&&(0,e.jsx)(I,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(q,{"data-testid":"vector-table",children:[(0,e.jsx)(L,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(c,{children:a("name")}),(0,e.jsx)(c,{children:a("table")}),(0,e.jsx)(c,{children:a("dimensions")}),(0,e.jsx)(c,{children:a("metric")}),(0,e.jsx)(c,{children:a("vectors")})]})}),(0,e.jsx)(B,{children:r.map(t=>(0,e.jsxs)(f,{className:t.name===N?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-index":t.name,"data-testid":`vector-row-${t.name}`,onClick:G,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:t.name}),(0,e.jsx)(d,{className:"font-mono text-xs",children:t.table}),(0,e.jsx)(d,{className:"tabular-nums",children:t.dimensions??"\u2014"}),(0,e.jsx)(d,{children:t.metric??"\u2014"}),(0,e.jsx)(d,{className:"tabular-nums",children:t.vectorsCount??"\u2014"})]},t.name))})]})})}),o!==null&&(0,e.jsxs)("section",{className:"border border-border bg-card p-3","data-testid":"vector-detail",children:[(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[(0,e.jsx)(g,{label:a("field"),value:o.field}),(0,e.jsx)(g,{label:a("dimensions"),value:o.dimensions}),(0,e.jsx)(g,{label:a("metric"),value:o.metric}),(0,e.jsx)(g,{label:a("vectors"),value:o.vectorsCount})]}),o.metadata!==void 0&&o.metadata.length>0&&(0,e.jsxs)("p",{className:"mt-3 text-xs text-muted-foreground","data-testid":"vector-metadata",children:[a("metadata"),": ",(0,e.jsx)("span",{className:"font-mono",children:o.metadata.join(", ")})]}),(0,e.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,e.jsx)(Q,{className:"min-w-[18rem] flex-1","data-testid":"vector-query-input",onChange:H,placeholder:a("Search by similarity\u2026"),value:b}),(0,e.jsx)(W,{"data-testid":"vector-search",disabled:T||b.trim()==="",onClick:O,children:a(T?"Searching\u2026":"Search")})]}),M!==null&&(0,e.jsx)("p",{className:"mt-2 text-sm text-destructive","data-testid":"vector-query-error",role:"alert",children:M}),x!==null&&x.length===0&&(0,e.jsx)("p",{className:"mt-2 text-sm text-muted-foreground","data-testid":"vector-no-matches",children:a("No matches.")}),x!==null&&x.length>0&&(0,e.jsx)(I,{className:"mt-3 overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(q,{"data-testid":"vector-matches",children:[(0,e.jsx)(L,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(c,{children:a("id")}),(0,e.jsx)(c,{children:a("score")}),(0,e.jsx)(c,{children:a("metadata")})]})}),(0,e.jsx)(B,{children:x.map(t=>(0,e.jsxs)(f,{"data-testid":`vector-match-${t.id}`,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:t.id}),(0,e.jsx)(d,{className:"tabular-nums",children:t.score.toFixed(4)}),(0,e.jsx)(d,{className:"max-w-md truncate font-mono text-xs",children:t.metadata===void 0?"\u2014":$(t.metadata)})]},t.id))})]})})})]})]})},"ce");export{se as VectorBrowser};