@lunora/studio 1.0.0-alpha.185 → 1.0.0-alpha.187

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 (74) hide show
  1. package/dist/index.mjs +1 -1
  2. package/dist/packem_chunks/FileBrowser.mjs +1 -1
  3. package/dist/packem_chunks/SqlEditorPanel.mjs +1 -1
  4. package/dist/packem_chunks/TableEditor.mjs +1 -1
  5. package/dist/packem_chunks/migrations-route.mjs +1 -1
  6. package/dist/packem_shared/{DataBrowser-BUFMFvNX.mjs → DataBrowser-zqK4s0IE.mjs} +2 -2
  7. package/dist/packem_shared/grid-features-Dm80ngyR.mjs +6 -0
  8. package/dist/standalone/{chunk-3PUGTMHP.js → chunk-23C2QL7Z.js} +1 -1
  9. package/dist/standalone/{chunk-SMMYONB7.js → chunk-2FGXE3E5.js} +1 -1
  10. package/dist/standalone/{chunk-2VGRBZVS.js → chunk-367RGUUX.js} +1 -1
  11. package/dist/standalone/{chunk-QZJVCXWS.js → chunk-3BN3N2CX.js} +1 -1
  12. package/dist/standalone/{chunk-VWLX4CH4.js → chunk-62IKYVD3.js} +2 -2
  13. package/dist/standalone/{chunk-UCYK6YWD.js → chunk-6A34IMQS.js} +1 -1
  14. package/dist/standalone/{chunk-6MMHVZID.js → chunk-6DLHIMOI.js} +1 -1
  15. package/dist/standalone/{chunk-UD47ZOIF.js → chunk-6FTYD55M.js} +1 -1
  16. package/dist/standalone/{chunk-EMUTRNK5.js → chunk-6MJU7KID.js} +1 -1
  17. package/dist/standalone/{chunk-ZVMUTCUE.js → chunk-7VNHUUK4.js} +1 -1
  18. package/dist/standalone/{chunk-2254YC77.js → chunk-7VNOCXWO.js} +1 -1
  19. package/dist/standalone/{chunk-GXSHHAYL.js → chunk-AJU3V2XW.js} +1 -1
  20. package/dist/standalone/{chunk-XXB357HN.js → chunk-AO3LNXNG.js} +1 -1
  21. package/dist/standalone/{chunk-MH73AR4R.js → chunk-AWN2GXCK.js} +1 -1
  22. package/dist/standalone/{chunk-JA7FUFCP.js → chunk-B6BFVYFA.js} +1 -1
  23. package/dist/standalone/chunk-BDO4YYBB.js +6 -0
  24. package/dist/standalone/{chunk-GQQPTCCH.js → chunk-BG52HJBJ.js} +1 -1
  25. package/dist/standalone/{chunk-77UI3GTT.js → chunk-BI2PP4AE.js} +1 -1
  26. package/dist/standalone/{chunk-UREV5NIX.js → chunk-BNIDGSDE.js} +1 -1
  27. package/dist/standalone/{chunk-YAMJRRT2.js → chunk-BWRPOIEI.js} +1 -1
  28. package/dist/standalone/{chunk-FGEBPY6M.js → chunk-C3UMVVZD.js} +1 -1
  29. package/dist/standalone/{chunk-U5EMA2D7.js → chunk-CFN6A74K.js} +1 -1
  30. package/dist/standalone/{chunk-HEIGV6KL.js → chunk-CMO25UOM.js} +1 -1
  31. package/dist/standalone/{chunk-2TAFAGWH.js → chunk-DAAYIBSL.js} +1 -1
  32. package/dist/standalone/{chunk-RY2LZULX.js → chunk-DAXY4RAL.js} +1 -1
  33. package/dist/standalone/{chunk-EKMKNRYI.js → chunk-DK7IUHFW.js} +1 -1
  34. package/dist/standalone/{chunk-H7UQ7W6L.js → chunk-DLF7WRVK.js} +1 -1
  35. package/dist/standalone/{chunk-5G2MAI3G.js → chunk-FI3UY4QJ.js} +1 -1
  36. package/dist/standalone/{chunk-NSYGYSMJ.js → chunk-FUXL36RK.js} +1 -1
  37. package/dist/standalone/{chunk-RJZI2ZRF.js → chunk-HBWT2BXO.js} +3 -3
  38. package/dist/standalone/{chunk-22EHJEFE.js → chunk-I57A5YB6.js} +1 -1
  39. package/dist/standalone/{chunk-2PYJCU6C.js → chunk-IZDX3F65.js} +1 -1
  40. package/dist/standalone/{chunk-J6ESSV7B.js → chunk-KE5T44IA.js} +1 -1
  41. package/dist/standalone/{chunk-Q5R67CRQ.js → chunk-MKE333RB.js} +1 -1
  42. package/dist/standalone/{chunk-CEA2QYAI.js → chunk-MKL7VDTL.js} +2 -2
  43. package/dist/standalone/{chunk-PAWM6IP3.js → chunk-N4GEA5GK.js} +1 -1
  44. package/dist/standalone/{chunk-MVJL6J4Y.js → chunk-N6CQJUDY.js} +1 -1
  45. package/dist/standalone/{chunk-ZEZ5FW7V.js → chunk-NO5VGTWP.js} +1 -1
  46. package/dist/standalone/{chunk-NGEP4H3Q.js → chunk-ORJB5XQH.js} +1 -1
  47. package/dist/standalone/{chunk-QAIEAIIE.js → chunk-P5RUFDVX.js} +1 -1
  48. package/dist/standalone/chunk-PAZ72JHQ.js +1 -0
  49. package/dist/standalone/{chunk-MRI7UILC.js → chunk-PGV42T2U.js} +1 -1
  50. package/dist/standalone/{chunk-OUKLYU72.js → chunk-PTRUAQYA.js} +1 -1
  51. package/dist/standalone/{chunk-SZSHO6RE.js → chunk-PYI2MI4Q.js} +1 -1
  52. package/dist/standalone/{chunk-TLFNAWL6.js → chunk-Q6PUWGXK.js} +1 -1
  53. package/dist/standalone/{chunk-HB2AVFM7.js → chunk-QIPTFNQK.js} +1 -1
  54. package/dist/standalone/{chunk-QMFQGVTQ.js → chunk-QOSKGDBH.js} +1 -1
  55. package/dist/standalone/{chunk-METTWXRR.js → chunk-U7YOMGYN.js} +1 -1
  56. package/dist/standalone/{chunk-OGEHSNF7.js → chunk-UDXIBUS6.js} +1 -1
  57. package/dist/standalone/{chunk-RBAMNKW7.js → chunk-USCV7TYG.js} +1 -1
  58. package/dist/standalone/{chunk-IOPBEKDK.js → chunk-VBDYQCRQ.js} +1 -1
  59. package/dist/standalone/{chunk-P52AMBNB.js → chunk-VXQJWD3F.js} +1 -1
  60. package/dist/standalone/{chunk-K5ZNTNAC.js → chunk-W5YA2J66.js} +1 -1
  61. package/dist/standalone/{chunk-PCQP4NHL.js → chunk-WD22LMYA.js} +1 -1
  62. package/dist/standalone/{chunk-L3AFRJE2.js → chunk-WNVPC7FI.js} +1 -1
  63. package/dist/standalone/{chunk-HQWKWSY4.js → chunk-XSNWSHZ6.js} +1 -1
  64. package/dist/standalone/{chunk-XRR2R2H5.js → chunk-Y76TQLLR.js} +1 -1
  65. package/dist/standalone/{chunk-AMPB3H6K.js → chunk-YOKBLIIN.js} +1 -1
  66. package/dist/standalone/{chunk-6DGK6352.js → chunk-YVVP4DRM.js} +1 -1
  67. package/dist/standalone/{chunk-FHW7T5NC.js → chunk-ZNYTH4BS.js} +1 -1
  68. package/dist/standalone/{chunk-7F5LVCXA.js → chunk-ZTQSA34U.js} +1 -1
  69. package/dist/standalone/{chunk-Z4FYPU4Q.js → chunk-ZWDPWM3I.js} +1 -1
  70. package/dist/standalone/studio.js +1 -1
  71. package/package.json +6 -6
  72. package/dist/packem_shared/grid-features-CE8kcqsK.mjs +0 -6
  73. package/dist/standalone/chunk-GLTOTU4J.js +0 -1
  74. package/dist/standalone/chunk-M4POCI2J.js +0 -6
