@lunora/studio 1.0.0-alpha.83 → 1.0.0-alpha.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/standalone/{chunk-PXYWCZ7T.js → chunk-22LOWEEC.js} +1 -1
- package/dist/standalone/{chunk-6VAKZALJ.js → chunk-232MBXB2.js} +1 -1
- package/dist/standalone/{chunk-GB6LP6UJ.js → chunk-2EJADIPC.js} +1 -1
- package/dist/standalone/{chunk-D2RKH6JK.js → chunk-2SC3EG5Y.js} +1 -1
- package/dist/standalone/{chunk-UDVB4URN.js → chunk-347H2BQO.js} +1 -1
- package/dist/standalone/{chunk-A3KUNMU6.js → chunk-4I2TBTZS.js} +1 -1
- package/dist/standalone/{chunk-B2H5DK55.js → chunk-52OYJHM7.js} +1 -1
- package/dist/standalone/{chunk-YTA2HGRD.js → chunk-5YADKLAQ.js} +1 -1
- package/dist/standalone/{chunk-C7EOC2WS.js → chunk-6IEBRNDW.js} +1 -1
- package/dist/standalone/{chunk-HEB6GQQ6.js → chunk-7AG3T4DK.js} +2 -2
- package/dist/standalone/{chunk-53WEPGUD.js → chunk-AHVDZWB3.js} +1 -1
- package/dist/standalone/{chunk-CU55Y5TV.js → chunk-AQKXMWNF.js} +1 -1
- package/dist/standalone/{chunk-LLF5KWDZ.js → chunk-BAAU4OTI.js} +1 -1
- package/dist/standalone/{chunk-Y7A5NCXT.js → chunk-D3FRQZ4X.js} +1 -1
- package/dist/standalone/{chunk-T242WITF.js → chunk-D67BVBQW.js} +1 -1
- package/dist/standalone/{chunk-WQVVA5NB.js → chunk-EDOMDMVI.js} +1 -1
- package/dist/standalone/{chunk-GM67EQJU.js → chunk-ENBTOX7N.js} +1 -1
- package/dist/standalone/{chunk-DOZAODYC.js → chunk-ESKVOZLC.js} +1 -1
- package/dist/standalone/{chunk-KAPSM6AI.js → chunk-ETZYJL7Z.js} +1 -1
- package/dist/standalone/{chunk-PD4LANXJ.js → chunk-FUBR2PAD.js} +1 -1
- package/dist/standalone/{chunk-GWQIPIYA.js → chunk-HJR42BJY.js} +1 -1
- package/dist/standalone/{chunk-SV52HB7D.js → chunk-JAT5ZBQK.js} +1 -1
- package/dist/standalone/{chunk-CGLS2ILT.js → chunk-JE3WK77V.js} +1 -1
- package/dist/standalone/{chunk-6QP5N57V.js → chunk-KNHWIHC7.js} +1 -1
- package/dist/standalone/{chunk-OE465DVY.js → chunk-LVJ5IHEU.js} +1 -1
- package/dist/standalone/{chunk-TQXZ7LG4.js → chunk-MBVSXVTV.js} +1 -1
- package/dist/standalone/{chunk-7YKWP4QK.js → chunk-MDHUWMFD.js} +1 -1
- package/dist/standalone/{chunk-WZ3B3MEV.js → chunk-MLULN4R2.js} +1 -1
- package/dist/standalone/{chunk-Y5Y7DHFW.js → chunk-MN64D74P.js} +1 -1
- package/dist/standalone/{chunk-ZHBIKP5G.js → chunk-MUGKOGZG.js} +1 -1
- package/dist/standalone/{chunk-HOR3JLUY.js → chunk-NPKNFZUW.js} +1 -1
- package/dist/standalone/{chunk-KXSSTTEY.js → chunk-OLM62NLS.js} +1 -1
- package/dist/standalone/{chunk-Q7O6B7WC.js → chunk-OOL3FV6A.js} +1 -1
- package/dist/standalone/{chunk-DGBJE7YF.js → chunk-OV63HVE4.js} +1 -1
- package/dist/standalone/{chunk-SDQBPFLO.js → chunk-PWTURL56.js} +1 -1
- package/dist/standalone/{chunk-GN567L2T.js → chunk-QFJRZR4U.js} +1 -1
- package/dist/standalone/{chunk-WJGOI3FZ.js → chunk-QI25LTPH.js} +1 -1
- package/dist/standalone/{chunk-TBRZQICB.js → chunk-QNRAMF4X.js} +1 -1
- package/dist/standalone/{chunk-AADILRJW.js → chunk-QNUWWC3N.js} +12 -12
- package/dist/standalone/{chunk-UETNCBWU.js → chunk-QS4IFAFJ.js} +1 -1
- package/dist/standalone/{chunk-ZK3XKFCI.js → chunk-QSFKPGK4.js} +1 -1
- package/dist/standalone/{chunk-GWHM4C4N.js → chunk-QZ6TCNWR.js} +1 -1
- package/dist/standalone/{chunk-VTLYN3CX.js → chunk-RC3H4OP3.js} +1 -1
- package/dist/standalone/{chunk-7ZUQE3KU.js → chunk-RFBU5RZI.js} +1 -1
- package/dist/standalone/{chunk-7L7FXGJU.js → chunk-S67SBGB3.js} +1 -1
- package/dist/standalone/{chunk-VC5SSRUP.js → chunk-SHD2IWQI.js} +1 -1
- package/dist/standalone/{chunk-NRCXRCJX.js → chunk-SKFZXESP.js} +1 -1
- package/dist/standalone/{chunk-KSRP7GZV.js → chunk-SPT3KPV7.js} +1 -1
- package/dist/standalone/{chunk-74DN6HIE.js → chunk-TIR6CWHO.js} +1 -1
- package/dist/standalone/{chunk-Q7QTRX2E.js → chunk-TO45V3L6.js} +1 -1
- package/dist/standalone/{chunk-HJD2YUQS.js → chunk-U44CWN7H.js} +1 -1
- package/dist/standalone/{chunk-VCXH5V3Z.js → chunk-U5IIRHZ6.js} +1 -1
- package/dist/standalone/{chunk-EN2QAEO4.js → chunk-UBR4KB6K.js} +1 -1
- package/dist/standalone/{chunk-ZI5ZVNIN.js → chunk-UOQ24BAY.js} +1 -1
- package/dist/standalone/{chunk-BDJCCVB6.js → chunk-VKEJTZY7.js} +1 -1
- package/dist/standalone/{chunk-RNL6BSFM.js → chunk-VORDESEQ.js} +1 -1
- package/dist/standalone/{chunk-XDAT7LHC.js → chunk-YGKR536O.js} +1 -1
- package/dist/standalone/{chunk-CU6SCYQ7.js → chunk-YNBIW2GN.js} +1 -1
- package/dist/standalone/{chunk-WDG4WFUV.js → chunk-YSMJN36P.js} +1 -1
- package/dist/standalone/{chunk-5SQRE3VR.js → chunk-ZOX6X2DL.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as w}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as S}from"./chunk-
|
|
1
|
+
import{c as w}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as S}from"./chunk-AHVDZWB3.js";import"./chunk-XXQUMVWH.js";import"./chunk-VORDESEQ.js";import"./chunk-QLQADHFE.js";import{a as f}from"./chunk-ERMTJYQF.js";import{c as p}from"./chunk-YGKR536O.js";import"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as T}from"./chunk-XQCVZAGU.js";import{a as C,b as j,c as I,d as m,e as n,f as o}from"./chunk-MIQTKZAR.js";import{a as A,e as k}from"./chunk-UZERI5YC.js";import{d as z,q as B}from"./chunk-OG4N2XHD.js";import"./chunk-QNUWWC3N.js";import{a as i,e as U,f as W,h as X}from"./chunk-3XIESWL4.js";var D=U(W(),1);var e=U(X(),1);var F="agent_threads",Y="agent_messages",Z=100,ee=250,te={},ae={filters:[],limit:Z,offset:0,orderBy:{column:"updatedAt",direction:"desc"},skipCount:!0,table:F},l=i((s,t)=>{let a=s[t];return typeof a=="string"?a:void 0},"d"),K=i((s,t)=>{let a=s[t];return typeof a=="number"?a:void 0},"b"),M=i(s=>{let{usage:t}=s;if(t===null||typeof t!="object")return;let{totalTokens:a}=t;return typeof a=="number"?a:void 0},"z"),re=i(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"):[]},"ee"),se=i(s=>{switch(s){case"awaiting_input":return"warning";case"cancelled":return"warning";case"error":return"destructive";case"running":return"info";default:return"outline"}},"te"),ne=i(s=>{switch(s){case"approved":return"success";case"rejected":return"destructive";default:return"warning"}},"ae"),fe=i(({initialShardKey:s=""})=>{let t=z(),[a,$]=(0,D.useState)(void 0),{data:x}=p(f.listTables,te,{live:!0,shardKey:s}),L=x!==void 0,u=Array.isArray(x)&&x.some(r=>r.name===F),{data:_,error:O,errorSource:R,liveError:G}=p(f.readTablePage,ae,{enabled:u,live:!0,shardKey:s}),H={filters:[{column:"threadKey",operator:"eq",value:a??""}],limit:ee,offset:0,orderBy:{column:"seq",direction:"asc"},skipCount:!0,table:Y},{data:q,error:J,errorSource:Q}=p(f.readTablePage,H,{enabled:u&&a!==void 0,live:!0,shardKey:s}),v=Array.isArray(_?.rows)?_.rows:[],E=Array.isArray(q?.rows)?q.rows:[],P=v.find(r=>l(r,"key")===a),h;return L&&!u?h=(0,e.jsx)(T,{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")}):u&&v.length===0?h=(0,e.jsx)(T,{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")}):h=(0,e.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,e.jsx)(A,{className:"overflow-hidden py-0",children:(0,e.jsx)(k,{className:"px-0",children:(0,e.jsxs)(C,{"data-testid":"agents-threads-table",children:[(0,e.jsx)(j,{children:(0,e.jsxs)(m,{children:[(0,e.jsx)(n,{children:t("Agent")}),(0,e.jsx)(n,{children:t("Key")}),(0,e.jsx)(n,{children:t("Status")}),(0,e.jsx)(n,{children:t("Messages")}),(0,e.jsx)(n,{children:t("Tokens")}),(0,e.jsx)(n,{children:t("Updated")}),(0,e.jsx)(n,{"aria-label":t("Actions")})]})}),(0,e.jsx)(I,{children:v.map(r=>{let d=l(r,"key")??"",c=l(r,"status"),g=M(r);return(0,e.jsxs)(m,{"data-active":d===a?"":void 0,"data-testid":`agents-thread-${d}`,children:[(0,e.jsx)(o,{className:"font-mono text-xs",children:l(r,"agent")??"\u2014"}),(0,e.jsx)(o,{className:"font-mono text-xs text-muted-foreground",children:d}),(0,e.jsx)(o,{children:(0,e.jsx)(b,{"data-testid":`agents-thread-status-${d}`,variant:se(c),children:c??"\u2014"})}),(0,e.jsx)(o,{className:"tabular-nums",children:K(r,"messageCount")??"\u2014"}),(0,e.jsx)(o,{className:"tabular-nums text-muted-foreground",children:g??"\u2014"}),(0,e.jsx)(o,{className:"text-muted-foreground tabular-nums",children:B(K(r,"updatedAt"),"\u2014")}),(0,e.jsx)(o,{className:"text-right",children:(0,e.jsx)(w,{"data-testid":`agents-thread-open-${d}`,onClick:i(()=>{$(d)},"onClick"),size:"sm",type:"button",variant:"outline",children:t("Timeline")})})]},d)})})]})})}),J!==null&&(0,e.jsx)(S,{error:Q,testId:"agents-messages-error"}),a!==void 0&&(0,e.jsx)(A,{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,P!==void 0&&(0,e.jsxs)("span",{className:"text-muted-foreground",children:[" \xB7 ",t("Usage"),": ",M(P)??0," ",t("Tokens")]})]}),(0,e.jsx)(w,{"data-testid":"agents-thread-detail-close",onClick:i(()=>{$(void 0)},"onClick"),size:"xs",type:"button",variant:"ghost",children:t("Close")})]}),E.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:t("This thread has no messages yet.")}):(0,e.jsxs)(C,{"data-testid":"agents-messages-table",children:[(0,e.jsx)(j,{children:(0,e.jsxs)(m,{children:[(0,e.jsx)(n,{children:t("Role")}),(0,e.jsx)(n,{children:t("Content")}),(0,e.jsx)(n,{children:t("Tool")}),(0,e.jsx)(n,{children:t("Approval")})]})}),(0,e.jsx)(I,{children:E.map((r,d)=>{let c=l(r,"role")??"\u2014",g=re(r),V=l(r,"toolName"),y=l(r,"status"),N=K(r,"seq")??d;return(0,e.jsxs)(m,{"data-testid":`agents-message-${String(N)}`,children:[(0,e.jsx)(o,{className:"font-mono text-xs align-top text-muted-foreground",children:c}),(0,e.jsx)(o,{className:"max-w-md font-mono text-xs whitespace-pre-wrap break-words",children:l(r,"content")??"\u2014"}),(0,e.jsx)(o,{className:"font-mono text-xs align-top text-muted-foreground",children:V??(g.length>0?g.join(", "):"\u2014")}),(0,e.jsx)(o,{className:"align-top",children:y===void 0?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"\u2014"}):(0,e.jsx)(b,{"data-testid":`agents-message-approval-${String(N)}`,variant:ne(y),children:y})})]},l(r,"messageKey")??`${c}:${String(N)}`)})})]})]})})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-agents-panel",children:[O!==null&&(0,e.jsx)(S,{error:R,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.")}),G!==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.")}),h]})},"pe");export{fe as AgentsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as me,e as _}from"./chunk-Y5Y7DHFW.js";import{a as ue}from"./chunk-CTNB2KIA.js";import"./chunk-CU55Y5TV.js";import"./chunk-4UOFSGUS.js";import"./chunk-ILNELDFC.js";import{a as de}from"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{b as P}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import"./chunk-QLQADHFE.js";import{a as M}from"./chunk-ERMTJYQF.js";import{c as ce}from"./chunk-XDAT7LHC.js";import{f as ne,g as oe}from"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{a as A}from"./chunk-UZERI5YC.js";import{d as D,f as j,g as W,h as X,m as K,q as ie}from"./chunk-OG4N2XHD.js";import"./chunk-AADILRJW.js";import{a as h,e as I,f as qe,g as ae,h as le,j as q}from"./chunk-3XIESWL4.js";var Z=I(ae(),1);var f=I(qe(),1);var fe=I(ae(),1);var $=I(le(),1);var Me={connected:"bg-success",connecting:"bg-warning",idle:"bg-muted-foreground",offline:"bg-destructive"},pe=h(()=>{let t=(0,fe.c)(16),e=D(),a=oe(),s;e:switch(a){case"connected":{let n;t[0]!==e?(n=e("Connected"),t[0]=e,t[1]=n):n=t[1],s=n;break e}case"connecting":{let n;t[2]!==e?(n=e("Connecting\u2026"),t[2]=e,t[3]=n):n=t[3],s=n;break e}case"idle":{let n;t[4]!==e?(n=e("Idle"),t[4]=e,t[5]=n):n=t[5],s=n;break e}case"offline":{let n;t[6]!==e?(n=e("Offline"),t[6]=e,t[7]=n):n=t[7],s=n;break e}default:s=a}let l=Me[a],c;t[8]!==l?(c=q("size-2 rounded-full",l),t[8]=l,t[9]=c):c=t[9];let o;t[10]!==c?(o=(0,$.jsx)("span",{"aria-hidden":"true",className:c}),t[10]=c,t[11]=o):o=t[11];let i;return t[12]!==a||t[13]!==o||t[14]!==s?(i=(0,$.jsxs)("span",{"aria-live":"polite",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground","data-status":a,"data-testid":"dash-connection",role:"status",children:[o,s]}),t[12]=a,t[13]=o,t[14]=s,t[15]=i):i=t[15],i},"j");var r=I(le(),1);var Ae={crit:"destructive",ok:"secondary",warn:"default"},U=h((t,e)=>e===0?"\u2014":`${(t/e*100).toFixed(1)}%`,"_"),Y=h((t,e,a)=>Number.isNaN(t)?"ok":t>=a?"crit":t>=e?"warn":"ok","V"),xe=.01,ve=.05,je=h(t=>{let e=(0,Z.c)(36),{errorCount:a,logsError:s,topErrors:l,worstFunctions:c}=t,o=D(),i;e[0]!==o?(i=o("Functions by error rate"),e[0]=o,e[1]=i):i=e[1];let n;e[2]!==i?(n=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i})}),e[2]=i,e[3]=n):n=e[3];let p;e[4]!==o||e[5]!==c?(p=c.length===0?(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-functions-empty",children:o("No function activity yet.")}):(0,r.jsx)("ul",{className:"divide-y divide-border",children:c.map(w=>(0,r.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-xs","data-testid":"hl-fn-row",children:[(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:w.path}),(0,r.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[(0,r.jsx)("span",{className:"tabular-nums text-muted-foreground",children:o("{count} calls",{count:w.calls.toString()})}),(0,r.jsx)(P,{variant:Ae[Y(w.errors/w.calls,xe,ve)],children:U(w.errors,w.calls)})]})]},w.path))}),e[4]=o,e[5]=c,e[6]=p):p=e[6];let g;e[7]!==n||e[8]!==p?(g=(0,r.jsxs)(A,{className:"gap-0 py-0","data-testid":"hl-functions",children:[n,p]}),e[7]=n,e[8]=p,e[9]=g):g=e[9];let N;e[10]!==o?(N=o("Recent errors"),e[10]=o,e[11]=N):N=e[11];let d;e[12]!==N?(d=(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:N}),e[12]=N,e[13]=d):d=e[13];let u=a>0?"destructive":"outline",x;e[14]!==a||e[15]!==u?(x=(0,r.jsx)(P,{"data-testid":"hl-error-count",variant:u,children:a}),e[14]=a,e[15]=u,e[16]=x):x=e[16];let v;e[17]!==d||e[18]!==x?(v=(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[d,x]}),e[17]=d,e[18]=x,e[19]=v):v=e[19];let k;e[20]!==s?(k=s!==null&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:s}),e[20]=s,e[21]=k):k=e[21];let S;e[22]!==s||e[23]!==o||e[24]!==l.length?(S=s===null&&l.length===0&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-errors-empty",children:o("No recent errors.")}),e[22]=s,e[23]=o,e[24]=l.length,e[25]=S):S=e[25];let E;e[26]!==l?(E=l.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:l.map(Ce)}),e[26]=l,e[27]=E):E=e[27];let b;e[28]!==k||e[29]!==S||e[30]!==E||e[31]!==v?(b=(0,r.jsxs)(A,{className:"gap-0 py-0",children:[v,k,S,E]}),e[28]=k,e[29]=S,e[30]=E,e[31]=v,e[32]=b):b=e[32];let y;return e[33]!==b||e[34]!==g?(y=(0,r.jsxs)("div",{className:"grid gap-3 lg:grid-cols-2",children:[g,b]}),e[33]=b,e[34]=g,e[35]=y):y=e[35],y},"Se");function Ce(t,e){return(0,r.jsxs)("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)("time",{className:"shrink-0 text-muted-foreground",children:ie(t.timestamp)}),t.functionPath!==void 0&&(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:t.functionPath})]}),(0,r.jsx)("span",{className:"text-destructive",children:t.message})]},`${t.timestamp.toString()}-${e.toString()}`)}h(Ce,"Ee");var he={completed:0,failed:2,in_progress:1},Ie=h(t=>{let e=0,a=0,s=0,l=0,c=[];for(let{metrics:o}of t){if(o===null){l+=1;continue}s+=1,e+=o.requests,a+=o.errors,c.push(...o.history??[])}return{errors:a,failed:l,history:c,reachable:s,requests:e}},"Me"),De=h(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.path);if(l===void 0){e.set(s.path,{...s});continue}l.calls+=s.calls,l.errors+=s.errors,l.totalDurationMs+=s.totalDurationMs,l.scans=(l.scans??0)+(s.scans??0),l.maxDurationMs=Math.max(l.maxDurationMs,s.maxDurationMs),l.lastCalledAt=Math.max(l.lastCalledAt,s.lastCalledAt),(s.lastErrorAt??0)>(l.lastErrorAt??0)&&(l.lastErrorAt=s.lastErrorAt,l.lastErrorMessage=s.lastErrorMessage)}return[...e.values()]},"qe"),Pe=h(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.id);if(l===void 0){e.set(s.id,s);continue}let c=he[s.status]-he[l.status];(c>0||c===0&&(s.updatedAt??0)>(l.updatedAt??0))&&e.set(s.id,s)}return[...e.values()]},"$e"),Fe=j(M.getAuthMetrics),Le=j(M.getFunctionStats),Te=j(M.getLogs),Re=j(M.getMetrics),ze=j(M.migrationStatus),Oe=5,ge=2e3,Ke=5,_e=.1,$e=.3,He=1,Ue=50,Ge=h((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","_e"),Qe=h(t=>{let e=new Map;for(let s of t??[]){let l=e.get(s.bucketMs)??{calls:0,errors:0};l.calls+=s.calls,l.errors+=s.errors,e.set(s.bucketMs,l)}let a=[...e.entries()].toSorted((s,l)=>s[0]-l[0]);return{errors:a.map(([,s])=>s.errors),requests:a.map(([,s])=>s.calls)}},"ze"),Je=h(t=>{let e=0,a=0;for(let l of t)l.status==="failed"?e+=1:l.status==="in_progress"&&(a+=1);let s="ok";return e>0?s="crit":a>0&&(s="warn"),{failed:e,level:s,running:a}},"Ke"),Ve=h((t,e)=>t.failed>0?e("{count} failed",{count:t.failed.toString()}):t.running>0?e("{count} running",{count:t.running.toString()}):e("OK"),"He"),Ne={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},be={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},We={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},Xe=h(t=>t.includes("crit")?"crit":t.includes("warn")?"warn":"ok","Be"),H=h(t=>{let e=(0,Z.c)(19),{chart:a,label:s,level:l,testId:c,value:o}=t,i=Ne[l],n;e[0]!==i?(n=q("size-1.5 shrink-0 rounded-full",i),e[0]=i,e[1]=n):n=e[1];let p;e[2]!==n?(p=(0,r.jsx)("span",{"aria-hidden":"true",className:n}),e[2]=n,e[3]=p):p=e[3];let g;e[4]!==s||e[5]!==p?(g=(0,r.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[p,s]}),e[4]=s,e[5]=p,e[6]=g):g=e[6];let N=be[l],d;e[7]!==N?(d=q("truncate text-2xl font-semibold tabular-nums",N),e[7]=N,e[8]=d):d=e[8];let u;e[9]!==d||e[10]!==c||e[11]!==o?(u=(0,r.jsx)("span",{className:d,"data-testid":c,children:o}),e[9]=d,e[10]=c,e[11]=o,e[12]=u):u=e[12];let x;e[13]!==a||e[14]!==u?(x=(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[u,a]}),e[13]=a,e[14]=u,e[15]=x):x=e[15];let v;return e[16]!==g||e[17]!==x?(v=(0,r.jsx)(A,{className:"gap-0 py-0",children:(0,r.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[g,x]})}),e[16]=g,e[17]=x,e[18]=v):v=e[18],v},"T"),Ye=h(async(t,e,a)=>{let s=await Promise.all(a.map(d=>{let u=W(d);return Promise.allSettled([t.query(Re,{},u),t.query(Le,{},u),t.query(ze,{},u)])})),l=W(e),c=typeof t.schedulerStatus=="function"?t.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[o,i,n]=await Promise.allSettled([t.query(Te,{},l),t.query(Fe,{},l),c]),p=s.map(([d,u,x])=>({functions:u.status==="fulfilled"?u.value.functions:[],metrics:d.status==="fulfilled"?d.value:null,migrations:x.status==="fulfilled"?x.value.migrations:[]})),g=Ie(p),N=s[0]?.[0];return{auth:i.status==="fulfilled"?i.value:null,entries:o.status==="fulfilled"?o.value.entries:[],functions:De(p.map(d=>d.functions)),logsError:o.status==="rejected"?X(o.reason):null,metricsError:g.reachable===0&&N?.status==="rejected"?X(N.reason):null,migrations:Pe(p.map(d=>d.migrations)),scheduler:n.status==="fulfilled"?n.value:null,totals:g}},"Ge"),Ze=h(t=>{let e=t?.history??[];return{attempts:e.map(a=>a.attempts),failures:e.map(a=>a.failures)}},"Qe"),xt=h(({initialShardKey:t})=>{let e=ne(),a=D(),[s,l]=(0,f.useState)([]),[c,o]=(0,f.useState)(null),[i,n]=(0,f.useState)(null),[p,g]=(0,f.useState)(null),[N,d]=(0,f.useState)([]),[u,x]=(0,f.useState)(null),[v,k]=(0,f.useState)(null),[S,E]=(0,f.useState)([]),[b]=(0,f.useState)(de),y=(0,f.useRef)(!1),w=(0,f.useRef)(!0);(0,f.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]);let F=t??"",L=(0,f.useCallback)(async()=>{if(y.current)return;y.current=!0;let m=await Ye(e,F,me(F,b));if(!w.current){y.current=!1;return}n(m.totals),g(m.metricsError),d(m.functions),E(m.migrations),l(m.entries),o(m.logsError),x(m.auth),k(m.scheduler),y.current=!1},[e,b,F]);(0,f.useEffect)(()=>{K(L())},[L]);let G=(0,f.useRef)(0),C=(0,f.useRef)(null),we=h(()=>{let m=Date.now()-G.current;if(m>=ge){G.current=Date.now(),K(L());return}C.current===null&&(C.current=setTimeout(()=>{C.current=null,G.current=Date.now(),K(L())},ge-m))},"de");(0,f.useEffect)(()=>()=>{C.current!==null&&clearTimeout(C.current)},[]);let{data:B,liveError:ye}=ce(M.getMetrics,{},{live:!0,shardKey:F});(0,f.useEffect)(()=>{B!==void 0&&we()},[B]);let ee=s.filter(m=>m.level==="error"),ke=ee.slice(0,Oe),T=Qe(i?.history),te=Ze(u),Se=N.filter(m=>m.calls>0).toSorted((m,V)=>V.errors/V.calls-m.errors/m.calls||V.calls-m.calls).slice(0,Ke),Q=Je(S),Ee=i===null||i.requests===0?0:i.errors/i.requests,J=Y(Ee,xe,ve),re=u===null?"ok":Y(u.failureRate,_e,$e),se=v===null?"ok":Ge(v.backlog,He,Ue),R=Xe([J,re,se,Q.level]),z,O;return R==="crit"?(z=a("Critical"),O=a("One or more service levels are breached.")):R==="warn"?(z=a("Degraded"),O=a("Some service levels need attention.")):(z=a("All systems healthy"),O=a("All service levels are within target.")),(0,r.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[(0,r.jsxs)(A,{className:"gap-0 py-0",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:q("flex size-10 shrink-0 items-center justify-center rounded-full",We[R]),children:(0,r.jsx)("span",{className:q("size-3 rounded-full",Ne[R])})}),(0,r.jsxs)("div",{className:"grid leading-tight",children:[(0,r.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:z}),(0,r.jsx)("span",{className:"text-[13px] text-muted-foreground",children:O})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Requests")}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[T.requests.length>=2&&(0,r.jsx)(_,{ariaLabel:a("Requests over time"),className:"h-6 w-20 text-foreground",series:T.requests,testId:"hl-spark-requests"}),(0,r.jsx)("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:(i?.requests??0).toString()})]})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Error rate")}),(0,r.jsx)("div",{className:q("text-lg font-semibold tabular-nums",be[J]),"data-testid":"hl-error-rate",children:i===null?"\u2014":U(i.errors,i.requests)})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(pe,{}),(0,r.jsx)(ue,{message:ye,prefix:"hl"})]})]})]}),p!==null&&(0,r.jsx)("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-sm text-destructive","data-testid":"hl-metrics-error",role:"alert",children:p})]}),(0,r.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[(0,r.jsx)(H,{chart:T.errors.length>=2?(0,r.jsx)(_,{ariaLabel:a("Errors over time"),className:"h-7 w-20 text-destructive",series:T.errors,testId:"hl-spark-errors"}):void 0,label:a("Error rate"),level:J,testId:"hl-slo-errorrate",value:i===null?"\u2014":U(i.errors,i.requests)}),(0,r.jsx)(H,{chart:te.failures.length>=2?(0,r.jsx)(_,{ariaLabel:a("Auth failures over time"),className:"h-7 w-20 text-destructive",series:te.failures,testId:"hl-spark-auth"}):void 0,label:a("Auth failures"),level:re,testId:"hl-slo-auth",value:u===null?"\u2014":U(u.failures,u.attempts)}),(0,r.jsx)(H,{label:a("Scheduler backlog"),level:se,testId:"hl-slo-backlog",value:v===null?"\u2014":v.backlog.toString()}),(0,r.jsx)(H,{label:a("Migrations"),level:Q.level,testId:"hl-slo-migrations",value:Ve(Q,a)})]}),(0,r.jsx)(je,{errorCount:ee.length,logsError:c,topErrors:ke,worstFunctions:Se}),(0,r.jsxs)(A,{className:"gap-0 py-0",children:[(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Shards seen")}),(0,r.jsx)(P,{"data-testid":"hl-shard-count",variant:"outline",children:b.length})]}),b.length>0&&(0,r.jsx)("ul",{className:"flex flex-wrap gap-1.5 p-4",children:b.map(m=>(0,r.jsx)("li",{"data-testid":"hl-shard",children:(0,r.jsx)(P,{variant:"secondary",children:m})},m))})]})]})},"dt");export{xt as HealthPanel};
|
|
1
|
+
import{b as me,e as _}from"./chunk-MN64D74P.js";import{a as ue}from"./chunk-CTNB2KIA.js";import"./chunk-AQKXMWNF.js";import"./chunk-4UOFSGUS.js";import"./chunk-ILNELDFC.js";import{a as de}from"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{b as P}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import"./chunk-QLQADHFE.js";import{a as M}from"./chunk-ERMTJYQF.js";import{c as ce}from"./chunk-YGKR536O.js";import{f as ne,g as oe}from"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as A}from"./chunk-UZERI5YC.js";import{d as D,f as j,g as W,h as X,m as K,q as ie}from"./chunk-OG4N2XHD.js";import"./chunk-QNUWWC3N.js";import{a as h,e as I,f as qe,g as ae,h as le,j as q}from"./chunk-3XIESWL4.js";var Z=I(ae(),1);var f=I(qe(),1);var fe=I(ae(),1);var $=I(le(),1);var Me={connected:"bg-success",connecting:"bg-warning",idle:"bg-muted-foreground",offline:"bg-destructive"},pe=h(()=>{let t=(0,fe.c)(16),e=D(),a=oe(),s;e:switch(a){case"connected":{let n;t[0]!==e?(n=e("Connected"),t[0]=e,t[1]=n):n=t[1],s=n;break e}case"connecting":{let n;t[2]!==e?(n=e("Connecting\u2026"),t[2]=e,t[3]=n):n=t[3],s=n;break e}case"idle":{let n;t[4]!==e?(n=e("Idle"),t[4]=e,t[5]=n):n=t[5],s=n;break e}case"offline":{let n;t[6]!==e?(n=e("Offline"),t[6]=e,t[7]=n):n=t[7],s=n;break e}default:s=a}let l=Me[a],c;t[8]!==l?(c=q("size-2 rounded-full",l),t[8]=l,t[9]=c):c=t[9];let o;t[10]!==c?(o=(0,$.jsx)("span",{"aria-hidden":"true",className:c}),t[10]=c,t[11]=o):o=t[11];let i;return t[12]!==a||t[13]!==o||t[14]!==s?(i=(0,$.jsxs)("span",{"aria-live":"polite",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground","data-status":a,"data-testid":"dash-connection",role:"status",children:[o,s]}),t[12]=a,t[13]=o,t[14]=s,t[15]=i):i=t[15],i},"j");var r=I(le(),1);var Ae={crit:"destructive",ok:"secondary",warn:"default"},U=h((t,e)=>e===0?"\u2014":`${(t/e*100).toFixed(1)}%`,"_"),Y=h((t,e,a)=>Number.isNaN(t)?"ok":t>=a?"crit":t>=e?"warn":"ok","V"),xe=.01,ve=.05,je=h(t=>{let e=(0,Z.c)(36),{errorCount:a,logsError:s,topErrors:l,worstFunctions:c}=t,o=D(),i;e[0]!==o?(i=o("Functions by error rate"),e[0]=o,e[1]=i):i=e[1];let n;e[2]!==i?(n=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i})}),e[2]=i,e[3]=n):n=e[3];let p;e[4]!==o||e[5]!==c?(p=c.length===0?(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-functions-empty",children:o("No function activity yet.")}):(0,r.jsx)("ul",{className:"divide-y divide-border",children:c.map(w=>(0,r.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-xs","data-testid":"hl-fn-row",children:[(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:w.path}),(0,r.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[(0,r.jsx)("span",{className:"tabular-nums text-muted-foreground",children:o("{count} calls",{count:w.calls.toString()})}),(0,r.jsx)(P,{variant:Ae[Y(w.errors/w.calls,xe,ve)],children:U(w.errors,w.calls)})]})]},w.path))}),e[4]=o,e[5]=c,e[6]=p):p=e[6];let g;e[7]!==n||e[8]!==p?(g=(0,r.jsxs)(A,{className:"gap-0 py-0","data-testid":"hl-functions",children:[n,p]}),e[7]=n,e[8]=p,e[9]=g):g=e[9];let N;e[10]!==o?(N=o("Recent errors"),e[10]=o,e[11]=N):N=e[11];let d;e[12]!==N?(d=(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:N}),e[12]=N,e[13]=d):d=e[13];let u=a>0?"destructive":"outline",x;e[14]!==a||e[15]!==u?(x=(0,r.jsx)(P,{"data-testid":"hl-error-count",variant:u,children:a}),e[14]=a,e[15]=u,e[16]=x):x=e[16];let v;e[17]!==d||e[18]!==x?(v=(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[d,x]}),e[17]=d,e[18]=x,e[19]=v):v=e[19];let k;e[20]!==s?(k=s!==null&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:s}),e[20]=s,e[21]=k):k=e[21];let S;e[22]!==s||e[23]!==o||e[24]!==l.length?(S=s===null&&l.length===0&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-errors-empty",children:o("No recent errors.")}),e[22]=s,e[23]=o,e[24]=l.length,e[25]=S):S=e[25];let E;e[26]!==l?(E=l.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:l.map(Ce)}),e[26]=l,e[27]=E):E=e[27];let b;e[28]!==k||e[29]!==S||e[30]!==E||e[31]!==v?(b=(0,r.jsxs)(A,{className:"gap-0 py-0",children:[v,k,S,E]}),e[28]=k,e[29]=S,e[30]=E,e[31]=v,e[32]=b):b=e[32];let y;return e[33]!==b||e[34]!==g?(y=(0,r.jsxs)("div",{className:"grid gap-3 lg:grid-cols-2",children:[g,b]}),e[33]=b,e[34]=g,e[35]=y):y=e[35],y},"Se");function Ce(t,e){return(0,r.jsxs)("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)("time",{className:"shrink-0 text-muted-foreground",children:ie(t.timestamp)}),t.functionPath!==void 0&&(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:t.functionPath})]}),(0,r.jsx)("span",{className:"text-destructive",children:t.message})]},`${t.timestamp.toString()}-${e.toString()}`)}h(Ce,"Ee");var he={completed:0,failed:2,in_progress:1},Ie=h(t=>{let e=0,a=0,s=0,l=0,c=[];for(let{metrics:o}of t){if(o===null){l+=1;continue}s+=1,e+=o.requests,a+=o.errors,c.push(...o.history??[])}return{errors:a,failed:l,history:c,reachable:s,requests:e}},"Me"),De=h(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.path);if(l===void 0){e.set(s.path,{...s});continue}l.calls+=s.calls,l.errors+=s.errors,l.totalDurationMs+=s.totalDurationMs,l.scans=(l.scans??0)+(s.scans??0),l.maxDurationMs=Math.max(l.maxDurationMs,s.maxDurationMs),l.lastCalledAt=Math.max(l.lastCalledAt,s.lastCalledAt),(s.lastErrorAt??0)>(l.lastErrorAt??0)&&(l.lastErrorAt=s.lastErrorAt,l.lastErrorMessage=s.lastErrorMessage)}return[...e.values()]},"qe"),Pe=h(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.id);if(l===void 0){e.set(s.id,s);continue}let c=he[s.status]-he[l.status];(c>0||c===0&&(s.updatedAt??0)>(l.updatedAt??0))&&e.set(s.id,s)}return[...e.values()]},"$e"),Fe=j(M.getAuthMetrics),Le=j(M.getFunctionStats),Te=j(M.getLogs),Re=j(M.getMetrics),ze=j(M.migrationStatus),Oe=5,ge=2e3,Ke=5,_e=.1,$e=.3,He=1,Ue=50,Ge=h((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","_e"),Qe=h(t=>{let e=new Map;for(let s of t??[]){let l=e.get(s.bucketMs)??{calls:0,errors:0};l.calls+=s.calls,l.errors+=s.errors,e.set(s.bucketMs,l)}let a=[...e.entries()].toSorted((s,l)=>s[0]-l[0]);return{errors:a.map(([,s])=>s.errors),requests:a.map(([,s])=>s.calls)}},"ze"),Je=h(t=>{let e=0,a=0;for(let l of t)l.status==="failed"?e+=1:l.status==="in_progress"&&(a+=1);let s="ok";return e>0?s="crit":a>0&&(s="warn"),{failed:e,level:s,running:a}},"Ke"),Ve=h((t,e)=>t.failed>0?e("{count} failed",{count:t.failed.toString()}):t.running>0?e("{count} running",{count:t.running.toString()}):e("OK"),"He"),Ne={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},be={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},We={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},Xe=h(t=>t.includes("crit")?"crit":t.includes("warn")?"warn":"ok","Be"),H=h(t=>{let e=(0,Z.c)(19),{chart:a,label:s,level:l,testId:c,value:o}=t,i=Ne[l],n;e[0]!==i?(n=q("size-1.5 shrink-0 rounded-full",i),e[0]=i,e[1]=n):n=e[1];let p;e[2]!==n?(p=(0,r.jsx)("span",{"aria-hidden":"true",className:n}),e[2]=n,e[3]=p):p=e[3];let g;e[4]!==s||e[5]!==p?(g=(0,r.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[p,s]}),e[4]=s,e[5]=p,e[6]=g):g=e[6];let N=be[l],d;e[7]!==N?(d=q("truncate text-2xl font-semibold tabular-nums",N),e[7]=N,e[8]=d):d=e[8];let u;e[9]!==d||e[10]!==c||e[11]!==o?(u=(0,r.jsx)("span",{className:d,"data-testid":c,children:o}),e[9]=d,e[10]=c,e[11]=o,e[12]=u):u=e[12];let x;e[13]!==a||e[14]!==u?(x=(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[u,a]}),e[13]=a,e[14]=u,e[15]=x):x=e[15];let v;return e[16]!==g||e[17]!==x?(v=(0,r.jsx)(A,{className:"gap-0 py-0",children:(0,r.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[g,x]})}),e[16]=g,e[17]=x,e[18]=v):v=e[18],v},"T"),Ye=h(async(t,e,a)=>{let s=await Promise.all(a.map(d=>{let u=W(d);return Promise.allSettled([t.query(Re,{},u),t.query(Le,{},u),t.query(ze,{},u)])})),l=W(e),c=typeof t.schedulerStatus=="function"?t.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[o,i,n]=await Promise.allSettled([t.query(Te,{},l),t.query(Fe,{},l),c]),p=s.map(([d,u,x])=>({functions:u.status==="fulfilled"?u.value.functions:[],metrics:d.status==="fulfilled"?d.value:null,migrations:x.status==="fulfilled"?x.value.migrations:[]})),g=Ie(p),N=s[0]?.[0];return{auth:i.status==="fulfilled"?i.value:null,entries:o.status==="fulfilled"?o.value.entries:[],functions:De(p.map(d=>d.functions)),logsError:o.status==="rejected"?X(o.reason):null,metricsError:g.reachable===0&&N?.status==="rejected"?X(N.reason):null,migrations:Pe(p.map(d=>d.migrations)),scheduler:n.status==="fulfilled"?n.value:null,totals:g}},"Ge"),Ze=h(t=>{let e=t?.history??[];return{attempts:e.map(a=>a.attempts),failures:e.map(a=>a.failures)}},"Qe"),xt=h(({initialShardKey:t})=>{let e=ne(),a=D(),[s,l]=(0,f.useState)([]),[c,o]=(0,f.useState)(null),[i,n]=(0,f.useState)(null),[p,g]=(0,f.useState)(null),[N,d]=(0,f.useState)([]),[u,x]=(0,f.useState)(null),[v,k]=(0,f.useState)(null),[S,E]=(0,f.useState)([]),[b]=(0,f.useState)(de),y=(0,f.useRef)(!1),w=(0,f.useRef)(!0);(0,f.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]);let F=t??"",L=(0,f.useCallback)(async()=>{if(y.current)return;y.current=!0;let m=await Ye(e,F,me(F,b));if(!w.current){y.current=!1;return}n(m.totals),g(m.metricsError),d(m.functions),E(m.migrations),l(m.entries),o(m.logsError),x(m.auth),k(m.scheduler),y.current=!1},[e,b,F]);(0,f.useEffect)(()=>{K(L())},[L]);let G=(0,f.useRef)(0),C=(0,f.useRef)(null),we=h(()=>{let m=Date.now()-G.current;if(m>=ge){G.current=Date.now(),K(L());return}C.current===null&&(C.current=setTimeout(()=>{C.current=null,G.current=Date.now(),K(L())},ge-m))},"de");(0,f.useEffect)(()=>()=>{C.current!==null&&clearTimeout(C.current)},[]);let{data:B,liveError:ye}=ce(M.getMetrics,{},{live:!0,shardKey:F});(0,f.useEffect)(()=>{B!==void 0&&we()},[B]);let ee=s.filter(m=>m.level==="error"),ke=ee.slice(0,Oe),T=Qe(i?.history),te=Ze(u),Se=N.filter(m=>m.calls>0).toSorted((m,V)=>V.errors/V.calls-m.errors/m.calls||V.calls-m.calls).slice(0,Ke),Q=Je(S),Ee=i===null||i.requests===0?0:i.errors/i.requests,J=Y(Ee,xe,ve),re=u===null?"ok":Y(u.failureRate,_e,$e),se=v===null?"ok":Ge(v.backlog,He,Ue),R=Xe([J,re,se,Q.level]),z,O;return R==="crit"?(z=a("Critical"),O=a("One or more service levels are breached.")):R==="warn"?(z=a("Degraded"),O=a("Some service levels need attention.")):(z=a("All systems healthy"),O=a("All service levels are within target.")),(0,r.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[(0,r.jsxs)(A,{className:"gap-0 py-0",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:q("flex size-10 shrink-0 items-center justify-center rounded-full",We[R]),children:(0,r.jsx)("span",{className:q("size-3 rounded-full",Ne[R])})}),(0,r.jsxs)("div",{className:"grid leading-tight",children:[(0,r.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:z}),(0,r.jsx)("span",{className:"text-[13px] text-muted-foreground",children:O})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Requests")}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[T.requests.length>=2&&(0,r.jsx)(_,{ariaLabel:a("Requests over time"),className:"h-6 w-20 text-foreground",series:T.requests,testId:"hl-spark-requests"}),(0,r.jsx)("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:(i?.requests??0).toString()})]})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Error rate")}),(0,r.jsx)("div",{className:q("text-lg font-semibold tabular-nums",be[J]),"data-testid":"hl-error-rate",children:i===null?"\u2014":U(i.errors,i.requests)})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(pe,{}),(0,r.jsx)(ue,{message:ye,prefix:"hl"})]})]})]}),p!==null&&(0,r.jsx)("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-sm text-destructive","data-testid":"hl-metrics-error",role:"alert",children:p})]}),(0,r.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[(0,r.jsx)(H,{chart:T.errors.length>=2?(0,r.jsx)(_,{ariaLabel:a("Errors over time"),className:"h-7 w-20 text-destructive",series:T.errors,testId:"hl-spark-errors"}):void 0,label:a("Error rate"),level:J,testId:"hl-slo-errorrate",value:i===null?"\u2014":U(i.errors,i.requests)}),(0,r.jsx)(H,{chart:te.failures.length>=2?(0,r.jsx)(_,{ariaLabel:a("Auth failures over time"),className:"h-7 w-20 text-destructive",series:te.failures,testId:"hl-spark-auth"}):void 0,label:a("Auth failures"),level:re,testId:"hl-slo-auth",value:u===null?"\u2014":U(u.failures,u.attempts)}),(0,r.jsx)(H,{label:a("Scheduler backlog"),level:se,testId:"hl-slo-backlog",value:v===null?"\u2014":v.backlog.toString()}),(0,r.jsx)(H,{label:a("Migrations"),level:Q.level,testId:"hl-slo-migrations",value:Ve(Q,a)})]}),(0,r.jsx)(je,{errorCount:ee.length,logsError:c,topErrors:ke,worstFunctions:Se}),(0,r.jsxs)(A,{className:"gap-0 py-0",children:[(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Shards seen")}),(0,r.jsx)(P,{"data-testid":"hl-shard-count",variant:"outline",children:b.length})]}),b.length>0&&(0,r.jsx)("ul",{className:"flex flex-wrap gap-1.5 p-4",children:b.map(m=>(0,r.jsx)("li",{"data-testid":"hl-shard",children:(0,r.jsx)(P,{variant:"secondary",children:m})},m))})]})]})},"dt");export{xt as HealthPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as T}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as H}from"./chunk-
|
|
1
|
+
import{b as T}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as H}from"./chunk-AHVDZWB3.js";import"./chunk-XXQUMVWH.js";import"./chunk-VORDESEQ.js";import"./chunk-QLQADHFE.js";import{a as B}from"./chunk-ERMTJYQF.js";import{c as z}from"./chunk-YGKR536O.js";import"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as G}from"./chunk-XQCVZAGU.js";import{a as M,b as U,c as $,d as P,e as d,f as c}from"./chunk-MIQTKZAR.js";import{a as C,e as E}from"./chunk-UZERI5YC.js";import{d as q}from"./chunk-OG4N2XHD.js";import"./chunk-QNUWWC3N.js";import{a as S,e as _,g as L,h as V}from"./chunk-3XIESWL4.js";var K=_(L(),1);var r=_(V(),1);var J=["read","insert","update","delete"],W=S((e,t)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[t],"q"),Q=S(e=>{let t=new Map;for(let a of e){let s=t.get(a.table)??{operations:new Set,procedures:new Set,table:a.table};s.operations.add(a.on),s.procedures.add(a.procedure),t.set(a.table,s)}return[...t.values()].toSorted((a,s)=>a.table.localeCompare(s.table))},"B"),ie=S(()=>{let e=(0,K.c)(49),t=q(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let{data:s,error:R,errorSource:k}=z(B.rlsPolicies,a),p=s!==void 0,m,n,h,l,f,u,x,N,o;if(e[1]!==s||e[2]!==R||e[3]!==k||e[4]!==p||e[5]!==t){let F=Q(Array.isArray(s?.policies)?s.policies:[]),D;e[15]!==s?(D=Array.isArray(s?.roles)?s.roles:[],e[15]=s,e[16]=D):D=e[16],n=D,x="flex flex-col gap-6",N="lunora-rls-panel",e[17]!==R||e[18]!==k?(o=R!==null&&(0,r.jsx)(H,{error:k,testId:"rls-error"}),e[17]=R,e[18]=k,e[19]=o):o=e[19],u="flex flex-col gap-2",m=C,h="overflow-hidden py-0";let I;e[20]!==t?(I=t("Policies"),e[20]=t,e[21]=I):I=e[21],e[22]!==I?(l=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:I})}),e[22]=I,e[23]=l):l=e[23],f=p&&F.length===0?(0,r.jsx)(G,{description:t("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:t("No policies defined")}):(0,r.jsx)(E,{className:"px-0",children:(0,r.jsxs)(M,{"data-testid":"rls-policies-table",children:[(0,r.jsx)(U,{children:(0,r.jsxs)(P,{children:[(0,r.jsx)(d,{children:t("Table")}),J.map(i=>(0,r.jsx)(d,{children:W(t,i)},i)),(0,r.jsx)(d,{children:t("Guarded by")})]})}),(0,r.jsx)($,{children:F.map(i=>(0,r.jsxs)(P,{"data-testid":`rls-table-${i.table}`,children:[(0,r.jsx)(c,{className:"font-mono text-xs",children:i.table}),J.map(O=>(0,r.jsx)(c,{children:i.operations.has(O)?(0,r.jsx)(T,{variant:"secondary",children:t("Guarded")}):(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"})},O)),(0,r.jsx)(c,{className:"font-mono text-xs text-muted-foreground",children:[...i.procedures].join(", ")})]},i.table))})]})}),e[1]=s,e[2]=R,e[3]=k,e[4]=p,e[5]=t,e[6]=m,e[7]=n,e[8]=h,e[9]=l,e[10]=f,e[11]=u,e[12]=x,e[13]=N,e[14]=o}else m=e[6],n=e[7],h=e[8],l=e[9],f=e[10],u=e[11],x=e[12],N=e[13],o=e[14];let b;e[24]!==m||e[25]!==h||e[26]!==l||e[27]!==f?(b=(0,r.jsxs)(m,{className:h,children:[l,f]}),e[24]=m,e[25]=h,e[26]=l,e[27]=f,e[28]=b):b=e[28];let g;e[29]!==u||e[30]!==b?(g=(0,r.jsx)("section",{className:u,children:b}),e[29]=u,e[30]=b,e[31]=g):g=e[31];let y;e[32]!==t?(y=t("Roles"),e[32]=t,e[33]=y):y=e[33];let w;e[34]!==y?(w=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y})}),e[34]=y,e[35]=w):w=e[35];let v;e[36]!==p||e[37]!==n||e[38]!==t?(v=p&&n.length===0?(0,r.jsx)(G,{description:t("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:t("No roles defined")}):(0,r.jsx)(E,{className:"px-0",children:(0,r.jsxs)(M,{"data-testid":"rls-roles-table",children:[(0,r.jsx)(U,{children:(0,r.jsxs)(P,{children:[(0,r.jsx)(d,{children:t("Role")}),(0,r.jsx)(d,{children:t("Description")}),(0,r.jsx)(d,{children:t("Permissions")})]})}),(0,r.jsx)($,{children:n.map(Y)})]})}),e[36]=p,e[37]=n,e[38]=t,e[39]=v):v=e[39];let A;e[40]!==w||e[41]!==v?(A=(0,r.jsx)("section",{className:"flex flex-col gap-2",children:(0,r.jsxs)(C,{className:"overflow-hidden py-0",children:[w,v]})}),e[40]=w,e[41]=v,e[42]=A):A=e[42];let j;return e[43]!==A||e[44]!==x||e[45]!==N||e[46]!==o||e[47]!==g?(j=(0,r.jsxs)("div",{className:x,"data-testid":N,children:[o,g,A]}),e[43]=A,e[44]=x,e[45]=N,e[46]=o,e[47]=g,e[48]=j):j=e[48],j},"ae");function X(e){return(0,r.jsx)(T,{variant:"outline",children:e},e)}S(X,"H");function Y(e){return(0,r.jsxs)(P,{"data-testid":`rls-role-${e.name}`,children:[(0,r.jsx)(c,{className:"font-mono text-xs",children:e.name}),(0,r.jsx)(c,{className:"text-muted-foreground",children:e.description??""}),(0,r.jsx)(c,{children:e.permissions.length===0?(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,r.jsx)("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(X)})})]},e.name)}S(Y,"L");export{ie as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as R}from"./chunk-54MMVNPT.js";import{a as E}from"./chunk-
|
|
1
|
+
import{a as R}from"./chunk-54MMVNPT.js";import{a as E}from"./chunk-7AG3T4DK.js";import"./chunk-SFDOII3B.js";import"./chunk-SMIESS7P.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as x}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as T}from"./chunk-AHVDZWB3.js";import"./chunk-XXQUMVWH.js";import"./chunk-VORDESEQ.js";import"./chunk-QLQADHFE.js";import{a as v}from"./chunk-ERMTJYQF.js";import{c as b}from"./chunk-YGKR536O.js";import"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as w}from"./chunk-XQCVZAGU.js";import{a as A,b as j,c as I,d as g,e as c,f as a}from"./chunk-MIQTKZAR.js";import{a as y,e as N}from"./chunk-UZERI5YC.js";import{d as _,q as S}from"./chunk-OG4N2XHD.js";import"./chunk-QNUWWC3N.js";import{a as m,e as M,h as G}from"./chunk-3XIESWL4.js";var e=M(G(),1);var H=["subscriptions","events"],L={},k=new Set(["active","trialing"]),U=new Set(["past_due","unpaid"]),n=m((s,t)=>{if(s[t]!==void 0)return s[t];let p=s.__doc__;if(typeof p=="string")try{let o=JSON.parse(p);if(o!==null&&typeof o=="object"&&!Array.isArray(o))return o[t]}catch{}},"s"),i=m(s=>typeof s=="string"?s:typeof s=="number"||typeof s=="bigint"||typeof s=="boolean"?String(s):"","i"),$=m(s=>k.has(s)?"default":U.has(s)?"destructive":"outline","J"),te=m(({limit:s=100})=>{let t=_(),p=E(),{data:o}=b(v.listTables,L,{live:!0}),D=o!==void 0,O=Array.isArray(o)&&H.every(r=>o.some(l=>l.name===r)),f=p.payments&&O,d=b(v.readTablePage,{filters:[],limit:s,offset:0,orderBy:[],search:"",table:"subscriptions"},{enabled:f}),h=b(v.readTablePage,{filters:[],limit:25,offset:0,orderBy:[],search:"",table:"events"},{enabled:f});R(()=>{f&&(d.refetch(),h.refetch())},!0);let u=d.data?.rows??[],B=h.data?.rows??[],C=d.error??h.error,F=d.error===null?h.errorSource:d.errorSource,P=u.filter(r=>k.has(i(n(r,"state")))).length,J=B.toSorted((r,l)=>Number(n(l,"processedAt")??0)-Number(n(r,"processedAt")??0));return D&&!f?(0,e.jsx)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:(0,e.jsx)(w,{description:t("No @lunora/payment tables found in this deployment. Declare the store tables (subscriptions, events, \u2026) in lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions."),testId:"payments-unconfigured",title:t("No payments configured")})}):(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[(0,e.jsx)("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:(0,e.jsxs)(y,{className:"justify-between gap-0 py-0",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Subscriptions")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:P}),(0,e.jsx)(x,{variant:"default",children:t("{count} active",{count:P})})]})]}),(0,e.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:t("{total} total",{total:u.length})})]})}),C===null?void 0:(0,e.jsx)(T,{error:F}),u.length===0&&!d.isLoading?(0,e.jsx)(w,{testId:"payments-empty",title:t("No subscriptions yet")}):(0,e.jsx)(y,{className:"overflow-hidden py-0",children:(0,e.jsx)(N,{className:"px-0",children:(0,e.jsxs)(A,{children:[(0,e.jsx)(j,{children:(0,e.jsxs)(g,{children:[(0,e.jsx)(c,{children:t("Provider")}),(0,e.jsx)(c,{children:t("Reference")}),(0,e.jsx)(c,{children:t("Plan")}),(0,e.jsx)(c,{children:t("State")}),(0,e.jsx)(c,{children:t("Renews")})]})}),(0,e.jsx)(I,{children:u.map(r=>{let l=i(n(r,"state"));return(0,e.jsxs)(g,{"data-testid":"payment-subscription-row",children:[(0,e.jsx)(a,{children:i(n(r,"provider"))}),(0,e.jsx)(a,{children:i(n(r,"referenceId"))}),(0,e.jsx)(a,{children:i(n(r,"priceId"))}),(0,e.jsx)(a,{children:(0,e.jsx)(x,{variant:$(l),children:l})}),(0,e.jsx)(a,{children:S(n(r,"currentPeriodEnd"))})]},i(n(r,"providerSubscriptionId")))})})]})})}),(0,e.jsxs)(y,{className:"overflow-hidden py-0",children:[(0,e.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Recent webhook events")})}),(0,e.jsx)(N,{className:"px-0",children:(0,e.jsx)(A,{children:(0,e.jsx)(I,{children:J.map(r=>(0,e.jsxs)(g,{"data-testid":"payment-event-row",children:[(0,e.jsx)(a,{children:i(n(r,"provider"))}),(0,e.jsx)(a,{className:"font-medium",children:i(n(r,"type"))}),(0,e.jsx)(a,{className:"text-muted-foreground",children:i(n(r,"providerEventId"))}),(0,e.jsx)(a,{children:S(n(r,"processedAt"))})]},i(n(r,"providerEventId"))))})})})]})]})},"re");export{te as PaymentsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as yt}from"./chunk-V53KNYRN.js";import{a as St}from"./chunk-6VAKZALJ.js";import{a as Nt}from"./chunk-ESVP44Y3.js";import{a as le}from"./chunk-U6TNNM5U.js";import{a as kt}from"./chunk-5Y3QLNWX.js";import{a as Ct}from"./chunk-54MMVNPT.js";import{R as Z}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as L}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{b as ue}from"./chunk-XDAT7LHC.js";import{f as re}from"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{a as ce}from"./chunk-XQCVZAGU.js";import{a as ft,b as pt,c as vt,d as Ze,e as se,f as me}from"./chunk-MIQTKZAR.js";import{a as ht,e as bt}from"./chunk-UZERI5YC.js";import{d as q,h as wt,l as N,m as xt,q as zt}from"./chunk-OG4N2XHD.js";import"./chunk-AADILRJW.js";import{a as c,e as gt,f as Mt,g as Rt,h as Ft}from"./chunk-3XIESWL4.js";var U=gt(Rt(),1);var j=gt(Mt(),1);var n=gt(Ft(),1);var _t=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},"zt"),Et=c(t=>{let e=_t(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},"Tt"),$t=c(t=>t==null||t===""?"":typeof t=="string"?t:JSON.stringify(t,null,2),"St"),W=c(t=>{let e=(0,U.c)(6),{children:r,htmlFor:d,label:h}=t,i;e[0]!==d||e[1]!==h?(i=(0,n.jsx)(kt,{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,n.jsxs)("div",{className:"flex flex-col gap-1",children:[i,r]}),e[3]=r,e[4]=i,e[5]=o):o=e[5],o},"G"),de=c(({busy:t,canSubmit:e,children:r,destructive:d=!1,error:h,onClose:i,onSubmit:o,submitLabel:a,testId:l,title:s})=>{let m=q();return(0,n.jsxs)(Nt,{label:s,onClose:i,panelTestId:`${l}-panel`,testId:`${l}-overlay`,variant:"dialog",children:[(0,n.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:s}),r,h!==null&&(0,n.jsx)("p",{className:"text-sm text-destructive","data-testid":`${l}-error`,role:"alert",children:h}),(0,n.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[(0,n.jsx)(L,{"data-testid":`${l}-cancel`,onClick:i,size:"sm",type:"button",variant:"outline",children:m("Cancel")}),(0,n.jsx)(L,{"data-testid":`${l}-submit`,disabled:t||!e,onClick:o,size:"sm",type:"button",variant:d?"destructive":"default",children:t?m("Saving\u2026"):a})]})]})},"se"),Dt=c(t=>{let e=(0,U.c)(79),{mode:r,onClose:d,onDone:h,org:i}=t,o=re(),a=q(),{busy:l,error:s,run:m}=le(),b;e[0]!==i?(b=i?N(i.name):"",e[0]=i,e[1]=b):b=e[1];let[u,g]=(0,j.useState)(b),p;e[2]!==i?(p=i?N(i.slug):"",e[2]=i,e[3]=p):p=e[3];let[f,y]=(0,j.useState)(p),z;e[4]!==i?(z=i?N(i.logo):"",e[4]=i,e[5]=z):z=e[5];let[v,I]=(0,j.useState)(z),[C,k]=(0,j.useState)(""),w;e[6]!==r||e[7]!==i?.metadata?(w=r==="edit"?$t(i?.metadata):"",e[6]=r,e[7]=i?.metadata,e[8]=w):w=e[8];let[x,S]=(0,j.useState)(w),_;e[9]!==o||e[10]!==v||e[11]!==x||e[12]!==r||e[13]!==u||e[14]!==d||e[15]!==h||e[16]!==i?.id||e[17]!==C||e[18]!==m||e[19]!==f?(_=c(()=>{m(async()=>{let F=x.trim()===""?void 0:_t(x);r==="create"?await o.createAuthOrganization({logo:v.trim()===""?void 0:v.trim(),metadata:F,name:u.trim(),ownerId:C.trim()===""?void 0:C.trim(),slug:f.trim()===""?void 0:f.trim()}):await o.updateAuthOrganization({logo:v.trim()===""?void 0:v.trim(),metadata:F,name:u.trim()===""?void 0:u.trim(),organizationId:N(i?.id),slug:f.trim()===""?void 0:f.trim()}),h(),d()})},"D"),e[9]=o,e[10]=v,e[11]=x,e[12]=r,e[13]=u,e[14]=d,e[15]=h,e[16]=i?.id,e[17]=C,e[18]=m,e[19]=f,e[20]=_):_=e[20];let A=_,D;e[21]!==r||e[22]!==u?(D=u.trim()!==""||r==="edit",e[21]=r,e[22]=u,e[23]=D):D=e[23];let $;e[24]!==r||e[25]!==a?($=a(r==="create"?"Create":"Save"),e[24]=r,e[25]=a,e[26]=$):$=e[26];let T;e[27]!==r||e[28]!==a?(T=a(r==="create"?"New organization":"Edit organization"),e[27]=r,e[28]=a,e[29]=T):T=e[29];let P;e[30]!==a?(P=a("name"),e[30]=a,e[31]=P):P=e[31];let Q;e[32]===Symbol.for("react.memo_cache_sentinel")?(Q=c(F=>{g(F.target.value)},"q"),e[32]=Q):Q=e[32];let J;e[33]!==u?(J=(0,n.jsx)(Z,{"data-testid":"org-form-name",id:"org-form-name",onChange:Q,value:u}),e[33]=u,e[34]=J):J=e[34];let E;e[35]!==J||e[36]!==P?(E=(0,n.jsx)(W,{htmlFor:"org-form-name",label:P,children:J}),e[35]=J,e[36]=P,e[37]=E):E=e[37];let B;e[38]!==a?(B=a("Slug (optional \u2014 derived from name)"),e[38]=a,e[39]=B):B=e[39];let Y;e[40]===Symbol.for("react.memo_cache_sentinel")?(Y=c(F=>{y(F.target.value)},"Q"),e[40]=Y):Y=e[40];let M;e[41]!==f?(M=(0,n.jsx)(Z,{"data-testid":"org-form-slug",id:"org-form-slug",onChange:Y,value:f}),e[41]=f,e[42]=M):M=e[42];let R;e[43]!==B||e[44]!==M?(R=(0,n.jsx)(W,{htmlFor:"org-form-slug",label:B,children:M}),e[43]=B,e[44]=M,e[45]=R):R=e[45];let H;e[46]!==a?(H=a("Logo URL (optional)"),e[46]=a,e[47]=H):H=e[47];let ie;e[48]===Symbol.for("react.memo_cache_sentinel")?(ie=c(F=>{I(F.target.value)},"le"),e[48]=ie):ie=e[48];let K;e[49]!==v?(K=(0,n.jsx)(Z,{"data-testid":"org-form-logo",id:"org-form-logo",onChange:ie,value:v}),e[49]=v,e[50]=K):K=e[50];let ee;e[51]!==H||e[52]!==K?(ee=(0,n.jsx)(W,{htmlFor:"org-form-logo",label:H,children:K}),e[51]=H,e[52]=K,e[53]=ee):ee=e[53];let X;e[54]!==r||e[55]!==C||e[56]!==a?(X=r==="create"&&(0,n.jsx)(W,{htmlFor:"org-form-owner",label:a("Owner user id (optional)"),children:(0,n.jsx)(Z,{"data-testid":"org-form-owner",id:"org-form-owner",onChange:c(F=>{k(F.target.value)},"onChange"),value:C})}),e[54]=r,e[55]=C,e[56]=a,e[57]=X):X=e[57];let te;e[58]!==a?(te=a("Metadata (JSON, optional)"),e[58]=a,e[59]=te):te=e[59];let oe;e[60]===Symbol.for("react.memo_cache_sentinel")?(oe=c(F=>{S(F.target.value)},"re"),e[60]=oe):oe=e[60];let V;e[61]!==x?(V=(0,n.jsx)(yt,{"data-testid":"org-form-metadata",id:"org-form-metadata",onChange:oe,value:x}),e[61]=x,e[62]=V):V=e[62];let O;e[63]!==te||e[64]!==V?(O=(0,n.jsx)(W,{htmlFor:"org-form-metadata",label:te,children:V}),e[63]=te,e[64]=V,e[65]=O):O=e[65];let ne;return e[66]!==l||e[67]!==s||e[68]!==d||e[69]!==A||e[70]!==E||e[71]!==R||e[72]!==ee||e[73]!==X||e[74]!==O||e[75]!==D||e[76]!==$||e[77]!==T?(ne=(0,n.jsxs)(de,{busy:l,canSubmit:D,error:s,onClose:d,onSubmit:A,submitLabel:$,testId:"org-form",title:T,children:[E,R,ee,X,O]}),e[66]=l,e[67]=s,e[68]=d,e[69]=A,e[70]=E,e[71]=R,e[72]=ee,e[73]=X,e[74]=O,e[75]=D,e[76]=$,e[77]=T,e[78]=ne):ne=e[78],ne},"bt"),Lt=c(t=>{let e=(0,U.c)(40),{onClose:r,onDone:d,organizationId:h}=t,i=re(),o=q(),{busy:a,error:l,run:s}=le(),[m,b]=(0,j.useState)(""),[u,g]=(0,j.useState)(""),p;e[0]!==i||e[1]!==r||e[2]!==d||e[3]!==h||e[4]!==u||e[5]!==s||e[6]!==m?(p=c(()=>{s(async()=>{await i.addAuthOrgMember({organizationId:h,role:u.trim()===""?void 0:u.trim(),userId:m.trim()}),d(),r()})},"f"),e[0]=i,e[1]=r,e[2]=d,e[3]=h,e[4]=u,e[5]=s,e[6]=m,e[7]=p):p=e[7];let f=p,y;e[8]!==m?(y=m.trim(),e[8]=m,e[9]=y):y=e[9];let z=y!=="",v;e[10]!==o?(v=o("Add member"),e[10]=o,e[11]=v):v=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 k;e[16]===Symbol.for("react.memo_cache_sentinel")?(k=c(T=>{b(T.target.value)},"x"),e[16]=k):k=e[16];let w;e[17]!==m?(w=(0,n.jsx)(Z,{"data-testid":"org-add-member-user",id:"org-add-member-user",onChange:k,value:m}),e[17]=m,e[18]=w):w=e[18];let x;e[19]!==C||e[20]!==w?(x=(0,n.jsx)(W,{htmlFor:"org-add-member-user",label:C,children:w}),e[19]=C,e[20]=w,e[21]=x):x=e[21];let S;e[22]!==o?(S=o("Role (optional)"),e[22]=o,e[23]=S):S=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=c(T=>{g(T.target.value)},"D"),e[24]=_):_=e[24];let A;e[25]!==u?(A=(0,n.jsx)(Z,{"data-testid":"org-add-member-role",id:"org-add-member-role",onChange:_,value:u}),e[25]=u,e[26]=A):A=e[26];let D;e[27]!==S||e[28]!==A?(D=(0,n.jsx)(W,{htmlFor:"org-add-member-role",label:S,children:A}),e[27]=S,e[28]=A,e[29]=D):D=e[29];let $;return e[30]!==a||e[31]!==l||e[32]!==r||e[33]!==f||e[34]!==D||e[35]!==z||e[36]!==v||e[37]!==I||e[38]!==x?($=(0,n.jsxs)(de,{busy:a,canSubmit:z,error:l,onClose:r,onSubmit:f,submitLabel:v,testId:"org-add-member",title:I,children:[x,D]}),e[30]=a,e[31]=l,e[32]=r,e[33]=f,e[34]=D,e[35]=z,e[36]=v,e[37]=I,e[38]=x,e[39]=$):$=e[39],$},"Mt"),jt=c(t=>{let e=(0,U.c)(40),{onClose:r,onDone:d,organizationId:h}=t,i=re(),o=q(),{busy:a,error:l,run:s}=le(),[m,b]=(0,j.useState)(""),[u,g]=(0,j.useState)(""),p;e[0]!==i||e[1]!==m||e[2]!==r||e[3]!==d||e[4]!==h||e[5]!==u||e[6]!==s?(p=c(()=>{s(async()=>{await i.inviteAuthOrgMember({email:m.trim(),organizationId:h,role:u.trim()===""?void 0:u.trim()}),d(),r()})},"f"),e[0]=i,e[1]=m,e[2]=r,e[3]=d,e[4]=h,e[5]=u,e[6]=s,e[7]=p):p=e[7];let f=p,y;e[8]!==m?(y=m.trim(),e[8]=m,e[9]=y):y=e[9];let z=y!=="",v;e[10]!==o?(v=o("Send invitation"),e[10]=o,e[11]=v):v=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 k;e[16]===Symbol.for("react.memo_cache_sentinel")?(k=c(T=>{b(T.target.value)},"x"),e[16]=k):k=e[16];let w;e[17]!==m?(w=(0,n.jsx)(Z,{"data-testid":"org-invite-member-email",id:"org-invite-member-email",onChange:k,type:"email",value:m}),e[17]=m,e[18]=w):w=e[18];let x;e[19]!==C||e[20]!==w?(x=(0,n.jsx)(W,{htmlFor:"org-invite-member-email",label:C,children:w}),e[19]=C,e[20]=w,e[21]=x):x=e[21];let S;e[22]!==o?(S=o("Role (optional)"),e[22]=o,e[23]=S):S=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=c(T=>{g(T.target.value)},"D"),e[24]=_):_=e[24];let A;e[25]!==u?(A=(0,n.jsx)(Z,{"data-testid":"org-invite-member-role",id:"org-invite-member-role",onChange:_,value:u}),e[25]=u,e[26]=A):A=e[26];let D;e[27]!==S||e[28]!==A?(D=(0,n.jsx)(W,{htmlFor:"org-invite-member-role",label:S,children:A}),e[27]=S,e[28]=A,e[29]=D):D=e[29];let $;return e[30]!==a||e[31]!==l||e[32]!==r||e[33]!==f||e[34]!==D||e[35]!==z||e[36]!==v||e[37]!==I||e[38]!==x?($=(0,n.jsxs)(de,{busy:a,canSubmit:z,error:l,onClose:r,onSubmit:f,submitLabel:v,testId:"org-invite-member",title:I,children:[x,D]}),e[30]=a,e[31]=l,e[32]=r,e[33]=f,e[34]=D,e[35]=z,e[36]=v,e[37]=I,e[38]=x,e[39]=$):$=e[39],$},"Ft"),Pt=c(t=>{let e=(0,U.c)(32),{member:r,onClose:d,onDone:h}=t,i=re(),o=q(),{busy:a,error:l,run:s}=le(),m;e[0]!==r.role?(m=c(()=>N(r.role),"m"),e[0]=r.role,e[1]=m):m=e[1];let[b,u]=(0,j.useState)(m),g;e[2]!==i||e[3]!==r.id||e[4]!==d||e[5]!==h||e[6]!==b||e[7]!==s?(g=c(()=>{s(async()=>{await i.setAuthOrgMemberRole({memberId:N(r.id),role:b.trim()}),h(),d()})},"u"),e[2]=i,e[3]=r.id,e[4]=d,e[5]=h,e[6]=b,e[7]=s,e[8]=g):g=e[8];let p=g,f;e[9]!==b?(f=b.trim(),e[9]=b,e[10]=f):f=e[10];let y=f!=="",z;e[11]!==o?(z=o("Save"),e[11]=o,e[12]=z):z=e[12];let v;e[13]!==o?(v=o("Change member role"),e[13]=o,e[14]=v):v=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(S=>{u(S.target.value)},"y"),e[17]=C):C=e[17];let k;e[18]!==b?(k=(0,n.jsx)(Z,{"data-testid":"org-member-role-value",id:"org-member-role-value",onChange:C,value:b}),e[18]=b,e[19]=k):k=e[19];let w;e[20]!==I||e[21]!==k?(w=(0,n.jsx)(W,{htmlFor:"org-member-role-value",label:I,children:k}),e[20]=I,e[21]=k,e[22]=w):w=e[22];let x;return e[23]!==a||e[24]!==l||e[25]!==d||e[26]!==p||e[27]!==w||e[28]!==y||e[29]!==z||e[30]!==v?(x=(0,n.jsx)(de,{busy:a,canSubmit:y,error:l,onClose:d,onSubmit:p,submitLabel:z,testId:"org-member-role",title:v,children:w}),e[23]=a,e[24]=l,e[25]=d,e[26]=p,e[27]=w,e[28]=y,e[29]=z,e[30]=v,e[31]=x):x=e[31],x},"Et"),At=c(t=>{let e=(0,U.c)(36),{mode:r,onClose:d,onDone:h,organizationId:i,team:o}=t,a=re(),l=q(),{busy:s,error:m,run:b}=le(),u;e[0]!==o?(u=o?N(o.name):"",e[0]=o,e[1]=u):u=e[1];let[g,p]=(0,j.useState)(u),f;e[2]!==a||e[3]!==r||e[4]!==g||e[5]!==d||e[6]!==h||e[7]!==i||e[8]!==b||e[9]!==o?.id?(f=c(()=>{b(async()=>{await(r==="create"?a.createAuthOrgTeam({name:g.trim(),organizationId:i}):a.updateAuthOrgTeam({name:g.trim(),teamId:N(o?.id)})),h(),d()})},"b"),e[2]=a,e[3]=r,e[4]=g,e[5]=d,e[6]=h,e[7]=i,e[8]=b,e[9]=o?.id,e[10]=f):f=e[10];let y=f,z;e[11]!==g?(z=g.trim(),e[11]=g,e[12]=z):z=e[12];let v=z!=="",I;e[13]!==r||e[14]!==l?(I=l(r==="create"?"Create":"Save"),e[13]=r,e[14]=l,e[15]=I):I=e[15];let C;e[16]!==r||e[17]!==l?(C=l(r==="create"?"New team":"Rename team"),e[16]=r,e[17]=l,e[18]=C):C=e[18];let k;e[19]!==l?(k=l("name"),e[19]=l,e[20]=k):k=e[20];let w;e[21]===Symbol.for("react.memo_cache_sentinel")?(w=c(A=>{p(A.target.value)},"$"),e[21]=w):w=e[21];let x;e[22]!==g?(x=(0,n.jsx)(Z,{"data-testid":"org-team-form-name",id:"org-team-form-name",onChange:w,value:g}),e[22]=g,e[23]=x):x=e[23];let S;e[24]!==k||e[25]!==x?(S=(0,n.jsx)(W,{htmlFor:"org-team-form-name",label:k,children:x}),e[24]=k,e[25]=x,e[26]=S):S=e[26];let _;return e[27]!==s||e[28]!==m||e[29]!==d||e[30]!==y||e[31]!==S||e[32]!==v||e[33]!==I||e[34]!==C?(_=(0,n.jsx)(de,{busy:s,canSubmit:v,error:m,onClose:d,onSubmit:y,submitLabel:I,testId:"org-team-form",title:C,children:S}),e[27]=s,e[28]=m,e[29]=d,e[30]=y,e[31]=S,e[32]=v,e[33]=I,e[34]=C,e[35]=_):_=e[35],_},"ft"),Jt=c(t=>{let e=(0,U.c)(30),{onClose:r,onDone:d,teamId:h}=t,i=re(),o=q(),{busy:a,error:l,run:s}=le(),[m,b]=(0,j.useState)(""),u;e[0]!==i||e[1]!==r||e[2]!==d||e[3]!==s||e[4]!==h||e[5]!==m?(u=c(()=>{s(async()=>{await i.addAuthOrgTeamMember({teamId:h,userId:m.trim()}),d(),r()})},"c"),e[0]=i,e[1]=r,e[2]=d,e[3]=s,e[4]=h,e[5]=m,e[6]=u):u=e[6];let g=u,p;e[7]!==m?(p=m.trim(),e[7]=m,e[8]=p):p=e[8];let f=p!=="",y;e[9]!==o?(y=o("Add member"),e[9]=o,e[10]=y):y=e[10];let z;e[11]!==o?(z=o("Add team member"),e[11]=o,e[12]=z):z=e[12];let v;e[13]!==o?(v=o("User id"),e[13]=o,e[14]=v):v=e[14];let I;e[15]===Symbol.for("react.memo_cache_sentinel")?(I=c(x=>{b(x.target.value)},"C"),e[15]=I):I=e[15];let C;e[16]!==m?(C=(0,n.jsx)(Z,{"data-testid":"org-team-add-member-user",id:"org-team-add-member-user",onChange:I,value:m}),e[16]=m,e[17]=C):C=e[17];let k;e[18]!==v||e[19]!==C?(k=(0,n.jsx)(W,{htmlFor:"org-team-add-member-user",label:v,children:C}),e[18]=v,e[19]=C,e[20]=k):k=e[20];let w;return e[21]!==a||e[22]!==l||e[23]!==r||e[24]!==g||e[25]!==f||e[26]!==y||e[27]!==z||e[28]!==k?(w=(0,n.jsx)(de,{busy:a,canSubmit:f,error:l,onClose:r,onSubmit:g,submitLabel:y,testId:"org-team-add-member",title:z,children:k}),e[21]=a,e[22]=l,e[23]=r,e[24]=g,e[25]=f,e[26]=y,e[27]=z,e[28]=k,e[29]=w):w=e[29],w},"Lt"),Ot=c(t=>{let e=(0,U.c)(47),{mode:r,onClose:d,onDone:h,organizationId:i,role:o}=t,a=re(),l=q(),{busy:s,error:m,run:b}=le(),u;e[0]!==o?(u=o?N(o.role):"",e[0]=o,e[1]=u):u=e[1];let[g,p]=(0,j.useState)(u),f;e[2]!==r||e[3]!==o?.permission?(f=r==="edit"?$t(o?.permission):"",e[2]=r,e[3]=o?.permission,e[4]=f):f=e[4];let[y,z]=(0,j.useState)(f),v;e[5]!==a||e[6]!==r||e[7]!==g||e[8]!==d||e[9]!==h||e[10]!==i||e[11]!==y||e[12]!==o?.id||e[13]!==b?(v=c(()=>{b(async()=>{let T=Et(y);await(r==="create"?a.createAuthOrgRole({organizationId:i,permission:T,role:g.trim()}):a.updateAuthOrgRole({permission:T,roleId:N(o?.id)})),h(),d()})},"p"),e[5]=a,e[6]=r,e[7]=g,e[8]=d,e[9]=h,e[10]=i,e[11]=y,e[12]=o?.id,e[13]=b,e[14]=v):v=e[14];let I=v,C;e[15]!==r||e[16]!==g||e[17]!==y?(C=y.trim()!==""&&(r==="edit"||g.trim()!==""),e[15]=r,e[16]=g,e[17]=y,e[18]=C):C=e[18];let k;e[19]!==r||e[20]!==l?(k=l(r==="create"?"Create":"Save"),e[19]=r,e[20]=l,e[21]=k):k=e[21];let w;e[22]!==r||e[23]!==l?(w=l(r==="create"?"New role":"Edit role"),e[22]=r,e[23]=l,e[24]=w):w=e[24];let x;e[25]!==r||e[26]!==g||e[27]!==l?(x=r==="create"&&(0,n.jsx)(W,{htmlFor:"org-role-form-name",label:l("Role name"),children:(0,n.jsx)(Z,{"data-testid":"org-role-form-name",id:"org-role-form-name",onChange:c(T=>{p(T.target.value)},"onChange"),value:g})}),e[25]=r,e[26]=g,e[27]=l,e[28]=x):x=e[28];let S;e[29]!==l?(S=l('Permission (JSON, e.g. {"project":["create","update"]})'),e[29]=l,e[30]=S):S=e[30];let _;e[31]===Symbol.for("react.memo_cache_sentinel")?(_=c(T=>{z(T.target.value)},"D"),e[31]=_):_=e[31];let A;e[32]!==y?(A=(0,n.jsx)(yt,{"data-testid":"org-role-form-permission",id:"org-role-form-permission",onChange:_,value:y}),e[32]=y,e[33]=A):A=e[33];let D;e[34]!==A||e[35]!==S?(D=(0,n.jsx)(W,{htmlFor:"org-role-form-permission",label:S,children:A}),e[34]=A,e[35]=S,e[36]=D):D=e[36];let $;return e[37]!==s||e[38]!==m||e[39]!==d||e[40]!==I||e[41]!==D||e[42]!==C||e[43]!==k||e[44]!==w||e[45]!==x?($=(0,n.jsxs)(de,{busy:s,canSubmit:C,error:m,onClose:d,onSubmit:I,submitLabel:k,testId:"org-role-form",title:w,children:[x,D]}),e[37]=s,e[38]=m,e[39]=d,e[40]=I,e[41]=D,e[42]=C,e[43]=k,e[44]=w,e[45]=x,e[46]=$):$=e[46],$},"pt"),Tt=c(t=>{let e=(0,U.c)(18),{action:r,message:d,onClose:h,onDone:i,testId:o,title:a}=t,l=q(),{busy:s,error:m,run:b}=le(),u;e[0]!==r||e[1]!==h||e[2]!==i||e[3]!==b?(u=c(()=>{b(async()=>{await r(),i(),h()})},"c"),e[0]=r,e[1]=h,e[2]=i,e[3]=b,e[4]=u):u=e[4];let g=u,p;e[5]!==l?(p=l("Delete"),e[5]=l,e[6]=p):p=e[6];let f;e[7]!==d?(f=(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:d}),e[7]=d,e[8]=f):f=e[8];let y;return e[9]!==s||e[10]!==m||e[11]!==h||e[12]!==g||e[13]!==p||e[14]!==f||e[15]!==o||e[16]!==a?(y=(0,n.jsx)(de,{busy:s,canSubmit:!0,destructive:!0,error:m,onClose:h,onSubmit:g,submitLabel:p,testId:o,title:a,children:f}),e[9]=s,e[10]=m,e[11]=h,e[12]=g,e[13]=p,e[14]=f,e[15]=o,e[16]=a,e[17]=y):y=e[17],y},"kt"),Ge=c(t=>{let e=(0,U.c)(13),{action:r,children:d,heading:h,testId:i}=t,o;e[0]!==h?(o=(0,n.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 a;e[2]!==r?(a=r!==void 0&&(0,n.jsx)("div",{className:"flex items-center gap-2",children:r}),e[2]=r,e[3]=a):a=e[3];let l;e[4]!==o||e[5]!==a?(l=(0,n.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[o,a]}),e[4]=o,e[5]=a,e[6]=l):l=e[6];let s;e[7]!==d?(s=(0,n.jsx)(bt,{className:"px-0",children:d}),e[7]=d,e[8]=s):s=e[8];let m;return e[9]!==l||e[10]!==s||e[11]!==i?(m=(0,n.jsxs)(ht,{className:"overflow-hidden py-0","data-testid":i,children:[l,s]}),e[9]=l,e[10]=s,e[11]=i,e[12]=m):m=e[12],m},"Ve"),Ke=c(t=>{let e=(0,U.c)(23),{columns:r,rowActions:d,rowPrefix:h,rows:i}=t,o=q(),a;e[0]!==r?(a=r.map(Bt),e[0]=r,e[1]=a):a=e[1];let l;e[2]!==o?(l=o("Actions"),e[2]=o,e[3]=l):l=e[3];let s;e[4]!==l?(s=(0,n.jsx)(se,{"aria-label":l}),e[4]=l,e[5]=s):s=e[5];let m;e[6]!==a||e[7]!==s?(m=(0,n.jsx)(pt,{children:(0,n.jsxs)(Ze,{children:[a,s]})}),e[6]=a,e[7]=s,e[8]=m):m=e[8];let b;if(e[9]!==r||e[10]!==d||e[11]!==h||e[12]!==i){let p;e[14]!==r||e[15]!==d||e[16]!==h?(p=c((f,y)=>{let z=N(f.id),v=z===""?`index-${y.toString()}`:z;return(0,n.jsxs)(Ze,{"data-testid":`${h}-${v}`,children:[r.map(I=>(0,n.jsx)(me,{className:I.className,children:I.render(f)},I.head)),(0,n.jsx)(me,{children:(0,n.jsx)("div",{className:"flex justify-end gap-1",children:d(f)})})]},v)},"f"),e[14]=r,e[15]=d,e[16]=h,e[17]=p):p=e[17],b=i.map(p),e[9]=r,e[10]=d,e[11]=h,e[12]=i,e[13]=b}else b=e[13];let u;e[18]!==b?(u=(0,n.jsx)(vt,{children:b}),e[18]=b,e[19]=u):u=e[19];let g;return e[20]!==m||e[21]!==u?(g=(0,n.jsxs)(ft,{children:[m,u]}),e[20]=m,e[21]=u,e[22]=g):g=e[22],g},"Xe");function Bt(t){return(0,n.jsx)(se,{children:t.head},t.head)}c(Bt,"jt");var Ut=c(t=>{let e=(0,U.c)(30),{actionBusy:r,onRemoveMember:d,memberColumns:h,members:i,onDialog:o}=t,a=q(),l;e[0]!==o?(l=c(()=>{o({kind:"add-member"})},"a"),e[0]=o,e[1]=l):l=e[1];let s;e[2]!==a?(s=a("Add member"),e[2]=a,e[3]=s):s=e[3];let m;e[4]!==l||e[5]!==s?(m=(0,n.jsx)(L,{"data-testid":"org-open-add-member",onClick:l,size:"xs",type:"button",variant:"outline",children:s}),e[4]=l,e[5]=s,e[6]=m):m=e[6];let b;e[7]!==o?(b=c(()=>{o({kind:"invite-member"})},"h"),e[7]=o,e[8]=b):b=e[8];let u;e[9]!==a?(u=a("Invite member"),e[9]=a,e[10]=u):u=e[10];let g;e[11]!==b||e[12]!==u?(g=(0,n.jsx)(L,{"data-testid":"org-open-invite-member",onClick:b,size:"xs",type:"button",variant:"outline",children:u}),e[11]=b,e[12]=u,e[13]=g):g=e[13];let p;e[14]!==m||e[15]!==g?(p=(0,n.jsxs)(n.Fragment,{children:[m,g]}),e[14]=m,e[15]=g,e[16]=p):p=e[16];let f;e[17]!==a?(f=a("Members"),e[17]=a,e[18]=f):f=e[18];let y;e[19]!==r||e[20]!==h||e[21]!==i||e[22]!==o||e[23]!==d||e[24]!==a?(y=i.length===0?(0,n.jsx)("div",{className:"p-3",children:(0,n.jsx)(ce,{testId:"org-members-empty",title:a("No members.")})}):(0,n.jsx)(Ke,{columns:h,rowActions:c(v=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(L,{"data-testid":`org-member-role-${N(v.id)}`,onClick:c(()=>{o({kind:"member-role",member:v})},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Change role")}),(0,n.jsx)(L,{"data-testid":`org-remove-member-${N(v.id)}`,disabled:r,onClick:c(()=>{d(N(v.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Remove")})]}),"rowActions"),rowPrefix:"org-member",rows:i}),e[19]=r,e[20]=h,e[21]=i,e[22]=o,e[23]=d,e[24]=a,e[25]=y):y=e[25];let z;return e[26]!==p||e[27]!==f||e[28]!==y?(z=(0,n.jsx)(Ge,{action:p,heading:f,testId:"org-members",children:y}),e[26]=p,e[27]=f,e[28]=y,e[29]=z):z=e[29],z},"Pt"),qt=c(t=>{let e=(0,U.c)(21),{onConfirmDeleteTeam:r,onDialog:d,onSelectTeam:h,selectedTeam:i,teamColumns:o,teams:a}=t,l=q(),s;e[0]!==d?(s=c(()=>{d({kind:"team-create"})},"s"),e[0]=d,e[1]=s):s=e[1];let m;e[2]!==l?(m=l("New team"),e[2]=l,e[3]=m):m=e[3];let b;e[4]!==s||e[5]!==m?(b=(0,n.jsx)(L,{"data-testid":"org-open-create-team",onClick:s,size:"xs",type:"button",variant:"outline",children:m}),e[4]=s,e[5]=m,e[6]=b):b=e[6];let u;e[7]!==l?(u=l("Teams"),e[7]=l,e[8]=u):u=e[8];let g;e[9]!==r||e[10]!==d||e[11]!==h||e[12]!==i||e[13]!==l||e[14]!==o||e[15]!==a?(g=a.length===0?(0,n.jsx)("div",{className:"p-3",children:(0,n.jsx)(ce,{testId:"org-teams-empty",title:l("No teams.")})}):(0,n.jsx)(Ke,{columns:o,rowActions:c(f=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(L,{"aria-pressed":i===N(f.id),"data-testid":`org-team-select-${N(f.id)}`,onClick:c(()=>{h(N(f.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Members")}),(0,n.jsx)(L,{"data-testid":`org-team-rename-${N(f.id)}`,onClick:c(()=>{d({kind:"team-rename",team:f})},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Rename")}),(0,n.jsx)(L,{"data-testid":`org-team-delete-${N(f.id)}`,onClick:c(()=>{r(f)},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Delete")})]}),"rowActions"),rowPrefix:"org-team",rows:a}),e[9]=r,e[10]=d,e[11]=h,e[12]=i,e[13]=l,e[14]=o,e[15]=a,e[16]=g):g=e[16];let p;return e[17]!==b||e[18]!==u||e[19]!==g?(p=(0,n.jsx)(Ge,{action:b,heading:u,testId:"org-teams",children:g}),e[17]=b,e[18]=u,e[19]=g,e[20]=p):p=e[20],p},"Bt"),Ht=c(t=>{let e=(0,U.c)(20),{actionBusy:r,onRemoveTeamMember:d,onDialog:h,selectedTeam:i,teamMemberColumns:o,teamMembers:a}=t,l=q(),s;e[0]!==h||e[1]!==i?(s=c(()=>{h({kind:"team-add-member",teamId:i})},"s"),e[0]=h,e[1]=i,e[2]=s):s=e[2];let m;e[3]!==l?(m=l("Add member"),e[3]=l,e[4]=m):m=e[4];let b;e[5]!==s||e[6]!==m?(b=(0,n.jsx)(L,{"data-testid":"org-open-add-team-member",onClick:s,size:"xs",type:"button",variant:"outline",children:m}),e[5]=s,e[6]=m,e[7]=b):b=e[7];let u;e[8]!==l?(u=l("Team members"),e[8]=l,e[9]=u):u=e[9];let g;e[10]!==r||e[11]!==d||e[12]!==l||e[13]!==o||e[14]!==a?(g=a.length===0?(0,n.jsx)("div",{className:"p-3",children:(0,n.jsx)(ce,{testId:"org-team-members-empty",title:l("No team members.")})}):(0,n.jsx)(Ke,{columns:o,rowActions:c(f=>(0,n.jsx)(L,{"data-testid":`org-team-remove-member-${N(f.id)}`,disabled:r,onClick:c(()=>{d(N(f.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Remove")}),"rowActions"),rowPrefix:"org-team-member",rows:a}),e[10]=r,e[11]=d,e[12]=l,e[13]=o,e[14]=a,e[15]=g):g=e[15];let p;return e[16]!==b||e[17]!==u||e[18]!==g?(p=(0,n.jsx)(Ge,{action:b,heading:u,testId:"org-team-members",children:g}),e[16]=b,e[17]=u,e[18]=g,e[19]=p):p=e[19],p},"Jt"),Qt=c(t=>{let e=(0,U.c)(19),{onConfirmDeleteRole:r,onDialog:d,roleColumns:h,roles:i}=t,o=q(),a;e[0]!==d?(a=c(()=>{d({kind:"role-create"})},"n"),e[0]=d,e[1]=a):a=e[1];let l;e[2]!==o?(l=o("New role"),e[2]=o,e[3]=l):l=e[3];let s;e[4]!==a||e[5]!==l?(s=(0,n.jsx)(L,{"data-testid":"org-open-create-role",onClick:a,size:"xs",type:"button",variant:"outline",children:l}),e[4]=a,e[5]=l,e[6]=s):s=e[6];let m;e[7]!==o?(m=o("Roles"),e[7]=o,e[8]=m):m=e[8];let b;e[9]!==r||e[10]!==d||e[11]!==h||e[12]!==i||e[13]!==o?(b=i.length===0?(0,n.jsx)("div",{className:"p-3",children:(0,n.jsx)(ce,{testId:"org-roles-empty",title:o("No custom roles.")})}):(0,n.jsx)(Ke,{columns:h,rowActions:c(g=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(L,{"data-testid":`org-role-edit-${N(g.id)}`,onClick:c(()=>{d({kind:"role-edit",role:g})},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Edit")}),(0,n.jsx)(L,{"data-testid":`org-role-delete-${N(g.id)}`,onClick:c(()=>{r(N(g.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]=b):b=e[14];let u;return e[15]!==s||e[16]!==m||e[17]!==b?(u=(0,n.jsx)(Ge,{action:s,heading:m,testId:"org-roles",children:b}),e[15]=s,e[16]=m,e[17]=b,e[18]=u):u=e[18],u},"Ut"),Wt=c(t=>{let e=(0,U.c)(199),{organizationId:r,rolesEnabled:d,teamsEnabled:h}=t,i=re(),o=q(),[a,l]=(0,j.useState)(null),[s,m]=(0,j.useState)(null),[b,u]=(0,j.useState)(!1),[g,p]=(0,j.useState)(null),f;e[0]!==r?(f=["lunora-auth-org-members",r],e[0]=r,e[1]=f):f=e[1];let y;e[2]!==i||e[3]!==r?(y=c(()=>i.listAuthOrgMembers({limit:200,organizationId:r}),"v"),e[2]=i,e[3]=r,e[4]=y):y=e[4];let z=ue(f,y),v;e[5]!==r?(v=["lunora-auth-org-invitations",r],e[5]=r,e[6]=v):v=e[6];let I;e[7]!==i||e[8]!==r?(I=c(()=>i.listAuthOrgInvitations({limit:200,organizationId:r}),"C"),e[7]=i,e[8]=r,e[9]=I):I=e[9];let C=ue(v,I),k;e[10]!==r?(k=["lunora-auth-org-teams",r],e[10]=r,e[11]=k):k=e[11];let w;e[12]!==i||e[13]!==r?(w=c(()=>i.listAuthOrgTeams({limit:200,organizationId:r}),"$"),e[12]=i,e[13]=r,e[14]=w):w=e[14];let x;e[15]!==h?(x={enabled:h},e[15]=h,e[16]=x):x=e[16];let S=ue(k,w,x),_;e[17]!==r?(_=["lunora-auth-org-roles",r],e[17]=r,e[18]=_):_=e[18];let A;e[19]!==i||e[20]!==r?(A=c(()=>i.listAuthOrgRoles({limit:200,organizationId:r}),"A"),e[19]=i,e[20]=r,e[21]=A):A=e[21];let D;e[22]!==d?(D={enabled:d},e[22]=d,e[23]=D):D=e[23];let $=ue(_,A,D),T;e[24]!==s?(T=["lunora-auth-org-team-members",s],e[24]=s,e[25]=T):T=e[25];let P;e[26]!==i||e[27]!==s?(P=c(()=>i.listAuthOrgTeamMembers({limit:200,teamId:s??""}),"P"),e[26]=i,e[27]=s,e[28]=P):P=e[28];let Q=s!==null,J;e[29]!==Q?(J={enabled:Q},e[29]=Q,e[30]=J):J=e[30];let E=ue(T,P,J),B;e[31]!==z.data?.rows?(B=z.data?.rows??[],e[31]=z.data?.rows,e[32]=B):B=e[32];let Y=B,M;e[33]!==C.data?.rows?(M=C.data?.rows??[],e[33]=C.data?.rows,e[34]=M):M=e[34];let R=M,H;e[35]!==S.data?.rows?(H=S.data?.rows??[],e[35]=S.data?.rows,e[36]=H):H=e[36];let ie=H,K;e[37]!==$.data?.rows?(K=$.data?.rows??[],e[37]=$.data?.rows,e[38]=K):K=e[38];let ee=K,X;e[39]!==s||e[40]!==E?(X=s===null?[]:E.data?.rows??[],e[39]=s,e[40]=E,e[41]=X):X=e[41];let te=X,oe=z.error??C.error??S.error??$.error??E.error,V;e[42]!==C||e[43]!==z||e[44]!==d||e[45]!==$||e[46]!==s||e[47]!==E||e[48]!==h||e[49]!==S?(V=c(()=>{z.refetch(),C.refetch(),h&&S.refetch(),d&&$.refetch(),s!==null&&E.refetch()},"W"),e[42]=C,e[43]=z,e[44]=d,e[45]=$,e[46]=s,e[47]=E,e[48]=h,e[49]=S,e[50]=V):V=e[50];let O=V;Ct(O,!0);let ne;e[51]===Symbol.for("react.memo_cache_sentinel")?(ne=c(()=>{l(null)},"oe"),e[51]=ne):ne=e[51];let F=ne,Xe;e[52]!==O?(Xe=c(G=>{xt((async()=>{u(!0),p(null);try{await G(),O(),u(!1)}catch(lt){p(wt(lt)),u(!1)}})())},"Ye"),e[52]=O,e[53]=Xe):Xe=e[53];let ae=Xe,Ve;e[54]!==i||e[55]!==o?(Ve=c(G=>{let lt=N(G.id);l({action:c(async()=>{await i.removeAuthOrgTeam({teamId:lt}),m(It=>It===lt?null:It)},"action"),kind:"confirm",message:o("Delete this team and its memberships? This cannot be undone."),testId:"org-team-delete",title:o("Delete team")})},"Ze"),e[54]=i,e[55]=o,e[56]=Ve):Ve=e[56];let it=Ve,ge;e[57]!==o?(ge=o("userId"),e[57]=o,e[58]=ge):ge=e[58];let he;e[59]!==ge?(he={head:ge,render:Yt},e[59]=ge,e[60]=he):he=e[60];let be;e[61]!==o?(be=o("role"),e[61]=o,e[62]=be):be=e[62];let fe;e[63]!==be?(fe={head:be,render:Zt},e[63]=be,e[64]=fe):fe=e[64];let et;e[65]!==he||e[66]!==fe?(et=[he,fe],e[65]=he,e[66]=fe,e[67]=et):et=e[67];let st=et,pe;e[68]!==o?(pe=o("email"),e[68]=o,e[69]=pe):pe=e[69];let ve;e[70]!==pe?(ve={head:pe,render:Gt},e[70]=pe,e[71]=ve):ve=e[71];let ye;e[72]!==o?(ye=o("role"),e[72]=o,e[73]=ye):ye=e[73];let Ce;e[74]!==ye?(Ce={head:ye,render:Kt},e[74]=ye,e[75]=Ce):Ce=e[75];let Ie;e[76]!==o?(Ie=o("status"),e[76]=o,e[77]=Ie):Ie=e[77];let we;e[78]!==Ie?(we={head:Ie,render:Xt},e[78]=Ie,e[79]=we):we=e[79];let tt;e[80]!==ve||e[81]!==Ce||e[82]!==we?(tt=[ve,Ce,we],e[80]=ve,e[81]=Ce,e[82]=we,e[83]=tt):tt=e[83];let mt=tt,xe;e[84]!==o?(xe=o("id"),e[84]=o,e[85]=xe):xe=e[85];let ze;e[86]!==xe?(ze={className:"font-mono text-xs",head:xe,render:Vt},e[86]=xe,e[87]=ze):ze=e[87];let ke;e[88]!==o?(ke=o("name"),e[88]=o,e[89]=ke):ke=e[89];let Se;e[90]!==ke?(Se={head:ke,render:er},e[90]=ke,e[91]=Se):Se=e[91];let rt;e[92]!==ze||e[93]!==Se?(rt=[ze,Se],e[92]=ze,e[93]=Se,e[94]=rt):rt=e[94];let dt=rt,Ne;e[95]!==o?(Ne=o("userId"),e[95]=o,e[96]=Ne):Ne=e[96];let ot;e[97]!==Ne?(ot=[{head:Ne,render:tr}],e[97]=Ne,e[98]=ot):ot=e[98];let ct=ot,De;e[99]!==o?(De=o("role"),e[99]=o,e[100]=De):De=e[100];let Ae;e[101]!==De?(Ae={head:De,render:rr},e[101]=De,e[102]=Ae):Ae=e[102];let Oe;e[103]!==o?(Oe=o("Permission"),e[103]=o,e[104]=Oe):Oe=e[104];let _e;e[105]!==Oe?(_e={className:"font-mono text-xs whitespace-pre-wrap",head:Oe,render:or},e[105]=Oe,e[106]=_e):_e=e[106];let nt;e[107]!==Ae||e[108]!==_e?(nt=[Ae,_e],e[107]=Ae,e[108]=_e,e[109]=nt):nt=e[109];let ut=nt,$e;e[110]!==oe?($e=oe!==null&&(0,n.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-detail-error",role:"alert",children:oe}),e[110]=oe,e[111]=$e):$e=e[111];let Te;e[112]!==g?(Te=g!==null&&(0,n.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-action-error",role:"alert",children:g}),e[112]=g,e[113]=Te):Te=e[113];let Me;e[114]!==i||e[115]!==ae?(Me=c(G=>{ae(()=>i.removeAuthOrgMember({memberId:G}))},"_e"),e[114]=i,e[115]=ae,e[116]=Me):Me=e[116];let Re;e[117]!==b||e[118]!==st||e[119]!==Y||e[120]!==Me?(Re=(0,n.jsx)(Ut,{actionBusy:b,memberColumns:st,members:Y,onDialog:l,onRemoveMember:Me}),e[117]=b,e[118]=st,e[119]=Y,e[120]=Me,e[121]=Re):Re=e[121];let Fe;e[122]!==b||e[123]!==i||e[124]!==mt||e[125]!==R||e[126]!==ae||e[127]!==o?(Fe=R.length>0&&(0,n.jsx)(Ge,{heading:o("Invitations"),testId:"org-invitations",children:(0,n.jsx)(Ke,{columns:mt,rowActions:c(G=>(0,n.jsx)(L,{"data-testid":`org-cancel-invitation-${N(G.id)}`,disabled:b,onClick:c(()=>{ae(()=>i.cancelAuthOrgInvitation({invitationId:N(G.id)}))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Cancel")}),"rowActions"),rowPrefix:"org-invitation",rows:R})}),e[122]=b,e[123]=i,e[124]=mt,e[125]=R,e[126]=ae,e[127]=o,e[128]=Fe):Fe=e[128];let Ee;e[129]!==it||e[130]!==s||e[131]!==dt||e[132]!==ie||e[133]!==h?(Ee=h&&(0,n.jsx)(qt,{onConfirmDeleteTeam:it,onDialog:l,onSelectTeam:m,selectedTeam:s,teamColumns:dt,teams:ie}),e[129]=it,e[130]=s,e[131]=dt,e[132]=ie,e[133]=h,e[134]=Ee):Ee=e[134];let Le;e[135]!==b||e[136]!==i||e[137]!==ae||e[138]!==s||e[139]!==ct||e[140]!==te||e[141]!==h?(Le=h&&s!==null&&(0,n.jsx)(Ht,{actionBusy:b,onDialog:l,onRemoveTeamMember:c(G=>{ae(()=>i.removeAuthOrgTeamMember({teamMemberId:G}))},"onRemoveTeamMember"),selectedTeam:s,teamMemberColumns:ct,teamMembers:te}),e[135]=b,e[136]=i,e[137]=ae,e[138]=s,e[139]=ct,e[140]=te,e[141]=h,e[142]=Le):Le=e[142];let je;e[143]!==i||e[144]!==ut||e[145]!==ee||e[146]!==d||e[147]!==o?(je=d&&(0,n.jsx)(Qt,{onConfirmDeleteRole:c(G=>{l({action:c(()=>i.deleteAuthOrgRole({roleId:G}),"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:l,roleColumns:ut,roles:ee}),e[143]=i,e[144]=ut,e[145]=ee,e[146]=d,e[147]=o,e[148]=je):je=e[148];let Pe;e[149]!==a?.kind||e[150]!==r||e[151]!==O?(Pe=a?.kind==="add-member"&&(0,n.jsx)(Lt,{onClose:F,onDone:O,organizationId:r}),e[149]=a?.kind,e[150]=r,e[151]=O,e[152]=Pe):Pe=e[152];let Je;e[153]!==a?.kind||e[154]!==r||e[155]!==O?(Je=a?.kind==="invite-member"&&(0,n.jsx)(jt,{onClose:F,onDone:O,organizationId:r}),e[153]=a?.kind,e[154]=r,e[155]=O,e[156]=Je):Je=e[156];let Be;e[157]!==a||e[158]!==O?(Be=a?.kind==="member-role"&&(0,n.jsx)(Pt,{member:a.member,onClose:F,onDone:O}),e[157]=a,e[158]=O,e[159]=Be):Be=e[159];let Ue;e[160]!==a?.kind||e[161]!==r||e[162]!==O?(Ue=a?.kind==="team-create"&&(0,n.jsx)(At,{mode:"create",onClose:F,onDone:O,organizationId:r}),e[160]=a?.kind,e[161]=r,e[162]=O,e[163]=Ue):Ue=e[163];let qe;e[164]!==a||e[165]!==r||e[166]!==O?(qe=a?.kind==="team-rename"&&(0,n.jsx)(At,{mode:"edit",onClose:F,onDone:O,organizationId:r,team:a.team}),e[164]=a,e[165]=r,e[166]=O,e[167]=qe):qe=e[167];let He;e[168]!==a||e[169]!==O?(He=a?.kind==="team-add-member"&&(0,n.jsx)(Jt,{onClose:F,onDone:O,teamId:a.teamId}),e[168]=a,e[169]=O,e[170]=He):He=e[170];let Qe;e[171]!==a?.kind||e[172]!==r||e[173]!==O?(Qe=a?.kind==="role-create"&&(0,n.jsx)(Ot,{mode:"create",onClose:F,onDone:O,organizationId:r}),e[171]=a?.kind,e[172]=r,e[173]=O,e[174]=Qe):Qe=e[174];let We;e[175]!==a||e[176]!==r||e[177]!==O?(We=a?.kind==="role-edit"&&(0,n.jsx)(Ot,{mode:"edit",onClose:F,onDone:O,organizationId:r,role:a.role}),e[175]=a,e[176]=r,e[177]=O,e[178]=We):We=e[178];let Ye;e[179]!==a||e[180]!==O?(Ye=a?.kind==="confirm"&&(0,n.jsx)(Tt,{action:a.action,message:a.message,onClose:F,onDone:O,testId:a.testId,title:a.title}),e[179]=a,e[180]=O,e[181]=Ye):Ye=e[181];let at;return e[182]!==$e||e[183]!==Te||e[184]!==Re||e[185]!==Fe||e[186]!==Ee||e[187]!==Le||e[188]!==je||e[189]!==Pe||e[190]!==Je||e[191]!==Be||e[192]!==Ue||e[193]!==qe||e[194]!==He||e[195]!==Qe||e[196]!==We||e[197]!==Ye?(at=(0,n.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"org-detail",children:[$e,Te,Re,Fe,Ee,Le,je,Pe,Je,Be,Ue,qe,He,Qe,We,Ye]}),e[182]=$e,e[183]=Te,e[184]=Re,e[185]=Fe,e[186]=Ee,e[187]=Le,e[188]=je,e[189]=Pe,e[190]=Je,e[191]=Be,e[192]=Ue,e[193]=qe,e[194]=He,e[195]=Qe,e[196]=We,e[197]=Ye,e[198]=at):at=e[198],at},"Ht");function Yt(t){return(0,n.jsx)("span",{className:"font-mono text-xs",children:N(t.userId)})}c(Yt,"Kt");function Zt(t){return N(t.role)}c(Zt,"qt");function Gt(t){return N(t.email)}c(Gt,"Gt");function Kt(t){return N(t.role)}c(Kt,"Qt");function Xt(t){return N(t.status)}c(Xt,"Vt");function Vt(t){return N(t.id)}c(Vt,"Xt");function er(t){return N(t.name)}c(er,"Yt");function tr(t){return(0,n.jsx)("span",{className:"font-mono text-xs",children:N(t.userId)})}c(tr,"Zt");function rr(t){return N(t.role)}c(rr,"Wt");function or(t){return N(t.permission)}c(or,"er");var yr=c(()=>{let t=(0,U.c)(62),e=re(),r=q(),{config:d,ready:h}=St(),i=d.capabilities.organization,[o,a]=(0,j.useState)(null),[l,s]=(0,j.useState)(null),m;t[0]===Symbol.for("react.memo_cache_sentinel")?(m=["lunora-auth-orgs"],t[0]=m):m=t[0];let b;t[1]!==e?(b=c(()=>e.listAuthOrganizations({limit:100}),"h"),t[1]=e,t[2]=b):b=t[2];let u;t[3]!==i?(u={enabled:i},t[3]=i,t[4]=u):u=t[4];let g=ue(m,b,u),p=g.data?.rows??null,f;t[5]!==g?(f=c(()=>{g.refetch()},"b"),t[5]=g,t[6]=f):f=t[6],Ct(f,i);let y;t[7]===Symbol.for("react.memo_cache_sentinel")?(y=c(()=>{s(null)},"v"),t[7]=y):y=t[7];let z=y,v;t[8]!==g?(v=c(()=>{g.refetch()},"p"),t[8]=g,t[9]=v):v=t[9];let I=v,C;t[10]===Symbol.for("react.memo_cache_sentinel")?(C=c(M=>{a(M)},"y"),t[10]=C):C=t[10];let k=C;if(h&&!i){let M;t[11]!==r?(M=r("Enable the organization() plugin in your auth config to manage organizations here."),t[11]=r,t[12]=M):M=t[12];let R;t[13]!==r?(R=r("Organizations are not enabled."),t[13]=r,t[14]=R):R=t[14];let H;return t[15]!==M||t[16]!==R?(H=(0,n.jsx)(ce,{description:M,testId:"org-disabled",title:R}),t[15]=M,t[16]=R,t[17]=H):H=t[17],H}let w;t[18]!==r?(w=r("Organizations"),t[18]=r,t[19]=w):w=t[19];let x;t[20]!==w?(x=(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:w}),t[20]=w,t[21]=x):x=t[21];let S;t[22]===Symbol.for("react.memo_cache_sentinel")?(S=c(()=>{s({kind:"create"})},"z"),t[22]=S):S=t[22];let _;t[23]!==r?(_=r("New organization"),t[23]=r,t[24]=_):_=t[24];let A;t[25]!==_?(A=(0,n.jsx)(L,{"data-testid":"org-new",onClick:S,size:"sm",type:"button",children:_}),t[25]=_,t[26]=A):A=t[26];let D;t[27]!==A||t[28]!==x?(D=(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[x,A]}),t[27]=A,t[28]=x,t[29]=D):D=t[29];let $;t[30]!==g.error?($=g.error!==null&&(0,n.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-error",role:"alert",children:g.error}),t[30]=g.error,t[31]=$):$=t[31];let T;t[32]!==p||t[33]!==r?(T=p!==null&&p.length===0&&(0,n.jsx)(ce,{testId:"org-empty",title:r("No organizations.")}),t[32]=p,t[33]=r,t[34]=T):T=t[34];let P;t[35]!==p||t[36]!==o||t[37]!==r?(P=p!==null&&p.length>0&&(0,n.jsx)(ht,{className:"overflow-hidden py-0",children:(0,n.jsx)(bt,{className:"px-0",children:(0,n.jsxs)(ft,{"data-testid":"org-table",children:[(0,n.jsx)(pt,{children:(0,n.jsxs)(Ze,{children:[(0,n.jsx)(se,{children:r("id")}),(0,n.jsx)(se,{children:r("name")}),(0,n.jsx)(se,{children:r("slug")}),(0,n.jsx)(se,{children:r("created")}),(0,n.jsx)(se,{"aria-label":r("Actions")})]})}),(0,n.jsx)(vt,{children:p.map(M=>{let R=N(M.id);return(0,n.jsxs)(Ze,{"data-testid":`org-row-${R}`,children:[(0,n.jsx)(me,{className:"font-mono text-xs",children:R}),(0,n.jsx)(me,{children:N(M.name)}),(0,n.jsx)(me,{children:N(M.slug)}),(0,n.jsx)(me,{className:"text-muted-foreground tabular-nums",children:zt(M.createdAt)}),(0,n.jsx)(me,{children:(0,n.jsxs)("div",{className:"flex justify-end gap-1",children:[(0,n.jsx)(L,{"aria-pressed":o===R,"data-testid":`org-select-${R}`,onClick:c(()=>{k(R)},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Manage")}),(0,n.jsx)(L,{"data-testid":`org-edit-${R}`,onClick:c(()=>{s({kind:"edit",org:M})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Edit")}),(0,n.jsx)(L,{"data-testid":`org-delete-${R}`,onClick:c(()=>{s({kind:"delete",org:M})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Delete")})]})})]},R)})})]})})}),t[35]=p,t[36]=o,t[37]=r,t[38]=P):P=t[38];let Q;t[39]!==d.organization||t[40]!==o?(Q=o!==null&&(0,n.jsx)(Wt,{organizationId:o,rolesEnabled:d.organization.roles,teamsEnabled:d.organization.teams}),t[39]=d.organization,t[40]=o,t[41]=Q):Q=t[41];let J;t[42]!==l?.kind||t[43]!==I?(J=l?.kind==="create"&&(0,n.jsx)(Dt,{mode:"create",onClose:z,onDone:I}),t[42]=l?.kind,t[43]=I,t[44]=J):J=t[44];let E;t[45]!==l||t[46]!==I?(E=l?.kind==="edit"&&(0,n.jsx)(Dt,{mode:"edit",onClose:z,onDone:I,org:l.org}),t[45]=l,t[46]=I,t[47]=E):E=t[47];let B;t[48]!==e||t[49]!==l||t[50]!==I||t[51]!==r?(B=l?.kind==="delete"&&(0,n.jsx)(Tt,{action:c(async()=>{let M=N(l.org.id);await e.deleteAuthOrganization({organizationId:M}),a(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:z,onDone:I,testId:"org-delete",title:r("Delete organization")}),t[48]=e,t[49]=l,t[50]=I,t[51]=r,t[52]=B):B=t[52];let Y;return t[53]!==D||t[54]!==$||t[55]!==T||t[56]!==P||t[57]!==Q||t[58]!==J||t[59]!==E||t[60]!==B?(Y=(0,n.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-organizations",children:[D,$,T,P,Q,J,E,B]}),t[53]=D,t[54]=$,t[55]=T,t[56]=P,t[57]=Q,t[58]=J,t[59]=E,t[60]=B,t[61]=Y):Y=t[61],Y},"yr");export{yr as OrganizationsPanel};
|
|
1
|
+
import{a as yt}from"./chunk-V53KNYRN.js";import{a as St}from"./chunk-232MBXB2.js";import{a as Nt}from"./chunk-ESVP44Y3.js";import{a as le}from"./chunk-U6TNNM5U.js";import{a as kt}from"./chunk-5Y3QLNWX.js";import{a as Ct}from"./chunk-54MMVNPT.js";import{R as Z}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as L}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{b as ue}from"./chunk-YGKR536O.js";import{f as re}from"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as ce}from"./chunk-XQCVZAGU.js";import{a as ft,b as pt,c as vt,d as Ze,e as se,f as me}from"./chunk-MIQTKZAR.js";import{a as ht,e as bt}from"./chunk-UZERI5YC.js";import{d as q,h as wt,l as N,m as xt,q as zt}from"./chunk-OG4N2XHD.js";import"./chunk-QNUWWC3N.js";import{a as c,e as gt,f as Mt,g as Rt,h as Ft}from"./chunk-3XIESWL4.js";var U=gt(Rt(),1);var j=gt(Mt(),1);var n=gt(Ft(),1);var _t=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},"zt"),Et=c(t=>{let e=_t(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},"Tt"),$t=c(t=>t==null||t===""?"":typeof t=="string"?t:JSON.stringify(t,null,2),"St"),W=c(t=>{let e=(0,U.c)(6),{children:r,htmlFor:d,label:h}=t,i;e[0]!==d||e[1]!==h?(i=(0,n.jsx)(kt,{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,n.jsxs)("div",{className:"flex flex-col gap-1",children:[i,r]}),e[3]=r,e[4]=i,e[5]=o):o=e[5],o},"G"),de=c(({busy:t,canSubmit:e,children:r,destructive:d=!1,error:h,onClose:i,onSubmit:o,submitLabel:a,testId:l,title:s})=>{let m=q();return(0,n.jsxs)(Nt,{label:s,onClose:i,panelTestId:`${l}-panel`,testId:`${l}-overlay`,variant:"dialog",children:[(0,n.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:s}),r,h!==null&&(0,n.jsx)("p",{className:"text-sm text-destructive","data-testid":`${l}-error`,role:"alert",children:h}),(0,n.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[(0,n.jsx)(L,{"data-testid":`${l}-cancel`,onClick:i,size:"sm",type:"button",variant:"outline",children:m("Cancel")}),(0,n.jsx)(L,{"data-testid":`${l}-submit`,disabled:t||!e,onClick:o,size:"sm",type:"button",variant:d?"destructive":"default",children:t?m("Saving\u2026"):a})]})]})},"se"),Dt=c(t=>{let e=(0,U.c)(79),{mode:r,onClose:d,onDone:h,org:i}=t,o=re(),a=q(),{busy:l,error:s,run:m}=le(),b;e[0]!==i?(b=i?N(i.name):"",e[0]=i,e[1]=b):b=e[1];let[u,g]=(0,j.useState)(b),p;e[2]!==i?(p=i?N(i.slug):"",e[2]=i,e[3]=p):p=e[3];let[f,y]=(0,j.useState)(p),z;e[4]!==i?(z=i?N(i.logo):"",e[4]=i,e[5]=z):z=e[5];let[v,I]=(0,j.useState)(z),[C,k]=(0,j.useState)(""),w;e[6]!==r||e[7]!==i?.metadata?(w=r==="edit"?$t(i?.metadata):"",e[6]=r,e[7]=i?.metadata,e[8]=w):w=e[8];let[x,S]=(0,j.useState)(w),_;e[9]!==o||e[10]!==v||e[11]!==x||e[12]!==r||e[13]!==u||e[14]!==d||e[15]!==h||e[16]!==i?.id||e[17]!==C||e[18]!==m||e[19]!==f?(_=c(()=>{m(async()=>{let F=x.trim()===""?void 0:_t(x);r==="create"?await o.createAuthOrganization({logo:v.trim()===""?void 0:v.trim(),metadata:F,name:u.trim(),ownerId:C.trim()===""?void 0:C.trim(),slug:f.trim()===""?void 0:f.trim()}):await o.updateAuthOrganization({logo:v.trim()===""?void 0:v.trim(),metadata:F,name:u.trim()===""?void 0:u.trim(),organizationId:N(i?.id),slug:f.trim()===""?void 0:f.trim()}),h(),d()})},"D"),e[9]=o,e[10]=v,e[11]=x,e[12]=r,e[13]=u,e[14]=d,e[15]=h,e[16]=i?.id,e[17]=C,e[18]=m,e[19]=f,e[20]=_):_=e[20];let A=_,D;e[21]!==r||e[22]!==u?(D=u.trim()!==""||r==="edit",e[21]=r,e[22]=u,e[23]=D):D=e[23];let $;e[24]!==r||e[25]!==a?($=a(r==="create"?"Create":"Save"),e[24]=r,e[25]=a,e[26]=$):$=e[26];let T;e[27]!==r||e[28]!==a?(T=a(r==="create"?"New organization":"Edit organization"),e[27]=r,e[28]=a,e[29]=T):T=e[29];let P;e[30]!==a?(P=a("name"),e[30]=a,e[31]=P):P=e[31];let Q;e[32]===Symbol.for("react.memo_cache_sentinel")?(Q=c(F=>{g(F.target.value)},"q"),e[32]=Q):Q=e[32];let J;e[33]!==u?(J=(0,n.jsx)(Z,{"data-testid":"org-form-name",id:"org-form-name",onChange:Q,value:u}),e[33]=u,e[34]=J):J=e[34];let E;e[35]!==J||e[36]!==P?(E=(0,n.jsx)(W,{htmlFor:"org-form-name",label:P,children:J}),e[35]=J,e[36]=P,e[37]=E):E=e[37];let B;e[38]!==a?(B=a("Slug (optional \u2014 derived from name)"),e[38]=a,e[39]=B):B=e[39];let Y;e[40]===Symbol.for("react.memo_cache_sentinel")?(Y=c(F=>{y(F.target.value)},"Q"),e[40]=Y):Y=e[40];let M;e[41]!==f?(M=(0,n.jsx)(Z,{"data-testid":"org-form-slug",id:"org-form-slug",onChange:Y,value:f}),e[41]=f,e[42]=M):M=e[42];let R;e[43]!==B||e[44]!==M?(R=(0,n.jsx)(W,{htmlFor:"org-form-slug",label:B,children:M}),e[43]=B,e[44]=M,e[45]=R):R=e[45];let H;e[46]!==a?(H=a("Logo URL (optional)"),e[46]=a,e[47]=H):H=e[47];let ie;e[48]===Symbol.for("react.memo_cache_sentinel")?(ie=c(F=>{I(F.target.value)},"le"),e[48]=ie):ie=e[48];let K;e[49]!==v?(K=(0,n.jsx)(Z,{"data-testid":"org-form-logo",id:"org-form-logo",onChange:ie,value:v}),e[49]=v,e[50]=K):K=e[50];let ee;e[51]!==H||e[52]!==K?(ee=(0,n.jsx)(W,{htmlFor:"org-form-logo",label:H,children:K}),e[51]=H,e[52]=K,e[53]=ee):ee=e[53];let X;e[54]!==r||e[55]!==C||e[56]!==a?(X=r==="create"&&(0,n.jsx)(W,{htmlFor:"org-form-owner",label:a("Owner user id (optional)"),children:(0,n.jsx)(Z,{"data-testid":"org-form-owner",id:"org-form-owner",onChange:c(F=>{k(F.target.value)},"onChange"),value:C})}),e[54]=r,e[55]=C,e[56]=a,e[57]=X):X=e[57];let te;e[58]!==a?(te=a("Metadata (JSON, optional)"),e[58]=a,e[59]=te):te=e[59];let oe;e[60]===Symbol.for("react.memo_cache_sentinel")?(oe=c(F=>{S(F.target.value)},"re"),e[60]=oe):oe=e[60];let V;e[61]!==x?(V=(0,n.jsx)(yt,{"data-testid":"org-form-metadata",id:"org-form-metadata",onChange:oe,value:x}),e[61]=x,e[62]=V):V=e[62];let O;e[63]!==te||e[64]!==V?(O=(0,n.jsx)(W,{htmlFor:"org-form-metadata",label:te,children:V}),e[63]=te,e[64]=V,e[65]=O):O=e[65];let ne;return e[66]!==l||e[67]!==s||e[68]!==d||e[69]!==A||e[70]!==E||e[71]!==R||e[72]!==ee||e[73]!==X||e[74]!==O||e[75]!==D||e[76]!==$||e[77]!==T?(ne=(0,n.jsxs)(de,{busy:l,canSubmit:D,error:s,onClose:d,onSubmit:A,submitLabel:$,testId:"org-form",title:T,children:[E,R,ee,X,O]}),e[66]=l,e[67]=s,e[68]=d,e[69]=A,e[70]=E,e[71]=R,e[72]=ee,e[73]=X,e[74]=O,e[75]=D,e[76]=$,e[77]=T,e[78]=ne):ne=e[78],ne},"bt"),Lt=c(t=>{let e=(0,U.c)(40),{onClose:r,onDone:d,organizationId:h}=t,i=re(),o=q(),{busy:a,error:l,run:s}=le(),[m,b]=(0,j.useState)(""),[u,g]=(0,j.useState)(""),p;e[0]!==i||e[1]!==r||e[2]!==d||e[3]!==h||e[4]!==u||e[5]!==s||e[6]!==m?(p=c(()=>{s(async()=>{await i.addAuthOrgMember({organizationId:h,role:u.trim()===""?void 0:u.trim(),userId:m.trim()}),d(),r()})},"f"),e[0]=i,e[1]=r,e[2]=d,e[3]=h,e[4]=u,e[5]=s,e[6]=m,e[7]=p):p=e[7];let f=p,y;e[8]!==m?(y=m.trim(),e[8]=m,e[9]=y):y=e[9];let z=y!=="",v;e[10]!==o?(v=o("Add member"),e[10]=o,e[11]=v):v=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 k;e[16]===Symbol.for("react.memo_cache_sentinel")?(k=c(T=>{b(T.target.value)},"x"),e[16]=k):k=e[16];let w;e[17]!==m?(w=(0,n.jsx)(Z,{"data-testid":"org-add-member-user",id:"org-add-member-user",onChange:k,value:m}),e[17]=m,e[18]=w):w=e[18];let x;e[19]!==C||e[20]!==w?(x=(0,n.jsx)(W,{htmlFor:"org-add-member-user",label:C,children:w}),e[19]=C,e[20]=w,e[21]=x):x=e[21];let S;e[22]!==o?(S=o("Role (optional)"),e[22]=o,e[23]=S):S=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=c(T=>{g(T.target.value)},"D"),e[24]=_):_=e[24];let A;e[25]!==u?(A=(0,n.jsx)(Z,{"data-testid":"org-add-member-role",id:"org-add-member-role",onChange:_,value:u}),e[25]=u,e[26]=A):A=e[26];let D;e[27]!==S||e[28]!==A?(D=(0,n.jsx)(W,{htmlFor:"org-add-member-role",label:S,children:A}),e[27]=S,e[28]=A,e[29]=D):D=e[29];let $;return e[30]!==a||e[31]!==l||e[32]!==r||e[33]!==f||e[34]!==D||e[35]!==z||e[36]!==v||e[37]!==I||e[38]!==x?($=(0,n.jsxs)(de,{busy:a,canSubmit:z,error:l,onClose:r,onSubmit:f,submitLabel:v,testId:"org-add-member",title:I,children:[x,D]}),e[30]=a,e[31]=l,e[32]=r,e[33]=f,e[34]=D,e[35]=z,e[36]=v,e[37]=I,e[38]=x,e[39]=$):$=e[39],$},"Mt"),jt=c(t=>{let e=(0,U.c)(40),{onClose:r,onDone:d,organizationId:h}=t,i=re(),o=q(),{busy:a,error:l,run:s}=le(),[m,b]=(0,j.useState)(""),[u,g]=(0,j.useState)(""),p;e[0]!==i||e[1]!==m||e[2]!==r||e[3]!==d||e[4]!==h||e[5]!==u||e[6]!==s?(p=c(()=>{s(async()=>{await i.inviteAuthOrgMember({email:m.trim(),organizationId:h,role:u.trim()===""?void 0:u.trim()}),d(),r()})},"f"),e[0]=i,e[1]=m,e[2]=r,e[3]=d,e[4]=h,e[5]=u,e[6]=s,e[7]=p):p=e[7];let f=p,y;e[8]!==m?(y=m.trim(),e[8]=m,e[9]=y):y=e[9];let z=y!=="",v;e[10]!==o?(v=o("Send invitation"),e[10]=o,e[11]=v):v=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 k;e[16]===Symbol.for("react.memo_cache_sentinel")?(k=c(T=>{b(T.target.value)},"x"),e[16]=k):k=e[16];let w;e[17]!==m?(w=(0,n.jsx)(Z,{"data-testid":"org-invite-member-email",id:"org-invite-member-email",onChange:k,type:"email",value:m}),e[17]=m,e[18]=w):w=e[18];let x;e[19]!==C||e[20]!==w?(x=(0,n.jsx)(W,{htmlFor:"org-invite-member-email",label:C,children:w}),e[19]=C,e[20]=w,e[21]=x):x=e[21];let S;e[22]!==o?(S=o("Role (optional)"),e[22]=o,e[23]=S):S=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=c(T=>{g(T.target.value)},"D"),e[24]=_):_=e[24];let A;e[25]!==u?(A=(0,n.jsx)(Z,{"data-testid":"org-invite-member-role",id:"org-invite-member-role",onChange:_,value:u}),e[25]=u,e[26]=A):A=e[26];let D;e[27]!==S||e[28]!==A?(D=(0,n.jsx)(W,{htmlFor:"org-invite-member-role",label:S,children:A}),e[27]=S,e[28]=A,e[29]=D):D=e[29];let $;return e[30]!==a||e[31]!==l||e[32]!==r||e[33]!==f||e[34]!==D||e[35]!==z||e[36]!==v||e[37]!==I||e[38]!==x?($=(0,n.jsxs)(de,{busy:a,canSubmit:z,error:l,onClose:r,onSubmit:f,submitLabel:v,testId:"org-invite-member",title:I,children:[x,D]}),e[30]=a,e[31]=l,e[32]=r,e[33]=f,e[34]=D,e[35]=z,e[36]=v,e[37]=I,e[38]=x,e[39]=$):$=e[39],$},"Ft"),Pt=c(t=>{let e=(0,U.c)(32),{member:r,onClose:d,onDone:h}=t,i=re(),o=q(),{busy:a,error:l,run:s}=le(),m;e[0]!==r.role?(m=c(()=>N(r.role),"m"),e[0]=r.role,e[1]=m):m=e[1];let[b,u]=(0,j.useState)(m),g;e[2]!==i||e[3]!==r.id||e[4]!==d||e[5]!==h||e[6]!==b||e[7]!==s?(g=c(()=>{s(async()=>{await i.setAuthOrgMemberRole({memberId:N(r.id),role:b.trim()}),h(),d()})},"u"),e[2]=i,e[3]=r.id,e[4]=d,e[5]=h,e[6]=b,e[7]=s,e[8]=g):g=e[8];let p=g,f;e[9]!==b?(f=b.trim(),e[9]=b,e[10]=f):f=e[10];let y=f!=="",z;e[11]!==o?(z=o("Save"),e[11]=o,e[12]=z):z=e[12];let v;e[13]!==o?(v=o("Change member role"),e[13]=o,e[14]=v):v=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(S=>{u(S.target.value)},"y"),e[17]=C):C=e[17];let k;e[18]!==b?(k=(0,n.jsx)(Z,{"data-testid":"org-member-role-value",id:"org-member-role-value",onChange:C,value:b}),e[18]=b,e[19]=k):k=e[19];let w;e[20]!==I||e[21]!==k?(w=(0,n.jsx)(W,{htmlFor:"org-member-role-value",label:I,children:k}),e[20]=I,e[21]=k,e[22]=w):w=e[22];let x;return e[23]!==a||e[24]!==l||e[25]!==d||e[26]!==p||e[27]!==w||e[28]!==y||e[29]!==z||e[30]!==v?(x=(0,n.jsx)(de,{busy:a,canSubmit:y,error:l,onClose:d,onSubmit:p,submitLabel:z,testId:"org-member-role",title:v,children:w}),e[23]=a,e[24]=l,e[25]=d,e[26]=p,e[27]=w,e[28]=y,e[29]=z,e[30]=v,e[31]=x):x=e[31],x},"Et"),At=c(t=>{let e=(0,U.c)(36),{mode:r,onClose:d,onDone:h,organizationId:i,team:o}=t,a=re(),l=q(),{busy:s,error:m,run:b}=le(),u;e[0]!==o?(u=o?N(o.name):"",e[0]=o,e[1]=u):u=e[1];let[g,p]=(0,j.useState)(u),f;e[2]!==a||e[3]!==r||e[4]!==g||e[5]!==d||e[6]!==h||e[7]!==i||e[8]!==b||e[9]!==o?.id?(f=c(()=>{b(async()=>{await(r==="create"?a.createAuthOrgTeam({name:g.trim(),organizationId:i}):a.updateAuthOrgTeam({name:g.trim(),teamId:N(o?.id)})),h(),d()})},"b"),e[2]=a,e[3]=r,e[4]=g,e[5]=d,e[6]=h,e[7]=i,e[8]=b,e[9]=o?.id,e[10]=f):f=e[10];let y=f,z;e[11]!==g?(z=g.trim(),e[11]=g,e[12]=z):z=e[12];let v=z!=="",I;e[13]!==r||e[14]!==l?(I=l(r==="create"?"Create":"Save"),e[13]=r,e[14]=l,e[15]=I):I=e[15];let C;e[16]!==r||e[17]!==l?(C=l(r==="create"?"New team":"Rename team"),e[16]=r,e[17]=l,e[18]=C):C=e[18];let k;e[19]!==l?(k=l("name"),e[19]=l,e[20]=k):k=e[20];let w;e[21]===Symbol.for("react.memo_cache_sentinel")?(w=c(A=>{p(A.target.value)},"$"),e[21]=w):w=e[21];let x;e[22]!==g?(x=(0,n.jsx)(Z,{"data-testid":"org-team-form-name",id:"org-team-form-name",onChange:w,value:g}),e[22]=g,e[23]=x):x=e[23];let S;e[24]!==k||e[25]!==x?(S=(0,n.jsx)(W,{htmlFor:"org-team-form-name",label:k,children:x}),e[24]=k,e[25]=x,e[26]=S):S=e[26];let _;return e[27]!==s||e[28]!==m||e[29]!==d||e[30]!==y||e[31]!==S||e[32]!==v||e[33]!==I||e[34]!==C?(_=(0,n.jsx)(de,{busy:s,canSubmit:v,error:m,onClose:d,onSubmit:y,submitLabel:I,testId:"org-team-form",title:C,children:S}),e[27]=s,e[28]=m,e[29]=d,e[30]=y,e[31]=S,e[32]=v,e[33]=I,e[34]=C,e[35]=_):_=e[35],_},"ft"),Jt=c(t=>{let e=(0,U.c)(30),{onClose:r,onDone:d,teamId:h}=t,i=re(),o=q(),{busy:a,error:l,run:s}=le(),[m,b]=(0,j.useState)(""),u;e[0]!==i||e[1]!==r||e[2]!==d||e[3]!==s||e[4]!==h||e[5]!==m?(u=c(()=>{s(async()=>{await i.addAuthOrgTeamMember({teamId:h,userId:m.trim()}),d(),r()})},"c"),e[0]=i,e[1]=r,e[2]=d,e[3]=s,e[4]=h,e[5]=m,e[6]=u):u=e[6];let g=u,p;e[7]!==m?(p=m.trim(),e[7]=m,e[8]=p):p=e[8];let f=p!=="",y;e[9]!==o?(y=o("Add member"),e[9]=o,e[10]=y):y=e[10];let z;e[11]!==o?(z=o("Add team member"),e[11]=o,e[12]=z):z=e[12];let v;e[13]!==o?(v=o("User id"),e[13]=o,e[14]=v):v=e[14];let I;e[15]===Symbol.for("react.memo_cache_sentinel")?(I=c(x=>{b(x.target.value)},"C"),e[15]=I):I=e[15];let C;e[16]!==m?(C=(0,n.jsx)(Z,{"data-testid":"org-team-add-member-user",id:"org-team-add-member-user",onChange:I,value:m}),e[16]=m,e[17]=C):C=e[17];let k;e[18]!==v||e[19]!==C?(k=(0,n.jsx)(W,{htmlFor:"org-team-add-member-user",label:v,children:C}),e[18]=v,e[19]=C,e[20]=k):k=e[20];let w;return e[21]!==a||e[22]!==l||e[23]!==r||e[24]!==g||e[25]!==f||e[26]!==y||e[27]!==z||e[28]!==k?(w=(0,n.jsx)(de,{busy:a,canSubmit:f,error:l,onClose:r,onSubmit:g,submitLabel:y,testId:"org-team-add-member",title:z,children:k}),e[21]=a,e[22]=l,e[23]=r,e[24]=g,e[25]=f,e[26]=y,e[27]=z,e[28]=k,e[29]=w):w=e[29],w},"Lt"),Ot=c(t=>{let e=(0,U.c)(47),{mode:r,onClose:d,onDone:h,organizationId:i,role:o}=t,a=re(),l=q(),{busy:s,error:m,run:b}=le(),u;e[0]!==o?(u=o?N(o.role):"",e[0]=o,e[1]=u):u=e[1];let[g,p]=(0,j.useState)(u),f;e[2]!==r||e[3]!==o?.permission?(f=r==="edit"?$t(o?.permission):"",e[2]=r,e[3]=o?.permission,e[4]=f):f=e[4];let[y,z]=(0,j.useState)(f),v;e[5]!==a||e[6]!==r||e[7]!==g||e[8]!==d||e[9]!==h||e[10]!==i||e[11]!==y||e[12]!==o?.id||e[13]!==b?(v=c(()=>{b(async()=>{let T=Et(y);await(r==="create"?a.createAuthOrgRole({organizationId:i,permission:T,role:g.trim()}):a.updateAuthOrgRole({permission:T,roleId:N(o?.id)})),h(),d()})},"p"),e[5]=a,e[6]=r,e[7]=g,e[8]=d,e[9]=h,e[10]=i,e[11]=y,e[12]=o?.id,e[13]=b,e[14]=v):v=e[14];let I=v,C;e[15]!==r||e[16]!==g||e[17]!==y?(C=y.trim()!==""&&(r==="edit"||g.trim()!==""),e[15]=r,e[16]=g,e[17]=y,e[18]=C):C=e[18];let k;e[19]!==r||e[20]!==l?(k=l(r==="create"?"Create":"Save"),e[19]=r,e[20]=l,e[21]=k):k=e[21];let w;e[22]!==r||e[23]!==l?(w=l(r==="create"?"New role":"Edit role"),e[22]=r,e[23]=l,e[24]=w):w=e[24];let x;e[25]!==r||e[26]!==g||e[27]!==l?(x=r==="create"&&(0,n.jsx)(W,{htmlFor:"org-role-form-name",label:l("Role name"),children:(0,n.jsx)(Z,{"data-testid":"org-role-form-name",id:"org-role-form-name",onChange:c(T=>{p(T.target.value)},"onChange"),value:g})}),e[25]=r,e[26]=g,e[27]=l,e[28]=x):x=e[28];let S;e[29]!==l?(S=l('Permission (JSON, e.g. {"project":["create","update"]})'),e[29]=l,e[30]=S):S=e[30];let _;e[31]===Symbol.for("react.memo_cache_sentinel")?(_=c(T=>{z(T.target.value)},"D"),e[31]=_):_=e[31];let A;e[32]!==y?(A=(0,n.jsx)(yt,{"data-testid":"org-role-form-permission",id:"org-role-form-permission",onChange:_,value:y}),e[32]=y,e[33]=A):A=e[33];let D;e[34]!==A||e[35]!==S?(D=(0,n.jsx)(W,{htmlFor:"org-role-form-permission",label:S,children:A}),e[34]=A,e[35]=S,e[36]=D):D=e[36];let $;return e[37]!==s||e[38]!==m||e[39]!==d||e[40]!==I||e[41]!==D||e[42]!==C||e[43]!==k||e[44]!==w||e[45]!==x?($=(0,n.jsxs)(de,{busy:s,canSubmit:C,error:m,onClose:d,onSubmit:I,submitLabel:k,testId:"org-role-form",title:w,children:[x,D]}),e[37]=s,e[38]=m,e[39]=d,e[40]=I,e[41]=D,e[42]=C,e[43]=k,e[44]=w,e[45]=x,e[46]=$):$=e[46],$},"pt"),Tt=c(t=>{let e=(0,U.c)(18),{action:r,message:d,onClose:h,onDone:i,testId:o,title:a}=t,l=q(),{busy:s,error:m,run:b}=le(),u;e[0]!==r||e[1]!==h||e[2]!==i||e[3]!==b?(u=c(()=>{b(async()=>{await r(),i(),h()})},"c"),e[0]=r,e[1]=h,e[2]=i,e[3]=b,e[4]=u):u=e[4];let g=u,p;e[5]!==l?(p=l("Delete"),e[5]=l,e[6]=p):p=e[6];let f;e[7]!==d?(f=(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:d}),e[7]=d,e[8]=f):f=e[8];let y;return e[9]!==s||e[10]!==m||e[11]!==h||e[12]!==g||e[13]!==p||e[14]!==f||e[15]!==o||e[16]!==a?(y=(0,n.jsx)(de,{busy:s,canSubmit:!0,destructive:!0,error:m,onClose:h,onSubmit:g,submitLabel:p,testId:o,title:a,children:f}),e[9]=s,e[10]=m,e[11]=h,e[12]=g,e[13]=p,e[14]=f,e[15]=o,e[16]=a,e[17]=y):y=e[17],y},"kt"),Ge=c(t=>{let e=(0,U.c)(13),{action:r,children:d,heading:h,testId:i}=t,o;e[0]!==h?(o=(0,n.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 a;e[2]!==r?(a=r!==void 0&&(0,n.jsx)("div",{className:"flex items-center gap-2",children:r}),e[2]=r,e[3]=a):a=e[3];let l;e[4]!==o||e[5]!==a?(l=(0,n.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[o,a]}),e[4]=o,e[5]=a,e[6]=l):l=e[6];let s;e[7]!==d?(s=(0,n.jsx)(bt,{className:"px-0",children:d}),e[7]=d,e[8]=s):s=e[8];let m;return e[9]!==l||e[10]!==s||e[11]!==i?(m=(0,n.jsxs)(ht,{className:"overflow-hidden py-0","data-testid":i,children:[l,s]}),e[9]=l,e[10]=s,e[11]=i,e[12]=m):m=e[12],m},"Ve"),Ke=c(t=>{let e=(0,U.c)(23),{columns:r,rowActions:d,rowPrefix:h,rows:i}=t,o=q(),a;e[0]!==r?(a=r.map(Bt),e[0]=r,e[1]=a):a=e[1];let l;e[2]!==o?(l=o("Actions"),e[2]=o,e[3]=l):l=e[3];let s;e[4]!==l?(s=(0,n.jsx)(se,{"aria-label":l}),e[4]=l,e[5]=s):s=e[5];let m;e[6]!==a||e[7]!==s?(m=(0,n.jsx)(pt,{children:(0,n.jsxs)(Ze,{children:[a,s]})}),e[6]=a,e[7]=s,e[8]=m):m=e[8];let b;if(e[9]!==r||e[10]!==d||e[11]!==h||e[12]!==i){let p;e[14]!==r||e[15]!==d||e[16]!==h?(p=c((f,y)=>{let z=N(f.id),v=z===""?`index-${y.toString()}`:z;return(0,n.jsxs)(Ze,{"data-testid":`${h}-${v}`,children:[r.map(I=>(0,n.jsx)(me,{className:I.className,children:I.render(f)},I.head)),(0,n.jsx)(me,{children:(0,n.jsx)("div",{className:"flex justify-end gap-1",children:d(f)})})]},v)},"f"),e[14]=r,e[15]=d,e[16]=h,e[17]=p):p=e[17],b=i.map(p),e[9]=r,e[10]=d,e[11]=h,e[12]=i,e[13]=b}else b=e[13];let u;e[18]!==b?(u=(0,n.jsx)(vt,{children:b}),e[18]=b,e[19]=u):u=e[19];let g;return e[20]!==m||e[21]!==u?(g=(0,n.jsxs)(ft,{children:[m,u]}),e[20]=m,e[21]=u,e[22]=g):g=e[22],g},"Xe");function Bt(t){return(0,n.jsx)(se,{children:t.head},t.head)}c(Bt,"jt");var Ut=c(t=>{let e=(0,U.c)(30),{actionBusy:r,onRemoveMember:d,memberColumns:h,members:i,onDialog:o}=t,a=q(),l;e[0]!==o?(l=c(()=>{o({kind:"add-member"})},"a"),e[0]=o,e[1]=l):l=e[1];let s;e[2]!==a?(s=a("Add member"),e[2]=a,e[3]=s):s=e[3];let m;e[4]!==l||e[5]!==s?(m=(0,n.jsx)(L,{"data-testid":"org-open-add-member",onClick:l,size:"xs",type:"button",variant:"outline",children:s}),e[4]=l,e[5]=s,e[6]=m):m=e[6];let b;e[7]!==o?(b=c(()=>{o({kind:"invite-member"})},"h"),e[7]=o,e[8]=b):b=e[8];let u;e[9]!==a?(u=a("Invite member"),e[9]=a,e[10]=u):u=e[10];let g;e[11]!==b||e[12]!==u?(g=(0,n.jsx)(L,{"data-testid":"org-open-invite-member",onClick:b,size:"xs",type:"button",variant:"outline",children:u}),e[11]=b,e[12]=u,e[13]=g):g=e[13];let p;e[14]!==m||e[15]!==g?(p=(0,n.jsxs)(n.Fragment,{children:[m,g]}),e[14]=m,e[15]=g,e[16]=p):p=e[16];let f;e[17]!==a?(f=a("Members"),e[17]=a,e[18]=f):f=e[18];let y;e[19]!==r||e[20]!==h||e[21]!==i||e[22]!==o||e[23]!==d||e[24]!==a?(y=i.length===0?(0,n.jsx)("div",{className:"p-3",children:(0,n.jsx)(ce,{testId:"org-members-empty",title:a("No members.")})}):(0,n.jsx)(Ke,{columns:h,rowActions:c(v=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(L,{"data-testid":`org-member-role-${N(v.id)}`,onClick:c(()=>{o({kind:"member-role",member:v})},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Change role")}),(0,n.jsx)(L,{"data-testid":`org-remove-member-${N(v.id)}`,disabled:r,onClick:c(()=>{d(N(v.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Remove")})]}),"rowActions"),rowPrefix:"org-member",rows:i}),e[19]=r,e[20]=h,e[21]=i,e[22]=o,e[23]=d,e[24]=a,e[25]=y):y=e[25];let z;return e[26]!==p||e[27]!==f||e[28]!==y?(z=(0,n.jsx)(Ge,{action:p,heading:f,testId:"org-members",children:y}),e[26]=p,e[27]=f,e[28]=y,e[29]=z):z=e[29],z},"Pt"),qt=c(t=>{let e=(0,U.c)(21),{onConfirmDeleteTeam:r,onDialog:d,onSelectTeam:h,selectedTeam:i,teamColumns:o,teams:a}=t,l=q(),s;e[0]!==d?(s=c(()=>{d({kind:"team-create"})},"s"),e[0]=d,e[1]=s):s=e[1];let m;e[2]!==l?(m=l("New team"),e[2]=l,e[3]=m):m=e[3];let b;e[4]!==s||e[5]!==m?(b=(0,n.jsx)(L,{"data-testid":"org-open-create-team",onClick:s,size:"xs",type:"button",variant:"outline",children:m}),e[4]=s,e[5]=m,e[6]=b):b=e[6];let u;e[7]!==l?(u=l("Teams"),e[7]=l,e[8]=u):u=e[8];let g;e[9]!==r||e[10]!==d||e[11]!==h||e[12]!==i||e[13]!==l||e[14]!==o||e[15]!==a?(g=a.length===0?(0,n.jsx)("div",{className:"p-3",children:(0,n.jsx)(ce,{testId:"org-teams-empty",title:l("No teams.")})}):(0,n.jsx)(Ke,{columns:o,rowActions:c(f=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(L,{"aria-pressed":i===N(f.id),"data-testid":`org-team-select-${N(f.id)}`,onClick:c(()=>{h(N(f.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Members")}),(0,n.jsx)(L,{"data-testid":`org-team-rename-${N(f.id)}`,onClick:c(()=>{d({kind:"team-rename",team:f})},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Rename")}),(0,n.jsx)(L,{"data-testid":`org-team-delete-${N(f.id)}`,onClick:c(()=>{r(f)},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Delete")})]}),"rowActions"),rowPrefix:"org-team",rows:a}),e[9]=r,e[10]=d,e[11]=h,e[12]=i,e[13]=l,e[14]=o,e[15]=a,e[16]=g):g=e[16];let p;return e[17]!==b||e[18]!==u||e[19]!==g?(p=(0,n.jsx)(Ge,{action:b,heading:u,testId:"org-teams",children:g}),e[17]=b,e[18]=u,e[19]=g,e[20]=p):p=e[20],p},"Bt"),Ht=c(t=>{let e=(0,U.c)(20),{actionBusy:r,onRemoveTeamMember:d,onDialog:h,selectedTeam:i,teamMemberColumns:o,teamMembers:a}=t,l=q(),s;e[0]!==h||e[1]!==i?(s=c(()=>{h({kind:"team-add-member",teamId:i})},"s"),e[0]=h,e[1]=i,e[2]=s):s=e[2];let m;e[3]!==l?(m=l("Add member"),e[3]=l,e[4]=m):m=e[4];let b;e[5]!==s||e[6]!==m?(b=(0,n.jsx)(L,{"data-testid":"org-open-add-team-member",onClick:s,size:"xs",type:"button",variant:"outline",children:m}),e[5]=s,e[6]=m,e[7]=b):b=e[7];let u;e[8]!==l?(u=l("Team members"),e[8]=l,e[9]=u):u=e[9];let g;e[10]!==r||e[11]!==d||e[12]!==l||e[13]!==o||e[14]!==a?(g=a.length===0?(0,n.jsx)("div",{className:"p-3",children:(0,n.jsx)(ce,{testId:"org-team-members-empty",title:l("No team members.")})}):(0,n.jsx)(Ke,{columns:o,rowActions:c(f=>(0,n.jsx)(L,{"data-testid":`org-team-remove-member-${N(f.id)}`,disabled:r,onClick:c(()=>{d(N(f.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Remove")}),"rowActions"),rowPrefix:"org-team-member",rows:a}),e[10]=r,e[11]=d,e[12]=l,e[13]=o,e[14]=a,e[15]=g):g=e[15];let p;return e[16]!==b||e[17]!==u||e[18]!==g?(p=(0,n.jsx)(Ge,{action:b,heading:u,testId:"org-team-members",children:g}),e[16]=b,e[17]=u,e[18]=g,e[19]=p):p=e[19],p},"Jt"),Qt=c(t=>{let e=(0,U.c)(19),{onConfirmDeleteRole:r,onDialog:d,roleColumns:h,roles:i}=t,o=q(),a;e[0]!==d?(a=c(()=>{d({kind:"role-create"})},"n"),e[0]=d,e[1]=a):a=e[1];let l;e[2]!==o?(l=o("New role"),e[2]=o,e[3]=l):l=e[3];let s;e[4]!==a||e[5]!==l?(s=(0,n.jsx)(L,{"data-testid":"org-open-create-role",onClick:a,size:"xs",type:"button",variant:"outline",children:l}),e[4]=a,e[5]=l,e[6]=s):s=e[6];let m;e[7]!==o?(m=o("Roles"),e[7]=o,e[8]=m):m=e[8];let b;e[9]!==r||e[10]!==d||e[11]!==h||e[12]!==i||e[13]!==o?(b=i.length===0?(0,n.jsx)("div",{className:"p-3",children:(0,n.jsx)(ce,{testId:"org-roles-empty",title:o("No custom roles.")})}):(0,n.jsx)(Ke,{columns:h,rowActions:c(g=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(L,{"data-testid":`org-role-edit-${N(g.id)}`,onClick:c(()=>{d({kind:"role-edit",role:g})},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Edit")}),(0,n.jsx)(L,{"data-testid":`org-role-delete-${N(g.id)}`,onClick:c(()=>{r(N(g.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]=b):b=e[14];let u;return e[15]!==s||e[16]!==m||e[17]!==b?(u=(0,n.jsx)(Ge,{action:s,heading:m,testId:"org-roles",children:b}),e[15]=s,e[16]=m,e[17]=b,e[18]=u):u=e[18],u},"Ut"),Wt=c(t=>{let e=(0,U.c)(199),{organizationId:r,rolesEnabled:d,teamsEnabled:h}=t,i=re(),o=q(),[a,l]=(0,j.useState)(null),[s,m]=(0,j.useState)(null),[b,u]=(0,j.useState)(!1),[g,p]=(0,j.useState)(null),f;e[0]!==r?(f=["lunora-auth-org-members",r],e[0]=r,e[1]=f):f=e[1];let y;e[2]!==i||e[3]!==r?(y=c(()=>i.listAuthOrgMembers({limit:200,organizationId:r}),"v"),e[2]=i,e[3]=r,e[4]=y):y=e[4];let z=ue(f,y),v;e[5]!==r?(v=["lunora-auth-org-invitations",r],e[5]=r,e[6]=v):v=e[6];let I;e[7]!==i||e[8]!==r?(I=c(()=>i.listAuthOrgInvitations({limit:200,organizationId:r}),"C"),e[7]=i,e[8]=r,e[9]=I):I=e[9];let C=ue(v,I),k;e[10]!==r?(k=["lunora-auth-org-teams",r],e[10]=r,e[11]=k):k=e[11];let w;e[12]!==i||e[13]!==r?(w=c(()=>i.listAuthOrgTeams({limit:200,organizationId:r}),"$"),e[12]=i,e[13]=r,e[14]=w):w=e[14];let x;e[15]!==h?(x={enabled:h},e[15]=h,e[16]=x):x=e[16];let S=ue(k,w,x),_;e[17]!==r?(_=["lunora-auth-org-roles",r],e[17]=r,e[18]=_):_=e[18];let A;e[19]!==i||e[20]!==r?(A=c(()=>i.listAuthOrgRoles({limit:200,organizationId:r}),"A"),e[19]=i,e[20]=r,e[21]=A):A=e[21];let D;e[22]!==d?(D={enabled:d},e[22]=d,e[23]=D):D=e[23];let $=ue(_,A,D),T;e[24]!==s?(T=["lunora-auth-org-team-members",s],e[24]=s,e[25]=T):T=e[25];let P;e[26]!==i||e[27]!==s?(P=c(()=>i.listAuthOrgTeamMembers({limit:200,teamId:s??""}),"P"),e[26]=i,e[27]=s,e[28]=P):P=e[28];let Q=s!==null,J;e[29]!==Q?(J={enabled:Q},e[29]=Q,e[30]=J):J=e[30];let E=ue(T,P,J),B;e[31]!==z.data?.rows?(B=z.data?.rows??[],e[31]=z.data?.rows,e[32]=B):B=e[32];let Y=B,M;e[33]!==C.data?.rows?(M=C.data?.rows??[],e[33]=C.data?.rows,e[34]=M):M=e[34];let R=M,H;e[35]!==S.data?.rows?(H=S.data?.rows??[],e[35]=S.data?.rows,e[36]=H):H=e[36];let ie=H,K;e[37]!==$.data?.rows?(K=$.data?.rows??[],e[37]=$.data?.rows,e[38]=K):K=e[38];let ee=K,X;e[39]!==s||e[40]!==E?(X=s===null?[]:E.data?.rows??[],e[39]=s,e[40]=E,e[41]=X):X=e[41];let te=X,oe=z.error??C.error??S.error??$.error??E.error,V;e[42]!==C||e[43]!==z||e[44]!==d||e[45]!==$||e[46]!==s||e[47]!==E||e[48]!==h||e[49]!==S?(V=c(()=>{z.refetch(),C.refetch(),h&&S.refetch(),d&&$.refetch(),s!==null&&E.refetch()},"W"),e[42]=C,e[43]=z,e[44]=d,e[45]=$,e[46]=s,e[47]=E,e[48]=h,e[49]=S,e[50]=V):V=e[50];let O=V;Ct(O,!0);let ne;e[51]===Symbol.for("react.memo_cache_sentinel")?(ne=c(()=>{l(null)},"oe"),e[51]=ne):ne=e[51];let F=ne,Xe;e[52]!==O?(Xe=c(G=>{xt((async()=>{u(!0),p(null);try{await G(),O(),u(!1)}catch(lt){p(wt(lt)),u(!1)}})())},"Ye"),e[52]=O,e[53]=Xe):Xe=e[53];let ae=Xe,Ve;e[54]!==i||e[55]!==o?(Ve=c(G=>{let lt=N(G.id);l({action:c(async()=>{await i.removeAuthOrgTeam({teamId:lt}),m(It=>It===lt?null:It)},"action"),kind:"confirm",message:o("Delete this team and its memberships? This cannot be undone."),testId:"org-team-delete",title:o("Delete team")})},"Ze"),e[54]=i,e[55]=o,e[56]=Ve):Ve=e[56];let it=Ve,ge;e[57]!==o?(ge=o("userId"),e[57]=o,e[58]=ge):ge=e[58];let he;e[59]!==ge?(he={head:ge,render:Yt},e[59]=ge,e[60]=he):he=e[60];let be;e[61]!==o?(be=o("role"),e[61]=o,e[62]=be):be=e[62];let fe;e[63]!==be?(fe={head:be,render:Zt},e[63]=be,e[64]=fe):fe=e[64];let et;e[65]!==he||e[66]!==fe?(et=[he,fe],e[65]=he,e[66]=fe,e[67]=et):et=e[67];let st=et,pe;e[68]!==o?(pe=o("email"),e[68]=o,e[69]=pe):pe=e[69];let ve;e[70]!==pe?(ve={head:pe,render:Gt},e[70]=pe,e[71]=ve):ve=e[71];let ye;e[72]!==o?(ye=o("role"),e[72]=o,e[73]=ye):ye=e[73];let Ce;e[74]!==ye?(Ce={head:ye,render:Kt},e[74]=ye,e[75]=Ce):Ce=e[75];let Ie;e[76]!==o?(Ie=o("status"),e[76]=o,e[77]=Ie):Ie=e[77];let we;e[78]!==Ie?(we={head:Ie,render:Xt},e[78]=Ie,e[79]=we):we=e[79];let tt;e[80]!==ve||e[81]!==Ce||e[82]!==we?(tt=[ve,Ce,we],e[80]=ve,e[81]=Ce,e[82]=we,e[83]=tt):tt=e[83];let mt=tt,xe;e[84]!==o?(xe=o("id"),e[84]=o,e[85]=xe):xe=e[85];let ze;e[86]!==xe?(ze={className:"font-mono text-xs",head:xe,render:Vt},e[86]=xe,e[87]=ze):ze=e[87];let ke;e[88]!==o?(ke=o("name"),e[88]=o,e[89]=ke):ke=e[89];let Se;e[90]!==ke?(Se={head:ke,render:er},e[90]=ke,e[91]=Se):Se=e[91];let rt;e[92]!==ze||e[93]!==Se?(rt=[ze,Se],e[92]=ze,e[93]=Se,e[94]=rt):rt=e[94];let dt=rt,Ne;e[95]!==o?(Ne=o("userId"),e[95]=o,e[96]=Ne):Ne=e[96];let ot;e[97]!==Ne?(ot=[{head:Ne,render:tr}],e[97]=Ne,e[98]=ot):ot=e[98];let ct=ot,De;e[99]!==o?(De=o("role"),e[99]=o,e[100]=De):De=e[100];let Ae;e[101]!==De?(Ae={head:De,render:rr},e[101]=De,e[102]=Ae):Ae=e[102];let Oe;e[103]!==o?(Oe=o("Permission"),e[103]=o,e[104]=Oe):Oe=e[104];let _e;e[105]!==Oe?(_e={className:"font-mono text-xs whitespace-pre-wrap",head:Oe,render:or},e[105]=Oe,e[106]=_e):_e=e[106];let nt;e[107]!==Ae||e[108]!==_e?(nt=[Ae,_e],e[107]=Ae,e[108]=_e,e[109]=nt):nt=e[109];let ut=nt,$e;e[110]!==oe?($e=oe!==null&&(0,n.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-detail-error",role:"alert",children:oe}),e[110]=oe,e[111]=$e):$e=e[111];let Te;e[112]!==g?(Te=g!==null&&(0,n.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-action-error",role:"alert",children:g}),e[112]=g,e[113]=Te):Te=e[113];let Me;e[114]!==i||e[115]!==ae?(Me=c(G=>{ae(()=>i.removeAuthOrgMember({memberId:G}))},"_e"),e[114]=i,e[115]=ae,e[116]=Me):Me=e[116];let Re;e[117]!==b||e[118]!==st||e[119]!==Y||e[120]!==Me?(Re=(0,n.jsx)(Ut,{actionBusy:b,memberColumns:st,members:Y,onDialog:l,onRemoveMember:Me}),e[117]=b,e[118]=st,e[119]=Y,e[120]=Me,e[121]=Re):Re=e[121];let Fe;e[122]!==b||e[123]!==i||e[124]!==mt||e[125]!==R||e[126]!==ae||e[127]!==o?(Fe=R.length>0&&(0,n.jsx)(Ge,{heading:o("Invitations"),testId:"org-invitations",children:(0,n.jsx)(Ke,{columns:mt,rowActions:c(G=>(0,n.jsx)(L,{"data-testid":`org-cancel-invitation-${N(G.id)}`,disabled:b,onClick:c(()=>{ae(()=>i.cancelAuthOrgInvitation({invitationId:N(G.id)}))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Cancel")}),"rowActions"),rowPrefix:"org-invitation",rows:R})}),e[122]=b,e[123]=i,e[124]=mt,e[125]=R,e[126]=ae,e[127]=o,e[128]=Fe):Fe=e[128];let Ee;e[129]!==it||e[130]!==s||e[131]!==dt||e[132]!==ie||e[133]!==h?(Ee=h&&(0,n.jsx)(qt,{onConfirmDeleteTeam:it,onDialog:l,onSelectTeam:m,selectedTeam:s,teamColumns:dt,teams:ie}),e[129]=it,e[130]=s,e[131]=dt,e[132]=ie,e[133]=h,e[134]=Ee):Ee=e[134];let Le;e[135]!==b||e[136]!==i||e[137]!==ae||e[138]!==s||e[139]!==ct||e[140]!==te||e[141]!==h?(Le=h&&s!==null&&(0,n.jsx)(Ht,{actionBusy:b,onDialog:l,onRemoveTeamMember:c(G=>{ae(()=>i.removeAuthOrgTeamMember({teamMemberId:G}))},"onRemoveTeamMember"),selectedTeam:s,teamMemberColumns:ct,teamMembers:te}),e[135]=b,e[136]=i,e[137]=ae,e[138]=s,e[139]=ct,e[140]=te,e[141]=h,e[142]=Le):Le=e[142];let je;e[143]!==i||e[144]!==ut||e[145]!==ee||e[146]!==d||e[147]!==o?(je=d&&(0,n.jsx)(Qt,{onConfirmDeleteRole:c(G=>{l({action:c(()=>i.deleteAuthOrgRole({roleId:G}),"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:l,roleColumns:ut,roles:ee}),e[143]=i,e[144]=ut,e[145]=ee,e[146]=d,e[147]=o,e[148]=je):je=e[148];let Pe;e[149]!==a?.kind||e[150]!==r||e[151]!==O?(Pe=a?.kind==="add-member"&&(0,n.jsx)(Lt,{onClose:F,onDone:O,organizationId:r}),e[149]=a?.kind,e[150]=r,e[151]=O,e[152]=Pe):Pe=e[152];let Je;e[153]!==a?.kind||e[154]!==r||e[155]!==O?(Je=a?.kind==="invite-member"&&(0,n.jsx)(jt,{onClose:F,onDone:O,organizationId:r}),e[153]=a?.kind,e[154]=r,e[155]=O,e[156]=Je):Je=e[156];let Be;e[157]!==a||e[158]!==O?(Be=a?.kind==="member-role"&&(0,n.jsx)(Pt,{member:a.member,onClose:F,onDone:O}),e[157]=a,e[158]=O,e[159]=Be):Be=e[159];let Ue;e[160]!==a?.kind||e[161]!==r||e[162]!==O?(Ue=a?.kind==="team-create"&&(0,n.jsx)(At,{mode:"create",onClose:F,onDone:O,organizationId:r}),e[160]=a?.kind,e[161]=r,e[162]=O,e[163]=Ue):Ue=e[163];let qe;e[164]!==a||e[165]!==r||e[166]!==O?(qe=a?.kind==="team-rename"&&(0,n.jsx)(At,{mode:"edit",onClose:F,onDone:O,organizationId:r,team:a.team}),e[164]=a,e[165]=r,e[166]=O,e[167]=qe):qe=e[167];let He;e[168]!==a||e[169]!==O?(He=a?.kind==="team-add-member"&&(0,n.jsx)(Jt,{onClose:F,onDone:O,teamId:a.teamId}),e[168]=a,e[169]=O,e[170]=He):He=e[170];let Qe;e[171]!==a?.kind||e[172]!==r||e[173]!==O?(Qe=a?.kind==="role-create"&&(0,n.jsx)(Ot,{mode:"create",onClose:F,onDone:O,organizationId:r}),e[171]=a?.kind,e[172]=r,e[173]=O,e[174]=Qe):Qe=e[174];let We;e[175]!==a||e[176]!==r||e[177]!==O?(We=a?.kind==="role-edit"&&(0,n.jsx)(Ot,{mode:"edit",onClose:F,onDone:O,organizationId:r,role:a.role}),e[175]=a,e[176]=r,e[177]=O,e[178]=We):We=e[178];let Ye;e[179]!==a||e[180]!==O?(Ye=a?.kind==="confirm"&&(0,n.jsx)(Tt,{action:a.action,message:a.message,onClose:F,onDone:O,testId:a.testId,title:a.title}),e[179]=a,e[180]=O,e[181]=Ye):Ye=e[181];let at;return e[182]!==$e||e[183]!==Te||e[184]!==Re||e[185]!==Fe||e[186]!==Ee||e[187]!==Le||e[188]!==je||e[189]!==Pe||e[190]!==Je||e[191]!==Be||e[192]!==Ue||e[193]!==qe||e[194]!==He||e[195]!==Qe||e[196]!==We||e[197]!==Ye?(at=(0,n.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"org-detail",children:[$e,Te,Re,Fe,Ee,Le,je,Pe,Je,Be,Ue,qe,He,Qe,We,Ye]}),e[182]=$e,e[183]=Te,e[184]=Re,e[185]=Fe,e[186]=Ee,e[187]=Le,e[188]=je,e[189]=Pe,e[190]=Je,e[191]=Be,e[192]=Ue,e[193]=qe,e[194]=He,e[195]=Qe,e[196]=We,e[197]=Ye,e[198]=at):at=e[198],at},"Ht");function Yt(t){return(0,n.jsx)("span",{className:"font-mono text-xs",children:N(t.userId)})}c(Yt,"Kt");function Zt(t){return N(t.role)}c(Zt,"qt");function Gt(t){return N(t.email)}c(Gt,"Gt");function Kt(t){return N(t.role)}c(Kt,"Qt");function Xt(t){return N(t.status)}c(Xt,"Vt");function Vt(t){return N(t.id)}c(Vt,"Xt");function er(t){return N(t.name)}c(er,"Yt");function tr(t){return(0,n.jsx)("span",{className:"font-mono text-xs",children:N(t.userId)})}c(tr,"Zt");function rr(t){return N(t.role)}c(rr,"Wt");function or(t){return N(t.permission)}c(or,"er");var yr=c(()=>{let t=(0,U.c)(62),e=re(),r=q(),{config:d,ready:h}=St(),i=d.capabilities.organization,[o,a]=(0,j.useState)(null),[l,s]=(0,j.useState)(null),m;t[0]===Symbol.for("react.memo_cache_sentinel")?(m=["lunora-auth-orgs"],t[0]=m):m=t[0];let b;t[1]!==e?(b=c(()=>e.listAuthOrganizations({limit:100}),"h"),t[1]=e,t[2]=b):b=t[2];let u;t[3]!==i?(u={enabled:i},t[3]=i,t[4]=u):u=t[4];let g=ue(m,b,u),p=g.data?.rows??null,f;t[5]!==g?(f=c(()=>{g.refetch()},"b"),t[5]=g,t[6]=f):f=t[6],Ct(f,i);let y;t[7]===Symbol.for("react.memo_cache_sentinel")?(y=c(()=>{s(null)},"v"),t[7]=y):y=t[7];let z=y,v;t[8]!==g?(v=c(()=>{g.refetch()},"p"),t[8]=g,t[9]=v):v=t[9];let I=v,C;t[10]===Symbol.for("react.memo_cache_sentinel")?(C=c(M=>{a(M)},"y"),t[10]=C):C=t[10];let k=C;if(h&&!i){let M;t[11]!==r?(M=r("Enable the organization() plugin in your auth config to manage organizations here."),t[11]=r,t[12]=M):M=t[12];let R;t[13]!==r?(R=r("Organizations are not enabled."),t[13]=r,t[14]=R):R=t[14];let H;return t[15]!==M||t[16]!==R?(H=(0,n.jsx)(ce,{description:M,testId:"org-disabled",title:R}),t[15]=M,t[16]=R,t[17]=H):H=t[17],H}let w;t[18]!==r?(w=r("Organizations"),t[18]=r,t[19]=w):w=t[19];let x;t[20]!==w?(x=(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:w}),t[20]=w,t[21]=x):x=t[21];let S;t[22]===Symbol.for("react.memo_cache_sentinel")?(S=c(()=>{s({kind:"create"})},"z"),t[22]=S):S=t[22];let _;t[23]!==r?(_=r("New organization"),t[23]=r,t[24]=_):_=t[24];let A;t[25]!==_?(A=(0,n.jsx)(L,{"data-testid":"org-new",onClick:S,size:"sm",type:"button",children:_}),t[25]=_,t[26]=A):A=t[26];let D;t[27]!==A||t[28]!==x?(D=(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[x,A]}),t[27]=A,t[28]=x,t[29]=D):D=t[29];let $;t[30]!==g.error?($=g.error!==null&&(0,n.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-error",role:"alert",children:g.error}),t[30]=g.error,t[31]=$):$=t[31];let T;t[32]!==p||t[33]!==r?(T=p!==null&&p.length===0&&(0,n.jsx)(ce,{testId:"org-empty",title:r("No organizations.")}),t[32]=p,t[33]=r,t[34]=T):T=t[34];let P;t[35]!==p||t[36]!==o||t[37]!==r?(P=p!==null&&p.length>0&&(0,n.jsx)(ht,{className:"overflow-hidden py-0",children:(0,n.jsx)(bt,{className:"px-0",children:(0,n.jsxs)(ft,{"data-testid":"org-table",children:[(0,n.jsx)(pt,{children:(0,n.jsxs)(Ze,{children:[(0,n.jsx)(se,{children:r("id")}),(0,n.jsx)(se,{children:r("name")}),(0,n.jsx)(se,{children:r("slug")}),(0,n.jsx)(se,{children:r("created")}),(0,n.jsx)(se,{"aria-label":r("Actions")})]})}),(0,n.jsx)(vt,{children:p.map(M=>{let R=N(M.id);return(0,n.jsxs)(Ze,{"data-testid":`org-row-${R}`,children:[(0,n.jsx)(me,{className:"font-mono text-xs",children:R}),(0,n.jsx)(me,{children:N(M.name)}),(0,n.jsx)(me,{children:N(M.slug)}),(0,n.jsx)(me,{className:"text-muted-foreground tabular-nums",children:zt(M.createdAt)}),(0,n.jsx)(me,{children:(0,n.jsxs)("div",{className:"flex justify-end gap-1",children:[(0,n.jsx)(L,{"aria-pressed":o===R,"data-testid":`org-select-${R}`,onClick:c(()=>{k(R)},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Manage")}),(0,n.jsx)(L,{"data-testid":`org-edit-${R}`,onClick:c(()=>{s({kind:"edit",org:M})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Edit")}),(0,n.jsx)(L,{"data-testid":`org-delete-${R}`,onClick:c(()=>{s({kind:"delete",org:M})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Delete")})]})})]},R)})})]})})}),t[35]=p,t[36]=o,t[37]=r,t[38]=P):P=t[38];let Q;t[39]!==d.organization||t[40]!==o?(Q=o!==null&&(0,n.jsx)(Wt,{organizationId:o,rolesEnabled:d.organization.roles,teamsEnabled:d.organization.teams}),t[39]=d.organization,t[40]=o,t[41]=Q):Q=t[41];let J;t[42]!==l?.kind||t[43]!==I?(J=l?.kind==="create"&&(0,n.jsx)(Dt,{mode:"create",onClose:z,onDone:I}),t[42]=l?.kind,t[43]=I,t[44]=J):J=t[44];let E;t[45]!==l||t[46]!==I?(E=l?.kind==="edit"&&(0,n.jsx)(Dt,{mode:"edit",onClose:z,onDone:I,org:l.org}),t[45]=l,t[46]=I,t[47]=E):E=t[47];let B;t[48]!==e||t[49]!==l||t[50]!==I||t[51]!==r?(B=l?.kind==="delete"&&(0,n.jsx)(Tt,{action:c(async()=>{let M=N(l.org.id);await e.deleteAuthOrganization({organizationId:M}),a(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:z,onDone:I,testId:"org-delete",title:r("Delete organization")}),t[48]=e,t[49]=l,t[50]=I,t[51]=r,t[52]=B):B=t[52];let Y;return t[53]!==D||t[54]!==$||t[55]!==T||t[56]!==P||t[57]!==Q||t[58]!==J||t[59]!==E||t[60]!==B?(Y=(0,n.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-organizations",children:[D,$,T,P,Q,J,E,B]}),t[53]=D,t[54]=$,t[55]=T,t[56]=P,t[57]=Q,t[58]=J,t[59]=E,t[60]=B,t[61]=Y):Y=t[61],Y},"yr");export{yr as OrganizationsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as Q}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as W}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{f as F}from"./chunk-
|
|
1
|
+
import{R as Q}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as W}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{f as F}from"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as Z}from"./chunk-XQCVZAGU.js";import{a as q,b as L,c as B,d as f,e as c,f as d}from"./chunk-MIQTKZAR.js";import{a as I,e as j}from"./chunk-UZERI5YC.js";import{d as K,h as S,l as $,m as V}from"./chunk-OG4N2XHD.js";import"./chunk-QNUWWC3N.js";import{a as h,e as C,f as R,g as P,h as U}from"./chunk-3XIESWL4.js";var A=C(P(),1);var n=C(R(),1);var e=C(U(),1);var X=10,g=h(v=>{let l=(0,A.c)(7),{label:m,value:a}=v,r;l[0]!==m?(r=(0,e.jsx)("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:m}),l[0]=m,l[1]=r):r=l[1];let p=a??"\u2014",s;l[2]!==p?(s=(0,e.jsx)("span",{className:"font-mono text-sm",children:p}),l[2]=p,l[3]=s):s=l[3];let u;return l[4]!==r||l[5]!==s?(u=(0,e.jsxs)("div",{className:"flex flex-col gap-0.5",children:[r,s]}),l[4]=r,l[5]=s,l[6]=u):u=l[6],u},"g"),se=h(({loadIndexes:v,runQuery:l}={})=>{let m=F(),a=K(),[r,p]=(0,n.useState)(null),[s,u]=(0,n.useState)(null),[N,E]=(0,n.useState)(null),[b,D]=(0,n.useState)(""),[x,y]=(0,n.useState)(null),[M,w]=(0,n.useState)(null),[T,z]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let t={cancelled:!1};return V((async()=>{try{let i=await(v??(()=>m.listVectorIndexes()))();t.cancelled||(p(i),u(null),E(k=>k??i[0]?.name??null))}catch(i){t.cancelled||(p(null),u(S(i)))}})()),()=>{t.cancelled=!0}},[m,v]);let o=r?.find(t=>t.name===N)??null,G=h(t=>{E(t.currentTarget.dataset.index??null),y(null),w(null)},"K"),H=h(t=>{D(t.target.value)},"T"),J=h(async()=>{let t=b.trim();if(!(N===null||t==="")){z(!0),w(null);try{let i=await(l??(k=>m.queryVectorIndex(k)))({name:N,text:t,topK:X});y(i)}catch(i){y(null),w(S(i))}z(!1)}},"Z"),O=h(()=>{V(J())},"z");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-vector-browser",children:[s!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"vector-error",role:"alert",children:s}),r!==null&&r.length===0&&(0,e.jsx)(Z,{description:a("Indexes declared with .vectorize() or defineVectorIndex() appear here."),icon:(0,e.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsx)("path",{d:"M4 7l8-4 8 4-8 4-8-4Zm0 5 8 4 8-4M4 17l8 4 8-4"})}),testId:"vector-empty",title:a("No vector indexes.")}),r!==null&&r.length>0&&(0,e.jsx)(I,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(q,{"data-testid":"vector-table",children:[(0,e.jsx)(L,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(c,{children:a("name")}),(0,e.jsx)(c,{children:a("table")}),(0,e.jsx)(c,{children:a("dimensions")}),(0,e.jsx)(c,{children:a("metric")}),(0,e.jsx)(c,{children:a("vectors")})]})}),(0,e.jsx)(B,{children:r.map(t=>(0,e.jsxs)(f,{className:t.name===N?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-index":t.name,"data-testid":`vector-row-${t.name}`,onClick:G,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:t.name}),(0,e.jsx)(d,{className:"font-mono text-xs",children:t.table}),(0,e.jsx)(d,{className:"tabular-nums",children:t.dimensions??"\u2014"}),(0,e.jsx)(d,{children:t.metric??"\u2014"}),(0,e.jsx)(d,{className:"tabular-nums",children:t.vectorsCount??"\u2014"})]},t.name))})]})})}),o!==null&&(0,e.jsxs)("section",{className:"border border-border bg-card p-3","data-testid":"vector-detail",children:[(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[(0,e.jsx)(g,{label:a("field"),value:o.field}),(0,e.jsx)(g,{label:a("dimensions"),value:o.dimensions}),(0,e.jsx)(g,{label:a("metric"),value:o.metric}),(0,e.jsx)(g,{label:a("vectors"),value:o.vectorsCount})]}),o.metadata!==void 0&&o.metadata.length>0&&(0,e.jsxs)("p",{className:"mt-3 text-xs text-muted-foreground","data-testid":"vector-metadata",children:[a("metadata"),": ",(0,e.jsx)("span",{className:"font-mono",children:o.metadata.join(", ")})]}),(0,e.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,e.jsx)(Q,{className:"min-w-[18rem] flex-1","data-testid":"vector-query-input",onChange:H,placeholder:a("Search by similarity\u2026"),value:b}),(0,e.jsx)(W,{"data-testid":"vector-search",disabled:T||b.trim()==="",onClick:O,children:a(T?"Searching\u2026":"Search")})]}),M!==null&&(0,e.jsx)("p",{className:"mt-2 text-sm text-destructive","data-testid":"vector-query-error",role:"alert",children:M}),x!==null&&x.length===0&&(0,e.jsx)("p",{className:"mt-2 text-sm text-muted-foreground","data-testid":"vector-no-matches",children:a("No matches.")}),x!==null&&x.length>0&&(0,e.jsx)(I,{className:"mt-3 overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(q,{"data-testid":"vector-matches",children:[(0,e.jsx)(L,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(c,{children:a("id")}),(0,e.jsx)(c,{children:a("score")}),(0,e.jsx)(c,{children:a("metadata")})]})}),(0,e.jsx)(B,{children:x.map(t=>(0,e.jsxs)(f,{"data-testid":`vector-match-${t.id}`,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:t.id}),(0,e.jsx)(d,{className:"tabular-nums",children:t.score.toFixed(4)}),(0,e.jsx)(d,{className:"max-w-md truncate font-mono text-xs",children:t.metadata===void 0?"\u2014":$(t.metadata)})]},t.id))})]})})})]})]})},"ce");export{se as VectorBrowser};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as ye}from"./chunk-V53KNYRN.js";import{a as we}from"./chunk-QXXIJAD5.js";import{a as Ne}from"./chunk-X665E2HU.js";import{b as pe}from"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as ge}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{a as H}from"./chunk-ERMTJYQF.js";import{d as be}from"./chunk-
|
|
1
|
+
import{a as ye}from"./chunk-V53KNYRN.js";import{a as we}from"./chunk-QXXIJAD5.js";import{a as Ne}from"./chunk-X665E2HU.js";import{b as pe}from"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as ge}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{a as H}from"./chunk-ERMTJYQF.js";import{d as be}from"./chunk-YGKR536O.js";import{f as xe}from"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as ne,e as ie}from"./chunk-UZERI5YC.js";import{d as he,f as ce,g as de,h as ee,m as me}from"./chunk-OG4N2XHD.js";import{c as ae}from"./chunk-QNUWWC3N.js";import{a,e as se,f as ve,g as je,h as Ee}from"./chunk-3XIESWL4.js";var Se=se(je(),1);var b=se(ve(),1);var r=se(Ee(),1);var Ce=ce(H.exportShard),Oe=ce(H.importShard),Te=a(x=>x.map(e=>JSON.stringify(e)).join(`
|
|
2
2
|
`),"je"),Ae=a(x=>{let e=[],te=x.split(`
|
|
3
3
|
`);for(let[n,N]of te.entries()){let t=N.trim();if(t==="")continue;let o=JSON.parse(t);if(typeof o!="object"||o===null)throw new ae("INTERNAL",`line ${(n+1).toString()}: expected a { table, doc } object`);let h=o;if(typeof h.table!="string"||typeof h.doc!="object"||h.doc===null||Array.isArray(h.doc))throw new ae("INTERNAL",`line ${(n+1).toString()}: expected a { table, doc } object`);e.push(h)}return e},"$e"),Me=a(x=>{let e=(0,Se.c)(94),{initialShardKey:te}=x,n=xe(),N=be(),t=he(),[o,h]=(0,b.useState)(te??""),[l,ue]=(0,b.useState)(""),[d,K]=(0,b.useState)(!1),[Q,M]=(0,b.useState)(null),[i,re]=(0,b.useState)(null),[w,fe]=(0,b.useState)(null),V;e[0]!==n||e[1]!==o?(V=a(async()=>{K(!0),M(null),re(null);try{let c=await n.query(Ce,{},de(o));pe(o),ue(Te(c.rows)),fe(c.rows.length)}catch(c){M(ee(c))}K(!1)},"Q"),e[0]=n,e[1]=o,e[2]=V):V=e[2];let z=V,W;e[3]!==n||e[4]!==N||e[5]!==l||e[6]!==o||e[7]!==t?(W=a(async()=>{K(!0),M(null),re(null),fe(null);let c;try{c=Ae(l)}catch(s){M(t("Invalid NDJSON: {message}",{message:ee(s)})),K(!1);return}try{let s=await n.query(Oe,{rows:c},de(o));pe(o),re(s),N(H.readTablePage),N(H.listTables)}catch(s){M(ee(s))}K(!1)},"V"),e[3]=n,e[4]=N,e[5]=l,e[6]=o,e[7]=t,e[8]=W):W=e[8];let G=W,y,S,I,m,v,p,u,j,E,f,C;if(e[9]!==d||e[10]!==w||e[11]!==z||e[12]!==i||e[13]!==G||e[14]!==l||e[15]!==o||e[16]!==t){let c=i===null?0:Object.values(i.inserted).reduce(Le,0),s;e[28]!==z?(s=a(()=>{me(z())},"s"),e[28]=z,e[29]=s):s=e[29];let oe=s,Y;e[30]!==G?(Y=a(()=>{me(G())},"X"),e[30]=G,e[31]=Y):Y=e[31];let le=Y,Z;e[32]===Symbol.for("react.memo_cache_sentinel")?(Z=a(g=>{ue(g.target.value)},"Y"),e[32]=Z):Z=e[32];let Ie=Z;C="flex flex-col gap-4",I="lunora-export-import";let L;e[33]!==t?(L=t("Export"),e[33]=t,e[34]=L):L=e[34];let $;e[35]!==L?($=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:L})}),e[35]=L,e[36]=$):$=e[36];let J;e[37]!==o?(J=(0,r.jsx)(Ne,{onChange:h,testId:"ei-shard-input",value:o}),e[37]=o,e[38]=J):J=e[38];let k;e[39]!==t?(k=t("Export"),e[39]=t,e[40]=k):k=e[40];let D;e[41]!==d||e[42]!==oe||e[43]!==k?(D=(0,r.jsx)(ge,{"data-testid":"ei-export",disabled:d,onClick:oe,type:"button",children:k}),e[41]=d,e[42]=oe,e[43]=k,e[44]=D):D=e[44];let _;e[45]!==J||e[46]!==D?(_=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[J,D]}),e[45]=J,e[46]=D,e[47]=_):_=e[47];let q;e[48]!==w||e[49]!==t?(q=w!==null&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ei-export-result",children:t("Exported {count} rows.",{count:w})}),e[48]=w,e[49]=t,e[50]=q):q=e[50];let B;e[51]!==_||e[52]!==q?(B=(0,r.jsxs)(ie,{className:"flex flex-col gap-3 p-4",children:[_,q]}),e[51]=_,e[52]=q,e[53]=B):B=e[53],e[54]!==$||e[55]!==B?(m=(0,r.jsxs)(ne,{className:"rounded-xl border border-border bg-card shadow-xs",children:[$,B]}),e[54]=$,e[55]=B,e[56]=m):m=e[56],S=ne,E="rounded-xl border border-border bg-card shadow-xs";let P;e[57]!==t?(P=t("Import"),e[57]=t,e[58]=P):P=e[58],e[59]!==P?(f=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:P})}),e[59]=P,e[60]=f):f=e[60],y=ie,v="flex flex-col gap-3 p-4",e[61]!==l?(p=(0,r.jsx)(ye,{"aria-label":"NDJSON",className:"font-mono text-xs min-h-40 rounded-md","data-testid":"ei-ndjson",onChange:Ie,placeholder:'{"table":"messages","doc":{\u2026}}',value:l}),e[61]=l,e[62]=p):p=e[62];let R;e[63]!==t?(R=t("Import (writes rows)?"),e[63]=t,e[64]=R):R=e[64];let U;e[65]!==d||e[66]!==l?(U=d||l.trim()==="",e[65]=d,e[66]=l,e[67]=U):U=e[67];let F;e[68]!==t?(F=t("Import"),e[68]=t,e[69]=F):F=e[69],e[70]!==le||e[71]!==R||e[72]!==U||e[73]!==F?(u=(0,r.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:(0,r.jsx)(we,{confirmLabel:R,disabled:U,onConfirm:le,testId:"ei-import",children:F})}),e[70]=le,e[71]=R,e[72]=U,e[73]=F,e[74]=u):u=e[74],j=i!==null&&(0,r.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ei-import-result",children:[(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:t("Inserted {inserted}, {conflicts} conflicts, {errors} errors.",{conflicts:i.conflicts,errors:i.errors.length,inserted:c})}),i.errors.length>0&&(0,r.jsx)("ul",{className:"flex flex-col gap-1","data-testid":"ei-import-errors",children:i.errors.map(g=>(0,r.jsx)("li",{className:"text-xs text-destructive",children:t("line {line} ({table}): {message}",{line:g.line,message:g.message,table:g.table})},`${g.table}-${g.line.toString()}`))})]}),e[9]=d,e[10]=w,e[11]=z,e[12]=i,e[13]=G,e[14]=l,e[15]=o,e[16]=t,e[17]=y,e[18]=S,e[19]=I,e[20]=m,e[21]=v,e[22]=p,e[23]=u,e[24]=j,e[25]=E,e[26]=f,e[27]=C}else y=e[17],S=e[18],I=e[19],m=e[20],v=e[21],p=e[22],u=e[23],j=e[24],E=e[25],f=e[26],C=e[27];let O;e[75]!==y||e[76]!==v||e[77]!==p||e[78]!==u||e[79]!==j?(O=(0,r.jsxs)(y,{className:v,children:[p,u,j]}),e[75]=y,e[76]=v,e[77]=p,e[78]=u,e[79]=j,e[80]=O):O=e[80];let T;e[81]!==S||e[82]!==O||e[83]!==E||e[84]!==f?(T=(0,r.jsxs)(S,{className:E,children:[f,O]}),e[81]=S,e[82]=O,e[83]=E,e[84]=f,e[85]=T):T=e[85];let A;e[86]!==Q?(A=Q!==null&&(0,r.jsx)("p",{className:"text-sm text-destructive","data-testid":"ei-error",role:"alert",children:Q}),e[86]=Q,e[87]=A):A=e[87];let X;return e[88]!==I||e[89]!==m||e[90]!==T||e[91]!==A||e[92]!==C?(X=(0,r.jsxs)("div",{className:C,"data-testid":I,children:[m,T,A]}),e[88]=I,e[89]=m,e[90]=T,e[91]=A,e[92]=C,e[93]=X):X=e[93],X},"Be");function Le(x,e){return x+e}a(Le,"Ee");export{Me as ExportImportPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as q,b as B}from"./chunk-AVAC26HJ.js";import{a as O}from"./chunk-CTNB2KIA.js";import{a as j}from"./chunk-X665E2HU.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{a as z}from"./chunk-LFKCLLPT.js";import{R as C}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as y}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as A}from"./chunk-
|
|
1
|
+
import{a as q,b as B}from"./chunk-AVAC26HJ.js";import{a as O}from"./chunk-CTNB2KIA.js";import{a as j}from"./chunk-X665E2HU.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{a as z}from"./chunk-LFKCLLPT.js";import{R as C}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as y}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as A}from"./chunk-AHVDZWB3.js";import"./chunk-XXQUMVWH.js";import"./chunk-VORDESEQ.js";import"./chunk-QLQADHFE.js";import{a as V}from"./chunk-ERMTJYQF.js";import{c as R}from"./chunk-YGKR536O.js";import"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as k}from"./chunk-XQCVZAGU.js";import{a as T,b as F,c as K,d as p,e as l,f as d}from"./chunk-MIQTKZAR.js";import{a as I,e as E}from"./chunk-UZERI5YC.js";import{d as L,q as M}from"./chunk-OG4N2XHD.js";import"./chunk-QNUWWC3N.js";import{a as o,e as b,f as ee,h as te}from"./chunk-3XIESWL4.js";var i=b(ee(),1);var e=b(te(),1);var D=80,re=o(s=>{if(s===void 0)return"";let t=JSON.stringify(s);return t.length>D?`${t.slice(0,D)}\u2026`:t},"te"),ae=41,J=480,H=5,ie=o((s,t)=>q(s,n=>{t(n.height>0?n:{height:J,width:n.width})}),"ae"),Ne=o(({initialShardKey:s})=>{let t=L(),[n,P]=(0,i.useState)(s??""),[c,U]=(0,i.useState)(""),W=z(n.trim(),400),{data:f,error:g,errorSource:Z,isLoading:_,liveError:$}=R(V.getAuditLog,{},{live:!0,shardKey:W}),h=(0,i.useMemo)(()=>f?.entries??[],[f]),m=(0,i.useMemo)(()=>{let a=c.trim().toLowerCase();return a===""?h:h.filter(r=>r.op.toLowerCase().includes(a)||(r.table??"").toLowerCase().includes(a)||(r.id??"").toLowerCase().includes(a))},[h,c]),x=(0,i.useRef)(null),v=B({count:m.length,estimateSize:o(()=>ae,"estimateSize"),getScrollElement:o(()=>x.current,"getScrollElement"),initialRect:{height:J,width:800},observeElementRect:ie,overscan:8}),u=v.getVirtualItems(),G=v.getTotalSize(),N=u[0]?.start??0,w=G-(u.at(-1)?.end??0),Q={height:N},X={height:w},Y=o(a=>{U(a.target.value)},"V");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-audit",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(j,{onChange:P,testId:"au-shard-input",value:n}),(0,e.jsx)(O,{message:$,prefix:"au"}),(0,e.jsx)(C,{"aria-label":t("Filter audit log"),className:"h-8 w-48","data-testid":"au-search",onChange:Y,placeholder:t("filter op, table, id"),value:c})]}),g!==null&&(0,e.jsx)(A,{error:Z,testId:"au-error"}),g===null&&!_&&m.length===0&&(0,e.jsx)(k,{description:t("State-changing admin operations are recorded here."),icon:(0,e.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsx)("path",{d:"M8 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2h-2M9 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V3Zm-1 9h8m-8 4h5"})}),testId:"au-empty",title:t("No audit entries.")}),m.length>0&&(0,e.jsx)(I,{className:"overflow-hidden py-0",children:(0,e.jsx)(E,{className:"max-h-[30rem] overflow-auto px-0",ref:x,children:(0,e.jsxs)(T,{"data-testid":"au-table",children:[(0,e.jsx)(F,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(l,{children:t("time")}),(0,e.jsx)(l,{children:t("op")}),(0,e.jsx)(l,{children:t("table")}),(0,e.jsx)(l,{children:t("id")}),(0,e.jsx)(l,{children:t("detail")})]})}),(0,e.jsxs)(K,{children:[N>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:H,style:Q})}),u.map(a=>{let r=m[a.index],S=re(r.detail);return(0,e.jsxs)(p,{"data-testid":"au-row",children:[(0,e.jsx)(d,{className:"text-muted-foreground tabular-nums",children:M(r.ts,"\u2014")}),(0,e.jsx)(d,{children:(0,e.jsx)(y,{variant:"secondary",children:r.op})}),(0,e.jsx)(d,{className:"font-medium",children:r.table??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(d,{className:"max-w-[20ch] truncate font-mono text-xs",children:r.id??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(d,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:S||void 0,children:S||(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},r.seq)}),w>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:H,style:X})})]})]})})})]})},"we");export{Ne as AuditPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as g,n as b}from"./chunk-
|
|
1
|
+
import{m as g,n as b}from"./chunk-AQKXMWNF.js";import{a as c,e as p,g as y,h as M,j as d}from"./chunk-3XIESWL4.js";var w=c(e=>{let t=0,s=0,r=0,a=0,i=0,l=0,o=0;for(let{metrics:n}of e){if(n===null){i+=1;continue}a+=1,t+=n.requests,s+=n.errors,r+=n.databaseSize??0,n.cache!==null&&(l+=n.cache.hits,o+=n.cache.hits+n.cache.misses)}return{failed:i,hitRate:o===0?null:l/o,reachable:a,totalDatabaseSize:r,totalErrors:s,totalRequests:t}},"u"),C=c((e,t)=>{let s=new Set,r=[];for(let a of["",e.trim(),...t])s.has(a)||(s.add(a),r.push(a));return r},"h"),v=c((e,t)=>{if(e.length===0)return 0;if(e.sort((r,a)=>r-a),t<=0)return e[0]??0;if(t>=100)return e.at(-1)??0;let s=Math.ceil(t/100*e.length)-1;return e[s]??0},"i"),N=c(e=>{let t=e.functions;if(!t||t.length===0)return{p90:0,p95:0};let s=1e3,r=[];for(let a of t){if(a.calls<=0)continue;let i=a.totalDurationMs/a.calls,l=Math.min(a.calls,s);for(let o=0;o<l;o+=1)r.push(i)}return r.length===0?{p90:0,p95:0}:{p90:v([...r],90),p95:v([...r],95)}},"f");var q=c(e=>e.map(t=>({...t,avgDurationMs:t.execCount>0?t.totalDurationMs/t.execCount:0})),"g");var x=p(y(),1);var m=p(M(),1);var S={value:{colors:{dark:["var(--foreground)"],light:["var(--foreground)"]},label:""}},T=c(e=>{let t=(0,x.c)(12),{ariaLabel:s,className:r,series:a,testId:i}=e;if(a.length<2)return null;let l;t[0]!==a?(l=a.slice(-40).map(D),t[0]=a,t[1]=l):l=t[1];let o=l,n;t[2]!==r?(n=d("h-6 w-[120px]",r),t[2]=r,t[3]=n):n=t[3];let f;t[4]===Symbol.for("react.memo_cache_sentinel")?(f=(0,m.jsx)(b,{dataKey:"value"}),t[4]=f):f=t[4];let u;t[5]!==o?(u=(0,m.jsx)(g,{animationType:"none",barCategoryGap:1,className:"h-full w-full",config:S,data:o,children:f}),t[5]=o,t[6]=u):u=t[6];let h;return t[7]!==s||t[8]!==n||t[9]!==u||t[10]!==i?(h=(0,m.jsx)("div",{"aria-label":s,className:n,"data-testid":i,role:"img",children:u}),t[7]=s,t[8]=n,t[9]=u,t[10]=i,t[11]=h):h=t[11],h},"S");function D(e,t){return{index:t,value:e}}c(D,"b");export{w as a,C as b,N as c,q as d,T as e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as S}from"./chunk-EQZTSISX.js";import{a as z}from"./chunk-54MMVNPT.js";import{a as W}from"./chunk-X665E2HU.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{a as B}from"./chunk-LFKCLLPT.js";import"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as R}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as H}from"./chunk-
|
|
1
|
+
import{a as S}from"./chunk-EQZTSISX.js";import{a as z}from"./chunk-54MMVNPT.js";import{a as W}from"./chunk-X665E2HU.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{a as B}from"./chunk-LFKCLLPT.js";import"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as R}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as H}from"./chunk-AHVDZWB3.js";import"./chunk-XXQUMVWH.js";import"./chunk-VORDESEQ.js";import"./chunk-QLQADHFE.js";import{a as L}from"./chunk-ERMTJYQF.js";import{c as E}from"./chunk-YGKR536O.js";import"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as A}from"./chunk-XQCVZAGU.js";import{a as O,b as U,c as q,d as F,e as T,f as D}from"./chunk-MIQTKZAR.js";import{a as _}from"./chunk-UZERI5YC.js";import{d as K}from"./chunk-OG4N2XHD.js";import"./chunk-QNUWWC3N.js";import{a as M,e as P,f as X,g as Y,h as Q}from"./chunk-3XIESWL4.js";var j=P(Y(),1),V=P(X(),1);var t=P(Q(),1);var G=M(i=>`${i.toString()} ms`,"F"),Z=M(i=>i.totalConnections===0&&i.shapePoke.passes===0&&i.whisper.passes===0,"G"),J=M(i=>{let e=(0,j.c)(48),{counters:o,includeTiming:a,prefix:l,t:r,title:v}=i,I=`${l}-section`,f;e[0]!==v?(f=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:v}),e[0]=v,e[1]=f):f=e[1];let y=`${l}-stats`,s;e[2]!==r?(s=r("Passes"),e[2]=r,e[3]=s):s=e[3];let n=`${l}-passes`,x;e[4]!==o.passes||e[5]!==s||e[6]!==n?(x=(0,t.jsx)(S,{label:s,testId:n,value:o.passes}),e[4]=o.passes,e[5]=s,e[6]=n,e[7]=x):x=e[7];let b;e[8]!==r?(b=r("Sockets iterated"),e[8]=r,e[9]=b):b=e[9];let N=`${l}-iterated`,c;e[10]!==o.socketsIterated||e[11]!==b||e[12]!==N?(c=(0,t.jsx)(S,{label:b,testId:N,value:o.socketsIterated}),e[10]=o.socketsIterated,e[11]=b,e[12]=N,e[13]=c):c=e[13];let d;e[14]!==r?(d=r("Delivered"),e[14]=r,e[15]=d):d=e[15];let g=`${l}-delivered`,m;e[16]!==o.socketsDelivered||e[17]!==d||e[18]!==g?(m=(0,t.jsx)(S,{label:d,testId:g,value:o.socketsDelivered}),e[16]=o.socketsDelivered,e[17]=d,e[18]=g,e[19]=m):m=e[19];let u;e[20]!==r?(u=r("Peak width"),e[20]=r,e[21]=u):u=e[21];let k=`${l}-peak`,p;e[22]!==o.peakSocketsIterated||e[23]!==u||e[24]!==k?(p=(0,t.jsx)(S,{label:u,testId:k,value:o.peakSocketsIterated}),e[22]=o.peakSocketsIterated,e[23]=u,e[24]=k,e[25]=p):p=e[25];let h;e[26]!==o.totalMs||e[27]!==a||e[28]!==l||e[29]!==r?(h=a&&(0,t.jsx)(S,{label:r("Total time"),testId:`${l}-total-ms`,value:G(o.totalMs)}),e[26]=o.totalMs,e[27]=a,e[28]=l,e[29]=r,e[30]=h):h=e[30];let C;e[31]!==o.maxMs||e[32]!==a||e[33]!==l||e[34]!==r?(C=a&&(0,t.jsx)(S,{label:r("Max time"),testId:`${l}-max-ms`,value:G(o.maxMs)}),e[31]=o.maxMs,e[32]=a,e[33]=l,e[34]=r,e[35]=C):C=e[35];let $;e[36]!==m||e[37]!==p||e[38]!==h||e[39]!==C||e[40]!==y||e[41]!==x||e[42]!==c?($=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":y,children:[x,c,m,p,h,C]}),e[36]=m,e[37]=p,e[38]=h,e[39]=C,e[40]=y,e[41]=x,e[42]=c,e[43]=$):$=e[43];let w;return e[44]!==I||e[45]!==$||e[46]!==f?(w=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":I,children:[f,$]}),e[44]=I,e[45]=$,e[46]=f,e[47]=w):w=e[47],w},"P"),pe=M(i=>{let e=(0,j.c)(32),{initialShardKey:o}=i,a=K(),[l,r]=(0,V.useState)(o??""),v;e[0]!==l?(v=l.trim(),e[0]=l,e[1]=v):v=e[1];let I=B(v,400),f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f={},e[2]=f):f=e[2];let y;e[3]!==I?(y={keepPreviousData:!0,shardKey:I},e[3]=I,e[4]=y):y=e[4];let{data:s,error:n,errorSource:x,refetch:b}=E(L.getFanoutMetrics,f,y);z(b,!0);let N;e[5]!==s?(N=s!==void 0&&Z(s),e[5]=s,e[6]=N):N=e[6];let c=N,d;e[7]!==l?(d=(0,t.jsx)(W,{onChange:r,testId:"fanout-shard-input",value:l}),e[7]=l,e[8]=d):d=e[8];let g;e[9]!==s||e[10]!==a?(g=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)(R,{"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)(R,{variant:"secondary",children:a("{count} connections",{count:s.totalConnections})}),(0,t.jsx)(R,{variant:"secondary",children:a("peak {count} subscribers",{count:s.peakSubscribers})})]}),e[9]=s,e[10]=a,e[11]=g):g=e[11];let m;e[12]!==d||e[13]!==g?(m=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[d,g]}),e[12]=d,e[13]=g,e[14]=m):m=e[14];let u;e[15]!==n||e[16]!==x?(u=n!==null&&(0,t.jsx)(H,{error:x,testId:"fanout-error"}),e[15]=n,e[16]=x,e[17]=u):u=e[17];let k;e[18]!==n||e[19]!==c||e[20]!==a?(k=n===null&&c&&(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[18]=n,e[19]=c,e[20]=a,e[21]=k):k=e[21];let p;e[22]!==n||e[23]!==c||e[24]!==s||e[25]!==a?(p=n===null&&s!==void 0&&!c&&(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)(O,{"data-testid":"fanout-topics-table",children:[(0,t.jsx)(U,{children:(0,t.jsxs)(F,{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)(q,{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)(J,{counters:s.shapePoke,includeTiming:!0,prefix:"fanout-poke",t:a,title:a("Shape pokes")}),(0,t.jsx)(J,{counters:s.whisper,includeTiming:!1,prefix:"fanout-whisper",t:a,title:a("Whisper broadcasts")})]})]}),e[22]=n,e[23]=c,e[24]=s,e[25]=a,e[26]=p):p=e[26];let h;return e[27]!==p||e[28]!==m||e[29]!==u||e[30]!==k?(h=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"fanout-panel",children:[m,u,k,p]}),e[27]=p,e[28]=m,e[29]=u,e[30]=k,e[31]=h):h=e[31],h},"pe");function ee(i){return(0,t.jsxs)(F,{"data-testid":"fanout-topic-row",children:[(0,t.jsx)(D,{className:"font-mono text-xs",children:i.topic}),(0,t.jsx)(D,{children:(0,t.jsx)(R,{variant:"outline",children:i.kind})}),(0,t.jsx)(D,{className:"text-right font-medium tabular-nums",children:i.subscribers})]},`${i.kind}:${i.topic}`)}M(ee,"J");export{pe as default};
|