@lunora/studio 1.0.0-alpha.40 → 1.0.0-alpha.41

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 (51) hide show
  1. package/dist/standalone/{chunk-AAVIFQ4Y.js → chunk-25AYY4H7.js} +1 -1
  2. package/dist/standalone/{chunk-Q52CHOSY.js → chunk-2ANAF4ZM.js} +1 -1
  3. package/dist/standalone/{chunk-BKW7FFEO.js → chunk-3OIHOXVV.js} +1 -1
  4. package/dist/standalone/{chunk-AJFQ3LNM.js → chunk-447TAUFD.js} +1 -1
  5. package/dist/standalone/{chunk-SSI4G2MY.js → chunk-5C4TSNE6.js} +1 -1
  6. package/dist/standalone/{chunk-DC72CQY4.js → chunk-6HSHEMZV.js} +1 -1
  7. package/dist/standalone/{chunk-676HEBIR.js → chunk-6JIZ34MB.js} +1 -1
  8. package/dist/standalone/{chunk-YTO65GHS.js → chunk-7MVSQS7B.js} +1 -1
  9. package/dist/standalone/{chunk-P5HJXCZS.js → chunk-BX5MKYOC.js} +1 -1
  10. package/dist/standalone/{chunk-V6IWFYAQ.js → chunk-EQZQOTJY.js} +1 -1
  11. package/dist/standalone/{chunk-ZE6FT5Z3.js → chunk-GTLEWM5Y.js} +1 -1
  12. package/dist/standalone/{chunk-N746FOQP.js → chunk-GUI5GFFI.js} +1 -1
  13. package/dist/standalone/{chunk-CACB34RQ.js → chunk-HN6KJXYQ.js} +1 -1
  14. package/dist/standalone/{chunk-J46WXQYL.js → chunk-HYDJNCGW.js} +1 -1
  15. package/dist/standalone/{chunk-DECHEGIC.js → chunk-HZK5RQHG.js} +1 -1
  16. package/dist/standalone/{chunk-FSGCANAU.js → chunk-IN2SYVJB.js} +1 -1
  17. package/dist/standalone/{chunk-JVODY4EP.js → chunk-IOANPSJN.js} +1 -1
  18. package/dist/standalone/{chunk-NC6MBMSI.js → chunk-ISDZPW3V.js} +1 -1
  19. package/dist/standalone/{chunk-QDBOPDJ7.js → chunk-J73VHFCL.js} +1 -1
  20. package/dist/standalone/{chunk-GMSGZDDH.js → chunk-JHKMUTIF.js} +5 -5
  21. package/dist/standalone/{chunk-CICVBMEN.js → chunk-JPRH6DPK.js} +1 -1
  22. package/dist/standalone/{chunk-PTS5TW3J.js → chunk-KA5YB3VP.js} +1 -1
  23. package/dist/standalone/{chunk-SG3ALJJU.js → chunk-KBB75WNT.js} +1 -1
  24. package/dist/standalone/{chunk-LYB5L53X.js → chunk-KQV4NGH3.js} +1 -1
  25. package/dist/standalone/{chunk-I7ZZRM7I.js → chunk-KUH4P5F5.js} +1 -1
  26. package/dist/standalone/{chunk-5ZAA2PVR.js → chunk-KYJPPVGB.js} +1 -1
  27. package/dist/standalone/{chunk-HZTGDL4L.js → chunk-L2TJVSDQ.js} +1 -1
  28. package/dist/standalone/{chunk-ERJNDIXC.js → chunk-LBN7LPVK.js} +1 -1
  29. package/dist/standalone/{chunk-NY6GDADQ.js → chunk-MLZYX5CQ.js} +1 -1
  30. package/dist/standalone/{chunk-TH45YG6Q.js → chunk-N2X2OO4V.js} +1 -1
  31. package/dist/standalone/{chunk-BXOYVWJR.js → chunk-NGKITPQP.js} +1 -1
  32. package/dist/standalone/{chunk-YNZ7ARWW.js → chunk-OZACQNKG.js} +1 -1
  33. package/dist/standalone/{chunk-NN27EDQB.js → chunk-PNDNXS5Z.js} +1 -1
  34. package/dist/standalone/{chunk-CWEAJUHW.js → chunk-Q7DMUTUE.js} +1 -1
  35. package/dist/standalone/{chunk-C7WTJLC3.js → chunk-RHZ4M2NZ.js} +1 -1
  36. package/dist/standalone/{chunk-QHFTGJPS.js → chunk-TDZ44E5I.js} +1 -1
  37. package/dist/standalone/{chunk-X33MSJPP.js → chunk-THNBTMUF.js} +1 -1
  38. package/dist/standalone/{chunk-FKACHRWO.js → chunk-TIQISBGK.js} +1 -1
  39. package/dist/standalone/{chunk-H6RKXQZU.js → chunk-TMYVNQ66.js} +1 -1
  40. package/dist/standalone/{chunk-AJULNB46.js → chunk-UJB2LEI4.js} +1 -1
  41. package/dist/standalone/{chunk-23C4TCRO.js → chunk-W3JK4YWR.js} +1 -1
  42. package/dist/standalone/{chunk-MT2J3H7O.js → chunk-W3SHEIAL.js} +2 -2
  43. package/dist/standalone/chunk-WIHXMNUY.js +1 -0
  44. package/dist/standalone/{chunk-XRNXOIVZ.js → chunk-WLDVXVI2.js} +1 -1
  45. package/dist/standalone/{chunk-GLUNBZRI.js → chunk-XLXNLJ4N.js} +1 -1
  46. package/dist/standalone/{chunk-OY3HD7BJ.js → chunk-YJAPWSDC.js} +1 -1
  47. package/dist/standalone/{chunk-7RE5UW27.js → chunk-ZEJB6DXU.js} +1 -1
  48. package/dist/standalone/{chunk-V7SRH36W.js → chunk-ZFNBPAIZ.js} +1 -1
  49. package/dist/standalone/studio.js +1 -1
  50. package/package.json +6 -6
  51. package/dist/standalone/chunk-WPNXY7IS.js +0 -1