@@ -1 +1 @@
1
- import{a as O}from"./chunk-66UGPQVC.js";import{a as H}from"./chunk-PD6WIDY6.js";import{a as ee}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as Z}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{b as E}from"./chunk-5G2MAI3G.js";import{f as R}from"./chunk-SZSHO6RE.js";import"./chunk-FSRSK4LY.js";import"./chunk-CEA2QYAI.js";import{a as _}from"./chunk-FKVZRPV5.js";import{a as K,b as V,c as z,d as F,e as u,f as p}from"./chunk-HEAQVSNS.js";import{a as A,e as T}from"./chunk-WUWBZPUK.js";import{d as M,h as G,o as W,r as X}from"./chunk-FODLDLE2.js";import{a as c,d as P,e as oe,f as re,g as ae}from"./chunk-YKXDMIHQ.js";var U=P(re(),1),Y=P(oe(),1);var t=P(ae(),1);var se=P(re(),1);var Q=P(oe(),1);var h=P(ae(),1);var ie=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","X"),le=c(a=>a.toSorted((e,i)=>e.scheduledFor-i.scheduledFor),"F"),ce=c((a,e,i)=>e!==void 0?e:i===void 0?d=>a.cancelScheduledJob(d):void 0,"Y"),de=c(a=>{let e=(0,se.c)(16),{cancelJob:i,loadJobs:d}=a===void 0?{}:a,f=R(),r=M(),l=d===void 0,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-scheduled-jobs"],e[0]=o):o=e[0];let N=E(o,async()=>{let v=await(d??(()=>f.listScheduledJobs()))();return le(v)}),[x,n]=(0,Q.useState)(void 0),[s,m]=(0,Q.useState)(void 0),y,k;e[1]!==f||e[2]!==l?(y=c(()=>{if(l)return f.subscribeScheduledJobs(v=>{m(void 0),n(le(v))})},"v"),k=[l,f],e[1]=f,e[2]=l,e[3]=y,e[4]=k):(y=e[3],k=e[4]),(0,Q.useEffect)(y,k);let g;e[5]!==N?(g=c(()=>{N.refetch()},"y"),e[5]=N,e[6]=g):g=e[6],O(g,!l);let J=ce(f,i,d),b=x??N.data,j=s??N.error,I=c(async v=>{if(J!==void 0){m(void 0);try{await J(v),l||N.refetch()}catch(D){m(G(D))}}},"A"),q="flex flex-col gap-3",B="lunora-scheduled-jobs",S;e[7]!==j?(S=j!==null&&(0,h.jsx)("p",{className:"text-sm text-destructive","data-testid":"sj-error",role:"alert",children:j}),e[7]=j,e[8]=S):S=e[8];let L;e[9]!==b?.length||e[10]!==r?(L=b?.length===0&&(0,h.jsx)(_,{description:r("Jobs queued with runAfter / runAt will appear here."),icon:(0,h.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,h.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,h.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"sj-empty",title:r("No scheduled jobs.")}),e[9]=b?.length,e[10]=r,e[11]=L):L=e[11];let $=b!==void 0&&b.length>0&&(0,h.jsx)(A,{className:"overflow-hidden py-0",children:(0,h.jsx)(T,{className:"px-0",children:(0,h.jsxs)(K,{"data-testid":"sj-table",children:[(0,h.jsx)(V,{children:(0,h.jsxs)(F,{children:[(0,h.jsx)(u,{children:r("function")}),(0,h.jsx)(u,{children:r("scheduled for")}),(0,h.jsx)(u,{children:r("pool")}),(0,h.jsx)(u,{children:r("attempts")}),(0,h.jsx)(u,{children:r("shard")}),(0,h.jsx)(u,{children:r("id")}),J!==void 0&&(0,h.jsx)(u,{"aria-label":r("Actions")})]})}),(0,h.jsx)(z,{children:b.map(v=>(0,h.jsxs)(F,{"data-testid":`sj-row-${v.id}`,children:[(0,h.jsx)(p,{className:"font-mono text-xs",children:v.workflow??v.functionPath}),(0,h.jsx)(p,{className:"text-muted-foreground tabular-nums",children:ie(v.scheduledFor)}),(0,h.jsx)(p,{className:"font-mono text-xs",children:v.pool??""}),(0,h.jsx)(p,{className:"tabular-nums",children:v.attempts??0}),(0,h.jsx)(p,{children:v.shardKey??""}),(0,h.jsx)(p,{className:"font-mono text-xs",children:v.id}),J!==void 0&&(0,h.jsx)(p,{className:"text-right",children:(0,h.jsx)(H,{confirmLabel:r("Cancel job?"),onConfirm:c(()=>{W(I(v.id))},"onConfirm"),testId:`sj-cancel-${v.id}`,children:r("Cancel")})})]},v.id))})]})})}),w;return e[12]!==$||e[13]!==S||e[14]!==L?(w=(0,h.jsxs)("div",{className:q,"data-testid":B,children:[S,L,$]}),e[12]=$,e[13]=S,e[14]=L,e[15]=w):w=e[15],w},"he");var he={kind:"idle"},me=c((a,e,i)=>i!==void 0?i:e===void 0?d=>a.runCronJob(d):void 0,"re"),ue=c(({loadCronJobs:a,runCronJob:e}={})=>{let i=R(),d=M(),[f,r]=(0,Y.useState)({}),l=E(["lunora-cron-jobs",a?"custom":"default"],()=>(a??(()=>i.getCronJobs()))()),{data:o,error:N}=l,x=me(i,a,e),n=c(async s=>{if(x!==void 0){r(m=>({...m,[s]:{kind:"running"}}));try{await x(s),r(m=>({...m,[s]:{kind:"ok"}})),l.refetch()}catch(m){r(y=>({...y,[s]:{kind:"error",message:G(m)}}))}}},"i");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[N!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:N}),o?.length===0&&(0,t.jsx)(_,{description:d("Triggers declared with the cronJobs() builder appear here."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,t.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:d("No cron triggers.")}),o!==void 0&&o.length>0&&(0,t.jsx)(A,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"cron-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(u,{children:d("name")}),(0,t.jsx)(u,{children:d("schedule")}),(0,t.jsx)(u,{children:d("target")}),(0,t.jsx)(u,{children:d("shard")}),x!==void 0&&(0,t.jsx)(u,{"aria-label":d("Actions")})]})}),(0,t.jsx)(z,{children:o.map(s=>{let m=f[s.name]??he;return(0,t.jsxs)(F,{"data-testid":`cron-row-${s.name}`,children:[(0,t.jsx)(p,{children:s.name}),(0,t.jsx)(p,{className:"font-mono text-xs tabular-nums",children:s.cron}),(0,t.jsx)(p,{children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[s.workflow===void 0?(0,t.jsx)(Z,{variant:"outline",children:d("function")}):(0,t.jsx)(Z,{variant:"secondary",children:d("workflow")}),(0,t.jsx)("span",{className:"font-mono text-xs",children:s.workflow??s.functionPath})]})}),(0,t.jsx)(p,{children:s.shardKey??""}),x!==void 0&&(0,t.jsx)(p,{className:"text-right",children:(0,t.jsxs)("span",{className:"flex items-center justify-end gap-2",children:[m.kind==="ok"&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${s.name}`,children:d("ran")}),m.kind==="error"&&(0,t.jsx)("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${s.name}`,role:"alert",children:m.message}),(0,t.jsx)(H,{confirmLabel:d("Run now?"),disabled:m.kind==="running",onConfirm:c(()=>{W(n(s.name))},"onConfirm"),testId:`cron-run-${s.name}`,children:m.kind==="running"?d("Running\u2026"):d("Run now")})]})})]},`${s.cron}:${s.name}`)})})]})})})]})},"le"),pe=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","se"),fe=c(a=>{let e=(0,U.c)(34),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadJobs:d,removeJob:f,retryJob:r}=i,l=R(),o=M(),N;e[2]===Symbol.for("react.memo_cache_sentinel")?(N=["lunora-dead-jobs"],e[2]=N):N=e[2];let x;e[3]!==l||e[4]!==d?(x=c(async()=>(await(d??(()=>l.listDeadJobs()))()).toSorted(be),"h"),e[3]=l,e[4]=d,e[5]=x):x=e[5];let n=E(N,x),s=n.data,[m,y]=(0,Y.useState)(void 0),k=n.error??m,g=d===void 0,J;e[6]!==l||e[7]!==g||e[8]!==r?(J=r??(g?C=>l.retryDeadJob(C):void 0),e[6]=l,e[7]=g,e[8]=r,e[9]=J):J=e[9];let b=J,j;e[10]!==l||e[11]!==g||e[12]!==f?(j=f??(g?C=>l.removeDeadJob(C):void 0),e[10]=l,e[11]=g,e[12]=f,e[13]=j):j=e[13];let I=j,q;e[14]!==n?(q=c(()=>{n.refetch()},"$"),e[14]=n,e[15]=q):q=e[15],O(q,!0);let B;e[16]!==n?(B=c(async C=>{y(void 0);try{await C,n.refetch()}catch(ne){y(G(ne))}},"I"),e[16]=n,e[17]=B):B=e[17];let S=B,L=b!==void 0||I!==void 0,$;e[18]!==k?($=k!==void 0&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:k}),e[18]=k,e[19]=$):$=e[19];let w;e[20]!==s?.length||e[21]!==o?(w=s?.length===0&&(0,t.jsx)(_,{description:o("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:o("No dead-letter jobs.")}),e[20]=s?.length,e[21]=o,e[22]=w):w=e[22];let v;e[23]!==S||e[24]!==L||e[25]!==s||e[26]!==I||e[27]!==b||e[28]!==o?(v=s!==void 0&&s.length>0&&(0,t.jsx)(A,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"dlq-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(u,{children:o("function")}),(0,t.jsx)(u,{children:o("attempts")}),(0,t.jsx)(u,{children:o("last tried")}),(0,t.jsx)(u,{children:o("pool")}),(0,t.jsx)(u,{children:o("shard")}),(0,t.jsx)(u,{children:o("id")}),L&&(0,t.jsx)(u,{"aria-label":o("Actions")})]})}),(0,t.jsx)(z,{children:s.map(C=>(0,t.jsxs)(F,{"data-testid":`dlq-row-${C.id}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:C.workflow??C.functionPath}),(0,t.jsx)(p,{className:"tabular-nums",children:C.attempts??0}),(0,t.jsx)(p,{className:"text-muted-foreground tabular-nums",children:pe(C.scheduledFor)}),(0,t.jsx)(p,{className:"font-mono text-xs",children:C.pool??""}),(0,t.jsx)(p,{children:C.shardKey??""}),(0,t.jsx)(p,{className:"font-mono text-xs",children:C.id}),L&&(0,t.jsx)(p,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1.5",children:[b!==void 0&&(0,t.jsx)(ee,{"data-testid":`dlq-retry-${C.id}`,onClick:c(()=>{W(S(b(C.id)))},"onClick"),size:"sm",type:"button",variant:"outline",children:o("Retry")}),I!==void 0&&(0,t.jsx)(H,{confirmLabel:o("Drop job?"),onConfirm:c(()=>{W(S(I(C.id)))},"onConfirm"),testId:`dlq-remove-${C.id}`,children:o("Drop")})]})})]},C.id))})]})})}),e[23]=S,e[24]=L,e[25]=s,e[26]=I,e[27]=b,e[28]=o,e[29]=v):v=e[29];let D;return e[30]!==v||e[31]!==$||e[32]!==w?(D=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[$,w,v]}),e[30]=v,e[31]=$,e[32]=w,e[33]=D):D=e[33],D},"ne");function be(a,e){return(e.attempts??0)-(a.attempts??0)}c(be,"oe");var te=c(a=>{let e=(0,U.c)(8),{label:i,testId:d,value:f}=a,r;e[0]!==i?(r=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:i}),e[0]=i,e[1]=r):r=e[1];let l;e[2]!==d||e[3]!==f?(l=(0,t.jsx)("span",{className:"text-2xl font-semibold tabular-nums","data-testid":d,children:f}),e[2]=d,e[3]=f,e[4]=l):l=e[4];let o;return e[5]!==r||e[6]!==l?(o=(0,t.jsx)(A,{className:"flex-1 py-0",children:(0,t.jsxs)(T,{className:"flex flex-col gap-1 p-4",children:[r,l]})}),e[5]=r,e[6]=l,e[7]=o):o=e[7],o},"E"),ve=c(a=>{let e=(0,U.c)(25),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadStatus:d}=i,f=R(),r=M(),l=d===void 0,o;e[2]!==l?(o=["lunora-scheduler-status",l],e[2]=l,e[3]=o):o=e[3];let N;e[4]!==f||e[5]!==d?(N=c(async()=>{let j=await(d??(()=>f.schedulerStatus()))();return{...j,pools:j.pools.toSorted(xe)}},"y"),e[4]=f,e[5]=d,e[6]=N):N=e[6];let x=E(o,N),{data:n,error:s}=x,m;e[7]!==x?(m=c(()=>{x.refetch()},"d"),e[7]=x,e[8]=m):m=e[8],O(m,!0);let y;e[9]!==s?(y=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:s}),e[9]=s,e[10]=y):y=e[10];let k;e[11]!==n||e[12]!==r?(k=n!==void 0&&(0,t.jsxs)("div",{className:"flex gap-3","data-testid":"pools-totals",children:[(0,t.jsx)(te,{label:r("backlog"),testId:"pools-backlog",value:n.backlog}),(0,t.jsx)(te,{label:r("in flight"),testId:"pools-inflight",value:n.inFlight}),(0,t.jsx)(te,{label:r("pools"),testId:"pools-count",value:n.pools.length})]}),e[11]=n,e[12]=r,e[13]=k):k=e[13];let g;e[14]!==n?.pools.length||e[15]!==r?(g=n?.pools.length===0&&(0,t.jsx)(_,{description:r("Pools created with createWorkpool appear here once they have activity."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:r("No workpools.")}),e[14]=n?.pools.length,e[15]=r,e[16]=g):g=e[16];let J;e[17]!==n||e[18]!==r?(J=n!==void 0&&n.pools.length>0&&(0,t.jsx)(A,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"pools-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(u,{children:r("pool")}),(0,t.jsx)(u,{children:r("queued")}),(0,t.jsx)(u,{children:r("in flight")}),(0,t.jsx)(u,{children:r("max concurrency")})]})}),(0,t.jsx)(z,{children:n.pools.map(ge)})]})})}),e[17]=n,e[18]=r,e[19]=J):J=e[19];let b;return e[20]!==y||e[21]!==k||e[22]!==g||e[23]!==J?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[y,k,g,J]}),e[20]=y,e[21]=k,e[22]=g,e[23]=J,e[24]=b):b=e[24],b},"ae");function xe(a,e){return e.queued-a.queued}c(xe,"ie");function ge(a){return(0,t.jsxs)(F,{"data-testid":`pools-row-${a.name}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:a.name}),(0,t.jsx)(p,{className:"tabular-nums",children:a.queued}),(0,t.jsxs)(p,{className:"tabular-nums",children:[a.inFlight," / ",a.maxConcurrency]}),(0,t.jsx)(p,{className:"tabular-nums",children:a.maxConcurrency})]},a.name)}c(ge,"de");var Ne=["jobs","dead","pools","cron"],Ve=c(a=>{let e=(0,U.c)(41),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadCronJobs:d,scheduledCancel:f,scheduledLoad:r}=i,l=M(),[o,N]=(0,Y.useState)("jobs"),x;e[2]!==l?(x=l("Cron triggers"),e[2]=l,e[3]=x):x=e[3];let n;e[4]!==l?(n=l("Dead letter"),e[4]=l,e[5]=n):n=e[5];let s;e[6]!==l?(s=l("Scheduled jobs"),e[6]=l,e[7]=s):s=e[7];let m;e[8]!==l?(m=l("Pools"),e[8]=l,e[9]=m):m=e[9];let y;e[10]!==x||e[11]!==n||e[12]!==s||e[13]!==m?(y={cron:x,dead:n,jobs:s,pools:m},e[10]=x,e[11]=n,e[12]=s,e[13]=m,e[14]=y):y=e[14];let k=y,g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=c(w=>{N(w.currentTarget.dataset.view)},"f"),e[15]=g):g=e[15];let J=g,b;e[16]!==l?(b=l("Schedule view"),e[16]=l,e[17]=b):b=e[17];let j;e[18]!==o||e[19]!==k?(j=Ne.map(w=>(0,t.jsx)(ee,{"aria-selected":o===w,"data-testid":`schedule-view-${w}`,"data-view":w,onClick:J,role:"tab",size:"sm",type:"button",variant:o===w?"default":"outline",children:k[w]},w)),e[18]=o,e[19]=k,e[20]=j):j=e[20];let I;e[21]!==b||e[22]!==j?(I=(0,t.jsx)("div",{"aria-label":b,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:j}),e[21]=b,e[22]=j,e[23]=I):I=e[23];let q;e[24]!==f||e[25]!==r||e[26]!==o?(q=o==="jobs"&&(0,t.jsx)(de,{cancelJob:f,loadJobs:r}),e[24]=f,e[25]=r,e[26]=o,e[27]=q):q=e[27];let B;e[28]!==o?(B=o==="dead"&&(0,t.jsx)(fe,{}),e[28]=o,e[29]=B):B=e[29];let S;e[30]!==o?(S=o==="pools"&&(0,t.jsx)(ve,{}),e[30]=o,e[31]=S):S=e[31];let L;e[32]!==d||e[33]!==o?(L=o==="cron"&&(0,t.jsx)(ue,{loadCronJobs:d}),e[32]=d,e[33]=o,e[34]=L):L=e[34];let $;return e[35]!==I||e[36]!==q||e[37]!==B||e[38]!==S||e[39]!==L?($=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[I,q,B,S,L]}),e[35]=I,e[36]=q,e[37]=B,e[38]=S,e[39]=L,e[40]=$):$=e[40],$},"Ie");export{Ve as SchedulePanel};
1
+ import{a as O}from"./chunk-66UGPQVC.js";import{a as H}from"./chunk-PD6WIDY6.js";import{a as ee}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as Z}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{b as E}from"./chunk-FI3UY4QJ.js";import{f as R}from"./chunk-PYI2MI4Q.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as _}from"./chunk-FKVZRPV5.js";import{a as K,b as V,c as z,d as F,e as u,f as p}from"./chunk-HEAQVSNS.js";import{a as A,e as T}from"./chunk-WUWBZPUK.js";import{d as M,h as G,o as W,r as X}from"./chunk-FODLDLE2.js";import{a as c,d as P,e as oe,f as re,g as ae}from"./chunk-YKXDMIHQ.js";var U=P(re(),1),Y=P(oe(),1);var t=P(ae(),1);var se=P(re(),1);var Q=P(oe(),1);var h=P(ae(),1);var ie=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","X"),le=c(a=>a.toSorted((e,i)=>e.scheduledFor-i.scheduledFor),"F"),ce=c((a,e,i)=>e!==void 0?e:i===void 0?d=>a.cancelScheduledJob(d):void 0,"Y"),de=c(a=>{let e=(0,se.c)(16),{cancelJob:i,loadJobs:d}=a===void 0?{}:a,f=R(),r=M(),l=d===void 0,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-scheduled-jobs"],e[0]=o):o=e[0];let N=E(o,async()=>{let v=await(d??(()=>f.listScheduledJobs()))();return le(v)}),[x,n]=(0,Q.useState)(void 0),[s,m]=(0,Q.useState)(void 0),y,k;e[1]!==f||e[2]!==l?(y=c(()=>{if(l)return f.subscribeScheduledJobs(v=>{m(void 0),n(le(v))})},"v"),k=[l,f],e[1]=f,e[2]=l,e[3]=y,e[4]=k):(y=e[3],k=e[4]),(0,Q.useEffect)(y,k);let g;e[5]!==N?(g=c(()=>{N.refetch()},"y"),e[5]=N,e[6]=g):g=e[6],O(g,!l);let J=ce(f,i,d),b=x??N.data,j=s??N.error,I=c(async v=>{if(J!==void 0){m(void 0);try{await J(v),l||N.refetch()}catch(D){m(G(D))}}},"A"),q="flex flex-col gap-3",B="lunora-scheduled-jobs",S;e[7]!==j?(S=j!==null&&(0,h.jsx)("p",{className:"text-sm text-destructive","data-testid":"sj-error",role:"alert",children:j}),e[7]=j,e[8]=S):S=e[8];let L;e[9]!==b?.length||e[10]!==r?(L=b?.length===0&&(0,h.jsx)(_,{description:r("Jobs queued with runAfter / runAt will appear here."),icon:(0,h.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,h.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,h.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"sj-empty",title:r("No scheduled jobs.")}),e[9]=b?.length,e[10]=r,e[11]=L):L=e[11];let $=b!==void 0&&b.length>0&&(0,h.jsx)(A,{className:"overflow-hidden py-0",children:(0,h.jsx)(T,{className:"px-0",children:(0,h.jsxs)(K,{"data-testid":"sj-table",children:[(0,h.jsx)(V,{children:(0,h.jsxs)(F,{children:[(0,h.jsx)(u,{children:r("function")}),(0,h.jsx)(u,{children:r("scheduled for")}),(0,h.jsx)(u,{children:r("pool")}),(0,h.jsx)(u,{children:r("attempts")}),(0,h.jsx)(u,{children:r("shard")}),(0,h.jsx)(u,{children:r("id")}),J!==void 0&&(0,h.jsx)(u,{"aria-label":r("Actions")})]})}),(0,h.jsx)(z,{children:b.map(v=>(0,h.jsxs)(F,{"data-testid":`sj-row-${v.id}`,children:[(0,h.jsx)(p,{className:"font-mono text-xs",children:v.workflow??v.functionPath}),(0,h.jsx)(p,{className:"text-muted-foreground tabular-nums",children:ie(v.scheduledFor)}),(0,h.jsx)(p,{className:"font-mono text-xs",children:v.pool??""}),(0,h.jsx)(p,{className:"tabular-nums",children:v.attempts??0}),(0,h.jsx)(p,{children:v.shardKey??""}),(0,h.jsx)(p,{className:"font-mono text-xs",children:v.id}),J!==void 0&&(0,h.jsx)(p,{className:"text-right",children:(0,h.jsx)(H,{confirmLabel:r("Cancel job?"),onConfirm:c(()=>{W(I(v.id))},"onConfirm"),testId:`sj-cancel-${v.id}`,children:r("Cancel")})})]},v.id))})]})})}),w;return e[12]!==$||e[13]!==S||e[14]!==L?(w=(0,h.jsxs)("div",{className:q,"data-testid":B,children:[S,L,$]}),e[12]=$,e[13]=S,e[14]=L,e[15]=w):w=e[15],w},"he");var he={kind:"idle"},me=c((a,e,i)=>i!==void 0?i:e===void 0?d=>a.runCronJob(d):void 0,"re"),ue=c(({loadCronJobs:a,runCronJob:e}={})=>{let i=R(),d=M(),[f,r]=(0,Y.useState)({}),l=E(["lunora-cron-jobs",a?"custom":"default"],()=>(a??(()=>i.getCronJobs()))()),{data:o,error:N}=l,x=me(i,a,e),n=c(async s=>{if(x!==void 0){r(m=>({...m,[s]:{kind:"running"}}));try{await x(s),r(m=>({...m,[s]:{kind:"ok"}})),l.refetch()}catch(m){r(y=>({...y,[s]:{kind:"error",message:G(m)}}))}}},"i");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[N!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:N}),o?.length===0&&(0,t.jsx)(_,{description:d("Triggers declared with the cronJobs() builder appear here."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,t.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:d("No cron triggers.")}),o!==void 0&&o.length>0&&(0,t.jsx)(A,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"cron-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(u,{children:d("name")}),(0,t.jsx)(u,{children:d("schedule")}),(0,t.jsx)(u,{children:d("target")}),(0,t.jsx)(u,{children:d("shard")}),x!==void 0&&(0,t.jsx)(u,{"aria-label":d("Actions")})]})}),(0,t.jsx)(z,{children:o.map(s=>{let m=f[s.name]??he;return(0,t.jsxs)(F,{"data-testid":`cron-row-${s.name}`,children:[(0,t.jsx)(p,{children:s.name}),(0,t.jsx)(p,{className:"font-mono text-xs tabular-nums",children:s.cron}),(0,t.jsx)(p,{children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[s.workflow===void 0?(0,t.jsx)(Z,{variant:"outline",children:d("function")}):(0,t.jsx)(Z,{variant:"secondary",children:d("workflow")}),(0,t.jsx)("span",{className:"font-mono text-xs",children:s.workflow??s.functionPath})]})}),(0,t.jsx)(p,{children:s.shardKey??""}),x!==void 0&&(0,t.jsx)(p,{className:"text-right",children:(0,t.jsxs)("span",{className:"flex items-center justify-end gap-2",children:[m.kind==="ok"&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${s.name}`,children:d("ran")}),m.kind==="error"&&(0,t.jsx)("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${s.name}`,role:"alert",children:m.message}),(0,t.jsx)(H,{confirmLabel:d("Run now?"),disabled:m.kind==="running",onConfirm:c(()=>{W(n(s.name))},"onConfirm"),testId:`cron-run-${s.name}`,children:m.kind==="running"?d("Running\u2026"):d("Run now")})]})})]},`${s.cron}:${s.name}`)})})]})})})]})},"le"),pe=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","se"),fe=c(a=>{let e=(0,U.c)(34),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadJobs:d,removeJob:f,retryJob:r}=i,l=R(),o=M(),N;e[2]===Symbol.for("react.memo_cache_sentinel")?(N=["lunora-dead-jobs"],e[2]=N):N=e[2];let x;e[3]!==l||e[4]!==d?(x=c(async()=>(await(d??(()=>l.listDeadJobs()))()).toSorted(be),"h"),e[3]=l,e[4]=d,e[5]=x):x=e[5];let n=E(N,x),s=n.data,[m,y]=(0,Y.useState)(void 0),k=n.error??m,g=d===void 0,J;e[6]!==l||e[7]!==g||e[8]!==r?(J=r??(g?C=>l.retryDeadJob(C):void 0),e[6]=l,e[7]=g,e[8]=r,e[9]=J):J=e[9];let b=J,j;e[10]!==l||e[11]!==g||e[12]!==f?(j=f??(g?C=>l.removeDeadJob(C):void 0),e[10]=l,e[11]=g,e[12]=f,e[13]=j):j=e[13];let I=j,q;e[14]!==n?(q=c(()=>{n.refetch()},"$"),e[14]=n,e[15]=q):q=e[15],O(q,!0);let B;e[16]!==n?(B=c(async C=>{y(void 0);try{await C,n.refetch()}catch(ne){y(G(ne))}},"I"),e[16]=n,e[17]=B):B=e[17];let S=B,L=b!==void 0||I!==void 0,$;e[18]!==k?($=k!==void 0&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:k}),e[18]=k,e[19]=$):$=e[19];let w;e[20]!==s?.length||e[21]!==o?(w=s?.length===0&&(0,t.jsx)(_,{description:o("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:o("No dead-letter jobs.")}),e[20]=s?.length,e[21]=o,e[22]=w):w=e[22];let v;e[23]!==S||e[24]!==L||e[25]!==s||e[26]!==I||e[27]!==b||e[28]!==o?(v=s!==void 0&&s.length>0&&(0,t.jsx)(A,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"dlq-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(u,{children:o("function")}),(0,t.jsx)(u,{children:o("attempts")}),(0,t.jsx)(u,{children:o("last tried")}),(0,t.jsx)(u,{children:o("pool")}),(0,t.jsx)(u,{children:o("shard")}),(0,t.jsx)(u,{children:o("id")}),L&&(0,t.jsx)(u,{"aria-label":o("Actions")})]})}),(0,t.jsx)(z,{children:s.map(C=>(0,t.jsxs)(F,{"data-testid":`dlq-row-${C.id}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:C.workflow??C.functionPath}),(0,t.jsx)(p,{className:"tabular-nums",children:C.attempts??0}),(0,t.jsx)(p,{className:"text-muted-foreground tabular-nums",children:pe(C.scheduledFor)}),(0,t.jsx)(p,{className:"font-mono text-xs",children:C.pool??""}),(0,t.jsx)(p,{children:C.shardKey??""}),(0,t.jsx)(p,{className:"font-mono text-xs",children:C.id}),L&&(0,t.jsx)(p,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1.5",children:[b!==void 0&&(0,t.jsx)(ee,{"data-testid":`dlq-retry-${C.id}`,onClick:c(()=>{W(S(b(C.id)))},"onClick"),size:"sm",type:"button",variant:"outline",children:o("Retry")}),I!==void 0&&(0,t.jsx)(H,{confirmLabel:o("Drop job?"),onConfirm:c(()=>{W(S(I(C.id)))},"onConfirm"),testId:`dlq-remove-${C.id}`,children:o("Drop")})]})})]},C.id))})]})})}),e[23]=S,e[24]=L,e[25]=s,e[26]=I,e[27]=b,e[28]=o,e[29]=v):v=e[29];let D;return e[30]!==v||e[31]!==$||e[32]!==w?(D=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[$,w,v]}),e[30]=v,e[31]=$,e[32]=w,e[33]=D):D=e[33],D},"ne");function be(a,e){return(e.attempts??0)-(a.attempts??0)}c(be,"oe");var te=c(a=>{let e=(0,U.c)(8),{label:i,testId:d,value:f}=a,r;e[0]!==i?(r=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:i}),e[0]=i,e[1]=r):r=e[1];let l;e[2]!==d||e[3]!==f?(l=(0,t.jsx)("span",{className:"text-2xl font-semibold tabular-nums","data-testid":d,children:f}),e[2]=d,e[3]=f,e[4]=l):l=e[4];let o;return e[5]!==r||e[6]!==l?(o=(0,t.jsx)(A,{className:"flex-1 py-0",children:(0,t.jsxs)(T,{className:"flex flex-col gap-1 p-4",children:[r,l]})}),e[5]=r,e[6]=l,e[7]=o):o=e[7],o},"E"),ve=c(a=>{let e=(0,U.c)(25),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadStatus:d}=i,f=R(),r=M(),l=d===void 0,o;e[2]!==l?(o=["lunora-scheduler-status",l],e[2]=l,e[3]=o):o=e[3];let N;e[4]!==f||e[5]!==d?(N=c(async()=>{let j=await(d??(()=>f.schedulerStatus()))();return{...j,pools:j.pools.toSorted(xe)}},"y"),e[4]=f,e[5]=d,e[6]=N):N=e[6];let x=E(o,N),{data:n,error:s}=x,m;e[7]!==x?(m=c(()=>{x.refetch()},"d"),e[7]=x,e[8]=m):m=e[8],O(m,!0);let y;e[9]!==s?(y=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:s}),e[9]=s,e[10]=y):y=e[10];let k;e[11]!==n||e[12]!==r?(k=n!==void 0&&(0,t.jsxs)("div",{className:"flex gap-3","data-testid":"pools-totals",children:[(0,t.jsx)(te,{label:r("backlog"),testId:"pools-backlog",value:n.backlog}),(0,t.jsx)(te,{label:r("in flight"),testId:"pools-inflight",value:n.inFlight}),(0,t.jsx)(te,{label:r("pools"),testId:"pools-count",value:n.pools.length})]}),e[11]=n,e[12]=r,e[13]=k):k=e[13];let g;e[14]!==n?.pools.length||e[15]!==r?(g=n?.pools.length===0&&(0,t.jsx)(_,{description:r("Pools created with createWorkpool appear here once they have activity."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:r("No workpools.")}),e[14]=n?.pools.length,e[15]=r,e[16]=g):g=e[16];let J;e[17]!==n||e[18]!==r?(J=n!==void 0&&n.pools.length>0&&(0,t.jsx)(A,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"pools-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(u,{children:r("pool")}),(0,t.jsx)(u,{children:r("queued")}),(0,t.jsx)(u,{children:r("in flight")}),(0,t.jsx)(u,{children:r("max concurrency")})]})}),(0,t.jsx)(z,{children:n.pools.map(ge)})]})})}),e[17]=n,e[18]=r,e[19]=J):J=e[19];let b;return e[20]!==y||e[21]!==k||e[22]!==g||e[23]!==J?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[y,k,g,J]}),e[20]=y,e[21]=k,e[22]=g,e[23]=J,e[24]=b):b=e[24],b},"ae");function xe(a,e){return e.queued-a.queued}c(xe,"ie");function ge(a){return(0,t.jsxs)(F,{"data-testid":`pools-row-${a.name}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:a.name}),(0,t.jsx)(p,{className:"tabular-nums",children:a.queued}),(0,t.jsxs)(p,{className:"tabular-nums",children:[a.inFlight," / ",a.maxConcurrency]}),(0,t.jsx)(p,{className:"tabular-nums",children:a.maxConcurrency})]},a.name)}c(ge,"de");var Ne=["jobs","dead","pools","cron"],Ve=c(a=>{let e=(0,U.c)(41),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadCronJobs:d,scheduledCancel:f,scheduledLoad:r}=i,l=M(),[o,N]=(0,Y.useState)("jobs"),x;e[2]!==l?(x=l("Cron triggers"),e[2]=l,e[3]=x):x=e[3];let n;e[4]!==l?(n=l("Dead letter"),e[4]=l,e[5]=n):n=e[5];let s;e[6]!==l?(s=l("Scheduled jobs"),e[6]=l,e[7]=s):s=e[7];let m;e[8]!==l?(m=l("Pools"),e[8]=l,e[9]=m):m=e[9];let y;e[10]!==x||e[11]!==n||e[12]!==s||e[13]!==m?(y={cron:x,dead:n,jobs:s,pools:m},e[10]=x,e[11]=n,e[12]=s,e[13]=m,e[14]=y):y=e[14];let k=y,g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=c(w=>{N(w.currentTarget.dataset.view)},"f"),e[15]=g):g=e[15];let J=g,b;e[16]!==l?(b=l("Schedule view"),e[16]=l,e[17]=b):b=e[17];let j;e[18]!==o||e[19]!==k?(j=Ne.map(w=>(0,t.jsx)(ee,{"aria-selected":o===w,"data-testid":`schedule-view-${w}`,"data-view":w,onClick:J,role:"tab",size:"sm",type:"button",variant:o===w?"default":"outline",children:k[w]},w)),e[18]=o,e[19]=k,e[20]=j):j=e[20];let I;e[21]!==b||e[22]!==j?(I=(0,t.jsx)("div",{"aria-label":b,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:j}),e[21]=b,e[22]=j,e[23]=I):I=e[23];let q;e[24]!==f||e[25]!==r||e[26]!==o?(q=o==="jobs"&&(0,t.jsx)(de,{cancelJob:f,loadJobs:r}),e[24]=f,e[25]=r,e[26]=o,e[27]=q):q=e[27];let B;e[28]!==o?(B=o==="dead"&&(0,t.jsx)(fe,{}),e[28]=o,e[29]=B):B=e[29];let S;e[30]!==o?(S=o==="pools"&&(0,t.jsx)(ve,{}),e[30]=o,e[31]=S):S=e[31];let L;e[32]!==d||e[33]!==o?(L=o==="cron"&&(0,t.jsx)(ue,{loadCronJobs:d}),e[32]=d,e[33]=o,e[34]=L):L=e[34];let $;return e[35]!==I||e[36]!==q||e[37]!==B||e[38]!==S||e[39]!==L?($=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[I,q,B,S,L]}),e[35]=I,e[36]=q,e[37]=B,e[38]=S,e[39]=L,e[40]=$):$=e[40],$},"Ie");export{Ve as SchedulePanel};
@@ -1 +1 @@
1
- import{a as G}from"./chunk-EA2JKR5D.js";import{a as x}from"./chunk-IMOHEGMV.js";import{a as U}from"./chunk-2DX5MROH.js";import{b as M}from"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import{W as O}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as p}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as w}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as E}from"./chunk-4ZEL6BYL.js";import{f as D}from"./chunk-SZSHO6RE.js";import"./chunk-FSRSK4LY.js";import"./chunk-CEA2QYAI.js";import{d as K,e as _,f as z,h as B,o as P,r as q}from"./chunk-FODLDLE2.js";import{a as s,d as J,e as ie,g as oe}from"./chunk-YKXDMIHQ.js";var i=J(ie(),1);var e=J(oe(),1);var de=s(r=>r.kind==="id"?r.table===void 0?"id":`id<${r.table}>`:r.kind==="array"?r.element===void 0?"array":`${r.element}[]`:r.kind,"oe"),le=s(r=>r===void 0||r.length===0?"()":`(${r.map(o=>`${o.name}${o.optional?"?":""}: ${de(o)}`).join(", ")})`,"ie"),ce=s(r=>{switch(r){case"array":return[];case"bigint":case"number":return 0;case"boolean":return!1;case"object":case"record":return{};default:return""}},"de"),ue=s(r=>{let o={};for(let a of r??[])a.optional||(o[a.name]=ce(a.kind));return JSON.stringify(o,void 0,2)},"le"),me=z(E.runAs),fe=10,he=s(r=>r===void 0?"undefined":JSON.stringify(r,null,2),"me"),Fe=s(({functions:r,runAsIdentity:o=!1}={})=>{let a=K(),u=D(),[H,Q]=(0,i.useState)(null),[k,V]=(0,i.useState)(null),g=r??H??[],[I,S]=(0,i.useState)(""),[m,b]=(0,i.useState)("{}"),[c,F]=(0,i.useState)(""),[f,W]=(0,i.useState)(""),[v,h]=(0,i.useState)("idle"),[X,y]=(0,i.useState)(void 0),[C,N]=(0,i.useState)(null),[$,Y]=(0,i.useState)([]);(0,i.useEffect)(()=>{if(r!==void 0)return;let t=!1;return u.listFunctions().then(d=>(t||Q(d),d)).catch(d=>{t||V(B(d))}),()=>{t=!0}},[u,r]);let A=I===""?g[0]?.path??"":I,n=g.find(t=>t.path===A),Z=s(async()=>{if(!n)return;let t;try{t=m.trim()===""?{}:JSON.parse(m)}catch(l){h("error"),y(void 0),N(a("Invalid JSON args: {message}",{message:l.message}));return}let d={__lunoraRef:n.path},R=c.trim()===""?{}:{shardKey:c.trim()},j=o?f.trim():"",L=s(l=>{Y(T=>[{argsText:m,at:Date.now(),id:(T[0]?.id??0)+1,kind:n.kind,path:n.path,shardKey:c,status:l},...T].slice(0,fe))},"$");h("running"),N(null);try{let l=j===""?await _(u,n.kind,d,t,R):await u.query(me,{args:t,functionPath:n.path,userId:j},R);M(c),y(l),h("success"),L("success")}catch(l){y(void 0),N(l.message),h("error"),L("error")}},"J"),ee=s(t=>{S(t.path),b(t.argsText),F(t.shardKey)},"M"),te=s(t=>{S(t.target.value)},"P"),re=s(t=>{b(t.target.value)},"z"),ae=s(t=>{W(t.target.value)},"q"),se=s(()=>{P(Z())},"H"),ne=s(()=>{b(ue(n?.args))},"V");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-runner",children:[k!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"function-discover-error",role:"alert",children:k}),(0,e.jsxs)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsx)(x,{htmlFor:"function-select",children:a("Function")}),(0,e.jsx)("select",{"aria-label":a("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50","data-testid":"function-select",id:"function-select",onChange:te,value:A,children:g.map(t=>(0,e.jsxs)("option",{value:t.path,children:[t.path," (",t.kind,")"]},t.path))}),n!==void 0&&(0,e.jsxs)("p",{className:"text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"mr-1.5 font-medium",children:a("Signature")}),(0,e.jsx)("code",{className:"font-mono","data-testid":"function-signature",children:le(n.args)})]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)(x,{htmlFor:"args-input",children:a("Arguments")}),(0,e.jsx)(p,{"data-testid":"prefill-button",disabled:n===void 0,onClick:ne,size:"xs",type:"button",variant:"ghost",children:a("Prefill")})]}),(0,e.jsx)(G,{"aria-label":a("Arguments"),className:"font-mono text-xs","data-testid":"args-input",id:"args-input",onChange:re,value:m})]}),(0,e.jsx)(U,{onChange:F,testId:"shard-input",value:c}),o&&(0,e.jsxs)("div",{className:"flex flex-col gap-1.5","data-testid":"run-as-field",children:[(0,e.jsx)(x,{htmlFor:"run-as-input",children:a("Run as identity (userId)")}),(0,e.jsx)(O,{"aria-label":a("Run as identity (userId)"),className:"font-mono text-xs","data-testid":"run-as-input",id:"run-as-input",onChange:ae,placeholder:a("Leave empty to run as admin"),value:f}),(0,e.jsx)("p",{className:"text-[11px] text-muted-foreground",children:a("Dev only: runs the function as this user so you can test auth and RLS. Forged over the admin gate.")})]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(p,{"data-testid":"run-button",disabled:v==="running"||n===void 0,onClick:se,type:"button",children:a("Run")}),n!==void 0&&(0,e.jsx)(w,{variant:"outline",children:n.kind}),o&&f.trim()!==""&&(0,e.jsx)(w,{"data-testid":"run-as-badge",variant:"secondary",children:a("as {userId}",{userId:f.trim()})})]})]}),v==="error"&&C!==null&&(0,e.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"error",role:"alert",children:C}),v==="success"&&(0,e.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"result",children:he(X)}),$.length>0&&(0,e.jsx)("ul",{className:"flex flex-col overflow-hidden rounded-xl border border-border","data-testid":"fn-history",children:$.map((t,d)=>(0,e.jsxs)("li",{className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-2 text-sm last:border-b-0","data-testid":"fn-history-row",children:[(0,e.jsx)("span",{className:t.status==="success"?"text-success":"text-destructive","data-testid":`fn-history-status-${d.toString()}`,children:t.status==="success"?"\u2713":"\u2717"})," ",(0,e.jsxs)("span",{className:"font-mono text-xs",children:[t.path," (",t.kind,")"]})," ",(0,e.jsx)("time",{className:"text-xs text-muted-foreground",children:q(t.at)})," ",(0,e.jsx)(p,{className:"ml-auto","data-testid":`fn-history-load-${d.toString()}`,onClick:s(()=>{ee(t)},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Load")})]},t.id))})]})},"Ae");export{Fe as FunctionRunner};
1
+ import{a as G}from"./chunk-EA2JKR5D.js";import{a as x}from"./chunk-IMOHEGMV.js";import{a as U}from"./chunk-2DX5MROH.js";import{b as M}from"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import{W as O}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as p}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as w}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as E}from"./chunk-4ZEL6BYL.js";import{f as D}from"./chunk-PYI2MI4Q.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{d as K,e as _,f as z,h as B,o as P,r as q}from"./chunk-FODLDLE2.js";import{a as s,d as J,e as ie,g as oe}from"./chunk-YKXDMIHQ.js";var i=J(ie(),1);var e=J(oe(),1);var de=s(r=>r.kind==="id"?r.table===void 0?"id":`id<${r.table}>`:r.kind==="array"?r.element===void 0?"array":`${r.element}[]`:r.kind,"oe"),le=s(r=>r===void 0||r.length===0?"()":`(${r.map(o=>`${o.name}${o.optional?"?":""}: ${de(o)}`).join(", ")})`,"ie"),ce=s(r=>{switch(r){case"array":return[];case"bigint":case"number":return 0;case"boolean":return!1;case"object":case"record":return{};default:return""}},"de"),ue=s(r=>{let o={};for(let a of r??[])a.optional||(o[a.name]=ce(a.kind));return JSON.stringify(o,void 0,2)},"le"),me=z(E.runAs),fe=10,he=s(r=>r===void 0?"undefined":JSON.stringify(r,null,2),"me"),Fe=s(({functions:r,runAsIdentity:o=!1}={})=>{let a=K(),u=D(),[H,Q]=(0,i.useState)(null),[k,V]=(0,i.useState)(null),g=r??H??[],[I,S]=(0,i.useState)(""),[m,b]=(0,i.useState)("{}"),[c,F]=(0,i.useState)(""),[f,W]=(0,i.useState)(""),[v,h]=(0,i.useState)("idle"),[X,y]=(0,i.useState)(void 0),[C,N]=(0,i.useState)(null),[$,Y]=(0,i.useState)([]);(0,i.useEffect)(()=>{if(r!==void 0)return;let t=!1;return u.listFunctions().then(d=>(t||Q(d),d)).catch(d=>{t||V(B(d))}),()=>{t=!0}},[u,r]);let A=I===""?g[0]?.path??"":I,n=g.find(t=>t.path===A),Z=s(async()=>{if(!n)return;let t;try{t=m.trim()===""?{}:JSON.parse(m)}catch(l){h("error"),y(void 0),N(a("Invalid JSON args: {message}",{message:l.message}));return}let d={__lunoraRef:n.path},R=c.trim()===""?{}:{shardKey:c.trim()},j=o?f.trim():"",L=s(l=>{Y(T=>[{argsText:m,at:Date.now(),id:(T[0]?.id??0)+1,kind:n.kind,path:n.path,shardKey:c,status:l},...T].slice(0,fe))},"$");h("running"),N(null);try{let l=j===""?await _(u,n.kind,d,t,R):await u.query(me,{args:t,functionPath:n.path,userId:j},R);M(c),y(l),h("success"),L("success")}catch(l){y(void 0),N(l.message),h("error"),L("error")}},"J"),ee=s(t=>{S(t.path),b(t.argsText),F(t.shardKey)},"M"),te=s(t=>{S(t.target.value)},"P"),re=s(t=>{b(t.target.value)},"z"),ae=s(t=>{W(t.target.value)},"q"),se=s(()=>{P(Z())},"H"),ne=s(()=>{b(ue(n?.args))},"V");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-runner",children:[k!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"function-discover-error",role:"alert",children:k}),(0,e.jsxs)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsx)(x,{htmlFor:"function-select",children:a("Function")}),(0,e.jsx)("select",{"aria-label":a("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50","data-testid":"function-select",id:"function-select",onChange:te,value:A,children:g.map(t=>(0,e.jsxs)("option",{value:t.path,children:[t.path," (",t.kind,")"]},t.path))}),n!==void 0&&(0,e.jsxs)("p",{className:"text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"mr-1.5 font-medium",children:a("Signature")}),(0,e.jsx)("code",{className:"font-mono","data-testid":"function-signature",children:le(n.args)})]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)(x,{htmlFor:"args-input",children:a("Arguments")}),(0,e.jsx)(p,{"data-testid":"prefill-button",disabled:n===void 0,onClick:ne,size:"xs",type:"button",variant:"ghost",children:a("Prefill")})]}),(0,e.jsx)(G,{"aria-label":a("Arguments"),className:"font-mono text-xs","data-testid":"args-input",id:"args-input",onChange:re,value:m})]}),(0,e.jsx)(U,{onChange:F,testId:"shard-input",value:c}),o&&(0,e.jsxs)("div",{className:"flex flex-col gap-1.5","data-testid":"run-as-field",children:[(0,e.jsx)(x,{htmlFor:"run-as-input",children:a("Run as identity (userId)")}),(0,e.jsx)(O,{"aria-label":a("Run as identity (userId)"),className:"font-mono text-xs","data-testid":"run-as-input",id:"run-as-input",onChange:ae,placeholder:a("Leave empty to run as admin"),value:f}),(0,e.jsx)("p",{className:"text-[11px] text-muted-foreground",children:a("Dev only: runs the function as this user so you can test auth and RLS. Forged over the admin gate.")})]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(p,{"data-testid":"run-button",disabled:v==="running"||n===void 0,onClick:se,type:"button",children:a("Run")}),n!==void 0&&(0,e.jsx)(w,{variant:"outline",children:n.kind}),o&&f.trim()!==""&&(0,e.jsx)(w,{"data-testid":"run-as-badge",variant:"secondary",children:a("as {userId}",{userId:f.trim()})})]})]}),v==="error"&&C!==null&&(0,e.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"error",role:"alert",children:C}),v==="success"&&(0,e.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"result",children:he(X)}),$.length>0&&(0,e.jsx)("ul",{className:"flex flex-col overflow-hidden rounded-xl border border-border","data-testid":"fn-history",children:$.map((t,d)=>(0,e.jsxs)("li",{className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-2 text-sm last:border-b-0","data-testid":"fn-history-row",children:[(0,e.jsx)("span",{className:t.status==="success"?"text-success":"text-destructive","data-testid":`fn-history-status-${d.toString()}`,children:t.status==="success"?"\u2713":"\u2717"})," ",(0,e.jsxs)("span",{className:"font-mono text-xs",children:[t.path," (",t.kind,")"]})," ",(0,e.jsx)("time",{className:"text-xs text-muted-foreground",children:q(t.at)})," ",(0,e.jsx)(p,{className:"ml-auto","data-testid":`fn-history-load-${d.toString()}`,onClick:s(()=>{ee(t)},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Load")})]},t.id))})]})},"Ae");export{Fe as FunctionRunner};
@@ -1 +1 @@
1
- import{a as te}from"./chunk-EA2JKR5D.js";import{W as Z}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as O}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import{a as K}from"./chunk-4ZEL6BYL.js";import{c as ee}from"./chunk-5G2MAI3G.js";import{f as M}from"./chunk-SZSHO6RE.js";import"./chunk-FSRSK4LY.js";import"./chunk-CEA2QYAI.js";import{a as P}from"./chunk-FKVZRPV5.js";import{a as D,b as F,c as L,d as h,e as o,f as i}from"./chunk-HEAQVSNS.js";import{a as E,e as _}from"./chunk-WUWBZPUK.js";import{d as H,f as Q,g as V,h as W,o as $}from"./chunk-FODLDLE2.js";import{a as n,d as Y,e as ne,g as le}from"./chunk-YKXDMIHQ.js";var c=Y(ne(),1);var e=Y(le(),1);var oe=["queued","running","paused","waiting","complete","errored","terminated"],ie=["pause","resume","terminate"],de="WORKFLOWS_NOT_CONFIGURED",ce=n(l=>typeof l=="object"&&l!==null&&l.code===de,"ie"),me=n(l=>{let r=l.error??l.output;if(r===void 0)return"\u2014";try{return JSON.stringify(r)}catch{return"(unserializable)"}},"de"),ue=n(({loadDetail:l,loadInstances:r,readOnly:N,runAction:j,workflowName:g})=>{let A=M(),s=H(),[p,k]=(0,c.useState)(null),[S,C]=(0,c.useState)(null),[v,z]=(0,c.useState)(""),[b,f]=(0,c.useState)(null),[J,I]=(0,c.useState)(!1),[R,U]=(0,c.useState)(null),x=l??(a=>A.getWorkflowInstance(a)),w=N?void 0:j??(r===void 0?a=>A.setWorkflowInstanceStatus(a):void 0),T=n(async()=>{f(null),I(!1);let a=v===""?void 0:v;try{if(r===void 0){let d=await A.listWorkflowInstances({name:g,status:a});if(d.configured===!1){k(null),I(!0);return}k(d.instances);return}k(await r({name:g,status:a}))}catch(d){k(null),ce(d)?I(!0):f(W(d))}},"L");(0,c.useEffect)(()=>{C(null),$(T())},[g,v]);let q=n(async a=>{f(null);try{C(await x({id:a,name:g}))}catch(d){f(W(d))}},"K"),B=n(async(a,d)=>{if(w!==void 0){U(a),f(null);try{await w({action:d,id:a,name:g}),await T()}catch(G){f(W(G))}U(null)}},"q");return(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:s("Instance history")}),(0,e.jsxs)("select",{"aria-label":s("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:n(a=>{z(a.target.value)},"onChange"),value:v,children:[(0,e.jsx)("option",{value:"",children:s("All statuses")}),oe.map(a=>(0,e.jsx)("option",{value:a,children:a},a))]})]}),b!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:b}),J&&(0,e.jsx)(P,{description:s("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:s("Workflow inspection not configured")}),!J&&p!==null&&p.length===0&&(0,e.jsx)(P,{description:s("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:s("No instances")}),p!==null&&p.length>0&&(0,e.jsx)(E,{className:"overflow-hidden py-0",children:(0,e.jsx)(_,{className:"px-0",children:(0,e.jsxs)(D,{"data-testid":"workflow-instances-table",children:[(0,e.jsx)(F,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:s("Instance id")}),(0,e.jsx)(o,{children:s("Status")}),(0,e.jsx)(o,{children:s("Created")}),(0,e.jsx)(o,{children:s("Ended")}),(0,e.jsx)(o,{"aria-label":s("Actions")})]})}),(0,e.jsx)(L,{children:p.map(a=>(0,e.jsxs)(h,{"data-testid":`workflow-instance-${a.id}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:a.id}),(0,e.jsx)(i,{className:"font-mono text-xs",children:a.status}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.createdOn??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.endedOn??"\u2014"}),(0,e.jsx)(i,{className:"text-right",children:(0,e.jsxs)("div",{className:"flex justify-end gap-1.5",children:[(0,e.jsx)(O,{"data-testid":`workflow-instance-steps-${a.id}`,onClick:n(()=>{$(q(a.id))},"onClick"),size:"sm",type:"button",variant:"outline",children:s("Steps")}),w!==void 0&&ie.map(d=>(0,e.jsx)(O,{"data-testid":`workflow-instance-${d}-${a.id}`,disabled:R===a.id,onClick:n(()=>{$(B(a.id,d))},"onClick"),size:"sm",type:"button",variant:"ghost",children:s(d)},d))]})})]},a.id))})]})})}),S!==null&&(0,e.jsx)(E,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:(0,e.jsxs)(_,{className:"flex flex-col gap-2 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[s("Steps")," \xB7 ",S.id]}),(0,e.jsx)(O,{"data-testid":"workflow-instance-detail-close",onClick:n(()=>{C(null)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Close")})]}),S.steps.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:s("This instance has no recorded steps yet.")}):(0,e.jsxs)(D,{"data-testid":"workflow-instance-steps",children:[(0,e.jsx)(F,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:s("Step")}),(0,e.jsx)(o,{children:s("Type")}),(0,e.jsx)(o,{children:s("Attempts")}),(0,e.jsx)(o,{children:s("Started")}),(0,e.jsx)(o,{children:s("Output")})]})}),(0,e.jsx)(L,{children:S.steps.map((a,d)=>(0,e.jsxs)(h,{"data-testid":`workflow-step-${String(d)}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:a.name}),(0,e.jsx)(i,{className:"text-xs text-muted-foreground",children:a.type??"\u2014"}),(0,e.jsx)(i,{className:"tabular-nums",children:a.attempts??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.start??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:me(a)})]},`${a.name}:${String(d)}`))})]})]})})]})},"ce"),fe=Q(K.createWorkflowInstance),he=Q(K.getWorkflowInstanceStatus),pe=n(l=>{if(l.error)return`${l.error.name}: ${l.error.message}`;if(l.output===void 0)return"\u2014";try{return JSON.stringify(l.output)}catch{return"(unserializable)"}},"fe"),xe=n((l,r)=>l.some(N=>N.exportName===r)?r:l[0]?.exportName??"","he"),We=n(()=>{let l=M(),r=H(),{data:N,error:j}=ee(K.listWorkflows,{}),[g,A]=(0,c.useState)(""),[s,p]=(0,c.useState)(""),[k,S]=(0,c.useState)(""),[C,v]=(0,c.useState)(!1),[z,b]=(0,c.useState)(null),[f,J]=(0,c.useState)([]),[I,R]=(0,c.useState)(null),U=N!==void 0,x=Array.isArray(N?.workflows)?[...N.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],w=xe(x,g),T=x.find(t=>t.exportName===w),q=n(t=>{J(u=>{let m=u.filter(y=>!(y.exportName===t.exportName&&y.id===t.id));return[t,...m]})},"C"),B=n(async()=>{let t=w;if(t==="")return;let u,m=k.trim();if(m!=="")try{u=JSON.parse(m)}catch{b(r("Params must be valid JSON"));return}v(!0),b(null);try{let y=s.trim(),X=await l.query(fe,{exportName:t,id:y===""?void 0:y,params:u},V(""));q({exportName:t,id:X.id,status:X.status}),p("")}catch(y){b(W(y))}v(!1)},"L"),a=n(()=>{$(B())},"K"),d=n(async(t,u)=>{R(u);try{let m=await l.query(he,{exportName:t,id:u},V(""));q({error:m.error,exportName:t,id:m.id,output:m.output,status:m.status})}catch(m){b(W(m))}R(null)},"q"),G=n(t=>{A(t.target.value)},"r"),ae=n(t=>{p(t.target.value)},"l"),re=n(t=>{S(t.target.value)},"G"),se=n(t=>{let{export:u,id:m}=t.currentTarget.dataset;u!==void 0&&m!==void 0&&$(d(u,m))},"ee");return(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[j!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:j}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:r("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),U&&x.length===0?(0,e.jsx)(P,{description:r("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:r("No workflows defined")}):(0,e.jsx)(E,{className:"overflow-hidden py-0",children:(0,e.jsx)(_,{className:"px-0",children:(0,e.jsxs)(D,{"data-testid":"workflows-table",children:[(0,e.jsx)(F,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:r("Export")}),(0,e.jsx)(o,{children:r("Name")}),(0,e.jsx)(o,{children:r("Class")}),(0,e.jsx)(o,{children:r("Binding")})]})}),(0,e.jsx)(L,{children:x.map(t=>(0,e.jsxs)(h,{"data-testid":`workflows-row-${t.exportName}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.name}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.className}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.binding})]},t.exportName))})]})})}),x.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:r("Start instance")}),z!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:z}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("select",{"aria-label":r("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:G,value:w,children:x.map(t=>(0,e.jsx)("option",{value:t.exportName,children:t.exportName},t.exportName))}),(0,e.jsx)(Z,{"aria-label":r("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:ae,placeholder:r("Instance id (optional)"),value:s}),(0,e.jsx)(O,{"data-testid":"workflows-start-button",disabled:C||w==="",onClick:a,children:r(C?"Starting\u2026":"Start instance")})]}),(0,e.jsx)(te,{"aria-label":r("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:re,placeholder:r("Params (JSON, optional)"),value:k})]}),f.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:r("Instances")}),(0,e.jsx)(E,{className:"overflow-hidden py-0",children:(0,e.jsx)(_,{className:"px-0",children:(0,e.jsxs)(D,{"data-testid":"workflows-instances-table",children:[(0,e.jsx)(F,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:r("Workflow")}),(0,e.jsx)(o,{children:r("Instance id")}),(0,e.jsx)(o,{children:r("Status")}),(0,e.jsx)(o,{children:r("Output")}),(0,e.jsx)(o,{})]})}),(0,e.jsx)(L,{children:f.map(t=>(0,e.jsxs)(h,{"data-testid":`workflows-instance-${t.id}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.id}),(0,e.jsx)(i,{className:"font-mono text-xs",children:t.status}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:pe(t)}),(0,e.jsx)(i,{children:(0,e.jsx)(O,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:I===t.id,onClick:se,size:"xs",variant:"outline",children:I===t.id?r("Refreshing\u2026"):r("Refresh")})})]},`${t.exportName}:${t.id}`))})]})})})]}),T!==void 0&&(0,e.jsx)(ue,{workflowName:T.name})]})},"Te");export{We as default};
1
+ import{a as te}from"./chunk-EA2JKR5D.js";import{W as Z}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as O}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import{a as K}from"./chunk-4ZEL6BYL.js";import{c as ee}from"./chunk-FI3UY4QJ.js";import{f as M}from"./chunk-PYI2MI4Q.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as P}from"./chunk-FKVZRPV5.js";import{a as D,b as F,c as L,d as h,e as o,f as i}from"./chunk-HEAQVSNS.js";import{a as E,e as _}from"./chunk-WUWBZPUK.js";import{d as H,f as Q,g as V,h as W,o as $}from"./chunk-FODLDLE2.js";import{a as n,d as Y,e as ne,g as le}from"./chunk-YKXDMIHQ.js";var c=Y(ne(),1);var e=Y(le(),1);var oe=["queued","running","paused","waiting","complete","errored","terminated"],ie=["pause","resume","terminate"],de="WORKFLOWS_NOT_CONFIGURED",ce=n(l=>typeof l=="object"&&l!==null&&l.code===de,"ie"),me=n(l=>{let r=l.error??l.output;if(r===void 0)return"\u2014";try{return JSON.stringify(r)}catch{return"(unserializable)"}},"de"),ue=n(({loadDetail:l,loadInstances:r,readOnly:N,runAction:j,workflowName:g})=>{let A=M(),s=H(),[p,k]=(0,c.useState)(null),[S,C]=(0,c.useState)(null),[v,z]=(0,c.useState)(""),[b,f]=(0,c.useState)(null),[J,I]=(0,c.useState)(!1),[R,U]=(0,c.useState)(null),x=l??(a=>A.getWorkflowInstance(a)),w=N?void 0:j??(r===void 0?a=>A.setWorkflowInstanceStatus(a):void 0),T=n(async()=>{f(null),I(!1);let a=v===""?void 0:v;try{if(r===void 0){let d=await A.listWorkflowInstances({name:g,status:a});if(d.configured===!1){k(null),I(!0);return}k(d.instances);return}k(await r({name:g,status:a}))}catch(d){k(null),ce(d)?I(!0):f(W(d))}},"L");(0,c.useEffect)(()=>{C(null),$(T())},[g,v]);let q=n(async a=>{f(null);try{C(await x({id:a,name:g}))}catch(d){f(W(d))}},"K"),B=n(async(a,d)=>{if(w!==void 0){U(a),f(null);try{await w({action:d,id:a,name:g}),await T()}catch(G){f(W(G))}U(null)}},"q");return(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:s("Instance history")}),(0,e.jsxs)("select",{"aria-label":s("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:n(a=>{z(a.target.value)},"onChange"),value:v,children:[(0,e.jsx)("option",{value:"",children:s("All statuses")}),oe.map(a=>(0,e.jsx)("option",{value:a,children:a},a))]})]}),b!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:b}),J&&(0,e.jsx)(P,{description:s("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:s("Workflow inspection not configured")}),!J&&p!==null&&p.length===0&&(0,e.jsx)(P,{description:s("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:s("No instances")}),p!==null&&p.length>0&&(0,e.jsx)(E,{className:"overflow-hidden py-0",children:(0,e.jsx)(_,{className:"px-0",children:(0,e.jsxs)(D,{"data-testid":"workflow-instances-table",children:[(0,e.jsx)(F,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:s("Instance id")}),(0,e.jsx)(o,{children:s("Status")}),(0,e.jsx)(o,{children:s("Created")}),(0,e.jsx)(o,{children:s("Ended")}),(0,e.jsx)(o,{"aria-label":s("Actions")})]})}),(0,e.jsx)(L,{children:p.map(a=>(0,e.jsxs)(h,{"data-testid":`workflow-instance-${a.id}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:a.id}),(0,e.jsx)(i,{className:"font-mono text-xs",children:a.status}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.createdOn??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.endedOn??"\u2014"}),(0,e.jsx)(i,{className:"text-right",children:(0,e.jsxs)("div",{className:"flex justify-end gap-1.5",children:[(0,e.jsx)(O,{"data-testid":`workflow-instance-steps-${a.id}`,onClick:n(()=>{$(q(a.id))},"onClick"),size:"sm",type:"button",variant:"outline",children:s("Steps")}),w!==void 0&&ie.map(d=>(0,e.jsx)(O,{"data-testid":`workflow-instance-${d}-${a.id}`,disabled:R===a.id,onClick:n(()=>{$(B(a.id,d))},"onClick"),size:"sm",type:"button",variant:"ghost",children:s(d)},d))]})})]},a.id))})]})})}),S!==null&&(0,e.jsx)(E,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:(0,e.jsxs)(_,{className:"flex flex-col gap-2 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[s("Steps")," \xB7 ",S.id]}),(0,e.jsx)(O,{"data-testid":"workflow-instance-detail-close",onClick:n(()=>{C(null)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Close")})]}),S.steps.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:s("This instance has no recorded steps yet.")}):(0,e.jsxs)(D,{"data-testid":"workflow-instance-steps",children:[(0,e.jsx)(F,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:s("Step")}),(0,e.jsx)(o,{children:s("Type")}),(0,e.jsx)(o,{children:s("Attempts")}),(0,e.jsx)(o,{children:s("Started")}),(0,e.jsx)(o,{children:s("Output")})]})}),(0,e.jsx)(L,{children:S.steps.map((a,d)=>(0,e.jsxs)(h,{"data-testid":`workflow-step-${String(d)}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:a.name}),(0,e.jsx)(i,{className:"text-xs text-muted-foreground",children:a.type??"\u2014"}),(0,e.jsx)(i,{className:"tabular-nums",children:a.attempts??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.start??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:me(a)})]},`${a.name}:${String(d)}`))})]})]})})]})},"ce"),fe=Q(K.createWorkflowInstance),he=Q(K.getWorkflowInstanceStatus),pe=n(l=>{if(l.error)return`${l.error.name}: ${l.error.message}`;if(l.output===void 0)return"\u2014";try{return JSON.stringify(l.output)}catch{return"(unserializable)"}},"fe"),xe=n((l,r)=>l.some(N=>N.exportName===r)?r:l[0]?.exportName??"","he"),We=n(()=>{let l=M(),r=H(),{data:N,error:j}=ee(K.listWorkflows,{}),[g,A]=(0,c.useState)(""),[s,p]=(0,c.useState)(""),[k,S]=(0,c.useState)(""),[C,v]=(0,c.useState)(!1),[z,b]=(0,c.useState)(null),[f,J]=(0,c.useState)([]),[I,R]=(0,c.useState)(null),U=N!==void 0,x=Array.isArray(N?.workflows)?[...N.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],w=xe(x,g),T=x.find(t=>t.exportName===w),q=n(t=>{J(u=>{let m=u.filter(y=>!(y.exportName===t.exportName&&y.id===t.id));return[t,...m]})},"C"),B=n(async()=>{let t=w;if(t==="")return;let u,m=k.trim();if(m!=="")try{u=JSON.parse(m)}catch{b(r("Params must be valid JSON"));return}v(!0),b(null);try{let y=s.trim(),X=await l.query(fe,{exportName:t,id:y===""?void 0:y,params:u},V(""));q({exportName:t,id:X.id,status:X.status}),p("")}catch(y){b(W(y))}v(!1)},"L"),a=n(()=>{$(B())},"K"),d=n(async(t,u)=>{R(u);try{let m=await l.query(he,{exportName:t,id:u},V(""));q({error:m.error,exportName:t,id:m.id,output:m.output,status:m.status})}catch(m){b(W(m))}R(null)},"q"),G=n(t=>{A(t.target.value)},"r"),ae=n(t=>{p(t.target.value)},"l"),re=n(t=>{S(t.target.value)},"G"),se=n(t=>{let{export:u,id:m}=t.currentTarget.dataset;u!==void 0&&m!==void 0&&$(d(u,m))},"ee");return(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[j!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:j}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:r("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),U&&x.length===0?(0,e.jsx)(P,{description:r("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:r("No workflows defined")}):(0,e.jsx)(E,{className:"overflow-hidden py-0",children:(0,e.jsx)(_,{className:"px-0",children:(0,e.jsxs)(D,{"data-testid":"workflows-table",children:[(0,e.jsx)(F,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:r("Export")}),(0,e.jsx)(o,{children:r("Name")}),(0,e.jsx)(o,{children:r("Class")}),(0,e.jsx)(o,{children:r("Binding")})]})}),(0,e.jsx)(L,{children:x.map(t=>(0,e.jsxs)(h,{"data-testid":`workflows-row-${t.exportName}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.name}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.className}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.binding})]},t.exportName))})]})})}),x.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:r("Start instance")}),z!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:z}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("select",{"aria-label":r("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:G,value:w,children:x.map(t=>(0,e.jsx)("option",{value:t.exportName,children:t.exportName},t.exportName))}),(0,e.jsx)(Z,{"aria-label":r("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:ae,placeholder:r("Instance id (optional)"),value:s}),(0,e.jsx)(O,{"data-testid":"workflows-start-button",disabled:C||w==="",onClick:a,children:r(C?"Starting\u2026":"Start instance")})]}),(0,e.jsx)(te,{"aria-label":r("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:re,placeholder:r("Params (JSON, optional)"),value:k})]}),f.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:r("Instances")}),(0,e.jsx)(E,{className:"overflow-hidden py-0",children:(0,e.jsx)(_,{className:"px-0",children:(0,e.jsxs)(D,{"data-testid":"workflows-instances-table",children:[(0,e.jsx)(F,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:r("Workflow")}),(0,e.jsx)(o,{children:r("Instance id")}),(0,e.jsx)(o,{children:r("Status")}),(0,e.jsx)(o,{children:r("Output")}),(0,e.jsx)(o,{})]})}),(0,e.jsx)(L,{children:f.map(t=>(0,e.jsxs)(h,{"data-testid":`workflows-instance-${t.id}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.id}),(0,e.jsx)(i,{className:"font-mono text-xs",children:t.status}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:pe(t)}),(0,e.jsx)(i,{children:(0,e.jsx)(O,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:I===t.id,onClick:se,size:"xs",variant:"outline",children:I===t.id?r("Refreshing\u2026"):r("Refresh")})})]},`${t.exportName}:${t.id}`))})]})})})]}),T!==void 0&&(0,e.jsx)(ue,{workflowName:T.name})]})},"Te");export{We as default};
@@ -1 +1 @@
1
- import{a as Ge}from"./chunk-3FBLWUXD.js";import{a as Qe,b as qe}from"./chunk-L3AFRJE2.js";import{a as Xe}from"./chunk-TIUMFAN2.js";import{a as He}from"./chunk-XZMOZFE6.js";import{a as j}from"./chunk-IMOHEGMV.js";import{a as Ke}from"./chunk-66UGPQVC.js";import{a as Ze}from"./chunk-QKEJLVC5.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import{W as E}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as U}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as D}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{b as Ve}from"./chunk-5G2MAI3G.js";import{f as V}from"./chunk-SZSHO6RE.js";import"./chunk-FSRSK4LY.js";import"./chunk-CEA2QYAI.js";import{a as Me}from"./chunk-FKVZRPV5.js";import{a as Se,b as ze,c as Ue,d as T,e as S,f as z}from"./chunk-HEAQVSNS.js";import{a as H,e as W}from"./chunk-WUWBZPUK.js";import{d as q,h as Pe,n as Fe,o as J,r as Q}from"./chunk-FODLDLE2.js";import{a as s,d as Oe,e as tt,f as at,g as it}from"./chunk-YKXDMIHQ.js";var x=Oe(tt(),1);var X=Oe(at(),1);var t=Oe(it(),1);Qe.capabilities;var lt=s(()=>{let h=(0,X.c)(3),{config:e,ready:l}=qe(),i;return h[0]!==e.capabilities||h[1]!==l?(i={capabilities:e.capabilities,ready:l},h[0]=e.capabilities,h[1]=l,h[2]=i):i=h[2],i},"st"),st=s((h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending","nt"),Ye=500,nt=s(()=>{let h=V(),e=q(),[l,i]=(0,x.useState)(""),[m,a]=(0,x.useState)(null),[c,n]=(0,x.useState)(null),[d,v]=(0,x.useState)(!1),f=Ve(["lunora-auth-sign-up-invitations",Ye],()=>h.listAuthSignUpInvitations({limit:Ye})),C=f.data?.rows??null,y=f.data?.total??0,A=s(()=>{let r=l.trim();r!==""&&(a(null),J((async()=>{try{let u=await h.createAuthSignUpInvitation({email:r}),p=typeof u.token=="string"?u.token:void 0;n(p===void 0?null:`${globalThis.location.origin}/sign-up?email=${encodeURIComponent(r)}&invite=${encodeURIComponent(p)}`),v(!1),i(""),f.refetch()}catch(u){a(u instanceof Error?u.message:String(u))}})()))},"A"),N=s(()=>{let r="navigator"in globalThis?globalThis.navigator.clipboard:void 0;c===null||r===void 0||J(r.writeText(c).then(()=>(v(!0),!0)))},"y"),I=s(r=>{a(null),J((async()=>{try{await h.revokeAuthSignUpInvitation({email:r}),f.refetch()}catch(u){a(u instanceof Error?u.message:String(u))}})())},"I");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)(E,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:s(r=>{i(r.target.value)},"onChange"),placeholder:e("ada@example.com"),type:"email",value:l}),(0,t.jsx)(U,{"data-testid":"sign-up-invitation-submit",onClick:A,type:"button",children:e("Invite")})]}),c!==null&&(0,t.jsx)(H,{children:(0,t.jsxs)(W,{className:"flex flex-col gap-2 p-4",children:[(0,t.jsx)("p",{className:"text-sm",children:e("Send this link to the invitee. It is shown once and cannot be recovered.")}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(E,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:c}),(0,t.jsx)(U,{"data-testid":"sign-up-invitation-copy",onClick:N,type:"button",children:e(d?"Copied":"Copy")})]})]})}),(m??f.error)!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:m??f.error}),C!==null&&C.length===0&&(0,t.jsx)(Me,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),C!==null&&y>C.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.")}),C!==null&&C.length>0&&(0,t.jsx)(H,{children:(0,t.jsx)(W,{className:"p-0",children:(0,t.jsxs)(Se,{children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:e("Email")}),(0,t.jsx)(S,{children:e("Status")}),(0,t.jsx)(S,{children:e("Expires")}),(0,t.jsx)(S,{children:e("Invited by")}),(0,t.jsx)(S,{})]})}),(0,t.jsx)(Ue,{children:C.map(r=>{let u=st(r,Date.now()),p=r.email??"";return(0,t.jsxs)(T,{"data-testid":`sign-up-invitation-${p}`,children:[(0,t.jsx)(z,{children:p}),(0,t.jsxs)(z,{"data-testid":`sign-up-invitation-status-${p}`,children:[u==="spent"&&e("Accepted"),u==="expired"&&e("Expired"),u==="pending"&&e("Pending")]}),(0,t.jsx)(z,{children:typeof r.expiresAt=="number"?Q(r.expiresAt):"\u2014"}),(0,t.jsx)(z,{children:r.invitedBy??"\u2014"}),(0,t.jsx)(z,{className:"text-right",children:(0,t.jsx)(U,{onClick:s(()=>{I(p)},"onClick"),type:"button",variant:"ghost",children:e("Revoke")})})]},r.id)})})]})})})]})},"lt"),rt={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},dt=s((h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),"it"),ot=s((h,e)=>{if(h.type==="boolean")return e===!0?{value:!0}:h.required?{value:!1}:void 0;let l=typeof e=="string"?e.trim():"";if(l!==""){if(h.type==="number"){let i=Number(l);return Number.isNaN(i)?void 0:{value:i}}return{value:l}}},"rt"),ct=s(h=>{let e=(0,X.c)(105),{onClose:l,onCreated:i}=h,m=V(),a=q(),{config:c}=qe(),{busy:n,error:d,run:v}=Xe(),[f,C]=(0,x.useState)(""),[y,A]=(0,x.useState)(""),[N,I]=(0,x.useState)(""),[r,u]=(0,x.useState)(""),p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let[g,o]=(0,x.useState)(p),F;e[1]===Symbol.for("react.memo_cache_sentinel")?(F=s(b=>{C(b.target.value)},"F"),e[1]=F):F=e[1];let k=F,$;e[2]===Symbol.for("react.memo_cache_sentinel")?($=s(b=>{A(b.target.value)},"E"),e[2]=$):$=e[2];let L=$,_;e[3]===Symbol.for("react.memo_cache_sentinel")?(_=s(b=>{I(b.target.value)},"D"),e[3]=_):_=e[3];let Be=_,Z;e[4]===Symbol.for("react.memo_cache_sentinel")?(Z=s(b=>{u(b.target.value)},"Z"),e[4]=Z):Z=e[4];let De=Z,G;e[5]===Symbol.for("react.memo_cache_sentinel")?(G=s((b,R)=>{o(K=>({...K,[b]:R}))},"W"),e[5]=G):G=e[5];let _e=G,Y;e[6]!==g?(Y=s(b=>g[b.name]??(b.type==="boolean"?!1:""),"J"),e[6]=g,e[7]=Y):Y=e[7];let P=Y,ee;if(e[8]!==c.userFields||e[9]!==P){let b;e[11]!==P?(b=s(R=>!R.required||dt(R,P(R)),"g"),e[11]=P,e[12]=b):b=e[12],ee=c.userFields.every(b),e[8]=c.userFields,e[9]=P,e[10]=ee}else ee=e[10];let $e=ee,te;e[13]!==n||e[14]!==f||e[15]!==y||e[16]!==$e?(te=!n&&f.trim()!==""&&y.trim()!==""&&$e,e[13]=n,e[14]=f,e[15]=y,e[16]=$e,e[17]=te):te=e[17];let Te=te,ae;e[18]!==c.userFields||e[19]!==P?(ae=s(()=>{let b={};for(let R of c.userFields){let K=ot(R,P(R));K!==void 0&&(b[R.name]=K.value)}return Object.keys(b).length===0?void 0:b},"ee"),e[18]=c.userFields,e[19]=P,e[20]=ae):ae=e[20];let Re=ae,ie;e[21]!==Re||e[22]!==m||e[23]!==f||e[24]!==y||e[25]!==l||e[26]!==i||e[27]!==N||e[28]!==r||e[29]!==v?(ie=s(()=>{v(async()=>{await m.createAuthUser({data:Re(),email:f.trim(),name:y.trim(),password:N===""?void 0:N,role:r.trim()===""?void 0:r.trim()}),i(),l()})},"te"),e[21]=Re,e[22]=m,e[23]=f,e[24]=y,e[25]=l,e[26]=i,e[27]=N,e[28]=r,e[29]=v,e[30]=ie):ie=e[30];let w=ie,B;e[31]!==a?(B=a("Create user"),e[31]=a,e[32]=B):B=e[32];let O;e[33]!==a?(O=a("Create user"),e[33]=a,e[34]=O):O=e[34];let M;e[35]!==O?(M=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:O}),e[35]=O,e[36]=M):M=e[36];let le;e[37]!==a?(le=a("email"),e[37]=a,e[38]=le):le=e[38];let se;e[39]!==le?(se=(0,t.jsx)(j,{htmlFor:"uc-email",children:le}),e[39]=le,e[40]=se):se=e[40];let ne;e[41]!==f?(ne=(0,t.jsx)(E,{"data-testid":"uc-email",id:"uc-email",onChange:k,type:"email",value:f}),e[41]=f,e[42]=ne):ne=e[42];let re;e[43]!==se||e[44]!==ne?(re=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[se,ne]}),e[43]=se,e[44]=ne,e[45]=re):re=e[45];let de;e[46]!==a?(de=a("name"),e[46]=a,e[47]=de):de=e[47];let oe;e[48]!==de?(oe=(0,t.jsx)(j,{htmlFor:"uc-name",children:de}),e[48]=de,e[49]=oe):oe=e[49];let ce;e[50]!==y?(ce=(0,t.jsx)(E,{"data-testid":"uc-name",id:"uc-name",onChange:L,value:y}),e[50]=y,e[51]=ce):ce=e[51];let ue;e[52]!==oe||e[53]!==ce?(ue=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[oe,ce]}),e[52]=oe,e[53]=ce,e[54]=ue):ue=e[54];let he;e[55]!==a?(he=a("Password (optional)"),e[55]=a,e[56]=he):he=e[56];let me;e[57]!==he?(me=(0,t.jsx)(j,{htmlFor:"uc-password",children:he}),e[57]=he,e[58]=me):me=e[58];let pe;e[59]!==N?(pe=(0,t.jsx)(E,{"data-testid":"uc-password",id:"uc-password",onChange:Be,type:"password",value:N}),e[59]=N,e[60]=pe):pe=e[60];let ve;e[61]!==me||e[62]!==pe?(ve=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[me,pe]}),e[61]=me,e[62]=pe,e[63]=ve):ve=e[63];let fe;e[64]!==a?(fe=a("Role (optional)"),e[64]=a,e[65]=fe):fe=e[65];let be;e[66]!==fe?(be=(0,t.jsx)(j,{htmlFor:"uc-role",children:fe}),e[66]=fe,e[67]=be):be=e[67];let xe;e[68]!==r?(xe=(0,t.jsx)(E,{"data-testid":"uc-role",id:"uc-role",onChange:De,value:r}),e[68]=r,e[69]=xe):xe=e[69];let ye;e[70]!==be||e[71]!==xe?(ye=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[be,xe]}),e[70]=be,e[71]=xe,e[72]=ye):ye=e[72];let ge;e[73]!==c.userFields||e[74]!==P||e[75]!==a?(ge=c.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")}),c.userFields.map(b=>{let R=`uc-field-${b.name}`,K=b.required?"":` (${a("optional")})`;if(b.type==="boolean"){let Le=P(b)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:R,children:[(0,t.jsx)(Ge,{checked:Le,"data-testid":R,id:R,onCheckedChange:s(et=>{_e(b.name,et)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[b.name,K]})]},b.name)}let Je=P(b);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(j,{htmlFor:R,children:[b.name,K]}),(0,t.jsx)(E,{"data-testid":R,id:R,onChange:s(Le=>{_e(b.name,Le.target.value)},"onChange"),type:rt[b.type],value:typeof Je=="string"?Je:""})]},b.name)})]}),e[73]=c.userFields,e[74]=P,e[75]=a,e[76]=ge):ge=e[76];let Ne;e[77]!==d?(Ne=d!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:d}),e[77]=d,e[78]=Ne):Ne=e[78];let ke;e[79]!==a?(ke=a("Cancel"),e[79]=a,e[80]=ke):ke=e[80];let we;e[81]!==l||e[82]!==ke?(we=(0,t.jsx)(U,{"data-testid":"uc-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:ke}),e[81]=l,e[82]=ke,e[83]=we):we=e[83];let je=!Te,Ce;e[84]!==n||e[85]!==a?(Ce=a(n?"Creating\u2026":"Create"),e[84]=n,e[85]=a,e[86]=Ce):Ce=e[86];let Ae;e[87]!==w||e[88]!==je||e[89]!==Ce?(Ae=(0,t.jsx)(U,{"data-testid":"uc-submit",disabled:je,onClick:w,size:"sm",type:"button",children:Ce}),e[87]=w,e[88]=je,e[89]=Ce,e[90]=Ae):Ae=e[90];let Ie;e[91]!==we||e[92]!==Ae?(Ie=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[we,Ae]}),e[91]=we,e[92]=Ae,e[93]=Ie):Ie=e[93];let Ee;return e[94]!==l||e[95]!==B||e[96]!==M||e[97]!==re||e[98]!==ue||e[99]!==ve||e[100]!==ye||e[101]!==ge||e[102]!==Ne||e[103]!==Ie?(Ee=(0,t.jsxs)(He,{label:B,onClose:l,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[M,re,ue,ve,ye,ge,Ne,Ie]}),e[94]=l,e[95]=B,e[96]=M,e[97]=re,e[98]=ue,e[99]=ve,e[100]=ye,e[101]=ge,e[102]=Ne,e[103]=Ie,e[104]=Ee):Ee=e[104],Ee},"ot"),We=s(h=>{let e=(0,X.c)(2),{children:l}=h,i;return e[0]!==l?(i=(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l}),e[0]=l,e[1]=i):i=e[1],i},"je"),ut=s(h=>{let e=(0,X.c)(29),{busy:l,runAction:i,userId:m,version:a}=h,c=V(),n=q(),[d,v]=(0,x.useState)(null),[f,C]=(0,x.useState)(null),y;e[0]!==c||e[1]!==m?(y=s(()=>{J((async()=>{C(null);try{let k=await c.listAuthSessions({limit:50,userId:m});v(k.rows)}catch(k){let $=k;v(null),C(Pe($))}})())},"b"),e[0]=c,e[1]=m,e[2]=y):y=e[2];let A;e[3]!==c||e[4]!==m||e[5]!==a?(A=[c,m,a],e[3]=c,e[4]=m,e[5]=a,e[6]=A):A=e[6],(0,x.useEffect)(y,A);let N;e[7]!==c||e[8]!==i?(N=s(k=>{i(()=>c.revokeAuthSession({sessionId:k}))},"y"),e[7]=c,e[8]=i,e[9]=N):N=e[9];let I=N,r;e[10]!==n?(r=n("Sessions"),e[10]=n,e[11]=r):r=e[11];let u;e[12]!==r?(u=(0,t.jsx)(We,{children:r}),e[12]=r,e[13]=u):u=e[13];let p;e[14]!==f?(p=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:f}),e[14]=f,e[15]=p):p=e[15];let g;e[16]!==d||e[17]!==n?(g=d!==null&&d.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:n("No active sessions.")}),e[16]=d,e[17]=n,e[18]=g):g=e[18];let o;e[19]!==l||e[20]!==I||e[21]!==d||e[22]!==n?(o=d!==null&&d.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:n("expires")}),(0,t.jsx)(S,{children:n("ip")}),(0,t.jsx)(S,{children:n("user agent")}),(0,t.jsx)(S,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Ue,{children:d.map(k=>(0,t.jsxs)(T,{"data-testid":`ud-session-${k.id}`,children:[(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q(k.expiresAt)}),(0,t.jsx)(z,{children:k.ipAddress??""}),(0,t.jsx)(z,{className:"max-w-40 truncate",children:k.userAgent??""}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`ud-revoke-${k.id}`,disabled:l,onClick:s(()=>{I(k.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Revoke")})})]},k.id))})]})})}),e[19]=l,e[20]=I,e[21]=d,e[22]=n,e[23]=o):o=e[23];let F;return e[24]!==u||e[25]!==p||e[26]!==g||e[27]!==o?(F=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[u,p,g,o]}),e[24]=u,e[25]=p,e[26]=g,e[27]=o,e[28]=F):F=e[28],F},"dt"),ht=s(h=>{let e=(0,X.c)(30),{busy:l,runAction:i,userId:m,version:a}=h,c=V(),n=q(),[d,v]=(0,x.useState)(null),[f,C]=(0,x.useState)(null),y;e[0]!==c||e[1]!==m?(y=s(()=>{J((async()=>{C(null);try{v(await c.listAuthAccounts({userId:m}))}catch(k){let $=k;v(null),C(Pe($))}})())},"b"),e[0]=c,e[1]=m,e[2]=y):y=e[2];let A;e[3]!==c||e[4]!==m||e[5]!==a?(A=[c,m,a],e[3]=c,e[4]=m,e[5]=a,e[6]=A):A=e[6],(0,x.useEffect)(y,A);let N;e[7]!==c||e[8]!==i||e[9]!==m?(N=s(k=>{i(()=>c.unlinkAuthAccount({accountId:k,userId:m}))},"y"),e[7]=c,e[8]=i,e[9]=m,e[10]=N):N=e[10];let I=N,r;e[11]!==n?(r=n("Linked accounts"),e[11]=n,e[12]=r):r=e[12];let u;e[13]!==r?(u=(0,t.jsx)(We,{children:r}),e[13]=r,e[14]=u):u=e[14];let p;e[15]!==f?(p=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:f}),e[15]=f,e[16]=p):p=e[16];let g;e[17]!==d||e[18]!==n?(g=d!==null&&d.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:n("No linked accounts.")}),e[17]=d,e[18]=n,e[19]=g):g=e[19];let o;e[20]!==d||e[21]!==l||e[22]!==I||e[23]!==n?(o=d!==null&&d.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:n("provider")}),(0,t.jsx)(S,{children:n("created")}),(0,t.jsx)(S,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Ue,{children:d.map(k=>{let $=Fe(k.id);return(0,t.jsxs)(T,{"data-testid":`ud-account-${$}`,children:[(0,t.jsx)(z,{children:Fe(k.providerId)}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q(k.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`ud-unlink-${$}`,disabled:l,onClick:s(()=>{I($)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Unlink")})})]},$)})})]})})}),e[20]=d,e[21]=l,e[22]=I,e[23]=n,e[24]=o):o=e[24];let F;return e[25]!==u||e[26]!==p||e[27]!==g||e[28]!==o?(F=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[u,p,g,o]}),e[25]=u,e[26]=p,e[27]=g,e[28]=o,e[29]=F):F=e[29],F},"ct"),mt=s(h=>{let e=(0,X.c)(40),{busy:l,capabilities:i,runAction:m,userId:a,version:c}=h,n=V(),d=q(),[v,f]=(0,x.useState)(null),C;e[0]!==i.passkey||e[1]!==n||e[2]!==a?(C=s(()=>{i.passkey&&J((async()=>{try{f(await n.listAuthPasskeys({userId:a}))}catch{f(null)}})())},"C"),e[0]=i.passkey,e[1]=n,e[2]=a,e[3]=C):C=e[3];let y;e[4]!==i.passkey||e[5]!==n||e[6]!==a||e[7]!==c?(y=[i.passkey,n,a,c],e[4]=i.passkey,e[5]=n,e[6]=a,e[7]=c,e[8]=y):y=e[8],(0,x.useEffect)(C,y);let A;e[9]!==n||e[10]!==m||e[11]!==a?(A=s(()=>{m(()=>n.disableAuthTwoFactor({userId:a}))},"A"),e[9]=n,e[10]=m,e[11]=a,e[12]=A):A=e[12];let N=A,I;e[13]!==n||e[14]!==m?(I=s($=>{m(()=>n.deleteAuthPasskey({passkeyId:$}))},"I"),e[13]=n,e[14]=m,e[15]=I):I=e[15];let r=I,u;e[16]!==d?(u=d("Security"),e[16]=d,e[17]=u):u=e[17];let p;e[18]!==u?(p=(0,t.jsx)(We,{children:u}),e[18]=u,e[19]=p):p=e[19];let g;e[20]!==l||e[21]!==i.twoFactor||e[22]!==N||e[23]!==d?(g=i.twoFactor&&(0,t.jsx)(U,{"data-testid":"ud-disable-2fa",disabled:l,onClick:N,size:"sm",type:"button",variant:"outline",children:d("Disable two-factor")}),e[20]=l,e[21]=i.twoFactor,e[22]=N,e[23]=d,e[24]=g):g=e[24];let o;e[25]!==i.passkey||e[26]!==v||e[27]!==d?(o=i.passkey&&v!==null&&v.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:d("No passkeys.")}),e[25]=i.passkey,e[26]=v,e[27]=d,e[28]=o):o=e[28];let F;e[29]!==l||e[30]!==i.passkey||e[31]!==r||e[32]!==v||e[33]!==d?(F=i.passkey&&v!==null&&v.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"ud-passkeys-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:d("name")}),(0,t.jsx)(S,{children:d("created")}),(0,t.jsx)(S,{"aria-label":d("Actions")})]})}),(0,t.jsx)(Ue,{children:v.map($=>{let L=Fe($.id);return(0,t.jsxs)(T,{"data-testid":`ud-passkey-${L}`,children:[(0,t.jsx)(z,{children:Fe($.name)||L}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q($.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`ud-delete-passkey-${L}`,disabled:l,onClick:s(()=>{r(L)},"onClick"),size:"xs",type:"button",variant:"ghost",children:d("Delete")})})]},L)})})]})})}),e[29]=l,e[30]=i.passkey,e[31]=r,e[32]=v,e[33]=d,e[34]=F):F=e[34];let k;return e[35]!==p||e[36]!==g||e[37]!==o||e[38]!==F?(k=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[p,g,o,F]}),e[35]=p,e[36]=g,e[37]=o,e[38]=F,e[39]=k):k=e[39],k},"ut"),pt=/(?:at|expires)$/iu,vt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),ft=s((h,e)=>typeof e=="number"&&pt.test(h)?Q(e):Fe(e),"pt"),bt=s(({capabilities:h,onChanged:e,onClose:l,user:i})=>{let m=V(),a=q(),c=i.banned===!0,[n,d]=(0,x.useState)(null),[v,f]=(0,x.useState)(!1),[C,y]=(0,x.useState)(0),[A,N]=(0,x.useState)(typeof i.role=="string"?i.role:""),[I,r]=(0,x.useState)(""),[u,p]=(0,x.useState)(""),[g,o]=(0,x.useState)(""),[F,k]=(0,x.useState)(null),[$,L]=(0,x.useState)(!1),_=s((w,B)=>{J((async()=>{f(!0),d(null);try{let O=await w();B?.refresh!==!1&&(y(M=>M+1),e()),B?.onResult?.(O)}catch(O){d(Pe(O))}f(!1)})())},"D"),Be=s(w=>{N(w.target.value)},"$e"),Z=s(w=>{r(w.target.value)},"Z"),De=s(w=>{p(w.target.value)},"Be"),G=s(w=>{o(w.target.value)},"W"),_e=s(()=>{let w=A.trim();w!==""&&_(async()=>{await m.setAuthUserRole({role:w,userId:i.id})})},"De"),Y=s(()=>{let w=Number.parseInt(u,10),B=Number.isFinite(w)&&w>0?w*86400:void 0;_(async()=>{await m.banAuthUser({expiresInSeconds:B,reason:I.trim()===""?void 0:I.trim(),userId:i.id})})},"J"),P=s(()=>{_(async()=>{await m.unbanAuthUser({userId:i.id})})},"P"),ee=s(()=>{_(async()=>{await m.setAuthUserPassword({newPassword:g,userId:i.id}),o("")})},"K"),$e=s(()=>{_(()=>m.impersonateAuthUser({userId:i.id}),{onResult:s(w=>{k(w.token)},"onResult"),refresh:!1})},"Fe"),te=s(()=>{_(async()=>{await m.revokeAuthUserSessions({userId:i.id})})},"X"),Te=s(()=>{_(async()=>{await m.removeAuthUser({userId:i.id}),l()})},"ze"),ae=s(()=>{L(!0)},"ee"),Re=s(()=>{L(!1)},"Se"),ie=Object.entries(i).filter(([w])=>!vt.has(w));return(0,t.jsxs)(He,{label:a("User details"),onClose:l,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:i.name??i.email??i.id}),(0,t.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:i.id}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof i.role=="string"&&i.role!==""&&(0,t.jsx)(D,{variant:"secondary",children:i.role}),c?(0,t.jsx)(D,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(D,{variant:"outline",children:a("Active")}),i.emailVerified===!0?(0,t.jsx)(D,{variant:"secondary",children:a("verified")}):(0,t.jsx)(D,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(U,{"data-testid":"ud-close",onClick:l,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),n!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:n}),h.admin&&(0,t.jsxs)(H,{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)(W,{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)(j,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(E,{"data-testid":"ud-role-input",id:"ud-role",onChange:Be,value:A})]}),(0,t.jsx)(U,{"data-testid":"ud-set-role",disabled:v||A.trim()==="",onClick:_e,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),c?(0,t.jsx)(U,{"data-testid":"ud-unban",disabled:v,onClick:P,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(j,{htmlFor:"ud-ban-reason",children:a("Ban reason (optional)")}),(0,t.jsx)(E,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:Z,value:I})]}),(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[(0,t.jsx)(j,{htmlFor:"ud-ban-days",children:a("Days")}),(0,t.jsx)(E,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:De,type:"number",value:u})]}),(0,t.jsx)(U,{"data-testid":"ud-ban",disabled:v,onClick:Y,size:"sm",type:"button",variant:"destructive",children:a("Ban user")})]}),(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(j,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(E,{"data-testid":"ud-password",id:"ud-password",onChange:G,type:"password",value:g})]}),(0,t.jsx)(U,{"data-testid":"ud-set-password",disabled:v||g==="",onClick:ee,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(U,{"data-testid":"ud-impersonate",disabled:v,onClick:$e,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(U,{"data-testid":"ud-revoke-all",disabled:v,onClick:te,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),$?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(U,{"data-testid":"ud-delete-confirm",disabled:v,onClick:Te,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(U,{"data-testid":"ud-delete-cancel",onClick:Re,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(U,{"data-testid":"ud-delete",disabled:v,onClick:ae,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),F!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(j,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(E,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:F})]})]})]}),(0,t.jsx)(ut,{busy:v,runAction:_,userId:i.id,version:C}),h.accounts&&(0,t.jsx)(ht,{busy:v,runAction:_,userId:i.id,version:C}),(h.twoFactor||h.passkey)&&(0,t.jsx)(mt,{busy:v,capabilities:h,runAction:_,userId:i.id,version:C}),(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:ie.map(([w,B])=>(0,t.jsxs)("div",{className:"flex flex-col border-t border-border py-1.5",children:[(0,t.jsx)("dt",{className:"text-xs font-semibold text-muted-foreground",children:w}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:ft(w,B)})]},w))})]})]})},"ft"),xt=50,Bt=s(({pageSize:h=xt}={})=>{let e=V(),l=q(),[i,m]=(0,x.useState)(""),[a,c]=(0,x.useState)(""),n=Ze(i),[d,v]=(0,x.useState)(null),[f,C]=(0,x.useState)(!1),{capabilities:y}=lt(),A=n.trim(),N=a.trim(),I=Ve(["lunora-auth-users",A,N,h],()=>e.listAuthUsers({filterField:N===""?void 0:"role",filterValue:N===""?void 0:N,limit:h,search:A===""?void 0:A}),{keepPreviousData:!0}),r=I.data?.rows??null,u=I.error,p=s(()=>{I.refetch()},"p");Ke(()=>{I.refetch()},!0);let g=d===null?null:r?.find(o=>o.id===d)??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)(E,{"aria-label":l("Search users"),className:"w-56","data-testid":"us-search",onChange:s(o=>{m(o.target.value)},"onChange"),placeholder:l("Search by email or name\u2026"),value:i}),(0,t.jsx)(E,{"aria-label":l("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:s(o=>{c(o.target.value)},"onChange"),placeholder:l("Filter by role"),value:a}),(0,t.jsx)(U,{"data-testid":"us-new",onClick:s(()=>{C(!0)},"onClick"),size:"sm",type:"button",children:l("New user")})]}),u!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:u}),r!==null&&r.length===0&&(0,t.jsx)(Me,{description:l("Users who sign up to your app will appear here."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:l("No users.")}),r!==null&&r.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"us-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:l("id")}),(0,t.jsx)(S,{children:l("email")}),(0,t.jsx)(S,{children:l("name")}),(0,t.jsx)(S,{children:l("role")}),(0,t.jsx)(S,{children:l("status")}),(0,t.jsx)(S,{children:l("verified")}),(0,t.jsx)(S,{children:l("created")}),(0,t.jsx)(S,{"aria-label":l("Actions")})]})}),(0,t.jsx)(Ue,{children:r.map(o=>(0,t.jsxs)(T,{"data-testid":`us-row-${o.id}`,children:[(0,t.jsx)(z,{className:"font-mono text-xs",children:o.id}),(0,t.jsx)(z,{children:o.email??""}),(0,t.jsx)(z,{children:o.name??""}),(0,t.jsx)(z,{children:typeof o.role=="string"&&o.role!==""?(0,t.jsx)(D,{variant:"secondary",children:o.role}):""}),(0,t.jsx)(z,{children:o.banned===!0?(0,t.jsx)(D,{variant:"destructive",children:l("Banned")}):(0,t.jsx)(D,{variant:"success",children:l("Active")})}),(0,t.jsx)(z,{children:o.emailVerified===!0?(0,t.jsx)(D,{variant:"success",children:l("yes")}):(0,t.jsx)(D,{variant:"outline",children:l("no")})}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q(o.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`us-manage-${o.id}`,onClick:s(()=>{v(o.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Manage")})})]},o.id))})]})})}),g!==null&&(0,t.jsx)(bt,{capabilities:y,onChanged:p,onClose:s(()=>{v(null)},"onClose"),user:g}),f&&(0,t.jsx)(ct,{onClose:s(()=>{C(!1)},"onClose"),onCreated:p}),y.inviteOnly&&(0,t.jsx)(nt,{})]})},"zt");export{Bt as UsersPanel};
1
+ import{a as Ge}from"./chunk-3FBLWUXD.js";import{a as Qe,b as qe}from"./chunk-WNVPC7FI.js";import{a as Xe}from"./chunk-TIUMFAN2.js";import{a as He}from"./chunk-XZMOZFE6.js";import{a as j}from"./chunk-IMOHEGMV.js";import{a as Ke}from"./chunk-66UGPQVC.js";import{a as Ze}from"./chunk-QKEJLVC5.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import{W as E}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as U}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as D}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{b as Ve}from"./chunk-FI3UY4QJ.js";import{f as V}from"./chunk-PYI2MI4Q.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as Me}from"./chunk-FKVZRPV5.js";import{a as Se,b as ze,c as Ue,d as T,e as S,f as z}from"./chunk-HEAQVSNS.js";import{a as H,e as W}from"./chunk-WUWBZPUK.js";import{d as q,h as Pe,n as Fe,o as J,r as Q}from"./chunk-FODLDLE2.js";import{a as s,d as Oe,e as tt,f as at,g as it}from"./chunk-YKXDMIHQ.js";var x=Oe(tt(),1);var X=Oe(at(),1);var t=Oe(it(),1);Qe.capabilities;var lt=s(()=>{let h=(0,X.c)(3),{config:e,ready:l}=qe(),i;return h[0]!==e.capabilities||h[1]!==l?(i={capabilities:e.capabilities,ready:l},h[0]=e.capabilities,h[1]=l,h[2]=i):i=h[2],i},"st"),st=s((h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending","nt"),Ye=500,nt=s(()=>{let h=V(),e=q(),[l,i]=(0,x.useState)(""),[m,a]=(0,x.useState)(null),[c,n]=(0,x.useState)(null),[d,v]=(0,x.useState)(!1),f=Ve(["lunora-auth-sign-up-invitations",Ye],()=>h.listAuthSignUpInvitations({limit:Ye})),C=f.data?.rows??null,y=f.data?.total??0,A=s(()=>{let r=l.trim();r!==""&&(a(null),J((async()=>{try{let u=await h.createAuthSignUpInvitation({email:r}),p=typeof u.token=="string"?u.token:void 0;n(p===void 0?null:`${globalThis.location.origin}/sign-up?email=${encodeURIComponent(r)}&invite=${encodeURIComponent(p)}`),v(!1),i(""),f.refetch()}catch(u){a(u instanceof Error?u.message:String(u))}})()))},"A"),N=s(()=>{let r="navigator"in globalThis?globalThis.navigator.clipboard:void 0;c===null||r===void 0||J(r.writeText(c).then(()=>(v(!0),!0)))},"y"),I=s(r=>{a(null),J((async()=>{try{await h.revokeAuthSignUpInvitation({email:r}),f.refetch()}catch(u){a(u instanceof Error?u.message:String(u))}})())},"I");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)(E,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:s(r=>{i(r.target.value)},"onChange"),placeholder:e("ada@example.com"),type:"email",value:l}),(0,t.jsx)(U,{"data-testid":"sign-up-invitation-submit",onClick:A,type:"button",children:e("Invite")})]}),c!==null&&(0,t.jsx)(H,{children:(0,t.jsxs)(W,{className:"flex flex-col gap-2 p-4",children:[(0,t.jsx)("p",{className:"text-sm",children:e("Send this link to the invitee. It is shown once and cannot be recovered.")}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(E,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:c}),(0,t.jsx)(U,{"data-testid":"sign-up-invitation-copy",onClick:N,type:"button",children:e(d?"Copied":"Copy")})]})]})}),(m??f.error)!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:m??f.error}),C!==null&&C.length===0&&(0,t.jsx)(Me,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),C!==null&&y>C.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.")}),C!==null&&C.length>0&&(0,t.jsx)(H,{children:(0,t.jsx)(W,{className:"p-0",children:(0,t.jsxs)(Se,{children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:e("Email")}),(0,t.jsx)(S,{children:e("Status")}),(0,t.jsx)(S,{children:e("Expires")}),(0,t.jsx)(S,{children:e("Invited by")}),(0,t.jsx)(S,{})]})}),(0,t.jsx)(Ue,{children:C.map(r=>{let u=st(r,Date.now()),p=r.email??"";return(0,t.jsxs)(T,{"data-testid":`sign-up-invitation-${p}`,children:[(0,t.jsx)(z,{children:p}),(0,t.jsxs)(z,{"data-testid":`sign-up-invitation-status-${p}`,children:[u==="spent"&&e("Accepted"),u==="expired"&&e("Expired"),u==="pending"&&e("Pending")]}),(0,t.jsx)(z,{children:typeof r.expiresAt=="number"?Q(r.expiresAt):"\u2014"}),(0,t.jsx)(z,{children:r.invitedBy??"\u2014"}),(0,t.jsx)(z,{className:"text-right",children:(0,t.jsx)(U,{onClick:s(()=>{I(p)},"onClick"),type:"button",variant:"ghost",children:e("Revoke")})})]},r.id)})})]})})})]})},"lt"),rt={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},dt=s((h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),"it"),ot=s((h,e)=>{if(h.type==="boolean")return e===!0?{value:!0}:h.required?{value:!1}:void 0;let l=typeof e=="string"?e.trim():"";if(l!==""){if(h.type==="number"){let i=Number(l);return Number.isNaN(i)?void 0:{value:i}}return{value:l}}},"rt"),ct=s(h=>{let e=(0,X.c)(105),{onClose:l,onCreated:i}=h,m=V(),a=q(),{config:c}=qe(),{busy:n,error:d,run:v}=Xe(),[f,C]=(0,x.useState)(""),[y,A]=(0,x.useState)(""),[N,I]=(0,x.useState)(""),[r,u]=(0,x.useState)(""),p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let[g,o]=(0,x.useState)(p),F;e[1]===Symbol.for("react.memo_cache_sentinel")?(F=s(b=>{C(b.target.value)},"F"),e[1]=F):F=e[1];let k=F,$;e[2]===Symbol.for("react.memo_cache_sentinel")?($=s(b=>{A(b.target.value)},"E"),e[2]=$):$=e[2];let L=$,_;e[3]===Symbol.for("react.memo_cache_sentinel")?(_=s(b=>{I(b.target.value)},"D"),e[3]=_):_=e[3];let Be=_,Z;e[4]===Symbol.for("react.memo_cache_sentinel")?(Z=s(b=>{u(b.target.value)},"Z"),e[4]=Z):Z=e[4];let De=Z,G;e[5]===Symbol.for("react.memo_cache_sentinel")?(G=s((b,R)=>{o(K=>({...K,[b]:R}))},"W"),e[5]=G):G=e[5];let _e=G,Y;e[6]!==g?(Y=s(b=>g[b.name]??(b.type==="boolean"?!1:""),"J"),e[6]=g,e[7]=Y):Y=e[7];let P=Y,ee;if(e[8]!==c.userFields||e[9]!==P){let b;e[11]!==P?(b=s(R=>!R.required||dt(R,P(R)),"g"),e[11]=P,e[12]=b):b=e[12],ee=c.userFields.every(b),e[8]=c.userFields,e[9]=P,e[10]=ee}else ee=e[10];let $e=ee,te;e[13]!==n||e[14]!==f||e[15]!==y||e[16]!==$e?(te=!n&&f.trim()!==""&&y.trim()!==""&&$e,e[13]=n,e[14]=f,e[15]=y,e[16]=$e,e[17]=te):te=e[17];let Te=te,ae;e[18]!==c.userFields||e[19]!==P?(ae=s(()=>{let b={};for(let R of c.userFields){let K=ot(R,P(R));K!==void 0&&(b[R.name]=K.value)}return Object.keys(b).length===0?void 0:b},"ee"),e[18]=c.userFields,e[19]=P,e[20]=ae):ae=e[20];let Re=ae,ie;e[21]!==Re||e[22]!==m||e[23]!==f||e[24]!==y||e[25]!==l||e[26]!==i||e[27]!==N||e[28]!==r||e[29]!==v?(ie=s(()=>{v(async()=>{await m.createAuthUser({data:Re(),email:f.trim(),name:y.trim(),password:N===""?void 0:N,role:r.trim()===""?void 0:r.trim()}),i(),l()})},"te"),e[21]=Re,e[22]=m,e[23]=f,e[24]=y,e[25]=l,e[26]=i,e[27]=N,e[28]=r,e[29]=v,e[30]=ie):ie=e[30];let w=ie,B;e[31]!==a?(B=a("Create user"),e[31]=a,e[32]=B):B=e[32];let O;e[33]!==a?(O=a("Create user"),e[33]=a,e[34]=O):O=e[34];let M;e[35]!==O?(M=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:O}),e[35]=O,e[36]=M):M=e[36];let le;e[37]!==a?(le=a("email"),e[37]=a,e[38]=le):le=e[38];let se;e[39]!==le?(se=(0,t.jsx)(j,{htmlFor:"uc-email",children:le}),e[39]=le,e[40]=se):se=e[40];let ne;e[41]!==f?(ne=(0,t.jsx)(E,{"data-testid":"uc-email",id:"uc-email",onChange:k,type:"email",value:f}),e[41]=f,e[42]=ne):ne=e[42];let re;e[43]!==se||e[44]!==ne?(re=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[se,ne]}),e[43]=se,e[44]=ne,e[45]=re):re=e[45];let de;e[46]!==a?(de=a("name"),e[46]=a,e[47]=de):de=e[47];let oe;e[48]!==de?(oe=(0,t.jsx)(j,{htmlFor:"uc-name",children:de}),e[48]=de,e[49]=oe):oe=e[49];let ce;e[50]!==y?(ce=(0,t.jsx)(E,{"data-testid":"uc-name",id:"uc-name",onChange:L,value:y}),e[50]=y,e[51]=ce):ce=e[51];let ue;e[52]!==oe||e[53]!==ce?(ue=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[oe,ce]}),e[52]=oe,e[53]=ce,e[54]=ue):ue=e[54];let he;e[55]!==a?(he=a("Password (optional)"),e[55]=a,e[56]=he):he=e[56];let me;e[57]!==he?(me=(0,t.jsx)(j,{htmlFor:"uc-password",children:he}),e[57]=he,e[58]=me):me=e[58];let pe;e[59]!==N?(pe=(0,t.jsx)(E,{"data-testid":"uc-password",id:"uc-password",onChange:Be,type:"password",value:N}),e[59]=N,e[60]=pe):pe=e[60];let ve;e[61]!==me||e[62]!==pe?(ve=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[me,pe]}),e[61]=me,e[62]=pe,e[63]=ve):ve=e[63];let fe;e[64]!==a?(fe=a("Role (optional)"),e[64]=a,e[65]=fe):fe=e[65];let be;e[66]!==fe?(be=(0,t.jsx)(j,{htmlFor:"uc-role",children:fe}),e[66]=fe,e[67]=be):be=e[67];let xe;e[68]!==r?(xe=(0,t.jsx)(E,{"data-testid":"uc-role",id:"uc-role",onChange:De,value:r}),e[68]=r,e[69]=xe):xe=e[69];let ye;e[70]!==be||e[71]!==xe?(ye=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[be,xe]}),e[70]=be,e[71]=xe,e[72]=ye):ye=e[72];let ge;e[73]!==c.userFields||e[74]!==P||e[75]!==a?(ge=c.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")}),c.userFields.map(b=>{let R=`uc-field-${b.name}`,K=b.required?"":` (${a("optional")})`;if(b.type==="boolean"){let Le=P(b)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:R,children:[(0,t.jsx)(Ge,{checked:Le,"data-testid":R,id:R,onCheckedChange:s(et=>{_e(b.name,et)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[b.name,K]})]},b.name)}let Je=P(b);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(j,{htmlFor:R,children:[b.name,K]}),(0,t.jsx)(E,{"data-testid":R,id:R,onChange:s(Le=>{_e(b.name,Le.target.value)},"onChange"),type:rt[b.type],value:typeof Je=="string"?Je:""})]},b.name)})]}),e[73]=c.userFields,e[74]=P,e[75]=a,e[76]=ge):ge=e[76];let Ne;e[77]!==d?(Ne=d!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:d}),e[77]=d,e[78]=Ne):Ne=e[78];let ke;e[79]!==a?(ke=a("Cancel"),e[79]=a,e[80]=ke):ke=e[80];let we;e[81]!==l||e[82]!==ke?(we=(0,t.jsx)(U,{"data-testid":"uc-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:ke}),e[81]=l,e[82]=ke,e[83]=we):we=e[83];let je=!Te,Ce;e[84]!==n||e[85]!==a?(Ce=a(n?"Creating\u2026":"Create"),e[84]=n,e[85]=a,e[86]=Ce):Ce=e[86];let Ae;e[87]!==w||e[88]!==je||e[89]!==Ce?(Ae=(0,t.jsx)(U,{"data-testid":"uc-submit",disabled:je,onClick:w,size:"sm",type:"button",children:Ce}),e[87]=w,e[88]=je,e[89]=Ce,e[90]=Ae):Ae=e[90];let Ie;e[91]!==we||e[92]!==Ae?(Ie=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[we,Ae]}),e[91]=we,e[92]=Ae,e[93]=Ie):Ie=e[93];let Ee;return e[94]!==l||e[95]!==B||e[96]!==M||e[97]!==re||e[98]!==ue||e[99]!==ve||e[100]!==ye||e[101]!==ge||e[102]!==Ne||e[103]!==Ie?(Ee=(0,t.jsxs)(He,{label:B,onClose:l,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[M,re,ue,ve,ye,ge,Ne,Ie]}),e[94]=l,e[95]=B,e[96]=M,e[97]=re,e[98]=ue,e[99]=ve,e[100]=ye,e[101]=ge,e[102]=Ne,e[103]=Ie,e[104]=Ee):Ee=e[104],Ee},"ot"),We=s(h=>{let e=(0,X.c)(2),{children:l}=h,i;return e[0]!==l?(i=(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l}),e[0]=l,e[1]=i):i=e[1],i},"je"),ut=s(h=>{let e=(0,X.c)(29),{busy:l,runAction:i,userId:m,version:a}=h,c=V(),n=q(),[d,v]=(0,x.useState)(null),[f,C]=(0,x.useState)(null),y;e[0]!==c||e[1]!==m?(y=s(()=>{J((async()=>{C(null);try{let k=await c.listAuthSessions({limit:50,userId:m});v(k.rows)}catch(k){let $=k;v(null),C(Pe($))}})())},"b"),e[0]=c,e[1]=m,e[2]=y):y=e[2];let A;e[3]!==c||e[4]!==m||e[5]!==a?(A=[c,m,a],e[3]=c,e[4]=m,e[5]=a,e[6]=A):A=e[6],(0,x.useEffect)(y,A);let N;e[7]!==c||e[8]!==i?(N=s(k=>{i(()=>c.revokeAuthSession({sessionId:k}))},"y"),e[7]=c,e[8]=i,e[9]=N):N=e[9];let I=N,r;e[10]!==n?(r=n("Sessions"),e[10]=n,e[11]=r):r=e[11];let u;e[12]!==r?(u=(0,t.jsx)(We,{children:r}),e[12]=r,e[13]=u):u=e[13];let p;e[14]!==f?(p=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:f}),e[14]=f,e[15]=p):p=e[15];let g;e[16]!==d||e[17]!==n?(g=d!==null&&d.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:n("No active sessions.")}),e[16]=d,e[17]=n,e[18]=g):g=e[18];let o;e[19]!==l||e[20]!==I||e[21]!==d||e[22]!==n?(o=d!==null&&d.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:n("expires")}),(0,t.jsx)(S,{children:n("ip")}),(0,t.jsx)(S,{children:n("user agent")}),(0,t.jsx)(S,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Ue,{children:d.map(k=>(0,t.jsxs)(T,{"data-testid":`ud-session-${k.id}`,children:[(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q(k.expiresAt)}),(0,t.jsx)(z,{children:k.ipAddress??""}),(0,t.jsx)(z,{className:"max-w-40 truncate",children:k.userAgent??""}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`ud-revoke-${k.id}`,disabled:l,onClick:s(()=>{I(k.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Revoke")})})]},k.id))})]})})}),e[19]=l,e[20]=I,e[21]=d,e[22]=n,e[23]=o):o=e[23];let F;return e[24]!==u||e[25]!==p||e[26]!==g||e[27]!==o?(F=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[u,p,g,o]}),e[24]=u,e[25]=p,e[26]=g,e[27]=o,e[28]=F):F=e[28],F},"dt"),ht=s(h=>{let e=(0,X.c)(30),{busy:l,runAction:i,userId:m,version:a}=h,c=V(),n=q(),[d,v]=(0,x.useState)(null),[f,C]=(0,x.useState)(null),y;e[0]!==c||e[1]!==m?(y=s(()=>{J((async()=>{C(null);try{v(await c.listAuthAccounts({userId:m}))}catch(k){let $=k;v(null),C(Pe($))}})())},"b"),e[0]=c,e[1]=m,e[2]=y):y=e[2];let A;e[3]!==c||e[4]!==m||e[5]!==a?(A=[c,m,a],e[3]=c,e[4]=m,e[5]=a,e[6]=A):A=e[6],(0,x.useEffect)(y,A);let N;e[7]!==c||e[8]!==i||e[9]!==m?(N=s(k=>{i(()=>c.unlinkAuthAccount({accountId:k,userId:m}))},"y"),e[7]=c,e[8]=i,e[9]=m,e[10]=N):N=e[10];let I=N,r;e[11]!==n?(r=n("Linked accounts"),e[11]=n,e[12]=r):r=e[12];let u;e[13]!==r?(u=(0,t.jsx)(We,{children:r}),e[13]=r,e[14]=u):u=e[14];let p;e[15]!==f?(p=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:f}),e[15]=f,e[16]=p):p=e[16];let g;e[17]!==d||e[18]!==n?(g=d!==null&&d.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:n("No linked accounts.")}),e[17]=d,e[18]=n,e[19]=g):g=e[19];let o;e[20]!==d||e[21]!==l||e[22]!==I||e[23]!==n?(o=d!==null&&d.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:n("provider")}),(0,t.jsx)(S,{children:n("created")}),(0,t.jsx)(S,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Ue,{children:d.map(k=>{let $=Fe(k.id);return(0,t.jsxs)(T,{"data-testid":`ud-account-${$}`,children:[(0,t.jsx)(z,{children:Fe(k.providerId)}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q(k.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`ud-unlink-${$}`,disabled:l,onClick:s(()=>{I($)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Unlink")})})]},$)})})]})})}),e[20]=d,e[21]=l,e[22]=I,e[23]=n,e[24]=o):o=e[24];let F;return e[25]!==u||e[26]!==p||e[27]!==g||e[28]!==o?(F=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[u,p,g,o]}),e[25]=u,e[26]=p,e[27]=g,e[28]=o,e[29]=F):F=e[29],F},"ct"),mt=s(h=>{let e=(0,X.c)(40),{busy:l,capabilities:i,runAction:m,userId:a,version:c}=h,n=V(),d=q(),[v,f]=(0,x.useState)(null),C;e[0]!==i.passkey||e[1]!==n||e[2]!==a?(C=s(()=>{i.passkey&&J((async()=>{try{f(await n.listAuthPasskeys({userId:a}))}catch{f(null)}})())},"C"),e[0]=i.passkey,e[1]=n,e[2]=a,e[3]=C):C=e[3];let y;e[4]!==i.passkey||e[5]!==n||e[6]!==a||e[7]!==c?(y=[i.passkey,n,a,c],e[4]=i.passkey,e[5]=n,e[6]=a,e[7]=c,e[8]=y):y=e[8],(0,x.useEffect)(C,y);let A;e[9]!==n||e[10]!==m||e[11]!==a?(A=s(()=>{m(()=>n.disableAuthTwoFactor({userId:a}))},"A"),e[9]=n,e[10]=m,e[11]=a,e[12]=A):A=e[12];let N=A,I;e[13]!==n||e[14]!==m?(I=s($=>{m(()=>n.deleteAuthPasskey({passkeyId:$}))},"I"),e[13]=n,e[14]=m,e[15]=I):I=e[15];let r=I,u;e[16]!==d?(u=d("Security"),e[16]=d,e[17]=u):u=e[17];let p;e[18]!==u?(p=(0,t.jsx)(We,{children:u}),e[18]=u,e[19]=p):p=e[19];let g;e[20]!==l||e[21]!==i.twoFactor||e[22]!==N||e[23]!==d?(g=i.twoFactor&&(0,t.jsx)(U,{"data-testid":"ud-disable-2fa",disabled:l,onClick:N,size:"sm",type:"button",variant:"outline",children:d("Disable two-factor")}),e[20]=l,e[21]=i.twoFactor,e[22]=N,e[23]=d,e[24]=g):g=e[24];let o;e[25]!==i.passkey||e[26]!==v||e[27]!==d?(o=i.passkey&&v!==null&&v.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:d("No passkeys.")}),e[25]=i.passkey,e[26]=v,e[27]=d,e[28]=o):o=e[28];let F;e[29]!==l||e[30]!==i.passkey||e[31]!==r||e[32]!==v||e[33]!==d?(F=i.passkey&&v!==null&&v.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"ud-passkeys-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:d("name")}),(0,t.jsx)(S,{children:d("created")}),(0,t.jsx)(S,{"aria-label":d("Actions")})]})}),(0,t.jsx)(Ue,{children:v.map($=>{let L=Fe($.id);return(0,t.jsxs)(T,{"data-testid":`ud-passkey-${L}`,children:[(0,t.jsx)(z,{children:Fe($.name)||L}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q($.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`ud-delete-passkey-${L}`,disabled:l,onClick:s(()=>{r(L)},"onClick"),size:"xs",type:"button",variant:"ghost",children:d("Delete")})})]},L)})})]})})}),e[29]=l,e[30]=i.passkey,e[31]=r,e[32]=v,e[33]=d,e[34]=F):F=e[34];let k;return e[35]!==p||e[36]!==g||e[37]!==o||e[38]!==F?(k=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[p,g,o,F]}),e[35]=p,e[36]=g,e[37]=o,e[38]=F,e[39]=k):k=e[39],k},"ut"),pt=/(?:at|expires)$/iu,vt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),ft=s((h,e)=>typeof e=="number"&&pt.test(h)?Q(e):Fe(e),"pt"),bt=s(({capabilities:h,onChanged:e,onClose:l,user:i})=>{let m=V(),a=q(),c=i.banned===!0,[n,d]=(0,x.useState)(null),[v,f]=(0,x.useState)(!1),[C,y]=(0,x.useState)(0),[A,N]=(0,x.useState)(typeof i.role=="string"?i.role:""),[I,r]=(0,x.useState)(""),[u,p]=(0,x.useState)(""),[g,o]=(0,x.useState)(""),[F,k]=(0,x.useState)(null),[$,L]=(0,x.useState)(!1),_=s((w,B)=>{J((async()=>{f(!0),d(null);try{let O=await w();B?.refresh!==!1&&(y(M=>M+1),e()),B?.onResult?.(O)}catch(O){d(Pe(O))}f(!1)})())},"D"),Be=s(w=>{N(w.target.value)},"$e"),Z=s(w=>{r(w.target.value)},"Z"),De=s(w=>{p(w.target.value)},"Be"),G=s(w=>{o(w.target.value)},"W"),_e=s(()=>{let w=A.trim();w!==""&&_(async()=>{await m.setAuthUserRole({role:w,userId:i.id})})},"De"),Y=s(()=>{let w=Number.parseInt(u,10),B=Number.isFinite(w)&&w>0?w*86400:void 0;_(async()=>{await m.banAuthUser({expiresInSeconds:B,reason:I.trim()===""?void 0:I.trim(),userId:i.id})})},"J"),P=s(()=>{_(async()=>{await m.unbanAuthUser({userId:i.id})})},"P"),ee=s(()=>{_(async()=>{await m.setAuthUserPassword({newPassword:g,userId:i.id}),o("")})},"K"),$e=s(()=>{_(()=>m.impersonateAuthUser({userId:i.id}),{onResult:s(w=>{k(w.token)},"onResult"),refresh:!1})},"Fe"),te=s(()=>{_(async()=>{await m.revokeAuthUserSessions({userId:i.id})})},"X"),Te=s(()=>{_(async()=>{await m.removeAuthUser({userId:i.id}),l()})},"ze"),ae=s(()=>{L(!0)},"ee"),Re=s(()=>{L(!1)},"Se"),ie=Object.entries(i).filter(([w])=>!vt.has(w));return(0,t.jsxs)(He,{label:a("User details"),onClose:l,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:i.name??i.email??i.id}),(0,t.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:i.id}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof i.role=="string"&&i.role!==""&&(0,t.jsx)(D,{variant:"secondary",children:i.role}),c?(0,t.jsx)(D,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(D,{variant:"outline",children:a("Active")}),i.emailVerified===!0?(0,t.jsx)(D,{variant:"secondary",children:a("verified")}):(0,t.jsx)(D,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(U,{"data-testid":"ud-close",onClick:l,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),n!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:n}),h.admin&&(0,t.jsxs)(H,{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)(W,{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)(j,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(E,{"data-testid":"ud-role-input",id:"ud-role",onChange:Be,value:A})]}),(0,t.jsx)(U,{"data-testid":"ud-set-role",disabled:v||A.trim()==="",onClick:_e,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),c?(0,t.jsx)(U,{"data-testid":"ud-unban",disabled:v,onClick:P,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(j,{htmlFor:"ud-ban-reason",children:a("Ban reason (optional)")}),(0,t.jsx)(E,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:Z,value:I})]}),(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[(0,t.jsx)(j,{htmlFor:"ud-ban-days",children:a("Days")}),(0,t.jsx)(E,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:De,type:"number",value:u})]}),(0,t.jsx)(U,{"data-testid":"ud-ban",disabled:v,onClick:Y,size:"sm",type:"button",variant:"destructive",children:a("Ban user")})]}),(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(j,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(E,{"data-testid":"ud-password",id:"ud-password",onChange:G,type:"password",value:g})]}),(0,t.jsx)(U,{"data-testid":"ud-set-password",disabled:v||g==="",onClick:ee,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(U,{"data-testid":"ud-impersonate",disabled:v,onClick:$e,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(U,{"data-testid":"ud-revoke-all",disabled:v,onClick:te,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),$?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(U,{"data-testid":"ud-delete-confirm",disabled:v,onClick:Te,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(U,{"data-testid":"ud-delete-cancel",onClick:Re,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(U,{"data-testid":"ud-delete",disabled:v,onClick:ae,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),F!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(j,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(E,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:F})]})]})]}),(0,t.jsx)(ut,{busy:v,runAction:_,userId:i.id,version:C}),h.accounts&&(0,t.jsx)(ht,{busy:v,runAction:_,userId:i.id,version:C}),(h.twoFactor||h.passkey)&&(0,t.jsx)(mt,{busy:v,capabilities:h,runAction:_,userId:i.id,version:C}),(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:ie.map(([w,B])=>(0,t.jsxs)("div",{className:"flex flex-col border-t border-border py-1.5",children:[(0,t.jsx)("dt",{className:"text-xs font-semibold text-muted-foreground",children:w}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:ft(w,B)})]},w))})]})]})},"ft"),xt=50,Bt=s(({pageSize:h=xt}={})=>{let e=V(),l=q(),[i,m]=(0,x.useState)(""),[a,c]=(0,x.useState)(""),n=Ze(i),[d,v]=(0,x.useState)(null),[f,C]=(0,x.useState)(!1),{capabilities:y}=lt(),A=n.trim(),N=a.trim(),I=Ve(["lunora-auth-users",A,N,h],()=>e.listAuthUsers({filterField:N===""?void 0:"role",filterValue:N===""?void 0:N,limit:h,search:A===""?void 0:A}),{keepPreviousData:!0}),r=I.data?.rows??null,u=I.error,p=s(()=>{I.refetch()},"p");Ke(()=>{I.refetch()},!0);let g=d===null?null:r?.find(o=>o.id===d)??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)(E,{"aria-label":l("Search users"),className:"w-56","data-testid":"us-search",onChange:s(o=>{m(o.target.value)},"onChange"),placeholder:l("Search by email or name\u2026"),value:i}),(0,t.jsx)(E,{"aria-label":l("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:s(o=>{c(o.target.value)},"onChange"),placeholder:l("Filter by role"),value:a}),(0,t.jsx)(U,{"data-testid":"us-new",onClick:s(()=>{C(!0)},"onClick"),size:"sm",type:"button",children:l("New user")})]}),u!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:u}),r!==null&&r.length===0&&(0,t.jsx)(Me,{description:l("Users who sign up to your app will appear here."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:l("No users.")}),r!==null&&r.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"us-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:l("id")}),(0,t.jsx)(S,{children:l("email")}),(0,t.jsx)(S,{children:l("name")}),(0,t.jsx)(S,{children:l("role")}),(0,t.jsx)(S,{children:l("status")}),(0,t.jsx)(S,{children:l("verified")}),(0,t.jsx)(S,{children:l("created")}),(0,t.jsx)(S,{"aria-label":l("Actions")})]})}),(0,t.jsx)(Ue,{children:r.map(o=>(0,t.jsxs)(T,{"data-testid":`us-row-${o.id}`,children:[(0,t.jsx)(z,{className:"font-mono text-xs",children:o.id}),(0,t.jsx)(z,{children:o.email??""}),(0,t.jsx)(z,{children:o.name??""}),(0,t.jsx)(z,{children:typeof o.role=="string"&&o.role!==""?(0,t.jsx)(D,{variant:"secondary",children:o.role}):""}),(0,t.jsx)(z,{children:o.banned===!0?(0,t.jsx)(D,{variant:"destructive",children:l("Banned")}):(0,t.jsx)(D,{variant:"success",children:l("Active")})}),(0,t.jsx)(z,{children:o.emailVerified===!0?(0,t.jsx)(D,{variant:"success",children:l("yes")}):(0,t.jsx)(D,{variant:"outline",children:l("no")})}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q(o.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`us-manage-${o.id}`,onClick:s(()=>{v(o.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Manage")})})]},o.id))})]})})}),g!==null&&(0,t.jsx)(bt,{capabilities:y,onChanged:p,onClose:s(()=>{v(null)},"onClose"),user:g}),f&&(0,t.jsx)(ct,{onClose:s(()=>{C(!1)},"onClose"),onCreated:p}),y.inviteOnly&&(0,t.jsx)(nt,{})]})},"zt");export{Bt as UsersPanel};
@@ -1 +1 @@
1
- import{b as c}from"./chunk-5G2MAI3G.js";import{f as l}from"./chunk-SZSHO6RE.js";import{a as r,d as f,f as g}from"./chunk-YKXDMIHQ.js";var m=f(g(),1);var p={capabilities:{accounts:!0,admin:!0,inviteOnly:!1,organization:!1,passkey:!1,twoFactor:!1},emailAndPassword:!1,organization:{enabled:!1,roles:!1,teams:!1},plugins:[],rateLimit:{enabled:!1},session:{},socialProviders:[],userFields:[]},h=r(()=>{let a=(0,m.c)(6),s=l(),o;a[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-auth-config"],a[0]=o):o=a[0];let e;a[1]!==s?(e=r(()=>s.getAuthConfig(),"t"),a[1]=s,a[2]=e):e=a[2];let{data:u,isLoading:d}=c(o,e),t=u??p,n=!d,i;return a[3]!==t||a[4]!==n?(i={config:t,ready:n},a[3]=t,a[4]=n,a[5]=i):i=a[5],i},"b");export{p as a,h as b};
1
+ import{b as c}from"./chunk-FI3UY4QJ.js";import{f as l}from"./chunk-PYI2MI4Q.js";import{a as r,d as f,f as g}from"./chunk-YKXDMIHQ.js";var m=f(g(),1);var p={capabilities:{accounts:!0,admin:!0,inviteOnly:!1,organization:!1,passkey:!1,twoFactor:!1},emailAndPassword:!1,organization:{enabled:!1,roles:!1,teams:!1},plugins:[],rateLimit:{enabled:!1},session:{},socialProviders:[],userFields:[]},h=r(()=>{let a=(0,m.c)(6),s=l(),o;a[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-auth-config"],a[0]=o):o=a[0];let e;a[1]!==s?(e=r(()=>s.getAuthConfig(),"t"),a[1]=s,a[2]=e):e=a[2];let{data:u,isLoading:d}=c(o,e),t=u??p,n=!d,i;return a[3]!==t||a[4]!==n?(i={config:t,ready:n},a[3]=t,a[4]=n,a[5]=i):i=a[5],i},"b");export{p as a,h as b};
@@ -1,4 +1,4 @@
1
- import{a as Pe}from"./chunk-EA2JKR5D.js";import{a as he}from"./chunk-IMOHEGMV.js";import{d as Ne,f as ke,g as we,k as oe}from"./chunk-V3VJAA4D.js";import{a as V}from"./chunk-5WJXVZMZ.js";import{a as $e}from"./chunk-2DX5MROH.js";import"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import{W as ye}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as B}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as ve}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as Oe}from"./chunk-4ZEL6BYL.js";import{f as F}from"./chunk-SZSHO6RE.js";import"./chunk-FSRSK4LY.js";import{d as be}from"./chunk-CEA2QYAI.js";import{a as U}from"./chunk-FKVZRPV5.js";import{d as M,e as Se,f as se,g as ie,h as le,o as Ie,q as ae}from"./chunk-FODLDLE2.js";import{a as u,d as z,e as ue,f as te,g as re,i as fe}from"./chunk-YKXDMIHQ.js";var He=z(te(),1),xe=z(ue(),1);var Y=z(te(),1);var X=z(ue(),1);var C=z(re(),1);var Qe=se(Oe.listTables),Ve=["react","client","cli"],Xe={action:"action",mutation:"mutation",query:"query"},_e=u(t=>{let e=t.indexOf(":");return e===-1?{file:"",fn:t}:{file:t.slice(0,e),fn:t.slice(e+1)}},"Q"),Ye=u(({file:t,fn:e,kind:a})=>`await client.${Xe[a]}(api.${t}.${e}, { /* args */ });`,"ie"),Ze=u(t=>{let e=`api.${t.file}.${t.fn}`;switch(t.kind){case"action":return`const { call: ${t.fn} } = useAction(${e});`;case"mutation":return`const ${t.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},"se"),et=u(({file:t,fn:e})=>`lunora run ${t}:${e} --args '{ }'`,"oe"),tt=u(t=>["// Read rows",`const rows = await ctx.db.query("${t}").collect();`,"","// Insert a row",`const id = await ctx.db.insert("${t}", { /* fields */ });`,"","// Generated types",`type Row = Doc<"${t}">;`,`type RowId = Id<"${t}">;`].join(`
1
+ import{a as Pe}from"./chunk-EA2JKR5D.js";import{a as he}from"./chunk-IMOHEGMV.js";import{d as Ne,f as ke,g as we,k as oe}from"./chunk-V3VJAA4D.js";import{a as V}from"./chunk-5WJXVZMZ.js";import{a as $e}from"./chunk-2DX5MROH.js";import"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import{W as ye}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as B}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as ve}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as Oe}from"./chunk-4ZEL6BYL.js";import{f as F}from"./chunk-PYI2MI4Q.js";import"./chunk-FSRSK4LY.js";import{d as be}from"./chunk-MKL7VDTL.js";import{a as U}from"./chunk-FKVZRPV5.js";import{d as M,e as Se,f as se,g as ie,h as le,o as Ie,q as ae}from"./chunk-FODLDLE2.js";import{a as u,d as z,e as ue,f as te,g as re,i as fe}from"./chunk-YKXDMIHQ.js";var He=z(te(),1),xe=z(ue(),1);var Y=z(te(),1);var X=z(ue(),1);var C=z(re(),1);var Qe=se(Oe.listTables),Ve=["react","client","cli"],Xe={action:"action",mutation:"mutation",query:"query"},_e=u(t=>{let e=t.indexOf(":");return e===-1?{file:"",fn:t}:{file:t.slice(0,e),fn:t.slice(e+1)}},"Q"),Ye=u(({file:t,fn:e,kind:a})=>`await client.${Xe[a]}(api.${t}.${e}, { /* args */ });`,"ie"),Ze=u(t=>{let e=`api.${t.file}.${t.fn}`;switch(t.kind){case"action":return`const { call: ${t.fn} } = useAction(${e});`;case"mutation":return`const ${t.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},"se"),et=u(({file:t,fn:e})=>`lunora run ${t}:${e} --args '{ }'`,"oe"),tt=u(t=>["// Read rows",`const rows = await ctx.db.query("${t}").collect();`,"","// Insert a row",`const id = await ctx.db.insert("${t}", { /* fields */ });`,"","// Generated types",`type Row = Doc<"${t}">;`,`type RowId = Id<"${t}">;`].join(`
2
2
  `),"ce"),rt=u((t,e)=>{switch(t){case"cli":return et(e);case"client":return Ye(e);default:return Ze(e)}},"re"),Te=u(t=>{let e=(0,Y.c)(19),{code:a,label:r,testId:n}=t,s=M(),o;e[0]!==a?(o=u(()=>{ae(a)},"c"),e[0]=a,e[1]=o):o=e[1];let i=o,d;e[2]!==r?(d=(0,C.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:r}),e[2]=r,e[3]=d):d=e[3];let m=`${n}-copy`,l;e[4]!==s?(l=s("Copy"),e[4]=s,e[5]=l):l=e[5];let c;e[6]!==i||e[7]!==m||e[8]!==l?(c=(0,C.jsx)(B,{"data-testid":m,onClick:i,size:"xs",type:"button",variant:"ghost",children:l}),e[6]=i,e[7]=m,e[8]=l,e[9]=c):c=e[9];let f;e[10]!==d||e[11]!==c?(f=(0,C.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[d,c]}),e[10]=d,e[11]=c,e[12]=f):f=e[12];let h;e[13]!==a||e[14]!==n?(h=(0,C.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":n,children:a}),e[13]=a,e[14]=n,e[15]=h):h=e[15];let g;return e[16]!==f||e[17]!==h?(g=(0,C.jsxs)("div",{className:"flex flex-col gap-1.5",children:[f,h]}),e[16]=f,e[17]=h,e[18]=g):g=e[18],g},"U"),at=u(t=>{let e=(0,Y.c)(46),{file:a,fn:r,kind:n}=t,s=M(),[o,i]=(0,X.useState)("react"),d,m,l;if(e[0]!==a||e[1]!==r||e[2]!==n||e[3]!==s||e[4]!==o){let w={file:a,fn:r,kind:n},j;e[8]!==s?(j=s("CLI"),e[8]=s,e[9]=j):j=e[9];let O;e[10]!==s?(O=s("Client"),e[10]=s,e[11]=O):O=e[11];let S;e[12]!==s?(S=s("React"),e[12]=s,e[13]=S):S=e[13];let T;e[14]!==j||e[15]!==O||e[16]!==S?(T={cli:j,client:O,react:S},e[14]=j,e[15]=O,e[16]=S,e[17]=T):T=e[17],l=T;let A;e[18]===Symbol.for("react.memo_cache_sentinel")?(A=u(R=>{i(R.currentTarget.dataset.tab)},"B"),e[18]=A):A=e[18],d=A,m=rt(o,w),e[0]=a,e[1]=r,e[2]=n,e[3]=s,e[4]=o,e[5]=d,e[6]=m,e[7]=l}else d=e[5],m=e[6],l=e[7];let c=m,f=`api.${a}.${r}`,h;e[19]!==f?(h=(0,C.jsx)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-fn-title",children:f}),e[19]=f,e[20]=h):h=e[20];let g;e[21]!==n||e[22]!==s?(g=s("Call this {kind} from your app.",{kind:n}),e[21]=n,e[22]=s,e[23]=g):g=e[23];let x;e[24]!==g?(x=(0,C.jsx)("p",{className:"text-xs text-muted-foreground",children:g}),e[24]=g,e[25]=x):x=e[25];let y;e[26]!==h||e[27]!==x?(y=(0,C.jsxs)("div",{children:[h,x]}),e[26]=h,e[27]=x,e[28]=y):y=e[28];let N;e[29]!==s?(N=s("Snippet flavour"),e[29]=s,e[30]=N):N=e[30];let v;e[31]!==d||e[32]!==o||e[33]!==l?(v=Ve.map(w=>(0,C.jsx)(B,{"aria-selected":o===w,"data-tab":w,"data-testid":`api-tab-${w}`,onClick:d,role:"tab",size:"xs",type:"button",variant:o===w?"default":"outline",children:l[w]},w)),e[31]=d,e[32]=o,e[33]=l,e[34]=v):v=e[34];let b;e[35]!==N||e[36]!==v?(b=(0,C.jsx)("div",{"aria-label":N,className:"flex gap-1.5","data-testid":"api-tabs",role:"tablist",children:v}),e[35]=N,e[36]=v,e[37]=b):b=e[37];let I=l[o],P=`api-snippet-${o}`,$;e[38]!==c||e[39]!==I||e[40]!==P?($=(0,C.jsx)(Te,{code:c,label:I,testId:P}),e[38]=c,e[39]=I,e[40]=P,e[41]=$):$=e[41];let k;return e[42]!==$||e[43]!==y||e[44]!==b?(k=(0,C.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"api-fn-doc",children:[y,b,$]}),e[42]=$,e[43]=y,e[44]=b,e[45]=k):k=e[45],k},"de"),nt=u(t=>{let e=(0,Y.c)(19),{name:a}=t,r=M(),n;e[0]!==a?(n=tt(a),e[0]=a,e[1]=n):n=e[1];let s=n,o;e[2]!==a?(o=(0,C.jsx)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-table-title",children:a}),e[2]=a,e[3]=o):o=e[3];let i;e[4]!==r?(i=r("Read and write this table through the typed data model."),e[4]=r,e[5]=i):i=e[5];let d;e[6]!==i?(d=(0,C.jsx)("p",{className:"text-xs text-muted-foreground",children:i}),e[6]=i,e[7]=d):d=e[7];let m;e[8]!==o||e[9]!==d?(m=(0,C.jsxs)("div",{children:[o,d]}),e[8]=o,e[9]=d,e[10]=m):m=e[10];let l;e[11]!==r?(l=r("Data model"),e[11]=r,e[12]=l):l=e[12];let c;e[13]!==s||e[14]!==l?(c=(0,C.jsx)(Te,{code:s,label:l,testId:"api-snippet-table"}),e[13]=s,e[14]=l,e[15]=c):c=e[15];let f;return e[16]!==m||e[17]!==c?(f=(0,C.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"api-table-doc",children:[m,c]}),e[16]=m,e[17]=c,e[18]=f):f=e[18],f},"fe"),je=u(t=>{let e=(0,Y.c)(8),{active:a,label:r,onSelect:n,testId:s,value:o}=t,i;e[0]!==n||e[1]!==o?(i=u(()=>{n(o)},"m"),e[0]=n,e[1]=o,e[2]=i):i=e[2];let d=i,m=a?"page":void 0,l;return e[3]!==r||e[4]!==d||e[5]!==m||e[6]!==s?(l=(0,C.jsx)("button",{"aria-current":m,className:"w-full truncate rounded-md px-2 py-1 text-start font-mono text-xs text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-foreground","data-testid":s,onClick:d,type:"button",children:r}),e[3]=r,e[4]=d,e[5]=m,e[6]=s,e[7]=l):l=e[7],l},"G"),ot=u(t=>{let e=new Map;for(let a of t){let{file:r,fn:n}=_e(a.path),s=e.get(r)??[];s.push({fn:n,kind:a.kind,path:a.path}),e.set(r,s)}return[...e.entries()].map(([a,r])=>({file:a,items:r.toSorted((n,s)=>n.fn.localeCompare(s.fn))})).toSorted((a,r)=>a.file.localeCompare(r.file))},"pe"),Ce=u(t=>{let e=(0,Y.c)(58),{functions:a,initialShardKey:r}=t,n=M(),s=F(),[o,i]=(0,X.useState)(null),[d,m]=(0,X.useState)(null),l,c;e[0]!==s||e[1]!==r?(l=u(()=>{let R=!1;return s.query(Qe,{},ie(r??"")).then(_=>(R||i(_),_)).catch(()=>{R||i([])}),()=>{R=!0}},"o"),c=[s,r],e[0]=s,e[1]=r,e[2]=l,e[3]=c):(l=e[2],c=e[3]),(0,X.useEffect)(l,c);let f,h,g,x,y,N,v,b,I,P;if(e[4]!==a||e[5]!==d||e[6]!==n||e[7]!==o){let R=a??[],_=ot(R),L=(o??[]).map(st).toSorted(it),E;e[18]===Symbol.for("react.memo_cache_sentinel")?(E=u(q=>{m({kind:"fn",path:q})},"P"),e[18]=E):E=e[18];let W=E,Q;e[19]===Symbol.for("react.memo_cache_sentinel")?(Q=u(q=>{m({kind:"table",name:q})},"j"),e[19]=Q):Q=e[19];let Ge=Q;h=d?.kind==="fn"?R.find(q=>q.path===d.path):void 0,f=R.length>0||L.length>0,g=h===void 0?void 0:_e(h.path),I="grid min-h-0 gap-6 md:grid-cols-[16rem_minmax(0,1fr)]",P="lunora-api-docs",e[20]!==n?(x=n("API resources"),e[20]=n,e[21]=x):x=e[21],y="flex flex-col gap-4 overflow-y-auto",N="api-rail";let ne;e[22]!==d||e[23]!==n?(ne=u(q=>(0,C.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,C.jsx)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:q.file||n("(root)")}),q.items.map(ee=>(0,C.jsx)(je,{active:d?.kind==="fn"&&d.path===ee.path,label:ee.fn,onSelect:W,testId:`api-rail-fn-${ee.path}`,value:ee.path},ee.path))]},q.file),"q"),e[22]=d,e[23]=n,e[24]=ne):ne=e[24],v=_.map(ne),b=L.length>0&&(0,C.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,C.jsx)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Tables")}),L.map(q=>(0,C.jsx)(je,{active:d?.kind==="table"&&d.name===q,label:q,onSelect:Ge,testId:`api-rail-table-${q}`,value:q},q))]}),e[4]=a,e[5]=d,e[6]=n,e[7]=o,e[8]=f,e[9]=h,e[10]=g,e[11]=x,e[12]=y,e[13]=N,e[14]=v,e[15]=b,e[16]=I,e[17]=P}else f=e[8],h=e[9],g=e[10],x=e[11],y=e[12],N=e[13],v=e[14],b=e[15],I=e[16],P=e[17];let $;e[25]!==f||e[26]!==n?($=!f&&(0,C.jsx)("p",{className:"px-2 text-xs text-muted-foreground","data-testid":"api-rail-empty",children:n("No functions or tables to document yet.")}),e[25]=f,e[26]=n,e[27]=$):$=e[27];let k;e[28]!==$||e[29]!==x||e[30]!==y||e[31]!==N||e[32]!==v||e[33]!==b?(k=(0,C.jsxs)("nav",{"aria-label":x,className:y,"data-testid":N,children:[v,b,$]}),e[28]=$,e[29]=x,e[30]=y,e[31]=N,e[32]=v,e[33]=b,e[34]=k):k=e[34];let w;e[35]!==d||e[36]!==n?(w=d===null&&(0,C.jsx)(U,{description:n("Select a function or table to see how to call it from your app."),testId:"api-empty",title:n("API usage snippets")}),e[35]=d,e[36]=n,e[37]=w):w=e[37];let j;e[38]!==d?.kind||e[39]!==h||e[40]!==g?(j=d?.kind==="fn"&&h!==void 0&&g!==void 0&&(0,C.jsx)(at,{file:g.file,fn:g.fn,kind:h.kind},h.path),e[38]=d?.kind,e[39]=h,e[40]=g,e[41]=j):j=e[41];let O;e[42]!==d?.kind||e[43]!==h||e[44]!==n?(O=d?.kind==="fn"&&h===void 0&&(0,C.jsx)(U,{testId:"api-empty",title:n("API usage snippets")}),e[42]=d?.kind,e[43]=h,e[44]=n,e[45]=O):O=e[45];let S;e[46]!==d?(S=d?.kind==="table"&&(0,C.jsx)(nt,{name:d.name}),e[46]=d,e[47]=S):S=e[47];let T;e[48]!==w||e[49]!==j||e[50]!==O||e[51]!==S?(T=(0,C.jsxs)("div",{className:"min-w-0",children:[w,j,O,S]}),e[48]=w,e[49]=j,e[50]=O,e[51]=S,e[52]=T):T=e[52];let A;return e[53]!==k||e[54]!==T||e[55]!==I||e[56]!==P?(A=(0,C.jsxs)("div",{className:I,"data-testid":P,children:[k,T]}),e[53]=k,e[54]=T,e[55]=I,e[56]=P,e[57]=A):A=e[57],A},"ke");function st(t){return t.name}u(st,"ue");function it(t,e){return t.localeCompare(e)}u(it,"me");var De=z(te(),1);var K=z(te(),1),J=z(ue(),1);var p=z(re(),1);var pe=u(function(t,e,a){let r=(0,K.c)(15),n;r[0]===Symbol.for("react.memo_cache_sentinel")?(n={kind:"loading"},r[0]=n):n=r[0];let[s,o]=(0,J.useState)(n),i;r[1]!==e?(i=u(async()=>e(),"a"),r[1]=e,r[2]=i):i=r[2];let d=(0,J.useEffectEvent)(i),m;r[3]!==a?(m=u(g=>a(g),"d"),r[3]=a,r[4]=m):m=r[4];let l=(0,J.useEffectEvent)(m),c;r[5]!==l||r[6]!==d||r[7]!==t?(c=u(()=>{if(t!==void 0)return;let g=!1;return d().then(x=>(g||o(l(x)),x)).catch(x=>{g||o({kind:"error",message:le(x)})}),()=>{g=!0}},"u"),r[5]=l,r[6]=d,r[7]=t,r[8]=c):c=r[8];let f;r[9]!==t?(f=[t],r[9]=t,r[10]=f):f=r[10],(0,J.useEffect)(c,f);let h;return r[11]!==a||r[12]!==s||r[13]!==t?(h=t===void 0?s:a(t),r[11]=a,r[12]=s,r[13]=t,r[14]=h):h=r[14],h},"wt"),lt=u(t=>typeof t=="number"?"number":typeof t=="boolean"?"boolean":"string","we"),Ee=u(t=>{if(t.enum!==void 0&&t.enum.length>0)return t.enum;if(t.anyOf!==void 0&&t.anyOf.length>0&&t.anyOf.every(e=>e.const!==void 0))return t.anyOf.map(e=>e.const)},"Z"),ce=u(t=>t===void 0?"any":t.const!==void 0?JSON.stringify(t.const):t.enum!==void 0&&t.enum.length>0?t.enum.map(e=>JSON.stringify(e)).join(" | "):t.anyOf!==void 0&&t.anyOf.length>0?t.anyOf.map(e=>ce(e)).join(" | "):t.type==="array"?`array<${ce(t.items)}>`:t.type??"any","F"),dt=u(t=>{let e=Ee(t);return e!==void 0?t.type??lt(e[0]):ce(t)},"Oe"),ct=u(t=>{let e=Ee(t);return e===void 0?void 0:e.map(a=>JSON.stringify(a)).join(" | ")},"$e"),pt=u(t=>{let e=[];t.minimum!==void 0?e.push(`${String(t.minimum)} \u2264`):t.exclusiveMinimum!==void 0&&e.push(`${String(t.exclusiveMinimum)} <`);let a=e.length>0;e.push("value"),t.maximum!==void 0?e.push(`\u2264 ${String(t.maximum)}`):t.exclusiveMaximum!==void 0&&e.push(`< ${String(t.exclusiveMaximum)}`);let r=e.length>(a?2:1);return a||r?e.join(" "):void 0},"Te"),mt=u(t=>{if(t.type==="object"&&t.properties!==void 0)return t;if(t.type==="array"&&t.items?.type==="object"&&t.items.properties!==void 0)return t.items},"Ee"),Z=u(t=>{if(t===void 0)return null;if(t.const!==void 0)return t.const;if(t.enum!==void 0&&t.enum.length>0)return t.enum[0];if(t.anyOf!==void 0&&t.anyOf.length>0)return Z(t.anyOf[0]);switch(t.type){case"array":return[];case"boolean":return!1;case"number":return 0;case"object":{let e={};for(let[a,r]of Object.entries(t.properties??{}))e[a]=Z(r);return e}case"string":return"";default:return null}},"D"),de=u(t=>{let e=(0,K.c)(7),{label:a,value:r}=t,n;e[0]!==a?(n=(0,p.jsx)("span",{className:"text-muted-foreground",children:a}),e[0]=a,e[1]=n):n=e[1];let s;e[2]!==r?(s=(0,p.jsx)("span",{className:"text-foreground",children:r}),e[2]=r,e[3]=s):s=e[3];let o;return e[4]!==n||e[5]!==s?(o=(0,p.jsxs)("span",{className:"inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 font-mono text-[10px]",children:[n,s]}),e[4]=n,e[5]=s,e[6]=o):o=e[6],o},"K"),ut=u(t=>{let e=(0,K.c)(40),{name:a,required:r,schema:n}=t,s=M(),o;e[0]!==n?(o=pt(n),e[0]=n,e[1]=o):o=e[1];let i=o,d;e[2]!==n?(d=ct(n),e[2]=n,e[3]=d):d=e[3];let m=d,l=n["x-lunora-table"],c=n.format!==void 0||i!==void 0||m!==void 0||l!==void 0,f;e[4]!==n?(f=mt(n),e[4]=n,e[5]=f):f=e[5];let h=f,g=r?"*":"?",x;e[6]!==g?(x=(0,p.jsx)("span",{className:"text-muted-foreground",children:g}),e[6]=g,e[7]=x):x=e[7];let y;e[8]!==a||e[9]!==x?(y=(0,p.jsxs)("span",{className:"font-mono text-foreground",children:[a,x]}),e[8]=a,e[9]=x,e[10]=y):y=e[10];let N;e[11]!==n?(N=dt(n),e[11]=n,e[12]=N):N=e[12];let v;e[13]!==N?(v=(0,p.jsx)("span",{className:"font-mono text-muted-foreground",children:N}),e[13]=N,e[14]=v):v=e[14];let b;e[15]!==y||e[16]!==v?(b=(0,p.jsxs)("div",{className:"flex items-baseline gap-2",children:[y,v]}),e[15]=y,e[16]=v,e[17]=b):b=e[17];let I;e[18]!==n.description?(I=n.description!==void 0&&(0,p.jsx)("p",{className:"max-w-prose text-muted-foreground",children:n.description}),e[18]=n.description,e[19]=I):I=e[19];let P;e[20]!==c||e[21]!==i||e[22]!==l||e[23]!==n.format||e[24]!==s||e[25]!==m?(P=c&&(0,p.jsxs)("div",{className:"flex flex-wrap gap-1",children:[n.format!==void 0&&(0,p.jsx)(de,{label:s("Format"),value:n.format}),i!==void 0&&(0,p.jsx)(de,{label:s("Range"),value:i}),m!==void 0&&(0,p.jsx)(de,{label:s("Value in"),value:m}),l!==void 0&&(0,p.jsx)(de,{label:s("relation"),value:l})]}),e[20]=c,e[21]=i,e[22]=l,e[23]=n.format,e[24]=s,e[25]=m,e[26]=P):P=e[26];let $;e[27]!==I||e[28]!==P||e[29]!==b?($=(0,p.jsxs)("div",{className:"flex flex-col gap-1 py-2",children:[b,I,P]}),e[27]=I,e[28]=P,e[29]=b,e[30]=$):$=e[30];let k=$;if(h===void 0){let S;return e[31]!==k?(S=(0,p.jsx)("div",{className:"border-b border-border/50 last:border-b-0",children:k}),e[31]=k,e[32]=S):S=e[32],S}let w;e[33]!==k?(w=(0,p.jsx)("summary",{className:"cursor-pointer marker:text-muted-foreground",children:k}),e[33]=k,e[34]=w):w=e[34];let j;e[35]!==h?(j=(0,p.jsx)("div",{className:"mb-2 ml-2 border-l border-border pl-3",children:(0,p.jsx)(Je,{schema:h})}),e[35]=h,e[36]=j):j=e[36];let O;return e[37]!==w||e[38]!==j?(O=(0,p.jsxs)("details",{className:"border-b border-border/50 last:border-b-0",children:[w,j]}),e[37]=w,e[38]=j,e[39]=O):O=e[39],O},"Ce"),Je=u(t=>{let e=(0,K.c)(7),{schema:a}=t,r;e[0]!==a.required?(r=new Set(a.required),e[0]=a.required,e[1]=r):r=e[1];let n=r,s;e[2]!==a.properties?(s=Object.entries(a.properties??{}),e[2]=a.properties,e[3]=s):s=e[3];let o=s,i;return e[4]!==n||e[5]!==o?(i=(0,p.jsx)("div",{className:"flex flex-col",children:o.map(d=>{let[m,l]=d;return(0,p.jsx)(ut,{name:m,required:n.has(m),schema:l},m)})}),e[4]=n,e[5]=o,e[6]=i):i=e[6],i},"ee"),Ae=u(t=>{let e=(0,K.c)(10),{schema:a,testId:r}=t;if(a?.type!=="object"||Object.keys(a.properties??{}).length===0){let o;e[0]!==a?(o=ce(a),e[0]=a,e[1]=o):o=e[1];let i;return e[2]!==o||e[3]!==r?(i=(0,p.jsx)("p",{className:"font-mono text-xs text-muted-foreground","data-testid":r,children:o}),e[2]=o,e[3]=r,e[4]=i):i=e[4],i}let n;e[5]!==a?(n=(0,p.jsx)(Je,{schema:a}),e[5]=a,e[6]=n):n=e[6];let s;return e[7]!==n||e[8]!==r?(s=(0,p.jsx)("div",{className:"text-xs","data-testid":r,children:n}),e[7]=n,e[8]=r,e[9]=s):s=e[9],s},"G"),ft=["curl","javascript","lunora"],ht={lunora:"Lunora",curl:"cURL",javascript:"JavaScript"},gt=u(t=>`api.${t.replaceAll(/[/:]/g,".")}`,"Re"),xt=u(t=>{let e=Z(t.argsSchema)??{};return t.functionPath===void 0?e:{args:e,functionPath:t.functionPath}},"je"),bt=u((t,e,a)=>{let r=`${a}${e.httpPath}`,n=JSON.stringify(xt(e),void 0,2),s=JSON.stringify(Z(e.argsSchema)??{},void 0,2);switch(t){case"curl":{let o=e.method!=="GET"&&e.method!=="HEAD",i=[`curl -X ${e.method} ${JSON.stringify(r)}`];return o&&i.push(' -H "Content-Type: application/json"',` -d '${n}'`),i.join(` \\
3
3
  `)}case"lunora":return e.functionPath===void 0?`await fetch(${JSON.stringify(e.httpPath)}, { method: ${JSON.stringify(e.method)} });`:`import { useLunora } from "@lunora/react";
4
4
  import { api } from "./_generated/api";
@@ -1 +1 @@
1
- import{a as H}from"./chunk-66UGPQVC.js";import{b as x}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{b as z}from"./chunk-5G2MAI3G.js";import{f as O}from"./chunk-SZSHO6RE.js";import"./chunk-FSRSK4LY.js";import"./chunk-CEA2QYAI.js";import{a as _}from"./chunk-FKVZRPV5.js";import{a as q,b as B,c as E,d as S,e as i,f as s}from"./chunk-HEAQVSNS.js";import{a as A,e as L}from"./chunk-WUWBZPUK.js";import{d as W}from"./chunk-FODLDLE2.js";import{a as R,d as M,f as $,g as D}from"./chunk-YKXDMIHQ.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,refetch: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-66UGPQVC.js";import{b as x}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{b as z}from"./chunk-FI3UY4QJ.js";import{f as O}from"./chunk-PYI2MI4Q.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as _}from"./chunk-FKVZRPV5.js";import{a as q,b as B,c as E,d as S,e as i,f as s}from"./chunk-HEAQVSNS.js";import{a as A,e as L}from"./chunk-WUWBZPUK.js";import{d as W}from"./chunk-FODLDLE2.js";import{a as R,d as M,f as $,g as D}from"./chunk-YKXDMIHQ.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,refetch: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 +1 @@
1
- import{a as s}from"./chunk-5G2MAI3G.js";import{a as n}from"./chunk-YKXDMIHQ.js";var b="__lunora_admin__:",g=new Set(["action","mutation","query"]),c=Symbol("lunora.operationSeq"),_=n(t=>{if(typeof t!="object"||t===null)return;let e=t[c];return typeof e=="number"?e:void 0},"g"),d=n((t,e)=>{if(!(typeof t!="object"||t===null||!Object.isExtensible(t)))try{Object.defineProperty(t,c,{configurable:!0,enumerable:!1,value:e,writable:!0})}catch{}},"h"),m=n(t=>{if(typeof t!="object"||t===null)return;let e=t.__lunoraRef;return typeof e=="string"&&e.startsWith(b)?e:void 0},"p"),h=n(t=>{if(typeof t!="object"||t===null)return"";let{shardKey:e}=t;return typeof e=="string"?e:""},"O"),w=n(t=>new Proxy(t,{get(e,u,y){let i=Reflect.get(e,u,y);if(typeof i!="function"||typeof u!="string"||!g.has(u))return typeof i=="function"?i.bind(e):i;let f=i;return async(...o)=>{let l=m(o[0]);if(l===void 0)return f.apply(e,o);let p=typeof o[1]=="object"&&o[1]!==null?o[1]:{},a=s.start(l,p,h(o[2]));try{let r=await f.apply(e,o);return s.settle(a,{result:r}),r}catch(r){throw s.settle(a,{error:r instanceof Error?r.message:String(r)}),d(r,a),r}}}}),"E");export{_ as a,w as b};
1
+ import{a as s}from"./chunk-FI3UY4QJ.js";import{a as n}from"./chunk-YKXDMIHQ.js";var b="__lunora_admin__:",g=new Set(["action","mutation","query"]),c=Symbol("lunora.operationSeq"),_=n(t=>{if(typeof t!="object"||t===null)return;let e=t[c];return typeof e=="number"?e:void 0},"g"),d=n((t,e)=>{if(!(typeof t!="object"||t===null||!Object.isExtensible(t)))try{Object.defineProperty(t,c,{configurable:!0,enumerable:!1,value:e,writable:!0})}catch{}},"h"),m=n(t=>{if(typeof t!="object"||t===null)return;let e=t.__lunoraRef;return typeof e=="string"&&e.startsWith(b)?e:void 0},"p"),h=n(t=>{if(typeof t!="object"||t===null)return"";let{shardKey:e}=t;return typeof e=="string"?e:""},"O"),w=n(t=>new Proxy(t,{get(e,u,y){let i=Reflect.get(e,u,y);if(typeof i!="function"||typeof u!="string"||!g.has(u))return typeof i=="function"?i.bind(e):i;let f=i;return async(...o)=>{let l=m(o[0]);if(l===void 0)return f.apply(e,o);let p=typeof o[1]=="object"&&o[1]!==null?o[1]:{},a=s.start(l,p,h(o[2]));try{let r=await f.apply(e,o);return s.settle(a,{result:r}),r}catch(r){throw s.settle(a,{error:r instanceof Error?r.message:String(r)}),d(r,a),r}}}}),"E");export{_ as a,w as b};
@@ -1 +1 @@
1
- import{m as h,n as v}from"./chunk-QAIEAIIE.js";import{a as u,d as p,f as x,g as y,i as g}from"./chunk-YKXDMIHQ.js";var b=p(x(),1);var n=p(y(),1);var w={value:{colors:{dark:["var(--foreground)"],light:["var(--foreground)"]},label:""}},j=u(i=>{let a=(0,b.c)(12),{ariaLabel:c,className:m,series:l,testId:d}=i;if(l.length<2)return null;let t;a[0]!==l?(t=l.slice(-40).map(N),a[0]=l,a[1]=t):t=a[1];let f=t,e;a[2]!==m?(e=g("h-6 w-[120px]",m),a[2]=m,a[3]=e):e=a[3];let o;a[4]===Symbol.for("react.memo_cache_sentinel")?(o=(0,n.jsx)(v,{dataKey:"value"}),a[4]=o):o=a[4];let r;a[5]!==f?(r=(0,n.jsx)(h,{animationType:"none",barCategoryGap:1,className:"h-full w-full",config:w,data:f,children:o}),a[5]=f,a[6]=r):r=a[6];let s;return a[7]!==c||a[8]!==e||a[9]!==r||a[10]!==d?(s=(0,n.jsx)("div",{"aria-label":c,className:e,"data-testid":d,role:"img",children:r}),a[7]=c,a[8]=e,a[9]=r,a[10]=d,a[11]=s):s=a[11],s},"w");function N(i,a){return{index:a,value:i}}u(N,"b");export{j as a};
1
+ import{m as h,n as v}from"./chunk-P5RUFDVX.js";import{a as u,d as p,f as x,g as y,i as g}from"./chunk-YKXDMIHQ.js";var b=p(x(),1);var n=p(y(),1);var w={value:{colors:{dark:["var(--foreground)"],light:["var(--foreground)"]},label:""}},j=u(i=>{let a=(0,b.c)(12),{ariaLabel:c,className:m,series:l,testId:d}=i;if(l.length<2)return null;let t;a[0]!==l?(t=l.slice(-40).map(N),a[0]=l,a[1]=t):t=a[1];let f=t,e;a[2]!==m?(e=g("h-6 w-[120px]",m),a[2]=m,a[3]=e):e=a[3];let o;a[4]===Symbol.for("react.memo_cache_sentinel")?(o=(0,n.jsx)(v,{dataKey:"value"}),a[4]=o):o=a[4];let r;a[5]!==f?(r=(0,n.jsx)(h,{animationType:"none",barCategoryGap:1,className:"h-full w-full",config:w,data:f,children:o}),a[5]=f,a[6]=r):r=a[6];let s;return a[7]!==c||a[8]!==e||a[9]!==r||a[10]!==d?(s=(0,n.jsx)("div",{"aria-label":c,className:e,"data-testid":d,role:"img",children:r}),a[7]=c,a[8]=e,a[9]=r,a[10]=d,a[11]=s):s=a[11],s},"w");function N(i,a){return{index:a,value:i}}u(N,"b");export{j as a};
@@ -1 +1 @@
1
- import{W as k}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as q}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as j}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as U}from"./chunk-UD47ZOIF.js";import"./chunk-ULIQFBZU.js";import"./chunk-AMPB3H6K.js";import"./chunk-35DM4JJG.js";import{a as R}from"./chunk-4ZEL6BYL.js";import{c as P}from"./chunk-5G2MAI3G.js";import"./chunk-SZSHO6RE.js";import"./chunk-FSRSK4LY.js";import"./chunk-CEA2QYAI.js";import{a as M}from"./chunk-FKVZRPV5.js";import{a as G,b as H,c as J,d as B,e as x,f as N}from"./chunk-HEAQVSNS.js";import{a as z,e as D}from"./chunk-WUWBZPUK.js";import{d as F,r as O}from"./chunk-FODLDLE2.js";import{a as A,d as T,e as $,f as X,g as Y}from"./chunk-YKXDMIHQ.js";var K=T(X(),1),Q=T($(),1);var t=T(Y(),1);var de=A(()=>{let e=(0,K.c)(39),a=F(),[s,V]=(0,Q.useState)(""),y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={},e[0]=y):y=e[0];let{data:C,error:l,errorSource:S,isLoading:E,refetch:_}=P(R.getAuthAuditLog,y),I;if(e[1]!==C?.entries||e[2]!==s){let r=C?.entries??[],v=s.trim().toLowerCase();I=v===""?r:r.filter(w=>w.event.toLowerCase().includes(v)||(w.actorId??"").toLowerCase().includes(v)||(w.actorEmail??"").toLowerCase().includes(v)||(w.ip??"").toLowerCase().includes(v)||w.outcome.toLowerCase().includes(v)),e[1]=C?.entries,e[2]=s,e[3]=I}else I=e[3];let o=I,L;e[4]===Symbol.for("react.memo_cache_sentinel")?(L=A(r=>{V(r.target.value)},"I"),e[4]=L):L=e[4];let W=L,i;e[5]!==a?(i=a("Filter security events"),e[5]=a,e[6]=i):i=e[6];let n;e[7]!==a?(n=a("filter event, actor, IP"),e[7]=a,e[8]=n):n=e[8];let c;e[9]!==s||e[10]!==i||e[11]!==n?(c=(0,t.jsx)(k,{"aria-label":i,className:"h-8 w-56","data-testid":"aa-search",onChange:W,placeholder:n,value:s}),e[9]=s,e[10]=i,e[11]=n,e[12]=c):c=e[12];let d;e[13]!==_?(d=A(()=>{_()},"m"),e[13]=_,e[14]=d):d=e[14];let m;e[15]!==a?(m=a("Refresh"),e[15]=a,e[16]=m):m=e[16];let u;e[17]!==d||e[18]!==m?(u=(0,t.jsx)(q,{"data-testid":"aa-refresh",onClick:d,size:"xs",type:"button",variant:"ghost",children:m}),e[17]=d,e[18]=m,e[19]=u):u=e[19];let h;e[20]!==c||e[21]!==u?(h=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,u]}),e[20]=c,e[21]=u,e[22]=h):h=e[22];let f;e[23]!==l||e[24]!==S?(f=l!==null&&(0,t.jsx)(U,{error:S,testId:"aa-error"}),e[23]=l,e[24]=S,e[25]=f):f=e[25];let p;e[26]!==l||e[27]!==o.length||e[28]!==E||e[29]!==a?(p=l===null&&!E&&o.length===0&&(0,t.jsx)(M,{description:a("Authentication and security events are recorded here."),testId:"aa-empty",title:a("No security events.")}),e[26]=l,e[27]=o.length,e[28]=E,e[29]=a,e[30]=p):p=e[30];let g;e[31]!==o||e[32]!==a?(g=o.length>0&&(0,t.jsx)(z,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"max-h-[30rem] overflow-auto px-0",children:(0,t.jsxs)(G,{"data-testid":"aa-table",children:[(0,t.jsx)(H,{children:(0,t.jsxs)(B,{children:[(0,t.jsx)(x,{children:a("time")}),(0,t.jsx)(x,{children:a("event")}),(0,t.jsx)(x,{children:a("actor")}),(0,t.jsx)(x,{children:a("ip / user agent")}),(0,t.jsx)(x,{children:a("outcome")})]})}),(0,t.jsx)(J,{children:o.map(r=>(0,t.jsxs)(B,{"data-testid":"aa-row",children:[(0,t.jsx)(N,{className:"text-muted-foreground tabular-nums",children:O(r.ts,"\u2014")}),(0,t.jsx)(N,{children:(0,t.jsx)(j,{variant:"secondary",children:r.event})}),(0,t.jsx)(N,{className:"max-w-[24ch] truncate font-mono text-xs",title:r.actorId??void 0,children:r.actorEmail??r.actorId??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,t.jsxs)(N,{className:"max-w-[28ch] truncate text-xs text-muted-foreground",title:r.userAgent??void 0,children:[r.ip??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),r.userAgent!==void 0&&(0,t.jsxs)("span",{className:"ml-1 opacity-70",children:["\xB7 ",r.userAgent]})]}),(0,t.jsx)(N,{children:(0,t.jsx)(j,{variant:r.outcome==="failure"?"destructive":"outline",children:a(r.outcome)})})]},r.seq))})]})})}),e[31]=o,e[32]=a,e[33]=g):g=e[33];let b;return e[34]!==f||e[35]!==p||e[36]!==g||e[37]!==h?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-auth-audit",children:[h,f,p,g]}),e[34]=f,e[35]=p,e[36]=g,e[37]=h,e[38]=b):b=e[38],b},"ne");export{de as default};
1
+ import{W as k}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as q}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as j}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as U}from"./chunk-6FTYD55M.js";import"./chunk-ULIQFBZU.js";import"./chunk-YOKBLIIN.js";import"./chunk-35DM4JJG.js";import{a as R}from"./chunk-4ZEL6BYL.js";import{c as P}from"./chunk-FI3UY4QJ.js";import"./chunk-PYI2MI4Q.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as M}from"./chunk-FKVZRPV5.js";import{a as G,b as H,c as J,d as B,e as x,f as N}from"./chunk-HEAQVSNS.js";import{a as z,e as D}from"./chunk-WUWBZPUK.js";import{d as F,r as O}from"./chunk-FODLDLE2.js";import{a as A,d as T,e as $,f as X,g as Y}from"./chunk-YKXDMIHQ.js";var K=T(X(),1),Q=T($(),1);var t=T(Y(),1);var de=A(()=>{let e=(0,K.c)(39),a=F(),[s,V]=(0,Q.useState)(""),y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={},e[0]=y):y=e[0];let{data:C,error:l,errorSource:S,isLoading:E,refetch:_}=P(R.getAuthAuditLog,y),I;if(e[1]!==C?.entries||e[2]!==s){let r=C?.entries??[],v=s.trim().toLowerCase();I=v===""?r:r.filter(w=>w.event.toLowerCase().includes(v)||(w.actorId??"").toLowerCase().includes(v)||(w.actorEmail??"").toLowerCase().includes(v)||(w.ip??"").toLowerCase().includes(v)||w.outcome.toLowerCase().includes(v)),e[1]=C?.entries,e[2]=s,e[3]=I}else I=e[3];let o=I,L;e[4]===Symbol.for("react.memo_cache_sentinel")?(L=A(r=>{V(r.target.value)},"I"),e[4]=L):L=e[4];let W=L,i;e[5]!==a?(i=a("Filter security events"),e[5]=a,e[6]=i):i=e[6];let n;e[7]!==a?(n=a("filter event, actor, IP"),e[7]=a,e[8]=n):n=e[8];let c;e[9]!==s||e[10]!==i||e[11]!==n?(c=(0,t.jsx)(k,{"aria-label":i,className:"h-8 w-56","data-testid":"aa-search",onChange:W,placeholder:n,value:s}),e[9]=s,e[10]=i,e[11]=n,e[12]=c):c=e[12];let d;e[13]!==_?(d=A(()=>{_()},"m"),e[13]=_,e[14]=d):d=e[14];let m;e[15]!==a?(m=a("Refresh"),e[15]=a,e[16]=m):m=e[16];let u;e[17]!==d||e[18]!==m?(u=(0,t.jsx)(q,{"data-testid":"aa-refresh",onClick:d,size:"xs",type:"button",variant:"ghost",children:m}),e[17]=d,e[18]=m,e[19]=u):u=e[19];let h;e[20]!==c||e[21]!==u?(h=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,u]}),e[20]=c,e[21]=u,e[22]=h):h=e[22];let f;e[23]!==l||e[24]!==S?(f=l!==null&&(0,t.jsx)(U,{error:S,testId:"aa-error"}),e[23]=l,e[24]=S,e[25]=f):f=e[25];let p;e[26]!==l||e[27]!==o.length||e[28]!==E||e[29]!==a?(p=l===null&&!E&&o.length===0&&(0,t.jsx)(M,{description:a("Authentication and security events are recorded here."),testId:"aa-empty",title:a("No security events.")}),e[26]=l,e[27]=o.length,e[28]=E,e[29]=a,e[30]=p):p=e[30];let g;e[31]!==o||e[32]!==a?(g=o.length>0&&(0,t.jsx)(z,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"max-h-[30rem] overflow-auto px-0",children:(0,t.jsxs)(G,{"data-testid":"aa-table",children:[(0,t.jsx)(H,{children:(0,t.jsxs)(B,{children:[(0,t.jsx)(x,{children:a("time")}),(0,t.jsx)(x,{children:a("event")}),(0,t.jsx)(x,{children:a("actor")}),(0,t.jsx)(x,{children:a("ip / user agent")}),(0,t.jsx)(x,{children:a("outcome")})]})}),(0,t.jsx)(J,{children:o.map(r=>(0,t.jsxs)(B,{"data-testid":"aa-row",children:[(0,t.jsx)(N,{className:"text-muted-foreground tabular-nums",children:O(r.ts,"\u2014")}),(0,t.jsx)(N,{children:(0,t.jsx)(j,{variant:"secondary",children:r.event})}),(0,t.jsx)(N,{className:"max-w-[24ch] truncate font-mono text-xs",title:r.actorId??void 0,children:r.actorEmail??r.actorId??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,t.jsxs)(N,{className:"max-w-[28ch] truncate text-xs text-muted-foreground",title:r.userAgent??void 0,children:[r.ip??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),r.userAgent!==void 0&&(0,t.jsxs)("span",{className:"ml-1 opacity-70",children:["\xB7 ",r.userAgent]})]}),(0,t.jsx)(N,{children:(0,t.jsx)(j,{variant:r.outcome==="failure"?"destructive":"outline",children:a(r.outcome)})})]},r.seq))})]})})}),e[31]=o,e[32]=a,e[33]=g):g=e[33];let b;return e[34]!==f||e[35]!==p||e[36]!==g||e[37]!==h?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-auth-audit",children:[h,f,p,g]}),e[34]=f,e[35]=p,e[36]=g,e[37]=h,e[38]=b):b=e[38],b},"ne");export{de as default};
@@ -1 +1 @@
1
- import{d as k}from"./chunk-YOB2X3FZ.js";import{a as j}from"./chunk-66UGPQVC.js";import{a as _}from"./chunk-VWLX4CH4.js";import"./chunk-K7AJEMKE.js";import"./chunk-6D6Z2KXU.js";import"./chunk-Y6CXU7T4.js";import"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as g}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as E}from"./chunk-UD47ZOIF.js";import"./chunk-ULIQFBZU.js";import"./chunk-AMPB3H6K.js";import"./chunk-35DM4JJG.js";import{a as y}from"./chunk-4ZEL6BYL.js";import{c as b}from"./chunk-5G2MAI3G.js";import"./chunk-SZSHO6RE.js";import"./chunk-FSRSK4LY.js";import"./chunk-CEA2QYAI.js";import{a as w}from"./chunk-FKVZRPV5.js";import{a as I,b as R,c as A,d as v,e as l,f as n}from"./chunk-HEAQVSNS.js";import{a as f,e as N}from"./chunk-WUWBZPUK.js";import{d as T,r as S}from"./chunk-FODLDLE2.js";import{a as c,d as G,g as H}from"./chunk-YKXDMIHQ.js";var e=G(H(),1);var Q=["subscriptions","events"],U={},B=new Set(["active","trialing"]),V=new Set(["past_due","unpaid"]),s=c((a,t)=>{if(a[t]!==void 0)return a[t];let m=a.__doc__;return typeof m=="string"?k(m)?.[t]:void 0},"n"),i=c(a=>typeof a=="string"?a:typeof a=="number"||typeof a=="bigint"||typeof a=="boolean"?String(a):"","a"),q=c(a=>B.has(a)?"default":V.has(a)?"destructive":"outline","G"),se=c(({limit:a=100})=>{let t=T(),m=_(),{data:x}=b(y.listTables,U,{live:!0}),D=x!==void 0,C=Array.isArray(x)&&Q.every(r=>x.some(d=>d.name===r)),p=m.payments&&C,o=b(y.readTablePage,{filters:[],limit:a,offset:0,orderBy:[],search:"",table:"subscriptions"},{enabled:p}),h=b(y.readTablePage,{filters:[],limit:25,offset:0,orderBy:[],search:"",table:"events"},{enabled:p});j(()=>{p&&(o.refetch(),h.refetch())},!0);let u=o.data?.rows??[],O=h.data?.rows??[],F=o.error??h.error,L=o.error===null?h.errorSource:o.errorSource,P=u.filter(r=>B.has(i(s(r,"state")))).length,M=O.toSorted((r,d)=>Number(s(d,"processedAt")??0)-Number(s(r,"processedAt")??0));return D&&!p?(0,e.jsx)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:(0,e.jsx)(w,{description:t("No @lunora/payment tables found in this deployment. Declare the store tables (subscriptions, events, \u2026) in 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)(f,{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:P}),(0,e.jsx)(g,{variant:"default",children:t("{count} active",{count:P})})]})]}),(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:u.length})})]})}),F===null?void 0:(0,e.jsx)(E,{error:L}),u.length===0&&!o.isLoading?(0,e.jsx)(w,{testId:"payments-empty",title:t("No subscriptions yet")}):(0,e.jsx)(f,{className:"overflow-hidden py-0",children:(0,e.jsx)(N,{className:"px-0",children:(0,e.jsxs)(I,{children:[(0,e.jsx)(R,{children:(0,e.jsxs)(v,{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)(A,{children:u.map(r=>{let d=i(s(r,"state"));return(0,e.jsxs)(v,{"data-testid":"payment-subscription-row",children:[(0,e.jsx)(n,{children:i(s(r,"provider"))}),(0,e.jsx)(n,{children:i(s(r,"referenceId"))}),(0,e.jsx)(n,{children:i(s(r,"priceId"))}),(0,e.jsx)(n,{children:(0,e.jsx)(g,{variant:q(d),children:d})}),(0,e.jsx)(n,{children:S(s(r,"currentPeriodEnd"))})]},i(s(r,"providerSubscriptionId")))})})]})})}),(0,e.jsxs)(f,{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)(N,{className:"px-0",children:(0,e.jsx)(I,{children:(0,e.jsx)(A,{children:M.map(r=>(0,e.jsxs)(v,{"data-testid":"payment-event-row",children:[(0,e.jsx)(n,{children:i(s(r,"provider"))}),(0,e.jsx)(n,{className:"font-medium",children:i(s(r,"type"))}),(0,e.jsx)(n,{className:"text-muted-foreground",children:i(s(r,"providerEventId"))}),(0,e.jsx)(n,{children:S(s(r,"processedAt"))})]},i(s(r,"providerEventId"))))})})})]})]})},"se");export{se as PaymentsPanel};
1
+ import{d as k}from"./chunk-YOB2X3FZ.js";import{a as j}from"./chunk-66UGPQVC.js";import{a as _}from"./chunk-62IKYVD3.js";import"./chunk-K7AJEMKE.js";import"./chunk-6D6Z2KXU.js";import"./chunk-Y6CXU7T4.js";import"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as g}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as E}from"./chunk-6FTYD55M.js";import"./chunk-ULIQFBZU.js";import"./chunk-YOKBLIIN.js";import"./chunk-35DM4JJG.js";import{a as y}from"./chunk-4ZEL6BYL.js";import{c as b}from"./chunk-FI3UY4QJ.js";import"./chunk-PYI2MI4Q.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as w}from"./chunk-FKVZRPV5.js";import{a as I,b as R,c as A,d as v,e as l,f as n}from"./chunk-HEAQVSNS.js";import{a as f,e as N}from"./chunk-WUWBZPUK.js";import{d as T,r as S}from"./chunk-FODLDLE2.js";import{a as c,d as G,g as H}from"./chunk-YKXDMIHQ.js";var e=G(H(),1);var Q=["subscriptions","events"],U={},B=new Set(["active","trialing"]),V=new Set(["past_due","unpaid"]),s=c((a,t)=>{if(a[t]!==void 0)return a[t];let m=a.__doc__;return typeof m=="string"?k(m)?.[t]:void 0},"n"),i=c(a=>typeof a=="string"?a:typeof a=="number"||typeof a=="bigint"||typeof a=="boolean"?String(a):"","a"),q=c(a=>B.has(a)?"default":V.has(a)?"destructive":"outline","G"),se=c(({limit:a=100})=>{let t=T(),m=_(),{data:x}=b(y.listTables,U,{live:!0}),D=x!==void 0,C=Array.isArray(x)&&Q.every(r=>x.some(d=>d.name===r)),p=m.payments&&C,o=b(y.readTablePage,{filters:[],limit:a,offset:0,orderBy:[],search:"",table:"subscriptions"},{enabled:p}),h=b(y.readTablePage,{filters:[],limit:25,offset:0,orderBy:[],search:"",table:"events"},{enabled:p});j(()=>{p&&(o.refetch(),h.refetch())},!0);let u=o.data?.rows??[],O=h.data?.rows??[],F=o.error??h.error,L=o.error===null?h.errorSource:o.errorSource,P=u.filter(r=>B.has(i(s(r,"state")))).length,M=O.toSorted((r,d)=>Number(s(d,"processedAt")??0)-Number(s(r,"processedAt")??0));return D&&!p?(0,e.jsx)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:(0,e.jsx)(w,{description:t("No @lunora/payment tables found in this deployment. Declare the store tables (subscriptions, events, \u2026) in 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)(f,{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:P}),(0,e.jsx)(g,{variant:"default",children:t("{count} active",{count:P})})]})]}),(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:u.length})})]})}),F===null?void 0:(0,e.jsx)(E,{error:L}),u.length===0&&!o.isLoading?(0,e.jsx)(w,{testId:"payments-empty",title:t("No subscriptions yet")}):(0,e.jsx)(f,{className:"overflow-hidden py-0",children:(0,e.jsx)(N,{className:"px-0",children:(0,e.jsxs)(I,{children:[(0,e.jsx)(R,{children:(0,e.jsxs)(v,{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)(A,{children:u.map(r=>{let d=i(s(r,"state"));return(0,e.jsxs)(v,{"data-testid":"payment-subscription-row",children:[(0,e.jsx)(n,{children:i(s(r,"provider"))}),(0,e.jsx)(n,{children:i(s(r,"referenceId"))}),(0,e.jsx)(n,{children:i(s(r,"priceId"))}),(0,e.jsx)(n,{children:(0,e.jsx)(g,{variant:q(d),children:d})}),(0,e.jsx)(n,{children:S(s(r,"currentPeriodEnd"))})]},i(s(r,"providerSubscriptionId")))})})]})})}),(0,e.jsxs)(f,{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)(N,{className:"px-0",children:(0,e.jsx)(I,{children:(0,e.jsx)(A,{children:M.map(r=>(0,e.jsxs)(v,{"data-testid":"payment-event-row",children:[(0,e.jsx)(n,{children:i(s(r,"provider"))}),(0,e.jsx)(n,{className:"font-medium",children:i(s(r,"type"))}),(0,e.jsx)(n,{className:"text-muted-foreground",children:i(s(r,"providerEventId"))}),(0,e.jsx)(n,{children:S(s(r,"processedAt"))})]},i(s(r,"providerEventId"))))})})})]})]})},"se");export{se as PaymentsPanel};
@@ -1 +1 @@
1
- import{b as g}from"./chunk-OGEHSNF7.js";import"./chunk-UD47ZOIF.js";import"./chunk-ULIQFBZU.js";import"./chunk-AMPB3H6K.js";import"./chunk-35DM4JJG.js";import{a as f}from"./chunk-4ZEL6BYL.js";import{c as m}from"./chunk-5G2MAI3G.js";import"./chunk-SZSHO6RE.js";import"./chunk-FSRSK4LY.js";import"./chunk-CEA2QYAI.js";import"./chunk-HEAQVSNS.js";import"./chunk-WUWBZPUK.js";import{d as p}from"./chunk-FODLDLE2.js";import{a as r,d as h,f as S,g as A}from"./chunk-YKXDMIHQ.js";var R=h(S(),1);var k=h(A(),1);var _=r((e,s)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("User subscriptions are ungated")})[s.kind],"k"),w=r(e=>Array.isArray(e.findings)?e.findings:[],"g"),b=r(e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],"S"),E=r((e,s)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters \u2014 use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:s.detail?.length,min:s.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed \u2014 browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: anyone who can reach the worker can open a socket and run ordinary user subscriptions. Admin subscriptions are unaffected \u2014 they need the admin token. Set it if subscribers should present a shared credential.")})[s.kind],"A"),O=r(()=>{let e=(0,R.c)(8),s=p(),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];let{data:a,error:d,errorSource:c}=m(f.getSecurityAudit,i),n;if(e[1]!==a||e[2]!==s){let u=a===void 0?null:w(a);n=u===null?null:u.map(t=>({description:E(s,t),entity:b(t),issueType:_(s,t),key:t.kind,level:t.level})),e[1]=a,e[2]=s,e[3]=n}else n=e[3];let l=n,o;return e[4]!==d||e[5]!==c||e[6]!==l?(o=(0,k.jsx)(g,{error:d,errorSource:c,rows:l,testId:"lunora-security-advisor"}),e[4]=d,e[5]=c,e[6]=l,e[7]=o):o=e[7],o},"T");export{O as default};
1
+ import{b as g}from"./chunk-UDXIBUS6.js";import"./chunk-6FTYD55M.js";import"./chunk-ULIQFBZU.js";import"./chunk-YOKBLIIN.js";import"./chunk-35DM4JJG.js";import{a as f}from"./chunk-4ZEL6BYL.js";import{c as m}from"./chunk-FI3UY4QJ.js";import"./chunk-PYI2MI4Q.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import"./chunk-HEAQVSNS.js";import"./chunk-WUWBZPUK.js";import{d as p}from"./chunk-FODLDLE2.js";import{a as r,d as h,f as S,g as A}from"./chunk-YKXDMIHQ.js";var R=h(S(),1);var k=h(A(),1);var _=r((e,s)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("User subscriptions are ungated")})[s.kind],"k"),w=r(e=>Array.isArray(e.findings)?e.findings:[],"g"),b=r(e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],"S"),E=r((e,s)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters \u2014 use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:s.detail?.length,min:s.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed \u2014 browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: anyone who can reach the worker can open a socket and run ordinary user subscriptions. Admin subscriptions are unaffected \u2014 they need the admin token. Set it if subscribers should present a shared credential.")})[s.kind],"A"),O=r(()=>{let e=(0,R.c)(8),s=p(),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];let{data:a,error:d,errorSource:c}=m(f.getSecurityAudit,i),n;if(e[1]!==a||e[2]!==s){let u=a===void 0?null:w(a);n=u===null?null:u.map(t=>({description:E(s,t),entity:b(t),issueType:_(s,t),key:t.kind,level:t.level})),e[1]=a,e[2]=s,e[3]=n}else n=e[3];let l=n,o;return e[4]!==d||e[5]!==c||e[6]!==l?(o=(0,k.jsx)(g,{error:d,errorSource:c,rows:l,testId:"lunora-security-advisor"}),e[4]=d,e[5]=c,e[6]=l,e[7]=o):o=e[7],o},"T");export{O as default};