@lunora/studio 1.0.0-alpha.390 → 1.0.0-alpha.392

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 (107) hide show
  1. package/dist/index.d.mts +1 -1
  2. package/dist/index.d.ts +1 -1
  3. package/dist/packem_chunks/ai-knowledge.mjs +1 -1
  4. package/dist/packem_chunks/auth-audit-panel.mjs +1 -1
  5. package/dist/standalone/{chunk-OWCTA7GY.js → chunk-22C2K5PS.js} +1 -1
  6. package/dist/standalone/{chunk-EMZ7RPR3.js → chunk-2CMHGYZ4.js} +1 -1
  7. package/dist/standalone/{chunk-Y5QMX4YG.js → chunk-2XAJCKRP.js} +1 -1
  8. package/dist/standalone/{chunk-CXXCVBMK.js → chunk-34USSEJN.js} +1 -1
  9. package/dist/standalone/{chunk-ADS4BJ7K.js → chunk-3HVF5LKQ.js} +1 -1
  10. package/dist/standalone/{chunk-CY45AO5T.js → chunk-3RCYH6UA.js} +1 -1
  11. package/dist/standalone/{chunk-HUL247LG.js → chunk-3YBXNEUY.js} +1 -1
  12. package/dist/standalone/{chunk-ELPLRD4S.js → chunk-4YZAJTU5.js} +1 -1
  13. package/dist/standalone/{chunk-KGQPMSNY.js → chunk-5D73GSOC.js} +1 -1
  14. package/dist/standalone/{chunk-K2LXQ3LS.js → chunk-5FFKYQHT.js} +1 -1
  15. package/dist/standalone/{chunk-375GZTYC.js → chunk-6HZDJA4T.js} +1 -1
  16. package/dist/standalone/{chunk-L6VJTINV.js → chunk-6IDVWVML.js} +1 -1
  17. package/dist/standalone/{chunk-PBXRUYD3.js → chunk-6WTQL4W2.js} +1 -1
  18. package/dist/standalone/{chunk-HLBZ7OAO.js → chunk-6YDEXJRE.js} +1 -1
  19. package/dist/standalone/{chunk-U5UEDY4E.js → chunk-725JLR43.js} +1 -1
  20. package/dist/standalone/{chunk-OQTMT64P.js → chunk-7ELEYWJC.js} +1 -1
  21. package/dist/standalone/{chunk-ATBPQT7F.js → chunk-7ML357XR.js} +1 -1
  22. package/dist/standalone/{chunk-4YVCKOYF.js → chunk-7UPL6MQR.js} +1 -1
  23. package/dist/standalone/{chunk-V3DOKU22.js → chunk-7Z243YUE.js} +1 -1
  24. package/dist/standalone/{chunk-VQQEDEHH.js → chunk-ACCTEC6Y.js} +1 -1
  25. package/dist/standalone/{chunk-V5TGDG6U.js → chunk-AJFMXVR4.js} +1 -1
  26. package/dist/standalone/{chunk-2YDK4MZM.js → chunk-ANHHDGNL.js} +1 -1
  27. package/dist/standalone/{chunk-I6YVDNKQ.js → chunk-ATYVKUH7.js} +1 -1
  28. package/dist/standalone/{chunk-3WYPRZY3.js → chunk-AZ6QNL6G.js} +1 -1
  29. package/dist/standalone/{chunk-4MFQ4XEJ.js → chunk-B34JDEEO.js} +1 -1
  30. package/dist/standalone/{chunk-ZP453BM4.js → chunk-BFEX6HDU.js} +1 -1
  31. package/dist/standalone/{chunk-AXB32N5O.js → chunk-BKKE4QKE.js} +1 -1
  32. package/dist/standalone/{chunk-2ZJJH4YN.js → chunk-CDIV23I2.js} +2 -2
  33. package/dist/standalone/{chunk-IXCSVK2Z.js → chunk-COMBKDVY.js} +1 -1
  34. package/dist/standalone/{chunk-CP3LCFFM.js → chunk-D63EYK5I.js} +1 -1
  35. package/dist/standalone/{chunk-5EIGSLIK.js → chunk-D7UOJY4N.js} +1 -1
  36. package/dist/standalone/{chunk-AQG5OGO4.js → chunk-DW5KLXPI.js} +1 -1
  37. package/dist/standalone/{chunk-AXDXIMCN.js → chunk-DYPC464U.js} +1 -1
  38. package/dist/standalone/{chunk-SGIEXE5J.js → chunk-E3IVOZVW.js} +1 -1
  39. package/dist/standalone/{chunk-CFQQHZYU.js → chunk-EFEAOMEB.js} +1 -1
  40. package/dist/standalone/{chunk-3YCWRKSW.js → chunk-EMNOVYZC.js} +1 -1
  41. package/dist/standalone/{chunk-WEPANQGT.js → chunk-EXHVWM27.js} +1 -1
  42. package/dist/standalone/{chunk-MNN3YCKF.js → chunk-EYBS3Q7O.js} +1 -1
  43. package/dist/standalone/{chunk-WXZ334CL.js → chunk-EZ5PVGPY.js} +1 -1
  44. package/dist/standalone/{chunk-KZXSJF7K.js → chunk-FNBNPTCM.js} +1 -1
  45. package/dist/standalone/{chunk-EZMAQE3T.js → chunk-FT5WEK3S.js} +1 -1
  46. package/dist/standalone/{chunk-CQDENTSP.js → chunk-GVPVWT3Q.js} +1 -1
  47. package/dist/standalone/{chunk-ZADOHFZB.js → chunk-H2HGJURT.js} +1 -1
  48. package/dist/standalone/{chunk-HCK62XWB.js → chunk-HWG2R642.js} +1 -1
  49. package/dist/standalone/{chunk-FYAUOSTX.js → chunk-HYAGF6A5.js} +1 -1
  50. package/dist/standalone/{chunk-UFS6UP4Z.js → chunk-I37WFNA6.js} +1 -1
  51. package/dist/standalone/{chunk-LOEVTOKP.js → chunk-IFU5WQHZ.js} +1 -1
  52. package/dist/standalone/{chunk-APCHI5CD.js → chunk-INDH6PRB.js} +1 -1
  53. package/dist/standalone/{chunk-U7NVTULW.js → chunk-JKTAHFTK.js} +1 -1
  54. package/dist/standalone/{chunk-23MMGFHI.js → chunk-JPL3WAVW.js} +1 -1
  55. package/dist/standalone/chunk-K2I3AGZR.js +1 -0
  56. package/dist/standalone/{chunk-RJJRUUTE.js → chunk-KBPMT33Z.js} +1 -1
  57. package/dist/standalone/{chunk-ZJIYJZ6F.js → chunk-KMBE7RTC.js} +1 -1
  58. package/dist/standalone/{chunk-6K4F727K.js → chunk-KULAZ4W3.js} +1 -1
  59. package/dist/standalone/{chunk-V4B7ZPEG.js → chunk-LEF32Q5K.js} +1 -1
  60. package/dist/standalone/{chunk-YLC2ZYCL.js → chunk-LFWS6VBU.js} +1 -1
  61. package/dist/standalone/{chunk-QTWNCDLK.js → chunk-MA2KXG2L.js} +1 -1
  62. package/dist/standalone/{chunk-DZV6YFWZ.js → chunk-MPGM6L64.js} +1 -1
  63. package/dist/standalone/{chunk-L7TFQUD7.js → chunk-MVWMRJD5.js} +1 -1
  64. package/dist/standalone/{chunk-OJR7BDKC.js → chunk-N4P6WYRV.js} +1 -1
  65. package/dist/standalone/{chunk-LRUYEVHH.js → chunk-NP6H72XD.js} +1 -1
  66. package/dist/standalone/{chunk-XV2XEUUB.js → chunk-NPHGFVNE.js} +1 -1
  67. package/dist/standalone/{chunk-CO6R6GCX.js → chunk-NRWR25MB.js} +1 -1
  68. package/dist/standalone/{chunk-HMMALUXM.js → chunk-O46IV64X.js} +1 -1
  69. package/dist/standalone/{chunk-BRPLE2Z6.js → chunk-O56AZXG6.js} +1 -1
  70. package/dist/standalone/{chunk-BHUWAGFN.js → chunk-OOPMRFI2.js} +1 -1
  71. package/dist/standalone/chunk-OZUPOUHR.js +1 -0
  72. package/dist/standalone/{chunk-O66HDCZT.js → chunk-PLDE5R5Y.js} +1 -1
  73. package/dist/standalone/{chunk-NAGIOR23.js → chunk-PRVBT5AJ.js} +1 -1
  74. package/dist/standalone/{chunk-JZN3MNJX.js → chunk-PUTERXSU.js} +1 -1
  75. package/dist/standalone/{chunk-2M37OAK3.js → chunk-PYG3TDLZ.js} +1 -1
  76. package/dist/standalone/{chunk-CBTPJPCZ.js → chunk-QHI77TGI.js} +1 -1
  77. package/dist/standalone/{chunk-NP6CBOPK.js → chunk-QIROOZNJ.js} +1 -1
  78. package/dist/standalone/{chunk-Y2AKO63C.js → chunk-QMZKJK53.js} +1 -1
  79. package/dist/standalone/{chunk-HJOXP6C3.js → chunk-RIHWRGFS.js} +1 -1
  80. package/dist/standalone/{chunk-FKAOFBS3.js → chunk-RN32N6ZO.js} +1 -1
  81. package/dist/standalone/{chunk-ERUKFS3I.js → chunk-RTD3B67U.js} +1 -1
  82. package/dist/standalone/{chunk-3OVQC66W.js → chunk-RUCMNPTD.js} +1 -1
  83. package/dist/standalone/{chunk-BU5VWXRR.js → chunk-RZJAZ5ED.js} +1 -1
  84. package/dist/standalone/{chunk-7ASIMMZY.js → chunk-S64V5MAT.js} +1 -1
  85. package/dist/standalone/{chunk-EKXAE4PS.js → chunk-TFH347JK.js} +1 -1
  86. package/dist/standalone/{chunk-KIQ34774.js → chunk-TJ76NZTD.js} +1 -1
  87. package/dist/standalone/{chunk-CVJDEN5L.js → chunk-TJV64AXT.js} +1 -1
  88. package/dist/standalone/{chunk-P3ML7HGE.js → chunk-TVDBLCXQ.js} +1 -1
  89. package/dist/standalone/{chunk-LYWT6GTX.js → chunk-TVJFKXX4.js} +1 -1
  90. package/dist/standalone/{chunk-NFI2TNKU.js → chunk-UDKKUJHY.js} +1 -1
  91. package/dist/standalone/{chunk-W5BTAOHO.js → chunk-UEONVTOV.js} +1 -1
  92. package/dist/standalone/{chunk-JQBVRWFN.js → chunk-UNUSBFIC.js} +1 -1
  93. package/dist/standalone/{chunk-LLD7TMBV.js → chunk-UQ3WOVL2.js} +1 -1
  94. package/dist/standalone/{chunk-2OSZRVNW.js → chunk-UW34S35F.js} +1 -1
  95. package/dist/standalone/{chunk-UL5XVKGR.js → chunk-XHDCFSC6.js} +1 -1
  96. package/dist/standalone/{chunk-2CDROYSG.js → chunk-XKK5ABPC.js} +1 -1
  97. package/dist/standalone/{chunk-BWBECJFT.js → chunk-XYWMQVZ2.js} +1 -1
  98. package/dist/standalone/chunk-YESGXFAR.js +7 -0
  99. package/dist/standalone/{chunk-2D4WBSDO.js → chunk-Z6PYAG36.js} +1 -1
  100. package/dist/standalone/{chunk-BWHVY6L6.js → chunk-Z7ZRXPPE.js} +1 -1
  101. package/dist/standalone/{chunk-LLSK6QBX.js → chunk-ZHDO7DYM.js} +1 -1
  102. package/dist/standalone/{chunk-EYSF4DHD.js → chunk-ZIY53FID.js} +1 -1
  103. package/dist/standalone/studio.js +1 -1
  104. package/package.json +3 -3
  105. package/dist/standalone/chunk-IL64HWFW.js +0 -1
  106. package/dist/standalone/chunk-K5W5C237.js +0 -1
  107. package/dist/standalone/chunk-QFN62JQJ.js +0 -7
