@lunora/studio 1.0.0-alpha.331 → 1.0.0-alpha.333

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 (67) hide show
  1. package/dist/index.mjs +1 -1
  2. package/dist/mount.mjs +1 -1
  3. package/dist/packem_shared/{StudioApp-BG3kyQ-I.mjs → StudioApp-CUxEVr__.mjs} +1 -1
  4. package/dist/standalone/{chunk-EFXC3EHZ.js → chunk-2CDRWAL6.js} +1 -1
  5. package/dist/standalone/{chunk-F4HMMGVL.js → chunk-2VIGYW3S.js} +1 -1
  6. package/dist/standalone/{chunk-RNVXXJBN.js → chunk-2YEDTLGD.js} +1 -1
  7. package/dist/standalone/{chunk-2GYGUDJS.js → chunk-357O3FBE.js} +1 -1
  8. package/dist/standalone/{chunk-QMECH2OK.js → chunk-3TL6EMCG.js} +1 -1
  9. package/dist/standalone/{chunk-J2OLAMJR.js → chunk-3ZVTL2VM.js} +1 -1
  10. package/dist/standalone/{chunk-J4BVPEXN.js → chunk-4RDTHNCM.js} +1 -1
  11. package/dist/standalone/{chunk-KDF7XOVW.js → chunk-544PMJL6.js} +1 -1
  12. package/dist/standalone/{chunk-NSNRU3CH.js → chunk-5V4REVOK.js} +1 -1
  13. package/dist/standalone/{chunk-5ZCMUHYK.js → chunk-6JMKSAOS.js} +1 -1
  14. package/dist/standalone/{chunk-U2ACS5ID.js → chunk-6M5R5VXY.js} +1 -1
  15. package/dist/standalone/{chunk-JKOBTLQU.js → chunk-6T6JFHWU.js} +1 -1
  16. package/dist/standalone/{chunk-CHF23IX6.js → chunk-7NGFZ7OK.js} +1 -1
  17. package/dist/standalone/{chunk-3O4QTTSY.js → chunk-CMAPNVCT.js} +1 -1
  18. package/dist/standalone/{chunk-M45NNDDU.js → chunk-CWVYS5LB.js} +1 -1
  19. package/dist/standalone/{chunk-AH56E26M.js → chunk-DCD562KJ.js} +1 -1
  20. package/dist/standalone/{chunk-VFAP6A6G.js → chunk-DMEGDUGQ.js} +1 -1
  21. package/dist/standalone/{chunk-B475OGG2.js → chunk-DVCBS7Z6.js} +1 -1
  22. package/dist/standalone/{chunk-FZJY5QLO.js → chunk-ESQNSJEK.js} +1 -1
  23. package/dist/standalone/{chunk-K73JDHTM.js → chunk-F2JMVU2F.js} +1 -1
  24. package/dist/standalone/{chunk-22MSJQDH.js → chunk-GBAQ5M7Y.js} +1 -1
  25. package/dist/standalone/{chunk-XVE6WFB4.js → chunk-HNMSVHPM.js} +1 -1
  26. package/dist/standalone/{chunk-KARIZQ65.js → chunk-I5PK6SLS.js} +1 -1
  27. package/dist/standalone/{chunk-BDAZK3QX.js → chunk-I5U5LU6L.js} +1 -1
  28. package/dist/standalone/{chunk-5QXC7TAH.js → chunk-I6VQ56RO.js} +1 -1
  29. package/dist/standalone/{chunk-NBYAGXMZ.js → chunk-IHAUHNTM.js} +1 -1
  30. package/dist/standalone/{chunk-2KXU4RFA.js → chunk-IWF4IWJT.js} +1 -1
  31. package/dist/standalone/{chunk-ENRGUWYC.js → chunk-JPEXFCD7.js} +1 -1
  32. package/dist/standalone/{chunk-4DPZVEBK.js → chunk-KLDGZ5FU.js} +1 -1
  33. package/dist/standalone/{chunk-JYPEPARL.js → chunk-KNYZMZPY.js} +1 -1
  34. package/dist/standalone/chunk-KPRNLQKZ.js +7 -0
  35. package/dist/standalone/{chunk-XDWPHAV6.js → chunk-KQ7RUNQV.js} +1 -1
  36. package/dist/standalone/{chunk-HXO6YGKL.js → chunk-KTJR54TW.js} +1 -1
  37. package/dist/standalone/{chunk-VESZYIB4.js → chunk-KU2V3NDJ.js} +1 -1
  38. package/dist/standalone/{chunk-G3ZNPPY3.js → chunk-L5ZKGZHX.js} +1 -1
  39. package/dist/standalone/{chunk-B3SX5SBI.js → chunk-LSNLFUZ6.js} +1 -1
  40. package/dist/standalone/{chunk-4NSXTCPY.js → chunk-MBW5C5GU.js} +1 -1
  41. package/dist/standalone/{chunk-BOGUQHYU.js → chunk-NGPK5RSU.js} +1 -1
  42. package/dist/standalone/{chunk-LVCMJJQO.js → chunk-NQNI4E56.js} +1 -1
  43. package/dist/standalone/{chunk-TBEEPT5P.js → chunk-OOQHMMNK.js} +1 -1
  44. package/dist/standalone/{chunk-TRUA26Q4.js → chunk-PPXPRPMU.js} +1 -1
  45. package/dist/standalone/{chunk-34HRTSIP.js → chunk-PRQKA5BT.js} +1 -1
  46. package/dist/standalone/{chunk-KC67JOVJ.js → chunk-QA5RUU7W.js} +1 -1
  47. package/dist/standalone/{chunk-ZBHXISOD.js → chunk-QTDX7WSP.js} +1 -1
  48. package/dist/standalone/{chunk-MMCREWVL.js → chunk-QYPMUUYF.js} +1 -1
  49. package/dist/standalone/{chunk-4ZPDCXIA.js → chunk-R7SRERCX.js} +1 -1
  50. package/dist/standalone/{chunk-CLXX5RVY.js → chunk-RGUL4AQZ.js} +1 -1
  51. package/dist/standalone/{chunk-SHY25BCU.js → chunk-TNF67D54.js} +1 -1
  52. package/dist/standalone/{chunk-5XSZGYSM.js → chunk-UHCFEXE5.js} +1 -1
  53. package/dist/standalone/{chunk-WDGITBC6.js → chunk-UJTSGF6S.js} +1 -1
  54. package/dist/standalone/{chunk-QMENQICE.js → chunk-UUESQ5A2.js} +1 -1
  55. package/dist/standalone/{chunk-T6XTWQC2.js → chunk-V5JA533L.js} +1 -1
  56. package/dist/standalone/{chunk-ZVXBXVS3.js → chunk-V6IC22GP.js} +1 -1
  57. package/dist/standalone/{chunk-YCQP3TYK.js → chunk-VKSSPTTK.js} +1 -1
  58. package/dist/standalone/{chunk-ZWLIXZWR.js → chunk-WDWGLJNK.js} +1 -1
  59. package/dist/standalone/{chunk-GPNP4QSZ.js → chunk-X4MAMXRE.js} +1 -1
  60. package/dist/standalone/{chunk-K3ST3XOT.js → chunk-XSVQZ5JW.js} +1 -1
  61. package/dist/standalone/{chunk-WAJZ4QKG.js → chunk-YF3GD7OV.js} +1 -1
  62. package/dist/standalone/{chunk-6UKEJNM5.js → chunk-YXTJSSB4.js} +1 -1
  63. package/dist/standalone/{chunk-VNBONC2Q.js → chunk-ZODHG66O.js} +1 -1
  64. package/dist/standalone/{chunk-HQPW3EZF.js → chunk-ZVGDUDHN.js} +1 -1
  65. package/dist/standalone/studio.js +2 -2
  66. package/package.json +5 -5
  67. package/dist/standalone/chunk-X6XAMP4E.js +0 -7
