@lunora/studio 1.0.0-alpha.87 → 1.0.0-alpha.89
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.
- package/dist/standalone/{chunk-4JIOFDMR.js → chunk-24JLZ2Z5.js} +1 -1
- package/dist/standalone/{chunk-EWDLYYJM.js → chunk-3AV5CV6K.js} +1 -1
- package/dist/standalone/{chunk-XZN645UJ.js → chunk-4COKHD2C.js} +1 -1
- package/dist/standalone/{chunk-T2Q7I3V2.js → chunk-53KJRSHE.js} +1 -1
- package/dist/standalone/{chunk-UNVK2VZP.js → chunk-5ZXDB6LB.js} +1 -1
- package/dist/standalone/{chunk-LYRAWNV7.js → chunk-62EKHKTS.js} +1 -1
- package/dist/standalone/{chunk-B5S6GSUC.js → chunk-67DKQC23.js} +1 -1
- package/dist/standalone/{chunk-PDMZITZZ.js → chunk-6MKDYZ7A.js} +1 -1
- package/dist/standalone/{chunk-TVGKSIIW.js → chunk-6VTLIGVX.js} +1 -1
- package/dist/standalone/{chunk-EAIUBZA5.js → chunk-AQX2QFCN.js} +1 -1
- package/dist/standalone/{chunk-HYCMT2V5.js → chunk-ARP36PTE.js} +1 -1
- package/dist/standalone/{chunk-7DNDRUMZ.js → chunk-AUQKJYHL.js} +1 -1
- package/dist/standalone/{chunk-CLNB7I3O.js → chunk-AZAGCJVI.js} +1 -1
- package/dist/standalone/{chunk-SMEW3ZTU.js → chunk-BL6NO3U3.js} +1 -1
- package/dist/standalone/{chunk-L4RW5BFD.js → chunk-BRQMMGOS.js} +1 -1
- package/dist/standalone/{chunk-NMLCYY4H.js → chunk-BUTBQGUU.js} +1 -1
- package/dist/standalone/{chunk-OOWHAURL.js → chunk-C3HXK3A5.js} +1 -1
- package/dist/standalone/{chunk-NBUBAW3V.js → chunk-CT6ZDXLL.js} +1 -1
- package/dist/standalone/{chunk-EVTCXQ5D.js → chunk-D3HXVA33.js} +1 -1
- package/dist/standalone/{chunk-SJZQPIZB.js → chunk-DG7YINFM.js} +1 -1
- package/dist/standalone/{chunk-BDNDSBYM.js → chunk-DMCYISRF.js} +1 -1
- package/dist/standalone/{chunk-KJIBL5D4.js → chunk-E7TB4USI.js} +1 -1
- package/dist/standalone/{chunk-QJTGO4JG.js → chunk-GKSRVABT.js} +1 -1
- package/dist/standalone/{chunk-2VWWXVWK.js → chunk-GSKOAKQ2.js} +1 -1
- package/dist/standalone/{chunk-QXDMHM2V.js → chunk-IC64YIX5.js} +1 -1
- package/dist/standalone/{chunk-NCWUTRZB.js → chunk-JFW3YNVQ.js} +1 -1
- package/dist/standalone/{chunk-D3JTCLSF.js → chunk-LAHYLAT4.js} +1 -1
- package/dist/standalone/{chunk-YRYEZHOJ.js → chunk-LJIFMW67.js} +1 -1
- package/dist/standalone/{chunk-DABW4OOI.js → chunk-LJISXTZJ.js} +1 -1
- package/dist/standalone/{chunk-YFJXQUPW.js → chunk-LQAKPCFX.js} +1 -1
- package/dist/standalone/{chunk-6MGI5IN6.js → chunk-MHAXZQVO.js} +1 -1
- package/dist/standalone/{chunk-S2CXYDNT.js → chunk-OG2AMGOC.js} +1 -1
- package/dist/standalone/{chunk-EJ2CHD4G.js → chunk-PB7FNRDB.js} +1 -1
- package/dist/standalone/{chunk-5KRD6F67.js → chunk-PGC523I2.js} +1 -1
- package/dist/standalone/{chunk-F7NVC7YK.js → chunk-PM37X2V3.js} +1 -1
- package/dist/standalone/{chunk-WPUINKEO.js → chunk-QV6KV4SD.js} +1 -1
- package/dist/standalone/{chunk-PNAVAJAF.js → chunk-QWBRD6PX.js} +1 -1
- package/dist/standalone/{chunk-5X4OZ7OD.js → chunk-QYIOW7CD.js} +1 -1
- package/dist/standalone/{chunk-B5UFGO4E.js → chunk-SF4MF2FT.js} +1 -1
- package/dist/standalone/{chunk-TS6346VY.js → chunk-SHMNA6UL.js} +1 -1
- package/dist/standalone/{chunk-OUCGTB3Y.js → chunk-SP5SBO2W.js} +1 -1
- package/dist/standalone/{chunk-ORVR33FM.js → chunk-T6OAYQTX.js} +1 -1
- package/dist/standalone/{chunk-GZS3ORGS.js → chunk-TBBJPPZ3.js} +1 -1
- package/dist/standalone/{chunk-VQK34A2H.js → chunk-ULCZDGWQ.js} +1 -1
- package/dist/standalone/chunk-V2U5CL3S.js +11 -0
- package/dist/standalone/{chunk-IVCIG5J7.js → chunk-VFQDHG7I.js} +1 -1
- package/dist/standalone/{chunk-T3CGXSXO.js → chunk-WB5IUUUU.js} +1 -1
- package/dist/standalone/{chunk-GE5WTIWX.js → chunk-XZSGE5ST.js} +1 -1
- package/dist/standalone/{chunk-YKAO3JNJ.js → chunk-Y7JXGNXD.js} +1 -1
- package/dist/standalone/{chunk-UR3X4K4T.js → chunk-YOUKADZH.js} +1 -1
- package/dist/standalone/{chunk-SNK7TOOO.js → chunk-YU5CI2FD.js} +1 -1
- package/dist/standalone/{chunk-ZCFDQW4U.js → chunk-Z7G74IH4.js} +1 -1
- package/dist/standalone/{chunk-7FO57AZY.js → chunk-ZPLWCC4I.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +4 -4
- package/dist/standalone/chunk-MIFLRBVS.js +0 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Qe}from"./chunk-JN2Y24PY.js";import{a as Me}from"./chunk-NCWUTRZB.js";import{a as Ve}from"./chunk-ESVP44Y3.js";import{a as Je}from"./chunk-U6TNNM5U.js";import{a as D}from"./chunk-5Y3QLNWX.js";import{a as He}from"./chunk-54MMVNPT.js";import{a as Ke}from"./chunk-FURI47Z2.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import{R as P}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as z}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as T}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{b as Ge}from"./chunk-TS6346VY.js";import{f as E}from"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{a as Ze}from"./chunk-XQCVZAGU.js";import{a as Ue,b as _e,c as Re,d as L,e as U,f as _}from"./chunk-MIQTKZAR.js";import{a as we,e as Ce}from"./chunk-UZERI5YC.js";import{d as W,h as Be,l as Ae,m as ze,q as Ie}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as r,e as Le,f as Ye,g as et,h as tt}from"./chunk-3XIESWL4.js";var k=Le(Ye(),1);var Z=Le(et(),1);var t=Le(tt(),1);var at=r(()=>{let u=(0,Z.c)(3),{config:e,ready:l}=Me(),s;return u[0]!==e.capabilities||u[1]!==l?(s={capabilities:e.capabilities,ready:l},u[0]=e.capabilities,u[1]=l,u[2]=s):s=u[2],s},"et"),st={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},lt=r((u,e)=>u.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:u.type!=="number"||!Number.isNaN(Number(e.trim())),"at"),rt=r((u,e)=>{if(u.type==="boolean")return e===!0?{value:!0}:u.required?{value:!1}:void 0;let l=typeof e=="string"?e.trim():"";if(l!==""){if(u.type==="number"){let s=Number(l);return Number.isNaN(s)?void 0:{value:s}}return{value:l}}},"lt"),it=r(u=>{let e=(0,Z.c)(105),{onClose:l,onCreated:s}=u,c=E(),a=W(),{config:o}=Me(),{busy:i,error:n,run:m}=Je(),[w,S]=(0,k.useState)(""),[b,C]=(0,k.useState)(""),[y,I]=(0,k.useState)(""),[h,g]=(0,k.useState)(""),v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={},e[0]=v):v=e[0];let[f,d]=(0,k.useState)(v),A;e[1]===Symbol.for("react.memo_cache_sentinel")?(A=r(p=>{S(p.target.value)},"C"),e[1]=A):A=e[1];let x=A,F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F=r(p=>{C(p.target.value)},"F"),e[2]=F):F=e[2];let O=F,$;e[3]===Symbol.for("react.memo_cache_sentinel")?($=r(p=>{I(p.target.value)},"R"),e[3]=$):$=e[3];let Pe=$,G;e[4]===Symbol.for("react.memo_cache_sentinel")?(G=r(p=>{g(p.target.value)},"O"),e[4]=G):G=e[4];let Te=G,H;e[5]===Symbol.for("react.memo_cache_sentinel")?(H=r((p,R)=>{d(V=>({...V,[p]:R}))},"G"),e[5]=H):H=e[5];let $e=H,J;e[6]!==f?(J=r(p=>f[p.name]??(p.type==="boolean"?!1:""),"H"),e[6]=f,e[7]=J):J=e[7];let j=J,K;if(e[8]!==o.userFields||e[9]!==j){let p;e[11]!==j?(p=r(R=>!R.required||lt(R,j(R)),"p"),e[11]=j,e[12]=p):p=e[12],K=o.userFields.every(p),e[8]=o.userFields,e[9]=j,e[10]=K}else K=e[10];let Fe=K,Q;e[13]!==i||e[14]!==w||e[15]!==b||e[16]!==Fe?(Q=!i&&w.trim()!==""&&b.trim()!==""&&Fe,e[13]=i,e[14]=w,e[15]=b,e[16]=Fe,e[17]=Q):Q=e[17];let De=Q,X;e[18]!==o.userFields||e[19]!==j?(X=r(()=>{let p={};for(let R of o.userFields){let V=rt(R,j(R));V!==void 0&&(p[R.name]=V.value)}return Object.keys(p).length===0?void 0:p},"W"),e[18]=o.userFields,e[19]=j,e[20]=X):X=e[20];let Se=X,Y;e[21]!==Se||e[22]!==c||e[23]!==w||e[24]!==b||e[25]!==l||e[26]!==s||e[27]!==y||e[28]!==h||e[29]!==m?(Y=r(()=>{m(async()=>{await c.createAuthUser({data:Se(),email:w.trim(),name:b.trim(),password:y===""?void 0:y,role:h.trim()===""?void 0:h.trim()}),s(),l()})},"Z"),e[21]=Se,e[22]=c,e[23]=w,e[24]=b,e[25]=l,e[26]=s,e[27]=y,e[28]=h,e[29]=m,e[30]=Y):Y=e[30];let N=Y,B;e[31]!==a?(B=a("Create user"),e[31]=a,e[32]=B):B=e[32];let q;e[33]!==a?(q=a("Create user"),e[33]=a,e[34]=q):q=e[34];let M;e[35]!==q?(M=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:q}),e[35]=q,e[36]=M):M=e[36];let ee;e[37]!==a?(ee=a("email"),e[37]=a,e[38]=ee):ee=e[38];let te;e[39]!==ee?(te=(0,t.jsx)(D,{htmlFor:"uc-email",children:ee}),e[39]=ee,e[40]=te):te=e[40];let ae;e[41]!==w?(ae=(0,t.jsx)(P,{"data-testid":"uc-email",id:"uc-email",onChange:x,type:"email",value:w}),e[41]=w,e[42]=ae):ae=e[42];let se;e[43]!==te||e[44]!==ae?(se=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[te,ae]}),e[43]=te,e[44]=ae,e[45]=se):se=e[45];let le;e[46]!==a?(le=a("name"),e[46]=a,e[47]=le):le=e[47];let re;e[48]!==le?(re=(0,t.jsx)(D,{htmlFor:"uc-name",children:le}),e[48]=le,e[49]=re):re=e[49];let ie;e[50]!==b?(ie=(0,t.jsx)(P,{"data-testid":"uc-name",id:"uc-name",onChange:O,value:b}),e[50]=b,e[51]=ie):ie=e[51];let ne;e[52]!==re||e[53]!==ie?(ne=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[re,ie]}),e[52]=re,e[53]=ie,e[54]=ne):ne=e[54];let de;e[55]!==a?(de=a("Password (optional)"),e[55]=a,e[56]=de):de=e[56];let oe;e[57]!==de?(oe=(0,t.jsx)(D,{htmlFor:"uc-password",children:de}),e[57]=de,e[58]=oe):oe=e[58];let ce;e[59]!==y?(ce=(0,t.jsx)(P,{"data-testid":"uc-password",id:"uc-password",onChange:Pe,type:"password",value:y}),e[59]=y,e[60]=ce):ce=e[60];let ue;e[61]!==oe||e[62]!==ce?(ue=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[oe,ce]}),e[61]=oe,e[62]=ce,e[63]=ue):ue=e[63];let me;e[64]!==a?(me=a("Role (optional)"),e[64]=a,e[65]=me):me=e[65];let he;e[66]!==me?(he=(0,t.jsx)(D,{htmlFor:"uc-role",children:me}),e[66]=me,e[67]=he):he=e[67];let pe;e[68]!==h?(pe=(0,t.jsx)(P,{"data-testid":"uc-role",id:"uc-role",onChange:Te,value:h}),e[68]=h,e[69]=pe):pe=e[69];let fe;e[70]!==he||e[71]!==pe?(fe=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[he,pe]}),e[70]=he,e[71]=pe,e[72]=fe):fe=e[72];let ve;e[73]!==o.userFields||e[74]!==j||e[75]!==a?(ve=o.userFields.length>0&&(0,t.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Plugin fields")}),o.userFields.map(p=>{let R=`uc-field-${p.name}`,V=p.required?"":` (${a("optional")})`;if(p.type==="boolean"){let qe=j(p)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:R,children:[(0,t.jsx)(Qe,{checked:qe,"data-testid":R,id:R,onCheckedChange:r(Xe=>{$e(p.name,Xe)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[p.name,V]})]},p.name)}let We=j(p);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(D,{htmlFor:R,children:[p.name,V]}),(0,t.jsx)(P,{"data-testid":R,id:R,onChange:r(qe=>{$e(p.name,qe.target.value)},"onChange"),type:st[p.type],value:typeof We=="string"?We:""})]},p.name)})]}),e[73]=o.userFields,e[74]=j,e[75]=a,e[76]=ve):ve=e[76];let xe;e[77]!==n?(xe=n!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:n}),e[77]=n,e[78]=xe):xe=e[78];let be;e[79]!==a?(be=a("Cancel"),e[79]=a,e[80]=be):be=e[80];let ye;e[81]!==l||e[82]!==be?(ye=(0,t.jsx)(z,{"data-testid":"uc-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:be}),e[81]=l,e[82]=be,e[83]=ye):ye=e[83];let Oe=!De,ge;e[84]!==i||e[85]!==a?(ge=a(i?"Creating\u2026":"Create"),e[84]=i,e[85]=a,e[86]=ge):ge=e[86];let Ne;e[87]!==N||e[88]!==Oe||e[89]!==ge?(Ne=(0,t.jsx)(z,{"data-testid":"uc-submit",disabled:Oe,onClick:N,size:"sm",type:"button",children:ge}),e[87]=N,e[88]=Oe,e[89]=ge,e[90]=Ne):Ne=e[90];let ke;e[91]!==ye||e[92]!==Ne?(ke=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[ye,Ne]}),e[91]=ye,e[92]=Ne,e[93]=ke):ke=e[93];let je;return e[94]!==l||e[95]!==B||e[96]!==M||e[97]!==se||e[98]!==ne||e[99]!==ue||e[100]!==fe||e[101]!==ve||e[102]!==xe||e[103]!==ke?(je=(0,t.jsxs)(Ve,{label:B,onClose:l,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[M,se,ne,ue,fe,ve,xe,ke]}),e[94]=l,e[95]=B,e[96]=M,e[97]=se,e[98]=ne,e[99]=ue,e[100]=fe,e[101]=ve,e[102]=xe,e[103]=ke,e[104]=je):je=e[104],je},"st"),Ee=r(u=>{let e=(0,Z.c)(2),{children:l}=u,s;return e[0]!==l?(s=(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l}),e[0]=l,e[1]=s):s=e[1],s},"Le"),nt=r(u=>{let e=(0,Z.c)(29),{busy:l,runAction:s,userId:c,version:a}=u,o=E(),i=W(),[n,m]=(0,k.useState)(null),[w,S]=(0,k.useState)(null),b;e[0]!==o||e[1]!==c?(b=r(()=>{ze((async()=>{S(null);try{let x=await o.listAuthSessions({limit:50,userId:c});m(x.rows)}catch(x){let F=x;m(null),S(Be(F))}})())},"x"),e[0]=o,e[1]=c,e[2]=b):b=e[2];let C;e[3]!==o||e[4]!==c||e[5]!==a?(C=[o,c,a],e[3]=o,e[4]=c,e[5]=a,e[6]=C):C=e[6],(0,k.useEffect)(b,C);let y;e[7]!==o||e[8]!==s?(y=r(x=>{s(()=>o.revokeAuthSession({sessionId:x}))},"y"),e[7]=o,e[8]=s,e[9]=y):y=e[9];let I=y,h;e[10]!==i?(h=i("Sessions"),e[10]=i,e[11]=h):h=e[11];let g;e[12]!==h?(g=(0,t.jsx)(Ee,{children:h}),e[12]=h,e[13]=g):g=e[13];let v;e[14]!==w?(v=w!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:w}),e[14]=w,e[15]=v):v=e[15];let f;e[16]!==n||e[17]!==i?(f=n!==null&&n.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:i("No active sessions.")}),e[16]=n,e[17]=i,e[18]=f):f=e[18];let d;e[19]!==l||e[20]!==I||e[21]!==n||e[22]!==i?(d=n!==null&&n.length>0&&(0,t.jsx)(we,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(Ue,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(L,{children:[(0,t.jsx)(U,{children:i("expires")}),(0,t.jsx)(U,{children:i("ip")}),(0,t.jsx)(U,{children:i("user agent")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Re,{children:n.map(x=>(0,t.jsxs)(L,{"data-testid":`ud-session-${x.id}`,children:[(0,t.jsx)(_,{className:"text-muted-foreground tabular-nums",children:Ie(x.expiresAt)}),(0,t.jsx)(_,{children:x.ipAddress??""}),(0,t.jsx)(_,{className:"max-w-40 truncate",children:x.userAgent??""}),(0,t.jsx)(_,{children:(0,t.jsx)(z,{"data-testid":`ud-revoke-${x.id}`,disabled:l,onClick:r(()=>{I(x.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Revoke")})})]},x.id))})]})})}),e[19]=l,e[20]=I,e[21]=n,e[22]=i,e[23]=d):d=e[23];let A;return e[24]!==g||e[25]!==v||e[26]!==f||e[27]!==d?(A=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[g,v,f,d]}),e[24]=g,e[25]=v,e[26]=f,e[27]=d,e[28]=A):A=e[28],A},"rt"),dt=r(u=>{let e=(0,Z.c)(30),{busy:l,runAction:s,userId:c,version:a}=u,o=E(),i=W(),[n,m]=(0,k.useState)(null),[w,S]=(0,k.useState)(null),b;e[0]!==o||e[1]!==c?(b=r(()=>{ze((async()=>{S(null);try{m(await o.listAuthAccounts({userId:c}))}catch(x){let F=x;m(null),S(Be(F))}})())},"x"),e[0]=o,e[1]=c,e[2]=b):b=e[2];let C;e[3]!==o||e[4]!==c||e[5]!==a?(C=[o,c,a],e[3]=o,e[4]=c,e[5]=a,e[6]=C):C=e[6],(0,k.useEffect)(b,C);let y;e[7]!==o||e[8]!==s||e[9]!==c?(y=r(x=>{s(()=>o.unlinkAuthAccount({accountId:x,userId:c}))},"y"),e[7]=o,e[8]=s,e[9]=c,e[10]=y):y=e[10];let I=y,h;e[11]!==i?(h=i("Linked accounts"),e[11]=i,e[12]=h):h=e[12];let g;e[13]!==h?(g=(0,t.jsx)(Ee,{children:h}),e[13]=h,e[14]=g):g=e[14];let v;e[15]!==w?(v=w!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:w}),e[15]=w,e[16]=v):v=e[16];let f;e[17]!==n||e[18]!==i?(f=n!==null&&n.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:i("No linked accounts.")}),e[17]=n,e[18]=i,e[19]=f):f=e[19];let d;e[20]!==n||e[21]!==l||e[22]!==I||e[23]!==i?(d=n!==null&&n.length>0&&(0,t.jsx)(we,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(Ue,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(L,{children:[(0,t.jsx)(U,{children:i("provider")}),(0,t.jsx)(U,{children:i("created")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Re,{children:n.map(x=>{let F=Ae(x.id);return(0,t.jsxs)(L,{"data-testid":`ud-account-${F}`,children:[(0,t.jsx)(_,{children:Ae(x.providerId)}),(0,t.jsx)(_,{className:"text-muted-foreground tabular-nums",children:Ie(x.createdAt)}),(0,t.jsx)(_,{children:(0,t.jsx)(z,{"data-testid":`ud-unlink-${F}`,disabled:l,onClick:r(()=>{I(F)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Unlink")})})]},F)})})]})})}),e[20]=n,e[21]=l,e[22]=I,e[23]=i,e[24]=d):d=e[24];let A;return e[25]!==g||e[26]!==v||e[27]!==f||e[28]!==d?(A=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[g,v,f,d]}),e[25]=g,e[26]=v,e[27]=f,e[28]=d,e[29]=A):A=e[29],A},"it"),ot=r(u=>{let e=(0,Z.c)(40),{busy:l,capabilities:s,runAction:c,userId:a,version:o}=u,i=E(),n=W(),[m,w]=(0,k.useState)(null),S;e[0]!==s.passkey||e[1]!==i||e[2]!==a?(S=r(()=>{s.passkey&&ze((async()=>{try{w(await i.listAuthPasskeys({userId:a}))}catch{w(null)}})())},"I"),e[0]=s.passkey,e[1]=i,e[2]=a,e[3]=S):S=e[3];let b;e[4]!==s.passkey||e[5]!==i||e[6]!==a||e[7]!==o?(b=[s.passkey,i,a,o],e[4]=s.passkey,e[5]=i,e[6]=a,e[7]=o,e[8]=b):b=e[8],(0,k.useEffect)(S,b);let C;e[9]!==i||e[10]!==c||e[11]!==a?(C=r(()=>{c(()=>i.disableAuthTwoFactor({userId:a}))},"w"),e[9]=i,e[10]=c,e[11]=a,e[12]=C):C=e[12];let y=C,I;e[13]!==i||e[14]!==c?(I=r(F=>{c(()=>i.deleteAuthPasskey({passkeyId:F}))},"A"),e[13]=i,e[14]=c,e[15]=I):I=e[15];let h=I,g;e[16]!==n?(g=n("Security"),e[16]=n,e[17]=g):g=e[17];let v;e[18]!==g?(v=(0,t.jsx)(Ee,{children:g}),e[18]=g,e[19]=v):v=e[19];let f;e[20]!==l||e[21]!==s.twoFactor||e[22]!==y||e[23]!==n?(f=s.twoFactor&&(0,t.jsx)(z,{"data-testid":"ud-disable-2fa",disabled:l,onClick:y,size:"sm",type:"button",variant:"outline",children:n("Disable two-factor")}),e[20]=l,e[21]=s.twoFactor,e[22]=y,e[23]=n,e[24]=f):f=e[24];let d;e[25]!==s.passkey||e[26]!==m||e[27]!==n?(d=s.passkey&&m!==null&&m.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:n("No passkeys.")}),e[25]=s.passkey,e[26]=m,e[27]=n,e[28]=d):d=e[28];let A;e[29]!==l||e[30]!==s.passkey||e[31]!==h||e[32]!==m||e[33]!==n?(A=s.passkey&&m!==null&&m.length>0&&(0,t.jsx)(we,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(Ue,{"data-testid":"ud-passkeys-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(L,{children:[(0,t.jsx)(U,{children:n("name")}),(0,t.jsx)(U,{children:n("created")}),(0,t.jsx)(U,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Re,{children:m.map(F=>{let O=Ae(F.id);return(0,t.jsxs)(L,{"data-testid":`ud-passkey-${O}`,children:[(0,t.jsx)(_,{children:Ae(F.name)||O}),(0,t.jsx)(_,{className:"text-muted-foreground tabular-nums",children:Ie(F.createdAt)}),(0,t.jsx)(_,{children:(0,t.jsx)(z,{"data-testid":`ud-delete-passkey-${O}`,disabled:l,onClick:r(()=>{h(O)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Delete")})})]},O)})})]})})}),e[29]=l,e[30]=s.passkey,e[31]=h,e[32]=m,e[33]=n,e[34]=A):A=e[34];let x;return e[35]!==v||e[36]!==f||e[37]!==d||e[38]!==A?(x=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[v,f,d,A]}),e[35]=v,e[36]=f,e[37]=d,e[38]=A,e[39]=x):x=e[39],x},"nt"),ct=/(?:at|expires)$/iu,ut=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),mt=r((u,e)=>typeof e=="number"&&ct.test(u)?Ie(e):Ae(e),"ct"),ht=r(({capabilities:u,onChanged:e,onClose:l,user:s})=>{let c=E(),a=W(),o=s.banned===!0,[i,n]=(0,k.useState)(null),[m,w]=(0,k.useState)(!1),[S,b]=(0,k.useState)(0),[C,y]=(0,k.useState)(typeof s.role=="string"?s.role:""),[I,h]=(0,k.useState)(""),[g,v]=(0,k.useState)(""),[f,d]=(0,k.useState)(""),[A,x]=(0,k.useState)(null),[F,O]=(0,k.useState)(!1),$=r((N,B)=>{ze((async()=>{w(!0),n(null);try{let q=await N();B?.refresh!==!1&&(b(M=>M+1),e()),B?.onResult?.(q)}catch(q){n(Be(q))}w(!1)})())},"R"),Pe=r(N=>{y(N.target.value)},"De"),G=r(N=>{h(N.target.value)},"O"),Te=r(N=>{v(N.target.value)},"je"),H=r(N=>{d(N.target.value)},"G"),$e=r(()=>{let N=C.trim();N!==""&&$(async()=>{await c.setAuthUserRole({role:N,userId:s.id})})},"Se"),J=r(()=>{let N=Number.parseInt(g,10),B=Number.isFinite(N)&&N>0?N*86400:void 0;$(async()=>{await c.banAuthUser({expiresInSeconds:B,reason:I.trim()===""?void 0:I.trim(),userId:s.id})})},"H"),j=r(()=>{$(async()=>{await c.unbanAuthUser({userId:s.id})})},"_"),K=r(()=>{$(async()=>{await c.setAuthUserPassword({newPassword:f,userId:s.id}),d("")})},"J"),Fe=r(()=>{$(()=>c.impersonateAuthUser({userId:s.id}),{onResult:r(N=>{x(N.token)},"onResult"),refresh:!1})},"we"),Q=r(()=>{$(async()=>{await c.revokeAuthUserSessions({userId:s.id})})},"K"),De=r(()=>{$(async()=>{await c.removeAuthUser({userId:s.id}),l()})},"Te"),X=r(()=>{O(!0)},"W"),Se=r(()=>{O(!1)},"Ce"),Y=Object.entries(s).filter(([N])=>!ut.has(N));return(0,t.jsxs)(Ve,{label:a("User details"),onClose:l,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:s.name??s.email??s.id}),(0,t.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:s.id}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof s.role=="string"&&s.role!==""&&(0,t.jsx)(T,{variant:"secondary",children:s.role}),o?(0,t.jsx)(T,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(T,{variant:"outline",children:a("Active")}),s.emailVerified===!0?(0,t.jsx)(T,{variant:"secondary",children:a("verified")}):(0,t.jsx)(T,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(z,{"data-testid":"ud-close",onClick:l,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),i!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:i}),u.admin&&(0,t.jsxs)(we,{className:"gap-0 py-0",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Actions")})}),(0,t.jsxs)(Ce,{className:"flex flex-col gap-3 p-3",children:[(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(D,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(P,{"data-testid":"ud-role-input",id:"ud-role",onChange:Pe,value:C})]}),(0,t.jsx)(z,{"data-testid":"ud-set-role",disabled:m||C.trim()==="",onClick:$e,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),o?(0,t.jsx)(z,{"data-testid":"ud-unban",disabled:m,onClick:j,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(D,{htmlFor:"ud-ban-reason",children:a("Ban reason (optional)")}),(0,t.jsx)(P,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:G,value:I})]}),(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[(0,t.jsx)(D,{htmlFor:"ud-ban-days",children:a("Days")}),(0,t.jsx)(P,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:Te,type:"number",value:g})]}),(0,t.jsx)(z,{"data-testid":"ud-ban",disabled:m,onClick:J,size:"sm",type:"button",variant:"destructive",children:a("Ban user")})]}),(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(D,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(P,{"data-testid":"ud-password",id:"ud-password",onChange:H,type:"password",value:f})]}),(0,t.jsx)(z,{"data-testid":"ud-set-password",disabled:m||f==="",onClick:K,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(z,{"data-testid":"ud-impersonate",disabled:m,onClick:Fe,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(z,{"data-testid":"ud-revoke-all",disabled:m,onClick:Q,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),F?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(z,{"data-testid":"ud-delete-confirm",disabled:m,onClick:De,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(z,{"data-testid":"ud-delete-cancel",onClick:Se,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(z,{"data-testid":"ud-delete",disabled:m,onClick:X,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),A!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(D,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(P,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:A})]})]})]}),(0,t.jsx)(nt,{busy:m,runAction:$,userId:s.id,version:S}),u.accounts&&(0,t.jsx)(dt,{busy:m,runAction:$,userId:s.id,version:S}),(u.twoFactor||u.passkey)&&(0,t.jsx)(ot,{busy:m,capabilities:u,runAction:$,userId:s.id,version:S}),(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Fields")}),(0,t.jsx)("dl",{className:"flex flex-col",children:Y.map(([N,B])=>(0,t.jsxs)("div",{className:"flex flex-col border-t border-border py-1.5",children:[(0,t.jsx)("dt",{className:"text-xs font-semibold text-muted-foreground",children:N}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:mt(N,B)})]},N))})]})]})},"ut"),pt=50,Rt=r(({pageSize:u=pt}={})=>{let e=E(),l=W(),[s,c]=(0,k.useState)(""),[a,o]=(0,k.useState)(""),i=Ke(s),[n,m]=(0,k.useState)(null),[w,S]=(0,k.useState)(!1),{capabilities:b}=at(),C=i.trim(),y=a.trim(),I=Ge(["lunora-auth-users",C,y,u],()=>e.listAuthUsers({filterField:y===""?void 0:"role",filterValue:y===""?void 0:y,limit:u,search:C===""?void 0:C}),{keepPreviousData:!0}),h=I.data?.rows??null,g=I.error,v=r(()=>{I.refetch()},"v");He(()=>{I.refetch()},!0);let f=n===null?null:h?.find(d=>d.id===n)??null;return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(P,{"aria-label":l("Search users"),className:"w-56","data-testid":"us-search",onChange:r(d=>{c(d.target.value)},"onChange"),placeholder:l("Search by email or name\u2026"),value:s}),(0,t.jsx)(P,{"aria-label":l("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:r(d=>{o(d.target.value)},"onChange"),placeholder:l("Filter by role"),value:a}),(0,t.jsx)(z,{"data-testid":"us-new",onClick:r(()=>{S(!0)},"onClick"),size:"sm",type:"button",children:l("New user")})]}),g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:g}),h!==null&&h.length===0&&(0,t.jsx)(Ze,{description:l("Users who sign up to your app will appear here."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:l("No users.")}),h!==null&&h.length>0&&(0,t.jsx)(we,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(Ue,{"data-testid":"us-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(L,{children:[(0,t.jsx)(U,{children:l("id")}),(0,t.jsx)(U,{children:l("email")}),(0,t.jsx)(U,{children:l("name")}),(0,t.jsx)(U,{children:l("role")}),(0,t.jsx)(U,{children:l("status")}),(0,t.jsx)(U,{children:l("verified")}),(0,t.jsx)(U,{children:l("created")}),(0,t.jsx)(U,{"aria-label":l("Actions")})]})}),(0,t.jsx)(Re,{children:h.map(d=>(0,t.jsxs)(L,{"data-testid":`us-row-${d.id}`,children:[(0,t.jsx)(_,{className:"font-mono text-xs",children:d.id}),(0,t.jsx)(_,{children:d.email??""}),(0,t.jsx)(_,{children:d.name??""}),(0,t.jsx)(_,{children:typeof d.role=="string"&&d.role!==""?(0,t.jsx)(T,{variant:"secondary",children:d.role}):""}),(0,t.jsx)(_,{children:d.banned===!0?(0,t.jsx)(T,{variant:"destructive",children:l("Banned")}):(0,t.jsx)(T,{variant:"success",children:l("Active")})}),(0,t.jsx)(_,{children:d.emailVerified===!0?(0,t.jsx)(T,{variant:"success",children:l("yes")}):(0,t.jsx)(T,{variant:"outline",children:l("no")})}),(0,t.jsx)(_,{className:"text-muted-foreground tabular-nums",children:Ie(d.createdAt)}),(0,t.jsx)(_,{children:(0,t.jsx)(z,{"data-testid":`us-manage-${d.id}`,onClick:r(()=>{m(d.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Manage")})})]},d.id))})]})})}),f!==null&&(0,t.jsx)(ht,{capabilities:b,onChanged:v,onClose:r(()=>{m(null)},"onClose"),user:f}),w&&(0,t.jsx)(it,{onClose:r(()=>{S(!1)},"onClose"),onCreated:v})]})},"Rt");export{Rt as UsersPanel};
|
|
1
|
+
import{a as Qe}from"./chunk-JN2Y24PY.js";import{a as Me}from"./chunk-JFW3YNVQ.js";import{a as Ve}from"./chunk-ESVP44Y3.js";import{a as Je}from"./chunk-U6TNNM5U.js";import{a as D}from"./chunk-5Y3QLNWX.js";import{a as He}from"./chunk-54MMVNPT.js";import{a as Ke}from"./chunk-FURI47Z2.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import{R as P}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as z}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as T}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{b as Ge}from"./chunk-SHMNA6UL.js";import{f as E}from"./chunk-V2U5CL3S.js";import"./chunk-XBDKZZ67.js";import{a as Ze}from"./chunk-XQCVZAGU.js";import{a as Ue,b as _e,c as Re,d as L,e as U,f as _}from"./chunk-MIQTKZAR.js";import{a as we,e as Ce}from"./chunk-UZERI5YC.js";import{d as W,h as Be,l as Ae,m as ze,q as Ie}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as r,e as Le,f as Ye,g as et,h as tt}from"./chunk-3XIESWL4.js";var k=Le(Ye(),1);var Z=Le(et(),1);var t=Le(tt(),1);var at=r(()=>{let u=(0,Z.c)(3),{config:e,ready:l}=Me(),s;return u[0]!==e.capabilities||u[1]!==l?(s={capabilities:e.capabilities,ready:l},u[0]=e.capabilities,u[1]=l,u[2]=s):s=u[2],s},"et"),st={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},lt=r((u,e)=>u.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:u.type!=="number"||!Number.isNaN(Number(e.trim())),"at"),rt=r((u,e)=>{if(u.type==="boolean")return e===!0?{value:!0}:u.required?{value:!1}:void 0;let l=typeof e=="string"?e.trim():"";if(l!==""){if(u.type==="number"){let s=Number(l);return Number.isNaN(s)?void 0:{value:s}}return{value:l}}},"lt"),it=r(u=>{let e=(0,Z.c)(105),{onClose:l,onCreated:s}=u,c=E(),a=W(),{config:o}=Me(),{busy:i,error:n,run:m}=Je(),[w,S]=(0,k.useState)(""),[b,C]=(0,k.useState)(""),[y,I]=(0,k.useState)(""),[h,g]=(0,k.useState)(""),v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={},e[0]=v):v=e[0];let[f,d]=(0,k.useState)(v),A;e[1]===Symbol.for("react.memo_cache_sentinel")?(A=r(p=>{S(p.target.value)},"C"),e[1]=A):A=e[1];let x=A,F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F=r(p=>{C(p.target.value)},"F"),e[2]=F):F=e[2];let O=F,$;e[3]===Symbol.for("react.memo_cache_sentinel")?($=r(p=>{I(p.target.value)},"R"),e[3]=$):$=e[3];let Pe=$,G;e[4]===Symbol.for("react.memo_cache_sentinel")?(G=r(p=>{g(p.target.value)},"O"),e[4]=G):G=e[4];let Te=G,H;e[5]===Symbol.for("react.memo_cache_sentinel")?(H=r((p,R)=>{d(V=>({...V,[p]:R}))},"G"),e[5]=H):H=e[5];let $e=H,J;e[6]!==f?(J=r(p=>f[p.name]??(p.type==="boolean"?!1:""),"H"),e[6]=f,e[7]=J):J=e[7];let j=J,K;if(e[8]!==o.userFields||e[9]!==j){let p;e[11]!==j?(p=r(R=>!R.required||lt(R,j(R)),"p"),e[11]=j,e[12]=p):p=e[12],K=o.userFields.every(p),e[8]=o.userFields,e[9]=j,e[10]=K}else K=e[10];let Fe=K,Q;e[13]!==i||e[14]!==w||e[15]!==b||e[16]!==Fe?(Q=!i&&w.trim()!==""&&b.trim()!==""&&Fe,e[13]=i,e[14]=w,e[15]=b,e[16]=Fe,e[17]=Q):Q=e[17];let De=Q,X;e[18]!==o.userFields||e[19]!==j?(X=r(()=>{let p={};for(let R of o.userFields){let V=rt(R,j(R));V!==void 0&&(p[R.name]=V.value)}return Object.keys(p).length===0?void 0:p},"W"),e[18]=o.userFields,e[19]=j,e[20]=X):X=e[20];let Se=X,Y;e[21]!==Se||e[22]!==c||e[23]!==w||e[24]!==b||e[25]!==l||e[26]!==s||e[27]!==y||e[28]!==h||e[29]!==m?(Y=r(()=>{m(async()=>{await c.createAuthUser({data:Se(),email:w.trim(),name:b.trim(),password:y===""?void 0:y,role:h.trim()===""?void 0:h.trim()}),s(),l()})},"Z"),e[21]=Se,e[22]=c,e[23]=w,e[24]=b,e[25]=l,e[26]=s,e[27]=y,e[28]=h,e[29]=m,e[30]=Y):Y=e[30];let N=Y,B;e[31]!==a?(B=a("Create user"),e[31]=a,e[32]=B):B=e[32];let q;e[33]!==a?(q=a("Create user"),e[33]=a,e[34]=q):q=e[34];let M;e[35]!==q?(M=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:q}),e[35]=q,e[36]=M):M=e[36];let ee;e[37]!==a?(ee=a("email"),e[37]=a,e[38]=ee):ee=e[38];let te;e[39]!==ee?(te=(0,t.jsx)(D,{htmlFor:"uc-email",children:ee}),e[39]=ee,e[40]=te):te=e[40];let ae;e[41]!==w?(ae=(0,t.jsx)(P,{"data-testid":"uc-email",id:"uc-email",onChange:x,type:"email",value:w}),e[41]=w,e[42]=ae):ae=e[42];let se;e[43]!==te||e[44]!==ae?(se=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[te,ae]}),e[43]=te,e[44]=ae,e[45]=se):se=e[45];let le;e[46]!==a?(le=a("name"),e[46]=a,e[47]=le):le=e[47];let re;e[48]!==le?(re=(0,t.jsx)(D,{htmlFor:"uc-name",children:le}),e[48]=le,e[49]=re):re=e[49];let ie;e[50]!==b?(ie=(0,t.jsx)(P,{"data-testid":"uc-name",id:"uc-name",onChange:O,value:b}),e[50]=b,e[51]=ie):ie=e[51];let ne;e[52]!==re||e[53]!==ie?(ne=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[re,ie]}),e[52]=re,e[53]=ie,e[54]=ne):ne=e[54];let de;e[55]!==a?(de=a("Password (optional)"),e[55]=a,e[56]=de):de=e[56];let oe;e[57]!==de?(oe=(0,t.jsx)(D,{htmlFor:"uc-password",children:de}),e[57]=de,e[58]=oe):oe=e[58];let ce;e[59]!==y?(ce=(0,t.jsx)(P,{"data-testid":"uc-password",id:"uc-password",onChange:Pe,type:"password",value:y}),e[59]=y,e[60]=ce):ce=e[60];let ue;e[61]!==oe||e[62]!==ce?(ue=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[oe,ce]}),e[61]=oe,e[62]=ce,e[63]=ue):ue=e[63];let me;e[64]!==a?(me=a("Role (optional)"),e[64]=a,e[65]=me):me=e[65];let he;e[66]!==me?(he=(0,t.jsx)(D,{htmlFor:"uc-role",children:me}),e[66]=me,e[67]=he):he=e[67];let pe;e[68]!==h?(pe=(0,t.jsx)(P,{"data-testid":"uc-role",id:"uc-role",onChange:Te,value:h}),e[68]=h,e[69]=pe):pe=e[69];let fe;e[70]!==he||e[71]!==pe?(fe=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[he,pe]}),e[70]=he,e[71]=pe,e[72]=fe):fe=e[72];let ve;e[73]!==o.userFields||e[74]!==j||e[75]!==a?(ve=o.userFields.length>0&&(0,t.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Plugin fields")}),o.userFields.map(p=>{let R=`uc-field-${p.name}`,V=p.required?"":` (${a("optional")})`;if(p.type==="boolean"){let qe=j(p)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:R,children:[(0,t.jsx)(Qe,{checked:qe,"data-testid":R,id:R,onCheckedChange:r(Xe=>{$e(p.name,Xe)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[p.name,V]})]},p.name)}let We=j(p);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(D,{htmlFor:R,children:[p.name,V]}),(0,t.jsx)(P,{"data-testid":R,id:R,onChange:r(qe=>{$e(p.name,qe.target.value)},"onChange"),type:st[p.type],value:typeof We=="string"?We:""})]},p.name)})]}),e[73]=o.userFields,e[74]=j,e[75]=a,e[76]=ve):ve=e[76];let xe;e[77]!==n?(xe=n!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:n}),e[77]=n,e[78]=xe):xe=e[78];let be;e[79]!==a?(be=a("Cancel"),e[79]=a,e[80]=be):be=e[80];let ye;e[81]!==l||e[82]!==be?(ye=(0,t.jsx)(z,{"data-testid":"uc-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:be}),e[81]=l,e[82]=be,e[83]=ye):ye=e[83];let Oe=!De,ge;e[84]!==i||e[85]!==a?(ge=a(i?"Creating\u2026":"Create"),e[84]=i,e[85]=a,e[86]=ge):ge=e[86];let Ne;e[87]!==N||e[88]!==Oe||e[89]!==ge?(Ne=(0,t.jsx)(z,{"data-testid":"uc-submit",disabled:Oe,onClick:N,size:"sm",type:"button",children:ge}),e[87]=N,e[88]=Oe,e[89]=ge,e[90]=Ne):Ne=e[90];let ke;e[91]!==ye||e[92]!==Ne?(ke=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[ye,Ne]}),e[91]=ye,e[92]=Ne,e[93]=ke):ke=e[93];let je;return e[94]!==l||e[95]!==B||e[96]!==M||e[97]!==se||e[98]!==ne||e[99]!==ue||e[100]!==fe||e[101]!==ve||e[102]!==xe||e[103]!==ke?(je=(0,t.jsxs)(Ve,{label:B,onClose:l,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[M,se,ne,ue,fe,ve,xe,ke]}),e[94]=l,e[95]=B,e[96]=M,e[97]=se,e[98]=ne,e[99]=ue,e[100]=fe,e[101]=ve,e[102]=xe,e[103]=ke,e[104]=je):je=e[104],je},"st"),Ee=r(u=>{let e=(0,Z.c)(2),{children:l}=u,s;return e[0]!==l?(s=(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l}),e[0]=l,e[1]=s):s=e[1],s},"Le"),nt=r(u=>{let e=(0,Z.c)(29),{busy:l,runAction:s,userId:c,version:a}=u,o=E(),i=W(),[n,m]=(0,k.useState)(null),[w,S]=(0,k.useState)(null),b;e[0]!==o||e[1]!==c?(b=r(()=>{ze((async()=>{S(null);try{let x=await o.listAuthSessions({limit:50,userId:c});m(x.rows)}catch(x){let F=x;m(null),S(Be(F))}})())},"x"),e[0]=o,e[1]=c,e[2]=b):b=e[2];let C;e[3]!==o||e[4]!==c||e[5]!==a?(C=[o,c,a],e[3]=o,e[4]=c,e[5]=a,e[6]=C):C=e[6],(0,k.useEffect)(b,C);let y;e[7]!==o||e[8]!==s?(y=r(x=>{s(()=>o.revokeAuthSession({sessionId:x}))},"y"),e[7]=o,e[8]=s,e[9]=y):y=e[9];let I=y,h;e[10]!==i?(h=i("Sessions"),e[10]=i,e[11]=h):h=e[11];let g;e[12]!==h?(g=(0,t.jsx)(Ee,{children:h}),e[12]=h,e[13]=g):g=e[13];let v;e[14]!==w?(v=w!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:w}),e[14]=w,e[15]=v):v=e[15];let f;e[16]!==n||e[17]!==i?(f=n!==null&&n.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:i("No active sessions.")}),e[16]=n,e[17]=i,e[18]=f):f=e[18];let d;e[19]!==l||e[20]!==I||e[21]!==n||e[22]!==i?(d=n!==null&&n.length>0&&(0,t.jsx)(we,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(Ue,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(L,{children:[(0,t.jsx)(U,{children:i("expires")}),(0,t.jsx)(U,{children:i("ip")}),(0,t.jsx)(U,{children:i("user agent")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Re,{children:n.map(x=>(0,t.jsxs)(L,{"data-testid":`ud-session-${x.id}`,children:[(0,t.jsx)(_,{className:"text-muted-foreground tabular-nums",children:Ie(x.expiresAt)}),(0,t.jsx)(_,{children:x.ipAddress??""}),(0,t.jsx)(_,{className:"max-w-40 truncate",children:x.userAgent??""}),(0,t.jsx)(_,{children:(0,t.jsx)(z,{"data-testid":`ud-revoke-${x.id}`,disabled:l,onClick:r(()=>{I(x.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Revoke")})})]},x.id))})]})})}),e[19]=l,e[20]=I,e[21]=n,e[22]=i,e[23]=d):d=e[23];let A;return e[24]!==g||e[25]!==v||e[26]!==f||e[27]!==d?(A=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[g,v,f,d]}),e[24]=g,e[25]=v,e[26]=f,e[27]=d,e[28]=A):A=e[28],A},"rt"),dt=r(u=>{let e=(0,Z.c)(30),{busy:l,runAction:s,userId:c,version:a}=u,o=E(),i=W(),[n,m]=(0,k.useState)(null),[w,S]=(0,k.useState)(null),b;e[0]!==o||e[1]!==c?(b=r(()=>{ze((async()=>{S(null);try{m(await o.listAuthAccounts({userId:c}))}catch(x){let F=x;m(null),S(Be(F))}})())},"x"),e[0]=o,e[1]=c,e[2]=b):b=e[2];let C;e[3]!==o||e[4]!==c||e[5]!==a?(C=[o,c,a],e[3]=o,e[4]=c,e[5]=a,e[6]=C):C=e[6],(0,k.useEffect)(b,C);let y;e[7]!==o||e[8]!==s||e[9]!==c?(y=r(x=>{s(()=>o.unlinkAuthAccount({accountId:x,userId:c}))},"y"),e[7]=o,e[8]=s,e[9]=c,e[10]=y):y=e[10];let I=y,h;e[11]!==i?(h=i("Linked accounts"),e[11]=i,e[12]=h):h=e[12];let g;e[13]!==h?(g=(0,t.jsx)(Ee,{children:h}),e[13]=h,e[14]=g):g=e[14];let v;e[15]!==w?(v=w!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:w}),e[15]=w,e[16]=v):v=e[16];let f;e[17]!==n||e[18]!==i?(f=n!==null&&n.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:i("No linked accounts.")}),e[17]=n,e[18]=i,e[19]=f):f=e[19];let d;e[20]!==n||e[21]!==l||e[22]!==I||e[23]!==i?(d=n!==null&&n.length>0&&(0,t.jsx)(we,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(Ue,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(L,{children:[(0,t.jsx)(U,{children:i("provider")}),(0,t.jsx)(U,{children:i("created")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Re,{children:n.map(x=>{let F=Ae(x.id);return(0,t.jsxs)(L,{"data-testid":`ud-account-${F}`,children:[(0,t.jsx)(_,{children:Ae(x.providerId)}),(0,t.jsx)(_,{className:"text-muted-foreground tabular-nums",children:Ie(x.createdAt)}),(0,t.jsx)(_,{children:(0,t.jsx)(z,{"data-testid":`ud-unlink-${F}`,disabled:l,onClick:r(()=>{I(F)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Unlink")})})]},F)})})]})})}),e[20]=n,e[21]=l,e[22]=I,e[23]=i,e[24]=d):d=e[24];let A;return e[25]!==g||e[26]!==v||e[27]!==f||e[28]!==d?(A=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[g,v,f,d]}),e[25]=g,e[26]=v,e[27]=f,e[28]=d,e[29]=A):A=e[29],A},"it"),ot=r(u=>{let e=(0,Z.c)(40),{busy:l,capabilities:s,runAction:c,userId:a,version:o}=u,i=E(),n=W(),[m,w]=(0,k.useState)(null),S;e[0]!==s.passkey||e[1]!==i||e[2]!==a?(S=r(()=>{s.passkey&&ze((async()=>{try{w(await i.listAuthPasskeys({userId:a}))}catch{w(null)}})())},"I"),e[0]=s.passkey,e[1]=i,e[2]=a,e[3]=S):S=e[3];let b;e[4]!==s.passkey||e[5]!==i||e[6]!==a||e[7]!==o?(b=[s.passkey,i,a,o],e[4]=s.passkey,e[5]=i,e[6]=a,e[7]=o,e[8]=b):b=e[8],(0,k.useEffect)(S,b);let C;e[9]!==i||e[10]!==c||e[11]!==a?(C=r(()=>{c(()=>i.disableAuthTwoFactor({userId:a}))},"w"),e[9]=i,e[10]=c,e[11]=a,e[12]=C):C=e[12];let y=C,I;e[13]!==i||e[14]!==c?(I=r(F=>{c(()=>i.deleteAuthPasskey({passkeyId:F}))},"A"),e[13]=i,e[14]=c,e[15]=I):I=e[15];let h=I,g;e[16]!==n?(g=n("Security"),e[16]=n,e[17]=g):g=e[17];let v;e[18]!==g?(v=(0,t.jsx)(Ee,{children:g}),e[18]=g,e[19]=v):v=e[19];let f;e[20]!==l||e[21]!==s.twoFactor||e[22]!==y||e[23]!==n?(f=s.twoFactor&&(0,t.jsx)(z,{"data-testid":"ud-disable-2fa",disabled:l,onClick:y,size:"sm",type:"button",variant:"outline",children:n("Disable two-factor")}),e[20]=l,e[21]=s.twoFactor,e[22]=y,e[23]=n,e[24]=f):f=e[24];let d;e[25]!==s.passkey||e[26]!==m||e[27]!==n?(d=s.passkey&&m!==null&&m.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:n("No passkeys.")}),e[25]=s.passkey,e[26]=m,e[27]=n,e[28]=d):d=e[28];let A;e[29]!==l||e[30]!==s.passkey||e[31]!==h||e[32]!==m||e[33]!==n?(A=s.passkey&&m!==null&&m.length>0&&(0,t.jsx)(we,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(Ue,{"data-testid":"ud-passkeys-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(L,{children:[(0,t.jsx)(U,{children:n("name")}),(0,t.jsx)(U,{children:n("created")}),(0,t.jsx)(U,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Re,{children:m.map(F=>{let O=Ae(F.id);return(0,t.jsxs)(L,{"data-testid":`ud-passkey-${O}`,children:[(0,t.jsx)(_,{children:Ae(F.name)||O}),(0,t.jsx)(_,{className:"text-muted-foreground tabular-nums",children:Ie(F.createdAt)}),(0,t.jsx)(_,{children:(0,t.jsx)(z,{"data-testid":`ud-delete-passkey-${O}`,disabled:l,onClick:r(()=>{h(O)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Delete")})})]},O)})})]})})}),e[29]=l,e[30]=s.passkey,e[31]=h,e[32]=m,e[33]=n,e[34]=A):A=e[34];let x;return e[35]!==v||e[36]!==f||e[37]!==d||e[38]!==A?(x=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[v,f,d,A]}),e[35]=v,e[36]=f,e[37]=d,e[38]=A,e[39]=x):x=e[39],x},"nt"),ct=/(?:at|expires)$/iu,ut=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),mt=r((u,e)=>typeof e=="number"&&ct.test(u)?Ie(e):Ae(e),"ct"),ht=r(({capabilities:u,onChanged:e,onClose:l,user:s})=>{let c=E(),a=W(),o=s.banned===!0,[i,n]=(0,k.useState)(null),[m,w]=(0,k.useState)(!1),[S,b]=(0,k.useState)(0),[C,y]=(0,k.useState)(typeof s.role=="string"?s.role:""),[I,h]=(0,k.useState)(""),[g,v]=(0,k.useState)(""),[f,d]=(0,k.useState)(""),[A,x]=(0,k.useState)(null),[F,O]=(0,k.useState)(!1),$=r((N,B)=>{ze((async()=>{w(!0),n(null);try{let q=await N();B?.refresh!==!1&&(b(M=>M+1),e()),B?.onResult?.(q)}catch(q){n(Be(q))}w(!1)})())},"R"),Pe=r(N=>{y(N.target.value)},"De"),G=r(N=>{h(N.target.value)},"O"),Te=r(N=>{v(N.target.value)},"je"),H=r(N=>{d(N.target.value)},"G"),$e=r(()=>{let N=C.trim();N!==""&&$(async()=>{await c.setAuthUserRole({role:N,userId:s.id})})},"Se"),J=r(()=>{let N=Number.parseInt(g,10),B=Number.isFinite(N)&&N>0?N*86400:void 0;$(async()=>{await c.banAuthUser({expiresInSeconds:B,reason:I.trim()===""?void 0:I.trim(),userId:s.id})})},"H"),j=r(()=>{$(async()=>{await c.unbanAuthUser({userId:s.id})})},"_"),K=r(()=>{$(async()=>{await c.setAuthUserPassword({newPassword:f,userId:s.id}),d("")})},"J"),Fe=r(()=>{$(()=>c.impersonateAuthUser({userId:s.id}),{onResult:r(N=>{x(N.token)},"onResult"),refresh:!1})},"we"),Q=r(()=>{$(async()=>{await c.revokeAuthUserSessions({userId:s.id})})},"K"),De=r(()=>{$(async()=>{await c.removeAuthUser({userId:s.id}),l()})},"Te"),X=r(()=>{O(!0)},"W"),Se=r(()=>{O(!1)},"Ce"),Y=Object.entries(s).filter(([N])=>!ut.has(N));return(0,t.jsxs)(Ve,{label:a("User details"),onClose:l,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:s.name??s.email??s.id}),(0,t.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:s.id}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof s.role=="string"&&s.role!==""&&(0,t.jsx)(T,{variant:"secondary",children:s.role}),o?(0,t.jsx)(T,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(T,{variant:"outline",children:a("Active")}),s.emailVerified===!0?(0,t.jsx)(T,{variant:"secondary",children:a("verified")}):(0,t.jsx)(T,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(z,{"data-testid":"ud-close",onClick:l,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),i!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:i}),u.admin&&(0,t.jsxs)(we,{className:"gap-0 py-0",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Actions")})}),(0,t.jsxs)(Ce,{className:"flex flex-col gap-3 p-3",children:[(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(D,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(P,{"data-testid":"ud-role-input",id:"ud-role",onChange:Pe,value:C})]}),(0,t.jsx)(z,{"data-testid":"ud-set-role",disabled:m||C.trim()==="",onClick:$e,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),o?(0,t.jsx)(z,{"data-testid":"ud-unban",disabled:m,onClick:j,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(D,{htmlFor:"ud-ban-reason",children:a("Ban reason (optional)")}),(0,t.jsx)(P,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:G,value:I})]}),(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[(0,t.jsx)(D,{htmlFor:"ud-ban-days",children:a("Days")}),(0,t.jsx)(P,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:Te,type:"number",value:g})]}),(0,t.jsx)(z,{"data-testid":"ud-ban",disabled:m,onClick:J,size:"sm",type:"button",variant:"destructive",children:a("Ban user")})]}),(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(D,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(P,{"data-testid":"ud-password",id:"ud-password",onChange:H,type:"password",value:f})]}),(0,t.jsx)(z,{"data-testid":"ud-set-password",disabled:m||f==="",onClick:K,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(z,{"data-testid":"ud-impersonate",disabled:m,onClick:Fe,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(z,{"data-testid":"ud-revoke-all",disabled:m,onClick:Q,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),F?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(z,{"data-testid":"ud-delete-confirm",disabled:m,onClick:De,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(z,{"data-testid":"ud-delete-cancel",onClick:Se,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(z,{"data-testid":"ud-delete",disabled:m,onClick:X,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),A!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(D,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(P,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:A})]})]})]}),(0,t.jsx)(nt,{busy:m,runAction:$,userId:s.id,version:S}),u.accounts&&(0,t.jsx)(dt,{busy:m,runAction:$,userId:s.id,version:S}),(u.twoFactor||u.passkey)&&(0,t.jsx)(ot,{busy:m,capabilities:u,runAction:$,userId:s.id,version:S}),(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Fields")}),(0,t.jsx)("dl",{className:"flex flex-col",children:Y.map(([N,B])=>(0,t.jsxs)("div",{className:"flex flex-col border-t border-border py-1.5",children:[(0,t.jsx)("dt",{className:"text-xs font-semibold text-muted-foreground",children:N}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:mt(N,B)})]},N))})]})]})},"ut"),pt=50,Rt=r(({pageSize:u=pt}={})=>{let e=E(),l=W(),[s,c]=(0,k.useState)(""),[a,o]=(0,k.useState)(""),i=Ke(s),[n,m]=(0,k.useState)(null),[w,S]=(0,k.useState)(!1),{capabilities:b}=at(),C=i.trim(),y=a.trim(),I=Ge(["lunora-auth-users",C,y,u],()=>e.listAuthUsers({filterField:y===""?void 0:"role",filterValue:y===""?void 0:y,limit:u,search:C===""?void 0:C}),{keepPreviousData:!0}),h=I.data?.rows??null,g=I.error,v=r(()=>{I.refetch()},"v");He(()=>{I.refetch()},!0);let f=n===null?null:h?.find(d=>d.id===n)??null;return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(P,{"aria-label":l("Search users"),className:"w-56","data-testid":"us-search",onChange:r(d=>{c(d.target.value)},"onChange"),placeholder:l("Search by email or name\u2026"),value:s}),(0,t.jsx)(P,{"aria-label":l("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:r(d=>{o(d.target.value)},"onChange"),placeholder:l("Filter by role"),value:a}),(0,t.jsx)(z,{"data-testid":"us-new",onClick:r(()=>{S(!0)},"onClick"),size:"sm",type:"button",children:l("New user")})]}),g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:g}),h!==null&&h.length===0&&(0,t.jsx)(Ze,{description:l("Users who sign up to your app will appear here."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:l("No users.")}),h!==null&&h.length>0&&(0,t.jsx)(we,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(Ue,{"data-testid":"us-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(L,{children:[(0,t.jsx)(U,{children:l("id")}),(0,t.jsx)(U,{children:l("email")}),(0,t.jsx)(U,{children:l("name")}),(0,t.jsx)(U,{children:l("role")}),(0,t.jsx)(U,{children:l("status")}),(0,t.jsx)(U,{children:l("verified")}),(0,t.jsx)(U,{children:l("created")}),(0,t.jsx)(U,{"aria-label":l("Actions")})]})}),(0,t.jsx)(Re,{children:h.map(d=>(0,t.jsxs)(L,{"data-testid":`us-row-${d.id}`,children:[(0,t.jsx)(_,{className:"font-mono text-xs",children:d.id}),(0,t.jsx)(_,{children:d.email??""}),(0,t.jsx)(_,{children:d.name??""}),(0,t.jsx)(_,{children:typeof d.role=="string"&&d.role!==""?(0,t.jsx)(T,{variant:"secondary",children:d.role}):""}),(0,t.jsx)(_,{children:d.banned===!0?(0,t.jsx)(T,{variant:"destructive",children:l("Banned")}):(0,t.jsx)(T,{variant:"success",children:l("Active")})}),(0,t.jsx)(_,{children:d.emailVerified===!0?(0,t.jsx)(T,{variant:"success",children:l("yes")}):(0,t.jsx)(T,{variant:"outline",children:l("no")})}),(0,t.jsx)(_,{className:"text-muted-foreground tabular-nums",children:Ie(d.createdAt)}),(0,t.jsx)(_,{children:(0,t.jsx)(z,{"data-testid":`us-manage-${d.id}`,onClick:r(()=>{m(d.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Manage")})})]},d.id))})]})})}),f!==null&&(0,t.jsx)(ht,{capabilities:b,onChanged:v,onClose:r(()=>{m(null)},"onClose"),user:f}),w&&(0,t.jsx)(it,{onClose:r(()=>{S(!1)},"onClose"),onCreated:v})]})},"Rt");export{Rt as UsersPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as te}from"./chunk-V53KNYRN.js";import{R as Z}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as I}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{a as K}from"./chunk-VDW32UET.js";import{c as ee}from"./chunk-TS6346VY.js";import{f as M}from"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{a as q}from"./chunk-XQCVZAGU.js";import{a as z,b as D,c as F,d as h,e as o,f as i}from"./chunk-MIQTKZAR.js";import{a as T,e as j}from"./chunk-UZERI5YC.js";import{d as H,f as Q,g as V,h as W,m as $}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as n,e as Y,f as ne,h as le}from"./chunk-3XIESWL4.js";var c=Y(ne(),1);var e=Y(le(),1);var oe=["queued","running","paused","waiting","complete","errored","terminated"],ie=["pause","resume","terminate"],de="WORKFLOWS_NOT_CONFIGURED",ce=n(l=>typeof l=="object"&&l!==null&&l.code===de,"ie"),me=n(l=>{let r=l.error??l.output;if(r===void 0)return"\u2014";try{return JSON.stringify(r)}catch{return"(unserializable)"}},"de"),ue=n(({loadDetail:l,loadInstances:r,readOnly:N,runAction:R,workflowName:g})=>{let A=M(),s=H(),[p,k]=(0,c.useState)(null),[S,O]=(0,c.useState)(null),[v,_]=(0,c.useState)(""),[b,f]=(0,c.useState)(null),[J,C]=(0,c.useState)(!1),[L,P]=(0,c.useState)(null),w=l??(a=>A.getWorkflowInstance(a)),x=N?void 0:R??(r===void 0?a=>A.setWorkflowInstanceStatus(a):void 0),E=n(async()=>{f(null),C(!1);let a=v===""?void 0:v;try{if(r===void 0){let d=await A.listWorkflowInstances({name:g,status:a});if(d.configured===!1){k(null),C(!0);return}k(d.instances);return}k(await r({name:g,status:a}))}catch(d){k(null),ce(d)?C(!0):f(W(d))}},"O");(0,c.useEffect)(()=>{O(null),$(E())},[g,v]);let U=n(async a=>{f(null);try{O(await w({id:a,name:g}))}catch(d){f(W(d))}},"D"),B=n(async(a,d)=>{if(x!==void 0){P(a),f(null);try{await x({action:d,id:a,name:g}),await E()}catch(G){f(W(G))}P(null)}},"K");return(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:s("Instance history")}),(0,e.jsxs)("select",{"aria-label":s("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:n(a=>{_(a.target.value)},"onChange"),value:v,children:[(0,e.jsx)("option",{value:"",children:s("All statuses")}),oe.map(a=>(0,e.jsx)("option",{value:a,children:a},a))]})]}),b!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:b}),J&&(0,e.jsx)(q,{description:s("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:s("Workflow inspection not configured")}),!J&&p!==null&&p.length===0&&(0,e.jsx)(q,{description:s("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:s("No instances")}),p!==null&&p.length>0&&(0,e.jsx)(T,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(z,{"data-testid":"workflow-instances-table",children:[(0,e.jsx)(D,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:s("Instance id")}),(0,e.jsx)(o,{children:s("Status")}),(0,e.jsx)(o,{children:s("Created")}),(0,e.jsx)(o,{children:s("Ended")}),(0,e.jsx)(o,{"aria-label":s("Actions")})]})}),(0,e.jsx)(F,{children:p.map(a=>(0,e.jsxs)(h,{"data-testid":`workflow-instance-${a.id}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:a.id}),(0,e.jsx)(i,{className:"font-mono text-xs",children:a.status}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.createdOn??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.endedOn??"\u2014"}),(0,e.jsx)(i,{className:"text-right",children:(0,e.jsxs)("div",{className:"flex justify-end gap-1.5",children:[(0,e.jsx)(I,{"data-testid":`workflow-instance-steps-${a.id}`,onClick:n(()=>{$(U(a.id))},"onClick"),size:"sm",type:"button",variant:"outline",children:s("Steps")}),x!==void 0&&ie.map(d=>(0,e.jsx)(I,{"data-testid":`workflow-instance-${d}-${a.id}`,disabled:L===a.id,onClick:n(()=>{$(B(a.id,d))},"onClick"),size:"sm",type:"button",variant:"ghost",children:s(d)},d))]})})]},a.id))})]})})}),S!==null&&(0,e.jsx)(T,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:(0,e.jsxs)(j,{className:"flex flex-col gap-2 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[s("Steps")," \xB7 ",S.id]}),(0,e.jsx)(I,{"data-testid":"workflow-instance-detail-close",onClick:n(()=>{O(null)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Close")})]}),S.steps.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:s("This instance has no recorded steps yet.")}):(0,e.jsxs)(z,{"data-testid":"workflow-instance-steps",children:[(0,e.jsx)(D,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:s("Step")}),(0,e.jsx)(o,{children:s("Type")}),(0,e.jsx)(o,{children:s("Attempts")}),(0,e.jsx)(o,{children:s("Started")}),(0,e.jsx)(o,{children:s("Output")})]})}),(0,e.jsx)(F,{children:S.steps.map((a,d)=>(0,e.jsxs)(h,{"data-testid":`workflow-step-${String(d)}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:a.name}),(0,e.jsx)(i,{className:"text-xs text-muted-foreground",children:a.type??"\u2014"}),(0,e.jsx)(i,{className:"tabular-nums",children:a.attempts??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.start??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:me(a)})]},`${a.name}:${String(d)}`))})]})]})})]})},"ce"),fe=Q(K.createWorkflowInstance),he=Q(K.getWorkflowInstanceStatus),pe=n(l=>{if(l.error)return`${l.error.name}: ${l.error.message}`;if(l.output===void 0)return"\u2014";try{return JSON.stringify(l.output)}catch{return"(unserializable)"}},"fe"),we=n((l,r)=>l.some(N=>N.exportName===r)?r:l[0]?.exportName??"","he"),We=n(()=>{let l=M(),r=H(),{data:N,error:R}=ee(K.listWorkflows,{}),[g,A]=(0,c.useState)(""),[s,p]=(0,c.useState)(""),[k,S]=(0,c.useState)(""),[O,v]=(0,c.useState)(!1),[_,b]=(0,c.useState)(null),[f,J]=(0,c.useState)([]),[C,L]=(0,c.useState)(null),P=N!==void 0,w=Array.isArray(N?.workflows)?[...N.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],x=we(w,g),E=w.find(t=>t.exportName===x),U=n(t=>{J(u=>{let m=u.filter(y=>!(y.exportName===t.exportName&&y.id===t.id));return[t,...m]})},"D"),B=n(async()=>{let t=x;if(t==="")return;let u,m=k.trim();if(m!=="")try{u=JSON.parse(m)}catch{b(r("Params must be valid JSON"));return}v(!0),b(null);try{let y=s.trim(),X=await l.query(fe,{exportName:t,id:y===""?void 0:y,params:u},V(""));U({exportName:t,id:X.id,status:X.status}),p("")}catch(y){b(W(y))}v(!1)},"K"),a=n(()=>{$(B())},"a"),d=n(async(t,u)=>{L(u);try{let m=await l.query(he,{exportName:t,id:u},V(""));U({error:m.error,exportName:t,id:m.id,output:m.output,status:m.status})}catch(m){b(W(m))}L(null)},"l"),G=n(t=>{A(t.target.value)},"P"),ae=n(t=>{p(t.target.value)},"Y"),re=n(t=>{S(t.target.value)},"Z"),se=n(t=>{let{export:u,id:m}=t.currentTarget.dataset;u!==void 0&&m!==void 0&&$(d(u,m))},"ee");return(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[R!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:R}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:r("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),P&&w.length===0?(0,e.jsx)(q,{description:r("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:r("No workflows defined")}):(0,e.jsx)(T,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(z,{"data-testid":"workflows-table",children:[(0,e.jsx)(D,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:r("Export")}),(0,e.jsx)(o,{children:r("Name")}),(0,e.jsx)(o,{children:r("Class")}),(0,e.jsx)(o,{children:r("Binding")})]})}),(0,e.jsx)(F,{children:w.map(t=>(0,e.jsxs)(h,{"data-testid":`workflows-row-${t.exportName}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.name}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.className}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.binding})]},t.exportName))})]})})}),w.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:r("Start instance")}),_!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:_}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("select",{"aria-label":r("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:G,value:x,children:w.map(t=>(0,e.jsx)("option",{value:t.exportName,children:t.exportName},t.exportName))}),(0,e.jsx)(Z,{"aria-label":r("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:ae,placeholder:r("Instance id (optional)"),value:s}),(0,e.jsx)(I,{"data-testid":"workflows-start-button",disabled:O||x==="",onClick:a,children:r(O?"Starting\u2026":"Start instance")})]}),(0,e.jsx)(te,{"aria-label":r("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:re,placeholder:r("Params (JSON, optional)"),value:k})]}),f.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:r("Instances")}),(0,e.jsx)(T,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(z,{"data-testid":"workflows-instances-table",children:[(0,e.jsx)(D,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:r("Workflow")}),(0,e.jsx)(o,{children:r("Instance id")}),(0,e.jsx)(o,{children:r("Status")}),(0,e.jsx)(o,{children:r("Output")}),(0,e.jsx)(o,{})]})}),(0,e.jsx)(F,{children:f.map(t=>(0,e.jsxs)(h,{"data-testid":`workflows-instance-${t.id}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.id}),(0,e.jsx)(i,{className:"font-mono text-xs",children:t.status}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:pe(t)}),(0,e.jsx)(i,{children:(0,e.jsx)(I,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:C===t.id,onClick:se,size:"xs",variant:"outline",children:C===t.id?r("Refreshing\u2026"):r("Refresh")})})]},`${t.exportName}:${t.id}`))})]})})})]}),E!==void 0&&(0,e.jsx)(ue,{workflowName:E.name})]})},"Oe");export{We as default};
|
|
1
|
+
import{a as te}from"./chunk-V53KNYRN.js";import{R as Z}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as I}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{a as K}from"./chunk-VDW32UET.js";import{c as ee}from"./chunk-SHMNA6UL.js";import{f as M}from"./chunk-V2U5CL3S.js";import"./chunk-XBDKZZ67.js";import{a as q}from"./chunk-XQCVZAGU.js";import{a as z,b as D,c as F,d as h,e as o,f as i}from"./chunk-MIQTKZAR.js";import{a as T,e as j}from"./chunk-UZERI5YC.js";import{d as H,f as Q,g as V,h as W,m as $}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as n,e as Y,f as ne,h as le}from"./chunk-3XIESWL4.js";var c=Y(ne(),1);var e=Y(le(),1);var oe=["queued","running","paused","waiting","complete","errored","terminated"],ie=["pause","resume","terminate"],de="WORKFLOWS_NOT_CONFIGURED",ce=n(l=>typeof l=="object"&&l!==null&&l.code===de,"ie"),me=n(l=>{let r=l.error??l.output;if(r===void 0)return"\u2014";try{return JSON.stringify(r)}catch{return"(unserializable)"}},"de"),ue=n(({loadDetail:l,loadInstances:r,readOnly:N,runAction:R,workflowName:g})=>{let A=M(),s=H(),[p,k]=(0,c.useState)(null),[S,O]=(0,c.useState)(null),[v,_]=(0,c.useState)(""),[b,f]=(0,c.useState)(null),[J,C]=(0,c.useState)(!1),[L,P]=(0,c.useState)(null),w=l??(a=>A.getWorkflowInstance(a)),x=N?void 0:R??(r===void 0?a=>A.setWorkflowInstanceStatus(a):void 0),E=n(async()=>{f(null),C(!1);let a=v===""?void 0:v;try{if(r===void 0){let d=await A.listWorkflowInstances({name:g,status:a});if(d.configured===!1){k(null),C(!0);return}k(d.instances);return}k(await r({name:g,status:a}))}catch(d){k(null),ce(d)?C(!0):f(W(d))}},"O");(0,c.useEffect)(()=>{O(null),$(E())},[g,v]);let U=n(async a=>{f(null);try{O(await w({id:a,name:g}))}catch(d){f(W(d))}},"D"),B=n(async(a,d)=>{if(x!==void 0){P(a),f(null);try{await x({action:d,id:a,name:g}),await E()}catch(G){f(W(G))}P(null)}},"K");return(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:s("Instance history")}),(0,e.jsxs)("select",{"aria-label":s("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:n(a=>{_(a.target.value)},"onChange"),value:v,children:[(0,e.jsx)("option",{value:"",children:s("All statuses")}),oe.map(a=>(0,e.jsx)("option",{value:a,children:a},a))]})]}),b!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:b}),J&&(0,e.jsx)(q,{description:s("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:s("Workflow inspection not configured")}),!J&&p!==null&&p.length===0&&(0,e.jsx)(q,{description:s("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:s("No instances")}),p!==null&&p.length>0&&(0,e.jsx)(T,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(z,{"data-testid":"workflow-instances-table",children:[(0,e.jsx)(D,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:s("Instance id")}),(0,e.jsx)(o,{children:s("Status")}),(0,e.jsx)(o,{children:s("Created")}),(0,e.jsx)(o,{children:s("Ended")}),(0,e.jsx)(o,{"aria-label":s("Actions")})]})}),(0,e.jsx)(F,{children:p.map(a=>(0,e.jsxs)(h,{"data-testid":`workflow-instance-${a.id}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:a.id}),(0,e.jsx)(i,{className:"font-mono text-xs",children:a.status}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.createdOn??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.endedOn??"\u2014"}),(0,e.jsx)(i,{className:"text-right",children:(0,e.jsxs)("div",{className:"flex justify-end gap-1.5",children:[(0,e.jsx)(I,{"data-testid":`workflow-instance-steps-${a.id}`,onClick:n(()=>{$(U(a.id))},"onClick"),size:"sm",type:"button",variant:"outline",children:s("Steps")}),x!==void 0&&ie.map(d=>(0,e.jsx)(I,{"data-testid":`workflow-instance-${d}-${a.id}`,disabled:L===a.id,onClick:n(()=>{$(B(a.id,d))},"onClick"),size:"sm",type:"button",variant:"ghost",children:s(d)},d))]})})]},a.id))})]})})}),S!==null&&(0,e.jsx)(T,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:(0,e.jsxs)(j,{className:"flex flex-col gap-2 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[s("Steps")," \xB7 ",S.id]}),(0,e.jsx)(I,{"data-testid":"workflow-instance-detail-close",onClick:n(()=>{O(null)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Close")})]}),S.steps.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:s("This instance has no recorded steps yet.")}):(0,e.jsxs)(z,{"data-testid":"workflow-instance-steps",children:[(0,e.jsx)(D,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:s("Step")}),(0,e.jsx)(o,{children:s("Type")}),(0,e.jsx)(o,{children:s("Attempts")}),(0,e.jsx)(o,{children:s("Started")}),(0,e.jsx)(o,{children:s("Output")})]})}),(0,e.jsx)(F,{children:S.steps.map((a,d)=>(0,e.jsxs)(h,{"data-testid":`workflow-step-${String(d)}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:a.name}),(0,e.jsx)(i,{className:"text-xs text-muted-foreground",children:a.type??"\u2014"}),(0,e.jsx)(i,{className:"tabular-nums",children:a.attempts??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.start??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:me(a)})]},`${a.name}:${String(d)}`))})]})]})})]})},"ce"),fe=Q(K.createWorkflowInstance),he=Q(K.getWorkflowInstanceStatus),pe=n(l=>{if(l.error)return`${l.error.name}: ${l.error.message}`;if(l.output===void 0)return"\u2014";try{return JSON.stringify(l.output)}catch{return"(unserializable)"}},"fe"),we=n((l,r)=>l.some(N=>N.exportName===r)?r:l[0]?.exportName??"","he"),We=n(()=>{let l=M(),r=H(),{data:N,error:R}=ee(K.listWorkflows,{}),[g,A]=(0,c.useState)(""),[s,p]=(0,c.useState)(""),[k,S]=(0,c.useState)(""),[O,v]=(0,c.useState)(!1),[_,b]=(0,c.useState)(null),[f,J]=(0,c.useState)([]),[C,L]=(0,c.useState)(null),P=N!==void 0,w=Array.isArray(N?.workflows)?[...N.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],x=we(w,g),E=w.find(t=>t.exportName===x),U=n(t=>{J(u=>{let m=u.filter(y=>!(y.exportName===t.exportName&&y.id===t.id));return[t,...m]})},"D"),B=n(async()=>{let t=x;if(t==="")return;let u,m=k.trim();if(m!=="")try{u=JSON.parse(m)}catch{b(r("Params must be valid JSON"));return}v(!0),b(null);try{let y=s.trim(),X=await l.query(fe,{exportName:t,id:y===""?void 0:y,params:u},V(""));U({exportName:t,id:X.id,status:X.status}),p("")}catch(y){b(W(y))}v(!1)},"K"),a=n(()=>{$(B())},"a"),d=n(async(t,u)=>{L(u);try{let m=await l.query(he,{exportName:t,id:u},V(""));U({error:m.error,exportName:t,id:m.id,output:m.output,status:m.status})}catch(m){b(W(m))}L(null)},"l"),G=n(t=>{A(t.target.value)},"P"),ae=n(t=>{p(t.target.value)},"Y"),re=n(t=>{S(t.target.value)},"Z"),se=n(t=>{let{export:u,id:m}=t.currentTarget.dataset;u!==void 0&&m!==void 0&&$(d(u,m))},"ee");return(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[R!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:R}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:r("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),P&&w.length===0?(0,e.jsx)(q,{description:r("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:r("No workflows defined")}):(0,e.jsx)(T,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(z,{"data-testid":"workflows-table",children:[(0,e.jsx)(D,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:r("Export")}),(0,e.jsx)(o,{children:r("Name")}),(0,e.jsx)(o,{children:r("Class")}),(0,e.jsx)(o,{children:r("Binding")})]})}),(0,e.jsx)(F,{children:w.map(t=>(0,e.jsxs)(h,{"data-testid":`workflows-row-${t.exportName}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.name}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.className}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.binding})]},t.exportName))})]})})}),w.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:r("Start instance")}),_!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:_}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("select",{"aria-label":r("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:G,value:x,children:w.map(t=>(0,e.jsx)("option",{value:t.exportName,children:t.exportName},t.exportName))}),(0,e.jsx)(Z,{"aria-label":r("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:ae,placeholder:r("Instance id (optional)"),value:s}),(0,e.jsx)(I,{"data-testid":"workflows-start-button",disabled:O||x==="",onClick:a,children:r(O?"Starting\u2026":"Start instance")})]}),(0,e.jsx)(te,{"aria-label":r("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:re,placeholder:r("Params (JSON, optional)"),value:k})]}),f.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:r("Instances")}),(0,e.jsx)(T,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(z,{"data-testid":"workflows-instances-table",children:[(0,e.jsx)(D,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:r("Workflow")}),(0,e.jsx)(o,{children:r("Instance id")}),(0,e.jsx)(o,{children:r("Status")}),(0,e.jsx)(o,{children:r("Output")}),(0,e.jsx)(o,{})]})}),(0,e.jsx)(F,{children:f.map(t=>(0,e.jsxs)(h,{"data-testid":`workflows-instance-${t.id}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.id}),(0,e.jsx)(i,{className:"font-mono text-xs",children:t.status}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:pe(t)}),(0,e.jsx)(i,{children:(0,e.jsx)(I,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:C===t.id,onClick:se,size:"xs",variant:"outline",children:C===t.id?r("Refreshing\u2026"):r("Refresh")})})]},`${t.exportName}:${t.id}`))})]})})})]}),E!==void 0&&(0,e.jsx)(ue,{workflowName:E.name})]})},"Oe");export{We as default};
|