@lunora/studio 1.0.0-alpha.326 → 1.0.0-alpha.327
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/packem_chunks/migrations-route.mjs +1 -1
- package/dist/standalone/{chunk-G26RQPDL.js → chunk-3G52JQDE.js} +1 -1
- package/dist/standalone/{chunk-PKHFMUAX.js → chunk-4OPMHED5.js} +1 -1
- package/dist/standalone/{chunk-PWH4FCFR.js → chunk-4WVVQII7.js} +1 -1
- package/dist/standalone/{chunk-N5VW6ADU.js → chunk-6LAOOCDD.js} +1 -1
- package/dist/standalone/{chunk-K67NQCL7.js → chunk-7ULZKZQQ.js} +1 -1
- package/dist/standalone/{chunk-O3YOPOFI.js → chunk-7XM3Z7IQ.js} +1 -1
- package/dist/standalone/{chunk-2PZ4MP3G.js → chunk-ABBJRINK.js} +1 -1
- package/dist/standalone/{chunk-UQAMQR4Q.js → chunk-ARXLF43Z.js} +1 -1
- package/dist/standalone/{chunk-LCYDNUTU.js → chunk-B6ATVGZY.js} +1 -1
- package/dist/standalone/{chunk-4LAD57XQ.js → chunk-BBJAUO6Q.js} +1 -1
- package/dist/standalone/{chunk-MRWBB3N3.js → chunk-BKAIQ3EW.js} +1 -1
- package/dist/standalone/{chunk-5CNRDILP.js → chunk-BZSLOCHA.js} +1 -1
- package/dist/standalone/{chunk-PYNRIX74.js → chunk-C4ZPJ4KT.js} +1 -1
- package/dist/standalone/{chunk-JM4M6D6X.js → chunk-CJXS7ZFK.js} +1 -1
- package/dist/standalone/{chunk-BDYCZHD2.js → chunk-DTFIEXYN.js} +1 -1
- package/dist/standalone/{chunk-OVVRMPVR.js → chunk-EKKX6QM5.js} +1 -1
- package/dist/standalone/{chunk-WGU2LV5D.js → chunk-EYX7T7D6.js} +1 -1
- package/dist/standalone/{chunk-7TF3N4ZD.js → chunk-F2632QSD.js} +1 -1
- package/dist/standalone/{chunk-P2NSASR2.js → chunk-FZHX4SU4.js} +1 -1
- package/dist/standalone/{chunk-GH24P7D2.js → chunk-G7HELO37.js} +1 -1
- package/dist/standalone/{chunk-CUEZLEQO.js → chunk-GAW73INZ.js} +1 -1
- package/dist/standalone/{chunk-MZB4M3O4.js → chunk-GIE6BF2N.js} +1 -1
- package/dist/standalone/{chunk-RU4O6ZXP.js → chunk-GWN7ZBB6.js} +1 -1
- package/dist/standalone/{chunk-E7Q7NE77.js → chunk-GXJA7VNB.js} +1 -1
- package/dist/standalone/{chunk-SEODHPIF.js → chunk-HAAMTGU2.js} +1 -1
- package/dist/standalone/{chunk-7QP56XBQ.js → chunk-HCM7G3LJ.js} +1 -1
- package/dist/standalone/{chunk-HXLPQMQY.js → chunk-HM6K7CGB.js} +1 -1
- package/dist/standalone/{chunk-MNXBTILQ.js → chunk-HPXALQPF.js} +1 -1
- package/dist/standalone/{chunk-6LU7UD32.js → chunk-J7UN5TFS.js} +1 -1
- package/dist/standalone/chunk-JLACL25R.js +1 -0
- package/dist/standalone/{chunk-XD6XP3QZ.js → chunk-JW5LYFFK.js} +1 -1
- package/dist/standalone/{chunk-XBZGJ7I6.js → chunk-KQZL4DGC.js} +1 -1
- package/dist/standalone/{chunk-NFCRD6DB.js → chunk-L7D3XUSL.js} +1 -1
- package/dist/standalone/{chunk-W3QVYZMI.js → chunk-LCA6DK6F.js} +1 -1
- package/dist/standalone/{chunk-O4AU6G7Z.js → chunk-LS37O7PT.js} +1 -1
- package/dist/standalone/{chunk-KC67FFZF.js → chunk-NP3PMKD7.js} +1 -1
- package/dist/standalone/{chunk-OKX7I64M.js → chunk-NRJY6XLS.js} +1 -1
- package/dist/standalone/{chunk-LWE4JQGT.js → chunk-OBIZNIQG.js} +1 -1
- package/dist/standalone/{chunk-JOQMVPGT.js → chunk-OCCAELSS.js} +1 -1
- package/dist/standalone/{chunk-7AEDQPBM.js → chunk-OIX2HXFZ.js} +1 -1
- package/dist/standalone/{chunk-KGWOEE3Y.js → chunk-OP5AKUEV.js} +1 -1
- package/dist/standalone/{chunk-6Z2A2P2U.js → chunk-P32XL2PD.js} +1 -1
- package/dist/standalone/{chunk-AKHBJSQO.js → chunk-PUOC4Q55.js} +1 -1
- package/dist/standalone/{chunk-OJVA6YJI.js → chunk-PWNGXOCF.js} +1 -1
- package/dist/standalone/{chunk-HC4J57UZ.js → chunk-SWRJFAMY.js} +1 -1
- package/dist/standalone/{chunk-DGHWBHUF.js → chunk-TYDCG5RQ.js} +1 -1
- package/dist/standalone/{chunk-7FY6RTSD.js → chunk-UBZRQ3Z6.js} +1 -1
- package/dist/standalone/{chunk-DSYUT6DA.js → chunk-UYLNH4SJ.js} +1 -1
- package/dist/standalone/{chunk-3I6JC6NL.js → chunk-VA2K2MGN.js} +1 -1
- package/dist/standalone/{chunk-OTQSYE6X.js → chunk-VKQCSJMV.js} +1 -1
- package/dist/standalone/{chunk-B74YABQU.js → chunk-W5CE7LGU.js} +1 -1
- package/dist/standalone/{chunk-OGNEIWHN.js → chunk-WCTMLOQC.js} +1 -1
- package/dist/standalone/{chunk-CQ3UUCD2.js → chunk-WQSX6BFJ.js} +1 -1
- package/dist/standalone/{chunk-7JYYC4A5.js → chunk-X7UBUDG2.js} +1 -1
- package/dist/standalone/{chunk-52YTJ556.js → chunk-XBPVXRYQ.js} +1 -1
- package/dist/standalone/{chunk-VST2VNEU.js → chunk-XDSDUCPP.js} +1 -1
- package/dist/standalone/{chunk-6TILEHRA.js → chunk-XUBHW2IG.js} +1 -1
- package/dist/standalone/{chunk-HTGHQYIG.js → chunk-YUNCGMB2.js} +1 -1
- package/dist/standalone/{chunk-33YIKGW6.js → chunk-ZCC25Q2H.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +5 -5
- package/dist/standalone/chunk-IBXENKTW.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as H}from"./chunk-OMN44W6V.js";import"./chunk-VASJTDMU.js";import{a as F}from"./chunk-JQXA2OYK.js";import{a as I}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import"./chunk-BOMPSVRC.js";import{b as $}from"./chunk-
|
|
1
|
+
import{a as H}from"./chunk-OMN44W6V.js";import"./chunk-VASJTDMU.js";import{a as F}from"./chunk-JQXA2OYK.js";import{a as I}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import"./chunk-BOMPSVRC.js";import{b as $}from"./chunk-C4ZPJ4KT.js";import{l as S}from"./chunk-DTFIEXYN.js";import"./chunk-QAQDMS6R.js";import"./chunk-WS7WNXF3.js";import{a as B}from"./chunk-RWVIV3U7.js";import{a as L,b as O,c as E,d as k,e as n,f as l}from"./chunk-HCTJKP5J.js";import{a as j,e as z}from"./chunk-2IKDEUCX.js";import{d as C,p as R,t as T}from"./chunk-5OMZCVRF.js";import{a as f,d as y,e as D,f as G,g as J}from"./chunk-I26MS5PJ.js";var P=y(G(),1);var Q=y(D(),1);var s=y(J(),1);var w=200,se=f(()=>{let e=(0,P.c)(28),d=S(),a=C(),[i,q]=(0,Q.useState)(0),p;e[0]!==i?(p=["lunora-auth-sessions",w,i],e[0]=i,e[1]=p):p=e[1];let x;e[2]!==d||e[3]!==i?(x=f(()=>d.listAuthSessions({limit:w,offset:i}),"p"),e[2]=d,e[3]=i,e[4]=x):x=e[4];let r=$(p,x),{error:g}=r,t=r.data?.rows??null,N;e[5]!==r?(N=f(()=>{r.refetch()},"b"),e[5]=r,e[6]=N):N=e[6],F(N,!0);let v;e[7]!==d||e[8]!==r?(v=f(o=>{R((async()=>{await d.revokeAuthSession({sessionId:o}),r.refetch()})())},"g"),e[7]=d,e[8]=r,e[9]=v):v=e[9];let b=v,c;e[10]!==g?(c=g!==null&&(0,s.jsx)("p",{className:"text-sm text-destructive","data-testid":"auth-sessions-error",role:"alert",children:g}),e[10]=g,e[11]=c):c=e[11];let m;e[12]!==t||e[13]!==a?(m=t!==null&&t.length===0&&(0,s.jsx)(B,{testId:"auth-sessions-empty",title:a("No active sessions.")}),e[12]=t,e[13]=a,e[14]=m):m=e[14];let h;e[15]!==b||e[16]!==t||e[17]!==a?(h=t!==null&&t.length>0&&(0,s.jsx)(j,{className:"overflow-hidden py-0",children:(0,s.jsx)(z,{className:"px-0",children:(0,s.jsxs)(L,{"data-testid":"auth-sessions-table",children:[(0,s.jsx)(O,{children:(0,s.jsxs)(k,{children:[(0,s.jsx)(n,{children:a("user")}),(0,s.jsx)(n,{children:a("expires")}),(0,s.jsx)(n,{children:a("ip")}),(0,s.jsx)(n,{children:a("user agent")}),(0,s.jsx)(n,{children:a("impersonated by")}),(0,s.jsx)(n,{"aria-label":a("Actions")})]})}),(0,s.jsx)(E,{children:t.map(o=>(0,s.jsxs)(k,{"data-testid":`auth-session-${o.id}`,children:[(0,s.jsx)(l,{className:"font-mono text-xs",children:o.userId}),(0,s.jsx)(l,{className:"text-muted-foreground tabular-nums",children:T(o.expiresAt)}),(0,s.jsx)(l,{children:o.ipAddress??""}),(0,s.jsx)(l,{className:"max-w-40 truncate",children:o.userAgent??""}),(0,s.jsx)(l,{className:"font-mono text-xs",children:o.impersonatedBy??""}),(0,s.jsx)(l,{children:(0,s.jsx)(I,{"data-testid":`auth-session-revoke-${o.id}`,onClick:f(()=>{b(o.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Revoke")})})]},o.id))})]})})}),e[15]=b,e[16]=t,e[17]=a,e[18]=h):h=e[18];let u;e[19]!==i||e[20]!==t||e[21]!==r.data?.total?(u=t!==null&&(0,s.jsx)(H,{count:t.length,offset:i,onOffsetChange:q,pageSize:w,prefix:"auth-sessions",total:r.data?.total}),e[19]=i,e[20]=t,e[21]=r.data?.total,e[22]=u):u=e[22];let A;return e[23]!==c||e[24]!==m||e[25]!==h||e[26]!==u?(A=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"auth-sessions",children:[c,m,h,u]}),e[23]=c,e[24]=m,e[25]=h,e[26]=u,e[27]=A):A=e[27],A},"ee");export{se as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as v}from"./chunk-253UHWDX.js";import{a as Q}from"./chunk-JQXA2OYK.js";import{a as L}from"./chunk-R6U22RSY.js";import{a as G}from"./chunk-2EYOYWS2.js";import"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import"./chunk-AUAECCXB.js";import{b as $}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as W}from"./chunk-
|
|
1
|
+
import{a as v}from"./chunk-253UHWDX.js";import{a as Q}from"./chunk-JQXA2OYK.js";import{a as L}from"./chunk-R6U22RSY.js";import{a as G}from"./chunk-2EYOYWS2.js";import"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import"./chunk-AUAECCXB.js";import{b as $}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as W}from"./chunk-ARXLF43Z.js";import"./chunk-NCPW7WHO.js";import"./chunk-VA2K2MGN.js";import"./chunk-55UGUCQ6.js";import{a as E}from"./chunk-4ZEL6BYL.js";import{c as B}from"./chunk-C4ZPJ4KT.js";import"./chunk-DTFIEXYN.js";import"./chunk-QAQDMS6R.js";import"./chunk-WS7WNXF3.js";import{a as A}from"./chunk-RWVIV3U7.js";import{a as q,b as H,c as O,d as K,e as T,f as D}from"./chunk-HCTJKP5J.js";import{a as _}from"./chunk-2IKDEUCX.js";import{d as j}from"./chunk-5OMZCVRF.js";import{a as S,d as F,f as J,g as V}from"./chunk-I26MS5PJ.js";var R=F(J(),1);var t=F(V(),1);var U=S(c=>`${c.toString()} ms`,"D"),X=S(c=>c.totalConnections===0&&c.shapePoke.passes===0&&c.whisper.passes===0&&c.shapeProbe.run===0&&c.shapeProbe.served===0&&c.globalPoll.drains===0&&c.globalPoll.pairsSkipped===0,"J"),z=S(c=>{let e=(0,R.c)(48),{counters:o,includeTiming:a,prefix:r,t:l,title:u}=c,d=`${r}-section`,n;e[0]!==u?(n=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:u}),e[0]=u,e[1]=n):n=e[1];let s=`${r}-stats`,i;e[2]!==l?(i=l("Passes"),e[2]=l,e[3]=i):i=e[3];let m=`${r}-passes`,I;e[4]!==o.passes||e[5]!==i||e[6]!==m?(I=(0,t.jsx)(v,{label:i,testId:m,value:o.passes}),e[4]=o.passes,e[5]=i,e[6]=m,e[7]=I):I=e[7];let g;e[8]!==l?(g=l("Sockets iterated"),e[8]=l,e[9]=g):g=e[9];let k=`${r}-iterated`,p;e[10]!==o.socketsIterated||e[11]!==g||e[12]!==k?(p=(0,t.jsx)(v,{label:g,testId:k,value:o.socketsIterated}),e[10]=o.socketsIterated,e[11]=g,e[12]=k,e[13]=p):p=e[13];let f;e[14]!==l?(f=l("Delivered"),e[14]=l,e[15]=f):f=e[15];let y=`${r}-delivered`,h;e[16]!==o.socketsDelivered||e[17]!==f||e[18]!==y?(h=(0,t.jsx)(v,{label:f,testId:y,value:o.socketsDelivered}),e[16]=o.socketsDelivered,e[17]=f,e[18]=y,e[19]=h):h=e[19];let x;e[20]!==l?(x=l("Peak width"),e[20]=l,e[21]=x):x=e[21];let N=`${r}-peak`,b;e[22]!==o.peakSocketsIterated||e[23]!==x||e[24]!==N?(b=(0,t.jsx)(v,{label:x,testId:N,value:o.peakSocketsIterated}),e[22]=o.peakSocketsIterated,e[23]=x,e[24]=N,e[25]=b):b=e[25];let C;e[26]!==o.totalMs||e[27]!==a||e[28]!==r||e[29]!==l?(C=a&&(0,t.jsx)(v,{label:l("Total time"),testId:`${r}-total-ms`,value:U(o.totalMs)}),e[26]=o.totalMs,e[27]=a,e[28]=r,e[29]=l,e[30]=C):C=e[30];let P;e[31]!==o.maxMs||e[32]!==a||e[33]!==r||e[34]!==l?(P=a&&(0,t.jsx)(v,{label:l("Max time"),testId:`${r}-max-ms`,value:U(o.maxMs)}),e[31]=o.maxMs,e[32]=a,e[33]=r,e[34]=l,e[35]=P):P=e[35];let M;e[36]!==h||e[37]!==b||e[38]!==C||e[39]!==P||e[40]!==s||e[41]!==I||e[42]!==p?(M=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":s,children:[I,p,h,b,C,P]}),e[36]=h,e[37]=b,e[38]=C,e[39]=P,e[40]=s,e[41]=I,e[42]=p,e[43]=M):M=e[43];let w;return e[44]!==d||e[45]!==M||e[46]!==n?(w=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":d,children:[n,M]}),e[44]=d,e[45]=M,e[46]=n,e[47]=w):w=e[47],w},"F"),Y=S(c=>{let e=(0,R.c)(20),{counters:o,t:a}=c,r;e[0]!==a?(r=a("Membership probes"),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==r?(l=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:r}),e[2]=r,e[3]=l):l=e[3];let u;e[4]!==a?(u=a("Queries run"),e[4]=a,e[5]=u):u=e[5];let d;e[6]!==o.run||e[7]!==u?(d=(0,t.jsx)(v,{label:u,testId:"fanout-probe-run",value:o.run}),e[6]=o.run,e[7]=u,e[8]=d):d=e[8];let n;e[9]!==a?(n=a("Shared from cache"),e[9]=a,e[10]=n):n=e[10];let s;e[11]!==o.served||e[12]!==n?(s=(0,t.jsx)(v,{label:n,testId:"fanout-probe-served",value:o.served}),e[11]=o.served,e[12]=n,e[13]=s):s=e[13];let i;e[14]!==d||e[15]!==s?(i=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"fanout-probe-stats",children:[d,s]}),e[14]=d,e[15]=s,e[16]=i):i=e[16];let m;return e[17]!==l||e[18]!==i?(m=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-probe-section",children:[l,i]}),e[17]=l,e[18]=i,e[19]=m):m=e[19],m},"V"),Z=S(c=>{let e=(0,R.c)(20),{counters:o,t:a}=c,r;e[0]!==a?(r=a("Global shape polls"),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==r?(l=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:r}),e[2]=r,e[3]=l):l=e[3];let u;e[4]!==a?(u=a("Global reads"),e[4]=a,e[5]=u):u=e[5];let d;e[6]!==o.drains||e[7]!==u?(d=(0,t.jsx)(v,{label:u,testId:"fanout-global-poll-drains",value:o.drains}),e[6]=o.drains,e[7]=u,e[8]=d):d=e[8];let n;e[9]!==a?(n=a("Pairs skipped"),e[9]=a,e[10]=n):n=e[10];let s;e[11]!==o.pairsSkipped||e[12]!==n?(s=(0,t.jsx)(v,{label:n,testId:"fanout-global-poll-pairs-skipped",value:o.pairsSkipped}),e[11]=o.pairsSkipped,e[12]=n,e[13]=s):s=e[13];let i;e[14]!==d||e[15]!==s?(i=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"fanout-global-poll-stats",children:[d,s]}),e[14]=d,e[15]=s,e[16]=i):i=e[16];let m;return e[17]!==l||e[18]!==i?(m=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-global-poll-section",children:[l,i]}),e[17]=l,e[18]=i,e[19]=m):m=e[19],m},"X"),pe=S(c=>{let e=(0,R.c)(31),{initialShardKey:o}=c,a=j(),{queryShardKey:r,setShardKey:l,shardKey:u}=L(o),d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={},e[0]=d):d=e[0];let n;e[1]!==r?(n={keepPreviousData:!0,shardKey:r},e[1]=r,e[2]=n):n=e[2];let{data:s,error:i,errorSource:m,refetch:I}=B(E.getFanoutMetrics,d,n);Q(I,!0);let g;e[3]!==s?(g=s!==void 0&&X(s),e[3]=s,e[4]=g):g=e[4];let k=g,p;e[5]!==l||e[6]!==u?(p=(0,t.jsx)(G,{onChange:l,testId:"fanout-shard-input",value:u}),e[5]=l,e[6]=u,e[7]=p):p=e[7];let f;e[8]!==s||e[9]!==a?(f=s!==void 0&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"fanout-count",children:[s.promoted&&(0,t.jsx)($,{"data-testid":"fanout-promoted",variant:s.relayCount>=s.maxRelays?"destructive":"default",children:s.relayCount>=s.maxRelays?a("auto-scaled: {relayCount}/{maxRelays} relays (at ceiling)",{maxRelays:s.maxRelays,relayCount:s.relayCount}):a("auto-scaled: {relayCount}/{maxRelays} relays",{maxRelays:s.maxRelays,relayCount:s.relayCount})}),(0,t.jsx)($,{variant:"secondary",children:a("{count} connections",{count:s.totalConnections})}),(0,t.jsx)($,{variant:"secondary",children:a("peak {count} subscribers",{count:s.peakSubscribers})})]}),e[8]=s,e[9]=a,e[10]=f):f=e[10];let y;e[11]!==p||e[12]!==f?(y=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[p,f]}),e[11]=p,e[12]=f,e[13]=y):y=e[13];let h;e[14]!==i||e[15]!==m?(h=i!==null&&(0,t.jsx)(W,{error:m,testId:"fanout-error"}),e[14]=i,e[15]=m,e[16]=h):h=e[16];let x;e[17]!==i||e[18]!==k||e[19]!==a?(x=i===null&&k&&(0,t.jsx)(A,{description:a("Realtime fan-out cost and per-topic subscriber counts for this shard."),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:"M4 12h4l3 7 4-14 3 7h2"})}),testId:"fanout-empty",title:a("No fan-out activity yet.")}),e[17]=i,e[18]=k,e[19]=a,e[20]=x):x=e[20];let N;e[21]!==i||e[22]!==k||e[23]!==s||e[24]!==a?(N=i===null&&s!==void 0&&!k&&(0,t.jsxs)(t.Fragment,{children:[s.topics.length>0&&(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-topics-section",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:a("Hot topics")}),(0,t.jsx)(_,{className:"overflow-hidden py-0",children:(0,t.jsxs)(q,{"data-testid":"fanout-topics-table",children:[(0,t.jsx)(H,{children:(0,t.jsxs)(K,{children:[(0,t.jsx)(T,{children:a("Topic")}),(0,t.jsx)(T,{children:a("Kind")}),(0,t.jsx)(T,{className:"text-right",children:a("Subscribers")})]})}),(0,t.jsx)(O,{children:s.topics.map(ee)})]})})]}),(0,t.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"fanout-cost",children:[(0,t.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:a("Fan-out cost since this instance woke")}),(0,t.jsx)(z,{counters:s.shapePoke,includeTiming:!0,prefix:"fanout-poke",t:a,title:a("Shape pokes")}),(0,t.jsx)(z,{counters:s.whisper,includeTiming:!1,prefix:"fanout-whisper",t:a,title:a("Whisper broadcasts")}),(0,t.jsx)(Y,{counters:s.shapeProbe,t:a}),(0,t.jsx)(Z,{counters:s.globalPoll,t:a})]})]}),e[21]=i,e[22]=k,e[23]=s,e[24]=a,e[25]=N):N=e[25];let b;return e[26]!==y||e[27]!==h||e[28]!==x||e[29]!==N?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"fanout-panel",children:[y,h,x,N]}),e[26]=y,e[27]=h,e[28]=x,e[29]=N,e[30]=b):b=e[30],b},"me");function ee(c){return(0,t.jsxs)(K,{"data-testid":"fanout-topic-row",children:[(0,t.jsx)(D,{className:"font-mono text-xs",children:c.topic}),(0,t.jsx)(D,{children:(0,t.jsx)($,{variant:"outline",children:c.kind})}),(0,t.jsx)(D,{className:"text-right font-medium tabular-nums",children:c.subscribers})]},`${c.kind}:${c.topic}`)}S(ee,"Y");export{pe as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as dt}from"./chunk-AQFI2GWT.js";import"./chunk-Q6IT6ZD7.js";import"./chunk-FBGCQYRO.js";import"./chunk-NQZALRU3.js";import"./chunk-OPM7ESDV.js";import"./chunk-Y3AYVFTK.js";import{a as De}from"./chunk-37WYCOQ2.js";import{a as st}from"./chunk-D746I7ZX.js";import"./chunk-OYCUPD3Q.js";import"./chunk-NXQW5E6W.js";import"./chunk-UC7MNI2F.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import"./chunk-AUGKHAMQ.js";import{a as at}from"./chunk-R6U22RSY.js";import{a as ot}from"./chunk-I23ULEUU.js";import{a as tt}from"./chunk-2EYOYWS2.js";import{b as et}from"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import{h as We,i as Ue}from"./chunk-OQ6I6OXT.js";import{i as He}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{a as Qe}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as ze}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as qe}from"./chunk-ARXLF43Z.js";import"./chunk-NCPW7WHO.js";import"./chunk-VA2K2MGN.js";import"./chunk-55UGUCQ6.js";import{a as F}from"./chunk-4ZEL6BYL.js";import{c as ce}from"./chunk-C4ZPJ4KT.js";import{l as Be}from"./chunk-DTFIEXYN.js";import"./chunk-QAQDMS6R.js";import"./chunk-WS7WNXF3.js";import{a as Se}from"./chunk-RWVIV3U7.js";import{a as rt,b as it,c as nt,d as _e,e as q,f as T}from"./chunk-HCTJKP5J.js";import{a as Ve,e as Ge}from"./chunk-2IKDEUCX.js";import{d as le,f as Xe,g as Ye,h as Ze,p as Oe,t as je}from"./chunk-5OMZCVRF.js";import{a as s,d as se,e as Je,f as Ae,g as Pe,i as de}from"./chunk-I26MS5PJ.js";var ge=se(Ae(),1),he=se(Je(),1);var lt=se(Ae(),1);var S=se(Je(),1);var m=se(Pe(),1);var qt=Xe(F.runMigration),ct=s(t=>{let e=(0,lt.c)(98),{initialShardKey:r}=t,i=Be(),a=le(),{queryShardKey:o,setShardKey:n,shardKey:d}=at(r),[l,f]=(0,S.useState)(""),[h,g]=(0,S.useState)("up"),[p,b]=(0,S.useState)(!0),[y,x]=(0,S.useState)(!1),[v,u]=(0,S.useState)(null),[w,k]=(0,S.useState)(null),L;e[0]!==d?(L=d.trim(),e[0]=d,e[1]=L):L=e[1];let C=L===o,j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j={},e[2]=j):j=e[2];let M;e[3]!==o?(M={live:!0,shardKey:o},e[3]=o,e[4]=M):M=e[4];let $=ce(F.migrationStatus,j,M),N=$.data?.migrations??null,Ie=$.error,{errorSource:Fe,liveError:Re}=$,be,ye;e[5]!==o||e[6]!==$.data?(be=s(()=>{$.data!==void 0&&et(o)},"W"),ye=[$.data,o],e[5]=o,e[6]=$.data,e[7]=be,e[8]=ye):(be=e[7],ye=e[8]),(0,S.useEffect)(be,ye);let ve;if(e[9]!==i||e[10]!==h||e[11]!==p||e[12]!==l||e[13]!==d||e[14]!==$||e[15]!==a){let I=s(async()=>{let Ee=l.trim();if(Ee===""){k(a("Enter a migration id")),u(null);return}x(!0),k(null);try{let Le=await i.query(qt,{direction:h,dryRun:p,id:Ee},Ye(d));u(Le),$.refetch()}catch(Le){let jt=Le;u(null),k(Ze(jt))}x(!1)},"m");ve=s(()=>{Oe(I())},"V"),e[9]=i,e[10]=h,e[11]=p,e[12]=l,e[13]=d,e[14]=$,e[15]=a,e[16]=ve}else ve=e[16];let xe=ve,ke;e[17]===Symbol.for("react.memo_cache_sentinel")?(ke=s(I=>{f(I.target.value)},"Y"),e[17]=ke):ke=e[17];let Nt=ke,we;e[18]===Symbol.for("react.memo_cache_sentinel")?(we=s(I=>{g(I.target.value==="down"?"down":"up")},"Z"),e[18]=we):we=e[18];let St=we,$e;e[19]===Symbol.for("react.memo_cache_sentinel")?($e=s(I=>{b(I.target.checked)},"ee"),e[19]=$e):$e=e[19];let Ot=$e,_;e[20]!==n||e[21]!==d?(_=(0,m.jsx)(tt,{onChange:n,testId:"mg-shard-input",value:d}),e[20]=n,e[21]=d,e[22]=_):_=e[22];let D;e[23]!==Re?(D=(0,m.jsx)(st,{message:Re,prefix:"mg"}),e[23]=Re,e[24]=D):D=e[24];let K;e[25]!==_||e[26]!==D?(K=(0,m.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[_,D]}),e[25]=_,e[26]=D,e[27]=K):K=e[27];let E;e[28]!==Ie||e[29]!==Fe?(E=Ie!==null&&(0,m.jsx)(qe,{error:Fe,testId:"mg-status-error"}),e[28]=Ie,e[29]=Fe,e[30]=E):E=e[30];let J;e[31]!==N||e[32]!==a?(J=N!==null&&N.length===0&&(0,m.jsx)(Se,{description:a("Data migrations you run against this shard will be tracked here."),icon:(0,m.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,m.jsx)("path",{d:"M4 12a8 8 0 0 1 13.7-5.6L20 8M20 4v4h-4M20 12a8 8 0 0 1-13.7 5.6L4 16m0 4v-4h4"})}),testId:"mg-empty",title:a("No migrations have run on this shard.")}),e[31]=N,e[32]=a,e[33]=J):J=e[33];let A;e[34]!==N||e[35]!==a?(A=N!==null&&N.length>0&&(0,m.jsx)(Ve,{className:"overflow-hidden py-0",children:(0,m.jsx)(Ge,{className:"px-0",children:(0,m.jsxs)(rt,{"data-testid":"mg-table",children:[(0,m.jsx)(it,{children:(0,m.jsxs)(_e,{children:[(0,m.jsx)(q,{children:a("id")}),(0,m.jsx)(q,{children:a("direction")}),(0,m.jsx)(q,{children:a("status")}),(0,m.jsx)(q,{children:a("processed")}),(0,m.jsx)(q,{children:a("changed")}),(0,m.jsx)(q,{children:a("updated")}),(0,m.jsx)(q,{children:a("error")})]})}),(0,m.jsx)(nt,{children:N.map(Tt)})]})})}),e[34]=N,e[35]=a,e[36]=A):A=e[36];let P;e[37]!==a?(P=a("Run migration"),e[37]=a,e[38]=P):P=e[38];let B;e[39]!==P?(B=(0,m.jsx)(De,{children:P}),e[39]=P,e[40]=B):B=e[40];let W;e[41]!==a?(W=a("Migration id"),e[41]=a,e[42]=W):W=e[42];let U;e[43]!==a?(U=a("migration id"),e[43]=a,e[44]=U):U=e[44];let z;e[45]!==l||e[46]!==W||e[47]!==U?(z=(0,m.jsx)(He,{"aria-label":W,className:"w-auto","data-testid":"mg-id-input",onChange:Nt,placeholder:U,value:l}),e[45]=l,e[46]=W,e[47]=U,e[48]=z):z=e[48];let H;e[49]!==a?(H=a("Direction"),e[49]=a,e[50]=H):H=e[50];let Q;e[51]!==a?(Q=a("up"),e[51]=a,e[52]=Q):Q=e[52];let V;e[53]!==Q?(V=(0,m.jsx)("option",{value:"up",children:Q}),e[53]=Q,e[54]=V):V=e[54];let G;e[55]!==a?(G=a("down"),e[55]=a,e[56]=G):G=e[56];let X;e[57]!==G?(X=(0,m.jsx)("option",{value:"down",children:G}),e[57]=G,e[58]=X):X=e[58];let Y;e[59]!==h||e[60]!==H||e[61]!==V||e[62]!==X?(Y=(0,m.jsxs)("select",{"aria-label":H,className:"flex h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs transition-colors outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 dark:bg-input/30","data-testid":"mg-direction",onChange:St,value:h,children:[V,X]}),e[59]=h,e[60]=H,e[61]=V,e[62]=X,e[63]=Y):Y=e[63];let Z;e[64]!==p?(Z=(0,m.jsx)("input",{checked:p,className:"size-4 accent-primary","data-testid":"mg-dry-run",id:"mg-dry-run",onChange:Ot,type:"checkbox"}),e[64]=p,e[65]=Z):Z=e[65];let ee;e[66]!==a?(ee=a("Dry run"),e[66]=a,e[67]=ee):ee=e[67];let te;e[68]!==Z||e[69]!==ee?(te=(0,m.jsxs)(De,{className:"flex items-center gap-1.5",htmlFor:"mg-dry-run",children:[Z,ee]}),e[68]=Z,e[69]=ee,e[70]=te):te=e[70];let ae;e[71]!==p||e[72]!==xe||e[73]!==y||e[74]!==C||e[75]!==a?(ae=p?(0,m.jsx)(Qe,{"data-testid":"mg-run",disabled:y||!C,onClick:xe,type:"button",children:a(y?"Running\u2026":"Run")}):(0,m.jsx)(ot,{confirmLabel:a(y?"Running\u2026":"Run migration?"),disabled:y||!C,onConfirm:xe,testId:"mg-run",children:a("Run")}),e[71]=p,e[72]=xe,e[73]=y,e[74]=C,e[75]=a,e[76]=ae):ae=e[76];let re;e[77]!==z||e[78]!==Y||e[79]!==te||e[80]!==ae?(re=(0,m.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[z,Y,te,ae]}),e[77]=z,e[78]=Y,e[79]=te,e[80]=ae,e[81]=re):re=e[81];let ie;e[82]!==B||e[83]!==re?(ie=(0,m.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs",children:[B,re]}),e[82]=B,e[83]=re,e[84]=ie):ie=e[84];let ne;e[85]!==w?(ne=w!==null&&(0,m.jsx)("pre",{className:"text-sm text-destructive whitespace-pre-wrap","data-testid":"mg-run-error",role:"alert",children:w}),e[85]=w,e[86]=ne):ne=e[86];let oe;e[87]!==v||e[88]!==a?(oe=v!==null&&(0,m.jsxs)("p",{className:"text-sm text-muted-foreground","data-testid":"mg-run-result",children:[v.dryRun?a("Dry run: "):"",a("{status} \u2014 processed",{status:v.status}),v.processed,a(", changed"),v.changed]}),e[87]=v,e[88]=a,e[89]=oe):oe=e[89];let Ne;return e[90]!==K||e[91]!==E||e[92]!==J||e[93]!==A||e[94]!==ie||e[95]!==ne||e[96]!==oe?(Ne=(0,m.jsxs)("div",{className:"flex flex-col gap-3 pt-4","data-testid":"lunora-migrations",children:[K,E,J,A,ie,ne,oe]}),e[90]=K,e[91]=E,e[92]=J,e[93]=A,e[94]=ie,e[95]=ne,e[96]=oe,e[97]=Ne):Ne=e[97],Ne},"yt");function Tt(t){return(0,m.jsxs)(_e,{"data-testid":`mg-row-${t.id}`,children:[(0,m.jsx)(T,{children:t.id}),(0,m.jsx)(T,{children:t.direction}),(0,m.jsx)(T,{children:(0,m.jsx)(ze,{variant:"secondary",children:t.status})}),(0,m.jsx)(T,{children:t.processed}),(0,m.jsx)(T,{children:t.changed}),(0,m.jsx)(T,{children:je(t.updatedAt)}),(0,m.jsx)(T,{children:t.error??""})]},t.id)}s(Tt,"Je");var c=se(Pe(),1);var Ke=1;function Ct(t){let e={},r=Object.keys(t);r.sort();for(let i of r)e[i]=t[i];return e}s(Ct,"me");var me=s(t=>typeof t=="object"&&t!==null,"O"),Mt=s(t=>me(t)&&me(t.fields)&&me(t.indexes)&&me(t.relations)&&typeof t.shardMode=="string","ue"),It=s(t=>{if(t===void 0||t.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(t)}catch(r){return{error:`baseline is not valid JSON: ${r instanceof Error?r.message:String(r)}`,status:"invalid"}}if(!me(e)||e.version!==Ke||!me(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(Ke)})`,status:"invalid"};for(let[r,i]of Object.entries(e.tables))if(!Mt(i))return{error:`baseline table "${r}" has an invalid structure`,status:"invalid"};return{snapshot:{jurisdiction:typeof e.jurisdiction=="string"?e.jurisdiction:void 0,migrationIds:Array.isArray(e.migrationIds)?e.migrationIds:[],tables:e.tables,version:Ke},status:"ok"}},"fe"),Ft=s((t,e)=>t.unique===e.unique&&t.fields.length===e.fields.length&&t.fields.every((r,i)=>r===e.fields[i]),"he"),mt=s(t=>t.unique!==void 0,"V"),pe=s(({nullable:t,optional:e,refined:r,unique:i,...a})=>JSON.stringify(Ct(a)),"M"),ut=s(t=>({form:JSON.stringify([pe(t),t.optional===!0,t.nullable===!0]),refined:t.refined===!0}),"G"),ht=s(t=>t.kind==="union"&&t.members?t.members.map(e=>ut(e)):[ut({...t,nullable:!1,optional:!1})],"Q"),Rt=s((t,e)=>{if(e.kind!=="union")return!1;let r=ht(e);return ht(t).every(i=>r.some(a=>a.form===i.form&&(i.refined||!a.refined)))},"pe"),O=s(t=>{switch(t.kind){case"array":return`array(${t.of?O(t.of):"?"})`;case"from":return t.output===void 0?"from":`from(${t.output})`;case"id":return`id(${t.ref??"?"})`;case"literal":return`literal(${t.literal??"?"})`;case"object":return`object({ ${Object.keys(t.fields??{}).join(", ")} })`;case"record":return`record(${t.key?O(t.key):"?"}, ${t.of?O(t.of):"?"})`;case"union":return(t.members??[]).map(e=>O(e)).join(" | ");default:return t.kind}},"x"),fe=s((t,e,r)=>({remediation:"backfill",scope:"table",severity:"breaking",summary:r,table:t,type:e}),"j"),Ce=s((t,e,r)=>({remediation:"none",scope:"table",severity:"safe",summary:r,table:t,type:e}),"C"),kt=s((t,e)=>{let r=JSON.stringify(t),i=JSON.stringify(e);return r===i?0:r<i?-1:1},"X"),ue=s(t=>({...t,...t.kind==="from"?{output:void 0}:{},...t.fields?{fields:Object.fromEntries(Object.entries(t.fields).map(([e,r])=>[e,ue(r)]))}:{},...t.key?{key:ue(t.key)}:{},...t.of?{of:ue(t.of)}:{},...t.members?{members:t.members.map(e=>ue(e)).toSorted(kt)}:{}}),"S"),ft=s(t=>t.kind==="union"?t.members??[]:[t],"U"),Lt=s((t,e)=>{let r=[...t],i=[...e],a=new Set,o=new Set,n=s((d,l)=>{for(let[f,h]of r.entries()){if(o.has(f))continue;let g=i.findIndex((p,b)=>!a.has(b)&&d(h,p));g!==-1&&(a.add(g),o.add(f),l&&([r[f],i[g]]=Me(h,i[g])))}},"s");return n((d,l)=>JSON.stringify(d)===JSON.stringify(l),!1),n((d,l)=>pe(ue(d))===pe(ue(l)),!0),[r,i]},"ge"),Me=s((t,e)=>{if(t.kind==="union"||e.kind==="union"){let[a,o]=Lt(ft(t),ft(e)),n=s((d,l)=>d.kind==="union"?{...d,members:l.toSorted(kt)}:l[0],"s");return[n(t,a),n(e,o)]}if(t.kind!==e.kind)return[t,e];if(t.kind==="from")return t.output===void 0||e.output===void 0?[{...t,output:void 0},{...e,output:void 0}]:[t,e];let r={...t.fields?{fields:{...t.fields}}:{}},i={...e.fields?{fields:{...e.fields}}:{}};for(let a of["key","of"])t[a]&&e[a]&&([r[a],i[a]]=Me(t[a],e[a]));for(let a of Object.keys(t.fields??{})){let o=t.fields?.[a],n=e.fields?.[a];o&&n&&r.fields&&i.fields&&([r.fields[a],i.fields[a]]=Me(o,n))}return[{...t,...r},{...e,...i}]},"I"),_t=s((t,e,r,i,a)=>{let[o,n]=Me(r,i);if(!(o.kind===n.kind&&(!a||pe(o)===pe(n))))return a&&Rt(o,n)?Ce(t,"widenedFieldShape",`field ${t}.${e} widened: ${O(o)} \u2192 ${O(n)} \u2014 every stored value stays valid`):o.kind!==n.kind?fe(t,"changedFieldKind",`field ${t}.${e} changed type: ${o.kind} \u2192 ${n.kind} \u2014 add a data migration to convert existing values`):fe(t,"changedFieldShape",`field ${t}.${e} changed shape: ${O(o)} \u2192 ${O(n)} \u2014 stored values were written against the old shape; add a data migration to convert them`)},"be"),Dt=s((t,e,r,i)=>{let a=[];return r.unique!==i.unique&&a.push(i.unique===!0?fe(t,"addedFieldConstraint",`field ${t}.${e} became unique \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`):Ce(t,"relaxedFieldConstraint",`field ${t}.${e} is no longer unique`)),r.nullable!==i.nullable&&a.push(i.nullable===!0?Ce(t,"relaxedFieldConstraint",`field ${t}.${e} became nullable`):fe(t,"addedFieldConstraint",`field ${t}.${e} is no longer nullable \u2014 rows holding NULL would be invalid; add a data migration to backfill them`)),r.refined!==i.refined&&a.push(i.refined===!0?fe(t,"addedFieldConstraint",`field ${t}.${e} gained a validation refinement \u2014 stored values were never checked against it; add a data migration if any could fail`):Ce(t,"relaxedFieldConstraint",`field ${t}.${e} dropped its validation refinement`)),a},"ye"),wt=s((t,e,r,i)=>{let a=[],o=mt(r)&&mt(i),n=_t(t,e,r,i,o);return n&&a.push(n),o&&a.push(...Dt(t,e,r,i)),r.optional&&!i.optional?a.push({remediation:"backfill",severity:"breaking",summary:`field ${t}.${e} became required \u2014 rows missing it would be invalid; add a data migration to backfill it`,table:t,scope:"table",type:"fieldOptionalToRequired"}):!r.optional&&i.optional&&a.push({remediation:"none",scope:"table",severity:"safe",summary:`field ${t}.${e} became optional`,table:t,type:"fieldRequiredToOptional"}),a},"Z"),Kt=s((t,e,r)=>r.optional?{remediation:"none",scope:"table",severity:"safe",summary:`added optional field ${t}.${e}`,table:t,type:"addedOptionalField"}:{remediation:"backfill",severity:"breaking",summary:`added required field ${t}.${e} \u2014 existing rows have no value; add a data migration to backfill it`,table:t,scope:"table",type:"addedRequiredField"},"ve"),Et=s((t,e,r,i)=>{for(let[a,o]of Object.entries(r.fields)){let n=e.fields[a];n===void 0?i.push(Kt(t,a,o)):i.push(...wt(t,a,n,o))}for(let a of Object.keys(e.fields))r.fields[a]===void 0&&i.push({remediation:"backfill",severity:"breaking",summary:`removed field ${t}.${a} \u2014 add a data migration if stored data must be cleaned up`,table:t,scope:"table",type:"removedField"})},"xe"),Jt=s((t,e,r,i)=>{for(let[a,o]of Object.entries(r.indexes)){let n=e.indexes[a];if(n===void 0){i.push(o.unique?{remediation:"backfill",scope:"table",severity:"breaking",summary:`added unique index ${a} on ${t} \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`,table:t,type:"addedIndex"}:{remediation:"none",scope:"table",severity:"safe",summary:`added index ${a} on ${t}`,table:t,type:"addedIndex"});continue}Ft(n,o)||i.push({remediation:"code",severity:"breaking",summary:`index ${a} on ${t} changed shape \u2014 a query may have relied on the old index`,table:t,scope:"table",type:"changedIndex"})}for(let a of Object.keys(e.indexes))r.indexes[a]===void 0&&i.push({remediation:"code",severity:"breaking",summary:`removed index ${a} on ${t} \u2014 a query that used \`.withIndex("${a}")\` would break`,table:t,scope:"table",type:"removedIndex"})},"ke"),At=s((t,e,r,i)=>{for(let a of Object.keys(r.relations))e.relations[a]===void 0&&i.push({remediation:"none",scope:"schema",severity:"safe",summary:`added relation ${t}.${a}`,table:t,type:"addedRelation"});for(let a of Object.keys(e.relations))r.relations[a]===void 0&&i.push({remediation:"code",scope:"schema",severity:"breaking",summary:`removed relation ${t}.${a}`,table:t,type:"removedRelation"})},"$e"),pt="shardBy:_unknown_",Te="global",Pt=s((t,e)=>t===Te&&e.startsWith(`${Te}:`)||e===Te&&t.startsWith(`${Te}:`),"we"),Bt=s((t,e,r)=>{if(e===r)return r!==pt?void 0:{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} declares a non-literal .shardBy(...) key, so codegen cannot read which column partitions it \u2014 every such key records as "${pt}" and two DIFFERENT keys would compare equal. Pass the shard key as a string literal; until then this is reported on every run, because the alternative is a silent pass on a re-home that strands every row (export/import is the only way back).`,table:t,type:"changedShardMode"};if(!Pt(e,r))return{remediation:"rehome",severity:"breaking",summary:`table ${t} changed shard mode: ${e} \u2192 ${r} \u2014 its physical storage moves, and existing rows do NOT follow the schema; re-home them with an export/import round trip (https://lunora.sh/docs/concepts/sharding#migrating-a-populated-table)`,table:t,scope:"table",type:"changedShardMode"}},"Oe"),gt=s(t=>t.memory!==void 0,"B"),bt=s(t=>t.after??0,"K"),R=s(t=>t.after===void 0?`.ttl("${t.field}")`:`.ttl("${t.field}", { after: ${String(t.after)} })`,"w"),Wt=s((t,e,r)=>{if(e===void 0&&r===void 0)return;let i=s(d=>({remediation:"backfill",scope:"table",severity:"breaking",summary:d,table:t,type:"changedTtlPolicy"}),"i"),a=s(d=>({remediation:"none",scope:"table",severity:"safe",summary:d,table:t,type:"changedTtlPolicy"}),"o");if(r===void 0)return a(`table ${t} dropped its TTL policy \u2014 its rows are no longer swept`);if(e===void 0)return i(`table ${t} gained a TTL policy ${R(r)} \u2014 every row already past the cutoff is deleted on the next alarm sweep; add a data migration to refresh or clear "${r.field}" on the rows written before it`);if(e.field!==r.field)return i(`table ${t} moved its TTL to a different column: ${R(e)} \u2192 ${R(r)} \u2014 rows are now expired by a column they were never written against; add a data migration to populate "${r.field}"`);let o=bt(e),n=bt(r);return n<o?i(`table ${t} shortened its TTL: ${R(e)} \u2192 ${R(r)} \u2014 rows that were not expired under the old offset are deleted on the next alarm sweep; add a data migration to refresh "${r.field}" on the rows that must survive`):n>o?a(`table ${t} lengthened its TTL: ${R(e)} \u2192 ${R(r)}`):void 0},"Se"),Ut=s((t,e,r)=>{let i=[];return e.memory!==r.memory&&i.push(r.memory===!0?{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} became a .memory() table \u2014 every row is deleted in every shard on the next Durable Object cold start, and no data migration survives that; export the rows first if they must be kept, or revert`,table:t,type:"changedMemoryMode"}:{remediation:"none",scope:"table",severity:"safe",summary:`table ${t} is no longer a .memory() table \u2014 its rows now survive a cold start`,table:t,type:"changedMemoryMode"}),e.commitOrdered!==r.commitOrdered&&i.push(r.commitOrdered===!0?{remediation:"backfill",scope:"table",severity:"breaking",summary:`table ${t} became .commitOrdered() \u2014 rows written before it carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed never offers them; add a data migration over the table to stamp them (the rewrite allocates a sequence)`,table:t,type:"changedCommitOrdering"}:{remediation:"code",scope:"table",severity:"breaking",summary:`table ${t} is no longer .commitOrdered() \u2014 new rows carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed stops advancing without erroring; update the consumers before deploying`,table:t,type:"changedCommitOrdering"}),i},"Te"),zt=s((t,e,r,i)=>{let a=Bt(t,e.shardMode,r.shardMode);if(a&&i.push(a),gt(e)&>(r)){i.push(...Ut(t,e,r));let o=Wt(t,e.ttl,r.ttl);o&&i.push(o)}Et(t,e,r,i),Jt(t,e,r,i),At(t,e,r,i)},"je"),Ht=s((t,e)=>{let r=[],i=t?.tables??{};for(let[a,o]of Object.entries(e.tables)){let n=i[a];if(n===void 0){r.push({remediation:"none",scope:"table",severity:"safe",summary:`added table ${a}`,table:a,type:"addedTable"});continue}zt(a,n,o,r)}for(let a of Object.keys(i))e.tables[a]===void 0&&r.push({remediation:"rehome",scope:"table",severity:"breaking",summary:`removed table ${a} \u2014 its rows stay in each shard's SQLite, unreachable through the schema; export the shard first if the data must be kept`,table:a,type:"removedTable"});if(t!==void 0&&t.jurisdiction!==e.jurisdiction){let a=t.jurisdiction??"(none)",o=e.jurisdiction??"(none)";r.push({remediation:"rehome",scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${a} to ${o} \u2014 this re-homes every DO and strands all existing shard, scheduler, and session-DO data in the old region (no in-place migration; export then import to move it). Revert the change, or override the gate to proceed intentionally.`,type:"changedJurisdiction"})}return{changes:r}},"Fe"),yt=s(t=>Object.entries(t.fields).map(([e,r])=>({name:e,optional:r.optional,ref:Object.values(t.relations).find(i=>i.field===e&&i.kind==="one")?.table,type:O(r)})),"Y"),vt=s((t,e,r)=>{let i={},a=e?.fields??{},o=r?.fields??{};for(let[n,d]of Object.entries(o)){let l=a[n];l===void 0?i[n]=e===void 0?"unchanged":"added":i[n]=wt(t,n,l,d).length===0?"unchanged":"changed"}for(let n of Object.keys(a))o[n]===void 0&&(i[n]="removed");return i},"z"),Qt=s((t,e)=>{let{changes:r}=Ht(t,e),i=new Set(r.filter(n=>n.scope==="table"&&n.table!==void 0).map(n=>n.table)),a=[],o=s((n,d)=>n?"added":i.has(d)?"changed":"context","r");for(let[n,d]of Object.entries(e.tables)){let l=t?.tables[n],f=o(l===void 0,n);a.push({columns:yt(d),fieldStatus:vt(n,l,d),name:n,shardMode:d.shardMode,status:f})}for(let[n,d]of Object.entries(t?.tables??{}))e.tables[n]===void 0&&a.push({columns:yt(d),fieldStatus:vt(n,d,void 0),name:n,shardMode:d.shardMode,status:"removed"});return a.sort((n,d)=>n.name.localeCompare(d.name)),{breakingCount:r.filter(n=>n.severity==="breaking").length,changes:r,tables:a}},"Me"),xt=s(t=>{let e=It(t);return e.status==="ok"?e.snapshot:void 0},"N"),Vt={added:"ring-2 ring-emerald-500/60",changed:"ring-2 ring-amber-500/70",context:"opacity-55",removed:"opacity-70 ring-2 ring-destructive/60"},Gt=s(t=>t==="global"||t.startsWith("global:")?"global":"shard","Ce"),Xt=s(t=>{let e=(0,ge.c)(24),{appliedAt:r,hash:i,onSelect:a,selected:o,seq:n}=t,d=o?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground",l;e[0]!==d?(l=de("flex w-full flex-col items-start gap-1 border-s-2 px-4 py-3 text-start outline-none transition-colors",d),e[0]=d,e[1]=l):l=e[1];let f=`sh-version-${i}`,h;e[2]!==i||e[3]!==a?(h=s(()=>{a(i)},"f"),e[2]=i,e[3]=a,e[4]=h):h=e[4];let g;e[5]!==n?(g=(0,c.jsxs)("span",{className:"font-mono text-[13px] tabular-nums",children:["v",n]}),e[5]=n,e[6]=g):g=e[6];let p;e[7]!==i?(p=i.slice(0,7),e[7]=i,e[8]=p):p=e[8];let b;e[9]!==p?(b=(0,c.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:p}),e[9]=p,e[10]=b):b=e[10];let y;e[11]!==g||e[12]!==b?(y=(0,c.jsxs)("span",{className:"flex w-full items-baseline gap-2",children:[g,b]}),e[11]=g,e[12]=b,e[13]=y):y=e[13];let x;e[14]!==r?(x=je(r),e[14]=r,e[15]=x):x=e[15];let v;e[16]!==x?(v=(0,c.jsx)("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:x}),e[16]=x,e[17]=v):v=e[17];let u;return e[18]!==v||e[19]!==l||e[20]!==f||e[21]!==h||e[22]!==y?(u=(0,c.jsx)("li",{children:(0,c.jsxs)("button",{className:l,"data-testid":f,onClick:h,type:"button",children:[y,v]})}),e[18]=v,e[19]=l,e[20]=f,e[21]=h,e[22]=y,e[23]=u):u=e[23],u},"Ie"),Yt=s(t=>{let e=(0,ge.c)(26),{breaking:r,count:i,first:a}=t,o=le();if(a){let b;e[0]!==i?(b=(0,c.jsx)("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:i}),e[0]=i,e[1]=b):b=e[1];let y;e[2]!==o?(y=o("tables"),e[2]=o,e[3]=y):y=e[3];let x;e[4]!==y?(x=(0,c.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:y}),e[4]=y,e[5]=x):x=e[5];let v;return e[6]!==b||e[7]!==x?(v=(0,c.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[b,x]}),e[6]=b,e[7]=x,e[8]=v):v=e[8],v}let n=r>0&&"text-destructive",d;e[9]!==n?(d=de("text-3xl leading-none font-light tracking-tight tabular-nums",n),e[9]=n,e[10]=d):d=e[10];let l;e[11]!==i||e[12]!==d?(l=(0,c.jsx)("span",{className:d,children:i}),e[11]=i,e[12]=d,e[13]=l):l=e[13];let f;e[14]!==i||e[15]!==o?(f=o(i===1?"change":"changes"),e[14]=i,e[15]=o,e[16]=f):f=e[16];let h;e[17]!==f?(h=(0,c.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:f}),e[17]=f,e[18]=h):h=e[18];let g;e[19]!==r||e[20]!==o?(g=r>0&&(0,c.jsxs)("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["\xB7 ",o("{count} breaking",{count:r})]}),e[19]=r,e[20]=o,e[21]=g):g=e[21];let p;return e[22]!==l||e[23]!==h||e[24]!==g?(p=(0,c.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[l,h,g]}),e[22]=l,e[23]=h,e[24]=g,e[25]=p):p=e[25],p},"Re"),$t={addedFieldConstraint:{action:"added",kind:"constraint"},addedIndex:{action:"added",kind:"index"},addedOptionalField:{action:"added",kind:"field?"},addedRelation:{action:"added",kind:"relation"},addedRequiredField:{action:"added",kind:"field"},addedTable:{action:"added",kind:"table"},changedCommitOrdering:{action:"changed",kind:"commit ordering"},changedFieldKind:{action:"changed",kind:"field kind"},changedFieldShape:{action:"changed",kind:"field shape"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedMemoryMode:{action:"changed",kind:"memory mode"},changedShardMode:{action:"changed",kind:"shard mode"},changedTtlPolicy:{action:"changed",kind:"TTL policy"},fieldOptionalToRequired:{action:"changed",kind:"field \u2192 required"},fieldRequiredToOptional:{action:"changed",kind:"field \u2192 optional"},relaxedFieldConstraint:{action:"removed",kind:"constraint"},removedField:{action:"removed",kind:"field"},removedIndex:{action:"removed",kind:"index"},removedRelation:{action:"removed",kind:"relation"},removedTable:{action:"removed",kind:"table"},widenedFieldShape:{action:"changed",kind:"field \u2192 wider"}},Zt=s((t,e)=>{let r=`${$t[t.type].action} ${e} `;return t.summary.startsWith(r)?t.summary.slice(r.length):t.summary},"Ee"),ea=s(t=>{let e=new Map;for(let i of t){let a=i.table??"",o=e.get(a);o===void 0?e.set(a,[i]):o.push(i)}let r=[...e].map(([i,a])=>({changes:a,table:i}));return[...r.filter(i=>i.table!==""),...r.filter(i=>i.table==="")]},"Ae"),ta=s(t=>{let e=(0,ge.c)(2),{children:r}=t,i;return e[0]!==r?(i=(0,c.jsx)("div",{className:"px-4 pt-4 pb-2 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:r}),e[0]=r,e[1]=i):i=e[1],i},"De"),aa=s(({pane:t,shardKey:e=""})=>{let r=le(),i=Ue(),a=We({strict:!1}).version,o=s(u=>{Oe(i({search:{version:u},to:"/migrations"}))},"s"),n=ce(F.schemaHistory,{},{shardKey:e}),d=n.data?.versions??[],l=a!==void 0&&d.some(u=>u.hash===a)?a:d[0]?.hash,f=d.findIndex(u=>u.hash===l),h=f===-1?void 0:d[f+1]?.hash,g=ce(F.schemaVersion,{hash:l??""},{enabled:l!==void 0,shardKey:e}),p=ce(F.schemaVersion,{hash:h??""},{enabled:h!==void 0,shardKey:e}),b=(0,he.useMemo)(()=>{let u=xt(g.data?.version?.snapshotJson);if(u!==void 0)return Qt(xt(p.data?.version?.snapshotJson),u)},[g.data,p.data]),y=(0,he.useMemo)(()=>(b?.tables??[]).map(u=>({columns:u.columns,name:u.name,tier:Gt(u.shardMode)})),[b]),x=(0,he.useMemo)(()=>{let u={};for(let w of b?.tables??[])u[w.name]=Vt[w.status];return u},[b]);if(n.error!==null)return(0,c.jsx)(qe,{error:n.errorSource,testId:"sh-error"});if(d.length===0)return(0,c.jsx)(Se,{description:r("Each distinct schema shape this shard runs is recorded here, so you can see what changed and when."),testId:"sh-empty",title:r("No schema versions recorded yet.")});let v=b?.changes??[];return(0,c.jsxs)("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[(0,c.jsxs)("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[(0,c.jsx)(ta,{children:r("Schema versions")}),(0,c.jsx)("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:d.map(u=>(0,c.jsx)(Xt,{appliedAt:u.appliedAt,hash:u.hash,onSelect:o,selected:u.hash===l,seq:u.seq},u.hash))})]}),(0,c.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[(0,c.jsx)(Yt,{breaking:b?.breakingCount??0,count:h===void 0?y.length:v.length,first:h===void 0}),t==="diagram"?(0,c.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,c.jsx)(dt,{fill:!0,nodeClasses:x,tables:y,testIdPrefix:"sh"})}):(0,c.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:ea(v).map(u=>{let w=(b?.tables??[]).find(k=>k.name===u.table);return(0,c.jsxs)("section",{className:"mb-6",children:[(0,c.jsxs)("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[(0,c.jsx)("span",{className:"font-mono text-[13px] text-foreground",children:u.table===""?r("schema"):u.table}),w!==void 0&&(0,c.jsx)("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:r("{count} columns",{count:w.columns.length})}),u.changes.length>1&&(0,c.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:u.changes.length})]}),(0,c.jsx)("ul",{children:u.changes.map(k=>{let{action:L,kind:C}=$t[k.type],j=k.severity==="breaking",M=Zt(k,C);return(0,c.jsxs)("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[(0,c.jsx)("span",{"aria-hidden":"true",className:de("-ms-3 h-3 w-0.5 shrink-0 self-center",j?"bg-destructive":"bg-transparent")}),(0,c.jsxs)("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[r(L)," ",C]}),M!==u.table&&(0,c.jsx)("span",{className:de("min-w-0 font-mono text-[13px]",j?"text-destructive":"text-foreground"),children:M}),j&&(0,c.jsx)("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:r("breaking")})]},`${k.type}-${k.summary}`)})})]},u.table)})})]})]})},"Le"),ra=s(t=>de("-mb-px border-b-2 px-3 py-2.5 font-mono text-[11px] tracking-wider uppercase transition-colors outline-none","hover:bg-accent/40 focus-visible:bg-accent/40",t?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"Je"),Ra=s(t=>{let e=(0,ge.c)(11),{initialShardKey:r}=t,i=le(),[a,o]=(0,he.useState)("diagram"),n;e[0]!==a?(n=s((g,p,b,y)=>(0,c.jsxs)("button",{"aria-selected":a===g,className:ra(a===g),"data-testid":b,onClick:s(()=>{o(g)},"onClick"),role:"tab",type:"button",children:[p,y!==void 0&&(0,c.jsx)("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:y})]}),"s"),e[0]=a,e[1]=n):n=e[1];let d=n,l;e[2]!==i||e[3]!==d?(l=(0,c.jsxs)("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-3","data-testid":"mg-panes",role:"tablist",children:[d("diagram",i("Diagram"),"mg-pane-diagram"),d("changes",i("Changes"),"mg-pane-changes"),d("data",i("Data migrations"),"mg-pane-data")]}),e[2]=i,e[3]=d,e[4]=l):l=e[4];let f;e[5]!==r||e[6]!==a?(f=(0,c.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:a==="data"?(0,c.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:(0,c.jsx)(ct,{initialShardKey:r})}):(0,c.jsx)(aa,{pane:a,shardKey:r})}),e[5]=r,e[6]=a,e[7]=f):f=e[7];let h;return e[8]!==l||e[9]!==f?(h=(0,c.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[l,f]}),e[8]=l,e[9]=f,e[10]=h):h=e[10],h},"Xe");export{Ra as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Ze}from"./chunk-ECY2JC5F.js";import"./chunk-NRP22GKC.js";import{a as Xe}from"./chunk-FPI7AMQJ.js";import{a as Ye}from"./chunk-JQXA2OYK.js";import"./chunk-UC7MNI2F.js";import{a as Ve}from"./chunk-I23ULEUU.js";import{i as Pe}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as le}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as de}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as Ke}from"./chunk-UQAMQR4Q.js";import{a as He}from"./chunk-NCPW7WHO.js";import"./chunk-3I6JC6NL.js";import"./chunk-55UGUCQ6.js";import{a as W}from"./chunk-4ZEL6BYL.js";import{c as Le}from"./chunk-PYNRIX74.js";import{l as ze}from"./chunk-BDYCZHD2.js";import"./chunk-QAQDMS6R.js";import"./chunk-WS7WNXF3.js";import{a as ie}from"./chunk-RWVIV3U7.js";import{a as Te,b as _e,c as Be,d as z,e as C,f as w}from"./chunk-HCTJKP5J.js";import{a as Me,e as Ae}from"./chunk-2IKDEUCX.js";import{d as F,f as ce,g as ue,h as H,m as Ue,p as me,t as Ge}from"./chunk-5OMZCVRF.js";import{a as c,d as Ee,e as ct,f as ut,g as mt}from"./chunk-I26MS5PJ.js";var D=Ee(ut(),1);var Q=Ee(ct(),1);var t=Ee(mt(),1);var pt=c((n,e)=>{let a=new Set(n.map(s=>s.deadLetterQueue).filter(s=>typeof s=="string"&&s!=="")),d=n.filter(s=>(s.deadLetterQueue===void 0||s.deadLetterQueue==="")&&!a.has(s.name)),r=e.filter(s=>s.deadLettered).length;return{deadLetteredCount:r,queuesWithoutDlq:d,showReliabilityWarning:d.length>0||r>0}},"ut"),De="topic:",$e=c(n=>{let e=[],a=new Map;for(let d of n)d.topic===void 0?e.push(d):a.set(d.topic,[...a.get(d.topic)??[],d]);return{plain:e,topics:a}},"Ae"),tt=c(n=>`${De}${n}`,"We"),ht=c((n,e)=>n.startsWith(De)?(e.get(n.slice(De.length))??[]).map(a=>a.exportName):[n],"mt"),gt=200,ft=ce(W.sendQueueMessage),xt=c(async(n,e,a)=>{let d=(await Promise.allSettled(e.map(async s=>n.query(ft,s,ue(""))))).flatMap((s,l)=>s.status==="rejected"?[{exportName:e[l]?.exportName??"",message:H(s.reason)}]:[]),[r]=d;return r===void 0?null:e.length===1?r.message:a("Not sent to {failed}",{failed:d.map(s=>`${s.exportName}: ${s.message}`).join("; ")})},"ht"),yt=ce(W.replayQueueMessage),Nt=ce(W.clearQueueMessages),et=96,bt=c(n=>{if(n===void 0)return"\u2014";try{return JSON.stringify(n,Ue)}catch{return"[unserializable]"}},"yt"),qt=c(n=>n.length>et?`${n.slice(0,et)}\u2026`:n,"bt"),vt=c(n=>n==="error"?"destructive":n==="retry"?"outline":"secondary","Nt"),St=c((n,e)=>e(n==="messages"?"Messages":n==="send"?"Send":"Declared"),"qt"),at=c(n=>{let e=(0,D.c)(17),{queue:a}=n,d=`queues-row-${a.exportName}`,r;e[0]!==a.exportName?(r=(0,t.jsx)(w,{className:"font-mono text-xs",children:a.exportName}),e[0]=a.exportName,e[1]=r):r=e[1];let s;e[2]!==a.name?(s=(0,t.jsx)(w,{className:"font-mono text-xs text-muted-foreground",children:a.name}),e[2]=a.name,e[3]=s):s=e[3];let l;e[4]!==a.mode?(l=(0,t.jsx)(w,{className:"font-mono text-xs text-muted-foreground",children:a.mode}),e[4]=a.mode,e[5]=l):l=e[5];let o;e[6]!==a.binding?(o=(0,t.jsx)(w,{className:"font-mono text-xs text-muted-foreground",children:a.binding}),e[6]=a.binding,e[7]=o):o=e[7];let m=a.deadLetterQueue??"\u2014",i;e[8]!==m?(i=(0,t.jsx)(w,{className:"font-mono text-xs text-muted-foreground",children:m}),e[8]=m,e[9]=i):i=e[9];let p;return e[10]!==d||e[11]!==r||e[12]!==s||e[13]!==l||e[14]!==o||e[15]!==i?(p=(0,t.jsxs)(z,{"data-testid":d,children:[r,s,l,o,i]}),e[10]=d,e[11]=r,e[12]=s,e[13]=l,e[14]=o,e[15]=i,e[16]=p):p=e[16],p},"Ge"),wt=c(n=>{let e=(0,D.c)(8),{loaded:a,queues:d}=n,r=F(),s;if(e[0]!==a||e[1]!==d||e[2]!==r){let{plain:l,topics:o}=$e(d),m;e[4]!==r?(m=r("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[4]=r,e[5]=m):m=e[5];let i;e[6]!==m?(i=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:m}),e[6]=m,e[7]=i):i=e[7],s=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[i,a&&d.length===0?(0,t.jsx)(ie,{description:r("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:r("No queues defined")}):(0,t.jsx)(Me,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ae,{className:"px-0",children:(0,t.jsxs)(Te,{"data-testid":"queues-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(z,{children:[(0,t.jsx)(C,{children:r("Export")}),(0,t.jsx)(C,{children:r("Queue")}),(0,t.jsx)(C,{children:r("Mode")}),(0,t.jsx)(C,{children:r("Binding")}),(0,t.jsx)(C,{children:r("Dead-letter")})]})}),(0,t.jsxs)(Be,{children:[l.map(Et),[...o].map(p=>{let[f,x]=p;return(0,t.jsxs)(Q.Fragment,{children:[(0,t.jsx)(z,{className:"bg-muted/40","data-testid":`queues-topic-${f}`,children:(0,t.jsx)(w,{className:"text-xs font-medium",colSpan:5,children:r("Topic {topic} \xB7 {count} subscriptions",{count:x.length,topic:f})})}),x.map(Mt)]},f)})]})]})})})]}),e[0]=a,e[1]=d,e[2]=r,e[3]=s}else s=e[3];return s},"St"),Ct=c(n=>{let e=(0,D.c)(67),{message:a,onReplay:d,replayingId:r}=n,s=F(),l,o,m,i,p,f,x,u,h,N;if(e[0]!==a.attempts||e[1]!==a.body||e[2]!==a.deadLettered||e[3]!==a.exportName||e[4]!==a.id||e[5]!==a.messageId||e[6]!==a.outcome||e[7]!==a.queue||e[8]!==s){let P=bt(a.body);o=z,f=`queues-message-${a.id}`;let U=a.exportName??a.queue;e[19]!==U?(x=(0,t.jsx)(w,{className:"font-mono text-xs",children:U}),e[19]=U,e[20]=x):x=e[20],e[21]!==a.messageId?(u=(0,t.jsx)(w,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:a.messageId,children:a.messageId}),e[21]=a.messageId,e[22]=u):u=e[22],e[23]!==a.attempts?(h=(0,t.jsx)(w,{className:"font-mono text-xs tabular-nums",children:a.attempts}),e[23]=a.attempts,e[24]=h):h=e[24];let L=`queues-outcome-${a.id}`,T;e[25]!==a.outcome?(T=vt(a.outcome),e[25]=a.outcome,e[26]=T):T=e[26];let I;e[27]!==a.outcome||e[28]!==L||e[29]!==T?(I=(0,t.jsx)(de,{"data-testid":L,variant:T,children:a.outcome}),e[27]=a.outcome,e[28]=L,e[29]=T,e[30]=I):I=e[30];let _;e[31]!==a.deadLettered||e[32]!==a.id||e[33]!==s?(_=a.deadLettered&&(0,t.jsx)(de,{"data-testid":`queues-dlq-${a.id}`,variant:"destructive",children:s("DLQ")}),e[31]=a.deadLettered,e[32]=a.id,e[33]=s,e[34]=_):_=e[34],e[35]!==I||e[36]!==_?(N=(0,t.jsx)(w,{children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-1",children:[I,_]})}),e[35]=I,e[36]=_,e[37]=N):N=e[37],l=w,m="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",i=P,p=qt(P),e[0]=a.attempts,e[1]=a.body,e[2]=a.deadLettered,e[3]=a.exportName,e[4]=a.id,e[5]=a.messageId,e[6]=a.outcome,e[7]=a.queue,e[8]=s,e[9]=l,e[10]=o,e[11]=m,e[12]=i,e[13]=p,e[14]=f,e[15]=x,e[16]=u,e[17]=h,e[18]=N}else l=e[9],o=e[10],m=e[11],i=e[12],p=e[13],f=e[14],x=e[15],u=e[16],h=e[17],N=e[18];let y;e[38]!==l||e[39]!==m||e[40]!==i||e[41]!==p?(y=(0,t.jsx)(l,{className:m,title:i,children:p}),e[38]=l,e[39]=m,e[40]=i,e[41]=p,e[42]=y):y=e[42];let q;e[43]!==a.capturedAt?(q=Ge(a.capturedAt,"\u2014"),e[43]=a.capturedAt,e[44]=q):q=e[44];let b;e[45]!==q?(b=(0,t.jsx)(w,{className:"text-xs text-muted-foreground tabular-nums",children:q}),e[45]=q,e[46]=b):b=e[46];let v=`queues-replay-${a.id}`,E=r!==null,M;e[47]!==a.id||e[48]!==r||e[49]!==s?(M=r===a.id?s("Replaying\u2026"):s("Replay"),e[47]=a.id,e[48]=r,e[49]=s,e[50]=M):M=e[50];let A;e[51]!==a.id||e[52]!==d||e[53]!==v||e[54]!==E||e[55]!==M?(A=(0,t.jsx)(w,{children:(0,t.jsx)(le,{"data-id":a.id,"data-testid":v,disabled:E,onClick:d,size:"xs",type:"button",variant:"outline",children:M})}),e[51]=a.id,e[52]=d,e[53]=v,e[54]=E,e[55]=M,e[56]=A):A=e[56];let $;return e[57]!==o||e[58]!==b||e[59]!==A||e[60]!==f||e[61]!==x||e[62]!==u||e[63]!==h||e[64]!==N||e[65]!==y?($=(0,t.jsxs)(o,{"data-testid":f,children:[x,u,h,N,y,b,A]}),e[57]=o,e[58]=b,e[59]=A,e[60]=f,e[61]=x,e[62]=u,e[63]=h,e[64]=N,e[65]=y,e[66]=$):$=e[66],$},"Et"),It=c(n=>{let e=(0,D.c)(29),{hasError:a,messages:d,onClear:r,onReplay:s,replayingId:l}=n,o=F(),m;e[0]!==o?(m=o("Cloudflare Queues have no peek API, so this is what push consumers actually processed \u2014 not pending depth."),e[0]=o,e[1]=m):m=e[1];let i;e[2]!==m?(i=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:m}),e[2]=m,e[3]=i):i=e[3];let p;e[4]!==o?(p=o("Clear the whole message log?"),e[4]=o,e[5]=p):p=e[5];let f=d.length===0,x;e[6]!==o?(x=o("Clear log"),e[6]=o,e[7]=x):x=e[7];let u;e[8]!==r||e[9]!==p||e[10]!==f||e[11]!==x?(u=(0,t.jsx)("div",{className:"ml-auto",children:(0,t.jsx)(Ve,{confirmLabel:p,disabled:f,onConfirm:r,testId:"queues-clear",children:x})}),e[8]=r,e[9]=p,e[10]=f,e[11]=x,e[12]=u):u=e[12];let h;e[13]!==d.length||e[14]!==o?(h=d.length>0&&(0,t.jsx)(de,{"data-testid":"queues-count",variant:"secondary",children:o("{count} messages",{count:d.length})}),e[13]=d.length,e[14]=o,e[15]=h):h=e[15];let N;e[16]!==i||e[17]!==u||e[18]!==h?(N=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[i,u,h]}),e[16]=i,e[17]=u,e[18]=h,e[19]=N):N=e[19];let y;e[20]!==a||e[21]!==d||e[22]!==s||e[23]!==l||e[24]!==o?(y=!a&&d.length===0?(0,t.jsx)(ie,{description:o("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:o("No consumed messages yet.")}):(0,t.jsx)(Me,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ae,{className:"px-0",children:(0,t.jsx)(Ze,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:(0,t.jsxs)(Te,{"data-testid":"queues-messages-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(z,{children:[(0,t.jsx)(C,{children:o("Export")}),(0,t.jsx)(C,{children:o("Message")}),(0,t.jsx)(C,{children:o("Attempts")}),(0,t.jsx)(C,{children:o("Outcome")}),(0,t.jsx)(C,{children:o("Body")}),(0,t.jsx)(C,{children:o("Captured")}),(0,t.jsx)(C,{})]})}),(0,t.jsx)(Be,{children:d.map(b=>(0,t.jsx)(Ct,{message:b,onReplay:s,replayingId:l},b.id))})]})})})}),e[20]=a,e[21]=d,e[22]=s,e[23]=l,e[24]=o,e[25]=y):y=e[25];let q;return e[26]!==N||e[27]!==y?(q=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[N,y]}),e[26]=N,e[27]=y,e[28]=q):q=e[28],q},"Tt"),Qt=c(n=>{let e=(0,D.c)(20),{batchMode:a,bodyText:d,delayText:r,onBatchModeChange:s,onBodyChange:l,onDelayChange:o,onSelectExport:m,onSend:i,queues:p,selectedExportName:f,sending:x}=n,u=F(),h;e[0]!==u?(h=u("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=u,e[1]=h):h=e[1];let N;e[2]!==h?(N=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:h}),e[2]=h,e[3]=N):N=e[3];let y;e[4]!==a||e[5]!==d||e[6]!==r||e[7]!==s||e[8]!==l||e[9]!==o||e[10]!==m||e[11]!==i||e[12]!==p||e[13]!==f||e[14]!==x||e[15]!==u?(y=p.length===0?(0,t.jsx)(ie,{description:u("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:u("No queues to send to")}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("select",{"aria-label":u("Queue"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"queues-send-select",onChange:m,value:f,children:[p.map(At),[...$e(p).topics].map(b=>{let[v,E]=b;return(0,t.jsx)("option",{value:tt(v),children:u("{topic} (topic \u2192 {count} subscriptions)",{count:E.length,topic:v})},v)})]}),(0,t.jsx)(Pe,{"aria-label":u("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:o,placeholder:u("Delay (s)"),type:"number",value:r}),(0,t.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[(0,t.jsx)("input",{checked:a,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:s,type:"checkbox"}),u("Send as batch (JSON array)")]}),(0,t.jsx)(le,{className:"ml-auto","data-testid":"queues-send-button",disabled:x||f==="",onClick:i,type:"button",children:u(x?"Sending\u2026":"Send message")})]}),(0,t.jsx)(Xe,{"aria-label":u("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:l,placeholder:a?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:d})]}),e[4]=a,e[5]=d,e[6]=r,e[7]=s,e[8]=l,e[9]=o,e[10]=m,e[11]=i,e[12]=p,e[13]=f,e[14]=x,e[15]=u,e[16]=y):y=e[16];let q;return e[17]!==N||e[18]!==y?(q=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[N,y]}),e[17]=N,e[18]=y,e[19]=q):q=e[19],q},"_t"),Yt=c(n=>{let e=(0,D.c)(57),{limit:a}=n,d=a??gt,r=ze(),s=F(),[l,o]=(0,Q.useState)("declared"),[m,i]=(0,Q.useState)(null),p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let{data:f,error:x,errorSource:u}=Le(W.listQueues,p),h;e[1]!==d?(h={limit:d},e[1]=d,e[2]=h):h=e[2];let{data:N,error:y,errorSource:q,refetch:b}=Le(W.getQueueMessages,h),v=Array.isArray(f?.queues)?[...f.queues].toSorted(Lt):[],E=N?.entries??[],{deadLetteredCount:M,queuesWithoutDlq:A,showReliabilityWarning:$}=pt(v,E),[P,U]=(0,Q.useState)(""),[L,T]=(0,Q.useState)(""),[I,_]=(0,Q.useState)(""),[G,st]=(0,Q.useState)(!1),[pe,ke]=(0,Q.useState)(!1),[he,Oe]=(0,Q.useState)(null),{topics:Re}=$e(v),Je=[...v.map(Tt),...[...Re.keys()].map(_t)],K=Je.includes(P)?P:Je[0]??"",je=l==="messages"?y:x,nt=l==="messages"?q:u,ge=je??m,fe=je===null?m:nt,V;e[3]!==b?(V=c(()=>{b()},"V"),e[3]=b,e[4]=V):V=e[4],Ye(V,l==="messages");let rt=c(async()=>{i(null);let g=K;if(g==="")return;let S=null,Fe=L.trim();if(Fe!=="")try{S=JSON.parse(Fe)}catch{i(s("Body must be valid JSON."));return}let Qe,We=I.trim();if(We!==""){let B=Number(We);if(!Number.isFinite(B)||B<0){i(s("Delay must be a non-negative number of seconds."));return}Qe=B}if(G&&!Array.isArray(S)){i(s("Batch mode needs a JSON array body \u2014 each element is enqueued as one message."));return}ke(!0);let it=ht(g,Re).map(B=>G?{batch:S,delaySeconds:Qe,exportName:B}:{body:S,delaySeconds:Qe,exportName:B});try{i(await xt(r,it,s)),b()}catch(B){i(H(B))}ke(!1)},"Ve"),X;e[5]!==r||e[6]!==b?(X=c(async g=>{i(null),Oe(g);try{await r.query(yt,{id:g},ue("")),b()}catch(S){i(H(S))}Oe(null)},"X"),e[5]=r,e[6]=b,e[7]=X):X=e[7];let xe=X,Y;e[8]!==r||e[9]!==b?(Y=c(async()=>{i(null);try{await r.query(Nt,{},ue("")),b()}catch(g){i(H(g))}},"Y"),e[8]=r,e[9]=b,e[10]=Y):Y=e[10];let ye=Y,Z;e[11]===Symbol.for("react.memo_cache_sentinel")?(Z=c(g=>{let S=g.currentTarget.dataset.tab;(S==="declared"||S==="messages"||S==="send")&&o(S)},"K"),e[11]=Z):Z=e[11];let ot=Z,ee;e[12]===Symbol.for("react.memo_cache_sentinel")?(ee=c(g=>{U(g.currentTarget.value)},"Z"),e[12]=ee):ee=e[12];let Ne=ee,te;e[13]===Symbol.for("react.memo_cache_sentinel")?(te=c(g=>{T(g.currentTarget.value)},"ee"),e[13]=te):te=e[13];let be=te,ae;e[14]===Symbol.for("react.memo_cache_sentinel")?(ae=c(g=>{_(g.currentTarget.value)},"te"),e[14]=ae):ae=e[14];let qe=ae,se;e[15]===Symbol.for("react.memo_cache_sentinel")?(se=c(g=>{st(g.currentTarget.checked)},"se"),e[15]=se):se=e[15];let ve=se,Se=c(()=>{me(rt())},"xe"),ne;e[16]!==xe?(ne=c(g=>{let{id:S}=g.currentTarget.dataset;S!==void 0&&me(xe(S))},"ae"),e[16]=xe,e[17]=ne):ne=e[17];let we=ne,re;e[18]!==ye?(re=c(()=>{me(ye())},"re"),e[18]=ye,e[19]=re):re=e[19];let Ce=re,dt="flex flex-col gap-6",lt="lunora-queues-panel",k;e[20]!==s||e[21]!==l?(k=(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(g=>(0,t.jsx)(le,{"aria-selected":l===g,"data-tab":g,"data-testid":`queues-tab-${g}`,onClick:ot,role:"tab",size:"sm",type:"button",variant:l===g?"secondary":"ghost",children:St(g,s)},g))}),e[20]=s,e[21]=l,e[22]=k):k=e[22];let O;e[23]!==ge||e[24]!==fe?(O=ge!==null&&(0,t.jsx)(Ke,{error:fe,testId:"queues-error"}),e[23]=ge,e[24]=fe,e[25]=O):O=e[25];let Ie=$&&(0,t.jsx)(He,{icon:(0,t.jsx)("span",{"aria-hidden":"true",className:"text-base leading-none",children:"\u26A0"}),testId:"queues-dlq-warning",variant:"warning",children:(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[A.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"font-medium",children:s("No dead-letter queue on {queues}.",{queues:A.map(Bt).join(", ")})}),(0,t.jsx)("p",{className:"text-muted-foreground",children:s("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),M>0&&(0,t.jsx)("p",{className:A.length>0?"text-muted-foreground":"font-medium",children:M===1?s("1 message was recently dead-lettered."):s("{count} messages were recently dead-lettered.",{count:M})})]})}),R;e[26]!==v||e[27]!==f||e[28]!==l?(R=l==="declared"&&(0,t.jsx)(wt,{loaded:f!==void 0,queues:v}),e[26]=v,e[27]=f,e[28]=l,e[29]=R):R=e[29];let J;e[30]!==E||e[31]!==y||e[32]!==Ce||e[33]!==we||e[34]!==he||e[35]!==l?(J=l==="messages"&&(0,t.jsx)(It,{hasError:y!==null,messages:E,onClear:Ce,onReplay:we,replayingId:he}),e[30]=E,e[31]=y,e[32]=Ce,e[33]=we,e[34]=he,e[35]=l,e[36]=J):J=e[36];let j;e[37]!==G||e[38]!==L||e[39]!==I||e[40]!==ve||e[41]!==be||e[42]!==qe||e[43]!==Ne||e[44]!==Se||e[45]!==v||e[46]!==K||e[47]!==pe||e[48]!==l?(j=l==="send"&&(0,t.jsx)(Qt,{batchMode:G,bodyText:L,delayText:I,onBatchModeChange:ve,onBodyChange:be,onDelayChange:qe,onSelectExport:Ne,onSend:Se,queues:v,selectedExportName:K,sending:pe}),e[37]=G,e[38]=L,e[39]=I,e[40]=ve,e[41]=be,e[42]=qe,e[43]=Ne,e[44]=Se,e[45]=v,e[46]=K,e[47]=pe,e[48]=l,e[49]=j):j=e[49];let oe;return e[50]!==k||e[51]!==O||e[52]!==Ie||e[53]!==R||e[54]!==J||e[55]!==j?(oe=(0,t.jsxs)("div",{className:dt,"data-testid":lt,children:[k,O,Ie,R,J,j]}),e[50]=k,e[51]=O,e[52]=Ie,e[53]=R,e[54]=J,e[55]=j,e[56]=oe):oe=e[56],oe},"es");function Et(n){return(0,t.jsx)(at,{queue:n},n.exportName)}c(Et,"Ct");function Mt(n){return(0,t.jsx)(at,{queue:n},n.exportName)}c(Mt,"vt");function At(n){return(0,t.jsx)("option",{value:n.exportName,children:n.exportName},n.exportName)}c(At,"wt");function Lt(n,e){return n.exportName.localeCompare(e.exportName)}c(Lt,"Qt");function Tt(n){return n.exportName}c(Tt,"At");function _t(n){return tt(n)}c(_t,"It");function Bt(n){return n.name}c(Bt,"Mt");export{Yt as default};
|
|
1
|
+
import{a as Ze}from"./chunk-ECY2JC5F.js";import"./chunk-NRP22GKC.js";import{a as Xe}from"./chunk-FPI7AMQJ.js";import{a as Ye}from"./chunk-JQXA2OYK.js";import"./chunk-UC7MNI2F.js";import{a as Ve}from"./chunk-I23ULEUU.js";import{i as Pe}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as le}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as de}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as Ke}from"./chunk-ARXLF43Z.js";import{a as He}from"./chunk-NCPW7WHO.js";import"./chunk-VA2K2MGN.js";import"./chunk-55UGUCQ6.js";import{a as W}from"./chunk-4ZEL6BYL.js";import{c as Le}from"./chunk-C4ZPJ4KT.js";import{l as ze}from"./chunk-DTFIEXYN.js";import"./chunk-QAQDMS6R.js";import"./chunk-WS7WNXF3.js";import{a as ie}from"./chunk-RWVIV3U7.js";import{a as Te,b as _e,c as Be,d as z,e as C,f as w}from"./chunk-HCTJKP5J.js";import{a as Me,e as Ae}from"./chunk-2IKDEUCX.js";import{d as F,f as ce,g as ue,h as H,m as Ue,p as me,t as Ge}from"./chunk-5OMZCVRF.js";import{a as c,d as Ee,e as ct,f as ut,g as mt}from"./chunk-I26MS5PJ.js";var D=Ee(ut(),1);var Q=Ee(ct(),1);var t=Ee(mt(),1);var pt=c((n,e)=>{let a=new Set(n.map(s=>s.deadLetterQueue).filter(s=>typeof s=="string"&&s!=="")),d=n.filter(s=>(s.deadLetterQueue===void 0||s.deadLetterQueue==="")&&!a.has(s.name)),r=e.filter(s=>s.deadLettered).length;return{deadLetteredCount:r,queuesWithoutDlq:d,showReliabilityWarning:d.length>0||r>0}},"ut"),De="topic:",$e=c(n=>{let e=[],a=new Map;for(let d of n)d.topic===void 0?e.push(d):a.set(d.topic,[...a.get(d.topic)??[],d]);return{plain:e,topics:a}},"Ae"),tt=c(n=>`${De}${n}`,"We"),ht=c((n,e)=>n.startsWith(De)?(e.get(n.slice(De.length))??[]).map(a=>a.exportName):[n],"mt"),gt=200,ft=ce(W.sendQueueMessage),xt=c(async(n,e,a)=>{let d=(await Promise.allSettled(e.map(async s=>n.query(ft,s,ue(""))))).flatMap((s,l)=>s.status==="rejected"?[{exportName:e[l]?.exportName??"",message:H(s.reason)}]:[]),[r]=d;return r===void 0?null:e.length===1?r.message:a("Not sent to {failed}",{failed:d.map(s=>`${s.exportName}: ${s.message}`).join("; ")})},"ht"),yt=ce(W.replayQueueMessage),Nt=ce(W.clearQueueMessages),et=96,bt=c(n=>{if(n===void 0)return"\u2014";try{return JSON.stringify(n,Ue)}catch{return"[unserializable]"}},"yt"),qt=c(n=>n.length>et?`${n.slice(0,et)}\u2026`:n,"bt"),vt=c(n=>n==="error"?"destructive":n==="retry"?"outline":"secondary","Nt"),St=c((n,e)=>e(n==="messages"?"Messages":n==="send"?"Send":"Declared"),"qt"),at=c(n=>{let e=(0,D.c)(17),{queue:a}=n,d=`queues-row-${a.exportName}`,r;e[0]!==a.exportName?(r=(0,t.jsx)(w,{className:"font-mono text-xs",children:a.exportName}),e[0]=a.exportName,e[1]=r):r=e[1];let s;e[2]!==a.name?(s=(0,t.jsx)(w,{className:"font-mono text-xs text-muted-foreground",children:a.name}),e[2]=a.name,e[3]=s):s=e[3];let l;e[4]!==a.mode?(l=(0,t.jsx)(w,{className:"font-mono text-xs text-muted-foreground",children:a.mode}),e[4]=a.mode,e[5]=l):l=e[5];let o;e[6]!==a.binding?(o=(0,t.jsx)(w,{className:"font-mono text-xs text-muted-foreground",children:a.binding}),e[6]=a.binding,e[7]=o):o=e[7];let m=a.deadLetterQueue??"\u2014",i;e[8]!==m?(i=(0,t.jsx)(w,{className:"font-mono text-xs text-muted-foreground",children:m}),e[8]=m,e[9]=i):i=e[9];let p;return e[10]!==d||e[11]!==r||e[12]!==s||e[13]!==l||e[14]!==o||e[15]!==i?(p=(0,t.jsxs)(z,{"data-testid":d,children:[r,s,l,o,i]}),e[10]=d,e[11]=r,e[12]=s,e[13]=l,e[14]=o,e[15]=i,e[16]=p):p=e[16],p},"Ge"),wt=c(n=>{let e=(0,D.c)(8),{loaded:a,queues:d}=n,r=F(),s;if(e[0]!==a||e[1]!==d||e[2]!==r){let{plain:l,topics:o}=$e(d),m;e[4]!==r?(m=r("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[4]=r,e[5]=m):m=e[5];let i;e[6]!==m?(i=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:m}),e[6]=m,e[7]=i):i=e[7],s=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[i,a&&d.length===0?(0,t.jsx)(ie,{description:r("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:r("No queues defined")}):(0,t.jsx)(Me,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ae,{className:"px-0",children:(0,t.jsxs)(Te,{"data-testid":"queues-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(z,{children:[(0,t.jsx)(C,{children:r("Export")}),(0,t.jsx)(C,{children:r("Queue")}),(0,t.jsx)(C,{children:r("Mode")}),(0,t.jsx)(C,{children:r("Binding")}),(0,t.jsx)(C,{children:r("Dead-letter")})]})}),(0,t.jsxs)(Be,{children:[l.map(Et),[...o].map(p=>{let[f,x]=p;return(0,t.jsxs)(Q.Fragment,{children:[(0,t.jsx)(z,{className:"bg-muted/40","data-testid":`queues-topic-${f}`,children:(0,t.jsx)(w,{className:"text-xs font-medium",colSpan:5,children:r("Topic {topic} \xB7 {count} subscriptions",{count:x.length,topic:f})})}),x.map(Mt)]},f)})]})]})})})]}),e[0]=a,e[1]=d,e[2]=r,e[3]=s}else s=e[3];return s},"St"),Ct=c(n=>{let e=(0,D.c)(67),{message:a,onReplay:d,replayingId:r}=n,s=F(),l,o,m,i,p,f,x,u,h,N;if(e[0]!==a.attempts||e[1]!==a.body||e[2]!==a.deadLettered||e[3]!==a.exportName||e[4]!==a.id||e[5]!==a.messageId||e[6]!==a.outcome||e[7]!==a.queue||e[8]!==s){let P=bt(a.body);o=z,f=`queues-message-${a.id}`;let U=a.exportName??a.queue;e[19]!==U?(x=(0,t.jsx)(w,{className:"font-mono text-xs",children:U}),e[19]=U,e[20]=x):x=e[20],e[21]!==a.messageId?(u=(0,t.jsx)(w,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:a.messageId,children:a.messageId}),e[21]=a.messageId,e[22]=u):u=e[22],e[23]!==a.attempts?(h=(0,t.jsx)(w,{className:"font-mono text-xs tabular-nums",children:a.attempts}),e[23]=a.attempts,e[24]=h):h=e[24];let L=`queues-outcome-${a.id}`,T;e[25]!==a.outcome?(T=vt(a.outcome),e[25]=a.outcome,e[26]=T):T=e[26];let I;e[27]!==a.outcome||e[28]!==L||e[29]!==T?(I=(0,t.jsx)(de,{"data-testid":L,variant:T,children:a.outcome}),e[27]=a.outcome,e[28]=L,e[29]=T,e[30]=I):I=e[30];let _;e[31]!==a.deadLettered||e[32]!==a.id||e[33]!==s?(_=a.deadLettered&&(0,t.jsx)(de,{"data-testid":`queues-dlq-${a.id}`,variant:"destructive",children:s("DLQ")}),e[31]=a.deadLettered,e[32]=a.id,e[33]=s,e[34]=_):_=e[34],e[35]!==I||e[36]!==_?(N=(0,t.jsx)(w,{children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-1",children:[I,_]})}),e[35]=I,e[36]=_,e[37]=N):N=e[37],l=w,m="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",i=P,p=qt(P),e[0]=a.attempts,e[1]=a.body,e[2]=a.deadLettered,e[3]=a.exportName,e[4]=a.id,e[5]=a.messageId,e[6]=a.outcome,e[7]=a.queue,e[8]=s,e[9]=l,e[10]=o,e[11]=m,e[12]=i,e[13]=p,e[14]=f,e[15]=x,e[16]=u,e[17]=h,e[18]=N}else l=e[9],o=e[10],m=e[11],i=e[12],p=e[13],f=e[14],x=e[15],u=e[16],h=e[17],N=e[18];let y;e[38]!==l||e[39]!==m||e[40]!==i||e[41]!==p?(y=(0,t.jsx)(l,{className:m,title:i,children:p}),e[38]=l,e[39]=m,e[40]=i,e[41]=p,e[42]=y):y=e[42];let q;e[43]!==a.capturedAt?(q=Ge(a.capturedAt,"\u2014"),e[43]=a.capturedAt,e[44]=q):q=e[44];let b;e[45]!==q?(b=(0,t.jsx)(w,{className:"text-xs text-muted-foreground tabular-nums",children:q}),e[45]=q,e[46]=b):b=e[46];let v=`queues-replay-${a.id}`,E=r!==null,M;e[47]!==a.id||e[48]!==r||e[49]!==s?(M=r===a.id?s("Replaying\u2026"):s("Replay"),e[47]=a.id,e[48]=r,e[49]=s,e[50]=M):M=e[50];let A;e[51]!==a.id||e[52]!==d||e[53]!==v||e[54]!==E||e[55]!==M?(A=(0,t.jsx)(w,{children:(0,t.jsx)(le,{"data-id":a.id,"data-testid":v,disabled:E,onClick:d,size:"xs",type:"button",variant:"outline",children:M})}),e[51]=a.id,e[52]=d,e[53]=v,e[54]=E,e[55]=M,e[56]=A):A=e[56];let $;return e[57]!==o||e[58]!==b||e[59]!==A||e[60]!==f||e[61]!==x||e[62]!==u||e[63]!==h||e[64]!==N||e[65]!==y?($=(0,t.jsxs)(o,{"data-testid":f,children:[x,u,h,N,y,b,A]}),e[57]=o,e[58]=b,e[59]=A,e[60]=f,e[61]=x,e[62]=u,e[63]=h,e[64]=N,e[65]=y,e[66]=$):$=e[66],$},"Et"),It=c(n=>{let e=(0,D.c)(29),{hasError:a,messages:d,onClear:r,onReplay:s,replayingId:l}=n,o=F(),m;e[0]!==o?(m=o("Cloudflare Queues have no peek API, so this is what push consumers actually processed \u2014 not pending depth."),e[0]=o,e[1]=m):m=e[1];let i;e[2]!==m?(i=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:m}),e[2]=m,e[3]=i):i=e[3];let p;e[4]!==o?(p=o("Clear the whole message log?"),e[4]=o,e[5]=p):p=e[5];let f=d.length===0,x;e[6]!==o?(x=o("Clear log"),e[6]=o,e[7]=x):x=e[7];let u;e[8]!==r||e[9]!==p||e[10]!==f||e[11]!==x?(u=(0,t.jsx)("div",{className:"ml-auto",children:(0,t.jsx)(Ve,{confirmLabel:p,disabled:f,onConfirm:r,testId:"queues-clear",children:x})}),e[8]=r,e[9]=p,e[10]=f,e[11]=x,e[12]=u):u=e[12];let h;e[13]!==d.length||e[14]!==o?(h=d.length>0&&(0,t.jsx)(de,{"data-testid":"queues-count",variant:"secondary",children:o("{count} messages",{count:d.length})}),e[13]=d.length,e[14]=o,e[15]=h):h=e[15];let N;e[16]!==i||e[17]!==u||e[18]!==h?(N=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[i,u,h]}),e[16]=i,e[17]=u,e[18]=h,e[19]=N):N=e[19];let y;e[20]!==a||e[21]!==d||e[22]!==s||e[23]!==l||e[24]!==o?(y=!a&&d.length===0?(0,t.jsx)(ie,{description:o("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:o("No consumed messages yet.")}):(0,t.jsx)(Me,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ae,{className:"px-0",children:(0,t.jsx)(Ze,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:(0,t.jsxs)(Te,{"data-testid":"queues-messages-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(z,{children:[(0,t.jsx)(C,{children:o("Export")}),(0,t.jsx)(C,{children:o("Message")}),(0,t.jsx)(C,{children:o("Attempts")}),(0,t.jsx)(C,{children:o("Outcome")}),(0,t.jsx)(C,{children:o("Body")}),(0,t.jsx)(C,{children:o("Captured")}),(0,t.jsx)(C,{})]})}),(0,t.jsx)(Be,{children:d.map(b=>(0,t.jsx)(Ct,{message:b,onReplay:s,replayingId:l},b.id))})]})})})}),e[20]=a,e[21]=d,e[22]=s,e[23]=l,e[24]=o,e[25]=y):y=e[25];let q;return e[26]!==N||e[27]!==y?(q=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[N,y]}),e[26]=N,e[27]=y,e[28]=q):q=e[28],q},"Tt"),Qt=c(n=>{let e=(0,D.c)(20),{batchMode:a,bodyText:d,delayText:r,onBatchModeChange:s,onBodyChange:l,onDelayChange:o,onSelectExport:m,onSend:i,queues:p,selectedExportName:f,sending:x}=n,u=F(),h;e[0]!==u?(h=u("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=u,e[1]=h):h=e[1];let N;e[2]!==h?(N=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:h}),e[2]=h,e[3]=N):N=e[3];let y;e[4]!==a||e[5]!==d||e[6]!==r||e[7]!==s||e[8]!==l||e[9]!==o||e[10]!==m||e[11]!==i||e[12]!==p||e[13]!==f||e[14]!==x||e[15]!==u?(y=p.length===0?(0,t.jsx)(ie,{description:u("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:u("No queues to send to")}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("select",{"aria-label":u("Queue"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"queues-send-select",onChange:m,value:f,children:[p.map(At),[...$e(p).topics].map(b=>{let[v,E]=b;return(0,t.jsx)("option",{value:tt(v),children:u("{topic} (topic \u2192 {count} subscriptions)",{count:E.length,topic:v})},v)})]}),(0,t.jsx)(Pe,{"aria-label":u("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:o,placeholder:u("Delay (s)"),type:"number",value:r}),(0,t.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[(0,t.jsx)("input",{checked:a,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:s,type:"checkbox"}),u("Send as batch (JSON array)")]}),(0,t.jsx)(le,{className:"ml-auto","data-testid":"queues-send-button",disabled:x||f==="",onClick:i,type:"button",children:u(x?"Sending\u2026":"Send message")})]}),(0,t.jsx)(Xe,{"aria-label":u("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:l,placeholder:a?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:d})]}),e[4]=a,e[5]=d,e[6]=r,e[7]=s,e[8]=l,e[9]=o,e[10]=m,e[11]=i,e[12]=p,e[13]=f,e[14]=x,e[15]=u,e[16]=y):y=e[16];let q;return e[17]!==N||e[18]!==y?(q=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[N,y]}),e[17]=N,e[18]=y,e[19]=q):q=e[19],q},"_t"),Yt=c(n=>{let e=(0,D.c)(57),{limit:a}=n,d=a??gt,r=ze(),s=F(),[l,o]=(0,Q.useState)("declared"),[m,i]=(0,Q.useState)(null),p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let{data:f,error:x,errorSource:u}=Le(W.listQueues,p),h;e[1]!==d?(h={limit:d},e[1]=d,e[2]=h):h=e[2];let{data:N,error:y,errorSource:q,refetch:b}=Le(W.getQueueMessages,h),v=Array.isArray(f?.queues)?[...f.queues].toSorted(Lt):[],E=N?.entries??[],{deadLetteredCount:M,queuesWithoutDlq:A,showReliabilityWarning:$}=pt(v,E),[P,U]=(0,Q.useState)(""),[L,T]=(0,Q.useState)(""),[I,_]=(0,Q.useState)(""),[G,st]=(0,Q.useState)(!1),[pe,ke]=(0,Q.useState)(!1),[he,Oe]=(0,Q.useState)(null),{topics:Re}=$e(v),Je=[...v.map(Tt),...[...Re.keys()].map(_t)],K=Je.includes(P)?P:Je[0]??"",je=l==="messages"?y:x,nt=l==="messages"?q:u,ge=je??m,fe=je===null?m:nt,V;e[3]!==b?(V=c(()=>{b()},"V"),e[3]=b,e[4]=V):V=e[4],Ye(V,l==="messages");let rt=c(async()=>{i(null);let g=K;if(g==="")return;let S=null,Fe=L.trim();if(Fe!=="")try{S=JSON.parse(Fe)}catch{i(s("Body must be valid JSON."));return}let Qe,We=I.trim();if(We!==""){let B=Number(We);if(!Number.isFinite(B)||B<0){i(s("Delay must be a non-negative number of seconds."));return}Qe=B}if(G&&!Array.isArray(S)){i(s("Batch mode needs a JSON array body \u2014 each element is enqueued as one message."));return}ke(!0);let it=ht(g,Re).map(B=>G?{batch:S,delaySeconds:Qe,exportName:B}:{body:S,delaySeconds:Qe,exportName:B});try{i(await xt(r,it,s)),b()}catch(B){i(H(B))}ke(!1)},"Ve"),X;e[5]!==r||e[6]!==b?(X=c(async g=>{i(null),Oe(g);try{await r.query(yt,{id:g},ue("")),b()}catch(S){i(H(S))}Oe(null)},"X"),e[5]=r,e[6]=b,e[7]=X):X=e[7];let xe=X,Y;e[8]!==r||e[9]!==b?(Y=c(async()=>{i(null);try{await r.query(Nt,{},ue("")),b()}catch(g){i(H(g))}},"Y"),e[8]=r,e[9]=b,e[10]=Y):Y=e[10];let ye=Y,Z;e[11]===Symbol.for("react.memo_cache_sentinel")?(Z=c(g=>{let S=g.currentTarget.dataset.tab;(S==="declared"||S==="messages"||S==="send")&&o(S)},"K"),e[11]=Z):Z=e[11];let ot=Z,ee;e[12]===Symbol.for("react.memo_cache_sentinel")?(ee=c(g=>{U(g.currentTarget.value)},"Z"),e[12]=ee):ee=e[12];let Ne=ee,te;e[13]===Symbol.for("react.memo_cache_sentinel")?(te=c(g=>{T(g.currentTarget.value)},"ee"),e[13]=te):te=e[13];let be=te,ae;e[14]===Symbol.for("react.memo_cache_sentinel")?(ae=c(g=>{_(g.currentTarget.value)},"te"),e[14]=ae):ae=e[14];let qe=ae,se;e[15]===Symbol.for("react.memo_cache_sentinel")?(se=c(g=>{st(g.currentTarget.checked)},"se"),e[15]=se):se=e[15];let ve=se,Se=c(()=>{me(rt())},"xe"),ne;e[16]!==xe?(ne=c(g=>{let{id:S}=g.currentTarget.dataset;S!==void 0&&me(xe(S))},"ae"),e[16]=xe,e[17]=ne):ne=e[17];let we=ne,re;e[18]!==ye?(re=c(()=>{me(ye())},"re"),e[18]=ye,e[19]=re):re=e[19];let Ce=re,dt="flex flex-col gap-6",lt="lunora-queues-panel",k;e[20]!==s||e[21]!==l?(k=(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(g=>(0,t.jsx)(le,{"aria-selected":l===g,"data-tab":g,"data-testid":`queues-tab-${g}`,onClick:ot,role:"tab",size:"sm",type:"button",variant:l===g?"secondary":"ghost",children:St(g,s)},g))}),e[20]=s,e[21]=l,e[22]=k):k=e[22];let O;e[23]!==ge||e[24]!==fe?(O=ge!==null&&(0,t.jsx)(Ke,{error:fe,testId:"queues-error"}),e[23]=ge,e[24]=fe,e[25]=O):O=e[25];let Ie=$&&(0,t.jsx)(He,{icon:(0,t.jsx)("span",{"aria-hidden":"true",className:"text-base leading-none",children:"\u26A0"}),testId:"queues-dlq-warning",variant:"warning",children:(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[A.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"font-medium",children:s("No dead-letter queue on {queues}.",{queues:A.map(Bt).join(", ")})}),(0,t.jsx)("p",{className:"text-muted-foreground",children:s("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),M>0&&(0,t.jsx)("p",{className:A.length>0?"text-muted-foreground":"font-medium",children:M===1?s("1 message was recently dead-lettered."):s("{count} messages were recently dead-lettered.",{count:M})})]})}),R;e[26]!==v||e[27]!==f||e[28]!==l?(R=l==="declared"&&(0,t.jsx)(wt,{loaded:f!==void 0,queues:v}),e[26]=v,e[27]=f,e[28]=l,e[29]=R):R=e[29];let J;e[30]!==E||e[31]!==y||e[32]!==Ce||e[33]!==we||e[34]!==he||e[35]!==l?(J=l==="messages"&&(0,t.jsx)(It,{hasError:y!==null,messages:E,onClear:Ce,onReplay:we,replayingId:he}),e[30]=E,e[31]=y,e[32]=Ce,e[33]=we,e[34]=he,e[35]=l,e[36]=J):J=e[36];let j;e[37]!==G||e[38]!==L||e[39]!==I||e[40]!==ve||e[41]!==be||e[42]!==qe||e[43]!==Ne||e[44]!==Se||e[45]!==v||e[46]!==K||e[47]!==pe||e[48]!==l?(j=l==="send"&&(0,t.jsx)(Qt,{batchMode:G,bodyText:L,delayText:I,onBatchModeChange:ve,onBodyChange:be,onDelayChange:qe,onSelectExport:Ne,onSend:Se,queues:v,selectedExportName:K,sending:pe}),e[37]=G,e[38]=L,e[39]=I,e[40]=ve,e[41]=be,e[42]=qe,e[43]=Ne,e[44]=Se,e[45]=v,e[46]=K,e[47]=pe,e[48]=l,e[49]=j):j=e[49];let oe;return e[50]!==k||e[51]!==O||e[52]!==Ie||e[53]!==R||e[54]!==J||e[55]!==j?(oe=(0,t.jsxs)("div",{className:dt,"data-testid":lt,children:[k,O,Ie,R,J,j]}),e[50]=k,e[51]=O,e[52]=Ie,e[53]=R,e[54]=J,e[55]=j,e[56]=oe):oe=e[56],oe},"es");function Et(n){return(0,t.jsx)(at,{queue:n},n.exportName)}c(Et,"Ct");function Mt(n){return(0,t.jsx)(at,{queue:n},n.exportName)}c(Mt,"vt");function At(n){return(0,t.jsx)("option",{value:n.exportName,children:n.exportName},n.exportName)}c(At,"wt");function Lt(n,e){return n.exportName.localeCompare(e.exportName)}c(Lt,"Qt");function Tt(n){return n.exportName}c(Tt,"At");function _t(n){return tt(n)}c(_t,"It");function Bt(n){return n.name}c(Bt,"Mt");export{Yt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as wt}from"./chunk-FPI7AMQJ.js";import{a as Tt}from"./chunk-AKHBJSQO.js";import{a as se}from"./chunk-2G3B5PAO.js";import{a as $t}from"./chunk-QJLHH3ET.js";import{a as Ot}from"./chunk-37WYCOQ2.js";import{a as zt,b as _t}from"./chunk-OMN44W6V.js";import"./chunk-VASJTDMU.js";import{a as kt}from"./chunk-JQXA2OYK.js";import{i as V}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as j}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import"./chunk-BOMPSVRC.js";import{b as ge}from"./chunk-PYNRIX74.js";import{l as oe}from"./chunk-BDYCZHD2.js";import"./chunk-QAQDMS6R.js";import"./chunk-WS7WNXF3.js";import{a as ue}from"./chunk-RWVIV3U7.js";import{a as Ct,b as It,c as xt,d as Ve,e as me,f as de}from"./chunk-HCTJKP5J.js";import{a as vt,e as yt}from"./chunk-2IKDEUCX.js";import{d as Q,h as Nt,o as A,p as At,t as Dt}from"./chunk-5OMZCVRF.js";import{a as c,d as pt,e as Jt,f as Ut,g as Ht}from"./chunk-I26MS5PJ.js";var H=pt(Ut(),1);var F=pt(Jt(),1);var a=pt(Ht(),1);var Lt=c(t=>{let e=JSON.parse(t);if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("Expected a JSON object");return e},"Tt"),Kt=c(t=>{let e=Lt(t),r={};for(let[d,h]of Object.entries(e)){if(!Array.isArray(h)||h.some(i=>typeof i!="string"))throw new TypeError(`"${d}" must map to an array of action strings`);r[d]=h}return r},"Qt"),Pt=c(t=>t==null||t===""?"":typeof t=="string"?t:JSON.stringify(t,null,2),"$t"),G=c(t=>{let e=(0,H.c)(6),{children:r,htmlFor:d,label:h}=t,i;e[0]!==d||e[1]!==h?(i=(0,a.jsx)(Ot,{htmlFor:d,children:h}),e[0]=d,e[1]=h,e[2]=i):i=e[2];let o;return e[3]!==r||e[4]!==i?(o=(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[i,r]}),e[3]=r,e[4]=i,e[5]=o):o=e[5],o},"V"),ce=c(({busy:t,canSubmit:e,children:r,destructive:d=!1,error:h,onClose:i,onSubmit:o,submitLabel:l,testId:n,title:m})=>{let s=Q();return(0,a.jsxs)($t,{label:m,onClose:i,panelTestId:`${n}-panel`,testId:`${n}-overlay`,variant:"dialog",children:[(0,a.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:m}),r,h!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":`${n}-error`,role:"alert",children:h}),(0,a.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[(0,a.jsx)(j,{"data-testid":`${n}-cancel`,onClick:i,size:"sm",type:"button",variant:"outline",children:s("Cancel")}),(0,a.jsx)(j,{"data-testid":`${n}-submit`,disabled:t||!e,onClick:o,size:"sm",type:"button",variant:d?"destructive":"default",children:t?s("Saving\u2026"):l})]})]})},"me"),Rt=c(t=>{let e=(0,H.c)(79),{mode:r,onClose:d,onDone:h,org:i}=t,o=oe(),l=Q(),{busy:n,error:m,run:s}=se(),f;e[0]!==i?(f=i?A(i.name):"",e[0]=i,e[1]=f):f=e[1];let[u,b]=(0,F.useState)(f),v;e[2]!==i?(v=i?A(i.slug):"",e[2]=i,e[3]=v):v=e[3];let[g,p]=(0,F.useState)(v),k;e[4]!==i?(k=i?A(i.logo):"",e[4]=i,e[5]=k):k=e[5];let[y,I]=(0,F.useState)(k),[C,w]=(0,F.useState)(""),x;e[6]!==r||e[7]!==i?.metadata?(x=r==="edit"?Pt(i?.metadata):"",e[6]=r,e[7]=i?.metadata,e[8]=x):x=e[8];let[z,N]=(0,F.useState)(x),_;e[9]!==o||e[10]!==y||e[11]!==z||e[12]!==r||e[13]!==u||e[14]!==d||e[15]!==h||e[16]!==i?.id||e[17]!==C||e[18]!==s||e[19]!==g?(_=c(()=>{s(async()=>{let S=z.trim()===""?void 0:Lt(z);r==="create"?await o.createAuthOrganization({logo:y.trim()===""?void 0:y.trim(),metadata:S,name:u.trim(),ownerId:C.trim()===""?void 0:C.trim(),slug:g.trim()===""?void 0:g.trim()}):await o.updateAuthOrganization({logo:y.trim()===""?void 0:y.trim(),metadata:S,name:u.trim()===""?void 0:u.trim(),organizationId:A(i?.id),slug:g.trim()===""?void 0:g.trim()}),h(),d()})},"O"),e[9]=o,e[10]=y,e[11]=z,e[12]=r,e[13]=u,e[14]=d,e[15]=h,e[16]=i?.id,e[17]=C,e[18]=s,e[19]=g,e[20]=_):_=e[20];let D=_,O;e[21]!==r||e[22]!==u?(O=u.trim()!==""||r==="edit",e[21]=r,e[22]=u,e[23]=O):O=e[23];let T;e[24]!==r||e[25]!==l?(T=l(r==="create"?"Create":"Save"),e[24]=r,e[25]=l,e[26]=T):T=e[26];let $;e[27]!==r||e[28]!==l?($=l(r==="create"?"New organization":"Edit organization"),e[27]=r,e[28]=l,e[29]=$):$=e[29];let E;e[30]!==l?(E=l("name"),e[30]=l,e[31]=E):E=e[31];let Z;e[32]===Symbol.for("react.memo_cache_sentinel")?(Z=c(S=>{b(S.target.value)},"H"),e[32]=Z):Z=e[32];let B;e[33]!==u?(B=(0,a.jsx)(V,{"data-testid":"org-form-name",id:"org-form-name",onChange:Z,value:u}),e[33]=u,e[34]=B):B=e[34];let K;e[35]!==B||e[36]!==E?(K=(0,a.jsx)(G,{htmlFor:"org-form-name",label:E,children:B}),e[35]=B,e[36]=E,e[37]=K):K=e[37];let J;e[38]!==l?(J=l("Slug (optional \u2014 derived from name)"),e[38]=l,e[39]=J):J=e[39];let P;e[40]===Symbol.for("react.memo_cache_sentinel")?(P=c(S=>{p(S.target.value)},"P"),e[40]=P):P=e[40];let U;e[41]!==g?(U=(0,a.jsx)(V,{"data-testid":"org-form-slug",id:"org-form-slug",onChange:P,value:g}),e[41]=g,e[42]=U):U=e[42];let L;e[43]!==J||e[44]!==U?(L=(0,a.jsx)(G,{htmlFor:"org-form-slug",label:J,children:U}),e[43]=J,e[44]=U,e[45]=L):L=e[45];let Y;e[46]!==l?(Y=l("Logo URL (optional)"),e[46]=l,e[47]=Y):Y=e[47];let M;e[48]===Symbol.for("react.memo_cache_sentinel")?(M=c(S=>{I(S.target.value)},"M"),e[48]=M):M=e[48];let R;e[49]!==y?(R=(0,a.jsx)(V,{"data-testid":"org-form-logo",id:"org-form-logo",onChange:M,value:y}),e[49]=y,e[50]=R):R=e[50];let q;e[51]!==Y||e[52]!==R?(q=(0,a.jsx)(G,{htmlFor:"org-form-logo",label:Y,children:R}),e[51]=Y,e[52]=R,e[53]=q):q=e[53];let W;e[54]!==r||e[55]!==C||e[56]!==l?(W=r==="create"&&(0,a.jsx)(G,{htmlFor:"org-form-owner",label:l("Owner user id (optional)"),children:(0,a.jsx)(V,{"data-testid":"org-form-owner",id:"org-form-owner",onChange:c(S=>{w(S.target.value)},"onChange"),value:C})}),e[54]=r,e[55]=C,e[56]=l,e[57]=W):W=e[57];let te;e[58]!==l?(te=l("Metadata (JSON, optional)"),e[58]=l,e[59]=te):te=e[59];let ae;e[60]===Symbol.for("react.memo_cache_sentinel")?(ae=c(S=>{N(S.target.value)},"oe"),e[60]=ae):ae=e[60];let re;e[61]!==z?(re=(0,a.jsx)(wt,{"data-testid":"org-form-metadata",id:"org-form-metadata",onChange:ae,value:z}),e[61]=z,e[62]=re):re=e[62];let ee;e[63]!==te||e[64]!==re?(ee=(0,a.jsx)(G,{htmlFor:"org-form-metadata",label:te,children:re}),e[63]=te,e[64]=re,e[65]=ee):ee=e[65];let le;return e[66]!==n||e[67]!==m||e[68]!==d||e[69]!==D||e[70]!==K||e[71]!==L||e[72]!==q||e[73]!==W||e[74]!==ee||e[75]!==O||e[76]!==T||e[77]!==$?(le=(0,a.jsxs)(ce,{busy:n,canSubmit:O,error:m,onClose:d,onSubmit:D,submitLabel:T,testId:"org-form",title:$,children:[K,L,q,W,ee]}),e[66]=n,e[67]=m,e[68]=d,e[69]=D,e[70]=K,e[71]=L,e[72]=q,e[73]=W,e[74]=ee,e[75]=O,e[76]=T,e[77]=$,e[78]=le):le=e[78],le},"yt"),Qt=c(t=>{let e=(0,H.c)(40),{onClose:r,onDone:d,organizationId:h}=t,i=oe(),o=Q(),{busy:l,error:n,run:m}=se(),[s,f]=(0,F.useState)(""),[u,b]=(0,F.useState)(""),v;e[0]!==i||e[1]!==r||e[2]!==d||e[3]!==h||e[4]!==u||e[5]!==m||e[6]!==s?(v=c(()=>{m(async()=>{await i.addAuthOrgMember({organizationId:h,role:u.trim()===""?void 0:u.trim(),userId:s.trim()}),d(),r()})},"p"),e[0]=i,e[1]=r,e[2]=d,e[3]=h,e[4]=u,e[5]=m,e[6]=s,e[7]=v):v=e[7];let g=v,p;e[8]!==s?(p=s.trim(),e[8]=s,e[9]=p):p=e[9];let k=p!=="",y;e[10]!==o?(y=o("Add member"),e[10]=o,e[11]=y):y=e[11];let I;e[12]!==o?(I=o("Add member"),e[12]=o,e[13]=I):I=e[13];let C;e[14]!==o?(C=o("User id"),e[14]=o,e[15]=C):C=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=c($=>{f($.target.value)},"I"),e[16]=w):w=e[16];let x;e[17]!==s?(x=(0,a.jsx)(V,{"data-testid":"org-add-member-user",id:"org-add-member-user",onChange:w,value:s}),e[17]=s,e[18]=x):x=e[18];let z;e[19]!==C||e[20]!==x?(z=(0,a.jsx)(G,{htmlFor:"org-add-member-user",label:C,children:x}),e[19]=C,e[20]=x,e[21]=z):z=e[21];let N;e[22]!==o?(N=o("Role (optional)"),e[22]=o,e[23]=N):N=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=c($=>{b($.target.value)},"O"),e[24]=_):_=e[24];let D;e[25]!==u?(D=(0,a.jsx)(V,{"data-testid":"org-add-member-role",id:"org-add-member-role",onChange:_,value:u}),e[25]=u,e[26]=D):D=e[26];let O;e[27]!==N||e[28]!==D?(O=(0,a.jsx)(G,{htmlFor:"org-add-member-role",label:N,children:D}),e[27]=N,e[28]=D,e[29]=O):O=e[29];let T;return e[30]!==l||e[31]!==n||e[32]!==r||e[33]!==g||e[34]!==O||e[35]!==k||e[36]!==y||e[37]!==I||e[38]!==z?(T=(0,a.jsxs)(ce,{busy:l,canSubmit:k,error:n,onClose:r,onSubmit:g,submitLabel:y,testId:"org-add-member",title:I,children:[z,O]}),e[30]=l,e[31]=n,e[32]=r,e[33]=g,e[34]=O,e[35]=k,e[36]=y,e[37]=I,e[38]=z,e[39]=T):T=e[39],T},"Jt"),Zt=c(t=>{let e=(0,H.c)(40),{onClose:r,onDone:d,organizationId:h}=t,i=oe(),o=Q(),{busy:l,error:n,run:m}=se(),[s,f]=(0,F.useState)(""),[u,b]=(0,F.useState)(""),v;e[0]!==i||e[1]!==s||e[2]!==r||e[3]!==d||e[4]!==h||e[5]!==u||e[6]!==m?(v=c(()=>{m(async()=>{await i.inviteAuthOrgMember({email:s.trim(),organizationId:h,role:u.trim()===""?void 0:u.trim()}),d(),r()})},"p"),e[0]=i,e[1]=s,e[2]=r,e[3]=d,e[4]=h,e[5]=u,e[6]=m,e[7]=v):v=e[7];let g=v,p;e[8]!==s?(p=s.trim(),e[8]=s,e[9]=p):p=e[9];let k=p!=="",y;e[10]!==o?(y=o("Send invitation"),e[10]=o,e[11]=y):y=e[11];let I;e[12]!==o?(I=o("Invite member"),e[12]=o,e[13]=I):I=e[13];let C;e[14]!==o?(C=o("email"),e[14]=o,e[15]=C):C=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=c($=>{f($.target.value)},"I"),e[16]=w):w=e[16];let x;e[17]!==s?(x=(0,a.jsx)(V,{"data-testid":"org-invite-member-email",id:"org-invite-member-email",onChange:w,type:"email",value:s}),e[17]=s,e[18]=x):x=e[18];let z;e[19]!==C||e[20]!==x?(z=(0,a.jsx)(G,{htmlFor:"org-invite-member-email",label:C,children:x}),e[19]=C,e[20]=x,e[21]=z):z=e[21];let N;e[22]!==o?(N=o("Role (optional)"),e[22]=o,e[23]=N):N=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=c($=>{b($.target.value)},"O"),e[24]=_):_=e[24];let D;e[25]!==u?(D=(0,a.jsx)(V,{"data-testid":"org-invite-member-role",id:"org-invite-member-role",onChange:_,value:u}),e[25]=u,e[26]=D):D=e[26];let O;e[27]!==N||e[28]!==D?(O=(0,a.jsx)(G,{htmlFor:"org-invite-member-role",label:N,children:D}),e[27]=N,e[28]=D,e[29]=O):O=e[29];let T;return e[30]!==l||e[31]!==n||e[32]!==r||e[33]!==g||e[34]!==O||e[35]!==k||e[36]!==y||e[37]!==I||e[38]!==z?(T=(0,a.jsxs)(ce,{busy:l,canSubmit:k,error:n,onClose:r,onSubmit:g,submitLabel:y,testId:"org-invite-member",title:I,children:[z,O]}),e[30]=l,e[31]=n,e[32]=r,e[33]=g,e[34]=O,e[35]=k,e[36]=y,e[37]=I,e[38]=z,e[39]=T):T=e[39],T},"Ut"),Yt=c(t=>{let e=(0,H.c)(32),{member:r,onClose:d,onDone:h}=t,i=oe(),o=Q(),{busy:l,error:n,run:m}=se(),s;e[0]!==r.role?(s=c(()=>A(r.role),"a"),e[0]=r.role,e[1]=s):s=e[1];let[f,u]=(0,F.useState)(s),b;e[2]!==i||e[3]!==r.id||e[4]!==d||e[5]!==h||e[6]!==f||e[7]!==m?(b=c(()=>{m(async()=>{await i.setAuthOrgMemberRole({memberId:A(r.id),role:f.trim()}),h(),d()})},"g"),e[2]=i,e[3]=r.id,e[4]=d,e[5]=h,e[6]=f,e[7]=m,e[8]=b):b=e[8];let v=b,g;e[9]!==f?(g=f.trim(),e[9]=f,e[10]=g):g=e[10];let p=g!=="",k;e[11]!==o?(k=o("Save"),e[11]=o,e[12]=k):k=e[12];let y;e[13]!==o?(y=o("Change member role"),e[13]=o,e[14]=y):y=e[14];let I;e[15]!==o?(I=o("Role"),e[15]=o,e[16]=I):I=e[16];let C;e[17]===Symbol.for("react.memo_cache_sentinel")?(C=c(N=>{u(N.target.value)},"y"),e[17]=C):C=e[17];let w;e[18]!==f?(w=(0,a.jsx)(V,{"data-testid":"org-member-role-value",id:"org-member-role-value",onChange:C,value:f}),e[18]=f,e[19]=w):w=e[19];let x;e[20]!==I||e[21]!==w?(x=(0,a.jsx)(G,{htmlFor:"org-member-role-value",label:I,children:w}),e[20]=I,e[21]=w,e[22]=x):x=e[22];let z;return e[23]!==l||e[24]!==n||e[25]!==d||e[26]!==v||e[27]!==x||e[28]!==p||e[29]!==k||e[30]!==y?(z=(0,a.jsx)(ce,{busy:l,canSubmit:p,error:n,onClose:d,onSubmit:v,submitLabel:k,testId:"org-member-role",title:y,children:x}),e[23]=l,e[24]=n,e[25]=d,e[26]=v,e[27]=x,e[28]=p,e[29]=k,e[30]=y,e[31]=z):z=e[31],z},"Gt"),Mt=c(t=>{let e=(0,H.c)(36),{mode:r,onClose:d,onDone:h,organizationId:i,team:o}=t,l=oe(),n=Q(),{busy:m,error:s,run:f}=se(),u;e[0]!==o?(u=o?A(o.name):"",e[0]=o,e[1]=u):u=e[1];let[b,v]=(0,F.useState)(u),g;e[2]!==l||e[3]!==r||e[4]!==b||e[5]!==d||e[6]!==h||e[7]!==i||e[8]!==f||e[9]!==o?.id?(g=c(()=>{f(async()=>{await(r==="create"?l.createAuthOrgTeam({name:b.trim(),organizationId:i}):l.updateAuthOrgTeam({name:b.trim(),teamId:A(o?.id)})),h(),d()})},"f"),e[2]=l,e[3]=r,e[4]=b,e[5]=d,e[6]=h,e[7]=i,e[8]=f,e[9]=o?.id,e[10]=g):g=e[10];let p=g,k;e[11]!==b?(k=b.trim(),e[11]=b,e[12]=k):k=e[12];let y=k!=="",I;e[13]!==r||e[14]!==n?(I=n(r==="create"?"Create":"Save"),e[13]=r,e[14]=n,e[15]=I):I=e[15];let C;e[16]!==r||e[17]!==n?(C=n(r==="create"?"New team":"Rename team"),e[16]=r,e[17]=n,e[18]=C):C=e[18];let w;e[19]!==n?(w=n("name"),e[19]=n,e[20]=w):w=e[20];let x;e[21]===Symbol.for("react.memo_cache_sentinel")?(x=c(D=>{v(D.target.value)},"x"),e[21]=x):x=e[21];let z;e[22]!==b?(z=(0,a.jsx)(V,{"data-testid":"org-team-form-name",id:"org-team-form-name",onChange:x,value:b}),e[22]=b,e[23]=z):z=e[23];let N;e[24]!==w||e[25]!==z?(N=(0,a.jsx)(G,{htmlFor:"org-team-form-name",label:w,children:z}),e[24]=w,e[25]=z,e[26]=N):N=e[26];let _;return e[27]!==m||e[28]!==s||e[29]!==d||e[30]!==p||e[31]!==N||e[32]!==y||e[33]!==I||e[34]!==C?(_=(0,a.jsx)(ce,{busy:m,canSubmit:y,error:s,onClose:d,onSubmit:p,submitLabel:I,testId:"org-team-form",title:C,children:N}),e[27]=m,e[28]=s,e[29]=d,e[30]=p,e[31]=N,e[32]=y,e[33]=I,e[34]=C,e[35]=_):_=e[35],_},"Ct"),qt=c(t=>{let e=(0,H.c)(30),{onClose:r,onDone:d,teamId:h}=t,i=oe(),o=Q(),{busy:l,error:n,run:m}=se(),[s,f]=(0,F.useState)(""),u;e[0]!==i||e[1]!==r||e[2]!==d||e[3]!==m||e[4]!==h||e[5]!==s?(u=c(()=>{m(async()=>{await i.addAuthOrgTeamMember({teamId:h,userId:s.trim()}),d(),r()})},"c"),e[0]=i,e[1]=r,e[2]=d,e[3]=m,e[4]=h,e[5]=s,e[6]=u):u=e[6];let b=u,v;e[7]!==s?(v=s.trim(),e[7]=s,e[8]=v):v=e[8];let g=v!=="",p;e[9]!==o?(p=o("Add member"),e[9]=o,e[10]=p):p=e[10];let k;e[11]!==o?(k=o("Add team member"),e[11]=o,e[12]=k):k=e[12];let y;e[13]!==o?(y=o("User id"),e[13]=o,e[14]=y):y=e[14];let I;e[15]===Symbol.for("react.memo_cache_sentinel")?(I=c(z=>{f(z.target.value)},"C"),e[15]=I):I=e[15];let C;e[16]!==s?(C=(0,a.jsx)(V,{"data-testid":"org-team-add-member-user",id:"org-team-add-member-user",onChange:I,value:s}),e[16]=s,e[17]=C):C=e[17];let w;e[18]!==y||e[19]!==C?(w=(0,a.jsx)(G,{htmlFor:"org-team-add-member-user",label:y,children:C}),e[18]=y,e[19]=C,e[20]=w):w=e[20];let x;return e[21]!==l||e[22]!==n||e[23]!==r||e[24]!==b||e[25]!==g||e[26]!==p||e[27]!==k||e[28]!==w?(x=(0,a.jsx)(ce,{busy:l,canSubmit:g,error:n,onClose:r,onSubmit:b,submitLabel:p,testId:"org-team-add-member",title:k,children:w}),e[21]=l,e[22]=n,e[23]=r,e[24]=b,e[25]=g,e[26]=p,e[27]=k,e[28]=w,e[29]=x):x=e[29],x},"Ht"),Ft=c(t=>{let e=(0,H.c)(47),{mode:r,onClose:d,onDone:h,organizationId:i,role:o}=t,l=oe(),n=Q(),{busy:m,error:s,run:f}=se(),u;e[0]!==o?(u=o?A(o.role):"",e[0]=o,e[1]=u):u=e[1];let[b,v]=(0,F.useState)(u),g;e[2]!==r||e[3]!==o?.permission?(g=r==="edit"?Pt(o?.permission):"",e[2]=r,e[3]=o?.permission,e[4]=g):g=e[4];let[p,k]=(0,F.useState)(g),y;e[5]!==l||e[6]!==r||e[7]!==b||e[8]!==d||e[9]!==h||e[10]!==i||e[11]!==p||e[12]!==o?.id||e[13]!==f?(y=c(()=>{f(async()=>{let $=Kt(p);await(r==="create"?l.createAuthOrgRole({organizationId:i,permission:$,role:b.trim()}):l.updateAuthOrgRole({permission:$,roleId:A(o?.id)})),h(),d()})},"v"),e[5]=l,e[6]=r,e[7]=b,e[8]=d,e[9]=h,e[10]=i,e[11]=p,e[12]=o?.id,e[13]=f,e[14]=y):y=e[14];let I=y,C;e[15]!==r||e[16]!==b||e[17]!==p?(C=p.trim()!==""&&(r==="edit"||b.trim()!==""),e[15]=r,e[16]=b,e[17]=p,e[18]=C):C=e[18];let w;e[19]!==r||e[20]!==n?(w=n(r==="create"?"Create":"Save"),e[19]=r,e[20]=n,e[21]=w):w=e[21];let x;e[22]!==r||e[23]!==n?(x=n(r==="create"?"New role":"Edit role"),e[22]=r,e[23]=n,e[24]=x):x=e[24];let z;e[25]!==r||e[26]!==b||e[27]!==n?(z=r==="create"&&(0,a.jsx)(G,{htmlFor:"org-role-form-name",label:n("Role name"),children:(0,a.jsx)(V,{"data-testid":"org-role-form-name",id:"org-role-form-name",onChange:c($=>{v($.target.value)},"onChange"),value:b})}),e[25]=r,e[26]=b,e[27]=n,e[28]=z):z=e[28];let N;e[29]!==n?(N=n('Permission (JSON, e.g. {"project":["create","update"]})'),e[29]=n,e[30]=N):N=e[30];let _;e[31]===Symbol.for("react.memo_cache_sentinel")?(_=c($=>{k($.target.value)},"O"),e[31]=_):_=e[31];let D;e[32]!==p?(D=(0,a.jsx)(wt,{"data-testid":"org-role-form-permission",id:"org-role-form-permission",onChange:_,value:p}),e[32]=p,e[33]=D):D=e[33];let O;e[34]!==D||e[35]!==N?(O=(0,a.jsx)(G,{htmlFor:"org-role-form-permission",label:N,children:D}),e[34]=D,e[35]=N,e[36]=O):O=e[36];let T;return e[37]!==m||e[38]!==s||e[39]!==d||e[40]!==I||e[41]!==O||e[42]!==C||e[43]!==w||e[44]!==x||e[45]!==z?(T=(0,a.jsxs)(ce,{busy:m,canSubmit:C,error:s,onClose:d,onSubmit:I,submitLabel:w,testId:"org-role-form",title:x,children:[z,O]}),e[37]=m,e[38]=s,e[39]=d,e[40]=I,e[41]=O,e[42]=C,e[43]=w,e[44]=x,e[45]=z,e[46]=T):T=e[46],T},"xt"),Bt=c(t=>{let e=(0,H.c)(18),{action:r,message:d,onClose:h,onDone:i,testId:o,title:l}=t,n=Q(),{busy:m,error:s,run:f}=se(),u;e[0]!==r||e[1]!==h||e[2]!==i||e[3]!==f?(u=c(()=>{f(async()=>{await r(),i(),h()})},"c"),e[0]=r,e[1]=h,e[2]=i,e[3]=f,e[4]=u):u=e[4];let b=u,v;e[5]!==n?(v=n("Delete"),e[5]=n,e[6]=v):v=e[6];let g;e[7]!==d?(g=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:d}),e[7]=d,e[8]=g):g=e[8];let p;return e[9]!==m||e[10]!==s||e[11]!==h||e[12]!==b||e[13]!==v||e[14]!==g||e[15]!==o||e[16]!==l?(p=(0,a.jsx)(ce,{busy:m,canSubmit:!0,destructive:!0,error:s,onClose:h,onSubmit:b,submitLabel:v,testId:o,title:l,children:g}),e[9]=m,e[10]=s,e[11]=h,e[12]=b,e[13]=v,e[14]=g,e[15]=o,e[16]=l,e[17]=p):p=e[17],p},"Mt"),Xe=c(t=>{let e=(0,H.c)(13),{action:r,children:d,heading:h,testId:i}=t,o;e[0]!==h?(o=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h}),e[0]=h,e[1]=o):o=e[1];let l;e[2]!==r?(l=r!==void 0&&(0,a.jsx)("div",{className:"flex items-center gap-2",children:r}),e[2]=r,e[3]=l):l=e[3];let n;e[4]!==o||e[5]!==l?(n=(0,a.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[o,l]}),e[4]=o,e[5]=l,e[6]=n):n=e[6];let m;e[7]!==d?(m=(0,a.jsx)(yt,{className:"px-0",children:d}),e[7]=d,e[8]=m):m=e[8];let s;return e[9]!==n||e[10]!==m||e[11]!==i?(s=(0,a.jsxs)(vt,{className:"overflow-hidden py-0","data-testid":i,children:[n,m]}),e[9]=n,e[10]=m,e[11]=i,e[12]=s):s=e[12],s},"We"),We=c(t=>{let e=(0,H.c)(23),{columns:r,rowActions:d,rowPrefix:h,rows:i}=t,o=Q(),l;e[0]!==r?(l=r.map(Gt),e[0]=r,e[1]=l):l=e[1];let n;e[2]!==o?(n=o("Actions"),e[2]=o,e[3]=n):n=e[3];let m;e[4]!==n?(m=(0,a.jsx)(me,{"aria-label":n}),e[4]=n,e[5]=m):m=e[5];let s;e[6]!==l||e[7]!==m?(s=(0,a.jsx)(It,{children:(0,a.jsxs)(Ve,{children:[l,m]})}),e[6]=l,e[7]=m,e[8]=s):s=e[8];let f;if(e[9]!==r||e[10]!==d||e[11]!==h||e[12]!==i){let v;e[14]!==r||e[15]!==d||e[16]!==h?(v=c((g,p)=>{let k=A(g.id),y=k===""?`index-${p.toString()}`:k;return(0,a.jsxs)(Ve,{"data-testid":`${h}-${y}`,children:[r.map(I=>(0,a.jsx)(de,{className:I.className,children:I.render(g)},I.head)),(0,a.jsx)(de,{children:(0,a.jsx)("div",{className:"flex justify-end gap-1",children:d(g)})})]},y)},"p"),e[14]=r,e[15]=d,e[16]=h,e[17]=v):v=e[17],f=i.map(v),e[9]=r,e[10]=d,e[11]=h,e[12]=i,e[13]=f}else f=e[13];let u;e[18]!==f?(u=(0,a.jsx)(xt,{children:f}),e[18]=f,e[19]=u):u=e[19];let b;return e[20]!==s||e[21]!==u?(b=(0,a.jsxs)(Ct,{children:[s,u]}),e[20]=s,e[21]=u,e[22]=b):b=e[22],b},"Xe");function Gt(t){return(0,a.jsx)(me,{children:t.head},t.head)}c(Gt,"Zt");var Vt=c(t=>{let e=(0,H.c)(30),{actionBusy:r,onRemoveMember:d,memberColumns:h,members:i,onDialog:o}=t,l=Q(),n;e[0]!==o?(n=c(()=>{o({kind:"add-member"})},"r"),e[0]=o,e[1]=n):n=e[1];let m;e[2]!==l?(m=l("Add member"),e[2]=l,e[3]=m):m=e[3];let s;e[4]!==n||e[5]!==m?(s=(0,a.jsx)(j,{"data-testid":"org-open-add-member",onClick:n,size:"xs",type:"button",variant:"outline",children:m}),e[4]=n,e[5]=m,e[6]=s):s=e[6];let f;e[7]!==o?(f=c(()=>{o({kind:"invite-member"})},"h"),e[7]=o,e[8]=f):f=e[8];let u;e[9]!==l?(u=l("Invite member"),e[9]=l,e[10]=u):u=e[10];let b;e[11]!==f||e[12]!==u?(b=(0,a.jsx)(j,{"data-testid":"org-open-invite-member",onClick:f,size:"xs",type:"button",variant:"outline",children:u}),e[11]=f,e[12]=u,e[13]=b):b=e[13];let v;e[14]!==s||e[15]!==b?(v=(0,a.jsxs)(a.Fragment,{children:[s,b]}),e[14]=s,e[15]=b,e[16]=v):v=e[16];let g;e[17]!==l?(g=l("Members"),e[17]=l,e[18]=g):g=e[18];let p;e[19]!==r||e[20]!==h||e[21]!==i||e[22]!==o||e[23]!==d||e[24]!==l?(p=i.length===0?(0,a.jsx)("div",{className:"p-3",children:(0,a.jsx)(ue,{testId:"org-members-empty",title:l("No members.")})}):(0,a.jsx)(We,{columns:h,rowActions:c(y=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(j,{"data-testid":`org-member-role-${A(y.id)}`,onClick:c(()=>{o({kind:"member-role",member:y})},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Change role")}),(0,a.jsx)(j,{"data-testid":`org-remove-member-${A(y.id)}`,disabled:r,onClick:c(()=>{d(A(y.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Remove")})]}),"rowActions"),rowPrefix:"org-member",rows:i}),e[19]=r,e[20]=h,e[21]=i,e[22]=o,e[23]=d,e[24]=l,e[25]=p):p=e[25];let k;return e[26]!==v||e[27]!==g||e[28]!==p?(k=(0,a.jsx)(Xe,{action:v,heading:g,testId:"org-members",children:p}),e[26]=v,e[27]=g,e[28]=p,e[29]=k):k=e[29],k},"qt"),Xt=c(t=>{let e=(0,H.c)(21),{onConfirmDeleteTeam:r,onDialog:d,onSelectTeam:h,selectedTeam:i,teamColumns:o,teams:l}=t,n=Q(),m;e[0]!==d?(m=c(()=>{d({kind:"team-create"})},"m"),e[0]=d,e[1]=m):m=e[1];let s;e[2]!==n?(s=n("New team"),e[2]=n,e[3]=s):s=e[3];let f;e[4]!==m||e[5]!==s?(f=(0,a.jsx)(j,{"data-testid":"org-open-create-team",onClick:m,size:"xs",type:"button",variant:"outline",children:s}),e[4]=m,e[5]=s,e[6]=f):f=e[6];let u;e[7]!==n?(u=n("Teams"),e[7]=n,e[8]=u):u=e[8];let b;e[9]!==r||e[10]!==d||e[11]!==h||e[12]!==i||e[13]!==n||e[14]!==o||e[15]!==l?(b=l.length===0?(0,a.jsx)("div",{className:"p-3",children:(0,a.jsx)(ue,{testId:"org-teams-empty",title:n("No teams.")})}):(0,a.jsx)(We,{columns:o,rowActions:c(g=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(j,{"aria-pressed":i===A(g.id),"data-testid":`org-team-select-${A(g.id)}`,onClick:c(()=>{h(A(g.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Members")}),(0,a.jsx)(j,{"data-testid":`org-team-rename-${A(g.id)}`,onClick:c(()=>{d({kind:"team-rename",team:g})},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Rename")}),(0,a.jsx)(j,{"data-testid":`org-team-delete-${A(g.id)}`,onClick:c(()=>{r(g)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Delete")})]}),"rowActions"),rowPrefix:"org-team",rows:l}),e[9]=r,e[10]=d,e[11]=h,e[12]=i,e[13]=n,e[14]=o,e[15]=l,e[16]=b):b=e[16];let v;return e[17]!==f||e[18]!==u||e[19]!==b?(v=(0,a.jsx)(Xe,{action:f,heading:u,testId:"org-teams",children:b}),e[17]=f,e[18]=u,e[19]=b,e[20]=v):v=e[20],v},"Kt"),Wt=c(t=>{let e=(0,H.c)(20),{actionBusy:r,onRemoveTeamMember:d,onDialog:h,selectedTeam:i,teamMemberColumns:o,teamMembers:l}=t,n=Q(),m;e[0]!==h||e[1]!==i?(m=c(()=>{h({kind:"team-add-member",teamId:i})},"m"),e[0]=h,e[1]=i,e[2]=m):m=e[2];let s;e[3]!==n?(s=n("Add member"),e[3]=n,e[4]=s):s=e[4];let f;e[5]!==m||e[6]!==s?(f=(0,a.jsx)(j,{"data-testid":"org-open-add-team-member",onClick:m,size:"xs",type:"button",variant:"outline",children:s}),e[5]=m,e[6]=s,e[7]=f):f=e[7];let u;e[8]!==n?(u=n("Team members"),e[8]=n,e[9]=u):u=e[9];let b;e[10]!==r||e[11]!==d||e[12]!==n||e[13]!==o||e[14]!==l?(b=l.length===0?(0,a.jsx)("div",{className:"p-3",children:(0,a.jsx)(ue,{testId:"org-team-members-empty",title:n("No team members.")})}):(0,a.jsx)(We,{columns:o,rowActions:c(g=>(0,a.jsx)(j,{"data-testid":`org-team-remove-member-${A(g.id)}`,disabled:r,onClick:c(()=>{d(A(g.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Remove")}),"rowActions"),rowPrefix:"org-team-member",rows:l}),e[10]=r,e[11]=d,e[12]=n,e[13]=o,e[14]=l,e[15]=b):b=e[15];let v;return e[16]!==f||e[17]!==u||e[18]!==b?(v=(0,a.jsx)(Xe,{action:f,heading:u,testId:"org-team-members",children:b}),e[16]=f,e[17]=u,e[18]=b,e[19]=v):v=e[19],v},"Vt"),er=c(t=>{let e=(0,H.c)(19),{onConfirmDeleteRole:r,onDialog:d,roleColumns:h,roles:i}=t,o=Q(),l;e[0]!==d?(l=c(()=>{d({kind:"role-create"})},"i"),e[0]=d,e[1]=l):l=e[1];let n;e[2]!==o?(n=o("New role"),e[2]=o,e[3]=n):n=e[3];let m;e[4]!==l||e[5]!==n?(m=(0,a.jsx)(j,{"data-testid":"org-open-create-role",onClick:l,size:"xs",type:"button",variant:"outline",children:n}),e[4]=l,e[5]=n,e[6]=m):m=e[6];let s;e[7]!==o?(s=o("Roles"),e[7]=o,e[8]=s):s=e[8];let f;e[9]!==r||e[10]!==d||e[11]!==h||e[12]!==i||e[13]!==o?(f=i.length===0?(0,a.jsx)("div",{className:"p-3",children:(0,a.jsx)(ue,{testId:"org-roles-empty",title:o("No custom roles.")})}):(0,a.jsx)(We,{columns:h,rowActions:c(b=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(j,{"data-testid":`org-role-edit-${A(b.id)}`,onClick:c(()=>{d({kind:"role-edit",role:b})},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Edit")}),(0,a.jsx)(j,{"data-testid":`org-role-delete-${A(b.id)}`,onClick:c(()=>{r(A(b.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Delete")})]}),"rowActions"),rowPrefix:"org-role",rows:i}),e[9]=r,e[10]=d,e[11]=h,e[12]=i,e[13]=o,e[14]=f):f=e[14];let u;return e[15]!==m||e[16]!==s||e[17]!==f?(u=(0,a.jsx)(Xe,{action:m,heading:s,testId:"org-roles",children:f}),e[15]=m,e[16]=s,e[17]=f,e[18]=u):u=e[18],u},"Wt"),Et=200,tr=c(t=>{let e=(0,H.c)(207),{organizationId:r,rolesEnabled:d,teamsEnabled:h}=t,i=oe(),o=Q(),[l,n]=(0,F.useState)(null),[m,s]=(0,F.useState)(null),[f,u]=(0,F.useState)(!1),[b,v]=(0,F.useState)(null),[g,p]=_t(r),k;e[0]!==g||e[1]!==r?(k=["lunora-auth-org-members",r,g],e[0]=g,e[1]=r,e[2]=k):k=e[2];let y;e[3]!==i||e[4]!==g||e[5]!==r?(y=c(()=>i.listAuthOrgMembers({limit:Et,offset:g,organizationId:r}),"v"),e[3]=i,e[4]=g,e[5]=r,e[6]=y):y=e[6];let I=ge(k,y),C;e[7]!==r?(C=["lunora-auth-org-invitations",r],e[7]=r,e[8]=C):C=e[8];let w;e[9]!==i||e[10]!==r?(w=c(()=>i.listAuthOrgInvitations({limit:200,organizationId:r}),"I"),e[9]=i,e[10]=r,e[11]=w):w=e[11];let x=ge(C,w),z;e[12]!==r?(z=["lunora-auth-org-teams",r],e[12]=r,e[13]=z):z=e[13];let N;e[14]!==i||e[15]!==r?(N=c(()=>i.listAuthOrgTeams({limit:200,organizationId:r}),"D"),e[14]=i,e[15]=r,e[16]=N):N=e[16];let _;e[17]!==h?(_={enabled:h},e[17]=h,e[18]=_):_=e[18];let D=ge(z,N,_),O;e[19]!==r?(O=["lunora-auth-org-roles",r],e[19]=r,e[20]=O):O=e[20];let T;e[21]!==i||e[22]!==r?(T=c(()=>i.listAuthOrgRoles({limit:200,organizationId:r}),"_"),e[21]=i,e[22]=r,e[23]=T):T=e[23];let $;e[24]!==d?($={enabled:d},e[24]=d,e[25]=$):$=e[25];let E=ge(O,T,$),Z;e[26]!==m?(Z=["lunora-auth-org-team-members",m],e[26]=m,e[27]=Z):Z=e[27];let B;e[28]!==i||e[29]!==m?(B=c(()=>i.listAuthOrgTeamMembers({limit:200,teamId:m??""}),"B"),e[28]=i,e[29]=m,e[30]=B):B=e[30];let K=m!==null,J;e[31]!==K?(J={enabled:K},e[31]=K,e[32]=J):J=e[32];let P=ge(Z,B,J),U;e[33]!==I.data?.rows?(U=I.data?.rows??[],e[33]=I.data?.rows,e[34]=U):U=e[34];let L=U,Y;e[35]!==x.data?.rows?(Y=x.data?.rows??[],e[35]=x.data?.rows,e[36]=Y):Y=e[36];let M=Y,R;e[37]!==D.data?.rows?(R=D.data?.rows??[],e[37]=D.data?.rows,e[38]=R):R=e[38];let q=R,W;e[39]!==E.data?.rows?(W=E.data?.rows??[],e[39]=E.data?.rows,e[40]=W):W=e[40];let te=W,ae;e[41]!==m||e[42]!==P?(ae=m===null?[]:P.data?.rows??[],e[41]=m,e[42]=P,e[43]=ae):ae=e[43];let re=ae,ee=I.error??x.error??D.error??E.error??P.error,le;e[44]!==x||e[45]!==I||e[46]!==d||e[47]!==E||e[48]!==m||e[49]!==P||e[50]!==h||e[51]!==D?(le=c(()=>{I.refetch(),x.refetch(),h&&D.refetch(),d&&E.refetch(),m!==null&&P.refetch()},"ie"),e[44]=x,e[45]=I,e[46]=d,e[47]=E,e[48]=m,e[49]=P,e[50]=h,e[51]=D,e[52]=le):le=e[52];let S=le;kt(S,!0);let et;e[53]===Symbol.for("react.memo_cache_sentinel")?(et=c(()=>{n(null)},"Ye"),e[53]=et):et=e[53];let ne=et,tt;e[54]!==S?(tt=c(X=>{At((async()=>{u(!0),v(null);try{await X(),S(),u(!1)}catch(mt){v(Nt(mt)),u(!1)}})())},"et"),e[54]=S,e[55]=tt):tt=e[55];let ie=tt,rt;e[56]!==i||e[57]!==o?(rt=c(X=>{let mt=A(X.id);n({action:c(async()=>{await i.removeAuthOrgTeam({teamId:mt}),s(St=>St===mt?null:St)},"action"),kind:"confirm",message:o("Delete this team and its memberships? This cannot be undone."),testId:"org-team-delete",title:o("Delete team")})},"tt"),e[56]=i,e[57]=o,e[58]=rt):rt=e[58];let dt=rt,he;e[59]!==o?(he=o("userId"),e[59]=o,e[60]=he):he=e[60];let be;e[61]!==he?(be={head:he,render:rr},e[61]=he,e[62]=be):be=e[62];let fe;e[63]!==o?(fe=o("role"),e[63]=o,e[64]=fe):fe=e[64];let pe;e[65]!==fe?(pe={head:fe,render:or},e[65]=fe,e[66]=pe):pe=e[66];let ot;e[67]!==be||e[68]!==pe?(ot=[be,pe],e[67]=be,e[68]=pe,e[69]=ot):ot=e[69];let ct=ot,ve;e[70]!==o?(ve=o("email"),e[70]=o,e[71]=ve):ve=e[71];let ye;e[72]!==ve?(ye={head:ve,render:ar},e[72]=ve,e[73]=ye):ye=e[73];let Ce;e[74]!==o?(Ce=o("role"),e[74]=o,e[75]=Ce):Ce=e[75];let Ie;e[76]!==Ce?(Ie={head:Ce,render:lr},e[76]=Ce,e[77]=Ie):Ie=e[77];let xe;e[78]!==o?(xe=o("status"),e[78]=o,e[79]=xe):xe=e[79];let we;e[80]!==xe?(we={head:xe,render:nr},e[80]=xe,e[81]=we):we=e[81];let at;e[82]!==ye||e[83]!==Ie||e[84]!==we?(at=[ye,Ie,we],e[82]=ye,e[83]=Ie,e[84]=we,e[85]=at):at=e[85];let ut=at,ke;e[86]!==o?(ke=o("id"),e[86]=o,e[87]=ke):ke=e[87];let ze;e[88]!==ke?(ze={className:"font-mono text-xs",head:ke,render:ir},e[88]=ke,e[89]=ze):ze=e[89];let Se;e[90]!==o?(Se=o("name"),e[90]=o,e[91]=Se):Se=e[91];let Ne;e[92]!==Se?(Ne={head:Se,render:sr},e[92]=Se,e[93]=Ne):Ne=e[93];let lt;e[94]!==ze||e[95]!==Ne?(lt=[ze,Ne],e[94]=ze,e[95]=Ne,e[96]=lt):lt=e[96];let gt=lt,Ae;e[97]!==o?(Ae=o("userId"),e[97]=o,e[98]=Ae):Ae=e[98];let nt;e[99]!==Ae?(nt=[{head:Ae,render:mr}],e[99]=Ae,e[100]=nt):nt=e[100];let ht=nt,De;e[101]!==o?(De=o("role"),e[101]=o,e[102]=De):De=e[102];let Oe;e[103]!==De?(Oe={head:De,render:dr},e[103]=De,e[104]=Oe):Oe=e[104];let _e;e[105]!==o?(_e=o("Permission"),e[105]=o,e[106]=_e):_e=e[106];let Te;e[107]!==_e?(Te={className:"font-mono text-xs whitespace-pre-wrap",head:_e,render:cr},e[107]=_e,e[108]=Te):Te=e[108];let it;e[109]!==Oe||e[110]!==Te?(it=[Oe,Te],e[109]=Oe,e[110]=Te,e[111]=it):it=e[111];let bt=it,$e;e[112]!==ee?($e=ee!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-detail-error",role:"alert",children:ee}),e[112]=ee,e[113]=$e):$e=e[113];let Re;e[114]!==b?(Re=b!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-action-error",role:"alert",children:b}),e[114]=b,e[115]=Re):Re=e[115];let Me;e[116]!==i||e[117]!==ie?(Me=c(X=>{ie(()=>i.removeAuthOrgMember({memberId:X}))},"$e"),e[116]=i,e[117]=ie,e[118]=Me):Me=e[118];let Fe;e[119]!==f||e[120]!==ct||e[121]!==L||e[122]!==Me?(Fe=(0,a.jsx)(Vt,{actionBusy:f,memberColumns:ct,members:L,onDialog:n,onRemoveMember:Me}),e[119]=f,e[120]=ct,e[121]=L,e[122]=Me,e[123]=Fe):Fe=e[123];let ft=I.data?.total,Ee;e[124]!==L.length||e[125]!==g||e[126]!==p||e[127]!==ft?(Ee=(0,a.jsx)(zt,{count:L.length,offset:g,onOffsetChange:p,pageSize:Et,prefix:"org-members",total:ft}),e[124]=L.length,e[125]=g,e[126]=p,e[127]=ft,e[128]=Ee):Ee=e[128];let je;e[129]!==f||e[130]!==i||e[131]!==ut||e[132]!==M||e[133]!==ie||e[134]!==o?(je=M.length>0&&(0,a.jsx)(Xe,{heading:o("Invitations"),testId:"org-invitations",children:(0,a.jsx)(We,{columns:ut,rowActions:c(X=>(0,a.jsx)(j,{"data-testid":`org-cancel-invitation-${A(X.id)}`,disabled:f,onClick:c(()=>{ie(()=>i.cancelAuthOrgInvitation({invitationId:A(X.id)}))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Cancel")}),"rowActions"),rowPrefix:"org-invitation",rows:M})}),e[129]=f,e[130]=i,e[131]=ut,e[132]=M,e[133]=ie,e[134]=o,e[135]=je):je=e[135];let Le;e[136]!==dt||e[137]!==m||e[138]!==gt||e[139]!==q||e[140]!==h?(Le=h&&(0,a.jsx)(Xt,{onConfirmDeleteTeam:dt,onDialog:n,onSelectTeam:s,selectedTeam:m,teamColumns:gt,teams:q}),e[136]=dt,e[137]=m,e[138]=gt,e[139]=q,e[140]=h,e[141]=Le):Le=e[141];let Pe;e[142]!==f||e[143]!==i||e[144]!==ie||e[145]!==m||e[146]!==ht||e[147]!==re||e[148]!==h?(Pe=h&&m!==null&&(0,a.jsx)(Wt,{actionBusy:f,onDialog:n,onRemoveTeamMember:c(X=>{ie(()=>i.removeAuthOrgTeamMember({teamMemberId:X}))},"onRemoveTeamMember"),selectedTeam:m,teamMemberColumns:ht,teamMembers:re}),e[142]=f,e[143]=i,e[144]=ie,e[145]=m,e[146]=ht,e[147]=re,e[148]=h,e[149]=Pe):Pe=e[149];let Be;e[150]!==i||e[151]!==bt||e[152]!==te||e[153]!==d||e[154]!==o?(Be=d&&(0,a.jsx)(er,{onConfirmDeleteRole:c(X=>{n({action:c(()=>i.deleteAuthOrgRole({roleId:X}),"action"),kind:"confirm",message:o("Delete this custom role? Members keeping it will lose its grants."),testId:"org-role-delete",title:o("Delete role")})},"onConfirmDeleteRole"),onDialog:n,roleColumns:bt,roles:te}),e[150]=i,e[151]=bt,e[152]=te,e[153]=d,e[154]=o,e[155]=Be):Be=e[155];let Je;e[156]!==l?.kind||e[157]!==r||e[158]!==S?(Je=l?.kind==="add-member"&&(0,a.jsx)(Qt,{onClose:ne,onDone:S,organizationId:r}),e[156]=l?.kind,e[157]=r,e[158]=S,e[159]=Je):Je=e[159];let Ue;e[160]!==l?.kind||e[161]!==r||e[162]!==S?(Ue=l?.kind==="invite-member"&&(0,a.jsx)(Zt,{onClose:ne,onDone:S,organizationId:r}),e[160]=l?.kind,e[161]=r,e[162]=S,e[163]=Ue):Ue=e[163];let He;e[164]!==l||e[165]!==S?(He=l?.kind==="member-role"&&(0,a.jsx)(Yt,{member:l.member,onClose:ne,onDone:S}),e[164]=l,e[165]=S,e[166]=He):He=e[166];let Ke;e[167]!==l?.kind||e[168]!==r||e[169]!==S?(Ke=l?.kind==="team-create"&&(0,a.jsx)(Mt,{mode:"create",onClose:ne,onDone:S,organizationId:r}),e[167]=l?.kind,e[168]=r,e[169]=S,e[170]=Ke):Ke=e[170];let Qe;e[171]!==l||e[172]!==r||e[173]!==S?(Qe=l?.kind==="team-rename"&&(0,a.jsx)(Mt,{mode:"edit",onClose:ne,onDone:S,organizationId:r,team:l.team}),e[171]=l,e[172]=r,e[173]=S,e[174]=Qe):Qe=e[174];let Ze;e[175]!==l||e[176]!==S?(Ze=l?.kind==="team-add-member"&&(0,a.jsx)(qt,{onClose:ne,onDone:S,teamId:l.teamId}),e[175]=l,e[176]=S,e[177]=Ze):Ze=e[177];let Ye;e[178]!==l?.kind||e[179]!==r||e[180]!==S?(Ye=l?.kind==="role-create"&&(0,a.jsx)(Ft,{mode:"create",onClose:ne,onDone:S,organizationId:r}),e[178]=l?.kind,e[179]=r,e[180]=S,e[181]=Ye):Ye=e[181];let qe;e[182]!==l||e[183]!==r||e[184]!==S?(qe=l?.kind==="role-edit"&&(0,a.jsx)(Ft,{mode:"edit",onClose:ne,onDone:S,organizationId:r,role:l.role}),e[182]=l,e[183]=r,e[184]=S,e[185]=qe):qe=e[185];let Ge;e[186]!==l||e[187]!==S?(Ge=l?.kind==="confirm"&&(0,a.jsx)(Bt,{action:l.action,message:l.message,onClose:ne,onDone:S,testId:l.testId,title:l.title}),e[186]=l,e[187]=S,e[188]=Ge):Ge=e[188];let st;return e[189]!==$e||e[190]!==Re||e[191]!==Fe||e[192]!==Ee||e[193]!==je||e[194]!==Le||e[195]!==Pe||e[196]!==Be||e[197]!==Je||e[198]!==Ue||e[199]!==He||e[200]!==Ke||e[201]!==Qe||e[202]!==Ze||e[203]!==Ye||e[204]!==qe||e[205]!==Ge?(st=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"org-detail",children:[$e,Re,Fe,Ee,je,Le,Pe,Be,Je,Ue,He,Ke,Qe,Ze,Ye,qe,Ge]}),e[189]=$e,e[190]=Re,e[191]=Fe,e[192]=Ee,e[193]=je,e[194]=Le,e[195]=Pe,e[196]=Be,e[197]=Je,e[198]=Ue,e[199]=He,e[200]=Ke,e[201]=Qe,e[202]=Ze,e[203]=Ye,e[204]=qe,e[205]=Ge,e[206]=st):st=e[206],st},"Xt");function rr(t){return(0,a.jsx)("span",{className:"font-mono text-xs",children:A(t.userId)})}c(rr,"Yt");function or(t){return A(t.role)}c(or,"el");function ar(t){return A(t.email)}c(ar,"tl");function lr(t){return A(t.role)}c(lr,"ll");function nr(t){return A(t.status)}c(nr,"ol");function ir(t){return A(t.id)}c(ir,"il");function sr(t){return A(t.name)}c(sr,"rl");function mr(t){return(0,a.jsx)("span",{className:"font-mono text-xs",children:A(t.userId)})}c(mr,"nl");function dr(t){return A(t.role)}c(dr,"sl");function cr(t){return A(t.permission)}c(cr,"al");var jt=100,Ar=c(()=>{let t=(0,H.c)(69),e=oe(),r=Q(),{config:d,ready:h}=Tt(),i=d.capabilities.organization,[o,l]=(0,F.useState)(null),[n,m]=(0,F.useState)(null),[s,f]=(0,F.useState)(0),u;t[0]!==s?(u=["lunora-auth-orgs",s],t[0]=s,t[1]=u):u=t[1];let b;t[2]!==e||t[3]!==s?(b=c(()=>e.listAuthOrganizations({limit:jt,offset:s}),"g"),t[2]=e,t[3]=s,t[4]=b):b=t[4];let v;t[5]!==i?(v={enabled:i},t[5]=i,t[6]=v):v=t[6];let g=ge(u,b,v),p=g.data?.rows??null,k;t[7]!==g?(k=c(()=>{g.refetch()},"S"),t[7]=g,t[8]=k):k=t[8],kt(k,i);let y;t[9]===Symbol.for("react.memo_cache_sentinel")?(y=c(()=>{m(null)},"v"),t[9]=y):y=t[9];let I=y,C;t[10]!==g?(C=c(()=>{g.refetch()},"y"),t[10]=g,t[11]=C):C=t[11];let w=C,x;t[12]===Symbol.for("react.memo_cache_sentinel")?(x=c(M=>{l(M)},"x"),t[12]=x):x=t[12];let z=x;if(h&&!i){let M;t[13]!==r?(M=r("Enable the organization() plugin in your auth config to manage organizations here."),t[13]=r,t[14]=M):M=t[14];let R;t[15]!==r?(R=r("Organizations are not enabled."),t[15]=r,t[16]=R):R=t[16];let q;return t[17]!==M||t[18]!==R?(q=(0,a.jsx)(ue,{description:M,testId:"org-disabled",title:R}),t[17]=M,t[18]=R,t[19]=q):q=t[19],q}let N;t[20]!==r?(N=r("Organizations"),t[20]=r,t[21]=N):N=t[21];let _;t[22]!==N?(_=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:N}),t[22]=N,t[23]=_):_=t[23];let D;t[24]===Symbol.for("react.memo_cache_sentinel")?(D=c(()=>{m({kind:"create"})},"A"),t[24]=D):D=t[24];let O;t[25]!==r?(O=r("New organization"),t[25]=r,t[26]=O):O=t[26];let T;t[27]!==O?(T=(0,a.jsx)(j,{"data-testid":"org-new",onClick:D,size:"sm",type:"button",children:O}),t[27]=O,t[28]=T):T=t[28];let $;t[29]!==T||t[30]!==_?($=(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[_,T]}),t[29]=T,t[30]=_,t[31]=$):$=t[31];let E;t[32]!==g.error?(E=g.error!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-error",role:"alert",children:g.error}),t[32]=g.error,t[33]=E):E=t[33];let Z;t[34]!==p||t[35]!==r?(Z=p!==null&&p.length===0&&(0,a.jsx)(ue,{testId:"org-empty",title:r("No organizations.")}),t[34]=p,t[35]=r,t[36]=Z):Z=t[36];let B;t[37]!==p||t[38]!==o||t[39]!==r?(B=p!==null&&p.length>0&&(0,a.jsx)(vt,{className:"overflow-hidden py-0",children:(0,a.jsx)(yt,{className:"px-0",children:(0,a.jsxs)(Ct,{"data-testid":"org-table",children:[(0,a.jsx)(It,{children:(0,a.jsxs)(Ve,{children:[(0,a.jsx)(me,{children:r("id")}),(0,a.jsx)(me,{children:r("name")}),(0,a.jsx)(me,{children:r("slug")}),(0,a.jsx)(me,{children:r("created")}),(0,a.jsx)(me,{"aria-label":r("Actions")})]})}),(0,a.jsx)(xt,{children:p.map(M=>{let R=A(M.id);return(0,a.jsxs)(Ve,{"data-testid":`org-row-${R}`,children:[(0,a.jsx)(de,{className:"font-mono text-xs",children:R}),(0,a.jsx)(de,{children:A(M.name)}),(0,a.jsx)(de,{children:A(M.slug)}),(0,a.jsx)(de,{className:"text-muted-foreground tabular-nums",children:Dt(M.createdAt)}),(0,a.jsx)(de,{children:(0,a.jsxs)("div",{className:"flex justify-end gap-1",children:[(0,a.jsx)(j,{"aria-pressed":o===R,"data-testid":`org-select-${R}`,onClick:c(()=>{z(R)},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Manage")}),(0,a.jsx)(j,{"data-testid":`org-edit-${R}`,onClick:c(()=>{m({kind:"edit",org:M})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Edit")}),(0,a.jsx)(j,{"data-testid":`org-delete-${R}`,onClick:c(()=>{m({kind:"delete",org:M})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Delete")})]})})]},R)})})]})})}),t[37]=p,t[38]=o,t[39]=r,t[40]=B):B=t[40];let K;t[41]!==s||t[42]!==p||t[43]!==g.data?.total?(K=p!==null&&(0,a.jsx)(zt,{count:p.length,offset:s,onOffsetChange:f,pageSize:jt,prefix:"org",total:g.data?.total}),t[41]=s,t[42]=p,t[43]=g.data?.total,t[44]=K):K=t[44];let J;t[45]!==d.organization||t[46]!==o?(J=o!==null&&(0,a.jsx)(tr,{organizationId:o,rolesEnabled:d.organization.roles,teamsEnabled:d.organization.teams}),t[45]=d.organization,t[46]=o,t[47]=J):J=t[47];let P;t[48]!==n?.kind||t[49]!==w?(P=n?.kind==="create"&&(0,a.jsx)(Rt,{mode:"create",onClose:I,onDone:w}),t[48]=n?.kind,t[49]=w,t[50]=P):P=t[50];let U;t[51]!==n||t[52]!==w?(U=n?.kind==="edit"&&(0,a.jsx)(Rt,{mode:"edit",onClose:I,onDone:w,org:n.org}),t[51]=n,t[52]=w,t[53]=U):U=t[53];let L;t[54]!==e||t[55]!==n||t[56]!==w||t[57]!==r?(L=n?.kind==="delete"&&(0,a.jsx)(Bt,{action:c(async()=>{let M=A(n.org.id);await e.deleteAuthOrganization({organizationId:M}),l(R=>R===M?null:R)},"action"),message:r("Delete this organization? Its members, invitations, teams, and custom roles are removed. This cannot be undone."),onClose:I,onDone:w,testId:"org-delete",title:r("Delete organization")}),t[54]=e,t[55]=n,t[56]=w,t[57]=r,t[58]=L):L=t[58];let Y;return t[59]!==$||t[60]!==E||t[61]!==Z||t[62]!==B||t[63]!==K||t[64]!==J||t[65]!==P||t[66]!==U||t[67]!==L?(Y=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-organizations",children:[$,E,Z,B,K,J,P,U,L]}),t[59]=$,t[60]=E,t[61]=Z,t[62]=B,t[63]=K,t[64]=J,t[65]=P,t[66]=U,t[67]=L,t[68]=Y):Y=t[68],Y},"Al");export{Ar as default};
|
|
1
|
+
import{a as wt}from"./chunk-FPI7AMQJ.js";import{a as Tt}from"./chunk-PUOC4Q55.js";import{a as se}from"./chunk-2G3B5PAO.js";import{a as $t}from"./chunk-QJLHH3ET.js";import{a as Ot}from"./chunk-37WYCOQ2.js";import{a as zt,b as _t}from"./chunk-OMN44W6V.js";import"./chunk-VASJTDMU.js";import{a as kt}from"./chunk-JQXA2OYK.js";import{i as V}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as j}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import"./chunk-BOMPSVRC.js";import{b as ge}from"./chunk-C4ZPJ4KT.js";import{l as oe}from"./chunk-DTFIEXYN.js";import"./chunk-QAQDMS6R.js";import"./chunk-WS7WNXF3.js";import{a as ue}from"./chunk-RWVIV3U7.js";import{a as Ct,b as It,c as xt,d as Ve,e as me,f as de}from"./chunk-HCTJKP5J.js";import{a as vt,e as yt}from"./chunk-2IKDEUCX.js";import{d as Q,h as Nt,o as A,p as At,t as Dt}from"./chunk-5OMZCVRF.js";import{a as c,d as pt,e as Jt,f as Ut,g as Ht}from"./chunk-I26MS5PJ.js";var H=pt(Ut(),1);var F=pt(Jt(),1);var a=pt(Ht(),1);var Lt=c(t=>{let e=JSON.parse(t);if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("Expected a JSON object");return e},"Tt"),Kt=c(t=>{let e=Lt(t),r={};for(let[d,h]of Object.entries(e)){if(!Array.isArray(h)||h.some(i=>typeof i!="string"))throw new TypeError(`"${d}" must map to an array of action strings`);r[d]=h}return r},"Qt"),Pt=c(t=>t==null||t===""?"":typeof t=="string"?t:JSON.stringify(t,null,2),"$t"),G=c(t=>{let e=(0,H.c)(6),{children:r,htmlFor:d,label:h}=t,i;e[0]!==d||e[1]!==h?(i=(0,a.jsx)(Ot,{htmlFor:d,children:h}),e[0]=d,e[1]=h,e[2]=i):i=e[2];let o;return e[3]!==r||e[4]!==i?(o=(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[i,r]}),e[3]=r,e[4]=i,e[5]=o):o=e[5],o},"V"),ce=c(({busy:t,canSubmit:e,children:r,destructive:d=!1,error:h,onClose:i,onSubmit:o,submitLabel:l,testId:n,title:m})=>{let s=Q();return(0,a.jsxs)($t,{label:m,onClose:i,panelTestId:`${n}-panel`,testId:`${n}-overlay`,variant:"dialog",children:[(0,a.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:m}),r,h!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":`${n}-error`,role:"alert",children:h}),(0,a.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[(0,a.jsx)(j,{"data-testid":`${n}-cancel`,onClick:i,size:"sm",type:"button",variant:"outline",children:s("Cancel")}),(0,a.jsx)(j,{"data-testid":`${n}-submit`,disabled:t||!e,onClick:o,size:"sm",type:"button",variant:d?"destructive":"default",children:t?s("Saving\u2026"):l})]})]})},"me"),Rt=c(t=>{let e=(0,H.c)(79),{mode:r,onClose:d,onDone:h,org:i}=t,o=oe(),l=Q(),{busy:n,error:m,run:s}=se(),f;e[0]!==i?(f=i?A(i.name):"",e[0]=i,e[1]=f):f=e[1];let[u,b]=(0,F.useState)(f),v;e[2]!==i?(v=i?A(i.slug):"",e[2]=i,e[3]=v):v=e[3];let[g,p]=(0,F.useState)(v),k;e[4]!==i?(k=i?A(i.logo):"",e[4]=i,e[5]=k):k=e[5];let[y,I]=(0,F.useState)(k),[C,w]=(0,F.useState)(""),x;e[6]!==r||e[7]!==i?.metadata?(x=r==="edit"?Pt(i?.metadata):"",e[6]=r,e[7]=i?.metadata,e[8]=x):x=e[8];let[z,N]=(0,F.useState)(x),_;e[9]!==o||e[10]!==y||e[11]!==z||e[12]!==r||e[13]!==u||e[14]!==d||e[15]!==h||e[16]!==i?.id||e[17]!==C||e[18]!==s||e[19]!==g?(_=c(()=>{s(async()=>{let S=z.trim()===""?void 0:Lt(z);r==="create"?await o.createAuthOrganization({logo:y.trim()===""?void 0:y.trim(),metadata:S,name:u.trim(),ownerId:C.trim()===""?void 0:C.trim(),slug:g.trim()===""?void 0:g.trim()}):await o.updateAuthOrganization({logo:y.trim()===""?void 0:y.trim(),metadata:S,name:u.trim()===""?void 0:u.trim(),organizationId:A(i?.id),slug:g.trim()===""?void 0:g.trim()}),h(),d()})},"O"),e[9]=o,e[10]=y,e[11]=z,e[12]=r,e[13]=u,e[14]=d,e[15]=h,e[16]=i?.id,e[17]=C,e[18]=s,e[19]=g,e[20]=_):_=e[20];let D=_,O;e[21]!==r||e[22]!==u?(O=u.trim()!==""||r==="edit",e[21]=r,e[22]=u,e[23]=O):O=e[23];let T;e[24]!==r||e[25]!==l?(T=l(r==="create"?"Create":"Save"),e[24]=r,e[25]=l,e[26]=T):T=e[26];let $;e[27]!==r||e[28]!==l?($=l(r==="create"?"New organization":"Edit organization"),e[27]=r,e[28]=l,e[29]=$):$=e[29];let E;e[30]!==l?(E=l("name"),e[30]=l,e[31]=E):E=e[31];let Z;e[32]===Symbol.for("react.memo_cache_sentinel")?(Z=c(S=>{b(S.target.value)},"H"),e[32]=Z):Z=e[32];let B;e[33]!==u?(B=(0,a.jsx)(V,{"data-testid":"org-form-name",id:"org-form-name",onChange:Z,value:u}),e[33]=u,e[34]=B):B=e[34];let K;e[35]!==B||e[36]!==E?(K=(0,a.jsx)(G,{htmlFor:"org-form-name",label:E,children:B}),e[35]=B,e[36]=E,e[37]=K):K=e[37];let J;e[38]!==l?(J=l("Slug (optional \u2014 derived from name)"),e[38]=l,e[39]=J):J=e[39];let P;e[40]===Symbol.for("react.memo_cache_sentinel")?(P=c(S=>{p(S.target.value)},"P"),e[40]=P):P=e[40];let U;e[41]!==g?(U=(0,a.jsx)(V,{"data-testid":"org-form-slug",id:"org-form-slug",onChange:P,value:g}),e[41]=g,e[42]=U):U=e[42];let L;e[43]!==J||e[44]!==U?(L=(0,a.jsx)(G,{htmlFor:"org-form-slug",label:J,children:U}),e[43]=J,e[44]=U,e[45]=L):L=e[45];let Y;e[46]!==l?(Y=l("Logo URL (optional)"),e[46]=l,e[47]=Y):Y=e[47];let M;e[48]===Symbol.for("react.memo_cache_sentinel")?(M=c(S=>{I(S.target.value)},"M"),e[48]=M):M=e[48];let R;e[49]!==y?(R=(0,a.jsx)(V,{"data-testid":"org-form-logo",id:"org-form-logo",onChange:M,value:y}),e[49]=y,e[50]=R):R=e[50];let q;e[51]!==Y||e[52]!==R?(q=(0,a.jsx)(G,{htmlFor:"org-form-logo",label:Y,children:R}),e[51]=Y,e[52]=R,e[53]=q):q=e[53];let W;e[54]!==r||e[55]!==C||e[56]!==l?(W=r==="create"&&(0,a.jsx)(G,{htmlFor:"org-form-owner",label:l("Owner user id (optional)"),children:(0,a.jsx)(V,{"data-testid":"org-form-owner",id:"org-form-owner",onChange:c(S=>{w(S.target.value)},"onChange"),value:C})}),e[54]=r,e[55]=C,e[56]=l,e[57]=W):W=e[57];let te;e[58]!==l?(te=l("Metadata (JSON, optional)"),e[58]=l,e[59]=te):te=e[59];let ae;e[60]===Symbol.for("react.memo_cache_sentinel")?(ae=c(S=>{N(S.target.value)},"oe"),e[60]=ae):ae=e[60];let re;e[61]!==z?(re=(0,a.jsx)(wt,{"data-testid":"org-form-metadata",id:"org-form-metadata",onChange:ae,value:z}),e[61]=z,e[62]=re):re=e[62];let ee;e[63]!==te||e[64]!==re?(ee=(0,a.jsx)(G,{htmlFor:"org-form-metadata",label:te,children:re}),e[63]=te,e[64]=re,e[65]=ee):ee=e[65];let le;return e[66]!==n||e[67]!==m||e[68]!==d||e[69]!==D||e[70]!==K||e[71]!==L||e[72]!==q||e[73]!==W||e[74]!==ee||e[75]!==O||e[76]!==T||e[77]!==$?(le=(0,a.jsxs)(ce,{busy:n,canSubmit:O,error:m,onClose:d,onSubmit:D,submitLabel:T,testId:"org-form",title:$,children:[K,L,q,W,ee]}),e[66]=n,e[67]=m,e[68]=d,e[69]=D,e[70]=K,e[71]=L,e[72]=q,e[73]=W,e[74]=ee,e[75]=O,e[76]=T,e[77]=$,e[78]=le):le=e[78],le},"yt"),Qt=c(t=>{let e=(0,H.c)(40),{onClose:r,onDone:d,organizationId:h}=t,i=oe(),o=Q(),{busy:l,error:n,run:m}=se(),[s,f]=(0,F.useState)(""),[u,b]=(0,F.useState)(""),v;e[0]!==i||e[1]!==r||e[2]!==d||e[3]!==h||e[4]!==u||e[5]!==m||e[6]!==s?(v=c(()=>{m(async()=>{await i.addAuthOrgMember({organizationId:h,role:u.trim()===""?void 0:u.trim(),userId:s.trim()}),d(),r()})},"p"),e[0]=i,e[1]=r,e[2]=d,e[3]=h,e[4]=u,e[5]=m,e[6]=s,e[7]=v):v=e[7];let g=v,p;e[8]!==s?(p=s.trim(),e[8]=s,e[9]=p):p=e[9];let k=p!=="",y;e[10]!==o?(y=o("Add member"),e[10]=o,e[11]=y):y=e[11];let I;e[12]!==o?(I=o("Add member"),e[12]=o,e[13]=I):I=e[13];let C;e[14]!==o?(C=o("User id"),e[14]=o,e[15]=C):C=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=c($=>{f($.target.value)},"I"),e[16]=w):w=e[16];let x;e[17]!==s?(x=(0,a.jsx)(V,{"data-testid":"org-add-member-user",id:"org-add-member-user",onChange:w,value:s}),e[17]=s,e[18]=x):x=e[18];let z;e[19]!==C||e[20]!==x?(z=(0,a.jsx)(G,{htmlFor:"org-add-member-user",label:C,children:x}),e[19]=C,e[20]=x,e[21]=z):z=e[21];let N;e[22]!==o?(N=o("Role (optional)"),e[22]=o,e[23]=N):N=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=c($=>{b($.target.value)},"O"),e[24]=_):_=e[24];let D;e[25]!==u?(D=(0,a.jsx)(V,{"data-testid":"org-add-member-role",id:"org-add-member-role",onChange:_,value:u}),e[25]=u,e[26]=D):D=e[26];let O;e[27]!==N||e[28]!==D?(O=(0,a.jsx)(G,{htmlFor:"org-add-member-role",label:N,children:D}),e[27]=N,e[28]=D,e[29]=O):O=e[29];let T;return e[30]!==l||e[31]!==n||e[32]!==r||e[33]!==g||e[34]!==O||e[35]!==k||e[36]!==y||e[37]!==I||e[38]!==z?(T=(0,a.jsxs)(ce,{busy:l,canSubmit:k,error:n,onClose:r,onSubmit:g,submitLabel:y,testId:"org-add-member",title:I,children:[z,O]}),e[30]=l,e[31]=n,e[32]=r,e[33]=g,e[34]=O,e[35]=k,e[36]=y,e[37]=I,e[38]=z,e[39]=T):T=e[39],T},"Jt"),Zt=c(t=>{let e=(0,H.c)(40),{onClose:r,onDone:d,organizationId:h}=t,i=oe(),o=Q(),{busy:l,error:n,run:m}=se(),[s,f]=(0,F.useState)(""),[u,b]=(0,F.useState)(""),v;e[0]!==i||e[1]!==s||e[2]!==r||e[3]!==d||e[4]!==h||e[5]!==u||e[6]!==m?(v=c(()=>{m(async()=>{await i.inviteAuthOrgMember({email:s.trim(),organizationId:h,role:u.trim()===""?void 0:u.trim()}),d(),r()})},"p"),e[0]=i,e[1]=s,e[2]=r,e[3]=d,e[4]=h,e[5]=u,e[6]=m,e[7]=v):v=e[7];let g=v,p;e[8]!==s?(p=s.trim(),e[8]=s,e[9]=p):p=e[9];let k=p!=="",y;e[10]!==o?(y=o("Send invitation"),e[10]=o,e[11]=y):y=e[11];let I;e[12]!==o?(I=o("Invite member"),e[12]=o,e[13]=I):I=e[13];let C;e[14]!==o?(C=o("email"),e[14]=o,e[15]=C):C=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=c($=>{f($.target.value)},"I"),e[16]=w):w=e[16];let x;e[17]!==s?(x=(0,a.jsx)(V,{"data-testid":"org-invite-member-email",id:"org-invite-member-email",onChange:w,type:"email",value:s}),e[17]=s,e[18]=x):x=e[18];let z;e[19]!==C||e[20]!==x?(z=(0,a.jsx)(G,{htmlFor:"org-invite-member-email",label:C,children:x}),e[19]=C,e[20]=x,e[21]=z):z=e[21];let N;e[22]!==o?(N=o("Role (optional)"),e[22]=o,e[23]=N):N=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=c($=>{b($.target.value)},"O"),e[24]=_):_=e[24];let D;e[25]!==u?(D=(0,a.jsx)(V,{"data-testid":"org-invite-member-role",id:"org-invite-member-role",onChange:_,value:u}),e[25]=u,e[26]=D):D=e[26];let O;e[27]!==N||e[28]!==D?(O=(0,a.jsx)(G,{htmlFor:"org-invite-member-role",label:N,children:D}),e[27]=N,e[28]=D,e[29]=O):O=e[29];let T;return e[30]!==l||e[31]!==n||e[32]!==r||e[33]!==g||e[34]!==O||e[35]!==k||e[36]!==y||e[37]!==I||e[38]!==z?(T=(0,a.jsxs)(ce,{busy:l,canSubmit:k,error:n,onClose:r,onSubmit:g,submitLabel:y,testId:"org-invite-member",title:I,children:[z,O]}),e[30]=l,e[31]=n,e[32]=r,e[33]=g,e[34]=O,e[35]=k,e[36]=y,e[37]=I,e[38]=z,e[39]=T):T=e[39],T},"Ut"),Yt=c(t=>{let e=(0,H.c)(32),{member:r,onClose:d,onDone:h}=t,i=oe(),o=Q(),{busy:l,error:n,run:m}=se(),s;e[0]!==r.role?(s=c(()=>A(r.role),"a"),e[0]=r.role,e[1]=s):s=e[1];let[f,u]=(0,F.useState)(s),b;e[2]!==i||e[3]!==r.id||e[4]!==d||e[5]!==h||e[6]!==f||e[7]!==m?(b=c(()=>{m(async()=>{await i.setAuthOrgMemberRole({memberId:A(r.id),role:f.trim()}),h(),d()})},"g"),e[2]=i,e[3]=r.id,e[4]=d,e[5]=h,e[6]=f,e[7]=m,e[8]=b):b=e[8];let v=b,g;e[9]!==f?(g=f.trim(),e[9]=f,e[10]=g):g=e[10];let p=g!=="",k;e[11]!==o?(k=o("Save"),e[11]=o,e[12]=k):k=e[12];let y;e[13]!==o?(y=o("Change member role"),e[13]=o,e[14]=y):y=e[14];let I;e[15]!==o?(I=o("Role"),e[15]=o,e[16]=I):I=e[16];let C;e[17]===Symbol.for("react.memo_cache_sentinel")?(C=c(N=>{u(N.target.value)},"y"),e[17]=C):C=e[17];let w;e[18]!==f?(w=(0,a.jsx)(V,{"data-testid":"org-member-role-value",id:"org-member-role-value",onChange:C,value:f}),e[18]=f,e[19]=w):w=e[19];let x;e[20]!==I||e[21]!==w?(x=(0,a.jsx)(G,{htmlFor:"org-member-role-value",label:I,children:w}),e[20]=I,e[21]=w,e[22]=x):x=e[22];let z;return e[23]!==l||e[24]!==n||e[25]!==d||e[26]!==v||e[27]!==x||e[28]!==p||e[29]!==k||e[30]!==y?(z=(0,a.jsx)(ce,{busy:l,canSubmit:p,error:n,onClose:d,onSubmit:v,submitLabel:k,testId:"org-member-role",title:y,children:x}),e[23]=l,e[24]=n,e[25]=d,e[26]=v,e[27]=x,e[28]=p,e[29]=k,e[30]=y,e[31]=z):z=e[31],z},"Gt"),Mt=c(t=>{let e=(0,H.c)(36),{mode:r,onClose:d,onDone:h,organizationId:i,team:o}=t,l=oe(),n=Q(),{busy:m,error:s,run:f}=se(),u;e[0]!==o?(u=o?A(o.name):"",e[0]=o,e[1]=u):u=e[1];let[b,v]=(0,F.useState)(u),g;e[2]!==l||e[3]!==r||e[4]!==b||e[5]!==d||e[6]!==h||e[7]!==i||e[8]!==f||e[9]!==o?.id?(g=c(()=>{f(async()=>{await(r==="create"?l.createAuthOrgTeam({name:b.trim(),organizationId:i}):l.updateAuthOrgTeam({name:b.trim(),teamId:A(o?.id)})),h(),d()})},"f"),e[2]=l,e[3]=r,e[4]=b,e[5]=d,e[6]=h,e[7]=i,e[8]=f,e[9]=o?.id,e[10]=g):g=e[10];let p=g,k;e[11]!==b?(k=b.trim(),e[11]=b,e[12]=k):k=e[12];let y=k!=="",I;e[13]!==r||e[14]!==n?(I=n(r==="create"?"Create":"Save"),e[13]=r,e[14]=n,e[15]=I):I=e[15];let C;e[16]!==r||e[17]!==n?(C=n(r==="create"?"New team":"Rename team"),e[16]=r,e[17]=n,e[18]=C):C=e[18];let w;e[19]!==n?(w=n("name"),e[19]=n,e[20]=w):w=e[20];let x;e[21]===Symbol.for("react.memo_cache_sentinel")?(x=c(D=>{v(D.target.value)},"x"),e[21]=x):x=e[21];let z;e[22]!==b?(z=(0,a.jsx)(V,{"data-testid":"org-team-form-name",id:"org-team-form-name",onChange:x,value:b}),e[22]=b,e[23]=z):z=e[23];let N;e[24]!==w||e[25]!==z?(N=(0,a.jsx)(G,{htmlFor:"org-team-form-name",label:w,children:z}),e[24]=w,e[25]=z,e[26]=N):N=e[26];let _;return e[27]!==m||e[28]!==s||e[29]!==d||e[30]!==p||e[31]!==N||e[32]!==y||e[33]!==I||e[34]!==C?(_=(0,a.jsx)(ce,{busy:m,canSubmit:y,error:s,onClose:d,onSubmit:p,submitLabel:I,testId:"org-team-form",title:C,children:N}),e[27]=m,e[28]=s,e[29]=d,e[30]=p,e[31]=N,e[32]=y,e[33]=I,e[34]=C,e[35]=_):_=e[35],_},"Ct"),qt=c(t=>{let e=(0,H.c)(30),{onClose:r,onDone:d,teamId:h}=t,i=oe(),o=Q(),{busy:l,error:n,run:m}=se(),[s,f]=(0,F.useState)(""),u;e[0]!==i||e[1]!==r||e[2]!==d||e[3]!==m||e[4]!==h||e[5]!==s?(u=c(()=>{m(async()=>{await i.addAuthOrgTeamMember({teamId:h,userId:s.trim()}),d(),r()})},"c"),e[0]=i,e[1]=r,e[2]=d,e[3]=m,e[4]=h,e[5]=s,e[6]=u):u=e[6];let b=u,v;e[7]!==s?(v=s.trim(),e[7]=s,e[8]=v):v=e[8];let g=v!=="",p;e[9]!==o?(p=o("Add member"),e[9]=o,e[10]=p):p=e[10];let k;e[11]!==o?(k=o("Add team member"),e[11]=o,e[12]=k):k=e[12];let y;e[13]!==o?(y=o("User id"),e[13]=o,e[14]=y):y=e[14];let I;e[15]===Symbol.for("react.memo_cache_sentinel")?(I=c(z=>{f(z.target.value)},"C"),e[15]=I):I=e[15];let C;e[16]!==s?(C=(0,a.jsx)(V,{"data-testid":"org-team-add-member-user",id:"org-team-add-member-user",onChange:I,value:s}),e[16]=s,e[17]=C):C=e[17];let w;e[18]!==y||e[19]!==C?(w=(0,a.jsx)(G,{htmlFor:"org-team-add-member-user",label:y,children:C}),e[18]=y,e[19]=C,e[20]=w):w=e[20];let x;return e[21]!==l||e[22]!==n||e[23]!==r||e[24]!==b||e[25]!==g||e[26]!==p||e[27]!==k||e[28]!==w?(x=(0,a.jsx)(ce,{busy:l,canSubmit:g,error:n,onClose:r,onSubmit:b,submitLabel:p,testId:"org-team-add-member",title:k,children:w}),e[21]=l,e[22]=n,e[23]=r,e[24]=b,e[25]=g,e[26]=p,e[27]=k,e[28]=w,e[29]=x):x=e[29],x},"Ht"),Ft=c(t=>{let e=(0,H.c)(47),{mode:r,onClose:d,onDone:h,organizationId:i,role:o}=t,l=oe(),n=Q(),{busy:m,error:s,run:f}=se(),u;e[0]!==o?(u=o?A(o.role):"",e[0]=o,e[1]=u):u=e[1];let[b,v]=(0,F.useState)(u),g;e[2]!==r||e[3]!==o?.permission?(g=r==="edit"?Pt(o?.permission):"",e[2]=r,e[3]=o?.permission,e[4]=g):g=e[4];let[p,k]=(0,F.useState)(g),y;e[5]!==l||e[6]!==r||e[7]!==b||e[8]!==d||e[9]!==h||e[10]!==i||e[11]!==p||e[12]!==o?.id||e[13]!==f?(y=c(()=>{f(async()=>{let $=Kt(p);await(r==="create"?l.createAuthOrgRole({organizationId:i,permission:$,role:b.trim()}):l.updateAuthOrgRole({permission:$,roleId:A(o?.id)})),h(),d()})},"v"),e[5]=l,e[6]=r,e[7]=b,e[8]=d,e[9]=h,e[10]=i,e[11]=p,e[12]=o?.id,e[13]=f,e[14]=y):y=e[14];let I=y,C;e[15]!==r||e[16]!==b||e[17]!==p?(C=p.trim()!==""&&(r==="edit"||b.trim()!==""),e[15]=r,e[16]=b,e[17]=p,e[18]=C):C=e[18];let w;e[19]!==r||e[20]!==n?(w=n(r==="create"?"Create":"Save"),e[19]=r,e[20]=n,e[21]=w):w=e[21];let x;e[22]!==r||e[23]!==n?(x=n(r==="create"?"New role":"Edit role"),e[22]=r,e[23]=n,e[24]=x):x=e[24];let z;e[25]!==r||e[26]!==b||e[27]!==n?(z=r==="create"&&(0,a.jsx)(G,{htmlFor:"org-role-form-name",label:n("Role name"),children:(0,a.jsx)(V,{"data-testid":"org-role-form-name",id:"org-role-form-name",onChange:c($=>{v($.target.value)},"onChange"),value:b})}),e[25]=r,e[26]=b,e[27]=n,e[28]=z):z=e[28];let N;e[29]!==n?(N=n('Permission (JSON, e.g. {"project":["create","update"]})'),e[29]=n,e[30]=N):N=e[30];let _;e[31]===Symbol.for("react.memo_cache_sentinel")?(_=c($=>{k($.target.value)},"O"),e[31]=_):_=e[31];let D;e[32]!==p?(D=(0,a.jsx)(wt,{"data-testid":"org-role-form-permission",id:"org-role-form-permission",onChange:_,value:p}),e[32]=p,e[33]=D):D=e[33];let O;e[34]!==D||e[35]!==N?(O=(0,a.jsx)(G,{htmlFor:"org-role-form-permission",label:N,children:D}),e[34]=D,e[35]=N,e[36]=O):O=e[36];let T;return e[37]!==m||e[38]!==s||e[39]!==d||e[40]!==I||e[41]!==O||e[42]!==C||e[43]!==w||e[44]!==x||e[45]!==z?(T=(0,a.jsxs)(ce,{busy:m,canSubmit:C,error:s,onClose:d,onSubmit:I,submitLabel:w,testId:"org-role-form",title:x,children:[z,O]}),e[37]=m,e[38]=s,e[39]=d,e[40]=I,e[41]=O,e[42]=C,e[43]=w,e[44]=x,e[45]=z,e[46]=T):T=e[46],T},"xt"),Bt=c(t=>{let e=(0,H.c)(18),{action:r,message:d,onClose:h,onDone:i,testId:o,title:l}=t,n=Q(),{busy:m,error:s,run:f}=se(),u;e[0]!==r||e[1]!==h||e[2]!==i||e[3]!==f?(u=c(()=>{f(async()=>{await r(),i(),h()})},"c"),e[0]=r,e[1]=h,e[2]=i,e[3]=f,e[4]=u):u=e[4];let b=u,v;e[5]!==n?(v=n("Delete"),e[5]=n,e[6]=v):v=e[6];let g;e[7]!==d?(g=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:d}),e[7]=d,e[8]=g):g=e[8];let p;return e[9]!==m||e[10]!==s||e[11]!==h||e[12]!==b||e[13]!==v||e[14]!==g||e[15]!==o||e[16]!==l?(p=(0,a.jsx)(ce,{busy:m,canSubmit:!0,destructive:!0,error:s,onClose:h,onSubmit:b,submitLabel:v,testId:o,title:l,children:g}),e[9]=m,e[10]=s,e[11]=h,e[12]=b,e[13]=v,e[14]=g,e[15]=o,e[16]=l,e[17]=p):p=e[17],p},"Mt"),Xe=c(t=>{let e=(0,H.c)(13),{action:r,children:d,heading:h,testId:i}=t,o;e[0]!==h?(o=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h}),e[0]=h,e[1]=o):o=e[1];let l;e[2]!==r?(l=r!==void 0&&(0,a.jsx)("div",{className:"flex items-center gap-2",children:r}),e[2]=r,e[3]=l):l=e[3];let n;e[4]!==o||e[5]!==l?(n=(0,a.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[o,l]}),e[4]=o,e[5]=l,e[6]=n):n=e[6];let m;e[7]!==d?(m=(0,a.jsx)(yt,{className:"px-0",children:d}),e[7]=d,e[8]=m):m=e[8];let s;return e[9]!==n||e[10]!==m||e[11]!==i?(s=(0,a.jsxs)(vt,{className:"overflow-hidden py-0","data-testid":i,children:[n,m]}),e[9]=n,e[10]=m,e[11]=i,e[12]=s):s=e[12],s},"We"),We=c(t=>{let e=(0,H.c)(23),{columns:r,rowActions:d,rowPrefix:h,rows:i}=t,o=Q(),l;e[0]!==r?(l=r.map(Gt),e[0]=r,e[1]=l):l=e[1];let n;e[2]!==o?(n=o("Actions"),e[2]=o,e[3]=n):n=e[3];let m;e[4]!==n?(m=(0,a.jsx)(me,{"aria-label":n}),e[4]=n,e[5]=m):m=e[5];let s;e[6]!==l||e[7]!==m?(s=(0,a.jsx)(It,{children:(0,a.jsxs)(Ve,{children:[l,m]})}),e[6]=l,e[7]=m,e[8]=s):s=e[8];let f;if(e[9]!==r||e[10]!==d||e[11]!==h||e[12]!==i){let v;e[14]!==r||e[15]!==d||e[16]!==h?(v=c((g,p)=>{let k=A(g.id),y=k===""?`index-${p.toString()}`:k;return(0,a.jsxs)(Ve,{"data-testid":`${h}-${y}`,children:[r.map(I=>(0,a.jsx)(de,{className:I.className,children:I.render(g)},I.head)),(0,a.jsx)(de,{children:(0,a.jsx)("div",{className:"flex justify-end gap-1",children:d(g)})})]},y)},"p"),e[14]=r,e[15]=d,e[16]=h,e[17]=v):v=e[17],f=i.map(v),e[9]=r,e[10]=d,e[11]=h,e[12]=i,e[13]=f}else f=e[13];let u;e[18]!==f?(u=(0,a.jsx)(xt,{children:f}),e[18]=f,e[19]=u):u=e[19];let b;return e[20]!==s||e[21]!==u?(b=(0,a.jsxs)(Ct,{children:[s,u]}),e[20]=s,e[21]=u,e[22]=b):b=e[22],b},"Xe");function Gt(t){return(0,a.jsx)(me,{children:t.head},t.head)}c(Gt,"Zt");var Vt=c(t=>{let e=(0,H.c)(30),{actionBusy:r,onRemoveMember:d,memberColumns:h,members:i,onDialog:o}=t,l=Q(),n;e[0]!==o?(n=c(()=>{o({kind:"add-member"})},"r"),e[0]=o,e[1]=n):n=e[1];let m;e[2]!==l?(m=l("Add member"),e[2]=l,e[3]=m):m=e[3];let s;e[4]!==n||e[5]!==m?(s=(0,a.jsx)(j,{"data-testid":"org-open-add-member",onClick:n,size:"xs",type:"button",variant:"outline",children:m}),e[4]=n,e[5]=m,e[6]=s):s=e[6];let f;e[7]!==o?(f=c(()=>{o({kind:"invite-member"})},"h"),e[7]=o,e[8]=f):f=e[8];let u;e[9]!==l?(u=l("Invite member"),e[9]=l,e[10]=u):u=e[10];let b;e[11]!==f||e[12]!==u?(b=(0,a.jsx)(j,{"data-testid":"org-open-invite-member",onClick:f,size:"xs",type:"button",variant:"outline",children:u}),e[11]=f,e[12]=u,e[13]=b):b=e[13];let v;e[14]!==s||e[15]!==b?(v=(0,a.jsxs)(a.Fragment,{children:[s,b]}),e[14]=s,e[15]=b,e[16]=v):v=e[16];let g;e[17]!==l?(g=l("Members"),e[17]=l,e[18]=g):g=e[18];let p;e[19]!==r||e[20]!==h||e[21]!==i||e[22]!==o||e[23]!==d||e[24]!==l?(p=i.length===0?(0,a.jsx)("div",{className:"p-3",children:(0,a.jsx)(ue,{testId:"org-members-empty",title:l("No members.")})}):(0,a.jsx)(We,{columns:h,rowActions:c(y=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(j,{"data-testid":`org-member-role-${A(y.id)}`,onClick:c(()=>{o({kind:"member-role",member:y})},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Change role")}),(0,a.jsx)(j,{"data-testid":`org-remove-member-${A(y.id)}`,disabled:r,onClick:c(()=>{d(A(y.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Remove")})]}),"rowActions"),rowPrefix:"org-member",rows:i}),e[19]=r,e[20]=h,e[21]=i,e[22]=o,e[23]=d,e[24]=l,e[25]=p):p=e[25];let k;return e[26]!==v||e[27]!==g||e[28]!==p?(k=(0,a.jsx)(Xe,{action:v,heading:g,testId:"org-members",children:p}),e[26]=v,e[27]=g,e[28]=p,e[29]=k):k=e[29],k},"qt"),Xt=c(t=>{let e=(0,H.c)(21),{onConfirmDeleteTeam:r,onDialog:d,onSelectTeam:h,selectedTeam:i,teamColumns:o,teams:l}=t,n=Q(),m;e[0]!==d?(m=c(()=>{d({kind:"team-create"})},"m"),e[0]=d,e[1]=m):m=e[1];let s;e[2]!==n?(s=n("New team"),e[2]=n,e[3]=s):s=e[3];let f;e[4]!==m||e[5]!==s?(f=(0,a.jsx)(j,{"data-testid":"org-open-create-team",onClick:m,size:"xs",type:"button",variant:"outline",children:s}),e[4]=m,e[5]=s,e[6]=f):f=e[6];let u;e[7]!==n?(u=n("Teams"),e[7]=n,e[8]=u):u=e[8];let b;e[9]!==r||e[10]!==d||e[11]!==h||e[12]!==i||e[13]!==n||e[14]!==o||e[15]!==l?(b=l.length===0?(0,a.jsx)("div",{className:"p-3",children:(0,a.jsx)(ue,{testId:"org-teams-empty",title:n("No teams.")})}):(0,a.jsx)(We,{columns:o,rowActions:c(g=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(j,{"aria-pressed":i===A(g.id),"data-testid":`org-team-select-${A(g.id)}`,onClick:c(()=>{h(A(g.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Members")}),(0,a.jsx)(j,{"data-testid":`org-team-rename-${A(g.id)}`,onClick:c(()=>{d({kind:"team-rename",team:g})},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Rename")}),(0,a.jsx)(j,{"data-testid":`org-team-delete-${A(g.id)}`,onClick:c(()=>{r(g)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Delete")})]}),"rowActions"),rowPrefix:"org-team",rows:l}),e[9]=r,e[10]=d,e[11]=h,e[12]=i,e[13]=n,e[14]=o,e[15]=l,e[16]=b):b=e[16];let v;return e[17]!==f||e[18]!==u||e[19]!==b?(v=(0,a.jsx)(Xe,{action:f,heading:u,testId:"org-teams",children:b}),e[17]=f,e[18]=u,e[19]=b,e[20]=v):v=e[20],v},"Kt"),Wt=c(t=>{let e=(0,H.c)(20),{actionBusy:r,onRemoveTeamMember:d,onDialog:h,selectedTeam:i,teamMemberColumns:o,teamMembers:l}=t,n=Q(),m;e[0]!==h||e[1]!==i?(m=c(()=>{h({kind:"team-add-member",teamId:i})},"m"),e[0]=h,e[1]=i,e[2]=m):m=e[2];let s;e[3]!==n?(s=n("Add member"),e[3]=n,e[4]=s):s=e[4];let f;e[5]!==m||e[6]!==s?(f=(0,a.jsx)(j,{"data-testid":"org-open-add-team-member",onClick:m,size:"xs",type:"button",variant:"outline",children:s}),e[5]=m,e[6]=s,e[7]=f):f=e[7];let u;e[8]!==n?(u=n("Team members"),e[8]=n,e[9]=u):u=e[9];let b;e[10]!==r||e[11]!==d||e[12]!==n||e[13]!==o||e[14]!==l?(b=l.length===0?(0,a.jsx)("div",{className:"p-3",children:(0,a.jsx)(ue,{testId:"org-team-members-empty",title:n("No team members.")})}):(0,a.jsx)(We,{columns:o,rowActions:c(g=>(0,a.jsx)(j,{"data-testid":`org-team-remove-member-${A(g.id)}`,disabled:r,onClick:c(()=>{d(A(g.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Remove")}),"rowActions"),rowPrefix:"org-team-member",rows:l}),e[10]=r,e[11]=d,e[12]=n,e[13]=o,e[14]=l,e[15]=b):b=e[15];let v;return e[16]!==f||e[17]!==u||e[18]!==b?(v=(0,a.jsx)(Xe,{action:f,heading:u,testId:"org-team-members",children:b}),e[16]=f,e[17]=u,e[18]=b,e[19]=v):v=e[19],v},"Vt"),er=c(t=>{let e=(0,H.c)(19),{onConfirmDeleteRole:r,onDialog:d,roleColumns:h,roles:i}=t,o=Q(),l;e[0]!==d?(l=c(()=>{d({kind:"role-create"})},"i"),e[0]=d,e[1]=l):l=e[1];let n;e[2]!==o?(n=o("New role"),e[2]=o,e[3]=n):n=e[3];let m;e[4]!==l||e[5]!==n?(m=(0,a.jsx)(j,{"data-testid":"org-open-create-role",onClick:l,size:"xs",type:"button",variant:"outline",children:n}),e[4]=l,e[5]=n,e[6]=m):m=e[6];let s;e[7]!==o?(s=o("Roles"),e[7]=o,e[8]=s):s=e[8];let f;e[9]!==r||e[10]!==d||e[11]!==h||e[12]!==i||e[13]!==o?(f=i.length===0?(0,a.jsx)("div",{className:"p-3",children:(0,a.jsx)(ue,{testId:"org-roles-empty",title:o("No custom roles.")})}):(0,a.jsx)(We,{columns:h,rowActions:c(b=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(j,{"data-testid":`org-role-edit-${A(b.id)}`,onClick:c(()=>{d({kind:"role-edit",role:b})},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Edit")}),(0,a.jsx)(j,{"data-testid":`org-role-delete-${A(b.id)}`,onClick:c(()=>{r(A(b.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Delete")})]}),"rowActions"),rowPrefix:"org-role",rows:i}),e[9]=r,e[10]=d,e[11]=h,e[12]=i,e[13]=o,e[14]=f):f=e[14];let u;return e[15]!==m||e[16]!==s||e[17]!==f?(u=(0,a.jsx)(Xe,{action:m,heading:s,testId:"org-roles",children:f}),e[15]=m,e[16]=s,e[17]=f,e[18]=u):u=e[18],u},"Wt"),Et=200,tr=c(t=>{let e=(0,H.c)(207),{organizationId:r,rolesEnabled:d,teamsEnabled:h}=t,i=oe(),o=Q(),[l,n]=(0,F.useState)(null),[m,s]=(0,F.useState)(null),[f,u]=(0,F.useState)(!1),[b,v]=(0,F.useState)(null),[g,p]=_t(r),k;e[0]!==g||e[1]!==r?(k=["lunora-auth-org-members",r,g],e[0]=g,e[1]=r,e[2]=k):k=e[2];let y;e[3]!==i||e[4]!==g||e[5]!==r?(y=c(()=>i.listAuthOrgMembers({limit:Et,offset:g,organizationId:r}),"v"),e[3]=i,e[4]=g,e[5]=r,e[6]=y):y=e[6];let I=ge(k,y),C;e[7]!==r?(C=["lunora-auth-org-invitations",r],e[7]=r,e[8]=C):C=e[8];let w;e[9]!==i||e[10]!==r?(w=c(()=>i.listAuthOrgInvitations({limit:200,organizationId:r}),"I"),e[9]=i,e[10]=r,e[11]=w):w=e[11];let x=ge(C,w),z;e[12]!==r?(z=["lunora-auth-org-teams",r],e[12]=r,e[13]=z):z=e[13];let N;e[14]!==i||e[15]!==r?(N=c(()=>i.listAuthOrgTeams({limit:200,organizationId:r}),"D"),e[14]=i,e[15]=r,e[16]=N):N=e[16];let _;e[17]!==h?(_={enabled:h},e[17]=h,e[18]=_):_=e[18];let D=ge(z,N,_),O;e[19]!==r?(O=["lunora-auth-org-roles",r],e[19]=r,e[20]=O):O=e[20];let T;e[21]!==i||e[22]!==r?(T=c(()=>i.listAuthOrgRoles({limit:200,organizationId:r}),"_"),e[21]=i,e[22]=r,e[23]=T):T=e[23];let $;e[24]!==d?($={enabled:d},e[24]=d,e[25]=$):$=e[25];let E=ge(O,T,$),Z;e[26]!==m?(Z=["lunora-auth-org-team-members",m],e[26]=m,e[27]=Z):Z=e[27];let B;e[28]!==i||e[29]!==m?(B=c(()=>i.listAuthOrgTeamMembers({limit:200,teamId:m??""}),"B"),e[28]=i,e[29]=m,e[30]=B):B=e[30];let K=m!==null,J;e[31]!==K?(J={enabled:K},e[31]=K,e[32]=J):J=e[32];let P=ge(Z,B,J),U;e[33]!==I.data?.rows?(U=I.data?.rows??[],e[33]=I.data?.rows,e[34]=U):U=e[34];let L=U,Y;e[35]!==x.data?.rows?(Y=x.data?.rows??[],e[35]=x.data?.rows,e[36]=Y):Y=e[36];let M=Y,R;e[37]!==D.data?.rows?(R=D.data?.rows??[],e[37]=D.data?.rows,e[38]=R):R=e[38];let q=R,W;e[39]!==E.data?.rows?(W=E.data?.rows??[],e[39]=E.data?.rows,e[40]=W):W=e[40];let te=W,ae;e[41]!==m||e[42]!==P?(ae=m===null?[]:P.data?.rows??[],e[41]=m,e[42]=P,e[43]=ae):ae=e[43];let re=ae,ee=I.error??x.error??D.error??E.error??P.error,le;e[44]!==x||e[45]!==I||e[46]!==d||e[47]!==E||e[48]!==m||e[49]!==P||e[50]!==h||e[51]!==D?(le=c(()=>{I.refetch(),x.refetch(),h&&D.refetch(),d&&E.refetch(),m!==null&&P.refetch()},"ie"),e[44]=x,e[45]=I,e[46]=d,e[47]=E,e[48]=m,e[49]=P,e[50]=h,e[51]=D,e[52]=le):le=e[52];let S=le;kt(S,!0);let et;e[53]===Symbol.for("react.memo_cache_sentinel")?(et=c(()=>{n(null)},"Ye"),e[53]=et):et=e[53];let ne=et,tt;e[54]!==S?(tt=c(X=>{At((async()=>{u(!0),v(null);try{await X(),S(),u(!1)}catch(mt){v(Nt(mt)),u(!1)}})())},"et"),e[54]=S,e[55]=tt):tt=e[55];let ie=tt,rt;e[56]!==i||e[57]!==o?(rt=c(X=>{let mt=A(X.id);n({action:c(async()=>{await i.removeAuthOrgTeam({teamId:mt}),s(St=>St===mt?null:St)},"action"),kind:"confirm",message:o("Delete this team and its memberships? This cannot be undone."),testId:"org-team-delete",title:o("Delete team")})},"tt"),e[56]=i,e[57]=o,e[58]=rt):rt=e[58];let dt=rt,he;e[59]!==o?(he=o("userId"),e[59]=o,e[60]=he):he=e[60];let be;e[61]!==he?(be={head:he,render:rr},e[61]=he,e[62]=be):be=e[62];let fe;e[63]!==o?(fe=o("role"),e[63]=o,e[64]=fe):fe=e[64];let pe;e[65]!==fe?(pe={head:fe,render:or},e[65]=fe,e[66]=pe):pe=e[66];let ot;e[67]!==be||e[68]!==pe?(ot=[be,pe],e[67]=be,e[68]=pe,e[69]=ot):ot=e[69];let ct=ot,ve;e[70]!==o?(ve=o("email"),e[70]=o,e[71]=ve):ve=e[71];let ye;e[72]!==ve?(ye={head:ve,render:ar},e[72]=ve,e[73]=ye):ye=e[73];let Ce;e[74]!==o?(Ce=o("role"),e[74]=o,e[75]=Ce):Ce=e[75];let Ie;e[76]!==Ce?(Ie={head:Ce,render:lr},e[76]=Ce,e[77]=Ie):Ie=e[77];let xe;e[78]!==o?(xe=o("status"),e[78]=o,e[79]=xe):xe=e[79];let we;e[80]!==xe?(we={head:xe,render:nr},e[80]=xe,e[81]=we):we=e[81];let at;e[82]!==ye||e[83]!==Ie||e[84]!==we?(at=[ye,Ie,we],e[82]=ye,e[83]=Ie,e[84]=we,e[85]=at):at=e[85];let ut=at,ke;e[86]!==o?(ke=o("id"),e[86]=o,e[87]=ke):ke=e[87];let ze;e[88]!==ke?(ze={className:"font-mono text-xs",head:ke,render:ir},e[88]=ke,e[89]=ze):ze=e[89];let Se;e[90]!==o?(Se=o("name"),e[90]=o,e[91]=Se):Se=e[91];let Ne;e[92]!==Se?(Ne={head:Se,render:sr},e[92]=Se,e[93]=Ne):Ne=e[93];let lt;e[94]!==ze||e[95]!==Ne?(lt=[ze,Ne],e[94]=ze,e[95]=Ne,e[96]=lt):lt=e[96];let gt=lt,Ae;e[97]!==o?(Ae=o("userId"),e[97]=o,e[98]=Ae):Ae=e[98];let nt;e[99]!==Ae?(nt=[{head:Ae,render:mr}],e[99]=Ae,e[100]=nt):nt=e[100];let ht=nt,De;e[101]!==o?(De=o("role"),e[101]=o,e[102]=De):De=e[102];let Oe;e[103]!==De?(Oe={head:De,render:dr},e[103]=De,e[104]=Oe):Oe=e[104];let _e;e[105]!==o?(_e=o("Permission"),e[105]=o,e[106]=_e):_e=e[106];let Te;e[107]!==_e?(Te={className:"font-mono text-xs whitespace-pre-wrap",head:_e,render:cr},e[107]=_e,e[108]=Te):Te=e[108];let it;e[109]!==Oe||e[110]!==Te?(it=[Oe,Te],e[109]=Oe,e[110]=Te,e[111]=it):it=e[111];let bt=it,$e;e[112]!==ee?($e=ee!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-detail-error",role:"alert",children:ee}),e[112]=ee,e[113]=$e):$e=e[113];let Re;e[114]!==b?(Re=b!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-action-error",role:"alert",children:b}),e[114]=b,e[115]=Re):Re=e[115];let Me;e[116]!==i||e[117]!==ie?(Me=c(X=>{ie(()=>i.removeAuthOrgMember({memberId:X}))},"$e"),e[116]=i,e[117]=ie,e[118]=Me):Me=e[118];let Fe;e[119]!==f||e[120]!==ct||e[121]!==L||e[122]!==Me?(Fe=(0,a.jsx)(Vt,{actionBusy:f,memberColumns:ct,members:L,onDialog:n,onRemoveMember:Me}),e[119]=f,e[120]=ct,e[121]=L,e[122]=Me,e[123]=Fe):Fe=e[123];let ft=I.data?.total,Ee;e[124]!==L.length||e[125]!==g||e[126]!==p||e[127]!==ft?(Ee=(0,a.jsx)(zt,{count:L.length,offset:g,onOffsetChange:p,pageSize:Et,prefix:"org-members",total:ft}),e[124]=L.length,e[125]=g,e[126]=p,e[127]=ft,e[128]=Ee):Ee=e[128];let je;e[129]!==f||e[130]!==i||e[131]!==ut||e[132]!==M||e[133]!==ie||e[134]!==o?(je=M.length>0&&(0,a.jsx)(Xe,{heading:o("Invitations"),testId:"org-invitations",children:(0,a.jsx)(We,{columns:ut,rowActions:c(X=>(0,a.jsx)(j,{"data-testid":`org-cancel-invitation-${A(X.id)}`,disabled:f,onClick:c(()=>{ie(()=>i.cancelAuthOrgInvitation({invitationId:A(X.id)}))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Cancel")}),"rowActions"),rowPrefix:"org-invitation",rows:M})}),e[129]=f,e[130]=i,e[131]=ut,e[132]=M,e[133]=ie,e[134]=o,e[135]=je):je=e[135];let Le;e[136]!==dt||e[137]!==m||e[138]!==gt||e[139]!==q||e[140]!==h?(Le=h&&(0,a.jsx)(Xt,{onConfirmDeleteTeam:dt,onDialog:n,onSelectTeam:s,selectedTeam:m,teamColumns:gt,teams:q}),e[136]=dt,e[137]=m,e[138]=gt,e[139]=q,e[140]=h,e[141]=Le):Le=e[141];let Pe;e[142]!==f||e[143]!==i||e[144]!==ie||e[145]!==m||e[146]!==ht||e[147]!==re||e[148]!==h?(Pe=h&&m!==null&&(0,a.jsx)(Wt,{actionBusy:f,onDialog:n,onRemoveTeamMember:c(X=>{ie(()=>i.removeAuthOrgTeamMember({teamMemberId:X}))},"onRemoveTeamMember"),selectedTeam:m,teamMemberColumns:ht,teamMembers:re}),e[142]=f,e[143]=i,e[144]=ie,e[145]=m,e[146]=ht,e[147]=re,e[148]=h,e[149]=Pe):Pe=e[149];let Be;e[150]!==i||e[151]!==bt||e[152]!==te||e[153]!==d||e[154]!==o?(Be=d&&(0,a.jsx)(er,{onConfirmDeleteRole:c(X=>{n({action:c(()=>i.deleteAuthOrgRole({roleId:X}),"action"),kind:"confirm",message:o("Delete this custom role? Members keeping it will lose its grants."),testId:"org-role-delete",title:o("Delete role")})},"onConfirmDeleteRole"),onDialog:n,roleColumns:bt,roles:te}),e[150]=i,e[151]=bt,e[152]=te,e[153]=d,e[154]=o,e[155]=Be):Be=e[155];let Je;e[156]!==l?.kind||e[157]!==r||e[158]!==S?(Je=l?.kind==="add-member"&&(0,a.jsx)(Qt,{onClose:ne,onDone:S,organizationId:r}),e[156]=l?.kind,e[157]=r,e[158]=S,e[159]=Je):Je=e[159];let Ue;e[160]!==l?.kind||e[161]!==r||e[162]!==S?(Ue=l?.kind==="invite-member"&&(0,a.jsx)(Zt,{onClose:ne,onDone:S,organizationId:r}),e[160]=l?.kind,e[161]=r,e[162]=S,e[163]=Ue):Ue=e[163];let He;e[164]!==l||e[165]!==S?(He=l?.kind==="member-role"&&(0,a.jsx)(Yt,{member:l.member,onClose:ne,onDone:S}),e[164]=l,e[165]=S,e[166]=He):He=e[166];let Ke;e[167]!==l?.kind||e[168]!==r||e[169]!==S?(Ke=l?.kind==="team-create"&&(0,a.jsx)(Mt,{mode:"create",onClose:ne,onDone:S,organizationId:r}),e[167]=l?.kind,e[168]=r,e[169]=S,e[170]=Ke):Ke=e[170];let Qe;e[171]!==l||e[172]!==r||e[173]!==S?(Qe=l?.kind==="team-rename"&&(0,a.jsx)(Mt,{mode:"edit",onClose:ne,onDone:S,organizationId:r,team:l.team}),e[171]=l,e[172]=r,e[173]=S,e[174]=Qe):Qe=e[174];let Ze;e[175]!==l||e[176]!==S?(Ze=l?.kind==="team-add-member"&&(0,a.jsx)(qt,{onClose:ne,onDone:S,teamId:l.teamId}),e[175]=l,e[176]=S,e[177]=Ze):Ze=e[177];let Ye;e[178]!==l?.kind||e[179]!==r||e[180]!==S?(Ye=l?.kind==="role-create"&&(0,a.jsx)(Ft,{mode:"create",onClose:ne,onDone:S,organizationId:r}),e[178]=l?.kind,e[179]=r,e[180]=S,e[181]=Ye):Ye=e[181];let qe;e[182]!==l||e[183]!==r||e[184]!==S?(qe=l?.kind==="role-edit"&&(0,a.jsx)(Ft,{mode:"edit",onClose:ne,onDone:S,organizationId:r,role:l.role}),e[182]=l,e[183]=r,e[184]=S,e[185]=qe):qe=e[185];let Ge;e[186]!==l||e[187]!==S?(Ge=l?.kind==="confirm"&&(0,a.jsx)(Bt,{action:l.action,message:l.message,onClose:ne,onDone:S,testId:l.testId,title:l.title}),e[186]=l,e[187]=S,e[188]=Ge):Ge=e[188];let st;return e[189]!==$e||e[190]!==Re||e[191]!==Fe||e[192]!==Ee||e[193]!==je||e[194]!==Le||e[195]!==Pe||e[196]!==Be||e[197]!==Je||e[198]!==Ue||e[199]!==He||e[200]!==Ke||e[201]!==Qe||e[202]!==Ze||e[203]!==Ye||e[204]!==qe||e[205]!==Ge?(st=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"org-detail",children:[$e,Re,Fe,Ee,je,Le,Pe,Be,Je,Ue,He,Ke,Qe,Ze,Ye,qe,Ge]}),e[189]=$e,e[190]=Re,e[191]=Fe,e[192]=Ee,e[193]=je,e[194]=Le,e[195]=Pe,e[196]=Be,e[197]=Je,e[198]=Ue,e[199]=He,e[200]=Ke,e[201]=Qe,e[202]=Ze,e[203]=Ye,e[204]=qe,e[205]=Ge,e[206]=st):st=e[206],st},"Xt");function rr(t){return(0,a.jsx)("span",{className:"font-mono text-xs",children:A(t.userId)})}c(rr,"Yt");function or(t){return A(t.role)}c(or,"el");function ar(t){return A(t.email)}c(ar,"tl");function lr(t){return A(t.role)}c(lr,"ll");function nr(t){return A(t.status)}c(nr,"ol");function ir(t){return A(t.id)}c(ir,"il");function sr(t){return A(t.name)}c(sr,"rl");function mr(t){return(0,a.jsx)("span",{className:"font-mono text-xs",children:A(t.userId)})}c(mr,"nl");function dr(t){return A(t.role)}c(dr,"sl");function cr(t){return A(t.permission)}c(cr,"al");var jt=100,Ar=c(()=>{let t=(0,H.c)(69),e=oe(),r=Q(),{config:d,ready:h}=Tt(),i=d.capabilities.organization,[o,l]=(0,F.useState)(null),[n,m]=(0,F.useState)(null),[s,f]=(0,F.useState)(0),u;t[0]!==s?(u=["lunora-auth-orgs",s],t[0]=s,t[1]=u):u=t[1];let b;t[2]!==e||t[3]!==s?(b=c(()=>e.listAuthOrganizations({limit:jt,offset:s}),"g"),t[2]=e,t[3]=s,t[4]=b):b=t[4];let v;t[5]!==i?(v={enabled:i},t[5]=i,t[6]=v):v=t[6];let g=ge(u,b,v),p=g.data?.rows??null,k;t[7]!==g?(k=c(()=>{g.refetch()},"S"),t[7]=g,t[8]=k):k=t[8],kt(k,i);let y;t[9]===Symbol.for("react.memo_cache_sentinel")?(y=c(()=>{m(null)},"v"),t[9]=y):y=t[9];let I=y,C;t[10]!==g?(C=c(()=>{g.refetch()},"y"),t[10]=g,t[11]=C):C=t[11];let w=C,x;t[12]===Symbol.for("react.memo_cache_sentinel")?(x=c(M=>{l(M)},"x"),t[12]=x):x=t[12];let z=x;if(h&&!i){let M;t[13]!==r?(M=r("Enable the organization() plugin in your auth config to manage organizations here."),t[13]=r,t[14]=M):M=t[14];let R;t[15]!==r?(R=r("Organizations are not enabled."),t[15]=r,t[16]=R):R=t[16];let q;return t[17]!==M||t[18]!==R?(q=(0,a.jsx)(ue,{description:M,testId:"org-disabled",title:R}),t[17]=M,t[18]=R,t[19]=q):q=t[19],q}let N;t[20]!==r?(N=r("Organizations"),t[20]=r,t[21]=N):N=t[21];let _;t[22]!==N?(_=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:N}),t[22]=N,t[23]=_):_=t[23];let D;t[24]===Symbol.for("react.memo_cache_sentinel")?(D=c(()=>{m({kind:"create"})},"A"),t[24]=D):D=t[24];let O;t[25]!==r?(O=r("New organization"),t[25]=r,t[26]=O):O=t[26];let T;t[27]!==O?(T=(0,a.jsx)(j,{"data-testid":"org-new",onClick:D,size:"sm",type:"button",children:O}),t[27]=O,t[28]=T):T=t[28];let $;t[29]!==T||t[30]!==_?($=(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[_,T]}),t[29]=T,t[30]=_,t[31]=$):$=t[31];let E;t[32]!==g.error?(E=g.error!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-error",role:"alert",children:g.error}),t[32]=g.error,t[33]=E):E=t[33];let Z;t[34]!==p||t[35]!==r?(Z=p!==null&&p.length===0&&(0,a.jsx)(ue,{testId:"org-empty",title:r("No organizations.")}),t[34]=p,t[35]=r,t[36]=Z):Z=t[36];let B;t[37]!==p||t[38]!==o||t[39]!==r?(B=p!==null&&p.length>0&&(0,a.jsx)(vt,{className:"overflow-hidden py-0",children:(0,a.jsx)(yt,{className:"px-0",children:(0,a.jsxs)(Ct,{"data-testid":"org-table",children:[(0,a.jsx)(It,{children:(0,a.jsxs)(Ve,{children:[(0,a.jsx)(me,{children:r("id")}),(0,a.jsx)(me,{children:r("name")}),(0,a.jsx)(me,{children:r("slug")}),(0,a.jsx)(me,{children:r("created")}),(0,a.jsx)(me,{"aria-label":r("Actions")})]})}),(0,a.jsx)(xt,{children:p.map(M=>{let R=A(M.id);return(0,a.jsxs)(Ve,{"data-testid":`org-row-${R}`,children:[(0,a.jsx)(de,{className:"font-mono text-xs",children:R}),(0,a.jsx)(de,{children:A(M.name)}),(0,a.jsx)(de,{children:A(M.slug)}),(0,a.jsx)(de,{className:"text-muted-foreground tabular-nums",children:Dt(M.createdAt)}),(0,a.jsx)(de,{children:(0,a.jsxs)("div",{className:"flex justify-end gap-1",children:[(0,a.jsx)(j,{"aria-pressed":o===R,"data-testid":`org-select-${R}`,onClick:c(()=>{z(R)},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Manage")}),(0,a.jsx)(j,{"data-testid":`org-edit-${R}`,onClick:c(()=>{m({kind:"edit",org:M})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Edit")}),(0,a.jsx)(j,{"data-testid":`org-delete-${R}`,onClick:c(()=>{m({kind:"delete",org:M})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Delete")})]})})]},R)})})]})})}),t[37]=p,t[38]=o,t[39]=r,t[40]=B):B=t[40];let K;t[41]!==s||t[42]!==p||t[43]!==g.data?.total?(K=p!==null&&(0,a.jsx)(zt,{count:p.length,offset:s,onOffsetChange:f,pageSize:jt,prefix:"org",total:g.data?.total}),t[41]=s,t[42]=p,t[43]=g.data?.total,t[44]=K):K=t[44];let J;t[45]!==d.organization||t[46]!==o?(J=o!==null&&(0,a.jsx)(tr,{organizationId:o,rolesEnabled:d.organization.roles,teamsEnabled:d.organization.teams}),t[45]=d.organization,t[46]=o,t[47]=J):J=t[47];let P;t[48]!==n?.kind||t[49]!==w?(P=n?.kind==="create"&&(0,a.jsx)(Rt,{mode:"create",onClose:I,onDone:w}),t[48]=n?.kind,t[49]=w,t[50]=P):P=t[50];let U;t[51]!==n||t[52]!==w?(U=n?.kind==="edit"&&(0,a.jsx)(Rt,{mode:"edit",onClose:I,onDone:w,org:n.org}),t[51]=n,t[52]=w,t[53]=U):U=t[53];let L;t[54]!==e||t[55]!==n||t[56]!==w||t[57]!==r?(L=n?.kind==="delete"&&(0,a.jsx)(Bt,{action:c(async()=>{let M=A(n.org.id);await e.deleteAuthOrganization({organizationId:M}),l(R=>R===M?null:R)},"action"),message:r("Delete this organization? Its members, invitations, teams, and custom roles are removed. This cannot be undone."),onClose:I,onDone:w,testId:"org-delete",title:r("Delete organization")}),t[54]=e,t[55]=n,t[56]=w,t[57]=r,t[58]=L):L=t[58];let Y;return t[59]!==$||t[60]!==E||t[61]!==Z||t[62]!==B||t[63]!==K||t[64]!==J||t[65]!==P||t[66]!==U||t[67]!==L?(Y=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-organizations",children:[$,E,Z,B,K,J,P,U,L]}),t[59]=$,t[60]=E,t[61]=Z,t[62]=B,t[63]=K,t[64]=J,t[65]=P,t[66]=U,t[67]=L,t[68]=Y):Y=t[68],Y},"Al");export{Ar as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as le}from"./chunk-2W67FQCF.js";import{a as je}from"./chunk-FPI7AMQJ.js";import{a as he}from"./chunk-37WYCOQ2.js";import{a as V}from"./chunk-SA2OGF3F.js";import{d as Ne,f as ke,g as we,k as oe}from"./chunk-GHQ2VDI2.js";import{a as Pe}from"./chunk-2EYOYWS2.js";import"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import{i as ve}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as W}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as ye}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as $e}from"./chunk-4ZEL6BYL.js";import{l as F}from"./chunk-
|
|
1
|
+
import{a as le}from"./chunk-2W67FQCF.js";import{a as je}from"./chunk-FPI7AMQJ.js";import{a as he}from"./chunk-37WYCOQ2.js";import{a as V}from"./chunk-SA2OGF3F.js";import{d as Ne,f as ke,g as we,k as oe}from"./chunk-GHQ2VDI2.js";import{a as Pe}from"./chunk-2EYOYWS2.js";import"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import{i as ve}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as W}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as ye}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as $e}from"./chunk-4ZEL6BYL.js";import{l as F}from"./chunk-DTFIEXYN.js";import"./chunk-QAQDMS6R.js";import{d as be}from"./chunk-WS7WNXF3.js";import{a as U}from"./chunk-RWVIV3U7.js";import{d as J,e as Se,f as se,g as ie,h as fe,m as Ie,p as Oe,s as ae}from"./chunk-5OMZCVRF.js";import{a as u,d as K,e as me,f as te,g as re,i as ue}from"./chunk-I26MS5PJ.js";var Ge=K(te(),1),xe=K(me(),1);var Y=K(te(),1);var X=K(me(),1);var R=K(re(),1);var Ve=se($e.listTables),Xe=["react","client","cli"],Ye={action:"action",mutation:"mutation",query:"query"},Ce=u(t=>{let e=t.indexOf(":");return e===-1?{file:"",fn:t}:{file:t.slice(0,e),fn:t.slice(e+1)}},"Q"),Ze=u(({file:t,fn:e,kind:a})=>`await client.${Ye[a]}(api.${t}.${e}, { /* args */ });`,"ie"),et=u(t=>{let e=`api.${t.file}.${t.fn}`;switch(t.kind){case"action":return`const { call: ${t.fn} } = useAction(${e});`;case"mutation":return`const ${t.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},"se"),tt=u(({file:t,fn:e})=>`lunora run ${t}:${e} --args '{ }'`,"oe"),rt=u(t=>["// Read rows",`const rows = await ctx.db.query("${t}").collect();`,"","// Insert a row",`const id = await ctx.db.insert("${t}", { /* fields */ });`,"","// Generated types",`type Row = Doc<"${t}">;`,`type RowId = Id<"${t}">;`].join(`
|
|
2
2
|
`),"ce"),at=u((t,e)=>{switch(t){case"cli":return tt(e);case"client":return Ze(e);default:return et(e)}},"re"),Re=u(t=>{let e=(0,Y.c)(19),{code:a,label:r,testId:n}=t,s=J(),o;e[0]!==a?(o=u(()=>{ae(a)},"c"),e[0]=a,e[1]=o):o=e[1];let i=o,c;e[2]!==r?(c=(0,R.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:r}),e[2]=r,e[3]=c):c=e[3];let m=`${n}-copy`,l;e[4]!==s?(l=s("Copy"),e[4]=s,e[5]=l):l=e[5];let p;e[6]!==i||e[7]!==m||e[8]!==l?(p=(0,R.jsx)(W,{"data-testid":m,onClick:i,size:"xs",type:"button",variant:"ghost",children:l}),e[6]=i,e[7]=m,e[8]=l,e[9]=p):p=e[9];let f;e[10]!==c||e[11]!==p?(f=(0,R.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[c,p]}),e[10]=c,e[11]=p,e[12]=f):f=e[12];let h;e[13]!==a||e[14]!==n?(h=(0,R.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":n,children:a}),e[13]=a,e[14]=n,e[15]=h):h=e[15];let g;return e[16]!==f||e[17]!==h?(g=(0,R.jsxs)("div",{className:"flex flex-col gap-1.5",children:[f,h]}),e[16]=f,e[17]=h,e[18]=g):g=e[18],g},"U"),nt=u(t=>{let e=(0,Y.c)(46),{file:a,fn:r,kind:n}=t,s=J(),[o,i]=(0,X.useState)("react"),c,m,l;if(e[0]!==a||e[1]!==r||e[2]!==n||e[3]!==s||e[4]!==o){let w={file:a,fn:r,kind:n},j;e[8]!==s?(j=s("CLI"),e[8]=s,e[9]=j):j=e[9];let O;e[10]!==s?(O=s("Client"),e[10]=s,e[11]=O):O=e[11];let S;e[12]!==s?(S=s("React"),e[12]=s,e[13]=S):S=e[13];let C;e[14]!==j||e[15]!==O||e[16]!==S?(C={cli:j,client:O,react:S},e[14]=j,e[15]=O,e[16]=S,e[17]=C):C=e[17],l=C;let A;e[18]===Symbol.for("react.memo_cache_sentinel")?(A=u(_=>{i(_.currentTarget.dataset.tab)},"B"),e[18]=A):A=e[18],c=A,m=at(o,w),e[0]=a,e[1]=r,e[2]=n,e[3]=s,e[4]=o,e[5]=c,e[6]=m,e[7]=l}else c=e[5],m=e[6],l=e[7];let p=m,f=`api.${a}.${r}`,h;e[19]!==f?(h=(0,R.jsx)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-fn-title",children:f}),e[19]=f,e[20]=h):h=e[20];let g;e[21]!==n||e[22]!==s?(g=s("Call this {kind} from your app.",{kind:n}),e[21]=n,e[22]=s,e[23]=g):g=e[23];let x;e[24]!==g?(x=(0,R.jsx)("p",{className:"text-xs text-muted-foreground",children:g}),e[24]=g,e[25]=x):x=e[25];let v;e[26]!==h||e[27]!==x?(v=(0,R.jsxs)("div",{children:[h,x]}),e[26]=h,e[27]=x,e[28]=v):v=e[28];let N;e[29]!==s?(N=s("Snippet flavour"),e[29]=s,e[30]=N):N=e[30];let y;e[31]!==c||e[32]!==o||e[33]!==l?(y=Xe.map(w=>(0,R.jsx)(W,{"aria-selected":o===w,"data-tab":w,"data-testid":`api-tab-${w}`,onClick:c,role:"tab",size:"xs",type:"button",variant:o===w?"default":"outline",children:l[w]},w)),e[31]=c,e[32]=o,e[33]=l,e[34]=y):y=e[34];let b;e[35]!==N||e[36]!==y?(b=(0,R.jsx)("div",{"aria-label":N,className:"flex gap-1.5","data-testid":"api-tabs",role:"tablist",children:y}),e[35]=N,e[36]=y,e[37]=b):b=e[37];let I=l[o],P=`api-snippet-${o}`,$;e[38]!==p||e[39]!==I||e[40]!==P?($=(0,R.jsx)(Re,{code:p,label:I,testId:P}),e[38]=p,e[39]=I,e[40]=P,e[41]=$):$=e[41];let k;return e[42]!==$||e[43]!==v||e[44]!==b?(k=(0,R.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"api-fn-doc",children:[v,b,$]}),e[42]=$,e[43]=v,e[44]=b,e[45]=k):k=e[45],k},"de"),ot=u(t=>{let e=(0,Y.c)(19),{name:a}=t,r=J(),n;e[0]!==a?(n=rt(a),e[0]=a,e[1]=n):n=e[1];let s=n,o;e[2]!==a?(o=(0,R.jsx)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-table-title",children:a}),e[2]=a,e[3]=o):o=e[3];let i;e[4]!==r?(i=r("Read and write this table through the typed data model."),e[4]=r,e[5]=i):i=e[5];let c;e[6]!==i?(c=(0,R.jsx)("p",{className:"text-xs text-muted-foreground",children:i}),e[6]=i,e[7]=c):c=e[7];let m;e[8]!==o||e[9]!==c?(m=(0,R.jsxs)("div",{children:[o,c]}),e[8]=o,e[9]=c,e[10]=m):m=e[10];let l;e[11]!==r?(l=r("Data model"),e[11]=r,e[12]=l):l=e[12];let p;e[13]!==s||e[14]!==l?(p=(0,R.jsx)(Re,{code:s,label:l,testId:"api-snippet-table"}),e[13]=s,e[14]=l,e[15]=p):p=e[15];let f;return e[16]!==m||e[17]!==p?(f=(0,R.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"api-table-doc",children:[m,p]}),e[16]=m,e[17]=p,e[18]=f):f=e[18],f},"fe"),Te=u(t=>{let e=(0,Y.c)(8),{active:a,label:r,onSelect:n,testId:s,value:o}=t,i;e[0]!==n||e[1]!==o?(i=u(()=>{n(o)},"m"),e[0]=n,e[1]=o,e[2]=i):i=e[2];let c=i,m=a?"page":void 0,l;return e[3]!==r||e[4]!==c||e[5]!==m||e[6]!==s?(l=(0,R.jsx)("button",{"aria-current":m,className:"w-full truncate rounded-md px-2 py-1 text-start font-mono text-xs text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-foreground","data-testid":s,onClick:c,type:"button",children:r}),e[3]=r,e[4]=c,e[5]=m,e[6]=s,e[7]=l):l=e[7],l},"G"),st=u(t=>{let e=new Map;for(let a of t){let{file:r,fn:n}=Ce(a.path),s=e.get(r)??[];s.push({fn:n,kind:a.kind,path:a.path}),e.set(r,s)}return[...e.entries()].map(([a,r])=>({file:a,items:r.toSorted((n,s)=>n.fn.localeCompare(s.fn))})).toSorted((a,r)=>a.file.localeCompare(r.file))},"pe"),Ae=u(t=>{let e=(0,Y.c)(58),{functions:a,initialShardKey:r}=t,n=J(),s=F(),[o,i]=(0,X.useState)(null),[c,m]=(0,X.useState)(null),l,p;e[0]!==s||e[1]!==r?(l=u(()=>{let _=!1;return s.query(Ve,{},ie(r??"")).then(T=>(_||i(T),T)).catch(()=>{_||i([])}),()=>{_=!0}},"o"),p=[s,r],e[0]=s,e[1]=r,e[2]=l,e[3]=p):(l=e[2],p=e[3]),(0,X.useEffect)(l,p);let f,h,g,x,v,N,y,b,I,P;if(e[4]!==a||e[5]!==c||e[6]!==n||e[7]!==o){let _=a??[],T=st(_),L=(o??[]).map(it).toSorted(lt),E;e[18]===Symbol.for("react.memo_cache_sentinel")?(E=u(M=>{m({kind:"fn",path:M})},"P"),e[18]=E):E=e[18];let D=E,Q;e[19]===Symbol.for("react.memo_cache_sentinel")?(Q=u(M=>{m({kind:"table",name:M})},"j"),e[19]=Q):Q=e[19];let Qe=Q;h=c?.kind==="fn"?_.find(M=>M.path===c.path):void 0,f=_.length>0||L.length>0,g=h===void 0?void 0:Ce(h.path),I="grid min-h-0 gap-6 md:grid-cols-[16rem_minmax(0,1fr)]",P="lunora-api-docs",e[20]!==n?(x=n("API resources"),e[20]=n,e[21]=x):x=e[21],v="flex flex-col gap-4 overflow-y-auto",N="api-rail";let ne;e[22]!==c||e[23]!==n?(ne=u(M=>(0,R.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,R.jsx)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:M.file||n("(root)")}),M.items.map(ee=>(0,R.jsx)(Te,{active:c?.kind==="fn"&&c.path===ee.path,label:ee.fn,onSelect:D,testId:`api-rail-fn-${ee.path}`,value:ee.path},ee.path))]},M.file),"q"),e[22]=c,e[23]=n,e[24]=ne):ne=e[24],y=T.map(ne),b=L.length>0&&(0,R.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,R.jsx)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Tables")}),L.map(M=>(0,R.jsx)(Te,{active:c?.kind==="table"&&c.name===M,label:M,onSelect:Qe,testId:`api-rail-table-${M}`,value:M},M))]}),e[4]=a,e[5]=c,e[6]=n,e[7]=o,e[8]=f,e[9]=h,e[10]=g,e[11]=x,e[12]=v,e[13]=N,e[14]=y,e[15]=b,e[16]=I,e[17]=P}else f=e[8],h=e[9],g=e[10],x=e[11],v=e[12],N=e[13],y=e[14],b=e[15],I=e[16],P=e[17];let $;e[25]!==f||e[26]!==n?($=!f&&(0,R.jsx)("p",{className:"px-2 text-xs text-muted-foreground","data-testid":"api-rail-empty",children:n("No functions or tables to document yet.")}),e[25]=f,e[26]=n,e[27]=$):$=e[27];let k;e[28]!==$||e[29]!==x||e[30]!==v||e[31]!==N||e[32]!==y||e[33]!==b?(k=(0,R.jsxs)("nav",{"aria-label":x,className:v,"data-testid":N,children:[y,b,$]}),e[28]=$,e[29]=x,e[30]=v,e[31]=N,e[32]=y,e[33]=b,e[34]=k):k=e[34];let w;e[35]!==c||e[36]!==n?(w=c===null&&(0,R.jsx)(U,{description:n("Select a function or table to see how to call it from your app."),testId:"api-empty",title:n("API usage snippets")}),e[35]=c,e[36]=n,e[37]=w):w=e[37];let j;e[38]!==c?.kind||e[39]!==h||e[40]!==g?(j=c?.kind==="fn"&&h!==void 0&&g!==void 0&&(0,R.jsx)(nt,{file:g.file,fn:g.fn,kind:h.kind},h.path),e[38]=c?.kind,e[39]=h,e[40]=g,e[41]=j):j=e[41];let O;e[42]!==c?.kind||e[43]!==h||e[44]!==n?(O=c?.kind==="fn"&&h===void 0&&(0,R.jsx)(U,{testId:"api-empty",title:n("API usage snippets")}),e[42]=c?.kind,e[43]=h,e[44]=n,e[45]=O):O=e[45];let S;e[46]!==c?(S=c?.kind==="table"&&(0,R.jsx)(ot,{name:c.name}),e[46]=c,e[47]=S):S=e[47];let C;e[48]!==w||e[49]!==j||e[50]!==O||e[51]!==S?(C=(0,R.jsxs)("div",{className:"min-w-0",children:[w,j,O,S]}),e[48]=w,e[49]=j,e[50]=O,e[51]=S,e[52]=C):C=e[52];let A;return e[53]!==k||e[54]!==C||e[55]!==I||e[56]!==P?(A=(0,R.jsxs)("div",{className:I,"data-testid":P,children:[k,C]}),e[53]=k,e[54]=C,e[55]=I,e[56]=P,e[57]=A):A=e[57],A},"ke");function it(t){return t.name}u(it,"ue");function lt(t,e){return t.localeCompare(e)}u(lt,"me");var De=K(te(),1);var z=K(te(),1);var q=K(me(),1);var d=K(re(),1);var dt=u(t=>typeof t=="number"?"number":typeof t=="boolean"?"boolean":"string","we"),Je=u(t=>{if(t.enum!==void 0&&t.enum.length>0)return t.enum;if(t.anyOf!==void 0&&t.anyOf.length>0&&t.anyOf.every(e=>e.const!==void 0))return t.anyOf.map(e=>e.const)},"Q"),ce=u(t=>t===void 0?"any":t.const!==void 0?JSON.stringify(t.const):t.enum!==void 0&&t.enum.length>0?t.enum.map(e=>JSON.stringify(e)).join(" | "):t.anyOf!==void 0&&t.anyOf.length>0?t.anyOf.map(e=>ce(e)).join(" | "):t.type==="array"?`array<${ce(t.items)}>`:t.type??"any","z"),ct=u(t=>{let e=Je(t);return e!==void 0?t.type??dt(e[0]):ce(t)},"ke"),pt=u(t=>{let e=Je(t);return e===void 0?void 0:e.map(a=>JSON.stringify(a)).join(" | ")},"Oe"),mt=u(t=>{let e=[];t.minimum!==void 0?e.push(`${String(t.minimum)} \u2264`):t.exclusiveMinimum!==void 0&&e.push(`${String(t.exclusiveMinimum)} <`);let a=e.length>0;e.push("value"),t.maximum!==void 0?e.push(`\u2264 ${String(t.maximum)}`):t.exclusiveMaximum!==void 0&&e.push(`< ${String(t.exclusiveMaximum)}`);let r=e.length>(a?2:1);return a||r?e.join(" "):void 0},"$e"),ut=u(t=>{if(t.type==="object"&&t.properties!==void 0)return t;if(t.type==="array"&&t.items?.type==="object"&&t.items.properties!==void 0)return t.items},"Te"),Z=u(t=>{if(t===void 0)return null;if(t.const!==void 0)return t.const;if(t.enum!==void 0&&t.enum.length>0)return t.enum[0];if(t.anyOf!==void 0&&t.anyOf.length>0)return Z(t.anyOf[0]);switch(t.type){case"array":return[];case"boolean":return!1;case"number":return 0;case"object":{let e={};for(let[a,r]of Object.entries(t.properties??{}))e[a]=Z(r);return e}case"string":return"";default:return null}},"D"),de=u(t=>{let e=(0,z.c)(7),{label:a,value:r}=t,n;e[0]!==a?(n=(0,d.jsx)("span",{className:"text-muted-foreground",children:a}),e[0]=a,e[1]=n):n=e[1];let s;e[2]!==r?(s=(0,d.jsx)("span",{className:"text-foreground",children:r}),e[2]=r,e[3]=s):s=e[3];let o;return e[4]!==n||e[5]!==s?(o=(0,d.jsxs)("span",{className:"inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 font-mono text-[10px]",children:[n,s]}),e[4]=n,e[5]=s,e[6]=o):o=e[6],o},"K"),ft=u(t=>{let e=(0,z.c)(40),{name:a,required:r,schema:n}=t,s=J(),o;e[0]!==n?(o=mt(n),e[0]=n,e[1]=o):o=e[1];let i=o,c;e[2]!==n?(c=pt(n),e[2]=n,e[3]=c):c=e[3];let m=c,l=n["x-lunora-table"],p=n.format!==void 0||i!==void 0||m!==void 0||l!==void 0,f;e[4]!==n?(f=ut(n),e[4]=n,e[5]=f):f=e[5];let h=f,g=r?"*":"?",x;e[6]!==g?(x=(0,d.jsx)("span",{className:"text-muted-foreground",children:g}),e[6]=g,e[7]=x):x=e[7];let v;e[8]!==a||e[9]!==x?(v=(0,d.jsxs)("span",{className:"font-mono text-foreground",children:[a,x]}),e[8]=a,e[9]=x,e[10]=v):v=e[10];let N;e[11]!==n?(N=ct(n),e[11]=n,e[12]=N):N=e[12];let y;e[13]!==N?(y=(0,d.jsx)("span",{className:"font-mono text-muted-foreground",children:N}),e[13]=N,e[14]=y):y=e[14];let b;e[15]!==v||e[16]!==y?(b=(0,d.jsxs)("div",{className:"flex items-baseline gap-2",children:[v,y]}),e[15]=v,e[16]=y,e[17]=b):b=e[17];let I;e[18]!==n.description?(I=n.description!==void 0&&(0,d.jsx)("p",{className:"max-w-prose text-muted-foreground",children:n.description}),e[18]=n.description,e[19]=I):I=e[19];let P;e[20]!==p||e[21]!==i||e[22]!==l||e[23]!==n.format||e[24]!==s||e[25]!==m?(P=p&&(0,d.jsxs)("div",{className:"flex flex-wrap gap-1",children:[n.format!==void 0&&(0,d.jsx)(de,{label:s("Format"),value:n.format}),i!==void 0&&(0,d.jsx)(de,{label:s("Range"),value:i}),m!==void 0&&(0,d.jsx)(de,{label:s("Value in"),value:m}),l!==void 0&&(0,d.jsx)(de,{label:s("relation"),value:l})]}),e[20]=p,e[21]=i,e[22]=l,e[23]=n.format,e[24]=s,e[25]=m,e[26]=P):P=e[26];let $;e[27]!==I||e[28]!==P||e[29]!==b?($=(0,d.jsxs)("div",{className:"flex flex-col gap-1 py-2",children:[b,I,P]}),e[27]=I,e[28]=P,e[29]=b,e[30]=$):$=e[30];let k=$;if(h===void 0){let S;return e[31]!==k?(S=(0,d.jsx)("div",{className:"border-b border-border/50 last:border-b-0",children:k}),e[31]=k,e[32]=S):S=e[32],S}let w;e[33]!==k?(w=(0,d.jsx)("summary",{className:"cursor-pointer marker:text-muted-foreground",children:k}),e[33]=k,e[34]=w):w=e[34];let j;e[35]!==h?(j=(0,d.jsx)("div",{className:"mb-2 ml-2 border-l border-border pl-3",children:(0,d.jsx)(Le,{schema:h})}),e[35]=h,e[36]=j):j=e[36];let O;return e[37]!==w||e[38]!==j?(O=(0,d.jsxs)("details",{className:"border-b border-border/50 last:border-b-0",children:[w,j]}),e[37]=w,e[38]=j,e[39]=O):O=e[39],O},"Ee"),Le=u(t=>{let e=(0,z.c)(7),{schema:a}=t,r;e[0]!==a.required?(r=new Set(a.required),e[0]=a.required,e[1]=r):r=e[1];let n=r,s;e[2]!==a.properties?(s=Object.entries(a.properties??{}),e[2]=a.properties,e[3]=s):s=e[3];let o=s,i;return e[4]!==n||e[5]!==o?(i=(0,d.jsx)("div",{className:"flex flex-col",children:o.map(c=>{let[m,l]=c;return(0,d.jsx)(ft,{name:m,required:n.has(m),schema:l},m)})}),e[4]=n,e[5]=o,e[6]=i):i=e[6],i},"Z"),_e=u(t=>{let e=(0,z.c)(10),{schema:a,testId:r}=t;if(a?.type!=="object"||Object.keys(a.properties??{}).length===0){let o;e[0]!==a?(o=ce(a),e[0]=a,e[1]=o):o=e[1];let i;return e[2]!==o||e[3]!==r?(i=(0,d.jsx)("p",{className:"font-mono text-xs text-muted-foreground","data-testid":r,children:o}),e[2]=o,e[3]=r,e[4]=i):i=e[4],i}let n;e[5]!==a?(n=(0,d.jsx)(Le,{schema:a}),e[5]=a,e[6]=n):n=e[6];let s;return e[7]!==n||e[8]!==r?(s=(0,d.jsx)("div",{className:"text-xs","data-testid":r,children:n}),e[7]=n,e[8]=r,e[9]=s):s=e[9],s},"V"),ht=["curl","javascript","lunora"],gt={lunora:"Lunora",curl:"cURL",javascript:"JavaScript"},xt=u(t=>`api.${t.replaceAll(/[/:]/g,".")}`,"je"),bt=u(t=>{let e=Z(t.argsSchema)??{};return t.functionPath===void 0?e:{args:e,functionPath:t.functionPath}},"Ae"),yt=u((t,e,a)=>{let r=`${a}${e.httpPath}`,n=JSON.stringify(bt(e),void 0,2),s=JSON.stringify(Z(e.argsSchema)??{},void 0,2);switch(t){case"curl":{let o=e.method!=="GET"&&e.method!=="HEAD",i=[`curl -X ${e.method} ${JSON.stringify(r)}`];return o&&i.push(' -H "Content-Type: application/json"',` -d '${n}'`),i.join(` \\
|
|
3
3
|
`)}case"lunora":return e.functionPath===void 0?`await fetch(${JSON.stringify(e.httpPath)}, { method: ${JSON.stringify(e.method)} });`:`import { useLunora } from "@lunora/react";
|
|
4
4
|
import { api } from "./_generated/api";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as C}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as v}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as j}from"./chunk-
|
|
1
|
+
import{a as C}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as v}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as j}from"./chunk-ARXLF43Z.js";import"./chunk-NCPW7WHO.js";import"./chunk-VA2K2MGN.js";import"./chunk-55UGUCQ6.js";import{a as g}from"./chunk-4ZEL6BYL.js";import{c as h}from"./chunk-C4ZPJ4KT.js";import"./chunk-DTFIEXYN.js";import"./chunk-QAQDMS6R.js";import"./chunk-WS7WNXF3.js";import{a as $}from"./chunk-RWVIV3U7.js";import{a as I,b as _,c as q,d as p,e as o,f as i}from"./chunk-HCTJKP5J.js";import{a as S,e as K}from"./chunk-2IKDEUCX.js";import{d as T,t as F}from"./chunk-5OMZCVRF.js";import{a as d,d as k,e as ne,f as oe,g as ie}from"./chunk-I26MS5PJ.js";var Q=k(oe(),1),G=k(ne(),1);var e=k(ie(),1);var H="agent_threads",de="agent_messages",L="agent_run_queue",J=100,N=250,le={},ce={filters:[],limit:J,offset:0,orderBy:{column:"updatedAt",direction:"desc"},skipCount:!0,table:H},c=d((s,t)=>{let a=s[t];return typeof a=="string"?a:void 0},"c"),B=d((s,t)=>{let a=s[t];return typeof a=="number"?a:void 0},"E"),O=d(s=>{let{usage:t}=s;if(t===null||typeof t!="object")return;let{totalTokens:a}=t;return typeof a=="number"?a:void 0},"H"),me=d(s=>{let{toolCalls:t}=s;return Array.isArray(t)?t.map(a=>a!==null&&typeof a=="object"?a.name:void 0).filter(a=>typeof a=="string"):[]},"de"),ue=d(s=>{switch(s){case"awaiting_input":return"warning";case"cancelled":return"warning";case"error":return"destructive";case"running":return"info";default:return"outline"}},"le"),he=d(s=>{switch(s){case"approved":return"success";case"rejected":return"destructive";default:return"warning"}},"ie"),ge=d(s=>{let t=(0,Q.c)(3),{fetched:a}=s,m=T(),l;return t[0]!==a||t[1]!==m?(l=a<=N?null:(0,e.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"agents-messages-truncated",children:m("Showing the latest {count} messages; older ones are not shown.",{count:N})}),t[0]=a,t[1]=m,t[2]=l):l=t[2],l},"ce"),Te=d(({initialShardKey:s=""})=>{let t=T(),[a,m]=(0,G.useState)(void 0),{data:l}=h(g.listTables,le,{live:!0,shardKey:s}),V=l!==void 0,f=Array.isArray(l)&&l.some(r=>r.name===H),W=Array.isArray(l)&&l.some(r=>r.name===L),{data:E,error:X,errorSource:Y,liveError:Z}=h(g.readTablePage,ce,{enabled:f,live:!0,shardKey:s}),ee={filters:[{column:"threadKey",operator:"eq",value:a??""}],limit:N+1,offset:0,orderBy:{column:"seq",direction:"desc"},skipCount:!0,table:de},{data:P}=h(g.readTablePage,{limit:J,offset:0,orderBy:{column:"position",direction:"asc"},skipCount:!0,table:L},{enabled:W,live:!0,shardKey:s}),{data:U,error:te,errorSource:ae}=h(g.readTablePage,ee,{enabled:f&&a!==void 0,live:!0,shardKey:s}),b=Array.isArray(E?.rows)?E.rows:[],re=Array.isArray(P?.rows)?P.rows:[],z=d(r=>re.filter(n=>c(n,"threadKey")===r).length,"C"),M=Array.isArray(U?.rows)?U.rows:[],R=M.slice(0,N).toReversed(),D=b.find(r=>c(r,"key")===a),x;return V&&!f?x=(0,e.jsx)($,{description:t("No @lunora/agent tables found in this deployment. Add lunora/agents.ts with defineAgent(...) and merge the agent schema extension to run durable AI agents."),testId:"agents-unconfigured",title:t("No agents configured")}):f&&b.length===0?x=(0,e.jsx)($,{description:t("No agent has run yet. Start a run with ctx.agents.<name>.run(...) and its thread appears here."),testId:"agents-empty",title:t("No agent threads yet")}):x=(0,e.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,e.jsx)(S,{className:"overflow-hidden py-0",children:(0,e.jsx)(K,{className:"px-0",children:(0,e.jsxs)(I,{"data-testid":"agents-threads-table",children:[(0,e.jsx)(_,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(o,{children:t("Agent")}),(0,e.jsx)(o,{children:t("Key")}),(0,e.jsx)(o,{children:t("Status")}),(0,e.jsx)(o,{children:t("Queued")}),(0,e.jsx)(o,{children:t("Messages")}),(0,e.jsx)(o,{children:t("Tokens")}),(0,e.jsx)(o,{children:t("Updated")}),(0,e.jsx)(o,{"aria-label":t("Actions")})]})}),(0,e.jsx)(q,{children:b.map(r=>{let n=c(r,"key")??"",u=c(r,"status"),y=O(r);return(0,e.jsxs)(p,{"data-active":n===a?"":void 0,"data-testid":`agents-thread-${n}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:c(r,"agent")??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:n}),(0,e.jsx)(i,{children:(0,e.jsx)(v,{"data-testid":`agents-thread-status-${n}`,variant:ue(u),children:u??"\u2014"})}),(0,e.jsx)(i,{className:"tabular-nums",children:z(n)===0?(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}):(0,e.jsx)(v,{"data-testid":`agents-thread-queued-${n}`,variant:"warning",children:z(n)})}),(0,e.jsx)(i,{className:"tabular-nums",children:B(r,"messageCount")??"\u2014"}),(0,e.jsx)(i,{className:"tabular-nums text-muted-foreground",children:y??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:F(B(r,"updatedAt"),"\u2014")}),(0,e.jsx)(i,{className:"text-right",children:(0,e.jsx)(C,{"data-testid":`agents-thread-open-${n}`,onClick:d(()=>{m(n)},"onClick"),size:"sm",type:"button",variant:"outline",children:t("Timeline")})})]},n)})})]})})}),te!==null&&(0,e.jsx)(j,{error:ae,testId:"agents-messages-error"}),a!==void 0&&(0,e.jsx)(S,{className:"overflow-hidden py-0","data-testid":"agents-thread-detail",children:(0,e.jsxs)(K,{className:"flex flex-col gap-3 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[t("Timeline")," \xB7 ",a,D!==void 0&&(0,e.jsxs)("span",{className:"text-muted-foreground",children:[" \xB7 ",t("Usage"),": ",O(D)??0," ",t("Tokens")]})]}),(0,e.jsx)(C,{"data-testid":"agents-thread-detail-close",onClick:d(()=>{m(void 0)},"onClick"),size:"xs",type:"button",variant:"ghost",children:t("Close")})]}),(0,e.jsx)(ge,{fetched:M.length}),R.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:t("This thread has no messages yet.")}):(0,e.jsxs)(I,{"data-testid":"agents-messages-table",children:[(0,e.jsx)(_,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(o,{children:t("Role")}),(0,e.jsx)(o,{children:t("Content")}),(0,e.jsx)(o,{children:t("Tool")}),(0,e.jsx)(o,{children:t("Approval")})]})}),(0,e.jsx)(q,{children:R.map((r,n)=>{let u=c(r,"role")??"\u2014",y=me(r),se=c(r,"toolName"),w=c(r,"status"),A=B(r,"seq")??n;return(0,e.jsxs)(p,{"data-testid":`agents-message-${String(A)}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs align-top text-muted-foreground",children:u}),(0,e.jsx)(i,{className:"max-w-md font-mono text-xs whitespace-pre-wrap break-words",children:c(r,"content")??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs align-top text-muted-foreground",children:se??(y.length>0?y.join(", "):"\u2014")}),(0,e.jsx)(i,{className:"align-top",children:w===void 0?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"\u2014"}):(0,e.jsx)(v,{"data-testid":`agents-message-approval-${String(A)}`,variant:he(w),children:w})})]},c(r,"messageKey")??`${u}:${String(A)}`)})})]})]})})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-agents-panel",children:[X!==null&&(0,e.jsx)(j,{error:Y,testId:"agents-error"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t("Agents run as durable workflows. Each run persists a thread of assistant and tool messages; select a thread to inspect its timeline, tool calls, approvals, and token usage.")}),Z!==void 0&&(0,e.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"agents-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")}),x]})},"Ee");export{Te as default};
|