@@ -1 +1 @@
1
- import{b as C}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as J}from"./chunk-4ZPDCXIA.js";import"./chunk-NCPW7WHO.js";import"./chunk-CLXX5RVY.js";import"./chunk-55UGUCQ6.js";import{a as H}from"./chunk-4ZEL6BYL.js";import{c as z}from"./chunk-ZBHXISOD.js";import"./chunk-X6XAMP4E.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as E}from"./chunk-RWVIV3U7.js";import{a as G,b as M,c as U,d as P,e as d,f as c}from"./chunk-HCTJKP5J.js";import{a as D,e as _}from"./chunk-2IKDEUCX.js";import{d as q}from"./chunk-74IYYDDI.js";import{a as S,d as O,f as Q,g as V}from"./chunk-I26MS5PJ.js";var L=O(Q(),1);var r=O(V(),1);var K=["read","insert","update","delete"],B=S((e,s)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[s],"z"),W=S(e=>{let s=new Map;for(let a of e){let t=s.get(a.table)??{operations:new Set,procedures:new Set,table:a.table};t.operations.add(a.on),t.procedures.add(a.procedure),s.set(a.table,t)}return[...s.values()].toSorted((a,t)=>a.table.localeCompare(t.table))},"J"),ie=S(()=>{let e=(0,L.c)(49),s=q(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let{data:t,error:R,errorSource:k}=z(H.rlsPolicies,a),p=t!==void 0,m,n,h,l,f,u,x,b,o;if(e[1]!==t||e[2]!==R||e[3]!==k||e[4]!==p||e[5]!==s){let $=W(Array.isArray(t?.policies)?t.policies:[]),j;e[15]!==t?(j=Array.isArray(t?.roles)?t.roles:[],e[15]=t,e[16]=j):j=e[16],n=j,x="flex flex-col gap-6",b="lunora-rls-panel",e[17]!==R||e[18]!==k?(o=R!==null&&(0,r.jsx)(J,{error:k,testId:"rls-error"}),e[17]=R,e[18]=k,e[19]=o):o=e[19],u="flex flex-col gap-2",m=D,h="overflow-hidden py-0";let I;e[20]!==s?(I=s("Policies"),e[20]=s,e[21]=I):I=e[21],e[22]!==I?(l=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:I})}),e[22]=I,e[23]=l):l=e[23],f=p&&$.length===0?(0,r.jsx)(E,{description:s("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:s("No policies defined")}):(0,r.jsx)(_,{className:"px-0",children:(0,r.jsxs)(G,{"data-testid":"rls-policies-table",children:[(0,r.jsx)(M,{children:(0,r.jsxs)(P,{children:[(0,r.jsx)(d,{children:s("Table")}),K.map(i=>(0,r.jsx)(d,{children:B(s,i)},i)),(0,r.jsx)(d,{children:s("Guarded by")})]})}),(0,r.jsx)(U,{children:$.map(i=>(0,r.jsxs)(P,{"data-testid":`rls-table-${i.table}`,children:[(0,r.jsx)(c,{className:"font-mono text-xs",children:i.table}),K.map(F=>(0,r.jsx)(c,{children:i.operations.has(F)?(0,r.jsx)(C,{variant:"secondary",children:s("Guarded")}):(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"})},F)),(0,r.jsx)(c,{className:"font-mono text-xs text-muted-foreground",children:[...i.procedures].join(", ")})]},i.table))})]})}),e[1]=t,e[2]=R,e[3]=k,e[4]=p,e[5]=s,e[6]=m,e[7]=n,e[8]=h,e[9]=l,e[10]=f,e[11]=u,e[12]=x,e[13]=b,e[14]=o}else m=e[6],n=e[7],h=e[8],l=e[9],f=e[10],u=e[11],x=e[12],b=e[13],o=e[14];let N;e[24]!==m||e[25]!==h||e[26]!==l||e[27]!==f?(N=(0,r.jsxs)(m,{className:h,children:[l,f]}),e[24]=m,e[25]=h,e[26]=l,e[27]=f,e[28]=N):N=e[28];let g;e[29]!==u||e[30]!==N?(g=(0,r.jsx)("section",{className:u,children:N}),e[29]=u,e[30]=N,e[31]=g):g=e[31];let y;e[32]!==s?(y=s("Roles"),e[32]=s,e[33]=y):y=e[33];let w;e[34]!==y?(w=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y})}),e[34]=y,e[35]=w):w=e[35];let v;e[36]!==p||e[37]!==n||e[38]!==s?(v=p&&n.length===0?(0,r.jsx)(E,{description:s("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:s("No roles defined")}):(0,r.jsx)(_,{className:"px-0",children:(0,r.jsxs)(G,{"data-testid":"rls-roles-table",children:[(0,r.jsx)(M,{children:(0,r.jsxs)(P,{children:[(0,r.jsx)(d,{children:s("Role")}),(0,r.jsx)(d,{children:s("Description")}),(0,r.jsx)(d,{children:s("Permissions")})]})}),(0,r.jsx)(U,{children:n.map(Y)})]})}),e[36]=p,e[37]=n,e[38]=s,e[39]=v):v=e[39];let A;e[40]!==w||e[41]!==v?(A=(0,r.jsx)("section",{className:"flex flex-col gap-2",children:(0,r.jsxs)(D,{className:"overflow-hidden py-0",children:[w,v]})}),e[40]=w,e[41]=v,e[42]=A):A=e[42];let T;return e[43]!==A||e[44]!==x||e[45]!==b||e[46]!==o||e[47]!==g?(T=(0,r.jsxs)("div",{className:x,"data-testid":b,children:[o,g,A]}),e[43]=A,e[44]=x,e[45]=b,e[46]=o,e[47]=g,e[48]=T):T=e[48],T},"oe");function X(e){return(0,r.jsx)(C,{variant:"outline",children:e},e)}S(X,"K");function Y(e){return(0,r.jsxs)(P,{"data-testid":`rls-role-${e.name}`,children:[(0,r.jsx)(c,{className:"font-mono text-xs",children:e.name}),(0,r.jsx)(c,{className:"text-muted-foreground",children:e.description??""}),(0,r.jsx)(c,{children:e.permissions.length===0?(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,r.jsx)("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(X)})})]},e.name)}S(Y,"V");export{ie as default};
1
+ import{b as C}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as J}from"./chunk-R7SRERCX.js";import"./chunk-NCPW7WHO.js";import"./chunk-RGUL4AQZ.js";import"./chunk-55UGUCQ6.js";import{a as H}from"./chunk-4ZEL6BYL.js";import{c as z}from"./chunk-QTDX7WSP.js";import"./chunk-KPRNLQKZ.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as E}from"./chunk-RWVIV3U7.js";import{a as G,b as M,c as U,d as P,e as d,f as c}from"./chunk-HCTJKP5J.js";import{a as D,e as _}from"./chunk-2IKDEUCX.js";import{d as q}from"./chunk-74IYYDDI.js";import{a as S,d as O,f as Q,g as V}from"./chunk-I26MS5PJ.js";var L=O(Q(),1);var r=O(V(),1);var K=["read","insert","update","delete"],B=S((e,s)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[s],"z"),W=S(e=>{let s=new Map;for(let a of e){let t=s.get(a.table)??{operations:new Set,procedures:new Set,table:a.table};t.operations.add(a.on),t.procedures.add(a.procedure),s.set(a.table,t)}return[...s.values()].toSorted((a,t)=>a.table.localeCompare(t.table))},"J"),ie=S(()=>{let e=(0,L.c)(49),s=q(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let{data:t,error:R,errorSource:k}=z(H.rlsPolicies,a),p=t!==void 0,m,n,h,l,f,u,x,b,o;if(e[1]!==t||e[2]!==R||e[3]!==k||e[4]!==p||e[5]!==s){let $=W(Array.isArray(t?.policies)?t.policies:[]),j;e[15]!==t?(j=Array.isArray(t?.roles)?t.roles:[],e[15]=t,e[16]=j):j=e[16],n=j,x="flex flex-col gap-6",b="lunora-rls-panel",e[17]!==R||e[18]!==k?(o=R!==null&&(0,r.jsx)(J,{error:k,testId:"rls-error"}),e[17]=R,e[18]=k,e[19]=o):o=e[19],u="flex flex-col gap-2",m=D,h="overflow-hidden py-0";let I;e[20]!==s?(I=s("Policies"),e[20]=s,e[21]=I):I=e[21],e[22]!==I?(l=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:I})}),e[22]=I,e[23]=l):l=e[23],f=p&&$.length===0?(0,r.jsx)(E,{description:s("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:s("No policies defined")}):(0,r.jsx)(_,{className:"px-0",children:(0,r.jsxs)(G,{"data-testid":"rls-policies-table",children:[(0,r.jsx)(M,{children:(0,r.jsxs)(P,{children:[(0,r.jsx)(d,{children:s("Table")}),K.map(i=>(0,r.jsx)(d,{children:B(s,i)},i)),(0,r.jsx)(d,{children:s("Guarded by")})]})}),(0,r.jsx)(U,{children:$.map(i=>(0,r.jsxs)(P,{"data-testid":`rls-table-${i.table}`,children:[(0,r.jsx)(c,{className:"font-mono text-xs",children:i.table}),K.map(F=>(0,r.jsx)(c,{children:i.operations.has(F)?(0,r.jsx)(C,{variant:"secondary",children:s("Guarded")}):(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"})},F)),(0,r.jsx)(c,{className:"font-mono text-xs text-muted-foreground",children:[...i.procedures].join(", ")})]},i.table))})]})}),e[1]=t,e[2]=R,e[3]=k,e[4]=p,e[5]=s,e[6]=m,e[7]=n,e[8]=h,e[9]=l,e[10]=f,e[11]=u,e[12]=x,e[13]=b,e[14]=o}else m=e[6],n=e[7],h=e[8],l=e[9],f=e[10],u=e[11],x=e[12],b=e[13],o=e[14];let N;e[24]!==m||e[25]!==h||e[26]!==l||e[27]!==f?(N=(0,r.jsxs)(m,{className:h,children:[l,f]}),e[24]=m,e[25]=h,e[26]=l,e[27]=f,e[28]=N):N=e[28];let g;e[29]!==u||e[30]!==N?(g=(0,r.jsx)("section",{className:u,children:N}),e[29]=u,e[30]=N,e[31]=g):g=e[31];let y;e[32]!==s?(y=s("Roles"),e[32]=s,e[33]=y):y=e[33];let w;e[34]!==y?(w=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y})}),e[34]=y,e[35]=w):w=e[35];let v;e[36]!==p||e[37]!==n||e[38]!==s?(v=p&&n.length===0?(0,r.jsx)(E,{description:s("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:s("No roles defined")}):(0,r.jsx)(_,{className:"px-0",children:(0,r.jsxs)(G,{"data-testid":"rls-roles-table",children:[(0,r.jsx)(M,{children:(0,r.jsxs)(P,{children:[(0,r.jsx)(d,{children:s("Role")}),(0,r.jsx)(d,{children:s("Description")}),(0,r.jsx)(d,{children:s("Permissions")})]})}),(0,r.jsx)(U,{children:n.map(Y)})]})}),e[36]=p,e[37]=n,e[38]=s,e[39]=v):v=e[39];let A;e[40]!==w||e[41]!==v?(A=(0,r.jsx)("section",{className:"flex flex-col gap-2",children:(0,r.jsxs)(D,{className:"overflow-hidden py-0",children:[w,v]})}),e[40]=w,e[41]=v,e[42]=A):A=e[42];let T;return e[43]!==A||e[44]!==x||e[45]!==b||e[46]!==o||e[47]!==g?(T=(0,r.jsxs)("div",{className:x,"data-testid":b,children:[o,g,A]}),e[43]=A,e[44]=x,e[45]=b,e[46]=o,e[47]=g,e[48]=T):T=e[48],T},"oe");function X(e){return(0,r.jsx)(C,{variant:"outline",children:e},e)}S(X,"K");function Y(e){return(0,r.jsxs)(P,{"data-testid":`rls-role-${e.name}`,children:[(0,r.jsx)(c,{className:"font-mono text-xs",children:e.name}),(0,r.jsx)(c,{className:"text-muted-foreground",children:e.description??""}),(0,r.jsx)(c,{children:e.permissions.length===0?(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,r.jsx)("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(X)})})]},e.name)}S(Y,"V");export{ie as default};
@@ -1 +1 @@
1
- import{i as k}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as q}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as j}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as U}from"./chunk-4ZPDCXIA.js";import"./chunk-NCPW7WHO.js";import"./chunk-CLXX5RVY.js";import"./chunk-55UGUCQ6.js";import{a as R}from"./chunk-4ZEL6BYL.js";import{c as P}from"./chunk-ZBHXISOD.js";import"./chunk-X6XAMP4E.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as M}from"./chunk-RWVIV3U7.js";import{a as G,b as H,c as J,d as B,e as x,f as N}from"./chunk-HCTJKP5J.js";import{a as z,e as D}from"./chunk-2IKDEUCX.js";import{d as F,u as O}from"./chunk-74IYYDDI.js";import{a as A,d as T,e as $,f as X,g as Y}from"./chunk-I26MS5PJ.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{i as k}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as q}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as j}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as U}from"./chunk-R7SRERCX.js";import"./chunk-NCPW7WHO.js";import"./chunk-RGUL4AQZ.js";import"./chunk-55UGUCQ6.js";import{a as R}from"./chunk-4ZEL6BYL.js";import{c as P}from"./chunk-QTDX7WSP.js";import"./chunk-KPRNLQKZ.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as M}from"./chunk-RWVIV3U7.js";import{a as G,b as H,c as J,d as B,e as x,f as N}from"./chunk-HCTJKP5J.js";import{a as z,e as D}from"./chunk-2IKDEUCX.js";import{d as F,u as O}from"./chunk-74IYYDDI.js";import{a as A,d as T,e as $,f as X,g as Y}from"./chunk-I26MS5PJ.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{a as D}from"./chunk-J2OLAMJR.js";import{a as k}from"./chunk-B3SX5SBI.js";import"./chunk-FUYEZFBP.js";import"./chunk-OQ6I6OXT.js";import"./chunk-SJQERRSZ.js";import"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as N}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as B}from"./chunk-4ZPDCXIA.js";import"./chunk-NCPW7WHO.js";import"./chunk-CLXX5RVY.js";import"./chunk-55UGUCQ6.js";import{a as u}from"./chunk-4ZEL6BYL.js";import{c as p}from"./chunk-ZBHXISOD.js";import{e as R}from"./chunk-X6XAMP4E.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as S}from"./chunk-RWVIV3U7.js";import{a as A,b as C,c as P,d as b,e as l,f as n}from"./chunk-HCTJKP5J.js";import{a as v,e as w}from"./chunk-2IKDEUCX.js";import{d as j,u as I}from"./chunk-74IYYDDI.js";import{a as m,d as H,g as Q}from"./chunk-I26MS5PJ.js";var e=H(Q(),1);var _="payment_subscriptions",O="payment_events",V=[_,O],Y={},E=new Set(["active","trialing"]),z=new Set(["past_due","unpaid"]),s=m((a,t)=>{if(a[t]!==void 0)return a[t];let h=a.__doc__;return typeof h=="string"?R(h)?.[t]:void 0},"a"),o=m(a=>typeof a=="string"?a:typeof a=="number"||typeof a=="bigint"||typeof a=="boolean"?String(a):"","s"),J=m(a=>E.has(a)?"default":z.has(a)?"destructive":"outline","q"),ie=m(({limit:a=100})=>{let t=j(),h=k(),{data:x}=p(u.listTables,Y,{live:!0}),F=x!==void 0,L=Array.isArray(x)&&V.every(r=>x.some(d=>d.name===r)),c=h.payments&&L,i=p(u.readTablePage,{filters:[],limit:a,offset:0,orderBy:{column:"updatedAt",direction:"desc"},search:"",table:_},{enabled:c}),f=p(u.readTablePage,{filters:[],limit:25,offset:0,orderBy:{column:"processedAt",direction:"desc"},search:"",table:O},{enabled:c}),g=p(u.facetColumn,{column:"state",table:_},{enabled:c});D(()=>{if(c)return Promise.all([i.poll(),f.poll(),g.poll()])},!0);let y=i.data?.rows??[],M=f.data?.rows??[],U=i.error??f.error,q=i.error===null?f.errorSource:i.errorSource,G=i.data?.total??y.length,T=g.data?.values===void 0?y.filter(r=>E.has(o(s(r,"state")))).length:g.data.values.reduce((r,d)=>r+(E.has(o(d.value))?d.count:0),0);return F&&!c?(0,e.jsx)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:(0,e.jsx)(S,{description:t("No @lunora/payment tables found in this deployment. Add `.extend(paymentExtension)` to lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions."),testId:"payments-unconfigured",title:t("No payments configured")})}):(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[(0,e.jsx)("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:(0,e.jsxs)(v,{className:"justify-between gap-0 py-0",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Subscriptions")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:T}),(0,e.jsx)(N,{variant:"default",children:t("{count} active",{count:T})})]})]}),(0,e.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:t("{total} total",{total:G})})]})}),U===null?void 0:(0,e.jsx)(B,{error:q}),y.length===0&&!i.isLoading?(0,e.jsx)(S,{testId:"payments-empty",title:t("No subscriptions yet")}):(0,e.jsx)(v,{className:"overflow-hidden py-0",children:(0,e.jsx)(w,{className:"px-0",children:(0,e.jsxs)(A,{children:[(0,e.jsx)(C,{children:(0,e.jsxs)(b,{children:[(0,e.jsx)(l,{children:t("Provider")}),(0,e.jsx)(l,{children:t("Reference")}),(0,e.jsx)(l,{children:t("Plan")}),(0,e.jsx)(l,{children:t("State")}),(0,e.jsx)(l,{children:t("Renews")})]})}),(0,e.jsx)(P,{children:y.map(r=>{let d=o(s(r,"state"));return(0,e.jsxs)(b,{"data-testid":"payment-subscription-row",children:[(0,e.jsx)(n,{children:o(s(r,"provider"))}),(0,e.jsx)(n,{children:o(s(r,"referenceId"))}),(0,e.jsx)(n,{children:o(s(r,"priceId"))}),(0,e.jsx)(n,{children:(0,e.jsx)(N,{variant:J(d),children:d})}),(0,e.jsx)(n,{children:I(s(r,"currentPeriodEnd"))})]},o(s(r,"providerSubscriptionId")))})})]})})}),(0,e.jsxs)(v,{className:"overflow-hidden py-0",children:[(0,e.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Recent webhook events")})}),(0,e.jsx)(w,{className:"px-0",children:(0,e.jsx)(A,{children:(0,e.jsx)(P,{children:M.map(r=>(0,e.jsxs)(b,{"data-testid":"payment-event-row",children:[(0,e.jsx)(n,{children:o(s(r,"provider"))}),(0,e.jsx)(n,{className:"font-medium",children:o(s(r,"type"))}),(0,e.jsx)(n,{className:"text-muted-foreground",children:o(s(r,"providerEventId"))}),(0,e.jsx)(n,{children:I(s(r,"processedAt"))})]},o(s(r,"providerEventId"))))})})})]})]})},"oe");export{ie as PaymentsPanel};
1
+ import{a as D}from"./chunk-3ZVTL2VM.js";import{a as k}from"./chunk-LSNLFUZ6.js";import"./chunk-FUYEZFBP.js";import"./chunk-OQ6I6OXT.js";import"./chunk-SJQERRSZ.js";import"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as N}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as B}from"./chunk-R7SRERCX.js";import"./chunk-NCPW7WHO.js";import"./chunk-RGUL4AQZ.js";import"./chunk-55UGUCQ6.js";import{a as u}from"./chunk-4ZEL6BYL.js";import{c as p}from"./chunk-QTDX7WSP.js";import{e as R}from"./chunk-KPRNLQKZ.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as S}from"./chunk-RWVIV3U7.js";import{a as A,b as C,c as P,d as b,e as l,f as n}from"./chunk-HCTJKP5J.js";import{a as v,e as w}from"./chunk-2IKDEUCX.js";import{d as j,u as I}from"./chunk-74IYYDDI.js";import{a as m,d as H,g as Q}from"./chunk-I26MS5PJ.js";var e=H(Q(),1);var _="payment_subscriptions",O="payment_events",V=[_,O],Y={},E=new Set(["active","trialing"]),z=new Set(["past_due","unpaid"]),s=m((a,t)=>{if(a[t]!==void 0)return a[t];let h=a.__doc__;return typeof h=="string"?R(h)?.[t]:void 0},"a"),o=m(a=>typeof a=="string"?a:typeof a=="number"||typeof a=="bigint"||typeof a=="boolean"?String(a):"","s"),J=m(a=>E.has(a)?"default":z.has(a)?"destructive":"outline","q"),ie=m(({limit:a=100})=>{let t=j(),h=k(),{data:x}=p(u.listTables,Y,{live:!0}),F=x!==void 0,L=Array.isArray(x)&&V.every(r=>x.some(d=>d.name===r)),c=h.payments&&L,i=p(u.readTablePage,{filters:[],limit:a,offset:0,orderBy:{column:"updatedAt",direction:"desc"},search:"",table:_},{enabled:c}),f=p(u.readTablePage,{filters:[],limit:25,offset:0,orderBy:{column:"processedAt",direction:"desc"},search:"",table:O},{enabled:c}),g=p(u.facetColumn,{column:"state",table:_},{enabled:c});D(()=>{if(c)return Promise.all([i.poll(),f.poll(),g.poll()])},!0);let y=i.data?.rows??[],M=f.data?.rows??[],U=i.error??f.error,q=i.error===null?f.errorSource:i.errorSource,G=i.data?.total??y.length,T=g.data?.values===void 0?y.filter(r=>E.has(o(s(r,"state")))).length:g.data.values.reduce((r,d)=>r+(E.has(o(d.value))?d.count:0),0);return F&&!c?(0,e.jsx)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:(0,e.jsx)(S,{description:t("No @lunora/payment tables found in this deployment. Add `.extend(paymentExtension)` to lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions."),testId:"payments-unconfigured",title:t("No payments configured")})}):(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[(0,e.jsx)("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:(0,e.jsxs)(v,{className:"justify-between gap-0 py-0",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Subscriptions")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:T}),(0,e.jsx)(N,{variant:"default",children:t("{count} active",{count:T})})]})]}),(0,e.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:t("{total} total",{total:G})})]})}),U===null?void 0:(0,e.jsx)(B,{error:q}),y.length===0&&!i.isLoading?(0,e.jsx)(S,{testId:"payments-empty",title:t("No subscriptions yet")}):(0,e.jsx)(v,{className:"overflow-hidden py-0",children:(0,e.jsx)(w,{className:"px-0",children:(0,e.jsxs)(A,{children:[(0,e.jsx)(C,{children:(0,e.jsxs)(b,{children:[(0,e.jsx)(l,{children:t("Provider")}),(0,e.jsx)(l,{children:t("Reference")}),(0,e.jsx)(l,{children:t("Plan")}),(0,e.jsx)(l,{children:t("State")}),(0,e.jsx)(l,{children:t("Renews")})]})}),(0,e.jsx)(P,{children:y.map(r=>{let d=o(s(r,"state"));return(0,e.jsxs)(b,{"data-testid":"payment-subscription-row",children:[(0,e.jsx)(n,{children:o(s(r,"provider"))}),(0,e.jsx)(n,{children:o(s(r,"referenceId"))}),(0,e.jsx)(n,{children:o(s(r,"priceId"))}),(0,e.jsx)(n,{children:(0,e.jsx)(N,{variant:J(d),children:d})}),(0,e.jsx)(n,{children:I(s(r,"currentPeriodEnd"))})]},o(s(r,"providerSubscriptionId")))})})]})})}),(0,e.jsxs)(v,{className:"overflow-hidden py-0",children:[(0,e.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Recent webhook events")})}),(0,e.jsx)(w,{className:"px-0",children:(0,e.jsx)(A,{children:(0,e.jsx)(P,{children:M.map(r=>(0,e.jsxs)(b,{"data-testid":"payment-event-row",children:[(0,e.jsx)(n,{children:o(s(r,"provider"))}),(0,e.jsx)(n,{className:"font-medium",children:o(s(r,"type"))}),(0,e.jsx)(n,{className:"text-muted-foreground",children:o(s(r,"providerEventId"))}),(0,e.jsx)(n,{children:I(s(r,"processedAt"))})]},o(s(r,"providerEventId"))))})})})]})]})},"oe");export{ie as PaymentsPanel};
@@ -1 +1 @@
1
- import{a as q}from"./chunk-J2OLAMJR.js";import{a as F}from"./chunk-R6U22RSY.js";import{a as D}from"./chunk-7Q256NLI.js";import"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import"./chunk-AUAECCXB.js";import{b as S}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as L}from"./chunk-4ZPDCXIA.js";import"./chunk-NCPW7WHO.js";import"./chunk-CLXX5RVY.js";import"./chunk-55UGUCQ6.js";import{a as B}from"./chunk-4ZEL6BYL.js";import{c as _}from"./chunk-ZBHXISOD.js";import"./chunk-X6XAMP4E.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as j}from"./chunk-RWVIV3U7.js";import{a as O,b as P,c as W,d as C,e as h,f as p}from"./chunk-HCTJKP5J.js";import{a as T,e as $}from"./chunk-2IKDEUCX.js";import{d as M,n as E}from"./chunk-74IYYDDI.js";import{a as N,d as A,f as H,g as U}from"./chunk-I26MS5PJ.js";var R=A(H(),1);var t=A(U(),1);var J=80,Z=N(a=>{if(a===void 0)return"";let e=JSON.stringify(a,E);return e.length>J?`${e.slice(0,J)}\u2026`:e},"G"),z=N(a=>{let e=[];for(let r of a){let n=r.id.toString();if(r.subscriptions.length===0){e.push({admin:r.admin,connectionId:r.id,key:`c${n}`,subscription:null});continue}r.subscriptions.forEach((d,o)=>{e.push({admin:r.admin,connectionId:r.id,key:`c${n}-s${o.toString()}`,subscription:d})})}return e},"J"),w=(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),ce=N(a=>{let e=(0,R.c)(22),{initialShardKey:r}=a,n=M(),{queryShardKey:d,setShardKey:o,shardKey:m}=F(r),f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f={},e[0]=f):f=e[0];let b;e[1]!==d?(b={keepPreviousData:!0,shardKey:d},e[1]=d,e[2]=b):b=e[2];let{data:s,error:i,errorSource:u,poll:G}=_(B.listSubscriptions,f,b);q(G,!0);let x;if(e[3]!==i||e[4]!==u||e[5]!==s||e[6]!==o||e[7]!==m||e[8]!==n){let k=s===void 0?[]:z(s.connections),c;e[10]!==o||e[11]!==m?(c=(0,t.jsx)(D,{onChange:o,testId:"subs-shard-input",value:m}),e[10]=o,e[11]=m,e[12]=c):c=e[12];let l;e[13]!==s||e[14]!==n?(l=s!==void 0&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[(0,t.jsx)(S,{variant:"secondary",children:n("{count} connections",{count:s.totalConnections})}),(0,t.jsx)(S,{variant:"secondary",children:n("{count} subscriptions",{count:s.totalSubscriptions})})]}),e[13]=s,e[14]=n,e[15]=l):l=e[15];let g;e[16]!==c||e[17]!==l?(g=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,l]}),e[16]=c,e[17]=l,e[18]=g):g=e[18];let v;e[19]!==i||e[20]!==u?(v=i!==null&&(0,t.jsx)(L,{error:u,testId:"subs-error"}),e[19]=i,e[20]=u,e[21]=v):v=e[21],x=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[g,v,i===null&&s!==void 0&&k.length===0&&(0,t.jsx)(j,{description:n("Active WebSocket subscriptions on this shard."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"})}),testId:"subs-empty",title:n("No active subscriptions.")}),i===null&&k.length>0&&(0,t.jsx)(T,{className:"overflow-hidden py-0",children:(0,t.jsx)($,{className:"px-0",children:(0,t.jsxs)(O,{"data-testid":"subs-table",children:[(0,t.jsx)(P,{children:(0,t.jsxs)(C,{children:[(0,t.jsx)(h,{children:n("Connection")}),(0,t.jsx)(h,{children:n("Function path")}),(0,t.jsx)(h,{children:n("Table")}),(0,t.jsx)(h,{children:n("Arguments")})]})}),(0,t.jsx)(W,{children:k.map(y=>{let{subscription:I}=y,K=Z(I?.args);return(0,t.jsxs)(C,{"data-testid":"subs-row",children:[(0,t.jsx)(p,{className:"font-medium tabular-nums",children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:["#",y.connectionId,y.admin&&(0,t.jsx)(S,{variant:"outline",children:n("admin")})]})}),(0,t.jsx)(p,{className:"font-mono text-xs",children:I?.functionPath??w}),(0,t.jsx)(p,{children:I?.table??w}),(0,t.jsx)(p,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:K||void 0,children:K||w})]},y.key)})})]})})})]}),e[3]=i,e[4]=u,e[5]=s,e[6]=o,e[7]=m,e[8]=n,e[9]=x}else x=e[9];return x},"ae");export{ce as default};
1
+ import{a as q}from"./chunk-3ZVTL2VM.js";import{a as F}from"./chunk-R6U22RSY.js";import{a as D}from"./chunk-7Q256NLI.js";import"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import"./chunk-AUAECCXB.js";import{b as S}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as L}from"./chunk-R7SRERCX.js";import"./chunk-NCPW7WHO.js";import"./chunk-RGUL4AQZ.js";import"./chunk-55UGUCQ6.js";import{a as B}from"./chunk-4ZEL6BYL.js";import{c as _}from"./chunk-QTDX7WSP.js";import"./chunk-KPRNLQKZ.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as j}from"./chunk-RWVIV3U7.js";import{a as O,b as P,c as W,d as C,e as h,f as p}from"./chunk-HCTJKP5J.js";import{a as T,e as $}from"./chunk-2IKDEUCX.js";import{d as M,n as E}from"./chunk-74IYYDDI.js";import{a as N,d as A,f as H,g as U}from"./chunk-I26MS5PJ.js";var R=A(H(),1);var t=A(U(),1);var J=80,Z=N(a=>{if(a===void 0)return"";let e=JSON.stringify(a,E);return e.length>J?`${e.slice(0,J)}\u2026`:e},"G"),z=N(a=>{let e=[];for(let r of a){let n=r.id.toString();if(r.subscriptions.length===0){e.push({admin:r.admin,connectionId:r.id,key:`c${n}`,subscription:null});continue}r.subscriptions.forEach((d,o)=>{e.push({admin:r.admin,connectionId:r.id,key:`c${n}-s${o.toString()}`,subscription:d})})}return e},"J"),w=(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),ce=N(a=>{let e=(0,R.c)(22),{initialShardKey:r}=a,n=M(),{queryShardKey:d,setShardKey:o,shardKey:m}=F(r),f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f={},e[0]=f):f=e[0];let b;e[1]!==d?(b={keepPreviousData:!0,shardKey:d},e[1]=d,e[2]=b):b=e[2];let{data:s,error:i,errorSource:u,poll:G}=_(B.listSubscriptions,f,b);q(G,!0);let x;if(e[3]!==i||e[4]!==u||e[5]!==s||e[6]!==o||e[7]!==m||e[8]!==n){let k=s===void 0?[]:z(s.connections),c;e[10]!==o||e[11]!==m?(c=(0,t.jsx)(D,{onChange:o,testId:"subs-shard-input",value:m}),e[10]=o,e[11]=m,e[12]=c):c=e[12];let l;e[13]!==s||e[14]!==n?(l=s!==void 0&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[(0,t.jsx)(S,{variant:"secondary",children:n("{count} connections",{count:s.totalConnections})}),(0,t.jsx)(S,{variant:"secondary",children:n("{count} subscriptions",{count:s.totalSubscriptions})})]}),e[13]=s,e[14]=n,e[15]=l):l=e[15];let g;e[16]!==c||e[17]!==l?(g=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,l]}),e[16]=c,e[17]=l,e[18]=g):g=e[18];let v;e[19]!==i||e[20]!==u?(v=i!==null&&(0,t.jsx)(L,{error:u,testId:"subs-error"}),e[19]=i,e[20]=u,e[21]=v):v=e[21],x=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[g,v,i===null&&s!==void 0&&k.length===0&&(0,t.jsx)(j,{description:n("Active WebSocket subscriptions on this shard."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"})}),testId:"subs-empty",title:n("No active subscriptions.")}),i===null&&k.length>0&&(0,t.jsx)(T,{className:"overflow-hidden py-0",children:(0,t.jsx)($,{className:"px-0",children:(0,t.jsxs)(O,{"data-testid":"subs-table",children:[(0,t.jsx)(P,{children:(0,t.jsxs)(C,{children:[(0,t.jsx)(h,{children:n("Connection")}),(0,t.jsx)(h,{children:n("Function path")}),(0,t.jsx)(h,{children:n("Table")}),(0,t.jsx)(h,{children:n("Arguments")})]})}),(0,t.jsx)(W,{children:k.map(y=>{let{subscription:I}=y,K=Z(I?.args);return(0,t.jsxs)(C,{"data-testid":"subs-row",children:[(0,t.jsx)(p,{className:"font-medium tabular-nums",children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:["#",y.connectionId,y.admin&&(0,t.jsx)(S,{variant:"outline",children:n("admin")})]})}),(0,t.jsx)(p,{className:"font-mono text-xs",children:I?.functionPath??w}),(0,t.jsx)(p,{children:I?.table??w}),(0,t.jsx)(p,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:K||void 0,children:K||w})]},y.key)})})]})})})]}),e[3]=i,e[4]=u,e[5]=s,e[6]=o,e[7]=m,e[8]=n,e[9]=x}else x=e[9];return x},"ae");export{ce as default};
@@ -1 +1 @@
1
- import{a as be,b as fe,c as xe,d as Ne,e as Ce}from"./chunk-5QR2SQIS.js";import"./chunk-NRP22GKC.js";import"./chunk-OPM7ESDV.js";import{a as ce}from"./chunk-FPI7AMQJ.js";import{a as ue}from"./chunk-7RKB5KS7.js";import{a as q}from"./chunk-37WYCOQ2.js";import{g as me,h as ve,i as pe,j as ye}from"./chunk-KC67JOVJ.js";import"./chunk-XGCIDUJF.js";import"./chunk-B3SX5SBI.js";import"./chunk-CCDX5RYT.js";import"./chunk-OYCUPD3Q.js";import"./chunk-NXQW5E6W.js";import"./chunk-UC7MNI2F.js";import"./chunk-SA2OGF3F.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import"./chunk-WJRYEML4.js";import"./chunk-FUYEZFBP.js";import"./chunk-RGMVGZV4.js";import"./chunk-OQ6I6OXT.js";import{i as ae}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{a as $}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as he}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import"./chunk-55UGUCQ6.js";import"./chunk-4ZEL6BYL.js";import"./chunk-ZBHXISOD.js";import{l as G}from"./chunk-X6XAMP4E.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as ke}from"./chunk-RWVIV3U7.js";import{a as se,b as ie,c as oe,d as Q,e as X,f as Y}from"./chunk-HCTJKP5J.js";import{a as re,e as ne}from"./chunk-2IKDEUCX.js";import{d as R,h as Z,m as ge,q as z,t as de}from"./chunk-74IYYDDI.js";import{a as i,d as le,e as Oe,f as _e,g as De}from"./chunk-I26MS5PJ.js";var P=le(Oe(),1);var ee=le(_e(),1);var a=le(De(),1);var Be=i(l=>{let e=l.trim();if(e==="")return;let n=Number(e);return Number.isFinite(n)&&n>0?Math.floor(n):void 0},"Be"),Le=i(l=>l===void 0?"\u2014":new Date(l*1e3).toISOString(),"Oe"),Je=i(l=>new TextEncoder().encode(l).length,"Ae"),Fe=i(l=>{if(l.trim()!=="")try{return JSON.stringify(JSON.parse(l),void 0,2)}catch{return}},"ge"),Ke=i(l=>{if(l.trim()==="")return!0;try{return JSON.parse(l),!0}catch{return!1}},"xe"),Ee=[{key:"seconds",seconds:1},{key:"minutes",seconds:60},{key:"hours",seconds:3600},{key:"days",seconds:86400}],we=i((l,e)=>{let n=l.trim();if(n==="")return"";let u=Number(n),s=Ee.find(p=>p.key===e)?.seconds??1;return Number.isFinite(u)&&u>0?String(Math.round(u*s)):n},"ue"),Ve=i(l=>{let e=l.trim();if(e==="")return!0;let n=Number(e);return Number.isInteger(n)&&n>=60},"Ce"),Te=i((l,e,n,u)=>{let s=Be(l.ttl);return{expiration:s===void 0?u:void 0,expirationTtl:s,key:e,metadata:l.metadata.trim()===""?void 0:JSON.parse(l.metadata),namespace:n,value:l.value}},"Se"),Me=i(l=>{let e=(0,ee.c)(60),{helper:n,id:u,invalid:s,onChange:p,testId:o}=l,t=R(),[r,y]=(0,P.useState)(""),[c,x]=(0,P.useState)("seconds"),b;e[0]!==p||e[1]!==c?(b=i(f=>{y(f.target.value),p(we(f.target.value,c))},"k"),e[0]=p,e[1]=c,e[2]=b):b=e[2];let _=b,V;e[3]!==r||e[4]!==p?(V=i(f=>{f!==null&&(x(f),p(we(r,f)))},"K"),e[3]=r,e[4]=p,e[5]=V):V=e[5];let T=V,h;e[6]!==t?(h=t("days"),e[6]=t,e[7]=h):h=e[7];let v;e[8]!==t?(v=t("hours"),e[8]=t,e[9]=v):v=e[9];let k;e[10]!==t?(k=t("minutes"),e[10]=t,e[11]=k):k=e[11];let N;e[12]!==t?(N=t("seconds"),e[12]=t,e[13]=N):N=e[13];let C;e[14]!==h||e[15]!==v||e[16]!==k||e[17]!==N?(C={days:h,hours:v,minutes:k,seconds:N},e[14]=h,e[15]=v,e[16]=k,e[17]=N,e[18]=C):C=e[18];let w=C,g;e[19]!==t?(g=t("Expires after"),e[19]=t,e[20]=g):g=e[20];let S;e[21]!==u||e[22]!==g?(S=(0,a.jsx)(q,{className:"text-xs",htmlFor:u,children:g}),e[21]=u,e[22]=g,e[23]=S):S=e[23];let E;e[24]!==t?(E=t("No expiration"),e[24]=t,e[25]=E):E=e[25];let B;e[26]!==r||e[27]!==u||e[28]!==s||e[29]!==_||e[30]!==E||e[31]!==o?(B=(0,a.jsx)(ae,{"aria-invalid":s,className:"flex-1","data-testid":o,id:u,inputMode:"numeric",onChange:_,placeholder:E,value:r}),e[26]=r,e[27]=u,e[28]=s,e[29]=_,e[30]=E,e[31]=o,e[32]=B):B=e[32];let M;e[33]!==t?(M=t("TTL unit"),e[33]=t,e[34]=M):M=e[34];let J=`${o}-unit`,L;e[35]===Symbol.for("react.memo_cache_sentinel")?(L=(0,a.jsx)(fe,{}),e[35]=L):L=e[35];let I;e[36]!==M||e[37]!==J?(I=(0,a.jsx)(xe,{"aria-label":M,className:"w-[7.5rem]","data-testid":J,children:L}),e[36]=M,e[37]=J,e[38]=I):I=e[38];let d;e[39]!==w?(d=Ee.map(f=>(0,a.jsx)(Ce,{value:f.key,children:w[f.key]},f.key)),e[39]=w,e[40]=d):d=e[40];let m;e[41]!==d?(m=(0,a.jsx)(Ne,{children:d}),e[41]=d,e[42]=m):m=e[42];let F;e[43]!==T||e[44]!==I||e[45]!==m||e[46]!==c?(F=(0,a.jsxs)(be,{onValueChange:T,value:c,children:[I,m]}),e[43]=T,e[44]=I,e[45]=m,e[46]=c,e[47]=F):F=e[47];let O;e[48]!==B||e[49]!==F?(O=(0,a.jsxs)("div",{className:"flex gap-2",children:[B,F]}),e[48]=B,e[49]=F,e[50]=O):O=e[50];let K;e[51]!==n||e[52]!==s||e[53]!==t||e[54]!==o?(K=s?(0,a.jsx)("p",{className:"text-xs text-destructive","data-testid":`${o}-invalid`,children:t("TTL must be at least 60 seconds.")}):n!==void 0&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:n}),e[51]=n,e[52]=s,e[53]=t,e[54]=o,e[55]=K):K=e[55];let D;return e[56]!==O||e[57]!==K||e[58]!==S?(D=(0,a.jsxs)("div",{className:"mb-3 grid gap-1",children:[S,O,K]}),e[56]=O,e[57]=K,e[58]=S,e[59]=D):D=e[59],D},"we"),Ie=i(l=>{let e=(0,ee.c)(36),{id:n,invalidTestId:u,onChange:s,testId:p,valid:o,value:t}=l,r=R(),y;e[0]!==t?(y=Fe(t),e[0]=t,e[1]=y):y=e[1];let c=y,x;e[2]!==r?(x=r("Metadata (JSON)"),e[2]=r,e[3]=x):x=e[3];let b;e[4]!==n||e[5]!==x?(b=(0,a.jsx)(q,{className:"text-xs",htmlFor:n,children:x}),e[4]=n,e[5]=x,e[6]=b):b=e[6];let _=`${p}-format`,V=c===void 0,T;e[7]!==c||e[8]!==s?(T=i(()=>{c!==void 0&&s(c)},"V"),e[7]=c,e[8]=s,e[9]=T):T=e[9];let h;e[10]!==r?(h=r("Format JSON"),e[10]=r,e[11]=h):h=e[11];let v;e[12]!==_||e[13]!==V||e[14]!==T||e[15]!==h?(v=(0,a.jsx)($,{"data-testid":_,disabled:V,onClick:T,size:"sm",variant:"outline",children:h}),e[12]=_,e[13]=V,e[14]=T,e[15]=h,e[16]=v):v=e[16];let k;e[17]!==b||e[18]!==v?(k=(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[b,v]}),e[17]=b,e[18]=v,e[19]=k):k=e[19];let N=!o,C;e[20]!==s?(C=i(E=>{s(E.target.value)},"N"),e[20]=s,e[21]=C):C=e[21];let w;e[22]!==n||e[23]!==N||e[24]!==C||e[25]!==p||e[26]!==t?(w=(0,a.jsx)(ce,{"aria-invalid":N,className:"min-h-[4rem] font-mono text-xs","data-testid":p,id:n,onChange:C,value:t}),e[22]=n,e[23]=N,e[24]=C,e[25]=p,e[26]=t,e[27]=w):w=e[27];let g;e[28]!==u||e[29]!==r||e[30]!==o?(g=!o&&(0,a.jsx)("p",{className:"text-xs text-destructive","data-testid":u,children:r("Metadata must be valid JSON.")}),e[28]=u,e[29]=r,e[30]=o,e[31]=g):g=e[31];let S;return e[32]!==w||e[33]!==g||e[34]!==k?(S=(0,a.jsxs)("div",{className:"mb-3 grid gap-1",children:[k,w,g]}),e[32]=w,e[33]=g,e[34]=k,e[35]=S):S=e[35],S},"Te"),Pe={busy:!1,error:null,metadata:"",name:"",ttl:"",value:""},$e=i((l,e)=>{switch(e.type){case"setField":return{...l,[e.field]:e.value};case"submitFailed":return{...l,busy:!1,error:e.error};case"submitStart":return{...l,busy:!0,error:null};default:return l}},"Je"),je=i(l=>{let e=(0,ee.c)(73),{namespace:n,onCancel:u,onCreated:s}=l,p=G(),o=R(),[t,r]=(0,P.useReducer)($e,Pe),y;e[0]!==t.metadata?(y=Ke(t.metadata),e[0]=t.metadata,e[1]=y):y=e[1];let c=y,x;e[2]!==t.ttl?(x=Ve(t.ttl),e[2]=t.ttl,e[3]=x):x=e[3];let b=x,_;e[4]!==c||e[5]!==t.busy||e[6]!==t.name||e[7]!==b?(_=t.name.trim()!==""&&c&&b&&!t.busy,e[4]=c,e[5]=t.busy,e[6]=t.name,e[7]=b,e[8]=_):_=e[8];let V=_,T;e[9]!==V||e[10]!==p||e[11]!==n||e[12]!==s||e[13]!==t.metadata||e[14]!==t.name||e[15]!==t.ttl||e[16]!==t.value?(T=i(()=>{V&&(r({type:"submitStart"}),z((async()=>{try{await p.putKvValue(Te({metadata:t.metadata,ttl:t.ttl,value:t.value},t.name,n)),s()}catch(A){r({error:Z(A),type:"submitFailed"})}})()))},"V"),e[9]=V,e[10]=p,e[11]=n,e[12]=s,e[13]=t.metadata,e[14]=t.name,e[15]=t.ttl,e[16]=t.value,e[17]=T):T=e[17];let h=T,v;e[18]!==o?(v=o("Key name"),e[18]=o,e[19]=v):v=e[19];let k;e[20]!==v?(k=(0,a.jsx)(q,{className:"text-xs",htmlFor:"kv-create-name",children:v}),e[20]=v,e[21]=k):k=e[21];let N;e[22]===Symbol.for("react.memo_cache_sentinel")?(N=i(A=>{r({field:"name",type:"setField",value:A.target.value})},"x"),e[22]=N):N=e[22];let C;e[23]!==o?(C=o("Key name"),e[23]=o,e[24]=C):C=e[24];let w;e[25]!==t.name||e[26]!==C?(w=(0,a.jsx)(ae,{autoFocus:!0,"data-testid":"kv-create-name",id:"kv-create-name",onChange:N,placeholder:C,value:t.name}),e[25]=t.name,e[26]=C,e[27]=w):w=e[27];let g;e[28]!==k||e[29]!==w?(g=(0,a.jsxs)("div",{className:"grid gap-1",children:[k,w]}),e[28]=k,e[29]=w,e[30]=g):g=e[30];let S;e[31]!==o?(S=o("Value"),e[31]=o,e[32]=S):S=e[32];let E;e[33]!==S?(E=(0,a.jsx)(q,{className:"text-xs",htmlFor:"kv-create-value",children:S}),e[33]=S,e[34]=E):E=e[34];let B;e[35]===Symbol.for("react.memo_cache_sentinel")?(B=i(A=>{r({field:"value",type:"setField",value:A.target.value})},"O"),e[35]=B):B=e[35];let M;e[36]!==t.value?(M=(0,a.jsx)(ce,{className:"min-h-[6rem] font-mono text-xs","data-testid":"kv-create-value",id:"kv-create-value",onChange:B,value:t.value}),e[36]=t.value,e[37]=M):M=e[37];let J;e[38]!==E||e[39]!==M?(J=(0,a.jsxs)("div",{className:"grid gap-1",children:[E,M]}),e[38]=E,e[39]=M,e[40]=J):J=e[40];let L=!b,I;e[41]===Symbol.for("react.memo_cache_sentinel")?(I=i(A=>{r({field:"ttl",type:"setField",value:A})},"_"),e[41]=I):I=e[41];let d;e[42]!==L?(d=(0,a.jsx)(Me,{id:"kv-create-ttl",invalid:L,onChange:I,testId:"kv-create-ttl"}),e[42]=L,e[43]=d):d=e[43];let m;e[44]===Symbol.for("react.memo_cache_sentinel")?(m=i(A=>{r({field:"metadata",type:"setField",value:A})},"u"),e[44]=m):m=e[44];let F;e[45]!==c||e[46]!==t.metadata?(F=(0,a.jsx)(Ie,{id:"kv-create-metadata",invalidTestId:"kv-create-metadata-invalid",onChange:m,testId:"kv-create-metadata",valid:c,value:t.metadata}),e[45]=c,e[46]=t.metadata,e[47]=F):F=e[47];let O=!V,K;e[48]!==t.busy||e[49]!==o?(K=t.busy?o("Creating\u2026"):o("Create key"),e[48]=t.busy,e[49]=o,e[50]=K):K=e[50];let D;e[51]!==h||e[52]!==O||e[53]!==K?(D=(0,a.jsx)($,{"data-testid":"kv-create-submit",disabled:O,onClick:h,children:K}),e[51]=h,e[52]=O,e[53]=K,e[54]=D):D=e[54];let f=t.busy,j;e[55]!==o?(j=o("Cancel"),e[55]=o,e[56]=j):j=e[56];let H;e[57]!==u||e[58]!==t.busy||e[59]!==j?(H=(0,a.jsx)($,{"data-testid":"kv-create-cancel",disabled:f,onClick:u,variant:"outline",children:j}),e[57]=u,e[58]=t.busy,e[59]=j,e[60]=H):H=e[60];let U;e[61]!==D||e[62]!==H?(U=(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[D,H]}),e[61]=D,e[62]=H,e[63]=U):U=e[63];let W;e[64]!==t.error?(W=t.error!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"kv-create-error",role:"alert",children:t.error}),e[64]=t.error,e[65]=W):W=e[65];let te;return e[66]!==g||e[67]!==J||e[68]!==d||e[69]!==F||e[70]!==U||e[71]!==W?(te=(0,a.jsxs)("div",{className:"grid gap-3 px-4 pb-4","data-testid":"kv-create-form",children:[g,J,d,F,U,W]}),e[66]=g,e[67]=J,e[68]=d,e[69]=F,e[70]=U,e[71]=W,e[72]=te):te=e[72],te},"Pe"),Ae={busy:"",editedMetadata:"",editedTtl:"",editedValue:"",loadError:null,loading:!0,value:null,writeError:null},ze=i((l,e)=>{switch(e.type){case"deleteStart":return{...l,busy:"deleting",writeError:null};case"editMetadata":return{...l,editedMetadata:e.value};case"editTtl":return{...l,editedTtl:e.value};case"editValue":return{...l,editedValue:e.value};case"loaded":return{...l,editedMetadata:e.metadata===null||e.metadata===void 0?"":JSON.stringify(e.metadata,null,2),editedValue:e.value??"",loading:!1,value:e.value};case"loadFailed":return{...l,loadError:e.error,loading:!1};case"saveOk":return{...l,busy:"",value:l.editedValue};case"saveStart":return{...l,busy:"saving",writeError:null};case"writeFailed":return{...l,busy:"",writeError:e.error};default:return l}},"je"),He=i(l=>{let e=(0,ee.c)(67),{expiration:n,keyName:u,namespace:s,onDeleted:p}=l,o=G(),t=R(),[r,y]=(0,P.useReducer)(ze,Ae),c,x;e[0]!==o||e[1]!==u||e[2]!==s?(c=i(()=>{let f={cancelled:!1};return z((async()=>{try{let j=await o.getKvValue({key:u,namespace:s});f.cancelled||y({metadata:j.metadata,type:"loaded",value:j.value})}catch(j){let H=j;f.cancelled||y({error:Z(H),type:"loadFailed"})}})()),()=>{f.cancelled=!0}},"o"),x=[o,s,u],e[0]=o,e[1]=u,e[2]=s,e[3]=c,e[4]=x):(c=e[3],x=e[4]),(0,P.useEffect)(c,x);let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=i(f=>{y({type:"editValue",value:f.target.value})},"k"),e[5]=b):b=e[5];let _=b,V;e[6]===Symbol.for("react.memo_cache_sentinel")?(V=i(f=>{y({type:"editMetadata",value:f})},"K"),e[6]=V):V=e[6];let T=V,h;e[7]!==r.editedValue?(h=Fe(r.editedValue),e[7]=r.editedValue,e[8]=h):h=e[8];let v=h,k;e[9]!==r.editedMetadata?(k=Ke(r.editedMetadata),e[9]=r.editedMetadata,e[10]=k):k=e[10];let N=k,C;e[11]!==r.editedTtl?(C=Ve(r.editedTtl),e[11]=r.editedTtl,e[12]=C):C=e[12];let w=C,g;e[13]!==v?(g=i(()=>{v!==void 0&&y({type:"editValue",value:v})},"y"),e[13]=v,e[14]=g):g=e[14];let S=g,E;e[15]!==o||e[16]!==n||e[17]!==u||e[18]!==N||e[19]!==s||e[20]!==r.editedMetadata||e[21]!==r.editedTtl||e[22]!==r.editedValue||e[23]!==t?(E=i(()=>{if(!N){y({error:t("Metadata must be valid JSON."),type:"writeFailed"});return}y({type:"saveStart"}),z((async()=>{try{await o.putKvValue(Te({metadata:r.editedMetadata,ttl:r.editedTtl,value:r.editedValue},u,s,n)),y({type:"saveOk"})}catch(f){y({error:Z(f),type:"writeFailed"})}})())},"F"),e[15]=o,e[16]=n,e[17]=u,e[18]=N,e[19]=s,e[20]=r.editedMetadata,e[21]=r.editedTtl,e[22]=r.editedValue,e[23]=t,e[24]=E):E=e[24];let B=E,M;e[25]!==o||e[26]!==u||e[27]!==s||e[28]!==p?(M=i(()=>{y({type:"deleteStart"}),z((async()=>{try{await o.deleteKvKey({key:u,namespace:s}),p(u)}catch(f){y({error:Z(f),type:"writeFailed"})}})())},"I"),e[25]=o,e[26]=u,e[27]=s,e[28]=p,e[29]=M):M=e[29];let J=M,L;e[30]!==u?(L=i(()=>{de(u)},"A"),e[30]=u,e[31]=L):L=e[31];let I;e[32]!==t?(I=t("Copy key"),e[32]=t,e[33]=I):I=e[33];let d;e[34]!==L||e[35]!==I?(d=(0,a.jsx)("div",{className:"mb-2 flex justify-end",children:(0,a.jsx)($,{"data-testid":"kv-copy-key-btn",onClick:L,size:"sm",variant:"outline",children:I})}),e[34]=L,e[35]=I,e[36]=d):d=e[36];let m;e[37]!==r.loadError?(m=r.loadError!==null&&(0,a.jsx)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-value-error",role:"alert",children:r.loadError}),e[37]=r.loadError,e[38]=m):m=e[38];let F;e[39]!==r.loading||e[40]!==t?(F=r.loading&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-value-loading",children:t("Loading\u2026")}),e[39]=r.loading,e[40]=t,e[41]=F):F=e[41];let O;e[42]!==v||e[43]!==N||e[44]!==J||e[45]!==S||e[46]!==B||e[47]!==r.busy||e[48]!==r.editedMetadata||e[49]!==r.editedValue||e[50]!==r.loading||e[51]!==r.value||e[52]!==r.writeError||e[53]!==t||e[54]!==w?(O=!r.loading&&r.value!==null&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[(0,a.jsx)(q,{className:"text-xs",htmlFor:"kv-value-editor",children:t("Value")}),v!==void 0&&(0,a.jsx)(he,{variant:"secondary",children:t("JSON")}),(0,a.jsx)("span",{className:"ml-auto text-xs tabular-nums text-muted-foreground","data-testid":"kv-value-size",children:ge(Je(r.editedValue))})]}),(0,a.jsx)("textarea",{"aria-label":t("KV value"),className:"mb-2 min-h-[8rem] w-full rounded border border-border bg-muted/30 p-2 font-mono text-xs","data-testid":"kv-value-editor",id:"kv-value-editor",onChange:_,value:r.editedValue}),(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap gap-2",children:[(0,a.jsx)($,{"data-testid":"kv-format-btn",disabled:v===void 0,onClick:S,size:"sm",variant:"outline",children:t("Format JSON")}),(0,a.jsx)($,{"data-testid":"kv-copy-value-btn",onClick:i(()=>{de(r.editedValue)},"onClick"),size:"sm",variant:"outline",children:t("Copy value")})]}),(0,a.jsx)(Me,{helper:t("Leave blank to keep the current expiration."),id:"kv-ttl-input",invalid:!w,onChange:i(f=>{y({type:"editTtl",value:f})},"onChange"),testId:"kv-ttl-input"}),(0,a.jsx)(Ie,{id:"kv-metadata-editor",invalidTestId:"kv-metadata-invalid",onChange:T,testId:"kv-metadata-editor",valid:N,value:r.editedMetadata}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)($,{"data-testid":"kv-save-btn",disabled:r.busy!==""||!N||!w,onClick:B,children:r.busy==="saving"?t("Saving\u2026"):t("Save")}),(0,a.jsx)($,{"data-testid":"kv-delete-btn",disabled:r.busy!=="",onClick:J,variant:"destructive",children:r.busy==="deleting"?t("Deleting\u2026"):t("Delete")})]}),r.writeError!==null&&(0,a.jsx)("p",{className:"mt-2 text-sm text-destructive","data-testid":"kv-save-error",role:"alert",children:r.writeError})]}),e[42]=v,e[43]=N,e[44]=J,e[45]=S,e[46]=B,e[47]=r.busy,e[48]=r.editedMetadata,e[49]=r.editedValue,e[50]=r.loading,e[51]=r.value,e[52]=r.writeError,e[53]=t,e[54]=w,e[55]=O):O=e[55];let K;e[56]!==r.loadError||e[57]!==r.loading||e[58]!==r.value||e[59]!==t?(K=!r.loading&&r.value===null&&r.loadError===null&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-absent",children:t("Key is absent or has no value.")}),e[56]=r.loadError,e[57]=r.loading,e[58]=r.value,e[59]=t,e[60]=K):K=e[60];let D;return e[61]!==d||e[62]!==m||e[63]!==F||e[64]!==O||e[65]!==K?(D=(0,a.jsxs)("div",{className:"px-4 pb-4","data-testid":"kv-value-section",children:[d,m,F,O,K]}),e[61]=d,e[62]=m,e[63]=F,e[64]=O,e[65]=K,e[66]=D):D=e[66],D},"He"),Se=100,Ze={appliedPrefix:"",bulk:[],bulkBusy:!1,bulkError:null,cursor:null,keys:null,listComplete:!1,loadError:null,loading:!1,prefixInput:"",reloadNonce:0,selectedKey:null},Re=i((l,e)=>{switch(e.type){case"appendPage":return e.generation!==l.reloadNonce?l:{...l,cursor:e.cursor,keys:[...l.keys??[],...e.keys],listComplete:e.listComplete,loading:!1};case"applyFilter":return{...l,appliedPrefix:l.prefixInput,bulk:[],bulkError:null,cursor:null,keys:null,listComplete:!1,reloadNonce:l.reloadNonce+1,selectedKey:null};case"bulkDeleted":{let n=new Set(e.deleted);return{...l,bulk:l.bulk.filter(u=>!n.has(u)),bulkBusy:!1,bulkError:e.error,keys:l.keys===null?null:l.keys.filter(u=>!n.has(u.name)),selectedKey:l.selectedKey!==null&&n.has(l.selectedKey)?null:l.selectedKey}}case"bulkDeleteStart":return{...l,bulkBusy:!0,bulkError:null};case"firstPage":return{...l,cursor:e.cursor,keys:e.keys,listComplete:e.listComplete,loading:!1};case"keyDeleted":return{...l,bulk:l.bulk.filter(n=>n!==e.name),keys:l.keys===null?null:l.keys.filter(n=>n.name!==e.name),selectedKey:null};case"loadFailed":return e.generation!==void 0&&e.generation!==l.reloadNonce?l:{...l,loadError:e.error,loading:!1};case"loadStart":return{...l,loadError:null,loading:!0};case"prefixInput":return{...l,prefixInput:e.value};case"reload":return{...l,bulk:[],bulkError:null,reloadNonce:l.reloadNonce+1,selectedKey:null};case"selectKey":return{...l,selectedKey:e.name};case"toggleAllBulk":return{...l,bulk:e.names};case"toggleBulk":return{...l,bulk:l.bulk.includes(e.name)?l.bulk.filter(n=>n!==e.name):[...l.bulk,e.name]};default:return l}},"ze"),Ue=i(({namespace:l})=>{let e=G(),n=R(),[u,s]=(0,P.useReducer)(Re,Ze),{appliedPrefix:p,bulk:o,bulkBusy:t,bulkError:r,cursor:y,keys:c,listComplete:x,loadError:b,loading:_,prefixInput:V,reloadNonce:T,selectedKey:h}=u,[v,k]=(0,P.useState)(!1);(0,P.useEffect)(()=>{let d={cancelled:!1};return z((async()=>{s({type:"loadStart"});try{let m=await e.listKvKeys({limit:Se,namespace:l,prefix:p===""?void 0:p});d.cancelled||s({cursor:m.cursor??null,keys:m.keys,listComplete:m.listComplete,type:"firstPage"})}catch(m){d.cancelled||s({error:Z(m),type:"loadFailed"})}})()),()=>{d.cancelled=!0}},[e,l,p,T]);let N=i(d=>{s({type:"prefixInput",value:d.target.value})},"x"),C=i(()=>{s({type:"applyFilter"})},"N"),w=i(d=>{s({name:d.currentTarget.dataset.key??null,type:"selectKey"})},"C"),g=i(()=>{if(y===null)return;s({type:"loadStart"});let d=T;z((async()=>{try{let m=await e.listKvKeys({cursor:y,limit:Se,namespace:l,prefix:p===""?void 0:p});s({cursor:m.cursor??null,generation:d,keys:m.keys,listComplete:m.listComplete,type:"appendPage"})}catch(m){s({error:Z(m),generation:d,type:"loadFailed"})}})())},"y"),S=i(d=>{s({name:d,type:"keyDeleted"})},"S"),E=i(d=>{s({name:d,type:"toggleBulk"})},"F"),B=i(d=>{s({names:d&&c!==null?c.map(m=>m.name):[],type:"toggleAllBulk"})},"O"),M=i(()=>{if(o.length===0)return;let d=[...o];s({type:"bulkDeleteStart"}),z((async()=>{let m=await Promise.allSettled(d.map(K=>e.deleteKvKey({key:K,namespace:l}))),F=d.filter((K,D)=>m[D]?.status==="fulfilled"),O=d.length-F.length;s({deleted:F,error:O>0?n("Failed to delete {count} keys.",{count:O}):null,type:"bulkDeleted"})})())},"I"),J=i(()=>{k(!1),s({type:"reload"})},"D"),L=c!==null&&c.length>0&&o.length===c.length,I=new Set(o);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("section",{className:"border border-border bg-card p-3","data-testid":"kv-keys-section",children:[(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[(0,a.jsx)(ae,{"aria-label":n("Filter keys by prefix"),className:"min-w-[16rem] flex-1","data-testid":"kv-prefix-input",onChange:N,placeholder:n("Filter by prefix\u2026"),value:V}),(0,a.jsx)($,{"data-testid":"kv-filter-btn",disabled:_,onClick:C,children:n("Filter")}),(0,a.jsx)($,{"data-testid":"kv-new-key-btn",onClick:i(()=>{k(d=>!d)},"onClick"),variant:"outline",children:n("New key")}),o.length>0&&(0,a.jsx)($,{"data-testid":"kv-bulk-delete-btn",disabled:t,onClick:M,variant:"destructive",children:t?n("Deleting\u2026"):n("Delete {count}",{count:o.length})})]}),r!==null&&(0,a.jsx)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-bulk-error",role:"alert",children:r}),b!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"kv-keys-error",role:"alert",children:b}),c!==null&&c.length===0&&!_&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-no-keys",children:n("No keys.")}),c!==null&&c.length>0&&(0,a.jsx)(re,{className:"overflow-hidden py-0",children:(0,a.jsx)(ne,{className:"px-0",children:(0,a.jsxs)(se,{"data-testid":"kv-key-table",children:[(0,a.jsx)(ie,{children:(0,a.jsxs)(Q,{children:[(0,a.jsx)(X,{className:"w-10",children:(0,a.jsx)(ue,{"aria-label":n("Select all"),checked:L,"data-testid":"kv-select-all",onCheckedChange:B})}),(0,a.jsx)(X,{children:n("Key")}),(0,a.jsx)(X,{children:n("Expiration")})]})}),(0,a.jsx)(oe,{children:c.map(d=>(0,a.jsxs)(Q,{className:d.name===h?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-key":d.name,"data-testid":`kv-key-row-${d.name}`,onClick:w,children:[(0,a.jsx)(Y,{onClick:i(m=>{m.stopPropagation()},"onClick"),children:(0,a.jsx)(ue,{"aria-label":n("Select {name}",{name:d.name}),checked:I.has(d.name),"data-testid":`kv-select-${d.name}`,onCheckedChange:i(()=>{E(d.name)},"onCheckedChange")})}),(0,a.jsx)(Y,{className:"font-mono text-xs",children:d.name}),(0,a.jsx)(Y,{className:"tabular-nums text-xs",children:Le(d.expiration)})]},d.name))})]})})}),!x&&y!==null&&(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)($,{"data-testid":"kv-load-more",disabled:_,onClick:g,variant:"outline",children:n(_?"Loading\u2026":"Load more")})})]}),(0,a.jsx)(me,{onOpenChange:i(d=>{d||k(!1)},"onOpenChange"),open:v,children:(0,a.jsxs)(ve,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-create-sheet",side:"right",children:[(0,a.jsx)(pe,{children:(0,a.jsx)(ye,{children:n("New key")})}),(0,a.jsx)(je,{namespace:l,onCancel:i(()=>{k(!1)},"onCancel"),onCreated:J})]})}),(0,a.jsx)(me,{onOpenChange:i(d=>{d||s({name:null,type:"selectKey"})},"onOpenChange"),open:h!==null,children:(0,a.jsxs)(ve,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-editor-sheet",side:"right",children:[(0,a.jsx)(pe,{children:(0,a.jsx)(ye,{className:"truncate font-mono text-xs",children:h})}),h!==null&&(0,a.jsx)(He,{expiration:c?.find(d=>d.name===h)?.expiration,keyName:h,namespace:l,onDeleted:S},`${l}:${h}`)]})})]})},"Ue"),it=i(({loadNamespaces:l}={})=>{let e=G(),n=R(),[u,s]=(0,P.useState)(null),[p,o]=(0,P.useState)(null),[t,r]=(0,P.useState)(null);(0,P.useEffect)(()=>{let c={cancelled:!1};return z((async()=>{try{let x=await(l??(()=>e.listKvNamespaces()))();c.cancelled||(s(x),o(null),r(b=>b??x[0]?.binding??null))}catch(x){c.cancelled||(s(null),o(Z(x)))}})()),()=>{c.cancelled=!0}},[e,l]);let y=i(c=>{r(c.currentTarget.dataset.ns??null)},"f");return(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-kv-browser",children:[p!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"kv-ns-error",role:"alert",children:p}),u!==null&&u.length===0&&(0,a.jsx)(ke,{description:n("Add a kv_namespaces binding to wrangler.jsonc \u2014 it appears here automatically, no wiring needed."),icon:(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M5 5h14v4H5V5Zm0 5h14v4H5v-4Zm0 5h14v4H5v-4Z"})}),testId:"kv-empty",title:n("No KV namespaces.")}),u!==null&&u.length>0&&(0,a.jsx)(re,{className:"overflow-hidden py-0",children:(0,a.jsx)(ne,{className:"px-0",children:(0,a.jsxs)(se,{"data-testid":"kv-namespace-table",children:[(0,a.jsx)(ie,{children:(0,a.jsx)(Q,{children:(0,a.jsx)(X,{children:n("Namespace")})})}),(0,a.jsx)(oe,{children:u.map(c=>(0,a.jsx)(Q,{className:c.binding===t?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-ns":c.binding,"data-testid":`kv-ns-row-${c.binding}`,onClick:y,children:(0,a.jsx)(Y,{className:"font-mono text-xs",children:c.binding})},c.binding))})]})})}),t!==null&&(0,a.jsx)(Ue,{namespace:t},t)]})},"ut");export{it as KvBrowser};
1
+ import{a as be,b as fe,c as xe,d as Ne,e as Ce}from"./chunk-5QR2SQIS.js";import"./chunk-NRP22GKC.js";import"./chunk-OPM7ESDV.js";import{a as ce}from"./chunk-FPI7AMQJ.js";import{a as ue}from"./chunk-7RKB5KS7.js";import{a as q}from"./chunk-37WYCOQ2.js";import{g as me,h as ve,i as pe,j as ye}from"./chunk-QA5RUU7W.js";import"./chunk-XGCIDUJF.js";import"./chunk-LSNLFUZ6.js";import"./chunk-CCDX5RYT.js";import"./chunk-OYCUPD3Q.js";import"./chunk-NXQW5E6W.js";import"./chunk-UC7MNI2F.js";import"./chunk-SA2OGF3F.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import"./chunk-WJRYEML4.js";import"./chunk-FUYEZFBP.js";import"./chunk-RGMVGZV4.js";import"./chunk-OQ6I6OXT.js";import{i as ae}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{a as $}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as he}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import"./chunk-55UGUCQ6.js";import"./chunk-4ZEL6BYL.js";import"./chunk-QTDX7WSP.js";import{l as G}from"./chunk-KPRNLQKZ.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as ke}from"./chunk-RWVIV3U7.js";import{a as se,b as ie,c as oe,d as Q,e as X,f as Y}from"./chunk-HCTJKP5J.js";import{a as re,e as ne}from"./chunk-2IKDEUCX.js";import{d as R,h as Z,m as ge,q as z,t as de}from"./chunk-74IYYDDI.js";import{a as i,d as le,e as Oe,f as _e,g as De}from"./chunk-I26MS5PJ.js";var P=le(Oe(),1);var ee=le(_e(),1);var a=le(De(),1);var Be=i(l=>{let e=l.trim();if(e==="")return;let n=Number(e);return Number.isFinite(n)&&n>0?Math.floor(n):void 0},"Be"),Le=i(l=>l===void 0?"\u2014":new Date(l*1e3).toISOString(),"Oe"),Je=i(l=>new TextEncoder().encode(l).length,"Ae"),Fe=i(l=>{if(l.trim()!=="")try{return JSON.stringify(JSON.parse(l),void 0,2)}catch{return}},"ge"),Ke=i(l=>{if(l.trim()==="")return!0;try{return JSON.parse(l),!0}catch{return!1}},"xe"),Ee=[{key:"seconds",seconds:1},{key:"minutes",seconds:60},{key:"hours",seconds:3600},{key:"days",seconds:86400}],we=i((l,e)=>{let n=l.trim();if(n==="")return"";let u=Number(n),s=Ee.find(p=>p.key===e)?.seconds??1;return Number.isFinite(u)&&u>0?String(Math.round(u*s)):n},"ue"),Ve=i(l=>{let e=l.trim();if(e==="")return!0;let n=Number(e);return Number.isInteger(n)&&n>=60},"Ce"),Te=i((l,e,n,u)=>{let s=Be(l.ttl);return{expiration:s===void 0?u:void 0,expirationTtl:s,key:e,metadata:l.metadata.trim()===""?void 0:JSON.parse(l.metadata),namespace:n,value:l.value}},"Se"),Me=i(l=>{let e=(0,ee.c)(60),{helper:n,id:u,invalid:s,onChange:p,testId:o}=l,t=R(),[r,y]=(0,P.useState)(""),[c,x]=(0,P.useState)("seconds"),b;e[0]!==p||e[1]!==c?(b=i(f=>{y(f.target.value),p(we(f.target.value,c))},"k"),e[0]=p,e[1]=c,e[2]=b):b=e[2];let _=b,V;e[3]!==r||e[4]!==p?(V=i(f=>{f!==null&&(x(f),p(we(r,f)))},"K"),e[3]=r,e[4]=p,e[5]=V):V=e[5];let T=V,h;e[6]!==t?(h=t("days"),e[6]=t,e[7]=h):h=e[7];let v;e[8]!==t?(v=t("hours"),e[8]=t,e[9]=v):v=e[9];let k;e[10]!==t?(k=t("minutes"),e[10]=t,e[11]=k):k=e[11];let N;e[12]!==t?(N=t("seconds"),e[12]=t,e[13]=N):N=e[13];let C;e[14]!==h||e[15]!==v||e[16]!==k||e[17]!==N?(C={days:h,hours:v,minutes:k,seconds:N},e[14]=h,e[15]=v,e[16]=k,e[17]=N,e[18]=C):C=e[18];let w=C,g;e[19]!==t?(g=t("Expires after"),e[19]=t,e[20]=g):g=e[20];let S;e[21]!==u||e[22]!==g?(S=(0,a.jsx)(q,{className:"text-xs",htmlFor:u,children:g}),e[21]=u,e[22]=g,e[23]=S):S=e[23];let E;e[24]!==t?(E=t("No expiration"),e[24]=t,e[25]=E):E=e[25];let B;e[26]!==r||e[27]!==u||e[28]!==s||e[29]!==_||e[30]!==E||e[31]!==o?(B=(0,a.jsx)(ae,{"aria-invalid":s,className:"flex-1","data-testid":o,id:u,inputMode:"numeric",onChange:_,placeholder:E,value:r}),e[26]=r,e[27]=u,e[28]=s,e[29]=_,e[30]=E,e[31]=o,e[32]=B):B=e[32];let M;e[33]!==t?(M=t("TTL unit"),e[33]=t,e[34]=M):M=e[34];let J=`${o}-unit`,L;e[35]===Symbol.for("react.memo_cache_sentinel")?(L=(0,a.jsx)(fe,{}),e[35]=L):L=e[35];let I;e[36]!==M||e[37]!==J?(I=(0,a.jsx)(xe,{"aria-label":M,className:"w-[7.5rem]","data-testid":J,children:L}),e[36]=M,e[37]=J,e[38]=I):I=e[38];let d;e[39]!==w?(d=Ee.map(f=>(0,a.jsx)(Ce,{value:f.key,children:w[f.key]},f.key)),e[39]=w,e[40]=d):d=e[40];let m;e[41]!==d?(m=(0,a.jsx)(Ne,{children:d}),e[41]=d,e[42]=m):m=e[42];let F;e[43]!==T||e[44]!==I||e[45]!==m||e[46]!==c?(F=(0,a.jsxs)(be,{onValueChange:T,value:c,children:[I,m]}),e[43]=T,e[44]=I,e[45]=m,e[46]=c,e[47]=F):F=e[47];let O;e[48]!==B||e[49]!==F?(O=(0,a.jsxs)("div",{className:"flex gap-2",children:[B,F]}),e[48]=B,e[49]=F,e[50]=O):O=e[50];let K;e[51]!==n||e[52]!==s||e[53]!==t||e[54]!==o?(K=s?(0,a.jsx)("p",{className:"text-xs text-destructive","data-testid":`${o}-invalid`,children:t("TTL must be at least 60 seconds.")}):n!==void 0&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:n}),e[51]=n,e[52]=s,e[53]=t,e[54]=o,e[55]=K):K=e[55];let D;return e[56]!==O||e[57]!==K||e[58]!==S?(D=(0,a.jsxs)("div",{className:"mb-3 grid gap-1",children:[S,O,K]}),e[56]=O,e[57]=K,e[58]=S,e[59]=D):D=e[59],D},"we"),Ie=i(l=>{let e=(0,ee.c)(36),{id:n,invalidTestId:u,onChange:s,testId:p,valid:o,value:t}=l,r=R(),y;e[0]!==t?(y=Fe(t),e[0]=t,e[1]=y):y=e[1];let c=y,x;e[2]!==r?(x=r("Metadata (JSON)"),e[2]=r,e[3]=x):x=e[3];let b;e[4]!==n||e[5]!==x?(b=(0,a.jsx)(q,{className:"text-xs",htmlFor:n,children:x}),e[4]=n,e[5]=x,e[6]=b):b=e[6];let _=`${p}-format`,V=c===void 0,T;e[7]!==c||e[8]!==s?(T=i(()=>{c!==void 0&&s(c)},"V"),e[7]=c,e[8]=s,e[9]=T):T=e[9];let h;e[10]!==r?(h=r("Format JSON"),e[10]=r,e[11]=h):h=e[11];let v;e[12]!==_||e[13]!==V||e[14]!==T||e[15]!==h?(v=(0,a.jsx)($,{"data-testid":_,disabled:V,onClick:T,size:"sm",variant:"outline",children:h}),e[12]=_,e[13]=V,e[14]=T,e[15]=h,e[16]=v):v=e[16];let k;e[17]!==b||e[18]!==v?(k=(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[b,v]}),e[17]=b,e[18]=v,e[19]=k):k=e[19];let N=!o,C;e[20]!==s?(C=i(E=>{s(E.target.value)},"N"),e[20]=s,e[21]=C):C=e[21];let w;e[22]!==n||e[23]!==N||e[24]!==C||e[25]!==p||e[26]!==t?(w=(0,a.jsx)(ce,{"aria-invalid":N,className:"min-h-[4rem] font-mono text-xs","data-testid":p,id:n,onChange:C,value:t}),e[22]=n,e[23]=N,e[24]=C,e[25]=p,e[26]=t,e[27]=w):w=e[27];let g;e[28]!==u||e[29]!==r||e[30]!==o?(g=!o&&(0,a.jsx)("p",{className:"text-xs text-destructive","data-testid":u,children:r("Metadata must be valid JSON.")}),e[28]=u,e[29]=r,e[30]=o,e[31]=g):g=e[31];let S;return e[32]!==w||e[33]!==g||e[34]!==k?(S=(0,a.jsxs)("div",{className:"mb-3 grid gap-1",children:[k,w,g]}),e[32]=w,e[33]=g,e[34]=k,e[35]=S):S=e[35],S},"Te"),Pe={busy:!1,error:null,metadata:"",name:"",ttl:"",value:""},$e=i((l,e)=>{switch(e.type){case"setField":return{...l,[e.field]:e.value};case"submitFailed":return{...l,busy:!1,error:e.error};case"submitStart":return{...l,busy:!0,error:null};default:return l}},"Je"),je=i(l=>{let e=(0,ee.c)(73),{namespace:n,onCancel:u,onCreated:s}=l,p=G(),o=R(),[t,r]=(0,P.useReducer)($e,Pe),y;e[0]!==t.metadata?(y=Ke(t.metadata),e[0]=t.metadata,e[1]=y):y=e[1];let c=y,x;e[2]!==t.ttl?(x=Ve(t.ttl),e[2]=t.ttl,e[3]=x):x=e[3];let b=x,_;e[4]!==c||e[5]!==t.busy||e[6]!==t.name||e[7]!==b?(_=t.name.trim()!==""&&c&&b&&!t.busy,e[4]=c,e[5]=t.busy,e[6]=t.name,e[7]=b,e[8]=_):_=e[8];let V=_,T;e[9]!==V||e[10]!==p||e[11]!==n||e[12]!==s||e[13]!==t.metadata||e[14]!==t.name||e[15]!==t.ttl||e[16]!==t.value?(T=i(()=>{V&&(r({type:"submitStart"}),z((async()=>{try{await p.putKvValue(Te({metadata:t.metadata,ttl:t.ttl,value:t.value},t.name,n)),s()}catch(A){r({error:Z(A),type:"submitFailed"})}})()))},"V"),e[9]=V,e[10]=p,e[11]=n,e[12]=s,e[13]=t.metadata,e[14]=t.name,e[15]=t.ttl,e[16]=t.value,e[17]=T):T=e[17];let h=T,v;e[18]!==o?(v=o("Key name"),e[18]=o,e[19]=v):v=e[19];let k;e[20]!==v?(k=(0,a.jsx)(q,{className:"text-xs",htmlFor:"kv-create-name",children:v}),e[20]=v,e[21]=k):k=e[21];let N;e[22]===Symbol.for("react.memo_cache_sentinel")?(N=i(A=>{r({field:"name",type:"setField",value:A.target.value})},"x"),e[22]=N):N=e[22];let C;e[23]!==o?(C=o("Key name"),e[23]=o,e[24]=C):C=e[24];let w;e[25]!==t.name||e[26]!==C?(w=(0,a.jsx)(ae,{autoFocus:!0,"data-testid":"kv-create-name",id:"kv-create-name",onChange:N,placeholder:C,value:t.name}),e[25]=t.name,e[26]=C,e[27]=w):w=e[27];let g;e[28]!==k||e[29]!==w?(g=(0,a.jsxs)("div",{className:"grid gap-1",children:[k,w]}),e[28]=k,e[29]=w,e[30]=g):g=e[30];let S;e[31]!==o?(S=o("Value"),e[31]=o,e[32]=S):S=e[32];let E;e[33]!==S?(E=(0,a.jsx)(q,{className:"text-xs",htmlFor:"kv-create-value",children:S}),e[33]=S,e[34]=E):E=e[34];let B;e[35]===Symbol.for("react.memo_cache_sentinel")?(B=i(A=>{r({field:"value",type:"setField",value:A.target.value})},"O"),e[35]=B):B=e[35];let M;e[36]!==t.value?(M=(0,a.jsx)(ce,{className:"min-h-[6rem] font-mono text-xs","data-testid":"kv-create-value",id:"kv-create-value",onChange:B,value:t.value}),e[36]=t.value,e[37]=M):M=e[37];let J;e[38]!==E||e[39]!==M?(J=(0,a.jsxs)("div",{className:"grid gap-1",children:[E,M]}),e[38]=E,e[39]=M,e[40]=J):J=e[40];let L=!b,I;e[41]===Symbol.for("react.memo_cache_sentinel")?(I=i(A=>{r({field:"ttl",type:"setField",value:A})},"_"),e[41]=I):I=e[41];let d;e[42]!==L?(d=(0,a.jsx)(Me,{id:"kv-create-ttl",invalid:L,onChange:I,testId:"kv-create-ttl"}),e[42]=L,e[43]=d):d=e[43];let m;e[44]===Symbol.for("react.memo_cache_sentinel")?(m=i(A=>{r({field:"metadata",type:"setField",value:A})},"u"),e[44]=m):m=e[44];let F;e[45]!==c||e[46]!==t.metadata?(F=(0,a.jsx)(Ie,{id:"kv-create-metadata",invalidTestId:"kv-create-metadata-invalid",onChange:m,testId:"kv-create-metadata",valid:c,value:t.metadata}),e[45]=c,e[46]=t.metadata,e[47]=F):F=e[47];let O=!V,K;e[48]!==t.busy||e[49]!==o?(K=t.busy?o("Creating\u2026"):o("Create key"),e[48]=t.busy,e[49]=o,e[50]=K):K=e[50];let D;e[51]!==h||e[52]!==O||e[53]!==K?(D=(0,a.jsx)($,{"data-testid":"kv-create-submit",disabled:O,onClick:h,children:K}),e[51]=h,e[52]=O,e[53]=K,e[54]=D):D=e[54];let f=t.busy,j;e[55]!==o?(j=o("Cancel"),e[55]=o,e[56]=j):j=e[56];let H;e[57]!==u||e[58]!==t.busy||e[59]!==j?(H=(0,a.jsx)($,{"data-testid":"kv-create-cancel",disabled:f,onClick:u,variant:"outline",children:j}),e[57]=u,e[58]=t.busy,e[59]=j,e[60]=H):H=e[60];let U;e[61]!==D||e[62]!==H?(U=(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[D,H]}),e[61]=D,e[62]=H,e[63]=U):U=e[63];let W;e[64]!==t.error?(W=t.error!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"kv-create-error",role:"alert",children:t.error}),e[64]=t.error,e[65]=W):W=e[65];let te;return e[66]!==g||e[67]!==J||e[68]!==d||e[69]!==F||e[70]!==U||e[71]!==W?(te=(0,a.jsxs)("div",{className:"grid gap-3 px-4 pb-4","data-testid":"kv-create-form",children:[g,J,d,F,U,W]}),e[66]=g,e[67]=J,e[68]=d,e[69]=F,e[70]=U,e[71]=W,e[72]=te):te=e[72],te},"Pe"),Ae={busy:"",editedMetadata:"",editedTtl:"",editedValue:"",loadError:null,loading:!0,value:null,writeError:null},ze=i((l,e)=>{switch(e.type){case"deleteStart":return{...l,busy:"deleting",writeError:null};case"editMetadata":return{...l,editedMetadata:e.value};case"editTtl":return{...l,editedTtl:e.value};case"editValue":return{...l,editedValue:e.value};case"loaded":return{...l,editedMetadata:e.metadata===null||e.metadata===void 0?"":JSON.stringify(e.metadata,null,2),editedValue:e.value??"",loading:!1,value:e.value};case"loadFailed":return{...l,loadError:e.error,loading:!1};case"saveOk":return{...l,busy:"",value:l.editedValue};case"saveStart":return{...l,busy:"saving",writeError:null};case"writeFailed":return{...l,busy:"",writeError:e.error};default:return l}},"je"),He=i(l=>{let e=(0,ee.c)(67),{expiration:n,keyName:u,namespace:s,onDeleted:p}=l,o=G(),t=R(),[r,y]=(0,P.useReducer)(ze,Ae),c,x;e[0]!==o||e[1]!==u||e[2]!==s?(c=i(()=>{let f={cancelled:!1};return z((async()=>{try{let j=await o.getKvValue({key:u,namespace:s});f.cancelled||y({metadata:j.metadata,type:"loaded",value:j.value})}catch(j){let H=j;f.cancelled||y({error:Z(H),type:"loadFailed"})}})()),()=>{f.cancelled=!0}},"o"),x=[o,s,u],e[0]=o,e[1]=u,e[2]=s,e[3]=c,e[4]=x):(c=e[3],x=e[4]),(0,P.useEffect)(c,x);let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=i(f=>{y({type:"editValue",value:f.target.value})},"k"),e[5]=b):b=e[5];let _=b,V;e[6]===Symbol.for("react.memo_cache_sentinel")?(V=i(f=>{y({type:"editMetadata",value:f})},"K"),e[6]=V):V=e[6];let T=V,h;e[7]!==r.editedValue?(h=Fe(r.editedValue),e[7]=r.editedValue,e[8]=h):h=e[8];let v=h,k;e[9]!==r.editedMetadata?(k=Ke(r.editedMetadata),e[9]=r.editedMetadata,e[10]=k):k=e[10];let N=k,C;e[11]!==r.editedTtl?(C=Ve(r.editedTtl),e[11]=r.editedTtl,e[12]=C):C=e[12];let w=C,g;e[13]!==v?(g=i(()=>{v!==void 0&&y({type:"editValue",value:v})},"y"),e[13]=v,e[14]=g):g=e[14];let S=g,E;e[15]!==o||e[16]!==n||e[17]!==u||e[18]!==N||e[19]!==s||e[20]!==r.editedMetadata||e[21]!==r.editedTtl||e[22]!==r.editedValue||e[23]!==t?(E=i(()=>{if(!N){y({error:t("Metadata must be valid JSON."),type:"writeFailed"});return}y({type:"saveStart"}),z((async()=>{try{await o.putKvValue(Te({metadata:r.editedMetadata,ttl:r.editedTtl,value:r.editedValue},u,s,n)),y({type:"saveOk"})}catch(f){y({error:Z(f),type:"writeFailed"})}})())},"F"),e[15]=o,e[16]=n,e[17]=u,e[18]=N,e[19]=s,e[20]=r.editedMetadata,e[21]=r.editedTtl,e[22]=r.editedValue,e[23]=t,e[24]=E):E=e[24];let B=E,M;e[25]!==o||e[26]!==u||e[27]!==s||e[28]!==p?(M=i(()=>{y({type:"deleteStart"}),z((async()=>{try{await o.deleteKvKey({key:u,namespace:s}),p(u)}catch(f){y({error:Z(f),type:"writeFailed"})}})())},"I"),e[25]=o,e[26]=u,e[27]=s,e[28]=p,e[29]=M):M=e[29];let J=M,L;e[30]!==u?(L=i(()=>{de(u)},"A"),e[30]=u,e[31]=L):L=e[31];let I;e[32]!==t?(I=t("Copy key"),e[32]=t,e[33]=I):I=e[33];let d;e[34]!==L||e[35]!==I?(d=(0,a.jsx)("div",{className:"mb-2 flex justify-end",children:(0,a.jsx)($,{"data-testid":"kv-copy-key-btn",onClick:L,size:"sm",variant:"outline",children:I})}),e[34]=L,e[35]=I,e[36]=d):d=e[36];let m;e[37]!==r.loadError?(m=r.loadError!==null&&(0,a.jsx)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-value-error",role:"alert",children:r.loadError}),e[37]=r.loadError,e[38]=m):m=e[38];let F;e[39]!==r.loading||e[40]!==t?(F=r.loading&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-value-loading",children:t("Loading\u2026")}),e[39]=r.loading,e[40]=t,e[41]=F):F=e[41];let O;e[42]!==v||e[43]!==N||e[44]!==J||e[45]!==S||e[46]!==B||e[47]!==r.busy||e[48]!==r.editedMetadata||e[49]!==r.editedValue||e[50]!==r.loading||e[51]!==r.value||e[52]!==r.writeError||e[53]!==t||e[54]!==w?(O=!r.loading&&r.value!==null&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[(0,a.jsx)(q,{className:"text-xs",htmlFor:"kv-value-editor",children:t("Value")}),v!==void 0&&(0,a.jsx)(he,{variant:"secondary",children:t("JSON")}),(0,a.jsx)("span",{className:"ml-auto text-xs tabular-nums text-muted-foreground","data-testid":"kv-value-size",children:ge(Je(r.editedValue))})]}),(0,a.jsx)("textarea",{"aria-label":t("KV value"),className:"mb-2 min-h-[8rem] w-full rounded border border-border bg-muted/30 p-2 font-mono text-xs","data-testid":"kv-value-editor",id:"kv-value-editor",onChange:_,value:r.editedValue}),(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap gap-2",children:[(0,a.jsx)($,{"data-testid":"kv-format-btn",disabled:v===void 0,onClick:S,size:"sm",variant:"outline",children:t("Format JSON")}),(0,a.jsx)($,{"data-testid":"kv-copy-value-btn",onClick:i(()=>{de(r.editedValue)},"onClick"),size:"sm",variant:"outline",children:t("Copy value")})]}),(0,a.jsx)(Me,{helper:t("Leave blank to keep the current expiration."),id:"kv-ttl-input",invalid:!w,onChange:i(f=>{y({type:"editTtl",value:f})},"onChange"),testId:"kv-ttl-input"}),(0,a.jsx)(Ie,{id:"kv-metadata-editor",invalidTestId:"kv-metadata-invalid",onChange:T,testId:"kv-metadata-editor",valid:N,value:r.editedMetadata}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)($,{"data-testid":"kv-save-btn",disabled:r.busy!==""||!N||!w,onClick:B,children:r.busy==="saving"?t("Saving\u2026"):t("Save")}),(0,a.jsx)($,{"data-testid":"kv-delete-btn",disabled:r.busy!=="",onClick:J,variant:"destructive",children:r.busy==="deleting"?t("Deleting\u2026"):t("Delete")})]}),r.writeError!==null&&(0,a.jsx)("p",{className:"mt-2 text-sm text-destructive","data-testid":"kv-save-error",role:"alert",children:r.writeError})]}),e[42]=v,e[43]=N,e[44]=J,e[45]=S,e[46]=B,e[47]=r.busy,e[48]=r.editedMetadata,e[49]=r.editedValue,e[50]=r.loading,e[51]=r.value,e[52]=r.writeError,e[53]=t,e[54]=w,e[55]=O):O=e[55];let K;e[56]!==r.loadError||e[57]!==r.loading||e[58]!==r.value||e[59]!==t?(K=!r.loading&&r.value===null&&r.loadError===null&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-absent",children:t("Key is absent or has no value.")}),e[56]=r.loadError,e[57]=r.loading,e[58]=r.value,e[59]=t,e[60]=K):K=e[60];let D;return e[61]!==d||e[62]!==m||e[63]!==F||e[64]!==O||e[65]!==K?(D=(0,a.jsxs)("div",{className:"px-4 pb-4","data-testid":"kv-value-section",children:[d,m,F,O,K]}),e[61]=d,e[62]=m,e[63]=F,e[64]=O,e[65]=K,e[66]=D):D=e[66],D},"He"),Se=100,Ze={appliedPrefix:"",bulk:[],bulkBusy:!1,bulkError:null,cursor:null,keys:null,listComplete:!1,loadError:null,loading:!1,prefixInput:"",reloadNonce:0,selectedKey:null},Re=i((l,e)=>{switch(e.type){case"appendPage":return e.generation!==l.reloadNonce?l:{...l,cursor:e.cursor,keys:[...l.keys??[],...e.keys],listComplete:e.listComplete,loading:!1};case"applyFilter":return{...l,appliedPrefix:l.prefixInput,bulk:[],bulkError:null,cursor:null,keys:null,listComplete:!1,reloadNonce:l.reloadNonce+1,selectedKey:null};case"bulkDeleted":{let n=new Set(e.deleted);return{...l,bulk:l.bulk.filter(u=>!n.has(u)),bulkBusy:!1,bulkError:e.error,keys:l.keys===null?null:l.keys.filter(u=>!n.has(u.name)),selectedKey:l.selectedKey!==null&&n.has(l.selectedKey)?null:l.selectedKey}}case"bulkDeleteStart":return{...l,bulkBusy:!0,bulkError:null};case"firstPage":return{...l,cursor:e.cursor,keys:e.keys,listComplete:e.listComplete,loading:!1};case"keyDeleted":return{...l,bulk:l.bulk.filter(n=>n!==e.name),keys:l.keys===null?null:l.keys.filter(n=>n.name!==e.name),selectedKey:null};case"loadFailed":return e.generation!==void 0&&e.generation!==l.reloadNonce?l:{...l,loadError:e.error,loading:!1};case"loadStart":return{...l,loadError:null,loading:!0};case"prefixInput":return{...l,prefixInput:e.value};case"reload":return{...l,bulk:[],bulkError:null,reloadNonce:l.reloadNonce+1,selectedKey:null};case"selectKey":return{...l,selectedKey:e.name};case"toggleAllBulk":return{...l,bulk:e.names};case"toggleBulk":return{...l,bulk:l.bulk.includes(e.name)?l.bulk.filter(n=>n!==e.name):[...l.bulk,e.name]};default:return l}},"ze"),Ue=i(({namespace:l})=>{let e=G(),n=R(),[u,s]=(0,P.useReducer)(Re,Ze),{appliedPrefix:p,bulk:o,bulkBusy:t,bulkError:r,cursor:y,keys:c,listComplete:x,loadError:b,loading:_,prefixInput:V,reloadNonce:T,selectedKey:h}=u,[v,k]=(0,P.useState)(!1);(0,P.useEffect)(()=>{let d={cancelled:!1};return z((async()=>{s({type:"loadStart"});try{let m=await e.listKvKeys({limit:Se,namespace:l,prefix:p===""?void 0:p});d.cancelled||s({cursor:m.cursor??null,keys:m.keys,listComplete:m.listComplete,type:"firstPage"})}catch(m){d.cancelled||s({error:Z(m),type:"loadFailed"})}})()),()=>{d.cancelled=!0}},[e,l,p,T]);let N=i(d=>{s({type:"prefixInput",value:d.target.value})},"x"),C=i(()=>{s({type:"applyFilter"})},"N"),w=i(d=>{s({name:d.currentTarget.dataset.key??null,type:"selectKey"})},"C"),g=i(()=>{if(y===null)return;s({type:"loadStart"});let d=T;z((async()=>{try{let m=await e.listKvKeys({cursor:y,limit:Se,namespace:l,prefix:p===""?void 0:p});s({cursor:m.cursor??null,generation:d,keys:m.keys,listComplete:m.listComplete,type:"appendPage"})}catch(m){s({error:Z(m),generation:d,type:"loadFailed"})}})())},"y"),S=i(d=>{s({name:d,type:"keyDeleted"})},"S"),E=i(d=>{s({name:d,type:"toggleBulk"})},"F"),B=i(d=>{s({names:d&&c!==null?c.map(m=>m.name):[],type:"toggleAllBulk"})},"O"),M=i(()=>{if(o.length===0)return;let d=[...o];s({type:"bulkDeleteStart"}),z((async()=>{let m=await Promise.allSettled(d.map(K=>e.deleteKvKey({key:K,namespace:l}))),F=d.filter((K,D)=>m[D]?.status==="fulfilled"),O=d.length-F.length;s({deleted:F,error:O>0?n("Failed to delete {count} keys.",{count:O}):null,type:"bulkDeleted"})})())},"I"),J=i(()=>{k(!1),s({type:"reload"})},"D"),L=c!==null&&c.length>0&&o.length===c.length,I=new Set(o);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("section",{className:"border border-border bg-card p-3","data-testid":"kv-keys-section",children:[(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[(0,a.jsx)(ae,{"aria-label":n("Filter keys by prefix"),className:"min-w-[16rem] flex-1","data-testid":"kv-prefix-input",onChange:N,placeholder:n("Filter by prefix\u2026"),value:V}),(0,a.jsx)($,{"data-testid":"kv-filter-btn",disabled:_,onClick:C,children:n("Filter")}),(0,a.jsx)($,{"data-testid":"kv-new-key-btn",onClick:i(()=>{k(d=>!d)},"onClick"),variant:"outline",children:n("New key")}),o.length>0&&(0,a.jsx)($,{"data-testid":"kv-bulk-delete-btn",disabled:t,onClick:M,variant:"destructive",children:t?n("Deleting\u2026"):n("Delete {count}",{count:o.length})})]}),r!==null&&(0,a.jsx)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-bulk-error",role:"alert",children:r}),b!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"kv-keys-error",role:"alert",children:b}),c!==null&&c.length===0&&!_&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-no-keys",children:n("No keys.")}),c!==null&&c.length>0&&(0,a.jsx)(re,{className:"overflow-hidden py-0",children:(0,a.jsx)(ne,{className:"px-0",children:(0,a.jsxs)(se,{"data-testid":"kv-key-table",children:[(0,a.jsx)(ie,{children:(0,a.jsxs)(Q,{children:[(0,a.jsx)(X,{className:"w-10",children:(0,a.jsx)(ue,{"aria-label":n("Select all"),checked:L,"data-testid":"kv-select-all",onCheckedChange:B})}),(0,a.jsx)(X,{children:n("Key")}),(0,a.jsx)(X,{children:n("Expiration")})]})}),(0,a.jsx)(oe,{children:c.map(d=>(0,a.jsxs)(Q,{className:d.name===h?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-key":d.name,"data-testid":`kv-key-row-${d.name}`,onClick:w,children:[(0,a.jsx)(Y,{onClick:i(m=>{m.stopPropagation()},"onClick"),children:(0,a.jsx)(ue,{"aria-label":n("Select {name}",{name:d.name}),checked:I.has(d.name),"data-testid":`kv-select-${d.name}`,onCheckedChange:i(()=>{E(d.name)},"onCheckedChange")})}),(0,a.jsx)(Y,{className:"font-mono text-xs",children:d.name}),(0,a.jsx)(Y,{className:"tabular-nums text-xs",children:Le(d.expiration)})]},d.name))})]})})}),!x&&y!==null&&(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)($,{"data-testid":"kv-load-more",disabled:_,onClick:g,variant:"outline",children:n(_?"Loading\u2026":"Load more")})})]}),(0,a.jsx)(me,{onOpenChange:i(d=>{d||k(!1)},"onOpenChange"),open:v,children:(0,a.jsxs)(ve,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-create-sheet",side:"right",children:[(0,a.jsx)(pe,{children:(0,a.jsx)(ye,{children:n("New key")})}),(0,a.jsx)(je,{namespace:l,onCancel:i(()=>{k(!1)},"onCancel"),onCreated:J})]})}),(0,a.jsx)(me,{onOpenChange:i(d=>{d||s({name:null,type:"selectKey"})},"onOpenChange"),open:h!==null,children:(0,a.jsxs)(ve,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-editor-sheet",side:"right",children:[(0,a.jsx)(pe,{children:(0,a.jsx)(ye,{className:"truncate font-mono text-xs",children:h})}),h!==null&&(0,a.jsx)(He,{expiration:c?.find(d=>d.name===h)?.expiration,keyName:h,namespace:l,onDeleted:S},`${l}:${h}`)]})})]})},"Ue"),it=i(({loadNamespaces:l}={})=>{let e=G(),n=R(),[u,s]=(0,P.useState)(null),[p,o]=(0,P.useState)(null),[t,r]=(0,P.useState)(null);(0,P.useEffect)(()=>{let c={cancelled:!1};return z((async()=>{try{let x=await(l??(()=>e.listKvNamespaces()))();c.cancelled||(s(x),o(null),r(b=>b??x[0]?.binding??null))}catch(x){c.cancelled||(s(null),o(Z(x)))}})()),()=>{c.cancelled=!0}},[e,l]);let y=i(c=>{r(c.currentTarget.dataset.ns??null)},"f");return(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-kv-browser",children:[p!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"kv-ns-error",role:"alert",children:p}),u!==null&&u.length===0&&(0,a.jsx)(ke,{description:n("Add a kv_namespaces binding to wrangler.jsonc \u2014 it appears here automatically, no wiring needed."),icon:(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M5 5h14v4H5V5Zm0 5h14v4H5v-4Zm0 5h14v4H5v-4Z"})}),testId:"kv-empty",title:n("No KV namespaces.")}),u!==null&&u.length>0&&(0,a.jsx)(re,{className:"overflow-hidden py-0",children:(0,a.jsx)(ne,{className:"px-0",children:(0,a.jsxs)(se,{"data-testid":"kv-namespace-table",children:[(0,a.jsx)(ie,{children:(0,a.jsx)(Q,{children:(0,a.jsx)(X,{children:n("Namespace")})})}),(0,a.jsx)(oe,{children:u.map(c=>(0,a.jsx)(Q,{className:c.binding===t?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-ns":c.binding,"data-testid":`kv-ns-row-${c.binding}`,onClick:y,children:(0,a.jsx)(Y,{className:"font-mono text-xs",children:c.binding})},c.binding))})]})})}),t!==null&&(0,a.jsx)(Ue,{namespace:t},t)]})},"ut");export{it as KvBrowser};
@@ -1 +1 @@
1
- import{b as y}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as R}from"./chunk-4ZPDCXIA.js";import"./chunk-NCPW7WHO.js";import"./chunk-CLXX5RVY.js";import"./chunk-55UGUCQ6.js";import{a as v}from"./chunk-4ZEL6BYL.js";import{c as $}from"./chunk-ZBHXISOD.js";import"./chunk-X6XAMP4E.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as S}from"./chunk-RWVIV3U7.js";import{a as A,b as C,c as I,d as x,e as c,f as n}from"./chunk-HCTJKP5J.js";import{a as k,e as w}from"./chunk-2IKDEUCX.js";import{d as N}from"./chunk-74IYYDDI.js";import{a as f,d as b,f as E,g as O}from"./chunk-I26MS5PJ.js";var j=b(E(),1);var r=b(O(),1);var _=f((e,t)=>({delete:e("Delete"),list:e("List"),read:e("Read"),write:e("Write")})[t],"I"),T={delete:2,list:3,read:0,write:1},B=f(e=>[...e].toSorted((t,a)=>t.bucket.localeCompare(a.bucket)||T[t.on]-T[a.on]||(t.prefix??"").localeCompare(a.prefix??"")),"O"),q=f(()=>{let e=(0,j.c)(14),t=N(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let{data:l,error:i,errorSource:d}=$(v.storageRules,a),h=l!==void 0,m;if(e[1]!==l||e[2]!==i||e[3]!==d||e[4]!==h||e[5]!==t){let g=B(Array.isArray(l?.rules)?l.rules:[]),u;e[7]!==i||e[8]!==d?(u=i!==null&&(0,r.jsx)(R,{error:d,testId:"storage-rules-error"}),e[7]=i,e[8]=d,e[9]=u):u=e[9];let o;e[10]!==t?(o=t("Storage rules are declared in code with defineStorageRule and gate ctx.storage access per bucket. This view is read-only."),e[10]=t,e[11]=o):o=e[11];let p;e[12]!==o?(p=(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"storage-rules-note",children:o}),e[12]=o,e[13]=p):p=e[13],m=(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-storage-rules-panel",children:[u,p,h&&g.length===0?(0,r.jsx)(S,{description:t("No defineStorageRule is wired through .use(storageRules(...)) in this deployment. Add one to gate object access by key prefix."),testId:"storage-rules-empty",title:t("No storage rules defined")}):(0,r.jsx)(k,{className:"overflow-hidden py-0",children:(0,r.jsx)(w,{className:"px-0",children:(0,r.jsxs)(A,{"data-testid":"storage-rules-table",children:[(0,r.jsx)(C,{children:(0,r.jsxs)(x,{children:[(0,r.jsx)(c,{children:t("Bucket")}),(0,r.jsx)(c,{children:t("Operation")}),(0,r.jsx)(c,{children:t("Key prefix")}),(0,r.jsx)(c,{children:t("Guarded by")})]})}),(0,r.jsx)(I,{children:g.map(s=>(0,r.jsxs)(x,{"data-testid":`storage-rule-${s.bucket}-${s.on}-${s.prefix??""}`,children:[(0,r.jsx)(n,{className:"font-mono text-xs",children:s.bucket}),(0,r.jsx)(n,{children:(0,r.jsx)(y,{variant:"secondary",children:_(t,s.on)})}),(0,r.jsx)(n,{className:"font-mono text-xs",children:s.prefix??(0,r.jsx)("span",{className:"text-muted-foreground",children:t("(whole bucket)")})}),(0,r.jsx)(n,{className:"font-mono text-xs text-muted-foreground",children:s.procedure})]},`${s.bucket}:${s.on}:${s.prefix??""}:${s.procedure}`))})]})})})]}),e[1]=l,e[2]=i,e[3]=d,e[4]=h,e[5]=t,e[6]=m}else m=e[6];return m},"M");export{q as default};
1
+ import{b as y}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as R}from"./chunk-R7SRERCX.js";import"./chunk-NCPW7WHO.js";import"./chunk-RGUL4AQZ.js";import"./chunk-55UGUCQ6.js";import{a as v}from"./chunk-4ZEL6BYL.js";import{c as $}from"./chunk-QTDX7WSP.js";import"./chunk-KPRNLQKZ.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as S}from"./chunk-RWVIV3U7.js";import{a as A,b as C,c as I,d as x,e as c,f as n}from"./chunk-HCTJKP5J.js";import{a as k,e as w}from"./chunk-2IKDEUCX.js";import{d as N}from"./chunk-74IYYDDI.js";import{a as f,d as b,f as E,g as O}from"./chunk-I26MS5PJ.js";var j=b(E(),1);var r=b(O(),1);var _=f((e,t)=>({delete:e("Delete"),list:e("List"),read:e("Read"),write:e("Write")})[t],"I"),T={delete:2,list:3,read:0,write:1},B=f(e=>[...e].toSorted((t,a)=>t.bucket.localeCompare(a.bucket)||T[t.on]-T[a.on]||(t.prefix??"").localeCompare(a.prefix??"")),"O"),q=f(()=>{let e=(0,j.c)(14),t=N(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let{data:l,error:i,errorSource:d}=$(v.storageRules,a),h=l!==void 0,m;if(e[1]!==l||e[2]!==i||e[3]!==d||e[4]!==h||e[5]!==t){let g=B(Array.isArray(l?.rules)?l.rules:[]),u;e[7]!==i||e[8]!==d?(u=i!==null&&(0,r.jsx)(R,{error:d,testId:"storage-rules-error"}),e[7]=i,e[8]=d,e[9]=u):u=e[9];let o;e[10]!==t?(o=t("Storage rules are declared in code with defineStorageRule and gate ctx.storage access per bucket. This view is read-only."),e[10]=t,e[11]=o):o=e[11];let p;e[12]!==o?(p=(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"storage-rules-note",children:o}),e[12]=o,e[13]=p):p=e[13],m=(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-storage-rules-panel",children:[u,p,h&&g.length===0?(0,r.jsx)(S,{description:t("No defineStorageRule is wired through .use(storageRules(...)) in this deployment. Add one to gate object access by key prefix."),testId:"storage-rules-empty",title:t("No storage rules defined")}):(0,r.jsx)(k,{className:"overflow-hidden py-0",children:(0,r.jsx)(w,{className:"px-0",children:(0,r.jsxs)(A,{"data-testid":"storage-rules-table",children:[(0,r.jsx)(C,{children:(0,r.jsxs)(x,{children:[(0,r.jsx)(c,{children:t("Bucket")}),(0,r.jsx)(c,{children:t("Operation")}),(0,r.jsx)(c,{children:t("Key prefix")}),(0,r.jsx)(c,{children:t("Guarded by")})]})}),(0,r.jsx)(I,{children:g.map(s=>(0,r.jsxs)(x,{"data-testid":`storage-rule-${s.bucket}-${s.on}-${s.prefix??""}`,children:[(0,r.jsx)(n,{className:"font-mono text-xs",children:s.bucket}),(0,r.jsx)(n,{children:(0,r.jsx)(y,{variant:"secondary",children:_(t,s.on)})}),(0,r.jsx)(n,{className:"font-mono text-xs",children:s.prefix??(0,r.jsx)("span",{className:"text-muted-foreground",children:t("(whole bucket)")})}),(0,r.jsx)(n,{className:"font-mono text-xs text-muted-foreground",children:s.procedure})]},`${s.bucket}:${s.on}:${s.prefix??""}:${s.procedure}`))})]})})})]}),e[1]=l,e[2]=i,e[3]=d,e[4]=h,e[5]=t,e[6]=m}else m=e[6];return m},"M");export{q as default};
@@ -1 +1 @@
1
- import{a as Ye}from"./chunk-ECY2JC5F.js";import"./chunk-NRP22GKC.js";import{a as Ve}from"./chunk-FPI7AMQJ.js";import{a as Xe}from"./chunk-J2OLAMJR.js";import"./chunk-UC7MNI2F.js";import{a as Ke}from"./chunk-LXCVA5SP.js";import{i as ze}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as de}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as oe}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as He}from"./chunk-4ZPDCXIA.js";import{a as Ge}from"./chunk-NCPW7WHO.js";import"./chunk-CLXX5RVY.js";import"./chunk-55UGUCQ6.js";import{a as W}from"./chunk-4ZEL6BYL.js";import{c as Ae}from"./chunk-ZBHXISOD.js";import{l as We}from"./chunk-X6XAMP4E.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as le}from"./chunk-RWVIV3U7.js";import{a as Le,b as Te,c as _e,d as z,e as I,f as w}from"./chunk-HCTJKP5J.js";import{a as Ee,e as Me}from"./chunk-2IKDEUCX.js";import{d as F,f as ie,g as ce,h as G,n as Pe,q as ue,u as Ue}from"./chunk-74IYYDDI.js";import{a as c,d as Qe,e as ct,f as ut,g as mt}from"./chunk-I26MS5PJ.js";var D=Qe(ut(),1);var A=Qe(ct(),1);var t=Qe(mt(),1);var pt=c((n,e)=>{let a=new Set(n.map(s=>s.deadLetterQueue).filter(s=>typeof s=="string"&&s!=="")),d=n.filter(s=>(s.deadLetterQueue===void 0||s.deadLetterQueue==="")&&!a.has(s.name)),r=e.filter(s=>s.deadLettered).length;return{deadLetteredCount:r,queuesWithoutDlq:d,showReliabilityWarning:d.length>0||r>0}},"ut"),Be="topic:",De=c(n=>{let e=[],a=new Map;for(let d of n)d.topic===void 0?e.push(d):a.set(d.topic,[...a.get(d.topic)??[],d]);return{plain:e,topics:a}},"Qe"),et=c(n=>`${Be}${n}`,"je"),ht=c((n,e)=>n.startsWith(Be)?(e.get(n.slice(Be.length))??[]).map(a=>a.exportName):[n],"mt"),gt=200,ft=ie(W.sendQueueMessage),xt=c(async(n,e,a)=>{let d=(await Promise.allSettled(e.map(async s=>n.query(ft,s,ce(""))))).flatMap((s,l)=>s.status==="rejected"?[{exportName:e[l]?.exportName??"",message:G(s.reason)}]:[]),[r]=d;return r===void 0?null:e.length===1?r.message:a("Not sent to {failed}",{failed:d.map(s=>`${s.exportName}: ${s.message}`).join("; ")})},"ht"),yt=ie(W.replayQueueMessage),Nt=ie(W.clearQueueMessages),Ze=96,bt=c(n=>{if(n===void 0)return"\u2014";try{return JSON.stringify(n,Pe)}catch{return"[unserializable]"}},"yt"),qt=c(n=>n.length>Ze?`${n.slice(0,Ze)}\u2026`:n,"bt"),vt=c(n=>n==="error"?"destructive":n==="retry"?"outline":"secondary","Nt"),St=c((n,e)=>e(n==="messages"?"Messages":n==="send"?"Send":"Declared"),"qt"),tt=c(n=>{let e=(0,D.c)(17),{queue:a}=n,d=`queues-row-${a.exportName}`,r;e[0]!==a.exportName?(r=(0,t.jsx)(w,{className:"font-mono text-xs",children:a.exportName}),e[0]=a.exportName,e[1]=r):r=e[1];let s;e[2]!==a.name?(s=(0,t.jsx)(w,{className:"font-mono text-xs text-muted-foreground",children:a.name}),e[2]=a.name,e[3]=s):s=e[3];let l;e[4]!==a.mode?(l=(0,t.jsx)(w,{className:"font-mono text-xs text-muted-foreground",children:a.mode}),e[4]=a.mode,e[5]=l):l=e[5];let o;e[6]!==a.binding?(o=(0,t.jsx)(w,{className:"font-mono text-xs text-muted-foreground",children:a.binding}),e[6]=a.binding,e[7]=o):o=e[7];let m=a.deadLetterQueue??"\u2014",i;e[8]!==m?(i=(0,t.jsx)(w,{className:"font-mono text-xs text-muted-foreground",children:m}),e[8]=m,e[9]=i):i=e[9];let p;return e[10]!==d||e[11]!==r||e[12]!==s||e[13]!==l||e[14]!==o||e[15]!==i?(p=(0,t.jsxs)(z,{"data-testid":d,children:[r,s,l,o,i]}),e[10]=d,e[11]=r,e[12]=s,e[13]=l,e[14]=o,e[15]=i,e[16]=p):p=e[16],p},"We"),wt=c(n=>{let e=(0,D.c)(8),{loaded:a,queues:d}=n,r=F(),s;if(e[0]!==a||e[1]!==d||e[2]!==r){let{plain:l,topics:o}=De(d),m;e[4]!==r?(m=r("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[4]=r,e[5]=m):m=e[5];let i;e[6]!==m?(i=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:m}),e[6]=m,e[7]=i):i=e[7],s=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[i,a&&d.length===0?(0,t.jsx)(le,{description:r("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:r("No queues defined")}):(0,t.jsx)(Ee,{className:"overflow-hidden py-0",children:(0,t.jsx)(Me,{className:"px-0",children:(0,t.jsxs)(Le,{"data-testid":"queues-table",children:[(0,t.jsx)(Te,{children:(0,t.jsxs)(z,{children:[(0,t.jsx)(I,{children:r("Export")}),(0,t.jsx)(I,{children:r("Queue")}),(0,t.jsx)(I,{children:r("Mode")}),(0,t.jsx)(I,{children:r("Binding")}),(0,t.jsx)(I,{children:r("Dead-letter")})]})}),(0,t.jsxs)(_e,{children:[l.map(Et),[...o].map(p=>{let[f,x]=p;return(0,t.jsxs)(A.Fragment,{children:[(0,t.jsx)(z,{className:"bg-muted/40","data-testid":`queues-topic-${f}`,children:(0,t.jsx)(w,{className:"text-xs font-medium",colSpan:5,children:r("Topic {topic} \xB7 {count} subscriptions",{count:x.length,topic:f})})}),x.map(Mt)]},f)})]})]})})})]}),e[0]=a,e[1]=d,e[2]=r,e[3]=s}else s=e[3];return s},"St"),Ct=c(n=>{let e=(0,D.c)(67),{message:a,onReplay:d,replayingId:r}=n,s=F(),l,o,m,i,p,f,x,u,h,N;if(e[0]!==a.attempts||e[1]!==a.body||e[2]!==a.deadLettered||e[3]!==a.exportName||e[4]!==a.id||e[5]!==a.messageId||e[6]!==a.outcome||e[7]!==a.queue||e[8]!==s){let H=bt(a.body);o=z,f=`queues-message-${a.id}`;let $=a.exportName??a.queue;e[19]!==$?(x=(0,t.jsx)(w,{className:"font-mono text-xs",children:$}),e[19]=$,e[20]=x):x=e[20],e[21]!==a.messageId?(u=(0,t.jsx)(w,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:a.messageId,children:a.messageId}),e[21]=a.messageId,e[22]=u):u=e[22],e[23]!==a.attempts?(h=(0,t.jsx)(w,{className:"font-mono text-xs tabular-nums",children:a.attempts}),e[23]=a.attempts,e[24]=h):h=e[24];let P=`queues-outcome-${a.id}`,E;e[25]!==a.outcome?(E=vt(a.outcome),e[25]=a.outcome,e[26]=E):E=e[26];let _;e[27]!==a.outcome||e[28]!==P||e[29]!==E?(_=(0,t.jsx)(oe,{"data-testid":P,variant:E,children:a.outcome}),e[27]=a.outcome,e[28]=P,e[29]=E,e[30]=_):_=e[30];let M;e[31]!==a.deadLettered||e[32]!==a.id||e[33]!==s?(M=a.deadLettered&&(0,t.jsx)(oe,{"data-testid":`queues-dlq-${a.id}`,variant:"destructive",children:s("DLQ")}),e[31]=a.deadLettered,e[32]=a.id,e[33]=s,e[34]=M):M=e[34],e[35]!==_||e[36]!==M?(N=(0,t.jsx)(w,{children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-1",children:[_,M]})}),e[35]=_,e[36]=M,e[37]=N):N=e[37],l=w,m="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",i=H,p=qt(H),e[0]=a.attempts,e[1]=a.body,e[2]=a.deadLettered,e[3]=a.exportName,e[4]=a.id,e[5]=a.messageId,e[6]=a.outcome,e[7]=a.queue,e[8]=s,e[9]=l,e[10]=o,e[11]=m,e[12]=i,e[13]=p,e[14]=f,e[15]=x,e[16]=u,e[17]=h,e[18]=N}else l=e[9],o=e[10],m=e[11],i=e[12],p=e[13],f=e[14],x=e[15],u=e[16],h=e[17],N=e[18];let y;e[38]!==l||e[39]!==m||e[40]!==i||e[41]!==p?(y=(0,t.jsx)(l,{className:m,title:i,children:p}),e[38]=l,e[39]=m,e[40]=i,e[41]=p,e[42]=y):y=e[42];let b;e[43]!==a.capturedAt?(b=Ue(a.capturedAt,"\u2014"),e[43]=a.capturedAt,e[44]=b):b=e[44];let C;e[45]!==b?(C=(0,t.jsx)(w,{className:"text-xs text-muted-foreground tabular-nums",children:b}),e[45]=b,e[46]=C):C=e[46];let q=`queues-replay-${a.id}`,v=r!==null,Q;e[47]!==a.id||e[48]!==r||e[49]!==s?(Q=r===a.id?s("Replaying\u2026"):s("Replay"),e[47]=a.id,e[48]=r,e[49]=s,e[50]=Q):Q=e[50];let L;e[51]!==a.id||e[52]!==d||e[53]!==q||e[54]!==v||e[55]!==Q?(L=(0,t.jsx)(w,{children:(0,t.jsx)(de,{"data-id":a.id,"data-testid":q,disabled:v,onClick:d,size:"xs",type:"button",variant:"outline",children:Q})}),e[51]=a.id,e[52]=d,e[53]=q,e[54]=v,e[55]=Q,e[56]=L):L=e[56];let T;return e[57]!==o||e[58]!==C||e[59]!==L||e[60]!==f||e[61]!==x||e[62]!==u||e[63]!==h||e[64]!==N||e[65]!==y?(T=(0,t.jsxs)(o,{"data-testid":f,children:[x,u,h,N,y,C,L]}),e[57]=o,e[58]=C,e[59]=L,e[60]=f,e[61]=x,e[62]=u,e[63]=h,e[64]=N,e[65]=y,e[66]=T):T=e[66],T},"Et"),It=c(n=>{let e=(0,D.c)(29),{hasError:a,messages:d,onClear:r,onReplay:s,replayingId:l}=n,o=F(),m;e[0]!==o?(m=o("Cloudflare Queues have no peek API, so this is what push consumers actually processed \u2014 not pending depth."),e[0]=o,e[1]=m):m=e[1];let i;e[2]!==m?(i=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:m}),e[2]=m,e[3]=i):i=e[3];let p;e[4]!==o?(p=o("Clear the whole message log?"),e[4]=o,e[5]=p):p=e[5];let f=d.length===0,x;e[6]!==o?(x=o("Clear log"),e[6]=o,e[7]=x):x=e[7];let u;e[8]!==r||e[9]!==p||e[10]!==f||e[11]!==x?(u=(0,t.jsx)("div",{className:"ml-auto",children:(0,t.jsx)(Ke,{confirmLabel:p,disabled:f,onConfirm:r,testId:"queues-clear",children:x})}),e[8]=r,e[9]=p,e[10]=f,e[11]=x,e[12]=u):u=e[12];let h;e[13]!==d.length||e[14]!==o?(h=d.length>0&&(0,t.jsx)(oe,{"data-testid":"queues-count",variant:"secondary",children:o("{count} messages",{count:d.length})}),e[13]=d.length,e[14]=o,e[15]=h):h=e[15];let N;e[16]!==i||e[17]!==u||e[18]!==h?(N=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[i,u,h]}),e[16]=i,e[17]=u,e[18]=h,e[19]=N):N=e[19];let y;e[20]!==a||e[21]!==d||e[22]!==s||e[23]!==l||e[24]!==o?(y=!a&&d.length===0?(0,t.jsx)(le,{description:o("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:o("No consumed messages yet.")}):(0,t.jsx)(Ee,{className:"overflow-hidden py-0",children:(0,t.jsx)(Me,{className:"px-0",children:(0,t.jsx)(Ye,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:(0,t.jsxs)(Le,{"data-testid":"queues-messages-table",children:[(0,t.jsx)(Te,{children:(0,t.jsxs)(z,{children:[(0,t.jsx)(I,{children:o("Export")}),(0,t.jsx)(I,{children:o("Message")}),(0,t.jsx)(I,{children:o("Attempts")}),(0,t.jsx)(I,{children:o("Outcome")}),(0,t.jsx)(I,{children:o("Body")}),(0,t.jsx)(I,{children:o("Captured")}),(0,t.jsx)(I,{})]})}),(0,t.jsx)(_e,{children:d.map(C=>(0,t.jsx)(Ct,{message:C,onReplay:s,replayingId:l},C.id))})]})})})}),e[20]=a,e[21]=d,e[22]=s,e[23]=l,e[24]=o,e[25]=y):y=e[25];let b;return e[26]!==N||e[27]!==y?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[N,y]}),e[26]=N,e[27]=y,e[28]=b):b=e[28],b},"Tt"),Qt=c(n=>{let e=(0,D.c)(20),{batchMode:a,bodyText:d,delayText:r,onBatchModeChange:s,onBodyChange:l,onDelayChange:o,onSelectExport:m,onSend:i,queues:p,selectedExportName:f,sending:x}=n,u=F(),h;e[0]!==u?(h=u("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=u,e[1]=h):h=e[1];let N;e[2]!==h?(N=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:h}),e[2]=h,e[3]=N):N=e[3];let y;e[4]!==a||e[5]!==d||e[6]!==r||e[7]!==s||e[8]!==l||e[9]!==o||e[10]!==m||e[11]!==i||e[12]!==p||e[13]!==f||e[14]!==x||e[15]!==u?(y=p.length===0?(0,t.jsx)(le,{description:u("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:u("No queues to send to")}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("select",{"aria-label":u("Queue"),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":"queues-send-select",onChange:m,value:f,children:[p.map(At),[...De(p).topics].map(C=>{let[q,v]=C;return(0,t.jsx)("option",{value:et(q),children:u("{topic} (topic \u2192 {count} subscriptions)",{count:v.length,topic:q})},q)})]}),(0,t.jsx)(ze,{"aria-label":u("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:o,placeholder:u("Delay (s)"),type:"number",value:r}),(0,t.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[(0,t.jsx)("input",{checked:a,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:s,type:"checkbox"}),u("Send as batch (JSON array)")]}),(0,t.jsx)(de,{className:"ml-auto","data-testid":"queues-send-button",disabled:x||f==="",onClick:i,type:"button",children:u(x?"Sending\u2026":"Send message")})]}),(0,t.jsx)(Ve,{"aria-label":u("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:l,placeholder:a?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:d})]}),e[4]=a,e[5]=d,e[6]=r,e[7]=s,e[8]=l,e[9]=o,e[10]=m,e[11]=i,e[12]=p,e[13]=f,e[14]=x,e[15]=u,e[16]=y):y=e[16];let b;return e[17]!==N||e[18]!==y?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[N,y]}),e[17]=N,e[18]=y,e[19]=b):b=e[19],b},"_t"),Yt=c(n=>{let e=(0,D.c)(55),{limit:a}=n,d=a??gt,r=We(),s=F(),[l,o]=(0,A.useState)("declared"),[m,i]=(0,A.useState)(null),p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let{data:f,error:x,errorSource:u}=Ae(W.listQueues,p),h;e[1]!==d?(h={limit:d},e[1]=d,e[2]=h):h=e[2];let{data:N,error:y,errorSource:b,poll:C,refetch:q}=Ae(W.getQueueMessages,h),v=Array.isArray(f?.queues)?[...f.queues].toSorted(Lt):[],Q=N?.entries??[],{deadLetteredCount:L,queuesWithoutDlq:T,showReliabilityWarning:H}=pt(v,Q),[$,P]=(0,A.useState)(""),[E,_]=(0,A.useState)(""),[M,at]=(0,A.useState)(""),[U,st]=(0,A.useState)(!1),[me,$e]=(0,A.useState)(!1),[pe,ke]=(0,A.useState)(null),{topics:Oe}=De(v),Re=[...v.map(Tt),...[...Oe.keys()].map(_t)],K=Re.includes($)?$:Re[0]??"",Je=l==="messages"?y:x,nt=l==="messages"?b:u,he=Je??m,ge=Je===null?m:nt;Xe(C,l==="messages");let rt=c(async()=>{i(null);let g=K;if(g==="")return;let S=null,je=E.trim();if(je!=="")try{S=JSON.parse(je)}catch{i(s("Body must be valid JSON."));return}let Ie,Fe=M.trim();if(Fe!==""){let B=Number(Fe);if(!Number.isFinite(B)||B<0){i(s("Delay must be a non-negative number of seconds."));return}Ie=B}if(U&&!Array.isArray(S)){i(s("Batch mode needs a JSON array body \u2014 each element is enqueued as one message."));return}$e(!0);let it=ht(g,Oe).map(B=>U?{batch:S,delaySeconds:Ie,exportName:B}:{body:S,delaySeconds:Ie,exportName:B});try{i(await xt(r,it,s)),q()}catch(B){i(G(B))}$e(!1)},"Ve"),V;e[3]!==r||e[4]!==q?(V=c(async g=>{i(null),ke(g);try{await r.query(yt,{id:g},ce("")),q()}catch(S){i(G(S))}ke(null)},"V"),e[3]=r,e[4]=q,e[5]=V):V=e[5];let fe=V,X;e[6]!==r||e[7]!==q?(X=c(async()=>{i(null);try{await r.query(Nt,{},ce("")),q()}catch(g){i(G(g))}},"X"),e[6]=r,e[7]=q,e[8]=X):X=e[8];let xe=X,Y;e[9]===Symbol.for("react.memo_cache_sentinel")?(Y=c(g=>{let S=g.currentTarget.dataset.tab;(S==="declared"||S==="messages"||S==="send")&&o(S)},"Y"),e[9]=Y):Y=e[9];let ot=Y,Z;e[10]===Symbol.for("react.memo_cache_sentinel")?(Z=c(g=>{P(g.currentTarget.value)},"K"),e[10]=Z):Z=e[10];let ye=Z,ee;e[11]===Symbol.for("react.memo_cache_sentinel")?(ee=c(g=>{_(g.currentTarget.value)},"Z"),e[11]=ee):ee=e[11];let Ne=ee,te;e[12]===Symbol.for("react.memo_cache_sentinel")?(te=c(g=>{at(g.currentTarget.value)},"ee"),e[12]=te):te=e[12];let be=te,ae;e[13]===Symbol.for("react.memo_cache_sentinel")?(ae=c(g=>{st(g.currentTarget.checked)},"te"),e[13]=ae):ae=e[13];let qe=ae,ve=c(()=>{ue(rt())},"ge"),se;e[14]!==fe?(se=c(g=>{let{id:S}=g.currentTarget.dataset;S!==void 0&&ue(fe(S))},"se"),e[14]=fe,e[15]=se):se=e[15];let Se=se,ne;e[16]!==xe?(ne=c(()=>{ue(xe())},"ae"),e[16]=xe,e[17]=ne):ne=e[17];let we=ne,dt="flex flex-col gap-6",lt="lunora-queues-panel",k;e[18]!==s||e[19]!==l?(k=(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(g=>(0,t.jsx)(de,{"aria-selected":l===g,"data-tab":g,"data-testid":`queues-tab-${g}`,onClick:ot,role:"tab",size:"sm",type:"button",variant:l===g?"secondary":"ghost",children:St(g,s)},g))}),e[18]=s,e[19]=l,e[20]=k):k=e[20];let O;e[21]!==he||e[22]!==ge?(O=he!==null&&(0,t.jsx)(He,{error:ge,testId:"queues-error"}),e[21]=he,e[22]=ge,e[23]=O):O=e[23];let Ce=H&&(0,t.jsx)(Ge,{icon:(0,t.jsx)("span",{"aria-hidden":"true",className:"text-base leading-none",children:"\u26A0"}),testId:"queues-dlq-warning",variant:"warning",children:(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[T.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"font-medium",children:s("No dead-letter queue on {queues}.",{queues:T.map(Bt).join(", ")})}),(0,t.jsx)("p",{className:"text-muted-foreground",children:s("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),L>0&&(0,t.jsx)("p",{className:T.length>0?"text-muted-foreground":"font-medium",children:L===1?s("1 message was recently dead-lettered."):s("{count} messages were recently dead-lettered.",{count:L})})]})}),R;e[24]!==v||e[25]!==f||e[26]!==l?(R=l==="declared"&&(0,t.jsx)(wt,{loaded:f!==void 0,queues:v}),e[24]=v,e[25]=f,e[26]=l,e[27]=R):R=e[27];let J;e[28]!==Q||e[29]!==y||e[30]!==we||e[31]!==Se||e[32]!==pe||e[33]!==l?(J=l==="messages"&&(0,t.jsx)(It,{hasError:y!==null,messages:Q,onClear:we,onReplay:Se,replayingId:pe}),e[28]=Q,e[29]=y,e[30]=we,e[31]=Se,e[32]=pe,e[33]=l,e[34]=J):J=e[34];let j;e[35]!==U||e[36]!==E||e[37]!==M||e[38]!==qe||e[39]!==Ne||e[40]!==be||e[41]!==ye||e[42]!==ve||e[43]!==v||e[44]!==K||e[45]!==me||e[46]!==l?(j=l==="send"&&(0,t.jsx)(Qt,{batchMode:U,bodyText:E,delayText:M,onBatchModeChange:qe,onBodyChange:Ne,onDelayChange:be,onSelectExport:ye,onSend:ve,queues:v,selectedExportName:K,sending:me}),e[35]=U,e[36]=E,e[37]=M,e[38]=qe,e[39]=Ne,e[40]=be,e[41]=ye,e[42]=ve,e[43]=v,e[44]=K,e[45]=me,e[46]=l,e[47]=j):j=e[47];let re;return e[48]!==k||e[49]!==O||e[50]!==Ce||e[51]!==R||e[52]!==J||e[53]!==j?(re=(0,t.jsxs)("div",{className:dt,"data-testid":lt,children:[k,O,Ce,R,J,j]}),e[48]=k,e[49]=O,e[50]=Ce,e[51]=R,e[52]=J,e[53]=j,e[54]=re):re=e[54],re},"es");function Et(n){return(0,t.jsx)(tt,{queue:n},n.exportName)}c(Et,"Ct");function Mt(n){return(0,t.jsx)(tt,{queue:n},n.exportName)}c(Mt,"vt");function At(n){return(0,t.jsx)("option",{value:n.exportName,children:n.exportName},n.exportName)}c(At,"wt");function Lt(n,e){return n.exportName.localeCompare(e.exportName)}c(Lt,"Qt");function Tt(n){return n.exportName}c(Tt,"At");function _t(n){return et(n)}c(_t,"It");function Bt(n){return n.name}c(Bt,"Mt");export{Yt as default};
1
+ import{a as Ye}from"./chunk-ECY2JC5F.js";import"./chunk-NRP22GKC.js";import{a as Ve}from"./chunk-FPI7AMQJ.js";import{a as Xe}from"./chunk-3ZVTL2VM.js";import"./chunk-UC7MNI2F.js";import{a as Ke}from"./chunk-LXCVA5SP.js";import{i as ze}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as de}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as oe}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as He}from"./chunk-R7SRERCX.js";import{a as Ge}from"./chunk-NCPW7WHO.js";import"./chunk-RGUL4AQZ.js";import"./chunk-55UGUCQ6.js";import{a as W}from"./chunk-4ZEL6BYL.js";import{c as Ae}from"./chunk-QTDX7WSP.js";import{l as We}from"./chunk-KPRNLQKZ.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as le}from"./chunk-RWVIV3U7.js";import{a as Le,b as Te,c as _e,d as z,e as I,f as w}from"./chunk-HCTJKP5J.js";import{a as Ee,e as Me}from"./chunk-2IKDEUCX.js";import{d as F,f as ie,g as ce,h as G,n as Pe,q as ue,u as Ue}from"./chunk-74IYYDDI.js";import{a as c,d as Qe,e as ct,f as ut,g as mt}from"./chunk-I26MS5PJ.js";var D=Qe(ut(),1);var A=Qe(ct(),1);var t=Qe(mt(),1);var pt=c((n,e)=>{let a=new Set(n.map(s=>s.deadLetterQueue).filter(s=>typeof s=="string"&&s!=="")),d=n.filter(s=>(s.deadLetterQueue===void 0||s.deadLetterQueue==="")&&!a.has(s.name)),r=e.filter(s=>s.deadLettered).length;return{deadLetteredCount:r,queuesWithoutDlq:d,showReliabilityWarning:d.length>0||r>0}},"ut"),Be="topic:",De=c(n=>{let e=[],a=new Map;for(let d of n)d.topic===void 0?e.push(d):a.set(d.topic,[...a.get(d.topic)??[],d]);return{plain:e,topics:a}},"Qe"),et=c(n=>`${Be}${n}`,"je"),ht=c((n,e)=>n.startsWith(Be)?(e.get(n.slice(Be.length))??[]).map(a=>a.exportName):[n],"mt"),gt=200,ft=ie(W.sendQueueMessage),xt=c(async(n,e,a)=>{let d=(await Promise.allSettled(e.map(async s=>n.query(ft,s,ce(""))))).flatMap((s,l)=>s.status==="rejected"?[{exportName:e[l]?.exportName??"",message:G(s.reason)}]:[]),[r]=d;return r===void 0?null:e.length===1?r.message:a("Not sent to {failed}",{failed:d.map(s=>`${s.exportName}: ${s.message}`).join("; ")})},"ht"),yt=ie(W.replayQueueMessage),Nt=ie(W.clearQueueMessages),Ze=96,bt=c(n=>{if(n===void 0)return"\u2014";try{return JSON.stringify(n,Pe)}catch{return"[unserializable]"}},"yt"),qt=c(n=>n.length>Ze?`${n.slice(0,Ze)}\u2026`:n,"bt"),vt=c(n=>n==="error"?"destructive":n==="retry"?"outline":"secondary","Nt"),St=c((n,e)=>e(n==="messages"?"Messages":n==="send"?"Send":"Declared"),"qt"),tt=c(n=>{let e=(0,D.c)(17),{queue:a}=n,d=`queues-row-${a.exportName}`,r;e[0]!==a.exportName?(r=(0,t.jsx)(w,{className:"font-mono text-xs",children:a.exportName}),e[0]=a.exportName,e[1]=r):r=e[1];let s;e[2]!==a.name?(s=(0,t.jsx)(w,{className:"font-mono text-xs text-muted-foreground",children:a.name}),e[2]=a.name,e[3]=s):s=e[3];let l;e[4]!==a.mode?(l=(0,t.jsx)(w,{className:"font-mono text-xs text-muted-foreground",children:a.mode}),e[4]=a.mode,e[5]=l):l=e[5];let o;e[6]!==a.binding?(o=(0,t.jsx)(w,{className:"font-mono text-xs text-muted-foreground",children:a.binding}),e[6]=a.binding,e[7]=o):o=e[7];let m=a.deadLetterQueue??"\u2014",i;e[8]!==m?(i=(0,t.jsx)(w,{className:"font-mono text-xs text-muted-foreground",children:m}),e[8]=m,e[9]=i):i=e[9];let p;return e[10]!==d||e[11]!==r||e[12]!==s||e[13]!==l||e[14]!==o||e[15]!==i?(p=(0,t.jsxs)(z,{"data-testid":d,children:[r,s,l,o,i]}),e[10]=d,e[11]=r,e[12]=s,e[13]=l,e[14]=o,e[15]=i,e[16]=p):p=e[16],p},"We"),wt=c(n=>{let e=(0,D.c)(8),{loaded:a,queues:d}=n,r=F(),s;if(e[0]!==a||e[1]!==d||e[2]!==r){let{plain:l,topics:o}=De(d),m;e[4]!==r?(m=r("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[4]=r,e[5]=m):m=e[5];let i;e[6]!==m?(i=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:m}),e[6]=m,e[7]=i):i=e[7],s=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[i,a&&d.length===0?(0,t.jsx)(le,{description:r("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:r("No queues defined")}):(0,t.jsx)(Ee,{className:"overflow-hidden py-0",children:(0,t.jsx)(Me,{className:"px-0",children:(0,t.jsxs)(Le,{"data-testid":"queues-table",children:[(0,t.jsx)(Te,{children:(0,t.jsxs)(z,{children:[(0,t.jsx)(I,{children:r("Export")}),(0,t.jsx)(I,{children:r("Queue")}),(0,t.jsx)(I,{children:r("Mode")}),(0,t.jsx)(I,{children:r("Binding")}),(0,t.jsx)(I,{children:r("Dead-letter")})]})}),(0,t.jsxs)(_e,{children:[l.map(Et),[...o].map(p=>{let[f,x]=p;return(0,t.jsxs)(A.Fragment,{children:[(0,t.jsx)(z,{className:"bg-muted/40","data-testid":`queues-topic-${f}`,children:(0,t.jsx)(w,{className:"text-xs font-medium",colSpan:5,children:r("Topic {topic} \xB7 {count} subscriptions",{count:x.length,topic:f})})}),x.map(Mt)]},f)})]})]})})})]}),e[0]=a,e[1]=d,e[2]=r,e[3]=s}else s=e[3];return s},"St"),Ct=c(n=>{let e=(0,D.c)(67),{message:a,onReplay:d,replayingId:r}=n,s=F(),l,o,m,i,p,f,x,u,h,N;if(e[0]!==a.attempts||e[1]!==a.body||e[2]!==a.deadLettered||e[3]!==a.exportName||e[4]!==a.id||e[5]!==a.messageId||e[6]!==a.outcome||e[7]!==a.queue||e[8]!==s){let H=bt(a.body);o=z,f=`queues-message-${a.id}`;let $=a.exportName??a.queue;e[19]!==$?(x=(0,t.jsx)(w,{className:"font-mono text-xs",children:$}),e[19]=$,e[20]=x):x=e[20],e[21]!==a.messageId?(u=(0,t.jsx)(w,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:a.messageId,children:a.messageId}),e[21]=a.messageId,e[22]=u):u=e[22],e[23]!==a.attempts?(h=(0,t.jsx)(w,{className:"font-mono text-xs tabular-nums",children:a.attempts}),e[23]=a.attempts,e[24]=h):h=e[24];let P=`queues-outcome-${a.id}`,E;e[25]!==a.outcome?(E=vt(a.outcome),e[25]=a.outcome,e[26]=E):E=e[26];let _;e[27]!==a.outcome||e[28]!==P||e[29]!==E?(_=(0,t.jsx)(oe,{"data-testid":P,variant:E,children:a.outcome}),e[27]=a.outcome,e[28]=P,e[29]=E,e[30]=_):_=e[30];let M;e[31]!==a.deadLettered||e[32]!==a.id||e[33]!==s?(M=a.deadLettered&&(0,t.jsx)(oe,{"data-testid":`queues-dlq-${a.id}`,variant:"destructive",children:s("DLQ")}),e[31]=a.deadLettered,e[32]=a.id,e[33]=s,e[34]=M):M=e[34],e[35]!==_||e[36]!==M?(N=(0,t.jsx)(w,{children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-1",children:[_,M]})}),e[35]=_,e[36]=M,e[37]=N):N=e[37],l=w,m="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",i=H,p=qt(H),e[0]=a.attempts,e[1]=a.body,e[2]=a.deadLettered,e[3]=a.exportName,e[4]=a.id,e[5]=a.messageId,e[6]=a.outcome,e[7]=a.queue,e[8]=s,e[9]=l,e[10]=o,e[11]=m,e[12]=i,e[13]=p,e[14]=f,e[15]=x,e[16]=u,e[17]=h,e[18]=N}else l=e[9],o=e[10],m=e[11],i=e[12],p=e[13],f=e[14],x=e[15],u=e[16],h=e[17],N=e[18];let y;e[38]!==l||e[39]!==m||e[40]!==i||e[41]!==p?(y=(0,t.jsx)(l,{className:m,title:i,children:p}),e[38]=l,e[39]=m,e[40]=i,e[41]=p,e[42]=y):y=e[42];let b;e[43]!==a.capturedAt?(b=Ue(a.capturedAt,"\u2014"),e[43]=a.capturedAt,e[44]=b):b=e[44];let C;e[45]!==b?(C=(0,t.jsx)(w,{className:"text-xs text-muted-foreground tabular-nums",children:b}),e[45]=b,e[46]=C):C=e[46];let q=`queues-replay-${a.id}`,v=r!==null,Q;e[47]!==a.id||e[48]!==r||e[49]!==s?(Q=r===a.id?s("Replaying\u2026"):s("Replay"),e[47]=a.id,e[48]=r,e[49]=s,e[50]=Q):Q=e[50];let L;e[51]!==a.id||e[52]!==d||e[53]!==q||e[54]!==v||e[55]!==Q?(L=(0,t.jsx)(w,{children:(0,t.jsx)(de,{"data-id":a.id,"data-testid":q,disabled:v,onClick:d,size:"xs",type:"button",variant:"outline",children:Q})}),e[51]=a.id,e[52]=d,e[53]=q,e[54]=v,e[55]=Q,e[56]=L):L=e[56];let T;return e[57]!==o||e[58]!==C||e[59]!==L||e[60]!==f||e[61]!==x||e[62]!==u||e[63]!==h||e[64]!==N||e[65]!==y?(T=(0,t.jsxs)(o,{"data-testid":f,children:[x,u,h,N,y,C,L]}),e[57]=o,e[58]=C,e[59]=L,e[60]=f,e[61]=x,e[62]=u,e[63]=h,e[64]=N,e[65]=y,e[66]=T):T=e[66],T},"Et"),It=c(n=>{let e=(0,D.c)(29),{hasError:a,messages:d,onClear:r,onReplay:s,replayingId:l}=n,o=F(),m;e[0]!==o?(m=o("Cloudflare Queues have no peek API, so this is what push consumers actually processed \u2014 not pending depth."),e[0]=o,e[1]=m):m=e[1];let i;e[2]!==m?(i=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:m}),e[2]=m,e[3]=i):i=e[3];let p;e[4]!==o?(p=o("Clear the whole message log?"),e[4]=o,e[5]=p):p=e[5];let f=d.length===0,x;e[6]!==o?(x=o("Clear log"),e[6]=o,e[7]=x):x=e[7];let u;e[8]!==r||e[9]!==p||e[10]!==f||e[11]!==x?(u=(0,t.jsx)("div",{className:"ml-auto",children:(0,t.jsx)(Ke,{confirmLabel:p,disabled:f,onConfirm:r,testId:"queues-clear",children:x})}),e[8]=r,e[9]=p,e[10]=f,e[11]=x,e[12]=u):u=e[12];let h;e[13]!==d.length||e[14]!==o?(h=d.length>0&&(0,t.jsx)(oe,{"data-testid":"queues-count",variant:"secondary",children:o("{count} messages",{count:d.length})}),e[13]=d.length,e[14]=o,e[15]=h):h=e[15];let N;e[16]!==i||e[17]!==u||e[18]!==h?(N=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[i,u,h]}),e[16]=i,e[17]=u,e[18]=h,e[19]=N):N=e[19];let y;e[20]!==a||e[21]!==d||e[22]!==s||e[23]!==l||e[24]!==o?(y=!a&&d.length===0?(0,t.jsx)(le,{description:o("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:o("No consumed messages yet.")}):(0,t.jsx)(Ee,{className:"overflow-hidden py-0",children:(0,t.jsx)(Me,{className:"px-0",children:(0,t.jsx)(Ye,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:(0,t.jsxs)(Le,{"data-testid":"queues-messages-table",children:[(0,t.jsx)(Te,{children:(0,t.jsxs)(z,{children:[(0,t.jsx)(I,{children:o("Export")}),(0,t.jsx)(I,{children:o("Message")}),(0,t.jsx)(I,{children:o("Attempts")}),(0,t.jsx)(I,{children:o("Outcome")}),(0,t.jsx)(I,{children:o("Body")}),(0,t.jsx)(I,{children:o("Captured")}),(0,t.jsx)(I,{})]})}),(0,t.jsx)(_e,{children:d.map(C=>(0,t.jsx)(Ct,{message:C,onReplay:s,replayingId:l},C.id))})]})})})}),e[20]=a,e[21]=d,e[22]=s,e[23]=l,e[24]=o,e[25]=y):y=e[25];let b;return e[26]!==N||e[27]!==y?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[N,y]}),e[26]=N,e[27]=y,e[28]=b):b=e[28],b},"Tt"),Qt=c(n=>{let e=(0,D.c)(20),{batchMode:a,bodyText:d,delayText:r,onBatchModeChange:s,onBodyChange:l,onDelayChange:o,onSelectExport:m,onSend:i,queues:p,selectedExportName:f,sending:x}=n,u=F(),h;e[0]!==u?(h=u("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=u,e[1]=h):h=e[1];let N;e[2]!==h?(N=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:h}),e[2]=h,e[3]=N):N=e[3];let y;e[4]!==a||e[5]!==d||e[6]!==r||e[7]!==s||e[8]!==l||e[9]!==o||e[10]!==m||e[11]!==i||e[12]!==p||e[13]!==f||e[14]!==x||e[15]!==u?(y=p.length===0?(0,t.jsx)(le,{description:u("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:u("No queues to send to")}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("select",{"aria-label":u("Queue"),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":"queues-send-select",onChange:m,value:f,children:[p.map(At),[...De(p).topics].map(C=>{let[q,v]=C;return(0,t.jsx)("option",{value:et(q),children:u("{topic} (topic \u2192 {count} subscriptions)",{count:v.length,topic:q})},q)})]}),(0,t.jsx)(ze,{"aria-label":u("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:o,placeholder:u("Delay (s)"),type:"number",value:r}),(0,t.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[(0,t.jsx)("input",{checked:a,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:s,type:"checkbox"}),u("Send as batch (JSON array)")]}),(0,t.jsx)(de,{className:"ml-auto","data-testid":"queues-send-button",disabled:x||f==="",onClick:i,type:"button",children:u(x?"Sending\u2026":"Send message")})]}),(0,t.jsx)(Ve,{"aria-label":u("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:l,placeholder:a?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:d})]}),e[4]=a,e[5]=d,e[6]=r,e[7]=s,e[8]=l,e[9]=o,e[10]=m,e[11]=i,e[12]=p,e[13]=f,e[14]=x,e[15]=u,e[16]=y):y=e[16];let b;return e[17]!==N||e[18]!==y?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[N,y]}),e[17]=N,e[18]=y,e[19]=b):b=e[19],b},"_t"),Yt=c(n=>{let e=(0,D.c)(55),{limit:a}=n,d=a??gt,r=We(),s=F(),[l,o]=(0,A.useState)("declared"),[m,i]=(0,A.useState)(null),p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let{data:f,error:x,errorSource:u}=Ae(W.listQueues,p),h;e[1]!==d?(h={limit:d},e[1]=d,e[2]=h):h=e[2];let{data:N,error:y,errorSource:b,poll:C,refetch:q}=Ae(W.getQueueMessages,h),v=Array.isArray(f?.queues)?[...f.queues].toSorted(Lt):[],Q=N?.entries??[],{deadLetteredCount:L,queuesWithoutDlq:T,showReliabilityWarning:H}=pt(v,Q),[$,P]=(0,A.useState)(""),[E,_]=(0,A.useState)(""),[M,at]=(0,A.useState)(""),[U,st]=(0,A.useState)(!1),[me,$e]=(0,A.useState)(!1),[pe,ke]=(0,A.useState)(null),{topics:Oe}=De(v),Re=[...v.map(Tt),...[...Oe.keys()].map(_t)],K=Re.includes($)?$:Re[0]??"",Je=l==="messages"?y:x,nt=l==="messages"?b:u,he=Je??m,ge=Je===null?m:nt;Xe(C,l==="messages");let rt=c(async()=>{i(null);let g=K;if(g==="")return;let S=null,je=E.trim();if(je!=="")try{S=JSON.parse(je)}catch{i(s("Body must be valid JSON."));return}let Ie,Fe=M.trim();if(Fe!==""){let B=Number(Fe);if(!Number.isFinite(B)||B<0){i(s("Delay must be a non-negative number of seconds."));return}Ie=B}if(U&&!Array.isArray(S)){i(s("Batch mode needs a JSON array body \u2014 each element is enqueued as one message."));return}$e(!0);let it=ht(g,Oe).map(B=>U?{batch:S,delaySeconds:Ie,exportName:B}:{body:S,delaySeconds:Ie,exportName:B});try{i(await xt(r,it,s)),q()}catch(B){i(G(B))}$e(!1)},"Ve"),V;e[3]!==r||e[4]!==q?(V=c(async g=>{i(null),ke(g);try{await r.query(yt,{id:g},ce("")),q()}catch(S){i(G(S))}ke(null)},"V"),e[3]=r,e[4]=q,e[5]=V):V=e[5];let fe=V,X;e[6]!==r||e[7]!==q?(X=c(async()=>{i(null);try{await r.query(Nt,{},ce("")),q()}catch(g){i(G(g))}},"X"),e[6]=r,e[7]=q,e[8]=X):X=e[8];let xe=X,Y;e[9]===Symbol.for("react.memo_cache_sentinel")?(Y=c(g=>{let S=g.currentTarget.dataset.tab;(S==="declared"||S==="messages"||S==="send")&&o(S)},"Y"),e[9]=Y):Y=e[9];let ot=Y,Z;e[10]===Symbol.for("react.memo_cache_sentinel")?(Z=c(g=>{P(g.currentTarget.value)},"K"),e[10]=Z):Z=e[10];let ye=Z,ee;e[11]===Symbol.for("react.memo_cache_sentinel")?(ee=c(g=>{_(g.currentTarget.value)},"Z"),e[11]=ee):ee=e[11];let Ne=ee,te;e[12]===Symbol.for("react.memo_cache_sentinel")?(te=c(g=>{at(g.currentTarget.value)},"ee"),e[12]=te):te=e[12];let be=te,ae;e[13]===Symbol.for("react.memo_cache_sentinel")?(ae=c(g=>{st(g.currentTarget.checked)},"te"),e[13]=ae):ae=e[13];let qe=ae,ve=c(()=>{ue(rt())},"ge"),se;e[14]!==fe?(se=c(g=>{let{id:S}=g.currentTarget.dataset;S!==void 0&&ue(fe(S))},"se"),e[14]=fe,e[15]=se):se=e[15];let Se=se,ne;e[16]!==xe?(ne=c(()=>{ue(xe())},"ae"),e[16]=xe,e[17]=ne):ne=e[17];let we=ne,dt="flex flex-col gap-6",lt="lunora-queues-panel",k;e[18]!==s||e[19]!==l?(k=(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(g=>(0,t.jsx)(de,{"aria-selected":l===g,"data-tab":g,"data-testid":`queues-tab-${g}`,onClick:ot,role:"tab",size:"sm",type:"button",variant:l===g?"secondary":"ghost",children:St(g,s)},g))}),e[18]=s,e[19]=l,e[20]=k):k=e[20];let O;e[21]!==he||e[22]!==ge?(O=he!==null&&(0,t.jsx)(He,{error:ge,testId:"queues-error"}),e[21]=he,e[22]=ge,e[23]=O):O=e[23];let Ce=H&&(0,t.jsx)(Ge,{icon:(0,t.jsx)("span",{"aria-hidden":"true",className:"text-base leading-none",children:"\u26A0"}),testId:"queues-dlq-warning",variant:"warning",children:(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[T.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"font-medium",children:s("No dead-letter queue on {queues}.",{queues:T.map(Bt).join(", ")})}),(0,t.jsx)("p",{className:"text-muted-foreground",children:s("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),L>0&&(0,t.jsx)("p",{className:T.length>0?"text-muted-foreground":"font-medium",children:L===1?s("1 message was recently dead-lettered."):s("{count} messages were recently dead-lettered.",{count:L})})]})}),R;e[24]!==v||e[25]!==f||e[26]!==l?(R=l==="declared"&&(0,t.jsx)(wt,{loaded:f!==void 0,queues:v}),e[24]=v,e[25]=f,e[26]=l,e[27]=R):R=e[27];let J;e[28]!==Q||e[29]!==y||e[30]!==we||e[31]!==Se||e[32]!==pe||e[33]!==l?(J=l==="messages"&&(0,t.jsx)(It,{hasError:y!==null,messages:Q,onClear:we,onReplay:Se,replayingId:pe}),e[28]=Q,e[29]=y,e[30]=we,e[31]=Se,e[32]=pe,e[33]=l,e[34]=J):J=e[34];let j;e[35]!==U||e[36]!==E||e[37]!==M||e[38]!==qe||e[39]!==Ne||e[40]!==be||e[41]!==ye||e[42]!==ve||e[43]!==v||e[44]!==K||e[45]!==me||e[46]!==l?(j=l==="send"&&(0,t.jsx)(Qt,{batchMode:U,bodyText:E,delayText:M,onBatchModeChange:qe,onBodyChange:Ne,onDelayChange:be,onSelectExport:ye,onSend:ve,queues:v,selectedExportName:K,sending:me}),e[35]=U,e[36]=E,e[37]=M,e[38]=qe,e[39]=Ne,e[40]=be,e[41]=ye,e[42]=ve,e[43]=v,e[44]=K,e[45]=me,e[46]=l,e[47]=j):j=e[47];let re;return e[48]!==k||e[49]!==O||e[50]!==Ce||e[51]!==R||e[52]!==J||e[53]!==j?(re=(0,t.jsxs)("div",{className:dt,"data-testid":lt,children:[k,O,Ce,R,J,j]}),e[48]=k,e[49]=O,e[50]=Ce,e[51]=R,e[52]=J,e[53]=j,e[54]=re):re=e[54],re},"es");function Et(n){return(0,t.jsx)(tt,{queue:n},n.exportName)}c(Et,"Ct");function Mt(n){return(0,t.jsx)(tt,{queue:n},n.exportName)}c(Mt,"vt");function At(n){return(0,t.jsx)("option",{value:n.exportName,children:n.exportName},n.exportName)}c(At,"wt");function Lt(n,e){return n.exportName.localeCompare(e.exportName)}c(Lt,"Qt");function Tt(n){return n.exportName}c(Tt,"At");function _t(n){return et(n)}c(_t,"It");function Bt(n){return n.name}c(Bt,"Mt");export{Yt as default};
@@ -1 +1 @@
1
- import{a as Ze}from"./chunk-7RKB5KS7.js";import{a as qe}from"./chunk-5ZCMUHYK.js";import{a as Ke}from"./chunk-WVWCUB4S.js";import{a as He}from"./chunk-QJLHH3ET.js";import{a as O}from"./chunk-37WYCOQ2.js";import{a as Je}from"./chunk-VQRCJJXS.js";import"./chunk-PSMQQV6S.js";import{a as We}from"./chunk-J2OLAMJR.js";import{a as Xe}from"./chunk-IWZ7GVQO.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import{i as T}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as _}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as D}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{b as De}from"./chunk-ZBHXISOD.js";import{l as J}from"./chunk-X6XAMP4E.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as Ve}from"./chunk-RWVIV3U7.js";import{a as ze,b as _e,c as Pe,d as q,e as U,f as z}from"./chunk-HCTJKP5J.js";import{a as K,e as X}from"./chunk-2IKDEUCX.js";import{d as Q,h as Ee,p as Ue,q as Z,s as Qe,u as te}from"./chunk-74IYYDDI.js";import{a as s,d as Me,e as at,f as lt,g as nt}from"./chunk-I26MS5PJ.js";var C=Me(at(),1);var W=Me(lt(),1);var t=Me(nt(),1);var it=s(()=>{let h=(0,W.c)(3),{config:e,ready:n}=qe(),l;return h[0]!==e.capabilities||h[1]!==n?(l={capabilities:e.capabilities,ready:n},h[0]=e.capabilities,h[1]=n,h[2]=l):l=h[2],l},"nt"),st=s((h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending","lt"),et=500,rt=s((h,e)=>{if(!URL.canParse(h.trim()))return null;let n=new URL(h.trim());return n.searchParams.set("email",e.email),n.searchParams.set("invite",e.token),n.toString()},"at"),dt=s(h=>{let e=(0,W.c)(34),{issued:n,onSignUpPageChange:l,signUpPage:o}=h,a=Q(),[p,i]=(0,C.useState)(null),u;e[0]!==n||e[1]!==o?(u=rt(o,n),e[0]=n,e[1]=o,e[2]=u):u=e[2];let c=u,y;e[3]!==c?(y=s(()=>{let $="navigator"in globalThis?globalThis.navigator.clipboard:void 0;c===null||$===void 0||Z($.writeText(c).then(()=>(i(c),!0)))},"y"),e[3]=c,e[4]=y):y=e[4];let w=y,g;e[5]!==a?(g=a("Send this link to the invitee. It is shown once and cannot be recovered."),e[5]=a,e[6]=g):g=e[6];let I;e[7]!==g?(I=(0,t.jsx)("p",{className:"text-sm",children:g}),e[7]=g,e[8]=I):I=e[8];let k=c===null,v;e[9]!==a?(v=a("Your app's sign-up page"),e[9]=a,e[10]=v):v=e[10];let d;e[11]!==l?(d=s($=>{l($.target.value)},"r"),e[11]=l,e[12]=d):d=e[12];let m;e[13]!==o||e[14]!==k||e[15]!==v||e[16]!==d?(m=(0,t.jsx)(T,{"aria-invalid":k,"aria-label":v,"data-testid":"sign-up-invitation-page",onChange:d,value:o}),e[13]=o,e[14]=k,e[15]=v,e[16]=d,e[17]=m):m=e[17];let b=c??"",x;e[18]!==b?(x=(0,t.jsx)(T,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:b}),e[18]=b,e[19]=x):x=e[19];let N;e[20]!==p||e[21]!==c||e[22]!==a?(N=a(p!==null&&p===c?"Copied":"Copy"),e[20]=p,e[21]=c,e[22]=a,e[23]=N):N=e[23];let f;e[24]!==w||e[25]!==N?(f=(0,t.jsx)(_,{"data-testid":"sign-up-invitation-copy",onClick:w,type:"button",children:N}),e[24]=w,e[25]=N,e[26]=f):f=e[26];let r;e[27]!==x||e[28]!==f?(r=(0,t.jsxs)("div",{className:"flex gap-2",children:[x,f]}),e[27]=x,e[28]=f,e[29]=r):r=e[29];let S;return e[30]!==r||e[31]!==I||e[32]!==m?(S=(0,t.jsx)(K,{children:(0,t.jsxs)(X,{className:"flex flex-col gap-2 p-4",children:[I,m,r]})}),e[30]=r,e[31]=I,e[32]=m,e[33]=S):S=e[33],S},"it"),ot=s(()=>{let h=J(),e=Q(),[n,l]=(0,C.useState)(""),[o,a]=(0,C.useState)(null),[p,i]=(0,C.useState)(null),[u,c]=(0,C.useState)(()=>`${Qe(h.url)}/sign-up`),y=De(["lunora-auth-sign-up-invitations",et],()=>h.listAuthSignUpInvitations({limit:et})),w=y.data?.rows??null,g=y.data?.total??0,I=s(()=>{let v=n.trim();v!==""&&(a(null),Z((async()=>{try{let d=await h.createAuthSignUpInvitation({email:v}),m=typeof d.token=="string"?d.token:void 0;i(m===void 0?null:{email:v,token:m}),l(""),y.refetch()}catch(d){a(d instanceof Error?d.message:String(d))}})()))},"w"),k=s(v=>{a(null),Z((async()=>{try{await h.revokeAuthSignUpInvitation({email:v}),y.refetch()}catch(d){a(d instanceof Error?d.message:String(d))}})())},"k");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"sign-up-invitations",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-base font-medium",children:e("Sign-up invitations")}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("Only invited addresses can create an account. Nothing is emailed \u2014 send the invitee the one-time link yourself.")})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(T,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:s(v=>{l(v.target.value)},"onChange"),placeholder:e("ada@example.com"),type:"email",value:n}),(0,t.jsx)(_,{"data-testid":"sign-up-invitation-submit",onClick:I,type:"button",children:e("Invite")})]}),p!==null&&(0,t.jsx)(dt,{issued:p,onSignUpPageChange:c,signUpPage:u},p.token),(o??y.error)!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:o??y.error}),w!==null&&w.length===0&&(0,t.jsx)(Ve,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),w!==null&&g>w.length&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sign-up-invitations-truncated",children:e("Showing the most recent invitations. Query the signUpInvitation table directly to see the rest.")}),w!==null&&w.length>0&&(0,t.jsx)(K,{children:(0,t.jsx)(X,{className:"p-0",children:(0,t.jsxs)(ze,{children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:e("Email")}),(0,t.jsx)(U,{children:e("Status")}),(0,t.jsx)(U,{children:e("Expires")}),(0,t.jsx)(U,{children:e("Invited by")}),(0,t.jsx)(U,{})]})}),(0,t.jsx)(Pe,{children:w.map(v=>{let d=st(v,Date.now()),m=v.email??"";return(0,t.jsxs)(q,{"data-testid":`sign-up-invitation-${m}`,children:[(0,t.jsx)(z,{children:m}),(0,t.jsxs)(z,{"data-testid":`sign-up-invitation-status-${m}`,children:[d==="spent"&&e("Accepted"),d==="expired"&&e("Expired"),d==="pending"&&e("Pending")]}),(0,t.jsx)(z,{children:typeof v.expiresAt=="number"?te(v.expiresAt):"\u2014"}),(0,t.jsx)(z,{children:v.invitedBy??"\u2014"}),(0,t.jsx)(z,{className:"text-right",children:(0,t.jsx)(_,{onClick:s(()=>{k(m)},"onClick"),type:"button",variant:"ghost",children:e("Revoke")})})]},v.id)})})]})})})]})},"rt"),ct={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},ut=s((h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),"dt"),mt=s((h,e)=>{if(h.type==="boolean")return e===!0?{value:!0}:h.required?{value:!1}:void 0;let n=typeof e=="string"?e.trim():"";if(n!==""){if(h.type==="number"){let l=Number(n);return Number.isNaN(l)?void 0:{value:l}}return{value:n}}},"ct"),ht=s(h=>{let e=(0,W.c)(105),{onClose:n,onCreated:l}=h,o=J(),a=Q(),{config:p}=qe(),{busy:i,error:u,run:c}=Ke(),[y,w]=(0,C.useState)(""),[g,I]=(0,C.useState)(""),[k,v]=(0,C.useState)(""),[d,m]=(0,C.useState)(""),b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];let[x,N]=(0,C.useState)(b),f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=s(A=>{w(A.target.value)},"p"),e[1]=f):f=e[1];let r=f,S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=s(A=>{I(A.target.value)},"I"),e[2]=S):S=e[2];let $=S,j;e[3]===Symbol.for("react.memo_cache_sentinel")?(j=s(A=>{v(A.target.value)},"z"),e[3]=j):j=e[3];let H=j,M;e[4]===Symbol.for("react.memo_cache_sentinel")?(M=s(A=>{m(A.target.value)},"M"),e[4]=M):M=e[4];let Y=M,B;e[5]===Symbol.for("react.memo_cache_sentinel")?(B=s((A,R)=>{N(ee=>({...ee,[A]:R}))},"L"),e[5]=B):B=e[5];let V=B,G;e[6]!==x?(G=s(A=>x[A.name]??(A.type==="boolean"?!1:""),"Y"),e[6]=x,e[7]=G):G=e[7];let P=G,L;if(e[8]!==p.userFields||e[9]!==P){let A;e[11]!==P?(A=s(R=>!R.required||ut(R,P(R)),"A"),e[11]=P,e[12]=A):A=e[12],L=p.userFields.every(A),e[8]=p.userFields,e[9]=P,e[10]=L}else L=e[10];let F=L,E;e[13]!==i||e[14]!==y||e[15]!==g||e[16]!==F?(E=!i&&y.trim()!==""&&g.trim()!==""&&F,e[13]=i,e[14]=y,e[15]=g,e[16]=F,e[17]=E):E=e[17];let $e=E,ae;e[18]!==p.userFields||e[19]!==P?(ae=s(()=>{let A={};for(let R of p.userFields){let ee=mt(R,P(R));ee!==void 0&&(A[R.name]=ee.value)}return Object.keys(A).length===0?void 0:A},"te"),e[18]=p.userFields,e[19]=P,e[20]=ae):ae=e[20];let je=ae,Re;e[21]!==je||e[22]!==o||e[23]!==y||e[24]!==g||e[25]!==n||e[26]!==l||e[27]!==k||e[28]!==d||e[29]!==c?(Re=s(()=>{c(async()=>{await o.createAuthUser({data:je(),email:y.trim(),name:g.trim(),password:k===""?void 0:k,role:d.trim()===""?void 0:d.trim()}),l(),n()})},"De"),e[21]=je,e[22]=o,e[23]=y,e[24]=g,e[25]=n,e[26]=l,e[27]=k,e[28]=d,e[29]=c,e[30]=Re):Re=e[30];let Be=Re,le;e[31]!==a?(le=a("Create user"),e[31]=a,e[32]=le):le=e[32];let ne;e[33]!==a?(ne=a("Create user"),e[33]=a,e[34]=ne):ne=e[34];let ie;e[35]!==ne?(ie=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:ne}),e[35]=ne,e[36]=ie):ie=e[36];let se;e[37]!==a?(se=a("email"),e[37]=a,e[38]=se):se=e[38];let re;e[39]!==se?(re=(0,t.jsx)(O,{htmlFor:"uc-email",children:se}),e[39]=se,e[40]=re):re=e[40];let de;e[41]!==y?(de=(0,t.jsx)(T,{"data-testid":"uc-email",id:"uc-email",onChange:r,type:"email",value:y}),e[41]=y,e[42]=de):de=e[42];let oe;e[43]!==re||e[44]!==de?(oe=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[re,de]}),e[43]=re,e[44]=de,e[45]=oe):oe=e[45];let ce;e[46]!==a?(ce=a("name"),e[46]=a,e[47]=ce):ce=e[47];let ue;e[48]!==ce?(ue=(0,t.jsx)(O,{htmlFor:"uc-name",children:ce}),e[48]=ce,e[49]=ue):ue=e[49];let me;e[50]!==g?(me=(0,t.jsx)(T,{"data-testid":"uc-name",id:"uc-name",onChange:$,value:g}),e[50]=g,e[51]=me):me=e[51];let he;e[52]!==ue||e[53]!==me?(he=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[ue,me]}),e[52]=ue,e[53]=me,e[54]=he):he=e[54];let pe;e[55]!==a?(pe=a("Password (optional)"),e[55]=a,e[56]=pe):pe=e[56];let fe;e[57]!==pe?(fe=(0,t.jsx)(O,{htmlFor:"uc-password",children:pe}),e[57]=pe,e[58]=fe):fe=e[58];let ve;e[59]!==k?(ve=(0,t.jsx)(T,{"data-testid":"uc-password",id:"uc-password",onChange:H,type:"password",value:k}),e[59]=k,e[60]=ve):ve=e[60];let ge;e[61]!==fe||e[62]!==ve?(ge=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[fe,ve]}),e[61]=fe,e[62]=ve,e[63]=ge):ge=e[63];let be;e[64]!==a?(be=a("Role (optional)"),e[64]=a,e[65]=be):be=e[65];let xe;e[66]!==be?(xe=(0,t.jsx)(O,{htmlFor:"uc-role",children:be}),e[66]=be,e[67]=xe):xe=e[67];let ye;e[68]!==d?(ye=(0,t.jsx)(T,{"data-testid":"uc-role",id:"uc-role",onChange:Y,value:d}),e[68]=d,e[69]=ye):ye=e[69];let Ne;e[70]!==xe||e[71]!==ye?(Ne=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[xe,ye]}),e[70]=xe,e[71]=ye,e[72]=Ne):Ne=e[72];let ke;e[73]!==p.userFields||e[74]!==P||e[75]!==a?(ke=p.userFields.length>0&&(0,t.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Plugin fields")}),p.userFields.map(A=>{let R=`uc-field-${A.name}`,ee=A.required?"":` (${a("optional")})`;if(A.type==="boolean"){let Oe=P(A)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:R,children:[(0,t.jsx)(Ze,{checked:Oe,"data-testid":R,id:R,onCheckedChange:s(tt=>{V(A.name,tt)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[A.name,ee]})]},A.name)}let Ge=P(A);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(O,{htmlFor:R,children:[A.name,ee]}),(0,t.jsx)(T,{"data-testid":R,id:R,onChange:s(Oe=>{V(A.name,Oe.target.value)},"onChange"),type:ct[A.type],value:typeof Ge=="string"?Ge:""})]},A.name)})]}),e[73]=p.userFields,e[74]=P,e[75]=a,e[76]=ke):ke=e[76];let we;e[77]!==u?(we=u!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:u}),e[77]=u,e[78]=we):we=e[78];let Ce;e[79]!==a?(Ce=a("Cancel"),e[79]=a,e[80]=Ce):Ce=e[80];let Ie;e[81]!==n||e[82]!==Ce?(Ie=(0,t.jsx)(_,{"data-testid":"uc-cancel",onClick:n,size:"sm",type:"button",variant:"outline",children:Ce}),e[81]=n,e[82]=Ce,e[83]=Ie):Ie=e[83];let Le=!$e,Ae;e[84]!==i||e[85]!==a?(Ae=a(i?"Creating\u2026":"Create"),e[84]=i,e[85]=a,e[86]=Ae):Ae=e[86];let Se;e[87]!==Be||e[88]!==Le||e[89]!==Ae?(Se=(0,t.jsx)(_,{"data-testid":"uc-submit",disabled:Le,onClick:Be,size:"sm",type:"button",children:Ae}),e[87]=Be,e[88]=Le,e[89]=Ae,e[90]=Se):Se=e[90];let Fe;e[91]!==Ie||e[92]!==Se?(Fe=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[Ie,Se]}),e[91]=Ie,e[92]=Se,e[93]=Fe):Fe=e[93];let Te;return e[94]!==n||e[95]!==le||e[96]!==ie||e[97]!==oe||e[98]!==he||e[99]!==ge||e[100]!==Ne||e[101]!==ke||e[102]!==we||e[103]!==Fe?(Te=(0,t.jsxs)(He,{label:le,onClose:n,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[ie,oe,he,ge,Ne,ke,we,Fe]}),e[94]=n,e[95]=le,e[96]=ie,e[97]=oe,e[98]=he,e[99]=ge,e[100]=Ne,e[101]=ke,e[102]=we,e[103]=Fe,e[104]=Te):Te=e[104],Te},"ut"),Ye=s(h=>{let e=(0,W.c)(2),{children:n}=h,l;return e[0]!==n?(l=(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n}),e[0]=n,e[1]=l):l=e[1],l},"_e"),pt=s(h=>{let e=(0,W.c)(29),{busy:n,runAction:l,userId:o,version:a}=h,p=J(),i=Q(),[u,c]=(0,C.useState)(null),[y,w]=(0,C.useState)(null),g;e[0]!==p||e[1]!==o?(g=s(()=>{Z((async()=>{w(null);try{let r=await p.listAuthSessions({limit:50,userId:o});c(r.rows)}catch(r){let S=r;c(null),w(Ee(S))}})())},"g"),e[0]=p,e[1]=o,e[2]=g):g=e[2];let I;e[3]!==p||e[4]!==o||e[5]!==a?(I=[p,o,a],e[3]=p,e[4]=o,e[5]=a,e[6]=I):I=e[6],(0,C.useEffect)(g,I);let k;e[7]!==p||e[8]!==l?(k=s(r=>{l(()=>p.revokeAuthSession({sessionId:r}))},"k"),e[7]=p,e[8]=l,e[9]=k):k=e[9];let v=k,d;e[10]!==i?(d=i("Sessions"),e[10]=i,e[11]=d):d=e[11];let m;e[12]!==d?(m=(0,t.jsx)(Ye,{children:d}),e[12]=d,e[13]=m):m=e[13];let b;e[14]!==y?(b=y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:y}),e[14]=y,e[15]=b):b=e[15];let x;e[16]!==u||e[17]!==i?(x=u!==null&&u.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:i("No active sessions.")}),e[16]=u,e[17]=i,e[18]=x):x=e[18];let N;e[19]!==n||e[20]!==v||e[21]!==u||e[22]!==i?(N=u!==null&&u.length>0&&(0,t.jsx)(K,{className:"overflow-hidden py-0",children:(0,t.jsx)(X,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:i("expires")}),(0,t.jsx)(U,{children:i("ip")}),(0,t.jsx)(U,{children:i("user agent")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Pe,{children:u.map(r=>(0,t.jsxs)(q,{"data-testid":`ud-session-${r.id}`,children:[(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.expiresAt)}),(0,t.jsx)(z,{children:r.ipAddress??""}),(0,t.jsx)(z,{className:"max-w-40 truncate",children:r.userAgent??""}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-revoke-${r.id}`,disabled:n,onClick:s(()=>{v(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Revoke")})})]},r.id))})]})})}),e[19]=n,e[20]=v,e[21]=u,e[22]=i,e[23]=N):N=e[23];let f;return e[24]!==m||e[25]!==b||e[26]!==x||e[27]!==N?(f=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[m,b,x,N]}),e[24]=m,e[25]=b,e[26]=x,e[27]=N,e[28]=f):f=e[28],f},"mt"),ft=s(h=>{let e=(0,W.c)(30),{busy:n,runAction:l,userId:o,version:a}=h,p=J(),i=Q(),[u,c]=(0,C.useState)(null),[y,w]=(0,C.useState)(null),g;e[0]!==p||e[1]!==o?(g=s(()=>{Z((async()=>{w(null);try{c(await p.listAuthAccounts({userId:o}))}catch(r){let S=r;c(null),w(Ee(S))}})())},"g"),e[0]=p,e[1]=o,e[2]=g):g=e[2];let I;e[3]!==p||e[4]!==o||e[5]!==a?(I=[p,o,a],e[3]=p,e[4]=o,e[5]=a,e[6]=I):I=e[6],(0,C.useEffect)(g,I);let k;e[7]!==p||e[8]!==l||e[9]!==o?(k=s(r=>{l(()=>p.unlinkAuthAccount({accountId:r,userId:o}))},"k"),e[7]=p,e[8]=l,e[9]=o,e[10]=k):k=e[10];let v=k,d;e[11]!==i?(d=i("Linked accounts"),e[11]=i,e[12]=d):d=e[12];let m;e[13]!==d?(m=(0,t.jsx)(Ye,{children:d}),e[13]=d,e[14]=m):m=e[14];let b;e[15]!==y?(b=y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:y}),e[15]=y,e[16]=b):b=e[16];let x;e[17]!==u||e[18]!==i?(x=u!==null&&u.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:i("No linked accounts.")}),e[17]=u,e[18]=i,e[19]=x):x=e[19];let N;e[20]!==u||e[21]!==n||e[22]!==v||e[23]!==i?(N=u!==null&&u.length>0&&(0,t.jsx)(K,{className:"overflow-hidden py-0",children:(0,t.jsx)(X,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:i("provider")}),(0,t.jsx)(U,{children:i("created")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Pe,{children:u.map(r=>{let S=Ue(r.id);return(0,t.jsxs)(q,{"data-testid":`ud-account-${S}`,children:[(0,t.jsx)(z,{children:Ue(r.providerId)}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-unlink-${S}`,disabled:n,onClick:s(()=>{v(S)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Unlink")})})]},S)})})]})})}),e[20]=u,e[21]=n,e[22]=v,e[23]=i,e[24]=N):N=e[24];let f;return e[25]!==m||e[26]!==b||e[27]!==x||e[28]!==N?(f=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[m,b,x,N]}),e[25]=m,e[26]=b,e[27]=x,e[28]=N,e[29]=f):f=e[29],f},"ht"),vt=s(h=>{let e=(0,W.c)(40),{busy:n,capabilities:l,runAction:o,userId:a,version:p}=h,i=J(),u=Q(),[c,y]=(0,C.useState)(null),w;e[0]!==l.passkey||e[1]!==i||e[2]!==a?(w=s(()=>{l.passkey&&Z((async()=>{try{y(await i.listAuthPasskeys({userId:a}))}catch{y(null)}})())},"C"),e[0]=l.passkey,e[1]=i,e[2]=a,e[3]=w):w=e[3];let g;e[4]!==l.passkey||e[5]!==i||e[6]!==a||e[7]!==p?(g=[l.passkey,i,a,p],e[4]=l.passkey,e[5]=i,e[6]=a,e[7]=p,e[8]=g):g=e[8],(0,C.useEffect)(w,g);let I;e[9]!==i||e[10]!==o||e[11]!==a?(I=s(()=>{o(()=>i.disableAuthTwoFactor({userId:a}))},"w"),e[9]=i,e[10]=o,e[11]=a,e[12]=I):I=e[12];let k=I,v;e[13]!==i||e[14]!==o?(v=s(S=>{o(()=>i.deleteAuthPasskey({passkeyId:S}))},"v"),e[13]=i,e[14]=o,e[15]=v):v=e[15];let d=v,m;e[16]!==u?(m=u("Security"),e[16]=u,e[17]=m):m=e[17];let b;e[18]!==m?(b=(0,t.jsx)(Ye,{children:m}),e[18]=m,e[19]=b):b=e[19];let x;e[20]!==n||e[21]!==l.twoFactor||e[22]!==k||e[23]!==u?(x=l.twoFactor&&(0,t.jsx)(_,{"data-testid":"ud-disable-2fa",disabled:n,onClick:k,size:"sm",type:"button",variant:"outline",children:u("Disable two-factor")}),e[20]=n,e[21]=l.twoFactor,e[22]=k,e[23]=u,e[24]=x):x=e[24];let N;e[25]!==l.passkey||e[26]!==c||e[27]!==u?(N=l.passkey&&c!==null&&c.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:u("No passkeys.")}),e[25]=l.passkey,e[26]=c,e[27]=u,e[28]=N):N=e[28];let f;e[29]!==n||e[30]!==l.passkey||e[31]!==d||e[32]!==c||e[33]!==u?(f=l.passkey&&c!==null&&c.length>0&&(0,t.jsx)(K,{className:"overflow-hidden py-0",children:(0,t.jsx)(X,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-passkeys-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:u("name")}),(0,t.jsx)(U,{children:u("created")}),(0,t.jsx)(U,{"aria-label":u("Actions")})]})}),(0,t.jsx)(Pe,{children:c.map(S=>{let $=Ue(S.id);return(0,t.jsxs)(q,{"data-testid":`ud-passkey-${$}`,children:[(0,t.jsx)(z,{children:Ue(S.name)||$}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(S.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-delete-passkey-${$}`,disabled:n,onClick:s(()=>{d($)},"onClick"),size:"xs",type:"button",variant:"ghost",children:u("Delete")})})]},$)})})]})})}),e[29]=n,e[30]=l.passkey,e[31]=d,e[32]=c,e[33]=u,e[34]=f):f=e[34];let r;return e[35]!==b||e[36]!==x||e[37]!==N||e[38]!==f?(r=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[b,x,N,f]}),e[35]=b,e[36]=x,e[37]=N,e[38]=f,e[39]=r):r=e[39],r},"ft"),gt=/(?:at|expires)$/iu,bt=/^[1-9]\d*$/u,xt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),yt=s(h=>{let e=(0,W.c)(51),{busy:n,onBan:l}=h,o=Q(),[a,p]=(0,C.useState)(""),[i,u]=(0,C.useState)(""),[c,y]=(0,C.useState)(!1),w;e[0]!==i?(w=bt.test(i.trim())&&Number.isSafeInteger(Number(i.trim())*86400)?Number(i.trim()):void 0,e[0]=i,e[1]=w):w=e[1];let g=w,I=c||g!==void 0,k;e[2]!==l||e[3]!==c||e[4]!==a||e[5]!==g?(k=s(()=>{l({expiresInSeconds:c||g===void 0?void 0:g*86400,reason:a.trim()===""?void 0:a.trim()})},"k"),e[2]=l,e[3]=c,e[4]=a,e[5]=g,e[6]=k):k=e[6];let v=k,d;e[7]!==o?(d=o("Ban reason (optional)"),e[7]=o,e[8]=d):d=e[8];let m;e[9]!==d?(m=(0,t.jsx)(O,{htmlFor:"ud-ban-reason",children:d}),e[9]=d,e[10]=m):m=e[10];let b;e[11]===Symbol.for("react.memo_cache_sentinel")?(b=s(E=>{p(E.target.value)},"b"),e[11]=b):b=e[11];let x;e[12]!==a?(x=(0,t.jsx)(T,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:b,value:a}),e[12]=a,e[13]=x):x=e[13];let N;e[14]!==m||e[15]!==x?(N=(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[m,x]}),e[14]=m,e[15]=x,e[16]=N):N=e[16];let f;e[17]!==o?(f=o("Days"),e[17]=o,e[18]=f):f=e[18];let r;e[19]!==f?(r=(0,t.jsx)(O,{htmlFor:"ud-ban-days",children:f}),e[19]=f,e[20]=r):r=e[20];let S;e[21]!==i||e[22]!==g?(S=i.trim()!==""&&g===void 0,e[21]=i,e[22]=g,e[23]=S):S=e[23];let $;e[24]===Symbol.for("react.memo_cache_sentinel")?($=s(E=>{u(E.target.value)},"T"),e[24]=$):$=e[24];let j;e[25]!==i||e[26]!==c||e[27]!==S?(j=(0,t.jsx)(T,{"aria-invalid":S,"data-testid":"ud-ban-days",disabled:c,id:"ud-ban-days",min:1,onChange:$,step:1,type:"number",value:i}),e[25]=i,e[26]=c,e[27]=S,e[28]=j):j=e[28];let H;e[29]!==j||e[30]!==r?(H=(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[r,j]}),e[29]=j,e[30]=r,e[31]=H):H=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=s(E=>{y(E.target.checked)},"M"),e[32]=M):M=e[32];let Y;e[33]!==c?(Y=(0,t.jsx)("input",{checked:c,className:"size-4 accent-destructive","data-testid":"ud-ban-permanent",id:"ud-ban-permanent",onChange:M,type:"checkbox"}),e[33]=c,e[34]=Y):Y=e[34];let B;e[35]!==o?(B=o("Permanent"),e[35]=o,e[36]=B):B=e[36];let V;e[37]!==Y||e[38]!==B?(V=(0,t.jsxs)(O,{className:"flex items-center gap-1.5 pb-2 text-xs font-normal",htmlFor:"ud-ban-permanent",children:[Y,B]}),e[37]=Y,e[38]=B,e[39]=V):V=e[39];let G=n||!I,P;e[40]!==o?(P=o("Ban user"),e[40]=o,e[41]=P):P=e[41];let L;e[42]!==v||e[43]!==G||e[44]!==P?(L=(0,t.jsx)(_,{"data-testid":"ud-ban",disabled:G,onClick:v,size:"sm",type:"button",variant:"destructive",children:P}),e[42]=v,e[43]=G,e[44]=P,e[45]=L):L=e[45];let F;return e[46]!==H||e[47]!==V||e[48]!==L||e[49]!==N?(F=(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[N,H,V,L]}),e[46]=H,e[47]=V,e[48]=L,e[49]=N,e[50]=F):F=e[50],F},"bt"),Nt=s((h,e)=>typeof e=="number"&&gt.test(h)?te(e):Ue(e),"xt"),kt=s(({capabilities:h,onChanged:e,onClose:n,user:l})=>{let o=J(),a=Q(),p=l.banned===!0,[i,u]=(0,C.useState)(null),[c,y]=(0,C.useState)(!1),[w,g]=(0,C.useState)(0),[I,k]=(0,C.useState)(typeof l.role=="string"?l.role:""),[v,d]=(0,C.useState)(""),[m,b]=(0,C.useState)(null),[x,N]=(0,C.useState)(!1),f=s((F,E)=>{Z((async()=>{y(!0),u(null);try{let $e=await F();E?.refresh!==!1&&(g(ae=>ae+1),e()),E?.onResult?.($e)}catch($e){u(Ee($e))}y(!1)})())},"p"),r=s(F=>{k(F.target.value)},"i"),S=s(F=>{d(F.target.value)},"I"),$=s(()=>{let F=I.trim();F!==""&&f(async()=>{await o.setAuthUserRole({role:F,userId:l.id})})},"T"),j=s(F=>{f(async()=>{await o.banAuthUser({...F,userId:l.id})})},"z"),H=s(()=>{f(async()=>{await o.unbanAuthUser({userId:l.id})})},"j"),M=s(()=>{f(async()=>{await o.setAuthUserPassword({newPassword:v,userId:l.id}),d("")})},"M"),Y=s(()=>{f(()=>o.impersonateAuthUser({userId:l.id}),{onResult:s(F=>{b(F.token)},"onResult"),refresh:!1})},"H"),B=s(()=>{f(async()=>{await o.revokeAuthUserSessions({userId:l.id})})},"L"),V=s(()=>{f(async()=>{await o.removeAuthUser({userId:l.id}),n()})},"V"),G=s(()=>{N(!0)},"Y"),P=s(()=>{N(!1)},"E"),L=Object.entries(l).filter(([F])=>!xt.has(F));return(0,t.jsxs)(He,{label:a("User details"),onClose:n,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:l.name??l.email??l.id}),(0,t.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:l.id}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof l.role=="string"&&l.role!==""&&(0,t.jsx)(D,{variant:"secondary",children:l.role}),p?(0,t.jsx)(D,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(D,{variant:"outline",children:a("Active")}),l.emailVerified===!0?(0,t.jsx)(D,{variant:"secondary",children:a("verified")}):(0,t.jsx)(D,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(_,{"data-testid":"ud-close",onClick:n,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),i!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:i}),h.admin&&(0,t.jsxs)(K,{className:"gap-0 py-0",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Actions")})}),(0,t.jsxs)(X,{className:"flex flex-col gap-3 p-3",children:[(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(O,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(T,{"data-testid":"ud-role-input",id:"ud-role",onChange:r,value:I})]}),(0,t.jsx)(_,{"data-testid":"ud-set-role",disabled:c||I.trim()==="",onClick:$,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),p?(0,t.jsx)(_,{"data-testid":"ud-unban",disabled:c,onClick:H,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(0,t.jsx)(yt,{busy:c,onBan:j}),(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(O,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(T,{"data-testid":"ud-password",id:"ud-password",onChange:S,type:"password",value:v})]}),(0,t.jsx)(_,{"data-testid":"ud-set-password",disabled:c||v==="",onClick:M,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(_,{"data-testid":"ud-impersonate",disabled:c,onClick:Y,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(_,{"data-testid":"ud-revoke-all",disabled:c,onClick:B,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),x?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(_,{"data-testid":"ud-delete-confirm",disabled:c,onClick:V,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(_,{"data-testid":"ud-delete-cancel",onClick:P,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(_,{"data-testid":"ud-delete",disabled:c,onClick:G,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),m!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(O,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(T,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:m})]})]})]}),(0,t.jsx)(pt,{busy:c,runAction:f,userId:l.id,version:w}),h.accounts&&(0,t.jsx)(ft,{busy:c,runAction:f,userId:l.id,version:w}),(h.twoFactor||h.passkey)&&(0,t.jsx)(vt,{busy:c,capabilities:h,runAction:f,userId:l.id,version:w}),(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Fields")}),(0,t.jsx)("dl",{className:"flex flex-col",children:L.map(([F,E])=>(0,t.jsxs)("div",{className:"flex flex-col border-t border-border py-1.5",children:[(0,t.jsx)("dt",{className:"text-xs font-semibold text-muted-foreground",children:F}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:Nt(F,E)})]},F))})]})]})},"yt"),wt=50,Vt=s(({pageSize:h=wt}={})=>{let e=J(),n=Q(),[l,o]=(0,C.useState)(""),[a,p]=(0,C.useState)(""),[i,u]=(0,C.useState)(0),c=Xe(l),[y,w]=(0,C.useState)(null),[g,I]=(0,C.useState)(!1),{capabilities:k}=it(),v=c.trim(),d=a.trim(),m=De(["lunora-auth-users",v,d,h,i],()=>e.listAuthUsers({filterField:d===""?void 0:"role",filterValue:d===""?void 0:d,limit:h,offset:i,search:v===""?void 0:v}).then(r=>({...r,offset:i})),{keepPreviousData:!0}),b=m.data?.rows??null,x=m.error,N=s(()=>{m.refetch()},"N");We(()=>m.poll(),!0);let f=y===null?null:b?.find(r=>r.id===y)??null;return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(T,{"aria-label":n("Search users"),className:"w-56","data-testid":"us-search",onChange:s(r=>{o(r.target.value),u(0)},"onChange"),placeholder:n("Search by email or name\u2026"),value:l}),(0,t.jsx)(T,{"aria-label":n("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:s(r=>{p(r.target.value),u(0)},"onChange"),placeholder:n("Filter by role"),value:a}),(0,t.jsx)(_,{"data-testid":"us-new",onClick:s(()=>{I(!0)},"onClick"),size:"sm",type:"button",children:n("New user")})]}),x!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:x}),b!==null&&b.length===0&&(0,t.jsx)(Ve,{description:n("Users who sign up to your app will appear here."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:n("No users.")}),b!==null&&b.length>0&&(0,t.jsx)(K,{className:"overflow-hidden py-0",children:(0,t.jsx)(X,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"us-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:n("id")}),(0,t.jsx)(U,{children:n("email")}),(0,t.jsx)(U,{children:n("name")}),(0,t.jsx)(U,{children:n("role")}),(0,t.jsx)(U,{children:n("status")}),(0,t.jsx)(U,{children:n("verified")}),(0,t.jsx)(U,{children:n("created")}),(0,t.jsx)(U,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Pe,{children:b.map(r=>(0,t.jsxs)(q,{"data-testid":`us-row-${r.id}`,children:[(0,t.jsx)(z,{className:"font-mono text-xs",children:r.id}),(0,t.jsx)(z,{children:r.email??""}),(0,t.jsx)(z,{children:r.name??""}),(0,t.jsx)(z,{children:typeof r.role=="string"&&r.role!==""?(0,t.jsx)(D,{variant:"secondary",children:r.role}):""}),(0,t.jsx)(z,{children:r.banned===!0?(0,t.jsx)(D,{variant:"destructive",children:n("Banned")}):(0,t.jsx)(D,{variant:"success",children:n("Active")})}),(0,t.jsx)(z,{children:r.emailVerified===!0?(0,t.jsx)(D,{variant:"success",children:n("yes")}):(0,t.jsx)(D,{variant:"outline",children:n("no")})}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`us-manage-${r.id}`,onClick:s(()=>{w(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Manage")})})]},r.id))})]})})}),b!==null&&(0,t.jsx)(Je,{count:b.length,offset:m.data?.offset??0,onOffsetChange:u,pageSize:h,prefix:"us",total:m.data?.total}),f!==null&&(0,t.jsx)(kt,{capabilities:k,onChanged:N,onClose:s(()=>{w(null)},"onClose"),user:f}),g&&(0,t.jsx)(ht,{onClose:s(()=>{I(!1)},"onClose"),onCreated:N}),k.inviteOnly&&(0,t.jsx)(ot,{})]})},"jt");export{Vt as UsersPanel};
1
+ import{a as Ze}from"./chunk-7RKB5KS7.js";import{a as qe}from"./chunk-6JMKSAOS.js";import{a as Ke}from"./chunk-WVWCUB4S.js";import{a as He}from"./chunk-QJLHH3ET.js";import{a as O}from"./chunk-37WYCOQ2.js";import{a as Je}from"./chunk-VQRCJJXS.js";import"./chunk-PSMQQV6S.js";import{a as We}from"./chunk-3ZVTL2VM.js";import{a as Xe}from"./chunk-IWZ7GVQO.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import{i as T}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as _}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as D}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{b as De}from"./chunk-QTDX7WSP.js";import{l as J}from"./chunk-KPRNLQKZ.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as Ve}from"./chunk-RWVIV3U7.js";import{a as ze,b as _e,c as Pe,d as q,e as U,f as z}from"./chunk-HCTJKP5J.js";import{a as K,e as X}from"./chunk-2IKDEUCX.js";import{d as Q,h as Ee,p as Ue,q as Z,s as Qe,u as te}from"./chunk-74IYYDDI.js";import{a as s,d as Me,e as at,f as lt,g as nt}from"./chunk-I26MS5PJ.js";var C=Me(at(),1);var W=Me(lt(),1);var t=Me(nt(),1);var it=s(()=>{let h=(0,W.c)(3),{config:e,ready:n}=qe(),l;return h[0]!==e.capabilities||h[1]!==n?(l={capabilities:e.capabilities,ready:n},h[0]=e.capabilities,h[1]=n,h[2]=l):l=h[2],l},"nt"),st=s((h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending","lt"),et=500,rt=s((h,e)=>{if(!URL.canParse(h.trim()))return null;let n=new URL(h.trim());return n.searchParams.set("email",e.email),n.searchParams.set("invite",e.token),n.toString()},"at"),dt=s(h=>{let e=(0,W.c)(34),{issued:n,onSignUpPageChange:l,signUpPage:o}=h,a=Q(),[p,i]=(0,C.useState)(null),u;e[0]!==n||e[1]!==o?(u=rt(o,n),e[0]=n,e[1]=o,e[2]=u):u=e[2];let c=u,y;e[3]!==c?(y=s(()=>{let $="navigator"in globalThis?globalThis.navigator.clipboard:void 0;c===null||$===void 0||Z($.writeText(c).then(()=>(i(c),!0)))},"y"),e[3]=c,e[4]=y):y=e[4];let w=y,g;e[5]!==a?(g=a("Send this link to the invitee. It is shown once and cannot be recovered."),e[5]=a,e[6]=g):g=e[6];let I;e[7]!==g?(I=(0,t.jsx)("p",{className:"text-sm",children:g}),e[7]=g,e[8]=I):I=e[8];let k=c===null,v;e[9]!==a?(v=a("Your app's sign-up page"),e[9]=a,e[10]=v):v=e[10];let d;e[11]!==l?(d=s($=>{l($.target.value)},"r"),e[11]=l,e[12]=d):d=e[12];let m;e[13]!==o||e[14]!==k||e[15]!==v||e[16]!==d?(m=(0,t.jsx)(T,{"aria-invalid":k,"aria-label":v,"data-testid":"sign-up-invitation-page",onChange:d,value:o}),e[13]=o,e[14]=k,e[15]=v,e[16]=d,e[17]=m):m=e[17];let b=c??"",x;e[18]!==b?(x=(0,t.jsx)(T,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:b}),e[18]=b,e[19]=x):x=e[19];let N;e[20]!==p||e[21]!==c||e[22]!==a?(N=a(p!==null&&p===c?"Copied":"Copy"),e[20]=p,e[21]=c,e[22]=a,e[23]=N):N=e[23];let f;e[24]!==w||e[25]!==N?(f=(0,t.jsx)(_,{"data-testid":"sign-up-invitation-copy",onClick:w,type:"button",children:N}),e[24]=w,e[25]=N,e[26]=f):f=e[26];let r;e[27]!==x||e[28]!==f?(r=(0,t.jsxs)("div",{className:"flex gap-2",children:[x,f]}),e[27]=x,e[28]=f,e[29]=r):r=e[29];let S;return e[30]!==r||e[31]!==I||e[32]!==m?(S=(0,t.jsx)(K,{children:(0,t.jsxs)(X,{className:"flex flex-col gap-2 p-4",children:[I,m,r]})}),e[30]=r,e[31]=I,e[32]=m,e[33]=S):S=e[33],S},"it"),ot=s(()=>{let h=J(),e=Q(),[n,l]=(0,C.useState)(""),[o,a]=(0,C.useState)(null),[p,i]=(0,C.useState)(null),[u,c]=(0,C.useState)(()=>`${Qe(h.url)}/sign-up`),y=De(["lunora-auth-sign-up-invitations",et],()=>h.listAuthSignUpInvitations({limit:et})),w=y.data?.rows??null,g=y.data?.total??0,I=s(()=>{let v=n.trim();v!==""&&(a(null),Z((async()=>{try{let d=await h.createAuthSignUpInvitation({email:v}),m=typeof d.token=="string"?d.token:void 0;i(m===void 0?null:{email:v,token:m}),l(""),y.refetch()}catch(d){a(d instanceof Error?d.message:String(d))}})()))},"w"),k=s(v=>{a(null),Z((async()=>{try{await h.revokeAuthSignUpInvitation({email:v}),y.refetch()}catch(d){a(d instanceof Error?d.message:String(d))}})())},"k");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"sign-up-invitations",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-base font-medium",children:e("Sign-up invitations")}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("Only invited addresses can create an account. Nothing is emailed \u2014 send the invitee the one-time link yourself.")})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(T,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:s(v=>{l(v.target.value)},"onChange"),placeholder:e("ada@example.com"),type:"email",value:n}),(0,t.jsx)(_,{"data-testid":"sign-up-invitation-submit",onClick:I,type:"button",children:e("Invite")})]}),p!==null&&(0,t.jsx)(dt,{issued:p,onSignUpPageChange:c,signUpPage:u},p.token),(o??y.error)!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:o??y.error}),w!==null&&w.length===0&&(0,t.jsx)(Ve,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),w!==null&&g>w.length&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sign-up-invitations-truncated",children:e("Showing the most recent invitations. Query the signUpInvitation table directly to see the rest.")}),w!==null&&w.length>0&&(0,t.jsx)(K,{children:(0,t.jsx)(X,{className:"p-0",children:(0,t.jsxs)(ze,{children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:e("Email")}),(0,t.jsx)(U,{children:e("Status")}),(0,t.jsx)(U,{children:e("Expires")}),(0,t.jsx)(U,{children:e("Invited by")}),(0,t.jsx)(U,{})]})}),(0,t.jsx)(Pe,{children:w.map(v=>{let d=st(v,Date.now()),m=v.email??"";return(0,t.jsxs)(q,{"data-testid":`sign-up-invitation-${m}`,children:[(0,t.jsx)(z,{children:m}),(0,t.jsxs)(z,{"data-testid":`sign-up-invitation-status-${m}`,children:[d==="spent"&&e("Accepted"),d==="expired"&&e("Expired"),d==="pending"&&e("Pending")]}),(0,t.jsx)(z,{children:typeof v.expiresAt=="number"?te(v.expiresAt):"\u2014"}),(0,t.jsx)(z,{children:v.invitedBy??"\u2014"}),(0,t.jsx)(z,{className:"text-right",children:(0,t.jsx)(_,{onClick:s(()=>{k(m)},"onClick"),type:"button",variant:"ghost",children:e("Revoke")})})]},v.id)})})]})})})]})},"rt"),ct={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},ut=s((h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),"dt"),mt=s((h,e)=>{if(h.type==="boolean")return e===!0?{value:!0}:h.required?{value:!1}:void 0;let n=typeof e=="string"?e.trim():"";if(n!==""){if(h.type==="number"){let l=Number(n);return Number.isNaN(l)?void 0:{value:l}}return{value:n}}},"ct"),ht=s(h=>{let e=(0,W.c)(105),{onClose:n,onCreated:l}=h,o=J(),a=Q(),{config:p}=qe(),{busy:i,error:u,run:c}=Ke(),[y,w]=(0,C.useState)(""),[g,I]=(0,C.useState)(""),[k,v]=(0,C.useState)(""),[d,m]=(0,C.useState)(""),b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];let[x,N]=(0,C.useState)(b),f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=s(A=>{w(A.target.value)},"p"),e[1]=f):f=e[1];let r=f,S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=s(A=>{I(A.target.value)},"I"),e[2]=S):S=e[2];let $=S,j;e[3]===Symbol.for("react.memo_cache_sentinel")?(j=s(A=>{v(A.target.value)},"z"),e[3]=j):j=e[3];let H=j,M;e[4]===Symbol.for("react.memo_cache_sentinel")?(M=s(A=>{m(A.target.value)},"M"),e[4]=M):M=e[4];let Y=M,B;e[5]===Symbol.for("react.memo_cache_sentinel")?(B=s((A,R)=>{N(ee=>({...ee,[A]:R}))},"L"),e[5]=B):B=e[5];let V=B,G;e[6]!==x?(G=s(A=>x[A.name]??(A.type==="boolean"?!1:""),"Y"),e[6]=x,e[7]=G):G=e[7];let P=G,L;if(e[8]!==p.userFields||e[9]!==P){let A;e[11]!==P?(A=s(R=>!R.required||ut(R,P(R)),"A"),e[11]=P,e[12]=A):A=e[12],L=p.userFields.every(A),e[8]=p.userFields,e[9]=P,e[10]=L}else L=e[10];let F=L,E;e[13]!==i||e[14]!==y||e[15]!==g||e[16]!==F?(E=!i&&y.trim()!==""&&g.trim()!==""&&F,e[13]=i,e[14]=y,e[15]=g,e[16]=F,e[17]=E):E=e[17];let $e=E,ae;e[18]!==p.userFields||e[19]!==P?(ae=s(()=>{let A={};for(let R of p.userFields){let ee=mt(R,P(R));ee!==void 0&&(A[R.name]=ee.value)}return Object.keys(A).length===0?void 0:A},"te"),e[18]=p.userFields,e[19]=P,e[20]=ae):ae=e[20];let je=ae,Re;e[21]!==je||e[22]!==o||e[23]!==y||e[24]!==g||e[25]!==n||e[26]!==l||e[27]!==k||e[28]!==d||e[29]!==c?(Re=s(()=>{c(async()=>{await o.createAuthUser({data:je(),email:y.trim(),name:g.trim(),password:k===""?void 0:k,role:d.trim()===""?void 0:d.trim()}),l(),n()})},"De"),e[21]=je,e[22]=o,e[23]=y,e[24]=g,e[25]=n,e[26]=l,e[27]=k,e[28]=d,e[29]=c,e[30]=Re):Re=e[30];let Be=Re,le;e[31]!==a?(le=a("Create user"),e[31]=a,e[32]=le):le=e[32];let ne;e[33]!==a?(ne=a("Create user"),e[33]=a,e[34]=ne):ne=e[34];let ie;e[35]!==ne?(ie=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:ne}),e[35]=ne,e[36]=ie):ie=e[36];let se;e[37]!==a?(se=a("email"),e[37]=a,e[38]=se):se=e[38];let re;e[39]!==se?(re=(0,t.jsx)(O,{htmlFor:"uc-email",children:se}),e[39]=se,e[40]=re):re=e[40];let de;e[41]!==y?(de=(0,t.jsx)(T,{"data-testid":"uc-email",id:"uc-email",onChange:r,type:"email",value:y}),e[41]=y,e[42]=de):de=e[42];let oe;e[43]!==re||e[44]!==de?(oe=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[re,de]}),e[43]=re,e[44]=de,e[45]=oe):oe=e[45];let ce;e[46]!==a?(ce=a("name"),e[46]=a,e[47]=ce):ce=e[47];let ue;e[48]!==ce?(ue=(0,t.jsx)(O,{htmlFor:"uc-name",children:ce}),e[48]=ce,e[49]=ue):ue=e[49];let me;e[50]!==g?(me=(0,t.jsx)(T,{"data-testid":"uc-name",id:"uc-name",onChange:$,value:g}),e[50]=g,e[51]=me):me=e[51];let he;e[52]!==ue||e[53]!==me?(he=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[ue,me]}),e[52]=ue,e[53]=me,e[54]=he):he=e[54];let pe;e[55]!==a?(pe=a("Password (optional)"),e[55]=a,e[56]=pe):pe=e[56];let fe;e[57]!==pe?(fe=(0,t.jsx)(O,{htmlFor:"uc-password",children:pe}),e[57]=pe,e[58]=fe):fe=e[58];let ve;e[59]!==k?(ve=(0,t.jsx)(T,{"data-testid":"uc-password",id:"uc-password",onChange:H,type:"password",value:k}),e[59]=k,e[60]=ve):ve=e[60];let ge;e[61]!==fe||e[62]!==ve?(ge=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[fe,ve]}),e[61]=fe,e[62]=ve,e[63]=ge):ge=e[63];let be;e[64]!==a?(be=a("Role (optional)"),e[64]=a,e[65]=be):be=e[65];let xe;e[66]!==be?(xe=(0,t.jsx)(O,{htmlFor:"uc-role",children:be}),e[66]=be,e[67]=xe):xe=e[67];let ye;e[68]!==d?(ye=(0,t.jsx)(T,{"data-testid":"uc-role",id:"uc-role",onChange:Y,value:d}),e[68]=d,e[69]=ye):ye=e[69];let Ne;e[70]!==xe||e[71]!==ye?(Ne=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[xe,ye]}),e[70]=xe,e[71]=ye,e[72]=Ne):Ne=e[72];let ke;e[73]!==p.userFields||e[74]!==P||e[75]!==a?(ke=p.userFields.length>0&&(0,t.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Plugin fields")}),p.userFields.map(A=>{let R=`uc-field-${A.name}`,ee=A.required?"":` (${a("optional")})`;if(A.type==="boolean"){let Oe=P(A)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:R,children:[(0,t.jsx)(Ze,{checked:Oe,"data-testid":R,id:R,onCheckedChange:s(tt=>{V(A.name,tt)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[A.name,ee]})]},A.name)}let Ge=P(A);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(O,{htmlFor:R,children:[A.name,ee]}),(0,t.jsx)(T,{"data-testid":R,id:R,onChange:s(Oe=>{V(A.name,Oe.target.value)},"onChange"),type:ct[A.type],value:typeof Ge=="string"?Ge:""})]},A.name)})]}),e[73]=p.userFields,e[74]=P,e[75]=a,e[76]=ke):ke=e[76];let we;e[77]!==u?(we=u!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:u}),e[77]=u,e[78]=we):we=e[78];let Ce;e[79]!==a?(Ce=a("Cancel"),e[79]=a,e[80]=Ce):Ce=e[80];let Ie;e[81]!==n||e[82]!==Ce?(Ie=(0,t.jsx)(_,{"data-testid":"uc-cancel",onClick:n,size:"sm",type:"button",variant:"outline",children:Ce}),e[81]=n,e[82]=Ce,e[83]=Ie):Ie=e[83];let Le=!$e,Ae;e[84]!==i||e[85]!==a?(Ae=a(i?"Creating\u2026":"Create"),e[84]=i,e[85]=a,e[86]=Ae):Ae=e[86];let Se;e[87]!==Be||e[88]!==Le||e[89]!==Ae?(Se=(0,t.jsx)(_,{"data-testid":"uc-submit",disabled:Le,onClick:Be,size:"sm",type:"button",children:Ae}),e[87]=Be,e[88]=Le,e[89]=Ae,e[90]=Se):Se=e[90];let Fe;e[91]!==Ie||e[92]!==Se?(Fe=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[Ie,Se]}),e[91]=Ie,e[92]=Se,e[93]=Fe):Fe=e[93];let Te;return e[94]!==n||e[95]!==le||e[96]!==ie||e[97]!==oe||e[98]!==he||e[99]!==ge||e[100]!==Ne||e[101]!==ke||e[102]!==we||e[103]!==Fe?(Te=(0,t.jsxs)(He,{label:le,onClose:n,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[ie,oe,he,ge,Ne,ke,we,Fe]}),e[94]=n,e[95]=le,e[96]=ie,e[97]=oe,e[98]=he,e[99]=ge,e[100]=Ne,e[101]=ke,e[102]=we,e[103]=Fe,e[104]=Te):Te=e[104],Te},"ut"),Ye=s(h=>{let e=(0,W.c)(2),{children:n}=h,l;return e[0]!==n?(l=(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n}),e[0]=n,e[1]=l):l=e[1],l},"_e"),pt=s(h=>{let e=(0,W.c)(29),{busy:n,runAction:l,userId:o,version:a}=h,p=J(),i=Q(),[u,c]=(0,C.useState)(null),[y,w]=(0,C.useState)(null),g;e[0]!==p||e[1]!==o?(g=s(()=>{Z((async()=>{w(null);try{let r=await p.listAuthSessions({limit:50,userId:o});c(r.rows)}catch(r){let S=r;c(null),w(Ee(S))}})())},"g"),e[0]=p,e[1]=o,e[2]=g):g=e[2];let I;e[3]!==p||e[4]!==o||e[5]!==a?(I=[p,o,a],e[3]=p,e[4]=o,e[5]=a,e[6]=I):I=e[6],(0,C.useEffect)(g,I);let k;e[7]!==p||e[8]!==l?(k=s(r=>{l(()=>p.revokeAuthSession({sessionId:r}))},"k"),e[7]=p,e[8]=l,e[9]=k):k=e[9];let v=k,d;e[10]!==i?(d=i("Sessions"),e[10]=i,e[11]=d):d=e[11];let m;e[12]!==d?(m=(0,t.jsx)(Ye,{children:d}),e[12]=d,e[13]=m):m=e[13];let b;e[14]!==y?(b=y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:y}),e[14]=y,e[15]=b):b=e[15];let x;e[16]!==u||e[17]!==i?(x=u!==null&&u.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:i("No active sessions.")}),e[16]=u,e[17]=i,e[18]=x):x=e[18];let N;e[19]!==n||e[20]!==v||e[21]!==u||e[22]!==i?(N=u!==null&&u.length>0&&(0,t.jsx)(K,{className:"overflow-hidden py-0",children:(0,t.jsx)(X,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:i("expires")}),(0,t.jsx)(U,{children:i("ip")}),(0,t.jsx)(U,{children:i("user agent")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Pe,{children:u.map(r=>(0,t.jsxs)(q,{"data-testid":`ud-session-${r.id}`,children:[(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.expiresAt)}),(0,t.jsx)(z,{children:r.ipAddress??""}),(0,t.jsx)(z,{className:"max-w-40 truncate",children:r.userAgent??""}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-revoke-${r.id}`,disabled:n,onClick:s(()=>{v(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Revoke")})})]},r.id))})]})})}),e[19]=n,e[20]=v,e[21]=u,e[22]=i,e[23]=N):N=e[23];let f;return e[24]!==m||e[25]!==b||e[26]!==x||e[27]!==N?(f=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[m,b,x,N]}),e[24]=m,e[25]=b,e[26]=x,e[27]=N,e[28]=f):f=e[28],f},"mt"),ft=s(h=>{let e=(0,W.c)(30),{busy:n,runAction:l,userId:o,version:a}=h,p=J(),i=Q(),[u,c]=(0,C.useState)(null),[y,w]=(0,C.useState)(null),g;e[0]!==p||e[1]!==o?(g=s(()=>{Z((async()=>{w(null);try{c(await p.listAuthAccounts({userId:o}))}catch(r){let S=r;c(null),w(Ee(S))}})())},"g"),e[0]=p,e[1]=o,e[2]=g):g=e[2];let I;e[3]!==p||e[4]!==o||e[5]!==a?(I=[p,o,a],e[3]=p,e[4]=o,e[5]=a,e[6]=I):I=e[6],(0,C.useEffect)(g,I);let k;e[7]!==p||e[8]!==l||e[9]!==o?(k=s(r=>{l(()=>p.unlinkAuthAccount({accountId:r,userId:o}))},"k"),e[7]=p,e[8]=l,e[9]=o,e[10]=k):k=e[10];let v=k,d;e[11]!==i?(d=i("Linked accounts"),e[11]=i,e[12]=d):d=e[12];let m;e[13]!==d?(m=(0,t.jsx)(Ye,{children:d}),e[13]=d,e[14]=m):m=e[14];let b;e[15]!==y?(b=y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:y}),e[15]=y,e[16]=b):b=e[16];let x;e[17]!==u||e[18]!==i?(x=u!==null&&u.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:i("No linked accounts.")}),e[17]=u,e[18]=i,e[19]=x):x=e[19];let N;e[20]!==u||e[21]!==n||e[22]!==v||e[23]!==i?(N=u!==null&&u.length>0&&(0,t.jsx)(K,{className:"overflow-hidden py-0",children:(0,t.jsx)(X,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:i("provider")}),(0,t.jsx)(U,{children:i("created")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Pe,{children:u.map(r=>{let S=Ue(r.id);return(0,t.jsxs)(q,{"data-testid":`ud-account-${S}`,children:[(0,t.jsx)(z,{children:Ue(r.providerId)}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-unlink-${S}`,disabled:n,onClick:s(()=>{v(S)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Unlink")})})]},S)})})]})})}),e[20]=u,e[21]=n,e[22]=v,e[23]=i,e[24]=N):N=e[24];let f;return e[25]!==m||e[26]!==b||e[27]!==x||e[28]!==N?(f=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[m,b,x,N]}),e[25]=m,e[26]=b,e[27]=x,e[28]=N,e[29]=f):f=e[29],f},"ht"),vt=s(h=>{let e=(0,W.c)(40),{busy:n,capabilities:l,runAction:o,userId:a,version:p}=h,i=J(),u=Q(),[c,y]=(0,C.useState)(null),w;e[0]!==l.passkey||e[1]!==i||e[2]!==a?(w=s(()=>{l.passkey&&Z((async()=>{try{y(await i.listAuthPasskeys({userId:a}))}catch{y(null)}})())},"C"),e[0]=l.passkey,e[1]=i,e[2]=a,e[3]=w):w=e[3];let g;e[4]!==l.passkey||e[5]!==i||e[6]!==a||e[7]!==p?(g=[l.passkey,i,a,p],e[4]=l.passkey,e[5]=i,e[6]=a,e[7]=p,e[8]=g):g=e[8],(0,C.useEffect)(w,g);let I;e[9]!==i||e[10]!==o||e[11]!==a?(I=s(()=>{o(()=>i.disableAuthTwoFactor({userId:a}))},"w"),e[9]=i,e[10]=o,e[11]=a,e[12]=I):I=e[12];let k=I,v;e[13]!==i||e[14]!==o?(v=s(S=>{o(()=>i.deleteAuthPasskey({passkeyId:S}))},"v"),e[13]=i,e[14]=o,e[15]=v):v=e[15];let d=v,m;e[16]!==u?(m=u("Security"),e[16]=u,e[17]=m):m=e[17];let b;e[18]!==m?(b=(0,t.jsx)(Ye,{children:m}),e[18]=m,e[19]=b):b=e[19];let x;e[20]!==n||e[21]!==l.twoFactor||e[22]!==k||e[23]!==u?(x=l.twoFactor&&(0,t.jsx)(_,{"data-testid":"ud-disable-2fa",disabled:n,onClick:k,size:"sm",type:"button",variant:"outline",children:u("Disable two-factor")}),e[20]=n,e[21]=l.twoFactor,e[22]=k,e[23]=u,e[24]=x):x=e[24];let N;e[25]!==l.passkey||e[26]!==c||e[27]!==u?(N=l.passkey&&c!==null&&c.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:u("No passkeys.")}),e[25]=l.passkey,e[26]=c,e[27]=u,e[28]=N):N=e[28];let f;e[29]!==n||e[30]!==l.passkey||e[31]!==d||e[32]!==c||e[33]!==u?(f=l.passkey&&c!==null&&c.length>0&&(0,t.jsx)(K,{className:"overflow-hidden py-0",children:(0,t.jsx)(X,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-passkeys-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:u("name")}),(0,t.jsx)(U,{children:u("created")}),(0,t.jsx)(U,{"aria-label":u("Actions")})]})}),(0,t.jsx)(Pe,{children:c.map(S=>{let $=Ue(S.id);return(0,t.jsxs)(q,{"data-testid":`ud-passkey-${$}`,children:[(0,t.jsx)(z,{children:Ue(S.name)||$}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(S.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-delete-passkey-${$}`,disabled:n,onClick:s(()=>{d($)},"onClick"),size:"xs",type:"button",variant:"ghost",children:u("Delete")})})]},$)})})]})})}),e[29]=n,e[30]=l.passkey,e[31]=d,e[32]=c,e[33]=u,e[34]=f):f=e[34];let r;return e[35]!==b||e[36]!==x||e[37]!==N||e[38]!==f?(r=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[b,x,N,f]}),e[35]=b,e[36]=x,e[37]=N,e[38]=f,e[39]=r):r=e[39],r},"ft"),gt=/(?:at|expires)$/iu,bt=/^[1-9]\d*$/u,xt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),yt=s(h=>{let e=(0,W.c)(51),{busy:n,onBan:l}=h,o=Q(),[a,p]=(0,C.useState)(""),[i,u]=(0,C.useState)(""),[c,y]=(0,C.useState)(!1),w;e[0]!==i?(w=bt.test(i.trim())&&Number.isSafeInteger(Number(i.trim())*86400)?Number(i.trim()):void 0,e[0]=i,e[1]=w):w=e[1];let g=w,I=c||g!==void 0,k;e[2]!==l||e[3]!==c||e[4]!==a||e[5]!==g?(k=s(()=>{l({expiresInSeconds:c||g===void 0?void 0:g*86400,reason:a.trim()===""?void 0:a.trim()})},"k"),e[2]=l,e[3]=c,e[4]=a,e[5]=g,e[6]=k):k=e[6];let v=k,d;e[7]!==o?(d=o("Ban reason (optional)"),e[7]=o,e[8]=d):d=e[8];let m;e[9]!==d?(m=(0,t.jsx)(O,{htmlFor:"ud-ban-reason",children:d}),e[9]=d,e[10]=m):m=e[10];let b;e[11]===Symbol.for("react.memo_cache_sentinel")?(b=s(E=>{p(E.target.value)},"b"),e[11]=b):b=e[11];let x;e[12]!==a?(x=(0,t.jsx)(T,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:b,value:a}),e[12]=a,e[13]=x):x=e[13];let N;e[14]!==m||e[15]!==x?(N=(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[m,x]}),e[14]=m,e[15]=x,e[16]=N):N=e[16];let f;e[17]!==o?(f=o("Days"),e[17]=o,e[18]=f):f=e[18];let r;e[19]!==f?(r=(0,t.jsx)(O,{htmlFor:"ud-ban-days",children:f}),e[19]=f,e[20]=r):r=e[20];let S;e[21]!==i||e[22]!==g?(S=i.trim()!==""&&g===void 0,e[21]=i,e[22]=g,e[23]=S):S=e[23];let $;e[24]===Symbol.for("react.memo_cache_sentinel")?($=s(E=>{u(E.target.value)},"T"),e[24]=$):$=e[24];let j;e[25]!==i||e[26]!==c||e[27]!==S?(j=(0,t.jsx)(T,{"aria-invalid":S,"data-testid":"ud-ban-days",disabled:c,id:"ud-ban-days",min:1,onChange:$,step:1,type:"number",value:i}),e[25]=i,e[26]=c,e[27]=S,e[28]=j):j=e[28];let H;e[29]!==j||e[30]!==r?(H=(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[r,j]}),e[29]=j,e[30]=r,e[31]=H):H=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=s(E=>{y(E.target.checked)},"M"),e[32]=M):M=e[32];let Y;e[33]!==c?(Y=(0,t.jsx)("input",{checked:c,className:"size-4 accent-destructive","data-testid":"ud-ban-permanent",id:"ud-ban-permanent",onChange:M,type:"checkbox"}),e[33]=c,e[34]=Y):Y=e[34];let B;e[35]!==o?(B=o("Permanent"),e[35]=o,e[36]=B):B=e[36];let V;e[37]!==Y||e[38]!==B?(V=(0,t.jsxs)(O,{className:"flex items-center gap-1.5 pb-2 text-xs font-normal",htmlFor:"ud-ban-permanent",children:[Y,B]}),e[37]=Y,e[38]=B,e[39]=V):V=e[39];let G=n||!I,P;e[40]!==o?(P=o("Ban user"),e[40]=o,e[41]=P):P=e[41];let L;e[42]!==v||e[43]!==G||e[44]!==P?(L=(0,t.jsx)(_,{"data-testid":"ud-ban",disabled:G,onClick:v,size:"sm",type:"button",variant:"destructive",children:P}),e[42]=v,e[43]=G,e[44]=P,e[45]=L):L=e[45];let F;return e[46]!==H||e[47]!==V||e[48]!==L||e[49]!==N?(F=(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[N,H,V,L]}),e[46]=H,e[47]=V,e[48]=L,e[49]=N,e[50]=F):F=e[50],F},"bt"),Nt=s((h,e)=>typeof e=="number"&&gt.test(h)?te(e):Ue(e),"xt"),kt=s(({capabilities:h,onChanged:e,onClose:n,user:l})=>{let o=J(),a=Q(),p=l.banned===!0,[i,u]=(0,C.useState)(null),[c,y]=(0,C.useState)(!1),[w,g]=(0,C.useState)(0),[I,k]=(0,C.useState)(typeof l.role=="string"?l.role:""),[v,d]=(0,C.useState)(""),[m,b]=(0,C.useState)(null),[x,N]=(0,C.useState)(!1),f=s((F,E)=>{Z((async()=>{y(!0),u(null);try{let $e=await F();E?.refresh!==!1&&(g(ae=>ae+1),e()),E?.onResult?.($e)}catch($e){u(Ee($e))}y(!1)})())},"p"),r=s(F=>{k(F.target.value)},"i"),S=s(F=>{d(F.target.value)},"I"),$=s(()=>{let F=I.trim();F!==""&&f(async()=>{await o.setAuthUserRole({role:F,userId:l.id})})},"T"),j=s(F=>{f(async()=>{await o.banAuthUser({...F,userId:l.id})})},"z"),H=s(()=>{f(async()=>{await o.unbanAuthUser({userId:l.id})})},"j"),M=s(()=>{f(async()=>{await o.setAuthUserPassword({newPassword:v,userId:l.id}),d("")})},"M"),Y=s(()=>{f(()=>o.impersonateAuthUser({userId:l.id}),{onResult:s(F=>{b(F.token)},"onResult"),refresh:!1})},"H"),B=s(()=>{f(async()=>{await o.revokeAuthUserSessions({userId:l.id})})},"L"),V=s(()=>{f(async()=>{await o.removeAuthUser({userId:l.id}),n()})},"V"),G=s(()=>{N(!0)},"Y"),P=s(()=>{N(!1)},"E"),L=Object.entries(l).filter(([F])=>!xt.has(F));return(0,t.jsxs)(He,{label:a("User details"),onClose:n,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:l.name??l.email??l.id}),(0,t.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:l.id}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof l.role=="string"&&l.role!==""&&(0,t.jsx)(D,{variant:"secondary",children:l.role}),p?(0,t.jsx)(D,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(D,{variant:"outline",children:a("Active")}),l.emailVerified===!0?(0,t.jsx)(D,{variant:"secondary",children:a("verified")}):(0,t.jsx)(D,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(_,{"data-testid":"ud-close",onClick:n,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),i!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:i}),h.admin&&(0,t.jsxs)(K,{className:"gap-0 py-0",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Actions")})}),(0,t.jsxs)(X,{className:"flex flex-col gap-3 p-3",children:[(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(O,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(T,{"data-testid":"ud-role-input",id:"ud-role",onChange:r,value:I})]}),(0,t.jsx)(_,{"data-testid":"ud-set-role",disabled:c||I.trim()==="",onClick:$,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),p?(0,t.jsx)(_,{"data-testid":"ud-unban",disabled:c,onClick:H,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(0,t.jsx)(yt,{busy:c,onBan:j}),(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(O,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(T,{"data-testid":"ud-password",id:"ud-password",onChange:S,type:"password",value:v})]}),(0,t.jsx)(_,{"data-testid":"ud-set-password",disabled:c||v==="",onClick:M,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(_,{"data-testid":"ud-impersonate",disabled:c,onClick:Y,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(_,{"data-testid":"ud-revoke-all",disabled:c,onClick:B,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),x?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(_,{"data-testid":"ud-delete-confirm",disabled:c,onClick:V,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(_,{"data-testid":"ud-delete-cancel",onClick:P,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(_,{"data-testid":"ud-delete",disabled:c,onClick:G,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),m!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(O,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(T,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:m})]})]})]}),(0,t.jsx)(pt,{busy:c,runAction:f,userId:l.id,version:w}),h.accounts&&(0,t.jsx)(ft,{busy:c,runAction:f,userId:l.id,version:w}),(h.twoFactor||h.passkey)&&(0,t.jsx)(vt,{busy:c,capabilities:h,runAction:f,userId:l.id,version:w}),(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Fields")}),(0,t.jsx)("dl",{className:"flex flex-col",children:L.map(([F,E])=>(0,t.jsxs)("div",{className:"flex flex-col border-t border-border py-1.5",children:[(0,t.jsx)("dt",{className:"text-xs font-semibold text-muted-foreground",children:F}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:Nt(F,E)})]},F))})]})]})},"yt"),wt=50,Vt=s(({pageSize:h=wt}={})=>{let e=J(),n=Q(),[l,o]=(0,C.useState)(""),[a,p]=(0,C.useState)(""),[i,u]=(0,C.useState)(0),c=Xe(l),[y,w]=(0,C.useState)(null),[g,I]=(0,C.useState)(!1),{capabilities:k}=it(),v=c.trim(),d=a.trim(),m=De(["lunora-auth-users",v,d,h,i],()=>e.listAuthUsers({filterField:d===""?void 0:"role",filterValue:d===""?void 0:d,limit:h,offset:i,search:v===""?void 0:v}).then(r=>({...r,offset:i})),{keepPreviousData:!0}),b=m.data?.rows??null,x=m.error,N=s(()=>{m.refetch()},"N");We(()=>m.poll(),!0);let f=y===null?null:b?.find(r=>r.id===y)??null;return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(T,{"aria-label":n("Search users"),className:"w-56","data-testid":"us-search",onChange:s(r=>{o(r.target.value),u(0)},"onChange"),placeholder:n("Search by email or name\u2026"),value:l}),(0,t.jsx)(T,{"aria-label":n("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:s(r=>{p(r.target.value),u(0)},"onChange"),placeholder:n("Filter by role"),value:a}),(0,t.jsx)(_,{"data-testid":"us-new",onClick:s(()=>{I(!0)},"onClick"),size:"sm",type:"button",children:n("New user")})]}),x!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:x}),b!==null&&b.length===0&&(0,t.jsx)(Ve,{description:n("Users who sign up to your app will appear here."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:n("No users.")}),b!==null&&b.length>0&&(0,t.jsx)(K,{className:"overflow-hidden py-0",children:(0,t.jsx)(X,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"us-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:n("id")}),(0,t.jsx)(U,{children:n("email")}),(0,t.jsx)(U,{children:n("name")}),(0,t.jsx)(U,{children:n("role")}),(0,t.jsx)(U,{children:n("status")}),(0,t.jsx)(U,{children:n("verified")}),(0,t.jsx)(U,{children:n("created")}),(0,t.jsx)(U,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Pe,{children:b.map(r=>(0,t.jsxs)(q,{"data-testid":`us-row-${r.id}`,children:[(0,t.jsx)(z,{className:"font-mono text-xs",children:r.id}),(0,t.jsx)(z,{children:r.email??""}),(0,t.jsx)(z,{children:r.name??""}),(0,t.jsx)(z,{children:typeof r.role=="string"&&r.role!==""?(0,t.jsx)(D,{variant:"secondary",children:r.role}):""}),(0,t.jsx)(z,{children:r.banned===!0?(0,t.jsx)(D,{variant:"destructive",children:n("Banned")}):(0,t.jsx)(D,{variant:"success",children:n("Active")})}),(0,t.jsx)(z,{children:r.emailVerified===!0?(0,t.jsx)(D,{variant:"success",children:n("yes")}):(0,t.jsx)(D,{variant:"outline",children:n("no")})}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`us-manage-${r.id}`,onClick:s(()=>{w(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Manage")})})]},r.id))})]})})}),b!==null&&(0,t.jsx)(Je,{count:b.length,offset:m.data?.offset??0,onOffsetChange:u,pageSize:h,prefix:"us",total:m.data?.total}),f!==null&&(0,t.jsx)(kt,{capabilities:k,onChanged:N,onClose:s(()=>{w(null)},"onClose"),user:f}),g&&(0,t.jsx)(ht,{onClose:s(()=>{I(!1)},"onClose"),onCreated:N}),k.inviteOnly&&(0,t.jsx)(ot,{})]})},"jt");export{Vt as UsersPanel};