@@ -1 +1 @@
1
- import{a as Oe,b as Je}from"./chunk-PTS5TW3J.js";import{a as Ke}from"./chunk-7YXOPTWI.js";import{a as qe}from"./chunk-AHILM3ZP.js";import{a as We}from"./chunk-J6J54MBP.js";import"./chunk-L7SK4ZZD.js";import{a as Ge}from"./chunk-2K47A3P6.js";import{a as De,b as Re,c as Pe,d as j,e as D,f as R}from"./chunk-GTM65MVX.js";import{a as V}from"./chunk-JSEXCW5Q.js";import"./chunk-4QHKBC77.js";import{R as B}from"./chunk-3CJW6NWG.js";import{c as U}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as Qe}from"./chunk-TAD43CG5.js";import{a as Ze}from"./chunk-C7WTJLC3.js";import{a as we,e as Ce}from"./chunk-SEU5V7I6.js";import{b as $}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as H}from"./chunk-GLUNBZRI.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as Y,g as ze,j as Ae,k as Ue,o as Fe}from"./chunk-E75ANNWX.js";import"./chunk-GMSGZDDH.js";import{a as i,e as je,f as _e,g as et,h as tt}from"./chunk-RRCPZMC2.js";var k=je(_e(),1);var Q=je(et(),1);var t=je(tt(),1);var st=i(()=>{let u=(0,Q.c)(3),{config:e,ready:a}=Oe(),l;return u[0]!==e.capabilities||u[1]!==a?(l={capabilities:e.capabilities,ready:a},u[0]=e.capabilities,u[1]=a,u[2]=l):l=u[2],l},"useAuthCapabilities"),lt={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},at=i((u,e)=>u.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:u.type!=="number"||!Number.isNaN(Number(e.trim())),"isFieldFilled"),it=i((u,e)=>{if(u.type==="boolean")return e===!0?{value:!0}:u.required?{value:!1}:void 0;let a=typeof e=="string"?e.trim():"";if(a!==""){if(u.type==="number"){let l=Number(a);return Number.isNaN(l)?void 0:{value:l}}return{value:a}}},"coerceFieldValue"),ot=i(u=>{let e=(0,Q.c)(105),{onClose:a,onCreated:l}=u,c=H(),s=Y(),{config:r}=Oe(),{busy:o,error:n,run:f}=Je(),[w,S]=(0,k.useState)(""),[x,C]=(0,k.useState)(""),[y,F]=(0,k.useState)(""),[v,g]=(0,k.useState)(""),p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let[h,d]=(0,k.useState)(p),A;e[1]===Symbol.for("react.memo_cache_sentinel")?(A=i(m=>{S(m.target.value)},"t2"),e[1]=A):A=e[1];let b=A,I;e[2]===Symbol.for("react.memo_cache_sentinel")?(I=i(m=>{C(m.target.value)},"t3"),e[2]=I):I=e[2];let M=I,E;e[3]===Symbol.for("react.memo_cache_sentinel")?(E=i(m=>{F(m.target.value)},"t4"),e[3]=E):E=e[3];let Be=E,Z;e[4]===Symbol.for("react.memo_cache_sentinel")?(Z=i(m=>{g(m.target.value)},"t5"),e[4]=Z):Z=e[4];let $e=Z,G;e[5]===Symbol.for("react.memo_cache_sentinel")?(G=i((m,P)=>{d(q=>({...q,[m]:P}))},"t6"),e[5]=G):G=e[5];let Ee=G,W;e[6]!==h?(W=i(m=>h[m.name]??(m.type==="boolean"?!1:""),"t7"),e[6]=h,e[7]=W):W=e[7];let T=W,J;if(e[8]!==r.userFields||e[9]!==T){let m;e[11]!==T?(m=i(P=>!P.required||at(P,T(P)),"t92"),e[11]=T,e[12]=m):m=e[12],J=r.userFields.every(m),e[8]=r.userFields,e[9]=T,e[10]=J}else J=e[10];let Ie=J,K;e[13]!==o||e[14]!==w||e[15]!==x||e[16]!==Ie?(K=!o&&w.trim()!==""&&x.trim()!==""&&Ie,e[13]=o,e[14]=w,e[15]=x,e[16]=Ie,e[17]=K):K=e[17];let Ve=K,X;e[18]!==r.userFields||e[19]!==T?(X=i(()=>{let m={};for(let P of r.userFields){let q=it(P,T(P));q!==void 0&&(m[P.name]=q.value)}return Object.keys(m).length===0?void 0:m},"t10"),e[18]=r.userFields,e[19]=T,e[20]=X):X=e[20];let Se=X,_;e[21]!==Se||e[22]!==c||e[23]!==w||e[24]!==x||e[25]!==a||e[26]!==l||e[27]!==y||e[28]!==v||e[29]!==f?(_=i(()=>{f(async()=>{await c.createAuthUser({data:Se(),email:w.trim(),name:x.trim(),password:y===""?void 0:y,role:v.trim()===""?void 0:v.trim()}),l(),a()})},"t11"),e[21]=Se,e[22]=c,e[23]=w,e[24]=x,e[25]=a,e[26]=l,e[27]=y,e[28]=v,e[29]=f,e[30]=_):_=e[30];let N=_,z;e[31]!==s?(z=s("Create user"),e[31]=s,e[32]=z):z=e[32];let L;e[33]!==s?(L=s("Create user"),e[33]=s,e[34]=L):L=e[34];let O;e[35]!==L?(O=(0,t.jsxDEV)("h2",{className:"text-sm font-semibold text-foreground",children:L},void 0,!1),e[35]=L,e[36]=O):O=e[36];let ee;e[37]!==s?(ee=s("email"),e[37]=s,e[38]=ee):ee=e[38];let te;e[39]!==ee?(te=(0,t.jsxDEV)(V,{htmlFor:"uc-email",children:ee},void 0,!1),e[39]=ee,e[40]=te):te=e[40];let se;e[41]!==w?(se=(0,t.jsxDEV)(B,{"data-testid":"uc-email",id:"uc-email",onChange:b,type:"email",value:w},void 0,!1),e[41]=w,e[42]=se):se=e[42];let le;e[43]!==te||e[44]!==se?(le=(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[te,se]},void 0,!0),e[43]=te,e[44]=se,e[45]=le):le=e[45];let ae;e[46]!==s?(ae=s("name"),e[46]=s,e[47]=ae):ae=e[47];let ie;e[48]!==ae?(ie=(0,t.jsxDEV)(V,{htmlFor:"uc-name",children:ae},void 0,!1),e[48]=ae,e[49]=ie):ie=e[49];let oe;e[50]!==x?(oe=(0,t.jsxDEV)(B,{"data-testid":"uc-name",id:"uc-name",onChange:M,value:x},void 0,!1),e[50]=x,e[51]=oe):oe=e[51];let ne;e[52]!==ie||e[53]!==oe?(ne=(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[ie,oe]},void 0,!0),e[52]=ie,e[53]=oe,e[54]=ne):ne=e[54];let de;e[55]!==s?(de=s("Password (optional)"),e[55]=s,e[56]=de):de=e[56];let re;e[57]!==de?(re=(0,t.jsxDEV)(V,{htmlFor:"uc-password",children:de},void 0,!1),e[57]=de,e[58]=re):re=e[58];let ce;e[59]!==y?(ce=(0,t.jsxDEV)(B,{"data-testid":"uc-password",id:"uc-password",onChange:Be,type:"password",value:y},void 0,!1),e[59]=y,e[60]=ce):ce=e[60];let ue;e[61]!==re||e[62]!==ce?(ue=(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[re,ce]},void 0,!0),e[61]=re,e[62]=ce,e[63]=ue):ue=e[63];let fe;e[64]!==s?(fe=s("Role (optional)"),e[64]=s,e[65]=fe):fe=e[65];let ve;e[66]!==fe?(ve=(0,t.jsxDEV)(V,{htmlFor:"uc-role",children:fe},void 0,!1),e[66]=fe,e[67]=ve):ve=e[67];let me;e[68]!==v?(me=(0,t.jsxDEV)(B,{"data-testid":"uc-role",id:"uc-role",onChange:$e,value:v},void 0,!1),e[68]=v,e[69]=me):me=e[69];let he;e[70]!==ve||e[71]!==me?(he=(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[ve,me]},void 0,!0),e[70]=ve,e[71]=me,e[72]=he):he=e[72];let pe;e[73]!==r.userFields||e[74]!==T||e[75]!==s?(pe=r.userFields.length>0&&(0,t.jsxDEV)("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[(0,t.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Plugin fields")},void 0,!1),r.userFields.map(m=>{let P=`uc-field-${m.name}`,q=m.required?"":` (${s("optional")})`;if(m.type==="boolean"){let Le=T(m)===!0;return(0,t.jsxDEV)("label",{className:"flex items-center gap-2",htmlFor:P,children:[(0,t.jsxDEV)(Ke,{checked:Le,"data-testid":P,id:P,onCheckedChange:i(Xe=>{Ee(m.name,Xe)},"onCheckedChange")},void 0,!1),(0,t.jsxDEV)("span",{className:"text-sm",children:[m.name,q]},void 0,!0)]},m.name,!0)}let Ye=T(m);return(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxDEV)(V,{htmlFor:P,children:[m.name,q]},void 0,!0),(0,t.jsxDEV)(B,{"data-testid":P,id:P,onChange:i(Le=>{Ee(m.name,Le.target.value)},"onChange"),type:lt[m.type],value:typeof Ye=="string"?Ye:""},void 0,!1)]},m.name,!0)})]},void 0,!0),e[73]=r.userFields,e[74]=T,e[75]=s,e[76]=pe):pe=e[76];let be;e[77]!==n?(be=n!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:n},void 0,!1),e[77]=n,e[78]=be):be=e[78];let xe;e[79]!==s?(xe=s("Cancel"),e[79]=s,e[80]=xe):xe=e[80];let ye;e[81]!==a||e[82]!==xe?(ye=(0,t.jsxDEV)(U,{"data-testid":"uc-cancel",onClick:a,size:"sm",type:"button",variant:"outline",children:xe},void 0,!1),e[81]=a,e[82]=xe,e[83]=ye):ye=e[83];let Me=!Ve,ge;e[84]!==o||e[85]!==s?(ge=s(o?"Creating\u2026":"Create"),e[84]=o,e[85]=s,e[86]=ge):ge=e[86];let Ne;e[87]!==N||e[88]!==Me||e[89]!==ge?(Ne=(0,t.jsxDEV)(U,{"data-testid":"uc-submit",disabled:Me,onClick:N,size:"sm",type:"button",children:ge},void 0,!1),e[87]=N,e[88]=Me,e[89]=ge,e[90]=Ne):Ne=e[90];let ke;e[91]!==ye||e[92]!==Ne?(ke=(0,t.jsxDEV)("div",{className:"flex justify-end gap-2 pt-1",children:[ye,Ne]},void 0,!0),e[91]=ye,e[92]=Ne,e[93]=ke):ke=e[93];let Te;return e[94]!==a||e[95]!==z||e[96]!==O||e[97]!==le||e[98]!==ne||e[99]!==ue||e[100]!==he||e[101]!==pe||e[102]!==be||e[103]!==ke?(Te=(0,t.jsxDEV)(qe,{label:z,onClose:a,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[O,le,ne,ue,he,pe,be,ke]},void 0,!0),e[94]=a,e[95]=z,e[96]=O,e[97]=le,e[98]=ne,e[99]=ue,e[100]=he,e[101]=pe,e[102]=be,e[103]=ke,e[104]=Te):Te=e[104],Te},"UserCreateDialog"),He=i(u=>{let e=(0,Q.c)(2),{children:a}=u,l;return e[0]!==a?(l=(0,t.jsxDEV)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a},void 0,!1),e[0]=a,e[1]=l):l=e[1],l},"SectionHeading"),nt=i(u=>{let e=(0,Q.c)(29),{busy:a,runAction:l,userId:c,version:s}=u,r=H(),o=Y(),[n,f]=(0,k.useState)(null),[w,S]=(0,k.useState)(null),x;e[0]!==r||e[1]!==c?(x=i(()=>{Ue((async()=>{S(null);try{let b=await r.listAuthSessions({limit:50,userId:c});f(b.rows)}catch(b){let I=b;f(null),S(ze(I))}})())},"t1"),e[0]=r,e[1]=c,e[2]=x):x=e[2];let C;e[3]!==r||e[4]!==c||e[5]!==s?(C=[r,c,s],e[3]=r,e[4]=c,e[5]=s,e[6]=C):C=e[6],(0,k.useEffect)(x,C);let y;e[7]!==r||e[8]!==l?(y=i(b=>{l(()=>r.revokeAuthSession({sessionId:b}))},"t3"),e[7]=r,e[8]=l,e[9]=y):y=e[9];let F=y,v;e[10]!==o?(v=o("Sessions"),e[10]=o,e[11]=v):v=e[11];let g;e[12]!==v?(g=(0,t.jsxDEV)(He,{children:v},void 0,!1),e[12]=v,e[13]=g):g=e[13];let p;e[14]!==w?(p=w!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:w},void 0,!1),e[14]=w,e[15]=p):p=e[15];let h;e[16]!==n||e[17]!==o?(h=n!==null&&n.length===0&&(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:o("No active sessions.")},void 0,!1),e[16]=n,e[17]=o,e[18]=h):h=e[18];let d;e[19]!==a||e[20]!==F||e[21]!==n||e[22]!==o?(d=n!==null&&n.length>0&&(0,t.jsxDEV)(we,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Ce,{className:"px-0",children:(0,t.jsxDEV)(De,{"data-testid":"ud-sessions-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(D,{children:o("expires")},void 0,!1),(0,t.jsxDEV)(D,{children:o("ip")},void 0,!1),(0,t.jsxDEV)(D,{children:o("user agent")},void 0,!1),(0,t.jsxDEV)(D,{"aria-label":o("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(Pe,{children:n.map(b=>(0,t.jsxDEV)(j,{"data-testid":`ud-session-${b.id}`,children:[(0,t.jsxDEV)(R,{className:"text-muted-foreground tabular-nums",children:Fe(b.expiresAt)},void 0,!1),(0,t.jsxDEV)(R,{children:b.ipAddress??""},void 0,!1),(0,t.jsxDEV)(R,{className:"max-w-40 truncate",children:b.userAgent??""},void 0,!1),(0,t.jsxDEV)(R,{children:(0,t.jsxDEV)(U,{"data-testid":`ud-revoke-${b.id}`,disabled:a,onClick:i(()=>{F(b.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Revoke")},void 0,!1)},void 0,!1)]},b.id,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[19]=a,e[20]=F,e[21]=n,e[22]=o,e[23]=d):d=e[23];let A;return e[24]!==g||e[25]!==p||e[26]!==h||e[27]!==d?(A=(0,t.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[g,p,h,d]},void 0,!0),e[24]=g,e[25]=p,e[26]=h,e[27]=d,e[28]=A):A=e[28],A},"UserSessionsPanel"),dt=i(u=>{let e=(0,Q.c)(30),{busy:a,runAction:l,userId:c,version:s}=u,r=H(),o=Y(),[n,f]=(0,k.useState)(null),[w,S]=(0,k.useState)(null),x;e[0]!==r||e[1]!==c?(x=i(()=>{Ue((async()=>{S(null);try{f(await r.listAuthAccounts({userId:c}))}catch(b){let I=b;f(null),S(ze(I))}})())},"t1"),e[0]=r,e[1]=c,e[2]=x):x=e[2];let C;e[3]!==r||e[4]!==c||e[5]!==s?(C=[r,c,s],e[3]=r,e[4]=c,e[5]=s,e[6]=C):C=e[6],(0,k.useEffect)(x,C);let y;e[7]!==r||e[8]!==l||e[9]!==c?(y=i(b=>{l(()=>r.unlinkAuthAccount({accountId:b,userId:c}))},"t3"),e[7]=r,e[8]=l,e[9]=c,e[10]=y):y=e[10];let F=y,v;e[11]!==o?(v=o("Linked accounts"),e[11]=o,e[12]=v):v=e[12];let g;e[13]!==v?(g=(0,t.jsxDEV)(He,{children:v},void 0,!1),e[13]=v,e[14]=g):g=e[14];let p;e[15]!==w?(p=w!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive",role:"alert",children:w},void 0,!1),e[15]=w,e[16]=p):p=e[16];let h;e[17]!==n||e[18]!==o?(h=n!==null&&n.length===0&&(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:o("No linked accounts.")},void 0,!1),e[17]=n,e[18]=o,e[19]=h):h=e[19];let d;e[20]!==n||e[21]!==a||e[22]!==F||e[23]!==o?(d=n!==null&&n.length>0&&(0,t.jsxDEV)(we,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Ce,{className:"px-0",children:(0,t.jsxDEV)(De,{"data-testid":"ud-accounts-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(D,{children:o("provider")},void 0,!1),(0,t.jsxDEV)(D,{children:o("created")},void 0,!1),(0,t.jsxDEV)(D,{"aria-label":o("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(Pe,{children:n.map(b=>{let I=Ae(b.id);return(0,t.jsxDEV)(j,{"data-testid":`ud-account-${I}`,children:[(0,t.jsxDEV)(R,{children:Ae(b.providerId)},void 0,!1),(0,t.jsxDEV)(R,{className:"text-muted-foreground tabular-nums",children:Fe(b.createdAt)},void 0,!1),(0,t.jsxDEV)(R,{children:(0,t.jsxDEV)(U,{"data-testid":`ud-unlink-${I}`,disabled:a,onClick:i(()=>{F(I)},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Unlink")},void 0,!1)},void 0,!1)]},I,!0)})},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[20]=n,e[21]=a,e[22]=F,e[23]=o,e[24]=d):d=e[24];let A;return e[25]!==g||e[26]!==p||e[27]!==h||e[28]!==d?(A=(0,t.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[g,p,h,d]},void 0,!0),e[25]=g,e[26]=p,e[27]=h,e[28]=d,e[29]=A):A=e[29],A},"UserAccountsPanel"),rt=i(u=>{let e=(0,Q.c)(40),{busy:a,capabilities:l,runAction:c,userId:s,version:r}=u,o=H(),n=Y(),[f,w]=(0,k.useState)(null),S;e[0]!==l.passkey||e[1]!==o||e[2]!==s?(S=i(()=>{l.passkey&&Ue((async()=>{try{w(await o.listAuthPasskeys({userId:s}))}catch{w(null)}})())},"t1"),e[0]=l.passkey,e[1]=o,e[2]=s,e[3]=S):S=e[3];let x;e[4]!==l.passkey||e[5]!==o||e[6]!==s||e[7]!==r?(x=[l.passkey,o,s,r],e[4]=l.passkey,e[5]=o,e[6]=s,e[7]=r,e[8]=x):x=e[8],(0,k.useEffect)(S,x);let C;e[9]!==o||e[10]!==c||e[11]!==s?(C=i(()=>{c(()=>o.disableAuthTwoFactor({userId:s}))},"t3"),e[9]=o,e[10]=c,e[11]=s,e[12]=C):C=e[12];let y=C,F;e[13]!==o||e[14]!==c?(F=i(I=>{c(()=>o.deleteAuthPasskey({passkeyId:I}))},"t4"),e[13]=o,e[14]=c,e[15]=F):F=e[15];let v=F,g;e[16]!==n?(g=n("Security"),e[16]=n,e[17]=g):g=e[17];let p;e[18]!==g?(p=(0,t.jsxDEV)(He,{children:g},void 0,!1),e[18]=g,e[19]=p):p=e[19];let h;e[20]!==a||e[21]!==l.twoFactor||e[22]!==y||e[23]!==n?(h=l.twoFactor&&(0,t.jsxDEV)(U,{"data-testid":"ud-disable-2fa",disabled:a,onClick:y,size:"sm",type:"button",variant:"outline",children:n("Disable two-factor")},void 0,!1),e[20]=a,e[21]=l.twoFactor,e[22]=y,e[23]=n,e[24]=h):h=e[24];let d;e[25]!==l.passkey||e[26]!==f||e[27]!==n?(d=l.passkey&&f!==null&&f.length===0&&(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:n("No passkeys.")},void 0,!1),e[25]=l.passkey,e[26]=f,e[27]=n,e[28]=d):d=e[28];let A;e[29]!==a||e[30]!==l.passkey||e[31]!==v||e[32]!==f||e[33]!==n?(A=l.passkey&&f!==null&&f.length>0&&(0,t.jsxDEV)(we,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Ce,{className:"px-0",children:(0,t.jsxDEV)(De,{"data-testid":"ud-passkeys-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(D,{children:n("name")},void 0,!1),(0,t.jsxDEV)(D,{children:n("created")},void 0,!1),(0,t.jsxDEV)(D,{"aria-label":n("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(Pe,{children:f.map(I=>{let M=Ae(I.id);return(0,t.jsxDEV)(j,{"data-testid":`ud-passkey-${M}`,children:[(0,t.jsxDEV)(R,{children:Ae(I.name)||M},void 0,!1),(0,t.jsxDEV)(R,{className:"text-muted-foreground tabular-nums",children:Fe(I.createdAt)},void 0,!1),(0,t.jsxDEV)(R,{children:(0,t.jsxDEV)(U,{"data-testid":`ud-delete-passkey-${M}`,disabled:a,onClick:i(()=>{v(M)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Delete")},void 0,!1)},void 0,!1)]},M,!0)})},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[29]=a,e[30]=l.passkey,e[31]=v,e[32]=f,e[33]=n,e[34]=A):A=e[34];let b;return e[35]!==p||e[36]!==h||e[37]!==d||e[38]!==A?(b=(0,t.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[p,h,d,A]},void 0,!0),e[35]=p,e[36]=h,e[37]=d,e[38]=A,e[39]=b):b=e[39],b},"UserSecurityPanel"),ct=/(?:at|expires)$/iu,ut=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),ft=i((u,e)=>typeof e=="number"&&ct.test(u)?Fe(e):Ae(e),"formatField"),vt=i(({capabilities:u,onChanged:e,onClose:a,user:l})=>{let c=H(),s=Y(),r=l.banned===!0,[o,n]=(0,k.useState)(null),[f,w]=(0,k.useState)(!1),[S,x]=(0,k.useState)(0),[C,y]=(0,k.useState)(typeof l.role=="string"?l.role:""),[F,v]=(0,k.useState)(""),[g,p]=(0,k.useState)(""),[h,d]=(0,k.useState)(""),[A,b]=(0,k.useState)(null),[I,M]=(0,k.useState)(!1),E=i((N,z)=>{Ue((async()=>{w(!0),n(null);try{let L=await N();z?.refresh!==!1&&(x(O=>O+1),e()),z?.onResult?.(L)}catch(L){n(ze(L))}finally{w(!1)}})())},"runAction"),Be=i(N=>{y(N.target.value)},"onRoleInputChange"),Z=i(N=>{v(N.target.value)},"onBanReasonChange"),$e=i(N=>{p(N.target.value)},"onBanDaysChange"),G=i(N=>{d(N.target.value)},"onNewPasswordChange"),Ee=i(()=>{let N=C.trim();N!==""&&E(async()=>{await c.setAuthUserRole({role:N,userId:l.id})})},"onSetRole"),W=i(()=>{let N=Number.parseInt(g,10),z=Number.isFinite(N)&&N>0?N*86400:void 0;E(async()=>{await c.banAuthUser({expiresInSeconds:z,reason:F.trim()===""?void 0:F.trim(),userId:l.id})})},"onBan"),T=i(()=>{E(async()=>{await c.unbanAuthUser({userId:l.id})})},"onUnban"),J=i(()=>{E(async()=>{await c.setAuthUserPassword({newPassword:h,userId:l.id}),d("")})},"onSetPassword"),Ie=i(()=>{E(()=>c.impersonateAuthUser({userId:l.id}),{onResult:i(N=>{b(N.token)},"onResult"),refresh:!1})},"onImpersonate"),K=i(()=>{E(async()=>{await c.revokeAuthUserSessions({userId:l.id})})},"onRevokeAll"),Ve=i(()=>{E(async()=>{await c.removeAuthUser({userId:l.id}),a()})},"onDelete"),X=i(()=>{M(!0)},"onConfirmDelete"),Se=i(()=>{M(!1)},"onCancelDelete"),_=Object.entries(l).filter(([N])=>!ut.has(N));return(0,t.jsxDEV)(qe,{label:s("User details"),onClose:a,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[(0,t.jsxDEV)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxDEV)("h2",{className:"text-sm font-semibold text-foreground",children:l.name??l.email??l.id},void 0,!1),(0,t.jsxDEV)("p",{className:"font-mono text-xs text-muted-foreground",children:l.id},void 0,!1),(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof l.role=="string"&&l.role!==""&&(0,t.jsxDEV)($,{variant:"secondary",children:l.role},void 0,!1),r?(0,t.jsxDEV)($,{variant:"destructive",children:s("Banned")},void 0,!1):(0,t.jsxDEV)($,{variant:"outline",children:s("Active")},void 0,!1),l.emailVerified===!0?(0,t.jsxDEV)($,{variant:"secondary",children:s("verified")},void 0,!1):(0,t.jsxDEV)($,{variant:"outline",children:s("unverified")},void 0,!1)]},void 0,!0)]},void 0,!0),(0,t.jsxDEV)(U,{"data-testid":"ud-close",onClick:a,size:"sm",type:"button",variant:"ghost",children:s("Close")},void 0,!1)]},void 0,!0),o!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:o},void 0,!1),u.admin&&(0,t.jsxDEV)(we,{className:"gap-0 py-0",children:[(0,t.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Actions")},void 0,!1)},void 0,!1),(0,t.jsxDEV)(Ce,{className:"flex flex-col gap-3 p-3",children:[(0,t.jsxDEV)("div",{className:"flex items-end gap-2",children:[(0,t.jsxDEV)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsxDEV)(V,{htmlFor:"ud-role",children:s("Role")},void 0,!1),(0,t.jsxDEV)(B,{"data-testid":"ud-role-input",id:"ud-role",onChange:Be,value:C},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(U,{"data-testid":"ud-set-role",disabled:f||C.trim()==="",onClick:Ee,size:"sm",type:"button",variant:"outline",children:s("Set role")},void 0,!1)]},void 0,!0),r?(0,t.jsxDEV)(U,{"data-testid":"ud-unban",disabled:f,onClick:T,size:"sm",type:"button",variant:"outline",children:s("Unban")},void 0,!1):(0,t.jsxDEV)("div",{className:"flex items-end gap-2",children:[(0,t.jsxDEV)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsxDEV)(V,{htmlFor:"ud-ban-reason",children:s("Ban reason (optional)")},void 0,!1),(0,t.jsxDEV)(B,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:Z,value:F},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex w-24 flex-col gap-1",children:[(0,t.jsxDEV)(V,{htmlFor:"ud-ban-days",children:s("Days")},void 0,!1),(0,t.jsxDEV)(B,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:$e,type:"number",value:g},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(U,{"data-testid":"ud-ban",disabled:f,onClick:W,size:"sm",type:"button",variant:"destructive",children:s("Ban user")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex items-end gap-2",children:[(0,t.jsxDEV)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsxDEV)(V,{htmlFor:"ud-password",children:s("New password")},void 0,!1),(0,t.jsxDEV)(B,{"data-testid":"ud-password",id:"ud-password",onChange:G,type:"password",value:h},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(U,{"data-testid":"ud-set-password",disabled:f||h==="",onClick:J,size:"sm",type:"button",variant:"outline",children:s("Set password")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsxDEV)(U,{"data-testid":"ud-impersonate",disabled:f,onClick:Ie,size:"sm",type:"button",variant:"outline",children:s("Impersonate")},void 0,!1),(0,t.jsxDEV)(U,{"data-testid":"ud-revoke-all",disabled:f,onClick:K,size:"sm",type:"button",variant:"outline",children:s("Revoke all sessions")},void 0,!1),I?(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)(U,{"data-testid":"ud-delete-confirm",disabled:f,onClick:Ve,size:"sm",type:"button",variant:"destructive",children:s("Confirm delete")},void 0,!1),(0,t.jsxDEV)(U,{"data-testid":"ud-delete-cancel",onClick:Se,size:"sm",type:"button",variant:"ghost",children:s("Cancel")},void 0,!1)]},void 0,!0):(0,t.jsxDEV)(U,{"data-testid":"ud-delete",disabled:f,onClick:X,size:"sm",type:"button",variant:"destructive",children:s("Delete user")},void 0,!1)]},void 0,!0),A!==null&&(0,t.jsxDEV)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsxDEV)(V,{htmlFor:"ud-token",children:s("Impersonation token")},void 0,!1),(0,t.jsxDEV)(B,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:A},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0),(0,t.jsxDEV)(nt,{busy:f,runAction:E,userId:l.id,version:S},void 0,!1),u.accounts&&(0,t.jsxDEV)(dt,{busy:f,runAction:E,userId:l.id,version:S},void 0,!1),(u.twoFactor||u.passkey)&&(0,t.jsxDEV)(rt,{busy:f,capabilities:u,runAction:E,userId:l.id,version:S},void 0,!1),(0,t.jsxDEV)("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[(0,t.jsxDEV)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Fields")},void 0,!1),(0,t.jsxDEV)("dl",{className:"flex flex-col",children:_.map(([N,z])=>(0,t.jsxDEV)("div",{className:"flex flex-col border-t border-border py-1.5",children:[(0,t.jsxDEV)("dt",{className:"text-xs font-semibold text-muted-foreground",children:N},void 0,!1),(0,t.jsxDEV)("dd",{className:"m-0 font-mono text-xs break-words",children:ft(N,z)},void 0,!1)]},N,!0))},void 0,!1)]},void 0,!0)]},void 0,!0)},"UserDetailDrawer"),mt=50,Rt=i(({pageSize:u=mt}={})=>{let e=H(),a=Y(),[l,c]=(0,k.useState)(""),[s,r]=(0,k.useState)(""),o=Ge(l),[n,f]=(0,k.useState)(null),[w,S]=(0,k.useState)(!1),{capabilities:x}=st(),C=o.trim(),y=s.trim(),F=Ze(["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}),v=F.data?.rows??null,g=F.error,p=i(()=>{F.refetch()},"reloadUsers");We(()=>{F.refetch()},!0);let h=n===null?null:v?.find(d=>d.id===n)??null;return(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxDEV)(B,{"aria-label":a("Search users"),className:"w-56","data-testid":"us-search",onChange:i(d=>{c(d.target.value)},"onChange"),placeholder:a("Search by email or name\u2026"),value:l},void 0,!1),(0,t.jsxDEV)(B,{"aria-label":a("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:i(d=>{r(d.target.value)},"onChange"),placeholder:a("Filter by role"),value:s},void 0,!1),(0,t.jsxDEV)(U,{"data-testid":"us-new",onClick:i(()=>{S(!0)},"onClick"),size:"sm",type:"button",children:a("New user")},void 0,!1)]},void 0,!0),g!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:g},void 0,!1),v!==null&&v.length===0&&(0,t.jsxDEV)(Qe,{description:a("Users who sign up to your app will appear here."),icon:(0,t.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsxDEV)("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"},void 0,!1)},void 0,!1),testId:"us-empty",title:a("No users.")},void 0,!1),v!==null&&v.length>0&&(0,t.jsxDEV)(we,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Ce,{className:"px-0",children:(0,t.jsxDEV)(De,{"data-testid":"us-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(D,{children:a("id")},void 0,!1),(0,t.jsxDEV)(D,{children:a("email")},void 0,!1),(0,t.jsxDEV)(D,{children:a("name")},void 0,!1),(0,t.jsxDEV)(D,{children:a("role")},void 0,!1),(0,t.jsxDEV)(D,{children:a("status")},void 0,!1),(0,t.jsxDEV)(D,{children:a("verified")},void 0,!1),(0,t.jsxDEV)(D,{children:a("created")},void 0,!1),(0,t.jsxDEV)(D,{"aria-label":a("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(Pe,{children:v.map(d=>(0,t.jsxDEV)(j,{"data-testid":`us-row-${d.id}`,children:[(0,t.jsxDEV)(R,{className:"font-mono text-xs",children:d.id},void 0,!1),(0,t.jsxDEV)(R,{children:d.email??""},void 0,!1),(0,t.jsxDEV)(R,{children:d.name??""},void 0,!1),(0,t.jsxDEV)(R,{children:typeof d.role=="string"&&d.role!==""?(0,t.jsxDEV)($,{variant:"secondary",children:d.role},void 0,!1):""},void 0,!1),(0,t.jsxDEV)(R,{children:d.banned===!0?(0,t.jsxDEV)($,{variant:"destructive",children:a("Banned")},void 0,!1):(0,t.jsxDEV)($,{variant:"success",children:a("Active")},void 0,!1)},void 0,!1),(0,t.jsxDEV)(R,{children:d.emailVerified===!0?(0,t.jsxDEV)($,{variant:"success",children:a("yes")},void 0,!1):(0,t.jsxDEV)($,{variant:"outline",children:a("no")},void 0,!1)},void 0,!1),(0,t.jsxDEV)(R,{className:"text-muted-foreground tabular-nums",children:Fe(d.createdAt)},void 0,!1),(0,t.jsxDEV)(R,{children:(0,t.jsxDEV)(U,{"data-testid":`us-manage-${d.id}`,onClick:i(()=>{f(d.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Manage")},void 0,!1)},void 0,!1)]},d.id,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),h!==null&&(0,t.jsxDEV)(vt,{capabilities:x,onChanged:p,onClose:i(()=>{f(null)},"onClose"),user:h},void 0,!1),w&&(0,t.jsxDEV)(ot,{onClose:i(()=>{S(!1)},"onClose"),onCreated:p},void 0,!1)]},void 0,!0)},"UsersPanel");export{Rt as UsersPanel};
1
+ import{a as Oe,b as Je}from"./chunk-KA5YB3VP.js";import{a as Ke}from"./chunk-7YXOPTWI.js";import{a as qe}from"./chunk-AHILM3ZP.js";import{a as We}from"./chunk-J6J54MBP.js";import"./chunk-L7SK4ZZD.js";import{a as Ge}from"./chunk-2K47A3P6.js";import{a as De,b as Re,c as Pe,d as j,e as D,f as R}from"./chunk-GTM65MVX.js";import{a as V}from"./chunk-JSEXCW5Q.js";import"./chunk-4QHKBC77.js";import{R as B}from"./chunk-3CJW6NWG.js";import{c as U}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as Qe}from"./chunk-TAD43CG5.js";import{a as Ze}from"./chunk-RHZ4M2NZ.js";import{a as we,e as Ce}from"./chunk-SEU5V7I6.js";import{b as $}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as H}from"./chunk-XLXNLJ4N.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as Y,g as ze,j as Ae,k as Ue,o as Fe}from"./chunk-E75ANNWX.js";import"./chunk-JHKMUTIF.js";import{a as i,e as je,f as _e,g as et,h as tt}from"./chunk-RRCPZMC2.js";var k=je(_e(),1);var Q=je(et(),1);var t=je(tt(),1);var st=i(()=>{let u=(0,Q.c)(3),{config:e,ready:a}=Oe(),l;return u[0]!==e.capabilities||u[1]!==a?(l={capabilities:e.capabilities,ready:a},u[0]=e.capabilities,u[1]=a,u[2]=l):l=u[2],l},"useAuthCapabilities"),lt={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},at=i((u,e)=>u.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:u.type!=="number"||!Number.isNaN(Number(e.trim())),"isFieldFilled"),it=i((u,e)=>{if(u.type==="boolean")return e===!0?{value:!0}:u.required?{value:!1}:void 0;let a=typeof e=="string"?e.trim():"";if(a!==""){if(u.type==="number"){let l=Number(a);return Number.isNaN(l)?void 0:{value:l}}return{value:a}}},"coerceFieldValue"),ot=i(u=>{let e=(0,Q.c)(105),{onClose:a,onCreated:l}=u,c=H(),s=Y(),{config:r}=Oe(),{busy:o,error:n,run:f}=Je(),[w,S]=(0,k.useState)(""),[x,C]=(0,k.useState)(""),[y,F]=(0,k.useState)(""),[v,g]=(0,k.useState)(""),p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let[h,d]=(0,k.useState)(p),A;e[1]===Symbol.for("react.memo_cache_sentinel")?(A=i(m=>{S(m.target.value)},"t2"),e[1]=A):A=e[1];let b=A,I;e[2]===Symbol.for("react.memo_cache_sentinel")?(I=i(m=>{C(m.target.value)},"t3"),e[2]=I):I=e[2];let M=I,E;e[3]===Symbol.for("react.memo_cache_sentinel")?(E=i(m=>{F(m.target.value)},"t4"),e[3]=E):E=e[3];let Be=E,Z;e[4]===Symbol.for("react.memo_cache_sentinel")?(Z=i(m=>{g(m.target.value)},"t5"),e[4]=Z):Z=e[4];let $e=Z,G;e[5]===Symbol.for("react.memo_cache_sentinel")?(G=i((m,P)=>{d(q=>({...q,[m]:P}))},"t6"),e[5]=G):G=e[5];let Ee=G,W;e[6]!==h?(W=i(m=>h[m.name]??(m.type==="boolean"?!1:""),"t7"),e[6]=h,e[7]=W):W=e[7];let T=W,J;if(e[8]!==r.userFields||e[9]!==T){let m;e[11]!==T?(m=i(P=>!P.required||at(P,T(P)),"t92"),e[11]=T,e[12]=m):m=e[12],J=r.userFields.every(m),e[8]=r.userFields,e[9]=T,e[10]=J}else J=e[10];let Ie=J,K;e[13]!==o||e[14]!==w||e[15]!==x||e[16]!==Ie?(K=!o&&w.trim()!==""&&x.trim()!==""&&Ie,e[13]=o,e[14]=w,e[15]=x,e[16]=Ie,e[17]=K):K=e[17];let Ve=K,X;e[18]!==r.userFields||e[19]!==T?(X=i(()=>{let m={};for(let P of r.userFields){let q=it(P,T(P));q!==void 0&&(m[P.name]=q.value)}return Object.keys(m).length===0?void 0:m},"t10"),e[18]=r.userFields,e[19]=T,e[20]=X):X=e[20];let Se=X,_;e[21]!==Se||e[22]!==c||e[23]!==w||e[24]!==x||e[25]!==a||e[26]!==l||e[27]!==y||e[28]!==v||e[29]!==f?(_=i(()=>{f(async()=>{await c.createAuthUser({data:Se(),email:w.trim(),name:x.trim(),password:y===""?void 0:y,role:v.trim()===""?void 0:v.trim()}),l(),a()})},"t11"),e[21]=Se,e[22]=c,e[23]=w,e[24]=x,e[25]=a,e[26]=l,e[27]=y,e[28]=v,e[29]=f,e[30]=_):_=e[30];let N=_,z;e[31]!==s?(z=s("Create user"),e[31]=s,e[32]=z):z=e[32];let L;e[33]!==s?(L=s("Create user"),e[33]=s,e[34]=L):L=e[34];let O;e[35]!==L?(O=(0,t.jsxDEV)("h2",{className:"text-sm font-semibold text-foreground",children:L},void 0,!1),e[35]=L,e[36]=O):O=e[36];let ee;e[37]!==s?(ee=s("email"),e[37]=s,e[38]=ee):ee=e[38];let te;e[39]!==ee?(te=(0,t.jsxDEV)(V,{htmlFor:"uc-email",children:ee},void 0,!1),e[39]=ee,e[40]=te):te=e[40];let se;e[41]!==w?(se=(0,t.jsxDEV)(B,{"data-testid":"uc-email",id:"uc-email",onChange:b,type:"email",value:w},void 0,!1),e[41]=w,e[42]=se):se=e[42];let le;e[43]!==te||e[44]!==se?(le=(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[te,se]},void 0,!0),e[43]=te,e[44]=se,e[45]=le):le=e[45];let ae;e[46]!==s?(ae=s("name"),e[46]=s,e[47]=ae):ae=e[47];let ie;e[48]!==ae?(ie=(0,t.jsxDEV)(V,{htmlFor:"uc-name",children:ae},void 0,!1),e[48]=ae,e[49]=ie):ie=e[49];let oe;e[50]!==x?(oe=(0,t.jsxDEV)(B,{"data-testid":"uc-name",id:"uc-name",onChange:M,value:x},void 0,!1),e[50]=x,e[51]=oe):oe=e[51];let ne;e[52]!==ie||e[53]!==oe?(ne=(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[ie,oe]},void 0,!0),e[52]=ie,e[53]=oe,e[54]=ne):ne=e[54];let de;e[55]!==s?(de=s("Password (optional)"),e[55]=s,e[56]=de):de=e[56];let re;e[57]!==de?(re=(0,t.jsxDEV)(V,{htmlFor:"uc-password",children:de},void 0,!1),e[57]=de,e[58]=re):re=e[58];let ce;e[59]!==y?(ce=(0,t.jsxDEV)(B,{"data-testid":"uc-password",id:"uc-password",onChange:Be,type:"password",value:y},void 0,!1),e[59]=y,e[60]=ce):ce=e[60];let ue;e[61]!==re||e[62]!==ce?(ue=(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[re,ce]},void 0,!0),e[61]=re,e[62]=ce,e[63]=ue):ue=e[63];let fe;e[64]!==s?(fe=s("Role (optional)"),e[64]=s,e[65]=fe):fe=e[65];let ve;e[66]!==fe?(ve=(0,t.jsxDEV)(V,{htmlFor:"uc-role",children:fe},void 0,!1),e[66]=fe,e[67]=ve):ve=e[67];let me;e[68]!==v?(me=(0,t.jsxDEV)(B,{"data-testid":"uc-role",id:"uc-role",onChange:$e,value:v},void 0,!1),e[68]=v,e[69]=me):me=e[69];let he;e[70]!==ve||e[71]!==me?(he=(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[ve,me]},void 0,!0),e[70]=ve,e[71]=me,e[72]=he):he=e[72];let pe;e[73]!==r.userFields||e[74]!==T||e[75]!==s?(pe=r.userFields.length>0&&(0,t.jsxDEV)("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[(0,t.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Plugin fields")},void 0,!1),r.userFields.map(m=>{let P=`uc-field-${m.name}`,q=m.required?"":` (${s("optional")})`;if(m.type==="boolean"){let Le=T(m)===!0;return(0,t.jsxDEV)("label",{className:"flex items-center gap-2",htmlFor:P,children:[(0,t.jsxDEV)(Ke,{checked:Le,"data-testid":P,id:P,onCheckedChange:i(Xe=>{Ee(m.name,Xe)},"onCheckedChange")},void 0,!1),(0,t.jsxDEV)("span",{className:"text-sm",children:[m.name,q]},void 0,!0)]},m.name,!0)}let Ye=T(m);return(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxDEV)(V,{htmlFor:P,children:[m.name,q]},void 0,!0),(0,t.jsxDEV)(B,{"data-testid":P,id:P,onChange:i(Le=>{Ee(m.name,Le.target.value)},"onChange"),type:lt[m.type],value:typeof Ye=="string"?Ye:""},void 0,!1)]},m.name,!0)})]},void 0,!0),e[73]=r.userFields,e[74]=T,e[75]=s,e[76]=pe):pe=e[76];let be;e[77]!==n?(be=n!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:n},void 0,!1),e[77]=n,e[78]=be):be=e[78];let xe;e[79]!==s?(xe=s("Cancel"),e[79]=s,e[80]=xe):xe=e[80];let ye;e[81]!==a||e[82]!==xe?(ye=(0,t.jsxDEV)(U,{"data-testid":"uc-cancel",onClick:a,size:"sm",type:"button",variant:"outline",children:xe},void 0,!1),e[81]=a,e[82]=xe,e[83]=ye):ye=e[83];let Me=!Ve,ge;e[84]!==o||e[85]!==s?(ge=s(o?"Creating\u2026":"Create"),e[84]=o,e[85]=s,e[86]=ge):ge=e[86];let Ne;e[87]!==N||e[88]!==Me||e[89]!==ge?(Ne=(0,t.jsxDEV)(U,{"data-testid":"uc-submit",disabled:Me,onClick:N,size:"sm",type:"button",children:ge},void 0,!1),e[87]=N,e[88]=Me,e[89]=ge,e[90]=Ne):Ne=e[90];let ke;e[91]!==ye||e[92]!==Ne?(ke=(0,t.jsxDEV)("div",{className:"flex justify-end gap-2 pt-1",children:[ye,Ne]},void 0,!0),e[91]=ye,e[92]=Ne,e[93]=ke):ke=e[93];let Te;return e[94]!==a||e[95]!==z||e[96]!==O||e[97]!==le||e[98]!==ne||e[99]!==ue||e[100]!==he||e[101]!==pe||e[102]!==be||e[103]!==ke?(Te=(0,t.jsxDEV)(qe,{label:z,onClose:a,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[O,le,ne,ue,he,pe,be,ke]},void 0,!0),e[94]=a,e[95]=z,e[96]=O,e[97]=le,e[98]=ne,e[99]=ue,e[100]=he,e[101]=pe,e[102]=be,e[103]=ke,e[104]=Te):Te=e[104],Te},"UserCreateDialog"),He=i(u=>{let e=(0,Q.c)(2),{children:a}=u,l;return e[0]!==a?(l=(0,t.jsxDEV)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a},void 0,!1),e[0]=a,e[1]=l):l=e[1],l},"SectionHeading"),nt=i(u=>{let e=(0,Q.c)(29),{busy:a,runAction:l,userId:c,version:s}=u,r=H(),o=Y(),[n,f]=(0,k.useState)(null),[w,S]=(0,k.useState)(null),x;e[0]!==r||e[1]!==c?(x=i(()=>{Ue((async()=>{S(null);try{let b=await r.listAuthSessions({limit:50,userId:c});f(b.rows)}catch(b){let I=b;f(null),S(ze(I))}})())},"t1"),e[0]=r,e[1]=c,e[2]=x):x=e[2];let C;e[3]!==r||e[4]!==c||e[5]!==s?(C=[r,c,s],e[3]=r,e[4]=c,e[5]=s,e[6]=C):C=e[6],(0,k.useEffect)(x,C);let y;e[7]!==r||e[8]!==l?(y=i(b=>{l(()=>r.revokeAuthSession({sessionId:b}))},"t3"),e[7]=r,e[8]=l,e[9]=y):y=e[9];let F=y,v;e[10]!==o?(v=o("Sessions"),e[10]=o,e[11]=v):v=e[11];let g;e[12]!==v?(g=(0,t.jsxDEV)(He,{children:v},void 0,!1),e[12]=v,e[13]=g):g=e[13];let p;e[14]!==w?(p=w!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:w},void 0,!1),e[14]=w,e[15]=p):p=e[15];let h;e[16]!==n||e[17]!==o?(h=n!==null&&n.length===0&&(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:o("No active sessions.")},void 0,!1),e[16]=n,e[17]=o,e[18]=h):h=e[18];let d;e[19]!==a||e[20]!==F||e[21]!==n||e[22]!==o?(d=n!==null&&n.length>0&&(0,t.jsxDEV)(we,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Ce,{className:"px-0",children:(0,t.jsxDEV)(De,{"data-testid":"ud-sessions-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(D,{children:o("expires")},void 0,!1),(0,t.jsxDEV)(D,{children:o("ip")},void 0,!1),(0,t.jsxDEV)(D,{children:o("user agent")},void 0,!1),(0,t.jsxDEV)(D,{"aria-label":o("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(Pe,{children:n.map(b=>(0,t.jsxDEV)(j,{"data-testid":`ud-session-${b.id}`,children:[(0,t.jsxDEV)(R,{className:"text-muted-foreground tabular-nums",children:Fe(b.expiresAt)},void 0,!1),(0,t.jsxDEV)(R,{children:b.ipAddress??""},void 0,!1),(0,t.jsxDEV)(R,{className:"max-w-40 truncate",children:b.userAgent??""},void 0,!1),(0,t.jsxDEV)(R,{children:(0,t.jsxDEV)(U,{"data-testid":`ud-revoke-${b.id}`,disabled:a,onClick:i(()=>{F(b.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Revoke")},void 0,!1)},void 0,!1)]},b.id,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[19]=a,e[20]=F,e[21]=n,e[22]=o,e[23]=d):d=e[23];let A;return e[24]!==g||e[25]!==p||e[26]!==h||e[27]!==d?(A=(0,t.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[g,p,h,d]},void 0,!0),e[24]=g,e[25]=p,e[26]=h,e[27]=d,e[28]=A):A=e[28],A},"UserSessionsPanel"),dt=i(u=>{let e=(0,Q.c)(30),{busy:a,runAction:l,userId:c,version:s}=u,r=H(),o=Y(),[n,f]=(0,k.useState)(null),[w,S]=(0,k.useState)(null),x;e[0]!==r||e[1]!==c?(x=i(()=>{Ue((async()=>{S(null);try{f(await r.listAuthAccounts({userId:c}))}catch(b){let I=b;f(null),S(ze(I))}})())},"t1"),e[0]=r,e[1]=c,e[2]=x):x=e[2];let C;e[3]!==r||e[4]!==c||e[5]!==s?(C=[r,c,s],e[3]=r,e[4]=c,e[5]=s,e[6]=C):C=e[6],(0,k.useEffect)(x,C);let y;e[7]!==r||e[8]!==l||e[9]!==c?(y=i(b=>{l(()=>r.unlinkAuthAccount({accountId:b,userId:c}))},"t3"),e[7]=r,e[8]=l,e[9]=c,e[10]=y):y=e[10];let F=y,v;e[11]!==o?(v=o("Linked accounts"),e[11]=o,e[12]=v):v=e[12];let g;e[13]!==v?(g=(0,t.jsxDEV)(He,{children:v},void 0,!1),e[13]=v,e[14]=g):g=e[14];let p;e[15]!==w?(p=w!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive",role:"alert",children:w},void 0,!1),e[15]=w,e[16]=p):p=e[16];let h;e[17]!==n||e[18]!==o?(h=n!==null&&n.length===0&&(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:o("No linked accounts.")},void 0,!1),e[17]=n,e[18]=o,e[19]=h):h=e[19];let d;e[20]!==n||e[21]!==a||e[22]!==F||e[23]!==o?(d=n!==null&&n.length>0&&(0,t.jsxDEV)(we,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Ce,{className:"px-0",children:(0,t.jsxDEV)(De,{"data-testid":"ud-accounts-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(D,{children:o("provider")},void 0,!1),(0,t.jsxDEV)(D,{children:o("created")},void 0,!1),(0,t.jsxDEV)(D,{"aria-label":o("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(Pe,{children:n.map(b=>{let I=Ae(b.id);return(0,t.jsxDEV)(j,{"data-testid":`ud-account-${I}`,children:[(0,t.jsxDEV)(R,{children:Ae(b.providerId)},void 0,!1),(0,t.jsxDEV)(R,{className:"text-muted-foreground tabular-nums",children:Fe(b.createdAt)},void 0,!1),(0,t.jsxDEV)(R,{children:(0,t.jsxDEV)(U,{"data-testid":`ud-unlink-${I}`,disabled:a,onClick:i(()=>{F(I)},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Unlink")},void 0,!1)},void 0,!1)]},I,!0)})},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[20]=n,e[21]=a,e[22]=F,e[23]=o,e[24]=d):d=e[24];let A;return e[25]!==g||e[26]!==p||e[27]!==h||e[28]!==d?(A=(0,t.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[g,p,h,d]},void 0,!0),e[25]=g,e[26]=p,e[27]=h,e[28]=d,e[29]=A):A=e[29],A},"UserAccountsPanel"),rt=i(u=>{let e=(0,Q.c)(40),{busy:a,capabilities:l,runAction:c,userId:s,version:r}=u,o=H(),n=Y(),[f,w]=(0,k.useState)(null),S;e[0]!==l.passkey||e[1]!==o||e[2]!==s?(S=i(()=>{l.passkey&&Ue((async()=>{try{w(await o.listAuthPasskeys({userId:s}))}catch{w(null)}})())},"t1"),e[0]=l.passkey,e[1]=o,e[2]=s,e[3]=S):S=e[3];let x;e[4]!==l.passkey||e[5]!==o||e[6]!==s||e[7]!==r?(x=[l.passkey,o,s,r],e[4]=l.passkey,e[5]=o,e[6]=s,e[7]=r,e[8]=x):x=e[8],(0,k.useEffect)(S,x);let C;e[9]!==o||e[10]!==c||e[11]!==s?(C=i(()=>{c(()=>o.disableAuthTwoFactor({userId:s}))},"t3"),e[9]=o,e[10]=c,e[11]=s,e[12]=C):C=e[12];let y=C,F;e[13]!==o||e[14]!==c?(F=i(I=>{c(()=>o.deleteAuthPasskey({passkeyId:I}))},"t4"),e[13]=o,e[14]=c,e[15]=F):F=e[15];let v=F,g;e[16]!==n?(g=n("Security"),e[16]=n,e[17]=g):g=e[17];let p;e[18]!==g?(p=(0,t.jsxDEV)(He,{children:g},void 0,!1),e[18]=g,e[19]=p):p=e[19];let h;e[20]!==a||e[21]!==l.twoFactor||e[22]!==y||e[23]!==n?(h=l.twoFactor&&(0,t.jsxDEV)(U,{"data-testid":"ud-disable-2fa",disabled:a,onClick:y,size:"sm",type:"button",variant:"outline",children:n("Disable two-factor")},void 0,!1),e[20]=a,e[21]=l.twoFactor,e[22]=y,e[23]=n,e[24]=h):h=e[24];let d;e[25]!==l.passkey||e[26]!==f||e[27]!==n?(d=l.passkey&&f!==null&&f.length===0&&(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:n("No passkeys.")},void 0,!1),e[25]=l.passkey,e[26]=f,e[27]=n,e[28]=d):d=e[28];let A;e[29]!==a||e[30]!==l.passkey||e[31]!==v||e[32]!==f||e[33]!==n?(A=l.passkey&&f!==null&&f.length>0&&(0,t.jsxDEV)(we,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Ce,{className:"px-0",children:(0,t.jsxDEV)(De,{"data-testid":"ud-passkeys-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(D,{children:n("name")},void 0,!1),(0,t.jsxDEV)(D,{children:n("created")},void 0,!1),(0,t.jsxDEV)(D,{"aria-label":n("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(Pe,{children:f.map(I=>{let M=Ae(I.id);return(0,t.jsxDEV)(j,{"data-testid":`ud-passkey-${M}`,children:[(0,t.jsxDEV)(R,{children:Ae(I.name)||M},void 0,!1),(0,t.jsxDEV)(R,{className:"text-muted-foreground tabular-nums",children:Fe(I.createdAt)},void 0,!1),(0,t.jsxDEV)(R,{children:(0,t.jsxDEV)(U,{"data-testid":`ud-delete-passkey-${M}`,disabled:a,onClick:i(()=>{v(M)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Delete")},void 0,!1)},void 0,!1)]},M,!0)})},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[29]=a,e[30]=l.passkey,e[31]=v,e[32]=f,e[33]=n,e[34]=A):A=e[34];let b;return e[35]!==p||e[36]!==h||e[37]!==d||e[38]!==A?(b=(0,t.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[p,h,d,A]},void 0,!0),e[35]=p,e[36]=h,e[37]=d,e[38]=A,e[39]=b):b=e[39],b},"UserSecurityPanel"),ct=/(?:at|expires)$/iu,ut=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),ft=i((u,e)=>typeof e=="number"&&ct.test(u)?Fe(e):Ae(e),"formatField"),vt=i(({capabilities:u,onChanged:e,onClose:a,user:l})=>{let c=H(),s=Y(),r=l.banned===!0,[o,n]=(0,k.useState)(null),[f,w]=(0,k.useState)(!1),[S,x]=(0,k.useState)(0),[C,y]=(0,k.useState)(typeof l.role=="string"?l.role:""),[F,v]=(0,k.useState)(""),[g,p]=(0,k.useState)(""),[h,d]=(0,k.useState)(""),[A,b]=(0,k.useState)(null),[I,M]=(0,k.useState)(!1),E=i((N,z)=>{Ue((async()=>{w(!0),n(null);try{let L=await N();z?.refresh!==!1&&(x(O=>O+1),e()),z?.onResult?.(L)}catch(L){n(ze(L))}finally{w(!1)}})())},"runAction"),Be=i(N=>{y(N.target.value)},"onRoleInputChange"),Z=i(N=>{v(N.target.value)},"onBanReasonChange"),$e=i(N=>{p(N.target.value)},"onBanDaysChange"),G=i(N=>{d(N.target.value)},"onNewPasswordChange"),Ee=i(()=>{let N=C.trim();N!==""&&E(async()=>{await c.setAuthUserRole({role:N,userId:l.id})})},"onSetRole"),W=i(()=>{let N=Number.parseInt(g,10),z=Number.isFinite(N)&&N>0?N*86400:void 0;E(async()=>{await c.banAuthUser({expiresInSeconds:z,reason:F.trim()===""?void 0:F.trim(),userId:l.id})})},"onBan"),T=i(()=>{E(async()=>{await c.unbanAuthUser({userId:l.id})})},"onUnban"),J=i(()=>{E(async()=>{await c.setAuthUserPassword({newPassword:h,userId:l.id}),d("")})},"onSetPassword"),Ie=i(()=>{E(()=>c.impersonateAuthUser({userId:l.id}),{onResult:i(N=>{b(N.token)},"onResult"),refresh:!1})},"onImpersonate"),K=i(()=>{E(async()=>{await c.revokeAuthUserSessions({userId:l.id})})},"onRevokeAll"),Ve=i(()=>{E(async()=>{await c.removeAuthUser({userId:l.id}),a()})},"onDelete"),X=i(()=>{M(!0)},"onConfirmDelete"),Se=i(()=>{M(!1)},"onCancelDelete"),_=Object.entries(l).filter(([N])=>!ut.has(N));return(0,t.jsxDEV)(qe,{label:s("User details"),onClose:a,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[(0,t.jsxDEV)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxDEV)("h2",{className:"text-sm font-semibold text-foreground",children:l.name??l.email??l.id},void 0,!1),(0,t.jsxDEV)("p",{className:"font-mono text-xs text-muted-foreground",children:l.id},void 0,!1),(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof l.role=="string"&&l.role!==""&&(0,t.jsxDEV)($,{variant:"secondary",children:l.role},void 0,!1),r?(0,t.jsxDEV)($,{variant:"destructive",children:s("Banned")},void 0,!1):(0,t.jsxDEV)($,{variant:"outline",children:s("Active")},void 0,!1),l.emailVerified===!0?(0,t.jsxDEV)($,{variant:"secondary",children:s("verified")},void 0,!1):(0,t.jsxDEV)($,{variant:"outline",children:s("unverified")},void 0,!1)]},void 0,!0)]},void 0,!0),(0,t.jsxDEV)(U,{"data-testid":"ud-close",onClick:a,size:"sm",type:"button",variant:"ghost",children:s("Close")},void 0,!1)]},void 0,!0),o!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:o},void 0,!1),u.admin&&(0,t.jsxDEV)(we,{className:"gap-0 py-0",children:[(0,t.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Actions")},void 0,!1)},void 0,!1),(0,t.jsxDEV)(Ce,{className:"flex flex-col gap-3 p-3",children:[(0,t.jsxDEV)("div",{className:"flex items-end gap-2",children:[(0,t.jsxDEV)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsxDEV)(V,{htmlFor:"ud-role",children:s("Role")},void 0,!1),(0,t.jsxDEV)(B,{"data-testid":"ud-role-input",id:"ud-role",onChange:Be,value:C},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(U,{"data-testid":"ud-set-role",disabled:f||C.trim()==="",onClick:Ee,size:"sm",type:"button",variant:"outline",children:s("Set role")},void 0,!1)]},void 0,!0),r?(0,t.jsxDEV)(U,{"data-testid":"ud-unban",disabled:f,onClick:T,size:"sm",type:"button",variant:"outline",children:s("Unban")},void 0,!1):(0,t.jsxDEV)("div",{className:"flex items-end gap-2",children:[(0,t.jsxDEV)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsxDEV)(V,{htmlFor:"ud-ban-reason",children:s("Ban reason (optional)")},void 0,!1),(0,t.jsxDEV)(B,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:Z,value:F},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex w-24 flex-col gap-1",children:[(0,t.jsxDEV)(V,{htmlFor:"ud-ban-days",children:s("Days")},void 0,!1),(0,t.jsxDEV)(B,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:$e,type:"number",value:g},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(U,{"data-testid":"ud-ban",disabled:f,onClick:W,size:"sm",type:"button",variant:"destructive",children:s("Ban user")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex items-end gap-2",children:[(0,t.jsxDEV)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsxDEV)(V,{htmlFor:"ud-password",children:s("New password")},void 0,!1),(0,t.jsxDEV)(B,{"data-testid":"ud-password",id:"ud-password",onChange:G,type:"password",value:h},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(U,{"data-testid":"ud-set-password",disabled:f||h==="",onClick:J,size:"sm",type:"button",variant:"outline",children:s("Set password")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsxDEV)(U,{"data-testid":"ud-impersonate",disabled:f,onClick:Ie,size:"sm",type:"button",variant:"outline",children:s("Impersonate")},void 0,!1),(0,t.jsxDEV)(U,{"data-testid":"ud-revoke-all",disabled:f,onClick:K,size:"sm",type:"button",variant:"outline",children:s("Revoke all sessions")},void 0,!1),I?(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)(U,{"data-testid":"ud-delete-confirm",disabled:f,onClick:Ve,size:"sm",type:"button",variant:"destructive",children:s("Confirm delete")},void 0,!1),(0,t.jsxDEV)(U,{"data-testid":"ud-delete-cancel",onClick:Se,size:"sm",type:"button",variant:"ghost",children:s("Cancel")},void 0,!1)]},void 0,!0):(0,t.jsxDEV)(U,{"data-testid":"ud-delete",disabled:f,onClick:X,size:"sm",type:"button",variant:"destructive",children:s("Delete user")},void 0,!1)]},void 0,!0),A!==null&&(0,t.jsxDEV)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsxDEV)(V,{htmlFor:"ud-token",children:s("Impersonation token")},void 0,!1),(0,t.jsxDEV)(B,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:A},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0),(0,t.jsxDEV)(nt,{busy:f,runAction:E,userId:l.id,version:S},void 0,!1),u.accounts&&(0,t.jsxDEV)(dt,{busy:f,runAction:E,userId:l.id,version:S},void 0,!1),(u.twoFactor||u.passkey)&&(0,t.jsxDEV)(rt,{busy:f,capabilities:u,runAction:E,userId:l.id,version:S},void 0,!1),(0,t.jsxDEV)("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[(0,t.jsxDEV)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Fields")},void 0,!1),(0,t.jsxDEV)("dl",{className:"flex flex-col",children:_.map(([N,z])=>(0,t.jsxDEV)("div",{className:"flex flex-col border-t border-border py-1.5",children:[(0,t.jsxDEV)("dt",{className:"text-xs font-semibold text-muted-foreground",children:N},void 0,!1),(0,t.jsxDEV)("dd",{className:"m-0 font-mono text-xs break-words",children:ft(N,z)},void 0,!1)]},N,!0))},void 0,!1)]},void 0,!0)]},void 0,!0)},"UserDetailDrawer"),mt=50,Rt=i(({pageSize:u=mt}={})=>{let e=H(),a=Y(),[l,c]=(0,k.useState)(""),[s,r]=(0,k.useState)(""),o=Ge(l),[n,f]=(0,k.useState)(null),[w,S]=(0,k.useState)(!1),{capabilities:x}=st(),C=o.trim(),y=s.trim(),F=Ze(["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}),v=F.data?.rows??null,g=F.error,p=i(()=>{F.refetch()},"reloadUsers");We(()=>{F.refetch()},!0);let h=n===null?null:v?.find(d=>d.id===n)??null;return(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxDEV)(B,{"aria-label":a("Search users"),className:"w-56","data-testid":"us-search",onChange:i(d=>{c(d.target.value)},"onChange"),placeholder:a("Search by email or name\u2026"),value:l},void 0,!1),(0,t.jsxDEV)(B,{"aria-label":a("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:i(d=>{r(d.target.value)},"onChange"),placeholder:a("Filter by role"),value:s},void 0,!1),(0,t.jsxDEV)(U,{"data-testid":"us-new",onClick:i(()=>{S(!0)},"onClick"),size:"sm",type:"button",children:a("New user")},void 0,!1)]},void 0,!0),g!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:g},void 0,!1),v!==null&&v.length===0&&(0,t.jsxDEV)(Qe,{description:a("Users who sign up to your app will appear here."),icon:(0,t.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsxDEV)("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"},void 0,!1)},void 0,!1),testId:"us-empty",title:a("No users.")},void 0,!1),v!==null&&v.length>0&&(0,t.jsxDEV)(we,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Ce,{className:"px-0",children:(0,t.jsxDEV)(De,{"data-testid":"us-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(D,{children:a("id")},void 0,!1),(0,t.jsxDEV)(D,{children:a("email")},void 0,!1),(0,t.jsxDEV)(D,{children:a("name")},void 0,!1),(0,t.jsxDEV)(D,{children:a("role")},void 0,!1),(0,t.jsxDEV)(D,{children:a("status")},void 0,!1),(0,t.jsxDEV)(D,{children:a("verified")},void 0,!1),(0,t.jsxDEV)(D,{children:a("created")},void 0,!1),(0,t.jsxDEV)(D,{"aria-label":a("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(Pe,{children:v.map(d=>(0,t.jsxDEV)(j,{"data-testid":`us-row-${d.id}`,children:[(0,t.jsxDEV)(R,{className:"font-mono text-xs",children:d.id},void 0,!1),(0,t.jsxDEV)(R,{children:d.email??""},void 0,!1),(0,t.jsxDEV)(R,{children:d.name??""},void 0,!1),(0,t.jsxDEV)(R,{children:typeof d.role=="string"&&d.role!==""?(0,t.jsxDEV)($,{variant:"secondary",children:d.role},void 0,!1):""},void 0,!1),(0,t.jsxDEV)(R,{children:d.banned===!0?(0,t.jsxDEV)($,{variant:"destructive",children:a("Banned")},void 0,!1):(0,t.jsxDEV)($,{variant:"success",children:a("Active")},void 0,!1)},void 0,!1),(0,t.jsxDEV)(R,{children:d.emailVerified===!0?(0,t.jsxDEV)($,{variant:"success",children:a("yes")},void 0,!1):(0,t.jsxDEV)($,{variant:"outline",children:a("no")},void 0,!1)},void 0,!1),(0,t.jsxDEV)(R,{className:"text-muted-foreground tabular-nums",children:Fe(d.createdAt)},void 0,!1),(0,t.jsxDEV)(R,{children:(0,t.jsxDEV)(U,{"data-testid":`us-manage-${d.id}`,onClick:i(()=>{f(d.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Manage")},void 0,!1)},void 0,!1)]},d.id,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),h!==null&&(0,t.jsxDEV)(vt,{capabilities:x,onChanged:p,onClose:i(()=>{f(null)},"onClose"),user:h},void 0,!1),w&&(0,t.jsxDEV)(ot,{onClose:i(()=>{S(!1)},"onClose"),onCreated:p},void 0,!1)]},void 0,!0)},"UsersPanel");export{Rt as UsersPanel};
@@ -1,13 +1,13 @@
1
- import{a as t}from"./chunk-RRCPZMC2.js";var a={BAD_REQUEST:{status:400,title:"Bad request"},UNAUTHORIZED:{status:401,title:"Unauthorized"},FORBIDDEN:{status:403,title:"Forbidden"},NOT_FOUND:{status:404,title:"Not found"},CONFLICT:{hint:["Another write changed this row while your mutation was running (optimistic concurrency conflict).","","Re-read the row and retry the mutation with the fresh value. Lunora serializes a DO's mutations, so a persistent conflict usually means the handler conflicts **with itself** (e.g. a trigger or cascade touching the same row) \u2014 split that work rather than adding a retry loop."],status:409,title:"Conflict"},NOT_UNIQUE:{hint:["A row with the same value already exists in a `unique` index.","","- If you meant to upsert, use `ctx.db.<table>().upsert(...)` (or `.patch(...)` an existing row) instead of `.insert(...)`.",`- Otherwise pick a value that isn't already taken, and consider surfacing a friendly "already exists" message to the user.`],status:400,title:"Unique constraint violation"},VALIDATION_ERROR:{status:400,title:"Validation failed"},TOO_MANY_REQUESTS:{status:429,title:"Too many requests"},UNPROCESSABLE:{status:422,title:"Unprocessable"},NOT_IMPLEMENTED:{status:501,title:"Not implemented"},FUNCTION_NOT_FOUND:{status:404,title:"Function not found"},METHOD_NOT_ALLOWED:{status:405,title:"Method not allowed"},PAYLOAD_TOO_LARGE:{status:413,title:"Payload too large"},INTERNAL:{internal:!0,status:500,title:"Internal error"},INTERNAL_SERVER_ERROR:{internal:!0,status:500,title:"Internal error"},RPC_FAILED:{internal:!0,status:500,title:"Internal error"},COUNT_RLS_UNSUPPORTED:{status:422,title:"count() is unsupported under an RLS policy"},MASK_UNSUPPORTED:{status:422,title:"Aggregation over a masked column is unsupported"},RELATION_PREDICATE_UNSUPPORTED:{status:422,title:"Relation predicate is unsupported in a write policy"},RLS_REQUIRED:{hint:["This table is secure-by-default: it has no `.public()` marker and no RLS policy resolved for the caller, so the read fails closed.","","Add a read policy with `.rls(...)`, or mark the table `.public()` if it is intentionally world-readable."],status:403,title:"RLS policy required"},SHARD_ERROR:{status:503,title:"Shard error"},SHARD_UNAVAILABLE:{status:503,title:"Shard unavailable"},OFFLINE_IDENTITY_CHANGED:{status:409,title:"Offline identity changed"},CODEGEN_DIAGNOSTIC:{status:500,title:"Codegen diagnostic"},SCHEMA_SNAPSHOT_PARSE:{status:500,title:"Schema snapshot parse error"},ENV_INVALID:{status:500,title:"Invalid environment"},AUTH_HEADERS_MISSING:{status:500,title:"Auth headers missing"},ANALYTICS_SQL_ERROR:{status:502,title:"Analytics Engine SQL API error"},R2_SQL_ERROR:{status:502,title:"R2 SQL API error"},WORKFLOWS_REST_ERROR:{status:502,title:"Cloudflare Workflows REST API error"}};var l=[{body:["Lunora codegen couldn't find a schema to generate from.","","Create `lunora/schema.ts` exporting a `defineSchema(...)` call:","","```ts",'import { defineSchema, defineTable, v } from "@lunora/server";',"","export default defineSchema({"," messages: defineTable({ body: v.string() }),","});","```","","Or run `lunora init` to scaffold Lunora (a sample `lunora/schema.ts` included) into your app."].join(`
1
+ import{a as t}from"./chunk-RRCPZMC2.js";var r={BAD_REQUEST:{status:400,title:"Bad request"},UNAUTHORIZED:{status:401,title:"Unauthorized"},FORBIDDEN:{status:403,title:"Forbidden"},NOT_FOUND:{status:404,title:"Not found"},CONFLICT:{hint:["Another write changed this row while your mutation was running (optimistic concurrency conflict).","","Re-read the row and retry the mutation with the fresh value. Lunora serializes a DO's mutations, so a persistent conflict usually means the handler conflicts **with itself** (e.g. a trigger or cascade touching the same row) \u2014 split that work rather than adding a retry loop."],status:409,title:"Conflict"},NOT_UNIQUE:{hint:["`.unique()` matched more than one document \u2014 it expects the query to identify at most one row.","","- If several matches are legitimate, use `.first()` (take one) or `.collect()` (take all) instead.","- Otherwise tighten the query (e.g. filter on a unique/indexed field) so it can only match one row."],status:400,title:"Query matched more than one document"},VALIDATION_ERROR:{status:400,title:"Validation failed"},TOO_MANY_REQUESTS:{status:429,title:"Too many requests"},UNPROCESSABLE:{status:422,title:"Unprocessable"},NOT_IMPLEMENTED:{status:501,title:"Not implemented"},FUNCTION_NOT_FOUND:{status:404,title:"Function not found"},METHOD_NOT_ALLOWED:{status:405,title:"Method not allowed"},PAYLOAD_TOO_LARGE:{status:413,title:"Payload too large"},INTERNAL:{internal:!0,status:500,title:"Internal error"},INTERNAL_SERVER_ERROR:{internal:!0,status:500,title:"Internal error"},RPC_FAILED:{internal:!0,status:500,title:"Internal error"},COUNT_RLS_UNSUPPORTED:{status:422,title:"count() is unsupported under an RLS policy"},MASK_UNSUPPORTED:{status:422,title:"Aggregation over a masked column is unsupported"},RELATION_PREDICATE_UNSUPPORTED:{status:422,title:"Relation predicate is unsupported in a write policy"},RLS_REQUIRED:{hint:["This table is secure-by-default: it has no `.public()` marker and no RLS policy resolved for the caller, so the read fails closed.","","Add a read policy with `.rls(...)`, or mark the table `.public()` if it is intentionally world-readable."],status:403,title:"RLS policy required"},SHARD_ERROR:{status:503,title:"Shard error"},SHARD_UNAVAILABLE:{status:503,title:"Shard unavailable"},OFFLINE_IDENTITY_CHANGED:{status:409,title:"Offline identity changed"},CODEGEN_DIAGNOSTIC:{status:500,title:"Codegen diagnostic"},SCHEMA_SNAPSHOT_PARSE:{status:500,title:"Schema snapshot parse error"},ENV_INVALID:{internal:!0,status:500,title:"Invalid environment"},AUTH_HEADERS_MISSING:{internal:!0,status:500,title:"Auth headers missing"},ANALYTICS_SQL_ERROR:{status:502,title:"Analytics Engine SQL API error"},R2_SQL_ERROR:{status:502,title:"R2 SQL API error"},WORKFLOWS_REST_ERROR:{status:502,title:"Cloudflare Workflows REST API error"}};var l=[{body:["Lunora codegen couldn't find a schema to generate from.","","Create `lunora/schema.ts` exporting a `defineSchema(...)` call:","","```ts",'import { defineSchema, defineTable, v } from "@lunora/server";',"","export default defineSchema({"," messages: defineTable({ body: v.string() }),","});","```","","Or run `lunora init` to scaffold Lunora (a sample `lunora/schema.ts` included) into your app."].join(`
2
2
  `),header:"No Lunora schema found",id:"lunora-schema-missing",test:t(e=>e.includes("defineSchema() not found")||e.includes("schema.ts not found at"),"test")},{body:["`defineSchema(...)` must be called with an **inline object literal** mapping table names to `defineTable(...)`:","","```ts","export default defineSchema({"," todos: defineTable({ title: v.string(), done: v.boolean() }),","});","```","","Codegen reads the schema statically, so it can't follow a variable or a spread \u2014 pass the object literal directly."].join(`
3
3
  `),header:"`defineSchema()` needs an inline object literal",id:"lunora-schema-not-object-literal",test:t(e=>e.includes("defineSchema() expects an object literal"),"test")},{body:["This table name collides with a built-in `ctx.db` member, so the generated client can't expose it.","","Rename the table to anything that isn't a reserved name (the error lists them) \u2014 e.g. `userAccounts` instead of `insert`."].join(`
4
4
  `),header:"Table name is reserved",id:"lunora-table-reserved",test:t(e=>e.includes("is reserved")&&e.includes("ctx.db"),"test")},{body:["Two tables resolve to the same name \u2014 usually a base table and a schema **extension** both defining it.","","Rename one of them, or drop the duplicate from the extension. Each table name must be unique across `defineSchema(...)` and every `.extend(...)`."].join(`
5
5
  `),header:"Duplicate table name",id:"lunora-table-duplicate",test:t(e=>e.includes("already exists")&&e.includes(".extend("),"test")},{body:['`.jurisdiction(...)` accepts only a **string literal** of `"eu"`, `"us"`, or `"fedramp"`:',"","```ts",'defineSchema({ /* \u2026 */ }).jurisdiction("eu");',"```"].join(`
6
6
  `),header:"Invalid `.jurisdiction(...)` value",id:"lunora-jurisdiction",test:t(e=>e.includes("unknown jurisdiction")||e.includes("jurisdiction")&&e.includes('"eu", "us", or "fedramp"'),"test")},{body:["The `unique` flag on an index must be a **literal** `true` or `false`, not a computed value \u2014 codegen needs to read it statically:","","```ts",'defineTable({ email: v.string() }).index("by_email", ["email"], { unique: true });',"```"].join(`
7
7
  `),header:"`unique` must be a literal",id:"lunora-unique-literal",test:t(e=>e.includes("must be a literal")&&e.includes("unique"),"test")},{body:["A declared container/workflow class isn't re-exported by your worker entry, so `wrangler deploy` would reject it.","","Add the generated re-export shown in the error to your worker entry (e.g. `src/index.ts`):","","```ts",'export * from "./lunora/_generated/containers";',"```"].join(`
8
- `),header:"Binding not exported by your worker entry",id:"lunora-worker-entry-export-gap",test:t(e=>e.includes("not exported by your worker entry"),"test")},{body:a.NOT_UNIQUE.hint.join(`
9
- `),header:"Unique constraint violation",id:"lunora-runtime-unique",test:t(e=>e.includes("unique constraint violation on"),"test")},{body:a.CONFLICT.hint.join(`
8
+ `),header:"Binding not exported by your worker entry",id:"lunora-worker-entry-export-gap",test:t(e=>e.includes("not exported by your worker entry"),"test")},{body:["A row with the same value already exists in a `unique` index.","","- If you meant to upsert, use `ctx.db.<table>().upsert(...)` (or `.patch(...)` an existing row) instead of `.insert(...)`.",`- Otherwise pick a value that isn't already taken, and consider surfacing a friendly "already exists" message to the user.`].join(`
9
+ `),header:"Unique constraint violation",id:"lunora-runtime-unique",test:t(e=>e.includes("unique constraint violation on"),"test")},{body:r.CONFLICT.hint.join(`
10
10
  `),header:"Optimistic concurrency conflict",id:"lunora-runtime-occ",test:t(e=>e.includes("optimistic concurrency conflict"),"test")}],d=t(e=>(Array.isArray(e)?e.join(`
11
11
  `):e).split(`
12
- `).filter(n=>!n.startsWith("```")).join(`
13
- `).replaceAll(/\*\*(.+?)\*\*/gu,"$1").replaceAll(/`([^`]+)`/gu,"$1"),"flattenHint");var o=class extends Error{static{t(this,"LunoraError")}type="VisulimaError";hint;title;loc;code;status;docsUrl;data;constructor(n,s,i={}){let r=a[n];super(s??n,{cause:i.cause}),this.name=i.name??"LunoraError",this.hint=i.hint??r?.hint,this.title=i.title??r?.title,this.loc=i.location,this.code=n,this.status=i.status??r?.status??500,this.docsUrl=i.docsUrl??r?.docsUrl,this.data=i.data}};export{d as a,o as b};
12
+ `).filter(i=>!i.startsWith("```")).join(`
13
+ `).replaceAll(/\*\*(.+?)\*\*/gu,"$1").replaceAll(/`([^`]+)`/gu,"$1"),"flattenHint");var o=class extends Error{static{t(this,"LunoraError")}type="VisulimaError";hint;title;loc;code;status;docsUrl;data;constructor(i,s,n={}){let a=r[i];super(s??i,{cause:n.cause}),this.name=n.name??"LunoraError",this.hint=n.hint??a?.hint,this.title=n.title??a?.title,this.loc=n.location,this.code=i,this.status=n.status??a?.status??500,this.docsUrl=n.docsUrl??a?.docsUrl,this.data=n.data}};export{d as a,o as b};
@@ -1 +1 @@
1
- import{a as le}from"./chunk-UGUEC6BC.js";import{a as te}from"./chunk-CACB34RQ.js";import"./chunk-XNJNSCLM.js";import{a as ae,b as se,c as oe,d as Q,e as $,f as z}from"./chunk-GTM65MVX.js";import{a as re}from"./chunk-VLXV72QE.js";import{a as C}from"./chunk-JSEXCW5Q.js";import{a as ee}from"./chunk-UKDJ4H7I.js";import"./chunk-TBMYIZIO.js";import{R as E}from"./chunk-3CJW6NWG.js";import{c as k}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as L}from"./chunk-BOXSWNXZ.js";import{a as J}from"./chunk-TAD43CG5.js";import{b as U}from"./chunk-C7WTJLC3.js";import{a as j,b as K,c as V,d as Y,e as q}from"./chunk-SEU5V7I6.js";import{b as I}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as W}from"./chunk-GLUNBZRI.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as O,e as G,f as X,g as Z,k as D}from"./chunk-E75ANNWX.js";import"./chunk-GMSGZDDH.js";import{a as n,e as B,f as ve,g as he,h as xe}from"./chunk-RRCPZMC2.js";var c=B(ve(),1);var ne=B(he(),1);var e=B(xe(),1);var ie=["read","insert","update","delete"],ye=n((a,t)=>({delete:a("Delete"),insert:a("Insert"),read:a("Read"),update:a("Update")})[t],"operationLabel"),ge=n(a=>{let t=new Set;for(let l of a?.advisories??[])if(l.name==="rls_uncovered_table"){let{table:r}=l.metadata;typeof r=="string"&&r!==""&&t.add(r)}return t},"uncoveredTables"),be=n((a,t,l)=>{let r=new Map,s=n(o=>{let d=r.get(o);if(d!==void 0)return d;let i={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:[],table:o,uncovered:l.has(o)};return r.set(o,i),i},"ensure");for(let o of a)s(o.table).cells[o.on]={procedure:o.procedure};for(let o of t){let d=s(o.table);d.maskedColumns.includes(o.column)||d.maskedColumns.push(o.column)}for(let o of l)s(o);return[...r.values()].toSorted((o,d)=>o.table.localeCompare(d.table))},"buildRows"),Ne=n(a=>{let t=(0,ne.c)(17),l;t[0]!==a?(l=a===void 0?{}:a,t[0]=a,t[1]=l):l=t[1];let{onProbe:r}=l,s=O(),o,d;t[2]===Symbol.for("react.memo_cache_sentinel")?(o={},d={live:!0},t[2]=o,t[3]=d):(o=t[2],d=t[3]);let i=U(L.rlsPolicies,o,d),x;t[4]===Symbol.for("react.memo_cache_sentinel")?(x={},t[4]=x):x=t[4];let p=U(L.maskPolicies,x),v;t[5]===Symbol.for("react.memo_cache_sentinel")?(v={},t[5]=v):v=t[5];let b=U(L.getAdvisories,v),N;if(t[6]!==b.data||t[7]!==p.data||t[8]!==r||t[9]!==i||t[10]!==s){let g=null;i.data!==void 0&&(g=Array.isArray(i.data.policies)?i.data.policies:[]);let _=Array.isArray(p.data?.columns)?p.data.columns:[],F=b.data??null,{error:h,errorSource:m,liveError:P}=i,A=g===null?[]:be(g,_,ge(F)),T;t[12]!==P?(T=(0,e.jsxDEV)("div",{className:"flex items-center justify-end",children:(0,e.jsxDEV)(le,{message:P,prefix:"pm"},void 0,!1)},void 0,!1),t[12]=P,t[13]=T):T=t[13];let y;t[14]!==h||t[15]!==m?(y=h!==null&&(0,e.jsxDEV)(te,{error:m,testId:"pm-error"},void 0,!1),t[14]=h,t[15]=m,t[16]=y):y=t[16],N=(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[T,y,g!==null&&A.length===0?(0,e.jsxDEV)(J,{description:s("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:s("No policy")},void 0,!1):(0,e.jsxDEV)(ae,{"data-testid":"pm-table",children:[(0,e.jsxDEV)(se,{children:(0,e.jsxDEV)(Q,{children:[(0,e.jsxDEV)($,{children:s("Table")},void 0,!1),ie.map(u=>(0,e.jsxDEV)($,{children:ye(s,u)},u,!1)),(0,e.jsxDEV)($,{children:s("Masked columns")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(oe,{children:A.map(u=>(0,e.jsxDEV)(Q,{"data-testid":`pm-row-${u.table}`,children:[(0,e.jsxDEV)(z,{className:"font-mono text-xs",children:(0,e.jsxDEV)("span",{className:"flex items-center gap-1.5",children:[u.table,u.uncovered&&(0,e.jsxDEV)(I,{"data-testid":`pm-uncovered-${u.table}`,title:s("Uncovered \u2014 reachable without a policy"),variant:"destructive",children:s("Uncovered \u2014 reachable without a policy")},void 0,!1)]},void 0,!0)},void 0,!1),ie.map(w=>{let R=u.cells[w];return(0,e.jsxDEV)(z,{"data-testid":`pm-cell-${u.table}-${w}`,children:R.procedure===void 0?(0,e.jsxDEV)("span",{className:"text-xs text-muted-foreground",children:s("No policy")},void 0,!1):(0,e.jsxDEV)("span",{className:"flex flex-col gap-1",children:[(0,e.jsxDEV)(I,{variant:"secondary",children:s("Covered by {procedure}",{procedure:R.procedure})},void 0,!1),r!==void 0&&(0,e.jsxDEV)(k,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${u.table}-${w}`,onClick:n(()=>{r(u.table,w,R.procedure??"")},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Probe this")},void 0,!1)]},void 0,!0)},w,!1)}),(0,e.jsxDEV)(z,{children:u.maskedColumns.length===0?(0,e.jsxDEV)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"},void 0,!1):(0,e.jsxDEV)("span",{className:"flex flex-wrap gap-1",children:u.maskedColumns.map(ke)},void 0,!1)},void 0,!1)]},u.table,!0))},void 0,!1)]},void 0,!0)]},void 0,!0),t[6]=b.data,t[7]=p.data,t[8]=r,t[9]=i,t[10]=s,t[11]=N}else N=t[11];return N},"PermissionsMatrix");function ke(a){return(0,e.jsxDEV)(I,{variant:"outline",children:a},a,!1)}n(ke,"_temp");var Ce=G(L.runAs),we=n(()=>{let a=W();return async({args:t,functionPath:l,shardKey:r="",userId:s})=>{let o=Ce;try{return{kind:"allowed",value:await a.query(o,{args:t,functionPath:l,userId:s},X(r))}}catch(d){return{kind:"denied",message:d instanceof Error?d.message:String(d)}}}},"useRunAsProbe"),Se=n(a=>a===void 0?"undefined":JSON.stringify(a,null,2),"formatValue"),Pe=n(({functions:a,prefill:t,runAsIdentity:l=!1}={})=>{let r=W(),s=O(),o=we(),[d,i]=(0,c.useState)(null),[x,p]=(0,c.useState)(null),v=a??d??[],[b,N]=(0,c.useState)(""),[g,_]=(0,c.useState)("{}"),[F,h]=(0,c.useState)(""),[m,P]=(0,c.useState)(""),[A,T]=(0,c.useState)(!1),[y,u]=(0,c.useState)(null),[w,R]=(0,c.useState)(null),H=(0,c.useRef)(-1);(0,c.useEffect)(()=>{if(a!==void 0)return;let f=!1;return r.listFunctions().then(S=>(f||i(S),S)).catch(S=>{f||p(Z(S))}),()=>{f=!0}},[r,a]),(0,c.useEffect)(()=>{if(t===void 0||H.current===t.nonce)return;H.current=t.nonce;let f=t.functionPath;queueMicrotask(()=>{N(f),u(null)})},[t]);let M=b===""?v[0]?.path??"":b,ce=n(async()=>{if(M==="")return;let f;try{f=g.trim()===""?{}:JSON.parse(g)}catch(S){R(s("Invalid JSON args: {message}",{message:S.message})),u(null);return}R(null),T(!0);try{let S=await o({args:f,functionPath:M,shardKey:F.trim(),userId:m.trim()});u(S)}finally{T(!1)}},"run"),fe=n(()=>{D(ce())},"runOnce"),ue=n(f=>{N(f.target.value)},"onSelectChange"),me=n(f=>{_(f.target.value)},"onArgsChange"),pe=n(f=>{P(f.target.value)},"onUserIdChange");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[x!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:x},void 0,!1),!l&&(0,e.jsxDEV)(J,{description:s("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:s("Set `runAsIdentity` to forge an identity and probe access.")},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxDEV)(C,{htmlFor:"pp-function",children:s("Function")},void 0,!1),(0,e.jsxDEV)("select",{"aria-label":s("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","data-testid":"pp-function",id:"pp-function",onChange:ue,value:M,children:v.map(f=>(0,e.jsxDEV)("option",{value:f.path,children:[f.path," (",f.kind,")"]},f.path,!0))},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxDEV)(C,{htmlFor:"pp-args",children:s("Arguments")},void 0,!1),(0,e.jsxDEV)(re,{"aria-label":s("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:me,value:g},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(ee,{onChange:h,testId:"pp-shard",value:F},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxDEV)(C,{htmlFor:"pp-user",children:s("Run as (userId)")},void 0,!1),(0,e.jsxDEV)(E,{"aria-label":s("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:pe,placeholder:s("Leave empty to run as admin"),value:m},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex items-center gap-2",children:[(0,e.jsxDEV)(k,{"data-testid":"pp-run",disabled:!l||A||M==="",onClick:fe,type:"button",children:s(A?"Probing\u2026":"Run probe")},void 0,!1),m.trim()!==""&&(0,e.jsxDEV)(I,{"data-testid":"pp-as-badge",variant:"secondary",children:s("as {userId}",{userId:m.trim()})},void 0,!1)]},void 0,!0)]},void 0,!0),w!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:w},void 0,!1),y!==null&&y.kind==="allowed"&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[(0,e.jsxDEV)(I,{variant:"secondary",children:s("Allowed")},void 0,!1),(0,e.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:Se(y.value)},void 0,!1)]},void 0,!0),y!==null&&y.kind==="denied"&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[(0,e.jsxDEV)(I,{variant:"destructive",children:s("Denied")},void 0,!1),(0,e.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"pp-denied",role:"alert",children:y.message},void 0,!1)]},void 0,!0)]},void 0,!0)},"PermissionsPlayground"),Ae="/__lunora/policy-scaffold",Te={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists \u2014 pick another name or edit it by hand.","invalid-identifier":"Name, table, and policy-set must be plain identifiers (letters, digits, _ or $).","unknown-procedure":"No exported procedure was found at that file path.","unsupported-procedure-shape":"That procedure uses the bare query({\u2026}) form \u2014 convert it to the builder form (c.use(\u2026).query(\u2026)) before wiring RLS."},Ie=n(async a=>{let t=await fetch(Ae,{body:JSON.stringify(a),headers:{"Content-Type":"application/json"},method:"POST"}),l=await t.json();if(l.needsManualEdit===!0)return{kind:"needs-manual-edit",message:l.message??"This change must be made by hand."};if(t.ok)return{diagnostics:l.diagnostics??[],kind:"ok",label:l.fileName??l.exportName??""};let r=l.error;return{kind:"error",message:r===void 0?`policy scaffold failed (${String(t.status)})`:Te[r]??r}},"applyPolicyScaffold"),de={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Ee=n(()=>{let a=O(),[t,l]=(0,c.useState)(null),[r,s]=(0,c.useState)(!1),[o,d]=(0,c.useState)(null),[i,x]=(0,c.useState)(de),p=n(h=>{let m=h.target.name,{value:P}=h.target;x(A=>({...A,[m]:P}))},"onFieldChange"),v=n(()=>{l(null),x(de)},"reset"),b=n(async h=>{s(!0),d(null);try{let m=await Ie(h);d(m),m.kind==="ok"&&v()}catch(m){d({kind:"error",message:m instanceof Error?m.message:String(m)})}finally{s(!1)}},"submit"),N=n(()=>{D(b({kind:"scaffoldPolicy",name:i.policyName.trim(),table:i.tableName.trim()}))},"onSubmitScaffold"),g=n(()=>{D(b({exportName:i.exportName.trim(),filePath:i.filePath.trim(),kind:"wireRls",policies:i.policies.trim()}))},"onSubmitWire"),_=n(()=>{d(null),l("scaffold")},"openScaffold"),F=n(()=>{d(null),l("wire")},"openWire");return(0,e.jsxDEV)(j,{"data-testid":"policy-scaffolder",size:"sm",children:[(0,e.jsxDEV)(K,{children:[(0,e.jsxDEV)(V,{children:a("Scaffold access rules")},void 0,!1),(0,e.jsxDEV)(Y,{children:a("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only.")},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(q,{children:[(0,e.jsxDEV)("div",{className:"flex flex-wrap gap-2",children:[(0,e.jsxDEV)(k,{"data-testid":"policy-scaffolder-new",onClick:_,size:"xs",type:"button",variant:t==="scaffold"?"default":"outline",children:a("New policy file")},void 0,!1),(0,e.jsxDEV)(k,{"data-testid":"policy-scaffolder-wire",onClick:F,size:"xs",type:"button",variant:t==="wire"?"default":"outline",children:a("Wire into a procedure")},void 0,!1)]},void 0,!0),t==="scaffold"&&(0,e.jsxDEV)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-name",children:a("Policy name")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:p,value:i.policyName},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-table",children:a("Table name")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:p,value:i.tableName},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(k,{"data-testid":"policy-scaffolder-create",disabled:r||i.policyName.trim()===""||i.tableName.trim()==="",onClick:N,size:"xs",type:"button",children:a(r?"Creating\u2026":"Create policy file")},void 0,!1),(0,e.jsxDEV)(k,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")},void 0,!1)]},void 0,!0),t==="wire"&&(0,e.jsxDEV)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-file",children:a("Procedure file path")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:p,value:i.filePath},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-export",children:a("Exported procedure")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:p,value:i.exportName},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-policies",children:a("Policy set identifier")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:p,value:i.policies},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(k,{"data-testid":"policy-scaffolder-apply",disabled:r||i.filePath.trim()===""||i.exportName.trim()===""||i.policies.trim()==="",onClick:g,size:"xs",type:"button",children:a(r?"Wiring\u2026":"Wire RLS")},void 0,!1),(0,e.jsxDEV)(k,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")},void 0,!1)]},void 0,!0),o?.kind==="error"&&(0,e.jsxDEV)("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:o.message},void 0,!1),o?.kind==="needs-manual-edit"&&(0,e.jsxDEV)("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:a("This change must be made by hand \u2014 the scaffolder only adds new, deny-by-default rules.")},void 0,!1),o?.kind==="ok"&&(0,e.jsxDEV)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[(0,e.jsxDEV)("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:a("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:o.label})},void 0,!1),o.diagnostics.length>0&&(0,e.jsxDEV)("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:o.diagnostics.map(h=>(0,e.jsxDEV)("li",{className:"font-mono text-[11px] text-destructive",children:h},h,!1))},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0)},"PolicyScaffolder"),He=n(({functions:a,runAsIdentity:t=!1,schemaEditable:l=!1}={})=>{let r=O(),[s,o]=(0,c.useState)(void 0),d=n((i,x,p)=>{p!==""&&o(v=>({functionPath:p,nonce:(v?.nonce??0)+1}))},"onProbe");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[(0,e.jsxDEV)("section",{className:"flex flex-col gap-3",children:[(0,e.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Permissions")},void 0,!1)},void 0,!1),(0,e.jsxDEV)(Ne,{onProbe:d},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("section",{className:"flex flex-col gap-3",children:(0,e.jsxDEV)(j,{className:"gap-0 py-0",children:[(0,e.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Probe")},void 0,!1)},void 0,!1),(0,e.jsxDEV)(q,{className:"px-4 py-4",children:[(0,e.jsxDEV)("p",{className:"mb-3 text-sm text-muted-foreground",children:r("Pick a function and an identity, then run it to see the access outcome.")},void 0,!1),(0,e.jsxDEV)(Pe,{functions:a,prefill:s,runAsIdentity:t},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1),l&&(0,e.jsxDEV)("section",{className:"flex flex-col gap-2",children:(0,e.jsxDEV)(Ee,{},void 0,!1)},void 0,!1)]},void 0,!0)},"PermissionsPanel");export{He as PermissionsPanel};
1
+ import{a as le}from"./chunk-UGUEC6BC.js";import{a as te}from"./chunk-HN6KJXYQ.js";import"./chunk-XNJNSCLM.js";import{a as ae,b as se,c as oe,d as Q,e as $,f as z}from"./chunk-GTM65MVX.js";import{a as re}from"./chunk-VLXV72QE.js";import{a as C}from"./chunk-JSEXCW5Q.js";import{a as ee}from"./chunk-UKDJ4H7I.js";import"./chunk-TBMYIZIO.js";import{R as E}from"./chunk-3CJW6NWG.js";import{c as k}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as L}from"./chunk-BOXSWNXZ.js";import{a as J}from"./chunk-TAD43CG5.js";import{b as U}from"./chunk-RHZ4M2NZ.js";import{a as j,b as K,c as V,d as Y,e as q}from"./chunk-SEU5V7I6.js";import{b as I}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as W}from"./chunk-XLXNLJ4N.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as O,e as G,f as X,g as Z,k as D}from"./chunk-E75ANNWX.js";import"./chunk-JHKMUTIF.js";import{a as n,e as B,f as ve,g as he,h as xe}from"./chunk-RRCPZMC2.js";var c=B(ve(),1);var ne=B(he(),1);var e=B(xe(),1);var ie=["read","insert","update","delete"],ye=n((a,t)=>({delete:a("Delete"),insert:a("Insert"),read:a("Read"),update:a("Update")})[t],"operationLabel"),ge=n(a=>{let t=new Set;for(let l of a?.advisories??[])if(l.name==="rls_uncovered_table"){let{table:r}=l.metadata;typeof r=="string"&&r!==""&&t.add(r)}return t},"uncoveredTables"),be=n((a,t,l)=>{let r=new Map,s=n(o=>{let d=r.get(o);if(d!==void 0)return d;let i={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:[],table:o,uncovered:l.has(o)};return r.set(o,i),i},"ensure");for(let o of a)s(o.table).cells[o.on]={procedure:o.procedure};for(let o of t){let d=s(o.table);d.maskedColumns.includes(o.column)||d.maskedColumns.push(o.column)}for(let o of l)s(o);return[...r.values()].toSorted((o,d)=>o.table.localeCompare(d.table))},"buildRows"),Ne=n(a=>{let t=(0,ne.c)(17),l;t[0]!==a?(l=a===void 0?{}:a,t[0]=a,t[1]=l):l=t[1];let{onProbe:r}=l,s=O(),o,d;t[2]===Symbol.for("react.memo_cache_sentinel")?(o={},d={live:!0},t[2]=o,t[3]=d):(o=t[2],d=t[3]);let i=U(L.rlsPolicies,o,d),x;t[4]===Symbol.for("react.memo_cache_sentinel")?(x={},t[4]=x):x=t[4];let p=U(L.maskPolicies,x),v;t[5]===Symbol.for("react.memo_cache_sentinel")?(v={},t[5]=v):v=t[5];let b=U(L.getAdvisories,v),N;if(t[6]!==b.data||t[7]!==p.data||t[8]!==r||t[9]!==i||t[10]!==s){let g=null;i.data!==void 0&&(g=Array.isArray(i.data.policies)?i.data.policies:[]);let _=Array.isArray(p.data?.columns)?p.data.columns:[],F=b.data??null,{error:h,errorSource:m,liveError:P}=i,A=g===null?[]:be(g,_,ge(F)),T;t[12]!==P?(T=(0,e.jsxDEV)("div",{className:"flex items-center justify-end",children:(0,e.jsxDEV)(le,{message:P,prefix:"pm"},void 0,!1)},void 0,!1),t[12]=P,t[13]=T):T=t[13];let y;t[14]!==h||t[15]!==m?(y=h!==null&&(0,e.jsxDEV)(te,{error:m,testId:"pm-error"},void 0,!1),t[14]=h,t[15]=m,t[16]=y):y=t[16],N=(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[T,y,g!==null&&A.length===0?(0,e.jsxDEV)(J,{description:s("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:s("No policy")},void 0,!1):(0,e.jsxDEV)(ae,{"data-testid":"pm-table",children:[(0,e.jsxDEV)(se,{children:(0,e.jsxDEV)(Q,{children:[(0,e.jsxDEV)($,{children:s("Table")},void 0,!1),ie.map(u=>(0,e.jsxDEV)($,{children:ye(s,u)},u,!1)),(0,e.jsxDEV)($,{children:s("Masked columns")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(oe,{children:A.map(u=>(0,e.jsxDEV)(Q,{"data-testid":`pm-row-${u.table}`,children:[(0,e.jsxDEV)(z,{className:"font-mono text-xs",children:(0,e.jsxDEV)("span",{className:"flex items-center gap-1.5",children:[u.table,u.uncovered&&(0,e.jsxDEV)(I,{"data-testid":`pm-uncovered-${u.table}`,title:s("Uncovered \u2014 reachable without a policy"),variant:"destructive",children:s("Uncovered \u2014 reachable without a policy")},void 0,!1)]},void 0,!0)},void 0,!1),ie.map(w=>{let R=u.cells[w];return(0,e.jsxDEV)(z,{"data-testid":`pm-cell-${u.table}-${w}`,children:R.procedure===void 0?(0,e.jsxDEV)("span",{className:"text-xs text-muted-foreground",children:s("No policy")},void 0,!1):(0,e.jsxDEV)("span",{className:"flex flex-col gap-1",children:[(0,e.jsxDEV)(I,{variant:"secondary",children:s("Covered by {procedure}",{procedure:R.procedure})},void 0,!1),r!==void 0&&(0,e.jsxDEV)(k,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${u.table}-${w}`,onClick:n(()=>{r(u.table,w,R.procedure??"")},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Probe this")},void 0,!1)]},void 0,!0)},w,!1)}),(0,e.jsxDEV)(z,{children:u.maskedColumns.length===0?(0,e.jsxDEV)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"},void 0,!1):(0,e.jsxDEV)("span",{className:"flex flex-wrap gap-1",children:u.maskedColumns.map(ke)},void 0,!1)},void 0,!1)]},u.table,!0))},void 0,!1)]},void 0,!0)]},void 0,!0),t[6]=b.data,t[7]=p.data,t[8]=r,t[9]=i,t[10]=s,t[11]=N}else N=t[11];return N},"PermissionsMatrix");function ke(a){return(0,e.jsxDEV)(I,{variant:"outline",children:a},a,!1)}n(ke,"_temp");var Ce=G(L.runAs),we=n(()=>{let a=W();return async({args:t,functionPath:l,shardKey:r="",userId:s})=>{let o=Ce;try{return{kind:"allowed",value:await a.query(o,{args:t,functionPath:l,userId:s},X(r))}}catch(d){return{kind:"denied",message:d instanceof Error?d.message:String(d)}}}},"useRunAsProbe"),Se=n(a=>a===void 0?"undefined":JSON.stringify(a,null,2),"formatValue"),Pe=n(({functions:a,prefill:t,runAsIdentity:l=!1}={})=>{let r=W(),s=O(),o=we(),[d,i]=(0,c.useState)(null),[x,p]=(0,c.useState)(null),v=a??d??[],[b,N]=(0,c.useState)(""),[g,_]=(0,c.useState)("{}"),[F,h]=(0,c.useState)(""),[m,P]=(0,c.useState)(""),[A,T]=(0,c.useState)(!1),[y,u]=(0,c.useState)(null),[w,R]=(0,c.useState)(null),H=(0,c.useRef)(-1);(0,c.useEffect)(()=>{if(a!==void 0)return;let f=!1;return r.listFunctions().then(S=>(f||i(S),S)).catch(S=>{f||p(Z(S))}),()=>{f=!0}},[r,a]),(0,c.useEffect)(()=>{if(t===void 0||H.current===t.nonce)return;H.current=t.nonce;let f=t.functionPath;queueMicrotask(()=>{N(f),u(null)})},[t]);let M=b===""?v[0]?.path??"":b,ce=n(async()=>{if(M==="")return;let f;try{f=g.trim()===""?{}:JSON.parse(g)}catch(S){R(s("Invalid JSON args: {message}",{message:S.message})),u(null);return}R(null),T(!0);try{let S=await o({args:f,functionPath:M,shardKey:F.trim(),userId:m.trim()});u(S)}finally{T(!1)}},"run"),fe=n(()=>{D(ce())},"runOnce"),ue=n(f=>{N(f.target.value)},"onSelectChange"),me=n(f=>{_(f.target.value)},"onArgsChange"),pe=n(f=>{P(f.target.value)},"onUserIdChange");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[x!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:x},void 0,!1),!l&&(0,e.jsxDEV)(J,{description:s("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:s("Set `runAsIdentity` to forge an identity and probe access.")},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxDEV)(C,{htmlFor:"pp-function",children:s("Function")},void 0,!1),(0,e.jsxDEV)("select",{"aria-label":s("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","data-testid":"pp-function",id:"pp-function",onChange:ue,value:M,children:v.map(f=>(0,e.jsxDEV)("option",{value:f.path,children:[f.path," (",f.kind,")"]},f.path,!0))},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxDEV)(C,{htmlFor:"pp-args",children:s("Arguments")},void 0,!1),(0,e.jsxDEV)(re,{"aria-label":s("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:me,value:g},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(ee,{onChange:h,testId:"pp-shard",value:F},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxDEV)(C,{htmlFor:"pp-user",children:s("Run as (userId)")},void 0,!1),(0,e.jsxDEV)(E,{"aria-label":s("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:pe,placeholder:s("Leave empty to run as admin"),value:m},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex items-center gap-2",children:[(0,e.jsxDEV)(k,{"data-testid":"pp-run",disabled:!l||A||M==="",onClick:fe,type:"button",children:s(A?"Probing\u2026":"Run probe")},void 0,!1),m.trim()!==""&&(0,e.jsxDEV)(I,{"data-testid":"pp-as-badge",variant:"secondary",children:s("as {userId}",{userId:m.trim()})},void 0,!1)]},void 0,!0)]},void 0,!0),w!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:w},void 0,!1),y!==null&&y.kind==="allowed"&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[(0,e.jsxDEV)(I,{variant:"secondary",children:s("Allowed")},void 0,!1),(0,e.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:Se(y.value)},void 0,!1)]},void 0,!0),y!==null&&y.kind==="denied"&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[(0,e.jsxDEV)(I,{variant:"destructive",children:s("Denied")},void 0,!1),(0,e.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"pp-denied",role:"alert",children:y.message},void 0,!1)]},void 0,!0)]},void 0,!0)},"PermissionsPlayground"),Ae="/__lunora/policy-scaffold",Te={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists \u2014 pick another name or edit it by hand.","invalid-identifier":"Name, table, and policy-set must be plain identifiers (letters, digits, _ or $).","unknown-procedure":"No exported procedure was found at that file path.","unsupported-procedure-shape":"That procedure uses the bare query({\u2026}) form \u2014 convert it to the builder form (c.use(\u2026).query(\u2026)) before wiring RLS."},Ie=n(async a=>{let t=await fetch(Ae,{body:JSON.stringify(a),headers:{"Content-Type":"application/json"},method:"POST"}),l=await t.json();if(l.needsManualEdit===!0)return{kind:"needs-manual-edit",message:l.message??"This change must be made by hand."};if(t.ok)return{diagnostics:l.diagnostics??[],kind:"ok",label:l.fileName??l.exportName??""};let r=l.error;return{kind:"error",message:r===void 0?`policy scaffold failed (${String(t.status)})`:Te[r]??r}},"applyPolicyScaffold"),de={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Ee=n(()=>{let a=O(),[t,l]=(0,c.useState)(null),[r,s]=(0,c.useState)(!1),[o,d]=(0,c.useState)(null),[i,x]=(0,c.useState)(de),p=n(h=>{let m=h.target.name,{value:P}=h.target;x(A=>({...A,[m]:P}))},"onFieldChange"),v=n(()=>{l(null),x(de)},"reset"),b=n(async h=>{s(!0),d(null);try{let m=await Ie(h);d(m),m.kind==="ok"&&v()}catch(m){d({kind:"error",message:m instanceof Error?m.message:String(m)})}finally{s(!1)}},"submit"),N=n(()=>{D(b({kind:"scaffoldPolicy",name:i.policyName.trim(),table:i.tableName.trim()}))},"onSubmitScaffold"),g=n(()=>{D(b({exportName:i.exportName.trim(),filePath:i.filePath.trim(),kind:"wireRls",policies:i.policies.trim()}))},"onSubmitWire"),_=n(()=>{d(null),l("scaffold")},"openScaffold"),F=n(()=>{d(null),l("wire")},"openWire");return(0,e.jsxDEV)(j,{"data-testid":"policy-scaffolder",size:"sm",children:[(0,e.jsxDEV)(K,{children:[(0,e.jsxDEV)(V,{children:a("Scaffold access rules")},void 0,!1),(0,e.jsxDEV)(Y,{children:a("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only.")},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(q,{children:[(0,e.jsxDEV)("div",{className:"flex flex-wrap gap-2",children:[(0,e.jsxDEV)(k,{"data-testid":"policy-scaffolder-new",onClick:_,size:"xs",type:"button",variant:t==="scaffold"?"default":"outline",children:a("New policy file")},void 0,!1),(0,e.jsxDEV)(k,{"data-testid":"policy-scaffolder-wire",onClick:F,size:"xs",type:"button",variant:t==="wire"?"default":"outline",children:a("Wire into a procedure")},void 0,!1)]},void 0,!0),t==="scaffold"&&(0,e.jsxDEV)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-name",children:a("Policy name")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:p,value:i.policyName},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-table",children:a("Table name")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:p,value:i.tableName},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(k,{"data-testid":"policy-scaffolder-create",disabled:r||i.policyName.trim()===""||i.tableName.trim()==="",onClick:N,size:"xs",type:"button",children:a(r?"Creating\u2026":"Create policy file")},void 0,!1),(0,e.jsxDEV)(k,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")},void 0,!1)]},void 0,!0),t==="wire"&&(0,e.jsxDEV)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-file",children:a("Procedure file path")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:p,value:i.filePath},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-export",children:a("Exported procedure")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:p,value:i.exportName},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-policies",children:a("Policy set identifier")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:p,value:i.policies},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(k,{"data-testid":"policy-scaffolder-apply",disabled:r||i.filePath.trim()===""||i.exportName.trim()===""||i.policies.trim()==="",onClick:g,size:"xs",type:"button",children:a(r?"Wiring\u2026":"Wire RLS")},void 0,!1),(0,e.jsxDEV)(k,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")},void 0,!1)]},void 0,!0),o?.kind==="error"&&(0,e.jsxDEV)("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:o.message},void 0,!1),o?.kind==="needs-manual-edit"&&(0,e.jsxDEV)("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:a("This change must be made by hand \u2014 the scaffolder only adds new, deny-by-default rules.")},void 0,!1),o?.kind==="ok"&&(0,e.jsxDEV)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[(0,e.jsxDEV)("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:a("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:o.label})},void 0,!1),o.diagnostics.length>0&&(0,e.jsxDEV)("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:o.diagnostics.map(h=>(0,e.jsxDEV)("li",{className:"font-mono text-[11px] text-destructive",children:h},h,!1))},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0)},"PolicyScaffolder"),He=n(({functions:a,runAsIdentity:t=!1,schemaEditable:l=!1}={})=>{let r=O(),[s,o]=(0,c.useState)(void 0),d=n((i,x,p)=>{p!==""&&o(v=>({functionPath:p,nonce:(v?.nonce??0)+1}))},"onProbe");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[(0,e.jsxDEV)("section",{className:"flex flex-col gap-3",children:[(0,e.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Permissions")},void 0,!1)},void 0,!1),(0,e.jsxDEV)(Ne,{onProbe:d},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("section",{className:"flex flex-col gap-3",children:(0,e.jsxDEV)(j,{className:"gap-0 py-0",children:[(0,e.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Probe")},void 0,!1)},void 0,!1),(0,e.jsxDEV)(q,{className:"px-4 py-4",children:[(0,e.jsxDEV)("p",{className:"mb-3 text-sm text-muted-foreground",children:r("Pick a function and an identity, then run it to see the access outcome.")},void 0,!1),(0,e.jsxDEV)(Pe,{functions:a,prefill:s,runAsIdentity:t},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1),l&&(0,e.jsxDEV)("section",{className:"flex flex-col gap-2",children:(0,e.jsxDEV)(Ee,{},void 0,!1)},void 0,!1)]},void 0,!0)},"PermissionsPanel");export{He as PermissionsPanel};
@@ -1 +1 @@
1
- import{a as y}from"./chunk-C7WTJLC3.js";import{f as m}from"./chunk-GLUNBZRI.js";import{g as d,k as g}from"./chunk-E75ANNWX.js";import{a as o,e as f,f as A,g as b}from"./chunk-RRCPZMC2.js";var p=f(b(),1);var c=f(A(),1);var h={capabilities:{accounts:!0,admin:!0,organization:!1,passkey:!1,twoFactor:!1},emailAndPassword:!1,organization:{enabled:!1,roles:!1,teams:!1},plugins:[],rateLimit:{enabled:!1},session:{},socialProviders:[],userFields:[]},L=o(()=>{let e=(0,p.c)(6),t=m(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=["lunora-auth-config"],e[0]=a):a=e[0];let s;e[1]!==t?(s=o(()=>t.getAuthConfig(),"t1"),e[1]=t,e[2]=s):s=e[2];let{data:u,isLoading:i}=y(a,s),r=u??h,l=!i,n;return e[3]!==r||e[4]!==l?(n={config:r,ready:l},e[3]=r,e[4]=l,e[5]=n):n=e[5],n},"useAuthConfig"),w=o(()=>{let[e,t]=(0,c.useState)(!1),[a,s]=(0,c.useState)(null);return{busy:e,error:a,run:o(i=>{g((async()=>{t(!0),s(null);try{await i()}catch(r){s(d(r))}finally{t(!1)}})())},"run")}},"useAsyncSubmit");export{L as a,w as b};
1
+ import{a as y}from"./chunk-RHZ4M2NZ.js";import{f as m}from"./chunk-XLXNLJ4N.js";import{g as d,k as g}from"./chunk-E75ANNWX.js";import{a as o,e as f,f as A,g as b}from"./chunk-RRCPZMC2.js";var p=f(b(),1);var c=f(A(),1);var h={capabilities:{accounts:!0,admin:!0,organization:!1,passkey:!1,twoFactor:!1},emailAndPassword:!1,organization:{enabled:!1,roles:!1,teams:!1},plugins:[],rateLimit:{enabled:!1},session:{},socialProviders:[],userFields:[]},L=o(()=>{let e=(0,p.c)(6),t=m(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=["lunora-auth-config"],e[0]=a):a=e[0];let s;e[1]!==t?(s=o(()=>t.getAuthConfig(),"t1"),e[1]=t,e[2]=s):s=e[2];let{data:u,isLoading:i}=y(a,s),r=u??h,l=!i,n;return e[3]!==r||e[4]!==l?(n={config:r,ready:l},e[3]=r,e[4]=l,e[5]=n):n=e[5],n},"useAuthConfig"),w=o(()=>{let[e,t]=(0,c.useState)(!1),[a,s]=(0,c.useState)(null);return{busy:e,error:a,run:o(i=>{g((async()=>{t(!0),s(null);try{await i()}catch(r){s(d(r))}finally{t(!1)}})())},"run")}},"useAsyncSubmit");export{L as a,w as b};
@@ -1 +1 @@
1
- import{a as g,b as S}from"./chunk-DC72CQY4.js";import{a as i,e as m,g as v,h as C,j as d}from"./chunk-RRCPZMC2.js";var w=i(e=>{let t=0,n=0,o=0,r=0,s=0,l=0,c=0;for(let{metrics:a}of e){if(a===null){s+=1;continue}r+=1,t+=a.requests,n+=a.errors,o+=a.databaseSize??0,a.cache!==null&&(l+=a.cache.hits,c+=a.cache.hits+a.cache.misses)}return{failed:s,hitRate:c===0?null:l/c,reachable:r,totalDatabaseSize:o,totalErrors:n,totalRequests:t}},"aggregateMetrics"),E=i((e,t)=>{let n=new Set,o=[];for(let r of["",e.trim(),...t])n.has(r)||(n.add(r),o.push(r));return o},"shardsToAggregate"),x=i((e,t)=>{if(e.length===0)return 0;if(e.sort((o,r)=>o-r),t<=0)return e[0]??0;if(t>=100)return e.at(-1)??0;let n=Math.ceil(t/100*e.length)-1;return e[n]??0},"percentile"),N=i(e=>{let n=e.functions;if(!n||n.length===0)return{p90:0,p95:0};let o=1e3,r=[];for(let s of n){if(s.calls<=0)continue;let l=s.totalDurationMs/s.calls,c=Math.min(s.calls,o);for(let a=0;a<c;a+=1)r.push(l)}return r.length===0?{p90:0,p95:0}:{p90:x([...r],90),p95:x([...r],95)}},"computeLatencyPercentiles");var _=i(e=>e.map(t=>({...t,avgDurationMs:t.execCount>0?t.totalDurationMs/t.execCount:0})),"enrichQueryStats");var b=m(v(),1);var p=m(C(),1);var D={value:{colors:{dark:["var(--foreground)"],light:["var(--foreground)"]},label:""}},P=i(e=>{let t=(0,b.c)(12),{ariaLabel:n,className:o,series:r,testId:s}=e;if(r.length<2)return null;let l;t[0]!==r?(l=r.slice(-40).map(M),t[0]=r,t[1]=l):l=t[1];let c=l,a;t[2]!==o?(a=d("h-6 w-[120px]",o),t[2]=o,t[3]=a):a=t[3];let u;t[4]===Symbol.for("react.memo_cache_sentinel")?(u=(0,p.jsxDEV)(S,{dataKey:"value"},void 0,!1),t[4]=u):u=t[4];let f;t[5]!==c?(f=(0,p.jsxDEV)(g,{animationType:"none",barCategoryGap:1,className:"h-full w-full",config:D,data:c,children:u},void 0,!1),t[5]=c,t[6]=f):f=t[6];let h;return t[7]!==n||t[8]!==a||t[9]!==f||t[10]!==s?(h=(0,p.jsxDEV)("div",{"aria-label":n,className:a,"data-testid":s,role:"img",children:f},void 0,!1),t[7]=n,t[8]=a,t[9]=f,t[10]=s,t[11]=h):h=t[11],h},"Sparkline");function M(e,t){return{index:t,value:e}}i(M,"_temp");export{w as a,E as b,N as c,_ as d,P as e};
1
+ import{a as g,b as S}from"./chunk-6HSHEMZV.js";import{a as i,e as m,g as v,h as C,j as d}from"./chunk-RRCPZMC2.js";var w=i(e=>{let t=0,n=0,o=0,r=0,s=0,l=0,c=0;for(let{metrics:a}of e){if(a===null){s+=1;continue}r+=1,t+=a.requests,n+=a.errors,o+=a.databaseSize??0,a.cache!==null&&(l+=a.cache.hits,c+=a.cache.hits+a.cache.misses)}return{failed:s,hitRate:c===0?null:l/c,reachable:r,totalDatabaseSize:o,totalErrors:n,totalRequests:t}},"aggregateMetrics"),E=i((e,t)=>{let n=new Set,o=[];for(let r of["",e.trim(),...t])n.has(r)||(n.add(r),o.push(r));return o},"shardsToAggregate"),x=i((e,t)=>{if(e.length===0)return 0;if(e.sort((o,r)=>o-r),t<=0)return e[0]??0;if(t>=100)return e.at(-1)??0;let n=Math.ceil(t/100*e.length)-1;return e[n]??0},"percentile"),N=i(e=>{let n=e.functions;if(!n||n.length===0)return{p90:0,p95:0};let o=1e3,r=[];for(let s of n){if(s.calls<=0)continue;let l=s.totalDurationMs/s.calls,c=Math.min(s.calls,o);for(let a=0;a<c;a+=1)r.push(l)}return r.length===0?{p90:0,p95:0}:{p90:x([...r],90),p95:x([...r],95)}},"computeLatencyPercentiles");var _=i(e=>e.map(t=>({...t,avgDurationMs:t.execCount>0?t.totalDurationMs/t.execCount:0})),"enrichQueryStats");var b=m(v(),1);var p=m(C(),1);var D={value:{colors:{dark:["var(--foreground)"],light:["var(--foreground)"]},label:""}},P=i(e=>{let t=(0,b.c)(12),{ariaLabel:n,className:o,series:r,testId:s}=e;if(r.length<2)return null;let l;t[0]!==r?(l=r.slice(-40).map(M),t[0]=r,t[1]=l):l=t[1];let c=l,a;t[2]!==o?(a=d("h-6 w-[120px]",o),t[2]=o,t[3]=a):a=t[3];let u;t[4]===Symbol.for("react.memo_cache_sentinel")?(u=(0,p.jsxDEV)(S,{dataKey:"value"},void 0,!1),t[4]=u):u=t[4];let f;t[5]!==c?(f=(0,p.jsxDEV)(g,{animationType:"none",barCategoryGap:1,className:"h-full w-full",config:D,data:c,children:u},void 0,!1),t[5]=c,t[6]=f):f=t[6];let h;return t[7]!==n||t[8]!==a||t[9]!==f||t[10]!==s?(h=(0,p.jsxDEV)("div",{"aria-label":n,className:a,"data-testid":s,role:"img",children:f},void 0,!1),t[7]=n,t[8]=a,t[9]=f,t[10]=s,t[11]=h):h=t[11],h},"Sparkline");function M(e,t){return{index:t,value:e}}i(M,"_temp");export{w as a,E as b,N as c,_ as d,P as e};
@@ -1 +1 @@
1
- import{a as $,b as F,c as D,d as p,e as l,f as i}from"./chunk-GTM65MVX.js";import{a as se}from"./chunk-VLXV72QE.js";import{R as te}from"./chunk-3CJW6NWG.js";import{c as T}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as K}from"./chunk-BOXSWNXZ.js";import{a as B}from"./chunk-TAD43CG5.js";import{b as ae}from"./chunk-C7WTJLC3.js";import{a as R,e as _}from"./chunk-SEU5V7I6.js";import"./chunk-CKSHCYGC.js";import{f as Q}from"./chunk-GLUNBZRI.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as V,e as X,f as Y,g as E,k as W}from"./chunk-E75ANNWX.js";import"./chunk-GMSGZDDH.js";import{a as r,e as ee,f as re,h as le}from"./chunk-RRCPZMC2.js";var n=ee(re(),1);var e=ee(le(),1);var ie=["queued","running","paused","waiting","complete","errored","terminated"],ne=["pause","resume","terminate"],de="WORKFLOWS_NOT_CONFIGURED",ce=r(c=>typeof c=="object"&&c!==null&&c.code===de,"isNotConfigured"),fe=r(c=>{let s=c.error??c.output;if(s===void 0)return"\u2014";try{return JSON.stringify(s)}catch{return"(unserializable)"}},"formatStepPayload"),ue=r(({loadDetail:c,loadInstances:s,readOnly:y,runAction:L,workflowName:v})=>{let A=Q(),o=V(),[x,N]=(0,n.useState)(null),[k,I]=(0,n.useState)(null),[w,P]=(0,n.useState)(""),[g,h]=(0,n.useState)(null),[U,S]=(0,n.useState)(!1),[z,J]=(0,n.useState)(null),m=c??(a=>A.getWorkflowInstance(a)),O=y?void 0:L??(s===void 0?a=>A.setWorkflowInstanceStatus(a):void 0),j=r(async()=>{h(null),S(!1);let a=w===""?void 0:w;try{if(s===void 0){let d=await A.listWorkflowInstances({name:v,status:a});if(d.configured===!1){N(null),S(!0);return}N(d.instances);return}N(await s({name:v,status:a}))}catch(d){N(null),ce(d)?S(!0):h(E(d))}},"load");(0,n.useEffect)(()=>{I(null),W(j())},[v,w]);let G=r(async a=>{h(null);try{I(await m({id:a,name:v}))}catch(d){h(E(d))}},"openDetail"),H=r(async(a,d)=>{if(O!==void 0){J(a),h(null);try{await O({action:d,id:a,name:v}),await j()}catch(M){h(E(M))}finally{J(null)}}},"act");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[(0,e.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxDEV)("h3",{className:"text-sm font-medium",children:o("Instance history")},void 0,!1),(0,e.jsxDEV)("select",{"aria-label":o("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:r(a=>{P(a.target.value)},"onChange"),value:w,children:[(0,e.jsxDEV)("option",{value:"",children:o("All statuses")},void 0,!1),ie.map(a=>(0,e.jsxDEV)("option",{value:a,children:a},a,!1))]},void 0,!0)]},void 0,!0),g!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:g},void 0,!1),U&&(0,e.jsxDEV)(B,{description:o("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:o("Workflow inspection not configured")},void 0,!1),!U&&x!==null&&x.length===0&&(0,e.jsxDEV)(B,{description:o("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:o("No instances")},void 0,!1),x!==null&&x.length>0&&(0,e.jsxDEV)(R,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(_,{className:"px-0",children:(0,e.jsxDEV)($,{"data-testid":"workflow-instances-table",children:[(0,e.jsxDEV)(F,{children:(0,e.jsxDEV)(p,{children:[(0,e.jsxDEV)(l,{children:o("Instance id")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Status")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Created")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Ended")},void 0,!1),(0,e.jsxDEV)(l,{"aria-label":o("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(D,{children:x.map(a=>(0,e.jsxDEV)(p,{"data-testid":`workflow-instance-${a.id}`,children:[(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:a.id},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:a.status},void 0,!1),(0,e.jsxDEV)(i,{className:"text-muted-foreground tabular-nums",children:a.createdOn??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"text-muted-foreground tabular-nums",children:a.endedOn??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"text-right",children:(0,e.jsxDEV)("div",{className:"flex justify-end gap-1.5",children:[(0,e.jsxDEV)(T,{"data-testid":`workflow-instance-steps-${a.id}`,onClick:r(()=>{W(G(a.id))},"onClick"),size:"sm",type:"button",variant:"outline",children:o("Steps")},void 0,!1),O!==void 0&&ne.map(d=>(0,e.jsxDEV)(T,{"data-testid":`workflow-instance-${d}-${a.id}`,disabled:z===a.id,onClick:r(()=>{W(H(a.id,d))},"onClick"),size:"sm",type:"button",variant:"ghost",children:o(d)},d,!1))]},void 0,!0)},void 0,!1)]},a.id,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),k!==null&&(0,e.jsxDEV)(R,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:(0,e.jsxDEV)(_,{className:"flex flex-col gap-2 px-4 py-3",children:[(0,e.jsxDEV)("div",{className:"flex items-center justify-between",children:[(0,e.jsxDEV)("span",{className:"font-mono text-xs",children:[o("Steps")," \xB7 ",k.id]},void 0,!0),(0,e.jsxDEV)(T,{"data-testid":"workflow-instance-detail-close",onClick:r(()=>{I(null)},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Close")},void 0,!1)]},void 0,!0),k.steps.length===0?(0,e.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:o("This instance has no recorded steps yet.")},void 0,!1):(0,e.jsxDEV)($,{"data-testid":"workflow-instance-steps",children:[(0,e.jsxDEV)(F,{children:(0,e.jsxDEV)(p,{children:[(0,e.jsxDEV)(l,{children:o("Step")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Type")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Attempts")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Started")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Output")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(D,{children:k.steps.map((a,d)=>(0,e.jsxDEV)(p,{"data-testid":`workflow-step-${String(d)}`,children:[(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:a.name},void 0,!1),(0,e.jsxDEV)(i,{className:"text-xs text-muted-foreground",children:a.type??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"tabular-nums",children:a.attempts??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"text-muted-foreground tabular-nums",children:a.start??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:fe(a)},void 0,!1)]},`${a.name}:${String(d)}`,!0))},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1)]},void 0,!0)},"WorkflowInstanceHistory"),me=X(K.createWorkflowInstance),ve=X(K.getWorkflowInstanceStatus),he=r(c=>{if(c.error)return`${c.error.name}: ${c.error.message}`;if(c.output===void 0)return"\u2014";try{return JSON.stringify(c.output)}catch{return"(unserializable)"}},"formatPayload"),Oe=r(()=>{let c=Q(),s=V(),{data:y,error:L}=ae(K.listWorkflows,{}),[v,A]=(0,n.useState)(""),[o,x]=(0,n.useState)(""),[N,k]=(0,n.useState)(""),[I,w]=(0,n.useState)(!1),[P,g]=(0,n.useState)(null),[h,U]=(0,n.useState)([]),[S,z]=(0,n.useState)(null),J=y!==void 0,m=(0,n.useMemo)(()=>Array.isArray(y?.workflows)?[...y.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],[y]),C=(0,n.useMemo)(()=>m.some(t=>t.exportName===v)?v:m[0]?.exportName??"",[m,v]),q=(0,n.useMemo)(()=>m.find(t=>t.exportName===C),[m,C]),O=r(t=>{U(u=>{let f=u.filter(b=>!(b.exportName===t.exportName&&b.id===t.id));return[t,...f]})},"upsertInstance"),j=r(async()=>{let t=C;if(t==="")return;let u,f=N.trim();if(f!=="")try{u=JSON.parse(f)}catch{g(s("Params must be valid JSON"));return}w(!0),g(null);try{let b=o.trim(),Z=await c.query(me,{exportName:t,id:b===""?void 0:b,params:u},Y(""));O({exportName:t,id:Z.id,status:Z.status}),x("")}catch(b){g(E(b))}finally{w(!1)}},"start"),G=r(()=>{W(j())},"startInstance"),H=r(async(t,u)=>{z(u);try{let f=await c.query(ve,{exportName:t,id:u},Y(""));O({error:f.error,exportName:t,id:f.id,output:f.output,status:f.status})}catch(f){g(E(f))}finally{z(null)}},"refreshInstance"),a=r(t=>{A(t.target.value)},"onSelectedExportChange"),d=r(t=>{x(t.target.value)},"onInstanceIdChange"),M=r(t=>{k(t.target.value)},"onParamsChange"),oe=r(t=>{let{export:u,id:f}=t.currentTarget.dataset;u!==void 0&&f!==void 0&&W(H(u,f))},"onRefreshClick");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[L!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:L},void 0,!1),(0,e.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:s("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")},void 0,!1),J&&m.length===0?(0,e.jsxDEV)(B,{description:s("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:s("No workflows defined")},void 0,!1):(0,e.jsxDEV)(R,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(_,{className:"px-0",children:(0,e.jsxDEV)($,{"data-testid":"workflows-table",children:[(0,e.jsxDEV)(F,{children:(0,e.jsxDEV)(p,{children:[(0,e.jsxDEV)(l,{children:s("Export")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Name")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Class")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Binding")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(D,{children:m.map(t=>(0,e.jsxDEV)(p,{"data-testid":`workflows-row-${t.exportName}`,children:[(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:t.exportName},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:t.name},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:t.className},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:t.binding},void 0,!1)]},t.exportName,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),m.length>0&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[(0,e.jsxDEV)("h3",{className:"text-sm font-medium",children:s("Start instance")},void 0,!1),P!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:P},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxDEV)("select",{"aria-label":s("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:a,value:C,children:m.map(t=>(0,e.jsxDEV)("option",{value:t.exportName,children:t.exportName},t.exportName,!1))},void 0,!1),(0,e.jsxDEV)(te,{"aria-label":s("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:d,placeholder:s("Instance id (optional)"),value:o},void 0,!1),(0,e.jsxDEV)(T,{"data-testid":"workflows-start-button",disabled:I||C==="",onClick:G,children:s(I?"Starting\u2026":"Start instance")},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(se,{"aria-label":s("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:M,placeholder:s("Params (JSON, optional)"),value:N},void 0,!1)]},void 0,!0),h.length>0&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[(0,e.jsxDEV)("h3",{className:"text-sm font-medium",children:s("Instances")},void 0,!1),(0,e.jsxDEV)(R,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(_,{className:"px-0",children:(0,e.jsxDEV)($,{"data-testid":"workflows-instances-table",children:[(0,e.jsxDEV)(F,{children:(0,e.jsxDEV)(p,{children:[(0,e.jsxDEV)(l,{children:s("Workflow")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Instance id")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Status")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Output")},void 0,!1),(0,e.jsxDEV)(l,{},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(D,{children:h.map(t=>(0,e.jsxDEV)(p,{"data-testid":`workflows-instance-${t.id}`,children:[(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:t.exportName},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:t.id},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:t.status},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:he(t)},void 0,!1),(0,e.jsxDEV)(i,{children:(0,e.jsxDEV)(T,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:S===t.id,onClick:oe,size:"xs",variant:"outline",children:S===t.id?s("Refreshing\u2026"):s("Refresh")},void 0,!1)},void 0,!1)]},`${t.exportName}:${t.id}`,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0),q!==void 0&&(0,e.jsxDEV)(ue,{workflowName:q.name},void 0,!1)]},void 0,!0)},"WorkflowsPanel");export{Oe as default};
1
+ import{a as $,b as F,c as D,d as p,e as l,f as i}from"./chunk-GTM65MVX.js";import{a as se}from"./chunk-VLXV72QE.js";import{R as te}from"./chunk-3CJW6NWG.js";import{c as T}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as K}from"./chunk-BOXSWNXZ.js";import{a as B}from"./chunk-TAD43CG5.js";import{b as ae}from"./chunk-RHZ4M2NZ.js";import{a as R,e as _}from"./chunk-SEU5V7I6.js";import"./chunk-CKSHCYGC.js";import{f as Q}from"./chunk-XLXNLJ4N.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as V,e as X,f as Y,g as E,k as W}from"./chunk-E75ANNWX.js";import"./chunk-JHKMUTIF.js";import{a as r,e as ee,f as re,h as le}from"./chunk-RRCPZMC2.js";var n=ee(re(),1);var e=ee(le(),1);var ie=["queued","running","paused","waiting","complete","errored","terminated"],ne=["pause","resume","terminate"],de="WORKFLOWS_NOT_CONFIGURED",ce=r(c=>typeof c=="object"&&c!==null&&c.code===de,"isNotConfigured"),fe=r(c=>{let s=c.error??c.output;if(s===void 0)return"\u2014";try{return JSON.stringify(s)}catch{return"(unserializable)"}},"formatStepPayload"),ue=r(({loadDetail:c,loadInstances:s,readOnly:y,runAction:L,workflowName:v})=>{let A=Q(),o=V(),[x,N]=(0,n.useState)(null),[k,I]=(0,n.useState)(null),[w,P]=(0,n.useState)(""),[g,h]=(0,n.useState)(null),[U,S]=(0,n.useState)(!1),[z,J]=(0,n.useState)(null),m=c??(a=>A.getWorkflowInstance(a)),O=y?void 0:L??(s===void 0?a=>A.setWorkflowInstanceStatus(a):void 0),j=r(async()=>{h(null),S(!1);let a=w===""?void 0:w;try{if(s===void 0){let d=await A.listWorkflowInstances({name:v,status:a});if(d.configured===!1){N(null),S(!0);return}N(d.instances);return}N(await s({name:v,status:a}))}catch(d){N(null),ce(d)?S(!0):h(E(d))}},"load");(0,n.useEffect)(()=>{I(null),W(j())},[v,w]);let G=r(async a=>{h(null);try{I(await m({id:a,name:v}))}catch(d){h(E(d))}},"openDetail"),H=r(async(a,d)=>{if(O!==void 0){J(a),h(null);try{await O({action:d,id:a,name:v}),await j()}catch(M){h(E(M))}finally{J(null)}}},"act");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[(0,e.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxDEV)("h3",{className:"text-sm font-medium",children:o("Instance history")},void 0,!1),(0,e.jsxDEV)("select",{"aria-label":o("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:r(a=>{P(a.target.value)},"onChange"),value:w,children:[(0,e.jsxDEV)("option",{value:"",children:o("All statuses")},void 0,!1),ie.map(a=>(0,e.jsxDEV)("option",{value:a,children:a},a,!1))]},void 0,!0)]},void 0,!0),g!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:g},void 0,!1),U&&(0,e.jsxDEV)(B,{description:o("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:o("Workflow inspection not configured")},void 0,!1),!U&&x!==null&&x.length===0&&(0,e.jsxDEV)(B,{description:o("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:o("No instances")},void 0,!1),x!==null&&x.length>0&&(0,e.jsxDEV)(R,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(_,{className:"px-0",children:(0,e.jsxDEV)($,{"data-testid":"workflow-instances-table",children:[(0,e.jsxDEV)(F,{children:(0,e.jsxDEV)(p,{children:[(0,e.jsxDEV)(l,{children:o("Instance id")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Status")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Created")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Ended")},void 0,!1),(0,e.jsxDEV)(l,{"aria-label":o("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(D,{children:x.map(a=>(0,e.jsxDEV)(p,{"data-testid":`workflow-instance-${a.id}`,children:[(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:a.id},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:a.status},void 0,!1),(0,e.jsxDEV)(i,{className:"text-muted-foreground tabular-nums",children:a.createdOn??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"text-muted-foreground tabular-nums",children:a.endedOn??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"text-right",children:(0,e.jsxDEV)("div",{className:"flex justify-end gap-1.5",children:[(0,e.jsxDEV)(T,{"data-testid":`workflow-instance-steps-${a.id}`,onClick:r(()=>{W(G(a.id))},"onClick"),size:"sm",type:"button",variant:"outline",children:o("Steps")},void 0,!1),O!==void 0&&ne.map(d=>(0,e.jsxDEV)(T,{"data-testid":`workflow-instance-${d}-${a.id}`,disabled:z===a.id,onClick:r(()=>{W(H(a.id,d))},"onClick"),size:"sm",type:"button",variant:"ghost",children:o(d)},d,!1))]},void 0,!0)},void 0,!1)]},a.id,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),k!==null&&(0,e.jsxDEV)(R,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:(0,e.jsxDEV)(_,{className:"flex flex-col gap-2 px-4 py-3",children:[(0,e.jsxDEV)("div",{className:"flex items-center justify-between",children:[(0,e.jsxDEV)("span",{className:"font-mono text-xs",children:[o("Steps")," \xB7 ",k.id]},void 0,!0),(0,e.jsxDEV)(T,{"data-testid":"workflow-instance-detail-close",onClick:r(()=>{I(null)},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Close")},void 0,!1)]},void 0,!0),k.steps.length===0?(0,e.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:o("This instance has no recorded steps yet.")},void 0,!1):(0,e.jsxDEV)($,{"data-testid":"workflow-instance-steps",children:[(0,e.jsxDEV)(F,{children:(0,e.jsxDEV)(p,{children:[(0,e.jsxDEV)(l,{children:o("Step")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Type")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Attempts")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Started")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Output")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(D,{children:k.steps.map((a,d)=>(0,e.jsxDEV)(p,{"data-testid":`workflow-step-${String(d)}`,children:[(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:a.name},void 0,!1),(0,e.jsxDEV)(i,{className:"text-xs text-muted-foreground",children:a.type??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"tabular-nums",children:a.attempts??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"text-muted-foreground tabular-nums",children:a.start??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:fe(a)},void 0,!1)]},`${a.name}:${String(d)}`,!0))},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1)]},void 0,!0)},"WorkflowInstanceHistory"),me=X(K.createWorkflowInstance),ve=X(K.getWorkflowInstanceStatus),he=r(c=>{if(c.error)return`${c.error.name}: ${c.error.message}`;if(c.output===void 0)return"\u2014";try{return JSON.stringify(c.output)}catch{return"(unserializable)"}},"formatPayload"),Oe=r(()=>{let c=Q(),s=V(),{data:y,error:L}=ae(K.listWorkflows,{}),[v,A]=(0,n.useState)(""),[o,x]=(0,n.useState)(""),[N,k]=(0,n.useState)(""),[I,w]=(0,n.useState)(!1),[P,g]=(0,n.useState)(null),[h,U]=(0,n.useState)([]),[S,z]=(0,n.useState)(null),J=y!==void 0,m=(0,n.useMemo)(()=>Array.isArray(y?.workflows)?[...y.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],[y]),C=(0,n.useMemo)(()=>m.some(t=>t.exportName===v)?v:m[0]?.exportName??"",[m,v]),q=(0,n.useMemo)(()=>m.find(t=>t.exportName===C),[m,C]),O=r(t=>{U(u=>{let f=u.filter(b=>!(b.exportName===t.exportName&&b.id===t.id));return[t,...f]})},"upsertInstance"),j=r(async()=>{let t=C;if(t==="")return;let u,f=N.trim();if(f!=="")try{u=JSON.parse(f)}catch{g(s("Params must be valid JSON"));return}w(!0),g(null);try{let b=o.trim(),Z=await c.query(me,{exportName:t,id:b===""?void 0:b,params:u},Y(""));O({exportName:t,id:Z.id,status:Z.status}),x("")}catch(b){g(E(b))}finally{w(!1)}},"start"),G=r(()=>{W(j())},"startInstance"),H=r(async(t,u)=>{z(u);try{let f=await c.query(ve,{exportName:t,id:u},Y(""));O({error:f.error,exportName:t,id:f.id,output:f.output,status:f.status})}catch(f){g(E(f))}finally{z(null)}},"refreshInstance"),a=r(t=>{A(t.target.value)},"onSelectedExportChange"),d=r(t=>{x(t.target.value)},"onInstanceIdChange"),M=r(t=>{k(t.target.value)},"onParamsChange"),oe=r(t=>{let{export:u,id:f}=t.currentTarget.dataset;u!==void 0&&f!==void 0&&W(H(u,f))},"onRefreshClick");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[L!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:L},void 0,!1),(0,e.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:s("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")},void 0,!1),J&&m.length===0?(0,e.jsxDEV)(B,{description:s("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:s("No workflows defined")},void 0,!1):(0,e.jsxDEV)(R,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(_,{className:"px-0",children:(0,e.jsxDEV)($,{"data-testid":"workflows-table",children:[(0,e.jsxDEV)(F,{children:(0,e.jsxDEV)(p,{children:[(0,e.jsxDEV)(l,{children:s("Export")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Name")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Class")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Binding")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(D,{children:m.map(t=>(0,e.jsxDEV)(p,{"data-testid":`workflows-row-${t.exportName}`,children:[(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:t.exportName},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:t.name},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:t.className},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:t.binding},void 0,!1)]},t.exportName,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),m.length>0&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[(0,e.jsxDEV)("h3",{className:"text-sm font-medium",children:s("Start instance")},void 0,!1),P!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:P},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxDEV)("select",{"aria-label":s("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:a,value:C,children:m.map(t=>(0,e.jsxDEV)("option",{value:t.exportName,children:t.exportName},t.exportName,!1))},void 0,!1),(0,e.jsxDEV)(te,{"aria-label":s("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:d,placeholder:s("Instance id (optional)"),value:o},void 0,!1),(0,e.jsxDEV)(T,{"data-testid":"workflows-start-button",disabled:I||C==="",onClick:G,children:s(I?"Starting\u2026":"Start instance")},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(se,{"aria-label":s("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:M,placeholder:s("Params (JSON, optional)"),value:N},void 0,!1)]},void 0,!0),h.length>0&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[(0,e.jsxDEV)("h3",{className:"text-sm font-medium",children:s("Instances")},void 0,!1),(0,e.jsxDEV)(R,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(_,{className:"px-0",children:(0,e.jsxDEV)($,{"data-testid":"workflows-instances-table",children:[(0,e.jsxDEV)(F,{children:(0,e.jsxDEV)(p,{children:[(0,e.jsxDEV)(l,{children:s("Workflow")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Instance id")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Status")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Output")},void 0,!1),(0,e.jsxDEV)(l,{},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(D,{children:h.map(t=>(0,e.jsxDEV)(p,{"data-testid":`workflows-instance-${t.id}`,children:[(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:t.exportName},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:t.id},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:t.status},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:he(t)},void 0,!1),(0,e.jsxDEV)(i,{children:(0,e.jsxDEV)(T,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:S===t.id,onClick:oe,size:"xs",variant:"outline",children:S===t.id?s("Refreshing\u2026"):s("Refresh")},void 0,!1)},void 0,!1)]},`${t.exportName}:${t.id}`,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0),q!==void 0&&(0,e.jsxDEV)(ue,{workflowName:q.name},void 0,!1)]},void 0,!0)},"WorkflowsPanel");export{Oe as default};
@@ -1 +1 @@
1
- import{a as k,b as N,c as O,d as x,e as q,f as D}from"./chunk-GTM65MVX.js";import{a as C}from"./chunk-TAD43CG5.js";import{a as g}from"./chunk-SEU5V7I6.js";import{d as T,g as I,j as _,k as w}from"./chunk-E75ANNWX.js";import{b as L}from"./chunk-GMSGZDDH.js";import{a as d,e as b,f as U,g as Y,h as F}from"./chunk-RRCPZMC2.js";var M=b(Y(),1);var H="https://api.cloudflare.com/client/v4/accounts",E=class extends L{static{d(this,"AnalyticsSqlError")}constructor(e,f){super("ANALYTICS_SQL_ERROR",`Analytics Engine SQL API returned ${String(e)}: ${f}`,{name:"AnalyticsSqlError",status:e})}},v=d(t=>{let e=t.fetch??globalThis.fetch,f=`${H}/${encodeURIComponent(t.accountId)}/analytics_engine/sql`;return{query:d(async s=>{let l=await e(f,{body:s,headers:{Authorization:`Bearer ${t.apiToken}`,"Content-Type":"text/plain"},method:"POST"});if(!l.ok)throw new E(l.status,await l.text());let n;try{n=await l.json()}catch{throw new E(l.status,"Analytics Engine SQL API returned a non-JSON body.")}let o=n,a=o.data??[];return{columns:o.meta??[],rowCount:o.rows??a.length,rows:a}},"query")}},"createAnalyticsSqlClient");var m=b(U(),1);var r=b(F(),1);var W="ANALYTICS",P=[{key:"volume",sql:d(t=>`SELECT blob2 AS fn, count() AS calls FROM ${t} WHERE blob1 = 'function_call' GROUP BY fn ORDER BY calls DESC LIMIT 25`,"sql"),title:"Request volume per function"},{key:"latency",sql:d(t=>`SELECT blob2 AS fn, quantileWeighted(0.50)(double1, _sample_interval) AS p50, quantileWeighted(0.95)(double1, _sample_interval) AS p95 FROM ${t} WHERE blob1 = 'function_call' GROUP BY fn ORDER BY p95 DESC LIMIT 25`,"sql"),title:"Latency p50 / p95 per function"},{key:"hotShards",sql:d(t=>`SELECT blob3 AS shard, count() AS calls FROM ${t} WHERE blob1 = 'function_call' GROUP BY shard ORDER BY calls DESC LIMIT 25`,"sql"),title:"Hot shards"}],j={error:null,loading:!0,result:null},G=d(t=>{let e=(0,M.c)(27),{state:f,title:p}=t,s=T(),{error:l,loading:n,result:o}=f,a=`analytics-panel-${p}`,i;e[0]!==s||e[1]!==p?(i=s(p),e[0]=s,e[1]=p,e[2]=i):i=e[2];let c;e[3]!==i?(c=(0,r.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i},void 0,!1)},void 0,!1),e[3]=i,e[4]=c):c=e[4];let u;e[5]!==n||e[6]!==s?(u=n&&(0,r.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"analytics-loading",children:s("Loading\u2026")},void 0,!1),e[5]=n,e[6]=s,e[7]=u):u=e[7];let y;e[8]!==l||e[9]!==n?(y=!n&&l!==null&&(0,r.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"analytics-error",role:"alert",children:l},void 0,!1),e[8]=l,e[9]=n,e[10]=y):y=e[10];let h;e[11]!==l||e[12]!==n||e[13]!==o||e[14]!==s?(h=!n&&l===null&&o!==null&&o.rows.length===0&&(0,r.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"analytics-empty-rows",children:s("No data points yet.")},void 0,!1),e[11]=l,e[12]=n,e[13]=o,e[14]=s,e[15]=h):h=e[15];let A;e[16]!==l||e[17]!==n||e[18]!==o?(A=!n&&l===null&&o!==null&&o.rows.length>0&&(0,r.jsxDEV)(k,{children:[(0,r.jsxDEV)(N,{children:(0,r.jsxDEV)(x,{children:o.columns.map(Q)},void 0,!1)},void 0,!1),(0,r.jsxDEV)(O,{children:o.rows.map((B,$)=>(0,r.jsxDEV)(x,{children:o.columns.map(R=>(0,r.jsxDEV)(D,{className:"font-mono text-xs",children:_(B[R.name])},R.name,!1))},$,!1))},void 0,!1)]},void 0,!0),e[16]=l,e[17]=n,e[18]=o,e[19]=A):A=e[19];let S;return e[20]!==a||e[21]!==c||e[22]!==u||e[23]!==y||e[24]!==h||e[25]!==A?(S=(0,r.jsxDEV)(g,{className:"gap-0 py-0","data-testid":a,children:[c,u,y,h,A]},void 0,!0),e[20]=a,e[21]=c,e[22]=u,e[23]=y,e[24]=h,e[25]=A,e[26]=S):S=e[26],S},"PanelResult"),re=d(({config:t,dataset:e=W,runQuery:f}={})=>{let p=T(),[s,l]=(0,m.useState)({}),n=(0,m.useMemo)(()=>{if(f!==void 0)return f;if(t===void 0)return null;let a=v({accountId:t.accountId,apiToken:t.apiToken});return i=>a.query(i)},[t,f]),o=(0,m.useCallback)(async a=>{if(n!==null)for(let i of P){if(a.cancelled)return;l(c=>({...c,[i.key]:{error:null,loading:!0,result:null}}));try{let c=await n(i.sql(e));a.cancelled||l(u=>({...u,[i.key]:{error:null,loading:!1,result:c}}))}catch(c){a.cancelled||l(u=>({...u,[i.key]:{error:I(c),loading:!1,result:null}}))}}},[n,e]);return(0,m.useEffect)(()=>{let a={cancelled:!1};return w(o(a)),()=>{a.cancelled=!0}},[o]),n===null?(0,r.jsxDEV)(C,{description:p("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN (Analytics Read) in your .dev.vars to enable usage panels."),icon:(0,r.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsxDEV)("path",{d:"M5 20V10m6.5 10V4M18 20v-7M3 20h18"},void 0,!1)},void 0,!1),testId:"analytics-not-configured",title:p("Analytics is not configured.")},void 0,!1):(0,r.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-analytics-panel",children:P.map(a=>(0,r.jsxDEV)(G,{state:s[a.key]??j,title:a.title},a.key,!1))},void 0,!1)},"AnalyticsPanel");function Q(t){return(0,r.jsxDEV)(q,{children:t.name},t.name,!1)}d(Q,"_temp");export{re as AnalyticsPanel};
1
+ import{a as k,b as N,c as O,d as x,e as q,f as D}from"./chunk-GTM65MVX.js";import{a as C}from"./chunk-TAD43CG5.js";import{a as g}from"./chunk-SEU5V7I6.js";import{d as T,g as I,j as _,k as w}from"./chunk-E75ANNWX.js";import{b as L}from"./chunk-JHKMUTIF.js";import{a as d,e as b,f as U,g as Y,h as F}from"./chunk-RRCPZMC2.js";var M=b(Y(),1);var H="https://api.cloudflare.com/client/v4/accounts",E=class extends L{static{d(this,"AnalyticsSqlError")}constructor(e,f){super("ANALYTICS_SQL_ERROR",`Analytics Engine SQL API returned ${String(e)}: ${f}`,{name:"AnalyticsSqlError",status:e})}},v=d(t=>{let e=t.fetch??globalThis.fetch,f=`${H}/${encodeURIComponent(t.accountId)}/analytics_engine/sql`;return{query:d(async s=>{let l=await e(f,{body:s,headers:{Authorization:`Bearer ${t.apiToken}`,"Content-Type":"text/plain"},method:"POST"});if(!l.ok)throw new E(l.status,await l.text());let n;try{n=await l.json()}catch{throw new E(l.status,"Analytics Engine SQL API returned a non-JSON body.")}let o=n,a=o.data??[];return{columns:o.meta??[],rowCount:o.rows??a.length,rows:a}},"query")}},"createAnalyticsSqlClient");var m=b(U(),1);var r=b(F(),1);var W="ANALYTICS",P=[{key:"volume",sql:d(t=>`SELECT blob2 AS fn, count() AS calls FROM ${t} WHERE blob1 = 'function_call' GROUP BY fn ORDER BY calls DESC LIMIT 25`,"sql"),title:"Request volume per function"},{key:"latency",sql:d(t=>`SELECT blob2 AS fn, quantileWeighted(0.50)(double1, _sample_interval) AS p50, quantileWeighted(0.95)(double1, _sample_interval) AS p95 FROM ${t} WHERE blob1 = 'function_call' GROUP BY fn ORDER BY p95 DESC LIMIT 25`,"sql"),title:"Latency p50 / p95 per function"},{key:"hotShards",sql:d(t=>`SELECT blob3 AS shard, count() AS calls FROM ${t} WHERE blob1 = 'function_call' GROUP BY shard ORDER BY calls DESC LIMIT 25`,"sql"),title:"Hot shards"}],j={error:null,loading:!0,result:null},G=d(t=>{let e=(0,M.c)(27),{state:f,title:p}=t,s=T(),{error:l,loading:n,result:o}=f,a=`analytics-panel-${p}`,i;e[0]!==s||e[1]!==p?(i=s(p),e[0]=s,e[1]=p,e[2]=i):i=e[2];let c;e[3]!==i?(c=(0,r.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i},void 0,!1)},void 0,!1),e[3]=i,e[4]=c):c=e[4];let u;e[5]!==n||e[6]!==s?(u=n&&(0,r.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"analytics-loading",children:s("Loading\u2026")},void 0,!1),e[5]=n,e[6]=s,e[7]=u):u=e[7];let y;e[8]!==l||e[9]!==n?(y=!n&&l!==null&&(0,r.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"analytics-error",role:"alert",children:l},void 0,!1),e[8]=l,e[9]=n,e[10]=y):y=e[10];let h;e[11]!==l||e[12]!==n||e[13]!==o||e[14]!==s?(h=!n&&l===null&&o!==null&&o.rows.length===0&&(0,r.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"analytics-empty-rows",children:s("No data points yet.")},void 0,!1),e[11]=l,e[12]=n,e[13]=o,e[14]=s,e[15]=h):h=e[15];let A;e[16]!==l||e[17]!==n||e[18]!==o?(A=!n&&l===null&&o!==null&&o.rows.length>0&&(0,r.jsxDEV)(k,{children:[(0,r.jsxDEV)(N,{children:(0,r.jsxDEV)(x,{children:o.columns.map(Q)},void 0,!1)},void 0,!1),(0,r.jsxDEV)(O,{children:o.rows.map((B,$)=>(0,r.jsxDEV)(x,{children:o.columns.map(R=>(0,r.jsxDEV)(D,{className:"font-mono text-xs",children:_(B[R.name])},R.name,!1))},$,!1))},void 0,!1)]},void 0,!0),e[16]=l,e[17]=n,e[18]=o,e[19]=A):A=e[19];let S;return e[20]!==a||e[21]!==c||e[22]!==u||e[23]!==y||e[24]!==h||e[25]!==A?(S=(0,r.jsxDEV)(g,{className:"gap-0 py-0","data-testid":a,children:[c,u,y,h,A]},void 0,!0),e[20]=a,e[21]=c,e[22]=u,e[23]=y,e[24]=h,e[25]=A,e[26]=S):S=e[26],S},"PanelResult"),re=d(({config:t,dataset:e=W,runQuery:f}={})=>{let p=T(),[s,l]=(0,m.useState)({}),n=(0,m.useMemo)(()=>{if(f!==void 0)return f;if(t===void 0)return null;let a=v({accountId:t.accountId,apiToken:t.apiToken});return i=>a.query(i)},[t,f]),o=(0,m.useCallback)(async a=>{if(n!==null)for(let i of P){if(a.cancelled)return;l(c=>({...c,[i.key]:{error:null,loading:!0,result:null}}));try{let c=await n(i.sql(e));a.cancelled||l(u=>({...u,[i.key]:{error:null,loading:!1,result:c}}))}catch(c){a.cancelled||l(u=>({...u,[i.key]:{error:I(c),loading:!1,result:null}}))}}},[n,e]);return(0,m.useEffect)(()=>{let a={cancelled:!1};return w(o(a)),()=>{a.cancelled=!0}},[o]),n===null?(0,r.jsxDEV)(C,{description:p("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN (Analytics Read) in your .dev.vars to enable usage panels."),icon:(0,r.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsxDEV)("path",{d:"M5 20V10m6.5 10V4M18 20v-7M3 20h18"},void 0,!1)},void 0,!1),testId:"analytics-not-configured",title:p("Analytics is not configured.")},void 0,!1):(0,r.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-analytics-panel",children:P.map(a=>(0,r.jsxDEV)(G,{state:s[a.key]??j,title:a.title},a.key,!1))},void 0,!1)},"AnalyticsPanel");function Q(t){return(0,r.jsxDEV)(q,{children:t.name},t.name,!1)}d(Q,"_temp");export{re as AnalyticsPanel};
@@ -1 +1 @@
1
- import{a as S}from"./chunk-CACB34RQ.js";import"./chunk-XNJNSCLM.js";import{a as w,b as A,c as E,d as m,e as s,f as l}from"./chunk-GTM65MVX.js";import{a as O}from"./chunk-VLXV72QE.js";import{a as k}from"./chunk-JSEXCW5Q.js";import{a as C}from"./chunk-BOXSWNXZ.js";import{a as u}from"./chunk-TAD43CG5.js";import{b as T}from"./chunk-C7WTJLC3.js";import{a as N,e as b}from"./chunk-SEU5V7I6.js";import{b as y}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import"./chunk-GLUNBZRI.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as h}from"./chunk-E75ANNWX.js";import"./chunk-GMSGZDDH.js";import{a as d,e as p,f as D,h as H}from"./chunk-RRCPZMC2.js";var n=p(D(),1);var e=p(H(),1);var K=d(a=>{let t=a.trim();if(t.length===0)return{context:void 0,error:null};try{let o=JSON.parse(t);return o===null||typeof o!="object"||Array.isArray(o)?{context:void 0,error:"Targeting context must be a JSON object."}:{context:o,error:null}}catch{return{context:void 0,error:"Targeting context is not valid JSON."}}},"parseContext"),R='{ "targetingKey": "user-123", "plan": "premium" }',M=d(a=>a.type==="object"?JSON.stringify(a.value):String(a.value),"formatValue"),Y=d(({initialShardKey:a=""})=>{let t=h(),[o,F]=(0,n.useState)(""),{context:f,error:g}=K(o),I=(0,n.useMemo)(()=>f===void 0?{}:{context:f},[f]),{data:i,error:J,errorSource:L,liveError:j}=T(C.listFlags,I,{live:!0,shardKey:a}),v=i!==void 0,V=i?.configured??!1,x=(0,n.useMemo)(()=>Array.isArray(i?.flags)?[...i.flags].toSorted((r,B)=>r.key.localeCompare(B.key)):[],[i]),c;return v&&!V?c=(0,e.jsxDEV)(u,{description:t("No @lunora/flags provider is wired in this deployment. Add lunora/flags.ts with defineFlags({ provider }) to gate code paths on feature flags."),testId:"flags-unconfigured",title:t("No flags provider configured")},void 0,!1):v&&x.length===0?c=(0,e.jsxDEV)(u,{description:t('A flags provider is configured, but no handler reads a flag yet. Call ctx.flags.boolean("key", false) in a query, mutation, or action.'),testId:"flags-empty",title:t("No flags read")},void 0,!1):c=(0,e.jsxDEV)(N,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(b,{className:"px-0",children:(0,e.jsxDEV)(w,{"data-testid":"flags-table",children:[(0,e.jsxDEV)(A,{children:(0,e.jsxDEV)(m,{children:[(0,e.jsxDEV)(s,{children:t("Key")},void 0,!1),(0,e.jsxDEV)(s,{children:t("Type")},void 0,!1),(0,e.jsxDEV)(s,{children:t("Value")},void 0,!1),(0,e.jsxDEV)(s,{children:t("Reason")},void 0,!1),(0,e.jsxDEV)(s,{children:t("Variant")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(E,{children:x.map(r=>(0,e.jsxDEV)(m,{"data-testid":`flags-row-${r.key}`,children:[(0,e.jsxDEV)(l,{className:"font-mono text-xs",children:r.key},void 0,!1),(0,e.jsxDEV)(l,{className:"font-mono text-xs text-muted-foreground",children:r.type},void 0,!1),(0,e.jsxDEV)(l,{className:"font-mono text-xs",children:M(r)},void 0,!1),(0,e.jsxDEV)(l,{children:r.errorCode===void 0?(0,e.jsxDEV)("span",{className:"font-mono text-xs text-muted-foreground",children:r.reason??"\u2014"},void 0,!1):(0,e.jsxDEV)(y,{"data-testid":`flags-error-${r.key}`,variant:"destructive",children:r.errorCode},void 0,!1)},void 0,!1),(0,e.jsxDEV)(l,{className:"font-mono text-xs text-muted-foreground",children:r.variant??"\u2014"},void 0,!1)]},r.key,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-col gap-6","data-testid":"lunora-flags-panel",children:[J!==null&&(0,e.jsxDEV)(S,{error:L,testId:"flags-error"},void 0,!1),(0,e.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:t('Feature flags are read in code with ctx.flags.<type>("key", default). They evaluate through the OpenFeature provider configured in lunora/flags.ts; edit the targeting context below to see how each flag resolves for a given audience.')},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-col gap-2",children:[(0,e.jsxDEV)(k,{htmlFor:"flags-targeting-context",children:t("Targeting context (JSON)")},void 0,!1),(0,e.jsxDEV)(O,{className:"font-mono text-xs","data-testid":"flags-context-input",id:"flags-targeting-context",onChange:d(r=>{F(r.target.value)},"onChange"),placeholder:R,rows:3,value:o},void 0,!1),g!==null&&(0,e.jsxDEV)("p",{className:"text-xs text-destructive","data-testid":"flags-context-error",role:"alert",children:t(g)},void 0,!1),j!==void 0&&(0,e.jsxDEV)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"flags-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")},void 0,!1)]},void 0,!0),c]},void 0,!0)},"FlagsPanel");export{Y as FlagsPanel};
1
+ import{a as S}from"./chunk-HN6KJXYQ.js";import"./chunk-XNJNSCLM.js";import{a as w,b as A,c as E,d as m,e as s,f as l}from"./chunk-GTM65MVX.js";import{a as O}from"./chunk-VLXV72QE.js";import{a as k}from"./chunk-JSEXCW5Q.js";import{a as C}from"./chunk-BOXSWNXZ.js";import{a as u}from"./chunk-TAD43CG5.js";import{b as T}from"./chunk-RHZ4M2NZ.js";import{a as N,e as b}from"./chunk-SEU5V7I6.js";import{b as y}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import"./chunk-XLXNLJ4N.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as h}from"./chunk-E75ANNWX.js";import"./chunk-JHKMUTIF.js";import{a as d,e as p,f as D,h as H}from"./chunk-RRCPZMC2.js";var n=p(D(),1);var e=p(H(),1);var K=d(a=>{let t=a.trim();if(t.length===0)return{context:void 0,error:null};try{let o=JSON.parse(t);return o===null||typeof o!="object"||Array.isArray(o)?{context:void 0,error:"Targeting context must be a JSON object."}:{context:o,error:null}}catch{return{context:void 0,error:"Targeting context is not valid JSON."}}},"parseContext"),R='{ "targetingKey": "user-123", "plan": "premium" }',M=d(a=>a.type==="object"?JSON.stringify(a.value):String(a.value),"formatValue"),Y=d(({initialShardKey:a=""})=>{let t=h(),[o,F]=(0,n.useState)(""),{context:f,error:g}=K(o),I=(0,n.useMemo)(()=>f===void 0?{}:{context:f},[f]),{data:i,error:J,errorSource:L,liveError:j}=T(C.listFlags,I,{live:!0,shardKey:a}),v=i!==void 0,V=i?.configured??!1,x=(0,n.useMemo)(()=>Array.isArray(i?.flags)?[...i.flags].toSorted((r,B)=>r.key.localeCompare(B.key)):[],[i]),c;return v&&!V?c=(0,e.jsxDEV)(u,{description:t("No @lunora/flags provider is wired in this deployment. Add lunora/flags.ts with defineFlags({ provider }) to gate code paths on feature flags."),testId:"flags-unconfigured",title:t("No flags provider configured")},void 0,!1):v&&x.length===0?c=(0,e.jsxDEV)(u,{description:t('A flags provider is configured, but no handler reads a flag yet. Call ctx.flags.boolean("key", false) in a query, mutation, or action.'),testId:"flags-empty",title:t("No flags read")},void 0,!1):c=(0,e.jsxDEV)(N,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(b,{className:"px-0",children:(0,e.jsxDEV)(w,{"data-testid":"flags-table",children:[(0,e.jsxDEV)(A,{children:(0,e.jsxDEV)(m,{children:[(0,e.jsxDEV)(s,{children:t("Key")},void 0,!1),(0,e.jsxDEV)(s,{children:t("Type")},void 0,!1),(0,e.jsxDEV)(s,{children:t("Value")},void 0,!1),(0,e.jsxDEV)(s,{children:t("Reason")},void 0,!1),(0,e.jsxDEV)(s,{children:t("Variant")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(E,{children:x.map(r=>(0,e.jsxDEV)(m,{"data-testid":`flags-row-${r.key}`,children:[(0,e.jsxDEV)(l,{className:"font-mono text-xs",children:r.key},void 0,!1),(0,e.jsxDEV)(l,{className:"font-mono text-xs text-muted-foreground",children:r.type},void 0,!1),(0,e.jsxDEV)(l,{className:"font-mono text-xs",children:M(r)},void 0,!1),(0,e.jsxDEV)(l,{children:r.errorCode===void 0?(0,e.jsxDEV)("span",{className:"font-mono text-xs text-muted-foreground",children:r.reason??"\u2014"},void 0,!1):(0,e.jsxDEV)(y,{"data-testid":`flags-error-${r.key}`,variant:"destructive",children:r.errorCode},void 0,!1)},void 0,!1),(0,e.jsxDEV)(l,{className:"font-mono text-xs text-muted-foreground",children:r.variant??"\u2014"},void 0,!1)]},r.key,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-col gap-6","data-testid":"lunora-flags-panel",children:[J!==null&&(0,e.jsxDEV)(S,{error:L,testId:"flags-error"},void 0,!1),(0,e.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:t('Feature flags are read in code with ctx.flags.<type>("key", default). They evaluate through the OpenFeature provider configured in lunora/flags.ts; edit the targeting context below to see how each flag resolves for a given audience.')},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-col gap-2",children:[(0,e.jsxDEV)(k,{htmlFor:"flags-targeting-context",children:t("Targeting context (JSON)")},void 0,!1),(0,e.jsxDEV)(O,{className:"font-mono text-xs","data-testid":"flags-context-input",id:"flags-targeting-context",onChange:d(r=>{F(r.target.value)},"onChange"),placeholder:R,rows:3,value:o},void 0,!1),g!==null&&(0,e.jsxDEV)("p",{className:"text-xs text-destructive","data-testid":"flags-context-error",role:"alert",children:t(g)},void 0,!1),j!==void 0&&(0,e.jsxDEV)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"flags-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")},void 0,!1)]},void 0,!0),c]},void 0,!0)},"FlagsPanel");export{Y as FlagsPanel};
@@ -1 +1 @@
1
- import{a as He}from"./chunk-YAECF5LW.js";import"./chunk-DWDILV2E.js";import{a as je}from"./chunk-J6J54MBP.js";import"./chunk-5OIBXYZM.js";import{a as Pe}from"./chunk-CACB34RQ.js";import{a as Ge}from"./chunk-XNJNSCLM.js";import{a as Be,b as Re,c as $e,d as j,e as E,f as _}from"./chunk-GTM65MVX.js";import{a as Ve}from"./chunk-VLXV72QE.js";import{R as We}from"./chunk-3CJW6NWG.js";import{c as V}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as J}from"./chunk-BOXSWNXZ.js";import{a as ie}from"./chunk-TAD43CG5.js";import{b as De}from"./chunk-C7WTJLC3.js";import{a as Le,e as Me}from"./chunk-SEU5V7I6.js";import{b as de}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as Fe}from"./chunk-GLUNBZRI.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as U,e as ce,f as ue,g as me,k as fe,o as ze}from"./chunk-E75ANNWX.js";import"./chunk-GMSGZDDH.js";import{a as f,e as Ie,f as at,g as ot,h as rt}from"./chunk-RRCPZMC2.js";var F=Ie(ot(),1);var w=Ie(at(),1);var t=Ie(rt(),1);var lt=f((o,e)=>{let s=new Set(o.map(a=>a.deadLetterQueue).filter(a=>typeof a=="string"&&a!=="")),i=o.filter(a=>(a.deadLetterQueue===void 0||a.deadLetterQueue==="")&&!s.has(a.name)),n=e.filter(a=>a.deadLettered).length;return{deadLetteredCount:n,queuesWithoutDlq:i,showReliabilityWarning:i.length>0||n>0}},"computeQueueReliability"),nt=200,dt=ce(J.sendQueueMessage),it=ce(J.replayQueueMessage),ct=ce(J.clearQueueMessages),Ye=96,ut=f(o=>{if(o===void 0)return"\u2014";try{return JSON.stringify(o)}catch{return"[unserializable]"}},"formatBody"),mt=f(o=>o.length>Ye?`${o.slice(0,Ye)}\u2026`:o,"truncate"),ft=f(o=>o==="error"?"destructive":o==="retry"?"outline":"secondary","outcomeVariant"),ht=f((o,e)=>e(o==="messages"?"Messages":o==="send"?"Send":"Declared"),"tabLabel"),pt=f(o=>{let e=(0,F.c)(11),{loaded:s,queues:i}=o,n=U(),a;e[0]!==n?(a=n("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[0]=n,e[1]=a):a=e[1];let l;e[2]!==a?(l=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:a},void 0,!1),e[2]=a,e[3]=l):l=e[3];let r;e[4]!==s||e[5]!==i||e[6]!==n?(r=s&&i.length===0?(0,t.jsxDEV)(ie,{description:n("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:n("No queues defined")},void 0,!1):(0,t.jsxDEV)(Le,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Me,{className:"px-0",children:(0,t.jsxDEV)(Be,{"data-testid":"queues-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(E,{children:n("Export")},void 0,!1),(0,t.jsxDEV)(E,{children:n("Queue")},void 0,!1),(0,t.jsxDEV)(E,{children:n("Mode")},void 0,!1),(0,t.jsxDEV)(E,{children:n("Binding")},void 0,!1),(0,t.jsxDEV)(E,{children:n("Dead-letter")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)($e,{children:i.map(yt)},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[4]=s,e[5]=i,e[6]=n,e[7]=r):r=e[7];let h;return e[8]!==l||e[9]!==r?(h=(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[l,r]},void 0,!0),e[8]=l,e[9]=r,e[10]=h):h=e[10],h},"QueuesDeclaredTab"),gt=f(o=>{let e=(0,F.c)(67),{message:s,onReplay:i,replayingId:n}=o,a=U(),l,r,h,u,y,p,x,d,m,g;if(e[0]!==s.attempts||e[1]!==s.body||e[2]!==s.deadLettered||e[3]!==s.exportName||e[4]!==s.id||e[5]!==s.messageId||e[6]!==s.outcome||e[7]!==s.queue||e[8]!==a){let W=ut(s.body);r=j,p=`queues-message-${s.id}`;let z=s.exportName??s.queue;e[19]!==z?(x=(0,t.jsxDEV)(_,{className:"font-mono text-xs",children:z},void 0,!1),e[19]=z,e[20]=x):x=e[20],e[21]!==s.messageId?(d=(0,t.jsxDEV)(_,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:s.messageId,children:s.messageId},void 0,!1),e[21]=s.messageId,e[22]=d):d=e[22],e[23]!==s.attempts?(m=(0,t.jsxDEV)(_,{className:"font-mono text-xs tabular-nums",children:s.attempts},void 0,!1),e[23]=s.attempts,e[24]=m):m=e[24];let I=`queues-outcome-${s.id}`,L;e[25]!==s.outcome?(L=ft(s.outcome),e[25]=s.outcome,e[26]=L):L=e[26];let T;e[27]!==s.outcome||e[28]!==I||e[29]!==L?(T=(0,t.jsxDEV)(de,{"data-testid":I,variant:L,children:s.outcome},void 0,!1),e[27]=s.outcome,e[28]=I,e[29]=L,e[30]=T):T=e[30];let M;e[31]!==s.deadLettered||e[32]!==s.id||e[33]!==a?(M=s.deadLettered&&(0,t.jsxDEV)(de,{"data-testid":`queues-dlq-${s.id}`,variant:"destructive",children:a("DLQ")},void 0,!1),e[31]=s.deadLettered,e[32]=s.id,e[33]=a,e[34]=M):M=e[34],e[35]!==T||e[36]!==M?(g=(0,t.jsxDEV)(_,{children:(0,t.jsxDEV)("span",{className:"inline-flex items-center gap-1",children:[T,M]},void 0,!0)},void 0,!1),e[35]=T,e[36]=M,e[37]=g):g=e[37],l=_,h="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",u=W,y=mt(W),e[0]=s.attempts,e[1]=s.body,e[2]=s.deadLettered,e[3]=s.exportName,e[4]=s.id,e[5]=s.messageId,e[6]=s.outcome,e[7]=s.queue,e[8]=a,e[9]=l,e[10]=r,e[11]=h,e[12]=u,e[13]=y,e[14]=p,e[15]=x,e[16]=d,e[17]=m,e[18]=g}else l=e[9],r=e[10],h=e[11],u=e[12],y=e[13],p=e[14],x=e[15],d=e[16],m=e[17],g=e[18];let v;e[38]!==l||e[39]!==h||e[40]!==u||e[41]!==y?(v=(0,t.jsxDEV)(l,{className:h,title:u,children:y},void 0,!1),e[38]=l,e[39]=h,e[40]=u,e[41]=y,e[42]=v):v=e[42];let N;e[43]!==s.capturedAt?(N=ze(s.capturedAt,"\u2014"),e[43]=s.capturedAt,e[44]=N):N=e[44];let b;e[45]!==N?(b=(0,t.jsxDEV)(_,{className:"text-xs text-muted-foreground tabular-nums",children:N},void 0,!1),e[45]=N,e[46]=b):b=e[46];let S=`queues-replay-${s.id}`,A=n!==null,C;e[47]!==s.id||e[48]!==n||e[49]!==a?(C=n===s.id?a("Replaying\u2026"):a("Replay"),e[47]=s.id,e[48]=n,e[49]=a,e[50]=C):C=e[50];let Q;e[51]!==s.id||e[52]!==i||e[53]!==S||e[54]!==A||e[55]!==C?(Q=(0,t.jsxDEV)(_,{children:(0,t.jsxDEV)(V,{"data-id":s.id,"data-testid":S,disabled:A,onClick:i,size:"xs",type:"button",variant:"outline",children:C},void 0,!1)},void 0,!1),e[51]=s.id,e[52]=i,e[53]=S,e[54]=A,e[55]=C,e[56]=Q):Q=e[56];let D;return e[57]!==r||e[58]!==b||e[59]!==Q||e[60]!==p||e[61]!==x||e[62]!==d||e[63]!==m||e[64]!==g||e[65]!==v?(D=(0,t.jsxDEV)(r,{"data-testid":p,children:[x,d,m,g,v,b,Q]},void 0,!0),e[57]=r,e[58]=b,e[59]=Q,e[60]=p,e[61]=x,e[62]=d,e[63]=m,e[64]=g,e[65]=v,e[66]=D):D=e[66],D},"QueueLogRow"),vt=f(o=>{let e=(0,F.c)(26),{hasError:s,messages:i,onClear:n,onReplay:a,replayingId:l}=o,r=U(),h;e[0]!==r?(h=r("Cloudflare Queues have no peek API, so this is what push consumers actually processed \u2014 not pending depth."),e[0]=r,e[1]=h):h=e[1];let u;e[2]!==h?(u=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:h},void 0,!1),e[2]=h,e[3]=u):u=e[3];let y=i.length===0,p;e[4]!==r?(p=r("Clear log"),e[4]=r,e[5]=p):p=e[5];let x;e[6]!==n||e[7]!==y||e[8]!==p?(x=(0,t.jsxDEV)(V,{className:"ml-auto","data-testid":"queues-clear",disabled:y,onClick:n,size:"sm",type:"button",variant:"outline",children:p},void 0,!1),e[6]=n,e[7]=y,e[8]=p,e[9]=x):x=e[9];let d;e[10]!==i.length||e[11]!==r?(d=i.length>0&&(0,t.jsxDEV)(de,{"data-testid":"queues-count",variant:"secondary",children:r("{count} messages",{count:i.length})},void 0,!1),e[10]=i.length,e[11]=r,e[12]=d):d=e[12];let m;e[13]!==u||e[14]!==x||e[15]!==d?(m=(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[u,x,d]},void 0,!0),e[13]=u,e[14]=x,e[15]=d,e[16]=m):m=e[16];let g;e[17]!==s||e[18]!==i||e[19]!==a||e[20]!==l||e[21]!==r?(g=!s&&i.length===0?(0,t.jsxDEV)(ie,{description:r("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:r("No consumed messages yet.")},void 0,!1):(0,t.jsxDEV)(Le,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Me,{className:"px-0",children:(0,t.jsxDEV)(He,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:(0,t.jsxDEV)(Be,{"data-testid":"queues-messages-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(E,{children:r("Export")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Message")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Attempts")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Outcome")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Body")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Captured")},void 0,!1),(0,t.jsxDEV)(E,{},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)($e,{children:i.map(N=>(0,t.jsxDEV)(gt,{message:N,onReplay:a,replayingId:l},N.id,!1))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)},void 0,!1),e[17]=s,e[18]=i,e[19]=a,e[20]=l,e[21]=r,e[22]=g):g=e[22];let v;return e[23]!==m||e[24]!==g?(v=(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[m,g]},void 0,!0),e[23]=m,e[24]=g,e[25]=v):v=e[25],v},"QueuesMessagesTab"),xt=f(o=>{let e=(0,F.c)(20),{batchMode:s,bodyText:i,delayText:n,onBatchModeChange:a,onBodyChange:l,onDelayChange:r,onSelectExport:h,onSend:u,queues:y,selectedExportName:p,sending:x}=o,d=U(),m;e[0]!==d?(m=d("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=d,e[1]=m):m=e[1];let g;e[2]!==m?(g=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:m},void 0,!1),e[2]=m,e[3]=g):g=e[3];let v;e[4]!==s||e[5]!==i||e[6]!==n||e[7]!==a||e[8]!==l||e[9]!==r||e[10]!==h||e[11]!==u||e[12]!==y||e[13]!==p||e[14]!==x||e[15]!==d?(v=y.length===0?(0,t.jsxDEV)(ie,{description:d("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:d("No queues to send to")},void 0,!1):(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxDEV)("select",{"aria-label":d("Queue"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"queues-send-select",onChange:h,value:p,children:y.map(bt)},void 0,!1),(0,t.jsxDEV)(We,{"aria-label":d("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:r,placeholder:d("Delay (s)"),type:"number",value:n},void 0,!1),(0,t.jsxDEV)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[(0,t.jsxDEV)("input",{checked:s,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:a,type:"checkbox"},void 0,!1),d("Send as batch (JSON array)")]},void 0,!0),(0,t.jsxDEV)(V,{className:"ml-auto","data-testid":"queues-send-button",disabled:x||p==="",onClick:u,type:"button",children:d(x?"Sending\u2026":"Send message")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(Ve,{"aria-label":d("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:l,placeholder:s?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:i},void 0,!1)]},void 0,!0),e[4]=s,e[5]=i,e[6]=n,e[7]=a,e[8]=l,e[9]=r,e[10]=h,e[11]=u,e[12]=y,e[13]=p,e[14]=x,e[15]=d,e[16]=v):v=e[16];let N;return e[17]!==g||e[18]!==v?(N=(0,t.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[g,v]},void 0,!0),e[17]=g,e[18]=v,e[19]=N):N=e[19],N},"QueuesSendTab"),Ut=f(o=>{let e=(0,F.c)(59),{limit:s}=o,i=s??nt,n=Fe(),a=U(),[l,r]=(0,w.useState)("declared"),[h,u]=(0,w.useState)(null),y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={},e[0]=y):y=e[0];let{data:p,error:x,errorSource:d}=De(J.listQueues,y),m;e[1]!==i?(m={limit:i},e[1]=i,e[2]=m):m=e[2];let{data:g,error:v,errorSource:N,refetch:b}=De(J.getQueueMessages,m),S=Array.isArray(p?.queues)?[...p.queues].toSorted(Nt):[],A=g?.entries??[],{deadLetteredCount:C,queuesWithoutDlq:Q,showReliabilityWarning:D}=lt(S,A),[W,z]=(0,w.useState)(""),[I,L]=(0,w.useState)(""),[T,M]=(0,w.useState)(""),[G,Xe]=(0,w.useState)(!1),[he,Oe]=(0,w.useState)(!1),[pe,ke]=(0,w.useState)(null),H=S.some(c=>c.exportName===W)?W:S[0]?.exportName??"",Ue=l==="messages"?v:x,Ke=l==="messages"?N:d,ge=Ue??h,ve=Ue===null?h:Ke,Y;e[3]!==b?(Y=f(()=>{b()},"t3"),e[3]=b,e[4]=Y):Y=e[4],je(Y,l==="messages");let xe=f(async()=>{u(null);let c=H;if(c==="")return;let q=null,we=I.trim();if(we!=="")try{q=JSON.parse(we)}catch{u(a("Body must be valid JSON."));return}let Ae,Je=T.trim();if(Je!==""){let P=Number(Je);if(!Number.isFinite(P)||P<0){u(a("Delay must be a non-negative number of seconds."));return}Ae=P}if(G&&!Array.isArray(q)){u(a("Batch mode needs a JSON array body \u2014 each element is enqueued as one message."));return}Oe(!0);let st=G?{batch:q,delaySeconds:Ae,exportName:c}:{body:q,delaySeconds:Ae,exportName:c};try{await n.query(dt,st,ue("")),b()}catch(P){u(me(P))}Oe(!1)},"send"),X;e[5]!==n||e[6]!==b?(X=f(async c=>{u(null),ke(c);try{await n.query(it,{id:c},ue("")),b()}catch(q){u(me(q))}ke(null)},"t5"),e[5]=n,e[6]=b,e[7]=X):X=e[7];let ye=X,K;e[8]!==n||e[9]!==b?(K=f(async()=>{u(null);try{await n.query(ct,{},ue("")),b()}catch(c){u(me(c))}},"t6"),e[8]=n,e[9]=b,e[10]=K):K=e[10];let be=K,Z;e[11]===Symbol.for("react.memo_cache_sentinel")?(Z=f(c=>{let q=c.currentTarget.dataset.tab;(q==="declared"||q==="messages"||q==="send")&&r(q)},"t7"),e[11]=Z):Z=e[11];let Ze=Z,ee;e[12]===Symbol.for("react.memo_cache_sentinel")?(ee=f(c=>{z(c.currentTarget.value)},"t8"),e[12]=ee):ee=e[12];let Ne=ee,te;e[13]===Symbol.for("react.memo_cache_sentinel")?(te=f(c=>{L(c.currentTarget.value)},"t9"),e[13]=te):te=e[13];let qe=te,se;e[14]===Symbol.for("react.memo_cache_sentinel")?(se=f(c=>{M(c.currentTarget.value)},"t10"),e[14]=se):se=e[14];let Se=se,ae;e[15]===Symbol.for("react.memo_cache_sentinel")?(ae=f(c=>{Xe(c.currentTarget.checked)},"t11"),e[15]=ae):ae=e[15];let Ee=ae,oe;e[16]!==xe?(oe=f(()=>{fe(xe())},"t12"),e[16]=xe,e[17]=oe):oe=e[17];let _e=oe,re;e[18]!==ye?(re=f(c=>{let{id:q}=c.currentTarget.dataset;q!==void 0&&fe(ye(q))},"t13"),e[18]=ye,e[19]=re):re=e[19];let Te=re,le;e[20]!==be?(le=f(()=>{fe(be())},"t14"),e[20]=be,e[21]=le):le=e[21];let Ce=le,et="flex flex-col gap-6",tt="lunora-queues-panel",B;e[22]!==a||e[23]!==l?(B=(0,t.jsxDEV)("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(c=>(0,t.jsxDEV)(V,{"aria-selected":l===c,"data-tab":c,"data-testid":`queues-tab-${c}`,onClick:Ze,role:"tab",size:"sm",type:"button",variant:l===c?"secondary":"ghost",children:ht(c,a)},c,!1))},void 0,!1),e[22]=a,e[23]=l,e[24]=B):B=e[24];let R;e[25]!==ge||e[26]!==ve?(R=ge!==null&&(0,t.jsxDEV)(Pe,{error:ve,testId:"queues-error"},void 0,!1),e[25]=ge,e[26]=ve,e[27]=R):R=e[27];let Qe=D&&(0,t.jsxDEV)(Ge,{icon:(0,t.jsxDEV)("span",{"aria-hidden":"true",className:"text-base leading-none",children:"\u26A0"},void 0,!1),testId:"queues-dlq-warning",variant:"warning",children:(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[Q.length>0&&(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)("p",{className:"font-medium",children:a("No dead-letter queue on {queues}.",{queues:Q.map(qt).join(", ")})},void 0,!1),(0,t.jsxDEV)("p",{className:"text-muted-foreground",children:a("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")},void 0,!1)]},void 0,!0),C>0&&(0,t.jsxDEV)("p",{className:Q.length>0?"text-muted-foreground":"font-medium",children:C===1?a("1 message was recently dead-lettered."):a("{count} messages were recently dead-lettered.",{count:C})},void 0,!1)]},void 0,!0)},void 0,!1),$;e[28]!==S||e[29]!==p||e[30]!==l?($=l==="declared"&&(0,t.jsxDEV)(pt,{loaded:p!==void 0,queues:S},void 0,!1),e[28]=S,e[29]=p,e[30]=l,e[31]=$):$=e[31];let O;e[32]!==A||e[33]!==v||e[34]!==Ce||e[35]!==Te||e[36]!==pe||e[37]!==l?(O=l==="messages"&&(0,t.jsxDEV)(vt,{hasError:v!==null,messages:A,onClear:Ce,onReplay:Te,replayingId:pe},void 0,!1),e[32]=A,e[33]=v,e[34]=Ce,e[35]=Te,e[36]=pe,e[37]=l,e[38]=O):O=e[38];let k;e[39]!==G||e[40]!==I||e[41]!==T||e[42]!==Ee||e[43]!==qe||e[44]!==Se||e[45]!==Ne||e[46]!==_e||e[47]!==S||e[48]!==H||e[49]!==he||e[50]!==l?(k=l==="send"&&(0,t.jsxDEV)(xt,{batchMode:G,bodyText:I,delayText:T,onBatchModeChange:Ee,onBodyChange:qe,onDelayChange:Se,onSelectExport:Ne,onSend:_e,queues:S,selectedExportName:H,sending:he},void 0,!1),e[39]=G,e[40]=I,e[41]=T,e[42]=Ee,e[43]=qe,e[44]=Se,e[45]=Ne,e[46]=_e,e[47]=S,e[48]=H,e[49]=he,e[50]=l,e[51]=k):k=e[51];let ne;return e[52]!==B||e[53]!==R||e[54]!==Qe||e[55]!==$||e[56]!==O||e[57]!==k?(ne=(0,t.jsxDEV)("div",{className:et,"data-testid":tt,children:[B,R,Qe,$,O,k]},void 0,!0),e[52]=B,e[53]=R,e[54]=Qe,e[55]=$,e[56]=O,e[57]=k,e[58]=ne):ne=e[58],ne},"QueuesPanel");function yt(o){return(0,t.jsxDEV)(j,{"data-testid":`queues-row-${o.exportName}`,children:[(0,t.jsxDEV)(_,{className:"font-mono text-xs",children:o.exportName},void 0,!1),(0,t.jsxDEV)(_,{className:"font-mono text-xs text-muted-foreground",children:o.name},void 0,!1),(0,t.jsxDEV)(_,{className:"font-mono text-xs text-muted-foreground",children:o.mode},void 0,!1),(0,t.jsxDEV)(_,{className:"font-mono text-xs text-muted-foreground",children:o.binding},void 0,!1),(0,t.jsxDEV)(_,{className:"font-mono text-xs text-muted-foreground",children:o.deadLetterQueue??"\u2014"},void 0,!1)]},o.exportName,!0)}f(yt,"_temp");function bt(o){return(0,t.jsxDEV)("option",{value:o.exportName,children:o.exportName},o.exportName,!1)}f(bt,"_temp2");function Nt(o,e){return o.exportName.localeCompare(e.exportName)}f(Nt,"_temp3");function qt(o){return o.name}f(qt,"_temp4");export{Ut as default};
1
+ import{a as He}from"./chunk-YAECF5LW.js";import"./chunk-DWDILV2E.js";import{a as je}from"./chunk-J6J54MBP.js";import"./chunk-5OIBXYZM.js";import{a as Pe}from"./chunk-HN6KJXYQ.js";import{a as Ge}from"./chunk-XNJNSCLM.js";import{a as Be,b as Re,c as $e,d as j,e as E,f as _}from"./chunk-GTM65MVX.js";import{a as Ve}from"./chunk-VLXV72QE.js";import{R as We}from"./chunk-3CJW6NWG.js";import{c as V}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as J}from"./chunk-BOXSWNXZ.js";import{a as ie}from"./chunk-TAD43CG5.js";import{b as De}from"./chunk-RHZ4M2NZ.js";import{a as Le,e as Me}from"./chunk-SEU5V7I6.js";import{b as de}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as Fe}from"./chunk-XLXNLJ4N.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as U,e as ce,f as ue,g as me,k as fe,o as ze}from"./chunk-E75ANNWX.js";import"./chunk-JHKMUTIF.js";import{a as f,e as Ie,f as at,g as ot,h as rt}from"./chunk-RRCPZMC2.js";var F=Ie(ot(),1);var w=Ie(at(),1);var t=Ie(rt(),1);var lt=f((o,e)=>{let s=new Set(o.map(a=>a.deadLetterQueue).filter(a=>typeof a=="string"&&a!=="")),i=o.filter(a=>(a.deadLetterQueue===void 0||a.deadLetterQueue==="")&&!s.has(a.name)),n=e.filter(a=>a.deadLettered).length;return{deadLetteredCount:n,queuesWithoutDlq:i,showReliabilityWarning:i.length>0||n>0}},"computeQueueReliability"),nt=200,dt=ce(J.sendQueueMessage),it=ce(J.replayQueueMessage),ct=ce(J.clearQueueMessages),Ye=96,ut=f(o=>{if(o===void 0)return"\u2014";try{return JSON.stringify(o)}catch{return"[unserializable]"}},"formatBody"),mt=f(o=>o.length>Ye?`${o.slice(0,Ye)}\u2026`:o,"truncate"),ft=f(o=>o==="error"?"destructive":o==="retry"?"outline":"secondary","outcomeVariant"),ht=f((o,e)=>e(o==="messages"?"Messages":o==="send"?"Send":"Declared"),"tabLabel"),pt=f(o=>{let e=(0,F.c)(11),{loaded:s,queues:i}=o,n=U(),a;e[0]!==n?(a=n("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[0]=n,e[1]=a):a=e[1];let l;e[2]!==a?(l=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:a},void 0,!1),e[2]=a,e[3]=l):l=e[3];let r;e[4]!==s||e[5]!==i||e[6]!==n?(r=s&&i.length===0?(0,t.jsxDEV)(ie,{description:n("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:n("No queues defined")},void 0,!1):(0,t.jsxDEV)(Le,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Me,{className:"px-0",children:(0,t.jsxDEV)(Be,{"data-testid":"queues-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(E,{children:n("Export")},void 0,!1),(0,t.jsxDEV)(E,{children:n("Queue")},void 0,!1),(0,t.jsxDEV)(E,{children:n("Mode")},void 0,!1),(0,t.jsxDEV)(E,{children:n("Binding")},void 0,!1),(0,t.jsxDEV)(E,{children:n("Dead-letter")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)($e,{children:i.map(yt)},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[4]=s,e[5]=i,e[6]=n,e[7]=r):r=e[7];let h;return e[8]!==l||e[9]!==r?(h=(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[l,r]},void 0,!0),e[8]=l,e[9]=r,e[10]=h):h=e[10],h},"QueuesDeclaredTab"),gt=f(o=>{let e=(0,F.c)(67),{message:s,onReplay:i,replayingId:n}=o,a=U(),l,r,h,u,y,p,x,d,m,g;if(e[0]!==s.attempts||e[1]!==s.body||e[2]!==s.deadLettered||e[3]!==s.exportName||e[4]!==s.id||e[5]!==s.messageId||e[6]!==s.outcome||e[7]!==s.queue||e[8]!==a){let W=ut(s.body);r=j,p=`queues-message-${s.id}`;let z=s.exportName??s.queue;e[19]!==z?(x=(0,t.jsxDEV)(_,{className:"font-mono text-xs",children:z},void 0,!1),e[19]=z,e[20]=x):x=e[20],e[21]!==s.messageId?(d=(0,t.jsxDEV)(_,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:s.messageId,children:s.messageId},void 0,!1),e[21]=s.messageId,e[22]=d):d=e[22],e[23]!==s.attempts?(m=(0,t.jsxDEV)(_,{className:"font-mono text-xs tabular-nums",children:s.attempts},void 0,!1),e[23]=s.attempts,e[24]=m):m=e[24];let I=`queues-outcome-${s.id}`,L;e[25]!==s.outcome?(L=ft(s.outcome),e[25]=s.outcome,e[26]=L):L=e[26];let T;e[27]!==s.outcome||e[28]!==I||e[29]!==L?(T=(0,t.jsxDEV)(de,{"data-testid":I,variant:L,children:s.outcome},void 0,!1),e[27]=s.outcome,e[28]=I,e[29]=L,e[30]=T):T=e[30];let M;e[31]!==s.deadLettered||e[32]!==s.id||e[33]!==a?(M=s.deadLettered&&(0,t.jsxDEV)(de,{"data-testid":`queues-dlq-${s.id}`,variant:"destructive",children:a("DLQ")},void 0,!1),e[31]=s.deadLettered,e[32]=s.id,e[33]=a,e[34]=M):M=e[34],e[35]!==T||e[36]!==M?(g=(0,t.jsxDEV)(_,{children:(0,t.jsxDEV)("span",{className:"inline-flex items-center gap-1",children:[T,M]},void 0,!0)},void 0,!1),e[35]=T,e[36]=M,e[37]=g):g=e[37],l=_,h="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",u=W,y=mt(W),e[0]=s.attempts,e[1]=s.body,e[2]=s.deadLettered,e[3]=s.exportName,e[4]=s.id,e[5]=s.messageId,e[6]=s.outcome,e[7]=s.queue,e[8]=a,e[9]=l,e[10]=r,e[11]=h,e[12]=u,e[13]=y,e[14]=p,e[15]=x,e[16]=d,e[17]=m,e[18]=g}else l=e[9],r=e[10],h=e[11],u=e[12],y=e[13],p=e[14],x=e[15],d=e[16],m=e[17],g=e[18];let v;e[38]!==l||e[39]!==h||e[40]!==u||e[41]!==y?(v=(0,t.jsxDEV)(l,{className:h,title:u,children:y},void 0,!1),e[38]=l,e[39]=h,e[40]=u,e[41]=y,e[42]=v):v=e[42];let N;e[43]!==s.capturedAt?(N=ze(s.capturedAt,"\u2014"),e[43]=s.capturedAt,e[44]=N):N=e[44];let b;e[45]!==N?(b=(0,t.jsxDEV)(_,{className:"text-xs text-muted-foreground tabular-nums",children:N},void 0,!1),e[45]=N,e[46]=b):b=e[46];let S=`queues-replay-${s.id}`,A=n!==null,C;e[47]!==s.id||e[48]!==n||e[49]!==a?(C=n===s.id?a("Replaying\u2026"):a("Replay"),e[47]=s.id,e[48]=n,e[49]=a,e[50]=C):C=e[50];let Q;e[51]!==s.id||e[52]!==i||e[53]!==S||e[54]!==A||e[55]!==C?(Q=(0,t.jsxDEV)(_,{children:(0,t.jsxDEV)(V,{"data-id":s.id,"data-testid":S,disabled:A,onClick:i,size:"xs",type:"button",variant:"outline",children:C},void 0,!1)},void 0,!1),e[51]=s.id,e[52]=i,e[53]=S,e[54]=A,e[55]=C,e[56]=Q):Q=e[56];let D;return e[57]!==r||e[58]!==b||e[59]!==Q||e[60]!==p||e[61]!==x||e[62]!==d||e[63]!==m||e[64]!==g||e[65]!==v?(D=(0,t.jsxDEV)(r,{"data-testid":p,children:[x,d,m,g,v,b,Q]},void 0,!0),e[57]=r,e[58]=b,e[59]=Q,e[60]=p,e[61]=x,e[62]=d,e[63]=m,e[64]=g,e[65]=v,e[66]=D):D=e[66],D},"QueueLogRow"),vt=f(o=>{let e=(0,F.c)(26),{hasError:s,messages:i,onClear:n,onReplay:a,replayingId:l}=o,r=U(),h;e[0]!==r?(h=r("Cloudflare Queues have no peek API, so this is what push consumers actually processed \u2014 not pending depth."),e[0]=r,e[1]=h):h=e[1];let u;e[2]!==h?(u=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:h},void 0,!1),e[2]=h,e[3]=u):u=e[3];let y=i.length===0,p;e[4]!==r?(p=r("Clear log"),e[4]=r,e[5]=p):p=e[5];let x;e[6]!==n||e[7]!==y||e[8]!==p?(x=(0,t.jsxDEV)(V,{className:"ml-auto","data-testid":"queues-clear",disabled:y,onClick:n,size:"sm",type:"button",variant:"outline",children:p},void 0,!1),e[6]=n,e[7]=y,e[8]=p,e[9]=x):x=e[9];let d;e[10]!==i.length||e[11]!==r?(d=i.length>0&&(0,t.jsxDEV)(de,{"data-testid":"queues-count",variant:"secondary",children:r("{count} messages",{count:i.length})},void 0,!1),e[10]=i.length,e[11]=r,e[12]=d):d=e[12];let m;e[13]!==u||e[14]!==x||e[15]!==d?(m=(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[u,x,d]},void 0,!0),e[13]=u,e[14]=x,e[15]=d,e[16]=m):m=e[16];let g;e[17]!==s||e[18]!==i||e[19]!==a||e[20]!==l||e[21]!==r?(g=!s&&i.length===0?(0,t.jsxDEV)(ie,{description:r("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:r("No consumed messages yet.")},void 0,!1):(0,t.jsxDEV)(Le,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Me,{className:"px-0",children:(0,t.jsxDEV)(He,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:(0,t.jsxDEV)(Be,{"data-testid":"queues-messages-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(E,{children:r("Export")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Message")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Attempts")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Outcome")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Body")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Captured")},void 0,!1),(0,t.jsxDEV)(E,{},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)($e,{children:i.map(N=>(0,t.jsxDEV)(gt,{message:N,onReplay:a,replayingId:l},N.id,!1))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)},void 0,!1),e[17]=s,e[18]=i,e[19]=a,e[20]=l,e[21]=r,e[22]=g):g=e[22];let v;return e[23]!==m||e[24]!==g?(v=(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[m,g]},void 0,!0),e[23]=m,e[24]=g,e[25]=v):v=e[25],v},"QueuesMessagesTab"),xt=f(o=>{let e=(0,F.c)(20),{batchMode:s,bodyText:i,delayText:n,onBatchModeChange:a,onBodyChange:l,onDelayChange:r,onSelectExport:h,onSend:u,queues:y,selectedExportName:p,sending:x}=o,d=U(),m;e[0]!==d?(m=d("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=d,e[1]=m):m=e[1];let g;e[2]!==m?(g=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:m},void 0,!1),e[2]=m,e[3]=g):g=e[3];let v;e[4]!==s||e[5]!==i||e[6]!==n||e[7]!==a||e[8]!==l||e[9]!==r||e[10]!==h||e[11]!==u||e[12]!==y||e[13]!==p||e[14]!==x||e[15]!==d?(v=y.length===0?(0,t.jsxDEV)(ie,{description:d("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:d("No queues to send to")},void 0,!1):(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxDEV)("select",{"aria-label":d("Queue"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"queues-send-select",onChange:h,value:p,children:y.map(bt)},void 0,!1),(0,t.jsxDEV)(We,{"aria-label":d("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:r,placeholder:d("Delay (s)"),type:"number",value:n},void 0,!1),(0,t.jsxDEV)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[(0,t.jsxDEV)("input",{checked:s,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:a,type:"checkbox"},void 0,!1),d("Send as batch (JSON array)")]},void 0,!0),(0,t.jsxDEV)(V,{className:"ml-auto","data-testid":"queues-send-button",disabled:x||p==="",onClick:u,type:"button",children:d(x?"Sending\u2026":"Send message")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(Ve,{"aria-label":d("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:l,placeholder:s?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:i},void 0,!1)]},void 0,!0),e[4]=s,e[5]=i,e[6]=n,e[7]=a,e[8]=l,e[9]=r,e[10]=h,e[11]=u,e[12]=y,e[13]=p,e[14]=x,e[15]=d,e[16]=v):v=e[16];let N;return e[17]!==g||e[18]!==v?(N=(0,t.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[g,v]},void 0,!0),e[17]=g,e[18]=v,e[19]=N):N=e[19],N},"QueuesSendTab"),Ut=f(o=>{let e=(0,F.c)(59),{limit:s}=o,i=s??nt,n=Fe(),a=U(),[l,r]=(0,w.useState)("declared"),[h,u]=(0,w.useState)(null),y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={},e[0]=y):y=e[0];let{data:p,error:x,errorSource:d}=De(J.listQueues,y),m;e[1]!==i?(m={limit:i},e[1]=i,e[2]=m):m=e[2];let{data:g,error:v,errorSource:N,refetch:b}=De(J.getQueueMessages,m),S=Array.isArray(p?.queues)?[...p.queues].toSorted(Nt):[],A=g?.entries??[],{deadLetteredCount:C,queuesWithoutDlq:Q,showReliabilityWarning:D}=lt(S,A),[W,z]=(0,w.useState)(""),[I,L]=(0,w.useState)(""),[T,M]=(0,w.useState)(""),[G,Xe]=(0,w.useState)(!1),[he,Oe]=(0,w.useState)(!1),[pe,ke]=(0,w.useState)(null),H=S.some(c=>c.exportName===W)?W:S[0]?.exportName??"",Ue=l==="messages"?v:x,Ke=l==="messages"?N:d,ge=Ue??h,ve=Ue===null?h:Ke,Y;e[3]!==b?(Y=f(()=>{b()},"t3"),e[3]=b,e[4]=Y):Y=e[4],je(Y,l==="messages");let xe=f(async()=>{u(null);let c=H;if(c==="")return;let q=null,we=I.trim();if(we!=="")try{q=JSON.parse(we)}catch{u(a("Body must be valid JSON."));return}let Ae,Je=T.trim();if(Je!==""){let P=Number(Je);if(!Number.isFinite(P)||P<0){u(a("Delay must be a non-negative number of seconds."));return}Ae=P}if(G&&!Array.isArray(q)){u(a("Batch mode needs a JSON array body \u2014 each element is enqueued as one message."));return}Oe(!0);let st=G?{batch:q,delaySeconds:Ae,exportName:c}:{body:q,delaySeconds:Ae,exportName:c};try{await n.query(dt,st,ue("")),b()}catch(P){u(me(P))}Oe(!1)},"send"),X;e[5]!==n||e[6]!==b?(X=f(async c=>{u(null),ke(c);try{await n.query(it,{id:c},ue("")),b()}catch(q){u(me(q))}ke(null)},"t5"),e[5]=n,e[6]=b,e[7]=X):X=e[7];let ye=X,K;e[8]!==n||e[9]!==b?(K=f(async()=>{u(null);try{await n.query(ct,{},ue("")),b()}catch(c){u(me(c))}},"t6"),e[8]=n,e[9]=b,e[10]=K):K=e[10];let be=K,Z;e[11]===Symbol.for("react.memo_cache_sentinel")?(Z=f(c=>{let q=c.currentTarget.dataset.tab;(q==="declared"||q==="messages"||q==="send")&&r(q)},"t7"),e[11]=Z):Z=e[11];let Ze=Z,ee;e[12]===Symbol.for("react.memo_cache_sentinel")?(ee=f(c=>{z(c.currentTarget.value)},"t8"),e[12]=ee):ee=e[12];let Ne=ee,te;e[13]===Symbol.for("react.memo_cache_sentinel")?(te=f(c=>{L(c.currentTarget.value)},"t9"),e[13]=te):te=e[13];let qe=te,se;e[14]===Symbol.for("react.memo_cache_sentinel")?(se=f(c=>{M(c.currentTarget.value)},"t10"),e[14]=se):se=e[14];let Se=se,ae;e[15]===Symbol.for("react.memo_cache_sentinel")?(ae=f(c=>{Xe(c.currentTarget.checked)},"t11"),e[15]=ae):ae=e[15];let Ee=ae,oe;e[16]!==xe?(oe=f(()=>{fe(xe())},"t12"),e[16]=xe,e[17]=oe):oe=e[17];let _e=oe,re;e[18]!==ye?(re=f(c=>{let{id:q}=c.currentTarget.dataset;q!==void 0&&fe(ye(q))},"t13"),e[18]=ye,e[19]=re):re=e[19];let Te=re,le;e[20]!==be?(le=f(()=>{fe(be())},"t14"),e[20]=be,e[21]=le):le=e[21];let Ce=le,et="flex flex-col gap-6",tt="lunora-queues-panel",B;e[22]!==a||e[23]!==l?(B=(0,t.jsxDEV)("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(c=>(0,t.jsxDEV)(V,{"aria-selected":l===c,"data-tab":c,"data-testid":`queues-tab-${c}`,onClick:Ze,role:"tab",size:"sm",type:"button",variant:l===c?"secondary":"ghost",children:ht(c,a)},c,!1))},void 0,!1),e[22]=a,e[23]=l,e[24]=B):B=e[24];let R;e[25]!==ge||e[26]!==ve?(R=ge!==null&&(0,t.jsxDEV)(Pe,{error:ve,testId:"queues-error"},void 0,!1),e[25]=ge,e[26]=ve,e[27]=R):R=e[27];let Qe=D&&(0,t.jsxDEV)(Ge,{icon:(0,t.jsxDEV)("span",{"aria-hidden":"true",className:"text-base leading-none",children:"\u26A0"},void 0,!1),testId:"queues-dlq-warning",variant:"warning",children:(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[Q.length>0&&(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)("p",{className:"font-medium",children:a("No dead-letter queue on {queues}.",{queues:Q.map(qt).join(", ")})},void 0,!1),(0,t.jsxDEV)("p",{className:"text-muted-foreground",children:a("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")},void 0,!1)]},void 0,!0),C>0&&(0,t.jsxDEV)("p",{className:Q.length>0?"text-muted-foreground":"font-medium",children:C===1?a("1 message was recently dead-lettered."):a("{count} messages were recently dead-lettered.",{count:C})},void 0,!1)]},void 0,!0)},void 0,!1),$;e[28]!==S||e[29]!==p||e[30]!==l?($=l==="declared"&&(0,t.jsxDEV)(pt,{loaded:p!==void 0,queues:S},void 0,!1),e[28]=S,e[29]=p,e[30]=l,e[31]=$):$=e[31];let O;e[32]!==A||e[33]!==v||e[34]!==Ce||e[35]!==Te||e[36]!==pe||e[37]!==l?(O=l==="messages"&&(0,t.jsxDEV)(vt,{hasError:v!==null,messages:A,onClear:Ce,onReplay:Te,replayingId:pe},void 0,!1),e[32]=A,e[33]=v,e[34]=Ce,e[35]=Te,e[36]=pe,e[37]=l,e[38]=O):O=e[38];let k;e[39]!==G||e[40]!==I||e[41]!==T||e[42]!==Ee||e[43]!==qe||e[44]!==Se||e[45]!==Ne||e[46]!==_e||e[47]!==S||e[48]!==H||e[49]!==he||e[50]!==l?(k=l==="send"&&(0,t.jsxDEV)(xt,{batchMode:G,bodyText:I,delayText:T,onBatchModeChange:Ee,onBodyChange:qe,onDelayChange:Se,onSelectExport:Ne,onSend:_e,queues:S,selectedExportName:H,sending:he},void 0,!1),e[39]=G,e[40]=I,e[41]=T,e[42]=Ee,e[43]=qe,e[44]=Se,e[45]=Ne,e[46]=_e,e[47]=S,e[48]=H,e[49]=he,e[50]=l,e[51]=k):k=e[51];let ne;return e[52]!==B||e[53]!==R||e[54]!==Qe||e[55]!==$||e[56]!==O||e[57]!==k?(ne=(0,t.jsxDEV)("div",{className:et,"data-testid":tt,children:[B,R,Qe,$,O,k]},void 0,!0),e[52]=B,e[53]=R,e[54]=Qe,e[55]=$,e[56]=O,e[57]=k,e[58]=ne):ne=e[58],ne},"QueuesPanel");function yt(o){return(0,t.jsxDEV)(j,{"data-testid":`queues-row-${o.exportName}`,children:[(0,t.jsxDEV)(_,{className:"font-mono text-xs",children:o.exportName},void 0,!1),(0,t.jsxDEV)(_,{className:"font-mono text-xs text-muted-foreground",children:o.name},void 0,!1),(0,t.jsxDEV)(_,{className:"font-mono text-xs text-muted-foreground",children:o.mode},void 0,!1),(0,t.jsxDEV)(_,{className:"font-mono text-xs text-muted-foreground",children:o.binding},void 0,!1),(0,t.jsxDEV)(_,{className:"font-mono text-xs text-muted-foreground",children:o.deadLetterQueue??"\u2014"},void 0,!1)]},o.exportName,!0)}f(yt,"_temp");function bt(o){return(0,t.jsxDEV)("option",{value:o.exportName,children:o.exportName},o.exportName,!1)}f(bt,"_temp2");function Nt(o,e){return o.exportName.localeCompare(e.exportName)}f(Nt,"_temp3");function qt(o){return o.name}f(qt,"_temp4");export{Ut as default};
@@ -1 +1 @@
1
- import{b as f}from"./chunk-X33MSJPP.js";import"./chunk-CACB34RQ.js";import"./chunk-XNJNSCLM.js";import"./chunk-GTM65MVX.js";import{a as R}from"./chunk-BOXSWNXZ.js";import{b as p}from"./chunk-C7WTJLC3.js";import"./chunk-SEU5V7I6.js";import"./chunk-GLUNBZRI.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as h}from"./chunk-E75ANNWX.js";import"./chunk-GMSGZDDH.js";import{a as i,e as m,g as S,h as A}from"./chunk-RRCPZMC2.js";var g=m(S(),1);var k=m(A(),1);var _=i((e,s)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("Live admin subscriptions are ungated")})[s.kind],"findingTitle"),E=i(e=>Array.isArray(e.findings)?e.findings:[],"toFindings"),w=i(e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],"findingEntity"),T=i((e,s)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters \u2014 use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:s.detail?.length,min:s.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed \u2014 browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: live admin subscriptions need no credential. Set it to gate them like the HTTP admin RPCs.")})[s.kind],"findingDetail"),v=i(()=>{let e=(0,g.c)(8),s=h(),r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},e[0]=r):r=e[0];let{data:a,error:d,errorSource:c}=p(R.getSecurityAudit,r),o;if(e[1]!==a||e[2]!==s){let u=a===void 0?null:E(a);o=u===null?null:u.map(t=>({description:T(s,t),entity:w(t),issueType:_(s,t),key:t.kind,level:t.level})),e[1]=a,e[2]=s,e[3]=o}else o=e[3];let l=o,n;return e[4]!==d||e[5]!==c||e[6]!==l?(n=(0,k.jsxDEV)(f,{error:d,errorSource:c,rows:l,testId:"lunora-security-advisor"},void 0,!1),e[4]=d,e[5]=c,e[6]=l,e[7]=n):n=e[7],n},"SecurityAdvisorPanel");export{v as default};
1
+ import{b as f}from"./chunk-THNBTMUF.js";import"./chunk-HN6KJXYQ.js";import"./chunk-XNJNSCLM.js";import"./chunk-GTM65MVX.js";import{a as R}from"./chunk-BOXSWNXZ.js";import{b as p}from"./chunk-RHZ4M2NZ.js";import"./chunk-SEU5V7I6.js";import"./chunk-XLXNLJ4N.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as h}from"./chunk-E75ANNWX.js";import"./chunk-JHKMUTIF.js";import{a as i,e as m,g as S,h as A}from"./chunk-RRCPZMC2.js";var g=m(S(),1);var k=m(A(),1);var _=i((e,s)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("Live admin subscriptions are ungated")})[s.kind],"findingTitle"),E=i(e=>Array.isArray(e.findings)?e.findings:[],"toFindings"),w=i(e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],"findingEntity"),T=i((e,s)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters \u2014 use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:s.detail?.length,min:s.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed \u2014 browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: live admin subscriptions need no credential. Set it to gate them like the HTTP admin RPCs.")})[s.kind],"findingDetail"),v=i(()=>{let e=(0,g.c)(8),s=h(),r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},e[0]=r):r=e[0];let{data:a,error:d,errorSource:c}=p(R.getSecurityAudit,r),o;if(e[1]!==a||e[2]!==s){let u=a===void 0?null:E(a);o=u===null?null:u.map(t=>({description:T(s,t),entity:w(t),issueType:_(s,t),key:t.kind,level:t.level})),e[1]=a,e[2]=s,e[3]=o}else o=e[3];let l=o,n;return e[4]!==d||e[5]!==c||e[6]!==l?(n=(0,k.jsxDEV)(f,{error:d,errorSource:c,rows:l,testId:"lunora-security-advisor"},void 0,!1),e[4]=d,e[5]=c,e[6]=l,e[7]=n):n=e[7],n},"SecurityAdvisorPanel");export{v as default};