@lunora/studio 1.0.0-alpha.196 → 1.0.0-alpha.197
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/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/packem_chunks/TableEditor.mjs +1 -1
- package/dist/packem_shared/{DataBrowser-zqK4s0IE.mjs → DataBrowser-DLRa1EYq.mjs} +2 -2
- package/dist/standalone/{chunk-HYGZWDB7.js → chunk-27KDQM4D.js} +1 -1
- package/dist/standalone/{chunk-4HGB4HWB.js → chunk-2DEL2YBJ.js} +1 -1
- package/dist/standalone/{chunk-425GLFP3.js → chunk-2OA2FSFF.js} +1 -1
- package/dist/standalone/{chunk-HZ6TVAF3.js → chunk-2VRLRPX7.js} +1 -1
- package/dist/standalone/{chunk-PJKHJCIC.js → chunk-3ATTKBAS.js} +1 -1
- package/dist/standalone/{chunk-NXUZEDGK.js → chunk-4NDUMJBO.js} +1 -1
- package/dist/standalone/{chunk-OGJEN75K.js → chunk-55ZSYJIW.js} +1 -1
- package/dist/standalone/{chunk-GCQEUAKS.js → chunk-5BTKGXYJ.js} +1 -1
- package/dist/standalone/{chunk-TTDW3FTR.js → chunk-5P5R4K4G.js} +1 -1
- package/dist/standalone/{chunk-H5AIVPUF.js → chunk-5ZPM37G7.js} +1 -1
- package/dist/standalone/{chunk-GOJ5JCTC.js → chunk-6VSUIO3X.js} +1 -1
- package/dist/standalone/{chunk-DAAUTRQE.js → chunk-ACZIA4KX.js} +1 -1
- package/dist/standalone/chunk-B4YYP5AH.js +11 -0
- package/dist/standalone/{chunk-ISCGWWET.js → chunk-BKM6EMBQ.js} +1 -1
- package/dist/standalone/{chunk-VDKL2SKM.js → chunk-BX72LN2S.js} +1 -1
- package/dist/standalone/{chunk-HARUS64R.js → chunk-DUS5YSTV.js} +1 -1
- package/dist/standalone/{chunk-XBYHPJFP.js → chunk-DW2WPI2K.js} +1 -1
- package/dist/standalone/{chunk-I73WRNA2.js → chunk-EKEHGHPT.js} +1 -1
- package/dist/standalone/{chunk-GOITJEW6.js → chunk-EWBZPW2U.js} +1 -1
- package/dist/standalone/{chunk-R357HINN.js → chunk-FDY2NVBM.js} +1 -1
- package/dist/standalone/{chunk-HCFPWTSP.js → chunk-FHYAWPNA.js} +1 -1
- package/dist/standalone/{chunk-3DZ6DV43.js → chunk-FZSDIUFA.js} +1 -1
- package/dist/standalone/{chunk-IOEBGFXY.js → chunk-GOL6VVKZ.js} +1 -1
- package/dist/standalone/{chunk-5RC7EB7G.js → chunk-GYTB4A2M.js} +1 -1
- package/dist/standalone/{chunk-3PVQGOWU.js → chunk-HP34OREE.js} +1 -1
- package/dist/standalone/{chunk-VCA27V6S.js → chunk-IY3Q4FMI.js} +1 -1
- package/dist/standalone/{chunk-MFGX5TG2.js → chunk-LJIHGFHU.js} +1 -1
- package/dist/standalone/{chunk-LM4VYHLG.js → chunk-LQI765MA.js} +1 -1
- package/dist/standalone/{chunk-SU7LZGWQ.js → chunk-LZIKJ7N4.js} +1 -1
- package/dist/standalone/{chunk-IWA4HV64.js → chunk-M2EYXPDX.js} +1 -1
- package/dist/standalone/{chunk-MWWJJZMX.js → chunk-MB46H4XH.js} +1 -1
- package/dist/standalone/{chunk-EEPI7RD5.js → chunk-MSYDLNH7.js} +1 -1
- package/dist/standalone/{chunk-O4K2PC3A.js → chunk-OTYTU5PT.js} +1 -1
- package/dist/standalone/{chunk-UYS6VVJA.js → chunk-OZF6QK5O.js} +1 -1
- package/dist/standalone/{chunk-GM5ADIIU.js → chunk-PCHMHMHE.js} +1 -1
- package/dist/standalone/{chunk-S2A6CARX.js → chunk-PD7H5BKL.js} +1 -1
- package/dist/standalone/{chunk-X3CZFQ62.js → chunk-PLDXUMLT.js} +1 -1
- package/dist/standalone/{chunk-7TDTNXSJ.js → chunk-QIXW4S4K.js} +1 -1
- package/dist/standalone/{chunk-2LUUF5RM.js → chunk-QY54P54V.js} +1 -1
- package/dist/standalone/{chunk-TGEC4TTH.js → chunk-QZM4KMEX.js} +1 -1
- package/dist/standalone/{chunk-O47LQ7YR.js → chunk-RIJ5VJGY.js} +1 -1
- package/dist/standalone/{chunk-W57FGW32.js → chunk-S2DHKQCI.js} +1 -1
- package/dist/standalone/{chunk-ZSKVKBTI.js → chunk-SBJV3HW6.js} +1 -1
- package/dist/standalone/{chunk-QWLFFOVP.js → chunk-SSMXYD2M.js} +1 -1
- package/dist/standalone/{chunk-56BRFXVG.js → chunk-T2RLHI5N.js} +1 -1
- package/dist/standalone/{chunk-4YRBL2BF.js → chunk-T53H5D2A.js} +1 -1
- package/dist/standalone/{chunk-OEM2AQSE.js → chunk-UUCBHRSG.js} +1 -1
- package/dist/standalone/{chunk-KWLJEG4G.js → chunk-VIIZ5YJB.js} +1 -1
- package/dist/standalone/{chunk-7EDZNLVG.js → chunk-VQJD345K.js} +1 -1
- package/dist/standalone/{chunk-HKYYSETK.js → chunk-VUXVPYAD.js} +1 -1
- package/dist/standalone/{chunk-PKUEXDSC.js → chunk-W3OQPG5Z.js} +1 -1
- package/dist/standalone/{chunk-IUOWYLXN.js → chunk-WIJSO6ZU.js} +1 -1
- package/dist/standalone/{chunk-CGSVO47H.js → chunk-WYU6OKTT.js} +1 -1
- package/dist/standalone/{chunk-JI6MEPCE.js → chunk-XQBWIYQN.js} +1 -1
- package/dist/standalone/{chunk-2HTSOS6M.js → chunk-ZA5KJ2E3.js} +3 -3
- package/dist/standalone/{chunk-GJH2G5M2.js → chunk-ZW5AIWQO.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +3 -3
- package/dist/standalone/chunk-IL4CKMJM.js +0 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as E}from"./chunk-66UGPQVC.js";import{a as w}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import{b as T}from"./chunk-
|
|
1
|
+
import{a as E}from"./chunk-66UGPQVC.js";import{a as w}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import{b as T}from"./chunk-T53H5D2A.js";import{f as A}from"./chunk-B4YYP5AH.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as j}from"./chunk-FKVZRPV5.js";import{a as _,b as $,c as C,d as g,e as o,f as l}from"./chunk-HEAQVSNS.js";import{a as I,e as S}from"./chunk-WUWBZPUK.js";import{d as k,o as B,r as R}from"./chunk-FODLDLE2.js";import{a as h,d as y,f as K,g as L}from"./chunk-YKXDMIHQ.js";var H=y(K(),1);var s=y(L(),1);var z=200,U=h(()=>{let e=(0,H.c)(21),n=A(),t=k(),u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=["lunora-auth-sessions",z],e[0]=u):u=e[0];let p;e[1]!==n?(p=h(()=>n.listAuthSessions({limit:z}),"u"),e[1]=n,e[2]=p):p=e[2];let a=T(u,p),{error:f}=a,i=a.data?.rows??null,x;e[3]!==a?(x=h(()=>{a.refetch()},"p"),e[3]=a,e[4]=x):x=e[4],E(x,!0);let N;e[5]!==n||e[6]!==a?(N=h(r=>{B((async()=>{await n.revokeAuthSession({sessionId:r}),a.refetch()})())},"x"),e[5]=n,e[6]=a,e[7]=N):N=e[7];let v=N,d;e[8]!==f?(d=f!==null&&(0,s.jsx)("p",{className:"text-sm text-destructive","data-testid":"auth-sessions-error",role:"alert",children:f}),e[8]=f,e[9]=d):d=e[9];let c;e[10]!==i||e[11]!==t?(c=i!==null&&i.length===0&&(0,s.jsx)(j,{testId:"auth-sessions-empty",title:t("No active sessions.")}),e[10]=i,e[11]=t,e[12]=c):c=e[12];let m;e[13]!==v||e[14]!==i||e[15]!==t?(m=i!==null&&i.length>0&&(0,s.jsx)(I,{className:"overflow-hidden py-0",children:(0,s.jsx)(S,{className:"px-0",children:(0,s.jsxs)(_,{"data-testid":"auth-sessions-table",children:[(0,s.jsx)($,{children:(0,s.jsxs)(g,{children:[(0,s.jsx)(o,{children:t("user")}),(0,s.jsx)(o,{children:t("expires")}),(0,s.jsx)(o,{children:t("ip")}),(0,s.jsx)(o,{children:t("user agent")}),(0,s.jsx)(o,{children:t("impersonated by")}),(0,s.jsx)(o,{"aria-label":t("Actions")})]})}),(0,s.jsx)(C,{children:i.map(r=>(0,s.jsxs)(g,{"data-testid":`auth-session-${r.id}`,children:[(0,s.jsx)(l,{className:"font-mono text-xs",children:r.userId}),(0,s.jsx)(l,{className:"text-muted-foreground tabular-nums",children:R(r.expiresAt)}),(0,s.jsx)(l,{children:r.ipAddress??""}),(0,s.jsx)(l,{className:"max-w-40 truncate",children:r.userAgent??""}),(0,s.jsx)(l,{className:"font-mono text-xs",children:r.impersonatedBy??""}),(0,s.jsx)(l,{children:(0,s.jsx)(w,{"data-testid":`auth-session-revoke-${r.id}`,onClick:h(()=>{v(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:t("Revoke")})})]},r.id))})]})})}),e[13]=v,e[14]=i,e[15]=t,e[16]=m):m=e[16];let b;return e[17]!==d||e[18]!==c||e[19]!==m?(b=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"auth-sessions",children:[d,c,m]}),e[17]=d,e[18]=c,e[19]=m,e[20]=b):b=e[20],b},"K");export{U as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as D}from"./chunk-BOTGXX4H.js";import{b as C}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import"./chunk-35DM4JJG.js";import{a as L}from"./chunk-4ZEL6BYL.js";import{c as $}from"./chunk-
|
|
1
|
+
import{a as D}from"./chunk-BOTGXX4H.js";import{b as C}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import"./chunk-35DM4JJG.js";import{a as L}from"./chunk-4ZEL6BYL.js";import{c as $}from"./chunk-T53H5D2A.js";import"./chunk-B4YYP5AH.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as I}from"./chunk-FKVZRPV5.js";import{a as T,b as k,c as A,d as g,e as c,f as l}from"./chunk-HEAQVSNS.js";import{a as b,e as S}from"./chunk-WUWBZPUK.js";import{d as w}from"./chunk-FODLDLE2.js";import{a as f,d as y,f as _,g as j}from"./chunk-YKXDMIHQ.js";var O=y(_(),1);var t=y(j(),1);var E="container:",M={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},B=f(e=>{let n=e.indexOf(":");if(n===-1)return{event:e.trim()};let r=e.slice(n+1).trim(),a=e.slice(0,n).trim();return r===""?{event:a}:{detail:r,event:a}},"B"),P=f(e=>{let n=new Map;for(let r of e){let a=r.functionPath??"";if(!a.startsWith(E))continue;let i=a.slice(E.length);if(i==="")continue;let s=JSON.stringify([i,r.instance??""]),o=n.get(s);if(o!==void 0&&o.timestamp>=r.timestamp)continue;let{detail:p,event:d}=B(r.message);n.set(s,{detail:p,event:d,exitCode:r.exitCode,instance:r.instance,level:r.level,name:i,state:M[d]??"unknown",timestamp:r.timestamp})}return[...n.values()].toSorted((r,a)=>r.name.localeCompare(a.name)||(r.instance??"").localeCompare(a.instance??""))},"D"),W={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},q=f(e=>{let{entries:n}=e??{};return Array.isArray(n)?n:[]},"P"),V=f(()=>{let e=(0,O.c)(19),n=w(),r,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},a={live:!0,shardKey:""},e[0]=r,e[1]=a):(r=e[0],a=e[1]);let{data:i,error:s,liveError:o}=$(L.getLogs,r,a),p=i!==void 0,d;if(e[2]!==i||e[3]!==s||e[4]!==o||e[5]!==p||e[6]!==n){let N=P(q(i)),x;e[8]!==s?(x=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:s}),e[8]=s,e[9]=x):x=e[9];let m;e[10]!==n?(m=n("Cloudflare Containers are observed from their lifecycle log stream. This shows the current state per instance \u2014 ports and health checks aren't carried in that stream."),e[10]=n,e[11]=m):m=e[11];let u;e[12]!==m?(u=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:m}),e[12]=m,e[13]=u):u=e[13];let h;e[14]!==o?(h=(0,t.jsx)(D,{message:o,prefix:"containers"}),e[14]=o,e[15]=h):h=e[15];let v;e[16]!==u||e[17]!==h?(v=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[u,h]}),e[16]=u,e[17]=h,e[18]=v):v=e[18],d=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[x,v,p&&N.length===0?(0,t.jsx)(I,{description:n("No container lifecycle activity yet. Instances declared with defineContainer show up here once they start, sleep, stop, or error."),testId:"containers-empty",title:n("No container activity")}):(0,t.jsx)(b,{className:"overflow-hidden py-0",children:(0,t.jsx)(S,{className:"px-0",children:(0,t.jsxs)(T,{"data-testid":"containers-table",children:[(0,t.jsx)(k,{children:(0,t.jsxs)(g,{children:[(0,t.jsx)(c,{children:n("Container")}),(0,t.jsx)(c,{children:n("Instance")}),(0,t.jsx)(c,{children:n("State")}),(0,t.jsx)(c,{children:n("Last event")}),(0,t.jsx)(c,{children:n("Detail")}),(0,t.jsx)(c,{children:n("Exit")}),(0,t.jsx)(c,{children:n("When")})]})}),(0,t.jsx)(A,{children:N.map(F)})]})})})]}),e[2]=i,e[3]=s,e[4]=o,e[5]=p,e[6]=n,e[7]=d}else d=e[7];return d},"q");function F(e){return(0,t.jsxs)(g,{"data-testid":`containers-row-${e.name}${e.instance===void 0?"":`-${e.instance}`}`,children:[(0,t.jsx)(l,{className:"font-mono text-xs",children:e.name}),(0,t.jsx)(l,{className:"max-w-40 truncate font-mono text-xs text-muted-foreground",title:e.instance,children:e.instance??"\u2014"}),(0,t.jsx)(l,{children:(0,t.jsx)(C,{variant:W[e.state],children:e.state})}),(0,t.jsx)(l,{className:"font-mono text-xs text-muted-foreground",children:e.event}),(0,t.jsx)(l,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"\u2014"}),(0,t.jsx)(l,{className:"font-mono text-xs tabular-nums text-muted-foreground",children:e.exitCode??"\u2014"}),(0,t.jsx)(l,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]},`${e.name}/${e.instance??""}`)}f(F,"j");export{V as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{b as Se,c as Ie}from"./chunk-YOB2X3FZ.js";import{a as we}from"./chunk-EA2JKR5D.js";import{a as ye}from"./chunk-PD6WIDY6.js";import{a as Ne}from"./chunk-2DX5MROH.js";import{b as pe}from"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as he}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import{a as H}from"./chunk-4ZEL6BYL.js";import{d as ge}from"./chunk-
|
|
1
|
+
import{b as Se,c as Ie}from"./chunk-YOB2X3FZ.js";import{a as we}from"./chunk-EA2JKR5D.js";import{a as ye}from"./chunk-PD6WIDY6.js";import{a as Ne}from"./chunk-2DX5MROH.js";import{b as pe}from"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as he}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import{a as H}from"./chunk-4ZEL6BYL.js";import{d as ge}from"./chunk-T53H5D2A.js";import{f as xe}from"./chunk-B4YYP5AH.js";import"./chunk-FSRSK4LY.js";import{d as se}from"./chunk-MKL7VDTL.js";import{a as ne,e as ie}from"./chunk-WUWBZPUK.js";import{d as be,f as ce,g as de,h as ee,o as me}from"./chunk-FODLDLE2.js";import{a as s,d as le,e as Ce,f as Te,g as Ee}from"./chunk-YKXDMIHQ.js";var ve=le(Te(),1);var g=le(Ce(),1);var r=le(Ee(),1);var Ae=ce(H.exportShard),Oe=ce(H.importShard),Le=s(x=>x.map(e=>JSON.stringify(Se(e))).join(`
|
|
2
2
|
`),"Ce"),Je=s(x=>{let e=[],te=x.split(`
|
|
3
3
|
`);for(let[n,N]of te.entries()){let t=N.trim();if(t==="")continue;let o=Ie(JSON.parse(t));if(typeof o!="object"||o===null)throw new se("INTERNAL",`line ${(n+1).toString()}: expected a { table, doc } object`);let b=o;if(typeof b.table!="string"||typeof b.doc!="object"||b.doc===null||Array.isArray(b.doc))throw new se("INTERNAL",`line ${(n+1).toString()}: expected a { table, doc } object`);e.push(b)}return e},"Te"),He=s(x=>{let e=(0,ve.c)(94),{initialShardKey:te}=x,n=xe(),N=ge(),t=be(),[o,b]=(0,g.useState)(te??""),[a,fe]=(0,g.useState)(""),[d,K]=(0,g.useState)(!1),[Q,M]=(0,g.useState)(null),[i,re]=(0,g.useState)(null),[y,ue]=(0,g.useState)(null),V;e[0]!==n||e[1]!==o?(V=s(async()=>{K(!0),M(null),re(null);try{let c=await n.query(Ae,{},de(o));pe(o),fe(Le(c.rows)),ue(c.rows.length)}catch(c){M(ee(c))}K(!1)},"G"),e[0]=n,e[1]=o,e[2]=V):V=e[2];let z=V,W;e[3]!==n||e[4]!==N||e[5]!==a||e[6]!==o||e[7]!==t?(W=s(async()=>{K(!0),M(null),re(null),ue(null);let c;try{c=Je(a)}catch(l){M(t("Invalid NDJSON: {message}",{message:ee(l)})),K(!1);return}try{let l=await n.query(Oe,{rows:c},de(o));pe(o),re(l),N(H.readTablePage),N(H.listTables)}catch(l){M(ee(l))}K(!1)},"Q"),e[3]=n,e[4]=N,e[5]=a,e[6]=o,e[7]=t,e[8]=W):W=e[8];let G=W,w,S,I,m,v,p,f,j,C,u,T;if(e[9]!==d||e[10]!==y||e[11]!==z||e[12]!==i||e[13]!==G||e[14]!==a||e[15]!==o||e[16]!==t){let c=i===null?0:Object.values(i.inserted).reduce(_e,0),l;e[28]!==z?(l=s(()=>{me(z())},"o"),e[28]=z,e[29]=l):l=e[29];let oe=l,Y;e[30]!==G?(Y=s(()=>{me(G())},"Y"),e[30]=G,e[31]=Y):Y=e[31];let ae=Y,Z;e[32]===Symbol.for("react.memo_cache_sentinel")?(Z=s(h=>{fe(h.target.value)},"Z"),e[32]=Z):Z=e[32];let je=Z;T="flex flex-col gap-4",I="lunora-export-import";let L;e[33]!==t?(L=t("Export"),e[33]=t,e[34]=L):L=e[34];let J;e[35]!==L?(J=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:L})}),e[35]=L,e[36]=J):J=e[36];let _;e[37]!==o?(_=(0,r.jsx)(Ne,{onChange:b,testId:"ei-shard-input",value:o}),e[37]=o,e[38]=_):_=e[38];let $;e[39]!==t?($=t("Export"),e[39]=t,e[40]=$):$=e[40];let k;e[41]!==d||e[42]!==oe||e[43]!==$?(k=(0,r.jsx)(he,{"data-testid":"ei-export",disabled:d,onClick:oe,type:"button",children:$}),e[41]=d,e[42]=oe,e[43]=$,e[44]=k):k=e[44];let D;e[45]!==_||e[46]!==k?(D=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[_,k]}),e[45]=_,e[46]=k,e[47]=D):D=e[47];let q;e[48]!==y||e[49]!==t?(q=y!==null&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ei-export-result",children:t("Exported {count} rows.",{count:y})}),e[48]=y,e[49]=t,e[50]=q):q=e[50];let B;e[51]!==D||e[52]!==q?(B=(0,r.jsxs)(ie,{className:"flex flex-col gap-3 p-4",children:[D,q]}),e[51]=D,e[52]=q,e[53]=B):B=e[53],e[54]!==J||e[55]!==B?(m=(0,r.jsxs)(ne,{className:"gap-0 py-0 rounded-xl border border-border bg-card shadow-xs",children:[J,B]}),e[54]=J,e[55]=B,e[56]=m):m=e[56],S=ne,C="gap-0 py-0 rounded-xl border border-border bg-card shadow-xs";let P;e[57]!==t?(P=t("Import"),e[57]=t,e[58]=P):P=e[58],e[59]!==P?(u=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:P})}),e[59]=P,e[60]=u):u=e[60],w=ie,v="flex flex-col gap-3 p-4",e[61]!==a?(p=(0,r.jsx)(we,{"aria-label":"NDJSON",className:"font-mono text-xs min-h-40 rounded-md","data-testid":"ei-ndjson",onChange:je,placeholder:'{"table":"messages","doc":{\u2026}}',value:a}),e[61]=a,e[62]=p):p=e[62];let R;e[63]!==t?(R=t("Import (writes rows)?"),e[63]=t,e[64]=R):R=e[64];let U;e[65]!==d||e[66]!==a?(U=d||a.trim()==="",e[65]=d,e[66]=a,e[67]=U):U=e[67];let F;e[68]!==t?(F=t("Import"),e[68]=t,e[69]=F):F=e[69],e[70]!==ae||e[71]!==R||e[72]!==U||e[73]!==F?(f=(0,r.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:(0,r.jsx)(ye,{confirmLabel:R,disabled:U,onConfirm:ae,testId:"ei-import",children:F})}),e[70]=ae,e[71]=R,e[72]=U,e[73]=F,e[74]=f):f=e[74],j=i!==null&&(0,r.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ei-import-result",children:[(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:t("Inserted {inserted}, {conflicts} conflicts, {errors} errors.",{conflicts:i.conflicts,errors:i.errors.length,inserted:c})}),i.errors.length>0&&(0,r.jsx)("ul",{className:"flex flex-col gap-1","data-testid":"ei-import-errors",children:i.errors.map(h=>(0,r.jsx)("li",{className:"text-xs text-destructive",children:t("line {line} ({table}): {message}",{line:h.line,message:h.message,table:h.table})},`${h.table}-${h.line.toString()}`))})]}),e[9]=d,e[10]=y,e[11]=z,e[12]=i,e[13]=G,e[14]=a,e[15]=o,e[16]=t,e[17]=w,e[18]=S,e[19]=I,e[20]=m,e[21]=v,e[22]=p,e[23]=f,e[24]=j,e[25]=C,e[26]=u,e[27]=T}else w=e[17],S=e[18],I=e[19],m=e[20],v=e[21],p=e[22],f=e[23],j=e[24],C=e[25],u=e[26],T=e[27];let E;e[75]!==w||e[76]!==v||e[77]!==p||e[78]!==f||e[79]!==j?(E=(0,r.jsxs)(w,{className:v,children:[p,f,j]}),e[75]=w,e[76]=v,e[77]=p,e[78]=f,e[79]=j,e[80]=E):E=e[80];let A;e[81]!==S||e[82]!==E||e[83]!==C||e[84]!==u?(A=(0,r.jsxs)(S,{className:C,children:[u,E]}),e[81]=S,e[82]=E,e[83]=C,e[84]=u,e[85]=A):A=e[85];let O;e[86]!==Q?(O=Q!==null&&(0,r.jsx)("p",{className:"text-sm text-destructive","data-testid":"ei-error",role:"alert",children:Q}),e[86]=Q,e[87]=O):O=e[87];let X;return e[88]!==I||e[89]!==m||e[90]!==A||e[91]!==O||e[92]!==T?(X=(0,r.jsxs)("div",{className:T,"data-testid":I,children:[m,A,O]}),e[88]=I,e[89]=m,e[90]=A,e[91]=O,e[92]=T,e[93]=X):X=e[93],X},"Ue");function _e(x,e){return x+e}s(_e,"Ae");export{He as ExportImportPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Ge}from"./chunk-3FBLWUXD.js";import{a as Qe,b as qe}from"./chunk-O47LQ7YR.js";import{a as Xe}from"./chunk-TIUMFAN2.js";import{a as He}from"./chunk-XZMOZFE6.js";import{a as j}from"./chunk-IMOHEGMV.js";import{a as Ke}from"./chunk-66UGPQVC.js";import{a as Ze}from"./chunk-QKEJLVC5.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import{W as E}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as U}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as D}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{b as Ve}from"./chunk-4YRBL2BF.js";import{f as V}from"./chunk-IL4CKMJM.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as Me}from"./chunk-FKVZRPV5.js";import{a as Se,b as ze,c as Ue,d as T,e as S,f as z}from"./chunk-HEAQVSNS.js";import{a as H,e as W}from"./chunk-WUWBZPUK.js";import{d as q,h as Pe,n as Fe,o as J,r as Q}from"./chunk-FODLDLE2.js";import{a as s,d as Oe,e as tt,f as at,g as it}from"./chunk-YKXDMIHQ.js";var x=Oe(tt(),1);var X=Oe(at(),1);var t=Oe(it(),1);Qe.capabilities;var lt=s(()=>{let h=(0,X.c)(3),{config:e,ready:l}=qe(),i;return h[0]!==e.capabilities||h[1]!==l?(i={capabilities:e.capabilities,ready:l},h[0]=e.capabilities,h[1]=l,h[2]=i):i=h[2],i},"st"),st=s((h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending","nt"),Ye=500,nt=s(()=>{let h=V(),e=q(),[l,i]=(0,x.useState)(""),[m,a]=(0,x.useState)(null),[c,n]=(0,x.useState)(null),[d,v]=(0,x.useState)(!1),f=Ve(["lunora-auth-sign-up-invitations",Ye],()=>h.listAuthSignUpInvitations({limit:Ye})),C=f.data?.rows??null,y=f.data?.total??0,A=s(()=>{let r=l.trim();r!==""&&(a(null),J((async()=>{try{let u=await h.createAuthSignUpInvitation({email:r}),p=typeof u.token=="string"?u.token:void 0;n(p===void 0?null:`${globalThis.location.origin}/sign-up?email=${encodeURIComponent(r)}&invite=${encodeURIComponent(p)}`),v(!1),i(""),f.refetch()}catch(u){a(u instanceof Error?u.message:String(u))}})()))},"A"),N=s(()=>{let r="navigator"in globalThis?globalThis.navigator.clipboard:void 0;c===null||r===void 0||J(r.writeText(c).then(()=>(v(!0),!0)))},"y"),I=s(r=>{a(null),J((async()=>{try{await h.revokeAuthSignUpInvitation({email:r}),f.refetch()}catch(u){a(u instanceof Error?u.message:String(u))}})())},"I");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)(E,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:s(r=>{i(r.target.value)},"onChange"),placeholder:e("ada@example.com"),type:"email",value:l}),(0,t.jsx)(U,{"data-testid":"sign-up-invitation-submit",onClick:A,type:"button",children:e("Invite")})]}),c!==null&&(0,t.jsx)(H,{children:(0,t.jsxs)(W,{className:"flex flex-col gap-2 p-4",children:[(0,t.jsx)("p",{className:"text-sm",children:e("Send this link to the invitee. It is shown once and cannot be recovered.")}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(E,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:c}),(0,t.jsx)(U,{"data-testid":"sign-up-invitation-copy",onClick:N,type:"button",children:e(d?"Copied":"Copy")})]})]})}),(m??f.error)!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:m??f.error}),C!==null&&C.length===0&&(0,t.jsx)(Me,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),C!==null&&y>C.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.")}),C!==null&&C.length>0&&(0,t.jsx)(H,{children:(0,t.jsx)(W,{className:"p-0",children:(0,t.jsxs)(Se,{children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:e("Email")}),(0,t.jsx)(S,{children:e("Status")}),(0,t.jsx)(S,{children:e("Expires")}),(0,t.jsx)(S,{children:e("Invited by")}),(0,t.jsx)(S,{})]})}),(0,t.jsx)(Ue,{children:C.map(r=>{let u=st(r,Date.now()),p=r.email??"";return(0,t.jsxs)(T,{"data-testid":`sign-up-invitation-${p}`,children:[(0,t.jsx)(z,{children:p}),(0,t.jsxs)(z,{"data-testid":`sign-up-invitation-status-${p}`,children:[u==="spent"&&e("Accepted"),u==="expired"&&e("Expired"),u==="pending"&&e("Pending")]}),(0,t.jsx)(z,{children:typeof r.expiresAt=="number"?Q(r.expiresAt):"\u2014"}),(0,t.jsx)(z,{children:r.invitedBy??"\u2014"}),(0,t.jsx)(z,{className:"text-right",children:(0,t.jsx)(U,{onClick:s(()=>{I(p)},"onClick"),type:"button",variant:"ghost",children:e("Revoke")})})]},r.id)})})]})})})]})},"lt"),rt={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},dt=s((h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),"it"),ot=s((h,e)=>{if(h.type==="boolean")return e===!0?{value:!0}:h.required?{value:!1}:void 0;let l=typeof e=="string"?e.trim():"";if(l!==""){if(h.type==="number"){let i=Number(l);return Number.isNaN(i)?void 0:{value:i}}return{value:l}}},"rt"),ct=s(h=>{let e=(0,X.c)(105),{onClose:l,onCreated:i}=h,m=V(),a=q(),{config:c}=qe(),{busy:n,error:d,run:v}=Xe(),[f,C]=(0,x.useState)(""),[y,A]=(0,x.useState)(""),[N,I]=(0,x.useState)(""),[r,u]=(0,x.useState)(""),p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let[g,o]=(0,x.useState)(p),F;e[1]===Symbol.for("react.memo_cache_sentinel")?(F=s(b=>{C(b.target.value)},"F"),e[1]=F):F=e[1];let k=F,$;e[2]===Symbol.for("react.memo_cache_sentinel")?($=s(b=>{A(b.target.value)},"E"),e[2]=$):$=e[2];let L=$,_;e[3]===Symbol.for("react.memo_cache_sentinel")?(_=s(b=>{I(b.target.value)},"D"),e[3]=_):_=e[3];let Be=_,Z;e[4]===Symbol.for("react.memo_cache_sentinel")?(Z=s(b=>{u(b.target.value)},"Z"),e[4]=Z):Z=e[4];let De=Z,G;e[5]===Symbol.for("react.memo_cache_sentinel")?(G=s((b,R)=>{o(K=>({...K,[b]:R}))},"W"),e[5]=G):G=e[5];let _e=G,Y;e[6]!==g?(Y=s(b=>g[b.name]??(b.type==="boolean"?!1:""),"J"),e[6]=g,e[7]=Y):Y=e[7];let P=Y,ee;if(e[8]!==c.userFields||e[9]!==P){let b;e[11]!==P?(b=s(R=>!R.required||dt(R,P(R)),"g"),e[11]=P,e[12]=b):b=e[12],ee=c.userFields.every(b),e[8]=c.userFields,e[9]=P,e[10]=ee}else ee=e[10];let $e=ee,te;e[13]!==n||e[14]!==f||e[15]!==y||e[16]!==$e?(te=!n&&f.trim()!==""&&y.trim()!==""&&$e,e[13]=n,e[14]=f,e[15]=y,e[16]=$e,e[17]=te):te=e[17];let Te=te,ae;e[18]!==c.userFields||e[19]!==P?(ae=s(()=>{let b={};for(let R of c.userFields){let K=ot(R,P(R));K!==void 0&&(b[R.name]=K.value)}return Object.keys(b).length===0?void 0:b},"ee"),e[18]=c.userFields,e[19]=P,e[20]=ae):ae=e[20];let Re=ae,ie;e[21]!==Re||e[22]!==m||e[23]!==f||e[24]!==y||e[25]!==l||e[26]!==i||e[27]!==N||e[28]!==r||e[29]!==v?(ie=s(()=>{v(async()=>{await m.createAuthUser({data:Re(),email:f.trim(),name:y.trim(),password:N===""?void 0:N,role:r.trim()===""?void 0:r.trim()}),i(),l()})},"te"),e[21]=Re,e[22]=m,e[23]=f,e[24]=y,e[25]=l,e[26]=i,e[27]=N,e[28]=r,e[29]=v,e[30]=ie):ie=e[30];let w=ie,B;e[31]!==a?(B=a("Create user"),e[31]=a,e[32]=B):B=e[32];let O;e[33]!==a?(O=a("Create user"),e[33]=a,e[34]=O):O=e[34];let M;e[35]!==O?(M=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:O}),e[35]=O,e[36]=M):M=e[36];let le;e[37]!==a?(le=a("email"),e[37]=a,e[38]=le):le=e[38];let se;e[39]!==le?(se=(0,t.jsx)(j,{htmlFor:"uc-email",children:le}),e[39]=le,e[40]=se):se=e[40];let ne;e[41]!==f?(ne=(0,t.jsx)(E,{"data-testid":"uc-email",id:"uc-email",onChange:k,type:"email",value:f}),e[41]=f,e[42]=ne):ne=e[42];let re;e[43]!==se||e[44]!==ne?(re=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[se,ne]}),e[43]=se,e[44]=ne,e[45]=re):re=e[45];let de;e[46]!==a?(de=a("name"),e[46]=a,e[47]=de):de=e[47];let oe;e[48]!==de?(oe=(0,t.jsx)(j,{htmlFor:"uc-name",children:de}),e[48]=de,e[49]=oe):oe=e[49];let ce;e[50]!==y?(ce=(0,t.jsx)(E,{"data-testid":"uc-name",id:"uc-name",onChange:L,value:y}),e[50]=y,e[51]=ce):ce=e[51];let ue;e[52]!==oe||e[53]!==ce?(ue=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[oe,ce]}),e[52]=oe,e[53]=ce,e[54]=ue):ue=e[54];let he;e[55]!==a?(he=a("Password (optional)"),e[55]=a,e[56]=he):he=e[56];let me;e[57]!==he?(me=(0,t.jsx)(j,{htmlFor:"uc-password",children:he}),e[57]=he,e[58]=me):me=e[58];let pe;e[59]!==N?(pe=(0,t.jsx)(E,{"data-testid":"uc-password",id:"uc-password",onChange:Be,type:"password",value:N}),e[59]=N,e[60]=pe):pe=e[60];let ve;e[61]!==me||e[62]!==pe?(ve=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[me,pe]}),e[61]=me,e[62]=pe,e[63]=ve):ve=e[63];let fe;e[64]!==a?(fe=a("Role (optional)"),e[64]=a,e[65]=fe):fe=e[65];let be;e[66]!==fe?(be=(0,t.jsx)(j,{htmlFor:"uc-role",children:fe}),e[66]=fe,e[67]=be):be=e[67];let xe;e[68]!==r?(xe=(0,t.jsx)(E,{"data-testid":"uc-role",id:"uc-role",onChange:De,value:r}),e[68]=r,e[69]=xe):xe=e[69];let ye;e[70]!==be||e[71]!==xe?(ye=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[be,xe]}),e[70]=be,e[71]=xe,e[72]=ye):ye=e[72];let ge;e[73]!==c.userFields||e[74]!==P||e[75]!==a?(ge=c.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")}),c.userFields.map(b=>{let R=`uc-field-${b.name}`,K=b.required?"":` (${a("optional")})`;if(b.type==="boolean"){let Le=P(b)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:R,children:[(0,t.jsx)(Ge,{checked:Le,"data-testid":R,id:R,onCheckedChange:s(et=>{_e(b.name,et)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[b.name,K]})]},b.name)}let Je=P(b);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(j,{htmlFor:R,children:[b.name,K]}),(0,t.jsx)(E,{"data-testid":R,id:R,onChange:s(Le=>{_e(b.name,Le.target.value)},"onChange"),type:rt[b.type],value:typeof Je=="string"?Je:""})]},b.name)})]}),e[73]=c.userFields,e[74]=P,e[75]=a,e[76]=ge):ge=e[76];let Ne;e[77]!==d?(Ne=d!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:d}),e[77]=d,e[78]=Ne):Ne=e[78];let ke;e[79]!==a?(ke=a("Cancel"),e[79]=a,e[80]=ke):ke=e[80];let we;e[81]!==l||e[82]!==ke?(we=(0,t.jsx)(U,{"data-testid":"uc-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:ke}),e[81]=l,e[82]=ke,e[83]=we):we=e[83];let je=!Te,Ce;e[84]!==n||e[85]!==a?(Ce=a(n?"Creating\u2026":"Create"),e[84]=n,e[85]=a,e[86]=Ce):Ce=e[86];let Ae;e[87]!==w||e[88]!==je||e[89]!==Ce?(Ae=(0,t.jsx)(U,{"data-testid":"uc-submit",disabled:je,onClick:w,size:"sm",type:"button",children:Ce}),e[87]=w,e[88]=je,e[89]=Ce,e[90]=Ae):Ae=e[90];let Ie;e[91]!==we||e[92]!==Ae?(Ie=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[we,Ae]}),e[91]=we,e[92]=Ae,e[93]=Ie):Ie=e[93];let Ee;return e[94]!==l||e[95]!==B||e[96]!==M||e[97]!==re||e[98]!==ue||e[99]!==ve||e[100]!==ye||e[101]!==ge||e[102]!==Ne||e[103]!==Ie?(Ee=(0,t.jsxs)(He,{label:B,onClose:l,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[M,re,ue,ve,ye,ge,Ne,Ie]}),e[94]=l,e[95]=B,e[96]=M,e[97]=re,e[98]=ue,e[99]=ve,e[100]=ye,e[101]=ge,e[102]=Ne,e[103]=Ie,e[104]=Ee):Ee=e[104],Ee},"ot"),We=s(h=>{let e=(0,X.c)(2),{children:l}=h,i;return e[0]!==l?(i=(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l}),e[0]=l,e[1]=i):i=e[1],i},"je"),ut=s(h=>{let e=(0,X.c)(29),{busy:l,runAction:i,userId:m,version:a}=h,c=V(),n=q(),[d,v]=(0,x.useState)(null),[f,C]=(0,x.useState)(null),y;e[0]!==c||e[1]!==m?(y=s(()=>{J((async()=>{C(null);try{let k=await c.listAuthSessions({limit:50,userId:m});v(k.rows)}catch(k){let $=k;v(null),C(Pe($))}})())},"b"),e[0]=c,e[1]=m,e[2]=y):y=e[2];let A;e[3]!==c||e[4]!==m||e[5]!==a?(A=[c,m,a],e[3]=c,e[4]=m,e[5]=a,e[6]=A):A=e[6],(0,x.useEffect)(y,A);let N;e[7]!==c||e[8]!==i?(N=s(k=>{i(()=>c.revokeAuthSession({sessionId:k}))},"y"),e[7]=c,e[8]=i,e[9]=N):N=e[9];let I=N,r;e[10]!==n?(r=n("Sessions"),e[10]=n,e[11]=r):r=e[11];let u;e[12]!==r?(u=(0,t.jsx)(We,{children:r}),e[12]=r,e[13]=u):u=e[13];let p;e[14]!==f?(p=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:f}),e[14]=f,e[15]=p):p=e[15];let g;e[16]!==d||e[17]!==n?(g=d!==null&&d.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:n("No active sessions.")}),e[16]=d,e[17]=n,e[18]=g):g=e[18];let o;e[19]!==l||e[20]!==I||e[21]!==d||e[22]!==n?(o=d!==null&&d.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:n("expires")}),(0,t.jsx)(S,{children:n("ip")}),(0,t.jsx)(S,{children:n("user agent")}),(0,t.jsx)(S,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Ue,{children:d.map(k=>(0,t.jsxs)(T,{"data-testid":`ud-session-${k.id}`,children:[(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q(k.expiresAt)}),(0,t.jsx)(z,{children:k.ipAddress??""}),(0,t.jsx)(z,{className:"max-w-40 truncate",children:k.userAgent??""}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`ud-revoke-${k.id}`,disabled:l,onClick:s(()=>{I(k.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Revoke")})})]},k.id))})]})})}),e[19]=l,e[20]=I,e[21]=d,e[22]=n,e[23]=o):o=e[23];let F;return e[24]!==u||e[25]!==p||e[26]!==g||e[27]!==o?(F=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[u,p,g,o]}),e[24]=u,e[25]=p,e[26]=g,e[27]=o,e[28]=F):F=e[28],F},"dt"),ht=s(h=>{let e=(0,X.c)(30),{busy:l,runAction:i,userId:m,version:a}=h,c=V(),n=q(),[d,v]=(0,x.useState)(null),[f,C]=(0,x.useState)(null),y;e[0]!==c||e[1]!==m?(y=s(()=>{J((async()=>{C(null);try{v(await c.listAuthAccounts({userId:m}))}catch(k){let $=k;v(null),C(Pe($))}})())},"b"),e[0]=c,e[1]=m,e[2]=y):y=e[2];let A;e[3]!==c||e[4]!==m||e[5]!==a?(A=[c,m,a],e[3]=c,e[4]=m,e[5]=a,e[6]=A):A=e[6],(0,x.useEffect)(y,A);let N;e[7]!==c||e[8]!==i||e[9]!==m?(N=s(k=>{i(()=>c.unlinkAuthAccount({accountId:k,userId:m}))},"y"),e[7]=c,e[8]=i,e[9]=m,e[10]=N):N=e[10];let I=N,r;e[11]!==n?(r=n("Linked accounts"),e[11]=n,e[12]=r):r=e[12];let u;e[13]!==r?(u=(0,t.jsx)(We,{children:r}),e[13]=r,e[14]=u):u=e[14];let p;e[15]!==f?(p=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:f}),e[15]=f,e[16]=p):p=e[16];let g;e[17]!==d||e[18]!==n?(g=d!==null&&d.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:n("No linked accounts.")}),e[17]=d,e[18]=n,e[19]=g):g=e[19];let o;e[20]!==d||e[21]!==l||e[22]!==I||e[23]!==n?(o=d!==null&&d.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:n("provider")}),(0,t.jsx)(S,{children:n("created")}),(0,t.jsx)(S,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Ue,{children:d.map(k=>{let $=Fe(k.id);return(0,t.jsxs)(T,{"data-testid":`ud-account-${$}`,children:[(0,t.jsx)(z,{children:Fe(k.providerId)}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q(k.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`ud-unlink-${$}`,disabled:l,onClick:s(()=>{I($)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Unlink")})})]},$)})})]})})}),e[20]=d,e[21]=l,e[22]=I,e[23]=n,e[24]=o):o=e[24];let F;return e[25]!==u||e[26]!==p||e[27]!==g||e[28]!==o?(F=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[u,p,g,o]}),e[25]=u,e[26]=p,e[27]=g,e[28]=o,e[29]=F):F=e[29],F},"ct"),mt=s(h=>{let e=(0,X.c)(40),{busy:l,capabilities:i,runAction:m,userId:a,version:c}=h,n=V(),d=q(),[v,f]=(0,x.useState)(null),C;e[0]!==i.passkey||e[1]!==n||e[2]!==a?(C=s(()=>{i.passkey&&J((async()=>{try{f(await n.listAuthPasskeys({userId:a}))}catch{f(null)}})())},"C"),e[0]=i.passkey,e[1]=n,e[2]=a,e[3]=C):C=e[3];let y;e[4]!==i.passkey||e[5]!==n||e[6]!==a||e[7]!==c?(y=[i.passkey,n,a,c],e[4]=i.passkey,e[5]=n,e[6]=a,e[7]=c,e[8]=y):y=e[8],(0,x.useEffect)(C,y);let A;e[9]!==n||e[10]!==m||e[11]!==a?(A=s(()=>{m(()=>n.disableAuthTwoFactor({userId:a}))},"A"),e[9]=n,e[10]=m,e[11]=a,e[12]=A):A=e[12];let N=A,I;e[13]!==n||e[14]!==m?(I=s($=>{m(()=>n.deleteAuthPasskey({passkeyId:$}))},"I"),e[13]=n,e[14]=m,e[15]=I):I=e[15];let r=I,u;e[16]!==d?(u=d("Security"),e[16]=d,e[17]=u):u=e[17];let p;e[18]!==u?(p=(0,t.jsx)(We,{children:u}),e[18]=u,e[19]=p):p=e[19];let g;e[20]!==l||e[21]!==i.twoFactor||e[22]!==N||e[23]!==d?(g=i.twoFactor&&(0,t.jsx)(U,{"data-testid":"ud-disable-2fa",disabled:l,onClick:N,size:"sm",type:"button",variant:"outline",children:d("Disable two-factor")}),e[20]=l,e[21]=i.twoFactor,e[22]=N,e[23]=d,e[24]=g):g=e[24];let o;e[25]!==i.passkey||e[26]!==v||e[27]!==d?(o=i.passkey&&v!==null&&v.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:d("No passkeys.")}),e[25]=i.passkey,e[26]=v,e[27]=d,e[28]=o):o=e[28];let F;e[29]!==l||e[30]!==i.passkey||e[31]!==r||e[32]!==v||e[33]!==d?(F=i.passkey&&v!==null&&v.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"ud-passkeys-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:d("name")}),(0,t.jsx)(S,{children:d("created")}),(0,t.jsx)(S,{"aria-label":d("Actions")})]})}),(0,t.jsx)(Ue,{children:v.map($=>{let L=Fe($.id);return(0,t.jsxs)(T,{"data-testid":`ud-passkey-${L}`,children:[(0,t.jsx)(z,{children:Fe($.name)||L}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q($.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`ud-delete-passkey-${L}`,disabled:l,onClick:s(()=>{r(L)},"onClick"),size:"xs",type:"button",variant:"ghost",children:d("Delete")})})]},L)})})]})})}),e[29]=l,e[30]=i.passkey,e[31]=r,e[32]=v,e[33]=d,e[34]=F):F=e[34];let k;return e[35]!==p||e[36]!==g||e[37]!==o||e[38]!==F?(k=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[p,g,o,F]}),e[35]=p,e[36]=g,e[37]=o,e[38]=F,e[39]=k):k=e[39],k},"ut"),pt=/(?:at|expires)$/iu,vt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),ft=s((h,e)=>typeof e=="number"&&pt.test(h)?Q(e):Fe(e),"pt"),bt=s(({capabilities:h,onChanged:e,onClose:l,user:i})=>{let m=V(),a=q(),c=i.banned===!0,[n,d]=(0,x.useState)(null),[v,f]=(0,x.useState)(!1),[C,y]=(0,x.useState)(0),[A,N]=(0,x.useState)(typeof i.role=="string"?i.role:""),[I,r]=(0,x.useState)(""),[u,p]=(0,x.useState)(""),[g,o]=(0,x.useState)(""),[F,k]=(0,x.useState)(null),[$,L]=(0,x.useState)(!1),_=s((w,B)=>{J((async()=>{f(!0),d(null);try{let O=await w();B?.refresh!==!1&&(y(M=>M+1),e()),B?.onResult?.(O)}catch(O){d(Pe(O))}f(!1)})())},"D"),Be=s(w=>{N(w.target.value)},"$e"),Z=s(w=>{r(w.target.value)},"Z"),De=s(w=>{p(w.target.value)},"Be"),G=s(w=>{o(w.target.value)},"W"),_e=s(()=>{let w=A.trim();w!==""&&_(async()=>{await m.setAuthUserRole({role:w,userId:i.id})})},"De"),Y=s(()=>{let w=Number.parseInt(u,10),B=Number.isFinite(w)&&w>0?w*86400:void 0;_(async()=>{await m.banAuthUser({expiresInSeconds:B,reason:I.trim()===""?void 0:I.trim(),userId:i.id})})},"J"),P=s(()=>{_(async()=>{await m.unbanAuthUser({userId:i.id})})},"P"),ee=s(()=>{_(async()=>{await m.setAuthUserPassword({newPassword:g,userId:i.id}),o("")})},"K"),$e=s(()=>{_(()=>m.impersonateAuthUser({userId:i.id}),{onResult:s(w=>{k(w.token)},"onResult"),refresh:!1})},"Fe"),te=s(()=>{_(async()=>{await m.revokeAuthUserSessions({userId:i.id})})},"X"),Te=s(()=>{_(async()=>{await m.removeAuthUser({userId:i.id}),l()})},"ze"),ae=s(()=>{L(!0)},"ee"),Re=s(()=>{L(!1)},"Se"),ie=Object.entries(i).filter(([w])=>!vt.has(w));return(0,t.jsxs)(He,{label:a("User details"),onClose:l,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:i.name??i.email??i.id}),(0,t.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:i.id}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof i.role=="string"&&i.role!==""&&(0,t.jsx)(D,{variant:"secondary",children:i.role}),c?(0,t.jsx)(D,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(D,{variant:"outline",children:a("Active")}),i.emailVerified===!0?(0,t.jsx)(D,{variant:"secondary",children:a("verified")}):(0,t.jsx)(D,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(U,{"data-testid":"ud-close",onClick:l,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),n!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:n}),h.admin&&(0,t.jsxs)(H,{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)(W,{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)(j,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(E,{"data-testid":"ud-role-input",id:"ud-role",onChange:Be,value:A})]}),(0,t.jsx)(U,{"data-testid":"ud-set-role",disabled:v||A.trim()==="",onClick:_e,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),c?(0,t.jsx)(U,{"data-testid":"ud-unban",disabled:v,onClick:P,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(j,{htmlFor:"ud-ban-reason",children:a("Ban reason (optional)")}),(0,t.jsx)(E,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:Z,value:I})]}),(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[(0,t.jsx)(j,{htmlFor:"ud-ban-days",children:a("Days")}),(0,t.jsx)(E,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:De,type:"number",value:u})]}),(0,t.jsx)(U,{"data-testid":"ud-ban",disabled:v,onClick:Y,size:"sm",type:"button",variant:"destructive",children:a("Ban user")})]}),(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(j,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(E,{"data-testid":"ud-password",id:"ud-password",onChange:G,type:"password",value:g})]}),(0,t.jsx)(U,{"data-testid":"ud-set-password",disabled:v||g==="",onClick:ee,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(U,{"data-testid":"ud-impersonate",disabled:v,onClick:$e,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(U,{"data-testid":"ud-revoke-all",disabled:v,onClick:te,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),$?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(U,{"data-testid":"ud-delete-confirm",disabled:v,onClick:Te,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(U,{"data-testid":"ud-delete-cancel",onClick:Re,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(U,{"data-testid":"ud-delete",disabled:v,onClick:ae,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),F!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(j,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(E,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:F})]})]})]}),(0,t.jsx)(ut,{busy:v,runAction:_,userId:i.id,version:C}),h.accounts&&(0,t.jsx)(ht,{busy:v,runAction:_,userId:i.id,version:C}),(h.twoFactor||h.passkey)&&(0,t.jsx)(mt,{busy:v,capabilities:h,runAction:_,userId:i.id,version:C}),(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:ie.map(([w,B])=>(0,t.jsxs)("div",{className:"flex flex-col border-t border-border py-1.5",children:[(0,t.jsx)("dt",{className:"text-xs font-semibold text-muted-foreground",children:w}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:ft(w,B)})]},w))})]})]})},"ft"),xt=50,Bt=s(({pageSize:h=xt}={})=>{let e=V(),l=q(),[i,m]=(0,x.useState)(""),[a,c]=(0,x.useState)(""),n=Ze(i),[d,v]=(0,x.useState)(null),[f,C]=(0,x.useState)(!1),{capabilities:y}=lt(),A=n.trim(),N=a.trim(),I=Ve(["lunora-auth-users",A,N,h],()=>e.listAuthUsers({filterField:N===""?void 0:"role",filterValue:N===""?void 0:N,limit:h,search:A===""?void 0:A}),{keepPreviousData:!0}),r=I.data?.rows??null,u=I.error,p=s(()=>{I.refetch()},"p");Ke(()=>{I.refetch()},!0);let g=d===null?null:r?.find(o=>o.id===d)??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)(E,{"aria-label":l("Search users"),className:"w-56","data-testid":"us-search",onChange:s(o=>{m(o.target.value)},"onChange"),placeholder:l("Search by email or name\u2026"),value:i}),(0,t.jsx)(E,{"aria-label":l("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:s(o=>{c(o.target.value)},"onChange"),placeholder:l("Filter by role"),value:a}),(0,t.jsx)(U,{"data-testid":"us-new",onClick:s(()=>{C(!0)},"onClick"),size:"sm",type:"button",children:l("New user")})]}),u!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:u}),r!==null&&r.length===0&&(0,t.jsx)(Me,{description:l("Users who sign up to your app will appear here."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:l("No users.")}),r!==null&&r.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"us-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:l("id")}),(0,t.jsx)(S,{children:l("email")}),(0,t.jsx)(S,{children:l("name")}),(0,t.jsx)(S,{children:l("role")}),(0,t.jsx)(S,{children:l("status")}),(0,t.jsx)(S,{children:l("verified")}),(0,t.jsx)(S,{children:l("created")}),(0,t.jsx)(S,{"aria-label":l("Actions")})]})}),(0,t.jsx)(Ue,{children:r.map(o=>(0,t.jsxs)(T,{"data-testid":`us-row-${o.id}`,children:[(0,t.jsx)(z,{className:"font-mono text-xs",children:o.id}),(0,t.jsx)(z,{children:o.email??""}),(0,t.jsx)(z,{children:o.name??""}),(0,t.jsx)(z,{children:typeof o.role=="string"&&o.role!==""?(0,t.jsx)(D,{variant:"secondary",children:o.role}):""}),(0,t.jsx)(z,{children:o.banned===!0?(0,t.jsx)(D,{variant:"destructive",children:l("Banned")}):(0,t.jsx)(D,{variant:"success",children:l("Active")})}),(0,t.jsx)(z,{children:o.emailVerified===!0?(0,t.jsx)(D,{variant:"success",children:l("yes")}):(0,t.jsx)(D,{variant:"outline",children:l("no")})}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q(o.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`us-manage-${o.id}`,onClick:s(()=>{v(o.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Manage")})})]},o.id))})]})})}),g!==null&&(0,t.jsx)(bt,{capabilities:y,onChanged:p,onClose:s(()=>{v(null)},"onClose"),user:g}),f&&(0,t.jsx)(ct,{onClose:s(()=>{C(!1)},"onClose"),onCreated:p}),y.inviteOnly&&(0,t.jsx)(nt,{})]})},"zt");export{Bt as UsersPanel};
|
|
1
|
+
import{a as Ge}from"./chunk-3FBLWUXD.js";import{a as Qe,b as qe}from"./chunk-RIJ5VJGY.js";import{a as Xe}from"./chunk-TIUMFAN2.js";import{a as He}from"./chunk-XZMOZFE6.js";import{a as j}from"./chunk-IMOHEGMV.js";import{a as Ke}from"./chunk-66UGPQVC.js";import{a as Ze}from"./chunk-QKEJLVC5.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import{W as E}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as U}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as D}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{b as Ve}from"./chunk-T53H5D2A.js";import{f as V}from"./chunk-B4YYP5AH.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as Me}from"./chunk-FKVZRPV5.js";import{a as Se,b as ze,c as Ue,d as T,e as S,f as z}from"./chunk-HEAQVSNS.js";import{a as H,e as W}from"./chunk-WUWBZPUK.js";import{d as q,h as Pe,n as Fe,o as J,r as Q}from"./chunk-FODLDLE2.js";import{a as s,d as Oe,e as tt,f as at,g as it}from"./chunk-YKXDMIHQ.js";var x=Oe(tt(),1);var X=Oe(at(),1);var t=Oe(it(),1);Qe.capabilities;var lt=s(()=>{let h=(0,X.c)(3),{config:e,ready:l}=qe(),i;return h[0]!==e.capabilities||h[1]!==l?(i={capabilities:e.capabilities,ready:l},h[0]=e.capabilities,h[1]=l,h[2]=i):i=h[2],i},"st"),st=s((h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending","nt"),Ye=500,nt=s(()=>{let h=V(),e=q(),[l,i]=(0,x.useState)(""),[m,a]=(0,x.useState)(null),[c,n]=(0,x.useState)(null),[d,v]=(0,x.useState)(!1),f=Ve(["lunora-auth-sign-up-invitations",Ye],()=>h.listAuthSignUpInvitations({limit:Ye})),C=f.data?.rows??null,y=f.data?.total??0,A=s(()=>{let r=l.trim();r!==""&&(a(null),J((async()=>{try{let u=await h.createAuthSignUpInvitation({email:r}),p=typeof u.token=="string"?u.token:void 0;n(p===void 0?null:`${globalThis.location.origin}/sign-up?email=${encodeURIComponent(r)}&invite=${encodeURIComponent(p)}`),v(!1),i(""),f.refetch()}catch(u){a(u instanceof Error?u.message:String(u))}})()))},"A"),N=s(()=>{let r="navigator"in globalThis?globalThis.navigator.clipboard:void 0;c===null||r===void 0||J(r.writeText(c).then(()=>(v(!0),!0)))},"y"),I=s(r=>{a(null),J((async()=>{try{await h.revokeAuthSignUpInvitation({email:r}),f.refetch()}catch(u){a(u instanceof Error?u.message:String(u))}})())},"I");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)(E,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:s(r=>{i(r.target.value)},"onChange"),placeholder:e("ada@example.com"),type:"email",value:l}),(0,t.jsx)(U,{"data-testid":"sign-up-invitation-submit",onClick:A,type:"button",children:e("Invite")})]}),c!==null&&(0,t.jsx)(H,{children:(0,t.jsxs)(W,{className:"flex flex-col gap-2 p-4",children:[(0,t.jsx)("p",{className:"text-sm",children:e("Send this link to the invitee. It is shown once and cannot be recovered.")}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(E,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:c}),(0,t.jsx)(U,{"data-testid":"sign-up-invitation-copy",onClick:N,type:"button",children:e(d?"Copied":"Copy")})]})]})}),(m??f.error)!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:m??f.error}),C!==null&&C.length===0&&(0,t.jsx)(Me,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),C!==null&&y>C.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.")}),C!==null&&C.length>0&&(0,t.jsx)(H,{children:(0,t.jsx)(W,{className:"p-0",children:(0,t.jsxs)(Se,{children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:e("Email")}),(0,t.jsx)(S,{children:e("Status")}),(0,t.jsx)(S,{children:e("Expires")}),(0,t.jsx)(S,{children:e("Invited by")}),(0,t.jsx)(S,{})]})}),(0,t.jsx)(Ue,{children:C.map(r=>{let u=st(r,Date.now()),p=r.email??"";return(0,t.jsxs)(T,{"data-testid":`sign-up-invitation-${p}`,children:[(0,t.jsx)(z,{children:p}),(0,t.jsxs)(z,{"data-testid":`sign-up-invitation-status-${p}`,children:[u==="spent"&&e("Accepted"),u==="expired"&&e("Expired"),u==="pending"&&e("Pending")]}),(0,t.jsx)(z,{children:typeof r.expiresAt=="number"?Q(r.expiresAt):"\u2014"}),(0,t.jsx)(z,{children:r.invitedBy??"\u2014"}),(0,t.jsx)(z,{className:"text-right",children:(0,t.jsx)(U,{onClick:s(()=>{I(p)},"onClick"),type:"button",variant:"ghost",children:e("Revoke")})})]},r.id)})})]})})})]})},"lt"),rt={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},dt=s((h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),"it"),ot=s((h,e)=>{if(h.type==="boolean")return e===!0?{value:!0}:h.required?{value:!1}:void 0;let l=typeof e=="string"?e.trim():"";if(l!==""){if(h.type==="number"){let i=Number(l);return Number.isNaN(i)?void 0:{value:i}}return{value:l}}},"rt"),ct=s(h=>{let e=(0,X.c)(105),{onClose:l,onCreated:i}=h,m=V(),a=q(),{config:c}=qe(),{busy:n,error:d,run:v}=Xe(),[f,C]=(0,x.useState)(""),[y,A]=(0,x.useState)(""),[N,I]=(0,x.useState)(""),[r,u]=(0,x.useState)(""),p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let[g,o]=(0,x.useState)(p),F;e[1]===Symbol.for("react.memo_cache_sentinel")?(F=s(b=>{C(b.target.value)},"F"),e[1]=F):F=e[1];let k=F,$;e[2]===Symbol.for("react.memo_cache_sentinel")?($=s(b=>{A(b.target.value)},"E"),e[2]=$):$=e[2];let L=$,_;e[3]===Symbol.for("react.memo_cache_sentinel")?(_=s(b=>{I(b.target.value)},"D"),e[3]=_):_=e[3];let Be=_,Z;e[4]===Symbol.for("react.memo_cache_sentinel")?(Z=s(b=>{u(b.target.value)},"Z"),e[4]=Z):Z=e[4];let De=Z,G;e[5]===Symbol.for("react.memo_cache_sentinel")?(G=s((b,R)=>{o(K=>({...K,[b]:R}))},"W"),e[5]=G):G=e[5];let _e=G,Y;e[6]!==g?(Y=s(b=>g[b.name]??(b.type==="boolean"?!1:""),"J"),e[6]=g,e[7]=Y):Y=e[7];let P=Y,ee;if(e[8]!==c.userFields||e[9]!==P){let b;e[11]!==P?(b=s(R=>!R.required||dt(R,P(R)),"g"),e[11]=P,e[12]=b):b=e[12],ee=c.userFields.every(b),e[8]=c.userFields,e[9]=P,e[10]=ee}else ee=e[10];let $e=ee,te;e[13]!==n||e[14]!==f||e[15]!==y||e[16]!==$e?(te=!n&&f.trim()!==""&&y.trim()!==""&&$e,e[13]=n,e[14]=f,e[15]=y,e[16]=$e,e[17]=te):te=e[17];let Te=te,ae;e[18]!==c.userFields||e[19]!==P?(ae=s(()=>{let b={};for(let R of c.userFields){let K=ot(R,P(R));K!==void 0&&(b[R.name]=K.value)}return Object.keys(b).length===0?void 0:b},"ee"),e[18]=c.userFields,e[19]=P,e[20]=ae):ae=e[20];let Re=ae,ie;e[21]!==Re||e[22]!==m||e[23]!==f||e[24]!==y||e[25]!==l||e[26]!==i||e[27]!==N||e[28]!==r||e[29]!==v?(ie=s(()=>{v(async()=>{await m.createAuthUser({data:Re(),email:f.trim(),name:y.trim(),password:N===""?void 0:N,role:r.trim()===""?void 0:r.trim()}),i(),l()})},"te"),e[21]=Re,e[22]=m,e[23]=f,e[24]=y,e[25]=l,e[26]=i,e[27]=N,e[28]=r,e[29]=v,e[30]=ie):ie=e[30];let w=ie,B;e[31]!==a?(B=a("Create user"),e[31]=a,e[32]=B):B=e[32];let O;e[33]!==a?(O=a("Create user"),e[33]=a,e[34]=O):O=e[34];let M;e[35]!==O?(M=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:O}),e[35]=O,e[36]=M):M=e[36];let le;e[37]!==a?(le=a("email"),e[37]=a,e[38]=le):le=e[38];let se;e[39]!==le?(se=(0,t.jsx)(j,{htmlFor:"uc-email",children:le}),e[39]=le,e[40]=se):se=e[40];let ne;e[41]!==f?(ne=(0,t.jsx)(E,{"data-testid":"uc-email",id:"uc-email",onChange:k,type:"email",value:f}),e[41]=f,e[42]=ne):ne=e[42];let re;e[43]!==se||e[44]!==ne?(re=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[se,ne]}),e[43]=se,e[44]=ne,e[45]=re):re=e[45];let de;e[46]!==a?(de=a("name"),e[46]=a,e[47]=de):de=e[47];let oe;e[48]!==de?(oe=(0,t.jsx)(j,{htmlFor:"uc-name",children:de}),e[48]=de,e[49]=oe):oe=e[49];let ce;e[50]!==y?(ce=(0,t.jsx)(E,{"data-testid":"uc-name",id:"uc-name",onChange:L,value:y}),e[50]=y,e[51]=ce):ce=e[51];let ue;e[52]!==oe||e[53]!==ce?(ue=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[oe,ce]}),e[52]=oe,e[53]=ce,e[54]=ue):ue=e[54];let he;e[55]!==a?(he=a("Password (optional)"),e[55]=a,e[56]=he):he=e[56];let me;e[57]!==he?(me=(0,t.jsx)(j,{htmlFor:"uc-password",children:he}),e[57]=he,e[58]=me):me=e[58];let pe;e[59]!==N?(pe=(0,t.jsx)(E,{"data-testid":"uc-password",id:"uc-password",onChange:Be,type:"password",value:N}),e[59]=N,e[60]=pe):pe=e[60];let ve;e[61]!==me||e[62]!==pe?(ve=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[me,pe]}),e[61]=me,e[62]=pe,e[63]=ve):ve=e[63];let fe;e[64]!==a?(fe=a("Role (optional)"),e[64]=a,e[65]=fe):fe=e[65];let be;e[66]!==fe?(be=(0,t.jsx)(j,{htmlFor:"uc-role",children:fe}),e[66]=fe,e[67]=be):be=e[67];let xe;e[68]!==r?(xe=(0,t.jsx)(E,{"data-testid":"uc-role",id:"uc-role",onChange:De,value:r}),e[68]=r,e[69]=xe):xe=e[69];let ye;e[70]!==be||e[71]!==xe?(ye=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[be,xe]}),e[70]=be,e[71]=xe,e[72]=ye):ye=e[72];let ge;e[73]!==c.userFields||e[74]!==P||e[75]!==a?(ge=c.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")}),c.userFields.map(b=>{let R=`uc-field-${b.name}`,K=b.required?"":` (${a("optional")})`;if(b.type==="boolean"){let Le=P(b)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:R,children:[(0,t.jsx)(Ge,{checked:Le,"data-testid":R,id:R,onCheckedChange:s(et=>{_e(b.name,et)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[b.name,K]})]},b.name)}let Je=P(b);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(j,{htmlFor:R,children:[b.name,K]}),(0,t.jsx)(E,{"data-testid":R,id:R,onChange:s(Le=>{_e(b.name,Le.target.value)},"onChange"),type:rt[b.type],value:typeof Je=="string"?Je:""})]},b.name)})]}),e[73]=c.userFields,e[74]=P,e[75]=a,e[76]=ge):ge=e[76];let Ne;e[77]!==d?(Ne=d!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:d}),e[77]=d,e[78]=Ne):Ne=e[78];let ke;e[79]!==a?(ke=a("Cancel"),e[79]=a,e[80]=ke):ke=e[80];let we;e[81]!==l||e[82]!==ke?(we=(0,t.jsx)(U,{"data-testid":"uc-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:ke}),e[81]=l,e[82]=ke,e[83]=we):we=e[83];let je=!Te,Ce;e[84]!==n||e[85]!==a?(Ce=a(n?"Creating\u2026":"Create"),e[84]=n,e[85]=a,e[86]=Ce):Ce=e[86];let Ae;e[87]!==w||e[88]!==je||e[89]!==Ce?(Ae=(0,t.jsx)(U,{"data-testid":"uc-submit",disabled:je,onClick:w,size:"sm",type:"button",children:Ce}),e[87]=w,e[88]=je,e[89]=Ce,e[90]=Ae):Ae=e[90];let Ie;e[91]!==we||e[92]!==Ae?(Ie=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[we,Ae]}),e[91]=we,e[92]=Ae,e[93]=Ie):Ie=e[93];let Ee;return e[94]!==l||e[95]!==B||e[96]!==M||e[97]!==re||e[98]!==ue||e[99]!==ve||e[100]!==ye||e[101]!==ge||e[102]!==Ne||e[103]!==Ie?(Ee=(0,t.jsxs)(He,{label:B,onClose:l,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[M,re,ue,ve,ye,ge,Ne,Ie]}),e[94]=l,e[95]=B,e[96]=M,e[97]=re,e[98]=ue,e[99]=ve,e[100]=ye,e[101]=ge,e[102]=Ne,e[103]=Ie,e[104]=Ee):Ee=e[104],Ee},"ot"),We=s(h=>{let e=(0,X.c)(2),{children:l}=h,i;return e[0]!==l?(i=(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l}),e[0]=l,e[1]=i):i=e[1],i},"je"),ut=s(h=>{let e=(0,X.c)(29),{busy:l,runAction:i,userId:m,version:a}=h,c=V(),n=q(),[d,v]=(0,x.useState)(null),[f,C]=(0,x.useState)(null),y;e[0]!==c||e[1]!==m?(y=s(()=>{J((async()=>{C(null);try{let k=await c.listAuthSessions({limit:50,userId:m});v(k.rows)}catch(k){let $=k;v(null),C(Pe($))}})())},"b"),e[0]=c,e[1]=m,e[2]=y):y=e[2];let A;e[3]!==c||e[4]!==m||e[5]!==a?(A=[c,m,a],e[3]=c,e[4]=m,e[5]=a,e[6]=A):A=e[6],(0,x.useEffect)(y,A);let N;e[7]!==c||e[8]!==i?(N=s(k=>{i(()=>c.revokeAuthSession({sessionId:k}))},"y"),e[7]=c,e[8]=i,e[9]=N):N=e[9];let I=N,r;e[10]!==n?(r=n("Sessions"),e[10]=n,e[11]=r):r=e[11];let u;e[12]!==r?(u=(0,t.jsx)(We,{children:r}),e[12]=r,e[13]=u):u=e[13];let p;e[14]!==f?(p=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:f}),e[14]=f,e[15]=p):p=e[15];let g;e[16]!==d||e[17]!==n?(g=d!==null&&d.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:n("No active sessions.")}),e[16]=d,e[17]=n,e[18]=g):g=e[18];let o;e[19]!==l||e[20]!==I||e[21]!==d||e[22]!==n?(o=d!==null&&d.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:n("expires")}),(0,t.jsx)(S,{children:n("ip")}),(0,t.jsx)(S,{children:n("user agent")}),(0,t.jsx)(S,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Ue,{children:d.map(k=>(0,t.jsxs)(T,{"data-testid":`ud-session-${k.id}`,children:[(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q(k.expiresAt)}),(0,t.jsx)(z,{children:k.ipAddress??""}),(0,t.jsx)(z,{className:"max-w-40 truncate",children:k.userAgent??""}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`ud-revoke-${k.id}`,disabled:l,onClick:s(()=>{I(k.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Revoke")})})]},k.id))})]})})}),e[19]=l,e[20]=I,e[21]=d,e[22]=n,e[23]=o):o=e[23];let F;return e[24]!==u||e[25]!==p||e[26]!==g||e[27]!==o?(F=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[u,p,g,o]}),e[24]=u,e[25]=p,e[26]=g,e[27]=o,e[28]=F):F=e[28],F},"dt"),ht=s(h=>{let e=(0,X.c)(30),{busy:l,runAction:i,userId:m,version:a}=h,c=V(),n=q(),[d,v]=(0,x.useState)(null),[f,C]=(0,x.useState)(null),y;e[0]!==c||e[1]!==m?(y=s(()=>{J((async()=>{C(null);try{v(await c.listAuthAccounts({userId:m}))}catch(k){let $=k;v(null),C(Pe($))}})())},"b"),e[0]=c,e[1]=m,e[2]=y):y=e[2];let A;e[3]!==c||e[4]!==m||e[5]!==a?(A=[c,m,a],e[3]=c,e[4]=m,e[5]=a,e[6]=A):A=e[6],(0,x.useEffect)(y,A);let N;e[7]!==c||e[8]!==i||e[9]!==m?(N=s(k=>{i(()=>c.unlinkAuthAccount({accountId:k,userId:m}))},"y"),e[7]=c,e[8]=i,e[9]=m,e[10]=N):N=e[10];let I=N,r;e[11]!==n?(r=n("Linked accounts"),e[11]=n,e[12]=r):r=e[12];let u;e[13]!==r?(u=(0,t.jsx)(We,{children:r}),e[13]=r,e[14]=u):u=e[14];let p;e[15]!==f?(p=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:f}),e[15]=f,e[16]=p):p=e[16];let g;e[17]!==d||e[18]!==n?(g=d!==null&&d.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:n("No linked accounts.")}),e[17]=d,e[18]=n,e[19]=g):g=e[19];let o;e[20]!==d||e[21]!==l||e[22]!==I||e[23]!==n?(o=d!==null&&d.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:n("provider")}),(0,t.jsx)(S,{children:n("created")}),(0,t.jsx)(S,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Ue,{children:d.map(k=>{let $=Fe(k.id);return(0,t.jsxs)(T,{"data-testid":`ud-account-${$}`,children:[(0,t.jsx)(z,{children:Fe(k.providerId)}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q(k.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`ud-unlink-${$}`,disabled:l,onClick:s(()=>{I($)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Unlink")})})]},$)})})]})})}),e[20]=d,e[21]=l,e[22]=I,e[23]=n,e[24]=o):o=e[24];let F;return e[25]!==u||e[26]!==p||e[27]!==g||e[28]!==o?(F=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[u,p,g,o]}),e[25]=u,e[26]=p,e[27]=g,e[28]=o,e[29]=F):F=e[29],F},"ct"),mt=s(h=>{let e=(0,X.c)(40),{busy:l,capabilities:i,runAction:m,userId:a,version:c}=h,n=V(),d=q(),[v,f]=(0,x.useState)(null),C;e[0]!==i.passkey||e[1]!==n||e[2]!==a?(C=s(()=>{i.passkey&&J((async()=>{try{f(await n.listAuthPasskeys({userId:a}))}catch{f(null)}})())},"C"),e[0]=i.passkey,e[1]=n,e[2]=a,e[3]=C):C=e[3];let y;e[4]!==i.passkey||e[5]!==n||e[6]!==a||e[7]!==c?(y=[i.passkey,n,a,c],e[4]=i.passkey,e[5]=n,e[6]=a,e[7]=c,e[8]=y):y=e[8],(0,x.useEffect)(C,y);let A;e[9]!==n||e[10]!==m||e[11]!==a?(A=s(()=>{m(()=>n.disableAuthTwoFactor({userId:a}))},"A"),e[9]=n,e[10]=m,e[11]=a,e[12]=A):A=e[12];let N=A,I;e[13]!==n||e[14]!==m?(I=s($=>{m(()=>n.deleteAuthPasskey({passkeyId:$}))},"I"),e[13]=n,e[14]=m,e[15]=I):I=e[15];let r=I,u;e[16]!==d?(u=d("Security"),e[16]=d,e[17]=u):u=e[17];let p;e[18]!==u?(p=(0,t.jsx)(We,{children:u}),e[18]=u,e[19]=p):p=e[19];let g;e[20]!==l||e[21]!==i.twoFactor||e[22]!==N||e[23]!==d?(g=i.twoFactor&&(0,t.jsx)(U,{"data-testid":"ud-disable-2fa",disabled:l,onClick:N,size:"sm",type:"button",variant:"outline",children:d("Disable two-factor")}),e[20]=l,e[21]=i.twoFactor,e[22]=N,e[23]=d,e[24]=g):g=e[24];let o;e[25]!==i.passkey||e[26]!==v||e[27]!==d?(o=i.passkey&&v!==null&&v.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:d("No passkeys.")}),e[25]=i.passkey,e[26]=v,e[27]=d,e[28]=o):o=e[28];let F;e[29]!==l||e[30]!==i.passkey||e[31]!==r||e[32]!==v||e[33]!==d?(F=i.passkey&&v!==null&&v.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"ud-passkeys-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:d("name")}),(0,t.jsx)(S,{children:d("created")}),(0,t.jsx)(S,{"aria-label":d("Actions")})]})}),(0,t.jsx)(Ue,{children:v.map($=>{let L=Fe($.id);return(0,t.jsxs)(T,{"data-testid":`ud-passkey-${L}`,children:[(0,t.jsx)(z,{children:Fe($.name)||L}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q($.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`ud-delete-passkey-${L}`,disabled:l,onClick:s(()=>{r(L)},"onClick"),size:"xs",type:"button",variant:"ghost",children:d("Delete")})})]},L)})})]})})}),e[29]=l,e[30]=i.passkey,e[31]=r,e[32]=v,e[33]=d,e[34]=F):F=e[34];let k;return e[35]!==p||e[36]!==g||e[37]!==o||e[38]!==F?(k=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[p,g,o,F]}),e[35]=p,e[36]=g,e[37]=o,e[38]=F,e[39]=k):k=e[39],k},"ut"),pt=/(?:at|expires)$/iu,vt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),ft=s((h,e)=>typeof e=="number"&&pt.test(h)?Q(e):Fe(e),"pt"),bt=s(({capabilities:h,onChanged:e,onClose:l,user:i})=>{let m=V(),a=q(),c=i.banned===!0,[n,d]=(0,x.useState)(null),[v,f]=(0,x.useState)(!1),[C,y]=(0,x.useState)(0),[A,N]=(0,x.useState)(typeof i.role=="string"?i.role:""),[I,r]=(0,x.useState)(""),[u,p]=(0,x.useState)(""),[g,o]=(0,x.useState)(""),[F,k]=(0,x.useState)(null),[$,L]=(0,x.useState)(!1),_=s((w,B)=>{J((async()=>{f(!0),d(null);try{let O=await w();B?.refresh!==!1&&(y(M=>M+1),e()),B?.onResult?.(O)}catch(O){d(Pe(O))}f(!1)})())},"D"),Be=s(w=>{N(w.target.value)},"$e"),Z=s(w=>{r(w.target.value)},"Z"),De=s(w=>{p(w.target.value)},"Be"),G=s(w=>{o(w.target.value)},"W"),_e=s(()=>{let w=A.trim();w!==""&&_(async()=>{await m.setAuthUserRole({role:w,userId:i.id})})},"De"),Y=s(()=>{let w=Number.parseInt(u,10),B=Number.isFinite(w)&&w>0?w*86400:void 0;_(async()=>{await m.banAuthUser({expiresInSeconds:B,reason:I.trim()===""?void 0:I.trim(),userId:i.id})})},"J"),P=s(()=>{_(async()=>{await m.unbanAuthUser({userId:i.id})})},"P"),ee=s(()=>{_(async()=>{await m.setAuthUserPassword({newPassword:g,userId:i.id}),o("")})},"K"),$e=s(()=>{_(()=>m.impersonateAuthUser({userId:i.id}),{onResult:s(w=>{k(w.token)},"onResult"),refresh:!1})},"Fe"),te=s(()=>{_(async()=>{await m.revokeAuthUserSessions({userId:i.id})})},"X"),Te=s(()=>{_(async()=>{await m.removeAuthUser({userId:i.id}),l()})},"ze"),ae=s(()=>{L(!0)},"ee"),Re=s(()=>{L(!1)},"Se"),ie=Object.entries(i).filter(([w])=>!vt.has(w));return(0,t.jsxs)(He,{label:a("User details"),onClose:l,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:i.name??i.email??i.id}),(0,t.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:i.id}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof i.role=="string"&&i.role!==""&&(0,t.jsx)(D,{variant:"secondary",children:i.role}),c?(0,t.jsx)(D,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(D,{variant:"outline",children:a("Active")}),i.emailVerified===!0?(0,t.jsx)(D,{variant:"secondary",children:a("verified")}):(0,t.jsx)(D,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(U,{"data-testid":"ud-close",onClick:l,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),n!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:n}),h.admin&&(0,t.jsxs)(H,{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)(W,{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)(j,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(E,{"data-testid":"ud-role-input",id:"ud-role",onChange:Be,value:A})]}),(0,t.jsx)(U,{"data-testid":"ud-set-role",disabled:v||A.trim()==="",onClick:_e,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),c?(0,t.jsx)(U,{"data-testid":"ud-unban",disabled:v,onClick:P,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(j,{htmlFor:"ud-ban-reason",children:a("Ban reason (optional)")}),(0,t.jsx)(E,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:Z,value:I})]}),(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[(0,t.jsx)(j,{htmlFor:"ud-ban-days",children:a("Days")}),(0,t.jsx)(E,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:De,type:"number",value:u})]}),(0,t.jsx)(U,{"data-testid":"ud-ban",disabled:v,onClick:Y,size:"sm",type:"button",variant:"destructive",children:a("Ban user")})]}),(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(j,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(E,{"data-testid":"ud-password",id:"ud-password",onChange:G,type:"password",value:g})]}),(0,t.jsx)(U,{"data-testid":"ud-set-password",disabled:v||g==="",onClick:ee,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(U,{"data-testid":"ud-impersonate",disabled:v,onClick:$e,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(U,{"data-testid":"ud-revoke-all",disabled:v,onClick:te,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),$?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(U,{"data-testid":"ud-delete-confirm",disabled:v,onClick:Te,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(U,{"data-testid":"ud-delete-cancel",onClick:Re,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(U,{"data-testid":"ud-delete",disabled:v,onClick:ae,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),F!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(j,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(E,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:F})]})]})]}),(0,t.jsx)(ut,{busy:v,runAction:_,userId:i.id,version:C}),h.accounts&&(0,t.jsx)(ht,{busy:v,runAction:_,userId:i.id,version:C}),(h.twoFactor||h.passkey)&&(0,t.jsx)(mt,{busy:v,capabilities:h,runAction:_,userId:i.id,version:C}),(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:ie.map(([w,B])=>(0,t.jsxs)("div",{className:"flex flex-col border-t border-border py-1.5",children:[(0,t.jsx)("dt",{className:"text-xs font-semibold text-muted-foreground",children:w}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:ft(w,B)})]},w))})]})]})},"ft"),xt=50,Bt=s(({pageSize:h=xt}={})=>{let e=V(),l=q(),[i,m]=(0,x.useState)(""),[a,c]=(0,x.useState)(""),n=Ze(i),[d,v]=(0,x.useState)(null),[f,C]=(0,x.useState)(!1),{capabilities:y}=lt(),A=n.trim(),N=a.trim(),I=Ve(["lunora-auth-users",A,N,h],()=>e.listAuthUsers({filterField:N===""?void 0:"role",filterValue:N===""?void 0:N,limit:h,search:A===""?void 0:A}),{keepPreviousData:!0}),r=I.data?.rows??null,u=I.error,p=s(()=>{I.refetch()},"p");Ke(()=>{I.refetch()},!0);let g=d===null?null:r?.find(o=>o.id===d)??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)(E,{"aria-label":l("Search users"),className:"w-56","data-testid":"us-search",onChange:s(o=>{m(o.target.value)},"onChange"),placeholder:l("Search by email or name\u2026"),value:i}),(0,t.jsx)(E,{"aria-label":l("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:s(o=>{c(o.target.value)},"onChange"),placeholder:l("Filter by role"),value:a}),(0,t.jsx)(U,{"data-testid":"us-new",onClick:s(()=>{C(!0)},"onClick"),size:"sm",type:"button",children:l("New user")})]}),u!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:u}),r!==null&&r.length===0&&(0,t.jsx)(Me,{description:l("Users who sign up to your app will appear here."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:l("No users.")}),r!==null&&r.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"us-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:l("id")}),(0,t.jsx)(S,{children:l("email")}),(0,t.jsx)(S,{children:l("name")}),(0,t.jsx)(S,{children:l("role")}),(0,t.jsx)(S,{children:l("status")}),(0,t.jsx)(S,{children:l("verified")}),(0,t.jsx)(S,{children:l("created")}),(0,t.jsx)(S,{"aria-label":l("Actions")})]})}),(0,t.jsx)(Ue,{children:r.map(o=>(0,t.jsxs)(T,{"data-testid":`us-row-${o.id}`,children:[(0,t.jsx)(z,{className:"font-mono text-xs",children:o.id}),(0,t.jsx)(z,{children:o.email??""}),(0,t.jsx)(z,{children:o.name??""}),(0,t.jsx)(z,{children:typeof o.role=="string"&&o.role!==""?(0,t.jsx)(D,{variant:"secondary",children:o.role}):""}),(0,t.jsx)(z,{children:o.banned===!0?(0,t.jsx)(D,{variant:"destructive",children:l("Banned")}):(0,t.jsx)(D,{variant:"success",children:l("Active")})}),(0,t.jsx)(z,{children:o.emailVerified===!0?(0,t.jsx)(D,{variant:"success",children:l("yes")}):(0,t.jsx)(D,{variant:"outline",children:l("no")})}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q(o.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`us-manage-${o.id}`,onClick:s(()=>{v(o.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Manage")})})]},o.id))})]})})}),g!==null&&(0,t.jsx)(bt,{capabilities:y,onChanged:p,onClose:s(()=>{v(null)},"onClose"),user:g}),f&&(0,t.jsx)(ct,{onClose:s(()=>{C(!1)},"onClose"),onCreated:p}),y.inviteOnly&&(0,t.jsx)(nt,{})]})},"zt");export{Bt as UsersPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as u}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as y}from"./chunk-
|
|
1
|
+
import{b as u}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as y}from"./chunk-VUXVPYAD.js";import"./chunk-ULIQFBZU.js";import"./chunk-PCHMHMHE.js";import"./chunk-35DM4JJG.js";import{a as N}from"./chunk-4ZEL6BYL.js";import{c as v}from"./chunk-T53H5D2A.js";import"./chunk-B4YYP5AH.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as g}from"./chunk-FKVZRPV5.js";import{a as w,b,c as S,d as c,e as s,f as o}from"./chunk-HEAQVSNS.js";import{a as f,e as x}from"./chunk-WUWBZPUK.js";import{d as p}from"./chunk-FODLDLE2.js";import{a as n,d as R,g as T}from"./chunk-YKXDMIHQ.js";var e=R(T(),1);var $={active:"default",failing:"destructive",idle:"secondary"},j=n(a=>a===void 0?"\u2014":`${new Date(a).toISOString().slice(0,19).replace("T"," ")} UTC`,"I"),U=n(a=>{let t=a.runs+a.suppressed;return t===0?void 0:Math.round(a.suppressed/t*100)},"$"),F=n(({initialShardKey:a=""})=>{let t=p(),{data:l,error:E,errorSource:A,liveError:I}=v(N.listReactors,{},{live:!0,shardKey:a}),C=l!==void 0,i=Array.isArray(l?.reactors)?l.reactors:[],d;C&&i.length===0?d=(0,e.jsx)(g,{description:t("No reactor is declared in this deployment. Export an onQueryChange(select, handler) from lunora/ to run server-side logic when a query's result changes."),testId:"reactors-empty",title:t("No reactors declared")}):d=(0,e.jsx)(f,{className:"overflow-hidden py-0",children:(0,e.jsx)(x,{className:"px-0",children:(0,e.jsxs)(w,{"data-testid":"reactors-table",children:[(0,e.jsx)(b,{children:(0,e.jsxs)(c,{children:[(0,e.jsx)(s,{children:t("Reactor")}),(0,e.jsx)(s,{children:t("State")}),(0,e.jsx)(s,{children:t("Ran")}),(0,e.jsx)(s,{children:t("Suppressed")}),(0,e.jsx)(s,{children:t("Errors")}),(0,e.jsx)(s,{children:t("Watches")}),(0,e.jsx)(s,{children:t("Last dispatch")})]})}),(0,e.jsx)(S,{children:i.map(r=>{let m=U(r);return(0,e.jsxs)(c,{"data-testid":`reactors-row-${r.path}`,children:[(0,e.jsx)(o,{className:"font-mono text-xs",children:r.path}),(0,e.jsx)(o,{children:(0,e.jsx)(u,{"data-testid":`reactors-state-${r.path}`,variant:$[r.state],children:r.state})}),(0,e.jsx)(o,{className:"font-mono text-xs",children:r.runs}),(0,e.jsxs)(o,{className:"font-mono text-xs text-muted-foreground",children:[r.suppressed,m===void 0?"":` (${String(m)}%)`]}),(0,e.jsx)(o,{className:"font-mono text-xs",children:r.errors===0?(0,e.jsx)("span",{className:"text-muted-foreground",children:"0"}):(0,e.jsx)("span",{className:"text-destructive",children:r.errors})}),(0,e.jsx)(o,{className:"font-mono text-xs text-muted-foreground",children:r.tables===void 0||r.tables.length===0?"\u2014":r.tables.join(", ")}),(0,e.jsx)(o,{className:"font-mono text-xs text-muted-foreground",children:j(r.lastRanAt)})]},r.path)})})]})})});let h=i.filter(r=>r.state==="failing");return(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-reactors-panel",children:[E!==null&&(0,e.jsx)(y,{error:A,testId:"reactors-error"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t("A reactor runs after a write flush, but only when the result of the query it watches actually changed \u2014 a trigger fires on a row write, a reactor fires on a result changing. Suppressed dispatches are the ones where the read re-ran and nothing had moved.")}),h.length>0&&(0,e.jsx)("div",{className:"flex flex-col gap-2","data-testid":"reactors-failing",children:h.map(r=>(0,e.jsxs)("p",{className:"text-xs text-destructive",role:"alert",children:[(0,e.jsx)("span",{className:"font-mono",children:r.path}),": ",r.lastError??t("last dispatch failed")]},r.path))}),I!==void 0&&(0,e.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"reactors-live-error",role:"alert",children:t("Live updates unavailable; showing the last reading.")}),d]})},"U");export{F as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as g}from"./chunk-
|
|
1
|
+
import{b as g}from"./chunk-EWBZPW2U.js";import"./chunk-VUXVPYAD.js";import"./chunk-ULIQFBZU.js";import"./chunk-PCHMHMHE.js";import"./chunk-35DM4JJG.js";import{a as f}from"./chunk-4ZEL6BYL.js";import{c as m}from"./chunk-T53H5D2A.js";import"./chunk-B4YYP5AH.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import"./chunk-HEAQVSNS.js";import"./chunk-WUWBZPUK.js";import{d as p}from"./chunk-FODLDLE2.js";import{a as r,d as h,f as S,g as A}from"./chunk-YKXDMIHQ.js";var R=h(S(),1);var k=h(A(),1);var _=r((e,s)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("User subscriptions are ungated")})[s.kind],"k"),w=r(e=>Array.isArray(e.findings)?e.findings:[],"g"),b=r(e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],"S"),E=r((e,s)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters \u2014 use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:s.detail?.length,min:s.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed \u2014 browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: anyone who can reach the worker can open a socket and run ordinary user subscriptions. Admin subscriptions are unaffected \u2014 they need the admin token. Set it if subscribers should present a shared credential.")})[s.kind],"A"),O=r(()=>{let e=(0,R.c)(8),s=p(),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];let{data:a,error:d,errorSource:c}=m(f.getSecurityAudit,i),n;if(e[1]!==a||e[2]!==s){let u=a===void 0?null:w(a);n=u===null?null:u.map(t=>({description:E(s,t),entity:b(t),issueType:_(s,t),key:t.kind,level:t.level})),e[1]=a,e[2]=s,e[3]=n}else n=e[3];let l=n,o;return e[4]!==d||e[5]!==c||e[6]!==l?(o=(0,k.jsx)(g,{error:d,errorSource:c,rows:l,testId:"lunora-security-advisor"}),e[4]=d,e[5]=c,e[6]=l,e[7]=o):o=e[7],o},"T");export{O as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Pe,b as Re}from"./chunk-LBMSRD6N.js";import{a as ce}from"./chunk-RPQL45FL.js";import{a as Te}from"./chunk-GGPSI4ZR.js";import"./chunk-4GTO7FL5.js";import{a as Se}from"./chunk-MXLAOCAN.js";import{b as ke}from"./chunk-CMA4PTV7.js";import{a as de}from"./chunk-UYEZR3BI.js";import{a as Le}from"./chunk-BOTGXX4H.js";import{a as ie}from"./chunk-QKEJLVC5.js";import{a as xe}from"./chunk-S3CRZLGS.js";import{a as be}from"./chunk-2DX5MROH.js";import{b as ve}from"./chunk-OGUKYRFM.js";import"./chunk-6D6Z2KXU.js";import"./chunk-OKG3HWSJ.js";import{W as D}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as pe}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as re}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as ye}from"./chunk-HKYYSETK.js";import"./chunk-ULIQFBZU.js";import"./chunk-GM5ADIIU.js";import"./chunk-35DM4JJG.js";import{a as ne}from"./chunk-4ZEL6BYL.js";import{c as oe}from"./chunk-4YRBL2BF.js";import{f as ge}from"./chunk-IL4CKMJM.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as J}from"./chunk-FKVZRPV5.js";import{a as we,b as Ne,c as Ce,d as se,e as B,f as W}from"./chunk-HEAQVSNS.js";import{d as z,h as ae,i as fe,o as le}from"./chunk-FODLDLE2.js";import{a as v,d as te,e as _e,f as Ae,g as Ue,i as j}from"./chunk-YKXDMIHQ.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"),Be=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)(W,{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)(W,{children:(0,r.jsx)(re,{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)(W,{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)(W,{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)(W,{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)(W,{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)(W,{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"),We=v(({shardKey:i})=>{let e=ge(),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,le((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(fe(C)===$e?{type:"notConfigured"}:{message:ae(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:ae(C),type:"pageFailed"})}},"T"),R=v(p=>{s(p.target.value)},"R"),k=v(p=>{c(p.target.value)},"N"),L=v(p=>{m(p.target.value)},"L"),S=v(()=>{le(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:k,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:L,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)(B,{children:t("Time")}),(0,r.jsx)(B,{children:t("Level")}),(0,r.jsx)(B,{children:t("Function")}),(0,r.jsx)(B,{children:t("Message")}),(0,r.jsx)(B,{children:t("Trace")}),(0,r.jsx)(B,{children:t("Shard")}),(0,r.jsx)(B,{children:t("User")})]})}),(0,r.jsx)(Ce,{children:u.map((p,C)=>(0,r.jsx)(Be,{row:p},`${String(p.ts)}-${String(C)}`))})]})}),d!==void 0&&(0,r.jsx)("div",{children:(0,r.jsx)(pe,{"data-testid":"lg-archive-more",disabled:h,onClick:S,size:"sm",variant:"outline",children:t(h?"Loading\u2026":"Load more")})})]})},"ze"),je=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=j("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)(je,{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 k;e[26]!==l?(k=l("Time range"),e[26]=l,e[27]=k):k=e[27];let L;e[28]!==l?(L=l("All time"),e[28]=l,e[29]=L):L=e[29];let S;e[30]!==L?(S=(0,r.jsx)("option",{value:"all",children:L}),e[30]=L,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]!==k||e[46]!==S||e[47]!==C||e[48]!==F||e[49]!==E||e[50]!==h?(M=(0,r.jsxs)("select",{"aria-label":k,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]=k,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?(_=j("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 k;e[31]!==R?(k=(0,r.jsx)("option",{value:"all",children:R}),e[31]=R,e[32]=k):k=e[32];let L;e[33]!==a?(L=a("ok"),e[33]=a,e[34]=L):L=e[34];let S;e[35]!==L?(S=(0,r.jsx)("option",{value:"ok",children:L}),e[35]=L,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]!==k||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:[k,S,C]}),e[41]=t,e[42]=c,e[43]=T,e[44]=k,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=j("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=j("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",k;e[18]!==R?(k=j("px-3 py-1 text-sm",R),e[18]=R,e[19]=k):k=e[19];let L;e[20]!==d?(L=d("Archive"),e[20]=d,e[21]=L):L=e[21];let S;e[22]!==s||e[23]!==T||e[24]!==k||e[25]!==L?(S=(0,r.jsx)("button",{"aria-selected":T,className:k,"data-testid":"lg-view-archive",onClick:s,role:"tab",type:"button",children:L}),e[22]=s,e[23]=T,e[24]=k,e[25]=L,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)(Le,{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)(re,{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 k;e[19]!==t.errorMessage||e[20]!==t.outcome||e[21]!==t.tablesRead||e[22]!==t.tablesWritten?(k=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]=k):k=e[23];let L;e[24]!==k?(L=(0,r.jsx)("span",{className:"flex-1 truncate text-muted-foreground",role:"gridcell",children:k}),e[24]=k,e[25]=L):L=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]!==L||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,L,S]}),e[29]=n,e[30]=s,e[31]=d,e[32]=N,e[33]=R,e[34]=L,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,k]=(0,I.useState)(""),[L,S]=(0,I.useState)("all"),p=at({functionPathPrefix:w,outcome:L,tableTouched:R,userId:y}),C=oe(ne.getRequestLog,p,{enabled:t==="requests",live:!0,shardKey:s}),q=oe(ne.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=ke({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=>{k(P.target.value)},"onTableChange"),onUserChange:v(P=>{T(P.target.value)},"onUserChange"),outcomeFilter:L,pathPrefix:w,tableFilter:R,userIdFilter:y}),t==="archive"?(0,r.jsx)(We,{shardKey:s}):(0,r.jsxs)(r.Fragment,{children:[Y==="error"&&(0,r.jsx)(ye,{error:E,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-LBMSRD6N.js";import{a as ce}from"./chunk-RPQL45FL.js";import{a as Te}from"./chunk-GGPSI4ZR.js";import"./chunk-4GTO7FL5.js";import{a as Se}from"./chunk-MXLAOCAN.js";import{b as ke}from"./chunk-CMA4PTV7.js";import{a as de}from"./chunk-UYEZR3BI.js";import{a as Le}from"./chunk-BOTGXX4H.js";import{a as ie}from"./chunk-QKEJLVC5.js";import{a as xe}from"./chunk-S3CRZLGS.js";import{a as be}from"./chunk-2DX5MROH.js";import{b as ve}from"./chunk-OGUKYRFM.js";import"./chunk-6D6Z2KXU.js";import"./chunk-OKG3HWSJ.js";import{W as D}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as pe}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as re}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as ye}from"./chunk-VUXVPYAD.js";import"./chunk-ULIQFBZU.js";import"./chunk-PCHMHMHE.js";import"./chunk-35DM4JJG.js";import{a as ne}from"./chunk-4ZEL6BYL.js";import{c as oe}from"./chunk-T53H5D2A.js";import{f as ge}from"./chunk-B4YYP5AH.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as J}from"./chunk-FKVZRPV5.js";import{a as we,b as Ne,c as Ce,d as se,e as B,f as W}from"./chunk-HEAQVSNS.js";import{d as z,h as ae,i as fe,o as le}from"./chunk-FODLDLE2.js";import{a as v,d as te,e as _e,f as Ae,g as Ue,i as j}from"./chunk-YKXDMIHQ.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"),Be=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)(W,{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)(W,{children:(0,r.jsx)(re,{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)(W,{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)(W,{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)(W,{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)(W,{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)(W,{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"),We=v(({shardKey:i})=>{let e=ge(),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,le((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(fe(C)===$e?{type:"notConfigured"}:{message:ae(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:ae(C),type:"pageFailed"})}},"T"),R=v(p=>{s(p.target.value)},"R"),k=v(p=>{c(p.target.value)},"N"),L=v(p=>{m(p.target.value)},"L"),S=v(()=>{le(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:k,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:L,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)(B,{children:t("Time")}),(0,r.jsx)(B,{children:t("Level")}),(0,r.jsx)(B,{children:t("Function")}),(0,r.jsx)(B,{children:t("Message")}),(0,r.jsx)(B,{children:t("Trace")}),(0,r.jsx)(B,{children:t("Shard")}),(0,r.jsx)(B,{children:t("User")})]})}),(0,r.jsx)(Ce,{children:u.map((p,C)=>(0,r.jsx)(Be,{row:p},`${String(p.ts)}-${String(C)}`))})]})}),d!==void 0&&(0,r.jsx)("div",{children:(0,r.jsx)(pe,{"data-testid":"lg-archive-more",disabled:h,onClick:S,size:"sm",variant:"outline",children:t(h?"Loading\u2026":"Load more")})})]})},"ze"),je=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=j("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)(je,{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 k;e[26]!==l?(k=l("Time range"),e[26]=l,e[27]=k):k=e[27];let L;e[28]!==l?(L=l("All time"),e[28]=l,e[29]=L):L=e[29];let S;e[30]!==L?(S=(0,r.jsx)("option",{value:"all",children:L}),e[30]=L,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]!==k||e[46]!==S||e[47]!==C||e[48]!==F||e[49]!==E||e[50]!==h?(M=(0,r.jsxs)("select",{"aria-label":k,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]=k,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?(_=j("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 k;e[31]!==R?(k=(0,r.jsx)("option",{value:"all",children:R}),e[31]=R,e[32]=k):k=e[32];let L;e[33]!==a?(L=a("ok"),e[33]=a,e[34]=L):L=e[34];let S;e[35]!==L?(S=(0,r.jsx)("option",{value:"ok",children:L}),e[35]=L,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]!==k||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:[k,S,C]}),e[41]=t,e[42]=c,e[43]=T,e[44]=k,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=j("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=j("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",k;e[18]!==R?(k=j("px-3 py-1 text-sm",R),e[18]=R,e[19]=k):k=e[19];let L;e[20]!==d?(L=d("Archive"),e[20]=d,e[21]=L):L=e[21];let S;e[22]!==s||e[23]!==T||e[24]!==k||e[25]!==L?(S=(0,r.jsx)("button",{"aria-selected":T,className:k,"data-testid":"lg-view-archive",onClick:s,role:"tab",type:"button",children:L}),e[22]=s,e[23]=T,e[24]=k,e[25]=L,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)(Le,{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)(re,{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 k;e[19]!==t.errorMessage||e[20]!==t.outcome||e[21]!==t.tablesRead||e[22]!==t.tablesWritten?(k=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]=k):k=e[23];let L;e[24]!==k?(L=(0,r.jsx)("span",{className:"flex-1 truncate text-muted-foreground",role:"gridcell",children:k}),e[24]=k,e[25]=L):L=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]!==L||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,L,S]}),e[29]=n,e[30]=s,e[31]=d,e[32]=N,e[33]=R,e[34]=L,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,k]=(0,I.useState)(""),[L,S]=(0,I.useState)("all"),p=at({functionPathPrefix:w,outcome:L,tableTouched:R,userId:y}),C=oe(ne.getRequestLog,p,{enabled:t==="requests",live:!0,shardKey:s}),q=oe(ne.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=ke({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=>{k(P.target.value)},"onTableChange"),onUserChange:v(P=>{T(P.target.value)},"onUserChange"),outcomeFilter:L,pathPrefix:w,tableFilter:R,userIdFilter:y}),t==="archive"?(0,r.jsx)(We,{shardKey:s}):(0,r.jsxs)(r.Fragment,{children:[Y==="error"&&(0,r.jsx)(ye,{error:E,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 +1 @@
|
|
|
1
|
-
import{b as h}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{b as A}from"./chunk-
|
|
1
|
+
import{b as h}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{b as A}from"./chunk-T53H5D2A.js";import{f as k}from"./chunk-B4YYP5AH.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as y,e as S}from"./chunk-WUWBZPUK.js";import{d as I}from"./chunk-FODLDLE2.js";import{a as u,d as w,f as z,g as P}from"./chunk-YKXDMIHQ.js";var N=w(z(),1);var a=w(P(),1);var j=[{key:"accounts",label:"Accounts"},{key:"admin",label:"Admin"},{key:"organization",label:"Organizations"},{key:"passkey",label:"Passkeys"},{key:"twoFactor",label:"Two-factor"}],v=u(e=>{if(e===void 0)return"\u2014";let i=[[86400,"d"],[3600,"h"],[60,"m"]];for(let[t,d]of i)if(e>=t&&e%t===0)return`${String(e/t)}${d}`;return`${String(e)}s`},"v"),p=u(e=>{let i=(0,N.c)(8),{children:t,heading:d,testId:n}=e,l;i[0]!==d?(l=(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:d})}),i[0]=d,i[1]=l):l=i[1];let s;i[2]!==t?(s=(0,a.jsx)(S,{className:"p-3",children:t}),i[2]=t,i[3]=s):s=i[3];let c;return i[4]!==l||i[5]!==s||i[6]!==n?(c=(0,a.jsxs)(y,{className:"gap-0 py-0","data-testid":n,children:[l,s]}),i[4]=l,i[5]=s,i[6]=n,i[7]=c):c=i[7],c},"h"),o=u(e=>{let i=(0,N.c)(7),{label:t,value:d}=e,n;i[0]!==t?(n=(0,a.jsx)("span",{className:"text-sm",children:t}),i[0]=t,i[1]=n):n=i[1];let l;i[2]!==d?(l=(0,a.jsx)("span",{className:"text-sm text-muted-foreground tabular-nums",children:d}),i[2]=d,i[3]=l):l=i[3];let s;return i[4]!==n||i[5]!==l?(s=(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs",children:[n,l]}),i[4]=n,i[5]=l,i[6]=s):s=i[6],s},"c"),M=u(()=>{let e=(0,N.c)(20),i=k(),t=I(),d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=["lunora-auth-config"],e[0]=d):d=e[0];let n;e[1]!==i?(n=u(()=>i.getAuthConfig(),"r"),e[1]=i,e[2]=n):n=e[2];let{data:l,error:s}=A(d,n),c;e[3]!==t?(c=u(r=>(0,a.jsx)(h,{variant:r?"success":"outline",children:t(r?"Enabled":"Disabled")}),"u"),e[3]=t,e[4]=c):c=e[4];let m=c,g;e[5]!==s?(g=s!==null&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"auth-config-error",role:"alert",children:s}),e[5]=s,e[6]=g):g=e[6];let f;e[7]!==l||e[8]!==s||e[9]!==t?(f=s===null&&l===void 0&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"auth-config-loading",children:t("Loading auth configuration\u2026")}),e[7]=l,e[8]=s,e[9]=t,e[10]=f):f=e[10];let x;e[11]!==l||e[12]!==s||e[13]!==m||e[14]!==t?(x=s===null&&l!==void 0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(p,{heading:t("Enabled capabilities"),testId:"auth-config-capabilities",children:(0,a.jsx)("ul",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:j.map(r=>{let $=l.capabilities[r.key];return(0,a.jsxs)("li",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs","data-testid":`auth-config-cap-${r.key}`,children:[(0,a.jsx)("span",{className:"text-sm",children:t(r.label)}),m($)]},r.key)})})}),(0,a.jsx)(p,{heading:t("Plugins"),testId:"auth-config-plugins",children:l.plugins.length===0?(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:t("No plugins enabled.")}):(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:l.plugins.map(C)})}),(0,a.jsx)(p,{heading:t("Sign-in methods"),testId:"auth-config-signin",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(o,{label:t("Email & password"),value:m(l.emailAndPassword)}),(0,a.jsx)(o,{label:t("Social providers"),value:l.socialProviders.length===0?t("None"):(0,a.jsx)("span",{className:"flex flex-wrap justify-end gap-1",children:l.socialProviders.map(L)})})]})}),l.organization.enabled&&(0,a.jsx)(p,{heading:t("Organizations"),testId:"auth-config-org",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(o,{label:t("Teams"),value:m(l.organization.teams)}),(0,a.jsx)(o,{label:t("Custom roles"),value:m(l.organization.roles)})]})}),(0,a.jsx)(p,{heading:t("Session policy"),testId:"auth-config-session",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(o,{label:t("Expires in"),value:v(l.session.expiresIn)}),(0,a.jsx)(o,{label:t("Refresh after"),value:v(l.session.updateAge)}),(0,a.jsx)(o,{label:t("Fresh window"),value:v(l.session.freshAge)}),(0,a.jsx)(o,{label:t("Cookie cache"),value:m(l.session.cookieCache===!0)})]})}),(0,a.jsx)(p,{heading:t("Rate limit"),testId:"auth-config-ratelimit",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(o,{label:t("Status"),value:m(l.rateLimit.enabled)}),l.rateLimit.enabled&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o,{label:t("Max requests"),value:l.rateLimit.max??"\u2014"}),(0,a.jsx)(o,{label:t("Window"),value:v(l.rateLimit.window)})]})]})}),l.userFields.length>0&&(0,a.jsx)(p,{heading:t("Plugin user fields"),testId:"auth-config-user-fields",children:(0,a.jsx)("ul",{className:"flex flex-col gap-2",children:l.userFields.map(r=>(0,a.jsxs)("li",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs","data-testid":`auth-config-user-field-${r.name}`,children:[(0,a.jsxs)("span",{className:"flex flex-col",children:[(0,a.jsx)("span",{className:"font-mono text-xs",children:r.name}),r.plugin!==void 0&&(0,a.jsx)("span",{className:"text-[11px] text-muted-foreground",children:r.plugin})]}),(0,a.jsxs)("span",{className:"flex items-center gap-1",children:[(0,a.jsx)(h,{variant:"outline",children:r.type}),r.required&&(0,a.jsx)(h,{variant:"secondary",children:t("required")}),r.unique&&(0,a.jsx)(h,{variant:"secondary",children:t("unique")})]})]},r.name))})}),(0,a.jsx)(y,{className:"gap-0 py-0",children:(0,a.jsx)("p",{className:"px-4 py-3 text-xs text-muted-foreground","data-testid":"auth-config-note",children:t("OAuth providers, email templates, and rate limits are configured at deploy time in the better-auth setup and aren't editable here. See the Mail tab for email output.")})})]}),e[11]=l,e[12]=s,e[13]=m,e[14]=t,e[15]=x):x=e[15];let b;return e[16]!==g||e[17]!==f||e[18]!==x?(b=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"auth-config",children:[g,f,x]}),e[16]=g,e[17]=f,e[18]=x,e[19]=b):b=e[19],b},"O");function C(e){return(0,a.jsx)(h,{"data-testid":`auth-config-plugin-${e}`,variant:"outline",children:e},e)}u(C,"P");function L(e){return(0,a.jsx)(h,{"data-testid":`auth-config-provider-${e}`,variant:"outline",children:e},e)}u(L,"z");export{M as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as O}from"./chunk-EA2JKR5D.js";import{a as C}from"./chunk-IMOHEGMV.js";import{b as v}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as k}from"./chunk-
|
|
1
|
+
import{a as O}from"./chunk-EA2JKR5D.js";import{a as C}from"./chunk-IMOHEGMV.js";import{b as v}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as k}from"./chunk-VUXVPYAD.js";import"./chunk-ULIQFBZU.js";import"./chunk-PCHMHMHE.js";import"./chunk-35DM4JJG.js";import{a as S}from"./chunk-4ZEL6BYL.js";import{c as b}from"./chunk-T53H5D2A.js";import"./chunk-B4YYP5AH.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as c}from"./chunk-FKVZRPV5.js";import{a as w,b as T,c as A,d as f,e as s,f as l}from"./chunk-HEAQVSNS.js";import{a as y,e as N}from"./chunk-WUWBZPUK.js";import{d as p}from"./chunk-FODLDLE2.js";import{a as n,d as x,e as R,g as V}from"./chunk-YKXDMIHQ.js";var F=x(R(),1);var e=x(V(),1);var $=n(a=>{let t=a.trim();if(t.length===0)return{context:void 0,error:null};try{let o=JSON.parse(t);return o===null||typeof o!="object"||Array.isArray(o)?{context:void 0,error:"Targeting context must be a JSON object."}:{context:o,error:null}}catch{return{context:void 0,error:"Targeting context is not valid JSON."}}},"H"),q='{ "targetingKey": "user-123", "plan": "premium" }',D=n(a=>a.type==="object"?JSON.stringify(a.value):String(a.value),"R"),Y=n(({initialShardKey:a=""})=>{let t=p(),[o,j]=(0,F.useState)(""),{context:g,error:m}=$(o),I=g===void 0?{}:{context:g},{data:i,error:J,errorSource:K,liveError:E}=b(S.listFlags,I,{live:!0,shardKey:a}),u=i!==void 0,L=i?.configured??!1,h=Array.isArray(i?.flags)?[...i.flags].toSorted((r,B)=>r.key.localeCompare(B.key)):[],d;return u&&!L?d=(0,e.jsx)(c,{description:t("No @lunora/flags provider is wired in this deployment. Add lunora/flags.ts with defineFlags({ provider }) to gate code paths on feature flags."),testId:"flags-unconfigured",title:t("No flags provider configured")}):u&&h.length===0?d=(0,e.jsx)(c,{description:t('A flags provider is configured, but no handler reads a flag yet. Call ctx.flags.boolean("key", false) in a query, mutation, or action.'),testId:"flags-empty",title:t("No flags read")}):d=(0,e.jsx)(y,{className:"overflow-hidden py-0",children:(0,e.jsx)(N,{className:"px-0",children:(0,e.jsxs)(w,{"data-testid":"flags-table",children:[(0,e.jsx)(T,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(s,{children:t("Key")}),(0,e.jsx)(s,{children:t("Type")}),(0,e.jsx)(s,{children:t("Value")}),(0,e.jsx)(s,{children:t("Reason")}),(0,e.jsx)(s,{children:t("Variant")})]})}),(0,e.jsx)(A,{children:h.map(r=>(0,e.jsxs)(f,{"data-testid":`flags-row-${r.key}`,children:[(0,e.jsx)(l,{className:"font-mono text-xs",children:r.key}),(0,e.jsx)(l,{className:"font-mono text-xs text-muted-foreground",children:r.type}),(0,e.jsx)(l,{className:"font-mono text-xs",children:D(r)}),(0,e.jsx)(l,{children:r.errorCode===void 0?(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:r.reason??"\u2014"}):(0,e.jsx)(v,{"data-testid":`flags-error-${r.key}`,variant:"destructive",children:r.errorCode})}),(0,e.jsx)(l,{className:"font-mono text-xs text-muted-foreground",children:r.variant??"\u2014"})]},r.key))})]})})}),(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-flags-panel",children:[J!==null&&(0,e.jsx)(k,{error:K,testId:"flags-error"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t('Feature flags are read in code with ctx.flags.<type>("key", default). They evaluate through the OpenFeature provider configured in lunora/flags.ts; edit the targeting context below to see how each flag resolves for a given audience.')}),(0,e.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,e.jsx)(C,{htmlFor:"flags-targeting-context",children:t("Targeting context (JSON)")}),(0,e.jsx)(O,{className:"font-mono text-xs","data-testid":"flags-context-input",id:"flags-targeting-context",onChange:n(r=>{j(r.target.value)},"onChange"),placeholder:q,rows:3,value:o}),m!==null&&(0,e.jsx)("p",{className:"text-xs text-destructive","data-testid":"flags-context-error",role:"alert",children:t(m)}),E!==void 0&&(0,e.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"flags-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")})]}),d]})},"W");export{Y as default};
|