@lunora/studio 1.0.0-alpha.362 → 1.0.0-alpha.363
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/standalone/{chunk-J6XQKD2F.js → chunk-32V7XGNC.js} +1 -1
- package/dist/standalone/{chunk-Q2J73V2C.js → chunk-4L55URI5.js} +1 -1
- package/dist/standalone/{chunk-FBDIQ67D.js → chunk-4N76XUNG.js} +1 -1
- package/dist/standalone/{chunk-6KE7ILEZ.js → chunk-53XKGQEE.js} +1 -1
- package/dist/standalone/{chunk-7KJCRT4B.js → chunk-5QUTVSHM.js} +1 -1
- package/dist/standalone/{chunk-MJTVTUNI.js → chunk-5RX5CQSU.js} +1 -1
- package/dist/standalone/{chunk-ZG3IUVQ2.js → chunk-5Z2U4KBN.js} +1 -1
- package/dist/standalone/{chunk-ZKEYRU5C.js → chunk-75TRPM7O.js} +1 -1
- package/dist/standalone/{chunk-GC3GKGWD.js → chunk-7MLX5CGD.js} +1 -1
- package/dist/standalone/{chunk-BO5NNWMO.js → chunk-7TQ7BZ67.js} +1 -1
- package/dist/standalone/{chunk-H7BQUL7D.js → chunk-AD5J2ANS.js} +1 -1
- package/dist/standalone/{chunk-COLSZPCE.js → chunk-ALR4VAUE.js} +1 -1
- package/dist/standalone/{chunk-5EWIOOBI.js → chunk-AXE2SDRU.js} +1 -1
- package/dist/standalone/{chunk-JENPPZFV.js → chunk-BAEIW3YS.js} +1 -1
- package/dist/standalone/{chunk-BX7TFVCC.js → chunk-BBDTJG2K.js} +1 -1
- package/dist/standalone/{chunk-ZFQ253FX.js → chunk-BI6MZHZJ.js} +1 -1
- package/dist/standalone/{chunk-EE2COWFF.js → chunk-CP7QNLR4.js} +1 -1
- package/dist/standalone/{chunk-OP4QEV27.js → chunk-D57B4MFK.js} +1 -1
- package/dist/standalone/{chunk-53CGUTRT.js → chunk-DZFXH55R.js} +1 -1
- package/dist/standalone/{chunk-J3BZWYJQ.js → chunk-EPWCW2DF.js} +1 -1
- package/dist/standalone/{chunk-PAZKX7I6.js → chunk-FJLRSFTE.js} +1 -1
- package/dist/standalone/{chunk-L26RMC2W.js → chunk-FVCBNFQW.js} +1 -1
- package/dist/standalone/{chunk-UW6QNC74.js → chunk-GVQPNM3T.js} +1 -1
- package/dist/standalone/{chunk-7WV3EPE6.js → chunk-H3EIPYRZ.js} +1 -1
- package/dist/standalone/{chunk-HCCQTUHS.js → chunk-H5TMLWIS.js} +1 -1
- package/dist/standalone/{chunk-LPFUEJZ4.js → chunk-HBG6SSE2.js} +1 -1
- package/dist/standalone/{chunk-5O7ICPWV.js → chunk-HC2B7SXW.js} +1 -1
- package/dist/standalone/{chunk-IDZLHZIA.js → chunk-HGCOTYPV.js} +1 -1
- package/dist/standalone/{chunk-Q2KL457J.js → chunk-HLHMHCXS.js} +1 -1
- package/dist/standalone/{chunk-WADY55J2.js → chunk-HSF2DCJ2.js} +1 -1
- package/dist/standalone/{chunk-QEFLZBT7.js → chunk-I3SSF2T6.js} +1 -1
- package/dist/standalone/{chunk-ALQHMFOC.js → chunk-I5QX75DE.js} +1 -1
- package/dist/standalone/{chunk-JCRFMCNP.js → chunk-ICHZ2IBL.js} +1 -1
- package/dist/standalone/{chunk-E2FFHKGI.js → chunk-IG5VD7R7.js} +1 -1
- package/dist/standalone/{chunk-ABMHWBYA.js → chunk-KKMQUBYH.js} +1 -1
- package/dist/standalone/{chunk-AEU3EF4T.js → chunk-LDHJRHPZ.js} +1 -1
- package/dist/standalone/{chunk-X54WR7FF.js → chunk-MNYDT3RH.js} +1 -1
- package/dist/standalone/{chunk-OPIMGKWU.js → chunk-MT4ICMXJ.js} +1 -1
- package/dist/standalone/{chunk-N7WQJPOM.js → chunk-MXJTD2OX.js} +1 -1
- package/dist/standalone/{chunk-WCWP4EAW.js → chunk-OZAOWE7T.js} +1 -1
- package/dist/standalone/{chunk-GVZ3VFGG.js → chunk-Q3IA6HPX.js} +1 -1
- package/dist/standalone/{chunk-3RZD6VJ7.js → chunk-RBIVXSXT.js} +1 -1
- package/dist/standalone/{chunk-JHTL3QHW.js → chunk-SDDEOSQB.js} +1 -1
- package/dist/standalone/chunk-SHHGIT7M.js +7 -0
- package/dist/standalone/{chunk-Z57KMMOK.js → chunk-SVQWZPO4.js} +1 -1
- package/dist/standalone/{chunk-YX2N5PJW.js → chunk-TEMI7MVE.js} +1 -1
- package/dist/standalone/{chunk-VHPTPEZ4.js → chunk-U5MPNEM2.js} +1 -1
- package/dist/standalone/{chunk-5NIQHOPN.js → chunk-ULQNADMJ.js} +1 -1
- package/dist/standalone/{chunk-66LYVBXB.js → chunk-UPPNZ6MI.js} +1 -1
- package/dist/standalone/{chunk-ZSLKFLWE.js → chunk-UTQLJKHH.js} +1 -1
- package/dist/standalone/{chunk-FQEZUQ36.js → chunk-UVG3ZISC.js} +1 -1
- package/dist/standalone/{chunk-2FTGLXYA.js → chunk-VQDTA4P6.js} +1 -1
- package/dist/standalone/{chunk-7O5SGABV.js → chunk-WLHQ4FKC.js} +1 -1
- package/dist/standalone/{chunk-XWWQIAF6.js → chunk-XPFVUAPX.js} +1 -1
- package/dist/standalone/{chunk-NF2Q75WM.js → chunk-Y3IGTWUE.js} +1 -1
- package/dist/standalone/{chunk-J6FR2B77.js → chunk-Y64STA6O.js} +1 -1
- package/dist/standalone/{chunk-IUGNIG6L.js → chunk-YEXTJUKQ.js} +1 -1
- package/dist/standalone/{chunk-RE7GRXBM.js → chunk-YFTPHGS2.js} +1 -1
- package/dist/standalone/{chunk-EXFERMUT.js → chunk-Z64BZNPS.js} +1 -1
- package/dist/standalone/{chunk-TMWKF4XM.js → chunk-Z6VILGGP.js} +1 -1
- package/dist/standalone/{chunk-MQTI3STP.js → chunk-ZBOB33BA.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +3 -3
- package/dist/standalone/chunk-FACXM2UB.js +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as qe}from"./chunk-7O5SGABV.js";import{a as Ke}from"./chunk-JOPNP4EO.js";import{a as Je}from"./chunk-J4PQAVOF.js";import{a as Ze}from"./chunk-GJXCPZDN.js";import"./chunk-UXBNXITB.js";import{a as We}from"./chunk-J3BZWYJQ.js";import{a as He}from"./chunk-66BMMNUR.js";import{a as L}from"./chunk-TKBTZX4K.js";import{a as Xe}from"./chunk-2DT3QG6Q.js";import"./chunk-NGVP66OH.js";import"./chunk-QAOZXPLU.js";import{i as T}from"./chunk-IHGRWY3Y.js";import"./chunk-OWRKSQPE.js";import"./chunk-4EPW63HS.js";import{a as _}from"./chunk-V3BE427M.js";import"./chunk-CKEQX655.js";import"./chunk-UD5REVU2.js";import{a as De}from"./chunk-RCXNYW7P.js";import{b as D}from"./chunk-UQA2AJGI.js";import"./chunk-T3ZCW3RG.js";import{a as ze,b as _e,c as Pe,d as q,e as U,f as z}from"./chunk-7QEZ2SFW.js";import{b as Ve}from"./chunk-FBDIQ67D.js";import{a as X,e as Z}from"./chunk-OK2QU2EV.js";import{m as K}from"./chunk-FACXM2UB.js";import"./chunk-ZPQBVYNN.js";import{B as Q,j as Ee,r as Ue,s as J,u as Qe,w as te}from"./chunk-GNI37YCV.js";import"./chunk-PDBW6GTJ.js";import{a as lt}from"./chunk-GWNGVKLG.js";import{a as at,b as nt}from"./chunk-6G3E4PJ2.js";import{a as s,d as Me}from"./chunk-5PEAXTYQ.js";var C=Me(at(),1);var W=Me(lt(),1);var t=Me(nt(),1);var it=s(()=>{let h=(0,W.c)(3),{config:e,ready:n}=qe(),l;return h[0]!==e.capabilities||h[1]!==n?(l={capabilities:e.capabilities,ready:n},h[0]=e.capabilities,h[1]=n,h[2]=l):l=h[2],l},"nt"),st=s((h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending","lt"),et=500,rt=s((h,e)=>{if(!URL.canParse(h.trim()))return null;let n=new URL(h.trim());return n.searchParams.set("email",e.email),n.searchParams.set("invite",e.token),n.toString()},"at"),dt=s(h=>{let e=(0,W.c)(34),{issued:n,onSignUpPageChange:l,signUpPage:o}=h,a=Q(),[p,i]=(0,C.useState)(null),u;e[0]!==n||e[1]!==o?(u=rt(o,n),e[0]=n,e[1]=o,e[2]=u):u=e[2];let c=u,y;e[3]!==c?(y=s(()=>{let $="navigator"in globalThis?globalThis.navigator.clipboard:void 0;c===null||$===void 0||J($.writeText(c).then(()=>(i(c),!0)))},"y"),e[3]=c,e[4]=y):y=e[4];let w=y,g;e[5]!==a?(g=a("Send this link to the invitee. It is shown once and cannot be recovered."),e[5]=a,e[6]=g):g=e[6];let I;e[7]!==g?(I=(0,t.jsx)("p",{className:"text-sm",children:g}),e[7]=g,e[8]=I):I=e[8];let k=c===null,v;e[9]!==a?(v=a("Your app's sign-up page"),e[9]=a,e[10]=v):v=e[10];let d;e[11]!==l?(d=s($=>{l($.target.value)},"r"),e[11]=l,e[12]=d):d=e[12];let m;e[13]!==o||e[14]!==k||e[15]!==v||e[16]!==d?(m=(0,t.jsx)(T,{"aria-invalid":k,"aria-label":v,"data-testid":"sign-up-invitation-page",onChange:d,value:o}),e[13]=o,e[14]=k,e[15]=v,e[16]=d,e[17]=m):m=e[17];let b=c??"",x;e[18]!==b?(x=(0,t.jsx)(T,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:b}),e[18]=b,e[19]=x):x=e[19];let N;e[20]!==p||e[21]!==c||e[22]!==a?(N=a(p!==null&&p===c?"Copied":"Copy"),e[20]=p,e[21]=c,e[22]=a,e[23]=N):N=e[23];let f;e[24]!==w||e[25]!==N?(f=(0,t.jsx)(_,{"data-testid":"sign-up-invitation-copy",onClick:w,type:"button",children:N}),e[24]=w,e[25]=N,e[26]=f):f=e[26];let r;e[27]!==x||e[28]!==f?(r=(0,t.jsxs)("div",{className:"flex gap-2",children:[x,f]}),e[27]=x,e[28]=f,e[29]=r):r=e[29];let A;return e[30]!==r||e[31]!==I||e[32]!==m?(A=(0,t.jsx)(X,{children:(0,t.jsxs)(Z,{className:"flex flex-col gap-2 p-4",children:[I,m,r]})}),e[30]=r,e[31]=I,e[32]=m,e[33]=A):A=e[33],A},"it"),ot=s(()=>{let h=K(),e=Q(),[n,l]=(0,C.useState)(""),[o,a]=(0,C.useState)(null),[p,i]=(0,C.useState)(null),[u,c]=(0,C.useState)(()=>`${Qe(h.url)}/sign-up`),y=Ve(["lunora-auth-sign-up-invitations",et],()=>h.listAuthSignUpInvitations({limit:et})),w=y.data?.rows??null,g=y.data?.total??0,I=s(()=>{let v=n.trim();v!==""&&(a(null),J((async()=>{try{let d=await h.createAuthSignUpInvitation({email:v}),m=typeof d.token=="string"?d.token:void 0;i(m===void 0?null:{email:v,token:m}),l(""),y.refetch()}catch(d){a(d instanceof Error?d.message:String(d))}})()))},"w"),k=s(v=>{a(null),J((async()=>{try{await h.revokeAuthSignUpInvitation({email:v}),y.refetch()}catch(d){a(d instanceof Error?d.message:String(d))}})())},"k");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"sign-up-invitations",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-base font-medium",children:e("Sign-up invitations")}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("Only invited addresses can create an account. Nothing is emailed \u2014 send the invitee the one-time link yourself.")})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(T,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:s(v=>{l(v.target.value)},"onChange"),placeholder:e("ada@example.com"),type:"email",value:n}),(0,t.jsx)(_,{"data-testid":"sign-up-invitation-submit",onClick:I,type:"button",children:e("Invite")})]}),p!==null&&(0,t.jsx)(dt,{issued:p,onSignUpPageChange:c,signUpPage:u},p.token),(o??y.error)!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:o??y.error}),w!==null&&w.length===0&&(0,t.jsx)(De,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),w!==null&&g>w.length&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sign-up-invitations-truncated",children:e("Showing the most recent invitations. Query the signUpInvitation table directly to see the rest.")}),w!==null&&w.length>0&&(0,t.jsx)(X,{children:(0,t.jsx)(Z,{className:"p-0",children:(0,t.jsxs)(ze,{children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:e("Email")}),(0,t.jsx)(U,{children:e("Status")}),(0,t.jsx)(U,{children:e("Expires")}),(0,t.jsx)(U,{children:e("Invited by")}),(0,t.jsx)(U,{})]})}),(0,t.jsx)(Pe,{children:w.map(v=>{let d=st(v,Date.now()),m=v.email??"";return(0,t.jsxs)(q,{"data-testid":`sign-up-invitation-${m}`,children:[(0,t.jsx)(z,{children:m}),(0,t.jsxs)(z,{"data-testid":`sign-up-invitation-status-${m}`,children:[d==="spent"&&e("Accepted"),d==="expired"&&e("Expired"),d==="pending"&&e("Pending")]}),(0,t.jsx)(z,{children:typeof v.expiresAt=="number"?te(v.expiresAt):"\u2014"}),(0,t.jsx)(z,{children:v.invitedBy??"\u2014"}),(0,t.jsx)(z,{className:"text-right",children:(0,t.jsx)(_,{onClick:s(()=>{k(m)},"onClick"),type:"button",variant:"ghost",children:e("Revoke")})})]},v.id)})})]})})})]})},"rt"),ct={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},ut=s((h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),"dt"),mt=s((h,e)=>{if(h.type==="boolean")return e===!0?{value:!0}:h.required?{value:!1}:void 0;let n=typeof e=="string"?e.trim():"";if(n!==""){if(h.type==="number"){let l=Number(n);return Number.isNaN(l)?void 0:{value:l}}return{value:n}}},"ct"),ht=s(h=>{let e=(0,W.c)(105),{onClose:n,onCreated:l}=h,o=K(),a=Q(),{config:p}=qe(),{busy:i,error:u,run:c}=Ke(),[y,w]=(0,C.useState)(""),[g,I]=(0,C.useState)(""),[k,v]=(0,C.useState)(""),[d,m]=(0,C.useState)(""),b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];let[x,N]=(0,C.useState)(b),f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=s(S=>{w(S.target.value)},"p"),e[1]=f):f=e[1];let r=f,A;e[2]===Symbol.for("react.memo_cache_sentinel")?(A=s(S=>{I(S.target.value)},"S"),e[2]=A):A=e[2];let $=A,j;e[3]===Symbol.for("react.memo_cache_sentinel")?(j=s(S=>{v(S.target.value)},"z"),e[3]=j):j=e[3];let H=j,M;e[4]===Symbol.for("react.memo_cache_sentinel")?(M=s(S=>{m(S.target.value)},"M"),e[4]=M):M=e[4];let Y=M,B;e[5]===Symbol.for("react.memo_cache_sentinel")?(B=s((S,R)=>{N(ee=>({...ee,[S]:R}))},"L"),e[5]=B):B=e[5];let V=B,G;e[6]!==x?(G=s(S=>x[S.name]??(S.type==="boolean"?!1:""),"Y"),e[6]=x,e[7]=G):G=e[7];let P=G,O;if(e[8]!==p.userFields||e[9]!==P){let S;e[11]!==P?(S=s(R=>!R.required||ut(R,P(R)),"A"),e[11]=P,e[12]=S):S=e[12],O=p.userFields.every(S),e[8]=p.userFields,e[9]=P,e[10]=O}else O=e[10];let F=O,E;e[13]!==i||e[14]!==y||e[15]!==g||e[16]!==F?(E=!i&&y.trim()!==""&&g.trim()!==""&&F,e[13]=i,e[14]=y,e[15]=g,e[16]=F,e[17]=E):E=e[17];let $e=E,ae;e[18]!==p.userFields||e[19]!==P?(ae=s(()=>{let S={};for(let R of p.userFields){let ee=mt(R,P(R));ee!==void 0&&(S[R.name]=ee.value)}return Object.keys(S).length===0?void 0:S},"te"),e[18]=p.userFields,e[19]=P,e[20]=ae):ae=e[20];let je=ae,Re;e[21]!==je||e[22]!==o||e[23]!==y||e[24]!==g||e[25]!==n||e[26]!==l||e[27]!==k||e[28]!==d||e[29]!==c?(Re=s(()=>{c(async()=>{await o.createAuthUser({data:je(),email:y.trim(),name:g.trim(),password:k===""?void 0:k,role:d.trim()===""?void 0:d.trim()}),l(),n()})},"De"),e[21]=je,e[22]=o,e[23]=y,e[24]=g,e[25]=n,e[26]=l,e[27]=k,e[28]=d,e[29]=c,e[30]=Re):Re=e[30];let Be=Re,le;e[31]!==a?(le=a("Create user"),e[31]=a,e[32]=le):le=e[32];let ne;e[33]!==a?(ne=a("Create user"),e[33]=a,e[34]=ne):ne=e[34];let ie;e[35]!==ne?(ie=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:ne}),e[35]=ne,e[36]=ie):ie=e[36];let se;e[37]!==a?(se=a("email"),e[37]=a,e[38]=se):se=e[38];let re;e[39]!==se?(re=(0,t.jsx)(L,{htmlFor:"uc-email",children:se}),e[39]=se,e[40]=re):re=e[40];let de;e[41]!==y?(de=(0,t.jsx)(T,{"data-testid":"uc-email",id:"uc-email",onChange:r,type:"email",value:y}),e[41]=y,e[42]=de):de=e[42];let oe;e[43]!==re||e[44]!==de?(oe=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[re,de]}),e[43]=re,e[44]=de,e[45]=oe):oe=e[45];let ce;e[46]!==a?(ce=a("name"),e[46]=a,e[47]=ce):ce=e[47];let ue;e[48]!==ce?(ue=(0,t.jsx)(L,{htmlFor:"uc-name",children:ce}),e[48]=ce,e[49]=ue):ue=e[49];let me;e[50]!==g?(me=(0,t.jsx)(T,{"data-testid":"uc-name",id:"uc-name",onChange:$,value:g}),e[50]=g,e[51]=me):me=e[51];let he;e[52]!==ue||e[53]!==me?(he=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[ue,me]}),e[52]=ue,e[53]=me,e[54]=he):he=e[54];let pe;e[55]!==a?(pe=a("Password (optional)"),e[55]=a,e[56]=pe):pe=e[56];let fe;e[57]!==pe?(fe=(0,t.jsx)(L,{htmlFor:"uc-password",children:pe}),e[57]=pe,e[58]=fe):fe=e[58];let ve;e[59]!==k?(ve=(0,t.jsx)(T,{"data-testid":"uc-password",id:"uc-password",onChange:H,type:"password",value:k}),e[59]=k,e[60]=ve):ve=e[60];let ge;e[61]!==fe||e[62]!==ve?(ge=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[fe,ve]}),e[61]=fe,e[62]=ve,e[63]=ge):ge=e[63];let be;e[64]!==a?(be=a("Role (optional)"),e[64]=a,e[65]=be):be=e[65];let xe;e[66]!==be?(xe=(0,t.jsx)(L,{htmlFor:"uc-role",children:be}),e[66]=be,e[67]=xe):xe=e[67];let ye;e[68]!==d?(ye=(0,t.jsx)(T,{"data-testid":"uc-role",id:"uc-role",onChange:Y,value:d}),e[68]=d,e[69]=ye):ye=e[69];let Ne;e[70]!==xe||e[71]!==ye?(Ne=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[xe,ye]}),e[70]=xe,e[71]=ye,e[72]=Ne):Ne=e[72];let ke;e[73]!==p.userFields||e[74]!==P||e[75]!==a?(ke=p.userFields.length>0&&(0,t.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Plugin fields")}),p.userFields.map(S=>{let R=`uc-field-${S.name}`,ee=S.required?"":` (${a("optional")})`;if(S.type==="boolean"){let Le=P(S)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:R,children:[(0,t.jsx)(Ze,{checked:Le,"data-testid":R,id:R,onCheckedChange:s(tt=>{V(S.name,tt)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[S.name,ee]})]},S.name)}let Ge=P(S);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(L,{htmlFor:R,children:[S.name,ee]}),(0,t.jsx)(T,{"data-testid":R,id:R,onChange:s(Le=>{V(S.name,Le.target.value)},"onChange"),type:ct[S.type],value:typeof Ge=="string"?Ge:""})]},S.name)})]}),e[73]=p.userFields,e[74]=P,e[75]=a,e[76]=ke):ke=e[76];let we;e[77]!==u?(we=u!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:u}),e[77]=u,e[78]=we):we=e[78];let Ce;e[79]!==a?(Ce=a("Cancel"),e[79]=a,e[80]=Ce):Ce=e[80];let Ie;e[81]!==n||e[82]!==Ce?(Ie=(0,t.jsx)(_,{"data-testid":"uc-cancel",onClick:n,size:"sm",type:"button",variant:"outline",children:Ce}),e[81]=n,e[82]=Ce,e[83]=Ie):Ie=e[83];let Oe=!$e,Se;e[84]!==i||e[85]!==a?(Se=a(i?"Creating\u2026":"Create"),e[84]=i,e[85]=a,e[86]=Se):Se=e[86];let Ae;e[87]!==Be||e[88]!==Oe||e[89]!==Se?(Ae=(0,t.jsx)(_,{"data-testid":"uc-submit",disabled:Oe,onClick:Be,size:"sm",type:"button",children:Se}),e[87]=Be,e[88]=Oe,e[89]=Se,e[90]=Ae):Ae=e[90];let Fe;e[91]!==Ie||e[92]!==Ae?(Fe=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[Ie,Ae]}),e[91]=Ie,e[92]=Ae,e[93]=Fe):Fe=e[93];let Te;return e[94]!==n||e[95]!==le||e[96]!==ie||e[97]!==oe||e[98]!==he||e[99]!==ge||e[100]!==Ne||e[101]!==ke||e[102]!==we||e[103]!==Fe?(Te=(0,t.jsxs)(He,{label:le,onClose:n,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[ie,oe,he,ge,Ne,ke,we,Fe]}),e[94]=n,e[95]=le,e[96]=ie,e[97]=oe,e[98]=he,e[99]=ge,e[100]=Ne,e[101]=ke,e[102]=we,e[103]=Fe,e[104]=Te):Te=e[104],Te},"ut"),Ye=s(h=>{let e=(0,W.c)(2),{children:n}=h,l;return e[0]!==n?(l=(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n}),e[0]=n,e[1]=l):l=e[1],l},"_e"),pt=s(h=>{let e=(0,W.c)(29),{busy:n,runAction:l,userId:o,version:a}=h,p=K(),i=Q(),[u,c]=(0,C.useState)(null),[y,w]=(0,C.useState)(null),g;e[0]!==p||e[1]!==o?(g=s(()=>{J((async()=>{w(null);try{let r=await p.listAuthSessions({limit:50,userId:o});c(r.rows)}catch(r){let A=r;c(null),w(Ee(A))}})())},"g"),e[0]=p,e[1]=o,e[2]=g):g=e[2];let I;e[3]!==p||e[4]!==o||e[5]!==a?(I=[p,o,a],e[3]=p,e[4]=o,e[5]=a,e[6]=I):I=e[6],(0,C.useEffect)(g,I);let k;e[7]!==p||e[8]!==l?(k=s(r=>{l(()=>p.revokeAuthSession({sessionId:r}))},"k"),e[7]=p,e[8]=l,e[9]=k):k=e[9];let v=k,d;e[10]!==i?(d=i("Sessions"),e[10]=i,e[11]=d):d=e[11];let m;e[12]!==d?(m=(0,t.jsx)(Ye,{children:d}),e[12]=d,e[13]=m):m=e[13];let b;e[14]!==y?(b=y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:y}),e[14]=y,e[15]=b):b=e[15];let x;e[16]!==u||e[17]!==i?(x=u!==null&&u.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:i("No active sessions.")}),e[16]=u,e[17]=i,e[18]=x):x=e[18];let N;e[19]!==n||e[20]!==v||e[21]!==u||e[22]!==i?(N=u!==null&&u.length>0&&(0,t.jsx)(X,{className:"overflow-hidden py-0",children:(0,t.jsx)(Z,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:i("expires")}),(0,t.jsx)(U,{children:i("ip")}),(0,t.jsx)(U,{children:i("user agent")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Pe,{children:u.map(r=>(0,t.jsxs)(q,{"data-testid":`ud-session-${r.id}`,children:[(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.expiresAt)}),(0,t.jsx)(z,{children:r.ipAddress??""}),(0,t.jsx)(z,{className:"max-w-40 truncate",children:r.userAgent??""}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-revoke-${r.id}`,disabled:n,onClick:s(()=>{v(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Revoke")})})]},r.id))})]})})}),e[19]=n,e[20]=v,e[21]=u,e[22]=i,e[23]=N):N=e[23];let f;return e[24]!==m||e[25]!==b||e[26]!==x||e[27]!==N?(f=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[m,b,x,N]}),e[24]=m,e[25]=b,e[26]=x,e[27]=N,e[28]=f):f=e[28],f},"mt"),ft=s(h=>{let e=(0,W.c)(30),{busy:n,runAction:l,userId:o,version:a}=h,p=K(),i=Q(),[u,c]=(0,C.useState)(null),[y,w]=(0,C.useState)(null),g;e[0]!==p||e[1]!==o?(g=s(()=>{J((async()=>{w(null);try{c(await p.listAuthAccounts({userId:o}))}catch(r){let A=r;c(null),w(Ee(A))}})())},"g"),e[0]=p,e[1]=o,e[2]=g):g=e[2];let I;e[3]!==p||e[4]!==o||e[5]!==a?(I=[p,o,a],e[3]=p,e[4]=o,e[5]=a,e[6]=I):I=e[6],(0,C.useEffect)(g,I);let k;e[7]!==p||e[8]!==l||e[9]!==o?(k=s(r=>{l(()=>p.unlinkAuthAccount({accountId:r,userId:o}))},"k"),e[7]=p,e[8]=l,e[9]=o,e[10]=k):k=e[10];let v=k,d;e[11]!==i?(d=i("Linked accounts"),e[11]=i,e[12]=d):d=e[12];let m;e[13]!==d?(m=(0,t.jsx)(Ye,{children:d}),e[13]=d,e[14]=m):m=e[14];let b;e[15]!==y?(b=y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:y}),e[15]=y,e[16]=b):b=e[16];let x;e[17]!==u||e[18]!==i?(x=u!==null&&u.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:i("No linked accounts.")}),e[17]=u,e[18]=i,e[19]=x):x=e[19];let N;e[20]!==u||e[21]!==n||e[22]!==v||e[23]!==i?(N=u!==null&&u.length>0&&(0,t.jsx)(X,{className:"overflow-hidden py-0",children:(0,t.jsx)(Z,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:i("provider")}),(0,t.jsx)(U,{children:i("created")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Pe,{children:u.map(r=>{let A=Ue(r.id);return(0,t.jsxs)(q,{"data-testid":`ud-account-${A}`,children:[(0,t.jsx)(z,{children:Ue(r.providerId)}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-unlink-${A}`,disabled:n,onClick:s(()=>{v(A)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Unlink")})})]},A)})})]})})}),e[20]=u,e[21]=n,e[22]=v,e[23]=i,e[24]=N):N=e[24];let f;return e[25]!==m||e[26]!==b||e[27]!==x||e[28]!==N?(f=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[m,b,x,N]}),e[25]=m,e[26]=b,e[27]=x,e[28]=N,e[29]=f):f=e[29],f},"ht"),vt=s(h=>{let e=(0,W.c)(40),{busy:n,capabilities:l,runAction:o,userId:a,version:p}=h,i=K(),u=Q(),[c,y]=(0,C.useState)(null),w;e[0]!==l.passkey||e[1]!==i||e[2]!==a?(w=s(()=>{l.passkey&&J((async()=>{try{y(await i.listAuthPasskeys({userId:a}))}catch{y(null)}})())},"C"),e[0]=l.passkey,e[1]=i,e[2]=a,e[3]=w):w=e[3];let g;e[4]!==l.passkey||e[5]!==i||e[6]!==a||e[7]!==p?(g=[l.passkey,i,a,p],e[4]=l.passkey,e[5]=i,e[6]=a,e[7]=p,e[8]=g):g=e[8],(0,C.useEffect)(w,g);let I;e[9]!==i||e[10]!==o||e[11]!==a?(I=s(()=>{o(()=>i.disableAuthTwoFactor({userId:a}))},"w"),e[9]=i,e[10]=o,e[11]=a,e[12]=I):I=e[12];let k=I,v;e[13]!==i||e[14]!==o?(v=s(A=>{o(()=>i.deleteAuthPasskey({passkeyId:A}))},"v"),e[13]=i,e[14]=o,e[15]=v):v=e[15];let d=v,m;e[16]!==u?(m=u("Security"),e[16]=u,e[17]=m):m=e[17];let b;e[18]!==m?(b=(0,t.jsx)(Ye,{children:m}),e[18]=m,e[19]=b):b=e[19];let x;e[20]!==n||e[21]!==l.twoFactor||e[22]!==k||e[23]!==u?(x=l.twoFactor&&(0,t.jsx)(_,{"data-testid":"ud-disable-2fa",disabled:n,onClick:k,size:"sm",type:"button",variant:"outline",children:u("Disable two-factor")}),e[20]=n,e[21]=l.twoFactor,e[22]=k,e[23]=u,e[24]=x):x=e[24];let N;e[25]!==l.passkey||e[26]!==c||e[27]!==u?(N=l.passkey&&c!==null&&c.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:u("No passkeys.")}),e[25]=l.passkey,e[26]=c,e[27]=u,e[28]=N):N=e[28];let f;e[29]!==n||e[30]!==l.passkey||e[31]!==d||e[32]!==c||e[33]!==u?(f=l.passkey&&c!==null&&c.length>0&&(0,t.jsx)(X,{className:"overflow-hidden py-0",children:(0,t.jsx)(Z,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-passkeys-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:u("name")}),(0,t.jsx)(U,{children:u("created")}),(0,t.jsx)(U,{"aria-label":u("Actions")})]})}),(0,t.jsx)(Pe,{children:c.map(A=>{let $=Ue(A.id);return(0,t.jsxs)(q,{"data-testid":`ud-passkey-${$}`,children:[(0,t.jsx)(z,{children:Ue(A.name)||$}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(A.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-delete-passkey-${$}`,disabled:n,onClick:s(()=>{d($)},"onClick"),size:"xs",type:"button",variant:"ghost",children:u("Delete")})})]},$)})})]})})}),e[29]=n,e[30]=l.passkey,e[31]=d,e[32]=c,e[33]=u,e[34]=f):f=e[34];let r;return e[35]!==b||e[36]!==x||e[37]!==N||e[38]!==f?(r=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[b,x,N,f]}),e[35]=b,e[36]=x,e[37]=N,e[38]=f,e[39]=r):r=e[39],r},"ft"),gt=/(?:at|expires)$/iu,bt=/^[1-9]\d*$/u,xt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),yt=s(h=>{let e=(0,W.c)(51),{busy:n,onBan:l}=h,o=Q(),[a,p]=(0,C.useState)(""),[i,u]=(0,C.useState)(""),[c,y]=(0,C.useState)(!1),w;e[0]!==i?(w=bt.test(i.trim())&&Number.isSafeInteger(Number(i.trim())*86400)?Number(i.trim()):void 0,e[0]=i,e[1]=w):w=e[1];let g=w,I=c||g!==void 0,k;e[2]!==l||e[3]!==c||e[4]!==a||e[5]!==g?(k=s(()=>{l({expiresInSeconds:c||g===void 0?void 0:g*86400,reason:a.trim()===""?void 0:a.trim()})},"k"),e[2]=l,e[3]=c,e[4]=a,e[5]=g,e[6]=k):k=e[6];let v=k,d;e[7]!==o?(d=o("Ban reason (optional)"),e[7]=o,e[8]=d):d=e[8];let m;e[9]!==d?(m=(0,t.jsx)(L,{htmlFor:"ud-ban-reason",children:d}),e[9]=d,e[10]=m):m=e[10];let b;e[11]===Symbol.for("react.memo_cache_sentinel")?(b=s(E=>{p(E.target.value)},"b"),e[11]=b):b=e[11];let x;e[12]!==a?(x=(0,t.jsx)(T,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:b,value:a}),e[12]=a,e[13]=x):x=e[13];let N;e[14]!==m||e[15]!==x?(N=(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[m,x]}),e[14]=m,e[15]=x,e[16]=N):N=e[16];let f;e[17]!==o?(f=o("Days"),e[17]=o,e[18]=f):f=e[18];let r;e[19]!==f?(r=(0,t.jsx)(L,{htmlFor:"ud-ban-days",children:f}),e[19]=f,e[20]=r):r=e[20];let A;e[21]!==i||e[22]!==g?(A=i.trim()!==""&&g===void 0,e[21]=i,e[22]=g,e[23]=A):A=e[23];let $;e[24]===Symbol.for("react.memo_cache_sentinel")?($=s(E=>{u(E.target.value)},"T"),e[24]=$):$=e[24];let j;e[25]!==i||e[26]!==c||e[27]!==A?(j=(0,t.jsx)(T,{"aria-invalid":A,"data-testid":"ud-ban-days",disabled:c,id:"ud-ban-days",min:1,onChange:$,step:1,type:"number",value:i}),e[25]=i,e[26]=c,e[27]=A,e[28]=j):j=e[28];let H;e[29]!==j||e[30]!==r?(H=(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[r,j]}),e[29]=j,e[30]=r,e[31]=H):H=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=s(E=>{y(E.target.checked)},"M"),e[32]=M):M=e[32];let Y;e[33]!==c?(Y=(0,t.jsx)("input",{checked:c,className:"size-4 accent-destructive","data-testid":"ud-ban-permanent",id:"ud-ban-permanent",onChange:M,type:"checkbox"}),e[33]=c,e[34]=Y):Y=e[34];let B;e[35]!==o?(B=o("Permanent"),e[35]=o,e[36]=B):B=e[36];let V;e[37]!==Y||e[38]!==B?(V=(0,t.jsxs)(L,{className:"flex items-center gap-1.5 pb-2 text-xs font-normal",htmlFor:"ud-ban-permanent",children:[Y,B]}),e[37]=Y,e[38]=B,e[39]=V):V=e[39];let G=n||!I,P;e[40]!==o?(P=o("Ban user"),e[40]=o,e[41]=P):P=e[41];let O;e[42]!==v||e[43]!==G||e[44]!==P?(O=(0,t.jsx)(_,{"data-testid":"ud-ban",disabled:G,onClick:v,size:"sm",type:"button",variant:"destructive",children:P}),e[42]=v,e[43]=G,e[44]=P,e[45]=O):O=e[45];let F;return e[46]!==H||e[47]!==V||e[48]!==O||e[49]!==N?(F=(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[N,H,V,O]}),e[46]=H,e[47]=V,e[48]=O,e[49]=N,e[50]=F):F=e[50],F},"bt"),Nt=s((h,e)=>typeof e=="number"&>.test(h)?te(e):Ue(e),"xt"),kt=s(({capabilities:h,onChanged:e,onClose:n,user:l})=>{let o=K(),a=Q(),p=l.banned===!0,[i,u]=(0,C.useState)(null),[c,y]=(0,C.useState)(!1),[w,g]=(0,C.useState)(0),[I,k]=(0,C.useState)(typeof l.role=="string"?l.role:""),[v,d]=(0,C.useState)(""),[m,b]=(0,C.useState)(null),[x,N]=(0,C.useState)(!1),f=s((F,E)=>{J((async()=>{y(!0),u(null);try{let $e=await F();E?.refresh!==!1&&(g(ae=>ae+1),e()),E?.onResult?.($e)}catch($e){u(Ee($e))}y(!1)})())},"p"),r=s(F=>{k(F.target.value)},"i"),A=s(F=>{d(F.target.value)},"S"),$=s(()=>{let F=I.trim();F!==""&&f(async()=>{await o.setAuthUserRole({role:F,userId:l.id})})},"T"),j=s(F=>{f(async()=>{await o.banAuthUser({...F,userId:l.id})})},"z"),H=s(()=>{f(async()=>{await o.unbanAuthUser({userId:l.id})})},"j"),M=s(()=>{f(async()=>{await o.setAuthUserPassword({newPassword:v,userId:l.id}),d("")})},"M"),Y=s(()=>{f(()=>o.impersonateAuthUser({userId:l.id}),{onResult:s(F=>{b(F.token)},"onResult"),refresh:!1})},"H"),B=s(()=>{f(async()=>{await o.revokeAuthUserSessions({userId:l.id})})},"L"),V=s(()=>{f(async()=>{await o.removeAuthUser({userId:l.id}),n()})},"V"),G=s(()=>{N(!0)},"Y"),P=s(()=>{N(!1)},"E"),O=Object.entries(l).filter(([F])=>!xt.has(F));return(0,t.jsxs)(He,{label:a("User details"),onClose:n,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:l.name??l.email??l.id}),(0,t.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:l.id}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof l.role=="string"&&l.role!==""&&(0,t.jsx)(D,{variant:"secondary",children:l.role}),p?(0,t.jsx)(D,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(D,{variant:"outline",children:a("Active")}),l.emailVerified===!0?(0,t.jsx)(D,{variant:"secondary",children:a("verified")}):(0,t.jsx)(D,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(_,{"data-testid":"ud-close",onClick:n,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),i!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:i}),h.admin&&(0,t.jsxs)(X,{className:"gap-0 py-0",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Actions")})}),(0,t.jsxs)(Z,{className:"flex flex-col gap-3 p-3",children:[(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(L,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(T,{"data-testid":"ud-role-input",id:"ud-role",onChange:r,value:I})]}),(0,t.jsx)(_,{"data-testid":"ud-set-role",disabled:c||I.trim()==="",onClick:$,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),p?(0,t.jsx)(_,{"data-testid":"ud-unban",disabled:c,onClick:H,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(0,t.jsx)(yt,{busy:c,onBan:j}),(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(L,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(T,{"data-testid":"ud-password",id:"ud-password",onChange:A,type:"password",value:v})]}),(0,t.jsx)(_,{"data-testid":"ud-set-password",disabled:c||v==="",onClick:M,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(_,{"data-testid":"ud-impersonate",disabled:c,onClick:Y,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(_,{"data-testid":"ud-revoke-all",disabled:c,onClick:B,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),x?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(_,{"data-testid":"ud-delete-confirm",disabled:c,onClick:V,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(_,{"data-testid":"ud-delete-cancel",onClick:P,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(_,{"data-testid":"ud-delete",disabled:c,onClick:G,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),m!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(L,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(T,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:m})]})]})]}),(0,t.jsx)(pt,{busy:c,runAction:f,userId:l.id,version:w}),h.accounts&&(0,t.jsx)(ft,{busy:c,runAction:f,userId:l.id,version:w}),(h.twoFactor||h.passkey)&&(0,t.jsx)(vt,{busy:c,capabilities:h,runAction:f,userId:l.id,version:w}),(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Fields")}),(0,t.jsx)("dl",{className:"flex flex-col",children:O.map(([F,E])=>(0,t.jsxs)("div",{className:"flex flex-col border-t border-border py-1.5",children:[(0,t.jsx)("dt",{className:"text-xs font-semibold text-muted-foreground",children:F}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:Nt(F,E)})]},F))})]})]})},"yt"),wt=50,Vt=s(({pageSize:h=wt}={})=>{let e=K(),n=Q(),[l,o]=(0,C.useState)(""),[a,p]=(0,C.useState)(""),[i,u]=(0,C.useState)(0),c=Xe(l),[y,w]=(0,C.useState)(null),[g,I]=(0,C.useState)(!1),{capabilities:k}=it(),v=c.trim(),d=a.trim(),m=Ve(["lunora-auth-users",v,d,h,i],()=>e.listAuthUsers({filterField:d===""?void 0:"role",filterValue:d===""?void 0:d,limit:h,offset:i,search:v===""?void 0:v}).then(r=>({...r,offset:i})),{keepPreviousData:!0}),b=m.data?.rows??null,x=m.error,N=s(()=>{m.refetch()},"N");We(()=>m.poll(),!0);let f=y===null?null:b?.find(r=>r.id===y)??null;return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(T,{"aria-label":n("Search users"),className:"w-56","data-testid":"us-search",onChange:s(r=>{o(r.target.value),u(0)},"onChange"),placeholder:n("Search by email or name\u2026"),value:l}),(0,t.jsx)(T,{"aria-label":n("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:s(r=>{p(r.target.value),u(0)},"onChange"),placeholder:n("Filter by role"),value:a}),(0,t.jsx)(_,{"data-testid":"us-new",onClick:s(()=>{I(!0)},"onClick"),size:"sm",type:"button",children:n("New user")})]}),x!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:x}),b!==null&&b.length===0&&(0,t.jsx)(De,{description:n("Users who sign up to your app will appear here."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:n("No users.")}),b!==null&&b.length>0&&(0,t.jsx)(X,{className:"overflow-hidden py-0",children:(0,t.jsx)(Z,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"us-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:n("id")}),(0,t.jsx)(U,{children:n("email")}),(0,t.jsx)(U,{children:n("name")}),(0,t.jsx)(U,{children:n("role")}),(0,t.jsx)(U,{children:n("status")}),(0,t.jsx)(U,{children:n("verified")}),(0,t.jsx)(U,{children:n("created")}),(0,t.jsx)(U,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Pe,{children:b.map(r=>(0,t.jsxs)(q,{"data-testid":`us-row-${r.id}`,children:[(0,t.jsx)(z,{className:"font-mono text-xs",children:r.id}),(0,t.jsx)(z,{children:r.email??""}),(0,t.jsx)(z,{children:r.name??""}),(0,t.jsx)(z,{children:typeof r.role=="string"&&r.role!==""?(0,t.jsx)(D,{variant:"secondary",children:r.role}):""}),(0,t.jsx)(z,{children:r.banned===!0?(0,t.jsx)(D,{variant:"destructive",children:n("Banned")}):(0,t.jsx)(D,{variant:"success",children:n("Active")})}),(0,t.jsx)(z,{children:r.emailVerified===!0?(0,t.jsx)(D,{variant:"success",children:n("yes")}):(0,t.jsx)(D,{variant:"outline",children:n("no")})}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`us-manage-${r.id}`,onClick:s(()=>{w(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Manage")})})]},r.id))})]})})}),b!==null&&(0,t.jsx)(Je,{count:b.length,offset:m.data?.offset??0,onOffsetChange:u,pageSize:h,prefix:"us",total:m.data?.total}),f!==null&&(0,t.jsx)(kt,{capabilities:k,onChanged:N,onClose:s(()=>{w(null)},"onClose"),user:f}),g&&(0,t.jsx)(ht,{onClose:s(()=>{I(!1)},"onClose"),onCreated:N}),k.inviteOnly&&(0,t.jsx)(ot,{})]})},"jt");export{Vt as UsersPanel};
|
|
1
|
+
import{a as qe}from"./chunk-WLHQ4FKC.js";import{a as Ke}from"./chunk-JOPNP4EO.js";import{a as Je}from"./chunk-J4PQAVOF.js";import{a as Ze}from"./chunk-GJXCPZDN.js";import"./chunk-UXBNXITB.js";import{a as We}from"./chunk-EPWCW2DF.js";import{a as He}from"./chunk-66BMMNUR.js";import{a as L}from"./chunk-TKBTZX4K.js";import{a as Xe}from"./chunk-2DT3QG6Q.js";import"./chunk-NGVP66OH.js";import"./chunk-QAOZXPLU.js";import{i as T}from"./chunk-IHGRWY3Y.js";import"./chunk-OWRKSQPE.js";import"./chunk-4EPW63HS.js";import{a as _}from"./chunk-V3BE427M.js";import"./chunk-CKEQX655.js";import"./chunk-UD5REVU2.js";import{a as De}from"./chunk-RCXNYW7P.js";import{b as D}from"./chunk-UQA2AJGI.js";import"./chunk-T3ZCW3RG.js";import{a as ze,b as _e,c as Pe,d as q,e as U,f as z}from"./chunk-7QEZ2SFW.js";import{b as Ve}from"./chunk-4N76XUNG.js";import{a as X,e as Z}from"./chunk-OK2QU2EV.js";import{m as K}from"./chunk-SHHGIT7M.js";import"./chunk-ZPQBVYNN.js";import{B as Q,j as Ee,r as Ue,s as J,u as Qe,w as te}from"./chunk-GNI37YCV.js";import"./chunk-PDBW6GTJ.js";import{a as lt}from"./chunk-GWNGVKLG.js";import{a as at,b as nt}from"./chunk-6G3E4PJ2.js";import{a as s,d as Me}from"./chunk-5PEAXTYQ.js";var C=Me(at(),1);var W=Me(lt(),1);var t=Me(nt(),1);var it=s(()=>{let h=(0,W.c)(3),{config:e,ready:n}=qe(),l;return h[0]!==e.capabilities||h[1]!==n?(l={capabilities:e.capabilities,ready:n},h[0]=e.capabilities,h[1]=n,h[2]=l):l=h[2],l},"nt"),st=s((h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending","lt"),et=500,rt=s((h,e)=>{if(!URL.canParse(h.trim()))return null;let n=new URL(h.trim());return n.searchParams.set("email",e.email),n.searchParams.set("invite",e.token),n.toString()},"at"),dt=s(h=>{let e=(0,W.c)(34),{issued:n,onSignUpPageChange:l,signUpPage:o}=h,a=Q(),[p,i]=(0,C.useState)(null),u;e[0]!==n||e[1]!==o?(u=rt(o,n),e[0]=n,e[1]=o,e[2]=u):u=e[2];let c=u,y;e[3]!==c?(y=s(()=>{let $="navigator"in globalThis?globalThis.navigator.clipboard:void 0;c===null||$===void 0||J($.writeText(c).then(()=>(i(c),!0)))},"y"),e[3]=c,e[4]=y):y=e[4];let w=y,g;e[5]!==a?(g=a("Send this link to the invitee. It is shown once and cannot be recovered."),e[5]=a,e[6]=g):g=e[6];let I;e[7]!==g?(I=(0,t.jsx)("p",{className:"text-sm",children:g}),e[7]=g,e[8]=I):I=e[8];let k=c===null,v;e[9]!==a?(v=a("Your app's sign-up page"),e[9]=a,e[10]=v):v=e[10];let d;e[11]!==l?(d=s($=>{l($.target.value)},"r"),e[11]=l,e[12]=d):d=e[12];let m;e[13]!==o||e[14]!==k||e[15]!==v||e[16]!==d?(m=(0,t.jsx)(T,{"aria-invalid":k,"aria-label":v,"data-testid":"sign-up-invitation-page",onChange:d,value:o}),e[13]=o,e[14]=k,e[15]=v,e[16]=d,e[17]=m):m=e[17];let b=c??"",x;e[18]!==b?(x=(0,t.jsx)(T,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:b}),e[18]=b,e[19]=x):x=e[19];let N;e[20]!==p||e[21]!==c||e[22]!==a?(N=a(p!==null&&p===c?"Copied":"Copy"),e[20]=p,e[21]=c,e[22]=a,e[23]=N):N=e[23];let f;e[24]!==w||e[25]!==N?(f=(0,t.jsx)(_,{"data-testid":"sign-up-invitation-copy",onClick:w,type:"button",children:N}),e[24]=w,e[25]=N,e[26]=f):f=e[26];let r;e[27]!==x||e[28]!==f?(r=(0,t.jsxs)("div",{className:"flex gap-2",children:[x,f]}),e[27]=x,e[28]=f,e[29]=r):r=e[29];let A;return e[30]!==r||e[31]!==I||e[32]!==m?(A=(0,t.jsx)(X,{children:(0,t.jsxs)(Z,{className:"flex flex-col gap-2 p-4",children:[I,m,r]})}),e[30]=r,e[31]=I,e[32]=m,e[33]=A):A=e[33],A},"it"),ot=s(()=>{let h=K(),e=Q(),[n,l]=(0,C.useState)(""),[o,a]=(0,C.useState)(null),[p,i]=(0,C.useState)(null),[u,c]=(0,C.useState)(()=>`${Qe(h.url)}/sign-up`),y=Ve(["lunora-auth-sign-up-invitations",et],()=>h.listAuthSignUpInvitations({limit:et})),w=y.data?.rows??null,g=y.data?.total??0,I=s(()=>{let v=n.trim();v!==""&&(a(null),J((async()=>{try{let d=await h.createAuthSignUpInvitation({email:v}),m=typeof d.token=="string"?d.token:void 0;i(m===void 0?null:{email:v,token:m}),l(""),y.refetch()}catch(d){a(d instanceof Error?d.message:String(d))}})()))},"w"),k=s(v=>{a(null),J((async()=>{try{await h.revokeAuthSignUpInvitation({email:v}),y.refetch()}catch(d){a(d instanceof Error?d.message:String(d))}})())},"k");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"sign-up-invitations",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-base font-medium",children:e("Sign-up invitations")}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("Only invited addresses can create an account. Nothing is emailed \u2014 send the invitee the one-time link yourself.")})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(T,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:s(v=>{l(v.target.value)},"onChange"),placeholder:e("ada@example.com"),type:"email",value:n}),(0,t.jsx)(_,{"data-testid":"sign-up-invitation-submit",onClick:I,type:"button",children:e("Invite")})]}),p!==null&&(0,t.jsx)(dt,{issued:p,onSignUpPageChange:c,signUpPage:u},p.token),(o??y.error)!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:o??y.error}),w!==null&&w.length===0&&(0,t.jsx)(De,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),w!==null&&g>w.length&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sign-up-invitations-truncated",children:e("Showing the most recent invitations. Query the signUpInvitation table directly to see the rest.")}),w!==null&&w.length>0&&(0,t.jsx)(X,{children:(0,t.jsx)(Z,{className:"p-0",children:(0,t.jsxs)(ze,{children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:e("Email")}),(0,t.jsx)(U,{children:e("Status")}),(0,t.jsx)(U,{children:e("Expires")}),(0,t.jsx)(U,{children:e("Invited by")}),(0,t.jsx)(U,{})]})}),(0,t.jsx)(Pe,{children:w.map(v=>{let d=st(v,Date.now()),m=v.email??"";return(0,t.jsxs)(q,{"data-testid":`sign-up-invitation-${m}`,children:[(0,t.jsx)(z,{children:m}),(0,t.jsxs)(z,{"data-testid":`sign-up-invitation-status-${m}`,children:[d==="spent"&&e("Accepted"),d==="expired"&&e("Expired"),d==="pending"&&e("Pending")]}),(0,t.jsx)(z,{children:typeof v.expiresAt=="number"?te(v.expiresAt):"\u2014"}),(0,t.jsx)(z,{children:v.invitedBy??"\u2014"}),(0,t.jsx)(z,{className:"text-right",children:(0,t.jsx)(_,{onClick:s(()=>{k(m)},"onClick"),type:"button",variant:"ghost",children:e("Revoke")})})]},v.id)})})]})})})]})},"rt"),ct={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},ut=s((h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),"dt"),mt=s((h,e)=>{if(h.type==="boolean")return e===!0?{value:!0}:h.required?{value:!1}:void 0;let n=typeof e=="string"?e.trim():"";if(n!==""){if(h.type==="number"){let l=Number(n);return Number.isNaN(l)?void 0:{value:l}}return{value:n}}},"ct"),ht=s(h=>{let e=(0,W.c)(105),{onClose:n,onCreated:l}=h,o=K(),a=Q(),{config:p}=qe(),{busy:i,error:u,run:c}=Ke(),[y,w]=(0,C.useState)(""),[g,I]=(0,C.useState)(""),[k,v]=(0,C.useState)(""),[d,m]=(0,C.useState)(""),b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];let[x,N]=(0,C.useState)(b),f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=s(S=>{w(S.target.value)},"p"),e[1]=f):f=e[1];let r=f,A;e[2]===Symbol.for("react.memo_cache_sentinel")?(A=s(S=>{I(S.target.value)},"S"),e[2]=A):A=e[2];let $=A,j;e[3]===Symbol.for("react.memo_cache_sentinel")?(j=s(S=>{v(S.target.value)},"z"),e[3]=j):j=e[3];let H=j,M;e[4]===Symbol.for("react.memo_cache_sentinel")?(M=s(S=>{m(S.target.value)},"M"),e[4]=M):M=e[4];let Y=M,B;e[5]===Symbol.for("react.memo_cache_sentinel")?(B=s((S,R)=>{N(ee=>({...ee,[S]:R}))},"L"),e[5]=B):B=e[5];let V=B,G;e[6]!==x?(G=s(S=>x[S.name]??(S.type==="boolean"?!1:""),"Y"),e[6]=x,e[7]=G):G=e[7];let P=G,O;if(e[8]!==p.userFields||e[9]!==P){let S;e[11]!==P?(S=s(R=>!R.required||ut(R,P(R)),"A"),e[11]=P,e[12]=S):S=e[12],O=p.userFields.every(S),e[8]=p.userFields,e[9]=P,e[10]=O}else O=e[10];let F=O,E;e[13]!==i||e[14]!==y||e[15]!==g||e[16]!==F?(E=!i&&y.trim()!==""&&g.trim()!==""&&F,e[13]=i,e[14]=y,e[15]=g,e[16]=F,e[17]=E):E=e[17];let $e=E,ae;e[18]!==p.userFields||e[19]!==P?(ae=s(()=>{let S={};for(let R of p.userFields){let ee=mt(R,P(R));ee!==void 0&&(S[R.name]=ee.value)}return Object.keys(S).length===0?void 0:S},"te"),e[18]=p.userFields,e[19]=P,e[20]=ae):ae=e[20];let je=ae,Re;e[21]!==je||e[22]!==o||e[23]!==y||e[24]!==g||e[25]!==n||e[26]!==l||e[27]!==k||e[28]!==d||e[29]!==c?(Re=s(()=>{c(async()=>{await o.createAuthUser({data:je(),email:y.trim(),name:g.trim(),password:k===""?void 0:k,role:d.trim()===""?void 0:d.trim()}),l(),n()})},"De"),e[21]=je,e[22]=o,e[23]=y,e[24]=g,e[25]=n,e[26]=l,e[27]=k,e[28]=d,e[29]=c,e[30]=Re):Re=e[30];let Be=Re,le;e[31]!==a?(le=a("Create user"),e[31]=a,e[32]=le):le=e[32];let ne;e[33]!==a?(ne=a("Create user"),e[33]=a,e[34]=ne):ne=e[34];let ie;e[35]!==ne?(ie=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:ne}),e[35]=ne,e[36]=ie):ie=e[36];let se;e[37]!==a?(se=a("email"),e[37]=a,e[38]=se):se=e[38];let re;e[39]!==se?(re=(0,t.jsx)(L,{htmlFor:"uc-email",children:se}),e[39]=se,e[40]=re):re=e[40];let de;e[41]!==y?(de=(0,t.jsx)(T,{"data-testid":"uc-email",id:"uc-email",onChange:r,type:"email",value:y}),e[41]=y,e[42]=de):de=e[42];let oe;e[43]!==re||e[44]!==de?(oe=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[re,de]}),e[43]=re,e[44]=de,e[45]=oe):oe=e[45];let ce;e[46]!==a?(ce=a("name"),e[46]=a,e[47]=ce):ce=e[47];let ue;e[48]!==ce?(ue=(0,t.jsx)(L,{htmlFor:"uc-name",children:ce}),e[48]=ce,e[49]=ue):ue=e[49];let me;e[50]!==g?(me=(0,t.jsx)(T,{"data-testid":"uc-name",id:"uc-name",onChange:$,value:g}),e[50]=g,e[51]=me):me=e[51];let he;e[52]!==ue||e[53]!==me?(he=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[ue,me]}),e[52]=ue,e[53]=me,e[54]=he):he=e[54];let pe;e[55]!==a?(pe=a("Password (optional)"),e[55]=a,e[56]=pe):pe=e[56];let fe;e[57]!==pe?(fe=(0,t.jsx)(L,{htmlFor:"uc-password",children:pe}),e[57]=pe,e[58]=fe):fe=e[58];let ve;e[59]!==k?(ve=(0,t.jsx)(T,{"data-testid":"uc-password",id:"uc-password",onChange:H,type:"password",value:k}),e[59]=k,e[60]=ve):ve=e[60];let ge;e[61]!==fe||e[62]!==ve?(ge=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[fe,ve]}),e[61]=fe,e[62]=ve,e[63]=ge):ge=e[63];let be;e[64]!==a?(be=a("Role (optional)"),e[64]=a,e[65]=be):be=e[65];let xe;e[66]!==be?(xe=(0,t.jsx)(L,{htmlFor:"uc-role",children:be}),e[66]=be,e[67]=xe):xe=e[67];let ye;e[68]!==d?(ye=(0,t.jsx)(T,{"data-testid":"uc-role",id:"uc-role",onChange:Y,value:d}),e[68]=d,e[69]=ye):ye=e[69];let Ne;e[70]!==xe||e[71]!==ye?(Ne=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[xe,ye]}),e[70]=xe,e[71]=ye,e[72]=Ne):Ne=e[72];let ke;e[73]!==p.userFields||e[74]!==P||e[75]!==a?(ke=p.userFields.length>0&&(0,t.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Plugin fields")}),p.userFields.map(S=>{let R=`uc-field-${S.name}`,ee=S.required?"":` (${a("optional")})`;if(S.type==="boolean"){let Le=P(S)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:R,children:[(0,t.jsx)(Ze,{checked:Le,"data-testid":R,id:R,onCheckedChange:s(tt=>{V(S.name,tt)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[S.name,ee]})]},S.name)}let Ge=P(S);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(L,{htmlFor:R,children:[S.name,ee]}),(0,t.jsx)(T,{"data-testid":R,id:R,onChange:s(Le=>{V(S.name,Le.target.value)},"onChange"),type:ct[S.type],value:typeof Ge=="string"?Ge:""})]},S.name)})]}),e[73]=p.userFields,e[74]=P,e[75]=a,e[76]=ke):ke=e[76];let we;e[77]!==u?(we=u!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:u}),e[77]=u,e[78]=we):we=e[78];let Ce;e[79]!==a?(Ce=a("Cancel"),e[79]=a,e[80]=Ce):Ce=e[80];let Ie;e[81]!==n||e[82]!==Ce?(Ie=(0,t.jsx)(_,{"data-testid":"uc-cancel",onClick:n,size:"sm",type:"button",variant:"outline",children:Ce}),e[81]=n,e[82]=Ce,e[83]=Ie):Ie=e[83];let Oe=!$e,Se;e[84]!==i||e[85]!==a?(Se=a(i?"Creating\u2026":"Create"),e[84]=i,e[85]=a,e[86]=Se):Se=e[86];let Ae;e[87]!==Be||e[88]!==Oe||e[89]!==Se?(Ae=(0,t.jsx)(_,{"data-testid":"uc-submit",disabled:Oe,onClick:Be,size:"sm",type:"button",children:Se}),e[87]=Be,e[88]=Oe,e[89]=Se,e[90]=Ae):Ae=e[90];let Fe;e[91]!==Ie||e[92]!==Ae?(Fe=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[Ie,Ae]}),e[91]=Ie,e[92]=Ae,e[93]=Fe):Fe=e[93];let Te;return e[94]!==n||e[95]!==le||e[96]!==ie||e[97]!==oe||e[98]!==he||e[99]!==ge||e[100]!==Ne||e[101]!==ke||e[102]!==we||e[103]!==Fe?(Te=(0,t.jsxs)(He,{label:le,onClose:n,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[ie,oe,he,ge,Ne,ke,we,Fe]}),e[94]=n,e[95]=le,e[96]=ie,e[97]=oe,e[98]=he,e[99]=ge,e[100]=Ne,e[101]=ke,e[102]=we,e[103]=Fe,e[104]=Te):Te=e[104],Te},"ut"),Ye=s(h=>{let e=(0,W.c)(2),{children:n}=h,l;return e[0]!==n?(l=(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n}),e[0]=n,e[1]=l):l=e[1],l},"_e"),pt=s(h=>{let e=(0,W.c)(29),{busy:n,runAction:l,userId:o,version:a}=h,p=K(),i=Q(),[u,c]=(0,C.useState)(null),[y,w]=(0,C.useState)(null),g;e[0]!==p||e[1]!==o?(g=s(()=>{J((async()=>{w(null);try{let r=await p.listAuthSessions({limit:50,userId:o});c(r.rows)}catch(r){let A=r;c(null),w(Ee(A))}})())},"g"),e[0]=p,e[1]=o,e[2]=g):g=e[2];let I;e[3]!==p||e[4]!==o||e[5]!==a?(I=[p,o,a],e[3]=p,e[4]=o,e[5]=a,e[6]=I):I=e[6],(0,C.useEffect)(g,I);let k;e[7]!==p||e[8]!==l?(k=s(r=>{l(()=>p.revokeAuthSession({sessionId:r}))},"k"),e[7]=p,e[8]=l,e[9]=k):k=e[9];let v=k,d;e[10]!==i?(d=i("Sessions"),e[10]=i,e[11]=d):d=e[11];let m;e[12]!==d?(m=(0,t.jsx)(Ye,{children:d}),e[12]=d,e[13]=m):m=e[13];let b;e[14]!==y?(b=y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:y}),e[14]=y,e[15]=b):b=e[15];let x;e[16]!==u||e[17]!==i?(x=u!==null&&u.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:i("No active sessions.")}),e[16]=u,e[17]=i,e[18]=x):x=e[18];let N;e[19]!==n||e[20]!==v||e[21]!==u||e[22]!==i?(N=u!==null&&u.length>0&&(0,t.jsx)(X,{className:"overflow-hidden py-0",children:(0,t.jsx)(Z,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:i("expires")}),(0,t.jsx)(U,{children:i("ip")}),(0,t.jsx)(U,{children:i("user agent")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Pe,{children:u.map(r=>(0,t.jsxs)(q,{"data-testid":`ud-session-${r.id}`,children:[(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.expiresAt)}),(0,t.jsx)(z,{children:r.ipAddress??""}),(0,t.jsx)(z,{className:"max-w-40 truncate",children:r.userAgent??""}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-revoke-${r.id}`,disabled:n,onClick:s(()=>{v(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Revoke")})})]},r.id))})]})})}),e[19]=n,e[20]=v,e[21]=u,e[22]=i,e[23]=N):N=e[23];let f;return e[24]!==m||e[25]!==b||e[26]!==x||e[27]!==N?(f=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[m,b,x,N]}),e[24]=m,e[25]=b,e[26]=x,e[27]=N,e[28]=f):f=e[28],f},"mt"),ft=s(h=>{let e=(0,W.c)(30),{busy:n,runAction:l,userId:o,version:a}=h,p=K(),i=Q(),[u,c]=(0,C.useState)(null),[y,w]=(0,C.useState)(null),g;e[0]!==p||e[1]!==o?(g=s(()=>{J((async()=>{w(null);try{c(await p.listAuthAccounts({userId:o}))}catch(r){let A=r;c(null),w(Ee(A))}})())},"g"),e[0]=p,e[1]=o,e[2]=g):g=e[2];let I;e[3]!==p||e[4]!==o||e[5]!==a?(I=[p,o,a],e[3]=p,e[4]=o,e[5]=a,e[6]=I):I=e[6],(0,C.useEffect)(g,I);let k;e[7]!==p||e[8]!==l||e[9]!==o?(k=s(r=>{l(()=>p.unlinkAuthAccount({accountId:r,userId:o}))},"k"),e[7]=p,e[8]=l,e[9]=o,e[10]=k):k=e[10];let v=k,d;e[11]!==i?(d=i("Linked accounts"),e[11]=i,e[12]=d):d=e[12];let m;e[13]!==d?(m=(0,t.jsx)(Ye,{children:d}),e[13]=d,e[14]=m):m=e[14];let b;e[15]!==y?(b=y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:y}),e[15]=y,e[16]=b):b=e[16];let x;e[17]!==u||e[18]!==i?(x=u!==null&&u.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:i("No linked accounts.")}),e[17]=u,e[18]=i,e[19]=x):x=e[19];let N;e[20]!==u||e[21]!==n||e[22]!==v||e[23]!==i?(N=u!==null&&u.length>0&&(0,t.jsx)(X,{className:"overflow-hidden py-0",children:(0,t.jsx)(Z,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:i("provider")}),(0,t.jsx)(U,{children:i("created")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Pe,{children:u.map(r=>{let A=Ue(r.id);return(0,t.jsxs)(q,{"data-testid":`ud-account-${A}`,children:[(0,t.jsx)(z,{children:Ue(r.providerId)}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-unlink-${A}`,disabled:n,onClick:s(()=>{v(A)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Unlink")})})]},A)})})]})})}),e[20]=u,e[21]=n,e[22]=v,e[23]=i,e[24]=N):N=e[24];let f;return e[25]!==m||e[26]!==b||e[27]!==x||e[28]!==N?(f=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[m,b,x,N]}),e[25]=m,e[26]=b,e[27]=x,e[28]=N,e[29]=f):f=e[29],f},"ht"),vt=s(h=>{let e=(0,W.c)(40),{busy:n,capabilities:l,runAction:o,userId:a,version:p}=h,i=K(),u=Q(),[c,y]=(0,C.useState)(null),w;e[0]!==l.passkey||e[1]!==i||e[2]!==a?(w=s(()=>{l.passkey&&J((async()=>{try{y(await i.listAuthPasskeys({userId:a}))}catch{y(null)}})())},"C"),e[0]=l.passkey,e[1]=i,e[2]=a,e[3]=w):w=e[3];let g;e[4]!==l.passkey||e[5]!==i||e[6]!==a||e[7]!==p?(g=[l.passkey,i,a,p],e[4]=l.passkey,e[5]=i,e[6]=a,e[7]=p,e[8]=g):g=e[8],(0,C.useEffect)(w,g);let I;e[9]!==i||e[10]!==o||e[11]!==a?(I=s(()=>{o(()=>i.disableAuthTwoFactor({userId:a}))},"w"),e[9]=i,e[10]=o,e[11]=a,e[12]=I):I=e[12];let k=I,v;e[13]!==i||e[14]!==o?(v=s(A=>{o(()=>i.deleteAuthPasskey({passkeyId:A}))},"v"),e[13]=i,e[14]=o,e[15]=v):v=e[15];let d=v,m;e[16]!==u?(m=u("Security"),e[16]=u,e[17]=m):m=e[17];let b;e[18]!==m?(b=(0,t.jsx)(Ye,{children:m}),e[18]=m,e[19]=b):b=e[19];let x;e[20]!==n||e[21]!==l.twoFactor||e[22]!==k||e[23]!==u?(x=l.twoFactor&&(0,t.jsx)(_,{"data-testid":"ud-disable-2fa",disabled:n,onClick:k,size:"sm",type:"button",variant:"outline",children:u("Disable two-factor")}),e[20]=n,e[21]=l.twoFactor,e[22]=k,e[23]=u,e[24]=x):x=e[24];let N;e[25]!==l.passkey||e[26]!==c||e[27]!==u?(N=l.passkey&&c!==null&&c.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:u("No passkeys.")}),e[25]=l.passkey,e[26]=c,e[27]=u,e[28]=N):N=e[28];let f;e[29]!==n||e[30]!==l.passkey||e[31]!==d||e[32]!==c||e[33]!==u?(f=l.passkey&&c!==null&&c.length>0&&(0,t.jsx)(X,{className:"overflow-hidden py-0",children:(0,t.jsx)(Z,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-passkeys-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:u("name")}),(0,t.jsx)(U,{children:u("created")}),(0,t.jsx)(U,{"aria-label":u("Actions")})]})}),(0,t.jsx)(Pe,{children:c.map(A=>{let $=Ue(A.id);return(0,t.jsxs)(q,{"data-testid":`ud-passkey-${$}`,children:[(0,t.jsx)(z,{children:Ue(A.name)||$}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(A.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-delete-passkey-${$}`,disabled:n,onClick:s(()=>{d($)},"onClick"),size:"xs",type:"button",variant:"ghost",children:u("Delete")})})]},$)})})]})})}),e[29]=n,e[30]=l.passkey,e[31]=d,e[32]=c,e[33]=u,e[34]=f):f=e[34];let r;return e[35]!==b||e[36]!==x||e[37]!==N||e[38]!==f?(r=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[b,x,N,f]}),e[35]=b,e[36]=x,e[37]=N,e[38]=f,e[39]=r):r=e[39],r},"ft"),gt=/(?:at|expires)$/iu,bt=/^[1-9]\d*$/u,xt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),yt=s(h=>{let e=(0,W.c)(51),{busy:n,onBan:l}=h,o=Q(),[a,p]=(0,C.useState)(""),[i,u]=(0,C.useState)(""),[c,y]=(0,C.useState)(!1),w;e[0]!==i?(w=bt.test(i.trim())&&Number.isSafeInteger(Number(i.trim())*86400)?Number(i.trim()):void 0,e[0]=i,e[1]=w):w=e[1];let g=w,I=c||g!==void 0,k;e[2]!==l||e[3]!==c||e[4]!==a||e[5]!==g?(k=s(()=>{l({expiresInSeconds:c||g===void 0?void 0:g*86400,reason:a.trim()===""?void 0:a.trim()})},"k"),e[2]=l,e[3]=c,e[4]=a,e[5]=g,e[6]=k):k=e[6];let v=k,d;e[7]!==o?(d=o("Ban reason (optional)"),e[7]=o,e[8]=d):d=e[8];let m;e[9]!==d?(m=(0,t.jsx)(L,{htmlFor:"ud-ban-reason",children:d}),e[9]=d,e[10]=m):m=e[10];let b;e[11]===Symbol.for("react.memo_cache_sentinel")?(b=s(E=>{p(E.target.value)},"b"),e[11]=b):b=e[11];let x;e[12]!==a?(x=(0,t.jsx)(T,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:b,value:a}),e[12]=a,e[13]=x):x=e[13];let N;e[14]!==m||e[15]!==x?(N=(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[m,x]}),e[14]=m,e[15]=x,e[16]=N):N=e[16];let f;e[17]!==o?(f=o("Days"),e[17]=o,e[18]=f):f=e[18];let r;e[19]!==f?(r=(0,t.jsx)(L,{htmlFor:"ud-ban-days",children:f}),e[19]=f,e[20]=r):r=e[20];let A;e[21]!==i||e[22]!==g?(A=i.trim()!==""&&g===void 0,e[21]=i,e[22]=g,e[23]=A):A=e[23];let $;e[24]===Symbol.for("react.memo_cache_sentinel")?($=s(E=>{u(E.target.value)},"T"),e[24]=$):$=e[24];let j;e[25]!==i||e[26]!==c||e[27]!==A?(j=(0,t.jsx)(T,{"aria-invalid":A,"data-testid":"ud-ban-days",disabled:c,id:"ud-ban-days",min:1,onChange:$,step:1,type:"number",value:i}),e[25]=i,e[26]=c,e[27]=A,e[28]=j):j=e[28];let H;e[29]!==j||e[30]!==r?(H=(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[r,j]}),e[29]=j,e[30]=r,e[31]=H):H=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=s(E=>{y(E.target.checked)},"M"),e[32]=M):M=e[32];let Y;e[33]!==c?(Y=(0,t.jsx)("input",{checked:c,className:"size-4 accent-destructive","data-testid":"ud-ban-permanent",id:"ud-ban-permanent",onChange:M,type:"checkbox"}),e[33]=c,e[34]=Y):Y=e[34];let B;e[35]!==o?(B=o("Permanent"),e[35]=o,e[36]=B):B=e[36];let V;e[37]!==Y||e[38]!==B?(V=(0,t.jsxs)(L,{className:"flex items-center gap-1.5 pb-2 text-xs font-normal",htmlFor:"ud-ban-permanent",children:[Y,B]}),e[37]=Y,e[38]=B,e[39]=V):V=e[39];let G=n||!I,P;e[40]!==o?(P=o("Ban user"),e[40]=o,e[41]=P):P=e[41];let O;e[42]!==v||e[43]!==G||e[44]!==P?(O=(0,t.jsx)(_,{"data-testid":"ud-ban",disabled:G,onClick:v,size:"sm",type:"button",variant:"destructive",children:P}),e[42]=v,e[43]=G,e[44]=P,e[45]=O):O=e[45];let F;return e[46]!==H||e[47]!==V||e[48]!==O||e[49]!==N?(F=(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[N,H,V,O]}),e[46]=H,e[47]=V,e[48]=O,e[49]=N,e[50]=F):F=e[50],F},"bt"),Nt=s((h,e)=>typeof e=="number"&>.test(h)?te(e):Ue(e),"xt"),kt=s(({capabilities:h,onChanged:e,onClose:n,user:l})=>{let o=K(),a=Q(),p=l.banned===!0,[i,u]=(0,C.useState)(null),[c,y]=(0,C.useState)(!1),[w,g]=(0,C.useState)(0),[I,k]=(0,C.useState)(typeof l.role=="string"?l.role:""),[v,d]=(0,C.useState)(""),[m,b]=(0,C.useState)(null),[x,N]=(0,C.useState)(!1),f=s((F,E)=>{J((async()=>{y(!0),u(null);try{let $e=await F();E?.refresh!==!1&&(g(ae=>ae+1),e()),E?.onResult?.($e)}catch($e){u(Ee($e))}y(!1)})())},"p"),r=s(F=>{k(F.target.value)},"i"),A=s(F=>{d(F.target.value)},"S"),$=s(()=>{let F=I.trim();F!==""&&f(async()=>{await o.setAuthUserRole({role:F,userId:l.id})})},"T"),j=s(F=>{f(async()=>{await o.banAuthUser({...F,userId:l.id})})},"z"),H=s(()=>{f(async()=>{await o.unbanAuthUser({userId:l.id})})},"j"),M=s(()=>{f(async()=>{await o.setAuthUserPassword({newPassword:v,userId:l.id}),d("")})},"M"),Y=s(()=>{f(()=>o.impersonateAuthUser({userId:l.id}),{onResult:s(F=>{b(F.token)},"onResult"),refresh:!1})},"H"),B=s(()=>{f(async()=>{await o.revokeAuthUserSessions({userId:l.id})})},"L"),V=s(()=>{f(async()=>{await o.removeAuthUser({userId:l.id}),n()})},"V"),G=s(()=>{N(!0)},"Y"),P=s(()=>{N(!1)},"E"),O=Object.entries(l).filter(([F])=>!xt.has(F));return(0,t.jsxs)(He,{label:a("User details"),onClose:n,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:l.name??l.email??l.id}),(0,t.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:l.id}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof l.role=="string"&&l.role!==""&&(0,t.jsx)(D,{variant:"secondary",children:l.role}),p?(0,t.jsx)(D,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(D,{variant:"outline",children:a("Active")}),l.emailVerified===!0?(0,t.jsx)(D,{variant:"secondary",children:a("verified")}):(0,t.jsx)(D,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(_,{"data-testid":"ud-close",onClick:n,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),i!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:i}),h.admin&&(0,t.jsxs)(X,{className:"gap-0 py-0",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Actions")})}),(0,t.jsxs)(Z,{className:"flex flex-col gap-3 p-3",children:[(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(L,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(T,{"data-testid":"ud-role-input",id:"ud-role",onChange:r,value:I})]}),(0,t.jsx)(_,{"data-testid":"ud-set-role",disabled:c||I.trim()==="",onClick:$,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),p?(0,t.jsx)(_,{"data-testid":"ud-unban",disabled:c,onClick:H,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(0,t.jsx)(yt,{busy:c,onBan:j}),(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(L,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(T,{"data-testid":"ud-password",id:"ud-password",onChange:A,type:"password",value:v})]}),(0,t.jsx)(_,{"data-testid":"ud-set-password",disabled:c||v==="",onClick:M,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(_,{"data-testid":"ud-impersonate",disabled:c,onClick:Y,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(_,{"data-testid":"ud-revoke-all",disabled:c,onClick:B,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),x?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(_,{"data-testid":"ud-delete-confirm",disabled:c,onClick:V,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(_,{"data-testid":"ud-delete-cancel",onClick:P,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(_,{"data-testid":"ud-delete",disabled:c,onClick:G,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),m!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(L,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(T,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:m})]})]})]}),(0,t.jsx)(pt,{busy:c,runAction:f,userId:l.id,version:w}),h.accounts&&(0,t.jsx)(ft,{busy:c,runAction:f,userId:l.id,version:w}),(h.twoFactor||h.passkey)&&(0,t.jsx)(vt,{busy:c,capabilities:h,runAction:f,userId:l.id,version:w}),(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Fields")}),(0,t.jsx)("dl",{className:"flex flex-col",children:O.map(([F,E])=>(0,t.jsxs)("div",{className:"flex flex-col border-t border-border py-1.5",children:[(0,t.jsx)("dt",{className:"text-xs font-semibold text-muted-foreground",children:F}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:Nt(F,E)})]},F))})]})]})},"yt"),wt=50,Vt=s(({pageSize:h=wt}={})=>{let e=K(),n=Q(),[l,o]=(0,C.useState)(""),[a,p]=(0,C.useState)(""),[i,u]=(0,C.useState)(0),c=Xe(l),[y,w]=(0,C.useState)(null),[g,I]=(0,C.useState)(!1),{capabilities:k}=it(),v=c.trim(),d=a.trim(),m=Ve(["lunora-auth-users",v,d,h,i],()=>e.listAuthUsers({filterField:d===""?void 0:"role",filterValue:d===""?void 0:d,limit:h,offset:i,search:v===""?void 0:v}).then(r=>({...r,offset:i})),{keepPreviousData:!0}),b=m.data?.rows??null,x=m.error,N=s(()=>{m.refetch()},"N");We(()=>m.poll(),!0);let f=y===null?null:b?.find(r=>r.id===y)??null;return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(T,{"aria-label":n("Search users"),className:"w-56","data-testid":"us-search",onChange:s(r=>{o(r.target.value),u(0)},"onChange"),placeholder:n("Search by email or name\u2026"),value:l}),(0,t.jsx)(T,{"aria-label":n("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:s(r=>{p(r.target.value),u(0)},"onChange"),placeholder:n("Filter by role"),value:a}),(0,t.jsx)(_,{"data-testid":"us-new",onClick:s(()=>{I(!0)},"onClick"),size:"sm",type:"button",children:n("New user")})]}),x!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:x}),b!==null&&b.length===0&&(0,t.jsx)(De,{description:n("Users who sign up to your app will appear here."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:n("No users.")}),b!==null&&b.length>0&&(0,t.jsx)(X,{className:"overflow-hidden py-0",children:(0,t.jsx)(Z,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"us-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:n("id")}),(0,t.jsx)(U,{children:n("email")}),(0,t.jsx)(U,{children:n("name")}),(0,t.jsx)(U,{children:n("role")}),(0,t.jsx)(U,{children:n("status")}),(0,t.jsx)(U,{children:n("verified")}),(0,t.jsx)(U,{children:n("created")}),(0,t.jsx)(U,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Pe,{children:b.map(r=>(0,t.jsxs)(q,{"data-testid":`us-row-${r.id}`,children:[(0,t.jsx)(z,{className:"font-mono text-xs",children:r.id}),(0,t.jsx)(z,{children:r.email??""}),(0,t.jsx)(z,{children:r.name??""}),(0,t.jsx)(z,{children:typeof r.role=="string"&&r.role!==""?(0,t.jsx)(D,{variant:"secondary",children:r.role}):""}),(0,t.jsx)(z,{children:r.banned===!0?(0,t.jsx)(D,{variant:"destructive",children:n("Banned")}):(0,t.jsx)(D,{variant:"success",children:n("Active")})}),(0,t.jsx)(z,{children:r.emailVerified===!0?(0,t.jsx)(D,{variant:"success",children:n("yes")}):(0,t.jsx)(D,{variant:"outline",children:n("no")})}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`us-manage-${r.id}`,onClick:s(()=>{w(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Manage")})})]},r.id))})]})})}),b!==null&&(0,t.jsx)(Je,{count:b.length,offset:m.data?.offset??0,onOffsetChange:u,pageSize:h,prefix:"us",total:m.data?.total}),f!==null&&(0,t.jsx)(kt,{capabilities:k,onChanged:N,onClose:s(()=>{w(null)},"onClose"),user:f}),g&&(0,t.jsx)(ht,{onClose:s(()=>{I(!1)},"onClose"),onCreated:N}),k.inviteOnly&&(0,t.jsx)(ot,{})]})},"jt");export{Vt as UsersPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as v}from"./chunk-RCXNYW7P.js";import{b as w}from"./chunk-UQA2AJGI.js";import"./chunk-T3ZCW3RG.js";import{a as R}from"./chunk-
|
|
1
|
+
import{a as v}from"./chunk-RCXNYW7P.js";import{b as w}from"./chunk-UQA2AJGI.js";import"./chunk-T3ZCW3RG.js";import{a as R}from"./chunk-YEXTJUKQ.js";import"./chunk-LSEUUZN4.js";import{a as A,b as C,c as I,d as x,e as c,f as n}from"./chunk-7QEZ2SFW.js";import"./chunk-OZAOWE7T.js";import"./chunk-BBDTJG2K.js";import"./chunk-4PI2OSSP.js";import{a as y}from"./chunk-2W4UO5BC.js";import{c as N}from"./chunk-4N76XUNG.js";import{a as S,e as $}from"./chunk-OK2QU2EV.js";import"./chunk-SHHGIT7M.js";import"./chunk-ZPQBVYNN.js";import{B as k}from"./chunk-GNI37YCV.js";import"./chunk-PDBW6GTJ.js";import{a as E}from"./chunk-GWNGVKLG.js";import{b as O}from"./chunk-6G3E4PJ2.js";import{a as f,d as b}from"./chunk-5PEAXTYQ.js";var j=b(E(),1);var r=b(O(),1);var _=f((e,t)=>({delete:e("Delete"),list:e("List"),read:e("Read"),write:e("Write")})[t],"I"),T={delete:2,list:3,read:0,write:1},B=f(e=>[...e].toSorted((t,a)=>t.bucket.localeCompare(a.bucket)||T[t.on]-T[a.on]||(t.prefix??"").localeCompare(a.prefix??"")),"O"),q=f(()=>{let e=(0,j.c)(14),t=k(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let{data:l,error:i,errorSource:d}=N(y.storageRules,a),h=l!==void 0,m;if(e[1]!==l||e[2]!==i||e[3]!==d||e[4]!==h||e[5]!==t){let g=B(Array.isArray(l?.rules)?l.rules:[]),u;e[7]!==i||e[8]!==d?(u=i!==null&&(0,r.jsx)(R,{error:d,testId:"storage-rules-error"}),e[7]=i,e[8]=d,e[9]=u):u=e[9];let o;e[10]!==t?(o=t("Storage rules are declared in code with defineStorageRule and gate ctx.storage access per bucket. This view is read-only."),e[10]=t,e[11]=o):o=e[11];let p;e[12]!==o?(p=(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"storage-rules-note",children:o}),e[12]=o,e[13]=p):p=e[13],m=(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-storage-rules-panel",children:[u,p,h&&g.length===0?(0,r.jsx)(v,{description:t("No defineStorageRule is wired through .use(storageRules(...)) in this deployment. Add one to gate object access by key prefix."),testId:"storage-rules-empty",title:t("No storage rules defined")}):(0,r.jsx)(S,{className:"overflow-hidden py-0",children:(0,r.jsx)($,{className:"px-0",children:(0,r.jsxs)(A,{"data-testid":"storage-rules-table",children:[(0,r.jsx)(C,{children:(0,r.jsxs)(x,{children:[(0,r.jsx)(c,{children:t("Bucket")}),(0,r.jsx)(c,{children:t("Operation")}),(0,r.jsx)(c,{children:t("Key prefix")}),(0,r.jsx)(c,{children:t("Guarded by")})]})}),(0,r.jsx)(I,{children:g.map(s=>(0,r.jsxs)(x,{"data-testid":`storage-rule-${s.bucket}-${s.on}-${s.prefix??""}`,children:[(0,r.jsx)(n,{className:"font-mono text-xs",children:s.bucket}),(0,r.jsx)(n,{children:(0,r.jsx)(w,{variant:"secondary",children:_(t,s.on)})}),(0,r.jsx)(n,{className:"font-mono text-xs",children:s.prefix??(0,r.jsx)("span",{className:"text-muted-foreground",children:t("(whole bucket)")})}),(0,r.jsx)(n,{className:"font-mono text-xs text-muted-foreground",children:s.procedure})]},`${s.bucket}:${s.on}:${s.prefix??""}:${s.procedure}`))})]})})})]}),e[1]=l,e[2]=i,e[3]=d,e[4]=h,e[5]=t,e[6]=m}else m=e[6];return m},"M");export{q as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as R}from"./chunk-2W4UO5BC.js";import{c as K}from"./chunk-
|
|
1
|
+
import{a as R}from"./chunk-2W4UO5BC.js";import{c as K}from"./chunk-4N76XUNG.js";import{a as N}from"./chunk-GWNGVKLG.js";import{a as C,b as F}from"./chunk-6G3E4PJ2.js";import{a as o,d as A}from"./chunk-5PEAXTYQ.js";var b=A(N(),1),u=A(C(),1);var S=A(F(),1);var x=(0,u.createContext)(void 0),w={},T="New chat",j=o((n,s)=>({id:n,name:s?.title??T,schema:s?.schema??[],shardKey:s?.shardKey,suggestions:s?.suggestions??[],turns:[]}),"F"),D=o((n,s)=>[...n.sessions,s].slice(-10),"T"),m=o((n,s)=>{let a=`chat-${String(n.seq+1)}`;return{activeId:a,draft:s?.draft===void 0?void 0:{id:n.seq+1,text:s.draft},hasEditor:n.hasEditor,insertRequest:void 0,open:!0,pendingAsk:s?.ask===void 0?void 0:{id:n.seq+1,sessionId:a,text:s.ask},seq:n.seq+1,sessions:D(n,j(a,s))}},"f"),v=o((n,s)=>n.find(a=>a.id===s),"l"),O=o((n,s,a)=>n.map(c=>c.id===s?{...c,schema:a}:c),"D"),U=o((n,s,a)=>n.map(c=>c.id===s?{...c,schema:[],shardKey:a}:c),"O"),$=o((n,s)=>n.filter(a=>a.id!==s),"U"),E=o((n,s,a)=>n.map(c=>c.id===s?{...c,turns:a}:c),"y"),z=o(n=>{let s=(0,b.c)(16),{children:a}=n,c;s[0]===Symbol.for("react.memo_cache_sentinel")?(c={shardKey:""},s[0]=c):c=s[0];let _=K(R.aiAvailable,w,c),l;s[1]===Symbol.for("react.memo_cache_sentinel")?(l={activeId:void 0,draft:void 0,hasEditor:!1,insertRequest:void 0,open:!1,pendingAsk:void 0,seq:0,sessions:[]},s[1]=l):l=s[1];let[d,h]=(0,u.useState)(l),p;s[2]===Symbol.for("react.memo_cache_sentinel")?(p=o(()=>({close:o(()=>{h(H)},"close"),deleteChat:o(t=>{h(e=>{let i=$(e.sessions,t);return{...e,activeId:e.activeId===t?i.at(-1)?.id:e.activeId,open:i.length===0?!1:e.open,sessions:i}})},"deleteChat"),newChat:o(t=>{h(e=>m(e,t))},"newChat"),openAssistant:o(t=>{h(e=>{let i=e.activeId===void 0?void 0:v(e.sessions,e.activeId);return t?.ask!==void 0||i===void 0||(t?.shardKey??"")!==(i.shardKey??"")?m(e,t):{...e,draft:t?.draft===void 0?e.draft:{id:e.seq+1,text:t.draft},open:!0,sessions:t?.schema===void 0?e.sessions:O(e.sessions,i.id,t.schema),seq:e.seq+1}})},"openAssistant"),rebindShard:o((t,e)=>{h(i=>{let r=i.activeId===void 0?void 0:v(i.sessions,i.activeId);return!i.open||r===void 0||(r.shardKey??"")!==t||t===e?i:r.turns.length===0?{...i,sessions:U(i.sessions,r.id,e)}:m(i,{shardKey:e,title:r.name})})},"rebindShard"),requestInsert:o(t=>{h(e=>({...e,insertRequest:{id:e.seq+1,sql:t},seq:e.seq+1}))},"requestInsert"),setHasEditor:o(t=>{h(e=>e.hasEditor===t?e:{...e,hasEditor:t})},"setHasEditor"),takeInsert:o(t=>{h(e=>e.insertRequest?.id===t?{...e,insertRequest:void 0}:e)},"takeInsert"),selectChat:o(t=>{h(e=>({...e,activeId:t,open:!0}))},"selectChat"),branchFrom:o((t,e)=>{h(i=>{let r=v(i.sessions,t);if(r===void 0)return i;let y=m(i,{schema:r.schema,shardKey:r.shardKey,title:r.name});return{...y,sessions:E(y.sessions,y.activeId??"",r.turns.slice(0,e+1))}})},"branchFrom"),setTurns:o((t,e)=>{h(i=>{let r=v(i.sessions,t);return r===void 0?i:{...i,sessions:E(i.sessions,t,typeof e=="function"?e(r.turns):e)}})},"setTurns"),toggle:o(()=>{h(M)},"toggle"),truncateFrom:o((t,e)=>{h(i=>{let r=v(i.sessions,t);return r===void 0?i:{...i,sessions:E(i.sessions,t,r.turns.slice(0,e))}})},"truncateFrom"),takeAsk:o(t=>{h(e=>e.pendingAsk?.id===t?{...e,pendingAsk:void 0}:e)},"takeAsk")}),"c"),s[2]=p):p=s[2];let[I]=(0,u.useState)(p),g=_.data?.available!==!0,f;s[3]!==I||s[4]!==d.activeId||s[5]!==d.draft||s[6]!==d.hasEditor||s[7]!==d.insertRequest||s[8]!==d.open||s[9]!==d.pendingAsk||s[10]!==d.sessions||s[11]!==g?(f={...I,activeId:d.activeId,draft:d.draft,hasEditor:d.hasEditor,insertRequest:d.insertRequest,open:d.open,pendingAsk:d.pendingAsk,sessions:d.sessions,unavailable:g},s[3]=I,s[4]=d.activeId,s[5]=d.draft,s[6]=d.hasEditor,s[7]=d.insertRequest,s[8]=d.open,s[9]=d.pendingAsk,s[10]=d.sessions,s[11]=g,s[12]=f):f=s[12];let k=f,q;return s[13]!==a||s[14]!==k?(q=(0,S.jsx)(x,{value:k,children:a}),s[13]=a,s[14]=k,s[15]=q):q=s[15],q},"P"),B=o(()=>(0,u.use)(x),"Q");function H(n){return{...n,open:!1}}o(H,"$");function M(n){return!n.open&&n.activeId===void 0?m(n,void 0):{...n,open:!n.open}}o(M,"j");export{z as a,B as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as He}from"./chunk-6FPV3EK2.js";import{a as Ge}from"./chunk-J3BZWYJQ.js";import{a as Se}from"./chunk-TKBTZX4K.js";import{a as qe}from"./chunk-YEVTA35E.js";import{i as je}from"./chunk-IHGRWY3Y.js";import"./chunk-OWRKSQPE.js";import"./chunk-4EPW63HS.js";import{a as $e}from"./chunk-V3BE427M.js";import"./chunk-CKEQX655.js";import"./chunk-UD5REVU2.js";import{b as Ze}from"./chunk-UQA2AJGI.js";import"./chunk-T3ZCW3RG.js";import{a as Fe}from"./chunk-2W4UO5BC.js";import{m as Ke}from"./chunk-FACXM2UB.js";import"./chunk-ZPQBVYNN.js";import{B as Oe,h as Pe,i as me,j as Ce,k as Ue,s as Re}from"./chunk-GNI37YCV.js";import"./chunk-PDBW6GTJ.js";import{a as at}from"./chunk-GWNGVKLG.js";import{a as ot,b as lt}from"./chunk-6G3E4PJ2.js";import{a as s,d as Me}from"./chunk-5PEAXTYQ.js";var De=Me(at(),1),m=Me(ot(),1);var r=Me(lt(),1);var ze=Pe(Fe.getPitrBookmark),st=Pe(Fe.pitrRestore),nt=/^\d+$/u,Je=s(ie=>{let e=ie.trim(),h=nt.test(e)?Number(e):Date.parse(e),l=new Date(h);return Number.isNaN(l.getTime())?void 0:{epochMs:h,iso:l.toISOString()}},"De"),it=s(ie=>{let e=(0,De.c)(9),{text:h}=ie,l=Oe();if(h.trim()==="")return null;let t,o,p;if(e[0]!==l||e[1]!==h){let y=Je(h);t="font-mono text-xs text-muted-foreground",o="pitr-time-resolved",p=y===void 0?l("Not a time \u2014 use epoch-ms or ISO 8601."):l("Resolves to {instant} (a date-time without an offset is read in this browser's time zone; a bare date is UTC)",{instant:y.iso}),e[0]=l,e[1]=h,e[2]=t,e[3]=o,e[4]=p}else t=e[2],o=e[3],p=e[4];let N;return e[5]!==t||e[6]!==o||e[7]!==p?(N=(0,r.jsx)("p",{className:t,"data-testid":o,children:p}),e[5]=t,e[6]=o,e[7]=p,e[8]=N):N=e[8],N},"lt"),vt=s(ie=>{let e=(0,De.c)(140),{initialShardKey:h}=ie,l=Ke(),t=Oe(),o=h??"",p=He(o),[N,y]=(0,m.useState)(null),[f,Qe]=(0,m.useState)(""),[ce,Ee]=(0,m.useState)(null),[c,We]=(0,m.useState)(""),[b,Xe]=(0,m.useState)(!1),[i,Ye]=(0,m.useState)(null),[ue,w]=(0,m.useState)(null),[de,I]=(0,m.useState)(!1),[C,Ve]=(0,m.useState)(!1),pe;e[0]!==l||e[1]!==o?(pe=s(async a=>{I(!0),w(null);let d;try{d={current:(await l.query(ze,{},me(o))).current,error:null,unavailable:!1}}catch(n){let g=n;d={current:null,error:Ce(g),unavailable:Ue(g)==="PITR_UNAVAILABLE"}}a?.aborted!==!0&&(d.error===null?y(d.current):w(d.error),Ve(d.unavailable),I(!1))},"fe"),e[0]=l,e[1]=o,e[2]=pe):pe=e[2];let x=pe,he,fe;e[3]!==x?(he=s(()=>{let a=new AbortController;return Re(x(a.signal)),()=>{a.abort()}},"ue"),fe=[x],e[3]=x,e[4]=he,e[5]=fe):(he=e[4],fe=e[5]),(0,m.useEffect)(he,fe);let be;e[6]!==l||e[7]!==o?(be=s(async()=>{let a=await l.query(ze,{},me(o));y(a.current)},"he"),e[6]=l,e[7]=o,e[8]=be):be=e[8],Ge(be,!C);let xe;e[9]===Symbol.for("react.memo_cache_sentinel")?(xe=s(a=>{Qe(a.target.value)},"be"),e[9]=xe):xe=e[9];let et=xe,ke;e[10]===Symbol.for("react.memo_cache_sentinel")?(ke=s(a=>{We(a.target.value)},"xe"),e[10]=ke):ke=e[10];let tt=ke,Ne;e[11]===Symbol.for("react.memo_cache_sentinel")?(Ne=s(a=>{Xe(a.target.checked)},"ke"),e[11]=Ne):Ne=e[11];let rt=Ne,ve,R,u,k,v,ge;if(e[12]!==c||e[13]!==l||e[14]!==ce||e[15]!==x||e[16]!==o||e[17]!==p||e[18]!==t||e[19]!==f){u=Je(f),R=s(()=>{if(u===void 0)return;let d=o;Re((async()=>{I(!0),w(null);let n;try{n={result:await l.query(ze,{time:u.epochMs},me(d))}}catch(g){n={error:Ce(g)}}p.current===d&&("result"in n?(Ee(n.result.forTime===void 0?null:{bookmark:n.result.forTime,shard:d}),y(n.result.current)):(Ee(null),w(n.error)),I(!1))})())},"C"),v=ce?.shard===o?ce.bookmark:null;let a;e[26]!==l||e[27]!==x||e[28]!==o?(a=s(d=>{Re((async()=>{I(!0),w(null);try{let n=await l.mutation(st,d,me(o));Ye(n),await x()}catch(n){let g=n;w(Ce(g)),Ue(g)==="PITR_UNAVAILABLE"&&Ve(!0)}I(!1)})())},"o"),e[26]=l,e[27]=x,e[28]=o,e[29]=a):a=e[29],k=a,ve=c.trim()!==""||u!==void 0,ge=t("Restore {shard} to {target}?",{shard:o===""?t("root"):o,target:c.trim()===""?u?.iso??"":t("the given bookmark")}),e[12]=c,e[13]=l,e[14]=ce,e[15]=x,e[16]=o,e[17]=p,e[18]=t,e[19]=f,e[20]=ve,e[21]=R,e[22]=u,e[23]=k,e[24]=v,e[25]=ge}else ve=e[20],R=e[21],u=e[22],k=e[23],v=e[24],ge=e[25];let Te=ge,ye;e[30]!==c||e[31]!==u?.epochMs||e[32]!==b||e[33]!==k?(ye=s(()=>{let a=b?{restart:!0}:{};c.trim()===""?a.time=u?.epochMs:a.bookmark=c.trim(),k(a)},"Ne"),e[30]=c,e[31]=u?.epochMs,e[32]=b,e[33]=k,e[34]=ye):ye=e[34];let Be=ye,we;e[35]!==b||e[36]!==i||e[37]!==k?(we=s(()=>{i!==null&&k(b?{bookmark:i.undoBookmark,restart:!0}:{bookmark:i.undoBookmark})},"ye"),e[35]=b,e[36]=i,e[37]=k,e[38]=we):we=e[38];let Ae=we,S;e[39]!==t?(S=t("Shard"),e[39]=t,e[40]=S):S=e[40];let T;e[41]!==o||e[42]!==t?(T=o===""?t("root"):o,e[41]=o,e[42]=t,e[43]=T):T=e[43];let B;e[44]!==T?(B=(0,r.jsx)("span",{className:"font-mono",children:T}),e[44]=T,e[45]=B):B=e[45];let A;e[46]!==S||e[47]!==B?(A=(0,r.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[S,": ",B]})}),e[46]=S,e[47]=B,e[48]=A):A=e[48];let _;e[49]!==t?(_=t("In-place recovery to any moment in the last 30 days. For older or portable recovery, use the snapshot backup tier."),e[49]=t,e[50]=_):_=e[50];let L;e[51]!==_?(L=(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"pitr-note",children:_}),e[51]=_,e[52]=L):L=e[52];let M;e[53]!==ue?(M=ue!==null&&(0,r.jsx)("p",{className:"text-sm text-destructive","data-testid":"pitr-error",role:"alert",children:ue}),e[53]=ue,e[54]=M):M=e[54];let P;e[55]!==t?(P=t("Current bookmark"),e[55]=t,e[56]=P):P=e[56];let U;e[57]!==P?(U=(0,r.jsx)("h3",{className:"mb-2 text-sm font-semibold",children:P}),e[57]=P,e[58]=U):U=e[58];let F;e[59]!==N?(F=N??(0,r.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),e[59]=N,e[60]=F):F=e[60];let O;e[61]!==F?(O=(0,r.jsx)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-current",children:F}),e[61]=F,e[62]=O):O=e[62];let j;e[63]!==U||e[64]!==O?(j=(0,r.jsxs)("section",{className:"rounded-xl border border-border bg-card p-3 shadow-xs",children:[U,O]}),e[63]=U,e[64]=O,e[65]=j):j=e[65];let q;e[66]!==t?(q=t("Restore"),e[66]=t,e[67]=q):q=e[67];let z;e[68]!==q?(z=(0,r.jsx)("h3",{className:"text-sm font-semibold",children:q}),e[68]=q,e[69]=z):z=e[69];let D;e[70]!==t?(D=t("Time (ISO or epoch-ms, last 30 days)"),e[70]=t,e[71]=D):D=e[71];let E;e[72]!==D?(E=(0,r.jsx)(Se,{htmlFor:"pitr-time",children:D}),e[72]=D,e[73]=E):E=e[73];let V;e[74]!==f?(V=(0,r.jsx)(je,{"data-testid":"pitr-time",id:"pitr-time",onChange:et,placeholder:"2026-06-01T00:00:00.000Z",value:f}),e[74]=f,e[75]=V):V=e[75];let _e=de||C||u===void 0,K;e[76]!==t?(K=t("Preview"),e[76]=t,e[77]=K):K=e[77];let Z;e[78]!==R||e[79]!==_e||e[80]!==K?(Z=(0,r.jsx)($e,{"data-testid":"pitr-preview",disabled:_e,onClick:R,size:"sm",type:"button",variant:"outline",children:K}),e[78]=R,e[79]=_e,e[80]=K,e[81]=Z):Z=e[81];let $;e[82]!==V||e[83]!==Z?($=(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[V,Z]}),e[82]=V,e[83]=Z,e[84]=$):$=e[84];let G;e[85]!==f?(G=(0,r.jsx)(it,{text:f}),e[85]=f,e[86]=G):G=e[86];let H;e[87]!==v||e[88]!==t?(H=v!==null&&(0,r.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-preview-bookmark",children:[t("Bookmark for that time"),": ",v]}),e[87]=v,e[88]=t,e[89]=H):H=e[89];let J;e[90]!==E||e[91]!==$||e[92]!==G||e[93]!==H?(J=(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[E,$,G,H]}),e[90]=E,e[91]=$,e[92]=G,e[93]=H,e[94]=J):J=e[94];let Q;e[95]!==t?(Q=t("Or an explicit bookmark (wins over time)"),e[95]=t,e[96]=Q):Q=e[96];let W;e[97]!==Q?(W=(0,r.jsx)(Se,{htmlFor:"pitr-bookmark",children:Q}),e[97]=Q,e[98]=W):W=e[98];let X;e[99]!==t?(X=t("bookmark string"),e[99]=t,e[100]=X):X=e[100];let Y;e[101]!==c||e[102]!==X?(Y=(0,r.jsx)(je,{"data-testid":"pitr-bookmark",id:"pitr-bookmark",onChange:tt,placeholder:X,value:c}),e[101]=c,e[102]=X,e[103]=Y):Y=e[103];let ee;e[104]!==W||e[105]!==Y?(ee=(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[W,Y]}),e[104]=W,e[105]=Y,e[106]=ee):ee=e[106];let te;e[107]!==b?(te=(0,r.jsx)("input",{checked:b,className:"size-4 accent-primary","data-testid":"pitr-restart",id:"pitr-restart",onChange:rt,type:"checkbox"}),e[107]=b,e[108]=te):te=e[108];let re;e[109]!==t?(re=t("Restart the shard now so recovery applies immediately"),e[109]=t,e[110]=re):re=e[110];let oe;e[111]!==te||e[112]!==re?(oe=(0,r.jsxs)(Se,{className:"flex items-center gap-2 text-xs font-normal text-muted-foreground",htmlFor:"pitr-restart",children:[te,re]}),e[111]=te,e[112]=re,e[113]=oe):oe=e[113];let Le=de||C||!ve,ae;e[114]!==t?(ae=t("Restore"),e[114]=t,e[115]=ae):ae=e[115];let le;e[116]!==Te||e[117]!==Be||e[118]!==Le||e[119]!==ae?(le=(0,r.jsx)("div",{children:(0,r.jsx)(qe,{confirmLabel:Te,disabled:Le,onConfirm:Be,testId:"pitr-restore",children:ae})}),e[116]=Te,e[117]=Be,e[118]=Le,e[119]=ae,e[120]=le):le=e[120];let se;e[121]!==z||e[122]!==J||e[123]!==ee||e[124]!==oe||e[125]!==le?(se=(0,r.jsxs)("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-3 shadow-xs",children:[z,J,ee,oe,le]}),e[121]=z,e[122]=J,e[123]=ee,e[124]=oe,e[125]=le,e[126]=se):se=e[126];let ne;e[127]!==de||e[128]!==Ae||e[129]!==i||e[130]!==t||e[131]!==C?(ne=i!==null&&(0,r.jsxs)("section",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs","data-testid":"pitr-result",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold",children:t("Restore armed")}),(0,r.jsx)(Ze,{variant:i.restarted?"destructive":"secondary",children:i.restarted?t("restarted now"):t("on next restart")})]}),(0,r.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground",children:[t("Restored to"),": ",i.restoredTo]}),(0,r.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-undo-bookmark",children:[t("Undo bookmark"),": ",i.undoBookmark]}),(0,r.jsx)("div",{children:(0,r.jsx)(qe,{confirmLabel:t("Confirm undo"),disabled:de||C,onConfirm:Ae,testId:"pitr-undo",children:t("Undo restore")})})]}),e[127]=de,e[128]=Ae,e[129]=i,e[130]=t,e[131]=C,e[132]=ne):ne=e[132];let Ie;return e[133]!==A||e[134]!==L||e[135]!==M||e[136]!==j||e[137]!==se||e[138]!==ne?(Ie=(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-pitr",children:[A,L,M,j,se,ne]}),e[133]=A,e[134]=L,e[135]=M,e[136]=j,e[137]=se,e[138]=ne,e[139]=Ie):Ie=e[139],Ie},"Nt");export{vt as PitrPanel};
|
|
1
|
+
import{a as He}from"./chunk-6FPV3EK2.js";import{a as Ge}from"./chunk-EPWCW2DF.js";import{a as Se}from"./chunk-TKBTZX4K.js";import{a as qe}from"./chunk-YEVTA35E.js";import{i as je}from"./chunk-IHGRWY3Y.js";import"./chunk-OWRKSQPE.js";import"./chunk-4EPW63HS.js";import{a as $e}from"./chunk-V3BE427M.js";import"./chunk-CKEQX655.js";import"./chunk-UD5REVU2.js";import{b as Ze}from"./chunk-UQA2AJGI.js";import"./chunk-T3ZCW3RG.js";import{a as Fe}from"./chunk-2W4UO5BC.js";import{m as Ke}from"./chunk-SHHGIT7M.js";import"./chunk-ZPQBVYNN.js";import{B as Oe,h as Pe,i as me,j as Ce,k as Ue,s as Re}from"./chunk-GNI37YCV.js";import"./chunk-PDBW6GTJ.js";import{a as at}from"./chunk-GWNGVKLG.js";import{a as ot,b as lt}from"./chunk-6G3E4PJ2.js";import{a as s,d as Me}from"./chunk-5PEAXTYQ.js";var De=Me(at(),1),m=Me(ot(),1);var r=Me(lt(),1);var ze=Pe(Fe.getPitrBookmark),st=Pe(Fe.pitrRestore),nt=/^\d+$/u,Je=s(ie=>{let e=ie.trim(),h=nt.test(e)?Number(e):Date.parse(e),l=new Date(h);return Number.isNaN(l.getTime())?void 0:{epochMs:h,iso:l.toISOString()}},"De"),it=s(ie=>{let e=(0,De.c)(9),{text:h}=ie,l=Oe();if(h.trim()==="")return null;let t,o,p;if(e[0]!==l||e[1]!==h){let y=Je(h);t="font-mono text-xs text-muted-foreground",o="pitr-time-resolved",p=y===void 0?l("Not a time \u2014 use epoch-ms or ISO 8601."):l("Resolves to {instant} (a date-time without an offset is read in this browser's time zone; a bare date is UTC)",{instant:y.iso}),e[0]=l,e[1]=h,e[2]=t,e[3]=o,e[4]=p}else t=e[2],o=e[3],p=e[4];let N;return e[5]!==t||e[6]!==o||e[7]!==p?(N=(0,r.jsx)("p",{className:t,"data-testid":o,children:p}),e[5]=t,e[6]=o,e[7]=p,e[8]=N):N=e[8],N},"lt"),vt=s(ie=>{let e=(0,De.c)(140),{initialShardKey:h}=ie,l=Ke(),t=Oe(),o=h??"",p=He(o),[N,y]=(0,m.useState)(null),[f,Qe]=(0,m.useState)(""),[ce,Ee]=(0,m.useState)(null),[c,We]=(0,m.useState)(""),[b,Xe]=(0,m.useState)(!1),[i,Ye]=(0,m.useState)(null),[ue,w]=(0,m.useState)(null),[de,I]=(0,m.useState)(!1),[C,Ve]=(0,m.useState)(!1),pe;e[0]!==l||e[1]!==o?(pe=s(async a=>{I(!0),w(null);let d;try{d={current:(await l.query(ze,{},me(o))).current,error:null,unavailable:!1}}catch(n){let g=n;d={current:null,error:Ce(g),unavailable:Ue(g)==="PITR_UNAVAILABLE"}}a?.aborted!==!0&&(d.error===null?y(d.current):w(d.error),Ve(d.unavailable),I(!1))},"fe"),e[0]=l,e[1]=o,e[2]=pe):pe=e[2];let x=pe,he,fe;e[3]!==x?(he=s(()=>{let a=new AbortController;return Re(x(a.signal)),()=>{a.abort()}},"ue"),fe=[x],e[3]=x,e[4]=he,e[5]=fe):(he=e[4],fe=e[5]),(0,m.useEffect)(he,fe);let be;e[6]!==l||e[7]!==o?(be=s(async()=>{let a=await l.query(ze,{},me(o));y(a.current)},"he"),e[6]=l,e[7]=o,e[8]=be):be=e[8],Ge(be,!C);let xe;e[9]===Symbol.for("react.memo_cache_sentinel")?(xe=s(a=>{Qe(a.target.value)},"be"),e[9]=xe):xe=e[9];let et=xe,ke;e[10]===Symbol.for("react.memo_cache_sentinel")?(ke=s(a=>{We(a.target.value)},"xe"),e[10]=ke):ke=e[10];let tt=ke,Ne;e[11]===Symbol.for("react.memo_cache_sentinel")?(Ne=s(a=>{Xe(a.target.checked)},"ke"),e[11]=Ne):Ne=e[11];let rt=Ne,ve,R,u,k,v,ge;if(e[12]!==c||e[13]!==l||e[14]!==ce||e[15]!==x||e[16]!==o||e[17]!==p||e[18]!==t||e[19]!==f){u=Je(f),R=s(()=>{if(u===void 0)return;let d=o;Re((async()=>{I(!0),w(null);let n;try{n={result:await l.query(ze,{time:u.epochMs},me(d))}}catch(g){n={error:Ce(g)}}p.current===d&&("result"in n?(Ee(n.result.forTime===void 0?null:{bookmark:n.result.forTime,shard:d}),y(n.result.current)):(Ee(null),w(n.error)),I(!1))})())},"C"),v=ce?.shard===o?ce.bookmark:null;let a;e[26]!==l||e[27]!==x||e[28]!==o?(a=s(d=>{Re((async()=>{I(!0),w(null);try{let n=await l.mutation(st,d,me(o));Ye(n),await x()}catch(n){let g=n;w(Ce(g)),Ue(g)==="PITR_UNAVAILABLE"&&Ve(!0)}I(!1)})())},"o"),e[26]=l,e[27]=x,e[28]=o,e[29]=a):a=e[29],k=a,ve=c.trim()!==""||u!==void 0,ge=t("Restore {shard} to {target}?",{shard:o===""?t("root"):o,target:c.trim()===""?u?.iso??"":t("the given bookmark")}),e[12]=c,e[13]=l,e[14]=ce,e[15]=x,e[16]=o,e[17]=p,e[18]=t,e[19]=f,e[20]=ve,e[21]=R,e[22]=u,e[23]=k,e[24]=v,e[25]=ge}else ve=e[20],R=e[21],u=e[22],k=e[23],v=e[24],ge=e[25];let Te=ge,ye;e[30]!==c||e[31]!==u?.epochMs||e[32]!==b||e[33]!==k?(ye=s(()=>{let a=b?{restart:!0}:{};c.trim()===""?a.time=u?.epochMs:a.bookmark=c.trim(),k(a)},"Ne"),e[30]=c,e[31]=u?.epochMs,e[32]=b,e[33]=k,e[34]=ye):ye=e[34];let Be=ye,we;e[35]!==b||e[36]!==i||e[37]!==k?(we=s(()=>{i!==null&&k(b?{bookmark:i.undoBookmark,restart:!0}:{bookmark:i.undoBookmark})},"ye"),e[35]=b,e[36]=i,e[37]=k,e[38]=we):we=e[38];let Ae=we,S;e[39]!==t?(S=t("Shard"),e[39]=t,e[40]=S):S=e[40];let T;e[41]!==o||e[42]!==t?(T=o===""?t("root"):o,e[41]=o,e[42]=t,e[43]=T):T=e[43];let B;e[44]!==T?(B=(0,r.jsx)("span",{className:"font-mono",children:T}),e[44]=T,e[45]=B):B=e[45];let A;e[46]!==S||e[47]!==B?(A=(0,r.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[S,": ",B]})}),e[46]=S,e[47]=B,e[48]=A):A=e[48];let _;e[49]!==t?(_=t("In-place recovery to any moment in the last 30 days. For older or portable recovery, use the snapshot backup tier."),e[49]=t,e[50]=_):_=e[50];let L;e[51]!==_?(L=(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"pitr-note",children:_}),e[51]=_,e[52]=L):L=e[52];let M;e[53]!==ue?(M=ue!==null&&(0,r.jsx)("p",{className:"text-sm text-destructive","data-testid":"pitr-error",role:"alert",children:ue}),e[53]=ue,e[54]=M):M=e[54];let P;e[55]!==t?(P=t("Current bookmark"),e[55]=t,e[56]=P):P=e[56];let U;e[57]!==P?(U=(0,r.jsx)("h3",{className:"mb-2 text-sm font-semibold",children:P}),e[57]=P,e[58]=U):U=e[58];let F;e[59]!==N?(F=N??(0,r.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),e[59]=N,e[60]=F):F=e[60];let O;e[61]!==F?(O=(0,r.jsx)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-current",children:F}),e[61]=F,e[62]=O):O=e[62];let j;e[63]!==U||e[64]!==O?(j=(0,r.jsxs)("section",{className:"rounded-xl border border-border bg-card p-3 shadow-xs",children:[U,O]}),e[63]=U,e[64]=O,e[65]=j):j=e[65];let q;e[66]!==t?(q=t("Restore"),e[66]=t,e[67]=q):q=e[67];let z;e[68]!==q?(z=(0,r.jsx)("h3",{className:"text-sm font-semibold",children:q}),e[68]=q,e[69]=z):z=e[69];let D;e[70]!==t?(D=t("Time (ISO or epoch-ms, last 30 days)"),e[70]=t,e[71]=D):D=e[71];let E;e[72]!==D?(E=(0,r.jsx)(Se,{htmlFor:"pitr-time",children:D}),e[72]=D,e[73]=E):E=e[73];let V;e[74]!==f?(V=(0,r.jsx)(je,{"data-testid":"pitr-time",id:"pitr-time",onChange:et,placeholder:"2026-06-01T00:00:00.000Z",value:f}),e[74]=f,e[75]=V):V=e[75];let _e=de||C||u===void 0,K;e[76]!==t?(K=t("Preview"),e[76]=t,e[77]=K):K=e[77];let Z;e[78]!==R||e[79]!==_e||e[80]!==K?(Z=(0,r.jsx)($e,{"data-testid":"pitr-preview",disabled:_e,onClick:R,size:"sm",type:"button",variant:"outline",children:K}),e[78]=R,e[79]=_e,e[80]=K,e[81]=Z):Z=e[81];let $;e[82]!==V||e[83]!==Z?($=(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[V,Z]}),e[82]=V,e[83]=Z,e[84]=$):$=e[84];let G;e[85]!==f?(G=(0,r.jsx)(it,{text:f}),e[85]=f,e[86]=G):G=e[86];let H;e[87]!==v||e[88]!==t?(H=v!==null&&(0,r.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-preview-bookmark",children:[t("Bookmark for that time"),": ",v]}),e[87]=v,e[88]=t,e[89]=H):H=e[89];let J;e[90]!==E||e[91]!==$||e[92]!==G||e[93]!==H?(J=(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[E,$,G,H]}),e[90]=E,e[91]=$,e[92]=G,e[93]=H,e[94]=J):J=e[94];let Q;e[95]!==t?(Q=t("Or an explicit bookmark (wins over time)"),e[95]=t,e[96]=Q):Q=e[96];let W;e[97]!==Q?(W=(0,r.jsx)(Se,{htmlFor:"pitr-bookmark",children:Q}),e[97]=Q,e[98]=W):W=e[98];let X;e[99]!==t?(X=t("bookmark string"),e[99]=t,e[100]=X):X=e[100];let Y;e[101]!==c||e[102]!==X?(Y=(0,r.jsx)(je,{"data-testid":"pitr-bookmark",id:"pitr-bookmark",onChange:tt,placeholder:X,value:c}),e[101]=c,e[102]=X,e[103]=Y):Y=e[103];let ee;e[104]!==W||e[105]!==Y?(ee=(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[W,Y]}),e[104]=W,e[105]=Y,e[106]=ee):ee=e[106];let te;e[107]!==b?(te=(0,r.jsx)("input",{checked:b,className:"size-4 accent-primary","data-testid":"pitr-restart",id:"pitr-restart",onChange:rt,type:"checkbox"}),e[107]=b,e[108]=te):te=e[108];let re;e[109]!==t?(re=t("Restart the shard now so recovery applies immediately"),e[109]=t,e[110]=re):re=e[110];let oe;e[111]!==te||e[112]!==re?(oe=(0,r.jsxs)(Se,{className:"flex items-center gap-2 text-xs font-normal text-muted-foreground",htmlFor:"pitr-restart",children:[te,re]}),e[111]=te,e[112]=re,e[113]=oe):oe=e[113];let Le=de||C||!ve,ae;e[114]!==t?(ae=t("Restore"),e[114]=t,e[115]=ae):ae=e[115];let le;e[116]!==Te||e[117]!==Be||e[118]!==Le||e[119]!==ae?(le=(0,r.jsx)("div",{children:(0,r.jsx)(qe,{confirmLabel:Te,disabled:Le,onConfirm:Be,testId:"pitr-restore",children:ae})}),e[116]=Te,e[117]=Be,e[118]=Le,e[119]=ae,e[120]=le):le=e[120];let se;e[121]!==z||e[122]!==J||e[123]!==ee||e[124]!==oe||e[125]!==le?(se=(0,r.jsxs)("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-3 shadow-xs",children:[z,J,ee,oe,le]}),e[121]=z,e[122]=J,e[123]=ee,e[124]=oe,e[125]=le,e[126]=se):se=e[126];let ne;e[127]!==de||e[128]!==Ae||e[129]!==i||e[130]!==t||e[131]!==C?(ne=i!==null&&(0,r.jsxs)("section",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs","data-testid":"pitr-result",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold",children:t("Restore armed")}),(0,r.jsx)(Ze,{variant:i.restarted?"destructive":"secondary",children:i.restarted?t("restarted now"):t("on next restart")})]}),(0,r.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground",children:[t("Restored to"),": ",i.restoredTo]}),(0,r.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-undo-bookmark",children:[t("Undo bookmark"),": ",i.undoBookmark]}),(0,r.jsx)("div",{children:(0,r.jsx)(qe,{confirmLabel:t("Confirm undo"),disabled:de||C,onConfirm:Ae,testId:"pitr-undo",children:t("Undo restore")})})]}),e[127]=de,e[128]=Ae,e[129]=i,e[130]=t,e[131]=C,e[132]=ne):ne=e[132];let Ie;return e[133]!==A||e[134]!==L||e[135]!==M||e[136]!==j||e[137]!==se||e[138]!==ne?(Ie=(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-pitr",children:[A,L,M,j,se,ne]}),e[133]=A,e[134]=L,e[135]=M,e[136]=j,e[137]=se,e[138]=ne,e[139]=Ie):Ie=e[139],Ie},"Nt");export{vt as PitrPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Ie}from"./chunk-ELSQ4FVH.js";import{a as Se}from"./chunk-PJUVJTDR.js";import{a as _}from"./chunk-TKBTZX4K.js";import{a as Ce}from"./chunk-YEVTA35E.js";import{a as ve}from"./chunk-FHLODLBC.js";import"./chunk-3D67ZJRW.js";import"./chunk-ZSWW2UGP.js";import{i as V}from"./chunk-IHGRWY3Y.js";import"./chunk-OWRKSQPE.js";import"./chunk-4EPW63HS.js";import{a as z}from"./chunk-V3BE427M.js";import"./chunk-CKEQX655.js";import"./chunk-UD5REVU2.js";import{a as ce}from"./chunk-RCXNYW7P.js";import{b as E}from"./chunk-UQA2AJGI.js";import"./chunk-T3ZCW3RG.js";import{a as Ne}from"./chunk-IUGNIG6L.js";import"./chunk-LSEUUZN4.js";import{a as ke,b as we,c as Pe,d as me,e as le,f as ie}from"./chunk-7QEZ2SFW.js";import"./chunk-WCWP4EAW.js";import"./chunk-BX7TFVCC.js";import"./chunk-4PI2OSSP.js";import{a as X}from"./chunk-2W4UO5BC.js";import{c as re}from"./chunk-FBDIQ67D.js";import{a as ne,b as ge,c as ye,d as be,e as de}from"./chunk-OK2QU2EV.js";import{i as pe,m as se}from"./chunk-FACXM2UB.js";import"./chunk-ZPQBVYNN.js";import{B as K,h as ue,i as fe,j as he,p as xe,s as ae}from"./chunk-GNI37YCV.js";import"./chunk-PDBW6GTJ.js";import{a as Te}from"./chunk-GWNGVKLG.js";import{a as Fe,b as Ee}from"./chunk-6G3E4PJ2.js";import{a as f,d as oe}from"./chunk-5PEAXTYQ.js";var y=oe(Fe(),1);var ee=oe(Te(),1);var a=oe(Ee(),1);var _e=["read","insert","update","delete"],ze=f((t,e)=>({delete:t("Delete"),insert:t("Insert"),read:t("Read"),update:t("Update")})[e],"_e"),$e=f(t=>t.file===""?t.procedure:`${t.file}:${t.procedure}`,"Fe"),De=f(t=>{let e=new Set;for(let l of t?.advisories??[])if(l.name==="rls_uncovered_table"){let{table:o}=l.metadata;typeof o=="string"&&o!==""&&e.add(o)}return e},"Oe"),Le=f((t,e,l)=>{let o=new Map,i=f(n=>{let s=o.get(n);if(s!==void 0)return s;let p={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:n,uncovered:l.has(n)};return o.set(n,p),p},"r");for(let n of t)i(n.table).cells[n.on]={path:$e(n),procedure:n.procedure};for(let n of e)i(n.table).maskedColumns.add(n.column);for(let n of l)i(n);return[...o.values()].toSorted((n,s)=>n.table.localeCompare(s.table))},"De"),Oe=f(t=>{let e=(0,ee.c)(17),l;e[0]!==t?(l=t===void 0?{}:t,e[0]=t,e[1]=l):l=e[1];let{onProbe:o}=l,i=K(),n,s;e[2]===Symbol.for("react.memo_cache_sentinel")?(n={},s={live:!0},e[2]=n,e[3]=s):(n=e[2],s=e[3]);let p=re(X.rlsPolicies,n,s),r;e[4]===Symbol.for("react.memo_cache_sentinel")?(r={},e[4]=r):r=e[4];let m=re(X.maskPolicies,r),d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d={},e[5]=d):d=e[5];let c=re(X.getAdvisories,d),h;if(e[6]!==c.data||e[7]!==m.data||e[8]!==o||e[9]!==p||e[10]!==i){let g=null;p.data!==void 0&&(g=Array.isArray(p.data.policies)?p.data.policies:[]);let $=Array.isArray(m.data?.columns)?m.data.columns:[],H=c.data??null,{error:C,errorSource:w,liveError:S}=p,A=g===null?[]:Le(g,$,De(H)),k;e[12]!==S?(k=(0,a.jsx)("div",{className:"flex items-center justify-end",children:(0,a.jsx)(Ie,{message:S,prefix:"pm"})}),e[12]=S,e[13]=k):k=e[13];let R;e[14]!==C||e[15]!==w?(R=C!==null&&(0,a.jsx)(Ne,{error:w,testId:"pm-error"}),e[14]=C,e[15]=w,e[16]=R):R=e[16],h=(0,a.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[k,R,g!==null&&A.length===0?(0,a.jsx)(ce,{description:i("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:i("No policy")}):(0,a.jsxs)(ke,{"data-testid":"pm-table",children:[(0,a.jsx)(we,{children:(0,a.jsxs)(me,{children:[(0,a.jsx)(le,{children:i("Table")}),_e.map(x=>(0,a.jsx)(le,{children:ze(i,x)},x)),(0,a.jsx)(le,{children:i("Masked columns")})]})}),(0,a.jsx)(Pe,{children:A.map(x=>(0,a.jsxs)(me,{"data-testid":`pm-row-${x.table}`,children:[(0,a.jsx)(ie,{className:"font-mono text-xs",children:(0,a.jsxs)("span",{className:"flex items-center gap-1.5",children:[x.table,x.uncovered&&(0,a.jsx)(E,{"data-testid":`pm-uncovered-${x.table}`,title:i("Uncovered \u2014 reachable without a policy"),variant:"destructive",children:i("Uncovered \u2014 reachable without a policy")})]})}),_e.map(I=>{let v=x.cells[I];return(0,a.jsx)(ie,{"data-testid":`pm-cell-${x.table}-${I}`,children:v.procedure===void 0?(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:i("No policy")}):(0,a.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,a.jsx)(E,{variant:"secondary",children:i("Covered by {procedure}",{procedure:v.procedure})}),o!==void 0&&(0,a.jsx)(z,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${x.table}-${I}`,onClick:f(()=>{o(x.table,I,v.path??"")},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Probe this")})]})},I)}),(0,a.jsx)(ie,{children:x.maskedColumns.size===0?(0,a.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,a.jsx)("span",{className:"flex flex-wrap gap-1",children:[...x.maskedColumns].map(qe)})})]},x.table))})]})]}),e[6]=c.data,e[7]=m.data,e[8]=o,e[9]=p,e[10]=i,e[11]=h}else h=e[11];return h},"Le");function qe(t){return(0,a.jsx)(E,{variant:"outline",children:t},t)}f(qe,"$e");var Ue=ue(X.runAs),We=new Set(["FORBIDDEN","RLS_REQUIRED","UNAUTHORIZED"]),je=f(t=>{let e=t?.code;return typeof e=="string"?e:void 0},"Me"),Be=f(()=>{let t=se();return async({args:e,functionPath:l,shardKey:o="",userId:i})=>{if(i.trim()==="")return{kind:"invalid",message:"No identity to probe: enter the userId whose access you want to test."};let n=Ue;try{return{kind:"allowed",value:await t.query(n,{args:e,functionPath:l,userId:i},fe(o))}}catch(s){let p=s instanceof Error?s.message:String(s),r=je(s);return r!==void 0&&We.has(r)?{kind:"denied",message:p}:{kind:"errored",message:p}}}},"ze"),Me=f(t=>t===void 0?"undefined":JSON.stringify(t,xe,2),"qe"),Je=f(t=>{let e=(0,ee.c)(43),{outcome:l}=t,o=K();if(l.kind==="allowed"){let r;e[0]!==o?(r=o("Allowed"),e[0]=o,e[1]=r):r=e[1];let m;e[2]!==r?(m=(0,a.jsx)(E,{variant:"secondary",children:r}),e[2]=r,e[3]=m):m=e[3];let d;e[4]!==l.value?(d=Me(l.value),e[4]=l.value,e[5]=d):d=e[5];let c;e[6]!==d?(c=(0,a.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:d}),e[6]=d,e[7]=c):c=e[7];let h;return e[8]!==m||e[9]!==c?(h=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[m,c]}),e[8]=m,e[9]=c,e[10]=h):h=e[10],h}if(l.kind==="denied"){let r;e[11]!==o?(r=o("Denied"),e[11]=o,e[12]=r):r=e[12];let m;e[13]!==r?(m=(0,a.jsx)(E,{variant:"destructive",children:r}),e[13]=r,e[14]=m):m=e[14];let d;e[15]!==l.message?(d=(0,a.jsx)("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:l.message}),e[15]=l.message,e[16]=d):d=e[16];let c;return e[17]!==m||e[18]!==d?(c=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[m,d]}),e[17]=m,e[18]=d,e[19]=c):c=e[19],c}if(l.kind==="errored"){let r;e[20]!==o?(r=o("Errored"),e[20]=o,e[21]=r):r=e[21];let m;e[22]!==r?(m=(0,a.jsx)(E,{variant:"outline",children:r}),e[22]=r,e[23]=m):m=e[23];let d;e[24]!==o?(d=o("The call failed for a reason that is not an access verdict, so it says nothing about the policy."),e[24]=o,e[25]=d):d=e[25];let c;e[26]!==d?(c=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:d}),e[26]=d,e[27]=c):c=e[27];let h;e[28]!==l.message?(h=(0,a.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-errored",role:"alert",children:l.message}),e[28]=l.message,e[29]=h):h=e[29];let g;return e[30]!==m||e[31]!==c||e[32]!==h?(g=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-errored",children:[m,c,h]}),e[30]=m,e[31]=c,e[32]=h,e[33]=g):g=e[33],g}let i;e[34]!==o?(i=o("Not run"),e[34]=o,e[35]=i):i=e[35];let n;e[36]!==i?(n=(0,a.jsx)(E,{variant:"outline",children:i}),e[36]=i,e[37]=n):n=e[37];let s;e[38]!==l.message?(s=(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"pp-invalid",role:"status",children:l.message}),e[38]=l.message,e[39]=s):s=e[39];let p;return e[40]!==n||e[41]!==s?(p=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-invalid",children:[n,s]}),e[40]=n,e[41]=s,e[42]=p):p=e[42],p},"Be"),He=f(t=>{let e=(0,ee.c)(17),{disabled:l,executesWrites:o,functionPath:i,onRun:n,running:s,userId:p}=t,r=K(),m;e[0]!==s||e[1]!==r?(m=r(s?"Probing\u2026":"Run probe"),e[0]=s,e[1]=r,e[2]=m):m=e[2];let d=m,c;e[3]!==l||e[4]!==o||e[5]!==i||e[6]!==d||e[7]!==n||e[8]!==r||e[9]!==p?(c=o?(0,a.jsx)(Ce,{confirmLabel:r("This will execute `{functionPath}` as user `{userId}`.",{functionPath:i,userId:p}),disabled:l,onConfirm:n,testId:"pp-run",children:d}):(0,a.jsx)(z,{"data-testid":"pp-run",disabled:l,onClick:n,type:"button",children:d}),e[3]=l,e[4]=o,e[5]=i,e[6]=d,e[7]=n,e[8]=r,e[9]=p,e[10]=c):c=e[10];let h;e[11]!==r||e[12]!==p?(h=p!==""&&(0,a.jsx)(E,{"data-testid":"pp-as-badge",variant:"secondary",children:r("as {userId}",{userId:p})}),e[11]=r,e[12]=p,e[13]=h):h=e[13];let g;return e[14]!==c||e[15]!==h?(g=(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[c,h]}),e[14]=c,e[15]=h,e[16]=g):g=e[16],g},"je"),Ke=f(({functions:t,prefill:e,runAsIdentity:l=!1}={})=>{let o=se(),i=K(),n=Be(),[s,p]=(0,y.useState)(null),[r,m]=(0,y.useState)(null),d=t??s??[],[c,h]=(0,y.useState)(""),[g,$]=(0,y.useState)("{}"),[H,C]=(0,y.useState)(""),[w,S]=(0,y.useState)(""),[A,k]=(0,y.useState)(!1),[R,x]=(0,y.useState)(null),[I,v]=(0,y.useState)(null),[F,D]=(0,y.useState)(!1),T=(0,y.useRef)(-1),P=(0,y.useRef)(0);(0,y.useEffect)(()=>{if(t!==void 0)return;let u=!1;return o.listFunctions().then(N=>(u||p(N),N)).catch(N=>{u||m(he(N))}),()=>{u=!0}},[o,t]),(0,y.useEffect)(()=>{if(e===void 0||T.current===e.nonce)return;T.current=e.nonce,P.current+=1;let u=e.functionPath;queueMicrotask(()=>{h(u),x(null)})},[e]);let Q=F?d:d.filter(u=>u.kind==="query"||u.path===c),b=c===""?Q[0]?.path??"":c,L=d.find(u=>u.path===b),Z=b!==""&&L?.kind!=="query",O=f(async()=>{if(b==="")return;let u;try{u=g.trim()===""?{}:pe(JSON.parse(g))}catch(J){v(i("Invalid JSON args: {message}",{message:J.message})),x(null);return}P.current+=1;let N=P.current;v(null),k(!0);try{let J=await n({args:u,functionPath:b,shardKey:H.trim(),userId:w.trim()});N===P.current&&x(J)}finally{k(!1)}},"L"),q=f(()=>{ae(O())},"$"),U=f(u=>{h(u.target.value)},"U"),W=f(u=>{$(u.target.value)},"W"),j=f(u=>{S(u.target.value)},"M"),B=f(u=>{D(u.target.checked),!u.target.checked&&Z&&h("")},"z"),M=!l||A||b==="";return(0,a.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[r!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:r}),!l&&(0,a.jsx)(ce,{description:i("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:i("Set `runAsIdentity` to forge an identity and probe access.")}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)(_,{htmlFor:"pp-function",children:i("Function")}),(0,a.jsx)("select",{"aria-label":i("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:U,value:b,children:Q.map(u=>(0,a.jsxs)("option",{value:u.path,children:[u.path," (",u.kind,")"]},u.path))}),(0,a.jsxs)(_,{className:"flex items-center gap-1.5 text-xs font-normal",htmlFor:"pp-include-writes",children:[(0,a.jsx)("input",{checked:F,className:"size-4 accent-primary","data-testid":"pp-include-writes",id:"pp-include-writes",onChange:B,type:"checkbox"}),i("Include mutations and actions")]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)(_,{htmlFor:"pp-args",children:i("Arguments")}),(0,a.jsx)(Se,{"aria-label":i("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:W,value:g})]}),(0,a.jsx)(ve,{onChange:C,testId:"pp-shard",value:H}),(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)(_,{htmlFor:"pp-user",children:i("Run as (userId)")}),(0,a.jsx)(V,{"aria-label":i("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:j,placeholder:i("Required \u2014 the identity to probe as"),value:w})]}),(0,a.jsx)(He,{disabled:M,executesWrites:Z,functionPath:b,onRun:q,running:A,userId:w.trim()})]}),I!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:I}),R!==null&&(0,a.jsx)(Je,{outcome:R})]})},"Qe"),Ve="/__lunora/policy-scaffold",Qe={"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."},Ze=f(async t=>{let e=await fetch(Ve,{body:JSON.stringify(t),headers:{"Content-Type":"application/json"},method:"POST"}),l=await e.json();if(l.needsManualEdit===!0)return{kind:"needs-manual-edit",message:l.message??"This change must be made by hand."};if(e.ok)return{diagnostics:l.diagnostics??[],kind:"ok",label:l.fileName??l.exportName??""};let o=l.error;return{kind:"error",message:o===void 0?`policy scaffold failed (${String(e.status)})`:Qe[o]??o}},"Ke"),Ae={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Ye=f(()=>{let t=(0,ee.c)(69),e=K(),[l,o]=(0,y.useState)(null),[i,n]=(0,y.useState)(!1),[s,p]=(0,y.useState)(null),[r,m]=(0,y.useState)(Ae),d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=f(te=>{let Y=te.target.name,{value:G}=te.target;m(Re=>({...Re,[Y]:G}))},"c"),t[0]=d):d=t[0];let c=d,h;t[1]===Symbol.for("react.memo_cache_sentinel")?(h=f(()=>{o(null),m(Ae)},"h"),t[1]=h):h=t[1];let g=h,$;t[2]===Symbol.for("react.memo_cache_sentinel")?($=f(async te=>{n(!0),p(null);try{let Y=await Ze(te);p(Y),Y.kind==="ok"&&g()}catch(Y){let G=Y;p({kind:"error",message:G instanceof Error?G.message:String(G)})}n(!1)},"F"),t[2]=$):$=t[2];let H=$,C;t[3]!==r.policyName||t[4]!==r.tableName?(C=f(()=>{ae(H({kind:"scaffoldPolicy",name:r.policyName.trim(),table:r.tableName.trim()}))},"w"),t[3]=r.policyName,t[4]=r.tableName,t[5]=C):C=t[5];let w=C,S;t[6]!==r.exportName||t[7]!==r.filePath||t[8]!==r.policies?(S=f(()=>{ae(H({exportName:r.exportName.trim(),filePath:r.filePath.trim(),kind:"wireRls",policies:r.policies.trim()}))},"P"),t[6]=r.exportName,t[7]=r.filePath,t[8]=r.policies,t[9]=S):S=t[9];let A=S,k;t[10]===Symbol.for("react.memo_cache_sentinel")?(k=f(()=>{p(null),o("scaffold")},"k"),t[10]=k):k=t[10];let R=k,x;t[11]===Symbol.for("react.memo_cache_sentinel")?(x=f(()=>{p(null),o("wire")},"x"),t[11]=x):x=t[11];let I=x,v;t[12]!==e?(v=e("Scaffold access rules"),t[12]=e,t[13]=v):v=t[13];let F;t[14]!==v?(F=(0,a.jsx)(ye,{children:v}),t[14]=v,t[15]=F):F=t[15];let D;t[16]!==e?(D=e("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only."),t[16]=e,t[17]=D):D=t[17];let T;t[18]!==D?(T=(0,a.jsx)(be,{children:D}),t[18]=D,t[19]=T):T=t[19];let P;t[20]!==T||t[21]!==F?(P=(0,a.jsxs)(ge,{children:[F,T]}),t[20]=T,t[21]=F,t[22]=P):P=t[22];let Q=l==="scaffold"?"default":"outline",b;t[23]!==e?(b=e("New policy file"),t[23]=e,t[24]=b):b=t[24];let L;t[25]!==Q||t[26]!==b?(L=(0,a.jsx)(z,{"data-testid":"policy-scaffolder-new",onClick:R,size:"xs",type:"button",variant:Q,children:b}),t[25]=Q,t[26]=b,t[27]=L):L=t[27];let Z=l==="wire"?"default":"outline",O;t[28]!==e?(O=e("Wire into a procedure"),t[28]=e,t[29]=O):O=t[29];let q;t[30]!==Z||t[31]!==O?(q=(0,a.jsx)(z,{"data-testid":"policy-scaffolder-wire",onClick:I,size:"xs",type:"button",variant:Z,children:O}),t[30]=Z,t[31]=O,t[32]=q):q=t[32];let U;t[33]!==L||t[34]!==q?(U=(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[L,q]}),t[33]=L,t[34]=q,t[35]=U):U=t[35];let W;t[36]!==i||t[37]!==r.policyName||t[38]!==r.tableName||t[39]!==l||t[40]!==w||t[41]!==e?(W=l==="scaffold"&&(0,a.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-name",children:e("Policy name")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:c,value:r.policyName})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-table",children:e("Table name")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:c,value:r.tableName})]}),(0,a.jsx)(z,{"data-testid":"policy-scaffolder-create",disabled:i||r.policyName.trim()===""||r.tableName.trim()==="",onClick:w,size:"xs",type:"button",children:e(i?"Creating\u2026":"Create policy file")}),(0,a.jsx)(z,{onClick:g,size:"xs",type:"button",variant:"ghost",children:e("Cancel")})]}),t[36]=i,t[37]=r.policyName,t[38]=r.tableName,t[39]=l,t[40]=w,t[41]=e,t[42]=W):W=t[42];let j;t[43]!==i||t[44]!==r.exportName||t[45]!==r.filePath||t[46]!==r.policies||t[47]!==l||t[48]!==A||t[49]!==e?(j=l==="wire"&&(0,a.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-file",children:e("Procedure file path")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:c,value:r.filePath})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-export",children:e("Exported procedure")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:c,value:r.exportName})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-policies",children:e("Policy set identifier")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:c,value:r.policies})]}),(0,a.jsx)(z,{"data-testid":"policy-scaffolder-apply",disabled:i||r.filePath.trim()===""||r.exportName.trim()===""||r.policies.trim()==="",onClick:A,size:"xs",type:"button",children:e(i?"Wiring\u2026":"Wire RLS")}),(0,a.jsx)(z,{onClick:g,size:"xs",type:"button",variant:"ghost",children:e("Cancel")})]}),t[43]=i,t[44]=r.exportName,t[45]=r.filePath,t[46]=r.policies,t[47]=l,t[48]=A,t[49]=e,t[50]=j):j=t[50];let B;t[51]!==s?(B=s?.kind==="error"&&(0,a.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:s.message}),t[51]=s,t[52]=B):B=t[52];let M;t[53]!==s?.kind||t[54]!==e?(M=s?.kind==="needs-manual-edit"&&(0,a.jsx)("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:e("This change must be made by hand \u2014 the scaffolder only adds new, deny-by-default rules.")}),t[53]=s?.kind,t[54]=e,t[55]=M):M=t[55];let u;t[56]!==s||t[57]!==e?(u=s?.kind==="ok"&&(0,a.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[(0,a.jsx)("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:e("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:s.label})}),s.diagnostics.length>0&&(0,a.jsx)("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:s.diagnostics.map(Ge)})]}),t[56]=s,t[57]=e,t[58]=u):u=t[58];let N;t[59]!==U||t[60]!==W||t[61]!==j||t[62]!==B||t[63]!==M||t[64]!==u?(N=(0,a.jsxs)(de,{children:[U,W,j,B,M,u]}),t[59]=U,t[60]=W,t[61]=j,t[62]=B,t[63]=M,t[64]=u,t[65]=N):N=t[65];let J;return t[66]!==P||t[67]!==N?(J=(0,a.jsxs)(ne,{"data-testid":"policy-scaffolder",size:"sm",children:[P,N]}),t[66]=P,t[67]=N,t[68]=J):J=t[68],J},"Ve");function Ge(t){return(0,a.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:t},t)}f(Ge,"Ye");var gt=f(({functions:t,runAsIdentity:e=!1,schemaEditable:l=!1}={})=>{let o=K(),[i,n]=(0,y.useState)(void 0),s=f((p,r,m)=>{m!==""&&n(d=>({functionPath:m,nonce:(d?.nonce??0)+1}))},"i");return(0,a.jsxs)("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[(0,a.jsxs)("section",{className:"flex flex-col gap-3",children:[(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o("Permissions")})}),(0,a.jsx)(Oe,{onProbe:s})]}),(0,a.jsx)("section",{className:"flex flex-col gap-3",children:(0,a.jsxs)(ne,{className:"gap-0 py-0",children:[(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o("Probe")})}),(0,a.jsxs)(de,{className:"px-4 py-4",children:[(0,a.jsx)("p",{className:"mb-3 text-sm text-muted-foreground",children:o("Pick a function and an identity, then run it to see the access outcome.")}),(0,a.jsx)(Ke,{functions:t,prefill:i,runAsIdentity:e})]})]})}),l&&(0,a.jsx)("section",{className:"flex flex-col gap-2",children:(0,a.jsx)(Ye,{})})]})},"bt");export{gt as PermissionsPanel};
|
|
1
|
+
import{a as Ie}from"./chunk-ELSQ4FVH.js";import{a as Se}from"./chunk-PJUVJTDR.js";import{a as _}from"./chunk-TKBTZX4K.js";import{a as Ce}from"./chunk-YEVTA35E.js";import{a as ve}from"./chunk-FHLODLBC.js";import"./chunk-3D67ZJRW.js";import"./chunk-ZSWW2UGP.js";import{i as V}from"./chunk-IHGRWY3Y.js";import"./chunk-OWRKSQPE.js";import"./chunk-4EPW63HS.js";import{a as z}from"./chunk-V3BE427M.js";import"./chunk-CKEQX655.js";import"./chunk-UD5REVU2.js";import{a as ce}from"./chunk-RCXNYW7P.js";import{b as E}from"./chunk-UQA2AJGI.js";import"./chunk-T3ZCW3RG.js";import{a as Ne}from"./chunk-YEXTJUKQ.js";import"./chunk-LSEUUZN4.js";import{a as ke,b as we,c as Pe,d as me,e as le,f as ie}from"./chunk-7QEZ2SFW.js";import"./chunk-OZAOWE7T.js";import"./chunk-BBDTJG2K.js";import"./chunk-4PI2OSSP.js";import{a as X}from"./chunk-2W4UO5BC.js";import{c as re}from"./chunk-4N76XUNG.js";import{a as ne,b as ge,c as ye,d as be,e as de}from"./chunk-OK2QU2EV.js";import{d as pe,m as se}from"./chunk-SHHGIT7M.js";import"./chunk-ZPQBVYNN.js";import{B as K,h as ue,i as fe,j as he,p as xe,s as ae}from"./chunk-GNI37YCV.js";import"./chunk-PDBW6GTJ.js";import{a as Te}from"./chunk-GWNGVKLG.js";import{a as Fe,b as Ee}from"./chunk-6G3E4PJ2.js";import{a as f,d as oe}from"./chunk-5PEAXTYQ.js";var y=oe(Fe(),1);var ee=oe(Te(),1);var a=oe(Ee(),1);var _e=["read","insert","update","delete"],ze=f((t,e)=>({delete:t("Delete"),insert:t("Insert"),read:t("Read"),update:t("Update")})[e],"_e"),$e=f(t=>t.file===""?t.procedure:`${t.file}:${t.procedure}`,"Fe"),De=f(t=>{let e=new Set;for(let l of t?.advisories??[])if(l.name==="rls_uncovered_table"){let{table:o}=l.metadata;typeof o=="string"&&o!==""&&e.add(o)}return e},"Oe"),Le=f((t,e,l)=>{let o=new Map,i=f(n=>{let s=o.get(n);if(s!==void 0)return s;let p={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:n,uncovered:l.has(n)};return o.set(n,p),p},"r");for(let n of t)i(n.table).cells[n.on]={path:$e(n),procedure:n.procedure};for(let n of e)i(n.table).maskedColumns.add(n.column);for(let n of l)i(n);return[...o.values()].toSorted((n,s)=>n.table.localeCompare(s.table))},"De"),Oe=f(t=>{let e=(0,ee.c)(17),l;e[0]!==t?(l=t===void 0?{}:t,e[0]=t,e[1]=l):l=e[1];let{onProbe:o}=l,i=K(),n,s;e[2]===Symbol.for("react.memo_cache_sentinel")?(n={},s={live:!0},e[2]=n,e[3]=s):(n=e[2],s=e[3]);let p=re(X.rlsPolicies,n,s),r;e[4]===Symbol.for("react.memo_cache_sentinel")?(r={},e[4]=r):r=e[4];let m=re(X.maskPolicies,r),d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d={},e[5]=d):d=e[5];let c=re(X.getAdvisories,d),h;if(e[6]!==c.data||e[7]!==m.data||e[8]!==o||e[9]!==p||e[10]!==i){let g=null;p.data!==void 0&&(g=Array.isArray(p.data.policies)?p.data.policies:[]);let $=Array.isArray(m.data?.columns)?m.data.columns:[],H=c.data??null,{error:C,errorSource:w,liveError:S}=p,A=g===null?[]:Le(g,$,De(H)),k;e[12]!==S?(k=(0,a.jsx)("div",{className:"flex items-center justify-end",children:(0,a.jsx)(Ie,{message:S,prefix:"pm"})}),e[12]=S,e[13]=k):k=e[13];let R;e[14]!==C||e[15]!==w?(R=C!==null&&(0,a.jsx)(Ne,{error:w,testId:"pm-error"}),e[14]=C,e[15]=w,e[16]=R):R=e[16],h=(0,a.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[k,R,g!==null&&A.length===0?(0,a.jsx)(ce,{description:i("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:i("No policy")}):(0,a.jsxs)(ke,{"data-testid":"pm-table",children:[(0,a.jsx)(we,{children:(0,a.jsxs)(me,{children:[(0,a.jsx)(le,{children:i("Table")}),_e.map(x=>(0,a.jsx)(le,{children:ze(i,x)},x)),(0,a.jsx)(le,{children:i("Masked columns")})]})}),(0,a.jsx)(Pe,{children:A.map(x=>(0,a.jsxs)(me,{"data-testid":`pm-row-${x.table}`,children:[(0,a.jsx)(ie,{className:"font-mono text-xs",children:(0,a.jsxs)("span",{className:"flex items-center gap-1.5",children:[x.table,x.uncovered&&(0,a.jsx)(E,{"data-testid":`pm-uncovered-${x.table}`,title:i("Uncovered \u2014 reachable without a policy"),variant:"destructive",children:i("Uncovered \u2014 reachable without a policy")})]})}),_e.map(I=>{let v=x.cells[I];return(0,a.jsx)(ie,{"data-testid":`pm-cell-${x.table}-${I}`,children:v.procedure===void 0?(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:i("No policy")}):(0,a.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,a.jsx)(E,{variant:"secondary",children:i("Covered by {procedure}",{procedure:v.procedure})}),o!==void 0&&(0,a.jsx)(z,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${x.table}-${I}`,onClick:f(()=>{o(x.table,I,v.path??"")},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Probe this")})]})},I)}),(0,a.jsx)(ie,{children:x.maskedColumns.size===0?(0,a.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,a.jsx)("span",{className:"flex flex-wrap gap-1",children:[...x.maskedColumns].map(qe)})})]},x.table))})]})]}),e[6]=c.data,e[7]=m.data,e[8]=o,e[9]=p,e[10]=i,e[11]=h}else h=e[11];return h},"Le");function qe(t){return(0,a.jsx)(E,{variant:"outline",children:t},t)}f(qe,"$e");var Ue=ue(X.runAs),We=new Set(["FORBIDDEN","RLS_REQUIRED","UNAUTHORIZED"]),je=f(t=>{let e=t?.code;return typeof e=="string"?e:void 0},"Me"),Be=f(()=>{let t=se();return async({args:e,functionPath:l,shardKey:o="",userId:i})=>{if(i.trim()==="")return{kind:"invalid",message:"No identity to probe: enter the userId whose access you want to test."};let n=Ue;try{return{kind:"allowed",value:await t.query(n,{args:e,functionPath:l,userId:i},fe(o))}}catch(s){let p=s instanceof Error?s.message:String(s),r=je(s);return r!==void 0&&We.has(r)?{kind:"denied",message:p}:{kind:"errored",message:p}}}},"ze"),Me=f(t=>t===void 0?"undefined":JSON.stringify(t,xe,2),"qe"),Je=f(t=>{let e=(0,ee.c)(43),{outcome:l}=t,o=K();if(l.kind==="allowed"){let r;e[0]!==o?(r=o("Allowed"),e[0]=o,e[1]=r):r=e[1];let m;e[2]!==r?(m=(0,a.jsx)(E,{variant:"secondary",children:r}),e[2]=r,e[3]=m):m=e[3];let d;e[4]!==l.value?(d=Me(l.value),e[4]=l.value,e[5]=d):d=e[5];let c;e[6]!==d?(c=(0,a.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:d}),e[6]=d,e[7]=c):c=e[7];let h;return e[8]!==m||e[9]!==c?(h=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[m,c]}),e[8]=m,e[9]=c,e[10]=h):h=e[10],h}if(l.kind==="denied"){let r;e[11]!==o?(r=o("Denied"),e[11]=o,e[12]=r):r=e[12];let m;e[13]!==r?(m=(0,a.jsx)(E,{variant:"destructive",children:r}),e[13]=r,e[14]=m):m=e[14];let d;e[15]!==l.message?(d=(0,a.jsx)("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:l.message}),e[15]=l.message,e[16]=d):d=e[16];let c;return e[17]!==m||e[18]!==d?(c=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[m,d]}),e[17]=m,e[18]=d,e[19]=c):c=e[19],c}if(l.kind==="errored"){let r;e[20]!==o?(r=o("Errored"),e[20]=o,e[21]=r):r=e[21];let m;e[22]!==r?(m=(0,a.jsx)(E,{variant:"outline",children:r}),e[22]=r,e[23]=m):m=e[23];let d;e[24]!==o?(d=o("The call failed for a reason that is not an access verdict, so it says nothing about the policy."),e[24]=o,e[25]=d):d=e[25];let c;e[26]!==d?(c=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:d}),e[26]=d,e[27]=c):c=e[27];let h;e[28]!==l.message?(h=(0,a.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-errored",role:"alert",children:l.message}),e[28]=l.message,e[29]=h):h=e[29];let g;return e[30]!==m||e[31]!==c||e[32]!==h?(g=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-errored",children:[m,c,h]}),e[30]=m,e[31]=c,e[32]=h,e[33]=g):g=e[33],g}let i;e[34]!==o?(i=o("Not run"),e[34]=o,e[35]=i):i=e[35];let n;e[36]!==i?(n=(0,a.jsx)(E,{variant:"outline",children:i}),e[36]=i,e[37]=n):n=e[37];let s;e[38]!==l.message?(s=(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"pp-invalid",role:"status",children:l.message}),e[38]=l.message,e[39]=s):s=e[39];let p;return e[40]!==n||e[41]!==s?(p=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-invalid",children:[n,s]}),e[40]=n,e[41]=s,e[42]=p):p=e[42],p},"Be"),He=f(t=>{let e=(0,ee.c)(17),{disabled:l,executesWrites:o,functionPath:i,onRun:n,running:s,userId:p}=t,r=K(),m;e[0]!==s||e[1]!==r?(m=r(s?"Probing\u2026":"Run probe"),e[0]=s,e[1]=r,e[2]=m):m=e[2];let d=m,c;e[3]!==l||e[4]!==o||e[5]!==i||e[6]!==d||e[7]!==n||e[8]!==r||e[9]!==p?(c=o?(0,a.jsx)(Ce,{confirmLabel:r("This will execute `{functionPath}` as user `{userId}`.",{functionPath:i,userId:p}),disabled:l,onConfirm:n,testId:"pp-run",children:d}):(0,a.jsx)(z,{"data-testid":"pp-run",disabled:l,onClick:n,type:"button",children:d}),e[3]=l,e[4]=o,e[5]=i,e[6]=d,e[7]=n,e[8]=r,e[9]=p,e[10]=c):c=e[10];let h;e[11]!==r||e[12]!==p?(h=p!==""&&(0,a.jsx)(E,{"data-testid":"pp-as-badge",variant:"secondary",children:r("as {userId}",{userId:p})}),e[11]=r,e[12]=p,e[13]=h):h=e[13];let g;return e[14]!==c||e[15]!==h?(g=(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[c,h]}),e[14]=c,e[15]=h,e[16]=g):g=e[16],g},"je"),Ke=f(({functions:t,prefill:e,runAsIdentity:l=!1}={})=>{let o=se(),i=K(),n=Be(),[s,p]=(0,y.useState)(null),[r,m]=(0,y.useState)(null),d=t??s??[],[c,h]=(0,y.useState)(""),[g,$]=(0,y.useState)("{}"),[H,C]=(0,y.useState)(""),[w,S]=(0,y.useState)(""),[A,k]=(0,y.useState)(!1),[R,x]=(0,y.useState)(null),[I,v]=(0,y.useState)(null),[F,D]=(0,y.useState)(!1),T=(0,y.useRef)(-1),P=(0,y.useRef)(0);(0,y.useEffect)(()=>{if(t!==void 0)return;let u=!1;return o.listFunctions().then(N=>(u||p(N),N)).catch(N=>{u||m(he(N))}),()=>{u=!0}},[o,t]),(0,y.useEffect)(()=>{if(e===void 0||T.current===e.nonce)return;T.current=e.nonce,P.current+=1;let u=e.functionPath;queueMicrotask(()=>{h(u),x(null)})},[e]);let Q=F?d:d.filter(u=>u.kind==="query"||u.path===c),b=c===""?Q[0]?.path??"":c,L=d.find(u=>u.path===b),Z=b!==""&&L?.kind!=="query",O=f(async()=>{if(b==="")return;let u;try{u=g.trim()===""?{}:pe(JSON.parse(g))}catch(J){v(i("Invalid JSON args: {message}",{message:J.message})),x(null);return}P.current+=1;let N=P.current;v(null),k(!0);try{let J=await n({args:u,functionPath:b,shardKey:H.trim(),userId:w.trim()});N===P.current&&x(J)}finally{k(!1)}},"L"),q=f(()=>{ae(O())},"$"),U=f(u=>{h(u.target.value)},"U"),W=f(u=>{$(u.target.value)},"W"),j=f(u=>{S(u.target.value)},"M"),B=f(u=>{D(u.target.checked),!u.target.checked&&Z&&h("")},"z"),M=!l||A||b==="";return(0,a.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[r!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:r}),!l&&(0,a.jsx)(ce,{description:i("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:i("Set `runAsIdentity` to forge an identity and probe access.")}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)(_,{htmlFor:"pp-function",children:i("Function")}),(0,a.jsx)("select",{"aria-label":i("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:U,value:b,children:Q.map(u=>(0,a.jsxs)("option",{value:u.path,children:[u.path," (",u.kind,")"]},u.path))}),(0,a.jsxs)(_,{className:"flex items-center gap-1.5 text-xs font-normal",htmlFor:"pp-include-writes",children:[(0,a.jsx)("input",{checked:F,className:"size-4 accent-primary","data-testid":"pp-include-writes",id:"pp-include-writes",onChange:B,type:"checkbox"}),i("Include mutations and actions")]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)(_,{htmlFor:"pp-args",children:i("Arguments")}),(0,a.jsx)(Se,{"aria-label":i("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:W,value:g})]}),(0,a.jsx)(ve,{onChange:C,testId:"pp-shard",value:H}),(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)(_,{htmlFor:"pp-user",children:i("Run as (userId)")}),(0,a.jsx)(V,{"aria-label":i("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:j,placeholder:i("Required \u2014 the identity to probe as"),value:w})]}),(0,a.jsx)(He,{disabled:M,executesWrites:Z,functionPath:b,onRun:q,running:A,userId:w.trim()})]}),I!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:I}),R!==null&&(0,a.jsx)(Je,{outcome:R})]})},"Qe"),Ve="/__lunora/policy-scaffold",Qe={"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."},Ze=f(async t=>{let e=await fetch(Ve,{body:JSON.stringify(t),headers:{"Content-Type":"application/json"},method:"POST"}),l=await e.json();if(l.needsManualEdit===!0)return{kind:"needs-manual-edit",message:l.message??"This change must be made by hand."};if(e.ok)return{diagnostics:l.diagnostics??[],kind:"ok",label:l.fileName??l.exportName??""};let o=l.error;return{kind:"error",message:o===void 0?`policy scaffold failed (${String(e.status)})`:Qe[o]??o}},"Ke"),Ae={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Ye=f(()=>{let t=(0,ee.c)(69),e=K(),[l,o]=(0,y.useState)(null),[i,n]=(0,y.useState)(!1),[s,p]=(0,y.useState)(null),[r,m]=(0,y.useState)(Ae),d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=f(te=>{let Y=te.target.name,{value:G}=te.target;m(Re=>({...Re,[Y]:G}))},"c"),t[0]=d):d=t[0];let c=d,h;t[1]===Symbol.for("react.memo_cache_sentinel")?(h=f(()=>{o(null),m(Ae)},"h"),t[1]=h):h=t[1];let g=h,$;t[2]===Symbol.for("react.memo_cache_sentinel")?($=f(async te=>{n(!0),p(null);try{let Y=await Ze(te);p(Y),Y.kind==="ok"&&g()}catch(Y){let G=Y;p({kind:"error",message:G instanceof Error?G.message:String(G)})}n(!1)},"F"),t[2]=$):$=t[2];let H=$,C;t[3]!==r.policyName||t[4]!==r.tableName?(C=f(()=>{ae(H({kind:"scaffoldPolicy",name:r.policyName.trim(),table:r.tableName.trim()}))},"w"),t[3]=r.policyName,t[4]=r.tableName,t[5]=C):C=t[5];let w=C,S;t[6]!==r.exportName||t[7]!==r.filePath||t[8]!==r.policies?(S=f(()=>{ae(H({exportName:r.exportName.trim(),filePath:r.filePath.trim(),kind:"wireRls",policies:r.policies.trim()}))},"P"),t[6]=r.exportName,t[7]=r.filePath,t[8]=r.policies,t[9]=S):S=t[9];let A=S,k;t[10]===Symbol.for("react.memo_cache_sentinel")?(k=f(()=>{p(null),o("scaffold")},"k"),t[10]=k):k=t[10];let R=k,x;t[11]===Symbol.for("react.memo_cache_sentinel")?(x=f(()=>{p(null),o("wire")},"x"),t[11]=x):x=t[11];let I=x,v;t[12]!==e?(v=e("Scaffold access rules"),t[12]=e,t[13]=v):v=t[13];let F;t[14]!==v?(F=(0,a.jsx)(ye,{children:v}),t[14]=v,t[15]=F):F=t[15];let D;t[16]!==e?(D=e("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only."),t[16]=e,t[17]=D):D=t[17];let T;t[18]!==D?(T=(0,a.jsx)(be,{children:D}),t[18]=D,t[19]=T):T=t[19];let P;t[20]!==T||t[21]!==F?(P=(0,a.jsxs)(ge,{children:[F,T]}),t[20]=T,t[21]=F,t[22]=P):P=t[22];let Q=l==="scaffold"?"default":"outline",b;t[23]!==e?(b=e("New policy file"),t[23]=e,t[24]=b):b=t[24];let L;t[25]!==Q||t[26]!==b?(L=(0,a.jsx)(z,{"data-testid":"policy-scaffolder-new",onClick:R,size:"xs",type:"button",variant:Q,children:b}),t[25]=Q,t[26]=b,t[27]=L):L=t[27];let Z=l==="wire"?"default":"outline",O;t[28]!==e?(O=e("Wire into a procedure"),t[28]=e,t[29]=O):O=t[29];let q;t[30]!==Z||t[31]!==O?(q=(0,a.jsx)(z,{"data-testid":"policy-scaffolder-wire",onClick:I,size:"xs",type:"button",variant:Z,children:O}),t[30]=Z,t[31]=O,t[32]=q):q=t[32];let U;t[33]!==L||t[34]!==q?(U=(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[L,q]}),t[33]=L,t[34]=q,t[35]=U):U=t[35];let W;t[36]!==i||t[37]!==r.policyName||t[38]!==r.tableName||t[39]!==l||t[40]!==w||t[41]!==e?(W=l==="scaffold"&&(0,a.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-name",children:e("Policy name")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:c,value:r.policyName})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-table",children:e("Table name")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:c,value:r.tableName})]}),(0,a.jsx)(z,{"data-testid":"policy-scaffolder-create",disabled:i||r.policyName.trim()===""||r.tableName.trim()==="",onClick:w,size:"xs",type:"button",children:e(i?"Creating\u2026":"Create policy file")}),(0,a.jsx)(z,{onClick:g,size:"xs",type:"button",variant:"ghost",children:e("Cancel")})]}),t[36]=i,t[37]=r.policyName,t[38]=r.tableName,t[39]=l,t[40]=w,t[41]=e,t[42]=W):W=t[42];let j;t[43]!==i||t[44]!==r.exportName||t[45]!==r.filePath||t[46]!==r.policies||t[47]!==l||t[48]!==A||t[49]!==e?(j=l==="wire"&&(0,a.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-file",children:e("Procedure file path")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:c,value:r.filePath})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-export",children:e("Exported procedure")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:c,value:r.exportName})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-policies",children:e("Policy set identifier")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:c,value:r.policies})]}),(0,a.jsx)(z,{"data-testid":"policy-scaffolder-apply",disabled:i||r.filePath.trim()===""||r.exportName.trim()===""||r.policies.trim()==="",onClick:A,size:"xs",type:"button",children:e(i?"Wiring\u2026":"Wire RLS")}),(0,a.jsx)(z,{onClick:g,size:"xs",type:"button",variant:"ghost",children:e("Cancel")})]}),t[43]=i,t[44]=r.exportName,t[45]=r.filePath,t[46]=r.policies,t[47]=l,t[48]=A,t[49]=e,t[50]=j):j=t[50];let B;t[51]!==s?(B=s?.kind==="error"&&(0,a.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:s.message}),t[51]=s,t[52]=B):B=t[52];let M;t[53]!==s?.kind||t[54]!==e?(M=s?.kind==="needs-manual-edit"&&(0,a.jsx)("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:e("This change must be made by hand \u2014 the scaffolder only adds new, deny-by-default rules.")}),t[53]=s?.kind,t[54]=e,t[55]=M):M=t[55];let u;t[56]!==s||t[57]!==e?(u=s?.kind==="ok"&&(0,a.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[(0,a.jsx)("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:e("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:s.label})}),s.diagnostics.length>0&&(0,a.jsx)("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:s.diagnostics.map(Ge)})]}),t[56]=s,t[57]=e,t[58]=u):u=t[58];let N;t[59]!==U||t[60]!==W||t[61]!==j||t[62]!==B||t[63]!==M||t[64]!==u?(N=(0,a.jsxs)(de,{children:[U,W,j,B,M,u]}),t[59]=U,t[60]=W,t[61]=j,t[62]=B,t[63]=M,t[64]=u,t[65]=N):N=t[65];let J;return t[66]!==P||t[67]!==N?(J=(0,a.jsxs)(ne,{"data-testid":"policy-scaffolder",size:"sm",children:[P,N]}),t[66]=P,t[67]=N,t[68]=J):J=t[68],J},"Ve");function Ge(t){return(0,a.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:t},t)}f(Ge,"Ye");var gt=f(({functions:t,runAsIdentity:e=!1,schemaEditable:l=!1}={})=>{let o=K(),[i,n]=(0,y.useState)(void 0),s=f((p,r,m)=>{m!==""&&n(d=>({functionPath:m,nonce:(d?.nonce??0)+1}))},"i");return(0,a.jsxs)("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[(0,a.jsxs)("section",{className:"flex flex-col gap-3",children:[(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o("Permissions")})}),(0,a.jsx)(Oe,{onProbe:s})]}),(0,a.jsx)("section",{className:"flex flex-col gap-3",children:(0,a.jsxs)(ne,{className:"gap-0 py-0",children:[(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o("Probe")})}),(0,a.jsxs)(de,{className:"px-4 py-4",children:[(0,a.jsx)("p",{className:"mb-3 text-sm text-muted-foreground",children:o("Pick a function and an identity, then run it to see the access outcome.")}),(0,a.jsx)(Ke,{functions:t,prefill:i,runAsIdentity:e})]})]})}),l&&(0,a.jsx)("section",{className:"flex flex-col gap-2",children:(0,a.jsx)(Ye,{})})]})},"bt");export{gt as PermissionsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Pe,b as Re}from"./chunk-W4LJQYCI.js";import{a as ce}from"./chunk-YORPLSI5.js";import{a as Te}from"./chunk-QNM2J7MG.js";import"./chunk-ONTGYVAN.js";import{a as de}from"./chunk-P6VNMPWR.js";import{a as Se}from"./chunk-S36FVTKK.js";import{c as Le}from"./chunk-BKI3JMXQ.js";import{a as ke}from"./chunk-ELSQ4FVH.js";import{a as ie}from"./chunk-2DT3QG6Q.js";import{a as xe}from"./chunk-J45HAKBU.js";import{a as be}from"./chunk-FHLODLBC.js";import{b as ve}from"./chunk-3D67ZJRW.js";import"./chunk-ZSWW2UGP.js";import"./chunk-RTS5G3ET.js";import"./chunk-QRA7AKYO.js";import{i as D}from"./chunk-IHGRWY3Y.js";import"./chunk-OWRKSQPE.js";import"./chunk-4EPW63HS.js";import{a as fe}from"./chunk-V3BE427M.js";import"./chunk-CKEQX655.js";import"./chunk-UD5REVU2.js";import{a as J}from"./chunk-RCXNYW7P.js";import{b as ne}from"./chunk-UQA2AJGI.js";import"./chunk-T3ZCW3RG.js";import{a as ye}from"./chunk-IUGNIG6L.js";import"./chunk-LSEUUZN4.js";import{a as we,b as Ne,c as Ce,d as se,e as j,f as B}from"./chunk-7QEZ2SFW.js";import"./chunk-WCWP4EAW.js";import"./chunk-BX7TFVCC.js";import"./chunk-4PI2OSSP.js";import{a as oe}from"./chunk-2W4UO5BC.js";import{c as le}from"./chunk-FBDIQ67D.js";import{m as pe}from"./chunk-FACXM2UB.js";import"./chunk-ZPQBVYNN.js";import{B as z,j as re,k as ge,s as ae,x as W}from"./chunk-GNI37YCV.js";import"./chunk-PDBW6GTJ.js";import{a as Ae}from"./chunk-GWNGVKLG.js";import{a as _e,b as Ue}from"./chunk-6G3E4PJ2.js";import{a as v,d as te}from"./chunk-5PEAXTYQ.js";var K=te(Ae(),1);var I=te(_e(),1);var r=te(Ue(),1);var me=["trace","debug","log","info","warn","error","fatal"],$e="LOG_ARCHIVE_NOT_CONFIGURED",ze={cursor:void 0,error:null,loading:!1,notConfigured:!1,rows:null},De=v((i,e)=>{switch(e.type){case"append":return{...i,cursor:e.cursor,error:null,loading:!1,rows:[...i.rows??[],...e.rows]};case"failed":return{cursor:void 0,error:e.message,loading:!1,notConfigured:!1,rows:null};case"loaded":return{cursor:e.cursor,error:null,loading:!1,notConfigured:!1,rows:e.rows};case"loading":return{...i,error:null,loading:!0,notConfigured:!1};case"notConfigured":return{cursor:void 0,error:null,loading:!1,notConfigured:!0,rows:null};case"pageFailed":return{...i,error:e.message,loading:!1};default:return i}},"De"),je=v(i=>{let e=(0,K.c)(33),{row:t}=i,n;e[0]!==t.fields?(n=ce(t.fields),e[0]=t.fields,e[1]=n):n=e[1];let s=n,o=`lg-archive-row-${String(t.ts)}`,c;e[2]!==t.ts?(c=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=c):c=e[3];let f;e[4]!==c?(f=(0,r.jsx)(B,{className:"tabular-nums whitespace-nowrap text-xs text-muted-foreground",children:c}),e[4]=c,e[5]=f):f=e[5];let m=Pe[t.level],d;e[6]!==t.level||e[7]!==m?(d=(0,r.jsx)(B,{children:(0,r.jsx)(ne,{variant:m,children:t.level})}),e[6]=t.level,e[7]=m,e[8]=d):d=e[8];let a;e[9]!==t.functionPath?(a=(0,r.jsx)(B,{className:"font-mono text-xs",children:t.functionPath}),e[9]=t.functionPath,e[10]=a):a=e[10];let h;e[11]!==t.message?(h=(0,r.jsx)("div",{className:"truncate",title:t.message,children:t.message}),e[11]=t.message,e[12]=h):h=e[12];let l;e[13]!==s?(l=s!==""&&(0,r.jsx)("div",{className:"truncate font-mono text-[11px] text-muted-foreground",title:s,children:s}),e[13]=s,e[14]=l):l=e[14];let u;e[15]!==h||e[16]!==l?(u=(0,r.jsxs)(B,{className:"max-w-md",children:[h,l]}),e[15]=h,e[16]=l,e[17]=u):u=e[17];let g=t.traceId??"\u2014",b;e[18]!==g?(b=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:g}),e[18]=g,e[19]=b):b=e[19];let x=t.shardKey??"\u2014",w;e[20]!==x?(w=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:x}),e[20]=x,e[21]=w):w=e[21];let N=t.userId??"\u2014",y;e[22]!==N?(y=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:N}),e[22]=N,e[23]=y):y=e[23];let T;return e[24]!==u||e[25]!==b||e[26]!==w||e[27]!==y||e[28]!==o||e[29]!==f||e[30]!==d||e[31]!==a?(T=(0,r.jsxs)(se,{"data-testid":o,children:[f,d,a,u,b,w,y]}),e[24]=u,e[25]=b,e[26]=w,e[27]=y,e[28]=o,e[29]=f,e[30]=d,e[31]=a,e[32]=T):T=e[32],T},"Qe"),Be=v(({shardKey:i})=>{let e=pe(),t=z(),[n,s]=(0,I.useState)(""),[o,c]=(0,I.useState)(""),[f,m]=(0,I.useState)(""),[{cursor:d,error:a,loading:h,notConfigured:l,rows:u},g]=(0,I.useReducer)(De,ze),b=ie(n.trim(),400),x=ie(o.trim(),400),w={...b===""?{}:{functionPathPrefix:b},...f===""?{}:{minLevel:f},...i===""?{}:{shardKey:i},...x===""?{}:{userId:x}},N=JSON.stringify(w),y=(0,I.useRef)(N);(0,I.useEffect)(()=>{let p={cancelled:!1};return y.current=N,ae((async()=>{g({type:"loading"});try{let C=await e.queryLogArchive(w);p.cancelled||g({cursor:C.nextCursor,rows:C.rows,type:"loaded"})}catch(C){p.cancelled||g(ge(C)===$e?{type:"notConfigured"}:{message:re(C),type:"failed"})}})()),()=>{p.cancelled=!0}},[e,N]);let T=v(async()=>{if(d===void 0)return;let p=N;g({type:"loading"});try{let C=await e.queryLogArchive({...w,cursor:d});y.current===p&&g({cursor:C.nextCursor,rows:C.rows,type:"append"})}catch(C){y.current===p&&g({message:re(C),type:"pageFailed"})}},"T"),R=v(p=>{s(p.target.value)},"R"),L=v(p=>{c(p.target.value)},"N"),k=v(p=>{m(p.target.value)},"L"),S=v(()=>{ae(T())},"S");return l?(0,r.jsx)(J,{action:(0,r.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline",href:de,rel:"noreferrer",target:"_blank",children:t("Open in Cloudflare")}),description:t("Wire pipelineLogSink to a Cloudflare Pipeline \u2192 R2 Data Catalog table and set R2_SQL_ACCOUNT_ID, R2_SQL_TOKEN, R2_SQL_BUCKET to browse the durable log archive here."),testId:"lg-archive-not-configured",title:t("Log archive not configured")}):(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lg-archive",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(D,{"aria-label":t("Function path prefix"),className:"h-8 w-48","data-testid":"lg-archive-path",onChange:R,placeholder:t("function path\u2026"),value:n}),(0,r.jsx)(D,{"aria-label":t("User id"),className:"h-8 w-40","data-testid":"lg-archive-user",onChange:L,placeholder:t("user id\u2026"),value:o}),(0,r.jsxs)("select",{"aria-label":t("Minimum level"),className:"h-8 rounded-md border border-border bg-background px-2 text-sm","data-testid":"lg-archive-min-level",onChange:k,value:f,children:[(0,r.jsx)("option",{value:"",children:t("min level")}),me.map(p=>(0,r.jsx)("option",{value:p,children:p},p))]})]}),a!==null&&(0,r.jsx)("p",{className:"text-sm text-destructive","data-testid":"lg-archive-error",role:"alert",children:a}),h&&u===null&&a===null&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"lg-archive-loading",children:t("Loading\u2026")}),u!==null&&u.length===0&&(0,r.jsx)(J,{description:t("No archived logs match these filters. The durable archive fills as pipelineLogSink flushes records to R2."),testId:"lg-archive-empty",title:t("No archived logs.")}),u!==null&&u.length>0&&(0,r.jsx)("div",{className:"overflow-hidden rounded-xl border border-border shadow-xs",children:(0,r.jsxs)(we,{"data-testid":"lg-archive-table",children:[(0,r.jsx)(Ne,{children:(0,r.jsxs)(se,{children:[(0,r.jsx)(j,{children:t("Time")}),(0,r.jsx)(j,{children:t("Level")}),(0,r.jsx)(j,{children:t("Function")}),(0,r.jsx)(j,{children:t("Message")}),(0,r.jsx)(j,{children:t("Trace")}),(0,r.jsx)(j,{children:t("Shard")}),(0,r.jsx)(j,{children:t("User")})]})}),(0,r.jsx)(Ce,{children:u.map((p,C)=>(0,r.jsx)(je,{row:p},`${String(p.ts)}-${String(C)}`))})]})}),d!==void 0&&(0,r.jsx)("div",{children:(0,r.jsx)(fe,{"data-testid":"lg-archive-more",disabled:h,onClick:S,size:"sm",variant:"outline",children:t(h?"Loading\u2026":"Load more")})})]})},"ze"),We=v(i=>{let e=(0,K.c)(11),{level:t,onToggle:n,selected:s}=i,o;e[0]!==t||e[1]!==n?(o=v(()=>{n(t)},"o"),e[0]=t,e[1]=n,e[2]=o):o=e[2];let c=o,f=s?"border-border bg-muted font-medium":"border-input text-muted-foreground",m;e[3]!==f?(m=W("rounded-md border px-2 py-1 text-xs",f),e[3]=f,e[4]=m):m=e[4];let d=`logs-level-${t}`,a;return e[5]!==t||e[6]!==c||e[7]!==s||e[8]!==m||e[9]!==d?(a=(0,r.jsx)("button",{"aria-pressed":s,className:m,"data-testid":d,onClick:c,type:"button",children:t}),e[5]=t,e[6]=c,e[7]=s,e[8]=m,e[9]=d,e[10]=a):a=e[10],a},"Ge"),Ve=v(i=>{let e=(0,K.c)(68),{levelFilter:t,onLogPathChange:n,onSearchChange:s,onTimeRangeChange:o,onToggleLevel:c,onToggleSummary:f,pathFilter:m,search:d,showSummary:a,timeRange:h}=i,l=z(),u;e[0]!==l?(u=l("Search messages"),e[0]=l,e[1]=u):u=e[1];let g;e[2]!==l?(g=l("search message"),e[2]=l,e[3]=g):g=e[3];let b;e[4]!==s||e[5]!==d||e[6]!==u||e[7]!==g?(b=(0,r.jsx)(D,{"aria-label":u,className:"h-8 w-48","data-testid":"lg-search",onChange:s,placeholder:g,value:d}),e[4]=s,e[5]=d,e[6]=u,e[7]=g,e[8]=b):b=e[8];let x;e[9]!==l?(x=l("Function path"),e[9]=l,e[10]=x):x=e[10];let w;e[11]!==l?(w=l("filter path"),e[11]=l,e[12]=w):w=e[12];let N;e[13]!==n||e[14]!==m||e[15]!==x||e[16]!==w?(N=(0,r.jsx)(D,{"aria-label":x,className:"h-8 w-40","data-testid":"logs-path-filter",onChange:n,placeholder:w,value:m}),e[13]=n,e[14]=m,e[15]=x,e[16]=w,e[17]=N):N=e[17];let y;e[18]!==l?(y=l("Level filter"),e[18]=l,e[19]=y):y=e[19];let T;e[20]!==t||e[21]!==c?(T=me.map(Q=>(0,r.jsx)(We,{level:Q,onToggle:c,selected:t.has(Q)},Q)),e[20]=t,e[21]=c,e[22]=T):T=e[22];let R;e[23]!==y||e[24]!==T?(R=(0,r.jsx)("div",{"aria-label":y,className:"inline-flex items-center gap-1","data-testid":"logs-level-filter",role:"group",children:T}),e[23]=y,e[24]=T,e[25]=R):R=e[25];let L;e[26]!==l?(L=l("Time range"),e[26]=l,e[27]=L):L=e[27];let k;e[28]!==l?(k=l("All time"),e[28]=l,e[29]=k):k=e[29];let S;e[30]!==k?(S=(0,r.jsx)("option",{value:"all",children:k}),e[30]=k,e[31]=S):S=e[31];let p;e[32]!==l?(p=l("Last 5m"),e[32]=l,e[33]=p):p=e[33];let C;e[34]!==p?(C=(0,r.jsx)("option",{value:"5m",children:p}),e[34]=p,e[35]=C):C=e[35];let q;e[36]!==l?(q=l("Last 15m"),e[36]=l,e[37]=q):q=e[37];let F;e[38]!==q?(F=(0,r.jsx)("option",{value:"15m",children:q}),e[38]=q,e[39]=F):F=e[39];let O;e[40]!==l?(O=l("Last hour"),e[40]=l,e[41]=O):O=e[41];let E;e[42]!==O?(E=(0,r.jsx)("option",{value:"1h",children:O}),e[42]=O,e[43]=E):E=e[43];let M;e[44]!==o||e[45]!==L||e[46]!==S||e[47]!==C||e[48]!==F||e[49]!==E||e[50]!==h?(M=(0,r.jsxs)("select",{"aria-label":L,className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"logs-time-range",onChange:o,value:h,children:[S,C,F,E]}),e[44]=o,e[45]=L,e[46]=S,e[47]=C,e[48]=F,e[49]=E,e[50]=h,e[51]=M):M=e[51];let V=a?"border-border bg-muted font-medium":"border-input text-muted-foreground",_;e[52]!==V?(_=W("h-8 rounded-md border px-3 text-sm",V),e[52]=V,e[53]=_):_=e[53];let U;e[54]!==a||e[55]!==l?(U=l(a?"List":"Summary"),e[54]=a,e[55]=l,e[56]=U):U=e[56];let A;e[57]!==f||e[58]!==a||e[59]!==_||e[60]!==U?(A=(0,r.jsx)("button",{"aria-pressed":a,className:_,"data-testid":"logs-summary-toggle",onClick:f,type:"button",children:U}),e[57]=f,e[58]=a,e[59]=_,e[60]=U,e[61]=A):A=e[61];let $;return e[62]!==M||e[63]!==A||e[64]!==b||e[65]!==N||e[66]!==R?($=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[b,N,R,M,A]}),e[62]=M,e[63]=A,e[64]=b,e[65]=N,e[66]=R,e[67]=$):$=e[67],$},"He"),Qe=v(i=>{let e=(0,K.c)(53),{onOutcomeChange:t,onPathChange:n,onTableChange:s,onUserChange:o,outcomeFilter:c,pathPrefix:f,tableFilter:m,userIdFilter:d}=i,a=z(),h;e[0]!==a?(h=a("Function path"),e[0]=a,e[1]=h):h=e[1];let l;e[2]!==a?(l=a("file:function"),e[2]=a,e[3]=l):l=e[3];let u;e[4]!==n||e[5]!==f||e[6]!==h||e[7]!==l?(u=(0,r.jsx)(D,{"aria-label":h,className:"h-8 w-44","data-testid":"lg-req-path",onChange:n,placeholder:l,value:f}),e[4]=n,e[5]=f,e[6]=h,e[7]=l,e[8]=u):u=e[8];let g;e[9]!==a?(g=a("User id"),e[9]=a,e[10]=g):g=e[10];let b;e[11]!==a?(b=a("userId"),e[11]=a,e[12]=b):b=e[12];let x;e[13]!==o||e[14]!==g||e[15]!==b||e[16]!==d?(x=(0,r.jsx)(D,{"aria-label":g,className:"h-8 w-32","data-testid":"lg-req-user",onChange:o,placeholder:b,value:d}),e[13]=o,e[14]=g,e[15]=b,e[16]=d,e[17]=x):x=e[17];let w;e[18]!==a?(w=a("Table touched"),e[18]=a,e[19]=w):w=e[19];let N;e[20]!==a?(N=a("table"),e[20]=a,e[21]=N):N=e[21];let y;e[22]!==s||e[23]!==w||e[24]!==N||e[25]!==m?(y=(0,r.jsx)(D,{"aria-label":w,className:"h-8 w-32","data-testid":"lg-req-table",onChange:s,placeholder:N,value:m}),e[22]=s,e[23]=w,e[24]=N,e[25]=m,e[26]=y):y=e[26];let T;e[27]!==a?(T=a("Outcome filter"),e[27]=a,e[28]=T):T=e[28];let R;e[29]!==a?(R=a("all"),e[29]=a,e[30]=R):R=e[30];let L;e[31]!==R?(L=(0,r.jsx)("option",{value:"all",children:R}),e[31]=R,e[32]=L):L=e[32];let k;e[33]!==a?(k=a("ok"),e[33]=a,e[34]=k):k=e[34];let S;e[35]!==k?(S=(0,r.jsx)("option",{value:"ok",children:k}),e[35]=k,e[36]=S):S=e[36];let p;e[37]!==a?(p=a("error"),e[37]=a,e[38]=p):p=e[38];let C;e[39]!==p?(C=(0,r.jsx)("option",{value:"error",children:p}),e[39]=p,e[40]=C):C=e[40];let q;e[41]!==t||e[42]!==c||e[43]!==T||e[44]!==L||e[45]!==S||e[46]!==C?(q=(0,r.jsxs)("select",{"aria-label":T,className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"lg-req-outcome",onChange:t,value:c,children:[L,S,C]}),e[41]=t,e[42]=c,e[43]=T,e[44]=L,e[45]=S,e[46]=C,e[47]=q):q=e[47];let F;return e[48]!==q||e[49]!==u||e[50]!==x||e[51]!==y?(F=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[u,x,y,q]}),e[48]=q,e[49]=u,e[50]=x,e[51]=y,e[52]=F):F=e[52],F},"We"),Fe=v(i=>{let e=(0,K.c)(7),{bucket:t}=i,n;e[0]!==t.key?(n=(0,r.jsx)("span",{className:"truncate text-muted-foreground",role:"gridcell",children:t.key}),e[0]=t.key,e[1]=n):n=e[1];let s;e[2]!==t.count?(s=(0,r.jsx)("span",{className:"shrink-0 tabular-nums",role:"gridcell",children:t.count}),e[2]=t.count,e[3]=s):s=e[3];let o;return e[4]!==n||e[5]!==s?(o=(0,r.jsxs)("div",{className:"flex items-center justify-between gap-4 px-3 py-1 font-mono text-xs","data-testid":"logs-summary-row",role:"row",children:[n,s]}),e[4]=n,e[5]=s,e[6]=o):o=e[6],o},"ve"),Ye=v(i=>{let e=(0,K.c)(31),{summary:t}=i,n=z(),s;e[0]!==t.total||e[1]!==n?(s=n("{count} entries",{count:t.total}),e[0]=t.total,e[1]=n,e[2]=s):s=e[2];let o;e[3]!==s?(o=(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"logs-summary-total",children:s}),e[3]=s,e[4]=o):o=e[4];let c;e[5]!==n?(c=n("By level"),e[5]=n,e[6]=c):c=e[6];let f;e[7]!==c?(f=(0,r.jsx)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:c}),e[7]=c,e[8]=f):f=e[8];let m;e[9]!==t.byLevel?(m=t.byLevel.map(Ge),e[9]=t.byLevel,e[10]=m):m=e[10];let d;e[11]!==m?(d=(0,r.jsx)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-levels",role:"grid",children:m}),e[11]=m,e[12]=d):d=e[12];let a;e[13]!==f||e[14]!==d?(a=(0,r.jsxs)("div",{children:[f,d]}),e[13]=f,e[14]=d,e[15]=a):a=e[15];let h;e[16]!==n?(h=n("By function"),e[16]=n,e[17]=h):h=e[17];let l;e[18]!==h?(l=(0,r.jsx)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h}),e[18]=h,e[19]=l):l=e[19];let u;e[20]!==t.byPath?(u=t.byPath.map(He),e[20]=t.byPath,e[21]=u):u=e[21];let g;e[22]!==u?(g=(0,r.jsx)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-paths",role:"grid",children:u}),e[22]=u,e[23]=g):g=e[23];let b;e[24]!==g||e[25]!==l?(b=(0,r.jsxs)("div",{children:[l,g]}),e[24]=g,e[25]=l,e[26]=b):b=e[26];let x;return e[27]!==b||e[28]!==o||e[29]!==a?(x=(0,r.jsxs)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"logs-summary",children:[o,a,b]}),e[27]=b,e[28]=o,e[29]=a,e[30]=x):x=e[30],x},"Ye");function Ge(i){return(0,r.jsx)(Fe,{bucket:i},i.key)}v(Ge,"je");function He(i){return(0,r.jsx)(Fe,{bucket:i},i.key)}v(He,"Je");var Je=v(i=>{let e=(0,K.c)(46),{liveError:t,onShardKeyChange:n,onShowArchive:s,onShowErrors:o,onShowRequests:c,shardKey:f,view:m}=i,d=z(),a=m==="requests",h=m==="requests"?"bg-muted font-medium":"text-muted-foreground",l;e[0]!==h?(l=W("px-3 py-1 text-sm",h),e[0]=h,e[1]=l):l=e[1];let u;e[2]!==d?(u=d("Requests"),e[2]=d,e[3]=u):u=e[3];let g;e[4]!==c||e[5]!==a||e[6]!==l||e[7]!==u?(g=(0,r.jsx)("button",{"aria-selected":a,className:l,"data-testid":"lg-view-requests",onClick:c,role:"tab",type:"button",children:u}),e[4]=c,e[5]=a,e[6]=l,e[7]=u,e[8]=g):g=e[8];let b=m==="errors",x=m==="errors"?"bg-muted font-medium":"text-muted-foreground",w;e[9]!==x?(w=W("px-3 py-1 text-sm",x),e[9]=x,e[10]=w):w=e[10];let N;e[11]!==d?(N=d("Errors"),e[11]=d,e[12]=N):N=e[12];let y;e[13]!==o||e[14]!==b||e[15]!==w||e[16]!==N?(y=(0,r.jsx)("button",{"aria-selected":b,className:w,"data-testid":"lg-view-errors",onClick:o,role:"tab",type:"button",children:N}),e[13]=o,e[14]=b,e[15]=w,e[16]=N,e[17]=y):y=e[17];let T=m==="archive",R=m==="archive"?"bg-muted font-medium":"text-muted-foreground",L;e[18]!==R?(L=W("px-3 py-1 text-sm",R),e[18]=R,e[19]=L):L=e[19];let k;e[20]!==d?(k=d("Archive"),e[20]=d,e[21]=k):k=e[21];let S;e[22]!==s||e[23]!==T||e[24]!==L||e[25]!==k?(S=(0,r.jsx)("button",{"aria-selected":T,className:L,"data-testid":"lg-view-archive",onClick:s,role:"tab",type:"button",children:k}),e[22]=s,e[23]=T,e[24]=L,e[25]=k,e[26]=S):S=e[26];let p;e[27]!==y||e[28]!==S||e[29]!==g?(p=(0,r.jsxs)("div",{className:"inline-flex overflow-hidden rounded-lg border border-border",role:"tablist",children:[g,y,S]}),e[27]=y,e[28]=S,e[29]=g,e[30]=p):p=e[30];let C;e[31]!==n||e[32]!==f?(C=(0,r.jsx)(be,{onChange:n,testId:"lg-shard-input",value:f}),e[31]=n,e[32]=f,e[33]=C):C=e[33];let q;e[34]!==t||e[35]!==m?(q=m!=="archive"&&(0,r.jsx)(ke,{message:t,prefix:"lg"}),e[34]=t,e[35]=m,e[36]=q):q=e[36];let F;e[37]!==d?(F=d("Open in Cloudflare"),e[37]=d,e[38]=F):F=e[38];let O;e[39]!==F?(O=(0,r.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"lg-cf-link",href:de,rel:"noreferrer",target:"_blank",children:F}),e[39]=F,e[40]=O):O=e[40];let E;return e[41]!==p||e[42]!==C||e[43]!==q||e[44]!==O?(E=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[p,C,q,O]}),e[41]=p,e[42]=C,e[43]=q,e[44]=O,e[45]=E):E=e[45],E},"Xe"),ue=400,Xe=36,Ze={height:ue,overflow:"auto"},Oe={left:0,position:"absolute",top:0,width:"100%"},et={error:"destructive",ok:"secondary"},Ee=v(i=>{let e=(0,K.c)(6),{onOpenTrace:t,traceId:n}=i,s=z(),o;e[0]!==t||e[1]!==s||e[2]!==n?(o=n===void 0?null:(0,r.jsx)("button",{className:"text-primary underline-offset-2 hover:underline","data-testid":"lg-trace-link",onClick:v(()=>{t(n)},"onClick"),type:"button",children:s("Trace")}),e[0]=t,e[1]=s,e[2]=n,e[3]=o):o=e[3];let c;return e[4]!==o?(c=(0,r.jsx)("span",{className:"w-16 shrink-0 text-right",role:"gridcell",children:o}),e[4]=o,e[5]=c):c=e[5],c},"xe"),tt=v(i=>{let e=(0,K.c)(13),{entry:t,index:n,measureRef:s,onOpenTrace:o,start:c}=i,f=`translateY(${String(c)}px)`,m;e[0]!==f?(m={...Oe,transform:f},e[0]=f,e[1]=m):m=e[1];let d=m,a;e[2]!==t?(a=(0,r.jsx)(Re,{entry:t}),e[2]=t,e[3]=a):a=e[3];let h;e[4]!==t.traceId||e[5]!==o?(h=(0,r.jsx)(Ee,{onOpenTrace:o,traceId:t.traceId}),e[4]=t.traceId,e[5]=o,e[6]=h):h=e[6];let l;return e[7]!==n||e[8]!==s||e[9]!==d||e[10]!==a||e[11]!==h?(l=(0,r.jsxs)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":n,"data-testid":"lg-row",ref:s,role:"row",style:d,children:[a,h]}),e[7]=n,e[8]=s,e[9]=d,e[10]=a,e[11]=h,e[12]=l):l=e[12],l},"rt"),Ie=v(i=>i.length===0?"\u2014":i.join(", "),"ce"),rt=v(i=>{let e=(0,K.c)(41),{entry:t,index:n,measureRef:s,onOpenTrace:o,start:c}=i,f=`translateY(${String(c)}px)`,m;e[0]!==f?(m={...Oe,transform:f},e[0]=f,e[1]=m):m=e[1];let d=m,a;e[2]!==t.ts?(a=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=a):a=e[3];let h;e[4]!==a?(h=(0,r.jsx)("span",{className:"w-40 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:a}),e[4]=a,e[5]=h):h=e[5];let l=et[t.outcome],u;e[6]!==t.outcome||e[7]!==l?(u=(0,r.jsx)("span",{className:"w-16 shrink-0",role:"gridcell",children:(0,r.jsx)(ne,{variant:l,children:t.outcome})}),e[6]=t.outcome,e[7]=l,e[8]=u):u=e[8];let g;e[9]!==t.functionPath?(g=(0,r.jsx)("span",{className:"w-44 shrink-0 truncate",role:"gridcell",title:t.functionPath,children:t.functionPath}),e[9]=t.functionPath,e[10]=g):g=e[10];let b=t.shardKey??"\u2014",x;e[11]!==b?(x=(0,r.jsx)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:b}),e[11]=b,e[12]=x):x=e[12];let w=t.userId??"\u2014",N;e[13]!==w?(N=(0,r.jsx)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:w}),e[13]=w,e[14]=N):N=e[14];let y;e[15]!==t.durationMs?(y=Math.round(t.durationMs),e[15]=t.durationMs,e[16]=y):y=e[16];let T=`${String(y)}ms`,R;e[17]!==T?(R=(0,r.jsx)("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:T}),e[17]=T,e[18]=R):R=e[18];let L;e[19]!==t.errorMessage||e[20]!==t.outcome||e[21]!==t.tablesRead||e[22]!==t.tablesWritten?(L=t.outcome==="error"&&t.errorMessage!==void 0?t.errorMessage:`r:${Ie(t.tablesRead)} \xB7 w:${Ie(t.tablesWritten)}`,e[19]=t.errorMessage,e[20]=t.outcome,e[21]=t.tablesRead,e[22]=t.tablesWritten,e[23]=L):L=e[23];let k;e[24]!==L?(k=(0,r.jsx)("span",{className:"flex-1 truncate text-muted-foreground",role:"gridcell",children:L}),e[24]=L,e[25]=k):k=e[25];let S;e[26]!==t.traceId||e[27]!==o?(S=(0,r.jsx)(Ee,{onOpenTrace:o,traceId:t.traceId}),e[26]=t.traceId,e[27]=o,e[28]=S):S=e[28];let p;return e[29]!==n||e[30]!==s||e[31]!==d||e[32]!==N||e[33]!==R||e[34]!==k||e[35]!==S||e[36]!==h||e[37]!==u||e[38]!==g||e[39]!==x?(p=(0,r.jsxs)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":n,"data-testid":"lg-req-row",ref:s,role:"row",style:d,children:[h,u,g,x,N,R,k,S]}),e[29]=n,e[30]=s,e[31]=d,e[32]=N,e[33]=R,e[34]=k,e[35]=S,e[36]=h,e[37]=u,e[38]=g,e[39]=x,e[40]=p):p=e[40],p},"st"),qe=v(i=>{let{entries:e}=i??{};return Array.isArray(e)?e:[]},"de"),at=v(i=>{let e={};return i.functionPathPrefix.trim()!==""&&(e.functionPathPrefix=i.functionPathPrefix.trim()),i.userId.trim()!==""&&(e.userId=i.userId.trim()),i.tableTouched.trim()!==""&&(e.tableTouched=i.tableTouched.trim()),(i.outcome==="ok"||i.outcome==="error")&&(e.outcome=i.outcome),e},"lt"),lt={"5m":300*1e3,"15m":900*1e3,"1h":3600*1e3},ot=v((i,e)=>{let t=e.search.trim().toLowerCase(),n=e.path.trim().toLowerCase(),s=e.range==="all"?Number.NEGATIVE_INFINITY:e.now-lt[e.range];return i.filter(o=>e.levels.size>0&&!e.levels.has(o.level)||o.timestamp<s||n!==""&&!(o.functionPath??"").toLowerCase().includes(n)?!1:t===""||o.message.toLowerCase().includes(t)||ce(o.fields).toLowerCase().includes(t))},"at"),nt="\u2014",st=v(i=>{let e=new Map,t=new Map;for(let o of i){e.set(o.level,(e.get(o.level)??0)+1);let c=o.functionPath??nt;t.set(c,(t.get(c)??0)+1)}let n=me.filter(o=>e.has(o)).map(o=>({count:e.get(o)??0,key:o})),s=[...t.entries()].map(([o,c])=>({count:c,key:o})).toSorted((o,c)=>c.count===o.count?o.key.localeCompare(c.key):c.count-o.count);return{byLevel:n,byPath:s,total:i.length}},"it"),qt=v(({initialShardKey:i})=>{let e=z(),[t,n]=(0,I.useState)("requests"),{queryShardKey:s,setShardKey:o,shardKey:c}=xe(i),[f,m]=(0,I.useState)(""),[d,a]=(0,I.useState)(()=>new Set),[h,l]=(0,I.useState)(""),[u,g]=(0,I.useState)("all"),[b,x]=(0,I.useState)(!1),[w,N]=(0,I.useState)(""),[y,T]=(0,I.useState)(""),[R,L]=(0,I.useState)(""),[k,S]=(0,I.useState)("all"),p=at({functionPathPrefix:w,outcome:k,tableTouched:R,userId:y}),C=le(oe.getRequestLog,p,{enabled:t==="requests",live:!0,shardKey:s}),q=le(oe.getLogs,{},{enabled:t==="errors",live:!0,shardKey:s}),F=t==="requests"?C:q,{error:O,errorSource:E,isLoading:M,liveError:V}=F,_=Te(s),U=qe(q.data),A=qe(C.data);(0,I.useEffect)(()=>{F.data!==void 0&&ve(s)},[F.data,s]);let $=ot(U,{levels:d,now:Date.now(),path:h,range:u,search:f}),Q=st($),X=t==="requests"?A.length:$.length,Z=t==="errors"&&b,Y=(0,I.useMemo)(()=>O!==null?"error":X===0?M?Z?"summary":"list":"empty":Z?"summary":"list",[X,M,O,Z]),he=(0,I.useRef)(null),G=Le({count:X,estimateSize:v(()=>Xe,"estimateSize"),getScrollElement:v(()=>he.current,"getScrollElement"),initialRect:{height:ue,width:800},observeElementRect:v((P,ee)=>Se(P,ee,ue),"observeElementRect"),overscan:8}),Ke=G.getVirtualItems(),Me={height:G.getTotalSize(),position:"relative",width:"100%"};return(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-logs",children:[(0,r.jsx)(Je,{liveError:V,onShardKeyChange:o,onShowArchive:v(()=>{n("archive"),x(!1)},"onShowArchive"),onShowErrors:v(()=>{n("errors"),x(!1)},"onShowErrors"),onShowRequests:v(()=>{n("requests"),x(!1)},"onShowRequests"),shardKey:c,view:t}),t==="errors"&&(0,r.jsx)(Ve,{levelFilter:d,onLogPathChange:v(P=>{l(P.target.value)},"onLogPathChange"),onSearchChange:v(P=>{m(P.target.value)},"onSearchChange"),onTimeRangeChange:v(P=>{g(P.target.value)},"onTimeRangeChange"),onToggleLevel:v(P=>{a(ee=>{let H=new Set(ee);return H.has(P)?H.delete(P):H.add(P),H})},"onToggleLevel"),onToggleSummary:v(()=>{x(P=>!P)},"onToggleSummary"),pathFilter:h,search:f,showSummary:b,timeRange:u}),t==="requests"&&(0,r.jsx)(Qe,{onOutcomeChange:v(P=>{S(P.target.value)},"onOutcomeChange"),onPathChange:v(P=>{N(P.target.value)},"onPathChange"),onTableChange:v(P=>{L(P.target.value)},"onTableChange"),onUserChange:v(P=>{T(P.target.value)},"onUserChange"),outcomeFilter:k,pathPrefix:w,tableFilter:R,userIdFilter:y}),t==="archive"?(0,r.jsx)(Be,{shardKey:s}):(0,r.jsxs)(r.Fragment,{children:[Y==="error"&&(0,r.jsx)(ye,{error:E,shardKey:s,testId:"lg-error"}),Y==="empty"&&(0,r.jsx)(J,{description:e("Function and request logs for this shard show up here as your app handles traffic."),icon:(0,r.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M4 5h16M4 12h16M4 19h10"})}),testId:"lg-empty",title:e("No logs.")}),Y==="summary"&&(0,r.jsx)(Ye,{summary:Q}),Y==="list"&&(0,r.jsx)("div",{className:"rounded-xl border border-border shadow-xs","data-testid":"lg-scroll",ref:he,style:Ze,children:(0,r.jsx)("div",{"aria-label":e("Recent logs"),"data-testid":"lg-table",role:"grid",style:Me,children:Ke.map(P=>t==="requests"?(0,r.jsx)(rt,{entry:A[P.index],index:P.index,measureRef:G.measureElement,onOpenTrace:_,start:P.start},P.key):(0,r.jsx)(tt,{entry:$[P.index],index:P.index,measureRef:G.measureElement,onOpenTrace:_,start:P.start},P.key))})})]})]})},"Wt");export{qt as LogsPanel,ot as filterLogs,st as summarizeLogs};
|
|
1
|
+
import{a as Pe,b as Re}from"./chunk-W4LJQYCI.js";import{a as ce}from"./chunk-YORPLSI5.js";import{a as Te}from"./chunk-QNM2J7MG.js";import"./chunk-ONTGYVAN.js";import{a as de}from"./chunk-P6VNMPWR.js";import{a as Se}from"./chunk-S36FVTKK.js";import{c as Le}from"./chunk-BKI3JMXQ.js";import{a as ke}from"./chunk-ELSQ4FVH.js";import{a as ie}from"./chunk-2DT3QG6Q.js";import{a as xe}from"./chunk-J45HAKBU.js";import{a as be}from"./chunk-FHLODLBC.js";import{b as ve}from"./chunk-3D67ZJRW.js";import"./chunk-ZSWW2UGP.js";import"./chunk-RTS5G3ET.js";import"./chunk-QRA7AKYO.js";import{i as D}from"./chunk-IHGRWY3Y.js";import"./chunk-OWRKSQPE.js";import"./chunk-4EPW63HS.js";import{a as fe}from"./chunk-V3BE427M.js";import"./chunk-CKEQX655.js";import"./chunk-UD5REVU2.js";import{a as J}from"./chunk-RCXNYW7P.js";import{b as ne}from"./chunk-UQA2AJGI.js";import"./chunk-T3ZCW3RG.js";import{a as ye}from"./chunk-YEXTJUKQ.js";import"./chunk-LSEUUZN4.js";import{a as we,b as Ne,c as Ce,d as se,e as j,f as B}from"./chunk-7QEZ2SFW.js";import"./chunk-OZAOWE7T.js";import"./chunk-BBDTJG2K.js";import"./chunk-4PI2OSSP.js";import{a as oe}from"./chunk-2W4UO5BC.js";import{c as le}from"./chunk-4N76XUNG.js";import{m as pe}from"./chunk-SHHGIT7M.js";import"./chunk-ZPQBVYNN.js";import{B as z,j as re,k as ge,s as ae,x as W}from"./chunk-GNI37YCV.js";import"./chunk-PDBW6GTJ.js";import{a as Ae}from"./chunk-GWNGVKLG.js";import{a as _e,b as Ue}from"./chunk-6G3E4PJ2.js";import{a as v,d as te}from"./chunk-5PEAXTYQ.js";var K=te(Ae(),1);var I=te(_e(),1);var r=te(Ue(),1);var me=["trace","debug","log","info","warn","error","fatal"],$e="LOG_ARCHIVE_NOT_CONFIGURED",ze={cursor:void 0,error:null,loading:!1,notConfigured:!1,rows:null},De=v((i,e)=>{switch(e.type){case"append":return{...i,cursor:e.cursor,error:null,loading:!1,rows:[...i.rows??[],...e.rows]};case"failed":return{cursor:void 0,error:e.message,loading:!1,notConfigured:!1,rows:null};case"loaded":return{cursor:e.cursor,error:null,loading:!1,notConfigured:!1,rows:e.rows};case"loading":return{...i,error:null,loading:!0,notConfigured:!1};case"notConfigured":return{cursor:void 0,error:null,loading:!1,notConfigured:!0,rows:null};case"pageFailed":return{...i,error:e.message,loading:!1};default:return i}},"De"),je=v(i=>{let e=(0,K.c)(33),{row:t}=i,n;e[0]!==t.fields?(n=ce(t.fields),e[0]=t.fields,e[1]=n):n=e[1];let s=n,o=`lg-archive-row-${String(t.ts)}`,c;e[2]!==t.ts?(c=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=c):c=e[3];let f;e[4]!==c?(f=(0,r.jsx)(B,{className:"tabular-nums whitespace-nowrap text-xs text-muted-foreground",children:c}),e[4]=c,e[5]=f):f=e[5];let m=Pe[t.level],d;e[6]!==t.level||e[7]!==m?(d=(0,r.jsx)(B,{children:(0,r.jsx)(ne,{variant:m,children:t.level})}),e[6]=t.level,e[7]=m,e[8]=d):d=e[8];let a;e[9]!==t.functionPath?(a=(0,r.jsx)(B,{className:"font-mono text-xs",children:t.functionPath}),e[9]=t.functionPath,e[10]=a):a=e[10];let h;e[11]!==t.message?(h=(0,r.jsx)("div",{className:"truncate",title:t.message,children:t.message}),e[11]=t.message,e[12]=h):h=e[12];let l;e[13]!==s?(l=s!==""&&(0,r.jsx)("div",{className:"truncate font-mono text-[11px] text-muted-foreground",title:s,children:s}),e[13]=s,e[14]=l):l=e[14];let u;e[15]!==h||e[16]!==l?(u=(0,r.jsxs)(B,{className:"max-w-md",children:[h,l]}),e[15]=h,e[16]=l,e[17]=u):u=e[17];let g=t.traceId??"\u2014",b;e[18]!==g?(b=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:g}),e[18]=g,e[19]=b):b=e[19];let x=t.shardKey??"\u2014",w;e[20]!==x?(w=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:x}),e[20]=x,e[21]=w):w=e[21];let N=t.userId??"\u2014",y;e[22]!==N?(y=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:N}),e[22]=N,e[23]=y):y=e[23];let T;return e[24]!==u||e[25]!==b||e[26]!==w||e[27]!==y||e[28]!==o||e[29]!==f||e[30]!==d||e[31]!==a?(T=(0,r.jsxs)(se,{"data-testid":o,children:[f,d,a,u,b,w,y]}),e[24]=u,e[25]=b,e[26]=w,e[27]=y,e[28]=o,e[29]=f,e[30]=d,e[31]=a,e[32]=T):T=e[32],T},"Qe"),Be=v(({shardKey:i})=>{let e=pe(),t=z(),[n,s]=(0,I.useState)(""),[o,c]=(0,I.useState)(""),[f,m]=(0,I.useState)(""),[{cursor:d,error:a,loading:h,notConfigured:l,rows:u},g]=(0,I.useReducer)(De,ze),b=ie(n.trim(),400),x=ie(o.trim(),400),w={...b===""?{}:{functionPathPrefix:b},...f===""?{}:{minLevel:f},...i===""?{}:{shardKey:i},...x===""?{}:{userId:x}},N=JSON.stringify(w),y=(0,I.useRef)(N);(0,I.useEffect)(()=>{let p={cancelled:!1};return y.current=N,ae((async()=>{g({type:"loading"});try{let C=await e.queryLogArchive(w);p.cancelled||g({cursor:C.nextCursor,rows:C.rows,type:"loaded"})}catch(C){p.cancelled||g(ge(C)===$e?{type:"notConfigured"}:{message:re(C),type:"failed"})}})()),()=>{p.cancelled=!0}},[e,N]);let T=v(async()=>{if(d===void 0)return;let p=N;g({type:"loading"});try{let C=await e.queryLogArchive({...w,cursor:d});y.current===p&&g({cursor:C.nextCursor,rows:C.rows,type:"append"})}catch(C){y.current===p&&g({message:re(C),type:"pageFailed"})}},"T"),R=v(p=>{s(p.target.value)},"R"),L=v(p=>{c(p.target.value)},"N"),k=v(p=>{m(p.target.value)},"L"),S=v(()=>{ae(T())},"S");return l?(0,r.jsx)(J,{action:(0,r.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline",href:de,rel:"noreferrer",target:"_blank",children:t("Open in Cloudflare")}),description:t("Wire pipelineLogSink to a Cloudflare Pipeline \u2192 R2 Data Catalog table and set R2_SQL_ACCOUNT_ID, R2_SQL_TOKEN, R2_SQL_BUCKET to browse the durable log archive here."),testId:"lg-archive-not-configured",title:t("Log archive not configured")}):(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lg-archive",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(D,{"aria-label":t("Function path prefix"),className:"h-8 w-48","data-testid":"lg-archive-path",onChange:R,placeholder:t("function path\u2026"),value:n}),(0,r.jsx)(D,{"aria-label":t("User id"),className:"h-8 w-40","data-testid":"lg-archive-user",onChange:L,placeholder:t("user id\u2026"),value:o}),(0,r.jsxs)("select",{"aria-label":t("Minimum level"),className:"h-8 rounded-md border border-border bg-background px-2 text-sm","data-testid":"lg-archive-min-level",onChange:k,value:f,children:[(0,r.jsx)("option",{value:"",children:t("min level")}),me.map(p=>(0,r.jsx)("option",{value:p,children:p},p))]})]}),a!==null&&(0,r.jsx)("p",{className:"text-sm text-destructive","data-testid":"lg-archive-error",role:"alert",children:a}),h&&u===null&&a===null&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"lg-archive-loading",children:t("Loading\u2026")}),u!==null&&u.length===0&&(0,r.jsx)(J,{description:t("No archived logs match these filters. The durable archive fills as pipelineLogSink flushes records to R2."),testId:"lg-archive-empty",title:t("No archived logs.")}),u!==null&&u.length>0&&(0,r.jsx)("div",{className:"overflow-hidden rounded-xl border border-border shadow-xs",children:(0,r.jsxs)(we,{"data-testid":"lg-archive-table",children:[(0,r.jsx)(Ne,{children:(0,r.jsxs)(se,{children:[(0,r.jsx)(j,{children:t("Time")}),(0,r.jsx)(j,{children:t("Level")}),(0,r.jsx)(j,{children:t("Function")}),(0,r.jsx)(j,{children:t("Message")}),(0,r.jsx)(j,{children:t("Trace")}),(0,r.jsx)(j,{children:t("Shard")}),(0,r.jsx)(j,{children:t("User")})]})}),(0,r.jsx)(Ce,{children:u.map((p,C)=>(0,r.jsx)(je,{row:p},`${String(p.ts)}-${String(C)}`))})]})}),d!==void 0&&(0,r.jsx)("div",{children:(0,r.jsx)(fe,{"data-testid":"lg-archive-more",disabled:h,onClick:S,size:"sm",variant:"outline",children:t(h?"Loading\u2026":"Load more")})})]})},"ze"),We=v(i=>{let e=(0,K.c)(11),{level:t,onToggle:n,selected:s}=i,o;e[0]!==t||e[1]!==n?(o=v(()=>{n(t)},"o"),e[0]=t,e[1]=n,e[2]=o):o=e[2];let c=o,f=s?"border-border bg-muted font-medium":"border-input text-muted-foreground",m;e[3]!==f?(m=W("rounded-md border px-2 py-1 text-xs",f),e[3]=f,e[4]=m):m=e[4];let d=`logs-level-${t}`,a;return e[5]!==t||e[6]!==c||e[7]!==s||e[8]!==m||e[9]!==d?(a=(0,r.jsx)("button",{"aria-pressed":s,className:m,"data-testid":d,onClick:c,type:"button",children:t}),e[5]=t,e[6]=c,e[7]=s,e[8]=m,e[9]=d,e[10]=a):a=e[10],a},"Ge"),Ve=v(i=>{let e=(0,K.c)(68),{levelFilter:t,onLogPathChange:n,onSearchChange:s,onTimeRangeChange:o,onToggleLevel:c,onToggleSummary:f,pathFilter:m,search:d,showSummary:a,timeRange:h}=i,l=z(),u;e[0]!==l?(u=l("Search messages"),e[0]=l,e[1]=u):u=e[1];let g;e[2]!==l?(g=l("search message"),e[2]=l,e[3]=g):g=e[3];let b;e[4]!==s||e[5]!==d||e[6]!==u||e[7]!==g?(b=(0,r.jsx)(D,{"aria-label":u,className:"h-8 w-48","data-testid":"lg-search",onChange:s,placeholder:g,value:d}),e[4]=s,e[5]=d,e[6]=u,e[7]=g,e[8]=b):b=e[8];let x;e[9]!==l?(x=l("Function path"),e[9]=l,e[10]=x):x=e[10];let w;e[11]!==l?(w=l("filter path"),e[11]=l,e[12]=w):w=e[12];let N;e[13]!==n||e[14]!==m||e[15]!==x||e[16]!==w?(N=(0,r.jsx)(D,{"aria-label":x,className:"h-8 w-40","data-testid":"logs-path-filter",onChange:n,placeholder:w,value:m}),e[13]=n,e[14]=m,e[15]=x,e[16]=w,e[17]=N):N=e[17];let y;e[18]!==l?(y=l("Level filter"),e[18]=l,e[19]=y):y=e[19];let T;e[20]!==t||e[21]!==c?(T=me.map(Q=>(0,r.jsx)(We,{level:Q,onToggle:c,selected:t.has(Q)},Q)),e[20]=t,e[21]=c,e[22]=T):T=e[22];let R;e[23]!==y||e[24]!==T?(R=(0,r.jsx)("div",{"aria-label":y,className:"inline-flex items-center gap-1","data-testid":"logs-level-filter",role:"group",children:T}),e[23]=y,e[24]=T,e[25]=R):R=e[25];let L;e[26]!==l?(L=l("Time range"),e[26]=l,e[27]=L):L=e[27];let k;e[28]!==l?(k=l("All time"),e[28]=l,e[29]=k):k=e[29];let S;e[30]!==k?(S=(0,r.jsx)("option",{value:"all",children:k}),e[30]=k,e[31]=S):S=e[31];let p;e[32]!==l?(p=l("Last 5m"),e[32]=l,e[33]=p):p=e[33];let C;e[34]!==p?(C=(0,r.jsx)("option",{value:"5m",children:p}),e[34]=p,e[35]=C):C=e[35];let q;e[36]!==l?(q=l("Last 15m"),e[36]=l,e[37]=q):q=e[37];let F;e[38]!==q?(F=(0,r.jsx)("option",{value:"15m",children:q}),e[38]=q,e[39]=F):F=e[39];let O;e[40]!==l?(O=l("Last hour"),e[40]=l,e[41]=O):O=e[41];let E;e[42]!==O?(E=(0,r.jsx)("option",{value:"1h",children:O}),e[42]=O,e[43]=E):E=e[43];let M;e[44]!==o||e[45]!==L||e[46]!==S||e[47]!==C||e[48]!==F||e[49]!==E||e[50]!==h?(M=(0,r.jsxs)("select",{"aria-label":L,className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"logs-time-range",onChange:o,value:h,children:[S,C,F,E]}),e[44]=o,e[45]=L,e[46]=S,e[47]=C,e[48]=F,e[49]=E,e[50]=h,e[51]=M):M=e[51];let V=a?"border-border bg-muted font-medium":"border-input text-muted-foreground",_;e[52]!==V?(_=W("h-8 rounded-md border px-3 text-sm",V),e[52]=V,e[53]=_):_=e[53];let U;e[54]!==a||e[55]!==l?(U=l(a?"List":"Summary"),e[54]=a,e[55]=l,e[56]=U):U=e[56];let A;e[57]!==f||e[58]!==a||e[59]!==_||e[60]!==U?(A=(0,r.jsx)("button",{"aria-pressed":a,className:_,"data-testid":"logs-summary-toggle",onClick:f,type:"button",children:U}),e[57]=f,e[58]=a,e[59]=_,e[60]=U,e[61]=A):A=e[61];let $;return e[62]!==M||e[63]!==A||e[64]!==b||e[65]!==N||e[66]!==R?($=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[b,N,R,M,A]}),e[62]=M,e[63]=A,e[64]=b,e[65]=N,e[66]=R,e[67]=$):$=e[67],$},"He"),Qe=v(i=>{let e=(0,K.c)(53),{onOutcomeChange:t,onPathChange:n,onTableChange:s,onUserChange:o,outcomeFilter:c,pathPrefix:f,tableFilter:m,userIdFilter:d}=i,a=z(),h;e[0]!==a?(h=a("Function path"),e[0]=a,e[1]=h):h=e[1];let l;e[2]!==a?(l=a("file:function"),e[2]=a,e[3]=l):l=e[3];let u;e[4]!==n||e[5]!==f||e[6]!==h||e[7]!==l?(u=(0,r.jsx)(D,{"aria-label":h,className:"h-8 w-44","data-testid":"lg-req-path",onChange:n,placeholder:l,value:f}),e[4]=n,e[5]=f,e[6]=h,e[7]=l,e[8]=u):u=e[8];let g;e[9]!==a?(g=a("User id"),e[9]=a,e[10]=g):g=e[10];let b;e[11]!==a?(b=a("userId"),e[11]=a,e[12]=b):b=e[12];let x;e[13]!==o||e[14]!==g||e[15]!==b||e[16]!==d?(x=(0,r.jsx)(D,{"aria-label":g,className:"h-8 w-32","data-testid":"lg-req-user",onChange:o,placeholder:b,value:d}),e[13]=o,e[14]=g,e[15]=b,e[16]=d,e[17]=x):x=e[17];let w;e[18]!==a?(w=a("Table touched"),e[18]=a,e[19]=w):w=e[19];let N;e[20]!==a?(N=a("table"),e[20]=a,e[21]=N):N=e[21];let y;e[22]!==s||e[23]!==w||e[24]!==N||e[25]!==m?(y=(0,r.jsx)(D,{"aria-label":w,className:"h-8 w-32","data-testid":"lg-req-table",onChange:s,placeholder:N,value:m}),e[22]=s,e[23]=w,e[24]=N,e[25]=m,e[26]=y):y=e[26];let T;e[27]!==a?(T=a("Outcome filter"),e[27]=a,e[28]=T):T=e[28];let R;e[29]!==a?(R=a("all"),e[29]=a,e[30]=R):R=e[30];let L;e[31]!==R?(L=(0,r.jsx)("option",{value:"all",children:R}),e[31]=R,e[32]=L):L=e[32];let k;e[33]!==a?(k=a("ok"),e[33]=a,e[34]=k):k=e[34];let S;e[35]!==k?(S=(0,r.jsx)("option",{value:"ok",children:k}),e[35]=k,e[36]=S):S=e[36];let p;e[37]!==a?(p=a("error"),e[37]=a,e[38]=p):p=e[38];let C;e[39]!==p?(C=(0,r.jsx)("option",{value:"error",children:p}),e[39]=p,e[40]=C):C=e[40];let q;e[41]!==t||e[42]!==c||e[43]!==T||e[44]!==L||e[45]!==S||e[46]!==C?(q=(0,r.jsxs)("select",{"aria-label":T,className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"lg-req-outcome",onChange:t,value:c,children:[L,S,C]}),e[41]=t,e[42]=c,e[43]=T,e[44]=L,e[45]=S,e[46]=C,e[47]=q):q=e[47];let F;return e[48]!==q||e[49]!==u||e[50]!==x||e[51]!==y?(F=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[u,x,y,q]}),e[48]=q,e[49]=u,e[50]=x,e[51]=y,e[52]=F):F=e[52],F},"We"),Fe=v(i=>{let e=(0,K.c)(7),{bucket:t}=i,n;e[0]!==t.key?(n=(0,r.jsx)("span",{className:"truncate text-muted-foreground",role:"gridcell",children:t.key}),e[0]=t.key,e[1]=n):n=e[1];let s;e[2]!==t.count?(s=(0,r.jsx)("span",{className:"shrink-0 tabular-nums",role:"gridcell",children:t.count}),e[2]=t.count,e[3]=s):s=e[3];let o;return e[4]!==n||e[5]!==s?(o=(0,r.jsxs)("div",{className:"flex items-center justify-between gap-4 px-3 py-1 font-mono text-xs","data-testid":"logs-summary-row",role:"row",children:[n,s]}),e[4]=n,e[5]=s,e[6]=o):o=e[6],o},"ve"),Ye=v(i=>{let e=(0,K.c)(31),{summary:t}=i,n=z(),s;e[0]!==t.total||e[1]!==n?(s=n("{count} entries",{count:t.total}),e[0]=t.total,e[1]=n,e[2]=s):s=e[2];let o;e[3]!==s?(o=(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"logs-summary-total",children:s}),e[3]=s,e[4]=o):o=e[4];let c;e[5]!==n?(c=n("By level"),e[5]=n,e[6]=c):c=e[6];let f;e[7]!==c?(f=(0,r.jsx)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:c}),e[7]=c,e[8]=f):f=e[8];let m;e[9]!==t.byLevel?(m=t.byLevel.map(Ge),e[9]=t.byLevel,e[10]=m):m=e[10];let d;e[11]!==m?(d=(0,r.jsx)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-levels",role:"grid",children:m}),e[11]=m,e[12]=d):d=e[12];let a;e[13]!==f||e[14]!==d?(a=(0,r.jsxs)("div",{children:[f,d]}),e[13]=f,e[14]=d,e[15]=a):a=e[15];let h;e[16]!==n?(h=n("By function"),e[16]=n,e[17]=h):h=e[17];let l;e[18]!==h?(l=(0,r.jsx)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h}),e[18]=h,e[19]=l):l=e[19];let u;e[20]!==t.byPath?(u=t.byPath.map(He),e[20]=t.byPath,e[21]=u):u=e[21];let g;e[22]!==u?(g=(0,r.jsx)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-paths",role:"grid",children:u}),e[22]=u,e[23]=g):g=e[23];let b;e[24]!==g||e[25]!==l?(b=(0,r.jsxs)("div",{children:[l,g]}),e[24]=g,e[25]=l,e[26]=b):b=e[26];let x;return e[27]!==b||e[28]!==o||e[29]!==a?(x=(0,r.jsxs)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"logs-summary",children:[o,a,b]}),e[27]=b,e[28]=o,e[29]=a,e[30]=x):x=e[30],x},"Ye");function Ge(i){return(0,r.jsx)(Fe,{bucket:i},i.key)}v(Ge,"je");function He(i){return(0,r.jsx)(Fe,{bucket:i},i.key)}v(He,"Je");var Je=v(i=>{let e=(0,K.c)(46),{liveError:t,onShardKeyChange:n,onShowArchive:s,onShowErrors:o,onShowRequests:c,shardKey:f,view:m}=i,d=z(),a=m==="requests",h=m==="requests"?"bg-muted font-medium":"text-muted-foreground",l;e[0]!==h?(l=W("px-3 py-1 text-sm",h),e[0]=h,e[1]=l):l=e[1];let u;e[2]!==d?(u=d("Requests"),e[2]=d,e[3]=u):u=e[3];let g;e[4]!==c||e[5]!==a||e[6]!==l||e[7]!==u?(g=(0,r.jsx)("button",{"aria-selected":a,className:l,"data-testid":"lg-view-requests",onClick:c,role:"tab",type:"button",children:u}),e[4]=c,e[5]=a,e[6]=l,e[7]=u,e[8]=g):g=e[8];let b=m==="errors",x=m==="errors"?"bg-muted font-medium":"text-muted-foreground",w;e[9]!==x?(w=W("px-3 py-1 text-sm",x),e[9]=x,e[10]=w):w=e[10];let N;e[11]!==d?(N=d("Errors"),e[11]=d,e[12]=N):N=e[12];let y;e[13]!==o||e[14]!==b||e[15]!==w||e[16]!==N?(y=(0,r.jsx)("button",{"aria-selected":b,className:w,"data-testid":"lg-view-errors",onClick:o,role:"tab",type:"button",children:N}),e[13]=o,e[14]=b,e[15]=w,e[16]=N,e[17]=y):y=e[17];let T=m==="archive",R=m==="archive"?"bg-muted font-medium":"text-muted-foreground",L;e[18]!==R?(L=W("px-3 py-1 text-sm",R),e[18]=R,e[19]=L):L=e[19];let k;e[20]!==d?(k=d("Archive"),e[20]=d,e[21]=k):k=e[21];let S;e[22]!==s||e[23]!==T||e[24]!==L||e[25]!==k?(S=(0,r.jsx)("button",{"aria-selected":T,className:L,"data-testid":"lg-view-archive",onClick:s,role:"tab",type:"button",children:k}),e[22]=s,e[23]=T,e[24]=L,e[25]=k,e[26]=S):S=e[26];let p;e[27]!==y||e[28]!==S||e[29]!==g?(p=(0,r.jsxs)("div",{className:"inline-flex overflow-hidden rounded-lg border border-border",role:"tablist",children:[g,y,S]}),e[27]=y,e[28]=S,e[29]=g,e[30]=p):p=e[30];let C;e[31]!==n||e[32]!==f?(C=(0,r.jsx)(be,{onChange:n,testId:"lg-shard-input",value:f}),e[31]=n,e[32]=f,e[33]=C):C=e[33];let q;e[34]!==t||e[35]!==m?(q=m!=="archive"&&(0,r.jsx)(ke,{message:t,prefix:"lg"}),e[34]=t,e[35]=m,e[36]=q):q=e[36];let F;e[37]!==d?(F=d("Open in Cloudflare"),e[37]=d,e[38]=F):F=e[38];let O;e[39]!==F?(O=(0,r.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"lg-cf-link",href:de,rel:"noreferrer",target:"_blank",children:F}),e[39]=F,e[40]=O):O=e[40];let E;return e[41]!==p||e[42]!==C||e[43]!==q||e[44]!==O?(E=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[p,C,q,O]}),e[41]=p,e[42]=C,e[43]=q,e[44]=O,e[45]=E):E=e[45],E},"Xe"),ue=400,Xe=36,Ze={height:ue,overflow:"auto"},Oe={left:0,position:"absolute",top:0,width:"100%"},et={error:"destructive",ok:"secondary"},Ee=v(i=>{let e=(0,K.c)(6),{onOpenTrace:t,traceId:n}=i,s=z(),o;e[0]!==t||e[1]!==s||e[2]!==n?(o=n===void 0?null:(0,r.jsx)("button",{className:"text-primary underline-offset-2 hover:underline","data-testid":"lg-trace-link",onClick:v(()=>{t(n)},"onClick"),type:"button",children:s("Trace")}),e[0]=t,e[1]=s,e[2]=n,e[3]=o):o=e[3];let c;return e[4]!==o?(c=(0,r.jsx)("span",{className:"w-16 shrink-0 text-right",role:"gridcell",children:o}),e[4]=o,e[5]=c):c=e[5],c},"xe"),tt=v(i=>{let e=(0,K.c)(13),{entry:t,index:n,measureRef:s,onOpenTrace:o,start:c}=i,f=`translateY(${String(c)}px)`,m;e[0]!==f?(m={...Oe,transform:f},e[0]=f,e[1]=m):m=e[1];let d=m,a;e[2]!==t?(a=(0,r.jsx)(Re,{entry:t}),e[2]=t,e[3]=a):a=e[3];let h;e[4]!==t.traceId||e[5]!==o?(h=(0,r.jsx)(Ee,{onOpenTrace:o,traceId:t.traceId}),e[4]=t.traceId,e[5]=o,e[6]=h):h=e[6];let l;return e[7]!==n||e[8]!==s||e[9]!==d||e[10]!==a||e[11]!==h?(l=(0,r.jsxs)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":n,"data-testid":"lg-row",ref:s,role:"row",style:d,children:[a,h]}),e[7]=n,e[8]=s,e[9]=d,e[10]=a,e[11]=h,e[12]=l):l=e[12],l},"rt"),Ie=v(i=>i.length===0?"\u2014":i.join(", "),"ce"),rt=v(i=>{let e=(0,K.c)(41),{entry:t,index:n,measureRef:s,onOpenTrace:o,start:c}=i,f=`translateY(${String(c)}px)`,m;e[0]!==f?(m={...Oe,transform:f},e[0]=f,e[1]=m):m=e[1];let d=m,a;e[2]!==t.ts?(a=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=a):a=e[3];let h;e[4]!==a?(h=(0,r.jsx)("span",{className:"w-40 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:a}),e[4]=a,e[5]=h):h=e[5];let l=et[t.outcome],u;e[6]!==t.outcome||e[7]!==l?(u=(0,r.jsx)("span",{className:"w-16 shrink-0",role:"gridcell",children:(0,r.jsx)(ne,{variant:l,children:t.outcome})}),e[6]=t.outcome,e[7]=l,e[8]=u):u=e[8];let g;e[9]!==t.functionPath?(g=(0,r.jsx)("span",{className:"w-44 shrink-0 truncate",role:"gridcell",title:t.functionPath,children:t.functionPath}),e[9]=t.functionPath,e[10]=g):g=e[10];let b=t.shardKey??"\u2014",x;e[11]!==b?(x=(0,r.jsx)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:b}),e[11]=b,e[12]=x):x=e[12];let w=t.userId??"\u2014",N;e[13]!==w?(N=(0,r.jsx)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:w}),e[13]=w,e[14]=N):N=e[14];let y;e[15]!==t.durationMs?(y=Math.round(t.durationMs),e[15]=t.durationMs,e[16]=y):y=e[16];let T=`${String(y)}ms`,R;e[17]!==T?(R=(0,r.jsx)("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:T}),e[17]=T,e[18]=R):R=e[18];let L;e[19]!==t.errorMessage||e[20]!==t.outcome||e[21]!==t.tablesRead||e[22]!==t.tablesWritten?(L=t.outcome==="error"&&t.errorMessage!==void 0?t.errorMessage:`r:${Ie(t.tablesRead)} \xB7 w:${Ie(t.tablesWritten)}`,e[19]=t.errorMessage,e[20]=t.outcome,e[21]=t.tablesRead,e[22]=t.tablesWritten,e[23]=L):L=e[23];let k;e[24]!==L?(k=(0,r.jsx)("span",{className:"flex-1 truncate text-muted-foreground",role:"gridcell",children:L}),e[24]=L,e[25]=k):k=e[25];let S;e[26]!==t.traceId||e[27]!==o?(S=(0,r.jsx)(Ee,{onOpenTrace:o,traceId:t.traceId}),e[26]=t.traceId,e[27]=o,e[28]=S):S=e[28];let p;return e[29]!==n||e[30]!==s||e[31]!==d||e[32]!==N||e[33]!==R||e[34]!==k||e[35]!==S||e[36]!==h||e[37]!==u||e[38]!==g||e[39]!==x?(p=(0,r.jsxs)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":n,"data-testid":"lg-req-row",ref:s,role:"row",style:d,children:[h,u,g,x,N,R,k,S]}),e[29]=n,e[30]=s,e[31]=d,e[32]=N,e[33]=R,e[34]=k,e[35]=S,e[36]=h,e[37]=u,e[38]=g,e[39]=x,e[40]=p):p=e[40],p},"st"),qe=v(i=>{let{entries:e}=i??{};return Array.isArray(e)?e:[]},"de"),at=v(i=>{let e={};return i.functionPathPrefix.trim()!==""&&(e.functionPathPrefix=i.functionPathPrefix.trim()),i.userId.trim()!==""&&(e.userId=i.userId.trim()),i.tableTouched.trim()!==""&&(e.tableTouched=i.tableTouched.trim()),(i.outcome==="ok"||i.outcome==="error")&&(e.outcome=i.outcome),e},"lt"),lt={"5m":300*1e3,"15m":900*1e3,"1h":3600*1e3},ot=v((i,e)=>{let t=e.search.trim().toLowerCase(),n=e.path.trim().toLowerCase(),s=e.range==="all"?Number.NEGATIVE_INFINITY:e.now-lt[e.range];return i.filter(o=>e.levels.size>0&&!e.levels.has(o.level)||o.timestamp<s||n!==""&&!(o.functionPath??"").toLowerCase().includes(n)?!1:t===""||o.message.toLowerCase().includes(t)||ce(o.fields).toLowerCase().includes(t))},"at"),nt="\u2014",st=v(i=>{let e=new Map,t=new Map;for(let o of i){e.set(o.level,(e.get(o.level)??0)+1);let c=o.functionPath??nt;t.set(c,(t.get(c)??0)+1)}let n=me.filter(o=>e.has(o)).map(o=>({count:e.get(o)??0,key:o})),s=[...t.entries()].map(([o,c])=>({count:c,key:o})).toSorted((o,c)=>c.count===o.count?o.key.localeCompare(c.key):c.count-o.count);return{byLevel:n,byPath:s,total:i.length}},"it"),qt=v(({initialShardKey:i})=>{let e=z(),[t,n]=(0,I.useState)("requests"),{queryShardKey:s,setShardKey:o,shardKey:c}=xe(i),[f,m]=(0,I.useState)(""),[d,a]=(0,I.useState)(()=>new Set),[h,l]=(0,I.useState)(""),[u,g]=(0,I.useState)("all"),[b,x]=(0,I.useState)(!1),[w,N]=(0,I.useState)(""),[y,T]=(0,I.useState)(""),[R,L]=(0,I.useState)(""),[k,S]=(0,I.useState)("all"),p=at({functionPathPrefix:w,outcome:k,tableTouched:R,userId:y}),C=le(oe.getRequestLog,p,{enabled:t==="requests",live:!0,shardKey:s}),q=le(oe.getLogs,{},{enabled:t==="errors",live:!0,shardKey:s}),F=t==="requests"?C:q,{error:O,errorSource:E,isLoading:M,liveError:V}=F,_=Te(s),U=qe(q.data),A=qe(C.data);(0,I.useEffect)(()=>{F.data!==void 0&&ve(s)},[F.data,s]);let $=ot(U,{levels:d,now:Date.now(),path:h,range:u,search:f}),Q=st($),X=t==="requests"?A.length:$.length,Z=t==="errors"&&b,Y=(0,I.useMemo)(()=>O!==null?"error":X===0?M?Z?"summary":"list":"empty":Z?"summary":"list",[X,M,O,Z]),he=(0,I.useRef)(null),G=Le({count:X,estimateSize:v(()=>Xe,"estimateSize"),getScrollElement:v(()=>he.current,"getScrollElement"),initialRect:{height:ue,width:800},observeElementRect:v((P,ee)=>Se(P,ee,ue),"observeElementRect"),overscan:8}),Ke=G.getVirtualItems(),Me={height:G.getTotalSize(),position:"relative",width:"100%"};return(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-logs",children:[(0,r.jsx)(Je,{liveError:V,onShardKeyChange:o,onShowArchive:v(()=>{n("archive"),x(!1)},"onShowArchive"),onShowErrors:v(()=>{n("errors"),x(!1)},"onShowErrors"),onShowRequests:v(()=>{n("requests"),x(!1)},"onShowRequests"),shardKey:c,view:t}),t==="errors"&&(0,r.jsx)(Ve,{levelFilter:d,onLogPathChange:v(P=>{l(P.target.value)},"onLogPathChange"),onSearchChange:v(P=>{m(P.target.value)},"onSearchChange"),onTimeRangeChange:v(P=>{g(P.target.value)},"onTimeRangeChange"),onToggleLevel:v(P=>{a(ee=>{let H=new Set(ee);return H.has(P)?H.delete(P):H.add(P),H})},"onToggleLevel"),onToggleSummary:v(()=>{x(P=>!P)},"onToggleSummary"),pathFilter:h,search:f,showSummary:b,timeRange:u}),t==="requests"&&(0,r.jsx)(Qe,{onOutcomeChange:v(P=>{S(P.target.value)},"onOutcomeChange"),onPathChange:v(P=>{N(P.target.value)},"onPathChange"),onTableChange:v(P=>{L(P.target.value)},"onTableChange"),onUserChange:v(P=>{T(P.target.value)},"onUserChange"),outcomeFilter:k,pathPrefix:w,tableFilter:R,userIdFilter:y}),t==="archive"?(0,r.jsx)(Be,{shardKey:s}):(0,r.jsxs)(r.Fragment,{children:[Y==="error"&&(0,r.jsx)(ye,{error:E,shardKey:s,testId:"lg-error"}),Y==="empty"&&(0,r.jsx)(J,{description:e("Function and request logs for this shard show up here as your app handles traffic."),icon:(0,r.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M4 5h16M4 12h16M4 19h10"})}),testId:"lg-empty",title:e("No logs.")}),Y==="summary"&&(0,r.jsx)(Ye,{summary:Q}),Y==="list"&&(0,r.jsx)("div",{className:"rounded-xl border border-border shadow-xs","data-testid":"lg-scroll",ref:he,style:Ze,children:(0,r.jsx)("div",{"aria-label":e("Recent logs"),"data-testid":"lg-table",role:"grid",style:Me,children:Ke.map(P=>t==="requests"?(0,r.jsx)(rt,{entry:A[P.index],index:P.index,measureRef:G.measureElement,onOpenTrace:_,start:P.start},P.key):(0,r.jsx)(tt,{entry:$[P.index],index:P.index,measureRef:G.measureElement,onOpenTrace:_,start:P.start},P.key))})})]})]})},"Wt");export{qt as LogsPanel,ot as filterLogs,st as summarizeLogs};
|