@@ -1 +1 @@
1
- import{a as qe}from"./chunk-5EIGSLIK.js";import{a as Je}from"./chunk-O66HDCZT.js";import{a as Ge}from"./chunk-APCHI5CD.js";import{a as Ze}from"./chunk-ATBPQT7F.js";import"./chunk-WXZ334CL.js";import{a as He}from"./chunk-UL5XVKGR.js";import{a as W}from"./chunk-MNN3YCKF.js";import{a as Xe}from"./chunk-DRHZZ7IN.js";import{a as We}from"./chunk-ERUKFS3I.js";import"./chunk-QHVUXMRV.js";import"./chunk-2NUCBQFU.js";import{i as q}from"./chunk-2D4WBSDO.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as K}from"./chunk-CBTPJPCZ.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as Me}from"./chunk-HMMALUXM.js";import{b as X}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{a as Pe,b as Re,c as Be,d as Q,e as _,f as U}from"./chunk-ZJIYJZ6F.js";import{b as je}from"./chunk-LRUYEVHH.js";import{a as ie,e as ne}from"./chunk-XV2XEUUB.js";import{n as le}from"./chunk-QFN62JQJ.js";import"./chunk-ZPQBVYNN.js";import{B as J,j as Ee,r as ee,s as te,u as Qe,w as ae}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as it}from"./chunk-A6TVTNKO.js";import{a as lt,b as nt}from"./chunk-ADABTCDI.js";import{a as r,d as Te}from"./chunk-5PEAXTYQ.js";var w=Te(lt(),1);var Z=Te(it(),1);var t=Te(nt(),1);var st=r(()=>{let h=(0,Z.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},"lt"),rt=r((h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending","it"),et=500,dt=r((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"),ot=r(h=>{let e=(0,Z.c)(34),{issued:n,onSignUpPageChange:l,signUpPage:d}=h,a=J(),[u,i]=(0,w.useState)(null),s;e[0]!==n||e[1]!==d?(s=dt(d,n),e[0]=n,e[1]=d,e[2]=s):s=e[2];let c=s,f;e[3]!==c?(f=r(()=>{let L="navigator"in globalThis?globalThis.navigator.clipboard:void 0;c===null||L===void 0||te(L.writeText(c).then(()=>(i(c),!0)))},"p"),e[3]=c,e[4]=f):f=e[4];let N=f,b;e[5]!==a?(b=a("Send this link to the invitee. It is shown once and cannot be recovered."),e[5]=a,e[6]=b):b=e[6];let F;e[7]!==b?(F=(0,t.jsx)("p",{className:"text-sm",children:b}),e[7]=b,e[8]=F):F=e[8];let C=c===null,v;e[9]!==a?(v=a("Your app's sign-up page"),e[9]=a,e[10]=v):v=e[10];let m;e[11]!==l?(m=r(L=>{l(L.target.value)},"u"),e[11]=l,e[12]=m):m=e[12];let p;e[13]!==d||e[14]!==C||e[15]!==v||e[16]!==m?(p=(0,t.jsx)(q,{"aria-invalid":C,"aria-label":v,"data-testid":"sign-up-invitation-page",onChange:m,value:d}),e[13]=d,e[14]=C,e[15]=v,e[16]=m,e[17]=p):p=e[17];let x=c??"",y;e[18]!==x?(y=(0,t.jsx)(q,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:x}),e[18]=x,e[19]=y):y=e[19];let k;e[20]!==u||e[21]!==c||e[22]!==a?(k=a(u!==null&&u===c?"Copied":"Copy"),e[20]=u,e[21]=c,e[22]=a,e[23]=k):k=e[23];let g;e[24]!==N||e[25]!==k?(g=(0,t.jsx)(K,{"data-testid":"sign-up-invitation-copy",onClick:N,type:"button",children:k}),e[24]=N,e[25]=k,e[26]=g):g=e[26];let o;e[27]!==y||e[28]!==g?(o=(0,t.jsxs)("div",{className:"flex gap-2",children:[y,g]}),e[27]=y,e[28]=g,e[29]=o):o=e[29];let S;return e[30]!==o||e[31]!==F||e[32]!==p?(S=(0,t.jsx)(ie,{children:(0,t.jsxs)(ne,{className:"flex flex-col gap-2 p-4",children:[F,p,o]})}),e[30]=o,e[31]=F,e[32]=p,e[33]=S):S=e[33],S},"rt"),ct=r(()=>{let h=le(),e=J(),[n,l]=(0,w.useState)(""),[d,a]=(0,w.useState)(null),[u,i]=(0,w.useState)(null),[s,c]=(0,w.useState)(()=>`${Qe(h.url)}/sign-up`),f=je(["lunora-auth-sign-up-invitations",et],()=>h.listAuthSignUpInvitations({limit:et})),N=f.data?.rows??null,b=f.data?.total??0,F=r(()=>{let v=n.trim();v!==""&&(a(null),te((async()=>{try{let m=await h.createAuthSignUpInvitation({email:v}),p=typeof m.token=="string"?m.token:void 0;i(p===void 0?null:{email:v,token:p}),l(""),f.refetch()}catch(m){a(m instanceof Error?m.message:String(m))}})()))},"F"),C=r(v=>{a(null),te((async()=>{try{await h.revokeAuthSignUpInvitation({email:v}),f.refetch()}catch(m){a(m instanceof Error?m.message:String(m))}})())},"C");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)(q,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:r(v=>{l(v.target.value)},"onChange"),placeholder:e("ada@example.com"),type:"email",value:n}),(0,t.jsx)(K,{"data-testid":"sign-up-invitation-submit",onClick:F,type:"button",children:e("Invite")})]}),u!==null&&(0,t.jsx)(ot,{issued:u,onSignUpPageChange:c,signUpPage:s},u.token),(d??f.error)!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:d??f.error}),N!==null&&N.length===0&&(0,t.jsx)(Me,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),N!==null&&b>N.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.")}),N!==null&&N.length>0&&(0,t.jsx)(ie,{children:(0,t.jsx)(ne,{className:"p-0",children:(0,t.jsxs)(Pe,{children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(_,{children:e("Email")}),(0,t.jsx)(_,{children:e("Status")}),(0,t.jsx)(_,{children:e("Expires")}),(0,t.jsx)(_,{children:e("Invited by")}),(0,t.jsx)(_,{})]})}),(0,t.jsx)(Be,{children:N.map(v=>{let m=rt(v,Date.now()),p=v.email??"";return(0,t.jsxs)(Q,{"data-testid":`sign-up-invitation-${p}`,children:[(0,t.jsx)(U,{children:p}),(0,t.jsxs)(U,{"data-testid":`sign-up-invitation-status-${p}`,children:[m==="spent"&&e("Accepted"),m==="expired"&&e("Expired"),m==="pending"&&e("Pending")]}),(0,t.jsx)(U,{children:typeof v.expiresAt=="number"?ae(v.expiresAt):"\u2014"}),(0,t.jsx)(U,{children:v.invitedBy??"\u2014"}),(0,t.jsx)(U,{className:"text-right",children:(0,t.jsx)(K,{onClick:r(()=>{C(p)},"onClick"),type:"button",variant:"ghost",children:e("Revoke")})})]},v.id)})})]})})})]})},"ot"),ut={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},mt=r((h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),"ct"),ht=r((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}}},"ut"),pt=r(h=>{let e=(0,Z.c)(105),{onClose:n,onCreated:l}=h,d=le(),a=J(),{config:u}=qe(),{busy:i,error:s,run:c}=Je(),[f,N]=(0,w.useState)(""),[b,F]=(0,w.useState)(""),[C,v]=(0,w.useState)(""),[m,p]=(0,w.useState)(""),x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x={},e[0]=x):x=e[0];let[y,k]=(0,w.useState)(x),g;e[1]===Symbol.for("react.memo_cache_sentinel")?(g=r(A=>{N(A.target.value)},"g"),e[1]=g):g=e[1];let o=g,S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=r(A=>{F(A.target.value)},"S"),e[2]=S):S=e[2];let L=S,E;e[3]===Symbol.for("react.memo_cache_sentinel")?(E=r(A=>{v(A.target.value)},"z"),e[3]=E):E=e[3];let H=E,j;e[4]===Symbol.for("react.memo_cache_sentinel")?(j=r(A=>{p(A.target.value)},"M"),e[4]=j):j=e[4];let Y=j,B;e[5]===Symbol.for("react.memo_cache_sentinel")?(B=r((A,M)=>{k(se=>({...se,[A]:M}))},"D"),e[5]=B):B=e[5];let O=B,T;e[6]!==y?(T=r(A=>y[A.name]??(A.type==="boolean"?!1:""),"O"),e[6]=y,e[7]=T):T=e[7];let z=T,$;if(e[8]!==u.userFields||e[9]!==z){let A;e[11]!==z?(A=r(M=>!M.required||mt(M,z(M)),"A"),e[11]=z,e[12]=A):A=e[12],$=u.userFields.every(A),e[8]=u.userFields,e[9]=z,e[10]=$}else $=e[10];let I=$,P;e[13]!==i||e[14]!==f||e[15]!==b||e[16]!==I?(P=!i&&f.trim()!==""&&b.trim()!==""&&I,e[13]=i,e[14]=f,e[15]=b,e[16]=I,e[17]=P):P=e[17];let V=P,G;e[18]!==u.userFields||e[19]!==z?(G=r(()=>{let A={};for(let M of u.userFields){let se=ht(M,z(M));se!==void 0&&(A[M.name]=se.value)}return Object.keys(A).length===0?void 0:A},"Q"),e[18]=u.userFields,e[19]=z,e[20]=G):G=e[20];let R=G,D;e[21]!==R||e[22]!==d||e[23]!==f||e[24]!==b||e[25]!==n||e[26]!==l||e[27]!==C||e[28]!==m||e[29]!==c?(D=r(()=>{c(async()=>{await d.createAuthUser({data:R(),email:f.trim(),name:b.trim(),password:C===""?void 0:C,role:m.trim()===""?void 0:m.trim()}),l(),n()})},"L"),e[21]=R,e[22]=d,e[23]=f,e[24]=b,e[25]=n,e[26]=l,e[27]=C,e[28]=m,e[29]=c,e[30]=D):D=e[30];let Oe=D,re;e[31]!==a?(re=a("Create user"),e[31]=a,e[32]=re):re=e[32];let de;e[33]!==a?(de=a("Create user"),e[33]=a,e[34]=de):de=e[34];let oe;e[35]!==de?(oe=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:de}),e[35]=de,e[36]=oe):oe=e[36];let ce;e[37]!==a?(ce=a("email"),e[37]=a,e[38]=ce):ce=e[38];let ue;e[39]!==ce?(ue=(0,t.jsx)(W,{htmlFor:"uc-email",children:ce}),e[39]=ce,e[40]=ue):ue=e[40];let me;e[41]!==f?(me=(0,t.jsx)(q,{"data-testid":"uc-email",id:"uc-email",onChange:o,type:"email",value:f}),e[41]=f,e[42]=me):me=e[42];let he;e[43]!==ue||e[44]!==me?(he=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[ue,me]}),e[43]=ue,e[44]=me,e[45]=he):he=e[45];let pe;e[46]!==a?(pe=a("name"),e[46]=a,e[47]=pe):pe=e[47];let fe;e[48]!==pe?(fe=(0,t.jsx)(W,{htmlFor:"uc-name",children:pe}),e[48]=pe,e[49]=fe):fe=e[49];let ve;e[50]!==b?(ve=(0,t.jsx)(q,{"data-testid":"uc-name",id:"uc-name",onChange:L,value:b}),e[50]=b,e[51]=ve):ve=e[51];let ge;e[52]!==fe||e[53]!==ve?(ge=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[fe,ve]}),e[52]=fe,e[53]=ve,e[54]=ge):ge=e[54];let ye;e[55]!==a?(ye=a("Password (optional)"),e[55]=a,e[56]=ye):ye=e[56];let be;e[57]!==ye?(be=(0,t.jsx)(W,{htmlFor:"uc-password",children:ye}),e[57]=ye,e[58]=be):be=e[58];let xe;e[59]!==C?(xe=(0,t.jsx)(q,{"data-testid":"uc-password",id:"uc-password",onChange:H,type:"password",value:C}),e[59]=C,e[60]=xe):xe=e[60];let Ne;e[61]!==be||e[62]!==xe?(Ne=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[be,xe]}),e[61]=be,e[62]=xe,e[63]=Ne):Ne=e[63];let ke;e[64]!==a?(ke=a("Role (optional)"),e[64]=a,e[65]=ke):ke=e[65];let we;e[66]!==ke?(we=(0,t.jsx)(W,{htmlFor:"uc-role",children:ke}),e[66]=ke,e[67]=we):we=e[67];let Ce;e[68]!==m?(Ce=(0,t.jsx)(q,{"data-testid":"uc-role",id:"uc-role",onChange:Y,value:m}),e[68]=m,e[69]=Ce):Ce=e[69];let Ie;e[70]!==we||e[71]!==Ce?(Ie=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[we,Ce]}),e[70]=we,e[71]=Ce,e[72]=Ie):Ie=e[72];let Ae;e[73]!==u.userFields||e[74]!==z||e[75]!==a?(Ae=u.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")}),u.userFields.map(A=>{let M=`uc-field-${A.name}`,se=A.required?"":` (${a("optional")})`;if(A.type==="boolean"){let Le=z(A)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:M,children:[(0,t.jsx)(Ze,{checked:Le,"data-testid":M,id:M,onCheckedChange:r(at=>{O(A.name,at)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[A.name,se]})]},A.name)}let Ve=z(A);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(W,{htmlFor:M,children:[A.name,se]}),(0,t.jsx)(q,{"data-testid":M,id:M,onChange:r(Le=>{O(A.name,Le.target.value)},"onChange"),type:ut[A.type],value:typeof Ve=="string"?Ve:""})]},A.name)})]}),e[73]=u.userFields,e[74]=z,e[75]=a,e[76]=Ae):Ae=e[76];let Se;e[77]!==s?(Se=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:s}),e[77]=s,e[78]=Se):Se=e[78];let Fe;e[79]!==a?(Fe=a("Cancel"),e[79]=a,e[80]=Fe):Fe=e[80];let Ue;e[81]!==n||e[82]!==Fe?(Ue=(0,t.jsx)(K,{"data-testid":"uc-cancel",onClick:n,size:"sm",type:"button",variant:"outline",children:Fe}),e[81]=n,e[82]=Fe,e[83]=Ue):Ue=e[83];let De=!V,ze;e[84]!==i||e[85]!==a?(ze=a(i?"Creating\u2026":"Create"),e[84]=i,e[85]=a,e[86]=ze):ze=e[86];let Ke;e[87]!==Oe||e[88]!==De||e[89]!==ze?(Ke=(0,t.jsx)(K,{"data-testid":"uc-submit",disabled:De,onClick:Oe,size:"sm",type:"button",children:ze}),e[87]=Oe,e[88]=De,e[89]=ze,e[90]=Ke):Ke=e[90];let _e;e[91]!==Ue||e[92]!==Ke?(_e=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[Ue,Ke]}),e[91]=Ue,e[92]=Ke,e[93]=_e):_e=e[93];let $e;return e[94]!==n||e[95]!==re||e[96]!==oe||e[97]!==he||e[98]!==ge||e[99]!==Ne||e[100]!==Ie||e[101]!==Ae||e[102]!==Se||e[103]!==_e?($e=(0,t.jsxs)(He,{label:re,onClose:n,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[oe,he,ge,Ne,Ie,Ae,Se,_e]}),e[94]=n,e[95]=re,e[96]=oe,e[97]=he,e[98]=ge,e[99]=Ne,e[100]=Ie,e[101]=Ae,e[102]=Se,e[103]=_e,e[104]=$e):$e=e[104],$e},"mt"),Ye=r(h=>{let e=(0,Z.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},"Me"),tt=r(h=>{let e=(0,Z.c)(15),{children:n,columns:l,testId:d}=h,a=J(),u;e[0]!==l?(u=l.map(yt),e[0]=l,e[1]=u):u=e[1];let i;e[2]!==a?(i=a("Actions"),e[2]=a,e[3]=i):i=e[3];let s;e[4]!==i?(s=(0,t.jsx)(_,{"aria-label":i}),e[4]=i,e[5]=s):s=e[5];let c;e[6]!==u||e[7]!==s?(c=(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[u,s]})}),e[6]=u,e[7]=s,e[8]=c):c=e[8];let f;e[9]!==n?(f=(0,t.jsx)(Be,{children:n}),e[9]=n,e[10]=f):f=e[10];let N;return e[11]!==c||e[12]!==f||e[13]!==d?(N=(0,t.jsx)(ie,{className:"overflow-hidden py-0",children:(0,t.jsx)(ne,{className:"px-0",children:(0,t.jsxs)(Pe,{"data-testid":d,children:[c,f]})})}),e[11]=c,e[12]=f,e[13]=d,e[14]=N):N=e[14],N},"qe"),ft=r(h=>{let e=(0,Z.c)(29),{busy:n,runAction:l,userId:d,version:a}=h,u=le(),i=J(),[s,c]=(0,w.useState)(null),[f,N]=(0,w.useState)(null),b;e[0]!==u||e[1]!==d?(b=r(()=>{te((async()=>{N(null);try{let o=await u.listAuthSessions({limit:50,userId:d});c(o.rows)}catch(o){let S=o;c(null),N(Ee(S))}})())},"b"),e[0]=u,e[1]=d,e[2]=b):b=e[2];let F;e[3]!==u||e[4]!==d||e[5]!==a?(F=[u,d,a],e[3]=u,e[4]=d,e[5]=a,e[6]=F):F=e[6],(0,w.useEffect)(b,F);let C;e[7]!==u||e[8]!==l?(C=r(o=>{l(()=>u.revokeAuthSession({sessionId:o}))},"C"),e[7]=u,e[8]=l,e[9]=C):C=e[9];let v=C,m;e[10]!==i?(m=i("Sessions"),e[10]=i,e[11]=m):m=e[11];let p;e[12]!==m?(p=(0,t.jsx)(Ye,{children:m}),e[12]=m,e[13]=p):p=e[13];let x;e[14]!==f?(x=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:f}),e[14]=f,e[15]=x):x=e[15];let y;e[16]!==s||e[17]!==i?(y=s!==null&&s.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:i("No active sessions.")}),e[16]=s,e[17]=i,e[18]=y):y=e[18];let k;e[19]!==n||e[20]!==v||e[21]!==s||e[22]!==i?(k=s!==null&&s.length>0&&(0,t.jsx)(ie,{className:"overflow-hidden py-0",children:(0,t.jsx)(ne,{className:"px-0",children:(0,t.jsxs)(Pe,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(_,{children:i("expires")}),(0,t.jsx)(_,{children:i("ip")}),(0,t.jsx)(_,{children:i("user agent")}),(0,t.jsx)(_,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Be,{children:s.map(o=>(0,t.jsxs)(Q,{"data-testid":`ud-session-${o.id}`,children:[(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(o.expiresAt)}),(0,t.jsx)(U,{children:o.ipAddress??""}),(0,t.jsx)(U,{className:"max-w-40 truncate",children:o.userAgent??""}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`ud-revoke-${o.id}`,disabled:n,onClick:r(()=>{v(o.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Revoke")})})]},o.id))})]})})}),e[19]=n,e[20]=v,e[21]=s,e[22]=i,e[23]=k):k=e[23];let g;return e[24]!==p||e[25]!==x||e[26]!==y||e[27]!==k?(g=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[p,x,y,k]}),e[24]=p,e[25]=x,e[26]=y,e[27]=k,e[28]=g):g=e[28],g},"ht"),vt=r(h=>{let e=(0,Z.c)(30),{busy:n,runAction:l,userId:d,version:a}=h,u=le(),i=J(),[s,c]=(0,w.useState)(null),[f,N]=(0,w.useState)(null),b;e[0]!==u||e[1]!==d?(b=r(()=>{te((async()=>{N(null);try{c(await u.listAuthAccounts({userId:d}))}catch(o){let S=o;c(null),N(Ee(S))}})())},"b"),e[0]=u,e[1]=d,e[2]=b):b=e[2];let F;e[3]!==u||e[4]!==d||e[5]!==a?(F=[u,d,a],e[3]=u,e[4]=d,e[5]=a,e[6]=F):F=e[6],(0,w.useEffect)(b,F);let C;e[7]!==u||e[8]!==l||e[9]!==d?(C=r(o=>{l(()=>u.unlinkAuthAccount({accountId:o,userId:d}))},"C"),e[7]=u,e[8]=l,e[9]=d,e[10]=C):C=e[10];let v=C,m;e[11]!==i?(m=i("Linked accounts"),e[11]=i,e[12]=m):m=e[12];let p;e[13]!==m?(p=(0,t.jsx)(Ye,{children:m}),e[13]=m,e[14]=p):p=e[14];let x;e[15]!==f?(x=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:f}),e[15]=f,e[16]=x):x=e[16];let y;e[17]!==s||e[18]!==i?(y=s!==null&&s.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:i("No linked accounts.")}),e[17]=s,e[18]=i,e[19]=y):y=e[19];let k;e[20]!==s||e[21]!==n||e[22]!==v||e[23]!==i?(k=s!==null&&s.length>0&&(0,t.jsx)(ie,{className:"overflow-hidden py-0",children:(0,t.jsx)(ne,{className:"px-0",children:(0,t.jsxs)(Pe,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(_,{children:i("provider")}),(0,t.jsx)(_,{children:i("created")}),(0,t.jsx)(_,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Be,{children:s.map(o=>{let S=ee(o.id);return(0,t.jsxs)(Q,{"data-testid":`ud-account-${S}`,children:[(0,t.jsx)(U,{children:ee(o.providerId)}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(o.createdAt)}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`ud-unlink-${S}`,disabled:n,onClick:r(()=>{v(S)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Unlink")})})]},S)})})]})})}),e[20]=s,e[21]=n,e[22]=v,e[23]=i,e[24]=k):k=e[24];let g;return e[25]!==p||e[26]!==x||e[27]!==y||e[28]!==k?(g=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[p,x,y,k]}),e[25]=p,e[26]=x,e[27]=y,e[28]=k,e[29]=g):g=e[29],g},"ft"),gt=r(h=>{let e=(0,Z.c)(71),{busy:n,capabilities:l,runAction:d,userId:a,version:u}=h,i=le(),s=J(),[c,f]=(0,w.useState)(null),[N,b]=(0,w.useState)(null),[F,C]=(0,w.useState)(null),[v,m]=(0,w.useState)(0),p;e[0]!==l.apiKey||e[1]!==i||e[2]!==a?(p=r(()=>{if(!l.apiKey)return;let R={live:!0};return te((async()=>{try{let D=await i.listAuthApiKeys({userId:a});R.live&&(b({rows:D,userId:a}),C(null))}catch{R.live&&C(a)}})()),()=>{R.live=!1}},"f"),e[0]=l.apiKey,e[1]=i,e[2]=a,e[3]=p):p=e[3];let x;e[4]!==v||e[5]!==l.apiKey||e[6]!==i||e[7]!==a||e[8]!==u?(x=[v,l.apiKey,i,a,u],e[4]=v,e[5]=l.apiKey,e[6]=i,e[7]=a,e[8]=u,e[9]=x):x=e[9],(0,w.useEffect)(p,x);let y=N?.userId===a?N.rows:null,k=F===a,g;e[10]!==l.passkey||e[11]!==i||e[12]!==a?(g=r(()=>{l.passkey&&te((async()=>{try{f(await i.listAuthPasskeys({userId:a}))}catch{f(null)}})())},"g"),e[10]=l.passkey,e[11]=i,e[12]=a,e[13]=g):g=e[13];let o;e[14]!==l.passkey||e[15]!==i||e[16]!==a||e[17]!==u?(o=[l.passkey,i,a,u],e[14]=l.passkey,e[15]=i,e[16]=a,e[17]=u,e[18]=o):o=e[18],(0,w.useEffect)(g,o);let S;e[19]!==i||e[20]!==d||e[21]!==a?(S=r(()=>{d(()=>i.disableAuthTwoFactor({userId:a}))},"S"),e[19]=i,e[20]=d,e[21]=a,e[22]=S):S=e[22];let L=S,E;e[23]!==i||e[24]!==d?(E=r(R=>{d(()=>i.deleteAuthPasskey({passkeyId:R}))},"z"),e[23]=i,e[24]=d,e[25]=E):E=e[25];let H=E,j;e[26]!==i||e[27]!==d?(j=r(R=>{d(()=>i.deleteAuthApiKey({apiKeyId:R}))},"M"),e[26]=i,e[27]=d,e[28]=j):j=e[28];let Y=j,B;e[29]!==s?(B=s("Security"),e[29]=s,e[30]=B):B=e[30];let O;e[31]!==B?(O=(0,t.jsx)(Ye,{children:B}),e[31]=B,e[32]=O):O=e[32];let T;e[33]!==n||e[34]!==l.twoFactor||e[35]!==L||e[36]!==s?(T=l.twoFactor&&(0,t.jsx)(K,{"data-testid":"ud-disable-2fa",disabled:n,onClick:L,size:"sm",type:"button",variant:"outline",children:s("Disable two-factor")}),e[33]=n,e[34]=l.twoFactor,e[35]=L,e[36]=s,e[37]=T):T=e[37];let z;e[38]!==l.passkey||e[39]!==c||e[40]!==s?(z=l.passkey&&c!==null&&c.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s("No passkeys.")}),e[38]=l.passkey,e[39]=c,e[40]=s,e[41]=z):z=e[41];let $;e[42]!==n||e[43]!==l.passkey||e[44]!==H||e[45]!==c||e[46]!==s?($=l.passkey&&c!==null&&c.length>0&&(0,t.jsx)(tt,{columns:[s("name"),s("created")],testId:"ud-passkeys-table",children:c.map(R=>{let D=ee(R.id);return(0,t.jsxs)(Q,{"data-testid":`ud-passkey-${D}`,children:[(0,t.jsx)(U,{children:ee(R.name)||D}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(R.createdAt)}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`ud-delete-passkey-${D}`,disabled:n,onClick:r(()=>{H(D)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Delete")})})]},D)})}),e[42]=n,e[43]=l.passkey,e[44]=H,e[45]=c,e[46]=s,e[47]=$):$=e[47];let I;e[48]!==k||e[49]!==n||e[50]!==l.apiKey||e[51]!==s?(I=l.apiKey&&k&&(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s("Could not load API keys.")}),(0,t.jsx)(K,{"data-testid":"ud-api-keys-retry",disabled:n,onClick:r(()=>{m(bt)},"onClick"),size:"xs",type:"button",variant:"outline",children:s("Retry")})]}),e[48]=k,e[49]=n,e[50]=l.apiKey,e[51]=s,e[52]=I):I=e[52];let P;e[53]!==l.apiKey||e[54]!==y||e[55]!==s?(P=l.apiKey&&y!==null&&y.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s("No API keys.")}),e[53]=l.apiKey,e[54]=y,e[55]=s,e[56]=P):P=e[56];let V;e[57]!==n||e[58]!==l.apiKey||e[59]!==y||e[60]!==Y||e[61]!==s?(V=l.apiKey&&y!==null&&y.length>0&&(0,t.jsx)(tt,{columns:[s("name"),s("Key"),s("created"),s("Expires")],testId:"ud-api-keys-table",children:y.map(R=>{let D=ee(R.id);return(0,t.jsxs)(Q,{"data-testid":`ud-api-key-${D}`,children:[(0,t.jsx)(U,{children:ee(R.name)||D}),(0,t.jsx)(U,{className:"font-mono text-muted-foreground",children:ee(R.start)||"\u2014"}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(R.createdAt)}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(R.expiresAt,s("Never"))}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`ud-revoke-api-key-${D}`,disabled:n,onClick:r(()=>{Y(D)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Revoke")})})]},D)})}),e[57]=n,e[58]=l.apiKey,e[59]=y,e[60]=Y,e[61]=s,e[62]=V):V=e[62];let G;return e[63]!==T||e[64]!==z||e[65]!==$||e[66]!==I||e[67]!==P||e[68]!==V||e[69]!==O?(G=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[O,T,z,$,I,P,V]}),e[63]=T,e[64]=z,e[65]=$,e[66]=I,e[67]=P,e[68]=V,e[69]=O,e[70]=G):G=e[70],G},"pt");function yt(h){return(0,t.jsx)(_,{children:h},h)}r(yt,"vt");function bt(h){return h+1}r(bt,"gt");var xt=/(?:at|expires)$/iu,Nt=/^[1-9]\d*$/u,kt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),wt=r(h=>{let e=(0,Z.c)(51),{busy:n,onBan:l}=h,d=J(),[a,u]=(0,w.useState)(""),[i,s]=(0,w.useState)(""),[c,f]=(0,w.useState)(!1),N;e[0]!==i?(N=Nt.test(i.trim())&&Number.isSafeInteger(Number(i.trim())*86400)?Number(i.trim()):void 0,e[0]=i,e[1]=N):N=e[1];let b=N,F=c||b!==void 0,C;e[2]!==l||e[3]!==c||e[4]!==a||e[5]!==b?(C=r(()=>{l({expiresInSeconds:c||b===void 0?void 0:b*86400,reason:a.trim()===""?void 0:a.trim()})},"C"),e[2]=l,e[3]=c,e[4]=a,e[5]=b,e[6]=C):C=e[6];let v=C,m;e[7]!==d?(m=d("Ban reason (optional)"),e[7]=d,e[8]=m):m=e[8];let p;e[9]!==m?(p=(0,t.jsx)(W,{htmlFor:"ud-ban-reason",children:m}),e[9]=m,e[10]=p):p=e[10];let x;e[11]===Symbol.for("react.memo_cache_sentinel")?(x=r(P=>{u(P.target.value)},"x"),e[11]=x):x=e[11];let y;e[12]!==a?(y=(0,t.jsx)(q,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:x,value:a}),e[12]=a,e[13]=y):y=e[13];let k;e[14]!==p||e[15]!==y?(k=(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[p,y]}),e[14]=p,e[15]=y,e[16]=k):k=e[16];let g;e[17]!==d?(g=d("Days"),e[17]=d,e[18]=g):g=e[18];let o;e[19]!==g?(o=(0,t.jsx)(W,{htmlFor:"ud-ban-days",children:g}),e[19]=g,e[20]=o):o=e[20];let S;e[21]!==i||e[22]!==b?(S=i.trim()!==""&&b===void 0,e[21]=i,e[22]=b,e[23]=S):S=e[23];let L;e[24]===Symbol.for("react.memo_cache_sentinel")?(L=r(P=>{s(P.target.value)},"_"),e[24]=L):L=e[24];let E;e[25]!==i||e[26]!==c||e[27]!==S?(E=(0,t.jsx)(q,{"aria-invalid":S,"data-testid":"ud-ban-days",disabled:c,id:"ud-ban-days",min:1,onChange:L,step:1,type:"number",value:i}),e[25]=i,e[26]=c,e[27]=S,e[28]=E):E=e[28];let H;e[29]!==E||e[30]!==o?(H=(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[o,E]}),e[29]=E,e[30]=o,e[31]=H):H=e[31];let j;e[32]===Symbol.for("react.memo_cache_sentinel")?(j=r(P=>{f(P.target.checked)},"M"),e[32]=j):j=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:j,type:"checkbox"}),e[33]=c,e[34]=Y):Y=e[34];let B;e[35]!==d?(B=d("Permanent"),e[35]=d,e[36]=B):B=e[36];let O;e[37]!==Y||e[38]!==B?(O=(0,t.jsxs)(W,{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]=O):O=e[39];let T=n||!F,z;e[40]!==d?(z=d("Ban user"),e[40]=d,e[41]=z):z=e[41];let $;e[42]!==v||e[43]!==T||e[44]!==z?($=(0,t.jsx)(K,{"data-testid":"ud-ban",disabled:T,onClick:v,size:"sm",type:"button",variant:"destructive",children:z}),e[42]=v,e[43]=T,e[44]=z,e[45]=$):$=e[45];let I;return e[46]!==H||e[47]!==O||e[48]!==$||e[49]!==k?(I=(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[k,H,O,$]}),e[46]=H,e[47]=O,e[48]=$,e[49]=k,e[50]=I):I=e[50],I},"Nt"),Ct=r((h,e)=>typeof e=="number"&&xt.test(h)?ae(e):ee(e),"kt"),It=r(({capabilities:h,onChanged:e,onClose:n,user:l})=>{let d=le(),a=J(),u=l.banned===!0,[i,s]=(0,w.useState)(null),[c,f]=(0,w.useState)(!1),[N,b]=(0,w.useState)(0),[F,C]=(0,w.useState)(typeof l.role=="string"?l.role:""),[v,m]=(0,w.useState)(""),[p,x]=(0,w.useState)(null),[y,k]=(0,w.useState)(!1),g=r((I,P)=>{te((async()=>{f(!0),s(null);try{let V=await I();P?.refresh!==!1&&(b(G=>G+1),e()),P?.onResult?.(V)}catch(V){s(Ee(V))}f(!1)})())},"g"),o=r(I=>{C(I.target.value)},"o"),S=r(I=>{m(I.target.value)},"S"),L=r(()=>{let I=F.trim();I!==""&&g(async()=>{await d.setAuthUserRole({role:I,userId:l.id})})},"_"),E=r(I=>{g(async()=>{await d.banAuthUser({...I,userId:l.id})})},"z"),H=r(()=>{g(async()=>{await d.unbanAuthUser({userId:l.id})})},"q"),j=r(()=>{g(async()=>{await d.setAuthUserPassword({newPassword:v,userId:l.id}),m("")})},"M"),Y=r(()=>{g(()=>d.impersonateAuthUser({userId:l.id}),{onResult:r(I=>{x(I.token)},"onResult"),refresh:!1})},"H"),B=r(()=>{g(async()=>{await d.revokeAuthUserSessions({userId:l.id})})},"D"),O=r(()=>{g(async()=>{await d.removeAuthUser({userId:l.id}),n()})},"B"),T=r(()=>{k(!0)},"O"),z=r(()=>{k(!1)},"U"),$=Object.entries(l).filter(([I])=>!kt.has(I));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)(X,{variant:"secondary",children:l.role}),u?(0,t.jsx)(X,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(X,{variant:"outline",children:a("Active")}),l.emailVerified===!0?(0,t.jsx)(X,{variant:"secondary",children:a("verified")}):(0,t.jsx)(X,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(K,{"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)(ie,{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)(ne,{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)(W,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(q,{"data-testid":"ud-role-input",id:"ud-role",onChange:o,value:F})]}),(0,t.jsx)(K,{"data-testid":"ud-set-role",disabled:c||F.trim()==="",onClick:L,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),u?(0,t.jsx)(K,{"data-testid":"ud-unban",disabled:c,onClick:H,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(0,t.jsx)(wt,{busy:c,onBan:E}),(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)(W,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(q,{"data-testid":"ud-password",id:"ud-password",onChange:S,type:"password",value:v})]}),(0,t.jsx)(K,{"data-testid":"ud-set-password",disabled:c||v==="",onClick:j,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(K,{"data-testid":"ud-impersonate",disabled:c,onClick:Y,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(K,{"data-testid":"ud-revoke-all",disabled:c,onClick:B,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),y?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(K,{"data-testid":"ud-delete-confirm",disabled:c,onClick:O,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(K,{"data-testid":"ud-delete-cancel",onClick:z,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(K,{"data-testid":"ud-delete",disabled:c,onClick:T,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),p!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(W,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(q,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:p})]})]})]}),(0,t.jsx)(ft,{busy:c,runAction:g,userId:l.id,version:N}),h.accounts&&(0,t.jsx)(vt,{busy:c,runAction:g,userId:l.id,version:N}),(h.twoFactor||h.passkey||h.apiKey)&&(0,t.jsx)(gt,{busy:c,capabilities:h,runAction:g,userId:l.id,version:N}),(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:$.map(([I,P])=>(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:I}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:Ct(I,P)})]},I))})]})]})},"Ct"),At=50,Ht=r(({pageSize:h=At}={})=>{let e=le(),n=J(),[l,d]=(0,w.useState)(""),[a,u]=(0,w.useState)(""),[i,s]=(0,w.useState)(0),c=Xe(l),[f,N]=(0,w.useState)(null),[b,F]=(0,w.useState)(!1),{capabilities:C}=st(),v=c.trim(),m=a.trim(),p=je(["lunora-auth-users",v,m,h,i],()=>e.listAuthUsers({filterField:m===""?void 0:"role",filterValue:m===""?void 0:m,limit:h,offset:i,search:v===""?void 0:v}).then(o=>({...o,offset:i})),{keepPreviousData:!0}),x=p.data?.rows??null,y=p.error,k=r(()=>{p.refetch()},"k");We(()=>p.poll(),!0);let g=f===null?null:x?.find(o=>o.id===f)??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)(q,{"aria-label":n("Search users"),className:"w-56","data-testid":"us-search",onChange:r(o=>{d(o.target.value),s(0)},"onChange"),placeholder:n("Search by email or name\u2026"),value:l}),(0,t.jsx)(q,{"aria-label":n("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:r(o=>{u(o.target.value),s(0)},"onChange"),placeholder:n("Filter by role"),value:a}),(0,t.jsx)(K,{"data-testid":"us-new",onClick:r(()=>{F(!0)},"onClick"),size:"sm",type:"button",children:n("New user")})]}),y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:y}),x!==null&&x.length===0&&(0,t.jsx)(Me,{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.")}),x!==null&&x.length>0&&(0,t.jsx)(ie,{className:"overflow-hidden py-0",children:(0,t.jsx)(ne,{className:"px-0",children:(0,t.jsxs)(Pe,{"data-testid":"us-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(_,{children:n("id")}),(0,t.jsx)(_,{children:n("email")}),(0,t.jsx)(_,{children:n("name")}),(0,t.jsx)(_,{children:n("role")}),(0,t.jsx)(_,{children:n("status")}),(0,t.jsx)(_,{children:n("verified")}),(0,t.jsx)(_,{children:n("created")}),(0,t.jsx)(_,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Be,{children:x.map(o=>(0,t.jsxs)(Q,{"data-testid":`us-row-${o.id}`,children:[(0,t.jsx)(U,{className:"font-mono text-xs",children:o.id}),(0,t.jsx)(U,{children:o.email??""}),(0,t.jsx)(U,{children:o.name??""}),(0,t.jsx)(U,{children:typeof o.role=="string"&&o.role!==""?(0,t.jsx)(X,{variant:"secondary",children:o.role}):""}),(0,t.jsx)(U,{children:o.banned===!0?(0,t.jsx)(X,{variant:"destructive",children:n("Banned")}):(0,t.jsx)(X,{variant:"success",children:n("Active")})}),(0,t.jsx)(U,{children:o.emailVerified===!0?(0,t.jsx)(X,{variant:"success",children:n("yes")}):(0,t.jsx)(X,{variant:"outline",children:n("no")})}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(o.createdAt)}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`us-manage-${o.id}`,onClick:r(()=>{N(o.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Manage")})})]},o.id))})]})})}),x!==null&&(0,t.jsx)(Ge,{count:x.length,offset:p.data?.offset??0,onOffsetChange:s,pageSize:h,prefix:"us",total:p.data?.total}),g!==null&&(0,t.jsx)(It,{capabilities:C,onChanged:k,onClose:r(()=>{N(null)},"onClose"),user:g}),b&&(0,t.jsx)(pt,{onClose:r(()=>{F(!1)},"onClose"),onCreated:k}),C.inviteOnly&&(0,t.jsx)(ct,{})]})},"Ht");export{Ht as UsersPanel};
1
+ import{a as qe}from"./chunk-D7UOJY4N.js";import{a as Je}from"./chunk-PLDE5R5Y.js";import{a as Ge}from"./chunk-INDH6PRB.js";import{a as Ze}from"./chunk-7ML357XR.js";import"./chunk-EZ5PVGPY.js";import{a as He}from"./chunk-XHDCFSC6.js";import{a as W}from"./chunk-EYBS3Q7O.js";import{a as Xe}from"./chunk-DRHZZ7IN.js";import{a as We}from"./chunk-RTD3B67U.js";import"./chunk-QHVUXMRV.js";import"./chunk-2NUCBQFU.js";import{i as q}from"./chunk-Z6PYAG36.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as K}from"./chunk-QHI77TGI.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as Me}from"./chunk-O46IV64X.js";import{b as X}from"./chunk-OOPMRFI2.js";import"./chunk-L27FKJTG.js";import{a as Pe,b as Re,c as Be,d as Q,e as _,f as U}from"./chunk-KMBE7RTC.js";import{b as je}from"./chunk-NP6H72XD.js";import{a as ie,e as ne}from"./chunk-NPHGFVNE.js";import{n as le}from"./chunk-YESGXFAR.js";import"./chunk-ZPQBVYNN.js";import{B as J,j as Ee,r as ee,s as te,u as Qe,w as ae}from"./chunk-CDIV23I2.js";import"./chunk-PDBW6GTJ.js";import{a as it}from"./chunk-A6TVTNKO.js";import{a as lt,b as nt}from"./chunk-ADABTCDI.js";import{a as r,d as Te}from"./chunk-5PEAXTYQ.js";var w=Te(lt(),1);var Z=Te(it(),1);var t=Te(nt(),1);var st=r(()=>{let h=(0,Z.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},"lt"),rt=r((h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending","it"),et=500,dt=r((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"),ot=r(h=>{let e=(0,Z.c)(34),{issued:n,onSignUpPageChange:l,signUpPage:d}=h,a=J(),[u,i]=(0,w.useState)(null),s;e[0]!==n||e[1]!==d?(s=dt(d,n),e[0]=n,e[1]=d,e[2]=s):s=e[2];let c=s,f;e[3]!==c?(f=r(()=>{let L="navigator"in globalThis?globalThis.navigator.clipboard:void 0;c===null||L===void 0||te(L.writeText(c).then(()=>(i(c),!0)))},"p"),e[3]=c,e[4]=f):f=e[4];let N=f,b;e[5]!==a?(b=a("Send this link to the invitee. It is shown once and cannot be recovered."),e[5]=a,e[6]=b):b=e[6];let F;e[7]!==b?(F=(0,t.jsx)("p",{className:"text-sm",children:b}),e[7]=b,e[8]=F):F=e[8];let C=c===null,v;e[9]!==a?(v=a("Your app's sign-up page"),e[9]=a,e[10]=v):v=e[10];let m;e[11]!==l?(m=r(L=>{l(L.target.value)},"u"),e[11]=l,e[12]=m):m=e[12];let p;e[13]!==d||e[14]!==C||e[15]!==v||e[16]!==m?(p=(0,t.jsx)(q,{"aria-invalid":C,"aria-label":v,"data-testid":"sign-up-invitation-page",onChange:m,value:d}),e[13]=d,e[14]=C,e[15]=v,e[16]=m,e[17]=p):p=e[17];let x=c??"",y;e[18]!==x?(y=(0,t.jsx)(q,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:x}),e[18]=x,e[19]=y):y=e[19];let k;e[20]!==u||e[21]!==c||e[22]!==a?(k=a(u!==null&&u===c?"Copied":"Copy"),e[20]=u,e[21]=c,e[22]=a,e[23]=k):k=e[23];let g;e[24]!==N||e[25]!==k?(g=(0,t.jsx)(K,{"data-testid":"sign-up-invitation-copy",onClick:N,type:"button",children:k}),e[24]=N,e[25]=k,e[26]=g):g=e[26];let o;e[27]!==y||e[28]!==g?(o=(0,t.jsxs)("div",{className:"flex gap-2",children:[y,g]}),e[27]=y,e[28]=g,e[29]=o):o=e[29];let S;return e[30]!==o||e[31]!==F||e[32]!==p?(S=(0,t.jsx)(ie,{children:(0,t.jsxs)(ne,{className:"flex flex-col gap-2 p-4",children:[F,p,o]})}),e[30]=o,e[31]=F,e[32]=p,e[33]=S):S=e[33],S},"rt"),ct=r(()=>{let h=le(),e=J(),[n,l]=(0,w.useState)(""),[d,a]=(0,w.useState)(null),[u,i]=(0,w.useState)(null),[s,c]=(0,w.useState)(()=>`${Qe(h.url)}/sign-up`),f=je(["lunora-auth-sign-up-invitations",et],()=>h.listAuthSignUpInvitations({limit:et})),N=f.data?.rows??null,b=f.data?.total??0,F=r(()=>{let v=n.trim();v!==""&&(a(null),te((async()=>{try{let m=await h.createAuthSignUpInvitation({email:v}),p=typeof m.token=="string"?m.token:void 0;i(p===void 0?null:{email:v,token:p}),l(""),f.refetch()}catch(m){a(m instanceof Error?m.message:String(m))}})()))},"F"),C=r(v=>{a(null),te((async()=>{try{await h.revokeAuthSignUpInvitation({email:v}),f.refetch()}catch(m){a(m instanceof Error?m.message:String(m))}})())},"C");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)(q,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:r(v=>{l(v.target.value)},"onChange"),placeholder:e("ada@example.com"),type:"email",value:n}),(0,t.jsx)(K,{"data-testid":"sign-up-invitation-submit",onClick:F,type:"button",children:e("Invite")})]}),u!==null&&(0,t.jsx)(ot,{issued:u,onSignUpPageChange:c,signUpPage:s},u.token),(d??f.error)!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:d??f.error}),N!==null&&N.length===0&&(0,t.jsx)(Me,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),N!==null&&b>N.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.")}),N!==null&&N.length>0&&(0,t.jsx)(ie,{children:(0,t.jsx)(ne,{className:"p-0",children:(0,t.jsxs)(Pe,{children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(_,{children:e("Email")}),(0,t.jsx)(_,{children:e("Status")}),(0,t.jsx)(_,{children:e("Expires")}),(0,t.jsx)(_,{children:e("Invited by")}),(0,t.jsx)(_,{})]})}),(0,t.jsx)(Be,{children:N.map(v=>{let m=rt(v,Date.now()),p=v.email??"";return(0,t.jsxs)(Q,{"data-testid":`sign-up-invitation-${p}`,children:[(0,t.jsx)(U,{children:p}),(0,t.jsxs)(U,{"data-testid":`sign-up-invitation-status-${p}`,children:[m==="spent"&&e("Accepted"),m==="expired"&&e("Expired"),m==="pending"&&e("Pending")]}),(0,t.jsx)(U,{children:typeof v.expiresAt=="number"?ae(v.expiresAt):"\u2014"}),(0,t.jsx)(U,{children:v.invitedBy??"\u2014"}),(0,t.jsx)(U,{className:"text-right",children:(0,t.jsx)(K,{onClick:r(()=>{C(p)},"onClick"),type:"button",variant:"ghost",children:e("Revoke")})})]},v.id)})})]})})})]})},"ot"),ut={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},mt=r((h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),"ct"),ht=r((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}}},"ut"),pt=r(h=>{let e=(0,Z.c)(105),{onClose:n,onCreated:l}=h,d=le(),a=J(),{config:u}=qe(),{busy:i,error:s,run:c}=Je(),[f,N]=(0,w.useState)(""),[b,F]=(0,w.useState)(""),[C,v]=(0,w.useState)(""),[m,p]=(0,w.useState)(""),x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x={},e[0]=x):x=e[0];let[y,k]=(0,w.useState)(x),g;e[1]===Symbol.for("react.memo_cache_sentinel")?(g=r(A=>{N(A.target.value)},"g"),e[1]=g):g=e[1];let o=g,S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=r(A=>{F(A.target.value)},"S"),e[2]=S):S=e[2];let L=S,E;e[3]===Symbol.for("react.memo_cache_sentinel")?(E=r(A=>{v(A.target.value)},"z"),e[3]=E):E=e[3];let H=E,j;e[4]===Symbol.for("react.memo_cache_sentinel")?(j=r(A=>{p(A.target.value)},"M"),e[4]=j):j=e[4];let Y=j,B;e[5]===Symbol.for("react.memo_cache_sentinel")?(B=r((A,M)=>{k(se=>({...se,[A]:M}))},"D"),e[5]=B):B=e[5];let O=B,T;e[6]!==y?(T=r(A=>y[A.name]??(A.type==="boolean"?!1:""),"O"),e[6]=y,e[7]=T):T=e[7];let z=T,$;if(e[8]!==u.userFields||e[9]!==z){let A;e[11]!==z?(A=r(M=>!M.required||mt(M,z(M)),"A"),e[11]=z,e[12]=A):A=e[12],$=u.userFields.every(A),e[8]=u.userFields,e[9]=z,e[10]=$}else $=e[10];let I=$,P;e[13]!==i||e[14]!==f||e[15]!==b||e[16]!==I?(P=!i&&f.trim()!==""&&b.trim()!==""&&I,e[13]=i,e[14]=f,e[15]=b,e[16]=I,e[17]=P):P=e[17];let V=P,G;e[18]!==u.userFields||e[19]!==z?(G=r(()=>{let A={};for(let M of u.userFields){let se=ht(M,z(M));se!==void 0&&(A[M.name]=se.value)}return Object.keys(A).length===0?void 0:A},"Q"),e[18]=u.userFields,e[19]=z,e[20]=G):G=e[20];let R=G,D;e[21]!==R||e[22]!==d||e[23]!==f||e[24]!==b||e[25]!==n||e[26]!==l||e[27]!==C||e[28]!==m||e[29]!==c?(D=r(()=>{c(async()=>{await d.createAuthUser({data:R(),email:f.trim(),name:b.trim(),password:C===""?void 0:C,role:m.trim()===""?void 0:m.trim()}),l(),n()})},"L"),e[21]=R,e[22]=d,e[23]=f,e[24]=b,e[25]=n,e[26]=l,e[27]=C,e[28]=m,e[29]=c,e[30]=D):D=e[30];let Oe=D,re;e[31]!==a?(re=a("Create user"),e[31]=a,e[32]=re):re=e[32];let de;e[33]!==a?(de=a("Create user"),e[33]=a,e[34]=de):de=e[34];let oe;e[35]!==de?(oe=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:de}),e[35]=de,e[36]=oe):oe=e[36];let ce;e[37]!==a?(ce=a("email"),e[37]=a,e[38]=ce):ce=e[38];let ue;e[39]!==ce?(ue=(0,t.jsx)(W,{htmlFor:"uc-email",children:ce}),e[39]=ce,e[40]=ue):ue=e[40];let me;e[41]!==f?(me=(0,t.jsx)(q,{"data-testid":"uc-email",id:"uc-email",onChange:o,type:"email",value:f}),e[41]=f,e[42]=me):me=e[42];let he;e[43]!==ue||e[44]!==me?(he=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[ue,me]}),e[43]=ue,e[44]=me,e[45]=he):he=e[45];let pe;e[46]!==a?(pe=a("name"),e[46]=a,e[47]=pe):pe=e[47];let fe;e[48]!==pe?(fe=(0,t.jsx)(W,{htmlFor:"uc-name",children:pe}),e[48]=pe,e[49]=fe):fe=e[49];let ve;e[50]!==b?(ve=(0,t.jsx)(q,{"data-testid":"uc-name",id:"uc-name",onChange:L,value:b}),e[50]=b,e[51]=ve):ve=e[51];let ge;e[52]!==fe||e[53]!==ve?(ge=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[fe,ve]}),e[52]=fe,e[53]=ve,e[54]=ge):ge=e[54];let ye;e[55]!==a?(ye=a("Password (optional)"),e[55]=a,e[56]=ye):ye=e[56];let be;e[57]!==ye?(be=(0,t.jsx)(W,{htmlFor:"uc-password",children:ye}),e[57]=ye,e[58]=be):be=e[58];let xe;e[59]!==C?(xe=(0,t.jsx)(q,{"data-testid":"uc-password",id:"uc-password",onChange:H,type:"password",value:C}),e[59]=C,e[60]=xe):xe=e[60];let Ne;e[61]!==be||e[62]!==xe?(Ne=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[be,xe]}),e[61]=be,e[62]=xe,e[63]=Ne):Ne=e[63];let ke;e[64]!==a?(ke=a("Role (optional)"),e[64]=a,e[65]=ke):ke=e[65];let we;e[66]!==ke?(we=(0,t.jsx)(W,{htmlFor:"uc-role",children:ke}),e[66]=ke,e[67]=we):we=e[67];let Ce;e[68]!==m?(Ce=(0,t.jsx)(q,{"data-testid":"uc-role",id:"uc-role",onChange:Y,value:m}),e[68]=m,e[69]=Ce):Ce=e[69];let Ie;e[70]!==we||e[71]!==Ce?(Ie=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[we,Ce]}),e[70]=we,e[71]=Ce,e[72]=Ie):Ie=e[72];let Ae;e[73]!==u.userFields||e[74]!==z||e[75]!==a?(Ae=u.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")}),u.userFields.map(A=>{let M=`uc-field-${A.name}`,se=A.required?"":` (${a("optional")})`;if(A.type==="boolean"){let Le=z(A)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:M,children:[(0,t.jsx)(Ze,{checked:Le,"data-testid":M,id:M,onCheckedChange:r(at=>{O(A.name,at)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[A.name,se]})]},A.name)}let Ve=z(A);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(W,{htmlFor:M,children:[A.name,se]}),(0,t.jsx)(q,{"data-testid":M,id:M,onChange:r(Le=>{O(A.name,Le.target.value)},"onChange"),type:ut[A.type],value:typeof Ve=="string"?Ve:""})]},A.name)})]}),e[73]=u.userFields,e[74]=z,e[75]=a,e[76]=Ae):Ae=e[76];let Se;e[77]!==s?(Se=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:s}),e[77]=s,e[78]=Se):Se=e[78];let Fe;e[79]!==a?(Fe=a("Cancel"),e[79]=a,e[80]=Fe):Fe=e[80];let Ue;e[81]!==n||e[82]!==Fe?(Ue=(0,t.jsx)(K,{"data-testid":"uc-cancel",onClick:n,size:"sm",type:"button",variant:"outline",children:Fe}),e[81]=n,e[82]=Fe,e[83]=Ue):Ue=e[83];let De=!V,ze;e[84]!==i||e[85]!==a?(ze=a(i?"Creating\u2026":"Create"),e[84]=i,e[85]=a,e[86]=ze):ze=e[86];let Ke;e[87]!==Oe||e[88]!==De||e[89]!==ze?(Ke=(0,t.jsx)(K,{"data-testid":"uc-submit",disabled:De,onClick:Oe,size:"sm",type:"button",children:ze}),e[87]=Oe,e[88]=De,e[89]=ze,e[90]=Ke):Ke=e[90];let _e;e[91]!==Ue||e[92]!==Ke?(_e=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[Ue,Ke]}),e[91]=Ue,e[92]=Ke,e[93]=_e):_e=e[93];let $e;return e[94]!==n||e[95]!==re||e[96]!==oe||e[97]!==he||e[98]!==ge||e[99]!==Ne||e[100]!==Ie||e[101]!==Ae||e[102]!==Se||e[103]!==_e?($e=(0,t.jsxs)(He,{label:re,onClose:n,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[oe,he,ge,Ne,Ie,Ae,Se,_e]}),e[94]=n,e[95]=re,e[96]=oe,e[97]=he,e[98]=ge,e[99]=Ne,e[100]=Ie,e[101]=Ae,e[102]=Se,e[103]=_e,e[104]=$e):$e=e[104],$e},"mt"),Ye=r(h=>{let e=(0,Z.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},"Me"),tt=r(h=>{let e=(0,Z.c)(15),{children:n,columns:l,testId:d}=h,a=J(),u;e[0]!==l?(u=l.map(yt),e[0]=l,e[1]=u):u=e[1];let i;e[2]!==a?(i=a("Actions"),e[2]=a,e[3]=i):i=e[3];let s;e[4]!==i?(s=(0,t.jsx)(_,{"aria-label":i}),e[4]=i,e[5]=s):s=e[5];let c;e[6]!==u||e[7]!==s?(c=(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[u,s]})}),e[6]=u,e[7]=s,e[8]=c):c=e[8];let f;e[9]!==n?(f=(0,t.jsx)(Be,{children:n}),e[9]=n,e[10]=f):f=e[10];let N;return e[11]!==c||e[12]!==f||e[13]!==d?(N=(0,t.jsx)(ie,{className:"overflow-hidden py-0",children:(0,t.jsx)(ne,{className:"px-0",children:(0,t.jsxs)(Pe,{"data-testid":d,children:[c,f]})})}),e[11]=c,e[12]=f,e[13]=d,e[14]=N):N=e[14],N},"qe"),ft=r(h=>{let e=(0,Z.c)(29),{busy:n,runAction:l,userId:d,version:a}=h,u=le(),i=J(),[s,c]=(0,w.useState)(null),[f,N]=(0,w.useState)(null),b;e[0]!==u||e[1]!==d?(b=r(()=>{te((async()=>{N(null);try{let o=await u.listAuthSessions({limit:50,userId:d});c(o.rows)}catch(o){let S=o;c(null),N(Ee(S))}})())},"b"),e[0]=u,e[1]=d,e[2]=b):b=e[2];let F;e[3]!==u||e[4]!==d||e[5]!==a?(F=[u,d,a],e[3]=u,e[4]=d,e[5]=a,e[6]=F):F=e[6],(0,w.useEffect)(b,F);let C;e[7]!==u||e[8]!==l?(C=r(o=>{l(()=>u.revokeAuthSession({sessionId:o}))},"C"),e[7]=u,e[8]=l,e[9]=C):C=e[9];let v=C,m;e[10]!==i?(m=i("Sessions"),e[10]=i,e[11]=m):m=e[11];let p;e[12]!==m?(p=(0,t.jsx)(Ye,{children:m}),e[12]=m,e[13]=p):p=e[13];let x;e[14]!==f?(x=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:f}),e[14]=f,e[15]=x):x=e[15];let y;e[16]!==s||e[17]!==i?(y=s!==null&&s.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:i("No active sessions.")}),e[16]=s,e[17]=i,e[18]=y):y=e[18];let k;e[19]!==n||e[20]!==v||e[21]!==s||e[22]!==i?(k=s!==null&&s.length>0&&(0,t.jsx)(ie,{className:"overflow-hidden py-0",children:(0,t.jsx)(ne,{className:"px-0",children:(0,t.jsxs)(Pe,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(_,{children:i("expires")}),(0,t.jsx)(_,{children:i("ip")}),(0,t.jsx)(_,{children:i("user agent")}),(0,t.jsx)(_,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Be,{children:s.map(o=>(0,t.jsxs)(Q,{"data-testid":`ud-session-${o.id}`,children:[(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(o.expiresAt)}),(0,t.jsx)(U,{children:o.ipAddress??""}),(0,t.jsx)(U,{className:"max-w-40 truncate",children:o.userAgent??""}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`ud-revoke-${o.id}`,disabled:n,onClick:r(()=>{v(o.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Revoke")})})]},o.id))})]})})}),e[19]=n,e[20]=v,e[21]=s,e[22]=i,e[23]=k):k=e[23];let g;return e[24]!==p||e[25]!==x||e[26]!==y||e[27]!==k?(g=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[p,x,y,k]}),e[24]=p,e[25]=x,e[26]=y,e[27]=k,e[28]=g):g=e[28],g},"ht"),vt=r(h=>{let e=(0,Z.c)(30),{busy:n,runAction:l,userId:d,version:a}=h,u=le(),i=J(),[s,c]=(0,w.useState)(null),[f,N]=(0,w.useState)(null),b;e[0]!==u||e[1]!==d?(b=r(()=>{te((async()=>{N(null);try{c(await u.listAuthAccounts({userId:d}))}catch(o){let S=o;c(null),N(Ee(S))}})())},"b"),e[0]=u,e[1]=d,e[2]=b):b=e[2];let F;e[3]!==u||e[4]!==d||e[5]!==a?(F=[u,d,a],e[3]=u,e[4]=d,e[5]=a,e[6]=F):F=e[6],(0,w.useEffect)(b,F);let C;e[7]!==u||e[8]!==l||e[9]!==d?(C=r(o=>{l(()=>u.unlinkAuthAccount({accountId:o,userId:d}))},"C"),e[7]=u,e[8]=l,e[9]=d,e[10]=C):C=e[10];let v=C,m;e[11]!==i?(m=i("Linked accounts"),e[11]=i,e[12]=m):m=e[12];let p;e[13]!==m?(p=(0,t.jsx)(Ye,{children:m}),e[13]=m,e[14]=p):p=e[14];let x;e[15]!==f?(x=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:f}),e[15]=f,e[16]=x):x=e[16];let y;e[17]!==s||e[18]!==i?(y=s!==null&&s.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:i("No linked accounts.")}),e[17]=s,e[18]=i,e[19]=y):y=e[19];let k;e[20]!==s||e[21]!==n||e[22]!==v||e[23]!==i?(k=s!==null&&s.length>0&&(0,t.jsx)(ie,{className:"overflow-hidden py-0",children:(0,t.jsx)(ne,{className:"px-0",children:(0,t.jsxs)(Pe,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(_,{children:i("provider")}),(0,t.jsx)(_,{children:i("created")}),(0,t.jsx)(_,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Be,{children:s.map(o=>{let S=ee(o.id);return(0,t.jsxs)(Q,{"data-testid":`ud-account-${S}`,children:[(0,t.jsx)(U,{children:ee(o.providerId)}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(o.createdAt)}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`ud-unlink-${S}`,disabled:n,onClick:r(()=>{v(S)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Unlink")})})]},S)})})]})})}),e[20]=s,e[21]=n,e[22]=v,e[23]=i,e[24]=k):k=e[24];let g;return e[25]!==p||e[26]!==x||e[27]!==y||e[28]!==k?(g=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[p,x,y,k]}),e[25]=p,e[26]=x,e[27]=y,e[28]=k,e[29]=g):g=e[29],g},"ft"),gt=r(h=>{let e=(0,Z.c)(71),{busy:n,capabilities:l,runAction:d,userId:a,version:u}=h,i=le(),s=J(),[c,f]=(0,w.useState)(null),[N,b]=(0,w.useState)(null),[F,C]=(0,w.useState)(null),[v,m]=(0,w.useState)(0),p;e[0]!==l.apiKey||e[1]!==i||e[2]!==a?(p=r(()=>{if(!l.apiKey)return;let R={live:!0};return te((async()=>{try{let D=await i.listAuthApiKeys({userId:a});R.live&&(b({rows:D,userId:a}),C(null))}catch{R.live&&C(a)}})()),()=>{R.live=!1}},"f"),e[0]=l.apiKey,e[1]=i,e[2]=a,e[3]=p):p=e[3];let x;e[4]!==v||e[5]!==l.apiKey||e[6]!==i||e[7]!==a||e[8]!==u?(x=[v,l.apiKey,i,a,u],e[4]=v,e[5]=l.apiKey,e[6]=i,e[7]=a,e[8]=u,e[9]=x):x=e[9],(0,w.useEffect)(p,x);let y=N?.userId===a?N.rows:null,k=F===a,g;e[10]!==l.passkey||e[11]!==i||e[12]!==a?(g=r(()=>{l.passkey&&te((async()=>{try{f(await i.listAuthPasskeys({userId:a}))}catch{f(null)}})())},"g"),e[10]=l.passkey,e[11]=i,e[12]=a,e[13]=g):g=e[13];let o;e[14]!==l.passkey||e[15]!==i||e[16]!==a||e[17]!==u?(o=[l.passkey,i,a,u],e[14]=l.passkey,e[15]=i,e[16]=a,e[17]=u,e[18]=o):o=e[18],(0,w.useEffect)(g,o);let S;e[19]!==i||e[20]!==d||e[21]!==a?(S=r(()=>{d(()=>i.disableAuthTwoFactor({userId:a}))},"S"),e[19]=i,e[20]=d,e[21]=a,e[22]=S):S=e[22];let L=S,E;e[23]!==i||e[24]!==d?(E=r(R=>{d(()=>i.deleteAuthPasskey({passkeyId:R}))},"z"),e[23]=i,e[24]=d,e[25]=E):E=e[25];let H=E,j;e[26]!==i||e[27]!==d?(j=r(R=>{d(()=>i.deleteAuthApiKey({apiKeyId:R}))},"M"),e[26]=i,e[27]=d,e[28]=j):j=e[28];let Y=j,B;e[29]!==s?(B=s("Security"),e[29]=s,e[30]=B):B=e[30];let O;e[31]!==B?(O=(0,t.jsx)(Ye,{children:B}),e[31]=B,e[32]=O):O=e[32];let T;e[33]!==n||e[34]!==l.twoFactor||e[35]!==L||e[36]!==s?(T=l.twoFactor&&(0,t.jsx)(K,{"data-testid":"ud-disable-2fa",disabled:n,onClick:L,size:"sm",type:"button",variant:"outline",children:s("Disable two-factor")}),e[33]=n,e[34]=l.twoFactor,e[35]=L,e[36]=s,e[37]=T):T=e[37];let z;e[38]!==l.passkey||e[39]!==c||e[40]!==s?(z=l.passkey&&c!==null&&c.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s("No passkeys.")}),e[38]=l.passkey,e[39]=c,e[40]=s,e[41]=z):z=e[41];let $;e[42]!==n||e[43]!==l.passkey||e[44]!==H||e[45]!==c||e[46]!==s?($=l.passkey&&c!==null&&c.length>0&&(0,t.jsx)(tt,{columns:[s("name"),s("created")],testId:"ud-passkeys-table",children:c.map(R=>{let D=ee(R.id);return(0,t.jsxs)(Q,{"data-testid":`ud-passkey-${D}`,children:[(0,t.jsx)(U,{children:ee(R.name)||D}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(R.createdAt)}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`ud-delete-passkey-${D}`,disabled:n,onClick:r(()=>{H(D)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Delete")})})]},D)})}),e[42]=n,e[43]=l.passkey,e[44]=H,e[45]=c,e[46]=s,e[47]=$):$=e[47];let I;e[48]!==k||e[49]!==n||e[50]!==l.apiKey||e[51]!==s?(I=l.apiKey&&k&&(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s("Could not load API keys.")}),(0,t.jsx)(K,{"data-testid":"ud-api-keys-retry",disabled:n,onClick:r(()=>{m(bt)},"onClick"),size:"xs",type:"button",variant:"outline",children:s("Retry")})]}),e[48]=k,e[49]=n,e[50]=l.apiKey,e[51]=s,e[52]=I):I=e[52];let P;e[53]!==l.apiKey||e[54]!==y||e[55]!==s?(P=l.apiKey&&y!==null&&y.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s("No API keys.")}),e[53]=l.apiKey,e[54]=y,e[55]=s,e[56]=P):P=e[56];let V;e[57]!==n||e[58]!==l.apiKey||e[59]!==y||e[60]!==Y||e[61]!==s?(V=l.apiKey&&y!==null&&y.length>0&&(0,t.jsx)(tt,{columns:[s("name"),s("Key"),s("created"),s("Expires")],testId:"ud-api-keys-table",children:y.map(R=>{let D=ee(R.id);return(0,t.jsxs)(Q,{"data-testid":`ud-api-key-${D}`,children:[(0,t.jsx)(U,{children:ee(R.name)||D}),(0,t.jsx)(U,{className:"font-mono text-muted-foreground",children:ee(R.start)||"\u2014"}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(R.createdAt)}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(R.expiresAt,s("Never"))}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`ud-revoke-api-key-${D}`,disabled:n,onClick:r(()=>{Y(D)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Revoke")})})]},D)})}),e[57]=n,e[58]=l.apiKey,e[59]=y,e[60]=Y,e[61]=s,e[62]=V):V=e[62];let G;return e[63]!==T||e[64]!==z||e[65]!==$||e[66]!==I||e[67]!==P||e[68]!==V||e[69]!==O?(G=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[O,T,z,$,I,P,V]}),e[63]=T,e[64]=z,e[65]=$,e[66]=I,e[67]=P,e[68]=V,e[69]=O,e[70]=G):G=e[70],G},"pt");function yt(h){return(0,t.jsx)(_,{children:h},h)}r(yt,"vt");function bt(h){return h+1}r(bt,"gt");var xt=/(?:at|expires)$/iu,Nt=/^[1-9]\d*$/u,kt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),wt=r(h=>{let e=(0,Z.c)(51),{busy:n,onBan:l}=h,d=J(),[a,u]=(0,w.useState)(""),[i,s]=(0,w.useState)(""),[c,f]=(0,w.useState)(!1),N;e[0]!==i?(N=Nt.test(i.trim())&&Number.isSafeInteger(Number(i.trim())*86400)?Number(i.trim()):void 0,e[0]=i,e[1]=N):N=e[1];let b=N,F=c||b!==void 0,C;e[2]!==l||e[3]!==c||e[4]!==a||e[5]!==b?(C=r(()=>{l({expiresInSeconds:c||b===void 0?void 0:b*86400,reason:a.trim()===""?void 0:a.trim()})},"C"),e[2]=l,e[3]=c,e[4]=a,e[5]=b,e[6]=C):C=e[6];let v=C,m;e[7]!==d?(m=d("Ban reason (optional)"),e[7]=d,e[8]=m):m=e[8];let p;e[9]!==m?(p=(0,t.jsx)(W,{htmlFor:"ud-ban-reason",children:m}),e[9]=m,e[10]=p):p=e[10];let x;e[11]===Symbol.for("react.memo_cache_sentinel")?(x=r(P=>{u(P.target.value)},"x"),e[11]=x):x=e[11];let y;e[12]!==a?(y=(0,t.jsx)(q,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:x,value:a}),e[12]=a,e[13]=y):y=e[13];let k;e[14]!==p||e[15]!==y?(k=(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[p,y]}),e[14]=p,e[15]=y,e[16]=k):k=e[16];let g;e[17]!==d?(g=d("Days"),e[17]=d,e[18]=g):g=e[18];let o;e[19]!==g?(o=(0,t.jsx)(W,{htmlFor:"ud-ban-days",children:g}),e[19]=g,e[20]=o):o=e[20];let S;e[21]!==i||e[22]!==b?(S=i.trim()!==""&&b===void 0,e[21]=i,e[22]=b,e[23]=S):S=e[23];let L;e[24]===Symbol.for("react.memo_cache_sentinel")?(L=r(P=>{s(P.target.value)},"_"),e[24]=L):L=e[24];let E;e[25]!==i||e[26]!==c||e[27]!==S?(E=(0,t.jsx)(q,{"aria-invalid":S,"data-testid":"ud-ban-days",disabled:c,id:"ud-ban-days",min:1,onChange:L,step:1,type:"number",value:i}),e[25]=i,e[26]=c,e[27]=S,e[28]=E):E=e[28];let H;e[29]!==E||e[30]!==o?(H=(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[o,E]}),e[29]=E,e[30]=o,e[31]=H):H=e[31];let j;e[32]===Symbol.for("react.memo_cache_sentinel")?(j=r(P=>{f(P.target.checked)},"M"),e[32]=j):j=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:j,type:"checkbox"}),e[33]=c,e[34]=Y):Y=e[34];let B;e[35]!==d?(B=d("Permanent"),e[35]=d,e[36]=B):B=e[36];let O;e[37]!==Y||e[38]!==B?(O=(0,t.jsxs)(W,{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]=O):O=e[39];let T=n||!F,z;e[40]!==d?(z=d("Ban user"),e[40]=d,e[41]=z):z=e[41];let $;e[42]!==v||e[43]!==T||e[44]!==z?($=(0,t.jsx)(K,{"data-testid":"ud-ban",disabled:T,onClick:v,size:"sm",type:"button",variant:"destructive",children:z}),e[42]=v,e[43]=T,e[44]=z,e[45]=$):$=e[45];let I;return e[46]!==H||e[47]!==O||e[48]!==$||e[49]!==k?(I=(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[k,H,O,$]}),e[46]=H,e[47]=O,e[48]=$,e[49]=k,e[50]=I):I=e[50],I},"Nt"),Ct=r((h,e)=>typeof e=="number"&&xt.test(h)?ae(e):ee(e),"kt"),It=r(({capabilities:h,onChanged:e,onClose:n,user:l})=>{let d=le(),a=J(),u=l.banned===!0,[i,s]=(0,w.useState)(null),[c,f]=(0,w.useState)(!1),[N,b]=(0,w.useState)(0),[F,C]=(0,w.useState)(typeof l.role=="string"?l.role:""),[v,m]=(0,w.useState)(""),[p,x]=(0,w.useState)(null),[y,k]=(0,w.useState)(!1),g=r((I,P)=>{te((async()=>{f(!0),s(null);try{let V=await I();P?.refresh!==!1&&(b(G=>G+1),e()),P?.onResult?.(V)}catch(V){s(Ee(V))}f(!1)})())},"g"),o=r(I=>{C(I.target.value)},"o"),S=r(I=>{m(I.target.value)},"S"),L=r(()=>{let I=F.trim();I!==""&&g(async()=>{await d.setAuthUserRole({role:I,userId:l.id})})},"_"),E=r(I=>{g(async()=>{await d.banAuthUser({...I,userId:l.id})})},"z"),H=r(()=>{g(async()=>{await d.unbanAuthUser({userId:l.id})})},"q"),j=r(()=>{g(async()=>{await d.setAuthUserPassword({newPassword:v,userId:l.id}),m("")})},"M"),Y=r(()=>{g(()=>d.impersonateAuthUser({userId:l.id}),{onResult:r(I=>{x(I.token)},"onResult"),refresh:!1})},"H"),B=r(()=>{g(async()=>{await d.revokeAuthUserSessions({userId:l.id})})},"D"),O=r(()=>{g(async()=>{await d.removeAuthUser({userId:l.id}),n()})},"B"),T=r(()=>{k(!0)},"O"),z=r(()=>{k(!1)},"U"),$=Object.entries(l).filter(([I])=>!kt.has(I));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)(X,{variant:"secondary",children:l.role}),u?(0,t.jsx)(X,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(X,{variant:"outline",children:a("Active")}),l.emailVerified===!0?(0,t.jsx)(X,{variant:"secondary",children:a("verified")}):(0,t.jsx)(X,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(K,{"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)(ie,{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)(ne,{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)(W,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(q,{"data-testid":"ud-role-input",id:"ud-role",onChange:o,value:F})]}),(0,t.jsx)(K,{"data-testid":"ud-set-role",disabled:c||F.trim()==="",onClick:L,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),u?(0,t.jsx)(K,{"data-testid":"ud-unban",disabled:c,onClick:H,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(0,t.jsx)(wt,{busy:c,onBan:E}),(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)(W,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(q,{"data-testid":"ud-password",id:"ud-password",onChange:S,type:"password",value:v})]}),(0,t.jsx)(K,{"data-testid":"ud-set-password",disabled:c||v==="",onClick:j,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(K,{"data-testid":"ud-impersonate",disabled:c,onClick:Y,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(K,{"data-testid":"ud-revoke-all",disabled:c,onClick:B,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),y?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(K,{"data-testid":"ud-delete-confirm",disabled:c,onClick:O,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(K,{"data-testid":"ud-delete-cancel",onClick:z,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(K,{"data-testid":"ud-delete",disabled:c,onClick:T,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),p!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(W,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(q,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:p})]})]})]}),(0,t.jsx)(ft,{busy:c,runAction:g,userId:l.id,version:N}),h.accounts&&(0,t.jsx)(vt,{busy:c,runAction:g,userId:l.id,version:N}),(h.twoFactor||h.passkey||h.apiKey)&&(0,t.jsx)(gt,{busy:c,capabilities:h,runAction:g,userId:l.id,version:N}),(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:$.map(([I,P])=>(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:I}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:Ct(I,P)})]},I))})]})]})},"Ct"),At=50,Ht=r(({pageSize:h=At}={})=>{let e=le(),n=J(),[l,d]=(0,w.useState)(""),[a,u]=(0,w.useState)(""),[i,s]=(0,w.useState)(0),c=Xe(l),[f,N]=(0,w.useState)(null),[b,F]=(0,w.useState)(!1),{capabilities:C}=st(),v=c.trim(),m=a.trim(),p=je(["lunora-auth-users",v,m,h,i],()=>e.listAuthUsers({filterField:m===""?void 0:"role",filterValue:m===""?void 0:m,limit:h,offset:i,search:v===""?void 0:v}).then(o=>({...o,offset:i})),{keepPreviousData:!0}),x=p.data?.rows??null,y=p.error,k=r(()=>{p.refetch()},"k");We(()=>p.poll(),!0);let g=f===null?null:x?.find(o=>o.id===f)??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)(q,{"aria-label":n("Search users"),className:"w-56","data-testid":"us-search",onChange:r(o=>{d(o.target.value),s(0)},"onChange"),placeholder:n("Search by email or name\u2026"),value:l}),(0,t.jsx)(q,{"aria-label":n("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:r(o=>{u(o.target.value),s(0)},"onChange"),placeholder:n("Filter by role"),value:a}),(0,t.jsx)(K,{"data-testid":"us-new",onClick:r(()=>{F(!0)},"onClick"),size:"sm",type:"button",children:n("New user")})]}),y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:y}),x!==null&&x.length===0&&(0,t.jsx)(Me,{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.")}),x!==null&&x.length>0&&(0,t.jsx)(ie,{className:"overflow-hidden py-0",children:(0,t.jsx)(ne,{className:"px-0",children:(0,t.jsxs)(Pe,{"data-testid":"us-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(_,{children:n("id")}),(0,t.jsx)(_,{children:n("email")}),(0,t.jsx)(_,{children:n("name")}),(0,t.jsx)(_,{children:n("role")}),(0,t.jsx)(_,{children:n("status")}),(0,t.jsx)(_,{children:n("verified")}),(0,t.jsx)(_,{children:n("created")}),(0,t.jsx)(_,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Be,{children:x.map(o=>(0,t.jsxs)(Q,{"data-testid":`us-row-${o.id}`,children:[(0,t.jsx)(U,{className:"font-mono text-xs",children:o.id}),(0,t.jsx)(U,{children:o.email??""}),(0,t.jsx)(U,{children:o.name??""}),(0,t.jsx)(U,{children:typeof o.role=="string"&&o.role!==""?(0,t.jsx)(X,{variant:"secondary",children:o.role}):""}),(0,t.jsx)(U,{children:o.banned===!0?(0,t.jsx)(X,{variant:"destructive",children:n("Banned")}):(0,t.jsx)(X,{variant:"success",children:n("Active")})}),(0,t.jsx)(U,{children:o.emailVerified===!0?(0,t.jsx)(X,{variant:"success",children:n("yes")}):(0,t.jsx)(X,{variant:"outline",children:n("no")})}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(o.createdAt)}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`us-manage-${o.id}`,onClick:r(()=>{N(o.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Manage")})})]},o.id))})]})})}),x!==null&&(0,t.jsx)(Ge,{count:x.length,offset:p.data?.offset??0,onOffsetChange:s,pageSize:h,prefix:"us",total:p.data?.total}),g!==null&&(0,t.jsx)(It,{capabilities:C,onChanged:k,onClose:r(()=>{N(null)},"onClose"),user:g}),b&&(0,t.jsx)(pt,{onClose:r(()=>{F(!1)},"onClose"),onCreated:k}),C.inviteOnly&&(0,t.jsx)(ct,{})]})},"Ht");export{Ht as UsersPanel};
@@ -1 +1 @@
1
- import{a as f}from"./chunk-XV2XEUUB.js";import{a as h}from"./chunk-A6TVTNKO.js";import{b as N}from"./chunk-ADABTCDI.js";import{a as u,d as x}from"./chunk-5PEAXTYQ.js";var b=x(h(),1);var t=x(N(),1);var v=u(g=>{let e=(0,b.c)(16),{chart:c,footer:n,label:i,testId:m,value:p}=g,r;e[0]!==i?(r=(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i}),e[0]=i,e[1]=r):r=e[1];let a;e[2]!==m||e[3]!==p?(a=(0,t.jsx)("span",{className:"truncate text-2xl font-semibold tabular-nums text-foreground","data-testid":m,children:p}),e[2]=m,e[3]=p,e[4]=a):a=e[4];let s;e[5]!==c||e[6]!==a?(s=(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[a,c]}),e[5]=c,e[6]=a,e[7]=s):s=e[7];let l;e[8]!==r||e[9]!==s?(l=(0,t.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[r,s]}),e[8]=r,e[9]=s,e[10]=l):l=e[10];let o;e[11]!==n?(o=n!=null&&(0,t.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:n}),e[11]=n,e[12]=o):o=e[12];let d;return e[13]!==l||e[14]!==o?(d=(0,t.jsxs)(f,{className:"justify-between gap-0 py-0",children:[l,o]}),e[13]=l,e[14]=o,e[15]=d):d=e[15],d},"j");export{v as a};
1
+ import{a as f}from"./chunk-NPHGFVNE.js";import{a as h}from"./chunk-A6TVTNKO.js";import{b as N}from"./chunk-ADABTCDI.js";import{a as u,d as x}from"./chunk-5PEAXTYQ.js";var b=x(h(),1);var t=x(N(),1);var v=u(g=>{let e=(0,b.c)(16),{chart:c,footer:n,label:i,testId:m,value:p}=g,r;e[0]!==i?(r=(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i}),e[0]=i,e[1]=r):r=e[1];let a;e[2]!==m||e[3]!==p?(a=(0,t.jsx)("span",{className:"truncate text-2xl font-semibold tabular-nums text-foreground","data-testid":m,children:p}),e[2]=m,e[3]=p,e[4]=a):a=e[4];let s;e[5]!==c||e[6]!==a?(s=(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[a,c]}),e[5]=c,e[6]=a,e[7]=s):s=e[7];let l;e[8]!==r||e[9]!==s?(l=(0,t.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[r,s]}),e[8]=r,e[9]=s,e[10]=l):l=e[10];let o;e[11]!==n?(o=n!=null&&(0,t.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:n}),e[11]=n,e[12]=o):o=e[12];let d;return e[13]!==l||e[14]!==o?(d=(0,t.jsxs)(f,{className:"justify-between gap-0 py-0",children:[l,o]}),e[13]=l,e[14]=o,e[15]=d):d=e[15],d},"j");export{v as a};
@@ -1 +1 @@
1
- import{a as Et}from"./chunk-5EIGSLIK.js";import{a as me}from"./chunk-O66HDCZT.js";import{a as _t,b as jt}from"./chunk-APCHI5CD.js";import"./chunk-WXZ334CL.js";import{a as Lt}from"./chunk-UL5XVKGR.js";import{a as Ot}from"./chunk-VQQEDEHH.js";import{a as Ft}from"./chunk-MNN3YCKF.js";import{a as he,b as Mt}from"./chunk-ERUKFS3I.js";import{i as X}from"./chunk-2D4WBSDO.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as L}from"./chunk-CBTPJPCZ.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as be}from"./chunk-HMMALUXM.js";import"./chunk-L27FKJTG.js";import{a as Nt,b as At,c as Dt,d as Ve,e as de,f as ce}from"./chunk-ZJIYJZ6F.js";import{b as ge}from"./chunk-LRUYEVHH.js";import{a as kt,e as St}from"./chunk-XV2XEUUB.js";import{n as oe}from"./chunk-QFN62JQJ.js";import"./chunk-ZPQBVYNN.js";import{B as Q,j as Rt,r as D,s as zt,w as $t}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as qt}from"./chunk-A6TVTNKO.js";import{a as Yt,b as Gt}from"./chunk-ADABTCDI.js";import{a as m,d as wt}from"./chunk-5PEAXTYQ.js";var H=wt(qt(),1),E=wt(Yt(),1);var l=wt(Gt(),1);var Kt=m(t=>{let e=JSON.parse(t);if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("Expected a JSON object");return e},"Pt"),Wt=m(t=>{let e=Kt(t),r={};for(let[c,h]of Object.entries(e)){if(!Array.isArray(h)||h.some(i=>typeof i!="string"))throw new TypeError(`"${c}" must map to an array of action strings`);r[c]=h}return r},"qt"),Qt=m(t=>t==null||t===""?"":typeof t=="string"?t:JSON.stringify(t,null,2),"jt"),W=m(t=>{let e=(0,H.c)(6),{children:r,htmlFor:c,label:h}=t,i;e[0]!==c||e[1]!==h?(i=(0,l.jsx)(Ft,{htmlFor:c,children:h}),e[0]=c,e[1]=h,e[2]=i):i=e[2];let o;return e[3]!==r||e[4]!==i?(o=(0,l.jsxs)("div",{className:"flex flex-col gap-1",children:[i,r]}),e[3]=r,e[4]=i,e[5]=o):o=e[5],o},"W"),ue=m(({busy:t,canSubmit:e,children:r,destructive:c=!1,error:h,onClose:i,onSubmit:o,submitLabel:a,testId:n,title:d})=>{let s=Q();return(0,l.jsxs)(Lt,{label:d,onClose:i,panelTestId:`${n}-panel`,testId:`${n}-overlay`,variant:"dialog",children:[(0,l.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:d}),r,h!==null&&(0,l.jsx)("p",{className:"text-sm text-destructive","data-testid":`${n}-error`,role:"alert",children:h}),(0,l.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[(0,l.jsx)(L,{"data-testid":`${n}-cancel`,onClick:i,size:"sm",type:"button",variant:"outline",children:s("Cancel")}),(0,l.jsx)(L,{"data-testid":`${n}-submit`,disabled:t||!e,onClick:o,size:"sm",type:"button",variant:c?"destructive":"default",children:t?s("Saving\u2026"):a})]})]})},"de"),Pt=m(t=>{let e=(0,H.c)(79),{mode:r,onClose:c,onDone:h,org:i}=t,o=oe(),a=Q(),{busy:n,error:d,run:s}=me(),p;e[0]!==i?(p=i?D(i.name):"",e[0]=i,e[1]=p):p=e[1];let[u,b]=(0,E.useState)(p),v;e[2]!==i?(v=i?D(i.slug):"",e[2]=i,e[3]=v):v=e[3];let[g,f]=(0,E.useState)(v),z;e[4]!==i?(z=i?D(i.logo):"",e[4]=i,e[5]=z):z=e[5];let[y,C]=(0,E.useState)(z),[x,w]=(0,E.useState)(""),I;e[6]!==r||e[7]!==i?.metadata?(I=r==="edit"?Qt(i?.metadata):"",e[6]=r,e[7]=i?.metadata,e[8]=I):I=e[8];let[k,S]=(0,E.useState)(I),_;e[9]!==o||e[10]!==y||e[11]!==k||e[12]!==r||e[13]!==u||e[14]!==c||e[15]!==h||e[16]!==i?.id||e[17]!==x||e[18]!==s||e[19]!==g?(_=m(()=>{s(async()=>{let N=k.trim()===""?void 0:Kt(k);r==="create"?await o.createAuthOrganization({logo:y.trim()===""?void 0:y.trim(),metadata:N,name:u.trim(),ownerId:x.trim()===""?void 0:x.trim(),slug:g.trim()===""?void 0:g.trim()}):await o.updateAuthOrganization({logo:y.trim()===""?void 0:y.trim(),metadata:N,name:u.trim()===""?void 0:u.trim(),organizationId:D(i?.id),slug:g.trim()===""?void 0:g.trim()}),h(),c()})},"O"),e[9]=o,e[10]=y,e[11]=k,e[12]=r,e[13]=u,e[14]=c,e[15]=h,e[16]=i?.id,e[17]=x,e[18]=s,e[19]=g,e[20]=_):_=e[20];let A=_,O;e[21]!==r||e[22]!==u?(O=u.trim()!==""||r==="edit",e[21]=r,e[22]=u,e[23]=O):O=e[23];let T;e[24]!==r||e[25]!==a?(T=a(r==="create"?"Create":"Save"),e[24]=r,e[25]=a,e[26]=T):T=e[26];let R;e[27]!==r||e[28]!==a?(R=a(r==="create"?"New organization":"Edit organization"),e[27]=r,e[28]=a,e[29]=R):R=e[29];let F;e[30]!==a?(F=a("name"),e[30]=a,e[31]=F):F=e[31];let Z;e[32]===Symbol.for("react.memo_cache_sentinel")?(Z=m(N=>{b(N.target.value)},"H"),e[32]=Z):Z=e[32];let B;e[33]!==u?(B=(0,l.jsx)(X,{"data-testid":"org-form-name",id:"org-form-name",onChange:Z,value:u}),e[33]=u,e[34]=B):B=e[34];let K;e[35]!==B||e[36]!==F?(K=(0,l.jsx)(W,{htmlFor:"org-form-name",label:F,children:B}),e[35]=B,e[36]=F,e[37]=K):K=e[37];let J;e[38]!==a?(J=a("Slug (optional \u2014 derived from name)"),e[38]=a,e[39]=J):J=e[39];let j;e[40]===Symbol.for("react.memo_cache_sentinel")?(j=m(N=>{f(N.target.value)},"F"),e[40]=j):j=e[40];let U;e[41]!==g?(U=(0,l.jsx)(X,{"data-testid":"org-form-slug",id:"org-form-slug",onChange:j,value:g}),e[41]=g,e[42]=U):U=e[42];let P;e[43]!==J||e[44]!==U?(P=(0,l.jsx)(W,{htmlFor:"org-form-slug",label:J,children:U}),e[43]=J,e[44]=U,e[45]=P):P=e[45];let Y;e[46]!==a?(Y=a("Logo URL (optional)"),e[46]=a,e[47]=Y):Y=e[47];let M;e[48]===Symbol.for("react.memo_cache_sentinel")?(M=m(N=>{C(N.target.value)},"M"),e[48]=M):M=e[48];let $;e[49]!==y?($=(0,l.jsx)(X,{"data-testid":"org-form-logo",id:"org-form-logo",onChange:M,value:y}),e[49]=y,e[50]=$):$=e[50];let q;e[51]!==Y||e[52]!==$?(q=(0,l.jsx)(W,{htmlFor:"org-form-logo",label:Y,children:$}),e[51]=Y,e[52]=$,e[53]=q):q=e[53];let V;e[54]!==r||e[55]!==x||e[56]!==a?(V=r==="create"&&(0,l.jsx)(W,{htmlFor:"org-form-owner",label:a("Owner user id (optional)"),children:(0,l.jsx)(X,{"data-testid":"org-form-owner",id:"org-form-owner",onChange:m(N=>{w(N.target.value)},"onChange"),value:x})}),e[54]=r,e[55]=x,e[56]=a,e[57]=V):V=e[57];let te;e[58]!==a?(te=a("Metadata (JSON, optional)"),e[58]=a,e[59]=te):te=e[59];let le;e[60]===Symbol.for("react.memo_cache_sentinel")?(le=m(N=>{S(N.target.value)},"oe"),e[60]=le):le=e[60];let re;e[61]!==k?(re=(0,l.jsx)(Ot,{"data-testid":"org-form-metadata",id:"org-form-metadata",onChange:le,value:k}),e[61]=k,e[62]=re):re=e[62];let ee;e[63]!==te||e[64]!==re?(ee=(0,l.jsx)(W,{htmlFor:"org-form-metadata",label:te,children:re}),e[63]=te,e[64]=re,e[65]=ee):ee=e[65];let ae;return e[66]!==n||e[67]!==d||e[68]!==c||e[69]!==A||e[70]!==K||e[71]!==P||e[72]!==q||e[73]!==V||e[74]!==ee||e[75]!==O||e[76]!==T||e[77]!==R?(ae=(0,l.jsxs)(ue,{busy:n,canSubmit:O,error:d,onClose:c,onSubmit:A,submitLabel:T,testId:"org-form",title:R,children:[K,P,q,V,ee]}),e[66]=n,e[67]=d,e[68]=c,e[69]=A,e[70]=K,e[71]=P,e[72]=q,e[73]=V,e[74]=ee,e[75]=O,e[76]=T,e[77]=R,e[78]=ae):ae=e[78],ae},"Dt"),Xt=m(t=>{let e=(0,H.c)(40),{onClose:r,onDone:c,organizationId:h}=t,i=oe(),o=Q(),{busy:a,error:n,run:d}=me(),[s,p]=(0,E.useState)(""),[u,b]=(0,E.useState)(""),v;e[0]!==i||e[1]!==r||e[2]!==c||e[3]!==h||e[4]!==u||e[5]!==d||e[6]!==s?(v=m(()=>{d(async()=>{await i.addAuthOrgMember({organizationId:h,role:u.trim()===""?void 0:u.trim(),userId:s.trim()}),c(),r()})},"p"),e[0]=i,e[1]=r,e[2]=c,e[3]=h,e[4]=u,e[5]=d,e[6]=s,e[7]=v):v=e[7];let g=v,f;e[8]!==s?(f=s.trim(),e[8]=s,e[9]=f):f=e[9];let z=f!=="",y;e[10]!==o?(y=o("Add member"),e[10]=o,e[11]=y):y=e[11];let C;e[12]!==o?(C=o("Add member"),e[12]=o,e[13]=C):C=e[13];let x;e[14]!==o?(x=o("User id"),e[14]=o,e[15]=x):x=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=m(R=>{p(R.target.value)},"I"),e[16]=w):w=e[16];let I;e[17]!==s?(I=(0,l.jsx)(X,{"data-testid":"org-add-member-user",id:"org-add-member-user",onChange:w,value:s}),e[17]=s,e[18]=I):I=e[18];let k;e[19]!==x||e[20]!==I?(k=(0,l.jsx)(W,{htmlFor:"org-add-member-user",label:x,children:I}),e[19]=x,e[20]=I,e[21]=k):k=e[21];let S;e[22]!==o?(S=o("Role (optional)"),e[22]=o,e[23]=S):S=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=m(R=>{b(R.target.value)},"O"),e[24]=_):_=e[24];let A;e[25]!==u?(A=(0,l.jsx)(X,{"data-testid":"org-add-member-role",id:"org-add-member-role",onChange:_,value:u}),e[25]=u,e[26]=A):A=e[26];let O;e[27]!==S||e[28]!==A?(O=(0,l.jsx)(W,{htmlFor:"org-add-member-role",label:S,children:A}),e[27]=S,e[28]=A,e[29]=O):O=e[29];let T;return e[30]!==a||e[31]!==n||e[32]!==r||e[33]!==g||e[34]!==O||e[35]!==z||e[36]!==y||e[37]!==C||e[38]!==k?(T=(0,l.jsxs)(ue,{busy:a,canSubmit:z,error:n,onClose:r,onSubmit:g,submitLabel:y,testId:"org-add-member",title:C,children:[k,O]}),e[30]=a,e[31]=n,e[32]=r,e[33]=g,e[34]=O,e[35]=z,e[36]=y,e[37]=C,e[38]=k,e[39]=T):T=e[39],T},"Kt"),Vt=m(t=>{let e=(0,H.c)(40),{onClose:r,onDone:c,organizationId:h}=t,i=oe(),o=Q(),{busy:a,error:n,run:d}=me(),[s,p]=(0,E.useState)(""),[u,b]=(0,E.useState)(""),v;e[0]!==i||e[1]!==s||e[2]!==r||e[3]!==c||e[4]!==h||e[5]!==u||e[6]!==d?(v=m(()=>{d(async()=>{await i.inviteAuthOrgMember({email:s.trim(),organizationId:h,role:u.trim()===""?void 0:u.trim()}),c(),r()})},"p"),e[0]=i,e[1]=s,e[2]=r,e[3]=c,e[4]=h,e[5]=u,e[6]=d,e[7]=v):v=e[7];let g=v,f;e[8]!==s?(f=s.trim(),e[8]=s,e[9]=f):f=e[9];let z=f!=="",y;e[10]!==o?(y=o("Send invitation"),e[10]=o,e[11]=y):y=e[11];let C;e[12]!==o?(C=o("Invite member"),e[12]=o,e[13]=C):C=e[13];let x;e[14]!==o?(x=o("email"),e[14]=o,e[15]=x):x=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=m(R=>{p(R.target.value)},"I"),e[16]=w):w=e[16];let I;e[17]!==s?(I=(0,l.jsx)(X,{"data-testid":"org-invite-member-email",id:"org-invite-member-email",onChange:w,type:"email",value:s}),e[17]=s,e[18]=I):I=e[18];let k;e[19]!==x||e[20]!==I?(k=(0,l.jsx)(W,{htmlFor:"org-invite-member-email",label:x,children:I}),e[19]=x,e[20]=I,e[21]=k):k=e[21];let S;e[22]!==o?(S=o("Role (optional)"),e[22]=o,e[23]=S):S=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=m(R=>{b(R.target.value)},"O"),e[24]=_):_=e[24];let A;e[25]!==u?(A=(0,l.jsx)(X,{"data-testid":"org-invite-member-role",id:"org-invite-member-role",onChange:_,value:u}),e[25]=u,e[26]=A):A=e[26];let O;e[27]!==S||e[28]!==A?(O=(0,l.jsx)(W,{htmlFor:"org-invite-member-role",label:S,children:A}),e[27]=S,e[28]=A,e[29]=O):O=e[29];let T;return e[30]!==a||e[31]!==n||e[32]!==r||e[33]!==g||e[34]!==O||e[35]!==z||e[36]!==y||e[37]!==C||e[38]!==k?(T=(0,l.jsxs)(ue,{busy:a,canSubmit:z,error:n,onClose:r,onSubmit:g,submitLabel:y,testId:"org-invite-member",title:C,children:[k,O]}),e[30]=a,e[31]=n,e[32]=r,e[33]=g,e[34]=O,e[35]=z,e[36]=y,e[37]=C,e[38]=k,e[39]=T):T=e[39],T},"Vt"),er=m(t=>{let e=(0,H.c)(32),{member:r,onClose:c,onDone:h}=t,i=oe(),o=Q(),{busy:a,error:n,run:d}=me(),s;e[0]!==r.role?(s=m(()=>D(r.role),"a"),e[0]=r.role,e[1]=s):s=e[1];let[p,u]=(0,E.useState)(s),b;e[2]!==i||e[3]!==r.id||e[4]!==c||e[5]!==h||e[6]!==p||e[7]!==d?(b=m(()=>{d(async()=>{await i.setAuthOrgMemberRole({memberId:D(r.id),role:p.trim()}),h(),c()})},"g"),e[2]=i,e[3]=r.id,e[4]=c,e[5]=h,e[6]=p,e[7]=d,e[8]=b):b=e[8];let v=b,g;e[9]!==p?(g=p.trim(),e[9]=p,e[10]=g):g=e[10];let f=g!=="",z;e[11]!==o?(z=o("Save"),e[11]=o,e[12]=z):z=e[12];let y;e[13]!==o?(y=o("Change member role"),e[13]=o,e[14]=y):y=e[14];let C;e[15]!==o?(C=o("Role"),e[15]=o,e[16]=C):C=e[16];let x;e[17]===Symbol.for("react.memo_cache_sentinel")?(x=m(S=>{u(S.target.value)},"x"),e[17]=x):x=e[17];let w;e[18]!==p?(w=(0,l.jsx)(X,{"data-testid":"org-member-role-value",id:"org-member-role-value",onChange:x,value:p}),e[18]=p,e[19]=w):w=e[19];let I;e[20]!==C||e[21]!==w?(I=(0,l.jsx)(W,{htmlFor:"org-member-role-value",label:C,children:w}),e[20]=C,e[21]=w,e[22]=I):I=e[22];let k;return e[23]!==a||e[24]!==n||e[25]!==c||e[26]!==v||e[27]!==I||e[28]!==f||e[29]!==z||e[30]!==y?(k=(0,l.jsx)(ue,{busy:a,canSubmit:f,error:n,onClose:c,onSubmit:v,submitLabel:z,testId:"org-member-role",title:y,children:I}),e[23]=a,e[24]=n,e[25]=c,e[26]=v,e[27]=I,e[28]=f,e[29]=z,e[30]=y,e[31]=k):k=e[31],k},"Wt"),Bt=m(t=>{let e=(0,H.c)(36),{mode:r,onClose:c,onDone:h,organizationId:i,team:o}=t,a=oe(),n=Q(),{busy:d,error:s,run:p}=me(),u;e[0]!==o?(u=o?D(o.name):"",e[0]=o,e[1]=u):u=e[1];let[b,v]=(0,E.useState)(u),g;e[2]!==a||e[3]!==r||e[4]!==b||e[5]!==c||e[6]!==h||e[7]!==i||e[8]!==p||e[9]!==o?.id?(g=m(()=>{p(async()=>{await(r==="create"?a.createAuthOrgTeam({name:b.trim(),organizationId:i}):a.updateAuthOrgTeam({name:b.trim(),teamId:D(o?.id)})),h(),c()})},"f"),e[2]=a,e[3]=r,e[4]=b,e[5]=c,e[6]=h,e[7]=i,e[8]=p,e[9]=o?.id,e[10]=g):g=e[10];let f=g,z;e[11]!==b?(z=b.trim(),e[11]=b,e[12]=z):z=e[12];let y=z!=="",C;e[13]!==r||e[14]!==n?(C=n(r==="create"?"Create":"Save"),e[13]=r,e[14]=n,e[15]=C):C=e[15];let x;e[16]!==r||e[17]!==n?(x=n(r==="create"?"New team":"Rename team"),e[16]=r,e[17]=n,e[18]=x):x=e[18];let w;e[19]!==n?(w=n("name"),e[19]=n,e[20]=w):w=e[20];let I;e[21]===Symbol.for("react.memo_cache_sentinel")?(I=m(A=>{v(A.target.value)},"C"),e[21]=I):I=e[21];let k;e[22]!==b?(k=(0,l.jsx)(X,{"data-testid":"org-team-form-name",id:"org-team-form-name",onChange:I,value:b}),e[22]=b,e[23]=k):k=e[23];let S;e[24]!==w||e[25]!==k?(S=(0,l.jsx)(W,{htmlFor:"org-team-form-name",label:w,children:k}),e[24]=w,e[25]=k,e[26]=S):S=e[26];let _;return e[27]!==d||e[28]!==s||e[29]!==c||e[30]!==f||e[31]!==S||e[32]!==y||e[33]!==C||e[34]!==x?(_=(0,l.jsx)(ue,{busy:d,canSubmit:y,error:s,onClose:c,onSubmit:f,submitLabel:C,testId:"org-team-form",title:x,children:S}),e[27]=d,e[28]=s,e[29]=c,e[30]=f,e[31]=S,e[32]=y,e[33]=C,e[34]=x,e[35]=_):_=e[35],_},"zt"),tr=m(t=>{let e=(0,H.c)(30),{onClose:r,onDone:c,teamId:h}=t,i=oe(),o=Q(),{busy:a,error:n,run:d}=me(),[s,p]=(0,E.useState)(""),u;e[0]!==i||e[1]!==r||e[2]!==c||e[3]!==d||e[4]!==h||e[5]!==s?(u=m(()=>{d(async()=>{await i.addAuthOrgTeamMember({teamId:h,userId:s.trim()}),c(),r()})},"c"),e[0]=i,e[1]=r,e[2]=c,e[3]=d,e[4]=h,e[5]=s,e[6]=u):u=e[6];let b=u,v;e[7]!==s?(v=s.trim(),e[7]=s,e[8]=v):v=e[8];let g=v!=="",f;e[9]!==o?(f=o("Add member"),e[9]=o,e[10]=f):f=e[10];let z;e[11]!==o?(z=o("Add team member"),e[11]=o,e[12]=z):z=e[12];let y;e[13]!==o?(y=o("User id"),e[13]=o,e[14]=y):y=e[14];let C;e[15]===Symbol.for("react.memo_cache_sentinel")?(C=m(k=>{p(k.target.value)},"y"),e[15]=C):C=e[15];let x;e[16]!==s?(x=(0,l.jsx)(X,{"data-testid":"org-team-add-member-user",id:"org-team-add-member-user",onChange:C,value:s}),e[16]=s,e[17]=x):x=e[17];let w;e[18]!==y||e[19]!==x?(w=(0,l.jsx)(W,{htmlFor:"org-team-add-member-user",label:y,children:x}),e[18]=y,e[19]=x,e[20]=w):w=e[20];let I;return e[21]!==a||e[22]!==n||e[23]!==r||e[24]!==b||e[25]!==g||e[26]!==f||e[27]!==z||e[28]!==w?(I=(0,l.jsx)(ue,{busy:a,canSubmit:g,error:n,onClose:r,onSubmit:b,submitLabel:f,testId:"org-team-add-member",title:z,children:w}),e[21]=a,e[22]=n,e[23]=r,e[24]=b,e[25]=g,e[26]=f,e[27]=z,e[28]=w,e[29]=I):I=e[29],I},"Xt"),Jt=m(t=>{let e=(0,H.c)(47),{mode:r,onClose:c,onDone:h,organizationId:i,role:o}=t,a=oe(),n=Q(),{busy:d,error:s,run:p}=me(),u;e[0]!==o?(u=o?D(o.role):"",e[0]=o,e[1]=u):u=e[1];let[b,v]=(0,E.useState)(u),g;e[2]!==r||e[3]!==o?.permission?(g=r==="edit"?Qt(o?.permission):"",e[2]=r,e[3]=o?.permission,e[4]=g):g=e[4];let[f,z]=(0,E.useState)(g),y;e[5]!==a||e[6]!==r||e[7]!==b||e[8]!==c||e[9]!==h||e[10]!==i||e[11]!==f||e[12]!==o?.id||e[13]!==p?(y=m(()=>{p(async()=>{let R=Wt(f);await(r==="create"?a.createAuthOrgRole({organizationId:i,permission:R,role:b.trim()}):a.updateAuthOrgRole({permission:R,roleId:D(o?.id)})),h(),c()})},"v"),e[5]=a,e[6]=r,e[7]=b,e[8]=c,e[9]=h,e[10]=i,e[11]=f,e[12]=o?.id,e[13]=p,e[14]=y):y=e[14];let C=y,x;e[15]!==r||e[16]!==b||e[17]!==f?(x=f.trim()!==""&&(r==="edit"||b.trim()!==""),e[15]=r,e[16]=b,e[17]=f,e[18]=x):x=e[18];let w;e[19]!==r||e[20]!==n?(w=n(r==="create"?"Create":"Save"),e[19]=r,e[20]=n,e[21]=w):w=e[21];let I;e[22]!==r||e[23]!==n?(I=n(r==="create"?"New role":"Edit role"),e[22]=r,e[23]=n,e[24]=I):I=e[24];let k;e[25]!==r||e[26]!==b||e[27]!==n?(k=r==="create"&&(0,l.jsx)(W,{htmlFor:"org-role-form-name",label:n("Role name"),children:(0,l.jsx)(X,{"data-testid":"org-role-form-name",id:"org-role-form-name",onChange:m(R=>{v(R.target.value)},"onChange"),value:b})}),e[25]=r,e[26]=b,e[27]=n,e[28]=k):k=e[28];let S;e[29]!==n?(S=n('Permission (JSON, e.g. {"project":["create","update"]})'),e[29]=n,e[30]=S):S=e[30];let _;e[31]===Symbol.for("react.memo_cache_sentinel")?(_=m(R=>{z(R.target.value)},"O"),e[31]=_):_=e[31];let A;e[32]!==f?(A=(0,l.jsx)(Ot,{"data-testid":"org-role-form-permission",id:"org-role-form-permission",onChange:_,value:f}),e[32]=f,e[33]=A):A=e[33];let O;e[34]!==A||e[35]!==S?(O=(0,l.jsx)(W,{htmlFor:"org-role-form-permission",label:S,children:A}),e[34]=A,e[35]=S,e[36]=O):O=e[36];let T;return e[37]!==d||e[38]!==s||e[39]!==c||e[40]!==C||e[41]!==O||e[42]!==x||e[43]!==w||e[44]!==I||e[45]!==k?(T=(0,l.jsxs)(ue,{busy:d,canSubmit:x,error:s,onClose:c,onSubmit:C,submitLabel:w,testId:"org-role-form",title:I,children:[k,O]}),e[37]=d,e[38]=s,e[39]=c,e[40]=C,e[41]=O,e[42]=x,e[43]=w,e[44]=I,e[45]=k,e[46]=T):T=e[46],T},"At"),Zt=m(t=>{let e=(0,H.c)(18),{action:r,message:c,onClose:h,onDone:i,testId:o,title:a}=t,n=Q(),{busy:d,error:s,run:p}=me(),u;e[0]!==r||e[1]!==h||e[2]!==i||e[3]!==p?(u=m(()=>{p(async()=>{await r(),i(),h()})},"c"),e[0]=r,e[1]=h,e[2]=i,e[3]=p,e[4]=u):u=e[4];let b=u,v;e[5]!==n?(v=n("Delete"),e[5]=n,e[6]=v):v=e[6];let g;e[7]!==c?(g=(0,l.jsx)("p",{className:"text-sm text-muted-foreground",children:c}),e[7]=c,e[8]=g):g=e[8];let f;return e[9]!==d||e[10]!==s||e[11]!==h||e[12]!==b||e[13]!==v||e[14]!==g||e[15]!==o||e[16]!==a?(f=(0,l.jsx)(ue,{busy:d,canSubmit:!0,destructive:!0,error:s,onClose:h,onSubmit:b,submitLabel:v,testId:o,title:a,children:g}),e[9]=d,e[10]=s,e[11]=h,e[12]=b,e[13]=v,e[14]=g,e[15]=o,e[16]=a,e[17]=f):f=e[17],f},"Lt"),et=m(t=>{let e=(0,H.c)(13),{action:r,children:c,heading:h,testId:i}=t,o;e[0]!==h?(o=(0,l.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h}),e[0]=h,e[1]=o):o=e[1];let a;e[2]!==r?(a=r!==void 0&&(0,l.jsx)("div",{className:"flex items-center gap-2",children:r}),e[2]=r,e[3]=a):a=e[3];let n;e[4]!==o||e[5]!==a?(n=(0,l.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[o,a]}),e[4]=o,e[5]=a,e[6]=n):n=e[6];let d;e[7]!==c?(d=(0,l.jsx)(St,{className:"px-0",children:c}),e[7]=c,e[8]=d):d=e[8];let s;return e[9]!==n||e[10]!==d||e[11]!==i?(s=(0,l.jsxs)(kt,{className:"overflow-hidden py-0","data-testid":i,children:[n,d]}),e[9]=n,e[10]=d,e[11]=i,e[12]=s):s=e[12],s},"Ye"),tt=m(t=>{let e=(0,H.c)(23),{columns:r,rowActions:c,rowPrefix:h,rows:i}=t,o=Q(),a;e[0]!==r?(a=r.map(rr),e[0]=r,e[1]=a):a=e[1];let n;e[2]!==o?(n=o("Actions"),e[2]=o,e[3]=n):n=e[3];let d;e[4]!==n?(d=(0,l.jsx)(de,{"aria-label":n}),e[4]=n,e[5]=d):d=e[5];let s;e[6]!==a||e[7]!==d?(s=(0,l.jsx)(At,{children:(0,l.jsxs)(Ve,{children:[a,d]})}),e[6]=a,e[7]=d,e[8]=s):s=e[8];let p;if(e[9]!==r||e[10]!==c||e[11]!==h||e[12]!==i){let v;e[14]!==r||e[15]!==c||e[16]!==h?(v=m((g,f)=>{let z=D(g.id),y=z===""?`index-${f.toString()}`:z;return(0,l.jsxs)(Ve,{"data-testid":`${h}-${y}`,children:[r.map(C=>(0,l.jsx)(ce,{className:C.className,children:C.render(g)},C.head)),(0,l.jsx)(ce,{children:(0,l.jsx)("div",{className:"flex justify-end gap-1",children:c(g)})})]},y)},"p"),e[14]=r,e[15]=c,e[16]=h,e[17]=v):v=e[17],p=i.map(v),e[9]=r,e[10]=c,e[11]=h,e[12]=i,e[13]=p}else p=e[13];let u;e[18]!==p?(u=(0,l.jsx)(Dt,{children:p}),e[18]=p,e[19]=u):u=e[19];let b;return e[20]!==s||e[21]!==u?(b=(0,l.jsxs)(Nt,{children:[s,u]}),e[20]=s,e[21]=u,e[22]=b):b=e[22],b},"et");function rr(t){return(0,l.jsx)(de,{children:t.head},t.head)}m(rr,"Yt");var or=m(t=>{let e=(0,H.c)(30),{actionBusy:r,onRemoveMember:c,memberColumns:h,members:i,onDialog:o}=t,a=Q(),n;e[0]!==o?(n=m(()=>{o({kind:"add-member"})},"r"),e[0]=o,e[1]=n):n=e[1];let d;e[2]!==a?(d=a("Add member"),e[2]=a,e[3]=d):d=e[3];let s;e[4]!==n||e[5]!==d?(s=(0,l.jsx)(L,{"data-testid":"org-open-add-member",onClick:n,size:"xs",type:"button",variant:"outline",children:d}),e[4]=n,e[5]=d,e[6]=s):s=e[6];let p;e[7]!==o?(p=m(()=>{o({kind:"invite-member"})},"h"),e[7]=o,e[8]=p):p=e[8];let u;e[9]!==a?(u=a("Invite member"),e[9]=a,e[10]=u):u=e[10];let b;e[11]!==p||e[12]!==u?(b=(0,l.jsx)(L,{"data-testid":"org-open-invite-member",onClick:p,size:"xs",type:"button",variant:"outline",children:u}),e[11]=p,e[12]=u,e[13]=b):b=e[13];let v;e[14]!==s||e[15]!==b?(v=(0,l.jsxs)(l.Fragment,{children:[s,b]}),e[14]=s,e[15]=b,e[16]=v):v=e[16];let g;e[17]!==a?(g=a("Members"),e[17]=a,e[18]=g):g=e[18];let f;e[19]!==r||e[20]!==h||e[21]!==i||e[22]!==o||e[23]!==c||e[24]!==a?(f=i.length===0?(0,l.jsx)("div",{className:"p-3",children:(0,l.jsx)(be,{testId:"org-members-empty",title:a("No members.")})}):(0,l.jsx)(tt,{columns:h,rowActions:m(y=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L,{"data-testid":`org-member-role-${D(y.id)}`,onClick:m(()=>{o({kind:"member-role",member:y})},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Change role")}),(0,l.jsx)(L,{"data-testid":`org-remove-member-${D(y.id)}`,disabled:r,onClick:m(()=>{c(D(y.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Remove")})]}),"rowActions"),rowPrefix:"org-member",rows:i}),e[19]=r,e[20]=h,e[21]=i,e[22]=o,e[23]=c,e[24]=a,e[25]=f):f=e[25];let z;return e[26]!==v||e[27]!==g||e[28]!==f?(z=(0,l.jsx)(et,{action:v,heading:g,testId:"org-members",children:f}),e[26]=v,e[27]=g,e[28]=f,e[29]=z):z=e[29],z},"el"),lr=m(t=>{let e=(0,H.c)(21),{onConfirmDeleteTeam:r,onDialog:c,onSelectTeam:h,selectedTeam:i,teamColumns:o,teams:a}=t,n=Q(),d;e[0]!==c?(d=m(()=>{c({kind:"team-create"})},"m"),e[0]=c,e[1]=d):d=e[1];let s;e[2]!==n?(s=n("New team"),e[2]=n,e[3]=s):s=e[3];let p;e[4]!==d||e[5]!==s?(p=(0,l.jsx)(L,{"data-testid":"org-open-create-team",onClick:d,size:"xs",type:"button",variant:"outline",children:s}),e[4]=d,e[5]=s,e[6]=p):p=e[6];let u;e[7]!==n?(u=n("Teams"),e[7]=n,e[8]=u):u=e[8];let b;e[9]!==r||e[10]!==c||e[11]!==h||e[12]!==i||e[13]!==n||e[14]!==o||e[15]!==a?(b=a.length===0?(0,l.jsx)("div",{className:"p-3",children:(0,l.jsx)(be,{testId:"org-teams-empty",title:n("No teams.")})}):(0,l.jsx)(tt,{columns:o,rowActions:m(g=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L,{"aria-pressed":i===D(g.id),"data-testid":`org-team-select-${D(g.id)}`,onClick:m(()=>{h(D(g.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Members")}),(0,l.jsx)(L,{"data-testid":`org-team-rename-${D(g.id)}`,onClick:m(()=>{c({kind:"team-rename",team:g})},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Rename")}),(0,l.jsx)(L,{"data-testid":`org-team-delete-${D(g.id)}`,onClick:m(()=>{r(g)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Delete")})]}),"rowActions"),rowPrefix:"org-team",rows:a}),e[9]=r,e[10]=c,e[11]=h,e[12]=i,e[13]=n,e[14]=o,e[15]=a,e[16]=b):b=e[16];let v;return e[17]!==p||e[18]!==u||e[19]!==b?(v=(0,l.jsx)(et,{action:p,heading:u,testId:"org-teams",children:b}),e[17]=p,e[18]=u,e[19]=b,e[20]=v):v=e[20],v},"tl"),ar=m(t=>{let e=(0,H.c)(20),{actionBusy:r,onRemoveTeamMember:c,onDialog:h,selectedTeam:i,teamMemberColumns:o,teamMembers:a}=t,n=Q(),d;e[0]!==h||e[1]!==i?(d=m(()=>{h({kind:"team-add-member",teamId:i})},"m"),e[0]=h,e[1]=i,e[2]=d):d=e[2];let s;e[3]!==n?(s=n("Add member"),e[3]=n,e[4]=s):s=e[4];let p;e[5]!==d||e[6]!==s?(p=(0,l.jsx)(L,{"data-testid":"org-open-add-team-member",onClick:d,size:"xs",type:"button",variant:"outline",children:s}),e[5]=d,e[6]=s,e[7]=p):p=e[7];let u;e[8]!==n?(u=n("Team members"),e[8]=n,e[9]=u):u=e[9];let b;e[10]!==r||e[11]!==c||e[12]!==n||e[13]!==o||e[14]!==a?(b=a.length===0?(0,l.jsx)("div",{className:"p-3",children:(0,l.jsx)(be,{testId:"org-team-members-empty",title:n("No team members.")})}):(0,l.jsx)(tt,{columns:o,rowActions:m(g=>(0,l.jsx)(L,{"data-testid":`org-team-remove-member-${D(g.id)}`,disabled:r,onClick:m(()=>{c(D(g.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Remove")}),"rowActions"),rowPrefix:"org-team-member",rows:a}),e[10]=r,e[11]=c,e[12]=n,e[13]=o,e[14]=a,e[15]=b):b=e[15];let v;return e[16]!==p||e[17]!==u||e[18]!==b?(v=(0,l.jsx)(et,{action:p,heading:u,testId:"org-team-members",children:b}),e[16]=p,e[17]=u,e[18]=b,e[19]=v):v=e[19],v},"ll"),nr=m(t=>{let e=(0,H.c)(19),{onConfirmDeleteRole:r,onDialog:c,roleColumns:h,roles:i}=t,o=Q(),a;e[0]!==c?(a=m(()=>{c({kind:"role-create"})},"i"),e[0]=c,e[1]=a):a=e[1];let n;e[2]!==o?(n=o("New role"),e[2]=o,e[3]=n):n=e[3];let d;e[4]!==a||e[5]!==n?(d=(0,l.jsx)(L,{"data-testid":"org-open-create-role",onClick:a,size:"xs",type:"button",variant:"outline",children:n}),e[4]=a,e[5]=n,e[6]=d):d=e[6];let s;e[7]!==o?(s=o("Roles"),e[7]=o,e[8]=s):s=e[8];let p;e[9]!==r||e[10]!==c||e[11]!==h||e[12]!==i||e[13]!==o?(p=i.length===0?(0,l.jsx)("div",{className:"p-3",children:(0,l.jsx)(be,{testId:"org-roles-empty",title:o("No custom roles.")})}):(0,l.jsx)(tt,{columns:h,rowActions:m(b=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L,{"data-testid":`org-role-edit-${D(b.id)}`,onClick:m(()=>{c({kind:"role-edit",role:b})},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Edit")}),(0,l.jsx)(L,{"data-testid":`org-role-delete-${D(b.id)}`,onClick:m(()=>{r(D(b.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Delete")})]}),"rowActions"),rowPrefix:"org-role",rows:i}),e[9]=r,e[10]=c,e[11]=h,e[12]=i,e[13]=o,e[14]=p):p=e[14];let u;return e[15]!==d||e[16]!==s||e[17]!==p?(u=(0,l.jsx)(et,{action:d,heading:s,testId:"org-roles",children:p}),e[15]=d,e[16]=s,e[17]=p,e[18]=u):u=e[18],u},"ol"),Ut=200,ir=m(t=>{let e=(0,H.c)(217),{organizationId:r,rolesEnabled:c,teamsEnabled:h}=t,i=oe(),o=Q(),[a,n]=(0,E.useState)(null),[d,s]=(0,E.useState)(null),[p,u]=(0,E.useState)(!1),[b,v]=(0,E.useState)(null),[g,f]=jt(r),z;e[0]!==g||e[1]!==r?(z=["lunora-auth-org-members",r,g],e[0]=g,e[1]=r,e[2]=z):z=e[2];let y;e[3]!==i||e[4]!==g||e[5]!==r?(y=m(()=>i.listAuthOrgMembers({limit:Ut,offset:g,organizationId:r}),"v"),e[3]=i,e[4]=g,e[5]=r,e[6]=y):y=e[6];let C=ge(z,y),x;e[7]!==r?(x=["lunora-auth-org-invitations",r],e[7]=r,e[8]=x):x=e[8];let w;e[9]!==i||e[10]!==r?(w=m(()=>i.listAuthOrgInvitations({limit:200,organizationId:r}),"I"),e[9]=i,e[10]=r,e[11]=w):w=e[11];let I=ge(x,w),k;e[12]!==r?(k=["lunora-auth-org-teams",r],e[12]=r,e[13]=k):k=e[13];let S;e[14]!==i||e[15]!==r?(S=m(()=>i.listAuthOrgTeams({limit:200,organizationId:r}),"k"),e[14]=i,e[15]=r,e[16]=S):S=e[16];let _;e[17]!==h?(_={enabled:h},e[17]=h,e[18]=_):_=e[18];let A=ge(k,S,_),O;e[19]!==r?(O=["lunora-auth-org-roles",r],e[19]=r,e[20]=O):O=e[20];let T;e[21]!==i||e[22]!==r?(T=m(()=>i.listAuthOrgRoles({limit:200,organizationId:r}),"_"),e[21]=i,e[22]=r,e[23]=T):T=e[23];let R;e[24]!==c?(R={enabled:c},e[24]=c,e[25]=R):R=e[25];let F=ge(O,T,R),Z;e[26]!==d?(Z=["lunora-auth-org-team-members",d],e[26]=d,e[27]=Z):Z=e[27];let B;e[28]!==i||e[29]!==d?(B=m(()=>i.listAuthOrgTeamMembers({limit:200,teamId:d??""}),"B"),e[28]=i,e[29]=d,e[30]=B):B=e[30];let K=d!==null,J;e[31]!==K?(J={enabled:K},e[31]=K,e[32]=J):J=e[32];let j=ge(Z,B,J),U;e[33]!==C.data?.rows?(U=C.data?.rows??[],e[33]=C.data?.rows,e[34]=U):U=e[34];let P=U,Y;e[35]!==I.data?.rows?(Y=I.data?.rows??[],e[35]=I.data?.rows,e[36]=Y):Y=e[36];let M=Y,$;e[37]!==A.data?.rows?($=A.data?.rows??[],e[37]=A.data?.rows,e[38]=$):$=e[38];let q=$,V;e[39]!==F.data?.rows?(V=F.data?.rows??[],e[39]=F.data?.rows,e[40]=V):V=e[40];let te=V,le;e[41]!==d||e[42]!==j.data?.rows?(le=d===null?[]:j.data?.rows??[],e[41]=d,e[42]=j.data?.rows,e[43]=le):le=e[43];let re=le,ee=C.error??I.error??A.error??F.error??j.error,ae;if(e[44]!==I||e[45]!==C||e[46]!==c||e[47]!==F||e[48]!==d||e[49]!==j||e[50]!==h||e[51]!==A){let G=m(()=>{let se=[C.poll(),I.poll()];return h&&se.push(A.poll()),c&&se.push(F.poll()),d!==null&&se.push(j.poll()),Mt(se)},"V");ae=m(()=>{zt(G())},"ie"),e[44]=I,e[45]=C,e[46]=c,e[47]=F,e[48]=d,e[49]=j,e[50]=h,e[51]=A,e[52]=ae}else ae=e[52];let N=ae,rt;e[53]!==C?(rt=m(()=>C.poll(),"tt"),e[53]=C,e[54]=rt):rt=e[54],he(rt,!0);let ot;e[55]!==I?(ot=m(()=>I.poll(),"lt"),e[55]=I,e[56]=ot):ot=e[56],he(ot,!0);let lt;e[57]!==A?(lt=m(()=>A.poll(),"ot"),e[57]=A,e[58]=lt):lt=e[58],he(lt,h);let at;e[59]!==F?(at=m(()=>F.poll(),"it"),e[59]=F,e[60]=at):at=e[60],he(at,c);let nt;e[61]!==j?(nt=m(()=>j.poll(),"rt"),e[61]=j,e[62]=nt):nt=e[62],he(nt,d!==null);let it;e[63]===Symbol.for("react.memo_cache_sentinel")?(it=m(()=>{n(null)},"st"),e[63]=it):it=e[63];let ne=it,st;e[64]!==N?(st=m(G=>{zt((async()=>{u(!0),v(null);try{await G(),N(),u(!1)}catch(se){v(Rt(se)),u(!1)}})())},"nt"),e[64]=N,e[65]=st):st=e[65];let ie=st,mt;e[66]!==i||e[67]!==o?(mt=m(G=>{let se=D(G.id);n({action:m(async()=>{await i.removeAuthOrgTeam({teamId:se}),s(Tt=>Tt===se?null:Tt)},"action"),kind:"confirm",message:o("Delete this team and its memberships? This cannot be undone."),testId:"org-team-delete",title:o("Delete team")})},"at"),e[66]=i,e[67]=o,e[68]=mt):mt=e[68];let pt=mt,pe;e[69]!==o?(pe=o("userId"),e[69]=o,e[70]=pe):pe=e[70];let fe;e[71]!==pe?(fe={head:pe,render:sr},e[71]=pe,e[72]=fe):fe=e[72];let ve;e[73]!==o?(ve=o("role"),e[73]=o,e[74]=ve):ve=e[74];let ye;e[75]!==ve?(ye={head:ve,render:mr},e[75]=ve,e[76]=ye):ye=e[76];let dt;e[77]!==fe||e[78]!==ye?(dt=[fe,ye],e[77]=fe,e[78]=ye,e[79]=dt):dt=e[79];let ft=dt,Ce;e[80]!==o?(Ce=o("email"),e[80]=o,e[81]=Ce):Ce=e[81];let Ie;e[82]!==Ce?(Ie={head:Ce,render:dr},e[82]=Ce,e[83]=Ie):Ie=e[83];let xe;e[84]!==o?(xe=o("role"),e[84]=o,e[85]=xe):xe=e[85];let we;e[86]!==xe?(we={head:xe,render:cr},e[86]=xe,e[87]=we):we=e[87];let ze;e[88]!==o?(ze=o("status"),e[88]=o,e[89]=ze):ze=e[89];let ke;e[90]!==ze?(ke={head:ze,render:ur},e[90]=ze,e[91]=ke):ke=e[91];let ct;e[92]!==Ie||e[93]!==we||e[94]!==ke?(ct=[Ie,we,ke],e[92]=Ie,e[93]=we,e[94]=ke,e[95]=ct):ct=e[95];let vt=ct,Se;e[96]!==o?(Se=o("id"),e[96]=o,e[97]=Se):Se=e[97];let Ne;e[98]!==Se?(Ne={className:"font-mono text-xs",head:Se,render:gr},e[98]=Se,e[99]=Ne):Ne=e[99];let Ae;e[100]!==o?(Ae=o("name"),e[100]=o,e[101]=Ae):Ae=e[101];let De;e[102]!==Ae?(De={head:Ae,render:hr},e[102]=Ae,e[103]=De):De=e[103];let ut;e[104]!==Ne||e[105]!==De?(ut=[Ne,De],e[104]=Ne,e[105]=De,e[106]=ut):ut=e[106];let yt=ut,Oe;e[107]!==o?(Oe=o("userId"),e[107]=o,e[108]=Oe):Oe=e[108];let gt;e[109]!==Oe?(gt=[{head:Oe,render:br}],e[109]=Oe,e[110]=gt):gt=e[110];let Ct=gt,_e;e[111]!==o?(_e=o("role"),e[111]=o,e[112]=_e):_e=e[112];let Te;e[113]!==_e?(Te={head:_e,render:pr},e[113]=_e,e[114]=Te):Te=e[114];let Re;e[115]!==o?(Re=o("Permission"),e[115]=o,e[116]=Re):Re=e[116];let $e;e[117]!==Re?($e={className:"font-mono text-xs whitespace-pre-wrap",head:Re,render:fr},e[117]=Re,e[118]=$e):$e=e[118];let ht;e[119]!==Te||e[120]!==$e?(ht=[Te,$e],e[119]=Te,e[120]=$e,e[121]=ht):ht=e[121];let It=ht,Me;e[122]!==ee?(Me=ee!==null&&(0,l.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-detail-error",role:"alert",children:ee}),e[122]=ee,e[123]=Me):Me=e[123];let Fe;e[124]!==b?(Fe=b!==null&&(0,l.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-action-error",role:"alert",children:b}),e[124]=b,e[125]=Fe):Fe=e[125];let je;e[126]!==i||e[127]!==ie?(je=m(G=>{ie(()=>i.removeAuthOrgMember({memberId:G}))},"Me"),e[126]=i,e[127]=ie,e[128]=je):je=e[128];let Ee;e[129]!==p||e[130]!==ft||e[131]!==P||e[132]!==je?(Ee=(0,l.jsx)(or,{actionBusy:p,memberColumns:ft,members:P,onDialog:n,onRemoveMember:je}),e[129]=p,e[130]=ft,e[131]=P,e[132]=je,e[133]=Ee):Ee=e[133];let xt=C.data?.total,Le;e[134]!==P.length||e[135]!==g||e[136]!==f||e[137]!==xt?(Le=(0,l.jsx)(_t,{count:P.length,offset:g,onOffsetChange:f,pageSize:Ut,prefix:"org-members",total:xt}),e[134]=P.length,e[135]=g,e[136]=f,e[137]=xt,e[138]=Le):Le=e[138];let Pe;e[139]!==p||e[140]!==i||e[141]!==vt||e[142]!==M||e[143]!==ie||e[144]!==o?(Pe=M.length>0&&(0,l.jsx)(et,{heading:o("Invitations"),testId:"org-invitations",children:(0,l.jsx)(tt,{columns:vt,rowActions:m(G=>(0,l.jsx)(L,{"data-testid":`org-cancel-invitation-${D(G.id)}`,disabled:p,onClick:m(()=>{ie(()=>i.cancelAuthOrgInvitation({invitationId:D(G.id)}))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Cancel")}),"rowActions"),rowPrefix:"org-invitation",rows:M})}),e[139]=p,e[140]=i,e[141]=vt,e[142]=M,e[143]=ie,e[144]=o,e[145]=Pe):Pe=e[145];let Be;e[146]!==pt||e[147]!==d||e[148]!==yt||e[149]!==q||e[150]!==h?(Be=h&&(0,l.jsx)(lr,{onConfirmDeleteTeam:pt,onDialog:n,onSelectTeam:s,selectedTeam:d,teamColumns:yt,teams:q}),e[146]=pt,e[147]=d,e[148]=yt,e[149]=q,e[150]=h,e[151]=Be):Be=e[151];let Je;e[152]!==p||e[153]!==i||e[154]!==ie||e[155]!==d||e[156]!==Ct||e[157]!==re||e[158]!==h?(Je=h&&d!==null&&(0,l.jsx)(ar,{actionBusy:p,onDialog:n,onRemoveTeamMember:m(G=>{ie(()=>i.removeAuthOrgTeamMember({teamMemberId:G}))},"onRemoveTeamMember"),selectedTeam:d,teamMemberColumns:Ct,teamMembers:re}),e[152]=p,e[153]=i,e[154]=ie,e[155]=d,e[156]=Ct,e[157]=re,e[158]=h,e[159]=Je):Je=e[159];let Ue;e[160]!==i||e[161]!==It||e[162]!==te||e[163]!==c||e[164]!==o?(Ue=c&&(0,l.jsx)(nr,{onConfirmDeleteRole:m(G=>{n({action:m(()=>i.deleteAuthOrgRole({roleId:G}),"action"),kind:"confirm",message:o("Delete this custom role? Members keeping it will lose its grants."),testId:"org-role-delete",title:o("Delete role")})},"onConfirmDeleteRole"),onDialog:n,roleColumns:It,roles:te}),e[160]=i,e[161]=It,e[162]=te,e[163]=c,e[164]=o,e[165]=Ue):Ue=e[165];let He;e[166]!==a?.kind||e[167]!==r||e[168]!==N?(He=a?.kind==="add-member"&&(0,l.jsx)(Xt,{onClose:ne,onDone:N,organizationId:r}),e[166]=a?.kind,e[167]=r,e[168]=N,e[169]=He):He=e[169];let Ke;e[170]!==a?.kind||e[171]!==r||e[172]!==N?(Ke=a?.kind==="invite-member"&&(0,l.jsx)(Vt,{onClose:ne,onDone:N,organizationId:r}),e[170]=a?.kind,e[171]=r,e[172]=N,e[173]=Ke):Ke=e[173];let Qe;e[174]!==a||e[175]!==N?(Qe=a?.kind==="member-role"&&(0,l.jsx)(er,{member:a.member,onClose:ne,onDone:N}),e[174]=a,e[175]=N,e[176]=Qe):Qe=e[176];let Ze;e[177]!==a?.kind||e[178]!==r||e[179]!==N?(Ze=a?.kind==="team-create"&&(0,l.jsx)(Bt,{mode:"create",onClose:ne,onDone:N,organizationId:r}),e[177]=a?.kind,e[178]=r,e[179]=N,e[180]=Ze):Ze=e[180];let Ye;e[181]!==a||e[182]!==r||e[183]!==N?(Ye=a?.kind==="team-rename"&&(0,l.jsx)(Bt,{mode:"edit",onClose:ne,onDone:N,organizationId:r,team:a.team}),e[181]=a,e[182]=r,e[183]=N,e[184]=Ye):Ye=e[184];let qe;e[185]!==a||e[186]!==N?(qe=a?.kind==="team-add-member"&&(0,l.jsx)(tr,{onClose:ne,onDone:N,teamId:a.teamId}),e[185]=a,e[186]=N,e[187]=qe):qe=e[187];let Ge;e[188]!==a?.kind||e[189]!==r||e[190]!==N?(Ge=a?.kind==="role-create"&&(0,l.jsx)(Jt,{mode:"create",onClose:ne,onDone:N,organizationId:r}),e[188]=a?.kind,e[189]=r,e[190]=N,e[191]=Ge):Ge=e[191];let We;e[192]!==a||e[193]!==r||e[194]!==N?(We=a?.kind==="role-edit"&&(0,l.jsx)(Jt,{mode:"edit",onClose:ne,onDone:N,organizationId:r,role:a.role}),e[192]=a,e[193]=r,e[194]=N,e[195]=We):We=e[195];let Xe;e[196]!==a||e[197]!==N?(Xe=a?.kind==="confirm"&&(0,l.jsx)(Zt,{action:a.action,message:a.message,onClose:ne,onDone:N,testId:a.testId,title:a.title}),e[196]=a,e[197]=N,e[198]=Xe):Xe=e[198];let bt;return e[199]!==Me||e[200]!==Fe||e[201]!==Ee||e[202]!==Le||e[203]!==Pe||e[204]!==Be||e[205]!==Je||e[206]!==Ue||e[207]!==He||e[208]!==Ke||e[209]!==Qe||e[210]!==Ze||e[211]!==Ye||e[212]!==qe||e[213]!==Ge||e[214]!==We||e[215]!==Xe?(bt=(0,l.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"org-detail",children:[Me,Fe,Ee,Le,Pe,Be,Je,Ue,He,Ke,Qe,Ze,Ye,qe,Ge,We,Xe]}),e[199]=Me,e[200]=Fe,e[201]=Ee,e[202]=Le,e[203]=Pe,e[204]=Be,e[205]=Je,e[206]=Ue,e[207]=He,e[208]=Ke,e[209]=Qe,e[210]=Ze,e[211]=Ye,e[212]=qe,e[213]=Ge,e[214]=We,e[215]=Xe,e[216]=bt):bt=e[216],bt},"il");function sr(t){return(0,l.jsx)("span",{className:"font-mono text-xs",children:D(t.userId)})}m(sr,"rl");function mr(t){return D(t.role)}m(mr,"sl");function dr(t){return D(t.email)}m(dr,"nl");function cr(t){return D(t.role)}m(cr,"al");function ur(t){return D(t.status)}m(ur,"ml");function gr(t){return D(t.id)}m(gr,"dl");function hr(t){return D(t.name)}m(hr,"cl");function br(t){return(0,l.jsx)("span",{className:"font-mono text-xs",children:D(t.userId)})}m(br,"fl");function pr(t){return D(t.role)}m(pr,"ul");function fr(t){return D(t.permission)}m(fr,"gl");var Ht=100,$r=m(()=>{let t=(0,H.c)(69),e=oe(),r=Q(),{config:c,ready:h}=Et(),i=c.capabilities.organization,[o,a]=(0,E.useState)(null),[n,d]=(0,E.useState)(null),[s,p]=(0,E.useState)(0),u;t[0]!==s?(u=["lunora-auth-orgs",s],t[0]=s,t[1]=u):u=t[1];let b;t[2]!==e||t[3]!==s?(b=m(()=>e.listAuthOrganizations({limit:Ht,offset:s}),"g"),t[2]=e,t[3]=s,t[4]=b):b=t[4];let v;t[5]!==i?(v={enabled:i},t[5]=i,t[6]=v):v=t[6];let g=ge(u,b,v),f=g.data?.rows??null,z;t[7]!==g?(z=m(()=>g.poll(),"S"),t[7]=g,t[8]=z):z=t[8],he(z,i);let y;t[9]===Symbol.for("react.memo_cache_sentinel")?(y=m(()=>{d(null)},"v"),t[9]=y):y=t[9];let C=y,x;t[10]!==g?(x=m(()=>{g.refetch()},"x"),t[10]=g,t[11]=x):x=t[11];let w=x,I;t[12]===Symbol.for("react.memo_cache_sentinel")?(I=m(M=>{a(M)},"C"),t[12]=I):I=t[12];let k=I;if(h&&!i){let M;t[13]!==r?(M=r("Enable the organization() plugin in your auth config to manage organizations here."),t[13]=r,t[14]=M):M=t[14];let $;t[15]!==r?($=r("Organizations are not enabled."),t[15]=r,t[16]=$):$=t[16];let q;return t[17]!==M||t[18]!==$?(q=(0,l.jsx)(be,{description:M,testId:"org-disabled",title:$}),t[17]=M,t[18]=$,t[19]=q):q=t[19],q}let S;t[20]!==r?(S=r("Organizations"),t[20]=r,t[21]=S):S=t[21];let _;t[22]!==S?(_=(0,l.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:S}),t[22]=S,t[23]=_):_=t[23];let A;t[24]===Symbol.for("react.memo_cache_sentinel")?(A=m(()=>{d({kind:"create"})},"z"),t[24]=A):A=t[24];let O;t[25]!==r?(O=r("New organization"),t[25]=r,t[26]=O):O=t[26];let T;t[27]!==O?(T=(0,l.jsx)(L,{"data-testid":"org-new",onClick:A,size:"sm",type:"button",children:O}),t[27]=O,t[28]=T):T=t[28];let R;t[29]!==T||t[30]!==_?(R=(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[_,T]}),t[29]=T,t[30]=_,t[31]=R):R=t[31];let F;t[32]!==g.error?(F=g.error!==null&&(0,l.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-error",role:"alert",children:g.error}),t[32]=g.error,t[33]=F):F=t[33];let Z;t[34]!==f||t[35]!==r?(Z=f!==null&&f.length===0&&(0,l.jsx)(be,{testId:"org-empty",title:r("No organizations.")}),t[34]=f,t[35]=r,t[36]=Z):Z=t[36];let B;t[37]!==f||t[38]!==o||t[39]!==r?(B=f!==null&&f.length>0&&(0,l.jsx)(kt,{className:"overflow-hidden py-0",children:(0,l.jsx)(St,{className:"px-0",children:(0,l.jsxs)(Nt,{"data-testid":"org-table",children:[(0,l.jsx)(At,{children:(0,l.jsxs)(Ve,{children:[(0,l.jsx)(de,{children:r("id")}),(0,l.jsx)(de,{children:r("name")}),(0,l.jsx)(de,{children:r("slug")}),(0,l.jsx)(de,{children:r("created")}),(0,l.jsx)(de,{"aria-label":r("Actions")})]})}),(0,l.jsx)(Dt,{children:f.map(M=>{let $=D(M.id);return(0,l.jsxs)(Ve,{"data-testid":`org-row-${$}`,children:[(0,l.jsx)(ce,{className:"font-mono text-xs",children:$}),(0,l.jsx)(ce,{children:D(M.name)}),(0,l.jsx)(ce,{children:D(M.slug)}),(0,l.jsx)(ce,{className:"text-muted-foreground tabular-nums",children:$t(M.createdAt)}),(0,l.jsx)(ce,{children:(0,l.jsxs)("div",{className:"flex justify-end gap-1",children:[(0,l.jsx)(L,{"aria-pressed":o===$,"data-testid":`org-select-${$}`,onClick:m(()=>{k($)},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Manage")}),(0,l.jsx)(L,{"data-testid":`org-edit-${$}`,onClick:m(()=>{d({kind:"edit",org:M})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Edit")}),(0,l.jsx)(L,{"data-testid":`org-delete-${$}`,onClick:m(()=>{d({kind:"delete",org:M})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Delete")})]})})]},$)})})]})})}),t[37]=f,t[38]=o,t[39]=r,t[40]=B):B=t[40];let K;t[41]!==s||t[42]!==f||t[43]!==g.data?.total?(K=f!==null&&(0,l.jsx)(_t,{count:f.length,offset:s,onOffsetChange:p,pageSize:Ht,prefix:"org",total:g.data?.total}),t[41]=s,t[42]=f,t[43]=g.data?.total,t[44]=K):K=t[44];let J;t[45]!==c.organization||t[46]!==o?(J=o!==null&&(0,l.jsx)(ir,{organizationId:o,rolesEnabled:c.organization.roles,teamsEnabled:c.organization.teams}),t[45]=c.organization,t[46]=o,t[47]=J):J=t[47];let j;t[48]!==n?.kind||t[49]!==w?(j=n?.kind==="create"&&(0,l.jsx)(Pt,{mode:"create",onClose:C,onDone:w}),t[48]=n?.kind,t[49]=w,t[50]=j):j=t[50];let U;t[51]!==n||t[52]!==w?(U=n?.kind==="edit"&&(0,l.jsx)(Pt,{mode:"edit",onClose:C,onDone:w,org:n.org}),t[51]=n,t[52]=w,t[53]=U):U=t[53];let P;t[54]!==e||t[55]!==n||t[56]!==w||t[57]!==r?(P=n?.kind==="delete"&&(0,l.jsx)(Zt,{action:m(async()=>{let M=D(n.org.id);await e.deleteAuthOrganization({organizationId:M}),a($=>$===M?null:$)},"action"),message:r("Delete this organization? Its members, invitations, teams, and custom roles are removed. This cannot be undone."),onClose:C,onDone:w,testId:"org-delete",title:r("Delete organization")}),t[54]=e,t[55]=n,t[56]=w,t[57]=r,t[58]=P):P=t[58];let Y;return t[59]!==R||t[60]!==F||t[61]!==Z||t[62]!==B||t[63]!==K||t[64]!==J||t[65]!==j||t[66]!==U||t[67]!==P?(Y=(0,l.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-organizations",children:[R,F,Z,B,K,J,j,U,P]}),t[59]=R,t[60]=F,t[61]=Z,t[62]=B,t[63]=K,t[64]=J,t[65]=j,t[66]=U,t[67]=P,t[68]=Y):Y=t[68],Y},"Ml");export{$r as default};
1
+ import{a as Et}from"./chunk-D7UOJY4N.js";import{a as me}from"./chunk-PLDE5R5Y.js";import{a as _t,b as jt}from"./chunk-INDH6PRB.js";import"./chunk-EZ5PVGPY.js";import{a as Lt}from"./chunk-XHDCFSC6.js";import{a as Ot}from"./chunk-ACCTEC6Y.js";import{a as Ft}from"./chunk-EYBS3Q7O.js";import{a as he,b as Mt}from"./chunk-RTD3B67U.js";import{i as X}from"./chunk-Z6PYAG36.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as L}from"./chunk-QHI77TGI.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as be}from"./chunk-O46IV64X.js";import"./chunk-L27FKJTG.js";import{a as Nt,b as At,c as Dt,d as Ve,e as de,f as ce}from"./chunk-KMBE7RTC.js";import{b as ge}from"./chunk-NP6H72XD.js";import{a as kt,e as St}from"./chunk-NPHGFVNE.js";import{n as oe}from"./chunk-YESGXFAR.js";import"./chunk-ZPQBVYNN.js";import{B as Q,j as Rt,r as D,s as zt,w as $t}from"./chunk-CDIV23I2.js";import"./chunk-PDBW6GTJ.js";import{a as qt}from"./chunk-A6TVTNKO.js";import{a as Yt,b as Gt}from"./chunk-ADABTCDI.js";import{a as m,d as wt}from"./chunk-5PEAXTYQ.js";var H=wt(qt(),1),E=wt(Yt(),1);var l=wt(Gt(),1);var Kt=m(t=>{let e=JSON.parse(t);if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("Expected a JSON object");return e},"Pt"),Wt=m(t=>{let e=Kt(t),r={};for(let[c,h]of Object.entries(e)){if(!Array.isArray(h)||h.some(i=>typeof i!="string"))throw new TypeError(`"${c}" must map to an array of action strings`);r[c]=h}return r},"qt"),Qt=m(t=>t==null||t===""?"":typeof t=="string"?t:JSON.stringify(t,null,2),"jt"),W=m(t=>{let e=(0,H.c)(6),{children:r,htmlFor:c,label:h}=t,i;e[0]!==c||e[1]!==h?(i=(0,l.jsx)(Ft,{htmlFor:c,children:h}),e[0]=c,e[1]=h,e[2]=i):i=e[2];let o;return e[3]!==r||e[4]!==i?(o=(0,l.jsxs)("div",{className:"flex flex-col gap-1",children:[i,r]}),e[3]=r,e[4]=i,e[5]=o):o=e[5],o},"W"),ue=m(({busy:t,canSubmit:e,children:r,destructive:c=!1,error:h,onClose:i,onSubmit:o,submitLabel:a,testId:n,title:d})=>{let s=Q();return(0,l.jsxs)(Lt,{label:d,onClose:i,panelTestId:`${n}-panel`,testId:`${n}-overlay`,variant:"dialog",children:[(0,l.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:d}),r,h!==null&&(0,l.jsx)("p",{className:"text-sm text-destructive","data-testid":`${n}-error`,role:"alert",children:h}),(0,l.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[(0,l.jsx)(L,{"data-testid":`${n}-cancel`,onClick:i,size:"sm",type:"button",variant:"outline",children:s("Cancel")}),(0,l.jsx)(L,{"data-testid":`${n}-submit`,disabled:t||!e,onClick:o,size:"sm",type:"button",variant:c?"destructive":"default",children:t?s("Saving\u2026"):a})]})]})},"de"),Pt=m(t=>{let e=(0,H.c)(79),{mode:r,onClose:c,onDone:h,org:i}=t,o=oe(),a=Q(),{busy:n,error:d,run:s}=me(),p;e[0]!==i?(p=i?D(i.name):"",e[0]=i,e[1]=p):p=e[1];let[u,b]=(0,E.useState)(p),v;e[2]!==i?(v=i?D(i.slug):"",e[2]=i,e[3]=v):v=e[3];let[g,f]=(0,E.useState)(v),z;e[4]!==i?(z=i?D(i.logo):"",e[4]=i,e[5]=z):z=e[5];let[y,C]=(0,E.useState)(z),[x,w]=(0,E.useState)(""),I;e[6]!==r||e[7]!==i?.metadata?(I=r==="edit"?Qt(i?.metadata):"",e[6]=r,e[7]=i?.metadata,e[8]=I):I=e[8];let[k,S]=(0,E.useState)(I),_;e[9]!==o||e[10]!==y||e[11]!==k||e[12]!==r||e[13]!==u||e[14]!==c||e[15]!==h||e[16]!==i?.id||e[17]!==x||e[18]!==s||e[19]!==g?(_=m(()=>{s(async()=>{let N=k.trim()===""?void 0:Kt(k);r==="create"?await o.createAuthOrganization({logo:y.trim()===""?void 0:y.trim(),metadata:N,name:u.trim(),ownerId:x.trim()===""?void 0:x.trim(),slug:g.trim()===""?void 0:g.trim()}):await o.updateAuthOrganization({logo:y.trim()===""?void 0:y.trim(),metadata:N,name:u.trim()===""?void 0:u.trim(),organizationId:D(i?.id),slug:g.trim()===""?void 0:g.trim()}),h(),c()})},"O"),e[9]=o,e[10]=y,e[11]=k,e[12]=r,e[13]=u,e[14]=c,e[15]=h,e[16]=i?.id,e[17]=x,e[18]=s,e[19]=g,e[20]=_):_=e[20];let A=_,O;e[21]!==r||e[22]!==u?(O=u.trim()!==""||r==="edit",e[21]=r,e[22]=u,e[23]=O):O=e[23];let T;e[24]!==r||e[25]!==a?(T=a(r==="create"?"Create":"Save"),e[24]=r,e[25]=a,e[26]=T):T=e[26];let R;e[27]!==r||e[28]!==a?(R=a(r==="create"?"New organization":"Edit organization"),e[27]=r,e[28]=a,e[29]=R):R=e[29];let F;e[30]!==a?(F=a("name"),e[30]=a,e[31]=F):F=e[31];let Z;e[32]===Symbol.for("react.memo_cache_sentinel")?(Z=m(N=>{b(N.target.value)},"H"),e[32]=Z):Z=e[32];let B;e[33]!==u?(B=(0,l.jsx)(X,{"data-testid":"org-form-name",id:"org-form-name",onChange:Z,value:u}),e[33]=u,e[34]=B):B=e[34];let K;e[35]!==B||e[36]!==F?(K=(0,l.jsx)(W,{htmlFor:"org-form-name",label:F,children:B}),e[35]=B,e[36]=F,e[37]=K):K=e[37];let J;e[38]!==a?(J=a("Slug (optional \u2014 derived from name)"),e[38]=a,e[39]=J):J=e[39];let j;e[40]===Symbol.for("react.memo_cache_sentinel")?(j=m(N=>{f(N.target.value)},"F"),e[40]=j):j=e[40];let U;e[41]!==g?(U=(0,l.jsx)(X,{"data-testid":"org-form-slug",id:"org-form-slug",onChange:j,value:g}),e[41]=g,e[42]=U):U=e[42];let P;e[43]!==J||e[44]!==U?(P=(0,l.jsx)(W,{htmlFor:"org-form-slug",label:J,children:U}),e[43]=J,e[44]=U,e[45]=P):P=e[45];let Y;e[46]!==a?(Y=a("Logo URL (optional)"),e[46]=a,e[47]=Y):Y=e[47];let M;e[48]===Symbol.for("react.memo_cache_sentinel")?(M=m(N=>{C(N.target.value)},"M"),e[48]=M):M=e[48];let $;e[49]!==y?($=(0,l.jsx)(X,{"data-testid":"org-form-logo",id:"org-form-logo",onChange:M,value:y}),e[49]=y,e[50]=$):$=e[50];let q;e[51]!==Y||e[52]!==$?(q=(0,l.jsx)(W,{htmlFor:"org-form-logo",label:Y,children:$}),e[51]=Y,e[52]=$,e[53]=q):q=e[53];let V;e[54]!==r||e[55]!==x||e[56]!==a?(V=r==="create"&&(0,l.jsx)(W,{htmlFor:"org-form-owner",label:a("Owner user id (optional)"),children:(0,l.jsx)(X,{"data-testid":"org-form-owner",id:"org-form-owner",onChange:m(N=>{w(N.target.value)},"onChange"),value:x})}),e[54]=r,e[55]=x,e[56]=a,e[57]=V):V=e[57];let te;e[58]!==a?(te=a("Metadata (JSON, optional)"),e[58]=a,e[59]=te):te=e[59];let le;e[60]===Symbol.for("react.memo_cache_sentinel")?(le=m(N=>{S(N.target.value)},"oe"),e[60]=le):le=e[60];let re;e[61]!==k?(re=(0,l.jsx)(Ot,{"data-testid":"org-form-metadata",id:"org-form-metadata",onChange:le,value:k}),e[61]=k,e[62]=re):re=e[62];let ee;e[63]!==te||e[64]!==re?(ee=(0,l.jsx)(W,{htmlFor:"org-form-metadata",label:te,children:re}),e[63]=te,e[64]=re,e[65]=ee):ee=e[65];let ae;return e[66]!==n||e[67]!==d||e[68]!==c||e[69]!==A||e[70]!==K||e[71]!==P||e[72]!==q||e[73]!==V||e[74]!==ee||e[75]!==O||e[76]!==T||e[77]!==R?(ae=(0,l.jsxs)(ue,{busy:n,canSubmit:O,error:d,onClose:c,onSubmit:A,submitLabel:T,testId:"org-form",title:R,children:[K,P,q,V,ee]}),e[66]=n,e[67]=d,e[68]=c,e[69]=A,e[70]=K,e[71]=P,e[72]=q,e[73]=V,e[74]=ee,e[75]=O,e[76]=T,e[77]=R,e[78]=ae):ae=e[78],ae},"Dt"),Xt=m(t=>{let e=(0,H.c)(40),{onClose:r,onDone:c,organizationId:h}=t,i=oe(),o=Q(),{busy:a,error:n,run:d}=me(),[s,p]=(0,E.useState)(""),[u,b]=(0,E.useState)(""),v;e[0]!==i||e[1]!==r||e[2]!==c||e[3]!==h||e[4]!==u||e[5]!==d||e[6]!==s?(v=m(()=>{d(async()=>{await i.addAuthOrgMember({organizationId:h,role:u.trim()===""?void 0:u.trim(),userId:s.trim()}),c(),r()})},"p"),e[0]=i,e[1]=r,e[2]=c,e[3]=h,e[4]=u,e[5]=d,e[6]=s,e[7]=v):v=e[7];let g=v,f;e[8]!==s?(f=s.trim(),e[8]=s,e[9]=f):f=e[9];let z=f!=="",y;e[10]!==o?(y=o("Add member"),e[10]=o,e[11]=y):y=e[11];let C;e[12]!==o?(C=o("Add member"),e[12]=o,e[13]=C):C=e[13];let x;e[14]!==o?(x=o("User id"),e[14]=o,e[15]=x):x=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=m(R=>{p(R.target.value)},"I"),e[16]=w):w=e[16];let I;e[17]!==s?(I=(0,l.jsx)(X,{"data-testid":"org-add-member-user",id:"org-add-member-user",onChange:w,value:s}),e[17]=s,e[18]=I):I=e[18];let k;e[19]!==x||e[20]!==I?(k=(0,l.jsx)(W,{htmlFor:"org-add-member-user",label:x,children:I}),e[19]=x,e[20]=I,e[21]=k):k=e[21];let S;e[22]!==o?(S=o("Role (optional)"),e[22]=o,e[23]=S):S=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=m(R=>{b(R.target.value)},"O"),e[24]=_):_=e[24];let A;e[25]!==u?(A=(0,l.jsx)(X,{"data-testid":"org-add-member-role",id:"org-add-member-role",onChange:_,value:u}),e[25]=u,e[26]=A):A=e[26];let O;e[27]!==S||e[28]!==A?(O=(0,l.jsx)(W,{htmlFor:"org-add-member-role",label:S,children:A}),e[27]=S,e[28]=A,e[29]=O):O=e[29];let T;return e[30]!==a||e[31]!==n||e[32]!==r||e[33]!==g||e[34]!==O||e[35]!==z||e[36]!==y||e[37]!==C||e[38]!==k?(T=(0,l.jsxs)(ue,{busy:a,canSubmit:z,error:n,onClose:r,onSubmit:g,submitLabel:y,testId:"org-add-member",title:C,children:[k,O]}),e[30]=a,e[31]=n,e[32]=r,e[33]=g,e[34]=O,e[35]=z,e[36]=y,e[37]=C,e[38]=k,e[39]=T):T=e[39],T},"Kt"),Vt=m(t=>{let e=(0,H.c)(40),{onClose:r,onDone:c,organizationId:h}=t,i=oe(),o=Q(),{busy:a,error:n,run:d}=me(),[s,p]=(0,E.useState)(""),[u,b]=(0,E.useState)(""),v;e[0]!==i||e[1]!==s||e[2]!==r||e[3]!==c||e[4]!==h||e[5]!==u||e[6]!==d?(v=m(()=>{d(async()=>{await i.inviteAuthOrgMember({email:s.trim(),organizationId:h,role:u.trim()===""?void 0:u.trim()}),c(),r()})},"p"),e[0]=i,e[1]=s,e[2]=r,e[3]=c,e[4]=h,e[5]=u,e[6]=d,e[7]=v):v=e[7];let g=v,f;e[8]!==s?(f=s.trim(),e[8]=s,e[9]=f):f=e[9];let z=f!=="",y;e[10]!==o?(y=o("Send invitation"),e[10]=o,e[11]=y):y=e[11];let C;e[12]!==o?(C=o("Invite member"),e[12]=o,e[13]=C):C=e[13];let x;e[14]!==o?(x=o("email"),e[14]=o,e[15]=x):x=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=m(R=>{p(R.target.value)},"I"),e[16]=w):w=e[16];let I;e[17]!==s?(I=(0,l.jsx)(X,{"data-testid":"org-invite-member-email",id:"org-invite-member-email",onChange:w,type:"email",value:s}),e[17]=s,e[18]=I):I=e[18];let k;e[19]!==x||e[20]!==I?(k=(0,l.jsx)(W,{htmlFor:"org-invite-member-email",label:x,children:I}),e[19]=x,e[20]=I,e[21]=k):k=e[21];let S;e[22]!==o?(S=o("Role (optional)"),e[22]=o,e[23]=S):S=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=m(R=>{b(R.target.value)},"O"),e[24]=_):_=e[24];let A;e[25]!==u?(A=(0,l.jsx)(X,{"data-testid":"org-invite-member-role",id:"org-invite-member-role",onChange:_,value:u}),e[25]=u,e[26]=A):A=e[26];let O;e[27]!==S||e[28]!==A?(O=(0,l.jsx)(W,{htmlFor:"org-invite-member-role",label:S,children:A}),e[27]=S,e[28]=A,e[29]=O):O=e[29];let T;return e[30]!==a||e[31]!==n||e[32]!==r||e[33]!==g||e[34]!==O||e[35]!==z||e[36]!==y||e[37]!==C||e[38]!==k?(T=(0,l.jsxs)(ue,{busy:a,canSubmit:z,error:n,onClose:r,onSubmit:g,submitLabel:y,testId:"org-invite-member",title:C,children:[k,O]}),e[30]=a,e[31]=n,e[32]=r,e[33]=g,e[34]=O,e[35]=z,e[36]=y,e[37]=C,e[38]=k,e[39]=T):T=e[39],T},"Vt"),er=m(t=>{let e=(0,H.c)(32),{member:r,onClose:c,onDone:h}=t,i=oe(),o=Q(),{busy:a,error:n,run:d}=me(),s;e[0]!==r.role?(s=m(()=>D(r.role),"a"),e[0]=r.role,e[1]=s):s=e[1];let[p,u]=(0,E.useState)(s),b;e[2]!==i||e[3]!==r.id||e[4]!==c||e[5]!==h||e[6]!==p||e[7]!==d?(b=m(()=>{d(async()=>{await i.setAuthOrgMemberRole({memberId:D(r.id),role:p.trim()}),h(),c()})},"g"),e[2]=i,e[3]=r.id,e[4]=c,e[5]=h,e[6]=p,e[7]=d,e[8]=b):b=e[8];let v=b,g;e[9]!==p?(g=p.trim(),e[9]=p,e[10]=g):g=e[10];let f=g!=="",z;e[11]!==o?(z=o("Save"),e[11]=o,e[12]=z):z=e[12];let y;e[13]!==o?(y=o("Change member role"),e[13]=o,e[14]=y):y=e[14];let C;e[15]!==o?(C=o("Role"),e[15]=o,e[16]=C):C=e[16];let x;e[17]===Symbol.for("react.memo_cache_sentinel")?(x=m(S=>{u(S.target.value)},"x"),e[17]=x):x=e[17];let w;e[18]!==p?(w=(0,l.jsx)(X,{"data-testid":"org-member-role-value",id:"org-member-role-value",onChange:x,value:p}),e[18]=p,e[19]=w):w=e[19];let I;e[20]!==C||e[21]!==w?(I=(0,l.jsx)(W,{htmlFor:"org-member-role-value",label:C,children:w}),e[20]=C,e[21]=w,e[22]=I):I=e[22];let k;return e[23]!==a||e[24]!==n||e[25]!==c||e[26]!==v||e[27]!==I||e[28]!==f||e[29]!==z||e[30]!==y?(k=(0,l.jsx)(ue,{busy:a,canSubmit:f,error:n,onClose:c,onSubmit:v,submitLabel:z,testId:"org-member-role",title:y,children:I}),e[23]=a,e[24]=n,e[25]=c,e[26]=v,e[27]=I,e[28]=f,e[29]=z,e[30]=y,e[31]=k):k=e[31],k},"Wt"),Bt=m(t=>{let e=(0,H.c)(36),{mode:r,onClose:c,onDone:h,organizationId:i,team:o}=t,a=oe(),n=Q(),{busy:d,error:s,run:p}=me(),u;e[0]!==o?(u=o?D(o.name):"",e[0]=o,e[1]=u):u=e[1];let[b,v]=(0,E.useState)(u),g;e[2]!==a||e[3]!==r||e[4]!==b||e[5]!==c||e[6]!==h||e[7]!==i||e[8]!==p||e[9]!==o?.id?(g=m(()=>{p(async()=>{await(r==="create"?a.createAuthOrgTeam({name:b.trim(),organizationId:i}):a.updateAuthOrgTeam({name:b.trim(),teamId:D(o?.id)})),h(),c()})},"f"),e[2]=a,e[3]=r,e[4]=b,e[5]=c,e[6]=h,e[7]=i,e[8]=p,e[9]=o?.id,e[10]=g):g=e[10];let f=g,z;e[11]!==b?(z=b.trim(),e[11]=b,e[12]=z):z=e[12];let y=z!=="",C;e[13]!==r||e[14]!==n?(C=n(r==="create"?"Create":"Save"),e[13]=r,e[14]=n,e[15]=C):C=e[15];let x;e[16]!==r||e[17]!==n?(x=n(r==="create"?"New team":"Rename team"),e[16]=r,e[17]=n,e[18]=x):x=e[18];let w;e[19]!==n?(w=n("name"),e[19]=n,e[20]=w):w=e[20];let I;e[21]===Symbol.for("react.memo_cache_sentinel")?(I=m(A=>{v(A.target.value)},"C"),e[21]=I):I=e[21];let k;e[22]!==b?(k=(0,l.jsx)(X,{"data-testid":"org-team-form-name",id:"org-team-form-name",onChange:I,value:b}),e[22]=b,e[23]=k):k=e[23];let S;e[24]!==w||e[25]!==k?(S=(0,l.jsx)(W,{htmlFor:"org-team-form-name",label:w,children:k}),e[24]=w,e[25]=k,e[26]=S):S=e[26];let _;return e[27]!==d||e[28]!==s||e[29]!==c||e[30]!==f||e[31]!==S||e[32]!==y||e[33]!==C||e[34]!==x?(_=(0,l.jsx)(ue,{busy:d,canSubmit:y,error:s,onClose:c,onSubmit:f,submitLabel:C,testId:"org-team-form",title:x,children:S}),e[27]=d,e[28]=s,e[29]=c,e[30]=f,e[31]=S,e[32]=y,e[33]=C,e[34]=x,e[35]=_):_=e[35],_},"zt"),tr=m(t=>{let e=(0,H.c)(30),{onClose:r,onDone:c,teamId:h}=t,i=oe(),o=Q(),{busy:a,error:n,run:d}=me(),[s,p]=(0,E.useState)(""),u;e[0]!==i||e[1]!==r||e[2]!==c||e[3]!==d||e[4]!==h||e[5]!==s?(u=m(()=>{d(async()=>{await i.addAuthOrgTeamMember({teamId:h,userId:s.trim()}),c(),r()})},"c"),e[0]=i,e[1]=r,e[2]=c,e[3]=d,e[4]=h,e[5]=s,e[6]=u):u=e[6];let b=u,v;e[7]!==s?(v=s.trim(),e[7]=s,e[8]=v):v=e[8];let g=v!=="",f;e[9]!==o?(f=o("Add member"),e[9]=o,e[10]=f):f=e[10];let z;e[11]!==o?(z=o("Add team member"),e[11]=o,e[12]=z):z=e[12];let y;e[13]!==o?(y=o("User id"),e[13]=o,e[14]=y):y=e[14];let C;e[15]===Symbol.for("react.memo_cache_sentinel")?(C=m(k=>{p(k.target.value)},"y"),e[15]=C):C=e[15];let x;e[16]!==s?(x=(0,l.jsx)(X,{"data-testid":"org-team-add-member-user",id:"org-team-add-member-user",onChange:C,value:s}),e[16]=s,e[17]=x):x=e[17];let w;e[18]!==y||e[19]!==x?(w=(0,l.jsx)(W,{htmlFor:"org-team-add-member-user",label:y,children:x}),e[18]=y,e[19]=x,e[20]=w):w=e[20];let I;return e[21]!==a||e[22]!==n||e[23]!==r||e[24]!==b||e[25]!==g||e[26]!==f||e[27]!==z||e[28]!==w?(I=(0,l.jsx)(ue,{busy:a,canSubmit:g,error:n,onClose:r,onSubmit:b,submitLabel:f,testId:"org-team-add-member",title:z,children:w}),e[21]=a,e[22]=n,e[23]=r,e[24]=b,e[25]=g,e[26]=f,e[27]=z,e[28]=w,e[29]=I):I=e[29],I},"Xt"),Jt=m(t=>{let e=(0,H.c)(47),{mode:r,onClose:c,onDone:h,organizationId:i,role:o}=t,a=oe(),n=Q(),{busy:d,error:s,run:p}=me(),u;e[0]!==o?(u=o?D(o.role):"",e[0]=o,e[1]=u):u=e[1];let[b,v]=(0,E.useState)(u),g;e[2]!==r||e[3]!==o?.permission?(g=r==="edit"?Qt(o?.permission):"",e[2]=r,e[3]=o?.permission,e[4]=g):g=e[4];let[f,z]=(0,E.useState)(g),y;e[5]!==a||e[6]!==r||e[7]!==b||e[8]!==c||e[9]!==h||e[10]!==i||e[11]!==f||e[12]!==o?.id||e[13]!==p?(y=m(()=>{p(async()=>{let R=Wt(f);await(r==="create"?a.createAuthOrgRole({organizationId:i,permission:R,role:b.trim()}):a.updateAuthOrgRole({permission:R,roleId:D(o?.id)})),h(),c()})},"v"),e[5]=a,e[6]=r,e[7]=b,e[8]=c,e[9]=h,e[10]=i,e[11]=f,e[12]=o?.id,e[13]=p,e[14]=y):y=e[14];let C=y,x;e[15]!==r||e[16]!==b||e[17]!==f?(x=f.trim()!==""&&(r==="edit"||b.trim()!==""),e[15]=r,e[16]=b,e[17]=f,e[18]=x):x=e[18];let w;e[19]!==r||e[20]!==n?(w=n(r==="create"?"Create":"Save"),e[19]=r,e[20]=n,e[21]=w):w=e[21];let I;e[22]!==r||e[23]!==n?(I=n(r==="create"?"New role":"Edit role"),e[22]=r,e[23]=n,e[24]=I):I=e[24];let k;e[25]!==r||e[26]!==b||e[27]!==n?(k=r==="create"&&(0,l.jsx)(W,{htmlFor:"org-role-form-name",label:n("Role name"),children:(0,l.jsx)(X,{"data-testid":"org-role-form-name",id:"org-role-form-name",onChange:m(R=>{v(R.target.value)},"onChange"),value:b})}),e[25]=r,e[26]=b,e[27]=n,e[28]=k):k=e[28];let S;e[29]!==n?(S=n('Permission (JSON, e.g. {"project":["create","update"]})'),e[29]=n,e[30]=S):S=e[30];let _;e[31]===Symbol.for("react.memo_cache_sentinel")?(_=m(R=>{z(R.target.value)},"O"),e[31]=_):_=e[31];let A;e[32]!==f?(A=(0,l.jsx)(Ot,{"data-testid":"org-role-form-permission",id:"org-role-form-permission",onChange:_,value:f}),e[32]=f,e[33]=A):A=e[33];let O;e[34]!==A||e[35]!==S?(O=(0,l.jsx)(W,{htmlFor:"org-role-form-permission",label:S,children:A}),e[34]=A,e[35]=S,e[36]=O):O=e[36];let T;return e[37]!==d||e[38]!==s||e[39]!==c||e[40]!==C||e[41]!==O||e[42]!==x||e[43]!==w||e[44]!==I||e[45]!==k?(T=(0,l.jsxs)(ue,{busy:d,canSubmit:x,error:s,onClose:c,onSubmit:C,submitLabel:w,testId:"org-role-form",title:I,children:[k,O]}),e[37]=d,e[38]=s,e[39]=c,e[40]=C,e[41]=O,e[42]=x,e[43]=w,e[44]=I,e[45]=k,e[46]=T):T=e[46],T},"At"),Zt=m(t=>{let e=(0,H.c)(18),{action:r,message:c,onClose:h,onDone:i,testId:o,title:a}=t,n=Q(),{busy:d,error:s,run:p}=me(),u;e[0]!==r||e[1]!==h||e[2]!==i||e[3]!==p?(u=m(()=>{p(async()=>{await r(),i(),h()})},"c"),e[0]=r,e[1]=h,e[2]=i,e[3]=p,e[4]=u):u=e[4];let b=u,v;e[5]!==n?(v=n("Delete"),e[5]=n,e[6]=v):v=e[6];let g;e[7]!==c?(g=(0,l.jsx)("p",{className:"text-sm text-muted-foreground",children:c}),e[7]=c,e[8]=g):g=e[8];let f;return e[9]!==d||e[10]!==s||e[11]!==h||e[12]!==b||e[13]!==v||e[14]!==g||e[15]!==o||e[16]!==a?(f=(0,l.jsx)(ue,{busy:d,canSubmit:!0,destructive:!0,error:s,onClose:h,onSubmit:b,submitLabel:v,testId:o,title:a,children:g}),e[9]=d,e[10]=s,e[11]=h,e[12]=b,e[13]=v,e[14]=g,e[15]=o,e[16]=a,e[17]=f):f=e[17],f},"Lt"),et=m(t=>{let e=(0,H.c)(13),{action:r,children:c,heading:h,testId:i}=t,o;e[0]!==h?(o=(0,l.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h}),e[0]=h,e[1]=o):o=e[1];let a;e[2]!==r?(a=r!==void 0&&(0,l.jsx)("div",{className:"flex items-center gap-2",children:r}),e[2]=r,e[3]=a):a=e[3];let n;e[4]!==o||e[5]!==a?(n=(0,l.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[o,a]}),e[4]=o,e[5]=a,e[6]=n):n=e[6];let d;e[7]!==c?(d=(0,l.jsx)(St,{className:"px-0",children:c}),e[7]=c,e[8]=d):d=e[8];let s;return e[9]!==n||e[10]!==d||e[11]!==i?(s=(0,l.jsxs)(kt,{className:"overflow-hidden py-0","data-testid":i,children:[n,d]}),e[9]=n,e[10]=d,e[11]=i,e[12]=s):s=e[12],s},"Ye"),tt=m(t=>{let e=(0,H.c)(23),{columns:r,rowActions:c,rowPrefix:h,rows:i}=t,o=Q(),a;e[0]!==r?(a=r.map(rr),e[0]=r,e[1]=a):a=e[1];let n;e[2]!==o?(n=o("Actions"),e[2]=o,e[3]=n):n=e[3];let d;e[4]!==n?(d=(0,l.jsx)(de,{"aria-label":n}),e[4]=n,e[5]=d):d=e[5];let s;e[6]!==a||e[7]!==d?(s=(0,l.jsx)(At,{children:(0,l.jsxs)(Ve,{children:[a,d]})}),e[6]=a,e[7]=d,e[8]=s):s=e[8];let p;if(e[9]!==r||e[10]!==c||e[11]!==h||e[12]!==i){let v;e[14]!==r||e[15]!==c||e[16]!==h?(v=m((g,f)=>{let z=D(g.id),y=z===""?`index-${f.toString()}`:z;return(0,l.jsxs)(Ve,{"data-testid":`${h}-${y}`,children:[r.map(C=>(0,l.jsx)(ce,{className:C.className,children:C.render(g)},C.head)),(0,l.jsx)(ce,{children:(0,l.jsx)("div",{className:"flex justify-end gap-1",children:c(g)})})]},y)},"p"),e[14]=r,e[15]=c,e[16]=h,e[17]=v):v=e[17],p=i.map(v),e[9]=r,e[10]=c,e[11]=h,e[12]=i,e[13]=p}else p=e[13];let u;e[18]!==p?(u=(0,l.jsx)(Dt,{children:p}),e[18]=p,e[19]=u):u=e[19];let b;return e[20]!==s||e[21]!==u?(b=(0,l.jsxs)(Nt,{children:[s,u]}),e[20]=s,e[21]=u,e[22]=b):b=e[22],b},"et");function rr(t){return(0,l.jsx)(de,{children:t.head},t.head)}m(rr,"Yt");var or=m(t=>{let e=(0,H.c)(30),{actionBusy:r,onRemoveMember:c,memberColumns:h,members:i,onDialog:o}=t,a=Q(),n;e[0]!==o?(n=m(()=>{o({kind:"add-member"})},"r"),e[0]=o,e[1]=n):n=e[1];let d;e[2]!==a?(d=a("Add member"),e[2]=a,e[3]=d):d=e[3];let s;e[4]!==n||e[5]!==d?(s=(0,l.jsx)(L,{"data-testid":"org-open-add-member",onClick:n,size:"xs",type:"button",variant:"outline",children:d}),e[4]=n,e[5]=d,e[6]=s):s=e[6];let p;e[7]!==o?(p=m(()=>{o({kind:"invite-member"})},"h"),e[7]=o,e[8]=p):p=e[8];let u;e[9]!==a?(u=a("Invite member"),e[9]=a,e[10]=u):u=e[10];let b;e[11]!==p||e[12]!==u?(b=(0,l.jsx)(L,{"data-testid":"org-open-invite-member",onClick:p,size:"xs",type:"button",variant:"outline",children:u}),e[11]=p,e[12]=u,e[13]=b):b=e[13];let v;e[14]!==s||e[15]!==b?(v=(0,l.jsxs)(l.Fragment,{children:[s,b]}),e[14]=s,e[15]=b,e[16]=v):v=e[16];let g;e[17]!==a?(g=a("Members"),e[17]=a,e[18]=g):g=e[18];let f;e[19]!==r||e[20]!==h||e[21]!==i||e[22]!==o||e[23]!==c||e[24]!==a?(f=i.length===0?(0,l.jsx)("div",{className:"p-3",children:(0,l.jsx)(be,{testId:"org-members-empty",title:a("No members.")})}):(0,l.jsx)(tt,{columns:h,rowActions:m(y=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L,{"data-testid":`org-member-role-${D(y.id)}`,onClick:m(()=>{o({kind:"member-role",member:y})},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Change role")}),(0,l.jsx)(L,{"data-testid":`org-remove-member-${D(y.id)}`,disabled:r,onClick:m(()=>{c(D(y.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Remove")})]}),"rowActions"),rowPrefix:"org-member",rows:i}),e[19]=r,e[20]=h,e[21]=i,e[22]=o,e[23]=c,e[24]=a,e[25]=f):f=e[25];let z;return e[26]!==v||e[27]!==g||e[28]!==f?(z=(0,l.jsx)(et,{action:v,heading:g,testId:"org-members",children:f}),e[26]=v,e[27]=g,e[28]=f,e[29]=z):z=e[29],z},"el"),lr=m(t=>{let e=(0,H.c)(21),{onConfirmDeleteTeam:r,onDialog:c,onSelectTeam:h,selectedTeam:i,teamColumns:o,teams:a}=t,n=Q(),d;e[0]!==c?(d=m(()=>{c({kind:"team-create"})},"m"),e[0]=c,e[1]=d):d=e[1];let s;e[2]!==n?(s=n("New team"),e[2]=n,e[3]=s):s=e[3];let p;e[4]!==d||e[5]!==s?(p=(0,l.jsx)(L,{"data-testid":"org-open-create-team",onClick:d,size:"xs",type:"button",variant:"outline",children:s}),e[4]=d,e[5]=s,e[6]=p):p=e[6];let u;e[7]!==n?(u=n("Teams"),e[7]=n,e[8]=u):u=e[8];let b;e[9]!==r||e[10]!==c||e[11]!==h||e[12]!==i||e[13]!==n||e[14]!==o||e[15]!==a?(b=a.length===0?(0,l.jsx)("div",{className:"p-3",children:(0,l.jsx)(be,{testId:"org-teams-empty",title:n("No teams.")})}):(0,l.jsx)(tt,{columns:o,rowActions:m(g=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L,{"aria-pressed":i===D(g.id),"data-testid":`org-team-select-${D(g.id)}`,onClick:m(()=>{h(D(g.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Members")}),(0,l.jsx)(L,{"data-testid":`org-team-rename-${D(g.id)}`,onClick:m(()=>{c({kind:"team-rename",team:g})},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Rename")}),(0,l.jsx)(L,{"data-testid":`org-team-delete-${D(g.id)}`,onClick:m(()=>{r(g)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Delete")})]}),"rowActions"),rowPrefix:"org-team",rows:a}),e[9]=r,e[10]=c,e[11]=h,e[12]=i,e[13]=n,e[14]=o,e[15]=a,e[16]=b):b=e[16];let v;return e[17]!==p||e[18]!==u||e[19]!==b?(v=(0,l.jsx)(et,{action:p,heading:u,testId:"org-teams",children:b}),e[17]=p,e[18]=u,e[19]=b,e[20]=v):v=e[20],v},"tl"),ar=m(t=>{let e=(0,H.c)(20),{actionBusy:r,onRemoveTeamMember:c,onDialog:h,selectedTeam:i,teamMemberColumns:o,teamMembers:a}=t,n=Q(),d;e[0]!==h||e[1]!==i?(d=m(()=>{h({kind:"team-add-member",teamId:i})},"m"),e[0]=h,e[1]=i,e[2]=d):d=e[2];let s;e[3]!==n?(s=n("Add member"),e[3]=n,e[4]=s):s=e[4];let p;e[5]!==d||e[6]!==s?(p=(0,l.jsx)(L,{"data-testid":"org-open-add-team-member",onClick:d,size:"xs",type:"button",variant:"outline",children:s}),e[5]=d,e[6]=s,e[7]=p):p=e[7];let u;e[8]!==n?(u=n("Team members"),e[8]=n,e[9]=u):u=e[9];let b;e[10]!==r||e[11]!==c||e[12]!==n||e[13]!==o||e[14]!==a?(b=a.length===0?(0,l.jsx)("div",{className:"p-3",children:(0,l.jsx)(be,{testId:"org-team-members-empty",title:n("No team members.")})}):(0,l.jsx)(tt,{columns:o,rowActions:m(g=>(0,l.jsx)(L,{"data-testid":`org-team-remove-member-${D(g.id)}`,disabled:r,onClick:m(()=>{c(D(g.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Remove")}),"rowActions"),rowPrefix:"org-team-member",rows:a}),e[10]=r,e[11]=c,e[12]=n,e[13]=o,e[14]=a,e[15]=b):b=e[15];let v;return e[16]!==p||e[17]!==u||e[18]!==b?(v=(0,l.jsx)(et,{action:p,heading:u,testId:"org-team-members",children:b}),e[16]=p,e[17]=u,e[18]=b,e[19]=v):v=e[19],v},"ll"),nr=m(t=>{let e=(0,H.c)(19),{onConfirmDeleteRole:r,onDialog:c,roleColumns:h,roles:i}=t,o=Q(),a;e[0]!==c?(a=m(()=>{c({kind:"role-create"})},"i"),e[0]=c,e[1]=a):a=e[1];let n;e[2]!==o?(n=o("New role"),e[2]=o,e[3]=n):n=e[3];let d;e[4]!==a||e[5]!==n?(d=(0,l.jsx)(L,{"data-testid":"org-open-create-role",onClick:a,size:"xs",type:"button",variant:"outline",children:n}),e[4]=a,e[5]=n,e[6]=d):d=e[6];let s;e[7]!==o?(s=o("Roles"),e[7]=o,e[8]=s):s=e[8];let p;e[9]!==r||e[10]!==c||e[11]!==h||e[12]!==i||e[13]!==o?(p=i.length===0?(0,l.jsx)("div",{className:"p-3",children:(0,l.jsx)(be,{testId:"org-roles-empty",title:o("No custom roles.")})}):(0,l.jsx)(tt,{columns:h,rowActions:m(b=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L,{"data-testid":`org-role-edit-${D(b.id)}`,onClick:m(()=>{c({kind:"role-edit",role:b})},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Edit")}),(0,l.jsx)(L,{"data-testid":`org-role-delete-${D(b.id)}`,onClick:m(()=>{r(D(b.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Delete")})]}),"rowActions"),rowPrefix:"org-role",rows:i}),e[9]=r,e[10]=c,e[11]=h,e[12]=i,e[13]=o,e[14]=p):p=e[14];let u;return e[15]!==d||e[16]!==s||e[17]!==p?(u=(0,l.jsx)(et,{action:d,heading:s,testId:"org-roles",children:p}),e[15]=d,e[16]=s,e[17]=p,e[18]=u):u=e[18],u},"ol"),Ut=200,ir=m(t=>{let e=(0,H.c)(217),{organizationId:r,rolesEnabled:c,teamsEnabled:h}=t,i=oe(),o=Q(),[a,n]=(0,E.useState)(null),[d,s]=(0,E.useState)(null),[p,u]=(0,E.useState)(!1),[b,v]=(0,E.useState)(null),[g,f]=jt(r),z;e[0]!==g||e[1]!==r?(z=["lunora-auth-org-members",r,g],e[0]=g,e[1]=r,e[2]=z):z=e[2];let y;e[3]!==i||e[4]!==g||e[5]!==r?(y=m(()=>i.listAuthOrgMembers({limit:Ut,offset:g,organizationId:r}),"v"),e[3]=i,e[4]=g,e[5]=r,e[6]=y):y=e[6];let C=ge(z,y),x;e[7]!==r?(x=["lunora-auth-org-invitations",r],e[7]=r,e[8]=x):x=e[8];let w;e[9]!==i||e[10]!==r?(w=m(()=>i.listAuthOrgInvitations({limit:200,organizationId:r}),"I"),e[9]=i,e[10]=r,e[11]=w):w=e[11];let I=ge(x,w),k;e[12]!==r?(k=["lunora-auth-org-teams",r],e[12]=r,e[13]=k):k=e[13];let S;e[14]!==i||e[15]!==r?(S=m(()=>i.listAuthOrgTeams({limit:200,organizationId:r}),"k"),e[14]=i,e[15]=r,e[16]=S):S=e[16];let _;e[17]!==h?(_={enabled:h},e[17]=h,e[18]=_):_=e[18];let A=ge(k,S,_),O;e[19]!==r?(O=["lunora-auth-org-roles",r],e[19]=r,e[20]=O):O=e[20];let T;e[21]!==i||e[22]!==r?(T=m(()=>i.listAuthOrgRoles({limit:200,organizationId:r}),"_"),e[21]=i,e[22]=r,e[23]=T):T=e[23];let R;e[24]!==c?(R={enabled:c},e[24]=c,e[25]=R):R=e[25];let F=ge(O,T,R),Z;e[26]!==d?(Z=["lunora-auth-org-team-members",d],e[26]=d,e[27]=Z):Z=e[27];let B;e[28]!==i||e[29]!==d?(B=m(()=>i.listAuthOrgTeamMembers({limit:200,teamId:d??""}),"B"),e[28]=i,e[29]=d,e[30]=B):B=e[30];let K=d!==null,J;e[31]!==K?(J={enabled:K},e[31]=K,e[32]=J):J=e[32];let j=ge(Z,B,J),U;e[33]!==C.data?.rows?(U=C.data?.rows??[],e[33]=C.data?.rows,e[34]=U):U=e[34];let P=U,Y;e[35]!==I.data?.rows?(Y=I.data?.rows??[],e[35]=I.data?.rows,e[36]=Y):Y=e[36];let M=Y,$;e[37]!==A.data?.rows?($=A.data?.rows??[],e[37]=A.data?.rows,e[38]=$):$=e[38];let q=$,V;e[39]!==F.data?.rows?(V=F.data?.rows??[],e[39]=F.data?.rows,e[40]=V):V=e[40];let te=V,le;e[41]!==d||e[42]!==j.data?.rows?(le=d===null?[]:j.data?.rows??[],e[41]=d,e[42]=j.data?.rows,e[43]=le):le=e[43];let re=le,ee=C.error??I.error??A.error??F.error??j.error,ae;if(e[44]!==I||e[45]!==C||e[46]!==c||e[47]!==F||e[48]!==d||e[49]!==j||e[50]!==h||e[51]!==A){let G=m(()=>{let se=[C.poll(),I.poll()];return h&&se.push(A.poll()),c&&se.push(F.poll()),d!==null&&se.push(j.poll()),Mt(se)},"V");ae=m(()=>{zt(G())},"ie"),e[44]=I,e[45]=C,e[46]=c,e[47]=F,e[48]=d,e[49]=j,e[50]=h,e[51]=A,e[52]=ae}else ae=e[52];let N=ae,rt;e[53]!==C?(rt=m(()=>C.poll(),"tt"),e[53]=C,e[54]=rt):rt=e[54],he(rt,!0);let ot;e[55]!==I?(ot=m(()=>I.poll(),"lt"),e[55]=I,e[56]=ot):ot=e[56],he(ot,!0);let lt;e[57]!==A?(lt=m(()=>A.poll(),"ot"),e[57]=A,e[58]=lt):lt=e[58],he(lt,h);let at;e[59]!==F?(at=m(()=>F.poll(),"it"),e[59]=F,e[60]=at):at=e[60],he(at,c);let nt;e[61]!==j?(nt=m(()=>j.poll(),"rt"),e[61]=j,e[62]=nt):nt=e[62],he(nt,d!==null);let it;e[63]===Symbol.for("react.memo_cache_sentinel")?(it=m(()=>{n(null)},"st"),e[63]=it):it=e[63];let ne=it,st;e[64]!==N?(st=m(G=>{zt((async()=>{u(!0),v(null);try{await G(),N(),u(!1)}catch(se){v(Rt(se)),u(!1)}})())},"nt"),e[64]=N,e[65]=st):st=e[65];let ie=st,mt;e[66]!==i||e[67]!==o?(mt=m(G=>{let se=D(G.id);n({action:m(async()=>{await i.removeAuthOrgTeam({teamId:se}),s(Tt=>Tt===se?null:Tt)},"action"),kind:"confirm",message:o("Delete this team and its memberships? This cannot be undone."),testId:"org-team-delete",title:o("Delete team")})},"at"),e[66]=i,e[67]=o,e[68]=mt):mt=e[68];let pt=mt,pe;e[69]!==o?(pe=o("userId"),e[69]=o,e[70]=pe):pe=e[70];let fe;e[71]!==pe?(fe={head:pe,render:sr},e[71]=pe,e[72]=fe):fe=e[72];let ve;e[73]!==o?(ve=o("role"),e[73]=o,e[74]=ve):ve=e[74];let ye;e[75]!==ve?(ye={head:ve,render:mr},e[75]=ve,e[76]=ye):ye=e[76];let dt;e[77]!==fe||e[78]!==ye?(dt=[fe,ye],e[77]=fe,e[78]=ye,e[79]=dt):dt=e[79];let ft=dt,Ce;e[80]!==o?(Ce=o("email"),e[80]=o,e[81]=Ce):Ce=e[81];let Ie;e[82]!==Ce?(Ie={head:Ce,render:dr},e[82]=Ce,e[83]=Ie):Ie=e[83];let xe;e[84]!==o?(xe=o("role"),e[84]=o,e[85]=xe):xe=e[85];let we;e[86]!==xe?(we={head:xe,render:cr},e[86]=xe,e[87]=we):we=e[87];let ze;e[88]!==o?(ze=o("status"),e[88]=o,e[89]=ze):ze=e[89];let ke;e[90]!==ze?(ke={head:ze,render:ur},e[90]=ze,e[91]=ke):ke=e[91];let ct;e[92]!==Ie||e[93]!==we||e[94]!==ke?(ct=[Ie,we,ke],e[92]=Ie,e[93]=we,e[94]=ke,e[95]=ct):ct=e[95];let vt=ct,Se;e[96]!==o?(Se=o("id"),e[96]=o,e[97]=Se):Se=e[97];let Ne;e[98]!==Se?(Ne={className:"font-mono text-xs",head:Se,render:gr},e[98]=Se,e[99]=Ne):Ne=e[99];let Ae;e[100]!==o?(Ae=o("name"),e[100]=o,e[101]=Ae):Ae=e[101];let De;e[102]!==Ae?(De={head:Ae,render:hr},e[102]=Ae,e[103]=De):De=e[103];let ut;e[104]!==Ne||e[105]!==De?(ut=[Ne,De],e[104]=Ne,e[105]=De,e[106]=ut):ut=e[106];let yt=ut,Oe;e[107]!==o?(Oe=o("userId"),e[107]=o,e[108]=Oe):Oe=e[108];let gt;e[109]!==Oe?(gt=[{head:Oe,render:br}],e[109]=Oe,e[110]=gt):gt=e[110];let Ct=gt,_e;e[111]!==o?(_e=o("role"),e[111]=o,e[112]=_e):_e=e[112];let Te;e[113]!==_e?(Te={head:_e,render:pr},e[113]=_e,e[114]=Te):Te=e[114];let Re;e[115]!==o?(Re=o("Permission"),e[115]=o,e[116]=Re):Re=e[116];let $e;e[117]!==Re?($e={className:"font-mono text-xs whitespace-pre-wrap",head:Re,render:fr},e[117]=Re,e[118]=$e):$e=e[118];let ht;e[119]!==Te||e[120]!==$e?(ht=[Te,$e],e[119]=Te,e[120]=$e,e[121]=ht):ht=e[121];let It=ht,Me;e[122]!==ee?(Me=ee!==null&&(0,l.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-detail-error",role:"alert",children:ee}),e[122]=ee,e[123]=Me):Me=e[123];let Fe;e[124]!==b?(Fe=b!==null&&(0,l.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-action-error",role:"alert",children:b}),e[124]=b,e[125]=Fe):Fe=e[125];let je;e[126]!==i||e[127]!==ie?(je=m(G=>{ie(()=>i.removeAuthOrgMember({memberId:G}))},"Me"),e[126]=i,e[127]=ie,e[128]=je):je=e[128];let Ee;e[129]!==p||e[130]!==ft||e[131]!==P||e[132]!==je?(Ee=(0,l.jsx)(or,{actionBusy:p,memberColumns:ft,members:P,onDialog:n,onRemoveMember:je}),e[129]=p,e[130]=ft,e[131]=P,e[132]=je,e[133]=Ee):Ee=e[133];let xt=C.data?.total,Le;e[134]!==P.length||e[135]!==g||e[136]!==f||e[137]!==xt?(Le=(0,l.jsx)(_t,{count:P.length,offset:g,onOffsetChange:f,pageSize:Ut,prefix:"org-members",total:xt}),e[134]=P.length,e[135]=g,e[136]=f,e[137]=xt,e[138]=Le):Le=e[138];let Pe;e[139]!==p||e[140]!==i||e[141]!==vt||e[142]!==M||e[143]!==ie||e[144]!==o?(Pe=M.length>0&&(0,l.jsx)(et,{heading:o("Invitations"),testId:"org-invitations",children:(0,l.jsx)(tt,{columns:vt,rowActions:m(G=>(0,l.jsx)(L,{"data-testid":`org-cancel-invitation-${D(G.id)}`,disabled:p,onClick:m(()=>{ie(()=>i.cancelAuthOrgInvitation({invitationId:D(G.id)}))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Cancel")}),"rowActions"),rowPrefix:"org-invitation",rows:M})}),e[139]=p,e[140]=i,e[141]=vt,e[142]=M,e[143]=ie,e[144]=o,e[145]=Pe):Pe=e[145];let Be;e[146]!==pt||e[147]!==d||e[148]!==yt||e[149]!==q||e[150]!==h?(Be=h&&(0,l.jsx)(lr,{onConfirmDeleteTeam:pt,onDialog:n,onSelectTeam:s,selectedTeam:d,teamColumns:yt,teams:q}),e[146]=pt,e[147]=d,e[148]=yt,e[149]=q,e[150]=h,e[151]=Be):Be=e[151];let Je;e[152]!==p||e[153]!==i||e[154]!==ie||e[155]!==d||e[156]!==Ct||e[157]!==re||e[158]!==h?(Je=h&&d!==null&&(0,l.jsx)(ar,{actionBusy:p,onDialog:n,onRemoveTeamMember:m(G=>{ie(()=>i.removeAuthOrgTeamMember({teamMemberId:G}))},"onRemoveTeamMember"),selectedTeam:d,teamMemberColumns:Ct,teamMembers:re}),e[152]=p,e[153]=i,e[154]=ie,e[155]=d,e[156]=Ct,e[157]=re,e[158]=h,e[159]=Je):Je=e[159];let Ue;e[160]!==i||e[161]!==It||e[162]!==te||e[163]!==c||e[164]!==o?(Ue=c&&(0,l.jsx)(nr,{onConfirmDeleteRole:m(G=>{n({action:m(()=>i.deleteAuthOrgRole({roleId:G}),"action"),kind:"confirm",message:o("Delete this custom role? Members keeping it will lose its grants."),testId:"org-role-delete",title:o("Delete role")})},"onConfirmDeleteRole"),onDialog:n,roleColumns:It,roles:te}),e[160]=i,e[161]=It,e[162]=te,e[163]=c,e[164]=o,e[165]=Ue):Ue=e[165];let He;e[166]!==a?.kind||e[167]!==r||e[168]!==N?(He=a?.kind==="add-member"&&(0,l.jsx)(Xt,{onClose:ne,onDone:N,organizationId:r}),e[166]=a?.kind,e[167]=r,e[168]=N,e[169]=He):He=e[169];let Ke;e[170]!==a?.kind||e[171]!==r||e[172]!==N?(Ke=a?.kind==="invite-member"&&(0,l.jsx)(Vt,{onClose:ne,onDone:N,organizationId:r}),e[170]=a?.kind,e[171]=r,e[172]=N,e[173]=Ke):Ke=e[173];let Qe;e[174]!==a||e[175]!==N?(Qe=a?.kind==="member-role"&&(0,l.jsx)(er,{member:a.member,onClose:ne,onDone:N}),e[174]=a,e[175]=N,e[176]=Qe):Qe=e[176];let Ze;e[177]!==a?.kind||e[178]!==r||e[179]!==N?(Ze=a?.kind==="team-create"&&(0,l.jsx)(Bt,{mode:"create",onClose:ne,onDone:N,organizationId:r}),e[177]=a?.kind,e[178]=r,e[179]=N,e[180]=Ze):Ze=e[180];let Ye;e[181]!==a||e[182]!==r||e[183]!==N?(Ye=a?.kind==="team-rename"&&(0,l.jsx)(Bt,{mode:"edit",onClose:ne,onDone:N,organizationId:r,team:a.team}),e[181]=a,e[182]=r,e[183]=N,e[184]=Ye):Ye=e[184];let qe;e[185]!==a||e[186]!==N?(qe=a?.kind==="team-add-member"&&(0,l.jsx)(tr,{onClose:ne,onDone:N,teamId:a.teamId}),e[185]=a,e[186]=N,e[187]=qe):qe=e[187];let Ge;e[188]!==a?.kind||e[189]!==r||e[190]!==N?(Ge=a?.kind==="role-create"&&(0,l.jsx)(Jt,{mode:"create",onClose:ne,onDone:N,organizationId:r}),e[188]=a?.kind,e[189]=r,e[190]=N,e[191]=Ge):Ge=e[191];let We;e[192]!==a||e[193]!==r||e[194]!==N?(We=a?.kind==="role-edit"&&(0,l.jsx)(Jt,{mode:"edit",onClose:ne,onDone:N,organizationId:r,role:a.role}),e[192]=a,e[193]=r,e[194]=N,e[195]=We):We=e[195];let Xe;e[196]!==a||e[197]!==N?(Xe=a?.kind==="confirm"&&(0,l.jsx)(Zt,{action:a.action,message:a.message,onClose:ne,onDone:N,testId:a.testId,title:a.title}),e[196]=a,e[197]=N,e[198]=Xe):Xe=e[198];let bt;return e[199]!==Me||e[200]!==Fe||e[201]!==Ee||e[202]!==Le||e[203]!==Pe||e[204]!==Be||e[205]!==Je||e[206]!==Ue||e[207]!==He||e[208]!==Ke||e[209]!==Qe||e[210]!==Ze||e[211]!==Ye||e[212]!==qe||e[213]!==Ge||e[214]!==We||e[215]!==Xe?(bt=(0,l.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"org-detail",children:[Me,Fe,Ee,Le,Pe,Be,Je,Ue,He,Ke,Qe,Ze,Ye,qe,Ge,We,Xe]}),e[199]=Me,e[200]=Fe,e[201]=Ee,e[202]=Le,e[203]=Pe,e[204]=Be,e[205]=Je,e[206]=Ue,e[207]=He,e[208]=Ke,e[209]=Qe,e[210]=Ze,e[211]=Ye,e[212]=qe,e[213]=Ge,e[214]=We,e[215]=Xe,e[216]=bt):bt=e[216],bt},"il");function sr(t){return(0,l.jsx)("span",{className:"font-mono text-xs",children:D(t.userId)})}m(sr,"rl");function mr(t){return D(t.role)}m(mr,"sl");function dr(t){return D(t.email)}m(dr,"nl");function cr(t){return D(t.role)}m(cr,"al");function ur(t){return D(t.status)}m(ur,"ml");function gr(t){return D(t.id)}m(gr,"dl");function hr(t){return D(t.name)}m(hr,"cl");function br(t){return(0,l.jsx)("span",{className:"font-mono text-xs",children:D(t.userId)})}m(br,"fl");function pr(t){return D(t.role)}m(pr,"ul");function fr(t){return D(t.permission)}m(fr,"gl");var Ht=100,$r=m(()=>{let t=(0,H.c)(69),e=oe(),r=Q(),{config:c,ready:h}=Et(),i=c.capabilities.organization,[o,a]=(0,E.useState)(null),[n,d]=(0,E.useState)(null),[s,p]=(0,E.useState)(0),u;t[0]!==s?(u=["lunora-auth-orgs",s],t[0]=s,t[1]=u):u=t[1];let b;t[2]!==e||t[3]!==s?(b=m(()=>e.listAuthOrganizations({limit:Ht,offset:s}),"g"),t[2]=e,t[3]=s,t[4]=b):b=t[4];let v;t[5]!==i?(v={enabled:i},t[5]=i,t[6]=v):v=t[6];let g=ge(u,b,v),f=g.data?.rows??null,z;t[7]!==g?(z=m(()=>g.poll(),"S"),t[7]=g,t[8]=z):z=t[8],he(z,i);let y;t[9]===Symbol.for("react.memo_cache_sentinel")?(y=m(()=>{d(null)},"v"),t[9]=y):y=t[9];let C=y,x;t[10]!==g?(x=m(()=>{g.refetch()},"x"),t[10]=g,t[11]=x):x=t[11];let w=x,I;t[12]===Symbol.for("react.memo_cache_sentinel")?(I=m(M=>{a(M)},"C"),t[12]=I):I=t[12];let k=I;if(h&&!i){let M;t[13]!==r?(M=r("Enable the organization() plugin in your auth config to manage organizations here."),t[13]=r,t[14]=M):M=t[14];let $;t[15]!==r?($=r("Organizations are not enabled."),t[15]=r,t[16]=$):$=t[16];let q;return t[17]!==M||t[18]!==$?(q=(0,l.jsx)(be,{description:M,testId:"org-disabled",title:$}),t[17]=M,t[18]=$,t[19]=q):q=t[19],q}let S;t[20]!==r?(S=r("Organizations"),t[20]=r,t[21]=S):S=t[21];let _;t[22]!==S?(_=(0,l.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:S}),t[22]=S,t[23]=_):_=t[23];let A;t[24]===Symbol.for("react.memo_cache_sentinel")?(A=m(()=>{d({kind:"create"})},"z"),t[24]=A):A=t[24];let O;t[25]!==r?(O=r("New organization"),t[25]=r,t[26]=O):O=t[26];let T;t[27]!==O?(T=(0,l.jsx)(L,{"data-testid":"org-new",onClick:A,size:"sm",type:"button",children:O}),t[27]=O,t[28]=T):T=t[28];let R;t[29]!==T||t[30]!==_?(R=(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[_,T]}),t[29]=T,t[30]=_,t[31]=R):R=t[31];let F;t[32]!==g.error?(F=g.error!==null&&(0,l.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-error",role:"alert",children:g.error}),t[32]=g.error,t[33]=F):F=t[33];let Z;t[34]!==f||t[35]!==r?(Z=f!==null&&f.length===0&&(0,l.jsx)(be,{testId:"org-empty",title:r("No organizations.")}),t[34]=f,t[35]=r,t[36]=Z):Z=t[36];let B;t[37]!==f||t[38]!==o||t[39]!==r?(B=f!==null&&f.length>0&&(0,l.jsx)(kt,{className:"overflow-hidden py-0",children:(0,l.jsx)(St,{className:"px-0",children:(0,l.jsxs)(Nt,{"data-testid":"org-table",children:[(0,l.jsx)(At,{children:(0,l.jsxs)(Ve,{children:[(0,l.jsx)(de,{children:r("id")}),(0,l.jsx)(de,{children:r("name")}),(0,l.jsx)(de,{children:r("slug")}),(0,l.jsx)(de,{children:r("created")}),(0,l.jsx)(de,{"aria-label":r("Actions")})]})}),(0,l.jsx)(Dt,{children:f.map(M=>{let $=D(M.id);return(0,l.jsxs)(Ve,{"data-testid":`org-row-${$}`,children:[(0,l.jsx)(ce,{className:"font-mono text-xs",children:$}),(0,l.jsx)(ce,{children:D(M.name)}),(0,l.jsx)(ce,{children:D(M.slug)}),(0,l.jsx)(ce,{className:"text-muted-foreground tabular-nums",children:$t(M.createdAt)}),(0,l.jsx)(ce,{children:(0,l.jsxs)("div",{className:"flex justify-end gap-1",children:[(0,l.jsx)(L,{"aria-pressed":o===$,"data-testid":`org-select-${$}`,onClick:m(()=>{k($)},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Manage")}),(0,l.jsx)(L,{"data-testid":`org-edit-${$}`,onClick:m(()=>{d({kind:"edit",org:M})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Edit")}),(0,l.jsx)(L,{"data-testid":`org-delete-${$}`,onClick:m(()=>{d({kind:"delete",org:M})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Delete")})]})})]},$)})})]})})}),t[37]=f,t[38]=o,t[39]=r,t[40]=B):B=t[40];let K;t[41]!==s||t[42]!==f||t[43]!==g.data?.total?(K=f!==null&&(0,l.jsx)(_t,{count:f.length,offset:s,onOffsetChange:p,pageSize:Ht,prefix:"org",total:g.data?.total}),t[41]=s,t[42]=f,t[43]=g.data?.total,t[44]=K):K=t[44];let J;t[45]!==c.organization||t[46]!==o?(J=o!==null&&(0,l.jsx)(ir,{organizationId:o,rolesEnabled:c.organization.roles,teamsEnabled:c.organization.teams}),t[45]=c.organization,t[46]=o,t[47]=J):J=t[47];let j;t[48]!==n?.kind||t[49]!==w?(j=n?.kind==="create"&&(0,l.jsx)(Pt,{mode:"create",onClose:C,onDone:w}),t[48]=n?.kind,t[49]=w,t[50]=j):j=t[50];let U;t[51]!==n||t[52]!==w?(U=n?.kind==="edit"&&(0,l.jsx)(Pt,{mode:"edit",onClose:C,onDone:w,org:n.org}),t[51]=n,t[52]=w,t[53]=U):U=t[53];let P;t[54]!==e||t[55]!==n||t[56]!==w||t[57]!==r?(P=n?.kind==="delete"&&(0,l.jsx)(Zt,{action:m(async()=>{let M=D(n.org.id);await e.deleteAuthOrganization({organizationId:M}),a($=>$===M?null:$)},"action"),message:r("Delete this organization? Its members, invitations, teams, and custom roles are removed. This cannot be undone."),onClose:C,onDone:w,testId:"org-delete",title:r("Delete organization")}),t[54]=e,t[55]=n,t[56]=w,t[57]=r,t[58]=P):P=t[58];let Y;return t[59]!==R||t[60]!==F||t[61]!==Z||t[62]!==B||t[63]!==K||t[64]!==J||t[65]!==j||t[66]!==U||t[67]!==P?(Y=(0,l.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-organizations",children:[R,F,Z,B,K,J,j,U,P]}),t[59]=R,t[60]=F,t[61]=Z,t[62]=B,t[63]=K,t[64]=J,t[65]=j,t[66]=U,t[67]=P,t[68]=Y):Y=t[68],Y},"Ml");export{$r as default};
@@ -1 +1 @@
1
- import{b as Ke}from"./chunk-R6NJ4ER6.js";import{a as Ie,b as De,c as Oe}from"./chunk-AFLNQEZ5.js";import{a as Ee}from"./chunk-W5BTAOHO.js";import"./chunk-4KPATTV6.js";import{i as we}from"./chunk-2D4WBSDO.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as ke}from"./chunk-CBTPJPCZ.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{b as _e}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{a as je}from"./chunk-JZN3MNJX.js";import"./chunk-EYSF4DHD.js";import{a as Se,b as Te,c as Ce,d as ie,e as M,f as W}from"./chunk-ZJIYJZ6F.js";import"./chunk-ELPLRD4S.js";import"./chunk-NFI2TNKU.js";import"./chunk-EOFWXI3T.js";import{a as ve}from"./chunk-LYVYUTQY.js";import{c as ye}from"./chunk-LRUYEVHH.js";import{a as le,e as oe}from"./chunk-XV2XEUUB.js";import{n as Ae}from"./chunk-QFN62JQJ.js";import"./chunk-ZPQBVYNN.js";import{B as xe,j as pe,s as he,w as fe}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as ze}from"./chunk-A6TVTNKO.js";import{a as Ue,b as Pe}from"./chunk-ADABTCDI.js";import{a as b,d as Ne}from"./chunk-5PEAXTYQ.js";var ce=Ne(ze(),1);var I=Ne(Ue(),1);var a=Ne(Pe(),1);var Le=["disabled","schema","schema_and_log","schema_and_log_and_data"],$e={describeTables:"schema",readAdvisors:"schema",readLogs:"schema_and_log",readPolicies:"schema",runSql:"schema_and_log_and_data"},Be=864e5,qe=b(()=>{let t=(0,ce.c)(67),e=Ae(),r=xe(),n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],t[0]=n):n=t[0];let g;t[1]!==e?(g={owner:e,tokens:n},t[1]=e,t[2]=g):g=t[2];let[h,N]=(0,I.useState)(g),x=h.owner===e?h.tokens:[],[c,m]=(0,I.useState)(null),[p,o]=(0,I.useState)(null);p!==null&&p.owner!==e&&o(null);let d=p?.owner===e?p.token:null,[l,i]=(0,I.useState)(""),[s,u]=(0,I.useState)(""),[_,k]=(0,I.useState)(null),D=_===e,v=(0,I.useRef)(0),w=(0,I.useRef)(e),O,j;t[3]!==e?(O=b(()=>{w.current=e},"D"),j=[e],t[3]=e,t[4]=O,t[5]=j):(O=t[4],j=t[5]),(0,I.useEffect)(O,j);let K;t[6]!==e?(K=b(async()=>{if(w.current!==e)return;v.current=v.current+1;let f=v.current;try{let E=await e.listAdminTokens();f===v.current&&(N({owner:e,tokens:E}),m(null))}catch(E){let de=E;f===v.current&&m(pe(de))}},"L"),t[6]=e,t[7]=K):K=t[7];let y=K,L,R;t[8]!==y?(L=b(()=>{he(y())},"O"),R=[y],t[8]=y,t[9]=L,t[10]=R):(L=t[9],R=t[10]),(0,I.useEffect)(L,R);let U;t[11]!==e||t[12]!==d||t[13]!==D||t[14]!==s||t[15]!==l||t[16]!==y?(U=b(f=>{if(f.preventDefault(),D||d!==null)return;k(e);let E=e,de=s===""?void 0:Date.now()+Number(s)*Be;he((async()=>{try{let se=await E.createAdminToken({expiresAt:de,name:l.trim()});w.current===E&&(o({owner:E,token:se}),i(""),u(""),await y())}catch(se){m(pe(se))}k(se=>se===E?null:se)})())},"K"),t[11]=e,t[12]=d,t[13]=D,t[14]=s,t[15]=l,t[16]=y,t[17]=U):U=t[17];let B=U,H=b(f=>{he((async()=>{try{await e.revokeAdminToken(f),o(E=>E?.token.name===f?null:E),await y()}catch(E){let de=E;await y(),w.current===e&&m(pe(de))}})())},"q"),q=le,G="py-0",J="set-admin-tokens",S;t[18]!==r?(S=r("Admin tokens"),t[18]=r,t[19]=S):S=t[19];let T;t[20]!==S?(T=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:S})}),t[20]=S,t[21]=T):T=t[21];let F=oe,Q="flex flex-col gap-3 py-3",C;t[22]!==r?(C=r("Named tokens use the admin API but cannot manage tokens or open admin WebSockets. A revoked token is refused within 30 seconds."),t[22]=r,t[23]=C):C=t[23];let z;t[24]!==C?(z=(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:C}),t[24]=C,t[25]=z):z=t[25];let V;t[26]!==c?(V=c!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"set-admin-tokens-error",role:"alert",children:c}),t[26]=c,t[27]=V):V=t[27];let P;t[28]!==d||t[29]!==r?(P=d!==null&&(0,a.jsxs)("div",{className:"rounded-md border border-border p-3 text-xs","data-testid":"set-admin-token-created",role:"status",children:[(0,a.jsx)("p",{className:"pb-1 text-muted-foreground",children:r("Copy this token now. It is not shown again.")}),(0,a.jsx)("code",{className:"font-mono break-all select-all",children:d.token}),(0,a.jsx)("div",{className:"pt-2",children:(0,a.jsx)(ke,{"data-testid":"set-admin-token-dismiss",onClick:b(()=>{o(null)},"onClick"),size:"xs",variant:"outline",children:r("Dismiss")})})]}),t[28]=d,t[29]=r,t[30]=P):P=t[30];let A;t[31]!==r?(A=r("Token name"),t[31]=r,t[32]=A):A=t[32];let $;t[33]===Symbol.for("react.memo_cache_sentinel")?($=b(f=>{i(f.target.value)},"B"),t[33]=$):$=t[33];let X;t[34]!==l||t[35]!==A?(X=(0,a.jsx)(we,{"aria-label":A,className:"w-48","data-testid":"set-admin-token-name",onChange:$,pattern:"[a-z0-9][a-z0-9_\\-]{0,63}",placeholder:"ci-deploy",required:!0,value:l}),t[34]=l,t[35]=A,t[36]=X):X=t[36];let Y;t[37]!==r?(Y=r("Expires in days (optional)"),t[37]=r,t[38]=Y):Y=t[38];let me;t[39]===Symbol.for("react.memo_cache_sentinel")?(me=b(f=>{u(f.target.value)},"de"),t[39]=me):me=t[39];let Z;t[40]!==r?(Z=r("Expires in days (optional)"),t[40]=r,t[41]=Z):Z=t[41];let ee;t[42]!==s||t[43]!==Y||t[44]!==Z?(ee=(0,a.jsx)(we,{"aria-label":Y,className:"w-40",min:1,onChange:me,placeholder:Z,type:"number",value:s}),t[42]=s,t[43]=Y,t[44]=Z,t[45]=ee):ee=t[45];let be=D||d!==null,te;t[46]!==r?(te=r("Create token"),t[46]=r,t[47]=te):te=t[47];let ae;t[48]!==be||t[49]!==te?(ae=(0,a.jsx)(ke,{"data-testid":"set-admin-token-create",disabled:be,size:"sm",type:"submit",children:te}),t[48]=be,t[49]=te,t[50]=ae):ae=t[50];let ne;t[51]!==B||t[52]!==X||t[53]!==ee||t[54]!==ae?(ne=(0,a.jsxs)("form",{className:"flex flex-wrap items-end gap-2",onSubmit:B,children:[X,ee,ae]}),t[51]=B,t[52]=X,t[53]=ee,t[54]=ae,t[55]=ne):ne=t[55];let ge=x.length>0&&(0,a.jsxs)(Se,{"data-testid":"set-admin-tokens-table",children:[(0,a.jsx)(Te,{children:(0,a.jsxs)(ie,{children:[(0,a.jsx)(M,{children:r("name")}),(0,a.jsx)(M,{children:r("Created")}),(0,a.jsx)(M,{children:r("Last used")}),(0,a.jsx)(M,{children:r("Expires")}),(0,a.jsx)(M,{})]})}),(0,a.jsx)(Ce,{children:x.map(f=>(0,a.jsxs)(ie,{"data-testid":"set-admin-token-row",children:[(0,a.jsxs)(W,{className:"font-mono text-xs",children:[f.name,f.revoked===!0&&(0,a.jsx)("span",{className:"pl-2 text-destructive",children:r("Revoked")})]}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.createdAt)}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.lastUsedAt,"\u2014")}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.expiresAt,r("Never"))}),(0,a.jsx)(W,{children:(0,a.jsx)(Ee,{onConfirm:b(()=>{H(f.name)},"onConfirm"),testId:`set-admin-token-revoke-${f.name}`,children:r("Revoke")})})]},f.name))})]}),re;t[56]!==F||t[57]!==z||t[58]!==V||t[59]!==P||t[60]!==ne||t[61]!==ge?(re=(0,a.jsxs)(F,{className:Q,children:[z,V,P,ne,ge]}),t[56]=F,t[57]=z,t[58]=V,t[59]=P,t[60]=ne,t[61]=ge,t[62]=re):re=t[62];let ue;return t[63]!==q||t[64]!==T||t[65]!==re?(ue=(0,a.jsxs)(q,{className:G,"data-testid":J,children:[T,re]}),t[63]=q,t[64]=T,t[65]=re,t[66]=ue):ue=t[66],ue},"Fe"),Fe={binding:"outline",secret:"destructive",var:"secondary"},Ve=b((t,e)=>{if(t===void 0)return[];let r=[];return t.workerUrl!==void 0&&r.push({label:e("URL"),value:t.workerUrl}),t.environment!==void 0&&r.push({label:e("Environment"),value:t.environment}),t.deploymentId!==void 0&&r.push({label:e("Deployment"),value:t.deploymentId}),t.versionTag!==void 0&&r.push({label:e("Version"),value:t.versionTag}),r},"Pe"),Me={disabled:"The assistant is off. Nothing about this deployment is sent to a model.",schema:"Table and column names.",schema_and_log:"Table and column names, plus recent log lines.",schema_and_log_and_data:"Table and column names, log lines, and rows read with SELECT."},We=b(t=>{let e=[];for(let[r,n]of Object.entries($e))n===t&&e.push(r);return e},"qe"),He=b(()=>{let t=(0,ce.c)(29),e=xe(),r,n;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={},n={shardKey:""},t[0]=r,t[1]=n):(r=t[0],n=t[1]);let{data:g}=ye(ve.aiAvailable,r,n),h=g?.level,N;t[2]!==h?(N=h===void 0?-1:Le.indexOf(h),t[2]=h,t[3]=N):N=t[3];let x=N,c;t[4]!==e?(c=e("AI assistant data sharing"),t[4]=e,t[5]=c):c=t[5];let m;t[6]!==c?(m=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:c}),t[6]=c,t[7]=m):m=t[7];let p;t[8]!==h?(p=h!==void 0&&(0,a.jsx)(_e,{"data-testid":"set-ai-level",variant:h==="disabled"?"outline":"secondary",children:h}),t[8]=h,t[9]=p):p=t[9];let o;t[10]!==m||t[11]!==p?(o=(0,a.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[m,p]}),t[10]=m,t[11]=p,t[12]=o):o=t[12];let d;t[13]!==x||t[14]!==h||t[15]!==e?(d=Le.map((k,D)=>{let v=x>=D,w=We(k);return(0,a.jsxs)("li",{className:v?"flex flex-col gap-0.5":"flex flex-col gap-0.5 opacity-50","data-granted":String(v),"data-testid":`set-ai-tier-${k}`,children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"font-mono text-xs",children:k}),k===h&&(0,a.jsx)("span",{className:"text-[11px] text-primary",children:e("current")})]}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:e(Me[k])}),w.length>0&&(0,a.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:w.join(", ")})]},k)}),t[13]=x,t[14]=h,t[15]=e,t[16]=d):d=t[16];let l;t[17]!==d?(l=(0,a.jsx)("ul",{className:"flex flex-col gap-1.5 text-sm",children:d}),t[17]=d,t[18]=l):l=t[18];let i;t[19]!==e?(i=e("Set LUNORA_AI_OPT_IN in wrangler.jsonc and redeploy to change this. The Studio can read this level but never raise it."),t[19]=e,t[20]=i):i=t[20];let s;t[21]!==i?(s=(0,a.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"set-ai-howto",children:i}),t[21]=i,t[22]=s):s=t[22];let u;t[23]!==s||t[24]!==l?(u=(0,a.jsxs)(oe,{className:"flex flex-col gap-3 py-3",children:[l,s]}),t[23]=s,t[24]=l,t[25]=u):u=t[25];let _;return t[26]!==u||t[27]!==o?(_=(0,a.jsxs)(le,{className:"py-0","data-testid":"set-ai-sharing",children:[o,u]}),t[26]=u,t[27]=o,t[28]=_):_=t[28],_},"ze"),Re=b(t=>{let e=(0,ce.c)(18),{modifier:r,name:n,label:g}=t,h=Ie(),N;e[0]!==n?(N=b(u=>{if(!["Escape","Tab"].includes(u.key)){if(u.shiftKey){u.preventDefault();return}u.preventDefault(),De(n,u.key)}},"N"),e[0]=n,e[1]=N):N=e[1];let x=N,c=`set-shortcut-${n}`,m;e[2]!==g?(m=(0,a.jsx)("dt",{className:"text-muted-foreground",children:g}),e[2]=g,e[3]=m):m=e[3];let p;e[4]!==r?(p=(0,a.jsx)("kbd",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:r}),e[4]=r,e[5]=p):p=e[5];let o=`set-shortcut-input-${n}`,d=h[n],l;e[6]!==g||e[7]!==x||e[8]!==o||e[9]!==d?(l=(0,a.jsx)("input",{"aria-label":g,className:"h-7 w-12 rounded-md border border-border bg-background text-center font-mono text-xs uppercase outline-none focus-visible:border-ring","data-testid":o,onKeyDown:x,readOnly:!0,value:d}),e[6]=g,e[7]=x,e[8]=o,e[9]=d,e[10]=l):l=e[10];let i;e[11]!==p||e[12]!==l?(i=(0,a.jsxs)("dd",{className:"flex items-center gap-1.5",children:[p,l]}),e[11]=p,e[12]=l,e[13]=i):i=e[13];let s;return e[14]!==c||e[15]!==m||e[16]!==i?(s=(0,a.jsxs)("div",{className:"contents","data-testid":c,children:[m,i]}),e[14]=c,e[15]=m,e[16]=i,e[17]=s):s=e[17],s},"we"),ct=b(t=>{let e=(0,ce.c)(87),{initialShardKey:r}=t,n=xe(),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={},e[0]=g):g=e[0];let h=r??"",N;e[1]!==h?(N={shardKey:h},e[1]=h,e[2]=N):N=e[2];let{data:x,error:c,errorSource:m,isLoading:p}=ye(ve.getSettings,g,N),o,d,l,i,s,u,_;if(e[3]!==c||e[4]!==m||e[5]!==x?.deploy||e[6]!==x?.settings||e[7]!==n){let V=Ve(x?.deploy,n),P;e[15]!==x?.settings?(P=x?.settings??[],e[15]=x?.settings,e[16]=P):P=e[16],o=P,d="flex flex-col gap-4",l="lunora-settings";let A;e[17]!==n?(A=n("Open in Cloudflare"),e[17]=n,e[18]=A):A=e[18],e[19]!==A?(i=(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,a.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:Ke,rel:"noreferrer",target:"_blank",children:A})}),e[19]=A,e[20]=i):i=e[20];let $;e[21]!==n?($=n("View-only \u2014 values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=n,e[22]=$):$=e[22],e[23]!==$?(s=(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:$}),e[23]=$,e[24]=s):s=e[24],e[25]!==c||e[26]!==m?(u=c!==null&&(0,a.jsx)(je,{error:m,testId:"set-error"}),e[25]=c,e[26]=m,e[27]=u):u=e[27],_=V.length>0&&(0,a.jsxs)(le,{className:"py-0","data-testid":"set-deploy",children:[(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Deployment")})}),(0,a.jsx)(oe,{className:"py-3",children:(0,a.jsx)("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:V.map(Ge)})})]}),e[3]=c,e[4]=m,e[5]=x?.deploy,e[6]=x?.settings,e[7]=n,e[8]=o,e[9]=d,e[10]=l,e[11]=i,e[12]=s,e[13]=u,e[14]=_}else o=e[8],d=e[9],l=e[10],i=e[11],s=e[12],u=e[13],_=e[14];let k,D;e[28]===Symbol.for("react.memo_cache_sentinel")?(k=(0,a.jsx)(He,{}),D=(0,a.jsx)(qe,{}),e[28]=k,e[29]=D):(k=e[28],D=e[29]);let v;e[30]!==n?(v=n("Keyboard shortcuts"),e[30]=n,e[31]=v):v=e[31];let w;e[32]!==v?(w=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v}),e[32]=v,e[33]=w):w=e[33];let O;e[34]!==n?(O=n("Reset"),e[34]=n,e[35]=O):O=e[35];let j;e[36]!==O?(j=(0,a.jsx)("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"set-shortcut-reset",onClick:Oe,type:"button",children:O}),e[36]=O,e[37]=j):j=e[37];let K;e[38]!==w||e[39]!==j?(K=(0,a.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[w,j]}),e[38]=w,e[39]=j,e[40]=K):K=e[40];let y;e[41]!==n?(y=n("Command palette"),e[41]=n,e[42]=y):y=e[42];let L;e[43]!==y?(L=(0,a.jsx)(Re,{label:y,modifier:"\u2318/Ctrl",name:"palette"}),e[43]=y,e[44]=L):L=e[44];let R;e[45]!==n?(R=n("Operation console"),e[45]=n,e[46]=R):R=e[46];let U;e[47]!==R?(U=(0,a.jsx)(Re,{label:R,modifier:"Ctrl",name:"console"}),e[47]=R,e[48]=U):U=e[48];let B;e[49]!==L||e[50]!==U?(B=(0,a.jsxs)("dl",{className:"grid grid-cols-[10rem_minmax(0,1fr)] items-center gap-x-4 gap-y-2 text-sm",children:[L,U]}),e[49]=L,e[50]=U,e[51]=B):B=e[51];let H;e[52]!==n?(H=n("Stored in this browser. Focus a box and press a key to rebind it."),e[52]=n,e[53]=H):H=e[53];let q;e[54]!==H?(q=(0,a.jsx)("p",{className:"pt-3 text-xs text-muted-foreground",children:H}),e[54]=H,e[55]=q):q=e[55];let G;e[56]!==B||e[57]!==q?(G=(0,a.jsxs)(oe,{className:"py-3",children:[B,q]}),e[56]=B,e[57]=q,e[58]=G):G=e[58];let J;e[59]!==K||e[60]!==G?(J=(0,a.jsxs)(le,{className:"py-0","data-testid":"set-preferences",children:[K,G]}),e[59]=K,e[60]=G,e[61]=J):J=e[61];let S;e[62]!==n?(S=n("Environment & bindings"),e[62]=n,e[63]=S):S=e[63];let T;e[64]!==S?(T=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:S})}),e[64]=S,e[65]=T):T=e[65];let F;e[66]!==c||e[67]!==p||e[68]!==o.length||e[69]!==n?(F=c===null&&!p&&o.length===0&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:n("No environment variables or bindings.")}),e[66]=c,e[67]=p,e[68]=o.length,e[69]=n,e[70]=F):F=e[70];let Q;e[71]!==o||e[72]!==n?(Q=o.length>0&&(0,a.jsx)(oe,{className:"px-0 py-0",children:(0,a.jsxs)(Se,{"data-testid":"set-table",children:[(0,a.jsx)(Te,{children:(0,a.jsxs)(ie,{children:[(0,a.jsx)(M,{children:n("name")}),(0,a.jsx)(M,{children:n("kind")}),(0,a.jsx)(M,{children:n("value")})]})}),(0,a.jsx)(Ce,{children:o.map(Je)})]})}),e[71]=o,e[72]=n,e[73]=Q):Q=e[73];let C;e[74]!==T||e[75]!==F||e[76]!==Q?(C=(0,a.jsxs)(le,{className:"py-0",children:[T,F,Q]}),e[74]=T,e[75]=F,e[76]=Q,e[77]=C):C=e[77];let z;return e[78]!==J||e[79]!==C||e[80]!==d||e[81]!==l||e[82]!==i||e[83]!==s||e[84]!==u||e[85]!==_?(z=(0,a.jsxs)("div",{className:d,"data-testid":l,children:[i,s,u,_,k,D,J,C]}),e[78]=J,e[79]=C,e[80]=d,e[81]=l,e[82]=i,e[83]=s,e[84]=u,e[85]=_,e[86]=z):z=e[86],z},"ft");function Ge(t){return(0,a.jsxs)("div",{className:"contents","data-testid":"set-deploy-row",children:[(0,a.jsx)("dt",{className:"text-muted-foreground",children:t.label}),(0,a.jsx)("dd",{className:"truncate font-mono text-xs",title:t.value,children:t.value})]},t.label)}b(Ge,"He");function Je(t){return(0,a.jsxs)(ie,{"data-testid":"set-row",children:[(0,a.jsx)(W,{className:"font-mono text-xs font-medium",children:t.name}),(0,a.jsx)(W,{children:(0,a.jsx)(_e,{variant:Fe[t.kind],children:t.bindingType??t.kind})}),(0,a.jsx)(W,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:t.value??(0,a.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},t.name)}b(Je,"We");export{ct as SettingsPanel};
1
+ import{b as Ke}from"./chunk-R6NJ4ER6.js";import{a as Ie,b as De,c as Oe}from"./chunk-AFLNQEZ5.js";import{a as Ee}from"./chunk-UEONVTOV.js";import"./chunk-4KPATTV6.js";import{i as we}from"./chunk-Z6PYAG36.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as ke}from"./chunk-QHI77TGI.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{b as _e}from"./chunk-OOPMRFI2.js";import"./chunk-L27FKJTG.js";import{a as je}from"./chunk-PUTERXSU.js";import"./chunk-ZIY53FID.js";import{a as Se,b as Te,c as Ce,d as ie,e as M,f as W}from"./chunk-KMBE7RTC.js";import"./chunk-4YZAJTU5.js";import"./chunk-UDKKUJHY.js";import"./chunk-EOFWXI3T.js";import{a as ve}from"./chunk-LYVYUTQY.js";import{c as ye}from"./chunk-NP6H72XD.js";import{a as le,e as oe}from"./chunk-NPHGFVNE.js";import{n as Ae}from"./chunk-YESGXFAR.js";import"./chunk-ZPQBVYNN.js";import{B as xe,j as pe,s as he,w as fe}from"./chunk-CDIV23I2.js";import"./chunk-PDBW6GTJ.js";import{a as ze}from"./chunk-A6TVTNKO.js";import{a as Ue,b as Pe}from"./chunk-ADABTCDI.js";import{a as b,d as Ne}from"./chunk-5PEAXTYQ.js";var ce=Ne(ze(),1);var I=Ne(Ue(),1);var a=Ne(Pe(),1);var Le=["disabled","schema","schema_and_log","schema_and_log_and_data"],$e={describeTables:"schema",readAdvisors:"schema",readLogs:"schema_and_log",readPolicies:"schema",runSql:"schema_and_log_and_data"},Be=864e5,qe=b(()=>{let t=(0,ce.c)(67),e=Ae(),r=xe(),n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],t[0]=n):n=t[0];let g;t[1]!==e?(g={owner:e,tokens:n},t[1]=e,t[2]=g):g=t[2];let[h,N]=(0,I.useState)(g),x=h.owner===e?h.tokens:[],[c,m]=(0,I.useState)(null),[p,o]=(0,I.useState)(null);p!==null&&p.owner!==e&&o(null);let d=p?.owner===e?p.token:null,[l,i]=(0,I.useState)(""),[s,u]=(0,I.useState)(""),[_,k]=(0,I.useState)(null),D=_===e,v=(0,I.useRef)(0),w=(0,I.useRef)(e),O,j;t[3]!==e?(O=b(()=>{w.current=e},"D"),j=[e],t[3]=e,t[4]=O,t[5]=j):(O=t[4],j=t[5]),(0,I.useEffect)(O,j);let K;t[6]!==e?(K=b(async()=>{if(w.current!==e)return;v.current=v.current+1;let f=v.current;try{let E=await e.listAdminTokens();f===v.current&&(N({owner:e,tokens:E}),m(null))}catch(E){let de=E;f===v.current&&m(pe(de))}},"L"),t[6]=e,t[7]=K):K=t[7];let y=K,L,R;t[8]!==y?(L=b(()=>{he(y())},"O"),R=[y],t[8]=y,t[9]=L,t[10]=R):(L=t[9],R=t[10]),(0,I.useEffect)(L,R);let U;t[11]!==e||t[12]!==d||t[13]!==D||t[14]!==s||t[15]!==l||t[16]!==y?(U=b(f=>{if(f.preventDefault(),D||d!==null)return;k(e);let E=e,de=s===""?void 0:Date.now()+Number(s)*Be;he((async()=>{try{let se=await E.createAdminToken({expiresAt:de,name:l.trim()});w.current===E&&(o({owner:E,token:se}),i(""),u(""),await y())}catch(se){m(pe(se))}k(se=>se===E?null:se)})())},"K"),t[11]=e,t[12]=d,t[13]=D,t[14]=s,t[15]=l,t[16]=y,t[17]=U):U=t[17];let B=U,H=b(f=>{he((async()=>{try{await e.revokeAdminToken(f),o(E=>E?.token.name===f?null:E),await y()}catch(E){let de=E;await y(),w.current===e&&m(pe(de))}})())},"q"),q=le,G="py-0",J="set-admin-tokens",S;t[18]!==r?(S=r("Admin tokens"),t[18]=r,t[19]=S):S=t[19];let T;t[20]!==S?(T=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:S})}),t[20]=S,t[21]=T):T=t[21];let F=oe,Q="flex flex-col gap-3 py-3",C;t[22]!==r?(C=r("Named tokens use the admin API but cannot manage tokens or open admin WebSockets. A revoked token is refused within 30 seconds."),t[22]=r,t[23]=C):C=t[23];let z;t[24]!==C?(z=(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:C}),t[24]=C,t[25]=z):z=t[25];let V;t[26]!==c?(V=c!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"set-admin-tokens-error",role:"alert",children:c}),t[26]=c,t[27]=V):V=t[27];let P;t[28]!==d||t[29]!==r?(P=d!==null&&(0,a.jsxs)("div",{className:"rounded-md border border-border p-3 text-xs","data-testid":"set-admin-token-created",role:"status",children:[(0,a.jsx)("p",{className:"pb-1 text-muted-foreground",children:r("Copy this token now. It is not shown again.")}),(0,a.jsx)("code",{className:"font-mono break-all select-all",children:d.token}),(0,a.jsx)("div",{className:"pt-2",children:(0,a.jsx)(ke,{"data-testid":"set-admin-token-dismiss",onClick:b(()=>{o(null)},"onClick"),size:"xs",variant:"outline",children:r("Dismiss")})})]}),t[28]=d,t[29]=r,t[30]=P):P=t[30];let A;t[31]!==r?(A=r("Token name"),t[31]=r,t[32]=A):A=t[32];let $;t[33]===Symbol.for("react.memo_cache_sentinel")?($=b(f=>{i(f.target.value)},"B"),t[33]=$):$=t[33];let X;t[34]!==l||t[35]!==A?(X=(0,a.jsx)(we,{"aria-label":A,className:"w-48","data-testid":"set-admin-token-name",onChange:$,pattern:"[a-z0-9][a-z0-9_\\-]{0,63}",placeholder:"ci-deploy",required:!0,value:l}),t[34]=l,t[35]=A,t[36]=X):X=t[36];let Y;t[37]!==r?(Y=r("Expires in days (optional)"),t[37]=r,t[38]=Y):Y=t[38];let me;t[39]===Symbol.for("react.memo_cache_sentinel")?(me=b(f=>{u(f.target.value)},"de"),t[39]=me):me=t[39];let Z;t[40]!==r?(Z=r("Expires in days (optional)"),t[40]=r,t[41]=Z):Z=t[41];let ee;t[42]!==s||t[43]!==Y||t[44]!==Z?(ee=(0,a.jsx)(we,{"aria-label":Y,className:"w-40",min:1,onChange:me,placeholder:Z,type:"number",value:s}),t[42]=s,t[43]=Y,t[44]=Z,t[45]=ee):ee=t[45];let be=D||d!==null,te;t[46]!==r?(te=r("Create token"),t[46]=r,t[47]=te):te=t[47];let ae;t[48]!==be||t[49]!==te?(ae=(0,a.jsx)(ke,{"data-testid":"set-admin-token-create",disabled:be,size:"sm",type:"submit",children:te}),t[48]=be,t[49]=te,t[50]=ae):ae=t[50];let ne;t[51]!==B||t[52]!==X||t[53]!==ee||t[54]!==ae?(ne=(0,a.jsxs)("form",{className:"flex flex-wrap items-end gap-2",onSubmit:B,children:[X,ee,ae]}),t[51]=B,t[52]=X,t[53]=ee,t[54]=ae,t[55]=ne):ne=t[55];let ge=x.length>0&&(0,a.jsxs)(Se,{"data-testid":"set-admin-tokens-table",children:[(0,a.jsx)(Te,{children:(0,a.jsxs)(ie,{children:[(0,a.jsx)(M,{children:r("name")}),(0,a.jsx)(M,{children:r("Created")}),(0,a.jsx)(M,{children:r("Last used")}),(0,a.jsx)(M,{children:r("Expires")}),(0,a.jsx)(M,{})]})}),(0,a.jsx)(Ce,{children:x.map(f=>(0,a.jsxs)(ie,{"data-testid":"set-admin-token-row",children:[(0,a.jsxs)(W,{className:"font-mono text-xs",children:[f.name,f.revoked===!0&&(0,a.jsx)("span",{className:"pl-2 text-destructive",children:r("Revoked")})]}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.createdAt)}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.lastUsedAt,"\u2014")}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.expiresAt,r("Never"))}),(0,a.jsx)(W,{children:(0,a.jsx)(Ee,{onConfirm:b(()=>{H(f.name)},"onConfirm"),testId:`set-admin-token-revoke-${f.name}`,children:r("Revoke")})})]},f.name))})]}),re;t[56]!==F||t[57]!==z||t[58]!==V||t[59]!==P||t[60]!==ne||t[61]!==ge?(re=(0,a.jsxs)(F,{className:Q,children:[z,V,P,ne,ge]}),t[56]=F,t[57]=z,t[58]=V,t[59]=P,t[60]=ne,t[61]=ge,t[62]=re):re=t[62];let ue;return t[63]!==q||t[64]!==T||t[65]!==re?(ue=(0,a.jsxs)(q,{className:G,"data-testid":J,children:[T,re]}),t[63]=q,t[64]=T,t[65]=re,t[66]=ue):ue=t[66],ue},"Fe"),Fe={binding:"outline",secret:"destructive",var:"secondary"},Ve=b((t,e)=>{if(t===void 0)return[];let r=[];return t.workerUrl!==void 0&&r.push({label:e("URL"),value:t.workerUrl}),t.environment!==void 0&&r.push({label:e("Environment"),value:t.environment}),t.deploymentId!==void 0&&r.push({label:e("Deployment"),value:t.deploymentId}),t.versionTag!==void 0&&r.push({label:e("Version"),value:t.versionTag}),r},"Pe"),Me={disabled:"The assistant is off. Nothing about this deployment is sent to a model.",schema:"Table and column names.",schema_and_log:"Table and column names, plus recent log lines.",schema_and_log_and_data:"Table and column names, log lines, and rows read with SELECT."},We=b(t=>{let e=[];for(let[r,n]of Object.entries($e))n===t&&e.push(r);return e},"qe"),He=b(()=>{let t=(0,ce.c)(29),e=xe(),r,n;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={},n={shardKey:""},t[0]=r,t[1]=n):(r=t[0],n=t[1]);let{data:g}=ye(ve.aiAvailable,r,n),h=g?.level,N;t[2]!==h?(N=h===void 0?-1:Le.indexOf(h),t[2]=h,t[3]=N):N=t[3];let x=N,c;t[4]!==e?(c=e("AI assistant data sharing"),t[4]=e,t[5]=c):c=t[5];let m;t[6]!==c?(m=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:c}),t[6]=c,t[7]=m):m=t[7];let p;t[8]!==h?(p=h!==void 0&&(0,a.jsx)(_e,{"data-testid":"set-ai-level",variant:h==="disabled"?"outline":"secondary",children:h}),t[8]=h,t[9]=p):p=t[9];let o;t[10]!==m||t[11]!==p?(o=(0,a.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[m,p]}),t[10]=m,t[11]=p,t[12]=o):o=t[12];let d;t[13]!==x||t[14]!==h||t[15]!==e?(d=Le.map((k,D)=>{let v=x>=D,w=We(k);return(0,a.jsxs)("li",{className:v?"flex flex-col gap-0.5":"flex flex-col gap-0.5 opacity-50","data-granted":String(v),"data-testid":`set-ai-tier-${k}`,children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"font-mono text-xs",children:k}),k===h&&(0,a.jsx)("span",{className:"text-[11px] text-primary",children:e("current")})]}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:e(Me[k])}),w.length>0&&(0,a.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:w.join(", ")})]},k)}),t[13]=x,t[14]=h,t[15]=e,t[16]=d):d=t[16];let l;t[17]!==d?(l=(0,a.jsx)("ul",{className:"flex flex-col gap-1.5 text-sm",children:d}),t[17]=d,t[18]=l):l=t[18];let i;t[19]!==e?(i=e("Set LUNORA_AI_OPT_IN in wrangler.jsonc and redeploy to change this. The Studio can read this level but never raise it."),t[19]=e,t[20]=i):i=t[20];let s;t[21]!==i?(s=(0,a.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"set-ai-howto",children:i}),t[21]=i,t[22]=s):s=t[22];let u;t[23]!==s||t[24]!==l?(u=(0,a.jsxs)(oe,{className:"flex flex-col gap-3 py-3",children:[l,s]}),t[23]=s,t[24]=l,t[25]=u):u=t[25];let _;return t[26]!==u||t[27]!==o?(_=(0,a.jsxs)(le,{className:"py-0","data-testid":"set-ai-sharing",children:[o,u]}),t[26]=u,t[27]=o,t[28]=_):_=t[28],_},"ze"),Re=b(t=>{let e=(0,ce.c)(18),{modifier:r,name:n,label:g}=t,h=Ie(),N;e[0]!==n?(N=b(u=>{if(!["Escape","Tab"].includes(u.key)){if(u.shiftKey){u.preventDefault();return}u.preventDefault(),De(n,u.key)}},"N"),e[0]=n,e[1]=N):N=e[1];let x=N,c=`set-shortcut-${n}`,m;e[2]!==g?(m=(0,a.jsx)("dt",{className:"text-muted-foreground",children:g}),e[2]=g,e[3]=m):m=e[3];let p;e[4]!==r?(p=(0,a.jsx)("kbd",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:r}),e[4]=r,e[5]=p):p=e[5];let o=`set-shortcut-input-${n}`,d=h[n],l;e[6]!==g||e[7]!==x||e[8]!==o||e[9]!==d?(l=(0,a.jsx)("input",{"aria-label":g,className:"h-7 w-12 rounded-md border border-border bg-background text-center font-mono text-xs uppercase outline-none focus-visible:border-ring","data-testid":o,onKeyDown:x,readOnly:!0,value:d}),e[6]=g,e[7]=x,e[8]=o,e[9]=d,e[10]=l):l=e[10];let i;e[11]!==p||e[12]!==l?(i=(0,a.jsxs)("dd",{className:"flex items-center gap-1.5",children:[p,l]}),e[11]=p,e[12]=l,e[13]=i):i=e[13];let s;return e[14]!==c||e[15]!==m||e[16]!==i?(s=(0,a.jsxs)("div",{className:"contents","data-testid":c,children:[m,i]}),e[14]=c,e[15]=m,e[16]=i,e[17]=s):s=e[17],s},"we"),ct=b(t=>{let e=(0,ce.c)(87),{initialShardKey:r}=t,n=xe(),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={},e[0]=g):g=e[0];let h=r??"",N;e[1]!==h?(N={shardKey:h},e[1]=h,e[2]=N):N=e[2];let{data:x,error:c,errorSource:m,isLoading:p}=ye(ve.getSettings,g,N),o,d,l,i,s,u,_;if(e[3]!==c||e[4]!==m||e[5]!==x?.deploy||e[6]!==x?.settings||e[7]!==n){let V=Ve(x?.deploy,n),P;e[15]!==x?.settings?(P=x?.settings??[],e[15]=x?.settings,e[16]=P):P=e[16],o=P,d="flex flex-col gap-4",l="lunora-settings";let A;e[17]!==n?(A=n("Open in Cloudflare"),e[17]=n,e[18]=A):A=e[18],e[19]!==A?(i=(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,a.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:Ke,rel:"noreferrer",target:"_blank",children:A})}),e[19]=A,e[20]=i):i=e[20];let $;e[21]!==n?($=n("View-only \u2014 values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=n,e[22]=$):$=e[22],e[23]!==$?(s=(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:$}),e[23]=$,e[24]=s):s=e[24],e[25]!==c||e[26]!==m?(u=c!==null&&(0,a.jsx)(je,{error:m,testId:"set-error"}),e[25]=c,e[26]=m,e[27]=u):u=e[27],_=V.length>0&&(0,a.jsxs)(le,{className:"py-0","data-testid":"set-deploy",children:[(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Deployment")})}),(0,a.jsx)(oe,{className:"py-3",children:(0,a.jsx)("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:V.map(Ge)})})]}),e[3]=c,e[4]=m,e[5]=x?.deploy,e[6]=x?.settings,e[7]=n,e[8]=o,e[9]=d,e[10]=l,e[11]=i,e[12]=s,e[13]=u,e[14]=_}else o=e[8],d=e[9],l=e[10],i=e[11],s=e[12],u=e[13],_=e[14];let k,D;e[28]===Symbol.for("react.memo_cache_sentinel")?(k=(0,a.jsx)(He,{}),D=(0,a.jsx)(qe,{}),e[28]=k,e[29]=D):(k=e[28],D=e[29]);let v;e[30]!==n?(v=n("Keyboard shortcuts"),e[30]=n,e[31]=v):v=e[31];let w;e[32]!==v?(w=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v}),e[32]=v,e[33]=w):w=e[33];let O;e[34]!==n?(O=n("Reset"),e[34]=n,e[35]=O):O=e[35];let j;e[36]!==O?(j=(0,a.jsx)("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"set-shortcut-reset",onClick:Oe,type:"button",children:O}),e[36]=O,e[37]=j):j=e[37];let K;e[38]!==w||e[39]!==j?(K=(0,a.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[w,j]}),e[38]=w,e[39]=j,e[40]=K):K=e[40];let y;e[41]!==n?(y=n("Command palette"),e[41]=n,e[42]=y):y=e[42];let L;e[43]!==y?(L=(0,a.jsx)(Re,{label:y,modifier:"\u2318/Ctrl",name:"palette"}),e[43]=y,e[44]=L):L=e[44];let R;e[45]!==n?(R=n("Operation console"),e[45]=n,e[46]=R):R=e[46];let U;e[47]!==R?(U=(0,a.jsx)(Re,{label:R,modifier:"Ctrl",name:"console"}),e[47]=R,e[48]=U):U=e[48];let B;e[49]!==L||e[50]!==U?(B=(0,a.jsxs)("dl",{className:"grid grid-cols-[10rem_minmax(0,1fr)] items-center gap-x-4 gap-y-2 text-sm",children:[L,U]}),e[49]=L,e[50]=U,e[51]=B):B=e[51];let H;e[52]!==n?(H=n("Stored in this browser. Focus a box and press a key to rebind it."),e[52]=n,e[53]=H):H=e[53];let q;e[54]!==H?(q=(0,a.jsx)("p",{className:"pt-3 text-xs text-muted-foreground",children:H}),e[54]=H,e[55]=q):q=e[55];let G;e[56]!==B||e[57]!==q?(G=(0,a.jsxs)(oe,{className:"py-3",children:[B,q]}),e[56]=B,e[57]=q,e[58]=G):G=e[58];let J;e[59]!==K||e[60]!==G?(J=(0,a.jsxs)(le,{className:"py-0","data-testid":"set-preferences",children:[K,G]}),e[59]=K,e[60]=G,e[61]=J):J=e[61];let S;e[62]!==n?(S=n("Environment & bindings"),e[62]=n,e[63]=S):S=e[63];let T;e[64]!==S?(T=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:S})}),e[64]=S,e[65]=T):T=e[65];let F;e[66]!==c||e[67]!==p||e[68]!==o.length||e[69]!==n?(F=c===null&&!p&&o.length===0&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:n("No environment variables or bindings.")}),e[66]=c,e[67]=p,e[68]=o.length,e[69]=n,e[70]=F):F=e[70];let Q;e[71]!==o||e[72]!==n?(Q=o.length>0&&(0,a.jsx)(oe,{className:"px-0 py-0",children:(0,a.jsxs)(Se,{"data-testid":"set-table",children:[(0,a.jsx)(Te,{children:(0,a.jsxs)(ie,{children:[(0,a.jsx)(M,{children:n("name")}),(0,a.jsx)(M,{children:n("kind")}),(0,a.jsx)(M,{children:n("value")})]})}),(0,a.jsx)(Ce,{children:o.map(Je)})]})}),e[71]=o,e[72]=n,e[73]=Q):Q=e[73];let C;e[74]!==T||e[75]!==F||e[76]!==Q?(C=(0,a.jsxs)(le,{className:"py-0",children:[T,F,Q]}),e[74]=T,e[75]=F,e[76]=Q,e[77]=C):C=e[77];let z;return e[78]!==J||e[79]!==C||e[80]!==d||e[81]!==l||e[82]!==i||e[83]!==s||e[84]!==u||e[85]!==_?(z=(0,a.jsxs)("div",{className:d,"data-testid":l,children:[i,s,u,_,k,D,J,C]}),e[78]=J,e[79]=C,e[80]=d,e[81]=l,e[82]=i,e[83]=s,e[84]=u,e[85]=_,e[86]=z):z=e[86],z},"ft");function Ge(t){return(0,a.jsxs)("div",{className:"contents","data-testid":"set-deploy-row",children:[(0,a.jsx)("dt",{className:"text-muted-foreground",children:t.label}),(0,a.jsx)("dd",{className:"truncate font-mono text-xs",title:t.value,children:t.value})]},t.label)}b(Ge,"He");function Je(t){return(0,a.jsxs)(ie,{"data-testid":"set-row",children:[(0,a.jsx)(W,{className:"font-mono text-xs font-medium",children:t.name}),(0,a.jsx)(W,{children:(0,a.jsx)(_e,{variant:Fe[t.kind],children:t.bindingType??t.kind})}),(0,a.jsx)(W,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:t.value??(0,a.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},t.name)}b(Je,"We");export{ct as SettingsPanel};
@@ -1 +1 @@
1
- import{a as C}from"./chunk-CBTPJPCZ.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as $}from"./chunk-HMMALUXM.js";import{b as v}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{a as j}from"./chunk-JZN3MNJX.js";import"./chunk-EYSF4DHD.js";import{a as I,b as _,c as q,d as p,e as o,f as i}from"./chunk-ZJIYJZ6F.js";import"./chunk-ELPLRD4S.js";import"./chunk-NFI2TNKU.js";import"./chunk-EOFWXI3T.js";import{a as g}from"./chunk-LYVYUTQY.js";import{c as h}from"./chunk-LRUYEVHH.js";import{a as K,e as S}from"./chunk-XV2XEUUB.js";import"./chunk-QFN62JQJ.js";import"./chunk-ZPQBVYNN.js";import{B as T,w as F}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as oe}from"./chunk-A6TVTNKO.js";import{a as ne,b as ie}from"./chunk-ADABTCDI.js";import{a as d,d as k}from"./chunk-5PEAXTYQ.js";var Q=k(oe(),1),G=k(ne(),1);var e=k(ie(),1);var H="agent_threads",de="agent_messages",L="agent_run_queue",J=100,N=250,le={},ce={filters:[],limit:J,offset:0,orderBy:{column:"updatedAt",direction:"desc"},skipCount:!0,table:H},c=d((s,t)=>{let a=s[t];return typeof a=="string"?a:void 0},"c"),B=d((s,t)=>{let a=s[t];return typeof a=="number"?a:void 0},"E"),O=d(s=>{let{usage:t}=s;if(t===null||typeof t!="object")return;let{totalTokens:a}=t;return typeof a=="number"?a:void 0},"H"),me=d(s=>{let{toolCalls:t}=s;return Array.isArray(t)?t.map(a=>a!==null&&typeof a=="object"?a.name:void 0).filter(a=>typeof a=="string"):[]},"de"),ue=d(s=>{switch(s){case"awaiting_input":return"warning";case"cancelled":return"warning";case"error":return"destructive";case"running":return"info";default:return"outline"}},"le"),he=d(s=>{switch(s){case"approved":return"success";case"rejected":return"destructive";default:return"warning"}},"ie"),ge=d(s=>{let t=(0,Q.c)(3),{fetched:a}=s,m=T(),l;return t[0]!==a||t[1]!==m?(l=a<=N?null:(0,e.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"agents-messages-truncated",children:m("Showing the latest {count} messages; older ones are not shown.",{count:N})}),t[0]=a,t[1]=m,t[2]=l):l=t[2],l},"ce"),Te=d(({initialShardKey:s=""})=>{let t=T(),[a,m]=(0,G.useState)(void 0),{data:l}=h(g.listTables,le,{live:!0,shardKey:s}),V=l!==void 0,f=Array.isArray(l)&&l.some(r=>r.name===H),W=Array.isArray(l)&&l.some(r=>r.name===L),{data:E,error:X,errorSource:Y,liveError:Z}=h(g.readTablePage,ce,{enabled:f,live:!0,shardKey:s}),ee={filters:[{column:"threadKey",operator:"eq",value:a??""}],limit:N+1,offset:0,orderBy:{column:"seq",direction:"desc"},skipCount:!0,table:de},{data:P}=h(g.readTablePage,{limit:J,offset:0,orderBy:{column:"position",direction:"asc"},skipCount:!0,table:L},{enabled:W,live:!0,shardKey:s}),{data:U,error:te,errorSource:ae}=h(g.readTablePage,ee,{enabled:f&&a!==void 0,live:!0,shardKey:s}),b=Array.isArray(E?.rows)?E.rows:[],re=Array.isArray(P?.rows)?P.rows:[],z=d(r=>re.filter(n=>c(n,"threadKey")===r).length,"C"),M=Array.isArray(U?.rows)?U.rows:[],R=M.slice(0,N).toReversed(),D=b.find(r=>c(r,"key")===a),x;return V&&!f?x=(0,e.jsx)($,{description:t("No @lunora/agent tables found in this deployment. Add lunora/agents.ts with defineAgent(...) and merge the agent schema extension to run durable AI agents."),testId:"agents-unconfigured",title:t("No agents configured")}):f&&b.length===0?x=(0,e.jsx)($,{description:t("No agent has run yet. Start a run with ctx.agents.<name>.run(...) and its thread appears here."),testId:"agents-empty",title:t("No agent threads yet")}):x=(0,e.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,e.jsx)(K,{className:"overflow-hidden py-0",children:(0,e.jsx)(S,{className:"px-0",children:(0,e.jsxs)(I,{"data-testid":"agents-threads-table",children:[(0,e.jsx)(_,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(o,{children:t("Agent")}),(0,e.jsx)(o,{children:t("Key")}),(0,e.jsx)(o,{children:t("Status")}),(0,e.jsx)(o,{children:t("Queued")}),(0,e.jsx)(o,{children:t("Messages")}),(0,e.jsx)(o,{children:t("Tokens")}),(0,e.jsx)(o,{children:t("Updated")}),(0,e.jsx)(o,{"aria-label":t("Actions")})]})}),(0,e.jsx)(q,{children:b.map(r=>{let n=c(r,"key")??"",u=c(r,"status"),y=O(r);return(0,e.jsxs)(p,{"data-active":n===a?"":void 0,"data-testid":`agents-thread-${n}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:c(r,"agent")??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:n}),(0,e.jsx)(i,{children:(0,e.jsx)(v,{"data-testid":`agents-thread-status-${n}`,variant:ue(u),children:u??"\u2014"})}),(0,e.jsx)(i,{className:"tabular-nums",children:z(n)===0?(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}):(0,e.jsx)(v,{"data-testid":`agents-thread-queued-${n}`,variant:"warning",children:z(n)})}),(0,e.jsx)(i,{className:"tabular-nums",children:B(r,"messageCount")??"\u2014"}),(0,e.jsx)(i,{className:"tabular-nums text-muted-foreground",children:y??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:F(B(r,"updatedAt"),"\u2014")}),(0,e.jsx)(i,{className:"text-right",children:(0,e.jsx)(C,{"data-testid":`agents-thread-open-${n}`,onClick:d(()=>{m(n)},"onClick"),size:"sm",type:"button",variant:"outline",children:t("Timeline")})})]},n)})})]})})}),te!==null&&(0,e.jsx)(j,{error:ae,shardKey:s,testId:"agents-messages-error"}),a!==void 0&&(0,e.jsx)(K,{className:"overflow-hidden py-0","data-testid":"agents-thread-detail",children:(0,e.jsxs)(S,{className:"flex flex-col gap-3 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[t("Timeline")," \xB7 ",a,D!==void 0&&(0,e.jsxs)("span",{className:"text-muted-foreground",children:[" \xB7 ",t("Usage"),": ",O(D)??0," ",t("Tokens")]})]}),(0,e.jsx)(C,{"data-testid":"agents-thread-detail-close",onClick:d(()=>{m(void 0)},"onClick"),size:"xs",type:"button",variant:"ghost",children:t("Close")})]}),(0,e.jsx)(ge,{fetched:M.length}),R.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:t("This thread has no messages yet.")}):(0,e.jsxs)(I,{"data-testid":"agents-messages-table",children:[(0,e.jsx)(_,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(o,{children:t("Role")}),(0,e.jsx)(o,{children:t("Content")}),(0,e.jsx)(o,{children:t("Tool")}),(0,e.jsx)(o,{children:t("Approval")})]})}),(0,e.jsx)(q,{children:R.map((r,n)=>{let u=c(r,"role")??"\u2014",y=me(r),se=c(r,"toolName"),w=c(r,"status"),A=B(r,"seq")??n;return(0,e.jsxs)(p,{"data-testid":`agents-message-${String(A)}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs align-top text-muted-foreground",children:u}),(0,e.jsx)(i,{className:"max-w-md font-mono text-xs whitespace-pre-wrap break-words",children:c(r,"content")??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs align-top text-muted-foreground",children:se??(y.length>0?y.join(", "):"\u2014")}),(0,e.jsx)(i,{className:"align-top",children:w===void 0?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"\u2014"}):(0,e.jsx)(v,{"data-testid":`agents-message-approval-${String(A)}`,variant:he(w),children:w})})]},c(r,"messageKey")??`${u}:${String(A)}`)})})]})]})})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-agents-panel",children:[X!==null&&(0,e.jsx)(j,{error:Y,shardKey:s,testId:"agents-error"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t("Agents run as durable workflows. Each run persists a thread of assistant and tool messages; select a thread to inspect its timeline, tool calls, approvals, and token usage.")}),Z!==void 0&&(0,e.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"agents-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")}),x]})},"Ee");export{Te as default};
1
+ import{a as C}from"./chunk-QHI77TGI.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as $}from"./chunk-O46IV64X.js";import{b as v}from"./chunk-OOPMRFI2.js";import"./chunk-L27FKJTG.js";import{a as j}from"./chunk-PUTERXSU.js";import"./chunk-ZIY53FID.js";import{a as I,b as _,c as q,d as p,e as o,f as i}from"./chunk-KMBE7RTC.js";import"./chunk-4YZAJTU5.js";import"./chunk-UDKKUJHY.js";import"./chunk-EOFWXI3T.js";import{a as g}from"./chunk-LYVYUTQY.js";import{c as h}from"./chunk-NP6H72XD.js";import{a as K,e as S}from"./chunk-NPHGFVNE.js";import"./chunk-YESGXFAR.js";import"./chunk-ZPQBVYNN.js";import{B as T,w as F}from"./chunk-CDIV23I2.js";import"./chunk-PDBW6GTJ.js";import{a as oe}from"./chunk-A6TVTNKO.js";import{a as ne,b as ie}from"./chunk-ADABTCDI.js";import{a as d,d as k}from"./chunk-5PEAXTYQ.js";var Q=k(oe(),1),G=k(ne(),1);var e=k(ie(),1);var H="agent_threads",de="agent_messages",L="agent_run_queue",J=100,N=250,le={},ce={filters:[],limit:J,offset:0,orderBy:{column:"updatedAt",direction:"desc"},skipCount:!0,table:H},c=d((s,t)=>{let a=s[t];return typeof a=="string"?a:void 0},"c"),B=d((s,t)=>{let a=s[t];return typeof a=="number"?a:void 0},"E"),O=d(s=>{let{usage:t}=s;if(t===null||typeof t!="object")return;let{totalTokens:a}=t;return typeof a=="number"?a:void 0},"H"),me=d(s=>{let{toolCalls:t}=s;return Array.isArray(t)?t.map(a=>a!==null&&typeof a=="object"?a.name:void 0).filter(a=>typeof a=="string"):[]},"de"),ue=d(s=>{switch(s){case"awaiting_input":return"warning";case"cancelled":return"warning";case"error":return"destructive";case"running":return"info";default:return"outline"}},"le"),he=d(s=>{switch(s){case"approved":return"success";case"rejected":return"destructive";default:return"warning"}},"ie"),ge=d(s=>{let t=(0,Q.c)(3),{fetched:a}=s,m=T(),l;return t[0]!==a||t[1]!==m?(l=a<=N?null:(0,e.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"agents-messages-truncated",children:m("Showing the latest {count} messages; older ones are not shown.",{count:N})}),t[0]=a,t[1]=m,t[2]=l):l=t[2],l},"ce"),Te=d(({initialShardKey:s=""})=>{let t=T(),[a,m]=(0,G.useState)(void 0),{data:l}=h(g.listTables,le,{live:!0,shardKey:s}),V=l!==void 0,f=Array.isArray(l)&&l.some(r=>r.name===H),W=Array.isArray(l)&&l.some(r=>r.name===L),{data:E,error:X,errorSource:Y,liveError:Z}=h(g.readTablePage,ce,{enabled:f,live:!0,shardKey:s}),ee={filters:[{column:"threadKey",operator:"eq",value:a??""}],limit:N+1,offset:0,orderBy:{column:"seq",direction:"desc"},skipCount:!0,table:de},{data:P}=h(g.readTablePage,{limit:J,offset:0,orderBy:{column:"position",direction:"asc"},skipCount:!0,table:L},{enabled:W,live:!0,shardKey:s}),{data:U,error:te,errorSource:ae}=h(g.readTablePage,ee,{enabled:f&&a!==void 0,live:!0,shardKey:s}),b=Array.isArray(E?.rows)?E.rows:[],re=Array.isArray(P?.rows)?P.rows:[],z=d(r=>re.filter(n=>c(n,"threadKey")===r).length,"C"),M=Array.isArray(U?.rows)?U.rows:[],R=M.slice(0,N).toReversed(),D=b.find(r=>c(r,"key")===a),x;return V&&!f?x=(0,e.jsx)($,{description:t("No @lunora/agent tables found in this deployment. Add lunora/agents.ts with defineAgent(...) and merge the agent schema extension to run durable AI agents."),testId:"agents-unconfigured",title:t("No agents configured")}):f&&b.length===0?x=(0,e.jsx)($,{description:t("No agent has run yet. Start a run with ctx.agents.<name>.run(...) and its thread appears here."),testId:"agents-empty",title:t("No agent threads yet")}):x=(0,e.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,e.jsx)(K,{className:"overflow-hidden py-0",children:(0,e.jsx)(S,{className:"px-0",children:(0,e.jsxs)(I,{"data-testid":"agents-threads-table",children:[(0,e.jsx)(_,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(o,{children:t("Agent")}),(0,e.jsx)(o,{children:t("Key")}),(0,e.jsx)(o,{children:t("Status")}),(0,e.jsx)(o,{children:t("Queued")}),(0,e.jsx)(o,{children:t("Messages")}),(0,e.jsx)(o,{children:t("Tokens")}),(0,e.jsx)(o,{children:t("Updated")}),(0,e.jsx)(o,{"aria-label":t("Actions")})]})}),(0,e.jsx)(q,{children:b.map(r=>{let n=c(r,"key")??"",u=c(r,"status"),y=O(r);return(0,e.jsxs)(p,{"data-active":n===a?"":void 0,"data-testid":`agents-thread-${n}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:c(r,"agent")??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:n}),(0,e.jsx)(i,{children:(0,e.jsx)(v,{"data-testid":`agents-thread-status-${n}`,variant:ue(u),children:u??"\u2014"})}),(0,e.jsx)(i,{className:"tabular-nums",children:z(n)===0?(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}):(0,e.jsx)(v,{"data-testid":`agents-thread-queued-${n}`,variant:"warning",children:z(n)})}),(0,e.jsx)(i,{className:"tabular-nums",children:B(r,"messageCount")??"\u2014"}),(0,e.jsx)(i,{className:"tabular-nums text-muted-foreground",children:y??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:F(B(r,"updatedAt"),"\u2014")}),(0,e.jsx)(i,{className:"text-right",children:(0,e.jsx)(C,{"data-testid":`agents-thread-open-${n}`,onClick:d(()=>{m(n)},"onClick"),size:"sm",type:"button",variant:"outline",children:t("Timeline")})})]},n)})})]})})}),te!==null&&(0,e.jsx)(j,{error:ae,shardKey:s,testId:"agents-messages-error"}),a!==void 0&&(0,e.jsx)(K,{className:"overflow-hidden py-0","data-testid":"agents-thread-detail",children:(0,e.jsxs)(S,{className:"flex flex-col gap-3 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[t("Timeline")," \xB7 ",a,D!==void 0&&(0,e.jsxs)("span",{className:"text-muted-foreground",children:[" \xB7 ",t("Usage"),": ",O(D)??0," ",t("Tokens")]})]}),(0,e.jsx)(C,{"data-testid":"agents-thread-detail-close",onClick:d(()=>{m(void 0)},"onClick"),size:"xs",type:"button",variant:"ghost",children:t("Close")})]}),(0,e.jsx)(ge,{fetched:M.length}),R.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:t("This thread has no messages yet.")}):(0,e.jsxs)(I,{"data-testid":"agents-messages-table",children:[(0,e.jsx)(_,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(o,{children:t("Role")}),(0,e.jsx)(o,{children:t("Content")}),(0,e.jsx)(o,{children:t("Tool")}),(0,e.jsx)(o,{children:t("Approval")})]})}),(0,e.jsx)(q,{children:R.map((r,n)=>{let u=c(r,"role")??"\u2014",y=me(r),se=c(r,"toolName"),w=c(r,"status"),A=B(r,"seq")??n;return(0,e.jsxs)(p,{"data-testid":`agents-message-${String(A)}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs align-top text-muted-foreground",children:u}),(0,e.jsx)(i,{className:"max-w-md font-mono text-xs whitespace-pre-wrap break-words",children:c(r,"content")??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs align-top text-muted-foreground",children:se??(y.length>0?y.join(", "):"\u2014")}),(0,e.jsx)(i,{className:"align-top",children:w===void 0?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"\u2014"}):(0,e.jsx)(v,{"data-testid":`agents-message-approval-${String(A)}`,variant:he(w),children:w})})]},c(r,"messageKey")??`${u}:${String(A)}`)})})]})]})})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-agents-panel",children:[X!==null&&(0,e.jsx)(j,{error:Y,shardKey:s,testId:"agents-error"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t("Agents run as durable workflows. Each run persists a thread of assistant and tool messages; select a thread to inspect its timeline, tool calls, approvals, and token usage.")}),Z!==void 0&&(0,e.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"agents-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")}),x]})},"Ee");export{Te as default};