@lunora/studio 1.0.0-alpha.345 → 1.0.0-alpha.347

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 (69) hide show
  1. package/dist/standalone/{chunk-DNIDQC3K.js → chunk-2PMCHTCC.js} +1 -1
  2. package/dist/standalone/{chunk-YNJEO3WB.js → chunk-34OJ2OXP.js} +1 -1
  3. package/dist/standalone/{chunk-3F3742NV.js → chunk-3FWAGIOT.js} +1 -1
  4. package/dist/standalone/chunk-3I25WO3P.js +15 -0
  5. package/dist/standalone/{chunk-5QTTNVDW.js → chunk-4GHCKQLY.js} +1 -1
  6. package/dist/standalone/{chunk-SQ4ZU5YB.js → chunk-4HYPC5NN.js} +1 -1
  7. package/dist/standalone/{chunk-EYTZURBK.js → chunk-4TYCTORB.js} +1 -1
  8. package/dist/standalone/{chunk-4RLRI34N.js → chunk-5TQHZVNN.js} +1 -1
  9. package/dist/standalone/{chunk-AD7FLIUQ.js → chunk-5YLFS5NU.js} +1 -1
  10. package/dist/standalone/{chunk-TFLKMZK5.js → chunk-6BELLPMP.js} +1 -1
  11. package/dist/standalone/{chunk-EJSTZM7A.js → chunk-6FZLAL4W.js} +1 -1
  12. package/dist/standalone/{chunk-GXRBCKNP.js → chunk-6I2QO7SE.js} +1 -1
  13. package/dist/standalone/{chunk-CUIPEXIW.js → chunk-6TJHYXQW.js} +1 -1
  14. package/dist/standalone/{chunk-SRNH27XV.js → chunk-6XPDVZVB.js} +1 -1
  15. package/dist/standalone/{chunk-A4WUN5R3.js → chunk-ATVMUIBN.js} +1 -1
  16. package/dist/standalone/{chunk-RGDSRUIX.js → chunk-AVSMQPR3.js} +3 -3
  17. package/dist/standalone/{chunk-JAPCIIQC.js → chunk-B57UZJ6W.js} +1 -1
  18. package/dist/standalone/{chunk-DD7J6RMR.js → chunk-BOMFGCKX.js} +1 -1
  19. package/dist/standalone/{chunk-EUTV2OGD.js → chunk-C7SAXSO3.js} +1 -1
  20. package/dist/standalone/{chunk-WXMYNIXK.js → chunk-CCTWURT3.js} +1 -1
  21. package/dist/standalone/{chunk-PBQ5ZONR.js → chunk-DJ3BKVAZ.js} +1 -1
  22. package/dist/standalone/{chunk-5X7LJ6UT.js → chunk-E4Y6TF6C.js} +1 -1
  23. package/dist/standalone/{chunk-ZUB5DMJT.js → chunk-EFGDGZHN.js} +1 -1
  24. package/dist/standalone/{chunk-66MXYZBW.js → chunk-EGYPW6UY.js} +1 -1
  25. package/dist/standalone/{chunk-3BF2QRJM.js → chunk-EPI4SHLN.js} +1 -1
  26. package/dist/standalone/{chunk-FMSWGAHK.js → chunk-FTN4XJOQ.js} +1 -1
  27. package/dist/standalone/{chunk-YYEQLN53.js → chunk-GDP3S4GQ.js} +1 -1
  28. package/dist/standalone/{chunk-3XYWAO26.js → chunk-H6FW2TMO.js} +1 -1
  29. package/dist/standalone/{chunk-N36IWCKG.js → chunk-IIU4TZRG.js} +1 -1
  30. package/dist/standalone/{chunk-QMJTL4SW.js → chunk-IQ3SMVFW.js} +1 -1
  31. package/dist/standalone/{chunk-G5P5DUVD.js → chunk-JD6SCY7V.js} +1 -1
  32. package/dist/standalone/{chunk-NJ3YQOVN.js → chunk-JGUKFZ3R.js} +1 -1
  33. package/dist/standalone/{chunk-S7XJPD6Z.js → chunk-JLQPIE3Z.js} +2 -2
  34. package/dist/standalone/{chunk-KLQVRXER.js → chunk-KEHDC5BQ.js} +1 -1
  35. package/dist/standalone/{chunk-D6CNULEI.js → chunk-KNUGID7F.js} +1 -1
  36. package/dist/standalone/{chunk-L7OWZOME.js → chunk-L4BDA4VZ.js} +1 -1
  37. package/dist/standalone/{chunk-IDX6KQRG.js → chunk-LI2GRPOB.js} +1 -1
  38. package/dist/standalone/{chunk-RGCYH5VO.js → chunk-M7HCYBJJ.js} +1 -1
  39. package/dist/standalone/{chunk-GTEER76O.js → chunk-MFZF7GEM.js} +1 -1
  40. package/dist/standalone/{chunk-ATVJ7XYZ.js → chunk-MT4E42PB.js} +1 -1
  41. package/dist/standalone/{chunk-5DKOUMFY.js → chunk-N45O7D5G.js} +1 -1
  42. package/dist/standalone/{chunk-XUS6E3C7.js → chunk-NARRSYMQ.js} +1 -1
  43. package/dist/standalone/{chunk-NQZMPZNU.js → chunk-PQ6DUCKC.js} +1 -1
  44. package/dist/standalone/{chunk-WZ2CXW4B.js → chunk-PTIKIQY6.js} +1 -1
  45. package/dist/standalone/{chunk-Y5PZGFRZ.js → chunk-QDHFLZ3N.js} +1 -1
  46. package/dist/standalone/{chunk-DQAXICZV.js → chunk-R37RA67H.js} +1 -1
  47. package/dist/standalone/{chunk-E57JT34T.js → chunk-R457VG7L.js} +1 -1
  48. package/dist/standalone/{chunk-SMZHXNCR.js → chunk-R75AFV7G.js} +1 -1
  49. package/dist/standalone/{chunk-42DNLDTQ.js → chunk-RLVR5BRF.js} +1 -1
  50. package/dist/standalone/{chunk-HXC2I6YI.js → chunk-RTWSDGPV.js} +1 -1
  51. package/dist/standalone/{chunk-EITTEB6M.js → chunk-SJYQFABZ.js} +1 -1
  52. package/dist/standalone/{chunk-VVHORMP3.js → chunk-SQYX2Z5H.js} +1 -1
  53. package/dist/standalone/{chunk-DFVQBXUZ.js → chunk-T2JHVL34.js} +1 -1
  54. package/dist/standalone/{chunk-3BCMZMOX.js → chunk-TET2ESOI.js} +1 -1
  55. package/dist/standalone/{chunk-5CW7W7LQ.js → chunk-TNPF3XGI.js} +1 -1
  56. package/dist/standalone/{chunk-IC2NNXPZ.js → chunk-TVSU6RYZ.js} +1 -1
  57. package/dist/standalone/{chunk-YR5YXUZT.js → chunk-U7KUGVBB.js} +1 -1
  58. package/dist/standalone/{chunk-SMN2PVWA.js → chunk-V7IFSDTT.js} +1 -1
  59. package/dist/standalone/{chunk-SPLVBIFP.js → chunk-WQW4IPHB.js} +1 -1
  60. package/dist/standalone/{chunk-GWCMBJ2U.js → chunk-WW7D5RFR.js} +1 -1
  61. package/dist/standalone/{chunk-6ZRYMZEX.js → chunk-XCVO3IAH.js} +1 -1
  62. package/dist/standalone/{chunk-QNAKWBFW.js → chunk-XCWVO6DI.js} +1 -1
  63. package/dist/standalone/{chunk-NRJJBPJY.js → chunk-XEGAP64U.js} +1 -1
  64. package/dist/standalone/{chunk-UMPQDFU6.js → chunk-XJPJSZ4W.js} +1 -1
  65. package/dist/standalone/{chunk-SFMWHWJG.js → chunk-XR2JH2A7.js} +1 -1
  66. package/dist/standalone/{chunk-PAYY63FN.js → chunk-XWGORWQU.js} +1 -1
  67. package/dist/standalone/studio.js +1 -1
  68. package/package.json +5 -5
  69. package/dist/standalone/chunk-35Q6XYRL.js +0 -15
@@ -1 +1 @@
1
- import{a as H}from"./chunk-VQRCJJXS.js";import"./chunk-PSMQQV6S.js";import{a as F}from"./chunk-EYTZURBK.js";import{a as I}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import"./chunk-BOMPSVRC.js";import{b as $}from"./chunk-DFVQBXUZ.js";import{l as S}from"./chunk-RGDSRUIX.js";import"./chunk-QAQDMS6R.js";import"./chunk-35Q6XYRL.js";import{a as B}from"./chunk-RWVIV3U7.js";import{a as L,b as O,c as E,d as k,e as l,f as n}from"./chunk-HCTJKP5J.js";import{a as j,e as z}from"./chunk-2IKDEUCX.js";import{d as C,q as R,u as T}from"./chunk-74IYYDDI.js";import{a as f,d as y,e as D,f as G,g as J}from"./chunk-I26MS5PJ.js";var P=y(G(),1);var Q=y(D(),1);var s=y(J(),1);var w=200,se=f(()=>{let e=(0,P.c)(28),d=S(),a=C(),[r,q]=(0,Q.useState)(0),p;e[0]!==r?(p=["lunora-auth-sessions",w,r],e[0]=r,e[1]=p):p=e[1];let x;e[2]!==d||e[3]!==r?(x=f(()=>d.listAuthSessions({limit:w,offset:r}),"p"),e[2]=d,e[3]=r,e[4]=x):x=e[4];let o=$(p,x),{error:g}=o,t=o.data?.rows??null,N;e[5]!==o?(N=f(()=>o.poll(),"b"),e[5]=o,e[6]=N):N=e[6],F(N,!0);let v;e[7]!==d||e[8]!==o?(v=f(i=>{R((async()=>{await d.revokeAuthSession({sessionId:i}),o.refetch()})())},"g"),e[7]=d,e[8]=o,e[9]=v):v=e[9];let b=v,m;e[10]!==g?(m=g!==null&&(0,s.jsx)("p",{className:"text-sm text-destructive","data-testid":"auth-sessions-error",role:"alert",children:g}),e[10]=g,e[11]=m):m=e[11];let c;e[12]!==t||e[13]!==a?(c=t!==null&&t.length===0&&(0,s.jsx)(B,{testId:"auth-sessions-empty",title:a("No active sessions.")}),e[12]=t,e[13]=a,e[14]=c):c=e[14];let h;e[15]!==b||e[16]!==t||e[17]!==a?(h=t!==null&&t.length>0&&(0,s.jsx)(j,{className:"overflow-hidden py-0",children:(0,s.jsx)(z,{className:"px-0",children:(0,s.jsxs)(L,{"data-testid":"auth-sessions-table",children:[(0,s.jsx)(O,{children:(0,s.jsxs)(k,{children:[(0,s.jsx)(l,{children:a("user")}),(0,s.jsx)(l,{children:a("expires")}),(0,s.jsx)(l,{children:a("ip")}),(0,s.jsx)(l,{children:a("user agent")}),(0,s.jsx)(l,{children:a("impersonated by")}),(0,s.jsx)(l,{"aria-label":a("Actions")})]})}),(0,s.jsx)(E,{children:t.map(i=>(0,s.jsxs)(k,{"data-testid":`auth-session-${i.id}`,children:[(0,s.jsx)(n,{className:"font-mono text-xs",children:i.userId}),(0,s.jsx)(n,{className:"text-muted-foreground tabular-nums",children:T(i.expiresAt)}),(0,s.jsx)(n,{children:i.ipAddress??""}),(0,s.jsx)(n,{className:"max-w-40 truncate",children:i.userAgent??""}),(0,s.jsx)(n,{className:"font-mono text-xs",children:i.impersonatedBy??""}),(0,s.jsx)(n,{children:(0,s.jsx)(I,{"data-testid":`auth-session-revoke-${i.id}`,onClick:f(()=>{b(i.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Revoke")})})]},i.id))})]})})}),e[15]=b,e[16]=t,e[17]=a,e[18]=h):h=e[18];let u;e[19]!==r||e[20]!==t||e[21]!==o.data?.total?(u=t!==null&&(0,s.jsx)(H,{count:t.length,offset:r,onOffsetChange:q,pageSize:w,prefix:"auth-sessions",total:o.data?.total}),e[19]=r,e[20]=t,e[21]=o.data?.total,e[22]=u):u=e[22];let A;return e[23]!==m||e[24]!==c||e[25]!==h||e[26]!==u?(A=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"auth-sessions",children:[m,c,h,u]}),e[23]=m,e[24]=c,e[25]=h,e[26]=u,e[27]=A):A=e[27],A},"ee");export{se as default};
1
+ import{a as H}from"./chunk-VQRCJJXS.js";import"./chunk-PSMQQV6S.js";import{a as F}from"./chunk-4TYCTORB.js";import{a as I}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import"./chunk-BOMPSVRC.js";import{b as $}from"./chunk-T2JHVL34.js";import{l as S}from"./chunk-AVSMQPR3.js";import"./chunk-QAQDMS6R.js";import"./chunk-3I25WO3P.js";import{a as B}from"./chunk-RWVIV3U7.js";import{a as L,b as O,c as E,d as k,e as l,f as n}from"./chunk-HCTJKP5J.js";import{a as j,e as z}from"./chunk-2IKDEUCX.js";import{d as C,q as R,u as T}from"./chunk-74IYYDDI.js";import{a as f,d as y,e as D,f as G,g as J}from"./chunk-I26MS5PJ.js";var P=y(G(),1);var Q=y(D(),1);var s=y(J(),1);var w=200,se=f(()=>{let e=(0,P.c)(28),d=S(),a=C(),[r,q]=(0,Q.useState)(0),p;e[0]!==r?(p=["lunora-auth-sessions",w,r],e[0]=r,e[1]=p):p=e[1];let x;e[2]!==d||e[3]!==r?(x=f(()=>d.listAuthSessions({limit:w,offset:r}),"p"),e[2]=d,e[3]=r,e[4]=x):x=e[4];let o=$(p,x),{error:g}=o,t=o.data?.rows??null,N;e[5]!==o?(N=f(()=>o.poll(),"b"),e[5]=o,e[6]=N):N=e[6],F(N,!0);let v;e[7]!==d||e[8]!==o?(v=f(i=>{R((async()=>{await d.revokeAuthSession({sessionId:i}),o.refetch()})())},"g"),e[7]=d,e[8]=o,e[9]=v):v=e[9];let b=v,m;e[10]!==g?(m=g!==null&&(0,s.jsx)("p",{className:"text-sm text-destructive","data-testid":"auth-sessions-error",role:"alert",children:g}),e[10]=g,e[11]=m):m=e[11];let c;e[12]!==t||e[13]!==a?(c=t!==null&&t.length===0&&(0,s.jsx)(B,{testId:"auth-sessions-empty",title:a("No active sessions.")}),e[12]=t,e[13]=a,e[14]=c):c=e[14];let h;e[15]!==b||e[16]!==t||e[17]!==a?(h=t!==null&&t.length>0&&(0,s.jsx)(j,{className:"overflow-hidden py-0",children:(0,s.jsx)(z,{className:"px-0",children:(0,s.jsxs)(L,{"data-testid":"auth-sessions-table",children:[(0,s.jsx)(O,{children:(0,s.jsxs)(k,{children:[(0,s.jsx)(l,{children:a("user")}),(0,s.jsx)(l,{children:a("expires")}),(0,s.jsx)(l,{children:a("ip")}),(0,s.jsx)(l,{children:a("user agent")}),(0,s.jsx)(l,{children:a("impersonated by")}),(0,s.jsx)(l,{"aria-label":a("Actions")})]})}),(0,s.jsx)(E,{children:t.map(i=>(0,s.jsxs)(k,{"data-testid":`auth-session-${i.id}`,children:[(0,s.jsx)(n,{className:"font-mono text-xs",children:i.userId}),(0,s.jsx)(n,{className:"text-muted-foreground tabular-nums",children:T(i.expiresAt)}),(0,s.jsx)(n,{children:i.ipAddress??""}),(0,s.jsx)(n,{className:"max-w-40 truncate",children:i.userAgent??""}),(0,s.jsx)(n,{className:"font-mono text-xs",children:i.impersonatedBy??""}),(0,s.jsx)(n,{children:(0,s.jsx)(I,{"data-testid":`auth-session-revoke-${i.id}`,onClick:f(()=>{b(i.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Revoke")})})]},i.id))})]})})}),e[15]=b,e[16]=t,e[17]=a,e[18]=h):h=e[18];let u;e[19]!==r||e[20]!==t||e[21]!==o.data?.total?(u=t!==null&&(0,s.jsx)(H,{count:t.length,offset:r,onOffsetChange:q,pageSize:w,prefix:"auth-sessions",total:o.data?.total}),e[19]=r,e[20]=t,e[21]=o.data?.total,e[22]=u):u=e[22];let A;return e[23]!==m||e[24]!==c||e[25]!==h||e[26]!==u?(A=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"auth-sessions",children:[m,c,h,u]}),e[23]=m,e[24]=c,e[25]=h,e[26]=u,e[27]=A):A=e[27],A},"ee");export{se as default};
@@ -1 +1 @@
1
- import{a as D}from"./chunk-EYTZURBK.js";import{a as k}from"./chunk-S7XJPD6Z.js";import"./chunk-FUYEZFBP.js";import"./chunk-OQ6I6OXT.js";import"./chunk-SJQERRSZ.js";import"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as N}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as B}from"./chunk-SMZHXNCR.js";import"./chunk-NCPW7WHO.js";import"./chunk-QMJTL4SW.js";import"./chunk-55UGUCQ6.js";import{a as u}from"./chunk-4ZEL6BYL.js";import{c as p}from"./chunk-DFVQBXUZ.js";import{e as R}from"./chunk-RGDSRUIX.js";import"./chunk-QAQDMS6R.js";import"./chunk-35Q6XYRL.js";import{a as S}from"./chunk-RWVIV3U7.js";import{a as A,b as C,c as P,d as b,e as l,f as n}from"./chunk-HCTJKP5J.js";import{a as v,e as w}from"./chunk-2IKDEUCX.js";import{d as j,u as I}from"./chunk-74IYYDDI.js";import{a as m,d as H,g as Q}from"./chunk-I26MS5PJ.js";var e=H(Q(),1);var _="payment_subscriptions",O="payment_events",V=[_,O],Y={},E=new Set(["active","trialing"]),z=new Set(["past_due","unpaid"]),s=m((a,t)=>{if(a[t]!==void 0)return a[t];let h=a.__doc__;return typeof h=="string"?R(h)?.[t]:void 0},"a"),o=m(a=>typeof a=="string"?a:typeof a=="number"||typeof a=="bigint"||typeof a=="boolean"?String(a):"","s"),J=m(a=>E.has(a)?"default":z.has(a)?"destructive":"outline","q"),ie=m(({limit:a=100})=>{let t=j(),h=k(),{data:x}=p(u.listTables,Y,{live:!0}),F=x!==void 0,L=Array.isArray(x)&&V.every(r=>x.some(d=>d.name===r)),c=h.payments&&L,i=p(u.readTablePage,{filters:[],limit:a,offset:0,orderBy:{column:"updatedAt",direction:"desc"},search:"",table:_},{enabled:c}),f=p(u.readTablePage,{filters:[],limit:25,offset:0,orderBy:{column:"processedAt",direction:"desc"},search:"",table:O},{enabled:c}),g=p(u.facetColumn,{column:"state",table:_},{enabled:c});D(()=>{if(c)return Promise.all([i.poll(),f.poll(),g.poll()])},!0);let y=i.data?.rows??[],M=f.data?.rows??[],U=i.error??f.error,q=i.error===null?f.errorSource:i.errorSource,G=i.data?.total??y.length,T=g.data?.values===void 0?y.filter(r=>E.has(o(s(r,"state")))).length:g.data.values.reduce((r,d)=>r+(E.has(o(d.value))?d.count:0),0);return F&&!c?(0,e.jsx)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:(0,e.jsx)(S,{description:t("No @lunora/payment tables found in this deployment. Add `.extend(paymentExtension)` to lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions."),testId:"payments-unconfigured",title:t("No payments configured")})}):(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[(0,e.jsx)("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:(0,e.jsxs)(v,{className:"justify-between gap-0 py-0",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Subscriptions")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:T}),(0,e.jsx)(N,{variant:"default",children:t("{count} active",{count:T})})]})]}),(0,e.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:t("{total} total",{total:G})})]})}),U===null?void 0:(0,e.jsx)(B,{error:q}),y.length===0&&!i.isLoading?(0,e.jsx)(S,{testId:"payments-empty",title:t("No subscriptions yet")}):(0,e.jsx)(v,{className:"overflow-hidden py-0",children:(0,e.jsx)(w,{className:"px-0",children:(0,e.jsxs)(A,{children:[(0,e.jsx)(C,{children:(0,e.jsxs)(b,{children:[(0,e.jsx)(l,{children:t("Provider")}),(0,e.jsx)(l,{children:t("Reference")}),(0,e.jsx)(l,{children:t("Plan")}),(0,e.jsx)(l,{children:t("State")}),(0,e.jsx)(l,{children:t("Renews")})]})}),(0,e.jsx)(P,{children:y.map(r=>{let d=o(s(r,"state"));return(0,e.jsxs)(b,{"data-testid":"payment-subscription-row",children:[(0,e.jsx)(n,{children:o(s(r,"provider"))}),(0,e.jsx)(n,{children:o(s(r,"referenceId"))}),(0,e.jsx)(n,{children:o(s(r,"priceId"))}),(0,e.jsx)(n,{children:(0,e.jsx)(N,{variant:J(d),children:d})}),(0,e.jsx)(n,{children:I(s(r,"currentPeriodEnd"))})]},o(s(r,"providerSubscriptionId")))})})]})})}),(0,e.jsxs)(v,{className:"overflow-hidden py-0",children:[(0,e.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Recent webhook events")})}),(0,e.jsx)(w,{className:"px-0",children:(0,e.jsx)(A,{children:(0,e.jsx)(P,{children:M.map(r=>(0,e.jsxs)(b,{"data-testid":"payment-event-row",children:[(0,e.jsx)(n,{children:o(s(r,"provider"))}),(0,e.jsx)(n,{className:"font-medium",children:o(s(r,"type"))}),(0,e.jsx)(n,{className:"text-muted-foreground",children:o(s(r,"providerEventId"))}),(0,e.jsx)(n,{children:I(s(r,"processedAt"))})]},o(s(r,"providerEventId"))))})})})]})]})},"oe");export{ie as PaymentsPanel};
1
+ import{a as D}from"./chunk-4TYCTORB.js";import{a as k}from"./chunk-JLQPIE3Z.js";import"./chunk-FUYEZFBP.js";import"./chunk-OQ6I6OXT.js";import"./chunk-SJQERRSZ.js";import"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as N}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as B}from"./chunk-R75AFV7G.js";import"./chunk-NCPW7WHO.js";import"./chunk-IQ3SMVFW.js";import"./chunk-55UGUCQ6.js";import{a as u}from"./chunk-4ZEL6BYL.js";import{c as p}from"./chunk-T2JHVL34.js";import{e as R}from"./chunk-AVSMQPR3.js";import"./chunk-QAQDMS6R.js";import"./chunk-3I25WO3P.js";import{a as S}from"./chunk-RWVIV3U7.js";import{a as A,b as C,c as P,d as b,e as l,f as n}from"./chunk-HCTJKP5J.js";import{a as v,e as w}from"./chunk-2IKDEUCX.js";import{d as j,u as I}from"./chunk-74IYYDDI.js";import{a as m,d as H,g as Q}from"./chunk-I26MS5PJ.js";var e=H(Q(),1);var _="payment_subscriptions",O="payment_events",V=[_,O],Y={},E=new Set(["active","trialing"]),z=new Set(["past_due","unpaid"]),s=m((a,t)=>{if(a[t]!==void 0)return a[t];let h=a.__doc__;return typeof h=="string"?R(h)?.[t]:void 0},"a"),o=m(a=>typeof a=="string"?a:typeof a=="number"||typeof a=="bigint"||typeof a=="boolean"?String(a):"","s"),J=m(a=>E.has(a)?"default":z.has(a)?"destructive":"outline","q"),ie=m(({limit:a=100})=>{let t=j(),h=k(),{data:x}=p(u.listTables,Y,{live:!0}),F=x!==void 0,L=Array.isArray(x)&&V.every(r=>x.some(d=>d.name===r)),c=h.payments&&L,i=p(u.readTablePage,{filters:[],limit:a,offset:0,orderBy:{column:"updatedAt",direction:"desc"},search:"",table:_},{enabled:c}),f=p(u.readTablePage,{filters:[],limit:25,offset:0,orderBy:{column:"processedAt",direction:"desc"},search:"",table:O},{enabled:c}),g=p(u.facetColumn,{column:"state",table:_},{enabled:c});D(()=>{if(c)return Promise.all([i.poll(),f.poll(),g.poll()])},!0);let y=i.data?.rows??[],M=f.data?.rows??[],U=i.error??f.error,q=i.error===null?f.errorSource:i.errorSource,G=i.data?.total??y.length,T=g.data?.values===void 0?y.filter(r=>E.has(o(s(r,"state")))).length:g.data.values.reduce((r,d)=>r+(E.has(o(d.value))?d.count:0),0);return F&&!c?(0,e.jsx)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:(0,e.jsx)(S,{description:t("No @lunora/payment tables found in this deployment. Add `.extend(paymentExtension)` to lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions."),testId:"payments-unconfigured",title:t("No payments configured")})}):(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[(0,e.jsx)("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:(0,e.jsxs)(v,{className:"justify-between gap-0 py-0",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Subscriptions")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:T}),(0,e.jsx)(N,{variant:"default",children:t("{count} active",{count:T})})]})]}),(0,e.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:t("{total} total",{total:G})})]})}),U===null?void 0:(0,e.jsx)(B,{error:q}),y.length===0&&!i.isLoading?(0,e.jsx)(S,{testId:"payments-empty",title:t("No subscriptions yet")}):(0,e.jsx)(v,{className:"overflow-hidden py-0",children:(0,e.jsx)(w,{className:"px-0",children:(0,e.jsxs)(A,{children:[(0,e.jsx)(C,{children:(0,e.jsxs)(b,{children:[(0,e.jsx)(l,{children:t("Provider")}),(0,e.jsx)(l,{children:t("Reference")}),(0,e.jsx)(l,{children:t("Plan")}),(0,e.jsx)(l,{children:t("State")}),(0,e.jsx)(l,{children:t("Renews")})]})}),(0,e.jsx)(P,{children:y.map(r=>{let d=o(s(r,"state"));return(0,e.jsxs)(b,{"data-testid":"payment-subscription-row",children:[(0,e.jsx)(n,{children:o(s(r,"provider"))}),(0,e.jsx)(n,{children:o(s(r,"referenceId"))}),(0,e.jsx)(n,{children:o(s(r,"priceId"))}),(0,e.jsx)(n,{children:(0,e.jsx)(N,{variant:J(d),children:d})}),(0,e.jsx)(n,{children:I(s(r,"currentPeriodEnd"))})]},o(s(r,"providerSubscriptionId")))})})]})})}),(0,e.jsxs)(v,{className:"overflow-hidden py-0",children:[(0,e.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Recent webhook events")})}),(0,e.jsx)(w,{className:"px-0",children:(0,e.jsx)(A,{children:(0,e.jsx)(P,{children:M.map(r=>(0,e.jsxs)(b,{"data-testid":"payment-event-row",children:[(0,e.jsx)(n,{children:o(s(r,"provider"))}),(0,e.jsx)(n,{className:"font-medium",children:o(s(r,"type"))}),(0,e.jsx)(n,{className:"text-muted-foreground",children:o(s(r,"providerEventId"))}),(0,e.jsx)(n,{children:I(s(r,"processedAt"))})]},o(s(r,"providerEventId"))))})})})]})]})},"oe");export{ie as PaymentsPanel};
@@ -1 +1 @@
1
- import{b as me}from"./chunk-2I4NHEKA.js";import{a as $}from"./chunk-GWCMBJ2U.js";import{a as ue}from"./chunk-EWMBX5N2.js";import"./chunk-3BCMZMOX.js";import"./chunk-AUGKHAMQ.js";import"./chunk-WJRYEML4.js";import{a as de}from"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{b as P}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import"./chunk-55UGUCQ6.js";import{a as A}from"./chunk-4ZEL6BYL.js";import{c as ce}from"./chunk-DFVQBXUZ.js";import{l as ne,m as oe}from"./chunk-RGDSRUIX.js";import"./chunk-QAQDMS6R.js";import"./chunk-35Q6XYRL.js";import{a as C}from"./chunk-2IKDEUCX.js";import{d as D,f as I,g as Q,h as W,q as _,u as ie}from"./chunk-74IYYDDI.js";import{a as f,d as T,e as qe,f as ae,g as le,i as M}from"./chunk-I26MS5PJ.js";var Y=T(ae(),1);var h=T(qe(),1);var fe=T(ae(),1);var B=T(le(),1);var Me={connected:"bg-success",connecting:"bg-warning",idle:"bg-muted-foreground",offline:"bg-destructive",polling:"bg-warning"},he=f(()=>{let t=(0,fe.c)(18),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}case"polling":{let n;t[8]!==e?(n=e("Polling"),t[8]=e,t[9]=n):n=t[9],s=n;break e}default:s=a}let l=Me[a],c;t[10]!==l?(c=M("size-2 rounded-full",l),t[10]=l,t[11]=c):c=t[11];let i;t[12]!==c?(i=(0,B.jsx)("span",{"aria-hidden":"true",className:c}),t[12]=c,t[13]=i):i=t[13];let o;return t[14]!==a||t[15]!==i||t[16]!==s?(o=(0,B.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:[i,s]}),t[14]=a,t[15]=i,t[16]=s,t[17]=o):o=t[17],o},"T");var r=T(le(),1);var Ae={crit:"destructive",ok:"secondary",warn:"default"},U=f((t,e)=>e===0?"\u2014":`${(t/e*100).toFixed(1)}%`,"P"),X=f((t,e,a)=>Number.isNaN(t)?"ok":t>=a?"crit":t>=e?"warn":"ok","z"),xe=.01,ve=.05,je=f(t=>{let e=(0,Y.c)(36),{errorCount:a,logsError:s,topErrors:l,worstFunctions:c}=t,i=D(),o;e[0]!==i?(o=i("Functions by error rate"),e[0]=i,e[1]=o):o=e[1];let n;e[2]!==o?(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:o})}),e[2]=o,e[3]=n):n=e[3];let m;e[4]!==i||e[5]!==c?(m=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:i("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:i("{count} calls",{count:w.calls.toString()})}),(0,r.jsx)(P,{variant:Ae[X(w.errors/w.calls,xe,ve)],children:U(w.errors,w.calls)})]})]},w.path))}),e[4]=i,e[5]=c,e[6]=m):m=e[6];let p;e[7]!==n||e[8]!==m?(p=(0,r.jsxs)(C,{className:"gap-0 py-0","data-testid":"hl-functions",children:[n,m]}),e[7]=n,e[8]=m,e[9]=p):p=e[9];let v;e[10]!==i?(v=i("Recent errors"),e[10]=i,e[11]=v):v=e[11];let d;e[12]!==v?(d=(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v}),e[12]=v,e[13]=d):d=e[13];let u=a>0?"destructive":"outline",g;e[14]!==a||e[15]!==u?(g=(0,r.jsx)(P,{"data-testid":"hl-error-count",variant:u,children:a}),e[14]=a,e[15]=u,e[16]=g):g=e[16];let x;e[17]!==d||e[18]!==g?(x=(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[d,g]}),e[17]=d,e[18]=g,e[19]=x):x=e[19];let S;e[20]!==s?(S=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]=S):S=e[21];let E;e[22]!==s||e[23]!==i||e[24]!==l.length?(E=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:i("No recent errors.")}),e[22]=s,e[23]=i,e[24]=l.length,e[25]=E):E=e[25];let q;e[26]!==l?(q=l.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:l.map(Ce)}),e[26]=l,e[27]=q):q=e[27];let N;e[28]!==S||e[29]!==E||e[30]!==q||e[31]!==x?(N=(0,r.jsxs)(C,{className:"gap-0 py-0",children:[x,S,E,q]}),e[28]=S,e[29]=E,e[30]=q,e[31]=x,e[32]=N):N=e[32];let k;return e[33]!==N||e[34]!==p?(k=(0,r.jsxs)("div",{className:"grid gap-3 lg:grid-cols-2",children:[p,N]}),e[33]=N,e[34]=p,e[35]=k):k=e[35],k},"ye");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()}`)}f(Ce,"Te");var pe={completed:0,failed:2,in_progress:1},Ie=f(t=>{let e=0,a=0,s=0,l=0,c=!1,i=[];for(let{metrics:o}of t){if(o===null){l+=1;continue}s+=1,e+=o.requests,a+=o.errors,i.push(...o.history??[]),c||=o.historyTruncated===!0}return{errors:a,failed:l,history:i,historyTruncated:c,reachable:s,requests:e}},"Ae"),Te=f(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()]},"ke"),De=f(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=pe[s.status]-pe[l.status];(c>0||c===0&&(s.updatedAt??0)>(l.updatedAt??0))&&e.set(s.id,s)}return[...e.values()]},"Re"),Pe=I(A.getAuthMetrics),Fe=I(A.getFunctionStats),Le=I(A.getLogs),Re=I(A.getMetrics),ze=I(A.migrationStatus),Oe=5,ge=2e3,Ke=5,_e=.1,$e=.3,Be=1,He=50,Ue=f((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","Pe"),Ge=f(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)}},"Ge"),Ve=f(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}},"Ve"),Je=f((t,e)=>t.failed>0?e("{count} failed",{count:t.failed.toString()}):t.running>0?e("{count} running",{count:t.running.toString()}):e("OK"),"Be"),be={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},Ne={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},Qe={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},We=f(t=>t.includes("crit")?"crit":t.includes("warn")?"warn":"ok","Ke"),H=f(t=>{let e=(0,Y.c)(19),{chart:a,label:s,level:l,testId:c,value:i}=t,o=be[l],n;e[0]!==o?(n=M("size-1.5 shrink-0 rounded-full",o),e[0]=o,e[1]=n):n=e[1];let m;e[2]!==n?(m=(0,r.jsx)("span",{"aria-hidden":"true",className:n}),e[2]=n,e[3]=m):m=e[3];let p;e[4]!==s||e[5]!==m?(p=(0,r.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[m,s]}),e[4]=s,e[5]=m,e[6]=p):p=e[6];let v=Ne[l],d;e[7]!==v?(d=M("truncate text-2xl font-semibold tabular-nums",v),e[7]=v,e[8]=d):d=e[8];let u;e[9]!==d||e[10]!==c||e[11]!==i?(u=(0,r.jsx)("span",{className:d,"data-testid":c,children:i}),e[9]=d,e[10]=c,e[11]=i,e[12]=u):u=e[12];let g;e[13]!==a||e[14]!==u?(g=(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[u,a]}),e[13]=a,e[14]=u,e[15]=g):g=e[15];let x;return e[16]!==p||e[17]!==g?(x=(0,r.jsx)(C,{className:"gap-0 py-0",children:(0,r.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[p,g]})}),e[16]=p,e[17]=g,e[18]=x):x=e[18],x},"U"),Xe=f(async(t,e,a)=>{let s=await Promise.all(a.map(d=>{let u=Q(d);return Promise.allSettled([t.query(Re,{},u),t.query(Fe,{},u),t.query(ze,{},u)])})),l=Q(e),c=typeof t.schedulerStatus=="function"?t.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[i,o,n]=await Promise.allSettled([t.query(Le,{},l),t.query(Pe,{},l),c]),m=s.map(([d,u,g])=>({functions:u.status==="fulfilled"?u.value.functions:[],metrics:d.status==="fulfilled"?d.value:null,migrations:g.status==="fulfilled"?g.value.migrations:[]})),p=Ie(m),v=s[0]?.[0];return{auth:o.status==="fulfilled"?o.value:null,entries:i.status==="fulfilled"?i.value.entries:[],functions:Te(m.map(d=>d.functions)),logsError:i.status==="rejected"?W(i.reason):null,metricsError:p.reachable===0&&v?.status==="rejected"?W(v.reason):null,migrations:De(m.map(d=>d.migrations)),scheduler:n.status==="fulfilled"?n.value:null,totals:p}},"$e"),Ye=f(t=>{let e=t?.history??[];return{attempts:e.map(a=>a.attempts),failures:e.map(a=>a.failures)}},"ze"),xt=f(({initialShardKey:t})=>{let e=ne(),a=D(),[s,l]=(0,h.useState)([]),[c,i]=(0,h.useState)(null),[o,n]=(0,h.useState)(null),[m,p]=(0,h.useState)(null),[v,d]=(0,h.useState)([]),[u,g]=(0,h.useState)(null),[x,S]=(0,h.useState)(null),[E,q]=(0,h.useState)([]),[N]=(0,h.useState)(de),k=(0,h.useRef)(!1),w=(0,h.useRef)(0),G=(0,h.useRef)(0),j=(0,h.useRef)(null),F=t??"",L=(0,h.useCallback)(async()=>{if(k.current)return;k.current=!0;let b=w.current,y=await Xe(e,F,me(F,N));b===w.current&&(n(y.totals),p(y.metricsError),d(y.functions),q(y.migrations),l(y.entries),i(y.logsError),g(y.auth),S(y.scheduler),k.current=!1)},[e,N,F]);(0,h.useEffect)(()=>(_(L()),()=>{w.current+=1,k.current=!1,j.current!==null&&(clearTimeout(j.current),j.current=null)}),[L]);let ye=f(()=>{let b=Date.now()-G.current;if(b>=ge){G.current=Date.now(),_(L());return}j.current===null&&(j.current=setTimeout(()=>{j.current=null,G.current=Date.now(),_(L())},ge-b))},"ue"),{data:Z,liveError:we}=ce(A.getMetrics,{},{live:!0,shardKey:F});(0,h.useEffect)(()=>{Z!==void 0&&ye()},[Z]);let ee=s.filter(b=>b.level==="error"),ke=ee.slice(0,Oe),R=Ge(o?.history),te=Ye(u),Se=v.filter(b=>b.calls>0).toSorted((b,y)=>y.errors/y.calls-b.errors/b.calls||y.calls-b.calls).slice(0,Ke),V=Ve(E),Ee=o===null||o.requests===0?0:o.errors/o.requests,J=X(Ee,xe,ve),re=u===null?"ok":X(u.failureRate,_e,$e),se=x===null?"ok":Ue(x.backlog,Be,He),z=We([J,re,se,V.level]),O,K;return z==="crit"?(O=a("Critical"),K=a("One or more service levels are breached.")):z==="warn"?(O=a("Degraded"),K=a("Some service levels need attention.")):(O=a("All systems healthy"),K=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)(C,{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:M("flex size-10 shrink-0 items-center justify-center rounded-full",Qe[z]),children:(0,r.jsx)("span",{className:M("size-3 rounded-full",be[z])})}),(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:O}),(0,r.jsx)("span",{className:"text-[13px] text-muted-foreground",children:K})]})]}),(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:[R.requests.length>=2&&(0,r.jsx)($,{ariaLabel:a("Requests over time"),className:"h-6 w-20 text-foreground",series:R.requests,testId:"hl-spark-requests"}),(0,r.jsx)("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:(o?.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:M("text-lg font-semibold tabular-nums",Ne[J]),"data-testid":"hl-error-rate",children:o===null?"\u2014":U(o.errors,o.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)(he,{}),(0,r.jsx)(ue,{message:we,prefix:"hl"})]})]})]}),m!==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:m}),m===null&&o?.historyTruncated===!0&&(0,r.jsx)("div",{className:"border-t border-border bg-warning/5 px-4 py-2 text-sm text-muted-foreground","data-testid":"hl-history-truncated",children:a("Showing a partial request/error history \u2014 one or more shards have more data than the trend chart can display.")})]}),(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:R.errors.length>=2?(0,r.jsx)($,{ariaLabel:a("Errors over time"),className:"h-7 w-20 text-destructive",series:R.errors,testId:"hl-spark-errors"}):void 0,label:a("Error rate"),level:J,testId:"hl-slo-errorrate",value:o===null?"\u2014":U(o.errors,o.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:x===null?"\u2014":x.backlog.toString()}),(0,r.jsx)(H,{label:a("Migrations"),level:V.level,testId:"hl-slo-migrations",value:Je(V,a)})]}),(0,r.jsx)(je,{errorCount:ee.length,logsError:c,topErrors:ke,worstFunctions:Se}),(0,r.jsxs)(C,{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:N.length})]}),N.length>0&&(0,r.jsx)("ul",{className:"flex flex-wrap gap-1.5 p-4",children:N.map(b=>(0,r.jsx)("li",{"data-testid":"hl-shard",children:(0,r.jsx)(P,{variant:"secondary",children:b})},b))})]})]})},"ut");export{xt as HealthPanel};
1
+ import{b as me}from"./chunk-2I4NHEKA.js";import{a as $}from"./chunk-WW7D5RFR.js";import{a as ue}from"./chunk-EWMBX5N2.js";import"./chunk-TET2ESOI.js";import"./chunk-AUGKHAMQ.js";import"./chunk-WJRYEML4.js";import{a as de}from"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{b as P}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import"./chunk-55UGUCQ6.js";import{a as A}from"./chunk-4ZEL6BYL.js";import{c as ce}from"./chunk-T2JHVL34.js";import{l as ne,m as oe}from"./chunk-AVSMQPR3.js";import"./chunk-QAQDMS6R.js";import"./chunk-3I25WO3P.js";import{a as C}from"./chunk-2IKDEUCX.js";import{d as D,f as I,g as Q,h as W,q as _,u as ie}from"./chunk-74IYYDDI.js";import{a as f,d as T,e as qe,f as ae,g as le,i as M}from"./chunk-I26MS5PJ.js";var Y=T(ae(),1);var h=T(qe(),1);var fe=T(ae(),1);var B=T(le(),1);var Me={connected:"bg-success",connecting:"bg-warning",idle:"bg-muted-foreground",offline:"bg-destructive",polling:"bg-warning"},he=f(()=>{let t=(0,fe.c)(18),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}case"polling":{let n;t[8]!==e?(n=e("Polling"),t[8]=e,t[9]=n):n=t[9],s=n;break e}default:s=a}let l=Me[a],c;t[10]!==l?(c=M("size-2 rounded-full",l),t[10]=l,t[11]=c):c=t[11];let i;t[12]!==c?(i=(0,B.jsx)("span",{"aria-hidden":"true",className:c}),t[12]=c,t[13]=i):i=t[13];let o;return t[14]!==a||t[15]!==i||t[16]!==s?(o=(0,B.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:[i,s]}),t[14]=a,t[15]=i,t[16]=s,t[17]=o):o=t[17],o},"T");var r=T(le(),1);var Ae={crit:"destructive",ok:"secondary",warn:"default"},U=f((t,e)=>e===0?"\u2014":`${(t/e*100).toFixed(1)}%`,"P"),X=f((t,e,a)=>Number.isNaN(t)?"ok":t>=a?"crit":t>=e?"warn":"ok","z"),xe=.01,ve=.05,je=f(t=>{let e=(0,Y.c)(36),{errorCount:a,logsError:s,topErrors:l,worstFunctions:c}=t,i=D(),o;e[0]!==i?(o=i("Functions by error rate"),e[0]=i,e[1]=o):o=e[1];let n;e[2]!==o?(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:o})}),e[2]=o,e[3]=n):n=e[3];let m;e[4]!==i||e[5]!==c?(m=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:i("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:i("{count} calls",{count:w.calls.toString()})}),(0,r.jsx)(P,{variant:Ae[X(w.errors/w.calls,xe,ve)],children:U(w.errors,w.calls)})]})]},w.path))}),e[4]=i,e[5]=c,e[6]=m):m=e[6];let p;e[7]!==n||e[8]!==m?(p=(0,r.jsxs)(C,{className:"gap-0 py-0","data-testid":"hl-functions",children:[n,m]}),e[7]=n,e[8]=m,e[9]=p):p=e[9];let v;e[10]!==i?(v=i("Recent errors"),e[10]=i,e[11]=v):v=e[11];let d;e[12]!==v?(d=(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v}),e[12]=v,e[13]=d):d=e[13];let u=a>0?"destructive":"outline",g;e[14]!==a||e[15]!==u?(g=(0,r.jsx)(P,{"data-testid":"hl-error-count",variant:u,children:a}),e[14]=a,e[15]=u,e[16]=g):g=e[16];let x;e[17]!==d||e[18]!==g?(x=(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[d,g]}),e[17]=d,e[18]=g,e[19]=x):x=e[19];let S;e[20]!==s?(S=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]=S):S=e[21];let E;e[22]!==s||e[23]!==i||e[24]!==l.length?(E=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:i("No recent errors.")}),e[22]=s,e[23]=i,e[24]=l.length,e[25]=E):E=e[25];let q;e[26]!==l?(q=l.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:l.map(Ce)}),e[26]=l,e[27]=q):q=e[27];let N;e[28]!==S||e[29]!==E||e[30]!==q||e[31]!==x?(N=(0,r.jsxs)(C,{className:"gap-0 py-0",children:[x,S,E,q]}),e[28]=S,e[29]=E,e[30]=q,e[31]=x,e[32]=N):N=e[32];let k;return e[33]!==N||e[34]!==p?(k=(0,r.jsxs)("div",{className:"grid gap-3 lg:grid-cols-2",children:[p,N]}),e[33]=N,e[34]=p,e[35]=k):k=e[35],k},"ye");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()}`)}f(Ce,"Te");var pe={completed:0,failed:2,in_progress:1},Ie=f(t=>{let e=0,a=0,s=0,l=0,c=!1,i=[];for(let{metrics:o}of t){if(o===null){l+=1;continue}s+=1,e+=o.requests,a+=o.errors,i.push(...o.history??[]),c||=o.historyTruncated===!0}return{errors:a,failed:l,history:i,historyTruncated:c,reachable:s,requests:e}},"Ae"),Te=f(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()]},"ke"),De=f(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=pe[s.status]-pe[l.status];(c>0||c===0&&(s.updatedAt??0)>(l.updatedAt??0))&&e.set(s.id,s)}return[...e.values()]},"Re"),Pe=I(A.getAuthMetrics),Fe=I(A.getFunctionStats),Le=I(A.getLogs),Re=I(A.getMetrics),ze=I(A.migrationStatus),Oe=5,ge=2e3,Ke=5,_e=.1,$e=.3,Be=1,He=50,Ue=f((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","Pe"),Ge=f(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)}},"Ge"),Ve=f(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}},"Ve"),Je=f((t,e)=>t.failed>0?e("{count} failed",{count:t.failed.toString()}):t.running>0?e("{count} running",{count:t.running.toString()}):e("OK"),"Be"),be={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},Ne={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},Qe={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},We=f(t=>t.includes("crit")?"crit":t.includes("warn")?"warn":"ok","Ke"),H=f(t=>{let e=(0,Y.c)(19),{chart:a,label:s,level:l,testId:c,value:i}=t,o=be[l],n;e[0]!==o?(n=M("size-1.5 shrink-0 rounded-full",o),e[0]=o,e[1]=n):n=e[1];let m;e[2]!==n?(m=(0,r.jsx)("span",{"aria-hidden":"true",className:n}),e[2]=n,e[3]=m):m=e[3];let p;e[4]!==s||e[5]!==m?(p=(0,r.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[m,s]}),e[4]=s,e[5]=m,e[6]=p):p=e[6];let v=Ne[l],d;e[7]!==v?(d=M("truncate text-2xl font-semibold tabular-nums",v),e[7]=v,e[8]=d):d=e[8];let u;e[9]!==d||e[10]!==c||e[11]!==i?(u=(0,r.jsx)("span",{className:d,"data-testid":c,children:i}),e[9]=d,e[10]=c,e[11]=i,e[12]=u):u=e[12];let g;e[13]!==a||e[14]!==u?(g=(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[u,a]}),e[13]=a,e[14]=u,e[15]=g):g=e[15];let x;return e[16]!==p||e[17]!==g?(x=(0,r.jsx)(C,{className:"gap-0 py-0",children:(0,r.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[p,g]})}),e[16]=p,e[17]=g,e[18]=x):x=e[18],x},"U"),Xe=f(async(t,e,a)=>{let s=await Promise.all(a.map(d=>{let u=Q(d);return Promise.allSettled([t.query(Re,{},u),t.query(Fe,{},u),t.query(ze,{},u)])})),l=Q(e),c=typeof t.schedulerStatus=="function"?t.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[i,o,n]=await Promise.allSettled([t.query(Le,{},l),t.query(Pe,{},l),c]),m=s.map(([d,u,g])=>({functions:u.status==="fulfilled"?u.value.functions:[],metrics:d.status==="fulfilled"?d.value:null,migrations:g.status==="fulfilled"?g.value.migrations:[]})),p=Ie(m),v=s[0]?.[0];return{auth:o.status==="fulfilled"?o.value:null,entries:i.status==="fulfilled"?i.value.entries:[],functions:Te(m.map(d=>d.functions)),logsError:i.status==="rejected"?W(i.reason):null,metricsError:p.reachable===0&&v?.status==="rejected"?W(v.reason):null,migrations:De(m.map(d=>d.migrations)),scheduler:n.status==="fulfilled"?n.value:null,totals:p}},"$e"),Ye=f(t=>{let e=t?.history??[];return{attempts:e.map(a=>a.attempts),failures:e.map(a=>a.failures)}},"ze"),xt=f(({initialShardKey:t})=>{let e=ne(),a=D(),[s,l]=(0,h.useState)([]),[c,i]=(0,h.useState)(null),[o,n]=(0,h.useState)(null),[m,p]=(0,h.useState)(null),[v,d]=(0,h.useState)([]),[u,g]=(0,h.useState)(null),[x,S]=(0,h.useState)(null),[E,q]=(0,h.useState)([]),[N]=(0,h.useState)(de),k=(0,h.useRef)(!1),w=(0,h.useRef)(0),G=(0,h.useRef)(0),j=(0,h.useRef)(null),F=t??"",L=(0,h.useCallback)(async()=>{if(k.current)return;k.current=!0;let b=w.current,y=await Xe(e,F,me(F,N));b===w.current&&(n(y.totals),p(y.metricsError),d(y.functions),q(y.migrations),l(y.entries),i(y.logsError),g(y.auth),S(y.scheduler),k.current=!1)},[e,N,F]);(0,h.useEffect)(()=>(_(L()),()=>{w.current+=1,k.current=!1,j.current!==null&&(clearTimeout(j.current),j.current=null)}),[L]);let ye=f(()=>{let b=Date.now()-G.current;if(b>=ge){G.current=Date.now(),_(L());return}j.current===null&&(j.current=setTimeout(()=>{j.current=null,G.current=Date.now(),_(L())},ge-b))},"ue"),{data:Z,liveError:we}=ce(A.getMetrics,{},{live:!0,shardKey:F});(0,h.useEffect)(()=>{Z!==void 0&&ye()},[Z]);let ee=s.filter(b=>b.level==="error"),ke=ee.slice(0,Oe),R=Ge(o?.history),te=Ye(u),Se=v.filter(b=>b.calls>0).toSorted((b,y)=>y.errors/y.calls-b.errors/b.calls||y.calls-b.calls).slice(0,Ke),V=Ve(E),Ee=o===null||o.requests===0?0:o.errors/o.requests,J=X(Ee,xe,ve),re=u===null?"ok":X(u.failureRate,_e,$e),se=x===null?"ok":Ue(x.backlog,Be,He),z=We([J,re,se,V.level]),O,K;return z==="crit"?(O=a("Critical"),K=a("One or more service levels are breached.")):z==="warn"?(O=a("Degraded"),K=a("Some service levels need attention.")):(O=a("All systems healthy"),K=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)(C,{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:M("flex size-10 shrink-0 items-center justify-center rounded-full",Qe[z]),children:(0,r.jsx)("span",{className:M("size-3 rounded-full",be[z])})}),(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:O}),(0,r.jsx)("span",{className:"text-[13px] text-muted-foreground",children:K})]})]}),(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:[R.requests.length>=2&&(0,r.jsx)($,{ariaLabel:a("Requests over time"),className:"h-6 w-20 text-foreground",series:R.requests,testId:"hl-spark-requests"}),(0,r.jsx)("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:(o?.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:M("text-lg font-semibold tabular-nums",Ne[J]),"data-testid":"hl-error-rate",children:o===null?"\u2014":U(o.errors,o.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)(he,{}),(0,r.jsx)(ue,{message:we,prefix:"hl"})]})]})]}),m!==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:m}),m===null&&o?.historyTruncated===!0&&(0,r.jsx)("div",{className:"border-t border-border bg-warning/5 px-4 py-2 text-sm text-muted-foreground","data-testid":"hl-history-truncated",children:a("Showing a partial request/error history \u2014 one or more shards have more data than the trend chart can display.")})]}),(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:R.errors.length>=2?(0,r.jsx)($,{ariaLabel:a("Errors over time"),className:"h-7 w-20 text-destructive",series:R.errors,testId:"hl-spark-errors"}):void 0,label:a("Error rate"),level:J,testId:"hl-slo-errorrate",value:o===null?"\u2014":U(o.errors,o.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:x===null?"\u2014":x.backlog.toString()}),(0,r.jsx)(H,{label:a("Migrations"),level:V.level,testId:"hl-slo-migrations",value:Je(V,a)})]}),(0,r.jsx)(je,{errorCount:ee.length,logsError:c,topErrors:ke,worstFunctions:Se}),(0,r.jsxs)(C,{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:N.length})]}),N.length>0&&(0,r.jsx)("ul",{className:"flex flex-wrap gap-1.5 p-4",children:N.map(b=>(0,r.jsx)("li",{"data-testid":"hl-shard",children:(0,r.jsx)(P,{variant:"secondary",children:b})},b))})]})]})},"ut");export{xt as HealthPanel};
@@ -0,0 +1,15 @@
1
+ import{a}from"./chunk-I26MS5PJ.js";var r="https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/",n="https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-1xxx-errors/",T=/string or blob too big/iu,l={BAD_REQUEST:{status:400,title:"Bad request"},UNAUTHORIZED:{status:401,title:"Unauthorized"},FORBIDDEN:{status:403,title:"Forbidden"},NOT_FOUND:{status:404,title:"Not found"},DELIVERY_FENCED:{status:409,title:"Delivery authorization changed",hint:"The operation may have committed. Retry with the same transport key; a committed result from an older authority epoch returns DELIVERY_RECEIPT_FENCED. Do not automatically retry with a new transport key."},DELIVERY_RECEIPT_FENCED:{status:409,title:"Committed receipt authorization changed",hint:"The operation committed, but its stored result belongs to an older authority epoch. Do not automatically retry with a new transport ID. Recover through the application's durable operation key under current authorization."},CONFLICT:{hint:["Another write changed this row while your mutation was running (optimistic concurrency conflict).","","Re-read the row and retry the mutation with the fresh value. Lunora serializes a DO's mutations, so a persistent conflict usually means the handler conflicts **with itself** (e.g. a trigger or cascade touching the same row) \u2014 split that work rather than adding a retry loop."],status:409,title:"Conflict"},NOT_UNIQUE:{hint:["`.unique()` matched more than one document \u2014 it expects the query to identify at most one row.","","- If several matches are legitimate, use `.first()` (take one) or `.collect()` (take all) instead.","- Otherwise tighten the query (e.g. filter on a unique/indexed field) so it can only match one row."],status:400,title:"Query matched more than one document"},VALIDATION_ERROR:{status:400,title:"Validation failed"},TOO_MANY_REQUESTS:{status:429,title:"Too many requests"},UNPROCESSABLE:{status:422,title:"Unprocessable"},NOT_IMPLEMENTED:{status:501,title:"Not implemented"},FUNCTION_NOT_FOUND:{status:404,title:"Function not found"},METHOD_NOT_ALLOWED:{status:405,title:"Method not allowed"},PAYLOAD_TOO_LARGE:{status:413,title:"Payload too large"},INTERNAL:{internal:!0,status:500,title:"Internal error"},INTERNAL_SERVER_ERROR:{internal:!0,status:500,title:"Internal error"},RPC_FAILED:{internal:!0,status:500,title:"Internal error"},COUNT_RLS_UNSUPPORTED:{status:422,title:"count() is unsupported under an RLS policy"},MASK_UNSUPPORTED:{status:422,title:"Aggregation over a masked column is unsupported"},RELATION_PREDICATE_UNSUPPORTED:{status:422,title:"Relation predicate is unsupported in a write policy"},RLS_REQUIRED:{hint:["This table is secure-by-default: it has no `.public()` marker and no RLS policy resolved for the caller, so the read fails closed.","","Add a read policy with `.rls(...)`, or mark the table `.public()` if it is intentionally world-readable."],status:403,title:"RLS policy required"},RUN_DEPTH_EXCEEDED:{internal:!0,status:500,title:"Run depth exceeded"},RUN_KIND_FORBIDDEN:{status:500,title:"Function kind may not be composed from a query"},TRANSACTION_LIMIT_EXCEEDED:{hint:["A single mutation may only read and write a bounded amount before it is stopped.","","Narrow the read with an index (`.withIndex(...)`) instead of scanning the table, or split the write across several mutations \u2014 for a large backfill use `defineMigration` + `lunora migrate up`, which batches and checkpoints for you.","","The ceilings are deliberately conservative \u2014 they exist to stop one request taking down the whole shard. A deployment that genuinely needs bigger transactions can raise them by overriding the `transactionLimits()` seam on its generated shard class."],status:413,title:"Transaction limit exceeded"},MIGRATION_NOT_FOUND:{status:404,title:"Data migration not found"},MIGRATION_DRIFT:{hint:["An applied SQL migration is never re-run, so the runner stopped before applying anything.","","- **Its text changed after it ran:** revert the edit and put the change in a new migration. If the edit is inert (a comment, whitespace, line endings), record the new hash with the `UPDATE` the message prints.","- **Tracking rows predate versions and match no migration:** set each row's `version` with the `UPDATE` the message prints, so the runner can tell what already ran."],status:409,title:"Migration drift"},UNKNOWN_TABLE:{status:404,title:"Unknown table"},GLOBAL_TABLE_NOT_EDITABLE:{status:400,title:"Global table is not editable"},SHARD_ERROR:{status:503,title:"Shard error"},SHARD_UNAVAILABLE:{status:503,title:"Shard unavailable"},SHARD_TIMEOUT:{status:504,title:"Shard timeout"},SHARD_HTTP_ERROR:{status:502,title:"Shard HTTP error"},SHARD_DRY_RUN_UNSUPPORTED:{status:501,title:"Shard cannot dry-run an import"},SUBSCRIPTION_PERSIST_FAILED:{status:500,title:"Subscription persist failed"},TOO_MANY_SUBSCRIPTIONS:{status:429,title:"Too many subscriptions"},LIVE_CONTROL_SUPERSEDED:{status:409,title:"A later live control call already applied"},OFFLINE_IDENTITY_CHANGED:{status:409,title:"Offline identity changed"},OFFLINE_NOT_QUEUED:{hint:"A mutation sent with `onlineOnly: true` found its connection down or reconnecting (the shard had connected before), or, on a shard that has never connected, its request failed on the wire. It was refused instead of queued. Nothing was persisted or replayed; issue the call again once the connection is back. See [keeping a write off the queue](/docs/concepts/offline-first#keeping-a-write-off-the-queue).",status:503,title:"Offline, write not queued"},IDENTITY_MISMATCH:{hint:["A write queued offline was replayed on a session that now belongs to someone else (a sign-out, or another user's sign-in, while it waited), so the worker refused it rather than commit it as them.","","`@lunora/client` re-resolves the session on this refusal and settles the write itself. If every replay is refused while the same user stays signed in, your worker's `resolveIdentity` returns a different `userId` than better-auth's `user.id`, or the RPC request carries no session cookie."],status:409,title:"Session changed since the write was queued"},CODEGEN_DIAGNOSTIC:{status:500,title:"Codegen diagnostic"},JURISDICTION_MOVE:{hint:["The schema declares `.jurisdiction(...)` and the project has DO-backed auth (`.auth({ namespace })`). Pinning the auth object to the jurisdiction resolves it to a new, empty one: every user, account and session stays in the unpinned object until copied across. Voice sessions are pinned without an acknowledgement: they store nothing, and their transcripts are rows in the already-pinned shards.","",'Acknowledge with `.jurisdiction("eu", { pinAuth: true })` and deploy, then copy the auth tables across with the `__lunora_admin__:copyAuthToJurisdiction` admin op and, once the counts check out, purge the unpinned copy with `__lunora_admin__:purgeUnpinnedAuth` (see [Pinning auth and voice](/docs/concepts/data-residency#pinning-auth-and-voice)). For D1-mode auth the acknowledgement changes nothing.'],status:422,title:"Unacknowledged jurisdiction move"},SCHEMA_SNAPSHOT_PARSE:{status:500,title:"Schema snapshot parse error"},ENV_INVALID:{internal:!0,status:500,title:"Invalid environment"},X402_FACILITATOR_ERROR:{internal:!0,status:502,title:"Payment facilitator error"},AUTH_HEADERS_MISSING:{internal:!0,status:500,title:"Auth headers missing"},PRIVACY_COVERAGE:{status:500,title:"Privacy coverage check failed"},PRIVACY_REQUEST_OPEN:{status:409,title:"A privacy request is already open"},PRIVACY_SESSION_NOT_FRESH:{status:403,title:"Recent sign-in required"},EMAIL_DOMAIN_BLOCKED:{hint:["This address's domain is on the disposable/throwaway blocklist (or your configured deny-list).","","Sign up with a permanent mailbox. To tune the policy, pass `blockDisposable` / `allowDomains` / `denyDomains` in the `EmailGateConfig` you hand `assertEmailAllowed` / `classifyEmail` / `emailGateMiddleware` (`@lunora/auth/email-guard`)."],status:400,title:"Email domain not allowed"},EMAIL_UNDELIVERABLE:{hint:["The address's domain publishes no MX (or fallback A/AAAA) records, so it can't receive mail.","","Check for a typo in the domain. MX verification is opt-in (`mx: true`) and needs DNS \u2014 leave it off on the edge path if DNS is unavailable."],status:400,title:"Email domain cannot receive mail"},ANALYTICS_SQL_QUERY_ERROR:{status:502,title:"Analytics SQL query error"},BROWSER_RUN_ERROR:{status:502,title:"Browser Run API error"},BROWSER_TOO_MANY_REDIRECTS:{status:502,title:"Too many redirects"},R2_SQL_ERROR:{status:502,title:"R2 SQL API error"},WORKFLOWS_REST_ERROR:{status:502,title:"Cloudflare Workflows REST API error"},CONFIG_INVALID:{internal:!0,status:500,title:"Payment configuration invalid"},CURRENCY_MISMATCH:{status:400,title:"Currency mismatch"},PROVIDER_ERROR:{status:502,title:"Payment provider error"},WEBHOOK_EVENT_ID_MISSING:{status:400,title:"Webhook event id missing"},WEBHOOK_SIGNATURE_INVALID:{status:400,title:"Webhook signature invalid"},WEBHOOK_TIMESTAMP_INVALID:{status:400,title:"Webhook timestamp outside tolerance"},ADMIN_FORBIDDEN:{status:403,title:"Admin access forbidden"},ADMIN_TOKEN_NOT_CONFIGURED:{status:400,title:"Admin token not configured"},AUTH_MIGRATOR_UNSUPPORTED:{hint:["better-auth migrates only through its Kysely adapter, so `ensureMigrated` / `compileMigrationsSql` need the raw D1 binding as `database` \u2014 a custom adapter (`lunoraD1Adapter`, `lunoraAuthAdapter`, `lunoraDoAdapter`) cannot be migrated through, and neither can an absent `database`.","","Build a SECOND, migration-only instance over the raw binding \u2014 `createMigrationAuth({ ...options, database: env.DB })` (from `@lunora/auth/migrate`) \u2014 and hand that one to `ensureMigrated`. Keep the adapter on the instance that serves requests: the adapter exists to dodge a dev-runner hang in `$context`, which the migration instance never resolves.","","To compile the SQL off-platform (`compileMigrationsSql`), diff against an empty local database \u2014 `new DatabaseSync(':memory:')` from `node:sqlite` \u2014 rather than passing no `database` at all."],status:500,title:"Auth migrator cannot drive the configured database"},AUTH_NOT_CONFIGURED:{status:400,title:"Auth admin not configured"},AUTH_OP_NOT_SUPPORTED:{status:400,title:"Auth admin operation not supported"},AUTH_CIMD_FETCH_NOT_PUBLIC:{hint:'Add "global_fetch_strictly_public" to "compatibility_flags" in wrangler.jsonc, so CIMD metadata fetches cannot reach private addresses. `lunora doctor` reports it as `cimd-fetch-not-strictly-public`.',status:500,title:"CIMD transport needs the global_fetch_strictly_public flag"},AUTH_MCP_RESOURCE_AMBIGUOUS:{hint:'Use `mcp` from "@lunora/auth/plugins" (not `@better-auth/mcp`) and pass the plugin object as is: it records its `resource`, which the worker needs to serve the protected-resource metadata when the provider names several resources.',status:500,title:"MCP resource cannot be told apart from the provider's other resources"},AUTH_MCP_RESOURCE_INVALID:{hint:"Pass `resource` to `requireMcpAuth` (and `mcp()`) as the absolute URL of the MCP route, e.g. `https://app.example.com/mcp`: issued tokens are audience-bound to it.",status:500,title:"MCP resource missing or not an absolute URL"},MCP_STEP_UP_MISCONFIGURED:{hint:"Give `createAuthedMcpFetchHandler`'s `stepUp` a non-empty `scope` (such as `lunora:write`) and a `challenge` (`createInsufficientScopeError` from `@lunora/auth/plugins`), or leave `stepUp` out.",status:500,title:"MCP step-up misconfigured"},BACKUP_NOT_CONFIGURED:{status:500,title:"Scheduled backup not configured"},BACKUP_RETENTION_NOT_CONFIGURED:{hint:["`lunora backup prune` removes snapshots past the retention window, and this worker has no window: set `backupRetain` (how many to keep) and `backupCron` (which decides whose snapshots retention owns) on `createWorker`.","","Nothing was deleted. A default is deliberately not invented here \u2014 retention deleting on its own is exactly what this command exists to replace."],status:400,title:"Backup retention window not configured"},BACKUP_TOO_LARGE:{hint:["The scheduled backup is assembled inside the Worker isolate, so it caps the snapshot it will build. Nothing was written.","","The cap is on the NDJSON, not on peak memory: the export fan-out resolves every shard's rows before the first row is encoded, so a snapshot under the cap can still exhaust the isolate. It is set well below the isolate's limit for that reason.","","Narrow the snapshot with `backupTables`, or take this backup off-platform with `lunora backup create --bucket`, which runs on a machine rather than in an isolate. Backing up more often does not help \u2014 every run is a full snapshot."],status:507,title:"Backup too large to assemble in a Worker"},CRON_JOBS_NOT_CONFIGURED:{status:400,title:"Cron jobs not configured"},CRON_JOB_NOT_FOUND:{status:404,title:"Cron job not found"},EXPORT_SHARD_FAILED:{hint:["One or more shards failed to export, so the snapshot would have been short. Nothing is written when this fires \u2014 a partial export must never be mistaken for a complete one.","","The message names each failed shard key and its error. Re-run the export once those shards are reachable; a shard that fails repeatedly is usually over the per-request memory budget, which `backupTables` narrows."],status:502,title:"Export failed on one or more shards"},EXPORT_TAP_NOT_CONFIGURED:{status:400,title:"Export tap not configured"},FUNCTIONS_NOT_CONFIGURED:{status:400,title:"Functions registry not configured"},GLOBALS_NOT_CONFIGURED:{status:400,title:"Global-table introspector not configured"},ID_COLLISION:{hint:["The imported row carries an `_id` that is already held by a DIFFERENT table in this shard. Ids are per-table, so inserting it would leave two tables claiming one id and make a later lookup resolve to whichever one it reached first.","","This is reported per row rather than aborting the import: the remaining rows still apply. Re-mint the id on the source side, or import that table into a shard that does not already hold it."],status:409,title:"Document id already belongs to another table"},KV_NOT_CONFIGURED:{status:400,title:"KV introspector not configured"},MIGRATION_ID_REQUIRED:{status:400,title:"Migration id required"},PITR_UNAVAILABLE:{status:409,title:"Point-in-time recovery unavailable"},SCHEDULER_NOT_CONFIGURED:{status:400,title:"Scheduler not configured"},STORAGE_CHECKSUM_MISMATCH:{hint:["The upload body did not match the declared `expectedSize` or `expectedSha256`, so nothing was written \u2014 this check fails closed.","","Re-read the bytes from the source export and retry the transfer. A persistent mismatch means the source blob is corrupt or truncated; fix the export rather than bypassing the check."],status:400,title:"Storage checksum mismatch"},STORAGE_DELETE_NOT_CONFIGURED:{status:400,title:"Storage delete not configured"},STORAGE_DOWNLOAD_NOT_CONFIGURED:{hint:["`GET /_lunora/admin/storage/object` needs a `storageDownload` function on the worker. The generated app worker wires it up; a hand-written `createWorker({ ... })` has to pass `(key, opts) => pick(opts?.bucket).download(key)` \u2014 forwarding `opts.bucket` to the right bucket, and wrapping rather than passing `createStorage(...).download` itself, whose second parameter is a byte range.","","Without it a bucket-backed `lunora backup restore --bucket` cannot read the snapshot. The object is still readable out of band with `wrangler r2 object get`."],status:400,title:"Storage download not configured"},STORAGE_NOT_CONFIGURED:{status:400,title:"Storage not configured"},STORAGE_OBJECT_NOT_FOUND:{status:404,title:"Storage object not found"},STORAGE_UPLOAD_NOT_CONFIGURED:{status:400,title:"Storage upload not configured"},STORAGE_URL_NOT_CONFIGURED:{status:400,title:"Storage signed URL not configured"},AI_UNKNOWN_IMAGE_MODEL:{status:400,title:"Unknown image model"},RAG_DIMENSION_MISMATCH:{hint:["A stored vector and the query embedding have different widths, so they cannot be compared.","","This is what changing a RAG index's `embeddingModel` (or a provider's `dimensions` option) without reindexing looks like. Either put the previous model back, or reindex the namespace under the new one \u2014 bump `embeddingModelVersion` so the index rebuilds instead of mixing widths."],status:409,title:"Embedding dimension mismatch"},VECTORS_NOT_CONFIGURED:{status:400,title:"Vector index introspector not configured"},VECTOR_QUERY_UNSUPPORTED:{status:400,title:"Vector index querying not enabled"},WORKFLOWS_NOT_CONFIGURED:{status:501,title:"Workflows not configured"},AUTH_AUDIT_NOT_CONFIGURED:{status:400,title:"Auth audit reader not configured"},AUTH_AUDIT_READ_FAILED:{internal:!0,status:500,title:"Auth audit read failed"},AUTH_MOVE_NOT_CONFIGURED:{hint:"The copy needs DO-backed auth (`.auth({ namespace })`) pinned with `.jurisdiction(\u2026, { pinAuth: true })`, and the auth object's `internalSecret` set.",status:400,title:"Auth jurisdiction move not configured"},AUTH_MOVE_TARGET_NOT_EMPTY:{hint:"The pinned auth object holds users the copy did not write (someone signed up there), so copying into it would merge two user bases. Pass `force: true` to copy anyway: a copied row that collides with one of the pinned object's rows is left out and counted under `conflicts`.",status:409,title:"Pinned auth object is not empty"},AUTH_MOVE_CONFLICT:{hint:"A copied row has the same key or unique value (such as an email) as a row the pinned auth object holds on its own, or the pinned object changed a row the source changed too. Nothing from that page was written. Pass `force: true` to keep the pinned object's rows and count the collisions under `conflicts`.",status:409,title:"Auth copy conflict"},AUTH_MOVE_SOURCE_CHANGED:{hint:"The un-pinned auth object changed after the copy read it (an update, a delete, or a new row), for example during a gradual rollout or a rollback. Run the copy again: it reconciles the changed tables. Then purge.",status:409,title:"Un-pinned auth object changed since the copy"},AUTH_MOVE_SOURCE_PURGED:{hint:"The un-pinned auth object was already purged. Its tables may exist again (a rollback served requests there), but they hold only rows written since, so the copy refuses rather than read them as deletions and remove the pinned object's users. Nothing is left to copy.",status:409,title:"Un-pinned auth object already purged"},AUTH_MOVE_INCOMPLETE:{hint:"Run `__lunora_admin__:copyAuthToJurisdiction` until it answers `done: true`, check the per-table counts, then purge.",status:409,title:"Auth copy not finished"},AUTH_MOVE_FAILED:{hint:"The message names the step, the table and the class of the SQLite error; the auth object's log has the full error. The copy resumes where it stopped once the cause is fixed.",status:500,title:"Auth jurisdiction move failed"},CRON_EXPR_INVALID:{status:500,title:"Invalid cron expression"},CRON_EXPR_NOT_STATIC:{status:500,title:"Cron expression is not statically analyzable"},CRON_JOB_FAILED:{internal:!0,status:500,title:"Cron job failed"},CRON_NAME_NOT_STATIC:{status:500,title:"Cron job name is not statically analyzable"},CRON_NON_STATIC_FN:{status:500,title:"Cron function reference is not statically analyzable"},CRON_NON_STATIC_VALUE:{status:500,title:"Cron value is not statically analyzable"},CRON_SCHEDULE_INVALID:{status:500,title:"Invalid cron schedule"},CRON_SCHEDULE_NOT_STATIC:{status:500,title:"Cron schedule is not statically analyzable"},DUPLICATE_CRON_NAME:{status:500,title:"Duplicate cron job name"},DUPLICATE_AGENT_CLASS:{status:500,title:"Duplicate agent generated class name"},DUPLICATE_AGENT_NAME:{status:500,title:"Duplicate agent name"},DUPLICATE_MIGRATION_ID:{status:500,title:"Duplicate migration id"},DUPLICATE_QUEUE_BINDING:{status:500,title:"Duplicate queue binding"},DUPLICATE_QUEUE_NAME:{status:500,title:"Duplicate queue name"},DUPLICATE_ROOM_NAME:{status:500,title:"Duplicate room name"},ROOM_NAME_NOT_LITERAL:{status:500,title:"Room name is not a string literal"},DUPLICATE_SOCKET_PATH:{status:500,title:"Duplicate socket route path"},SOCKET_AUTH_NOT_LITERAL:{status:500,title:"Socket route auth is not a literal boolean"},SOCKET_PATH_INVALID:{status:500,title:"Socket route path is not a plain URL path"},SOCKET_PATH_NOT_LITERAL:{status:500,title:"Socket route path is not a string literal"},LIVE_STREAM_DUPLICATE:{status:500,title:"Duplicate live stream id or export name"},LIVE_STREAM_NOT_EXPORTED:{status:500,title:"Live stream is not a named export"},LIVE_STREAM_NOT_LITERAL:{status:500,title:"Live stream declaration is not a literal"},LIVE_TOPIC_INVALID:{status:500,title:"Live topic name or key field is not allowed"},DUPLICATE_WORKFLOW_CLASS:{status:500,title:"Duplicate workflow generated class name"},MIGRATION_ID_NOT_STATIC:{status:500,title:"Migration id is not statically analyzable"},NAMESPACE_COLLISION:{status:500,title:"Function namespace collision"},BAD_ROW:{status:400,title:"Malformed import row"},BAD_SUBSCRIPTION_ARGS:{status:400,title:"Invalid subscription arguments"},BATCH_LIMIT_EXCEEDED:{status:400,title:"Batch limit exceeded"},CASCADE_LIMIT:{status:400,title:"Cascade limit exceeded"},CROSS_SHARD_RANK_UNSUPPORTED:{status:400,title:"Cross-shard rank() is unsupported"},DISPATCH_UNAUTHENTICATED:{hint:"The scheduler could not authenticate to the worker. Check that `LUNORA_SCHEDULER_SECRET` matches on both sides, or that `LUNORA_ADMIN_TOKEN` is set and current.",status:403,title:"Dispatch caller not authenticated"},DISPATCH_IN_PROGRESS:{hint:"A dispatch with this idempotency id is still running on the shard. Retry it; once the first attempt settles the same id is served from the replay cache.",status:409,title:"Dispatch already in progress"},FORBIDDEN_FANOUT:{status:403,title:"Fan-out forbidden"},GLOBAL_SEARCH_SCORES_UNSUPPORTED:{status:400,title:"collectWithScores() is unsupported on a global table"},FORBIDDEN_ORIGIN:{status:403,title:"Origin forbidden"},FORBIDDEN_SHARD:{status:403,title:"Shard access forbidden"},FORBIDDEN_TOPIC:{status:403,title:"Live topic publish forbidden"},GLOBAL_DRY_RUN_UNSUPPORTED:{status:400,title:"Global table dry run not supported"},GLOBAL_NOT_CONFIGURED:{status:400,title:"Global table import not configured"},INVALID_INPUT:{status:400,title:"Invalid input"},INVALID_SCHEDULE_ID:{status:400,title:"Invalid schedule id"},RATE_LIMITED:{status:429,title:"Rate limited"},REPLICA_NOT_READY:{status:421,title:"Replica not caught up"},REPLICA_READ_ONLY:{status:421,title:"Replica is read-only"},SEARCH_INDEX_BUILDING:{status:503,title:"Search index is still building"},SERVICE_UNAVAILABLE:{status:503,title:"Service unavailable"},SHAPE_MEMORY_TABLE:{status:400,title:"Shape over a memory table is unsupported"},SHAPE_CROSS_SHARD_JOIN:{status:400,title:"Shape cross-shard join is unsupported"},SHAPE_RELATION_PREDICATE:{status:400,title:"Shape filtered by a relation is unsupported"},UNAUTHENTICATED:{status:401,title:"Unauthenticated"},WIRE_DECODE_FAILED:{status:502,title:"Could not decode a server frame"},WIRE_ENCODE_FAILED:{status:500,title:"Could not encode a return value"},UNKNOWN_COLUMN:{status:404,title:"Unknown column"},CDC_LOG_TRIMMED:{status:409,title:"CDC log trimmed"},CDC_TIMELINE_FORKED:{status:409,title:"CDC timeline forked"},CDC_PAYLOAD_COMPACTED:{status:409,title:"CDC payloads compacted"},EXPIRED:{status:404,title:"Session expired"},LIVE_CONNECTION_LIMIT:{status:503,title:"Live connection limit reached"},LIVE_CONNECTION_NOT_FOUND:{status:404,title:"Live connection not found"},LIVE_STREAMS_UNSUPPORTED:{status:501,title:"Live streams are not served by this worker"},NESTED_TRANSACTION:{internal:!0,status:500,title:"Nested transaction"},OUT_OF_ORDER:{status:409,title:"Out-of-order mutation"},SHAPE_GLOBAL_TOO_LARGE:{status:413,title:"Global shape too large"},SHAPE_NOT_FOUND:{status:404,title:"Shape not found"},SHAPE_REQUIRES_CDC:{status:409,title:"Shape requires change-data-capture"},SQL_UNAVAILABLE:{internal:!0,status:500,title:"SQL storage unavailable"},STREAM_ID_IN_USE:{status:409,title:"Stream id already in use"},STREAM_IDLE:{status:504,title:"Stream went idle"},STREAM_INTERRUPTED:{status:503,title:"Durable stream interrupted"},STREAM_TOO_LONG:{status:507,title:"Durable stream exceeded its chunk ceiling"},SUBSCRIPTION_RESULT_TOO_LARGE:{status:413,title:"Subscription result too large"},TOKEN_EXPIRED:{hint:["The caller's credential verified but its expiry has passed. The worker refuses an HTTP call with this code before it runs; a shard drops a socket with close code `4001` and the same code.","","It is a refusal of the credential, not of the call: `@lunora/client` holds a queued write, fires `onTokenExpired`, and re-sends it after `setAuthToken`. The held write survives the refresh only if you pass the same `subject` (the user id) with the new token, `setAuthToken(freshToken, user.id)`; without one a refresh reads as a user switch and the write is rejected `OFFLINE_IDENTITY_CHANGED`. Under a cookie session there is no token to replace: renew the cookie and the write is re-sent on a backoff. The worker can only tell expired from anonymous if your `resolveIdentity` returns the identity with its past `exp` (or `expiresAtMs`), or throws a `LunoraError` with this code. Returning `null` runs the call anonymous."],status:401,title:"Authentication token expired"},TOO_MANY_LIVE_TOPICS:{status:429,title:"Too many live topics"},TOO_MANY_STREAMS:{status:429,title:"Too many streams"},TOO_MANY_WHISPER_TOPICS:{hint:"Reuse a stable set of whisper topic names, or reconnect \u2014 the per-socket verdict memo is in-memory, so a new connection starts empty. Leaving a topic does not free its entry.",status:429,title:"Too many whisper topics"},UNKNOWN_ADMIN_OP:{status:404,title:"Unknown admin operation"},SOCKET_TAG_BUDGET_EXCEEDED:{status:400,title:"Socket tag budget exceeded"},RELAY_CANNOT_SEED:{status:500,title:"Relay cannot seed"},RELAY_MISCONFIGURED:{status:500,title:"Relay misconfigured"},RELAY_SEED_FAILED:{status:502,title:"Relay seed failed"},RELAY_SHAPE_UNROUTABLE:{status:500,title:"Relay shape unroutable"},MISCONFIGURED:{internal:!0,status:500,title:"Worker misconfigured"},LUNORA_RUNTIME_UNAVAILABLE:{status:500,title:"Lunora runtime unavailable"},INTERNAL_ERROR:{internal:!0,status:500,title:"Internal error"},BROWSER_TIMEOUT:{status:504,title:"Browser operation timed out"},CLIENT_CLOSED:{status:400,title:"Client is closed"},HTTP_STREAM_BAD_CHUNK:{status:502,title:"Malformed HTTP stream chunk"},HTTP_STREAM_CALLBACK:{status:500,title:"HTTP stream callback threw"},HTTP_STREAM_INTERRUPTED:{status:502,title:"HTTP stream interrupted"},HTTP_STREAM_MISSING_PARAM:{status:400,title:"HTTP stream missing path parameter"},HTTP_STREAM_NO_BODY:{hint:["The `fetch` implementation resolved with a response that exposes neither a `body` stream nor a `text()` read \u2014 a broken `fetch` substitute, not a runtime limitation.","A response with no `body` stream that can still be read as text (React Native's `whatwg-fetch` polyfill) is buffered through `text()` instead and never raises this code. Check the `fetch` override passed to the client or the `httpStream` call."],status:502,title:"HTTP stream response has no body"},HTTP_STREAM_STATUS:{status:502,title:"HTTP stream request failed"},HTTP_STREAM_TRANSPORT:{status:502,title:"HTTP stream transport error"},STREAM_BACKPRESSURE:{status:429,title:"Stream backpressure"},STREAM_DISCONNECTED:{status:503,title:"Stream disconnected"},STREAM_QUEUE_OVERFLOW:{status:429,title:"Stream queue overflow"},UNKNOWN_MUTATION_FN:{status:404,title:"Unknown mutation function"},LOCAL_DEPENDENCY_MISSING:{hint:["The command Lunora tried to run is not on your PATH, so nothing ran.","","Install it (or put it on PATH) and retry \u2014 `wrangler` ships as a dependency of a Lunora app, so `pnpm install` usually fixes that one; `git` and `docker` are installed separately."],status:500,title:"Required local tool not found"}},c=a(e=>Object.hasOwn(l,e)?l[e]:void 0,"h");var m=[{body:["A single row exceeded the storage engine's per-row ceiling \u2014 2 MB on a Durable Object's SQLite, and 2,000,000 bytes on D1.","","The limit is on the STORED bytes, which are UTF-8: a document of multi-byte text (CJK, emoji) costs up to 3x its character count. `v.bytes()` and `v.bigint()` columns cost more again on a shard-local table, where the row stores both a SQL-comparable projection and the original.","","Keep the large payload out of the row and store a reference to it:","","```ts","const key = `uploads/${crypto.randomUUID()}`;","await ctx.storage.uploads.put(key, bytes);",'await ctx.db.insert("documents", { storageKey: key, title });',"```","","R2 has no practical object-size ceiling, and the row stays small enough to read, index, and replicate."].join(`
2
+ `),header:"Row too large for the storage engine",id:"lunora-row-too-big",test:a(e=>T.test(e),"test")},{body:["Lunora codegen couldn't find a schema to generate from.","","Create `lunora/schema.ts` exporting a `defineSchema(...)` call:","","```ts",'import { defineSchema, defineTable, v } from "@lunora/server";',"","export default defineSchema({"," messages: defineTable({ body: v.string() }),","});","```","","Or run `lunora init` to scaffold Lunora (a sample `lunora/schema.ts` included) into your app."].join(`
3
+ `),header:"No Lunora schema found",id:"lunora-schema-missing",test:a(e=>e.includes("defineSchema() not found")||e.includes("schema.ts not found at"),"test")},{body:["`defineSchema(...)` must be called with an **inline object literal** mapping table names to `defineTable(...)`:","","```ts","export default defineSchema({"," todos: defineTable({ title: v.string(), done: v.boolean() }),","});","```","","Codegen reads the schema statically, so it can't follow a variable or a spread \u2014 pass the object literal directly."].join(`
4
+ `),header:"`defineSchema()` needs an inline object literal",id:"lunora-schema-not-object-literal",test:a(e=>e.includes("defineSchema() expects an object literal"),"test")},{body:["This table name collides with a built-in `ctx.db` member, so the generated client can't expose it.","","Rename the table to anything that isn't a `ctx.db` member (the error names the one it hit) \u2014 e.g. `userAccounts` instead of `insert`, or `pageViews` instead of `count`."].join(`
5
+ `),header:"Table name is reserved",id:"lunora-table-reserved",test:a(e=>e.includes("is reserved")&&e.includes("ctx.db"),"test")},{body:["Two tables resolve to the same name \u2014 usually a base table and a schema **extension** both defining it.","","Rename one of them, or drop the duplicate from the extension. Each table name must be unique across `defineSchema(...)` and every `.extend(...)`."].join(`
6
+ `),header:"Duplicate table name",id:"lunora-table-duplicate",test:a(e=>e.includes("already exists")&&e.includes(".extend("),"test")},{body:['`.jurisdiction(...)` accepts only a **string literal** of `"eu"`, `"us"`, or `"fedramp"`:',"","```ts",'defineSchema({ /* \u2026 */ }).jurisdiction("eu");',"```"].join(`
7
+ `),header:"Invalid `.jurisdiction(...)` value",id:"lunora-jurisdiction",test:a(e=>e.includes("unknown jurisdiction")||e.includes("jurisdiction")&&e.includes('"eu", "us", or "fedramp"'),"test")},{body:["The `unique` flag on an index must be a **literal** `true` or `false`, not a computed value \u2014 codegen needs to read it statically:","","```ts",'defineTable({ email: v.string() }).index("by_email", ["email"], { unique: true });',"```"].join(`
8
+ `),header:"`unique` must be a literal",id:"lunora-unique-literal",test:a(e=>e.includes("must be a literal")&&e.includes("unique"),"test")},{body:["A declared container/workflow class isn't re-exported by your worker entry, so `wrangler deploy` would reject it.","","Add the generated re-export shown in the error to your worker entry (e.g. `src/index.ts`):","","```ts",'export * from "./lunora/_generated/containers";',"```"].join(`
9
+ `),header:"Binding not exported by your worker entry",id:"lunora-worker-entry-export-gap",test:a(e=>e.includes("not exported by your worker entry"),"test")},{body:["A row with the same value already exists in a `unique` index.","","- If you meant to upsert, use `ctx.db.<table>().upsert(...)` (or `.patch(...)` an existing row) instead of `.insert(...)`.",`- Otherwise pick a value that isn't already taken, and consider surfacing a friendly "already exists" message to the user.`].join(`
10
+ `),header:"Unique constraint violation",id:"lunora-runtime-unique",test:a(e=>e.includes("unique constraint violation on"),"test")},{body:l.CONFLICT.hint.join(`
11
+ `),header:"Optimistic concurrency conflict",id:"lunora-runtime-occ",test:a(e=>e.includes("optimistic concurrency conflict"),"test")}],d=[{causes:"the origin returned an empty, unknown, or malformed response Cloudflare couldn't interpret (often an origin crash or an oversized response header)",code:"520",docsUrl:r,family:"5xx",fix:"check your origin's logs for a crash, ensure it returns a valid HTTP response, and keep response headers under the size limit",summary:"Cloudflare got an unknown/empty response from your origin web server.",title:"Web server returns an unknown error"},{causes:"the origin refused the connection \u2014 the web server is down, or a firewall is blocking Cloudflare's IP ranges",code:"521",docsUrl:r,family:"5xx",fix:"confirm the origin process is running and allowlist Cloudflare's published IP ranges in your firewall/security groups",summary:"Cloudflare could not connect to your origin because it refused the connection.",title:"Web server is down"},{causes:"Cloudflare could not establish a TCP connection to the origin in time \u2014 the origin is overloaded, a firewall is dropping packets, or the origin IP is wrong",code:"522",docsUrl:r,family:"5xx",fix:"verify the origin is reachable and not overloaded, and that the DNS record points at the correct origin IP",summary:"The connection to your origin timed out before it was established.",title:"Connection timed out"},{causes:"Cloudflare cannot route to the origin at all \u2014 a bad DNS record, an origin IP that changed, or invalid routing",code:"523",docsUrl:r,family:"5xx",fix:"verify the DNS A/AAAA record points at a reachable origin IP and that no upstream network is blocking Cloudflare",summary:"Cloudflare could not reach your origin server.",title:"Origin is unreachable"},{causes:"Cloudflare made a TCP connection but the origin did not return an HTTP response within 100 seconds \u2014 a slow handler or long-running request",code:"524",docsUrl:r,family:"5xx",fix:"speed up the slow origin handler, or move long work off the request path into a background job (a Durable Object, Queue, or Workflow)",summary:"Cloudflare connected to your origin but it did not respond in time.",title:"A timeout occurred"},{causes:"the TLS handshake between Cloudflare and the origin failed \u2014 a missing/invalid origin certificate, or a cipher/SNI mismatch under Full (Strict) SSL",code:"525",docsUrl:r,family:"5xx",fix:"install a valid certificate on the origin and align your Cloudflare SSL/TLS mode with the origin's certificate setup",summary:"The SSL handshake with your origin failed.",title:"SSL handshake failed"},{causes:"Cloudflare could not validate the origin's certificate under Full (Strict) SSL \u2014 it is expired, self-signed, or issued for the wrong hostname",code:"526",docsUrl:r,family:"5xx",fix:"install a valid, publicly-trusted certificate on the origin (or use a Cloudflare Origin CA cert), matching the request hostname",summary:"Cloudflare could not validate your origin's SSL certificate.",title:"Invalid SSL certificate"},{causes:"a DNS record points at a Cloudflare IP or another prohibited address instead of your real origin",code:"1000",docsUrl:n,family:"1xxx",fix:"point the DNS record at your real origin IP, not a Cloudflare-owned or loopback address",summary:"DNS points to a prohibited IP.",title:"DNS points to prohibited IP"},{causes:"Cloudflare could not resolve the requested hostname \u2014 a Worker fetched an unresolvable host, or a DNS record is misconfigured",code:"1001",docsUrl:n,family:"1xxx",fix:"check the hostname you're requesting and the DNS records for the zone resolve to a valid origin",summary:"Cloudflare could not resolve the origin DNS.",title:"DNS resolution error"},{causes:"a Worker or DNS record targets a restricted IP (for example a Cloudflare-owned or loopback address)",code:"1002",docsUrl:n,family:"1xxx",fix:"change the Worker fetch target or DNS record to a valid, non-restricted origin address",summary:"DNS points to a prohibited IP (Worker/restricted).",title:"DNS points to a prohibited IP"},{causes:"the visitor's IP was blocked by an IP Access Rule, WAF rule, or security configuration on the zone",code:"1006",docsUrl:n,family:"1xxx",fix:"review the zone's Firewall/WAF and IP Access Rules to see why the address was banned, and adjust if it was blocked in error",summary:"Access denied: the visitor's IP has been banned.",title:"Access denied: your IP has been banned"},{causes:"your Worker threw an unhandled JavaScript exception during the request",code:"1101",docsUrl:n,family:"1xxx",fix:"reproduce with `wrangler tail` (or the Workers Logs / Studio Logs panel) to get the stack trace, then handle the throwing code path",summary:"A Worker threw a JavaScript exception.",title:"Worker threw a JavaScript exception"},{causes:"the Worker used more CPU time than a single invocation is allowed \u2014 usually a hot loop or heavy synchronous work",code:"1102",docsUrl:n,family:"1xxx",fix:"reduce per-request CPU (optimize hot loops, avoid heavy synchronous work) or offload the heavy work to a Durable Object, Queue, or Workflow",summary:"A Worker exceeded its CPU-time resource limit.",title:"Worker exceeded resource limits"}],u=a(e=>e!==void 0&&e>="0"&&e<="9","l"),g=a((e,t)=>{for(let o=e.indexOf(t);o!==-1;o=e.indexOf(t,o+t.length))if(!u(e[o-1])&&!u(e[o+t.length]))return!0;return!1},"_"),A=a((e,t)=>{for(let o of[`error ${t}`,`error: ${t}`])for(let i=e.indexOf(o);i!==-1;i=e.indexOf(o,i+o.length))if(!u(e[i+o.length]))return!0;return!1},"E"),O=/error|cloudflare/iu,p=a(e=>({body:[e.summary,"",`**Likely cause:** ${e.causes}.`,"",`**Fix:** ${e.fix}.`,"",`See [Cloudflare's ${e.family} error docs](${e.docsUrl}).`].join(`
12
+ `),header:`Cloudflare Error ${e.code}: ${e.title}`,id:`cloudflare-error-${e.code}`}),"c"),_=a(e=>{if(!O.test(e))return;let t=e.toLowerCase(),o=t.includes("error"),i=t.includes("cloudflare");if(o){for(let s of d)if(A(t,s.code))return p(s)}if(i){for(let s of d)if(g(t,s.code))return p(s)}},"f"),R=a(e=>(typeof e=="string"?e:e.join(`
13
+ `)).split(`
14
+ `).filter(t=>!t.startsWith("```")).join(`
15
+ `).replaceAll(/\*\*(.+?)\*\*/gu,"$1").replaceAll(/`([^`]+)`/gu,"$1"),"A"),E=a(e=>{for(let t of m)if(t.test(e))return{body:t.body,header:t.header,id:t.id}},"u"),y=a(e=>E(e)??_(e),"O");var f=Symbol.for("@lunora/errors/LunoraError"),h=class e extends Error{static{a(this,"s")}static[Symbol.hasInstance](t){return this!==e?Function.prototype[Symbol.hasInstance].call(this,t):typeof t=="object"&&t!==null&&t[f]===!0}type="VisulimaError";hint;title;loc;code;status;docsUrl;data;why;constructor(t,o,i={}){let s=c(t);super(o??t,i.cause===void 0?void 0:{cause:i.cause}),this.name=i.name??"LunoraError",this.hint=i.hint??s?.hint,this.title=i.title??s?.title,this.loc=i.location,this.code=t,this.status=i.status??s?.status??500,this.docsUrl=i.docsUrl??s?.docsUrl,this.data=i.data,this.why=i.why,Object.defineProperty(this,f,{value:!0}),i.internal!==void 0&&Object.defineProperty(this,"internal",{value:i.internal}),i.headers!==void 0&&Object.defineProperty(this,"headers",{value:i.headers})}};export{l as a,R as b,y as c,h as d};
@@ -1 +1 @@
1
- import{b as h}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{b as A}from"./chunk-DFVQBXUZ.js";import{l as k}from"./chunk-RGDSRUIX.js";import"./chunk-QAQDMS6R.js";import"./chunk-35Q6XYRL.js";import{a as y,e as S}from"./chunk-2IKDEUCX.js";import{d as I}from"./chunk-74IYYDDI.js";import{a as u,d as w,f as z,g as P}from"./chunk-I26MS5PJ.js";var N=w(z(),1);var a=w(P(),1);var j=[{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"),p=u(e=>{let i=(0,N.c)(8),{children:t,heading:d,testId:n}=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 s;i[2]!==t?(s=(0,a.jsx)(S,{className:"p-3",children:t}),i[2]=t,i[3]=s):s=i[3];let c;return i[4]!==l||i[5]!==s||i[6]!==n?(c=(0,a.jsxs)(y,{className:"gap-0 py-0","data-testid":n,children:[l,s]}),i[4]=l,i[5]=s,i[6]=n,i[7]=c):c=i[7],c},"h"),o=u(e=>{let i=(0,N.c)(7),{label:t,value:d}=e,n;i[0]!==t?(n=(0,a.jsx)("span",{className:"text-sm",children:t}),i[0]=t,i[1]=n):n=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 s;return i[4]!==n||i[5]!==l?(s=(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs",children:[n,l]}),i[4]=n,i[5]=l,i[6]=s):s=i[6],s},"c"),M=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 n;e[1]!==i?(n=u(()=>i.getAuthConfig(),"r"),e[1]=i,e[2]=n):n=e[2];let{data:l,error:s}=A(d,n),c;e[3]!==t?(c=u(r=>(0,a.jsx)(h,{variant:r?"success":"outline",children:t(r?"Enabled":"Disabled")}),"u"),e[3]=t,e[4]=c):c=e[4];let m=c,g;e[5]!==s?(g=s!==null&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"auth-config-error",role:"alert",children:s}),e[5]=s,e[6]=g):g=e[6];let f;e[7]!==l||e[8]!==s||e[9]!==t?(f=s===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]=s,e[9]=t,e[10]=f):f=e[10];let x;e[11]!==l||e[12]!==s||e[13]!==m||e[14]!==t?(x=s===null&&l!==void 0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(p,{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:j.map(r=>{let $=l.capabilities[r.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-${r.key}`,children:[(0,a.jsx)("span",{className:"text-sm",children:t(r.label)}),m($)]},r.key)})})}),(0,a.jsx)(p,{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(C)})}),(0,a.jsx)(p,{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(L)})})]})}),l.organization.enabled&&(0,a.jsx)(p,{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)(p,{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)(p,{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)(p,{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(r=>(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-${r.name}`,children:[(0,a.jsxs)("span",{className:"flex flex-col",children:[(0,a.jsx)("span",{className:"font-mono text-xs",children:r.name}),r.plugin!==void 0&&(0,a.jsx)("span",{className:"text-[11px] text-muted-foreground",children:r.plugin})]}),(0,a.jsxs)("span",{className:"flex items-center gap-1",children:[(0,a.jsx)(h,{variant:"outline",children:r.type}),r.required&&(0,a.jsx)(h,{variant:"secondary",children:t("required")}),r.unique&&(0,a.jsx)(h,{variant:"secondary",children:t("unique")})]})]},r.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]=s,e[13]=m,e[14]=t,e[15]=x):x=e[15];let b;return e[16]!==g||e[17]!==f||e[18]!==x?(b=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"auth-config",children:[g,f,x]}),e[16]=g,e[17]=f,e[18]=x,e[19]=b):b=e[19],b},"O");function C(e){return(0,a.jsx)(h,{"data-testid":`auth-config-plugin-${e}`,variant:"outline",children:e},e)}u(C,"P");function L(e){return(0,a.jsx)(h,{"data-testid":`auth-config-provider-${e}`,variant:"outline",children:e},e)}u(L,"z");export{M as default};
1
+ import{b as h}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{b as A}from"./chunk-T2JHVL34.js";import{l as k}from"./chunk-AVSMQPR3.js";import"./chunk-QAQDMS6R.js";import"./chunk-3I25WO3P.js";import{a as y,e as S}from"./chunk-2IKDEUCX.js";import{d as I}from"./chunk-74IYYDDI.js";import{a as u,d as w,f as z,g as P}from"./chunk-I26MS5PJ.js";var N=w(z(),1);var a=w(P(),1);var j=[{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"),p=u(e=>{let i=(0,N.c)(8),{children:t,heading:d,testId:n}=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 s;i[2]!==t?(s=(0,a.jsx)(S,{className:"p-3",children:t}),i[2]=t,i[3]=s):s=i[3];let c;return i[4]!==l||i[5]!==s||i[6]!==n?(c=(0,a.jsxs)(y,{className:"gap-0 py-0","data-testid":n,children:[l,s]}),i[4]=l,i[5]=s,i[6]=n,i[7]=c):c=i[7],c},"h"),o=u(e=>{let i=(0,N.c)(7),{label:t,value:d}=e,n;i[0]!==t?(n=(0,a.jsx)("span",{className:"text-sm",children:t}),i[0]=t,i[1]=n):n=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 s;return i[4]!==n||i[5]!==l?(s=(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs",children:[n,l]}),i[4]=n,i[5]=l,i[6]=s):s=i[6],s},"c"),M=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 n;e[1]!==i?(n=u(()=>i.getAuthConfig(),"r"),e[1]=i,e[2]=n):n=e[2];let{data:l,error:s}=A(d,n),c;e[3]!==t?(c=u(r=>(0,a.jsx)(h,{variant:r?"success":"outline",children:t(r?"Enabled":"Disabled")}),"u"),e[3]=t,e[4]=c):c=e[4];let m=c,g;e[5]!==s?(g=s!==null&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"auth-config-error",role:"alert",children:s}),e[5]=s,e[6]=g):g=e[6];let f;e[7]!==l||e[8]!==s||e[9]!==t?(f=s===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]=s,e[9]=t,e[10]=f):f=e[10];let x;e[11]!==l||e[12]!==s||e[13]!==m||e[14]!==t?(x=s===null&&l!==void 0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(p,{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:j.map(r=>{let $=l.capabilities[r.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-${r.key}`,children:[(0,a.jsx)("span",{className:"text-sm",children:t(r.label)}),m($)]},r.key)})})}),(0,a.jsx)(p,{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(C)})}),(0,a.jsx)(p,{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(L)})})]})}),l.organization.enabled&&(0,a.jsx)(p,{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)(p,{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)(p,{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)(p,{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(r=>(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-${r.name}`,children:[(0,a.jsxs)("span",{className:"flex flex-col",children:[(0,a.jsx)("span",{className:"font-mono text-xs",children:r.name}),r.plugin!==void 0&&(0,a.jsx)("span",{className:"text-[11px] text-muted-foreground",children:r.plugin})]}),(0,a.jsxs)("span",{className:"flex items-center gap-1",children:[(0,a.jsx)(h,{variant:"outline",children:r.type}),r.required&&(0,a.jsx)(h,{variant:"secondary",children:t("required")}),r.unique&&(0,a.jsx)(h,{variant:"secondary",children:t("unique")})]})]},r.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]=s,e[13]=m,e[14]=t,e[15]=x):x=e[15];let b;return e[16]!==g||e[17]!==f||e[18]!==x?(b=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"auth-config",children:[g,f,x]}),e[16]=g,e[17]=f,e[18]=x,e[19]=b):b=e[19],b},"O");function C(e){return(0,a.jsx)(h,{"data-testid":`auth-config-plugin-${e}`,variant:"outline",children:e},e)}u(C,"P");function L(e){return(0,a.jsx)(h,{"data-testid":`auth-config-provider-${e}`,variant:"outline",children:e},e)}u(L,"z");export{M as default};
@@ -1 +1 @@
1
- import{a as Ze}from"./chunk-7RKB5KS7.js";import{a as qe}from"./chunk-SFMWHWJG.js";import{a as Ke}from"./chunk-WVWCUB4S.js";import{a as He}from"./chunk-QJLHH3ET.js";import{a as O}from"./chunk-37WYCOQ2.js";import{a as Je}from"./chunk-VQRCJJXS.js";import"./chunk-PSMQQV6S.js";import{a as We}from"./chunk-EYTZURBK.js";import{a as Xe}from"./chunk-IWZ7GVQO.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import{i as T}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as _}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as D}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{b as De}from"./chunk-DFVQBXUZ.js";import{l as J}from"./chunk-RGDSRUIX.js";import"./chunk-QAQDMS6R.js";import"./chunk-35Q6XYRL.js";import{a as Ve}from"./chunk-RWVIV3U7.js";import{a as ze,b as _e,c as Pe,d as q,e as U,f as z}from"./chunk-HCTJKP5J.js";import{a as K,e as X}from"./chunk-2IKDEUCX.js";import{d as Q,h as Ee,p as Ue,q as Z,s as Qe,u as te}from"./chunk-74IYYDDI.js";import{a as s,d as Me,e as at,f as lt,g as nt}from"./chunk-I26MS5PJ.js";var C=Me(at(),1);var W=Me(lt(),1);var t=Me(nt(),1);var it=s(()=>{let h=(0,W.c)(3),{config:e,ready:n}=qe(),l;return h[0]!==e.capabilities||h[1]!==n?(l={capabilities:e.capabilities,ready:n},h[0]=e.capabilities,h[1]=n,h[2]=l):l=h[2],l},"nt"),st=s((h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending","lt"),et=500,rt=s((h,e)=>{if(!URL.canParse(h.trim()))return null;let n=new URL(h.trim());return n.searchParams.set("email",e.email),n.searchParams.set("invite",e.token),n.toString()},"at"),dt=s(h=>{let e=(0,W.c)(34),{issued:n,onSignUpPageChange:l,signUpPage:o}=h,a=Q(),[p,i]=(0,C.useState)(null),u;e[0]!==n||e[1]!==o?(u=rt(o,n),e[0]=n,e[1]=o,e[2]=u):u=e[2];let c=u,y;e[3]!==c?(y=s(()=>{let $="navigator"in globalThis?globalThis.navigator.clipboard:void 0;c===null||$===void 0||Z($.writeText(c).then(()=>(i(c),!0)))},"y"),e[3]=c,e[4]=y):y=e[4];let w=y,g;e[5]!==a?(g=a("Send this link to the invitee. It is shown once and cannot be recovered."),e[5]=a,e[6]=g):g=e[6];let I;e[7]!==g?(I=(0,t.jsx)("p",{className:"text-sm",children:g}),e[7]=g,e[8]=I):I=e[8];let k=c===null,v;e[9]!==a?(v=a("Your app's sign-up page"),e[9]=a,e[10]=v):v=e[10];let d;e[11]!==l?(d=s($=>{l($.target.value)},"r"),e[11]=l,e[12]=d):d=e[12];let m;e[13]!==o||e[14]!==k||e[15]!==v||e[16]!==d?(m=(0,t.jsx)(T,{"aria-invalid":k,"aria-label":v,"data-testid":"sign-up-invitation-page",onChange:d,value:o}),e[13]=o,e[14]=k,e[15]=v,e[16]=d,e[17]=m):m=e[17];let b=c??"",x;e[18]!==b?(x=(0,t.jsx)(T,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:b}),e[18]=b,e[19]=x):x=e[19];let N;e[20]!==p||e[21]!==c||e[22]!==a?(N=a(p!==null&&p===c?"Copied":"Copy"),e[20]=p,e[21]=c,e[22]=a,e[23]=N):N=e[23];let f;e[24]!==w||e[25]!==N?(f=(0,t.jsx)(_,{"data-testid":"sign-up-invitation-copy",onClick:w,type:"button",children:N}),e[24]=w,e[25]=N,e[26]=f):f=e[26];let r;e[27]!==x||e[28]!==f?(r=(0,t.jsxs)("div",{className:"flex gap-2",children:[x,f]}),e[27]=x,e[28]=f,e[29]=r):r=e[29];let S;return e[30]!==r||e[31]!==I||e[32]!==m?(S=(0,t.jsx)(K,{children:(0,t.jsxs)(X,{className:"flex flex-col gap-2 p-4",children:[I,m,r]})}),e[30]=r,e[31]=I,e[32]=m,e[33]=S):S=e[33],S},"it"),ot=s(()=>{let h=J(),e=Q(),[n,l]=(0,C.useState)(""),[o,a]=(0,C.useState)(null),[p,i]=(0,C.useState)(null),[u,c]=(0,C.useState)(()=>`${Qe(h.url)}/sign-up`),y=De(["lunora-auth-sign-up-invitations",et],()=>h.listAuthSignUpInvitations({limit:et})),w=y.data?.rows??null,g=y.data?.total??0,I=s(()=>{let v=n.trim();v!==""&&(a(null),Z((async()=>{try{let d=await h.createAuthSignUpInvitation({email:v}),m=typeof d.token=="string"?d.token:void 0;i(m===void 0?null:{email:v,token:m}),l(""),y.refetch()}catch(d){a(d instanceof Error?d.message:String(d))}})()))},"w"),k=s(v=>{a(null),Z((async()=>{try{await h.revokeAuthSignUpInvitation({email:v}),y.refetch()}catch(d){a(d instanceof Error?d.message:String(d))}})())},"k");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"sign-up-invitations",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-base font-medium",children:e("Sign-up invitations")}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("Only invited addresses can create an account. Nothing is emailed \u2014 send the invitee the one-time link yourself.")})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(T,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:s(v=>{l(v.target.value)},"onChange"),placeholder:e("ada@example.com"),type:"email",value:n}),(0,t.jsx)(_,{"data-testid":"sign-up-invitation-submit",onClick:I,type:"button",children:e("Invite")})]}),p!==null&&(0,t.jsx)(dt,{issued:p,onSignUpPageChange:c,signUpPage:u},p.token),(o??y.error)!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:o??y.error}),w!==null&&w.length===0&&(0,t.jsx)(Ve,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),w!==null&&g>w.length&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sign-up-invitations-truncated",children:e("Showing the most recent invitations. Query the signUpInvitation table directly to see the rest.")}),w!==null&&w.length>0&&(0,t.jsx)(K,{children:(0,t.jsx)(X,{className:"p-0",children:(0,t.jsxs)(ze,{children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:e("Email")}),(0,t.jsx)(U,{children:e("Status")}),(0,t.jsx)(U,{children:e("Expires")}),(0,t.jsx)(U,{children:e("Invited by")}),(0,t.jsx)(U,{})]})}),(0,t.jsx)(Pe,{children:w.map(v=>{let d=st(v,Date.now()),m=v.email??"";return(0,t.jsxs)(q,{"data-testid":`sign-up-invitation-${m}`,children:[(0,t.jsx)(z,{children:m}),(0,t.jsxs)(z,{"data-testid":`sign-up-invitation-status-${m}`,children:[d==="spent"&&e("Accepted"),d==="expired"&&e("Expired"),d==="pending"&&e("Pending")]}),(0,t.jsx)(z,{children:typeof v.expiresAt=="number"?te(v.expiresAt):"\u2014"}),(0,t.jsx)(z,{children:v.invitedBy??"\u2014"}),(0,t.jsx)(z,{className:"text-right",children:(0,t.jsx)(_,{onClick:s(()=>{k(m)},"onClick"),type:"button",variant:"ghost",children:e("Revoke")})})]},v.id)})})]})})})]})},"rt"),ct={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},ut=s((h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),"dt"),mt=s((h,e)=>{if(h.type==="boolean")return e===!0?{value:!0}:h.required?{value:!1}:void 0;let n=typeof e=="string"?e.trim():"";if(n!==""){if(h.type==="number"){let l=Number(n);return Number.isNaN(l)?void 0:{value:l}}return{value:n}}},"ct"),ht=s(h=>{let e=(0,W.c)(105),{onClose:n,onCreated:l}=h,o=J(),a=Q(),{config:p}=qe(),{busy:i,error:u,run:c}=Ke(),[y,w]=(0,C.useState)(""),[g,I]=(0,C.useState)(""),[k,v]=(0,C.useState)(""),[d,m]=(0,C.useState)(""),b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];let[x,N]=(0,C.useState)(b),f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=s(A=>{w(A.target.value)},"p"),e[1]=f):f=e[1];let r=f,S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=s(A=>{I(A.target.value)},"I"),e[2]=S):S=e[2];let $=S,j;e[3]===Symbol.for("react.memo_cache_sentinel")?(j=s(A=>{v(A.target.value)},"z"),e[3]=j):j=e[3];let H=j,M;e[4]===Symbol.for("react.memo_cache_sentinel")?(M=s(A=>{m(A.target.value)},"M"),e[4]=M):M=e[4];let Y=M,B;e[5]===Symbol.for("react.memo_cache_sentinel")?(B=s((A,R)=>{N(ee=>({...ee,[A]:R}))},"L"),e[5]=B):B=e[5];let V=B,G;e[6]!==x?(G=s(A=>x[A.name]??(A.type==="boolean"?!1:""),"Y"),e[6]=x,e[7]=G):G=e[7];let P=G,L;if(e[8]!==p.userFields||e[9]!==P){let A;e[11]!==P?(A=s(R=>!R.required||ut(R,P(R)),"A"),e[11]=P,e[12]=A):A=e[12],L=p.userFields.every(A),e[8]=p.userFields,e[9]=P,e[10]=L}else L=e[10];let F=L,E;e[13]!==i||e[14]!==y||e[15]!==g||e[16]!==F?(E=!i&&y.trim()!==""&&g.trim()!==""&&F,e[13]=i,e[14]=y,e[15]=g,e[16]=F,e[17]=E):E=e[17];let $e=E,ae;e[18]!==p.userFields||e[19]!==P?(ae=s(()=>{let A={};for(let R of p.userFields){let ee=mt(R,P(R));ee!==void 0&&(A[R.name]=ee.value)}return Object.keys(A).length===0?void 0:A},"te"),e[18]=p.userFields,e[19]=P,e[20]=ae):ae=e[20];let je=ae,Re;e[21]!==je||e[22]!==o||e[23]!==y||e[24]!==g||e[25]!==n||e[26]!==l||e[27]!==k||e[28]!==d||e[29]!==c?(Re=s(()=>{c(async()=>{await o.createAuthUser({data:je(),email:y.trim(),name:g.trim(),password:k===""?void 0:k,role:d.trim()===""?void 0:d.trim()}),l(),n()})},"De"),e[21]=je,e[22]=o,e[23]=y,e[24]=g,e[25]=n,e[26]=l,e[27]=k,e[28]=d,e[29]=c,e[30]=Re):Re=e[30];let Be=Re,le;e[31]!==a?(le=a("Create user"),e[31]=a,e[32]=le):le=e[32];let ne;e[33]!==a?(ne=a("Create user"),e[33]=a,e[34]=ne):ne=e[34];let ie;e[35]!==ne?(ie=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:ne}),e[35]=ne,e[36]=ie):ie=e[36];let se;e[37]!==a?(se=a("email"),e[37]=a,e[38]=se):se=e[38];let re;e[39]!==se?(re=(0,t.jsx)(O,{htmlFor:"uc-email",children:se}),e[39]=se,e[40]=re):re=e[40];let de;e[41]!==y?(de=(0,t.jsx)(T,{"data-testid":"uc-email",id:"uc-email",onChange:r,type:"email",value:y}),e[41]=y,e[42]=de):de=e[42];let oe;e[43]!==re||e[44]!==de?(oe=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[re,de]}),e[43]=re,e[44]=de,e[45]=oe):oe=e[45];let ce;e[46]!==a?(ce=a("name"),e[46]=a,e[47]=ce):ce=e[47];let ue;e[48]!==ce?(ue=(0,t.jsx)(O,{htmlFor:"uc-name",children:ce}),e[48]=ce,e[49]=ue):ue=e[49];let me;e[50]!==g?(me=(0,t.jsx)(T,{"data-testid":"uc-name",id:"uc-name",onChange:$,value:g}),e[50]=g,e[51]=me):me=e[51];let he;e[52]!==ue||e[53]!==me?(he=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[ue,me]}),e[52]=ue,e[53]=me,e[54]=he):he=e[54];let pe;e[55]!==a?(pe=a("Password (optional)"),e[55]=a,e[56]=pe):pe=e[56];let fe;e[57]!==pe?(fe=(0,t.jsx)(O,{htmlFor:"uc-password",children:pe}),e[57]=pe,e[58]=fe):fe=e[58];let ve;e[59]!==k?(ve=(0,t.jsx)(T,{"data-testid":"uc-password",id:"uc-password",onChange:H,type:"password",value:k}),e[59]=k,e[60]=ve):ve=e[60];let ge;e[61]!==fe||e[62]!==ve?(ge=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[fe,ve]}),e[61]=fe,e[62]=ve,e[63]=ge):ge=e[63];let be;e[64]!==a?(be=a("Role (optional)"),e[64]=a,e[65]=be):be=e[65];let xe;e[66]!==be?(xe=(0,t.jsx)(O,{htmlFor:"uc-role",children:be}),e[66]=be,e[67]=xe):xe=e[67];let ye;e[68]!==d?(ye=(0,t.jsx)(T,{"data-testid":"uc-role",id:"uc-role",onChange:Y,value:d}),e[68]=d,e[69]=ye):ye=e[69];let Ne;e[70]!==xe||e[71]!==ye?(Ne=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[xe,ye]}),e[70]=xe,e[71]=ye,e[72]=Ne):Ne=e[72];let ke;e[73]!==p.userFields||e[74]!==P||e[75]!==a?(ke=p.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")}),p.userFields.map(A=>{let R=`uc-field-${A.name}`,ee=A.required?"":` (${a("optional")})`;if(A.type==="boolean"){let Oe=P(A)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:R,children:[(0,t.jsx)(Ze,{checked:Oe,"data-testid":R,id:R,onCheckedChange:s(tt=>{V(A.name,tt)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[A.name,ee]})]},A.name)}let Ge=P(A);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(O,{htmlFor:R,children:[A.name,ee]}),(0,t.jsx)(T,{"data-testid":R,id:R,onChange:s(Oe=>{V(A.name,Oe.target.value)},"onChange"),type:ct[A.type],value:typeof Ge=="string"?Ge:""})]},A.name)})]}),e[73]=p.userFields,e[74]=P,e[75]=a,e[76]=ke):ke=e[76];let we;e[77]!==u?(we=u!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:u}),e[77]=u,e[78]=we):we=e[78];let Ce;e[79]!==a?(Ce=a("Cancel"),e[79]=a,e[80]=Ce):Ce=e[80];let Ie;e[81]!==n||e[82]!==Ce?(Ie=(0,t.jsx)(_,{"data-testid":"uc-cancel",onClick:n,size:"sm",type:"button",variant:"outline",children:Ce}),e[81]=n,e[82]=Ce,e[83]=Ie):Ie=e[83];let Le=!$e,Ae;e[84]!==i||e[85]!==a?(Ae=a(i?"Creating\u2026":"Create"),e[84]=i,e[85]=a,e[86]=Ae):Ae=e[86];let Se;e[87]!==Be||e[88]!==Le||e[89]!==Ae?(Se=(0,t.jsx)(_,{"data-testid":"uc-submit",disabled:Le,onClick:Be,size:"sm",type:"button",children:Ae}),e[87]=Be,e[88]=Le,e[89]=Ae,e[90]=Se):Se=e[90];let Fe;e[91]!==Ie||e[92]!==Se?(Fe=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[Ie,Se]}),e[91]=Ie,e[92]=Se,e[93]=Fe):Fe=e[93];let Te;return e[94]!==n||e[95]!==le||e[96]!==ie||e[97]!==oe||e[98]!==he||e[99]!==ge||e[100]!==Ne||e[101]!==ke||e[102]!==we||e[103]!==Fe?(Te=(0,t.jsxs)(He,{label:le,onClose:n,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[ie,oe,he,ge,Ne,ke,we,Fe]}),e[94]=n,e[95]=le,e[96]=ie,e[97]=oe,e[98]=he,e[99]=ge,e[100]=Ne,e[101]=ke,e[102]=we,e[103]=Fe,e[104]=Te):Te=e[104],Te},"ut"),Ye=s(h=>{let e=(0,W.c)(2),{children:n}=h,l;return e[0]!==n?(l=(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n}),e[0]=n,e[1]=l):l=e[1],l},"_e"),pt=s(h=>{let e=(0,W.c)(29),{busy:n,runAction:l,userId:o,version:a}=h,p=J(),i=Q(),[u,c]=(0,C.useState)(null),[y,w]=(0,C.useState)(null),g;e[0]!==p||e[1]!==o?(g=s(()=>{Z((async()=>{w(null);try{let r=await p.listAuthSessions({limit:50,userId:o});c(r.rows)}catch(r){let S=r;c(null),w(Ee(S))}})())},"g"),e[0]=p,e[1]=o,e[2]=g):g=e[2];let I;e[3]!==p||e[4]!==o||e[5]!==a?(I=[p,o,a],e[3]=p,e[4]=o,e[5]=a,e[6]=I):I=e[6],(0,C.useEffect)(g,I);let k;e[7]!==p||e[8]!==l?(k=s(r=>{l(()=>p.revokeAuthSession({sessionId:r}))},"k"),e[7]=p,e[8]=l,e[9]=k):k=e[9];let v=k,d;e[10]!==i?(d=i("Sessions"),e[10]=i,e[11]=d):d=e[11];let m;e[12]!==d?(m=(0,t.jsx)(Ye,{children:d}),e[12]=d,e[13]=m):m=e[13];let b;e[14]!==y?(b=y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:y}),e[14]=y,e[15]=b):b=e[15];let x;e[16]!==u||e[17]!==i?(x=u!==null&&u.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:i("No active sessions.")}),e[16]=u,e[17]=i,e[18]=x):x=e[18];let N;e[19]!==n||e[20]!==v||e[21]!==u||e[22]!==i?(N=u!==null&&u.length>0&&(0,t.jsx)(K,{className:"overflow-hidden py-0",children:(0,t.jsx)(X,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{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)(Pe,{children:u.map(r=>(0,t.jsxs)(q,{"data-testid":`ud-session-${r.id}`,children:[(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.expiresAt)}),(0,t.jsx)(z,{children:r.ipAddress??""}),(0,t.jsx)(z,{className:"max-w-40 truncate",children:r.userAgent??""}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-revoke-${r.id}`,disabled:n,onClick:s(()=>{v(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Revoke")})})]},r.id))})]})})}),e[19]=n,e[20]=v,e[21]=u,e[22]=i,e[23]=N):N=e[23];let f;return e[24]!==m||e[25]!==b||e[26]!==x||e[27]!==N?(f=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[m,b,x,N]}),e[24]=m,e[25]=b,e[26]=x,e[27]=N,e[28]=f):f=e[28],f},"mt"),ft=s(h=>{let e=(0,W.c)(30),{busy:n,runAction:l,userId:o,version:a}=h,p=J(),i=Q(),[u,c]=(0,C.useState)(null),[y,w]=(0,C.useState)(null),g;e[0]!==p||e[1]!==o?(g=s(()=>{Z((async()=>{w(null);try{c(await p.listAuthAccounts({userId:o}))}catch(r){let S=r;c(null),w(Ee(S))}})())},"g"),e[0]=p,e[1]=o,e[2]=g):g=e[2];let I;e[3]!==p||e[4]!==o||e[5]!==a?(I=[p,o,a],e[3]=p,e[4]=o,e[5]=a,e[6]=I):I=e[6],(0,C.useEffect)(g,I);let k;e[7]!==p||e[8]!==l||e[9]!==o?(k=s(r=>{l(()=>p.unlinkAuthAccount({accountId:r,userId:o}))},"k"),e[7]=p,e[8]=l,e[9]=o,e[10]=k):k=e[10];let v=k,d;e[11]!==i?(d=i("Linked accounts"),e[11]=i,e[12]=d):d=e[12];let m;e[13]!==d?(m=(0,t.jsx)(Ye,{children:d}),e[13]=d,e[14]=m):m=e[14];let b;e[15]!==y?(b=y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:y}),e[15]=y,e[16]=b):b=e[16];let x;e[17]!==u||e[18]!==i?(x=u!==null&&u.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:i("No linked accounts.")}),e[17]=u,e[18]=i,e[19]=x):x=e[19];let N;e[20]!==u||e[21]!==n||e[22]!==v||e[23]!==i?(N=u!==null&&u.length>0&&(0,t.jsx)(K,{className:"overflow-hidden py-0",children:(0,t.jsx)(X,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{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)(Pe,{children:u.map(r=>{let S=Ue(r.id);return(0,t.jsxs)(q,{"data-testid":`ud-account-${S}`,children:[(0,t.jsx)(z,{children:Ue(r.providerId)}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-unlink-${S}`,disabled:n,onClick:s(()=>{v(S)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Unlink")})})]},S)})})]})})}),e[20]=u,e[21]=n,e[22]=v,e[23]=i,e[24]=N):N=e[24];let f;return e[25]!==m||e[26]!==b||e[27]!==x||e[28]!==N?(f=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[m,b,x,N]}),e[25]=m,e[26]=b,e[27]=x,e[28]=N,e[29]=f):f=e[29],f},"ht"),vt=s(h=>{let e=(0,W.c)(40),{busy:n,capabilities:l,runAction:o,userId:a,version:p}=h,i=J(),u=Q(),[c,y]=(0,C.useState)(null),w;e[0]!==l.passkey||e[1]!==i||e[2]!==a?(w=s(()=>{l.passkey&&Z((async()=>{try{y(await i.listAuthPasskeys({userId:a}))}catch{y(null)}})())},"C"),e[0]=l.passkey,e[1]=i,e[2]=a,e[3]=w):w=e[3];let g;e[4]!==l.passkey||e[5]!==i||e[6]!==a||e[7]!==p?(g=[l.passkey,i,a,p],e[4]=l.passkey,e[5]=i,e[6]=a,e[7]=p,e[8]=g):g=e[8],(0,C.useEffect)(w,g);let I;e[9]!==i||e[10]!==o||e[11]!==a?(I=s(()=>{o(()=>i.disableAuthTwoFactor({userId:a}))},"w"),e[9]=i,e[10]=o,e[11]=a,e[12]=I):I=e[12];let k=I,v;e[13]!==i||e[14]!==o?(v=s(S=>{o(()=>i.deleteAuthPasskey({passkeyId:S}))},"v"),e[13]=i,e[14]=o,e[15]=v):v=e[15];let d=v,m;e[16]!==u?(m=u("Security"),e[16]=u,e[17]=m):m=e[17];let b;e[18]!==m?(b=(0,t.jsx)(Ye,{children:m}),e[18]=m,e[19]=b):b=e[19];let x;e[20]!==n||e[21]!==l.twoFactor||e[22]!==k||e[23]!==u?(x=l.twoFactor&&(0,t.jsx)(_,{"data-testid":"ud-disable-2fa",disabled:n,onClick:k,size:"sm",type:"button",variant:"outline",children:u("Disable two-factor")}),e[20]=n,e[21]=l.twoFactor,e[22]=k,e[23]=u,e[24]=x):x=e[24];let N;e[25]!==l.passkey||e[26]!==c||e[27]!==u?(N=l.passkey&&c!==null&&c.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:u("No passkeys.")}),e[25]=l.passkey,e[26]=c,e[27]=u,e[28]=N):N=e[28];let f;e[29]!==n||e[30]!==l.passkey||e[31]!==d||e[32]!==c||e[33]!==u?(f=l.passkey&&c!==null&&c.length>0&&(0,t.jsx)(K,{className:"overflow-hidden py-0",children:(0,t.jsx)(X,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-passkeys-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:u("name")}),(0,t.jsx)(U,{children:u("created")}),(0,t.jsx)(U,{"aria-label":u("Actions")})]})}),(0,t.jsx)(Pe,{children:c.map(S=>{let $=Ue(S.id);return(0,t.jsxs)(q,{"data-testid":`ud-passkey-${$}`,children:[(0,t.jsx)(z,{children:Ue(S.name)||$}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(S.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-delete-passkey-${$}`,disabled:n,onClick:s(()=>{d($)},"onClick"),size:"xs",type:"button",variant:"ghost",children:u("Delete")})})]},$)})})]})})}),e[29]=n,e[30]=l.passkey,e[31]=d,e[32]=c,e[33]=u,e[34]=f):f=e[34];let r;return e[35]!==b||e[36]!==x||e[37]!==N||e[38]!==f?(r=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[b,x,N,f]}),e[35]=b,e[36]=x,e[37]=N,e[38]=f,e[39]=r):r=e[39],r},"ft"),gt=/(?:at|expires)$/iu,bt=/^[1-9]\d*$/u,xt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),yt=s(h=>{let e=(0,W.c)(51),{busy:n,onBan:l}=h,o=Q(),[a,p]=(0,C.useState)(""),[i,u]=(0,C.useState)(""),[c,y]=(0,C.useState)(!1),w;e[0]!==i?(w=bt.test(i.trim())&&Number.isSafeInteger(Number(i.trim())*86400)?Number(i.trim()):void 0,e[0]=i,e[1]=w):w=e[1];let g=w,I=c||g!==void 0,k;e[2]!==l||e[3]!==c||e[4]!==a||e[5]!==g?(k=s(()=>{l({expiresInSeconds:c||g===void 0?void 0:g*86400,reason:a.trim()===""?void 0:a.trim()})},"k"),e[2]=l,e[3]=c,e[4]=a,e[5]=g,e[6]=k):k=e[6];let v=k,d;e[7]!==o?(d=o("Ban reason (optional)"),e[7]=o,e[8]=d):d=e[8];let m;e[9]!==d?(m=(0,t.jsx)(O,{htmlFor:"ud-ban-reason",children:d}),e[9]=d,e[10]=m):m=e[10];let b;e[11]===Symbol.for("react.memo_cache_sentinel")?(b=s(E=>{p(E.target.value)},"b"),e[11]=b):b=e[11];let x;e[12]!==a?(x=(0,t.jsx)(T,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:b,value:a}),e[12]=a,e[13]=x):x=e[13];let N;e[14]!==m||e[15]!==x?(N=(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[m,x]}),e[14]=m,e[15]=x,e[16]=N):N=e[16];let f;e[17]!==o?(f=o("Days"),e[17]=o,e[18]=f):f=e[18];let r;e[19]!==f?(r=(0,t.jsx)(O,{htmlFor:"ud-ban-days",children:f}),e[19]=f,e[20]=r):r=e[20];let S;e[21]!==i||e[22]!==g?(S=i.trim()!==""&&g===void 0,e[21]=i,e[22]=g,e[23]=S):S=e[23];let $;e[24]===Symbol.for("react.memo_cache_sentinel")?($=s(E=>{u(E.target.value)},"T"),e[24]=$):$=e[24];let j;e[25]!==i||e[26]!==c||e[27]!==S?(j=(0,t.jsx)(T,{"aria-invalid":S,"data-testid":"ud-ban-days",disabled:c,id:"ud-ban-days",min:1,onChange:$,step:1,type:"number",value:i}),e[25]=i,e[26]=c,e[27]=S,e[28]=j):j=e[28];let H;e[29]!==j||e[30]!==r?(H=(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[r,j]}),e[29]=j,e[30]=r,e[31]=H):H=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=s(E=>{y(E.target.checked)},"M"),e[32]=M):M=e[32];let Y;e[33]!==c?(Y=(0,t.jsx)("input",{checked:c,className:"size-4 accent-destructive","data-testid":"ud-ban-permanent",id:"ud-ban-permanent",onChange:M,type:"checkbox"}),e[33]=c,e[34]=Y):Y=e[34];let B;e[35]!==o?(B=o("Permanent"),e[35]=o,e[36]=B):B=e[36];let V;e[37]!==Y||e[38]!==B?(V=(0,t.jsxs)(O,{className:"flex items-center gap-1.5 pb-2 text-xs font-normal",htmlFor:"ud-ban-permanent",children:[Y,B]}),e[37]=Y,e[38]=B,e[39]=V):V=e[39];let G=n||!I,P;e[40]!==o?(P=o("Ban user"),e[40]=o,e[41]=P):P=e[41];let L;e[42]!==v||e[43]!==G||e[44]!==P?(L=(0,t.jsx)(_,{"data-testid":"ud-ban",disabled:G,onClick:v,size:"sm",type:"button",variant:"destructive",children:P}),e[42]=v,e[43]=G,e[44]=P,e[45]=L):L=e[45];let F;return e[46]!==H||e[47]!==V||e[48]!==L||e[49]!==N?(F=(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[N,H,V,L]}),e[46]=H,e[47]=V,e[48]=L,e[49]=N,e[50]=F):F=e[50],F},"bt"),Nt=s((h,e)=>typeof e=="number"&&gt.test(h)?te(e):Ue(e),"xt"),kt=s(({capabilities:h,onChanged:e,onClose:n,user:l})=>{let o=J(),a=Q(),p=l.banned===!0,[i,u]=(0,C.useState)(null),[c,y]=(0,C.useState)(!1),[w,g]=(0,C.useState)(0),[I,k]=(0,C.useState)(typeof l.role=="string"?l.role:""),[v,d]=(0,C.useState)(""),[m,b]=(0,C.useState)(null),[x,N]=(0,C.useState)(!1),f=s((F,E)=>{Z((async()=>{y(!0),u(null);try{let $e=await F();E?.refresh!==!1&&(g(ae=>ae+1),e()),E?.onResult?.($e)}catch($e){u(Ee($e))}y(!1)})())},"p"),r=s(F=>{k(F.target.value)},"i"),S=s(F=>{d(F.target.value)},"I"),$=s(()=>{let F=I.trim();F!==""&&f(async()=>{await o.setAuthUserRole({role:F,userId:l.id})})},"T"),j=s(F=>{f(async()=>{await o.banAuthUser({...F,userId:l.id})})},"z"),H=s(()=>{f(async()=>{await o.unbanAuthUser({userId:l.id})})},"j"),M=s(()=>{f(async()=>{await o.setAuthUserPassword({newPassword:v,userId:l.id}),d("")})},"M"),Y=s(()=>{f(()=>o.impersonateAuthUser({userId:l.id}),{onResult:s(F=>{b(F.token)},"onResult"),refresh:!1})},"H"),B=s(()=>{f(async()=>{await o.revokeAuthUserSessions({userId:l.id})})},"L"),V=s(()=>{f(async()=>{await o.removeAuthUser({userId:l.id}),n()})},"V"),G=s(()=>{N(!0)},"Y"),P=s(()=>{N(!1)},"E"),L=Object.entries(l).filter(([F])=>!xt.has(F));return(0,t.jsxs)(He,{label:a("User details"),onClose:n,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:l.name??l.email??l.id}),(0,t.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:l.id}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof l.role=="string"&&l.role!==""&&(0,t.jsx)(D,{variant:"secondary",children:l.role}),p?(0,t.jsx)(D,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(D,{variant:"outline",children:a("Active")}),l.emailVerified===!0?(0,t.jsx)(D,{variant:"secondary",children:a("verified")}):(0,t.jsx)(D,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(_,{"data-testid":"ud-close",onClick:n,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}),h.admin&&(0,t.jsxs)(K,{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)(X,{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)(O,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(T,{"data-testid":"ud-role-input",id:"ud-role",onChange:r,value:I})]}),(0,t.jsx)(_,{"data-testid":"ud-set-role",disabled:c||I.trim()==="",onClick:$,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),p?(0,t.jsx)(_,{"data-testid":"ud-unban",disabled:c,onClick:H,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(0,t.jsx)(yt,{busy:c,onBan:j}),(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)(O,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(T,{"data-testid":"ud-password",id:"ud-password",onChange:S,type:"password",value:v})]}),(0,t.jsx)(_,{"data-testid":"ud-set-password",disabled:c||v==="",onClick:M,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(_,{"data-testid":"ud-impersonate",disabled:c,onClick:Y,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(_,{"data-testid":"ud-revoke-all",disabled:c,onClick:B,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),x?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(_,{"data-testid":"ud-delete-confirm",disabled:c,onClick:V,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(_,{"data-testid":"ud-delete-cancel",onClick:P,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(_,{"data-testid":"ud-delete",disabled:c,onClick:G,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),m!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(O,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(T,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:m})]})]})]}),(0,t.jsx)(pt,{busy:c,runAction:f,userId:l.id,version:w}),h.accounts&&(0,t.jsx)(ft,{busy:c,runAction:f,userId:l.id,version:w}),(h.twoFactor||h.passkey)&&(0,t.jsx)(vt,{busy:c,capabilities:h,runAction:f,userId:l.id,version:w}),(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:L.map(([F,E])=>(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:F}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:Nt(F,E)})]},F))})]})]})},"yt"),wt=50,Vt=s(({pageSize:h=wt}={})=>{let e=J(),n=Q(),[l,o]=(0,C.useState)(""),[a,p]=(0,C.useState)(""),[i,u]=(0,C.useState)(0),c=Xe(l),[y,w]=(0,C.useState)(null),[g,I]=(0,C.useState)(!1),{capabilities:k}=it(),v=c.trim(),d=a.trim(),m=De(["lunora-auth-users",v,d,h,i],()=>e.listAuthUsers({filterField:d===""?void 0:"role",filterValue:d===""?void 0:d,limit:h,offset:i,search:v===""?void 0:v}).then(r=>({...r,offset:i})),{keepPreviousData:!0}),b=m.data?.rows??null,x=m.error,N=s(()=>{m.refetch()},"N");We(()=>m.poll(),!0);let f=y===null?null:b?.find(r=>r.id===y)??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)(T,{"aria-label":n("Search users"),className:"w-56","data-testid":"us-search",onChange:s(r=>{o(r.target.value),u(0)},"onChange"),placeholder:n("Search by email or name\u2026"),value:l}),(0,t.jsx)(T,{"aria-label":n("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:s(r=>{p(r.target.value),u(0)},"onChange"),placeholder:n("Filter by role"),value:a}),(0,t.jsx)(_,{"data-testid":"us-new",onClick:s(()=>{I(!0)},"onClick"),size:"sm",type:"button",children:n("New user")})]}),x!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:x}),b!==null&&b.length===0&&(0,t.jsx)(Ve,{description:n("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:n("No users.")}),b!==null&&b.length>0&&(0,t.jsx)(K,{className:"overflow-hidden py-0",children:(0,t.jsx)(X,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"us-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:n("id")}),(0,t.jsx)(U,{children:n("email")}),(0,t.jsx)(U,{children:n("name")}),(0,t.jsx)(U,{children:n("role")}),(0,t.jsx)(U,{children:n("status")}),(0,t.jsx)(U,{children:n("verified")}),(0,t.jsx)(U,{children:n("created")}),(0,t.jsx)(U,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Pe,{children:b.map(r=>(0,t.jsxs)(q,{"data-testid":`us-row-${r.id}`,children:[(0,t.jsx)(z,{className:"font-mono text-xs",children:r.id}),(0,t.jsx)(z,{children:r.email??""}),(0,t.jsx)(z,{children:r.name??""}),(0,t.jsx)(z,{children:typeof r.role=="string"&&r.role!==""?(0,t.jsx)(D,{variant:"secondary",children:r.role}):""}),(0,t.jsx)(z,{children:r.banned===!0?(0,t.jsx)(D,{variant:"destructive",children:n("Banned")}):(0,t.jsx)(D,{variant:"success",children:n("Active")})}),(0,t.jsx)(z,{children:r.emailVerified===!0?(0,t.jsx)(D,{variant:"success",children:n("yes")}):(0,t.jsx)(D,{variant:"outline",children:n("no")})}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`us-manage-${r.id}`,onClick:s(()=>{w(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Manage")})})]},r.id))})]})})}),b!==null&&(0,t.jsx)(Je,{count:b.length,offset:m.data?.offset??0,onOffsetChange:u,pageSize:h,prefix:"us",total:m.data?.total}),f!==null&&(0,t.jsx)(kt,{capabilities:k,onChanged:N,onClose:s(()=>{w(null)},"onClose"),user:f}),g&&(0,t.jsx)(ht,{onClose:s(()=>{I(!1)},"onClose"),onCreated:N}),k.inviteOnly&&(0,t.jsx)(ot,{})]})},"jt");export{Vt as UsersPanel};
1
+ import{a as Ze}from"./chunk-7RKB5KS7.js";import{a as qe}from"./chunk-XR2JH2A7.js";import{a as Ke}from"./chunk-WVWCUB4S.js";import{a as He}from"./chunk-QJLHH3ET.js";import{a as O}from"./chunk-37WYCOQ2.js";import{a as Je}from"./chunk-VQRCJJXS.js";import"./chunk-PSMQQV6S.js";import{a as We}from"./chunk-4TYCTORB.js";import{a as Xe}from"./chunk-IWZ7GVQO.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import{i as T}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as _}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as D}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{b as De}from"./chunk-T2JHVL34.js";import{l as J}from"./chunk-AVSMQPR3.js";import"./chunk-QAQDMS6R.js";import"./chunk-3I25WO3P.js";import{a as Ve}from"./chunk-RWVIV3U7.js";import{a as ze,b as _e,c as Pe,d as q,e as U,f as z}from"./chunk-HCTJKP5J.js";import{a as K,e as X}from"./chunk-2IKDEUCX.js";import{d as Q,h as Ee,p as Ue,q as Z,s as Qe,u as te}from"./chunk-74IYYDDI.js";import{a as s,d as Me,e as at,f as lt,g as nt}from"./chunk-I26MS5PJ.js";var C=Me(at(),1);var W=Me(lt(),1);var t=Me(nt(),1);var it=s(()=>{let h=(0,W.c)(3),{config:e,ready:n}=qe(),l;return h[0]!==e.capabilities||h[1]!==n?(l={capabilities:e.capabilities,ready:n},h[0]=e.capabilities,h[1]=n,h[2]=l):l=h[2],l},"nt"),st=s((h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending","lt"),et=500,rt=s((h,e)=>{if(!URL.canParse(h.trim()))return null;let n=new URL(h.trim());return n.searchParams.set("email",e.email),n.searchParams.set("invite",e.token),n.toString()},"at"),dt=s(h=>{let e=(0,W.c)(34),{issued:n,onSignUpPageChange:l,signUpPage:o}=h,a=Q(),[p,i]=(0,C.useState)(null),u;e[0]!==n||e[1]!==o?(u=rt(o,n),e[0]=n,e[1]=o,e[2]=u):u=e[2];let c=u,y;e[3]!==c?(y=s(()=>{let $="navigator"in globalThis?globalThis.navigator.clipboard:void 0;c===null||$===void 0||Z($.writeText(c).then(()=>(i(c),!0)))},"y"),e[3]=c,e[4]=y):y=e[4];let w=y,g;e[5]!==a?(g=a("Send this link to the invitee. It is shown once and cannot be recovered."),e[5]=a,e[6]=g):g=e[6];let I;e[7]!==g?(I=(0,t.jsx)("p",{className:"text-sm",children:g}),e[7]=g,e[8]=I):I=e[8];let k=c===null,v;e[9]!==a?(v=a("Your app's sign-up page"),e[9]=a,e[10]=v):v=e[10];let d;e[11]!==l?(d=s($=>{l($.target.value)},"r"),e[11]=l,e[12]=d):d=e[12];let m;e[13]!==o||e[14]!==k||e[15]!==v||e[16]!==d?(m=(0,t.jsx)(T,{"aria-invalid":k,"aria-label":v,"data-testid":"sign-up-invitation-page",onChange:d,value:o}),e[13]=o,e[14]=k,e[15]=v,e[16]=d,e[17]=m):m=e[17];let b=c??"",x;e[18]!==b?(x=(0,t.jsx)(T,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:b}),e[18]=b,e[19]=x):x=e[19];let N;e[20]!==p||e[21]!==c||e[22]!==a?(N=a(p!==null&&p===c?"Copied":"Copy"),e[20]=p,e[21]=c,e[22]=a,e[23]=N):N=e[23];let f;e[24]!==w||e[25]!==N?(f=(0,t.jsx)(_,{"data-testid":"sign-up-invitation-copy",onClick:w,type:"button",children:N}),e[24]=w,e[25]=N,e[26]=f):f=e[26];let r;e[27]!==x||e[28]!==f?(r=(0,t.jsxs)("div",{className:"flex gap-2",children:[x,f]}),e[27]=x,e[28]=f,e[29]=r):r=e[29];let S;return e[30]!==r||e[31]!==I||e[32]!==m?(S=(0,t.jsx)(K,{children:(0,t.jsxs)(X,{className:"flex flex-col gap-2 p-4",children:[I,m,r]})}),e[30]=r,e[31]=I,e[32]=m,e[33]=S):S=e[33],S},"it"),ot=s(()=>{let h=J(),e=Q(),[n,l]=(0,C.useState)(""),[o,a]=(0,C.useState)(null),[p,i]=(0,C.useState)(null),[u,c]=(0,C.useState)(()=>`${Qe(h.url)}/sign-up`),y=De(["lunora-auth-sign-up-invitations",et],()=>h.listAuthSignUpInvitations({limit:et})),w=y.data?.rows??null,g=y.data?.total??0,I=s(()=>{let v=n.trim();v!==""&&(a(null),Z((async()=>{try{let d=await h.createAuthSignUpInvitation({email:v}),m=typeof d.token=="string"?d.token:void 0;i(m===void 0?null:{email:v,token:m}),l(""),y.refetch()}catch(d){a(d instanceof Error?d.message:String(d))}})()))},"w"),k=s(v=>{a(null),Z((async()=>{try{await h.revokeAuthSignUpInvitation({email:v}),y.refetch()}catch(d){a(d instanceof Error?d.message:String(d))}})())},"k");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"sign-up-invitations",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-base font-medium",children:e("Sign-up invitations")}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("Only invited addresses can create an account. Nothing is emailed \u2014 send the invitee the one-time link yourself.")})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(T,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:s(v=>{l(v.target.value)},"onChange"),placeholder:e("ada@example.com"),type:"email",value:n}),(0,t.jsx)(_,{"data-testid":"sign-up-invitation-submit",onClick:I,type:"button",children:e("Invite")})]}),p!==null&&(0,t.jsx)(dt,{issued:p,onSignUpPageChange:c,signUpPage:u},p.token),(o??y.error)!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:o??y.error}),w!==null&&w.length===0&&(0,t.jsx)(Ve,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),w!==null&&g>w.length&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sign-up-invitations-truncated",children:e("Showing the most recent invitations. Query the signUpInvitation table directly to see the rest.")}),w!==null&&w.length>0&&(0,t.jsx)(K,{children:(0,t.jsx)(X,{className:"p-0",children:(0,t.jsxs)(ze,{children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:e("Email")}),(0,t.jsx)(U,{children:e("Status")}),(0,t.jsx)(U,{children:e("Expires")}),(0,t.jsx)(U,{children:e("Invited by")}),(0,t.jsx)(U,{})]})}),(0,t.jsx)(Pe,{children:w.map(v=>{let d=st(v,Date.now()),m=v.email??"";return(0,t.jsxs)(q,{"data-testid":`sign-up-invitation-${m}`,children:[(0,t.jsx)(z,{children:m}),(0,t.jsxs)(z,{"data-testid":`sign-up-invitation-status-${m}`,children:[d==="spent"&&e("Accepted"),d==="expired"&&e("Expired"),d==="pending"&&e("Pending")]}),(0,t.jsx)(z,{children:typeof v.expiresAt=="number"?te(v.expiresAt):"\u2014"}),(0,t.jsx)(z,{children:v.invitedBy??"\u2014"}),(0,t.jsx)(z,{className:"text-right",children:(0,t.jsx)(_,{onClick:s(()=>{k(m)},"onClick"),type:"button",variant:"ghost",children:e("Revoke")})})]},v.id)})})]})})})]})},"rt"),ct={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},ut=s((h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),"dt"),mt=s((h,e)=>{if(h.type==="boolean")return e===!0?{value:!0}:h.required?{value:!1}:void 0;let n=typeof e=="string"?e.trim():"";if(n!==""){if(h.type==="number"){let l=Number(n);return Number.isNaN(l)?void 0:{value:l}}return{value:n}}},"ct"),ht=s(h=>{let e=(0,W.c)(105),{onClose:n,onCreated:l}=h,o=J(),a=Q(),{config:p}=qe(),{busy:i,error:u,run:c}=Ke(),[y,w]=(0,C.useState)(""),[g,I]=(0,C.useState)(""),[k,v]=(0,C.useState)(""),[d,m]=(0,C.useState)(""),b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];let[x,N]=(0,C.useState)(b),f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=s(A=>{w(A.target.value)},"p"),e[1]=f):f=e[1];let r=f,S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=s(A=>{I(A.target.value)},"I"),e[2]=S):S=e[2];let $=S,j;e[3]===Symbol.for("react.memo_cache_sentinel")?(j=s(A=>{v(A.target.value)},"z"),e[3]=j):j=e[3];let H=j,M;e[4]===Symbol.for("react.memo_cache_sentinel")?(M=s(A=>{m(A.target.value)},"M"),e[4]=M):M=e[4];let Y=M,B;e[5]===Symbol.for("react.memo_cache_sentinel")?(B=s((A,R)=>{N(ee=>({...ee,[A]:R}))},"L"),e[5]=B):B=e[5];let V=B,G;e[6]!==x?(G=s(A=>x[A.name]??(A.type==="boolean"?!1:""),"Y"),e[6]=x,e[7]=G):G=e[7];let P=G,L;if(e[8]!==p.userFields||e[9]!==P){let A;e[11]!==P?(A=s(R=>!R.required||ut(R,P(R)),"A"),e[11]=P,e[12]=A):A=e[12],L=p.userFields.every(A),e[8]=p.userFields,e[9]=P,e[10]=L}else L=e[10];let F=L,E;e[13]!==i||e[14]!==y||e[15]!==g||e[16]!==F?(E=!i&&y.trim()!==""&&g.trim()!==""&&F,e[13]=i,e[14]=y,e[15]=g,e[16]=F,e[17]=E):E=e[17];let $e=E,ae;e[18]!==p.userFields||e[19]!==P?(ae=s(()=>{let A={};for(let R of p.userFields){let ee=mt(R,P(R));ee!==void 0&&(A[R.name]=ee.value)}return Object.keys(A).length===0?void 0:A},"te"),e[18]=p.userFields,e[19]=P,e[20]=ae):ae=e[20];let je=ae,Re;e[21]!==je||e[22]!==o||e[23]!==y||e[24]!==g||e[25]!==n||e[26]!==l||e[27]!==k||e[28]!==d||e[29]!==c?(Re=s(()=>{c(async()=>{await o.createAuthUser({data:je(),email:y.trim(),name:g.trim(),password:k===""?void 0:k,role:d.trim()===""?void 0:d.trim()}),l(),n()})},"De"),e[21]=je,e[22]=o,e[23]=y,e[24]=g,e[25]=n,e[26]=l,e[27]=k,e[28]=d,e[29]=c,e[30]=Re):Re=e[30];let Be=Re,le;e[31]!==a?(le=a("Create user"),e[31]=a,e[32]=le):le=e[32];let ne;e[33]!==a?(ne=a("Create user"),e[33]=a,e[34]=ne):ne=e[34];let ie;e[35]!==ne?(ie=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:ne}),e[35]=ne,e[36]=ie):ie=e[36];let se;e[37]!==a?(se=a("email"),e[37]=a,e[38]=se):se=e[38];let re;e[39]!==se?(re=(0,t.jsx)(O,{htmlFor:"uc-email",children:se}),e[39]=se,e[40]=re):re=e[40];let de;e[41]!==y?(de=(0,t.jsx)(T,{"data-testid":"uc-email",id:"uc-email",onChange:r,type:"email",value:y}),e[41]=y,e[42]=de):de=e[42];let oe;e[43]!==re||e[44]!==de?(oe=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[re,de]}),e[43]=re,e[44]=de,e[45]=oe):oe=e[45];let ce;e[46]!==a?(ce=a("name"),e[46]=a,e[47]=ce):ce=e[47];let ue;e[48]!==ce?(ue=(0,t.jsx)(O,{htmlFor:"uc-name",children:ce}),e[48]=ce,e[49]=ue):ue=e[49];let me;e[50]!==g?(me=(0,t.jsx)(T,{"data-testid":"uc-name",id:"uc-name",onChange:$,value:g}),e[50]=g,e[51]=me):me=e[51];let he;e[52]!==ue||e[53]!==me?(he=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[ue,me]}),e[52]=ue,e[53]=me,e[54]=he):he=e[54];let pe;e[55]!==a?(pe=a("Password (optional)"),e[55]=a,e[56]=pe):pe=e[56];let fe;e[57]!==pe?(fe=(0,t.jsx)(O,{htmlFor:"uc-password",children:pe}),e[57]=pe,e[58]=fe):fe=e[58];let ve;e[59]!==k?(ve=(0,t.jsx)(T,{"data-testid":"uc-password",id:"uc-password",onChange:H,type:"password",value:k}),e[59]=k,e[60]=ve):ve=e[60];let ge;e[61]!==fe||e[62]!==ve?(ge=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[fe,ve]}),e[61]=fe,e[62]=ve,e[63]=ge):ge=e[63];let be;e[64]!==a?(be=a("Role (optional)"),e[64]=a,e[65]=be):be=e[65];let xe;e[66]!==be?(xe=(0,t.jsx)(O,{htmlFor:"uc-role",children:be}),e[66]=be,e[67]=xe):xe=e[67];let ye;e[68]!==d?(ye=(0,t.jsx)(T,{"data-testid":"uc-role",id:"uc-role",onChange:Y,value:d}),e[68]=d,e[69]=ye):ye=e[69];let Ne;e[70]!==xe||e[71]!==ye?(Ne=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[xe,ye]}),e[70]=xe,e[71]=ye,e[72]=Ne):Ne=e[72];let ke;e[73]!==p.userFields||e[74]!==P||e[75]!==a?(ke=p.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")}),p.userFields.map(A=>{let R=`uc-field-${A.name}`,ee=A.required?"":` (${a("optional")})`;if(A.type==="boolean"){let Oe=P(A)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:R,children:[(0,t.jsx)(Ze,{checked:Oe,"data-testid":R,id:R,onCheckedChange:s(tt=>{V(A.name,tt)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[A.name,ee]})]},A.name)}let Ge=P(A);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(O,{htmlFor:R,children:[A.name,ee]}),(0,t.jsx)(T,{"data-testid":R,id:R,onChange:s(Oe=>{V(A.name,Oe.target.value)},"onChange"),type:ct[A.type],value:typeof Ge=="string"?Ge:""})]},A.name)})]}),e[73]=p.userFields,e[74]=P,e[75]=a,e[76]=ke):ke=e[76];let we;e[77]!==u?(we=u!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:u}),e[77]=u,e[78]=we):we=e[78];let Ce;e[79]!==a?(Ce=a("Cancel"),e[79]=a,e[80]=Ce):Ce=e[80];let Ie;e[81]!==n||e[82]!==Ce?(Ie=(0,t.jsx)(_,{"data-testid":"uc-cancel",onClick:n,size:"sm",type:"button",variant:"outline",children:Ce}),e[81]=n,e[82]=Ce,e[83]=Ie):Ie=e[83];let Le=!$e,Ae;e[84]!==i||e[85]!==a?(Ae=a(i?"Creating\u2026":"Create"),e[84]=i,e[85]=a,e[86]=Ae):Ae=e[86];let Se;e[87]!==Be||e[88]!==Le||e[89]!==Ae?(Se=(0,t.jsx)(_,{"data-testid":"uc-submit",disabled:Le,onClick:Be,size:"sm",type:"button",children:Ae}),e[87]=Be,e[88]=Le,e[89]=Ae,e[90]=Se):Se=e[90];let Fe;e[91]!==Ie||e[92]!==Se?(Fe=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[Ie,Se]}),e[91]=Ie,e[92]=Se,e[93]=Fe):Fe=e[93];let Te;return e[94]!==n||e[95]!==le||e[96]!==ie||e[97]!==oe||e[98]!==he||e[99]!==ge||e[100]!==Ne||e[101]!==ke||e[102]!==we||e[103]!==Fe?(Te=(0,t.jsxs)(He,{label:le,onClose:n,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[ie,oe,he,ge,Ne,ke,we,Fe]}),e[94]=n,e[95]=le,e[96]=ie,e[97]=oe,e[98]=he,e[99]=ge,e[100]=Ne,e[101]=ke,e[102]=we,e[103]=Fe,e[104]=Te):Te=e[104],Te},"ut"),Ye=s(h=>{let e=(0,W.c)(2),{children:n}=h,l;return e[0]!==n?(l=(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n}),e[0]=n,e[1]=l):l=e[1],l},"_e"),pt=s(h=>{let e=(0,W.c)(29),{busy:n,runAction:l,userId:o,version:a}=h,p=J(),i=Q(),[u,c]=(0,C.useState)(null),[y,w]=(0,C.useState)(null),g;e[0]!==p||e[1]!==o?(g=s(()=>{Z((async()=>{w(null);try{let r=await p.listAuthSessions({limit:50,userId:o});c(r.rows)}catch(r){let S=r;c(null),w(Ee(S))}})())},"g"),e[0]=p,e[1]=o,e[2]=g):g=e[2];let I;e[3]!==p||e[4]!==o||e[5]!==a?(I=[p,o,a],e[3]=p,e[4]=o,e[5]=a,e[6]=I):I=e[6],(0,C.useEffect)(g,I);let k;e[7]!==p||e[8]!==l?(k=s(r=>{l(()=>p.revokeAuthSession({sessionId:r}))},"k"),e[7]=p,e[8]=l,e[9]=k):k=e[9];let v=k,d;e[10]!==i?(d=i("Sessions"),e[10]=i,e[11]=d):d=e[11];let m;e[12]!==d?(m=(0,t.jsx)(Ye,{children:d}),e[12]=d,e[13]=m):m=e[13];let b;e[14]!==y?(b=y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:y}),e[14]=y,e[15]=b):b=e[15];let x;e[16]!==u||e[17]!==i?(x=u!==null&&u.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:i("No active sessions.")}),e[16]=u,e[17]=i,e[18]=x):x=e[18];let N;e[19]!==n||e[20]!==v||e[21]!==u||e[22]!==i?(N=u!==null&&u.length>0&&(0,t.jsx)(K,{className:"overflow-hidden py-0",children:(0,t.jsx)(X,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{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)(Pe,{children:u.map(r=>(0,t.jsxs)(q,{"data-testid":`ud-session-${r.id}`,children:[(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.expiresAt)}),(0,t.jsx)(z,{children:r.ipAddress??""}),(0,t.jsx)(z,{className:"max-w-40 truncate",children:r.userAgent??""}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-revoke-${r.id}`,disabled:n,onClick:s(()=>{v(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Revoke")})})]},r.id))})]})})}),e[19]=n,e[20]=v,e[21]=u,e[22]=i,e[23]=N):N=e[23];let f;return e[24]!==m||e[25]!==b||e[26]!==x||e[27]!==N?(f=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[m,b,x,N]}),e[24]=m,e[25]=b,e[26]=x,e[27]=N,e[28]=f):f=e[28],f},"mt"),ft=s(h=>{let e=(0,W.c)(30),{busy:n,runAction:l,userId:o,version:a}=h,p=J(),i=Q(),[u,c]=(0,C.useState)(null),[y,w]=(0,C.useState)(null),g;e[0]!==p||e[1]!==o?(g=s(()=>{Z((async()=>{w(null);try{c(await p.listAuthAccounts({userId:o}))}catch(r){let S=r;c(null),w(Ee(S))}})())},"g"),e[0]=p,e[1]=o,e[2]=g):g=e[2];let I;e[3]!==p||e[4]!==o||e[5]!==a?(I=[p,o,a],e[3]=p,e[4]=o,e[5]=a,e[6]=I):I=e[6],(0,C.useEffect)(g,I);let k;e[7]!==p||e[8]!==l||e[9]!==o?(k=s(r=>{l(()=>p.unlinkAuthAccount({accountId:r,userId:o}))},"k"),e[7]=p,e[8]=l,e[9]=o,e[10]=k):k=e[10];let v=k,d;e[11]!==i?(d=i("Linked accounts"),e[11]=i,e[12]=d):d=e[12];let m;e[13]!==d?(m=(0,t.jsx)(Ye,{children:d}),e[13]=d,e[14]=m):m=e[14];let b;e[15]!==y?(b=y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:y}),e[15]=y,e[16]=b):b=e[16];let x;e[17]!==u||e[18]!==i?(x=u!==null&&u.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:i("No linked accounts.")}),e[17]=u,e[18]=i,e[19]=x):x=e[19];let N;e[20]!==u||e[21]!==n||e[22]!==v||e[23]!==i?(N=u!==null&&u.length>0&&(0,t.jsx)(K,{className:"overflow-hidden py-0",children:(0,t.jsx)(X,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{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)(Pe,{children:u.map(r=>{let S=Ue(r.id);return(0,t.jsxs)(q,{"data-testid":`ud-account-${S}`,children:[(0,t.jsx)(z,{children:Ue(r.providerId)}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-unlink-${S}`,disabled:n,onClick:s(()=>{v(S)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Unlink")})})]},S)})})]})})}),e[20]=u,e[21]=n,e[22]=v,e[23]=i,e[24]=N):N=e[24];let f;return e[25]!==m||e[26]!==b||e[27]!==x||e[28]!==N?(f=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[m,b,x,N]}),e[25]=m,e[26]=b,e[27]=x,e[28]=N,e[29]=f):f=e[29],f},"ht"),vt=s(h=>{let e=(0,W.c)(40),{busy:n,capabilities:l,runAction:o,userId:a,version:p}=h,i=J(),u=Q(),[c,y]=(0,C.useState)(null),w;e[0]!==l.passkey||e[1]!==i||e[2]!==a?(w=s(()=>{l.passkey&&Z((async()=>{try{y(await i.listAuthPasskeys({userId:a}))}catch{y(null)}})())},"C"),e[0]=l.passkey,e[1]=i,e[2]=a,e[3]=w):w=e[3];let g;e[4]!==l.passkey||e[5]!==i||e[6]!==a||e[7]!==p?(g=[l.passkey,i,a,p],e[4]=l.passkey,e[5]=i,e[6]=a,e[7]=p,e[8]=g):g=e[8],(0,C.useEffect)(w,g);let I;e[9]!==i||e[10]!==o||e[11]!==a?(I=s(()=>{o(()=>i.disableAuthTwoFactor({userId:a}))},"w"),e[9]=i,e[10]=o,e[11]=a,e[12]=I):I=e[12];let k=I,v;e[13]!==i||e[14]!==o?(v=s(S=>{o(()=>i.deleteAuthPasskey({passkeyId:S}))},"v"),e[13]=i,e[14]=o,e[15]=v):v=e[15];let d=v,m;e[16]!==u?(m=u("Security"),e[16]=u,e[17]=m):m=e[17];let b;e[18]!==m?(b=(0,t.jsx)(Ye,{children:m}),e[18]=m,e[19]=b):b=e[19];let x;e[20]!==n||e[21]!==l.twoFactor||e[22]!==k||e[23]!==u?(x=l.twoFactor&&(0,t.jsx)(_,{"data-testid":"ud-disable-2fa",disabled:n,onClick:k,size:"sm",type:"button",variant:"outline",children:u("Disable two-factor")}),e[20]=n,e[21]=l.twoFactor,e[22]=k,e[23]=u,e[24]=x):x=e[24];let N;e[25]!==l.passkey||e[26]!==c||e[27]!==u?(N=l.passkey&&c!==null&&c.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:u("No passkeys.")}),e[25]=l.passkey,e[26]=c,e[27]=u,e[28]=N):N=e[28];let f;e[29]!==n||e[30]!==l.passkey||e[31]!==d||e[32]!==c||e[33]!==u?(f=l.passkey&&c!==null&&c.length>0&&(0,t.jsx)(K,{className:"overflow-hidden py-0",children:(0,t.jsx)(X,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-passkeys-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:u("name")}),(0,t.jsx)(U,{children:u("created")}),(0,t.jsx)(U,{"aria-label":u("Actions")})]})}),(0,t.jsx)(Pe,{children:c.map(S=>{let $=Ue(S.id);return(0,t.jsxs)(q,{"data-testid":`ud-passkey-${$}`,children:[(0,t.jsx)(z,{children:Ue(S.name)||$}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(S.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-delete-passkey-${$}`,disabled:n,onClick:s(()=>{d($)},"onClick"),size:"xs",type:"button",variant:"ghost",children:u("Delete")})})]},$)})})]})})}),e[29]=n,e[30]=l.passkey,e[31]=d,e[32]=c,e[33]=u,e[34]=f):f=e[34];let r;return e[35]!==b||e[36]!==x||e[37]!==N||e[38]!==f?(r=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[b,x,N,f]}),e[35]=b,e[36]=x,e[37]=N,e[38]=f,e[39]=r):r=e[39],r},"ft"),gt=/(?:at|expires)$/iu,bt=/^[1-9]\d*$/u,xt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),yt=s(h=>{let e=(0,W.c)(51),{busy:n,onBan:l}=h,o=Q(),[a,p]=(0,C.useState)(""),[i,u]=(0,C.useState)(""),[c,y]=(0,C.useState)(!1),w;e[0]!==i?(w=bt.test(i.trim())&&Number.isSafeInteger(Number(i.trim())*86400)?Number(i.trim()):void 0,e[0]=i,e[1]=w):w=e[1];let g=w,I=c||g!==void 0,k;e[2]!==l||e[3]!==c||e[4]!==a||e[5]!==g?(k=s(()=>{l({expiresInSeconds:c||g===void 0?void 0:g*86400,reason:a.trim()===""?void 0:a.trim()})},"k"),e[2]=l,e[3]=c,e[4]=a,e[5]=g,e[6]=k):k=e[6];let v=k,d;e[7]!==o?(d=o("Ban reason (optional)"),e[7]=o,e[8]=d):d=e[8];let m;e[9]!==d?(m=(0,t.jsx)(O,{htmlFor:"ud-ban-reason",children:d}),e[9]=d,e[10]=m):m=e[10];let b;e[11]===Symbol.for("react.memo_cache_sentinel")?(b=s(E=>{p(E.target.value)},"b"),e[11]=b):b=e[11];let x;e[12]!==a?(x=(0,t.jsx)(T,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:b,value:a}),e[12]=a,e[13]=x):x=e[13];let N;e[14]!==m||e[15]!==x?(N=(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[m,x]}),e[14]=m,e[15]=x,e[16]=N):N=e[16];let f;e[17]!==o?(f=o("Days"),e[17]=o,e[18]=f):f=e[18];let r;e[19]!==f?(r=(0,t.jsx)(O,{htmlFor:"ud-ban-days",children:f}),e[19]=f,e[20]=r):r=e[20];let S;e[21]!==i||e[22]!==g?(S=i.trim()!==""&&g===void 0,e[21]=i,e[22]=g,e[23]=S):S=e[23];let $;e[24]===Symbol.for("react.memo_cache_sentinel")?($=s(E=>{u(E.target.value)},"T"),e[24]=$):$=e[24];let j;e[25]!==i||e[26]!==c||e[27]!==S?(j=(0,t.jsx)(T,{"aria-invalid":S,"data-testid":"ud-ban-days",disabled:c,id:"ud-ban-days",min:1,onChange:$,step:1,type:"number",value:i}),e[25]=i,e[26]=c,e[27]=S,e[28]=j):j=e[28];let H;e[29]!==j||e[30]!==r?(H=(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[r,j]}),e[29]=j,e[30]=r,e[31]=H):H=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=s(E=>{y(E.target.checked)},"M"),e[32]=M):M=e[32];let Y;e[33]!==c?(Y=(0,t.jsx)("input",{checked:c,className:"size-4 accent-destructive","data-testid":"ud-ban-permanent",id:"ud-ban-permanent",onChange:M,type:"checkbox"}),e[33]=c,e[34]=Y):Y=e[34];let B;e[35]!==o?(B=o("Permanent"),e[35]=o,e[36]=B):B=e[36];let V;e[37]!==Y||e[38]!==B?(V=(0,t.jsxs)(O,{className:"flex items-center gap-1.5 pb-2 text-xs font-normal",htmlFor:"ud-ban-permanent",children:[Y,B]}),e[37]=Y,e[38]=B,e[39]=V):V=e[39];let G=n||!I,P;e[40]!==o?(P=o("Ban user"),e[40]=o,e[41]=P):P=e[41];let L;e[42]!==v||e[43]!==G||e[44]!==P?(L=(0,t.jsx)(_,{"data-testid":"ud-ban",disabled:G,onClick:v,size:"sm",type:"button",variant:"destructive",children:P}),e[42]=v,e[43]=G,e[44]=P,e[45]=L):L=e[45];let F;return e[46]!==H||e[47]!==V||e[48]!==L||e[49]!==N?(F=(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[N,H,V,L]}),e[46]=H,e[47]=V,e[48]=L,e[49]=N,e[50]=F):F=e[50],F},"bt"),Nt=s((h,e)=>typeof e=="number"&&gt.test(h)?te(e):Ue(e),"xt"),kt=s(({capabilities:h,onChanged:e,onClose:n,user:l})=>{let o=J(),a=Q(),p=l.banned===!0,[i,u]=(0,C.useState)(null),[c,y]=(0,C.useState)(!1),[w,g]=(0,C.useState)(0),[I,k]=(0,C.useState)(typeof l.role=="string"?l.role:""),[v,d]=(0,C.useState)(""),[m,b]=(0,C.useState)(null),[x,N]=(0,C.useState)(!1),f=s((F,E)=>{Z((async()=>{y(!0),u(null);try{let $e=await F();E?.refresh!==!1&&(g(ae=>ae+1),e()),E?.onResult?.($e)}catch($e){u(Ee($e))}y(!1)})())},"p"),r=s(F=>{k(F.target.value)},"i"),S=s(F=>{d(F.target.value)},"I"),$=s(()=>{let F=I.trim();F!==""&&f(async()=>{await o.setAuthUserRole({role:F,userId:l.id})})},"T"),j=s(F=>{f(async()=>{await o.banAuthUser({...F,userId:l.id})})},"z"),H=s(()=>{f(async()=>{await o.unbanAuthUser({userId:l.id})})},"j"),M=s(()=>{f(async()=>{await o.setAuthUserPassword({newPassword:v,userId:l.id}),d("")})},"M"),Y=s(()=>{f(()=>o.impersonateAuthUser({userId:l.id}),{onResult:s(F=>{b(F.token)},"onResult"),refresh:!1})},"H"),B=s(()=>{f(async()=>{await o.revokeAuthUserSessions({userId:l.id})})},"L"),V=s(()=>{f(async()=>{await o.removeAuthUser({userId:l.id}),n()})},"V"),G=s(()=>{N(!0)},"Y"),P=s(()=>{N(!1)},"E"),L=Object.entries(l).filter(([F])=>!xt.has(F));return(0,t.jsxs)(He,{label:a("User details"),onClose:n,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:l.name??l.email??l.id}),(0,t.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:l.id}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof l.role=="string"&&l.role!==""&&(0,t.jsx)(D,{variant:"secondary",children:l.role}),p?(0,t.jsx)(D,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(D,{variant:"outline",children:a("Active")}),l.emailVerified===!0?(0,t.jsx)(D,{variant:"secondary",children:a("verified")}):(0,t.jsx)(D,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(_,{"data-testid":"ud-close",onClick:n,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}),h.admin&&(0,t.jsxs)(K,{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)(X,{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)(O,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(T,{"data-testid":"ud-role-input",id:"ud-role",onChange:r,value:I})]}),(0,t.jsx)(_,{"data-testid":"ud-set-role",disabled:c||I.trim()==="",onClick:$,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),p?(0,t.jsx)(_,{"data-testid":"ud-unban",disabled:c,onClick:H,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(0,t.jsx)(yt,{busy:c,onBan:j}),(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)(O,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(T,{"data-testid":"ud-password",id:"ud-password",onChange:S,type:"password",value:v})]}),(0,t.jsx)(_,{"data-testid":"ud-set-password",disabled:c||v==="",onClick:M,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(_,{"data-testid":"ud-impersonate",disabled:c,onClick:Y,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(_,{"data-testid":"ud-revoke-all",disabled:c,onClick:B,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),x?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(_,{"data-testid":"ud-delete-confirm",disabled:c,onClick:V,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(_,{"data-testid":"ud-delete-cancel",onClick:P,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(_,{"data-testid":"ud-delete",disabled:c,onClick:G,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),m!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(O,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(T,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:m})]})]})]}),(0,t.jsx)(pt,{busy:c,runAction:f,userId:l.id,version:w}),h.accounts&&(0,t.jsx)(ft,{busy:c,runAction:f,userId:l.id,version:w}),(h.twoFactor||h.passkey)&&(0,t.jsx)(vt,{busy:c,capabilities:h,runAction:f,userId:l.id,version:w}),(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:L.map(([F,E])=>(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:F}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:Nt(F,E)})]},F))})]})]})},"yt"),wt=50,Vt=s(({pageSize:h=wt}={})=>{let e=J(),n=Q(),[l,o]=(0,C.useState)(""),[a,p]=(0,C.useState)(""),[i,u]=(0,C.useState)(0),c=Xe(l),[y,w]=(0,C.useState)(null),[g,I]=(0,C.useState)(!1),{capabilities:k}=it(),v=c.trim(),d=a.trim(),m=De(["lunora-auth-users",v,d,h,i],()=>e.listAuthUsers({filterField:d===""?void 0:"role",filterValue:d===""?void 0:d,limit:h,offset:i,search:v===""?void 0:v}).then(r=>({...r,offset:i})),{keepPreviousData:!0}),b=m.data?.rows??null,x=m.error,N=s(()=>{m.refetch()},"N");We(()=>m.poll(),!0);let f=y===null?null:b?.find(r=>r.id===y)??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)(T,{"aria-label":n("Search users"),className:"w-56","data-testid":"us-search",onChange:s(r=>{o(r.target.value),u(0)},"onChange"),placeholder:n("Search by email or name\u2026"),value:l}),(0,t.jsx)(T,{"aria-label":n("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:s(r=>{p(r.target.value),u(0)},"onChange"),placeholder:n("Filter by role"),value:a}),(0,t.jsx)(_,{"data-testid":"us-new",onClick:s(()=>{I(!0)},"onClick"),size:"sm",type:"button",children:n("New user")})]}),x!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:x}),b!==null&&b.length===0&&(0,t.jsx)(Ve,{description:n("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:n("No users.")}),b!==null&&b.length>0&&(0,t.jsx)(K,{className:"overflow-hidden py-0",children:(0,t.jsx)(X,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"us-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:n("id")}),(0,t.jsx)(U,{children:n("email")}),(0,t.jsx)(U,{children:n("name")}),(0,t.jsx)(U,{children:n("role")}),(0,t.jsx)(U,{children:n("status")}),(0,t.jsx)(U,{children:n("verified")}),(0,t.jsx)(U,{children:n("created")}),(0,t.jsx)(U,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Pe,{children:b.map(r=>(0,t.jsxs)(q,{"data-testid":`us-row-${r.id}`,children:[(0,t.jsx)(z,{className:"font-mono text-xs",children:r.id}),(0,t.jsx)(z,{children:r.email??""}),(0,t.jsx)(z,{children:r.name??""}),(0,t.jsx)(z,{children:typeof r.role=="string"&&r.role!==""?(0,t.jsx)(D,{variant:"secondary",children:r.role}):""}),(0,t.jsx)(z,{children:r.banned===!0?(0,t.jsx)(D,{variant:"destructive",children:n("Banned")}):(0,t.jsx)(D,{variant:"success",children:n("Active")})}),(0,t.jsx)(z,{children:r.emailVerified===!0?(0,t.jsx)(D,{variant:"success",children:n("yes")}):(0,t.jsx)(D,{variant:"outline",children:n("no")})}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`us-manage-${r.id}`,onClick:s(()=>{w(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Manage")})})]},r.id))})]})})}),b!==null&&(0,t.jsx)(Je,{count:b.length,offset:m.data?.offset??0,onOffsetChange:u,pageSize:h,prefix:"us",total:m.data?.total}),f!==null&&(0,t.jsx)(kt,{capabilities:k,onChanged:N,onClose:s(()=>{w(null)},"onClose"),user:f}),g&&(0,t.jsx)(ht,{onClose:s(()=>{I(!1)},"onClose"),onCreated:N}),k.inviteOnly&&(0,t.jsx)(ot,{})]})},"jt");export{Vt as UsersPanel};
@@ -1 +1 @@
1
- import{l as v}from"./chunk-RGDSRUIX.js";import{j as A}from"./chunk-74IYYDDI.js";import{a as o,d as R,e as _,f as F}from"./chunk-I26MS5PJ.js";var M=R(F(),1);var a=R(_(),1);var U=6e4,b=o(e=>(typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function","g"),g=5e3,x=o((e,s,i)=>{let t=(0,M.c)(9),r=i===void 0?g:i,h=v(),d=(0,a.useRef)(e),c;t[0]!==e?(c=o(()=>{d.current=e},"c"),t[0]=e,t[1]=c):c=t[1],(0,a.useEffect)(c);let u;t[2]!==s||t[3]!==r?(u=o(()=>{if(!s)return;let l=r,p=!1,T,m=o(()=>{p||(T=setTimeout(P,l))},"f"),y=o(()=>{l=r,m()},"p"),E=o(n=>{A(n)||(l=Math.max(r,Math.min(l*2,U)),m())},"_"),P=o(()=>{if(globalThis.document?.hidden===!0){m();return}let n;try{n=d.current()}catch(S){E(S);return}b(n)?Promise.resolve(n).then(y).catch(E):y()},"A");return m(),()=>{p=!0,clearTimeout(T)}},"n"),t[2]=s,t[3]=r,t[4]=u):u=t[4];let f;t[5]!==h||t[6]!==s||t[7]!==r?(f=[h,s,r],t[5]=h,t[6]=s,t[7]=r,t[8]=f):f=t[8],(0,a.useEffect)(u,f)},"U"),D=o(async e=>{let s=(await Promise.allSettled(e)).find(i=>i.status==="rejected");if(s!==void 0)throw s.reason},"v");export{x as a,D as b};
1
+ import{l as v}from"./chunk-AVSMQPR3.js";import{j as A}from"./chunk-74IYYDDI.js";import{a as o,d as R,e as _,f as F}from"./chunk-I26MS5PJ.js";var M=R(F(),1);var a=R(_(),1);var U=6e4,b=o(e=>(typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function","g"),g=5e3,x=o((e,s,i)=>{let t=(0,M.c)(9),r=i===void 0?g:i,h=v(),d=(0,a.useRef)(e),c;t[0]!==e?(c=o(()=>{d.current=e},"c"),t[0]=e,t[1]=c):c=t[1],(0,a.useEffect)(c);let u;t[2]!==s||t[3]!==r?(u=o(()=>{if(!s)return;let l=r,p=!1,T,m=o(()=>{p||(T=setTimeout(P,l))},"f"),y=o(()=>{l=r,m()},"p"),E=o(n=>{A(n)||(l=Math.max(r,Math.min(l*2,U)),m())},"_"),P=o(()=>{if(globalThis.document?.hidden===!0){m();return}let n;try{n=d.current()}catch(S){E(S);return}b(n)?Promise.resolve(n).then(y).catch(E):y()},"A");return m(),()=>{p=!0,clearTimeout(T)}},"n"),t[2]=s,t[3]=r,t[4]=u):u=t[4];let f;t[5]!==h||t[6]!==s||t[7]!==r?(f=[h,s,r],t[5]=h,t[6]=s,t[7]=r,t[8]=f):f=t[8],(0,a.useEffect)(u,f)},"U"),D=o(async e=>{let s=(await Promise.allSettled(e)).find(i=>i.status==="rejected");if(s!==void 0)throw s.reason},"v");export{x as a,D as b};
@@ -1 +1 @@
1
- import{a as H}from"./chunk-EYTZURBK.js";import{b as x}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{b as z}from"./chunk-DFVQBXUZ.js";import{l as O}from"./chunk-RGDSRUIX.js";import"./chunk-QAQDMS6R.js";import"./chunk-35Q6XYRL.js";import{a as _}from"./chunk-RWVIV3U7.js";import{a as q,b as B,c as E,d as S,e as i,f as s}from"./chunk-HCTJKP5J.js";import{a as A,e as L}from"./chunk-2IKDEUCX.js";import{d as W}from"./chunk-74IYYDDI.js";import{a as R,d as M,f as $,g as D}from"./chunk-I26MS5PJ.js";var I=M($(),1);var n=M(D(),1);var F=2e3,G=new Set(["open"]),ie=R(Q=>{let e=(0,I.c)(41),{read:y}=Q,t=W(),j=O(),v;e[0]!==j||e[1]!==y?(v=R(()=>Promise.resolve(y?y():j.debug()),"T"),e[0]=j,e[1]=y,e[2]=v):v=e[2];let V=v,K=y?"injected":"live",b;e[3]!==K?(b=["lunora-studio","sync-client-debug",K],e[3]=K,e[4]=b):b=e[4];let{data:c,poll:Y}=z(b,V);if(H(Y,!0,F),!c){let r;e[5]!==t?(r=t("Reading the sync client's state\u2026"),e[5]=t,e[6]=r):r=e[6];let g;e[7]!==t?(g=t("Sync client"),e[7]=t,e[8]=g):g=e[8];let T;return e[9]!==r||e[10]!==g?(T=(0,n.jsx)(A,{children:(0,n.jsx)(L,{children:(0,n.jsx)(_,{description:r,title:g})})}),e[9]=r,e[10]=g,e[11]=T):T=e[11],T}let{pendingWrites:k,shards:N,subscriptions:w}=c,a;e[12]!==t?(a=t("This Studio session's sync client"),e[12]=t,e[13]=a):a=e[13];let l;e[14]!==a?(l=(0,n.jsx)("span",{className:"text-sm font-medium",children:a}),e[14]=a,e[15]=l):l=e[15];let P=c.connectionStatus==="connected"?"default":"secondary",o;e[16]!==c.connectionStatus||e[17]!==P?(o=(0,n.jsx)(x,{variant:P,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=P,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]!==l||e[23]!==o||e[24]!==d?(h=(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[l,o,d]}),e[22]=l,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)(_,{description:t("No shard connection has been opened yet."),title:t("No shards")}):(0,n.jsxs)(q,{children:[(0,n.jsx)(B,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(i,{children:t("Shard")}),(0,n.jsx)(i,{children:t("Socket")}),(0,n.jsx)(i,{children:t("Confirmed watermark")})]})}),(0,n.jsx)(E,{children:N.map(r=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{children:r.shardKey??t("(default)")}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:G.has(r.wsState)?"default":"secondary",children:r.wsState})}),(0,n.jsx)(s,{children:r.confirmedMutationWatermark})]},r.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)(_,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):(0,n.jsxs)(q,{children:[(0,n.jsx)(B,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(i,{children:t("Subscription")}),(0,n.jsx)(i,{children:t("Kind")}),(0,n.jsx)(i,{children:t("Acked")}),(0,n.jsx)(i,{children:t("Cursor")}),(0,n.jsx)(i,{children:t("Pending overlays")})]})}),(0,n.jsx)(E,{children:w.map(r=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{className:"font-mono text-xs",children:r.functionPath}),(0,n.jsx)(s,{children:r.kind}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:r.acked?"default":"secondary",children:r.acked?t("yes"):t("no")})}),(0,n.jsx)(s,{children:r.serverCursor??"\u2014"}),(0,n.jsx)(s,{children:r.pendingOptimisticLayers})]},r.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},"ie");export{ie as default};
1
+ import{a as H}from"./chunk-4TYCTORB.js";import{b as x}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{b as z}from"./chunk-T2JHVL34.js";import{l as O}from"./chunk-AVSMQPR3.js";import"./chunk-QAQDMS6R.js";import"./chunk-3I25WO3P.js";import{a as _}from"./chunk-RWVIV3U7.js";import{a as q,b as B,c as E,d as S,e as i,f as s}from"./chunk-HCTJKP5J.js";import{a as A,e as L}from"./chunk-2IKDEUCX.js";import{d as W}from"./chunk-74IYYDDI.js";import{a as R,d as M,f as $,g as D}from"./chunk-I26MS5PJ.js";var I=M($(),1);var n=M(D(),1);var F=2e3,G=new Set(["open"]),ie=R(Q=>{let e=(0,I.c)(41),{read:y}=Q,t=W(),j=O(),v;e[0]!==j||e[1]!==y?(v=R(()=>Promise.resolve(y?y():j.debug()),"T"),e[0]=j,e[1]=y,e[2]=v):v=e[2];let V=v,K=y?"injected":"live",b;e[3]!==K?(b=["lunora-studio","sync-client-debug",K],e[3]=K,e[4]=b):b=e[4];let{data:c,poll:Y}=z(b,V);if(H(Y,!0,F),!c){let r;e[5]!==t?(r=t("Reading the sync client's state\u2026"),e[5]=t,e[6]=r):r=e[6];let g;e[7]!==t?(g=t("Sync client"),e[7]=t,e[8]=g):g=e[8];let T;return e[9]!==r||e[10]!==g?(T=(0,n.jsx)(A,{children:(0,n.jsx)(L,{children:(0,n.jsx)(_,{description:r,title:g})})}),e[9]=r,e[10]=g,e[11]=T):T=e[11],T}let{pendingWrites:k,shards:N,subscriptions:w}=c,a;e[12]!==t?(a=t("This Studio session's sync client"),e[12]=t,e[13]=a):a=e[13];let l;e[14]!==a?(l=(0,n.jsx)("span",{className:"text-sm font-medium",children:a}),e[14]=a,e[15]=l):l=e[15];let P=c.connectionStatus==="connected"?"default":"secondary",o;e[16]!==c.connectionStatus||e[17]!==P?(o=(0,n.jsx)(x,{variant:P,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=P,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]!==l||e[23]!==o||e[24]!==d?(h=(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[l,o,d]}),e[22]=l,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)(_,{description:t("No shard connection has been opened yet."),title:t("No shards")}):(0,n.jsxs)(q,{children:[(0,n.jsx)(B,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(i,{children:t("Shard")}),(0,n.jsx)(i,{children:t("Socket")}),(0,n.jsx)(i,{children:t("Confirmed watermark")})]})}),(0,n.jsx)(E,{children:N.map(r=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{children:r.shardKey??t("(default)")}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:G.has(r.wsState)?"default":"secondary",children:r.wsState})}),(0,n.jsx)(s,{children:r.confirmedMutationWatermark})]},r.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)(_,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):(0,n.jsxs)(q,{children:[(0,n.jsx)(B,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(i,{children:t("Subscription")}),(0,n.jsx)(i,{children:t("Kind")}),(0,n.jsx)(i,{children:t("Acked")}),(0,n.jsx)(i,{children:t("Cursor")}),(0,n.jsx)(i,{children:t("Pending overlays")})]})}),(0,n.jsx)(E,{children:w.map(r=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{className:"font-mono text-xs",children:r.functionPath}),(0,n.jsx)(s,{children:r.kind}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:r.acked?"default":"secondary",children:r.acked?t("yes"):t("no")})}),(0,n.jsx)(s,{children:r.serverCursor??"\u2014"}),(0,n.jsx)(s,{children:r.pendingOptimisticLayers})]},r.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},"ie");export{ie as default};